@auth0/auth0-spa-js 2.18.1 → 2.18.2

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 (48) hide show
  1. package/dist/auth0-spa-js.development.js +2 -65
  2. package/dist/auth0-spa-js.development.js.map +1 -1
  3. package/dist/auth0-spa-js.production.esm.js +1 -1
  4. package/dist/auth0-spa-js.production.esm.js.map +1 -1
  5. package/dist/auth0-spa-js.production.js +1 -1
  6. package/dist/auth0-spa-js.production.js.map +1 -1
  7. package/dist/lib/auth0-spa-js.cjs.js +2 -65
  8. package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
  9. package/dist/typings/Auth0Client.d.ts +439 -0
  10. package/dist/typings/Auth0Client.utils.d.ts +90 -0
  11. package/dist/typings/MyAccountApiClient.d.ts +92 -0
  12. package/dist/typings/TokenExchange.d.ts +77 -0
  13. package/dist/typings/api.d.ts +2 -0
  14. package/dist/typings/cache/cache-localstorage.d.ts +7 -0
  15. package/dist/typings/cache/cache-manager.d.ts +56 -0
  16. package/dist/typings/cache/cache-memory.d.ts +4 -0
  17. package/dist/typings/cache/index.d.ts +4 -0
  18. package/dist/typings/cache/key-manifest.d.ts +12 -0
  19. package/dist/typings/cache/shared.d.ts +68 -0
  20. package/dist/typings/constants.d.ts +58 -0
  21. package/dist/typings/dpop/dpop.d.ts +17 -0
  22. package/dist/typings/dpop/storage.d.ts +27 -0
  23. package/dist/typings/dpop/utils.d.ts +15 -0
  24. package/dist/typings/errors.d.ts +96 -0
  25. package/dist/typings/fetcher.d.ts +54 -0
  26. package/dist/typings/global.d.ts +819 -0
  27. package/dist/typings/http.d.ts +5 -0
  28. package/dist/typings/index.d.ts +24 -0
  29. package/dist/typings/jwt.d.ts +21 -0
  30. package/dist/typings/lock.d.ts +32 -0
  31. package/dist/typings/mfa/MfaApiClient.d.ts +225 -0
  32. package/dist/typings/mfa/MfaContextManager.d.ts +79 -0
  33. package/dist/typings/mfa/constants.d.ts +23 -0
  34. package/dist/typings/mfa/errors.d.ts +117 -0
  35. package/dist/typings/mfa/index.d.ts +4 -0
  36. package/dist/typings/mfa/types.d.ts +181 -0
  37. package/dist/typings/mfa/utils.d.ts +23 -0
  38. package/dist/typings/promise-utils.d.ts +2 -0
  39. package/dist/typings/scope.d.ts +35 -0
  40. package/dist/typings/storage.d.ts +26 -0
  41. package/dist/typings/transaction-manager.d.ts +33 -0
  42. package/dist/typings/utils.d.ts +36 -0
  43. package/dist/typings/version.d.ts +2 -0
  44. package/dist/typings/worker/token.worker.d.ts +1 -0
  45. package/dist/typings/worker/worker.types.d.ts +15 -0
  46. package/dist/typings/worker/worker.utils.d.ts +7 -0
  47. package/package.json +4 -3
  48. package/src/version.ts +1 -1
