@auth0/auth0-express 1.0.0-beta.5 → 1.0.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/README.md +15 -5
- package/dist/errors.d.ts +25 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +29 -0
- package/dist/errors.js.map +1 -0
- package/dist/handlers/backchannel-logout-handler.js +2 -2
- package/dist/handlers/backchannel-logout-handler.js.map +1 -1
- package/dist/handlers/callback-handler.d.ts +2 -2
- package/dist/handlers/callback-handler.d.ts.map +1 -1
- package/dist/handlers/callback-handler.js +4 -8
- package/dist/handlers/callback-handler.js.map +1 -1
- package/dist/handlers/login-handler.d.ts +2 -2
- package/dist/handlers/login-handler.d.ts.map +1 -1
- package/dist/handlers/login-handler.js +3 -5
- package/dist/handlers/login-handler.js.map +1 -1
- package/dist/handlers/logout-handler.d.ts +2 -2
- package/dist/handlers/logout-handler.d.ts.map +1 -1
- package/dist/handlers/logout-handler.js +3 -5
- package/dist/handlers/logout-handler.js.map +1 -1
- package/dist/router.js +3 -3
- package/dist/router.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
The Auth0 Express SDK is a library for implementing user authentication in Express applications.
|
|
2
2
|
|
|
3
|
-
> :warning: Please be aware that auth0-express is currently in [**Beta**](https://auth0.com/docs/troubleshoot/product-lifecycle/product-release-stages). Whilst we encourage you to test the update within your applications, we do not recommend using this version in production yet.
|
|
4
|
-
> As with any beta release, we look forward to your questions and feedback to help us improve the library.
|
|
5
|
-
|
|
6
|
-

|
|
7
3
|

|
|
8
4
|

|
|
9
5
|
[](https://opensource.org/license/apache-2-0)
|
|
@@ -43,7 +39,7 @@ Jump straight to the capability you need.
|
|
|
43
39
|
### 1. Install the SDK
|
|
44
40
|
|
|
45
41
|
```shell
|
|
46
|
-
npm i @auth0/auth0-express
|
|
42
|
+
npm i @auth0/auth0-express
|
|
47
43
|
```
|
|
48
44
|
|
|
49
45
|
This library requires Node.js 22 LTS and newer LTS versions.
|
|
@@ -243,6 +239,20 @@ const accessTokenResult = await req.auth0.client.getAccessToken();
|
|
|
243
239
|
console.log(accessTokenResult.accessToken);
|
|
244
240
|
```
|
|
245
241
|
|
|
242
|
+
## Error Handling
|
|
243
|
+
|
|
244
|
+
The browser-facing auth routes (login, callback, and logout) forward failures to Express via `next(error)` rather than writing error detail to the response themselves. Before doing so, the SDK replaces the underlying error with a sanitized one that carries only a generic message and a fixed `500` status. This has two effects:
|
|
245
|
+
|
|
246
|
+
- No internal detail (an OAuth `error_description`, a token-endpoint failure reason, stack traces, file paths) reaches the client, regardless of `NODE_ENV`. The original error is preserved on `error.cause`, so your own logging can still inspect it.
|
|
247
|
+
- The failure status is a stable `500` instead of mirroring whatever status an upstream call happened to return (for example a `400` from the token endpoint).
|
|
248
|
+
|
|
249
|
+
Express still produces the final response. Its built-in error handler writes the (now generic) error stack into the response body unless `NODE_ENV` is set to `production`. For full control over what clients see, you can:
|
|
250
|
+
|
|
251
|
+
- Run your app with `NODE_ENV=production` in any deployed environment, and/or
|
|
252
|
+
- Mount your own [Express error-handling middleware](https://expressjs.com/en/guide/error-handling.html) after the Auth0 router. Read `error.cause` there if you want to log the original failure.
|
|
253
|
+
|
|
254
|
+
The back-channel logout route is different: it is called server-to-server by Auth0, not by a browser, so the SDK owns its response directly and always replies with the status codes required by the [OpenID Connect Back-Channel Logout](https://openid.net/specs/openid-connect-backchannel-1_0.html) spec (a success status, which the SDK returns as `204` and the spec also allows as `200`, or `400` on failure) without internal detail in the body. It does **not** flow through your error-handling middleware. If you need to log or customize back-channel logout failures, mount your own route and call `req.auth0.client.handleBackchannelLogout(logoutToken)` directly.
|
|
255
|
+
|
|
246
256
|
## Feedback
|
|
247
257
|
|
|
248
258
|
### Contributing
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes an error thrown by a browser-facing auth handler (login, callback,
|
|
3
|
+
* logout) into a sanitized error before it is handed to Express via `next()`.
|
|
4
|
+
*
|
|
5
|
+
* This solves two problems at once:
|
|
6
|
+
*
|
|
7
|
+
* 1. No internal detail leaks to the client. The browser-facing handlers
|
|
8
|
+
* delegate to Express's error pipeline, and Express's default handler
|
|
9
|
+
* (finalhandler) writes `err.stack` into the response body whenever the app
|
|
10
|
+
* is not running with `NODE_ENV=production`. By replacing the original error
|
|
11
|
+
* with one that carries only a generic message, that body can never contain
|
|
12
|
+
* an OAuth `error_description`, a token-endpoint failure reason, or any other
|
|
13
|
+
* internal detail, regardless of `NODE_ENV`. The original error is preserved
|
|
14
|
+
* on `cause` (which finalhandler never serializes into the body) so an
|
|
15
|
+
* application's own error-handling middleware can still log it server-side.
|
|
16
|
+
*
|
|
17
|
+
* 2. The client-facing status stays stable. finalhandler derives the HTTP
|
|
18
|
+
* status from `err.status`/`err.statusCode`. The underlying client attaches
|
|
19
|
+
* the upstream HTTP status to some failures, so a failed code exchange would
|
|
20
|
+
* otherwise surface to the browser as the token endpoint's `400` rather than
|
|
21
|
+
* a `500`. Pinning the status to `500` keeps the callback/login/logout
|
|
22
|
+
* failure contract independent of whatever status an upstream call returned.
|
|
23
|
+
*/
|
|
24
|
+
export declare function sanitizeHandlerError(cause: unknown): Error;
|
|
25
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAI1D"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes an error thrown by a browser-facing auth handler (login, callback,
|
|
3
|
+
* logout) into a sanitized error before it is handed to Express via `next()`.
|
|
4
|
+
*
|
|
5
|
+
* This solves two problems at once:
|
|
6
|
+
*
|
|
7
|
+
* 1. No internal detail leaks to the client. The browser-facing handlers
|
|
8
|
+
* delegate to Express's error pipeline, and Express's default handler
|
|
9
|
+
* (finalhandler) writes `err.stack` into the response body whenever the app
|
|
10
|
+
* is not running with `NODE_ENV=production`. By replacing the original error
|
|
11
|
+
* with one that carries only a generic message, that body can never contain
|
|
12
|
+
* an OAuth `error_description`, a token-endpoint failure reason, or any other
|
|
13
|
+
* internal detail, regardless of `NODE_ENV`. The original error is preserved
|
|
14
|
+
* on `cause` (which finalhandler never serializes into the body) so an
|
|
15
|
+
* application's own error-handling middleware can still log it server-side.
|
|
16
|
+
*
|
|
17
|
+
* 2. The client-facing status stays stable. finalhandler derives the HTTP
|
|
18
|
+
* status from `err.status`/`err.statusCode`. The underlying client attaches
|
|
19
|
+
* the upstream HTTP status to some failures, so a failed code exchange would
|
|
20
|
+
* otherwise surface to the browser as the token endpoint's `400` rather than
|
|
21
|
+
* a `500`. Pinning the status to `500` keeps the callback/login/logout
|
|
22
|
+
* failure contract independent of whatever status an upstream call returned.
|
|
23
|
+
*/
|
|
24
|
+
export function sanitizeHandlerError(cause) {
|
|
25
|
+
const error = new Error('Authentication request could not be completed.', { cause });
|
|
26
|
+
error.status = 500;
|
|
27
|
+
return error;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,gDAAgD,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACpF,KAAqC,CAAC,MAAM,GAAG,GAAG,CAAC;IACpD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -8,8 +8,8 @@ export async function handleBackchannelLogout(req, res) {
|
|
|
8
8
|
await req.auth0.client.handleBackchannelLogout(logoutToken);
|
|
9
9
|
res.status(204).send(null);
|
|
10
10
|
}
|
|
11
|
-
catch
|
|
12
|
-
res.status(400).send(
|
|
11
|
+
catch {
|
|
12
|
+
res.status(400).send();
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=backchannel-logout-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backchannel-logout-handler.js","sourceRoot":"","sources":["../../src/handlers/backchannel-logout-handler.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,GAAY,EAAE,GAAa;IACvE,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC;IAE1C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;QACpE,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;QAC5D,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,
|
|
1
|
+
{"version":3,"file":"backchannel-logout-handler.js","sourceRoot":"","sources":["../../src/handlers/backchannel-logout-handler.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,GAAY,EAAE,GAAa;IACvE,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC;IAE1C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;QACpE,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;QAC5D,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
2
|
import { Auth0Options } from '../types.js';
|
|
3
|
-
export declare function handleCallback(req: Request, res: Response, options: Auth0Options): Promise<void>;
|
|
3
|
+
export declare function handleCallback(req: Request, res: Response, options: Auth0Options, next: NextFunction): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=callback-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callback-handler.d.ts","sourceRoot":"","sources":["../../src/handlers/callback-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"callback-handler.d.ts","sourceRoot":"","sources":["../../src/handlers/callback-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,wBAAsB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA2B1H"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createRouteUrl } from '../utils.js';
|
|
2
2
|
import { resolveAppBaseUrl } from '../app-base-url.js';
|
|
3
|
-
|
|
3
|
+
import { sanitizeHandlerError } from '../errors.js';
|
|
4
|
+
export async function handleCallback(req, res, options, next) {
|
|
4
5
|
try {
|
|
5
6
|
const appBaseUrl = resolveAppBaseUrl(options.appBaseUrl, req);
|
|
6
7
|
if (options.enterpriseConnect) {
|
|
@@ -18,13 +19,8 @@ export async function handleCallback(req, res, options) {
|
|
|
18
19
|
const { appState } = await req.auth0.client.completeInteractiveLogin(createRouteUrl(req.url, appBaseUrl));
|
|
19
20
|
res.redirect(appState?.returnTo ?? appBaseUrl);
|
|
20
21
|
}
|
|
21
|
-
catch (
|
|
22
|
-
|
|
23
|
-
const error = e;
|
|
24
|
-
res.status(500).json({
|
|
25
|
-
error: error.cause?.error || error.name,
|
|
26
|
-
message: error.cause?.error_description || error.message,
|
|
27
|
-
});
|
|
22
|
+
catch (error) {
|
|
23
|
+
next(sanitizeHandlerError(error));
|
|
28
24
|
}
|
|
29
25
|
}
|
|
30
26
|
//# sourceMappingURL=callback-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callback-handler.js","sourceRoot":"","sources":["../../src/handlers/callback-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"callback-handler.js","sourceRoot":"","sources":["../../src/handlers/callback-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGpD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAY,EAAE,GAAa,EAAE,OAAqB,EAAE,IAAkB;IACzG,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAE9D,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAC9B,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,wBAAwB,CAC5D,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CACpC,CAAC;YACF,MAAM,OAAO,CAAC,UAAW,CAAC,GAAG,EAAE,GAAG,EAAE;gBAClC,aAAa,EAAE,MAAM,CAAC,aAAa;gBACnC,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;aAC1B,CAAC,CAAC;YACH,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;gBACrB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,OAAO,EAAE,iDAAiD,EAAE,CAAC,CAAC;YACvH,CAAC;YACD,OAAO;QACT,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,wBAAwB,CAClE,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CACpC,CAAC;QAEF,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,IAAI,UAAU,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IACpC,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
2
|
import { Auth0Options } from '../index.js';
|
|
3
|
-
export declare function handleLogin(req: Request, res: Response, options: Auth0Options): Promise<void>;
|
|
3
|
+
export declare function handleLogin(req: Request, res: Response, options: Auth0Options, next: NextFunction): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=login-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-handler.d.ts","sourceRoot":"","sources":["../../src/handlers/login-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"login-handler.d.ts","sourceRoot":"","sources":["../../src/handlers/login-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA+D3C,wBAAsB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBvH"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createRouteUrl, toSafeRedirect } from '../utils.js';
|
|
2
2
|
import { resolveAppBaseUrl } from '../app-base-url.js';
|
|
3
|
+
import { sanitizeHandlerError } from '../errors.js';
|
|
3
4
|
// Block both Object.prototype own-property names and commonly abused
|
|
4
5
|
// prototype-pollution keys that are not own-properties of Object.prototype.
|
|
5
6
|
const DENIED_KEYS = new Set([
|
|
@@ -55,7 +56,7 @@ function filterAuthorizationParams(params, disallowed) {
|
|
|
55
56
|
}
|
|
56
57
|
return Object.keys(filtered).length > 0 ? filtered : undefined;
|
|
57
58
|
}
|
|
58
|
-
export async function handleLogin(req, res, options) {
|
|
59
|
+
export async function handleLogin(req, res, options, next) {
|
|
59
60
|
try {
|
|
60
61
|
const appBaseUrl = resolveAppBaseUrl(options.appBaseUrl, req);
|
|
61
62
|
const callbackPath = options.routes?.callback ?? '/auth/callback';
|
|
@@ -74,10 +75,7 @@ export async function handleLogin(req, res, options) {
|
|
|
74
75
|
res.redirect(authorizationUrl.href);
|
|
75
76
|
}
|
|
76
77
|
catch (error) {
|
|
77
|
-
|
|
78
|
-
error: error.name,
|
|
79
|
-
message: error.message,
|
|
80
|
-
});
|
|
78
|
+
next(sanitizeHandlerError(error));
|
|
81
79
|
}
|
|
82
80
|
}
|
|
83
81
|
//# sourceMappingURL=login-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-handler.js","sourceRoot":"","sources":["../../src/handlers/login-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"login-handler.js","sourceRoot":"","sources":["../../src/handlers/login-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGpD,qEAAqE;AACrE,4EAA4E;AAC5E,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,SAAS,CAAC;IAC/C,WAAW;IACX,aAAa;IACb,WAAW;CACZ,CAAC,CAAC;AAEH,gFAAgF;AAChF,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IACpC,eAAe;IACf,OAAO;IACP,gBAAgB;IAChB,uBAAuB;IACvB,WAAW;IACX,cAAc;IACd,OAAO;IACP,OAAO;IACP,uFAAuF;IACvF,8FAA8F;IAC9F,6FAA6F;IAC7F,4FAA4F;IAC5F,UAAU;IACV,KAAK;IACL,UAAU;IACV,WAAW;IACX,oBAAoB;IACpB,wEAAwE;IACxE,wDAAwD;IACxD,kEAAkE;IAClE,SAAS;IACT,aAAa;IACb,eAAe;IACf,QAAQ;IACR,eAAe;IACf,uFAAuF;IACvF,0FAA0F;IAC1F,uBAAuB;CACxB,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,SAAS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,QAAQ,EAAE,EAAE,QAAQ,EAAE,iBAAiB,EAAE;YACzC,mBAAmB,EAAE;gBACnB,GAAG,yBAAyB,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC,CAAC;gBACjD,YAAY,EAAE,WAAW,CAAC,QAAQ,EAAE;aACrC;SACF,CAAC,CAAC;QAEH,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IACpC,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
2
|
import { Auth0Options } from '../types.js';
|
|
3
|
-
export declare function handleLogout(req: Request, res: Response, options: Auth0Options): Promise<void>;
|
|
3
|
+
export declare function handleLogout(req: Request, res: Response, options: Auth0Options, next: NextFunction): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=logout-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout-handler.d.ts","sourceRoot":"","sources":["../../src/handlers/logout-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"logout-handler.d.ts","sourceRoot":"","sources":["../../src/handlers/logout-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,wBAAsB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBxH"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveAppBaseUrl } from '../app-base-url.js';
|
|
2
|
-
|
|
2
|
+
import { sanitizeHandlerError } from '../errors.js';
|
|
3
|
+
export async function handleLogout(req, res, options, next) {
|
|
3
4
|
try {
|
|
4
5
|
const returnTo = resolveAppBaseUrl(options.appBaseUrl, req);
|
|
5
6
|
// In Enterprise Connect mode the mounted route always forces a federated
|
|
@@ -13,10 +14,7 @@ export async function handleLogout(req, res, options) {
|
|
|
13
14
|
res.redirect(logoutUrl.href);
|
|
14
15
|
}
|
|
15
16
|
catch (error) {
|
|
16
|
-
|
|
17
|
-
error: error.name,
|
|
18
|
-
message: error.message,
|
|
19
|
-
});
|
|
17
|
+
next(sanitizeHandlerError(error));
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
20
|
//# sourceMappingURL=logout-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout-handler.js","sourceRoot":"","sources":["../../src/handlers/logout-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"logout-handler.js","sourceRoot":"","sources":["../../src/handlers/logout-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGpD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAY,EAAE,GAAa,EAAE,OAAqB,EAAE,IAAkB;IACvG,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAC5D,yEAAyE;QACzE,wEAAwE;QACxE,yEAAyE;QACzE,wEAAwE;QACxE,MAAM,SAAS,GACb,OAAO,CAAC,iBAAiB,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,MAAM;YACzD,CAAC,CAAC,EAAE,SAAS,EAAE,IAAa,EAAE;YAC9B,CAAC,CAAC,EAAE,CAAC;QAET,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,CAAC,CAAC;QAE5E,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IACpC,CAAC;AACH,CAAC"}
|
package/dist/router.js
CHANGED
|
@@ -66,9 +66,9 @@ export function createAuth0(opts = {}) {
|
|
|
66
66
|
logout: options.routes?.logout ?? '/auth/logout',
|
|
67
67
|
backchannelLogout: options.routes?.backchannelLogout ?? '/auth/backchannel-logout',
|
|
68
68
|
};
|
|
69
|
-
router.get(routes.login, (req, res) => handleLogin(req, res, options));
|
|
70
|
-
router.get(routes.callback, (req, res) => handleCallback(req, res, options));
|
|
71
|
-
router.get(routes.logout, (req, res) => handleLogout(req, res, options));
|
|
69
|
+
router.get(routes.login, (req, res, next) => handleLogin(req, res, options, next));
|
|
70
|
+
router.get(routes.callback, (req, res, next) => handleCallback(req, res, options, next));
|
|
71
|
+
router.get(routes.logout, (req, res, next) => handleLogout(req, res, options, next));
|
|
72
72
|
router.post(routes.backchannelLogout, (req, res) => handleBackchannelLogout(req, res));
|
|
73
73
|
}
|
|
74
74
|
return router;
|
package/dist/router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmC,MAAM,SAAS,CAAC;AAClE,OAAO,YAAY,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAA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