@axa-fr/react-oidc 6.0.1 → 6.0.4
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 +7 -25
- package/bin/copy.js +37 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -49,25 +49,15 @@ It use AppAuthJS behind the scene because it very lightweight and created by ope
|
|
|
49
49
|
# Getting Started
|
|
50
50
|
|
|
51
51
|
```sh
|
|
52
|
-
npm install @axa-fr/react-oidc
|
|
52
|
+
npm install @axa-fr/react-oidc --save
|
|
53
|
+
|
|
54
|
+
# If you have a "public" folder, the 2 files will be created :
|
|
55
|
+
# ./public/OidcServiceWorker.js <-- will be updated at each "npm install"
|
|
56
|
+
# ./public/OidcTrustedDomains.js <-- won't be updated if already exist
|
|
53
57
|
```
|
|
54
58
|
|
|
55
59
|
If you need a very secure mode where refresh_token and access_token will be hide behind a service worker that will proxify requests.
|
|
56
|
-
|
|
57
|
-
Add a copy task in order to install and stay up to date an Oidc Service Worker.
|
|
58
|
-
The only file you should edit is "OidcTrustedDomains.js" which will never be erased with following configuration bellow.
|
|
59
|
-
|
|
60
|
-
```sh
|
|
61
|
-
#package.json
|
|
62
|
-
{
|
|
63
|
-
"scripts": {
|
|
64
|
-
"copy": "copyfiles -f ./node_modules/@axa-fr/react-oidc/dist/OidcServiceWorker.js ./public && copyfiles -f -s ./node_modules/@axa-fr/react-oidc/dist/OidcTrustedDomains.js ./public",
|
|
65
|
-
"start:server": "react-scripts start",
|
|
66
|
-
"build:server": "npm run copy && react-scripts build",
|
|
67
|
-
"prepare": "npm run copy"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
```
|
|
60
|
+
The only file you should edit is "OidcTrustedDomains.js".
|
|
71
61
|
|
|
72
62
|
```javascript
|
|
73
63
|
// OidcTrustedDomains.js
|
|
@@ -527,15 +517,7 @@ const configuration = {
|
|
|
527
517
|
redirect_uri: 'http://localhost:3001/#authentication/callback',
|
|
528
518
|
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
|
|
529
519
|
scope: 'openid profile email api offline_access',
|
|
530
|
-
authority: 'https://demo.duendesoftware.com'
|
|
531
|
-
authority_configuration: {
|
|
532
|
-
authorization_endpoint: 'https://demo.duendesoftware.com/connect/authorize',
|
|
533
|
-
token_endpoint: 'https://demo.duendesoftware.com/connect/token',
|
|
534
|
-
userinfo_endpoint: 'https://demo.duendesoftware.com/connect/userinfo',
|
|
535
|
-
end_session_endpoint: 'https://demo.duendesoftware.com/connect/endsession',
|
|
536
|
-
revocation_endpoint: 'https://demo.duendesoftware.com/connect/revocation',
|
|
537
|
-
check_session_iframe: 'https://demo.duendesoftware.com/connect/checksession'
|
|
538
|
-
},
|
|
520
|
+
authority: 'https://demo.duendesoftware.com'
|
|
539
521
|
};
|
|
540
522
|
|
|
541
523
|
const onEvent=(configurationName, eventName, data )=>{
|
package/bin/copy.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const applyCopy=(input) => {
|
|
6
|
+
try {
|
|
7
|
+
const destinationPath = path.join(__dirname, input);
|
|
8
|
+
if (fs.existsSync(destinationPath)) {
|
|
9
|
+
const serviceworkerFilename = "OidcServiceWorker.js";
|
|
10
|
+
const serviceWorkerDestinationPath = path.join(destinationPath, serviceworkerFilename);
|
|
11
|
+
if (fs.existsSync(serviceWorkerDestinationPath)) {
|
|
12
|
+
fs.unlinkSync(serviceWorkerDestinationPath);
|
|
13
|
+
}
|
|
14
|
+
fs.copyFileSync(path.join(__dirname, "..", "dist", serviceworkerFilename), serviceWorkerDestinationPath);
|
|
15
|
+
console.log(`File copied successfully at ${serviceWorkerDestinationPath}`);
|
|
16
|
+
|
|
17
|
+
const trustedDomainsFilename = "OidcTrustedDomains.js";
|
|
18
|
+
const trustedDomainsDestinationPath = path.join(destinationPath, `${trustedDomainsFilename}`);
|
|
19
|
+
if(!fs.existsSync(trustedDomainsDestinationPath)){
|
|
20
|
+
fs.copyFileSync(path.join(__dirname, "..", "dist", "trustedDomainsFilename"), trustedDomainsDestinationPath);
|
|
21
|
+
console.log(`File copied successfully at ${trustedDomainsDestinationPath}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
} catch (ex) {
|
|
25
|
+
console.error(ex);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const args = process.argv;
|
|
30
|
+
if (args.length >= 3) {
|
|
31
|
+
const input = args[2];
|
|
32
|
+
applyCopy(input);
|
|
33
|
+
} else if(__dirname.includes("@axa-fr")) {
|
|
34
|
+
applyCopy("../../../../public");
|
|
35
|
+
} else {
|
|
36
|
+
applyCopy("../public");
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/react-oidc",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"jsnext:main": "dist/index.js",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|
|
14
|
+
"bin",
|
|
14
15
|
"src/oidc",
|
|
15
16
|
"README.md",
|
|
16
17
|
"tsconfig.json",
|
|
@@ -33,7 +34,8 @@
|
|
|
33
34
|
"test": "react-scripts test --coverage",
|
|
34
35
|
"eject": "react-scripts eject",
|
|
35
36
|
"clean": "rimraf dist",
|
|
36
|
-
"prepare": "npm run clean && tsc --build \"./tsconfig.json\" && copyfiles -f ./src/oidc/vanilla/OidcServiceWorker.js ./dist && copyfiles -f ./src/oidc/vanilla/OidcTrustedDomains.js ./dist"
|
|
37
|
+
"prepare": "npm run clean && tsc --build \"./tsconfig.json\" && copyfiles -f ./src/oidc/vanilla/OidcServiceWorker.js ./dist && copyfiles -f ./src/oidc/vanilla/OidcTrustedDomains.js ./dist",
|
|
38
|
+
"postinstall": "node ./bin/copy.js"
|
|
37
39
|
},
|
|
38
40
|
"dependencies": {
|
|
39
41
|
"@openid/appauth": "1.3.1"
|