@versini/auth0-react-thin 2.19.0 → 2.20.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 +19 -179
- package/dist/auth0-react.cjs.js +1 -1
- package/dist/auth0-react.esm.js +1 -1
- package/dist/auth0-react.js +24 -24
- package/dist/auth0-react.js.map +1 -1
- package/dist/auth0-react.min.js +1 -1
- package/dist/auth0-react.min.js.map +1 -1
- package/package.json +9 -11
package/README.md
CHANGED
|
@@ -1,185 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
# @versini/auth0-react-thin
|
|
2
2
|
|
|
3
|
-
[
|
|
4
|
-
[](https://codecov.io/gh/auth0/auth0-react)
|
|
5
|
-
[](https://deepwiki.com/auth0/auth0-react)
|
|
6
|
-

|
|
7
|
-
[](https://opensource.org/licenses/MIT)
|
|
8
|
-
[](https://circleci.com/gh/auth0/auth0-react)
|
|
3
|
+
> **Unofficial, community-maintained fork of [`@auth0/auth0-react`](https://www.npmjs.com/package/@auth0/auth0-react) — NOT affiliated with, endorsed by, sponsored by, or supported by Auth0 or Okta.**
|
|
9
4
|
|
|
10
|
-
|
|
5
|
+
This is [`@auth0/auth0-react@2.20.0`](https://www.npmjs.com/package/@auth0/auth0-react/v/2.20.0)
|
|
6
|
+
rebuilt with a single one-line Rollup change (`external: ['@auth0/auth0-spa-js']`) so it no
|
|
7
|
+
longer inlines that dependency. That drops ~26 KB gzip of first-paint weight for apps that use
|
|
8
|
+
only basic Auth0 login (no MFA/Passkey/MyAccount/DPoP). The public runtime API is otherwise
|
|
9
|
+
unchanged from upstream.
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
**You almost certainly want the official package instead:
|
|
12
|
+
[`@auth0/auth0-react`](https://www.npmjs.com/package/@auth0/auth0-react).** Use this fork only if you
|
|
13
|
+
have deliberately opted into the slim build via
|
|
14
|
+
[`@versini/auth0-thin`](https://github.com/versini-org/auth0-thin).
|
|
13
15
|
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
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.
|
|
16
|
+
- What changed, why, and how it's built: https://github.com/versini-org/auth0-thin
|
|
17
|
+
- Issues with the slim build go to the `auth0-thin` repo, **not** to Auth0.
|
|
18
|
+
- For official docs and support, go to Auth0.
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## License & trademarks
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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>
|
|
22
|
+
The source is Auth0's, redistributed under Auth0's original MIT license, preserved verbatim in
|
|
23
|
+
[`LICENSE`](./LICENSE). MIT covers copyright only and grants no trademark rights. "Auth0" and
|
|
24
|
+
"Okta" are trademarks of Okta, Inc., used here solely nominatively to identify the upstream
|
|
25
|
+
package this build is derived from. This is an independent project, not produced by Okta, Inc.
|
package/dist/auth0-react.cjs.js
CHANGED
package/dist/auth0-react.esm.js
CHANGED