@axa-fr/oidc-client 7.27.19 → 7.29.2

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.
Files changed (85) hide show
  1. package/README.md +122 -4
  2. package/dist/crypto.d.ts.map +1 -1
  3. package/dist/crypto.spec.d.ts +2 -0
  4. package/dist/crypto.spec.d.ts.map +1 -0
  5. package/dist/events.d.ts +3 -0
  6. package/dist/events.d.ts.map +1 -1
  7. package/dist/fetch.d.ts +2 -1
  8. package/dist/fetch.d.ts.map +1 -1
  9. package/dist/fetch.spec.d.ts +2 -0
  10. package/dist/fetch.spec.d.ts.map +1 -0
  11. package/dist/index.d.ts +4 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +922 -556
  14. package/dist/index.umd.cjs +2 -2
  15. package/dist/jwt.spec.d.ts +2 -0
  16. package/dist/jwt.spec.d.ts.map +1 -0
  17. package/dist/login.d.ts +3 -3
  18. package/dist/login.d.ts.map +1 -1
  19. package/dist/logout.d.ts.map +1 -1
  20. package/dist/oidc.d.ts +12 -2
  21. package/dist/oidc.d.ts.map +1 -1
  22. package/dist/oidcClient.d.ts +5 -1
  23. package/dist/oidcClient.d.ts.map +1 -1
  24. package/dist/oidcError.d.ts +57 -0
  25. package/dist/oidcError.d.ts.map +1 -0
  26. package/dist/oidcError.spec.d.ts +2 -0
  27. package/dist/oidcError.spec.d.ts.map +1 -0
  28. package/dist/oidcStateError.d.ts +7 -4
  29. package/dist/oidcStateError.d.ts.map +1 -1
  30. package/dist/par.spec.d.ts +2 -0
  31. package/dist/par.spec.d.ts.map +1 -0
  32. package/dist/parseTokens.d.ts +1 -1
  33. package/dist/parseTokens.d.ts.map +1 -1
  34. package/dist/pushedAuthorizationRequestError.d.ts +20 -0
  35. package/dist/pushedAuthorizationRequestError.d.ts.map +1 -0
  36. package/dist/pushedAuthorizationRequestError.spec.d.ts +2 -0
  37. package/dist/pushedAuthorizationRequestError.spec.d.ts.map +1 -0
  38. package/dist/renewTokens.d.ts +11 -0
  39. package/dist/renewTokens.d.ts.map +1 -1
  40. package/dist/renewTokensError.spec.d.ts +2 -0
  41. package/dist/renewTokensError.spec.d.ts.map +1 -0
  42. package/dist/requests.d.ts +21 -14
  43. package/dist/requests.d.ts.map +1 -1
  44. package/dist/silentLogin.d.ts +6 -4
  45. package/dist/silentLogin.d.ts.map +1 -1
  46. package/dist/silentLogin.spec.d.ts +2 -0
  47. package/dist/silentLogin.spec.d.ts.map +1 -0
  48. package/dist/types.d.ts +5 -0
  49. package/dist/types.d.ts.map +1 -1
  50. package/dist/user.d.ts.map +1 -1
  51. package/dist/version.d.ts +1 -1
  52. package/dist/version.d.ts.map +1 -1
  53. package/package.json +2 -3
  54. package/src/crypto.spec.ts +40 -0
  55. package/src/crypto.ts +9 -10
  56. package/src/events.ts +3 -0
  57. package/src/fetch.spec.ts +105 -0
  58. package/src/fetch.ts +39 -3
  59. package/src/index.ts +14 -1
  60. package/src/jwt.spec.ts +33 -0
  61. package/src/jwt.ts +1 -47
  62. package/src/login.spec.ts +34 -0
  63. package/src/login.ts +119 -14
  64. package/src/logout.spec.ts +58 -0
  65. package/src/logout.ts +46 -7
  66. package/src/oidc.ts +78 -16
  67. package/src/oidcClient.ts +8 -1
  68. package/src/oidcError.spec.ts +105 -0
  69. package/src/oidcError.ts +197 -0
  70. package/src/oidcStateError.spec.ts +18 -0
  71. package/src/oidcStateError.ts +29 -8
  72. package/src/par.spec.ts +232 -0
  73. package/src/parseTokens.spec.ts +2 -1
  74. package/src/parseTokens.ts +1 -1
  75. package/src/pushedAuthorizationRequestError.spec.ts +43 -0
  76. package/src/pushedAuthorizationRequestError.ts +50 -0
  77. package/src/renewTokens.ts +167 -29
  78. package/src/renewTokensError.spec.ts +116 -0
  79. package/src/requests.spec.ts +293 -4
  80. package/src/requests.ts +174 -8
  81. package/src/silentLogin.spec.ts +158 -0
  82. package/src/silentLogin.ts +36 -9
  83. package/src/types.ts +6 -0
  84. package/src/user.ts +71 -31
  85. package/src/version.ts +1 -1
