auth0 6.4.0 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/README.md +20 -15
  2. package/dist/cjs/index.d.ts +0 -2
  3. package/dist/cjs/index.js +0 -2
  4. package/dist/cjs/lib/errors.d.ts +0 -18
  5. package/dist/cjs/lib/errors.js +1 -25
  6. package/dist/cjs/lib/middleware/auth0-client-telemetry.d.ts +3 -7
  7. package/dist/cjs/lib/middleware/auth0-client-telemetry.js +1 -25
  8. package/dist/cjs/lib/models.d.ts +0 -24
  9. package/dist/cjs/lib/models.js +0 -53
  10. package/dist/cjs/management/Client.d.ts +5 -5
  11. package/dist/cjs/management/Client.js +28 -28
  12. package/dist/cjs/management/api/errors/GatewayTimeoutError.d.ts +5 -0
  13. package/dist/cjs/management/api/errors/GatewayTimeoutError.js +54 -0
  14. package/dist/cjs/management/api/errors/index.d.ts +1 -0
  15. package/dist/cjs/management/api/errors/index.js +1 -0
  16. package/dist/cjs/management/api/requests/requests.d.ts +112 -88
  17. package/dist/cjs/management/api/resources/experimentation/client/Client.d.ts +12 -0
  18. package/dist/cjs/management/api/resources/experimentation/client/Client.js +16 -0
  19. package/dist/cjs/management/api/resources/experimentation/exports.d.ts +3 -0
  20. package/dist/cjs/management/api/resources/experimentation/exports.js +22 -0
  21. package/dist/cjs/management/api/resources/experimentation/index.d.ts +2 -0
  22. package/dist/cjs/management/api/resources/experimentation/index.js +18 -0
  23. package/dist/cjs/management/api/resources/experimentation/resources/experiments/client/Client.d.ts +34 -0
  24. package/dist/cjs/management/api/resources/experimentation/resources/experiments/client/Client.js +131 -0
  25. package/dist/cjs/management/api/resources/experimentation/resources/experiments/client/index.js +2 -0
  26. package/dist/cjs/management/api/resources/experimentation/resources/experiments/exports.d.ts +2 -0
  27. package/dist/cjs/management/api/resources/{organizationTemplates → experimentation/resources/experiments}/exports.js +2 -2
  28. package/dist/cjs/management/api/resources/experimentation/resources/index.d.ts +1 -0
  29. package/dist/cjs/management/api/resources/experimentation/resources/index.js +37 -0
  30. package/dist/cjs/management/api/resources/guardian/client/Client.d.ts +40 -1
  31. package/dist/cjs/management/api/resources/guardian/client/Client.js +172 -0
  32. package/dist/cjs/management/api/resources/guardian/resources/factors/client/Client.d.ts +3 -0
  33. package/dist/cjs/management/api/resources/guardian/resources/factors/client/Client.js +11 -6
  34. package/dist/cjs/management/api/resources/guardian/resources/factors/resources/email/client/Client.d.ts +46 -0
  35. package/dist/cjs/management/api/resources/guardian/resources/factors/resources/email/client/Client.js +181 -0
  36. package/dist/cjs/management/api/resources/guardian/resources/factors/resources/email/client/index.js +2 -0
  37. package/dist/cjs/management/api/resources/guardian/resources/factors/resources/email/exports.d.ts +2 -0
  38. package/dist/cjs/management/api/resources/guardian/resources/factors/resources/email/exports.js +21 -0
  39. package/dist/cjs/management/api/resources/guardian/resources/factors/resources/email/index.d.ts +1 -0
  40. package/dist/cjs/{lib → management/api/resources/guardian/resources/factors/resources/email}/index.js +1 -2
  41. package/dist/cjs/management/api/resources/guardian/resources/factors/resources/index.d.ts +1 -0
  42. package/dist/cjs/management/api/resources/guardian/resources/factors/resources/index.js +2 -1
  43. package/dist/cjs/management/api/resources/guardian/resources/factors/resources/phone/client/Client.d.ts +33 -0
  44. package/dist/cjs/management/api/resources/guardian/resources/factors/resources/phone/client/Client.js +122 -0
  45. package/dist/cjs/management/api/resources/index.d.ts +1 -1
  46. package/dist/cjs/management/api/resources/index.js +2 -2
  47. package/dist/cjs/management/api/resources/organizations/client/Client.d.ts +36 -0
  48. package/dist/cjs/management/api/resources/organizations/client/Client.js +104 -0
  49. package/dist/cjs/management/api/resources/resourceServers/client/Client.d.ts +29 -0
  50. package/dist/cjs/management/api/resources/resourceServers/client/Client.js +103 -0
  51. package/dist/cjs/management/api/types/types.d.ts +226 -51
  52. package/dist/cjs/management/api/types/types.js +37 -36
  53. package/dist/cjs/management/version.d.ts +1 -1
  54. package/dist/cjs/management/version.js +1 -1
  55. package/dist/cjs/management/wrapper/ManagementClient.d.ts +9 -2
  56. package/dist/cjs/management/wrapper/ManagementClient.js +0 -1
  57. package/dist/cjs/management/wrapper/token-provider.d.ts +4 -2
  58. package/dist/cjs/management/wrapper/token-provider.js +142 -11
  59. package/dist/cjs/utils.d.ts +0 -18
  60. package/dist/cjs/utils.js +1 -32
  61. package/dist/esm/index.d.mts +0 -2
  62. package/dist/esm/index.mjs +0 -2
  63. package/dist/esm/lib/errors.d.mts +0 -18
  64. package/dist/esm/lib/errors.mjs +0 -22
  65. package/dist/esm/lib/middleware/auth0-client-telemetry.d.mts +3 -7
  66. package/dist/esm/lib/middleware/auth0-client-telemetry.mjs +1 -25
  67. package/dist/esm/lib/models.d.mts +0 -24
  68. package/dist/esm/lib/models.mjs +1 -49
  69. package/dist/esm/management/Client.d.mts +5 -5
  70. package/dist/esm/management/Client.mjs +7 -7
  71. package/dist/esm/management/api/errors/GatewayTimeoutError.d.mts +5 -0
  72. package/dist/esm/management/api/errors/GatewayTimeoutError.mjs +17 -0
  73. package/dist/esm/management/api/errors/index.d.mts +1 -0
  74. package/dist/esm/management/api/errors/index.mjs +1 -0
  75. package/dist/esm/management/api/requests/requests.d.mts +112 -88
  76. package/dist/esm/management/api/resources/experimentation/client/Client.d.mts +12 -0
  77. package/dist/esm/management/api/resources/experimentation/client/Client.mjs +12 -0
  78. package/dist/esm/management/api/resources/experimentation/client/index.d.mts +1 -0
  79. package/dist/esm/management/api/resources/experimentation/client/index.mjs +1 -0
  80. package/dist/esm/management/api/resources/experimentation/exports.d.mts +3 -0
  81. package/dist/esm/management/api/resources/experimentation/exports.mjs +4 -0
  82. package/dist/esm/management/api/resources/experimentation/index.d.mts +2 -0
  83. package/dist/esm/management/api/resources/experimentation/index.mjs +2 -0
  84. package/dist/esm/management/api/resources/experimentation/resources/experiments/client/Client.d.mts +34 -0
  85. package/dist/esm/management/api/resources/experimentation/resources/experiments/client/Client.mjs +94 -0
  86. package/dist/esm/management/api/resources/experimentation/resources/experiments/client/index.d.mts +1 -0
  87. package/dist/esm/management/api/resources/experimentation/resources/experiments/client/index.mjs +1 -0
  88. package/dist/esm/management/api/resources/experimentation/resources/experiments/exports.d.mts +2 -0
  89. package/dist/esm/management/api/resources/{organizationTemplates → experimentation/resources/experiments}/exports.mjs +1 -1
  90. package/dist/esm/management/api/resources/experimentation/resources/index.d.mts +1 -0
  91. package/dist/esm/management/api/resources/experimentation/resources/index.mjs +1 -0
  92. package/dist/esm/management/api/resources/guardian/client/Client.d.mts +40 -1
  93. package/dist/esm/management/api/resources/guardian/client/Client.mjs +139 -0
  94. package/dist/esm/management/api/resources/guardian/resources/factors/client/Client.d.mts +3 -0
  95. package/dist/esm/management/api/resources/guardian/resources/factors/client/Client.mjs +5 -0
  96. package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/client/Client.d.mts +46 -0
  97. package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/client/Client.mjs +144 -0
  98. package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/client/index.d.mts +1 -0
  99. package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/client/index.mjs +1 -0
  100. package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/exports.d.mts +2 -0
  101. package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/exports.mjs +3 -0
  102. package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/index.d.mts +1 -0
  103. package/dist/esm/management/api/resources/guardian/resources/factors/resources/email/index.mjs +1 -0
  104. package/dist/esm/management/api/resources/guardian/resources/factors/resources/index.d.mts +1 -0
  105. package/dist/esm/management/api/resources/guardian/resources/factors/resources/index.mjs +1 -0
  106. package/dist/esm/management/api/resources/guardian/resources/factors/resources/phone/client/Client.d.mts +33 -0
  107. package/dist/esm/management/api/resources/guardian/resources/factors/resources/phone/client/Client.mjs +122 -0
  108. package/dist/esm/management/api/resources/index.d.mts +1 -1
  109. package/dist/esm/management/api/resources/index.mjs +1 -1
  110. package/dist/esm/management/api/resources/organizations/client/Client.d.mts +36 -0
  111. package/dist/esm/management/api/resources/organizations/client/Client.mjs +104 -0
  112. package/dist/esm/management/api/resources/resourceServers/client/Client.d.mts +29 -0
  113. package/dist/esm/management/api/resources/resourceServers/client/Client.mjs +103 -0
  114. package/dist/esm/management/api/types/types.d.mts +226 -51
  115. package/dist/esm/management/api/types/types.mjs +34 -33
  116. package/dist/esm/management/version.d.mts +1 -1
  117. package/dist/esm/management/version.mjs +1 -1
  118. package/dist/esm/management/wrapper/ManagementClient.d.mts +9 -2
  119. package/dist/esm/management/wrapper/ManagementClient.mjs +0 -1
  120. package/dist/esm/management/wrapper/token-provider.d.mts +4 -2
  121. package/dist/esm/management/wrapper/token-provider.mjs +142 -11
  122. package/dist/esm/utils.d.mts +0 -18
  123. package/dist/esm/utils.mjs +0 -30
  124. package/package.json +45 -23
  125. package/reference.md +654 -389
  126. package/dist/cjs/auth/backchannel.d.ts +0 -158
  127. package/dist/cjs/auth/backchannel.js +0 -135
  128. package/dist/cjs/auth/base-auth-api.d.ts +0 -41
  129. package/dist/cjs/auth/base-auth-api.js +0 -109
  130. package/dist/cjs/auth/client-authentication.d.ts +0 -27
  131. package/dist/cjs/auth/client-authentication.js +0 -82
  132. package/dist/cjs/auth/database.d.ts +0 -157
  133. package/dist/cjs/auth/database.js +0 -94
  134. package/dist/cjs/auth/id-token-validator.d.ts +0 -18
  135. package/dist/cjs/auth/id-token-validator.js +0 -158
  136. package/dist/cjs/auth/index.d.ts +0 -65
  137. package/dist/cjs/auth/index.js +0 -80
  138. package/dist/cjs/auth/oauth.d.ts +0 -462
  139. package/dist/cjs/auth/oauth.js +0 -280
  140. package/dist/cjs/auth/passwordless.d.ts +0 -165
  141. package/dist/cjs/auth/passwordless.js +0 -173
  142. package/dist/cjs/auth/tokenExchange.d.ts +0 -166
  143. package/dist/cjs/auth/tokenExchange.js +0 -74
  144. package/dist/cjs/lib/index.d.ts +0 -3
  145. package/dist/cjs/lib/runtime.d.ts +0 -61
  146. package/dist/cjs/lib/runtime.js +0 -222
  147. package/dist/cjs/management/api/resources/organizationTemplates/client/Client.d.ts +0 -106
  148. package/dist/cjs/management/api/resources/organizationTemplates/client/Client.js +0 -411
  149. package/dist/cjs/management/api/resources/organizationTemplates/exports.d.ts +0 -2
  150. package/dist/cjs/userinfo/index.d.ts +0 -87
  151. package/dist/cjs/userinfo/index.js +0 -104
  152. package/dist/esm/auth/backchannel.d.mts +0 -158
  153. package/dist/esm/auth/backchannel.mjs +0 -131
  154. package/dist/esm/auth/base-auth-api.d.mts +0 -41
  155. package/dist/esm/auth/base-auth-api.mjs +0 -103
  156. package/dist/esm/auth/client-authentication.d.mts +0 -27
  157. package/dist/esm/auth/client-authentication.mjs +0 -45
  158. package/dist/esm/auth/database.d.mts +0 -157
  159. package/dist/esm/auth/database.mjs +0 -90
  160. package/dist/esm/auth/id-token-validator.d.mts +0 -18
  161. package/dist/esm/auth/id-token-validator.mjs +0 -120
  162. package/dist/esm/auth/index.d.mts +0 -65
  163. package/dist/esm/auth/index.mjs +0 -60
  164. package/dist/esm/auth/oauth.d.mts +0 -462
  165. package/dist/esm/auth/oauth.mjs +0 -276
  166. package/dist/esm/auth/passwordless.d.mts +0 -165
  167. package/dist/esm/auth/passwordless.mjs +0 -169
  168. package/dist/esm/auth/tokenExchange.d.mts +0 -166
  169. package/dist/esm/auth/tokenExchange.mjs +0 -70
  170. package/dist/esm/lib/index.d.mts +0 -3
  171. package/dist/esm/lib/index.mjs +0 -2
  172. package/dist/esm/lib/runtime.d.mts +0 -61
  173. package/dist/esm/lib/runtime.mjs +0 -201
  174. package/dist/esm/management/api/resources/organizationTemplates/client/Client.d.mts +0 -106
  175. package/dist/esm/management/api/resources/organizationTemplates/client/Client.mjs +0 -374
  176. package/dist/esm/management/api/resources/organizationTemplates/exports.d.mts +0 -2
  177. package/dist/esm/userinfo/index.d.mts +0 -87
  178. package/dist/esm/userinfo/index.mjs +0 -98
  179. /package/dist/cjs/management/api/resources/{organizationTemplates → experimentation}/client/index.d.ts +0 -0
  180. /package/dist/cjs/management/api/resources/{organizationTemplates → experimentation}/client/index.js +0 -0
  181. /package/dist/{esm/management/api/resources/organizationTemplates/client/index.d.mts → cjs/management/api/resources/experimentation/resources/experiments/client/index.d.ts} +0 -0
  182. /package/dist/cjs/management/api/resources/{organizationTemplates → experimentation/resources/experiments}/index.d.ts +0 -0
  183. /package/dist/cjs/management/api/resources/{organizationTemplates → experimentation/resources/experiments}/index.js +0 -0
  184. /package/dist/{esm/management/api/resources/organizationTemplates/client/index.mjs → cjs/management/api/resources/guardian/resources/factors/resources/email/client/index.d.ts} +0 -0
  185. /package/dist/esm/management/api/resources/{organizationTemplates → experimentation/resources/experiments}/index.d.mts +0 -0
  186. /package/dist/esm/management/api/resources/{organizationTemplates → experimentation/resources/experiments}/index.mjs +0 -0
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "6.4.0";
1
+ export declare const SDK_VERSION = "7.1.0";
@@ -1 +1 @@
1
- export const SDK_VERSION = "6.4.0";
1
+ export const SDK_VERSION = "7.1.0";
@@ -15,7 +15,7 @@ export declare namespace ManagementClient {
15
15
  * @group Management API
16
16
  * @public
17
17
  */
18
- interface ManagementClientOptions extends Omit<FernClient.Options, "token" | "environment" | "fetcher" | "baseUrl" | "fetch"> {
18
+ interface ManagementClientOptions extends Omit<FernClient.Options, "token" | "environment" | "fetcher" | "baseUrl"> {
19
19
  /** Auth0 domain (e.g., 'your-tenant.auth0.com') */
20
20
  domain: string;
21
21
  /**
@@ -114,7 +114,14 @@ export declare namespace ManagementClient {
114
114
  clientAssertionSigningKey: string;
115
115
  /** Algorithm for signing the client assertion. Defaults to RS256 */
116
116
  clientAssertionSigningAlg?: string;
117
- /** Enable mTLS for token endpoint calls */
117
+ /**
118
+ * Enable mTLS for token endpoint calls.
119
+ *
120
+ * mTLS (RFC 8705) is a transport-layer concern that is independent of the client
121
+ * authentication method: a client authenticating with `private_key_jwt` can still present a
122
+ * TLS client certificate to obtain a certificate-bound access token. This mirrors v6, which
123
+ * added the `mtls.` endpoint alias from `useMTLS` alone regardless of the auth method.
124
+ */
118
125
  useMTLS?: boolean;
119
126
  }
120
127
  /**
@@ -71,7 +71,6 @@ export class ManagementClient extends FernClient {
71
71
  const token = createTokenSupplier(_options);
72
72
  // Temporarily remove fetcher from options to avoid people passing it for now
73
73
  delete _options.fetcher;
74
- delete _options.fetch;
75
74
  // Prepare the base client options
76
75
  let clientOptions = Object.assign(Object.assign({}, _options), { baseUrl,
77
76
  headers,
@@ -1,7 +1,6 @@
1
- import { ManagementClient } from "./ManagementClient.mjs";
1
+ import type { ManagementClient } from "./ManagementClient.mjs";
2
2
  export declare class TokenProvider {
3
3
  private readonly options;
4
- private authenticationClient;
5
4
  private expiresAt;
6
5
  private accessToken;
7
6
  private pending;
@@ -12,4 +11,7 @@ export declare class TokenProvider {
12
11
  audience: string;
13
12
  });
14
13
  getAccessToken(): Promise<string>;
14
+ private fetchToken;
15
+ private buildClientAssertion;
16
+ private buildTelemetryHeader;
15
17
  }
@@ -7,30 +7,161 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { AuthenticationClient } from "../../auth/index.mjs";
11
- const LEEWAY = 10 * 1000;
10
+ import { base64url, importPKCS8, SignJWT } from "jose";
11
+ import { generateClientInfo } from "../../utils.mjs";
12
+ import { ManagementError } from "../errors/ManagementError.mjs";
13
+ const LEEWAY = 10 * 1000; // 10s refresh-ahead in ms
12
14
  export class TokenProvider {
13
15
  constructor(options) {
14
16
  this.options = options;
15
17
  this.expiresAt = 0;
16
18
  this.accessToken = "";
17
- this.authenticationClient = new AuthenticationClient(Object.assign(Object.assign({}, options), { headers: options.headers }));
19
+ // Validate domain: must be a bare hostname, no slashes or query strings.
20
+ if (/[/?#]/.test(options.domain)) {
21
+ throw new Error(`ManagementClient: invalid domain "${options.domain}". Provide a bare hostname, e.g. "tenant.auth0.com".`);
22
+ }
23
+ if (options.useMTLS) {
24
+ const { fetch: customFetch } = options;
25
+ if (!customFetch) {
26
+ throw new Error("ManagementClient: useMTLS requires a custom fetch implementation. " +
27
+ "Provide a `fetch` option configured with your mTLS client certificate.");
28
+ }
29
+ // mTLS (RFC 8705) is a transport-layer concern independent of the client authentication
30
+ // method. It combines with both `clientSecret` and `clientAssertionSigningKey`: the TLS
31
+ // client certificate yields a certificate-bound token regardless of how the client
32
+ // authenticates. v6 supported this, so no auth-method restriction is imposed here.
33
+ }
18
34
  }
19
35
  getAccessToken() {
20
36
  return __awaiter(this, void 0, void 0, function* () {
21
37
  if (!this.accessToken || Date.now() > this.expiresAt - LEEWAY) {
22
- this.pending =
23
- this.pending ||
24
- this.authenticationClient.oauth.clientCredentialsGrant({
25
- audience: this.options.audience,
26
- });
27
- const { data: { access_token: accessToken, expires_in: expiresIn }, } = yield this.pending.finally(() => {
38
+ this.pending = this.pending || this.fetchToken();
39
+ const result = yield this.pending.finally(() => {
28
40
  delete this.pending;
29
41
  });
30
- this.expiresAt = Date.now() + expiresIn * 1000;
31
- this.accessToken = accessToken;
42
+ this.expiresAt = result.expiresAt;
43
+ this.accessToken = result.accessToken;
32
44
  }
33
45
  return this.accessToken;
34
46
  });
35
47
  }
48
+ fetchToken() {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ var _a;
51
+ const { domain, clientId, audience } = this.options;
52
+ const tokenUrl = this.options.useMTLS ? `https://mtls.${domain}/oauth/token` : `https://${domain}/oauth/token`;
53
+ const body = new URLSearchParams({
54
+ grant_type: "client_credentials",
55
+ client_id: clientId,
56
+ audience,
57
+ });
58
+ if ("clientSecret" in this.options) {
59
+ body.set("client_secret", this.options.clientSecret);
60
+ }
61
+ else if ("clientAssertionSigningKey" in this.options) {
62
+ const assertion = yield this.buildClientAssertion(domain, clientId);
63
+ body.set("client_assertion", assertion);
64
+ body.set("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer");
65
+ }
66
+ // Build request headers. Start with user-supplied plain-string headers so they can be
67
+ // overridden by SDK-controlled values (Content-Type, Auth0-Client) set below.
68
+ // Supplier-function headers (Fern's Supplier<string | null | undefined> type) are skipped —
69
+ // they require async resolution and are not supported on the token endpoint path.
70
+ const userHeaders = (_a = this.options.headers) !== null && _a !== void 0 ? _a : {};
71
+ const headers = {};
72
+ for (const [key, value] of Object.entries(userHeaders)) {
73
+ if (typeof value === "string") {
74
+ headers[key.toLowerCase()] = value;
75
+ }
76
+ }
77
+ headers["content-type"] = "application/x-www-form-urlencoded";
78
+ const telemetryHeader = this.buildTelemetryHeader();
79
+ if (telemetryHeader) {
80
+ headers["auth0-client"] = telemetryHeader;
81
+ }
82
+ // Use custom fetch for mTLS, else global fetch.
83
+ // `fetch` is defined on BaseClientOptions (src/management/BaseClient.ts) which is Fern-generated.
84
+ // If that file is regenerated, verify `fetch?: typeof fetch` is still present — token acquisition
85
+ // for mTLS depends on it being forwarded here.
86
+ const { fetch: customFetch } = this.options;
87
+ const fetcher = customFetch !== null && customFetch !== void 0 ? customFetch : fetch;
88
+ let response;
89
+ try {
90
+ response = yield fetcher(tokenUrl, {
91
+ method: "POST",
92
+ headers,
93
+ body: body.toString(),
94
+ signal: AbortSignal.timeout(10000),
95
+ });
96
+ }
97
+ catch (err) {
98
+ // Built-in fetch aborts with a "TimeoutError"; node-fetch (used on the mTLS path with a
99
+ // custom fetch) aborts with an "AbortError". Match both so a token-request timeout maps
100
+ // to a 408 regardless of the underlying fetch implementation.
101
+ if (err instanceof Error && (err.name === "TimeoutError" || err.name === "AbortError")) {
102
+ throw new ManagementError({
103
+ message: "ManagementClient: token request timed out",
104
+ statusCode: 408,
105
+ });
106
+ }
107
+ throw err;
108
+ }
109
+ if (!response.ok) {
110
+ // Read the body exactly once. `response.json()` followed by `response.text()` throws
111
+ // "Body has already been read", which would swallow non-JSON error payloads (e.g. proxy
112
+ // or WAF 502s). Read text, then attempt to parse it as JSON.
113
+ const raw = yield response.text().catch(() => "");
114
+ let errorBody;
115
+ try {
116
+ errorBody = raw ? JSON.parse(raw) : response.statusText;
117
+ }
118
+ catch (_b) {
119
+ errorBody = raw || response.statusText;
120
+ }
121
+ throw new ManagementError({
122
+ message: "ManagementClient: token request failed",
123
+ statusCode: response.status,
124
+ body: errorBody,
125
+ });
126
+ }
127
+ const json = (yield response.json());
128
+ return {
129
+ accessToken: json.access_token,
130
+ expiresAt: Date.now() + json.expires_in * 1000,
131
+ };
132
+ });
133
+ }
134
+ buildClientAssertion(domain, clientId) {
135
+ return __awaiter(this, void 0, void 0, function* () {
136
+ const { clientAssertionSigningKey, clientAssertionSigningAlg = "RS256" } = this
137
+ .options;
138
+ const key = yield importPKCS8(clientAssertionSigningKey, clientAssertionSigningAlg);
139
+ const now = Math.floor(Date.now() / 1000);
140
+ return new SignJWT({})
141
+ .setProtectedHeader({ alg: clientAssertionSigningAlg })
142
+ .setIssuedAt(now)
143
+ .setIssuer(clientId)
144
+ .setSubject(clientId)
145
+ .setAudience(`https://${domain}/`)
146
+ .setExpirationTime(now + 180) // 3 min lifetime
147
+ .setJti(crypto.randomUUID())
148
+ .sign(key);
149
+ });
150
+ }
151
+ buildTelemetryHeader() {
152
+ var _a;
153
+ const opts = this.options;
154
+ if (opts.telemetry === false)
155
+ return null;
156
+ const nodeAuth0Info = generateClientInfo();
157
+ const info = opts.clientInfo
158
+ ? { name: opts.clientInfo.name, version: String((_a = opts.clientInfo.version) !== null && _a !== void 0 ? _a : nodeAuth0Info.version) }
159
+ : { name: nodeAuth0Info.name, version: nodeAuth0Info.version };
160
+ // NOTE: auth0-auth-js TelemetryConfig does not support env fields.
161
+ // The runtime fingerprint (env.node / env.cloudflare-workers) present in the
162
+ // original node-auth0 Auth0-Client header is intentionally omitted here.
163
+ // This is a known, accepted delta vs the pre-v7 token request telemetry shape.
164
+ // Use jose's base64url encoder for runtime portability (Buffer is Node-only).
165
+ return base64url.encode(new TextEncoder().encode(JSON.stringify(info)));
166
+ }
36
167
  }
@@ -5,21 +5,3 @@ export declare const generateClientInfo: () => {
5
5
  [x: string]: string;
6
6
  };
7
7
  };
8
- /**
9
- * @private
10
- */
11
- export declare const mtlsPrefix = "mtls";
12
- type SyncGetter<T> = () => T;
13
- type AsyncGetter<T> = () => Promise<T>;
14
- /**
15
- * Resolves a value that can be a static value, a synchronous function, or an asynchronous function.
16
- *
17
- * @template T - The type of the value to be resolved.
18
- * @param {T | SyncGetter<T> | AsyncGetter<T>} value - The value to be resolved. It can be:
19
- * - A static value of type T.
20
- * - A synchronous function that returns a value of type T.
21
- * - An asynchronous function that returns a Promise of type T.
22
- * @returns {Promise<T>} A promise that resolves to the value of type T.
23
- */
24
- export declare const resolveValueToPromise: <T>(value: T | SyncGetter<T> | AsyncGetter<T>) => Promise<T>;
25
- export {};
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { SDK_VERSION as version } from "./management/version.mjs";
11
2
  import { RUNTIME } from "./management/core/index.mjs";
12
3
  export const generateClientInfo = () => {
@@ -22,24 +13,3 @@ export const generateClientInfo = () => {
22
13
  },
23
14
  };
24
15
  };
25
- /**
26
- * @private
27
- */
28
- export const mtlsPrefix = "mtls";
29
- /**
30
- * Resolves a value that can be a static value, a synchronous function, or an asynchronous function.
31
- *
32
- * @template T - The type of the value to be resolved.
33
- * @param {T | SyncGetter<T> | AsyncGetter<T>} value - The value to be resolved. It can be:
34
- * - A static value of type T.
35
- * - A synchronous function that returns a value of type T.
36
- * - An asynchronous function that returns a Promise of type T.
37
- * @returns {Promise<T>} A promise that resolves to the value of type T.
38
- */
39
- export const resolveValueToPromise = (value) => __awaiter(void 0, void 0, void 0, function* () {
40
- if (typeof value === "function") {
41
- const result = value(); // Call the function
42
- return result instanceof Promise ? result : Promise.resolve(result); // Handle sync/async
43
- }
44
- return Promise.resolve(value); // Static value
45
- });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auth0",
3
- "version": "6.4.0",
3
+ "version": "7.1.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -199,6 +199,17 @@
199
199
  },
