auth0 6.4.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.
Files changed (82) 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/version.d.ts +1 -1
  11. package/dist/cjs/management/version.js +1 -1
  12. package/dist/cjs/management/wrapper/ManagementClient.d.ts +9 -2
  13. package/dist/cjs/management/wrapper/ManagementClient.js +0 -1
  14. package/dist/cjs/management/wrapper/token-provider.d.ts +4 -2
  15. package/dist/cjs/management/wrapper/token-provider.js +142 -11
  16. package/dist/cjs/utils.d.ts +0 -18
  17. package/dist/cjs/utils.js +1 -32
  18. package/dist/esm/index.d.mts +0 -2
  19. package/dist/esm/index.mjs +0 -2
  20. package/dist/esm/lib/errors.d.mts +0 -18
  21. package/dist/esm/lib/errors.mjs +0 -22
  22. package/dist/esm/lib/middleware/auth0-client-telemetry.d.mts +3 -7
  23. package/dist/esm/lib/middleware/auth0-client-telemetry.mjs +1 -25
  24. package/dist/esm/lib/models.d.mts +0 -24
  25. package/dist/esm/lib/models.mjs +1 -49
  26. package/dist/esm/management/version.d.mts +1 -1
  27. package/dist/esm/management/version.mjs +1 -1
  28. package/dist/esm/management/wrapper/ManagementClient.d.mts +9 -2
  29. package/dist/esm/management/wrapper/ManagementClient.mjs +0 -1
  30. package/dist/esm/management/wrapper/token-provider.d.mts +4 -2
  31. package/dist/esm/management/wrapper/token-provider.mjs +142 -11
  32. package/dist/esm/utils.d.mts +0 -18
  33. package/dist/esm/utils.mjs +0 -30
  34. package/package.json +1 -2
  35. package/dist/cjs/auth/backchannel.d.ts +0 -158
  36. package/dist/cjs/auth/backchannel.js +0 -135
  37. package/dist/cjs/auth/base-auth-api.d.ts +0 -41
  38. package/dist/cjs/auth/base-auth-api.js +0 -109
  39. package/dist/cjs/auth/client-authentication.d.ts +0 -27
  40. package/dist/cjs/auth/client-authentication.js +0 -82
  41. package/dist/cjs/auth/database.d.ts +0 -157
  42. package/dist/cjs/auth/database.js +0 -94
  43. package/dist/cjs/auth/id-token-validator.d.ts +0 -18
  44. package/dist/cjs/auth/id-token-validator.js +0 -158
  45. package/dist/cjs/auth/index.d.ts +0 -65
  46. package/dist/cjs/auth/index.js +0 -80
  47. package/dist/cjs/auth/oauth.d.ts +0 -462
  48. package/dist/cjs/auth/oauth.js +0 -280
  49. package/dist/cjs/auth/passwordless.d.ts +0 -165
  50. package/dist/cjs/auth/passwordless.js +0 -173
  51. package/dist/cjs/auth/tokenExchange.d.ts +0 -166
  52. package/dist/cjs/auth/tokenExchange.js +0 -74
  53. package/dist/cjs/lib/index.d.ts +0 -3
  54. package/dist/cjs/lib/index.js +0 -18
  55. package/dist/cjs/lib/runtime.d.ts +0 -61
  56. package/dist/cjs/lib/runtime.js +0 -222
  57. package/dist/cjs/userinfo/index.d.ts +0 -87
  58. package/dist/cjs/userinfo/index.js +0 -104
  59. package/dist/esm/auth/backchannel.d.mts +0 -158
  60. package/dist/esm/auth/backchannel.mjs +0 -131
  61. package/dist/esm/auth/base-auth-api.d.mts +0 -41
  62. package/dist/esm/auth/base-auth-api.mjs +0 -103
  63. package/dist/esm/auth/client-authentication.d.mts +0 -27
  64. package/dist/esm/auth/client-authentication.mjs +0 -45
  65. package/dist/esm/auth/database.d.mts +0 -157
  66. package/dist/esm/auth/database.mjs +0 -90
  67. package/dist/esm/auth/id-token-validator.d.mts +0 -18
  68. package/dist/esm/auth/id-token-validator.mjs +0 -120
  69. package/dist/esm/auth/index.d.mts +0 -65
  70. package/dist/esm/auth/index.mjs +0 -60
  71. package/dist/esm/auth/oauth.d.mts +0 -462
  72. package/dist/esm/auth/oauth.mjs +0 -276
  73. package/dist/esm/auth/passwordless.d.mts +0 -165
  74. package/dist/esm/auth/passwordless.mjs +0 -169
  75. package/dist/esm/auth/tokenExchange.d.mts +0 -166
  76. package/dist/esm/auth/tokenExchange.mjs +0 -70
  77. package/dist/esm/lib/index.d.mts +0 -3
  78. package/dist/esm/lib/index.mjs +0 -2
  79. package/dist/esm/lib/runtime.d.mts +0 -61
  80. package/dist/esm/lib/runtime.mjs +0 -201
  81. package/dist/esm/userinfo/index.d.mts +0 -87
  82. package/dist/esm/userinfo/index.mjs +0 -98
