@axa-fr/oidc-client 7.22.8-alpha.1449 → 7.22.8-alpha.1450

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