@axa-fr/react-oidc 6.0.8 → 6.0.9

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.
@@ -59,6 +59,9 @@ const isTokensValid= (tokens) =>{
59
59
  function hideTokens(currentDatabaseElement) {
60
60
  const configurationName = currentDatabaseElement.configurationName;
61
61
  return (response) => {
62
+ if(response.status !== 200){
63
+ return response;
64
+ }
62
65
  return response.json().then(tokens => {
63
66
  if(!tokens.issued_at) {
64
67
  const currentTimeUnixSecond = new Date().getTime() /1000;
@@ -73,7 +76,7 @@ function hideTokens(currentDatabaseElement) {
73
76
  };
74
77
  tokens.accessTokenPayload = accessTokenPayload;
75
78
 
76
- let _idTokenPayload = null;
79
+ let _idTokenPayload = null;
77
80
  if(tokens.id_token) {
78
81
  _idTokenPayload = extractTokenPayload(tokens.id_token);
79
82
  secureTokens.idTokenPayload = _idTokenPayload;
@@ -113,11 +116,11 @@ const getCurrentDatabaseDomain = (database, url) => {
113
116
  }
114
117
  for (const [key, currentDatabase] of Object.entries(database)) {
115
118
  const oidcServerConfiguration = currentDatabase.oidcServerConfiguration;
116
-
119
+
117
120
  if(!oidcServerConfiguration){
118
121
  continue;
119
122
  }
120
-
123
+
121
124
  if(oidcServerConfiguration.tokenEndpoint && url === oidcServerConfiguration.tokenEndpoint){
122
125
  continue;
123
126
  }
@@ -184,11 +187,10 @@ const handleFetch = async (event) => {
184
187
  }
185
188
 
186
189
  const currentDatabaseForRequestAccessToken = getCurrentDatabaseDomain(database, originalRequest.url);
187
- if(currentDatabaseForRequestAccessToken && currentDatabaseForRequestAccessToken.tokens) {
188
-
190
+ if(currentDatabaseForRequestAccessToken && currentDatabaseForRequestAccessToken.tokens && currentDatabaseForRequestAccessToken.tokens.access_token) {
189
191
  while (currentDatabaseForRequestAccessToken.tokens && !isTokensValid(currentDatabaseForRequestAccessToken.tokens)){
190
192
  await sleep(200);
191
- }
193
+ }
192
194
  const newRequest = new Request(originalRequest, {
193
195
  headers: {
194
196
  ...serializeHeaders(originalRequest.headers),
@@ -220,7 +222,7 @@ const handleFetch = async (event) => {
220
222
  break;
221
223
  }
222
224
  }
223
-
225
+
224
226
  return fetch(clonedRequest, {
225
227
  body: newBody,
226
228
  method: clonedRequest.method,
@@ -278,11 +280,11 @@ self.addEventListener('fetch', handleFetch);
278
280
 
279
281
 
280
282
  const checkDomain =(domains, tokenEndpoint) => {
281
-
283
+
282
284
  if(!tokenEndpoint){
283
285
  return;
284
286
  }
285
-
287
+
286
288
  const domain = domains.find(domain => tokenEndpoint.startsWith(domain));
287
289
  if(!domain){
288
290
  throw new Error("Domain " + tokenEndpoint+ " is not trusted, please add domain in TrustedDomains.js");
@@ -332,7 +334,7 @@ addEventListener('message', event => {
332
334
  } else{
333
335
  currentLoginCallbackConfigurationName = null;
334
336
  }
335
-
337
+
336
338
  if(!currentDatabase.tokens){
337
339
  port.postMessage({
338
340
  tokens:null,
@@ -353,7 +355,7 @@ addEventListener('message', event => {
353
355
  });
354
356
  }
355
357
  return;
356
-
358
+
357
359
  case "setSessionState":
358
360
  currentDatabase.sessionState = data.data.sessionState;
359
361
  port.postMessage({configurationName});
@@ -5,7 +5,7 @@
5
5
 
6
6
  // Domains used by OIDC server must be also declared here
7
7
  const trustedDomains = {
8
- default:["https://demo.duendesoftware.com"],
8
+ default:["https://demo.duendesoftware.com", "https://kdhttps.auth0.com"],
9
9
  config_classic: ["https://demo.duendesoftware.com"] ,
10
10
  config_without_refresh_token: ["https://demo.duendesoftware.com"],
11
11
  config_google: ["https://oauth2.googleapis.com", "https://openidconnect.googleapis.com"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/react-oidc",
3
- "version": "6.0.8",
3
+ "version": "6.0.9",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "jsnext:main": "dist/index.js",
@@ -59,6 +59,9 @@ const isTokensValid= (tokens) =>{
59
59
  function hideTokens(currentDatabaseElement) {
60
60
  const configurationName = currentDatabaseElement.configurationName;
61
61
  return (response) => {
62
+ if(response.status !== 200){
63
+ return response;
64
+ }
62
65
  return response.json().then(tokens => {
63
66
  if(!tokens.issued_at) {
64
67
  const currentTimeUnixSecond = new Date().getTime() /1000;
@@ -73,7 +76,7 @@ function hideTokens(currentDatabaseElement) {
73
76
  };
74
77
  tokens.accessTokenPayload = accessTokenPayload;
75
78
 
76
- let _idTokenPayload = null;
79
+ let _idTokenPayload = null;
77
80
  if(tokens.id_token) {
78
81
  _idTokenPayload = extractTokenPayload(tokens.id_token);
79
82
  secureTokens.idTokenPayload = _idTokenPayload;
@@ -113,11 +116,11 @@ const getCurrentDatabaseDomain = (database, url) => {
113
116
  }
114
117
  for (const [key, currentDatabase] of Object.entries(database)) {
115
118
  const oidcServerConfiguration = currentDatabase.oidcServerConfiguration;
116
-
119
+
117
120
  if(!oidcServerConfiguration){
118
121
  continue;
119
122
  }
120
-
123
+
121
124
  if(oidcServerConfiguration.tokenEndpoint && url === oidcServerConfiguration.tokenEndpoint){
122
125
  continue;
123
126
  }
@@ -184,11 +187,10 @@ const handleFetch = async (event) => {
184
187
  }
185
188
 
186
189
  const currentDatabaseForRequestAccessToken = getCurrentDatabaseDomain(database, originalRequest.url);
187
- if(currentDatabaseForRequestAccessToken && currentDatabaseForRequestAccessToken.tokens) {
188
-
190
+ if(currentDatabaseForRequestAccessToken && currentDatabaseForRequestAccessToken.tokens && currentDatabaseForRequestAccessToken.tokens.access_token) {
189
191
  while (currentDatabaseForRequestAccessToken.tokens && !isTokensValid(currentDatabaseForRequestAccessToken.tokens)){
190
192
  await sleep(200);
191
- }
193
+ }
192
194
  const newRequest = new Request(originalRequest, {
193
195
  headers: {
194
196
  ...serializeHeaders(originalRequest.headers),
@@ -220,7 +222,7 @@ const handleFetch = async (event) => {
220
222
  break;
221
223
  }
222
224
  }
223
-
225
+
224
226
  return fetch(clonedRequest, {
225
227
  body: newBody,
226
228
  method: clonedRequest.method,
@@ -278,11 +280,11 @@ self.addEventListener('fetch', handleFetch);
278
280
 
279
281
 
280
282
  const checkDomain =(domains, tokenEndpoint) => {
281
-
283
+
282
284
  if(!tokenEndpoint){
283
285
  return;
284
286
  }
285
-
287
+
286
288
  const domain = domains.find(domain => tokenEndpoint.startsWith(domain));
287
289
  if(!domain){
288
290
  throw new Error("Domain " + tokenEndpoint+ " is not trusted, please add domain in TrustedDomains.js");
@@ -332,7 +334,7 @@ addEventListener('message', event => {
332
334
  } else{
333
335
  currentLoginCallbackConfigurationName = null;
334
336
  }
335
-
337
+
336
338
  if(!currentDatabase.tokens){
337
339
  port.postMessage({
338
340
  tokens:null,
@@ -353,7 +355,7 @@ addEventListener('message', event => {
353
355
  });
354
356
  }
355
357
  return;
356
-
358
+
357
359
  case "setSessionState":
358
360
  currentDatabase.sessionState = data.data.sessionState;
359
361
  port.postMessage({configurationName});
@@ -5,7 +5,7 @@
5
5
 
6
6
  // Domains used by OIDC server must be also declared here
7
7
  const trustedDomains = {
8
- default:["https://demo.duendesoftware.com"],
8
+ default:["https://demo.duendesoftware.com", "https://kdhttps.auth0.com"],
9
9
  config_classic: ["https://demo.duendesoftware.com"] ,
10
10
  config_without_refresh_token: ["https://demo.duendesoftware.com"],
11
11
  config_google: ["https://oauth2.googleapis.com", "https://openidconnect.googleapis.com"],