zudoku 0.46.3 → 0.47.0

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 (117) hide show
  1. package/dist/config/config.d.ts +11 -0
  2. package/dist/config/validators/InputSidebarSchema.d.ts +1 -1
  3. package/dist/config/validators/validate.d.ts +47 -47
  4. package/dist/config/validators/validate.js +11 -1
  5. package/dist/config/validators/validate.js.map +1 -1
  6. package/dist/config/validators/validate.test.d.ts +1 -0
  7. package/dist/config/validators/validate.test.js +80 -0
  8. package/dist/config/validators/validate.test.js.map +1 -0
  9. package/dist/lib/auth/issuer.d.ts +2 -0
  10. package/dist/lib/auth/issuer.js +34 -0
  11. package/dist/lib/auth/issuer.js.map +1 -0
  12. package/dist/lib/auth/issuer.test.d.ts +1 -0
  13. package/dist/lib/auth/issuer.test.js +81 -0
  14. package/dist/lib/auth/issuer.test.js.map +1 -0
  15. package/dist/lib/authentication/hook.d.ts +6 -0
  16. package/dist/lib/authentication/providers/auth0.js +1 -1
  17. package/dist/lib/authentication/providers/auth0.js.map +1 -1
  18. package/dist/lib/authentication/providers/azureb2c.d.ts +28 -0
  19. package/dist/lib/authentication/providers/azureb2c.js +145 -0
  20. package/dist/lib/authentication/providers/azureb2c.js.map +1 -0
  21. package/dist/lib/authentication/providers/clerk.js +3 -12
  22. package/dist/lib/authentication/providers/clerk.js.map +1 -1
  23. package/dist/lib/authentication/providers/openid.d.ts +1 -0
  24. package/dist/lib/authentication/providers/openid.js +38 -0
  25. package/dist/lib/authentication/providers/openid.js.map +1 -1
  26. package/dist/lib/authentication/providers/supabase.js +2 -9
  27. package/dist/lib/authentication/providers/supabase.js.map +1 -1
  28. package/dist/lib/authentication/state.d.ts +6 -5
  29. package/dist/lib/authentication/state.js +19 -6
  30. package/dist/lib/authentication/state.js.map +1 -1
  31. package/dist/lib/components/context/ZudokuProvider.d.ts +1 -1
  32. package/dist/lib/components/index.d.ts +6 -0
  33. package/dist/lib/hooks/index.d.ts +6 -0
  34. package/dist/lib/plugins/openapi/PlaygroundDialogWrapper.d.ts +1 -1
  35. package/dist/lib/plugins/openapi/playground/Headers.d.ts +2 -2
  36. package/dist/lib/plugins/openapi/playground/fileUtils.js +1 -1
  37. package/dist/lib/plugins/openapi/playground/fileUtils.js.map +1 -1
  38. package/dist/lib/util/MdxComponents.js +1 -1
  39. package/dist/lib/util/MdxComponents.js.map +1 -1
  40. package/dist/vite/build.js +1 -28
  41. package/dist/vite/build.js.map +1 -1
  42. package/lib/{Markdown-D81l28Ib.js → Markdown-BUE2ViaD.js} +37 -37
  43. package/lib/{Markdown-D81l28Ib.js.map → Markdown-BUE2ViaD.js.map} +1 -1
  44. package/lib/{MdxPage-S_CxlNmX.js → MdxPage-By4UkRkI.js} +4 -4
  45. package/lib/{MdxPage-S_CxlNmX.js.map → MdxPage-By4UkRkI.js.map} +1 -1
  46. package/lib/{OasProvider-D5rt6WMb.js → OasProvider-C6_Kx5O7.js} +2 -2
  47. package/lib/{OasProvider-D5rt6WMb.js.map → OasProvider-C6_Kx5O7.js.map} +1 -1
  48. package/lib/{OperationList-CNhg654C.js → OperationList-BISd29LY.js} +6 -6
  49. package/lib/OperationList-BISd29LY.js.map +1 -0
  50. package/lib/{RouteGuard-CZ_uLv3g.js → RouteGuard-CgmsSw7T.js} +2 -2
  51. package/lib/{RouteGuard-CZ_uLv3g.js.map → RouteGuard-CgmsSw7T.js.map} +1 -1
  52. package/lib/{SchemaList-BvzCrTYg.js → SchemaList-BqnRo5ov.js} +6 -6
  53. package/lib/{SchemaList-BvzCrTYg.js.map → SchemaList-BqnRo5ov.js.map} +1 -1
  54. package/lib/{SchemaView-Br1RupCp.js → SchemaView-CtYJpxQI.js} +3 -3
  55. package/lib/{SchemaView-Br1RupCp.js.map → SchemaView-CtYJpxQI.js.map} +1 -1
  56. package/lib/{SignUp-B-1Pvc-8.js → SignUp-CrjeBbqN.js} +2 -2
  57. package/lib/{SignUp-B-1Pvc-8.js.map → SignUp-CrjeBbqN.js.map} +1 -1
  58. package/lib/{Slot-T8NJUkm4.js → Slot-DANV2b7_.js} +4 -4
  59. package/lib/{Slot-T8NJUkm4.js.map → Slot-DANV2b7_.js.map} +1 -1
  60. package/lib/{SyntaxHighlight-Cz6Me7-F.js → SyntaxHighlight-DtvR7RLF.js} +1291 -1265
  61. package/lib/SyntaxHighlight-DtvR7RLF.js.map +1 -0
  62. package/lib/{Toc-PA-j0gEu.js → Toc-ClJBmdtI.js} +2 -2
  63. package/lib/{Toc-PA-j0gEu.js.map → Toc-ClJBmdtI.js.map} +1 -1
  64. package/lib/{circular-5FeDWJOn.js → circular-pOdgLzpG.js} +2 -2
  65. package/lib/{circular-5FeDWJOn.js.map → circular-pOdgLzpG.js.map} +1 -1
  66. package/lib/clerk-yAKDC3Qz.js +24812 -0
  67. package/lib/clerk-yAKDC3Qz.js.map +1 -0
  68. package/lib/{createServer-BC2RZgmW.js → createServer-qAtUf99r.js} +2625 -2615
  69. package/lib/createServer-qAtUf99r.js.map +1 -0
  70. package/lib/errors-Bpodza84.js +78 -0
  71. package/lib/errors-Bpodza84.js.map +1 -0
  72. package/lib/{hook-k7PfUIsj.js → hook-wIlTGE-2.js} +52 -31
  73. package/lib/{hook-k7PfUIsj.js.map → hook-wIlTGE-2.js.map} +1 -1
  74. package/lib/{index-CJZthJSj.js → index-RFzRn4fM.js} +10 -10
  75. package/lib/index-RFzRn4fM.js.map +1 -0
  76. package/lib/{mutation-BSeQ8pEK.js → mutation-C-kdA_1r.js} +2 -2
  77. package/lib/{mutation-BSeQ8pEK.js.map → mutation-C-kdA_1r.js.map} +1 -1
  78. package/lib/ui/SyntaxHighlight.js +2 -2
  79. package/lib/{useMutation-CZSmsIGW.js → useMutation-3Ph3x6En.js} +3 -3
  80. package/lib/{useMutation-CZSmsIGW.js.map → useMutation-3Ph3x6En.js.map} +1 -1
  81. package/lib/zudoku.auth-auth0.js +2 -2
  82. package/lib/zudoku.auth-auth0.js.map +1 -1
  83. package/lib/zudoku.auth-azureb2c.js +9974 -0
  84. package/lib/zudoku.auth-azureb2c.js.map +1 -0
  85. package/lib/zudoku.auth-clerk.js +39 -48
  86. package/lib/zudoku.auth-clerk.js.map +1 -1
  87. package/lib/zudoku.auth-openid.js +291 -316
  88. package/lib/zudoku.auth-openid.js.map +1 -1
  89. package/lib/zudoku.components.js +1222 -1594
  90. package/lib/zudoku.components.js.map +1 -1
  91. package/lib/zudoku.hooks.js +2 -2
  92. package/lib/zudoku.plugin-api-catalog.js +2 -2
  93. package/lib/zudoku.plugin-api-keys.js +3 -3
  94. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  95. package/lib/zudoku.plugin-custom-pages.js +1 -1
  96. package/lib/zudoku.plugin-markdown.js +1 -1
  97. package/lib/zudoku.plugin-openapi.js +2 -2
  98. package/lib/zudoku.plugin-search-pagefind.js +2 -2
  99. package/package.json +37 -19
  100. package/src/lib/auth/issuer.test.ts +104 -0
  101. package/src/lib/auth/issuer.ts +38 -0
  102. package/src/lib/authentication/providers/auth0.tsx +1 -1
  103. package/src/lib/authentication/providers/azureb2c.tsx +196 -0
  104. package/src/lib/authentication/providers/clerk.tsx +3 -12
  105. package/src/lib/authentication/providers/openid.tsx +53 -0
  106. package/src/lib/authentication/providers/supabase.tsx +2 -9
  107. package/src/lib/authentication/state.ts +37 -7
  108. package/src/lib/components/context/ZudokuProvider.tsx +1 -1
  109. package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +1 -1
  110. package/src/lib/plugins/openapi/PlaygroundDialogWrapper.tsx +1 -1
  111. package/src/lib/plugins/openapi/playground/Headers.tsx +2 -2
  112. package/src/lib/plugins/openapi/playground/fileUtils.ts +1 -1
  113. package/src/lib/util/MdxComponents.tsx +1 -1
  114. package/lib/OperationList-CNhg654C.js.map +0 -1
  115. package/lib/SyntaxHighlight-Cz6Me7-F.js.map +0 -1
  116. package/lib/createServer-BC2RZgmW.js.map +0 -1
  117. package/lib/index-CJZthJSj.js.map +0 -1
