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,166 +0,0 @@
1
- import { BaseAuthAPI } from "./base-auth-api.mjs";
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,70 +0,0 @@
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
- import { JSONApiResponse } from "../lib/models.mjs";
11
- import { BaseAuthAPI } from "./base-auth-api.mjs";
12
- /** RFC 8693-defined grant type for token exchange */
13
- const TOKEN_EXCHANGE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:token-exchange";
14
- /** Auth0 token endpoint path */
15
- const TOKEN_URL = "/oauth/token";
16
- /**
17
- * Implements Auth0's Custom Token Exchange functionality with security best practices
18
- *
19
- * @security
20
- * - **HTTPS Enforcement**: All requests require TLS encryption
21
- * - **Credential Protection**: Client secrets never exposed in browser contexts
22
- * - **Input Validation**: Strict namespace enforcement for token types
23
- *
24
- * @example
25
- * ```typescript
26
- * // Secure token validation in Auth0 Action
27
- * exports.onExecuteCustomTokenExchange = async (event, api) => {
28
- * const { jws } = require('jose');
29
- * const { createRemoteJWKSet } = require('jose/jwks');
30
- *
31
- * const JWKS = createRemoteJWKSet(new URL('https://external-idp.com/.well-known/jwks.json'));
32
- *
33
- * try {
34
- * const { payload } = await jws.verify(event.transaction.subject_token, JWKS);
35
- * api.authentication.setUserById(payload.sub);
36
- * } catch (error) {
37
- * api.access.rejectInvalidSubjectToken('Invalid token signature');
38
- * }
39
- * };
40
- * ```
41
- */
42
- export class CustomTokenExchange extends BaseAuthAPI {
43
- /**
44
- * Executes token exchange flow with security validations
45
- *
46
- * @param options - Exchange configuration parameters
47
- * @returns Auth0-issued tokens with requested claims
48
- *
49
- * @throws {Error} When:
50
- * - `subject_token_type` uses prohibited namespace
51
- * - Network failures occur
52
- * - Auth0 returns error responses (4xx/5xx)
53
- */
54
- exchangeToken(options) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- const body = Object.assign(Object.assign({}, options), { grant_type: TOKEN_EXCHANGE_GRANT_TYPE, client_id: this.clientId });
57
- yield this.addClientAuthentication(body);
58
- const response = yield this.request({
59
- path: TOKEN_URL,
60
- method: "POST",
61
- headers: {
62
- "Content-Type": "application/x-www-form-urlencoded",
63
- },
64
- body: new URLSearchParams(body),
65
- }, {});
66
- const r = yield JSONApiResponse.fromResponse(response);
67
- return r.data;
68
- });
69
- }
70
- }
@@ -1,3 +0,0 @@
1
- export * from "./errors.mjs";
2
- export * from "./models.mjs";
3
- export { RetryConfiguration } from "./retry.mjs";
@@ -1,2 +0,0 @@
1
- export * from "./errors.mjs";
2
- export * from "./models.mjs";
@@ -1,61 +0,0 @@
1
- import { RequestOpts, InitOverrideFunction, Configuration } from "./models.mjs";
2
- export * from "./models.mjs";
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,201 +0,0 @@
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
- import { retry } from "./retry.mjs";
11
- import { FetchError, RequiredError, TimeoutError } from "./errors.mjs";
12
- export * from "./models.mjs";
13
- /**
14
- * @private
15
- * This is the base class for all generated API classes.
16
- */
17
- export class BaseAPI {
18
- constructor(configuration) {
19
- this.configuration = configuration;
20
- this.fetchWithTimeout = (url, init) => __awaiter(this, void 0, void 0, function* () {
21
- const controller = new AbortController();
22
- const timeout = setTimeout(() => {
23
- controller.abort();
24
- }, this.timeoutDuration);
25
- try {
26
- return yield this.fetchApi(url, Object.assign({ signal: controller.signal }, init));
27
- }
28
- catch (e) {
29
- if (e.name === "AbortError") {
30
- throw new TimeoutError();
31
- }
32
- throw e;
33
- }
34
- finally {
35
- clearTimeout(timeout);
36
- }
37
- });
38
- this.fetch = (url, init) => __awaiter(this, void 0, void 0, function* () {
39
- var _a;
40
- let fetchParams = { url, init };
41
- for (const middleware of this.middleware) {
42
- if (middleware.pre) {
43
- fetchParams =
44
- (yield middleware.pre(Object.assign({ fetch: this.fetchWithTimeout }, fetchParams))) || fetchParams;
45
- }
46
- }
47
- let response = undefined;
48
- let error = undefined;
49
- try {
50
- response =
51
- ((_a = this.configuration.retry) === null || _a === void 0 ? void 0 : _a.enabled) !== false
52
- ? yield retry(() => this.fetchWithTimeout(fetchParams.url, fetchParams.init), Object.assign({}, this.configuration.retry))
53
- : yield this.fetchWithTimeout(fetchParams.url, fetchParams.init);
54
- }
55
- catch (e) {
56
- error = e;
57
- }
58
- if (error || !response.ok) {
59
- for (const middleware of this.middleware) {
60
- if (middleware.onError) {
61
- response =
62
- (yield middleware.onError(Object.assign(Object.assign({ fetch: this.fetchWithTimeout }, fetchParams), { error, response: response ? response.clone() : undefined }))) || response;
63
- }
64
- }
65
- if (response === undefined) {
66
- throw new FetchError(error, "The request failed and the interceptors did not return an alternative response");
67
- }
68
- }
69
- else {
70
- for (const middleware of this.middleware) {
71
- if (middleware.post) {
72
- response =
73
- (yield middleware.post(Object.assign(Object.assign({ fetch: this.fetchApi }, fetchParams), { response: response.clone() }))) || response;
74
- }
75
- }
76
- }
77
- return response;
78
- });
79
- if (configuration.baseUrl === null || configuration.baseUrl === undefined) {
80
- throw new Error("Must provide a base URL for the API");
81
- }
82
- if ("string" !== typeof configuration.baseUrl || configuration.baseUrl.length === 0) {
83
- throw new Error("The provided base URL is invalid");
84
- }
85
- this.middleware = configuration.middleware || [];
86
- this.fetchApi = configuration.fetch || globalThis.fetch.bind(globalThis);
87
- this.parseError = configuration.parseError;
88
- this.timeoutDuration =
89
- typeof configuration.timeoutDuration === "number" ? configuration.timeoutDuration : 10000;
90
- }
91
- request(context, initOverrides) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- const { url, init } = yield this.createFetchParams(context, initOverrides);
94
- const response = yield this.fetch(url, init);
95
- if (response && response.status >= 200 && response.status < 300) {
96
- return response;
97
- }
98
- const error = yield this.parseError(response);
99
- throw error;
100
- });
101
- }
102
- createFetchParams(context, initOverrides) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- let url = this.configuration.baseUrl + context.path;
105
- if (context.query !== undefined && Object.keys(context.query).length !== 0) {
106
- // only add the querystring to the URL if there are query parameters.
107
- // this is done to avoid urls ending with a "?" character which buggy webservers
108
- // do not handle correctly sometimes.
109
- url += `?${querystring(context.query)}`;
110
- }
111
- const headers = Object.assign({}, this.configuration.headers, context.headers);
112
- Object.keys(headers).forEach((key) => (headers[key] === undefined ? delete headers[key] : {}));
113
- const initOverrideFn = typeof initOverrides === "function" ? initOverrides : () => __awaiter(this, void 0, void 0, function* () { return initOverrides; });
114
- const initParams = {
115
- method: context.method,
116
- headers,
117
- body: context.body,
118
- dispatcher: this.configuration.agent,
119
- };
120
- const overriddenInit = Object.assign(Object.assign({}, initParams), (yield initOverrideFn({
121
- init: initParams,
122
- context,
123
- })));
124
- const init = Object.assign(Object.assign({}, overriddenInit), { body: overriddenInit.body instanceof FormData ||
125
- overriddenInit.body instanceof URLSearchParams ||
126
- overriddenInit.body instanceof Blob
127
- ? overriddenInit.body
128
- : JSON.stringify(overriddenInit.body) });
129
- return { url, init };
130
- });
131
- }
132
- }
133
- /**
134
- * @private
135
- */
136
- export const COLLECTION_FORMATS = {
137
- csv: ",",
138
- ssv: " ",
139
- tsv: "\t",
140
- pipes: "|",
141
- };
142
- /**
143
- * @private
144
- */
145
- function querystring(params) {
146
- return Object.keys(params)
147
- .map((key) => querystringSingleKey(key, params[key]))
148
- .filter((part) => part.length > 0)
149
- .join("&");
150
- }
151
- function querystringSingleKey(key, value) {
152
- if (value instanceof Array) {
153
- const multiValue = value
154
- .map((singleValue) => encodeURIComponent(String(singleValue)))
155
- .join(`&${encodeURIComponent(key)}=`);
156
- return `${encodeURIComponent(key)}=${multiValue}`;
157
- }
158
- return `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`;
159
- }
160
- /**
161
- * @private
162
- */
163
- export function validateRequiredRequestParams(requestParameters, keys) {
164
- keys.forEach((key) => {
165
- if (requestParameters[key] === null || requestParameters[key] === undefined) {
166
- throw new RequiredError(key, `Required parameter requestParameters.${key} was null or undefined.`);
167
- }
168
- });
169
- }
170
- /**
171
- * @private
172
- */
173
- export function applyQueryParams(requestParameters, keys) {
174
- return keys.reduce((acc, { key, config, }) => {
175
- let value;
176
- if (config.isArray) {
177
- if (config.isCollectionFormatMulti) {
178
- value = requestParameters[key];
179
- }
180
- else {
181
- value = requestParameters[key].join(COLLECTION_FORMATS[config.collectionFormat]);
182
- }
183
- }
184
- else {
185
- if (requestParameters[key] !== undefined) {
186
- value = requestParameters[key];
187
- }
188
- }
189
- return value !== undefined ? Object.assign(Object.assign({}, acc), { [key]: value }) : acc;
190
- }, {});
191
- }
192
- /**
193
- * @private
194
- */
195
- export function parseFormParam(originalValue) {
196
- return __awaiter(this, void 0, void 0, function* () {
197
- let value = originalValue;
198
- value = typeof value == "number" || typeof value == "boolean" ? "" + value : value;
199
- return value;
200
- });
201
- }
@@ -1,106 +0,0 @@
1
- import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
2
- import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
3
- import * as core from "../../../../core/index.mjs";
4
- import * as Management from "../../../index.mjs";
5
- export declare namespace OrganizationTemplatesClient {
6
- type Options = BaseClientOptions;
7
- interface RequestOptions extends BaseRequestOptions {
8
- }
9
- }
10
- export declare class OrganizationTemplatesClient {
11
- protected readonly _options: NormalizedClientOptionsWithAuth<OrganizationTemplatesClient.Options>;
12
- constructor(options: OrganizationTemplatesClient.Options);
13
- /**
14
- * Retrieve a list of Organization Templates. This endpoint supports Checkpoint pagination. Results are returned in a stable order, sorted by their identifier (`id`) in ascending order.
15
- *
16
- * @param {Management.ListOrganizationTemplatesRequestParameters} request
17
- * @param {OrganizationTemplatesClient.RequestOptions} requestOptions - Request-specific configuration.
18
- *
19
- * @throws {@link Management.BadRequestError}
20
- * @throws {@link Management.UnauthorizedError}
21
- * @throws {@link Management.ForbiddenError}
22
- * @throws {@link Management.TooManyRequestsError}
23
- *
24
- * @example
25
- * await client.organizationTemplates.list({
26
- * from: "from",
27
- * take: 1
28
- * })
29
- */
30
- list(request?: Management.ListOrganizationTemplatesRequestParameters, requestOptions?: OrganizationTemplatesClient.RequestOptions): Promise<core.Page<Management.OrganizationTemplate, Management.ListOrganizationTemplatesPaginatedResponseContent>>;
31
- /**
32
- * Create an Organization Template.
33
- *
34
- * @param {Management.CreateOrganizationTemplateRequestContent} request
35
- * @param {OrganizationTemplatesClient.RequestOptions} requestOptions - Request-specific configuration.
36
- *
37
- * @throws {@link Management.BadRequestError}
38
- * @throws {@link Management.UnauthorizedError}
39
- * @throws {@link Management.ForbiddenError}
40
- * @throws {@link Management.ConflictError}
41
- * @throws {@link Management.TooManyRequestsError}
42
- *
43
- * @example
44
- * await client.organizationTemplates.create({
45
- * name: "name",
46
- * organization_deletion_behavior: "allow",
47
- * enforce_permission_ceiling: true,
48
- * enforce_self_assignment_restriction: true
49
- * })
50
- */
51
- create(request: Management.CreateOrganizationTemplateRequestContent, requestOptions?: OrganizationTemplatesClient.RequestOptions): core.HttpResponsePromise<Management.OrganizationTemplate>;
52
- private __create;
53
- /**
54
- * Retrieve details about a single Organization Template specified by ID.
55
- *
56
- * @param {string} id - Organization Template identifier.
57
- * @param {OrganizationTemplatesClient.RequestOptions} requestOptions - Request-specific configuration.
58
- *
59
- * @throws {@link Management.UnauthorizedError}
60
- * @throws {@link Management.ForbiddenError}
61
- * @throws {@link Management.NotFoundError}
62
- * @throws {@link Management.TooManyRequestsError}
63
- *
64
- * @example
65
- * await client.organizationTemplates.get("id")
66
- */
67
- get(id: string, requestOptions?: OrganizationTemplatesClient.RequestOptions): core.HttpResponsePromise<Management.OrganizationTemplate>;
68
- private __get;
69
- /**
70
- * Update the details of a specific Organization Template.
71
- *
72
- * @param {string} id - Organization Template identifier.
73
- * @param {Management.UpdateOrganizationTemplateRequestContent} request
74
- * @param {OrganizationTemplatesClient.RequestOptions} requestOptions - Request-specific configuration.
75
- *
76
- * @throws {@link Management.BadRequestError}
77
- * @throws {@link Management.UnauthorizedError}
78
- * @throws {@link Management.ForbiddenError}
79
- * @throws {@link Management.NotFoundError}
80
- * @throws {@link Management.TooManyRequestsError}
81
- *
82
- * @example
83
- * await client.organizationTemplates.update("id")
84
- */
85
- update(id: string, request?: Management.UpdateOrganizationTemplateRequestContent, requestOptions?: OrganizationTemplatesClient.RequestOptions): core.HttpResponsePromise<Management.OrganizationTemplate>;
86
- private __update;
87
- /**
88
- * Retrieve a list of organizations assigned to an Organization Template. This endpoint supports Checkpoint pagination. Results are returned in a stable order, sorted by their identifier (`id`) in ascending order.
89
- *
90
- * @param {string} id - The ID of the organization template.
91
- * @param {Management.ListTemplateOrganizationsRequestParameters} request
92
- * @param {OrganizationTemplatesClient.RequestOptions} requestOptions - Request-specific configuration.
93
- *
94
- * @throws {@link Management.BadRequestError}
95
- * @throws {@link Management.UnauthorizedError}
96
- * @throws {@link Management.ForbiddenError}
97
- * @throws {@link Management.TooManyRequestsError}
98
- *
99
- * @example
100
- * await client.organizationTemplates.listOrganizations("id", {
101
- * from: "from",
102
- * take: 1
103
- * })
104
- */
105
- listOrganizations(id: string, request?: Management.ListTemplateOrganizationsRequestParameters, requestOptions?: OrganizationTemplatesClient.RequestOptions): Promise<core.Page<Management.OrganizationTemplateAssignedOrganization, Management.ListTemplateOrganizationsPaginatedResponseContent>>;
106
- }