@axa-fr/oidc-client 7.26.3 → 7.26.4

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