@evara-group/guard 1.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/dist/core/enums/locale.d.ts +4 -0
- package/dist/core/enums/locale.js +9 -0
- package/dist/core/enums/locale.js.map +1 -0
- package/dist/core/enums/user-role.d.ts +4 -0
- package/dist/core/enums/user-role.js +9 -0
- package/dist/core/enums/user-role.js.map +1 -0
- package/dist/core/utils/base.dto.d.ts +9 -0
- package/dist/core/utils/base.dto.js +7 -0
- package/dist/core/utils/base.dto.js.map +1 -0
- package/dist/core/utils/base.entity.d.ts +9 -0
- package/dist/core/utils/base.entity.js +45 -0
- package/dist/core/utils/base.entity.js.map +1 -0
- package/dist/core/utils/header-util.d.ts +4 -0
- package/dist/core/utils/header-util.js +12 -0
- package/dist/core/utils/header-util.js.map +1 -0
- package/dist/core/utils/paginate.dto.d.ts +6 -0
- package/dist/core/utils/paginate.dto.js +64 -0
- package/dist/core/utils/paginate.dto.js.map +1 -0
- package/dist/core/utils/pagination.entity.d.ts +19 -0
- package/dist/core/utils/pagination.entity.js +63 -0
- package/dist/core/utils/pagination.entity.js.map +1 -0
- package/dist/core/utils/password-util.d.ts +3 -0
- package/dist/core/utils/password-util.js +44 -0
- package/dist/core/utils/password-util.js.map +1 -0
- package/dist/core/utils/request.d.ts +7 -0
- package/dist/core/utils/request.js +3 -0
- package/dist/core/utils/request.js.map +1 -0
- package/dist/core/utils/response-message.dto.d.ts +3 -0
- package/dist/core/utils/response-message.dto.js +7 -0
- package/dist/core/utils/response-message.dto.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/security/decorators/auth-user.decorator.d.ts +1 -0
- package/dist/security/decorators/auth-user.decorator.js +9 -0
- package/dist/security/decorators/auth-user.decorator.js.map +1 -0
- package/dist/security/decorators/roles.decorator.d.ts +1 -0
- package/dist/security/decorators/roles.decorator.js +7 -0
- package/dist/security/decorators/roles.decorator.js.map +1 -0
- package/dist/security/guards/jwt-auth.guard.d.ts +4 -0
- package/dist/security/guards/jwt-auth.guard.js +18 -0
- package/dist/security/guards/jwt-auth.guard.js.map +1 -0
- package/dist/security/guards/roles.guard.d.ts +7 -0
- package/dist/security/guards/roles.guard.js +35 -0
- package/dist/security/guards/roles.guard.js.map +1 -0
- package/dist/security/security.module.d.ts +7 -0
- package/dist/security/security.module.js +43 -0
- package/dist/security/security.module.js.map +1 -0
- package/dist/security/security.service.d.ts +7 -0
- package/dist/security/security.service.js +31 -0
- package/dist/security/security.service.js.map +1 -0
- package/dist/security/strategies/jwt.strategy.d.ts +9 -0
- package/dist/security/strategies/jwt.strategy.js +38 -0
- package/dist/security/strategies/jwt.strategy.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/user/dtos/create-user.dto.d.ts +5 -0
- package/dist/user/dtos/create-user.dto.js +7 -0
- package/dist/user/dtos/create-user.dto.js.map +1 -0
- package/dist/user/dtos/update-user.dto.d.ts +5 -0
- package/dist/user/dtos/update-user.dto.js +9 -0
- package/dist/user/dtos/update-user.dto.js.map +1 -0
- package/dist/user/dtos/user-query.dto.d.ts +3 -0
- package/dist/user/dtos/user-query.dto.js +8 -0
- package/dist/user/dtos/user-query.dto.js.map +1 -0
- package/dist/user/dtos/user.dto.d.ts +11 -0
- package/dist/user/dtos/user.dto.js +81 -0
- package/dist/user/dtos/user.dto.js.map +1 -0
- package/dist/user/user.controller.d.ts +16 -0
- package/dist/user/user.controller.js +161 -0
- package/dist/user/user.controller.js.map +1 -0
- package/dist/user/user.entity.d.ts +11 -0
- package/dist/user/user.entity.js +52 -0
- package/dist/user/user.entity.js.map +1 -0
- package/dist/user/user.mapper.d.ts +6 -0
- package/dist/user/user.mapper.js +32 -0
- package/dist/user/user.mapper.js.map +1 -0
- package/dist/user/user.module.d.ts +4 -0
- package/dist/user/user.module.js +31 -0
- package/dist/user/user.module.js.map +1 -0
- package/dist/user/user.service.d.ts +15 -0
- package/dist/user/user.service.js +79 -0
- package/dist/user/user.service.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var SecurityModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SecurityModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
13
|
+
const passport_1 = require("@nestjs/passport");
|
|
14
|
+
const security_service_1 = require("./security.service");
|
|
15
|
+
const jwt_strategy_1 = require("./strategies/jwt.strategy");
|
|
16
|
+
let SecurityModule = SecurityModule_1 = class SecurityModule {
|
|
17
|
+
static register(config) {
|
|
18
|
+
if (!config.jwtSecret) {
|
|
19
|
+
throw new Error("JWT secret is required in SecurityModule.register()");
|
|
20
|
+
}
|
|
21
|
+
const jwtStrategyProvider = {
|
|
22
|
+
provide: jwt_strategy_1.JwtStrategy,
|
|
23
|
+
useFactory: () => new jwt_strategy_1.JwtStrategy(config.jwtSecret),
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
module: SecurityModule_1,
|
|
27
|
+
imports: [
|
|
28
|
+
passport_1.PassportModule.register({ defaultStrategy: "jwt" }),
|
|
29
|
+
jwt_1.JwtModule.register({
|
|
30
|
+
secret: config.jwtSecret,
|
|
31
|
+
signOptions: { expiresIn: config.expiresIn ?? "1d" },
|
|
32
|
+
}),
|
|
33
|
+
],
|
|
34
|
+
providers: [security_service_1.SecurityService, jwtStrategyProvider],
|
|
35
|
+
exports: [security_service_1.SecurityService, passport_1.PassportModule, jwt_1.JwtModule],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.SecurityModule = SecurityModule;
|
|
40
|
+
exports.SecurityModule = SecurityModule = SecurityModule_1 = __decorate([
|
|
41
|
+
(0, common_1.Module)({})
|
|
42
|
+
], SecurityModule);
|
|
43
|
+
//# sourceMappingURL=security.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.module.js","sourceRoot":"","sources":["../../src/security/security.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAiE;AACjE,qCAA0D;AAC1D,+CAAkD;AAClD,yDAAqD;AACrD,4DAAwD;AAGjD,IAAM,cAAc,sBAApB,MAAM,cAAc;IACzB,MAAM,CAAC,QAAQ,CAAC,MAGf;QACC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACzE,CAAC;QAGD,MAAM,mBAAmB,GAAa;YACpC,OAAO,EAAE,0BAAW;YACpB,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,0BAAW,CAAC,MAAM,CAAC,SAAS,CAAC;SACpD,CAAC;QAEF,OAAO;YACL,MAAM,EAAE,gBAAc;YACtB,OAAO,EAAE;gBACP,yBAAc,CAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;gBACnD,eAAS,CAAC,QAAQ,CAAC;oBACjB,MAAM,EAAE,MAAM,CAAC,SAAS;oBACxB,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI,EAAE;iBACjC,CAAC;aACvB;YACD,SAAS,EAAE,CAAC,kCAAe,EAAE,mBAAmB,CAAC;YACjD,OAAO,EAAE,CAAC,kCAAe,EAAE,yBAAc,EAAE,eAAS,CAAC;SACtD,CAAC;IACJ,CAAC;CACF,CAAA;AA5BY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,cAAc,CA4B1B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SecurityService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
15
|
+
let SecurityService = class SecurityService {
|
|
16
|
+
constructor(jwtService) {
|
|
17
|
+
this.jwtService = jwtService;
|
|
18
|
+
}
|
|
19
|
+
sign(payload) {
|
|
20
|
+
return this.jwtService.sign(payload);
|
|
21
|
+
}
|
|
22
|
+
verify(token) {
|
|
23
|
+
return this.jwtService.verify(token);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
exports.SecurityService = SecurityService;
|
|
27
|
+
exports.SecurityService = SecurityService = __decorate([
|
|
28
|
+
(0, common_1.Injectable)(),
|
|
29
|
+
__metadata("design:paramtypes", [jwt_1.JwtService])
|
|
30
|
+
], SecurityService);
|
|
31
|
+
//# sourceMappingURL=security.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.service.js","sourceRoot":"","sources":["../../src/security/security.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,qCAAyC;AAGlC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvD,IAAI,CAAC,OAAY;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;CACF,CAAA;AAVY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;qCAE8B,gBAAU;GADxC,eAAe,CAU3B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Strategy } from "passport-jwt";
|
|
2
|
+
declare const JwtStrategy_base: new (...args: [opt: import("passport-jwt").StrategyOptionsWithoutRequest] | [opt: import("passport-jwt").StrategyOptionsWithRequest]) => Strategy & {
|
|
3
|
+
validate(...args: any[]): unknown;
|
|
4
|
+
};
|
|
5
|
+
export declare class JwtStrategy extends JwtStrategy_base {
|
|
6
|
+
constructor(secret: string);
|
|
7
|
+
validate(payload: any): Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.JwtStrategy = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const passport_1 = require("@nestjs/passport");
|
|
15
|
+
const passport_jwt_1 = require("passport-jwt");
|
|
16
|
+
let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
|
|
17
|
+
constructor(secret) {
|
|
18
|
+
if (!secret) {
|
|
19
|
+
throw new Error("JWT secret must be provided");
|
|
20
|
+
}
|
|
21
|
+
const options = {
|
|
22
|
+
jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
23
|
+
ignoreExpiration: false,
|
|
24
|
+
secretOrKey: secret,
|
|
25
|
+
passReqToCallback: false,
|
|
26
|
+
};
|
|
27
|
+
super(options);
|
|
28
|
+
}
|
|
29
|
+
async validate(payload) {
|
|
30
|
+
return payload;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.JwtStrategy = JwtStrategy;
|
|
34
|
+
exports.JwtStrategy = JwtStrategy = __decorate([
|
|
35
|
+
(0, common_1.Injectable)(),
|
|
36
|
+
__metadata("design:paramtypes", [String])
|
|
37
|
+
], JwtStrategy);
|
|
38
|
+
//# sourceMappingURL=jwt.strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt.strategy.js","sourceRoot":"","sources":["../../../src/security/strategies/jwt.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,+CAAoD;AACpD,+CAAqE;AAG9D,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,IAAA,2BAAgB,EAAC,uBAAQ,CAAC;IACzD,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,OAAO,GAAoB;YAC/B,cAAc,EAAE,yBAAU,CAAC,2BAA2B,EAAE;YACxD,gBAAgB,EAAE,KAAK;YACvB,WAAW,EAAE,MAAM;YACnB,iBAAiB,EAAE,KAAK;SACzB,CAAC;QAEF,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAY;QACzB,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AAnBY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;;GACA,WAAW,CAmBvB"}
|