@breadstone/archipel-platform-authentication 0.0.35 → 0.0.37

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@breadstone/archipel-platform-authentication",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "description": "JWT and OAuth authentication, MFA, session management, and email verification for NestJS applications.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -89,10 +89,10 @@
89
89
  "README.md"
90
90
  ],
91
91
  "dependencies": {
92
- "@breadstone/archipel-platform-configuration": "0.0.35",
93
- "@breadstone/archipel-platform-core": "0.0.35",
94
- "@breadstone/archipel-platform-cryptography": "0.0.35",
95
- "@breadstone/archipel-platform-mapping": "0.0.35",
92
+ "@breadstone/archipel-platform-configuration": "0.0.37",
93
+ "@breadstone/archipel-platform-core": "0.0.37",
94
+ "@breadstone/archipel-platform-cryptography": "0.0.37",
95
+ "@breadstone/archipel-platform-mapping": "0.0.37",
96
96
  "tslib": "2.8.1"
97
97
  },
98
98
  "peerDependencies": {
@@ -72,6 +72,32 @@ export interface IAuthModuleOptions {
72
72
  * For multi-instance deployments, provide a Redis-backed implementation.
73
73
  */
74
74
  challengeStore?: Type<ChallengeStorePort>;
75
+ /**
76
+ * Optional middleware configuration.
77
+ * Controls registration of `LastActiveMiddleware` and `LimitRequestSizeMiddleware`.
78
+ * Both are enabled by default when omitted.
79
+ */
80
+ middleware?: IAuthMiddlewareOptions;
81
+ }
82
+ /**
83
+ * Configuration for the auth module's middleware registration.
84
+ *
85
+ * @public
86
+ */
87
+ export interface IAuthMiddlewareOptions {
88
+ /**
89
+ * Configuration for the last-active tracking middleware.
90
+ * - `true` or `undefined`: enabled for all routes (default)
91
+ * - `false`: disabled entirely
92
+ */
93
+ lastActive?: boolean;
94
+ /**
95
+ * Configuration for the request size limit middleware on the register endpoint.
96
+ * - `undefined`: enabled with default path `'auth/register'`
97
+ * - `false`: disabled entirely
98
+ * - `string`: custom path for the register endpoint (relative, without global prefix)
99
+ */
100
+ requestSizeLimit?: false | string;
75
101
  }
76
102
  /**
77
103
  * The `AuthModule` handles JWT-based authentication,
@@ -89,6 +115,7 @@ export interface IAuthModuleOptions {
89
115
  * @public
90
116
  */
91
117
  export declare class AuthModule {
118
+ private static _options;
92
119
  /**
93
120
  * Registers the auth module with the provided port implementations.
94
121
  *
package/src/AuthModule.js CHANGED
@@ -57,6 +57,7 @@ const VerificationService_1 = require("./services/VerificationService");
57
57
  * @public
58
58
  */
59
59
  let AuthModule = AuthModule_1 = class AuthModule {
60
+ // #endregion
60
61
  // #region Methods
61
62
  /**
62
63
  * Registers the auth module with the provided port implementations.
@@ -66,6 +67,7 @@ let AuthModule = AuthModule_1 = class AuthModule {
66
67
  * @returns The configured dynamic module.
67
68
  */
68
69
  static register(options) {
70
+ AuthModule_1._options = options;
69
71
  const portProviders = [
70
72
  { provide: AuthSubjectPort_1.AuthSubjectPort, useClass: options.authSubject },
71
73
  { provide: MfaSubjectPort_1.MfaSubjectPort, useClass: options.mfaSubject },
@@ -164,14 +166,20 @@ let AuthModule = AuthModule_1 = class AuthModule {
164
166
  };
165
167
  }
166
168
  configure(consumer) {
167
- consumer.apply(archipel_platform_core_1.LimitRequestSizeMiddleware).forRoutes({
168
- path: 'api/auth/register',
169
- method: common_1.RequestMethod.POST,
170
- });
171
- consumer.apply(middlewares_1.LastActiveMiddleware).forRoutes({
172
- path: '*',
173
- method: common_1.RequestMethod.ALL,
174
- });
169
+ const middleware = AuthModule_1._options?.middleware;
170
+ if (middleware?.requestSizeLimit !== false) {
171
+ const registerPath = typeof middleware?.requestSizeLimit === 'string' ? middleware.requestSizeLimit : 'auth/register';
172
+ consumer.apply(archipel_platform_core_1.LimitRequestSizeMiddleware).forRoutes({
173
+ path: registerPath,
174
+ method: common_1.RequestMethod.POST,
175
+ });
176
+ }
177
+ if (middleware?.lastActive !== false) {
178
+ consumer.apply(middlewares_1.LastActiveMiddleware).forRoutes({
179
+ path: '/{*path}',
180
+ method: common_1.RequestMethod.ALL,
181
+ });
182
+ }
175
183
  }
176
184
  };
177
185
  exports.AuthModule = AuthModule;