Les sessions foncitonnent, reste à pouvoir les sauvegarder, soit via redis ou via type orm. Pour l'instant redis est un échec

This commit is contained in:
batche
2022-11-03 18:35:46 +01:00
parent 4622792534
commit 03b90690ce
1251 changed files with 35313 additions and 115 deletions

View File

@@ -21,6 +21,7 @@ services:
restart: unless-stopped
depends_on:
- postgresql
- redis
prod:
container_name: nestjs_api_prod
@@ -44,12 +45,13 @@ services:
NODE_ENV: "${NODE_ENV}"
depends_on:
- postgresql
- redis
postgresql:
container_name: nestjs_postgresql
image: postgres
ports:
- 5432:5432
expose:
- "5432"
networks:
- transcendance_network
volumes:
@@ -62,6 +64,19 @@ services:
POSTGRES_HOST: "${POSTGRES_HOST}"
POSTGRES_PORT: "${POSTGRES_PORT}"
redis:
container_name: nestjs_redis
image: redis:alpine
expose:
- "6379"
networks:
- transcendance_network
restart: unless-stopped
environment:
REDIS_HOST: "${REDIS_HOST}"
REDIS_PORT: "${REDIS_PORT}"
networks:
transcendance_network:
driver: bridge
@@ -69,6 +84,7 @@ networks:
volumes:
data_nest_back:
data_nest_postgresql:
data_nest_redis:

View File

@@ -1,10 +1,10 @@
import { AuthenticationService } from './authentication.service';
import { Response } from 'express';
export declare class AuthenticationController {
private readonly authService;
private authService;
constructor(authService: AuthenticationService);
login(): void;
redirect(res: Response): void;
redirect(response: Response): Promise<void>;
status(): string;
logout(): string;
}

View File

@@ -14,7 +14,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthenticationController = void 0;
const common_1 = require("@nestjs/common");
const guards_1 = require("./guards/guards");
const _42guards_1 = require("./guards/42guards");
const authentication_service_1 = require("./authentication.service");
let AuthenticationController = class AuthenticationController {
constructor(authService) {
@@ -23,9 +23,8 @@ let AuthenticationController = class AuthenticationController {
login() {
return;
}
redirect(res) {
console.log(`Redirection performed`);
res.sendStatus(200);
async redirect(response) {
response.send(200);
}
status() {
return 'status';
@@ -35,22 +34,23 @@ let AuthenticationController = class AuthenticationController {
}
};
__decorate([
(0, common_1.Get)('login'),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
(0, common_1.Get)(),
(0, common_1.UseGuards)(_42guards_1.FortyTwoAuthGuard),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)
], AuthenticationController.prototype, "login", null);
__decorate([
(0, common_1.Get)('redirect'),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
(0, common_1.UseGuards)(_42guards_1.FortyTwoAuthGuard),
__param(0, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
__metadata("design:returntype", Promise)
], AuthenticationController.prototype, "redirect", null);
__decorate([
(0, common_1.Get)('status'),
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)

View File

@@ -1 +1 @@
{"version":3,"file":"authentication.controller.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAiE;AACjE,4CAAoD;AACpD,qEAAiE;AAI1D,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAEpC,YAA6B,WAAkC;QAAlC,gBAAW,GAAX,WAAW,CAAuB;IAAG,CAAC;IAQnE,KAAK;QACJ,OAAO;IACR,CAAC;IASD,QAAQ,CAAQ,GAAa;QAC5B,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QACrC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IAQD,MAAM;QACL,OAAO,QAAQ,CAAC;IACjB,CAAC;IAOD,MAAM;QACL,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD,CAAA;AApCA;IAAC,IAAA,YAAG,EAAC,OAAO,CAAC;IACZ,IAAA,kBAAS,EAAC,0BAAiB,CAAC;;;;qDAG5B;AAOD;IAAC,IAAA,YAAG,EAAC,UAAU,CAAC;IACf,IAAA,kBAAS,EAAC,0BAAiB,CAAC;IACnB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;wDAGd;AAOD;IAAC,IAAA,YAAG,EAAC,QAAQ,CAAC;;;;sDAGb;AAMD;IAAC,IAAA,YAAG,EAAC,QAAQ,CAAC;;;;sDAGb;AA3CW,wBAAwB;IADpC,IAAA,mBAAU,EAAC,MAAM,CAAC;qCAGwB,8CAAqB;GAFnD,wBAAwB,CA4CpC;AA5CY,4DAAwB"}
{"version":3,"file":"authentication.controller.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsE;AACtE,iDAAyE;AACzE,qEAAiE;AAK1D,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAEpC,YAAoB,WAAkC;QAAlC,gBAAW,GAAX,WAAW,CAAuB;IAEhD,CAAC;IAQP,KAAK;QACJ,OAAQ;IACT,CAAC;IASK,AAAN,KAAK,CAAC,QAAQ,CAAQ,QAAmB;QACxC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IASD,MAAM;QACL,OAAO,QAAQ,CAAC;IACjB,CAAC;IAOD,MAAM;QACL,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD,CAAA;AApCA;IAAC,IAAA,YAAG,GAAE;IACL,IAAA,kBAAS,EAAC,6BAAiB,CAAC;;;;qDAG5B;AASK;IAFL,IAAA,YAAG,EAAC,UAAU,CAAC;IACf,IAAA,kBAAS,EAAC,6BAAiB,CAAC;IACb,WAAA,IAAA,YAAG,GAAE,CAAA;;;;wDAEpB;AAOD;IAAC,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,kBAAS,EAAC,6BAAiB,CAAC;;;;sDAG5B;AAMD;IAAC,IAAA,YAAG,EAAC,QAAQ,CAAC;;;;sDAGb;AA7CW,wBAAwB;IADpC,IAAA,mBAAU,EAAC,MAAM,CAAC;qCAGe,8CAAqB;GAF1C,wBAAwB,CA8CpC;AA9CY,4DAAwB"}

View File

@@ -15,14 +15,16 @@ const users_module_1 = require("../../users/users.module");
const users_service_1 = require("../../users/users.service");
const authentication_controller_1 = require("./authentication.controller");
const authentication_service_1 = require("./authentication.service");
const strategy_1 = require("./strategy/strategy");
const _42strategy_1 = require("./strategy/42strategy");
const serializer_1 = require("./utils/serializer");
let AuthenticationModule = class AuthenticationModule {
};
AuthenticationModule = __decorate([
(0, common_1.Module)({
imports: [typeorm_1.TypeOrmModule.forFeature([user_entity_1.User, friendship_entity_1.Friendship]), users_module_1.UsersModule],
providers: [authentication_service_1.AuthenticationService, strategy_1.FortyTwoStrategy, users_service_1.UsersService, serializer_1.SessionSerializer],
imports: [typeorm_1.TypeOrmModule.forFeature([user_entity_1.User, friendship_entity_1.Friendship]), users_module_1.UsersModule,
],
providers: [authentication_service_1.AuthenticationService, _42strategy_1.FortyTwoStrategy, users_service_1.UsersService, serializer_1.SessionSerializer,
],
exports: [authentication_service_1.AuthenticationService],
controllers: [authentication_controller_1.AuthenticationController],
})

View File

@@ -1 +1 @@
{"version":3,"file":"authentication.module.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,mFAAuE;AACvE,kEAAsD;AACtD,2DAAqD;AACrD,6DAAuD;AACvD,2EAAuE;AACvE,qEAAiE;AACjE,kDAAuD;AACvD,mDAAuD;AAQhD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oBAAoB;IANhC,IAAA,eAAM,EAAC;QACL,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,EAAE,8BAAU,CAAC,CAAC,EAAE,0BAAW,CAAC;QACpE,SAAS,EAAE,CAAC,8CAAqB,EAAE,2BAAgB,EAAE,4BAAY,EAAE,8BAAiB,CAAC;QACrF,OAAO,EAAE,CAAC,8CAAqB,CAAC;QAChC,WAAW,EAAE,CAAC,oDAAwB,CAAC;KACzC,CAAC;GACW,oBAAoB,CAAG;AAAvB,oDAAoB"}
{"version":3,"file":"authentication.module.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AAGxC,6CAAgD;AAChD,mFAAuE;AACvE,kEAAsD;AACtD,2DAAqD;AACrD,6DAAuD;AACvD,2EAAuE;AACvE,qEAAiE;AACjE,uDAAyD;AAEzD,mDAAuD;AAmBhD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oBAAoB;IAjBhC,IAAA,eAAM,EAAC;QACL,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,EAAE,8BAAU,CAAC,CAAC,EAAE,0BAAW;SASpE;QACC,SAAS,EAAE,CAAC,8CAAqB,EAAE,8BAAgB,EAAE,4BAAY,EAAE,8BAAiB;SAEtF;QACE,OAAO,EAAE,CAAC,8CAAqB,CAAC;QAChC,WAAW,EAAE,CAAC,oDAAwB,CAAC;KACzC,CAAC;GACW,oBAAoB,CAAG;AAAvB,oDAAoB"}

View File

@@ -1 +1 @@
{"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAK5C,6DAAuD;AAGhD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACjC,YACmB,WAAyB;QAAzB,gBAAW,GAAX,WAAW,CAAc;IACxC,CAAC;IAEL,KAAK,CAAC,YAAY,CAAC,cAA8B;QAChD,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;QACzD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACrF,IAAI,IAAI;YACP,OAAO,IAAI,CAAC;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,YAAqB;QACnC,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAClE,CAAC;CAED,CAAA;AAjBY,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAGoB,4BAAY;GAFhC,qBAAqB,CAiBjC;AAjBY,sDAAqB"}
{"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAG5C,6DAAuD;AAIhD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACjC,YACmB,WAAyB;QAAzB,gBAAW,GAAX,WAAW,CAAc;IAExC,CAAC;IAEL,KAAK,CAAC,YAAY,CAAC,cAA8B;QAChD,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;QACzD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACrF,IAAI,IAAI;YACP,OAAO,IAAI,CAAC;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,YAAqB;QACnC,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAClE,CAAC;CAMD,CAAA;AAtBY,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAGoB,4BAAY;GAFhC,qBAAqB,CAsBjC;AAtBY,sDAAqB"}

View File

@@ -0,0 +1,6 @@
import { ExecutionContext } from "@nestjs/common";
declare const FortyTwoAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
export declare class FortyTwoAuthGuard extends FortyTwoAuthGuard_base {
canActivate(context: ExecutionContext): Promise<any>;
}
export {};

View File

@@ -0,0 +1,24 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FortyTwoAuthGuard = void 0;
const common_1 = require("@nestjs/common");
const passport_1 = require("@nestjs/passport");
let FortyTwoAuthGuard = class FortyTwoAuthGuard extends (0, passport_1.AuthGuard)('42') {
async canActivate(context) {
const activate = (await super.canActivate(context));
const request = context.switchToHttp().getRequest();
await super.logIn(request);
return activate;
}
};
FortyTwoAuthGuard = __decorate([
(0, common_1.Injectable)()
], FortyTwoAuthGuard);
exports.FortyTwoAuthGuard = FortyTwoAuthGuard;
//# sourceMappingURL=42guards%20copy.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"42guards copy.js","sourceRoot":"","sources":["../../../../src/auth/42/guards/42guards copy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA2E;AAC3E,+CAA6C;AAGtC,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,IAAA,oBAAS,EAAC,IAAI,CAAC;IACrD,KAAK,CAAC,WAAW,CAAC,OAAyB;QAC1C,MAAM,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAY,CAAC;QAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD,CAAA;AAPY,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAO7B;AAPY,8CAAiB"}

View File

@@ -0,0 +1,9 @@
import { CanActivate, ExecutionContext } from "@nestjs/common";
declare const FortyTwoAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
export declare class FortyTwoAuthGuard extends FortyTwoAuthGuard_base {
canActivate(context: ExecutionContext): Promise<any>;
}
export declare class AuthenticateGuard implements CanActivate {
canActivate(context: ExecutionContext): Promise<boolean>;
}
export {};

View File

@@ -0,0 +1,35 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthenticateGuard = exports.FortyTwoAuthGuard = void 0;
const common_1 = require("@nestjs/common");
const passport_1 = require("@nestjs/passport");
let FortyTwoAuthGuard = class FortyTwoAuthGuard extends (0, passport_1.AuthGuard)('42') {
async canActivate(context) {
const activate = (await super.canActivate(context));
const request = context.switchToHttp().getRequest();
await super.logIn(request);
return activate;
}
};
FortyTwoAuthGuard = __decorate([
(0, common_1.Injectable)()
], FortyTwoAuthGuard);
exports.FortyTwoAuthGuard = FortyTwoAuthGuard;
let AuthenticateGuard = class AuthenticateGuard {
async canActivate(context) {
const request = context.switchToHttp().getRequest();
console.log(request.isAuthenticated());
return request.isAuthenticated();
}
};
AuthenticateGuard = __decorate([
(0, common_1.Injectable)()
], AuthenticateGuard);
exports.AuthenticateGuard = AuthenticateGuard;
//# sourceMappingURL=42guards.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"42guards.js","sourceRoot":"","sources":["../../../../src/auth/42/guards/42guards.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA2E;AAC3E,+CAA6C;AAGtC,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,IAAA,oBAAS,EAAC,IAAI,CAAC;IACrD,KAAK,CAAC,WAAW,CAAC,OAAyB;QAC1C,MAAM,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAY,CAAC;QAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD,CAAA;AAPY,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAO7B;AAPY,8CAAiB;AAUvB,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC7B,KAAK,CAAC,WAAW,CAAC,OAAyB;QAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;QACvC,OAAO,OAAO,CAAC,eAAe,EAAE,CAAC;IAClC,CAAC;CACD,CAAA;AANY,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAM7B;AANY,8CAAiB"}

View File

@@ -0,0 +1,4 @@
declare const JwtAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
export declare class JwtAuthGuard extends JwtAuthGuard_base {
}
export {};

View File

@@ -0,0 +1,18 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.JwtAuthGuard = void 0;
const common_1 = require("@nestjs/common");
const passport_1 = require("@nestjs/passport");
let JwtAuthGuard = class JwtAuthGuard extends (0, passport_1.AuthGuard)('jwt') {
};
JwtAuthGuard = __decorate([
(0, common_1.Injectable)()
], JwtAuthGuard);
exports.JwtAuthGuard = JwtAuthGuard;
//# sourceMappingURL=jwtGuards.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"jwtGuards.js","sourceRoot":"","sources":["../../../../src/auth/42/guards/jwtGuards.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA2E;AAC3E,+CAA6C;AAGtC,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,IAAA,oBAAS,EAAC,KAAK,CAAC;CAAG,CAAA;AAAxC,YAAY;IADxB,IAAA,mBAAU,GAAE;GACA,YAAY,CAA4B;AAAxC,oCAAY"}

View File

@@ -0,0 +1,9 @@
import { Profile } from "passport-42/lib";
import { AuthenticationService } from "../authentication.service";
declare const FortyTwoStrategy_base: new (...args: any[]) => any;
export declare class FortyTwoStrategy extends FortyTwoStrategy_base {
private authenticationService;
constructor(authenticationService: AuthenticationService);
validate(accessToken: string, refreshToken: string, profile: Profile, callbackURL: string): Promise<import("../../../users/entities/user.entity").User>;
}
export {};

View File

@@ -0,0 +1,42 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FortyTwoStrategy = void 0;
const lib_1 = require("passport-42/lib");
const passport_1 = require("@nestjs/passport");
const common_1 = require("@nestjs/common");
const authentication_service_1 = require("../authentication.service");
let FortyTwoStrategy = class FortyTwoStrategy extends (0, passport_1.PassportStrategy)(lib_1.Strategy, "42") {
constructor(authenticationService) {
super({
clientID: process.env.FORTYTWO_CLIENT_ID,
clientSecret: process.env.FORTYTWO_CLIENT_SECRET,
callbackURL: process.env.FORTYTWO_CALLBACK_URL,
scope: ["public"],
});
this.authenticationService = authenticationService;
}
async validate(accessToken, refreshToken, profile, callbackURL) {
console.log("Validate inside strategy.ts");
console.log(profile.id, profile.username, profile.phoneNumbers[0].value, profile.emails[0].value, profile.photos[0].value);
const userDTO = { fourtyTwoId: profile.id, username: profile.username, email: profile.emails[0].value, image_url: profile.photos[0].value };
const user = await this.authenticationService.validateUser(userDTO);
if (!user)
throw new common_1.UnauthorizedException();
return user;
}
};
FortyTwoStrategy = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [authentication_service_1.AuthenticationService])
], FortyTwoStrategy);
exports.FortyTwoStrategy = FortyTwoStrategy;
//# sourceMappingURL=42strategy.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"42strategy.js","sourceRoot":"","sources":["../../../../src/auth/42/strategy/42strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAoD;AACpD,+CAAoD;AACpD,2CAAmE;AACnE,sEAAkE;AAI3D,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,IAAA,2BAAgB,EAAC,cAAQ,EAAE,IAAI,CAAC;IACrE,YAAoB,qBAA4C;QAChE,KAAK,CAAC;YACJ,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;YACxC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;YAChD,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;YAC9C,KAAK,EAAE,CAAC,QAAQ,CAAC;SAClB,CAAC,CAAC;QANiB,0BAAqB,GAArB,qBAAqB,CAAuB;IAO/D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,WAAmB,EAAE,YAAoB,EAAE,OAAgB,EAAE,WAAmB;QAChG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC3H,MAAM,OAAO,GAAoB,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;QAC7J,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACpE,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACX,CAAC;CACF,CAAA;AAnBY,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAE+B,8CAAqB;GADpD,gBAAgB,CAmB5B;AAnBY,4CAAgB"}

View File

@@ -0,0 +1,13 @@
import { Strategy as PassportJwtStrategy } from "passport-jwt";
import { AuthenticationService } from "../authentication.service";
declare const JwtStrategy_base: new (...args: any[]) => PassportJwtStrategy;
export declare class JwtStrategy extends JwtStrategy_base {
private readonly authenticationService;
constructor(authenticationService: AuthenticationService);
validate(payload: any): Promise<{
fourtyTwoId: any;
username: any;
image_url: any;
}>;
}
export {};

View File

@@ -0,0 +1,39 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.JwtStrategy = void 0;
const common_1 = require("@nestjs/common");
const passport_1 = require("@nestjs/passport");
const passport_jwt_1 = require("passport-jwt");
const authentication_service_1 = require("../authentication.service");
let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy, "jwt") {
constructor(authenticationService) {
super({
jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
ignoreExpiration: false,
secretOrKey: process.env.JWT_SECRET,
});
this.authenticationService = authenticationService;
}
async validate(payload) {
console.log("Validate inside jwtStrategy.ts");
const user = await this.authenticationService.findUser(payload.fourtyTwoId);
if (!user)
throw new common_1.UnauthorizedException('You must be logged in to continue.');
return { fourtyTwoId: payload.fourtyTwoId, username: payload.username, image_url: payload.image_url };
}
};
JwtStrategy = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [authentication_service_1.AuthenticationService])
], JwtStrategy);
exports.JwtStrategy = JwtStrategy;
//# sourceMappingURL=jwtStrategy.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"jwtStrategy.js","sourceRoot":"","sources":["../../../../src/auth/42/strategy/jwtStrategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAmE;AACnE,+CAAoD;AACpD,+CAA2E;AAC3E,sEAAkE;AAI3D,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,IAAA,2BAAgB,EAAC,uBAAmB,EAAE,KAAK,CAAC;IAC5E,YAA6B,qBAA4C;QAExE,KAAK,CAAC;YACL,cAAc,EAAE,yBAAU,CAAC,2BAA2B,EAAE;YACxD,gBAAgB,EAAE,KAAK;YACvB,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;SACnC,CAAC,CAAC;QANyB,0BAAqB,GAArB,qBAAqB,CAAuB;IAOzE,CAAC;IACD,KAAK,CAAC,QAAQ,CAAC,OAAY;QAC1B,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QAC9C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAC5E,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,8BAAqB,CAAC,oCAAoC,CAAC,CAAC;QACvE,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;IACvG,CAAC;CACD,CAAA;AAhBY,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAEwC,8CAAqB;GAD7D,WAAW,CAgBvB;AAhBY,kCAAW"}

