zudoku 0.3.1-dev.2 → 0.3.1-dev.20

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 (125) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/lib/authentication/authentication.d.ts +1 -0
  3. package/dist/lib/authentication/components/CallbackHandler.d.ts +3 -0
  4. package/dist/lib/authentication/components/CallbackHandler.js +34 -0
  5. package/dist/lib/authentication/components/CallbackHandler.js.map +1 -0
  6. package/dist/lib/authentication/providers/auth0.js +20 -1
  7. package/dist/lib/authentication/providers/auth0.js.map +1 -1
  8. package/dist/lib/authentication/providers/openid.d.ts +3 -10
  9. package/dist/lib/authentication/providers/openid.js +46 -31
  10. package/dist/lib/authentication/providers/openid.js.map +1 -1
  11. package/dist/lib/components/Header.js +2 -4
  12. package/dist/lib/components/Header.js.map +1 -1
  13. package/dist/lib/components/Layout.js +5 -1
  14. package/dist/lib/components/Layout.js.map +1 -1
  15. package/dist/lib/components/context/ZudokuProvider.js +1 -3
  16. package/dist/lib/components/context/ZudokuProvider.js.map +1 -1
  17. package/dist/lib/core/DevPortalContext.d.ts +1 -4
  18. package/dist/lib/core/DevPortalContext.js +2 -2
  19. package/dist/lib/core/DevPortalContext.js.map +1 -1
  20. package/dist/lib/core/plugins.d.ts +2 -4
  21. package/dist/lib/core/plugins.js.map +1 -1
  22. package/dist/lib/plugins/openapi/OperationList.js +3 -4
  23. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  24. package/dist/lib/plugins/openapi/OperationListItem.js +2 -3
  25. package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
  26. package/dist/lib/plugins/openapi/ParameterListItem.js +1 -1
  27. package/dist/lib/plugins/openapi/ParameterListItem.js.map +1 -1
  28. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +2 -2
  29. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
  30. package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroup.d.ts +9 -0
  31. package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroup.js +14 -0
  32. package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroup.js.map +1 -0
  33. package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupConnector.d.ts +6 -0
  34. package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupConnector.js +17 -0
  35. package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupConnector.js.map +1 -0
  36. package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupItem.d.ts +7 -0
  37. package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupItem.js +10 -0
  38. package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupItem.js.map +1 -0
  39. package/dist/lib/plugins/openapi/schema/SchemaComponents.d.ts +3 -3
  40. package/dist/lib/plugins/openapi/schema/SchemaComponents.js +15 -15
  41. package/dist/lib/plugins/openapi/schema/SchemaComponents.js.map +1 -1
  42. package/dist/lib/plugins/openapi/schema/SchemaView.js +1 -1
  43. package/dist/lib/plugins/openapi/schema/SchemaView.js.map +1 -1
  44. package/dist/lib/plugins/openapi/schema/utils.d.ts +6 -0
  45. package/dist/lib/plugins/openapi/schema/utils.js +5 -0
  46. package/dist/lib/plugins/openapi/schema/utils.js.map +1 -1
  47. package/lib/{AuthenticationPlugin-CH5NSVOu.js → AuthenticationPlugin-owbEUimP.js} +3 -3
  48. package/lib/{AuthenticationPlugin-CH5NSVOu.js.map → AuthenticationPlugin-owbEUimP.js.map} +1 -1
  49. package/lib/{CategoryHeading-z15xh7Jb.js → CategoryHeading-DnPprxtD.js} +2 -2
  50. package/lib/{CategoryHeading-z15xh7Jb.js.map → CategoryHeading-DnPprxtD.js.map} +1 -1
  51. package/lib/{Combination-DTfV-c98.js → Combination-DruV0zX_.js} +3 -3
  52. package/lib/{Combination-DTfV-c98.js.map → Combination-DruV0zX_.js.map} +1 -1
  53. package/lib/ErrorPage-PUg985n_.js +18 -0
  54. package/lib/ErrorPage-PUg985n_.js.map +1 -0
  55. package/lib/{Input-DB9VROFR.js → Input-CBfi9Yjc.js} +5 -4
  56. package/lib/{Input-DB9VROFR.js.map → Input-CBfi9Yjc.js.map} +1 -1
  57. package/lib/{Markdown-CEccPMI_.js → Markdown-Chb9VIBv.js} +2 -2
  58. package/lib/{Markdown-CEccPMI_.js.map → Markdown-Chb9VIBv.js.map} +1 -1
  59. package/lib/{MdxPage-CnqOoqvp.js → MdxPage-CIBHMwTd.js} +5 -5
  60. package/lib/{MdxPage-CnqOoqvp.js.map → MdxPage-CIBHMwTd.js.map} +1 -1
  61. package/lib/OperationList-CZiSz5JH.js +590 -0
  62. package/lib/OperationList-CZiSz5JH.js.map +1 -0
  63. package/lib/{Route-DfAFiR7v.js → Route-Cle-r-bq.js} +4 -4
  64. package/lib/{Route-DfAFiR7v.js.map → Route-Cle-r-bq.js.map} +1 -1
  65. package/lib/{Spinner-BT_AYFrA.js → SidebarBadge-Ba0PhibA.js} +66 -76
  66. package/lib/SidebarBadge-Ba0PhibA.js.map +1 -0
  67. package/lib/{SlotletProvider-ByLSCZQa.js → SlotletProvider-Dq80og6-.js} +4 -4
  68. package/lib/{SlotletProvider-ByLSCZQa.js.map → SlotletProvider-Dq80og6-.js.map} +1 -1
  69. package/lib/Spinner-CvXZ7QK4.js +15 -0
  70. package/lib/Spinner-CvXZ7QK4.js.map +1 -0
  71. package/lib/{ZudokuContext-BIZ8zHbZ.js → ZudokuContext-BQ45UjcB.js} +2 -2
  72. package/lib/{ZudokuContext-BIZ8zHbZ.js.map → ZudokuContext-BQ45UjcB.js.map} +1 -1
  73. package/lib/{index-D-9zqIOh.js → index-Br1MQPxy.js} +595 -587
  74. package/lib/index-Br1MQPxy.js.map +1 -0
  75. package/lib/{index-Dz4LyXZI.js → index-DCJ9wEIV.js} +3 -3
  76. package/lib/{index-Dz4LyXZI.js.map → index-DCJ9wEIV.js.map} +1 -1
  77. package/lib/{index-7kcHaXD6.js → index-Yjb2PyPF.js} +4 -4
  78. package/lib/{index-7kcHaXD6.js.map → index-Yjb2PyPF.js.map} +1 -1
  79. package/lib/{urql-DrBfkb92.js → urql-YhcsXYy8.js} +2 -2
  80. package/lib/urql-YhcsXYy8.js.map +1 -0
  81. package/lib/{utils-Bh4upQ0e.js → utils-pDHePxa0.js} +3 -3
  82. package/lib/{utils-Bh4upQ0e.js.map → utils-pDHePxa0.js.map} +1 -1
  83. package/lib/zudoku.auth-auth0.js +31 -17
  84. package/lib/zudoku.auth-auth0.js.map +1 -1
  85. package/lib/zudoku.auth-clerk.js +1 -1
  86. package/lib/zudoku.auth-openid.js +491 -421
  87. package/lib/zudoku.auth-openid.js.map +1 -1
  88. package/lib/zudoku.components.js +434 -443
  89. package/lib/zudoku.components.js.map +1 -1
  90. package/lib/zudoku.openapi-worker.js +1 -1
  91. package/lib/zudoku.plugin-api-keys.js +6 -6
  92. package/lib/zudoku.plugin-custom-page.js +1 -1
  93. package/lib/zudoku.plugin-markdown.js +1 -1
  94. package/lib/zudoku.plugin-openapi.js +8 -7
  95. package/lib/zudoku.plugin-openapi.js.map +1 -1
  96. package/package.json +80 -100
  97. package/src/app/main.css +26 -1
  98. package/src/lib/authentication/authentication.ts +1 -0
  99. package/src/lib/authentication/components/CallbackHandler.tsx +59 -0
  100. package/src/lib/authentication/providers/auth0.tsx +28 -2
  101. package/src/lib/authentication/providers/openid.tsx +50 -37
  102. package/src/lib/components/Header.tsx +3 -10
  103. package/src/lib/components/Layout.tsx +6 -1
  104. package/src/lib/components/context/ZudokuProvider.tsx +1 -4
  105. package/src/lib/core/DevPortalContext.ts +2 -7
  106. package/src/lib/core/plugins.ts +1 -2
  107. package/src/lib/plugins/openapi/OperationList.tsx +3 -7
  108. package/src/lib/plugins/openapi/OperationListItem.tsx +3 -4
  109. package/src/lib/plugins/openapi/ParameterListItem.tsx +1 -1
  110. package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +27 -5
  111. package/src/lib/plugins/openapi/schema/LogicalGroup/LogicalGroup.tsx +47 -0
  112. package/src/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupConnector.tsx +54 -0
  113. package/src/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupItem.tsx +30 -0
  114. package/src/lib/plugins/openapi/schema/SchemaComponents.tsx +41 -41
  115. package/src/lib/plugins/openapi/schema/SchemaView.tsx +4 -4
  116. package/src/lib/plugins/openapi/schema/utils.ts +8 -0
  117. package/dist/lib/plugins/openapi/util/prose.d.ts +0 -1
  118. package/dist/lib/plugins/openapi/util/prose.js +0 -4
  119. package/dist/lib/plugins/openapi/util/prose.js.map +0 -1
  120. package/lib/OperationList-Cxiw2Z-v.js +0 -457
  121. package/lib/OperationList-Cxiw2Z-v.js.map +0 -1
  122. package/lib/Spinner-BT_AYFrA.js.map +0 -1
  123. package/lib/index-D-9zqIOh.js.map +0 -1
  124. package/lib/urql-DrBfkb92.js.map +0 -1
  125. package/src/lib/plugins/openapi/util/prose.ts +0 -7