200
200
  "default": "./dist/cjs/management/api/resources/groups/exports.js"
201
201
  },
202
+ "./guardian": {
203
+ "import": {
204
+ "types": "./dist/esm/management/api/resources/guardian/exports.d.mts",
205
+ "default": "./dist/esm/management/api/resources/guardian/exports.mjs"
206
+ },
207
+ "require": {
208
+ "types": "./dist/cjs/management/api/resources/guardian/exports.d.ts",
209
+ "default": "./dist/cjs/management/api/resources/guardian/exports.js"
210
+ },
211
+ "default": "./dist/cjs/management/api/resources/guardian/exports.js"
212
+ },
202
213
  "./hooks": {
203
214
  "import": {
204
215
  "types": "./dist/esm/management/api/resources/hooks/exports.d.mts",
@@ -254,17 +265,6 @@
254
265
  },
255
266
  "default": "./dist/cjs/management/api/resources/networkAcls/exports.js"
256
267
  },
257
- "./organizationTemplates": {
258
- "import": {
259
- "types": "./dist/esm/management/api/resources/organizationTemplates/exports.d.mts",
260
- "default": "./dist/esm/management/api/resources/organizationTemplates/exports.mjs"
261
- },
262
- "require": {
263
- "types": "./dist/cjs/management/api/resources/organizationTemplates/exports.d.ts",
264
- "default": "./dist/cjs/management/api/resources/organizationTemplates/exports.js"
265
- },
266
- "default": "./dist/cjs/management/api/resources/organizationTemplates/exports.js"
267
- },
268
268
  "./organizations": {
269
269
  "import": {
270
270
  "types": "./dist/esm/management/api/resources/organizations/exports.d.mts",
@@ -826,6 +826,28 @@
826
826
  },
827
827
  "default": "./dist/cjs/management/api/resources/eventStreams/resources/redeliveries/exports.js"
828
828
  },