View File

@@ -1,3 +1,6 @@
export declare const constants: {
secret: string;
};
export declare const jwt_constants: {
secret: string;
};

View File

@@ -1,7 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.constants = void 0;
exports.jwt_constants = exports.constants = void 0;
exports.constants = {
secret: process.env.COOKIE_SECRET,
};
exports.jwt_constants = {
secret: process.env.JWT_SECRET,
};
//# sourceMappingURL=constant.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/conf/constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IACtB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;CACnC,CAAC"}
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/conf/constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IACtB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;CACnC,CAAC;AAEW,QAAA,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;CAChC,CAAC"}

View File

@@ -14,7 +14,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.FriendshipController = void 0;
const common_1 = require("@nestjs/common");
const guards_1 = require("../auth/42/guards/guards");
const jwtGuards_1 = require("../auth/42/guards/jwtGuards");
const create_friendship_dto_1 = require("./dto/create-friendship.dto");
const update_friendship_dto_1 = require("./dto/update-friendship.dto");
const friendship_service_1 = require("./friendship.service");
@@ -49,7 +49,7 @@ let FriendshipController = class FriendshipController {
};
__decorate([
(0, common_1.Get)(':userId/friends'),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
(0, common_1.UseGuards)(jwtGuards_1.JwtAuthGuard),
__param(0, (0, common_1.Param)('userId')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
@@ -57,7 +57,7 @@ __decorate([
], FriendshipController.prototype, "findEmpty", null);
__decorate([
(0, common_1.Get)(':userId/blocked'),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
(0, common_1.UseGuards)(jwtGuards_1.JwtAuthGuard),
__param(0, (0, common_1.Param)('userId')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
@@ -65,7 +65,7 @@ __decorate([
], FriendshipController.prototype, "findAllBlocked", null);
__decorate([
(0, common_1.Get)(':userId/pending'),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
(0, common_1.UseGuards)(jwtGuards_1.JwtAuthGuard),
__param(0, (0, common_1.Param)('userId')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
@@ -73,7 +73,7 @@ __decorate([
], FriendshipController.prototype, "findAllPendantFriendshipRequested", null);
__decorate([
(0, common_1.Get)(':userId/received'),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
(0, common_1.UseGuards)(jwtGuards_1.JwtAuthGuard),
__param(0, (0, common_1.Param)('userId')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
@@ -81,7 +81,7 @@ __decorate([
], FriendshipController.prototype, "findAllPendantFriendshipReceived", null);
__decorate([
(0, common_1.Get)(':userId/myfriends/:friendId'),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
(0, common_1.UseGuards)(jwtGuards_1.JwtAuthGuard),
__param(0, (0, common_1.Param)('friendId')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
@@ -90,7 +90,7 @@ __decorate([
__decorate([
(0, common_1.Post)(),
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
(0, common_1.UseGuards)(jwtGuards_1.JwtAuthGuard),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [create_friendship_dto_1.CreateFriendshipDto]),
@@ -98,7 +98,7 @@ __decorate([
], FriendshipController.prototype, "create", null);
__decorate([
(0, common_1.Patch)(':userId/received/:relationshipId'),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
(0, common_1.UseGuards)(jwtGuards_1.JwtAuthGuard),
__param(0, (0, common_1.Param)('friendId')),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
@@ -107,7 +107,7 @@ __decorate([
], FriendshipController.prototype, "update", null);
__decorate([
(0, common_1.Delete)(':userId/:friendId'),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
(0, common_1.UseGuards)(jwtGuards_1.JwtAuthGuard),
__param(0, (0, common_1.Param)('friendId')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),

View File

@@ -1 +1 @@
{"version":3,"file":"friendship.controller.js","sourceRoot":"","sources":["../../src/friendship/friendship.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmI;AACnI,qDAA8D;AAE9D,uEAAkE;AAClE,uEAAkE;AAElE,6DAAyD;AAGlD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAChC,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAG,CAAC;IAIrE,SAAS,CAAkB,MAAc;QACxC,OAAO,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IAID,cAAc,CAAkB,MAAc;QAC7C,OAAO,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;IAID,iCAAiC,CAAkB,MAAc;QAChE,OAAO,IAAI,CAAC,iBAAiB,CAAC,mCAAmC,CAAC,MAAM,CAAC,CAAC;IAC3E,CAAC;IAID,gCAAgC,CAAkB,MAAc;QAC/D,OAAO,IAAI,CAAC,iBAAiB,CAAC,oCAAoC,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;IAID,aAAa,CAAoB,QAAgB;QAChD,OAAO,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACvD,CAAC;IAKD,MAAM,CAAS,mBAAwC;QACtD,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAC3D,CAAC;IAID,MAAM,CAAoB,cAAsB,EAAU,EAAC,MAAM,EAAsB;QACtF,OAAO,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,cAAc,EAAE,EAAC,MAAM,EAAC,CAAC,CAAC;IAC1E,CAAC;IAID,MAAM,CAAoB,QAAgB;QACzC,OAAO,IAAI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,kBAAS,EAAC,0BAAiB,CAAC;IACrB,WAAA,IAAA,cAAK,EAAC,UAAU,CAAC,CAAA;;;;kDAExB;AAlDW,oBAAoB;IADhC,IAAA,mBAAU,EAAC,SAAS,CAAC;qCAE2B,sCAAiB;GADrD,oBAAoB,CAmDhC;AAnDY,oDAAoB"}
{"version":3,"file":"friendship.controller.js","sourceRoot":"","sources":["../../src/friendship/friendship.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAmI;AAEnI,2DAA4D;AAE5D,uEAAkE;AAClE,uEAAkE;AAElE,6DAAyD;AAGlD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAChC,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAG,CAAC;IAIrE,SAAS,CAAkB,MAAc;QACxC,OAAO,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IAID,cAAc,CAAkB,MAAc;QAC7C,OAAO,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;IAID,iCAAiC,CAAkB,MAAc;QAChE,OAAO,IAAI,CAAC,iBAAiB,CAAC,mCAAmC,CAAC,MAAM,CAAC,CAAC;IAC3E,CAAC;IAID,gCAAgC,CAAkB,MAAc;QAC/D,OAAO,IAAI,CAAC,iBAAiB,CAAC,oCAAoC,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;IAID,aAAa,CAAoB,QAAgB;QAChD,OAAO,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACvD,CAAC;IAKD,MAAM,CAAS,mBAAwC;QACtD,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAC3D,CAAC;IAID,MAAM,CAAoB,cAAsB,EAAU,EAAC,MAAM,EAAsB;QACtF,OAAO,IAAI,CAAC,iBAAiB,CAAC,gBAAgB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,GAAE,CAAA;;6CAAW,2CAAmB;;kDAEtF;AAED;IAAC,IAAA,eAAM,EAAC,mBAAmB,CAAC;IAC3B,IAAA,kBAAS,EAAC,wBAAY,CAAC;IAChB,WAAA,IAAA,cAAK,EAAC,UAAU,CAAC,CAAA;;;;kDAExB;AAlDW,oBAAoB;IADhC,IAAA,mBAAU,EAAC,SAAS,CAAC;qCAE2B,sCAAiB;GADrD,oBAAoB,CAmDhC;AAnDY,oDAAoB"}

View File

@@ -5,9 +5,28 @@ const common_1 = require("@nestjs/common");
const app_module_1 = require("./app.module");
const session = require("express-session");
const passport = require("passport");
const constant_1 = require("./conf/constant");
const redis_1 = require("redis");
const connectRedis = require("connect-redis");
async function bootstrap() {
const app = await core_1.NestFactory.create(app_module_1.AppModule);
const client = (0, redis_1.createClient)({
url: process.env.REDIS_URL,
});
const RedisStore = connectRedis(session);
client
.connect()
.then(async (res) => {
console.log('connected');
})
.catch((err) => {
console.log('err happened' + err);
});
client.on('error', (err) => {
console.log("Redis error: " + err);
});
client.on('connect', () => {
console.log("Redis connected");
});
app.useGlobalPipes(new common_1.ValidationPipe({
whitelist: true,
forbidNonWhitelisted: true,
@@ -22,9 +41,10 @@ async function bootstrap() {
cookie: {
maxAge: 3600000 * 24,
},
secret: constant_1.constants.secret,
secret: process.env.COOKIE_SECRET,
resave: false,
saveUninitialized: false,
store: new RedisStore({ client }),
}));
app.use(passport.initialize());
app.use(passport.session());

View File

@@ -1 +1 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,2CAAgD;AAChD,6CAAyC;AACzC,2CAA2C;AAC3C,qCAAqC;AACrC,8CAA4C;AAC5C,KAAK,UAAU,SAAS;IAEtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAGhD,GAAG,CAAC,cAAc,CACnB,IAAI,uBAAc,CAAC;QAElB,SAAS,EAAE,IAAI;QAE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AAE,CAAC,CAAC;IAC5B,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7E,CAAC;AACD,SAAS,EAAE,CAAC"}

View File

@@ -0,0 +1,2 @@
export declare class RedisModule {
}

View File

@@ -0,0 +1,26 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedisModule = void 0;
const common_1 = require("@nestjs/common");
const Redis = require("redis");
let RedisModule = class RedisModule {
};
RedisModule = __decorate([
(0, common_1.Module)({
providers: [
{
provide: 'REDIS',
useValue: Redis.createClient({ port: 6379, host: process.env.REDIS_HOST }),
},
],
exports: ['REDIS'],
})
], RedisModule);
exports.RedisModule = RedisModule;
//# sourceMappingURL=redis.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"redis.module.js","sourceRoot":"","sources":["../../src/redis/redis.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,+BAA+B;AAWxB,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IATvB,IAAA,eAAM,EAAC;QACP,SAAS,EAAE;YACV;gBACC,OAAO,EAAE,OAAO;gBAChB,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;aAC1E;SACD;QACD,OAAO,EAAE,CAAC,OAAO,CAAC;KAClB,CAAC;GACW,WAAW,CAAG;AAAd,kCAAW"}

File diff suppressed because one or more lines are too long

View File

@@ -6,8 +6,8 @@ export declare class UsersController {
private readonly usersService;
constructor(usersService: UsersService);
findAll(paginationquery: PaginationQueryDto): Promise<import("./entities/user.entity").User[]>;
findOne(id: string): Promise<import("./entities/user.entity").User>;
findOne(req: any): Promise<import("./entities/user.entity").User>;
create(createUsersDto: CreateUsersDto): Promise<import("./entities/user.entity").User>;
update(id: string, usersUpdateDto: UpdateUsersDto): Promise<import("./entities/user.entity").User>;
remove(id: string): Promise<import("./entities/user.entity").User>;
update(req: any, usersUpdateDto: UpdateUsersDto): Promise<import("./entities/user.entity").User>;
remove(req: any): Promise<import("./entities/user.entity").User>;
}

View File

@@ -14,7 +14,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.UsersController = void 0;
const common_1 = require("@nestjs/common");
const guards_1 = require("../auth/42/guards/guards");
const _42guards_1 = require("../auth/42/guards/42guards");
const pagination_query_dto_1 = require("../common/dto/pagination-query.dto");
const create_users_dto_1 = require("./dto/create-users.dto");
const update_users_dto_1 = require("./dto/update-users.dto");
@@ -26,39 +26,40 @@ let UsersController = class UsersController {
findAll(paginationquery) {
return this.usersService.findAll(paginationquery);
}
findOne(id) {
return this.usersService.findOne(id);
findOne(req) {
console.log('INSIDE USER CONTROLLER');
console.log(req.user);
return this.usersService.findOne(req.user.id);
}
create(createUsersDto) {
console.log(createUsersDto);
return this.usersService.create(createUsersDto);
}
update(id, usersUpdateDto) {
return this.usersService.update(id, usersUpdateDto);
update(req, usersUpdateDto) {
return this.usersService.update(req.user.id, usersUpdateDto);
}
remove(id) {
return this.usersService.remove(id);
remove(req) {
return this.usersService.remove(req.user.id);
}
};
__decorate([
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
(0, common_1.Get)('all'),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
__param(0, (0, common_1.Query)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [pagination_query_dto_1.PaginationQueryDto]),
__metadata("design:returntype", void 0)
], UsersController.prototype, "findAll", null);
__decorate([
(0, common_1.Get)(':id'),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
__param(0, (0, common_1.Param)('id')),
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
(0, common_1.Get)(),
__param(0, (0, common_1.Req)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], UsersController.prototype, "findOne", null);
__decorate([
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
(0, common_1.Post)(),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
@@ -66,20 +67,20 @@ __decorate([
__metadata("design:returntype", void 0)
], UsersController.prototype, "create", null);
__decorate([
(0, common_1.Patch)(':id'),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
__param(0, (0, common_1.Param)('id')),
(0, common_1.Patch)(),
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String, update_users_dto_1.UpdateUsersDto]),
__metadata("design:paramtypes", [Object, update_users_dto_1.UpdateUsersDto]),
__metadata("design:returntype", void 0)
], UsersController.prototype, "update", null);
__decorate([
(0, common_1.Delete)(':id'),
(0, common_1.UseGuards)(guards_1.FortyTwoAuthGuard),
__param(0, (0, common_1.Param)('id')),
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
__param(0, (0, common_1.Req)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], UsersController.prototype, "remove", null);
UsersController = __decorate([

View File

@@ -1 +1 @@
{"version":3,"file":"users.controller.js","sourceRoot":"","sources":["../../src/users/users.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAGwB;AACxB,qDAA8D;AAC9D,6EAAyE;AACzE,6DAAwD;AACxD,6DAAwD;AAExD,mDAA+C;AAIxC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC3B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAK3D,OAAO,CAAU,eAAoC;QAEpD,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACnD,CAAC;IAID,OAAO,CAAc,EAAU;QAC9B,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;IAKD,MAAM,CAAS,cAA+B;QAC7C,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACjD,CAAC;IAID,MAAM,CAAc,EAAU,EAAU,cAA8B;QACrE,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IACrD,CAAC;IAID,MAAM,CAAc,EAAU;QAC7B,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;CACD,CAAA;AAhCA;IAAC,IAAA,YAAG,EAAC,KAAK,CAAC;IACV,IAAA,kBAAS,EAAC,0BAAiB,CAAC;IACpB,WAAA,IAAA,cAAK,GAAE,CAAA;;qCAAmB,yCAAkB;;8CAGpD;AAED;IAAC,IAAA,YAAG,EAAC,KAAK,CAAC;IACV,IAAA,kBAAS,EAAC,0BAAiB,CAAC;IACpB,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;8CAEnB;AAED;IAAC,IAAA,aAAI,GAAE;IACN,IAAA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users.module.js","sourceRoot":"","sources":["../../src/users/users.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,mDAA+C;AAC/C,yDAAqD;AACrD,wDAA8C;AAC9C,6CAAgD;AAChD,gFAAsE;AAQ/D,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IANvB,IAAA,eAAM,EAAC;QACP,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,EAAE,8BAAU,EAAE,CAAC,CAAC;QACxD,SAAS,EAAE,CAAC,4BAAY,CAAC;QACzB,OAAO,EAAE,CAAC,4BAAY,CAAC;QACvB,WAAW,EAAE,CAAC,kCAAe,CAAC;KAC9B,CAAC;GACW,WAAW,CAAG;AAAd,kCAAW"}
{"version":3,"file":"users.module.js","sourceRoot":"","sources":["../../src/users/users.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,mDAA+C;AAC/C,yDAAqD;AACrD,wDAA8C;AAC9C,6CAAgD;AAChD,gFAAsE;AAU/D,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IANvB,IAAA,eAAM,EAAC;QACP,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,EAAE,8BAAU,EAAE,CAAC,CAAC;QACxD,SAAS,EAAE,CAAC,4BAAY,CAAC;QACzB,OAAO,EAAE,CAAC,4BAAY,CAAC;QACvB,WAAW,EAAE,CAAC,kCAAe,CAAC;KAC9B,CAAC;GACW,WAAW,CAAG;AAAd,kCAAW"}

View File

@@ -37,8 +37,6 @@ let UsersService = class UsersService {
return user;
}
async findOne(id) {
if (!(0, class_validator_1.isNumberString)(id))
throw new common_1.HttpException(`The requested user not found.`, common_1.HttpStatus.NOT_FOUND);
const user = await this.userRepository.findOneBy({ id: +id });
if (!user)
throw new common_1.NotFoundException(`The requested user not found.`);

View File

@@ -1 +1 @@
{"version":3,"file":"users.service.js","sour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AM,IAAI,CAAC,cAAc,CAAC,OAAO,iBAC5C,EAAE,EAAE,CAAC,EAAE,IACL,aAAa,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,sBAAa,CAAC,gCAAgC,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACtB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,sBAAa,CAAC,gCAAgC,EAAC,mBAAU,CAAC,SAAS,CAAC,CAAC;QAChF,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACD,CAAA;AAjEY,YAAY;IADxB,IAAA,mBAAU,GAAE;IAIX,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;IAEtB,WAAA,IAAA,0BAAgB,EAAC,8BAAU,CAAC,CAAA;qCADI,oBAAU;QAEJ,oBAAU;GANrC,YAAY,CAiExB;AAjEY,oCAAY"}

View File

@@ -1537,6 +1537,26 @@
}
}
},
"node_modules/@nestjs/jwt": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/@nestjs/jwt/-/jwt-9.0.0.tgz",
"integrity": "sha512-ZsXGY/wMYKzEhymw2+dxiwrHTRKIKrGszx6r2EjQqNLypdXMQu0QrujwZJ8k3+XQV4snmuJwwNakQoA2ILfq8w==",
"dependencies": {
"@types/jsonwebtoken": "8.5.8",
"jsonwebtoken": "8.5.1"
},
"peerDependencies": {
"@nestjs/common": "^8.0.0 || ^9.0.0"
}
},
"node_modules/@nestjs/jwt/node_modules/@types/jsonwebtoken": {
"version": "8.5.8",
"resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-8.5.8.tgz",
"integrity": "sha512-zm6xBQpFDIDM6o9r6HSgDeIcLy82TKWctCXEPbJJcXb5AKmi5BNNdLXneixK4lplX3PqIVcwLBCGE/kAGnlD4A==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@nestjs/mapped-types": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-1.2.0.tgz",
@@ -1857,6 +1877,59 @@
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/@redis/bloom": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.1.0.tgz",
"integrity": "sha512-9QovlxmpRtvxVbN0UBcv8WfdSMudNZZTFqCsnBszcQXqaZb/TVe30ScgGEO7u1EAIacTPAo7/oCYjYAxiHLanQ==",
"peerDependencies": {
"@redis/client": "^1.0.0"
}
},
"node_modules/@redis/client": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/@redis/client/-/client-1.3.1.tgz",
"integrity": "sha512-FKEHpOu7Q4+cuM6VWjA54988K5jkqOxvhvj2hEGSx086lvKwXyjzO7Lya7hcirZ0/Db8FLBJN7UXsJuyoNWPJg==",
"dependencies": {
"cluster-key-slot": "1.1.1",
"generic-pool": "3.9.0",
"yallist": "4.0.0"
},
"engines": {
"node": ">=14"
}
},
"node_modules/@redis/graph": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@redis/graph/-/graph-1.1.0.tgz",
"integrity": "sha512-16yZWngxyXPd+MJxeSr0dqh2AIOi8j9yXKcKCwVaKDbH3HTuETpDVPcLujhFYVPtYrngSco31BUcSa9TH31Gqg==",
"peerDependencies": {
"@redis/client": "^1.0.0"
}
},
"node_modules/@redis/json": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@redis/json/-/json-1.0.4.tgz",
"integrity": "sha512-LUZE2Gdrhg0Rx7AN+cZkb1e6HjoSKaeeW8rYnt89Tly13GBI5eP4CwDVr+MY8BAYfCg4/N15OUrtLoona9uSgw==",
"peerDependencies": {
"@redis/client": "^1.0.0"
}
},
"node_modules/@redis/search": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@redis/search/-/search-1.1.0.tgz",
"integrity": "sha512-NyFZEVnxIJEybpy+YskjgOJRNsfTYqaPbK/Buv6W2kmFNaRk85JiqjJZA5QkRmWvGbyQYwoO5QfDi2wHskKrQQ==",
"peerDependencies": {
"@redis/client": "^1.0.0"
}
},
"node_modules/@redis/time-series": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@redis/time-series/-/time-series-1.0.3.tgz",
"integrity": "sha512-OFp0q4SGrTH0Mruf6oFsHGea58u8vS/iI5+NpYdicaM+7BgqBZH8FFvNZ8rYYLrUO/QRqMq72NpXmxLVNcdmjA==",
"peerDependencies": {
"@redis/client": "^1.0.0"
}
},
"node_modules/@sinclair/typebox": {
"version": "0.24.47",
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.47.tgz",
@@ -2078,6 +2151,15 @@
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"dev": true
},
"node_modules/@types/jsonwebtoken": {
"version": "8.5.9",
"resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-8.5.9.tgz",
"integrity": "sha512-272FMnFGzAVMGtu9tkr29hRL6bZj4Zs1KZNeHLnKqAvp06tAIcarTMwOh8/8bz4FmKRcMxZhZNeUAQsNLoiPhg==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/mime": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz",
@@ -2103,6 +2185,17 @@
"@types/express": "*"
}
},
"node_modules/@types/passport-jwt": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/@types/passport-jwt/-/passport-jwt-3.0.7.tgz",
"integrity": "sha512-qRQ4qlww1Yhs3IaioDKrsDNmKy6gLDLgFsGwpCnc2YqWovO2Oxu9yCQdWHMJafQ7UIuOba4C4/TNXcGkQfEjlQ==",
"dev": true,
"dependencies": {
"@types/express": "*",
"@types/jsonwebtoken": "*",
"@types/passport-strategy": "*"
}
},
"node_modules/@types/passport-local": {
"version": "1.0.34",
"resolved": "https://registry.npmjs.org/@types/passport-local/-/passport-local-1.0.34.tgz",
@@ -2140,6 +2233,15 @@
"resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz",
"integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw=="
},
"node_modules/@types/redis": {
"version": "4.0.11",
"resolved": "https://registry.npmjs.org/@types/redis/-/redis-4.0.11.tgz",
"integrity": "sha512-bI+gth8La8Wg/QCR1+V1fhrL9+LZUSWfcqpOj2Kc80ZQ4ffbdL173vQd5wovmoV9i071FU9oP2g6etLuEwb6Rg==",
"deprecated": "This is a stub types definition. redis provides its own type definitions, so you do not need this installed.",
"dependencies": {
"redis": "*"
}
},
"node_modules/@types/semver": {
"version": "7.3.12",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.12.tgz",
@@ -3057,6 +3159,11 @@
"ieee754": "^1.1.13"
}
},
"node_modules/buffer-equal-constant-time": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="
},
"node_modules/buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
@@ -3365,6 +3472,14 @@
"node": ">=0.8"
}
},
"node_modules/cluster-key-slot": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.1.tgz",
"integrity": "sha512-rwHwUfXL40Chm1r08yrhU3qpUvdVlgkKNeyeGPOxnW8/SyVDvgRaed/Uz54AqWNaTCAThlj6QAs3TZcKI0xDEw==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/co": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
@@ -3443,6 +3558,14 @@
"typedarray": "^0.0.6"
}
},
"node_modules/connect-redis": {
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/connect-redis/-/connect-redis-6.1.3.tgz",
"integrity": "sha512-aaNluLlAn/3JPxRwdzw7lhvEoU6Enb+d83xnokUNhC9dktqBoawKWL+WuxinxvBLTz6q9vReTnUDnUslaz74aw==",
"engines": {
"node": ">=12"
}
},
"node_modules/consola": {
"version": "2.15.3",
"resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz",
@@ -3709,6 +3832,14 @@
"node": ">=12"
}
},
"node_modules/ecdsa-sig-formatter": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
"integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
"dependencies": {
"safe-buffer": "^5.0.1"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
@@ -4633,6 +4764,14 @@
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
"node_modules/generic-pool": {
"version": "3.9.0",
"resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.9.0.tgz",
"integrity": "sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==",
"engines": {
"node": ">= 4"
}
},
"node_modules/gensync": {
"version": "1.0.0-beta.2",
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
@@ -6111,6 +6250,54 @@
"graceful-fs": "^4.1.6"
}
},
"node_modules/jsonwebtoken": {
"version": "8.5.1",
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz",
"integrity": "sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w==",
"dependencies": {
"jws": "^3.2.2",
"lodash.includes": "^4.3.0",
"lodash.isboolean": "^3.0.3",
"lodash.isinteger": "^4.0.4",
"lodash.isnumber": "^3.0.3",
"lodash.isplainobject": "^4.0.6",
"lodash.isstring": "^4.0.1",
"lodash.once": "^4.0.0",
"ms": "^2.1.1",
"semver": "^5.6.0"
},
"engines": {
"node": ">=4",
"npm": ">=1.4.28"
}
},
"node_modules/jsonwebtoken/node_modules/semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"bin": {
"semver": "bin/semver"
}
},
"node_modules/jwa": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz",
"integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==",
"dependencies": {
"buffer-equal-constant-time": "1.0.1",
"ecdsa-sig-formatter": "1.0.11",
"safe-buffer": "^5.0.1"
}
},
"node_modules/jws": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz",
"integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==",
"dependencies": {
"jwa": "^1.4.1",
"safe-buffer": "^5.0.1"
}
},
"node_modules/kleur": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
@@ -6182,6 +6369,36 @@
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"node_modules/lodash.includes": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
"integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w=="
},
"node_modules/lodash.isboolean": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz",
"integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg=="
},
"node_modules/lodash.isinteger": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz",
"integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA=="
},
"node_modules/lodash.isnumber": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
"integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw=="
},
"node_modules/lodash.isplainobject": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
"integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA=="
},
"node_modules/lodash.isstring": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
"integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw=="
},
"node_modules/lodash.memoize": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",
@@ -6194,6 +6411,11 @@
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
"dev": true
},
"node_modules/lodash.once": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
"integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg=="
},
"node_modules/log-symbols": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",
@@ -6841,6 +7063,15 @@
"node": ">= 6.0.0"
}
},
"node_modules/passport-jwt": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/passport-jwt/-/passport-jwt-4.0.0.tgz",
"integrity": "sha512-BwC0n2GP/1hMVjR4QpnvqA61TxenUMlmfNjYNgK0ZAs0HK4SOQkHcSv4L328blNTLtHq7DbmvyNJiH+bn6C5Mg==",
"dependencies": {
"jsonwebtoken": "^8.2.0",
"passport-strategy": "^1.0.0"
}
},
"node_modules/passport-local": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/passport-local/-/passport-local-1.0.0.tgz",
@@ -7373,6 +7604,19 @@
"node": ">= 0.10"
}
},
"node_modules/redis": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/redis/-/redis-4.4.0.tgz",
"integrity": "sha512-tQyFG6O9iewLxxHYRyirJNklhe2QI7M/0o8q0jk7D9Z/Cxh/7oZrQyHKyjWz0TkkCls8ool/xvhL9K8zRnkaYQ==",
"dependencies": {
"@redis/bloom": "1.1.0",
"@redis/client": "1.3.1",
"@redis/graph": "1.1.0",
"@redis/json": "1.0.4",
"@redis/search": "1.1.0",
"@redis/time-series": "1.0.3"
}
},
"node_modules/reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
@@ -9097,8 +9341,7 @@
"node_modules/yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
},
"node_modules/yaml": {
"version": "1.10.2",

View File

@@ -0,0 +1,58 @@
version: 2
aliases:
- &restore-cache
restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- &install-deps
run:
name: Install dependencies
command: npm ci
- &build-packages
run:
name: Build
command: npm run build
jobs:
build:
working_directory: ~/nest
docker:
- image: circleci/node:17
steps:
- checkout
- run:
name: Update NPM version
command: 'sudo npm install -g npm@latest'
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install dependencies
command: npm ci
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: Build
command: npm run build
test:
working_directory: ~/nest
docker:
- image: circleci/node:17
steps:
- checkout
- *restore-cache
- *install-deps
- run:
name: Unit tests
command: npm run test
workflows:
version: 2
build-and-test:
jobs:
- build
- test:
requires:
- build

View File

@@ -0,0 +1,28 @@
{
"extends": ["@commitlint/config-angular"],
"rules": {
"subject-case": [
2,
"always",
["sentence-case", "start-case", "pascal-case", "upper-case", "lower-case"]
],
"type-enum": [
2,
"always",
[
"build",
"chore",
"ci",
"docs",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test",
"sample"
]
]
}
}

View File

@@ -0,0 +1,2 @@
tests/**
lib/**/*.spec.ts

View File

@@ -0,0 +1,26 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/@typescript-eslint',
],
root: true,
env: {
node: true,
jest: true,
},
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
},
};

