diff --git a/Server.UnitTest/Server.UnitTest.csproj b/Server.UnitTest/Server.UnitTest.csproj
index 3d2fe42..cfab2ff 100644
--- a/Server.UnitTest/Server.UnitTest.csproj
+++ b/Server.UnitTest/Server.UnitTest.csproj
@@ -12,8 +12,9 @@
-
-
+
+
+
diff --git a/Server/Server.csproj b/Server/Server.csproj
index dc13281..2c93087 100644
--- a/Server/Server.csproj
+++ b/Server/Server.csproj
@@ -9,11 +9,11 @@
Always
-
+
-
-
-
+
+
+
diff --git a/client/package-lock.json b/client/package-lock.json
index 2c71f73..9450a4f 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -8,20 +8,20 @@
"name": "svelte-netcore-identity",
"version": "0.0.1",
"devDependencies": {
- "@axa-fr/vanilla-oidc": "^6.16.14",
- "@sveltejs/vite-plugin-svelte": "^2.0.4",
- "axios": "^1.3.5",
+ "@axa-fr/vanilla-oidc": "^6.19.2",
+ "@sveltejs/vite-plugin-svelte": "^2.4.1",
+ "axios": "^1.4.0",
"bootstrap": "^5.2.3",
- "sass": "^1.61.0",
- "svelte": "^3.58.0",
+ "sass": "^1.63.3",
+ "svelte": "^3.59.1",
"svelte-navigator": "^3.2.2",
- "vite": "^4.2.1"
+ "vite": "^4.3.9"
}
},
"node_modules/@axa-fr/vanilla-oidc": {
- "version": "6.16.14",
- "resolved": "https://registry.npmjs.org/@axa-fr/vanilla-oidc/-/vanilla-oidc-6.16.14.tgz",
- "integrity": "sha512-Cwy9QA7BWfw0Sd9yMeZ3SnuoW4JfyBPyEA6eT9EXVHYWjiMa2bZfYtUHNsdYobRMwkDlFVK7ObjMzd4+ki1//Q==",
+ "version": "6.19.2",
+ "resolved": "https://registry.npmjs.org/@axa-fr/vanilla-oidc/-/vanilla-oidc-6.19.2.tgz",
+ "integrity": "sha512-2TZyBbUaG97U5VB9lKFns5OgAS3WBFE+lhQd5MCeXR4Vwg/ZMFbE8SXZUU61OMdC6IVmr79naUg393F7HENhVQ==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
@@ -398,11 +398,12 @@
}
},
"node_modules/@sveltejs/vite-plugin-svelte": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-2.1.0.tgz",
- "integrity": "sha512-Bc9A8mtTGlhTICdLL/aZ+jyHI3kwtkcXremOH5xwjbNNKOTOtY8nMyG8/oZ5KK8IuUfAn1WL58Bp2tofDJBW0w==",
+ "version": "2.4.1",
+ "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-2.4.1.tgz",
+ "integrity": "sha512-bNNKvoRY89ptY7udeBSCmTdCVwkjmMcZ0j/z9J5MuedT8jPjq0zrknAo/jF1sToAza4NVaAgR9AkZoD9oJJmnA==",
"dev": true,
"dependencies": {
+ "@sveltejs/vite-plugin-svelte-inspector": "^1.0.2",
"debug": "^4.3.4",
"deepmerge": "^4.3.1",
"kleur": "^4.1.5",
@@ -414,7 +415,24 @@
"node": "^14.18.0 || >= 16"
},
"peerDependencies": {
- "svelte": "^3.54.0",
+ "svelte": "^3.54.0 || ^4.0.0-next.0",
+ "vite": "^4.0.0"
+ }
+ },
+ "node_modules/@sveltejs/vite-plugin-svelte-inspector": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte-inspector/-/vite-plugin-svelte-inspector-1.0.2.tgz",
+ "integrity": "sha512-Cy1dUMcYCnDVV/hPLXa43YZJ2jGKVW5rA0xuNL9dlmYhT0yoS1g7+FOFSRlgk0BXKk/Oc7grs+8BVA5Iz2fr8A==",
+ "dev": true,
+ "dependencies": {
+ "debug": "^4.3.4"
+ },
+ "engines": {
+ "node": "^14.18.0 || >= 16"
+ },
+ "peerDependencies": {
+ "@sveltejs/vite-plugin-svelte": "^2.2.0",
+ "svelte": "^3.54.0 || ^4.0.0-next.0",
"vite": "^4.0.0"
}
},
@@ -438,9 +456,9 @@
"dev": true
},
"node_modules/axios": {
- "version": "1.3.6",
- "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.6.tgz",
- "integrity": "sha512-PEcdkk7JcdPiMDkvM4K6ZBRYq9keuVJsToxm2zQIM70Qqo2WHTdJZMXcG9X+RmRp2VPNUQC8W1RAGbgt6b1yMg==",
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz",
+ "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
"dev": true,
"dependencies": {
"follow-redirects": "^1.15.0",
@@ -803,10 +821,16 @@
"dev": true
},
"node_modules/nanoid": {
- "version": "3.3.4",
- "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz",
- "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==",
+ "version": "3.3.6",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
+ "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==",
"dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/ai"
+ }
+ ],
"bin": {
"nanoid": "bin/nanoid.cjs"
},
@@ -862,9 +886,9 @@
}
},
"node_modules/postcss": {
- "version": "8.4.21",
- "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.21.tgz",
- "integrity": "sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg==",
+ "version": "8.4.24",
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.24.tgz",
+ "integrity": "sha512-M0RzbcI0sO/XJNucsGjvWU9ERWxb/ytp1w6dKtxTKgixdtQDq4rmx/g8W1hnaheq9jgwL/oyEdH5Bc4WwJKMqg==",
"dev": true,
"funding": [
{
@@ -874,10 +898,14 @@
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/postcss"
+ },
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/ai"
}
],
"dependencies": {
- "nanoid": "^3.3.4",
+ "nanoid": "^3.3.6",
"picocolors": "^1.0.0",
"source-map-js": "^1.0.2"
},
@@ -904,9 +932,9 @@
}
},
"node_modules/rollup": {
- "version": "3.20.7",
- "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.20.7.tgz",
- "integrity": "sha512-P7E2zezKSLhWnTz46XxjSmInrbOCiul1yf+kJccMxT56vxjHwCbDfoLbiqFgu+WQoo9ij2PkraYaBstgB2prBA==",
+ "version": "3.25.0",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.0.tgz",
+ "integrity": "sha512-FnJkNRst2jEZGw7f+v4hFo6UTzpDKrAKcHZWcEfm5/GJQ5CK7wgb4moNLNAe7npKUev7yQn1AY/YbZRIxOv6Qg==",
"dev": true,
"bin": {
"rollup": "dist/bin/rollup"
@@ -920,9 +948,9 @@
}
},
"node_modules/sass": {
- "version": "1.62.0",
- "resolved": "https://registry.npmjs.org/sass/-/sass-1.62.0.tgz",
- "integrity": "sha512-Q4USplo4pLYgCi+XlipZCWUQz5pkg/ruSSgJ0WRDSb/+3z9tXUOkQ7QPYn4XrhZKYAK4HlpaQecRwKLJX6+DBg==",
+ "version": "1.63.3",
+ "resolved": "https://registry.npmjs.org/sass/-/sass-1.63.3.tgz",
+ "integrity": "sha512-ySdXN+DVpfwq49jG1+hmtDslYqpS7SkOR5GpF6o2bmb1RL/xS+wvPmegMvMywyfsmAV6p7TgwXYGrCZIFFbAHg==",
"dev": true,
"dependencies": {
"chokidar": ">=3.0.0 <4.0.0",
@@ -946,9 +974,9 @@
}
},
"node_modules/svelte": {
- "version": "3.58.0",
- "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.58.0.tgz",
- "integrity": "sha512-brIBNNB76mXFmU/Kerm4wFnkskBbluBDCjx/8TcpYRb298Yh2dztS2kQ6bhtjMcvUhd5ynClfwpz5h2gnzdQ1A==",
+ "version": "3.59.1",
+ "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.59.1.tgz",
+ "integrity": "sha512-pKj8fEBmqf6mq3/NfrB9SLtcJcUvjYSWyePlfCqN9gujLB25RitWK8PvFzlwim6hD/We35KbPlRteuA6rnPGcQ==",
"dev": true,
"engines": {
"node": ">= 8"
@@ -1026,14 +1054,14 @@
}
},
"node_modules/vite": {
- "version": "4.3.1",
- "resolved": "https://registry.npmjs.org/vite/-/vite-4.3.1.tgz",
- "integrity": "sha512-EPmfPLAI79Z/RofuMvkIS0Yr091T2ReUoXQqc5ppBX/sjFRhHKiPPF/R46cTdoci/XgeQpB23diiJxq5w30vdg==",
+ "version": "4.3.9",
+ "resolved": "https://registry.npmjs.org/vite/-/vite-4.3.9.tgz",
+ "integrity": "sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==",
"dev": true,
"dependencies": {
"esbuild": "^0.17.5",
- "postcss": "^8.4.21",
- "rollup": "^3.20.2"
+ "postcss": "^8.4.23",
+ "rollup": "^3.21.0"
},
"bin": {
"vite": "bin/vite.js"
@@ -1090,9 +1118,9 @@
},
"dependencies": {
"@axa-fr/vanilla-oidc": {
- "version": "6.16.14",
- "resolved": "https://registry.npmjs.org/@axa-fr/vanilla-oidc/-/vanilla-oidc-6.16.14.tgz",
- "integrity": "sha512-Cwy9QA7BWfw0Sd9yMeZ3SnuoW4JfyBPyEA6eT9EXVHYWjiMa2bZfYtUHNsdYobRMwkDlFVK7ObjMzd4+ki1//Q==",
+ "version": "6.19.2",
+ "resolved": "https://registry.npmjs.org/@axa-fr/vanilla-oidc/-/vanilla-oidc-6.19.2.tgz",
+ "integrity": "sha512-2TZyBbUaG97U5VB9lKFns5OgAS3WBFE+lhQd5MCeXR4Vwg/ZMFbE8SXZUU61OMdC6IVmr79naUg393F7HENhVQ==",
"dev": true,
"requires": {
"base64-js": "1.5.1"
@@ -1266,11 +1294,12 @@
"peer": true
},
"@sveltejs/vite-plugin-svelte": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-2.1.0.tgz",
- "integrity": "sha512-Bc9A8mtTGlhTICdLL/aZ+jyHI3kwtkcXremOH5xwjbNNKOTOtY8nMyG8/oZ5KK8IuUfAn1WL58Bp2tofDJBW0w==",
+ "version": "2.4.1",
+ "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-2.4.1.tgz",
+ "integrity": "sha512-bNNKvoRY89ptY7udeBSCmTdCVwkjmMcZ0j/z9J5MuedT8jPjq0zrknAo/jF1sToAza4NVaAgR9AkZoD9oJJmnA==",
"dev": true,
"requires": {
+ "@sveltejs/vite-plugin-svelte-inspector": "^1.0.2",
"debug": "^4.3.4",
"deepmerge": "^4.3.1",
"kleur": "^4.1.5",
@@ -1279,6 +1308,15 @@
"vitefu": "^0.2.4"
}
},
+ "@sveltejs/vite-plugin-svelte-inspector": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte-inspector/-/vite-plugin-svelte-inspector-1.0.2.tgz",
+ "integrity": "sha512-Cy1dUMcYCnDVV/hPLXa43YZJ2jGKVW5rA0xuNL9dlmYhT0yoS1g7+FOFSRlgk0BXKk/Oc7grs+8BVA5Iz2fr8A==",
+ "dev": true,
+ "requires": {
+ "debug": "^4.3.4"
+ }
+ },
"anymatch": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
@@ -1296,9 +1334,9 @@
"dev": true
},
"axios": {
- "version": "1.3.6",
- "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.6.tgz",
- "integrity": "sha512-PEcdkk7JcdPiMDkvM4K6ZBRYq9keuVJsToxm2zQIM70Qqo2WHTdJZMXcG9X+RmRp2VPNUQC8W1RAGbgt6b1yMg==",
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz",
+ "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==",
"dev": true,
"requires": {
"follow-redirects": "^1.15.0",
@@ -1540,9 +1578,9 @@
"dev": true
},
"nanoid": {
- "version": "3.3.4",
- "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz",
- "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==",
+ "version": "3.3.6",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
+ "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==",
"dev": true
},
"no-case": {
@@ -1584,12 +1622,12 @@
"dev": true
},
"postcss": {
- "version": "8.4.21",
- "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.21.tgz",
- "integrity": "sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg==",
+ "version": "8.4.24",
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.24.tgz",
+ "integrity": "sha512-M0RzbcI0sO/XJNucsGjvWU9ERWxb/ytp1w6dKtxTKgixdtQDq4rmx/g8W1hnaheq9jgwL/oyEdH5Bc4WwJKMqg==",
"dev": true,
"requires": {
- "nanoid": "^3.3.4",
+ "nanoid": "^3.3.6",
"picocolors": "^1.0.0",
"source-map-js": "^1.0.2"
}
@@ -1610,18 +1648,18 @@
}
},
"rollup": {
- "version": "3.20.7",
- "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.20.7.tgz",
- "integrity": "sha512-P7E2zezKSLhWnTz46XxjSmInrbOCiul1yf+kJccMxT56vxjHwCbDfoLbiqFgu+WQoo9ij2PkraYaBstgB2prBA==",
+ "version": "3.25.0",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.0.tgz",
+ "integrity": "sha512-FnJkNRst2jEZGw7f+v4hFo6UTzpDKrAKcHZWcEfm5/GJQ5CK7wgb4moNLNAe7npKUev7yQn1AY/YbZRIxOv6Qg==",
"dev": true,
"requires": {
"fsevents": "~2.3.2"
}
},
"sass": {
- "version": "1.62.0",
- "resolved": "https://registry.npmjs.org/sass/-/sass-1.62.0.tgz",
- "integrity": "sha512-Q4USplo4pLYgCi+XlipZCWUQz5pkg/ruSSgJ0WRDSb/+3z9tXUOkQ7QPYn4XrhZKYAK4HlpaQecRwKLJX6+DBg==",
+ "version": "1.63.3",
+ "resolved": "https://registry.npmjs.org/sass/-/sass-1.63.3.tgz",
+ "integrity": "sha512-ySdXN+DVpfwq49jG1+hmtDslYqpS7SkOR5GpF6o2bmb1RL/xS+wvPmegMvMywyfsmAV6p7TgwXYGrCZIFFbAHg==",
"dev": true,
"requires": {
"chokidar": ">=3.0.0 <4.0.0",
@@ -1636,9 +1674,9 @@
"dev": true
},
"svelte": {
- "version": "3.58.0",
- "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.58.0.tgz",
- "integrity": "sha512-brIBNNB76mXFmU/Kerm4wFnkskBbluBDCjx/8TcpYRb298Yh2dztS2kQ6bhtjMcvUhd5ynClfwpz5h2gnzdQ1A==",
+ "version": "3.59.1",
+ "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.59.1.tgz",
+ "integrity": "sha512-pKj8fEBmqf6mq3/NfrB9SLtcJcUvjYSWyePlfCqN9gujLB25RitWK8PvFzlwim6hD/We35KbPlRteuA6rnPGcQ==",
"dev": true
},
"svelte-hmr": {
@@ -1690,15 +1728,15 @@
"peer": true
},
"vite": {
- "version": "4.3.1",
- "resolved": "https://registry.npmjs.org/vite/-/vite-4.3.1.tgz",
- "integrity": "sha512-EPmfPLAI79Z/RofuMvkIS0Yr091T2ReUoXQqc5ppBX/sjFRhHKiPPF/R46cTdoci/XgeQpB23diiJxq5w30vdg==",
+ "version": "4.3.9",
+ "resolved": "https://registry.npmjs.org/vite/-/vite-4.3.9.tgz",
+ "integrity": "sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==",
"dev": true,
"requires": {
"esbuild": "^0.17.5",
"fsevents": "~2.3.2",
- "postcss": "^8.4.21",
- "rollup": "^3.20.2"
+ "postcss": "^8.4.23",
+ "rollup": "^3.21.0"
}
},
"vitefu": {
diff --git a/client/package.json b/client/package.json
index 403a8f0..bbd818b 100644
--- a/client/package.json
+++ b/client/package.json
@@ -9,13 +9,13 @@
"preview": "vite preview"
},
"devDependencies": {
- "@axa-fr/vanilla-oidc": "^6.16.14",
- "@sveltejs/vite-plugin-svelte": "^2.0.4",
- "axios": "^1.3.5",
+ "@axa-fr/vanilla-oidc": "^6.19.2",
+ "@sveltejs/vite-plugin-svelte": "^2.4.1",
+ "axios": "^1.4.0",
"bootstrap": "^5.2.3",
- "sass": "^1.61.0",
- "svelte": "^3.58.0",
+ "sass": "^1.63.3",
+ "svelte": "^3.59.1",
"svelte-navigator": "^3.2.2",
- "vite": "^4.2.1"
+ "vite": "^4.3.9"
}
}
\ No newline at end of file
diff --git a/client/public/OidcServiceWorker.js b/client/public/OidcServiceWorker.js
index ca22aa3..08a48d4 100644
--- a/client/public/OidcServiceWorker.js
+++ b/client/public/OidcServiceWorker.js
@@ -1,2 +1,2 @@
-"use strict";const N="OidcTrustedDomains.js",y="*",_={REFRESH_TOKEN:"REFRESH_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",ACCESS_TOKEN:"ACCESS_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",NONCE_TOKEN:"NONCE_SECURED_BY_OIDC_SERVICE_WORKER",CODE_VERIFIER:"CODE_VERIFIER_SECURED_BY_OIDC_SERVICE_WORKER"},v={access_token_or_id_token_invalid:"access_token_or_id_token_invalid",access_token_invalid:"access_token_invalid",id_token_invalid:"id_token_invalid"},A="/.well-known/openid-configuration";function x(n,t){if(!t)return;if(!n.find(e=>{var s;let o;return typeof e=="string"?o=new RegExp(`^${e}`):o=e,(s=o.test)==null?void 0:s.call(o,t)}))throw new Error("Domain "+t+" is not trusted, please add domain in "+N)}const D=(n,t,i)=>{var e;if(t.endsWith(A))return null;for(const[o,s]of Object.entries(n)){const a=s.oidcServerConfiguration;if(!a||a.tokenEndpoint&&t===a.tokenEndpoint||a.revocationEndpoint&&t===a.revocationEndpoint)continue;const d=a.userInfoEndpoint?[a.userInfoEndpoint,...i[o]]:[...i[o]];let c=!1;if(d.find(u=>u===y))c=!0;else for(let u=0;u"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)).join(""))}function P(n,t){const i=new Date().getTime()/1e3;return Math.round(t-n-i)}function W(n){return n?P(0,n.expiresAt)>0:!1}const w=n=>{try{return n&&K(n,".")===2?M(n):null}catch(t){console.warn(t)}return null},F=(n,t,i)=>{if(n.idTokenPayload){const e=n.idTokenPayload;if(i.issuer!==e.iss)return{isValid:!1,reason:"Issuer does not match"};const o=new Date().getTime()/1e3;if(e.exp&&e.expi.status!==200?i:i.json().then(e=>{if(!e.issued_at){const f=new Date().getTime()/1e3;e.issued_at=f}const o=w(e.access_token),s={...e,access_token:_.ACCESS_TOKEN+"_"+t,accessTokenPayload:o};e.accessTokenPayload=o;let a=null;if(e.id_token){if(a=w(e.id_token),e.idTokenPayload={...a},a.nonce&&n.nonce!=null){const f=_.NONCE_TOKEN+"_"+n.configurationName;a.nonce=f}s.idTokenPayload=a}e.refresh_token&&(s.refresh_token=_.REFRESH_TOKEN+"_"+t);const d=a&&a.exp?a.exp:Number.MAX_VALUE,c=o&&o.exp?o.exp:e.issued_at+e.expires_in;let u;const r=n.oidcConfiguration.token_renew_mode;r===v.access_token_invalid?u=c:r===v.id_token_invalid?u=d:u=dnew Promise(t=>setTimeout(t,n)),g=self;g.importScripts(N);const I=Math.round(new Date().getTime()/1e3).toString(),b="OidcKeepAliveServiceWorker.json",q=n=>{console.log("[OidcServiceWorker] service worker installed "+I),n.waitUntil(g.skipWaiting())},L=n=>{console.log("[OidcServiceWorker] service worker activated "+I),n.waitUntil(g.clients.claim())};let S=null;const h={default:{configurationName:"default",tokens:null,status:null,state:null,codeVerifier:null,nonce:null,oidcServerConfiguration:null}},H=(n,t)=>{const i=[];for(const[,e]of Object.entries(n))(e.oidcServerConfiguration!=null&&t.startsWith(e.oidcServerConfiguration.tokenEndpoint)||e.oidcServerConfiguration!=null&&e.oidcServerConfiguration.revocationEndpoint&&t.startsWith(e.oidcServerConfiguration.revocationEndpoint))&&i.push(e);return i},j=async n=>{const t=n.request,i=t.headers.has("oidc-vanilla"),e={status:200,statusText:"oidc-service-worker"},o=new Response("{}",e);if(!i){const s=new URL(t.url),a=Number(s.searchParams.get("minSleepSeconds"))||240;for(let d=0;d{const t=n.request,i=t.url;if(t.url.includes(b)){n.respondWith(j(n));return}const e=D(h,t.url,trustedDomains);if(e&&e.tokens&&e.tokens.access_token){for(;e.tokens&&!W(e.tokens);)await V(200);const d=new Request(t,{headers:{...C(t.headers),authorization:"Bearer "+e.tokens.access_token},mode:e.oidcConfiguration.service_worker_convert_all_requests_to_cors?"cors":t.mode});n.waitUntil(n.respondWith(fetch(d)));return}if(n.request.method!=="POST")return;let o=null;const s=H(h,t.url),a=s.length;if(a>0){const d=new Promise((c,u)=>{const r=t.clone();r.text().then(l=>{if(l.includes(_.REFRESH_TOKEN)||l.includes(_.ACCESS_TOKEN)){let k=l;for(let f=0;f{const E=await f.text();return new Response(E,f)}):p.then(O(o))}else if(l.includes("code_verifier=")&&S){o=h[S],S=null;let k=l;if(o&&o.codeVerifier!=null){const p=_.CODE_VERIFIER+"_"+o.configurationName;l.includes(p)&&(k=k.replace(p,o.codeVerifier))}return fetch(t,{body:k,method:r.method,headers:{...C(t.headers)},mode:r.mode,cache:r.cache,redirect:r.redirect,referrer:r.referrer,credentials:r.credentials,integrity:r.integrity}).then(O(o))}}).then(l=>{l!==void 0?c(l):(console.log("success undefined"),u(new Error("Response is undefined inside a success")))}).catch(l=>{l!==void 0?u(l):(console.log("error undefined"),u(new Error("Response is undefined inside a error")))})});n.waitUntil(n.respondWith(d))}},Y=n=>{const t=n.ports[0],i=n.data,e=i.configurationName;let o=h[e];switch(o||(h[e]={tokens:null,state:null,codeVerifier:null,oidcServerConfiguration:null,oidcConfiguration:void 0,nonce:null,status:null,configurationName:e},o=h[e],trustedDomains[e]||(trustedDomains[e]=[])),i.type){case"clear":o.tokens=null,o.state=null,o.codeVerifier=null,o.status=i.data.status,t.postMessage({configurationName:e});return;case"init":{const s=i.data.oidcServerConfiguration,a=trustedDomains[e];a.find(c=>c===y)||[s.tokenEndpoint,s.revocationEndpoint,s.userInfoEndpoint,s.issuer].forEach(c=>{x(a,c)}),o.oidcServerConfiguration=s,o.oidcConfiguration=i.data.oidcConfiguration;const d=i.data.where;if(d==="loginCallbackAsync"||d==="tryKeepExistingSessionAsync"?S=e:S=null,!o.tokens)t.postMessage({tokens:null,status:o.status,configurationName:e});else{const c={...o.tokens,access_token:_.ACCESS_TOKEN+"_"+e};c.refresh_token&&(c.refresh_token=_.REFRESH_TOKEN+"_"+e),c.idTokenPayload&&c.idTokenPayload.nonce&&o.nonce!=null&&(c.idTokenPayload.nonce=_.NONCE_TOKEN+"_"+e),t.postMessage({tokens:c,status:o.status,configurationName:e})}return}case"setState":o.state=i.data.state,t.postMessage({configurationName:e});return;case"getState":{const s=o.state;t.postMessage({configurationName:e,state:s});return}case"setCodeVerifier":o.codeVerifier=i.data.codeVerifier,t.postMessage({configurationName:e});return;case"getCodeVerifier":{t.postMessage({configurationName:e,codeVerifier:_.CODE_VERIFIER+"_"+e});return}case"setSessionState":o.sessionState=i.data.sessionState,t.postMessage({configurationName:e});return;case"getSessionState":{const s=o.sessionState;t.postMessage({configurationName:e,sessionState:s});return}case"setNonce":o.nonce=i.data.nonce,t.postMessage({configurationName:e});return;default:o.items={...i.data},t.postMessage({configurationName:e})}};g.addEventListener("install",q);g.addEventListener("activate",L);g.addEventListener("fetch",J);g.addEventListener("message",Y);
+"use strict";const N="OidcTrustedDomains.js",A="*",_={REFRESH_TOKEN:"REFRESH_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",ACCESS_TOKEN:"ACCESS_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",NONCE_TOKEN:"NONCE_SECURED_BY_OIDC_SERVICE_WORKER",CODE_VERIFIER:"CODE_VERIFIER_SECURED_BY_OIDC_SERVICE_WORKER"},w={access_token_or_id_token_invalid:"access_token_or_id_token_invalid",access_token_invalid:"access_token_invalid",id_token_invalid:"id_token_invalid"},I="/.well-known/openid-configuration";function x(o,e){if(!e)return;if(!o.find(n=>{var i;let t;return typeof n=="string"?t=new RegExp(`^${n}`):t=n,(i=t.test)==null?void 0:i.call(t,e)}))throw new Error("Domain "+e+" is not trusted, please add domain in "+N)}const K=(o,e,s)=>{var n;if(e.endsWith(I))return null;for(const[t,i]of Object.entries(o)){const d=i.oidcServerConfiguration;if(!d||d.tokenEndpoint&&e===d.tokenEndpoint||d.revocationEndpoint&&e===d.revocationEndpoint)continue;const l=s==null?[]:s[t],f=Array.isArray(l)?l:l.domains,a=d.userInfoEndpoint?[d.userInfoEndpoint,...f]:[...f];let c=!1;if(a.find(h=>h===A))c=!0;else for(let h=0;h"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))}function W(o,e){const s=new Date().getTime()/1e3;return Math.round(e-o-s)}function F(o){return o?W(0,o.expiresAt)>0:!1}const O=o=>{try{return o&&M(o,".")===2?U(o):null}catch(e){console.warn(e)}return null},b=(o,e,s)=>{if(o.idTokenPayload){const n=o.idTokenPayload;if(s.issuer!==n.iss)return{isValid:!1,reason:"Issuer does not match"};const t=new Date().getTime()/1e3;if(n.exp&&n.exps.status!==200?s:s.json().then(n=>{const t=q(n,o,e),i=JSON.stringify(t);return new Response(i,s)})}function T(o){const e={};for(const s of o.keys())o.has(s)&&(e[s]=o.get(s));return e}const D=o=>new Promise(e=>setTimeout(e,o)),p=self;p.importScripts(N);const V=Math.round(new Date().getTime()/1e3).toString(),L="OidcKeepAliveServiceWorker.json",H=o=>{console.log("[OidcServiceWorker] service worker installed "+V),o.waitUntil(p.skipWaiting())},j=o=>{console.log("[OidcServiceWorker] service worker activated "+V),o.waitUntil(p.clients.claim())};let m=null;const E={default:{configurationName:"default",tokens:null,status:null,state:null,codeVerifier:null,nonce:null,oidcServerConfiguration:null,hideAccessToken:!0}},J=(o,e)=>{const s=[];for(const[,n]of Object.entries(o))(n.oidcServerConfiguration!=null&&e.startsWith(n.oidcServerConfiguration.tokenEndpoint)||n.oidcServerConfiguration!=null&&n.oidcServerConfiguration.revocationEndpoint&&e.startsWith(n.oidcServerConfiguration.revocationEndpoint))&&s.push(n);return s},Y=async o=>{const e=o.request,s=e.headers.has("oidc-vanilla"),n={status:200,statusText:"oidc-service-worker"},t=new Response("{}",n);if(!s){const i=new URL(e.url),d=Number(i.searchParams.get("minSleepSeconds"))||240;for(let l=0;l{const e=o.request,s=e.url;if(e.url.includes(L)){o.respondWith(Y(o));return}const n=K(E,e.url,trustedDomains);if(n&&n.tokens&&n.tokens.access_token){for(;n.tokens&&!F(n.tokens);)await D(200);const l=e.mode=="navigate"?new Request(e,{headers:{...T(e.headers),authorization:"Bearer "+n.tokens.access_token}}):new Request(e,{headers:{...T(e.headers),authorization:"Bearer "+n.tokens.access_token},mode:n.oidcConfiguration.service_worker_convert_all_requests_to_cors?"cors":e.mode});o.waitUntil(o.respondWith(fetch(l)));return}if(o.request.method!=="POST")return;let t=null;const i=J(E,e.url),d=i.length;if(d>0){const l=new Promise((f,a)=>{const c=e.clone();c.text().then(r=>{if(r.includes(_.REFRESH_TOKEN)||r.includes(_.ACCESS_TOKEN)){let u=r;for(let g=0;g{const k=await g.text();return new Response(k,g)}):S.then(y(t))}else if(r.includes("code_verifier=")&&m){t=E[m],m=null;let u=r;if(t&&t.codeVerifier!=null){const S=_.CODE_VERIFIER+"_"+t.configurationName;r.includes(S)&&(u=u.replace(S,t.codeVerifier))}return fetch(e,{body:u,method:c.method,headers:{...T(e.headers)},mode:c.mode,cache:c.cache,redirect:c.redirect,referrer:c.referrer,credentials:c.credentials,integrity:c.integrity}).then(y(t))}}).then(r=>{r!==void 0?f(r):(console.log("success undefined"),a(new Error("Response is undefined inside a success")))}).catch(r=>{r!==void 0?a(r):(console.log("error undefined"),a(new Error("Response is undefined inside a error")))})});o.waitUntil(o.respondWith(l))}},C={},$=o=>{const e=o.ports[0],s=o.data,n=s.configurationName;let t=E[n];if(trustedDomains==null&&(trustedDomains={}),!t){if(C[n]===void 0){let i=trustedDomains[n];C[n]=Array.isArray(i)?!1:i.showAccessToken}E[n]={tokens:null,state:null,codeVerifier:null,oidcServerConfiguration:null,oidcConfiguration:void 0,nonce:null,status:null,configurationName:n,hideAccessToken:!C[n]},console.log(E[n]),t=E[n],trustedDomains[n]||(trustedDomains[n]=[])}switch(s.type){case"clear":t.tokens=null,t.state=null,t.codeVerifier=null,t.status=s.data.status,e.postMessage({configurationName:n});return;case"init":{const i=s.data.oidcServerConfiguration;let d=trustedDomains[n];const l=Array.isArray(d)?d:d.domains;l.find(a=>a===A)||[i.tokenEndpoint,i.revocationEndpoint,i.userInfoEndpoint,i.issuer].forEach(a=>{x(l,a)}),t.oidcServerConfiguration=i,t.oidcConfiguration=s.data.oidcConfiguration;const f=s.data.where;if(f==="loginCallbackAsync"||f==="tryKeepExistingSessionAsync"?m=n:m=null,!t.tokens)e.postMessage({tokens:null,status:t.status,configurationName:n});else{const a={...t.tokens};t.hideAccessToken&&(a.access_token=_.ACCESS_TOKEN+"_"+n),a.refresh_token&&(a.refresh_token=_.REFRESH_TOKEN+"_"+n),a.idTokenPayload&&a.idTokenPayload.nonce&&t.nonce!=null&&(a.idTokenPayload.nonce=_.NONCE_TOKEN+"_"+n),e.postMessage({tokens:a,status:t.status,configurationName:n})}return}case"setState":t.state=s.data.state,e.postMessage({configurationName:n});return;case"getState":{const i=t.state;e.postMessage({configurationName:n,state:i});return}case"setCodeVerifier":t.codeVerifier=s.data.codeVerifier,e.postMessage({configurationName:n});return;case"getCodeVerifier":{e.postMessage({configurationName:n,codeVerifier:_.CODE_VERIFIER+"_"+n});return}case"setSessionState":t.sessionState=s.data.sessionState,e.postMessage({configurationName:n});return;case"getSessionState":{const i=t.sessionState;e.postMessage({configurationName:n,sessionState:i});return}case"setNonce":t.nonce=s.data.nonce,e.postMessage({configurationName:n});return;default:t.items={...s.data},e.postMessage({configurationName:n})}};p.addEventListener("install",H);p.addEventListener("activate",j);p.addEventListener("fetch",z);p.addEventListener("message",$);
//# sourceMappingURL=OidcServiceWorker.js.map