zudoku 0.3.0-dev.5 → 0.3.0-dev.6

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