ecrs-auth-core 1.0.20 → 1.0.22

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,55 +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
- return {
26
- module: AuthCoreModule_1,
27
- imports: [
28
- jwt_1.JwtModule.registerAsync({
29
- useFactory: (options) => ({
30
- secret: options.jwtSecret,
31
- signOptions: { expiresIn: options.jwtExpiresIn },
32
- }),
33
- inject: [exports.AUTH_CORE_OPTIONS],
34
- }),
35
- ],
36
- controllers: [auth_controller_1.AuthController],
37
- providers: [
38
- {
39
- provide: exports.AUTH_CORE_OPTIONS,
40
- useValue: options,
41
- },
42
- auth_service_1.AuthService,
43
- jwt_strategy_1.JwtStrategy,
44
- jwt_guard_1.JwtAuthGuard,
45
- module_guard_1.ModuleGuard,
46
- roles_guard_1.RolesGuard,
47
- feature_guard_1.FeatureGuard,
48
- route_guard_1.RouteGuard,
49
- permission_guard_1.PermissionGuard,
50
- ],
51
- exports: [
52
- auth_service_1.AuthService,
53
- jwt_strategy_1.JwtStrategy,
54
- jwt_guard_1.JwtAuthGuard,
55
- module_guard_1.ModuleGuard,
56
- roles_guard_1.RolesGuard,
57
- feature_guard_1.FeatureGuard,
58
- route_guard_1.RouteGuard,
59
- permission_guard_1.PermissionGuard,
60
- ],
61
- };
62
- }
63
24
  static registerAsync(options) {
64
25
  const asyncProvider = {
65
26
  provide: exports.AUTH_CORE_OPTIONS,
@@ -68,18 +29,22 @@ let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
68
29
  };
69
30
  return {
70
31
  module: AuthCoreModule_1,
71
- imports: [
72
- jwt_1.JwtModule.registerAsync({
73
- useFactory: (options) => ({
32
+ imports: [jwt_1.JwtModule.register({})],
33
+ providers: [
34
+ asyncProvider,
35
+ {
36
+ provide: 'ASYNC_JWT_OPTIONS',
37
+ useFactory: async (options) => ({
74
38
  secret: options.jwtSecret,
75
39
  signOptions: { expiresIn: options.jwtExpiresIn },
76
40
  }),
77
41
  inject: [exports.AUTH_CORE_OPTIONS],
78
- }),
79
- ],
80
- controllers: [auth_controller_1.AuthController],
81
- providers: [
82
- asyncProvider,
42
+ },
43
+ {
44
+ provide: jwt_1.JwtModule,
45
+ useFactory: async (jwtOptions) => jwt_1.JwtModule.register(jwtOptions),
46
+ inject: ['ASYNC_JWT_OPTIONS'],
47
+ },
83
48
  auth_service_1.AuthService,
84
49
  jwt_strategy_1.JwtStrategy,
85
50
  jwt_guard_1.JwtAuthGuard,
@@ -89,6 +54,7 @@ let AuthCoreModule = AuthCoreModule_1 = class AuthCoreModule {
89
54
  route_guard_1.RouteGuard,
90
55
  permission_guard_1.PermissionGuard,
91
56
  ],
57
+ controllers: [auth_controller_1.AuthController],
92
58
  exports: [
93
59
  auth_service_1.AuthService,
94
60
  jwt_strategy_1.JwtStrategy,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecrs-auth-core",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "Centralized authentication and authorization module for ECRS apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",