@auth0/auth0-react 1.12.0 → 2.0.0-beta.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.
- package/README.md +69 -148
- package/dist/auth0-context.d.ts +9 -43
- package/dist/auth0-context.d.ts.map +1 -1
- package/dist/auth0-provider.d.ts +3 -106
- package/dist/auth0-provider.d.ts.map +1 -1
- package/dist/auth0-react.cjs.js +34 -58
- package/dist/auth0-react.cjs.js.map +1 -1
- package/dist/auth0-react.esm.js +29 -47
- package/dist/auth0-react.esm.js.map +1 -1
- package/dist/auth0-react.js +34 -58
- package/dist/auth0-react.js.map +1 -1
- package/dist/auth0-react.min.js +1 -15
- package/dist/auth0-react.min.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/reducer.d.ts +1 -1
- package/dist/reducer.d.ts.map +1 -1
- package/dist/with-authentication-required.d.ts +1 -7
- package/dist/with-authentication-required.d.ts.map +1 -1
- package/package.json +33 -32
- package/src/auth0-context.tsx +14 -54
- package/src/auth0-provider.tsx +9 -155
- package/src/index.tsx +2 -2
- package/src/reducer.tsx +1 -1
- package/src/with-authentication-required.tsx +8 -19
package/README.md
CHANGED
|
@@ -1,45 +1,62 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> :warning: Please be aware that v2 is currently in [**Beta**](https://auth0.com/docs/troubleshoot/product-lifecycle/product-release-stages). Whilst we encourage you to test the update within your applications, we do no recommend using this version in production yet. Please follow the [migration guide](./MIGRATION_GUIDE.md) when updating your application.
|
|
4
4
|
|
|
5
|
-
[](https://circleci.com/gh/auth0/auth0-react)
|
|
6
|
-
[](https://opensource.org/licenses/MIT)
|
|
7
5
|
[](https://www.npmjs.com/package/@auth0/auth0-react)
|
|
8
6
|
[](https://codecov.io/gh/auth0/auth0-react)
|
|
7
|
+

|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
[](https://circleci.com/gh/auth0/auth0-react)
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- [Documentation](#documentation)
|
|
13
|
-
- [Installation](#installation)
|
|
14
|
-
- [Getting Started](#getting-started)
|
|
15
|
-
- [Contributing](#contributing)
|
|
16
|
-
- [Support + Feedback](#support--feedback)
|
|
17
|
-
- [Troubleshooting](#troubleshooting)
|
|
18
|
-
- [Frequently Asked Questions](#frequently-asked-questions)
|
|
19
|
-
- [Vulnerability Reporting](#vulnerability-reporting)
|
|
20
|
-
- [What is Auth0](#what-is-auth0)
|
|
21
|
-
- [License](#license)
|
|
11
|
+
📚 [Documentation](#documentation) - 🚀 [Getting Started](#getting-started) - 💻 [API Reference](#api-reference) - 💬 [Feedback](#feedback)
|
|
22
12
|
|
|
23
13
|
## Documentation
|
|
24
14
|
|
|
25
|
-
- [
|
|
26
|
-
- [
|
|
15
|
+
- [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.
|
|
16
|
+
- [Sample App](https://github.com/auth0-samples/auth0-react-samples/tree/master/Sample-01) - a full-fledged React application integrated with Auth0.
|
|
17
|
+
- [FAQs](https://github.com/auth0/auth0-react/blob/master/FAQ.md) - frequently asked questions about the auth0-react SDK.
|
|
18
|
+
- [Examples](https://github.com/auth0/auth0-react/blob/master/EXAMPLES.md) - code samples for common React authentication scenario's.
|
|
19
|
+
- [Docs site](https://www.auth0.com/docs) - explore our docs site and learn more about Auth0.
|
|
20
|
+
|
|
21
|
+
## Getting started
|
|
27
22
|
|
|
28
|
-
|
|
23
|
+
### Installation
|
|
29
24
|
|
|
30
25
|
Using [npm](https://npmjs.org/)
|
|
31
26
|
|
|
32
27
|
```bash
|
|
33
|
-
npm install @auth0/auth0-react
|
|
28
|
+
npm install @auth0/auth0-react@beta
|
|
34
29
|
```
|
|
35
30
|
|
|
36
31
|
Using [yarn](https://yarnpkg.com/)
|
|
37
32
|
|
|
38
33
|
```bash
|
|
39
|
-
yarn add @auth0/auth0-react
|
|
34
|
+
yarn add @auth0/auth0-react@beta
|
|
40
35
|
```
|
|
41
36
|
|
|
42
|
-
|
|
37
|
+
### Configure Auth0
|
|
38
|
+
|
|
39
|
+
Create a **Single Page Application** in the [Auth0 Dashboard](https://manage.auth0.com/#/applications).
|
|
40
|
+
|
|
41
|
+
> **If you're using an existing application**, verify that you have configured the following settings in your Single Page Application:
|
|
42
|
+
>
|
|
43
|
+
> - Click on the "Settings" tab of your application's page.
|
|
44
|
+
> - Ensure that "Token Endpoint Authentication Method" under "Application Properties" is set to "None"
|
|
45
|
+
> - Scroll down and click on the "Show Advanced Settings" link.
|
|
46
|
+
> - Under "Advanced Settings", click on the "OAuth" tab.
|
|
47
|
+
> - Ensure that "JsonWebToken Signature Algorithm" is set to `RS256` and that "OIDC Conformant" is enabled.
|
|
48
|
+
|
|
49
|
+
Next, configure the following URLs for your application under the "Application URIs" section of the "Settings" page:
|
|
50
|
+
|
|
51
|
+
- **Allowed Callback URLs**: `http://localhost:3000`
|
|
52
|
+
- **Allowed Logout URLs**: `http://localhost:3000`
|
|
53
|
+
- **Allowed Web Origins**: `http://localhost:3000`
|
|
54
|
+
|
|
55
|
+
> 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.
|
|
56
|
+
|
|
57
|
+
Take note of the **Client ID** and **Domain** values under the "Basic Information" section. You'll need these values in the next step.
|
|
58
|
+
|
|
59
|
+
### Configure the SDK
|
|
43
60
|
|
|
44
61
|
Configure the SDK by wrapping your application in `Auth0Provider`:
|
|
45
62
|
|
|
@@ -54,7 +71,9 @@ ReactDOM.render(
|
|
|
54
71
|
<Auth0Provider
|
|
55
72
|
domain="YOUR_AUTH0_DOMAIN"
|
|
56
73
|
clientId="YOUR_AUTH0_CLIENT_ID"
|
|
57
|
-
|
|
74
|
+
authorizationParams={{
|
|
75
|
+
redirect_uri: window.location.origin,
|
|
76
|
+
}}
|
|
58
77
|
>
|
|
59
78
|
<App />
|
|
60
79
|
</Auth0Provider>,
|
|
@@ -70,14 +89,8 @@ import React from 'react';
|
|
|
70
89
|
import { useAuth0 } from '@auth0/auth0-react';
|
|
71
90
|
|
|
72
91
|
function App() {
|
|
73
|
-
const {
|
|
74
|
-
|
|
75
|
-
isAuthenticated,
|
|
76
|
-
error,
|
|
77
|
-
user,
|
|
78
|
-
loginWithRedirect,
|
|
79
|
-
logout,
|
|
80
|
-
} = useAuth0();
|
|
92
|
+
const { isLoading, isAuthenticated, error, user, loginWithRedirect, logout } =
|
|
93
|
+
useAuth0();
|
|
81
94
|
|
|
82
95
|
if (isLoading) {
|
|
83
96
|
return <div>Loading...</div>;
|
|
@@ -103,101 +116,21 @@ function App() {
|
|
|
103
116
|
export default App;
|
|
104
117
|
```
|
|
105
118
|
|
|
106
|
-
|
|
119
|
+
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/master/EXAMPLES.md).
|
|
107
120
|
|
|
108
|
-
|
|
109
|
-
const { user } = useAuth0<{ name: string }>();
|
|
121
|
+
## API reference
|
|
110
122
|
|
|
111
|
-
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Use with a Class Component
|
|
115
|
-
|
|
116
|
-
Use the `withAuth0` higher order component to add the `auth0` property to Class components:
|
|
117
|
-
|
|
118
|
-
```jsx
|
|
119
|
-
import React, { Component } from 'react';
|
|
120
|
-
import { withAuth0 } from '@auth0/auth0-react';
|
|
121
|
-
|
|
122
|
-
class Profile extends Component {
|
|
123
|
-
render() {
|
|
124
|
-
// `this.props.auth0` has all the same properties as the `useAuth0` hook
|
|
125
|
-
const { user } = this.props.auth0;
|
|
126
|
-
return <div>Hello {user.name}</div>;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export default withAuth0(Profile);
|
|
131
|
-
```
|
|
123
|
+
Explore public API's available in auth0-react.
|
|
132
124
|
|
|
133
|
-
|
|
125
|
+
- [Auth0Provider](https://auth0.github.io/auth0-react/modules.html#Auth0Provider)
|
|
126
|
+
- [Auth0ProviderOptions](https://auth0.github.io/auth0-react/interfaces/Auth0ProviderOptions.html)
|
|
127
|
+
- [useAuth0](https://auth0.github.io/auth0-react/modules.html#useAuth0)
|
|
128
|
+
- [withAuth0](https://auth0.github.io/auth0-react/modules.html#withAuth0)
|
|
129
|
+
- [withAuthenticationRequired](https://auth0.github.io/auth0-react/modules.html#withAuthenticationRequired)
|
|
134
130
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
```jsx
|
|
138
|
-
import React from 'react';
|
|
139
|
-
import { withAuthenticationRequired } from '@auth0/auth0-react';
|
|
131
|
+
## Feedback
|
|
140
132
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
export default withAuthenticationRequired(PrivateRoute, {
|
|
144
|
-
// Show a message while the user waits to be redirected to the login page.
|
|
145
|
-
onRedirecting: () => <div>Redirecting you to the login page...</div>,
|
|
146
|
-
});
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
**Note** If you are using a custom router, you will need to supply the `Auth0Provider` with a custom `onRedirectCallback` method to perform the action that returns the user to the protected page. See examples for [react-router](https://github.com/auth0/auth0-react/blob/master/EXAMPLES.md#1-protecting-a-route-in-a-react-router-dom-app), [Gatsby](https://github.com/auth0/auth0-react/blob/master/EXAMPLES.md#2-protecting-a-route-in-a-gatsby-app) and [Next.js](https://github.com/auth0/auth0-react/blob/master/EXAMPLES.md#3-protecting-a-route-in-a-nextjs-app-in-spa-mode).
|
|
150
|
-
|
|
151
|
-
### Call an API
|
|
152
|
-
|
|
153
|
-
Call a protected API with an Access Token:
|
|
154
|
-
|
|
155
|
-
```jsx
|
|
156
|
-
import React, { useEffect, useState } from 'react';
|
|
157
|
-
import { useAuth0 } from '@auth0/auth0-react';
|
|
158
|
-
|
|
159
|
-
const Posts = () => {
|
|
160
|
-
const { getAccessTokenSilently } = useAuth0();
|
|
161
|
-
const [posts, setPosts] = useState(null);
|
|
162
|
-
|
|
163
|
-
useEffect(() => {
|
|
164
|
-
(async () => {
|
|
165
|
-
try {
|
|
166
|
-
const token = await getAccessTokenSilently({
|
|
167
|
-
audience: 'https://api.example.com/',
|
|
168
|
-
scope: 'read:posts',
|
|
169
|
-
});
|
|
170
|
-
const response = await fetch('https://api.example.com/posts', {
|
|
171
|
-
headers: {
|
|
172
|
-
Authorization: `Bearer ${token}`,
|
|
173
|
-
},
|
|
174
|
-
});
|
|
175
|
-
setPosts(await response.json());
|
|
176
|
-
} catch (e) {
|
|
177
|
-
console.error(e);
|
|
178
|
-
}
|
|
179
|
-
})();
|
|
180
|
-
}, [getAccessTokenSilently]);
|
|
181
|
-
|
|
182
|
-
if (!posts) {
|
|
183
|
-
return <div>Loading...</div>;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return (
|
|
187
|
-
<ul>
|
|
188
|
-
{posts.map((post, index) => {
|
|
189
|
-
return <li key={index}>{post}</li>;
|
|
190
|
-
})}
|
|
191
|
-
</ul>
|
|
192
|
-
);
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
export default Posts;
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
For a more detailed example see how to [create a `useApi` hook for accessing protected APIs with an access token](https://github.com/auth0/auth0-react/blob/master/EXAMPLES.md#4-create-a-useapi-hook-for-accessing-protected-apis-with-an-access-token).
|
|
199
|
-
|
|
200
|
-
## Contributing
|
|
133
|
+
### Contributing
|
|
201
134
|
|
|
202
135
|
We appreciate feedback and contribution to this repo! Before you get started, please see the following:
|
|
203
136
|
|
|
@@ -205,35 +138,23 @@ We appreciate feedback and contribution to this repo! Before you get started, pl
|
|
|
205
138
|
- [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
|
|
206
139
|
- [This repo's contribution guide](https://github.com/auth0/auth0-react/blob/master/CONTRIBUTING.md)
|
|
207
140
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
For support or to provide feedback, please [raise an issue on our issue tracker](https://github.com/auth0/auth0-react/issues).
|
|
211
|
-
|
|
212
|
-
## Troubleshooting
|
|
213
|
-
|
|
214
|
-
For information on how to solve common problems, check out the [Troubleshooting](https://github.com/auth0/auth0-react/blob/master/TROUBLESHOOTING.md) guide
|
|
215
|
-
|
|
216
|
-
## Frequently Asked Questions
|
|
217
|
-
|
|
218
|
-
For a rundown of common issues you might encounter when using the SDK, please check out the [FAQ](https://github.com/auth0/auth0-react/blob/master/FAQ.md).
|
|
219
|
-
|
|
220
|
-
## Vulnerability Reporting
|
|
221
|
-
|
|
222
|
-
Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.
|
|
223
|
-
|
|
224
|
-
## What is Auth0?
|
|
141
|
+
### Raise an issue
|
|
225
142
|
|
|
226
|
-
|
|
143
|
+
To provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/auth0/auth0-react/issues).
|
|
227
144
|
|
|
228
|
-
|
|
229
|
-
- Log in users with username/password databases, passwordless, or multi-factor authentication
|
|
230
|
-
- Link multiple user accounts together
|
|
231
|
-
- Generate signed JSON Web Tokens to authorize your API calls and flow the user identity securely
|
|
232
|
-
- Access demographics and analytics detailing how, when, and where users are logging in
|
|
233
|
-
- Enrich user profiles from other data sources using customizable JavaScript rules
|
|
145
|
+
### Vulnerability Reporting
|
|
234
146
|
|
|
235
|
-
[
|
|
147
|
+
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.
|
|
236
148
|
|
|
237
|
-
|
|
149
|
+
---
|
|
238
150
|
|
|
239
|
-
|
|
151
|
+
<p align="center">
|
|
152
|
+
<picture>
|
|
153
|
+
<source media="(prefers-color-scheme: light)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
|
|
154
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png" width="150">
|
|
155
|
+
<img alt="Auth0 Logo" src="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
|
|
156
|
+
</picture>
|
|
157
|
+
</p>
|
|
158
|
+
<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>
|
|
159
|
+
<p align="center">
|
|
160
|
+
This project is licensed under the MIT license. See the <a href="https://github.com/auth0/auth0-react/blob/master/LICENSE"> LICENSE</a> file for more info.</p>
|
package/dist/auth0-context.d.ts
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { GetTokenSilentlyOptions, GetTokenWithPopupOptions, IdToken, LogoutOptions as SPALogoutOptions, PopupLoginOptions, PopupConfigOptions, RedirectLoginResult, User, GetTokenSilentlyVerboseResponse, RedirectLoginOptions as SPARedirectLoginOptions } from '@auth0/auth0-spa-js';
|
|
3
3
|
import { AuthState } from './auth-state';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* the "Allowed Callback URLs" field in your Auth0 Application's
|
|
9
|
-
* settings.
|
|
10
|
-
*/
|
|
11
|
-
redirectUri?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Used to store state before doing the redirect
|
|
14
|
-
*/
|
|
15
|
-
appState?: any;
|
|
16
|
-
/**
|
|
17
|
-
* Used to add to the URL fragment before redirecting
|
|
18
|
-
*/
|
|
19
|
-
fragment?: string;
|
|
4
|
+
import { AppState } from './auth0-provider';
|
|
5
|
+
export interface LogoutOptions extends Omit<SPALogoutOptions, 'onRedirect'> {
|
|
6
|
+
}
|
|
7
|
+
export interface RedirectLoginOptions<TAppState = AppState> extends Omit<SPARedirectLoginOptions<TAppState>, 'onRedirect'> {
|
|
20
8
|
}
|
|
21
9
|
/**
|
|
22
10
|
* Contains the authenticated state and authentication methods provided by the `useAuth0` hook.
|
|
@@ -65,7 +53,7 @@ export interface Auth0ContextInterface<TUser extends User = User> extends AuthSt
|
|
|
65
53
|
* parameters will be auto-generated. If the response is successful,
|
|
66
54
|
* results will be valid according to their expiration times.
|
|
67
55
|
*/
|
|
68
|
-
getAccessTokenWithPopup: (options?: GetTokenWithPopupOptions, config?: PopupConfigOptions) => Promise<string>;
|
|
56
|
+
getAccessTokenWithPopup: (options?: GetTokenWithPopupOptions, config?: PopupConfigOptions) => Promise<string | undefined>;
|
|
69
57
|
/**
|
|
70
58
|
* ```js
|
|
71
59
|
* const claims = await getIdTokenClaims();
|
|
@@ -73,7 +61,7 @@ export interface Auth0ContextInterface<TUser extends User = User> extends AuthSt
|
|
|
73
61
|
*
|
|
74
62
|
* Returns all claims from the id_token if available.
|
|
75
63
|
*/
|
|
76
|
-
getIdTokenClaims: (
|
|
64
|
+
getIdTokenClaims: () => Promise<IdToken | undefined>;
|
|
77
65
|
/**
|
|
78
66
|
* ```js
|
|
79
67
|
* await loginWithRedirect(options);
|
|
@@ -83,7 +71,7 @@ export interface Auth0ContextInterface<TUser extends User = User> extends AuthSt
|
|
|
83
71
|
* provided as arguments. Random and secure `state` and `nonce`
|
|
84
72
|
* parameters will be auto-generated.
|
|
85
73
|
*/
|
|
86
|
-
loginWithRedirect: (options?: RedirectLoginOptions) => Promise<void>;
|
|
74
|
+
loginWithRedirect: (options?: RedirectLoginOptions<AppState>) => Promise<void>;
|
|
87
75
|
/**
|
|
88
76
|
* ```js
|
|
89
77
|
* await loginWithPopup(options, config);
|
|
@@ -106,32 +94,10 @@ export interface Auth0ContextInterface<TUser extends User = User> extends AuthSt
|
|
|
106
94
|
*
|
|
107
95
|
* Clears the application session and performs a redirect to `/v2/logout`, using
|
|
108
96
|
* the parameters provided as arguments, to clear the Auth0 session.
|
|
109
|
-
* If the `federated` option is specified, it also clears the Identity Provider session.
|
|
110
|
-
* If the `localOnly` option is specified, it only clears the application session.
|
|
111
|
-
* It is invalid to set both the `federated` and `localOnly` options to `true`,
|
|
112
|
-
* and an error will be thrown if you do.
|
|
97
|
+
* If the `logoutParams.federated` option is specified, it also clears the Identity Provider session.
|
|
113
98
|
* [Read more about how Logout works at Auth0](https://auth0.com/docs/logout).
|
|
114
99
|
*/
|
|
115
100
|
logout: (options?: LogoutOptions) => void;
|
|
116
|
-
/**
|
|
117
|
-
* ```js
|
|
118
|
-
* const authUrl = await buildAuthorizeUrl();
|
|
119
|
-
* ```
|
|
120
|
-
*
|
|
121
|
-
* Builds an `/authorize` URL for loginWithRedirect using the parameters
|
|
122
|
-
* provided as arguments. Random and secure `state` and `nonce`
|
|
123
|
-
* parameters will be auto-generated.
|
|
124
|
-
*/
|
|
125
|
-
buildAuthorizeUrl: (options?: Auth0RedirectLoginOptions) => Promise<string>;
|
|
126
|
-
/**
|
|
127
|
-
* ```js
|
|
128
|
-
* const logoutUrl = buildLogoutUrl();
|
|
129
|
-
* ```
|
|
130
|
-
*
|
|
131
|
-
* returns a URL to the logout endpoint using the parameters provided as arguments.
|
|
132
|
-
* @param options
|
|
133
|
-
*/
|
|
134
|
-
buildLogoutUrl: (options?: LogoutUrlOptions) => string;
|
|
135
101
|
/**
|
|
136
102
|
* After the browser redirects back to the callback page,
|
|
137
103
|
* call `handleRedirectCallback` to handle success and error
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth0-context.d.ts","sourceRoot":"","sources":["../src/auth0-context.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,
|
|
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,EAChD,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAoB,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC;CAAG;AAE9E,MAAM,WAAW,oBAAoB,CAAC,SAAS,GAAG,QAAQ,CACxD,SAAQ,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC;CAAG;AAEnE;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI,CAC9D,SAAQ,SAAS,CAAC,KAAK,CAAC;IACxB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,sBAAsB,EAAE;QACtB,CACE,OAAO,EAAE,uBAAuB,GAAG;YAAE,gBAAgB,EAAE,IAAI,CAAA;SAAE,GAC5D,OAAO,CAAC,+BAA+B,CAAC,CAAC;QAC5C,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CACzC,+BAA+B,GAAG,MAAM,CACzC,CAAC;KACH,CAAC;IAEF;;;;;;;;;;;OAWG;IACH,uBAAuB,EAAE,CACvB,OAAO,CAAC,EAAE,wBAAwB,EAClC,MAAM,CAAC,EAAE,kBAAkB,KACxB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAEjC;;;;;;OAMG;IACH,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;IAErD;;;;;;;;OAQG;IACH,iBAAiB,EAAE,CACjB,OAAO,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,KACrC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;;;;;;;;;;;;OAaG;IACH,cAAc,EAAE,CACd,OAAO,CAAC,EAAE,iBAAiB,EAC3B,MAAM,CAAC,EAAE,kBAAkB,KACxB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;;;;;;;;OASG;IACH,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;IAE1C;;;;;;;OAOG;IACH,sBAAsB,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACxE;AASD;;GAEG;AACH,eAAO,MAAM,cAAc;6BAPV,KAAK;0BAAL,KAAK;kCAAL,KAAK;mCAAL,KAAK;4BAAL,KAAK;6BAAL,KAAK;0BAAL,KAAK;kBAAL,KAAK;kCAAL,KAAK;;;;;CAkBrB,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,YAAY,sDAAuD,CAAC;AAE1E,eAAe,YAAY,CAAC"}
|
package/dist/auth0-provider.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Auth0ClientOptions, User } from '@auth0/auth0-spa-js';
|
|
3
3
|
import { Auth0ContextInterface } from './auth0-context';
|
|
4
4
|
/**
|
|
5
5
|
* The state of the application before the user was redirected to the login page.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type AppState = {
|
|
8
8
|
returnTo?: string;
|
|
9
9
|
[key: string]: any;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* The main configuration to instantiate the `Auth0Provider`.
|
|
13
13
|
*/
|
|
14
|
-
export interface Auth0ProviderOptions {
|
|
14
|
+
export interface Auth0ProviderOptions extends Auth0ClientOptions {
|
|
15
15
|
/**
|
|
16
16
|
* The child nodes your Provider has wrapped
|
|
17
17
|
*/
|
|
@@ -36,104 +36,6 @@ export interface Auth0ProviderOptions {
|
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
skipRedirectCallback?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Your Auth0 account domain such as `'example.auth0.com'`,
|
|
41
|
-
* `'example.eu.auth0.com'` or , `'example.mycompany.com'`
|
|
42
|
-
* (when using [custom domains](https://auth0.com/docs/custom-domains))
|
|
43
|
-
*/
|
|
44
|
-
domain: string;
|
|
45
|
-
/**
|
|
46
|
-
* The issuer to be used for validation of JWTs, optionally defaults to the domain above
|
|
47
|
-
*/
|
|
48
|
-
issuer?: string;
|
|
49
|
-
/**
|
|
50
|
-
* The Client ID found on your Application settings page
|
|
51
|
-
*/
|
|
52
|
-
clientId: string;
|
|
53
|
-
/**
|
|
54
|
-
* The default URL where Auth0 will redirect your browser to with
|
|
55
|
-
* the authentication result. It must be whitelisted in
|
|
56
|
-
* the "Allowed Callback URLs" field in your Auth0 Application's
|
|
57
|
-
* settings. If not provided here, it should be provided in the other
|
|
58
|
-
* methods that provide authentication.
|
|
59
|
-
*/
|
|
60
|
-
redirectUri?: string;
|
|
61
|
-
/**
|
|
62
|
-
* The value in seconds used to account for clock skew in JWT expirations.
|
|
63
|
-
* Typically, this value is no more than a minute or two at maximum.
|
|
64
|
-
* Defaults to 60s.
|
|
65
|
-
*/
|
|
66
|
-
leeway?: number;
|
|
67
|
-
/**
|
|
68
|
-
* The location to use when storing cache data. Valid values are `memory` or `localstorage`.
|
|
69
|
-
* The default setting is `memory`.
|
|
70
|
-
*
|
|
71
|
-
* Read more about [changing storage options in the Auth0 docs](https://auth0.com/docs/libraries/auth0-single-page-app-sdk#change-storage-options)
|
|
72
|
-
*/
|
|
73
|
-
cacheLocation?: CacheLocation;
|
|
74
|
-
/**
|
|
75
|
-
* Specify a custom cache implementation to use for token storage and retrieval. This setting takes precedence over `cacheLocation` if they are both specified.
|
|
76
|
-
*
|
|
77
|
-
* Read more about [creating a custom cache](https://github.com/auth0/auth0-spa-js#creating-a-custom-cache)
|
|
78
|
-
*/
|
|
79
|
-
cache?: ICache;
|
|
80
|
-
/**
|
|
81
|
-
* If true, refresh tokens are used to fetch new access tokens from the Auth0 server. If false, the legacy technique of using a hidden iframe and the `authorization_code` grant with `prompt=none` is used.
|
|
82
|
-
* The default setting is `false`.
|
|
83
|
-
*
|
|
84
|
-
* **Note**: Use of refresh tokens must be enabled by an administrator on your Auth0 client application.
|
|
85
|
-
*/
|
|
86
|
-
useRefreshTokens?: boolean;
|
|
87
|
-
/**
|
|
88
|
-
* A maximum number of seconds to wait before declaring background calls to /authorize as failed for timeout
|
|
89
|
-
* Defaults to 60s.
|
|
90
|
-
*/
|
|
91
|
-
authorizeTimeoutInSeconds?: number;
|
|
92
|
-
/**
|
|
93
|
-
* Changes to recommended defaults, like defaultScope
|
|
94
|
-
*/
|
|
95
|
-
advancedOptions?: {
|
|
96
|
-
/**
|
|
97
|
-
* The default scope to be included with all requests.
|
|
98
|
-
* If not provided, 'openid profile email' is used. This can be set to `null` in order to effectively remove the default scopes.
|
|
99
|
-
*
|
|
100
|
-
* Note: The `openid` scope is **always applied** regardless of this setting.
|
|
101
|
-
*/
|
|
102
|
-
defaultScope?: string;
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Maximum allowable elapsed time (in seconds) since authentication.
|
|
106
|
-
* If the last time the user authenticated is greater than this value,
|
|
107
|
-
* the user must be reauthenticated.
|
|
108
|
-
*/
|
|
109
|
-
maxAge?: string | number;
|
|
110
|
-
/**
|
|
111
|
-
* The default scope to be used on authentication requests.
|
|
112
|
-
* The defaultScope defined in the Auth0Client is included
|
|
113
|
-
* along with this scope
|
|
114
|
-
*/
|
|
115
|
-
scope?: string;
|
|
116
|
-
/**
|
|
117
|
-
* The default audience to be used for requesting API access.
|
|
118
|
-
*/
|
|
119
|
-
audience?: string;
|
|
120
|
-
/**
|
|
121
|
-
* The Id of an organization to log in to.
|
|
122
|
-
*
|
|
123
|
-
* This will specify an `organization` parameter in your user's login request and will add a step to validate
|
|
124
|
-
* the `org_id` claim in your user's ID Token.
|
|
125
|
-
*/
|
|
126
|
-
organization?: string;
|
|
127
|
-
/**
|
|
128
|
-
* 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.
|
|
129
|
-
*/
|
|
130
|
-
invitation?: string;
|
|
131
|
-
/**
|
|
132
|
-
* The name of the connection configured for your application.
|
|
133
|
-
* If null, it will redirect to the Auth0 Login Page and show
|
|
134
|
-
* the Login Widget.
|
|
135
|
-
*/
|
|
136
|
-
connection?: string;
|
|
137
39
|
/**
|
|
138
40
|
* Context to be used when creating the Auth0Provider, defaults to the internally created context.
|
|
139
41
|
*
|
|
@@ -152,11 +54,6 @@ export interface Auth0ProviderOptions {
|
|
|
152
54
|
* For a sample on using multiple Auth0Providers review the [React Account Linking Sample](https://github.com/auth0-samples/auth0-link-accounts-sample/tree/react-variant)
|
|
153
55
|
*/
|
|
154
56
|
context?: React.Context<Auth0ContextInterface>;
|
|
155
|
-
/**
|
|
156
|
-
* If you need to send custom parameters to the Authorization Server,
|
|
157
|
-
* make sure to use the original parameter name.
|
|
158
|
-
*/
|
|
159
|
-
[key: string]: any;
|
|
160
57
|
}
|
|
161
58
|
/**
|
|
162
59
|
* ```jsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth0-provider.d.ts","sourceRoot":"","sources":["../src/auth0-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AACf,OAAO,
|
|
1
|
+
{"version":3,"file":"auth0-provider.d.ts","sourceRoot":"","sources":["../src/auth0-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,kBAAkB,EAMlB,IAAI,EACL,MAAM,qBAAqB,CAAC;AAC7B,OAAqB,EACnB,qBAAqB,EAGtB,MAAM,iBAAiB,CAAC;AAKzB;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IAChE;;;;;;;;;;;;OAYG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAChD;AAkCD;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,aAAa,SAAU,oBAAoB,KAAG,WA2JnD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|