@quanticjs/auth-web-bff 4.4.2 → 5.1.0
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/bff.controller.d.ts +3 -1
- package/dist/bff.controller.js +10 -6
- package/dist/bff.service.js +1 -1
- package/package.json +2 -2
package/dist/bff.controller.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Request, Response } from 'express';
|
|
2
2
|
import { BffService } from './bff.service';
|
|
3
|
+
import { type BffModuleOptions } from './interfaces';
|
|
3
4
|
export declare class BffController {
|
|
4
5
|
private readonly bffService;
|
|
5
|
-
|
|
6
|
+
private readonly callbackPath;
|
|
7
|
+
constructor(bffService: BffService, options: BffModuleOptions);
|
|
6
8
|
login(returnTo: string, res: Response): void;
|
|
7
9
|
callback(code: string, state: string, req: Request, res: Response): Promise<void>;
|
|
8
10
|
refresh(req: Request, res: Response): Promise<void>;
|
package/dist/bff.controller.js
CHANGED
|
@@ -17,18 +17,21 @@ const common_1 = require("@nestjs/common");
|
|
|
17
17
|
const swagger_1 = require("@nestjs/swagger");
|
|
18
18
|
const core_1 = require("@quanticjs/core");
|
|
19
19
|
const bff_service_1 = require("./bff.service");
|
|
20
|
+
const interfaces_1 = require("./interfaces");
|
|
20
21
|
const VERIFIER_COOKIE = 'pkce_verifier';
|
|
21
22
|
let BffController = class BffController {
|
|
22
23
|
bffService;
|
|
23
|
-
|
|
24
|
+
callbackPath;
|
|
25
|
+
constructor(bffService, options) {
|
|
24
26
|
this.bffService = bffService;
|
|
27
|
+
this.callbackPath = options.callbackPath ?? '/api/auth/callback';
|
|
25
28
|
}
|
|
26
29
|
login(returnTo, res) {
|
|
27
30
|
const { url, codeVerifier } = this.bffService.getAuthorizationUrl(returnTo);
|
|
28
31
|
res.cookie(VERIFIER_COOKIE, codeVerifier, {
|
|
29
32
|
httpOnly: true,
|
|
30
33
|
sameSite: 'lax',
|
|
31
|
-
path:
|
|
34
|
+
path: this.callbackPath,
|
|
32
35
|
maxAge: 5 * 60 * 1000,
|
|
33
36
|
});
|
|
34
37
|
res.redirect(url);
|
|
@@ -36,17 +39,17 @@ let BffController = class BffController {
|
|
|
36
39
|
async callback(code, state, req, res) {
|
|
37
40
|
const codeVerifier = req.cookies?.[VERIFIER_COOKIE];
|
|
38
41
|
if (!codeVerifier || !code) {
|
|
39
|
-
res.redirect('/auth/login');
|
|
42
|
+
res.redirect('/api/auth/login');
|
|
40
43
|
return;
|
|
41
44
|
}
|
|
42
|
-
res.clearCookie(VERIFIER_COOKIE, { path:
|
|
45
|
+
res.clearCookie(VERIFIER_COOKIE, { path: this.callbackPath });
|
|
43
46
|
try {
|
|
44
47
|
const { sessionId, returnTo } = await this.bffService.handleCallback(code, state, codeVerifier);
|
|
45
48
|
res.cookie(this.bffService.getCookieName(), sessionId, this.bffService.getCookieOptions());
|
|
46
49
|
res.redirect(returnTo);
|
|
47
50
|
}
|
|
48
51
|
catch {
|
|
49
|
-
res.redirect('/auth/login?error=callback_failed');
|
|
52
|
+
res.redirect('/api/auth/login?error=callback_failed');
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
async refresh(req, res) {
|
|
@@ -143,5 +146,6 @@ __decorate([
|
|
|
143
146
|
exports.BffController = BffController = __decorate([
|
|
144
147
|
(0, swagger_1.ApiTags)('auth'),
|
|
145
148
|
(0, common_1.Controller)('auth'),
|
|
146
|
-
|
|
149
|
+
__param(1, (0, common_1.Inject)(interfaces_1.BFF_OPTIONS)),
|
|
150
|
+
__metadata("design:paramtypes", [bff_service_1.BffService, Object])
|
|
147
151
|
], BffController);
|
package/dist/bff.service.js
CHANGED
|
@@ -185,7 +185,7 @@ let BffService = class BffService {
|
|
|
185
185
|
return url.replace(this.internalKeycloakBase, this.publicKeycloakBase);
|
|
186
186
|
}
|
|
187
187
|
getCallbackUrl() {
|
|
188
|
-
const callbackPath = this.options.callbackPath ?? '/auth/callback';
|
|
188
|
+
const callbackPath = this.options.callbackPath ?? '/api/auth/callback';
|
|
189
189
|
return `${this.options.publicUrl}${callbackPath}`;
|
|
190
190
|
}
|
|
191
191
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quanticjs/auth-web-bff",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "BFF authentication module — Keycloak OIDC, Redis sessions, httpOnly cookies",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"clean": "rm -rf dist"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@quanticjs/core": "^
|
|
12
|
+
"@quanticjs/core": "^5.1.0"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"@nestjs/common": "^10.0.0 || ^11.0.0",
|