@axa-fr/oidc-client-service-worker 7.9.3-alpha.1132 → 7.9.3

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.
@@ -12,7 +12,14 @@ const TokenRenewMode = {
12
12
  id_token_invalid: "id_token_invalid"
13
13
  };
14
14
  const openidWellknownUrlEndWith = "/.well-known/openid-configuration";
15
- const version = "7.9.3-alpha.1132";
15
+ function normalizeUrl(url) {
16
+ try {
17
+ return new URL(url).toString();
18
+ } catch (error) {
19
+ console.error(`Failed to normalize url: ${url}`);
20
+ return url;
21
+ }
22
+ }
16
23
  function checkDomain(domains, endpoint) {
17
24
  if (!endpoint) {
18
25
  return;
@@ -49,10 +56,10 @@ const getCurrentDatabaseDomain = (database2, url, trustedDomains2) => {
49
56
  if (!oidcServerConfiguration) {
50
57
  continue;
51
58
  }
52
- if (oidcServerConfiguration.tokenEndpoint && normalizeUrl(url) === normalizeUrl(oidcServerConfiguration.tokenEndpoint)) {
59
+ if (oidcServerConfiguration.tokenEndpoint && url === normalizeUrl(oidcServerConfiguration.tokenEndpoint)) {
53
60
  continue;
54
61
  }
55
- if (oidcServerConfiguration.revocationEndpoint && normalizeUrl(url) === normalizeUrl(oidcServerConfiguration.revocationEndpoint)) {
62
+ if (oidcServerConfiguration.revocationEndpoint && url === normalizeUrl(oidcServerConfiguration.revocationEndpoint)) {
56
63
  continue;
57
64
  }
58
65
  const trustedDomain = trustedDomains2 == null ? [] : trustedDomains2[key];
@@ -82,55 +89,6 @@ const getCurrentDatabaseDomain = (database2, url, trustedDomains2) => {
82
89
  }
83
90
  return null;
84
91
  };
85
- function normalizeUrl(url) {
86
- url = url.trim();
87
- const hasRelativeProtocol = url.startsWith("//");
88
- const isRelativeUrl = !hasRelativeProtocol && /^\.*\//.test(url);
89
- if (!isRelativeUrl) {
90
- url = url.replace(/^(?!(?:\w+:)?\/\/)|^\/\//, "https:");
91
- }
92
- const urlObject = new URL(url);
93
- if (urlObject.pathname) {
94
- const protocolRegex = /\b[a-z][a-z\d+\-.]{1,50}:\/\//g;
95
- let lastIndex = 0;
96
- let result = "";
97
- for (; ; ) {
98
- const match = protocolRegex.exec(urlObject.pathname);
99
- if (!match) {
100
- break;
101
- }
102
- const protocol = match[0];
103
- const protocolAtIndex = match.index;
104
- const intermediate = urlObject.pathname.slice(lastIndex, protocolAtIndex);
105
- result += intermediate.replace(/\/{2,}/g, "/");
106
- result += protocol;
107
- lastIndex = protocolAtIndex + protocol.length;
108
- }
109
- const remnant = urlObject.pathname.slice(lastIndex, urlObject.pathname.length);
110
- result += remnant.replace(/\/{2,}/g, "/");
111
- urlObject.pathname = result;
112
- }
113
- if (urlObject.pathname) {
114
- try {
115
- urlObject.pathname = decodeURI(urlObject.pathname);
116
- } catch {
117
- }
118
- }
119
- if (urlObject.hostname) {
120
- urlObject.hostname = urlObject.hostname.replace(/\.$/, "");
121
- }
122
- urlObject.searchParams.sort();
123
- try {
124
- urlObject.search = decodeURIComponent(urlObject.search);
125
- } catch {
126
- }
127
- urlObject.pathname = urlObject.pathname.replace(/\/$/, "");
128
- url = urlObject.toString();
129
- if (urlObject.hash === "") {
130
- url = url.replace(/\/$/, "");
131
- }
132
- return url;
133
- }
134
92
  function serializeHeaders(headers) {
135
93
  const headersObj = {};
136
94
  for (const key of headers.keys()) {
@@ -301,6 +259,7 @@ function replaceCodeVerifier(codeVerifier, newCodeVerifier) {
301
259
  const regex = /code_verifier=[A-Za-z0-9_-]+/i;
302
260
  return codeVerifier.replace(regex, `code_verifier=${newCodeVerifier}`);
303
261
  }
262
+ const version = "7.9.3";
304
263
  if (typeof trustedTypes !== "undefined" && typeof trustedTypes.createPolicy == "function") {
305
264
  trustedTypes.createPolicy("default", {
306
265
  createScriptURL: function(url) {
@@ -329,9 +288,11 @@ const database = {};
329
288
  const getCurrentDatabasesTokenEndpoint = (database2, url) => {
330
289
  const databases = [];
331
290
  for (const [, value] of Object.entries(database2)) {
332
- if (value.oidcServerConfiguration != null && url.startsWith(value.oidcServerConfiguration.tokenEndpoint)) {
291
+ if (value.oidcServerConfiguration != null && url.startsWith(normalizeUrl(value.oidcServerConfiguration.tokenEndpoint))) {
333
292
  databases.push(value);
334
- } else if (value.oidcServerConfiguration != null && value.oidcServerConfiguration.revocationEndpoint && url.startsWith(value.oidcServerConfiguration.revocationEndpoint)) {
293
+ } else if (value.oidcServerConfiguration != null && value.oidcServerConfiguration.revocationEndpoint && url.startsWith(
294
+ normalizeUrl(value.oidcServerConfiguration.revocationEndpoint)
295
+ )) {
335
296
  databases.push(value);
336
297
  }
337
298
  }
@@ -355,14 +316,14 @@ const keepAliveAsync = async (event) => {
355
316
  };
356
317
  const handleFetch = async (event) => {
357
318
  const originalRequest = event.request;
358
- const url = originalRequest.url;
359
- if (originalRequest.url.includes(keepAliveJsonFilename)) {
319
+ const url = normalizeUrl(originalRequest.url);
320
+ if (url.includes(keepAliveJsonFilename)) {
360
321
  event.respondWith(keepAliveAsync(event));
361
322
  return;
362
323
  }
363
324
  const currentDatabaseForRequestAccessToken = getCurrentDatabaseDomain(
364
325
  database,
365
- originalRequest.url,
326
+ url,
366
327
  trustedDomains
367
328
  );
368
329
  if (currentDatabaseForRequestAccessToken && currentDatabaseForRequestAccessToken.tokens && currentDatabaseForRequestAccessToken.tokens.access_token) {
@@ -403,10 +364,7 @@ const handleFetch = async (event) => {
403
364
  return;
404
365
  }
405
366
  let currentDatabase = null;
406
- const currentDatabases = getCurrentDatabasesTokenEndpoint(
407
- database,
408
- originalRequest.url
409
- );
367
+ const currentDatabases = getCurrentDatabasesTokenEndpoint(database, url);
410
368
  const numberDatabase = currentDatabases.length;
411
369
  if (numberDatabase > 0) {
412
370
  const maPromesse = new Promise((resolve, reject) => {
@@ -451,7 +409,9 @@ const handleFetch = async (event) => {
451
409
  integrity: clonedRequest.integrity
452
410
  });
453
411
  if (currentDatabase && currentDatabase.oidcServerConfiguration != null && currentDatabase.oidcServerConfiguration.revocationEndpoint && url.startsWith(
454
- currentDatabase.oidcServerConfiguration.revocationEndpoint
412
+ normalizeUrl(
413
+ currentDatabase.oidcServerConfiguration.revocationEndpoint
414
+ )
455
415
  )) {
456
416
  return fetchPromise.then(async (response2) => {
457
417
  const text = await response2.text();
@@ -464,7 +424,10 @@ const handleFetch = async (event) => {
464
424
  currentLoginCallbackConfigurationName = null;
465
425
  let newBody = actualBody;
466
426
  if (currentDatabase && currentDatabase.codeVerifier != null) {
467
- newBody = replaceCodeVerifier(newBody, currentDatabase.codeVerifier);
427
+ newBody = replaceCodeVerifier(
428
+ newBody,
429
+ currentDatabase.codeVerifier
430
+ );
468
431
  }
469
432
  return fetch(originalRequest, {
470
433
  body: newBody,
@@ -552,7 +515,7 @@ const handleMessage = (event) => {
552
515
  const oidcServerConfiguration = data.data.oidcServerConfiguration;
553
516
  const trustedDomain = trustedDomains[configurationName];
554
517
  const domains = getDomains(trustedDomain, "oidc");
555
- if (!domains.find((f) => f === acceptAnyDomainToken)) {
518
+ if (!domains.some((domain) => domain === acceptAnyDomainToken)) {
556
519
  [
557
520
  oidcServerConfiguration.tokenEndpoint,
558
521
  oidcServerConfiguration.revocationEndpoint,
@@ -599,35 +562,47 @@ const handleMessage = (event) => {
599
562
  }
600
563
  return;
601
564
  }
602
- case "setDemonstratingProofOfPossessionNonce":
565
+ case "setDemonstratingProofOfPossessionNonce": {
603
566
  currentDatabase.demonstratingProofOfPossessionNonce = data.data.demonstratingProofOfPossessionNonce;
604
567
  port.postMessage({ configurationName });
605
568
  return;
606
- case "getDemonstratingProofOfPossessionNonce":
569
+ }
570
+ case "getDemonstratingProofOfPossessionNonce": {
607
571
  const demonstratingProofOfPossessionNonce = currentDatabase.demonstratingProofOfPossessionNonce;
608
- port.postMessage({ configurationName, demonstratingProofOfPossessionNonce });
572
+ port.postMessage({
573
+ configurationName,
574
+ demonstratingProofOfPossessionNonce
575
+ });
609
576
  return;
610
- case "setDemonstratingProofOfPossessionJwk":
577
+ }
578
+ case "setDemonstratingProofOfPossessionJwk": {
611
579
  currentDatabase.demonstratingProofOfPossessionJwkJson = data.data.demonstratingProofOfPossessionJwkJson;
612
580
  port.postMessage({ configurationName });
613
581
  return;
614
- case "getDemonstratingProofOfPossessionJwk":
582
+ }
583
+ case "getDemonstratingProofOfPossessionJwk": {
615
584
  const demonstratingProofOfPossessionJwkJson = currentDatabase.demonstratingProofOfPossessionJwkJson;
616
- port.postMessage({ configurationName, demonstratingProofOfPossessionJwkJson });
585
+ port.postMessage({
586
+ configurationName,
587
+ demonstratingProofOfPossessionJwkJson
588
+ });
617
589
  return;
618
- case "setState":
590
+ }
591
+ case "setState": {
619
592
  currentDatabase.state = data.data.state;
620
593
  port.postMessage({ configurationName });
621
594
  return;
595
+ }
622
596
  case "getState": {
623
597
  const state = currentDatabase.state;
624
598
  port.postMessage({ configurationName, state });
625
599
  return;
626
600
  }
627
- case "setCodeVerifier":
601
+ case "setCodeVerifier": {
628
602
  currentDatabase.codeVerifier = data.data.codeVerifier;
629
603
  port.postMessage({ configurationName });
630
604
  return;
605
+ }
631
606
  case "getCodeVerifier": {
632
607
  port.postMessage({
633
608
  configurationName,
@@ -635,10 +610,11 @@ const handleMessage = (event) => {
635
610
  });
636
611
  return;
637
612
  }
638
- case "setSessionState":
613
+ case "setSessionState": {
639
614
  currentDatabase.sessionState = data.data.sessionState;
640
615
  port.postMessage({ configurationName });
641
616
  return;
617
+ }
642
618
  case "getSessionState": {
643
619
  const sessionState = currentDatabase.sessionState;
644
620
  port.postMessage({ configurationName, sessionState });
@@ -658,9 +634,10 @@ const handleMessage = (event) => {
658
634
  port.postMessage({ configurationName, nonce });
659
635
  return;
660
636
  }
661
- default:
637
+ default: {
662
638
  currentDatabase.items = { ...data.data };
663
639
  port.postMessage({ configurationName });
640
+ }
664
641
  }
665
642
  };
666
643
  _self.addEventListener("install", handleInstall);
@@ -1 +1 @@
1
- {"version":3,"file":"OidcServiceWorker.js","sources":["../src/constants.ts","../src/version.ts","../src/utils/domains.ts","../src/utils/serializeHeaders.ts","../src/utils/sleep.ts","../src/utils/strings.ts","../src/utils/tokens.ts","../src/utils/codeVerifier.ts","../src/OidcServiceWorker.ts"],"sourcesContent":["const scriptFilename = 'OidcTrustedDomains.js';\nconst acceptAnyDomainToken = '*';\n\ntype TokenType = {\n readonly REFRESH_TOKEN: string;\n readonly ACCESS_TOKEN: string;\n readonly NONCE_TOKEN: string;\n readonly CODE_VERIFIER: string;\n};\n\nconst TOKEN: TokenType = {\n REFRESH_TOKEN: 'REFRESH_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER',\n ACCESS_TOKEN: 'ACCESS_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER',\n NONCE_TOKEN: 'NONCE_SECURED_BY_OIDC_SERVICE_WORKER',\n CODE_VERIFIER: 'CODE_VERIFIER_SECURED_BY_OIDC_SERVICE_WORKER',\n};\n\ntype TokenRenewModeType = {\n readonly access_token_or_id_token_invalid: string;\n readonly access_token_invalid: string;\n readonly id_token_invalid: string;\n};\n\nconst TokenRenewMode: TokenRenewModeType = {\n access_token_or_id_token_invalid: 'access_token_or_id_token_invalid',\n access_token_invalid: 'access_token_invalid',\n id_token_invalid: 'id_token_invalid',\n};\n\nconst openidWellknownUrlEndWith = '/.well-known/openid-configuration';\n\nexport { acceptAnyDomainToken, openidWellknownUrlEndWith, scriptFilename, TOKEN, TokenRenewMode };\n","export default '7.9.3-alpha.1132';\n","import { acceptAnyDomainToken, openidWellknownUrlEndWith, scriptFilename } from '../constants';\nimport { Database, Domain, DomainDetails, OidcConfig, TrustedDomains } from '../types';\n\nexport function checkDomain(domains: Domain[], endpoint: string) {\n\tif (!endpoint) {\n\t\treturn;\n\t}\n\n\tconst domain = domains.find((domain) => {\n\t\tlet testable: RegExp;\n\n\t\tif (typeof domain === 'string') {\n\t\t\ttestable = new RegExp(`^${domain}`);\n\t\t} else {\n\t\t\ttestable = domain;\n\t\t}\n\n\t\treturn testable.test?.(endpoint);\n\t});\n\tif (!domain) {\n\t\tthrow new Error(\n\t\t\t'Domain ' + endpoint + ' is not trusted, please add domain in ' + scriptFilename,\n\t\t);\n\t}\n}\n\nexport const getDomains = (\n\ttrustedDomain: Domain[] | DomainDetails,\n\ttype: 'oidc' | 'accessToken',\n) => {\n\tif (Array.isArray(trustedDomain)) {\n\t\treturn trustedDomain;\n\t}\n\n\treturn trustedDomain[`${type}Domains`] ?? trustedDomain.domains ?? [];\n};\n\nexport const getCurrentDatabaseDomain = (\n\tdatabase: Database,\n\turl: string,\n\ttrustedDomains: TrustedDomains,\n) => {\n\tif (url.endsWith(openidWellknownUrlEndWith)) {\n\t\treturn null;\n\t}\n\tfor (const [key, currentDatabase] of Object.entries<OidcConfig>(database)) {\n\t\tconst oidcServerConfiguration = currentDatabase.oidcServerConfiguration;\n\n\t\tif (!oidcServerConfiguration) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (\n\t\t\toidcServerConfiguration.tokenEndpoint &&\n\t\t\tnormalizeUrl(url) === normalizeUrl(oidcServerConfiguration.tokenEndpoint)\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\toidcServerConfiguration.revocationEndpoint &&\n\t\t\tnormalizeUrl(url) === normalizeUrl(oidcServerConfiguration.revocationEndpoint)\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst trustedDomain = trustedDomains == null ? [] : trustedDomains[key];\n\n\t\tconst domains = getDomains(trustedDomain, 'accessToken');\n\t\tconst domainsToSendTokens = oidcServerConfiguration.userInfoEndpoint\n\t\t\t? [oidcServerConfiguration.userInfoEndpoint, ...domains]\n\t\t\t: [...domains];\n\n\t\tlet hasToSendToken = false;\n\t\tif (domainsToSendTokens.find((f) => f === acceptAnyDomainToken)) {\n\t\t\thasToSendToken = true;\n\t\t} else {\n\t\t\tfor (let i = 0; i < domainsToSendTokens.length; i++) {\n\t\t\t\tlet domain = domainsToSendTokens[i];\n\n\t\t\t\tif (typeof domain === 'string') {\n\t\t\t\t\tdomain = new RegExp(`^${domain}`);\n\t\t\t\t}\n\n\t\t\t\tif (domain.test?.(url)) {\n\t\t\t\t\thasToSendToken = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (hasToSendToken) {\n\t\t\tif (!currentDatabase.tokens) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn currentDatabase;\n\t\t}\n\t}\n\treturn null;\n};\n\nexport function normalizeUrl(url: string) {\n\turl = url.trim();\n\n\tconst hasRelativeProtocol = url.startsWith('//');\n\tconst isRelativeUrl = !hasRelativeProtocol && /^\\.*\\//.test(url);\n\n\t// Prepend protocol\n\tif (!isRelativeUrl) {\n\t\turl = url.replace(/^(?!(?:\\w+:)?\\/\\/)|^\\/\\//, 'https:');\n\t}\n\n\tconst urlObject = new URL(url);\n\n\t// Remove duplicate slashes if not preceded by a protocol\n\t// NOTE: This could be implemented using a single negative lookbehind\n\t// regex, but we avoid that to maintain compatibility with older js engines\n\t// which do not have support for that feature.\n\tif (urlObject.pathname) {\n\t\t// Split the string by occurrences of this protocol regex, and perform\n\t\t// duplicate-slash replacement on the strings between those occurrences\n\t\t// (if any).\n\t\tconst protocolRegex = /\\b[a-z][a-z\\d+\\-.]{1,50}:\\/\\//g;\n\n\t\tlet lastIndex = 0;\n\t\tlet result = '';\n\t\tfor (;;) {\n\t\t\tconst match = protocolRegex.exec(urlObject.pathname);\n\t\t\tif (!match) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst protocol = match[0];\n\t\t\tconst protocolAtIndex = match.index;\n\t\t\tconst intermediate = urlObject.pathname.slice(lastIndex, protocolAtIndex);\n\n\t\t\tresult += intermediate.replace(/\\/{2,}/g, '/');\n\t\t\tresult += protocol;\n\t\t\tlastIndex = protocolAtIndex + protocol.length;\n\t\t}\n\n\t\tconst remnant = urlObject.pathname.slice(lastIndex, urlObject.pathname.length);\n\t\tresult += remnant.replace(/\\/{2,}/g, '/');\n\n\t\turlObject.pathname = result;\n\t}\n\n\t// Decode URI octets\n\tif (urlObject.pathname) {\n\t\ttry {\n\t\t\turlObject.pathname = decodeURI(urlObject.pathname);\n\t\t} catch {\n\t\t\t/* empty */\n\t\t}\n\t}\n\n\tif (urlObject.hostname) {\n\t\t// Remove trailing dot\n\t\turlObject.hostname = urlObject.hostname.replace(/\\.$/, '');\n\t}\n\n\t// Sort query parameters\n\turlObject.searchParams.sort();\n\n\t// Calling `.sort()` encodes the search parameters, so we need to decode them again.\n\ttry {\n\t\turlObject.search = decodeURIComponent(urlObject.search);\n\t} catch {\n\t\t/* empty */\n\t}\n\n\t// Remove trailing slash\n\turlObject.pathname = urlObject.pathname.replace(/\\/$/, '');\n\n\t// Take advantage of many of the Node `url` normalizations\n\turl = urlObject.toString();\n\n\t// Remove ending `/` unless removeSingleSlash is false\n\tif (urlObject.hash === '') {\n\t\turl = url.replace(/\\/$/, '');\n\t}\n\n\treturn url;\n}\n","import { FetchHeaders } from '../types';\n\nfunction serializeHeaders(headers: Headers) {\n const headersObj: Record<string, string> = {};\n for (const key of (headers as FetchHeaders).keys()) {\n if (headers.has(key)) {\n headersObj[key] = headers.get(key) as string;\n }\n }\n return headersObj;\n}\nexport { serializeHeaders };\n","const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\nexport { sleep };\n","/**\n * Count occurances of letter in string\n * @param str\n * @param find\n * @returns\n */\nexport function countLetter(str: string, find: string) {\n return str.split(find).length - 1;\n}\n","/* eslint-disable simple-import-sort/exports */\nimport { TOKEN, TokenRenewMode } from '../constants';\nimport {\n AccessTokenPayload,\n IdTokenPayload,\n OidcConfig,\n OidcConfiguration,\n OidcServerConfiguration,\n Tokens\n} from '../types';\nimport { countLetter } from './strings';\n\nfunction parseJwt(token: string) {\n return JSON.parse(\n b64DecodeUnicode(token.split('.')[1].replace('-', '+').replace('_', '/')),\n );\n}\nfunction b64DecodeUnicode(str: string) {\n return decodeURIComponent(\n Array.prototype.map\n .call(\n atob(str),\n (c) => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2),\n )\n .join(''),\n );\n}\n\nfunction computeTimeLeft(\n refreshTimeBeforeTokensExpirationInSecond: number,\n expiresAt: number,\n) {\n const currentTimeUnixSecond = new Date().getTime() / 1000;\n return Math.round(\n expiresAt -\n refreshTimeBeforeTokensExpirationInSecond -\n currentTimeUnixSecond,\n );\n}\n\nfunction isTokensValid(tokens: Tokens | null) {\n if (!tokens) {\n return false;\n }\n return computeTimeLeft(0, tokens.expiresAt) > 0;\n}\n\nconst extractTokenPayload = (token?: string) => {\n try {\n if (!token) {\n return null;\n }\n if (countLetter(token, '.') === 2) {\n return parseJwt(token);\n } else {\n return null;\n }\n } catch (e) {\n console.warn(e);\n }\n return null;\n};\n\n// https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation (excluding rules #1, #4, #5, #7, #8, #12, and #13 which did not apply).\n// https://github.com/openid/AppAuth-JS/issues/65\nconst isTokensOidcValid = (\n tokens: Tokens,\n nonce: string | null,\n oidcServerConfiguration: OidcServerConfiguration,\n): { isValid: boolean; reason: string } => {\n if (tokens.idTokenPayload) {\n const idTokenPayload = tokens.idTokenPayload;\n // 2: The Issuer Identifier for the OpenID Provider (which is typically obtained during Discovery) MUST exactly match the value of the iss (issuer) Claim.\n if (oidcServerConfiguration.issuer !== idTokenPayload.iss) {\n return { isValid: false, reason: `Issuer does not match (oidcServerConfiguration issuer) ${oidcServerConfiguration.issuer} !== (idTokenPayload issuer) ${idTokenPayload.iss}` };\n }\n // 3: The Client MUST validate that the aud (audience) Claim contains its client_id value registered at the Issuer identified by the iss (issuer) Claim as an audience. The aud (audience) Claim MAY contain an array with more than one element. The ID Token MUST be rejected if the ID Token does not list the Client as a valid audience, or if it contains additional audiences not trusted by the Client.\n\n // 6: If the ID Token is received via direct communication between the Client and the Token Endpoint (which it is in this flow), the TLS server validation MAY be used to validate the issuer in place of checking the token signature. The Client MUST validate the signature of all other ID Tokens according to JWS [JWS] using the algorithm specified in the JWT alg Header Parameter. The Client MUST use the keys provided by the Issuer.\n\n // 9: The current time MUST be before the time represented by the exp Claim.\n const currentTimeUnixSecond = new Date().getTime() / 1000;\n if (idTokenPayload.exp && idTokenPayload.exp < currentTimeUnixSecond) {\n return { isValid: false, reason: `Token expired at (idTokenPayload exp) ${idTokenPayload.exp} < (currentTimeUnixSecond) ${currentTimeUnixSecond}` };\n }\n // 10: The iat Claim can be used to reject tokens that were issued too far away from the current time, limiting the amount of time that nonces need to be stored to prevent attacks. The acceptable range is Client specific.\n const timeInSevenDays = 60 * 60 * 24 * 7;\n if (\n idTokenPayload.iat &&\n idTokenPayload.iat + timeInSevenDays < currentTimeUnixSecond\n ) {\n return { isValid: false, reason: `Token is used from too long time (idTokenPayload iat + timeInSevenDays) ${idTokenPayload.iat + timeInSevenDays} < (currentTimeUnixSecond) ${currentTimeUnixSecond}` };\n }\n // 11: If a nonce value was sent in the Authentication Request, a nonce Claim MUST be present and its value checked to verify that it is the same value as the one that was sent in the Authentication Request. The Client SHOULD check the nonce value for replay attacks. The precise method for detecting replay attacks is Client specific.\n if (nonce && idTokenPayload.nonce && idTokenPayload.nonce !== nonce) {\n return { isValid: false, reason: `Nonce does not match (nonce) ${nonce} !== (idTokenPayload nonce) ${idTokenPayload.nonce}` };\n }\n }\n return { isValid: true, reason: '' };\n};\n\nfunction extractedIssueAt(tokens: Tokens, accessTokenPayload: AccessTokenPayload | null, _idTokenPayload : IdTokenPayload) {\n if (!tokens.issued_at) {\n if (accessTokenPayload && accessTokenPayload.iat) {\n return accessTokenPayload.iat;\n } else if (_idTokenPayload && _idTokenPayload.iat) {\n return _idTokenPayload.iat;\n } else {\n const currentTimeUnixSecond = new Date().getTime() / 1000;\n return currentTimeUnixSecond;\n }\n } else if (typeof tokens.issued_at == \"string\") {\n return parseInt(tokens.issued_at, 10);\n }\n return tokens.issued_at;\n}\n\nfunction _hideTokens(tokens: Tokens, currentDatabaseElement: OidcConfig, configurationName: string) {\n if (!tokens.issued_at) {\n const currentTimeUnixSecond = new Date().getTime() / 1000;\n tokens.issued_at = currentTimeUnixSecond;\n } else if (typeof tokens.issued_at == \"string\") {\n tokens.issued_at = parseInt(tokens.issued_at, 10);\n }\n\n const accessTokenPayload = extractTokenPayload(tokens.access_token);\n const secureTokens = {\n ...tokens,\n accessTokenPayload,\n };\n if (currentDatabaseElement.hideAccessToken) {\n secureTokens.access_token = TOKEN.ACCESS_TOKEN + '_' + configurationName;\n }\n tokens.accessTokenPayload = accessTokenPayload;\n\n let _idTokenPayload = null;\n if (tokens.id_token) {\n _idTokenPayload = extractTokenPayload(tokens.id_token);\n tokens.idTokenPayload = { ..._idTokenPayload };\n if (_idTokenPayload.nonce && currentDatabaseElement.nonce != null) {\n const keyNonce =\n TOKEN.NONCE_TOKEN + '_' + currentDatabaseElement.configurationName;\n _idTokenPayload.nonce = keyNonce;\n }\n secureTokens.idTokenPayload = _idTokenPayload;\n }\n if (tokens.refresh_token) {\n secureTokens.refresh_token =\n TOKEN.REFRESH_TOKEN + '_' + configurationName;\n }\n\n tokens.issued_at = extractedIssueAt(tokens, accessTokenPayload, _idTokenPayload);\n\n const expireIn = typeof tokens.expires_in == \"string\" ? parseInt(tokens.expires_in, 10) : tokens.expires_in;\n\n const idTokenExpiresAt =\n _idTokenPayload && _idTokenPayload.exp\n ? _idTokenPayload.exp\n : Number.MAX_VALUE;\n const accessTokenExpiresAt =\n accessTokenPayload && accessTokenPayload.exp\n ? accessTokenPayload.exp\n : tokens.issued_at + expireIn;\n\n let expiresAt: number;\n const tokenRenewMode = (\n currentDatabaseElement.oidcConfiguration as OidcConfiguration\n ).token_renew_mode;\n if (tokenRenewMode === TokenRenewMode.access_token_invalid) {\n expiresAt = accessTokenExpiresAt;\n } else if (tokenRenewMode === TokenRenewMode.id_token_invalid) {\n expiresAt = idTokenExpiresAt;\n } else {\n expiresAt =\n idTokenExpiresAt < accessTokenExpiresAt\n ? idTokenExpiresAt\n : accessTokenExpiresAt;\n }\n secureTokens.expiresAt = expiresAt;\n\n tokens.expiresAt = expiresAt;\n const nonce = currentDatabaseElement.nonce\n ? currentDatabaseElement.nonce.nonce\n : null;\n const { isValid, reason } = isTokensOidcValid(\n tokens,\n nonce,\n currentDatabaseElement.oidcServerConfiguration as OidcServerConfiguration,\n ); // TODO: Type assertion, could be null.\n if (!isValid) {\n throw Error(`Tokens are not OpenID valid, reason: ${reason}`);\n }\n\n // When refresh_token is not rotated we reuse ald refresh_token\n if (\n currentDatabaseElement.tokens != null &&\n 'refresh_token' in currentDatabaseElement.tokens &&\n !('refresh_token' in tokens)\n ) {\n const refreshToken = currentDatabaseElement.tokens.refresh_token;\n\n currentDatabaseElement.tokens = {\n ...tokens,\n refresh_token: refreshToken,\n };\n } else {\n currentDatabaseElement.tokens = tokens;\n }\n\n currentDatabaseElement.status = 'LOGGED_IN';\n return secureTokens;\n}\n\nfunction hideTokens(currentDatabaseElement: OidcConfig) {\n const configurationName = currentDatabaseElement.configurationName;\n return (response: Response) => {\n if (response.status !== 200) {\n return response;\n }\n return response.json().then<Response>((tokens: Tokens) => {\n const secureTokens = _hideTokens(tokens, currentDatabaseElement, configurationName);\n const body = JSON.stringify(secureTokens);\n return new Response(body, response);\n });\n };\n}\n\nexport {\n b64DecodeUnicode,\n computeTimeLeft,\n isTokensValid,\n extractTokenPayload,\n isTokensOidcValid,\n hideTokens,\n _hideTokens,\n};\n","export function replaceCodeVerifier(codeVerifier:string, newCodeVerifier:string):string {\n const regex = /code_verifier=[A-Za-z0-9_-]+/i;\n return codeVerifier.replace(regex, `code_verifier=${newCodeVerifier}`);\n}\n","import { acceptAnyDomainToken, scriptFilename, TOKEN } from './constants';\nimport version from './version';\nimport {\n Database,\n MessageEventData,\n OidcConfig,\n TrustedDomains,\n} from './types';\nimport {\n checkDomain,\n getCurrentDatabaseDomain,\n getDomains,\n hideTokens,\n isTokensValid,\n serializeHeaders,\n sleep,\n} from './utils';\nimport { replaceCodeVerifier } from './utils/codeVerifier';\n\n// @ts-ignore\nif ((typeof trustedTypes !== 'undefined') && (typeof trustedTypes.createPolicy == 'function')) {\n // @ts-ignore\n trustedTypes.createPolicy('default', {\n createScriptURL: function(url: string) {\n if (url == scriptFilename) {\n return url;\n } else {\n throw new Error('Untrusted script URL blocked: ' + url);\n }\n },\n });\n}\n\nconst _self = self as ServiceWorkerGlobalScope & typeof globalThis;\n\ndeclare let trustedDomains: TrustedDomains;\n\n_self.importScripts(scriptFilename);\n\nconst id = Math.round(new Date().getTime() / 1000).toString();\n\nconst keepAliveJsonFilename = 'OidcKeepAliveServiceWorker.json';\nconst handleInstall = (event: ExtendableEvent) => {\n console.log('[OidcServiceWorker] service worker installed ' + id);\n event.waitUntil(_self.skipWaiting());\n};\n\nconst handleActivate = (event: ExtendableEvent) => {\n console.log('[OidcServiceWorker] service worker activated ' + id);\n event.waitUntil(_self.clients.claim());\n};\n\nlet currentLoginCallbackConfigurationName: string | null = null;\nconst database: Database = {};\n\nconst getCurrentDatabasesTokenEndpoint = (database: Database, url: string) => {\n const databases: OidcConfig[] = [];\n for (const [, value] of Object.entries<OidcConfig>(database)) {\n if (\n value.oidcServerConfiguration != null &&\n url.startsWith(value.oidcServerConfiguration.tokenEndpoint)\n ) {\n databases.push(value);\n } else if (\n value.oidcServerConfiguration != null &&\n value.oidcServerConfiguration.revocationEndpoint &&\n url.startsWith(value.oidcServerConfiguration.revocationEndpoint)\n ) {\n databases.push(value);\n }\n }\n return databases;\n};\n\nconst keepAliveAsync = async (event: FetchEvent) => {\n const originalRequest = event.request;\n const isFromVanilla = originalRequest.headers.has('oidc-vanilla');\n const init = { status: 200, statusText: 'oidc-service-worker' };\n const response = new Response('{}', init);\n if (!isFromVanilla) {\n const originalRequestUrl = new URL(originalRequest.url);\n const minSleepSeconds = Number(originalRequestUrl.searchParams.get('minSleepSeconds')) || 240;\n for (let i = 0; i < minSleepSeconds; i++) {\n await sleep(1000 + Math.floor(Math.random() * 1000));\n const cache = await caches.open('oidc_dummy_cache');\n await cache.put(event.request, response.clone());\n }\n }\n return response;\n};\n\nconst handleFetch = async (event: FetchEvent) => {\n const originalRequest = event.request;\n const url = originalRequest.url;\n if (originalRequest.url.includes(keepAliveJsonFilename)) {\n event.respondWith(keepAliveAsync(event));\n return;\n }\n\n const currentDatabaseForRequestAccessToken = getCurrentDatabaseDomain(\n database,\n originalRequest.url,\n trustedDomains,\n );\n if (\n currentDatabaseForRequestAccessToken &&\n currentDatabaseForRequestAccessToken.tokens &&\n currentDatabaseForRequestAccessToken.tokens.access_token\n ) {\n while (\n currentDatabaseForRequestAccessToken.tokens &&\n !isTokensValid(currentDatabaseForRequestAccessToken.tokens)\n ) {\n await sleep(200);\n }\n \n let requestMode = originalRequest.mode;\n \n if(originalRequest.mode !== \"navigate\" && currentDatabaseForRequestAccessToken.convertAllRequestsToCorsExceptNavigate) {\n requestMode = \"cors\";\n } \n \n let headers: { [p: string]: string };\n if(originalRequest.mode == \"navigate\" && !currentDatabaseForRequestAccessToken.setAccessTokenToNavigateRequests ) {\n headers = {\n ...serializeHeaders(originalRequest.headers),\n }\n } else{\n headers = {\n ...serializeHeaders(originalRequest.headers),\n authorization: 'Bearer ' + currentDatabaseForRequestAccessToken.tokens.access_token,\n }\n }\n let init: RequestInit;\n if(originalRequest.mode === \"navigate\"){\n init = {\n headers: headers,\n }\n } else{\n init = {\n headers: headers,\n mode: requestMode,\n }\n }\n \n const newRequest = new Request(originalRequest, init);\n\n event.respondWith(fetch(newRequest));\n\n return;\n }\n\n if (event.request.method !== 'POST') {\n return;\n }\n\n let currentDatabase: OidcConfig | null = null;\n const currentDatabases = getCurrentDatabasesTokenEndpoint(\n database,\n originalRequest.url,\n );\n const numberDatabase = currentDatabases.length;\n if (numberDatabase > 0) {\n const maPromesse = new Promise<Response>((resolve, reject) => {\n const clonedRequest = originalRequest.clone();\n const response = clonedRequest.text().then((actualBody) => {\n if (\n actualBody.includes(TOKEN.REFRESH_TOKEN) ||\n actualBody.includes(TOKEN.ACCESS_TOKEN)\n ) {\n let newBody = actualBody;\n for (let i = 0; i < numberDatabase; i++) {\n const currentDb = currentDatabases[i];\n\n if (currentDb && currentDb.tokens != null) {\n const keyRefreshToken =\n TOKEN.REFRESH_TOKEN + '_' + currentDb.configurationName;\n if (actualBody.includes(keyRefreshToken)) {\n newBody = newBody.replace(\n keyRefreshToken,\n encodeURIComponent(currentDb.tokens.refresh_token as string),\n );\n currentDatabase = currentDb;\n break;\n }\n const keyAccessToken =\n TOKEN.ACCESS_TOKEN + '_' + currentDb.configurationName;\n if (actualBody.includes(keyAccessToken)) {\n newBody = newBody.replace(\n keyAccessToken,\n encodeURIComponent(currentDb.tokens.access_token),\n );\n currentDatabase = currentDb;\n break;\n }\n }\n }\n const fetchPromise = fetch(originalRequest, {\n body: newBody,\n method: clonedRequest.method,\n headers: {\n ...serializeHeaders(originalRequest.headers),\n },\n mode: clonedRequest.mode,\n cache: clonedRequest.cache,\n redirect: clonedRequest.redirect,\n referrer: clonedRequest.referrer,\n credentials: clonedRequest.credentials,\n integrity: clonedRequest.integrity,\n });\n\n if (\n currentDatabase &&\n currentDatabase.oidcServerConfiguration != null &&\n currentDatabase.oidcServerConfiguration.revocationEndpoint &&\n url.startsWith(\n currentDatabase.oidcServerConfiguration.revocationEndpoint,\n )\n ) {\n return fetchPromise.then(async (response) => {\n const text = await response.text();\n return new Response(text, response);\n });\n }\n return fetchPromise.then(hideTokens(currentDatabase as OidcConfig)); // todo type assertion to OidcConfig but could be null, NEEDS REVIEW\n } else if (\n actualBody.includes('code_verifier=') &&\n currentLoginCallbackConfigurationName\n ) {\n currentDatabase = database[currentLoginCallbackConfigurationName];\n currentLoginCallbackConfigurationName = null;\n let newBody = actualBody;\n if (currentDatabase && currentDatabase.codeVerifier != null) {\n newBody = replaceCodeVerifier(newBody, currentDatabase.codeVerifier);\n }\n\n return fetch(originalRequest, {\n body: newBody,\n method: clonedRequest.method,\n headers: {\n ...serializeHeaders(originalRequest.headers),\n },\n mode: clonedRequest.mode,\n cache: clonedRequest.cache,\n redirect: clonedRequest.redirect,\n referrer: clonedRequest.referrer,\n credentials: clonedRequest.credentials,\n integrity: clonedRequest.integrity,\n }).then(hideTokens(currentDatabase));\n }\n\n // if showAccessToken=true, the token is already in the body\n // of the request, and it does not need to be injected\n // and we can simply clone the request\n return fetch(originalRequest, {\n body: actualBody,\n method: clonedRequest.method,\n headers: {\n ...serializeHeaders(originalRequest.headers),\n },\n mode: clonedRequest.mode,\n cache: clonedRequest.cache,\n redirect: clonedRequest.redirect,\n referrer: clonedRequest.referrer,\n credentials: clonedRequest.credentials,\n integrity: clonedRequest.integrity,\n });\n });\n response\n .then((r) => {\n resolve(r);\n })\n .catch((err) => {\n reject(err);\n });\n });\n\n event.respondWith(maPromesse);\n }\n};\n\n\nconst handleMessage = (event: ExtendableMessageEvent) => {\n const port = event.ports[0];\n const data = event.data as MessageEventData;\n if (event.data.type === \"claim\") {\n _self.clients.claim().then(() => port.postMessage({}));\n return;\n }\n const configurationName = data.configurationName;\n let currentDatabase = database[configurationName];\n if (trustedDomains == null) {\n trustedDomains = {};\n }\n if (!currentDatabase) {\n const trustedDomain = trustedDomains[configurationName];\n const showAccessToken = Array.isArray(trustedDomain) ? false : trustedDomain.showAccessToken;\n const doNotSetAccessTokenToNavigateRequests = Array.isArray(trustedDomain) ? true : trustedDomain.setAccessTokenToNavigateRequests;\n const convertAllRequestsToCorsExceptNavigate = Array.isArray(trustedDomain) ? false : trustedDomain.convertAllRequestsToCorsExceptNavigate;\n database[configurationName] = {\n tokens: null,\n state: null,\n codeVerifier: null,\n oidcServerConfiguration: null,\n oidcConfiguration: undefined,\n nonce: null,\n status: null,\n configurationName,\n hideAccessToken: !showAccessToken,\n setAccessTokenToNavigateRequests: doNotSetAccessTokenToNavigateRequests ?? true,\n convertAllRequestsToCorsExceptNavigate: convertAllRequestsToCorsExceptNavigate ?? false,\n demonstratingProofOfPossessionNonce: null,\n demonstratingProofOfPossessionJwkJson: null,\n };\n currentDatabase = database[configurationName];\n\n if (!trustedDomains[configurationName]) {\n trustedDomains[configurationName] = [];\n }\n }\n\n switch (data.type) {\n case 'clear':\n currentDatabase.tokens = null;\n currentDatabase.state = null;\n currentDatabase.codeVerifier = null;\n currentDatabase.status = data.data.status;\n port.postMessage({ configurationName });\n return;\n case 'init': {\n const oidcServerConfiguration = data.data.oidcServerConfiguration;\n const trustedDomain = trustedDomains[configurationName];\n const domains = getDomains(trustedDomain, 'oidc');\n if (!domains.find((f) => f === acceptAnyDomainToken)) {\n [\n oidcServerConfiguration.tokenEndpoint,\n oidcServerConfiguration.revocationEndpoint,\n oidcServerConfiguration.userInfoEndpoint,\n oidcServerConfiguration.issuer,\n ].forEach((url) => {\n checkDomain(domains, url);\n });\n }\n currentDatabase.oidcServerConfiguration = oidcServerConfiguration;\n currentDatabase.oidcConfiguration = data.data.oidcConfiguration;\n const where = data.data.where;\n if (\n where === 'loginCallbackAsync' ||\n where === 'tryKeepExistingSessionAsync'\n ) {\n currentLoginCallbackConfigurationName = configurationName;\n } else {\n currentLoginCallbackConfigurationName = null;\n }\n\n if (!currentDatabase.tokens) {\n port.postMessage({\n tokens: null,\n status: currentDatabase.status,\n configurationName,\n version\n });\n } else {\n const tokens = {\n ...currentDatabase.tokens,\n };\n if (currentDatabase.hideAccessToken) {\n tokens.access_token = TOKEN.ACCESS_TOKEN + '_' + configurationName;\n }\n if (tokens.refresh_token) {\n tokens.refresh_token = TOKEN.REFRESH_TOKEN + '_' + configurationName;\n }\n if (\n tokens.idTokenPayload &&\n tokens.idTokenPayload.nonce &&\n currentDatabase.nonce != null\n ) {\n tokens.idTokenPayload.nonce =\n TOKEN.NONCE_TOKEN + '_' + configurationName;\n }\n port.postMessage({\n tokens,\n status: currentDatabase.status,\n configurationName,\n version\n });\n }\n return;\n }\n case 'setDemonstratingProofOfPossessionNonce':\n currentDatabase.demonstratingProofOfPossessionNonce = data.data.demonstratingProofOfPossessionNonce;\n port.postMessage({ configurationName });\n return;\n case 'getDemonstratingProofOfPossessionNonce': \n const demonstratingProofOfPossessionNonce = currentDatabase.demonstratingProofOfPossessionNonce;\n port.postMessage({ configurationName, demonstratingProofOfPossessionNonce });\n return;\n case 'setDemonstratingProofOfPossessionJwk':\n currentDatabase.demonstratingProofOfPossessionJwkJson = data.data.demonstratingProofOfPossessionJwkJson;\n port.postMessage({ configurationName });\n return;\n case 'getDemonstratingProofOfPossessionJwk':\n const demonstratingProofOfPossessionJwkJson = currentDatabase.demonstratingProofOfPossessionJwkJson;\n port.postMessage({ configurationName, demonstratingProofOfPossessionJwkJson });\n return; \n case 'setState':\n currentDatabase.state = data.data.state;\n port.postMessage({ configurationName });\n return;\n case 'getState': {\n const state = currentDatabase.state;\n port.postMessage({ configurationName, state });\n return;\n }\n case 'setCodeVerifier':\n currentDatabase.codeVerifier = data.data.codeVerifier;\n port.postMessage({ configurationName });\n return;\n case 'getCodeVerifier': {\n port.postMessage({\n configurationName,\n codeVerifier: currentDatabase.codeVerifier != null ? TOKEN.CODE_VERIFIER + '_' + configurationName : null,\n });\n return;\n }\n case 'setSessionState':\n currentDatabase.sessionState = data.data.sessionState;\n port.postMessage({ configurationName });\n return;\n case 'getSessionState': {\n const sessionState = currentDatabase.sessionState;\n port.postMessage({ configurationName, sessionState });\n return;\n }\n case 'setNonce': {\n const nonce = data.data.nonce;\n if (nonce) {\n currentDatabase.nonce = nonce;\n }\n port.postMessage({ configurationName });\n return;\n }\n case 'getNonce': {\n const keyNonce = TOKEN.NONCE_TOKEN + '_' + configurationName;\n const nonce = currentDatabase.nonce ? keyNonce : null;\n port.postMessage({ configurationName, nonce });\n return;\n }\n default:\n currentDatabase.items = { ...data.data };\n port.postMessage({ configurationName });\n }\n};\n\n_self.addEventListener('install', handleInstall);\n_self.addEventListener('activate', handleActivate);\n_self.addEventListener('fetch', handleFetch);\n_self.addEventListener('message', handleMessage);\n"],"names":["domain","database","trustedDomains","response"],"mappings":"AAAA,MAAM,iBAAiB;AACvB,MAAM,uBAAuB;AAS7B,MAAM,QAAmB;AAAA,EACvB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,aAAa;AAAA,EACb,eAAe;AAC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YAAY,EAAE,kBAAA,CAAmB;AACtC;AAAA,IACF,KAAK,mBAAmB;AACtB,WAAK,YAAY;AAAA,QACf;AAAA,QACA,cAAc,gBAAgB,gBAAgB,OAAO,MAAM,gBAAgB,MAAM,oBAAoB;AAAA,MAAA,CACtG;AACD;AAAA,IACF;AAAA,IACA,KAAK;AACa,sBAAA,eAAe,KAAK,KAAK;AACpC,WAAA,YAAY,EAAE,kBAAA,CAAmB;AACtC;AAAA,IACF,KAAK,mBAAmB;AACtB,YAAM,eAAe,gBAAgB;AACrC,WAAK,YAAY,EAAE,mBAAmB,aAAc,CAAA;AACpD;AAAA,IACF;AAAA,IACA,KAAK,YAAY;AACT,YAAA,QAAQ,KAAK,KAAK;AACxB,UAAI,OAAO;AACT,wBAAgB,QAAQ;AAAA,MAC1B;AACK,WAAA,YAAY,EAAE,kBAAA,CAAmB;AACtC;AAAA,IACF;AAAA,IACA,KAAK,YAAY;AACT,YAAA,WAAW,MAAM,cAAc,MAAM;AACrC,YAAA,QAAQ,gBAAgB,QAAQ,WAAW;AACjD,WAAK,YAAY,EAAE,mBAAmB,MAAO,CAAA;AAC7C;AAAA,IACF;AAAA,IACA;AACE,sBAAgB,QAAQ,EAAE,GAAG,KAAK,KAAK;AAClC,WAAA,YAAY,EAAE,kBAAA,CAAmB;AAAA,EAC1C;AACF;AAEA,MAAM,iBAAiB,WAAW,aAAa;AAC/C,MAAM,iBAAiB,YAAY,cAAc;AACjD,MAAM,iBAAiB,SAAS,WAAW;AAC3C,MAAM,iBAAiB,WAAW,aAAa;"}
1
+ {"version":3,"file":"OidcServiceWorker.js","sources":["../src/constants.ts","../src/utils/normalizeUrl.ts","../src/utils/domains.ts","../src/utils/serializeHeaders.ts","../src/utils/sleep.ts","../src/utils/strings.ts","../src/utils/tokens.ts","../src/utils/codeVerifier.ts","../src/version.ts","../src/OidcServiceWorker.ts"],"sourcesContent":["const scriptFilename = 'OidcTrustedDomains.js';\nconst acceptAnyDomainToken = '*';\n\ntype TokenType = {\n readonly REFRESH_TOKEN: string;\n readonly ACCESS_TOKEN: string;\n readonly NONCE_TOKEN: string;\n readonly CODE_VERIFIER: string;\n};\n\nconst TOKEN: TokenType = {\n REFRESH_TOKEN: 'REFRESH_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER',\n ACCESS_TOKEN: 'ACCESS_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER',\n NONCE_TOKEN: 'NONCE_SECURED_BY_OIDC_SERVICE_WORKER',\n CODE_VERIFIER: 'CODE_VERIFIER_SECURED_BY_OIDC_SERVICE_WORKER',\n};\n\ntype TokenRenewModeType = {\n readonly access_token_or_id_token_invalid: string;\n readonly access_token_invalid: string;\n readonly id_token_invalid: string;\n};\n\nconst TokenRenewMode: TokenRenewModeType = {\n access_token_or_id_token_invalid: 'access_token_or_id_token_invalid',\n access_token_invalid: 'access_token_invalid',\n id_token_invalid: 'id_token_invalid',\n};\n\nconst openidWellknownUrlEndWith = '/.well-known/openid-configuration';\n\nexport { acceptAnyDomainToken, openidWellknownUrlEndWith, scriptFilename, TOKEN, TokenRenewMode };\n","export function normalizeUrl(url: string) {\n\ttry {\n\t\treturn new URL(url).toString();\n\t} catch (error) {\n\t\tconsole.error(`Failed to normalize url: ${url}`);\n\t\treturn url;\n\t}\n}\n\n","import { acceptAnyDomainToken, openidWellknownUrlEndWith, scriptFilename } from '../constants';\nimport { Database, Domain, DomainDetails, OidcConfig, TrustedDomains } from '../types';\nimport { normalizeUrl } from './normalizeUrl';\n\nexport function checkDomain(domains: Domain[], endpoint: string) {\n\tif (!endpoint) {\n\t\treturn;\n\t}\n\n\tconst domain = domains.find((domain) => {\n\t\tlet testable: RegExp;\n\n\t\tif (typeof domain === 'string') {\n\t\t\ttestable = new RegExp(`^${domain}`);\n\t\t} else {\n\t\t\ttestable = domain;\n\t\t}\n\n\t\treturn testable.test?.(endpoint);\n\t});\n\tif (!domain) {\n\t\tthrow new Error(\n\t\t\t'Domain ' + endpoint + ' is not trusted, please add domain in ' + scriptFilename,\n\t\t);\n\t}\n}\n\nexport const getDomains = (\n\ttrustedDomain: Domain[] | DomainDetails,\n\ttype: 'oidc' | 'accessToken',\n) => {\n\tif (Array.isArray(trustedDomain)) {\n\t\treturn trustedDomain;\n\t}\n\n\treturn trustedDomain[`${type}Domains`] ?? trustedDomain.domains ?? [];\n};\n\nexport const getCurrentDatabaseDomain = (\n\tdatabase: Database,\n\turl: string,\n\ttrustedDomains: TrustedDomains,\n) => {\n\tif (url.endsWith(openidWellknownUrlEndWith)) {\n\t\treturn null;\n\t}\n\tfor (const [key, currentDatabase] of Object.entries<OidcConfig>(database)) {\n\t\tconst oidcServerConfiguration = currentDatabase.oidcServerConfiguration;\n\n\t\tif (!oidcServerConfiguration) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (\n\t\t\toidcServerConfiguration.tokenEndpoint &&\n\t\t\turl === normalizeUrl(oidcServerConfiguration.tokenEndpoint)\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\toidcServerConfiguration.revocationEndpoint &&\n\t\t\turl === normalizeUrl(oidcServerConfiguration.revocationEndpoint)\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst trustedDomain = trustedDomains == null ? [] : trustedDomains[key];\n\n\t\tconst domains = getDomains(trustedDomain, 'accessToken');\n\t\tconst domainsToSendTokens = oidcServerConfiguration.userInfoEndpoint\n\t\t\t? [oidcServerConfiguration.userInfoEndpoint, ...domains]\n\t\t\t: [...domains];\n\n\t\tlet hasToSendToken = false;\n\t\tif (domainsToSendTokens.find((f) => f === acceptAnyDomainToken)) {\n\t\t\thasToSendToken = true;\n\t\t} else {\n\t\t\tfor (let i = 0; i < domainsToSendTokens.length; i++) {\n\t\t\t\tlet domain = domainsToSendTokens[i];\n\n\t\t\t\tif (typeof domain === 'string') {\n\t\t\t\t\tdomain = new RegExp(`^${domain}`);\n\t\t\t\t}\n\n\t\t\t\tif (domain.test?.(url)) {\n\t\t\t\t\thasToSendToken = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (hasToSendToken) {\n\t\t\tif (!currentDatabase.tokens) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn currentDatabase;\n\t\t}\n\t}\n\treturn null;\n};\n","import { FetchHeaders } from '../types';\n\nfunction serializeHeaders(headers: Headers) {\n const headersObj: Record<string, string> = {};\n for (const key of (headers as FetchHeaders).keys()) {\n if (headers.has(key)) {\n headersObj[key] = headers.get(key) as string;\n }\n }\n return headersObj;\n}\nexport { serializeHeaders };\n","const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\nexport { sleep };\n","/**\n * Count occurances of letter in string\n * @param str\n * @param find\n * @returns\n */\nexport function countLetter(str: string, find: string) {\n return str.split(find).length - 1;\n}\n","/* eslint-disable simple-import-sort/exports */\nimport { TOKEN, TokenRenewMode } from '../constants';\nimport {\n AccessTokenPayload,\n IdTokenPayload,\n OidcConfig,\n OidcConfiguration,\n OidcServerConfiguration,\n Tokens\n} from '../types';\nimport { countLetter } from './strings';\n\nfunction parseJwt(token: string) {\n return JSON.parse(\n b64DecodeUnicode(token.split('.')[1].replace('-', '+').replace('_', '/')),\n );\n}\nfunction b64DecodeUnicode(str: string) {\n return decodeURIComponent(\n Array.prototype.map\n .call(\n atob(str),\n (c) => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2),\n )\n .join(''),\n );\n}\n\nfunction computeTimeLeft(\n refreshTimeBeforeTokensExpirationInSecond: number,\n expiresAt: number,\n) {\n const currentTimeUnixSecond = new Date().getTime() / 1000;\n return Math.round(\n expiresAt -\n refreshTimeBeforeTokensExpirationInSecond -\n currentTimeUnixSecond,\n );\n}\n\nfunction isTokensValid(tokens: Tokens | null) {\n if (!tokens) {\n return false;\n }\n return computeTimeLeft(0, tokens.expiresAt) > 0;\n}\n\nconst extractTokenPayload = (token?: string) => {\n try {\n if (!token) {\n return null;\n }\n if (countLetter(token, '.') === 2) {\n return parseJwt(token);\n } else {\n return null;\n }\n } catch (e) {\n console.warn(e);\n }\n return null;\n};\n\n// https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation (excluding rules #1, #4, #5, #7, #8, #12, and #13 which did not apply).\n// https://github.com/openid/AppAuth-JS/issues/65\nconst isTokensOidcValid = (\n tokens: Tokens,\n nonce: string | null,\n oidcServerConfiguration: OidcServerConfiguration,\n): { isValid: boolean; reason: string } => {\n if (tokens.idTokenPayload) {\n const idTokenPayload = tokens.idTokenPayload;\n // 2: The Issuer Identifier for the OpenID Provider (which is typically obtained during Discovery) MUST exactly match the value of the iss (issuer) Claim.\n if (oidcServerConfiguration.issuer !== idTokenPayload.iss) {\n return { isValid: false, reason: `Issuer does not match (oidcServerConfiguration issuer) ${oidcServerConfiguration.issuer} !== (idTokenPayload issuer) ${idTokenPayload.iss}` };\n }\n // 3: The Client MUST validate that the aud (audience) Claim contains its client_id value registered at the Issuer identified by the iss (issuer) Claim as an audience. The aud (audience) Claim MAY contain an array with more than one element. The ID Token MUST be rejected if the ID Token does not list the Client as a valid audience, or if it contains additional audiences not trusted by the Client.\n\n // 6: If the ID Token is received via direct communication between the Client and the Token Endpoint (which it is in this flow), the TLS server validation MAY be used to validate the issuer in place of checking the token signature. The Client MUST validate the signature of all other ID Tokens according to JWS [JWS] using the algorithm specified in the JWT alg Header Parameter. The Client MUST use the keys provided by the Issuer.\n\n // 9: The current time MUST be before the time represented by the exp Claim.\n const currentTimeUnixSecond = new Date().getTime() / 1000;\n if (idTokenPayload.exp && idTokenPayload.exp < currentTimeUnixSecond) {\n return { isValid: false, reason: `Token expired at (idTokenPayload exp) ${idTokenPayload.exp} < (currentTimeUnixSecond) ${currentTimeUnixSecond}` };\n }\n // 10: The iat Claim can be used to reject tokens that were issued too far away from the current time, limiting the amount of time that nonces need to be stored to prevent attacks. The acceptable range is Client specific.\n const timeInSevenDays = 60 * 60 * 24 * 7;\n if (\n idTokenPayload.iat &&\n idTokenPayload.iat + timeInSevenDays < currentTimeUnixSecond\n ) {\n return { isValid: false, reason: `Token is used from too long time (idTokenPayload iat + timeInSevenDays) ${idTokenPayload.iat + timeInSevenDays} < (currentTimeUnixSecond) ${currentTimeUnixSecond}` };\n }\n // 11: If a nonce value was sent in the Authentication Request, a nonce Claim MUST be present and its value checked to verify that it is the same value as the one that was sent in the Authentication Request. The Client SHOULD check the nonce value for replay attacks. The precise method for detecting replay attacks is Client specific.\n if (nonce && idTokenPayload.nonce && idTokenPayload.nonce !== nonce) {\n return { isValid: false, reason: `Nonce does not match (nonce) ${nonce} !== (idTokenPayload nonce) ${idTokenPayload.nonce}` };\n }\n }\n return { isValid: true, reason: '' };\n};\n\nfunction extractedIssueAt(tokens: Tokens, accessTokenPayload: AccessTokenPayload | null, _idTokenPayload : IdTokenPayload) {\n if (!tokens.issued_at) {\n if (accessTokenPayload && accessTokenPayload.iat) {\n return accessTokenPayload.iat;\n } else if (_idTokenPayload && _idTokenPayload.iat) {\n return _idTokenPayload.iat;\n } else {\n const currentTimeUnixSecond = new Date().getTime() / 1000;\n return currentTimeUnixSecond;\n }\n } else if (typeof tokens.issued_at == \"string\") {\n return parseInt(tokens.issued_at, 10);\n }\n return tokens.issued_at;\n}\n\nfunction _hideTokens(tokens: Tokens, currentDatabaseElement: OidcConfig, configurationName: string) {\n if (!tokens.issued_at) {\n const currentTimeUnixSecond = new Date().getTime() / 1000;\n tokens.issued_at = currentTimeUnixSecond;\n } else if (typeof tokens.issued_at == \"string\") {\n tokens.issued_at = parseInt(tokens.issued_at, 10);\n }\n\n const accessTokenPayload = extractTokenPayload(tokens.access_token);\n const secureTokens = {\n ...tokens,\n accessTokenPayload,\n };\n if (currentDatabaseElement.hideAccessToken) {\n secureTokens.access_token = TOKEN.ACCESS_TOKEN + '_' + configurationName;\n }\n tokens.accessTokenPayload = accessTokenPayload;\n\n let _idTokenPayload = null;\n if (tokens.id_token) {\n _idTokenPayload = extractTokenPayload(tokens.id_token);\n tokens.idTokenPayload = { ..._idTokenPayload };\n if (_idTokenPayload.nonce && currentDatabaseElement.nonce != null) {\n const keyNonce =\n TOKEN.NONCE_TOKEN + '_' + currentDatabaseElement.configurationName;\n _idTokenPayload.nonce = keyNonce;\n }\n secureTokens.idTokenPayload = _idTokenPayload;\n }\n if (tokens.refresh_token) {\n secureTokens.refresh_token =\n TOKEN.REFRESH_TOKEN + '_' + configurationName;\n }\n\n tokens.issued_at = extractedIssueAt(tokens, accessTokenPayload, _idTokenPayload);\n\n const expireIn = typeof tokens.expires_in == \"string\" ? parseInt(tokens.expires_in, 10) : tokens.expires_in;\n\n const idTokenExpiresAt =\n _idTokenPayload && _idTokenPayload.exp\n ? _idTokenPayload.exp\n : Number.MAX_VALUE;\n const accessTokenExpiresAt =\n accessTokenPayload && accessTokenPayload.exp\n ? accessTokenPayload.exp\n : tokens.issued_at + expireIn;\n\n let expiresAt: number;\n const tokenRenewMode = (\n currentDatabaseElement.oidcConfiguration as OidcConfiguration\n ).token_renew_mode;\n if (tokenRenewMode === TokenRenewMode.access_token_invalid) {\n expiresAt = accessTokenExpiresAt;\n } else if (tokenRenewMode === TokenRenewMode.id_token_invalid) {\n expiresAt = idTokenExpiresAt;\n } else {\n expiresAt =\n idTokenExpiresAt < accessTokenExpiresAt\n ? idTokenExpiresAt\n : accessTokenExpiresAt;\n }\n secureTokens.expiresAt = expiresAt;\n\n tokens.expiresAt = expiresAt;\n const nonce = currentDatabaseElement.nonce\n ? currentDatabaseElement.nonce.nonce\n : null;\n const { isValid, reason } = isTokensOidcValid(\n tokens,\n nonce,\n currentDatabaseElement.oidcServerConfiguration as OidcServerConfiguration,\n ); // TODO: Type assertion, could be null.\n if (!isValid) {\n throw Error(`Tokens are not OpenID valid, reason: ${reason}`);\n }\n\n // When refresh_token is not rotated we reuse ald refresh_token\n if (\n currentDatabaseElement.tokens != null &&\n 'refresh_token' in currentDatabaseElement.tokens &&\n !('refresh_token' in tokens)\n ) {\n const refreshToken = currentDatabaseElement.tokens.refresh_token;\n\n currentDatabaseElement.tokens = {\n ...tokens,\n refresh_token: refreshToken,\n };\n } else {\n currentDatabaseElement.tokens = tokens;\n }\n\n currentDatabaseElement.status = 'LOGGED_IN';\n return secureTokens;\n}\n\nfunction hideTokens(currentDatabaseElement: OidcConfig) {\n const configurationName = currentDatabaseElement.configurationName;\n return (response: Response) => {\n if (response.status !== 200) {\n return response;\n }\n return response.json().then<Response>((tokens: Tokens) => {\n const secureTokens = _hideTokens(tokens, currentDatabaseElement, configurationName);\n const body = JSON.stringify(secureTokens);\n return new Response(body, response);\n });\n };\n}\n\nexport {\n b64DecodeUnicode,\n computeTimeLeft,\n isTokensValid,\n extractTokenPayload,\n isTokensOidcValid,\n hideTokens,\n _hideTokens,\n};\n","export function replaceCodeVerifier(codeVerifier:string, newCodeVerifier:string):string {\n const regex = /code_verifier=[A-Za-z0-9_-]+/i;\n return codeVerifier.replace(regex, `code_verifier=${newCodeVerifier}`);\n}\n","export default '7.9.3';\n","import { acceptAnyDomainToken, scriptFilename, TOKEN } from './constants';\nimport {\n\tDatabase,\n\tMessageEventData,\n\tOidcConfig,\n\tTrustedDomains,\n} from './types';\nimport {\n\tcheckDomain,\n\tgetCurrentDatabaseDomain,\n\tgetDomains,\n\thideTokens,\n\tisTokensValid,\n\tserializeHeaders,\n\tsleep,\n} from './utils';\nimport { replaceCodeVerifier } from './utils/codeVerifier';\nimport { normalizeUrl } from './utils/normalizeUrl';\nimport version from './version';\n\n// @ts-ignore\nif (typeof trustedTypes !== 'undefined' && typeof trustedTypes.createPolicy == 'function') {\n\t// @ts-ignore\n\ttrustedTypes.createPolicy('default', {\n\t\tcreateScriptURL: function (url: string) {\n\t\t\tif (url == scriptFilename) {\n\t\t\t\treturn url;\n\t\t\t} else {\n\t\t\t\tthrow new Error('Untrusted script URL blocked: ' + url);\n\t\t\t}\n\t\t},\n\t});\n}\n\nconst _self = self as ServiceWorkerGlobalScope & typeof globalThis;\n\ndeclare let trustedDomains: TrustedDomains;\n\n_self.importScripts(scriptFilename);\n\nconst id = Math.round(new Date().getTime() / 1000).toString();\n\nconst keepAliveJsonFilename = 'OidcKeepAliveServiceWorker.json';\nconst handleInstall = (event: ExtendableEvent) => {\n\tconsole.log('[OidcServiceWorker] service worker installed ' + id);\n\tevent.waitUntil(_self.skipWaiting());\n};\n\nconst handleActivate = (event: ExtendableEvent) => {\n\tconsole.log('[OidcServiceWorker] service worker activated ' + id);\n\tevent.waitUntil(_self.clients.claim());\n};\n\nlet currentLoginCallbackConfigurationName: string | null = null;\nconst database: Database = {};\n\nconst getCurrentDatabasesTokenEndpoint = (database: Database, url: string) => {\n\tconst databases: OidcConfig[] = [];\n\tfor (const [, value] of Object.entries<OidcConfig>(database)) {\n\t\tif (\n\t\t\tvalue.oidcServerConfiguration != null &&\n\t\t\turl.startsWith(normalizeUrl(value.oidcServerConfiguration.tokenEndpoint))\n\t\t) {\n\t\t\tdatabases.push(value);\n\t\t} else if (\n\t\t\tvalue.oidcServerConfiguration != null &&\n\t\t\tvalue.oidcServerConfiguration.revocationEndpoint &&\n\t\t\turl.startsWith(\n\t\t\t\tnormalizeUrl(value.oidcServerConfiguration.revocationEndpoint),\n\t\t\t)\n\t\t) {\n\t\t\tdatabases.push(value);\n\t\t}\n\t}\n\treturn databases;\n};\n\nconst keepAliveAsync = async (event: FetchEvent) => {\n\tconst originalRequest = event.request;\n\tconst isFromVanilla = originalRequest.headers.has('oidc-vanilla');\n\tconst init = { status: 200, statusText: 'oidc-service-worker' };\n\tconst response = new Response('{}', init);\n\tif (!isFromVanilla) {\n\t\tconst originalRequestUrl = new URL(originalRequest.url);\n\t\tconst minSleepSeconds =\n\t\t\tNumber(originalRequestUrl.searchParams.get('minSleepSeconds')) || 240;\n\t\tfor (let i = 0; i < minSleepSeconds; i++) {\n\t\t\tawait sleep(1000 + Math.floor(Math.random() * 1000));\n\t\t\tconst cache = await caches.open('oidc_dummy_cache');\n\t\t\tawait cache.put(event.request, response.clone());\n\t\t}\n\t}\n\treturn response;\n};\n\nconst handleFetch = async (event: FetchEvent) => {\n\tconst originalRequest = event.request;\n\tconst url = normalizeUrl(originalRequest.url);\n\tif (url.includes(keepAliveJsonFilename)) {\n\t\tevent.respondWith(keepAliveAsync(event));\n\t\treturn;\n\t}\n\n\tconst currentDatabaseForRequestAccessToken = getCurrentDatabaseDomain(\n\t\tdatabase,\n\t\turl,\n\t\ttrustedDomains,\n\t);\n\tif (\n\t\tcurrentDatabaseForRequestAccessToken &&\n\t\tcurrentDatabaseForRequestAccessToken.tokens &&\n\t\tcurrentDatabaseForRequestAccessToken.tokens.access_token\n\t) {\n\t\twhile (\n\t\t\tcurrentDatabaseForRequestAccessToken.tokens &&\n\t\t\t!isTokensValid(currentDatabaseForRequestAccessToken.tokens)\n\t\t) {\n\t\t\tawait sleep(200);\n\t\t}\n\n\t\tlet requestMode = originalRequest.mode;\n\n\t\tif (\n\t\t\toriginalRequest.mode !== 'navigate' &&\n\t\t\tcurrentDatabaseForRequestAccessToken.convertAllRequestsToCorsExceptNavigate\n\t\t) {\n\t\t\trequestMode = 'cors';\n\t\t}\n\n\t\tlet headers: { [p: string]: string };\n\t\tif (\n\t\t\toriginalRequest.mode == 'navigate' &&\n\t\t\t!currentDatabaseForRequestAccessToken.setAccessTokenToNavigateRequests\n\t\t) {\n\t\t\theaders = {\n\t\t\t\t...serializeHeaders(originalRequest.headers),\n\t\t\t};\n\t\t} else {\n\t\t\theaders = {\n\t\t\t\t...serializeHeaders(originalRequest.headers),\n\t\t\t\tauthorization:\n\t\t\t\t\t'Bearer ' + currentDatabaseForRequestAccessToken.tokens.access_token,\n\t\t\t};\n\t\t}\n\t\tlet init: RequestInit;\n\t\tif (originalRequest.mode === 'navigate') {\n\t\t\tinit = {\n\t\t\t\theaders: headers,\n\t\t\t};\n\t\t} else {\n\t\t\tinit = {\n\t\t\t\theaders: headers,\n\t\t\t\tmode: requestMode,\n\t\t\t};\n\t\t}\n\n\t\tconst newRequest = new Request(originalRequest, init);\n\n\t\tevent.respondWith(fetch(newRequest));\n\n\t\treturn;\n\t}\n\n\tif (event.request.method !== 'POST') {\n\t\treturn;\n\t}\n\n\tlet currentDatabase: OidcConfig | null = null;\n\tconst currentDatabases = getCurrentDatabasesTokenEndpoint(database, url);\n\tconst numberDatabase = currentDatabases.length;\n\tif (numberDatabase > 0) {\n\t\tconst maPromesse = new Promise<Response>((resolve, reject) => {\n\t\t\tconst clonedRequest = originalRequest.clone();\n\t\t\tconst response = clonedRequest.text().then((actualBody) => {\n\t\t\t\tif (\n\t\t\t\t\tactualBody.includes(TOKEN.REFRESH_TOKEN) ||\n\t\t\t\t\tactualBody.includes(TOKEN.ACCESS_TOKEN)\n\t\t\t\t) {\n\t\t\t\t\tlet newBody = actualBody;\n\t\t\t\t\tfor (let i = 0; i < numberDatabase; i++) {\n\t\t\t\t\t\tconst currentDb = currentDatabases[i];\n\n\t\t\t\t\t\tif (currentDb && currentDb.tokens != null) {\n\t\t\t\t\t\t\tconst keyRefreshToken =\n\t\t\t\t\t\t\t\tTOKEN.REFRESH_TOKEN + '_' + currentDb.configurationName;\n\t\t\t\t\t\t\tif (actualBody.includes(keyRefreshToken)) {\n\t\t\t\t\t\t\t\tnewBody = newBody.replace(\n\t\t\t\t\t\t\t\t\tkeyRefreshToken,\n\t\t\t\t\t\t\t\t\tencodeURIComponent(currentDb.tokens.refresh_token as string),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tcurrentDatabase = currentDb;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst keyAccessToken =\n\t\t\t\t\t\t\t\tTOKEN.ACCESS_TOKEN + '_' + currentDb.configurationName;\n\t\t\t\t\t\t\tif (actualBody.includes(keyAccessToken)) {\n\t\t\t\t\t\t\t\tnewBody = newBody.replace(\n\t\t\t\t\t\t\t\t\tkeyAccessToken,\n\t\t\t\t\t\t\t\t\tencodeURIComponent(currentDb.tokens.access_token),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tcurrentDatabase = currentDb;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconst fetchPromise = fetch(originalRequest, {\n\t\t\t\t\t\tbody: newBody,\n\t\t\t\t\t\tmethod: clonedRequest.method,\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t...serializeHeaders(originalRequest.headers),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmode: clonedRequest.mode,\n\t\t\t\t\t\tcache: clonedRequest.cache,\n\t\t\t\t\t\tredirect: clonedRequest.redirect,\n\t\t\t\t\t\treferrer: clonedRequest.referrer,\n\t\t\t\t\t\tcredentials: clonedRequest.credentials,\n\t\t\t\t\t\tintegrity: clonedRequest.integrity,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tcurrentDatabase &&\n\t\t\t\t\t\tcurrentDatabase.oidcServerConfiguration != null &&\n\t\t\t\t\t\tcurrentDatabase.oidcServerConfiguration.revocationEndpoint &&\n\t\t\t\t\t\turl.startsWith(\n\t\t\t\t\t\t\tnormalizeUrl(\n\t\t\t\t\t\t\t\tcurrentDatabase.oidcServerConfiguration.revocationEndpoint,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn fetchPromise.then(async (response) => {\n\t\t\t\t\t\t\tconst text = await response.text();\n\t\t\t\t\t\t\treturn new Response(text, response);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn fetchPromise.then(hideTokens(currentDatabase as OidcConfig)); // todo type assertion to OidcConfig but could be null, NEEDS REVIEW\n\t\t\t\t} else if (\n\t\t\t\t\tactualBody.includes('code_verifier=') &&\n\t\t\t\t\tcurrentLoginCallbackConfigurationName\n\t\t\t\t) {\n\t\t\t\t\tcurrentDatabase = database[currentLoginCallbackConfigurationName];\n\t\t\t\t\tcurrentLoginCallbackConfigurationName = null;\n\t\t\t\t\tlet newBody = actualBody;\n\t\t\t\t\tif (currentDatabase && currentDatabase.codeVerifier != null) {\n\t\t\t\t\t\tnewBody = replaceCodeVerifier(\n\t\t\t\t\t\t\tnewBody,\n\t\t\t\t\t\t\tcurrentDatabase.codeVerifier,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn fetch(originalRequest, {\n\t\t\t\t\t\tbody: newBody,\n\t\t\t\t\t\tmethod: clonedRequest.method,\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t...serializeHeaders(originalRequest.headers),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmode: clonedRequest.mode,\n\t\t\t\t\t\tcache: clonedRequest.cache,\n\t\t\t\t\t\tredirect: clonedRequest.redirect,\n\t\t\t\t\t\treferrer: clonedRequest.referrer,\n\t\t\t\t\t\tcredentials: clonedRequest.credentials,\n\t\t\t\t\t\tintegrity: clonedRequest.integrity,\n\t\t\t\t\t}).then(hideTokens(currentDatabase));\n\t\t\t\t}\n\n\t\t\t\t// if showAccessToken=true, the token is already in the body\n\t\t\t\t// of the request, and it does not need to be injected\n\t\t\t\t// and we can simply clone the request\n\t\t\t\treturn fetch(originalRequest, {\n\t\t\t\t\tbody: actualBody,\n\t\t\t\t\tmethod: clonedRequest.method,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t...serializeHeaders(originalRequest.headers),\n\t\t\t\t\t},\n\t\t\t\t\tmode: clonedRequest.mode,\n\t\t\t\t\tcache: clonedRequest.cache,\n\t\t\t\t\tredirect: clonedRequest.redirect,\n\t\t\t\t\treferrer: clonedRequest.referrer,\n\t\t\t\t\tcredentials: clonedRequest.credentials,\n\t\t\t\t\tintegrity: clonedRequest.integrity,\n\t\t\t\t});\n\t\t\t});\n\t\t\tresponse\n\t\t\t\t.then((r) => {\n\t\t\t\t\tresolve(r);\n\t\t\t\t})\n\t\t\t\t.catch((err) => {\n\t\t\t\t\treject(err);\n\t\t\t\t});\n\t\t});\n\n\t\tevent.respondWith(maPromesse);\n\t}\n};\n\nconst handleMessage = (event: ExtendableMessageEvent) => {\n\tconst port = event.ports[0];\n\tconst data = event.data as MessageEventData;\n\tif (event.data.type === 'claim') {\n\t\t_self.clients.claim().then(() => port.postMessage({}));\n\t\treturn;\n\t}\n\tconst configurationName = data.configurationName;\n\tlet currentDatabase = database[configurationName];\n\tif (trustedDomains == null) {\n\t\ttrustedDomains = {};\n\t}\n\tif (!currentDatabase) {\n\t\tconst trustedDomain = trustedDomains[configurationName];\n\t\tconst showAccessToken = Array.isArray(trustedDomain)\n\t\t\t? false\n\t\t\t: trustedDomain.showAccessToken;\n\t\tconst doNotSetAccessTokenToNavigateRequests = Array.isArray(trustedDomain)\n\t\t\t? true\n\t\t\t: trustedDomain.setAccessTokenToNavigateRequests;\n\t\tconst convertAllRequestsToCorsExceptNavigate = Array.isArray(trustedDomain)\n\t\t\t? false\n\t\t\t: trustedDomain.convertAllRequestsToCorsExceptNavigate;\n\t\tdatabase[configurationName] = {\n\t\t\ttokens: null,\n\t\t\tstate: null,\n\t\t\tcodeVerifier: null,\n\t\t\toidcServerConfiguration: null,\n\t\t\toidcConfiguration: undefined,\n\t\t\tnonce: null,\n\t\t\tstatus: null,\n\t\t\tconfigurationName,\n\t\t\thideAccessToken: !showAccessToken,\n\t\t\tsetAccessTokenToNavigateRequests:\n\t\t\t\tdoNotSetAccessTokenToNavigateRequests ?? true,\n\t\t\tconvertAllRequestsToCorsExceptNavigate:\n\t\t\t\tconvertAllRequestsToCorsExceptNavigate ?? false,\n\t\t\tdemonstratingProofOfPossessionNonce: null,\n\t\t\tdemonstratingProofOfPossessionJwkJson: null,\n\t\t};\n\t\tcurrentDatabase = database[configurationName];\n\n\t\tif (!trustedDomains[configurationName]) {\n\t\t\ttrustedDomains[configurationName] = [];\n\t\t}\n\t}\n\n\tswitch (data.type) {\n\t\tcase 'clear':\n\t\t\tcurrentDatabase.tokens = null;\n\t\t\tcurrentDatabase.state = null;\n\t\t\tcurrentDatabase.codeVerifier = null;\n\t\t\tcurrentDatabase.status = data.data.status;\n\t\t\tport.postMessage({ configurationName });\n\t\t\treturn;\n\t\tcase 'init': {\n\t\t\tconst oidcServerConfiguration = data.data.oidcServerConfiguration;\n\t\t\tconst trustedDomain = trustedDomains[configurationName];\n\t\t\tconst domains = getDomains(trustedDomain, 'oidc');\n\t\t\tif (!domains.some((domain) => domain === acceptAnyDomainToken)) {\n\t\t\t\t[\n\t\t\t\t\toidcServerConfiguration.tokenEndpoint,\n\t\t\t\t\toidcServerConfiguration.revocationEndpoint,\n\t\t\t\t\toidcServerConfiguration.userInfoEndpoint,\n\t\t\t\t\toidcServerConfiguration.issuer,\n\t\t\t\t].forEach((url) => {\n\t\t\t\t\tcheckDomain(domains, url);\n\t\t\t\t});\n\t\t\t}\n\t\t\tcurrentDatabase.oidcServerConfiguration = oidcServerConfiguration;\n\t\t\tcurrentDatabase.oidcConfiguration = data.data.oidcConfiguration;\n\t\t\tconst where = data.data.where;\n\t\t\tif (\n\t\t\t\twhere === 'loginCallbackAsync' ||\n\t\t\t\twhere === 'tryKeepExistingSessionAsync'\n\t\t\t) {\n\t\t\t\tcurrentLoginCallbackConfigurationName = configurationName;\n\t\t\t} else {\n\t\t\t\tcurrentLoginCallbackConfigurationName = null;\n\t\t\t}\n\n\t\t\tif (!currentDatabase.tokens) {\n\t\t\t\tport.postMessage({\n\t\t\t\t\ttokens: null,\n\t\t\t\t\tstatus: currentDatabase.status,\n\t\t\t\t\tconfigurationName,\n\t\t\t\t\tversion,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst tokens = {\n\t\t\t\t\t...currentDatabase.tokens,\n\t\t\t\t};\n\t\t\t\tif (currentDatabase.hideAccessToken) {\n\t\t\t\t\ttokens.access_token = TOKEN.ACCESS_TOKEN + '_' + configurationName;\n\t\t\t\t}\n\t\t\t\tif (tokens.refresh_token) {\n\t\t\t\t\ttokens.refresh_token = TOKEN.REFRESH_TOKEN + '_' + configurationName;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\ttokens.idTokenPayload &&\n\t\t\t\t\ttokens.idTokenPayload.nonce &&\n\t\t\t\t\tcurrentDatabase.nonce != null\n\t\t\t\t) {\n\t\t\t\t\ttokens.idTokenPayload.nonce =\n\t\t\t\t\t\tTOKEN.NONCE_TOKEN + '_' + configurationName;\n\t\t\t\t}\n\t\t\t\tport.postMessage({\n\t\t\t\t\ttokens,\n\t\t\t\t\tstatus: currentDatabase.status,\n\t\t\t\t\tconfigurationName,\n\t\t\t\t\tversion,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tcase 'setDemonstratingProofOfPossessionNonce': {\n\t\t\tcurrentDatabase.demonstratingProofOfPossessionNonce =\n\t\t\t\tdata.data.demonstratingProofOfPossessionNonce;\n\t\t\tport.postMessage({ configurationName });\n\t\t\treturn;\n\t\t}\n\t\tcase 'getDemonstratingProofOfPossessionNonce': {\n\t\t\tconst demonstratingProofOfPossessionNonce =\n\t\t\t\tcurrentDatabase.demonstratingProofOfPossessionNonce;\n\t\t\tport.postMessage({\n\t\t\t\tconfigurationName,\n\t\t\t\tdemonstratingProofOfPossessionNonce,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tcase 'setDemonstratingProofOfPossessionJwk': {\n\t\t\tcurrentDatabase.demonstratingProofOfPossessionJwkJson =\n\t\t\t\tdata.data.demonstratingProofOfPossessionJwkJson;\n\t\t\tport.postMessage({ configurationName });\n\t\t\treturn;\n\t\t}\n\t\tcase 'getDemonstratingProofOfPossessionJwk': {\n\t\t\tconst demonstratingProofOfPossessionJwkJson =\n\t\t\t\tcurrentDatabase.demonstratingProofOfPossessionJwkJson;\n\t\t\tport.postMessage({\n\t\t\t\tconfigurationName,\n\t\t\t\tdemonstratingProofOfPossessionJwkJson,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tcase 'setState': {\n\t\t\tcurrentDatabase.state = data.data.state;\n\t\t\tport.postMessage({ configurationName });\n\t\t\treturn;\n\t\t}\n\t\tcase 'getState': {\n\t\t\tconst state = currentDatabase.state;\n\t\t\tport.postMessage({ configurationName, state });\n\t\t\treturn;\n\t\t}\n\t\tcase 'setCodeVerifier': {\n\t\t\tcurrentDatabase.codeVerifier = data.data.codeVerifier;\n\t\t\tport.postMessage({ configurationName });\n\t\t\treturn;\n\t\t}\n\t\tcase 'getCodeVerifier': {\n\t\t\tport.postMessage({\n\t\t\t\tconfigurationName,\n\t\t\t\tcodeVerifier:\n\t\t\t\t\tcurrentDatabase.codeVerifier != null\n\t\t\t\t\t\t? TOKEN.CODE_VERIFIER + '_' + configurationName\n\t\t\t\t\t\t: null,\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tcase 'setSessionState': {\n\t\t\tcurrentDatabase.sessionState = data.data.sessionState;\n\t\t\tport.postMessage({ configurationName });\n\t\t\treturn;\n\t\t}\n\t\tcase 'getSessionState': {\n\t\t\tconst sessionState = currentDatabase.sessionState;\n\t\t\tport.postMessage({ configurationName, sessionState });\n\t\t\treturn;\n\t\t}\n\t\tcase 'setNonce': {\n\t\t\tconst nonce = data.data.nonce;\n\t\t\tif (nonce) {\n\t\t\t\tcurrentDatabase.nonce = nonce;\n\t\t\t}\n\t\t\tport.postMessage({ configurationName });\n\t\t\treturn;\n\t\t}\n\t\tcase 'getNonce': {\n\t\t\tconst keyNonce = TOKEN.NONCE_TOKEN + '_' + configurationName;\n\t\t\tconst nonce = currentDatabase.nonce ? keyNonce : null;\n\t\t\tport.postMessage({ configurationName, nonce });\n\t\t\treturn;\n\t\t}\n\t\tdefault: {\n\t\t\tcurrentDatabase.items = { ...data.data };\n\t\t\tport.postMessage({ configurationName });\n\t\t}\n\t}\n};\n\n_self.addEventListener('install', handleInstall);\n_self.addEventListener('activate', handleActivate);\n_self.addEventListener('fetch', handleFetch);\n_self.addEventListener('message', handleMessage);\n"],"names":["domain","database","trustedDomains","response"],"mappings":"AAAA,MAAM,iBAAiB;AACvB,MAAM,uBAAuB;AAS7B,MAAM,QAAmB;AAAA,EACvB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AC/C,MAAM,iBAAiB,YAAY,cAAc;AACjD,MAAM,iBAAiB,SAAS,WAAW;AAC3C,MAAM,iBAAiB,WAAW,aAAa;"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=normalizeUrl.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeUrl.spec.d.ts","sourceRoot":"","sources":["../../../../src/utils/__tests__/normalizeUrl.spec.ts"],"names":[],"mappings":""}
@@ -2,4 +2,3 @@ import { Database, Domain, DomainDetails, OidcConfig, TrustedDomains } from '../
2
2
  export declare function checkDomain(domains: Domain[], endpoint: string): void;
3
3
  export declare const getDomains: (trustedDomain: Domain[] | DomainDetails, type: 'oidc' | 'accessToken') => Domain[];
4
4
  export declare const getCurrentDatabaseDomain: (database: Database, url: string, trustedDomains: TrustedDomains) => OidcConfig | null;
5
- export declare function normalizeUrl(url: string): string;
@@ -1,4 +1,5 @@
1
1
  export * from './domains';
2
+ export * from './normalizeUrl';
2
3
  export * from './serializeHeaders';
3
4
  export * from './sleep';
4
5
  export * from './strings';
@@ -0,0 +1 @@
1
+ export declare function normalizeUrl(url: string): string;
@@ -1,2 +1,2 @@
1
- declare const _default: "7.9.3-alpha.1132";
1
+ declare const _default: "7.9.3";
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axa-fr/oidc-client-service-worker",
3
- "version": "7.9.3-alpha.1132",
3
+ "version": "7.9.3",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "dist/OidcServiceWorker.js",