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