@axa-fr/oidc-client 7.25.14 → 7.25.16-alpha.1772

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/dist/index.js CHANGED
@@ -90,18 +90,18 @@ const m = {
90
90
  n[`oidc.nonce.${e}`] = g.nonce;
91
91
  }, c = (g) => {
92
92
  n[`oidc.jwk.${e}`] = JSON.stringify(g);
93
- }, u = () => JSON.parse(n[`oidc.jwk.${e}`]), f = async () => ({ nonce: n[`oidc.nonce.${e}`] }), l = async (g) => {
93
+ }, u = () => JSON.parse(n[`oidc.jwk.${e}`]), _ = async () => ({ nonce: n[`oidc.nonce.${e}`] }), l = async (g) => {
94
94
  n[`oidc.dpop_nonce.${e}`] = g;
95
- }, h = () => n[`oidc.dpop_nonce.${e}`], _ = () => n[`oidc.${e}`] ? JSON.stringify({ tokens: JSON.parse(n[`oidc.${e}`]).tokens }) : null, k = {};
95
+ }, d = () => n[`oidc.dpop_nonce.${e}`], f = () => n[`oidc.${e}`] ? JSON.stringify({ tokens: JSON.parse(n[`oidc.${e}`]).tokens }) : null, k = {};
96
96
  return {
97
97
  clearAsync: s,
98
98
  initAsync: t,
99
99
  setTokens: o,
100
- getTokens: _,
100
+ getTokens: f,
101
101
  setSessionStateAsync: i,
102
102
  getSessionStateAsync: r,
103
103
  setNonceAsync: a,
104
- getNonceAsync: f,
104
+ getNonceAsync: _,
105
105
  setLoginParams: (g) => {
106
106
  k[e] = g, n[`oidc.login.${e}`] = JSON.stringify(g);
107
107
  },
@@ -120,7 +120,7 @@ const m = {
120
120
  n[`oidc.code_verifier.${e}`] = g;
121
121
  },
122
122
  setDemonstratingProofOfPossessionNonce: l,
123
- getDemonstratingProofOfPossessionNonce: h,
123
+ getDemonstratingProofOfPossessionNonce: d,
124
124
  setDemonstratingProofOfPossessionJwkAsync: c,
125
125
  getDemonstratingProofOfPossessionJwkAsync: u
126
126
  };
@@ -159,7 +159,7 @@ const oe = (e, n = null, s) => {
159
159
  e.issuedAt = Ue(e, t, r);
160
160
  let u;
161
161
  e.expiresAt ? u = e.expiresAt : s === Q.access_token_invalid ? u = c : s === Q.id_token_invalid ? u = a : u = a < c ? a : c;
162
- const f = {
162
+ const _ = {
163
163
  ...e,
164
164
  idTokenPayload: r,
165
165
  accessTokenPayload: t,
@@ -168,9 +168,9 @@ const oe = (e, n = null, s) => {
168
168
  };
169
169
  if (n != null && "refreshToken" in n && !("refreshToken" in e)) {
170
170
  const l = n.refreshToken;
171
- return { ...f, refreshToken: l };
171
+ return { ..._, refreshToken: l };
172
172
  }
173
- return f;
173
+ return _;
174
174
  }, ie = (e, n, s) => {
175
175
  if (!e)
176
176
  return null;
@@ -245,7 +245,7 @@ const oe = (e, n = null, s) => {
245
245
  setInterval: setInterval.bind(e),
246
246
  clearInterval: clearInterval.bind(e)
247
247
  };
248
- }(), Y = "7.25.14";
248
+ }(), Y = "7.25.16-alpha.1772";
249
249
  let ge = null, G;
250
250
  const re = ({ milliseconds: e }) => new Promise((n) => U.setTimeout(n, e)), Te = (e = "/") => {
251
251
  try {
@@ -273,7 +273,7 @@ const re = ({ milliseconds: e }) => new Promise((n) => U.setTimeout(n, e)), Te =
273
273
  }, e.active.postMessage({ ...n, tabId: ve(n.configurationName) }, [
274
274
  o.port2
275
275
  ]);
276
- }), x = async (e, n) => {
276
+ }), N = async (e, n) => {
277
277
  const s = e.service_worker_relative_url;
278
278
  if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !s || e.service_worker_activate() === !1)
279
279
  return null;
