ecrs-auth-core 1.0.33 → 1.0.35
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.module.d.ts +2 -2
- package/dist/auth.module.js +81 -15
- package/package.json +1 -1
package/dist/auth.module.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DynamicModule } from
|
|
2
|
-
import { AuthCoreOptions } from
|
|
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: {
|
package/dist/auth.module.js
CHANGED
|
@@ -19,7 +19,72 @@ 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 =
|
|
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: [JwtModule.register({})],
|
|
38
|
+
// providers: [
|
|
39
|
+
// asyncProvider,
|
|
40
|
+
// {
|
|
41
|
+
// provide: "ASYNC_JWT_OPTIONS",
|
|
42
|
+
// useFactory: async (options: AuthCoreOptions) => {
|
|
43
|
+
// console.log(
|
|
44
|
+
// "🔐 JWT Secret from AUTH_CORE_OPTIONS:",
|
|
45
|
+
// options.jwtSecret
|
|
46
|
+
// );
|
|
47
|
+
// console.log("⏳ JWT Expiry:", options.jwtExpiresIn);
|
|
48
|
+
// return {
|
|
49
|
+
// secret: options.jwtSecret,
|
|
50
|
+
// signOptions: { expiresIn: options.jwtExpiresIn },
|
|
51
|
+
// };
|
|
52
|
+
// },
|
|
53
|
+
// inject: [AUTH_CORE_OPTIONS],
|
|
54
|
+
// },
|
|
55
|
+
// {
|
|
56
|
+
// provide: JwtModule,
|
|
57
|
+
// useFactory: async (jwtOptions: any) => JwtModule.register(jwtOptions),
|
|
58
|
+
// inject: ["ASYNC_JWT_OPTIONS"],
|
|
59
|
+
// },
|
|
60
|
+
// {
|
|
61
|
+
// provide: "MODULE_CONFIG",
|
|
62
|
+
// useFactory: (options: AuthCoreOptions) => options.moduleConfig || {},
|
|
63
|
+
// inject: [AUTH_CORE_OPTIONS],
|
|
64
|
+
// },
|
|
65
|
+
// AuthService,
|
|
66
|
+
// JwtStrategy,
|
|
67
|
+
// JwtAuthGuard,
|
|
68
|
+
// ModuleGuard,
|
|
69
|
+
// RolesGuard,
|
|
70
|
+
// FeatureGuard,
|
|
71
|
+
// RouteGuard,
|
|
72
|
+
// PermissionGuard,
|
|
73
|
+
// ],
|
|
74
|
+
// controllers: [AuthController],
|
|
75
|
+
// exports: [
|
|
76
|
+
// AuthService,
|
|
77
|
+
// JwtStrategy,
|
|
78
|
+
// JwtAuthGuard,
|
|
79
|
+
// ModuleGuard,
|
|
80
|
+
// RolesGuard,
|
|
81
|
+
// FeatureGuard,
|
|
82
|
+
// RouteGuard,
|
|
83
|
+
// PermissionGuard,
|
|
84
|
+
// ],
|
|
85
|
+
// };
|
|
86
|
+
// }
|
|
87
|
+
// }
|
|
23
88
|
let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
|
|
24
89
|
static registerAsync(options) {
|
|
25
90
|
const asyncProvider = {
|
|
@@ -29,22 +94,22 @@ let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
|
|
|
29
94
|
};
|
|
30
95
|
return {
|
|
31
96
|
module: AuthCoreModule_1,
|
|
32
|
-
imports: [
|
|
97
|
+
imports: [
|
|
98
|
+
jwt_1.JwtModule.registerAsync({
|
|
99
|
+
inject: options.inject,
|
|
100
|
+
useFactory: async (...args) => {
|
|
101
|
+
const config = await options.useFactory(...args);
|
|
102
|
+
console.log("🔐 JWT Secret from AUTH_CORE_OPTIONS:", config.jwtSecret);
|
|
103
|
+
console.log("⏳ JWT Expiry:", config.jwtExpiresIn);
|
|
104
|
+
return {
|
|
105
|
+
secret: config.jwtSecret,
|
|
106
|
+
signOptions: { expiresIn: config.jwtExpiresIn },
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
}),
|
|
110
|
+
],
|
|
33
111
|
providers: [
|
|
34
112
|
asyncProvider,
|
|
35
|
-
{
|
|
36
|
-
provide: 'ASYNC_JWT_OPTIONS',
|
|
37
|
-
useFactory: async (options) => ({
|
|
38
|
-
secret: options.jwtSecret,
|
|
39
|
-
signOptions: { expiresIn: options.jwtExpiresIn },
|
|
40
|
-
}),
|
|
41
|
-
inject: [exports.AUTH_CORE_OPTIONS],
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
provide: jwt_1.JwtModule,
|
|
45
|
-
useFactory: async (jwtOptions) => jwt_1.JwtModule.register(jwtOptions),
|
|
46
|
-
inject: ['ASYNC_JWT_OPTIONS'],
|
|
47
|
-
},
|
|
48
113
|
{
|
|
49
114
|
provide: 'MODULE_CONFIG',
|
|
50
115
|
useFactory: (options) => options.moduleConfig || {},
|
|
@@ -69,6 +134,7 @@ let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
|
|
|
69
134
|
feature_guard_1.FeatureGuard,
|
|
70
135
|
route_guard_1.RouteGuard,
|
|
71
136
|
permission_guard_1.PermissionGuard,
|
|
137
|
+
jwt_1.JwtModule, // ✅ Re-export so JwtService works in consuming modules
|
|
72
138
|
],
|
|
73
139
|
};
|
|
74
140
|
}
|