View File

@@ -0,0 +1,106 @@
name: "\U0001F41B Bug Report"
description: "If something isn't working as expected \U0001F914"
labels: ["needs triage", "bug"]
body:
- type: markdown
attributes:
value: |
## :warning: We use GitHub Issues to track bug reports, feature requests and regressions
If you are not sure that your issue is a bug, you could:
- use our [Discord community](https://discord.gg/NestJS)
- use [StackOverflow using the tag `nestjs`](https://stackoverflow.com/questions/tagged/nestjs)
- If it's just a quick question you can ping [our Twitter](https://twitter.com/nestframework)
**NOTE:** You don't need to answer questions that you know that aren't relevant.
---
- type: checkboxes
attributes:
label: "Is there an existing issue for this?"
description: "Please search [here](./?q=is%3Aissue) to see if an issue already exists for the bug you encountered"
options:
- label: "I have searched the existing issues"
required: true
- type: textarea
validations:
required: true
attributes:
label: "Current behavior"
description: "How the issue manifests?"
- type: input
validations:
required: true
attributes:
label: "Minimum reproduction code"
description: "An URL to some git repository or gist that reproduces this issue. [Wtf is a minimum reproduction?](https://jmcdo29.github.io/wtf-is-a-minimum-reproduction)"
placeholder: "https://github.com/..."
- type: textarea
attributes:
label: "Steps to reproduce"
description: |
How the issue manifests?
You could leave this blank if you alread write this in your reproduction code/repo
placeholder: |
1. `npm i`
2. `npm start:dev`
3. See error...
- type: textarea
validations:
required: true
attributes:
label: "Expected behavior"
description: "A clear and concise description of what you expected to happend (or code)"
- type: markdown
attributes:
value: |
---
- type: input
validations:
required: true
attributes:
label: "Package version"
description: |
Which version of `@nestjs/jwt` are you using?
**Tip**: Make sure that all of yours `@nestjs/*` dependencies are in sync!
placeholder: "8.1.3"
- type: input
attributes:
label: "NestJS version"
description: "Which version of `@nestjs/core` are you using?"
placeholder: "8.1.3"
- type: input
attributes:
label: "Node.js version"
description: "Which version of Node.js are you using?"
placeholder: "14.17.6"
- type: checkboxes
attributes:
label: "In which operating systems have you tested?"
options:
- label: macOS
- label: Windows
- label: Linux
- type: markdown
attributes:
value: |
---
- type: textarea
attributes:
label: "Other"
description: |
Anything else relevant? eg: Logs, OS version, IDE, package manager, etc.
**Tip:** You can attach images, recordings or log files by clicking this area to highlight it and then dragging files in

View File

@@ -0,0 +1,52 @@
name: "\U0001F680 Feature Request"
description: "I have a suggestion \U0001F63B!"
labels: ["feature"]
body:
- type: markdown
attributes:
value: |
## :warning: We use GitHub Issues to track bug reports, feature requests and regressions
If you are not sure that your issue is a bug, you could:
- use our [Discord community](https://discord.gg/NestJS)
- use [StackOverflow using the tag `nestjs`](https://stackoverflow.com/questions/tagged/nestjs)
- If it's just a quick question you can ping [our Twitter](https://twitter.com/nestframework)
---
- type: checkboxes
attributes:
label: "Is there an existing issue that is already proposing this?"
description: "Please search [here](./?q=is%3Aissue) to see if an issue already exists for the feature you are requesting"
options:
- label: "I have searched the existing issues"
required: true
- type: textarea
validations:
required: true
attributes:
label: "Is your feature request related to a problem? Please describe it"
description: "A clear and concise description of what the problem is"
placeholder: |
I have an issue when ...
- type: textarea
validations:
required: true
attributes:
label: "Describe the solution you'd like"
description: "A clear and concise description of what you want to happen. Add any considered drawbacks"
- type: textarea
attributes:
label: "Teachability, documentation, adoption, migration strategy"
description: "If you can, explain how users will be able to use this and possibly write out a version the docs. Maybe a screenshot or design?"
- type: textarea
validations:
required: true
attributes:
label: "What is the motivation / use case for changing the behavior?"
description: "Describe the motivation or the concrete use case"

View File

@@ -0,0 +1,78 @@
name: "\U0001F4A5 Regression"
description: "Report an unexpected behavior while upgrading your Nest application!"
labels: ["needs triage"]
body:
- type: markdown
attributes:
value: |
## :warning: We use GitHub Issues to track bug reports, feature requests and regressions
If you are not sure that your issue is a bug, you could:
- use our [Discord community](https://discord.gg/NestJS)
- use [StackOverflow using the tag `nestjs`](https://stackoverflow.com/questions/tagged/nestjs)
- If it's just a quick question you can ping [our Twitter](https://twitter.com/nestframework)
**NOTE:** You don't need to answer questions that you know that aren't relevant.
---
- type: checkboxes
attributes:
label: "Did you read the migration guide?"
description: "Check out the [migration guide here](https://docs.nestjs.com/migration-guide)!"
options:
- label: "I have read the whole migration guide"
required: false
- type: checkboxes
attributes:
label: "Is there an existing issue that is already proposing this?"
description: "Please search [here](./?q=is%3Aissue) to see if an issue already exists for the feature you are requesting"
options:
- label: "I have searched the existing issues"
required: true
- type: input
attributes:
label: "Potential Commit/PR that introduced the regression"
description: "If you have time to investigate, what PR/date/version introduced this issue"
placeholder: "PR #123 or commit 5b3c4a4"
- type: input
attributes:
label: "Versions"
description: "From which version of `@nestjs/jwt` to which version you are upgrading"
placeholder: "8.1.0 -> 8.1.3"
- type: textarea
validations:
required: true
attributes:
label: "Describe the regression"
description: "A clear and concise description of what the regression is"
- type: textarea
attributes:
label: "Minimum reproduction code"
description: |
Please share a git repo, a gist, or step-by-step instructions. [Wtf is a minimum reproduction?](https://jmcdo29.github.io/wtf-is-a-minimum-reproduction)
**Tip:** If you leave a minimum repository, we will understand your issue faster!
value: |
```ts
```
- type: textarea
validations:
required: true
attributes:
label: "Expected behavior"
description: "A clear and concise description of what you expected to happend (or code)"
- type: textarea
attributes:
label: "Other"
description: |
Anything else relevant? eg: Logs, OS version, IDE, package manager, etc.
**Tip:** You can attach images, recordings or log files by clicking this area to highlight it and then dragging files in

View File

@@ -0,0 +1,7 @@
## To encourage contributors to use issue templates, we don't allow blank issues
blank_issues_enabled: false
contact_links:
- name: "\u2753 Discord Community of NestJS"
url: "https://discord.gg/NestJS"
about: "Please ask support questions or discuss suggestions/enhancements here."

View File

@@ -0,0 +1,37 @@
## PR Checklist
Please check if your PR fulfills the following requirements:
- [ ] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
## PR Type
What kind of change does this PR introduce?
<!-- Please check the one that applies to this PR using "x". -->
- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Other... Please describe:
## What is the current behavior?
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->
Issue Number: N/A
## What is the new behavior?
## Does this PR introduce a breaking change?
- [ ] Yes
- [ ] No
<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. -->
## Other information

View File

@@ -0,0 +1,8 @@
{
"git": {
"commitMessage": "chore(): release v${version}"
},
"github": {
"release": true
}
}

View File

@@ -0,0 +1,253 @@
# Contributing to Nest
We would love for you to contribute to Nest and help make it even better than it is
today! As a contributor, here are the guidelines we would like you to follow:
- [Code of Conduct](#coc)
- [Question or Problem?](#question)
- [Issues and Bugs](#issue)
- [Feature Requests](#feature)
- [Submission Guidelines](#submit)
- [Coding Rules](#rules)
- [Commit Message Guidelines](#commit)
<!-- - [Signing the CLA](#cla) -->
<!-- ## <a name="coc"></a> Code of Conduct
Help us keep Nest open and inclusive. Please read and follow our [Code of Conduct][coc]. -->
## <a name="question"></a> Got a Question or Problem?
**Do not open issues for general support questions as we want to keep GitHub issues for bug reports and feature requests.** You've got much better chances of getting your question answered on [Stack Overflow](https://stackoverflow.com/questions/tagged/nestjs) where the questions should be tagged with tag `nestjs`.
Stack Overflow is a much better place to ask questions since:
<!-- - there are thousands of people willing to help on Stack Overflow [maybe one day] -->
- questions and answers stay available for public viewing so your question / answer might help someone else
- Stack Overflow's voting system assures that the best answers are prominently visible.
To save your and our time, we will systematically close all issues that are requests for general support and redirect people to Stack Overflow.
If you would like to chat about the question in real-time, you can reach out via [our gitter channel][gitter].
## <a name="issue"></a> Found a Bug?
If you find a bug in the source code, you can help us by
[submitting an issue](#submit-issue) to our [GitHub Repository][github]. Even better, you can
[submit a Pull Request](#submit-pr) with a fix.
## <a name="feature"></a> Missing a Feature?
You can *request* a new feature by [submitting an issue](#submit-issue) to our GitHub
Repository. If you would like to *implement* a new feature, please submit an issue with
a proposal for your work first, to be sure that we can use it.
Please consider what kind of change it is:
* For a **Major Feature**, first open an issue and outline your proposal so that it can be
discussed. This will also allow us to better coordinate our efforts, prevent duplication of work,
and help you to craft the change so that it is successfully accepted into the project. For your issue name, please prefix your proposal with `[discussion]`, for example "[discussion]: your feature idea".
* **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr).
## <a name="submit"></a> Submission Guidelines
### <a name="submit-issue"></a> Submitting an Issue
Before you submit an issue, please search the issue tracker, maybe an issue for your problem already exists and the discussion might inform you of workarounds readily available.
We want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce and confirm it. In order to reproduce bugs we will systematically ask you to provide a minimal reproduction scenario using a repository or [Gist](https://gist.github.com/). Having a live, reproducible scenario gives us wealth of important information without going back & forth to you with additional questions like:
- version of NestJS used
- 3rd-party libraries and their versions
- and most importantly - a use-case that fails
<!--
// TODO we need to create a playground, similar to plunkr
A minimal reproduce scenario using a repository or Gist allows us to quickly confirm a bug (or point out coding problem) as well as confirm that we are fixing the right problem. If neither of these are not a suitable way to demonstrate the problem (for example for issues related to our npm packaging), please create a standalone git repository demonstrating the problem. -->
<!-- We will be insisting on a minimal reproduce scenario in order to save maintainers time and ultimately be able to fix more bugs. Interestingly, from our experience users often find coding problems themselves while preparing a minimal plunk. We understand that sometimes it might be hard to extract essentials bits of code from a larger code-base but we really need to isolate the problem before we can fix it. -->
Unfortunately, we are not able to investigate / fix bugs without a minimal reproduction, so if we don't hear back from you we are going to close an issue that don't have enough info to be reproduced.
You can file new issues by filling out our [new issue form](https://github.com/nestjs/nest/issues/new).
### <a name="submit-pr"></a> Submitting a Pull Request (PR)
Before you submit your Pull Request (PR) consider the following guidelines:
1. Search [GitHub](https://github.com/nestjs/nest/pulls) for an open or closed PR
that relates to your submission. You don't want to duplicate effort.
<!-- 1. Please sign our [Contributor License Agreement (CLA)](#cla) before sending PRs.
We cannot accept code without this. -->
1. Fork the nestjs/nest repo.
1. Make your changes in a new git branch:
```shell
git checkout -b my-fix-branch master
```
1. Create your patch, **including appropriate test cases**.
1. Follow our [Coding Rules](#rules).
1. Run the full Nest test suite, as described in the [developer documentation][dev-doc],
and ensure that all tests pass.
1. Commit your changes using a descriptive commit message that follows our
[commit message conventions](#commit). Adherence to these conventions
is necessary because release notes are automatically generated from these messages.
```shell
git commit -a
```
Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files.
1. Push your branch to GitHub:
```shell
git push origin my-fix-branch
```
1. In GitHub, send a pull request to `nestjs:master`.
* If we suggest changes then:
* Make the required updates.
* Re-run the Nest test suites to ensure tests are still passing.
* Rebase your branch and force push to your GitHub repository (this will update your Pull Request):
```shell
git rebase master -i
git push -f
```
That's it! Thank you for your contribution!
#### After your pull request is merged
After your pull request is merged, you can safely delete your branch and pull the changes
from the main (upstream) repository:
* Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows:
```shell
git push origin --delete my-fix-branch
```
* Check out the master branch:
```shell
git checkout master -f
```
* Delete the local branch:
```shell
git branch -D my-fix-branch
```
* Update your master with the latest upstream version:
```shell
git pull --ff upstream master
```
## <a name="rules"></a> Coding Rules
To ensure consistency throughout the source code, keep these rules in mind as you are working:
* All features or bug fixes **must be tested** by one or more specs (unit-tests).
<!--
// We're working on auto-documentation.
* All public API methods **must be documented**. (Details TBC). -->
* We follow [Google's JavaScript Style Guide][js-style-guide], but wrap all code at
**100 characters**. An automated formatter is available, see
[DEVELOPER.md](docs/DEVELOPER.md#clang-format).
## <a name="commit"></a> Commit Message Guidelines
We have very precise rules over how our git commit messages can be formatted. This leads to **more
readable messages** that are easy to follow when looking through the **project history**. But also,
we use the git commit messages to **generate the Nest change log**.
### Commit Message Format
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
format that includes a **type**, a **scope** and a **subject**:
```
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```
The **header** is mandatory and the **scope** of the header is optional.
Any line of the commit message cannot be longer 100 characters! This allows the message to be easier
to read on GitHub as well as in various git tools.
Footer should contain a [closing reference to an issue](https://help.github.com/articles/closing-issues-via-commit-messages/) if any.
Samples: (even more [samples](https://github.com/nestjs/nest/commits/master))
```
docs(changelog) update change log to beta.5
```
```
fix(@nestjs/core) need to depend on latest rxjs and zone.js
The version in our package.json gets copied to the one we publish, and users need the latest of these.
```
### Revert
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.
### Type
Must be one of the following:
* **build**: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
* **chroe**: Updating tasks etc; no production code change
* **ci**: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
* **docs**: Documentation only changes
* **feat**: A new feature
* **fix**: A bug fix
* **perf**: A code change that improves performance
* **refactor**: A code change that neither fixes a bug nor adds a feature
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
* **test**: Adding missing tests or correcting existing tests
### Subject
The subject contains succinct description of the change:
* use the imperative, present tense: "change" not "changed" nor "changes"
* don't capitalize first letter
* no dot (.) at the end
### Body
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.
### Footer
The footer should contain any information about **Breaking Changes** and is also the place to
reference GitHub issues that this commit **Closes**.
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
A detailed explanation can be found in this [document][commit-message-format].
<!-- ## <a name="cla"></a> Signing the CLA
Please sign our Contributor License Agreement (CLA) before sending pull requests. For any code
changes to be accepted, the CLA must be signed. It's a quick process, we promise!
* For individuals we have a [simple click-through form][individual-cla].
* For corporations we'll need you to
[print, sign and one of scan+email, fax or mail the form][corporate-cla]. -->
<!-- [angular-group]: https://groups.google.com/forum/#!forum/angular -->
<!-- [coc]: https://github.com/angular/code-of-conduct/blob/master/CODE_OF_CONDUCT.md -->
[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#
[corporate-cla]: http://code.google.com/legal/corporate-cla-v1.0.html
[dev-doc]: https://github.com/nestjs/nest/blob/master/docs/DEVELOPER.md
[github]: https://github.com/nestjs/nest
[gitter]: https://gitter.im/nestjs/nest
[individual-cla]: http://code.google.com/legal/individual-cla-v1.0.html
[js-style-guide]: https://google.github.io/styleguide/jsguide.html
[jsfiddle]: http://jsfiddle.net
[plunker]: http://plnkr.co/edit
[runnable]: http://runnable.com
<!-- [stackoverflow]: http://stackoverflow.com/questions/tagged/angular -->

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018-2022 Kamil Mysliwiec <https://kamilmysliwiec.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,197 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
</p>
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
[travis-url]: https://travis-ci.org/nestjs/nest
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
[linux-url]: https://travis-ci.org/nestjs/nest
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-dc3d53.svg"/></a>
<a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
## Description
JWT utilities module for [Nest](https://github.com/nestjs/nest) based on the [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) package.
## Installation
```bash
$ npm i --save @nestjs/jwt
```
## Usage
Import `JwtModule`:
```typescript
@Module({
imports: [JwtModule.register({ secret: 'hard!to-guess_secret' })],
providers: [...],
})
export class AuthModule {}
```
Inject `JwtService`:
```typescript
@Injectable()
export class AuthService {
constructor(private readonly jwtService: JwtService) {}
}
```
## Secret / Encryption Key options
If you want to control secret and key management dynamically you can use the `secretOrKeyProvider` function for that purpose.
```typescript
JwtModule.register({
/* Secret has precedence over keys */
secret: 'hard!to-guess_secret',
/* public key used in asymmetric algorithms (required if non other secrets present) */
publicKey: '...',
/* private key used in asymmetric algorithms (required if non other secrets present) */
privateKey: '...',
/* Dynamic key provider has precedence over static secret or pub/private keys */
secretOrKeyProvider: (
requestType: JwtSecretRequestType,
tokenOrPayload: string | Object | Buffer,
verifyOrSignOrOptions?: jwt.VerifyOptions | jwt.SignOptions
) => {
switch (requestType) {
case JwtSecretRequestType.SIGN:
// retrieve signing key dynamically
return 'privateKey';
case JwtSecretRequestType.VERIFY:
// retrieve public key for verification dynamically
return 'publicKey';
default:
// retrieve secret dynamically
return 'hard!to-guess_secret';
}
},
});
```
## Async options
Quite often you might want to asynchronously pass your module options instead of passing them beforehand. In such case, use `registerAsync()` method, that provides a couple of various ways to deal with async data.
**1. Use factory**
```typescript
JwtModule.registerAsync({
useFactory: () => ({
secret: 'hard!to-guess_secret'
})
});
```
Obviously, our factory behaves like every other one (might be `async` and is able to inject dependencies through `inject`).
```typescript
JwtModule.registerAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
secret: configService.get<string>('SECRET'),
}),
inject: [ConfigService],
}),
```
**2. Use class**
```typescript
JwtModule.registerAsync({
useClass: JwtConfigService
});
```
Above construction will instantiate `JwtConfigService` inside `JwtModule` and will leverage it to create options object.
```typescript
class JwtConfigService implements JwtOptionsFactory {
createJwtOptions(): JwtModuleOptions {
return {
secret: 'hard!to-guess_secret'
};
}
}
```
**3. Use existing**
```typescript
JwtModule.registerAsync({
imports: [ConfigModule],
useExisting: ConfigService,
}),
```
It works the same as `useClass` with one critical difference - `JwtModule` will lookup imported modules to reuse already created `ConfigService`, instead of instantiating it on its own.
## API Spec
The `JwtService` uses [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) underneath.
#### jwtService.sign(payload: string | Object | Buffer, options?: JwtSignOptions): string
The sign method is an implementation of jsonwebtoken `.sign()`. Differing from jsonwebtoken it also allows an additional `secret`, `privateKey`, and `publicKey` properties on `options` to override options passed in from the module. It only overrides the `secret`, `publicKey` or `privateKey` though not a `secretOrKeyProvider`.
#### jwtService.signAsync(payload: string | Object | Buffer, options?: JwtSignOptions): Promise\<string\>
The asynchronous `.sign()` method.
#### jwtService.verify\<T extends object = any>(token: string, options?: JwtVerifyOptions): T
The verify method is an implementation of jsonwebtoken `.verify()`. Differing from jsonwebtoken it also allows an additional `secret`, `privateKey`, and `publicKey` properties on `options` to override options passed in from the module. It only overrides the `secret`, `publicKey` or `privateKey` though not a `secretOrKeyProvider`.
#### jwtService.verifyAsync\<T extends object = any>(token: string, options?: JwtVerifyOptions): Promise\<T\>
The asynchronous `.verify()` method.
#### jwtService.decode(token: string, options: DecodeOptions): object | string
The decode method is an implementation of jsonwebtoken `.decode()`.
The `JwtModule` takes an `options` object:
- `secret` is either a string, buffer, or object containing the secret for HMAC algorithms
- `secretOrKeyProvider` function with the following signature `(requestType, tokenOrPayload, options?) => jwt.Secret` (allows generating either secrets or keys dynamically)
- `signOptions` [read more](https://github.com/auth0/node-jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback)
- `privateKey` PEM encoded private key for RSA and ECDSA with passphrase an object `{ key, passphrase }` [read more](https://github.com/auth0/node-jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback)
- `publicKey` PEM encoded public key for RSA and ECDSA
- `verifyOptions` [read more](https://github.com/auth0/node-jsonwebtoken#jwtverifytoken-secretorpublickey-options-callback)
- `secretOrPrivateKey` (DEPRECATED!) [read more](https://github.com/auth0/node-jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback)
## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
## Stay in touch
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
## License
Nest is [MIT licensed](LICENSE).

View File

@@ -0,0 +1,3 @@
export * from './interfaces';
export * from './jwt.module';
export * from './jwt.service';

View File

@@ -0,0 +1,15 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./interfaces"), exports);
__exportStar(require("./jwt.module"), exports);
__exportStar(require("./jwt.service"), exports);

View File

@@ -0,0 +1 @@
export * from './jwt-module-options.interface';

View File

@@ -0,0 +1,13 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./jwt-module-options.interface"), exports);

View File

@@ -0,0 +1,33 @@
/// <reference types="node" />
import { ModuleMetadata, Type } from '@nestjs/common';
import * as jwt from 'jsonwebtoken';
export declare enum JwtSecretRequestType {
SIGN = 0,
VERIFY = 1
}
export interface JwtModuleOptions {
signOptions?: jwt.SignOptions;
secret?: string | Buffer;
publicKey?: string | Buffer;
privateKey?: jwt.Secret;
secretOrPrivateKey?: jwt.Secret;
secretOrKeyProvider?: (requestType: JwtSecretRequestType, tokenOrPayload: string | object | Buffer, options?: jwt.VerifyOptions | jwt.SignOptions) => jwt.Secret;
verifyOptions?: jwt.VerifyOptions;
}
export interface JwtOptionsFactory {
createJwtOptions(): Promise<JwtModuleOptions> | JwtModuleOptions;
}
export interface JwtModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
useExisting?: Type<JwtOptionsFactory>;
useClass?: Type<JwtOptionsFactory>;
useFactory?: (...args: any[]) => Promise<JwtModuleOptions> | JwtModuleOptions;
inject?: any[];
}
export interface JwtSignOptions extends jwt.SignOptions {
secret?: string | Buffer;
privateKey?: string | Buffer;
}
export interface JwtVerifyOptions extends jwt.VerifyOptions {
secret?: string | Buffer;
publicKey?: string | Buffer;
}

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JwtSecretRequestType = void 0;
var JwtSecretRequestType;
(function (JwtSecretRequestType) {
JwtSecretRequestType[JwtSecretRequestType["SIGN"] = 0] = "SIGN";
JwtSecretRequestType[JwtSecretRequestType["VERIFY"] = 1] = "VERIFY";
})(JwtSecretRequestType = exports.JwtSecretRequestType || (exports.JwtSecretRequestType = {}));

View File

@@ -0,0 +1 @@
export declare const JWT_MODULE_OPTIONS = "JWT_MODULE_OPTIONS";

View File

@@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JWT_MODULE_OPTIONS = void 0;
exports.JWT_MODULE_OPTIONS = 'JWT_MODULE_OPTIONS';

View File

@@ -0,0 +1,8 @@
import { DynamicModule } from '@nestjs/common';
import { JwtModuleAsyncOptions, JwtModuleOptions } from './interfaces/jwt-module-options.interface';
export declare class JwtModule {
static register(options: JwtModuleOptions): DynamicModule;
static registerAsync(options: JwtModuleAsyncOptions): DynamicModule;
private static createAsyncProviders;
private static createAsyncOptionsProvider;
}

View File

@@ -0,0 +1,71 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var JwtModule_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.JwtModule = void 0;
const common_1 = require("@nestjs/common");
const jwt_constants_1 = require("./jwt.constants");
const jwt_providers_1 = require("./jwt.providers");
const jwt_service_1 = require("./jwt.service");
let JwtModule = JwtModule_1 = class JwtModule {
static register(options) {
return {
module: JwtModule_1,
providers: (0, jwt_providers_1.createJwtProvider)(options)
};
}
static registerAsync(options) {
return {
module: JwtModule_1,
imports: options.imports || [],
providers: this.createAsyncProviders(options)
};
}
static createAsyncProviders(options) {
if (options.useExisting || options.useFactory) {
return [this.createAsyncOptionsProvider(options)];
}
return [
this.createAsyncOptionsProvider(options),
{
provide: options.useClass,
useClass: options.useClass
}
];
}
static createAsyncOptionsProvider(options) {
if (options.useFactory) {
return {
provide: jwt_constants_1.JWT_MODULE_OPTIONS,
useFactory: options.useFactory,
inject: options.inject || []
};
}
return {
provide: jwt_constants_1.JWT_MODULE_OPTIONS,
useFactory: (optionsFactory) => __awaiter(this, void 0, void 0, function* () { return yield optionsFactory.createJwtOptions(); }),
inject: [options.useExisting || options.useClass]
};
}
};
JwtModule = JwtModule_1 = __decorate([
(0, common_1.Module)({
providers: [jwt_service_1.JwtService],
exports: [jwt_service_1.JwtService]
})
], JwtModule);
exports.JwtModule = JwtModule;

View File

@@ -0,0 +1,2 @@
import { JwtModuleOptions } from './interfaces/jwt-module-options.interface';
export declare function createJwtProvider(options: JwtModuleOptions): any[];

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createJwtProvider = void 0;
const jwt_constants_1 = require("./jwt.constants");
function createJwtProvider(options) {
return [{ provide: jwt_constants_1.JWT_MODULE_OPTIONS, useValue: options || {} }];
}
exports.createJwtProvider = createJwtProvider;

View File

@@ -0,0 +1,17 @@
/// <reference types="node" />
import * as jwt from 'jsonwebtoken';
import { JwtModuleOptions, JwtSignOptions, JwtVerifyOptions } from './interfaces';
export declare class JwtService {
private readonly options;
private readonly logger;
constructor(options?: JwtModuleOptions);
sign(payload: string | Buffer | object, options?: JwtSignOptions): string;
signAsync(payload: string | Buffer | object, options?: JwtSignOptions): Promise<string>;
verify<T extends object = any>(token: string, options?: JwtVerifyOptions): T;
verifyAsync<T extends object = any>(token: string, options?: JwtVerifyOptions): Promise<T>;
decode(token: string, options?: jwt.DecodeOptions): null | {
[key: string]: any;
} | string;
private mergeJwtOptions;
private getSecretKey;
}

View File

@@ -0,0 +1,83 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.JwtService = void 0;
const common_1 = require("@nestjs/common");
const jwt = require("jsonwebtoken");
const interfaces_1 = require("./interfaces");
const jwt_constants_1 = require("./jwt.constants");
let JwtService = class JwtService {
constructor(options = {}) {
this.options = options;
this.logger = new common_1.Logger('JwtService');
}
sign(payload, options) {
const signOptions = this.mergeJwtOptions(Object.assign({}, options), 'signOptions');
const secret = this.getSecretKey(payload, options, 'privateKey', interfaces_1.JwtSecretRequestType.SIGN);
return jwt.sign(payload, secret, signOptions);
}
signAsync(payload, options) {
const signOptions = this.mergeJwtOptions(Object.assign({}, options), 'signOptions');
const secret = this.getSecretKey(payload, options, 'privateKey', interfaces_1.JwtSecretRequestType.SIGN);
return new Promise((resolve, reject) => jwt.sign(payload, secret, signOptions, (err, encoded) => err ? reject(err) : resolve(encoded)));
}
verify(token, options) {
const verifyOptions = this.mergeJwtOptions(Object.assign({}, options), 'verifyOptions');
const secret = this.getSecretKey(token, options, 'publicKey', interfaces_1.JwtSecretRequestType.VERIFY);
return jwt.verify(token, secret, verifyOptions);
}
verifyAsync(token, options) {
const verifyOptions = this.mergeJwtOptions(Object.assign({}, options), 'verifyOptions');
const secret = this.getSecretKey(token, options, 'publicKey', interfaces_1.JwtSecretRequestType.VERIFY);
return new Promise((resolve, reject) => jwt.verify(token, secret, verifyOptions, (err, decoded) => err ? reject(err) : resolve(decoded)));
}
decode(token, options) {
return jwt.decode(token, options);
}
mergeJwtOptions(options, key) {
delete options.secret;
if (key === 'signOptions') {
delete options.privateKey;
}
else {
delete options.publicKey;
}
return options
? Object.assign(Object.assign({}, (this.options[key] || {})), options) : this.options[key];
}
getSecretKey(token, options, key, secretRequestType) {
var _a, _b;
let secret = this.options.secretOrKeyProvider
? this.options.secretOrKeyProvider(secretRequestType, token, options)
: (options === null || options === void 0 ? void 0 : options.secret) ||
this.options.secret ||
(key === 'privateKey'
? ((_a = options) === null || _a === void 0 ? void 0 : _a.privateKey) || this.options.privateKey
: ((_b = options) === null || _b === void 0 ? void 0 : _b.publicKey) ||
this.options.publicKey) ||
this.options[key];
if (this.options.secretOrPrivateKey) {
this.logger.warn(`"secretOrPrivateKey" has been deprecated, please use the new explicit "secret" or use "secretOrKeyProvider" or "privateKey"/"publicKey" exclusively.`);
secret = this.options.secretOrPrivateKey;
}
return secret;
}
};
JwtService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, common_1.Optional)()),
__param(0, (0, common_1.Inject)(jwt_constants_1.JWT_MODULE_OPTIONS)),
__metadata("design:paramtypes", [Object])
], JwtService);
exports.JwtService = JwtService;

View File

@@ -0,0 +1 @@
export * from './dist';

View File

@@ -0,0 +1,6 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
exports.__esModule = true;
__export(require("./dist"));

View File

@@ -0,0 +1,13 @@
{
"moduleFileExtensions": ["ts", "tsx", "js", "json"],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "/lib/.*\\.(test|spec).(ts|tsx|js)$",
"collectCoverageFrom": [
"lib/**/*.{js,jsx,tsx,ts}",
"!**/node_modules/**",
"!**/vendor/**"
],
"coverageReporters": ["json", "lcov"]
}

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE

View File

@@ -0,0 +1,16 @@
# Installation
> `npm install --save @types/jsonwebtoken`
# Summary
This package contains type definitions for jsonwebtoken (https://github.com/auth0/node-jsonwebtoken).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jsonwebtoken.
### Additional Details
* Last updated: Mon, 17 Jan 2022 12:01:30 GMT
* Dependencies: [@types/node](https://npmjs.com/package/@types/node)
* Global values: none
# Credits
These definitions were written by [Maxime LUCE](https://github.com/SomaticIT), [Daniel Heim](https://github.com/danielheim), [Brice BERNARD](https://github.com/brikou), [Veli-Pekka Kestilä](https://github.com/vpk), [Daniel Parker](https://github.com/GeneralistDev), [Kjell Dießel](https://github.com/kettil), [Robert Gajda](https://github.com/RunAge), [Nico Flaig](https://github.com/nflaig), [Linus Unnebäck](https://github.com/LinusU), [Ivan Sieder](https://github.com/ivansieder), [Piotr Błażejewicz](https://github.com/peterblazejewicz), and [Nandor Kraszlan](https://github.com/nandi95).

View File

@@ -0,0 +1,246 @@
// Type definitions for jsonwebtoken 8.5
// Project: https://github.com/auth0/node-jsonwebtoken
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>,
// Daniel Heim <https://github.com/danielheim>,
// Brice BERNARD <https://github.com/brikou>,
// Veli-Pekka Kestilä <https://github.com/vpk>,
// Daniel Parker <https://github.com/GeneralistDev>,
// Kjell Dießel <https://github.com/kettil>,
// Robert Gajda <https://github.com/RunAge>,
// Nico Flaig <https://github.com/nflaig>,
// Linus Unnebäck <https://github.com/LinusU>
// Ivan Sieder <https://github.com/ivansieder>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Nandor Kraszlan <https://github.com/nandi95>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
export class JsonWebTokenError extends Error {
inner: Error;
constructor(message: string, error?: Error);
}
export class TokenExpiredError extends JsonWebTokenError {
expiredAt: Date;
constructor(message: string, expiredAt: Date);
}
/**
* Thrown if current time is before the nbf claim.
*/
export class NotBeforeError extends JsonWebTokenError {
date: Date;
constructor(message: string, date: Date);
}
export interface SignOptions {
/**
* Signature algorithm. Could be one of these values :
* - HS256: HMAC using SHA-256 hash algorithm (default)
* - HS384: HMAC using SHA-384 hash algorithm
* - HS512: HMAC using SHA-512 hash algorithm
* - RS256: RSASSA using SHA-256 hash algorithm
* - RS384: RSASSA using SHA-384 hash algorithm
* - RS512: RSASSA using SHA-512 hash algorithm
* - ES256: ECDSA using P-256 curve and SHA-256 hash algorithm
* - ES384: ECDSA using P-384 curve and SHA-384 hash algorithm
* - ES512: ECDSA using P-521 curve and SHA-512 hash algorithm
* - none: No digital signature or MAC value included
*/
algorithm?: Algorithm | undefined;
keyid?: string | undefined;
/** expressed in seconds or a string describing a time span [zeit/ms](https://github.com/zeit/ms.js). Eg: 60, "2 days", "10h", "7d" */
expiresIn?: string | number | undefined;
/** expressed in seconds or a string describing a time span [zeit/ms](https://github.com/zeit/ms.js). Eg: 60, "2 days", "10h", "7d" */
notBefore?: string | number | undefined;
audience?: string | string[] | undefined;
subject?: string | undefined;
issuer?: string | undefined;
jwtid?: string | undefined;
mutatePayload?: boolean | undefined;
noTimestamp?: boolean | undefined;
header?: JwtHeader | undefined;
encoding?: string | undefined;
}
export interface VerifyOptions {
algorithms?: Algorithm[] | undefined;
audience?: string | RegExp | Array<string | RegExp> | undefined;
clockTimestamp?: number | undefined;
clockTolerance?: number | undefined;
/** return an object with the decoded `{ payload, header, signature }` instead of only the usual content of the payload. */
complete?: boolean | undefined;
issuer?: string | string[] | undefined;
ignoreExpiration?: boolean | undefined;
ignoreNotBefore?: boolean | undefined;
jwtid?: string | undefined;
/**
* If you want to check `nonce` claim, provide a string value here.
* It is used on Open ID for the ID Tokens. ([Open ID implementation notes](https://openid.net/specs/openid-connect-core-1_0.html#NonceNotes))
*/
nonce?: string | undefined;
subject?: string | undefined;
maxAge?: string | number | undefined;
}
export interface DecodeOptions {
complete?: boolean | undefined;
json?: boolean | undefined;
}
export type VerifyErrors =
| JsonWebTokenError
| NotBeforeError
| TokenExpiredError;
export type VerifyCallback<T = Jwt | JwtPayload | string> = (
err: VerifyErrors | null,
decoded: T | undefined,
) => void;
export type SignCallback = (
err: Error | null, encoded: string | undefined
) => void;
// standard names https://www.rfc-editor.org/rfc/rfc7515.html#section-4.1
export interface JwtHeader {
alg: string | Algorithm;
typ?: string | undefined;
cty?: string | undefined;
crit?: Array<string | Exclude<keyof JwtHeader, 'crit'>> | undefined;
kid?: string | undefined;
jku?: string | undefined;
x5u?: string | string[] | undefined;
'x5t#S256'?: string | undefined;
x5t?: string | undefined;
x5c?: string | string[] | undefined;
}
// standard claims https://datatracker.ietf.org/doc/html/rfc7519#section-4.1
export interface JwtPayload {
[key: string]: any;
iss?: string | undefined;
sub?: string | undefined;
aud?: string | string[] | undefined;
exp?: number | undefined;
nbf?: number | undefined;
iat?: number | undefined;
jti?: string | undefined;
}
export interface Jwt {
header: JwtHeader;
payload: JwtPayload | string;
signature: string;
}
// https://github.com/auth0/node-jsonwebtoken#algorithms-supported
export type Algorithm =
"HS256" | "HS384" | "HS512" |
"RS256" | "RS384" | "RS512" |
"ES256" | "ES384" | "ES512" |
"PS256" | "PS384" | "PS512" |
"none";
export type SigningKeyCallback = (
err: any,
signingKey?: Secret,
) => void;
export type GetPublicKeyOrSecret = (
header: JwtHeader,
callback: SigningKeyCallback
) => void;
export type Secret =
| string
| Buffer
| { key: string | Buffer; passphrase: string };
/**
* Synchronously sign the given payload into a JSON Web Token string
* payload - Payload to sign, could be an literal, buffer or string
* secretOrPrivateKey - Either the secret for HMAC algorithms, or the PEM encoded private key for RSA and ECDSA.
* [options] - Options for the signature
* returns - The JSON Web Token string
*/
export function sign(
payload: string | Buffer | object,
secretOrPrivateKey: Secret,
options?: SignOptions,
): string;
/**
* Sign the given payload into a JSON Web Token string
* payload - Payload to sign, could be an literal, buffer or string
* secretOrPrivateKey - Either the secret for HMAC algorithms, or the PEM encoded private key for RSA and ECDSA.
* [options] - Options for the signature
* callback - Callback to get the encoded token on
*/
export function sign(
payload: string | Buffer | object,
secretOrPrivateKey: Secret,
callback: SignCallback,
): void;
export function sign(
payload: string | Buffer | object,
secretOrPrivateKey: Secret,
options: SignOptions,
callback: SignCallback,
): void;
/**
* Synchronously verify given token using a secret or a public key to get a decoded token
* token - JWT string to verify
* secretOrPublicKey - Either the secret for HMAC algorithms, or the PEM encoded public key for RSA and ECDSA.
* [options] - Options for the verification
* returns - The decoded token.
*/
export function verify(token: string, secretOrPublicKey: Secret, options: VerifyOptions & { complete: true }): Jwt;
export function verify(token: string, secretOrPublicKey: Secret, options?: VerifyOptions & { complete?: false }): JwtPayload | string;
export function verify(token: string, secretOrPublicKey: Secret, options?: VerifyOptions): Jwt | JwtPayload | string;
/**
* Asynchronously verify given token using a secret or a public key to get a decoded token
* token - JWT string to verify
* secretOrPublicKey - A string or buffer containing either the secret for HMAC algorithms,
* or the PEM encoded public key for RSA and ECDSA. If jwt.verify is called asynchronous,
* secretOrPublicKey can be a function that should fetch the secret or public key
* [options] - Options for the verification
* callback - Callback to get the decoded token on
*/
export function verify(
token: string,
secretOrPublicKey: Secret | GetPublicKeyOrSecret,
callback?: VerifyCallback<JwtPayload | string>,
): void;
export function verify(
token: string,
secretOrPublicKey: Secret | GetPublicKeyOrSecret,
options: VerifyOptions & { complete: true },
callback?: VerifyCallback<Jwt>,
): void;
export function verify(
token: string,
secretOrPublicKey: Secret | GetPublicKeyOrSecret,
options?: VerifyOptions & { complete?: false },
callback?: VerifyCallback<JwtPayload | string>,
): void;
export function verify(
token: string,
secretOrPublicKey: Secret | GetPublicKeyOrSecret,
options?: VerifyOptions,
callback?: VerifyCallback,
): void;
/**
* Returns the decoded payload without verifying if the signature is valid.
* token - JWT string to decode
* [options] - Options for decoding
* returns - The decoded Token
*/
export function decode(token: string, options: DecodeOptions & { complete: true }): null | Jwt;
export function decode(token: string, options: DecodeOptions & { json: true }): null | JwtPayload;
export function decode(token: string, options?: DecodeOptions): null | JwtPayload | string;

View File

@@ -0,0 +1,82 @@
{
"name": "@types/jsonwebtoken",
"version": "8.5.8",
"description": "TypeScript definitions for jsonwebtoken",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jsonwebtoken",
"license": "MIT",
"contributors": [
{
"name": "Maxime LUCE",
"url": "https://github.com/SomaticIT",
"githubUsername": "SomaticIT"
},
{
"name": "Daniel Heim",
"url": "https://github.com/danielheim",
"githubUsername": "danielheim"
},
{
"name": "Brice BERNARD",
"url": "https://github.com/brikou",
"githubUsername": "brikou"
},
{
"name": "Veli-Pekka Kestilä",
"url": "https://github.com/vpk",
"githubUsername": "vpk"
},
{
"name": "Daniel Parker",
"url": "https://github.com/GeneralistDev",
"githubUsername": "GeneralistDev"
},
{
"name": "Kjell Dießel",
"url": "https://github.com/kettil",
"githubUsername": "kettil"
},
{
"name": "Robert Gajda",
"url": "https://github.com/RunAge",
"githubUsername": "RunAge"
},
{
"name": "Nico Flaig",
"url": "https://github.com/nflaig",
"githubUsername": "nflaig"
},
{
"name": "Linus Unnebäck",
"url": "https://github.com/LinusU",
"githubUsername": "LinusU"
},
{
"name": "Ivan Sieder",
"url": "https://github.com/ivansieder",
"githubUsername": "ivansieder"
},
{
"name": "Piotr Błażejewicz",
"url": "https://github.com/peterblazejewicz",
"githubUsername": "peterblazejewicz"
},
{
"name": "Nandor Kraszlan",
"url": "https://github.com/nandi95",
"githubUsername": "nandi95"
}
],
"main": "",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/jsonwebtoken"
},
"scripts": {},
"dependencies": {
"@types/node": "*"
},
"typesPublisherContentHash": "fa9db8bf3d45899001319a89d33c8a49d294c5214b7549967ba4033dc87cc1a3",
"typeScriptVersion": "3.8"
}

View File

@@ -0,0 +1,64 @@
{
"name": "@nestjs/jwt",
"version": "9.0.0",
"description": "Nest - modern, fast, powerful node.js web framework (@jwt)",
"author": "Kamil Mysliwiec",
"license": "MIT",
"scripts": {
"format": "prettier --write \"**/*.ts\"",
"lint": "eslint \"lib/**/*.ts\" --fix",
"test": "jest --config=jest.json",
"test:watch": "jest --config=jest.json --watch",
"test:coverage": "jest --config=jest.json --coverage --coverageDirectory=coverage",
"build": "rm -rf dist && tsc -p tsconfig.json",
"precommit": "lint-staged",
"prepublish:npm": "npm run build",
"publish:npm": "npm publish --access public",
"prerelease": "npm run build",
"release": "release-it"
},
"peerDependencies": {
"@nestjs/common": "^8.0.0 || ^9.0.0"
},
"devDependencies": {
"@commitlint/cli": "17.0.3",
"@commitlint/config-angular": "17.0.3",
"jest": "28.1.2",
"ts-jest": "28.0.5",
"reflect-metadata": "0.1.13",
"@nestjs/core": "9.0.1",
"@nestjs/testing": "9.0.1",
"@types/jest": "28.1.4",
"@typescript-eslint/eslint-plugin": "5.30.5",
"@typescript-eslint/parser": "5.30.5",
"eslint": "8.19.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"@nestjs/common": "9.0.1",
"@types/node": "16.11.43",
"husky": "8.0.1",
"lint-staged": "13.0.3",
"prettier": "2.7.1",
"release-it": "15.1.1",
"typescript": "4.7.4"
},
"dependencies": {
"@types/jsonwebtoken": "8.5.8",
"jsonwebtoken": "8.5.1"
},
"lint-staged": {
"*.ts": [
"prettier --write"
]
},
"husky": {
"hooks": {
"commit-msg": "commitlint -c .commitlintrc.json -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
},
"repository": {
"type": "git",
"url": "https://github.com/nestjs/jwt"
}
}

View File

@@ -0,0 +1,10 @@
{
"semanticCommits": true,
"packageRules": [{
"depTypeList": ["devDependencies"],
"automerge": true
}],
"extends": [
"config:base"
]
}

View File

@@ -0,0 +1,14 @@
# @redis/bloom
This package provides support for the [RedisBloom](https://redisbloom.io) module, which adds additional probabilistic data structures to Redis. It extends the [Node Redis client](https://github.com/redis/node-redis) to include functions for each of the RediBloom commands.
To use these extra commands, your Redis server must have the RedisBloom module installed.
RedisBloom provides the following probabilistic data structures:
* Bloom Filter: for checking set membership with a high degree of certainty.
* Cuckoo Filter: for checking set membership with a high degree of certainty.
* Count-Min Sketch: Determine the frequency of events in a stream.
* Top-K: Maintain a list of k most frequently seen items.
For complete examples, see `bloom-filter.js`, `cuckoo-filter.js`, `count-min-sketch.js` and `topk.js` in the Node Redis examples folder.

View File

@@ -0,0 +1,3 @@
export declare const FIRST_KEY_INDEX = 1;
export declare function transformArguments(key: string, item: string): Array<string>;
export { transformBooleanReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers';

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
function transformArguments(key, item) {
return ['BF.ADD', key, item];
}
exports.transformArguments = transformArguments;
var generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
Object.defineProperty(exports, "transformReply", { enumerable: true, get: function () { return generic_transformers_1.transformBooleanReply; } });

View File

@@ -0,0 +1,4 @@
export declare const FIRST_KEY_INDEX = 1;
export declare const IS_READ_ONLY = true;
export declare function transformArguments(key: string, item: string): Array<string>;
export { transformBooleanReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers';

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
exports.IS_READ_ONLY = true;
function transformArguments(key, item) {
return ['BF.EXISTS', key, item];
}
exports.transformArguments = transformArguments;
var generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
Object.defineProperty(exports, "transformReply", { enumerable: true, get: function () { return generic_transformers_1.transformBooleanReply; } });

View File

@@ -0,0 +1,23 @@
export declare const FIRST_KEY_INDEX = 1;
export declare const IS_READ_ONLY = true;
export declare function transformArguments(key: string): Array<string>;
export declare type InfoRawReply = [
_: string,
capacity: number,
_: string,
size: number,
_: string,
numberOfFilters: number,
_: string,
numberOfInsertedItems: number,
_: string,
expansionRate: number
];
export interface InfoReply {
capacity: number;
size: number;
numberOfFilters: number;
numberOfInsertedItems: number;
expansionRate: number;
}
export declare function transformReply(reply: InfoRawReply): InfoReply;

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
exports.IS_READ_ONLY = true;
function transformArguments(key) {
return ['BF.INFO', key];
}
exports.transformArguments = transformArguments;
function transformReply(reply) {
return {
capacity: reply[1],
size: reply[3],
numberOfFilters: reply[5],
numberOfInsertedItems: reply[7],
expansionRate: reply[9]
};
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,11 @@
import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands';
export declare const FIRST_KEY_INDEX = 1;
interface InsertOptions {
CAPACITY?: number;
ERROR?: number;
EXPANSION?: number;
NOCREATE?: true;
NONSCALING?: true;
}
export declare function transformArguments(key: string, items: RedisCommandArgument | Array<RedisCommandArgument>, options?: InsertOptions): RedisCommandArguments;
export { transformBooleanArrayReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers';

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
const generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
exports.FIRST_KEY_INDEX = 1;
function transformArguments(key, items, options) {
const args = ['BF.INSERT', key];
if (options?.CAPACITY) {
args.push('CAPACITY', options.CAPACITY.toString());
}
if (options?.ERROR) {
args.push('ERROR', options.ERROR.toString());
}
if (options?.EXPANSION) {
args.push('EXPANSION', options.EXPANSION.toString());
}
if (options?.NOCREATE) {
args.push('NOCREATE');
}
if (options?.NONSCALING) {
args.push('NONSCALING');
}
args.push('ITEMS');
return (0, generic_transformers_1.pushVerdictArguments)(args, items);
}
exports.transformArguments = transformArguments;
var generic_transformers_2 = require("@redis/client/dist/lib/commands/generic-transformers");
Object.defineProperty(exports, "transformReply", { enumerable: true, get: function () { return generic_transformers_2.transformBooleanArrayReply; } });

View File

@@ -0,0 +1,4 @@
import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands';
export declare const FIRST_KEY_INDEX = 1;
export declare function transformArguments(key: string, iteretor: number, chunk: RedisCommandArgument): RedisCommandArguments;
export declare function transformReply(): 'OK';

View File

@@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
function transformArguments(key, iteretor, chunk) {
return ['BF.LOADCHUNK', key, iteretor.toString(), chunk];
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,3 @@
export declare const FIRST_KEY_INDEX = 1;
export declare function transformArguments(key: string, items: Array<string>): Array<string>;
export { transformBooleanArrayReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers';

View File

@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
function transformArguments(key, items) {
return ['BF.MADD', key, ...items];
}
exports.transformArguments = transformArguments;
var generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
Object.defineProperty(exports, "transformReply", { enumerable: true, get: function () { return generic_transformers_1.transformBooleanArrayReply; } });

View File

@@ -0,0 +1,4 @@
export declare const FIRST_KEY_INDEX = 1;
export declare const IS_READ_ONLY = true;
export declare function transformArguments(key: string, items: Array<string>): Array<string>;
export { transformBooleanArrayReply as transformReply } from '@redis/client/dist/lib/commands/generic-transformers';

View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
exports.IS_READ_ONLY = true;
function transformArguments(key, items) {
return ['BF.MEXISTS', key, ...items];
}
exports.transformArguments = transformArguments;
var generic_transformers_1 = require("@redis/client/dist/lib/commands/generic-transformers");
Object.defineProperty(exports, "transformReply", { enumerable: true, get: function () { return generic_transformers_1.transformBooleanArrayReply; } });

View File

@@ -0,0 +1,8 @@
export declare const FIRST_KEY_INDEX = 1;
interface ReserveOptions {
EXPANSION?: number;
NONSCALING?: true;
}
export declare function transformArguments(key: string, errorRate: number, capacity: number, options?: ReserveOptions): Array<string>;
export declare function transformReply(): 'OK';
export {};

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
function transformArguments(key, errorRate, capacity, options) {
const args = ['BF.RESERVE', key, errorRate.toString(), capacity.toString()];
if (options?.EXPANSION) {
args.push('EXPANSION', options.EXPANSION.toString());
}
if (options?.NONSCALING) {
args.push('NONSCALING');
}
return args;
}
exports.transformArguments = transformArguments;

View File

@@ -0,0 +1,13 @@
export declare const FIRST_KEY_INDEX = 1;
export declare const IS_READ_ONLY = true;
export declare function transformArguments(key: string, iterator: number): Array<string>;
declare type ScanDumpRawReply = [
iterator: number,
chunk: string
];
interface ScanDumpReply {
iterator: number;
chunk: string;
}
export declare function transformReply([iterator, chunk]: ScanDumpRawReply): ScanDumpReply;
export {};

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = exports.IS_READ_ONLY = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
exports.IS_READ_ONLY = true;
function transformArguments(key, iterator) {
return ['BF.SCANDUMP', key, iterator.toString()];
}
exports.transformArguments = transformArguments;
function transformReply([iterator, chunk]) {
return {
iterator,
chunk
};
}
exports.transformReply = transformReply;

View File

@@ -0,0 +1,30 @@
import * as ADD from './ADD';
import * as EXISTS from './EXISTS';
import * as INFO from './INFO';
import * as INSERT from './INSERT';
import * as LOADCHUNK from './LOADCHUNK';
import * as MADD from './MADD';
import * as MEXISTS from './MEXISTS';
import * as RESERVE from './RESERVE';
import * as SCANDUMP from './SCANDUMP';
declare const _default: {
ADD: typeof ADD;
add: typeof ADD;
EXISTS: typeof EXISTS;
exists: typeof EXISTS;
INFO: typeof INFO;
info: typeof INFO;
INSERT: typeof INSERT;
insert: typeof INSERT;
LOADCHUNK: typeof LOADCHUNK;
loadChunk: typeof LOADCHUNK;
MADD: typeof MADD;
mAdd: typeof MADD;
MEXISTS: typeof MEXISTS;
mExists: typeof MEXISTS;
RESERVE: typeof RESERVE;
reserve: typeof RESERVE;
SCANDUMP: typeof SCANDUMP;
scanDump: typeof SCANDUMP;
};
export default _default;

View File

@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ADD = require("./ADD");
const EXISTS = require("./EXISTS");
const INFO = require("./INFO");
const INSERT = require("./INSERT");
const LOADCHUNK = require("./LOADCHUNK");
const MADD = require("./MADD");
const MEXISTS = require("./MEXISTS");
const RESERVE = require("./RESERVE");
const SCANDUMP = require("./SCANDUMP");
exports.default = {
ADD,
add: ADD,
EXISTS,
exists: EXISTS,
INFO,
info: INFO,
INSERT,
insert: INSERT,
LOADCHUNK,
loadChunk: LOADCHUNK,
MADD,
mAdd: MADD,
MEXISTS,
mExists: MEXISTS,
RESERVE,
reserve: RESERVE,
SCANDUMP,
scanDump: SCANDUMP
};

View File

@@ -0,0 +1,8 @@
export declare const FIRST_KEY_INDEX = 1;
interface IncrByItem {
item: string;
incrementBy: number;
}
export declare function transformArguments(key: string, items: IncrByItem | Array<IncrByItem>): Array<string>;
export declare function transformReply(): Array<number>;
export {};

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.FIRST_KEY_INDEX = void 0;
exports.FIRST_KEY_INDEX = 1;
function transformArguments(key, items) {
const args = ['CMS.INCRBY', key];
if (Array.isArray(items)) {
for (const item of items) {
pushIncrByItem(args, item);
}
}
else {
pushIncrByItem(args, items);
}
return args;
}
exports.transformArguments = transformArguments;
function pushIncrByItem(args, { item, incrementBy }) {
args.push(item, incrementBy.toString());
}

View File

@@ -0,0 +1,17 @@
export declare const FIRST_KEY_INDEX = 1;
export declare const IS_READ_ONLY = true;
export declare function transformArguments(key: string): Array<string>;
export declare type InfoRawReply = [
_: string,
width: number,
_: string,
depth: number,
_: string,
count: number
];
export interface InfoReply {
width: number;
depth: number;
count: number;
}
export declare function transformReply(reply: InfoRawReply): InfoReply;

Some files were not shown because too many files have changed in this diff Show More