@versini/auth0-react-thin 2.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +185 -0
  3. package/dist/auth-state.d.ts +15 -0
  4. package/dist/auth-state.d.ts.map +1 -0
  5. package/dist/auth0-context.d.ts +423 -0
  6. package/dist/auth0-context.d.ts.map +1 -0
  7. package/dist/auth0-provider.d.ts +96 -0
  8. package/dist/auth0-provider.d.ts.map +1 -0
  9. package/dist/auth0-react.cjs.js +830 -0
  10. package/dist/auth0-react.cjs.js.map +1 -0
  11. package/dist/auth0-react.esm.js +723 -0
  12. package/dist/auth0-react.esm.js.map +1 -0
  13. package/dist/auth0-react.js +759 -0
  14. package/dist/auth0-react.js.map +1 -0
  15. package/dist/auth0-react.min.js +2 -0
  16. package/dist/auth0-react.min.js.map +1 -0
  17. package/dist/errors.d.ts +12 -0
  18. package/dist/errors.d.ts.map +1 -0
  19. package/dist/index.d.ts +9 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/reducer.d.ts +19 -0
  22. package/dist/reducer.d.ts.map +1 -0
  23. package/dist/use-auth0.d.ts +29 -0
  24. package/dist/use-auth0.d.ts.map +1 -0
  25. package/dist/utils.d.ts +10 -0
  26. package/dist/utils.d.ts.map +1 -0
  27. package/dist/with-auth0.d.ts +29 -0
  28. package/dist/with-auth0.d.ts.map +1 -0
  29. package/dist/with-authentication-required.d.ts +77 -0
  30. package/dist/with-authentication-required.d.ts.map +1 -0
  31. package/package.json +43 -0
  32. package/src/auth-state.tsx +21 -0
  33. package/src/auth0-context.tsx +506 -0
  34. package/src/auth0-provider.tsx +488 -0
  35. package/src/errors.tsx +14 -0
  36. package/src/index.tsx +100 -0
  37. package/src/reducer.tsx +59 -0
  38. package/src/use-auth0.tsx +34 -0
  39. package/src/utils.tsx +74 -0
  40. package/src/with-auth0.tsx +44 -0
  41. package/src/with-authentication-required.tsx +141 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Auth0
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,185 @@
1
+ ![Auth0 SDK for React Single Page Applications](https://cdn.auth0.com/website/sdks/banners/auth0-react-banner.png)
2
+
3
+ [![npm](https://img.shields.io/npm/v/@auth0/auth0-react.svg?style=flat)](https://www.npmjs.com/package/@auth0/auth0-react)
4
+ [![codecov](https://img.shields.io/codecov/c/github/auth0/auth0-react/main.svg?style=flat)](https://codecov.io/gh/auth0/auth0-react)
5
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/auth0/auth0-react)
6
+ ![Downloads](https://img.shields.io/npm/dw/@auth0/auth0-react)
7
+ [![License](https://img.shields.io/:license-mit-blue.svg?style=flat)](https://opensource.org/licenses/MIT)
8
+ [![CircleCI](https://img.shields.io/circleci/build/github/auth0/auth0-react.svg?branch=main&style=flat)](https://circleci.com/gh/auth0/auth0-react)
9
+
10
+ 📚 [Documentation](#documentation) - 🚀 [Getting Started](#getting-started) - 💻 [API Reference](#api-reference) - 💬 [Feedback](#feedback)
11
+
12
+ ## Documentation
13
+
14
+ - [Quickstart](https://auth0.com/docs/quickstart/spa/react) - our interactive guide for quickly adding login, logout and user information to a React app using Auth0.
15
+ - [Sample App](https://github.com/auth0-samples/auth0-react-samples/tree/master/Sample-01) - a full-fledged React application integrated with Auth0.
16
+ - [FAQs](https://github.com/auth0/auth0-react/blob/main/FAQ.md) - frequently asked questions about the auth0-react SDK.
17
+ - [Examples](https://github.com/auth0/auth0-react/blob/main/EXAMPLES.md) - code samples for common React authentication scenario's.
18
+ - [Docs site](https://www.auth0.com/docs) - explore our docs site and learn more about Auth0.
19
+
20
+ ## Getting started
21
+
22
+ ### Installation
23
+
24
+ Using [npm](https://npmjs.org/)
25
+
26
+ ```bash
27
+ npm install @auth0/auth0-react
28
+ ```
29
+
30
+ Using [yarn](https://yarnpkg.com/)
31
+
32
+ ```bash
33
+ yarn add @auth0/auth0-react
34
+ ```
35
+
36
+ ### Configure Auth0
37
+
38
+ Create a **Single Page Application** in the [Auth0 Dashboard](https://manage.auth0.com/#/applications).
39
+
40
+ > **If you're using an existing application**, verify that you have configured the following settings in your Single Page Application:
41
+ >
42
+ > - Click on the "Settings" tab of your application's page.
43
+ > - Scroll down and click on the "Show Advanced Settings" link.
44
+ > - Under "Advanced Settings", click on the "OAuth" tab.
45
+ > - Ensure that "JsonWebToken Signature Algorithm" is set to `RS256` and that "OIDC Conformant" is enabled.
46
+
47
+ Next, configure the following URLs for your application under the "Application URIs" section of the "Settings" page:
48
+
49
+ - **Allowed Callback URLs**: `http://localhost:3000`
50
+ - **Allowed Logout URLs**: `http://localhost:3000`
51
+ - **Allowed Web Origins**: `http://localhost:3000`
52
+
53
+ > These URLs should reflect the origins that your application is running on. **Allowed Callback URLs** may also include a path, depending on where you're handling the callback.
54
+
55
+ Take note of the **Client ID** and **Domain** values under the "Basic Information" section. You'll need these values in the next step.
56
+
57
+ ### Configure the SDK
58
+
59
+ Configure the SDK by wrapping your application in `Auth0Provider`:
60
+
61
+ ```jsx
62
+ // src/index.js
63
+ import React from 'react';
64
+ import { createRoot } from 'react-dom/client';
65
+ import { Auth0Provider } from '@auth0/auth0-react';
66
+ import App from './App';
67
+
68
+ const root = createRoot(document.getElementById('app'));
69
+
70
+ root.render(
71
+ <Auth0Provider
72
+ domain="YOUR_AUTH0_DOMAIN"
73
+ clientId="YOUR_AUTH0_CLIENT_ID"
74
+ authorizationParams={{
75
+ redirect_uri: window.location.origin,
76
+ }}
77
+ >
78
+ <App />
79
+ </Auth0Provider>
80
+ );
81
+ ```
82
+
83
+ <details>
84
+ <summary>Instructions for React <18</summary>
85
+ <br>
86
+
87
+ ```jsx
88
+ // src/index.js
89
+ import React from 'react';
90
+ import ReactDOM from 'react-dom';
91
+ import { Auth0Provider } from '@auth0/auth0-react';
92
+ import App from './App';
93
+
94
+ ReactDOM.render(
95
+ <Auth0Provider
96
+ domain="YOUR_AUTH0_DOMAIN"
97
+ clientId="YOUR_AUTH0_CLIENT_ID"
98
+ authorizationParams={{
99
+ redirect_uri: window.location.origin,
100
+ }}
101
+ >
102
+ <App />
103
+ </Auth0Provider>,
104
+ document.getElementById('app')
105
+ );
106
+ ```
107
+ </details>
108
+
109
+ Use the `useAuth0` hook in your components to access authentication state (`isLoading`, `isAuthenticated` and `user`) and authentication methods (`loginWithRedirect` and `logout`):
110
+
111
+ ```jsx
112
+ // src/App.js
113
+ import React from 'react';
114
+ import { useAuth0 } from '@auth0/auth0-react';
115
+
116
+ function App() {
117
+ const { isLoading, isAuthenticated, error, user, loginWithRedirect, logout } =
118
+ useAuth0();
119
+
120
+ if (isLoading) {
121
+ return <div>Loading...</div>;
122
+ }
123
+ if (error) {
124
+ return <div>Oops... {error.message}</div>;
125
+ }
126
+
127
+ if (isAuthenticated) {
128
+ return (
129
+ <div>
130
+ Hello {user.name}{' '}
131
+ <button onClick={() => logout({ logoutParams: { returnTo: window.location.origin } })}>
132
+ Log out
133
+ </button>
134
+ </div>
135
+ );
136
+ } else {
137
+ return <button onClick={() => loginWithRedirect()}>Log in</button>;
138
+ }
139
+ }
140
+
141
+ export default App;
142
+ ```
143
+
144
+ For more code samples on how to integrate **auth0-react** SDK in your **React** application, have a look at our [examples](https://github.com/auth0/auth0-react/blob/main/EXAMPLES.md).
145
+
146
+ ## API reference
147
+
148
+ Explore public API's available in auth0-react.
149
+
150
+ - [Auth0Provider](https://auth0.github.io/auth0-react/functions/Auth0Provider.html)
151
+ - [Auth0ProviderOptions](https://auth0.github.io/auth0-react/interfaces/Auth0ProviderOptions.html)
152
+ - [useAuth0](https://auth0.github.io/auth0-react/functions/useAuth0.html)
153
+ - [withAuth0](https://auth0.github.io/auth0-react/functions/withAuth0.html)
154
+ - [withAuthenticationRequired](https://auth0.github.io/auth0-react/functions/withAuthenticationRequired.html)
155
+
156
+ ## Feedback
157
+
158
+ ### Contributing
159
+
160
+ We appreciate feedback and contribution to this repo! Before you get started, please see the following:
161
+
162
+ - [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
163
+ - [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
164
+ - [This repo's contribution guide](https://github.com/auth0/auth0-react/blob/main/CONTRIBUTING.md)
165
+
166
+ ### Raise an issue
167
+
168
+ To provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/auth0/auth0-react/issues).
169
+
170
+ ### Vulnerability Reporting
171
+
172
+ Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/responsible-disclosure-policy) details the procedure for disclosing security issues.
173
+
174
+ ---
175
+
176
+ <p align="center">
177
+ <picture>
178
+ <source media="(prefers-color-scheme: light)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
179
+ <source media="(prefers-color-scheme: dark)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png" width="150">
180
+ <img alt="Auth0 Logo" src="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
181
+ </picture>
182
+ </p>
183
+ <p align="center">Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout <a href="https://auth0.com/why-auth0">Why Auth0?</a></p>
184
+ <p align="center">
185
+ This project is licensed under the MIT license. See the <a href="https://github.com/auth0/auth0-react/blob/main/LICENSE"> LICENSE</a> file for more info.</p>
@@ -0,0 +1,15 @@
1
+ import { User } from '@auth0/auth0-spa-js';
2
+ /**
3
+ * The auth state which, when combined with the auth methods, make up the return object of the `useAuth0` hook.
4
+ */
5
+ export interface AuthState<TUser extends User = User> {
6
+ error: Error | undefined;
7
+ isAuthenticated: boolean;
8
+ isLoading: boolean;
9
+ user: TUser | undefined;
10
+ }
11
+ /**
12
+ * The initial auth state.
13
+ */
14
+ export declare const initialAuthState: AuthState;
15
+ //# sourceMappingURL=auth-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-state.d.ts","sourceRoot":"","sources":["../src/auth-state.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI;IAClD,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,KAAK,GAAG,SAAS,CAAC;CACzB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAK9B,CAAC"}
@@ -0,0 +1,423 @@
1
+ import { GetTokenSilentlyOptions, GetTokenWithPopupOptions, IdToken, LogoutOptions as SPALogoutOptions, PopupLoginOptions, PopupConfigOptions, RedirectLoginResult, User, GetTokenSilentlyVerboseResponse, RedirectLoginOptions as SPARedirectLoginOptions, type Auth0Client, RedirectConnectAccountOptions, ConnectAccountRedirectResult, CustomTokenExchangeOptions, TokenEndpointResponse, type MfaApiClient, type PasskeyApiClient, type MyAccountApiClient } from '@auth0/auth0-spa-js';
2
+ import { AuthState } from './auth-state';
3
+ import { AppState } from './auth0-provider';
4
+ export interface LogoutOptions extends Omit<SPALogoutOptions, 'onRedirect'> {
5
+ }
6
+ export interface RedirectLoginOptions<TAppState = AppState> extends Omit<SPARedirectLoginOptions<TAppState>, 'onRedirect'> {
7
+ }
8
+ /**
9
+ * Contains the authenticated state and authentication methods provided by the `useAuth0` hook.
10
+ */
11
+ export interface Auth0ContextInterface<TUser extends User = User> extends AuthState<TUser> {
12
+ /**
13
+ * ```js
14
+ * const token = await getAccessTokenSilently(options);
15
+ * ```
16
+ *
17
+ * If there's a valid token stored, return it. Otherwise, opens an
18
+ * iframe with the `/authorize` URL using the parameters provided
19
+ * as arguments. Random and secure `state` and `nonce` parameters
20
+ * will be auto-generated. If the response is successful, results
21
+ * will be valid according to their expiration times.
22
+ *
23
+ * If refresh tokens are used, the token endpoint is called directly with the
24
+ * 'refresh_token' grant. If no refresh token is available to make this call,
25
+ * the SDK will only fall back to using an iframe to the '/authorize' URL if
26
+ * the `useRefreshTokensFallback` setting has been set to `true`. By default this
27
+ * setting is `false`.
28
+ *
29
+ * This method may use a web worker to perform the token call if the in-memory
30
+ * cache is used.
31
+ *
32
+ * If an `audience` value is given to this function, the SDK always falls
33
+ * back to using an iframe to make the token exchange.
34
+ *
35
+ * Note that in all cases, falling back to an iframe requires access to
36
+ * the `auth0` cookie.
37
+ */
38
+ getAccessTokenSilently: {
39
+ (options: GetTokenSilentlyOptions & {
40
+ detailedResponse: true;
41
+ }): Promise<GetTokenSilentlyVerboseResponse>;
42
+ (options?: GetTokenSilentlyOptions): Promise<string>;
43
+ (options: GetTokenSilentlyOptions): Promise<GetTokenSilentlyVerboseResponse | string>;
44
+ };
45
+ /**
46
+ * ```js
47
+ * const token = await getTokenWithPopup(options, config);
48
+ * ```
49
+ *
50
+ * Get an access token interactively.
51
+ *
52
+ * Opens a popup with the `/authorize` URL using the parameters
53
+ * provided as arguments. Random and secure `state` and `nonce`
54
+ * parameters will be auto-generated. If the response is successful,
55
+ * results will be valid according to their expiration times.
56
+ */
57
+ getAccessTokenWithPopup: (options?: GetTokenWithPopupOptions, config?: PopupConfigOptions) => Promise<string | undefined>;
58
+ /**
59
+ * ```js
60
+ * const claims = await getIdTokenClaims();
61
+ * ```
62
+ *
63
+ * Returns all claims from the id_token if available.
64
+ */
65
+ getIdTokenClaims: () => Promise<IdToken | undefined>;
66
+ /**
67
+ * ```js
68
+ * await loginWithCustomTokenExchange(options);
69
+ * ```
70
+ *
71
+ * Exchanges an external subject token for Auth0 tokens and logs the user in.
72
+ * This method implements the Custom Token Exchange grant as specified in RFC 8693.
73
+ *
74
+ * The exchanged tokens are automatically cached, establishing an authenticated session.
75
+ * After calling this method, you can use `getUser()`, `getIdTokenClaims()`, and
76
+ * `getTokenSilently()` to access the user's information and tokens.
77
+ *
78
+ * @param options - The options required to perform the token exchange.
79
+ *
80
+ * @returns A promise that resolves to the token endpoint response,
81
+ * which contains the issued Auth0 tokens (access_token, id_token, etc.).
82
+ *
83
+ * The request includes the following parameters:
84
+ * - `grant_type`: "urn:ietf:params:oauth:grant-type:token-exchange"
85
+ * - `subject_token`: The external token to exchange
86
+ * - `subject_token_type`: The type identifier of the external token
87
+ * - `scope`: Merged scopes from the request and SDK defaults
88
+ * - `audience`: Target audience (defaults to SDK configuration)
89
+ * - `organization`: Optional organization ID/name for org-scoped authentication
90
+ *
91
+ * **Example Usage:**
92
+ *
93
+ * ```js
94
+ * const options = {
95
+ * subject_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6Ikp...',
96
+ * subject_token_type: 'urn:acme:legacy-system-token',
97
+ * scope: 'openid profile email',
98
+ * audience: 'https://api.example.com',
99
+ * organization: 'org_12345'
100
+ * };
101
+ *
102
+ * try {
103
+ * const tokenResponse = await loginWithCustomTokenExchange(options);
104
+ * console.log('Access token:', tokenResponse.access_token);
105
+ *
106
+ * // User is now logged in - access user info
107
+ * const user = await getUser();
108
+ * console.log('Logged in user:', user);
109
+ * } catch (error) {
110
+ * console.error('Token exchange failed:', error);
111
+ * }
112
+ * ```
113
+ */
114
+ loginWithCustomTokenExchange: (options: CustomTokenExchangeOptions) => Promise<TokenEndpointResponse>;
115
+ /**
116
+ * ```js
117
+ * const tokenResponse = await customTokenExchange({
118
+ * subject_token: 'ey...',
119
+ * subject_token_type: 'urn:acme:legacy-system-token',
120
+ * actor_token: 'ey...',
121
+ * actor_token_type: 'https://idp.example.com/token-type/agent',
122
+ * });
123
+ * ```
124
+ *
125
+ * Exchanges an external subject token for Auth0 tokens without affecting the current session.
126
+ *
127
+ * Unlike `loginWithCustomTokenExchange`, this method has no side effects — it does not cache
128
+ * tokens, does not update the authenticated session, and does not affect `isAuthenticated`
129
+ * or `user`. Use this for delegation or impersonation scenarios where you need a downstream
130
+ * API token without changing who the current user is.
131
+ *
132
+ * When `actor_token` is present Auth0 suppresses refresh token issuance; a missing
133
+ * `refresh_token` in the response is expected and will not cause an error.
134
+ *
135
+ * @param options - The options required to perform the token exchange.
136
+ * @returns A promise that resolves to the token endpoint response.
137
+ */
138
+ customTokenExchange: (options: CustomTokenExchangeOptions) => Promise<TokenEndpointResponse>;
139
+ /**
140
+ * @deprecated Use `loginWithCustomTokenExchange()` instead. This method will be removed in the next major version.
141
+ *
142
+ * ```js
143
+ * const tokenResponse = await exchangeToken({
144
+ * subject_token: 'external_token_value',
145
+ * subject_token_type: 'urn:acme:legacy-system-token',
146
+ * scope: 'openid profile email'
147
+ * });
148
+ * ```
149
+ *
150
+ * Exchanges an external subject token for Auth0 tokens and logs the user in.
151
+ *
152
+ * This method implements the token exchange grant as specified in RFC 8693.
153
+ * It performs a token exchange by sending a request to the `/oauth/token` endpoint
154
+ * with the external token and returns Auth0 tokens (access token, ID token, etc.).
155
+ *
156
+ * **Example:**
157
+ * ```js
158
+ * // Instead of:
159
+ * const tokens = await exchangeToken(options);
160
+ *
161
+ * // Use:
162
+ * const tokens = await loginWithCustomTokenExchange(options);
163
+ * ```
164
+ *
165
+ * @param options - The options required to perform the token exchange
166
+ * @returns A promise that resolves to the token endpoint response containing Auth0 tokens
167
+ */
168
+ exchangeToken: (options: CustomTokenExchangeOptions) => Promise<TokenEndpointResponse>;
169
+ /**
170
+ * ```js
171
+ * await loginWithRedirect(options);
172
+ * ```
173
+ *
174
+ * Performs a redirect to `/authorize` using the parameters
175
+ * provided as arguments. Random and secure `state` and `nonce`
176
+ * parameters will be auto-generated.
177
+ */
178
+ loginWithRedirect: (options?: RedirectLoginOptions<AppState>) => Promise<void>;
179
+ /**
180
+ * ```js
181
+ * await loginWithPopup(options, config);
182
+ * ```
183
+ *
184
+ * Opens a popup with the `/authorize` URL using the parameters
185
+ * provided as arguments. Random and secure `state` and `nonce`
186
+ * parameters will be auto-generated. If the response is successful,
187
+ * results will be valid according to their expiration times.
188
+ *
189
+ * IMPORTANT: This method has to be called from an event handler
190
+ * that was started by the user like a button click, for example,
191
+ * otherwise the popup will be blocked in most browsers.
192
+ */
193
+ loginWithPopup: (options?: PopupLoginOptions, config?: PopupConfigOptions) => Promise<void>;
194
+ /**
195
+ * ```js
196
+ * await connectAccountWithRedirect({
197
+ * connection: 'google-oauth2',
198
+ * scopes: ['openid', 'profile', 'email', 'https://www.googleapis.com/auth/drive.readonly'],
199
+ * authorization_params: {
200
+ * // additional authorization params to forward to the authorization server
201
+ * }
202
+ * });
203
+ * ```
204
+ *
205
+ * Redirects to the `/connect` URL using the parameters
206
+ * provided as arguments. This then redirects to the connection's login page
207
+ * where the user can authenticate and authorize the account to be connected.
208
+ *
209
+ * If connecting the account is successful `onRedirectCallback` will be called
210
+ * with the details of the connected account.
211
+ */
212
+ connectAccountWithRedirect: (options: RedirectConnectAccountOptions) => Promise<void>;
213
+ /**
214
+ * ```js
215
+ * auth0.logout({ logoutParams: { returnTo: window.location.origin } });
216
+ * ```
217
+ *
218
+ * Clears the application session and performs a redirect to `/v2/logout`, using
219
+ * the parameters provided as arguments, to clear the Auth0 session.
220
+ * If the `logoutParams.federated` option is specified, it also clears the Identity Provider session.
221
+ * [Read more about how Logout works at Auth0](https://auth0.com/docs/logout).
222
+ */
223
+ logout: (options?: LogoutOptions) => Promise<void>;
224
+ /**
225
+ * After the browser redirects back to the callback page,
226
+ * call `handleRedirectCallback` to handle success and error
227
+ * responses from Auth0. If the response is successful, results
228
+ * will be valid according to their expiration times.
229
+ *
230
+ * @param url The URL to that should be used to retrieve the `state` and `code` values. Defaults to `window.location.href` if not given.
231
+ */
232
+ handleRedirectCallback: (url?: string) => Promise<RedirectLoginResult | ConnectAccountRedirectResult>;
233
+ /**
234
+ * Returns the current DPoP nonce used for making requests to Auth0.
235
+ *
236
+ * It can return `undefined` because when starting fresh it will not
237
+ * be populated until after the first response from the server.
238
+ *
239
+ * It requires enabling the {@link Auth0ClientOptions.useDpop} option.
240
+ *
241
+ * @param nonce The nonce value.
242
+ * @param id The identifier of a nonce: if absent, it will get the nonce
243
+ * used for requests to Auth0. Otherwise, it will be used to
244
+ * select a specific non-Auth0 nonce.
245
+ */
246
+ getDpopNonce: Auth0Client['getDpopNonce'];
247
+ /**
248
+ * Sets the current DPoP nonce used for making requests to Auth0.
249
+ *
250
+ * It requires enabling the {@link Auth0ClientOptions.useDpop} option.
251
+ *
252
+ * @param nonce The nonce value.
253
+ * @param id The identifier of a nonce: if absent, it will set the nonce
254
+ * used for requests to Auth0. Otherwise, it will be used to
255
+ * select a specific non-Auth0 nonce.
256
+ */
257
+ setDpopNonce: Auth0Client['setDpopNonce'];
258
+ /**
259
+ * Returns a string to be used to demonstrate possession of the private
260
+ * key used to cryptographically bind access tokens with DPoP.
261
+ *
262
+ * It requires enabling the {@link Auth0ClientOptions.useDpop} option.
263
+ */
264
+ generateDpopProof: Auth0Client['generateDpopProof'];
265
+ /**
266
+ * Returns a new `Fetcher` class that will contain a `fetchWithAuth()` method.
267
+ * This is a drop-in replacement for the Fetch API's `fetch()` method, but will
268
+ * handle certain authentication logic for you, like building the proper auth
269
+ * headers or managing DPoP nonces and retries automatically.
270
+ *
271
+ * Check the `EXAMPLES.md` file for a deeper look into this method.
272
+ */
273
+ createFetcher: Auth0Client['createFetcher'];
274
+ /**
275
+ * ```js
276
+ * const config = getConfiguration();
277
+ * // { domain: 'tenant.auth0.com', clientId: 'abc123' }
278
+ * ```
279
+ *
280
+ * Returns a readonly copy of the initialization configuration
281
+ * containing the domain and clientId.
282
+ */
283
+ getConfiguration: Auth0Client['getConfiguration'];
284
+ /**
285
+ * ```js
286
+ * const { mfa } = useAuth0();
287
+ * const authenticators = await mfa.getAuthenticators(mfaToken);
288
+ * ```
289
+ *
290
+ * MFA API client for Multi-Factor Authentication operations.
291
+ *
292
+ * Provides access to all MFA-related methods:
293
+ * - `getAuthenticators(mfaToken)` - List enrolled authenticators
294
+ * - `enroll(params)` - Enroll new authenticators (OTP, SMS, Voice, Email, Push)
295
+ * - `challenge(params)` - Initiate MFA challenges
296
+ * - `verify(params)` - Verify MFA challenges and complete authentication
297
+ * - `getEnrollmentFactors(mfaToken)` - Get available enrollment factors
298
+ *
299
+ * @example
300
+ * ```js
301
+ * const { mfa, getAccessTokenSilently } = useAuth0();
302
+ *
303
+ * try {
304
+ * await getAccessTokenSilently();
305
+ * } catch (error) {
306
+ * if (error.error === 'mfa_required') {
307
+ * // Check if enrollment is needed
308
+ * const factors = await mfa.getEnrollmentFactors(error.mfa_token);
309
+ *
310
+ * if (factors.length > 0) {
311
+ * // Enroll in OTP
312
+ * const enrollment = await mfa.enroll({
313
+ * mfaToken: error.mfa_token,
314
+ * factorType: 'otp'
315
+ * });
316
+ * console.log('QR Code:', enrollment.barcodeUri);
317
+ * }
318
+ *
319
+ * // Get authenticators and challenge
320
+ * const authenticators = await mfa.getAuthenticators(error.mfa_token);
321
+ * await mfa.challenge({
322
+ * mfaToken: error.mfa_token,
323
+ * challengeType: 'otp',
324
+ * authenticatorId: authenticators[0].id
325
+ * });
326
+ *
327
+ * // Verify with user's code
328
+ * const tokens = await mfa.verify({
329
+ * mfaToken: error.mfa_token,
330
+ * otp: userCode
331
+ * });
332
+ * }
333
+ * }
334
+ * ```
335
+ */
336
+ mfa: MfaApiClient;
337
+ /**
338
+ * ```js
339
+ * const { passkey } = useAuth0();
340
+ * const tokens = await passkey.signup({ email: 'user@example.com' });
341
+ * ```
342
+ *
343
+ * Passkey API client for WebAuthn-based passwordless authentication.
344
+ *
345
+ * - `signup(options)` — register a new user and create a passkey credential
346
+ * - `login(options?)` — authenticate an existing user via passkey assertion
347
+ *
348
+ * Both methods exchange the WebAuthn credential for Auth0 tokens and update
349
+ * `isAuthenticated` / `user` in the same way as `loginWithPopup`.
350
+ */
351
+ passkey: PasskeyApiClient;
352
+ /**
353
+ * ```js
354
+ * const { myAccount } = useAuth0();
355
+ * const factors = await myAccount.getFactors();
356
+ * ```
357
+ *
358
+ * MyAccount API client for self-service account management operations.
359
+ *
360
+ * Provides access to methods for managing the authenticated user's authentication
361
+ * methods and factors:
362
+ * - `getFactors()` - List available authentication factors
363
+ * - `getAuthenticationMethods(type?)` - List enrolled authentication methods, optionally filtered by type
364
+ * - `getAuthenticationMethod(id)` - Get a specific authentication method by ID
365
+ * - `updateAuthenticationMethod(id, data)` - Update an authentication method (e.g. rename)
366
+ * - `deleteAuthenticationMethod(id)` - Remove an enrolled authentication method
367
+ * - `enrollmentChallenge(options)` - Initiate a two-step enrollment challenge
368
+ * - `enrollmentVerify(options)` - Complete a two-step enrollment by verifying the challenge
369
+ *
370
+ * @example
371
+ * ```js
372
+ * const { myAccount } = useAuth0();
373
+ *
374
+ * // List all enrolled authentication methods
375
+ * const methods = await myAccount.getAuthenticationMethods();
376
+ *
377
+ * // Enroll a new passkey
378
+ * const challenge = await myAccount.enrollmentChallenge({ type: 'passkey' });
379
+ * const credential = await navigator.credentials.create({ publicKey: challenge.authn_params_public_key });
380
+ * await myAccount.enrollmentVerify({ type: 'passkey', auth_session: challenge.auth_session, location: challenge.location, authn_response: credential });
381
+ *
382
+ * // Remove an authentication method
383
+ * await myAccount.deleteAuthenticationMethod('method-id');
384
+ * ```
385
+ */
386
+ myAccount: MyAccountApiClient;
387
+ }
388
+ /**
389
+ * @ignore
390
+ */
391
+ export declare const initialContext: {
392
+ buildAuthorizeUrl: () => never;
393
+ buildLogoutUrl: () => never;
394
+ getAccessTokenSilently: () => never;
395
+ getAccessTokenWithPopup: () => never;
396
+ getIdTokenClaims: () => never;
397
+ loginWithCustomTokenExchange: () => never;
398
+ customTokenExchange: () => never;
399
+ exchangeToken: () => never;
400
+ loginWithRedirect: () => never;
401
+ loginWithPopup: () => never;
402
+ connectAccountWithRedirect: () => never;
403
+ logout: () => never;
404
+ handleRedirectCallback: () => never;
405
+ getDpopNonce: () => never;
406
+ setDpopNonce: () => never;
407
+ generateDpopProof: () => never;
408
+ createFetcher: () => never;
409
+ getConfiguration: () => never;
410
+ mfa: MfaApiClient;
411
+ passkey: PasskeyApiClient;
412
+ myAccount: MyAccountApiClient;
413
+ error: Error | undefined;
414
+ isAuthenticated: boolean;
415
+ isLoading: boolean;
416
+ user: User | undefined;
417
+ };
418
+ /**
419
+ * The Auth0 Context
420
+ */
421
+ declare const Auth0Context: import("react").Context<Auth0ContextInterface<User>>;
422
+ export default Auth0Context;
423
+ //# sourceMappingURL=auth0-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth0-context.d.ts","sourceRoot":"","sources":["../src/auth0-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,OAAO,EACP,aAAa,IAAI,gBAAgB,EACjC,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,IAAI,EACJ,+BAA+B,EAC/B,oBAAoB,IAAI,uBAAuB,EAC/C,KAAK,WAAW,EAChB,6BAA6B,EAC7B,4BAA4B,EAC5B,0BAA0B,EAC1B,qBAA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