ecrs-auth-core 1.0.0
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/auth.controller.d.ts +9 -0
- package/dist/auth.controller.js +42 -0
- package/dist/auth.module.d.ts +6 -0
- package/dist/auth.module.js +64 -0
- package/dist/auth.service.d.ts +27 -0
- package/dist/auth.service.js +211 -0
- package/dist/decorators/current-user.decorator.d.ts +1 -0
- package/dist/decorators/current-user.decorator.js +9 -0
- package/dist/decorators/feature.decorator.d.ts +1 -0
- package/dist/decorators/feature.decorator.js +11 -0
- package/dist/decorators/has-permission.decorator.d.ts +6 -0
- package/dist/decorators/has-permission.decorator.js +8 -0
- package/dist/decorators/roles.decorator.d.ts +1 -0
- package/dist/decorators/roles.decorator.js +6 -0
- package/dist/decorators/route-permission.decorator.d.ts +1 -0
- package/dist/decorators/route-permission.decorator.js +11 -0
- package/dist/dtos/login.dto.d.ts +4 -0
- package/dist/dtos/login.dto.js +7 -0
- package/dist/entities/feature.entity.d.ts +9 -0
- package/dist/entities/feature.entity.js +48 -0
- package/dist/entities/module-route.entity.d.ts +9 -0
- package/dist/entities/module-route.entity.js +48 -0
- package/dist/entities/module-screen-permission.entity.d.ts +15 -0
- package/dist/entities/module-screen-permission.entity.js +44 -0
- package/dist/entities/module.entity.d.ts +8 -0
- package/dist/entities/module.entity.js +44 -0
- package/dist/entities/role.entity.d.ts +6 -0
- package/dist/entities/role.entity.js +36 -0
- package/dist/entities/user-feature-access.entity.d.ts +19 -0
- package/dist/entities/user-feature-access.entity.js +88 -0
- package/dist/entities/user-module-access.entity.d.ts +12 -0
- package/dist/entities/user-module-access.entity.js +60 -0
- package/dist/entities/user.entity.d.ts +24 -0
- package/dist/entities/user.entity.js +108 -0
- package/dist/guards/feature.guard.d.ts +7 -0
- package/dist/guards/feature.guard.js +34 -0
- package/dist/guards/module.guard.d.ts +8 -0
- package/dist/guards/module.guard.js +36 -0
- package/dist/guards/permission.guard.d.ts +7 -0
- package/dist/guards/permission.guard.js +41 -0
- package/dist/guards/roles.guard.d.ts +7 -0
- package/dist/guards/roles.guard.js +34 -0
- package/dist/guards/route.guard.d.ts +7 -0
- package/dist/guards/route.guard.js +34 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +28 -0
- package/dist/jwt/jwt.guard.d.ts +4 -0
- package/dist/jwt/jwt.guard.js +18 -0
- package/dist/jwt/jwt.strategy.d.ts +14 -0
- package/dist/jwt/jwt.strategy.js +43 -0
- package/package.json +41 -0
|
@@ -0,0 +1,44 @@
|
|
|
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.Module = void 0;
|
|
13
|
+
// src/entities/module.entity.ts
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
let Module = class Module {
|
|
16
|
+
};
|
|
17
|
+
exports.Module = Module;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
20
|
+
__metadata("design:type", Number)
|
|
21
|
+
], Module.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.Column)({ name: 'module_name', length: 100, unique: true }),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], Module.prototype, "moduleName", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)({ name: 'module_description', length: 255, nullable: true }),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], Module.prototype, "moduleDescription", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ type: 'smallint', default: 1 }),
|
|
32
|
+
__metadata("design:type", Number)
|
|
33
|
+
], Module.prototype, "status", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)({ name: 'created_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
36
|
+
__metadata("design:type", Date)
|
|
37
|
+
], Module.prototype, "createdAt", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'updated_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
40
|
+
__metadata("design:type", Date)
|
|
41
|
+
], Module.prototype, "updatedAt", void 0);
|
|
42
|
+
exports.Module = Module = __decorate([
|
|
43
|
+
(0, typeorm_1.Entity)({ name: 'tbl_c_modules' })
|
|
44
|
+
], Module);
|
|
@@ -0,0 +1,36 @@
|
|
|
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.Role = void 0;
|
|
13
|
+
// src/entities/role.entity.ts
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
let Role = class Role {
|
|
16
|
+
};
|
|
17
|
+
exports.Role = Role;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
20
|
+
__metadata("design:type", Number)
|
|
21
|
+
], Role.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.Column)({ name: 'role_name', length: 100, unique: true }),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], Role.prototype, "roleName", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)({ name: 'role_description', length: 255, nullable: true }),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], Role.prototype, "roleDescription", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ name: 'is_active', default: true }),
|
|
32
|
+
__metadata("design:type", Boolean)
|
|
33
|
+
], Role.prototype, "isActive", void 0);
|
|
34
|
+
exports.Role = Role = __decorate([
|
|
35
|
+
(0, typeorm_1.Entity)({ name: 'tbl_c_master_roles' })
|
|
36
|
+
], Role);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class UserFeatureAccess {
|
|
2
|
+
id: number;
|
|
3
|
+
userId: number;
|
|
4
|
+
moduleId: number;
|
|
5
|
+
featureId: number;
|
|
6
|
+
accessLevel: string;
|
|
7
|
+
canView: boolean;
|
|
8
|
+
canCreate: boolean;
|
|
9
|
+
canModify: boolean;
|
|
10
|
+
canDelete: boolean;
|
|
11
|
+
canImport: boolean;
|
|
12
|
+
canExport: boolean;
|
|
13
|
+
status: number;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
updatedAt: Date;
|
|
16
|
+
createdBy: number;
|
|
17
|
+
updatedBy?: number;
|
|
18
|
+
isDeleted: number;
|
|
19
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
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.UserFeatureAccess = void 0;
|
|
13
|
+
// src/entities/user-feature-access.entity.ts
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
let UserFeatureAccess = class UserFeatureAccess {
|
|
16
|
+
};
|
|
17
|
+
exports.UserFeatureAccess = UserFeatureAccess;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
20
|
+
__metadata("design:type", Number)
|
|
21
|
+
], UserFeatureAccess.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.Column)({ name: 'user_id' }),
|
|
24
|
+
__metadata("design:type", Number)
|
|
25
|
+
], UserFeatureAccess.prototype, "userId", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)({ name: 'module_id' }),
|
|
28
|
+
__metadata("design:type", Number)
|
|
29
|
+
], UserFeatureAccess.prototype, "moduleId", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ name: 'feature_id' }),
|
|
32
|
+
__metadata("design:type", Number)
|
|
33
|
+
], UserFeatureAccess.prototype, "featureId", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)({ name: 'access_level', default: 'view' }),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], UserFeatureAccess.prototype, "accessLevel", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'can_view', default: false }),
|
|
40
|
+
__metadata("design:type", Boolean)
|
|
41
|
+
], UserFeatureAccess.prototype, "canView", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({ name: 'can_create', default: false }),
|
|
44
|
+
__metadata("design:type", Boolean)
|
|
45
|
+
], UserFeatureAccess.prototype, "canCreate", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.Column)({ name: 'can_modify', default: false }),
|
|
48
|
+
__metadata("design:type", Boolean)
|
|
49
|
+
], UserFeatureAccess.prototype, "canModify", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typeorm_1.Column)({ name: 'can_delete', default: false }),
|
|
52
|
+
__metadata("design:type", Boolean)
|
|
53
|
+
], UserFeatureAccess.prototype, "canDelete", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, typeorm_1.Column)({ name: 'can_import', default: false }),
|
|
56
|
+
__metadata("design:type", Boolean)
|
|
57
|
+
], UserFeatureAccess.prototype, "canImport", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, typeorm_1.Column)({ name: 'can_export', default: false }),
|
|
60
|
+
__metadata("design:type", Boolean)
|
|
61
|
+
], UserFeatureAccess.prototype, "canExport", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, typeorm_1.Column)({ type: 'smallint', default: 1 }),
|
|
64
|
+
__metadata("design:type", Number)
|
|
65
|
+
], UserFeatureAccess.prototype, "status", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, typeorm_1.Column)({ name: 'created_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
68
|
+
__metadata("design:type", Date)
|
|
69
|
+
], UserFeatureAccess.prototype, "createdAt", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, typeorm_1.Column)({ name: 'updated_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
72
|
+
__metadata("design:type", Date)
|
|
73
|
+
], UserFeatureAccess.prototype, "updatedAt", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, typeorm_1.Column)({ name: 'created_by' }),
|
|
76
|
+
__metadata("design:type", Number)
|
|
77
|
+
], UserFeatureAccess.prototype, "createdBy", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, typeorm_1.Column)({ name: 'updated_by', nullable: true }),
|
|
80
|
+
__metadata("design:type", Number)
|
|
81
|
+
], UserFeatureAccess.prototype, "updatedBy", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, typeorm_1.Column)({ name: 'is_deleted', type: 'smallint', default: 0 }),
|
|
84
|
+
__metadata("design:type", Number)
|
|
85
|
+
], UserFeatureAccess.prototype, "isDeleted", void 0);
|
|
86
|
+
exports.UserFeatureAccess = UserFeatureAccess = __decorate([
|
|
87
|
+
(0, typeorm_1.Entity)({ name: 'tbl_c_user_feature_access' })
|
|
88
|
+
], UserFeatureAccess);
|
|
@@ -0,0 +1,60 @@
|
|
|
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.UserModuleAccess = void 0;
|
|
13
|
+
// src/entities/user-module-access.entity.ts
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
let UserModuleAccess = class UserModuleAccess {
|
|
16
|
+
};
|
|
17
|
+
exports.UserModuleAccess = UserModuleAccess;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
20
|
+
__metadata("design:type", Number)
|
|
21
|
+
], UserModuleAccess.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.Column)({ name: 'user_id' }),
|
|
24
|
+
__metadata("design:type", Number)
|
|
25
|
+
], UserModuleAccess.prototype, "userId", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)({ name: 'module_id' }),
|
|
28
|
+
__metadata("design:type", Number)
|
|
29
|
+
], UserModuleAccess.prototype, "moduleId", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)({ name: 'access_level', default: 'view' }),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], UserModuleAccess.prototype, "accessLevel", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)({ type: 'smallint', default: 1 }),
|
|
36
|
+
__metadata("design:type", Number)
|
|
37
|
+
], UserModuleAccess.prototype, "status", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ name: 'created_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
40
|
+
__metadata("design:type", Date)
|
|
41
|
+
], UserModuleAccess.prototype, "createdAt", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({ name: 'updated_at', type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
44
|
+
__metadata("design:type", Date)
|
|
45
|
+
], UserModuleAccess.prototype, "updatedAt", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.Column)({ name: 'created_by' }),
|
|
48
|
+
__metadata("design:type", Number)
|
|
49
|
+
], UserModuleAccess.prototype, "createdBy", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typeorm_1.Column)({ name: 'updated_by', nullable: true }),
|
|
52
|
+
__metadata("design:type", Number)
|
|
53
|
+
], UserModuleAccess.prototype, "updatedBy", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, typeorm_1.Column)({ name: 'is_deleted', type: 'smallint', default: 0 }),
|
|
56
|
+
__metadata("design:type", Number)
|
|
57
|
+
], UserModuleAccess.prototype, "isDeleted", void 0);
|
|
58
|
+
exports.UserModuleAccess = UserModuleAccess = __decorate([
|
|
59
|
+
(0, typeorm_1.Entity)({ name: 'tbl_c_user_module_access' })
|
|
60
|
+
], UserModuleAccess);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare class User {
|
|
2
|
+
id: number;
|
|
3
|
+
firstName: string;
|
|
4
|
+
lastName: string;
|
|
5
|
+
mobileNo: number;
|
|
6
|
+
email: string;
|
|
7
|
+
password: string;
|
|
8
|
+
status: number;
|
|
9
|
+
userImage: string;
|
|
10
|
+
roleId: number;
|
|
11
|
+
parentId: number;
|
|
12
|
+
notificationToken: string;
|
|
13
|
+
apiToken: string;
|
|
14
|
+
deviceDetails: string;
|
|
15
|
+
otpNumber: number;
|
|
16
|
+
isOtpVerified: number;
|
|
17
|
+
moduleId: number;
|
|
18
|
+
createdBy: number;
|
|
19
|
+
updatedBy: number;
|
|
20
|
+
deletedBy: number;
|
|
21
|
+
createdAt: Date;
|
|
22
|
+
updatedAt: Date;
|
|
23
|
+
deletedAt: Date;
|
|
24
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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.User = void 0;
|
|
13
|
+
// src/entities/user.entity.ts
|
|
14
|
+
const typeorm_1 = require("typeorm");
|
|
15
|
+
let User = class User {
|
|
16
|
+
};
|
|
17
|
+
exports.User = User;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
20
|
+
__metadata("design:type", Number)
|
|
21
|
+
], User.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, typeorm_1.Column)({ length: 64 }),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], User.prototype, "firstName", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, typeorm_1.Column)({ length: 64 }),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], User.prototype, "lastName", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typeorm_1.Column)('bigint'),
|
|
32
|
+
__metadata("design:type", Number)
|
|
33
|
+
], User.prototype, "mobileNo", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, typeorm_1.Column)({ length: 250, unique: true }),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], User.prototype, "email", void 0);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ length: 200 }),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], User.prototype, "password", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typeorm_1.Column)({ type: 'smallint', default: 1 }),
|
|
44
|
+
__metadata("design:type", Number)
|
|
45
|
+
], User.prototype, "status", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typeorm_1.Column)({ length: 250, nullable: true }),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], User.prototype, "userImage", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typeorm_1.Column)(),
|
|
52
|
+
__metadata("design:type", Number)
|
|
53
|
+
], User.prototype, "roleId", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, typeorm_1.Column)(),
|
|
56
|
+
__metadata("design:type", Number)
|
|
57
|
+
], User.prototype, "parentId", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
60
|
+
__metadata("design:type", String)
|
|
61
|
+
], User.prototype, "notificationToken", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, typeorm_1.Column)({ length: 500, nullable: true }),
|
|
64
|
+
__metadata("design:type", String)
|
|
65
|
+
], User.prototype, "apiToken", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, typeorm_1.Column)({ length: 500, nullable: true }),
|
|
68
|
+
__metadata("design:type", String)
|
|
69
|
+
], User.prototype, "deviceDetails", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, typeorm_1.Column)({ type: 'int', nullable: true }),
|
|
72
|
+
__metadata("design:type", Number)
|
|
73
|
+
], User.prototype, "otpNumber", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, typeorm_1.Column)({ type: 'smallint', nullable: true }),
|
|
76
|
+
__metadata("design:type", Number)
|
|
77
|
+
], User.prototype, "isOtpVerified", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
80
|
+
__metadata("design:type", Number)
|
|
81
|
+
], User.prototype, "moduleId", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, typeorm_1.Column)(),
|
|
84
|
+
__metadata("design:type", Number)
|
|
85
|
+
], User.prototype, "createdBy", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
88
|
+
__metadata("design:type", Number)
|
|
89
|
+
], User.prototype, "updatedBy", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
92
|
+
__metadata("design:type", Number)
|
|
93
|
+
], User.prototype, "deletedBy", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, typeorm_1.Column)({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' }),
|
|
96
|
+
__metadata("design:type", Date)
|
|
97
|
+
], User.prototype, "createdAt", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, typeorm_1.Column)({ type: 'timestamp', nullable: true }),
|
|
100
|
+
__metadata("design:type", Date)
|
|
101
|
+
], User.prototype, "updatedAt", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
(0, typeorm_1.Column)({ type: 'timestamp', nullable: true }),
|
|
104
|
+
__metadata("design:type", Date)
|
|
105
|
+
], User.prototype, "deletedAt", void 0);
|
|
106
|
+
exports.User = User = __decorate([
|
|
107
|
+
(0, typeorm_1.Entity)({ name: 'tbl_users' })
|
|
108
|
+
], User);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
export declare class FeatureGuard implements CanActivate {
|
|
4
|
+
private readonly reflector;
|
|
5
|
+
constructor(reflector: Reflector);
|
|
6
|
+
canActivate(context: ExecutionContext): boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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.FeatureGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@nestjs/core");
|
|
15
|
+
let FeatureGuard = class FeatureGuard {
|
|
16
|
+
constructor(reflector) {
|
|
17
|
+
this.reflector = reflector;
|
|
18
|
+
}
|
|
19
|
+
canActivate(context) {
|
|
20
|
+
const permission = this.reflector.get('feature_permission', context.getHandler());
|
|
21
|
+
const feature = this.reflector.get('feature_name', context.getHandler());
|
|
22
|
+
if (!permission || !feature)
|
|
23
|
+
return true;
|
|
24
|
+
const { user } = context.switchToHttp().getRequest();
|
|
25
|
+
const userFeatures = user?.permissions?.features || {};
|
|
26
|
+
const featurePermissions = userFeatures[feature] || [];
|
|
27
|
+
return featurePermissions.includes(permission);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.FeatureGuard = FeatureGuard;
|
|
31
|
+
exports.FeatureGuard = FeatureGuard = __decorate([
|
|
32
|
+
(0, common_1.Injectable)(),
|
|
33
|
+
__metadata("design:paramtypes", [core_1.Reflector])
|
|
34
|
+
], FeatureGuard);
|
|
@@ -0,0 +1,36 @@
|
|
|
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.ModuleGuard = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
let ModuleGuard = class ModuleGuard {
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.config = config;
|
|
20
|
+
}
|
|
21
|
+
canActivate(context) {
|
|
22
|
+
const request = context.switchToHttp().getRequest();
|
|
23
|
+
const user = request.user;
|
|
24
|
+
// SuperAdmin can bypass module checks
|
|
25
|
+
const isSuperAdmin = user.roleId === 1;
|
|
26
|
+
if (isSuperAdmin)
|
|
27
|
+
return true;
|
|
28
|
+
return user.moduleId === this.config.moduleId;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.ModuleGuard = ModuleGuard;
|
|
32
|
+
exports.ModuleGuard = ModuleGuard = __decorate([
|
|
33
|
+
(0, common_1.Injectable)(),
|
|
34
|
+
__param(0, (0, common_1.Inject)('MODULE_CONFIG')),
|
|
35
|
+
__metadata("design:paramtypes", [Object])
|
|
36
|
+
], ModuleGuard);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
export declare class PermissionGuard implements CanActivate {
|
|
4
|
+
private readonly reflector;
|
|
5
|
+
constructor(reflector: Reflector);
|
|
6
|
+
canActivate(context: ExecutionContext): boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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.PermissionGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@nestjs/core");
|
|
15
|
+
let PermissionGuard = class PermissionGuard {
|
|
16
|
+
constructor(reflector) {
|
|
17
|
+
this.reflector = reflector;
|
|
18
|
+
}
|
|
19
|
+
canActivate(context) {
|
|
20
|
+
const permissionMeta = this.reflector.get('combined_permission', context.getHandler());
|
|
21
|
+
if (!permissionMeta)
|
|
22
|
+
return true;
|
|
23
|
+
const request = context.switchToHttp().getRequest();
|
|
24
|
+
const user = request.user;
|
|
25
|
+
const { type, permission, name } = permissionMeta;
|
|
26
|
+
if (type === 'feature') {
|
|
27
|
+
const perms = user?.permissions?.features?.[name] || [];
|
|
28
|
+
return perms.includes(permission);
|
|
29
|
+
}
|
|
30
|
+
if (type === 'route') {
|
|
31
|
+
const perms = user?.permissions?.routes?.[name] || [];
|
|
32
|
+
return perms.includes(permission);
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.PermissionGuard = PermissionGuard;
|
|
38
|
+
exports.PermissionGuard = PermissionGuard = __decorate([
|
|
39
|
+
(0, common_1.Injectable)(),
|
|
40
|
+
__metadata("design:paramtypes", [core_1.Reflector])
|
|
41
|
+
], PermissionGuard);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
export declare class RolesGuard implements CanActivate {
|
|
4
|
+
private readonly reflector;
|
|
5
|
+
constructor(reflector: Reflector);
|
|
6
|
+
canActivate(context: ExecutionContext): boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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.RolesGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@nestjs/core");
|
|
15
|
+
let RolesGuard = class RolesGuard {
|
|
16
|
+
constructor(reflector) {
|
|
17
|
+
this.reflector = reflector;
|
|
18
|
+
}
|
|
19
|
+
canActivate(context) {
|
|
20
|
+
const requiredRoles = this.reflector.getAllAndOverride('roles', [
|
|
21
|
+
context.getHandler(),
|
|
22
|
+
context.getClass(),
|
|
23
|
+
]);
|
|
24
|
+
if (!requiredRoles || requiredRoles.length === 0)
|
|
25
|
+
return true;
|
|
26
|
+
const { user } = context.switchToHttp().getRequest();
|
|
27
|
+
return requiredRoles.includes(user.roleId?.toString());
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.RolesGuard = RolesGuard;
|
|
31
|
+
exports.RolesGuard = RolesGuard = __decorate([
|
|
32
|
+
(0, common_1.Injectable)(),
|
|
33
|
+
__metadata("design:paramtypes", [core_1.Reflector])
|
|
34
|
+
], RolesGuard);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
export declare class RouteGuard implements CanActivate {
|
|
4
|
+
private readonly reflector;
|
|
5
|
+
constructor(reflector: Reflector);
|
|
6
|
+
canActivate(context: ExecutionContext): boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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.RouteGuard = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@nestjs/core");
|
|
15
|
+
let RouteGuard = class RouteGuard {
|
|
16
|
+
constructor(reflector) {
|
|
17
|
+
this.reflector = reflector;
|
|
18
|
+
}
|
|
19
|
+
canActivate(context) {
|
|
20
|
+
const permission = this.reflector.get('route_permission', context.getHandler());
|
|
21
|
+
const route = this.reflector.get('route_name', context.getHandler());
|
|
22
|
+
if (!permission || !route)
|
|
23
|
+
return true;
|
|
24
|
+
const request = context.switchToHttp().getRequest();
|
|
25
|
+
const user = request.user;
|
|
26
|
+
const routeAccess = user?.permissions?.routes?.[route] || [];
|
|
27
|
+
return routeAccess.includes(permission);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.RouteGuard = RouteGuard;
|
|
31
|
+
exports.RouteGuard = RouteGuard = __decorate([
|
|
32
|
+
(0, common_1.Injectable)(),
|
|
33
|
+
__metadata("design:paramtypes", [core_1.Reflector])
|
|
34
|
+
], RouteGuard);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './auth.module';
|
|
2
|
+
export * from './auth.service';
|
|
3
|
+
export * from './jwt/jwt.guard';
|
|
4
|
+
export * from './jwt/jwt.strategy';
|
|
5
|
+
export * from './guards/roles.guard';
|
|
6
|
+
export * from './guards/module.guard';
|
|
7
|
+
export * from './guards/feature.guard';
|
|
8
|
+
export * from './decorators/current-user.decorator';
|
|
9
|
+
export * from './guards/route.guard';
|
|
10
|
+
export * from './decorators/route-permission.decorator';
|
|
11
|
+
export * from './guards/permission.guard';
|
|
12
|
+
export * from './decorators/has-permission.decorator';
|