@axa-fr/react-oidc 6.5.10 → 6.6.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.
@@ -2,6 +2,8 @@
2
2
 
3
3
  const id = Math.round(new Date().getTime() / 1000).toString();
4
4
 
5
+ const acceptAnyDomainToken = "*";
6
+
5
7
  const keepAliveJsonFilename = "OidcKeepAliveServiceWorker.json";
6
8
  const handleInstall = (event) => {
7
9
  console.log('[OidcServiceWorker] service worker installed ' + id);
@@ -182,11 +184,15 @@ const getCurrentDatabaseDomain = (database, url) => {
182
184
  ] : [...trustedDomains[key]];
183
185
 
184
186
  let hasToSendToken = false;
185
- for(let i=0;i<domainsToSendTokens.length;i++) {
186
- const domain = domainsToSendTokens[i];
187
- if (url.startsWith(domain)) {
188
- hasToSendToken = true;
189
- break;
187
+ if (domainsToSendTokens.find((f) => f === acceptAnyDomainToken)) {
188
+ hasToSendToken= true;
189
+ } else {
190
+ for (let i = 0; i < domainsToSendTokens.length; i++) {
191
+ const domain = domainsToSendTokens[i];
192
+ if (url.startsWith(domain)) {
193
+ hasToSendToken = true;
194
+ break;
195
+ }
190
196
  }
191
197
  }
192
198
 
@@ -335,15 +341,14 @@ self.addEventListener('activate', handleActivate);
335
341
  self.addEventListener('fetch', handleFetch);
336
342
 
337
343
 
338
- const checkDomain =(domains, tokenEndpoint) => {
339
-
340
- if(!tokenEndpoint){
344
+ const checkDomain = (domains, endpoint) => {
345
+ if(!endpoint){
341
346
  return;
342
347
  }
343
348
 
344
- const domain = domains.find(domain => tokenEndpoint.startsWith(domain));
349
+ const domain = domains.find(domain => endpoint.startsWith(domain));
345
350
  if(!domain){
346
- throw new Error("Domain " + tokenEndpoint+ " is not trusted, please add domain in TrustedDomains.js");
351
+ throw new Error("Domain " + endpoint + " is not trusted, please add domain in TrustedDomains.js");
347
352
  }
348
353
  }
349
354
 
@@ -378,13 +383,12 @@ addEventListener('message', event => {
378
383
  return;
379
384
  case "init":
380
385
  const oidcServerConfiguration = data.data.oidcServerConfiguration;
381
- const tokenEndpoint = oidcServerConfiguration.tokenEndpoint;
382
386
  const domains = trustedDomains[configurationName];
383
- checkDomain(domains, tokenEndpoint);
384
- const userInfoEndpoint = oidcServerConfiguration.userInfoEndpoint;
385
- checkDomain(domains, userInfoEndpoint);
386
- const issuer = oidcServerConfiguration.issuer;
387
- checkDomain(domains, issuer);
387
+ if (!domains.find(f => f === acceptAnyDomainToken)) {
388
+ checkDomain(domains, oidcServerConfiguration.tokenEndpoint);
389
+ checkDomain(domains, oidcServerConfiguration.userInfoEndpoint);
390
+ checkDomain(domains, oidcServerConfiguration.issuer);
391
+ }
388
392
  currentDatabase.oidcServerConfiguration = oidcServerConfiguration;
389
393
  const where = data.data.where;
390
394
  if(where === "loginCallbackAsync" || where === "tryKeepExistingSessionAsync") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/react-oidc",
3
- "version": "6.5.10",
3
+ "version": "6.6.1",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "jsnext:main": "dist/index.js",