ecrs-auth-core 1.0.21 → 1.0.23

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.
@@ -1,10 +1,9 @@
1
- import { DynamicModule } from "@nestjs/common";
2
- import { AuthCoreOptions } from "./interfaces/auth-core-options.interface";
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { AuthCoreOptions } from './interfaces/auth-core-options.interface';
3
3
  export declare const AUTH_CORE_OPTIONS = "AUTH_CORE_OPTIONS";
4
4
  export declare class AuthCoreModule {
5
- static register(options: AuthCoreOptions): DynamicModule;
6
5
  static registerAsync(options: {
7
6
  inject: any[];
8
- useFactory: (...args: any[]) => AuthCoreOptions | Promise<AuthCoreOptions>;
7
+ useFactory: (...args: any[]) => Promise<AuthCoreOptions>;
9
8
  }): DynamicModule;
10
9
  }
@@ -11,53 +11,16 @@ exports.AuthCoreModule = exports.AUTH_CORE_OPTIONS = void 0;
11
11
  const common_1 = require("@nestjs/common");
12
12
  const jwt_1 = require("@nestjs/jwt");
13
13
  const auth_service_1 = require("./auth.service");
14
+ const auth_controller_1 = require("./auth.controller");
14
15
  const jwt_strategy_1 = require("./jwt/jwt.strategy");
15
16
  const jwt_guard_1 = require("./jwt/jwt.guard");
16
- const auth_controller_1 = require("./auth.controller");
17
17
  const module_guard_1 = require("./guards/module.guard");
18
18
  const roles_guard_1 = require("./guards/roles.guard");
19
19
  const feature_guard_1 = require("./guards/feature.guard");
20
20
  const route_guard_1 = require("./guards/route.guard");
21
21
  const permission_guard_1 = require("./guards/permission.guard");
22
- exports.AUTH_CORE_OPTIONS = "AUTH_CORE_OPTIONS";
22
+ exports.AUTH_CORE_OPTIONS = 'AUTH_CORE_OPTIONS';
23
23
  let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
24
- static register(options) {
25
- const optionsProvider = {
26
- provide: exports.AUTH_CORE_OPTIONS,
27
- useValue: options,
28
- };
29
- return {
30
- module: AuthCoreModule_1,
31
- imports: [
32
- jwt_1.JwtModule.register({
33
- secret: options.jwtSecret,
34
- signOptions: { expiresIn: options.jwtExpiresIn },
35
- }),
36
- ],
37
- controllers: [auth_controller_1.AuthController],
38
- providers: [
39
- optionsProvider,
40
- auth_service_1.AuthService,
41
- jwt_strategy_1.JwtStrategy,
42
- jwt_guard_1.JwtAuthGuard,
43
- module_guard_1.ModuleGuard,
44
- roles_guard_1.RolesGuard,
45
- feature_guard_1.FeatureGuard,
46
- route_guard_1.RouteGuard,
47
- permission_guard_1.PermissionGuard,
48
- ],
49
- exports: [
50
- auth_service_1.AuthService,
51
- jwt_strategy_1.JwtStrategy,
52
- jwt_guard_1.JwtAuthGuard,
53
- module_guard_1.ModuleGuard,
54
- roles_guard_1.RolesGuard,
55
- feature_guard_1.FeatureGuard,
56
- route_guard_1.RouteGuard,
57
- permission_guard_1.PermissionGuard,
58
- ],
59
- };
60
- }
61
24
  static registerAsync(options) {
62
25
  const asyncProvider = {
63
26
  provide: exports.AUTH_CORE_OPTIONS,
@@ -66,18 +29,22 @@ let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
66
29
  };
67
30
  return {
68
31
  module: AuthCoreModule_1,
69
- imports: [
70
- jwt_1.JwtModule.registerAsync({
71
- useFactory: (authOptions) => ({
72
- secret: authOptions.jwtSecret,
73
- signOptions: { expiresIn: authOptions.jwtExpiresIn },
32
+ imports: [jwt_1.JwtModule.register({})],
33
+ providers: [
34
+ asyncProvider,
35
+ {
36
+ provide: 'ASYNC_JWT_OPTIONS',
37
+ useFactory: async (options) => ({
38
+ secret: options.jwtSecret,
39
+ signOptions: { expiresIn: options.jwtExpiresIn },
74
40
  }),
75
41
  inject: [exports.AUTH_CORE_OPTIONS],
76
- }),
77
- ],
78
- controllers: [auth_controller_1.AuthController],
79
- providers: [
80
- asyncProvider, // ✅ Register the option provider before JwtModule uses it
42
+ },
43
+ {
44
+ provide: jwt_1.JwtModule,
45
+ useFactory: async (jwtOptions) => jwt_1.JwtModule.register(jwtOptions),
46
+ inject: ['ASYNC_JWT_OPTIONS'],
47
+ },
81
48
  auth_service_1.AuthService,
82
49
  jwt_strategy_1.JwtStrategy,
83
50
  jwt_guard_1.JwtAuthGuard,
@@ -87,6 +54,7 @@ let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
87
54
  route_guard_1.RouteGuard,
88
55
  permission_guard_1.PermissionGuard,
89
56
  ],
57
+ controllers: [auth_controller_1.AuthController],
90
58
  exports: [
91
59
  auth_service_1.AuthService,
92
60
  jwt_strategy_1.JwtStrategy,
@@ -49,7 +49,7 @@ exports.AuthService = void 0;
49
49
  const common_1 = require("@nestjs/common");
50
50
  const jwt_1 = require("@nestjs/jwt");
51
51
  const bcrypt = __importStar(require("bcrypt"));
52
- const auth_module_1 = require("./auth.module");
52
+ const constants_1 = require("./constants/constants");
53
53
  let AuthService = class AuthService {
54
54
  constructor(jwtService, options) {
55
55
  this.jwtService = jwtService;
@@ -153,6 +153,6 @@ let AuthService = class AuthService {
153
153
  exports.AuthService = AuthService;
154
154
  exports.AuthService = AuthService = __decorate([
155
155
  (0, common_1.Injectable)(),
156
- __param(1, (0, common_1.Inject)(auth_module_1.AUTH_CORE_OPTIONS)),
156
+ __param(1, (0, common_1.Inject)(constants_1.AUTH_CORE_OPTIONS)),
157
157
  __metadata("design:paramtypes", [jwt_1.JwtService, Object])
158
158
  ], AuthService);
@@ -0,0 +1 @@
1
+ export declare const AUTH_CORE_OPTIONS = "AUTH_CORE_OPTIONS";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AUTH_CORE_OPTIONS = void 0;
4
+ exports.AUTH_CORE_OPTIONS = 'AUTH_CORE_OPTIONS';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecrs-auth-core",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "Centralized authentication and authorization module for ECRS apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",