@axa-fr/oidc-client 7.26.8 → 7.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- class Q {
1
+ class ee {
2
2
  open(n) {
3
3
  window.location.href = n;
4
4
  }
@@ -16,10 +16,10 @@ class Q {
16
16
  return window.origin;
17
17
  }
18
18
  }
19
- const ye = 2e3, K = console;
20
- class $e {
21
- constructor(n, t, s, o = ye, i = !0) {
22
- this._callback = n, this._client_id = t, this._url = s, this._interval = o || ye, this._stopOnError = i;
19
+ const Ae = 2e3, F = console;
20
+ class Fe {
21
+ constructor(n, t, s, o = Ae, i = !0) {
22
+ this._callback = n, this._client_id = t, this._url = s, this._interval = o || Ae, this._stopOnError = i;
23
23
  const r = s.indexOf("/", s.indexOf("//") + 2);
24
24
  this._frame_origin = s.substring(0, r), this._frame = window.document.createElement("iframe"), this._frame.style.visibility = "hidden", this._frame.style.position = "absolute", this._frame.style.display = "none", this._frame.width = 0, this._frame.height = 0, this._frame.src = s;
25
25
  }
@@ -31,10 +31,10 @@ class $e {
31
31
  });
32
32
  }
33
33
  _message(n) {
34
- n.origin === this._frame_origin && n.source === this._frame.contentWindow && (n.data === "error" ? (K.error("CheckSessionIFrame: error message from check session op iframe"), this._stopOnError && this.stop()) : n.data === "changed" ? (K.debug(n), K.debug("CheckSessionIFrame: changed message from check session op iframe"), this.stop(), this._callback()) : K.debug("CheckSessionIFrame: " + n.data + " message from check session op iframe"));
34
+ n.origin === this._frame_origin && n.source === this._frame.contentWindow && (n.data === "error" ? (F.error("CheckSessionIFrame: error message from check session op iframe"), this._stopOnError && this.stop()) : n.data === "changed" ? (F.debug(n), F.debug("CheckSessionIFrame: changed message from check session op iframe"), this.stop(), this._callback()) : F.debug("CheckSessionIFrame: " + n.data + " message from check session op iframe"));
35
35
  }
36
36
  start(n) {
37
- K.debug("CheckSessionIFrame.start :" + n), this.stop();
37
+ F.debug("CheckSessionIFrame.start :" + n), this.stop();
38
38
  const t = () => {
39
39
  this._frame.contentWindow.postMessage(
40
40
  this._client_id + " " + n,
@@ -44,10 +44,10 @@ class $e {
44
44
  t(), this._timer = window.setInterval(t, this._interval);
45
45
  }
46
46
  stop() {
47
- this._timer && (K.debug("CheckSessionIFrame.stop"), window.clearInterval(this._timer), this._timer = null);
47
+ this._timer && (F.debug("CheckSessionIFrame.stop"), window.clearInterval(this._timer), this._timer = null);
48
48
  }
49
49
  }
50
- const w = {
50
+ const k = {
51
51
  service_worker_not_supported_by_browser: "service_worker_not_supported_by_browser",
52
52
  token_acquired: "token_acquired",
53
53
  logout_from_another_tab: "logout_from_another_tab",
@@ -76,94 +76,94 @@ const w = {
76
76
  syncTokensAsync_end: "syncTokensAsync_end",
77
77
  syncTokensAsync_error: "syncTokensAsync_error",
78
78
  tokensInvalidAndWaitingActionsToRefresh: "tokensInvalidAndWaitingActionsToRefresh"
79
- }, N = (e, n = sessionStorage) => {
80
- const t = (y) => (n[`oidc.${e}`] = JSON.stringify({ tokens: null, status: y }), delete n[`oidc.${e}.userInfo`], Promise.resolve()), s = async () => {
79
+ }, x = (e, n = sessionStorage, t) => {
80
+ const s = t ?? n, o = (w) => (n[`oidc.${e}`] = JSON.stringify({ tokens: null, status: w }), delete n[`oidc.${e}.userInfo`], t && t !== n && (delete s[`oidc.login.${e}`], delete s[`oidc.state.${e}`], delete s[`oidc.code_verifier.${e}`], delete s[`oidc.nonce.${e}`]), Promise.resolve()), i = async () => {
81
81
  if (!n[`oidc.${e}`])
82
82
  return n[`oidc.${e}`] = JSON.stringify({ tokens: null, status: null }), { tokens: null, status: null };
83
- const y = JSON.parse(n[`oidc.${e}`]);
84
- return Promise.resolve({ tokens: y.tokens, status: y.status });
85
- }, o = (y) => {
86
- n[`oidc.${e}`] = JSON.stringify({ tokens: y });
87
- }, i = async (y) => {
88
- n[`oidc.session_state.${e}`] = y;
89
- }, r = async () => n[`oidc.session_state.${e}`], a = (y) => {
90
- n[`oidc.nonce.${e}`] = y.nonce;
91
- }, c = (y) => {
92
- n[`oidc.jwk.${e}`] = JSON.stringify(y);
93
- }, _ = () => JSON.parse(n[`oidc.jwk.${e}`]), u = async () => ({ nonce: n[`oidc.nonce.${e}`] }), l = async (y) => {
94
- n[`oidc.dpop_nonce.${e}`] = y;
95
- }, h = () => n[`oidc.dpop_nonce.${e}`], f = () => n[`oidc.${e}`] ? JSON.stringify({ tokens: JSON.parse(n[`oidc.${e}`]).tokens }) : null, m = {};
83
+ const w = JSON.parse(n[`oidc.${e}`]);
84
+ return Promise.resolve({ tokens: w.tokens, status: w.status });
85
+ }, r = (w) => {
86
+ n[`oidc.${e}`] = JSON.stringify({ tokens: w });
87
+ }, a = async (w) => {
88
+ n[`oidc.session_state.${e}`] = w;
89
+ }, c = async () => n[`oidc.session_state.${e}`], f = (w) => {
90
+ s[`oidc.nonce.${e}`] = w.nonce;
91
+ }, u = (w) => {
92
+ n[`oidc.jwk.${e}`] = JSON.stringify(w);
93
+ }, l = () => JSON.parse(n[`oidc.jwk.${e}`]), h = async () => ({ nonce: s[`oidc.nonce.${e}`] }), _ = async (w) => {
94
+ n[`oidc.dpop_nonce.${e}`] = w;
95
+ }, m = () => n[`oidc.dpop_nonce.${e}`], p = () => n[`oidc.${e}`] ? JSON.stringify({ tokens: JSON.parse(n[`oidc.${e}`]).tokens }) : null, g = {};
96
96
  return {
97
- clearAsync: t,
98
- initAsync: s,
99
- setTokens: o,
100
- getTokens: f,
101
- setSessionStateAsync: i,
102
- getSessionStateAsync: r,
103
- setNonceAsync: a,
104
- getNonceAsync: u,
105
- setLoginParams: (y) => {
106
- m[e] = y, n[`oidc.login.${e}`] = JSON.stringify(y);
97
+ clearAsync: o,
98
+ initAsync: i,
99
+ setTokens: r,
100
+ getTokens: p,
101
+ setSessionStateAsync: a,
102
+ getSessionStateAsync: c,
103
+ setNonceAsync: f,
104
+ getNonceAsync: h,
105
+ setLoginParams: (w) => {
106
+ g[e] = w, s[`oidc.login.${e}`] = JSON.stringify(w);
107
107
  },
108
108
  getLoginParams: () => {
109
- const y = n[`oidc.login.${e}`];
110
- return y ? (m[e] || (m[e] = JSON.parse(y)), m[e]) : (console.warn(
109
+ const w = s[`oidc.login.${e}`];
110
+ return w ? (g[e] || (g[e] = JSON.parse(w)), g[e]) : (console.warn(
111
111
  `storage[oidc.login.${e}] is empty, you should have an bad OIDC or code configuration somewhere.`
112
112
  ), null);
113
113
  },
114
- getStateAsync: async () => n[`oidc.state.${e}`],
115
- setStateAsync: async (y) => {
116
- n[`oidc.state.${e}`] = y;
114
+ getStateAsync: async () => s[`oidc.state.${e}`],
115
+ setStateAsync: async (w) => {
116
+ s[`oidc.state.${e}`] = w;
117
117
  },
118
- getCodeVerifierAsync: async () => n[`oidc.code_verifier.${e}`],
119
- setCodeVerifierAsync: async (y) => {
120
- n[`oidc.code_verifier.${e}`] = y;
118
+ getCodeVerifierAsync: async () => s[`oidc.code_verifier.${e}`],
119
+ setCodeVerifierAsync: async (w) => {
120
+ s[`oidc.code_verifier.${e}`] = w;
121
121
  },
122
- setDemonstratingProofOfPossessionNonce: l,
123
- getDemonstratingProofOfPossessionNonce: h,
124
- setDemonstratingProofOfPossessionJwkAsync: c,
125
- getDemonstratingProofOfPossessionJwkAsync: _
122
+ setDemonstratingProofOfPossessionNonce: _,
123
+ getDemonstratingProofOfPossessionNonce: m,
124
+ setDemonstratingProofOfPossessionJwkAsync: u,
125
+ getDemonstratingProofOfPossessionJwkAsync: l
126
126
  };
127
127
  };
128
- var H = /* @__PURE__ */ ((e) => (e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e))(H || {});
129
- const Re = (e) => decodeURIComponent(
128
+ var q = /* @__PURE__ */ ((e) => (e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e))(q || {});
129
+ const Me = (e) => decodeURIComponent(
130
130
  Array.prototype.map.call(atob(e), (n) => "%" + ("00" + n.charCodeAt(0).toString(16)).slice(-2)).join("")
131
- ), Ke = (e) => JSON.parse(Re(e.replaceAll(/-/g, "+").replaceAll(/_/g, "/"))), ke = (e) => {
131
+ ), Be = (e) => JSON.parse(Me(e.replaceAll(/-/g, "+").replaceAll(/_/g, "/"))), Se = (e) => {
132
132
  try {
133
- return e && Ue(e, ".") === 2 ? Ke(e.split(".")[1]) : null;
133
+ return e && Je(e, ".") === 2 ? Be(e.split(".")[1]) : null;
134
134
  } catch (n) {
135
135
  console.warn(n);
136
136
  }
137
137
  return null;
138
- }, Ue = (e, n) => e.split(n).length - 1, oe = {
138
+ }, Je = (e, n) => e.split(n).length - 1, re = {
139
139
  access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
140
140
  access_token_invalid: "access_token_invalid",
141
141
  id_token_invalid: "id_token_invalid"
142
142
  };
143
- function Ve(e, n, t) {
143
+ function He(e, n, t) {
144
144
  if (e.issuedAt) {
145
145
  if (typeof e.issuedAt == "string")
146
146
  return parseInt(e.issuedAt, 10);
147
147
  } else return n && n.iat ? n.iat : t && t.iat ? t.iat : (/* @__PURE__ */ new Date()).getTime() / 1e3;
148
148
  return e.issuedAt;
149
149
  }
150
- const ue = (e, n = null, t) => {
150
+ const de = (e, n = null, t) => {
151
151
  if (!e)
152
152
  return null;
153
153
  let s;
154
154
  const o = typeof e.expiresIn == "string" ? parseInt(e.expiresIn, 10) : e.expiresIn;
155
- e.accessTokenPayload !== void 0 ? s = e.accessTokenPayload : s = ke(e.accessToken);
155
+ e.accessTokenPayload !== void 0 ? s = e.accessTokenPayload : s = Se(e.accessToken);
156
156
  let i;
157
157
  n != null && "idToken" in n && !("idToken" in e) ? i = n.idToken : i = e.idToken;
158
- const r = e.idTokenPayload ? e.idTokenPayload : ke(i), a = r && r.exp ? r.exp : Number.MAX_VALUE, c = s && s.exp ? s.exp : e.issuedAt + o;
159
- e.issuedAt = Ve(e, s, r);
160
- let _;
161
- e.expiresAt ? _ = e.expiresAt : t === oe.access_token_invalid ? _ = c : t === oe.id_token_invalid ? _ = a : _ = a < c ? a : c;
158
+ const r = e.idTokenPayload ? e.idTokenPayload : Se(i), a = r && r.exp ? r.exp : Number.MAX_VALUE, c = s && s.exp ? s.exp : e.issuedAt + o;
159
+ e.issuedAt = He(e, s, r);
160
+ let f;
161
+ e.expiresAt ? f = e.expiresAt : t === re.access_token_invalid ? f = c : t === re.id_token_invalid ? f = a : f = a < c ? a : c;
162
162
  const u = {
163
163
  ...e,
164
164
  idTokenPayload: r,
165
165
  accessTokenPayload: s,
166
- expiresAt: _,
166
+ expiresAt: f,
167
167
  idToken: i
168
168
  };
169
169
  if (n != null && "refreshToken" in n && !("refreshToken" in e)) {
@@ -171,7 +171,7 @@ const ue = (e, n = null, t) => {
171
171
  return { ...u, refreshToken: l };
172
172
  }
173
173
  return u;
174
- }, _e = (e, n, t) => {
174
+ }, ge = (e, n, t) => {
175
175
  if (!e)
176
176
  return null;
177
177
  if (!e.issued_at) {
@@ -186,30 +186,30 @@ const ue = (e, n = null, t) => {
186
186
  tokenType: e.token_type,
187
187
  issuedAt: e.issued_at
188
188
  };
189
- return "refresh_token" in e && (s.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (s.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (s.idTokenPayload = e.idTokenPayload), ue(s, n, t);
190
- }, B = (e, n) => {
189
+ return "refresh_token" in e && (s.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (s.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (s.idTokenPayload = e.idTokenPayload), de(s, n, t);
190
+ }, G = (e, n) => {
191
191
  const t = (/* @__PURE__ */ new Date()).getTime() / 1e3, s = n - t;
192
192
  return Math.round(s - e);
193
- }, Fe = (e, n = 0) => e ? B(n, e.expiresAt) > 0 : !1, ve = async (e, n = 200, t = 50) => {
193
+ }, Ge = (e, n = 0) => e ? G(n, e.expiresAt) > 0 : !1, Ce = async (e, n = 200, t = 50) => {
194
194
  let s = t, o = await e.syncTokensInfoAsync();
195
195
  for (; [
196
- O.REQUIRE_SYNC_TOKENS,
197
- O.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
198
- O.TOKENS_INVALID
196
+ P.REQUIRE_SYNC_TOKENS,
197
+ P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
198
+ P.TOKENS_INVALID
199
199
  ].includes(o) && s > 0; ) {
200
- if (e.configuration.token_automatic_renew_mode == H.AutomaticOnlyWhenFetchExecuted) {
200
+ if (e.configuration.token_automatic_renew_mode == q.AutomaticOnlyWhenFetchExecuted) {
201
201
  await e.renewTokensAsync({});
202
202
  break;
203
203
  } else
204
- await ne({ milliseconds: n });
204
+ await Y({ milliseconds: n });
205
205
  s = s - 1, o = await e.syncTokensInfoAsync();
206
206
  }
207
207
  return {
208
- isTokensValid: Fe(e.getTokens()),
208
+ isTokensValid: Ge(e.getTokens()),
209
209
  tokens: e.getTokens(),
210
210
  numberWaited: s - t
211
211
  };
212
- }, Ee = (e, n, t) => {
212
+ }, Ne = (e, n, t) => {
213
213
  if (e.idTokenPayload) {
214
214
  const s = e.idTokenPayload;
215
215
  if (t.issuer !== s.iss)
@@ -236,7 +236,7 @@ const ue = (e, n = null, t) => {
236
236
  };
237
237
  }
238
238
  return { isValid: !0, reason: "" };
239
- }, $ = (function() {
239
+ }, R = (function() {
240
240
  const e = typeof window > "u" ? global : window;
241
241
  return {
242
242
  setTimeout: setTimeout.bind(e),
@@ -244,32 +244,32 @@ const ue = (e, n = null, t) => {
244
244
  setInterval: setInterval.bind(e),
245
245
  clearInterval: clearInterval.bind(e)
246
246
  };
247
- })(), te = "7.26.8";
248
- let me = null, Z;
249
- const ne = ({ milliseconds: e }) => new Promise((n) => $.setTimeout(n, e)), Oe = (e = "/") => {
247
+ })(), se = "7.27.1";
248
+ let Te = null, ne;
249
+ const Y = ({ milliseconds: e }) => new Promise((n) => R.setTimeout(n, e)), xe = (e = "/") => {
250
250
  try {
251
- Z = new AbortController(), fetch(
251
+ ne = new AbortController(), fetch(
252
252
  `${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`,
253
- { signal: Z.signal }
253
+ { signal: ne.signal }
254
254
  ).catch((s) => {
255
255
  console.log(s);
256
- }), ne({ milliseconds: 150 * 1e3 }).then(
257
- () => Oe(e)
256
+ }), Y({ milliseconds: 150 * 1e3 }).then(
257
+ () => xe(e)
258
258
  );
259
259
  } catch (n) {
260
260
  console.log(n);
261
261
  }
262
- }, X = () => {
263
- Z && Z.abort();
264
- }, be = (e) => {
262
+ }, Q = () => {
263
+ ne && ne.abort();
264
+ }, he = (e) => {
265
265
  const n = `oidc.tabId.${e}`, t = sessionStorage.getItem(n);
266
266
  if (t) return t;
267
267
  const s = globalThis.crypto.randomUUID();
268
268
  return sessionStorage.setItem(n, s), s;
269
- }, Me = 5e3, Be = (e) => navigator.serviceWorker.controller ?? e.active ?? e.waiting ?? e.installing ?? null, P = (e, n) => (t) => {
270
- const s = n?.timeoutMs ?? Me;
269
+ }, je = 5e3, qe = (e) => navigator.serviceWorker.controller ?? e.active ?? e.waiting ?? e.installing ?? null, I = (e, n) => (t) => {
270
+ const s = n?.timeoutMs ?? je;
271
271
  return new Promise((o, i) => {
272
- const r = Be(e);
272
+ const r = qe(e);
273
273
  if (!r) {
274
274
  i(
275
275
  new Error(
@@ -280,254 +280,313 @@ const ne = ({ milliseconds: e }) => new Promise((n) => $.setTimeout(n, e)), Oe =
280
280
  }
281
281
  const a = new MessageChannel();
282
282
  let c = null;
283
- const _ = () => {
283
+ const f = () => {
284
284
  try {
285
- c != null && ($.clearTimeout(c), c = null), a.port1.onmessage = null, a.port1.close(), a.port2.close();
285
+ c != null && (R.clearTimeout(c), c = null), a.port1.onmessage = null, a.port1.close(), a.port2.close();
286
286
  } catch (u) {
287
287
  console.error(u);
288
288
  }
289
289
  };
290
- c = $.setTimeout(() => {
291
- _(), i(
290
+ c = R.setTimeout(() => {
291
+ f(), i(
292
292
  new Error(`Service worker did not respond within ${s}ms (type=${t?.type})`)
293
293
  );
294
294
  }, s), a.port1.onmessage = (u) => {
295
- _(), u?.data?.error ? i(u.data.error) : o(u.data);
295
+ f(), u?.data?.error ? i(u.data.error) : o(u.data);
296
296
  };
297
297
  try {
298
298
  const u = t?.configurationName;
299
- r.postMessage({ ...t, tabId: be(u ?? "default") }, [
299
+ r.postMessage({ ...t, tabId: he(u ?? "default") }, [
300
300
  a.port2
301
301
  ]);
302
302
  } catch (u) {
303
- _(), i(u);
303
+ f(), i(u);
304
304
  }
305
305
  });
306
- }, Je = async (e) => navigator.serviceWorker.controller ? navigator.serviceWorker.controller : new Promise((n) => {
306
+ }, Ye = async (e) => navigator.serviceWorker.controller ? navigator.serviceWorker.controller : new Promise((n) => {
307
307
  let t = !1;
308
308
  const s = () => {
309
309
  t || (t = !0, navigator.serviceWorker.removeEventListener("controllerchange", s), n(navigator.serviceWorker.controller ?? null));
310
310
  };
311
- navigator.serviceWorker.addEventListener("controllerchange", s), $.setTimeout(() => {
311
+ navigator.serviceWorker.addEventListener("controllerchange", s), R.setTimeout(() => {
312
312
  t || (t = !0, navigator.serviceWorker.removeEventListener("controllerchange", s), n(navigator.serviceWorker.controller ?? null));
313
313
  }, e);
314
- }), C = async (e, n) => {
314
+ });
315
+ let ve = !1, M = !1;
316
+ const ye = "oidc.sw.controllerchange_reload_count", oe = 3, ae = () => {
317
+ try {
318
+ return parseInt(sessionStorage.getItem(ye) ?? "0", 10);
319
+ } catch {
320
+ return 0;
321
+ }
322
+ }, Xe = () => {
323
+ const e = ae() + 1;
324
+ try {
325
+ sessionStorage.setItem(ye, String(e));
326
+ } catch {
327
+ }
328
+ return e;
329
+ }, ze = () => {
330
+ try {
331
+ sessionStorage.removeItem(ye);
332
+ } catch {
333
+ }
334
+ }, W = async (e, n) => {
315
335
  const t = e.service_worker_relative_url;
316
336
  if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !t || e.service_worker_activate() === !1)
317
337
  return null;
318
- const s = `${t}?v=${te}`;
338
+ const s = `${t}?v=${se}`;
319
339
  let o = null;
320
340
  e.service_worker_register ? o = await e.service_worker_register(t) : o = await navigator.serviceWorker.register(s, {
321
341
  updateViaCache: "none"
322
342
  });
323
- const i = `oidc.sw.version_mismatch_reload.${n}`, r = async () => {
324
- X(), console.log("New SW waiting – SKIP_WAITING");
343
+ const i = `oidc.sw.version_mismatch_reload.${n}`, r = async (d) => {
344
+ Q(), console.log("New SW waiting – SKIP_WAITING");
325
345
  try {
326
- await P(o, { timeoutMs: 8e3 })({
327
- type: "SKIP_WAITING",
328
- configurationName: n,
329
- data: null
346
+ await new Promise((N, S) => {
347
+ const b = new MessageChannel();
348
+ let K = null;
349
+ const U = () => {
350
+ try {
351
+ K != null && (R.clearTimeout(K), K = null), b.port1.onmessage = null, b.port1.close(), b.port2.close();
352
+ } catch (L) {
353
+ console.error(L);
354
+ }
355
+ };
356
+ K = R.setTimeout(() => {
357
+ U(), S(new Error("SKIP_WAITING did not respond within 8000ms"));
358
+ }, 8e3), b.port1.onmessage = (L) => {
359
+ U(), L?.data?.error ? S(L.data.error) : N();
360
+ };
361
+ try {
362
+ d.postMessage(
363
+ {
364
+ type: "SKIP_WAITING",
365
+ configurationName: n,
366
+ data: null,
367
+ tabId: he(n ?? "default")
368
+ },
369
+ [b.port2]
370
+ );
371
+ } catch (L) {
372
+ U(), S(L);
373
+ }
330
374
  });
331
- } catch (d) {
332
- console.warn("SKIP_WAITING failed", d);
375
+ } catch (N) {
376
+ console.warn("SKIP_WAITING failed", N);
333
377
  }
334
- }, a = (d) => {
335
- X(), d.addEventListener("statechange", async () => {
336
- d.state === "installed" && navigator.serviceWorker.controller && await r();
378
+ }, a = async () => {
379
+ const d = o.waiting;
380
+ d ? await r(d) : console.warn("sendSkipWaiting called but no waiting service worker found");
381
+ }, c = (d) => {
382
+ Q(), d.addEventListener("statechange", async () => {
383
+ if (d.state === "installed" && navigator.serviceWorker.controller) {
384
+ if (ae() >= oe) {
385
+ console.warn(
386
+ "SW trackInstallingWorker: skipping SKIP_WAITING because the reload budget is exhausted"
387
+ );
388
+ return;
389
+ }
390
+ await r(d);
391
+ }
337
392
  });
338
393
  };
339
394
  o.addEventListener("updatefound", () => {
340
395
  const d = o.installing;
341
- d && a(d);
342
- }), o.installing ? a(o.installing) : o.waiting && navigator.serviceWorker.controller && r();
343
- try {
344
- await o.update();
345
- } catch (d) {
396
+ d && c(d);
397
+ }), o.installing ? c(o.installing) : o.waiting && navigator.serviceWorker.controller && (ae() < oe ? a() : console.warn(
398
+ "SW: a waiting worker exists but reload budget is exhausted – skipping activation"
399
+ )), o.update().catch((d) => {
346
400
  console.error(d);
347
- }
348
- const c = `oidc.sw.controllerchange.reloaded.${n}`;
349
- navigator.serviceWorker.addEventListener("controllerchange", () => {
350
- try {
351
- if (sessionStorage.getItem(c) === "1") return;
352
- sessionStorage.setItem(c, "1");
353
- } catch {
354
- }
355
- console.log("SW controller changed – reloading page"), X(), window.location.reload();
356
401
  });
357
402
  try {
358
- await navigator.serviceWorker.ready, navigator.serviceWorker.controller || (await P(o, { timeoutMs: 8e3 })({
403
+ await navigator.serviceWorker.ready, navigator.serviceWorker.controller || (await I(o, { timeoutMs: 8e3 })({
359
404
  type: "claim",
360
405
  configurationName: n,
361
406
  data: null
362
- }), await Je(2e3));
407
+ }), await Ye(2e3));
363
408
  } catch (d) {
364
409
  return console.warn(`Failed init ServiceWorker ${d?.toString?.() ?? String(d)}`), null;
365
410
  }
366
- const _ = async (d) => P(o)({ type: "clear", data: { status: d }, configurationName: n }), u = async (d, D, v) => {
367
- const b = await P(o)({
411
+ ve || (ve = !0, navigator.serviceWorker.addEventListener("controllerchange", () => {
412
+ if (M)
413
+ return;
414
+ const d = Xe();
415
+ if (d > oe) {
416
+ console.warn(
417
+ `SW controllerchange: reload budget exhausted (${d - 1} reloads). Skipping reload to avoid infinite loop.`
418
+ );
419
+ return;
420
+ }
421
+ M = !0, console.log("SW controller changed – reloading page"), Q(), window.location.reload();
422
+ }));
423
+ const f = async (d) => I(o)({ type: "clear", data: { status: d }, configurationName: n }), u = async (d, N, S) => {
424
+ const b = await I(o)({
368
425
  type: "init",
369
426
  data: {
370
427
  oidcServerConfiguration: d,
371
- where: D,
428
+ where: N,
372
429
  oidcConfiguration: {
373
- token_renew_mode: v.token_renew_mode,
374
- service_worker_convert_all_requests_to_cors: v.service_worker_convert_all_requests_to_cors
430
+ token_renew_mode: S.token_renew_mode,
431
+ service_worker_convert_all_requests_to_cors: S.service_worker_convert_all_requests_to_cors
375
432
  }
376
433
  },
377
434
  configurationName: n
378
- }), q = b.version;
379
- if (q !== te) {
435
+ }), K = b.version;
436
+ if (K !== se) {
380
437
  console.warn(
381
- `Service worker ${q} version mismatch with js client version ${te}, unregistering and reloading`
438
+ `Service worker ${K} version mismatch with js client version ${se}, unregistering and reloading`
382
439
  );
383
- const M = parseInt(sessionStorage.getItem(i) ?? "0", 10);
384
- if (M < 3)
385
- if (sessionStorage.setItem(i, String(M + 1)), o.waiting)
386
- await r();
387
- else {
388
- X();
440
+ const U = parseInt(sessionStorage.getItem(i) ?? "0", 10);
441
+ if (U < 3) {
442
+ if (sessionStorage.setItem(i, String(U + 1)), o.waiting)
443
+ return await a(), await Y({ milliseconds: 500 }), M || (M = !0, window.location.reload()), new Promise(() => {
444
+ });
445
+ {
446
+ Q();
389
447
  try {
390
448
  await o.update();
391
- } catch (ge) {
392
- console.error(ge);
449
+ } catch (pe) {
450
+ console.error(pe);
393
451
  }
394
- const Y = await o.unregister();
395
- console.log(`Service worker unregistering ${Y}`), await ne({ milliseconds: 2e3 }), window.location.reload();
452
+ const L = await o.unregister();
453
+ return console.log(`Service worker unregistering ${L}`), await Y({ milliseconds: 500 }), M || (M = !0, window.location.reload()), new Promise(() => {
454
+ });
396
455
  }
397
- else
456
+ } else
398
457
  console.error(
399
- `Service worker version mismatch persists after ${M} attempt(s). Continuing with mismatched version.`
400
- ), sessionStorage.removeItem(i);
458
+ `Service worker version mismatch persists after ${U} attempt(s). Continuing with mismatched version.`
459
+ );
401
460
  } else
402
- sessionStorage.removeItem(i);
461
+ sessionStorage.removeItem(i), ze();
403
462
  return {
404
- tokens: _e(b.tokens, null, v.token_renew_mode),
463
+ tokens: ge(b.tokens, null, S.token_renew_mode),
405
464
  status: b.status
406
465
  };
407
466
  }, l = (d = "/") => {
408
- me == null && (me = "not_null", Oe(d));
409
- }, h = (d) => P(o)({
467
+ Te == null && (Te = "not_null", xe(d));
468
+ }, h = (d) => I(o)({
410
469
  type: "setSessionState",
411
470
  data: { sessionState: d },
412
471
  configurationName: n
413
- }), f = async () => (await P(o)({
472
+ }), _ = async () => (await I(o)({
414
473
  type: "getSessionState",
415
474
  data: null,
416
475
  configurationName: n
417
- })).sessionState, m = (d) => (sessionStorage[`oidc.nonce.${n}`] = d.nonce, P(o)({
476
+ })).sessionState, m = (d) => (sessionStorage[`oidc.nonce.${n}`] = d.nonce, I(o)({
418
477
  type: "setNonce",
419
478
  data: { nonce: d },
420
479
  configurationName: n
421
480
  })), p = async (d = !0) => {
422
- let v = (await P(o)({
481
+ let S = (await I(o)({
423
482
  type: "getNonce",
424
483
  data: null,
425
484
  configurationName: n
426
485
  })).nonce;
427
- return v || (v = sessionStorage[`oidc.nonce.${n}`], console.warn("nonce not found in service worker, using sessionStorage"), d && (await m(v), v = (await p(!1)).nonce)), { nonce: v };
428
- }, g = {}, k = (d) => {
486
+ return S || (S = sessionStorage[`oidc.nonce.${n}`], console.warn("nonce not found in service worker, using sessionStorage"), d && (await m(S), S = (await p(!1)).nonce)), { nonce: S };
487
+ }, g = {}, y = (d) => {
429
488
  g[n] = d, localStorage[`oidc.login.${n}`] = JSON.stringify(d);
430
489
  }, A = () => {
431
490
  const d = localStorage[`oidc.login.${n}`];
432
491
  return g[n] || (g[n] = JSON.parse(d)), g[n];
433
- }, S = async (d) => {
434
- await P(o)({
492
+ }, T = async (d) => {
493
+ await I(o)({
435
494
  type: "setDemonstratingProofOfPossessionNonce",
436
495
  data: { demonstratingProofOfPossessionNonce: d },
437
496
  configurationName: n
438
497
  });
439
- }, E = async () => (await P(o)({
498
+ }, O = async () => (await I(o)({
440
499
  type: "getDemonstratingProofOfPossessionNonce",
441
500
  data: null,
442
501
  configurationName: n
443
- })).demonstratingProofOfPossessionNonce, y = async (d) => {
444
- const D = JSON.stringify(d);
445
- await P(o)({
502
+ })).demonstratingProofOfPossessionNonce, v = async (d) => {
503
+ const N = JSON.stringify(d);
504
+ await I(o)({
446
505
  type: "setDemonstratingProofOfPossessionJwk",
447
- data: { demonstratingProofOfPossessionJwkJson: D },
506
+ data: { demonstratingProofOfPossessionJwkJson: N },
448
507
  configurationName: n
449
508
  });
450
- }, I = async () => {
451
- const d = await P(o)({
509
+ }, C = async () => {
510
+ const d = await I(o)({
452
511
  type: "getDemonstratingProofOfPossessionJwk",
453
512
  data: null,
454
513
  configurationName: n
455
514
  });
456
515
  return d.demonstratingProofOfPossessionJwkJson ? JSON.parse(d.demonstratingProofOfPossessionJwkJson) : null;
457
- }, x = async (d = !0) => {
458
- let v = (await P(o)({
516
+ }, w = async (d = !0) => {
517
+ let S = (await I(o)({
459
518
  type: "getState",
460
519
  data: null,
461
520
  configurationName: n
462
521
  })).state;
463
- return v || (v = sessionStorage[`oidc.state.${n}`], console.warn("state not found in service worker, using sessionStorage"), d && (await F(v), v = await x(!1))), v;
464
- }, F = async (d) => (sessionStorage[`oidc.state.${n}`] = d, P(o)({
522
+ return S || (S = sessionStorage[`oidc.state.${n}`], console.warn("state not found in service worker, using sessionStorage"), d && (await H(S), S = await w(!1))), S;
523
+ }, H = async (d) => (sessionStorage[`oidc.state.${n}`] = d, I(o)({
465
524
  type: "setState",
466
525
  data: { state: d },
467
526
  configurationName: n
468
- })), L = async (d = !0) => {
469
- let v = (await P(o)({
527
+ })), $ = async (d = !0) => {
528
+ let S = (await I(o)({
470
529
  type: "getCodeVerifier",
471
530
  data: null,
472
531
  configurationName: n
473
532
  })).codeVerifier;
474
- return v || (v = sessionStorage[`oidc.code_verifier.${n}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), d && (await T(v), v = await L(!1))), v;
475
- }, T = async (d) => (sessionStorage[`oidc.code_verifier.${n}`] = d, P(o)({
533
+ return S || (S = sessionStorage[`oidc.code_verifier.${n}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), d && (await E(S), S = await $(!1))), S;
534
+ }, E = async (d) => (sessionStorage[`oidc.code_verifier.${n}`] = d, I(o)({
476
535
  type: "setCodeVerifier",
477
536
  data: { codeVerifier: d },
478
537
  configurationName: n
479
538
  }));
480
539
  return {
481
- clearAsync: _,
540
+ clearAsync: f,
482
541
  initAsync: u,
483
542
  startKeepAliveServiceWorker: () => l(e.service_worker_keep_alive_path),
484
543
  setSessionStateAsync: h,
485
- getSessionStateAsync: f,
544
+ getSessionStateAsync: _,
486
545
  setNonceAsync: m,
487
546
  getNonceAsync: p,
488
- setLoginParams: k,
547
+ setLoginParams: y,
489
548
  getLoginParams: A,
490
- getStateAsync: x,
491
- setStateAsync: F,
492
- getCodeVerifierAsync: L,
493
- setCodeVerifierAsync: T,
494
- setDemonstratingProofOfPossessionNonce: S,
495
- getDemonstratingProofOfPossessionNonce: E,
496
- setDemonstratingProofOfPossessionJwkAsync: y,
497
- getDemonstratingProofOfPossessionJwkAsync: I
549
+ getStateAsync: w,
550
+ setStateAsync: H,
551
+ getCodeVerifierAsync: $,
552
+ setCodeVerifierAsync: E,
553
+ setDemonstratingProofOfPossessionNonce: T,
554
+ getDemonstratingProofOfPossessionNonce: O,
555
+ setDemonstratingProofOfPossessionJwkAsync: v,
556
+ getDemonstratingProofOfPossessionJwkAsync: C
498
557
  };
499
- }, U = {}, He = (e, n = window.sessionStorage, t) => {
500
- if (!U[e] && n) {
558
+ }, B = {}, Qe = (e, n = window.sessionStorage, t) => {
559
+ if (!B[e] && n) {
501
560
  const o = n.getItem(e);
502
- o && (U[e] = JSON.parse(o));
561
+ o && (B[e] = JSON.parse(o));
503
562
  }
504
563
  const s = 1e3 * t;
505
- return U[e] && U[e].timestamp + s > Date.now() ? U[e].result : null;
506
- }, Ge = (e, n, t = window.sessionStorage) => {
564
+ return B[e] && B[e].timestamp + s > Date.now() ? B[e].result : null;
565
+ }, Ze = (e, n, t = window.sessionStorage) => {
507
566
  const s = Date.now();
508
- U[e] = { result: n, timestamp: s }, t && t.setItem(e, JSON.stringify({ result: n, timestamp: s }));
567
+ B[e] = { result: n, timestamp: s }, t && t.setItem(e, JSON.stringify({ result: n, timestamp: s }));
509
568
  };
510
- function Pe(e) {
569
+ function We(e) {
511
570
  return new TextEncoder().encode(e);
512
571
  }
513
- function Ie(e) {
572
+ function Le(e) {
514
573
  return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+/g, "");
515
574
  }
516
- function je(e) {
575
+ function en(e) {
517
576
  return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, function(t, s) {
518
577
  return String.fromCharCode(parseInt(s, 16));
519
578
  });
520
579
  }
521
- const fe = (e) => {
580
+ const ke = (e) => {
522
581
  let n = "";
523
582
  return e.forEach(function(t) {
524
583
  n += String.fromCharCode(t);
525
- }), Ie(n);
584
+ }), Le(n);
526
585
  };
527
- function we(e) {
528
- return Ie(je(e));
586
+ function Ee(e) {
587
+ return Le(en(e));
529
588
  }
530
- const qe = {
589
+ const nn = {
531
590
  importKeyAlgorithm: {
532
591
  name: "ECDSA",
533
592
  namedCurve: "P-256",
@@ -540,7 +599,7 @@ const qe = {
540
599
  },
541
600
  digestAlgorithm: { name: "SHA-256" },
542
601
  jwtHeaderAlgorithm: "ES256"
543
- }, Ye = (e) => async (n, t, s, o, i = "dpop+jwt") => {
602
+ }, tn = (e) => async (n, t, s, o, i = "dpop+jwt") => {
544
603
  switch (n = Object.assign({}, n), t.typ = i, t.alg = o.jwtHeaderAlgorithm, t.alg) {
545
604
  case "ES256":
546
605
  t.jwk = { kty: n.kty, crv: n.crv, x: n.x, y: n.y };
@@ -554,22 +613,22 @@ const qe = {
554
613
  const r = {
555
614
  // @ts-ignore
556
615
  // JWT "headers" really means JWS "protected headers"
557
- protected: we(JSON.stringify(t)),
616
+ protected: Ee(JSON.stringify(t)),
558
617
  // @ts-ignore
559
618
  // JWT "claims" are really a JSON-defined JWS "payload"
560
- payload: we(JSON.stringify(s))
561
- }, a = o.importKeyAlgorithm, c = !0, _ = ["sign"], u = await e.crypto.subtle.importKey("jwk", n, a, c, _), l = Pe(`${r.protected}.${r.payload}`), h = o.signAlgorithm, f = await e.crypto.subtle.sign(h, u, l);
562
- return r.signature = fe(new Uint8Array(f)), `${r.protected}.${r.payload}.${r.signature}`;
563
- }, Xe = { sign: Ye }, ze = (e) => async (n) => {
619
+ payload: Ee(JSON.stringify(s))
620
+ }, a = o.importKeyAlgorithm, c = !0, f = ["sign"], u = await e.crypto.subtle.importKey("jwk", n, a, c, f), l = We(`${r.protected}.${r.payload}`), h = o.signAlgorithm, _ = await e.crypto.subtle.sign(h, u, l);
621
+ return r.signature = ke(new Uint8Array(_)), `${r.protected}.${r.payload}.${r.signature}`;
622
+ }, sn = { sign: tn }, on = (e) => async (n) => {
564
623
  const t = n, s = !0, o = ["sign", "verify"], i = await e.crypto.subtle.generateKey(t, s, o);
565
624
  return await e.crypto.subtle.exportKey("jwk", i.privateKey);
566
- }, Qe = (e) => {
625
+ }, rn = (e) => {
567
626
  const n = Object.assign({}, e);
568
627
  return delete n.d, n.key_ops = ["verify"], n;
569
- }, Ze = {
570
- generate: ze,
571
- neuter: Qe
572
- }, en = (e) => async (n, t) => {
628
+ }, an = {
629
+ generate: on,
630
+ neuter: rn
631
+ }, cn = (e) => async (n, t) => {
573
632
  let s;
574
633
  switch (n.kty) {
575
634
  case "EC":
@@ -581,80 +640,80 @@ const qe = {
581
640
  default:
582
641
  throw new Error("Unknown or not implemented JWK type");
583
642
  }
584
- const o = await e.crypto.subtle.digest(t, Pe(s));
585
- return fe(new Uint8Array(o));
586
- }, nn = { thumbprint: en }, tn = (e) => async (n) => await Ze.generate(e)(n), Ne = (e) => (n) => async (t, s = "POST", o, i = {}) => {
643
+ const o = await e.crypto.subtle.digest(t, We(s));
644
+ return ke(new Uint8Array(o));
645
+ }, ln = { thumbprint: cn }, un = (e) => async (n) => await an.generate(e)(n), De = (e) => (n) => async (t, s = "POST", o, i = {}) => {
587
646
  const r = {
588
647
  // https://www.rfc-editor.org/rfc/rfc9449.html#name-concept
589
- jti: btoa(sn()),
648
+ jti: btoa(_n()),
590
649
  htm: s,
591
650
  htu: o,
592
651
  iat: Math.round(Date.now() / 1e3),
593
652
  ...i
594
- }, a = await nn.thumbprint(e)(
653
+ }, a = await ln.thumbprint(e)(
595
654
  t,
596
655
  n.digestAlgorithm
597
656
  );
598
- return await Xe.sign(e)(
657
+ return await sn.sign(e)(
599
658
  t,
600
659
  { kid: a },
601
660
  r,
602
661
  n
603
662
  );
604
- }, sn = () => {
663
+ }, _n = () => {
605
664
  const e = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", n = "0123456789abcdef";
606
665
  let t = 0, s = "";
607
666
  for (let o = 0; o < 36; o++)
608
667
  e[o] !== "-" && e[o] !== "4" && (t = Math.random() * 16 | 0), e[o] === "x" ? s += n[t] : e[o] === "y" ? (t &= 3, t |= 8, s += n[t]) : s += e[o];
609
668
  return s;
610
- }, Ce = () => {
669
+ }, Re = () => {
611
670
  const e = typeof window < "u" && !!window.crypto, n = e && !!window.crypto.subtle;
612
671
  return { hasCrypto: e, hasSubtleCrypto: n };
613
- }, ie = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", on = (e) => {
672
+ }, ce = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", fn = (e) => {
614
673
  const n = [];
615
674
  for (let t = 0; t < e.byteLength; t += 1) {
616
- const s = e[t] % ie.length;
617
- n.push(ie[s]);
675
+ const s = e[t] % ce.length;
676
+ n.push(ce[s]);
618
677
  }
619
678
  return n.join("");
620
- }, re = (e) => {
621
- const n = new Uint8Array(e), { hasCrypto: t } = Ce();
679
+ }, le = (e) => {
680
+ const n = new Uint8Array(e), { hasCrypto: t } = Re();
622
681
  if (t)
623
682
  window.crypto.getRandomValues(n);
624
683
  else
625
684
  for (let s = 0; s < e; s += 1)
626
- n[s] = Math.random() * ie.length | 0;
627
- return on(n);
685
+ n[s] = Math.random() * ce.length | 0;
686
+ return fn(n);
628
687
  };
629
- function rn(e) {
688
+ function dn(e) {
630
689
  const n = new ArrayBuffer(e.length), t = new Uint8Array(n);
631
690
  for (let s = 0; s < e.length; s++)
632
691
  t[s] = e.charCodeAt(s);
633
692
  return t;
634
693
  }
635
- function xe(e) {
694
+ function $e(e) {
636
695
  return new Promise((n, t) => {
637
- crypto.subtle.digest("SHA-256", rn(e)).then(
638
- (s) => n(fe(new Uint8Array(s))),
696
+ crypto.subtle.digest("SHA-256", dn(e)).then(
697
+ (s) => n(ke(new Uint8Array(s))),
639
698
  (s) => t(s)
640
699
  );
641
700
  });
642
701
  }
643
- const an = (e) => {
702
+ const gn = (e) => {
644
703
  if (e.length < 43 || e.length > 128)
645
704
  return Promise.reject(new Error("Invalid code length."));
646
- const { hasSubtleCrypto: n } = Ce();
647
- return n ? xe(e) : Promise.reject(new Error("window.crypto.subtle is unavailable."));
648
- }, cn = 3600, ln = (e) => async (n, t = cn, s = window.sessionStorage, o = 1e4) => {
649
- const i = `${n}/.well-known/openid-configuration`, r = `oidc.server:${n}`, a = He(r, s, t);
705
+ const { hasSubtleCrypto: n } = Re();
706
+ return n ? $e(e) : Promise.reject(new Error("window.crypto.subtle is unavailable."));
707
+ }, hn = 3600, yn = (e) => async (n, t = hn, s = window.sessionStorage, o = 1e4) => {
708
+ const i = `${n}/.well-known/openid-configuration`, r = `oidc.server:${n}`, a = Qe(r, s, t);
650
709
  if (a)
651
- return new le(a);
652
- const c = await j(e)(i, {}, o);
710
+ return new fe(a);
711
+ const c = await z(e)(i, {}, o);
653
712
  if (c.status !== 200)
654
713
  return null;
655
- const _ = await c.json();
656
- return Ge(r, _, s), new le(_);
657
- }, j = (e) => async (n, t = {}, s = 1e4, o = 0) => {
714
+ const f = await c.json();
715
+ return Ze(r, f, s), new fe(f);
716
+ }, z = (e) => async (n, t = {}, s = 1e4, o = 0) => {
658
717
  let i;
659
718
  try {
660
719
  const r = new AbortController();
@@ -662,16 +721,16 @@ const an = (e) => {
662
721
  } catch (r) {
663
722
  if (r.name === "AbortError" || r.message === "Network request failed") {
664
723
  if (o <= 1)
665
- return await j(e)(n, t, s, o + 1);
724
+ return await z(e)(n, t, s, o + 1);
666
725
  throw r;
667
726
  } else
668
727
  throw console.error(r.message), r;
669
728
  }
670
729
  return i;
671
- }, ae = {
730
+ }, ue = {
672
731
  refresh_token: "refresh_token",
673
732
  access_token: "access_token"
674
- }, pe = (e) => async (n, t, s = ae.refresh_token, o, i = {}, r = 1e4) => {
733
+ }, Oe = (e) => async (n, t, s = ue.refresh_token, o, i = {}, r = 1e4) => {
675
734
  const a = {
676
735
  token: t,
677
736
  token_type_hint: s,
@@ -681,32 +740,32 @@ const an = (e) => {
681
740
  a[l] === void 0 && (a[l] = h);
682
741
  const c = [];
683
742
  for (const l in a) {
684
- const h = encodeURIComponent(l), f = encodeURIComponent(a[l]);
685
- c.push(`${h}=${f}`);
743
+ const h = encodeURIComponent(l), _ = encodeURIComponent(a[l]);
744
+ c.push(`${h}=${_}`);
686
745
  }
687
- const _ = c.join("&");
688
- return (await j(e)(
746
+ const f = c.join("&");
747
+ return (await z(e)(
689
748
  n,
690
749
  {
691
750
  method: "POST",
692
751
  headers: {
693
752
  "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
694
753
  },
695
- body: _
754
+ body: f
696
755
  },
697
756
  r
698
757
  )).status !== 200 ? { success: !1 } : {
699
758
  success: !0
700
759
  };
701
- }, un = (e) => async (n, t, s, o, i = {}, r, a = 1e4) => {
702
- for (const [f, m] of Object.entries(s))
703
- t[f] === void 0 && (t[f] = m);
760
+ }, kn = (e) => async (n, t, s, o, i = {}, r, a = 1e4) => {
761
+ for (const [_, m] of Object.entries(s))
762
+ t[_] === void 0 && (t[_] = m);
704
763
  const c = [];
705
- for (const f in t) {
706
- const m = encodeURIComponent(f), p = encodeURIComponent(t[f]);
764
+ for (const _ in t) {
765
+ const m = encodeURIComponent(_), p = encodeURIComponent(t[_]);
707
766
  c.push(`${m}=${p}`);
708
767
  }
709
- const _ = c.join("&"), u = await j(e)(
768
+ const f = c.join("&"), u = await z(e)(
710
769
  n,
711
770
  {
712
771
  method: "POST",
@@ -714,7 +773,7 @@ const an = (e) => {
714
773
  "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
715
774
  ...i
716
775
  },
717
- body: _
776
+ body: f
718
777
  },
719
778
  a
720
779
  );
@@ -726,31 +785,31 @@ const an = (e) => {
726
785
  };
727
786
  const l = await u.json();
728
787
  let h = null;
729
- return u.headers.has(ee) && (h = u.headers.get(
730
- ee
788
+ return u.headers.has(te) && (h = u.headers.get(
789
+ te
731
790
  )), {
732
791
  success: !0,
733
792
  status: u.status,
734
- data: _e(l, o, r),
793
+ data: ge(l, o, r),
735
794
  demonstratingProofOfPossessionNonce: h
736
795
  };
737
- }, _n = (e, n) => async (t, s) => {
796
+ }, mn = (e, n) => async (t, s) => {
738
797
  s = s ? { ...s } : {};
739
- const o = re(128), i = await an(o);
798
+ const o = le(128), i = await gn(o);
740
799
  await e.setCodeVerifierAsync(o), await e.setStateAsync(s.state), s.code_challenge = i, s.code_challenge_method = "S256";
741
800
  let r = "";
742
801
  if (s)
743
802
  for (const [a, c] of Object.entries(s))
744
803
  r === "" ? r += "?" : r += "&", r += `${a}=${encodeURIComponent(c)}`;
745
804
  n.open(`${t}${r}`);
746
- }, ee = "DPoP-Nonce", fn = (e) => async (n, t, s, o, i = 1e4) => {
805
+ }, te = "DPoP-Nonce", wn = (e) => async (n, t, s, o, i = 1e4) => {
747
806
  t = t ? { ...t } : {}, t.code_verifier = await e.getCodeVerifierAsync();
748
807
  const r = [];
749
808
  for (const l in t) {
750
- const h = encodeURIComponent(l), f = encodeURIComponent(t[l]);
751
- r.push(`${h}=${f}`);
809
+ const h = encodeURIComponent(l), _ = encodeURIComponent(t[l]);
810
+ r.push(`${h}=${_}`);
752
811
  }
753
- const a = r.join("&"), c = await j(fetch)(
812
+ const a = r.join("&"), c = await z(fetch)(
754
813
  n,
755
814
  {
756
815
  method: "POST",
@@ -764,24 +823,24 @@ const an = (e) => {
764
823
  );
765
824
  if (await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]), c.status !== 200)
766
825
  return { success: !1, status: c.status };
767
- let _ = null;
768
- c.headers.has(ee) && (_ = c.headers.get(
769
- ee
826
+ let f = null;
827
+ c.headers.has(te) && (f = c.headers.get(
828
+ te
770
829
  ));
771
830
  const u = await c.json();
772
831
  return {
773
832
  success: !0,
774
833
  data: {
775
834
  state: t.state,
776
- tokens: _e(u, null, o),
777
- demonstratingProofOfPossessionNonce: _
835
+ tokens: ge(u, null, o),
836
+ demonstratingProofOfPossessionNonce: f
778
837
  }
779
838
  };
780
839
  };
781
- async function Ae(e, n, t, s = null) {
840
+ async function be(e, n, t, s = null) {
782
841
  const o = (c) => {
783
842
  e.tokens = c;
784
- }, { tokens: i, status: r } = await z(e)(
843
+ }, { tokens: i, status: r } = await Z(e)(
785
844
  o,
786
845
  0,
787
846
  0,
@@ -789,35 +848,39 @@ async function Ae(e, n, t, s = null) {
789
848
  t,
790
849
  s
791
850
  );
792
- return await C(e.configuration, e.configurationName) || N(e.configurationName, e.configuration.storage).setTokens(e.tokens), e.tokens ? i : (await e.destroyAsync(r), null);
851
+ return await W(e.configuration, e.configurationName) || x(
852
+ e.configurationName,
853
+ e.configuration.storage,
854
+ e.configuration.login_state_storage ?? e.configuration.storage
855
+ ).setTokens(e.tokens), e.tokens ? i : (await e.destroyAsync(r), null);
793
856
  }
794
- async function We(e, n = !1, t = null, s = null) {
857
+ async function Ke(e, n = !1, t = null, s = null) {
795
858
  const o = e.configuration, i = `${o.client_id}_${e.configurationName}_${o.authority}`;
796
859
  let r;
797
- const a = await C(e.configuration, e.configurationName);
860
+ const a = await W(e.configuration, e.configurationName);
798
861
  if (o?.storage === window?.sessionStorage && !a || !navigator.locks)
799
- r = await Ae(e, n, t, s);
862
+ r = await be(e, n, t, s);
800
863
  else {
801
864
  let c = "retry";
802
865
  for (; c === "retry"; )
803
866
  c = await navigator.locks.request(
804
867
  i,
805
868
  { ifAvailable: !0 },
806
- async (_) => _ ? await Ae(e, n, t, s) : (e.publishEvent(W.eventNames.syncTokensAsync_lock_not_available, {
869
+ async (f) => f ? await be(e, n, t, s) : (e.publishEvent(D.eventNames.syncTokensAsync_lock_not_available, {
807
870
  lock: "lock not available"
808
871
  }), "retry")
809
872
  );
810
873
  r = c;
811
874
  }
812
- return r ? (e.timeoutId && (e.timeoutId = G(e, e.tokens.expiresAt, t, s)), e.tokens) : null;
875
+ return r ? (e.timeoutId && (e.timeoutId = X(e, e.tokens.expiresAt, t, s)), e.tokens) : null;
813
876
  }
814
- const G = (e, n, t = null, s = null) => {
877
+ const X = (e, n, t = null, s = null) => {
815
878
  const o = e.configuration.refresh_time_before_tokens_expiration_in_second;
816
- return e.timeoutId && $.clearTimeout(e.timeoutId), $.setTimeout(async () => {
817
- const r = { timeLeft: B(o, n) };
818
- e.publishEvent(W.eventNames.token_timer, r), await We(e, !1, t, s);
879
+ return e.timeoutId && R.clearTimeout(e.timeoutId), R.setTimeout(async () => {
880
+ const r = { timeLeft: G(o, n) };
881
+ e.publishEvent(D.eventNames.token_timer, r), await Ke(e, !1, t, s);
819
882
  }, 1e3);
820
- }, O = {
883
+ }, P = {
821
884
  FORCE_REFRESH: "FORCE_REFRESH",
822
885
  SESSION_LOST: "SESSION_LOST",
823
886
  NOT_CONNECTED: "NOT_CONNECTED",
@@ -827,15 +890,15 @@ const G = (e, n, t = null, s = null) => {
827
890
  LOGOUT_FROM_ANOTHER_TAB: "LOGOUT_FROM_ANOTHER_TAB",
828
891
  REQUIRE_SYNC_TOKENS: "REQUIRE_SYNC_TOKENS",
829
892
  TOKENS_INVALID: "TOKENS_INVALID"
830
- }, de = (e) => async (n, t, s, o = !1) => {
893
+ }, me = (e) => async (n, t, s, o = !1) => {
831
894
  const i = { nonce: null };
832
895
  if (!s)
833
- return { tokens: null, status: O.NOT_CONNECTED, nonce: i };
896
+ return { tokens: null, status: P.NOT_CONNECTED, nonce: i };
834
897
  let r = i;
835
898
  const a = await e.initAsync(
836
899
  n.authority,
837
900
  n.authority_configuration
838
- ), c = await C(n, t);
901
+ ), c = await W(n, t);
839
902
  if (c) {
840
903
  const { status: l, tokens: h } = await c.initAsync(
841
904
  a,
@@ -845,92 +908,100 @@ const G = (e, n, t = null, s = null) => {
845
908
  if (l === "LOGGED_OUT")
846
909
  return {
847
910
  tokens: null,
848
- status: O.LOGOUT_FROM_ANOTHER_TAB,
911
+ status: P.LOGOUT_FROM_ANOTHER_TAB,
849
912
  nonce: i
850
913
  };
851
914
  if (l === "SESSIONS_LOST")
852
- return { tokens: null, status: O.SESSION_LOST, nonce: i };
915
+ return { tokens: null, status: P.SESSION_LOST, nonce: i };
853
916
  if (!l || !h)
854
917
  return {
855
918
  tokens: null,
856
- status: O.REQUIRE_SYNC_TOKENS,
919
+ status: P.REQUIRE_SYNC_TOKENS,
857
920
  nonce: i
858
921
  };
859
922
  if (h.issuedAt !== s.issuedAt) {
860
- const m = B(
923
+ const m = G(
861
924
  n.refresh_time_before_tokens_expiration_in_second,
862
925
  h.expiresAt
863
- ) > 0 ? O.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : O.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, p = await c.getNonceAsync();
926
+ ) > 0 ? P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, p = await c.getNonceAsync();
864
927
  return { tokens: h, status: m, nonce: p };
865
928
  }
866
929
  r = await c.getNonceAsync();
867
930
  } else {
868
- const l = N(t, n.storage ?? sessionStorage), h = await l.initAsync();
869
- let { tokens: f } = h;
931
+ const l = x(
932
+ t,
933
+ n.storage ?? sessionStorage,
934
+ n.login_state_storage ?? n.storage ?? sessionStorage
935
+ ), h = await l.initAsync();
936
+ let { tokens: _ } = h;
870
937
  const { status: m } = h;
871
- if (f && (f = ue(f, e.tokens, n.token_renew_mode)), f) {
938
+ if (_ && (_ = de(_, e.tokens, n.token_renew_mode)), _) {
872
939
  if (m === "SESSIONS_LOST")
873
- return { tokens: null, status: O.SESSION_LOST, nonce: i };
874
- if (f.issuedAt !== s.issuedAt) {
875
- const g = B(
940
+ return { tokens: null, status: P.SESSION_LOST, nonce: i };
941
+ if (_.issuedAt !== s.issuedAt) {
942
+ const g = G(
876
943
  n.refresh_time_before_tokens_expiration_in_second,
877
- f.expiresAt
878
- ) > 0 ? O.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : O.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, k = await l.getNonceAsync();
879
- return { tokens: f, status: g, nonce: k };
944
+ _.expiresAt
945
+ ) > 0 ? P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, y = await l.getNonceAsync();
946
+ return { tokens: _, status: g, nonce: y };
880
947
  }
881
948
  } else return {
882
949
  tokens: null,
883
- status: O.LOGOUT_FROM_ANOTHER_TAB,
950
+ status: P.LOGOUT_FROM_ANOTHER_TAB,
884
951
  nonce: i
885
952
  };
886
953
  r = await l.getNonceAsync();
887
954
  }
888
- const u = B(
955
+ const u = G(
889
956
  n.refresh_time_before_tokens_expiration_in_second,
890
957
  s.expiresAt
891
958
  ) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
892
959
  return o ? { tokens: s, status: "FORCE_REFRESH", nonce: r } : { tokens: s, status: u, nonce: r };
893
- }, z = (e) => async (n, t = 0, s = 0, o = !1, i = null, r = null) => {
960
+ }, Z = (e) => async (n, t = 0, s = 0, o = !1, i = null, r = null) => {
894
961
  if (!navigator.onLine && document.hidden)
895
962
  return { tokens: e.tokens, status: "GIVE_UP" };
896
963
  let a = 6;
897
- const c = o ? 2 : 5, _ = 5;
964
+ const c = o ? 2 : 5, f = 5;
898
965
  for (; !navigator.onLine && a > 0; )
899
- await ne({ milliseconds: 1e3 }), a--, e.publishEvent(w.refreshTokensAsync, {
966
+ await Y({ milliseconds: 1e3 }), a--, e.publishEvent(k.refreshTokensAsync, {
900
967
  message: `wait because navigator is offline try ${a}`
901
968
  });
902
969
  const u = document.hidden, l = u ? t : t + 1, h = u ? s + 1 : s;
903
- if (t >= c || s >= _)
904
- return n(null), e.publishEvent(w.refreshTokensAsync_error, { message: "refresh token" }), { tokens: null, status: "SESSION_LOST" };
970
+ if (t >= c || s >= f)
971
+ return n(null), e.publishEvent(k.refreshTokensAsync_error, { message: "refresh token" }), { tokens: null, status: "SESSION_LOST" };
905
972
  i || (i = {});
906
- const f = e.configuration, m = (g, k = null, A = null) => he(
973
+ const _ = e.configuration, m = (g, y = null, A = null) => we(
907
974
  e.configurationName,
908
975
  e.configuration,
909
976
  e.publishEvent.bind(e)
910
- )(g, k, A), p = async () => {
977
+ )(g, y, A), p = async () => {
911
978
  try {
912
979
  let g;
913
- const k = await C(f, e.configurationName);
914
- k ? g = k.getLoginParams() : g = N(e.configurationName, f.storage).getLoginParams();
980
+ const y = await W(_, e.configurationName);
981
+ y ? g = y.getLoginParams() : g = x(
982
+ e.configurationName,
983
+ _.storage,
984
+ _.login_state_storage ?? _.storage
985
+ ).getLoginParams();
915
986
  const A = {};
916
987
  if (g && g.extras)
917
- for (const [E, y] of Object.entries(g.extras))
918
- y != null && (A[E] = y);
988
+ for (const [O, v] of Object.entries(g.extras))
989
+ v != null && (A[O] = v);
919
990
  if (i)
920
- for (const [E, y] of Object.entries(i))
921
- y != null && (A[E] = y);
991
+ for (const [O, v] of Object.entries(i))
992
+ v != null && (A[O] = v);
922
993
  A.prompt = "none", r && (A.scope = r);
923
- const S = await m(A);
924
- return S ? S.error ? (n(null), e.publishEvent(w.refreshTokensAsync_error, {
994
+ const T = await m(A);
995
+ return T ? T.error ? (n(null), e.publishEvent(k.refreshTokensAsync_error, {
925
996
  message: "refresh token silent"
926
- }), { tokens: null, status: "SESSION_LOST" }) : (n(S.tokens), e.publishEvent(W.eventNames.token_renewed, {}), { tokens: S.tokens, status: "LOGGED" }) : (n(null), e.publishEvent(w.refreshTokensAsync_error, {
997
+ }), { tokens: null, status: "SESSION_LOST" }) : (n(T.tokens), e.publishEvent(D.eventNames.token_renewed, {}), { tokens: T.tokens, status: "LOGGED" }) : (n(null), e.publishEvent(k.refreshTokensAsync_error, {
927
998
  message: "refresh token silent not active"
928
999
  }), { tokens: null, status: "SESSION_LOST" });
929
1000
  } catch (g) {
930
- return console.error(g), e.publishEvent(w.refreshTokensAsync_silent_error, {
1001
+ return console.error(g), e.publishEvent(k.refreshTokensAsync_silent_error, {
931
1002
  message: "exceptionSilent",
932
1003
  exception: g.message
933
- }), await z(e)(
1004
+ }), await Z(e)(
934
1005
  n,
935
1006
  l,
936
1007
  h,
@@ -941,96 +1012,100 @@ const G = (e, n, t = null, s = null) => {
941
1012
  }
942
1013
  };
943
1014
  try {
944
- const { status: g, tokens: k, nonce: A } = await de(e)(
945
- f,
1015
+ const { status: g, tokens: y, nonce: A } = await me(e)(
1016
+ _,
946
1017
  e.configurationName,
947
1018
  e.tokens,
948
1019
  o
949
1020
  );
950
1021
  switch (g) {
951
- case O.SESSION_LOST:
952
- return n(null), e.publishEvent(w.refreshTokensAsync_error, {
1022
+ case P.SESSION_LOST:
1023
+ return n(null), e.publishEvent(k.refreshTokensAsync_error, {
953
1024
  message: "refresh token session lost"
954
1025
  }), { tokens: null, status: "SESSION_LOST" };
955
- case O.NOT_CONNECTED:
1026
+ case P.NOT_CONNECTED:
956
1027
  return n(null), { tokens: null, status: null };
957
- case O.TOKENS_VALID:
958
- return n(k), { tokens: k, status: "LOGGED_IN" };
959
- case O.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID:
960
- return n(k), e.publishEvent(W.eventNames.token_renewed, {
1028
+ case P.TOKENS_VALID:
1029
+ return n(y), { tokens: y, status: "LOGGED_IN" };
1030
+ case P.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID:
1031
+ return n(y), e.publishEvent(D.eventNames.token_renewed, {
961
1032
  reason: "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID"
962
- }), { tokens: k, status: "LOGGED_IN" };
963
- case O.LOGOUT_FROM_ANOTHER_TAB:
964
- return n(null), e.publishEvent(w.logout_from_another_tab, {
1033
+ }), { tokens: y, status: "LOGGED_IN" };
1034
+ case P.LOGOUT_FROM_ANOTHER_TAB:
1035
+ return n(null), e.publishEvent(k.logout_from_another_tab, {
965
1036
  status: "session syncTokensAsync"
966
1037
  }), { tokens: null, status: "LOGGED_OUT" };
967
- case O.REQUIRE_SYNC_TOKENS:
968
- return f.token_automatic_renew_mode == H.AutomaticOnlyWhenFetchExecuted && !o ? (e.publishEvent(w.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" }) : (e.publishEvent(w.refreshTokensAsync_begin, { tryNumber: t }), await p());
1038
+ case P.REQUIRE_SYNC_TOKENS:
1039
+ return _.token_automatic_renew_mode == q.AutomaticOnlyWhenFetchExecuted && !o ? (e.publishEvent(k.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" }) : (e.publishEvent(k.refreshTokensAsync_begin, { tryNumber: t }), await p());
969
1040
  default: {
970
- if (f.token_automatic_renew_mode == H.AutomaticOnlyWhenFetchExecuted && O.FORCE_REFRESH !== g)
971
- return e.publishEvent(w.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" };
972
- if (e.publishEvent(w.refreshTokensAsync_begin, {
973
- refreshToken: k.refreshToken,
1041
+ if (_.token_automatic_renew_mode == q.AutomaticOnlyWhenFetchExecuted && P.FORCE_REFRESH !== g)
1042
+ return e.publishEvent(k.tokensInvalidAndWaitingActionsToRefresh, {}), { tokens: e.tokens, status: "GIVE_UP" };
1043
+ if (e.publishEvent(k.refreshTokensAsync_begin, {
1044
+ refreshToken: y.refreshToken,
974
1045
  status: g,
975
1046
  tryNumber: t,
976
1047
  backgroundTry: s
977
- }), !k.refreshToken)
1048
+ }), !y.refreshToken)
978
1049
  return await p();
979
- const S = f.client_id, E = f.redirect_uri, y = f.authority, x = { ...f.token_request_extras ? f.token_request_extras : {} };
980
- for (const [L, T] of Object.entries(i))
981
- L.endsWith(":token_request") && (x[L.replace(":token_request", "")] = T);
1050
+ const T = _.client_id, O = _.redirect_uri, v = _.authority, w = { ..._.token_request_extras ? _.token_request_extras : {} };
1051
+ for (const [$, E] of Object.entries(i))
1052
+ $.endsWith(":token_request") && (w[$.replace(":token_request", "")] = E);
982
1053
  return await (async () => {
983
- const L = {
984
- client_id: S,
985
- redirect_uri: E,
1054
+ const $ = {
1055
+ client_id: T,
1056
+ redirect_uri: O,
986
1057
  grant_type: "refresh_token",
987
- refresh_token: k.refreshToken
988
- }, T = await e.initAsync(
989
- y,
990
- f.authority_configuration
991
- ), d = document.hidden ? 1e4 : 3e4 * 10, D = T.tokenEndpoint, v = {};
992
- f.demonstrating_proof_of_possession && (v.DPoP = await e.generateDemonstrationOfProofOfPossessionAsync(
993
- k.accessToken,
994
- D,
1058
+ refresh_token: y.refreshToken
1059
+ }, E = await e.initAsync(
1060
+ v,
1061
+ _.authority_configuration
1062
+ ), d = document.hidden ? 1e4 : 3e4 * 10, N = E.tokenEndpoint, S = {};
1063
+ _.demonstrating_proof_of_possession && (S.DPoP = await e.generateDemonstrationOfProofOfPossessionAsync(
1064
+ y.accessToken,
1065
+ N,
995
1066
  "POST"
996
1067
  ));
997
- const b = await un(e.getFetch())(
998
- D,
999
- L,
1000
- x,
1001
- k,
1002
- v,
1003
- f.token_renew_mode,
1068
+ const b = await kn(e.getFetch())(
1069
+ N,
1070
+ $,
1071
+ w,
1072
+ y,
1073
+ S,
1074
+ _.token_renew_mode,
1004
1075
  d
1005
1076
  );
1006
1077
  if (b.success) {
1007
- const { isValid: q, reason: M } = Ee(
1078
+ const { isValid: K, reason: U } = Ne(
1008
1079
  b.data,
1009
1080
  A.nonce,
1010
- T
1081
+ E
1011
1082
  );
1012
- if (!q)
1013
- return n(null), e.publishEvent(w.refreshTokensAsync_error, {
1014
- message: `refresh token return not valid tokens, reason: ${M}`
1083
+ if (!K)
1084
+ return n(null), e.publishEvent(k.refreshTokensAsync_error, {
1085
+ message: `refresh token return not valid tokens, reason: ${U}`
1015
1086
  }), { tokens: null, status: "SESSION_LOST" };
1016
1087
  if (n(b.data), b.demonstratingProofOfPossessionNonce) {
1017
- const Y = await C(f, e.configurationName);
1018
- Y ? await Y.setDemonstratingProofOfPossessionNonce(
1088
+ const L = await W(_, e.configurationName);
1089
+ L ? await L.setDemonstratingProofOfPossessionNonce(
1019
1090
  b.demonstratingProofOfPossessionNonce
1020
- ) : await N(e.configurationName, f.storage).setDemonstratingProofOfPossessionNonce(
1091
+ ) : await x(
1092
+ e.configurationName,
1093
+ _.storage,
1094
+ _.login_state_storage ?? _.storage
1095
+ ).setDemonstratingProofOfPossessionNonce(
1021
1096
  b.demonstratingProofOfPossessionNonce
1022
1097
  );
1023
1098
  }
1024
- return e.publishEvent(w.refreshTokensAsync_end, {
1099
+ return e.publishEvent(k.refreshTokensAsync_end, {
1025
1100
  success: b.success
1026
- }), e.publishEvent(W.eventNames.token_renewed, { reason: "REFRESH_TOKEN" }), { tokens: b.data, status: "LOGGED_IN" };
1101
+ }), e.publishEvent(D.eventNames.token_renewed, { reason: "REFRESH_TOKEN" }), { tokens: b.data, status: "LOGGED_IN" };
1027
1102
  } else
1028
- return e.publishEvent(w.refreshTokensAsync_silent_error, {
1103
+ return e.publishEvent(k.refreshTokensAsync_silent_error, {
1029
1104
  message: "bad request",
1030
1105
  tokenResponse: b
1031
- }), b.status >= 400 && b.status < 500 ? (n(null), e.publishEvent(w.refreshTokensAsync_error, {
1106
+ }), b.status >= 400 && b.status < 500 ? (n(null), e.publishEvent(k.refreshTokensAsync_error, {
1032
1107
  message: `session lost: ${b.status}`
1033
- }), { tokens: null, status: "SESSION_LOST" }) : await z(e)(
1108
+ }), { tokens: null, status: "SESSION_LOST" }) : await Z(e)(
1034
1109
  n,
1035
1110
  l,
1036
1111
  h,
@@ -1042,49 +1117,49 @@ const G = (e, n, t = null, s = null) => {
1042
1117
  }
1043
1118
  }
1044
1119
  } catch (g) {
1045
- return console.error(g), e.publishEvent(w.refreshTokensAsync_silent_error, {
1120
+ return console.error(g), e.publishEvent(k.refreshTokensAsync_silent_error, {
1046
1121
  message: "exception",
1047
1122
  exception: g.message
1048
- }), new Promise((k, A) => {
1123
+ }), new Promise((y, A) => {
1049
1124
  setTimeout(() => {
1050
- z(e)(
1125
+ Z(e)(
1051
1126
  n,
1052
1127
  l,
1053
1128
  h,
1054
1129
  o,
1055
1130
  i,
1056
1131
  r
1057
- ).then(k).catch(A);
1132
+ ).then(y).catch(A);
1058
1133
  }, 1e3);
1059
1134
  });
1060
1135
  }
1061
- }, he = (e, n, t) => (s = null, o = null, i = null) => {
1136
+ }, we = (e, n, t) => (s = null, o = null, i = null) => {
1062
1137
  if (!n.silent_redirect_uri || !n.silent_login_uri)
1063
1138
  return Promise.resolve(null);
1064
1139
  try {
1065
- t(w.silentLoginAsync_begin, {});
1140
+ t(k.silentLoginAsync_begin, {});
1066
1141
  let r = "";
1067
1142
  if (o && (s == null && (s = {}), s.state = o), i != null && (s == null && (s = {}), s.scope = i), s != null)
1068
1143
  for (const [l, h] of Object.entries(s))
1069
1144
  h != null && (r === "" ? r = `?${encodeURIComponent(l)}=${encodeURIComponent(h)}` : r += `&${encodeURIComponent(l)}=${encodeURIComponent(h)}`);
1070
- const a = n.silent_login_uri + r, c = a.indexOf("/", a.indexOf("//") + 2), _ = a.substring(0, c), u = document.createElement("iframe");
1145
+ const a = n.silent_login_uri + r, c = a.indexOf("/", a.indexOf("//") + 2), f = a.substring(0, c), u = document.createElement("iframe");
1071
1146
  return u.width = "0px", u.height = "0px", u.id = `${e}_oidc_iframe`, u.setAttribute("src", a), u.style.display = "none", document.body.appendChild(u), new Promise((l, h) => {
1072
- let f = !1;
1147
+ let _ = !1;
1073
1148
  const m = () => {
1074
- window.removeEventListener("message", p), u.remove(), f = !0;
1149
+ window.removeEventListener("message", p), u.remove(), _ = !0;
1075
1150
  }, p = (g) => {
1076
- if (g.origin === _ && g.source === u.contentWindow) {
1077
- const k = `${e}_oidc_tokens:`, A = `${e}_oidc_error:`, S = `${e}_oidc_exception:`, E = g.data;
1078
- if (E && typeof E == "string" && !f) {
1079
- if (E.startsWith(k)) {
1080
- const y = JSON.parse(g.data.replace(k, ""));
1081
- t(w.silentLoginAsync_end, {}), l(y), m();
1082
- } else if (E.startsWith(A)) {
1083
- const y = JSON.parse(g.data.replace(A, ""));
1084
- t(w.silentLoginAsync_error, y), l({ error: "oidc_" + y.error, tokens: null, sessionState: null }), m();
1085
- } else if (E.startsWith(S)) {
1086
- const y = JSON.parse(g.data.replace(S, ""));
1087
- t(w.silentLoginAsync_error, y), h(new Error(y.error)), m();
1151
+ if (g.origin === f && g.source === u.contentWindow) {
1152
+ const y = `${e}_oidc_tokens:`, A = `${e}_oidc_error:`, T = `${e}_oidc_exception:`, O = g.data;
1153
+ if (O && typeof O == "string" && !_) {
1154
+ if (O.startsWith(y)) {
1155
+ const v = JSON.parse(g.data.replace(y, ""));
1156
+ t(k.silentLoginAsync_end, {}), l(v), m();
1157
+ } else if (O.startsWith(A)) {
1158
+ const v = JSON.parse(g.data.replace(A, ""));
1159
+ t(k.silentLoginAsync_error, v), l({ error: "oidc_" + v.error, tokens: null, sessionState: null }), m();
1160
+ } else if (O.startsWith(T)) {
1161
+ const v = JSON.parse(g.data.replace(T, ""));
1162
+ t(k.silentLoginAsync_error, v), h(new Error(v.error)), m();
1088
1163
  }
1089
1164
  }
1090
1165
  }
@@ -1093,55 +1168,55 @@ const G = (e, n, t = null, s = null) => {
1093
1168
  window.addEventListener("message", p);
1094
1169
  const g = n.silent_login_timeout;
1095
1170
  setTimeout(() => {
1096
- f || (m(), t(w.silentLoginAsync_error, { reason: "timeout" }), h(new Error("timeout")));
1171
+ _ || (m(), t(k.silentLoginAsync_error, { reason: "timeout" }), h(new Error("timeout")));
1097
1172
  }, g);
1098
1173
  } catch (g) {
1099
- m(), t(w.silentLoginAsync_error, g), h(g);
1174
+ m(), t(k.silentLoginAsync_error, g), h(g);
1100
1175
  }
1101
1176
  });
1102
1177
  } catch (r) {
1103
- throw t(w.silentLoginAsync_error, r), r;
1178
+ throw t(k.silentLoginAsync_error, r), r;
1104
1179
  }
1105
- }, dn = (e, n, t, s, o) => (i = null, r = void 0) => {
1180
+ }, pn = (e, n, t, s, o) => (i = null, r = void 0) => {
1106
1181
  i = { ...i };
1107
- const a = (_, u, l) => he(n, t, s.bind(o))(
1108
- _,
1182
+ const a = (f, u, l) => we(n, t, s.bind(o))(
1183
+ f,
1109
1184
  u,
1110
1185
  l
1111
1186
  );
1112
1187
  return (async () => {
1113
- o.timeoutId && $.clearTimeout(o.timeoutId);
1114
- let _;
1115
- i && "state" in i && (_ = i.state, delete i.state);
1188
+ o.timeoutId && R.clearTimeout(o.timeoutId);
1189
+ let f;
1190
+ i && "state" in i && (f = i.state, delete i.state);
1116
1191
  try {
1117
1192
  const u = t.extras ? { ...t.extras, ...i } : i, l = await a(
1118
1193
  {
1119
1194
  ...u,
1120
1195
  prompt: "none"
1121
1196
  },
1122
- _,
1197
+ f,
1123
1198
  r
1124
1199
  );
1125
1200
  if (l)
1126
- return o.tokens = l.tokens, s(w.token_acquired, {}), o.timeoutId = G(o, o.tokens.expiresAt, i, r), {};
1201
+ return o.tokens = l.tokens, s(k.token_acquired, {}), o.timeoutId = X(o, o.tokens.expiresAt, i, r), {};
1127
1202
  } catch (u) {
1128
1203
  return u;
1129
1204
  }
1130
1205
  })();
1131
- }, hn = (e, n, t) => (s, o, i, r = !1) => {
1132
- const a = (c, _ = void 0, u = void 0) => he(e.configurationName, t, e.publishEvent.bind(e))(
1206
+ }, An = (e, n, t) => (s, o, i, r = !1) => {
1207
+ const a = (c, f = void 0, u = void 0) => we(e.configurationName, t, e.publishEvent.bind(e))(
1133
1208
  c,
1134
- _,
1209
+ f,
1135
1210
  u
1136
1211
  );
1137
- return new Promise((c, _) => {
1212
+ return new Promise((c, f) => {
1138
1213
  if (t.silent_login_uri && t.silent_redirect_uri && t.monitor_session && s && i && !r) {
1139
1214
  const u = () => {
1140
1215
  e.checkSessionIFrame.stop();
1141
1216
  const l = e.tokens;
1142
1217
  if (l === null)
1143
1218
  return;
1144
- const h = l.idToken, f = l.idTokenPayload;
1219
+ const h = l.idToken, _ = l.idTokenPayload;
1145
1220
  return a({
1146
1221
  prompt: "none",
1147
1222
  id_token_hint: h,
@@ -1150,9 +1225,9 @@ const G = (e, n, t = null, s = null) => {
1150
1225
  if (m.error)
1151
1226
  throw new Error(m.error);
1152
1227
  const p = m.tokens.idTokenPayload;
1153
- if (f.sub === p.sub) {
1228
+ if (_.sub === p.sub) {
1154
1229
  const g = m.sessionState;
1155
- e.checkSessionIFrame.start(m.sessionState), f.sid === p.sid ? console.debug(
1230
+ e.checkSessionIFrame.start(m.sessionState), _.sid === p.sid ? console.debug(
1156
1231
  "SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:",
1157
1232
  g
1158
1233
  ) : console.debug(
@@ -1170,22 +1245,22 @@ const G = (e, n, t = null, s = null) => {
1170
1245
  m
1171
1246
  );
1172
1247
  for (const [, p] of Object.entries(n))
1173
- await p.logoutOtherTabAsync(t.client_id, f.sub);
1248
+ await p.logoutOtherTabAsync(t.client_id, _.sub);
1174
1249
  });
1175
1250
  };
1176
- e.checkSessionIFrame = new $e(
1251
+ e.checkSessionIFrame = new Fe(
1177
1252
  u,
1178
1253
  o,
1179
1254
  s
1180
1255
  ), e.checkSessionIFrame.load().then(() => {
1181
1256
  e.checkSessionIFrame.start(i), c(e.checkSessionIFrame);
1182
1257
  }).catch((l) => {
1183
- _(l);
1258
+ f(l);
1184
1259
  });
1185
1260
  } else
1186
1261
  c(null);
1187
1262
  });
1188
- }, gn = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")), yn = (e) => {
1263
+ }, Sn = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")), Tn = (e) => {
1189
1264
  const n = e.appVersion, t = e.userAgent, s = "-";
1190
1265
  let o = s;
1191
1266
  const i = [
@@ -1245,7 +1320,7 @@ const G = (e, n, t = null, s = null) => {
1245
1320
  osVersion: r
1246
1321
  };
1247
1322
  };
1248
- function kn() {
1323
+ function vn() {
1249
1324
  const e = navigator.userAgent;
1250
1325
  let n, t = e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
1251
1326
  if (/trident/i.test(t[1]))
@@ -1263,23 +1338,23 @@ function kn() {
1263
1338
  version: t[1]
1264
1339
  };
1265
1340
  }
1266
- const mn = () => {
1267
- const { name: e, version: n } = kn();
1341
+ const En = () => {
1342
+ const { name: e, version: n } = vn();
1268
1343
  if (e === "chrome" && parseInt(n) <= 70 || e === "opera" && (!n || parseInt(n.split(".")[0]) < 80) || e === "ie")
1269
1344
  return !1;
1270
- const t = yn(navigator);
1271
- return !gn(t);
1272
- }, wn = async (e) => {
1345
+ const t = Tn(navigator);
1346
+ return !Sn(t);
1347
+ }, On = async (e) => {
1273
1348
  let n;
1274
1349
  if (e.tokens != null)
1275
1350
  return !1;
1276
- e.publishEvent(w.tryKeepExistingSessionAsync_begin, {});
1351
+ e.publishEvent(k.tryKeepExistingSessionAsync_begin, {});
1277
1352
  try {
1278
1353
  const t = e.configuration, s = await e.initAsync(
1279
1354
  t.authority,
1280
1355
  t.authority_configuration
1281
1356
  );
1282
- if (n = await C(t, e.configurationName), n) {
1357
+ if (n = await W(t, e.configurationName), n) {
1283
1358
  const { tokens: o } = await n.initAsync(
1284
1359
  s,
1285
1360
  "tryKeepExistingSessionAsync",
@@ -1288,7 +1363,7 @@ const mn = () => {
1288
1363
  if (o) {
1289
1364
  n.startKeepAliveServiceWorker(), e.tokens = o;
1290
1365
  const i = n.getLoginParams(e.configurationName);
1291
- e.timeoutId = G(
1366
+ e.timeoutId = X(
1292
1367
  e,
1293
1368
  e.tokens.expiresAt,
1294
1369
  i.extras,
@@ -1299,24 +1374,28 @@ const mn = () => {
1299
1374
  s.checkSessionIframe,
1300
1375
  t.client_id,
1301
1376
  r
1302
- ), t.preload_user_info && await e.userInfoAsync(), e.publishEvent(w.tryKeepExistingSessionAsync_end, {
1377
+ ), t.preload_user_info && await e.userInfoAsync(), e.publishEvent(k.tryKeepExistingSessionAsync_end, {
1303
1378
  success: !0,
1304
1379
  message: "tokens inside ServiceWorker are valid"
1305
1380
  }), !0;
1306
1381
  }
1307
- e.publishEvent(w.tryKeepExistingSessionAsync_end, {
1382
+ e.publishEvent(k.tryKeepExistingSessionAsync_end, {
1308
1383
  success: !1,
1309
1384
  message: "no exiting session found"
1310
1385
  });
1311
1386
  } else {
1312
- t.service_worker_relative_url && e.publishEvent(w.service_worker_not_supported_by_browser, {
1387
+ t.service_worker_relative_url && e.publishEvent(k.service_worker_not_supported_by_browser, {
1313
1388
  message: "service worker is not supported by this browser"
1314
1389
  });
1315
- const o = N(e.configurationName, t.storage ?? sessionStorage), { tokens: i } = await o.initAsync();
1390
+ const o = x(
1391
+ e.configurationName,
1392
+ t.storage ?? sessionStorage,
1393
+ t.login_state_storage ?? t.storage ?? sessionStorage
1394
+ ), { tokens: i } = await o.initAsync();
1316
1395
  if (i) {
1317
- e.tokens = ue(i, null, t.token_renew_mode);
1396
+ e.tokens = de(i, null, t.token_renew_mode);
1318
1397
  const r = o.getLoginParams();
1319
- e.timeoutId = G(
1398
+ e.timeoutId = X(
1320
1399
  e,
1321
1400
  e.tokens.expiresAt,
1322
1401
  r.extras,
@@ -1327,23 +1406,23 @@ const mn = () => {
1327
1406
  s.checkSessionIframe,
1328
1407
  t.client_id,
1329
1408
  a
1330
- ), t.preload_user_info && await e.userInfoAsync(), e.publishEvent(w.tryKeepExistingSessionAsync_end, {
1409
+ ), t.preload_user_info && await e.userInfoAsync(), e.publishEvent(k.tryKeepExistingSessionAsync_end, {
1331
1410
  success: !0,
1332
1411
  message: "tokens inside storage are valid"
1333
1412
  }), !0;
1334
1413
  }
1335
1414
  }
1336
- return e.publishEvent(w.tryKeepExistingSessionAsync_end, {
1415
+ return e.publishEvent(k.tryKeepExistingSessionAsync_end, {
1337
1416
  success: !1,
1338
1417
  message: n ? "service worker sessions not retrieved" : "session storage sessions not retrieved"
1339
1418
  }), !1;
1340
1419
  } catch (t) {
1341
1420
  return console.error(t), n && await n.clearAsync(), e.publishEvent(
1342
- w.tryKeepExistingSessionAsync_error,
1421
+ k.tryKeepExistingSessionAsync_error,
1343
1422
  "tokens inside ServiceWorker are invalid"
1344
1423
  ), !1;
1345
1424
  }
1346
- }, Le = (e) => {
1425
+ }, Ue = (e) => {
1347
1426
  const n = e.match(
1348
1427
  // eslint-disable-next-line no-useless-escape
1349
1428
  /^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/
@@ -1365,166 +1444,179 @@ const mn = () => {
1365
1444
  search: t,
1366
1445
  hash: s
1367
1446
  };
1368
- }, Cn = (e) => {
1369
- const n = Le(e);
1447
+ }, Kn = (e) => {
1448
+ const n = Ue(e);
1370
1449
  let { path: t } = n;
1371
1450
  t.endsWith("/") && (t = t.slice(0, -1));
1372
1451
  let { hash: s } = n;
1373
1452
  return s === "#_=_" && (s = ""), s && (t += s), t;
1374
- }, ce = (e) => {
1375
- const n = Le(e), { search: t } = n;
1376
- return pn(t);
1377
- }, pn = (e) => {
1453
+ }, _e = (e) => {
1454
+ const n = Ue(e), { search: t } = n;
1455
+ return bn(t);
1456
+ }, bn = (e) => {
1378
1457
  const n = {};
1379
1458
  let t, s, o;
1380
1459
  const i = e.split("&");
1381
1460
  for (s = 0, o = i.length; s < o; s++)
1382
1461
  t = i[s].split("="), n[decodeURIComponent(t[0])] = decodeURIComponent(t[1]);
1383
1462
  return n;
1384
- }, An = (e, n, t, s, o) => (i = void 0, r = null, a = !1, c = void 0) => {
1385
- const _ = r;
1463
+ }, Pn = (e, n, t, s, o) => (i = void 0, r = null, a = !1, c = void 0) => {
1464
+ const f = r;
1386
1465
  return r = { ...r }, (async () => {
1387
1466
  const l = i || o.getPath();
1388
- if ("state" in r || (r.state = re(16)), t(w.loginAsync_begin, {}), r)
1467
+ if ("state" in r || (r.state = le(16)), t(k.loginAsync_begin, {}), r)
1389
1468
  for (const h of Object.keys(r))
1390
1469
  h.endsWith(":token_request") && delete r[h];
1391
1470
  try {
1392
1471
  const h = a ? n.silent_redirect_uri : n.redirect_uri;
1393
1472
  c || (c = n.scope);
1394
- const f = n.extras ? { ...n.extras, ...r } : r;
1395
- f.nonce || (f.nonce = re(12));
1396
- const m = { nonce: f.nonce }, p = await C(n, e), g = await s(
1473
+ const _ = n.extras ? { ...n.extras, ...r } : r;
1474
+ _.nonce || (_.nonce = le(12));
1475
+ const m = { nonce: _.nonce }, p = await W(n, e), g = await s(
1397
1476
  n.authority,
1398
1477
  n.authority_configuration
1399
1478
  );
1400
- let k;
1479
+ let y;
1401
1480
  if (p)
1402
- p.setLoginParams({ callbackPath: l, extras: _, scope: c }), await p.initAsync(g, "loginAsync", n), await p.setNonceAsync(m), p.startKeepAliveServiceWorker(), k = p;
1481
+ p.setLoginParams({ callbackPath: l, extras: f, scope: c }), await p.initAsync(g, "loginAsync", n), await p.setNonceAsync(m), p.startKeepAliveServiceWorker(), y = p;
1403
1482
  else {
1404
- const S = N(e, n.storage ?? sessionStorage);
1405
- S.setLoginParams({ callbackPath: l, extras: _, scope: c }), await S.setNonceAsync(m), k = S;
1483
+ const T = x(
1484
+ e,
1485
+ n.storage ?? sessionStorage,
1486
+ n.login_state_storage ?? n.storage ?? sessionStorage
1487
+ );
1488
+ T.setLoginParams({ callbackPath: l, extras: f, scope: c }), await T.setNonceAsync(m), y = T;
1406
1489
  }
1407
1490
  const A = {
1408
1491
  client_id: n.client_id,
1409
1492
  redirect_uri: h,
1410
1493
  scope: c,
1411
1494
  response_type: "code",
1412
- ...f
1495
+ ..._
1413
1496
  };
1414
- await _n(k, o)(
1497
+ await mn(y, o)(
1415
1498
  g.authorizationEndpoint,
1416
1499
  A
1417
1500
  );
1418
1501
  } catch (h) {
1419
- throw t(w.loginAsync_error, h), h;
1502
+ throw t(k.loginAsync_error, h), h;
1420
1503
  }
1421
1504
  })();
1422
- }, Sn = (e) => async (n = !1) => {
1505
+ }, In = (e) => async (n = !1) => {
1423
1506
  try {
1424
- e.publishEvent(w.loginCallbackAsync_begin, {});
1507
+ e.publishEvent(k.loginCallbackAsync_begin, {});
1425
1508
  const t = e.configuration, s = t.client_id, o = n ? t.silent_redirect_uri : t.redirect_uri, i = t.authority, r = t.token_request_timeout, a = await e.initAsync(
1426
1509
  i,
1427
1510
  t.authority_configuration
1428
- ), c = e.location.getCurrentHref(), _ = ce(c), u = _.session_state, l = await C(t, e.configurationName);
1429
- let h, f, m, p;
1511
+ ), c = e.location.getCurrentHref(), f = _e(c), u = f.session_state, l = await W(t, e.configurationName);
1512
+ let h, _, m, p;
1430
1513
  if (l)
1431
- await l.initAsync(a, "loginCallbackAsync", t), await l.setSessionStateAsync(u), f = await l.getNonceAsync(), m = l.getLoginParams(), p = await l.getStateAsync(), l.startKeepAliveServiceWorker(), h = l;
1514
+ await l.initAsync(a, "loginCallbackAsync", t), await l.setSessionStateAsync(u), _ = await l.getNonceAsync(), m = l.getLoginParams(), p = await l.getStateAsync(), l.startKeepAliveServiceWorker(), h = l;
1432
1515
  else {
1433
- const T = N(
1516
+ const E = x(
1434
1517
  e.configurationName,
1435
- t.storage ?? sessionStorage
1518
+ t.storage ?? sessionStorage,
1519
+ t.login_state_storage ?? t.storage ?? sessionStorage
1436
1520
  );
1437
- await T.setSessionStateAsync(u), f = await T.getNonceAsync(), m = T.getLoginParams(), p = await T.getStateAsync(), h = T;
1521
+ await E.setSessionStateAsync(u), _ = await E.getNonceAsync(), m = E.getLoginParams(), p = await E.getStateAsync(), h = E;
1438
1522
  }
1439
- if (_.error || _.error_description)
1523
+ if (f.error || f.error_description)
1440
1524
  throw new Error(
1441
- `Error from OIDC server: ${_.error} - ${_.error_description}`
1525
+ `Error from OIDC server: ${f.error} - ${f.error_description}`
1442
1526
  );
1443
- if (_.iss && _.iss !== a.issuer)
1527
+ if (f.iss && f.iss !== a.issuer)
1444
1528
  throw console.error(), new Error(
1445
- `Issuer not valid (expected: ${a.issuer}, received: ${_.iss})`
1529
+ `Issuer not valid (expected: ${a.issuer}, received: ${f.iss})`
1446
1530
  );
1447
- if (_.state && _.state !== p)
1448
- throw new Error(`State not valid (expected: ${p}, received: ${_.state})`);
1531
+ if (f.state && f.state !== p)
1532
+ throw new Error(`State not valid (expected: ${p}, received: ${f.state})`);
1449
1533
  const g = {
1450
- code: _.code,
1534
+ code: f.code,
1451
1535
  grant_type: "authorization_code",
1452
1536
  client_id: t.client_id,
1453
1537
  redirect_uri: o
1454
- }, k = {};
1538
+ }, y = {};
1455
1539
  if (t.token_request_extras)
1456
- for (const [T, d] of Object.entries(t.token_request_extras))
1457
- k[T] = d;
1540
+ for (const [E, d] of Object.entries(t.token_request_extras))
1541
+ y[E] = d;
1458
1542
  if (m?.extras)
1459
- for (const [T, d] of Object.entries(m.extras))
1460
- T.endsWith(":token_request") && (k[T.replace(":token_request", "")] = d);
1461
- const A = a.tokenEndpoint, S = {};
1543
+ for (const [E, d] of Object.entries(m.extras))
1544
+ E.endsWith(":token_request") && (y[E.replace(":token_request", "")] = d);
1545
+ const A = a.tokenEndpoint, T = {};
1462
1546
  if (t.demonstrating_proof_of_possession)
1463
1547
  if (l)
1464
- S.DPoP = `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${e.configurationName}`;
1548
+ T.DPoP = `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${e.configurationName}`;
1465
1549
  else {
1466
- const T = await tn(window)(
1550
+ const E = await un(window)(
1467
1551
  t.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm
1468
1552
  );
1469
- await N(e.configurationName, t.storage).setDemonstratingProofOfPossessionJwkAsync(T), S.DPoP = await Ne(window)(
1553
+ await x(
1554
+ e.configurationName,
1555
+ t.storage,
1556
+ t.login_state_storage ?? t.storage
1557
+ ).setDemonstratingProofOfPossessionJwkAsync(E), T.DPoP = await De(window)(
1470
1558
  t.demonstrating_proof_of_possession_configuration
1471
- )(T, "POST", A);
1559
+ )(E, "POST", A);
1472
1560
  }
1473
- const E = await fn(h)(
1561
+ const O = await wn(h)(
1474
1562
  A,
1475
- { ...g, ...k },
1476
- S,
1563
+ { ...g, ...y },
1564
+ T,
1477
1565
  e.configuration.token_renew_mode,
1478
1566
  r
1479
1567
  );
1480
- if (!E.success)
1568
+ if (!O.success)
1481
1569
  throw new Error("Token request failed");
1482
- let y;
1483
- const I = E.data.tokens, x = E.data.demonstratingProofOfPossessionNonce;
1484
- if (E.data.state !== k.state)
1570
+ let v;
1571
+ const C = O.data.tokens, w = O.data.demonstratingProofOfPossessionNonce;
1572
+ if (O.data.state !== y.state)
1485
1573
  throw new Error("state is not valid");
1486
- const { isValid: F, reason: L } = Ee(
1487
- I,
1488
- f.nonce,
1574
+ const { isValid: H, reason: $ } = Ne(
1575
+ C,
1576
+ _.nonce,
1489
1577
  a
1490
1578
  );
1491
- if (!F)
1492
- throw new Error(`Tokens are not OpenID valid, reason: ${L}`);
1579
+ if (!H)
1580
+ throw new Error(`Tokens are not OpenID valid, reason: ${$}`);
1493
1581
  if (l) {
1494
- if (I.refreshToken && !I.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))
1582
+ if (C.refreshToken && !C.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))
1495
1583
  throw new Error("Refresh token should be hidden by service worker");
1496
- if (x && I?.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))
1584
+ if (w && C?.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))
1497
1585
  throw new Error(
1498
1586
  "Demonstration of proof of possession require Access token not hidden by service worker"
1499
1587
  );
1500
1588
  }
1501
1589
  if (l)
1502
- await l.initAsync(a, "syncTokensAsync", t), y = l.getLoginParams(), x && await l.setDemonstratingProofOfPossessionNonce(
1503
- x
1590
+ await l.initAsync(a, "syncTokensAsync", t), v = l.getLoginParams(), w && await l.setDemonstratingProofOfPossessionNonce(
1591
+ w
1504
1592
  );
1505
1593
  else {
1506
- const T = N(e.configurationName, t.storage);
1507
- y = T.getLoginParams(), x && await T.setDemonstratingProofOfPossessionNonce(x);
1594
+ const E = x(
1595
+ e.configurationName,
1596
+ t.storage,
1597
+ t.login_state_storage ?? t.storage
1598
+ );
1599
+ v = E.getLoginParams(), w && await E.setDemonstratingProofOfPossessionNonce(w);
1508
1600
  }
1509
1601
  return await e.startCheckSessionAsync(
1510
1602
  a.checkSessionIframe,
1511
1603
  s,
1512
1604
  u,
1513
1605
  n
1514
- ), e.publishEvent(w.loginCallbackAsync_end, {}), {
1515
- tokens: I,
1606
+ ), e.publishEvent(k.loginCallbackAsync_end, {}), {
1607
+ tokens: C,
1516
1608
  state: "request.state",
1517
- callbackPath: y.callbackPath,
1518
- scope: _.scope,
1519
- extras: y.extras
1609
+ callbackPath: v.callbackPath,
1610
+ scope: f.scope,
1611
+ extras: v.extras
1520
1612
  };
1521
1613
  } catch (t) {
1522
- throw console.error(t), e.publishEvent(w.loginCallbackAsync_error, t), t;
1614
+ throw console.error(t), e.publishEvent(k.loginCallbackAsync_error, t), t;
1523
1615
  }
1524
- }, Se = {
1616
+ }, Pe = {
1525
1617
  access_token: "access_token",
1526
1618
  refresh_token: "refresh_token"
1527
- }, se = (e, n) => {
1619
+ }, ie = (e, n) => {
1528
1620
  const t = {};
1529
1621
  if (e) {
1530
1622
  for (const [s, o] of Object.entries(e))
@@ -1535,7 +1627,7 @@ const mn = () => {
1535
1627
  return t;
1536
1628
  }
1537
1629
  return t;
1538
- }, Tn = (e) => {
1630
+ }, Cn = (e) => {
1539
1631
  const n = {};
1540
1632
  if (e) {
1541
1633
  for (const [t, s] of Object.entries(e))
@@ -1543,104 +1635,108 @@ const mn = () => {
1543
1635
  return n;
1544
1636
  }
1545
1637
  return n;
1546
- }, vn = (e) => async (n) => {
1547
- $.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
1548
- const t = await C(e.configuration, e.configurationName);
1549
- t ? await t.clearAsync(n) : await N(e.configurationName, e.configuration.storage).clearAsync(n), e.tokens = null, e.userInfo = null;
1550
- }, En = (e, n, t, s, o) => async (i = void 0, r = null) => {
1638
+ }, Nn = (e) => async (n) => {
1639
+ R.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
1640
+ const t = await W(e.configuration, e.configurationName);
1641
+ t ? await t.clearAsync(n) : await x(
1642
+ e.configurationName,
1643
+ e.configuration.storage,
1644
+ e.configuration.login_state_storage ?? e.configuration.storage
1645
+ ).clearAsync(n), e.tokens = null, e.userInfo = null;
1646
+ }, xn = (e, n, t, s, o) => async (i = void 0, r = null) => {
1551
1647
  const a = e.configuration, c = await e.initAsync(
1552
1648
  a.authority,
1553
1649
  a.authority_configuration
1554
1650
  );
1555
1651
  i && typeof i != "string" && (i = void 0, s.warn("callbackPathOrUrl path is not a string"));
1556
- const _ = i ?? o.getPath();
1652
+ const f = i ?? o.getPath();
1557
1653
  let u = !1;
1558
1654
  i && (u = i.includes("https://") || i.includes("http://"));
1559
- const l = u ? i : o.getOrigin() + _, h = e.tokens ? e.tokens.idToken : "";
1655
+ const l = u ? i : o.getOrigin() + f, h = e.tokens ? e.tokens.idToken : "";
1560
1656
  try {
1561
- const k = c.revocationEndpoint;
1562
- if (k) {
1563
- const A = [], S = e.tokens ? e.tokens.accessToken : null;
1564
- if (S && a.logout_tokens_to_invalidate.includes(Se.access_token)) {
1565
- const y = se(r, ":revoke_access_token"), I = pe(t)(
1566
- k,
1567
- S,
1568
- ae.access_token,
1657
+ const y = c.revocationEndpoint;
1658
+ if (y) {
1659
+ const A = [], T = e.tokens ? e.tokens.accessToken : null;
1660
+ if (T && a.logout_tokens_to_invalidate.includes(Pe.access_token)) {
1661
+ const v = ie(r, ":revoke_access_token"), C = Oe(t)(
1662
+ y,
1663
+ T,
1664
+ ue.access_token,
1569
1665
  a.client_id,
1570
- y
1666
+ v
1571
1667
  );
1572
- A.push(I);
1668
+ A.push(C);
1573
1669
  }
1574
- const E = e.tokens ? e.tokens.refreshToken : null;
1575
- if (E && a.logout_tokens_to_invalidate.includes(Se.refresh_token)) {
1576
- const y = se(r, ":revoke_refresh_token"), I = pe(t)(
1577
- k,
1578
- E,
1579
- ae.refresh_token,
1670
+ const O = e.tokens ? e.tokens.refreshToken : null;
1671
+ if (O && a.logout_tokens_to_invalidate.includes(Pe.refresh_token)) {
1672
+ const v = ie(r, ":revoke_refresh_token"), C = Oe(t)(
1673
+ y,
1674
+ O,
1675
+ ue.refresh_token,
1580
1676
  a.client_id,
1581
- y
1677
+ v
1582
1678
  );
1583
- A.push(I);
1679
+ A.push(C);
1584
1680
  }
1585
1681
  A.length > 0 && await Promise.all(A);
1586
1682
  }
1587
- } catch (k) {
1683
+ } catch (y) {
1588
1684
  s.warn(
1589
1685
  "logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"
1590
- ), s.warn(k);
1686
+ ), s.warn(y);
1591
1687
  }
1592
- const f = e.tokens?.idTokenPayload?.sub ?? null;
1688
+ const _ = e.tokens?.idTokenPayload?.sub ?? null;
1593
1689
  await e.destroyAsync("LOGGED_OUT");
1594
- for (const [, k] of Object.entries(n))
1595
- k !== e ? await e.logoutSameTabAsync(e.configuration.client_id, f) : e.publishEvent(w.logout_from_same_tab, {});
1596
- const m = se(r, ":oidc");
1690
+ for (const [, y] of Object.entries(n))
1691
+ y !== e ? await e.logoutSameTabAsync(e.configuration.client_id, _) : e.publishEvent(k.logout_from_same_tab, {});
1692
+ const m = ie(r, ":oidc");
1597
1693
  if (m && m.no_reload === "true")
1598
1694
  return;
1599
- const g = Tn(r);
1695
+ const g = Cn(r);
1600
1696
  if (c.endSessionEndpoint) {
1601
1697
  "id_token_hint" in g || (g.id_token_hint = h), !("post_logout_redirect_uri" in g) && i !== null && (g.post_logout_redirect_uri = l);
1602
- let k = "";
1603
- for (const [A, S] of Object.entries(g))
1604
- S != null && (k === "" ? k += "?" : k += "&", k += `${A}=${encodeURIComponent(S)}`);
1605
- o.open(`${c.endSessionEndpoint}${k}`);
1698
+ let y = "";
1699
+ for (const [A, T] of Object.entries(g))
1700
+ T != null && (y === "" ? y += "?" : y += "&", y += `${A}=${encodeURIComponent(T)}`);
1701
+ o.open(`${c.endSessionEndpoint}${y}`);
1606
1702
  } else
1607
1703
  o.reload();
1608
- }, De = (e, n, t = !1) => async (...s) => {
1704
+ }, Ve = (e, n, t = !1) => async (...s) => {
1609
1705
  const [o, i, ...r] = s, a = i ? { ...i } : { method: "GET" };
1610
1706
  let c = new Headers();
1611
1707
  a.headers && (c = a.headers instanceof Headers ? a.headers : new Headers(a.headers));
1612
- const _ = {
1708
+ const f = {
1613
1709
  getTokens: () => n.tokens,
1614
1710
  configuration: {
1615
1711
  token_automatic_renew_mode: n.configuration.token_automatic_renew_mode,
1616
1712
  refresh_time_before_tokens_expiration_in_second: n.configuration.refresh_time_before_tokens_expiration_in_second
1617
1713
  },
1618
1714
  syncTokensInfoAsync: async () => {
1619
- const { status: f } = await de(n)(
1715
+ const { status: _ } = await me(n)(
1620
1716
  n.configuration,
1621
1717
  n.configurationName,
1622
1718
  n.tokens,
1623
1719
  !1
1624
1720
  );
1625
- return f;
1721
+ return _;
1626
1722
  },
1627
1723
  renewTokensAsync: n.renewTokensAsync.bind(n)
1628
- }, l = (await ve(_))?.tokens?.accessToken;
1724
+ }, l = (await Ce(f))?.tokens?.accessToken;
1629
1725
  if (c.has("Accept") || c.set("Accept", "application/json"), l) {
1630
1726
  if (n.configuration.demonstrating_proof_of_possession && t) {
1631
- const f = await n.generateDemonstrationOfProofOfPossessionAsync(
1727
+ const _ = await n.generateDemonstrationOfProofOfPossessionAsync(
1632
1728
  l,
1633
1729
  o.toString(),
1634
1730
  a.method
1635
1731
  );
1636
- c.set("Authorization", `DPoP ${l}`), c.set("DPoP", f);
1732
+ c.set("Authorization", `DPoP ${l}`), c.set("DPoP", _);
1637
1733
  } else
1638
1734
  c.set("Authorization", `Bearer ${l}`);
1639
1735
  a.credentials || (a.credentials = "same-origin");
1640
1736
  }
1641
1737
  const h = { ...a, headers: c };
1642
1738
  return await e(o, h, ...r);
1643
- }, On = (e) => async (n = !1, t = !1) => {
1739
+ }, Wn = (e) => async (n = !1, t = !1) => {
1644
1740
  if (e.userInfo != null && !n)
1645
1741
  return e.userInfo;
1646
1742
  const s = !n && e.configuration.storage?.getItem(`oidc.${e.configurationName}.userInfo`);
@@ -1650,49 +1746,49 @@ const mn = () => {
1650
1746
  o.authority,
1651
1747
  o.authority_configuration
1652
1748
  )).userInfoEndpoint, c = await (async () => {
1653
- const u = await De(fetch, e, t)(r);
1749
+ const u = await Ve(fetch, e, t)(r);
1654
1750
  return u.status !== 200 ? null : u.json();
1655
1751
  })();
1656
1752
  return e.userInfo = c, c && e.configuration.storage?.setItem(
1657
1753
  `oidc.${e.configurationName}.userInfo`,
1658
1754
  JSON.stringify(c)
1659
1755
  ), c;
1660
- }, bn = () => fetch;
1661
- class le {
1756
+ }, Ln = () => fetch;
1757
+ class fe {
1662
1758
  constructor(n) {
1663
1759
  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;
1664
1760
  }
1665
1761
  }
1666
- const R = {}, Pn = (e, n = new Q()) => (t, s = "default") => (R[s] || (R[s] = new W(t, s, e, n)), R[s]), In = async (e) => {
1762
+ const V = {}, Dn = (e, n = new ee()) => (t, s = "default") => (V[s] || (V[s] = new D(t, s, e, n)), V[s]), Rn = async (e) => {
1667
1763
  const { parsedTokens: n, callbackPath: t, extras: s, scope: o } = await e.loginCallbackAsync();
1668
- return e.timeoutId = G(e, n.expiresAt, s, o), { callbackPath: t };
1669
- }, Nn = (e) => Math.floor(Math.random() * e), J = class J {
1670
- constructor(n, t = "default", s, o = new Q()) {
1764
+ return e.timeoutId = X(e, n.expiresAt, s, o), { callbackPath: t };
1765
+ }, $n = (e) => Math.floor(Math.random() * e), j = class j {
1766
+ constructor(n, t = "default", s, o = new ee()) {
1671
1767
  this.initPromise = null, this.tryKeepExistingSessionPromise = null, this.loginPromise = null, this.loginCallbackPromise = null, this.loginCallbackWithAutoTokensRenewPromise = null, this.userInfoPromise = null, this.renewTokensPromise = null, this.logoutPromise = null;
1672
1768
  let i = n.silent_login_uri;
1673
1769
  n.silent_redirect_uri && !n.silent_login_uri && (i = `${n.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
1674
1770
  let r = n.refresh_time_before_tokens_expiration_in_second ?? 120;
1675
- r > 60 && (r = r - Math.floor(Math.random() * 40)), this.location = o ?? new Q(), this.configuration = {
1771
+ r > 60 && (r = r - Math.floor(Math.random() * 40)), this.location = o ?? new ee(), this.configuration = {
1676
1772
  ...n,
1677
1773
  silent_login_uri: i,
1678
- token_automatic_renew_mode: n.token_automatic_renew_mode ?? H.AutomaticBeforeTokenExpiration,
1774
+ token_automatic_renew_mode: n.token_automatic_renew_mode ?? q.AutomaticBeforeTokenExpiration,
1679
1775
  monitor_session: n.monitor_session ?? !1,
1680
1776
  refresh_time_before_tokens_expiration_in_second: r,
1681
1777
  silent_login_timeout: n.silent_login_timeout ?? 12e3,
1682
- token_renew_mode: n.token_renew_mode ?? oe.access_token_or_id_token_invalid,
1778
+ token_renew_mode: n.token_renew_mode ?? re.access_token_or_id_token_invalid,
1683
1779
  demonstrating_proof_of_possession: n.demonstrating_proof_of_possession ?? !1,
1684
1780
  authority_timeout_wellknowurl_in_millisecond: n.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
1685
1781
  logout_tokens_to_invalidate: n.logout_tokens_to_invalidate ?? [
1686
1782
  "access_token",
1687
1783
  "refresh_token"
1688
1784
  ],
1689
- service_worker_activate: n.service_worker_activate ?? mn,
1690
- demonstrating_proof_of_possession_configuration: n.demonstrating_proof_of_possession_configuration ?? qe,
1785
+ service_worker_activate: n.service_worker_activate ?? En,
1786
+ demonstrating_proof_of_possession_configuration: n.demonstrating_proof_of_possession_configuration ?? nn,
1691
1787
  preload_user_info: n.preload_user_info ?? !1
1692
- }, this.getFetch = s ?? bn, this.configurationName = t, this.tokens = null, this.userInfo = null, this.events = [], this.timeoutId = null, this.loginCallbackWithAutoTokensRenewAsync.bind(this), this.initAsync.bind(this), this.loginCallbackAsync.bind(this), this.subscribeEvents.bind(this), this.removeEventSubscription.bind(this), this.publishEvent.bind(this), this.destroyAsync.bind(this), this.logoutAsync.bind(this), this.renewTokensAsync.bind(this), this.initAsync(this.configuration.authority, this.configuration.authority_configuration);
1788
+ }, this.getFetch = s ?? Ln, this.configurationName = t, this.tokens = null, this.userInfo = null, this.events = [], this.timeoutId = null, this.loginCallbackWithAutoTokensRenewAsync.bind(this), this.initAsync.bind(this), this.loginCallbackAsync.bind(this), this.subscribeEvents.bind(this), this.removeEventSubscription.bind(this), this.publishEvent.bind(this), this.destroyAsync.bind(this), this.logoutAsync.bind(this), this.renewTokensAsync.bind(this), this.initAsync(this.configuration.authority, this.configuration.authority_configuration);
1693
1789
  }
1694
1790
  subscribeEvents(n) {
1695
- const t = Nn(9999999999999).toString();
1791
+ const t = $n(9999999999999).toString();
1696
1792
  return this.events.push({ id: t, func: n }), t;
1697
1793
  }
1698
1794
  removeEventSubscription(n) {
@@ -1706,14 +1802,14 @@ const R = {}, Pn = (e, n = new Q()) => (t, s = "default") => (R[s] || (R[s] = ne
1706
1802
  }
1707
1803
  static get(n = "default") {
1708
1804
  const t = typeof process > "u";
1709
- if (!Object.prototype.hasOwnProperty.call(R, n) && t)
1805
+ if (!Object.prototype.hasOwnProperty.call(V, n) && t)
1710
1806
  throw Error(`OIDC library does seem initialized.
1711
1807
  Please checkout that you are using OIDC hook inside a <OidcProvider configurationName="${n}"></OidcProvider> component.`);
1712
- return R[n];
1808
+ return V[n];
1713
1809
  }
1714
1810
  _silentLoginCallbackFromIFrame() {
1715
1811
  if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
1716
- const n = this.location, t = ce(n.getCurrentHref());
1812
+ const n = this.location, t = _e(n.getCurrentHref());
1717
1813
  window.parent.postMessage(
1718
1814
  `${this.configurationName}_oidc_tokens:${JSON.stringify({ tokens: this.tokens, sessionState: t.session_state })}`,
1719
1815
  n.getOrigin()
@@ -1722,7 +1818,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1722
1818
  }
1723
1819
  _silentLoginErrorCallbackFromIFrame(n = null) {
1724
1820
  if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
1725
- const t = this.location, s = ce(t.getCurrentHref());
1821
+ const t = this.location, s = _e(t.getCurrentHref());
1726
1822
  s.error ? window.parent.postMessage(
1727
1823
  `${this.configurationName}_oidc_error:${JSON.stringify({ error: s.error })}`,
1728
1824
  t.getOrigin()
@@ -1744,7 +1840,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1744
1840
  return this.initPromise;
1745
1841
  const s = async () => {
1746
1842
  if (t != null)
1747
- return new le({
1843
+ return new fe({
1748
1844
  authorization_endpoint: t.authorization_endpoint,
1749
1845
  end_session_endpoint: t.end_session_endpoint,
1750
1846
  revocation_endpoint: t.revocation_endpoint,
@@ -1753,8 +1849,8 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1753
1849
  check_session_iframe: t.check_session_iframe,
1754
1850
  issuer: t.issuer
1755
1851
  });
1756
- const i = await C(this.configuration, this.configurationName) ? this.configuration.storage || window.sessionStorage : this.configuration.storage;
1757
- return await ln(this.getFetch())(
1852
+ const i = await W(this.configuration, this.configurationName) ? this.configuration.storage || window.sessionStorage : this.configuration.storage;
1853
+ return await yn(this.getFetch())(
1758
1854
  n,
1759
1855
  this.configuration.authority_time_cache_wellknowurl_in_second ?? 3600,
1760
1856
  i,
@@ -1766,12 +1862,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1766
1862
  });
1767
1863
  }
1768
1864
  async tryKeepExistingSessionAsync() {
1769
- return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise = wn(this), this.tryKeepExistingSessionPromise.finally(() => {
1865
+ return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise = On(this), this.tryKeepExistingSessionPromise.finally(() => {
1770
1866
  this.tryKeepExistingSessionPromise = null;
1771
1867
  }));
1772
1868
  }
1773
1869
  async startCheckSessionAsync(n, t, s, o = !1) {
1774
- await hn(this, R, this.configuration)(
1870
+ await An(this, V, this.configuration)(
1775
1871
  n,
1776
1872
  t,
1777
1873
  s,
@@ -1779,13 +1875,13 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1779
1875
  );
1780
1876
  }
1781
1877
  async loginAsync(n = void 0, t = null, s = !1, o = void 0, i = !1) {
1782
- return this.logoutPromise && await this.logoutPromise, this.loginPromise !== null ? this.loginPromise : (i ? this.loginPromise = dn(
1878
+ return this.logoutPromise && await this.logoutPromise, this.loginPromise !== null ? this.loginPromise : (i ? this.loginPromise = pn(
1783
1879
  window,
1784
1880
  this.configurationName,
1785
1881
  this.configuration,
1786
1882
  this.publishEvent.bind(this),
1787
1883
  this
1788
- )(t, o) : this.loginPromise = An(
1884
+ )(t, o) : this.loginPromise = Pn(
1789
1885
  this.configurationName,
1790
1886
  this.configuration,
1791
1887
  this.publishEvent.bind(this),
@@ -1799,8 +1895,12 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1799
1895
  if (this.loginCallbackPromise !== null)
1800
1896
  return this.loginCallbackPromise;
1801
1897
  const t = async () => {
1802
- const s = await Sn(this)(n), o = s.tokens;
1803
- return this.tokens = o, await C(this.configuration, this.configurationName) || N(this.configurationName, this.configuration.storage).setTokens(o), this.publishEvent(J.eventNames.token_acquired, o), this.configuration.preload_user_info && await this.userInfoAsync(), {
1898
+ const s = await In(this)(n), o = s.tokens;
1899
+ return this.tokens = o, await W(this.configuration, this.configurationName) || x(
1900
+ this.configurationName,
1901
+ this.configuration.storage,
1902
+ this.configuration.login_state_storage ?? this.configuration.storage
1903
+ ).setTokens(o), this.publishEvent(j.eventNames.token_acquired, o), this.configuration.preload_user_info && await this.userInfoAsync(), {
1804
1904
  parsedTokens: o,
1805
1905
  state: s.state,
1806
1906
  callbackPath: s.callbackPath,
@@ -1814,23 +1914,27 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1814
1914
  }
1815
1915
  async generateDemonstrationOfProofOfPossessionAsync(n, t, s, o = {}) {
1816
1916
  const i = this.configuration, r = {
1817
- ath: await xe(n),
1917
+ ath: await $e(n),
1818
1918
  ...o
1819
1919
  };
1820
- if (await C(i, this.configurationName))
1821
- return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${be(this.configurationName)}`;
1822
- const c = N(this.configurationName, i.storage), _ = await c.getDemonstratingProofOfPossessionJwkAsync(), u = c.getDemonstratingProofOfPossessionNonce();
1823
- return u && (r.nonce = u), await Ne(window)(
1920
+ if (await W(i, this.configurationName))
1921
+ return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${he(this.configurationName)}`;
1922
+ const c = x(
1923
+ this.configurationName,
1924
+ i.storage,
1925
+ i.login_state_storage ?? i.storage
1926
+ ), f = await c.getDemonstratingProofOfPossessionJwkAsync(), u = c.getDemonstratingProofOfPossessionNonce();
1927
+ return u && (r.nonce = u), await De(window)(
1824
1928
  i.demonstrating_proof_of_possession_configuration
1825
- )(_, s, t, r);
1929
+ )(f, s, t, r);
1826
1930
  }
1827
1931
  loginCallbackWithAutoTokensRenewAsync() {
1828
- return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise = In(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
1932
+ return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise = Rn(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
1829
1933
  this.loginCallbackWithAutoTokensRenewPromise = null;
1830
1934
  }));
1831
1935
  }
1832
1936
  userInfoAsync(n = !1, t = !1) {
1833
- return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise = On(this)(n, t), this.userInfoPromise.finally(() => {
1937
+ return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise = Wn(this)(n, t), this.userInfoPromise.finally(() => {
1834
1938
  this.userInfoPromise = null;
1835
1939
  }));
1836
1940
  }
@@ -1838,23 +1942,23 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1838
1942
  if (this.renewTokensPromise !== null)
1839
1943
  return this.renewTokensPromise;
1840
1944
  if (this.timeoutId)
1841
- return $.clearTimeout(this.timeoutId), this.renewTokensPromise = We(this, !0, n, t), this.renewTokensPromise.finally(() => {
1945
+ return R.clearTimeout(this.timeoutId), this.renewTokensPromise = Ke(this, !0, n, t), this.renewTokensPromise.finally(() => {
1842
1946
  this.renewTokensPromise = null;
1843
1947
  });
1844
1948
  }
1845
1949
  async destroyAsync(n) {
1846
- return await vn(this)(n);
1950
+ return await Nn(this)(n);
1847
1951
  }
1848
1952
  async logoutSameTabAsync(n, t) {
1849
- this.configuration.monitor_session && this.configuration.client_id === n && t && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === t && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(w.logout_from_same_tab, { mmessage: "SessionMonitor", sub: t }));
1953
+ this.configuration.monitor_session && this.configuration.client_id === n && t && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === t && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(k.logout_from_same_tab, { mmessage: "SessionMonitor", sub: t }));
1850
1954
  }
1851
1955
  async logoutOtherTabAsync(n, t) {
1852
- this.configuration.monitor_session && this.configuration.client_id === n && t && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === t && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(w.logout_from_another_tab, { message: "SessionMonitor", sub: t }));
1956
+ this.configuration.monitor_session && this.configuration.client_id === n && t && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === t && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(k.logout_from_another_tab, { message: "SessionMonitor", sub: t }));
1853
1957
  }
1854
1958
  async logoutAsync(n = void 0, t = null) {
1855
- return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = En(
1959
+ return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = xn(
1856
1960
  this,
1857
- R,
1961
+ V,
1858
1962
  this.getFetch(),
1859
1963
  console,
1860
1964
  this.location
@@ -1863,9 +1967,9 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1863
1967
  }));
1864
1968
  }
1865
1969
  };
1866
- J.getOrCreate = (n, t) => (s, o = "default") => Pn(n, t)(s, o), J.eventNames = w;
1867
- let W = J;
1868
- const V = class V {
1970
+ j.getOrCreate = (n, t) => (s, o = "default") => Dn(n, t)(s, o), j.eventNames = k;
1971
+ let D = j;
1972
+ const J = class J {
1869
1973
  constructor(n) {
1870
1974
  this._oidc = n;
1871
1975
  }
@@ -1879,7 +1983,7 @@ const V = class V {
1879
1983
  this._oidc.publishEvent(n, t);
1880
1984
  }
1881
1985
  static get(n = "default") {
1882
- return new V(W.get(n));
1986
+ return new J(D.get(n));
1883
1987
  }
1884
1988
  tryKeepExistingSessionAsync() {
1885
1989
  return this._oidc.tryKeepExistingSessionAsync();
@@ -1921,7 +2025,7 @@ const V = class V {
1921
2025
  refresh_time_before_tokens_expiration_in_second: s.configuration.refresh_time_before_tokens_expiration_in_second
1922
2026
  },
1923
2027
  syncTokensInfoAsync: async () => {
1924
- const { status: i } = await de(s)(
2028
+ const { status: i } = await me(s)(
1925
2029
  s.configuration,
1926
2030
  s.configurationName,
1927
2031
  s.tokens,
@@ -1931,10 +2035,10 @@ const V = class V {
1931
2035
  },
1932
2036
  renewTokensAsync: s.renewTokensAsync.bind(s)
1933
2037
  };
1934
- return ve(o, n, t);
2038
+ return Ce(o, n, t);
1935
2039
  }
1936
2040
  fetchWithTokens(n, t = !1) {
1937
- return De(n, this._oidc, t);
2041
+ return Ve(n, this._oidc, t);
1938
2042
  }
1939
2043
  async userInfoAsync(n = !1, t = !1) {
1940
2044
  return this._oidc.userInfoAsync(n, t);
@@ -1943,14 +2047,14 @@ const V = class V {
1943
2047
  return this._oidc.userInfo;
1944
2048
  }
1945
2049
  };
1946
- V.getOrCreate = (n, t = new Q()) => (s, o = "default") => new V(W.getOrCreate(n, t)(s, o)), V.eventNames = W.eventNames;
1947
- let Te = V;
2050
+ J.getOrCreate = (n, t = new ee()) => (s, o = "default") => new J(D.getOrCreate(n, t)(s, o)), J.eventNames = D.eventNames;
2051
+ let Ie = J;
1948
2052
  export {
1949
- Te as OidcClient,
1950
- Q as OidcLocation,
1951
- H as TokenAutomaticRenewMode,
1952
- oe as TokenRenewMode,
1953
- bn as getFetchDefault,
1954
- ce as getParseQueryStringFromLocation,
1955
- Cn as getPath
2053
+ Ie as OidcClient,
2054
+ ee as OidcLocation,
2055
+ q as TokenAutomaticRenewMode,
2056
+ re as TokenRenewMode,
2057
+ Ln as getFetchDefault,
2058
+ _e as getParseQueryStringFromLocation,
2059
+ Kn as getPath
1956
2060
  };