@bidding-micro/shared 1.0.0 → 1.0.2
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/dist/constants/enum.constant.d.ts +16 -0
- package/dist/constants/enum.constant.js +31 -0
- package/dist/constants/enum.constant.js.map +1 -0
- package/dist/constants/messages.constant.d.ts +6 -0
- package/dist/constants/messages.constant.js +10 -0
- package/dist/constants/messages.constant.js.map +1 -0
- package/dist/constants/rolePermissionsMap.constant.js +25 -0
- package/dist/constants/rolePermissionsMap.constant.js.map +1 -0
- package/dist/decorators/auth.decorator.d.ts +1 -0
- package/dist/{decorator → decorators}/auth.decorator.js +2 -3
- package/dist/decorators/auth.decorator.js.map +1 -0
- package/dist/{decorator → decorators}/currentUser.decorator.js +4 -4
- package/dist/decorators/currentUser.decorator.js.map +1 -0
- package/dist/guard/role.guard.d.ts +22 -0
- package/dist/guard/role.guard.js +103 -0
- package/dist/guard/role.guard.js.map +1 -0
- package/dist/index.d.ts +8 -6
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/interfaces/user.interface.d.ts +12 -0
- package/dist/interfaces/user.interface.js +3 -0
- package/dist/interfaces/user.interface.js.map +1 -0
- package/dist/modules/auth.module.d.ts +8 -0
- package/dist/modules/auth.module.js +43 -0
- package/dist/modules/auth.module.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/constant/enum.constant.d.ts +0 -69
- package/dist/constant/enum.constant.js +0 -77
- package/dist/constant/enum.constant.js.map +0 -1
- package/dist/constant/messages.constant.d.ts +0 -6
- package/dist/constant/messages.constant.js +0 -10
- package/dist/constant/messages.constant.js.map +0 -1
- package/dist/constant/rolePermissionsMap.constant.js +0 -100
- package/dist/constant/rolePermissionsMap.constant.js.map +0 -1
- package/dist/decorator/auth.decorator.d.ts +0 -3
- package/dist/decorator/auth.decorator.js.map +0 -1
- package/dist/decorator/currentUser.decorator.js.map +0 -1
- package/dist/guard/base-role.guard.d.ts +0 -18
- package/dist/guard/base-role.guard.js +0 -67
- package/dist/guard/base-role.guard.js.map +0 -1
- /package/dist/{constant → constants}/rolePermissionsMap.constant.d.ts +0 -0
- /package/dist/{decorator → decorators}/currentUser.decorator.d.ts +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare enum Role {
|
|
2
|
+
ADMIN = "admin",
|
|
3
|
+
USER = "user"
|
|
4
|
+
}
|
|
5
|
+
export declare const AllRoles: Role[];
|
|
6
|
+
export declare enum Permission {
|
|
7
|
+
UPDATE_USER = "update_user",
|
|
8
|
+
DELETE_USER = "delete_user",
|
|
9
|
+
EDIT_USER_ROLE = "edit_user_role",
|
|
10
|
+
VIEW_USER = "view_user",
|
|
11
|
+
CREATE_INSTRUCTOR = "create_instructor",
|
|
12
|
+
RESET_PASSWORD = "RESET_PASSWORD",
|
|
13
|
+
CHANGE_PASSWORD = "CHANGE_PASSWORD",
|
|
14
|
+
FORGOT_PASSWORD = "FORGOT_PASSWORD",
|
|
15
|
+
LOGOUT = "LOGOUT"
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Permission = exports.AllRoles = exports.Role = void 0;
|
|
4
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
5
|
+
var Role;
|
|
6
|
+
(function (Role) {
|
|
7
|
+
Role["ADMIN"] = "admin";
|
|
8
|
+
Role["USER"] = "user";
|
|
9
|
+
})(Role || (exports.Role = Role = {}));
|
|
10
|
+
exports.AllRoles = Object.values(Role);
|
|
11
|
+
var Permission;
|
|
12
|
+
(function (Permission) {
|
|
13
|
+
Permission["UPDATE_USER"] = "update_user";
|
|
14
|
+
Permission["DELETE_USER"] = "delete_user";
|
|
15
|
+
Permission["EDIT_USER_ROLE"] = "edit_user_role";
|
|
16
|
+
Permission["VIEW_USER"] = "view_user";
|
|
17
|
+
Permission["CREATE_INSTRUCTOR"] = "create_instructor";
|
|
18
|
+
Permission["RESET_PASSWORD"] = "RESET_PASSWORD";
|
|
19
|
+
Permission["CHANGE_PASSWORD"] = "CHANGE_PASSWORD";
|
|
20
|
+
Permission["FORGOT_PASSWORD"] = "FORGOT_PASSWORD";
|
|
21
|
+
Permission["LOGOUT"] = "LOGOUT";
|
|
22
|
+
})(Permission || (exports.Permission = Permission = {}));
|
|
23
|
+
(0, graphql_1.registerEnumType)(Permission, {
|
|
24
|
+
name: 'Permission',
|
|
25
|
+
description: 'Detailed permissions in the system',
|
|
26
|
+
});
|
|
27
|
+
(0, graphql_1.registerEnumType)(Role, {
|
|
28
|
+
name: 'Role',
|
|
29
|
+
description: 'User roles in the system',
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=enum.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum.constant.js","sourceRoot":"","sources":["../../src/constants/enum.constant.ts"],"names":[],"mappings":";;;AAAA,6CAAmD;AAEnD,IAAY,IAGX;AAHD,WAAY,IAAI;IACd,uBAAe,CAAA;IACf,qBAAa,CAAA;AACf,CAAC,EAHW,IAAI,oBAAJ,IAAI,QAGf;AACY,QAAA,QAAQ,GAAW,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAEpD,IAAY,UAeX;AAfD,WAAY,UAAU;IAEpB,yCAA2B,CAAA;IAC3B,yCAA2B,CAAA;IAC3B,+CAAiC,CAAA;IACjC,qCAAuB,CAAA;IACvB,qDAAuC,CAAA;IAGvC,+CAAiC,CAAA;IACjC,iDAAmC,CAAA;IACnC,iDAAmC,CAAA;IACnC,+BAAiB,CAAA;AAGnB,CAAC,EAfW,UAAU,0BAAV,UAAU,QAerB;AAGD,IAAA,0BAAgB,EAAC,UAAU,EAAE;IAC3B,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,oCAAoC;CAClD,CAAC,CAAC;AAEH,IAAA,0BAAgB,EAAC,IAAI,EAAE;IACrB,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,0BAA0B;CACxC,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const Limit = 12;
|
|
2
|
+
export declare const Page = 1;
|
|
3
|
+
export declare const CurrentUserMsg = "User not found in request";
|
|
4
|
+
export declare const PasswordValidator = "Password should be from 6 to 16 digits";
|
|
5
|
+
export declare const ExceptionFilterMsg = "An error occurred";
|
|
6
|
+
export declare const DelevaryPrice = 20;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DelevaryPrice = exports.ExceptionFilterMsg = exports.PasswordValidator = exports.CurrentUserMsg = exports.Page = exports.Limit = void 0;
|
|
4
|
+
exports.Limit = 12;
|
|
5
|
+
exports.Page = 1;
|
|
6
|
+
exports.CurrentUserMsg = 'User not found in request';
|
|
7
|
+
exports.PasswordValidator = 'Password should be from 6 to 16 digits';
|
|
8
|
+
exports.ExceptionFilterMsg = 'An error occurred';
|
|
9
|
+
exports.DelevaryPrice = 20;
|
|
10
|
+
//# sourceMappingURL=messages.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.constant.js","sourceRoot":"","sources":["../../src/constants/messages.constant.ts"],"names":[],"mappings":";;;AACa,QAAA,KAAK,GAAG,EAAE,CAAC;AACX,QAAA,IAAI,GAAG,CAAC,CAAC;AAGT,QAAA,cAAc,GAAG,2BAA2B,CAAC;AAC7C,QAAA,iBAAiB,GAAG,wCAAwC,CAAC;AAG7D,QAAA,kBAAkB,GAAG,mBAAmB,CAAC;AAGzC,QAAA,aAAa,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rolePermissionsMap = void 0;
|
|
4
|
+
const enum_constant_1 = require("./enum.constant");
|
|
5
|
+
exports.rolePermissionsMap = {
|
|
6
|
+
[enum_constant_1.Role.ADMIN]: [
|
|
7
|
+
enum_constant_1.Permission.UPDATE_USER,
|
|
8
|
+
enum_constant_1.Permission.DELETE_USER,
|
|
9
|
+
enum_constant_1.Permission.EDIT_USER_ROLE,
|
|
10
|
+
enum_constant_1.Permission.RESET_PASSWORD,
|
|
11
|
+
enum_constant_1.Permission.CHANGE_PASSWORD,
|
|
12
|
+
enum_constant_1.Permission.FORGOT_PASSWORD,
|
|
13
|
+
enum_constant_1.Permission.LOGOUT,
|
|
14
|
+
enum_constant_1.Permission.VIEW_USER,
|
|
15
|
+
enum_constant_1.Permission.CREATE_INSTRUCTOR,
|
|
16
|
+
],
|
|
17
|
+
[enum_constant_1.Role.USER]: [
|
|
18
|
+
enum_constant_1.Permission.UPDATE_USER,
|
|
19
|
+
enum_constant_1.Permission.RESET_PASSWORD,
|
|
20
|
+
enum_constant_1.Permission.CHANGE_PASSWORD,
|
|
21
|
+
enum_constant_1.Permission.FORGOT_PASSWORD,
|
|
22
|
+
enum_constant_1.Permission.LOGOUT,
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=rolePermissionsMap.constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rolePermissionsMap.constant.js","sourceRoot":"","sources":["../../src/constants/rolePermissionsMap.constant.ts"],"names":[],"mappings":";;;AAAA,mDAAmD;AAEtC,QAAA,kBAAkB,GAA+B;IAC5D,CAAC,oBAAI,CAAC,KAAK,CAAC,EAAE;QAEZ,0BAAU,CAAC,WAAW;QACtB,0BAAU,CAAC,WAAW;QACtB,0BAAU,CAAC,cAAc;QACzB,0BAAU,CAAC,cAAc;QACzB,0BAAU,CAAC,eAAe;QAC1B,0BAAU,CAAC,eAAe;QAC1B,0BAAU,CAAC,MAAM;QACjB,0BAAU,CAAC,SAAS;QACpB,0BAAU,CAAC,iBAAiB;KAG7B;IAED,CAAC,oBAAI,CAAC,IAAI,CAAC,EAAE;QAEX,0BAAU,CAAC,WAAW;QACtB,0BAAU,CAAC,cAAc;QACzB,0BAAU,CAAC,eAAe;QAC1B,0BAAU,CAAC,eAAe;QAC1B,0BAAU,CAAC,MAAM;KAElB;CAGF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Auth(permissions?: string[]): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PERMISSIONS_KEY = void 0;
|
|
4
3
|
exports.Auth = Auth;
|
|
5
4
|
const common_1 = require("@nestjs/common");
|
|
6
|
-
|
|
5
|
+
const role_guard_1 = require("../guard/role.guard");
|
|
7
6
|
function Auth(permissions = []) {
|
|
8
|
-
return (0, common_1.applyDecorators)((0, common_1.SetMetadata)(
|
|
7
|
+
return (0, common_1.applyDecorators)((0, common_1.SetMetadata)('permissions', permissions), (0, common_1.UseGuards)(role_guard_1.RoleGuard));
|
|
9
8
|
}
|
|
10
9
|
//# sourceMappingURL=auth.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.decorator.js","sourceRoot":"","sources":["../../src/decorators/auth.decorator.ts"],"names":[],"mappings":";;AAGA,oBAKC;AARD,2CAAyE;AACzE,oDAAgD;AAEhD,SAAgB,IAAI,CAAC,cAAwB,EAAE;IAC7C,OAAO,IAAA,wBAAe,EACpB,IAAA,oBAAW,EAAC,aAAa,EAAE,WAAW,CAAC,EACvC,IAAA,kBAAS,EAAC,sBAAS,CAAC,CACrB,CAAC;AACJ,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CurrentUser = void 0;
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
4
|
const graphql_1 = require("@nestjs/graphql");
|
|
6
|
-
const messages_constant_1 = require("../
|
|
7
|
-
|
|
5
|
+
const messages_constant_1 = require("../constants/messages.constant");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
exports.CurrentUser = (0, common_1.createParamDecorator)((data, context) => {
|
|
8
8
|
const ctx = graphql_1.GqlExecutionContext.create(context).getContext();
|
|
9
|
-
const user = ctx.req
|
|
9
|
+
const user = ctx.req.user;
|
|
10
10
|
if (!user) {
|
|
11
11
|
throw new common_1.BadRequestException(messages_constant_1.CurrentUserMsg);
|
|
12
12
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currentUser.decorator.js","sourceRoot":"","sources":["../../src/decorators/currentUser.decorator.ts"],"names":[],"mappings":";;;AAAA,6CAAqD;AACrD,sEAA+D;AAC/D,2CAIuB;AAEV,QAAA,WAAW,GAAG,IAAA,6BAAoB,EAC7C,CAAC,IAAa,EAAE,OAAyB,EAAE,EAAE;IAC3C,MAAM,GAAG,GAAG,6BAAmB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAA;IAC5D,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAA;IACzB,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,4BAAmB,CAAC,kCAAc,CAAC,CAAA;IAC/C,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CACF,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
import { JwtService } from '@nestjs/jwt';
|
|
4
|
+
import { I18nService } from 'nestjs-i18n';
|
|
5
|
+
import { IUser } from '../interfaces/user.interface';
|
|
6
|
+
export interface IUserService {
|
|
7
|
+
findById(id: string): Promise<IUser>;
|
|
8
|
+
}
|
|
9
|
+
export declare class RoleGuard implements CanActivate {
|
|
10
|
+
private readonly i18n;
|
|
11
|
+
private readonly jwtService;
|
|
12
|
+
private readonly reflector;
|
|
13
|
+
private readonly userService?;
|
|
14
|
+
constructor(i18n: I18nService, jwtService: JwtService, reflector: Reflector, userService?: IUserService | undefined);
|
|
15
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
16
|
+
private extractTokenFromHeader;
|
|
17
|
+
private verifyToken;
|
|
18
|
+
private getRequiredRoles;
|
|
19
|
+
private getRequiredPermissions;
|
|
20
|
+
private validateRole;
|
|
21
|
+
private validatePermissions;
|
|
22
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RoleGuard = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const core_1 = require("@nestjs/core");
|
|
18
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
19
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
20
|
+
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
21
|
+
const rolePermissionsMap_constant_1 = require("../constants/rolePermissionsMap.constant");
|
|
22
|
+
let RoleGuard = class RoleGuard {
|
|
23
|
+
constructor(i18n, jwtService, reflector, userService) {
|
|
24
|
+
this.i18n = i18n;
|
|
25
|
+
this.jwtService = jwtService;
|
|
26
|
+
this.reflector = reflector;
|
|
27
|
+
this.userService = userService;
|
|
28
|
+
}
|
|
29
|
+
async canActivate(context) {
|
|
30
|
+
if (!this.userService) {
|
|
31
|
+
throw new Error('USER_SERVICE not provided in AuthCommonModule context');
|
|
32
|
+
}
|
|
33
|
+
const ctx = graphql_1.GqlExecutionContext.create(context);
|
|
34
|
+
const request = ctx.getContext().req;
|
|
35
|
+
const token = await this.extractTokenFromHeader(request);
|
|
36
|
+
if (!token) {
|
|
37
|
+
throw new common_1.UnauthorizedException(await this.i18n.t('user.NO_TOKEN'));
|
|
38
|
+
}
|
|
39
|
+
const requiredRoles = this.getRequiredRoles(context);
|
|
40
|
+
const requiredPermissions = this.getRequiredPermissions(context);
|
|
41
|
+
const payload = (await this.verifyToken(token));
|
|
42
|
+
const user = await this.userService.findById(payload.sub);
|
|
43
|
+
const normalizedRole = user.role
|
|
44
|
+
? String(user.role).toLowerCase()
|
|
45
|
+
: '';
|
|
46
|
+
const hasRole = this.validateRole(normalizedRole, requiredRoles);
|
|
47
|
+
const userPermissions = rolePermissionsMap_constant_1.rolePermissionsMap[normalizedRole] ?? [];
|
|
48
|
+
const hasPermissions = this.validatePermissions(userPermissions, requiredPermissions);
|
|
49
|
+
if (!hasRole || !hasPermissions) {
|
|
50
|
+
throw new common_1.UnauthorizedException(await this.i18n.t('user.INSUFFICIENT_PERMISSIONS'));
|
|
51
|
+
}
|
|
52
|
+
request['user'] = {
|
|
53
|
+
id: user.id,
|
|
54
|
+
email: user.email,
|
|
55
|
+
role: user.role,
|
|
56
|
+
permissions: userPermissions,
|
|
57
|
+
};
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
extractTokenFromHeader(request) {
|
|
61
|
+
const [type, token] = request.headers['authorization']?.split(' ') ?? [];
|
|
62
|
+
return type === 'Bearer' ? token : null;
|
|
63
|
+
}
|
|
64
|
+
async verifyToken(token) {
|
|
65
|
+
try {
|
|
66
|
+
return await this.jwtService.verifyAsync(token, {
|
|
67
|
+
secret: process.env.JWT_SECRET,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
throw new common_1.UnauthorizedException(await this.i18n.t('user.INVALID_TOKEN'));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
getRequiredRoles(context) {
|
|
75
|
+
return (this.reflector.getAllAndOverride('roles', [
|
|
76
|
+
context.getHandler(),
|
|
77
|
+
context.getClass(),
|
|
78
|
+
]) ?? []);
|
|
79
|
+
}
|
|
80
|
+
getRequiredPermissions(context) {
|
|
81
|
+
return (this.reflector.getAllAndOverride('permissions', [
|
|
82
|
+
context.getHandler(),
|
|
83
|
+
context.getClass(),
|
|
84
|
+
]) ?? []);
|
|
85
|
+
}
|
|
86
|
+
validateRole(userRole, requiredRoles) {
|
|
87
|
+
return requiredRoles.length === 0 || requiredRoles.includes(userRole);
|
|
88
|
+
}
|
|
89
|
+
validatePermissions(userPermissions, required) {
|
|
90
|
+
return (required.length === 0 ||
|
|
91
|
+
required.every((p) => userPermissions.includes(p)));
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
exports.RoleGuard = RoleGuard;
|
|
95
|
+
exports.RoleGuard = RoleGuard = __decorate([
|
|
96
|
+
(0, common_1.Injectable)(),
|
|
97
|
+
__param(3, (0, common_1.Optional)()),
|
|
98
|
+
__param(3, (0, common_1.Inject)('USER_SERVICE')),
|
|
99
|
+
__metadata("design:paramtypes", [nestjs_i18n_1.I18nService,
|
|
100
|
+
jwt_1.JwtService,
|
|
101
|
+
core_1.Reflector, Object])
|
|
102
|
+
], RoleGuard);
|
|
103
|
+
//# sourceMappingURL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|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './guard/
|
|
1
|
+
export * from './constants/enum.constant';
|
|
2
|
+
export * from './constants/messages.constant';
|
|
3
|
+
export * from './constants/rolePermissionsMap.constant';
|
|
4
|
+
export * from './decorators/auth.decorator';
|
|
5
|
+
export * from './decorators/currentUser.decorator';
|
|
6
|
+
export * from './guard/role.guard';
|
|
7
|
+
export * from './interfaces/user.interface';
|
|
8
|
+
export * from './modules/auth.module';
|
|
7
9
|
export * from './nats/events';
|
|
8
10
|
export * from './nats/nats.module';
|
|
9
11
|
export * from './nats/nats.service';
|
package/dist/index.js
CHANGED
|
@@ -14,12 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
__exportStar(require("./
|
|
22
|
-
__exportStar(require("./guard/
|
|
17
|
+
__exportStar(require("./constants/enum.constant"), exports);
|
|
18
|
+
__exportStar(require("./constants/messages.constant"), exports);
|
|
19
|
+
__exportStar(require("./constants/rolePermissionsMap.constant"), exports);
|
|
20
|
+
__exportStar(require("./decorators/auth.decorator"), exports);
|
|
21
|
+
__exportStar(require("./decorators/currentUser.decorator"), exports);
|
|
22
|
+
__exportStar(require("./guard/role.guard"), exports);
|
|
23
|
+
__exportStar(require("./interfaces/user.interface"), exports);
|
|
24
|
+
__exportStar(require("./modules/auth.module"), exports);
|
|
23
25
|
__exportStar(require("./nats/events"), exports);
|
|
24
26
|
__exportStar(require("./nats/nats.module"), exports);
|
|
25
27
|
__exportStar(require("./nats/nats.service"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,4DAA0C;AAC1C,gEAA8C;AAC9C,0EAAwD;AAGxD,8DAA4C;AAC5C,qEAAmD;AAGnD,qDAAmC;AAGnC,8DAA4C;AAG5C,wDAAsC;AAGtC,gDAA8B;AAC9B,qDAAmC;AACnC,sDAAoC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.interface.js","sourceRoot":"","sources":["../../src/interfaces/user.interface.ts"],"names":[],"mappings":""}
|
|
@@ -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 AuthCommonModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AuthCommonModule = void 0;
|
|
11
|
+
const role_guard_1 = require("../guard/role.guard");
|
|
12
|
+
const common_1 = require("@nestjs/common");
|
|
13
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
14
|
+
const nats_module_1 = require("../nats/nats.module");
|
|
15
|
+
let AuthCommonModule = AuthCommonModule_1 = class AuthCommonModule {
|
|
16
|
+
static register(options) {
|
|
17
|
+
return {
|
|
18
|
+
module: AuthCommonModule_1,
|
|
19
|
+
imports: [
|
|
20
|
+
...(options.imports || []),
|
|
21
|
+
nats_module_1.NatsClientModule,
|
|
22
|
+
jwt_1.JwtModule.register({
|
|
23
|
+
secret: process.env.JWT_SECRET || 'default_secret',
|
|
24
|
+
signOptions: { expiresIn: process.env.JWT_EXPIRE },
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
providers: [
|
|
28
|
+
role_guard_1.RoleGuard,
|
|
29
|
+
...(options.providers || []),
|
|
30
|
+
{
|
|
31
|
+
provide: 'USER_SERVICE',
|
|
32
|
+
useClass: options.userService,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
exports: ['USER_SERVICE', jwt_1.JwtModule, role_guard_1.RoleGuard],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.AuthCommonModule = AuthCommonModule;
|
|
40
|
+
exports.AuthCommonModule = AuthCommonModule = AuthCommonModule_1 = __decorate([
|
|
41
|
+
(0, common_1.Module)({})
|
|
42
|
+
], AuthCommonModule);
|
|
43
|
+
//# sourceMappingURL=auth.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../src/modules/auth.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,oDAAgD;AAEhD,2CAAuD;AACvD,qCAAwC;AACxC,qDAAuD;AAGhD,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,MAAM,CAAC,QAAQ,CAAC,OAIf;QACC,OAAO;YACL,MAAM,EAAE,kBAAgB;YACxB,OAAO,EAAE;gBACP,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;gBAC1B,8BAAgB;gBAChB,eAAS,CAAC,QAAQ,CAAC;oBACjB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,gBAAgB;oBAClD,WAAW,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,UAAyB,EAAE;iBAClE,CAAC;aACH;YACD,SAAS,EAAE;gBACT,sBAAS;gBACT,GAAG,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;gBAC5B;oBACE,OAAO,EAAE,cAAc;oBACvB,QAAQ,EAAE,OAAO,CAAC,WAAW;iBAC9B;aACF;YACD,OAAO,EAAE,CAAC,cAAc,EAAE,eAAS,EAAE,sBAAS,CAAC;SAChD,CAAC;IACJ,CAAC;CACF,CAAA;AA3BY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,gBAAgB,CA2B5B"}
|