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.
Files changed (160) 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 +3 -0
  11. package/dist/cjs/management/Client.js +45 -40
  12. package/dist/cjs/management/api/errors/UnprocessableEntityError.d.ts +5 -0
  13. package/dist/cjs/management/api/errors/UnprocessableEntityError.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 +91 -0
  17. package/dist/cjs/management/api/resources/connections/client/Client.d.ts +2 -0
  18. package/dist/cjs/management/api/resources/connections/client/Client.js +6 -0
  19. package/dist/cjs/management/api/resources/connections/resources/scimConfiguration/client/Client.d.ts +1 -0
  20. package/dist/cjs/management/api/resources/connections/resources/scimConfiguration/client/Client.js +3 -0
  21. package/dist/cjs/management/api/resources/index.d.ts +1 -0
  22. package/dist/cjs/management/api/resources/index.js +2 -1
  23. package/dist/cjs/management/api/resources/keys/resources/networkAcls/client/Client.d.ts +17 -0
  24. package/dist/cjs/management/api/resources/keys/resources/networkAcls/client/Client.js +60 -0
  25. package/dist/cjs/management/api/resources/organizationTemplates/client/Client.d.ts +106 -0
  26. package/dist/cjs/management/api/resources/organizationTemplates/client/Client.js +411 -0
  27. package/dist/cjs/management/api/resources/organizationTemplates/client/index.d.ts +1 -0
  28. package/dist/cjs/management/api/resources/organizationTemplates/client/index.js +2 -0
  29. package/dist/cjs/management/api/resources/organizationTemplates/exports.d.ts +2 -0
  30. package/dist/cjs/management/api/resources/organizationTemplates/exports.js +21 -0
  31. package/dist/cjs/management/api/resources/organizationTemplates/index.d.ts +1 -0
  32. package/dist/cjs/{lib → management/api/resources/organizationTemplates}/index.js +1 -2
  33. package/dist/cjs/management/api/resources/organizations/client/Client.d.ts +3 -0
  34. package/dist/cjs/management/api/resources/organizations/client/Client.js +7 -2
  35. package/dist/cjs/management/api/resources/organizations/resources/index.d.ts +1 -0
  36. package/dist/cjs/management/api/resources/organizations/resources/index.js +2 -1
  37. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/client/Client.d.ts +63 -0
  38. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/client/Client.js +232 -0
  39. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/client/index.d.ts +1 -0
  40. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/client/index.js +2 -0
  41. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/exports.d.ts +2 -0
  42. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/exports.js +21 -0
  43. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/index.d.ts +1 -0
  44. package/dist/cjs/management/api/resources/organizations/resources/organizationTemplate/index.js +17 -0
  45. package/dist/cjs/management/api/resources/users/resources/organizations/client/Client.d.ts +17 -0
  46. package/dist/cjs/management/api/resources/users/resources/organizations/client/Client.js +19 -0
  47. package/dist/cjs/management/api/types/types.d.ts +8896 -2027
  48. package/dist/cjs/management/api/types/types.js +1455 -166
  49. package/dist/cjs/management/version.d.ts +1 -1
  50. package/dist/cjs/management/version.js +1 -1
  51. package/dist/cjs/management/wrapper/ManagementClient.d.ts +9 -2
  52. package/dist/cjs/management/wrapper/ManagementClient.js +0 -1
  53. package/dist/cjs/management/wrapper/token-provider.d.ts +4 -2
  54. package/dist/cjs/management/wrapper/token-provider.js +142 -11
  55. package/dist/cjs/utils.d.ts +0 -18
  56. package/dist/cjs/utils.js +1 -32
  57. package/dist/esm/index.d.mts +0 -2
  58. package/dist/esm/index.mjs +0 -2
  59. package/dist/esm/lib/errors.d.mts +0 -18
  60. package/dist/esm/lib/errors.mjs +0 -22
  61. package/dist/esm/lib/middleware/auth0-client-telemetry.d.mts +3 -7
  62. package/dist/esm/lib/middleware/auth0-client-telemetry.mjs +1 -25
  63. package/dist/esm/lib/models.d.mts +0 -24
  64. package/dist/esm/lib/models.mjs +1 -49
  65. package/dist/esm/management/Client.d.mts +3 -0
  66. package/dist/esm/management/Client.mjs +5 -0
  67. package/dist/esm/management/api/errors/UnprocessableEntityError.d.mts +5 -0
  68. package/dist/esm/management/api/errors/UnprocessableEntityError.mjs +17 -0
  69. package/dist/esm/management/api/errors/index.d.mts +1 -0
  70. package/dist/esm/management/api/errors/index.mjs +1 -0
  71. package/dist/esm/management/api/requests/requests.d.mts +91 -0
  72. package/dist/esm/management/api/resources/connections/client/Client.d.mts +2 -0
  73. package/dist/esm/management/api/resources/connections/client/Client.mjs +6 -0
  74. package/dist/esm/management/api/resources/connections/resources/scimConfiguration/client/Client.d.mts +1 -0
  75. package/dist/esm/management/api/resources/connections/resources/scimConfiguration/client/Client.mjs +3 -0
  76. package/dist/esm/management/api/resources/index.d.mts +1 -0
  77. package/dist/esm/management/api/resources/index.mjs +1 -0
  78. package/dist/esm/management/api/resources/keys/resources/networkAcls/client/Client.d.mts +17 -0
  79. package/dist/esm/management/api/resources/keys/resources/networkAcls/client/Client.mjs +60 -0
  80. package/dist/esm/management/api/resources/organizationTemplates/client/Client.d.mts +106 -0
  81. package/dist/esm/management/api/resources/organizationTemplates/client/Client.mjs +374 -0
  82. package/dist/esm/management/api/resources/organizationTemplates/client/index.d.mts +1 -0
  83. package/dist/esm/management/api/resources/organizationTemplates/client/index.mjs +1 -0
  84. package/dist/esm/management/api/resources/organizationTemplates/exports.d.mts +2 -0
  85. package/dist/esm/management/api/resources/organizationTemplates/exports.mjs +3 -0
  86. package/dist/esm/management/api/resources/organizationTemplates/index.d.mts +1 -0
  87. package/dist/esm/management/api/resources/organizationTemplates/index.mjs +1 -0
  88. package/dist/esm/management/api/resources/organizations/client/Client.d.mts +3 -0
  89. package/dist/esm/management/api/resources/organizations/client/Client.mjs +5 -0
  90. package/dist/esm/management/api/resources/organizations/resources/index.d.mts +1 -0
  91. package/dist/esm/management/api/resources/organizations/resources/index.mjs +1 -0
  92. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/client/Client.d.mts +63 -0
  93. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/client/Client.mjs +195 -0
  94. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/client/index.d.mts +1 -0
  95. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/client/index.mjs +1 -0
  96. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/exports.d.mts +2 -0
  97. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/exports.mjs +3 -0
  98. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/index.d.mts +1 -0
  99. package/dist/esm/management/api/resources/organizations/resources/organizationTemplate/index.mjs +1 -0
  100. package/dist/esm/management/api/resources/users/resources/organizations/client/Client.d.mts +17 -0
  101. package/dist/esm/management/api/resources/users/resources/organizations/client/Client.mjs +19 -0
  102. package/dist/esm/management/api/types/types.d.mts +8896 -2027
  103. package/dist/esm/management/api/types/types.mjs +1434 -150
  104. package/dist/esm/management/version.d.mts +1 -1
  105. package/dist/esm/management/version.mjs +1 -1
  106. package/dist/esm/management/wrapper/ManagementClient.d.mts +9 -2
  107. package/dist/esm/management/wrapper/ManagementClient.mjs +0 -1
  108. package/dist/esm/management/wrapper/token-provider.d.mts +4 -2
  109. package/dist/esm/management/wrapper/token-provider.mjs +142 -11
  110. package/dist/esm/utils.d.mts +0 -18
  111. package/dist/esm/utils.mjs +0 -30
  112. package/package.json +23 -2
  113. package/reference.md +688 -28
  114. package/dist/cjs/auth/backchannel.d.ts +0 -158
  115. package/dist/cjs/auth/backchannel.js +0 -135
  116. package/dist/cjs/auth/base-auth-api.d.ts +0 -41
  117. package/dist/cjs/auth/base-auth-api.js +0 -109
  118. package/dist/cjs/auth/client-authentication.d.ts +0 -27
  119. package/dist/cjs/auth/client-authentication.js +0 -82
  120. package/dist/cjs/auth/database.d.ts +0 -157
  121. package/dist/cjs/auth/database.js +0 -94
  122. package/dist/cjs/auth/id-token-validator.d.ts +0 -18
  123. package/dist/cjs/auth/id-token-validator.js +0 -158
  124. package/dist/cjs/auth/index.d.ts +0 -65
  125. package/dist/cjs/auth/index.js +0 -80
  126. package/dist/cjs/auth/oauth.d.ts +0 -462
  127. package/dist/cjs/auth/oauth.js +0 -280
  128. package/dist/cjs/auth/passwordless.d.ts +0 -165
  129. package/dist/cjs/auth/passwordless.js +0 -173
  130. package/dist/cjs/auth/tokenExchange.d.ts +0 -166
  131. package/dist/cjs/auth/tokenExchange.js +0 -74
  132. package/dist/cjs/lib/index.d.ts +0 -3
  133. package/dist/cjs/lib/runtime.d.ts +0 -61
  134. package/dist/cjs/lib/runtime.js +0 -222
  135. package/dist/cjs/userinfo/index.d.ts +0 -87
  136. package/dist/cjs/userinfo/index.js +0 -104
  137. package/dist/esm/auth/backchannel.d.mts +0 -158
  138. package/dist/esm/auth/backchannel.mjs +0 -131
  139. package/dist/esm/auth/base-auth-api.d.mts +0 -41
  140. package/dist/esm/auth/base-auth-api.mjs +0 -103
  141. package/dist/esm/auth/client-authentication.d.mts +0 -27
  142. package/dist/esm/auth/client-authentication.mjs +0 -45
  143. package/dist/esm/auth/database.d.mts +0 -157
  144. package/dist/esm/auth/database.mjs +0 -90
  145. package/dist/esm/auth/id-token-validator.d.mts +0 -18
  146. package/dist/esm/auth/id-token-validator.mjs +0 -120
  147. package/dist/esm/auth/index.d.mts +0 -65
  148. package/dist/esm/auth/index.mjs +0 -60
  149. package/dist/esm/auth/oauth.d.mts +0 -462
  150. package/dist/esm/auth/oauth.mjs +0 -276
  151. package/dist/esm/auth/passwordless.d.mts +0 -165
  152. package/dist/esm/auth/passwordless.mjs +0 -169
  153. package/dist/esm/auth/tokenExchange.d.mts +0 -166
  154. package/dist/esm/auth/tokenExchange.mjs +0 -70
  155. package/dist/esm/lib/index.d.mts +0 -3
  156. package/dist/esm/lib/index.mjs +0 -2
  157. package/dist/esm/lib/runtime.d.mts +0 -61
  158. package/dist/esm/lib/runtime.mjs +0 -201
  159. package/dist/esm/userinfo/index.d.mts +0 -87
  160. package/dist/esm/userinfo/index.mjs +0 -98