829
+ "./experimentation": {
830
+ "import": {
831
+ "types": "./dist/esm/management/api/resources/experimentation/exports.d.mts",
832
+ "default": "./dist/esm/management/api/resources/experimentation/exports.mjs"
833
+ },
834
+ "require": {
835
+ "types": "./dist/cjs/management/api/resources/experimentation/exports.d.ts",
836
+ "default": "./dist/cjs/management/api/resources/experimentation/exports.js"
837
+ },
838
+ "default": "./dist/cjs/management/api/resources/experimentation/exports.js"
839
+ },
840
+ "./experimentation/experiments": {
841
+ "import": {
842
+ "types": "./dist/esm/management/api/resources/experimentation/resources/experiments/exports.d.mts",
843
+ "default": "./dist/esm/management/api/resources/experimentation/resources/experiments/exports.mjs"
844
+ },
845
+ "require": {
846
+ "types": "./dist/cjs/management/api/resources/experimentation/resources/experiments/exports.d.ts",
847
+ "default": "./dist/cjs/management/api/resources/experimentation/resources/experiments/exports.js"
848
+ },
849
+ "default": "./dist/cjs/management/api/resources/experimentation/resources/experiments/exports.js"
850
+ },
829
851
  "./flows/executions": {
830
852
  "import": {
831
853
  "types": "./dist/esm/management/api/resources/flows/resources/executions/exports.d.mts",
@@ -881,17 +903,6 @@
881
903
  },
882
904
  "default": "./dist/cjs/management/api/resources/groups/resources/roles/exports.js"
883
905
  },
