ecrs-auth-core 1.0.43 → 1.0.44
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 +263 -0
- package/dist/auth.controller.d.ts +26 -19
- package/dist/auth.controller.js +41 -41
- package/dist/auth.module.d.ts +9 -9
- package/dist/auth.module.js +143 -143
- package/dist/auth.service.d.ts +47 -40
- package/dist/auth.service.js +185 -168
- package/dist/constants/constants.d.ts +1 -1
- package/dist/constants/constants.js +4 -4
- package/dist/decorators/current-user.decorator.d.ts +1 -1
- package/dist/decorators/current-user.decorator.js +9 -9
- package/dist/decorators/feature.decorator.d.ts +1 -1
- package/dist/decorators/feature.decorator.js +11 -11
- package/dist/decorators/has-permission.decorator.d.ts +6 -6
- package/dist/decorators/has-permission.decorator.js +8 -8
- package/dist/decorators/roles.decorator.d.ts +1 -1
- package/dist/decorators/roles.decorator.js +6 -6
- package/dist/decorators/route-permission.decorator.d.ts +1 -1
- package/dist/decorators/route-permission.decorator.js +11 -11
- package/dist/dtos/login.dto.d.ts +4 -4
- package/dist/dtos/login.dto.js +7 -7
- package/dist/entities/feature.entity.d.ts +9 -9
- package/dist/entities/feature.entity.js +48 -48
- package/dist/entities/module-route.entity.d.ts +9 -9
- package/dist/entities/module-route.entity.js +48 -48
- package/dist/entities/module-screen-permission.entity.d.ts +15 -15
- package/dist/entities/module-screen-permission.entity.js +44 -44
- package/dist/entities/module.entity.d.ts +8 -8
- package/dist/entities/module.entity.js +44 -44
- package/dist/entities/role.entity.d.ts +7 -7
- package/dist/entities/role.entity.js +44 -44
- package/dist/entities/user-feature-access.entity.d.ts +19 -19
- package/dist/entities/user-feature-access.entity.js +88 -88
- package/dist/entities/user-module-access.entity.d.ts +12 -12
- package/dist/entities/user-module-access.entity.js +60 -60
- package/dist/entities/user.entity.d.ts +25 -24
- package/dist/entities/user.entity.js +112 -108
- package/dist/guards/feature.guard.d.ts +7 -7
- package/dist/guards/feature.guard.js +34 -34
- package/dist/guards/module.guard.d.ts +8 -8
- package/dist/guards/module.guard.js +36 -36
- package/dist/guards/permission.guard.d.ts +7 -7
- package/dist/guards/permission.guard.js +41 -41
- package/dist/guards/roles.guard.d.ts +7 -7
- package/dist/guards/roles.guard.js +34 -34
- package/dist/guards/route.guard.d.ts +7 -7
- package/dist/guards/route.guard.js +34 -34
- package/dist/index.d.ts +23 -23
- package/dist/index.js +45 -45
- package/dist/interfaces/auth-core-options.interface.d.ts +30 -30
- package/dist/interfaces/auth-core-options.interface.js +2 -2
- package/dist/jwt/jwt.guard.d.ts +4 -4
- package/dist/jwt/jwt.guard.js +18 -18
- package/dist/jwt/jwt.strategy.d.ts +14 -14
- package/dist/jwt/jwt.strategy.js +42 -42
- package/package.json +47 -47
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/jwt/jwt.guard.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const JwtAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
2
|
-
export declare class JwtAuthGuard extends JwtAuthGuard_base {
|
|
3
|
-
}
|
|
4
|
-
export {};
|
|
1
|
+
declare const JwtAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
2
|
+
export declare class JwtAuthGuard extends JwtAuthGuard_base {
|
|
3
|
+
}
|
|
4
|
+
export {};
|
package/dist/jwt/jwt.guard.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.JwtAuthGuard = void 0;
|
|
10
|
-
// src/jwt/jwt.guard.ts
|
|
11
|
-
const common_1 = require("@nestjs/common");
|
|
12
|
-
const passport_1 = require("@nestjs/passport");
|
|
13
|
-
let JwtAuthGuard = class JwtAuthGuard extends (0, passport_1.AuthGuard)('jwt') {
|
|
14
|
-
};
|
|
15
|
-
exports.JwtAuthGuard = JwtAuthGuard;
|
|
16
|
-
exports.JwtAuthGuard = JwtAuthGuard = __decorate([
|
|
17
|
-
(0, common_1.Injectable)()
|
|
18
|
-
], JwtAuthGuard);
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.JwtAuthGuard = void 0;
|
|
10
|
+
// src/jwt/jwt.guard.ts
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const passport_1 = require("@nestjs/passport");
|
|
13
|
+
let JwtAuthGuard = class JwtAuthGuard extends (0, passport_1.AuthGuard)('jwt') {
|
|
14
|
+
};
|
|
15
|
+
exports.JwtAuthGuard = JwtAuthGuard;
|
|
16
|
+
exports.JwtAuthGuard = JwtAuthGuard = __decorate([
|
|
17
|
+
(0, common_1.Injectable)()
|
|
18
|
+
], JwtAuthGuard);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Strategy } from 'passport-jwt';
|
|
2
|
-
import { AuthService } from '../auth.service';
|
|
3
|
-
declare const JwtStrategy_base: new (...args: any[]) => Strategy;
|
|
4
|
-
export declare class JwtStrategy extends JwtStrategy_base {
|
|
5
|
-
private readonly authService;
|
|
6
|
-
constructor(authService: AuthService);
|
|
7
|
-
validate(payload: any): Promise<{
|
|
8
|
-
id: number;
|
|
9
|
-
email: string;
|
|
10
|
-
roleId: number;
|
|
11
|
-
moduleId: number;
|
|
12
|
-
} | null>;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
1
|
+
import { Strategy } from 'passport-jwt';
|
|
2
|
+
import { AuthService } from '../auth.service';
|
|
3
|
+
declare const JwtStrategy_base: new (...args: any[]) => Strategy;
|
|
4
|
+
export declare class JwtStrategy extends JwtStrategy_base {
|
|
5
|
+
private readonly authService;
|
|
6
|
+
constructor(authService: AuthService);
|
|
7
|
+
validate(payload: any): Promise<{
|
|
8
|
+
id: number;
|
|
9
|
+
email: string;
|
|
10
|
+
roleId: number;
|
|
11
|
+
moduleId: number;
|
|
12
|
+
} | null>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
package/dist/jwt/jwt.strategy.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
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
|
-
const auth_service_1 = require("../auth.service");
|
|
17
|
-
let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
|
|
18
|
-
constructor(authService) {
|
|
19
|
-
super({
|
|
20
|
-
jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
21
|
-
ignoreExpiration: false,
|
|
22
|
-
secretOrKey: process.env.JWT_SECRET || 'your-secret-key',
|
|
23
|
-
});
|
|
24
|
-
this.authService = authService;
|
|
25
|
-
}
|
|
26
|
-
async validate(payload) {
|
|
27
|
-
const user = await this.authService.findUserById(payload.id);
|
|
28
|
-
if (!user)
|
|
29
|
-
return null;
|
|
30
|
-
return {
|
|
31
|
-
id: user.id,
|
|
32
|
-
email: user.email,
|
|
33
|
-
roleId: user.roleId,
|
|
34
|
-
moduleId: user.moduleId,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
exports.JwtStrategy = JwtStrategy;
|
|
39
|
-
exports.JwtStrategy = JwtStrategy = __decorate([
|
|
40
|
-
(0, common_1.Injectable)(),
|
|
41
|
-
__metadata("design:paramtypes", [auth_service_1.AuthService])
|
|
42
|
-
], JwtStrategy);
|
|
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
|
+
const auth_service_1 = require("../auth.service");
|
|
17
|
+
let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
|
|
18
|
+
constructor(authService) {
|
|
19
|
+
super({
|
|
20
|
+
jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
|
|
21
|
+
ignoreExpiration: false,
|
|
22
|
+
secretOrKey: process.env.JWT_SECRET || 'your-secret-key',
|
|
23
|
+
});
|
|
24
|
+
this.authService = authService;
|
|
25
|
+
}
|
|
26
|
+
async validate(payload) {
|
|
27
|
+
const user = await this.authService.findUserById(payload.id);
|
|
28
|
+
if (!user)
|
|
29
|
+
return null;
|
|
30
|
+
return {
|
|
31
|
+
id: user.id,
|
|
32
|
+
email: user.email,
|
|
33
|
+
roleId: user.roleId,
|
|
34
|
+
moduleId: user.moduleId,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.JwtStrategy = JwtStrategy;
|
|
39
|
+
exports.JwtStrategy = JwtStrategy = __decorate([
|
|
40
|
+
(0, common_1.Injectable)(),
|
|
41
|
+
__metadata("design:paramtypes", [auth_service_1.AuthService])
|
|
42
|
+
], JwtStrategy);
|
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ecrs-auth-core",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Centralized authentication and authorization module for ECRS apps",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
],
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "tsc -p tsconfig.json"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"nestjs",
|
|
15
|
-
"auth",
|
|
16
|
-
"jwt",
|
|
17
|
-
"module",
|
|
18
|
-
"ecrs"
|
|
19
|
-
],
|
|
20
|
-
"author": "Chetan Yadnik",
|
|
21
|
-
"license": "MIT",
|
|
22
|
-
"peerDependencies": {
|
|
23
|
-
"@nestjs/common": "^10.2.7",
|
|
24
|
-
"@nestjs/core": "^10.2.7",
|
|
25
|
-
"@nestjs/passport": "^10.0.3",
|
|
26
|
-
"bcrypt": "^5.1.1",
|
|
27
|
-
"passport": "^0.6.0",
|
|
28
|
-
"passport-jwt": "^4.0.1",
|
|
29
|
-
"typeorm": "^0.3.25"
|
|
30
|
-
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"@nestjs/jwt": "^10.0.3",
|
|
33
|
-
"@nestjs/typeorm": "^10.0.0",
|
|
34
|
-
"jsonwebtoken": "^9.0.2",
|
|
35
|
-
"rxjs": "^7.8.1"
|
|
36
|
-
},
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"@nestjs/common": "^10.2.7",
|
|
39
|
-
"@nestjs/core": "^10.2.7",
|
|
40
|
-
"@nestjs/passport": "^10.0.3",
|
|
41
|
-
"@types/bcrypt": "^6.0.0",
|
|
42
|
-
"@types/passport-jwt": "^4.0.1",
|
|
43
|
-
"reflect-metadata": "^0.1.13",
|
|
44
|
-
"typeorm": "^0.3.17",
|
|
45
|
-
"typescript": "^5.8.3"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "ecrs-auth-core",
|
|
3
|
+
"version": "1.0.44",
|
|
4
|
+
"description": "Centralized authentication and authorization module for ECRS apps",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc -p tsconfig.json"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"nestjs",
|
|
15
|
+
"auth",
|
|
16
|
+
"jwt",
|
|
17
|
+
"module",
|
|
18
|
+
"ecrs"
|
|
19
|
+
],
|
|
20
|
+
"author": "Chetan Yadnik",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@nestjs/common": "^10.2.7",
|
|
24
|
+
"@nestjs/core": "^10.2.7",
|
|
25
|
+
"@nestjs/passport": "^10.0.3",
|
|
26
|
+
"bcrypt": "^5.1.1",
|
|
27
|
+
"passport": "^0.6.0",
|
|
28
|
+
"passport-jwt": "^4.0.1",
|
|
29
|
+
"typeorm": "^0.3.25"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@nestjs/jwt": "^10.0.3",
|
|
33
|
+
"@nestjs/typeorm": "^10.0.0",
|
|
34
|
+
"jsonwebtoken": "^9.0.2",
|
|
35
|
+
"rxjs": "^7.8.1"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@nestjs/common": "^10.2.7",
|
|
39
|
+
"@nestjs/core": "^10.2.7",
|
|
40
|
+
"@nestjs/passport": "^10.0.3",
|
|
41
|
+
"@types/bcrypt": "^6.0.0",
|
|
42
|
+
"@types/passport-jwt": "^4.0.1",
|
|
43
|
+
"reflect-metadata": "^0.1.13",
|
|
44
|
+
"typeorm": "^0.3.17",
|
|
45
|
+
"typescript": "^5.8.3"
|
|
46
|
+
}
|
|
47
|
+
}
|