@@ -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 xe = Object.defineProperty;
2
+ var Le = (t, e, n) => e in t ? xe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var y = (t, e, n) => Le(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { j as k } 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 ze, useRef as Je, useEffect as Oe } from "react";
8
+ import { D as Ne } 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 N } from "./state-DsXXkBLH.js";
14
+ var fe = { exports: {} };
9
15
  (function(t) {
10
16
  (function(e, n) {
11
17
  t.exports ? t.exports = n() : e.log = n();
12
- })(Ue, function() {
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
+ }, n = "undefined", o = typeof window !== n && typeof window.navigator !== n && /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
+ ], r = {}, 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 {
@@ -30,46 +36,46 @@ var de = { exports: {} };
30
36
  };
31
37
  }
32
38
  }
33
- function f() {
39
+ function h() {
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 === n ? !1 : l === "trace" && o ? h : 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 b() {
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
50
  if (this.log = this.debug, typeof console === n && l < this.levels.SILENT)
45
51
  return "No console available for logging";
46
52
  }
47
- function b(l) {
53
+ function _(l) {
48
54
  return function() {
49
- typeof console !== n && (_.call(this), this[l].apply(this, arguments));
55
+ typeof console !== n && (b.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 f(l, w, c) {
59
+ return m(l) || _.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, J, B, U, 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();
64
+ function Re(d) {
65
+ var g = (s[d] || "silent").toUpperCase();
60
66
  if (!(typeof window === n || !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 re() {
73
79
  var d;
74
80
  if (!(typeof window === n || !v)) {
75
81
  try {
@@ -78,16 +84,16 @@ var de = { exports: {} };
78
84
  }
79
85
  if (typeof d === n)
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, O = encodeURIComponent(v), ie = g.indexOf(O + "=");
88
+ ie !== -1 && (d = /^([^;]+)/.exec(
89
+ g.slice(ie + O.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() {
96
+ function Pe() {
91
97
  if (!(typeof window === n || !v)) {
92
98
  try {
93
99
  window.localStorage.removeItem(v);
@@ -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 || f, c.getLevel = function() {
122
+ return U ?? B ?? J;
123
+ }, c.setLevel = function(d, g) {
124
+ return U = L(d), g !== !1 && Re(U), b.call(c);
119
125
  }, c.setDefaultLevel = function(d) {
120
- H = U(d), X() || c.setLevel(d, !1);
126
+ B = L(d), re() || c.setLevel(d, !1);
121
127
  }, c.resetLevel = function() {
122
- R = null, Ae(), _.call(c);
128
+ U = null, Pe(), b.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 && (J = L(i.getLevel())), b.call(c), i === c)
135
+ for (var d in r)
136
+ r[d].rebuild();
137
+ }, J = L(
132
138
  i ? i.getLevel() : "WARN"
133
139
  );
134
- var ee = X();
135
- ee != null && (R = U(ee)), _.call(c);
140
+ var oe = re();
141
+ oe != null && (U = L(oe)), b.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 = r[w];
147
+ return c || (c = r[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 !== n ? 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 !== n && window.log === i && (window.log = P), i;
149
155
  }, i.getLoggers = function() {
150
- return o;
156
+ return r;
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,32 +171,32 @@ 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 n = 0; n < t.byteLength; n += se)
183
+ e.push(String.fromCharCode.apply(null, t.subarray(n, n + 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
188
  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);
189
+ for (let o = 0; o < e.length; o++)
190
+ n[o] = e.charCodeAt(o);
185
191
  return n;
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 E(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
  }
@@ -220,48 +226,48 @@ class S extends Error {
220
226
  super(e ?? "operation not supported"), this.name = this.constructor.name, (n = Error.captureStackTrace) == null || n.call(Error, this, this.constructor);
221
227
  }
222
228
  }
223
- class Ke extends Error {
229
+ class Ye extends Error {
224
230
  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);
231
+ var o;
232
+ super(e, n), 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:")
@@ -278,70 +284,70 @@ async function De(t, e) {
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)(n.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);
305
+ ne(e);
300
306
  let n;
301
307
  try {
302
308
  n = await e.json();
303
- } catch (r) {
304
- throw new a('failed to parse "response" body as JSON', { cause: r });
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(n))
307
313
  throw new a('"response" body must be a top level object');
308
- if (!m(n.issuer))
314
+ if (!p(n.issuer))
309
315
  throw new a('"response" body "issuer" property must be a non-empty string');
310
316
  if (new URL(n.issuer).href !== t.href)
311
317
  throw new a('"response" body "issuer" does not match "expectedIssuer"');
312
318
  return n;
313
319
  }
314
- function W() {
315
- return A(crypto.getRandomValues(new Uint8Array(32)));
320
+ function F() {
321
+ return E(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 nt(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 E(await crypto.subtle.digest("SHA-256", A(t)));
327
333
  }
328
- function Be(t) {
334
+ function rt(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 n = ae(t), o = ae(e);
348
+ return `Basic ${btoa(`${n}:${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,21 +398,21 @@ 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 n = M() + I(e);
408
414
  return {
409
- jti: W(),
415
+ jti: F(),
410
416
  aud: [t.issuer, t.token_endpoint],
411
417
  exp: n + 60,
412
418
  iat: n,
@@ -415,210 +421,218 @@ function Qe(t, e) {
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, n, o) {
425
+ return be({
426
+ alg: me(n),
427
+ kid: o
428
+ }, ct(t, e), n);
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 z(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) {
457
+ async function lt(t, e, n, o, s) {
452
458
  switch (n.delete("client_secret"), n.delete("client_assertion_type"), n.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), n.set("client_id", e.client_id), n.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: r, kid: i } = rt(s);
472
+ if (!ge(r))
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
+ 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));
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), n.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) {
487
+ async function be(t, e, n) {
482
488
  if (!n.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 = `${E(A(JSON.stringify(t)))}.${E(A(JSON.stringify(e)))}`, s = E(await crypto.subtle.sign(ke(n), n, 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, n, o, s, r) {
494
+ const { privateKey: i, publicKey: u, nonce: h = pe.get(n.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 (h !== void 0 && !p(h))
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, b = 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,
505
- nonce: f,
508
+ iat: m,
509
+ jti: F(),
510
+ htm: o,
511
+ nonce: h,
506
512
  htu: `${n.origin}${n.pathname}`,
507
- ath: o ? A(await crypto.subtle.digest("SHA-256", k(o))) : void 0
513
+ ath: r ? E(await crypto.subtle.digest("SHA-256", A(r))) : void 0
508
514
  }, i);
509
- t.set("dpop", _);
515
+ t.set("dpop", b);
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: n, n: o, x: s, y: r, crv: i } = await crypto.subtle.exportKey("jwk", t), u = { kty: e, e: n, n: o, x: s, y: r, 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, n) {
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, n) {
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, n, o, s, r) {
538
+ if (!p(t))
533
539
  throw new TypeError('"accessToken" must be a non-empty string');
534
540
  if (!(n 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), (r == null ? void 0 : r.DPoP) === void 0 ? o.set("authorization", `Bearer ${t}`) : (await dt(o, r.DPoP, n, "GET", I({ [H]: r == null ? void 0 : r[H] }), t), o.set("authorization", `DPoP ${t}`)), ((r == null ? void 0 : r[X]) || fetch)(n.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: r != null && r.signal ? te(r.signal) : null
548
+ }).then(ee);
549
+ }
550
+ async function gt(t, e, n, o) {
551
+ j(t), z(e);
552
+ const s = _e(t, "userinfo_endpoint"), r = $(o == null ? void 0 : o.headers);
553
+ return e.userinfo_signed_response_alg ? r.set("accept", "application/jwt") : (r.set("accept", "application/json"), r.append("accept", "application/jwt")), wt(n, "GET", s, r, null, {
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, n, o, s, r, i) {
559
+ return await lt(t, e, s, r, i == null ? void 0 : i.clientPrivateKey), r.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()),
561
+ headers: Object.fromEntries(r.entries()),
556
562
  method: n,
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, n, o, s) {
568
+ const r = _e(t, "token_endpoint");
569
+ o.set("grant_type", n);
570
+ const i = $(s == null ? void 0 : s.headers);
571
+ return i.set("accept", "application/json"), mt(t, e, "POST", r, 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, n, o) {
574
+ if (j(t), z(e), !p(n))
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", n), ve(t, e, "refresh_token", s, o);
572
578
  }
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))
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;
587
+ }
588
+ async function Te(t, e, n, o = !1, s = !1) {
589
+ if (j(t), z(e), !Q(n, Response))
576
590
  throw new TypeError('"response" must be an instance of Response');
577
591
  if (n.status !== 200) {
578
592
  let i;
579
- if (i = await yt(n))
593
+ if (i = await Ut(n))
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
+ ne(n);
598
+ let r;
585
599
  try {
586
- o = await n.json();
600
+ r = await n.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(r))
591
605
  throw new a('"response" body must be a top level object');
592
- if (!m(o.access_token))
606
+ if (!p(r.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(r.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 (r.token_type = r.token_type.toLowerCase(), r.token_type !== "dpop" && r.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 (r.expires_in !== void 0 && (typeof r.expires_in != "number" || r.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 && r.refresh_token !== void 0 && !p(r.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 (r.scope !== void 0 && typeof r.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 (r.id_token !== void 0 && !p(r.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 (r.id_token) {
622
+ const { claims: i } = await Lt(r.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(r, i);
614
628
  }
615
629
  }
616
- return o;
630
+ return r;
617
631
  }
618
- async function lt(t, e, n) {
619
- return _e(t, e, n);
632
+ async function _t(t, e, n) {
633
+ return Te(t, e, n);
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 Ee = /* @__PURE__ */ new WeakSet();
649
+ function Tt(t) {
650
+ return Ee.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 Et(t, e, n, o, s, r) {
653
+ if (j(t), z(e), !Ee.has(n))
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
659
  const i = T(n, "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(r == null ? void 0 : r.additionalParameters);
663
+ return u.set("redirect_uri", o), u.set("code_verifier", s), u.set("code", i), ve(t, e, "authorization_code", u, r);
650
664
  }
651
- const wt = {
665
+ const kt = {
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) {
681
+ function At(t, e) {
668
682
  for (const n of t)
669
683
  if (e.claims[n] === void 0)
670
- throw new a(`JWT "${n}" (${wt[n]}) claim missing`);
684
+ throw new a(`JWT "${n}" (${kt[n]}) 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))
687
+ const Rt = Symbol(), G = Symbol();
688
+ async function Pt(t, e, n, o, s) {
689
+ const r = await Te(t, e, n);
690
+ if (Z(r))
676
691
  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;
692
+ if (!p(r.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(r);
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), h = ye(e);
702
+ if (i.auth_time + s < u - h)
703
+ throw new a("too much time has elapsed since the last End-User authentication");
704
+ }
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');
681
718
  }
682
719
  return r;
683
720
  }
684
- function Q(t) {
721
+ function ne(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 Ut(t) {
689
726
  if (t.status > 399 && t.status < 500) {
690
- Q(t);
727
+ ne(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 xt(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 ke(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: xt(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,68 +769,68 @@ 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(".");
745
- if (f === 5)
779
+ const Ae = Symbol();
780
+ async function Lt(t, e, n, o, s) {
781
+ const { 0: r, 1: i, 2: u, length: h } = t.split(".");
782
+ if (h === 5)
746
783
  throw new S("JWE structure JWTs are not supported");
747
- if (f !== 3)
784
+ if (h !== 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(E(r)));
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);
760
- 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)))
796
+ const b = E(u);
797
+ let _;
798
+ if (n !== Ae) {
799
+ _ = await n(m);
800
+ const P = `${r}.${i}`;
801
+ if (!await crypto.subtle.verify(ke(_), _, b, A(P)))
765
802
  throw new a("JWT signature verification failed");
766
803
  }
767
- let h;
804
+ let f;
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
+ f = JSON.parse(A(E(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(f))
774
811
  throw new a("JWT Payload must be a top level object");
775
- const P = Z() + r;
776
- if (h.exp !== void 0) {
777
- if (typeof h.exp != "number")
812
+ const R = M() + o;
813
+ if (f.exp !== void 0) {
814
+ if (typeof f.exp != "number")
778
815
  throw new a('unexpected JWT "exp" (expiration time) claim type');
779
- if (h.exp <= P - s)
816
+ if (f.exp <= R - s)
780
817
  throw new a('unexpected JWT "exp" (expiration time) claim value, timestamp is <= now()');
781
818
  }
782
- if (h.iat !== void 0 && typeof h.iat != "number")
819
+ if (f.iat !== void 0 && typeof f.iat != "number")
783
820
  throw new a('unexpected JWT "iat" (issued at) claim type');
784
- if (h.iss !== void 0 && typeof h.iss != "string")
821
+ if (f.iss !== void 0 && typeof f.iss != "string")
785
822
  throw new a('unexpected JWT "iss" (issuer) claim type');
786
- if (h.nbf !== void 0) {
787
- if (typeof h.nbf != "number")
823
+ if (f.nbf !== void 0) {
824
+ if (typeof f.nbf != "number")
788
825
  throw new a('unexpected JWT "nbf" (not before) claim type');
789
- if (h.nbf > P + s)
826
+ if (f.nbf > R + s)
790
827
  throw new a('unexpected JWT "nbf" (not before) claim value, timestamp is > now()');
791
828
  }
792
- if (h.aud !== void 0 && typeof h.aud != "string" && !Array.isArray(h.aud))
829
+ if (f.aud !== void 0 && typeof f.aud != "string" && !Array.isArray(f.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: f, signature: b, key: _ };
795
832
  }
796
- function vt(t, e, n) {
833
+ function Ct(t, e, n) {
797
834
  if (t !== void 0) {
798
835
  if (n.alg !== t)
799
836
  throw new a('unexpected JWT "alg" header parameter');
@@ -808,36 +845,36 @@ function vt(t, e, n) {
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: n, length: o } = t.getAll(e);
849
+ if (o > 1)
813
850
  throw new a(`"${e}" parameter must be provided only once`);
814
851
  return n;
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 zt(t, e, n, o) {
855
+ if (j(t), z(e), n instanceof URL && (n = n.searchParams), !(n instanceof URLSearchParams))
819
856
  throw new TypeError('"parameters" must be an instance of URLSearchParams, or URL');
820
857
  if (T(n, "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(n, "iss"), r = T(n, "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 (r !== 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 (r === void 0)
839
876
  throw new a('response parameter "state" missing');
840
- if (o !== r)
877
+ if (r !== o)
841
878
  throw new a('unexpected "state" response parameter value');
842
879
  }
843
880
  const i = T(n, "error");
@@ -847,123 +884,150 @@ function At(t, e, n, r) {
847
884
  error_description: T(n, "error_description"),
848
885
  error_uri: T(n, "error_uri")
849
886
  };
850
- const u = T(n, "id_token"), f = T(n, "token");
851
- if (u !== void 0 || f !== void 0)
887
+ const u = T(n, "id_token"), h = T(n, "token");
888
+ if (u !== void 0 || h !== 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(n));
891
+ }
892
+ function Jt({
893
+ handleCallback: t
894
+ }) {
895
+ const [e, n] = ze(null), o = He(), s = Je(!1);
896
+ return Oe(() => {
897
+ s.current || (s.current = !0, t().then((r) => {
898
+ o(r);
899
+ }).catch((r) => {
900
+ K.error(r), n(r);
901
+ }));
902
+ }, [o, t]), e ? /* @__PURE__ */ k.jsx(
903
+ De,
904
+ {
905
+ category: "Error",
906
+ title: "Authentication Error",
907
+ message: /* @__PURE__ */ k.jsxs(k.Fragment, { children: [
908
+ /* @__PURE__ */ k.jsx(Ne, { 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__ */ k.jsx(We, { code: e.toString(), language: "plain" })
911
+ ] })
912
+ }
913
+ ) : /* @__PURE__ */ k.jsx("div", { className: "grid h-full place-items-center", children: /* @__PURE__ */ k.jsx(Ke, {}) });
854
914
  }
855
- class O extends Error {
915
+ class x 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 x {
918
+ constructor(e, n, o) {
919
+ super(e, o), this.error = n;
860
920
  }
861
921
  }
862
- const F = "code-verifier";
863
- class kt extends Le {
922
+ const V = "code-verifier";
923
+ class Ot extends je {
864
924
  constructor(e, n) {
865
- super(), this.callbackUrlPath = e, this.initialize = n;
925
+ super(), this.callbackUrlPath = e, this.handleCallback = n;
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__ */ k.jsx(Jt, { handleCallback: this.handleCallback })
873
933
  }
874
934
  ];
875
935
  }
876
936
  }
877
- class Et {
937
+ class Nt {
878
938
  constructor({
879
939
  issuer: e,
880
940
  audience: n,
881
- authorizationEndpoint: r,
941
+ authorizationEndpoint: o,
882
942
  tokenEndpoint: s,
883
- clientId: o,
943
+ clientId: r,
884
944
  redirectToAfterSignUp: i,
885
945
  redirectToAfterSignIn: u,
886
- redirectToAfterSignOut: f
946
+ redirectToAfterSignOut: h
887
947
  }) {
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({
948
+ y(this, "client");
949
+ y(this, "issuer");
950
+ y(this, "authorizationEndpoint");
951
+ y(this, "tokenEndpoint");
952
+ y(this, "authorizationServer");
953
+ y(this, "callbackUrlPath", "/oauth/callback");
954
+ y(this, "logoutRedirectUrlPath", "/");
955
+ y(this, "onAuthorizationUrl");
956
+ y(this, "redirectToAfterSignUp");
957
+ y(this, "redirectToAfterSignIn");
958
+ y(this, "redirectToAfterSignOut");
959
+ y(this, "audience");
960
+ y(this, "signOut", async () => {
961
+ N.setState({
903
962
  isAuthenticated: !1,
904
963
  isPending: !1,
905
964
  profile: void 0
906
- }), localStorage.removeItem("auto-login");
965
+ }), sessionStorage.clear();
907
966
  const e = await this.getAuthServer(), n = new URL(
908
967
  window.location.origin + this.redirectToAfterSignOut
909
968
  );
910
969
  n.pathname = this.logoutRedirectUrlPath;
911
- let r;
912
- e.end_session_endpoint ? (r = new URL(e.end_session_endpoint), r.searchParams.set(
970
+ let o;
971
+ e.end_session_endpoint ? (o = new URL(e.end_session_endpoint), o.searchParams.set(
913
972
  "post_logout_redirect_uri",
914
973
  n.toString()
915
- )) : r = n;
974
+ )) : o = n;
916
975
  });
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(
976
+ y(this, "handleCallback", async () => {
977
+ const e = new URL(window.location.href), n = e.searchParams.get("state"), o = sessionStorage.getItem(V);
978
+ if (sessionStorage.removeItem(V), !o)
979
+ throw new x("No code verifier found in state.");
980
+ const s = await this.getAuthServer(), r = zt(
922
981
  s,
923
982
  this.client,
924
983
  e.searchParams,
925
984
  n ?? void 0
926
985
  );
927
- if (B(o))
928
- throw re.error("Error validating OAuth response", o), new ue(
986
+ if (Z(r))
987
+ throw K.error("Error validating OAuth response", r), new de(
929
988
  "Error validating OAuth response",
930
- o
989
+ r
931
990
  );
932
991
  const i = new URL(e);
933
992
  i.pathname = this.redirectToAfterSignIn, i.search = "";
934
- const u = await pt(
993
+ const u = await Et(
935
994
  s,
936
995
  this.client,
937
- o,
996
+ r,
938
997
  i.toString(),
939
- r
940
- ), f = await mt(
998
+ o
999
+ ), h = await Pt(
941
1000
  s,
942
1001
  this.client,
943
1002
  u
944
1003
  );
945
- this.setTokensFromResponse(f);
946
- const y = await this.getAccessToken(), b = await (await st(
1004
+ this.setTokensFromResponse(h);
1005
+ const m = await this.getAccessToken(), _ = await (await gt(
947
1006
  s,
948
1007
  this.client,
949
- y
950
- )).json(), h = {
951
- sub: b.sub,
952
- email: b.email,
953
- name: b.name,
954
- emailVerified: b.email_verified ?? !1,
955
- pictureUrl: b.picture
1008
+ m
1009
+ )).json(), f = {
1010
+ sub: _.sub,
1011
+ email: _.email,
1012
+ name: _.name,
1013
+ emailVerified: _.email_verified ?? !1,
1014
+ pictureUrl: _.picture
956
1015
  };
957
- return ne.setState({
1016
+ N.setState({
958
1017
  isAuthenticated: !0,
959
1018
  isPending: !1,
960
- profile: h
961
- }), localStorage.setItem("auto-login", "1"), sessionStorage.getItem("redirect-to") ?? "/";
1019
+ profile: f
1020
+ }), sessionStorage.setItem(
1021
+ "profile-state",
1022
+ JSON.stringify(N.getState().profile)
1023
+ );
1024
+ const R = sessionStorage.getItem("redirect-to") ?? "/";
1025
+ return sessionStorage.removeItem("redirect-to"), R;
962
1026
  });
963
1027
  this.client = {
964
- client_id: o,
1028
+ client_id: r,
965
1029
  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 ?? "/";
1030
+ }, this.audience = n, this.issuer = e, this.authorizationEndpoint = o, this.tokenEndpoint = s, this.redirectToAfterSignUp = i ?? "/", this.redirectToAfterSignIn = u ?? "/", this.redirectToAfterSignOut = h ?? "/";
967
1031
  }
968
1032
  async getAuthServer() {
969
1033
  if (!this.authorizationServer)
@@ -975,8 +1039,8 @@ class Et {
975
1039
  code_challenge_methods_supported: []
976
1040
  };
977
1041
  else {
978
- const e = new URL(this.issuer), n = await De(e);
979
- this.authorizationServer = await He(
1042
+ const e = new URL(this.issuer), n = await Qe(e);
1043
+ this.authorizationServer = await Xe(
980
1044
  e,
981
1045
  n
982
1046
  );
@@ -988,16 +1052,17 @@ class Et {
988
1052
  * @param response
989
1053
  */
990
1054
  setTokensFromResponse(e) {
991
- if (B(e))
992
- throw re.error("Bad Token Response", e), new ue("Bad Token Response", e);
1055
+ if (Z(e))
1056
+ throw K.error("Bad Token Response", e), new de("Bad Token Response", e);
993
1057
  if (!e.expires_in)
994
- throw new O("No expires_in in response");
995
- this.tokens = {
1058
+ throw new x("No expires_in in response");
1059
+ const n = {
996
1060
  accessToken: e.access_token,
997
1061
  refreshToken: e.refresh_token,
998
1062
  expiresOn: new Date(Date.now() + e.expires_in * 1e3),
999
1063
  tokenType: e.token_type
1000
- }, sessionStorage.setItem("openid-token", JSON.stringify(this.tokens));
1064
+ };
1065
+ sessionStorage.setItem("token-state", JSON.stringify(n));
1001
1066
  }
1002
1067
  async signUp({ redirectTo: e } = {}) {
1003
1068
  return this.authorize({
@@ -1014,68 +1079,73 @@ class Et {
1014
1079
  redirectTo: e,
1015
1080
  isSignUp: n = !1
1016
1081
  }) {
1017
- var y, _;
1018
- const r = "S256", s = await this.getAuthServer();
1082
+ var m, b;
1083
+ const o = "S256", s = await this.getAuthServer();
1019
1084
  if (!s.authorization_endpoint)
1020
- throw new O("No authorization endpoint");
1021
- const o = $e(), i = await Me(o);
1022
- sessionStorage.setItem(F, o);
1085
+ throw new x("No authorization endpoint");
1086
+ const r = et(), i = await nt(r);
1087
+ sessionStorage.setItem(V, r);
1023
1088
  const u = new URL(
1024
1089
  s.authorization_endpoint
1025
1090
  );
1026
1091
  sessionStorage.setItem("redirect-to", e);
1027
- 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(
1092
+ const h = new URL(window.location.origin);
1093
+ if (h.pathname = this.callbackUrlPath, h.search = "", u.searchParams.set("client_id", this.client.client_id), u.searchParams.set("redirect_uri", h.toString()), u.searchParams.set("response_type", "code"), u.searchParams.set("scope", "openid profile email"), u.searchParams.set("code_challenge", i), u.searchParams.set(
1029
1094
  "code_challenge_method",
1030
- r
1031
- ), this.audience && u.searchParams.set("audience", this.audience), (y = this.onAuthorizationUrl) == null || y.call(this, u, {
1095
+ o
1096
+ ), this.audience && u.searchParams.set("audience", this.audience), (m = this.onAuthorizationUrl) == null || m.call(this, u, {
1032
1097
  isSignIn: !n,
1033
1098
  isSignUp: n
1034
- }), ((_ = s.code_challenge_methods_supported) == null ? void 0 : _.includes("S256")) !== !0) {
1035
- const b = Fe();
1036
- u.searchParams.set("state", b);
1099
+ }), ((b = s.code_challenge_methods_supported) == null ? void 0 : b.includes("S256")) !== !0) {
1100
+ const _ = tt();
1101
+ u.searchParams.set("state", _);
1037
1102
  }
1038
1103
  location.href = u.href;
1039
1104
  }
1040
1105
  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)
1106
+ const e = await this.getAuthServer(), n = sessionStorage.getItem("token-state");
1107
+ if (!n)
1108
+ throw new x("User is not authenticated");
1109
+ const o = JSON.parse(n);
1110
+ if (o.expiresOn < /* @__PURE__ */ new Date()) {
1111
+ if (!o.refreshToken)
1046
1112
  return await this.signIn(), "";
1047
- const n = await ct(
1113
+ const s = await yt(
1048
1114
  e,
1049
1115
  this.client,
1050
- this.tokens.refreshToken
1051
- ), r = await lt(
1116
+ o.refreshToken
1117
+ ), r = await _t(
1052
1118
  e,
1053
1119
  this.client,
1054
- n
1120
+ s
1055
1121
  );
1056
- this.setTokensFromResponse(r);
1057
- }
1058
- return this.tokens.accessToken;
1122
+ if (!r.access_token)
1123
+ throw new x("No access token in response");
1124
+ return this.setTokensFromResponse(r), r.access_token.toString();
1125
+ } else
1126
+ return o.accessToken;
1059
1127
  }
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
- }
1128
+ pageLoad() {
1129
+ const e = sessionStorage.getItem("profile-state");
1130
+ if (e)
1131
+ try {
1132
+ const n = JSON.parse(e);
1133
+ N.setState({
1134
+ isAuthenticated: !0,
1135
+ isPending: !1,
1136
+ profile: n
1137
+ });
1138
+ } catch (n) {
1139
+ K.error("Error parsing auth state", n);
1072
1140
  }
1073
- );
1141
+ }
1142
+ getAuthenticationPlugin() {
1143
+ return new Ot(this.callbackUrlPath, this.handleCallback);
1074
1144
  }
1075
1145
  }
1076
- const Ct = (t) => new Et(t);
1146
+ const Yt = (t) => new Nt(t);
1077
1147
  export {
1078
- Et as OpenIDAuthenticationProvider,
1079
- Ct as default
1148
+ Nt as OpenIDAuthenticationProvider,
1149
+ Yt as default
1080
1150
  };
1081
1151
  //# sourceMappingURL=zudoku.auth-openid.js.map