zudoku 0.1.1-dev.50 → 0.1.1-dev.52

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