@auth0/auth0-express 1.0.0-beta.1 → 1.0.0-beta.2

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.
Files changed (81) hide show
  1. package/README.md +25 -2
  2. package/dist/app-base-url.d.ts +31 -0
  3. package/dist/app-base-url.d.ts.map +1 -0
  4. package/dist/app-base-url.js +102 -0
  5. package/dist/app-base-url.js.map +1 -0
  6. package/dist/config.d.ts +15 -0
  7. package/dist/config.d.ts.map +1 -0
  8. package/dist/config.js +102 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/errors/index.d.ts +6 -0
  11. package/dist/errors/index.d.ts.map +1 -0
  12. package/dist/errors/index.js +9 -0
  13. package/dist/errors/index.js.map +1 -0
  14. package/dist/handlers/backchannel-logout-handler.d.ts +3 -0
  15. package/dist/handlers/backchannel-logout-handler.d.ts.map +1 -0
  16. package/dist/handlers/backchannel-logout-handler.js +15 -0
  17. package/dist/handlers/backchannel-logout-handler.js.map +1 -0
  18. package/dist/handlers/callback-handler.d.ts +4 -0
  19. package/dist/handlers/callback-handler.d.ts.map +1 -0
  20. package/dist/handlers/callback-handler.js +18 -0
  21. package/dist/handlers/callback-handler.js.map +1 -0
  22. package/dist/handlers/login-handler.d.ts +4 -0
  23. package/dist/handlers/login-handler.d.ts.map +1 -0
  24. package/dist/handlers/login-handler.js +64 -0
  25. package/dist/handlers/login-handler.js.map +1 -0
  26. package/dist/handlers/logout-handler.d.ts +4 -0
  27. package/dist/handlers/logout-handler.d.ts.map +1 -0
  28. package/dist/handlers/logout-handler.js +15 -0
  29. package/dist/handlers/logout-handler.js.map +1 -0
  30. package/dist/index.d.ts +11 -343
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +8 -521
  33. package/dist/index.js.map +1 -1
  34. package/dist/middleware/claim-auth.d.ts +28 -0
  35. package/dist/middleware/claim-auth.d.ts.map +1 -0
  36. package/dist/middleware/claim-auth.js +2 -0
  37. package/dist/middleware/claim-auth.js.map +1 -0
  38. package/dist/middleware/claim-check.d.ts +41 -0
  39. package/dist/middleware/claim-check.d.ts.map +1 -0
  40. package/dist/middleware/claim-check.js +62 -0
  41. package/dist/middleware/claim-check.js.map +1 -0
  42. package/dist/middleware/claim-equals.d.ts +27 -0
  43. package/dist/middleware/claim-equals.d.ts.map +1 -0
  44. package/dist/middleware/claim-equals.js +48 -0
  45. package/dist/middleware/claim-equals.js.map +1 -0
  46. package/dist/middleware/claim-includes.d.ts +37 -0
  47. package/dist/middleware/claim-includes.d.ts.map +1 -0
  48. package/dist/middleware/claim-includes.js +68 -0
  49. package/dist/middleware/claim-includes.js.map +1 -0
  50. package/dist/middleware/require-auth.d.ts +44 -0
  51. package/dist/middleware/require-auth.d.ts.map +1 -0
  52. package/dist/middleware/require-auth.js +57 -0
  53. package/dist/middleware/require-auth.js.map +1 -0
  54. package/dist/router.d.ts +34 -0
  55. package/dist/router.d.ts.map +1 -0
  56. package/dist/router.js +76 -0
  57. package/dist/router.js.map +1 -0
  58. package/dist/store/express-cookie-handler.d.ts +17 -0
  59. package/dist/store/express-cookie-handler.d.ts.map +1 -0
  60. package/dist/store/express-cookie-handler.js +30 -0
  61. package/dist/store/express-cookie-handler.js.map +1 -0
  62. package/dist/store/request-context.d.ts +36 -0
  63. package/dist/store/request-context.d.ts.map +1 -0
  64. package/dist/store/request-context.js +49 -0
  65. package/dist/store/request-context.js.map +1 -0
  66. package/dist/types/express.d.ts +13 -0
  67. package/dist/types/express.d.ts.map +1 -0
  68. package/dist/types/express.js +2 -0
  69. package/dist/types/express.js.map +1 -0
  70. package/dist/types.d.ts +125 -0
  71. package/dist/types.d.ts.map +1 -0
  72. package/dist/types.js +2 -0
  73. package/dist/types.js.map +1 -0
  74. package/dist/utils.d.ts +35 -0
  75. package/dist/utils.d.ts.map +1 -0
  76. package/dist/utils.js +146 -0
  77. package/dist/utils.js.map +1 -0
  78. package/package.json +9 -8
  79. package/dist/index.cjs +0 -566
  80. package/dist/index.cjs.map +0 -1
  81. package/dist/index.d.cts +0 -343