@@ -282,108 +282,108 @@ const re = ({ milliseconds: e }) => new Promise((n) => U.setTimeout(n, e)), Te =
282
282
  e.service_worker_register ? o = await e.service_worker_register(s) : o = await navigator.serviceWorker.register(t, {
283
283
  updateViaCache: "none"
284
284
  }), o.addEventListener("updatefound", () => {
285
- const d = o.installing;
286
- X(), d == null || d.addEventListener("statechange", () => {
287
- d.state === "installed" && navigator.serviceWorker.controller && (X(), console.log("New SW waiting – skipWaiting()"), d.postMessage({ type: "SKIP_WAITING" }));
285
+ const h = o.installing;
286
+ X(), h == null || h.addEventListener("statechange", () => {
287
+ h.state === "installed" && navigator.serviceWorker.controller && (X(), console.log("New SW waiting – skipWaiting()"), h.postMessage({ type: "SKIP_WAITING" }));
288
288
  });
289
289
  }), navigator.serviceWorker.addEventListener("controllerchange", () => {
290
290
  console.log("SW controller changed – reloading page"), X(), window.location.reload();
291
291
  });
292
292
  try {
293
293
  await navigator.serviceWorker.ready, navigator.serviceWorker.controller || await b(o)({ type: "claim" });
294
- } catch (d) {
295
- return console.warn(`Failed init ServiceWorker ${d.toString()}`), null;
294
+ } catch (h) {
295
+ return console.warn(`Failed init ServiceWorker ${h.toString()}`), null;
296
296
  }
297
- const i = async (d) => b(o)({ type: "clear", data: { status: d }, configurationName: n }), r = async (d, P, S) => {
298
- const T = await b(o)({
297
+ const i = async (h) => b(o)({ type: "clear", data: { status: h }, configurationName: n }), r = async (h, P, v) => {
298
+ const E = await b(o)({
299
299
  type: "init",
300
300
  data: {
301
- oidcServerConfiguration: d,
301
+ oidcServerConfiguration: h,
302
302
  where: P,
303
303
  oidcConfiguration: {
304
- token_renew_mode: S.token_renew_mode,
305
- service_worker_convert_all_requests_to_cors: S.service_worker_convert_all_requests_to_cors
304
+ token_renew_mode: v.token_renew_mode,
305
+ service_worker_convert_all_requests_to_cors: v.service_worker_convert_all_requests_to_cors
306
306
  }
307
307
  },
308
308
  configurationName: n
309
- }), W = T.version;
309
+ }), W = E.version;
310
310
  return W !== Y && console.warn(
311
311
  `Service worker ${W} version mismatch with js client version ${Y}, unregistering and reloading`
312
312
  ), {
313
- tokens: ie(T.tokens, null, S.token_renew_mode),
314
- status: T.status
313
+ tokens: ie(E.tokens, null, v.token_renew_mode),
314
+ status: E.status
315
315
  };
316
- }, a = (d = "/") => {
317
- ge == null && (ge = "not_null", Te(d));
318
- }, c = (d) => b(o)({
316
+ }, a = (h = "/") => {
317
+ ge == null && (ge = "not_null", Te(h));
318
+ }, c = (h) => b(o)({
319
319
  type: "setSessionState",
320
- data: { sessionState: d },
320
+ data: { sessionState: h },
321
321
  configurationName: n
322
322
  }), u = async () => (await b(o)({
323
323
  type: "getSessionState",
324
324
  data: null,
325
325
  configurationName: n
326
- })).sessionState, f = (d) => (sessionStorage[`oidc.nonce.${n}`] = d.nonce, b(o)({
326
+ })).sessionState, _ = (h) => (sessionStorage[`oidc.nonce.${n}`] = h.nonce, b(o)({
327
327
  type: "setNonce",
328
- data: { nonce: d },
328
+ data: { nonce: h },
329
329
  configurationName: n
330
- })), l = async (d = !0) => {
331
- let S = (await b(o)({
330
+ })), l = async (h = !0) => {
331
+ let v = (await b(o)({
332
332
  type: "getNonce",
333
333
  data: null,
334
334
  configurationName: n
335
335
  })).nonce;
336
- return S || (S = sessionStorage[`oidc.nonce.${n}`], console.warn("nonce not found in service worker, using sessionStorage"), d && (await f(S), S = (await l(!1)).nonce)), { nonce: S };
337
- }, h = {}, _ = (d) => {
338
- h[n] = d, localStorage[`oidc.login.${n}`] = JSON.stringify(d);
336
+ return v || (v = sessionStorage[`oidc.nonce.${n}`], console.warn("nonce not found in service worker, using sessionStorage"), h && (await _(v), v = (await l(!1)).nonce)), { nonce: v };
337
+ }, d = {}, f = (h) => {
338
+ d[n] = h, localStorage[`oidc.login.${n}`] = JSON.stringify(h);
339
339
  }, k = () => {
340
- const d = localStorage[`oidc.login.${n}`];
341
- return h[n] || (h[n] = JSON.parse(d)), h[n];
342
- }, w = async (d) => {
340
+ const h = localStorage[`oidc.login.${n}`];
341
+ return d[n] || (d[n] = JSON.parse(h)), d[n];
342
+ }, A = async (h) => {
343
343
  await b(o)({
344
344
  type: "setDemonstratingProofOfPossessionNonce",
345
- data: { demonstratingProofOfPossessionNonce: d },
345
+ data: { demonstratingProofOfPossessionNonce: h },
346
346
  configurationName: n
347
347
  });
348
348
  }, y = async () => (await b(o)({
349
349
  type: "getDemonstratingProofOfPossessionNonce",
350
350
  data: null,
351
351
  configurationName: n
352
- })).demonstratingProofOfPossessionNonce, p = async (d) => {
353
- const P = JSON.stringify(d);
352
+ })).demonstratingProofOfPossessionNonce, p = async (h) => {
353
+ const P = JSON.stringify(h);
354
354
  await b(o)({
355
355
  type: "setDemonstratingProofOfPossessionJwk",
356
356
  data: { demonstratingProofOfPossessionJwkJson: P },
357
357
  configurationName: n
358
358
  });
359
- }, v = async () => {
360
- const d = await b(o)({
359
+ }, S = async () => {
360
+ const h = await b(o)({
361
361
  type: "getDemonstratingProofOfPossessionJwk",
362
362
  data: null,
363
363
  configurationName: n
364
364
  });
365
- return d.demonstratingProofOfPossessionJwkJson ? JSON.parse(d.demonstratingProofOfPossessionJwkJson) : null;
366
- }, A = async (d = !0) => {
367
- let S = (await b(o)({
365
+ return h.demonstratingProofOfPossessionJwkJson ? JSON.parse(h.demonstratingProofOfPossessionJwkJson) : null;
366
+ }, w = async (h = !0) => {
367
+ let v = (await b(o)({
368
368
  type: "getState",
369
369
  data: null,
370
370
  configurationName: n
371
371
  })).state;
372
- return S || (S = sessionStorage[`oidc.state.${n}`], console.warn("state not found in service worker, using sessionStorage"), d && (await E(S), S = await A(!1))), S;
373
- }, E = async (d) => (sessionStorage[`oidc.state.${n}`] = d, b(o)({
372
+ return v || (v = sessionStorage[`oidc.state.${n}`], console.warn("state not found in service worker, using sessionStorage"), h && (await T(v), v = await w(!1))), v;
373
+ }, T = async (h) => (sessionStorage[`oidc.state.${n}`] = h, b(o)({
374
374
  type: "setState",
375
- data: { state: d },
375
+ data: { state: h },
376
376
  configurationName: n
377
- })), g = async (d = !0) => {
378
- let S = (await b(o)({
377
+ })), g = async (h = !0) => {
378
+ let v = (await b(o)({
379
379
  type: "getCodeVerifier",
380
380
  data: null,
381
381
  configurationName: n
382
382
  })).codeVerifier;
383
- return S || (S = sessionStorage[`oidc.code_verifier.${n}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), d && (await O(S), S = await g(!1))), S;
384
- }, O = async (d) => (sessionStorage[`oidc.code_verifier.${n}`] = d, b(o)({
383
+ return v || (v = sessionStorage[`oidc.code_verifier.${n}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), h && (await O(v), v = await g(!1))), v;
384
+ }, O = async (h) => (sessionStorage[`oidc.code_verifier.${n}`] = h, b(o)({
385
385
  type: "setCodeVerifier",
386
- data: { codeVerifier: d },
386
+ data: { codeVerifier: h },
387
387
  configurationName: n
388
388
  }));
389
389
  return {
@@ -392,18 +392,18 @@ const re = ({ milliseconds: e }) => new Promise((n) => U.setTimeout(n, e)), Te =
392
392
  startKeepAliveServiceWorker: () => a(e.service_worker_keep_alive_path),
393
393
  setSessionStateAsync: c,
394
394
  getSessionStateAsync: u,
395
- setNonceAsync: f,
395
+ setNonceAsync: _,
396
396
  getNonceAsync: l,
397
- setLoginParams: _,
397
+ setLoginParams: f,
398
398
  getLoginParams: k,
399
- getStateAsync: A,
400
- setStateAsync: E,
399
+ getStateAsync: w,
400
+ setStateAsync: T,
401
401
  getCodeVerifierAsync: g,
402
402
  setCodeVerifierAsync: O,
403
- setDemonstratingProofOfPossessionNonce: w,
403
+ setDemonstratingProofOfPossessionNonce: A,
404
404
  getDemonstratingProofOfPossessionNonce: y,
405
405
  setDemonstratingProofOfPossessionJwkAsync: p,
406
- getDemonstratingProofOfPossessionJwkAsync: v
406
+ getDemonstratingProofOfPossessionJwkAsync: S
407
407
  };
408
408
  }, $ = {}, Fe = (e, n = window.sessionStorage, s) => {
409
409
  if (!$[e] && n) {
@@ -467,8 +467,8 @@ const Je = {
467
467
  // @ts-ignore
468
468
  // JWT "claims" are really a JSON-defined JWS "payload"
469
469
  payload: ye(JSON.stringify(t))
470
- }, a = o.importKeyAlgorithm, c = !0, u = ["sign"], f = await e.crypto.subtle.importKey("jwk", n, a, c, u), l = Ee(`${r.protected}.${r.payload}`), h = o.signAlgorithm, _ = await e.crypto.subtle.sign(h, f, l);
471
- return r.signature = ae(new Uint8Array(_)), `${r.protected}.${r.payload}.${r.signature}`;
470
+ }, a = o.importKeyAlgorithm, c = !0, u = ["sign"], _ = await e.crypto.subtle.importKey("jwk", n, a, c, u), l = Ee(`${r.protected}.${r.payload}`), d = o.signAlgorithm, f = await e.crypto.subtle.sign(d, _, l);
471
+ return r.signature = ae(new Uint8Array(f)), `${r.protected}.${r.payload}.${r.signature}`;
472
472
  }, He = { sign: Be }, je = (e) => async (n) => {
473
473
  const s = n, t = !0, o = ["sign", "verify"], i = await e.crypto.subtle.generateKey(s, t, o);
474
474
  return await e.crypto.subtle.exportKey("jwk", i.privateKey);
@@ -586,12 +586,12 @@ const nn = (e) => {
586
586
  token_type_hint: t,
587
587
  client_id: o
588
588
  };
589
- for (const [l, h] of Object.entries(i))
590
- a[l] === void 0 && (a[l] = h);
589
+ for (const [l, d] of Object.entries(i))
590
+ a[l] === void 0 && (a[l] = d);
591
591
  const c = [];
592
592
  for (const l in a) {
593
- const h = encodeURIComponent(l), _ = encodeURIComponent(a[l]);
594
- c.push(`${h}=${_}`);
593
+ const d = encodeURIComponent(l), f = encodeURIComponent(a[l]);
594
+ c.push(`${d}=${f}`);
595
595
  }
596
596
  const u = c.join("&");
597
597
  return (await B(e)(
@@ -608,14 +608,14 @@ const nn = (e) => {
608
608
  success: !0
609
609
  };
610
610
  }, on = (e) => async (n, s, t, o, i = {}, r, a = 1e4) => {
611
- for (const [_, k] of Object.entries(t))
612
- s[_] === void 0 && (s[_] = k);
611
+ for (const [f, k] of Object.entries(t))
612
+ s[f] === void 0 && (s[f] = k);
613
613
  const c = [];
614
- for (const _ in s) {
615
- const k = encodeURIComponent(_), w = encodeURIComponent(s[_]);
616
- c.push(`${k}=${w}`);
614
+ for (const f in s) {
615
+ const k = encodeURIComponent(f), A = encodeURIComponent(s[f]);
616
+ c.push(`${k}=${A}`);
617
617
  }
618
- const u = c.join("&"), f = await B(e)(
618
+ const u = c.join("&"), _ = await B(e)(
619
619
  n,
620
620
  {
621
621
  method: "POST",
@@ -627,21 +627,21 @@ const nn = (e) => {
627
627
  },
628
628
  a
629
629
  );
630
- if (f.status !== 200)
630
+ if (_.status !== 200)
631
631
  return {
632
632
  success: !1,
633
- status: f.status,
633
+ status: _.status,
634
634
  demonstratingProofOfPossessionNonce: null
635
635
  };
636
- const l = await f.json();
637
- let h = null;
638
- return f.headers.has(q) && (h = f.headers.get(
636
+ const l = await _.json();
637
+ let d = null;
638
+ return _.headers.has(q) && (d = _.headers.get(
639
639
  q
640
640
  )), {
641
641
  success: !0,
642
- status: f.status,
642
+ status: _.status,
643
643
  data: ie(l, o, r),
644
- demonstratingProofOfPossessionNonce: h
644
+ demonstratingProofOfPossessionNonce: d
645
645
  };
646
646
  }, rn = (e, n) => async (s, t) => {
647
647
  t = t ? { ...t } : {};
@@ -656,8 +656,8 @@ const nn = (e) => {
656
656
  s = s ? { ...s } : {}, s.code_verifier = await e.getCodeVerifierAsync();
657
657
  const r = [];
658
658
  for (const l in s) {
659
- const h = encodeURIComponent(l), _ = encodeURIComponent(s[l]);
660
- r.push(`${h}=${_}`);
659
+ const d = encodeURIComponent(l), f = encodeURIComponent(s[l]);
660
+ r.push(`${d}=${f}`);
661
661
  }
662
662
  const a = r.join("&"), c = await B(fetch)(
663
663
  n,
@@ -677,12 +677,12 @@ const nn = (e) => {
677
677
  c.headers.has(q) && (u = c.headers.get(
678
678
  q
679
679
  ));
680
- const f = await c.json();
680
+ const _ = await c.json();
681
681
  return {
682
682
  success: !0,
683
683
  data: {
684
684
  state: s.state,
685
- tokens: ie(f, null, o),
685
+ tokens: ie(_, null, o),
686
686
  demonstratingProofOfPossessionNonce: u
687
687
  }
688
688
  };
@@ -698,12 +698,12 @@ async function me(e, n, s, t = null) {
698
698
  s,
699
699
  t
700
700
  );
701
- return await x(e.configuration, e.configurationName) || await C(e.configurationName, e.configuration.storage).setTokens(e.tokens), e.tokens ? i : (await e.destroyAsync(r), null);
701
+ return await N(e.configuration, e.configurationName) || await C(e.configurationName, e.configuration.storage).setTokens(e.tokens), e.tokens ? i : (await e.destroyAsync(r), null);
702
702
  }
703
703
  async function Ce(e, n = !1, s = null, t = null) {
704
704
  const o = e.configuration, i = `${o.client_id}_${e.configurationName}_${o.authority}`;
705
705
  let r;
706
- const a = await x(e.configuration, e.configurationName);
706
+ const a = await N(e.configuration, e.configurationName);
707
707
  if ((o == null ? void 0 : o.storage) === (window == null ? void 0 : window.sessionStorage) && !a || !navigator.locks)
708
708
  r = await me(e, n, s, t);
709
709
  else {
@@ -712,7 +712,7 @@ async function Ce(e, n = !1, s = null, t = null) {
712
712
  c = await navigator.locks.request(
713
713
  i,
714
714
  { ifAvailable: !0 },
715
- async (u) => u ? await me(e, n, s, t) : (e.publishEvent(N.eventNames.syncTokensAsync_lock_not_available, {
715
+ async (u) => u ? await me(e, n, s, t) : (e.publishEvent(x.eventNames.syncTokensAsync_lock_not_available, {
716
716
  lock: "lock not available"
717
717
  }), "retry")
718
718
  );
@@ -724,7 +724,7 @@ const J = (e, n, s = null, t = null) => {
724
724
  const o = e.configuration.refresh_time_before_tokens_expiration_in_second;
725
725
  return e.timeoutId && U.clearTimeout(e.timeoutId), U.setTimeout(async () => {
726
726
  const r = { timeLeft: F(o, n) };
727
- e.publishEvent(N.eventNames.token_timer, r), await Ce(e, !1, s, t);
727
+ e.publishEvent(x.eventNames.token_timer, r), await Ce(e, !1, s, t);
728
728
  }, 1e3);
729
729
  }, L = {
730
730
  FORCE_REFRESH: "FORCE_REFRESH",
@@ -742,9 +742,9 @@ const J = (e, n, s = null, t = null) => {
742
742
  const a = await e.initAsync(
743
743
  n.authority,
744
744
  n.authority_configuration
745
- ), c = await x(n, s);
745
+ ), c = await N(n, s);
746
746
  if (c) {
747
- const { status: l, tokens: h } = await c.initAsync(
747
+ const { status: l, tokens: d } = await c.initAsync(
748
748
  a,
749
749
  "syncTokensAsync",
750
750
  n
@@ -753,38 +753,38 @@ const J = (e, n, s = null, t = null) => {
753
753
  return { tokens: null, status: "LOGOUT_FROM_ANOTHER_TAB", nonce: i };
754
754
  if (l === "SESSIONS_LOST")
755
755
  return { tokens: null, status: "SESSIONS_LOST", nonce: i };
756
- if (!l || !h)
756
+ if (!l || !d)
757
757
  return { tokens: null, status: "REQUIRE_SYNC_TOKENS", nonce: i };
758
- if (h.issuedAt !== t.issuedAt) {
758
+ if (d.issuedAt !== t.issuedAt) {
759
759
  const k = F(
760
760
  n.refresh_time_before_tokens_expiration_in_second,
761
- h.expiresAt
762
- ) > 0 ? "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" : "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID", w = await c.getNonceAsync();
763
- return { tokens: h, status: k, nonce: w };
761
+ d.expiresAt
762
+ ) > 0 ? "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" : "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID", A = await c.getNonceAsync();
763
+ return { tokens: d, status: k, nonce: A };
764
764
  }
765
765
  r = await c.getNonceAsync();
766
766
  } else {
767
- const l = C(s, n.storage ?? sessionStorage), h = await l.initAsync();
768
- let { tokens: _ } = h;
769
- const { status: k } = h;
770
- if (_ && (_ = oe(_, e.tokens, n.token_renew_mode)), _) {
767
+ const l = C(s, n.storage ?? sessionStorage), d = await l.initAsync();
768
+ let { tokens: f } = d;
769
+ const { status: k } = d;
770
+ if (f && (f = oe(f, e.tokens, n.token_renew_mode)), f) {
771
771
  if (k === "SESSIONS_LOST")
772
772
  return { tokens: null, status: "SESSIONS_LOST", nonce: i };
773
- if (_.issuedAt !== t.issuedAt) {
773
+ if (f.issuedAt !== t.issuedAt) {
774
774
  const y = F(
775
775
  n.refresh_time_before_tokens_expiration_in_second,
776
- _.expiresAt
776
+ f.expiresAt
777
777
  ) > 0 ? "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" : "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID", p = await l.getNonceAsync();
778
- return { tokens: _, status: y, nonce: p };
778
+ return { tokens: f, status: y, nonce: p };
779
779
  }
780
780
  } else return { tokens: null, status: "LOGOUT_FROM_ANOTHER_TAB", nonce: i };
781
781
  r = await l.getNonceAsync();
782
782
  }
783
- const f = F(
783
+ const _ = F(
784
784
  n.refresh_time_before_tokens_expiration_in_second,
785
785
  t.expiresAt
786
786
  ) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
787
- return o ? { tokens: t, status: "FORCE_REFRESH", nonce: r } : { tokens: t, status: f, nonce: r };
787
+ return o ? { tokens: t, status: "FORCE_REFRESH", nonce: r } : { tokens: t, status: _, nonce: r };
788
788
  }, H = (e) => async (n, s = 0, t = 0, o = !1, i = null, r = null) => {
789
789
  if (!navigator.onLine && document.hidden)
790
790
  return { tokens: e.tokens, status: "GIVE_UP" };
@@ -794,28 +794,31 @@ const J = (e, n, s = null, t = null) => {
794
794
  await re({ milliseconds: 1e3 }), a--, e.publishEvent(m.refreshTokensAsync, {
795
795
  message: `wait because navigator is offline try ${a}`
796
796
  });
797
- const f = document.hidden, l = f ? s : s + 1, h = f ? t + 1 : t;
797
+ const _ = document.hidden, l = _ ? s : s + 1, d = _ ? t + 1 : t;
798
798
  if (s >= c || t >= u)
799
799
  return n(null), e.publishEvent(m.refreshTokensAsync_error, { message: "refresh token" }), { tokens: null, status: "SESSION_LOST" };
800
800
  i || (i = {});
801
- const _ = e.configuration, k = (y, p = null, v = null) => ce(
801
+ const f = e.configuration, k = (y, p = null, S = null) => ce(
802
802
  e.configurationName,
803
803
  e.configuration,
804
804
  e.publishEvent.bind(e)
805
- )(y, p, v), w = async () => {
805
+ )(y, p, S), A = async () => {
806
806
  try {
807
807
  let y;
808
- const p = await x(_, e.configurationName);
809
- p ? y = p.getLoginParams() : y = C(e.configurationName, _.storage).getLoginParams();
810
- const v = await k({
811
- ...y.extras,
812
- ...i,
813
- prompt: "none",
814
- scope: r
815
- });
816
- return v ? v.error ? (n(null), e.publishEvent(m.refreshTokensAsync_error, {
808
+ const p = await N(f, e.configurationName);
809
+ p ? y = p.getLoginParams() : y = C(e.configurationName, f.storage).getLoginParams(), console.log("loginParams:", y), console.log("extras:", i);
810
+ const S = {};
811
+ if (y && y.extras)
812
+ for (const [T, g] of Object.entries(y.extras))
813
+ S[T] = g;
814
+ if (i)
815
+ for (const [T, g] of Object.entries(i))
816
+ S[T] = g;
817
+ S.prompt = "none", r && (S.scope = r), S.scope = null, console.log("silentLoginInput:", S);
818
+ const w = await k(S);
819
+ return w ? w.error ? (n(null), e.publishEvent(m.refreshTokensAsync_error, {
817
820
  message: "refresh token silent"
818
- }), { tokens: null, status: "SESSION_LOST" }) : (n(v.tokens), e.publishEvent(N.eventNames.token_renewed, {}), { tokens: v.tokens, status: "LOGGED" }) : (n(null), e.publishEvent(m.refreshTokensAsync_error, {
821
+ }), { tokens: null, status: "SESSION_LOST" }) : (n(w.tokens), e.publishEvent(x.eventNames.token_renewed, {}), { tokens: w.tokens, status: "LOGGED" }) : (n(null), e.publishEvent(m.refreshTokensAsync_error, {
819
822
  message: "refresh token silent not active"
820
823
  }), { tokens: null, status: "SESSION_LOST" });
821
824
  } catch (y) {
@@ -825,7 +828,7 @@ const J = (e, n, s = null, t = null) => {
825
828
  }), await H(e)(
826
829
  n,
827
830
  l,
828
- h,
831
+ d,
829
832
  o,
830
833
  i,
831
834
  r
@@ -833,13 +836,13 @@ const J = (e, n, s = null, t = null) => {
833
836
  }
834
837
  };
835
838
  try {
836
- const { status: y, tokens: p, nonce: v } = await cn(e)(
837
- _,
839
+ const { status: y, tokens: p, nonce: S } = await cn(e)(
840
+ f,
838
841
  e.configurationName,
839
842
  e.tokens,
840
843
  o
841
844
  );
842
- switch (y) {
845
+ switch (console.log("status:", y), console.log("tokens:", p), console.log("nonce:", S), y) {
843
846
  case L.SESSION_LOST:
844
847
  return n(null), e.publishEvent(m.refreshTokensAsync_error, {
845
848
  message: "refresh token session lost"
@@ -849,7 +852,7 @@ const J = (e, n, s = null, t = null) => {
849
852
  case L.TOKENS_VALID:
850
853
  return n(p), { tokens: p, status: "LOGGED_IN" };
851
854
  case L.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID:
852
- return n(p), e.publishEvent(N.eventNames.token_renewed, {
855
+ return n(p), e.publishEvent(x.eventNames.token_renewed, {
853
856
  reason: "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID"
854
857
  }), { tokens: p, status: "LOGGED_IN" };
855
858
  case L.LOGOUT_FROM_ANOTHER_TAB:
@@ -857,9 +860,9 @@ const J = (e, n, s = null, t = null) => {
857
860
  status: "session syncTokensAsync"
858
861
  }), { tokens: null, status: "LOGGED_OUT" };
859
862
  case L.REQUIRE_SYNC_TOKENS:
860
- return _.token_automatic_renew_mode == M.AutomaticOnlyWhenFetchExecuted && L.FORCE_REFRESH !== y ? (e.publishEvent(m.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" }) : (e.publishEvent(m.refreshTokensAsync_begin, { tryNumber: s }), await w());
863
+ return f.token_automatic_renew_mode == M.AutomaticOnlyWhenFetchExecuted && L.FORCE_REFRESH !== y ? (e.publishEvent(m.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" }) : (e.publishEvent(m.refreshTokensAsync_begin, { tryNumber: s }), await A());
861
864
  default: {
862
- if (_.token_automatic_renew_mode == M.AutomaticOnlyWhenFetchExecuted && L.FORCE_REFRESH !== y)
865
+ if (f.token_automatic_renew_mode == M.AutomaticOnlyWhenFetchExecuted && L.FORCE_REFRESH !== y)
863
866
  return e.publishEvent(m.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" };
864
867
  if (e.publishEvent(m.refreshTokensAsync_begin, {
865
868
  refreshToken: p.refreshToken,
@@ -867,55 +870,55 @@ const J = (e, n, s = null, t = null) => {
867
870
  tryNumber: s,
868
871
  backgroundTry: t
869
872
  }), !p.refreshToken)
870
- return await w();
871
- const A = _.client_id, E = _.redirect_uri, g = _.authority, d = { ..._.token_request_extras ? _.token_request_extras : {} };
872
- for (const [S, T] of Object.entries(i))
873
- S.endsWith(":token_request") && (d[S.replace(":token_request", "")] = T);
873
+ return await A();
874
+ const w = f.client_id, T = f.redirect_uri, g = f.authority, h = { ...f.token_request_extras ? f.token_request_extras : {} };
875
+ for (const [v, E] of Object.entries(i))
876
+ v.endsWith(":token_request") && (h[v.replace(":token_request", "")] = E);
874
877
  return await (async () => {
875
- const S = {
876
- client_id: A,
877
- redirect_uri: E,
878
+ const v = {
879
+ client_id: w,
880
+ redirect_uri: T,
878
881
  grant_type: "refresh_token",
879
882
  refresh_token: p.refreshToken
880
- }, T = await e.initAsync(
883
+ }, E = await e.initAsync(
881
884
  g,
882
- _.authority_configuration
883
- ), W = document.hidden ? 1e4 : 3e4 * 10, le = T.tokenEndpoint, ue = {};
884
- _.demonstrating_proof_of_possession && (ue.DPoP = await e.generateDemonstrationOfProofOfPossessionAsync(
885
+ f.authority_configuration
886
+ ), W = document.hidden ? 1e4 : 3e4 * 10, le = E.tokenEndpoint, ue = {};
887
+ f.demonstrating_proof_of_possession && (ue.DPoP = await e.generateDemonstrationOfProofOfPossessionAsync(
885
888
  p.accessToken,
886
889
  le,
887
890
  "POST"
888
891
  ));
889
892
  const I = await on(e.getFetch())(
890
893
  le,
891
- S,
892
- d,
894
+ v,
895
+ h,
893
896
  p,
894
897
  ue,
895
- _.token_renew_mode,
898
+ f.token_renew_mode,
896
899
  W
897
900
  );
898
901
  if (I.success) {
899
902
  const { isValid: We, reason: Le } = Se(
900
903
  I.data,
901
- v.nonce,
902
- T
904
+ S.nonce,
905
+ E
903
906
  );
904
907
  if (!We)
905
908
  return n(null), e.publishEvent(m.refreshTokensAsync_error, {
906
909
  message: `refresh token return not valid tokens, reason: ${Le}`
907
910
  }), { tokens: null, status: "SESSION_LOST" };
908
911
  if (n(I.data), I.demonstratingProofOfPossessionNonce) {
909
- const _e = await x(_, e.configurationName);
912
+ const _e = await N(f, e.configurationName);
910
913
  _e ? await _e.setDemonstratingProofOfPossessionNonce(
911
914
  I.demonstratingProofOfPossessionNonce
912
- ) : await C(e.configurationName, _.storage).setDemonstratingProofOfPossessionNonce(
915
+ ) : await C(e.configurationName, f.storage).setDemonstratingProofOfPossessionNonce(
913
916
  I.demonstratingProofOfPossessionNonce
914
917
  );
915
918
  }
916
919
  return e.publishEvent(m.refreshTokensAsync_end, {
917
920
  success: I.success
918
- }), e.publishEvent(N.eventNames.token_renewed, { reason: "REFRESH_TOKEN" }), { tokens: I.data, status: "LOGGED_IN" };
921
+ }), e.publishEvent(x.eventNames.token_renewed, { reason: "REFRESH_TOKEN" }), { tokens: I.data, status: "LOGGED_IN" };
919
922
  } else
920
923
  return e.publishEvent(m.refreshTokensAsync_silent_error, {
921
924
  message: "bad request",
@@ -925,7 +928,7 @@ const J = (e, n, s = null, t = null) => {
925
928
  }), { tokens: null, status: "SESSION_LOST" }) : await H(e)(
926
929
  n,
927
930
  l,
928
- h,
931
+ d,
929
932
  o,
930
933
  i,
931
934
  r
@@ -937,16 +940,16 @@ const J = (e, n, s = null, t = null) => {
937
940
  return console.error(y), e.publishEvent(m.refreshTokensAsync_silent_error, {
938
941
  message: "exception",
939
942
  exception: y.message
940
- }), new Promise((p, v) => {
943
+ }), new Promise((p, S) => {
941
944
  setTimeout(() => {
942
945
  H(e)(
943
946
  n,
944
947
  l,
945
- h,
948
+ d,
946
949
  o,
947
950
  i,
948
951
  r
949
- ).then(p).catch(v);
952
+ ).then(p).catch(S);
950
953
  }, 1e3);
951
954
  });
952
955
  }
@@ -957,38 +960,38 @@ const J = (e, n, s = null, t = null) => {
957
960
  s(m.silentLoginAsync_begin, {});
958
961
  let r = "";
959
962
  if (o && (t == null && (t = {}), t.state = o), i != null && (t == null && (t = {}), t.scope = i), t != null)
960
- for (const [l, h] of Object.entries(t))
961
- r === "" ? r = `?${encodeURIComponent(l)}=${encodeURIComponent(h)}` : r += `&${encodeURIComponent(l)}=${encodeURIComponent(h)}`;
962
- const a = n.silent_login_uri + r, c = a.indexOf("/", a.indexOf("//") + 2), u = a.substring(0, c), f = document.createElement("iframe");
963
- return f.width = "0px", f.height = "0px", f.id = `${e}_oidc_iframe`, f.setAttribute("src", a), document.body.appendChild(f), new Promise((l, h) => {
964
- let _ = !1;
963
+ for (const [l, d] of Object.entries(t))
964
+ r === "" ? r = `?${encodeURIComponent(l)}=${encodeURIComponent(d)}` : r += `&${encodeURIComponent(l)}=${encodeURIComponent(d)}`;
965
+ const a = n.silent_login_uri + r, c = a.indexOf("/", a.indexOf("//") + 2), u = a.substring(0, c), _ = document.createElement("iframe");
966
+ return _.width = "0px", _.height = "0px", _.id = `${e}_oidc_iframe`, _.setAttribute("src", a), console.log("silent login link: " + a), console.log(`Silent login iframe: ${_.id}`), console.log(window.location.origin), _.style.display = "none", document.body.appendChild(_), new Promise((l, d) => {
967
+ let f = !1;
965
968
  const k = () => {
966
- window.removeEventListener("message", w), f.remove(), _ = !0;
967
- }, w = (y) => {
968
- if (y.origin === u && y.source === f.contentWindow) {
969
- const p = `${e}_oidc_tokens:`, v = `${e}_oidc_error:`, A = `${e}_oidc_exception:`, E = y.data;
970
- if (E && typeof E == "string" && !_) {
971
- if (E.startsWith(p)) {
969
+ window.removeEventListener("message", A), _.remove(), f = !0;
970
+ }, A = (y) => {
971
+ if (y.origin === u && y.source === _.contentWindow) {
972
+ const p = `${e}_oidc_tokens:`, S = `${e}_oidc_error:`, w = `${e}_oidc_exception:`, T = y.data;
973
+ if (T && typeof T == "string" && !f) {
974
+ if (T.startsWith(p)) {
972
975
  const g = JSON.parse(y.data.replace(p, ""));
973
976
  s(m.silentLoginAsync_end, {}), l(g), k();
974
- } else if (E.startsWith(v)) {
975
- const g = JSON.parse(y.data.replace(v, ""));
977
+ } else if (T.startsWith(S)) {
978
+ const g = JSON.parse(y.data.replace(S, ""));
976
979
  s(m.silentLoginAsync_error, g), l({ error: "oidc_" + g.error, tokens: null, sessionState: null }), k();
977
- } else if (E.startsWith(A)) {
978
- const g = JSON.parse(y.data.replace(A, ""));
979
- s(m.silentLoginAsync_error, g), h(new Error(g.error)), k();
980
+ } else if (T.startsWith(w)) {
981
+ const g = JSON.parse(y.data.replace(w, ""));
982
+ s(m.silentLoginAsync_error, g), d(new Error(g.error)), k();
980
983
  }
981
984
  }
982
985
  }
983
986
  };
984
987
  try {
985
- window.addEventListener("message", w);
988
+ window.addEventListener("message", A);
986
989
  const y = n.silent_login_timeout;
987
990
  setTimeout(() => {
988
- _ || (k(), s(m.silentLoginAsync_error, { reason: "timeout" }), h(new Error("timeout")));
991
+ f || (k(), s(m.silentLoginAsync_error, { reason: "timeout" }), d(new Error("timeout")));
989
992
  }, y);
990
993
  } catch (y) {
991
- k(), s(m.silentLoginAsync_error, y), h(y);
994
+ k(), s(m.silentLoginAsync_error, y), d(y);
992
995
  }
993
996
  });
994
997
  } catch (r) {
@@ -996,9 +999,9 @@ const J = (e, n, s = null, t = null) => {
996
999
  }
997
1000
  }, ln = (e, n, s, t, o) => (i = null, r = void 0) => {
998
1001
  i = { ...i };
999
- const a = (u, f, l) => ce(n, s, t.bind(o))(
1002
+ const a = (u, _, l) => ce(n, s, t.bind(o))(
1000
1003
  u,
1001
- f,
1004
+ _,
1002
1005
  l
1003
1006
  );
1004
1007
  return (async () => {
@@ -1006,9 +1009,9 @@ const J = (e, n, s = null, t = null) => {
1006
1009
  let u;
1007
1010
  i && "state" in i && (u = i.state, delete i.state);
1008
1011
  try {
1009
- const f = s.extras ? { ...s.extras, ...i } : i, l = await a(
1012
+ const _ = s.extras ? { ...s.extras, ...i } : i, l = await a(
1010
1013
  {
1011
- ...f,
1014
+ ..._,
1012
1015
  prompt: "none"
1013
1016
  },
1014
1017
  u,
@@ -1016,35 +1019,35 @@ const J = (e, n, s = null, t = null) => {
1016
1019
  );
1017
1020
  if (l)
1018
1021
  return o.tokens = l.tokens, t(m.token_acquired, {}), o.timeoutId = J(o, o.tokens.expiresAt, i, r), {};
1019
- } catch (f) {
1020
- return f;
1022
+ } catch (_) {
1023
+ return _;
1021
1024
  }
1022
1025
  })();
1023
1026
  }, un = (e, n, s) => (t, o, i, r = !1) => {
1024
- const a = (c, u = void 0, f = void 0) => ce(e.configurationName, s, e.publishEvent.bind(e))(
1027
+ const a = (c, u = void 0, _ = void 0) => ce(e.configurationName, s, e.publishEvent.bind(e))(
1025
1028
  c,
1026
1029
  u,
1027
- f
1030
+ _
1028
1031
  );
1029
1032
  return new Promise((c, u) => {
1030
1033
  if (s.silent_login_uri && s.silent_redirect_uri && s.monitor_session && t && i && !r) {
1031
- const f = () => {
1034
+ const _ = () => {
1032
1035
  e.checkSessionIFrame.stop();
1033
1036
  const l = e.tokens;
1034
1037
  if (l === null)
1035
1038
  return;
1036
- const h = l.idToken, _ = l.idTokenPayload;
1039
+ const d = l.idToken, f = l.idTokenPayload;
1037
1040
  return a({
1038
1041
  prompt: "none",
1039
- id_token_hint: h,
1042
+ id_token_hint: d,
1040
1043
  scope: s.scope || "openid"
1041
1044
  }).then((k) => {
1042
1045
  if (k.error)
1043
1046
  throw new Error(k.error);
1044
- const w = k.tokens.idTokenPayload;
1045
- if (_.sub === w.sub) {
1047
+ const A = k.tokens.idTokenPayload;
1048
+ if (f.sub === A.sub) {
1046
1049
  const y = k.sessionState;
1047
- e.checkSessionIFrame.start(k.sessionState), _.sid === w.sid ? console.debug(
1050
+ e.checkSessionIFrame.start(k.sessionState), f.sid === A.sid ? console.debug(
1048
1051
  "SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:",
1049
1052
  y
1050
1053
  ) : console.debug(
@@ -1054,19 +1057,19 @@ const J = (e, n, s = null, t = null) => {
1054
1057
  } else
1055
1058
  console.debug(
1056
1059
  "SessionMonitor._callback: Different subject signed into OP:",
1057
- w.sub
1060
+ A.sub
1058
1061
  );
1059
1062
  }).catch(async (k) => {
1060
1063
  console.warn(
1061
1064
  "SessionMonitor._callback: Silent login failed, logging out other tabs:",
1062
1065
  k
1063
1066
  );
1064
- for (const [, w] of Object.entries(n))
1065
- await w.logoutOtherTabAsync(s.client_id, _.sub);
1067
+ for (const [, A] of Object.entries(n))
1068
+ await A.logoutOtherTabAsync(s.client_id, f.sub);
1066
1069
  });
1067
1070
  };
1068
1071
  e.checkSessionIFrame = new De(
1069
- f,
1072
+ _,
1070
1073
  o,
1071
1074
  t
1072
1075
  ), e.checkSessionIFrame.load().then(() => {
@@ -1171,7 +1174,7 @@ const hn = () => {
1171
1174
  s.authority,
1172
1175
  s.authority_configuration
1173
1176
  );
1174
- if (n = await x(s, e.configurationName), n) {
1177
+ if (n = await N(s, e.configurationName), n) {
1175
1178
  const { tokens: o } = await n.initAsync(
1176
1179
  t,
1177
1180
  "tryKeepExistingSessionAsync",
@@ -1235,7 +1238,7 @@ const hn = () => {
1235
1238
  "tokens inside ServiceWorker are invalid"
1236
1239
  ), !1;
1237
1240
  }
1238
- }, xe = (e) => {
1241
+ }, Ne = (e) => {
1239
1242
  const n = e.match(
1240
1243
  // eslint-disable-next-line no-useless-escape
1241
1244
  /^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/
@@ -1258,13 +1261,13 @@ const hn = () => {
1258
1261
  hash: t
1259
1262
  };
1260
1263
  }, Pn = (e) => {
1261
- const n = xe(e);
1264
+ const n = Ne(e);
1262
1265
  let { path: s } = n;
1263
1266
  s.endsWith("/") && (s = s.slice(0, -1));
1264
1267
  let { hash: t } = n;
1265
1268
  return t === "#_=_" && (t = ""), t && (s += t), s;
1266
1269
  }, se = (e) => {
1267
- const n = xe(e), { search: s } = n;
1270
+ const n = Ne(e), { search: s } = n;
1268
1271
  return yn(s);
1269
1272
  }, yn = (e) => {
1270
1273
  const n = {};
@@ -1278,37 +1281,37 @@ const hn = () => {
1278
1281
  return r = { ...r }, (async () => {
1279
1282
  const l = i || o.getPath();
1280
1283
  if ("state" in r || (r.state = ee(16)), s(m.loginAsync_begin, {}), r)
1281
- for (const h of Object.keys(r))
1282
- h.endsWith(":token_request") && delete r[h];
1284
+ for (const d of Object.keys(r))
1285
+ d.endsWith(":token_request") && delete r[d];
1283
1286
  try {
1284
- const h = a ? n.silent_redirect_uri : n.redirect_uri;
1287
+ const d = a ? n.silent_redirect_uri : n.redirect_uri;
1285
1288
  c || (c = n.scope);
1286
- const _ = n.extras ? { ...n.extras, ...r } : r;
1287
- _.nonce || (_.nonce = ee(12));
1288
- const k = { nonce: _.nonce }, w = await x(n, e), y = await t(
1289
+ const f = n.extras ? { ...n.extras, ...r } : r;
1290
+ f.nonce || (f.nonce = ee(12));
1291
+ const k = { nonce: f.nonce }, A = await N(n, e), y = await t(
1289
1292
  n.authority,
1290
1293
  n.authority_configuration
1291
1294
  );
1292
1295
  let p;
1293
- if (w)
1294
- w.setLoginParams({ callbackPath: l, extras: u, scope: c }), await w.initAsync(y, "loginAsync", n), await w.setNonceAsync(k), w.startKeepAliveServiceWorker(), p = w;
1296
+ if (A)
1297
+ A.setLoginParams({ callbackPath: l, extras: u, scope: c }), await A.initAsync(y, "loginAsync", n), await A.setNonceAsync(k), A.startKeepAliveServiceWorker(), p = A;
1295
1298
  else {
1296
- const A = C(e, n.storage ?? sessionStorage);
1297
- A.setLoginParams({ callbackPath: l, extras: u, scope: c }), await A.setNonceAsync(k), p = A;
1299
+ const w = C(e, n.storage ?? sessionStorage);
1300
+ w.setLoginParams({ callbackPath: l, extras: u, scope: c }), await w.setNonceAsync(k), p = w;
1298
1301
  }
1299
- const v = {
1302
+ const S = {
1300
1303
  client_id: n.client_id,
1301
- redirect_uri: h,
1304
+ redirect_uri: d,
1302
1305
  scope: c,
1303
1306
  response_type: "code",
1304
- ..._
1307
+ ...f
1305
1308
  };
1306
1309
  await rn(p, o)(
1307
1310
  y.authorizationEndpoint,
1308
- v
1311
+ S
1309
1312
  );
1310
- } catch (h) {
1311
- throw s(m.loginAsync_error, h), h;
1313
+ } catch (d) {
1314
+ throw s(m.loginAsync_error, d), d;
1312
1315
  }
1313
1316
  })();
1314
1317
  }, mn = (e) => async (n = !1) => {
@@ -1317,16 +1320,16 @@ const hn = () => {
1317
1320
  const s = e.configuration, t = s.client_id, o = n ? s.silent_redirect_uri : s.redirect_uri, i = s.authority, r = s.token_request_timeout, a = await e.initAsync(
1318
1321
  i,
1319
1322
  s.authority_configuration
1320
- ), c = e.location.getCurrentHref(), u = se(c), f = u.session_state, l = await x(s, e.configurationName);
1321
- let h, _, k, w;
1323
+ ), c = e.location.getCurrentHref(), u = se(c), _ = u.session_state, l = await N(s, e.configurationName);
1324
+ let d, f, k, A;
1322
1325
  if (l)
1323
- await l.initAsync(a, "loginCallbackAsync", s), await l.setSessionStateAsync(f), _ = await l.getNonceAsync(), k = l.getLoginParams(), w = await l.getStateAsync(), l.startKeepAliveServiceWorker(), h = l;
1326
+ await l.initAsync(a, "loginCallbackAsync", s), await l.setSessionStateAsync(_), f = await l.getNonceAsync(), k = l.getLoginParams(), A = await l.getStateAsync(), l.startKeepAliveServiceWorker(), d = l;
1324
1327
  else {
1325
- const T = C(
1328
+ const E = C(
1326
1329
  e.configurationName,
1327
1330
  s.storage ?? sessionStorage
1328
1331
  );
1329
- await T.setSessionStateAsync(f), _ = await T.getNonceAsync(), k = T.getLoginParams(), w = await T.getStateAsync(), h = T;
1332
+ await E.setSessionStateAsync(_), f = await E.getNonceAsync(), k = E.getLoginParams(), A = await E.getStateAsync(), d = E;
1330
1333
  }
1331
1334
  if (u.error || u.error_description)
1332
1335
  throw new Error(
@@ -1336,8 +1339,8 @@ const hn = () => {
1336
1339
  throw console.error(), new Error(
1337
1340
  `Issuer not valid (expected: ${a.issuer}, received: ${u.iss})`
1338
1341
  );
1339
- if (u.state && u.state !== w)
1340
- throw new Error(`State not valid (expected: ${w}, received: ${u.state})`);
1342
+ if (u.state && u.state !== A)
1343
+ throw new Error(`State not valid (expected: ${A}, received: ${u.state})`);
1341
1344
  const y = {
1342
1345
  code: u.code,
1343
1346
  grant_type: "authorization_code",
@@ -1345,63 +1348,63 @@ const hn = () => {
1345
1348
  redirect_uri: o
1346
1349
  }, p = {};
1347
1350
  if (s.token_request_extras)
1348
- for (const [T, W] of Object.entries(s.token_request_extras))
1349
- p[T] = W;
1351
+ for (const [E, W] of Object.entries(s.token_request_extras))
1352
+ p[E] = W;
1350
1353
  if (k != null && k.extras)
1351
- for (const [T, W] of Object.entries(k.extras))
1352
- T.endsWith(":token_request") && (p[T.replace(":token_request", "")] = W);
1353
- const v = a.tokenEndpoint, A = {};
1354
+ for (const [E, W] of Object.entries(k.extras))
1355
+ E.endsWith(":token_request") && (p[E.replace(":token_request", "")] = W);
1356
+ const S = a.tokenEndpoint, w = {};
1354
1357
  if (s.demonstrating_proof_of_possession)
1355
1358
  if (l)
1356
- A.DPoP = `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${e.configurationName}`;
1359
+ w.DPoP = `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${e.configurationName}`;
1357
1360
  else {
1358
- const T = await ze(window)(
1361
+ const E = await ze(window)(
1359
1362
  s.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm
1360
1363
  );
1361
- await C(e.configurationName, s.storage).setDemonstratingProofOfPossessionJwkAsync(T), A.DPoP = await Oe(window)(
1364
+ await C(e.configurationName, s.storage).setDemonstratingProofOfPossessionJwkAsync(E), w.DPoP = await Oe(window)(
1362
1365
  s.demonstrating_proof_of_possession_configuration
1363
- )(T, "POST", v);
1366
+ )(E, "POST", S);
1364
1367
  }
1365
- const E = await an(h)(
1366
- v,
1368
+ const T = await an(d)(
1369
+ S,
1367
1370
  { ...y, ...p },
1368
- A,
1371
+ w,
1369
1372
  e.configuration.token_renew_mode,
1370
1373
  r
1371
1374
  );
1372
- if (!E.success)
1375
+ if (!T.success)
1373
1376
  throw new Error("Token request failed");
1374
1377
  let g;
1375
- const O = E.data.tokens, d = E.data.demonstratingProofOfPossessionNonce;
1376
- if (E.data.state !== p.state)
1378
+ const O = T.data.tokens, h = T.data.demonstratingProofOfPossessionNonce;
1379
+ if (T.data.state !== p.state)
1377
1380
  throw new Error("state is not valid");
1378
- const { isValid: P, reason: S } = Se(
1381
+ const { isValid: P, reason: v } = Se(
1379
1382
  O,
1380
- _.nonce,
1383
+ f.nonce,
1381
1384
  a
1382
1385
  );
1383
1386
  if (!P)
1384
- throw new Error(`Tokens are not OpenID valid, reason: ${S}`);
1387
+ throw new Error(`Tokens are not OpenID valid, reason: ${v}`);
1385
1388
  if (l) {
1386
1389
  if (O.refreshToken && !O.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))
1387
1390
  throw new Error("Refresh token should be hidden by service worker");
1388
- if (d && (O != null && O.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER")))
1391
+ if (h && (O != null && O.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER")))
1389
1392
  throw new Error(
1390
1393
  "Demonstration of proof of possession require Access token not hidden by service worker"
1391
1394
  );
1392
1395
  }
1393
1396
  if (l)
1394
- await l.initAsync(a, "syncTokensAsync", s), g = l.getLoginParams(), d && await l.setDemonstratingProofOfPossessionNonce(
1395
- d
1397
+ await l.initAsync(a, "syncTokensAsync", s), g = l.getLoginParams(), h && await l.setDemonstratingProofOfPossessionNonce(
1398
+ h
1396
1399
  );
1397
1400
  else {
1398
- const T = C(e.configurationName, s.storage);
1399
- g = T.getLoginParams(), d && await T.setDemonstratingProofOfPossessionNonce(d);
1401
+ const E = C(e.configurationName, s.storage);
1402
+ g = E.getLoginParams(), h && await E.setDemonstratingProofOfPossessionNonce(h);
1400
1403
  }
1401
1404
  return await e.startCheckSessionAsync(
1402
1405
  a.checkSessionIframe,
1403
1406
  t,
1404
- f,
1407
+ _,
1405
1408
  n
1406
1409
  ), e.publishEvent(m.loginCallbackAsync_end, {}), {
1407
1410
  tokens: O,
@@ -1437,69 +1440,69 @@ const hn = () => {
1437
1440
  return n;
1438
1441
  }, wn = (e) => async (n) => {
1439
1442
  U.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
1440
- const s = await x(e.configuration, e.configurationName);
1443
+ const s = await N(e.configuration, e.configurationName);
1441
1444
  s ? await s.clearAsync(n) : await C(e.configurationName, e.configuration.storage).clearAsync(n), e.tokens = null, e.userInfo = null;
1442
1445
  }, An = (e, n, s, t, o) => async (i = void 0, r = null) => {
1443
- var p, v;
1446
+ var p, S;
1444
1447
  const a = e.configuration, c = await e.initAsync(
1445
1448
  a.authority,
1446
1449
  a.authority_configuration
1447
1450
  );
1448
1451
  i && typeof i != "string" && (i = void 0, t.warn("callbackPathOrUrl path is not a string"));
1449
1452
  const u = i ?? o.getPath();
1450
- let f = !1;
1451
- i && (f = i.includes("https://") || i.includes("http://"));
1452
- const l = f ? i : o.getOrigin() + u, h = e.tokens ? e.tokens.idToken : "";
1453
+ let _ = !1;
1454
+ i && (_ = i.includes("https://") || i.includes("http://"));
1455
+ const l = _ ? i : o.getOrigin() + u, d = e.tokens ? e.tokens.idToken : "";
1453
1456
  try {
1454
- const A = c.revocationEndpoint;
1455
- if (A) {
1456
- const E = [], g = e.tokens ? e.tokens.accessToken : null;
1457
+ const w = c.revocationEndpoint;
1458
+ if (w) {
1459
+ const T = [], g = e.tokens ? e.tokens.accessToken : null;
1457
1460
  if (g && a.logout_tokens_to_invalidate.includes(pe.access_token)) {
1458
- const d = z(r, ":revoke_access_token"), P = ke(s)(
1459
- A,
1461
+ const h = z(r, ":revoke_access_token"), P = ke(s)(
1462
+ w,
1460
1463
  g,
1461
1464
  ne.access_token,
1462
1465
  a.client_id,
1463
- d
1466
+ h
1464
1467
  );
1465
- E.push(P);
1468
+ T.push(P);
1466
1469
  }
1467
1470
  const O = e.tokens ? e.tokens.refreshToken : null;
1468
1471
  if (O && a.logout_tokens_to_invalidate.includes(pe.refresh_token)) {
1469
- const d = z(r, ":revoke_refresh_token"), P = ke(s)(
1470
- A,
1472
+ const h = z(r, ":revoke_refresh_token"), P = ke(s)(
1473
+ w,
1471
1474
  O,
1472
1475
  ne.refresh_token,
1473
1476
  a.client_id,
1474
- d
1477
+ h
1475
1478
  );
1476
- E.push(P);
1479
+ T.push(P);
1477
1480
  }
1478
- E.length > 0 && await Promise.all(E);
1481
+ T.length > 0 && await Promise.all(T);
1479
1482
  }
1480
- } catch (A) {
1483
+ } catch (w) {
1481
1484
  t.warn(
1482
1485
  "logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"
1483
- ), t.warn(A);
1486
+ ), t.warn(w);
1484
1487
  }
1485
- const _ = ((v = (p = e.tokens) == null ? void 0 : p.idTokenPayload) == null ? void 0 : v.sub) ?? null;
1488
+ const f = ((S = (p = e.tokens) == null ? void 0 : p.idTokenPayload) == null ? void 0 : S.sub) ?? null;
1486
1489
  await e.destroyAsync("LOGGED_OUT");
1487
- for (const [, A] of Object.entries(n))
1488
- A !== e ? await e.logoutSameTabAsync(e.configuration.client_id, _) : e.publishEvent(m.logout_from_same_tab, {});
1490
+ for (const [, w] of Object.entries(n))
1491
+ w !== e ? await e.logoutSameTabAsync(e.configuration.client_id, f) : e.publishEvent(m.logout_from_same_tab, {});
1489
1492
  const k = z(r, ":oidc");
1490
1493
  if (k && k.no_reload === "true")
1491
1494
  return;
1492
1495
  const y = pn(r);
1493
1496
  if (c.endSessionEndpoint) {
1494
- "id_token_hint" in y || (y.id_token_hint = h), !("post_logout_redirect_uri" in y) && i !== null && (y.post_logout_redirect_uri = l);
1495
- let A = "";
1496
- for (const [E, g] of Object.entries(y))
1497
- g != null && (A === "" ? A += "?" : A += "&", A += `${E}=${encodeURIComponent(g)}`);
1498
- o.open(`${c.endSessionEndpoint}${A}`);
1497
+ "id_token_hint" in y || (y.id_token_hint = d), !("post_logout_redirect_uri" in y) && i !== null && (y.post_logout_redirect_uri = l);
1498
+ let w = "";
1499
+ for (const [T, g] of Object.entries(y))
1500
+ g != null && (w === "" ? w += "?" : w += "&", w += `${T}=${encodeURIComponent(g)}`);
1501
+ o.open(`${c.endSessionEndpoint}${w}`);
1499
1502
  } else
1500
1503
  o.reload();
1501
- }, Ne = (e, n, s = !1) => async (...t) => {
1502
- var _;
1504
+ }, xe = (e, n, s = !1) => async (...t) => {
1505
+ var f;
1503
1506
  const [o, i, ...r] = t, a = i ? { ...i } : { method: "GET" };
1504
1507
  let c = new Headers();
1505
1508
  a.headers && (c = a.headers instanceof Headers ? a.headers : new Headers(a.headers));
@@ -1510,7 +1513,7 @@ const hn = () => {
1510
1513
  refresh_time_before_tokens_expiration_in_second: n.configuration.refresh_time_before_tokens_expiration_in_second
1511
1514
  },
1512
1515
  renewTokensAsync: n.renewTokensAsync.bind(n)
1513
- }, f = await Ae(u), l = (_ = f == null ? void 0 : f.tokens) == null ? void 0 : _.accessToken;
1516
+ }, _ = await Ae(u), l = (f = _ == null ? void 0 : _.tokens) == null ? void 0 : f.accessToken;
1514
1517
  if (c.has("Accept") || c.set("Accept", "application/json"), l) {
1515
1518
  if (n.configuration.demonstrating_proof_of_possession && s) {
1516
1519
  const k = await n.generateDemonstrationOfProofOfPossessionAsync(
@@ -1523,26 +1526,33 @@ const hn = () => {
1523
1526
  c.set("Authorization", `Bearer ${l}`);
1524
1527
  a.credentials || (a.credentials = "same-origin");
1525
1528
  }
1526
- const h = { ...a, headers: c };
1527
- return await e(o, h, ...r);
1529
+ const d = { ...a, headers: c };
1530
+ return await e(o, d, ...r);
1528
1531
  }, Sn = (e) => async (n = !1, s = !1) => {
1532
+ var u, _;
1529
1533
  if (e.userInfo != null && !n)
1530
1534
  return e.userInfo;
1531
- const t = e.configuration, i = (await e.initAsync(
1532
- t.authority,
1533
- t.authority_configuration
1534
- )).userInfoEndpoint, a = await (async () => {
1535
- const u = await Ne(fetch, e, s)(i);
1536
- return u.status !== 200 ? null : u.json();
1535
+ const t = !n && ((u = e.configuration.storage) == null ? void 0 : u.getItem(`oidc.${e.configurationName}.userInfo`));
1536
+ if (t)
1537
+ return e.userInfo = JSON.parse(t), e.userInfo;
1538
+ const o = e.configuration, r = (await e.initAsync(
1539
+ o.authority,
1540
+ o.authority_configuration
1541
+ )).userInfoEndpoint, c = await (async () => {
1542
+ const d = await xe(fetch, e, s)(r);
1543
+ return d.status !== 200 ? null : d.json();
1537
1544
  })();
1538
- return e.userInfo = a, a;
1545
+ return e.userInfo = c, c && ((_ = e.configuration.storage) == null || _.setItem(
1546
+ `oidc.${e.configurationName}.userInfo`,
1547
+ JSON.stringify(c)
1548
+ )), c;
1539
1549
  }, Tn = () => fetch;
1540
1550
  class te {
1541
1551
  constructor(n) {
1542
1552
  this.authorizationEndpoint = n.authorization_endpoint, this.tokenEndpoint = n.token_endpoint, this.revocationEndpoint = n.revocation_endpoint, this.userInfoEndpoint = n.userinfo_endpoint, this.checkSessionIframe = n.check_session_iframe, this.issuer = n.issuer, this.endSessionEndpoint = n.end_session_endpoint;
1543
1553
  }
1544
1554
  }
1545
- const D = {}, vn = (e, n = new j()) => (s, t = "default") => (D[t] || (D[t] = new N(s, t, e, n)), D[t]), En = async (e) => {
1555
+ const D = {}, vn = (e, n = new j()) => (s, t = "default") => (D[t] || (D[t] = new x(s, t, e, n)), D[t]), En = async (e) => {
1546
1556
  const { parsedTokens: n, callbackPath: s, extras: t, scope: o } = await e.loginCallbackAsync();
1547
1557
  return e.timeoutId = J(e, n.expiresAt, t, o), { callbackPath: s };
1548
1558
  }, bn = (e) => Math.floor(Math.random() * e), V = class V {
@@ -1632,7 +1642,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1632
1642
  check_session_iframe: s.check_session_iframe,
1633
1643
  issuer: s.issuer
1634
1644
  });
1635
- const i = await x(this.configuration, this.configurationName) ? window.sessionStorage : null;
1645
+ const i = await N(this.configuration, this.configurationName) ? this.configuration.storage || window.sessionStorage : this.configuration.storage;
1636
1646
  return await tn(this.getFetch())(
1637
1647
  n,
1638
1648
  this.configuration.authority_time_cache_wellknowurl_in_second ?? 60 * 60,
@@ -1679,7 +1689,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1679
1689
  return this.loginCallbackPromise;
1680
1690
  const s = async () => {
1681
1691
  const t = await mn(this)(n), o = t.tokens;
1682
- return this.tokens = o, await x(this.configuration, this.configurationName) || C(this.configurationName, this.configuration.storage).setTokens(o), this.publishEvent(V.eventNames.token_acquired, o), this.configuration.preload_user_info && await this.userInfoAsync(), {
1692
+ return this.tokens = o, await N(this.configuration, this.configurationName) || C(this.configurationName, this.configuration.storage).setTokens(o), this.publishEvent(V.eventNames.token_acquired, o), this.configuration.preload_user_info && await this.userInfoAsync(), {
1683
1693
  parsedTokens: o,
1684
1694
  state: t.state,
1685
1695
  callbackPath: t.callbackPath,
@@ -1696,10 +1706,10 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1696
1706
  ath: await Ie(n),
1697
1707
  ...o
1698
1708
  };
1699
- if (await x(i, this.configurationName))
1709
+ if (await N(i, this.configurationName))
1700
1710
  return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${ve(this.configurationName)}`;
1701
- const c = C(this.configurationName, i.storage), u = await c.getDemonstratingProofOfPossessionJwkAsync(), f = c.getDemonstratingProofOfPossessionNonce();
1702
- return f && (r.nonce = f), await Oe(window)(
1711
+ const c = C(this.configurationName, i.storage), u = await c.getDemonstratingProofOfPossessionJwkAsync(), _ = c.getDemonstratingProofOfPossessionNonce();
1712
+ return _ && (r.nonce = _), await Oe(window)(
1703
1713
  i.demonstrating_proof_of_possession_configuration
1704
1714
  )(u, t, s, r);
1705
1715
  }
@@ -1743,7 +1753,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1743
1753
  }
1744
1754
  };
1745
1755
  V.getOrCreate = (n, s) => (t, o = "default") => vn(n, s)(t, o), V.eventNames = m;
1746
- let N = V;
1756
+ let x = V;
1747
1757
  const K = class K {
1748
1758
  constructor(n) {
1749
1759
  this._oidc = n;
@@ -1758,7 +1768,7 @@ const K = class K {
1758
1768
  this._oidc.publishEvent(n, s);
1759
1769
  }
1760
1770
  static get(n = "default") {
1761
- return new K(N.get(n));
1771
+ return new K(x.get(n));
1762
1772
  }
1763
1773
  tryKeepExistingSessionAsync() {
1764
1774
  return this._oidc.tryKeepExistingSessionAsync();
@@ -1804,7 +1814,7 @@ const K = class K {
1804
1814
  return Ae(o, n, s);
1805
1815
  }
1806
1816
  fetchWithTokens(n, s = !1) {
1807
- return Ne(n, this._oidc, s);
1817
+ return xe(n, this._oidc, s);
1808
1818
  }
1809
1819
  async userInfoAsync(n = !1, s = !1) {
1810
1820
  return this._oidc.userInfoAsync(n, s);
@@ -1813,7 +1823,7 @@ const K = class K {
1813
1823
  return this._oidc.userInfo;
1814
1824
  }
1815
1825
  };
1816
- K.getOrCreate = (n, s = new j()) => (t, o = "default") => new K(N.getOrCreate(n, s)(t, o)), K.eventNames = N.eventNames;
1826
+ K.getOrCreate = (n, s = new j()) => (t, o = "default") => new K(x.getOrCreate(n, s)(t, o)), K.eventNames = x.eventNames;
1817
1827
  let we = K;
1818
1828
  export {
1819
1829
  we as OidcClient,