@axa-fr/react-oidc 7.22.16 → 7.22.18
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 +21 -18
- package/package.json +3 -3
- package/src/FetchToken.tsx +1 -1
package/README.md
CHANGED
|
@@ -8,14 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
We provide a wrapper **@axa-fr/react-oidc** for **React** (compatible next.js) and we expect soon to provide one for **Vue**, **Angular** and **Svelte**.
|
|
10
10
|
|
|
11
|
-
- Try the
|
|
11
|
+
- Try the React demo at https://black-rock-0dc6b0d03.1.azurestaticapps.net/ (most advanced)
|
|
12
12
|
- Try the pure javascript demo at https://icy-glacier-004ab4303.2.azurestaticapps.net/
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
alt="Sample React Oicd"
|
|
17
|
-
/>
|
|
18
|
-
</p>
|
|
14
|
+
|
|
15
|
+
<img src="https://raw.githubusercontent.com/AxaFrance/oidc-client/main/docs/img/introduction.gif" alt="Sample React Oicd"/>
|
|
19
16
|
|
|
20
17
|
- [About](#about)
|
|
21
18
|
- [Getting Started](#getting-started)
|
|
@@ -120,6 +117,12 @@ trustedDomains.config_with_dpop = {
|
|
|
120
117
|
}*/
|
|
121
118
|
};
|
|
122
119
|
|
|
120
|
+
// Setting allowMultiTabLogin to true will enable storing login-specific parameters (state, nonce, code verifier)
|
|
121
|
+
// separately for each tab. This will prevent errors when logins are initiated from multiple tabs.
|
|
122
|
+
trustedDomains.config_multi_tab_login = {
|
|
123
|
+
domains: ["https://demo.duendesoftware.com"],
|
|
124
|
+
allowMultiTabLogin: true
|
|
125
|
+
};
|
|
123
126
|
|
|
124
127
|
```
|
|
125
128
|
|
|
@@ -139,7 +142,7 @@ pnpm start
|
|
|
139
142
|
|
|
140
143
|
### Application startup
|
|
141
144
|
|
|
142
|
-
The library is router agnostic and use native History API.
|
|
145
|
+
The library is router agnostic and will use native History API.
|
|
143
146
|
|
|
144
147
|
The default routes used internally :
|
|
145
148
|
|
|
@@ -238,8 +241,8 @@ const configuration = {
|
|
|
238
241
|
demonstrating_proof_of_possession_configuration: DemonstratingProofOfPossessionConfiguration // Optional, more details bellow
|
|
239
242
|
};
|
|
240
243
|
|
|
241
|
-
|
|
242
|
-
|
|
244
|
+
interface DemonstratingProofOfPossessionConfiguration
|
|
245
|
+
{
|
|
243
246
|
generateKeyAlgorithm: RsaHashedKeyGenParams | EcKeyGenParams,
|
|
244
247
|
digestAlgorithm: AlgorithmIdentifier,
|
|
245
248
|
importKeyAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm,
|
|
@@ -336,7 +339,7 @@ import { OidcSecure } from "@axa-fr/react-oidc";
|
|
|
336
339
|
|
|
337
340
|
const AdminSecure = () => (
|
|
338
341
|
<OidcSecure>
|
|
339
|
-
<h1>My sub component</h1>
|
|
342
|
+
<h1>My sub component</h1>
|
|
340
343
|
</OidcSecure>
|
|
341
344
|
);
|
|
342
345
|
|
|
@@ -344,9 +347,9 @@ const AdminSecure = () => (
|
|
|
344
347
|
export default AdminSecure;
|
|
345
348
|
```
|
|
346
349
|
|
|
347
|
-
## How to secure a component
|
|
350
|
+
## How to secure a component: HOC method
|
|
348
351
|
|
|
349
|
-
|
|
352
|
+
`withOidcSecure` will act the same as `OidcSecure`,it will also trigger authentication in case the user is not authenticated.
|
|
350
353
|
|
|
351
354
|
```javascript
|
|
352
355
|
import React from "react";
|
|
@@ -368,7 +371,7 @@ const Routes = () => (
|
|
|
368
371
|
export default Routes;
|
|
369
372
|
```
|
|
370
373
|
|
|
371
|
-
## How to get "Access Token"
|
|
374
|
+
## How to get "Access Token": Hook method
|
|
372
375
|
|
|
373
376
|
```javascript
|
|
374
377
|
import { useOidcAccessToken } from "@axa-fr/react-oidc";
|
|
@@ -399,7 +402,7 @@ const DisplayAccessToken = () => {
|
|
|
399
402
|
};
|
|
400
403
|
```
|
|
401
404
|
|
|
402
|
-
## How to get IDToken
|
|
405
|
+
## How to get IDToken: Hook method
|
|
403
406
|
|
|
404
407
|
```javascript
|
|
405
408
|
import { useOidcIdToken } from "@axa-fr/react-oidc";
|
|
@@ -425,7 +428,7 @@ const DisplayIdToken = () => {
|
|
|
425
428
|
};
|
|
426
429
|
```
|
|
427
430
|
|
|
428
|
-
## How to get User Information
|
|
431
|
+
## How to get User Information: Hook method
|
|
429
432
|
|
|
430
433
|
```javascript
|
|
431
434
|
import { useOidcUser, UserStatus } from "@axa-fr/react-oidc";
|
|
@@ -453,10 +456,10 @@ const DisplayUserInfo = () => {
|
|
|
453
456
|
};
|
|
454
457
|
```
|
|
455
458
|
|
|
456
|
-
## How to get a fetch that inject Access_Token
|
|
459
|
+
## How to get a fetch that inject Access_Token: Hook method
|
|
457
460
|
|
|
458
|
-
If
|
|
459
|
-
This
|
|
461
|
+
If you are not using the service worker. The Fetch function needs to send AccessToken.
|
|
462
|
+
This hook will give you a wrapped fetch that adds the access token for you.
|
|
460
463
|
|
|
461
464
|
```javascript
|
|
462
465
|
import React, { useEffect, useState } from "react";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/react-oidc",
|
|
3
|
-
"version": "7.22.
|
|
3
|
+
"version": "7.22.18",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.cjs",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"lint": "eslint src"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@axa-fr/oidc-client-service-worker": "7.22.
|
|
44
|
-
"@axa-fr/oidc-client": "7.22.
|
|
43
|
+
"@axa-fr/oidc-client-service-worker": "7.22.18",
|
|
44
|
+
"@axa-fr/oidc-client": "7.22.18"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^17.0.0 || ^18.0.0"
|
package/src/FetchToken.tsx
CHANGED
|
@@ -7,7 +7,7 @@ export interface ComponentWithOidcFetchProps {
|
|
|
7
7
|
|
|
8
8
|
const defaultConfigurationName = 'default';
|
|
9
9
|
|
|
10
|
-
const fetchWithToken = (fetch: Fetch, getOidcWithConfigurationName: () => OidcClient | null, demonstrating_proof_of_possession=false) => async (...params: Parameters<Fetch>) => {
|
|
10
|
+
const fetchWithToken = (fetch: Fetch, getOidcWithConfigurationName: () => OidcClient | null, demonstrating_proof_of_possession: boolean = false) => async (...params: Parameters<Fetch>) => {
|
|
11
11
|
const oidc = getOidcWithConfigurationName();
|
|
12
12
|
const newFetch = oidc.fetchWithTokens(fetch, demonstrating_proof_of_possession);
|
|
13
13
|
return await newFetch(...params);
|