@breadstone/archipel-platform-authentication 0.0.36 → 0.0.38
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 +6 -6
- package/src/AuthModule.d.ts +27 -0
- package/src/AuthModule.js +16 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@breadstone/archipel-platform-authentication",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.38",
|
|
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.
|
|
93
|
-
"@breadstone/archipel-platform-core": "0.0.
|
|
94
|
-
"@breadstone/archipel-platform-cryptography": "0.0.
|
|
95
|
-
"@breadstone/archipel-platform-mapping": "0.0.
|
|
92
|
+
"@breadstone/archipel-platform-configuration": "0.0.38",
|
|
93
|
+
"@breadstone/archipel-platform-core": "0.0.38",
|
|
94
|
+
"@breadstone/archipel-platform-cryptography": "0.0.38",
|
|
95
|
+
"@breadstone/archipel-platform-mapping": "0.0.38",
|
|
96
96
|
"tslib": "2.8.1"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
"@nestjs/core": "11.1.19",
|
|
145
145
|
"@nestjs/jwt": "11.0.2",
|
|
146
146
|
"@nestjs/passport": "11.0.5",
|
|
147
|
-
"@nestjs/swagger": "11.4.
|
|
147
|
+
"@nestjs/swagger": "11.4.2",
|
|
148
148
|
"@types/passport-apple": "2.0.3",
|
|
149
149
|
"@types/passport-github2": "1.2.9",
|
|
150
150
|
"@types/passport-google-oauth20": "2.0.17",
|
package/src/AuthModule.d.ts
CHANGED
|
@@ -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
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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;
|