package/README.md CHANGED
@@ -8,13 +8,34 @@ The Auth0 Express SDK is a library for implementing user authentication in Expre
8
8
  ![Downloads](https://img.shields.io/npm/dw/@auth0/auth0-express)
9
9
  [![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue)](https://opensource.org/license/apache-2-0)
10
10
 
11
- 📚 [Documentation](#documentation) - 🚀 [Getting Started](#getting-started) - 💬 [Feedback](#feedback)
11
+ 📚 [Documentation](#documentation) - 🔎 [Features](#features) - 🚀 [Getting Started](#getting-started) - 💬 [Feedback](#feedback)
12
12
 
13
13
  ## Documentation
14
14
 
15
15
  - [Examples](https://github.com/auth0/auth0-express/blob/main/packages/auth0-express/EXAMPLES.md) - examples for your different use cases.
16
16
  - [Docs Site](https://auth0.com/docs) - explore our docs site and learn more about Auth0.
17
17
 
18
+ ## Features
19
+
20
+ Jump straight to the capability you need.
21
+
22
+ | Feature | What it does |
23
+ | --- | --- |
24
+ | [Quick start](#getting-started) | Mount Auth0 with `createAuth0` in a few lines |
25
+ | [Environment variables](#using-environment-variables) | Configure from `AUTH0_*` env vars instead of hardcoding |
26
+ | [Migrate from `express-openid-connect`](#using-environment-variables) | Supported legacy env var aliases for an easier move |
27
+ | [Built-in routes](#routes) | `/auth/login`, `/logout`, `/callback`, back-channel logout |
28
+ | [Custom login / logout / callback](#3-adding-login-and-logout) | Roll your own routes instead of the mounted ones |
29
+ | [Configure mounted routes](./EXAMPLES.md#configuring-the-mounted-routes) | Rename, re-path, or disable the built-in routes |
30
+ | [Protect a route with a session](#4-protecting-routes) | Gate server-rendered pages behind a login session |
31
+ | [Get the current session / user](#4-protecting-routes) | Read the authenticated user from `req.auth0` |
32
+ | [Call an API (`getAccessToken`)](#requesting-an-access-token-to-call-an-api) | Get an access token to call APIs as the user |
33
+ | [Authorization with claims](./EXAMPLES.md#authorization-with-claims) | Restrict routes with `claimEquals`, `claimIncludes`, `claimCheck` |
34
+ | [Dynamic app base URLs](./EXAMPLES.md#dynamic-application-base-urls) | Infer the base URL per host or use an allow-list |
35
+ | [Multiple Custom Domains (MCD)](./EXAMPLES.md#multiple-custom-domains-mcd) | Resolve the Auth0 domain per request |
36
+ | [Custom `fetch`](./EXAMPLES.md#configuring-a-customfetch-implementation) | Swap in your own fetch (proxies, retries, instrumentation) |
37
+ | [Discovery cache](./EXAMPLES.md#discovery-cache) | Control caching of OIDC discovery metadata |
38
+
18
39
  ## Getting Started
19
40
 
20
41
  ### 1. Install the SDK
@@ -23,7 +44,7 @@ The Auth0 Express SDK is a library for implementing user authentication in Expre
23
44
  npm i @auth0/auth0-express@beta
24
45
  ```
25
46
 
26
- This library requires Node.js 20 LTS and newer LTS versions.
47
+ This library requires Node.js 22 LTS and newer LTS versions.
27
48
 
28
49
  ### 2. Register the Auth0 Express Router
29
50
 
@@ -52,6 +73,8 @@ The `SESSION_SECRET` is the key used to encrypt the session cookie. You can gene
52
73
  openssl rand -hex 64
53
74
  ```
54
75
 
76
+ To rotate the session secret without logging existing users out, pass an array (`sessionSecret: [newSecret, oldSecret]`) or a comma-separated `AUTH0_SESSION_SECRET`. The first secret encrypts new cookies; all secrets are tried, in order, when decrypting. Once every session has been re-encrypted under the new secret, drop the old one.
77
+
55
78
  The `APP_BASE_URL` is the URL that your application is running on. When developing locally, this is most commonly `http://localhost:3000`. `APP_BASE_URL` is optional. Omit it to infer the base URL from the request host (useful for preview deployments), or provide a comma-separated list of allowed URLs. See [Dynamic Application Base URLs](./EXAMPLES.md#dynamic-application-base-urls).
56
79
 
57
80
  #### Using Environment Variables
@@ -0,0 +1,31 @@
1
+ import type { Request } from 'express';
2
+ /**
3
+ * Checks if a string is a valid HTTP or HTTPS URL.
4
+ */
5
+ export declare function isUrl(value: string): boolean;
6
+ /**
7
+ * Infers the application base URL from the incoming request.
8
+ *
9
+ * The protocol comes from `req.protocol`, which already honors `trust proxy`
10
+ * (reading `X-Forwarded-Proto` only when the proxy is trusted) on both Express
11
+ * 4 and 5. For the host we only consult `X-Forwarded-Host` when `trust proxy`
12
+ * trusts the peer; otherwise we use the raw `Host` header. We read the header
13
+ * directly rather than `req.host`/`req.hostname` because the Express 4 getters
14
+ * strip the port (and `req.host` is deprecated there), whereas the allow-list
15
+ * matches on origin including the port.
16
+ *
17
+ * Returns null when a valid origin cannot be built.
18
+ */
19
+ export declare function inferBaseUrlFromRequest(req: Request): string | null;
20
+ /**
21
+ * Resolves the application base URL for the current request.
22
+ *
23
+ * - `string`: used as-is (static configuration).
24
+ * - `undefined`: inferred from the request host (dynamic mode).
25
+ * - `string[]`: the request origin is matched against the allow-list; the
26
+ * matching origin is returned, otherwise an error is thrown.
27
+ *
28
+ * @throws {InvalidConfigurationError} When the base URL cannot be resolved.
29
+ */
30
+ export declare function resolveAppBaseUrl(appBaseUrl: string | string[] | undefined, req?: Request): string;
31
+ //# sourceMappingURL=app-base-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-base-url.d.ts","sourceRoot":"","sources":["../src/app-base-url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAKvC;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAO5C;AA2BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAYnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,MAAM,CAyClG"}
@@ -0,0 +1,102 @@
1
+ import { InvalidConfigurationError } from './errors/index.js';
2
+ const HTTP_PROTOCOLS = new Set(['http:', 'https:']);
3
+ /**
4
+ * Checks if a string is a valid HTTP or HTTPS URL.
5
+ */
6
+ export function isUrl(value) {
7
+ try {
8
+ const parsed = new URL(value);
9
+ return HTTP_PROTOCOLS.has(parsed.protocol);
10
+ }
11
+ catch {
12
+ return false;
13
+ }
14
+ }
15
+ function getFirstHeaderValue(value) {
16
+ if (!value) {
17
+ return undefined;
18
+ }
19
+ const raw = Array.isArray(value) ? value[0] : value;
20
+ if (!raw) {
21
+ return undefined;
22
+ }
23
+ const [first] = raw.split(',');
24
+ return first?.trim() || undefined;
25
+ }
26
+ /**
27
+ * Returns true when Express has been configured to trust the peer that sent
28
+ * this request (`trust proxy`), meaning forwarded headers may be honored.
29
+ *
30
+ * We reuse Express's own compiled `trust proxy fn` rather than reimplementing
31
+ * the trust policy, so this matches how `req.protocol`/`req.secure` decide
32
+ * whether to trust `X-Forwarded-*`. This works identically on Express 4 and 5.
33
+ */
34
+ function isProxyTrusted(req) {
35
+ const trust = req.app?.get('trust proxy fn');
36
+ return typeof trust === 'function' && trust(req.socket?.remoteAddress, 0);
37
+ }
38
+ /**
39
+ * Infers the application base URL from the incoming request.
40
+ *
41
+ * The protocol comes from `req.protocol`, which already honors `trust proxy`
42
+ * (reading `X-Forwarded-Proto` only when the proxy is trusted) on both Express
43
+ * 4 and 5. For the host we only consult `X-Forwarded-Host` when `trust proxy`
44
+ * trusts the peer; otherwise we use the raw `Host` header. We read the header
45
+ * directly rather than `req.host`/`req.hostname` because the Express 4 getters
46
+ * strip the port (and `req.host` is deprecated there), whereas the allow-list
47
+ * matches on origin including the port.
48
+ *
49
+ * Returns null when a valid origin cannot be built.
50
+ */
51
+ export function inferBaseUrlFromRequest(req) {
52
+ const trusted = isProxyTrusted(req);
53
+ const forwardedHost = trusted ? getFirstHeaderValue(req.headers['x-forwarded-host']) : undefined;
54
+ const host = forwardedHost || getFirstHeaderValue(req.headers['host']);
55
+ const proto = req.protocol;
56
+ if (!host || !proto) {
57
+ return null;
58
+ }
59
+ const candidate = `${proto}://${host}`;
60
+ return isUrl(candidate) ? candidate : null;
61
+ }
62
+ /**
63
+ * Resolves the application base URL for the current request.
64
+ *
65
+ * - `string`: used as-is (static configuration).
66
+ * - `undefined`: inferred from the request host (dynamic mode).
67
+ * - `string[]`: the request origin is matched against the allow-list; the
68
+ * matching origin is returned, otherwise an error is thrown.
69
+ *
70
+ * @throws {InvalidConfigurationError} When the base URL cannot be resolved.
71
+ */
72
+ export function resolveAppBaseUrl(appBaseUrl, req) {
73
+ const staticAppBaseUrl = typeof appBaseUrl === 'string' ? appBaseUrl : undefined;
74
+ const allowedAppBaseUrls = typeof appBaseUrl === 'string' ? undefined : appBaseUrl;
75
+ if (staticAppBaseUrl) {
76
+ return staticAppBaseUrl;
77
+ }
78
+ if (!req) {
79
+ throw new InvalidConfigurationError('APP_BASE_URL is not configured as a static string, and a request context is not available.');
80
+ }
81
+ const inferred = inferBaseUrlFromRequest(req);
82
+ if (!inferred) {
83
+ throw new InvalidConfigurationError('APP_BASE_URL is not configured as a static string, and the request origin could not be determined from the request context.');
84
+ }
85
+ if (!allowedAppBaseUrls) {
86
+ return inferred;
87
+ }
88
+ const requestOrigin = new URL(inferred).origin;
89
+ const matchedEntry = allowedAppBaseUrls.find((allowedUrl) => {
90
+ try {
91
+ return new URL(allowedUrl).origin === requestOrigin;
92
+ }
93
+ catch {
94
+ return false;
95
+ }
96
+ });
97
+ if (matchedEntry !== undefined) {
98
+ return matchedEntry;
99
+ }
100
+ throw new InvalidConfigurationError('APP_BASE_URL is not configured as a static string, and the APP_BASE_URL configuration does not contain a match for the current request origin.');
101
+ }
102
+ //# sourceMappingURL=app-base-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-base-url.js","sourceRoot":"","sources":["../src/app-base-url.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEpD;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,C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AC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,IAAI,yBAAyB,CACjC,gJAAgJ,CACjJ,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Auth0Options } from './types.js';
2
+ /**
3
+ * Merges environment variables with provided configuration options.
4
+ * Environment variables are used as defaults and can be overridden by explicitly provided options.
5
+ *
6
+ * Supported environment variables:
7
+ * - AUTH0_DOMAIN or ISSUER_BASE_URL
8
+ * - AUTH0_CLIENT_ID or CLIENT_ID: Auth0 application client ID
9
+ * - AUTH0_CLIENT_SECRET or CLIENT_SECRET: Auth0 application client secret
10
+ * - APP_BASE_URL or BASE_URL: Application base URL
11
+ * - AUTH0_SESSION_SECRET or SECRET: Session secret for cookie signing
12
+ * - AUTH0_AUDIENCE: Optional API audience
13
+ */
14
+ export declare function getConfig(config?: Partial<Auth0Options>): Auth0Options;
15
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA6E/C;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,MAAM,GAAE,OAAO,CAAC,YAAY,CAAM,GAAG,YAAY,CA0C1E"}
package/dist/config.js ADDED
@@ -0,0 +1,102 @@
1
+ import { MissingRequiredArgumentError } from '@auth0/auth0-server-js';
2
+ import { isUrl } from './app-base-url.js';
3
+ import { InvalidConfigurationError } from './errors/index.js';
4
+ function stripProtocol(url) {
5
+ return url ? url.replace(/^https?:\/\//, '') : url;
6
+ }
7
+ function parseCommaSeparatedEnv(value) {
8
+ if (!value) {
9
+ return undefined;
10
+ }
11
+ if (value.includes(',')) {
12
+ const entries = value
13
+ .split(',')
14
+ .map((entry) => entry.trim())
15
+ .filter(Boolean);
16
+ return entries.length === 1 ? entries[0] : entries;
17
+ }
18
+ return value;
19
+ }
20
+ function validateAppBaseUrl(appBaseUrl) {
21
+ if (appBaseUrl === undefined) {
22
+ return; // dynamic mode
23
+ }
24
+ if (Array.isArray(appBaseUrl)) {
25
+ if (appBaseUrl.length === 0) {
26
+ throw new InvalidConfigurationError('APP_BASE_URL array configuration cannot be empty.');
27
+ }
28
+ const invalid = appBaseUrl.filter((url) => !isUrl(url));
29
+ if (invalid.length > 0) {
30
+ throw new InvalidConfigurationError(`APP_BASE_URL array contains invalid URLs: ${invalid.join(', ')}`);
31
+ }
32
+ return;
33
+ }
34
+ if (!isUrl(appBaseUrl)) {
35
+ throw new InvalidConfigurationError(`APP_BASE_URL must be a valid http(s) URL: ${appBaseUrl}`);
36
+ }
37
+ }
38
+ function enforceSecureCookies(config) {
39
+ const isProduction = process.env.NODE_ENV === 'production';
40
+ const isDynamic = typeof config.appBaseUrl !== 'string';
41
+ if (!isProduction || !isDynamic) {
42
+ return;
43
+ }
44
+ const explicitSecure = config.sessionConfiguration?.cookie?.secure;
45
+ if (explicitSecure === false) {
46
+ throw new InvalidConfigurationError('Secure cookies are required when relying on dynamic base URLs in production. ' +
47
+ 'Remove the explicit `sessionConfiguration.cookie.secure = false` or set a static APP_BASE_URL.');
48
+ }
49
+ config.sessionConfiguration = {
50
+ ...config.sessionConfiguration,
51
+ cookie: {
52
+ ...config.sessionConfiguration?.cookie,
53
+ secure: true,
54
+ },
55
+ };
56
+ }
57
+ /**
58
+ * Merges environment variables with provided configuration options.
59
+ * Environment variables are used as defaults and can be overridden by explicitly provided options.
60
+ *
61
+ * Supported environment variables:
62
+ * - AUTH0_DOMAIN or ISSUER_BASE_URL
63
+ * - AUTH0_CLIENT_ID or CLIENT_ID: Auth0 application client ID
64
+ * - AUTH0_CLIENT_SECRET or CLIENT_SECRET: Auth0 application client secret
65
+ * - APP_BASE_URL or BASE_URL: Application base URL
66
+ * - AUTH0_SESSION_SECRET or SECRET: Session secret for cookie signing
67
+ * - AUTH0_AUDIENCE: Optional API audience
68
+ */
69
+ export function getConfig(config = {}) {
70
+ const mergedConfig = {
71
+ domain: process.env.AUTH0_DOMAIN || stripProtocol(process.env.ISSUER_BASE_URL),
72
+ clientId: process.env.AUTH0_CLIENT_ID || process.env.CLIENT_ID,
73
+ clientSecret: process.env.AUTH0_CLIENT_SECRET || process.env.CLIENT_SECRET,
74
+ appBaseUrl: parseCommaSeparatedEnv(process.env.APP_BASE_URL || process.env.BASE_URL),
75
+ sessionSecret: parseCommaSeparatedEnv(process.env.AUTH0_SESSION_SECRET || process.env.SECRET),
76
+ audience: process.env.AUTH0_AUDIENCE,
77
+ ...config,
78
+ };
79
+ // A comma-separated value is normalized into an array whether it comes from
80
+ // the environment or is passed explicitly as `appBaseUrl`/`sessionSecret`,
81
+ // so both sources behave identically.
82
+ if (typeof mergedConfig.appBaseUrl === 'string') {
83
+ mergedConfig.appBaseUrl = parseCommaSeparatedEnv(mergedConfig.appBaseUrl);
84
+ }
85
+ if (typeof mergedConfig.sessionSecret === 'string') {
86
+ mergedConfig.sessionSecret = parseCommaSeparatedEnv(mergedConfig.sessionSecret);
87
+ }
88
+ if (!mergedConfig.domain) {
89
+ throw new MissingRequiredArgumentError('domain');
90
+ }
91
+ if (!mergedConfig.clientId) {
92
+ throw new MissingRequiredArgumentError('clientId');
93
+ }
94
+ validateAppBaseUrl(mergedConfig.appBaseUrl);
95
+ if (!mergedConfig.sessionSecret ||
96
+ (Array.isArray(mergedConfig.sessionSecret) && mergedConfig.sessionSecret.length === 0)) {
97
+ throw new MissingRequiredArgumentError('sessionSecret');
98
+ }
99
+ enforceSecureCookies(mergedConfig);
100
+ return mergedConfig;
101
+ }
102
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,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AY,CAAC;AACtB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { InvalidConfigurationError } from '@auth0/auth0-server-js';
2
+ export declare class MissingStoreOptionsError extends Error {
3
+ code: string;
4
+ constructor(message?: string);
5
+ }
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,qBAAa,wBAAyB,SAAQ,KAAK;IAC1C,IAAI,EAAE,MAAM,CAAiC;gBAExC,OAAO,CAAC,EAAE,MAAM;CAI7B"}
@@ -0,0 +1,9 @@
1
+ export { InvalidConfigurationError } from '@auth0/auth0-server-js';
2
+ export class MissingStoreOptionsError extends Error {
3
+ code = 'missing_store_options_error';
4
+ constructor(message) {
5
+ super(message ?? 'The store options are missing, making it impossible to interact with the store.');
6
+ this.name = 'MissingStoreOptionsError';
7
+ }
8
+ }
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAC1C,IAAI,GAAW,6BAA6B,CAAC;IAEpD,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,IAAI,iFAAiF,CAAC,CAAC;QACpG,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ import { Request, Response } from 'express';
2
+ export declare function handleBackchannelLogout(req: Request, res: Response): Promise<void>;
3
+ //# sourceMappingURL=backchannel-logout-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backchannel-logout-handler.d.ts","sourceRoot":"","sources":["../../src/handlers/backchannel-logout-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE5C,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAcxF"}
@@ -0,0 +1,15 @@
1
+ export async function handleBackchannelLogout(req, res) {
2
+ const logoutToken = req.body.logout_token;
3
+ if (!logoutToken) {
4
+ res.status(400).send('Missing `logout_token` in the request body.');
5
+ return;
6
+ }
7
+ try {
8
+ await req.auth0.client.handleBackchannelLogout(logoutToken);
9
+ res.status(204).send(null);
10
+ }
11
+ catch (e) {
12
+ res.status(400).send(e.message);
13
+ }
14
+ }
15
+ //# sourceMappingURL=backchannel-logout-handler.js.map
@@ -0,0 +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,OAAO,CAAC,EAAE,CAAC;QACX,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAE,CAAW,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Request, Response } from 'express';
2
+ import { Auth0Options } from '../types.js';
3
+ export declare function handleCallback(req: Request, res: Response, options: Auth0Options): Promise<void>;
4
+ //# sourceMappingURL=callback-handler.d.ts.map
@@ -0,0 +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;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,wBAAsB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBtG"}
@@ -0,0 +1,18 @@
1
+ import { createRouteUrl } from '../utils.js';
2
+ import { resolveAppBaseUrl } from '../app-base-url.js';
3
+ export async function handleCallback(req, res, options) {
4
+ try {
5
+ const appBaseUrl = resolveAppBaseUrl(options.appBaseUrl, req);
6
+ const { appState } = await req.auth0.client.completeInteractiveLogin(createRouteUrl(req.url, appBaseUrl));
7
+ res.redirect(appState?.returnTo ?? appBaseUrl);
8
+ }
9
+ catch (e) {
10
+ /* eslint-disable @typescript-eslint/no-explicit-any */
11
+ const error = e;
12
+ res.status(500).json({
13
+ error: error.cause?.error || error.name,
14
+ message: error.cause?.error_description || error.message,
15
+ });
16
+ }
17
+ }
18
+ //# sourceMappingURL=callback-handler.js.map
@@ -0,0 +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;AAGvD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAY,EAAE,GAAa,EAAE,OAAqB;IACrF,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAE9D,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,CAAU,EAAE,CAAC;QACpB,uDAAuD;QACvD,MAAM,KAAK,GAAG,CAAQ,CAAC;QAEvB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACnB,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,IAAI,KAAK,CAAC,IAAI;YACvC,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,iBAAiB,IAAI,KAAK,CAAC,OAAO;SACzD,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Request, Response } from 'express';
2
+ import { Auth0Options } from '../index.js';
3
+ export declare function handleLogin(req: Request, res: Response, options: Auth0Options): Promise<void>;
4
+ //# sourceMappingURL=login-handler.d.ts.map
@@ -0,0 +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;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA4C3C,wBAAsB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BnG"}
@@ -0,0 +1,64 @@
1
+ import { createRouteUrl, toSafeRedirect } from '../utils.js';
2
+ import { resolveAppBaseUrl } from '../app-base-url.js';
3
+ // Block both Object.prototype own-property names and commonly abused
4
+ // prototype-pollution keys that are not own-properties of Object.prototype.
5
+ const DENIED_KEYS = new Set([
6
+ ...Object.getOwnPropertyNames(Object.prototype),
7
+ '__proto__',
8
+ 'constructor',
9
+ 'prototype',
10
+ ]);
11
+ // OAuth/OIDC protocol parameters that must be SDK-controlled, not user-supplied
12
+ const RESERVED_OAUTH_PARAMS = new Set([
13
+ 'response_type',
14
+ 'state',
15
+ 'code_challenge',
16
+ 'code_challenge_method',
17
+ 'client_id',
18
+ 'redirect_uri',
19
+ 'nonce',
20
+ 'scope',
21
+ 'audience',
22
+ ]);
23
+ /**
24
+ * Filters out reserved OAuth parameters and any additional disallowed parameters from the input record.
25
+ * This ensures that only safe, non-reserved parameters are included in the authorization request.
26
+ * @param params The record of parameters to filter.
27
+ * @param disallowed An array of parameter names that should be excluded.
28
+ * @returns An object containing only the allowed parameters, or undefined if none are allowed.
29
+ */
30
+ function filterAuthorizationParams(params, disallowed) {
31
+ const filtered = Object.create(null);
32
+ for (const [key, value] of Object.entries(params)) {
33
+ if (!DENIED_KEYS.has(key) && !disallowed.includes(key) && !RESERVED_OAUTH_PARAMS.has(key)) {
34
+ filtered[key] = value;
35
+ }
36
+ }
37
+ return Object.keys(filtered).length > 0 ? filtered : undefined;
38
+ }
39
+ export async function handleLogin(req, res, options) {
40
+ try {
41
+ const appBaseUrl = resolveAppBaseUrl(options.appBaseUrl, req);
42
+ const callbackPath = options.routes?.callback ?? '/auth/callback';
43
+ const redirectUri = createRouteUrl(callbackPath, appBaseUrl);
44
+ const query = req.query;
45
+ const dangerousReturnTo = query.returnTo;
46
+ const sanitizedReturnTo = toSafeRedirect(dangerousReturnTo || '/', appBaseUrl);
47
+ const authorizationUrl = await req.auth0.client.startInteractiveLogin({
48
+ pushedAuthorizationRequests: options.pushedAuthorizationRequests,
49
+ appState: { returnTo: sanitizedReturnTo },
50
+ authorizationParams: {
51
+ ...filterAuthorizationParams(query, ['returnTo']),
52
+ redirect_uri: redirectUri.toString(),
53
+ },
54
+ });
55
+ res.redirect(authorizationUrl.href);
56
+ }
57
+ catch (error) {
58
+ res.status(500).json({
59
+ error: error.name,
60
+ message: error.message,
61
+ });
62
+ }
63
+ }
64
+ //# sourceMappingURL=login-handler.js.map
@@ -0,0 +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;AAGvD,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,UAAU;CACX,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,SAAS,yBAAyB,CAChC,MAA+B,EAC/B,UAAoB;IAEpB,MAAM,QAAQ,GAA4B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC9D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1F,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GA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import { Auth0Options } from '../types.js';
3
+ export declare function handleLogout(req: Request, res: Response, options: Auth0Options): Promise<void>;
4
+ //# sourceMappingURL=logout-handler.d.ts.map
@@ -0,0 +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;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,wBAAsB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAYpG"}
@@ -0,0 +1,15 @@
1
+ import { resolveAppBaseUrl } from '../app-base-url.js';
2
+ export async function handleLogout(req, res, options) {
3
+ try {
4
+ const returnTo = resolveAppBaseUrl(options.appBaseUrl, req);
5
+ const logoutUrl = await req.auth0.client.logout({ returnTo });
6
+ res.redirect(logoutUrl.href);
7
+ }
8
+ catch (error) {
9
+ res.status(500).json({
10
+ error: error.name,
11
+ message: error.message,
12
+ });
13
+ }
14
+ }
15
+ //# sourceMappingURL=logout-handler.js.map
@@ -0,0 +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;AAGvD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAY,EAAE,GAAa,EAAE,OAAqB;IACnF,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAC5D,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QAE9D,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YACnB,KAAK,EAAG,KAAe,CAAC,IAAI;YAC5B,OAAO,EAAG,KAAe,CAAC,OAAO;SAClC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}