@@ -0,0 +1,439 @@
1
+ import { Auth0ClientOptions, RedirectLoginOptions, PopupLoginOptions, PopupConfigOptions, RedirectLoginResult, GetTokenSilentlyOptions, GetTokenWithPopupOptions, LogoutOptions, User, IdToken, GetTokenSilentlyVerboseResponse, TokenEndpointResponse, ConnectAccountRedirectResult, RedirectConnectAccountOptions, ClientConfiguration } from './global';
2
+ import { CustomTokenExchangeOptions } from './TokenExchange';
3
+ import { Dpop } from './dpop/dpop';
4
+ import { Fetcher, type FetcherConfig, type CustomFetchMinimalOutput } from './fetcher';
5
+ import { MfaApiClient } from './mfa';
6
+ /**
7
+ * Auth0 SDK for Single Page Applications using [Authorization Code Grant Flow with PKCE](https://auth0.com/docs/api-auth/tutorials/authorization-code-grant-pkce).
8
+ */
9
+ export declare class Auth0Client {
10
+ private readonly transactionManager;
11
+ private readonly cacheManager;
12
+ private readonly lockManager;
13
+ private readonly domainUrl;
14
+ private readonly tokenIssuer;
15
+ private readonly scope;
16
+ private readonly cookieStorage;
17
+ private readonly dpop;
18
+ private readonly sessionCheckExpiryDays;
19
+ private readonly orgHintCookieName;
20
+ private readonly isAuthenticatedCookieName;
21
+ private readonly nowProvider;
22
+ private readonly httpTimeoutMs;
23
+ private readonly options;
24
+ private readonly userCache;
25
+ private readonly myAccountApi;
26
+ /**
27
+ * MFA API client for multi-factor authentication operations.
28
+ *
29
+ * Provides methods for:
30
+ * - Listing enrolled authenticators
31
+ * - Enrolling new authenticators (OTP, SMS, Voice, Push, Email)
32
+ * - Initiating MFA challenges
33
+ * - Verifying MFA challenges
34
+ */
35
+ readonly mfa: MfaApiClient;
36
+ private worker?;
37
+ private readonly authJsClient;
38
+ private readonly defaultOptions;
39
+ constructor(options: Auth0ClientOptions);
40
+ /**
41
+ * Returns a readonly copy of the initialization configuration.
42
+ *
43
+ * @returns An object containing domain and clientId
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const auth0 = new Auth0Client({
48
+ * domain: 'tenant.auth0.com',
49
+ * clientId: 'abc123'
50
+ * });
51
+ *
52
+ * const config = auth0.getConfiguration();
53
+ * // { domain: 'tenant.auth0.com', clientId: 'abc123' }
54
+ * ```
55
+ */
56
+ getConfiguration(): Readonly<ClientConfiguration>;
57
+ private _url;
58
+ private _authorizeUrl;
59
+ private _verifyIdToken;
60
+ private _processOrgHint;
61
+ /**
62
+ * Extracts the session transfer token from the current URL query parameters
63
+ * for Native to Web SSO flows.
64
+ *
65
+ * @param paramName The query parameter name to extract from the URL
66
+ * @returns The session transfer token if present, undefined otherwise
67
+ */
68
+ private _extractSessionTransferToken;
69
+ /**
70
+ * Clears the session transfer token from the current URL using the History API.
71
+ * This prevents the token from being re-sent on subsequent authentication requests,
72
+ * which is important since session transfer tokens are typically single-use.
73
+ *
74
+ * @param paramName The query parameter name to remove from the URL
75
+ */
76
+ private _clearSessionTransferTokenFromUrl;
77
+ /**
78
+ * Applies the session transfer token from the URL to the authorization parameters
79
+ * if configured and not already provided.
80
+ *
81
+ * @param authorizationParams The authorization parameters to enhance
82
+ * @returns The authorization parameters with session_transfer_token added if applicable
83
+ */
84
+ private _applySessionTransferToken;
85
+ private _prepareAuthorizeUrl;
86
+ /**
87
+ * ```js
88
+ * try {
89
+ * await auth0.loginWithPopup(options);
90
+ * } catch(e) {
91
+ * if (e instanceof PopupCancelledError) {
92
+ * // Popup was closed before login completed
93
+ * }
94
+ * }
95
+ * ```
96
+ *
97
+ * Opens a popup with the `/authorize` URL using the parameters
98
+ * provided as arguments. Random and secure `state` and `nonce`
99
+ * parameters will be auto-generated. If the response is successful,
100
+ * results will be valid according to their expiration times.
101
+ *
102
+ * IMPORTANT: This method has to be called from an event handler
103
+ * that was started by the user like a button click, for example,
104
+ * otherwise the popup will be blocked in most browsers.
105
+ *
106
+ * @param options
107
+ * @param config
108
+ */
109
+ loginWithPopup(options?: PopupLoginOptions, config?: PopupConfigOptions): Promise<void>;
110
+ /**
111
+ * ```js
112
+ * const user = await auth0.getUser();
113
+ * ```
114
+ *
115
+ * Returns the user information if available (decoded
116
+ * from the `id_token`).
117
+ *
118
+ * @typeparam TUser The type to return, has to extend {@link User}.
119
+ */
120
+ getUser<TUser extends User>(): Promise<TUser | undefined>;
121
+ /**
122
+ * ```js
123
+ * const claims = await auth0.getIdTokenClaims();
124
+ * ```
125
+ *
126
+ * Returns all claims from the id_token if available.
127
+ */
128
+ getIdTokenClaims(): Promise<IdToken | undefined>;
129
+ /**
130
+ * ```js
131
+ * await auth0.loginWithRedirect(options);
132
+ * ```
133
+ *
134
+ * Performs a redirect to `/authorize` using the parameters
135
+ * provided as arguments. Random and secure `state` and `nonce`
136
+ * parameters will be auto-generated.
137
+ *
138
+ * @param options
139
+ */
140
+ loginWithRedirect<TAppState = any>(options?: RedirectLoginOptions<TAppState>): Promise<void>;
141
+ /**
142
+ * After the browser redirects back to the callback page,
143
+ * call `handleRedirectCallback` to handle success and error
144
+ * responses from Auth0. If the response is successful, results
145
+ * will be valid according to their expiration times.
146
+ */
147
+ handleRedirectCallback<TAppState = any>(url?: string): Promise<RedirectLoginResult<TAppState> | ConnectAccountRedirectResult<TAppState>>;
148
+ /**
149
+ * Handles the redirect callback from the login flow.
150
+ *
151
+ * @template AppState - The application state persisted from the /authorize redirect.
152
+ * @param {string} authenticationResult - The parsed authentication result from the URL.
153
+ * @param {string} transaction - The login transaction.
154
+ *
155
+ * @returns {RedirectLoginResult} Resolves with the persisted app state.
156
+ * @throws {GenericError | Error} If the transaction is missing, invalid, or the code exchange fails.
157
+ */
158
+ private _handleLoginRedirectCallback;
159
+ /**
160
+ * Handles the redirect callback from the connect account flow.
161
+ * This works the same as the redirect from the login flow expect it verifies the `connect_code`
162
+ * with the My Account API rather than the `code` with the Authorization Server.
163
+ *
164
+ * @template AppState - The application state persisted from the connect redirect.
165
+ * @param {string} connectResult - The parsed connect accounts result from the URL.
166
+ * @param {string} transaction - The login transaction.
167
+ * @returns {Promise<ConnectAccountRedirectResult>} The result of the My Account API, including any persisted app state.
168
+ * @throws {GenericError | MyAccountApiError} If the transaction is missing, invalid, or an error is returned from the My Account API.
169
+ */
170
+ private _handleConnectAccountRedirectCallback;
171
+ /**
172
+ * ```js
173
+ * await auth0.checkSession();
174
+ * ```
175
+ *
176
+ * Check if the user is logged in using `getTokenSilently`. The difference
177
+ * with `getTokenSilently` is that this doesn't return a token, but it will
178
+ * pre-fill the token cache.
179
+ *
180
+ * This method also heeds the `auth0.{clientId}.is.authenticated` cookie, as an optimization
181
+ * to prevent calling Auth0 unnecessarily. If the cookie is not present because
182
+ * there was no previous login (or it has expired) then tokens will not be refreshed.
183
+ *
184
+ * It should be used for silently logging in the user when you instantiate the
185
+ * `Auth0Client` constructor. You should not need this if you are using the
186
+ * `createAuth0Client` factory.
187
+ *
188
+ * **Note:** the cookie **may not** be present if running an app using a private tab, as some
189
+ * browsers clear JS cookie data and local storage when the tab or page is closed, or on page reload. This effectively
190
+ * means that `checkSession` could silently return without authenticating the user on page refresh when
191
+ * using a private tab, despite having previously logged in. As a workaround, use `getTokenSilently` instead
192
+ * and handle the possible `login_required` error [as shown in the readme](https://github.com/auth0/auth0-spa-js#creating-the-client).
193
+ *
194
+ * @param options
195
+ */
196
+ checkSession(options?: GetTokenSilentlyOptions): Promise<void>;
197
+ /**
198
+ * Fetches a new access token and returns the response from the /oauth/token endpoint, omitting the refresh token.
199
+ *
200
+ * @param options
201
+ */
202
+ getTokenSilently(options: GetTokenSilentlyOptions & {
203
+ detailedResponse: true;
204
+ }): Promise<GetTokenSilentlyVerboseResponse>;
205
+ /**
206
+ * Fetches a new access token and returns it.
207
+ *
208
+ * @param options
209
+ */
210
+ getTokenSilently(options?: GetTokenSilentlyOptions): Promise<string>;
211
+ private _getTokenSilently;
212
+ /**
213
+ * Checks if an error should be handled by the interactive error handler.
214
+ * Matches:
215
+ * - MfaRequiredError (refresh token path, error='mfa_required')
216
+ * - GenericError from iframe path (error='login_required',
217
+ * error_description='Multifactor authentication required')
218
+ * Extensible for future interactive error types.
219
+ */
220
+ private _isInteractiveError;
221
+ /**
222
+ * Checks if a login_required error from the iframe flow is actually
223
+ * an MFA step-up requirement. The /authorize endpoint returns
224
+ * error='login_required' with error_description='Multifactor authentication required'
225
+ * when MFA is needed but prompt=none prevents interaction.
226
+ */
227
+ private _isIframeMfaError;
228
+ /**
229
+ * Handles MFA errors by opening a popup to complete authentication,
230
+ * then reads the resulting token from cache.
231
+ */
232
+ private _handleInteractiveErrorWithPopup;
233
+ /**
234
+ * ```js
235
+ * const token = await auth0.getTokenWithPopup(options);
236
+ * ```
237
+ * Opens a popup with the `/authorize` URL using the parameters
238
+ * provided as arguments. Random and secure `state` and `nonce`
239
+ * parameters will be auto-generated. If the response is successful,
240
+ * results will be valid according to their expiration times.
241
+ *
242
+ * @param options
243
+ * @param config
244
+ */
245
+ getTokenWithPopup(options?: GetTokenWithPopupOptions, config?: PopupConfigOptions): Promise<string | undefined>;
246
+ /**
247
+ * ```js
248
+ * const isAuthenticated = await auth0.isAuthenticated();
249
+ * ```
250
+ *
251
+ * Returns `true` if there's valid information stored,
252
+ * otherwise returns `false`.
253
+ *
254
+ */
255
+ isAuthenticated(): Promise<boolean>;
256
+ /**
257
+ * ```js
258
+ * await auth0.buildLogoutUrl(options);
259
+ * ```
260
+ *
261
+ * Builds a URL to the logout endpoint using the parameters provided as arguments.
262
+ * @param options
263
+ */
264
+ private _buildLogoutUrl;
265
+ /**
266
+ * ```js
267
+ * await auth0.logout(options);
268
+ * ```
269
+ *
270
+ * Clears the application session and performs a redirect to `/v2/logout`, using
271
+ * the parameters provided as arguments, to clear the Auth0 session.
272
+ *
273
+ * If the `federated` option is specified it also clears the Identity Provider session.
274
+ * [Read more about how Logout works at Auth0](https://auth0.com/docs/logout).
275
+ *
276
+ * @param options
277
+ */
278
+ logout(options?: LogoutOptions): Promise<void>;
279
+ private _getTokenFromIFrame;
280
+ private _getTokenUsingRefreshToken;
281
+ private _saveEntryInCache;
282
+ private _getIdTokenFromCache;
283
+ private _getEntryFromCache;
284
+ private _requestToken;
285
+ /**
286
+ * ```js
287
+ * await auth0.loginWithCustomTokenExchange(options);
288
+ * ```
289
+ *
290
+ * Exchanges an external subject token for Auth0 tokens and logs the user in.
291
+ * This method implements the Custom Token Exchange grant as specified in RFC 8693.
292
+ *
293
+ * The exchanged tokens are automatically cached, establishing an authenticated session.
294
+ * After calling this method, you can use `getUser()`, `getIdTokenClaims()`, and
295
+ * `getTokenSilently()` to access the user's information and tokens.
296
+ *
297
+ * @param {CustomTokenExchangeOptions} options - The options required to perform the token exchange.
298
+ *
299
+ * @returns {Promise<TokenEndpointResponse>} A promise that resolves to the token endpoint response,
300
+ * which contains the issued Auth0 tokens (access_token, id_token, etc.).
301
+ *
302
+ * The request includes the following parameters:
303
+ * - `grant_type`: "urn:ietf:params:oauth:grant-type:token-exchange"
304
+ * - `subject_token`: The external token to exchange
305
+ * - `subject_token_type`: The type identifier of the external token
306
+ * - `scope`: Merged scopes from the request and SDK defaults
307
+ * - `audience`: Target audience (defaults to SDK configuration)
308
+ * - `organization`: Optional organization ID/name for org-scoped authentication
309
+ *
310
+ * **Example Usage:**
311
+ *
312
+ * ```js
313
+ * const options = {
314
+ * subject_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6Ikp...',
315
+ * subject_token_type: 'urn:acme:legacy-system-token',
316
+ * scope: 'openid profile email',
317
+ * audience: 'https://api.example.com',
318
+ * organization: 'org_12345'
319
+ * };
320
+ *
321
+ * try {
322
+ * const tokenResponse = await auth0.loginWithCustomTokenExchange(options);
323
+ * console.log('Access token:', tokenResponse.access_token);
324
+ *
325
+ * // User is now logged in - access user info
326
+ * const user = await auth0.getUser();
327
+ * console.log('Logged in user:', user);
328
+ * } catch (error) {
329
+ * console.error('Token exchange failed:', error);
330
+ * }
331
+ * ```
332
+ */
333
+ loginWithCustomTokenExchange(options: CustomTokenExchangeOptions): Promise<TokenEndpointResponse>;
334
+ /**
335
+ * @deprecated Use `loginWithCustomTokenExchange()` instead. This method will be removed in the next major version.
336
+ *
337
+ * Exchanges an external subject token for Auth0 tokens.
338
+ *
339
+ * @param {CustomTokenExchangeOptions} options - The options required to perform the token exchange.
340
+ * @returns {Promise<TokenEndpointResponse>} A promise that resolves to the token endpoint response.
341
+ *
342
+ * **Example:**
343
+ * ```js
344
+ * // Instead of:
345
+ * const tokens = await auth0.exchangeToken(options);
346
+ *
347
+ * // Use:
348
+ * const tokens = await auth0.loginWithCustomTokenExchange(options);
349
+ * ```
350
+ */
351
+ exchangeToken(options: CustomTokenExchangeOptions): Promise<TokenEndpointResponse>;
352
+ protected _assertDpop(dpop: Dpop | undefined): asserts dpop is Dpop;
353
+ /**
354
+ * Returns the current DPoP nonce used for making requests to Auth0.
355
+ *
356
+ * It can return `undefined` because when starting fresh it will not
357
+ * be populated until after the first response from the server.
358
+ *
359
+ * It requires enabling the {@link Auth0ClientOptions.useDpop} option.
360
+ *
361
+ * @param nonce The nonce value.
362
+ * @param id The identifier of a nonce: if absent, it will get the nonce
363
+ * used for requests to Auth0. Otherwise, it will be used to
364
+ * select a specific non-Auth0 nonce.
365
+ */
366
+ getDpopNonce(id?: string): Promise<string | undefined>;
367
+ /**
368
+ * Sets the current DPoP nonce used for making requests to Auth0.
369
+ *
370
+ * It requires enabling the {@link Auth0ClientOptions.useDpop} option.
371
+ *
372
+ * @param nonce The nonce value.
373
+ * @param id The identifier of a nonce: if absent, it will set the nonce
374
+ * used for requests to Auth0. Otherwise, it will be used to
375
+ * select a specific non-Auth0 nonce.
376
+ */
377
+ setDpopNonce(nonce: string, id?: string): Promise<void>;
378
+ /**
379
+ * Returns a string to be used to demonstrate possession of the private
380
+ * key used to cryptographically bind access tokens with DPoP.
381
+ *
382
+ * It requires enabling the {@link Auth0ClientOptions.useDpop} option.
383
+ */
384
+ generateDpopProof(params: {
385
+ url: string;
386
+ method: string;
387
+ nonce?: string;
388
+ accessToken: string;
389
+ }): Promise<string>;
390
+ /**
391
+ * Returns a new `Fetcher` class that will contain a `fetchWithAuth()` method.
392
+ * This is a drop-in replacement for the Fetch API's `fetch()` method, but will
393
+ * handle certain authentication logic for you, like building the proper auth
394
+ * headers or managing DPoP nonces and retries automatically.
395
+ *
396
+ * Check the `EXAMPLES.md` file for a deeper look into this method.
397
+ */
398
+ createFetcher<TOutput extends CustomFetchMinimalOutput = Response>(config?: FetcherConfig<TOutput>): Fetcher<TOutput>;
399
+ /**
400
+ * Initiates a redirect to connect the user's account with a specified connection.
401
+ * This method generates PKCE parameters, creates a transaction, and redirects to the /connect endpoint.
402
+ *
403
+ * You must enable `Offline Access` from the Connection Permissions settings to be able to use the connection with Connected Accounts.
404
+ *
405
+ * @template TAppState - The application state to persist through the transaction.
406
+ * @param {RedirectConnectAccountOptions<TAppState>} options - Options for the connect account redirect flow.
407
+ * @param {string} options.connection - The name of the connection to link (e.g. 'google-oauth2').
408
+ * @param {string[]} [options.scopes] - Array of scopes to request from the Identity Provider during the connect account flow.
409
+ * @param {AuthorizationParams} [options.authorization_params] - Additional authorization parameters for the request to the upstream IdP.
410
+ * @param {string} [options.redirectUri] - The URI to redirect back to after connecting the account.
411
+ * @param {TAppState} [options.appState] - Application state to persist through the transaction.
412
+ * @param {(url: string) => Promise<void>} [options.openUrl] - Custom function to open the URL.
413
+ *
414
+ * @returns {Promise<void>} Resolves when the redirect is initiated.
415
+ * @throws {MyAccountApiError} If the connect request to the My Account API fails.
416
+ */
417
+ connectAccountWithRedirect<TAppState = any>(options: RedirectConnectAccountOptions<TAppState>): Promise<void>;
418
+ /**
419
+ * @internal
420
+ * Internal method used by MfaApiClient to exchange MFA tokens for access tokens.
421
+ * This method should not be called directly by applications.
422
+ */
423
+ _requestTokenForMfa(options: {
424
+ grant_type: string;
425
+ mfaToken: string;
426
+ scope?: string;
427
+ audience?: string;
428
+ otp?: string;
429
+ binding_code?: string;
430
+ oob_code?: string;
431
+ recovery_code?: string;
432
+ }, additionalParameters?: RequestTokenAdditionalParameters): Promise<TokenEndpointResponse>;
433
+ }
434
+ interface RequestTokenAdditionalParameters {
435
+ nonceIn?: string;
436
+ organization?: string;
437
+ scopesToRequest?: string;
438
+ }
439
+ export {};
@@ -0,0 +1,90 @@
1
+ import { ICache } from './cache';
2
+ import { Auth0ClientOptions, AuthorizationParams, AuthorizeOptions, ClientAuthorizationParams, LogoutOptions } from './global';
3
+ /**
4
+ * @ignore
5
+ */
6
+ export declare const GET_TOKEN_SILENTLY_LOCK_KEY = "auth0.lock.getTokenSilently";
7
+ /**
8
+ * @ignore
9
+ */
10
+ export declare const GET_TOKEN_FROM_IFRAME_LOCK_KEY = "auth0.lock.getTokenFromIFrame";
11
+ /**
12
+ * @ignore
13
+ */
14
+ export declare const buildGetTokenSilentlyLockKey: (clientId: string, audience: string) => string;
15
+ /**
16
+ * @ignore
17
+ * Builds a global lock key for iframe-based authentication flows.
18
+ * This ensures only one iframe authorization request runs at a time per client,
19
+ * preventing "Invalid state" errors from concurrent iframe requests overwriting
20
+ * each other's state in the Auth0 session.
21
+ */
22
+ export declare const buildIframeLockKey: (clientId: string) => string;
23
+ /**
24
+ * @ignore
25
+ */
26
+ export declare const buildOrganizationHintCookieName: (clientId: string) => string;
27
+ /**
28
+ * @ignore
29
+ */
30
+ export declare const OLD_IS_AUTHENTICATED_COOKIE_NAME = "auth0.is.authenticated";
31
+ /**
32
+ * @ignore
33
+ */
34
+ export declare const buildIsAuthenticatedCookieName: (clientId: string) => string;
35
+ /**
36
+ * @ignore
37
+ */
38
+ export declare const cacheFactory: (location: string) => () => ICache;
39
+ /**
40
+ * @ignore
41
+ */
42
+ export declare const getAuthorizeParams: (clientOptions: Auth0ClientOptions & {
43
+ authorizationParams: ClientAuthorizationParams;
44
+ }, scope: Record<string, string>, authorizationParams: AuthorizationParams & {
45
+ scope?: string | undefined;
46
+ }, state: string, nonce: string, code_challenge: string, redirect_uri: string | undefined, response_mode: string | undefined, thumbprint: string | undefined) => AuthorizeOptions;
47
+ /**
48
+ * @ignore
49
+ *
50
+ * Function used to provide support for the deprecated onRedirect through openUrl.
51
+ */
52
+ export declare const patchOpenUrlWithOnRedirect: <T extends Pick<LogoutOptions, "onRedirect" | "openUrl">>(options: T) => T;
53
+ /**
54
+ * @ignore
55
+ *
56
+ * Checks if all scopes are included inside other array of scopes
57
+ */
58
+ export declare const allScopesAreIncluded: (scopeToInclude?: string, scopes?: string) => boolean;
59
+ /**
60
+ * @ignore
61
+ *
62
+ * Returns the scopes that are missing after a refresh
63
+ */
64
+ export declare const getMissingScopes: (requestedScope?: string, respondedScope?: string) => string;
65
+ /**
66
+ * @ignore
67
+ *
68
+ * For backward compatibility we are going to check if we are going to downscope while doing a refresh request
69
+ * while MRRT is allowed. If the audience is the same for the refresh_token we are going to use and it has
70
+ * lower scopes than the ones originally in the token, we are going to return the scopes that were stored
71
+ * with the refresh_token in the tokenset.
72
+ * @param useMrrt Setting that the user can activate to use MRRT in their requests
73
+ * @param authorizationParams Contains the audience and scope that the user requested to obtain a token
74
+ * @param cachedAudience Audience stored with the refresh_token wich we are going to use in the request
75
+ * @param cachedScope Scope stored with the refresh_token wich we are going to use in the request
76
+ */
77
+ export declare const getScopeToRequest: (useMrrt: boolean | undefined, authorizationParams: {
78
+ audience?: string;
79
+ scope: string;
80
+ }, cachedAudience?: string, cachedScope?: string) => string;
81
+ /**
82
+ * @ignore
83
+ *
84
+ * Checks if the refresh request has been done using MRRT
85
+ * @param cachedAudience Audience from the refresh token used to refresh
86
+ * @param cachedScope Scopes from the refresh token used to refresh
87
+ * @param requestAudience Audience sent to the server
88
+ * @param requestScope Scopes sent to the server
89
+ */
90
+ export declare const isRefreshWithMrrt: (cachedAudience: string | undefined, cachedScope: string | undefined, requestAudience: string | undefined, requestScope: string) => boolean;
@@ -0,0 +1,92 @@
1
+ import { AuthorizationParams } from './global';
2
+ import { Fetcher } from './fetcher';
3
+ interface ConnectRequest {
4
+ /** The name of the connection to link the account with (e.g., 'google-oauth2', 'facebook'). */
5
+ connection: string;
6
+ /** Array of scopes to request from the Identity Provider during the connect account flow. */
7
+ scopes?: string[];
8
+ /** The URI to redirect to after the connection process completes. */
9
+ redirect_uri: string;
10
+ /** An opaque value used to maintain state between the request and callback. */
11
+ state?: string;
12
+ /** The PKCE code challenge derived from the code verifier. */
13
+ code_challenge?: string;
14
+ /** The method used to derive the code challenge. Required when code_challenge is provided. */
15
+ code_challenge_method?: 'S256';
16
+ authorization_params?: AuthorizationParams;
17
+ }
18
+ interface ConnectResponse {
19
+ /** The base URI to initiate the account connection flow. */
20
+ connect_uri: string;
21
+ /** The authentication session identifier. */
22
+ auth_session: string;
23
+ /** Parameters to be used with the connect URI. */
24
+ connect_params: {
25
+ /** The ticket identifier to be used with the connection URI. */
26
+ ticket: string;
27
+ };
28
+ /** The number of seconds until the ticket expires. */
29
+ expires_in: number;
30
+ }
31
+ interface CompleteRequest {
32
+ /** The authentication session identifier */
33
+ auth_session: string;
34
+ /** The authorization code returned from the connect flow */
35
+ connect_code: string;
36
+ /** The redirect URI used in the original request */
37
+ redirect_uri: string;
38
+ /** The PKCE code verifier */
39
+ code_verifier?: string;
40
+ }
41
+ export interface CompleteResponse {
42
+ /** The unique identifier of the connected account */
43
+ id: string;
44
+ /** The connection name */
45
+ connection: string;
46
+ /** The access type, always 'offline' */
47
+ access_type: 'offline';
48
+ /** Array of scopes granted */
49
+ scopes?: string[];
50
+ /** ISO date string of when the connected account was created */
51
+ created_at: string;
52
+ /** ISO date string of when the refresh token expires (optional) */
53
+ expires_at?: string;
54
+ }
55
+ export interface ErrorResponse {
56
+ type: string;
57
+ status: number;
58
+ title: string;
59
+ detail: string;
60
+ validation_errors?: {
61
+ detail: string;
62
+ field?: string;
63
+ pointer?: string;
64
+ source?: string;
65
+ }[];
66
+ }
67
+ /**
68
+ * Subset of the MyAccount API that handles the connect accounts flow.
69
+ */
70
+ export declare class MyAccountApiClient {
71
+ private myAccountFetcher;
72
+ private apiBase;
73
+ constructor(myAccountFetcher: Fetcher<Response>, apiBase: string);
74
+ /**
75
+ * Get a ticket for the connect account flow.
76
+ */
77
+ connectAccount(params: ConnectRequest): Promise<ConnectResponse>;
78
+ /**
79
+ * Verify the redirect from the connect account flow and complete the connecting of the account.
80
+ */
81
+ completeAccount(params: CompleteRequest): Promise<CompleteResponse>;
82
+ private _handleResponse;
83
+ }
84
+ export declare class MyAccountApiError extends Error {
85
+ readonly type: string;
86
+ readonly status: number;
87
+ readonly title: string;
88
+ readonly detail: string;
89
+ readonly validation_errors?: ErrorResponse['validation_errors'];
90
+ constructor({ type, status, title, detail, validation_errors }: ErrorResponse);
91
+ }
92
+ export {};