zudoku 0.13.5 → 0.13.6

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