ecrs-auth-core 1.0.34 → 1.0.36

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,5 +1,5 @@
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
5
  static registerAsync(options: {
@@ -19,7 +19,66 @@ 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
+ // @Global()
24
+ // @Module({})
25
+ // export class AuthCoreModule {
26
+ // static registerAsync(options: {
27
+ // inject: any[];
28
+ // useFactory: (...args: any[]) => Promise<AuthCoreOptions>;
29
+ // }): DynamicModule {
30
+ // const asyncProvider = {
31
+ // provide: AUTH_CORE_OPTIONS,
32
+ // inject: options.inject,
33
+ // useFactory: options.useFactory,
34
+ // };
35
+ // return {
36
+ // module: AuthCoreModule,
37
+ // imports: [
38
+ // JwtModule.registerAsync({
39
+ // inject: options.inject,
40
+ // useFactory: async (...args: any[]) => {
41
+ // const config = await options.useFactory(...args);
42
+ // console.log("🔐 JWT Secret from AUTH_CORE_OPTIONS:", config.jwtSecret);
43
+ // console.log("⏳ JWT Expiry:", config.jwtExpiresIn);
44
+ // return {
45
+ // secret: config.jwtSecret,
46
+ // signOptions: { expiresIn: config.jwtExpiresIn },
47
+ // };
48
+ // },
49
+ // }),
50
+ // ],
51
+ // providers: [
52
+ // asyncProvider,
53
+ // {
54
+ // provide: 'MODULE_CONFIG',
55
+ // useFactory: (options: AuthCoreOptions) => options.moduleConfig || {},
56
+ // inject: [AUTH_CORE_OPTIONS],
57
+ // },
58
+ // AuthService,
59
+ // JwtStrategy,
60
+ // JwtAuthGuard,
61
+ // ModuleGuard,
62
+ // RolesGuard,
63
+ // FeatureGuard,
64
+ // RouteGuard,
65
+ // PermissionGuard,
66
+ // ],
67
+ // controllers: [AuthController],
68
+ // exports: [
69
+ // AuthService,
70
+ // JwtStrategy,
71
+ // JwtAuthGuard,
72
+ // ModuleGuard,
73
+ // RolesGuard,
74
+ // FeatureGuard,
75
+ // RouteGuard,
76
+ // PermissionGuard,
77
+ // JwtModule,
78
+ // ],
79
+ // };
80
+ // }
81
+ // }
23
82
  let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
24
83
  static registerAsync(options) {
25
84
  const asyncProvider = {
@@ -29,29 +88,25 @@ let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
29
88
  };
30
89
  return {
31
90
  module: AuthCoreModule_1,
32
- imports: [jwt_1.JwtModule.register({})],
33
- providers: [
34
- asyncProvider,
35
- {
36
- provide: "ASYNC_JWT_OPTIONS",
37
- useFactory: async (options) => {
38
- console.log("🔐 JWT Secret from AUTH_CORE_OPTIONS:", options.jwtSecret);
39
- console.log("⏳ JWT Expiry:", options.jwtExpiresIn);
91
+ imports: [
92
+ jwt_1.JwtModule.registerAsync({
93
+ inject: options.inject,
94
+ useFactory: async (...args) => {
95
+ const config = await options.useFactory(...args);
96
+ console.log('🔐 JWT Secret from AUTH_CORE_OPTIONS:', config.jwtSecret);
97
+ console.log('⏳ JWT Expiry:', config.jwtExpiresIn);
40
98
  return {
41
- secret: options.jwtSecret,
42
- signOptions: { expiresIn: options.jwtExpiresIn },
99
+ secret: config.jwtSecret,
100
+ signOptions: { expiresIn: config.jwtExpiresIn },
43
101
  };
44
102
  },
45
- inject: [exports.AUTH_CORE_OPTIONS],
46
- },
47
- {
48
- provide: jwt_1.JwtModule,
49
- useFactory: async (jwtOptions) => jwt_1.JwtModule.register(jwtOptions),
50
- inject: ["ASYNC_JWT_OPTIONS"],
51
- },
103
+ }),
104
+ ],
105
+ providers: [
106
+ asyncProvider,
52
107
  {
53
- provide: "MODULE_CONFIG",
54
- useFactory: (options) => options.moduleConfig || {},
108
+ provide: 'MODULE_CONFIG',
109
+ useFactory: (opts) => opts.moduleConfig || {},
55
110
  inject: [exports.AUTH_CORE_OPTIONS],
56
111
  },
57
112
  auth_service_1.AuthService,
@@ -65,6 +120,11 @@ let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
65
120
  ],
66
121
  controllers: [auth_controller_1.AuthController],
67
122
  exports: [
123
+ // ⬇️ export these so Superadmin can resolve guard deps
124
+ exports.AUTH_CORE_OPTIONS,
125
+ 'MODULE_CONFIG',
126
+ // optional but handy:
127
+ jwt_1.JwtModule,
68
128
  auth_service_1.AuthService,
69
129
  jwt_strategy_1.JwtStrategy,
70
130
  jwt_guard_1.JwtAuthGuard,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecrs-auth-core",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
4
4
  "description": "Centralized authentication and authorization module for ECRS apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",