ecrs-auth-core 1.0.19 → 1.0.20

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.
@@ -22,10 +22,6 @@ const permission_guard_1 = require("./guards/permission.guard");
22
22
  exports.AUTH_CORE_OPTIONS = "AUTH_CORE_OPTIONS";
23
23
  let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
24
24
  static register(options) {
25
- const optionsProvider = {
26
- provide: exports.AUTH_CORE_OPTIONS,
27
- useValue: options,
28
- };
29
25
  return {
30
26
  module: AuthCoreModule_1,
31
27
  imports: [
@@ -39,7 +35,10 @@ let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
39
35
  ],
40
36
  controllers: [auth_controller_1.AuthController],
41
37
  providers: [
42
- optionsProvider,
38
+ {
39
+ provide: exports.AUTH_CORE_OPTIONS,
40
+ useValue: options,
41
+ },
43
42
  auth_service_1.AuthService,
44
43
  jwt_strategy_1.JwtStrategy,
45
44
  jwt_guard_1.JwtAuthGuard,
@@ -70,9 +69,12 @@ let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
70
69
  return {
71
70
  module: AuthCoreModule_1,
72
71
  imports: [
73
- jwt_1.JwtModule.register({
74
- secret: process.env.JWT_SECRET || "secret",
75
- signOptions: { expiresIn: "1d" },
72
+ jwt_1.JwtModule.registerAsync({
73
+ useFactory: (options) => ({
74
+ secret: options.jwtSecret,
75
+ signOptions: { expiresIn: options.jwtExpiresIn },
76
+ }),
77
+ inject: [exports.AUTH_CORE_OPTIONS],
76
78
  }),
77
79
  ],
78
80
  controllers: [auth_controller_1.AuthController],
@@ -54,15 +54,15 @@ let AuthService = class AuthService {
54
54
  constructor(jwtService, options) {
55
55
  this.jwtService = jwtService;
56
56
  this.options = options;
57
- const { userRepo, roleRepo, moduleRepo, featureRepo, routeRepo, featureAccessRepo, moduleAccessRepo, screenPermissionRepo, } = options.repositories;
58
- this.userRepo = userRepo;
59
- this.roleRepo = roleRepo;
60
- this.moduleRepo = moduleRepo;
61
- this.featureRepo = featureRepo;
62
- this.routeRepo = routeRepo;
63
- this.featureAccessRepo = featureAccessRepo;
64
- this.moduleAccessRepo = moduleAccessRepo;
65
- this.screenPermissionRepo = screenPermissionRepo;
57
+ const { repositories } = options;
58
+ this.userRepo = repositories.userRepo;
59
+ this.roleRepo = repositories.roleRepo;
60
+ this.moduleRepo = repositories.moduleRepo;
61
+ this.featureRepo = repositories.featureRepo;
62
+ this.routeRepo = repositories.routeRepo;
63
+ this.featureAccessRepo = repositories.featureAccessRepo;
64
+ this.moduleAccessRepo = repositories.moduleAccessRepo;
65
+ this.screenPermissionRepo = repositories.screenPermissionRepo;
66
66
  }
67
67
  async validateUser(email, password) {
68
68
  const user = await this.userRepo.findOne({ where: { email } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecrs-auth-core",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "Centralized authentication and authorization module for ECRS apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",