@axa-fr/react-oidc 6.13.2 → 6.13.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 CHANGED
@@ -148,6 +148,7 @@ const propTypes = {
148
148
  refresh_time_before_tokens_expiration_in_second: PropTypes.number,
149
149
  service_worker_relative_url: PropTypes.string,
150
150
  service_worker_only: PropTypes.boolean, // default false
151
+ service_worker_convert_all_requests_to_cors: PropTypes.boolean, // force all requests that servie worker upgrades to have 'cors' mode. This allows setting authentication token on requests initialted by html parsing(e.g. img tags, download links etc).
151
152
  extras: StringMap | undefined, // ex: {'prompt': 'consent', 'access_type': 'offline'} list of key/value that are send to the oidc server (more info: https://github.com/openid/AppAuth-JS)
152
153
  token_request_extras: StringMap | undefined, // ex: {'prompt': 'consent', 'access_type': 'offline'} list of key/value that are send to the oidc server during token request (more info: https://github.com/openid/AppAuth-JS)
153
154
  withCustomHistory: PropTypes.function, // Override history modification, return instance with replaceState(url, stateHistory) implemented (like History.replaceState())
@@ -217,7 +217,7 @@ const getCurrentDatabaseDomain = (database, url) => {
217
217
  let domain = domainsToSendTokens[i];
218
218
 
219
219
  if (typeof domain === 'string') {
220
- domain = new RegExp(`^${domain}`, 'gm');
220
+ domain = new RegExp(`^${domain}`);
221
221
  }
222
222
 
223
223
  if (domain.test?.(url)) {
@@ -286,6 +286,7 @@ const handleFetch = async (event) => {
286
286
  ...serializeHeaders(originalRequest.headers),
287
287
  authorization: 'Bearer ' + currentDatabaseForRequestAccessToken.tokens.access_token,
288
288
  },
289
+ mode: currentDatabaseForRequestAccessToken.oidcConfiguration.service_worker_convert_all_requests_to_cors ? "cors" : originalRequest.mode,
289
290
  });
290
291
  event.waitUntil(event.respondWith(fetch(newRequest)));
291
292
  return;
@@ -393,7 +394,7 @@ const checkDomain = (domains, endpoint) => {
393
394
  let testable = domain;
394
395
 
395
396
  if (typeof domain === 'string') {
396
- testable = new RegExp(`^${domain}`, 'gm');
397
+ testable = new RegExp(`^${domain}`);
397
398
  }
398
399
 
399
400
  return testable.test?.(endpoint);
@@ -12,6 +12,7 @@ export declare type OidcConfiguration = {
12
12
  token_request_timeout?: number;
13
13
  service_worker_relative_url?: string;
14
14
  service_worker_only?: boolean;
15
+ service_worker_convert_all_requests_to_cors?: boolean;
15
16
  extras?: StringMap;
16
17
  token_request_extras?: StringMap;
17
18
  storage?: Storage;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/oidc/vanilla/types.ts"],"names":[],"mappings":"AACA,oBAAY,iBAAiB,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAC,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAC,MAAM,CAAC;IACzB,oBAAoB,CAAC,EAAC,MAAM,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C,CAAC,EAAE,MAAM,CAAC;IACpD,uBAAuB,CAAC,EAAE,sBAAsB,CAAC;IACjD,+CAA+C,CAAC,EAAE,MAAM,CAAC;IACzD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,2BAA2B,CAAC,EAAC,MAAM,CAAC;IACpC,mBAAmB,CAAC,EAAC,OAAO,CAAC;IAC7B,MAAM,CAAC,EAAC,SAAS,CAAC;IAClB,oBAAoB,CAAC,EAAC,SAAS,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,WAAW,SAAS;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,sBAAsB;IACnC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,mBAAmB,EAAE,MAA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AAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB,CAAC,EAAC,MAAM,CAAC;IAC7B,MAAM,EAAC,MAAM,CAAC;CACjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/react-oidc",
3
- "version": "6.13.2",
3
+ "version": "6.13.4",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "jsnext:main": "dist/index.js",
@@ -217,7 +217,7 @@ const getCurrentDatabaseDomain = (database, url) => {
217
217
  let domain = domainsToSendTokens[i];
218
218
 
219
219
  if (typeof domain === 'string') {
220
- domain = new RegExp(`^${domain}`, 'gm');
220
+ domain = new RegExp(`^${domain}`);
221
221
  }
222
222
 
223
223
  if (domain.test?.(url)) {
@@ -286,6 +286,7 @@ const handleFetch = async (event) => {
286
286
  ...serializeHeaders(originalRequest.headers),
287
287
  authorization: 'Bearer ' + currentDatabaseForRequestAccessToken.tokens.access_token,
288
288
  },
289
+ mode: currentDatabaseForRequestAccessToken.oidcConfiguration.service_worker_convert_all_requests_to_cors ? "cors" : originalRequest.mode,
289
290
  });
290
291
  event.waitUntil(event.respondWith(fetch(newRequest)));
291
292
  return;
@@ -393,7 +394,7 @@ const checkDomain = (domains, endpoint) => {
393
394
  let testable = domain;
394
395
 
395
396
  if (typeof domain === 'string') {
396
- testable = new RegExp(`^${domain}`, 'gm');
397
+ testable = new RegExp(`^${domain}`);
397
398
  }
398
399
 
399
400
  return testable.test?.(endpoint);
@@ -13,6 +13,7 @@ export type OidcConfiguration = {
13
13
  token_request_timeout?: number;
14
14
  service_worker_relative_url?:string;
15
15
  service_worker_only?:boolean;
16
+ service_worker_convert_all_requests_to_cors?:boolean;
16
17
  extras?:StringMap;
17
18
  token_request_extras?:StringMap;
18
19
  storage?: Storage;