@@ -1,17 +1,14 @@
1
- import { j as L } from "./jsx-runtime-C5mzlN2N.js";
2
- import { g as Pe, Z as Le } from "./invariant-DAFpPywt.js";
1
+ import { j as ne } from "./jsx-runtime-C5mzlN2N.js";
2
+ import { g as Le } from "./invariant-DAFpPywt.js";
3
3
  import { C as Ue } from "./ClientOnly-E7hGysn1.js";
4
- import { d as xe, j as fe, u as x } from "./hook-k7PfUIsj.js";
5
- import { LogOutIcon as Ce } from "lucide-react";
6
- import { S as Ie, a as je, b as Oe } from "./SignUp-B-1Pvc-8.js";
7
- import { N as ze } from "./chunk-DQRVZFIR-BblmKnHy.js";
8
- import { useZudoku as Je } from "./zudoku.components.js";
9
- var J = { exports: {} }, De = J.exports, re;
10
- function Ne() {
11
- return re || (re = 1, function(t) {
4
+ import { j as xe, u as S } from "./hook-wIlTGE-2.js";
5
+ import { C as Ce, O as re, A as R, a as Ie } from "./errors-Bpodza84.js";
6
+ var O = { exports: {} }, je = O.exports, oe;
7
+ function De() {
8
+ return oe || (oe = 1, function(t) {
12
9
  (function(e, n) {
13
10
  t.exports ? t.exports = n() : e.log = n();
14
- })(De, function() {
11
+ })(je, function() {
15
12
  var e = function() {
16
13
  }, n = "undefined", o = typeof window !== n && typeof window.navigator !== n && /Trident\/|MSIE /.test(window.navigator.userAgent), s = [
17
14
  "trace",
@@ -46,16 +43,16 @@ function Ne() {
46
43
  if (this.log = this.debug, typeof console === n && l < this.levels.SILENT)
47
44
  return "No console available for logging";
48
45
  }
49
- function A(l) {
46
+ function k(l) {
50
47
  return function() {
51
48
  typeof console !== n && (p.call(this), this[l].apply(this, arguments));
52
49
  };
53
50
  }
54
51
  function b(l, m, u) {
55
- return y(l) || A.apply(this, arguments);
52
+ return y(l) || k.apply(this, arguments);
56
53
  }
57
54
  function h(l, m) {
58
- var u = this, O, H, P, _ = "loglevel";
55
+ var u = this, j, K, L, _ = "loglevel";
59
56
  typeof l == "string" ? _ += ":" + l : typeof l == "symbol" && (_ = void 0);
60
57
  function Ee(d) {
61
58
  var g = (s[d] || "silent").toUpperCase();
@@ -71,7 +68,7 @@ function Ne() {
71
68
  }
72
69
  }
73
70
  }
74
- function ee() {
71
+ function X() {
75
72
  var d;
76
73
  if (!(typeof window === n || !_)) {
77
74
  try {
@@ -80,16 +77,16 @@ function Ne() {
80
77
  }
81
78
  if (typeof d === n)
82
79
  try {
83
- var g = window.document.cookie, z = encodeURIComponent(_), ne = g.indexOf(z + "=");
84
- ne !== -1 && (d = /^([^;]+)/.exec(
85
- g.slice(ne + z.length + 1)
80
+ var g = window.document.cookie, D = encodeURIComponent(_), te = g.indexOf(D + "=");
81
+ te !== -1 && (d = /^([^;]+)/.exec(
82
+ g.slice(te + D.length + 1)
86
83
  )[1]);
87
84
  } catch {
88
85
  }
89
86
  return u.levels[d] === void 0 && (d = void 0), d;
90
87
  }
91
88
  }
92
- function ke() {
89
+ function Re() {
93
90
  if (!(typeof window === n || !_)) {
94
91
  try {
95
92
  window.localStorage.removeItem(_);
@@ -115,26 +112,26 @@ function Ne() {
115
112
  ERROR: 4,
116
113
  SILENT: 5
117
114
  }, u.methodFactory = m || b, u.getLevel = function() {
118
- return P ?? H ?? O;
115
+ return L ?? K ?? j;
119
116
  }, u.setLevel = function(d, g) {
120
- return P = U(d), g !== !1 && Ee(P), p.call(u);
117
+ return L = U(d), g !== !1 && Ee(L), p.call(u);
121
118
  }, u.setDefaultLevel = function(d) {
122
- H = U(d), ee() || u.setLevel(d, !1);
119
+ K = U(d), X() || u.setLevel(d, !1);
123
120
  }, u.resetLevel = function() {
124
- P = null, ke(), p.call(u);
121
+ L = null, Re(), p.call(u);
125
122
  }, u.enableAll = function(d) {
126
123
  u.setLevel(u.levels.TRACE, d);
127
124
  }, u.disableAll = function(d) {
128
125
  u.setLevel(u.levels.SILENT, d);
129
126
  }, u.rebuild = function() {
130
- if (i !== u && (O = U(i.getLevel())), p.call(u), i === u)
127
+ if (i !== u && (j = U(i.getLevel())), p.call(u), i === u)
131
128
  for (var d in r)
132
129
  r[d].rebuild();
133
- }, O = U(
130
+ }, j = U(
134
131
  i ? i.getLevel() : "WARN"
135
132
  );
136
- var te = ee();
137
- te != null && (P = U(te)), p.call(u);
133
+ var ee = X();
134
+ ee != null && (L = U(ee)), p.call(u);
138
135
  }
139
136
  i = new h(), i.getLogger = function(m) {
140
137
  if (typeof m != "symbol" && typeof m != "string" || m === "")
@@ -145,20 +142,20 @@ function Ne() {
145
142
  i.methodFactory
146
143
  )), u;
147
144
  };
148
- var R = typeof window !== n ? window.log : void 0;
145
+ var P = typeof window !== n ? window.log : void 0;
149
146
  return i.noConflict = function() {
150
- return typeof window !== n && window.log === i && (window.log = R), i;
147
+ return typeof window !== n && window.log === i && (window.log = P), i;
151
148
  }, i.getLoggers = function() {
152
149
  return r;
153
150
  }, i.default = i, i;
154
151
  });
155
- }(J)), J.exports;
152
+ }(O)), O.exports;
156
153
  }
157
- var We = Ne();
158
- const oe = /* @__PURE__ */ Pe(We);
159
- let B;
160
- (typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (B = "oauth4webapi/v2.17.0");
161
- function V(t, e) {
154
+ var Oe = De();
155
+ const ie = /* @__PURE__ */ Le(Oe);
156
+ let M;
157
+ (typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (M = "oauth4webapi/v2.17.0");
158
+ function q(t, e) {
162
159
  if (t == null)
163
160
  return !1;
164
161
  try {
@@ -167,19 +164,19 @@ function V(t, e) {
167
164
  return !1;
168
165
  }
169
166
  }
170
- const N = Symbol(), Ke = Symbol(), G = Symbol(), He = Symbol(), $e = Symbol(), Fe = Symbol(), Me = new TextEncoder(), Be = new TextDecoder();
167
+ const z = Symbol(), Je = Symbol(), V = Symbol(), ze = Symbol(), Ne = Symbol(), We = Symbol(), Ke = new TextEncoder(), He = new TextDecoder();
171
168
  function E(t) {
172
- return typeof t == "string" ? Me.encode(t) : Be.decode(t);
169
+ return typeof t == "string" ? Ke.encode(t) : He.decode(t);
173
170
  }
174
- const ie = 32768;
175
- function qe(t) {
171
+ const se = 32768;
172
+ function $e(t) {
176
173
  t instanceof ArrayBuffer && (t = new Uint8Array(t));
177
174
  const e = [];
178
- for (let n = 0; n < t.byteLength; n += ie)
179
- e.push(String.fromCharCode.apply(null, t.subarray(n, n + ie)));
175
+ for (let n = 0; n < t.byteLength; n += se)
176
+ e.push(String.fromCharCode.apply(null, t.subarray(n, n + se)));
180
177
  return btoa(e.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
181
178
  }
182
- function Ve(t) {
179
+ function Fe(t) {
183
180
  try {
184
181
  const e = atob(t.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "")), n = new Uint8Array(e.length);
185
182
  for (let o = 0; o < e.length; o++)
@@ -189,10 +186,10 @@ function Ve(t) {
189
186
  throw new a("The input to be decoded is not correctly encoded.", { cause: e });
190
187
  }
191
188
  }
192
- function T(t) {
193
- return typeof t == "string" ? Ve(t) : qe(t);
189
+ function A(t) {
190
+ return typeof t == "string" ? Fe(t) : $e(t);
194
191
  }
195
- class Ge {
192
+ class Me {
196
193
  constructor(e) {
197
194
  this.cache = /* @__PURE__ */ new Map(), this._cache = /* @__PURE__ */ new Map(), this.maxSize = e;
198
195
  }
@@ -221,47 +218,47 @@ class v extends Error {
221
218
  super(e ?? "operation not supported"), this.name = this.constructor.name, Error.captureStackTrace?.(this, this.constructor);
222
219
  }
223
220
  }
224
- class Ze extends Error {
221
+ class Be extends Error {
225
222
  constructor(e, n) {
226
223
  super(e, n), this.name = this.constructor.name, Error.captureStackTrace?.(this, this.constructor);
227
224
  }
228
225
  }
229
- const a = Ze, pe = new Ge(100);
230
- function we(t) {
226
+ const a = Be, we = new Me(100);
227
+ function me(t) {
231
228
  return t instanceof CryptoKey;
232
229
  }
233
- function Ye(t) {
234
- return we(t) && t.type === "private";
230
+ function qe(t) {
231
+ return me(t) && t.type === "private";
235
232
  }
236
- function Qe(t) {
237
- return we(t) && t.type === "public";
233
+ function Ve(t) {
234
+ return me(t) && t.type === "public";
238
235
  }
239
- function Z(t) {
236
+ function G(t) {
240
237
  try {
241
238
  const e = t.headers.get("dpop-nonce");
242
- e && pe.set(new URL(t.url).origin, e);
239
+ e && we.set(new URL(t.url).origin, e);
243
240
  } catch {
244
241
  }
245
242
  return t;
246
243
  }
247
- function C(t) {
244
+ function x(t) {
248
245
  return !(t === null || typeof t != "object" || Array.isArray(t));
249
246
  }
250
- function W(t) {
251
- V(t, Headers) && (t = Object.fromEntries(t.entries()));
247
+ function N(t) {
248
+ q(t, Headers) && (t = Object.fromEntries(t.entries()));
252
249
  const e = new Headers(t);
253
- if (B && !e.has("user-agent") && e.set("user-agent", B), e.has("authorization"))
250
+ if (M && !e.has("user-agent") && e.set("user-agent", M), e.has("authorization"))
254
251
  throw new TypeError('"options.headers" must not include the "authorization" header name');
255
252
  if (e.has("dpop"))
256
253
  throw new TypeError('"options.headers" must not include the "dpop" header name');
257
254
  return e;
258
255
  }
259
- function Xe(t) {
256
+ function Ge(t) {
260
257
  if (typeof t == "function" && (t = t()), !(t instanceof AbortSignal))
261
258
  throw new TypeError('"options.signal" must return or be an instance of AbortSignal');
262
259
  return t;
263
260
  }
264
- async function et(t, e) {
261
+ async function Ye(t, e) {
265
262
  if (!(t instanceof URL))
266
263
  throw new TypeError('"issuerIdentifier" must be an instance of URL');
267
264
  if (t.protocol !== "https:" && t.protocol !== "http:")
@@ -278,32 +275,32 @@ async function et(t, e) {
278
275
  default:
279
276
  throw new TypeError('"options.algorithm" must be "oidc" (default), or "oauth2"');
280
277
  }
281
- const o = W(e?.headers);
282
- return o.set("accept", "application/json"), (e?.[G] || fetch)(n.href, {
278
+ const o = N(e?.headers);
279
+ return o.set("accept", "application/json"), (e?.[V] || fetch)(n.href, {
283
280
  headers: Object.fromEntries(o.entries()),
284
281
  method: "GET",
285
282
  redirect: "manual",
286
283
  signal: null
287
- }).then(Z);
284
+ }).then(G);
288
285
  }
289
286
  function w(t) {
290
287
  return typeof t == "string" && t.length !== 0;
291
288
  }
292
- async function tt(t, e) {
289
+ async function Ze(t, e) {
293
290
  if (!(t instanceof URL))
294
291
  throw new TypeError('"expectedIssuer" must be an instance of URL');
295
- if (!V(e, Response))
292
+ if (!q(e, Response))
296
293
  throw new TypeError('"response" must be an instance of Response');
297
294
  if (e.status !== 200)
298
295
  throw new a('"response" is not a conform Authorization Server Metadata response');
299
- X(e);
296
+ Q(e);
300
297
  let n;
301
298
  try {
302
299
  n = await e.json();
303
300
  } catch (o) {
304
301
  throw new a('failed to parse "response" body as JSON', { cause: o });
305
302
  }
306
- if (!C(n))
303
+ if (!x(n))
307
304
  throw new a('"response" body must be a top level object');
308
305
  if (!w(n.issuer))
309
306
  throw new a('"response" body "issuer" property must be a non-empty string');
@@ -312,27 +309,27 @@ async function tt(t, e) {
312
309
  return n;
313
310
  }
314
311
  function Y() {
315
- return T(crypto.getRandomValues(new Uint8Array(32)));
312
+ return A(crypto.getRandomValues(new Uint8Array(32)));
316
313
  }
317
- function nt() {
314
+ function Qe() {
318
315
  return Y();
319
316
  }
320
- function rt() {
317
+ function Xe() {
321
318
  return Y();
322
319
  }
323
- async function ot(t) {
320
+ async function et(t) {
324
321
  if (!w(t))
325
322
  throw new TypeError('"codeVerifier" must be a non-empty string');
326
- return T(await crypto.subtle.digest("SHA-256", E(t)));
323
+ return A(await crypto.subtle.digest("SHA-256", E(t)));
327
324
  }
328
- function se(t) {
325
+ function ae(t) {
329
326
  return encodeURIComponent(t).replace(/%20/g, "+");
330
327
  }
331
- function it(t, e) {
332
- const n = se(t), o = se(e);
328
+ function tt(t, e) {
329
+ const n = ae(t), o = ae(e);
333
330
  return `Basic ${btoa(`${n}:${o}`)}`;
334
331
  }
335
- function st(t) {
332
+ function nt(t) {
336
333
  switch (t.algorithm.hash.name) {
337
334
  case "SHA-256":
338
335
  return "PS256";
@@ -344,7 +341,7 @@ function st(t) {
344
341
  throw new v("unsupported RsaHashedKeyAlgorithm hash name");
345
342
  }
346
343
  }
347
- function at(t) {
344
+ function rt(t) {
348
345
  switch (t.algorithm.hash.name) {
349
346
  case "SHA-256":
350
347
  return "RS256";
@@ -356,7 +353,7 @@ function at(t) {
356
353
  throw new v("unsupported RsaHashedKeyAlgorithm hash name");
357
354
  }
358
355
  }
359
- function ct(t) {
356
+ function ot(t) {
360
357
  switch (t.algorithm.namedCurve) {
361
358
  case "P-256":
362
359
  return "ES256";
@@ -368,14 +365,14 @@ function ct(t) {
368
365
  throw new v("unsupported EcKeyAlgorithm namedCurve");
369
366
  }
370
367
  }
371
- function ut(t) {
368
+ function it(t) {
372
369
  switch (t.algorithm.name) {
373
370
  case "RSA-PSS":
374
- return st(t);
371
+ return nt(t);
375
372
  case "RSASSA-PKCS1-v1_5":
376
- return at(t);
373
+ return rt(t);
377
374
  case "ECDSA":
378
- return ct(t);
375
+ return ot(t);
379
376
  case "Ed25519":
380
377
  case "Ed448":
381
378
  return "EdDSA";
@@ -383,184 +380,184 @@ function ut(t) {
383
380
  throw new v("unsupported CryptoKey algorithm name");
384
381
  }
385
382
  }
386
- function K(t) {
387
- const e = t?.[N];
383
+ function W(t) {
384
+ const e = t?.[z];
388
385
  return typeof e == "number" && Number.isFinite(e) ? e : 0;
389
386
  }
390
- function me(t) {
391
- const e = t?.[Ke];
387
+ function ge(t) {
388
+ const e = t?.[Je];
392
389
  return typeof e == "number" && Number.isFinite(e) && Math.sign(e) !== -1 ? e : 30;
393
390
  }
394
- function Q() {
391
+ function Z() {
395
392
  return Math.floor(Date.now() / 1e3);
396
393
  }
397
- function I(t) {
394
+ function C(t) {
398
395
  if (typeof t != "object" || t === null)
399
396
  throw new TypeError('"as" must be an object');
400
397
  if (!w(t.issuer))
401
398
  throw new TypeError('"as.issuer" property must be a non-empty string');
402
399
  return !0;
403
400
  }
404
- function j(t) {
401
+ function I(t) {
405
402
  if (typeof t != "object" || t === null)
406
403
  throw new TypeError('"client" must be an object');
407
404
  if (!w(t.client_id))
408
405
  throw new TypeError('"client.client_id" property must be a non-empty string');
409
406
  return !0;
410
407
  }
411
- function ae(t) {
408
+ function ce(t) {
412
409
  if (!w(t))
413
410
  throw new TypeError('"client.client_secret" property must be a non-empty string');
414
411
  return t;
415
412
  }
416
- function ce(t, e) {
413
+ function ue(t, e) {
417
414
  if (e !== void 0)
418
415
  throw new TypeError(`"client.client_secret" property must not be provided when ${t} client authentication method is used.`);
419
416
  }
420
- async function lt(t, e, n, o, s) {
417
+ async function st(t, e, n, o, s) {
421
418
  switch (n.delete("client_secret"), n.delete("client_assertion_type"), n.delete("client_assertion"), e.token_endpoint_auth_method) {
422
419
  case void 0:
423
420
  case "client_secret_basic": {
424
- o.set("authorization", it(e.client_id, ae(e.client_secret)));
421
+ o.set("authorization", tt(e.client_id, ce(e.client_secret)));
425
422
  break;
426
423
  }
427
424
  case "client_secret_post": {
428
- n.set("client_id", e.client_id), n.set("client_secret", ae(e.client_secret));
425
+ n.set("client_id", e.client_id), n.set("client_secret", ce(e.client_secret));
429
426
  break;
430
427
  }
431
428
  case "private_key_jwt":
432
- throw ce("private_key_jwt", e.client_secret), new TypeError('"options.clientPrivateKey" must be provided when "client.token_endpoint_auth_method" is "private_key_jwt"');
429
+ throw ue("private_key_jwt", e.client_secret), new TypeError('"options.clientPrivateKey" must be provided when "client.token_endpoint_auth_method" is "private_key_jwt"');
433
430
  case "tls_client_auth":
434
431
  case "self_signed_tls_client_auth":
435
432
  case "none": {
436
- ce(e.token_endpoint_auth_method, e.client_secret), e.token_endpoint_auth_method, n.set("client_id", e.client_id);
433
+ ue(e.token_endpoint_auth_method, e.client_secret), e.token_endpoint_auth_method, n.set("client_id", e.client_id);
437
434
  break;
438
435
  }
439
436
  default:
440
437
  throw new v("unsupported client token_endpoint_auth_method");
441
438
  }
442
439
  }
443
- async function dt(t, e, n) {
440
+ async function at(t, e, n) {
444
441
  if (!n.usages.includes("sign"))
445
442
  throw new TypeError('CryptoKey instances used for signing assertions must include "sign" in their "usages"');
446
- const o = `${T(E(JSON.stringify(t)))}.${T(E(JSON.stringify(e)))}`, s = T(await crypto.subtle.sign(Te(n), n, E(o)));
443
+ const o = `${A(E(JSON.stringify(t)))}.${A(E(JSON.stringify(e)))}`, s = A(await crypto.subtle.sign(Ae(n), n, E(o)));
447
444
  return `${o}.${s}`;
448
445
  }
449
- async function ht(t, e, n, o, s, r) {
450
- const { privateKey: i, publicKey: c, nonce: f = pe.get(n.origin) } = e;
451
- if (!Ye(i))
446
+ async function ct(t, e, n, o, s, r) {
447
+ const { privateKey: i, publicKey: c, nonce: f = we.get(n.origin) } = e;
448
+ if (!qe(i))
452
449
  throw new TypeError('"DPoP.privateKey" must be a private CryptoKey');
453
- if (!Qe(c))
450
+ if (!Ve(c))
454
451
  throw new TypeError('"DPoP.publicKey" must be a public CryptoKey');
455
452
  if (f !== void 0 && !w(f))
456
453
  throw new TypeError('"DPoP.nonce" must be a non-empty string or undefined');
457
454
  if (!c.extractable)
458
455
  throw new TypeError('"DPoP.publicKey.extractable" must be true');
459
- const y = Q() + s, p = {
460
- alg: ut(i),
456
+ const y = Z() + s, p = {
457
+ alg: it(i),
461
458
  typ: "dpop+jwt",
462
- jwk: await pt(c)
463
- }, A = {
459
+ jwk: await lt(c)
460
+ }, k = {
464
461
  iat: y,
465
462
  jti: Y(),
466
463
  htm: o,
467
464
  nonce: f,
468
465
  htu: `${n.origin}${n.pathname}`,
469
- ath: r ? T(await crypto.subtle.digest("SHA-256", E(r))) : void 0
466
+ ath: r ? A(await crypto.subtle.digest("SHA-256", E(r))) : void 0
470
467
  };
471
- e[He]?.(p, A), t.set("dpop", await dt(p, A, i));
468
+ e[ze]?.(p, k), t.set("dpop", await at(p, k, i));
472
469
  }
473
- let D;
474
- async function ft(t) {
470
+ let J;
471
+ async function ut(t) {
475
472
  const { kty: e, e: n, n: o, x: s, y: r, crv: i } = await crypto.subtle.exportKey("jwk", t), c = { kty: e, e: n, n: o, x: s, y: r, crv: i };
476
- return D.set(t, c), c;
473
+ return J.set(t, c), c;
477
474
  }
478
- async function pt(t) {
479
- return D || (D = /* @__PURE__ */ new WeakMap()), D.get(t) || ft(t);
475
+ async function lt(t) {
476
+ return J || (J = /* @__PURE__ */ new WeakMap()), J.get(t) || ut(t);
480
477
  }
481
- function ue(t, e, n) {
478
+ function le(t, e, n) {
482
479
  if (typeof t != "string")
483
480
  throw n ? new TypeError(`"as.mtls_endpoint_aliases.${e}" must be a string`) : new TypeError(`"as.${e}" must be a string`);
484
481
  return new URL(t);
485
482
  }
486
- function ge(t, e, n = !1) {
487
- return n && t.mtls_endpoint_aliases && e in t.mtls_endpoint_aliases ? ue(t.mtls_endpoint_aliases[e], e, n) : ue(t[e], e, n);
483
+ function ye(t, e, n = !1) {
484
+ return n && t.mtls_endpoint_aliases && e in t.mtls_endpoint_aliases ? le(t.mtls_endpoint_aliases[e], e, n) : le(t[e], e, n);
488
485
  }
489
- function ye(t, e) {
490
- return !!(t.use_mtls_endpoint_aliases || e?.[Fe]);
486
+ function be(t, e) {
487
+ return !!(t.use_mtls_endpoint_aliases || e?.[We]);
491
488
  }
492
- function q(t) {
489
+ function B(t) {
493
490
  const e = t;
494
491
  return typeof e != "object" || Array.isArray(e) || e === null ? !1 : e.error !== void 0;
495
492
  }
496
- async function wt(t, e, n, o, s, r) {
493
+ async function dt(t, e, n, o, s, r) {
497
494
  if (!w(t))
498
495
  throw new TypeError('"accessToken" must be a non-empty string');
499
496
  if (!(n instanceof URL))
500
497
  throw new TypeError('"url" must be an instance of URL');
501
- return o = W(o), r?.DPoP === void 0 ? o.set("authorization", `Bearer ${t}`) : (await ht(o, r.DPoP, n, e.toUpperCase(), K({ [N]: r?.[N] }), t), o.set("authorization", `DPoP ${t}`)), (r?.[G] || fetch)(n.href, {
498
+ return o = N(o), r?.DPoP === void 0 ? o.set("authorization", `Bearer ${t}`) : (await ct(o, r.DPoP, n, e.toUpperCase(), W({ [z]: r?.[z] }), t), o.set("authorization", `DPoP ${t}`)), (r?.[V] || fetch)(n.href, {
502
499
  body: s,
503
500
  headers: Object.fromEntries(o.entries()),
504
501
  method: e,
505
502
  redirect: "manual",
506
- signal: r?.signal ? Xe(r.signal) : null
507
- }).then(Z);
503
+ signal: r?.signal ? Ge(r.signal) : null
504
+ }).then(G);
508
505
  }
509
- async function mt(t, e, n, o) {
510
- I(t), j(e);
511
- const s = ge(t, "userinfo_endpoint", ye(e, o)), r = W(o?.headers);
512
- return e.userinfo_signed_response_alg ? r.set("accept", "application/jwt") : (r.set("accept", "application/json"), r.append("accept", "application/jwt")), wt(n, "GET", s, r, null, {
506
+ async function ht(t, e, n, o) {
507
+ C(t), I(e);
508
+ const s = ye(t, "userinfo_endpoint", be(e, o)), r = N(o?.headers);
509
+ return e.userinfo_signed_response_alg ? r.set("accept", "application/jwt") : (r.set("accept", "application/json"), r.append("accept", "application/jwt")), dt(n, "GET", s, r, null, {
513
510
  ...o,
514
- [N]: K(e)
511
+ [z]: W(e)
515
512
  });
516
513
  }
517
- async function gt(t, e, n, o, s, r, i) {
518
- return await lt(t, e, s, r), r.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"), (i?.[G] || fetch)(o.href, {
514
+ async function ft(t, e, n, o, s, r, i) {
515
+ return await st(t, e, s, r), r.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"), (i?.[V] || fetch)(o.href, {
519
516
  body: s,
520
517
  headers: Object.fromEntries(r.entries()),
521
518
  method: n,
522
519
  redirect: "manual",
523
520
  signal: null
524
- }).then(Z);
521
+ }).then(G);
525
522
  }
526
- async function be(t, e, n, o, s) {
527
- const r = ge(t, "token_endpoint", ye(e, s));
523
+ async function _e(t, e, n, o, s) {
524
+ const r = ye(t, "token_endpoint", be(e, s));
528
525
  o.set("grant_type", n);
529
- const i = W(s?.headers);
530
- return i.set("accept", "application/json"), gt(t, e, "POST", r, o, i, s);
526
+ const i = N(s?.headers);
527
+ return i.set("accept", "application/json"), ft(t, e, "POST", r, o, i, s);
531
528
  }
532
- async function yt(t, e, n, o) {
533
- if (I(t), j(e), !w(n))
529
+ async function de(t, e, n, o) {
530
+ if (C(t), I(e), !w(n))
534
531
  throw new TypeError('"refreshToken" must be a non-empty string');
535
532
  const s = new URLSearchParams(o?.additionalParameters);
536
- return s.set("refresh_token", n), be(t, e, "refresh_token", s, o);
533
+ return s.set("refresh_token", n), _e(t, e, "refresh_token", s, o);
537
534
  }
538
- const _e = /* @__PURE__ */ new WeakMap();
539
- function bt(t) {
535
+ const ve = /* @__PURE__ */ new WeakMap();
536
+ function pt(t) {
540
537
  if (!t.id_token)
541
538
  return;
542
- const e = _e.get(t);
539
+ const e = ve.get(t);
543
540
  if (!e)
544
541
  throw new TypeError('"ref" was already garbage collected or did not resolve from the proper sources');
545
542
  return e[0];
546
543
  }
547
- async function ve(t, e, n, o = !1, s = !1) {
548
- if (I(t), j(e), !V(n, Response))
544
+ async function Se(t, e, n, o = !1, s = !1) {
545
+ if (C(t), I(e), !q(n, Response))
549
546
  throw new TypeError('"response" must be an instance of Response');
550
547
  if (n.status !== 200) {
551
548
  let i;
552
- if (i = await Lt(n))
549
+ if (i = await Tt(n))
553
550
  return i;
554
551
  throw new a('"response" is not a conform Token Endpoint response');
555
552
  }
556
- X(n);
553
+ Q(n);
557
554
  let r;
558
555
  try {
559
556
  r = await n.json();
560
557
  } catch (i) {
561
558
  throw new a('failed to parse "response" body as JSON', { cause: i });
562
559
  }
563
- if (!C(r))
560
+ if (!x(r))
564
561
  throw new a('"response" body must be a top level object');
565
562
  if (!w(r.access_token))
566
563
  throw new a('"response" body "access_token" property must be a non-empty string');
@@ -578,7 +575,7 @@ async function ve(t, e, n, o = !1, s = !1) {
578
575
  if (r.id_token !== void 0 && !w(r.id_token))
579
576
  throw new a('"response" body "id_token" property must be a non-empty string');
580
577
  if (r.id_token) {
581
- const { claims: i, jwt: c } = await Ct(r.id_token, It.bind(void 0, e.id_token_signed_response_alg, t.id_token_signing_alg_values_supported), Ae, K(e), me(e), e[$e]).then(kt.bind(void 0, ["aud", "exp", "iat", "iss", "sub"])).then(St.bind(void 0, t.issuer)).then(vt.bind(void 0, e.client_id));
578
+ const { claims: i, jwt: c } = await Et(r.id_token, Rt.bind(void 0, e.id_token_signed_response_alg, t.id_token_signing_alg_values_supported), ke, W(e), ge(e), e[Ne]).then(_t.bind(void 0, ["aud", "exp", "iat", "iss", "sub"])).then(mt.bind(void 0, t.issuer)).then(wt.bind(void 0, e.client_id));
582
579
  if (Array.isArray(i.aud) && i.aud.length !== 1) {
583
580
  if (i.azp === void 0)
584
581
  throw new a('ID Token "aud" (audience) claim includes additional untrusted audiences');
@@ -587,15 +584,15 @@ async function ve(t, e, n, o = !1, s = !1) {
587
584
  }
588
585
  if (i.auth_time !== void 0 && (!Number.isFinite(i.auth_time) || Math.sign(i.auth_time) !== 1))
589
586
  throw new a('ID Token "auth_time" (authentication time) must be a positive number');
590
- _e.set(r, [i, c]);
587
+ ve.set(r, [i, c]);
591
588
  }
592
589
  }
593
590
  return r;
594
591
  }
595
- async function _t(t, e, n) {
596
- return ve(t, e, n);
592
+ async function he(t, e, n) {
593
+ return Se(t, e, n);
597
594
  }
598
- function vt(t, e) {
595
+ function wt(t, e) {
599
596
  if (Array.isArray(e.claims.aud)) {
600
597
  if (!e.claims.aud.includes(t))
601
598
  throw new a('unexpected JWT "aud" (audience) claim value');
@@ -603,29 +600,29 @@ function vt(t, e) {
603
600
  throw new a('unexpected JWT "aud" (audience) claim value');
604
601
  return e;
605
602
  }
606
- function St(t, e) {
603
+ function mt(t, e) {
607
604
  if (e.claims.iss !== t)
608
605
  throw new a('unexpected JWT "iss" (issuer) claim value');
609
606
  return e;
610
607
  }
611
- const Se = /* @__PURE__ */ new WeakSet();
612
- function Tt(t) {
613
- return Se.add(t), t;
608
+ const Te = /* @__PURE__ */ new WeakSet();
609
+ function gt(t) {
610
+ return Te.add(t), t;
614
611
  }
615
- async function At(t, e, n, o, s, r) {
616
- if (I(t), j(e), !Se.has(n))
612
+ async function yt(t, e, n, o, s, r) {
613
+ if (C(t), I(e), !Te.has(n))
617
614
  throw new TypeError('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()');
618
615
  if (!w(o))
619
616
  throw new TypeError('"redirectUri" must be a non-empty string');
620
617
  if (!w(s))
621
618
  throw new TypeError('"codeVerifier" must be a non-empty string');
622
- const i = S(n, "code");
619
+ const i = T(n, "code");
623
620
  if (!i)
624
621
  throw new a('no authorization code in "callbackParameters"');
625
622
  const c = new URLSearchParams(r?.additionalParameters);
626
- return c.set("redirect_uri", o), c.set("code_verifier", s), c.set("code", i), be(t, e, "authorization_code", c, r);
623
+ return c.set("redirect_uri", o), c.set("code_verifier", s), c.set("code", i), _e(t, e, "authorization_code", c, r);
627
624
  }
628
- const Et = {
625
+ const bt = {
629
626
  aud: "audience",
630
627
  c_hash: "code hash",
631
628
  client_id: "client id",
@@ -641,33 +638,33 @@ const Et = {
641
638
  htu: "http uri",
642
639
  cnf: "confirmation"
643
640
  };
644
- function kt(t, e) {
641
+ function _t(t, e) {
645
642
  for (const n of t)
646
643
  if (e.claims[n] === void 0)
647
- throw new a(`JWT "${n}" (${Et[n]}) claim missing`);
644
+ throw new a(`JWT "${n}" (${bt[n]}) claim missing`);
648
645
  return e;
649
646
  }
650
- const Rt = Symbol(), $ = Symbol();
651
- async function Pt(t, e, n, o, s) {
652
- const r = await ve(t, e, n);
653
- if (q(r))
647
+ const vt = Symbol(), H = Symbol();
648
+ async function St(t, e, n, o, s) {
649
+ const r = await Se(t, e, n);
650
+ if (B(r))
654
651
  return r;
655
652
  if (!w(r.id_token))
656
653
  throw new a('"response" body "id_token" property must be a non-empty string');
657
- s ?? (s = e.default_max_age ?? $);
658
- const i = bt(r);
659
- if ((e.require_auth_time || s !== $) && i.auth_time === void 0)
654
+ s ?? (s = e.default_max_age ?? H);
655
+ const i = pt(r);
656
+ if ((e.require_auth_time || s !== H) && i.auth_time === void 0)
660
657
  throw new a('ID Token "auth_time" (authentication time) claim missing');
661
- if (s !== $) {
658
+ if (s !== H) {
662
659
  if (typeof s != "number" || s < 0)
663
660
  throw new TypeError('"maxAge" must be a non-negative number');
664
- const c = Q() + K(e), f = me(e);
661
+ const c = Z() + W(e), f = ge(e);
665
662
  if (i.auth_time + s < c - f)
666
663
  throw new a("too much time has elapsed since the last End-User authentication");
667
664
  }
668
665
  switch (o) {
669
666
  case void 0:
670
- case Rt:
667
+ case vt:
671
668
  if (i.nonce !== void 0)
672
669
  throw new a('unexpected ID Token "nonce" claim value');
673
670
  break;
@@ -681,26 +678,26 @@ async function Pt(t, e, n, o, s) {
681
678
  }
682
679
  return r;
683
680
  }
684
- function X(t) {
681
+ function Q(t) {
685
682
  if (t.bodyUsed)
686
683
  throw new TypeError('"response" body has been used already');
687
684
  }
688
- async function Lt(t) {
685
+ async function Tt(t) {
689
686
  if (t.status > 399 && t.status < 500) {
690
- X(t);
687
+ Q(t);
691
688
  try {
692
689
  const e = await t.json();
693
- if (C(e) && typeof e.error == "string" && e.error.length)
690
+ if (x(e) && typeof e.error == "string" && e.error.length)
694
691
  return e.error_description !== void 0 && typeof e.error_description != "string" && delete e.error_description, e.error_uri !== void 0 && typeof e.error_uri != "string" && delete e.error_uri, e.algs !== void 0 && typeof e.algs != "string" && delete e.algs, e.scope !== void 0 && typeof e.scope != "string" && delete e.scope, e;
695
692
  } catch {
696
693
  }
697
694
  }
698
695
  }
699
- function le(t) {
696
+ function fe(t) {
700
697
  if (typeof t.modulusLength != "number" || t.modulusLength < 2048)
701
698
  throw new a(`${t.name} modulusLength must be at least 2048 bits`);
702
699
  }
703
- function Ut(t) {
700
+ function At(t) {
704
701
  switch (t) {
705
702
  case "P-256":
706
703
  return "SHA-256";
@@ -712,15 +709,15 @@ function Ut(t) {
712
709
  throw new v();
713
710
  }
714
711
  }
715
- function Te(t) {
712
+ function Ae(t) {
716
713
  switch (t.algorithm.name) {
717
714
  case "ECDSA":
718
715
  return {
719
716
  name: t.algorithm.name,
720
- hash: Ut(t.algorithm.namedCurve)
717
+ hash: At(t.algorithm.namedCurve)
721
718
  };
722
719
  case "RSA-PSS":
723
- switch (le(t.algorithm), t.algorithm.hash.name) {
720
+ switch (fe(t.algorithm), t.algorithm.hash.name) {
724
721
  case "SHA-256":
725
722
  case "SHA-384":
726
723
  case "SHA-512":
@@ -732,20 +729,20 @@ function Te(t) {
732
729
  throw new v();
733
730
  }
734
731
  case "RSASSA-PKCS1-v1_5":
735
- return le(t.algorithm), t.algorithm.name;
732
+ return fe(t.algorithm), t.algorithm.name;
736
733
  case "Ed448":
737
734
  case "Ed25519":
738
735
  return t.algorithm.name;
739
736
  }
740
737
  throw new v();
741
738
  }
742
- const Ae = Symbol();
743
- async function xt(t, e, n, o) {
739
+ const ke = Symbol();
740
+ async function kt(t, e, n, o) {
744
741
  const s = `${t}.${e}`;
745
- if (!await crypto.subtle.verify(Te(n), n, o, E(s)))
742
+ if (!await crypto.subtle.verify(Ae(n), n, o, E(s)))
746
743
  throw new a("JWT signature verification failed");
747
744
  }
748
- async function Ct(t, e, n, o, s, r) {
745
+ async function Et(t, e, n, o, s, r) {
749
746
  let { 0: i, 1: c, 2: f, length: y } = t.split(".");
750
747
  if (y === 5)
751
748
  if (r !== void 0)
@@ -756,30 +753,30 @@ async function Ct(t, e, n, o, s, r) {
756
753
  throw new a("Invalid JWT");
757
754
  let p;
758
755
  try {
759
- p = JSON.parse(E(T(i)));
756
+ p = JSON.parse(E(A(i)));
760
757
  } catch (l) {
761
758
  throw new a("failed to parse JWT Header body as base64url encoded JSON", { cause: l });
762
759
  }
763
- if (!C(p))
760
+ if (!x(p))
764
761
  throw new a("JWT Header must be a top level object");
765
762
  if (e(p), p.crit !== void 0)
766
763
  throw new a('unexpected JWT "crit" header parameter');
767
- const A = T(f);
764
+ const k = A(f);
768
765
  let b;
769
- n !== Ae && (b = await n(p), await xt(i, c, b, A));
766
+ n !== ke && (b = await n(p), await kt(i, c, b, k));
770
767
  let h;
771
768
  try {
772
- h = JSON.parse(E(T(c)));
769
+ h = JSON.parse(E(A(c)));
773
770
  } catch (l) {
774
771
  throw new a("failed to parse JWT Payload body as base64url encoded JSON", { cause: l });
775
772
  }
776
- if (!C(h))
773
+ if (!x(h))
777
774
  throw new a("JWT Payload must be a top level object");
778
- const R = Q() + o;
775
+ const P = Z() + o;
779
776
  if (h.exp !== void 0) {
780
777
  if (typeof h.exp != "number")
781
778
  throw new a('unexpected JWT "exp" (expiration time) claim type');
782
- if (h.exp <= R - s)
779
+ if (h.exp <= P - s)
783
780
  throw new a('unexpected JWT "exp" (expiration time) claim value, timestamp is <= now()');
784
781
  }
785
782
  if (h.iat !== void 0 && typeof h.iat != "number")
@@ -789,14 +786,14 @@ async function Ct(t, e, n, o, s, r) {
789
786
  if (h.nbf !== void 0) {
790
787
  if (typeof h.nbf != "number")
791
788
  throw new a('unexpected JWT "nbf" (not before) claim type');
792
- if (h.nbf > R + s)
789
+ if (h.nbf > P + s)
793
790
  throw new a('unexpected JWT "nbf" (not before) claim value, timestamp is > now()');
794
791
  }
795
792
  if (h.aud !== void 0 && typeof h.aud != "string" && !Array.isArray(h.aud))
796
793
  throw new a('unexpected JWT "aud" (audience) claim type');
797
- return { header: p, claims: h, signature: A, key: b, jwt: t };
794
+ return { header: p, claims: h, signature: k, key: b, jwt: t };
798
795
  }
799
- function It(t, e, n) {
796
+ function Rt(t, e, n) {
800
797
  if (t !== void 0) {
801
798
  if (n.alg !== t)
802
799
  throw new a('unexpected JWT "alg" header parameter');
@@ -810,30 +807,30 @@ function It(t, e, n) {
810
807
  if (n.alg !== "RS256")
811
808
  throw new a('unexpected JWT "alg" header parameter');
812
809
  }
813
- function S(t, e) {
810
+ function T(t, e) {
814
811
  const { 0: n, length: o } = t.getAll(e);
815
812
  if (o > 1)
816
813
  throw new a(`"${e}" parameter must be provided only once`);
817
814
  return n;
818
815
  }
819
- const jt = Symbol(), Ot = Symbol();
820
- function zt(t, e, n, o) {
821
- if (I(t), j(e), n instanceof URL && (n = n.searchParams), !(n instanceof URLSearchParams))
816
+ const Pt = Symbol(), Lt = Symbol();
817
+ function Ut(t, e, n, o) {
818
+ if (C(t), I(e), n instanceof URL && (n = n.searchParams), !(n instanceof URLSearchParams))
822
819
  throw new TypeError('"parameters" must be an instance of URLSearchParams, or URL');
823
- if (S(n, "response"))
820
+ if (T(n, "response"))
824
821
  throw new a('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()');
825
- const s = S(n, "iss"), r = S(n, "state");
822
+ const s = T(n, "iss"), r = T(n, "state");
826
823
  if (!s && t.authorization_response_iss_parameter_supported)
827
824
  throw new a('response parameter "iss" (issuer) missing');
828
825
  if (s && s !== t.issuer)
829
826
  throw new a('unexpected "iss" (issuer) response parameter value');
830
827
  switch (o) {
831
828
  case void 0:
832
- case Ot:
829
+ case Lt:
833
830
  if (r !== void 0)
834
831
  throw new a('unexpected "state" response parameter encountered');
835
832
  break;
836
- case jt:
833
+ case Pt:
837
834
  break;
838
835
  default:
839
836
  if (!w(o))
@@ -843,84 +840,20 @@ function zt(t, e, n, o) {
843
840
  if (r !== o)
844
841
  throw new a('unexpected "state" response parameter value');
845
842
  }
846
- const i = S(n, "error");
843
+ const i = T(n, "error");
847
844
  if (i)
848
845
  return {
849
846
  error: i,
850
- error_description: S(n, "error_description"),
851
- error_uri: S(n, "error_uri")
847
+ error_description: T(n, "error_description"),
848
+ error_uri: T(n, "error_uri")
852
849
  };
853
- const c = S(n, "id_token"), f = S(n, "token");
850
+ const c = T(n, "id_token"), f = T(n, "token");
854
851
  if (c !== void 0 || f !== void 0)
855
852
  throw new v("implicit and hybrid flows are not supported");
856
- return Tt(new URLSearchParams(n));
857
- }
858
- class Jt {
859
- getRoutes() {
860
- return [
861
- {
862
- path: "/signout",
863
- element: /* @__PURE__ */ L.jsx(Ie, {})
864
- },
865
- {
866
- path: "/signin",
867
- element: /* @__PURE__ */ L.jsx(je, {})
868
- },
869
- {
870
- path: "/signup",
871
- element: /* @__PURE__ */ L.jsx(Oe, {})
872
- }
873
- ];
874
- }
875
- getProfileMenuItems() {
876
- return [
877
- {
878
- label: "Logout",
879
- path: "/signout",
880
- category: "bottom",
881
- icon: Ce
882
- }
883
- ];
884
- }
853
+ return gt(new URLSearchParams(n));
885
854
  }
886
- function Dt(t, e, n = "/") {
887
- return t.startsWith(e) ? n !== "/" && t.startsWith(e + n) ? t.slice(e.length + n.length) : t.slice(e.length) : t;
888
- }
889
- function Nt({
890
- handleCallback: t
891
- }) {
892
- const { options: e } = Je(), n = xe({
893
- retry: !1,
894
- queryKey: ["oauth-callback"],
895
- queryFn: async () => {
896
- try {
897
- return fe(
898
- Dt(
899
- await t(),
900
- window.location.origin,
901
- e.basePath
902
- )
903
- );
904
- } catch (o) {
905
- throw new Le("Could not validate user", {
906
- cause: o,
907
- title: "Authentication Error",
908
- developerHint: "Check the configuration of your authorization provider and ensure all settings such as the callback URL are configured correctly."
909
- });
910
- }
911
- }
912
- });
913
- return /* @__PURE__ */ L.jsx(ze, { to: n.data });
914
- }
915
- class k extends Error {
916
- }
917
- class de extends k {
918
- constructor(e, n, o) {
919
- super(e, o), this.error = n;
920
- }
921
- }
922
- const F = "code-verifier", M = "oauth-state", he = "/oauth/callback";
923
- class Wt extends Jt {
855
+ const $ = "code-verifier", F = "oauth-state", pe = "/oauth/callback";
856
+ class xt extends Ce {
924
857
  client;
925
858
  issuer;
926
859
  authorizationServer;
@@ -944,12 +877,12 @@ class Wt extends Jt {
944
877
  super(), this.client = {
945
878
  client_id: o,
946
879
  token_endpoint_auth_method: "none"
947
- }, this.audience = n, this.issuer = e, this.callbackUrlPath = fe(c, he), this.scopes = f ?? ["openid", "profile", "email"], this.redirectToAfterSignUp = s, this.redirectToAfterSignIn = r, this.redirectToAfterSignOut = i;
880
+ }, this.audience = n, this.issuer = e, this.callbackUrlPath = xe(c, pe), this.scopes = f ?? ["openid", "profile", "email"], this.redirectToAfterSignUp = s, this.redirectToAfterSignIn = r, this.redirectToAfterSignOut = i;
948
881
  }
949
882
  async getAuthServer() {
950
883
  if (!this.authorizationServer) {
951
- const e = new URL(this.issuer), n = await et(e);
952
- this.authorizationServer = await tt(
884
+ const e = new URL(this.issuer), n = await Ye(e);
885
+ this.authorizationServer = await Ze(
953
886
  e,
954
887
  n
955
888
  );
@@ -961,10 +894,10 @@ class Wt extends Jt {
961
894
  * @param response
962
895
  */
963
896
  setTokensFromResponse(e) {
964
- if (q(e))
965
- throw oe.error("Bad Token Response", e), new de("Bad Token Response", e);
897
+ if (B(e))
898
+ throw ie.error("Bad Token Response", e), new re("Bad Token Response", e);
966
899
  if (!e.expires_in)
967
- throw new k("No expires_in in response");
900
+ throw new R("No expires_in in response");
968
901
  const n = {
969
902
  accessToken: e.access_token,
970
903
  refreshToken: e.refresh_token,
@@ -972,7 +905,7 @@ class Wt extends Jt {
972
905
  expiresOn: new Date(Date.now() + e.expires_in * 1e3),
973
906
  tokenType: e.token_type
974
907
  };
975
- x.setState({
908
+ S.setState({
976
909
  providerData: n
977
910
  });
978
911
  }
@@ -993,9 +926,9 @@ class Wt extends Jt {
993
926
  }) {
994
927
  const o = "S256", s = await this.getAuthServer();
995
928
  if (!s.authorization_endpoint)
996
- throw new k("No authorization endpoint");
997
- const r = nt(), i = await ot(r);
998
- sessionStorage.setItem(F, r);
929
+ throw new R("No authorization endpoint");
930
+ const r = Qe(), i = await et(r);
931
+ sessionStorage.setItem($, r);
999
932
  const c = new URL(
1000
933
  s.authorization_endpoint
1001
934
  );
@@ -1008,33 +941,33 @@ class Wt extends Jt {
1008
941
  isSignIn: !n,
1009
942
  isSignUp: n
1010
943
  });
1011
- const y = rt();
1012
- sessionStorage.setItem(M, y), c.searchParams.set("state", y), location.href = c.href;
944
+ const y = Xe();
945
+ sessionStorage.setItem(F, y), c.searchParams.set("state", y), location.href = c.href;
1013
946
  }
1014
947
  async getAccessToken() {
1015
- const e = await this.getAuthServer(), { providerData: n } = x.getState();
948
+ const e = await this.getAuthServer(), { providerData: n } = S.getState();
1016
949
  if (!n)
1017
- throw new k("User is not authenticated");
950
+ throw new R("User is not authenticated");
1018
951
  const o = n;
1019
952
  if (new Date(o.expiresOn) < /* @__PURE__ */ new Date()) {
1020
953
  if (!o.refreshToken)
1021
- return x.setState({
954
+ return S.setState({
1022
955
  isAuthenticated: !1,
1023
956
  isPending: !1,
1024
957
  profile: null,
1025
958
  providerData: null
1026
959
  }), "";
1027
- const s = await yt(
960
+ const s = await de(
1028
961
  e,
1029
962
  this.client,
1030
963
  o.refreshToken
1031
- ), r = await _t(
964
+ ), r = await he(
1032
965
  e,
1033
966
  this.client,
1034
967
  s
1035
968
  );
1036
969
  if (!r.access_token)
1037
- throw new k("No access token in response");
970
+ throw new R("No access token in response");
1038
971
  return this.setTokensFromResponse(r), r.access_token.toString();
1039
972
  } else
1040
973
  return o.accessToken;
@@ -1044,7 +977,7 @@ class Wt extends Jt {
1044
977
  return e.headers.set("Authorization", `Bearer ${n}`), e;
1045
978
  };
1046
979
  signOut = async () => {
1047
- x.setState({
980
+ S.setState({
1048
981
  isAuthenticated: !1,
1049
982
  isPending: !1,
1050
983
  profile: void 0,
@@ -1060,39 +993,81 @@ class Wt extends Jt {
1060
993
  n.toString()
1061
994
  )) : o = n;
1062
995
  };
996
+ onPageLoad = async () => {
997
+ const { providerData: e } = S.getState();
998
+ if (!e) {
999
+ S.setState({ isPending: !1 });
1000
+ return;
1001
+ }
1002
+ const n = e;
1003
+ if (new Date(n.expiresOn) < /* @__PURE__ */ new Date()) {
1004
+ if (!n.refreshToken) {
1005
+ S.setState({
1006
+ isAuthenticated: !1,
1007
+ isPending: !1,
1008
+ profile: null,
1009
+ providerData: null
1010
+ });
1011
+ return;
1012
+ }
1013
+ try {
1014
+ const o = await this.getAuthServer(), s = await de(
1015
+ o,
1016
+ this.client,
1017
+ n.refreshToken
1018
+ ), r = await he(
1019
+ o,
1020
+ this.client,
1021
+ s
1022
+ );
1023
+ if (!r.access_token)
1024
+ throw new R("No access token in response");
1025
+ this.setTokensFromResponse(r);
1026
+ } catch {
1027
+ S.setState({
1028
+ isAuthenticated: !1,
1029
+ isPending: !1,
1030
+ profile: null,
1031
+ providerData: null
1032
+ });
1033
+ return;
1034
+ }
1035
+ }
1036
+ S.setState({ isPending: !1 });
1037
+ };
1063
1038
  handleCallback = async () => {
1064
- const e = new URL(window.location.href), n = e.searchParams.get("state"), o = sessionStorage.getItem(M);
1065
- if (sessionStorage.removeItem(M), n !== o)
1066
- throw new k("Invalid state parameter");
1067
- const s = sessionStorage.getItem(F);
1068
- if (sessionStorage.removeItem(F), !s)
1069
- throw new k("No code verifier found in state.");
1070
- const r = await this.getAuthServer(), i = zt(
1039
+ const e = new URL(window.location.href), n = e.searchParams.get("state"), o = sessionStorage.getItem(F);
1040
+ if (sessionStorage.removeItem(F), n !== o)
1041
+ throw new R("Invalid state parameter");
1042
+ const s = sessionStorage.getItem($);
1043
+ if (sessionStorage.removeItem($), !s)
1044
+ throw new R("No code verifier found in state.");
1045
+ const r = await this.getAuthServer(), i = Ut(
1071
1046
  r,
1072
1047
  this.client,
1073
1048
  e.searchParams,
1074
1049
  n ?? void 0
1075
1050
  );
1076
- if (q(i))
1077
- throw oe.error("Error validating OAuth response", i), new de(
1051
+ if (B(i))
1052
+ throw ie.error("Error validating OAuth response", i), new re(
1078
1053
  "Error validating OAuth response",
1079
1054
  i
1080
1055
  );
1081
1056
  const c = new URL(e);
1082
1057
  c.pathname = this.callbackUrlPath, c.search = "";
1083
- const f = await At(
1058
+ const f = await yt(
1084
1059
  r,
1085
1060
  this.client,
1086
1061
  i,
1087
1062
  c.toString(),
1088
1063
  s
1089
- ), y = await Pt(
1064
+ ), y = await St(
1090
1065
  r,
1091
1066
  this.client,
1092
1067
  f
1093
1068
  );
1094
1069
  this.setTokensFromResponse(y);
1095
- const p = await this.getAccessToken(), b = await (await mt(
1070
+ const p = await this.getAccessToken(), b = await (await ht(
1096
1071
  r,
1097
1072
  this.client,
1098
1073
  p
@@ -1103,28 +1078,28 @@ class Wt extends Jt {
1103
1078
  emailVerified: b.email_verified ?? !1,
1104
1079
  pictureUrl: b.picture
1105
1080
  };
1106
- x.setState({
1081
+ S.setState({
1107
1082
  isAuthenticated: !0,
1108
1083
  isPending: !1,
1109
1084
  profile: h
1110
1085
  });
1111
- const R = sessionStorage.getItem("redirect-to") ?? "/";
1112
- return sessionStorage.removeItem("redirect-to"), R;
1086
+ const P = sessionStorage.getItem("redirect-to") ?? "/";
1087
+ return sessionStorage.removeItem("redirect-to"), P;
1113
1088
  };
1114
1089
  getRoutes() {
1115
1090
  return [
1116
1091
  ...super.getRoutes(),
1117
1092
  {
1118
- path: he,
1119
- element: /* @__PURE__ */ L.jsx(Ue, { children: /* @__PURE__ */ L.jsx(Nt, { handleCallback: this.handleCallback }) })
1093
+ path: pe,
1094
+ element: /* @__PURE__ */ ne.jsx(Ue, { children: /* @__PURE__ */ ne.jsx(Ie, { handleCallback: this.handleCallback }) })
1120
1095
  }
1121
1096
  ];
1122
1097
  }
1123
1098
  }
1124
- const Gt = (t) => new Wt(t);
1099
+ const Jt = (t) => new xt(t);
1125
1100
  export {
1126
- he as OPENID_CALLBACK_PATH,
1127
- Wt as OpenIDAuthenticationProvider,
1128
- Gt as default
1101
+ pe as OPENID_CALLBACK_PATH,
1102
+ xt as OpenIDAuthenticationProvider,
1103
+ Jt as default
1129
1104
  };
1130
1105
  //# sourceMappingURL=zudoku.auth-openid.js.map