@auth0/auth0-express 1.0.0-beta.0 → 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 +27 -4
  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 -297
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +8 -375
  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 +10 -9
  79. package/dist/index.cjs +0 -417
  80. package/dist/index.cjs.map +0 -1
  81. package/dist/index.d.cts +0 -297
package/dist/router.js ADDED
@@ -0,0 +1,76 @@
1
+ import { Router } from 'express';
2
+ import cookieParser from 'cookie-parser';
3
+ import { createServerClientInstance } from './utils.js';
4
+ import { handleLogin } from './handlers/login-handler.js';
5
+ import { handleCallback } from './handlers/callback-handler.js';
6
+ import { handleLogout } from './handlers/logout-handler.js';
7
+ import { handleBackchannelLogout } from './handlers/backchannel-logout-handler.js';
8
+ import { runWithContext } from './store/request-context.js';
9
+ import { getConfig } from './config.js';
10
+ import './types/express.js';
11
+ /**
12
+ * Creates an Express router with Auth0 authentication middleware.
13
+ *
14
+ * This is the main entry point for the Auth0 Express SDK. It configures
15
+ * authentication routes and attaches the Auth0 client to the request object.
16
+ *
17
+ * @param opts - Configuration options for Auth0 authentication
18
+ * @returns Express Router configured with Auth0 authentication
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import express from 'express';
23
+ * import { createAuth0 } from '@auth0/auth0-express';
24
+ *
25
+ * const app = express();
26
+ *
27
+ * // Using environment variables (AUTH0_DOMAIN, AUTH0_CLIENT_ID, etc.)
28
+ * app.use(createAuth0());
29
+ *
30
+ * // Or with explicit configuration
31
+ * app.use(createAuth0({
32
+ * domain: 'tenant.auth0.com',
33
+ * clientId: 'your_client_id',
34
+ * clientSecret: 'your_client_secret',
35
+ * appBaseUrl: 'http://localhost:3000',
36
+ * sessionSecret: process.env.SESSION_SECRET
37
+ * }));
38
+ * ```
39
+ */
40
+ export function createAuth0(opts = {}) {
41
+ const options = getConfig(opts);
42
+ const router = Router();
43
+ // Cookie parsing
44
+ router.use(cookieParser());
45
+ // Establish AsyncLocalStorage context for the request lifecycle
46
+ router.use((request, response, next) => {
47
+ runWithContext({ request, response }, () => next());
48
+ });
49
+ // Initialize auth0Client
50
+ const auth0Client = createServerClientInstance(options);
51
+ // Attach to request
52
+ router.use((req, res, next) => {
53
+ req.auth0 = { client: auth0Client };
54
+ req.app.locals.auth0Client = auth0Client;
55
+ req.app.locals.auth0ClientOptions = options;
56
+ req.app.locals.appBaseUrl = options.appBaseUrl;
57
+ req.app.locals.pushedAuthorizationRequests = options.pushedAuthorizationRequests;
58
+ next();
59
+ });
60
+ // Mount routes
61
+ const shouldMountRoutes = options.mountRoutes ?? true;
62
+ if (shouldMountRoutes) {
63
+ const routes = {
64
+ login: options.routes?.login ?? '/auth/login',
65
+ callback: options.routes?.callback ?? '/auth/callback',
66
+ logout: options.routes?.logout ?? '/auth/logout',
67
+ backchannelLogout: options.routes?.backchannelLogout ?? '/auth/backchannel-logout',
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));
72
+ router.post(routes.backchannelLogout, (req, res) => handleBackchannelLogout(req, res));
73
+ }
74
+ return router;
75
+ }
76
+ //# sourceMappingURL=router.js.map
@@ -0,0 +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,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,WAAW,CAAC,OAA8B,EAAE;IAC1D,MAAM,OAAO,GAAG,SA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,MAAM,IAAI,cAAc;YAChD,iBAAiB,EAAE,OAAO,CAAC,MAAM,EAAE,iBAAiB,IAAI,0BAA0B;SACnF,CAAC;QAEF,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;QACvE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;QAC7E,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;QACzE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,uBAAuB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACzF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { CookieHandler, CookieSerializeOptions } from '@auth0/auth0-server-js';
2
+ import { StoreOptions } from '../types.js';
3
+ /**
4
+ * Express-specific cookie handler that uses AsyncLocalStorage to automatically
5
+ * access the current request and response objects.
6
+ *
7
+ * This implementation supports both explicit storeOptions and AsyncLocalStorage context.
8
+ * When storeOptions are provided, they take precedence. Otherwise, it falls back to
9
+ * retrieving the request context from AsyncLocalStorage.
10
+ */
11
+ export declare class ExpressCookieHandler implements CookieHandler<StoreOptions> {
12
+ setCookie(name: string, value: string, options?: CookieSerializeOptions, storeOptions?: StoreOptions): void;
13
+ getCookie(name: string, storeOptions?: StoreOptions): string | undefined;
14
+ getCookies(storeOptions?: StoreOptions): Record<string, string>;
15
+ deleteCookie(name: string, storeOptions?: StoreOptions): void;
16
+ }
17
+ //# sourceMappingURL=express-cookie-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"express-cookie-handler.d.ts","sourceRoot":"","sources":["../../src/store/express-cookie-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C;;;;;;;GAOG;AACH,qBAAa,oBAAqB,YAAW,aAAa,CAAC,YAAY,CAAC;IACtE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,sBAAsB,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI;IAS3G,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS;IAKxE,UAAU,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAK/D,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI;CAI9D"}
@@ -0,0 +1,30 @@
1
+ import { getRequestContext } from './request-context.js';
2
+ /**
3
+ * Express-specific cookie handler that uses AsyncLocalStorage to automatically
4
+ * access the current request and response objects.
5
+ *
6
+ * This implementation supports both explicit storeOptions and AsyncLocalStorage context.
7
+ * When storeOptions are provided, they take precedence. Otherwise, it falls back to
8
+ * retrieving the request context from AsyncLocalStorage.
9
+ */
10
+ export class ExpressCookieHandler {
11
+ setCookie(name, value, options, storeOptions) {
12
+ const { response } = storeOptions ?? getRequestContext();
13
+ // options.maxAge is in seconds, but Express expects milliseconds
14
+ const maxAge = options?.maxAge != null ? options.maxAge * 1000 : undefined;
15
+ response.cookie(name, value, { ...options, maxAge });
16
+ }
17
+ getCookie(name, storeOptions) {
18
+ const { request } = storeOptions ?? getRequestContext();
19
+ return request.cookies?.[name];
20
+ }
21
+ getCookies(storeOptions) {
22
+ const { request } = storeOptions ?? getRequestContext();
23
+ return request.cookies;
24
+ }
25
+ deleteCookie(name, storeOptions) {
26
+ const { response } = storeOptions ?? getRequestContext();
27
+ response.clearCookie(name);
28
+ }
29
+ }
30
+ //# sourceMappingURL=express-cookie-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"express-cookie-handler.js","sourceRoot":"","sources":["../../src/store/express-cookie-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;;;;;GAOG;AACH,MAAM,OAAO,oBAAoB;IAC/B,SAAS,CAAC,IAAY,EAAE,KAAa,EAAE,OAAgC,EAAE,YAA2B;QAClG,MAAM,EAAE,QAAQ,EAAE,GAAG,YAAY,IAAI,iBAAiB,EAAE,CAAC;QAEzD,iEAAiE;QACjE,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAE3E,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,SAAS,CAAC,IAAY,EAAE,YAA2B;QACjD,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,IAAI,iBAAiB,EAAE,CAAC;QACxD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,UAAU,CAAC,YAA2B;QACpC,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,IAAI,iBAAiB,EAAE,CAAC;QACxD,OAAO,OAAO,CAAC,OAAiC,CAAC;IACnD,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,YAA2B;QACpD,MAAM,EAAE,QAAQ,EAAE,GAAG,YAAY,IAAI,iBAAiB,EAAE,CAAC;QACzD,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ import { StoreOptions } from 'src/types.js';
2
+ /**
3
+ * Context containing Express request and response objects.
4
+ * Available within the AsyncLocalStorage scope established by the auth0 middleware.
5
+ */
6
+ export type RequestContext = StoreOptions;
7
+ /**
8
+ * Runs a callback within an AsyncLocalStorage context containing the request and response.
9
+ * This establishes the context for the entire request lifecycle.
10
+ *
11
+ * @param request - Express request object
12
+ * @param response - Express response object
13
+ * @param callback - Function to execute within the context
14
+ * @returns The result of the callback
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * app.use((req, res, next) => {
19
+ * runWithContext(req, res, () => next());
20
+ * });
21
+ * ```
22
+ */
23
+ export declare function runWithContext<T>(context: RequestContext, callback: () => T): T;
24
+ /**
25
+ * Retrieves the current request context from AsyncLocalStorage.
26
+ *
27
+ * @returns The current RequestContext
28
+ * @throws {Error} If called outside of a request context
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const { request, response } = getRequestContext();
33
+ * ```
34
+ */
35
+ export declare function getRequestContext(): RequestContext;
36
+ //# sourceMappingURL=request-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/store/request-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC;AAQ1C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,MAAM,CAAC,GAChB,CAAC,CAEH;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CAelD"}
@@ -0,0 +1,49 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ /**
3
+ * AsyncLocalStorage instance for storing request context.
4
+ * @internal
5
+ */
6
+ const asyncLocalStorage = new AsyncLocalStorage();
7
+ /**
8
+ * Runs a callback within an AsyncLocalStorage context containing the request and response.
9
+ * This establishes the context for the entire request lifecycle.
10
+ *
11
+ * @param request - Express request object
12
+ * @param response - Express response object
13
+ * @param callback - Function to execute within the context
14
+ * @returns The result of the callback
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * app.use((req, res, next) => {
19
+ * runWithContext(req, res, () => next());
20
+ * });
21
+ * ```
22
+ */
23
+ export function runWithContext(context, callback) {
24
+ return asyncLocalStorage.run(context, callback);
25
+ }
26
+ /**
27
+ * Retrieves the current request context from AsyncLocalStorage.
28
+ *
29
+ * @returns The current RequestContext
30
+ * @throws {Error} If called outside of a request context
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const { request, response } = getRequestContext();
35
+ * ```
36
+ */
37
+ export function getRequestContext() {
38
+ const context = asyncLocalStorage.getStore();
39
+ if (!context) {
40
+ throw new Error('Request context not available. This error typically occurs when:\n' +
41
+ '1. Client methods are called outside of a request handler\n' +
42
+ '2. The auth0 middleware has not been initialized\n' +
43
+ '3. AsyncLocalStorage context was lost in an async operation\n\n' +
44
+ 'Ensure you are calling client methods within an Express request handler ' +
45
+ 'and the auth0 middleware is properly configured.');
46
+ }
47
+ return context;
48
+ }
49
+ //# sourceMappingURL=request-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-context.js","sourceRoot":"","sources":["../../src/store/request-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AASrD;;;GAGG;AACH,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAkB,CAAC;AAElE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAuB,EACvB,QAAiB;IAEjB,OAAO,iBAAiB,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,OAAO,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC;IAE7C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,oEAAoE;YAClE,6DAA6D;YAC7D,oDAAoD;YACpD,iEAAiE;YACjE,0EAA0E;YAC1E,kDAAkD,CACrD,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { ServerClient } from '@auth0/auth0-server-js';
2
+ import type { StoreOptions } from '../types.js';
3
+ declare global {
4
+ namespace Express {
5
+ interface Request {
6
+ auth0: {
7
+ client: ServerClient<StoreOptions>;
8
+ };
9
+ }
10
+ }
11
+ }
12
+ export {};
13
+ //# sourceMappingURL=express.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/types/express.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,KAAK,EAAE;gBACL,MAAM,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;aACpC,CAAC;SACH;KACF;CACF;AAED,OAAO,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=express.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/types/express.ts"],"names":[],"mappings":""}
@@ -0,0 +1,125 @@
1
+ import type { DiscoveryCacheOptions, DomainResolver, SessionConfiguration, SessionStore } from '@auth0/auth0-server-js';
2
+ import type { Request, Response } from 'express';
3
+ export type { DomainResolver, DiscoveryCacheOptions } from '@auth0/auth0-server-js';
4
+ /**
5
+ * Options passed to custom session store implementations.
6
+ *
7
+ * These options provide access to the Express request and response objects,
8
+ * which are needed for cookie and session management operations.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * class CustomSessionStore implements SessionStore<StoreOptions> {
13
+ * async get(id: string, options: StoreOptions) {
14
+ * const { request, response } = options;
15
+ * // Access cookies, headers, etc.
16
+ * }
17
+ * }
18
+ * ```
19
+ */
20
+ export interface StoreOptions {
21
+ /** Express request object */
22
+ request: Request;
23
+ /** Express response object */
24
+ response: Response;
25
+ }
26
+ /**
27
+ * Configuration options for Auth0 authentication in Express applications.
28
+ *
29
+ * Environment variable support:
30
+ * - AUTH0_DOMAIN or ISSUER_BASE_URL: Auth0 domain
31
+ * - AUTH0_CLIENT_ID or CLIENT_ID: Client ID
32
+ * - AUTH0_CLIENT_SECRET or CLIENT_SECRET: Client secret
33
+ * - APP_BASE_URL or BASE_URL: Application base URL
34
+ * - AUTH0_SESSION_SECRET or SECRET: Session encryption secret
35
+ * - AUTH0_AUDIENCE: Optional API audience
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const options: Auth0Options = {
40
+ * domain: 'tenant.auth0.com',
41
+ * clientId: 'your_client_id',
42
+ * clientSecret: 'your_client_secret',
43
+ * appBaseUrl: 'http://localhost:3000',
44
+ * sessionSecret: process.env.SESSION_SECRET
45
+ * };
46
+ * ```
47
+ */
48
+ export interface Auth0Options {
49
+ /**
50
+ * Auth0 domain (e.g., 'tenant.auth0.com') without protocol.
51
+ *
52
+ * Provide a `DomainResolver` function to resolve the Auth0 custom domain
53
+ * per request (Multiple Custom Domains). The resolver receives the Express
54
+ * request context (`{ request, response }`) and returns the domain string.
55
+ */
56
+ domain: string | DomainResolver<StoreOptions>;
57
+ /** Auth0 application client ID */
58
+ clientId: string;
59
+ /** Auth0 application client secret (required for token exchange) */
60
+ clientSecret?: string;
61
+ /** Private key for client assertion authentication (alternative to clientSecret) */
62
+ clientAssertionSigningKey?: string | CryptoKey;
63
+ /** Algorithm for client assertion signing (e.g., 'RS256') */
64
+ clientAssertionSigningAlg?: string;
65
+ /** API audience for requesting access tokens */
66
+ audience?: string;
67
+ /**
68
+ * Base URL of your application (e.g., 'http://localhost:3000').
69
+ *
70
+ * - Provide a single URL string for a static base URL (default behavior).
71
+ * - Provide an array of allowed URLs to validate the incoming request origin
72
+ * against an allow-list (recommended for dynamic/preview deployments).
73
+ * - Omit it (or set `APP_BASE_URL`/`BASE_URL` empty) to infer the base URL
74
+ * from the incoming request host at runtime.
75
+ */
76
+ appBaseUrl?: string | string[];
77
+ /** Enable Pushed Authorization Requests (PAR) for enhanced security */
78
+ pushedAuthorizationRequests?: boolean;
79
+ /**
80
+ * Secret for encrypting session cookies (minimum 32 characters recommended).
81
+ *
82
+ * Provide an array to support secret rotation: the first secret is used to encrypt new
83
+ * cookies, while all secrets are tried, in order, when decrypting. This lets you roll the
84
+ * secret without logging existing users out — deploy `[newSecret, oldSecret]`, then drop
85
+ * the old secret once every session has been re-encrypted under the new one.
86
+ *
87
+ * Via environment variables, a comma-separated `AUTH0_SESSION_SECRET` (or `SECRET`) is
88
+ * parsed into an array in the same order.
89
+ */
90
+ sessionSecret: string | string[];
91
+ /** Custom session store implementation (defaults to cookie-based sessions) */
92
+ sessionStore?: SessionStore<StoreOptions>;
93
+ /** Advanced session configuration (cookie settings, timeouts, etc.) */
94
+ sessionConfiguration?: SessionConfiguration;
95
+ /**
96
+ * Whether to mount the default routes for login, logout, callback and backchannel logout.
97
+ * Routes: /auth/login, /auth/callback, /auth/logout, /auth/backchannel-logout
98
+ * @default true
99
+ */
100
+ mountRoutes?: boolean;
101
+ /**
102
+ * Custom fetch implementation for HTTP requests.
103
+ * Useful for proxies, custom headers, or testing.
104
+ */
105
+ customFetch?: typeof fetch;
106
+ /**
107
+ * Optional discovery cache configuration for OIDC metadata and JWKS.
108
+ * `ttl` is in seconds. Cache entries are scoped per resolved domain, which
109
+ * matters for MCD deployments serving many domains. Defaults to the
110
+ * `ServerClient` defaults (TTL 600s, max 100 entries) when omitted.
111
+ */
112
+ discoveryCache?: DiscoveryCacheOptions;
113
+ /** Custom paths for authentication routes (only used if mountRoutes is true) */
114
+ routes?: {
115
+ /** Login route path @default '/auth/login' */
116
+ login?: string;
117
+ /** OAuth callback route path @default '/auth/callback' */
118
+ callback?: string;
119
+ /** Logout route path @default '/auth/logout' */
120
+ logout?: string;
121
+ /** Backchannel logout route path @default '/auth/backchannel-logout' */
122
+ backchannelLogout?: string;
123
+ };
124
+ }
125
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,YAAY,EACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEjD,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,YAAY;IAC3B,6BAA6B;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;IAC9C,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,yBAAyB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/C,6DAA6D;IAC7D,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE/B,uEAAuE;IACvE,2BAA2B,CAAC,EAAE,OAAO,CAAC;IAEtC;;;;;;;;;;OAUG;IACH,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,8EAA8E;IAC9E,YAAY,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;IAC1C,uEAAuE;IACvE,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,KAAK,CAAC;IAE3B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,qBAAqB,CAAC;IAEvC,gFAAgF;IAChF,MAAM,CAAC,EAAE;QACP,8CAA8C;QAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,0DAA0D;QAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,gDAAgD;QAChD,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,wEAAwE;QACxE,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import { ServerClient } from '@auth0/auth0-server-js';
2
+ import type { DomainResolver } from '@auth0/auth0-server-js';
3
+ import { Auth0Options, StoreOptions } from './types.js';
4
+ /**
5
+ * Wraps a user-provided domain resolver so it always receives the Express
6
+ * request context. `@auth0/auth0-server-js` invokes the resolver with the
7
+ * `storeOptions` passed to client methods; this SDK relies on
8
+ * `AsyncLocalStorage` instead of passing them explicitly, so when
9
+ * `storeOptions` is absent we recover it via `getRequestContext()` — the same
10
+ * fallback used by `ExpressCookieHandler`.
11
+ *
12
+ * A static string domain is returned unchanged.
13
+ */
14
+ export declare function wrapDomainResolver(domain: Auth0Options['domain']): string | DomainResolver<StoreOptions>;
15
+ /**
16
+ * Utility function to ensure Route URLs are created correctly when using both the root and subpath as base URL.
17
+ * Accepts a relative path or an absolute same-origin URL, such as one forwarded by a reverse proxy.
18
+ * Validates that the constructed URL has the same origin as the base URL to prevent host override attacks.
19
+ * @param url Relative path (e.g. `/auth/callback`) or absolute same-origin URL.
20
+ * @param base The base URL to use, including any subpath.
21
+ * @returns A URL object, combining the base and url.
22
+ * @throws {Error} If the input contains multiple leading slashes/backslashes or the origin does not match the base URL.
23
+ */
24
+ export declare function createRouteUrl(url: string, base: string): URL;
25
+ /**
26
+ * Validates a user-supplied redirect URL (e.g. a `returnTo` query parameter) against the application base URL.
27
+ * Accepts relative paths and absolute same-origin URLs. Rejects different-origin URLs and injection attempts.
28
+ * Never throws — returns undefined for any invalid or unsafe input.
29
+ * @param dangerousRedirect Untrusted redirect URL from user input.
30
+ * @param safeBaseUrl The base URL to check against.
31
+ * @returns A safe redirect URL, or undefined if the input is not safe.
32
+ */
33
+ export declare function toSafeRedirect(dangerousRedirect: string, safeBaseUrl: string): string | undefined;
34
+ export declare function createServerClientInstance(options: Auth0Options): ServerClient<StoreOptions>;
35
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,YAAY,EAA2C,MAAM,wBAAwB,CAAC;AACvH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAsCxD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,GAC7B,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC,CAMvC;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAsCvD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,iBAAiB,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASjG;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,YAAY,8BAyC/D"}
package/dist/utils.js ADDED
@@ -0,0 +1,146 @@
1
+ import { CookieTransactionStore, ServerClient, StatefulStateStore, StatelessStateStore } from '@auth0/auth0-server-js';
2
+ import { ExpressCookieHandler } from './store/express-cookie-handler.js';
3
+ import { getRequestContext } from './store/request-context.js';
4
+ /**
5
+ * Ensures the value has a trailing slash.
6
+ * If it does not, it will append one.
7
+ * @param value The value to ensure has a trailing slash.
8
+ * @returns The value with a trailing slash.
9
+ */
10
+ function ensureTrailingSlash(value) {
11
+ return value && !value.endsWith('/') ? `${value}/` : value;
12
+ }
13
+ /**
14
+ * Ensures the value does not have any leading slashes or backslashes.
15
+ * If it does, it will trim all of them.
16
+ * @param value The value to ensure has no leading slashes or backslashes.
17
+ * @returns The value without leading slashes or backslashes.
18
+ */
19
+ function ensureNoLeadingSlash(value) {
20
+ return value.replace(/^[/\\]+/, '');
21
+ }
22
+ // Matches only URLs with an authority component (e.g. https://, http://, file://).
23
+ // Bare-scheme inputs like `javascript:alert(1)` or `report:summary` do NOT match
24
+ // and are treated as relative paths — resolved safely against the base URL.
25
+ const AUTHORITY_URL_REGEX = /^[a-zA-Z][a-zA-Z0-9.+-]*:\/\//;
26
+ // Matches any scheme-like prefix (e.g. `javascript:`, `data:`, `report:`).
27
+ // Used to detect first-segment colons that would confuse the WHATWG URL parser
28
+ // when resolving relative paths, so we can prefix them with `./`.
29
+ const SCHEME_PREFIX_REGEX = /^[a-zA-Z][a-zA-Z0-9.+-]*:/;
30
+ // Schemes that must never be used as a redirect or route destination.
31
+ // These can execute code or render arbitrary content in a browser.
32
+ const UNSAFE_SCHEME_REGEX = /^(javascript|data|vbscript):/i;
33
+ /**
34
+ * Wraps a user-provided domain resolver so it always receives the Express
35
+ * request context. `@auth0/auth0-server-js` invokes the resolver with the
36
+ * `storeOptions` passed to client methods; this SDK relies on
37
+ * `AsyncLocalStorage` instead of passing them explicitly, so when
38
+ * `storeOptions` is absent we recover it via `getRequestContext()` — the same
39
+ * fallback used by `ExpressCookieHandler`.
40
+ *
41
+ * A static string domain is returned unchanged.
42
+ */
43
+ export function wrapDomainResolver(domain) {
44
+ if (typeof domain === 'string') {
45
+ return domain;
46
+ }
47
+ return (storeOptions) => domain(storeOptions ?? getRequestContext());
48
+ }
49
+ /**
50
+ * Utility function to ensure Route URLs are created correctly when using both the root and subpath as base URL.
51
+ * Accepts a relative path or an absolute same-origin URL, such as one forwarded by a reverse proxy.
52
+ * Validates that the constructed URL has the same origin as the base URL to prevent host override attacks.
53
+ * @param url Relative path (e.g. `/auth/callback`) or absolute same-origin URL.
54
+ * @param base The base URL to use, including any subpath.
55
+ * @returns A URL object, combining the base and url.
56
+ * @throws {Error} If the input contains multiple leading slashes/backslashes or the origin does not match the base URL.
57
+ */
58
+ export function createRouteUrl(url, base) {
59
+ const baseUrl = new URL(ensureTrailingSlash(base));
60
+ if (AUTHORITY_URL_REGEX.test(url)) {
61
+ // Absolute URL with authority (https://, http://, file://, etc.).
62
+ // Resolve against the base so the subpath is validated, then check origin.
63
+ let absolute;
64
+ try {
65
+ absolute = new URL(url);
66
+ }
67
+ catch {
68
+ throw new Error(`URL is not allowed: '${url}' is not a valid URL`);
69
+ }
70
+ if (absolute.origin !== baseUrl.origin) {
71
+ throw new Error('URL is not allowed: origin does not match base URL');
72
+ }
73
+ return absolute;
74
+ }
75
+ const normalized = ensureNoLeadingSlash(url);
76
+ if (normalized !== url.replace(/^[/\\]/, '')) {
77
+ throw new Error(`Invalid route configuration: '${url}' contains multiple leading slashes or backslashes`);
78
+ }
79
+ if (UNSAFE_SCHEME_REGEX.test(normalized)) {
80
+ throw new Error(`URL is not allowed: '${url}' uses an unsafe scheme`);
81
+ }
82
+ // Prepend `./` when the normalized path starts with a scheme-like prefix
83
+ // (e.g. `report:summary`) so the WHATWG URL parser treats it as a relative
84
+ // path rather than a scheme.
85
+ const resolvable = SCHEME_PREFIX_REGEX.test(normalized) ? `./${normalized}` : normalized;
86
+ const result = new URL(resolvable, baseUrl);
87
+ if (result.origin !== baseUrl.origin) {
88
+ throw new Error('URL is not allowed: origin does not match base URL');
89
+ }
90
+ return result;
91
+ }
92
+ /**
93
+ * Validates a user-supplied redirect URL (e.g. a `returnTo` query parameter) against the application base URL.
94
+ * Accepts relative paths and absolute same-origin URLs. Rejects different-origin URLs and injection attempts.
95
+ * Never throws — returns undefined for any invalid or unsafe input.
96
+ * @param dangerousRedirect Untrusted redirect URL from user input.
97
+ * @param safeBaseUrl The base URL to check against.
98
+ * @returns A safe redirect URL, or undefined if the input is not safe.
99
+ */
100
+ export function toSafeRedirect(dangerousRedirect, safeBaseUrl) {
101
+ try {
102
+ // createRouteUrl validates origin for both absolute and relative inputs.
103
+ // Using it for both branches avoids duplicating AUTHORITY_URL_REGEX logic here
104
+ // and ensures subpath preservation for relative paths in subpath deployments.
105
+ return createRouteUrl(dangerousRedirect, safeBaseUrl).toString();
106
+ }
107
+ catch {
108
+ return undefined;
109
+ }
110
+ }
111
+ export function createServerClientInstance(options) {
112
+ const callbackPath = options.routes?.callback ?? '/auth/callback';
113
+ // Only a static string base URL yields a startup redirect_uri. In dynamic
114
+ // (undefined) or allow-list (array) mode, the login handler sets redirect_uri
115
+ // per request from the resolved base URL.
116
+ const staticAppBaseUrl = typeof options.appBaseUrl === 'string' ? options.appBaseUrl : undefined;
117
+ const redirectUri = staticAppBaseUrl
118
+ ? createRouteUrl(callbackPath, staticAppBaseUrl).toString()
119
+ : undefined;
120
+ return new ServerClient({
121
+ domain: wrapDomainResolver(options.domain),
122
+ clientId: options.clientId,
123
+ clientSecret: options.clientSecret,
124
+ clientAssertionSigningKey: options.clientAssertionSigningKey,
125
+ clientAssertionSigningAlg: options.clientAssertionSigningAlg,
126
+ authorizationParams: {
127
+ audience: options.audience,
128
+ redirect_uri: redirectUri,
129
+ },
130
+ transactionStore: new CookieTransactionStore({ secret: options.sessionSecret }, new ExpressCookieHandler()),
131
+ stateStore: options.sessionStore
132
+ ? new StatefulStateStore({
133
+ ...options.sessionConfiguration,
134
+ secret: options.sessionSecret,
135
+ store: options.sessionStore,
136
+ }, new ExpressCookieHandler())
137
+ : new StatelessStateStore({
138
+ ...options.sessionConfiguration,
139
+ secret: options.sessionSecret,
140
+ }, new ExpressCookieHandler()),
141
+ stateIdentifier: options.sessionConfiguration?.cookie?.name,
142
+ customFetch: options.customFetch,
143
+ discoveryCache: options.discoveryCache,
144
+ });
145
+ }
146
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAGvH,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D;;;;;GAKG;AACH,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7D,CAAC;AAED;;;;;GAKG;AACH,SAAS,oBAAoB,CAAC,KAAa;IACzC,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAED,mFAAmF;AACnF,iFAAiF;AACjF,4EAA4E;AAC5E,MAAM,mBAAmB,GAAG,+BAA+B,CAAC;AAE5D,2EAA2E;AAC3E,+EAA+E;AAC/E,kEAAkE;A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OAAO,IAAI,YAAY,CAAe;QACpC,MAAM,EAAE,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC;QAC1C,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,yBAAyB,EAAE,OAAO,CAAC,yBAAyB;QAC5D,yBAAyB,EAAE,OAAO,CAAC,yBAAyB;QAC5D,mBAAmB,EAAE;YACnB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,YAAY,EAAE,WAAW;SAC1B;QACD,gBAAgB,EAAE,IAAI,sBAAsB,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,aAAa,EAAE,EAAE,IAAI,oBAAoB,EAAE,CAAC;QAC3G,UAAU,EAAE,OAAO,CAAC,YAAY;YAC9B,CAAC,CAAC,IAAI,kBAAkB,CACpB;gBACE,GAAG,OAAO,CAAC,oBAAoB;gBAC/B,MAAM,EAAE,OAAO,CAAC,aAAa;gBAC7B,KAAK,EAAE,OAAO,CAAC,YAAY;aAC5B,EACD,IAAI,oBAAoB,EAAE,CAC3B;YACH,CAAC,CAAC,IAAI,mBAAmB,CACrB;gBACE,GAAG,OAAO,CAAC,oBAAoB;gBAC/B,MAAM,EAAE,OAAO,CAAC,aAAa;aAC9B,EACD,IAAI,oBAAoB,EAAE,CAC3B;QACL,eAAe,EAAE,OAAO,CAAC,oBAAoB,EAAE,MAAM,EAAE,IAAI;QAC3D,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,cAAc,EAAE,OAAO,CAAC,cAAc;KACvC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,26 +1,28 @@
1
1
  {
2
2
  "name": "@auth0/auth0-express",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.2",
4
4
  "description": "Auth0 Authentication SDK for Express Applications on JavaScript runtimes",
5
5
  "author": "Auth0",
6
6
  "license": "Apache-2.0",
7
7
  "type": "module",
8
+ "engines": {
9
+ "node": "^22.12.0 || >=24"
10
+ },
8
11
  "scripts": {
9
- "build": "tsup",
10
- "build:watch": "tsup --watch",
12
+ "build": "tsc --project tsconfig.build.json",
13
+ "build:watch": "tsc --project tsconfig.build.json --watch",
11
14
  "clean": "rm -rf ./dist",
12
15
  "lint": "eslint \"./**/*.ts*\"",
13
16
  "test": "vitest run",
14
17
  "test:ci": "vitest --watch false --coverage"
15
18
  },
16
19
  "types": "./dist/index.d.ts",
17
- "main": "./dist/index.cjs",
18
- "module": "./dist/index.js",
20
+ "main": "./dist/index.js",
19
21
  "exports": {
20
22
  ".": {
21
23
  "types": "./dist/index.d.ts",
22
- "require": "./dist/index.cjs",
23
- "import": "./dist/index.js"
24
+ "import": "./dist/index.js",
25
+ "default": "./dist/index.js"
24
26
  }
25
27
  },
26
28
  "devDependencies": {
@@ -33,13 +35,12 @@
33
35
  "express": "^5.2.1",
34
36
  "msw": "^2.12.14",
35
37
  "supertest": "^7.2.2",
36
- "tsup": "^8.5.1",
37
38
  "typescript": "~5.9.3",
38
39
  "typescript-eslint": "^8.58.0",
39
40
  "vitest": "^4.1.2"
40
41
  },
41
42
  "dependencies": {
42
- "@auth0/auth0-server-js": "^1.3.0",
43
+ "@auth0/auth0-server-js": "^1.4.0",
43
44
  "cookie-parser": "^1.4.7"
44
45
  },
45
46
  "peerDependencies": {