884
- "./guardian": {
885
- "import": {
886
- "types": "./dist/esm/management/api/resources/guardian/exports.d.mts",
887
- "default": "./dist/esm/management/api/resources/guardian/exports.mjs"
888
- },
889
- "require": {
890
- "types": "./dist/cjs/management/api/resources/guardian/exports.d.ts",
891
- "default": "./dist/cjs/management/api/resources/guardian/exports.js"
892
- },
893
- "default": "./dist/cjs/management/api/resources/guardian/exports.js"
894
- },
895
906
  "./guardian/enrollments": {
896
907
  "import": {
897
908
  "types": "./dist/esm/management/api/resources/guardian/resources/enrollments/exports.d.mts",
@@ -925,6 +936,17 @@
925
936
  },
926
937
  "default": "./dist/cjs/management/api/resources/guardian/resources/policies/exports.js"
927
938
  },
939
+ "./guardian/factors/email": {
940
+ "import": {
941
+ "types": "./dist/esm/management/api/resources/guardian/resources/factors/resources/email/exports.d.mts",
942
+ "default": "./dist/esm/management/api/resources/guardian/resources/factors/resources/email/exports.mjs"
943
+ },
944
+ "require": {
945
+ "types": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/email/exports.d.ts",
946
+ "default": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/email/exports.js"
947
+ },
948
+ "default": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/email/exports.js"
949
+ },
928
950
  "./guardian/factors/phone": {
929
951
  "import": {
930
952
  "types": "./dist/esm/management/api/resources/guardian/resources/factors/resources/phone/exports.d.mts",