@axa-fr/react-oidc 7.3.0 → 7.3.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 +2 -2
- package/bin/copy-service-worker-files.mjs +14 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ The service worker catch **access_token** and **refresh_token** that will never
|
|
|
54
54
|
npm install @axa-fr/react-oidc --save
|
|
55
55
|
|
|
56
56
|
# To install or update OidcServiceWorker.js file, you can run
|
|
57
|
-
node
|
|
57
|
+
node ./node_modules/@axa-fr/react-oidc/bin/copy-service-worker-files.mjs public
|
|
58
58
|
|
|
59
59
|
# If you have a "public" folder, the 2 files will be created :
|
|
60
60
|
# ./public/OidcServiceWorker.js <-- will be updated at each "npm install"
|
|
@@ -65,7 +65,7 @@ WARNING : If you use Service Worker mode, the OidcServiceWorker.js file should a
|
|
|
65
65
|
```sh
|
|
66
66
|
"scripts": {
|
|
67
67
|
...
|
|
68
|
-
"postinstall": "node
|
|
68
|
+
"postinstall": "node ./node_modules/@axa-fr/react-oidc/bin/copy-service-worker-files.mjs public"
|
|
69
69
|
},
|
|
70
70
|
```
|
|
71
71
|
If you need a very secure mode where refresh_token and access_token will be hide behind a service worker that will proxify requests.
|
|
@@ -9,21 +9,22 @@ try {
|
|
|
9
9
|
*
|
|
10
10
|
* Copy selected files to user's directory
|
|
11
11
|
*/
|
|
12
|
-
const script_prefix= 'oidc
|
|
12
|
+
const script_prefix= 'react-oidc';
|
|
13
13
|
|
|
14
14
|
const copyFile = async (src, dest, overwrite) => {
|
|
15
15
|
if(!fileExists(src)) {
|
|
16
16
|
console.log(`[${script_prefix}:skip] file does not exist ${src}`);
|
|
17
|
-
return;
|
|
17
|
+
return false;
|
|
18
18
|
}
|
|
19
19
|
if (!overwrite) {
|
|
20
20
|
if (fileExists(dest)) {
|
|
21
21
|
console.log(`[${script_prefix}:skip] file exists not overwriting ${dest}`);
|
|
22
|
-
return;
|
|
22
|
+
return true;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
await fs.promises.copyFile(src, dest);
|
|
26
26
|
console.log(`[${script_prefix}:copy] ${dest}`);
|
|
27
|
+
return true
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
const fileExists = (path) => {
|
|
@@ -32,7 +33,8 @@ try {
|
|
|
32
33
|
|
|
33
34
|
const initPath = process.cwd();
|
|
34
35
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
35
|
-
const srcDir = path.join(__dirname, ".."
|
|
36
|
+
const srcDir = path.join(__dirname, ".." , ".." ,'oidc-client-service-worker', 'dist');
|
|
37
|
+
const srcDirFallback = path.join(__dirname, "..", 'node_modules', '@axa-fr' ,'oidc-client-service-worker', 'dist');
|
|
36
38
|
const destinationFolder = process.argv.length >= 3 ? process.argv[2] : 'public';
|
|
37
39
|
const destinationDir = path.join(initPath, destinationFolder);
|
|
38
40
|
|
|
@@ -48,11 +50,18 @@ try {
|
|
|
48
50
|
];
|
|
49
51
|
|
|
50
52
|
for await (const file of files) {
|
|
51
|
-
await copyFile(
|
|
53
|
+
const success = await copyFile(
|
|
52
54
|
path.join(srcDir, file.fileName),
|
|
53
55
|
path.join(destinationDir, file.fileName),
|
|
54
56
|
file.overwrite
|
|
55
57
|
);
|
|
58
|
+
if(!success){
|
|
59
|
+
await copyFile(
|
|
60
|
+
path.join(srcDirFallback, file.fileName),
|
|
61
|
+
path.join(destinationDir, file.fileName),
|
|
62
|
+
file.overwrite
|
|
63
|
+
);
|
|
64
|
+
}
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
} catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axa-fr/react-oidc",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.1",
|
|
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.3.
|
|
44
|
-
"@axa-fr/oidc-client": "7.3.
|
|
43
|
+
"@axa-fr/oidc-client-service-worker": "7.3.1",
|
|
44
|
+
"@axa-fr/oidc-client": "7.3.1",
|
|
45
45
|
"base64-js": "1.5.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|