@auth0/auth0-spa-js 2.18.3 → 2.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/auth0-spa-js.development.js +427 -370
- package/dist/auth0-spa-js.development.js.map +1 -1
- package/dist/auth0-spa-js.production.esm.js +1 -1
- package/dist/auth0-spa-js.production.esm.js.map +1 -1
- package/dist/auth0-spa-js.production.js +1 -1
- package/dist/auth0-spa-js.production.js.map +1 -1
- package/dist/auth0-spa-js.worker.development.js +132 -81
- package/dist/auth0-spa-js.worker.development.js.map +1 -1
- package/dist/auth0-spa-js.worker.production.js +1 -1
- package/dist/auth0-spa-js.worker.production.js.map +1 -1
- package/dist/lib/auth0-spa-js.cjs.js +449 -393
- package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
- package/dist/typings/Auth0Client.d.ts +476 -439
- package/dist/typings/Auth0Client.utils.d.ts +90 -90
- package/dist/typings/MyAccountApiClient.d.ts +92 -92
- package/dist/typings/TokenExchange.d.ts +77 -77
- package/dist/typings/api.d.ts +33 -2
- package/dist/typings/cache/cache-localstorage.d.ts +7 -7
- package/dist/typings/cache/cache-manager.d.ts +69 -56
- package/dist/typings/cache/cache-memory.d.ts +4 -4
- package/dist/typings/cache/index.d.ts +4 -4
- package/dist/typings/cache/key-manifest.d.ts +12 -12
- package/dist/typings/cache/shared.d.ts +68 -68
- package/dist/typings/constants.d.ts +58 -58
- package/dist/typings/dpop/dpop.d.ts +17 -17
- package/dist/typings/dpop/storage.d.ts +27 -27
- package/dist/typings/dpop/utils.d.ts +15 -15
- package/dist/typings/errors.d.ts +96 -96
- package/dist/typings/fetcher.d.ts +54 -54
- package/dist/typings/global.d.ts +826 -819
- package/dist/typings/http.d.ts +11 -5
- package/dist/typings/index.d.ts +24 -24
- package/dist/typings/jwt.d.ts +21 -21
- package/dist/typings/lock.d.ts +32 -32
- package/dist/typings/mfa/MfaApiClient.d.ts +225 -225
- package/dist/typings/mfa/MfaContextManager.d.ts +79 -79
- package/dist/typings/mfa/constants.d.ts +23 -23
- package/dist/typings/mfa/errors.d.ts +117 -117
- package/dist/typings/mfa/index.d.ts +4 -4
- package/dist/typings/mfa/types.d.ts +181 -181
- package/dist/typings/mfa/utils.d.ts +23 -23
- package/dist/typings/promise-utils.d.ts +2 -2
- package/dist/typings/scope.d.ts +35 -35
- package/dist/typings/storage.d.ts +26 -26
- package/dist/typings/transaction-manager.d.ts +33 -33
- package/dist/typings/utils.d.ts +36 -36
- package/dist/typings/version.d.ts +2 -2
- package/dist/typings/worker/token.worker.d.ts +1 -1
- package/dist/typings/worker/worker.types.d.ts +27 -20
- package/dist/typings/worker/worker.utils.d.ts +13 -7
- package/package.json +2 -2
- package/src/Auth0Client.ts +73 -2
- package/src/api.ts +116 -2
- package/src/cache/cache-manager.ts +85 -9
- package/src/global.ts +8 -0
- package/src/http.ts +28 -21
- package/src/version.ts +1 -1
- package/src/worker/token.worker.ts +120 -5
- package/src/worker/worker.types.ts +17 -6
- package/src/worker/worker.utils.ts +18 -7
package/dist/typings/global.d.ts
CHANGED
|
@@ -1,819 +1,826 @@
|
|
|
1
|
-
import { ICache } from './cache';
|
|
2
|
-
import type { Dpop } from './dpop/dpop';
|
|
3
|
-
import { CompleteResponse } from './MyAccountApiClient';
|
|
4
|
-
/**
|
|
5
|
-
* Configuration option for automatic interactive error handling.
|
|
6
|
-
*
|
|
7
|
-
* - `'popup'`: SDK automatically opens Universal Login popup on MFA error
|
|
8
|
-
*/
|
|
9
|
-
export type InteractiveErrorHandler = 'popup';
|
|
10
|
-
export interface AuthorizationParams {
|
|
11
|
-
/**
|
|
12
|
-
* - `'page'`: displays the UI with a full page view
|
|
13
|
-
* - `'popup'`: displays the UI with a popup window
|
|
14
|
-
* - `'touch'`: displays the UI in a way that leverages a touch interface
|
|
15
|
-
* - `'wap'`: displays the UI with a "feature phone" type interface
|
|
16
|
-
*/
|
|
17
|
-
display?: 'page' | 'popup' | 'touch' | 'wap';
|
|
18
|
-
/**
|
|
19
|
-
* - `'none'`: do not prompt user for login or consent on reauthentication
|
|
20
|
-
* - `'login'`: prompt user for reauthentication
|
|
21
|
-
* - `'consent'`: prompt user for consent before processing request
|
|
22
|
-
* - `'select_account'`: prompt user to select an account
|
|
23
|
-
*/
|
|
24
|
-
prompt?: 'none' | 'login' | 'consent' | 'select_account';
|
|
25
|
-
/**
|
|
26
|
-
* Maximum allowable elapsed time (in seconds) since authentication.
|
|
27
|
-
* If the last time the user authenticated is greater than this value,
|
|
28
|
-
* the user must be reauthenticated.
|
|
29
|
-
*/
|
|
30
|
-
max_age?: string | number;
|
|
31
|
-
/**
|
|
32
|
-
* The space-separated list of language tags, ordered by preference.
|
|
33
|
-
* For example: `'fr-CA fr en'`.
|
|
34
|
-
*/
|
|
35
|
-
ui_locales?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Previously issued ID Token.
|
|
38
|
-
*/
|
|
39
|
-
id_token_hint?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Provides a hint to Auth0 as to what flow should be displayed.
|
|
42
|
-
* The default behavior is to show a login page but you can override
|
|
43
|
-
* this by passing 'signup' to show the signup page instead.
|
|
44
|
-
*
|
|
45
|
-
* This only affects the New Universal Login Experience.
|
|
46
|
-
*/
|
|
47
|
-
screen_hint?: 'signup' | 'login' | string;
|
|
48
|
-
/**
|
|
49
|
-
* The user's email address or other identifier. When your app knows
|
|
50
|
-
* which user is trying to authenticate, you can provide this parameter
|
|
51
|
-
* to pre-fill the email box or select the right session for sign-in.
|
|
52
|
-
*
|
|
53
|
-
* This currently only affects the classic Lock experience.
|
|
54
|
-
*/
|
|
55
|
-
login_hint?: string;
|
|
56
|
-
acr_values?: string;
|
|
57
|
-
/**
|
|
58
|
-
* The default scope to be used on authentication requests.
|
|
59
|
-
*
|
|
60
|
-
* This defaults to `profile email` if not set. If you are setting extra scopes and require
|
|
61
|
-
* `profile` and `email` to be included then you must include them in the provided scope.
|
|
62
|
-
*
|
|
63
|
-
* Note: The `openid` scope is **always applied** regardless of this setting.
|
|
64
|
-
*/
|
|
65
|
-
scope?: string;
|
|
66
|
-
/**
|
|
67
|
-
* The default audience to be used for requesting API access.
|
|
68
|
-
*/
|
|
69
|
-
audience?: string;
|
|
70
|
-
/**
|
|
71
|
-
* The name of the connection configured for your application.
|
|
72
|
-
* If null, it will redirect to the Auth0 Login Page and show
|
|
73
|
-
* the Login Widget.
|
|
74
|
-
*/
|
|
75
|
-
connection?: string;
|
|
76
|
-
/**
|
|
77
|
-
* The organization to log in to.
|
|
78
|
-
*
|
|
79
|
-
* This will specify an `organization` parameter in your user's login request.
|
|
80
|
-
*
|
|
81
|
-
* - If you provide an Organization ID (a string with the prefix `org_`), it will be validated against the `org_id` claim of your user's ID Token. The validation is case-sensitive.
|
|
82
|
-
* - If you provide an Organization Name (a string *without* the prefix `org_`), it will be validated against the `org_name` claim of your user's ID Token. The validation is case-insensitive.
|
|
83
|
-
* To use an Organization Name you must have "Allow Organization Names in Authentication API" switched on in your Auth0 settings dashboard.
|
|
84
|
-
* More information is available on the [Auth0 documentation portal](https://auth0.com/docs/manage-users/organizations/configure-organizations/use-org-name-authentication-api)
|
|
85
|
-
*
|
|
86
|
-
*/
|
|
87
|
-
organization?: string;
|
|
88
|
-
/**
|
|
89
|
-
* The Id of an invitation to accept. This is available from the user invitation URL that is given when participating in a user invitation flow.
|
|
90
|
-
*/
|
|
91
|
-
invitation?: string;
|
|
92
|
-
/**
|
|
93
|
-
* The default URL where Auth0 will redirect your browser to with
|
|
94
|
-
* the authentication result. It must be whitelisted in
|
|
95
|
-
* the "Allowed Callback URLs" field in your Auth0 Application's
|
|
96
|
-
* settings. If not provided here, it should be provided in the other
|
|
97
|
-
* methods that provide authentication.
|
|
98
|
-
*/
|
|
99
|
-
redirect_uri?: string;
|
|
100
|
-
/**
|
|
101
|
-
* Session transfer token from a native application for Native to Web SSO.
|
|
102
|
-
* When `sessionTransferTokenQueryParamName` is set, this is automatically
|
|
103
|
-
* extracted from the specified URL query parameter if present.
|
|
104
|
-
*
|
|
105
|
-
* @see https://auth0.com/docs/authenticate/single-sign-on/native-to-web
|
|
106
|
-
*/
|
|
107
|
-
session_transfer_token?: string;
|
|
108
|
-
/**
|
|
109
|
-
* If you need to send custom parameters to the Authorization Server,
|
|
110
|
-
* make sure to use the original parameter name.
|
|
111
|
-
*/
|
|
112
|
-
[key: string]: any;
|
|
113
|
-
}
|
|
114
|
-
export interface ClientAuthorizationParams extends Omit<AuthorizationParams, 'scope'> {
|
|
115
|
-
scope?: string | Record<string, string>;
|
|
116
|
-
}
|
|
117
|
-
interface BaseLoginOptions {
|
|
118
|
-
/**
|
|
119
|
-
* URL parameters that will be sent back to the Authorization Server. This can be known parameters
|
|
120
|
-
* defined by Auth0 or custom parameters that you define.
|
|
121
|
-
*/
|
|
122
|
-
authorizationParams?: AuthorizationParams;
|
|
123
|
-
}
|
|
124
|
-
export interface Auth0ClientOptions {
|
|
125
|
-
/**
|
|
126
|
-
* Your Auth0 account domain such as `'example.auth0.com'`,
|
|
127
|
-
* `'example.eu.auth0.com'` or , `'example.mycompany.com'`
|
|
128
|
-
* (when using [custom domains](https://auth0.com/docs/custom-domains))
|
|
129
|
-
*/
|
|
130
|
-
domain: string;
|
|
131
|
-
/**
|
|
132
|
-
* The issuer to be used for validation of JWTs, optionally defaults to the domain above
|
|
133
|
-
*/
|
|
134
|
-
issuer?: string;
|
|
135
|
-
/**
|
|
136
|
-
* The Client ID found on your Application settings page
|
|
137
|
-
*/
|
|
138
|
-
clientId: string;
|
|
139
|
-
/**
|
|
140
|
-
* The value in seconds used to account for clock skew in JWT expirations.
|
|
141
|
-
* Typically, this value is no more than a minute or two at maximum.
|
|
142
|
-
* Defaults to 60s.
|
|
143
|
-
*/
|
|
144
|
-
leeway?: number;
|
|
145
|
-
/**
|
|
146
|
-
* The location to use when storing cache data. Valid values are `memory` or `localstorage`.
|
|
147
|
-
* The default setting is `memory`.
|
|
148
|
-
*
|
|
149
|
-
* Read more about [changing storage options in the Auth0 docs](https://auth0.com/docs/libraries/auth0-single-page-app-sdk#change-storage-options)
|
|
150
|
-
*/
|
|
151
|
-
cacheLocation?: CacheLocation;
|
|
152
|
-
/**
|
|
153
|
-
* Specify a custom cache implementation to use for token storage and retrieval. This setting takes precedence over `cacheLocation` if they are both specified.
|
|
154
|
-
*/
|
|
155
|
-
cache?: ICache;
|
|
156
|
-
/**
|
|
157
|
-
* If true, refresh tokens are used to fetch new access tokens from the Auth0 server. If false, the standard technique of using a hidden iframe and the `authorization_code` grant with `prompt=none` is used.
|
|
158
|
-
* The default setting is `false`.
|
|
159
|
-
*
|
|
160
|
-
* Standard technique relies on cookies. Because browsers increasingly block third-party cookies, it requires a Custom Domain to function reliably. Refresh tokens serve as a fallback for environments where third-party cookies are blocked.
|
|
161
|
-
* Using a Custom Domain with this set to `false` is the most secure and recommended approach.
|
|
162
|
-
*
|
|
163
|
-
* **Note**: Use of refresh tokens must be enabled by an administrator on your Auth0 client application.
|
|
164
|
-
*/
|
|
165
|
-
useRefreshTokens?: boolean;
|
|
166
|
-
/**
|
|
167
|
-
* If true, fallback to the technique of using a hidden iframe and the `authorization_code` grant with `prompt=none` when unable to use refresh tokens. If false, the iframe fallback is not used and
|
|
168
|
-
* errors relating to a failed `refresh_token` grant should be handled appropriately. The default setting is `false`.
|
|
169
|
-
*
|
|
170
|
-
* **Note**: There might be situations where doing silent auth with a Web Message response from an iframe is not possible,
|
|
171
|
-
* like when you're serving your application from the file system or a custom protocol (like in a Desktop or Native app).
|
|
172
|
-
* In situations like this you can disable the iframe fallback and handle the failed `refresh_token` grant and prompt the user to login interactively with `loginWithRedirect` or `loginWithPopup`."
|
|
173
|
-
*
|
|
174
|
-
* E.g. Using the `file:` protocol in an Electron application does not support that legacy technique.
|
|
175
|
-
*
|
|
176
|
-
* @example
|
|
177
|
-
* let token: string;
|
|
178
|
-
* try {
|
|
179
|
-
* token = await auth0.getTokenSilently();
|
|
180
|
-
* } catch (e) {
|
|
181
|
-
* if (e.error === 'missing_refresh_token' || e.error === 'invalid_grant') {
|
|
182
|
-
* auth0.loginWithRedirect();
|
|
183
|
-
* }
|
|
184
|
-
* }
|
|
185
|
-
*/
|
|
186
|
-
useRefreshTokensFallback?: boolean;
|
|
187
|
-
/**
|
|
188
|
-
* A maximum number of seconds to wait before declaring background calls to /authorize as failed for timeout
|
|
189
|
-
* Defaults to 60s.
|
|
190
|
-
*/
|
|
191
|
-
authorizeTimeoutInSeconds?: number;
|
|
192
|
-
/**
|
|
193
|
-
* Specify the timeout for HTTP calls using `fetch`. The default is 10 seconds.
|
|
194
|
-
*/
|
|
195
|
-
httpTimeoutInSeconds?: number;
|
|
196
|
-
/**
|
|
197
|
-
* Internal property to send information about the client to the authorization server.
|
|
198
|
-
* @internal
|
|
199
|
-
*/
|
|
200
|
-
auth0Client?: {
|
|
201
|
-
name: string;
|
|
202
|
-
version: string;
|
|
203
|
-
env?: {
|
|
204
|
-
[key: string]: string;
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
/**
|
|
208
|
-
* Sets an additional cookie with no SameSite attribute to support legacy browsers
|
|
209
|
-
* that are not compatible with the latest SameSite changes.
|
|
210
|
-
* This will log a warning on modern browsers, you can disable the warning by setting
|
|
211
|
-
* this to false but be aware that some older useragents will not work,
|
|
212
|
-
* See https://www.chromium.org/updates/same-site/incompatible-clients
|
|
213
|
-
* Defaults to true
|
|
214
|
-
*/
|
|
215
|
-
legacySameSiteCookie?: boolean;
|
|
216
|
-
/**
|
|
217
|
-
* If `true`, the SDK will use a cookie when storing information about the auth transaction while
|
|
218
|
-
* the user is going through the authentication flow on the authorization server.
|
|
219
|
-
*
|
|
220
|
-
* The default is `false`, in which case the SDK will use session storage.
|
|
221
|
-
*
|
|
222
|
-
* @notes
|
|
223
|
-
*
|
|
224
|
-
* You might want to enable this if you rely on your users being able to authenticate using flows that
|
|
225
|
-
* may end up spanning across multiple tabs (e.g. magic links) or you cannot otherwise rely on session storage being available.
|
|
226
|
-
*/
|
|
227
|
-
useCookiesForTransactions?: boolean;
|
|
228
|
-
/**
|
|
229
|
-
* Number of days until the cookie `auth0.is.authenticated` will expire
|
|
230
|
-
* Defaults to 1.
|
|
231
|
-
*/
|
|
232
|
-
sessionCheckExpiryDays?: number;
|
|
233
|
-
/**
|
|
234
|
-
* The domain the cookie is accessible from. If not set, the cookie is scoped to
|
|
235
|
-
* the current domain, including the subdomain.
|
|
236
|
-
*
|
|
237
|
-
* Note: setting this incorrectly may cause silent authentication to stop working
|
|
238
|
-
* on page load.
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
* To keep a user logged in across multiple subdomains set this to your
|
|
242
|
-
* top-level domain and prefixed with a `.` (eg: `.example.com`).
|
|
243
|
-
*/
|
|
244
|
-
cookieDomain?: string;
|
|
245
|
-
/**
|
|
246
|
-
* If true, data to the token endpoint is transmitted as x-www-form-urlencoded data, if false it will be transmitted as JSON. The default setting is `true`.
|
|
247
|
-
*
|
|
248
|
-
* **Note:** Setting this to `false` may affect you if you use Auth0 Rules and are sending custom, non-primitive data. If you disable this,
|
|
249
|
-
* please verify that your Auth0 Rules continue to work as intended.
|
|
250
|
-
*/
|
|
251
|
-
useFormData?: boolean;
|
|
252
|
-
/**
|
|
253
|
-
* Modify the value used as the current time during the token validation.
|
|
254
|
-
*
|
|
255
|
-
* **Note**: Using this improperly can potentially compromise the token validation.
|
|
256
|
-
*/
|
|
257
|
-
nowProvider?: () => Promise<number> | number;
|
|
258
|
-
/**
|
|
259
|
-
* If provided, the SDK will load the token worker from this URL instead of the integrated `blob`. An example of when this is useful is if you have strict
|
|
260
|
-
* Content-Security-Policy (CSP) and wish to avoid needing to set `worker-src: blob:`. We recommend either serving the worker, which you can find in the module
|
|
261
|
-
* at `<module_path>/dist/auth0-spa-js.worker.production.js`, from the same host as your application or using the Auth0 CDN
|
|
262
|
-
* `https://cdn.auth0.com/js/auth0-spa-js/<version>/auth0-spa-js.worker.production.js`.
|
|
263
|
-
*
|
|
264
|
-
* **Note**: The worker is only used when `useRefreshTokens: true`, `cacheLocation: 'memory'`, and the `cache` is not custom.
|
|
265
|
-
*/
|
|
266
|
-
workerUrl?: string;
|
|
267
|
-
/**
|
|
268
|
-
* If `true`, the SDK will allow the refreshing of tokens using MRRT
|
|
269
|
-
*/
|
|
270
|
-
useMrrt?: boolean;
|
|
271
|
-
/**
|
|
272
|
-
* If `true`, DPoP (OAuth 2.0 Demonstrating Proof of Possession, RFC9449)
|
|
273
|
-
* will be used to cryptographically bind tokens to this specific browser
|
|
274
|
-
* so they can't be used from a different device in case of a leak.
|
|
275
|
-
*
|
|
276
|
-
* The default setting is `false`.
|
|
277
|
-
*/
|
|
278
|
-
useDpop?: boolean;
|
|
279
|
-
/**
|
|
280
|
-
* Configures automatic handling of interactive authentication errors.
|
|
281
|
-
*
|
|
282
|
-
* When set, the SDK intercepts `mfa_required` errors from `getTokenSilently()`
|
|
283
|
-
* and handles them automatically instead of throwing to the caller.
|
|
284
|
-
*
|
|
285
|
-
* - `'popup'`: Opens Universal Login in a popup to complete MFA.
|
|
286
|
-
* The original `authorizationParams` (audience, scope) are preserved.
|
|
287
|
-
* On success, the token is returned. On failure, popup errors are thrown.
|
|
288
|
-
*
|
|
289
|
-
* This option only affects `getTokenSilently()`. Other methods are not affected.
|
|
290
|
-
*
|
|
291
|
-
* @default undefined (MFA errors are thrown to the caller)
|
|
292
|
-
*/
|
|
293
|
-
interactiveErrorHandler?: InteractiveErrorHandler;
|
|
294
|
-
/**
|
|
295
|
-
* URL parameters that will be sent back to the Authorization Server. This can be known parameters
|
|
296
|
-
* defined by Auth0 or custom parameters that you define.
|
|
297
|
-
*/
|
|
298
|
-
authorizationParams?: ClientAuthorizationParams;
|
|
299
|
-
/**
|
|
300
|
-
* Query parameter name to extract the session transfer token from for Native to Web SSO.
|
|
301
|
-
*
|
|
302
|
-
* When set, the SDK automatically extracts the token from the specified URL query
|
|
303
|
-
* parameter and includes it as `session_transfer_token` in authorization requests.
|
|
304
|
-
* This enables seamless single sign-on when users transition from a native mobile
|
|
305
|
-
* application to a web application.
|
|
306
|
-
*
|
|
307
|
-
* After extraction, the token is automatically removed from the URL using
|
|
308
|
-
* `window.history.replaceState()` to prevent accidental reuse on subsequent
|
|
309
|
-
* authentication requests.
|
|
310
|
-
*
|
|
311
|
-
* **Default:** `undefined` (feature disabled)
|
|
312
|
-
*
|
|
313
|
-
* **Common values:**
|
|
314
|
-
* - `'session_transfer_token'` - Standard parameter name
|
|
315
|
-
* - `'stt'` - Shortened version
|
|
316
|
-
* - Custom parameter name of your choice
|
|
317
|
-
*
|
|
318
|
-
* Set to `undefined` to disable automatic extraction if you prefer to handle
|
|
319
|
-
* session transfer tokens manually.
|
|
320
|
-
*
|
|
321
|
-
* @example
|
|
322
|
-
* ```js
|
|
323
|
-
* const auth0 = await createAuth0Client({
|
|
324
|
-
* domain: '<AUTH0_DOMAIN>',
|
|
325
|
-
* clientId: '<AUTH0_CLIENT_ID>',
|
|
326
|
-
* sessionTransferTokenQueryParamName: 'session_transfer_token'
|
|
327
|
-
* });
|
|
328
|
-
* ```
|
|
329
|
-
*
|
|
330
|
-
* @see https://auth0.com/docs/authenticate/single-sign-on/native-to-web
|
|
331
|
-
*/
|
|
332
|
-
sessionTransferTokenQueryParamName?: string;
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Configuration details exposed by the Auth0Client after initialization.
|
|
336
|
-
*
|
|
337
|
-
* @category Main
|
|
338
|
-
*/
|
|
339
|
-
export interface ClientConfiguration {
|
|
340
|
-
/**
|
|
341
|
-
* The Auth0 domain that was configured
|
|
342
|
-
*/
|
|
343
|
-
domain: string;
|
|
344
|
-
/**
|
|
345
|
-
* The Auth0 client ID that was configured
|
|
346
|
-
*/
|
|
347
|
-
clientId: string;
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* The possible locations where tokens can be stored
|
|
351
|
-
*/
|
|
352
|
-
export type CacheLocation = 'memory' | 'localstorage';
|
|
353
|
-
/**
|
|
354
|
-
* @ignore
|
|
355
|
-
*/
|
|
356
|
-
export interface AuthorizeOptions extends AuthorizationParams {
|
|
357
|
-
response_type: string;
|
|
358
|
-
response_mode: string;
|
|
359
|
-
redirect_uri?: string;
|
|
360
|
-
nonce: string;
|
|
361
|
-
state: string;
|
|
362
|
-
scope: string;
|
|
363
|
-
code_challenge: string;
|
|
364
|
-
code_challenge_method: string;
|
|
365
|
-
}
|
|
366
|
-
export interface RedirectLoginOptions<TAppState = any> extends BaseLoginOptions {
|
|
367
|
-
/**
|
|
368
|
-
* Used to store state before doing the redirect
|
|
369
|
-
*/
|
|
370
|
-
appState?: TAppState;
|
|
371
|
-
/**
|
|
372
|
-
* Used to add to the URL fragment before redirecting
|
|
373
|
-
*/
|
|
374
|
-
fragment?: string;
|
|
375
|
-
/**
|
|
376
|
-
* Used to control the redirect and not rely on the SDK to do the actual redirect.
|
|
377
|
-
*
|
|
378
|
-
* @example
|
|
379
|
-
* const client = new Auth0Client({
|
|
380
|
-
* async onRedirect(url) {
|
|
381
|
-
* window.location.replace(url);
|
|
382
|
-
* }
|
|
383
|
-
* });
|
|
384
|
-
* @deprecated since v2.0.1, use `openUrl` instead.
|
|
385
|
-
*/
|
|
386
|
-
onRedirect?: (url: string) => Promise<void>;
|
|
387
|
-
/**
|
|
388
|
-
* Used to control the redirect and not rely on the SDK to do the actual redirect.
|
|
389
|
-
*
|
|
390
|
-
* @example
|
|
391
|
-
* const client = new Auth0Client({
|
|
392
|
-
* openUrl(url) {
|
|
393
|
-
* window.location.replace(url);
|
|
394
|
-
* }
|
|
395
|
-
* });
|
|
396
|
-
*
|
|
397
|
-
* @example
|
|
398
|
-
* import { Browser } from '@capacitor/browser';
|
|
399
|
-
*
|
|
400
|
-
* const client = new Auth0Client({
|
|
401
|
-
* async openUrl(url) {
|
|
402
|
-
* await Browser.open({ url });
|
|
403
|
-
* }
|
|
404
|
-
* });
|
|
405
|
-
*/
|
|
406
|
-
openUrl?: (url: string) => Promise<void> | void;
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* The types of responses expected from the authorization server.
|
|
410
|
-
* - `code`: used for the standard login flow.
|
|
411
|
-
* - `connect_code`: used for the connect account flow.
|
|
412
|
-
*/
|
|
413
|
-
export declare enum ResponseType {
|
|
414
|
-
Code = "code",
|
|
415
|
-
ConnectCode = "connect_code"
|
|
416
|
-
}
|
|
417
|
-
export interface RedirectLoginResult<TAppState = any> {
|
|
418
|
-
/**
|
|
419
|
-
* State stored when the redirect request was made
|
|
420
|
-
*/
|
|
421
|
-
appState?: TAppState;
|
|
422
|
-
/**
|
|
423
|
-
* The type of response, for login it will be `code`
|
|
424
|
-
*/
|
|
425
|
-
response_type: ResponseType.Code;
|
|
426
|
-
}
|
|
427
|
-
export interface PopupLoginOptions extends BaseLoginOptions {
|
|
428
|
-
}
|
|
429
|
-
export interface PopupConfigOptions {
|
|
430
|
-
/**
|
|
431
|
-
* The number of seconds to wait for a popup response before
|
|
432
|
-
* throwing a timeout error. Defaults to 60s
|
|
433
|
-
*/
|
|
434
|
-
timeoutInSeconds?: number;
|
|
435
|
-
/**
|
|
436
|
-
* Accepts an already-created popup window to use. If not specified, the SDK
|
|
437
|
-
* will create its own. This may be useful for platforms like iOS that have
|
|
438
|
-
* security restrictions around when popups can be invoked (e.g. from a user click event)
|
|
439
|
-
*/
|
|
440
|
-
popup?: any;
|
|
441
|
-
/**
|
|
442
|
-
* Controls whether the SDK automatically closes the popup window.
|
|
443
|
-
*
|
|
444
|
-
* - `true` (default): SDK closes the popup automatically after receiving the authorization response
|
|
445
|
-
* - `false`: SDK does not close the popup. The caller is responsible for closing it, including on errors.
|
|
446
|
-
*
|
|
447
|
-
* Setting this to `false` is useful when you need full control over the popup lifecycle,
|
|
448
|
-
* such as in Chrome extensions where closing the popup too early can terminate the
|
|
449
|
-
* extension's service worker before authentication completes.
|
|
450
|
-
*
|
|
451
|
-
* When `closePopup: false`, you should close the popup in a try/finally block:
|
|
452
|
-
* ```
|
|
453
|
-
* const popup = window.open('', '_blank');
|
|
454
|
-
* try {
|
|
455
|
-
* await auth0.loginWithPopup({}, { popup, closePopup: false });
|
|
456
|
-
* } finally {
|
|
457
|
-
* popup.close();
|
|
458
|
-
* }
|
|
459
|
-
* ```
|
|
460
|
-
*
|
|
461
|
-
* @default true
|
|
462
|
-
*/
|
|
463
|
-
closePopup?: boolean;
|
|
464
|
-
}
|
|
465
|
-
export interface GetTokenSilentlyOptions {
|
|
466
|
-
/**
|
|
467
|
-
* When `off`, ignores the cache and always sends a
|
|
468
|
-
* request to Auth0.
|
|
469
|
-
* When `cache-only`, only reads from the cache and never sends a request to Auth0.
|
|
470
|
-
* Defaults to `on`, where it both reads from the cache and sends a request to Auth0 as needed.
|
|
471
|
-
*/
|
|
472
|
-
cacheMode?: 'on' | 'off' | 'cache-only';
|
|
473
|
-
/**
|
|
474
|
-
* Parameters that will be sent back to Auth0 as part of a request.
|
|
475
|
-
*/
|
|
476
|
-
authorizationParams?: {
|
|
477
|
-
/**
|
|
478
|
-
* There's no actual redirect when getting a token silently,
|
|
479
|
-
* but, according to the spec, a `redirect_uri` param is required.
|
|
480
|
-
* Auth0 uses this parameter to validate that the current `origin`
|
|
481
|
-
* matches the `redirect_uri` `origin` when sending the response.
|
|
482
|
-
* It must be whitelisted in the "Allowed Web Origins" in your
|
|
483
|
-
* Auth0 Application's settings.
|
|
484
|
-
*/
|
|
485
|
-
redirect_uri?: string;
|
|
486
|
-
/**
|
|
487
|
-
* The scope that was used in the authentication request
|
|
488
|
-
*/
|
|
489
|
-
scope?: string;
|
|
490
|
-
/**
|
|
491
|
-
* The audience that was used in the authentication request
|
|
492
|
-
*/
|
|
493
|
-
audience?: string;
|
|
494
|
-
/**
|
|
495
|
-
* If you need to send custom parameters to the Authorization Server,
|
|
496
|
-
* make sure to use the original parameter name.
|
|
497
|
-
*/
|
|
498
|
-
[key: string]: any;
|
|
499
|
-
};
|
|
500
|
-
/** A maximum number of seconds to wait before declaring the background /authorize call as failed for timeout
|
|
501
|
-
* Defaults to 60s.
|
|
502
|
-
*/
|
|
503
|
-
timeoutInSeconds?: number;
|
|
504
|
-
/**
|
|
505
|
-
* If true, the full response from the /oauth/token endpoint (or the cache, if the cache was used) is returned
|
|
506
|
-
* (minus `refresh_token` if one was issued). Otherwise, just the access token is returned.
|
|
507
|
-
*
|
|
508
|
-
* The default is `false`.
|
|
509
|
-
*/
|
|
510
|
-
detailedResponse?: boolean;
|
|
511
|
-
}
|
|
512
|
-
export interface GetTokenWithPopupOptions extends PopupLoginOptions {
|
|
513
|
-
/**
|
|
514
|
-
* When `off`, ignores the cache and always sends a request to Auth0.
|
|
515
|
-
* When `cache-only`, only reads from the cache and never sends a request to Auth0.
|
|
516
|
-
* Defaults to `on`, where it both reads from the cache and sends a request to Auth0 as needed.
|
|
517
|
-
*/
|
|
518
|
-
cacheMode?: 'on' | 'off' | 'cache-only';
|
|
519
|
-
}
|
|
520
|
-
export interface LogoutUrlOptions {
|
|
521
|
-
/**
|
|
522
|
-
* The `clientId` of your application.
|
|
523
|
-
*
|
|
524
|
-
* If this property is not set, then the `clientId` that was used during initialization of the SDK is sent to the logout endpoint.
|
|
525
|
-
*
|
|
526
|
-
* If this property is set to `null`, then no client ID value is sent to the logout endpoint.
|
|
527
|
-
*
|
|
528
|
-
* [Read more about how redirecting after logout works](https://auth0.com/docs/logout/guides/redirect-users-after-logout)
|
|
529
|
-
*/
|
|
530
|
-
clientId?: string | null;
|
|
531
|
-
/**
|
|
532
|
-
* Parameters to pass to the logout endpoint. This can be known parameters defined by Auth0 or custom parameters
|
|
533
|
-
* you wish to provide.
|
|
534
|
-
*/
|
|
535
|
-
logoutParams?: {
|
|
536
|
-
/**
|
|
537
|
-
* When supported by the upstream identity provider,
|
|
538
|
-
* forces the user to logout of their identity provider
|
|
539
|
-
* and from Auth0.
|
|
540
|
-
* [Read more about how federated logout works at Auth0](https://auth0.com/docs/logout/guides/logout-idps)
|
|
541
|
-
*/
|
|
542
|
-
federated?: boolean;
|
|
543
|
-
/**
|
|
544
|
-
* The URL where Auth0 will redirect your browser to after the logout.
|
|
545
|
-
*
|
|
546
|
-
* **Note**: If the `client_id` parameter is included, the
|
|
547
|
-
* `returnTo` URL that is provided must be listed in the
|
|
548
|
-
* Application's "Allowed Logout URLs" in the Auth0 dashboard.
|
|
549
|
-
* However, if the `client_id` parameter is not included, the
|
|
550
|
-
* `returnTo` URL must be listed in the "Allowed Logout URLs" at
|
|
551
|
-
* the account level in the Auth0 dashboard.
|
|
552
|
-
*
|
|
553
|
-
* [Read more about how redirecting after logout works](https://auth0.com/docs/logout/guides/redirect-users-after-logout)
|
|
554
|
-
*/
|
|
555
|
-
returnTo?: string;
|
|
556
|
-
/**
|
|
557
|
-
* If you need to send custom parameters to the logout endpoint, make sure to use the original parameter name.
|
|
558
|
-
*/
|
|
559
|
-
[key: string]: any;
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
export interface LogoutOptions extends LogoutUrlOptions {
|
|
563
|
-
/**
|
|
564
|
-
* Used to control the redirect and not rely on the SDK to do the actual redirect.
|
|
565
|
-
*
|
|
566
|
-
* @example
|
|
567
|
-
* await auth0.logout({
|
|
568
|
-
* async onRedirect(url) {
|
|
569
|
-
* window.location.replace(url);
|
|
570
|
-
* }
|
|
571
|
-
* });
|
|
572
|
-
* @deprecated since v2.0.1, use `openUrl` instead.
|
|
573
|
-
*/
|
|
574
|
-
onRedirect?: (url: string) => Promise<void>;
|
|
575
|
-
/**
|
|
576
|
-
* Used to control the redirect and not rely on the SDK to do the actual redirect.
|
|
577
|
-
*
|
|
578
|
-
* Set to `false` to disable the redirect, or provide a function to handle the actual redirect yourself.
|
|
579
|
-
*
|
|
580
|
-
* @example
|
|
581
|
-
* await auth0.logout({
|
|
582
|
-
* openUrl(url) {
|
|
583
|
-
* window.location.replace(url);
|
|
584
|
-
* }
|
|
585
|
-
* });
|
|
586
|
-
*
|
|
587
|
-
* @example
|
|
588
|
-
* import { Browser } from '@capacitor/browser';
|
|
589
|
-
*
|
|
590
|
-
* await auth0.logout({
|
|
591
|
-
* async openUrl(url) {
|
|
592
|
-
* await Browser.open({ url });
|
|
593
|
-
* }
|
|
594
|
-
* });
|
|
595
|
-
*/
|
|
596
|
-
openUrl?: false | ((url: string) => Promise<void> | void);
|
|
597
|
-
}
|
|
598
|
-
export interface RedirectConnectAccountOptions<TAppState = any> {
|
|
599
|
-
/**
|
|
600
|
-
* The name of the connection to link (e.g. 'google-oauth2').
|
|
601
|
-
*/
|
|
602
|
-
connection: string;
|
|
603
|
-
/**
|
|
604
|
-
* Array of scopes to request from the Identity Provider during the connect account flow.
|
|
605
|
-
*
|
|
606
|
-
* @example
|
|
607
|
-
* await auth0.connectAccountWithRedirect({
|
|
608
|
-
* connection: 'google-oauth2',
|
|
609
|
-
* scopes: ['https://www.googleapis.com/auth/calendar']
|
|
610
|
-
* });
|
|
611
|
-
*/
|
|
612
|
-
scopes?: string[];
|
|
613
|
-
/**
|
|
614
|
-
* Additional authorization parameters for the request.
|
|
615
|
-
*
|
|
616
|
-
* @example
|
|
617
|
-
* await auth0.connectAccountWithRedirect({
|
|
618
|
-
* connection: 'github',
|
|
619
|
-
* authorization_params: {
|
|
620
|
-
* audience: 'https://api.github.com'
|
|
621
|
-
* }
|
|
622
|
-
* });
|
|
623
|
-
*/
|
|
624
|
-
authorization_params?: AuthorizationParams;
|
|
625
|
-
/**
|
|
626
|
-
* The URI to redirect back to after connecting the account.
|
|
627
|
-
*/
|
|
628
|
-
redirectUri?: string;
|
|
629
|
-
/**
|
|
630
|
-
* Optional application state to persist through the transaction.
|
|
631
|
-
*
|
|
632
|
-
* @example
|
|
633
|
-
* await auth0.connectAccountWithRedirect({
|
|
634
|
-
* connection: 'google-oauth2',
|
|
635
|
-
* appState: { returnTo: '/settings' }
|
|
636
|
-
* });
|
|
637
|
-
*/
|
|
638
|
-
appState?: TAppState;
|
|
639
|
-
/**
|
|
640
|
-
* Optional function to handle the redirect URL.
|
|
641
|
-
*
|
|
642
|
-
* @example
|
|
643
|
-
* await auth0.connectAccountWithRedirect({
|
|
644
|
-
* connection: 'google-oauth2',
|
|
645
|
-
* openUrl: async (url) => { myBrowserApi.open(url); }
|
|
646
|
-
* });
|
|
647
|
-
*/
|
|
648
|
-
openUrl?: (url: string) => Promise<void>;
|
|
649
|
-
}
|
|
650
|
-
/**
|
|
651
|
-
* The result returned after a successful account connection redirect.
|
|
652
|
-
*
|
|
653
|
-
* Combines the redirect login result (including any persisted app state)
|
|
654
|
-
* with the complete response from the My Account API.
|
|
655
|
-
*
|
|
656
|
-
* @template TAppState - The type of application state persisted through the transaction.
|
|
657
|
-
* @example
|
|
658
|
-
* const result = await auth0.connectAccountWithRedirect(options);
|
|
659
|
-
* console.log(result.appState); // Access persisted app state
|
|
660
|
-
* console.log(result.connection); // The connection of the account you connected to.
|
|
661
|
-
* console.log(result.response_type === 'connect_code'); // The response type will be 'connect_code'
|
|
662
|
-
*/
|
|
663
|
-
export type ConnectAccountRedirectResult<TAppState = any> = CompleteResponse & {
|
|
664
|
-
/**
|
|
665
|
-
* State stored when the redirect request was made
|
|
666
|
-
*/
|
|
667
|
-
appState?: TAppState;
|
|
668
|
-
/**
|
|
669
|
-
* The type of response, for connect account it will be `connect_code`
|
|
670
|
-
*/
|
|
671
|
-
response_type: ResponseType.ConnectCode;
|
|
672
|
-
};
|
|
673
|
-
/**
|
|
674
|
-
* @ignore
|
|
675
|
-
*/
|
|
676
|
-
export interface AuthenticationResult {
|
|
677
|
-
state: string;
|
|
678
|
-
code?: string;
|
|
679
|
-
/**
|
|
680
|
-
* This is for the redirect from the connect account flow.
|
|
681
|
-
*/
|
|
682
|
-
connect_code?: string;
|
|
683
|
-
error?: string;
|
|
684
|
-
error_description?: string;
|
|
685
|
-
}
|
|
686
|
-
/**
|
|
687
|
-
* @ignore
|
|
688
|
-
*/
|
|
689
|
-
export interface TokenEndpointOptions {
|
|
690
|
-
baseUrl: string;
|
|
691
|
-
client_id: string;
|
|
692
|
-
grant_type: string;
|
|
693
|
-
timeout?: number;
|
|
694
|
-
auth0Client: any;
|
|
695
|
-
useFormData?: boolean;
|
|
696
|
-
dpop?: Pick<Dpop, 'generateProof' | 'getNonce' | 'setNonce'>;
|
|
697
|
-
[key: string]: any;
|
|
698
|
-
}
|
|
699
|
-
export type TokenEndpointResponse = {
|
|
700
|
-
id_token: string;
|
|
701
|
-
token_type: string;
|
|
702
|
-
access_token: string;
|
|
703
|
-
refresh_token?: string;
|
|
704
|
-
expires_in: number;
|
|
705
|
-
scope?: string;
|
|
706
|
-
};
|
|
707
|
-
/**
|
|
708
|
-
* @ignore
|
|
709
|
-
*/
|
|
710
|
-
export interface OAuthTokenOptions extends TokenEndpointOptions {
|
|
711
|
-
code_verifier: string;
|
|
712
|
-
code: string;
|
|
713
|
-
redirect_uri: string;
|
|
714
|
-
audience: string;
|
|
715
|
-
scope: string;
|
|
716
|
-
}
|
|
717
|
-
/**
|
|
718
|
-
* @ignore
|
|
719
|
-
*/
|
|
720
|
-
export interface RefreshTokenOptions extends TokenEndpointOptions {
|
|
721
|
-
refresh_token: string;
|
|
722
|
-
}
|
|
723
|
-
/**
|
|
724
|
-
* @ignore
|
|
725
|
-
*/
|
|
726
|
-
export interface JWTVerifyOptions {
|
|
727
|
-
iss: string;
|
|
728
|
-
aud: string;
|
|
729
|
-
id_token: string;
|
|
730
|
-
nonce?: string;
|
|
731
|
-
leeway?: number;
|
|
732
|
-
max_age?: number;
|
|
733
|
-
organization?: string;
|
|
734
|
-
now?: number;
|
|
735
|
-
}
|
|
736
|
-
export interface IdToken {
|
|
737
|
-
__raw: string;
|
|
738
|
-
name?: string;
|
|
739
|
-
given_name?: string;
|
|
740
|
-
family_name?: string;
|
|
741
|
-
middle_name?: string;
|
|
742
|
-
nickname?: string;
|
|
743
|
-
preferred_username?: string;
|
|
744
|
-
profile?: string;
|
|
745
|
-
picture?: string;
|
|
746
|
-
website?: string;
|
|
747
|
-
email?: string;
|
|
748
|
-
email_verified?: boolean;
|
|
749
|
-
gender?: string;
|
|
750
|
-
birthdate?: string;
|
|
751
|
-
zoneinfo?: string;
|
|
752
|
-
locale?: string;
|
|
753
|
-
phone_number?: string;
|
|
754
|
-
phone_number_verified?: boolean;
|
|
755
|
-
address?: string;
|
|
756
|
-
updated_at?: string;
|
|
757
|
-
iss?: string;
|
|
758
|
-
aud?: string;
|
|
759
|
-
exp?: number;
|
|
760
|
-
nbf?: number;
|
|
761
|
-
iat?: number;
|
|
762
|
-
jti?: string;
|
|
763
|
-
azp?: string;
|
|
764
|
-
nonce?: string;
|
|
765
|
-
auth_time?: string;
|
|
766
|
-
at_hash?: string;
|
|
767
|
-
c_hash?: string;
|
|
768
|
-
acr?: string;
|
|
769
|
-
amr?: string[];
|
|
770
|
-
sub_jwk?: string;
|
|
771
|
-
cnf?: string;
|
|
772
|
-
sid?: string;
|
|
773
|
-
org_id?: string;
|
|
774
|
-
org_name?: string;
|
|
775
|
-
[key: string]: any;
|
|
776
|
-
}
|
|
777
|
-
export declare class User {
|
|
778
|
-
name?: string;
|
|
779
|
-
given_name?: string;
|
|
780
|
-
family_name?: string;
|
|
781
|
-
middle_name?: string;
|
|
782
|
-
nickname?: string;
|
|
783
|
-
preferred_username?: string;
|
|
784
|
-
profile?: string;
|
|
785
|
-
picture?: string;
|
|
786
|
-
website?: string;
|
|
787
|
-
email?: string;
|
|
788
|
-
email_verified?: boolean;
|
|
789
|
-
gender?: string;
|
|
790
|
-
birthdate?: string;
|
|
791
|
-
zoneinfo?: string;
|
|
792
|
-
locale?: string;
|
|
793
|
-
phone_number?: string;
|
|
794
|
-
phone_number_verified?: boolean;
|
|
795
|
-
address?: string;
|
|
796
|
-
updated_at?: string;
|
|
797
|
-
sub?: string;
|
|
798
|
-
[key: string]: any;
|
|
799
|
-
}
|
|
800
|
-
/**
|
|
801
|
-
* @ignore
|
|
802
|
-
*/
|
|
803
|
-
export type FetchOptions = {
|
|
804
|
-
method?: string;
|
|
805
|
-
headers?: Record<string, string>;
|
|
806
|
-
credentials?: 'include' | 'omit';
|
|
807
|
-
body?: string;
|
|
808
|
-
signal?: AbortSignal;
|
|
809
|
-
};
|
|
810
|
-
/**
|
|
811
|
-
* @ignore
|
|
812
|
-
*/
|
|
813
|
-
export type FetchResponse = {
|
|
814
|
-
ok: boolean;
|
|
815
|
-
headers: Record<string, string | undefined>;
|
|
816
|
-
json: any;
|
|
817
|
-
};
|
|
818
|
-
export type GetTokenSilentlyVerboseResponse = Omit<TokenEndpointResponse, 'refresh_token'>;
|
|
819
|
-
|
|
1
|
+
import { ICache } from './cache';
|
|
2
|
+
import type { Dpop } from './dpop/dpop';
|
|
3
|
+
import { CompleteResponse } from './MyAccountApiClient';
|
|
4
|
+
/**
|
|
5
|
+
* Configuration option for automatic interactive error handling.
|
|
6
|
+
*
|
|
7
|
+
* - `'popup'`: SDK automatically opens Universal Login popup on MFA error
|
|
8
|
+
*/
|
|
9
|
+
export type InteractiveErrorHandler = 'popup';
|
|
10
|
+
export interface AuthorizationParams {
|
|
11
|
+
/**
|
|
12
|
+
* - `'page'`: displays the UI with a full page view
|
|
13
|
+
* - `'popup'`: displays the UI with a popup window
|
|
14
|
+
* - `'touch'`: displays the UI in a way that leverages a touch interface
|
|
15
|
+
* - `'wap'`: displays the UI with a "feature phone" type interface
|
|
16
|
+
*/
|
|
17
|
+
display?: 'page' | 'popup' | 'touch' | 'wap';
|
|
18
|
+
/**
|
|
19
|
+
* - `'none'`: do not prompt user for login or consent on reauthentication
|
|
20
|
+
* - `'login'`: prompt user for reauthentication
|
|
21
|
+
* - `'consent'`: prompt user for consent before processing request
|
|
22
|
+
* - `'select_account'`: prompt user to select an account
|
|
23
|
+
*/
|
|
24
|
+
prompt?: 'none' | 'login' | 'consent' | 'select_account';
|
|
25
|
+
/**
|
|
26
|
+
* Maximum allowable elapsed time (in seconds) since authentication.
|
|
27
|
+
* If the last time the user authenticated is greater than this value,
|
|
28
|
+
* the user must be reauthenticated.
|
|
29
|
+
*/
|
|
30
|
+
max_age?: string | number;
|
|
31
|
+
/**
|
|
32
|
+
* The space-separated list of language tags, ordered by preference.
|
|
33
|
+
* For example: `'fr-CA fr en'`.
|
|
34
|
+
*/
|
|
35
|
+
ui_locales?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Previously issued ID Token.
|
|
38
|
+
*/
|
|
39
|
+
id_token_hint?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Provides a hint to Auth0 as to what flow should be displayed.
|
|
42
|
+
* The default behavior is to show a login page but you can override
|
|
43
|
+
* this by passing 'signup' to show the signup page instead.
|
|
44
|
+
*
|
|
45
|
+
* This only affects the New Universal Login Experience.
|
|
46
|
+
*/
|
|
47
|
+
screen_hint?: 'signup' | 'login' | string;
|
|
48
|
+
/**
|
|
49
|
+
* The user's email address or other identifier. When your app knows
|
|
50
|
+
* which user is trying to authenticate, you can provide this parameter
|
|
51
|
+
* to pre-fill the email box or select the right session for sign-in.
|
|
52
|
+
*
|
|
53
|
+
* This currently only affects the classic Lock experience.
|
|
54
|
+
*/
|
|
55
|
+
login_hint?: string;
|
|
56
|
+
acr_values?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The default scope to be used on authentication requests.
|
|
59
|
+
*
|
|
60
|
+
* This defaults to `profile email` if not set. If you are setting extra scopes and require
|
|
61
|
+
* `profile` and `email` to be included then you must include them in the provided scope.
|
|
62
|
+
*
|
|
63
|
+
* Note: The `openid` scope is **always applied** regardless of this setting.
|
|
64
|
+
*/
|
|
65
|
+
scope?: string;
|
|
66
|
+
/**
|
|
67
|
+
* The default audience to be used for requesting API access.
|
|
68
|
+
*/
|
|
69
|
+
audience?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The name of the connection configured for your application.
|
|
72
|
+
* If null, it will redirect to the Auth0 Login Page and show
|
|
73
|
+
* the Login Widget.
|
|
74
|
+
*/
|
|
75
|
+
connection?: string;
|
|
76
|
+
/**
|
|
77
|
+
* The organization to log in to.
|
|
78
|
+
*
|
|
79
|
+
* This will specify an `organization` parameter in your user's login request.
|
|
80
|
+
*
|
|
81
|
+
* - If you provide an Organization ID (a string with the prefix `org_`), it will be validated against the `org_id` claim of your user's ID Token. The validation is case-sensitive.
|
|
82
|
+
* - If you provide an Organization Name (a string *without* the prefix `org_`), it will be validated against the `org_name` claim of your user's ID Token. The validation is case-insensitive.
|
|
83
|
+
* To use an Organization Name you must have "Allow Organization Names in Authentication API" switched on in your Auth0 settings dashboard.
|
|
84
|
+
* More information is available on the [Auth0 documentation portal](https://auth0.com/docs/manage-users/organizations/configure-organizations/use-org-name-authentication-api)
|
|
85
|
+
*
|
|
86
|
+
*/
|
|
87
|
+
organization?: string;
|
|
88
|
+
/**
|
|
89
|
+
* The Id of an invitation to accept. This is available from the user invitation URL that is given when participating in a user invitation flow.
|
|
90
|
+
*/
|
|
91
|
+
invitation?: string;
|
|
92
|
+
/**
|
|
93
|
+
* The default URL where Auth0 will redirect your browser to with
|
|
94
|
+
* the authentication result. It must be whitelisted in
|
|
95
|
+
* the "Allowed Callback URLs" field in your Auth0 Application's
|
|
96
|
+
* settings. If not provided here, it should be provided in the other
|
|
97
|
+
* methods that provide authentication.
|
|
98
|
+
*/
|
|
99
|
+
redirect_uri?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Session transfer token from a native application for Native to Web SSO.
|
|
102
|
+
* When `sessionTransferTokenQueryParamName` is set, this is automatically
|
|
103
|
+
* extracted from the specified URL query parameter if present.
|
|
104
|
+
*
|
|
105
|
+
* @see https://auth0.com/docs/authenticate/single-sign-on/native-to-web
|
|
106
|
+
*/
|
|
107
|
+
session_transfer_token?: string;
|
|
108
|
+
/**
|
|
109
|
+
* If you need to send custom parameters to the Authorization Server,
|
|
110
|
+
* make sure to use the original parameter name.
|
|
111
|
+
*/
|
|
112
|
+
[key: string]: any;
|
|
113
|
+
}
|
|
114
|
+
export interface ClientAuthorizationParams extends Omit<AuthorizationParams, 'scope'> {
|
|
115
|
+
scope?: string | Record<string, string>;
|
|
116
|
+
}
|
|
117
|
+
interface BaseLoginOptions {
|
|
118
|
+
/**
|
|
119
|
+
* URL parameters that will be sent back to the Authorization Server. This can be known parameters
|
|
120
|
+
* defined by Auth0 or custom parameters that you define.
|
|
121
|
+
*/
|
|
122
|
+
authorizationParams?: AuthorizationParams;
|
|
123
|
+
}
|
|
124
|
+
export interface Auth0ClientOptions {
|
|
125
|
+
/**
|
|
126
|
+
* Your Auth0 account domain such as `'example.auth0.com'`,
|
|
127
|
+
* `'example.eu.auth0.com'` or , `'example.mycompany.com'`
|
|
128
|
+
* (when using [custom domains](https://auth0.com/docs/custom-domains))
|
|
129
|
+
*/
|
|
130
|
+
domain: string;
|
|
131
|
+
/**
|
|
132
|
+
* The issuer to be used for validation of JWTs, optionally defaults to the domain above
|
|
133
|
+
*/
|
|
134
|
+
issuer?: string;
|
|
135
|
+
/**
|
|
136
|
+
* The Client ID found on your Application settings page
|
|
137
|
+
*/
|
|
138
|
+
clientId: string;
|
|
139
|
+
/**
|
|
140
|
+
* The value in seconds used to account for clock skew in JWT expirations.
|
|
141
|
+
* Typically, this value is no more than a minute or two at maximum.
|
|
142
|
+
* Defaults to 60s.
|
|
143
|
+
*/
|
|
144
|
+
leeway?: number;
|
|
145
|
+
/**
|
|
146
|
+
* The location to use when storing cache data. Valid values are `memory` or `localstorage`.
|
|
147
|
+
* The default setting is `memory`.
|
|
148
|
+
*
|
|
149
|
+
* Read more about [changing storage options in the Auth0 docs](https://auth0.com/docs/libraries/auth0-single-page-app-sdk#change-storage-options)
|
|
150
|
+
*/
|
|
151
|
+
cacheLocation?: CacheLocation;
|
|
152
|
+
/**
|
|
153
|
+
* Specify a custom cache implementation to use for token storage and retrieval. This setting takes precedence over `cacheLocation` if they are both specified.
|
|
154
|
+
*/
|
|
155
|
+
cache?: ICache;
|
|
156
|
+
/**
|
|
157
|
+
* If true, refresh tokens are used to fetch new access tokens from the Auth0 server. If false, the standard technique of using a hidden iframe and the `authorization_code` grant with `prompt=none` is used.
|
|
158
|
+
* The default setting is `false`.
|
|
159
|
+
*
|
|
160
|
+
* Standard technique relies on cookies. Because browsers increasingly block third-party cookies, it requires a Custom Domain to function reliably. Refresh tokens serve as a fallback for environments where third-party cookies are blocked.
|
|
161
|
+
* Using a Custom Domain with this set to `false` is the most secure and recommended approach.
|
|
162
|
+
*
|
|
163
|
+
* **Note**: Use of refresh tokens must be enabled by an administrator on your Auth0 client application.
|
|
164
|
+
*/
|
|
165
|
+
useRefreshTokens?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* If true, fallback to the technique of using a hidden iframe and the `authorization_code` grant with `prompt=none` when unable to use refresh tokens. If false, the iframe fallback is not used and
|
|
168
|
+
* errors relating to a failed `refresh_token` grant should be handled appropriately. The default setting is `false`.
|
|
169
|
+
*
|
|
170
|
+
* **Note**: There might be situations where doing silent auth with a Web Message response from an iframe is not possible,
|
|
171
|
+
* like when you're serving your application from the file system or a custom protocol (like in a Desktop or Native app).
|
|
172
|
+
* In situations like this you can disable the iframe fallback and handle the failed `refresh_token` grant and prompt the user to login interactively with `loginWithRedirect` or `loginWithPopup`."
|
|
173
|
+
*
|
|
174
|
+
* E.g. Using the `file:` protocol in an Electron application does not support that legacy technique.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* let token: string;
|
|
178
|
+
* try {
|
|
179
|
+
* token = await auth0.getTokenSilently();
|
|
180
|
+
* } catch (e) {
|
|
181
|
+
* if (e.error === 'missing_refresh_token' || e.error === 'invalid_grant') {
|
|
182
|
+
* auth0.loginWithRedirect();
|
|
183
|
+
* }
|
|
184
|
+
* }
|
|
185
|
+
*/
|
|
186
|
+
useRefreshTokensFallback?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* A maximum number of seconds to wait before declaring background calls to /authorize as failed for timeout
|
|
189
|
+
* Defaults to 60s.
|
|
190
|
+
*/
|
|
191
|
+
authorizeTimeoutInSeconds?: number;
|
|
192
|
+
/**
|
|
193
|
+
* Specify the timeout for HTTP calls using `fetch`. The default is 10 seconds.
|
|
194
|
+
*/
|
|
195
|
+
httpTimeoutInSeconds?: number;
|
|
196
|
+
/**
|
|
197
|
+
* Internal property to send information about the client to the authorization server.
|
|
198
|
+
* @internal
|
|
199
|
+
*/
|
|
200
|
+
auth0Client?: {
|
|
201
|
+
name: string;
|
|
202
|
+
version: string;
|
|
203
|
+
env?: {
|
|
204
|
+
[key: string]: string;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Sets an additional cookie with no SameSite attribute to support legacy browsers
|
|
209
|
+
* that are not compatible with the latest SameSite changes.
|
|
210
|
+
* This will log a warning on modern browsers, you can disable the warning by setting
|
|
211
|
+
* this to false but be aware that some older useragents will not work,
|
|
212
|
+
* See https://www.chromium.org/updates/same-site/incompatible-clients
|
|
213
|
+
* Defaults to true
|
|
214
|
+
*/
|
|
215
|
+
legacySameSiteCookie?: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* If `true`, the SDK will use a cookie when storing information about the auth transaction while
|
|
218
|
+
* the user is going through the authentication flow on the authorization server.
|
|
219
|
+
*
|
|
220
|
+
* The default is `false`, in which case the SDK will use session storage.
|
|
221
|
+
*
|
|
222
|
+
* @notes
|
|
223
|
+
*
|
|
224
|
+
* You might want to enable this if you rely on your users being able to authenticate using flows that
|
|
225
|
+
* may end up spanning across multiple tabs (e.g. magic links) or you cannot otherwise rely on session storage being available.
|
|
226
|
+
*/
|
|
227
|
+
useCookiesForTransactions?: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Number of days until the cookie `auth0.is.authenticated` will expire
|
|
230
|
+
* Defaults to 1.
|
|
231
|
+
*/
|
|
232
|
+
sessionCheckExpiryDays?: number;
|
|
233
|
+
/**
|
|
234
|
+
* The domain the cookie is accessible from. If not set, the cookie is scoped to
|
|
235
|
+
* the current domain, including the subdomain.
|
|
236
|
+
*
|
|
237
|
+
* Note: setting this incorrectly may cause silent authentication to stop working
|
|
238
|
+
* on page load.
|
|
239
|
+
*
|
|
240
|
+
*
|
|
241
|
+
* To keep a user logged in across multiple subdomains set this to your
|
|
242
|
+
* top-level domain and prefixed with a `.` (eg: `.example.com`).
|
|
243
|
+
*/
|
|
244
|
+
cookieDomain?: string;
|
|
245
|
+
/**
|
|
246
|
+
* If true, data to the token endpoint is transmitted as x-www-form-urlencoded data, if false it will be transmitted as JSON. The default setting is `true`.
|
|
247
|
+
*
|
|
248
|
+
* **Note:** Setting this to `false` may affect you if you use Auth0 Rules and are sending custom, non-primitive data. If you disable this,
|
|
249
|
+
* please verify that your Auth0 Rules continue to work as intended.
|
|
250
|
+
*/
|
|
251
|
+
useFormData?: boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Modify the value used as the current time during the token validation.
|
|
254
|
+
*
|
|
255
|
+
* **Note**: Using this improperly can potentially compromise the token validation.
|
|
256
|
+
*/
|
|
257
|
+
nowProvider?: () => Promise<number> | number;
|
|
258
|
+
/**
|
|
259
|
+
* If provided, the SDK will load the token worker from this URL instead of the integrated `blob`. An example of when this is useful is if you have strict
|
|
260
|
+
* Content-Security-Policy (CSP) and wish to avoid needing to set `worker-src: blob:`. We recommend either serving the worker, which you can find in the module
|
|
261
|
+
* at `<module_path>/dist/auth0-spa-js.worker.production.js`, from the same host as your application or using the Auth0 CDN
|
|
262
|
+
* `https://cdn.auth0.com/js/auth0-spa-js/<version>/auth0-spa-js.worker.production.js`.
|
|
263
|
+
*
|
|
264
|
+
* **Note**: The worker is only used when `useRefreshTokens: true`, `cacheLocation: 'memory'`, and the `cache` is not custom.
|
|
265
|
+
*/
|
|
266
|
+
workerUrl?: string;
|
|
267
|
+
/**
|
|
268
|
+
* If `true`, the SDK will allow the refreshing of tokens using MRRT
|
|
269
|
+
*/
|
|
270
|
+
useMrrt?: boolean;
|
|
271
|
+
/**
|
|
272
|
+
* If `true`, DPoP (OAuth 2.0 Demonstrating Proof of Possession, RFC9449)
|
|
273
|
+
* will be used to cryptographically bind tokens to this specific browser
|
|
274
|
+
* so they can't be used from a different device in case of a leak.
|
|
275
|
+
*
|
|
276
|
+
* The default setting is `false`.
|
|
277
|
+
*/
|
|
278
|
+
useDpop?: boolean;
|
|
279
|
+
/**
|
|
280
|
+
* Configures automatic handling of interactive authentication errors.
|
|
281
|
+
*
|
|
282
|
+
* When set, the SDK intercepts `mfa_required` errors from `getTokenSilently()`
|
|
283
|
+
* and handles them automatically instead of throwing to the caller.
|
|
284
|
+
*
|
|
285
|
+
* - `'popup'`: Opens Universal Login in a popup to complete MFA.
|
|
286
|
+
* The original `authorizationParams` (audience, scope) are preserved.
|
|
287
|
+
* On success, the token is returned. On failure, popup errors are thrown.
|
|
288
|
+
*
|
|
289
|
+
* This option only affects `getTokenSilently()`. Other methods are not affected.
|
|
290
|
+
*
|
|
291
|
+
* @default undefined (MFA errors are thrown to the caller)
|
|
292
|
+
*/
|
|
293
|
+
interactiveErrorHandler?: InteractiveErrorHandler;
|
|
294
|
+
/**
|
|
295
|
+
* URL parameters that will be sent back to the Authorization Server. This can be known parameters
|
|
296
|
+
* defined by Auth0 or custom parameters that you define.
|
|
297
|
+
*/
|
|
298
|
+
authorizationParams?: ClientAuthorizationParams;
|
|
299
|
+
/**
|
|
300
|
+
* Query parameter name to extract the session transfer token from for Native to Web SSO.
|
|
301
|
+
*
|
|
302
|
+
* When set, the SDK automatically extracts the token from the specified URL query
|
|
303
|
+
* parameter and includes it as `session_transfer_token` in authorization requests.
|
|
304
|
+
* This enables seamless single sign-on when users transition from a native mobile
|
|
305
|
+
* application to a web application.
|
|
306
|
+
*
|
|
307
|
+
* After extraction, the token is automatically removed from the URL using
|
|
308
|
+
* `window.history.replaceState()` to prevent accidental reuse on subsequent
|
|
309
|
+
* authentication requests.
|
|
310
|
+
*
|
|
311
|
+
* **Default:** `undefined` (feature disabled)
|
|
312
|
+
*
|
|
313
|
+
* **Common values:**
|
|
314
|
+
* - `'session_transfer_token'` - Standard parameter name
|
|
315
|
+
* - `'stt'` - Shortened version
|
|
316
|
+
* - Custom parameter name of your choice
|
|
317
|
+
*
|
|
318
|
+
* Set to `undefined` to disable automatic extraction if you prefer to handle
|
|
319
|
+
* session transfer tokens manually.
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```js
|
|
323
|
+
* const auth0 = await createAuth0Client({
|
|
324
|
+
* domain: '<AUTH0_DOMAIN>',
|
|
325
|
+
* clientId: '<AUTH0_CLIENT_ID>',
|
|
326
|
+
* sessionTransferTokenQueryParamName: 'session_transfer_token'
|
|
327
|
+
* });
|
|
328
|
+
* ```
|
|
329
|
+
*
|
|
330
|
+
* @see https://auth0.com/docs/authenticate/single-sign-on/native-to-web
|
|
331
|
+
*/
|
|
332
|
+
sessionTransferTokenQueryParamName?: string;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Configuration details exposed by the Auth0Client after initialization.
|
|
336
|
+
*
|
|
337
|
+
* @category Main
|
|
338
|
+
*/
|
|
339
|
+
export interface ClientConfiguration {
|
|
340
|
+
/**
|
|
341
|
+
* The Auth0 domain that was configured
|
|
342
|
+
*/
|
|
343
|
+
domain: string;
|
|
344
|
+
/**
|
|
345
|
+
* The Auth0 client ID that was configured
|
|
346
|
+
*/
|
|
347
|
+
clientId: string;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* The possible locations where tokens can be stored
|
|
351
|
+
*/
|
|
352
|
+
export type CacheLocation = 'memory' | 'localstorage';
|
|
353
|
+
/**
|
|
354
|
+
* @ignore
|
|
355
|
+
*/
|
|
356
|
+
export interface AuthorizeOptions extends AuthorizationParams {
|
|
357
|
+
response_type: string;
|
|
358
|
+
response_mode: string;
|
|
359
|
+
redirect_uri?: string;
|
|
360
|
+
nonce: string;
|
|
361
|
+
state: string;
|
|
362
|
+
scope: string;
|
|
363
|
+
code_challenge: string;
|
|
364
|
+
code_challenge_method: string;
|
|
365
|
+
}
|
|
366
|
+
export interface RedirectLoginOptions<TAppState = any> extends BaseLoginOptions {
|
|
367
|
+
/**
|
|
368
|
+
* Used to store state before doing the redirect
|
|
369
|
+
*/
|
|
370
|
+
appState?: TAppState;
|
|
371
|
+
/**
|
|
372
|
+
* Used to add to the URL fragment before redirecting
|
|
373
|
+
*/
|
|
374
|
+
fragment?: string;
|
|
375
|
+
/**
|
|
376
|
+
* Used to control the redirect and not rely on the SDK to do the actual redirect.
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* const client = new Auth0Client({
|
|
380
|
+
* async onRedirect(url) {
|
|
381
|
+
* window.location.replace(url);
|
|
382
|
+
* }
|
|
383
|
+
* });
|
|
384
|
+
* @deprecated since v2.0.1, use `openUrl` instead.
|
|
385
|
+
*/
|
|
386
|
+
onRedirect?: (url: string) => Promise<void>;
|
|
387
|
+
/**
|
|
388
|
+
* Used to control the redirect and not rely on the SDK to do the actual redirect.
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* const client = new Auth0Client({
|
|
392
|
+
* openUrl(url) {
|
|
393
|
+
* window.location.replace(url);
|
|
394
|
+
* }
|
|
395
|
+
* });
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* import { Browser } from '@capacitor/browser';
|
|
399
|
+
*
|
|
400
|
+
* const client = new Auth0Client({
|
|
401
|
+
* async openUrl(url) {
|
|
402
|
+
* await Browser.open({ url });
|
|
403
|
+
* }
|
|
404
|
+
* });
|
|
405
|
+
*/
|
|
406
|
+
openUrl?: (url: string) => Promise<void> | void;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* The types of responses expected from the authorization server.
|
|
410
|
+
* - `code`: used for the standard login flow.
|
|
411
|
+
* - `connect_code`: used for the connect account flow.
|
|
412
|
+
*/
|
|
413
|
+
export declare enum ResponseType {
|
|
414
|
+
Code = "code",
|
|
415
|
+
ConnectCode = "connect_code"
|
|
416
|
+
}
|
|
417
|
+
export interface RedirectLoginResult<TAppState = any> {
|
|
418
|
+
/**
|
|
419
|
+
* State stored when the redirect request was made
|
|
420
|
+
*/
|
|
421
|
+
appState?: TAppState;
|
|
422
|
+
/**
|
|
423
|
+
* The type of response, for login it will be `code`
|
|
424
|
+
*/
|
|
425
|
+
response_type: ResponseType.Code;
|
|
426
|
+
}
|
|
427
|
+
export interface PopupLoginOptions extends BaseLoginOptions {
|
|
428
|
+
}
|
|
429
|
+
export interface PopupConfigOptions {
|
|
430
|
+
/**
|
|
431
|
+
* The number of seconds to wait for a popup response before
|
|
432
|
+
* throwing a timeout error. Defaults to 60s
|
|
433
|
+
*/
|
|
434
|
+
timeoutInSeconds?: number;
|
|
435
|
+
/**
|
|
436
|
+
* Accepts an already-created popup window to use. If not specified, the SDK
|
|
437
|
+
* will create its own. This may be useful for platforms like iOS that have
|
|
438
|
+
* security restrictions around when popups can be invoked (e.g. from a user click event)
|
|
439
|
+
*/
|
|
440
|
+
popup?: any;
|
|
441
|
+
/**
|
|
442
|
+
* Controls whether the SDK automatically closes the popup window.
|
|
443
|
+
*
|
|
444
|
+
* - `true` (default): SDK closes the popup automatically after receiving the authorization response
|
|
445
|
+
* - `false`: SDK does not close the popup. The caller is responsible for closing it, including on errors.
|
|
446
|
+
*
|
|
447
|
+
* Setting this to `false` is useful when you need full control over the popup lifecycle,
|
|
448
|
+
* such as in Chrome extensions where closing the popup too early can terminate the
|
|
449
|
+
* extension's service worker before authentication completes.
|
|
450
|
+
*
|
|
451
|
+
* When `closePopup: false`, you should close the popup in a try/finally block:
|
|
452
|
+
* ```
|
|
453
|
+
* const popup = window.open('', '_blank');
|
|
454
|
+
* try {
|
|
455
|
+
* await auth0.loginWithPopup({}, { popup, closePopup: false });
|
|
456
|
+
* } finally {
|
|
457
|
+
* popup.close();
|
|
458
|
+
* }
|
|
459
|
+
* ```
|
|
460
|
+
*
|
|
461
|
+
* @default true
|
|
462
|
+
*/
|
|
463
|
+
closePopup?: boolean;
|
|
464
|
+
}
|
|
465
|
+
export interface GetTokenSilentlyOptions {
|
|
466
|
+
/**
|
|
467
|
+
* When `off`, ignores the cache and always sends a
|
|
468
|
+
* request to Auth0.
|
|
469
|
+
* When `cache-only`, only reads from the cache and never sends a request to Auth0.
|
|
470
|
+
* Defaults to `on`, where it both reads from the cache and sends a request to Auth0 as needed.
|
|
471
|
+
*/
|
|
472
|
+
cacheMode?: 'on' | 'off' | 'cache-only';
|
|
473
|
+
/**
|
|
474
|
+
* Parameters that will be sent back to Auth0 as part of a request.
|
|
475
|
+
*/
|
|
476
|
+
authorizationParams?: {
|
|
477
|
+
/**
|
|
478
|
+
* There's no actual redirect when getting a token silently,
|
|
479
|
+
* but, according to the spec, a `redirect_uri` param is required.
|
|
480
|
+
* Auth0 uses this parameter to validate that the current `origin`
|
|
481
|
+
* matches the `redirect_uri` `origin` when sending the response.
|
|
482
|
+
* It must be whitelisted in the "Allowed Web Origins" in your
|
|
483
|
+
* Auth0 Application's settings.
|
|
484
|
+
*/
|
|
485
|
+
redirect_uri?: string;
|
|
486
|
+
/**
|
|
487
|
+
* The scope that was used in the authentication request
|
|
488
|
+
*/
|
|
489
|
+
scope?: string;
|
|
490
|
+
/**
|
|
491
|
+
* The audience that was used in the authentication request
|
|
492
|
+
*/
|
|
493
|
+
audience?: string;
|
|
494
|
+
/**
|
|
495
|
+
* If you need to send custom parameters to the Authorization Server,
|
|
496
|
+
* make sure to use the original parameter name.
|
|
497
|
+
*/
|
|
498
|
+
[key: string]: any;
|
|
499
|
+
};
|
|
500
|
+
/** A maximum number of seconds to wait before declaring the background /authorize call as failed for timeout
|
|
501
|
+
* Defaults to 60s.
|
|
502
|
+
*/
|
|
503
|
+
timeoutInSeconds?: number;
|
|
504
|
+
/**
|
|
505
|
+
* If true, the full response from the /oauth/token endpoint (or the cache, if the cache was used) is returned
|
|
506
|
+
* (minus `refresh_token` if one was issued). Otherwise, just the access token is returned.
|
|
507
|
+
*
|
|
508
|
+
* The default is `false`.
|
|
509
|
+
*/
|
|
510
|
+
detailedResponse?: boolean;
|
|
511
|
+
}
|
|
512
|
+
export interface GetTokenWithPopupOptions extends PopupLoginOptions {
|
|
513
|
+
/**
|
|
514
|
+
* When `off`, ignores the cache and always sends a request to Auth0.
|
|
515
|
+
* When `cache-only`, only reads from the cache and never sends a request to Auth0.
|
|
516
|
+
* Defaults to `on`, where it both reads from the cache and sends a request to Auth0 as needed.
|
|
517
|
+
*/
|
|
518
|
+
cacheMode?: 'on' | 'off' | 'cache-only';
|
|
519
|
+
}
|
|
520
|
+
export interface LogoutUrlOptions {
|
|
521
|
+
/**
|
|
522
|
+
* The `clientId` of your application.
|
|
523
|
+
*
|
|
524
|
+
* If this property is not set, then the `clientId` that was used during initialization of the SDK is sent to the logout endpoint.
|
|
525
|
+
*
|
|
526
|
+
* If this property is set to `null`, then no client ID value is sent to the logout endpoint.
|
|
527
|
+
*
|
|
528
|
+
* [Read more about how redirecting after logout works](https://auth0.com/docs/logout/guides/redirect-users-after-logout)
|
|
529
|
+
*/
|
|
530
|
+
clientId?: string | null;
|
|
531
|
+
/**
|
|
532
|
+
* Parameters to pass to the logout endpoint. This can be known parameters defined by Auth0 or custom parameters
|
|
533
|
+
* you wish to provide.
|
|
534
|
+
*/
|
|
535
|
+
logoutParams?: {
|
|
536
|
+
/**
|
|
537
|
+
* When supported by the upstream identity provider,
|
|
538
|
+
* forces the user to logout of their identity provider
|
|
539
|
+
* and from Auth0.
|
|
540
|
+
* [Read more about how federated logout works at Auth0](https://auth0.com/docs/logout/guides/logout-idps)
|
|
541
|
+
*/
|
|
542
|
+
federated?: boolean;
|
|
543
|
+
/**
|
|
544
|
+
* The URL where Auth0 will redirect your browser to after the logout.
|
|
545
|
+
*
|
|
546
|
+
* **Note**: If the `client_id` parameter is included, the
|
|
547
|
+
* `returnTo` URL that is provided must be listed in the
|
|
548
|
+
* Application's "Allowed Logout URLs" in the Auth0 dashboard.
|
|
549
|
+
* However, if the `client_id` parameter is not included, the
|
|
550
|
+
* `returnTo` URL must be listed in the "Allowed Logout URLs" at
|
|
551
|
+
* the account level in the Auth0 dashboard.
|
|
552
|
+
*
|
|
553
|
+
* [Read more about how redirecting after logout works](https://auth0.com/docs/logout/guides/redirect-users-after-logout)
|
|
554
|
+
*/
|
|
555
|
+
returnTo?: string;
|
|
556
|
+
/**
|
|
557
|
+
* If you need to send custom parameters to the logout endpoint, make sure to use the original parameter name.
|
|
558
|
+
*/
|
|
559
|
+
[key: string]: any;
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
export interface LogoutOptions extends LogoutUrlOptions {
|
|
563
|
+
/**
|
|
564
|
+
* Used to control the redirect and not rely on the SDK to do the actual redirect.
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* await auth0.logout({
|
|
568
|
+
* async onRedirect(url) {
|
|
569
|
+
* window.location.replace(url);
|
|
570
|
+
* }
|
|
571
|
+
* });
|
|
572
|
+
* @deprecated since v2.0.1, use `openUrl` instead.
|
|
573
|
+
*/
|
|
574
|
+
onRedirect?: (url: string) => Promise<void>;
|
|
575
|
+
/**
|
|
576
|
+
* Used to control the redirect and not rely on the SDK to do the actual redirect.
|
|
577
|
+
*
|
|
578
|
+
* Set to `false` to disable the redirect, or provide a function to handle the actual redirect yourself.
|
|
579
|
+
*
|
|
580
|
+
* @example
|
|
581
|
+
* await auth0.logout({
|
|
582
|
+
* openUrl(url) {
|
|
583
|
+
* window.location.replace(url);
|
|
584
|
+
* }
|
|
585
|
+
* });
|
|
586
|
+
*
|
|
587
|
+
* @example
|
|
588
|
+
* import { Browser } from '@capacitor/browser';
|
|
589
|
+
*
|
|
590
|
+
* await auth0.logout({
|
|
591
|
+
* async openUrl(url) {
|
|
592
|
+
* await Browser.open({ url });
|
|
593
|
+
* }
|
|
594
|
+
* });
|
|
595
|
+
*/
|
|
596
|
+
openUrl?: false | ((url: string) => Promise<void> | void);
|
|
597
|
+
}
|
|
598
|
+
export interface RedirectConnectAccountOptions<TAppState = any> {
|
|
599
|
+
/**
|
|
600
|
+
* The name of the connection to link (e.g. 'google-oauth2').
|
|
601
|
+
*/
|
|
602
|
+
connection: string;
|
|
603
|
+
/**
|
|
604
|
+
* Array of scopes to request from the Identity Provider during the connect account flow.
|
|
605
|
+
*
|
|
606
|
+
* @example
|
|
607
|
+
* await auth0.connectAccountWithRedirect({
|
|
608
|
+
* connection: 'google-oauth2',
|
|
609
|
+
* scopes: ['https://www.googleapis.com/auth/calendar']
|
|
610
|
+
* });
|
|
611
|
+
*/
|
|
612
|
+
scopes?: string[];
|
|
613
|
+
/**
|
|
614
|
+
* Additional authorization parameters for the request.
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* await auth0.connectAccountWithRedirect({
|
|
618
|
+
* connection: 'github',
|
|
619
|
+
* authorization_params: {
|
|
620
|
+
* audience: 'https://api.github.com'
|
|
621
|
+
* }
|
|
622
|
+
* });
|
|
623
|
+
*/
|
|
624
|
+
authorization_params?: AuthorizationParams;
|
|
625
|
+
/**
|
|
626
|
+
* The URI to redirect back to after connecting the account.
|
|
627
|
+
*/
|
|
628
|
+
redirectUri?: string;
|
|
629
|
+
/**
|
|
630
|
+
* Optional application state to persist through the transaction.
|
|
631
|
+
*
|
|
632
|
+
* @example
|
|
633
|
+
* await auth0.connectAccountWithRedirect({
|
|
634
|
+
* connection: 'google-oauth2',
|
|
635
|
+
* appState: { returnTo: '/settings' }
|
|
636
|
+
* });
|
|
637
|
+
*/
|
|
638
|
+
appState?: TAppState;
|
|
639
|
+
/**
|
|
640
|
+
* Optional function to handle the redirect URL.
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* await auth0.connectAccountWithRedirect({
|
|
644
|
+
* connection: 'google-oauth2',
|
|
645
|
+
* openUrl: async (url) => { myBrowserApi.open(url); }
|
|
646
|
+
* });
|
|
647
|
+
*/
|
|
648
|
+
openUrl?: (url: string) => Promise<void>;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* The result returned after a successful account connection redirect.
|
|
652
|
+
*
|
|
653
|
+
* Combines the redirect login result (including any persisted app state)
|
|
654
|
+
* with the complete response from the My Account API.
|
|
655
|
+
*
|
|
656
|
+
* @template TAppState - The type of application state persisted through the transaction.
|
|
657
|
+
* @example
|
|
658
|
+
* const result = await auth0.connectAccountWithRedirect(options);
|
|
659
|
+
* console.log(result.appState); // Access persisted app state
|
|
660
|
+
* console.log(result.connection); // The connection of the account you connected to.
|
|
661
|
+
* console.log(result.response_type === 'connect_code'); // The response type will be 'connect_code'
|
|
662
|
+
*/
|
|
663
|
+
export type ConnectAccountRedirectResult<TAppState = any> = CompleteResponse & {
|
|
664
|
+
/**
|
|
665
|
+
* State stored when the redirect request was made
|
|
666
|
+
*/
|
|
667
|
+
appState?: TAppState;
|
|
668
|
+
/**
|
|
669
|
+
* The type of response, for connect account it will be `connect_code`
|
|
670
|
+
*/
|
|
671
|
+
response_type: ResponseType.ConnectCode;
|
|
672
|
+
};
|
|
673
|
+
/**
|
|
674
|
+
* @ignore
|
|
675
|
+
*/
|
|
676
|
+
export interface AuthenticationResult {
|
|
677
|
+
state: string;
|
|
678
|
+
code?: string;
|
|
679
|
+
/**
|
|
680
|
+
* This is for the redirect from the connect account flow.
|
|
681
|
+
*/
|
|
682
|
+
connect_code?: string;
|
|
683
|
+
error?: string;
|
|
684
|
+
error_description?: string;
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* @ignore
|
|
688
|
+
*/
|
|
689
|
+
export interface TokenEndpointOptions {
|
|
690
|
+
baseUrl: string;
|
|
691
|
+
client_id: string;
|
|
692
|
+
grant_type: string;
|
|
693
|
+
timeout?: number;
|
|
694
|
+
auth0Client: any;
|
|
695
|
+
useFormData?: boolean;
|
|
696
|
+
dpop?: Pick<Dpop, 'generateProof' | 'getNonce' | 'setNonce'>;
|
|
697
|
+
[key: string]: any;
|
|
698
|
+
}
|
|
699
|
+
export type TokenEndpointResponse = {
|
|
700
|
+
id_token: string;
|
|
701
|
+
token_type: string;
|
|
702
|
+
access_token: string;
|
|
703
|
+
refresh_token?: string;
|
|
704
|
+
expires_in: number;
|
|
705
|
+
scope?: string;
|
|
706
|
+
};
|
|
707
|
+
/**
|
|
708
|
+
* @ignore
|
|
709
|
+
*/
|
|
710
|
+
export interface OAuthTokenOptions extends TokenEndpointOptions {
|
|
711
|
+
code_verifier: string;
|
|
712
|
+
code: string;
|
|
713
|
+
redirect_uri: string;
|
|
714
|
+
audience: string;
|
|
715
|
+
scope: string;
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* @ignore
|
|
719
|
+
*/
|
|
720
|
+
export interface RefreshTokenOptions extends TokenEndpointOptions {
|
|
721
|
+
refresh_token: string;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* @ignore
|
|
725
|
+
*/
|
|
726
|
+
export interface JWTVerifyOptions {
|
|
727
|
+
iss: string;
|
|
728
|
+
aud: string;
|
|
729
|
+
id_token: string;
|
|
730
|
+
nonce?: string;
|
|
731
|
+
leeway?: number;
|
|
732
|
+
max_age?: number;
|
|
733
|
+
organization?: string;
|
|
734
|
+
now?: number;
|
|
735
|
+
}
|
|
736
|
+
export interface IdToken {
|
|
737
|
+
__raw: string;
|
|
738
|
+
name?: string;
|
|
739
|
+
given_name?: string;
|
|
740
|
+
family_name?: string;
|
|
741
|
+
middle_name?: string;
|
|
742
|
+
nickname?: string;
|
|
743
|
+
preferred_username?: string;
|
|
744
|
+
profile?: string;
|
|
745
|
+
picture?: string;
|
|
746
|
+
website?: string;
|
|
747
|
+
email?: string;
|
|
748
|
+
email_verified?: boolean;
|
|
749
|
+
gender?: string;
|
|
750
|
+
birthdate?: string;
|
|
751
|
+
zoneinfo?: string;
|
|
752
|
+
locale?: string;
|
|
753
|
+
phone_number?: string;
|
|
754
|
+
phone_number_verified?: boolean;
|
|
755
|
+
address?: string;
|
|
756
|
+
updated_at?: string;
|
|
757
|
+
iss?: string;
|
|
758
|
+
aud?: string;
|
|
759
|
+
exp?: number;
|
|
760
|
+
nbf?: number;
|
|
761
|
+
iat?: number;
|
|
762
|
+
jti?: string;
|
|
763
|
+
azp?: string;
|
|
764
|
+
nonce?: string;
|
|
765
|
+
auth_time?: string;
|
|
766
|
+
at_hash?: string;
|
|
767
|
+
c_hash?: string;
|
|
768
|
+
acr?: string;
|
|
769
|
+
amr?: string[];
|
|
770
|
+
sub_jwk?: string;
|
|
771
|
+
cnf?: string;
|
|
772
|
+
sid?: string;
|
|
773
|
+
org_id?: string;
|
|
774
|
+
org_name?: string;
|
|
775
|
+
[key: string]: any;
|
|
776
|
+
}
|
|
777
|
+
export declare class User {
|
|
778
|
+
name?: string;
|
|
779
|
+
given_name?: string;
|
|
780
|
+
family_name?: string;
|
|
781
|
+
middle_name?: string;
|
|
782
|
+
nickname?: string;
|
|
783
|
+
preferred_username?: string;
|
|
784
|
+
profile?: string;
|
|
785
|
+
picture?: string;
|
|
786
|
+
website?: string;
|
|
787
|
+
email?: string;
|
|
788
|
+
email_verified?: boolean;
|
|
789
|
+
gender?: string;
|
|
790
|
+
birthdate?: string;
|
|
791
|
+
zoneinfo?: string;
|
|
792
|
+
locale?: string;
|
|
793
|
+
phone_number?: string;
|
|
794
|
+
phone_number_verified?: boolean;
|
|
795
|
+
address?: string;
|
|
796
|
+
updated_at?: string;
|
|
797
|
+
sub?: string;
|
|
798
|
+
[key: string]: any;
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* @ignore
|
|
802
|
+
*/
|
|
803
|
+
export type FetchOptions = {
|
|
804
|
+
method?: string;
|
|
805
|
+
headers?: Record<string, string>;
|
|
806
|
+
credentials?: 'include' | 'omit';
|
|
807
|
+
body?: string;
|
|
808
|
+
signal?: AbortSignal;
|
|
809
|
+
};
|
|
810
|
+
/**
|
|
811
|
+
* @ignore
|
|
812
|
+
*/
|
|
813
|
+
export type FetchResponse = {
|
|
814
|
+
ok: boolean;
|
|
815
|
+
headers: Record<string, string | undefined>;
|
|
816
|
+
json: any;
|
|
817
|
+
};
|
|
818
|
+
export type GetTokenSilentlyVerboseResponse = Omit<TokenEndpointResponse, 'refresh_token'>;
|
|
819
|
+
/**
|
|
820
|
+
* Options for revoking a refresh token
|
|
821
|
+
*/
|
|
822
|
+
export interface RevokeRefreshTokenOptions {
|
|
823
|
+
/** Audience to identify which refresh token to revoke. Omit for default audience. */
|
|
824
|
+
audience?: string;
|
|
825
|
+
}
|
|
826
|
+
export type { Authenticator, AuthenticatorType, OobChannel, MfaFactorType, EnrollParams, EnrollOtpParams, EnrollSmsParams, EnrollVoiceParams, EnrollEmailParams, EnrollPushParams, EnrollmentResponse, OtpEnrollmentResponse, OobEnrollmentResponse, ChallengeAuthenticatorParams, ChallengeResponse, VerifyParams, MfaGrantType, EnrollmentFactor } from './mfa/types';
|