@axa-fr/react-oidc 6.9.7 → 6.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -102
- package/dist/FetchToken.d.ts.map +1 -1
- package/dist/FetchToken.js +2 -2
- package/dist/FetchToken.js.map +1 -1
- package/dist/OidcProvider.d.ts +7 -6
- package/dist/OidcProvider.d.ts.map +1 -1
- package/dist/OidcProvider.js +30 -26
- package/dist/OidcProvider.js.map +1 -1
- package/dist/OidcSecure.d.ts +2 -2
- package/dist/OidcSecure.d.ts.map +1 -1
- package/dist/OidcSecure.js +2 -4
- package/dist/OidcSecure.js.map +1 -1
- package/dist/OidcServiceWorker.js +150 -144
- package/dist/OidcTrustedDomains.js +9 -10
- package/dist/ReactOidc.d.ts +1 -1
- package/dist/ReactOidc.d.ts.map +1 -1
- package/dist/ReactOidc.js +22 -16
- package/dist/ReactOidc.js.map +1 -1
- package/dist/User.d.ts.map +1 -1
- package/dist/User.js +1 -1
- package/dist/User.js.map +1 -1
- package/dist/core/default-component/AuthenticateError.component.d.ts +1 -1
- package/dist/core/default-component/AuthenticateError.component.d.ts.map +1 -1
- package/dist/core/default-component/Authenticating.component.d.ts +1 -1
- package/dist/core/default-component/Authenticating.component.d.ts.map +1 -1
- package/dist/core/default-component/Callback.component.d.ts.map +1 -1
- package/dist/core/default-component/Callback.component.js +5 -5
- package/dist/core/default-component/Callback.component.js.map +1 -1
- package/dist/core/default-component/Loading.component.d.ts +1 -1
- package/dist/core/default-component/Loading.component.d.ts.map +1 -1
- package/dist/core/default-component/ServiceWorkerNotSupported.component.d.ts +1 -1
- package/dist/core/default-component/ServiceWorkerNotSupported.component.d.ts.map +1 -1
- package/dist/core/default-component/SessionLost.component.d.ts.map +1 -1
- package/dist/core/default-component/SilentCallback.component.d.ts.map +1 -1
- package/dist/core/default-component/SilentCallback.component.js +1 -0
- package/dist/core/default-component/SilentCallback.component.js.map +1 -1
- package/dist/core/default-component/SilentLogin.component.d.ts.map +1 -1
- package/dist/core/default-component/SilentLogin.component.js +5 -7
- package/dist/core/default-component/SilentLogin.component.js.map +1 -1
- package/dist/core/default-component/index.d.ts +2 -2
- package/dist/core/default-component/index.d.ts.map +1 -1
- package/dist/core/default-component/index.js +5 -5
- package/dist/core/default-component/index.js.map +1 -1
- package/dist/core/routes/OidcRoutes.d.ts +1 -1
- package/dist/core/routes/OidcRoutes.d.ts.map +1 -1
- package/dist/core/routes/OidcRoutes.js +1 -1
- package/dist/core/routes/OidcRoutes.js.map +1 -1
- package/dist/core/routes/withRouter.d.ts.map +1 -1
- package/dist/core/routes/withRouter.js.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/vanilla/checkSessionIFrame.d.ts.map +1 -1
- package/dist/vanilla/checkSessionIFrame.js +15 -15
- package/dist/vanilla/checkSessionIFrame.js.map +1 -1
- package/dist/vanilla/initSession.d.ts.map +1 -1
- package/dist/vanilla/initSession.js +1 -1
- package/dist/vanilla/initSession.js.map +1 -1
- package/dist/vanilla/initWorker.d.ts +1 -1
- package/dist/vanilla/initWorker.d.ts.map +1 -1
- package/dist/vanilla/initWorker.js +22 -20
- package/dist/vanilla/initWorker.js.map +1 -1
- package/dist/vanilla/memoryStorageBackend.d.ts +5 -4
- package/dist/vanilla/memoryStorageBackend.d.ts.map +1 -1
- package/dist/vanilla/memoryStorageBackend.js.map +1 -1
- package/dist/vanilla/noHashQueryStringUtils.d.ts +3 -3
- package/dist/vanilla/noHashQueryStringUtils.d.ts.map +1 -1
- package/dist/vanilla/noHashQueryStringUtils.js +4 -4
- package/dist/vanilla/noHashQueryStringUtils.js.map +1 -1
- package/dist/vanilla/oidc.d.ts +6 -6
- package/dist/vanilla/oidc.d.ts.map +1 -1
- package/dist/vanilla/oidc.js +215 -216
- package/dist/vanilla/oidc.js.map +1 -1
- package/dist/vanilla/parseTokens.d.ts +2 -2
- package/dist/vanilla/parseTokens.d.ts.map +1 -1
- package/dist/vanilla/parseTokens.js +8 -8
- package/dist/vanilla/parseTokens.js.map +1 -1
- package/dist/vanilla/route-utils.d.ts.map +1 -1
- package/dist/vanilla/route-utils.js +10 -7
- package/dist/vanilla/route-utils.js.map +1 -1
- package/dist/vanilla/timer.d.ts.map +1 -1
- package/dist/vanilla/timer.js +8 -8
- package/dist/vanilla/timer.js.map +1 -1
- package/dist/vanilla/vanillaOidc.d.ts +6 -4
- package/dist/vanilla/vanillaOidc.d.ts.map +1 -1
- package/dist/vanilla/vanillaOidc.js +4 -5
- package/dist/vanilla/vanillaOidc.js.map +1 -1
- package/package.json +15 -6
- package/src/oidc/FetchToken.tsx +10 -11
- package/src/oidc/OidcProvider.tsx +82 -83
- package/src/oidc/OidcSecure.tsx +16 -18
- package/src/oidc/ReactOidc.tsx +74 -63
- package/src/oidc/User.ts +14 -13
- package/src/oidc/core/default-component/AuthenticateError.component.tsx +1 -1
- package/src/oidc/core/default-component/Authenticating.component.tsx +1 -1
- package/src/oidc/core/default-component/Callback.component.tsx +18 -18
- package/src/oidc/core/default-component/Loading.component.tsx +1 -1
- package/src/oidc/core/default-component/ServiceWorkerNotSupported.component.tsx +1 -1
- package/src/oidc/core/default-component/SessionLost.component.tsx +1 -1
- package/src/oidc/core/default-component/SilentCallback.component.tsx +7 -6
- package/src/oidc/core/default-component/SilentLogin.component.tsx +16 -18
- package/src/oidc/core/default-component/index.ts +2 -2
- package/src/oidc/core/routes/OidcRoutes.tsx +16 -15
- package/src/oidc/core/routes/withRouter.tsx +2 -4
- package/src/oidc/index.ts +7 -6
- package/src/oidc/vanilla/OidcServiceWorker.js +150 -144
- package/src/oidc/vanilla/OidcTrustedDomains.js +9 -10
- package/src/oidc/vanilla/checkSessionIFrame.ts +24 -23
- package/src/oidc/vanilla/index.ts +2 -1
- package/src/oidc/vanilla/initSession.ts +36 -37
- package/src/oidc/vanilla/initWorker.ts +82 -83
- package/src/oidc/vanilla/memoryStorageBackend.ts +13 -6
- package/src/oidc/vanilla/noHashQueryStringUtils.ts +13 -13
- package/src/oidc/vanilla/oidc.ts +460 -467
- package/src/oidc/vanilla/parseTokens.ts +73 -79
- package/src/oidc/vanilla/route-utils.ts +18 -18
- package/src/oidc/vanilla/timer.ts +14 -16
- package/src/oidc/vanilla/vanillaOidc.ts +35 -19
- package/src/override/AuthenticateError.component.tsx +4 -3
- package/src/override/Authenticating.component.tsx +4 -3
- package/src/override/Callback.component.tsx +4 -3
- package/src/override/Loading.component.tsx +4 -6
- package/src/override/ServiceWorkerNotSupported.component.tsx +5 -5
- package/src/override/SessionLost.component.tsx +8 -7
- package/src/override/style.ts +12 -10
- package/dist/core/routes/index.d.ts +0 -3
- package/dist/core/routes/index.d.ts.map +0 -1
- package/dist/core/routes/index.js +0 -9
- package/dist/core/routes/index.js.map +0 -1
- package/dist/vanilla/index.d.ts +0 -2
- package/dist/vanilla/index.d.ts.map +0 -1
- package/dist/vanilla/index.js +0 -6
- package/dist/vanilla/index.js.map +0 -1
- package/src/App.css +0 -38
- package/src/App.specold.tsx +0 -46
- package/src/App.tsx +0 -103
- package/src/FetchUser.tsx +0 -53
- package/src/Home.tsx +0 -23
- package/src/MultiAuth.tsx +0 -129
- package/src/Profile.tsx +0 -81
- package/src/configurations.ts +0 -73
- package/src/index.css +0 -13
- package/src/index.tsx +0 -9
- package/src/logo.svg +0 -7
- package/src/setupTests.js +0 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @axa-fr/react-oidc
|
|
2
2
|
|
|
3
|
-
Try the demo at
|
|
3
|
+
Try the demo at https://black-rock-0dc6b0d03.1.azurestaticapps.net/
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
@@ -60,7 +60,7 @@ The only file you should edit is "OidcTrustedDomains.js".
|
|
|
60
60
|
|
|
61
61
|
// Domains used by OIDC server must be also declared here
|
|
62
62
|
const trustedDomains = {
|
|
63
|
-
default: [
|
|
63
|
+
default: ["https://demo.duendesoftware.com", "https://www.myapi.com/users"],
|
|
64
64
|
};
|
|
65
65
|
```
|
|
66
66
|
|
|
@@ -85,24 +85,24 @@ The default routes used internally :
|
|
|
85
85
|
- www.your-app.fr/authentication/callback
|
|
86
86
|
|
|
87
87
|
```javascript
|
|
88
|
-
import React from
|
|
89
|
-
import { render } from
|
|
90
|
-
import { BrowserRouter as Router } from
|
|
91
|
-
import { OidcProvider } from
|
|
92
|
-
import Header from
|
|
93
|
-
import Routes from
|
|
88
|
+
import React from "react";
|
|
89
|
+
import { render } from "react-dom";
|
|
90
|
+
import { BrowserRouter as Router } from "react-router-dom";
|
|
91
|
+
import { OidcProvider } from "@axa-fr/react-oidc";
|
|
92
|
+
import Header from "./Layout/Header";
|
|
93
|
+
import Routes from "./Router";
|
|
94
94
|
|
|
95
95
|
// This configuration use hybrid mode
|
|
96
96
|
// ServiceWorker are used if available (more secure) else tokens are given to the client
|
|
97
97
|
// You need to give inside your code the "access_token" when using fetch
|
|
98
98
|
const configuration = {
|
|
99
|
-
client_id:
|
|
100
|
-
redirect_uri: window.location.origin +
|
|
99
|
+
client_id: "interactive.public.short",
|
|
100
|
+
redirect_uri: window.location.origin + "/authentication/callback",
|
|
101
101
|
silent_redirect_uri:
|
|
102
|
-
window.location.origin +
|
|
103
|
-
scope:
|
|
104
|
-
authority:
|
|
105
|
-
service_worker_relative_url:
|
|
102
|
+
window.location.origin + "/authentication/silent-callback",
|
|
103
|
+
scope: "openid profile email api offline_access", // offline_access scope allow your client to retrieve the refresh_token
|
|
104
|
+
authority: "https://demo.duendesoftware.com",
|
|
105
|
+
service_worker_relative_url: "/OidcServiceWorker.js",
|
|
106
106
|
service_worker_only: false,
|
|
107
107
|
};
|
|
108
108
|
|
|
@@ -115,7 +115,7 @@ const App = () => (
|
|
|
115
115
|
</OidcProvider>
|
|
116
116
|
);
|
|
117
117
|
|
|
118
|
-
render(<App />, document.getElementById(
|
|
118
|
+
render(<App />, document.getElementById("root"));
|
|
119
119
|
```
|
|
120
120
|
|
|
121
121
|
```javascript
|
|
@@ -164,33 +164,33 @@ const propTypes = {
|
|
|
164
164
|
"useOidc" returns all props from the Hook :
|
|
165
165
|
|
|
166
166
|
```javascript
|
|
167
|
-
import React from
|
|
168
|
-
import { useOidc } from
|
|
167
|
+
import React from "react";
|
|
168
|
+
import { useOidc } from "./oidc";
|
|
169
169
|
|
|
170
170
|
export const Home = () => {
|
|
171
171
|
const { login, logout, renewTokens, isAuthenticated } = useOidc();
|
|
172
172
|
|
|
173
173
|
return (
|
|
174
|
-
<div className=
|
|
175
|
-
<div className=
|
|
176
|
-
<div className=
|
|
177
|
-
<h5 className=
|
|
178
|
-
<p className=
|
|
174
|
+
<div className="container-fluid mt-3">
|
|
175
|
+
<div className="card">
|
|
176
|
+
<div className="card-body">
|
|
177
|
+
<h5 className="card-title">Welcome !!!</h5>
|
|
178
|
+
<p className="card-text">
|
|
179
179
|
React Demo Application protected by OpenId Connect
|
|
180
180
|
</p>
|
|
181
181
|
{!isAuthenticated && (
|
|
182
182
|
<button
|
|
183
|
-
type=
|
|
184
|
-
className=
|
|
185
|
-
onClick={() => login(
|
|
183
|
+
type="button"
|
|
184
|
+
className="btn btn-primary"
|
|
185
|
+
onClick={() => login("/profile")}
|
|
186
186
|
>
|
|
187
187
|
Login
|
|
188
188
|
</button>
|
|
189
189
|
)}
|
|
190
190
|
{isAuthenticated && (
|
|
191
191
|
<button
|
|
192
|
-
type=
|
|
193
|
-
className=
|
|
192
|
+
type="button"
|
|
193
|
+
className="btn btn-primary"
|
|
194
194
|
onClick={() => logout()}
|
|
195
195
|
>
|
|
196
196
|
logout
|
|
@@ -198,8 +198,8 @@ export const Home = () => {
|
|
|
198
198
|
)}
|
|
199
199
|
{isAuthenticated && (
|
|
200
200
|
<button
|
|
201
|
-
type=
|
|
202
|
-
className=
|
|
201
|
+
type="button"
|
|
202
|
+
className="btn btn-primary"
|
|
203
203
|
onClick={() => renewTokens()}
|
|
204
204
|
>
|
|
205
205
|
renewTokens
|
|
@@ -224,8 +224,8 @@ The Hook method exposes :
|
|
|
224
224
|
`OidcSecure` component trigger authentication in case user is not authenticated. So, the children of that component can be accessible only once you are connected.
|
|
225
225
|
|
|
226
226
|
```javascript
|
|
227
|
-
import React from
|
|
228
|
-
import { OidcSecure } from
|
|
227
|
+
import React from "react";
|
|
228
|
+
import { OidcSecure } from "@axa-fr/react-oidc";
|
|
229
229
|
|
|
230
230
|
const AdminSecure = () => (
|
|
231
231
|
<OidcSecure>
|
|
@@ -242,19 +242,19 @@ export default AdminSecure;
|
|
|
242
242
|
"withOidcSecure" act the same as "OidcSecure" it also trigger authentication in case user is not authenticated.
|
|
243
243
|
|
|
244
244
|
```javascript
|
|
245
|
-
import React from
|
|
246
|
-
import { Switch, Route } from
|
|
247
|
-
import { withOidcSecure } from
|
|
248
|
-
import Home from
|
|
249
|
-
import Dashboard from
|
|
250
|
-
import Admin from
|
|
245
|
+
import React from "react";
|
|
246
|
+
import { Switch, Route } from "react-router-dom";
|
|
247
|
+
import { withOidcSecure } from "@axa-fr/react-oidc";
|
|
248
|
+
import Home from "../Pages/Home";
|
|
249
|
+
import Dashboard from "../Pages/Dashboard";
|
|
250
|
+
import Admin from "../Pages/Admin";
|
|
251
251
|
|
|
252
252
|
const Routes = () => (
|
|
253
253
|
<Switch>
|
|
254
|
-
<Route exact path=
|
|
255
|
-
<Route path=
|
|
256
|
-
<Route path=
|
|
257
|
-
<Route path=
|
|
254
|
+
<Route exact path="/" component={Home} />
|
|
255
|
+
<Route path="/dashboard" component={withOidcSecure(Dashboard)} />
|
|
256
|
+
<Route path="/admin" component={Admin} />
|
|
257
|
+
<Route path="/home" component={Home} />
|
|
258
258
|
</Switch>
|
|
259
259
|
);
|
|
260
260
|
|
|
@@ -264,7 +264,7 @@ export default Routes;
|
|
|
264
264
|
## How to get "Access Token" : Hook method
|
|
265
265
|
|
|
266
266
|
```javascript
|
|
267
|
-
import { useOidcAccessToken } from
|
|
267
|
+
import { useOidcAccessToken } from "@axa-fr/react-oidc";
|
|
268
268
|
|
|
269
269
|
const DisplayAccessToken = () => {
|
|
270
270
|
const { accessToken, accessTokenPayload } = useOidcAccessToken();
|
|
@@ -273,18 +273,18 @@ const DisplayAccessToken = () => {
|
|
|
273
273
|
return <p>you are not authentified</p>;
|
|
274
274
|
}
|
|
275
275
|
return (
|
|
276
|
-
<div className=
|
|
277
|
-
<div className=
|
|
278
|
-
<h5 className=
|
|
279
|
-
<p style={{ color:
|
|
276
|
+
<div className="card text-white bg-info mb-3">
|
|
277
|
+
<div className="card-body">
|
|
278
|
+
<h5 className="card-title">Access Token</h5>
|
|
279
|
+
<p style={{ color: "red", backgroundColor: "white" }}>
|
|
280
280
|
Please consider to configure the ServiceWorker in order to protect
|
|
281
281
|
your application from XSRF attacks. ""access_token" and
|
|
282
282
|
"refresh_token" will never be accessible from your client side
|
|
283
283
|
javascript.
|
|
284
284
|
</p>
|
|
285
|
-
{<p className=
|
|
285
|
+
{<p className="card-text">{JSON.stringify(accessToken)}</p>}
|
|
286
286
|
{accessTokenPayload != null && (
|
|
287
|
-
<p className=
|
|
287
|
+
<p className="card-text">{JSON.stringify(accessTokenPayload)}</p>
|
|
288
288
|
)}
|
|
289
289
|
</div>
|
|
290
290
|
</div>
|
|
@@ -295,7 +295,7 @@ const DisplayAccessToken = () => {
|
|
|
295
295
|
## How to get IDToken : Hook method
|
|
296
296
|
|
|
297
297
|
```javascript
|
|
298
|
-
import { useOidcIdToken } from
|
|
298
|
+
import { useOidcIdToken } from "@axa-fr/react-oidc";
|
|
299
299
|
|
|
300
300
|
const DisplayIdToken = () => {
|
|
301
301
|
const { idToken, idTokenPayload } = useOidcIdToken();
|
|
@@ -305,12 +305,12 @@ const DisplayIdToken = () => {
|
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
return (
|
|
308
|
-
<div className=
|
|
309
|
-
<div className=
|
|
310
|
-
<h5 className=
|
|
311
|
-
{<p className=
|
|
308
|
+
<div className="card text-white bg-info mb-3">
|
|
309
|
+
<div className="card-body">
|
|
310
|
+
<h5 className="card-title">ID Token</h5>
|
|
311
|
+
{<p className="card-text">{JSON.stringify(idToken)}</p>}
|
|
312
312
|
{idTokenPayload != null && (
|
|
313
|
-
<p className=
|
|
313
|
+
<p className="card-text">{JSON.stringify(idTokenPayload)}</p>
|
|
314
314
|
)}
|
|
315
315
|
</div>
|
|
316
316
|
</div>
|
|
@@ -321,7 +321,7 @@ const DisplayIdToken = () => {
|
|
|
321
321
|
## How to get User Information : Hook method
|
|
322
322
|
|
|
323
323
|
```javascript
|
|
324
|
-
import { useOidcUser, UserStatus } from
|
|
324
|
+
import { useOidcUser, UserStatus } from "@axa-fr/react-oidc";
|
|
325
325
|
|
|
326
326
|
const DisplayUserInfo = () => {
|
|
327
327
|
const { oidcUser, oidcUserLoadingState } = useOidcUser();
|
|
@@ -335,10 +335,10 @@ const DisplayUserInfo = () => {
|
|
|
335
335
|
return <p>Fail to load user information</p>;
|
|
336
336
|
default:
|
|
337
337
|
return (
|
|
338
|
-
<div className=
|
|
339
|
-
<div className=
|
|
340
|
-
<h5 className=
|
|
341
|
-
<p className=
|
|
338
|
+
<div className="card text-white bg-success mb-3">
|
|
339
|
+
<div className="card-body">
|
|
340
|
+
<h5 className="card-title">User information</h5>
|
|
341
|
+
<p className="card-text">{JSON.stringify(oidcUser)}</p>
|
|
342
342
|
</div>
|
|
343
343
|
</div>
|
|
344
344
|
);
|
|
@@ -352,8 +352,8 @@ If your are not using the service worker. Fetch function need to send AccessToke
|
|
|
352
352
|
This Hook give you a wrapped fetch that add the access token for you.
|
|
353
353
|
|
|
354
354
|
```javascript
|
|
355
|
-
import React, { useEffect, useState } from
|
|
356
|
-
import { useOidcFetch, OidcSecure } from
|
|
355
|
+
import React, { useEffect, useState } from "react";
|
|
356
|
+
import { useOidcFetch, OidcSecure } from "@axa-fr/react-oidc";
|
|
357
357
|
|
|
358
358
|
const DisplayUserInfo = ({ fetch }) => {
|
|
359
359
|
const [oidcUser, setOidcUser] = useState(null);
|
|
@@ -362,7 +362,7 @@ const DisplayUserInfo = ({ fetch }) => {
|
|
|
362
362
|
useEffect(() => {
|
|
363
363
|
const fetchUserInfoAsync = async () => {
|
|
364
364
|
const res = await fetch(
|
|
365
|
-
|
|
365
|
+
"https://demo.duendesoftware.com/connect/userinfo",
|
|
366
366
|
);
|
|
367
367
|
if (res.status != 200) {
|
|
368
368
|
return null;
|
|
@@ -386,12 +386,12 @@ const DisplayUserInfo = ({ fetch }) => {
|
|
|
386
386
|
}
|
|
387
387
|
|
|
388
388
|
return (
|
|
389
|
-
<div className=
|
|
390
|
-
<div className=
|
|
391
|
-
<div className=
|
|
392
|
-
<h5 className=
|
|
389
|
+
<div className="container mt-3">
|
|
390
|
+
<div className="card text-white bg-success mb-3">
|
|
391
|
+
<div className="card-body">
|
|
392
|
+
<h5 className="card-title">User information</h5>
|
|
393
393
|
{oidcUser != null && (
|
|
394
|
-
<p className=
|
|
394
|
+
<p className="card-text">{JSON.stringify(oidcUser)}</p>
|
|
395
395
|
)}
|
|
396
396
|
</div>
|
|
397
397
|
</div>
|
|
@@ -415,8 +415,8 @@ If your are not using the service worker. Fetch function need to send AccessToke
|
|
|
415
415
|
This HOC give you a wrapped fetch that add the access token for you.
|
|
416
416
|
|
|
417
417
|
```javascript
|
|
418
|
-
import React, { useEffect, useState } from
|
|
419
|
-
import { useOidcFetch, OidcSecure } from
|
|
418
|
+
import React, { useEffect, useState } from "react";
|
|
419
|
+
import { useOidcFetch, OidcSecure } from "@axa-fr/react-oidc";
|
|
420
420
|
|
|
421
421
|
const DisplayUserInfo = ({ fetch }) => {
|
|
422
422
|
const [oidcUser, setOidcUser] = useState(null);
|
|
@@ -425,7 +425,7 @@ const DisplayUserInfo = ({ fetch }) => {
|
|
|
425
425
|
useEffect(() => {
|
|
426
426
|
const fetchUserInfoAsync = async () => {
|
|
427
427
|
const res = await fetch(
|
|
428
|
-
|
|
428
|
+
"https://demo.duendesoftware.com/connect/userinfo",
|
|
429
429
|
);
|
|
430
430
|
if (res.status != 200) {
|
|
431
431
|
return null;
|
|
@@ -449,12 +449,12 @@ const DisplayUserInfo = ({ fetch }) => {
|
|
|
449
449
|
}
|
|
450
450
|
|
|
451
451
|
return (
|
|
452
|
-
<div className=
|
|
453
|
-
<div className=
|
|
454
|
-
<div className=
|
|
455
|
-
<h5 className=
|
|
452
|
+
<div className="container mt-3">
|
|
453
|
+
<div className="card text-white bg-success mb-3">
|
|
454
|
+
<div className="card-body">
|
|
455
|
+
<h5 className="card-title">User information</h5>
|
|
456
456
|
{oidcUser != null && (
|
|
457
|
-
<p className=
|
|
457
|
+
<p className="card-text">{JSON.stringify(oidcUser)}</p>
|
|
458
458
|
)}
|
|
459
459
|
</div>
|
|
460
460
|
</div>
|
|
@@ -476,23 +476,23 @@ You can inject your own components.
|
|
|
476
476
|
All components definition receive props `configurationName`. Please checkout the demo for more complete example.
|
|
477
477
|
|
|
478
478
|
```javascript
|
|
479
|
-
import React from
|
|
480
|
-
import { render } from
|
|
481
|
-
import { BrowserRouter as Router } from
|
|
482
|
-
import { OidcProvider } from
|
|
483
|
-
import Header from
|
|
484
|
-
import Routes from
|
|
479
|
+
import React from "react";
|
|
480
|
+
import { render } from "react-dom";
|
|
481
|
+
import { BrowserRouter as Router } from "react-router-dom";
|
|
482
|
+
import { OidcProvider } from "@axa-fr/react-oidc";
|
|
483
|
+
import Header from "./Layout/Header";
|
|
484
|
+
import Routes from "./Router";
|
|
485
485
|
|
|
486
486
|
// This configuration use hybrid mode
|
|
487
487
|
// ServiceWorker are used if available (more secure) else tokens are given to the client
|
|
488
488
|
// You need to give inside your code the "access_token" when using fetch
|
|
489
489
|
const configuration = {
|
|
490
|
-
client_id:
|
|
491
|
-
redirect_uri:
|
|
492
|
-
silent_redirect_uri:
|
|
493
|
-
scope:
|
|
494
|
-
authority:
|
|
495
|
-
service_worker_relative_url:
|
|
490
|
+
client_id: "interactive.public.short",
|
|
491
|
+
redirect_uri: "http://localhost:4200/authentication/callback",
|
|
492
|
+
silent_redirect_uri: "http://localhost:4200/authentication/silent-callback",
|
|
493
|
+
scope: "openid profile email api offline_access",
|
|
494
|
+
authority: "https://demo.identityserver.io",
|
|
495
|
+
service_worker_relative_url: "/OidcServiceWorker.js",
|
|
496
496
|
service_worker_only: false,
|
|
497
497
|
};
|
|
498
498
|
|
|
@@ -528,7 +528,7 @@ const App = () => (
|
|
|
528
528
|
</OidcProvider>
|
|
529
529
|
);
|
|
530
530
|
|
|
531
|
-
render(<App />, document.getElementById(
|
|
531
|
+
render(<App />, document.getElementById("root"));
|
|
532
532
|
```
|
|
533
533
|
|
|
534
534
|
## How It Works
|
|
@@ -549,15 +549,15 @@ To work with NextJS you need to inject your own history surcharge like the sampl
|
|
|
549
549
|
**component/layout.js**
|
|
550
550
|
|
|
551
551
|
```javascript
|
|
552
|
-
import { OidcProvider } from
|
|
553
|
-
import { useRouter } from
|
|
552
|
+
import { OidcProvider } from "@axa-fr/react-oidc";
|
|
553
|
+
import { useRouter } from "next/router";
|
|
554
554
|
|
|
555
555
|
const configuration = {
|
|
556
|
-
client_id:
|
|
557
|
-
redirect_uri:
|
|
558
|
-
silent_redirect_uri:
|
|
559
|
-
scope:
|
|
560
|
-
authority:
|
|
556
|
+
client_id: "interactive.public.short",
|
|
557
|
+
redirect_uri: "http://localhost:3001/#authentication/callback",
|
|
558
|
+
silent_redirect_uri: "http://localhost:3001/#authentication/silent-callback", // Optional activate silent-login that use cookies between OIDC server and client javascript to restore the session
|
|
559
|
+
scope: "openid profile email api offline_access",
|
|
560
|
+
authority: "https://demo.duendesoftware.com",
|
|
561
561
|
};
|
|
562
562
|
|
|
563
563
|
const onEvent = (configurationName, eventName, data) => {
|
|
@@ -574,7 +574,7 @@ export default function Layout({ children }) {
|
|
|
574
574
|
pathname: url,
|
|
575
575
|
})
|
|
576
576
|
.then(() => {
|
|
577
|
-
window.dispatchEvent(new Event(
|
|
577
|
+
window.dispatchEvent(new Event("popstate"));
|
|
578
578
|
});
|
|
579
579
|
},
|
|
580
580
|
};
|
|
@@ -602,14 +602,14 @@ For more information checkout the [NextJS React OIDC demo](https://github.com/Ax
|
|
|
602
602
|
|
|
603
603
|
```javascript
|
|
604
604
|
export const configurationIdentityServerWithHash = {
|
|
605
|
-
client_id:
|
|
606
|
-
redirect_uri: window.location.origin +
|
|
605
|
+
client_id: "interactive.public.short",
|
|
606
|
+
redirect_uri: window.location.origin + "#authentication-callback",
|
|
607
607
|
silent_redirect_uri:
|
|
608
|
-
window.location.origin +
|
|
609
|
-
scope:
|
|
610
|
-
authority:
|
|
608
|
+
window.location.origin + "#authentication-silent-callback",
|
|
609
|
+
scope: "openid profile email api offline_access",
|
|
610
|
+
authority: "https://demo.duendesoftware.com",
|
|
611
611
|
refresh_time_before_tokens_expiration_in_second: 70,
|
|
612
|
-
service_worker_relative_url:
|
|
612
|
+
service_worker_relative_url: "/OidcServiceWorker.js",
|
|
613
613
|
service_worker_only: false,
|
|
614
614
|
};
|
|
615
615
|
```
|
package/dist/FetchToken.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchToken.d.ts","sourceRoot":"","sources":["../src/oidc/FetchToken.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"FetchToken.d.ts","sourceRoot":"","sources":["../src/oidc/FetchToken.tsx"],"names":[],"mappings":";AAEA,oBAAY,KAAK,GAAG,OAAO,MAAM,CAAC,KAAK,CAAC;AAExC,MAAM,WAAW,2BAA2B;IAC1C,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAiCD,eAAO,MAAM,aAAa,WAAW,KAAK,oEAE3B,2BAA2B,gBAGvC,CAAC;AAEJ,eAAO,MAAM,YAAY,WAAW,KAAK;;CAMxC,CAAC"}
|
package/dist/FetchToken.js
CHANGED
|
@@ -12,10 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.useOidcFetch = exports.withOidcFetch = void 0;
|
|
13
13
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
14
14
|
const vanillaOidc_1 = require("./vanilla/vanillaOidc");
|
|
15
|
-
const defaultConfigurationName =
|
|
15
|
+
const defaultConfigurationName = 'default';
|
|
16
16
|
const fetchWithToken = (fetch, getOidcWithConfigurationName) => (...params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
const [url, options, ...rest] = params;
|
|
18
|
-
const optionTmp = options ? Object.assign({}, options) : { method:
|
|
18
|
+
const optionTmp = options ? Object.assign({}, options) : { method: 'GET' };
|
|
19
19
|
let headers = new Headers();
|
|
20
20
|
if (optionTmp.headers) {
|
|
21
21
|
headers = !(optionTmp.headers instanceof Headers)
|
package/dist/FetchToken.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FetchToken.js","sourceRoot":"","sources":["../src/oidc/FetchToken.tsx"],"names":[],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"FetchToken.js","sourceRoot":"","sources":["../src/oidc/FetchToken.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,uDAAoD;AAQpD,MAAM,wBAAwB,GAAG,SAAS,CAAC;AAE3C,MAAM,cAAc,GAAG,CAAC,KAAY,EAAE,4BAAsD,EAAE,EAAE,CAAC,CAAO,GAAG,MAAyB,EAAE,EAAE;IACtI,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC;IACvC,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,mBAAM,OAAO,EAAG,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAE/D,IAAI,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC5B,IAAI,SAAS,CAAC,OAAO,EAAE;QACrB,OAAO,GAAG,CAAC,CAAC,SAAS,CAAC,OAAO,YAAY,OAAO,CAAC;YAC7C,CAAC,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC;YAChC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;KACzB;IACD,MAAM,IAAI,GAAG,4BAA4B,EAAE,CAAC;IAE5C,aAAa;IACb,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACtD,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC;IAErD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;QAC1B,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;KAC3C;IACD,IAAI,WAAW,EAAE;QACf,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,WAAW,EAAE,CAAC,CAAC;QACtD,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;YAC1B,SAAS,CAAC,WAAW,GAAG,aAAa,CAAC;SACvC;KACF;IACD,MAAM,UAAU,mCAAQ,SAAS,KAAE,OAAO,GAAE,CAAC;IAC7C,OAAO,MAAM,KAAK,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC;AAC/C,CAAC,CAAA,CAAC;AAEK,MAAM,aAAa,GAAG,CAAC,QAAe,IAAI,EAAE,iBAAiB,GAAG,wBAAwB,EAAE,EAAE,CAAC,CAChG,gBAAgB,EAChB,EAAE,CAAC,CAAC,KAAkC,EAAE,EAAE;IAC1C,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAA,oBAAY,EAAC,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IAClF,OAAO,uBAAC,gBAAgB,oBAAK,KAAK,IAAE,KAAK,EAAE,QAAQ,IAAI,CAAC;AAC1D,CAAC,CAAC;AALS,QAAA,aAAa,iBAKtB;AAEG,MAAM,YAAY,GAAG,CAAC,QAAe,IAAI,EAAE,iBAAiB,GAAG,wBAAwB,EAAE,EAAE;IAChG,MAAM,aAAa,GAAG,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC;IAC5C,MAAM,OAAO,GAAG,yBAAW,CAAC,GAAG,CAAC;IAChC,MAAM,4BAA4B,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACtE,MAAM,QAAQ,GAAG,cAAc,CAAC,aAAa,EAAE,4BAA4B,CAAC,CAAC;IAC7E,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC7B,CAAC,CAAC;AANW,QAAA,YAAY,gBAMvB"}
|
package/dist/OidcProvider.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ComponentType, FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { CustomHistory } from './core/routes/withRouter';
|
|
2
3
|
import { OidcConfiguration } from './vanilla/oidc';
|
|
3
|
-
import {
|
|
4
|
+
import { VanillaOidc } from './vanilla/vanillaOidc';
|
|
4
5
|
export declare type oidcContext = {
|
|
5
|
-
|
|
6
|
+
(name?: string): VanillaOidc;
|
|
6
7
|
};
|
|
7
8
|
export declare type OidcProviderProps = {
|
|
8
9
|
callbackSuccessComponent?: ComponentType<any>;
|
|
@@ -14,11 +15,11 @@ export declare type OidcProviderProps = {
|
|
|
14
15
|
configurationName?: string;
|
|
15
16
|
configuration?: OidcConfiguration;
|
|
16
17
|
children: any;
|
|
17
|
-
onSessionLost?:
|
|
18
|
-
onLogoutFromAnotherTab?:
|
|
19
|
-
onLogoutFromSameTab?:
|
|
18
|
+
onSessionLost?: () => void;
|
|
19
|
+
onLogoutFromAnotherTab?: () => void;
|
|
20
|
+
onLogoutFromSameTab?: () => void;
|
|
20
21
|
withCustomHistory?: () => CustomHistory;
|
|
21
|
-
onEvent?:
|
|
22
|
+
onEvent?: (configuration: string, name: string, data: any) => void;
|
|
22
23
|
};
|
|
23
24
|
export declare type OidcSessionProps = {
|
|
24
25
|
configurationName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OidcProvider.d.ts","sourceRoot":"","sources":["../src/oidc/OidcProvider.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"OidcProvider.d.ts","sourceRoot":"","sources":["../src/oidc/OidcProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,EAAE,EAAE,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAMlF,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,oBAAY,WAAW,GAAG;IACtB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;CAChC,CAAC;AAIF,oBAAY,iBAAiB,GAAG;IAC5B,wBAAwB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAC9C,oBAAoB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAC1C,uBAAuB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAC7C,4BAA4B,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAClD,gBAAgB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IACtC,kCAAkC,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IACxD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,QAAQ,EAAE,GAAG,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;IACpC,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,aAAa,CAAC;IACxC,OAAO,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAC,GAAG,KAAK,IAAI,CAAC;CACrE,CAAC;AAEF,oBAAY,gBAAgB,GAAG;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC;CAC5C,CAAC;AA0CF,eAAO,MAAM,YAAY,EAAG,EAAE,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CA6HlE,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/dist/OidcProvider.js
CHANGED
|
@@ -6,14 +6,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.OidcProvider = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
|
-
const
|
|
10
|
-
const OidcRoutes_1 = __importDefault(require("./core/routes/OidcRoutes"));
|
|
9
|
+
const AuthenticateError_component_1 = __importDefault(require("./core/default-component/AuthenticateError.component"));
|
|
11
10
|
const index_1 = require("./core/default-component/index");
|
|
12
11
|
const ServiceWorkerNotSupported_component_1 = __importDefault(require("./core/default-component/ServiceWorkerNotSupported.component"));
|
|
13
|
-
const
|
|
14
|
-
const
|
|
12
|
+
const OidcRoutes_1 = __importDefault(require("./core/routes/OidcRoutes"));
|
|
13
|
+
const vanillaOidc_1 = require("./vanilla/vanillaOidc");
|
|
14
|
+
const defaultEventState = { name: '', data: null };
|
|
15
15
|
const OidcSession = ({ loadingComponent, children, configurationName }) => {
|
|
16
|
-
const [
|
|
16
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
|
|
17
17
|
const getOidc = vanillaOidc_1.VanillaOidc.get;
|
|
18
18
|
const oidc = getOidc(configurationName);
|
|
19
19
|
(0, react_1.useEffect)(() => {
|
|
@@ -21,16 +21,19 @@ const OidcSession = ({ loadingComponent, children, configurationName }) => {
|
|
|
21
21
|
if (oidc) {
|
|
22
22
|
oidc.tryKeepExistingSessionAsync().then(() => {
|
|
23
23
|
if (isMounted) {
|
|
24
|
-
|
|
24
|
+
setIsLoading(false);
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
return () => {
|
|
29
29
|
isMounted = false;
|
|
30
30
|
};
|
|
31
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
32
|
}, [configurationName]);
|
|
32
33
|
const LoadingComponent = loadingComponent;
|
|
33
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children:
|
|
34
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isLoading
|
|
35
|
+
? ((0, jsx_runtime_1.jsx)(LoadingComponent, { configurationName: configurationName }))
|
|
36
|
+
: ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children })) }));
|
|
34
37
|
};
|
|
35
38
|
const Switch = ({ isLoading, loadingComponent, children, configurationName }) => {
|
|
36
39
|
const LoadingComponent = loadingComponent;
|
|
@@ -39,16 +42,17 @@ const Switch = ({ isLoading, loadingComponent, children, configurationName }) =>
|
|
|
39
42
|
}
|
|
40
43
|
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
41
44
|
};
|
|
42
|
-
const OidcProvider = ({ children, configuration, configurationName =
|
|
43
|
-
const getOidc = (configurationName =
|
|
45
|
+
const OidcProvider = ({ children, configuration, configurationName = 'default', callbackSuccessComponent = index_1.CallBackSuccess, authenticatingComponent = index_1.Authenticating, loadingComponent = index_1.Loading, serviceWorkerNotSupportedComponent = ServiceWorkerNotSupported_component_1.default, authenticatingErrorComponent = AuthenticateError_component_1.default, sessionLostComponent = index_1.SessionLost, onSessionLost = null, onLogoutFromAnotherTab = null, onLogoutFromSameTab = null, withCustomHistory = null, onEvent = null, }) => {
|
|
46
|
+
const getOidc = (configurationName = 'default') => {
|
|
44
47
|
return vanillaOidc_1.VanillaOidc.getOrCreate(configuration, configurationName);
|
|
45
48
|
};
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
46
50
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
47
51
|
const [event, setEvent] = (0, react_1.useState)(defaultEventState);
|
|
48
|
-
const [currentConfigurationName, setConfigurationName] = (0, react_1.useState)(
|
|
52
|
+
const [currentConfigurationName, setConfigurationName] = (0, react_1.useState)('default');
|
|
49
53
|
(0, react_1.useEffect)(() => {
|
|
50
54
|
const oidc = getOidc(configurationName);
|
|
51
|
-
const newSubscriptionId = oidc.
|
|
55
|
+
const newSubscriptionId = oidc.subscribeEvents((name, data) => {
|
|
52
56
|
if (onEvent) {
|
|
53
57
|
onEvent(configurationName, name, data);
|
|
54
58
|
}
|
|
@@ -60,8 +64,8 @@ const OidcProvider = ({ children, configuration, configurationName = "default",
|
|
|
60
64
|
}, [configurationName, onEvent]);
|
|
61
65
|
(0, react_1.useEffect)(() => {
|
|
62
66
|
const oidc = getOidc(configurationName);
|
|
63
|
-
const newSubscriptionId = oidc.
|
|
64
|
-
if (name
|
|
67
|
+
const newSubscriptionId = oidc.subscribeEvents((name, data) => {
|
|
68
|
+
if (name === vanillaOidc_1.VanillaOidc.eventNames.refreshTokensAsync_error || name === vanillaOidc_1.VanillaOidc.eventNames.syncTokensAsync_error) {
|
|
65
69
|
if (onSessionLost != null) {
|
|
66
70
|
onSessionLost();
|
|
67
71
|
return;
|
|
@@ -78,17 +82,16 @@ const OidcProvider = ({ children, configuration, configurationName = "default",
|
|
|
78
82
|
else if (name === vanillaOidc_1.VanillaOidc.eventNames.logout_from_same_tab) {
|
|
79
83
|
if (onLogoutFromSameTab != null) {
|
|
80
84
|
onLogoutFromSameTab();
|
|
81
|
-
return;
|
|
82
85
|
}
|
|
83
|
-
//setEvent({name, data});
|
|
86
|
+
// setEvent({name, data});
|
|
84
87
|
}
|
|
85
|
-
else if (name
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
else if (name === vanillaOidc_1.VanillaOidc.eventNames.loginAsync_begin ||
|
|
89
|
+
name === vanillaOidc_1.VanillaOidc.eventNames.loginCallbackAsync_end ||
|
|
90
|
+
name === vanillaOidc_1.VanillaOidc.eventNames.loginAsync_error ||
|
|
91
|
+
name === vanillaOidc_1.VanillaOidc.eventNames.loginCallbackAsync_error) {
|
|
89
92
|
setEvent({ name, data });
|
|
90
93
|
}
|
|
91
|
-
else if (name
|
|
94
|
+
else if (name === vanillaOidc_1.VanillaOidc.eventNames.service_worker_not_supported_by_browser && configuration.service_worker_only === true) {
|
|
92
95
|
setEvent({ name, data });
|
|
93
96
|
}
|
|
94
97
|
});
|
|
@@ -99,27 +102,28 @@ const OidcProvider = ({ children, configuration, configurationName = "default",
|
|
|
99
102
|
previousOidc.removeEventSubscription(newSubscriptionId);
|
|
100
103
|
setEvent(defaultEventState);
|
|
101
104
|
};
|
|
105
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
102
106
|
}, [configuration, configurationName]);
|
|
103
107
|
const SessionLostComponent = sessionLostComponent;
|
|
104
108
|
const AuthenticatingComponent = authenticatingComponent;
|
|
105
109
|
const LoadingComponent = loadingComponent;
|
|
106
110
|
const ServiceWorkerNotSupportedComponent = serviceWorkerNotSupportedComponent;
|
|
107
111
|
const AuthenticatingErrorComponent = authenticatingErrorComponent;
|
|
108
|
-
const isLoading = (loading || (currentConfigurationName
|
|
112
|
+
const isLoading = (loading || (currentConfigurationName !== configurationName));
|
|
109
113
|
const oidc = getOidc(configurationName);
|
|
110
|
-
|
|
114
|
+
const eventName = event.name;
|
|
111
115
|
switch (eventName) {
|
|
112
116
|
case vanillaOidc_1.VanillaOidc.eventNames.service_worker_not_supported_by_browser:
|
|
113
|
-
return (0, jsx_runtime_1.jsx)(Switch, Object.assign({ loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName }, { children: (0, jsx_runtime_1.jsx)(ServiceWorkerNotSupportedComponent, { configurationName: configurationName }) }));
|
|
117
|
+
return ((0, jsx_runtime_1.jsx)(Switch, Object.assign({ loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName }, { children: (0, jsx_runtime_1.jsx)(ServiceWorkerNotSupportedComponent, { configurationName: configurationName }) })));
|
|
114
118
|
case vanillaOidc_1.VanillaOidc.eventNames.loginAsync_begin:
|
|
115
|
-
return (0, jsx_runtime_1.jsx)(Switch, Object.assign({ loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName }, { children: (0, jsx_runtime_1.jsx)(AuthenticatingComponent, { configurationName: configurationName }) }));
|
|
119
|
+
return ((0, jsx_runtime_1.jsx)(Switch, Object.assign({ loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName }, { children: (0, jsx_runtime_1.jsx)(AuthenticatingComponent, { configurationName: configurationName }) })));
|
|
116
120
|
case vanillaOidc_1.VanillaOidc.eventNames.loginAsync_error:
|
|
117
121
|
case vanillaOidc_1.VanillaOidc.eventNames.loginCallbackAsync_error:
|
|
118
|
-
return (0, jsx_runtime_1.jsx)(Switch, Object.assign({ loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName }, { children: (0, jsx_runtime_1.jsx)(AuthenticatingErrorComponent, { configurationName: configurationName }) }));
|
|
122
|
+
return ((0, jsx_runtime_1.jsx)(Switch, Object.assign({ loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName }, { children: (0, jsx_runtime_1.jsx)(AuthenticatingErrorComponent, { configurationName: configurationName }) })));
|
|
119
123
|
case vanillaOidc_1.VanillaOidc.eventNames.refreshTokensAsync_error:
|
|
120
124
|
case vanillaOidc_1.VanillaOidc.eventNames.syncTokensAsync_error:
|
|
121
125
|
case vanillaOidc_1.VanillaOidc.eventNames.logout_from_another_tab:
|
|
122
|
-
return (0, jsx_runtime_1.jsx)(Switch, Object.assign({ loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName }, { children: (0, jsx_runtime_1.jsx)(SessionLostComponent, { configurationName: configurationName }) }));
|
|
126
|
+
return ((0, jsx_runtime_1.jsx)(Switch, Object.assign({ loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName }, { children: (0, jsx_runtime_1.jsx)(SessionLostComponent, { configurationName: configurationName }) })));
|
|
123
127
|
default:
|
|
124
128
|
return ((0, jsx_runtime_1.jsx)(Switch, Object.assign({ loadingComponent: LoadingComponent, isLoading: isLoading, configurationName: configurationName }, { children: (0, jsx_runtime_1.jsx)(OidcRoutes_1.default, Object.assign({ redirect_uri: oidc.configuration.redirect_uri, silent_redirect_uri: oidc.configuration.silent_redirect_uri, silent_login_uri: oidc.configuration.silent_login_uri, callbackSuccessComponent: callbackSuccessComponent, callbackErrorComponent: authenticatingErrorComponent, authenticatingComponent: authenticatingComponent, configurationName: configurationName, withCustomHistory: withCustomHistory }, { children: (0, jsx_runtime_1.jsx)(OidcSession, Object.assign({ loadingComponent: LoadingComponent, configurationName: configurationName }, { children: children })) })) })));
|
|
125
129
|
}
|