package/dist/index.js CHANGED
@@ -13,6 +13,7 @@ var e = {
13
13
  loginCallbackAsync_error: "loginCallbackAsync_error",
14
14
  loginCallbackAsync_navigated: "loginCallbackAsync_navigated",
15
15
  loginCallbackAsync_navigation_error: "loginCallbackAsync_navigation_error",
16
+ logoutAsync_error: "logoutAsync_error",
16
17
  refreshTokensAsync_begin: "refreshTokensAsync_begin",
17
18
  refreshTokensAsync: "refreshTokensAsync",
18
19
  refreshTokensAsync_end: "refreshTokensAsync_end",
@@ -25,6 +26,8 @@ var e = {
25
26
  silentLoginAsync: "silentLoginAsync",
26
27
  silentLoginAsync_end: "silentLoginAsync_end",
27
28
  silentLoginAsync_error: "silentLoginAsync_error",
29
+ userInfoAsync_error: "userInfoAsync_error",
30
+ apiRequest_error: "apiRequest_error",
28
31
  syncTokensAsync_begin: "syncTokensAsync_begin",
29
32
  syncTokensAsync_lock_not_available: "syncTokensAsync_lock_not_available",
30
33
  syncTokensAsync_end: "syncTokensAsync_end",
@@ -140,7 +143,80 @@ var e = {
140
143
  stop() {
141
144
  this._timer &&= (o.debug("CheckSessionIFrame.stop"), window.clearInterval(this._timer), null);
142
145
  }
143
- }, c = (function() {
146
+ }, c = {
147
+ LOGIN_REQUIRED: "LOGIN_REQUIRED",
148
+ CONSENT_REQUIRED: "CONSENT_REQUIRED",
149
+ INTERACTION_REQUIRED: "INTERACTION_REQUIRED",
150
+ OAUTH_ERROR: "OAUTH_ERROR",
151
+ TOKEN_REQUEST_FAILED: "TOKEN_REQUEST_FAILED",
152
+ SILENT_LOGIN_TIMEOUT: "SILENT_LOGIN_TIMEOUT",
153
+ INVALID_STATE: "INVALID_STATE",
154
+ INVALID_NONCE: "INVALID_NONCE",
155
+ DPOP_NONCE_REQUIRED: "DPOP_NONCE_REQUIRED",
156
+ NETWORK_ERROR: "NETWORK_ERROR",
157
+ STATE_MISSING: "STATE_MISSING",
158
+ STATE_MISMATCH: "STATE_MISMATCH",
159
+ NONCE_MISSING: "NONCE_MISSING",
160
+ ENDPOINT_UNAVAILABLE: "ENDPOINT_UNAVAILABLE",
161
+ REQUEST_FAILED: "REQUEST_FAILED",
162
+ INVALID_RESPONSE: "INVALID_RESPONSE"
163
+ }, l = new Set(Object.values(c)), u = new Set([
164
+ "login",
165
+ "callback",
166
+ "refresh",
167
+ "logout",
168
+ "userinfo",
169
+ "api_request"
170
+ ]), d = class extends Error {
171
+ constructor(e, t, n) {
172
+ super(t), this.name = "OidcError", this.code = e, this.phase = n.phase, this.oauthError = n.oauthError, this.oauthErrorDescription = n.oauthErrorDescription, this.retryable = n.retryable, this.status = n.status, this.cause = n.cause, Object.setPrototypeOf(this, new.target.prototype);
173
+ }
174
+ }, f = (e) => e instanceof d, p = (e) => e === 408 || e === 429 || e !== void 0 && e >= 500, m = (e) => {
175
+ switch (e) {
176
+ case "login_required": return c.LOGIN_REQUIRED;
177
+ case "consent_required": return c.CONSENT_REQUIRED;
178
+ case "interaction_required": return c.INTERACTION_REQUIRED;
179
+ case "use_dpop_nonce": return c.DPOP_NONCE_REQUIRED;
180
+ default: return c.OAUTH_ERROR;
181
+ }
182
+ }, h = (e, t, n, r, i) => {
183
+ let a = m(e);
184
+ return new d(a, n, {
185
+ phase: r,
186
+ retryable: !(a === c.LOGIN_REQUIRED || a === c.CONSENT_REQUIRED || a === c.INTERACTION_REQUIRED) && (a === c.DPOP_NONCE_REQUIRED || e === "server_error" || e === "temporarily_unavailable" || p(i)),
187
+ oauthError: e,
188
+ oauthErrorDescription: t,
189
+ status: i
190
+ });
191
+ }, g = (e, t, n = "Network request failed") => {
192
+ let r = e instanceof Error && typeof e.message == "string" && e.message ? e.message : n;
193
+ return new d(c.NETWORK_ERROR, r, {
194
+ phase: t,
195
+ retryable: !0,
196
+ cause: e
197
+ });
198
+ }, _ = (e) => e instanceof Error ? e.name === "AbortError" || e.name === "NetworkError" || e.message === "Network request failed" || e.message === "Failed to fetch" || e.message === "fetch failed" : !1, v = (e) => ({
199
+ name: e.name,
200
+ message: e.message,
201
+ code: e.code,
202
+ phase: e.phase,
203
+ retryable: e.retryable,
204
+ oauthError: e.oauthError,
205
+ oauthErrorDescription: e.oauthErrorDescription,
206
+ status: e.status
207
+ }), y = (e) => {
208
+ if (!e || typeof e != "object") return null;
209
+ let t = e;
210
+ if (typeof t.message != "string" || typeof t.code != "string" || !l.has(t.code) || typeof t.phase != "string" || !u.has(t.phase) || typeof t.retryable != "boolean") return null;
211
+ let n = new d(t.code, t.message, {
212
+ phase: t.phase,
213
+ retryable: t.retryable,
214
+ oauthError: typeof t.oauthError == "string" ? t.oauthError : void 0,
215
+ oauthErrorDescription: typeof t.oauthErrorDescription == "string" ? t.oauthErrorDescription : void 0,
216
+ status: typeof t.status == "number" ? t.status : void 0
217
+ });
218
+ return typeof t.name == "string" && t.name && (n.name = t.name), n;
219
+ }, b = (function() {
144
220
  let e = typeof window > "u" ? global : window;
145
221
  return {
146
222
  setTimeout: setTimeout.bind(e),
@@ -148,55 +224,63 @@ var e = {
148
224
  setInterval: setInterval.bind(e),
149
225
  clearInterval: clearInterval.bind(e)
150
226
  };
151
- })(), l = (t, n, r) => (i = null, a = null, o = null) => {
227
+ })(), x = (t, n, r, i = "login") => (a = null, o = null, s = null) => {
152
228
  if (!n.silent_redirect_uri || !n.silent_login_uri) return Promise.resolve(null);
153
229
  try {
154
230
  r(e.silentLoginAsync_begin, {});
155
- let s = "";
156
- if (a && (i ??= {}, i.state = a), o != null && (i ??= {}, i.scope = o), i != null) for (let [e, t] of Object.entries(i)) t != null && (s === "" ? s = `?${encodeURIComponent(e)}=${encodeURIComponent(t)}` : s += `&${encodeURIComponent(e)}=${encodeURIComponent(t)}`);
157
- let c = n.silent_login_uri + s, l = c.indexOf("/", c.indexOf("//") + 2), u = c.substring(0, l), d = document.createElement("iframe");
158
- return d.width = "0px", d.height = "0px", d.id = `${t}_oidc_iframe`, d.setAttribute("src", c), d.style.display = "none", document.body.appendChild(d), new Promise((i, a) => {
159
- let o = !1, s = () => {
160
- window.removeEventListener("message", c), d.remove(), o = !0;
161
- }, c = (n) => {
162
- if (n.origin === u && n.source === d.contentWindow) {
163
- let c = `${t}_oidc_tokens:`, l = `${t}_oidc_error:`, u = `${t}_oidc_exception:`, d = n.data;
164
- if (d && typeof d == "string" && !o) {
165
- if (d.startsWith(c)) {
231
+ let l = "";
232
+ if (o && (a ??= {}, a.state = o), s != null && (a ??= {}, a.scope = s), a != null) for (let [e, t] of Object.entries(a)) t != null && (l === "" ? l = `?${encodeURIComponent(e)}=${encodeURIComponent(t)}` : l += `&${encodeURIComponent(e)}=${encodeURIComponent(t)}`);
233
+ let u = n.silent_login_uri + l, f = u.indexOf("/", u.indexOf("//") + 2), p = u.substring(0, f), m = document.createElement("iframe");
234
+ return m.width = "0px", m.height = "0px", m.id = `${t}_oidc_iframe`, m.setAttribute("src", u), m.style.display = "none", document.body.appendChild(m), new Promise((a, o) => {
235
+ let s = !1, l = () => {
236
+ window.removeEventListener("message", u), m.remove(), s = !0;
237
+ }, u = (n) => {
238
+ if (n.origin === p && n.source === m.contentWindow) {
239
+ let c = `${t}_oidc_tokens:`, u = `${t}_oidc_error:`, d = `${t}_oidc_exception:`, f = n.data;
240
+ if (f && typeof f == "string" && !s) {
241
+ if (f.startsWith(c)) {
166
242
  let t = JSON.parse(n.data.replace(c, ""));
167
- r(e.silentLoginAsync_end, {}), i(t), s();
168
- } else if (d.startsWith(l)) {
169
- let t = JSON.parse(n.data.replace(l, ""));
170
- r(e.silentLoginAsync_error, t), i({
243
+ r(e.silentLoginAsync_end, {}), a(t), l();
244
+ } else if (f.startsWith(u)) {
245
+ let t = JSON.parse(n.data.replace(u, "")), o = y(t.oidcError) ?? h(t.error, t.error_description, `Error from OIDC server: ${t.error} - ${t.error_description}`, i);
246
+ r(e.silentLoginAsync_error, o), a({
171
247
  error: "oidc_" + t.error,
172
248
  tokens: null,
173
- sessionState: null
174
- }), s();
175
- } else if (d.startsWith(u)) {
176
- let t = JSON.parse(n.data.replace(u, ""));
177
- r(e.silentLoginAsync_error, t), a(Error(t.error)), s();
249
+ sessionState: null,
250
+ oidcError: o
251
+ }), l();
252
+ } else if (f.startsWith(d)) {
253
+ let t = JSON.parse(n.data.replace(d, "")), i = y(t.oidcError) ?? Error(t.error);
254
+ r(e.silentLoginAsync_error, i), o(i), l();
178
255
  }
179
256
  }
180
257
  }
181
258
  };
182
259
  try {
183
- window.addEventListener("message", c);
260
+ window.addEventListener("message", u);
184
261
  let t = n.silent_login_timeout;
185
262
  setTimeout(() => {
186
- o || (s(), r(e.silentLoginAsync_error, { reason: "timeout" }), a(/* @__PURE__ */ Error("timeout")));
263
+ if (!s) {
264
+ l();
265
+ let t = new d(c.SILENT_LOGIN_TIMEOUT, "timeout", {
266
+ phase: i,
267
+ retryable: !0
268
+ });
269
+ r(e.silentLoginAsync_error, t), o(t);
270
+ }
187
271
  }, t);
188
272
  } catch (t) {
189
- s(), r(e.silentLoginAsync_error, t), a(t);
273
+ l(), r(e.silentLoginAsync_error, t), o(t);
190
274
  }
191
275
  });
192
276
  } catch (t) {
193
277
  throw r(e.silentLoginAsync_error, t), t;
194
278
  }
195
- }, u = (t, n, r, i, a) => (t = null, o = void 0) => {
279
+ }, S = (t, n, r, i, a) => (t = null, o = void 0) => {
196
280
  t = { ...t };
197
- let s = (e, t, o) => l(n, r, i.bind(a))(e, t, o);
281
+ let s = (e, t, o) => x(n, r, i.bind(a))(e, t, o);
198
282
  return (async () => {
199
- a.timeoutId && c.clearTimeout(a.timeoutId);
283
+ a.timeoutId && b.clearTimeout(a.timeoutId);
200
284
  let n;
201
285
  t && "state" in t && (n = t.state, delete t.state);
202
286
  try {
@@ -207,13 +291,13 @@ var e = {
207
291
  } : t,
208
292
  prompt: "none"
209
293
  }, n, o);
210
- if (c) return a.tokens = c.tokens, i(e.token_acquired, {}), a.timeoutId = H(a, a.tokens.expiresAt, t, o), {};
294
+ if (c) return a.tokens = c.tokens, i(e.token_acquired, {}), a.timeoutId = W(a, a.tokens.expiresAt, t, o), {};
211
295
  } catch (e) {
212
296
  return e;
213
297
  }
214
298
  })();
215
- }, d = (e, t, n) => (r, i, a, o = !1) => {
216
- let c = (t, r = void 0, i = void 0) => l(e.configurationName, n, e.publishEvent.bind(e))(t, r, i);
299
+ }, C = (e, t, n) => (r, i, a, o = !1) => {
300
+ let c = (t, r = void 0, i = void 0) => x(e.configurationName, n, e.publishEvent.bind(e))(t, r, i);
217
301
  return new Promise((l, u) => {
218
302
  n.silent_login_uri && n.silent_redirect_uri && n.monitor_session && r && a && !o ? (e.checkSessionIFrame = new s(() => {
219
303
  e.checkSessionIFrame.stop();
@@ -244,27 +328,27 @@ var e = {
244
328
  };
245
329
  //#endregion
246
330
  //#region src/jwt.ts
247
- function f(e) {
331
+ function w(e) {
248
332
  return new TextEncoder().encode(e);
249
333
  }
250
- function p(e) {
334
+ function T(e) {
251
335
  return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+/g, "");
252
336
  }
253
- function m(e) {
337
+ function E(e) {
254
338
  return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, function(e, t) {
255
339
  return String.fromCharCode(parseInt(t, 16));
256
340
  });
257
341
  }
258
- var h = (e) => {
342
+ var D = (e) => {
259
343
  let t = "";
260
344
  return e.forEach(function(e) {
261
345
  t += String.fromCharCode(e);
262
- }), p(t);
346
+ }), T(t);
263
347
  };
264
- function g(e) {
265
- return p(m(e));
348
+ function O(e) {
349
+ return T(E(e));
266
350
  }
267
- var _ = {
351
+ var k = {
268
352
  importKeyAlgorithm: {
269
353
  name: "ECDSA",
270
354
  namedCurve: "P-256",
@@ -280,7 +364,7 @@ var _ = {
280
364
  },
281
365
  digestAlgorithm: { name: "SHA-256" },
282
366
  jwtHeaderAlgorithm: "ES256"
283
- }, v = { sign: (e) => async (t, n, r, i, a = "dpop+jwt") => {
367
+ }, ee = { sign: (e) => async (t, n, r, i, a = "dpop+jwt") => {
284
368
  switch (t = Object.assign({}, t), n.typ = a, n.alg = i.jwtHeaderAlgorithm, n.alg) {
285
369
  case "ES256":
286
370
  n.jwk = {
@@ -301,11 +385,11 @@ var _ = {
301
385
  default: throw Error("Unknown or not implemented JWS algorithm");
302
386
  }
303
387
  let o = {
304
- protected: g(JSON.stringify(n)),
305
- payload: g(JSON.stringify(r))
306
- }, s = i.importKeyAlgorithm, c = await e.crypto.subtle.importKey("jwk", t, s, !0, ["sign"]), l = f(`${o.protected}.${o.payload}`), u = i.signAlgorithm, d = await e.crypto.subtle.sign(u, c, l);
307
- return o.signature = h(new Uint8Array(d)), `${o.protected}.${o.payload}.${o.signature}`;
308
- } }, y = {
388
+ protected: O(JSON.stringify(n)),
389
+ payload: O(JSON.stringify(r))
390
+ }, s = i.importKeyAlgorithm, c = await e.crypto.subtle.importKey("jwk", t, s, !0, ["sign"]), l = w(`${o.protected}.${o.payload}`), u = i.signAlgorithm, d = await e.crypto.subtle.sign(u, c, l);
391
+ return o.signature = D(new Uint8Array(d)), `${o.protected}.${o.payload}.${o.signature}`;
392
+ } }, te = {
309
393
  generate: (e) => async (t) => {
310
394
  let n = t, r = await e.crypto.subtle.generateKey(n, !0, ["sign", "verify"]);
311
395
  return await e.crypto.subtle.exportKey("jwk", r.privateKey);
@@ -314,7 +398,7 @@ var _ = {
314
398
  let t = Object.assign({}, e);
315
399
  return delete t.d, t.key_ops = ["verify"], t;
316
400
  }
317
- }, b = { thumbprint: (e) => async (t, n) => {
401
+ }, ne = { thumbprint: (e) => async (t, n) => {
318
402
  let r;
319
403
  switch (t.kty) {
320
404
  case "EC":
@@ -325,55 +409,50 @@ var _ = {
325
409
  break;
326
410
  default: throw Error("Unknown or not implemented JWK type");
327
411
  }
328
- let i = await e.crypto.subtle.digest(n, f(r));
329
- return h(new Uint8Array(i));
330
- } }, x = (e) => async (t) => await y.generate(e)(t), ee = (e) => (t) => async (n, r = "POST", i, a = {}) => {
412
+ let i = await e.crypto.subtle.digest(n, w(r));
413
+ return D(new Uint8Array(i));
414
+ } }, re = (e) => async (t) => await te.generate(e)(t), ie = (e) => (t) => async (n, r = "POST", i, a = {}) => {
331
415
  let o = {
332
- jti: btoa(S()),
416
+ jti: btoa(e.crypto.randomUUID()),
333
417
  htm: r,
334
418
  htu: i,
335
419
  iat: Math.round(Date.now() / 1e3),
336
420
  ...a
337
- }, s = await b.thumbprint(e)(n, t.digestAlgorithm);
338
- return await v.sign(e)(n, { kid: s }, o, t);
339
- }, S = () => {
340
- let e = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx", t = "0123456789abcdef", n = 0, r = "";
341
- for (let i = 0; i < 36; i++) e[i] !== "-" && e[i] !== "4" && (n = Math.random() * 16 | 0), e[i] === "x" ? r += t[n] : e[i] === "y" ? (n &= 3, n |= 8, r += t[n]) : r += e[i];
342
- return r;
343
- }, C = () => {
344
- let e = typeof window < "u" && !!window.crypto;
421
+ }, s = await ne.thumbprint(e)(n, t.digestAlgorithm);
422
+ return await ee.sign(e)(n, { kid: s }, o, t);
423
+ }, ae = () => typeof globalThis < "u" ? globalThis.crypto : void 0, oe = () => {
424
+ let e = ae();
345
425
  return {
346
- hasCrypto: e,
347
- hasSubtleCrypto: e && !!window.crypto.subtle
426
+ hasCrypto: !!e,
427
+ hasSubtleCrypto: !!e?.subtle
348
428
  };
349
- }, w = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", T = (e) => {
429
+ }, se = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", ce = (e) => {
350
430
  let t = [];
351
431
  for (let n = 0; n < e.byteLength; n += 1) {
352
432
  let r = e[n] % 62;
353
- t.push(w[r]);
433
+ t.push(se[r]);
354
434
  }
355
435
  return t.join("");
356
- }, E = (e) => {
357
- let t = new Uint8Array(e), { hasCrypto: n } = C();
358
- if (n) window.crypto.getRandomValues(t);
359
- else for (let n = 0; n < e; n += 1) t[n] = Math.random() * 62 | 0;
360
- return T(t);
436
+ }, A = (e) => {
437
+ let t = new Uint8Array(e), n = ae();
438
+ if (!n?.getRandomValues) throw Error("Web Crypto API is unavailable; secure random values cannot be generated.");
439
+ return n.getRandomValues(t), ce(t);
361
440
  };
362
- function D(e) {
441
+ function le(e) {
363
442
  let t = new ArrayBuffer(e.length), n = new Uint8Array(t);
364
443
  for (let t = 0; t < e.length; t++) n[t] = e.charCodeAt(t);
365
444
  return n;
366
445
  }
367
- function te(e) {
446
+ function ue(e) {
368
447
  return new Promise((t, n) => {
369
- crypto.subtle.digest("SHA-256", D(e)).then((e) => t(h(new Uint8Array(e))), (e) => n(e));
448
+ crypto.subtle.digest("SHA-256", le(e)).then((e) => t(D(new Uint8Array(e))), (e) => n(e));
370
449
  });
371
450
  }
372
- var ne = (e) => {
451
+ var de = (e) => {
373
452
  if (e.length < 43 || e.length > 128) return Promise.reject(/* @__PURE__ */ Error("Invalid code length."));
374
- let { hasSubtleCrypto: t } = C();
375
- return t ? te(e) : Promise.reject(/* @__PURE__ */ Error("window.crypto.subtle is unavailable."));
376
- }, re = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")), ie = (e) => {
453
+ let { hasSubtleCrypto: t } = oe();
454
+ return t ? ue(e) : Promise.reject(/* @__PURE__ */ Error("window.crypto.subtle is unavailable."));
455
+ }, fe = (e) => !!(e.os === "iOS" && e.osVersion.startsWith("12") || e.os === "Mac OS X" && e.osVersion.startsWith("10_15_6")), pe = (e) => {
377
456
  let t = e.appVersion, n = e.userAgent, r = "-", i = [
378
457
  {
379
458
  s: "Windows 10",
@@ -509,7 +588,7 @@ var ne = (e) => {
509
588
  osVersion: a
510
589
  };
511
590
  };
512
- function ae() {
591
+ function me() {
513
592
  let e = navigator.userAgent, t, n = e.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
514
593
  if (/trident/i.test(n[1])) return t = /\brv[ :]+(\d+)/g.exec(e) || [], {
515
594
  name: "ie",
@@ -535,10 +614,10 @@ function ae() {
535
614
  version: n[1]
536
615
  };
537
616
  }
538
- var oe = () => {
539
- let { name: e, version: t } = ae();
540
- return e === "chrome" && parseInt(t) <= 70 || e === "opera" && (!t || parseInt(t.split(".")[0]) < 80) || e === "ie" ? !1 : !re(ie(navigator));
541
- }, se = async (t) => {
617
+ var he = () => {
618
+ let { name: e, version: t } = me();
619
+ return e === "chrome" && parseInt(t) <= 70 || e === "opera" && (!t || parseInt(t.split(".")[0]) < 80) || e === "ie" ? !1 : !fe(pe(navigator));
620
+ }, ge = async (t) => {
542
621
  let n;
543
622
  if (t.tokens != null) return !1;
544
623
  t.publishEvent(e.tryKeepExistingSessionAsync_begin, {});
@@ -549,7 +628,7 @@ var oe = () => {
549
628
  if (i) {
550
629
  n.startKeepAliveServiceWorker(), t.tokens = i;
551
630
  let o = n.getLoginParams(t.configurationName);
552
- t.timeoutId = H(t, t.tokens.expiresAt, o.extras, o.scope);
631
+ t.timeoutId = W(t, t.tokens.expiresAt, o.extras, o.scope);
553
632
  let s = await n.getSessionStateAsync();
554
633
  return await t.startCheckSessionAsync(a.checkSessionIframe, r.client_id, s), r.preload_user_info && await t.userInfoAsync(), t.publishEvent(e.tryKeepExistingSessionAsync_end, {
555
634
  success: !0,
@@ -564,9 +643,9 @@ var oe = () => {
564
643
  r.service_worker_relative_url && t.publishEvent(e.service_worker_not_supported_by_browser, { message: "service worker is not supported by this browser" });
565
644
  let n = i(t.configurationName, r.storage ?? sessionStorage, r.login_state_storage ?? r.storage ?? sessionStorage), { tokens: o } = await n.initAsync();
566
645
  if (o) {
567
- t.tokens = Ve(o, null, r.token_renew_mode);
646
+ t.tokens = ot(o, null, r.token_renew_mode);
568
647
  let i = n.getLoginParams();
569
- t.timeoutId = H(t, t.tokens.expiresAt, i.extras, i.scope);
648
+ t.timeoutId = W(t, t.tokens.expiresAt, i.extras, i.scope);
570
649
  let s = await n.getSessionStateAsync();
571
650
  return await t.startCheckSessionAsync(a.checkSessionIframe, r.client_id, s), r.preload_user_info && await t.userInfoAsync(), t.publishEvent(e.tryKeepExistingSessionAsync_end, {
572
651
  success: !0,
@@ -581,7 +660,7 @@ var oe = () => {
581
660
  } catch (r) {
582
661
  return console.error(r), n && await n.clearAsync(), t.publishEvent(e.tryKeepExistingSessionAsync_error, "tokens inside ServiceWorker are invalid"), !1;
583
662
  }
584
- }, O = class {
663
+ }, j = class {
585
664
  open(e) {
586
665
  window.location.href = e;
587
666
  }
@@ -598,56 +677,78 @@ var oe = () => {
598
677
  getOrigin() {
599
678
  return window.origin;
600
679
  }
601
- }, k = {
680
+ }, M = {
602
681
  STATE_MISSING: "STATE_MISSING",
603
682
  STATE_MISMATCH: "STATE_MISMATCH",
604
683
  NONCE_MISSING: "NONCE_MISSING"
605
- }, A = class e extends Error {
606
- constructor(t, n) {
607
- super(n), this.name = "OidcStateError", this.code = t, Object.setPrototypeOf(this, e.prototype);
608
- }
609
- }, ce = (e) => e instanceof A, j = {}, le = (e, t = window.sessionStorage, n) => {
610
- if (!j[e] && t) {
684
+ }, _e = new Set(Object.values(M)), ve = (e) => typeof e == "string" && _e.has(e), N = class e extends d {
685
+ constructor(t, n, r = "callback") {
686
+ super(t, n, {
687
+ phase: r,
688
+ retryable: !1
689
+ }), this.name = "OidcStateError", Object.setPrototypeOf(this, e.prototype);
690
+ }
691
+ }, ye = (e) => e instanceof N || f(e) && ve(e.code), P = {
692
+ ENDPOINT_UNAVAILABLE: "ENDPOINT_UNAVAILABLE",
693
+ REQUEST_FAILED: "REQUEST_FAILED",
694
+ INVALID_RESPONSE: "INVALID_RESPONSE"
695
+ }, F = class e extends d {
696
+ constructor(t, n, r = {}) {
697
+ super(t, n, {
698
+ phase: "login",
699
+ retryable: r.cause !== void 0 || p(r.status),
700
+ status: r.status,
701
+ oauthError: r.oauthError,
702
+ oauthErrorDescription: r.oauthErrorDescription,
703
+ cause: r.cause
704
+ }), this.name = "PushedAuthorizationRequestError", Object.setPrototypeOf(this, e.prototype);
705
+ }
706
+ }, be = (e) => e instanceof F, I = {}, xe = (e, t = window.sessionStorage, n) => {
707
+ if (!I[e] && t) {
611
708
  let n = t.getItem(e);
612
- n && (j[e] = JSON.parse(n));
709
+ n && (I[e] = JSON.parse(n));
613
710
  }
614
711
  let r = 1e3 * n;
615
- return j[e] && j[e].timestamp + r > Date.now() ? j[e].result : null;
616
- }, ue = (e, t, n = window.sessionStorage) => {
712
+ return I[e] && I[e].timestamp + r > Date.now() ? I[e].result : null;
713
+ }, Se = (e, t, n = window.sessionStorage) => {
617
714
  let r = Date.now();
618
- j[e] = {
715
+ I[e] = {
619
716
  result: t,
620
717
  timestamp: r
621
718
  }, n && n.setItem(e, JSON.stringify({
622
719
  result: t,
623
720
  timestamp: r
624
721
  }));
625
- }, de = 3600, fe = (e) => async (t, n = de, r = window.sessionStorage, i = 1e4) => {
626
- let a = `${t}/.well-known/openid-configuration`, o = `oidc.server:${t}`, s = le(o, r, n);
627
- if (s) return new z(s);
628
- let c = await M(e)(a, {}, i);
722
+ }, Ce = 3600, we = (e) => async (t, n = Ce, r = window.sessionStorage, i = 1e4) => {
723
+ let a = `${t}/.well-known/openid-configuration`, o = `oidc.server:${t}`, s = xe(o, r, n);
724
+ if (s) return new qe(s);
725
+ let c = await L(e)(a, {}, i);
629
726
  if (c.status !== 200) return null;
630
727
  let l = await c.json();
631
- return ue(o, l, r), new z(l);
632
- }, M = (e) => async (t, n = {}, r = 1e4, i = 0) => {
728
+ return Se(o, l, r), new qe(l);
729
+ }, L = (e) => async (t, n = {}, r = 1e4, i = 0) => {
633
730
  let a;
634
731
  try {
635
- let i = new AbortController();
636
- setTimeout(() => i.abort(), r), a = await e(t, {
637
- ...n,
638
- signal: i.signal
639
- });
732
+ let i = new AbortController(), o = setTimeout(() => i.abort(), r);
733
+ try {
734
+ a = await e(t, {
735
+ ...n,
736
+ signal: i.signal
737
+ });
738
+ } finally {
739
+ clearTimeout(o);
740
+ }
640
741
  } catch (a) {
641
742
  if (a.name === "AbortError" || a.message === "Network request failed") {
642
- if (i <= 1) return await M(e)(t, n, r, i + 1);
743
+ if (i <= 1) return await L(e)(t, n, r, i + 1);
643
744
  throw a;
644
745
  } else throw console.error(a.message), a;
645
746
  }
646
747
  return a;
647
- }, N = {
748
+ }, Te = {
648
749
  refresh_token: "refresh_token",
649
750
  access_token: "access_token"
650
- }, pe = (e) => async (t, n, r = N.refresh_token, i, a = {}, o = 1e4) => {
751
+ }, Ee = (e) => async (t, n, r = Te.refresh_token, i, a = {}, o = 1e4) => {
651
752
  let s = {
652
753
  token: n,
653
754
  token_type_hint: r,
@@ -659,20 +760,69 @@ var oe = () => {
659
760
  let t = encodeURIComponent(e), n = encodeURIComponent(s[e]);
660
761
  c.push(`${t}=${n}`);
661
762
  }
662
- let l = c.join("&");
663
- return (await M(e)(t, {
763
+ let l = c.join("&"), u = await L(e)(t, {
664
764
  method: "POST",
665
765
  headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" },
666
766
  body: l
667
- }, o)).status === 200 ? { success: !0 } : { success: !1 };
668
- }, me = (e) => async (t, n, r, i, a = {}, o, s = 1e4) => {
767
+ }, o);
768
+ if (u.status !== 200) {
769
+ let e = await De(u);
770
+ return {
771
+ success: !1,
772
+ status: u.status,
773
+ oauthError: typeof e?.error == "string" ? e.error : void 0,
774
+ oauthErrorDescription: typeof e?.error_description == "string" ? e.error_description : void 0
775
+ };
776
+ }
777
+ return {
778
+ success: !0,
779
+ status: u.status
780
+ };
781
+ }, De = async (e) => {
782
+ try {
783
+ return await e.json();
784
+ } catch {
785
+ return null;
786
+ }
787
+ }, Oe = (e) => async (t, n, r = 1e4) => {
788
+ if (n.request_uri !== void 0) throw new F(P.REQUEST_FAILED, "The request_uri parameter must not be included in a pushed authorization request.");
789
+ let i = [];
790
+ for (let e in n) {
791
+ let t = encodeURIComponent(e), r = encodeURIComponent(n[e]);
792
+ i.push(`${t}=${r}`);
793
+ }
794
+ let a;
795
+ try {
796
+ a = await L(e)(t, {
797
+ method: "POST",
798
+ headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" },
799
+ body: i.join("&")
800
+ }, r);
801
+ } catch (e) {
802
+ throw new F(P.REQUEST_FAILED, "The pushed authorization request could not be sent.", { cause: e });
803
+ }
804
+ let o = await De(a);
805
+ if (a.status !== 201) {
806
+ let e = typeof o?.error == "string" ? o.error : void 0, t = typeof o?.error_description == "string" ? o.error_description : void 0, n = [e, t].filter(Boolean).join(": ");
807
+ throw new F(P.REQUEST_FAILED, `The pushed authorization request failed with HTTP status ${a.status}${n ? ` (${n})` : ""}.`, {
808
+ status: a.status,
809
+ oauthError: e,
810
+ oauthErrorDescription: t
811
+ });
812
+ }
813
+ if (typeof o?.request_uri != "string" || o.request_uri.length === 0 || !Number.isInteger(o?.expires_in) || o.expires_in <= 0) throw new F(P.INVALID_RESPONSE, "The pushed authorization response must contain a non-empty request_uri and a positive integer expires_in.", { status: a.status });
814
+ return {
815
+ request_uri: o.request_uri,
816
+ expires_in: o.expires_in
817
+ };
818
+ }, ke = (e) => async (t, n, r, i, a = {}, o, s = 1e4) => {
669
819
  for (let [e, t] of Object.entries(r)) n[e] === void 0 && (n[e] = t);
670
820
  let c = [];
671
821
  for (let e in n) {
672
822
  let t = encodeURIComponent(e), r = encodeURIComponent(n[e]);
673
823
  c.push(`${t}=${r}`);
674
824
  }
675
- let l = c.join("&"), u = await M(e)(t, {
825
+ let l = c.join("&"), u = await L(e)(t, {
676
826
  method: "POST",
677
827
  headers: {
678
828
  "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
@@ -680,56 +830,74 @@ var oe = () => {
680
830
  },
681
831
  body: l
682
832
  }, s);
683
- if (u.status !== 200) return {
684
- success: !1,
685
- status: u.status,
686
- demonstratingProofOfPossessionNonce: null
687
- };
833
+ if (u.status !== 200) {
834
+ let e = await De(u);
835
+ return {
836
+ success: !1,
837
+ status: u.status,
838
+ data: e,
839
+ oauthError: typeof e?.error == "string" ? e.error : void 0,
840
+ oauthErrorDescription: typeof e?.error_description == "string" ? e.error_description : void 0,
841
+ demonstratingProofOfPossessionNonce: u.headers?.has(R) ? u.headers.get(R) : null
842
+ };
843
+ }
688
844
  let d = await u.json(), f = null;
689
- return u.headers.has(P) && (f = u.headers.get(P)), {
845
+ return u.headers.has(R) && (f = u.headers.get(R)), {
690
846
  success: !0,
691
847
  status: u.status,
692
- data: He(d, i, o),
848
+ data: st(d, i, o),
693
849
  demonstratingProofOfPossessionNonce: f
694
850
  };
695
- }, he = (e, t) => async (n, r) => {
851
+ }, Ae = (e, t) => async (n, r, i) => {
696
852
  r = r ? { ...r } : {};
697
- let i = E(128), a = await ne(i);
698
- await e.setCodeVerifierAsync(i), await e.setStateAsync(r.state), r.code_challenge = a, r.code_challenge_method = "S256";
699
- let o = "";
700
- if (r) for (let [e, t] of Object.entries(r)) o === "" ? o += "?" : o += "&", o += `${e}=${encodeURIComponent(t)}`;
701
- t.open(`${n}${o}`);
702
- }, P = "DPoP-Nonce", ge = (e) => async (t, n, r, i, a = 1e4) => {
853
+ let a = A(128), o = await de(a);
854
+ if (await e.setCodeVerifierAsync(a), await e.setStateAsync(r.state), r.code_challenge = o, r.code_challenge_method = "S256", i) {
855
+ let e = await Oe(i.fetch)(i.endpoint, r, i.timeoutMs);
856
+ t.open(`${n}?client_id=${encodeURIComponent(r.client_id)}&request_uri=${encodeURIComponent(e.request_uri)}`);
857
+ return;
858
+ }
859
+ let s = "";
860
+ if (r) for (let [e, t] of Object.entries(r)) s === "" ? s += "?" : s += "&", s += `${e}=${encodeURIComponent(t)}`;
861
+ t.open(`${n}${s}`);
862
+ }, R = "DPoP-Nonce", je = (e) => async (t, n, r, i, a = 1e4, o = !1) => {
703
863
  n = n ? { ...n } : {}, n.code_verifier = await e.getCodeVerifierAsync();
704
- let o = [];
864
+ let s = [];
705
865
  for (let e in n) {
706
866
  let t = encodeURIComponent(e), r = encodeURIComponent(n[e]);
707
- o.push(`${t}=${r}`);
867
+ s.push(`${t}=${r}`);
708
868
  }
709
- let s = o.join("&"), c = await M(fetch)(t, {
869
+ let c = s.join("&"), l = await L(fetch)(t, {
710
870
  method: "POST",
711
871
  headers: {
712
872
  "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
713
873
  ...r
714
874
  },
715
- body: s
875
+ body: c
716
876
  }, a);
717
- if (await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]), c.status !== 200) return {
718
- success: !1,
719
- status: c.status
720
- };
721
- let l = null;
722
- c.headers.has(P) && (l = c.headers.get(P));
723
- let u = await c.json();
877
+ if (l.status !== 200) {
878
+ let t = await De(l), n = typeof t?.error == "string" ? t.error : void 0;
879
+ return o && n === "use_dpop_nonce" || await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]), {
880
+ success: !1,
881
+ status: l.status,
882
+ data: t,
883
+ oauthError: n,
884
+ oauthErrorDescription: typeof t?.error_description == "string" ? t.error_description : void 0,
885
+ demonstratingProofOfPossessionNonce: l.headers?.has(R) ? l.headers.get(R) : null
886
+ };
887
+ }
888
+ await Promise.all([e.setCodeVerifierAsync(null), e.setStateAsync(null)]);
889
+ let u = null;
890
+ l.headers.has(R) && (u = l.headers.get(R));
891
+ let d = await l.json();
724
892
  return {
725
893
  success: !0,
726
894
  data: {
727
895
  state: n.state,
728
- tokens: He(u, null, i),
729
- demonstratingProofOfPossessionNonce: l
896
+ tokens: st(d, null, i),
897
+ demonstratingProofOfPossessionNonce: u
730
898
  }
731
899
  };
732
- }, _e = (e) => {
900
+ }, Me = (e) => {
733
901
  let t = e.match(/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
734
902
  if (!t) throw Error("Invalid URL");
735
903
  let n = t[6], r = t[7];
@@ -747,119 +915,144 @@ var oe = () => {
747
915
  search: n,
748
916
  hash: r
749
917
  };
750
- }, ve = (e) => {
751
- let t = _e(e), { path: n } = t;
918
+ }, Ne = (e) => {
919
+ let t = Me(e), { path: n } = t;
752
920
  n.endsWith("/") && (n = n.slice(0, -1));
753
921
  let { hash: r } = t;
754
922
  return r === "#_=_" && (r = ""), r && (n += r), n;
755
- }, F = (e) => {
756
- let { search: t } = _e(e);
757
- return ye(t);
758
- }, ye = (e) => {
923
+ }, z = (e) => {
924
+ let { search: t } = Me(e);
925
+ return Pe(t);
926
+ }, Pe = (e) => {
759
927
  let t = {}, n, r, i, a = e.split("&");
760
928
  for (r = 0, i = a.length; r < i; r++) n = a[r].split("="), t[decodeURIComponent(n[0])] = decodeURIComponent(n[1]);
761
929
  return t;
762
- }, be = (t, n, r, a, o) => (s = void 0, c = null, l = !1, u = void 0) => {
763
- let d = c;
764
- return c = { ...c }, (async () => {
765
- let f = s || o.getPath();
766
- if ("state" in c || (c.state = E(16)), r(e.loginAsync_begin, {}), c) for (let e of Object.keys(c)) e.endsWith(":token_request") && delete c[e];
930
+ }, Fe = (t, n, r, a, o, s = () => window.fetch) => (c = void 0, l = null, u = !1, d = void 0) => {
931
+ let f = l;
932
+ return l = { ...l }, (async () => {
933
+ let p = c || o.getPath();
934
+ if ("state" in l || (l.state = A(16)), r(e.loginAsync_begin, {}), l) for (let e of Object.keys(l)) e.endsWith(":token_request") && delete l[e];
767
935
  try {
768
- let e = l ? n.silent_redirect_uri : n.redirect_uri;
769
- u ||= n.scope;
936
+ let e = u ? n.silent_redirect_uri : n.redirect_uri;
937
+ d ||= n.scope;
770
938
  let r = n.extras ? {
771
939
  ...n.extras,
772
- ...c
773
- } : c;
774
- r.nonce ||= E(12);
775
- let s = { nonce: r.nonce }, p = await $(n, t), m = await a(n.authority, n.authority_configuration), h;
776
- if (p) p.setLoginParams({
777
- callbackPath: f,
778
- extras: d,
779
- scope: u
780
- }), await p.initAsync(m, "loginAsync", n), await p.setNonceAsync(s), p.startKeepAliveServiceWorker(), h = p;
940
+ ...l
941
+ } : l;
942
+ r.nonce ||= A(12);
943
+ let c = { nonce: r.nonce }, m = await $(n, t), h = await a(n.authority, n.authority_configuration), g;
944
+ if (m) m.setLoginParams({
945
+ callbackPath: p,
946
+ extras: f,
947
+ scope: d
948
+ }), await m.initAsync(h, "loginAsync", n), await m.setNonceAsync(c), m.startKeepAliveServiceWorker(), g = m;
781
949
  else {
782
950
  let e = i(t, n.storage ?? sessionStorage, n.login_state_storage ?? n.storage ?? sessionStorage);
783
951
  e.setLoginParams({
784
- callbackPath: f,
785
- extras: d,
786
- scope: u
787
- }), await e.setNonceAsync(s), h = e;
952
+ callbackPath: p,
953
+ extras: f,
954
+ scope: d
955
+ }), await e.setNonceAsync(c), g = e;
788
956
  }
789
- let g = {
957
+ let _ = {
790
958
  client_id: n.client_id,
791
959
  redirect_uri: e,
792
- scope: u,
960
+ scope: d,
793
961
  response_type: "code",
794
962
  ...r
795
- };
796
- await he(h, o)(m.authorizationEndpoint, g);
963
+ }, v = n.par ?? "disabled", y = h.pushedAuthorizationRequestEndpoint, b = h.requirePushedAuthorizationRequests;
964
+ if (!y && (v === "required" || v === "auto" && b)) throw new F(P.ENDPOINT_UNAVAILABLE, "Pushed Authorization Requests are required, but the authorization server metadata does not provide a pushed_authorization_request_endpoint.");
965
+ let x = v !== "disabled" && y ? {
966
+ endpoint: y,
967
+ fetch: s(),
968
+ timeoutMs: n.par_request_timeout
969
+ } : void 0;
970
+ await Ae(g, o)(h.authorizationEndpoint, _, x);
797
971
  } catch (t) {
798
- throw r(e.loginAsync_error, t), t;
972
+ let n = _(t) ? g(t, "login") : t;
973
+ throw r(e.loginAsync_error, n), n;
799
974
  }
800
975
  })();
801
- }, xe = (t) => async (n = !1) => {
976
+ }, Ie = (t) => async (n = !1) => {
802
977
  try {
803
978
  t.publishEvent(e.loginCallbackAsync_begin, {});
804
- let r = t.configuration, a = r.client_id, o = n ? r.silent_redirect_uri : r.redirect_uri, s = r.authority, c = r.token_request_timeout, l = await t.initAsync(s, r.authority_configuration), u = F(t.location.getCurrentHref()), d = u.session_state, f = await $(r, t.configurationName), p, m, h, g;
805
- if (f) await f.initAsync(l, "loginCallbackAsync", r), await f.setSessionStateAsync(d), m = await f.getNonceAsync(), h = f.getLoginParams(), g = await f.getStateAsync(), f.startKeepAliveServiceWorker(), p = f;
979
+ let r = t.configuration, a = r.client_id, o = n ? r.silent_redirect_uri : r.redirect_uri, s = r.authority, l = r.token_request_timeout, u = await t.initAsync(s, r.authority_configuration), f = z(t.location.getCurrentHref()), m = f.session_state, g = await $(r, t.configurationName), _, v, y, b;
980
+ if (g) await g.initAsync(u, "loginCallbackAsync", r), await g.setSessionStateAsync(m), v = await g.getNonceAsync(), y = g.getLoginParams(), b = await g.getStateAsync(), g.startKeepAliveServiceWorker(), _ = g;
806
981
  else {
807
982
  let e = i(t.configurationName, r.storage ?? sessionStorage, r.login_state_storage ?? r.storage ?? sessionStorage);
808
- await e.setSessionStateAsync(d), m = await e.getNonceAsync(), h = e.getLoginParams(), g = await e.getStateAsync(), p = e;
983
+ await e.setSessionStateAsync(m), v = await e.getNonceAsync(), y = e.getLoginParams(), b = await e.getStateAsync(), _ = e;
809
984
  }
810
- if (u.error || u.error_description) throw Error(`Error from OIDC server: ${u.error} - ${u.error_description}`);
811
- if (u.iss && u.iss !== l.issuer) throw console.error(), Error(`Issuer not valid (expected: ${l.issuer}, received: ${u.iss})`);
812
- if (u.state) {
813
- if (!g) throw new A(k.STATE_MISSING, "OIDC state is missing from storage. The login state may have been cleared between the authorization redirect and the callback (e.g., private browsing, storage cleared, or browser eviction).");
814
- if (u.state !== g) throw new A(k.STATE_MISMATCH, `OIDC state does not match the stored one (expected: ${g}, received: ${u.state}).`);
985
+ if (f.error || f.error_description) throw h(f.error, f.error_description, `Error from OIDC server: ${f.error} - ${f.error_description}`, n ? "refresh" : "callback");
986
+ if (f.iss && f.iss !== u.issuer) throw console.error(), Error(`Issuer not valid (expected: ${u.issuer}, received: ${f.iss})`);
987
+ if (f.state) {
988
+ if (!b) throw new N(M.STATE_MISSING, "OIDC state is missing from storage. The login state may have been cleared between the authorization redirect and the callback (e.g., private browsing, storage cleared, or browser eviction).", n ? "refresh" : "callback");
989
+ if (f.state !== b) throw new N(M.STATE_MISMATCH, `OIDC state does not match the stored one (expected: ${b}, received: ${f.state}).`, n ? "refresh" : "callback");
815
990
  }
816
- if (!m || !m.nonce) throw new A(k.NONCE_MISSING, "OIDC nonce is missing from storage. The login state may have been cleared between the authorization redirect and the callback (e.g., private browsing, storage cleared, or browser eviction).");
817
- let _ = {
818
- code: u.code,
991
+ if (!v || !v.nonce) throw new N(M.NONCE_MISSING, "OIDC nonce is missing from storage. The login state may have been cleared between the authorization redirect and the callback (e.g., private browsing, storage cleared, or browser eviction).", n ? "refresh" : "callback");
992
+ let x = {
993
+ code: f.code,
819
994
  grant_type: "authorization_code",
820
995
  client_id: r.client_id,
821
996
  redirect_uri: o
822
- }, v = {};
823
- if (r.token_request_extras) for (let [e, t] of Object.entries(r.token_request_extras)) v[e] = t;
824
- if (h?.extras) for (let [e, t] of Object.entries(h.extras)) e.endsWith(":token_request") && (v[e.replace(":token_request", "")] = t);
825
- let y = l.tokenEndpoint, b = {};
826
- if (r.demonstrating_proof_of_possession) if (f) b.DPoP = `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${t.configurationName}`;
827
- else {
828
- let e = await x(window)(r.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm);
829
- await i(t.configurationName, r.storage, r.login_state_storage ?? r.storage).setDemonstratingProofOfPossessionJwkAsync(e), b.DPoP = await ee(window)(r.demonstrating_proof_of_possession_configuration)(e, "POST", y);
997
+ }, S = {};
998
+ if (r.token_request_extras) for (let [e, t] of Object.entries(r.token_request_extras)) S[e] = t;
999
+ if (y?.extras) for (let [e, t] of Object.entries(y.extras)) e.endsWith(":token_request") && (S[e.replace(":token_request", "")] = t);
1000
+ let C = u.tokenEndpoint, w = {}, T;
1001
+ r.demonstrating_proof_of_possession && (g ? w.DPoP = `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${t.configurationName}` : (T = await re(window)(r.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm), await i(t.configurationName, r.storage, r.login_state_storage ?? r.storage).setDemonstratingProofOfPossessionJwkAsync(T), w.DPoP = await ie(window)(r.demonstrating_proof_of_possession_configuration)(T, "POST", C)));
1002
+ let E = await je(_)(C, {
1003
+ ...x,
1004
+ ...S
1005
+ }, w, t.configuration.token_renew_mode, l, r.demonstrating_proof_of_possession);
1006
+ if (!E.success && E.oauthError === "use_dpop_nonce" && E.demonstratingProofOfPossessionNonce && r.demonstrating_proof_of_possession ? (await _.setDemonstratingProofOfPossessionNonce(E.demonstratingProofOfPossessionNonce), g || (w.DPoP = await ie(window)(r.demonstrating_proof_of_possession_configuration)(T, "POST", C, { nonce: E.demonstratingProofOfPossessionNonce })), E = await je(_)(C, {
1007
+ ...x,
1008
+ ...S
1009
+ }, w, t.configuration.token_renew_mode, l)) : !E.success && r.demonstrating_proof_of_possession && await Promise.all([_.setCodeVerifierAsync(null), _.setStateAsync(null)]), !E.success) {
1010
+ let e = E.oauthError === "use_dpop_nonce" ? c.DPOP_NONCE_REQUIRED : c.TOKEN_REQUEST_FAILED;
1011
+ throw new d(e, "Token request failed", {
1012
+ phase: n ? "refresh" : "callback",
1013
+ retryable: e === c.DPOP_NONCE_REQUIRED || p(E.status),
1014
+ status: E.status,
1015
+ oauthError: E.oauthError,
1016
+ oauthErrorDescription: E.oauthErrorDescription
1017
+ });
830
1018
  }
831
- let S = await ge(p)(y, {
832
- ..._,
833
- ...v
834
- }, b, t.configuration.token_renew_mode, c);
835
- if (!S.success) throw Error("Token request failed");
836
- let C, w = S.data.tokens, T = S.data.demonstratingProofOfPossessionNonce;
837
- if (S.data.state !== v.state) throw Error("state is not valid");
838
- let { isValid: E, reason: D } = Ge(w, m.nonce, l);
839
- if (!E) throw Error(`Tokens are not OpenID valid, reason: ${D}`);
840
- if (f) {
841
- if (w.refreshToken && !w.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER")) throw Error("Refresh token should be hidden by service worker");
842
- if (T && w?.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER")) throw Error("Demonstration of proof of possession require Access token not hidden by service worker");
1019
+ let D, O = E.data.tokens, k = E.data.demonstratingProofOfPossessionNonce;
1020
+ if (E.data.state !== S.state) throw new d(c.INVALID_STATE, "state is not valid", {
1021
+ phase: n ? "refresh" : "callback",
1022
+ retryable: !1
1023
+ });
1024
+ let { isValid: ee, reason: te } = ut(O, v.nonce, u);
1025
+ if (!ee) {
1026
+ let e = `Tokens are not OpenID valid, reason: ${te}`;
1027
+ throw te.startsWith("Nonce does not match") ? new d(c.INVALID_NONCE, e, {
1028
+ phase: n ? "refresh" : "callback",
1029
+ retryable: !1
1030
+ }) : Error(e);
1031
+ }
1032
+ if (g) {
1033
+ if (O.refreshToken && !O.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER")) throw Error("Refresh token should be hidden by service worker");
1034
+ if (k && O?.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER")) throw Error("Demonstration of proof of possession require Access token not hidden by service worker");
843
1035
  }
844
- if (f) await f.initAsync(l, "syncTokensAsync", r), C = f.getLoginParams(), T && await f.setDemonstratingProofOfPossessionNonce(T);
1036
+ if (g) await g.initAsync(u, "syncTokensAsync", r), D = g.getLoginParams(), k && await g.setDemonstratingProofOfPossessionNonce(k);
845
1037
  else {
846
1038
  let e = i(t.configurationName, r.storage, r.login_state_storage ?? r.storage);
847
- C = e.getLoginParams(), T && await e.setDemonstratingProofOfPossessionNonce(T);
1039
+ D = e.getLoginParams(), k && await e.setDemonstratingProofOfPossessionNonce(k);
848
1040
  }
849
- return await t.startCheckSessionAsync(l.checkSessionIframe, a, d, n), t.publishEvent(e.loginCallbackAsync_end, {}), {
850
- tokens: w,
1041
+ return await t.startCheckSessionAsync(u.checkSessionIframe, a, m, n), t.publishEvent(e.loginCallbackAsync_end, {}), {
1042
+ tokens: O,
851
1043
  state: "request.state",
852
- callbackPath: C.callbackPath,
853
- scope: u.scope,
854
- extras: C.extras
1044
+ callbackPath: D.callbackPath,
1045
+ scope: f.scope,
1046
+ extras: D.extras
855
1047
  };
856
- } catch (n) {
857
- throw console.error(n), t.publishEvent(e.loginCallbackAsync_error, n), n;
1048
+ } catch (r) {
1049
+ let i = !f(r) && _(r) ? g(r, n ? "refresh" : "callback") : r;
1050
+ throw console.error(i), t.publishEvent(e.loginCallbackAsync_error, i), i;
858
1051
  }
859
- }, Se = {
1052
+ }, Le = {
860
1053
  access_token: "access_token",
861
1054
  refresh_token: "refresh_token"
862
- }, I = (e, t) => {
1055
+ }, Re = (e, t) => {
863
1056
  let n = {};
864
1057
  if (e) {
865
1058
  for (let [r, i] of Object.entries(e)) if (r.endsWith(t)) {
@@ -869,134 +1062,184 @@ var oe = () => {
869
1062
  return n;
870
1063
  }
871
1064
  return n;
872
- }, Ce = (e) => {
1065
+ }, ze = (e) => {
873
1066
  let t = {};
874
1067
  if (e) {
875
1068
  for (let [n, r] of Object.entries(e)) n.includes(":") || (t[n] = r);
876
1069
  return t;
877
1070
  }
878
1071
  return t;
879
- }, we = (e) => async (t) => {
880
- c.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
1072
+ }, Be = (e) => async (t) => {
1073
+ b.clearTimeout(e.timeoutId), e.timeoutId = null, e.checkSessionIFrame && e.checkSessionIFrame.stop();
881
1074
  let n = await $(e.configuration, e.configurationName);
882
1075
  n ? await n.clearAsync(t) : await i(e.configurationName, e.configuration.storage, e.configuration.login_state_storage ?? e.configuration.storage).clearAsync(t), e.tokens = null, e.userInfo = null;
883
- }, L = (t, n) => async () => {
1076
+ }, Ve = (t, n) => async () => {
884
1077
  let r = t.tokens?.idTokenPayload?.sub ?? null;
885
1078
  await t.destroyAsync("LOGGED_OUT");
886
1079
  for (let [, i] of Object.entries(n)) i === t ? t.publishEvent(e.logout_from_same_tab, {}) : await t.logoutSameTabAsync(t.configuration.client_id, r);
887
- }, Te = (e, t, n, r) => {
1080
+ }, He = (e, t, n, r) => {
888
1081
  "id_token_hint" in t || (t.id_token_hint = n), !("post_logout_redirect_uri" in t) && r !== null && (t.post_logout_redirect_uri = r);
889
1082
  let i = "";
890
1083
  for (let [e, n] of Object.entries(t)) n != null && (i === "" ? i += "?" : i += "&", i += `${e}=${encodeURIComponent(n)}`);
891
1084
  return `${e}${i}`;
892
- }, Ee = (e, t, n, r, i) => async (a = void 0, o = null) => {
893
- let s = e.configuration, c = await e.initAsync(s.authority, s.authority_configuration);
894
- a && typeof a != "string" && (a = void 0, r.warn("callbackPathOrUrl path is not a string"));
895
- let l = a ?? i.getPath(), u = !1;
896
- a && (u = a.includes("https://") || a.includes("http://"));
897
- let d = a === null ? null : u ? a : i.getOrigin() + l, f = e.tokens ? e.tokens.idToken : "";
898
- e.isLoggingOut = !0;
1085
+ }, Ue = (t, n, r, i, a) => async (o = void 0, s = null) => {
1086
+ let l = t.configuration, u;
1087
+ try {
1088
+ u = await t.initAsync(l.authority, l.authority_configuration);
1089
+ } catch (n) {
1090
+ let r = _(n) ? g(n, "logout") : n;
1091
+ throw t.publishEvent(e.logoutAsync_error, r), r;
1092
+ }
1093
+ o && typeof o != "string" && (o = void 0, i.warn("callbackPathOrUrl path is not a string"));
1094
+ let m = o ?? a.getPath(), h = !1;
1095
+ o && (h = o.includes("https://") || o.includes("http://"));
1096
+ let v = o === null ? null : h ? o : a.getOrigin() + m, y = t.tokens ? t.tokens.idToken : "";
1097
+ t.isLoggingOut = !0;
899
1098
  try {
900
1099
  try {
901
- let t = c.revocationEndpoint;
902
- if (t) {
903
- let r = [], i = e.tokens ? e.tokens.accessToken : null;
904
- if (i && s.logout_tokens_to_invalidate.includes(Se.access_token)) {
905
- let e = I(o, ":revoke_access_token"), a = pe(n)(t, i, N.access_token, s.client_id, e);
906
- r.push(a);
1100
+ let n = u.revocationEndpoint;
1101
+ if (n) {
1102
+ let i = [], a = t.tokens ? t.tokens.accessToken : null;
1103
+ if (a && l.logout_tokens_to_invalidate.includes(Le.access_token)) {
1104
+ let e = Re(s, ":revoke_access_token"), t = Ee(r)(n, a, Te.access_token, l.client_id, e);
1105
+ i.push(t);
907
1106
  }
908
- let a = e.tokens ? e.tokens.refreshToken : null;
909
- if (a && s.logout_tokens_to_invalidate.includes(Se.refresh_token)) {
910
- let e = I(o, ":revoke_refresh_token"), i = pe(n)(t, a, N.refresh_token, s.client_id, e);
911
- r.push(i);
1107
+ let o = t.tokens ? t.tokens.refreshToken : null;
1108
+ if (o && l.logout_tokens_to_invalidate.includes(Le.refresh_token)) {
1109
+ let e = Re(s, ":revoke_refresh_token"), t = Ee(r)(n, o, Te.refresh_token, l.client_id, e);
1110
+ i.push(t);
1111
+ }
1112
+ if (i.length > 0) {
1113
+ let n = await Promise.all(i);
1114
+ for (let r of n) r.success || t.publishEvent(e.logoutAsync_error, new d(c.REQUEST_FAILED, "Token revocation request failed", {
1115
+ phase: "logout",
1116
+ retryable: p(r.status),
1117
+ status: r.status,
1118
+ oauthError: r.oauthError,
1119
+ oauthErrorDescription: r.oauthErrorDescription
1120
+ }));
912
1121
  }
913
- r.length > 0 && await Promise.all(r);
914
1122
  }
915
- } catch (e) {
916
- r.warn("logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"), r.warn(e);
1123
+ } catch (n) {
1124
+ let r = !f(n) && _(n) ? g(n, "logout") : n;
1125
+ t.publishEvent(e.logoutAsync_error, r), i.warn("logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"), i.warn(r);
917
1126
  }
918
- let a = I(o, ":oidc");
919
- if (a && a.no_reload === "true") {
920
- await L(e, t)(), e.isLoggingOut = !1;
1127
+ let o = Re(s, ":oidc");
1128
+ if (o && o.no_reload === "true") {
1129
+ await Ve(t, n)(), t.isLoggingOut = !1;
921
1130
  return;
922
1131
  }
923
- let l = Ce(o);
924
- if (c.endSessionEndpoint) {
925
- let e = Te(c.endSessionEndpoint, l, f, d);
926
- i.open(e);
927
- } else i.reload();
928
- await L(e, t)();
929
- } catch (t) {
930
- throw e.isLoggingOut = !1, t;
1132
+ let m = ze(s);
1133
+ if (u.endSessionEndpoint) {
1134
+ let e = He(u.endSessionEndpoint, m, y, v);
1135
+ a.open(e);
1136
+ } else a.reload();
1137
+ await Ve(t, n)();
1138
+ } catch (n) {
1139
+ t.isLoggingOut = !1;
1140
+ let r = !f(n) && _(n) ? g(n, "logout") : n;
1141
+ throw t.publishEvent(e.logoutAsync_error, r), r;
931
1142
  }
932
- }, R = /* @__PURE__ */ function(e) {
1143
+ }, B = /* @__PURE__ */ function(e) {
933
1144
  return e.AutomaticBeforeTokenExpiration = "AutomaticBeforeTokensExpiration", e.AutomaticOnlyWhenFetchExecuted = "AutomaticOnlyWhenFetchExecuted", e;
934
- }({}), De = (e, t, n = !1) => async (...r) => {
935
- let [i, a, ...o] = r, s = a ? { ...a } : { method: "GET" }, c = new Headers();
936
- s.headers && (c = s.headers instanceof Headers ? s.headers : new Headers(s.headers));
937
- let l = (await We({
938
- getTokens: () => t.tokens,
1145
+ }({}), We = (t, n, r = !1, i = "api_request") => async (...a) => {
1146
+ let [o, s, ...l] = a, u = s ? { ...s } : { method: "GET" }, f = new Headers();
1147
+ u.headers && (f = u.headers instanceof Headers ? u.headers : new Headers(u.headers));
1148
+ let p = (await lt({
1149
+ getTokens: () => n.tokens,
939
1150
  configuration: {
940
- token_automatic_renew_mode: t.configuration.token_automatic_renew_mode,
941
- refresh_time_before_tokens_expiration_in_second: t.configuration.refresh_time_before_tokens_expiration_in_second
1151
+ token_automatic_renew_mode: n.configuration.token_automatic_renew_mode,
1152
+ refresh_time_before_tokens_expiration_in_second: n.configuration.refresh_time_before_tokens_expiration_in_second
942
1153
  },
943
1154
  syncTokensInfoAsync: async () => {
944
- let { status: e } = await Fe(t)(t.configuration, t.configurationName, t.tokens, !1);
1155
+ let { status: e } = await $e(n)(n.configuration, n.configurationName, n.tokens, !1);
945
1156
  return e;
946
1157
  },
947
- renewTokensAsync: t.renewTokensAsync.bind(t)
1158
+ renewTokensAsync: n.renewTokensAsync.bind(n)
948
1159
  }))?.tokens?.accessToken;
949
- if (c.has("Accept") || c.set("Accept", "application/json"), l) {
950
- if (t.configuration.demonstrating_proof_of_possession && n) {
951
- let e = await t.generateDemonstrationOfProofOfPossessionAsync(l, i.toString(), s.method);
952
- c.set("Authorization", `DPoP ${l}`), c.set("DPoP", e);
953
- } else c.set("Authorization", `Bearer ${l}`);
954
- s.credentials ||= "same-origin";
955
- }
956
- return await e(i, {
957
- ...s,
958
- headers: c
959
- }, ...o);
960
- }, Oe = (e) => async (t = !1, n = !1) => {
961
- if (e.userInfo != null && !t) return e.userInfo;
962
- let r = !t && e.configuration.storage?.getItem(`oidc.${e.configurationName}.userInfo`);
963
- if (r) return e.userInfo = JSON.parse(r), e.userInfo;
964
- let i = e.configuration, a = (await e.initAsync(i.authority, i.authority_configuration)).userInfoEndpoint, o = await (async () => {
965
- let t = await De(fetch, e, n)(a);
966
- return t.status === 200 ? t.json() : null;
967
- })();
968
- return e.userInfo = o, o && e.configuration.storage?.setItem(`oidc.${e.configurationName}.userInfo`, JSON.stringify(o)), o;
969
- }, ke = () => fetch, z = class {
1160
+ if (f.has("Accept") || f.set("Accept", "application/json"), p) {
1161
+ if (n.configuration.demonstrating_proof_of_possession && r) {
1162
+ let e = await n.generateDemonstrationOfProofOfPossessionAsync(p, o.toString(), u.method);
1163
+ f.set("Authorization", `DPoP ${p}`), f.set("DPoP", e);
1164
+ } else f.set("Authorization", `Bearer ${p}`);
1165
+ u.credentials ||= "same-origin";
1166
+ }
1167
+ let m = {
1168
+ ...u,
1169
+ headers: f
1170
+ }, h;
1171
+ try {
1172
+ h = await t(o, m, ...l);
1173
+ } catch (t) {
1174
+ let r = g(t, i);
1175
+ throw i === "api_request" && n.publishEvent(e.apiRequest_error, r), r;
1176
+ }
1177
+ if (!h.ok && h.headers?.has("DPoP-Nonce") && (h.status === 400 || h.status === 401 || h.headers.get("WWW-Authenticate")?.includes("use_dpop_nonce"))) {
1178
+ let t = new d(c.DPOP_NONCE_REQUIRED, "DPoP nonce required", {
1179
+ phase: i,
1180
+ retryable: !0,
1181
+ status: h.status,
1182
+ oauthError: "use_dpop_nonce"
1183
+ });
1184
+ i === "api_request" && n.publishEvent(e.apiRequest_error, t);
1185
+ }
1186
+ return h;
1187
+ }, Ge = (t) => async (n = !1, r = !1) => {
1188
+ try {
1189
+ if (t.userInfo != null && !n) return t.userInfo;
1190
+ let i = !n && t.configuration.storage?.getItem(`oidc.${t.configurationName}.userInfo`);
1191
+ if (i) return t.userInfo = JSON.parse(i), t.userInfo;
1192
+ let a = t.configuration, o = (await t.initAsync(a.authority, a.authority_configuration)).userInfoEndpoint, s = await (async () => {
1193
+ let n = await We(fetch, t, r, "userinfo")(o);
1194
+ if (n.status !== 200) {
1195
+ let r = n.headers?.has("DPoP-Nonce") && (n.status === 400 || n.status === 401 || n.headers.get("WWW-Authenticate")?.includes("use_dpop_nonce")), i = new d(r ? c.DPOP_NONCE_REQUIRED : c.REQUEST_FAILED, "UserInfo request failed", {
1196
+ phase: "userinfo",
1197
+ retryable: r || p(n.status),
1198
+ status: n.status,
1199
+ oauthError: r ? "use_dpop_nonce" : void 0
1200
+ });
1201
+ return t.publishEvent(e.userInfoAsync_error, i), null;
1202
+ }
1203
+ return n.json();
1204
+ })();
1205
+ return t.userInfo = s, s && t.configuration.storage?.setItem(`oidc.${t.configurationName}.userInfo`, JSON.stringify(s)), s;
1206
+ } catch (n) {
1207
+ let r = f(n) ? n : _(n) ? g(n, "userinfo") : n;
1208
+ throw t.publishEvent(e.userInfoAsync_error, r), r;
1209
+ }
1210
+ }, Ke = () => fetch, qe = class {
970
1211
  constructor(e) {
971
- this.authorizationEndpoint = e.authorization_endpoint, this.tokenEndpoint = e.token_endpoint, this.revocationEndpoint = e.revocation_endpoint, this.userInfoEndpoint = e.userinfo_endpoint, this.checkSessionIframe = e.check_session_iframe, this.issuer = e.issuer, this.endSessionEndpoint = e.end_session_endpoint;
1212
+ this.authorizationEndpoint = e.authorization_endpoint, this.tokenEndpoint = e.token_endpoint, this.revocationEndpoint = e.revocation_endpoint, this.userInfoEndpoint = e.userinfo_endpoint, this.checkSessionIframe = e.check_session_iframe, this.issuer = e.issuer, this.endSessionEndpoint = e.end_session_endpoint, this.pushedAuthorizationRequestEndpoint = e.pushed_authorization_request_endpoint, this.requirePushedAuthorizationRequests = e.require_pushed_authorization_requests ?? !1;
972
1213
  }
973
- }, B = {}, Ae = (e, t = new O()) => (n, r = "default") => (B[r] || (B[r] = new V(n, r, e, t)), B[r]), je = async (e) => {
1214
+ }, V = {}, Je = (e, t = new j()) => (n, r = "default") => (V[r] || (V[r] = new H(n, r, e, t)), V[r]), Ye = async (e) => {
974
1215
  let { parsedTokens: t, callbackPath: n, extras: r, scope: i } = await e.loginCallbackAsync();
975
- return e.timeoutId = H(e, t.expiresAt, r, i), { callbackPath: n };
976
- }, Me = (e) => Math.floor(Math.random() * e), V = class t {
977
- constructor(e, t = "default", n, r = new O()) {
1216
+ return e.timeoutId = W(e, t.expiresAt, r, i), { callbackPath: n };
1217
+ }, H = class t {
1218
+ constructor(e, t = "default", n, r = new j()) {
978
1219
  this.isLoggingOut = !1, this.initPromise = null, this.tryKeepExistingSessionPromise = null, this.loginPromise = null, this.loginCallbackPromise = null, this.loginCallbackWithAutoTokensRenewPromise = null, this.userInfoPromise = null, this.renewTokensPromise = null, this.clearSessionPromise = null, this.logoutPromise = null;
979
1220
  let i = e.silent_login_uri;
980
1221
  e.silent_redirect_uri && !e.silent_login_uri && (i = `${e.silent_redirect_uri.replace("-callback", "").replace("callback", "")}-login`);
981
1222
  let a = e.refresh_time_before_tokens_expiration_in_second ?? 120;
982
- a > 60 && (a -= Math.floor(Math.random() * 40)), this.location = r ?? new O(), this.configuration = {
1223
+ a > 60 && (a -= Math.floor(Math.random() * 40)), this.location = r ?? new j(), this.configuration = {
983
1224
  ...e,
984
1225
  silent_login_uri: i,
985
- token_automatic_renew_mode: e.token_automatic_renew_mode ?? R.AutomaticBeforeTokenExpiration,
1226
+ token_automatic_renew_mode: e.token_automatic_renew_mode ?? B.AutomaticBeforeTokenExpiration,
986
1227
  monitor_session: e.monitor_session ?? !1,
987
1228
  refresh_time_before_tokens_expiration_in_second: a,
988
1229
  silent_login_timeout: e.silent_login_timeout ?? 12e3,
989
- token_renew_mode: e.token_renew_mode ?? G.access_token_or_id_token_invalid,
1230
+ token_renew_mode: e.token_renew_mode ?? it.access_token_or_id_token_invalid,
990
1231
  demonstrating_proof_of_possession: e.demonstrating_proof_of_possession ?? !1,
991
1232
  authority_timeout_wellknowurl_in_millisecond: e.authority_timeout_wellknowurl_in_millisecond ?? 1e4,
992
1233
  logout_tokens_to_invalidate: e.logout_tokens_to_invalidate ?? ["access_token", "refresh_token"],
993
- service_worker_activate: e.service_worker_activate ?? oe,
994
- demonstrating_proof_of_possession_configuration: e.demonstrating_proof_of_possession_configuration ?? _,
995
- preload_user_info: e.preload_user_info ?? !1
996
- }, this.getFetch = n ?? ke, 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);
1234
+ service_worker_activate: e.service_worker_activate ?? he,
1235
+ demonstrating_proof_of_possession_configuration: e.demonstrating_proof_of_possession_configuration ?? k,
1236
+ preload_user_info: e.preload_user_info ?? !1,
1237
+ par: e.par ?? "disabled",
1238
+ par_request_timeout: e.par_request_timeout ?? 1e4
1239
+ }, this.getFetch = n ?? Ke, 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.renewTokensOrThrowAsync.bind(this), this.initAsync(this.configuration.authority, this.configuration.authority_configuration);
997
1240
  }
998
1241
  subscribeEvents(e) {
999
- let t = Me(9999999999999).toString();
1242
+ let t = A(16);
1000
1243
  return this.events.push({
1001
1244
  id: t,
1002
1245
  func: e
@@ -1012,10 +1255,10 @@ var oe = () => {
1012
1255
  });
1013
1256
  }
1014
1257
  static {
1015
- this.getOrCreate = (e, t) => (n, r = "default") => Ae(e, t)(n, r);
1258
+ this.getOrCreate = (e, t) => (n, r = "default") => Je(e, t)(n, r);
1016
1259
  }
1017
1260
  static get(e = "default") {
1018
- return Object.prototype.hasOwnProperty.call(B, e) ? B[e] : null;
1261
+ return Object.prototype.hasOwnProperty.call(V, e) ? V[e] : null;
1019
1262
  }
1020
1263
  static getOrThrow(e = "default") {
1021
1264
  let n = t.get(e);
@@ -1028,7 +1271,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1028
1271
  }
1029
1272
  _silentLoginCallbackFromIFrame() {
1030
1273
  if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
1031
- let e = this.location, t = F(e.getCurrentHref());
1274
+ let e = this.location, t = z(e.getCurrentHref());
1032
1275
  window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({
1033
1276
  tokens: this.tokens,
1034
1277
  sessionState: t.session_state
@@ -1037,8 +1280,18 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1037
1280
  }
1038
1281
  _silentLoginErrorCallbackFromIFrame(e = null) {
1039
1282
  if (this.configuration.silent_redirect_uri && this.configuration.silent_login_uri) {
1040
- let t = this.location, n = F(t.getCurrentHref());
1041
- n.error ? window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({ error: n.error })}`, t.getOrigin()) : window.parent.postMessage(`${this.configurationName}_oidc_exception:${JSON.stringify({ error: e == null ? "" : e.toString() })}`, t.getOrigin());
1283
+ let t = this.location, n = z(t.getCurrentHref());
1284
+ if (n.error) {
1285
+ let e = h(n.error, n.error_description, `Error from OIDC server: ${n.error} - ${n.error_description}`, "refresh");
1286
+ window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({
1287
+ error: n.error,
1288
+ error_description: n.error_description,
1289
+ oidcError: v(e)
1290
+ })}`, t.getOrigin());
1291
+ } else window.parent.postMessage(`${this.configurationName}_oidc_exception:${JSON.stringify({
1292
+ error: e == null ? "" : e.toString(),
1293
+ oidcError: f(e) ? v(e) : void 0
1294
+ })}`, t.getOrigin());
1042
1295
  }
1043
1296
  }
1044
1297
  async silentLoginCallbackAsync() {
@@ -1051,39 +1304,41 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1051
1304
  async initAsync(e, t) {
1052
1305
  if (this.initPromise !== null) return this.initPromise;
1053
1306
  let n = async () => {
1054
- if (t != null) return new z({
1307
+ if (t != null) return new qe({
1055
1308
  authorization_endpoint: t.authorization_endpoint,
1056
1309
  end_session_endpoint: t.end_session_endpoint,
1057
1310
  revocation_endpoint: t.revocation_endpoint,
1058
1311
  token_endpoint: t.token_endpoint,
1059
1312
  userinfo_endpoint: t.userinfo_endpoint,
1060
1313
  check_session_iframe: t.check_session_iframe,
1061
- issuer: t.issuer
1314
+ issuer: t.issuer,
1315
+ pushed_authorization_request_endpoint: t.pushed_authorization_request_endpoint,
1316
+ require_pushed_authorization_requests: t.require_pushed_authorization_requests
1062
1317
  });
1063
1318
  let n = await $(this.configuration, this.configurationName) ? this.configuration.storage || window.sessionStorage : this.configuration.storage;
1064
- return await fe(this.getFetch())(e, this.configuration.authority_time_cache_wellknowurl_in_second ?? 3600, n, this.configuration.authority_timeout_wellknowurl_in_millisecond);
1319
+ return await we(this.getFetch())(e, this.configuration.authority_time_cache_wellknowurl_in_second ?? 3600, n, this.configuration.authority_timeout_wellknowurl_in_millisecond);
1065
1320
  };
1066
1321
  return this.initPromise = n(), this.initPromise.finally(() => {
1067
1322
  this.initPromise = null;
1068
1323
  });
1069
1324
  }
1070
1325
  async tryKeepExistingSessionAsync() {
1071
- return this.tryKeepExistingSessionPromise === null ? (this.tryKeepExistingSessionPromise = se(this), this.tryKeepExistingSessionPromise.finally(() => {
1326
+ return this.tryKeepExistingSessionPromise === null ? (this.tryKeepExistingSessionPromise = ge(this), this.tryKeepExistingSessionPromise.finally(() => {
1072
1327
  this.tryKeepExistingSessionPromise = null;
1073
1328
  })) : this.tryKeepExistingSessionPromise;
1074
1329
  }
1075
1330
  async startCheckSessionAsync(e, t, n, r = !1) {
1076
- await d(this, B, this.configuration)(e, t, n, r);
1331
+ await C(this, V, this.configuration)(e, t, n, r);
1077
1332
  }
1078
1333
  async loginAsync(e = void 0, t = null, n = !1, r = void 0, i = !1) {
1079
- return this.logoutPromise && await this.logoutPromise, this.loginPromise === null ? (i ? this.loginPromise = u(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(t, r) : this.loginPromise = be(this.configurationName, this.configuration, this.publishEvent.bind(this), this.initAsync.bind(this), this.location)(e, t, n, r), this.loginPromise.finally(() => {
1334
+ return this.logoutPromise && await this.logoutPromise, this.loginPromise === null ? (i ? this.loginPromise = S(window, this.configurationName, this.configuration, this.publishEvent.bind(this), this)(t, r) : this.loginPromise = Fe(this.configurationName, this.configuration, this.publishEvent.bind(this), this.initAsync.bind(this), this.location, this.getFetch)(e, t, n, r), this.loginPromise.finally(() => {
1080
1335
  this.loginPromise = null;
1081
1336
  })) : this.loginPromise;
1082
1337
  }
1083
1338
  async loginCallbackAsync(e = !1) {
1084
1339
  if (this.loginCallbackPromise !== null) return this.loginCallbackPromise;
1085
1340
  let n = async () => {
1086
- let n = await xe(this)(e), r = n.tokens;
1341
+ let n = await Ie(this)(e), r = n.tokens;
1087
1342
  return this.tokens = r, await $(this.configuration, this.configurationName) || i(this.configurationName, this.configuration.storage, this.configuration.login_state_storage ?? this.configuration.storage).setTokens(r), this.publishEvent(t.eventNames.token_acquired, r), this.configuration.preload_user_info && await this.userInfoAsync(), {
1088
1343
  parsedTokens: r,
1089
1344
  state: n.state,
@@ -1098,34 +1353,49 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1098
1353
  }
1099
1354
  async generateDemonstrationOfProofOfPossessionAsync(e, t, n, r = {}) {
1100
1355
  let a = this.configuration, o = {
1101
- ath: await te(e),
1356
+ ath: await ue(e),
1102
1357
  ...r
1103
1358
  };
1104
- if (await $(a, this.configurationName)) return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${Ye(this.configurationName)}`;
1359
+ if (await $(a, this.configurationName)) return `DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${mt(this.configurationName)}`;
1105
1360
  let s = i(this.configurationName, a.storage, a.login_state_storage ?? a.storage), c = await s.getDemonstratingProofOfPossessionJwkAsync(), l = s.getDemonstratingProofOfPossessionNonce();
1106
- return l && (o.nonce = l), await ee(window)(a.demonstrating_proof_of_possession_configuration)(c, n, t, o);
1361
+ return l && (o.nonce = l), await ie(window)(a.demonstrating_proof_of_possession_configuration)(c, n, t, o);
1107
1362
  }
1108
1363
  loginCallbackWithAutoTokensRenewAsync() {
1109
- return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise = je(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
1364
+ return this.loginCallbackWithAutoTokensRenewPromise === null ? (this.loginCallbackWithAutoTokensRenewPromise = Ye(this), this.loginCallbackWithAutoTokensRenewPromise.finally(() => {
1110
1365
  this.loginCallbackWithAutoTokensRenewPromise = null;
1111
1366
  })) : this.loginCallbackWithAutoTokensRenewPromise;
1112
1367
  }
1113
1368
  userInfoAsync(e = !1, t = !1) {
1114
- return this.userInfoPromise === null ? (this.userInfoPromise = Oe(this)(e, t), this.userInfoPromise.finally(() => {
1369
+ return this.userInfoPromise === null ? (this.userInfoPromise = Ge(this)(e, t), this.userInfoPromise.finally(() => {
1115
1370
  this.userInfoPromise = null;
1116
1371
  })) : this.userInfoPromise;
1117
1372
  }
1118
- async renewTokensAsync(e = null, t = null) {
1373
+ async renewTokensResultAsync(e = null, t = null) {
1119
1374
  if (this.renewTokensPromise !== null) return this.renewTokensPromise;
1120
- if (this.timeoutId) return c.clearTimeout(this.timeoutId), this.renewTokensPromise = Pe(this, !0, e, t), this.renewTokensPromise.finally(() => {
1121
- this.renewTokensPromise = null;
1375
+ if (!this.timeoutId) return null;
1376
+ b.clearTimeout(this.timeoutId);
1377
+ let n = Ze(this, !0, e, t);
1378
+ return this.renewTokensPromise = n, n.finally(() => {
1379
+ this.renewTokensPromise === n && (this.renewTokensPromise = null);
1122
1380
  });
1123
1381
  }
1382
+ async renewTokensAsync(e = null, t = null) {
1383
+ return (await this.renewTokensResultAsync(e, t))?.tokens;
1384
+ }
1385
+ async renewTokensOrThrowAsync(e = null, t = null) {
1386
+ let n = await this.renewTokensResultAsync(e, t);
1387
+ if (n?.error) throw n.error;
1388
+ if (!n?.tokens) throw new d(c.TOKEN_REQUEST_FAILED, "Token renewal failed", {
1389
+ phase: "refresh",
1390
+ retryable: !1
1391
+ });
1392
+ return n.tokens;
1393
+ }
1124
1394
  async destroyAsync(e) {
1125
- return await we(this)(e);
1395
+ return await Be(this)(e);
1126
1396
  }
1127
1397
  async clearSessionAsync() {
1128
- return this.clearSessionPromise ? this.clearSessionPromise : (this.clearSessionPromise = L(this, B)(), this.clearSessionPromise.finally(() => {
1398
+ return this.clearSessionPromise ? this.clearSessionPromise : (this.clearSessionPromise = Ve(this, V)(), this.clearSessionPromise.finally(() => {
1129
1399
  this.clearSessionPromise = null;
1130
1400
  }));
1131
1401
  }
@@ -1142,36 +1412,55 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
1142
1412
  }));
1143
1413
  }
1144
1414
  async logoutAsync(e = void 0, t = null) {
1145
- return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = Ee(this, B, this.getFetch(), console, this.location)(e, t), this.logoutPromise.finally(() => {
1415
+ return this.logoutPromise ? this.logoutPromise : (this.logoutPromise = Ue(this, V, this.getFetch(), console, this.location)(e, t), this.logoutPromise.finally(() => {
1146
1416
  this.logoutPromise = null;
1147
1417
  }));
1148
1418
  }
1419
+ }, U = (e, t) => {
1420
+ let n = t?.oauthError === "use_dpop_nonce" ? c.DPOP_NONCE_REQUIRED : c.TOKEN_REQUEST_FAILED;
1421
+ return new d(n, e, {
1422
+ phase: "refresh",
1423
+ retryable: n === c.DPOP_NONCE_REQUIRED || p(t?.status),
1424
+ status: t?.status,
1425
+ oauthError: t?.oauthError,
1426
+ oauthErrorDescription: t?.oauthErrorDescription
1427
+ });
1149
1428
  };
1150
- //#endregion
1151
- //#region src/renewTokens.ts
1152
- async function Ne(e, t, n, r = null) {
1153
- let { tokens: a, status: o } = await W(e)((t) => {
1429
+ async function Xe(e, t, n, r = null) {
1430
+ let a = await K(e)((t) => {
1154
1431
  e.tokens = t;
1155
- }, 0, 0, t, n, r);
1156
- return await $(e.configuration, e.configurationName) || i(e.configurationName, e.configuration.storage, e.configuration.login_state_storage ?? e.configuration.storage).setTokens(e.tokens), e.tokens ? a : (await e.destroyAsync(o), null);
1432
+ }, 0, 0, t, n, r), { tokens: o, status: s } = a;
1433
+ return await $(e.configuration, e.configurationName) || i(e.configurationName, e.configuration.storage, e.configuration.login_state_storage ?? e.configuration.storage).setTokens(e.tokens), e.tokens ? {
1434
+ ...a,
1435
+ tokens: o
1436
+ } : (await e.destroyAsync(s), {
1437
+ ...a,
1438
+ tokens: null
1439
+ });
1157
1440
  }
1158
- async function Pe(e, t = !1, n = null, r = null) {
1441
+ async function Ze(e, t = !1, n = null, r = null) {
1159
1442
  let i = e.configuration, a = `${i.client_id}_${e.configurationName}_${i.authority}`, o, s = await $(e.configuration, e.configurationName);
1160
- if (i?.storage === window?.sessionStorage && !s || !navigator.locks) o = await Ne(e, t, n, r);
1443
+ if (i?.storage === window?.sessionStorage && !s || !navigator.locks) o = await Xe(e, t, n, r);
1161
1444
  else {
1162
1445
  let i = "retry";
1163
- for (; i === "retry";) i = await navigator.locks.request(a, { ifAvailable: !0 }, async (i) => i ? await Ne(e, t, n, r) : (e.publishEvent(V.eventNames.syncTokensAsync_lock_not_available, { lock: "lock not available" }), "retry"));
1446
+ for (; i === "retry";) i = await navigator.locks.request(a, { ifAvailable: !0 }, async (i) => i ? await Xe(e, t, n, r) : (e.publishEvent(H.eventNames.syncTokensAsync_lock_not_available, { lock: "lock not available" }), "retry"));
1164
1447
  o = i;
1165
1448
  }
1166
- return o ? (e.timeoutId &&= H(e, e.tokens.expiresAt, n, r), e.tokens) : null;
1449
+ return o.tokens ? (e.timeoutId &&= W(e, e.tokens.expiresAt, n, r), {
1450
+ ...o,
1451
+ tokens: e.tokens
1452
+ }) : o;
1453
+ }
1454
+ async function Qe(e, t = !1, n = null, r = null) {
1455
+ return (await Ze(e, t, n, r)).tokens;
1167
1456
  }
1168
- var H = (e, t, n = null, r = null) => {
1457
+ var W = (e, t, n = null, r = null) => {
1169
1458
  let i = e.configuration.refresh_time_before_tokens_expiration_in_second;
1170
- return e.timeoutId && c.clearTimeout(e.timeoutId), c.setTimeout(async () => {
1171
- let a = { timeLeft: K(i, t) };
1172
- e.publishEvent(V.eventNames.token_timer, a), await Pe(e, !1, n, r);
1459
+ return e.timeoutId && b.clearTimeout(e.timeoutId), b.setTimeout(async () => {
1460
+ let a = { timeLeft: q(i, t) };
1461
+ e.publishEvent(H.eventNames.token_timer, a), await Qe(e, !1, n, r);
1173
1462
  }, 1e3);
1174
- }, U = {
1463
+ }, G = {
1175
1464
  FORCE_REFRESH: "FORCE_REFRESH",
1176
1465
  SESSION_LOST: "SESSION_LOST",
1177
1466
  NOT_CONNECTED: "NOT_CONNECTED",
@@ -1181,11 +1470,11 @@ var H = (e, t, n = null, r = null) => {
1181
1470
  LOGOUT_FROM_ANOTHER_TAB: "LOGOUT_FROM_ANOTHER_TAB",
1182
1471
  REQUIRE_SYNC_TOKENS: "REQUIRE_SYNC_TOKENS",
1183
1472
  TOKENS_INVALID: "TOKENS_INVALID"
1184
- }, Fe = (e) => async (t, n, r, a = !1) => {
1473
+ }, $e = (e) => async (t, n, r, a = !1) => {
1185
1474
  let o = { nonce: null };
1186
1475
  if (!r) return {
1187
1476
  tokens: null,
1188
- status: U.NOT_CONNECTED,
1477
+ status: G.NOT_CONNECTED,
1189
1478
  nonce: o
1190
1479
  };
1191
1480
  let s, c = await e.initAsync(t.authority, t.authority_configuration), l = await $(t, n);
@@ -1193,39 +1482,39 @@ var H = (e, t, n = null, r = null) => {
1193
1482
  let { status: e, tokens: n } = await l.initAsync(c, "syncTokensAsync", t);
1194
1483
  if (e === "LOGGED_OUT") return {
1195
1484
  tokens: null,
1196
- status: U.LOGOUT_FROM_ANOTHER_TAB,
1485
+ status: G.LOGOUT_FROM_ANOTHER_TAB,
1197
1486
  nonce: o
1198
1487
  };
1199
1488
  if (e === "SESSIONS_LOST") return {
1200
1489
  tokens: null,
1201
- status: U.SESSION_LOST,
1490
+ status: G.SESSION_LOST,
1202
1491
  nonce: o
1203
1492
  };
1204
1493
  if (!e || !n) return {
1205
1494
  tokens: null,
1206
- status: U.REQUIRE_SYNC_TOKENS,
1495
+ status: G.REQUIRE_SYNC_TOKENS,
1207
1496
  nonce: o
1208
1497
  };
1209
1498
  if (n.issuedAt !== r.issuedAt) return {
1210
1499
  tokens: n,
1211
- status: K(t.refresh_time_before_tokens_expiration_in_second, n.expiresAt) > 0 ? U.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : U.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
1500
+ status: q(t.refresh_time_before_tokens_expiration_in_second, n.expiresAt) > 0 ? G.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : G.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
1212
1501
  nonce: await l.getNonceAsync()
1213
1502
  };
1214
1503
  s = await l.getNonceAsync();
1215
1504
  } else {
1216
1505
  let a = i(n, t.storage ?? sessionStorage, t.login_state_storage ?? t.storage ?? sessionStorage), c = await a.initAsync(), { tokens: l } = c, { status: u } = c;
1217
- if (l &&= Ve(l, e.tokens, t.token_renew_mode), !l) return {
1506
+ if (l &&= ot(l, e.tokens, t.token_renew_mode), !l) return {
1218
1507
  tokens: null,
1219
- status: U.LOGOUT_FROM_ANOTHER_TAB,
1508
+ status: G.LOGOUT_FROM_ANOTHER_TAB,
1220
1509
  nonce: o
1221
1510
  };
1222
1511
  if (u === "SESSIONS_LOST") return {
1223
1512
  tokens: null,
1224
- status: U.SESSION_LOST,
1513
+ status: G.SESSION_LOST,
1225
1514
  nonce: o
1226
1515
  };
1227
1516
  if (l.issuedAt !== r.issuedAt) {
1228
- let e = K(t.refresh_time_before_tokens_expiration_in_second, l.expiresAt) > 0 ? U.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : U.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, n = await a.getNonceAsync();
1517
+ let e = q(t.refresh_time_before_tokens_expiration_in_second, l.expiresAt) > 0 ? G.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID : G.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID, n = await a.getNonceAsync();
1229
1518
  return {
1230
1519
  tokens: l,
1231
1520
  status: e,
@@ -1234,7 +1523,7 @@ var H = (e, t, n = null, r = null) => {
1234
1523
  }
1235
1524
  s = await a.getNonceAsync();
1236
1525
  }
1237
- let u = K(t.refresh_time_before_tokens_expiration_in_second, r.expiresAt) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
1526
+ let u = q(t.refresh_time_before_tokens_expiration_in_second, r.expiresAt) > 0 ? "TOKENS_VALID" : "TOKENS_INVALID";
1238
1527
  return a ? {
1239
1528
  tokens: r,
1240
1529
  status: "FORCE_REFRESH",
@@ -1244,157 +1533,231 @@ var H = (e, t, n = null, r = null) => {
1244
1533
  status: u,
1245
1534
  nonce: s
1246
1535
  };
1247
- }, W = (t) => async (n, r = 0, a = 0, o = !1, s = null, c = null) => {
1536
+ }, K = (t) => async (n, r = 0, a = 0, o = !1, s = null, l = null, u = null) => {
1248
1537
  if (!navigator.onLine && document.hidden) return {
1249
1538
  tokens: t.tokens,
1250
1539
  status: "GIVE_UP"
1251
1540
  };
1252
- let u = 6, d = o ? 2 : 5;
1253
- for (; !navigator.onLine && u > 0;) await J({ milliseconds: 1e3 }), u--, t.publishEvent(e.refreshTokensAsync, { message: `wait because navigator is offline try ${u}` });
1254
- let f = document.hidden, p = f ? r : r + 1, m = f ? a + 1 : a;
1255
- if (r >= d || a >= 5) return n(null), t.publishEvent(e.refreshTokensAsync_error, { message: "refresh token" }), {
1256
- tokens: null,
1257
- status: "SESSION_LOST"
1258
- };
1541
+ let p = 6, m = o ? 2 : 5;
1542
+ for (; !navigator.onLine && p > 0;) await Y({ milliseconds: 1e3 }), p--, t.publishEvent(e.refreshTokensAsync, { message: `wait because navigator is offline try ${p}` });
1543
+ let h = document.hidden, v = h ? r : r + 1, y = h ? a + 1 : a;
1544
+ if (r >= m || a >= 5) {
1545
+ n(null);
1546
+ let r = u ?? U("refresh token");
1547
+ return t.publishEvent(e.refreshTokensAsync_error, {
1548
+ message: "refresh token",
1549
+ error: r
1550
+ }), {
1551
+ tokens: null,
1552
+ status: "SESSION_LOST",
1553
+ error: r
1554
+ };
1555
+ }
1259
1556
  s ||= {};
1260
- let h = t.configuration, g = (e, n = null, r = null) => l(t.configurationName, t.configuration, t.publishEvent.bind(t))(e, n, r), _ = async () => {
1557
+ let b = t.configuration, S = (e, n = null, r = null) => x(t.configurationName, t.configuration, t.publishEvent.bind(t), "refresh")(e, n, r), C = async () => {
1261
1558
  try {
1262
- let r, a = await $(h, t.configurationName);
1263
- r = a ? a.getLoginParams() : i(t.configurationName, h.storage, h.login_state_storage ?? h.storage).getLoginParams();
1559
+ let r, a = await $(b, t.configurationName);
1560
+ r = a ? a.getLoginParams() : i(t.configurationName, b.storage, b.login_state_storage ?? b.storage).getLoginParams();
1264
1561
  let o = {};
1265
1562
  if (r && r.extras) for (let [e, t] of Object.entries(r.extras)) t != null && (o[e] = t);
1266
1563
  if (s) for (let [e, t] of Object.entries(s)) t != null && (o[e] = t);
1267
- o.prompt = "none", c && (o.scope = c);
1268
- let l = await g(o);
1269
- return l ? l.error ? (n(null), t.publishEvent(e.refreshTokensAsync_error, { message: "refresh token silent" }), {
1270
- tokens: null,
1271
- status: "SESSION_LOST"
1272
- }) : (n(l.tokens), t.publishEvent(V.eventNames.token_renewed, {}), {
1273
- tokens: l.tokens,
1564
+ o.prompt = "none", l && (o.scope = l);
1565
+ let u = await S(o);
1566
+ if (!u) {
1567
+ n(null);
1568
+ let r = U("refresh token silent not active");
1569
+ return t.publishEvent(e.refreshTokensAsync_error, {
1570
+ message: "refresh token silent not active",
1571
+ error: r
1572
+ }), {
1573
+ tokens: null,
1574
+ status: "SESSION_LOST",
1575
+ error: r
1576
+ };
1577
+ }
1578
+ if (u.error) {
1579
+ n(null);
1580
+ let r = u.oidcError ?? new d(c.OAUTH_ERROR, "refresh token silent", {
1581
+ phase: "refresh",
1582
+ retryable: !1,
1583
+ oauthError: u.error
1584
+ });
1585
+ return t.publishEvent(e.refreshTokensAsync_error, {
1586
+ message: "refresh token silent",
1587
+ error: r
1588
+ }), {
1589
+ tokens: null,
1590
+ status: "SESSION_LOST",
1591
+ error: r
1592
+ };
1593
+ }
1594
+ return n(u.tokens), t.publishEvent(H.eventNames.token_renewed, {}), {
1595
+ tokens: u.tokens,
1274
1596
  status: "LOGGED"
1275
- }) : (n(null), t.publishEvent(e.refreshTokensAsync_error, { message: "refresh token silent not active" }), {
1276
- tokens: null,
1277
- status: "SESSION_LOST"
1278
- });
1597
+ };
1279
1598
  } catch (r) {
1280
- return console.error(r), t.publishEvent(e.refreshTokensAsync_silent_error, {
1599
+ let i = f(r) || !_(r) ? r : g(r, "refresh");
1600
+ return console.error(i), t.publishEvent(e.refreshTokensAsync_silent_error, {
1281
1601
  message: "exceptionSilent",
1282
- exception: r.message
1283
- }), await W(t)(n, p, m, o, s, c);
1602
+ exception: i.message,
1603
+ error: f(i) ? i : void 0
1604
+ }), await K(t)(n, v, y, o, s, l, f(i) ? i : u);
1284
1605
  }
1285
1606
  };
1286
1607
  try {
1287
- let { status: l, tokens: u, nonce: d } = await Fe(t)(h, t.configurationName, t.tokens, o);
1288
- switch (l) {
1289
- case U.SESSION_LOST: return n(null), t.publishEvent(e.refreshTokensAsync_error, { message: "refresh token session lost" }), {
1290
- tokens: null,
1291
- status: "SESSION_LOST"
1292
- };
1293
- case U.NOT_CONNECTED: return n(null), {
1608
+ let { status: f, tokens: p, nonce: m } = await $e(t)(b, t.configurationName, t.tokens, o);
1609
+ switch (f) {
1610
+ case G.SESSION_LOST:
1611
+ n(null);
1612
+ {
1613
+ let n = u ?? U("refresh token session lost");
1614
+ return t.publishEvent(e.refreshTokensAsync_error, {
1615
+ message: "refresh token session lost",
1616
+ error: n
1617
+ }), {
1618
+ tokens: null,
1619
+ status: "SESSION_LOST",
1620
+ error: n
1621
+ };
1622
+ }
1623
+ case G.NOT_CONNECTED: return n(null), {
1294
1624
  tokens: null,
1295
1625
  status: null
1296
1626
  };
1297
- case U.TOKENS_VALID: return n(u), {
1298
- tokens: u,
1627
+ case G.TOKENS_VALID: return n(p), {
1628
+ tokens: p,
1299
1629
  status: "LOGGED_IN"
1300
1630
  };
1301
- case U.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID: return n(u), t.publishEvent(V.eventNames.token_renewed, { reason: "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" }), {
1302
- tokens: u,
1631
+ case G.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID: return n(p), t.publishEvent(H.eventNames.token_renewed, { reason: "TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID" }), {
1632
+ tokens: p,
1303
1633
  status: "LOGGED_IN"
1304
1634
  };
1305
- case U.LOGOUT_FROM_ANOTHER_TAB: return n(null), t.publishEvent(e.logout_from_another_tab, { status: "session syncTokensAsync" }), {
1635
+ case G.LOGOUT_FROM_ANOTHER_TAB: return n(null), t.publishEvent(e.logout_from_another_tab, { status: "session syncTokensAsync" }), {
1306
1636
  tokens: null,
1307
1637
  status: "LOGGED_OUT"
1308
1638
  };
1309
- case U.REQUIRE_SYNC_TOKENS: return h.token_automatic_renew_mode == R.AutomaticOnlyWhenFetchExecuted && !o ? (t.publishEvent(e.tokensInvalidAndWaitingActionsToRefresh, {}), {
1639
+ case G.REQUIRE_SYNC_TOKENS: return b.token_automatic_renew_mode == B.AutomaticOnlyWhenFetchExecuted && !o ? (t.publishEvent(e.tokensInvalidAndWaitingActionsToRefresh, {}), {
1310
1640
  tokens: t.tokens,
1311
1641
  status: "GIVE_UP"
1312
- }) : (t.publishEvent(e.refreshTokensAsync_begin, { tryNumber: r }), await _());
1642
+ }) : (t.publishEvent(e.refreshTokensAsync_begin, { tryNumber: r }), await C());
1313
1643
  default: {
1314
- if (h.token_automatic_renew_mode == R.AutomaticOnlyWhenFetchExecuted && U.FORCE_REFRESH !== l) return t.publishEvent(e.tokensInvalidAndWaitingActionsToRefresh, {}), {
1644
+ if (b.token_automatic_renew_mode == B.AutomaticOnlyWhenFetchExecuted && G.FORCE_REFRESH !== f) return t.publishEvent(e.tokensInvalidAndWaitingActionsToRefresh, {}), {
1315
1645
  tokens: t.tokens,
1316
1646
  status: "GIVE_UP"
1317
1647
  };
1318
1648
  if (t.publishEvent(e.refreshTokensAsync_begin, {
1319
- refreshToken: u.refreshToken,
1320
- status: l,
1649
+ refreshToken: p.refreshToken,
1650
+ status: f,
1321
1651
  tryNumber: r,
1322
1652
  backgroundTry: a
1323
- }), !u.refreshToken) return await _();
1324
- let f = h.client_id, g = h.redirect_uri, v = h.authority, y = { ...h.token_request_extras ? h.token_request_extras : {} };
1325
- for (let [e, t] of Object.entries(s)) e.endsWith(":token_request") && (y[e.replace(":token_request", "")] = t);
1653
+ }), !p.refreshToken) return await C();
1654
+ let u = b.client_id, h = b.redirect_uri, g = b.authority, _ = { ...b.token_request_extras ? b.token_request_extras : {} };
1655
+ for (let [e, t] of Object.entries(s)) e.endsWith(":token_request") && (_[e.replace(":token_request", "")] = t);
1326
1656
  return await (async () => {
1327
1657
  let r = {
1328
- client_id: f,
1329
- redirect_uri: g,
1658
+ client_id: u,
1659
+ redirect_uri: h,
1330
1660
  grant_type: "refresh_token",
1331
- refresh_token: u.refreshToken
1332
- }, a = await t.initAsync(v, h.authority_configuration), l = document.hidden ? 1e4 : 3e4 * 10, _ = a.tokenEndpoint, b = {};
1333
- h.demonstrating_proof_of_possession && (b.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(u.accessToken, _, "POST"));
1334
- let x = await me(t.getFetch())(_, r, y, u, b, h.token_renew_mode, l);
1335
- if (x.success) {
1336
- if (!d || !d.nonce) return n(null), t.publishEvent(e.refreshTokensAsync_error, { message: "refresh token: nonce missing from storage" }), {
1337
- tokens: null,
1338
- status: "SESSION_LOST"
1339
- };
1340
- let { isValid: r, reason: o } = Ge(x.data, d.nonce, a);
1341
- if (!r) return n(null), t.publishEvent(e.refreshTokensAsync_error, { message: `refresh token return not valid tokens, reason: ${o}` }), {
1342
- tokens: null,
1343
- status: "SESSION_LOST"
1344
- };
1345
- if (n(x.data), x.demonstratingProofOfPossessionNonce) {
1346
- let e = await $(h, t.configurationName);
1347
- e ? await e.setDemonstratingProofOfPossessionNonce(x.demonstratingProofOfPossessionNonce) : await i(t.configurationName, h.storage, h.login_state_storage ?? h.storage).setDemonstratingProofOfPossessionNonce(x.demonstratingProofOfPossessionNonce);
1661
+ refresh_token: p.refreshToken
1662
+ }, a = await t.initAsync(g, b.authority_configuration), f = document.hidden ? 1e4 : 3e4 * 10, x = a.tokenEndpoint, S = {};
1663
+ b.demonstrating_proof_of_possession && (S.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(p.accessToken, x, "POST"));
1664
+ let C = await ke(t.getFetch())(x, r, _, p, S, b.token_renew_mode, f);
1665
+ if (!C.success && C.oauthError === "use_dpop_nonce" && C.demonstratingProofOfPossessionNonce && b.demonstrating_proof_of_possession) {
1666
+ let e = await $(b, t.configurationName);
1667
+ e ? await e.setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce) : await i(t.configurationName, b.storage, b.login_state_storage ?? b.storage).setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce), S.DPoP = await t.generateDemonstrationOfProofOfPossessionAsync(p.accessToken, x, "POST"), C = await ke(t.getFetch())(x, r, _, p, S, b.token_renew_mode, f);
1668
+ }
1669
+ if (C.success) {
1670
+ if (!m || !m.nonce) {
1671
+ n(null);
1672
+ let r = new N(M.NONCE_MISSING, "refresh token: nonce missing from storage", "refresh");
1673
+ return t.publishEvent(e.refreshTokensAsync_error, {
1674
+ message: "refresh token: nonce missing from storage",
1675
+ error: r
1676
+ }), {
1677
+ tokens: null,
1678
+ status: "SESSION_LOST",
1679
+ error: r
1680
+ };
1348
1681
  }
1349
- return t.publishEvent(e.refreshTokensAsync_end, { success: x.success }), t.publishEvent(V.eventNames.token_renewed, { reason: "REFRESH_TOKEN" }), {
1350
- tokens: x.data,
1682
+ let { isValid: r, reason: o } = ut(C.data, m.nonce, a);
1683
+ if (!r) {
1684
+ n(null);
1685
+ let r = new d(o.startsWith("Nonce does not match") ? c.INVALID_NONCE : c.TOKEN_REQUEST_FAILED, `refresh token return not valid tokens, reason: ${o}`, {
1686
+ phase: "refresh",
1687
+ retryable: !1
1688
+ });
1689
+ return t.publishEvent(e.refreshTokensAsync_error, {
1690
+ message: `refresh token return not valid tokens, reason: ${o}`,
1691
+ error: r
1692
+ }), {
1693
+ tokens: null,
1694
+ status: "SESSION_LOST",
1695
+ error: r
1696
+ };
1697
+ }
1698
+ if (n(C.data), C.demonstratingProofOfPossessionNonce) {
1699
+ let e = await $(b, t.configurationName);
1700
+ e ? await e.setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce) : await i(t.configurationName, b.storage, b.login_state_storage ?? b.storage).setDemonstratingProofOfPossessionNonce(C.demonstratingProofOfPossessionNonce);
1701
+ }
1702
+ return t.publishEvent(e.refreshTokensAsync_end, { success: C.success }), t.publishEvent(H.eventNames.token_renewed, { reason: "REFRESH_TOKEN" }), {
1703
+ tokens: C.data,
1351
1704
  status: "LOGGED_IN"
1352
1705
  };
1353
- } else return t.publishEvent(e.refreshTokensAsync_silent_error, {
1354
- message: "bad request",
1355
- tokenResponse: x
1356
- }), x.status >= 400 && x.status < 500 ? (n(null), t.publishEvent(e.refreshTokensAsync_error, { message: `session lost: ${x.status}` }), {
1357
- tokens: null,
1358
- status: "SESSION_LOST"
1359
- }) : await W(t)(n, p, m, o, s, c);
1706
+ } else {
1707
+ let r = U("Token request failed", C);
1708
+ return t.publishEvent(e.refreshTokensAsync_silent_error, {
1709
+ message: "bad request",
1710
+ tokenResponse: C,
1711
+ error: r
1712
+ }), C.status >= 400 && C.status < 500 ? (n(null), t.publishEvent(e.refreshTokensAsync_error, {
1713
+ message: `session lost: ${C.status}`,
1714
+ error: r
1715
+ }), {
1716
+ tokens: null,
1717
+ status: "SESSION_LOST",
1718
+ error: r
1719
+ }) : await K(t)(n, v, y, o, s, l, r);
1720
+ }
1360
1721
  })();
1361
1722
  }
1362
1723
  }
1363
1724
  } catch (r) {
1364
- return console.error(r), t.publishEvent(e.refreshTokensAsync_silent_error, {
1725
+ let i = f(r) || !_(r) ? r : g(r, "refresh");
1726
+ return console.error(i), t.publishEvent(e.refreshTokensAsync_silent_error, {
1365
1727
  message: "exception",
1366
- exception: r.message
1728
+ exception: i.message,
1729
+ error: f(i) ? i : void 0
1367
1730
  }), new Promise((e, r) => {
1368
1731
  setTimeout(() => {
1369
- W(t)(n, p, m, o, s, c).then(e).catch(r);
1732
+ K(t)(n, v, y, o, s, l, f(i) ? i : u).then(e).catch(r);
1370
1733
  }, 1e3);
1371
1734
  });
1372
1735
  }
1373
- }, Ie = (e) => decodeURIComponent(Array.prototype.map.call(atob(e), (e) => "%" + ("00" + e.charCodeAt(0).toString(16)).slice(-2)).join("")), Le = (e) => JSON.parse(Ie(e.replaceAll(/-/g, "+").replaceAll(/_/g, "/"))), Re = (e) => {
1736
+ }, et = (e) => decodeURIComponent(Array.prototype.map.call(atob(e), (e) => "%" + ("00" + e.charCodeAt(0).toString(16)).slice(-2)).join("")), tt = (e) => JSON.parse(et(e.replaceAll(/-/g, "+").replaceAll(/_/g, "/"))), nt = (e) => {
1374
1737
  try {
1375
- return e && ze(e, ".") === 2 ? Le(e.split(".")[1]) : null;
1738
+ return e && rt(e, ".") === 2 ? tt(e.split(".")[1]) : null;
1376
1739
  } catch (e) {
1377
1740
  console.warn(e);
1378
1741
  }
1379
1742
  return null;
1380
- }, ze = (e, t) => e.split(t).length - 1, G = {
1743
+ }, rt = (e, t) => e.split(t).length - 1, it = {
1381
1744
  access_token_or_id_token_invalid: "access_token_or_id_token_invalid",
1382
1745
  access_token_invalid: "access_token_invalid",
1383
1746
  id_token_invalid: "id_token_invalid"
1384
1747
  };
1385
- function Be(e, t, n) {
1748
+ function at(e, t, n) {
1386
1749
  return e.issuedAt ? typeof e.issuedAt == "string" ? parseInt(e.issuedAt, 10) : e.issuedAt : t && t.iat ? t.iat : n && n.iat ? n.iat : (/* @__PURE__ */ new Date()).getTime() / 1e3;
1387
1750
  }
1388
- var Ve = (e, t = null, n) => {
1751
+ var ot = (e, t = null, n) => {
1389
1752
  if (!e) return null;
1390
1753
  let r, i = typeof e.expiresIn == "string" ? parseInt(e.expiresIn, 10) : e.expiresIn;
1391
- r = e.accessTokenPayload === void 0 ? Re(e.accessToken) : e.accessTokenPayload;
1754
+ r = e.accessTokenPayload === void 0 ? nt(e.accessToken) : e.accessTokenPayload;
1392
1755
  let a;
1393
1756
  a = t != null && "idToken" in t && !("idToken" in e) ? t.idToken : e.idToken;
1394
- let o = e.idTokenPayload ? e.idTokenPayload : Re(a), s = o && o.exp ? o.exp : Number.MAX_VALUE, c = r && r.exp ? r.exp : e.issuedAt + i;
1395
- e.issuedAt = Be(e, r, o);
1757
+ let o = e.idTokenPayload ? e.idTokenPayload : nt(a), s = o && o.exp ? o.exp : Number.MAX_VALUE, c = r && r.exp ? r.exp : e.issuedAt + i;
1758
+ e.issuedAt = at(e, r, o);
1396
1759
  let l;
1397
- l = e.expiresAt ? e.expiresAt : n === G.access_token_invalid ? c : n === G.id_token_invalid || s < c ? s : c;
1760
+ l = e.expiresAt ? e.expiresAt : n === it.access_token_invalid ? c : n === it.id_token_invalid || s < c ? s : c;
1398
1761
  let u = {
1399
1762
  ...e,
1400
1763
  idTokenPayload: o,
@@ -1410,7 +1773,7 @@ var Ve = (e, t = null, n) => {
1410
1773
  };
1411
1774
  }
1412
1775
  return u;
1413
- }, He = (e, t, n) => {
1776
+ }, st = (e, t, n) => {
1414
1777
  if (!e) return null;
1415
1778
  e.issued_at ||= (/* @__PURE__ */ new Date()).getTime() / 1e3;
1416
1779
  let r = {
@@ -1421,29 +1784,29 @@ var Ve = (e, t = null, n) => {
1421
1784
  tokenType: e.token_type,
1422
1785
  issuedAt: e.issued_at
1423
1786
  };
1424
- return "refresh_token" in e && (r.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (r.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (r.idTokenPayload = e.idTokenPayload), Ve(r, t, n);
1425
- }, K = (e, t) => {
1787
+ return "refresh_token" in e && (r.refreshToken = e.refresh_token), e.accessTokenPayload !== void 0 && (r.accessTokenPayload = e.accessTokenPayload), e.idTokenPayload !== void 0 && (r.idTokenPayload = e.idTokenPayload), ot(r, t, n);
1788
+ }, q = (e, t) => {
1426
1789
  let n = t - (/* @__PURE__ */ new Date()).getTime() / 1e3;
1427
1790
  return Math.round(n - e);
1428
- }, Ue = (e, t = 0) => e ? K(t, e.expiresAt) > 0 : !1, We = async (e, t = 200, n = 50) => {
1791
+ }, ct = (e, t = 0) => e ? q(t, e.expiresAt) > 0 : !1, lt = async (e, t = 200, n = 50) => {
1429
1792
  let r = n, i = await e.syncTokensInfoAsync();
1430
1793
  for (; [
1431
- U.REQUIRE_SYNC_TOKENS,
1432
- U.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
1433
- U.TOKENS_INVALID
1794
+ G.REQUIRE_SYNC_TOKENS,
1795
+ G.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID,
1796
+ G.TOKENS_INVALID
1434
1797
  ].includes(i) && r > 0;) {
1435
- if (e.configuration.token_automatic_renew_mode == R.AutomaticOnlyWhenFetchExecuted) {
1798
+ if (e.configuration.token_automatic_renew_mode == B.AutomaticOnlyWhenFetchExecuted) {
1436
1799
  await e.renewTokensAsync({});
1437
1800
  break;
1438
- } else await J({ milliseconds: t });
1801
+ } else await Y({ milliseconds: t });
1439
1802
  --r, i = await e.syncTokensInfoAsync();
1440
1803
  }
1441
1804
  return {
1442
- isTokensValid: Ue(e.getTokens()),
1805
+ isTokensValid: ct(e.getTokens()),
1443
1806
  tokens: e.getTokens(),
1444
1807
  numberWaited: r - n
1445
1808
  };
1446
- }, Ge = (e, t, n) => {
1809
+ }, ut = (e, t, n) => {
1447
1810
  if (e.idTokenPayload) {
1448
1811
  let r = e.idTokenPayload;
1449
1812
  if (n.issuer !== r.iss) return {
@@ -1469,98 +1832,98 @@ var Ve = (e, t = null, n) => {
1469
1832
  isValid: !0,
1470
1833
  reason: ""
1471
1834
  };
1472
- }, Ke = "7.27.19", qe = null, q, J = ({ milliseconds: e }) => new Promise((t) => c.setTimeout(t, e)), Je = (e = "/") => {
1835
+ }, dt = "7.29.2", ft = null, J, Y = ({ milliseconds: e }) => new Promise((t) => b.setTimeout(t, e)), pt = (e = "/") => {
1473
1836
  try {
1474
- q = new AbortController(), fetch(`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`, { signal: q.signal }).catch((e) => {
1837
+ J = new AbortController(), fetch(`${e}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`, { signal: J.signal }).catch((e) => {
1475
1838
  console.log(e);
1476
- }), J({ milliseconds: 150 * 1e3 }).then(() => Je(e));
1839
+ }), Y({ milliseconds: 150 * 1e3 }).then(() => pt(e));
1477
1840
  } catch (e) {
1478
1841
  console.log(e);
1479
1842
  }
1480
- }, Y = () => {
1481
- q && q.abort();
1482
- }, Ye = (e) => {
1843
+ }, X = () => {
1844
+ J && J.abort();
1845
+ }, mt = (e) => {
1483
1846
  let t = `oidc.tabId.${e}`, n = sessionStorage.getItem(t);
1484
1847
  if (n) return n;
1485
1848
  let r = globalThis.crypto.randomUUID();
1486
1849
  return sessionStorage.setItem(t, r), r;
1487
- }, Xe = (e) => navigator.serviceWorker.controller ?? e.active ?? e.waiting ?? e.installing ?? null, X = (e, t) => (n) => {
1850
+ }, ht = (e) => navigator.serviceWorker.controller ?? e.active ?? e.waiting ?? e.installing ?? null, Z = (e, t) => (n) => {
1488
1851
  let r = t?.timeoutMs ?? 5e3;
1489
1852
  return new Promise((t, i) => {
1490
- let a = Xe(e);
1853
+ let a = ht(e);
1491
1854
  if (!a) {
1492
1855
  i(/* @__PURE__ */ Error("Service worker target not available (controller/active/waiting/installing missing)"));
1493
1856
  return;
1494
1857
  }
1495
- let o = new MessageChannel(), s = null, l = () => {
1858
+ let o = new MessageChannel(), s = null, c = () => {
1496
1859
  try {
1497
- s != null && (c.clearTimeout(s), s = null), o.port1.onmessage = null, o.port1.close(), o.port2.close();
1860
+ s != null && (b.clearTimeout(s), s = null), o.port1.onmessage = null, o.port1.close(), o.port2.close();
1498
1861
  } catch (e) {
1499
1862
  console.error(e);
1500
1863
  }
1501
1864
  };
1502
- s = c.setTimeout(() => {
1503
- l(), i(/* @__PURE__ */ Error(`Service worker did not respond within ${r}ms (type=${n?.type})`));
1865
+ s = b.setTimeout(() => {
1866
+ c(), i(/* @__PURE__ */ Error(`Service worker did not respond within ${r}ms (type=${n?.type})`));
1504
1867
  }, r), o.port1.onmessage = (e) => {
1505
- l(), e?.data?.error ? i(e.data.error) : t(e.data);
1868
+ c(), e?.data?.error ? i(e.data.error) : t(e.data);
1506
1869
  };
1507
1870
  try {
1508
1871
  let e = n?.configurationName;
1509
1872
  a.postMessage({
1510
1873
  ...n,
1511
- tabId: Ye(e ?? "default")
1874
+ tabId: mt(e ?? "default")
1512
1875
  }, [o.port2]);
1513
1876
  } catch (e) {
1514
- l(), i(e);
1877
+ c(), i(e);
1515
1878
  }
1516
1879
  });
1517
- }, Ze = async (e) => navigator.serviceWorker.controller ? navigator.serviceWorker.controller : new Promise((t) => {
1880
+ }, gt = async (e) => navigator.serviceWorker.controller ? navigator.serviceWorker.controller : new Promise((t) => {
1518
1881
  let n = !1, r = () => {
1519
1882
  n || (n = !0, navigator.serviceWorker.removeEventListener("controllerchange", r), t(navigator.serviceWorker.controller ?? null));
1520
1883
  };
1521
- navigator.serviceWorker.addEventListener("controllerchange", r), c.setTimeout(() => {
1884
+ navigator.serviceWorker.addEventListener("controllerchange", r), b.setTimeout(() => {
1522
1885
  n || (n = !0, navigator.serviceWorker.removeEventListener("controllerchange", r), t(navigator.serviceWorker.controller ?? null));
1523
1886
  }, e);
1524
- }), Qe = !1, Z = !1, Q = /* @__PURE__ */ new Map(), $e = (e) => e instanceof DOMException ? e.name === "AbortError" : e?.name === "AbortError", et = "oidc.sw.controllerchange_reload_count", tt = 3, nt = () => {
1887
+ }), _t = !1, Q = !1, vt = /* @__PURE__ */ new Map(), yt = (e) => e instanceof DOMException ? e.name === "AbortError" : e?.name === "AbortError", bt = "oidc.sw.controllerchange_reload_count", xt = 3, St = () => {
1525
1888
  try {
1526
- return parseInt(sessionStorage.getItem(et) ?? "0", 10);
1889
+ return parseInt(sessionStorage.getItem(bt) ?? "0", 10);
1527
1890
  } catch {
1528
1891
  return 0;
1529
1892
  }
1530
- }, rt = () => {
1531
- let e = nt() + 1;
1893
+ }, Ct = () => {
1894
+ let e = St() + 1;
1532
1895
  try {
1533
- sessionStorage.setItem(et, String(e));
1896
+ sessionStorage.setItem(bt, String(e));
1534
1897
  } catch {}
1535
1898
  return e;
1536
- }, it = () => {
1899
+ }, wt = () => {
1537
1900
  try {
1538
- sessionStorage.removeItem(et);
1901
+ sessionStorage.removeItem(bt);
1539
1902
  } catch {}
1540
1903
  }, $ = async (e, t) => {
1541
1904
  let n = e.service_worker_relative_url;
1542
1905
  if (typeof window > "u" || typeof navigator > "u" || !navigator.serviceWorker || !n || e.service_worker_activate() === !1) return null;
1543
- let r = `${n}?v=${Ke}`, i = e.service_worker_register ? n : r;
1544
- Q.has(i) || Q.set(i, e.service_worker_register ? e.service_worker_register(n) : navigator.serviceWorker.register(r, { updateViaCache: "none" }));
1906
+ let r = `${n}?v=${dt}`, i = e.service_worker_register ? n : r;
1907
+ vt.has(i) || vt.set(i, e.service_worker_register ? e.service_worker_register(n) : navigator.serviceWorker.register(r, { updateViaCache: "none" }));
1545
1908
  let a = null;
1546
1909
  try {
1547
- a = await Q.get(i);
1910
+ a = await vt.get(i);
1548
1911
  } catch (e) {
1549
- if ($e(e)) return Q.delete(i), console.warn("oidc-client: service worker registration was aborted (likely tab shutdown or backgrounding); falling back to non–service-worker mode.", e), null;
1912
+ if (yt(e)) return vt.delete(i), console.warn("oidc-client: service worker registration was aborted (likely tab shutdown or backgrounding); falling back to non–service-worker mode.", e), null;
1550
1913
  throw e;
1551
1914
  }
1552
1915
  let o = `oidc.sw.version_mismatch_reload.${t}`, s = async (e) => {
1553
- Y(), console.log("New SW waiting – SKIP_WAITING");
1916
+ X(), console.log("New SW waiting – SKIP_WAITING");
1554
1917
  try {
1555
1918
  await new Promise((n, r) => {
1556
1919
  let i = new MessageChannel(), a = null, o = () => {
1557
1920
  try {
1558
- a != null && (c.clearTimeout(a), a = null), i.port1.onmessage = null, i.port1.close(), i.port2.close();
1921
+ a != null && (b.clearTimeout(a), a = null), i.port1.onmessage = null, i.port1.close(), i.port2.close();
1559
1922
  } catch (e) {
1560
1923
  console.error(e);
1561
1924
  }
1562
1925
  };
1563
- a = c.setTimeout(() => {
1926
+ a = b.setTimeout(() => {
1564
1927
  o(), r(/* @__PURE__ */ Error("SKIP_WAITING did not respond within 8000ms"));
1565
1928
  }, 8e3), i.port1.onmessage = (e) => {
1566
1929
  o(), e?.data?.error ? r(e.data.error) : n();
@@ -1570,7 +1933,7 @@ var Ve = (e, t = null, n) => {
1570
1933
  type: "SKIP_WAITING",
1571
1934
  configurationName: t,
1572
1935
  data: null,
1573
- tabId: Ye(t ?? "default")
1936
+ tabId: mt(t ?? "default")
1574
1937
  }, [i.port2]);
1575
1938
  } catch (e) {
1576
1939
  o(), r(e);
@@ -1579,13 +1942,13 @@ var Ve = (e, t = null, n) => {
1579
1942
  } catch (e) {
1580
1943
  console.warn("SKIP_WAITING failed", e);
1581
1944
  }
1582
- }, l = async () => {
1945
+ }, c = async () => {
1583
1946
  let e = a.waiting;
1584
1947
  e ? await s(e) : console.warn("sendSkipWaiting called but no waiting service worker found");
1585
- }, u = (e) => {
1586
- Y(), e.addEventListener("statechange", async () => {
1948
+ }, l = (e) => {
1949
+ X(), e.addEventListener("statechange", async () => {
1587
1950
  if (e.state === "installed" && navigator.serviceWorker.controller) {
1588
- if (nt() >= tt) {
1951
+ if (St() >= xt) {
1589
1952
  console.warn("SW trackInstallingWorker: skipping SKIP_WAITING because the reload budget is exhausted");
1590
1953
  return;
1591
1954
  }
@@ -1595,34 +1958,34 @@ var Ve = (e, t = null, n) => {
1595
1958
  };
1596
1959
  a.addEventListener("updatefound", () => {
1597
1960
  let e = a.installing;
1598
- e && u(e);
1599
- }), a.installing ? u(a.installing) : a.waiting && navigator.serviceWorker.controller && (nt() < tt ? l() : console.warn("SW: a waiting worker exists but reload budget is exhausted – skipping activation")), a.update().catch((e) => {
1961
+ e && l(e);
1962
+ }), a.installing ? l(a.installing) : a.waiting && navigator.serviceWorker.controller && (St() < xt ? c() : console.warn("SW: a waiting worker exists but reload budget is exhausted – skipping activation")), a.update().catch((e) => {
1600
1963
  console.error(e);
1601
1964
  });
1602
1965
  try {
1603
- await navigator.serviceWorker.ready, navigator.serviceWorker.controller || (await X(a, { timeoutMs: 8e3 })({
1966
+ await navigator.serviceWorker.ready, navigator.serviceWorker.controller || (await Z(a, { timeoutMs: 8e3 })({
1604
1967
  type: "claim",
1605
1968
  configurationName: t,
1606
1969
  data: null
1607
- }), await Ze(2e3));
1970
+ }), await gt(2e3));
1608
1971
  } catch (e) {
1609
1972
  return console.warn(`Failed init ServiceWorker ${e?.toString?.() ?? String(e)}`), null;
1610
1973
  }
1611
- Qe || (Qe = !0, navigator.serviceWorker.addEventListener("controllerchange", () => {
1612
- if (Z) return;
1613
- let e = rt();
1614
- if (e > tt) {
1974
+ _t || (_t = !0, navigator.serviceWorker.addEventListener("controllerchange", () => {
1975
+ if (Q) return;
1976
+ let e = Ct();
1977
+ if (e > xt) {
1615
1978
  console.warn(`SW controllerchange: reload budget exhausted (${e - 1} reloads). Skipping reload to avoid infinite loop.`);
1616
1979
  return;
1617
1980
  }
1618
- Z = !0, console.log("SW controller changed – reloading page"), Y(), window.location.reload();
1981
+ Q = !0, console.log("SW controller changed – reloading page"), X(), window.location.reload();
1619
1982
  }));
1620
- let d = async (e) => X(a)({
1983
+ let u = async (e) => Z(a)({
1621
1984
  type: "clear",
1622
1985
  data: { status: e },
1623
1986
  configurationName: t
1624
- }), f = async (e, n, r) => {
1625
- let i = await X(a)({
1987
+ }), d = async (e, n, r) => {
1988
+ let i = await Z(a)({
1626
1989
  type: "init",
1627
1990
  data: {
1628
1991
  oidcServerConfiguration: e,
@@ -1634,139 +1997,139 @@ var Ve = (e, t = null, n) => {
1634
1997
  },
1635
1998
  configurationName: t
1636
1999
  }), s = i.version;
1637
- if (s !== "7.27.19") {
1638
- console.warn(`Service worker ${s} version mismatch with js client version ${Ke}, unregistering and reloading`);
2000
+ if (s !== "7.29.2") {
2001
+ console.warn(`Service worker ${s} version mismatch with js client version ${dt}, unregistering and reloading`);
1639
2002
  let e = parseInt(sessionStorage.getItem(o) ?? "0", 10);
1640
2003
  if (e < 3) {
1641
- if (sessionStorage.setItem(o, String(e + 1)), a.waiting) return await l(), await J({ milliseconds: 500 }), Z || (Z = !0, window.location.reload()), new Promise(() => {});
2004
+ if (sessionStorage.setItem(o, String(e + 1)), a.waiting) return await c(), await Y({ milliseconds: 500 }), Q || (Q = !0, window.location.reload()), new Promise(() => {});
1642
2005
  {
1643
- Y();
2006
+ X();
1644
2007
  try {
1645
2008
  await a.update();
1646
2009
  } catch (e) {
1647
2010
  console.error(e);
1648
2011
  }
1649
2012
  let e = await a.unregister();
1650
- return console.log(`Service worker unregistering ${e}`), await J({ milliseconds: 500 }), Z || (Z = !0, window.location.reload()), new Promise(() => {});
2013
+ return console.log(`Service worker unregistering ${e}`), await Y({ milliseconds: 500 }), Q || (Q = !0, window.location.reload()), new Promise(() => {});
1651
2014
  }
1652
2015
  } else console.error(`Service worker version mismatch persists after ${e} attempt(s). Continuing with mismatched version.`);
1653
- } else sessionStorage.removeItem(o), it();
2016
+ } else sessionStorage.removeItem(o), wt();
1654
2017
  return {
1655
- tokens: He(i.tokens, null, r.token_renew_mode),
2018
+ tokens: st(i.tokens, null, r.token_renew_mode),
1656
2019
  status: i.status
1657
2020
  };
1658
- }, p = (e = "/") => {
1659
- qe ?? (qe = "not_null", Je(e));
1660
- }, m = (e) => X(a)({
2021
+ }, f = (e = "/") => {
2022
+ ft ?? (ft = "not_null", pt(e));
2023
+ }, p = (e) => Z(a)({
1661
2024
  type: "setSessionState",
1662
2025
  data: { sessionState: e },
1663
2026
  configurationName: t
1664
- }), h = async () => (await X(a)({
2027
+ }), m = async () => (await Z(a)({
1665
2028
  type: "getSessionState",
1666
2029
  data: null,
1667
2030
  configurationName: t
1668
- })).sessionState, g = (e) => (sessionStorage[`oidc.nonce.${t}`] = e.nonce, X(a)({
2031
+ })).sessionState, h = (e) => (sessionStorage[`oidc.nonce.${t}`] = e.nonce, Z(a)({
1669
2032
  type: "setNonce",
1670
2033
  data: { nonce: e },
1671
2034
  configurationName: t
1672
- })), _ = async (e = !0) => {
1673
- let n = (await X(a)({
2035
+ })), g = async (e = !0) => {
2036
+ let n = (await Z(a)({
1674
2037
  type: "getNonce",
1675
2038
  data: null,
1676
2039
  configurationName: t
1677
2040
  })).nonce;
1678
- return n || (n = sessionStorage[`oidc.nonce.${t}`], console.warn("nonce not found in service worker, using sessionStorage"), e && (await g(n), n = (await _(!1)).nonce)), { nonce: n };
1679
- }, v = {}, y = (e) => {
2041
+ return n || (n = sessionStorage[`oidc.nonce.${t}`], console.warn("nonce not found in service worker, using sessionStorage"), e && (await h(n), n = (await g(!1)).nonce)), { nonce: n };
2042
+ }, _ = {}, v = (e) => {
1680
2043
  if (e == null) {
1681
- delete v[t], delete localStorage[`oidc.login.${t}`];
2044
+ delete _[t], delete localStorage[`oidc.login.${t}`];
1682
2045
  return;
1683
2046
  }
1684
- v[t] = e, localStorage[`oidc.login.${t}`] = JSON.stringify(e);
1685
- }, b = () => {
1686
- if (v[t]) return v[t];
2047
+ _[t] = e, localStorage[`oidc.login.${t}`] = JSON.stringify(e);
2048
+ }, y = () => {
2049
+ if (_[t]) return _[t];
1687
2050
  let e = localStorage[`oidc.login.${t}`];
1688
2051
  if (typeof e != "string" || e === "" || e === "undefined" || e === "null") return null;
1689
2052
  try {
1690
- v[t] = JSON.parse(e);
2053
+ _[t] = JSON.parse(e);
1691
2054
  } catch {
1692
2055
  return null;
1693
2056
  }
1694
- return v[t];
2057
+ return _[t];
1695
2058
  }, x = async (e) => {
1696
- await X(a)({
2059
+ await Z(a)({
1697
2060
  type: "setDemonstratingProofOfPossessionNonce",
1698
2061
  data: { demonstratingProofOfPossessionNonce: e },
1699
2062
  configurationName: t
1700
2063
  });
1701
- }, ee = async () => (await X(a)({
2064
+ }, S = async () => (await Z(a)({
1702
2065
  type: "getDemonstratingProofOfPossessionNonce",
1703
2066
  data: null,
1704
2067
  configurationName: t
1705
- })).demonstratingProofOfPossessionNonce, S = async (e) => {
2068
+ })).demonstratingProofOfPossessionNonce, C = async (e) => {
1706
2069
  let n = JSON.stringify(e);
1707
- await X(a)({
2070
+ await Z(a)({
1708
2071
  type: "setDemonstratingProofOfPossessionJwk",
1709
2072
  data: { demonstratingProofOfPossessionJwkJson: n },
1710
2073
  configurationName: t
1711
2074
  });
1712
- }, C = async () => {
1713
- let e = await X(a)({
2075
+ }, w = async () => {
2076
+ let e = await Z(a)({
1714
2077
  type: "getDemonstratingProofOfPossessionJwk",
1715
2078
  data: null,
1716
2079
  configurationName: t
1717
2080
  });
1718
2081
  return e.demonstratingProofOfPossessionJwkJson ? JSON.parse(e.demonstratingProofOfPossessionJwkJson) : null;
1719
- }, w = async (e = !0) => {
1720
- let n = (await X(a)({
2082
+ }, T = async (e = !0) => {
2083
+ let n = (await Z(a)({
1721
2084
  type: "getState",
1722
2085
  data: null,
1723
2086
  configurationName: t
1724
2087
  })).state;
1725
- return n || (n = sessionStorage[`oidc.state.${t}`], console.warn("state not found in service worker, using sessionStorage"), e && (await T(n), n = await w(!1))), n;
1726
- }, T = async (e) => (sessionStorage[`oidc.state.${t}`] = e, X(a)({
2088
+ return n || (n = sessionStorage[`oidc.state.${t}`], console.warn("state not found in service worker, using sessionStorage"), e && (await E(n), n = await T(!1))), n;
2089
+ }, E = async (e) => (sessionStorage[`oidc.state.${t}`] = e, Z(a)({
1727
2090
  type: "setState",
1728
2091
  data: { state: e },
1729
2092
  configurationName: t
1730
- })), E = async (e = !0) => {
1731
- let n = (await X(a)({
2093
+ })), D = async (e = !0) => {
2094
+ let n = (await Z(a)({
1732
2095
  type: "getCodeVerifier",
1733
2096
  data: null,
1734
2097
  configurationName: t
1735
2098
  })).codeVerifier;
1736
- return n || (n = sessionStorage[`oidc.code_verifier.${t}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), e && (await D(n), n = await E(!1))), n;
1737
- }, D = async (e) => (sessionStorage[`oidc.code_verifier.${t}`] = e, X(a)({
2099
+ return n || (n = sessionStorage[`oidc.code_verifier.${t}`], console.warn("codeVerifier not found in service worker, using sessionStorage"), e && (await O(n), n = await D(!1))), n;
2100
+ }, O = async (e) => (sessionStorage[`oidc.code_verifier.${t}`] = e, Z(a)({
1738
2101
  type: "setCodeVerifier",
1739
2102
  data: { codeVerifier: e },
1740
2103
  configurationName: t
1741
2104
  }));
1742
2105
  return {
1743
- clearAsync: d,
1744
- initAsync: f,
1745
- startKeepAliveServiceWorker: () => p(e.service_worker_keep_alive_path),
1746
- setSessionStateAsync: m,
1747
- getSessionStateAsync: h,
1748
- setNonceAsync: g,
1749
- getNonceAsync: _,
1750
- setLoginParams: y,
1751
- getLoginParams: b,
1752
- getStateAsync: w,
1753
- setStateAsync: T,
1754
- getCodeVerifierAsync: E,
1755
- setCodeVerifierAsync: D,
2106
+ clearAsync: u,
2107
+ initAsync: d,
2108
+ startKeepAliveServiceWorker: () => f(e.service_worker_keep_alive_path),
2109
+ setSessionStateAsync: p,
2110
+ getSessionStateAsync: m,
2111
+ setNonceAsync: h,
2112
+ getNonceAsync: g,
2113
+ setLoginParams: v,
2114
+ getLoginParams: y,
2115
+ getStateAsync: T,
2116
+ setStateAsync: E,
2117
+ getCodeVerifierAsync: D,
2118
+ setCodeVerifierAsync: O,
1756
2119
  setDemonstratingProofOfPossessionNonce: x,
1757
- getDemonstratingProofOfPossessionNonce: ee,
1758
- setDemonstratingProofOfPossessionJwkAsync: S,
1759
- getDemonstratingProofOfPossessionJwkAsync: C,
1760
- signalAsync: (e, n) => X(a, n)({
2120
+ getDemonstratingProofOfPossessionNonce: S,
2121
+ setDemonstratingProofOfPossessionJwkAsync: C,
2122
+ getDemonstratingProofOfPossessionJwkAsync: w,
2123
+ signalAsync: (e, n) => Z(a, n)({
1761
2124
  ...e,
1762
2125
  configurationName: e.configurationName ?? t
1763
2126
  })
1764
2127
  };
1765
- }, at = async (e, t, n, r) => {
2128
+ }, Tt = async (e, t, n, r) => {
1766
2129
  let i = await $(e, t);
1767
2130
  if (!i) throw Error(`signalServiceWorkerAsync: no service worker registered for configuration "${t}"`);
1768
2131
  return i.signalAsync(n, r);
1769
- }, ot = class e {
2132
+ }, Et = class e {
1770
2133
  constructor(e) {
1771
2134
  this._oidc = e;
1772
2135
  }
@@ -1780,17 +2143,17 @@ var Ve = (e, t = null, n) => {
1780
2143
  this._oidc.publishEvent(e, t);
1781
2144
  }
1782
2145
  static {
1783
- this.getOrCreate = (t, n = new O()) => (r, i = "default") => new e(V.getOrCreate(t, n)(r, i));
2146
+ this.getOrCreate = (t, n = new j()) => (r, i = "default") => new e(H.getOrCreate(t, n)(r, i));
1784
2147
  }
1785
2148
  static get(t = "default") {
1786
- let n = V.get(t);
2149
+ let n = H.get(t);
1787
2150
  return n ? new e(n) : null;
1788
2151
  }
1789
2152
  static getOrThrow(t = "default") {
1790
- return new e(V.getOrThrow(t));
2153
+ return new e(H.getOrThrow(t));
1791
2154
  }
1792
2155
  static {
1793
- this.eventNames = V.eventNames;
2156
+ this.eventNames = H.eventNames;
1794
2157
  }
1795
2158
  tryKeepExistingSessionAsync() {
1796
2159
  return this._oidc.tryKeepExistingSessionAsync();
@@ -1813,6 +2176,9 @@ var Ve = (e, t = null, n) => {
1813
2176
  renewTokensAsync(e = null, t = null) {
1814
2177
  return this._oidc.renewTokensAsync(e, t);
1815
2178
  }
2179
+ renewTokensOrThrowAsync(e = null, t = null) {
2180
+ return this._oidc.renewTokensOrThrowAsync(e, t);
2181
+ }
1816
2182
  loginCallbackAsync() {
1817
2183
  return this._oidc.loginCallbackWithAutoTokensRenewAsync();
1818
2184
  }
@@ -1827,21 +2193,21 @@ var Ve = (e, t = null, n) => {
1827
2193
  }
1828
2194
  async getValidTokenAsync(e = 200, t = 50) {
1829
2195
  let n = this._oidc;
1830
- return We({
2196
+ return lt({
1831
2197
  getTokens: () => n.tokens,
1832
2198
  configuration: {
1833
2199
  token_automatic_renew_mode: n.configuration.token_automatic_renew_mode,
1834
2200
  refresh_time_before_tokens_expiration_in_second: n.configuration.refresh_time_before_tokens_expiration_in_second
1835
2201
  },
1836
2202
  syncTokensInfoAsync: async () => {
1837
- let { status: e } = await Fe(n)(n.configuration, n.configurationName, n.tokens, !1);
2203
+ let { status: e } = await $e(n)(n.configuration, n.configurationName, n.tokens, !1);
1838
2204
  return e;
1839
2205
  },
1840
2206
  renewTokensAsync: n.renewTokensAsync.bind(n)
1841
2207
  }, e, t);
1842
2208
  }
1843
2209
  fetchWithTokens(e, t = !1) {
1844
- return De(e, this._oidc, t);
2210
+ return We(e, this._oidc, t);
1845
2211
  }
1846
2212
  async userInfoAsync(e = !1, t = !1) {
1847
2213
  return this._oidc.userInfoAsync(e, t);
@@ -1850,9 +2216,9 @@ var Ve = (e, t = null, n) => {
1850
2216
  return this._oidc.userInfo;
1851
2217
  }
1852
2218
  async signalServiceWorker(e, t) {
1853
- return at(this._oidc.configuration, this._oidc.configurationName, e, t);
2219
+ return Tt(this._oidc.configuration, this._oidc.configurationName, e, t);
1854
2220
  }
1855
- }, st = "1.0.0", ct = {
2221
+ }, Dt = "1.0.0", Ot = {
1856
2222
  SKIP_WAITING: "SKIP_WAITING",
1857
2223
  CLAIM: "claim",
1858
2224
  CLEAR: "clear",
@@ -1869,18 +2235,18 @@ var Ve = (e, t = null, n) => {
1869
2235
  GET_DPOP_NONCE: "getDemonstratingProofOfPossessionNonce",
1870
2236
  SET_DPOP_JWK: "setDemonstratingProofOfPossessionJwk",
1871
2237
  GET_DPOP_JWK: "getDemonstratingProofOfPossessionJwk"
1872
- }, lt = {
2238
+ }, kt = {
1873
2239
  ACCESS_TOKEN: "ACCESS_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",
1874
2240
  REFRESH_TOKEN: "REFRESH_TOKEN_SECURED_BY_OIDC_SERVICE_WORKER",
1875
2241
  NONCE_TOKEN: "NONCE_SECURED_BY_OIDC_SERVICE_WORKER",
1876
2242
  CODE_VERIFIER: "CODE_VERIFIER_SECURED_BY_OIDC_SERVICE_WORKER"
1877
- }, ut = "DPOP_SECURED_BY_OIDC_SERVICE_WORKER", dt = {
2243
+ }, At = "DPOP_SECURED_BY_OIDC_SERVICE_WORKER", jt = {
1878
2244
  TAB_ID: "oidc.tabId.",
1879
2245
  STATE: "oidc.state.",
1880
2246
  NONCE: "oidc.nonce.",
1881
2247
  CODE_VERIFIER: "oidc.code_verifier.",
1882
2248
  LOGIN_PARAMS: "oidc.login.",
1883
2249
  SW_VERSION_MISMATCH_RELOAD: "oidc.sw.version_mismatch_reload."
1884
- }, ft = "oidc.sw.controllerchange_reload_count", pt = (e, t) => `${e}${t}`, mt = (e, t, n = "default") => `${e}_${t}#tabId=${n}`, ht = (e, t = "default") => `${ut}_${e}#tabId=${t}`, gt = (e) => typeof e == "string" ? Object.values(ct).includes(e) : !1;
2250
+ }, Mt = "oidc.sw.controllerchange_reload_count", Nt = (e, t) => `${e}${t}`, Pt = (e, t, n = "default") => `${e}_${t}#tabId=${n}`, Ft = (e, t = "default") => `${At}_${e}#tabId=${t}`, It = (e) => typeof e == "string" ? Object.values(Ot).includes(e) : !1;
1885
2251
  //#endregion
1886
- export { ut as DPOP_TOKEN_PLACEHOLDER_PREFIX, ot as OidcClient, O as OidcLocation, A as OidcStateError, k as OidcStateErrorCode, st as PROTOCOL_VERSION, dt as STORAGE_KEY_PREFIX, ft as SW_CONTROLLER_CHANGE_RELOAD_COUNT_KEY, ct as ServiceWorkerMessageType, lt as TOKEN_PLACEHOLDERS, R as TokenAutomaticRenewMode, G as TokenRenewMode, ht as buildDpopSecuredPlaceholder, mt as buildSecuredTokenPlaceholder, pt as buildStorageKey, ke as getFetchDefault, F as getParseQueryStringFromLocation, ve as getPath, ce as isOidcStateError, gt as isServiceWorkerMessageType, at as signalServiceWorkerAsync };
2252
+ export { At as DPOP_TOKEN_PLACEHOLDER_PREFIX, Et as OidcClient, d as OidcError, c as OidcErrorCode, j as OidcLocation, N as OidcStateError, M as OidcStateErrorCode, Dt as PROTOCOL_VERSION, F as PushedAuthorizationRequestError, P as PushedAuthorizationRequestErrorCode, jt as STORAGE_KEY_PREFIX, Mt as SW_CONTROLLER_CHANGE_RELOAD_COUNT_KEY, Ot as ServiceWorkerMessageType, kt as TOKEN_PLACEHOLDERS, B as TokenAutomaticRenewMode, it as TokenRenewMode, Ft as buildDpopSecuredPlaceholder, Pt as buildSecuredTokenPlaceholder, Nt as buildStorageKey, Ke as getFetchDefault, z as getParseQueryStringFromLocation, Ne as getPath, f as isOidcError, ye as isOidcStateError, be as isPushedAuthorizationRequestError, It as isServiceWorkerMessageType, Tt as signalServiceWorkerAsync };