auth0 6.3.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -15
- package/dist/cjs/index.d.ts +0 -2
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/lib/errors.d.ts +0 -18
- package/dist/cjs/lib/errors.js +1 -25
- package/dist/cjs/lib/middleware/auth0-client-telemetry.d.ts +3 -7
- package/dist/cjs/lib/middleware/auth0-client-telemetry.js +1 -25
- package/dist/cjs/lib/models.d.ts +0 -24
- package/dist/cjs/lib/models.js +0 -53
- package/dist/cjs/management/Client.d.ts +3 -0
- package/dist/cjs/management/Client.js +45 -40
- package/dist/cjs/management/api/errors/UnprocessableEntityError.d.ts +5 -0
- package/dist/cjs/management/api/errors/UnprocessableEntityError.js +54 -0
- package/dist/cjs/management/api/errors/index.d.ts +1 -0
- package/dist/cjs/management/api/errors/index.js +1 -0
- package/dist/cjs/management/api/requests/requests.d.ts +91 -0
- package/dist/cjs/management/api/resources/connections/client/Client.d.ts +2 -0
- package/dist/cjs/management/api/resources/connections/client/Client.js +6 -0
- package/dist/cjs/management/api/resources/connections/resources/scimConfiguration/client/Client.d.ts +1 -0
- package/dist/cjs/management/api/resources/connections/resources/scimConfiguration/client/Client.js +3 -0
- package/dist/cjs/management/api/resources/index.d.ts +1 -0
- package/dist/cjs/management/api/resources/index.js +2 -1
- package/dist/cjs/management/api/resources/keys/resources/networkAcls/client/Client.d.ts +17 -0
- package/dist/cjs/management/api/resources/keys/resources/networkAcls/client/Client.js +60 -0
- package/dist/cjs/management/api/resources/organizationTemplates/client/Client.d.ts +106 -0
- package/dist/cjs/management/api/resources/organizationTemplates/client/Client.js +411 -0
- package/dist/cjs/management/api/resources/organizationTemplates/client/index.d.ts +1 -0
- package/dist/cjs/management/api/resources/organizationTemplates/client/index.js +2 -0
- package/dist/cjs/management/api/resources/organizationTemplates/exports.d.ts +2 -0
- package/dist/cjs/management/api/resources/organizationTemplates/exports.js +21 -0
- package/dist/cjs/management/api/resources/organizationTemplates/index.d.ts +1 -0
- package/dist/cjs/{lib → management/api/resources/organizationTemplates}/index.js +1 -2
- package/dist/cjs/management/api/resources/organizations/client/Client.d.ts +3 -0
- package/dist/cjs/management/api/resources/organizations/client/Client.js +7 -2
- package/dist/cjs/management/api/resources/organizations/resources/index.d.ts +1 -0
- package/dist/cjs/management/api/resources/organizations/resources/index.js +2 -1
- package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/client/Client.d.ts +63 -0
- package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/client/Client.js +232 -0
- package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/client/index.d.ts +1 -0
- package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/client/index.js +2 -0
- package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/exports.d.ts +2 -0
- package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/exports.js +21 -0
- package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/index.d.ts +1 -0
- package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/index.js +17 -0
- package/dist/cjs/management/api/resources/users/resources/organizations/client/Client.d.ts +17 -0
- package/dist/cjs/management/api/resources/users/resources/organizations/client/Client.js +19 -0
- package/dist/cjs/management/api/types/types.d.ts +8896 -2027
- package/dist/cjs/management/api/types/types.js +1455 -166
- package/dist/cjs/management/version.d.ts +1 -1
- package/dist/cjs/management/version.js +1 -1
- package/dist/cjs/management/wrapper/ManagementClient.d.ts +9 -2
- package/dist/cjs/management/wrapper/ManagementClient.js +0 -1
- package/dist/cjs/management/wrapper/token-provider.d.ts +4 -2
- package/dist/cjs/management/wrapper/token-provider.js +142 -11
- package/dist/cjs/utils.d.ts +0 -18
- package/dist/cjs/utils.js +1 -32
- package/dist/esm/index.d.mts +0 -2
- package/dist/esm/index.mjs +0 -2
- package/dist/esm/lib/errors.d.mts +0 -18
- package/dist/esm/lib/errors.mjs +0 -22
- package/dist/esm/lib/middleware/auth0-client-telemetry.d.mts +3 -7
- package/dist/esm/lib/middleware/auth0-client-telemetry.mjs +1 -25
- package/dist/esm/lib/models.d.mts +0 -24
- package/dist/esm/lib/models.mjs +1 -49
- package/dist/esm/management/Client.d.mts +3 -0
- package/dist/esm/management/Client.mjs +5 -0
- package/dist/esm/management/api/errors/UnprocessableEntityError.d.mts +5 -0
- package/dist/esm/management/api/errors/UnprocessableEntityError.mjs +17 -0
- package/dist/esm/management/api/errors/index.d.mts +1 -0
- package/dist/esm/management/api/errors/index.mjs +1 -0
- package/dist/esm/management/api/requests/requests.d.mts +91 -0
- package/dist/esm/management/api/resources/connections/client/Client.d.mts +2 -0
- package/dist/esm/management/api/resources/connections/client/Client.mjs +6 -0
- package/dist/esm/management/api/resources/connections/resources/scimConfiguration/client/Client.d.mts +1 -0
- package/dist/esm/management/api/resources/connections/resources/scimConfiguration/client/Client.mjs +3 -0
- package/dist/esm/management/api/resources/index.d.mts +1 -0
- package/dist/esm/management/api/resources/index.mjs +1 -0
- package/dist/esm/management/api/resources/keys/resources/networkAcls/client/Client.d.mts +17 -0
- package/dist/esm/management/api/resources/keys/resources/networkAcls/client/Client.mjs +60 -0
- package/dist/esm/management/api/resources/organizationTemplates/client/Client.d.mts +106 -0
- package/dist/esm/management/api/resources/organizationTemplates/client/Client.mjs +374 -0
- package/dist/esm/management/api/resources/organizationTemplates/client/index.d.mts +1 -0
- package/dist/esm/management/api/resources/organizationTemplates/client/index.mjs +1 -0
- package/dist/esm/management/api/resources/organizationTemplates/exports.d.mts +2 -0
- package/dist/esm/management/api/resources/organizationTemplates/exports.mjs +3 -0
- package/dist/esm/management/api/resources/organizationTemplates/index.d.mts +1 -0
- package/dist/esm/management/api/resources/organizationTemplates/index.mjs +1 -0
- package/dist/esm/management/api/resources/organizations/client/Client.d.mts +3 -0
- package/dist/esm/management/api/resources/organizations/client/Client.mjs +5 -0
- package/dist/esm/management/api/resources/organizations/resources/index.d.mts +1 -0
- package/dist/esm/management/api/resources/organizations/resources/index.mjs +1 -0
- package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/client/Client.d.mts +63 -0
- package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/client/Client.mjs +195 -0
- package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/client/index.d.mts +1 -0
- package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/client/index.mjs +1 -0
- package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/exports.d.mts +2 -0
- package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/exports.mjs +3 -0
- package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/index.d.mts +1 -0
- package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/index.mjs +1 -0
- package/dist/esm/management/api/resources/users/resources/organizations/client/Client.d.mts +17 -0
- package/dist/esm/management/api/resources/users/resources/organizations/client/Client.mjs +19 -0
- package/dist/esm/management/api/types/types.d.mts +8896 -2027
- package/dist/esm/management/api/types/types.mjs +1434 -150
- package/dist/esm/management/version.d.mts +1 -1
- package/dist/esm/management/version.mjs +1 -1
- package/dist/esm/management/wrapper/ManagementClient.d.mts +9 -2
- package/dist/esm/management/wrapper/ManagementClient.mjs +0 -1
- package/dist/esm/management/wrapper/token-provider.d.mts +4 -2
- package/dist/esm/management/wrapper/token-provider.mjs +142 -11
- package/dist/esm/utils.d.mts +0 -18
- package/dist/esm/utils.mjs +0 -30
- package/package.json +23 -2
- package/reference.md +688 -28
- package/dist/cjs/auth/backchannel.d.ts +0 -158
- package/dist/cjs/auth/backchannel.js +0 -135
- package/dist/cjs/auth/base-auth-api.d.ts +0 -41
- package/dist/cjs/auth/base-auth-api.js +0 -109
- package/dist/cjs/auth/client-authentication.d.ts +0 -27
- package/dist/cjs/auth/client-authentication.js +0 -82
- package/dist/cjs/auth/database.d.ts +0 -157
- package/dist/cjs/auth/database.js +0 -94
- package/dist/cjs/auth/id-token-validator.d.ts +0 -18
- package/dist/cjs/auth/id-token-validator.js +0 -158
- package/dist/cjs/auth/index.d.ts +0 -65
- package/dist/cjs/auth/index.js +0 -80
- package/dist/cjs/auth/oauth.d.ts +0 -462
- package/dist/cjs/auth/oauth.js +0 -280
- package/dist/cjs/auth/passwordless.d.ts +0 -165
- package/dist/cjs/auth/passwordless.js +0 -173
- package/dist/cjs/auth/tokenExchange.d.ts +0 -166
- package/dist/cjs/auth/tokenExchange.js +0 -74
- package/dist/cjs/lib/index.d.ts +0 -3
- package/dist/cjs/lib/runtime.d.ts +0 -61
- package/dist/cjs/lib/runtime.js +0 -222
- package/dist/cjs/userinfo/index.d.ts +0 -87
- package/dist/cjs/userinfo/index.js +0 -104
- package/dist/esm/auth/backchannel.d.mts +0 -158
- package/dist/esm/auth/backchannel.mjs +0 -131
- package/dist/esm/auth/base-auth-api.d.mts +0 -41
- package/dist/esm/auth/base-auth-api.mjs +0 -103
- package/dist/esm/auth/client-authentication.d.mts +0 -27
- package/dist/esm/auth/client-authentication.mjs +0 -45
- package/dist/esm/auth/database.d.mts +0 -157
- package/dist/esm/auth/database.mjs +0 -90
- package/dist/esm/auth/id-token-validator.d.mts +0 -18
- package/dist/esm/auth/id-token-validator.mjs +0 -120
- package/dist/esm/auth/index.d.mts +0 -65
- package/dist/esm/auth/index.mjs +0 -60
- package/dist/esm/auth/oauth.d.mts +0 -462
- package/dist/esm/auth/oauth.mjs +0 -276
- package/dist/esm/auth/passwordless.d.mts +0 -165
- package/dist/esm/auth/passwordless.mjs +0 -169
- package/dist/esm/auth/tokenExchange.d.mts +0 -166
- package/dist/esm/auth/tokenExchange.mjs +0 -70
- package/dist/esm/lib/index.d.mts +0 -3
- package/dist/esm/lib/index.mjs +0 -2
- package/dist/esm/lib/runtime.d.mts +0 -61
- package/dist/esm/lib/runtime.mjs +0 -201
- package/dist/esm/userinfo/index.d.mts +0 -87
- package/dist/esm/userinfo/index.mjs +0 -98
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "
|
|
1
|
+
export declare const SDK_VERSION = "7.0.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"
|
|
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
|
-
/**
|
|
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
|
/**
|
|
@@ -74,7 +74,6 @@ class ManagementClient extends Client_js_1.ManagementClient {
|
|
|
74
74
|
const token = (0, auth_helpers_js_1.createTokenSupplier)(_options);
|
|
75
75
|
// Temporarily remove fetcher from options to avoid people passing it for now
|
|
76
76
|
delete _options.fetcher;
|
|
77
|
-
delete _options.fetch;
|
|
78
77
|
// Prepare the base client options
|
|
79
78
|
let clientOptions = Object.assign(Object.assign({}, _options), { baseUrl,
|
|
80
79
|
headers,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ManagementClient } from "./ManagementClient.js";
|
|
1
|
+
import type { ManagementClient } from "./ManagementClient.js";
|
|
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
|
}
|
|
@@ -10,31 +10,162 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.TokenProvider = void 0;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
13
|
+
const jose_1 = require("jose");
|
|
14
|
+
const utils_js_1 = require("../../utils.js");
|
|
15
|
+
const ManagementError_js_1 = require("../errors/ManagementError.js");
|
|
16
|
+
const LEEWAY = 10 * 1000; // 10s refresh-ahead in ms
|
|
15
17
|
class TokenProvider {
|
|
16
18
|
constructor(options) {
|
|
17
19
|
this.options = options;
|
|
18
20
|
this.expiresAt = 0;
|
|
19
21
|
this.accessToken = "";
|
|
20
|
-
|
|
22
|
+
// Validate domain: must be a bare hostname, no slashes or query strings.
|
|
23
|
+
if (/[/?#]/.test(options.domain)) {
|
|
24
|
+
throw new Error(`ManagementClient: invalid domain "${options.domain}". Provide a bare hostname, e.g. "tenant.auth0.com".`);
|
|
25
|
+
}
|
|
26
|
+
if (options.useMTLS) {
|
|
27
|
+
const { fetch: customFetch } = options;
|
|
28
|
+
if (!customFetch) {
|
|
29
|
+
throw new Error("ManagementClient: useMTLS requires a custom fetch implementation. " +
|
|
30
|
+
"Provide a `fetch` option configured with your mTLS client certificate.");
|
|
31
|
+
}
|
|
32
|
+
// mTLS (RFC 8705) is a transport-layer concern independent of the client authentication
|
|
33
|
+
// method. It combines with both `clientSecret` and `clientAssertionSigningKey`: the TLS
|
|
34
|
+
// client certificate yields a certificate-bound token regardless of how the client
|
|
35
|
+
// authenticates. v6 supported this, so no auth-method restriction is imposed here.
|
|
36
|
+
}
|
|
21
37
|
}
|
|
22
38
|
getAccessToken() {
|
|
23
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
40
|
if (!this.accessToken || Date.now() > this.expiresAt - LEEWAY) {
|
|
25
|
-
this.pending =
|
|
26
|
-
|
|
27
|
-
this.authenticationClient.oauth.clientCredentialsGrant({
|
|
28
|
-
audience: this.options.audience,
|
|
29
|
-
});
|
|
30
|
-
const { data: { access_token: accessToken, expires_in: expiresIn }, } = yield this.pending.finally(() => {
|
|
41
|
+
this.pending = this.pending || this.fetchToken();
|
|
42
|
+
const result = yield this.pending.finally(() => {
|
|
31
43
|
delete this.pending;
|
|
32
44
|
});
|
|
33
|
-
this.expiresAt =
|
|
34
|
-
this.accessToken = accessToken;
|
|
45
|
+
this.expiresAt = result.expiresAt;
|
|
46
|
+
this.accessToken = result.accessToken;
|
|
35
47
|
}
|
|
36
48
|
return this.accessToken;
|
|
37
49
|
});
|
|
38
50
|
}
|
|
51
|
+
fetchToken() {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
var _a;
|
|
54
|
+
const { domain, clientId, audience } = this.options;
|
|
55
|
+
const tokenUrl = this.options.useMTLS ? `https://mtls.${domain}/oauth/token` : `https://${domain}/oauth/token`;
|
|
56
|
+
const body = new URLSearchParams({
|
|
57
|
+
grant_type: "client_credentials",
|
|
58
|
+
client_id: clientId,
|
|
59
|
+
audience,
|
|
60
|
+
});
|
|
61
|
+
if ("clientSecret" in this.options) {
|
|
62
|
+
body.set("client_secret", this.options.clientSecret);
|
|
63
|
+
}
|
|
64
|
+
else if ("clientAssertionSigningKey" in this.options) {
|
|
65
|
+
const assertion = yield this.buildClientAssertion(domain, clientId);
|
|
66
|
+
body.set("client_assertion", assertion);
|
|
67
|
+
body.set("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer");
|
|
68
|
+
}
|
|
69
|
+
// Build request headers. Start with user-supplied plain-string headers so they can be
|
|
70
|
+
// overridden by SDK-controlled values (Content-Type, Auth0-Client) set below.
|
|
71
|
+
// Supplier-function headers (Fern's Supplier<string | null | undefined> type) are skipped —
|
|
72
|
+
// they require async resolution and are not supported on the token endpoint path.
|
|
73
|
+
const userHeaders = (_a = this.options.headers) !== null && _a !== void 0 ? _a : {};
|
|
74
|
+
const headers = {};
|
|
75
|
+
for (const [key, value] of Object.entries(userHeaders)) {
|
|
76
|
+
if (typeof value === "string") {
|
|
77
|
+
headers[key.toLowerCase()] = value;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
headers["content-type"] = "application/x-www-form-urlencoded";
|
|
81
|
+
const telemetryHeader = this.buildTelemetryHeader();
|
|
82
|
+
if (telemetryHeader) {
|
|
83
|
+
headers["auth0-client"] = telemetryHeader;
|
|
84
|
+
}
|
|
85
|
+
// Use custom fetch for mTLS, else global fetch.
|
|
86
|
+
// `fetch` is defined on BaseClientOptions (src/management/BaseClient.ts) which is Fern-generated.
|
|
87
|
+
// If that file is regenerated, verify `fetch?: typeof fetch` is still present — token acquisition
|
|
88
|
+
// for mTLS depends on it being forwarded here.
|
|
89
|
+
const { fetch: customFetch } = this.options;
|
|
90
|
+
const fetcher = customFetch !== null && customFetch !== void 0 ? customFetch : fetch;
|
|
91
|
+
let response;
|
|
92
|
+
try {
|
|
93
|
+
response = yield fetcher(tokenUrl, {
|
|
94
|
+
method: "POST",
|
|
95
|
+
headers,
|
|
96
|
+
body: body.toString(),
|
|
97
|
+
signal: AbortSignal.timeout(10000),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
// Built-in fetch aborts with a "TimeoutError"; node-fetch (used on the mTLS path with a
|
|
102
|
+
// custom fetch) aborts with an "AbortError". Match both so a token-request timeout maps
|
|
103
|
+
// to a 408 regardless of the underlying fetch implementation.
|
|
104
|
+
if (err instanceof Error && (err.name === "TimeoutError" || err.name === "AbortError")) {
|
|
105
|
+
throw new ManagementError_js_1.ManagementError({
|
|
106
|
+
message: "ManagementClient: token request timed out",
|
|
107
|
+
statusCode: 408,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
if (!response.ok) {
|
|
113
|
+
// Read the body exactly once. `response.json()` followed by `response.text()` throws
|
|
114
|
+
// "Body has already been read", which would swallow non-JSON error payloads (e.g. proxy
|
|
115
|
+
// or WAF 502s). Read text, then attempt to parse it as JSON.
|
|
116
|
+
const raw = yield response.text().catch(() => "");
|
|
117
|
+
let errorBody;
|
|
118
|
+
try {
|
|
119
|
+
errorBody = raw ? JSON.parse(raw) : response.statusText;
|
|
120
|
+
}
|
|
121
|
+
catch (_b) {
|
|
122
|
+
errorBody = raw || response.statusText;
|
|
123
|
+
}
|
|
124
|
+
throw new ManagementError_js_1.ManagementError({
|
|
125
|
+
message: "ManagementClient: token request failed",
|
|
126
|
+
statusCode: response.status,
|
|
127
|
+
body: errorBody,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const json = (yield response.json());
|
|
131
|
+
return {
|
|
132
|
+
accessToken: json.access_token,
|
|
133
|
+
expiresAt: Date.now() + json.expires_in * 1000,
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
buildClientAssertion(domain, clientId) {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
const { clientAssertionSigningKey, clientAssertionSigningAlg = "RS256" } = this
|
|
140
|
+
.options;
|
|
141
|
+
const key = yield (0, jose_1.importPKCS8)(clientAssertionSigningKey, clientAssertionSigningAlg);
|
|
142
|
+
const now = Math.floor(Date.now() / 1000);
|
|
143
|
+
return new jose_1.SignJWT({})
|
|
144
|
+
.setProtectedHeader({ alg: clientAssertionSigningAlg })
|
|
145
|
+
.setIssuedAt(now)
|
|
146
|
+
.setIssuer(clientId)
|
|
147
|
+
.setSubject(clientId)
|
|
148
|
+
.setAudience(`https://${domain}/`)
|
|
149
|
+
.setExpirationTime(now + 180) // 3 min lifetime
|
|
150
|
+
.setJti(crypto.randomUUID())
|
|
151
|
+
.sign(key);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
buildTelemetryHeader() {
|
|
155
|
+
var _a;
|
|
156
|
+
const opts = this.options;
|
|
157
|
+
if (opts.telemetry === false)
|
|
158
|
+
return null;
|
|
159
|
+
const nodeAuth0Info = (0, utils_js_1.generateClientInfo)();
|
|
160
|
+
const info = opts.clientInfo
|
|
161
|
+
? { name: opts.clientInfo.name, version: String((_a = opts.clientInfo.version) !== null && _a !== void 0 ? _a : nodeAuth0Info.version) }
|
|
162
|
+
: { name: nodeAuth0Info.name, version: nodeAuth0Info.version };
|
|
163
|
+
// NOTE: auth0-auth-js TelemetryConfig does not support env fields.
|
|
164
|
+
// The runtime fingerprint (env.node / env.cloudflare-workers) present in the
|
|
165
|
+
// original node-auth0 Auth0-Client header is intentionally omitted here.
|
|
166
|
+
// This is a known, accepted delta vs the pre-v7 token request telemetry shape.
|
|
167
|
+
// Use jose's base64url encoder for runtime portability (Buffer is Node-only).
|
|
168
|
+
return jose_1.base64url.encode(new TextEncoder().encode(JSON.stringify(info)));
|
|
169
|
+
}
|
|
39
170
|
}
|
|
40
171
|
exports.TokenProvider = TokenProvider;
|
package/dist/cjs/utils.d.ts
CHANGED
|
@@ -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 {};
|
package/dist/cjs/utils.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
3
|
+
exports.generateClientInfo = void 0;
|
|
13
4
|
const version_js_1 = require("./management/version.js");
|
|
14
5
|
const index_js_1 = require("./management/core/index.js");
|
|
15
6
|
const generateClientInfo = () => {
|
|
@@ -26,25 +17,3 @@ const generateClientInfo = () => {
|
|
|
26
17
|
};
|
|
27
18
|
};
|
|
28
19
|
exports.generateClientInfo = generateClientInfo;
|
|
29
|
-
/**
|
|
30
|
-
* @private
|
|
31
|
-
*/
|
|
32
|
-
exports.mtlsPrefix = "mtls";
|
|
33
|
-
/**
|
|
34
|
-
* Resolves a value that can be a static value, a synchronous function, or an asynchronous function.
|
|
35
|
-
*
|
|
36
|
-
* @template T - The type of the value to be resolved.
|
|
37
|
-
* @param {T | SyncGetter<T> | AsyncGetter<T>} value - The value to be resolved. It can be:
|
|
38
|
-
* - A static value of type T.
|
|
39
|
-
* - A synchronous function that returns a value of type T.
|
|
40
|
-
* - An asynchronous function that returns a Promise of type T.
|
|
41
|
-
* @returns {Promise<T>} A promise that resolves to the value of type T.
|
|
42
|
-
*/
|
|
43
|
-
const resolveValueToPromise = (value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
-
if (typeof value === "function") {
|
|
45
|
-
const result = value(); // Call the function
|
|
46
|
-
return result instanceof Promise ? result : Promise.resolve(result); // Handle sync/async
|
|
47
|
-
}
|
|
48
|
-
return Promise.resolve(value); // Static value
|
|
49
|
-
});
|
|
50
|
-
exports.resolveValueToPromise = resolveValueToPromise;
|
package/dist/esm/index.d.mts
CHANGED
package/dist/esm/index.mjs
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error thrown when the API returns an error response that can't be parsed to a more specific Error instance.
|
|
3
|
-
*/
|
|
4
|
-
export declare class ResponseError extends Error {
|
|
5
|
-
statusCode: number;
|
|
6
|
-
body: string;
|
|
7
|
-
headers: Headers;
|
|
8
|
-
name: "ResponseError";
|
|
9
|
-
constructor(statusCode: number, body: string, headers: Headers, msg?: string);
|
|
10
|
-
}
|
|
11
1
|
/**
|
|
12
2
|
* Error thrown when the request is aborted due to a timeout.
|
|
13
3
|
*/
|
|
@@ -15,14 +5,6 @@ export declare class TimeoutError extends Error {
|
|
|
15
5
|
name: "TimeoutError";
|
|
16
6
|
constructor();
|
|
17
7
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Error thrown when there is a network error.
|
|
20
|
-
*/
|
|
21
|
-
export declare class FetchError extends Error {
|
|
22
|
-
cause: Error;
|
|
23
|
-
name: "FetchError";
|
|
24
|
-
constructor(cause: Error, msg?: string);
|
|
25
|
-
}
|
|
26
8
|
/**
|
|
27
9
|
* Error thrown when a required argument was not provided.
|
|
28
10
|
*/
|
package/dist/esm/lib/errors.mjs
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error thrown when the API returns an error response that can't be parsed to a more specific Error instance.
|
|
3
|
-
*/
|
|
4
|
-
export class ResponseError extends Error {
|
|
5
|
-
constructor(statusCode, body, headers, msg) {
|
|
6
|
-
super(msg);
|
|
7
|
-
this.statusCode = statusCode;
|
|
8
|
-
this.body = body;
|
|
9
|
-
this.headers = headers;
|
|
10
|
-
this.name = "ResponseError";
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
1
|
/**
|
|
14
2
|
* Error thrown when the request is aborted due to a timeout.
|
|
15
3
|
*/
|
|
@@ -19,16 +7,6 @@ export class TimeoutError extends Error {
|
|
|
19
7
|
this.name = "TimeoutError";
|
|
20
8
|
}
|
|
21
9
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Error thrown when there is a network error.
|
|
24
|
-
*/
|
|
25
|
-
export class FetchError extends Error {
|
|
26
|
-
constructor(cause, msg) {
|
|
27
|
-
super(msg);
|
|
28
|
-
this.cause = cause;
|
|
29
|
-
this.name = "FetchError";
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
10
|
/**
|
|
33
11
|
* Error thrown when a required argument was not provided.
|
|
34
12
|
*/
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ClientOptions } from "../models.mjs";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* for automatic header injection and as a standalone utility for manual telemetry header generation.
|
|
3
|
+
* Generates the Auth0-Client telemetry header value.
|
|
5
4
|
* @private
|
|
6
5
|
*/
|
|
7
|
-
export declare class Auth0ClientTelemetry
|
|
6
|
+
export declare class Auth0ClientTelemetry {
|
|
8
7
|
clientInfo: {
|
|
9
8
|
name: string;
|
|
10
9
|
[key: string]: unknown;
|
|
@@ -12,9 +11,6 @@ export declare class Auth0ClientTelemetry implements Middleware {
|
|
|
12
11
|
constructor(options: ClientOptions);
|
|
13
12
|
/**
|
|
14
13
|
* Get the Auth0-Client header value for telemetry.
|
|
15
|
-
* This method can be used when you need to manually add telemetry headers
|
|
16
|
-
* instead of using the middleware system.
|
|
17
14
|
*/
|
|
18
15
|
getAuth0ClientHeader(): string | undefined;
|
|
19
|
-
pre?(context: RequestContext): Promise<FetchParams | void>;
|
|
20
16
|
}
|
|
@@ -1,17 +1,7 @@
|
|
|
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 { generateClientInfo } from "../../utils.mjs";
|
|
11
2
|
import { base64url } from "jose";
|
|
12
3
|
/**
|
|
13
|
-
*
|
|
14
|
-
* for automatic header injection and as a standalone utility for manual telemetry header generation.
|
|
4
|
+
* Generates the Auth0-Client telemetry header value.
|
|
15
5
|
* @private
|
|
16
6
|
*/
|
|
17
7
|
export class Auth0ClientTelemetry {
|
|
@@ -20,8 +10,6 @@ export class Auth0ClientTelemetry {
|
|
|
20
10
|
}
|
|
21
11
|
/**
|
|
22
12
|
* Get the Auth0-Client header value for telemetry.
|
|
23
|
-
* This method can be used when you need to manually add telemetry headers
|
|
24
|
-
* instead of using the middleware system.
|
|
25
13
|
*/
|
|
26
14
|
getAuth0ClientHeader() {
|
|
27
15
|
if ("string" === typeof this.clientInfo.name && this.clientInfo.name.length > 0) {
|
|
@@ -29,16 +17,4 @@ export class Auth0ClientTelemetry {
|
|
|
29
17
|
}
|
|
30
18
|
return undefined;
|
|
31
19
|
}
|
|
32
|
-
pre(context) {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const headerValue = this.getAuth0ClientHeader();
|
|
35
|
-
if (headerValue) {
|
|
36
|
-
context.init.headers = Object.assign(Object.assign({}, context.init.headers), { "Auth0-Client": headerValue });
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
url: context.url,
|
|
40
|
-
init: context.init,
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
20
|
}
|
|
@@ -71,30 +71,6 @@ export interface ApiResponse<T> {
|
|
|
71
71
|
status: number;
|
|
72
72
|
statusText: string;
|
|
73
73
|
}
|
|
74
|
-
export declare class JSONApiResponse<T> implements ApiResponse<T> {
|
|
75
|
-
data: T;
|
|
76
|
-
headers: Headers;
|
|
77
|
-
readonly status: number;
|
|
78
|
-
readonly statusText: string;
|
|
79
|
-
constructor(data: T, headers: Headers, status: number, statusText: string);
|
|
80
|
-
static fromResponse<T = unknown>(raw: Response): Promise<JSONApiResponse<T>>;
|
|
81
|
-
}
|
|
82
|
-
export declare class VoidApiResponse implements ApiResponse<undefined> {
|
|
83
|
-
headers: Headers;
|
|
84
|
-
readonly status: number;
|
|
85
|
-
readonly statusText: string;
|
|
86
|
-
data: undefined;
|
|
87
|
-
constructor(headers: Headers, status: number, statusText: string);
|
|
88
|
-
static fromResponse(raw: Response): Promise<VoidApiResponse>;
|
|
89
|
-
}
|
|
90
|
-
export declare class TextApiResponse implements ApiResponse<string> {
|
|
91
|
-
data: string;
|
|
92
|
-
headers: Headers;
|
|
93
|
-
readonly status: number;
|
|
94
|
-
readonly statusText: string;
|
|
95
|
-
constructor(data: string, headers: Headers, status: number, statusText: string);
|
|
96
|
-
static fromResponse(raw: Response): Promise<TextApiResponse>;
|
|
97
|
-
}
|
|
98
74
|
export interface FetchParams {
|
|
99
75
|
url: string | URL | Request;
|
|
100
76
|
init: RequestInit;
|
package/dist/esm/lib/models.mjs
CHANGED
|
@@ -1,49 +1 @@
|
|
|
1
|
-
|
|
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
|
-
export class JSONApiResponse {
|
|
11
|
-
constructor(data, headers, status, statusText) {
|
|
12
|
-
this.data = data;
|
|
13
|
-
this.headers = headers;
|
|
14
|
-
this.status = status;
|
|
15
|
-
this.statusText = statusText;
|
|
16
|
-
}
|
|
17
|
-
static fromResponse(raw) {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const value = (yield raw.json());
|
|
20
|
-
return new JSONApiResponse(value, raw.headers, raw.status, raw.statusText);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export class VoidApiResponse {
|
|
25
|
-
constructor(headers, status, statusText) {
|
|
26
|
-
this.headers = headers;
|
|
27
|
-
this.status = status;
|
|
28
|
-
this.statusText = statusText;
|
|
29
|
-
}
|
|
30
|
-
static fromResponse(raw) {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
return new VoidApiResponse(raw.headers, raw.status, raw.statusText);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export class TextApiResponse {
|
|
37
|
-
constructor(data, headers, status, statusText) {
|
|
38
|
-
this.data = data;
|
|
39
|
-
this.headers = headers;
|
|
40
|
-
this.status = status;
|
|
41
|
-
this.statusText = statusText;
|
|
42
|
-
}
|
|
43
|
-
static fromResponse(raw) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const value = yield raw.text();
|
|
46
|
-
return new TextApiResponse(value, raw.headers, raw.status, raw.statusText);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
1
|
+
export {};
|
|
@@ -24,6 +24,7 @@ import { LogsClient } from "./api/resources/logs/client/Client.mjs";
|
|
|
24
24
|
import { LogStreamsClient } from "./api/resources/logStreams/client/Client.mjs";
|
|
25
25
|
import { NetworkAclsClient } from "./api/resources/networkAcls/client/Client.mjs";
|
|
26
26
|
import { OrganizationsClient } from "./api/resources/organizations/client/Client.mjs";
|
|
27
|
+
import { OrganizationTemplatesClient } from "./api/resources/organizationTemplates/client/Client.mjs";
|
|
27
28
|
import { PromptsClient } from "./api/resources/prompts/client/Client.mjs";
|
|
28
29
|
import { RateLimitPoliciesClient } from "./api/resources/rateLimitPolicies/client/Client.mjs";
|
|
29
30
|
import { RefreshTokensClient } from "./api/resources/refreshTokens/client/Client.mjs";
|
|
@@ -75,6 +76,7 @@ export declare class ManagementClient {
|
|
|
75
76
|
protected _logStreams: LogStreamsClient | undefined;
|
|
76
77
|
protected _logs: LogsClient | undefined;
|
|
77
78
|
protected _networkAcls: NetworkAclsClient | undefined;
|
|
79
|
+
protected _organizationTemplates: OrganizationTemplatesClient | undefined;
|
|
78
80
|
protected _organizations: OrganizationsClient | undefined;
|
|
79
81
|
protected _prompts: PromptsClient | undefined;
|
|
80
82
|
protected _rateLimitPolicies: RateLimitPoliciesClient | undefined;
|
|
@@ -122,6 +124,7 @@ export declare class ManagementClient {
|
|
|
122
124
|
get logStreams(): LogStreamsClient;
|
|
123
125
|
get logs(): LogsClient;
|
|
124
126
|
get networkAcls(): NetworkAclsClient;
|
|
127
|
+
get organizationTemplates(): OrganizationTemplatesClient;
|
|
125
128
|
get organizations(): OrganizationsClient;
|
|
126
129
|
get prompts(): PromptsClient;
|
|
127
130
|
get rateLimitPolicies(): RateLimitPoliciesClient;
|
|
@@ -34,6 +34,7 @@ import { LogsClient } from "./api/resources/logs/client/Client.mjs";
|
|
|
34
34
|
import { LogStreamsClient } from "./api/resources/logStreams/client/Client.mjs";
|
|
35
35
|
import { NetworkAclsClient } from "./api/resources/networkAcls/client/Client.mjs";
|
|
36
36
|
import { OrganizationsClient } from "./api/resources/organizations/client/Client.mjs";
|
|
37
|
+
import { OrganizationTemplatesClient } from "./api/resources/organizationTemplates/client/Client.mjs";
|
|
37
38
|
import { PromptsClient } from "./api/resources/prompts/client/Client.mjs";
|
|
38
39
|
import { RateLimitPoliciesClient } from "./api/resources/rateLimitPolicies/client/Client.mjs";
|
|
39
40
|
import { RefreshTokensClient } from "./api/resources/refreshTokens/client/Client.mjs";
|
|
@@ -144,6 +145,10 @@ export class ManagementClient {
|
|
|
144
145
|
var _a;
|
|
145
146
|
return ((_a = this._networkAcls) !== null && _a !== void 0 ? _a : (this._networkAcls = new NetworkAclsClient(this._options)));
|
|
146
147
|
}
|
|
148
|
+
get organizationTemplates() {
|
|
149
|
+
var _a;
|
|
150
|
+
return ((_a = this._organizationTemplates) !== null && _a !== void 0 ? _a : (this._organizationTemplates = new OrganizationTemplatesClient(this._options)));
|
|
151
|
+
}
|
|
147
152
|
get organizations() {
|
|
148
153
|
var _a;
|
|
149
154
|
return ((_a = this._organizations) !== null && _a !== void 0 ? _a : (this._organizations = new OrganizationsClient(this._options)));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
import * as errors from "../../errors/index.mjs";
|
|
3
|
+
export class UnprocessableEntityError extends errors.ManagementError {
|
|
4
|
+
constructor(body, rawResponse) {
|
|
5
|
+
super({
|
|
6
|
+
message: "UnprocessableEntityError",
|
|
7
|
+
statusCode: 422,
|
|
8
|
+
body: body,
|
|
9
|
+
rawResponse: rawResponse,
|
|
10
|
+
});
|
|
11
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
12
|
+
if (Error.captureStackTrace) {
|
|
13
|
+
Error.captureStackTrace(this, this.constructor);
|
|
14
|
+
}
|
|
15
|
+
this.name = "UnprocessableEntityError";
|
|
16
|
+
}
|
|
17
|
+
}
|