@@ -1,166 +0,0 @@
1
- import { BaseAuthAPI } from "./base-auth-api.js";
2
- /**
3
- * Represents the configuration options required for initiating a Custom Token Exchange request
4
- * following RFC 8693 specifications.
5
- *
6
- * @see {@link https://www.rfc-editor.org/rfc/rfc8693 | RFC 8693: OAuth 2.0 Token Exchange}
7
- */
8
- export type CustomTokenExchangeOptions = {
9
- /**
10
- * The type identifier for the subject token being exchanged
11
- *
12
- * @pattern
13
- * - Must be a namespaced URI under your organization's control
14
- * - Forbidden patterns:
15
- * - `^urn:ietf:params:oauth:*` (IETF reserved)
16
- * - `^https:\/\/auth0\.com/*` (Auth0 reserved)
17
- * - `^urn:auth0:*` (Auth0 reserved)
18
- *
19
- * @example
20
- * "urn:acme:legacy-system-token"
21
- * "https://api.yourcompany.com/token-type/v1"
22
- */
23
- subject_token_type: string;
24
- /**
25
- * The opaque token value being exchanged for Auth0 tokens
26
- *
27
- * @security
28
- * - Must be validated in Auth0 Actions using strong cryptographic verification
29
- * - Implement replay attack protection
30
- * - Recommended validation libraries: `jose`, `jsonwebtoken`
31
- *
32
- * @example
33
- * "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
34
- */
35
- subject_token: string;
36
- /**
37
- * The target audience for the requested Auth0 token
38
- *
39
- * @remarks
40
- * Must match exactly with an API identifier configured in your Auth0 tenant
41
- *
42
- * @example
43
- * "https://api.your-service.com/v1"
44
- */
45
- audience: string;
46
- /**
47
- * Space-separated list of OAuth 2.0 scopes being requested
48
- *
49
- * @remarks
50
- * Subject to API authorization policies configured in Auth0
51
- *
52
- * @example
53
- * "openid profile email read:data write:data"
54
- */
55
- scope?: string;
56
- /**
57
- * Additional custom parameters for Auth0 Action processing
58
- *
59
- * @remarks
60
- * Accessible in Action code via `event.request.body`
61
- *
62
- * @example
63
- * ```typescript
64
- * {
65
- * custom_parameter: "session_context",
66
- * device_fingerprint: "a3d8f7...",
67
- * }
68
- * ```
69
- */
70
- [key: string]: unknown;
71
- };
72
- /**
73
- * Interface defining Custom Token Exchange operations
74
- *
75
- * @see {@link https://auth0.com/docs/authenticate/protocols/custom-token-exchange | Auth0 Custom Token Exchange Docs}
76
- */
77
- export interface ICustomTokenExchange {
78
- /**
79
- * Executes RFC 8693-compliant token exchange flow
80
- *
81
- * @throws {Auth0Error} For structured error responses
82
- * @throws {Error} For generic errors with these codes:
83
- * - `invalid_request`: Invalid parameters
84
- * - `consent_required`: Enable "Allow Skipping User Consent" in API settings
85
- * - `too_many_attempts`: Suspicious IP throttling triggered
86
- *
87
- * @example
88
- * ```typescript
89
- * // External IdP migration scenario
90
- * const tokens = await auth0.customTokenExchange.exchangeToken({
91
- * subject_token_type: 'urn:external-idp:legacy',
92
- * subject_token: externalIdPToken,
93
- * audience: 'https://api.your-service.com',
94
- * scope: 'openid profile'
95
- * });
96
- * ```
97
- */
98
- exchangeToken(options: CustomTokenExchangeOptions): Promise<TokenResponse>;
99
- }
100
- /**
101
- * Implements Auth0's Custom Token Exchange functionality with security best practices
102
- *
103
- * @security
104
- * - **HTTPS Enforcement**: All requests require TLS encryption
105
- * - **Credential Protection**: Client secrets never exposed in browser contexts
106
- * - **Input Validation**: Strict namespace enforcement for token types
107
- *
108
- * @example
109
- * ```typescript
110
- * // Secure token validation in Auth0 Action
111
- * exports.onExecuteCustomTokenExchange = async (event, api) => {
112
- * const { jws } = require('jose');
113
- * const { createRemoteJWKSet } = require('jose/jwks');
114
- *
115
- * const JWKS = createRemoteJWKSet(new URL('https://external-idp.com/.well-known/jwks.json'));
116
- *
117
- * try {
118
- * const { payload } = await jws.verify(event.transaction.subject_token, JWKS);
119
- * api.authentication.setUserById(payload.sub);
120
- * } catch (error) {
121
- * api.access.rejectInvalidSubjectToken('Invalid token signature');
122
- * }
123
- * };
124
- * ```
125
- */
126
- export declare class CustomTokenExchange extends BaseAuthAPI implements ICustomTokenExchange {
127
- /**
128
- * Executes token exchange flow with security validations
129
- *
130
- * @param options - Exchange configuration parameters
131
- * @returns Auth0-issued tokens with requested claims
132
- *
133
- * @throws {Error} When:
134
- * - `subject_token_type` uses prohibited namespace
135
- * - Network failures occur
136
- * - Auth0 returns error responses (4xx/5xx)
137
- */
138
- exchangeToken(options: CustomTokenExchangeOptions): Promise<TokenResponse>;
139
- }
140
- /**
141
- * Standardized token response structure for Auth0 authentication flows
142
- *
143
- * @remarks
144
- * **Token Lifetime Management**:
145
- * - Cache tokens according to `expires_in` value
146
- * - Rotate refresh tokens using `offline_access` scope
147
- * - Revoke compromised tokens immediately
148
- *
149
- * @security
150
- * - Store tokens in secure, encrypted storage
151
- * - Never expose in client-side code or logs
152
- */
153
- export type TokenResponse = {
154
- /** Bearer token for API authorization */
155
- access_token: string;
156
- /** Refresh token (requires `offline_access` scope) */
157
- refresh_token?: string;
158
- /** JWT containing user identity claims */
159
- id_token: string;
160
- /** Typically "Bearer" */
161
- token_type?: string;
162
- /** Token validity in seconds (default: 86400) */
163
- expires_in: number;
164
- /** Granted permissions space */
165
- scope: string;
166
- };
@@ -1,74 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.CustomTokenExchange = void 0;
13
- const models_js_1 = require("../lib/models.js");
14
- const base_auth_api_js_1 = require("./base-auth-api.js");
15
- /** RFC 8693-defined grant type for token exchange */
16
- const TOKEN_EXCHANGE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:token-exchange";
17
- /** Auth0 token endpoint path */
18
- const TOKEN_URL = "/oauth/token";
19
- /**
20
- * Implements Auth0's Custom Token Exchange functionality with security best practices
21
- *
22
- * @security
23
- * - **HTTPS Enforcement**: All requests require TLS encryption
24
- * - **Credential Protection**: Client secrets never exposed in browser contexts
25
- * - **Input Validation**: Strict namespace enforcement for token types
26
- *
27
- * @example
28
- * ```typescript
29
- * // Secure token validation in Auth0 Action
30
- * exports.onExecuteCustomTokenExchange = async (event, api) => {
31
- * const { jws } = require('jose');
32
- * const { createRemoteJWKSet } = require('jose/jwks');
33
- *
34
- * const JWKS = createRemoteJWKSet(new URL('https://external-idp.com/.well-known/jwks.json'));
35
- *
36
- * try {
37
- * const { payload } = await jws.verify(event.transaction.subject_token, JWKS);
38
- * api.authentication.setUserById(payload.sub);
39
- * } catch (error) {
40
- * api.access.rejectInvalidSubjectToken('Invalid token signature');
41
- * }
42
- * };
43
- * ```
44
- */
45
- class CustomTokenExchange extends base_auth_api_js_1.BaseAuthAPI {
46
- /**
47
- * Executes token exchange flow with security validations
48
- *
49
- * @param options - Exchange configuration parameters
50
- * @returns Auth0-issued tokens with requested claims
51
- *
52
- * @throws {Error} When:
53
- * - `subject_token_type` uses prohibited namespace
54
- * - Network failures occur
55
- * - Auth0 returns error responses (4xx/5xx)
56
- */
57
- exchangeToken(options) {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- const body = Object.assign(Object.assign({}, options), { grant_type: TOKEN_EXCHANGE_GRANT_TYPE, client_id: this.clientId });
60
- yield this.addClientAuthentication(body);
61
- const response = yield this.request({
62
- path: TOKEN_URL,
63
- method: "POST",
64
- headers: {
65
- "Content-Type": "application/x-www-form-urlencoded",
66
- },
67
- body: new URLSearchParams(body),
68
- }, {});
69
- const r = yield models_js_1.JSONApiResponse.fromResponse(response);
70
- return r.data;
71
- });
72
- }
73
- }
74
- exports.CustomTokenExchange = CustomTokenExchange;
@@ -1,3 +0,0 @@
1
- export * from "./errors.js";
2
- export * from "./models.js";
3
- export { RetryConfiguration } from "./retry.js";
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./errors.js"), exports);
18
- __exportStar(require("./models.js"), exports);
@@ -1,61 +0,0 @@
1
- import { RequestOpts, InitOverrideFunction, Configuration } from "./models.js";
2
- export * from "./models.js";
3
- /**
4
- * @private
5
- * This is the base class for all generated API classes.
6
- */
7
- export declare class BaseAPI {
8
- protected configuration: Configuration;
9
- private middleware;
10
- private fetchApi;
11
- private parseError;
12
- private timeoutDuration;
13
- constructor(configuration: Configuration);
14
- protected request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise<Response>;
15
- private createFetchParams;
16
- private fetchWithTimeout;
17
- private fetch;
18
- }
19
- /**
20
- * @private
21
- */
22
- export declare const COLLECTION_FORMATS: {
23
- csv: string;
24
- ssv: string;
25
- tsv: string;
26
- pipes: string;
27
- };
28
- /**
29
- * @private
30
- */
31
- export type ModelPropertyNaming = "camelCase" | "snake_case" | "PascalCase" | "original";
32
- /**
33
- * @private
34
- */
35
- export interface Consume {
36
- contentType: string;
37
- }
38
- /**
39
- * @private
40
- */
41
- export declare function validateRequiredRequestParams<TRequestParams extends {
42
- [key: string]: any;
43
- }>(requestParameters: TRequestParams, keys: Array<Extract<keyof TRequestParams, string>>): void;
44
- type QueryParamConfig = {
45
- isArray?: boolean;
46
- isCollectionFormatMulti?: boolean;
47
- collectionFormat?: keyof typeof COLLECTION_FORMATS;
48
- };
49
- /**
50
- * @private
51
- */
52
- export declare function applyQueryParams<TRequestParams extends {
53
- [key: string]: any;
54
- }, Key extends Extract<keyof TRequestParams, string>>(requestParameters: TRequestParams, keys: Array<{
55
- key: Key;
56
- config: QueryParamConfig;
57
- }>): Pick<TRequestParams, ReadonlyArray<Key>[number]>;
58
- /**
59
- * @private
60
- */
61
- export declare function parseFormParam(originalValue: number | boolean | string | Blob): Promise<string | Blob>;
@@ -1,222 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.COLLECTION_FORMATS = exports.BaseAPI = void 0;
27
- exports.validateRequiredRequestParams = validateRequiredRequestParams;
28
- exports.applyQueryParams = applyQueryParams;
29
- exports.parseFormParam = parseFormParam;
30
- const retry_js_1 = require("./retry.js");
31
- const errors_js_1 = require("./errors.js");
32
- __exportStar(require("./models.js"), exports);
33
- /**
34
- * @private
35
- * This is the base class for all generated API classes.
36
- */
37
- class BaseAPI {
38
- constructor(configuration) {
39
- this.configuration = configuration;
40
- this.fetchWithTimeout = (url, init) => __awaiter(this, void 0, void 0, function* () {
41
- const controller = new AbortController();
42
- const timeout = setTimeout(() => {
43
- controller.abort();
44
- }, this.timeoutDuration);
45
- try {
46
- return yield this.fetchApi(url, Object.assign({ signal: controller.signal }, init));
47
- }
48
- catch (e) {
49
- if (e.name === "AbortError") {
50
- throw new errors_js_1.TimeoutError();
51
- }
52
- throw e;
53
- }
54
- finally {
55
- clearTimeout(timeout);
56
- }
57
- });
58
- this.fetch = (url, init) => __awaiter(this, void 0, void 0, function* () {
59
- var _a;
60
- let fetchParams = { url, init };
61
- for (const middleware of this.middleware) {
62
- if (middleware.pre) {
63
- fetchParams =
64
- (yield middleware.pre(Object.assign({ fetch: this.fetchWithTimeout }, fetchParams))) || fetchParams;
65
- }
66
- }
67
- let response = undefined;
68
- let error = undefined;
69
- try {
70
- response =
71
- ((_a = this.configuration.retry) === null || _a === void 0 ? void 0 : _a.enabled) !== false
72
- ? yield (0, retry_js_1.retry)(() => this.fetchWithTimeout(fetchParams.url, fetchParams.init), Object.assign({}, this.configuration.retry))
73
- : yield this.fetchWithTimeout(fetchParams.url, fetchParams.init);
74
- }
75
- catch (e) {
76
- error = e;
77
- }
78
- if (error || !response.ok) {
79
- for (const middleware of this.middleware) {
80
- if (middleware.onError) {
81
- response =
82
- (yield middleware.onError(Object.assign(Object.assign({ fetch: this.fetchWithTimeout }, fetchParams), { error, response: response ? response.clone() : undefined }))) || response;
83
- }
84
- }
85
- if (response === undefined) {
86
- throw new errors_js_1.FetchError(error, "The request failed and the interceptors did not return an alternative response");
87
- }
88
- }
89
- else {
90
- for (const middleware of this.middleware) {
91
- if (middleware.post) {
92
- response =
93
- (yield middleware.post(Object.assign(Object.assign({ fetch: this.fetchApi }, fetchParams), { response: response.clone() }))) || response;
94
- }
95
- }
96
- }
97
- return response;
98
- });
99
- if (configuration.baseUrl === null || configuration.baseUrl === undefined) {
100
- throw new Error("Must provide a base URL for the API");
101
- }
102
- if ("string" !== typeof configuration.baseUrl || configuration.baseUrl.length === 0) {
103
- throw new Error("The provided base URL is invalid");
104
- }
105
- this.middleware = configuration.middleware || [];
106
- this.fetchApi = configuration.fetch || globalThis.fetch.bind(globalThis);
107
- this.parseError = configuration.parseError;
108
- this.timeoutDuration =
109
- typeof configuration.timeoutDuration === "number" ? configuration.timeoutDuration : 10000;
110
- }
111
- request(context, initOverrides) {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- const { url, init } = yield this.createFetchParams(context, initOverrides);
114
- const response = yield this.fetch(url, init);
115
- if (response && response.status >= 200 && response.status < 300) {
116
- return response;
117
- }
118
- const error = yield this.parseError(response);
119
- throw error;
120
- });
121
- }
122
- createFetchParams(context, initOverrides) {
123
- return __awaiter(this, void 0, void 0, function* () {
124
- let url = this.configuration.baseUrl + context.path;
125
- if (context.query !== undefined && Object.keys(context.query).length !== 0) {
126
- // only add the querystring to the URL if there are query parameters.
127
- // this is done to avoid urls ending with a "?" character which buggy webservers
128
- // do not handle correctly sometimes.
129
- url += `?${querystring(context.query)}`;
130
- }
131
- const headers = Object.assign({}, this.configuration.headers, context.headers);
132
- Object.keys(headers).forEach((key) => (headers[key] === undefined ? delete headers[key] : {}));
133
- const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __awaiter(this, void 0, void 0, function* () { return initOverrides; });
134
- const initParams = {
135
- method: context.method,
136
- headers,
137
- body: context.body,
138
- dispatcher: this.configuration.agent,
139
- };
140
- const overriddenInit = Object.assign(Object.assign({}, initParams), (yield initOverrideFn({
141
- init: initParams,
142
- context,
143
- })));
144
- const init = Object.assign(Object.assign({}, overriddenInit), { body: overriddenInit.body instanceof FormData ||
145
- overriddenInit.body instanceof URLSearchParams ||
146
- overriddenInit.body instanceof Blob
147
- ? overriddenInit.body
148
- : JSON.stringify(overriddenInit.body) });
149
- return { url, init };
150
- });
151
- }
152
- }
153
- exports.BaseAPI = BaseAPI;
154
- /**
155
- * @private
156
- */
157
- exports.COLLECTION_FORMATS = {
158
- csv: ",",
159
- ssv: " ",
160
- tsv: "\t",
161
- pipes: "|",
162
- };
163
- /**
164
- * @private
165
- */
166
- function querystring(params) {
167
- return Object.keys(params)
168
- .map((key) => querystringSingleKey(key, params[key]))
169
- .filter((part) => part.length > 0)
170
- .join("&");
171
- }
172
- function querystringSingleKey(key, value) {
173
- if (value instanceof Array) {
174
- const multiValue = value
175
- .map((singleValue) => encodeURIComponent(String(singleValue)))
176
- .join(`&${encodeURIComponent(key)}=`);
177
- return `${encodeURIComponent(key)}=${multiValue}`;
178
- }
179
- return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`;
180
- }
181
- /**
182
- * @private
183
- */
184
- function validateRequiredRequestParams(requestParameters, keys) {
185
- keys.forEach((key) => {
186
- if (requestParameters[key] === null || requestParameters[key] === undefined) {
187
- throw new errors_js_1.RequiredError(key, `Required parameter requestParameters.${key} was null or undefined.`);
188
- }
189
- });
190
- }
191
- /**
192
- * @private
193
- */
194
- function applyQueryParams(requestParameters, keys) {
195
- return keys.reduce((acc, { key, config, }) => {
196
- let value;
197
- if (config.isArray) {
198
- if (config.isCollectionFormatMulti) {
199
- value = requestParameters[key];
200
- }
201
- else {
202
- value = requestParameters[key].join(exports.COLLECTION_FORMATS[config.collectionFormat]);
203
- }
204
- }
205
- else {
206
- if (requestParameters[key] !== undefined) {
207
- value = requestParameters[key];
208
- }
209
- }
210
- return value !== undefined ? Object.assign(Object.assign({}, acc), { [key]: value }) : acc;
211
- }, {});
212
- }
213
- /**
214
- * @private
215
- */
216
- function parseFormParam(originalValue) {
217
- return __awaiter(this, void 0, void 0, function* () {
218
- let value = originalValue;
219
- value = typeof value == "number" || typeof value == "boolean" ? "" + value : value;
220
- return value;
221
- });
222
- }
@@ -1,87 +0,0 @@
1
- import { ResponseError } from "../lib/errors.js";
2
- import { ClientOptions, InitOverride, JSONApiResponse } from "../lib/models.js";
3
- import { BaseAPI } from "../lib/runtime.js";
4
- /**
5
- * Response interface for the UserInfo endpoint
6
- * @group UserInfo API
7
- */
8
- export interface UserInfoResponse {
9
- sub: string;
10
- name: string;
11
- given_name?: string;
12
- family_name?: string;
13
- middle_name?: string;
14
- nickname: string;
15
- preferred_username?: string;
16
- profile?: string;
17
- picture?: string;
18
- website?: string;
19
- email: string;
20
- email_verified: boolean;
21
- gender?: string;
22
- birthdate?: string;
23
- zoneinfo?: string;
24
- locale?: string;
25
- phone_number?: string;
26
- phone_number_verified?: string;
27
- address?: {
28
- country?: string;
29
- };
30
- updated_at: string;
31
- [key: string]: unknown;
32
- }
33
- export declare class UserInfoError extends Error {
34
- error: string;
35
- error_description: string;
36
- statusCode: number;
37
- body: string;
38
- headers: Headers;
39
- name: "UserInfoError";
40
- constructor(error: string, error_description: string, statusCode: number, body: string, headers: Headers);
41
- }
42
- export declare function parseError(response: Response): Promise<ResponseError | UserInfoError>;
43
- /**
44
- * Auth0 UserInfo API Client
45
- *
46
- * Provides access to the UserInfo endpoint to retrieve user profile information
47
- * using an access token obtained during authentication.
48
- *
49
- * @group UserInfo API
50
- *
51
- * @example Basic usage
52
- * ```typescript
53
- * import { UserInfoClient } from 'auth0';
54
- *
55
- * const userInfoClient = new UserInfoClient({
56
- * domain: 'your-tenant.auth0.com'
57
- * });
58
- *
59
- * const userInfo = await userInfoClient.getUserInfo(accessToken);
60
- * console.log(userInfo.data.sub, userInfo.data.email);
61
- * ```
62
- */
63
- export declare class UserInfoClient extends BaseAPI {
64
- /**
65
- * Create a new UserInfo API client
66
- * @param options - Configuration options including domain and client settings
67
- */
68
- constructor(options: {
69
- domain: string;
70
- } & ClientOptions);
71
- /**
72
- * Given an access token get the user profile linked to it.
73
- *
74
- * @example <caption>
75
- * Get the user information based on the Auth0 access token (obtained during
76
- * login). Find more information in the
77
- * <a href="https://auth0.com/docs/auth-api#!#get--userinfo">API Docs</a>.
78
- * </caption>
79
- *
80
- * const userInfoClient = new UserInfoClient({
81
- * domain: '...'
82
- * });
83
-
84
- * const userInfo = await userInfoClient.getUserInfo(accessToken);
85
- */
86
- getUserInfo(accessToken: string, initOverrides?: InitOverride): Promise<JSONApiResponse<UserInfoResponse>>;
87
- }