@@ -1,276 +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, VoidApiResponse, validateRequiredRequestParams } from "../lib/runtime.mjs";
11
- import { BaseAuthAPI, grant } from "./base-auth-api.mjs";
12
- import { IDTokenValidator } from "./id-token-validator.mjs";
13
- import { mtlsPrefix } from "../utils.mjs";
14
- export var SUBJECT_TOKEN_TYPES;
15
- (function (SUBJECT_TOKEN_TYPES) {
16
- /**
17
- * Constant representing the subject type for a refresh token.
18
- * This is used in OAuth 2.0 token exchange to specify that the token being exchanged is a refresh token.
19
- *
20
- * @see {@link https://tools.ietf.org/html/rfc8693#section-3.1 RFC 8693 Section 3.1}
21
- */
22
- SUBJECT_TOKEN_TYPES["REFRESH_TOKEN"] = "urn:ietf:params:oauth:token-type:refresh_token";
23
- /**
24
- * Constant representing the subject type for a access token.
25
- * This is used in OAuth 2.0 token exchange to specify that the token being exchanged is an access token.
26
- *
27
- * @see {@link https://tools.ietf.org/html/rfc8693#section-3.1 RFC 8693 Section 3.1}
28
- */
29
- SUBJECT_TOKEN_TYPES["ACCESS_TOKEN"] = "urn:ietf:params:oauth:token-type:access_token";
30
- })(SUBJECT_TOKEN_TYPES || (SUBJECT_TOKEN_TYPES = {}));
31
- export const TOKEN_FOR_CONNECTION_GRANT_TYPE = "urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token";
32
- /**
33
- * @deprecated Use {@link SUBJECT_TOKEN_TYPES.REFRESH_TOKEN} instead.
34
- */
35
- export const TOKEN_FOR_CONNECTION_TOKEN_TYPE = "urn:ietf:params:oauth:token-type:refresh_token";
36
- export const TOKEN_FOR_CONNECTION_REQUESTED_TOKEN_TYPE = "http://auth0.com/oauth/token-type/federated-connection-access-token";
37
- export const TOKEN_URL = "/oauth/token";
38
- /**
39
- * OAuth 2.0 flows.
40
- */
41
- export class OAuth extends BaseAuthAPI {
42
- constructor(options) {
43
- super(Object.assign(Object.assign({}, options), { domain: options.useMTLS ? `${mtlsPrefix}.${options.domain}` : options.domain }));
44
- this.idTokenValidator = new IDTokenValidator(options);
45
- }
46
- /**
47
- * This is the flow that regular web apps use to access an API.
48
- *
49
- * Use this endpoint to exchange an Authorization Code for a Token.
50
- *
51
- * See: https://auth0.com/docs/api/authentication#authorization-code-flow44
52
- *
53
- * @example
54
- * ```js
55
- * const auth0 = new AuthenticationApi({
56
- * domain: 'my-domain.auth0.com',
57
- * clientId: 'myClientId',
58
- * clientSecret: 'myClientSecret'
59
- * });
60
- *
61
- * await auth0.oauth.authorizationCodeGrant({ code: 'mycode' });
62
- * ```
63
- */
64
- authorizationCodeGrant(bodyParameters_1) {
65
- return __awaiter(this, arguments, void 0, function* (bodyParameters, options = {}) {
66
- validateRequiredRequestParams(bodyParameters, ["code"]);
67
- return grant("authorization_code", yield this.addClientAuthentication(bodyParameters), options, this.clientId, this.idTokenValidator, this.request.bind(this));
68
- });
69
- }
70
- /**
71
- * PKCE was originally designed to protect the authorization code flow in mobile apps,
72
- * but its ability to prevent authorization code injection makes it useful for every type of OAuth client,
73
- * even web apps that use client authentication.
74
- *
75
- * See: https://auth0.com/docs/api/authentication#authorization-code-flow-with-pkce45
76
- *
77
- * @example
78
- * ```js
79
- * const auth0 = new AuthenticationApi({
80
- * domain: 'my-domain.auth0.com',
81
- * clientId: 'myClientId',
82
- * clientSecret: 'myClientSecret'
83
- * });
84
- *
85
- * await auth0.oauth.authorizationCodeGrantWithPKCE({
86
- * code: 'mycode',
87
- * code_verifier: 'mycodeverifier'
88
- * });
89
- * ```
90
- */
91
- authorizationCodeGrantWithPKCE(bodyParameters_1) {
92
- return __awaiter(this, arguments, void 0, function* (bodyParameters, options = {}) {
93
- validateRequiredRequestParams(bodyParameters, ["code", "code_verifier"]);
94
- return grant("authorization_code", yield this.addClientAuthentication(bodyParameters), options, this.clientId, this.idTokenValidator, this.request.bind(this));
95
- });
96
- }
97
- /**
98
- * This is the OAuth 2.0 grant that server processes use to access an API.
99
- *
100
- * Use this endpoint to directly request an Access Token by using the Client's credentials
101
- * (a Client ID and a Client Secret or a Client Assertion).
102
- *
103
- * See: https://auth0.com/docs/api/authentication#client-credentials-flow
104
- *
105
- * @example
106
- * ```js
107
- * const auth0 = new AuthenticationApi({
108
- * domain: 'my-domain.auth0.com',
109
- * clientId: 'myClientId',
110
- * clientSecret: 'myClientSecret'
111
- * });
112
- *
113
- * await auth0.oauth.clientCredentialsGrant({ audience: 'myaudience' });
114
- * ```
115
- */
116
- clientCredentialsGrant(bodyParameters_1) {
117
- return __awaiter(this, arguments, void 0, function* (bodyParameters, options = {}) {
118
- validateRequiredRequestParams(bodyParameters, ["audience"]);
119
- return grant("client_credentials", yield this.addClientAuthentication(bodyParameters), options, this.clientId, this.idTokenValidator, this.request.bind(this));
120
- });
121
- }
122
- /**
123
- * This is the OAuth 2.0 extension that allows to initiate an OAuth flow from the backchannel instead of by building a URL.
124
- *
125
- *
126
- * See: https://www.rfc-editor.org/rfc/rfc9126.html
127
- *
128
- * @example
129
- * ```js
130
- * const auth0 = new AuthenticationApi({
131
- * domain: 'my-domain.auth0.com',
132
- * clientId: 'myClientId',
133
- * clientSecret: 'myClientSecret'
134
- * });
135
- *
136
- * await auth0.oauth.pushedAuthorization({ response_type: 'id_token', redirect_uri: 'http://localhost' });
137
- * ```
138
- */
139
- pushedAuthorization(bodyParameters_1) {
140
- return __awaiter(this, arguments, void 0, function* (bodyParameters, options = {}) {
141
- validateRequiredRequestParams(bodyParameters, ["client_id", "response_type", "redirect_uri"]);
142
- const bodyParametersWithClientAuthentication = yield this.addClientAuthentication(bodyParameters);
143
- const response = yield this.request({
144
- path: "/oauth/par",
145
- method: "POST",
146
- headers: {
147
- "Content-Type": "application/x-www-form-urlencoded",
148
- },
149
- body: new URLSearchParams(Object.assign({ client_id: this.clientId }, bodyParametersWithClientAuthentication)),
150
- }, options.initOverrides);
151
- return JSONApiResponse.fromResponse(response);
152
- });
153
- }
154
- /**
155
- * This information is typically received from a highly trusted public client like a SPA*.
156
- * (<strong>*Note:</string> For single-page applications and native/mobile apps, we recommend using web flows instead.)
157
- *
158
- * See: https://auth0.com/docs/api/authentication#resource-owner-password
159
- *
160
- * @example
161
- * ```js
162
- * const auth0 = new AuthenticationApi({
163
- * domain: 'my-domain.auth0.com',
164
- * clientId: 'myClientId'
165
- * clientSecret: 'myClientSecret'
166
- * });
167
- *
168
- * await auth0.oauth.passwordGrant({
169
- * username: 'myusername@example.com',
170
- * password: 'mypassword'
171
- * },
172
- * { initOverrides: { headers: { 'auth0-forwarded-for': 'END.USER.IP.123' } } }
173
- * );
174
- * ```
175
- *
176
- * Set the'auth0-forwarded-for' header to the end-user IP as a string value if you want
177
- * brute-force protection to work in server-side scenarios.
178
- *
179
- * See https://auth0.com/docs/get-started/authentication-and-authorization-flow/avoid-common-issues-with-resource-owner-password-flow-and-attack-protection
180
- *
181
- */
182
- passwordGrant(bodyParameters_1) {
183
- return __awaiter(this, arguments, void 0, function* (bodyParameters, options = {}) {
184
- validateRequiredRequestParams(bodyParameters, ["username", "password"]);
185
- return grant(bodyParameters.realm ? "http://auth0.com/oauth/grant-type/password-realm" : "password", yield this.addClientAuthentication(bodyParameters), options, this.clientId, this.idTokenValidator, this.request.bind(this));
186
- });
187
- }
188
- /**
189
- * Use this endpoint to refresh an Access Token using the Refresh Token you got during authorization.
190
- *
191
- * See: https://auth0.com/docs/api/authentication#refresh-token
192
- *
193
- * @example
194
- * ```js
195
- * const auth0 = new AuthenticationApi({
196
- * domain: 'my-domain.auth0.com',
197
- * clientId: 'myClientId'
198
- * clientSecret: 'myClientSecret'
199
- * });
200
- *
201
- * await auth0.oauth.refreshTokenGrant({ refresh_token: 'myrefreshtoken' })
202
- * ```
203
- */
204
- refreshTokenGrant(bodyParameters_1) {
205
- return __awaiter(this, arguments, void 0, function* (bodyParameters, options = {}) {
206
- validateRequiredRequestParams(bodyParameters, ["refresh_token"]);
207
- return grant("refresh_token", yield this.addClientAuthentication(bodyParameters), options, this.clientId, this.idTokenValidator, this.request.bind(this));
208
- });
209
- }
210
- /**
211
- * Use this endpoint to invalidate a Refresh Token if it has been compromised.
212
- *
213
- * The behaviour of this endpoint depends on the state of the <a href="https://auth0.com/docs/secure/tokens/refresh-tokens/revoke-refresh-tokens#refresh-tokens-and-grants">Refresh Token Revocation Deletes Grant</a> toggle.
214
- * If this toggle is enabled, then each revocation request invalidates not only the specific token, but all other tokens based on the same authorization grant.
215
- * This means that all Refresh Tokens that have been issued for the same user, application, and audience will be revoked.
216
- * If this toggle is disabled, then only the refresh token is revoked, while the grant is left intact.
217
- *
218
- * See: https://auth0.com/docs/api/authentication#revoke-refresh-token
219
- *
220
- * @example
221
- * ```js
222
- * const auth0 = new AuthenticationApi({
223
- * domain: 'my-domain.auth0.com',
224
- * clientId: 'myClientId'
225
- * clientSecret: 'myClientSecret'
226
- * });
227
- *
228
- * await auth0.oauth.revokeRefreshToken({ token: 'myrefreshtoken' })
229
- * ```
230
- */
231
- revokeRefreshToken(bodyParameters_1) {
232
- return __awaiter(this, arguments, void 0, function* (bodyParameters, options = {}) {
233
- validateRequiredRequestParams(bodyParameters, ["token"]);
234
- const response = yield this.request({
235
- path: "/oauth/revoke",
236
- method: "POST",
237
- headers: {
238
- "Content-Type": "application/json",
239
- },
240
- body: yield this.addClientAuthentication(Object.assign({ client_id: this.clientId }, bodyParameters)),
241
- }, options.initOverrides);
242
- return VoidApiResponse.fromResponse(response);
243
- });
244
- }
245
- /**
246
- * Exchanges a subject token for an access token for the connection.
247
- *
248
- * The request body includes:
249
- * - client_id (and client_secret/client_assertion via addClientAuthentication)
250
- * - grant_type set to `urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token`
251
- * - subject_token: the token to exchange
252
- * - subject_token_type: the type of token being exchanged. Defaults to refresh tokens (`urn:ietf:params:oauth:token-type:refresh_token`).
253
- * - requested_token_type (`http://auth0.com/oauth/token-type/federated-connection-access-token`) indicating that a federated connection access token is desired
254
- * - connection name and an optional `login_hint` if provided
255
- *
256
- * @param bodyParameters - The options to retrieve a token for a connection.
257
- * @returns A promise with the token response data.
258
- * @throws An error if the exchange fails.
259
- */
260
- tokenForConnection(bodyParameters_1) {
261
- return __awaiter(this, arguments, void 0, function* (bodyParameters, options = {}) {
262
- validateRequiredRequestParams(bodyParameters, ["connection", "subject_token"]);
263
- const body = Object.assign(Object.assign({ subject_token_type: SUBJECT_TOKEN_TYPES.REFRESH_TOKEN }, bodyParameters), { grant_type: TOKEN_FOR_CONNECTION_GRANT_TYPE, requested_token_type: TOKEN_FOR_CONNECTION_REQUESTED_TOKEN_TYPE });
264
- yield this.addClientAuthentication(body);
265
- const response = yield this.request({
266
- path: TOKEN_URL,
267
- method: "POST",
268
- headers: {
269
- "Content-Type": "application/x-www-form-urlencoded",
270
- },
271
- body: new URLSearchParams(body),
272
- }, options.initOverrides);
273
- return JSONApiResponse.fromResponse(response);
274
- });
275
- }
276
- }
@@ -1,165 +0,0 @@
1
- import { InitOverride, JSONApiResponse, VoidApiResponse } from "../lib/runtime.mjs";
2
- import { BaseAuthAPI, AuthenticationClientOptions } from "./base-auth-api.mjs";
3
- import { ClientCredentials, GrantOptions, TokenSet } from "./oauth.mjs";
4
- export interface SendEmailLinkRequest {
5
- /**
6
- * The user's email address
7
- */
8
- email: string;
9
- /**
10
- * Use `link` to send a link or `code` to send a verification code.
11
- * If omitted, a `link` will be sent.
12
- */
13
- send?: "link";
14
- /**
15
- * Append or override the link parameters (like `scope`, `redirect_uri`, `protocol`, `response_type`),
16
- * when you send a link using email.
17
- */
18
- authParams?: Record<string, unknown>;
19
- }
20
- export interface SendEmailCodeRequest {
21
- /**
22
- * The user's email address
23
- */
24
- email: string;
25
- /**
26
- * Use `link` to send a link or `code` to send a verification code.
27
- * If omitted, a `link` will be sent.
28
- */
29
- send?: "code";
30
- }
31
- export type SendEmailRequest = SendEmailLinkRequest | SendEmailCodeRequest;
32
- export interface SendSmsRequest {
33
- /**
34
- * The users phone number.
35
- */
36
- phone_number: string;
37
- }
38
- export interface LoginWithEmailRequest extends ClientCredentials {
39
- /**
40
- * The user's email address.
41
- */
42
- email: string;
43
- /**
44
- * The user's verification code.
45
- */
46
- code: string;
47
- /**
48
- * API Identifier of the API for which you want to get an Access Token.
49
- */
50
- audience?: string;
51
- /**
52
- * Use openid to get an ID Token, or openid profile email to also include user profile information in the ID Token.
53
- */
54
- scope?: string;
55
- }
56
- export interface LoginWithSMSRequest extends Omit<LoginWithEmailRequest, "email"> {
57
- /**
58
- * The user's phone number.
59
- */
60
- phone_number: string;
61
- }
62
- /**
63
- * Handles passwordless flows using Email and SMS.
64
- */
65
- export declare class Passwordless extends BaseAuthAPI {
66
- private idTokenValidator;
67
- constructor(configuration: AuthenticationClientOptions);
68
- /**
69
- * Start passwordless flow sending an email.
70
- *
71
- * Given the user `email` address, it will send an email with:
72
- *
73
- * <ul>
74
- * <li>A link (default, `send:"link"`). You can then authenticate with this
75
- * user opening the link and he will be automatically logged in to the
76
- * application. Optionally, you can append/override parameters to the link
77
- * (like `scope`, `redirect_uri`, `protocol`, `response_type`, etc.) using
78
- * `authParams` object.
79
- * </li>
80
- * <li>
81
- * A verification code (`send:"code"`). You can then authenticate with
82
- * this user using the `/oauth/token` endpoint specifying `email` as
83
- * `username` and `code` as `password`.
84
- * </li>
85
- * </ul>
86
- *
87
- * See: https://auth0.com/docs/api/authentication#get-code-or-link
88
- *
89
- * @example
90
- * ```js
91
- * const auth0 = new AuthenticationApi({
92
- * domain: 'my-domain.auth0.com',
93
- * clientId: 'myClientId',
94
- * clientSecret: 'myClientSecret'
95
- * });
96
- *
97
- * await auth0.passwordless.sendEmail({
98
- * email: '{EMAIL}',
99
- * send: 'link',
100
- * authParams: {} // Optional auth params.
101
- * });
102
- * ```
103
- */
104
- sendEmail(bodyParameters: SendEmailRequest, initOverrides?: InitOverride): Promise<VoidApiResponse>;
105
- /**
106
- * Start passwordless flow sending an SMS.
107
- *
108
- * Given the user `phone_number`, it will send a SMS message with a
109
- * verification code. You can then authenticate with this user using the
110
- * `/oauth/token` endpoint specifying `phone_number` as `username` and `code` as
111
- * `password`:
112
- *
113
- * See: https://auth0.com/docs/api/authentication#get-code-or-link
114
- *
115
- * @example
116
- * ```js
117
- * const auth0 = new AuthenticationApi({
118
- * domain: 'my-domain.auth0.com',
119
- * clientId: 'myClientId',
120
- * clientSecret: 'myClientSecret'
121
- * });
122
- *
123
- * await auth0.passwordless.sendSMS({
124
- * phone_number: '{PHONE}'
125
- * });
126
- * ```
127
- */
128
- sendSMS(bodyParameters: SendSmsRequest, initOverrides?: InitOverride): Promise<VoidApiResponse>;
129
- /**
130
- * Once you have a verification code, use this endpoint to login the user with their email and verification code.
131
- *
132
- * @example
133
- * ```js
134
- * const auth0 = new AuthenticationApi({
135
- * domain: 'my-domain.auth0.com',
136
- * clientId: 'myClientId',
137
- * clientSecret: 'myClientSecret'
138
- * });
139
- *
140
- * await auth0.passwordless.loginWithEmail({
141
- * email: 'foo@example.com',
142
- * code: 'ABC123'
143
- * });
144
- * ```
145
- */
146
- loginWithEmail(bodyParameters: LoginWithEmailRequest, options?: GrantOptions): Promise<JSONApiResponse<TokenSet>>;
147
- /**
148
- * Once you have a verification code, use this endpoint to login the user with their phone number and verification code.
149
- *
150
- * @example
151
- * ```js
152
- * const auth0 = new AuthenticationApi({
153
- * domain: 'my-domain.auth0.com',
154
- * clientId: 'myClientId',
155
- * clientSecret: 'myClientSecret'
156
- * });
157
- *
158
- * await auth0.passwordless.loginWithSMS({
159
- * phone_number: '0777777777',
160
- * code: 'ABC123'
161
- * });
162
- * ```
163
- */
164
- loginWithSMS(bodyParameters: LoginWithSMSRequest, options?: GrantOptions): Promise<JSONApiResponse<TokenSet>>;
165
- }
@@ -1,169 +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
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- import { VoidApiResponse, validateRequiredRequestParams } from "../lib/runtime.mjs";
22
- import { BaseAuthAPI, grant } from "./base-auth-api.mjs";
23
- import { IDTokenValidator } from "./id-token-validator.mjs";
24
- /**
25
- * Handles passwordless flows using Email and SMS.
26
- */
27
- export class Passwordless extends BaseAuthAPI {
28
- constructor(configuration) {
29
- super(configuration);
30
- this.idTokenValidator = new IDTokenValidator(configuration);
31
- }
32
- /**
33
- * Start passwordless flow sending an email.
34
- *
35
- * Given the user `email` address, it will send an email with:
36
- *
37
- * <ul>
38
- * <li>A link (default, `send:"link"`). You can then authenticate with this
39
- * user opening the link and he will be automatically logged in to the
40
- * application. Optionally, you can append/override parameters to the link
41
- * (like `scope`, `redirect_uri`, `protocol`, `response_type`, etc.) using
42
- * `authParams` object.
43
- * </li>
44
- * <li>
45
- * A verification code (`send:"code"`). You can then authenticate with
46
- * this user using the `/oauth/token` endpoint specifying `email` as
47
- * `username` and `code` as `password`.
48
- * </li>
49
- * </ul>
50
- *
51
- * See: https://auth0.com/docs/api/authentication#get-code-or-link
52
- *
53
- * @example
54
- * ```js
55
- * const auth0 = new AuthenticationApi({
56
- * domain: 'my-domain.auth0.com',
57
- * clientId: 'myClientId',
58
- * clientSecret: 'myClientSecret'
59
- * });
60
- *
61
- * await auth0.passwordless.sendEmail({
62
- * email: '{EMAIL}',
63
- * send: 'link',
64
- * authParams: {} // Optional auth params.
65
- * });
66
- * ```
67
- */
68
- sendEmail(bodyParameters, initOverrides) {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- validateRequiredRequestParams(bodyParameters, ["email"]);
71
- const response = yield this.request({
72
- path: "/passwordless/start",
73
- method: "POST",
74
- headers: {
75
- "Content-Type": "application/json",
76
- },
77
- body: yield this.addClientAuthentication(Object.assign({ client_id: this.clientId, connection: "email" }, bodyParameters)),
78
- }, initOverrides);
79
- return VoidApiResponse.fromResponse(response);
80
- });
81
- }
82
- /**
83
- * Start passwordless flow sending an SMS.
84
- *
85
- * Given the user `phone_number`, it will send a SMS message with a
86
- * verification code. You can then authenticate with this user using the
87
- * `/oauth/token` endpoint specifying `phone_number` as `username` and `code` as
88
- * `password`:
89
- *
90
- * See: https://auth0.com/docs/api/authentication#get-code-or-link
91
- *
92
- * @example
93
- * ```js
94
- * const auth0 = new AuthenticationApi({
95
- * domain: 'my-domain.auth0.com',
96
- * clientId: 'myClientId',
97
- * clientSecret: 'myClientSecret'
98
- * });
99
- *
100
- * await auth0.passwordless.sendSMS({
101
- * phone_number: '{PHONE}'
102
- * });
103
- * ```
104
- */
105
- sendSMS(bodyParameters, initOverrides) {
106
- return __awaiter(this, void 0, void 0, function* () {
107
- validateRequiredRequestParams(bodyParameters, ["phone_number"]);
108
- const response = yield this.request({
109
- path: "/passwordless/start",
110
- method: "POST",
111
- headers: {
112
- "Content-Type": "application/json",
113
- },
114
- body: yield this.addClientAuthentication(Object.assign({ client_id: this.clientId, connection: "sms" }, bodyParameters)),
115
- }, initOverrides);
116
- return VoidApiResponse.fromResponse(response);
117
- });
118
- }
119
- /**
120
- * Once you have a verification code, use this endpoint to login the user with their email and verification code.
121
- *
122
- * @example
123
- * ```js
124
- * const auth0 = new AuthenticationApi({
125
- * domain: 'my-domain.auth0.com',
126
- * clientId: 'myClientId',
127
- * clientSecret: 'myClientSecret'
128
- * });
129
- *
130
- * await auth0.passwordless.loginWithEmail({
131
- * email: 'foo@example.com',
132
- * code: 'ABC123'
133
- * });
134
- * ```
135
- */
136
- loginWithEmail(bodyParameters_1) {
137
- return __awaiter(this, arguments, void 0, function* (bodyParameters, options = {}) {
138
- validateRequiredRequestParams(bodyParameters, ["email", "code"]);
139
- const { email: username, code: otp } = bodyParameters, otherParams = __rest(bodyParameters, ["email", "code"]);
140
- return grant("http://auth0.com/oauth/grant-type/passwordless/otp", yield this.addClientAuthentication(Object.assign({ username,
141
- otp, realm: "email" }, otherParams)), options, this.clientId, this.idTokenValidator, this.request.bind(this));
142
- });
143
- }
144
- /**
145
- * Once you have a verification code, use this endpoint to login the user with their phone number and verification code.
146
- *
147
- * @example
148
- * ```js
149
- * const auth0 = new AuthenticationApi({
150
- * domain: 'my-domain.auth0.com',
151
- * clientId: 'myClientId',
152
- * clientSecret: 'myClientSecret'
153
- * });
154
- *
155
- * await auth0.passwordless.loginWithSMS({
156
- * phone_number: '0777777777',
157
- * code: 'ABC123'
158
- * });
159
- * ```
160
- */
161
- loginWithSMS(bodyParameters_1) {
162
- return __awaiter(this, arguments, void 0, function* (bodyParameters, options = {}) {
163
- validateRequiredRequestParams(bodyParameters, ["phone_number", "code"]);
164
- const { phone_number: username, code: otp } = bodyParameters, otherParams = __rest(bodyParameters, ["phone_number", "code"]);
165
- return grant("http://auth0.com/oauth/grant-type/passwordless/otp", yield this.addClientAuthentication(Object.assign({ username,
166
- otp, realm: "sms" }, otherParams)), options, this.clientId, this.idTokenValidator, this.request.bind(this));
167
- });
168
- }
169
- }