@axa-fr/oidc-client 7.14.0 → 7.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,24 +1,24 @@
1
1
  const L = console;
2
- class Ee {
3
- constructor(e, n, t, o = 2e3, i = !0) {
4
- this._callback = e, this._client_id = n, this._url = t, this._interval = o || 2e3, this._stopOnError = i;
2
+ class Oe {
3
+ constructor(s, n, t, o = 2e3, i = !0) {
4
+ this._callback = s, this._client_id = n, this._url = t, this._interval = o || 2e3, this._stopOnError = i;
5
5
  const r = t.indexOf("/", t.indexOf("//") + 2);
6
6
  this._frame_origin = t.substr(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;
7
7
  }
8
8
  load() {
9
- return new Promise((e) => {
9
+ return new Promise((s) => {
10
10
  this._frame.onload = () => {
11
- e();
11
+ s();
12
12
  }, window.document.body.appendChild(this._frame), this._boundMessageEvent = this._message.bind(this), window.addEventListener("message", this._boundMessageEvent, !1);
13
13
  });
14
14
  }
15
- _message(e) {
16
- e.origin === this._frame_origin && e.source === this._frame.contentWindow && (e.data === "error" ? (L.error("CheckSessionIFrame: error message from check session op iframe"), this._stopOnError && this.stop()) : e.data === "changed" ? (L.debug(e), L.debug("CheckSessionIFrame: changed message from check session op iframe"), this.stop(), this._callback()) : L.debug("CheckSessionIFrame: " + e.data + " message from check session op iframe"));
15
+ _message(s) {
16
+ s.origin === this._frame_origin && s.source === this._frame.contentWindow && (s.data === "error" ? (L.error("CheckSessionIFrame: error message from check session op iframe"), this._stopOnError && this.stop()) : s.data === "changed" ? (L.debug(s), L.debug("CheckSessionIFrame: changed message from check session op iframe"), this.stop(), this._callback()) : L.debug("CheckSessionIFrame: " + s.data + " message from check session op iframe"));
17
17
  }
18
- start(e) {
19
- L.debug("CheckSessionIFrame.start :" + e), this.stop();
18
+ start(s) {
19
+ L.debug("CheckSessionIFrame.start :" + s), this.stop();
20
20
  const n = () => {
21
- this._frame.contentWindow.postMessage(this._client_id + " " + e, this._frame_origin);
21
+ this._frame.contentWindow.postMessage(this._client_id + " " + s, this._frame_origin);
22
22
  };
23
23
  n(), this._timer = window.setInterval(n, this._interval);
24
24
  }
@@ -54,23 +54,23 @@ const m = {
54
54
  syncTokensAsync_lock_not_available: "syncTokensAsync_lock_not_available",
55
55
  syncTokensAsync_end: "syncTokensAsync_end",
56
56
  syncTokensAsync_error: "syncTokensAsync_error"
57
- }, I = (s, e = sessionStorage) => {
58
- const n = (p) => (e[`oidc.${s}`] = JSON.stringify({ tokens: null, status: p }), Promise.resolve()), t = async () => {
59
- if (!e[`oidc.${s}`])
60
- return e[`oidc.${s}`] = JSON.stringify({ tokens: null, status: null }), { tokens: null, status: null };
61
- const p = JSON.parse(e[`oidc.${s}`]);
57
+ }, I = (e, s = sessionStorage) => {
58
+ const n = (p) => (s[`oidc.${e}`] = JSON.stringify({ tokens: null, status: p }), Promise.resolve()), t = async () => {
59
+ if (!s[`oidc.${e}`])
60
+ return s[`oidc.${e}`] = JSON.stringify({ tokens: null, status: null }), { tokens: null, status: null };
61
+ const p = JSON.parse(s[`oidc.${e}`]);
62
62
  return Promise.resolve({ tokens: p.tokens, status: p.status });
63
63
  }, o = (p) => {
64
- e[`oidc.${s}`] = JSON.stringify({ tokens: p });
64
+ s[`oidc.${e}`] = JSON.stringify({ tokens: p });
65
65
  }, i = async (p) => {
66
- e[`oidc.session_state.${s}`] = p;
67
- }, r = async () => e[`oidc.session_state.${s}`], c = (p) => {
68
- e[`oidc.nonce.${s}`] = p.nonce;
66
+ s[`oidc.session_state.${e}`] = p;
67
+ }, r = async () => s[`oidc.session_state.${e}`], c = (p) => {
68
+ s[`oidc.nonce.${e}`] = p.nonce;
69
69
  }, a = (p) => {
70
- e[`oidc.jwk.${s}`] = JSON.stringify(p);
71
- }, u = () => JSON.parse(e[`oidc.jwk.${s}`]), f = async () => ({ nonce: e[`oidc.nonce.${s}`] }), d = async (p) => {
72
- e[`oidc.dpop_nonce.${s}`] = p;
73
- }, l = () => e[`oidc.dpop_nonce.${s}`], _ = () => e[`oidc.${s}`] ? JSON.stringify({ tokens: JSON.parse(e[`oidc.${s}`]).tokens }) : null;
70
+ s[`oidc.jwk.${e}`] = JSON.stringify(p);
71
+ }, u = () => JSON.parse(s[`oidc.jwk.${e}`]), f = async () => ({ nonce: s[`oidc.nonce.${e}`] }), d = async (p) => {
72
+ s[`oidc.dpop_nonce.${e}`] = p;
73
+ }, l = () => s[`oidc.dpop_nonce.${e}`], _ = () => s[`oidc.${e}`] ? JSON.stringify({ tokens: JSON.parse(s[`oidc.${e}`]).tokens }) : null;
74
74
  let y = {};
75
75
  return {
76
76
  clearAsync: n,
@@ -82,94 +82,94 @@ const m = {
82
82
  setNonceAsync: c,
83
83
  getNonceAsync: f,
84
84
  setLoginParams: (p) => {
85
- y[s] = p, e[`oidc.login.${s}`] = JSON.stringify(p);
85
+ y[e] = p, s[`oidc.login.${e}`] = JSON.stringify(p);
86
86
  },
87
87
  getLoginParams: () => {
88
- const p = e[`oidc.login.${s}`];
89
- return y[s] || (y[s] = JSON.parse(p)), y[s];
88
+ const p = s[`oidc.login.${e}`];
89
+ return y[e] || (y[e] = JSON.parse(p)), y[e];
90
90
  },
91
- getStateAsync: async () => e[`oidc.state.${s}`],
91
+ getStateAsync: async () => s[`oidc.state.${e}`],
92
92
  setStateAsync: async (p) => {
93
- e[`oidc.state.${s}`] = p;
93
+ s[`oidc.state.${e}`] = p;
94
94
  },
95
- getCodeVerifierAsync: async () => e[`oidc.code_verifier.${s}`],
95
+ getCodeVerifierAsync: async () => s[`oidc.code_verifier.${e}`],
96
96
  setCodeVerifierAsync: async (p) => {
97
- e[`oidc.code_verifier.${s}`] = p;
97
+ s[`oidc.code_verifier.${e}`] = p;
98
98
  },
99
99
  setDemonstratingProofOfPossessionNonce: d,
100
100
  getDemonstratingProofOfPossessionNonce: l,
101
101
  setDemonstratingProofOfPossessionJwkAsync: a,
102
102
  getDemonstratingProofOfPossessionJwkAsync: u
103
103
  };
104
- }, Ie = (s) => decodeURIComponent(Array.prototype.map.call(atob(s), (e) => "%" + ("00" + e.charCodeAt(0).toString(16)).slice(-2)).join("")), Ce = (s) => JSON.parse(Ie(s.replace(/-/g, "+").replace(/_/g, "/"))), ce = (s) => {
104
+ }, Ee = (e) => decodeURIComponent(Array.prototype.map.call(atob(e), (s) => "%" + ("00" + s.charCodeAt(0).toString(16)).slice(-2)).join("")), Ie = (e) => JSON.parse(Ee(e.replace(/-/g, "+").replace(/_/g, "/"))), ce = (e) => {
105
105
  try {
106
- return s && Ne(s, ".") === 2 ? Ce(s.split(".")[1]) : null;
107
- } catch (e) {
108
- console.warn(e);
106
+ return e && Ce(e, ".") === 2 ? Ie(e.split(".")[1]) : null;
107
+ } catch (s) {
108
+ console.warn(s);
109
109
  }
110
110
  return null;
111
- }, Ne = (s, e) => s.split(e).length - 1, z = {
111
+ }, Ce = (e, s) => e.split(s).length - 1, z = {
112
112
  access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
113
113
  access_token_invalid: "access_token_invalid",
114
114
  id_token_invalid: "id_token_invalid"
115
115
  };
116
- function xe(s, e, n) {
117
- if (s.issuedAt) {
118
- if (typeof s.issuedAt == "string")
119
- return parseInt(s.issuedAt, 10);
116
+ function Ne(e, s, n) {
117
+ if (e.issuedAt) {
118
+ if (typeof e.issuedAt == "string")
119
+ return parseInt(e.issuedAt, 10);
120
120
  } else
121
- return e && e.iat ? e.iat : n && n.iat ? n.iat : (/* @__PURE__ */ new Date()).getTime() / 1e3;
122
- return s.issuedAt;
121
+ return s && s.iat ? s.iat : n && n.iat ? n.iat : (/* @__PURE__ */ new Date()).getTime() / 1e3;
122
+ return e.issuedAt;
123
123
  }
124
- const te = (s, e = null, n) => {
125
- if (!s)
124
+ const te = (e, s = null, n) => {
125
+ if (!e)
126
126
  return null;
127
127
  let t;
128
- const o = typeof s.expiresIn == "string" ? parseInt(s.expiresIn, 10) : s.expiresIn;
129
- s.accessTokenPayload !== void 0 ? t = s.accessTokenPayload : t = ce(s.accessToken);
130
- const i = s.idTokenPayload ? s.idTokenPayload : ce(s.idToken), r = i && i.exp ? i.exp : Number.MAX_VALUE, c = t && t.exp ? t.exp : s.issuedAt + o;
131
- s.issuedAt = xe(s, t, i);
128
+ const o = typeof e.expiresIn == "string" ? parseInt(e.expiresIn, 10) : e.expiresIn;
129
+ e.accessTokenPayload !== void 0 ? t = e.accessTokenPayload : t = ce(e.accessToken);
130
+ const i = e.idTokenPayload ? e.idTokenPayload : ce(e.idToken), r = i && i.exp ? i.exp : Number.MAX_VALUE, c = t && t.exp ? t.exp : e.issuedAt + o;
131
+ e.issuedAt = Ne(e, t, i);
132
132
  let a;
133
- s.expiresAt ? a = s.expiresAt : n === z.access_token_invalid ? a = c : n === z.id_token_invalid ? a = r : a = r < c ? r : c;
134
- const u = { ...s, idTokenPayload: i, accessTokenPayload: t, expiresAt: a };
135
- if (e != null && "refreshToken" in e && !("refreshToken" in s)) {
136
- const f = e.refreshToken;
133
+ e.expiresAt ? a = e.expiresAt : n === z.access_token_invalid ? a = c : n === z.id_token_invalid ? a = r : a = r < c ? r : c;
134
+ const u = { ...e, idTokenPayload: i, accessTokenPayload: t, expiresAt: a };
135
+ if (s != null && "refreshToken" in s && !("refreshToken" in e)) {
136
+ const f = s.refreshToken;
137
137
  return { ...u, refreshToken: f };
138
138
  }
139
139
  return u;
140
- }, oe = (s, e, n) => {
141
- if (!s)
140
+ }, oe = (e, s, n) => {
141
+ if (!e)
142
142
  return null;
143
- if (!s.issued_at) {
143
+ if (!e.issued_at) {
144
144
  const o = (/* @__PURE__ */ new Date()).getTime() / 1e3;
145
- s.issued_at = o;
145
+ e.issued_at = o;
146
146
  }
147
147
  const t = {
148
- accessToken: s.access_token,
149
- expiresIn: s.expires_in,
150
- idToken: s.id_token,
151
- scope: s.scope,
152
- tokenType: s.token_type,
153
- issuedAt: s.issued_at
148
+ accessToken: e.access_token,
149
+ expiresIn: e.expires_in,
150
+ idToken: e.id_token,
151
+ scope: e.scope,
152
+ tokenType: e.token_type,
153
+ issuedAt: e.issued_at
154
154
  };
155
- return "refresh_token" in s && (t.refreshToken = s.refresh_token), s.accessTokenPayload !== void 0 && (t.accessTokenPayload = s.accessTokenPayload), s.idTokenPayload !== void 0 && (t.idTokenPayload = s.idTokenPayload), te(t, e, n);
156
- }, V = (s, e) => {
157
- const n = (/* @__PURE__ */ new Date()).getTime() / 1e3, t = e - n;
158
- return Math.round(t - s);
159
- }, Q = (s) => s ? V(0, s.expiresAt) > 0 : !1, We = async (s, e = 200, n = 50) => {
155
+ 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), te(t, s, n);
156
+ }, V = (e, s) => {
157
+ const n = (/* @__PURE__ */ new Date()).getTime() / 1e3, t = s - n;
158
+ return Math.round(t - e);
159
+ }, Q = (e) => e ? V(0, e.expiresAt) > 0 : !1, xe = async (e, s = 200, n = 50) => {
160
160
  let t = n;
161
- if (!s.tokens)
161
+ if (!e.tokens)
162
162
  return null;
163
- for (; !Q(s.tokens) && t > 0; )
164
- await R({ milliseconds: e }), t = t - 1;
163
+ for (; !Q(e.tokens) && t > 0; )
164
+ await R({ milliseconds: s }), t = t - 1;
165
165
  return {
166
- isTokensValid: Q(s.tokens),
167
- tokens: s.tokens,
166
+ isTokensValid: Q(e.tokens),
167
+ tokens: e.tokens,
168
168
  numberWaited: t - n
169
169
  };
170
- }, ke = (s, e, n) => {
171
- if (s.idTokenPayload) {
172
- const t = s.idTokenPayload;
170
+ }, ge = (e, s, n) => {
171
+ if (e.idTokenPayload) {
172
+ const t = e.idTokenPayload;
173
173
  if (n.issuer !== t.iss)
174
174
  return { isValid: !1, reason: `Issuer does not match (oidcServerConfiguration issuer) ${n.issuer} !== (idTokenPayload issuer) ${t.iss}` };
175
175
  const o = (/* @__PURE__ */ new Date()).getTime() / 1e3;
@@ -178,12 +178,12 @@ const te = (s, e = null, n) => {
178
178
  const i = 60 * 60 * 24 * 7;
179
179
  if (t.iat && t.iat + i < o)
180
180
  return { isValid: !1, reason: `Token is used from too long time (idTokenPayload iat + timeInSevenDays) ${t.iat + i} < (currentTimeUnixSecond) ${o}` };
181
- if (t.nonce && t.nonce !== e)
182
- return { isValid: !1, reason: `Nonce does not match (idTokenPayload nonce) ${t.nonce} !== (nonce) ${e}` };
181
+ if (t.nonce && t.nonce !== s)
182
+ return { isValid: !1, reason: `Nonce does not match (idTokenPayload nonce) ${t.nonce} !== (nonce) ${s}` };
183
183
  }
184
184
  return { isValid: !0, reason: "" };
185
185
  }, J = function() {
186
- const s = function() {
186
+ const e = function() {
187
187
  let a, u;
188
188
  const f = (function() {
189
189
  const l = {}, _ = {
@@ -238,7 +238,7 @@ const te = (s, e = null, n) => {
238
238
  }
239
239
  return null;
240
240
  }();
241
- if (!s) {
241
+ if (!e) {
242
242
  const a = typeof window > "u" ? global : window;
243
243
  return {
244
244
  setTimeout: setTimeout.bind(a),
@@ -247,13 +247,13 @@ const te = (s, e = null, n) => {
247
247
  clearInterval: clearInterval.bind(a)
248
248
  };
249
249
  }
250
- const e = function() {
250
+ const s = function() {
251
251
  let a = 0;
252
252
  return function() {
253
253
  return a++, a;
254
254
  };
255
255
  }(), n = {}, t = {};
256
- s.onmessage = function(a) {
256
+ e.onmessage = function(a) {
257
257
  const u = a.data, f = n[u];
258
258
  if (f) {
259
259
  f(), n[u] = null;
@@ -263,18 +263,18 @@ const te = (s, e = null, n) => {
263
263
  d && d();
264
264
  };
265
265
  function o(a, u) {
266
- const f = e();
267
- return s.postMessage(["setTimeout", f, u]), n[f] = a, f;
266
+ const f = s();
267
+ return e.postMessage(["setTimeout", f, u]), n[f] = a, f;
268
268
  }
269
269
  function i(a) {
270
- s.postMessage(["clearTimeout", a]), n[a] = null;
270
+ e.postMessage(["clearTimeout", a]), n[a] = null;
271
271
  }
272
272
  function r(a, u) {
273
- const f = e();
274
- return s.postMessage(["setInterval", f, u]), t[f] = a, f;
273
+ const f = s();
274
+ return e.postMessage(["setInterval", f, u]), t[f] = a, f;
275
275
  }
276
276
  function c(a) {
277
- s.postMessage(["clearInterval", a]), t[a] = null;
277
+ e.postMessage(["clearInterval", a]), t[a] = null;
278
278
  }
279
279
  return {
280
280
  setTimeout: o,
@@ -282,45 +282,45 @@ const te = (s, e = null, n) => {
282
282
  setInterval: r,
283
283
  clearInterval: c
284
284
  };
285
- }(), le = "7.14.0";
286
- let ue = null, q;
287
- const R = ({ milliseconds: s }) => new Promise((e) => J.setTimeout(e, s)), me = (s = "/") => {
285
+ }(), le = "7.14.1";
286
+ let ue = null, j;
287
+ const R = ({ milliseconds: e }) => new Promise((s) => J.setTimeout(s, e)), ke = (e = "/") => {
288
288
  try {
289
- q = new AbortController(), fetch(`${s}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`, { signal: q.signal }).catch((t) => {
289
+ j = new AbortController(), fetch(`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`, { signal: j.signal }).catch((t) => {
290
290
  console.log(t);
291
- }), R({ milliseconds: 150 * 1e3 }).then(me);
292
- } catch (e) {
293
- console.log(e);
291
+ }), R({ milliseconds: 150 * 1e3 }).then(ke);
292
+ } catch (s) {
293
+ console.log(s);
294
294
  }
295
- }, Le = () => {
296
- q && q.abort();
297
- }, De = (s = "/") => fetch(`${s}OidcKeepAliveServiceWorker.json`, {
295
+ }, We = () => {
296
+ j && j.abort();
297
+ }, Le = (e = "/") => fetch(`${e}OidcKeepAliveServiceWorker.json`, {
298
298
  headers: {
299
299
  "oidc-vanilla": "true"
300
300
  }
301
- }).then((e) => e.statusText === "oidc-service-worker").catch((e) => {
302
- console.log(e);
303
- }), $e = (s) => async (e, n) => {
304
- n(), await e.update();
305
- const t = await e.unregister();
306
- console.log(`Service worker unregistering ${t}`), await R({ milliseconds: 2e3 }), s.reload();
307
- }, b = (s) => (e) => new Promise(function(n, t) {
301
+ }).then((s) => s.statusText === "oidc-service-worker").catch((s) => {
302
+ console.log(s);
303
+ }), De = (e) => async (s, n) => {
304
+ n(), await s.update();
305
+ const t = await s.unregister();
306
+ console.log(`Service worker unregistering ${t}`), await R({ milliseconds: 2e3 }), e.reload();
307
+ }, b = (e) => (s) => new Promise(function(n, t) {
308
308
  const o = new MessageChannel();
309
309
  o.port1.onmessage = function(i) {
310
310
  i.data && i.data.error ? t(i.data.error) : n(i.data);
311
- }, s.active.postMessage(e, [o.port2]);
312
- }), E = async (s, e) => {
313
- const n = s.service_worker_relative_url;
314
- if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !n || s.service_worker_activate() === !1)
311
+ }, e.active.postMessage(s, [o.port2]);
312
+ }), E = async (e, s) => {
313
+ const n = e.service_worker_relative_url;
314
+ if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !n || e.service_worker_activate() === !1)
315
315
  return null;
316
316
  let t = null;
317
- s.register ? t = await s.service_worker_register(n) : t = await navigator.serviceWorker.register(n);
317
+ e.register ? t = await e.service_worker_register(n) : t = await navigator.serviceWorker.register(n);
318
318
  try {
319
319
  await navigator.serviceWorker.ready, navigator.serviceWorker.controller || await b(t)({ type: "claim" });
320
320
  } catch {
321
321
  return null;
322
322
  }
323
- const o = async (k) => b(t)({ type: "clear", data: { status: k }, configurationName: e }), i = async (k, A, O) => {
323
+ const o = async (k) => b(t)({ type: "clear", data: { status: k }, configurationName: s }), i = async (k, A, O) => {
324
324
  const N = await b(t)({
325
325
  type: "init",
326
326
  data: {
@@ -331,84 +331,84 @@ const R = ({ milliseconds: s }) => new Promise((e) => J.setTimeout(e, s)), me =
331
331
  service_worker_convert_all_requests_to_cors: O.service_worker_convert_all_requests_to_cors
332
332
  }
333
333
  },
334
- configurationName: e
334
+ configurationName: s
335
335
  }), P = N.version;
336
- return P !== le && (console.warn(`Service worker ${P} version mismatch with js client version ${le}, unregistering and reloading`), await O.service_worker_update_require_callback(t, Le)), { tokens: oe(N.tokens, null, O.token_renew_mode), status: N.status };
336
+ return P !== le && (console.warn(`Service worker ${P} version mismatch with js client version ${le}, unregistering and reloading`), await O.service_worker_update_require_callback(t, We)), { tokens: oe(N.tokens, null, O.token_renew_mode), status: N.status };
337
337
  }, r = (k = "/") => {
338
- ue == null && (ue = "not_null", me(k));
339
- }, c = (k) => b(t)({ type: "setSessionState", data: { sessionState: k }, configurationName: e }), a = async () => (await b(t)({ type: "getSessionState", data: null, configurationName: e })).sessionState, u = (k) => (sessionStorage[`oidc.nonce.${e}`] = k.nonce, b(t)({ type: "setNonce", data: { nonce: k }, configurationName: e })), f = async () => {
340
- let A = (await b(t)({ type: "getNonce", data: null, configurationName: e })).nonce;
341
- return A || (A = sessionStorage[`oidc.nonce.${e}`], console.warn("nonce not found in service worker, using sessionStorage")), { nonce: A };
338
+ ue == null && (ue = "not_null", ke(k));
339
+ }, c = (k) => b(t)({ type: "setSessionState", data: { sessionState: k }, configurationName: s }), a = async () => (await b(t)({ type: "getSessionState", data: null, configurationName: s })).sessionState, u = (k) => (sessionStorage[`oidc.nonce.${s}`] = k.nonce, b(t)({ type: "setNonce", data: { nonce: k }, configurationName: s })), f = async () => {
340
+ let A = (await b(t)({ type: "getNonce", data: null, configurationName: s })).nonce;
341
+ return A || (A = sessionStorage[`oidc.nonce.${s}`], console.warn("nonce not found in service worker, using sessionStorage")), { nonce: A };
342
342
  };
343
343
  let d = {};
344
344
  return {
345
345
  clearAsync: o,
346
346
  initAsync: i,
347
- startKeepAliveServiceWorker: () => r(s.service_worker_keep_alive_path),
348
- isServiceWorkerProxyActiveAsync: () => De(s.service_worker_keep_alive_path),
347
+ startKeepAliveServiceWorker: () => r(e.service_worker_keep_alive_path),
348
+ isServiceWorkerProxyActiveAsync: () => Le(e.service_worker_keep_alive_path),
349
349
  setSessionStateAsync: c,
350
350
  getSessionStateAsync: a,
351
351
  setNonceAsync: u,
352
352
  getNonceAsync: f,
353
353
  setLoginParams: (k) => {
354
- d[e] = k, localStorage[`oidc.login.${e}`] = JSON.stringify(k);
354
+ d[s] = k, localStorage[`oidc.login.${s}`] = JSON.stringify(k);
355
355
  },
356
356
  getLoginParams: () => {
357
- const k = localStorage[`oidc.login.${e}`];
358
- return d[e] || (d[e] = JSON.parse(k)), d[e];
357
+ const k = localStorage[`oidc.login.${s}`];
358
+ return d[s] || (d[s] = JSON.parse(k)), d[s];
359
359
  },
360
360
  getStateAsync: async () => {
361
- let A = (await b(t)({ type: "getState", data: null, configurationName: e })).state;
362
- return A || (A = sessionStorage[`oidc.state.${e}`], console.warn("state not found in service worker, using sessionStorage")), A;
361
+ let A = (await b(t)({ type: "getState", data: null, configurationName: s })).state;
362
+ return A || (A = sessionStorage[`oidc.state.${s}`], console.warn("state not found in service worker, using sessionStorage")), A;
363
363
  },
364
- setStateAsync: async (k) => (sessionStorage[`oidc.state.${e}`] = k, b(t)({ type: "setState", data: { state: k }, configurationName: e })),
364
+ setStateAsync: async (k) => (sessionStorage[`oidc.state.${s}`] = k, b(t)({ type: "setState", data: { state: k }, configurationName: s })),
365
365
  getCodeVerifierAsync: async () => {
366
- let A = (await b(t)({ type: "getCodeVerifier", data: null, configurationName: e })).codeVerifier;
367
- return A || (A = sessionStorage[`oidc.code_verifier.${e}`], console.warn("codeVerifier not found in service worker, using sessionStorage")), A;
366
+ let A = (await b(t)({ type: "getCodeVerifier", data: null, configurationName: s })).codeVerifier;
367
+ return A || (A = sessionStorage[`oidc.code_verifier.${s}`], console.warn("codeVerifier not found in service worker, using sessionStorage")), A;
368
368
  },
369
- setCodeVerifierAsync: async (k) => (sessionStorage[`oidc.code_verifier.${e}`] = k, b(t)({ type: "setCodeVerifier", data: { codeVerifier: k }, configurationName: e })),
369
+ setCodeVerifierAsync: async (k) => (sessionStorage[`oidc.code_verifier.${s}`] = k, b(t)({ type: "setCodeVerifier", data: { codeVerifier: k }, configurationName: s })),
370
370
  setDemonstratingProofOfPossessionNonce: async (k) => {
371
- await b(t)({ type: "setDemonstratingProofOfPossessionNonce", data: { demonstratingProofOfPossessionNonce: k }, configurationName: e });
371
+ await b(t)({ type: "setDemonstratingProofOfPossessionNonce", data: { demonstratingProofOfPossessionNonce: k }, configurationName: s });
372
372
  },
373
- getDemonstratingProofOfPossessionNonce: async () => (await b(t)({ type: "getDemonstratingProofOfPossessionNonce", data: null, configurationName: e })).demonstratingProofOfPossessionNonce,
373
+ getDemonstratingProofOfPossessionNonce: async () => (await b(t)({ type: "getDemonstratingProofOfPossessionNonce", data: null, configurationName: s })).demonstratingProofOfPossessionNonce,
374
374
  setDemonstratingProofOfPossessionJwkAsync: async (k) => {
375
375
  const A = JSON.stringify(k);
376
- b(t)({ type: "setDemonstratingProofOfPossessionJwk", data: { demonstratingProofOfPossessionJwkJson: A }, configurationName: e });
376
+ b(t)({ type: "setDemonstratingProofOfPossessionJwk", data: { demonstratingProofOfPossessionJwkJson: A }, configurationName: s });
377
377
  },
378
378
  getDemonstratingProofOfPossessionJwkAsync: async () => {
379
- const k = await b(t)({ type: "getDemonstratingProofOfPossessionJwk", data: null, configurationName: e });
379
+ const k = await b(t)({ type: "getDemonstratingProofOfPossessionJwk", data: null, configurationName: s });
380
380
  return k.demonstratingProofOfPossessionJwkJson ? JSON.parse(k.demonstratingProofOfPossessionJwkJson) : null;
381
381
  }
382
382
  };
383
383
  };
384
- async function de(s, e, n, t) {
384
+ async function de(e, s, n, t) {
385
385
  const o = (a) => {
386
- s.tokens = a;
387
- }, { tokens: i, status: r } = await s.synchroniseTokensAsync(e, 0, n, t, o);
388
- return await E(s.configuration, s.configurationName) || await I(s.configurationName, s.configuration.storage).setTokens(s.tokens), s.tokens ? i : (await s.destroyAsync(r), null);
386
+ e.tokens = a;
387
+ }, { tokens: i, status: r } = await e.synchroniseTokensAsync(s, 0, n, t, o);
388
+ return await E(e.configuration, e.configurationName) || await I(e.configurationName, e.configuration.storage).setTokens(e.tokens), e.tokens ? i : (await e.destroyAsync(r), null);
389
389
  }
390
- async function Re(s, e) {
391
- const n = await E(e, s.configurationName);
390
+ async function $e(e, s) {
391
+ const n = await E(s, e.configurationName);
392
392
  if (n) {
393
- const t = await s.initAsync(e.authority, e.authority_configuration), { tokens: o } = await n.initAsync(t, "tryKeepExistingSessionAsync", e);
393
+ const t = await e.initAsync(s.authority, s.authority_configuration), { tokens: o } = await n.initAsync(t, "tryKeepExistingSessionAsync", s);
394
394
  return o;
395
395
  } else {
396
- const t = I(s.configurationName, e.storage ?? sessionStorage);
396
+ const t = I(e.configurationName, s.storage ?? sessionStorage);
397
397
  let { tokens: o } = await t.initAsync();
398
- return o = te(o, s.tokens, e.token_renew_mode), o;
398
+ return o = te(o, e.tokens, s.token_renew_mode), o;
399
399
  }
400
400
  }
401
- async function pe(s, e, n = !1, t = null) {
402
- const o = s.configuration, i = `${o.client_id}_${s.configurationName}_${o.authority}`;
401
+ async function me(e, s, n = !1, t = null) {
402
+ const o = e.configuration, i = `${o.client_id}_${e.configurationName}_${o.authority}`;
403
403
  let r;
404
- const c = await E(s.configuration, s.configurationName);
405
- return (o == null ? void 0 : o.storage) === (window == null ? void 0 : window.sessionStorage) && !c ? r = await de(s, e, n, t) : r = await navigator.locks.request(i, { ifAvailable: !0 }, async (a) => a ? await de(s, e, n, t) : (s.publishEvent(K.eventNames.syncTokensAsync_lock_not_available, { lock: "lock not available" }), await Re(s, o))), r ? (s.timeoutId && (s.timeoutId = M(s, r.refreshToken, s.tokens.expiresAt, t)), s.tokens) : null;
404
+ const c = await E(e.configuration, e.configurationName);
405
+ return (o == null ? void 0 : o.storage) === (window == null ? void 0 : window.sessionStorage) && !c ? r = await de(e, s, n, t) : r = await navigator.locks.request(i, { ifAvailable: !0 }, async (a) => a ? await de(e, s, n, t) : (e.publishEvent(K.eventNames.syncTokensAsync_lock_not_available, { lock: "lock not available" }), await $e(e, o))), r ? (e.timeoutId && (e.timeoutId = M(e, r.refreshToken, e.tokens.expiresAt, t)), e.tokens) : null;
406
406
  }
407
- const M = (s, e, n, t = null) => {
408
- const o = s.configuration.refresh_time_before_tokens_expiration_in_second;
407
+ const M = (e, s, n, t = null) => {
408
+ const o = e.configuration.refresh_time_before_tokens_expiration_in_second;
409
409
  return J.setTimeout(async () => {
410
410
  const r = { timeLeft: V(o, n) };
411
- s.publishEvent(K.eventNames.token_timer, r), await pe(s, e, !1, t);
411
+ e.publishEvent(K.eventNames.token_timer, r), await me(e, s, !1, t);
412
412
  }, 1e3);
413
413
  }, D = {
414
414
  SESSION_LOST: "SESSION_LOST",
@@ -417,14 +417,14 @@ const M = (s, e, n, t = null) => {
417
417
  TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID: "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID",
418
418
  LOGOUT_FROM_ANOTHER_TAB: "LOGOUT_FROM_ANOTHER_TAB",
419
419
  REQUIRE_SYNC_TOKENS: "REQUIRE_SYNC_TOKENS"
420
- }, Ke = (s) => async (e, n, t, o = !1) => {
420
+ }, Re = (e) => async (s, n, t, o = !1) => {
421
421
  const i = { nonce: null };
422
422
  if (!t)
423
423
  return { tokens: null, status: "NOT_CONNECTED", nonce: i };
424
424
  let r = i;
425
- const c = await s.initAsync(e.authority, e.authority_configuration), a = await E(e, n);
425
+ const c = await e.initAsync(s.authority, s.authority_configuration), a = await E(s, n);
426
426
  if (a) {
427
- const { status: d, tokens: l } = await a.initAsync(c, "syncTokensAsync", e);
427
+ const { status: d, tokens: l } = await a.initAsync(c, "syncTokensAsync", s);
428
428
  if (d === "LOGGED_OUT")
429
429
  return { tokens: null, status: "LOGOUT_FROM_ANOTHER_TAB", nonce: i };
430
430
  if (d === "SESSIONS_LOST")
@@ -432,27 +432,27 @@ const M = (s, e, n, t = null) => {
432
432
  if (!d || !l)
433
433
  return { tokens: null, status: "REQUIRE_SYNC_TOKENS", nonce: i };
434
434
  if (l.issuedAt !== t.issuedAt) {
435
- const y = V(e.refresh_time_before_tokens_expiration_in_second, l.expiresAt) > 0 ? "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" : "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID", h = await a.getNonceAsync();
435
+ const y = V(s.refresh_time_before_tokens_expiration_in_second, l.expiresAt) > 0 ? "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" : "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID", h = await a.getNonceAsync();
436
436
  return { tokens: l, status: y, nonce: h };
437
437
  }
438
438
  r = await a.getNonceAsync();
439
439
  } else {
440
- const d = I(n, e.storage ?? sessionStorage), { tokens: l, status: _ } = await d.initAsync();
440
+ const d = I(n, s.storage ?? sessionStorage), { tokens: l, status: _ } = await d.initAsync();
441
441
  if (l) {
442
442
  if (_ === "SESSIONS_LOST")
443
443
  return { tokens: null, status: "SESSIONS_LOST", nonce: i };
444
444
  if (l.issuedAt !== t.issuedAt) {
445
- const h = V(e.refresh_time_before_tokens_expiration_in_second, l.expiresAt) > 0 ? "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" : "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID", g = await d.getNonceAsync();
445
+ const h = V(s.refresh_time_before_tokens_expiration_in_second, l.expiresAt) > 0 ? "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" : "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID", g = await d.getNonceAsync();
446
446
  return { tokens: l, status: h, nonce: g };
447
447
  }
448
448
  } else
449
449
  return { tokens: null, status: "LOGOUT_FROM_ANOTHER_TAB", nonce: i };
450
450
  r = await d.getNonceAsync();
451
451
  }
452
- const f = V(e.refresh_time_before_tokens_expiration_in_second, t.expiresAt) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
452
+ const f = V(s.refresh_time_before_tokens_expiration_in_second, t.expiresAt) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
453
453
  return o ? { tokens: t, status: "FORCE_REFRESH", nonce: r } : { tokens: t, status: f, nonce: r };
454
- }, ie = (s, e, n) => (t = null, o = null, i = null) => {
455
- if (!e.silent_redirect_uri || !e.silent_login_uri)
454
+ }, ie = (e, s, n) => (t = null, o = null, i = null) => {
455
+ if (!s.silent_redirect_uri || !s.silent_login_uri)
456
456
  return Promise.resolve(null);
457
457
  try {
458
458
  n(m.silentLoginAsync_begin, {});
@@ -460,13 +460,13 @@ const M = (s, e, n, t = null) => {
460
460
  if (o && (t == null && (t = {}), t.state = o), i && (t == null && (t = {}), t.scope = i), t != null)
461
461
  for (const [d, l] of Object.entries(t))
462
462
  r === "" ? r = `?${encodeURIComponent(d)}=${encodeURIComponent(l)}` : r += `&${encodeURIComponent(d)}=${encodeURIComponent(l)}`;
463
- const c = e.silent_login_uri + r, a = c.indexOf("/", c.indexOf("//") + 2), u = c.substr(0, a), f = document.createElement("iframe");
464
- return f.width = "0px", f.height = "0px", f.id = `${s}_oidc_iframe`, f.setAttribute("src", c), document.body.appendChild(f), new Promise((d, l) => {
463
+ const c = s.silent_login_uri + r, a = c.indexOf("/", c.indexOf("//") + 2), u = c.substr(0, a), f = document.createElement("iframe");
464
+ return f.width = "0px", f.height = "0px", f.id = `${e}_oidc_iframe`, f.setAttribute("src", c), document.body.appendChild(f), new Promise((d, l) => {
465
465
  try {
466
466
  let _ = !1;
467
467
  window.onmessage = (h) => {
468
468
  if (h.origin === u && h.source === f.contentWindow) {
469
- const g = `${s}_oidc_tokens:`, w = `${s}_oidc_error:`, S = h.data;
469
+ const g = `${e}_oidc_tokens:`, w = `${e}_oidc_error:`, S = h.data;
470
470
  if (S && typeof S == "string" && !_) {
471
471
  if (S.startsWith(g)) {
472
472
  const T = JSON.parse(h.data.replace(g, ""));
@@ -478,7 +478,7 @@ const M = (s, e, n, t = null) => {
478
478
  }
479
479
  }
480
480
  };
481
- const y = e.silent_login_timeout;
481
+ const y = s.silent_login_timeout;
482
482
  setTimeout(() => {
483
483
  _ || (n(m.silentLoginAsync_error, { reason: "timeout" }), f.remove(), _ = !0, l(new Error("timeout")));
484
484
  }, y);
@@ -489,9 +489,9 @@ const M = (s, e, n, t = null) => {
489
489
  } catch (r) {
490
490
  throw n(m.silentLoginAsync_error, r), r;
491
491
  }
492
- }, Ue = (s, e, n, t, o) => (i = null, r = void 0) => {
492
+ }, Ke = (e, s, n, t, o) => (i = null, r = void 0) => {
493
493
  i = { ...i };
494
- const c = (u, f, d) => ie(e, n, t.bind(o))(u, f, d);
494
+ const c = (u, f, d) => ie(s, n, t.bind(o))(u, f, d);
495
495
  return (async () => {
496
496
  o.timeoutId && J.clearTimeout(o.timeoutId);
497
497
  let u;
@@ -507,13 +507,13 @@ const M = (s, e, n, t = null) => {
507
507
  return f;
508
508
  }
509
509
  })();
510
- }, Fe = (s, e, n) => (t, o, i, r = !1) => {
511
- const c = (a, u = void 0, f = void 0) => ie(s.configurationName, n, s.publishEvent.bind(s))(a, u, f);
510
+ }, Ue = (e, s, n) => (t, o, i, r = !1) => {
511
+ const c = (a, u = void 0, f = void 0) => ie(e.configurationName, n, e.publishEvent.bind(e))(a, u, f);
512
512
  return new Promise((a, u) => {
513
513
  if (n.silent_login_uri && n.silent_redirect_uri && n.monitor_session && t && i && !r) {
514
514
  const f = () => {
515
- s.checkSessionIFrame.stop();
516
- const d = s.tokens;
515
+ e.checkSessionIFrame.stop();
516
+ const d = e.tokens;
517
517
  if (d === null)
518
518
  return;
519
519
  const l = d.idToken, _ = d.idTokenPayload;
@@ -525,17 +525,17 @@ const M = (s, e, n, t = null) => {
525
525
  const h = y.tokens.idTokenPayload;
526
526
  if (_.sub === h.sub) {
527
527
  const g = y.sessionState;
528
- s.checkSessionIFrame.start(y.sessionState), _.sid === h.sid ? console.debug("SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:", g) : console.debug("SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:", g);
528
+ e.checkSessionIFrame.start(y.sessionState), _.sid === h.sid ? console.debug("SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:", g) : console.debug("SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:", g);
529
529
  } else
530
530
  console.debug("SessionMonitor._callback: Different subject signed into OP:", h.sub);
531
531
  }).catch(async (y) => {
532
532
  console.warn("SessionMonitor._callback: Silent login failed, logging out other tabs:", y);
533
- for (const [h, g] of Object.entries(e))
533
+ for (const [h, g] of Object.entries(s))
534
534
  await g.logoutOtherTabAsync(n.client_id, _.sub);
535
535
  });
536
536
  };
537
- s.checkSessionIFrame = new Ee(f, o, t), s.checkSessionIFrame.load().then(() => {
538
- s.checkSessionIFrame.start(i), a(s.checkSessionIFrame);
537
+ e.checkSessionIFrame = new Oe(f, o, t), e.checkSessionIFrame.load().then(() => {
538
+ e.checkSessionIFrame.start(i), a(e.checkSessionIFrame);
539
539
  }).catch((d) => {
540
540
  u(d);
541
541
  });
@@ -543,89 +543,89 @@ const M = (s, e, n, t = null) => {
543
543
  a(null);
544
544
  });
545
545
  };
546
- var Ve = He, C = [], fe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
547
- for (var H = 0, Me = fe.length; H < Me; ++H)
546
+ var Fe = Be, C = [], fe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
547
+ for (var H = 0, Ve = fe.length; H < Ve; ++H)
548
548
  C[H] = fe[H];
549
- function Je(s) {
550
- return C[s >> 18 & 63] + C[s >> 12 & 63] + C[s >> 6 & 63] + C[s & 63];
549
+ function Me(e) {
550
+ return C[e >> 18 & 63] + C[e >> 12 & 63] + C[e >> 6 & 63] + C[e & 63];
551
551
  }
552
- function Be(s, e, n) {
553
- for (var t, o = [], i = e; i < n; i += 3)
554
- t = (s[i] << 16 & 16711680) + (s[i + 1] << 8 & 65280) + (s[i + 2] & 255), o.push(Je(t));
552
+ function Je(e, s, n) {
553
+ for (var t, o = [], i = s; i < n; i += 3)
554
+ t = (e[i] << 16 & 16711680) + (e[i + 1] << 8 & 65280) + (e[i + 2] & 255), o.push(Me(t));
555
555
  return o.join("");
556
556
  }
557
- function He(s) {
558
- for (var e, n = s.length, t = n % 3, o = [], i = 16383, r = 0, c = n - t; r < c; r += i)
559
- o.push(Be(s, r, r + i > c ? c : r + i));
560
- return t === 1 ? (e = s[n - 1], o.push(
561
- C[e >> 2] + C[e << 4 & 63] + "=="
562
- )) : t === 2 && (e = (s[n - 2] << 8) + s[n - 1], o.push(
563
- C[e >> 10] + C[e >> 4 & 63] + C[e << 2 & 63] + "="
557
+ function Be(e) {
558
+ for (var s, n = e.length, t = n % 3, o = [], i = 16383, r = 0, c = n - t; r < c; r += i)
559
+ o.push(Je(e, r, r + i > c ? c : r + i));
560
+ return t === 1 ? (s = e[n - 1], o.push(
561
+ C[s >> 2] + C[s << 4 & 63] + "=="
562
+ )) : t === 2 && (s = (e[n - 2] << 8) + e[n - 1], o.push(
563
+ C[s >> 10] + C[s >> 4 & 63] + C[s << 2 & 63] + "="
564
564
  )), o.join("");
565
565
  }
566
- const we = () => {
567
- const s = typeof window < "u" && !!window.crypto, e = s && !!window.crypto.subtle;
568
- return { hasCrypto: s, hasSubtleCrypto: e };
569
- }, Z = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", qe = (s) => {
570
- const e = [];
571
- for (let n = 0; n < s.byteLength; n += 1) {
572
- const t = s[n] % Z.length;
573
- e.push(Z[t]);
574
- }
575
- return e.join("");
576
- }, je = (s) => Ve(new Uint8Array(s)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, ""), ee = (s) => {
577
- const e = new Uint8Array(s), { hasCrypto: n } = we();
566
+ const pe = () => {
567
+ const e = typeof window < "u" && !!window.crypto, s = e && !!window.crypto.subtle;
568
+ return { hasCrypto: e, hasSubtleCrypto: s };
569
+ }, Z = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", He = (e) => {
570
+ const s = [];
571
+ for (let n = 0; n < e.byteLength; n += 1) {
572
+ const t = e[n] % Z.length;
573
+ s.push(Z[t]);
574
+ }
575
+ return s.join("");
576
+ }, je = (e) => Fe(new Uint8Array(e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, ""), ee = (e) => {
577
+ const s = new Uint8Array(e), { hasCrypto: n } = pe();
578
578
  if (n)
579
- window.crypto.getRandomValues(e);
579
+ window.crypto.getRandomValues(s);
580
580
  else
581
- for (let t = 0; t < s; t += 1)
582
- e[t] = Math.random() * Z.length | 0;
583
- return qe(e);
581
+ for (let t = 0; t < e; t += 1)
582
+ s[t] = Math.random() * Z.length | 0;
583
+ return He(s);
584
584
  };
585
- function Ge(s) {
586
- const e = new ArrayBuffer(s.length), n = new Uint8Array(e);
587
- for (let t = 0; t < s.length; t++)
588
- n[t] = s.charCodeAt(t);
585
+ function qe(e) {
586
+ const s = new ArrayBuffer(e.length), n = new Uint8Array(s);
587
+ for (let t = 0; t < e.length; t++)
588
+ n[t] = e.charCodeAt(t);
589
589
  return n;
590
590
  }
591
- function Ae(s) {
592
- return new Promise((e, n) => {
593
- crypto.subtle.digest("SHA-256", Ge(s)).then((t) => e(je(new Uint8Array(t))), (t) => n(t));
591
+ function we(e) {
592
+ return new Promise((s, n) => {
593
+ crypto.subtle.digest("SHA-256", qe(e)).then((t) => s(je(new Uint8Array(t))), (t) => n(t));
594
594
  });
595
595
  }
596
- const Ye = (s) => {
597
- if (s.length < 43 || s.length > 128)
596
+ const Ge = (e) => {
597
+ if (e.length < 43 || e.length > 128)
598
598
  return Promise.reject(new Error("Invalid code length."));
599
- const { hasSubtleCrypto: e } = we();
600
- return e ? Ae(s) : Promise.reject(new Error("window.crypto.subtle is unavailable."));
601
- }, $ = {}, Xe = (s, e = window.sessionStorage, n) => {
602
- if (!$[s] && e) {
603
- const o = e.getItem(s);
604
- o && ($[s] = JSON.parse(o));
599
+ const { hasSubtleCrypto: s } = pe();
600
+ return s ? we(e) : Promise.reject(new Error("window.crypto.subtle is unavailable."));
601
+ }, $ = {}, Ye = (e, s = window.sessionStorage, n) => {
602
+ if (!$[e] && s) {
603
+ const o = s.getItem(e);
604
+ o && ($[e] = JSON.parse(o));
605
605
  }
606
606
  const t = 1e3 * n;
607
- return $[s] && $[s].timestamp + t > Date.now() ? $[s].result : null;
608
- }, ze = (s, e, n = window.sessionStorage) => {
607
+ return $[e] && $[e].timestamp + t > Date.now() ? $[e].result : null;
608
+ }, Xe = (e, s, n = window.sessionStorage) => {
609
609
  const t = Date.now();
610
- $[s] = { result: e, timestamp: t }, n && n.setItem(s, JSON.stringify({ result: e, timestamp: t }));
611
- }, Qe = 60 * 60, Ze = (s) => async (e, n = Qe, t = window.sessionStorage, o = 1e4) => {
612
- const i = `${e}/.well-known/openid-configuration`, r = `oidc.server:${e}`, c = Xe(r, t, n);
610
+ $[e] = { result: s, timestamp: t }, n && n.setItem(e, JSON.stringify({ result: s, timestamp: t }));
611
+ }, ze = 60 * 60, Qe = (e) => async (s, n = ze, t = window.sessionStorage, o = 1e4) => {
612
+ const i = `${s}/.well-known/openid-configuration`, r = `oidc.server:${s}`, c = Ye(r, t, n);
613
613
  if (c)
614
614
  return new ne(c);
615
- const a = await B(s)(i, {}, o);
615
+ const a = await B(e)(i, {}, o);
616
616
  if (a.status !== 200)
617
617
  return null;
618
618
  const u = await a.json();
619
- return ze(r, u, t), new ne(u);
620
- }, B = (s) => async (e, n = {}, t = 1e4, o = 0) => {
619
+ return Xe(r, u, t), new ne(u);
620
+ }, B = (e) => async (s, n = {}, t = 1e4, o = 0) => {
621
621
  let i;
622
622
  try {
623
623
  const r = new AbortController();
624
- setTimeout(() => r.abort(), t), i = await s(e, { ...n, signal: r.signal });
624
+ setTimeout(() => r.abort(), t), i = await e(s, { ...n, signal: r.signal });
625
625
  } catch (r) {
626
626
  if (r.name === "AbortError" || r.message === "Network request failed") {
627
627
  if (o <= 1)
628
- return await B(s)(e, n, t, o + 1);
628
+ return await B(e)(s, n, t, o + 1);
629
629
  throw r;
630
630
  } else
631
631
  throw console.error(r.message), r;
@@ -634,7 +634,7 @@ const Ye = (s) => {
634
634
  }, se = {
635
635
  refresh_token: "refresh_token",
636
636
  access_token: "access_token"
637
- }, _e = (s) => async (e, n, t = se.refresh_token, o, i = 1e4) => {
637
+ }, _e = (e) => async (s, n, t = se.refresh_token, o, i = 1e4) => {
638
638
  const r = {
639
639
  token: n,
640
640
  token_type_hint: t,
@@ -645,7 +645,7 @@ const Ye = (s) => {
645
645
  c.push(`${d}=${l}`);
646
646
  }
647
647
  const a = c.join("&");
648
- return (await B(s)(e, {
648
+ return (await B(e)(s, {
649
649
  method: "POST",
650
650
  headers: {
651
651
  "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
@@ -654,7 +654,7 @@ const Ye = (s) => {
654
654
  }, i)).status !== 200 ? { success: !1 } : {
655
655
  success: !0
656
656
  };
657
- }, es = (s) => async (e, n, t, o, i = {}, r, c = 1e4) => {
657
+ }, Ze = (e) => async (s, n, t, o, i = {}, r, c = 1e4) => {
658
658
  for (const [_, y] of Object.entries(t))
659
659
  n[_] === void 0 && (n[_] = y);
660
660
  const a = [];
@@ -662,7 +662,7 @@ const Ye = (s) => {
662
662
  const y = encodeURIComponent(_), h = encodeURIComponent(n[_]);
663
663
  a.push(`${y}=${h}`);
664
664
  }
665
- const u = a.join("&"), f = await B(s)(e, {
665
+ const u = a.join("&"), f = await B(e)(s, {
666
666
  method: "POST",
667
667
  headers: {
668
668
  "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
@@ -674,28 +674,28 @@ const Ye = (s) => {
674
674
  return { success: !1, status: f.status, demonstratingProofOfPossessionNonce: null };
675
675
  const d = await f.json();
676
676
  let l = null;
677
- return f.headers.has(j) && (l = f.headers.get(j)), {
677
+ return f.headers.has(q) && (l = f.headers.get(q)), {
678
678
  success: !0,
679
679
  data: oe(d, o, r),
680
680
  demonstratingProofOfPossessionNonce: l
681
681
  };
682
- }, ss = (s, e) => async (n, t) => {
682
+ }, es = (e, s) => async (n, t) => {
683
683
  t = t ? { ...t } : {};
684
- const o = ee(128), i = await Ye(o);
685
- await s.setCodeVerifierAsync(o), await s.setStateAsync(t.state), t.code_challenge = i, t.code_challenge_method = "S256";
684
+ const o = ee(128), i = await Ge(o);
685
+ await e.setCodeVerifierAsync(o), await e.setStateAsync(t.state), t.code_challenge = i, t.code_challenge_method = "S256";
686
686
  let r = "";
687
687
  if (t)
688
688
  for (const [c, a] of Object.entries(t))
689
689
  r === "" ? r += "?" : r += "&", r += `${c}=${encodeURIComponent(a)}`;
690
- e.open(`${n}${r}`);
691
- }, j = "DPoP-Nonce", ns = (s) => async (e, n, t, o, i = 1e4) => {
692
- n = n ? { ...n } : {}, n.code_verifier = await s.getCodeVerifierAsync();
690
+ s.open(`${n}${r}`);
691
+ }, q = "DPoP-Nonce", ss = (e) => async (s, n, t, o, i = 1e4) => {
692
+ n = n ? { ...n } : {}, n.code_verifier = await e.getCodeVerifierAsync();
693
693
  const r = [];
694
694
  for (const d in n) {
695
695
  const l = encodeURIComponent(d), _ = encodeURIComponent(n[d]);
696
696
  r.push(`${l}=${_}`);
697
697
  }
698
- const c = r.join("&"), a = await B(fetch)(e, {
698
+ const c = r.join("&"), a = await B(fetch)(s, {
699
699
  method: "POST",
700
700
  headers: {
701
701
  "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
@@ -703,10 +703,10 @@ const Ye = (s) => {
703
703
  },
704
704
  body: c
705
705
  }, i);
706
- if (await Promise.all([s.setCodeVerifierAsync(null), s.setStateAsync(null)]), a.status !== 200)
706
+ if (await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]), a.status !== 200)
707
707
  return { success: !1, status: a.status };
708
708
  let u = null;
709
- a.headers.has(j) && (u = a.headers.get(j));
709
+ a.headers.has(q) && (u = a.headers.get(q));
710
710
  const f = await a.json();
711
711
  return {
712
712
  success: !0,
@@ -716,66 +716,66 @@ const Ye = (s) => {
716
716
  demonstratingProofOfPossessionNonce: u
717
717
  }
718
718
  };
719
- }, Se = (s) => {
720
- const e = s.match(
719
+ }, Ae = (e) => {
720
+ const s = e.match(
721
721
  // eslint-disable-next-line no-useless-escape
722
722
  /^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/
723
723
  );
724
- if (!e)
724
+ if (!s)
725
725
  throw new Error("Invalid URL");
726
- let n = e[6], t = e[7];
726
+ let n = s[6], t = s[7];
727
727
  if (t) {
728
728
  const o = t.split("?");
729
729
  o.length === 2 && (t = o[0], n = o[1]);
730
730
  }
731
- return n.startsWith("?") && (n = n.slice(1)), e && {
732
- href: s,
733
- protocol: e[1],
734
- host: e[2],
735
- hostname: e[3],
736
- port: e[4],
737
- path: e[5],
731
+ return n.startsWith("?") && (n = n.slice(1)), s && {
732
+ href: e,
733
+ protocol: s[1],
734
+ host: s[2],
735
+ hostname: s[3],
736
+ port: s[4],
737
+ path: s[5],
738
738
  search: n,
739
739
  hash: t
740
740
  };
741
- }, Cs = (s) => {
742
- const e = Se(s);
743
- let { path: n } = e;
741
+ }, Cs = (e) => {
742
+ const s = Ae(e);
743
+ let { path: n } = s;
744
744
  n.endsWith("/") && (n = n.slice(0, -1));
745
- let { hash: t } = e;
745
+ let { hash: t } = s;
746
746
  return t === "#_=_" && (t = ""), t && (n += t), n;
747
- }, G = (s) => {
748
- const e = Se(s), { search: n } = e;
749
- return ts(n);
750
- }, ts = (s) => {
751
- const e = {};
747
+ }, G = (e) => {
748
+ const s = Ae(e), { search: n } = s;
749
+ return ns(n);
750
+ }, ns = (e) => {
751
+ const s = {};
752
752
  let n, t, o;
753
- const i = s.split("&");
753
+ const i = e.split("&");
754
754
  for (t = 0, o = i.length; t < o; t++)
755
- n = i[t].split("="), e[decodeURIComponent(n[0])] = decodeURIComponent(n[1]);
756
- return e;
755
+ n = i[t].split("="), s[decodeURIComponent(n[0])] = decodeURIComponent(n[1]);
756
+ return s;
757
757
  };
758
- function ve(s) {
759
- return new TextEncoder().encode(s);
758
+ function Se(e) {
759
+ return new TextEncoder().encode(e);
760
760
  }
761
- function Te(s) {
762
- return btoa(s).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+/g, "");
761
+ function ve(e) {
762
+ return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+/g, "");
763
763
  }
764
- function os(s) {
765
- return encodeURIComponent(s).replace(/%([0-9A-F]{2})/g, function(t, o) {
764
+ function ts(e) {
765
+ return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, function(t, o) {
766
766
  return String.fromCharCode(parseInt(o, 16));
767
767
  });
768
768
  }
769
- function be(s) {
770
- let e = "";
771
- return s.forEach(function(n) {
772
- e += String.fromCharCode(n);
773
- }), Te(e);
769
+ function Te(e) {
770
+ let s = "";
771
+ return e.forEach(function(n) {
772
+ s += String.fromCharCode(n);
773
+ }), ve(s);
774
774
  }
775
- function he(s) {
776
- return Te(os(s));
775
+ function he(e) {
776
+ return ve(ts(e));
777
777
  }
778
- const is = {
778
+ const os = {
779
779
  importKeyAlgorithm: {
780
780
  name: "ECDSA",
781
781
  namedCurve: "P-256",
@@ -788,13 +788,13 @@ const is = {
788
788
  },
789
789
  digestAlgorithm: { name: "SHA-256" },
790
790
  jwtHeaderAlgorithm: "ES256"
791
- }, rs = async (s, e, n, t, o = "dpop+jwt") => {
792
- switch (s = Object.assign({}, s), e.typ = o, e.alg = t.jwtHeaderAlgorithm, e.alg) {
791
+ }, is = async (e, s, n, t, o = "dpop+jwt") => {
792
+ switch (e = Object.assign({}, e), s.typ = o, s.alg = t.jwtHeaderAlgorithm, s.alg) {
793
793
  case "ES256":
794
- e.jwk = { kty: s.kty, crv: s.crv, x: s.x, y: s.y };
794
+ s.jwk = { kty: e.kty, crv: e.crv, x: e.x, y: e.y };
795
795
  break;
796
796
  case "RS256":
797
- e.jwk = { kty: s.kty, n: s.n, e: s.e, kid: e.kid };
797
+ s.jwk = { kty: e.kty, n: e.n, e: e.e, kid: s.kid };
798
798
  break;
799
799
  default:
800
800
  throw new Error("Unknown or not implemented JWS algorithm");
@@ -802,43 +802,40 @@ const is = {
802
802
  const i = {
803
803
  // @ts-ignore
804
804
  // JWT "headers" really means JWS "protected headers"
805
- protected: he(JSON.stringify(e)),
805
+ protected: he(JSON.stringify(s)),
806
806
  // @ts-ignore
807
807
  // JWT "claims" are really a JSON-defined JWS "payload"
808
808
  payload: he(JSON.stringify(n))
809
- }, r = t.importKeyAlgorithm, c = !0, a = ["sign"], u = await window.crypto.subtle.importKey("jwk", s, r, c, a), f = ve(`${i.protected}.${i.payload}`), d = t.signAlgorithm, l = await window.crypto.subtle.sign(d, u, f);
810
- return i.signature = be(new Uint8Array(l)), `${i.protected}.${i.payload}.${i.signature}`;
809
+ }, r = t.importKeyAlgorithm, c = !0, a = ["sign"], u = await window.crypto.subtle.importKey("jwk", e, r, c, a), f = Se(`${i.protected}.${i.payload}`), d = t.signAlgorithm, l = await window.crypto.subtle.sign(d, u, f);
810
+ return i.signature = Te(new Uint8Array(l)), `${i.protected}.${i.payload}.${i.signature}`;
811
811
  };
812
- var as = { sign: rs };
813
- const cs = async (s) => {
814
- const e = s, n = !0, t = ["sign", "verify"], o = await window.crypto.subtle.generateKey(e, n, t);
812
+ var rs = { sign: is };
813
+ const as = async (e) => {
814
+ const s = e, n = !0, t = ["sign", "verify"], o = await window.crypto.subtle.generateKey(s, n, t);
815
815
  return await window.crypto.subtle.exportKey("jwk", o.privateKey);
816
- }, ls = (s) => {
817
- const e = Object.assign({}, s);
818
- return delete e.d, e.key_ops = ["verify"], e;
819
- }, ye = {
820
- generate: cs,
821
- neuter: ls
822
- }, us = async (s, e) => {
816
+ }, cs = (e) => {
817
+ const s = Object.assign({}, e);
818
+ return delete s.d, s.key_ops = ["verify"], s;
819
+ }, ls = {
820
+ generate: as,
821
+ neuter: cs
822
+ }, us = async (e, s) => {
823
823
  let n;
824
- switch (s.kty) {
824
+ switch (e.kty) {
825
825
  case "EC":
826
- n = '{"crv":"CRV","kty":"EC","x":"X","y":"Y"}'.replace("CRV", s.crv).replace("X", s.x).replace("Y", s.y);
826
+ n = '{"crv":"CRV","kty":"EC","x":"X","y":"Y"}'.replace("CRV", e.crv).replace("X", e.x).replace("Y", e.y);
827
827
  break;
828
828
  case "RSA":
829
- n = '{"e":"E","kty":"RSA","n":"N"}'.replace("E", s.e).replace("N", s.n);
829
+ n = '{"e":"E","kty":"RSA","n":"N"}'.replace("E", e.e).replace("N", e.n);
830
830
  break;
831
831
  default:
832
832
  throw new Error("Unknown or not implemented JWK type");
833
833
  }
834
- const t = await window.crypto.subtle.digest(e, ve(n));
835
- return be(new Uint8Array(t));
834
+ const t = await window.crypto.subtle.digest(s, Se(n));
835
+ return Te(new Uint8Array(t));
836
836
  };
837
837
  var ds = { thumbprint: us };
838
- const fs = async (s) => {
839
- const e = await ye.generate(s);
840
- return console.info("Private Key:", JSON.stringify(e)), console.info("Public Key:", JSON.stringify(ye.neuter(e))), e;
841
- }, Pe = (s) => async (e, n = "POST", t, o = {}) => {
838
+ const fs = async (e) => await ls.generate(e), be = (e) => async (s, n = "POST", t, o = {}) => {
842
839
  const i = {
843
840
  // https://www.rfc-editor.org/rfc/rfc9449.html#name-concept
844
841
  jti: btoa(_s()),
@@ -846,15 +843,15 @@ const fs = async (s) => {
846
843
  htu: t,
847
844
  iat: Math.round(Date.now() / 1e3),
848
845
  ...o
849
- }, r = await ds.thumbprint(e, s.digestAlgorithm);
850
- return await as.sign(e, { kid: r }, i, s);
846
+ }, r = await ds.thumbprint(s, e.digestAlgorithm);
847
+ return await rs.sign(s, { kid: r }, i, e);
851
848
  }, _s = () => {
852
- const s = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", e = "0123456789abcdef";
849
+ const e = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", s = "0123456789abcdef";
853
850
  let n = 0, t = "";
854
851
  for (let o = 0; o < 36; o++)
855
- s[o] !== "-" && s[o] !== "4" && (n = Math.random() * 16 | 0), s[o] === "x" ? t += e[n] : s[o] === "y" ? (n &= 3, n |= 8, t += e[n]) : t += s[o];
852
+ e[o] !== "-" && e[o] !== "4" && (n = Math.random() * 16 | 0), e[o] === "x" ? t += s[n] : e[o] === "y" ? (n &= 3, n |= 8, t += s[n]) : t += e[o];
856
853
  return t;
857
- }, hs = (s, e, n, t, o) => (i = void 0, r = null, c = !1, a = void 0) => {
854
+ }, hs = (e, s, n, t, o) => (i = void 0, r = null, c = !1, a = void 0) => {
858
855
  const u = r;
859
856
  return r = { ...r }, (async () => {
860
857
  const d = i || o.getPath();
@@ -862,39 +859,39 @@ const fs = async (s) => {
862
859
  for (const l of Object.keys(r))
863
860
  l.endsWith(":token_request") && delete r[l];
864
861
  try {
865
- const l = c ? e.silent_redirect_uri : e.redirect_uri;
866
- a || (a = e.scope);
867
- const _ = e.extras ? { ...e.extras, ...r } : r;
862
+ const l = c ? s.silent_redirect_uri : s.redirect_uri;
863
+ a || (a = s.scope);
864
+ const _ = s.extras ? { ...s.extras, ...r } : r;
868
865
  _.nonce || (_.nonce = ee(12));
869
- const y = { nonce: _.nonce }, h = await E(e, s), g = await t(e.authority, e.authority_configuration);
866
+ const y = { nonce: _.nonce }, h = await E(s, e), g = await t(s.authority, s.authority_configuration);
870
867
  let w;
871
868
  if (h)
872
- h.setLoginParams({ callbackPath: d, extras: u }), await h.initAsync(g, "loginAsync", e), await h.setNonceAsync(y), h.startKeepAliveServiceWorker(), w = h;
869
+ h.setLoginParams({ callbackPath: d, extras: u }), await h.initAsync(g, "loginAsync", s), await h.setNonceAsync(y), h.startKeepAliveServiceWorker(), w = h;
873
870
  else {
874
- const T = I(s, e.storage ?? sessionStorage);
871
+ const T = I(e, s.storage ?? sessionStorage);
875
872
  T.setLoginParams({ callbackPath: d, extras: u }), await T.setNonceAsync(y), w = T;
876
873
  }
877
874
  const S = {
878
- client_id: e.client_id,
875
+ client_id: s.client_id,
879
876
  redirect_uri: l,
880
877
  scope: a,
881
878
  response_type: "code",
882
879
  ..._
883
880
  };
884
- await ss(w, o)(g.authorizationEndpoint, S);
881
+ await es(w, o)(g.authorizationEndpoint, S);
885
882
  } catch (l) {
886
883
  throw n(m.loginAsync_error, l), l;
887
884
  }
888
885
  })();
889
- }, ys = (s) => async (e = !1) => {
886
+ }, ys = (e) => async (s = !1) => {
890
887
  try {
891
- s.publishEvent(m.loginCallbackAsync_begin, {});
892
- const n = s.configuration, t = n.client_id, o = e ? n.silent_redirect_uri : n.redirect_uri, i = n.authority, r = n.token_request_timeout, c = await s.initAsync(i, n.authority_configuration), a = s.location.getCurrentHref(), f = G(a).session_state, d = await E(n, s.configurationName);
888
+ e.publishEvent(m.loginCallbackAsync_begin, {});
889
+ const n = e.configuration, t = n.client_id, o = s ? n.silent_redirect_uri : n.redirect_uri, i = n.authority, r = n.token_request_timeout, c = await e.initAsync(i, n.authority_configuration), a = e.location.getCurrentHref(), f = G(a).session_state, d = await E(n, e.configurationName);
893
890
  let l, _, y, h;
894
891
  if (d)
895
892
  await d.initAsync(c, "loginCallbackAsync", n), await d.setSessionStateAsync(f), _ = await d.getNonceAsync(), y = d.getLoginParams(), h = await d.getStateAsync(), d.startKeepAliveServiceWorker(), l = d;
896
893
  else {
897
- const v = I(s.configurationName, n.storage ?? sessionStorage);
894
+ const v = I(e.configurationName, n.storage ?? sessionStorage);
898
895
  await v.setSessionStateAsync(f), _ = await v.getNonceAsync(), y = v.getLoginParams(), h = await v.getStateAsync(), l = v;
899
896
  }
900
897
  const g = G(a);
@@ -919,13 +916,13 @@ const fs = async (s) => {
919
916
  const T = c.tokenEndpoint, U = {};
920
917
  if (n.demonstrating_proof_of_possession) {
921
918
  const v = await fs(n.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm);
922
- d ? await d.setDemonstratingProofOfPossessionJwkAsync(v) : await I(s.configurationName, n.storage).setDemonstratingProofOfPossessionJwkAsync(v), U.DPoP = await Pe(n.demonstrating_proof_of_possession_configuration)(v, "POST", T);
919
+ d ? await d.setDemonstratingProofOfPossessionJwkAsync(v) : await I(e.configurationName, n.storage).setDemonstratingProofOfPossessionJwkAsync(v), U.DPoP = await be(n.demonstrating_proof_of_possession_configuration)(v, "POST", T);
923
920
  }
924
- const p = await ns(l)(
921
+ const p = await ss(l)(
925
922
  T,
926
923
  { ...w, ...S },
927
924
  U,
928
- s.configuration.token_renew_mode,
925
+ e.configuration.token_renew_mode,
929
926
  r
930
927
  );
931
928
  if (!p.success)
@@ -934,7 +931,7 @@ const fs = async (s) => {
934
931
  const A = p.data.tokens, O = p.data.demonstratingProofOfPossessionNonce;
935
932
  if (p.data.state !== S.state)
936
933
  throw new Error("state is not valid");
937
- const { isValid: N, reason: P } = ke(A, _.nonce, c);
934
+ const { isValid: N, reason: P } = ge(A, _.nonce, c);
938
935
  if (!N)
939
936
  throw new Error(`Tokens are not OpenID valid, reason: ${P}`);
940
937
  if (d) {
@@ -946,41 +943,41 @@ const fs = async (s) => {
946
943
  if (d)
947
944
  await d.initAsync(o, "syncTokensAsync", n), k = d.getLoginParams(), O && await d.setDemonstratingProofOfPossessionNonce(O);
948
945
  else {
949
- const v = I(s.configurationName, n.storage);
946
+ const v = I(e.configurationName, n.storage);
950
947
  k = v.getLoginParams(), O && await v.setDemonstratingProofOfPossessionNonce(O);
951
948
  }
952
- return await s.startCheckSessionAsync(c.checkSessionIframe, t, f, e), s.publishEvent(m.loginCallbackAsync_end, {}), {
949
+ return await e.startCheckSessionAsync(c.checkSessionIframe, t, f, s), e.publishEvent(m.loginCallbackAsync_end, {}), {
953
950
  tokens: A,
954
951
  state: "request.state",
955
952
  callbackPath: k.callbackPath
956
953
  };
957
954
  } catch (n) {
958
- throw console.error(n), s.publishEvent(m.loginCallbackAsync_error, n), n;
955
+ throw console.error(n), e.publishEvent(m.loginCallbackAsync_error, n), n;
959
956
  }
960
- }, ge = {
957
+ }, ye = {
961
958
  access_token: "access_token",
962
959
  refresh_token: "refresh_token"
963
- }, gs = (s) => async (e) => {
964
- J.clearTimeout(s.timeoutId), s.timeoutId = null, s.checkSessionIFrame && s.checkSessionIFrame.stop();
965
- const n = await E(s.configuration, s.configurationName);
966
- n ? await n.clearAsync(e) : await I(s.configurationName, s.configuration.storage).clearAsync(e), s.tokens = null, s.userInfo = null;
967
- }, ks = (s, e, n, t, o) => async (i = void 0, r = null) => {
968
- const c = s.configuration, a = await s.initAsync(c.authority, c.authority_configuration);
960
+ }, gs = (e) => async (s) => {
961
+ J.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
962
+ const n = await E(e.configuration, e.configurationName);
963
+ n ? await n.clearAsync(s) : await I(e.configurationName, e.configuration.storage).clearAsync(s), e.tokens = null, e.userInfo = null;
964
+ }, ks = (e, s, n, t, o) => async (i = void 0, r = null) => {
965
+ const c = e.configuration, a = await e.initAsync(c.authority, c.authority_configuration);
969
966
  i && typeof i != "string" && (i = void 0, t.warn("callbackPathOrUrl path is not a string"));
970
967
  const u = i ?? o.getPath();
971
968
  let f = !1;
972
969
  i && (f = i.includes("https://") || i.includes("http://"));
973
- const d = f ? i : o.getOrigin() + u, l = s.tokens ? s.tokens.idToken : "";
970
+ const d = f ? i : o.getOrigin() + u, l = e.tokens ? e.tokens.idToken : "";
974
971
  try {
975
972
  const y = a.revocationEndpoint;
976
973
  if (y) {
977
- const h = [], g = s.tokens ? s.tokens.accessToken : null;
978
- if (g && c.logout_tokens_to_invalidate.includes(ge.access_token)) {
974
+ const h = [], g = e.tokens ? e.tokens.accessToken : null;
975
+ if (g && c.logout_tokens_to_invalidate.includes(ye.access_token)) {
979
976
  const S = _e(n)(y, g, se.access_token, c.client_id);
980
977
  h.push(S);
981
978
  }
982
- const w = s.tokens ? s.tokens.refreshToken : null;
983
- if (w && c.logout_tokens_to_invalidate.includes(ge.refresh_token)) {
979
+ const w = e.tokens ? e.tokens.refreshToken : null;
980
+ if (w && c.logout_tokens_to_invalidate.includes(ye.refresh_token)) {
984
981
  const S = _e(n)(y, w, se.refresh_token, c.client_id);
985
982
  h.push(S);
986
983
  }
@@ -989,10 +986,10 @@ const fs = async (s) => {
989
986
  } catch (y) {
990
987
  t.warn("logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"), t.warn(y);
991
988
  }
992
- const _ = s.tokens && s.tokens.idTokenPayload ? s.tokens.idTokenPayload.sub : null;
993
- await s.destroyAsync("LOGGED_OUT");
994
- for (const [y, h] of Object.entries(e))
995
- h !== s && await s.logoutSameTabAsync(s.configuration.client_id, _);
989
+ const _ = e.tokens && e.tokens.idTokenPayload ? e.tokens.idTokenPayload.sub : null;
990
+ await e.destroyAsync("LOGGED_OUT");
991
+ for (const [y, h] of Object.entries(s))
992
+ h !== e && await e.logoutSameTabAsync(e.configuration.client_id, _);
996
993
  if (a.endSessionEndpoint) {
997
994
  r || (r = {
998
995
  id_token_hint: l
@@ -1004,17 +1001,17 @@ const fs = async (s) => {
1004
1001
  o.open(`${a.endSessionEndpoint}${y}`);
1005
1002
  } else
1006
1003
  o.reload();
1007
- }, ms = (s) => async (e = !1) => {
1008
- if (s.userInfo != null && !e)
1009
- return s.userInfo;
1010
- for (; s.tokens && !Q(s.tokens); )
1004
+ }, ms = (e) => async (s = !1) => {
1005
+ if (e.userInfo != null && !s)
1006
+ return e.userInfo;
1007
+ for (; e.tokens && !Q(e.tokens); )
1011
1008
  await R({ milliseconds: 200 });
1012
- if (!s.tokens)
1009
+ if (!e.tokens)
1013
1010
  return null;
1014
- const n = s.tokens.accessToken;
1011
+ const n = e.tokens.accessToken;
1015
1012
  if (!n)
1016
1013
  return null;
1017
- const t = s.configuration, i = (await s.initAsync(t.authority, t.authority_configuration)).userInfoEndpoint, c = await (async (a) => {
1014
+ const t = e.configuration, i = (await e.initAsync(t.authority, t.authority_configuration)).userInfoEndpoint, c = await (async (a) => {
1018
1015
  const u = await fetch(i, {
1019
1016
  headers: {
1020
1017
  authorization: `Bearer ${a}`
@@ -1022,11 +1019,11 @@ const fs = async (s) => {
1022
1019
  });
1023
1020
  return u.status !== 200 ? null : u.json();
1024
1021
  })(n);
1025
- return s.userInfo = c, c;
1022
+ return e.userInfo = c, c;
1026
1023
  };
1027
1024
  class Y {
1028
- open(e) {
1029
- window.open(e, "_self");
1025
+ open(s) {
1026
+ window.open(s, "_self");
1030
1027
  }
1031
1028
  reload() {
1032
1029
  window.location.reload();
@@ -1035,15 +1032,15 @@ class Y {
1035
1032
  return window.location.href;
1036
1033
  }
1037
1034
  getPath() {
1038
- const e = window.location;
1039
- return e.pathname + (e.search || "") + (e.hash || "");
1035
+ const s = window.location;
1036
+ return s.pathname + (s.search || "") + (s.hash || "");
1040
1037
  }
1041
1038
  getOrigin() {
1042
1039
  return window.origin;
1043
1040
  }
1044
1041
  }
1045
- const ps = (s) => !!(s.os === "iOS" && s.osVersion.startsWith("12") || s.os === "Mac OS X" && s.osVersion.startsWith("10_15_6")), ws = (s) => {
1046
- const e = s.appVersion, n = s.userAgent, t = "-";
1042
+ const ps = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")), ws = (e) => {
1043
+ const s = e.appVersion, n = e.userAgent, t = "-";
1047
1044
  let o = t;
1048
1045
  const i = [
1049
1046
  { s: "Windows 10", r: /(Windows 10.0|Windows NT 10.0)/ },
@@ -1089,7 +1086,7 @@ const ps = (s) => !!(s.os === "iOS" && s.osVersion.startsWith("12") || s.os ===
1089
1086
  r = /(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([._\d]+)/.exec(n)[1];
1090
1087
  break;
1091
1088
  case "iOS": {
1092
- const c = /OS (\d+)_(\d+)_?(\d+)?/.exec(e);
1089
+ const c = /OS (\d+)_(\d+)_?(\d+)?/.exec(s);
1093
1090
  c != null && c.length > 2 && (r = c[1] + "." + c[2] + "." + (parseInt(c[3]) | 0));
1094
1091
  break;
1095
1092
  }
@@ -1100,147 +1097,147 @@ const ps = (s) => !!(s.os === "iOS" && s.osVersion.startsWith("12") || s.os ===
1100
1097
  };
1101
1098
  };
1102
1099
  function As() {
1103
- const s = navigator.userAgent;
1104
- let e, n = s.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
1100
+ const e = navigator.userAgent;
1101
+ let s, n = e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
1105
1102
  if (/trident/i.test(n[1]))
1106
- return e = /\brv[ :]+(\d+)/g.exec(s) || [], { name: "ie", version: e[1] || "" };
1107
- if (n[1] === "Chrome" && (e = s.match(/\bOPR|Edge\/(\d+)/), e != null)) {
1108
- let t = e[1];
1103
+ return s = /\brv[ :]+(\d+)/g.exec(e) || [], { name: "ie", version: s[1] || "" };
1104
+ if (n[1] === "Chrome" && (s = e.match(/\bOPR|Edge\/(\d+)/), s != null)) {
1105
+ let t = s[1];
1109
1106
  if (!t) {
1110
- const o = s.split(e[0] + "/");
1107
+ const o = e.split(s[0] + "/");
1111
1108
  o.length > 1 && (t = o[1]);
1112
1109
  }
1113
1110
  return { name: "opera", version: t };
1114
1111
  }
1115
- return n = n[2] ? [n[1], n[2]] : [navigator.appName, navigator.appVersion, "-?"], (e = s.match(/version\/(\d+)/i)) != null && n.splice(1, 1, e[1]), {
1112
+ return n = n[2] ? [n[1], n[2]] : [navigator.appName, navigator.appVersion, "-?"], (s = e.match(/version\/(\d+)/i)) != null && n.splice(1, 1, s[1]), {
1116
1113
  name: n[0].toLowerCase(),
1117
1114
  version: n[1]
1118
1115
  };
1119
1116
  }
1120
1117
  const Ss = () => {
1121
- const { name: s, version: e } = As();
1122
- if (s === "chrome" && parseInt(e) <= 70 || s === "opera" && (!e || parseInt(e.split(".")[0]) < 80) || s === "ie")
1118
+ const { name: e, version: s } = As();
1119
+ if (e === "chrome" && parseInt(s) <= 70 || e === "opera" && (!s || parseInt(s.split(".")[0]) < 80) || e === "ie")
1123
1120
  return !1;
1124
1121
  const n = ws(navigator);
1125
1122
  return !ps(n);
1126
- }, vs = async (s) => {
1127
- let e;
1128
- if (s.tokens != null)
1123
+ }, vs = async (e) => {
1124
+ let s;
1125
+ if (e.tokens != null)
1129
1126
  return !1;
1130
- s.publishEvent(m.tryKeepExistingSessionAsync_begin, {});
1127
+ e.publishEvent(m.tryKeepExistingSessionAsync_begin, {});
1131
1128
  try {
1132
- const n = s.configuration, t = await s.initAsync(n.authority, n.authority_configuration);
1133
- if (e = await E(n, s.configurationName), e) {
1134
- const { tokens: o } = await e.initAsync(t, "tryKeepExistingSessionAsync", n);
1129
+ const n = e.configuration, t = await e.initAsync(n.authority, n.authority_configuration);
1130
+ if (s = await E(n, e.configurationName), s) {
1131
+ const { tokens: o } = await s.initAsync(t, "tryKeepExistingSessionAsync", n);
1135
1132
  if (o) {
1136
- e.startKeepAliveServiceWorker(), s.tokens = o;
1137
- const i = e.getLoginParams(s.configurationName);
1138
- s.timeoutId = M(s, s.tokens.refreshToken, s.tokens.expiresAt, i.extras);
1139
- const r = await e.getSessionStateAsync();
1140
- return await s.startCheckSessionAsync(t.check_session_iframe, n.client_id, r), s.publishEvent(m.tryKeepExistingSessionAsync_end, {
1133
+ s.startKeepAliveServiceWorker(), e.tokens = o;
1134
+ const i = s.getLoginParams(e.configurationName);
1135
+ e.timeoutId = M(e, e.tokens.refreshToken, e.tokens.expiresAt, i.extras);
1136
+ const r = await s.getSessionStateAsync();
1137
+ return await e.startCheckSessionAsync(t.check_session_iframe, n.client_id, r), e.publishEvent(m.tryKeepExistingSessionAsync_end, {
1141
1138
  success: !0,
1142
1139
  message: "tokens inside ServiceWorker are valid"
1143
1140
  }), !0;
1144
1141
  }
1145
- s.publishEvent(m.tryKeepExistingSessionAsync_end, {
1142
+ e.publishEvent(m.tryKeepExistingSessionAsync_end, {
1146
1143
  success: !1,
1147
1144
  message: "no exiting session found"
1148
1145
  });
1149
1146
  } else {
1150
- n.service_worker_relative_url && s.publishEvent(m.service_worker_not_supported_by_browser, {
1147
+ n.service_worker_relative_url && e.publishEvent(m.service_worker_not_supported_by_browser, {
1151
1148
  message: "service worker is not supported by this browser"
1152
1149
  });
1153
- const o = I(s.configurationName, n.storage ?? sessionStorage), { tokens: i } = await o.initAsync();
1150
+ const o = I(e.configurationName, n.storage ?? sessionStorage), { tokens: i } = await o.initAsync();
1154
1151
  if (i) {
1155
- s.tokens = te(i, null, n.token_renew_mode);
1152
+ e.tokens = te(i, null, n.token_renew_mode);
1156
1153
  const r = o.getLoginParams();
1157
- s.timeoutId = M(s, i.refreshToken, s.tokens.expiresAt, r.extras);
1154
+ e.timeoutId = M(e, i.refreshToken, e.tokens.expiresAt, r.extras);
1158
1155
  const c = await o.getSessionStateAsync();
1159
- return await s.startCheckSessionAsync(t.check_session_iframe, n.client_id, c), s.publishEvent(m.tryKeepExistingSessionAsync_end, {
1156
+ return await e.startCheckSessionAsync(t.check_session_iframe, n.client_id, c), e.publishEvent(m.tryKeepExistingSessionAsync_end, {
1160
1157
  success: !0,
1161
1158
  message: "tokens inside storage are valid"
1162
1159
  }), !0;
1163
1160
  }
1164
1161
  }
1165
- return s.publishEvent(m.tryKeepExistingSessionAsync_end, {
1162
+ return e.publishEvent(m.tryKeepExistingSessionAsync_end, {
1166
1163
  success: !1,
1167
- message: e ? "service worker sessions not retrieved" : "session storage sessions not retrieved"
1164
+ message: s ? "service worker sessions not retrieved" : "session storage sessions not retrieved"
1168
1165
  }), !1;
1169
1166
  } catch (n) {
1170
- return console.error(n), e && await e.clearAsync(), s.publishEvent(m.tryKeepExistingSessionAsync_error, "tokens inside ServiceWorker are invalid"), !1;
1167
+ return console.error(n), s && await s.clearAsync(), e.publishEvent(m.tryKeepExistingSessionAsync_error, "tokens inside ServiceWorker are invalid"), !1;
1171
1168
  }
1172
1169
  }, Ts = () => fetch;
1173
1170
  class ne {
1174
- constructor(e) {
1175
- this.authorizationEndpoint = e.authorization_endpoint, this.tokenEndpoint = e.token_endpoint, this.revocationEndpoint = e.revocation_endpoint, this.userInfoEndpoint = e.userinfo_endpoint, this.checkSessionIframe = e.check_session_iframe, this.issuer = e.issuer, this.endSessionEndpoint = e.end_session_endpoint;
1171
+ constructor(s) {
1172
+ this.authorizationEndpoint = s.authorization_endpoint, this.tokenEndpoint = s.token_endpoint, this.revocationEndpoint = s.revocation_endpoint, this.userInfoEndpoint = s.userinfo_endpoint, this.checkSessionIframe = s.check_session_iframe, this.issuer = s.issuer, this.endSessionEndpoint = s.end_session_endpoint;
1176
1173
  }
1177
1174
  }
1178
- const x = {}, bs = (s, e = new Y()) => (n, t = "default") => (x[t] || (x[t] = new K(n, t, s, e)), x[t]), Ps = async (s) => {
1179
- const { parsedTokens: e, callbackPath: n } = await s.loginCallbackAsync();
1180
- return s.timeoutId = M(s, e.refreshToken, e.expiresAt), { callbackPath: n };
1181
- }, Os = (s) => Math.floor(Math.random() * s), re = class F {
1182
- constructor(e, n = "default", t, o = new Y()) {
1175
+ const x = {}, bs = (e, s = new Y()) => (n, t = "default") => (x[t] || (x[t] = new K(n, t, e, s)), x[t]), Ps = async (e) => {
1176
+ const { parsedTokens: s, callbackPath: n } = await e.loginCallbackAsync();
1177
+ return e.timeoutId = M(e, s.refreshToken, s.expiresAt), { callbackPath: n };
1178
+ }, Os = (e) => Math.floor(Math.random() * e), re = class F {
1179
+ constructor(s, n = "default", t, o = new Y()) {
1183
1180
  this.initPromise = null, this.tryKeepExistingSessionPromise = null, this.loginPromise = null, this.loginCallbackPromise = null, this.loginCallbackWithAutoTokensRenewPromise = null, this.userInfoPromise = null, this.renewTokensPromise = null, this.logoutPromise = null;
1184
- let i = e.silent_login_uri;
1185
- e.silent_redirect_uri && !e.silent_login_uri && (i = `${e.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
1186
- let r = e.refresh_time_before_tokens_expiration_in_second ?? 120;
1181
+ let i = s.silent_login_uri;
1182
+ s.silent_redirect_uri && !s.silent_login_uri && (i = `${s.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
1183
+ let r = s.refresh_time_before_tokens_expiration_in_second ?? 120;
1187
1184
  r > 60 && (r = r - Math.floor(Math.random() * 40)), this.location = o ?? new Y();
1188
- const c = e.service_worker_update_require_callback ?? $e(this.location);
1185
+ const c = s.service_worker_update_require_callback ?? De(this.location);
1189
1186
  this.configuration = {
1190
- ...e,
1187
+ ...s,
1191
1188
  silent_login_uri: i,
1192
- monitor_session: e.monitor_session ?? !1,
1189
+ monitor_session: s.monitor_session ?? !1,
1193
1190
  refresh_time_before_tokens_expiration_in_second: r,
1194
- silent_login_timeout: e.silent_login_timeout ?? 12e3,
1195
- token_renew_mode: e.token_renew_mode ?? z.access_token_or_id_token_invalid,
1196
- demonstrating_proof_of_possession: e.demonstrating_proof_of_possession ?? !1,
1197
- authority_timeout_wellknowurl_in_millisecond: e.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
1198
- logout_tokens_to_invalidate: e.logout_tokens_to_invalidate ?? ["access_token", "refresh_token"],
1191
+ silent_login_timeout: s.silent_login_timeout ?? 12e3,
1192
+ token_renew_mode: s.token_renew_mode ?? z.access_token_or_id_token_invalid,
1193
+ demonstrating_proof_of_possession: s.demonstrating_proof_of_possession ?? !1,
1194
+ authority_timeout_wellknowurl_in_millisecond: s.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
1195
+ logout_tokens_to_invalidate: s.logout_tokens_to_invalidate ?? ["access_token", "refresh_token"],
1199
1196
  service_worker_update_require_callback: c,
1200
- service_worker_activate: e.service_worker_activate ?? Ss,
1201
- demonstrating_proof_of_possession_configuration: e.demonstrating_proof_of_possession_configuration ?? is
1197
+ service_worker_activate: s.service_worker_activate ?? Ss,
1198
+ demonstrating_proof_of_possession_configuration: s.demonstrating_proof_of_possession_configuration ?? os
1202
1199
  }, this.getFetch = t ?? Ts, this.configurationName = n, this.tokens = null, this.userInfo = null, this.events = [], this.timeoutId = null, this.synchroniseTokensAsync.bind(this), 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);
1203
1200
  }
1204
- subscribeEvents(e) {
1201
+ subscribeEvents(s) {
1205
1202
  const n = Os(9999999999999).toString();
1206
- return this.events.push({ id: n, func: e }), n;
1203
+ return this.events.push({ id: n, func: s }), n;
1207
1204
  }
1208
- removeEventSubscription(e) {
1209
- const n = this.events.filter((t) => t.id !== e);
1205
+ removeEventSubscription(s) {
1206
+ const n = this.events.filter((t) => t.id !== s);
1210
1207
  this.events = n;
1211
1208
  }
1212
- publishEvent(e, n) {
1209
+ publishEvent(s, n) {
1213
1210
  this.events.forEach((t) => {
1214
- t.func(e, n);
1211
+ t.func(s, n);
1215
1212
  });
1216
1213
  }
1217
- static get(e = "default") {
1214
+ static get(s = "default") {
1218
1215
  const n = typeof process > "u";
1219
- if (!Object.prototype.hasOwnProperty.call(x, e) && n)
1216
+ if (!Object.prototype.hasOwnProperty.call(x, s) && n)
1220
1217
  throw Error(`OIDC library does seem initialized.
1221
- Please checkout that you are using OIDC hook inside a <OidcProvider configurationName="${e}"></OidcProvider> compoment.`);
1222
- return x[e];
1218
+ Please checkout that you are using OIDC hook inside a <OidcProvider configurationName="${s}"></OidcProvider> compoment.`);
1219
+ return x[s];
1223
1220
  }
1224
1221
  _silentLoginCallbackFromIFrame() {
1225
1222
  if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
1226
- const e = this.location, n = G(e.getCurrentHref());
1227
- window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({ tokens: this.tokens, sessionState: n.session_state })}`, e.getOrigin());
1223
+ const s = this.location, n = G(s.getCurrentHref());
1224
+ window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({ tokens: this.tokens, sessionState: n.session_state })}`, s.getOrigin());
1228
1225
  }
1229
1226
  }
1230
1227
  _silentLoginErrorCallbackFromIFrame() {
1231
1228
  if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
1232
- const e = this.location, n = G(e.getCurrentHref());
1233
- window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({ error: n.error })}`, e.getOrigin());
1229
+ const s = this.location, n = G(s.getCurrentHref());
1230
+ window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({ error: n.error })}`, s.getOrigin());
1234
1231
  }
1235
1232
  }
1236
1233
  async silentLoginCallbackAsync() {
1237
1234
  try {
1238
1235
  await this.loginCallbackAsync(!0), this._silentLoginCallbackFromIFrame();
1239
- } catch (e) {
1240
- console.error(e), this._silentLoginErrorCallbackFromIFrame();
1236
+ } catch (s) {
1237
+ console.error(s), this._silentLoginErrorCallbackFromIFrame();
1241
1238
  }
1242
1239
  }
1243
- async initAsync(e, n) {
1240
+ async initAsync(s, n) {
1244
1241
  if (this.initPromise !== null)
1245
1242
  return this.initPromise;
1246
1243
  const t = async () => {
@@ -1255,29 +1252,29 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1255
1252
  issuer: n.issuer
1256
1253
  });
1257
1254
  const i = await E(this.configuration, this.configurationName) ? window.localStorage : null;
1258
- return await Ze(this.getFetch())(e, this.configuration.authority_time_cache_wellknowurl_in_second ?? 60 * 60, i, this.configuration.authority_timeout_wellknowurl_in_millisecond);
1255
+ return await Qe(this.getFetch())(s, this.configuration.authority_time_cache_wellknowurl_in_second ?? 60 * 60, i, this.configuration.authority_timeout_wellknowurl_in_millisecond);
1259
1256
  };
1260
1257
  return this.initPromise = t(), this.initPromise.then((o) => (this.initPromise = null, o));
1261
1258
  }
1262
1259
  async tryKeepExistingSessionAsync() {
1263
- return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise = vs(this), this.tryKeepExistingSessionPromise.then((e) => (this.tryKeepExistingSessionPromise = null, e)));
1260
+ return this.tryKeepExistingSessionPromise !== null ? this.tryKeepExistingSessionPromise : (this.tryKeepExistingSessionPromise = vs(this), this.tryKeepExistingSessionPromise.then((s) => (this.tryKeepExistingSessionPromise = null, s)));
1264
1261
  }
1265
- async startCheckSessionAsync(e, n, t, o = !1) {
1266
- await Fe(this, x, this.configuration)(e, n, t, o);
1262
+ async startCheckSessionAsync(s, n, t, o = !1) {
1263
+ await Ue(this, x, this.configuration)(s, n, t, o);
1267
1264
  }
1268
- async loginAsync(e = void 0, n = null, t = !1, o = void 0, i = !1) {
1269
- return this.loginPromise !== null ? this.loginPromise : i ? Ue(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(n, o) : (this.loginPromise = hs(this.configurationName, this.configuration, this.publishEvent.bind(this), this.initAsync.bind(this), this.location)(e, n, t, o), this.loginPromise.then((r) => (this.loginPromise = null, r)));
1265
+ async loginAsync(s = void 0, n = null, t = !1, o = void 0, i = !1) {
1266
+ return this.loginPromise !== null ? this.loginPromise : i ? Ke(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(n, o) : (this.loginPromise = hs(this.configurationName, this.configuration, this.publishEvent.bind(this), this.initAsync.bind(this), this.location)(s, n, t, o), this.loginPromise.then((r) => (this.loginPromise = null, r)));
1270
1267
  }
1271
- async loginCallbackAsync(e = !1) {
1268
+ async loginCallbackAsync(s = !1) {
1272
1269
  if (this.loginCallbackPromise !== null)
1273
1270
  return this.loginCallbackPromise;
1274
1271
  const n = async () => {
1275
- const t = await ys(this)(e), o = t.tokens;
1272
+ const t = await ys(this)(s), o = t.tokens;
1276
1273
  return this.tokens = o, await E(this.configuration, this.configurationName) || I(this.configurationName, this.configuration.storage).setTokens(o), this.publishEvent(F.eventNames.token_aquired, o), { parsedTokens: o, state: t.state, callbackPath: t.callbackPath };
1277
1274
  };
1278
1275
  return this.loginCallbackPromise = n(), this.loginCallbackPromise.then((t) => (this.loginCallbackPromise = null, t));
1279
1276
  }
1280
- async synchroniseTokensAsync(e, n = 0, t = !1, o = null, i) {
1277
+ async synchroniseTokensAsync(s, n = 0, t = !1, o = null, i) {
1281
1278
  for (; !navigator.onLine && document.hidden; )
1282
1279
  await R({ milliseconds: 1e3 }), this.publishEvent(m.refreshTokensAsync, { message: "wait because navigator is offline and hidden" });
1283
1280
  let r = 6;
@@ -1306,7 +1303,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1306
1303
  if (n > 4)
1307
1304
  return i(null), this.publishEvent(m.refreshTokensAsync_error, { message: "refresh token" }), { tokens: null, status: "SESSION_LOST" };
1308
1305
  try {
1309
- const { status: l, tokens: _, nonce: y } = await Ke(this)(u, this.configurationName, this.tokens, t);
1306
+ const { status: l, tokens: _, nonce: y } = await Re(this)(u, this.configurationName, this.tokens, t);
1310
1307
  switch (l) {
1311
1308
  case D.SESSION_LOST:
1312
1309
  return i(null), this.publishEvent(m.refreshTokensAsync_error, { message: "refresh token session lost" }), { tokens: null, status: "SESSION_LOST" };
@@ -1319,9 +1316,9 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1319
1316
  case D.LOGOUT_FROM_ANOTHER_TAB:
1320
1317
  return i(null), this.publishEvent(m.logout_from_another_tab, { status: "session syncTokensAsync" }), { tokens: null, status: "LOGGED_OUT" };
1321
1318
  case D.REQUIRE_SYNC_TOKENS:
1322
- return this.publishEvent(m.refreshTokensAsync_begin, { refreshToken: e, status: l, tryNumber: n }), await d();
1319
+ return this.publishEvent(m.refreshTokensAsync_begin, { refreshToken: s, status: l, tryNumber: n }), await d();
1323
1320
  default: {
1324
- if (this.publishEvent(m.refreshTokensAsync_begin, { refreshToken: e, status: l, tryNumber: n }), !e)
1321
+ if (this.publishEvent(m.refreshTokensAsync_begin, { refreshToken: s, status: l, tryNumber: n }), !s)
1325
1322
  return await d();
1326
1323
  const h = u.client_id, g = u.redirect_uri, w = u.authority, T = { ...u.token_request_extras ? u.token_request_extras : {} };
1327
1324
  for (const [p, k] of Object.entries(o))
@@ -1334,7 +1331,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1334
1331
  refresh_token: _.refreshToken
1335
1332
  }, k = await this.initAsync(w, u.authority_configuration), A = document.hidden ? 1e4 : 3e4 * 10, O = k.tokenEndpoint, N = {};
1336
1333
  u.demonstrating_proof_of_possession && (N.DPoP = await this.generateDemonstrationOfProofOfPossessionAsync(_.accessToken, O, "POST"));
1337
- const P = await es(this.getFetch())(
1334
+ const P = await Ze(this.getFetch())(
1338
1335
  O,
1339
1336
  p,
1340
1337
  T,
@@ -1344,7 +1341,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1344
1341
  A
1345
1342
  );
1346
1343
  if (P.success) {
1347
- const { isValid: v, reason: W } = ke(P.data, y.nonce, k);
1344
+ const { isValid: v, reason: W } = ge(P.data, y.nonce, k);
1348
1345
  if (!v)
1349
1346
  return i(null), this.publishEvent(m.refreshTokensAsync_error, { message: `refresh token return not valid tokens, reason: ${W}` }), { tokens: null, status: "SESSION_LOST" };
1350
1347
  if (i(P.data), P.demonstratingProofOfPossessionNonce) {
@@ -1356,16 +1353,16 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1356
1353
  return this.publishEvent(m.refreshTokensAsync_silent_error, {
1357
1354
  message: "bad request",
1358
1355
  tokenResponse: P
1359
- }), await this.synchroniseTokensAsync(e, a, t, o, i);
1356
+ }), await this.synchroniseTokensAsync(s, a, t, o, i);
1360
1357
  })();
1361
1358
  }
1362
1359
  }
1363
1360
  } catch (l) {
1364
- return console.error(l), this.publishEvent(m.refreshTokensAsync_silent_error, { message: "exception", exception: l.message }), this.synchroniseTokensAsync(e, a, t, o, i);
1361
+ return console.error(l), this.publishEvent(m.refreshTokensAsync_silent_error, { message: "exception", exception: l.message }), this.synchroniseTokensAsync(s, a, t, o, i);
1365
1362
  }
1366
1363
  }
1367
- async generateDemonstrationOfProofOfPossessionAsync(e, n, t) {
1368
- const o = this.configuration, i = { ath: await Ae(e) }, r = await E(o, this.configurationName);
1364
+ async generateDemonstrationOfProofOfPossessionAsync(s, n, t) {
1365
+ const o = this.configuration, i = { ath: await we(s) }, r = await E(o, this.configurationName);
1369
1366
  let c, a;
1370
1367
  if (r)
1371
1368
  c = await r.getDemonstratingProofOfPossessionNonce(), a = await r.getDemonstratingProofOfPossessionJwkAsync();
@@ -1373,42 +1370,42 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1373
1370
  const u = I(this.configurationName, o.storage);
1374
1371
  a = await u.getDemonstratingProofOfPossessionJwkAsync(), c = await u.getDemonstratingProofOfPossessionNonce();
1375
1372
  }
1376
- return c && (i.nonce = c), await Pe(o.demonstrating_proof_of_possession_configuration)(a, t, n, i);
1373
+ return c && (i.nonce = c), await be(o.demonstrating_proof_of_possession_configuration)(a, t, n, i);
1377
1374
  }
1378
1375
  loginCallbackWithAutoTokensRenewAsync() {
1379
- return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise = Ps(this), this.loginCallbackWithAutoTokensRenewPromise.then((e) => (this.loginCallbackWithAutoTokensRenewPromise = null, e)));
1376
+ return this.loginCallbackWithAutoTokensRenewPromise !== null ? this.loginCallbackWithAutoTokensRenewPromise : (this.loginCallbackWithAutoTokensRenewPromise = Ps(this), this.loginCallbackWithAutoTokensRenewPromise.then((s) => (this.loginCallbackWithAutoTokensRenewPromise = null, s)));
1380
1377
  }
1381
- userInfoAsync(e = !1) {
1382
- return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise = ms(this)(e), this.userInfoPromise.then((n) => (this.userInfoPromise = null, n)));
1378
+ userInfoAsync(s = !1) {
1379
+ return this.userInfoPromise !== null ? this.userInfoPromise : (this.userInfoPromise = ms(this)(s), this.userInfoPromise.then((n) => (this.userInfoPromise = null, n)));
1383
1380
  }
1384
- async renewTokensAsync(e = null) {
1381
+ async renewTokensAsync(s = null) {
1385
1382
  if (this.renewTokensPromise !== null)
1386
1383
  return this.renewTokensPromise;
1387
1384
  if (this.timeoutId)
1388
- return J.clearTimeout(this.timeoutId), this.renewTokensPromise = pe(this, this.tokens.refreshToken, !0, e), this.renewTokensPromise.then((n) => (this.renewTokensPromise = null, n));
1385
+ return J.clearTimeout(this.timeoutId), this.renewTokensPromise = me(this, this.tokens.refreshToken, !0, s), this.renewTokensPromise.then((n) => (this.renewTokensPromise = null, n));
1389
1386
  }
1390
- async destroyAsync(e) {
1391
- return await gs(this)(e);
1387
+ async destroyAsync(s) {
1388
+ return await gs(this)(s);
1392
1389
  }
1393
- async logoutSameTabAsync(e, n) {
1394
- this.configuration.monitor_session && this.configuration.client_id === e && n && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === n && (this.publishEvent(m.logout_from_same_tab, { message: n }), await this.destroyAsync("LOGGED_OUT"));
1390
+ async logoutSameTabAsync(s, n) {
1391
+ this.configuration.monitor_session && this.configuration.client_id === s && n && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === n && (this.publishEvent(m.logout_from_same_tab, { message: n }), await this.destroyAsync("LOGGED_OUT"));
1395
1392
  }
1396
- async logoutOtherTabAsync(e, n) {
1397
- this.configuration.monitor_session && this.configuration.client_id === e && n && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === n && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(m.logout_from_another_tab, { message: "SessionMonitor", sub: n }));
1393
+ async logoutOtherTabAsync(s, n) {
1394
+ this.configuration.monitor_session && this.configuration.client_id === s && n && this.tokens && this.tokens.idTokenPayload && this.tokens.idTokenPayload.sub === n && (await this.destroyAsync("LOGGED_OUT"), this.publishEvent(m.logout_from_another_tab, { message: "SessionMonitor", sub: n }));
1398
1395
  }
1399
- async logoutAsync(e = void 0, n = null) {
1400
- return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = ks(this, x, this.getFetch(), console, this.location)(e, n), this.logoutPromise.then((t) => (this.logoutPromise = null, t)));
1396
+ async logoutAsync(s = void 0, n = null) {
1397
+ return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = ks(this, x, this.getFetch(), console, this.location)(s, n), this.logoutPromise.then((t) => (this.logoutPromise = null, t)));
1401
1398
  }
1402
1399
  };
1403
- re.getOrCreate = (s, e) => (n, t = "default") => bs(s, e)(n, t);
1400
+ re.getOrCreate = (e, s) => (n, t = "default") => bs(e, s)(n, t);
1404
1401
  re.eventNames = m;
1405
1402
  let K = re;
1406
- const Es = (s, e) => async (...n) => {
1403
+ const Es = (e, s) => async (...n) => {
1407
1404
  var l;
1408
1405
  const [t, o, ...i] = n, r = o ? { ...o } : { method: "GET" };
1409
1406
  let c = new Headers();
1410
1407
  r.headers && (c = r.headers instanceof Headers ? r.headers : new Headers(r.headers));
1411
- const a = e, u = await a.getValidTokenAsync(), f = (l = u == null ? void 0 : u.tokens) == null ? void 0 : l.accessToken;
1408
+ const a = s, u = await a.getValidTokenAsync(), f = (l = u == null ? void 0 : u.tokens) == null ? void 0 : l.accessToken;
1412
1409
  if (c.has("Accept") || c.set("Accept", "application/json"), f) {
1413
1410
  if (a.configuration.demonstrating_proof_of_possession) {
1414
1411
  const _ = await a.generateDemonstrationOfProofOfPossessionAsync(f, t.toString(), r.method);
@@ -1418,37 +1415,37 @@ const Es = (s, e) => async (...n) => {
1418
1415
  r.credentials || (r.credentials = "same-origin");
1419
1416
  }
1420
1417
  const d = { ...r, headers: c };
1421
- return await s(t, d, ...i);
1422
- }, X = class Oe {
1423
- constructor(e) {
1424
- this._oidc = e;
1418
+ return await e(t, d, ...i);
1419
+ }, X = class Pe {
1420
+ constructor(s) {
1421
+ this._oidc = s;
1425
1422
  }
1426
- subscribeEvents(e) {
1427
- return this._oidc.subscribeEvents(e);
1423
+ subscribeEvents(s) {
1424
+ return this._oidc.subscribeEvents(s);
1428
1425
  }
1429
- removeEventSubscription(e) {
1430
- this._oidc.removeEventSubscription(e);
1426
+ removeEventSubscription(s) {
1427
+ this._oidc.removeEventSubscription(s);
1431
1428
  }
1432
- publishEvent(e, n) {
1433
- this._oidc.publishEvent(e, n);
1429
+ publishEvent(s, n) {
1430
+ this._oidc.publishEvent(s, n);
1434
1431
  }
1435
- static get(e = "default") {
1436
- return new Oe(K.get(e));
1432
+ static get(s = "default") {
1433
+ return new Pe(K.get(s));
1437
1434
  }
1438
1435
  tryKeepExistingSessionAsync() {
1439
1436
  return this._oidc.tryKeepExistingSessionAsync();
1440
1437
  }
1441
- loginAsync(e = void 0, n = null, t = !1, o = void 0, i = !1) {
1442
- return this._oidc.loginAsync(e, n, t, o, i);
1438
+ loginAsync(s = void 0, n = null, t = !1, o = void 0, i = !1) {
1439
+ return this._oidc.loginAsync(s, n, t, o, i);
1443
1440
  }
1444
- logoutAsync(e = void 0, n = null) {
1445
- return this._oidc.logoutAsync(e, n);
1441
+ logoutAsync(s = void 0, n = null) {
1442
+ return this._oidc.logoutAsync(s, n);
1446
1443
  }
1447
1444
  silentLoginCallbackAsync() {
1448
1445
  return this._oidc.silentLoginCallbackAsync();
1449
1446
  }
1450
- renewTokensAsync(e = null) {
1451
- return this._oidc.renewTokensAsync(e);
1447
+ renewTokensAsync(s = null) {
1448
+ return this._oidc.renewTokensAsync(s);
1452
1449
  }
1453
1450
  loginCallbackAsync() {
1454
1451
  return this._oidc.loginCallbackWithAutoTokensRenewAsync();
@@ -1459,20 +1456,20 @@ const Es = (s, e) => async (...n) => {
1459
1456
  get configuration() {
1460
1457
  return this._oidc.configuration;
1461
1458
  }
1462
- async generateDemonstrationOfProofOfPossessionAsync(e, n, t) {
1463
- return this._oidc.generateDemonstrationOfProofOfPossessionAsync(e, n, t);
1459
+ async generateDemonstrationOfProofOfPossessionAsync(s, n, t) {
1460
+ return this._oidc.generateDemonstrationOfProofOfPossessionAsync(s, n, t);
1464
1461
  }
1465
- async getValidTokenAsync(e = 200, n = 50) {
1466
- return We(this._oidc, e, n);
1462
+ async getValidTokenAsync(s = 200, n = 50) {
1463
+ return xe(this._oidc, s, n);
1467
1464
  }
1468
- fetchWithTokens(e) {
1469
- return Es(e, this);
1465
+ fetchWithTokens(s) {
1466
+ return Es(s, this);
1470
1467
  }
1471
- async userInfoAsync(e = !1) {
1472
- return this._oidc.userInfoAsync(e);
1468
+ async userInfoAsync(s = !1) {
1469
+ return this._oidc.userInfoAsync(s);
1473
1470
  }
1474
1471
  };
1475
- X.getOrCreate = (s, e = new Y()) => (n, t = "default") => new X(K.getOrCreate(s, e)(n, t));
1472
+ X.getOrCreate = (e, s = new Y()) => (n, t = "default") => new X(K.getOrCreate(e, s)(n, t));
1476
1473
  X.eventNames = K.eventNames;
1477
1474
  let Ns = X;
1478
1475
  export {