hookery 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +72 -11
  2. package/dist/bridges/auth0.d.mts +16 -0
  3. package/dist/bridges/auth0.d.ts +16 -0
  4. package/dist/bridges/auth0.js +3015 -0
  5. package/dist/bridges/auth0.js.map +1 -0
  6. package/dist/bridges/auth0.mjs +2977 -0
  7. package/dist/bridges/auth0.mjs.map +1 -0
  8. package/dist/bridges/axios.d.mts +17 -0
  9. package/dist/bridges/axios.d.ts +17 -0
  10. package/dist/bridges/axios.js +15351 -0
  11. package/dist/bridges/axios.js.map +1 -0
  12. package/dist/bridges/axios.mjs +15347 -0
  13. package/dist/bridges/axios.mjs.map +1 -0
  14. package/dist/bridges/clerk.d.mts +1 -0
  15. package/dist/bridges/clerk.d.ts +1 -0
  16. package/dist/bridges/clerk.js +5991 -0
  17. package/dist/bridges/clerk.js.map +1 -0
  18. package/dist/bridges/clerk.mjs +5985 -0
  19. package/dist/bridges/clerk.mjs.map +1 -0
  20. package/dist/bridges/firebase.d.mts +14 -0
  21. package/dist/bridges/firebase.d.ts +14 -0
  22. package/dist/bridges/firebase.js +52 -0
  23. package/dist/bridges/firebase.js.map +1 -0
  24. package/dist/bridges/firebase.mjs +25 -0
  25. package/dist/bridges/firebase.mjs.map +1 -0
  26. package/dist/bridges/jotai.d.mts +11 -0
  27. package/dist/bridges/jotai.d.ts +11 -0
  28. package/dist/bridges/jotai.js +870 -0
  29. package/dist/bridges/jotai.js.map +1 -0
  30. package/dist/bridges/jotai.mjs +827 -0
  31. package/dist/bridges/jotai.mjs.map +1 -0
  32. package/dist/bridges/motion.d.mts +6 -0
  33. package/dist/bridges/motion.d.ts +6 -0
  34. package/dist/bridges/motion.js +3752 -0
  35. package/dist/bridges/motion.js.map +1 -0
  36. package/dist/bridges/motion.mjs +3721 -0
  37. package/dist/bridges/motion.mjs.map +1 -0
  38. package/dist/bridges/next.d.mts +10 -0
  39. package/dist/bridges/next.d.ts +10 -0
  40. package/dist/bridges/next.js +2588 -0
  41. package/dist/bridges/next.js.map +1 -0
  42. package/dist/bridges/next.mjs +2582 -0
  43. package/dist/bridges/next.mjs.map +1 -0
  44. package/dist/bridges/redux.d.mts +15 -0
  45. package/dist/bridges/redux.d.ts +15 -0
  46. package/dist/bridges/redux.js +410 -0
  47. package/dist/bridges/redux.js.map +1 -0
  48. package/dist/bridges/redux.mjs +402 -0
  49. package/dist/bridges/redux.mjs.map +1 -0
  50. package/dist/bridges/remix.d.mts +1 -0
  51. package/dist/bridges/remix.d.ts +1 -0
  52. package/dist/bridges/remix.js +2215 -0
  53. package/dist/bridges/remix.js.map +1 -0
  54. package/dist/bridges/remix.mjs +2174 -0
  55. package/dist/bridges/remix.mjs.map +1 -0
  56. package/dist/bridges/stripe.d.mts +15 -0
  57. package/dist/bridges/stripe.d.ts +15 -0
  58. package/dist/bridges/stripe.js +1572 -0
  59. package/dist/bridges/stripe.js.map +1 -0
  60. package/dist/bridges/stripe.mjs +1556 -0
  61. package/dist/bridges/stripe.mjs.map +1 -0
  62. package/dist/bridges/supabase.d.mts +13 -0
  63. package/dist/bridges/supabase.d.ts +13 -0
  64. package/dist/bridges/supabase.js +51 -0
  65. package/dist/bridges/supabase.js.map +1 -0
  66. package/dist/bridges/supabase.mjs +24 -0
  67. package/dist/bridges/supabase.mjs.map +1 -0
  68. package/dist/bridges/tanstack.d.mts +3 -0
  69. package/dist/bridges/tanstack.d.ts +3 -0
  70. package/dist/bridges/tanstack.js +1319 -0
  71. package/dist/bridges/tanstack.js.map +1 -0
  72. package/dist/bridges/tanstack.mjs +1281 -0
  73. package/dist/bridges/tanstack.mjs.map +1 -0
  74. package/dist/bridges/yup.d.mts +16 -0
  75. package/dist/bridges/yup.d.ts +16 -0
  76. package/dist/bridges/yup.js +80 -0
  77. package/dist/bridges/yup.js.map +1 -0
  78. package/dist/bridges/yup.mjs +43 -0
  79. package/dist/bridges/yup.mjs.map +1 -0
  80. package/dist/bridges/zod.d.mts +19 -0
  81. package/dist/bridges/zod.d.ts +19 -0
  82. package/dist/bridges/zod.js +66 -0
  83. package/dist/bridges/zod.js.map +1 -0
  84. package/dist/bridges/zod.mjs +39 -0
  85. package/dist/bridges/zod.mjs.map +1 -0
  86. package/dist/bridges/zustand.d.mts +14 -0
  87. package/dist/bridges/zustand.d.ts +14 -0
  88. package/dist/bridges/zustand.js +58 -0
  89. package/dist/bridges/zustand.js.map +1 -0
  90. package/dist/bridges/zustand.mjs +21 -0
  91. package/dist/bridges/zustand.mjs.map +1 -0
  92. package/dist/index.d.mts +3124 -8
  93. package/dist/index.d.ts +3124 -8
  94. package/dist/index.js +4290 -10
  95. package/dist/index.js.map +1 -0
  96. package/dist/index.mjs +4172 -7
  97. package/dist/index.mjs.map +1 -0
  98. package/package.json +131 -6
@@ -0,0 +1,3015 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to2, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to2, key) && key !== except)
16
+ __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to2;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/bridges/auth0/index.ts
31
+ var auth0_exports = {};
32
+ __export(auth0_exports, {
33
+ useAuth0: () => useAuth0,
34
+ useAuth0User: () => useAuth0User
35
+ });
36
+ module.exports = __toCommonJS(auth0_exports);
37
+
38
+ // node_modules/@auth0/auth0-react/dist/auth0-react.esm.js
39
+ var import_react = __toESM(require("react"));
40
+ var extendStatics = function(d2, b) {
41
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b2) {
42
+ d3.__proto__ = b2;
43
+ } || function(d3, b2) {
44
+ for (var p2 in b2) if (Object.prototype.hasOwnProperty.call(b2, p2)) d3[p2] = b2[p2];
45
+ };
46
+ return extendStatics(d2, b);
47
+ };
48
+ function __extends(d2, b) {
49
+ if (typeof b !== "function" && b !== null)
50
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
51
+ extendStatics(d2, b);
52
+ function __() {
53
+ this.constructor = d2;
54
+ }
55
+ d2.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
56
+ }
57
+ var __assign = function() {
58
+ __assign = Object.assign || function __assign2(t2) {
59
+ for (var s2, i2 = 1, n2 = arguments.length; i2 < n2; i2++) {
60
+ s2 = arguments[i2];
61
+ for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2)) t2[p2] = s2[p2];
62
+ }
63
+ return t2;
64
+ };
65
+ return __assign.apply(this, arguments);
66
+ };
67
+ var t = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {};
68
+ var n = {};
69
+ var o = {};
70
+ Object.defineProperty(o, "__esModule", { value: true });
71
+ var r = (function() {
72
+ function e2() {
73
+ var e3 = this;
74
+ this.locked = /* @__PURE__ */ new Map(), this.addToLocked = function(t2, n2) {
75
+ var o2 = e3.locked.get(t2);
76
+ void 0 === o2 ? void 0 === n2 ? e3.locked.set(t2, []) : e3.locked.set(t2, [n2]) : void 0 !== n2 && (o2.unshift(n2), e3.locked.set(t2, o2));
77
+ }, this.isLocked = function(t2) {
78
+ return e3.locked.has(t2);
79
+ }, this.lock = function(t2) {
80
+ return new Promise((function(n2, o2) {
81
+ e3.isLocked(t2) ? e3.addToLocked(t2, n2) : (e3.addToLocked(t2), n2());
82
+ }));
83
+ }, this.unlock = function(t2) {
84
+ var n2 = e3.locked.get(t2);
85
+ if (void 0 !== n2 && 0 !== n2.length) {
86
+ var o2 = n2.pop();
87
+ e3.locked.set(t2, n2), void 0 !== o2 && setTimeout(o2, 0);
88
+ } else e3.locked.delete(t2);
89
+ };
90
+ }
91
+ return e2.getInstance = function() {
92
+ return void 0 === e2.instance && (e2.instance = new e2()), e2.instance;
93
+ }, e2;
94
+ })();
95
+ o.default = function() {
96
+ return r.getInstance();
97
+ };
98
+ var i = t && t.__awaiter || function(e2, t2, n2, o2) {
99
+ return new (n2 || (n2 = Promise))((function(r2, i2) {
100
+ function a2(e3) {
101
+ try {
102
+ c2(o2.next(e3));
103
+ } catch (e4) {
104
+ i2(e4);
105
+ }
106
+ }
107
+ function s2(e3) {
108
+ try {
109
+ c2(o2.throw(e3));
110
+ } catch (e4) {
111
+ i2(e4);
112
+ }
113
+ }
114
+ function c2(e3) {
115
+ e3.done ? r2(e3.value) : new n2((function(t3) {
116
+ t3(e3.value);
117
+ })).then(a2, s2);
118
+ }
119
+ c2((o2 = o2.apply(e2, t2 || [])).next());
120
+ }));
121
+ };
122
+ var a = t && t.__generator || function(e2, t2) {
123
+ var n2, o2, r2, i2, a2 = { label: 0, sent: function() {
124
+ if (1 & r2[0]) throw r2[1];
125
+ return r2[1];
126
+ }, trys: [], ops: [] };
127
+ return i2 = { next: s2(0), throw: s2(1), return: s2(2) }, "function" == typeof Symbol && (i2[Symbol.iterator] = function() {
128
+ return this;
129
+ }), i2;
130
+ function s2(i3) {
131
+ return function(s3) {
132
+ return (function(i4) {
133
+ if (n2) throw new TypeError("Generator is already executing.");
134
+ for (; a2; ) try {
135
+ if (n2 = 1, o2 && (r2 = 2 & i4[0] ? o2.return : i4[0] ? o2.throw || ((r2 = o2.return) && r2.call(o2), 0) : o2.next) && !(r2 = r2.call(o2, i4[1])).done) return r2;
136
+ switch (o2 = 0, r2 && (i4 = [2 & i4[0], r2.value]), i4[0]) {
137
+ case 0:
138
+ case 1:
139
+ r2 = i4;
140
+ break;
141
+ case 4:
142
+ return a2.label++, { value: i4[1], done: false };
143
+ case 5:
144
+ a2.label++, o2 = i4[1], i4 = [0];
145
+ continue;
146
+ case 7:
147
+ i4 = a2.ops.pop(), a2.trys.pop();
148
+ continue;
149
+ default:
150
+ if (!(r2 = a2.trys, (r2 = r2.length > 0 && r2[r2.length - 1]) || 6 !== i4[0] && 2 !== i4[0])) {
151
+ a2 = 0;
152
+ continue;
153
+ }
154
+ if (3 === i4[0] && (!r2 || i4[1] > r2[0] && i4[1] < r2[3])) {
155
+ a2.label = i4[1];
156
+ break;
157
+ }
158
+ if (6 === i4[0] && a2.label < r2[1]) {
159
+ a2.label = r2[1], r2 = i4;
160
+ break;
161
+ }
162
+ if (r2 && a2.label < r2[2]) {
163
+ a2.label = r2[2], a2.ops.push(i4);
164
+ break;
165
+ }
166
+ r2[2] && a2.ops.pop(), a2.trys.pop();
167
+ continue;
168
+ }
169
+ i4 = t2.call(e2, a2);
170
+ } catch (e3) {
171
+ i4 = [6, e3], o2 = 0;
172
+ } finally {
173
+ n2 = r2 = 0;
174
+ }
175
+ if (5 & i4[0]) throw i4[1];
176
+ return { value: i4[0] ? i4[1] : void 0, done: true };
177
+ })([i3, s3]);
178
+ };
179
+ }
180
+ };
181
+ var s = t;
182
+ Object.defineProperty(n, "__esModule", { value: true });
183
+ var c = o;
184
+ var u = { key: function(e2) {
185
+ return i(s, void 0, void 0, (function() {
186
+ return a(this, (function(e3) {
187
+ throw new Error("Unsupported");
188
+ }));
189
+ }));
190
+ }, getItem: function(e2) {
191
+ return i(s, void 0, void 0, (function() {
192
+ return a(this, (function(e3) {
193
+ throw new Error("Unsupported");
194
+ }));
195
+ }));
196
+ }, clear: function() {
197
+ return i(s, void 0, void 0, (function() {
198
+ return a(this, (function(e2) {
199
+ return [2, window.localStorage.clear()];
200
+ }));
201
+ }));
202
+ }, removeItem: function(e2) {
203
+ return i(s, void 0, void 0, (function() {
204
+ return a(this, (function(e3) {
205
+ throw new Error("Unsupported");
206
+ }));
207
+ }));
208
+ }, setItem: function(e2, t2) {
209
+ return i(s, void 0, void 0, (function() {
210
+ return a(this, (function(e3) {
211
+ throw new Error("Unsupported");
212
+ }));
213
+ }));
214
+ }, keySync: function(e2) {
215
+ return window.localStorage.key(e2);
216
+ }, getItemSync: function(e2) {
217
+ return window.localStorage.getItem(e2);
218
+ }, clearSync: function() {
219
+ return window.localStorage.clear();
220
+ }, removeItemSync: function(e2) {
221
+ return window.localStorage.removeItem(e2);
222
+ }, setItemSync: function(e2, t2) {
223
+ return window.localStorage.setItem(e2, t2);
224
+ } };
225
+ function l(e2) {
226
+ return new Promise((function(t2) {
227
+ return setTimeout(t2, e2);
228
+ }));
229
+ }
230
+ function d(e2) {
231
+ for (var t2 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz", n2 = "", o2 = 0; o2 < e2; o2++) {
232
+ n2 += t2[Math.floor(Math.random() * t2.length)];
233
+ }
234
+ return n2;
235
+ }
236
+ var h = (function() {
237
+ function e2(t2) {
238
+ this.acquiredIatSet = /* @__PURE__ */ new Set(), this.storageHandler = void 0, this.id = Date.now().toString() + d(15), this.acquireLock = this.acquireLock.bind(this), this.releaseLock = this.releaseLock.bind(this), this.releaseLock__private__ = this.releaseLock__private__.bind(this), this.waitForSomethingToChange = this.waitForSomethingToChange.bind(this), this.refreshLockWhileAcquired = this.refreshLockWhileAcquired.bind(this), this.storageHandler = t2, void 0 === e2.waiters && (e2.waiters = []);
239
+ }
240
+ return e2.prototype.acquireLock = function(t2, n2) {
241
+ return void 0 === n2 && (n2 = 5e3), i(this, void 0, void 0, (function() {
242
+ var o2, r2, i2, s2, c2, h2, p2;
243
+ return a(this, (function(a2) {
244
+ switch (a2.label) {
245
+ case 0:
246
+ o2 = Date.now() + d(4), r2 = Date.now() + n2, i2 = "browser-tabs-lock-key-" + t2, s2 = void 0 === this.storageHandler ? u : this.storageHandler, a2.label = 1;
247
+ case 1:
248
+ return Date.now() < r2 ? [4, l(30)] : [3, 8];
249
+ case 2:
250
+ return a2.sent(), null !== s2.getItemSync(i2) ? [3, 5] : (c2 = this.id + "-" + t2 + "-" + o2, [4, l(Math.floor(25 * Math.random()))]);
251
+ case 3:
252
+ return a2.sent(), s2.setItemSync(i2, JSON.stringify({ id: this.id, iat: o2, timeoutKey: c2, timeAcquired: Date.now(), timeRefreshed: Date.now() })), [4, l(30)];
253
+ case 4:
254
+ return a2.sent(), null !== (h2 = s2.getItemSync(i2)) && (p2 = JSON.parse(h2)).id === this.id && p2.iat === o2 ? (this.acquiredIatSet.add(o2), this.refreshLockWhileAcquired(i2, o2), [2, true]) : [3, 7];
255
+ case 5:
256
+ return e2.lockCorrector(void 0 === this.storageHandler ? u : this.storageHandler), [4, this.waitForSomethingToChange(r2)];
257
+ case 6:
258
+ a2.sent(), a2.label = 7;
259
+ case 7:
260
+ return o2 = Date.now() + d(4), [3, 1];
261
+ case 8:
262
+ return [2, false];
263
+ }
264
+ }));
265
+ }));
266
+ }, e2.prototype.refreshLockWhileAcquired = function(e3, t2) {
267
+ return i(this, void 0, void 0, (function() {
268
+ var n2 = this;
269
+ return a(this, (function(o2) {
270
+ return setTimeout((function() {
271
+ return i(n2, void 0, void 0, (function() {
272
+ var n3, o3, r2;
273
+ return a(this, (function(i2) {
274
+ switch (i2.label) {
275
+ case 0:
276
+ return [4, c.default().lock(t2)];
277
+ case 1:
278
+ return i2.sent(), this.acquiredIatSet.has(t2) ? (n3 = void 0 === this.storageHandler ? u : this.storageHandler, null === (o3 = n3.getItemSync(e3)) ? (c.default().unlock(t2), [2]) : ((r2 = JSON.parse(o3)).timeRefreshed = Date.now(), n3.setItemSync(e3, JSON.stringify(r2)), c.default().unlock(t2), this.refreshLockWhileAcquired(e3, t2), [2])) : (c.default().unlock(t2), [2]);
279
+ }
280
+ }));
281
+ }));
282
+ }), 1e3), [2];
283
+ }));
284
+ }));
285
+ }, e2.prototype.waitForSomethingToChange = function(t2) {
286
+ return i(this, void 0, void 0, (function() {
287
+ return a(this, (function(n2) {
288
+ switch (n2.label) {
289
+ case 0:
290
+ return [4, new Promise((function(n3) {
291
+ var o2 = false, r2 = Date.now(), i2 = false;
292
+ function a2() {
293
+ if (i2 || (window.removeEventListener("storage", a2), e2.removeFromWaiting(a2), clearTimeout(s2), i2 = true), !o2) {
294
+ o2 = true;
295
+ var t3 = 50 - (Date.now() - r2);
296
+ t3 > 0 ? setTimeout(n3, t3) : n3(null);
297
+ }
298
+ }
299
+ window.addEventListener("storage", a2), e2.addToWaiting(a2);
300
+ var s2 = setTimeout(a2, Math.max(0, t2 - Date.now()));
301
+ }))];
302
+ case 1:
303
+ return n2.sent(), [2];
304
+ }
305
+ }));
306
+ }));
307
+ }, e2.addToWaiting = function(t2) {
308
+ this.removeFromWaiting(t2), void 0 !== e2.waiters && e2.waiters.push(t2);
309
+ }, e2.removeFromWaiting = function(t2) {
310
+ void 0 !== e2.waiters && (e2.waiters = e2.waiters.filter((function(e3) {
311
+ return e3 !== t2;
312
+ })));
313
+ }, e2.notifyWaiters = function() {
314
+ void 0 !== e2.waiters && e2.waiters.slice().forEach((function(e3) {
315
+ return e3();
316
+ }));
317
+ }, e2.prototype.releaseLock = function(e3) {
318
+ return i(this, void 0, void 0, (function() {
319
+ return a(this, (function(t2) {
320
+ switch (t2.label) {
321
+ case 0:
322
+ return [4, this.releaseLock__private__(e3)];
323
+ case 1:
324
+ return [2, t2.sent()];
325
+ }
326
+ }));
327
+ }));
328
+ }, e2.prototype.releaseLock__private__ = function(t2) {
329
+ return i(this, void 0, void 0, (function() {
330
+ var n2, o2, r2, i2;
331
+ return a(this, (function(a2) {
332
+ switch (a2.label) {
333
+ case 0:
334
+ return n2 = void 0 === this.storageHandler ? u : this.storageHandler, o2 = "browser-tabs-lock-key-" + t2, null === (r2 = n2.getItemSync(o2)) ? [2] : (i2 = JSON.parse(r2)).id !== this.id ? [3, 2] : [4, c.default().lock(i2.iat)];
335
+ case 1:
336
+ a2.sent(), this.acquiredIatSet.delete(i2.iat), n2.removeItemSync(o2), c.default().unlock(i2.iat), e2.notifyWaiters(), a2.label = 2;
337
+ case 2:
338
+ return [2];
339
+ }
340
+ }));
341
+ }));
342
+ }, e2.lockCorrector = function(t2) {
343
+ for (var n2 = Date.now() - 5e3, o2 = t2, r2 = [], i2 = 0; ; ) {
344
+ var a2 = o2.keySync(i2);
345
+ if (null === a2) break;
346
+ r2.push(a2), i2++;
347
+ }
348
+ for (var s2 = false, c2 = 0; c2 < r2.length; c2++) {
349
+ var u2 = r2[c2];
350
+ if (u2.includes("browser-tabs-lock-key")) {
351
+ var l2 = o2.getItemSync(u2);
352
+ if (null !== l2) {
353
+ var d2 = JSON.parse(l2);
354
+ (void 0 === d2.timeRefreshed && d2.timeAcquired < n2 || void 0 !== d2.timeRefreshed && d2.timeRefreshed < n2) && (o2.removeItemSync(u2), s2 = true);
355
+ }
356
+ }
357
+ }
358
+ s2 && e2.notifyWaiters();
359
+ }, e2.waiters = void 0, e2;
360
+ })();
361
+ var p = n.default = h;
362
+ var N = new TextEncoder();
363
+ var W = new TextDecoder();
364
+ var M;
365
+ if (Uint8Array.prototype.toBase64) M = (e2) => (e2 instanceof ArrayBuffer && (e2 = new Uint8Array(e2)), e2.toBase64({ alphabet: "base64url", omitPadding: true }));
366
+ else {
367
+ const e2 = 32768;
368
+ M = (t2) => {
369
+ t2 instanceof ArrayBuffer && (t2 = new Uint8Array(t2));
370
+ const n2 = [];
371
+ for (let o2 = 0; o2 < t2.byteLength; o2 += e2) n2.push(String.fromCharCode.apply(null, t2.subarray(o2, o2 + e2)));
372
+ return btoa(n2.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
373
+ };
374
+ }
375
+ var ve = t && t.__assign || function() {
376
+ return ve = Object.assign || function(e2) {
377
+ for (var t2, n2 = 1, o2 = arguments.length; n2 < o2; n2++) for (var r2 in t2 = arguments[n2]) Object.prototype.hasOwnProperty.call(t2, r2) && (e2[r2] = t2[r2]);
378
+ return e2;
379
+ }, ve.apply(this, arguments);
380
+ };
381
+ var Oe;
382
+ !(function(e2) {
383
+ e2.Code = "code", e2.ConnectCode = "connect_code";
384
+ })(Oe || (Oe = {}));
385
+ function Ce(e2, t2, n2) {
386
+ var o2 = void 0 === t2 ? null : t2, r2 = (function(e3, t3) {
387
+ var n3 = atob(e3);
388
+ if (t3) {
389
+ for (var o3 = new Uint8Array(n3.length), r3 = 0, i3 = n3.length; r3 < i3; ++r3) o3[r3] = n3.charCodeAt(r3);
390
+ return String.fromCharCode.apply(null, new Uint16Array(o3.buffer));
391
+ }
392
+ return n3;
393
+ })(e2, void 0 !== n2 && n2), i2 = r2.indexOf("\n", 10) + 1, a2 = r2.substring(i2) + (o2 ? "//# sourceMappingURL=" + o2 : ""), s2 = new Blob([a2], { type: "application/javascript" });
394
+ return URL.createObjectURL(s2);
395
+ }
396
+ var je;
397
+ var De;
398
+ var Ke;
399
+ var Le;
400
+ var Ue = (je = "Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwohZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Y2xhc3MgZSBleHRlbmRzIEVycm9ye2NvbnN0cnVjdG9yKHQscil7c3VwZXIociksdGhpcy5lcnJvcj10LHRoaXMuZXJyb3JfZGVzY3JpcHRpb249cixPYmplY3Quc2V0UHJvdG90eXBlT2YodGhpcyxlLnByb3RvdHlwZSl9c3RhdGljIGZyb21QYXlsb2FkKHQpe2xldHtlcnJvcjpyLGVycm9yX2Rlc2NyaXB0aW9uOnN9PXQ7cmV0dXJuIG5ldyBlKHIscyl9fWNsYXNzIHQgZXh0ZW5kcyBle2NvbnN0cnVjdG9yKGUscyl7c3VwZXIoIm1pc3NpbmdfcmVmcmVzaF90b2tlbiIsIk1pc3NpbmcgUmVmcmVzaCBUb2tlbiAoYXVkaWVuY2U6ICciLmNvbmNhdChyKGUsWyJkZWZhdWx0Il0pLCInLCBzY29wZTogJyIpLmNvbmNhdChyKHMpLCInKSIpKSx0aGlzLmF1ZGllbmNlPWUsdGhpcy5zY29wZT1zLE9iamVjdC5zZXRQcm90b3R5cGVPZih0aGlzLHQucHJvdG90eXBlKX19ZnVuY3Rpb24gcihlKXtsZXQgdD1hcmd1bWVudHMubGVuZ3RoPjEmJnZvaWQgMCE9PWFyZ3VtZW50c1sxXT9hcmd1bWVudHNbMV06W107cmV0dXJuIGUmJiF0LmluY2x1ZGVzKGUpP2U6IiJ9ImZ1bmN0aW9uIj09dHlwZW9mIFN1cHByZXNzZWRFcnJvciYmU3VwcHJlc3NlZEVycm9yO2NvbnN0IHM9ZT0+e3ZhcntjbGllbnRJZDp0fT1lLHI9ZnVuY3Rpb24oZSx0KXt2YXIgcj17fTtmb3IodmFyIHMgaW4gZSlPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwoZSxzKSYmdC5pbmRleE9mKHMpPDAmJihyW3NdPWVbc10pO2lmKG51bGwhPWUmJiJmdW5jdGlvbiI9PXR5cGVvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlTeW1ib2xzKXt2YXIgbz0wO2ZvcihzPU9iamVjdC5nZXRPd25Qcm9wZXJ0eVN5bWJvbHMoZSk7bzxzLmxlbmd0aDtvKyspdC5pbmRleE9mKHNbb10pPDAmJk9iamVjdC5wcm90b3R5cGUucHJvcGVydHlJc0VudW1lcmFibGUuY2FsbChlLHNbb10pJiYocltzW29dXT1lW3Nbb11dKX1yZXR1cm4gcn0oZSxbImNsaWVudElkIl0pO3JldHVybiBuZXcgVVJMU2VhcmNoUGFyYW1zKChlPT5PYmplY3Qua2V5cyhlKS5maWx0ZXIoKHQ9PnZvaWQgMCE9PWVbdF0pKS5yZWR1Y2UoKCh0LHIpPT5PYmplY3QuYXNzaWduKE9iamVjdC5hc3NpZ24oe30sdCkse1tyXTplW3JdfSkpLHt9KSkoT2JqZWN0LmFzc2lnbih7Y2xpZW50X2lkOnR9LHIpKSkudG9TdHJpbmcoKX07bGV0IG89e307Y29uc3Qgbj0oZSx0KT0+IiIuY29uY2F0KGUsInwiKS5jb25jYXQodCk7YWRkRXZlbnRMaXN0ZW5lcigibWVzc2FnZSIsKGFzeW5jIGU9PntsZXQgcixjLHtkYXRhOnt0aW1lb3V0OmksYXV0aDphLGZldGNoVXJsOmYsZmV0Y2hPcHRpb25zOmwsdXNlRm9ybURhdGE6cCx1c2VNcnJ0Omh9LHBvcnRzOlt1XX09ZSxkPXt9O2NvbnN0e2F1ZGllbmNlOmcsc2NvcGU6eX09YXx8e307dHJ5e2NvbnN0IGU9cD8oZT0+e2NvbnN0IHQ9bmV3IFVSTFNlYXJjaFBhcmFtcyhlKSxyPXt9O3JldHVybiB0LmZvckVhY2goKChlLHQpPT57clt0XT1lfSkpLHJ9KShsLmJvZHkpOkpTT04ucGFyc2UobC5ib2R5KTtpZighZS5yZWZyZXNoX3Rva2VuJiYicmVmcmVzaF90b2tlbiI9PT1lLmdyYW50X3R5cGUpe2lmKGM9KChlLHQpPT5vW24oZSx0KV0pKGcseSksIWMmJmgpe2NvbnN0IGU9by5sYXRlc3RfcmVmcmVzaF90b2tlbix0PSgoZSx0KT0+e2NvbnN0IHI9T2JqZWN0LmtleXMobykuZmluZCgocj0+e2lmKCJsYXRlc3RfcmVmcmVzaF90b2tlbiIhPT1yKXtjb25zdCBzPSgoZSx0KT0+dC5zdGFydHNXaXRoKCIiLmNvbmNhdChlLCJ8IikpKSh0LHIpLG89ci5zcGxpdCgifCIpWzFdLnNwbGl0KCIgIiksbj1lLnNwbGl0KCIgIikuZXZlcnkoKGU9Pm8uaW5jbHVkZXMoZSkpKTtyZXR1cm4gcyYmbn19KSk7cmV0dXJuISFyfSkoeSxnKTtlJiYhdCYmKGM9ZSl9aWYoIWMpdGhyb3cgbmV3IHQoZyx5KTtsLmJvZHk9cD9zKE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpjfSkpOkpTT04uc3RyaW5naWZ5KE9iamVjdC5hc3NpZ24oT2JqZWN0LmFzc2lnbih7fSxlKSx7cmVmcmVzaF90b2tlbjpjfSkpfWxldCBhLGs7ImZ1bmN0aW9uIj09dHlwZW9mIEFib3J0Q29udHJvbGxlciYmKGE9bmV3IEFib3J0Q29udHJvbGxlcixsLnNpZ25hbD1hLnNpZ25hbCk7dHJ5e2s9YXdhaXQgUHJvbWlzZS5yYWNlKFsoaj1pLG5ldyBQcm9taXNlKChlPT5zZXRUaW1lb3V0KGUsaikpKSksZmV0Y2goZixPYmplY3QuYXNzaWduKHt9LGwpKV0pfWNhdGNoKGUpe3JldHVybiB2b2lkIHUucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZX0pfWlmKCFrKXJldHVybiBhJiZhLmFib3J0KCksdm9pZCB1LnBvc3RNZXNzYWdlKHtlcnJvcjoiVGltZW91dCB3aGVuIGV4ZWN1dGluZyAnZmV0Y2gnIn0pO189ay5oZWFkZXJzLGQ9Wy4uLl9dLnJlZHVjZSgoKGUsdCk9PntsZXRbcixzXT10O3JldHVybiBlW3JdPXMsZX0pLHt9KSxyPWF3YWl0IGsuanNvbigpLHIucmVmcmVzaF90b2tlbj8oaCYmKG8ubGF0ZXN0X3JlZnJlc2hfdG9rZW49ci5yZWZyZXNoX3Rva2VuLE89YyxiPXIucmVmcmVzaF90b2tlbixPYmplY3QuZW50cmllcyhvKS5mb3JFYWNoKChlPT57bGV0W3Qscl09ZTtyPT09TyYmKG9bdF09Yil9KSkpLCgoZSx0LHIpPT57b1tuKHQscildPWV9KShyLnJlZnJlc2hfdG9rZW4sZyx5KSxkZWxldGUgci5yZWZyZXNoX3Rva2VuKTooKGUsdCk9PntkZWxldGUgb1tuKGUsdCldfSkoZyx5KSx1LnBvc3RNZXNzYWdlKHtvazprLm9rLGpzb246cixoZWFkZXJzOmR9KX1jYXRjaChlKXt1LnBvc3RNZXNzYWdlKHtvazohMSxqc29uOntlcnJvcjplLmVycm9yLGVycm9yX2Rlc2NyaXB0aW9uOmUubWVzc2FnZX0saGVhZGVyczpkfSl9dmFyIE8sYixfLGp9KSl9KCk7Cgo=", De = null, Ke = false, function(e2) {
401
+ return Le = Le || Ce(je, De, Ke), new Worker(Le, e2);
402
+ });
403
+ var qe;
404
+ var Be;
405
+ var Xe;
406
+ !(function(e2) {
407
+ e2.Bearer = "Bearer", e2.DPoP = "DPoP";
408
+ })(qe || (qe = {}));
409
+ function et(e2, t2) {
410
+ this.v = e2, this.k = t2;
411
+ }
412
+ function tt(e2, t2, n2) {
413
+ if ("function" == typeof e2 ? e2 === t2 : e2.has(t2)) return arguments.length < 3 ? t2 : n2;
414
+ throw new TypeError("Private element is not present on this object");
415
+ }
416
+ function nt(e2) {
417
+ return new et(e2, 0);
418
+ }
419
+ function ot(e2, t2) {
420
+ if (t2.has(e2)) throw new TypeError("Cannot initialize the same private elements twice on an object");
421
+ }
422
+ function rt(e2, t2) {
423
+ return e2.get(tt(e2, t2));
424
+ }
425
+ function it(e2, t2, n2) {
426
+ ot(e2, t2), t2.set(e2, n2);
427
+ }
428
+ function at(e2, t2, n2) {
429
+ return e2.set(tt(e2, t2), n2), n2;
430
+ }
431
+ function st(e2, t2, n2) {
432
+ return (t2 = (function(e3) {
433
+ var t3 = (function(e4, t4) {
434
+ if ("object" != typeof e4 || !e4) return e4;
435
+ var n3 = e4[Symbol.toPrimitive];
436
+ if (void 0 !== n3) {
437
+ var o2 = n3.call(e4, t4 || "default");
438
+ if ("object" != typeof o2) return o2;
439
+ throw new TypeError("@@toPrimitive must return a primitive value.");
440
+ }
441
+ return ("string" === t4 ? String : Number)(e4);
442
+ })(e3, "string");
443
+ return "symbol" == typeof t3 ? t3 : t3 + "";
444
+ })(t2)) in e2 ? Object.defineProperty(e2, t2, { value: n2, enumerable: true, configurable: true, writable: true }) : e2[t2] = n2, e2;
445
+ }
446
+ function ct(e2, t2) {
447
+ var n2 = Object.keys(e2);
448
+ if (Object.getOwnPropertySymbols) {
449
+ var o2 = Object.getOwnPropertySymbols(e2);
450
+ t2 && (o2 = o2.filter((function(t3) {
451
+ return Object.getOwnPropertyDescriptor(e2, t3).enumerable;
452
+ }))), n2.push.apply(n2, o2);
453
+ }
454
+ return n2;
455
+ }
456
+ function ut(e2) {
457
+ for (var t2 = 1; t2 < arguments.length; t2++) {
458
+ var n2 = null != arguments[t2] ? arguments[t2] : {};
459
+ t2 % 2 ? ct(Object(n2), true).forEach((function(t3) {
460
+ st(e2, t3, n2[t3]);
461
+ })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(n2)) : ct(Object(n2)).forEach((function(t3) {
462
+ Object.defineProperty(e2, t3, Object.getOwnPropertyDescriptor(n2, t3));
463
+ }));
464
+ }
465
+ return e2;
466
+ }
467
+ function lt(e2, t2) {
468
+ if (null == e2) return {};
469
+ var n2, o2, r2 = (function(e3, t3) {
470
+ if (null == e3) return {};
471
+ var n3 = {};
472
+ for (var o3 in e3) if ({}.hasOwnProperty.call(e3, o3)) {
473
+ if (-1 !== t3.indexOf(o3)) continue;
474
+ n3[o3] = e3[o3];
475
+ }
476
+ return n3;
477
+ })(e2, t2);
478
+ if (Object.getOwnPropertySymbols) {
479
+ var i2 = Object.getOwnPropertySymbols(e2);
480
+ for (o2 = 0; o2 < i2.length; o2++) n2 = i2[o2], -1 === t2.indexOf(n2) && {}.propertyIsEnumerable.call(e2, n2) && (r2[n2] = e2[n2]);
481
+ }
482
+ return r2;
483
+ }
484
+ function dt(e2) {
485
+ return function() {
486
+ return new ht(e2.apply(this, arguments));
487
+ };
488
+ }
489
+ function ht(e2) {
490
+ var t2, n2;
491
+ function o2(t3, n3) {
492
+ try {
493
+ var i2 = e2[t3](n3), a2 = i2.value, s2 = a2 instanceof et;
494
+ Promise.resolve(s2 ? a2.v : a2).then((function(n4) {
495
+ if (s2) {
496
+ var c2 = "return" === t3 ? "return" : "next";
497
+ if (!a2.k || n4.done) return o2(c2, n4);
498
+ n4 = e2[c2](n4).value;
499
+ }
500
+ r2(i2.done ? "return" : "normal", n4);
501
+ }), (function(e3) {
502
+ o2("throw", e3);
503
+ }));
504
+ } catch (e3) {
505
+ r2("throw", e3);
506
+ }
507
+ }
508
+ function r2(e3, r3) {
509
+ switch (e3) {
510
+ case "return":
511
+ t2.resolve({ value: r3, done: true });
512
+ break;
513
+ case "throw":
514
+ t2.reject(r3);
515
+ break;
516
+ default:
517
+ t2.resolve({ value: r3, done: false });
518
+ }
519
+ (t2 = t2.next) ? o2(t2.key, t2.arg) : n2 = null;
520
+ }
521
+ this._invoke = function(e3, r3) {
522
+ return new Promise((function(i2, a2) {
523
+ var s2 = { key: e3, arg: r3, resolve: i2, reject: a2, next: null };
524
+ n2 ? n2 = n2.next = s2 : (t2 = n2 = s2, o2(e3, r3));
525
+ }));
526
+ }, "function" != typeof e2.return && (this.return = void 0);
527
+ }
528
+ var pt;
529
+ if (ht.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
530
+ return this;
531
+ }, ht.prototype.next = function(e2) {
532
+ return this._invoke("next", e2);
533
+ }, ht.prototype.throw = function(e2) {
534
+ return this._invoke("throw", e2);
535
+ }, ht.prototype.return = function(e2) {
536
+ return this._invoke("return", e2);
537
+ }, "undefined" == typeof navigator || null === (Be = navigator.userAgent) || void 0 === Be || null === (Xe = Be.startsWith) || void 0 === Xe || !Xe.call(Be, "Mozilla/5.0 ")) {
538
+ const e2 = "v3.8.3";
539
+ pt = "".concat("oauth4webapi", "/").concat(e2);
540
+ }
541
+ function ft(e2, t2) {
542
+ if (null == e2) return false;
543
+ try {
544
+ return e2 instanceof t2 || Object.getPrototypeOf(e2)[Symbol.toStringTag] === t2.prototype[Symbol.toStringTag];
545
+ } catch (e3) {
546
+ return false;
547
+ }
548
+ }
549
+ function mt(e2, t2, n2) {
550
+ const o2 = new TypeError(e2, { cause: n2 });
551
+ return Object.assign(o2, { code: t2 }), o2;
552
+ }
553
+ var yt = /* @__PURE__ */ Symbol();
554
+ var wt = /* @__PURE__ */ Symbol();
555
+ var gt = /* @__PURE__ */ Symbol();
556
+ var vt = /* @__PURE__ */ Symbol();
557
+ var bt = /* @__PURE__ */ Symbol();
558
+ var _t = /* @__PURE__ */ Symbol();
559
+ var kt = new TextEncoder();
560
+ var St = new TextDecoder();
561
+ function Et(e2) {
562
+ return "string" == typeof e2 ? kt.encode(e2) : St.decode(e2);
563
+ }
564
+ var At;
565
+ var Tt;
566
+ if (Uint8Array.prototype.toBase64) At = (e2) => (e2 instanceof ArrayBuffer && (e2 = new Uint8Array(e2)), e2.toBase64({ alphabet: "base64url", omitPadding: true }));
567
+ else {
568
+ const e2 = 32768;
569
+ At = (t2) => {
570
+ t2 instanceof ArrayBuffer && (t2 = new Uint8Array(t2));
571
+ const n2 = [];
572
+ for (let o2 = 0; o2 < t2.byteLength; o2 += e2) n2.push(String.fromCharCode.apply(null, t2.subarray(o2, o2 + e2)));
573
+ return btoa(n2.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
574
+ };
575
+ }
576
+ function Pt(e2) {
577
+ return "string" == typeof e2 ? Tt(e2) : At(e2);
578
+ }
579
+ Tt = Uint8Array.fromBase64 ? (e2) => {
580
+ try {
581
+ return Uint8Array.fromBase64(e2, { alphabet: "base64url" });
582
+ } catch (e3) {
583
+ throw mt("The input to be decoded is not correctly encoded.", "ERR_INVALID_ARG_VALUE", e3);
584
+ }
585
+ } : (e2) => {
586
+ try {
587
+ const t2 = atob(e2.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "")), n2 = new Uint8Array(t2.length);
588
+ for (let e3 = 0; e3 < t2.length; e3++) n2[e3] = t2.charCodeAt(e3);
589
+ return n2;
590
+ } catch (e3) {
591
+ throw mt("The input to be decoded is not correctly encoded.", "ERR_INVALID_ARG_VALUE", e3);
592
+ }
593
+ };
594
+ var Rt = class extends Error {
595
+ constructor(e2, t2) {
596
+ var n2;
597
+ super(e2, t2), st(this, "code", void 0), this.name = this.constructor.name, this.code = Rn, null === (n2 = Error.captureStackTrace) || void 0 === n2 || n2.call(Error, this, this.constructor);
598
+ }
599
+ };
600
+ var It = class extends Error {
601
+ constructor(e2, t2) {
602
+ var n2;
603
+ super(e2, t2), st(this, "code", void 0), this.name = this.constructor.name, null != t2 && t2.code && (this.code = null == t2 ? void 0 : t2.code), null === (n2 = Error.captureStackTrace) || void 0 === n2 || n2.call(Error, this, this.constructor);
604
+ }
605
+ };
606
+ function Ot(e2, t2, n2) {
607
+ return new It(e2, { code: t2, cause: n2 });
608
+ }
609
+ function xt(e2, t2) {
610
+ if ((function(e3, t3) {
611
+ if (!(e3 instanceof CryptoKey)) throw mt("".concat(t3, " must be a CryptoKey"), "ERR_INVALID_ARG_TYPE");
612
+ })(e2, t2), "private" !== e2.type) throw mt("".concat(t2, " must be a private CryptoKey"), "ERR_INVALID_ARG_VALUE");
613
+ }
614
+ function Ct(e2) {
615
+ return null !== e2 && "object" == typeof e2 && !Array.isArray(e2);
616
+ }
617
+ function jt(e2) {
618
+ ft(e2, Headers) && (e2 = Object.fromEntries(e2.entries()));
619
+ const t2 = new Headers(null != e2 ? e2 : {});
620
+ if (pt && !t2.has("user-agent") && t2.set("user-agent", pt), t2.has("authorization")) throw mt('"options.headers" must not include the "authorization" header name', "ERR_INVALID_ARG_VALUE");
621
+ return t2;
622
+ }
623
+ function Dt(e2, t2) {
624
+ if (void 0 !== t2) {
625
+ if ("function" == typeof t2 && (t2 = t2(e2.href)), !(t2 instanceof AbortSignal)) throw mt('"options.signal" must return or be an instance of AbortSignal', "ERR_INVALID_ARG_TYPE");
626
+ return t2;
627
+ }
628
+ }
629
+ function Kt(e2) {
630
+ return e2.includes("//") ? e2.replace("//", "/") : e2;
631
+ }
632
+ async function Lt(e2, t2) {
633
+ return (async function(e3, t3, n2, o2) {
634
+ if (!(e3 instanceof URL)) throw mt('"'.concat(t3, '" must be an instance of URL'), "ERR_INVALID_ARG_TYPE");
635
+ Xt(e3, true !== (null == o2 ? void 0 : o2[yt]));
636
+ const r2 = n2(new URL(e3.href)), i2 = jt(null == o2 ? void 0 : o2.headers);
637
+ return i2.set("accept", "application/json"), ((null == o2 ? void 0 : o2[vt]) || fetch)(r2.href, { body: void 0, headers: Object.fromEntries(i2.entries()), method: "GET", redirect: "manual", signal: Dt(r2, null == o2 ? void 0 : o2.signal) });
638
+ })(e2, "issuerIdentifier", ((e3) => {
639
+ switch (null == t2 ? void 0 : t2.algorithm) {
640
+ case void 0:
641
+ case "oidc":
642
+ !(function(e4, t3) {
643
+ e4.pathname = Kt("".concat(e4.pathname, "/").concat(t3));
644
+ })(e3, ".well-known/openid-configuration");
645
+ break;
646
+ case "oauth2":
647
+ !(function(e4, t3) {
648
+ let n2 = arguments.length > 2 && void 0 !== arguments[2] && arguments[2];
649
+ "/" === e4.pathname ? e4.pathname = t3 : e4.pathname = Kt("".concat(t3, "/").concat(n2 ? e4.pathname : e4.pathname.replace(/(\/)$/, "")));
650
+ })(e3, ".well-known/oauth-authorization-server");
651
+ break;
652
+ default:
653
+ throw mt('"options.algorithm" must be "oidc" (default), or "oauth2"', "ERR_INVALID_ARG_VALUE");
654
+ }
655
+ return e3;
656
+ }), t2);
657
+ }
658
+ function Ut(e2, t2, n2, o2, r2) {
659
+ try {
660
+ if ("number" != typeof e2 || !Number.isFinite(e2)) throw mt("".concat(n2, " must be a number"), "ERR_INVALID_ARG_TYPE", r2);
661
+ if (e2 > 0) return;
662
+ if (t2) {
663
+ if (0 !== e2) throw mt("".concat(n2, " must be a non-negative number"), "ERR_INVALID_ARG_VALUE", r2);
664
+ return;
665
+ }
666
+ throw mt("".concat(n2, " must be a positive number"), "ERR_INVALID_ARG_VALUE", r2);
667
+ } catch (e3) {
668
+ if (o2) throw Ot(e3.message, o2, r2);
669
+ throw e3;
670
+ }
671
+ }
672
+ function Nt(e2, t2, n2, o2) {
673
+ try {
674
+ if ("string" != typeof e2) throw mt("".concat(t2, " must be a string"), "ERR_INVALID_ARG_TYPE", o2);
675
+ if (0 === e2.length) throw mt("".concat(t2, " must not be empty"), "ERR_INVALID_ARG_VALUE", o2);
676
+ } catch (e3) {
677
+ if (n2) throw Ot(e3.message, n2, o2);
678
+ throw e3;
679
+ }
680
+ }
681
+ function Wt(e2) {
682
+ !(function(e3, t2) {
683
+ if (ln(e3) !== t2) throw (function(e4) {
684
+ let t3 = '"response" content-type must be ';
685
+ for (var n2 = arguments.length, o2 = new Array(n2 > 1 ? n2 - 1 : 0), r2 = 1; r2 < n2; r2++) o2[r2 - 1] = arguments[r2];
686
+ if (o2.length > 2) {
687
+ const e5 = o2.pop();
688
+ t3 += "".concat(o2.join(", "), ", or ").concat(e5);
689
+ } else 2 === o2.length ? t3 += "".concat(o2[0], " or ").concat(o2[1]) : t3 += o2[0];
690
+ return Ot(t3, Cn, e4);
691
+ })(e3, t2);
692
+ })(e2, "application/json");
693
+ }
694
+ function Ht() {
695
+ return Pt(crypto.getRandomValues(new Uint8Array(32)));
696
+ }
697
+ function zt(e2) {
698
+ switch (e2.algorithm.name) {
699
+ case "RSA-PSS":
700
+ return (function(e3) {
701
+ switch (e3.algorithm.hash.name) {
702
+ case "SHA-256":
703
+ return "PS256";
704
+ case "SHA-384":
705
+ return "PS384";
706
+ case "SHA-512":
707
+ return "PS512";
708
+ default:
709
+ throw new Rt("unsupported RsaHashedKeyAlgorithm hash name", { cause: e3 });
710
+ }
711
+ })(e2);
712
+ case "RSASSA-PKCS1-v1_5":
713
+ return (function(e3) {
714
+ switch (e3.algorithm.hash.name) {
715
+ case "SHA-256":
716
+ return "RS256";
717
+ case "SHA-384":
718
+ return "RS384";
719
+ case "SHA-512":
720
+ return "RS512";
721
+ default:
722
+ throw new Rt("unsupported RsaHashedKeyAlgorithm hash name", { cause: e3 });
723
+ }
724
+ })(e2);
725
+ case "ECDSA":
726
+ return (function(e3) {
727
+ switch (e3.algorithm.namedCurve) {
728
+ case "P-256":
729
+ return "ES256";
730
+ case "P-384":
731
+ return "ES384";
732
+ case "P-521":
733
+ return "ES512";
734
+ default:
735
+ throw new Rt("unsupported EcKeyAlgorithm namedCurve", { cause: e3 });
736
+ }
737
+ })(e2);
738
+ case "Ed25519":
739
+ case "ML-DSA-44":
740
+ case "ML-DSA-65":
741
+ case "ML-DSA-87":
742
+ return e2.algorithm.name;
743
+ case "EdDSA":
744
+ return "Ed25519";
745
+ default:
746
+ throw new Rt("unsupported CryptoKey algorithm name", { cause: e2 });
747
+ }
748
+ }
749
+ function Jt(e2) {
750
+ const t2 = null == e2 ? void 0 : e2[wt];
751
+ return "number" == typeof t2 && Number.isFinite(t2) ? t2 : 0;
752
+ }
753
+ function Mt(e2) {
754
+ const t2 = null == e2 ? void 0 : e2[gt];
755
+ return "number" == typeof t2 && Number.isFinite(t2) && -1 !== Math.sign(t2) ? t2 : 30;
756
+ }
757
+ function Vt() {
758
+ return Math.floor(Date.now() / 1e3);
759
+ }
760
+ function Gt(e2) {
761
+ if ("object" != typeof e2 || null === e2) throw mt('"as" must be an object', "ERR_INVALID_ARG_TYPE");
762
+ Nt(e2.issuer, '"as.issuer"');
763
+ }
764
+ function Ft(e2) {
765
+ if ("object" != typeof e2 || null === e2) throw mt('"client" must be an object', "ERR_INVALID_ARG_TYPE");
766
+ Nt(e2.client_id, '"client.client_id"');
767
+ }
768
+ function Zt(e2) {
769
+ return Nt(e2, '"clientSecret"'), (t2, n2, o2, r2) => {
770
+ o2.set("client_id", n2.client_id), o2.set("client_secret", e2);
771
+ };
772
+ }
773
+ function qt(e2, t2) {
774
+ const { key: n2, kid: o2 } = (r2 = e2) instanceof CryptoKey ? { key: r2 } : (null == r2 ? void 0 : r2.key) instanceof CryptoKey ? (void 0 !== r2.kid && Nt(r2.kid, '"kid"'), { key: r2.key, kid: r2.kid }) : {};
775
+ var r2;
776
+ return xt(n2, '"clientPrivateKey.key"'), async (e3, r3, i2, a2) => {
777
+ var s2;
778
+ const c2 = { alg: zt(n2), kid: o2 }, u2 = (function(e4, t3) {
779
+ const n3 = Vt() + Jt(t3);
780
+ return { jti: Ht(), aud: e4.issuer, exp: n3 + 60, iat: n3, nbf: n3, iss: t3.client_id, sub: t3.client_id };
781
+ })(e3, r3);
782
+ null == t2 || null === (s2 = t2[bt]) || void 0 === s2 || s2.call(t2, c2, u2), i2.set("client_id", r3.client_id), i2.set("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"), i2.set("client_assertion", await (async function(e4, t3, n3) {
783
+ if (!n3.usages.includes("sign")) throw mt('CryptoKey instances used for signing assertions must include "sign" in their "usages"', "ERR_INVALID_ARG_VALUE");
784
+ const o3 = "".concat(Pt(Et(JSON.stringify(e4))), ".").concat(Pt(Et(JSON.stringify(t3)))), r4 = Pt(await crypto.subtle.sign((function(e5) {
785
+ switch (e5.algorithm.name) {
786
+ case "ECDSA":
787
+ return { name: e5.algorithm.name, hash: Mn(e5) };
788
+ case "RSA-PSS":
789
+ switch (Jn(e5), e5.algorithm.hash.name) {
790
+ case "SHA-256":
791
+ case "SHA-384":
792
+ case "SHA-512":
793
+ return { name: e5.algorithm.name, saltLength: parseInt(e5.algorithm.hash.name.slice(-3), 10) >> 3 };
794
+ default:
795
+ throw new Rt("unsupported RSA-PSS hash name", { cause: e5 });
796
+ }
797
+ case "RSASSA-PKCS1-v1_5":
798
+ return Jn(e5), e5.algorithm.name;
799
+ case "ML-DSA-44":
800
+ case "ML-DSA-65":
801
+ case "ML-DSA-87":
802
+ case "Ed25519":
803
+ return e5.algorithm.name;
804
+ }
805
+ throw new Rt("unsupported CryptoKey algorithm name", { cause: e5 });
806
+ })(n3), n3, Et(o3)));
807
+ return "".concat(o3, ".").concat(r4);
808
+ })(c2, u2, n2));
809
+ };
810
+ }
811
+ var Bt = URL.parse ? (e2, t2) => URL.parse(e2, t2) : (e2, t2) => {
812
+ try {
813
+ return new URL(e2, t2);
814
+ } catch (e3) {
815
+ return null;
816
+ }
817
+ };
818
+ function Xt(e2, t2) {
819
+ if (t2 && "https:" !== e2.protocol) throw Ot("only requests to HTTPS are allowed", Dn, e2);
820
+ if ("https:" !== e2.protocol && "http:" !== e2.protocol) throw Ot("only HTTP and HTTPS requests are allowed", Kn, e2);
821
+ }
822
+ function Yt(e2, t2, n2, o2) {
823
+ let r2;
824
+ if ("string" != typeof e2 || !(r2 = Bt(e2))) throw Ot("authorization server metadata does not contain a valid ".concat(n2 ? '"as.mtls_endpoint_aliases.'.concat(t2, '"') : '"as.'.concat(t2, '"')), void 0 === e2 ? Wn : Hn, { attribute: n2 ? "mtls_endpoint_aliases.".concat(t2) : t2 });
825
+ return Xt(r2, o2), r2;
826
+ }
827
+ function Qt(e2, t2, n2, o2) {
828
+ return n2 && e2.mtls_endpoint_aliases && t2 in e2.mtls_endpoint_aliases ? Yt(e2.mtls_endpoint_aliases[t2], t2, n2, o2) : Yt(e2[t2], t2, n2, o2);
829
+ }
830
+ var $t = class extends Error {
831
+ constructor(e2, t2) {
832
+ var n2;
833
+ super(e2, t2), st(this, "cause", void 0), st(this, "code", void 0), st(this, "error", void 0), st(this, "status", void 0), st(this, "error_description", void 0), st(this, "response", void 0), this.name = this.constructor.name, this.code = Pn, this.cause = t2.cause, this.error = t2.cause.error, this.status = t2.response.status, this.error_description = t2.cause.error_description, Object.defineProperty(this, "response", { enumerable: false, value: t2.response }), null === (n2 = Error.captureStackTrace) || void 0 === n2 || n2.call(Error, this, this.constructor);
834
+ }
835
+ };
836
+ var en = class extends Error {
837
+ constructor(e2, t2) {
838
+ var n2, o2;
839
+ super(e2, t2), st(this, "cause", void 0), st(this, "code", void 0), st(this, "error", void 0), st(this, "error_description", void 0), this.name = this.constructor.name, this.code = In, this.cause = t2.cause, this.error = t2.cause.get("error"), this.error_description = null !== (n2 = t2.cause.get("error_description")) && void 0 !== n2 ? n2 : void 0, null === (o2 = Error.captureStackTrace) || void 0 === o2 || o2.call(Error, this, this.constructor);
840
+ }
841
+ };
842
+ var tn = class extends Error {
843
+ constructor(e2, t2) {
844
+ var n2;
845
+ super(e2, t2), st(this, "cause", void 0), st(this, "code", void 0), st(this, "response", void 0), st(this, "status", void 0), this.name = this.constructor.name, this.code = Tn, this.cause = t2.cause, this.status = t2.response.status, this.response = t2.response, Object.defineProperty(this, "response", { enumerable: false }), null === (n2 = Error.captureStackTrace) || void 0 === n2 || n2.call(Error, this, this.constructor);
846
+ }
847
+ };
848
+ var nn = "[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+";
849
+ var on = new RegExp("^[,\\s]*(" + nn + ")");
850
+ var rn = new RegExp('^[,\\s]*([a-zA-Z0-9!#$%&\\\'\\*\\+\\-\\.\\^_`\\|~]+)\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"[,\\s]*(.*)');
851
+ var an = new RegExp("^[,\\s]*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)\\s*=\\s*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)[,\\s]*(.*)");
852
+ var sn = new RegExp("^([a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2})(?:$|[,\\s])(.*)");
853
+ async function cn(e2, t2, n2) {
854
+ if (e2.status !== t2) {
855
+ let t3;
856
+ var o2;
857
+ if ((function(e3) {
858
+ let t4;
859
+ if (t4 = (function(e4) {
860
+ if (!ft(e4, Response)) throw mt('"response" must be an instance of Response', "ERR_INVALID_ARG_TYPE");
861
+ const t5 = e4.headers.get("www-authenticate");
862
+ if (null === t5) return;
863
+ const n3 = [];
864
+ let o3 = t5;
865
+ for (; o3; ) {
866
+ var r2;
867
+ let e5 = o3.match(on);
868
+ const t6 = null === (r2 = e5) || void 0 === r2 ? void 0 : r2[1].toLowerCase();
869
+ if (!t6) return;
870
+ const i2 = o3.substring(e5[0].length);
871
+ if (i2 && !i2.match(/^[\s,]/)) return;
872
+ const a2 = i2.match(/^\s+(.*)$/), s2 = !!a2;
873
+ o3 = a2 ? a2[1] : void 0;
874
+ const c2 = {};
875
+ let u2;
876
+ if (s2) for (; o3; ) {
877
+ let t7, n4;
878
+ if (e5 = o3.match(rn)) {
879
+ if ([, t7, n4, o3] = e5, n4.includes("\\")) try {
880
+ n4 = JSON.parse('"'.concat(n4, '"'));
881
+ } catch (e6) {
882
+ }
883
+ c2[t7.toLowerCase()] = n4;
884
+ } else {
885
+ if (!(e5 = o3.match(an))) {
886
+ if (e5 = o3.match(sn)) {
887
+ if (Object.keys(c2).length) break;
888
+ [, u2, o3] = e5;
889
+ break;
890
+ }
891
+ return;
892
+ }
893
+ [, t7, n4, o3] = e5, c2[t7.toLowerCase()] = n4;
894
+ }
895
+ }
896
+ else o3 = i2 || void 0;
897
+ const l2 = { scheme: t6, parameters: c2 };
898
+ u2 && (l2.token68 = u2), n3.push(l2);
899
+ }
900
+ return n3.length ? n3 : void 0;
901
+ })(e3)) throw new tn("server responded with a challenge in the WWW-Authenticate HTTP Header", { cause: t4, response: e3 });
902
+ })(e2), t3 = await (async function(e3) {
903
+ if (e3.status > 399 && e3.status < 500) {
904
+ zn(e3), Wt(e3);
905
+ try {
906
+ const t4 = await e3.clone().json();
907
+ if (Ct(t4) && "string" == typeof t4.error && t4.error.length) return t4;
908
+ } catch (e4) {
909
+ }
910
+ }
911
+ })(e2)) throw await (null === (o2 = e2.body) || void 0 === o2 ? void 0 : o2.cancel()), new $t("server responded with an error in the response body", { cause: t3, response: e2 });
912
+ throw Ot('"response" is not a conform '.concat(n2, " response (unexpected HTTP status code)"), jn, e2);
913
+ }
914
+ }
915
+ function un(e2) {
916
+ if (!vn.has(e2)) throw mt('"options.DPoP" is not a valid DPoPHandle', "ERR_INVALID_ARG_VALUE");
917
+ }
918
+ function ln(e2) {
919
+ var t2;
920
+ return null === (t2 = e2.headers.get("content-type")) || void 0 === t2 ? void 0 : t2.split(";")[0];
921
+ }
922
+ async function dn(e2, t2, n2, o2, r2, i2, a2) {
923
+ return await n2(e2, t2, r2, i2), i2.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"), ((null == a2 ? void 0 : a2[vt]) || fetch)(o2.href, { body: r2, headers: Object.fromEntries(i2.entries()), method: "POST", redirect: "manual", signal: Dt(o2, null == a2 ? void 0 : a2.signal) });
924
+ }
925
+ async function hn(e2, t2, n2, o2, r2, i2) {
926
+ var a2;
927
+ const s2 = Qt(e2, "token_endpoint", t2.use_mtls_endpoint_aliases, true !== (null == i2 ? void 0 : i2[yt]));
928
+ r2.set("grant_type", o2);
929
+ const c2 = jt(null == i2 ? void 0 : i2.headers);
930
+ c2.set("accept", "application/json"), void 0 !== (null == i2 ? void 0 : i2.DPoP) && (un(i2.DPoP), await i2.DPoP.addProof(s2, c2, "POST"));
931
+ const u2 = await dn(e2, t2, n2, s2, r2, c2, i2);
932
+ return null == i2 || null === (a2 = i2.DPoP) || void 0 === a2 || a2.cacheNonce(u2, s2), u2;
933
+ }
934
+ var pn = /* @__PURE__ */ new WeakMap();
935
+ var fn = /* @__PURE__ */ new WeakMap();
936
+ function mn(e2) {
937
+ if (!e2.id_token) return;
938
+ const t2 = pn.get(e2);
939
+ if (!t2) throw mt('"ref" was already garbage collected or did not resolve from the proper sources', "ERR_INVALID_ARG_VALUE");
940
+ return t2;
941
+ }
942
+ async function yn(e2, t2, n2, o2, r2, i2) {
943
+ if (Gt(e2), Ft(t2), !ft(n2, Response)) throw mt('"response" must be an instance of Response', "ERR_INVALID_ARG_TYPE");
944
+ await cn(n2, 200, "Token Endpoint"), zn(n2);
945
+ const a2 = await Xn(n2);
946
+ if (Nt(a2.access_token, '"response" body "access_token" property', xn, { body: a2 }), Nt(a2.token_type, '"response" body "token_type" property', xn, { body: a2 }), a2.token_type = a2.token_type.toLowerCase(), void 0 !== a2.expires_in) {
947
+ let e3 = "number" != typeof a2.expires_in ? parseFloat(a2.expires_in) : a2.expires_in;
948
+ Ut(e3, true, '"response" body "expires_in" property', xn, { body: a2 }), a2.expires_in = e3;
949
+ }
950
+ if (void 0 !== a2.refresh_token && Nt(a2.refresh_token, '"response" body "refresh_token" property', xn, { body: a2 }), void 0 !== a2.scope && "string" != typeof a2.scope) throw Ot('"response" body "scope" property must be a string', xn, { body: a2 });
951
+ if (void 0 !== a2.id_token) {
952
+ Nt(a2.id_token, '"response" body "id_token" property', xn, { body: a2 });
953
+ const i3 = ["aud", "exp", "iat", "iss", "sub"];
954
+ true === t2.require_auth_time && i3.push("auth_time"), void 0 !== t2.default_max_age && (Ut(t2.default_max_age, true, '"client.default_max_age"'), i3.push("auth_time")), null != o2 && o2.length && i3.push(...o2);
955
+ const { claims: s2, jwt: c2 } = await (async function(e3, t3, n3, o3, r3) {
956
+ let i4, a3, { 0: s3, 1: c3, length: u2 } = e3.split(".");
957
+ if (5 === u2) {
958
+ if (void 0 === r3) throw new Rt("JWE decryption is not configured", { cause: e3 });
959
+ e3 = await r3(e3), { 0: s3, 1: c3, length: u2 } = e3.split(".");
960
+ }
961
+ if (3 !== u2) throw Ot("Invalid JWT", xn, e3);
962
+ try {
963
+ i4 = JSON.parse(Et(Pt(s3)));
964
+ } catch (e4) {
965
+ throw Ot("failed to parse JWT Header body as base64url encoded JSON", On, e4);
966
+ }
967
+ if (!Ct(i4)) throw Ot("JWT Header must be a top level object", xn, e3);
968
+ if (t3(i4), void 0 !== i4.crit) throw new Rt('no JWT "crit" header parameter extensions are supported', { cause: { header: i4 } });
969
+ try {
970
+ a3 = JSON.parse(Et(Pt(c3)));
971
+ } catch (e4) {
972
+ throw Ot("failed to parse JWT Payload body as base64url encoded JSON", On, e4);
973
+ }
974
+ if (!Ct(a3)) throw Ot("JWT Payload must be a top level object", xn, e3);
975
+ const l2 = Vt() + n3;
976
+ if (void 0 !== a3.exp) {
977
+ if ("number" != typeof a3.exp) throw Ot('unexpected JWT "exp" (expiration time) claim type', xn, { claims: a3 });
978
+ if (a3.exp <= l2 - o3) throw Ot('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp', Ln, { claims: a3, now: l2, tolerance: o3, claim: "exp" });
979
+ }
980
+ if (void 0 !== a3.iat && "number" != typeof a3.iat) throw Ot('unexpected JWT "iat" (issued at) claim type', xn, { claims: a3 });
981
+ if (void 0 !== a3.iss && "string" != typeof a3.iss) throw Ot('unexpected JWT "iss" (issuer) claim type', xn, { claims: a3 });
982
+ if (void 0 !== a3.nbf) {
983
+ if ("number" != typeof a3.nbf) throw Ot('unexpected JWT "nbf" (not before) claim type', xn, { claims: a3 });
984
+ if (a3.nbf > l2 + o3) throw Ot('unexpected JWT "nbf" (not before) claim value', Ln, { claims: a3, now: l2, tolerance: o3, claim: "nbf" });
985
+ }
986
+ if (void 0 !== a3.aud && "string" != typeof a3.aud && !Array.isArray(a3.aud)) throw Ot('unexpected JWT "aud" (audience) claim type', xn, { claims: a3 });
987
+ return { header: i4, claims: a3, jwt: e3 };
988
+ })(a2.id_token, Gn.bind(void 0, t2.id_token_signed_response_alg, e2.id_token_signing_alg_values_supported, "RS256"), Jt(t2), Mt(t2), r2).then(kn.bind(void 0, i3)).then(gn.bind(void 0, e2)).then(wn.bind(void 0, t2.client_id));
989
+ if (Array.isArray(s2.aud) && 1 !== s2.aud.length) {
990
+ if (void 0 === s2.azp) throw Ot('ID Token "aud" (audience) claim includes additional untrusted audiences', Un, { claims: s2, claim: "aud" });
991
+ if (s2.azp !== t2.client_id) throw Ot('unexpected ID Token "azp" (authorized party) claim value', Un, { expected: t2.client_id, claims: s2, claim: "azp" });
992
+ }
993
+ void 0 !== s2.auth_time && Ut(s2.auth_time, true, 'ID Token "auth_time" (authentication time)', xn, { claims: s2 }), fn.set(n2, c2), pn.set(a2, s2);
994
+ }
995
+ if (void 0 !== (null == i2 ? void 0 : i2[a2.token_type])) i2[a2.token_type](n2, a2);
996
+ else if ("dpop" !== a2.token_type && "bearer" !== a2.token_type) throw new Rt("unsupported `token_type` value", { cause: { body: a2 } });
997
+ return a2;
998
+ }
999
+ function wn(e2, t2) {
1000
+ if (Array.isArray(t2.claims.aud)) {
1001
+ if (!t2.claims.aud.includes(e2)) throw Ot('unexpected JWT "aud" (audience) claim value', Un, { expected: e2, claims: t2.claims, claim: "aud" });
1002
+ } else if (t2.claims.aud !== e2) throw Ot('unexpected JWT "aud" (audience) claim value', Un, { expected: e2, claims: t2.claims, claim: "aud" });
1003
+ return t2;
1004
+ }
1005
+ function gn(e2, t2) {
1006
+ var n2, o2;
1007
+ const r2 = null !== (n2 = null === (o2 = e2[Qn]) || void 0 === o2 ? void 0 : o2.call(e2, t2)) && void 0 !== n2 ? n2 : e2.issuer;
1008
+ if (t2.claims.iss !== r2) throw Ot('unexpected JWT "iss" (issuer) claim value', Un, { expected: r2, claims: t2.claims, claim: "iss" });
1009
+ return t2;
1010
+ }
1011
+ var vn = /* @__PURE__ */ new WeakSet();
1012
+ var bn = /* @__PURE__ */ Symbol();
1013
+ var _n = { aud: "audience", c_hash: "code hash", client_id: "client id", exp: "expiration time", iat: "issued at", iss: "issuer", jti: "jwt id", nonce: "nonce", s_hash: "state hash", sub: "subject", ath: "access token hash", htm: "http method", htu: "http uri", cnf: "confirmation", auth_time: "authentication time" };
1014
+ function kn(e2, t2) {
1015
+ for (const n2 of e2) if (void 0 === t2.claims[n2]) throw Ot('JWT "'.concat(n2, '" (').concat(_n[n2], ") claim missing"), xn, { claims: t2.claims });
1016
+ return t2;
1017
+ }
1018
+ var Sn = /* @__PURE__ */ Symbol();
1019
+ var En = /* @__PURE__ */ Symbol();
1020
+ async function An(e2, t2, n2, o2) {
1021
+ return "string" == typeof (null == o2 ? void 0 : o2.expectedNonce) || "number" == typeof (null == o2 ? void 0 : o2.maxAge) || null != o2 && o2.requireIdToken ? (async function(e3, t3, n3, o3, r2, i2, a2) {
1022
+ const s2 = [];
1023
+ switch (o3) {
1024
+ case void 0:
1025
+ o3 = Sn;
1026
+ break;
1027
+ case Sn:
1028
+ break;
1029
+ default:
1030
+ Nt(o3, '"expectedNonce" argument'), s2.push("nonce");
1031
+ }
1032
+ switch (null != r2 || (r2 = t3.default_max_age), r2) {
1033
+ case void 0:
1034
+ r2 = En;
1035
+ break;
1036
+ case En:
1037
+ break;
1038
+ default:
1039
+ Ut(r2, true, '"maxAge" argument'), s2.push("auth_time");
1040
+ }
1041
+ const c2 = await yn(e3, t3, n3, s2, i2, a2);
1042
+ Nt(c2.id_token, '"response" body "id_token" property', xn, { body: c2 });
1043
+ const u2 = mn(c2);
1044
+ if (r2 !== En) {
1045
+ const e4 = Vt() + Jt(t3), n4 = Mt(t3);
1046
+ if (u2.auth_time + r2 < e4 - n4) throw Ot("too much time has elapsed since the last End-User authentication", Ln, { claims: u2, now: e4, tolerance: n4, claim: "auth_time" });
1047
+ }
1048
+ if (o3 === Sn) {
1049
+ if (void 0 !== u2.nonce) throw Ot('unexpected ID Token "nonce" claim value', Un, { expected: void 0, claims: u2, claim: "nonce" });
1050
+ } else if (u2.nonce !== o3) throw Ot('unexpected ID Token "nonce" claim value', Un, { expected: o3, claims: u2, claim: "nonce" });
1051
+ return c2;
1052
+ })(e2, t2, n2, o2.expectedNonce, o2.maxAge, o2[_t], o2.recognizedTokenTypes) : (async function(e3, t3, n3, o3, r2) {
1053
+ const i2 = await yn(e3, t3, n3, void 0, o3, r2), a2 = mn(i2);
1054
+ if (a2) {
1055
+ if (void 0 !== t3.default_max_age) {
1056
+ Ut(t3.default_max_age, true, '"client.default_max_age"');
1057
+ const e4 = Vt() + Jt(t3), n4 = Mt(t3);
1058
+ if (a2.auth_time + t3.default_max_age < e4 - n4) throw Ot("too much time has elapsed since the last End-User authentication", Ln, { claims: a2, now: e4, tolerance: n4, claim: "auth_time" });
1059
+ }
1060
+ if (void 0 !== a2.nonce) throw Ot('unexpected ID Token "nonce" claim value', Un, { expected: void 0, claims: a2, claim: "nonce" });
1061
+ }
1062
+ return i2;
1063
+ })(e2, t2, n2, null == o2 ? void 0 : o2[_t], null == o2 ? void 0 : o2.recognizedTokenTypes);
1064
+ }
1065
+ var Tn = "OAUTH_WWW_AUTHENTICATE_CHALLENGE";
1066
+ var Pn = "OAUTH_RESPONSE_BODY_ERROR";
1067
+ var Rn = "OAUTH_UNSUPPORTED_OPERATION";
1068
+ var In = "OAUTH_AUTHORIZATION_RESPONSE_ERROR";
1069
+ var On = "OAUTH_PARSE_ERROR";
1070
+ var xn = "OAUTH_INVALID_RESPONSE";
1071
+ var Cn = "OAUTH_RESPONSE_IS_NOT_JSON";
1072
+ var jn = "OAUTH_RESPONSE_IS_NOT_CONFORM";
1073
+ var Dn = "OAUTH_HTTP_REQUEST_FORBIDDEN";
1074
+ var Kn = "OAUTH_REQUEST_PROTOCOL_FORBIDDEN";
1075
+ var Ln = "OAUTH_JWT_TIMESTAMP_CHECK_FAILED";
1076
+ var Un = "OAUTH_JWT_CLAIM_COMPARISON_FAILED";
1077
+ var Nn = "OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED";
1078
+ var Wn = "OAUTH_MISSING_SERVER_METADATA";
1079
+ var Hn = "OAUTH_INVALID_SERVER_METADATA";
1080
+ function zn(e2) {
1081
+ if (e2.bodyUsed) throw mt('"response" body has been used already', "ERR_INVALID_ARG_VALUE");
1082
+ }
1083
+ function Jn(e2) {
1084
+ const { algorithm: t2 } = e2;
1085
+ if ("number" != typeof t2.modulusLength || t2.modulusLength < 2048) throw new Rt("unsupported ".concat(t2.name, " modulusLength"), { cause: e2 });
1086
+ }
1087
+ function Mn(e2) {
1088
+ const { algorithm: t2 } = e2;
1089
+ switch (t2.namedCurve) {
1090
+ case "P-256":
1091
+ return "SHA-256";
1092
+ case "P-384":
1093
+ return "SHA-384";
1094
+ case "P-521":
1095
+ return "SHA-512";
1096
+ default:
1097
+ throw new Rt("unsupported ECDSA namedCurve", { cause: e2 });
1098
+ }
1099
+ }
1100
+ async function Vn(e2) {
1101
+ if ("POST" !== e2.method) throw mt("form_post responses are expected to use the POST method", "ERR_INVALID_ARG_VALUE", { cause: e2 });
1102
+ if ("application/x-www-form-urlencoded" !== ln(e2)) throw mt("form_post responses are expected to use the application/x-www-form-urlencoded content-type", "ERR_INVALID_ARG_VALUE", { cause: e2 });
1103
+ return (async function(e3) {
1104
+ if (e3.bodyUsed) throw mt("form_post Request instances must contain a readable body", "ERR_INVALID_ARG_VALUE", { cause: e3 });
1105
+ return e3.text();
1106
+ })(e2);
1107
+ }
1108
+ function Gn(e2, t2, n2, o2) {
1109
+ if (void 0 === e2) if (Array.isArray(t2)) {
1110
+ if (!t2.includes(o2.alg)) throw Ot('unexpected JWT "alg" header parameter', xn, { header: o2, expected: t2, reason: "authorization server metadata" });
1111
+ } else {
1112
+ if (void 0 === n2) throw Ot('missing client or server configuration to verify used JWT "alg" header parameter', void 0, { client: e2, issuer: t2, fallback: n2 });
1113
+ if ("string" == typeof n2 ? o2.alg !== n2 : "function" == typeof n2 ? !n2(o2.alg) : !n2.includes(o2.alg)) throw Ot('unexpected JWT "alg" header parameter', xn, { header: o2, expected: n2, reason: "default value" });
1114
+ }
1115
+ else if ("string" == typeof e2 ? o2.alg !== e2 : !e2.includes(o2.alg)) throw Ot('unexpected JWT "alg" header parameter', xn, { header: o2, expected: e2, reason: "client configuration" });
1116
+ }
1117
+ function Fn(e2, t2) {
1118
+ const { 0: n2, length: o2 } = e2.getAll(t2);
1119
+ if (o2 > 1) throw Ot('"'.concat(t2, '" parameter must be provided only once'), xn);
1120
+ return n2;
1121
+ }
1122
+ var Zn = /* @__PURE__ */ Symbol();
1123
+ var qn = /* @__PURE__ */ Symbol();
1124
+ function Bn(e2, t2, n2, o2) {
1125
+ if (Gt(e2), Ft(t2), n2 instanceof URL && (n2 = n2.searchParams), !(n2 instanceof URLSearchParams)) throw mt('"parameters" must be an instance of URLSearchParams, or URL', "ERR_INVALID_ARG_TYPE");
1126
+ if (Fn(n2, "response")) throw Ot('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()', xn, { parameters: n2 });
1127
+ const r2 = Fn(n2, "iss"), i2 = Fn(n2, "state");
1128
+ if (!r2 && e2.authorization_response_iss_parameter_supported) throw Ot('response parameter "iss" (issuer) missing', xn, { parameters: n2 });
1129
+ if (r2 && r2 !== e2.issuer) throw Ot('unexpected "iss" (issuer) response parameter value', xn, { expected: e2.issuer, parameters: n2 });
1130
+ switch (o2) {
1131
+ case void 0:
1132
+ case qn:
1133
+ if (void 0 !== i2) throw Ot('unexpected "state" response parameter encountered', xn, { expected: void 0, parameters: n2 });
1134
+ break;
1135
+ case Zn:
1136
+ break;
1137
+ default:
1138
+ if (Nt(o2, '"expectedState" argument'), i2 !== o2) throw Ot(void 0 === i2 ? 'response parameter "state" missing' : 'unexpected "state" response parameter value', xn, { expected: o2, parameters: n2 });
1139
+ }
1140
+ if (Fn(n2, "error")) throw new en("authorization response from the server is an error", { cause: n2 });
1141
+ const a2 = Fn(n2, "id_token"), s2 = Fn(n2, "token");
1142
+ if (void 0 !== a2 || void 0 !== s2) throw new Rt("implicit and hybrid flows are not supported");
1143
+ return c2 = new URLSearchParams(n2), vn.add(c2), c2;
1144
+ var c2;
1145
+ }
1146
+ async function Xn(e2) {
1147
+ let t2, n2 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : Wt;
1148
+ try {
1149
+ t2 = await e2.json();
1150
+ } catch (t3) {
1151
+ throw n2(e2), Ot('failed to parse "response" body as JSON', On, t3);
1152
+ }
1153
+ if (!Ct(t2)) throw Ot('"response" body must be a top level object', xn, { body: t2 });
1154
+ return t2;
1155
+ }
1156
+ var Yn = /* @__PURE__ */ Symbol();
1157
+ var Qn = /* @__PURE__ */ Symbol();
1158
+ var $n = new TextEncoder();
1159
+ var eo = new TextDecoder();
1160
+ function to(e2) {
1161
+ const t2 = new Uint8Array(e2.length);
1162
+ for (let n2 = 0; n2 < e2.length; n2++) {
1163
+ const o2 = e2.charCodeAt(n2);
1164
+ if (o2 > 127) throw new TypeError("non-ASCII string encountered in encode()");
1165
+ t2[n2] = o2;
1166
+ }
1167
+ return t2;
1168
+ }
1169
+ function no(e2) {
1170
+ if (Uint8Array.fromBase64) return Uint8Array.fromBase64(e2);
1171
+ const t2 = atob(e2), n2 = new Uint8Array(t2.length);
1172
+ for (let e3 = 0; e3 < t2.length; e3++) n2[e3] = t2.charCodeAt(e3);
1173
+ return n2;
1174
+ }
1175
+ function oo(e2) {
1176
+ if (Uint8Array.fromBase64) return Uint8Array.fromBase64("string" == typeof e2 ? e2 : eo.decode(e2), { alphabet: "base64url" });
1177
+ let t2 = e2;
1178
+ t2 instanceof Uint8Array && (t2 = eo.decode(t2)), t2 = t2.replace(/-/g, "+").replace(/_/g, "/");
1179
+ try {
1180
+ return no(t2);
1181
+ } catch (e3) {
1182
+ throw new TypeError("The input to be decoded is not correctly encoded.");
1183
+ }
1184
+ }
1185
+ var ro = class extends Error {
1186
+ constructor(e2, t2) {
1187
+ var n2;
1188
+ super(e2, t2), st(this, "code", "ERR_JOSE_GENERIC"), this.name = this.constructor.name, null === (n2 = Error.captureStackTrace) || void 0 === n2 || n2.call(Error, this, this.constructor);
1189
+ }
1190
+ };
1191
+ st(ro, "code", "ERR_JOSE_GENERIC");
1192
+ var io = class extends ro {
1193
+ constructor(e2, t2) {
1194
+ let n2 = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "unspecified", o2 = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : "unspecified";
1195
+ super(e2, { cause: { claim: n2, reason: o2, payload: t2 } }), st(this, "code", "ERR_JWT_CLAIM_VALIDATION_FAILED"), st(this, "claim", void 0), st(this, "reason", void 0), st(this, "payload", void 0), this.claim = n2, this.reason = o2, this.payload = t2;
1196
+ }
1197
+ };
1198
+ st(io, "code", "ERR_JWT_CLAIM_VALIDATION_FAILED");
1199
+ var ao = class extends ro {
1200
+ constructor(e2, t2) {
1201
+ let n2 = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "unspecified", o2 = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : "unspecified";
1202
+ super(e2, { cause: { claim: n2, reason: o2, payload: t2 } }), st(this, "code", "ERR_JWT_EXPIRED"), st(this, "claim", void 0), st(this, "reason", void 0), st(this, "payload", void 0), this.claim = n2, this.reason = o2, this.payload = t2;
1203
+ }
1204
+ };
1205
+ st(ao, "code", "ERR_JWT_EXPIRED");
1206
+ var so = class extends ro {
1207
+ constructor() {
1208
+ super(...arguments), st(this, "code", "ERR_JOSE_ALG_NOT_ALLOWED");
1209
+ }
1210
+ };
1211
+ st(so, "code", "ERR_JOSE_ALG_NOT_ALLOWED");
1212
+ var co = class extends ro {
1213
+ constructor() {
1214
+ super(...arguments), st(this, "code", "ERR_JOSE_NOT_SUPPORTED");
1215
+ }
1216
+ };
1217
+ st(co, "code", "ERR_JOSE_NOT_SUPPORTED");
1218
+ st(class extends ro {
1219
+ constructor() {
1220
+ super(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "decryption operation failed", arguments.length > 1 ? arguments[1] : void 0), st(this, "code", "ERR_JWE_DECRYPTION_FAILED");
1221
+ }
1222
+ }, "code", "ERR_JWE_DECRYPTION_FAILED");
1223
+ st(class extends ro {
1224
+ constructor() {
1225
+ super(...arguments), st(this, "code", "ERR_JWE_INVALID");
1226
+ }
1227
+ }, "code", "ERR_JWE_INVALID");
1228
+ var uo = class extends ro {
1229
+ constructor() {
1230
+ super(...arguments), st(this, "code", "ERR_JWS_INVALID");
1231
+ }
1232
+ };
1233
+ st(uo, "code", "ERR_JWS_INVALID");
1234
+ var lo = class extends ro {
1235
+ constructor() {
1236
+ super(...arguments), st(this, "code", "ERR_JWT_INVALID");
1237
+ }
1238
+ };
1239
+ st(lo, "code", "ERR_JWT_INVALID");
1240
+ st(class extends ro {
1241
+ constructor() {
1242
+ super(...arguments), st(this, "code", "ERR_JWK_INVALID");
1243
+ }
1244
+ }, "code", "ERR_JWK_INVALID");
1245
+ var ho = class extends ro {
1246
+ constructor() {
1247
+ super(...arguments), st(this, "code", "ERR_JWKS_INVALID");
1248
+ }
1249
+ };
1250
+ st(ho, "code", "ERR_JWKS_INVALID");
1251
+ var po = class extends ro {
1252
+ constructor() {
1253
+ super(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "no applicable key found in the JSON Web Key Set", arguments.length > 1 ? arguments[1] : void 0), st(this, "code", "ERR_JWKS_NO_MATCHING_KEY");
1254
+ }
1255
+ };
1256
+ st(po, "code", "ERR_JWKS_NO_MATCHING_KEY");
1257
+ var fo = class extends ro {
1258
+ constructor() {
1259
+ super(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "multiple matching keys found in the JSON Web Key Set", arguments.length > 1 ? arguments[1] : void 0), st(this, Symbol.asyncIterator, void 0), st(this, "code", "ERR_JWKS_MULTIPLE_MATCHING_KEYS");
1260
+ }
1261
+ };
1262
+ st(fo, "code", "ERR_JWKS_MULTIPLE_MATCHING_KEYS");
1263
+ var mo = class extends ro {
1264
+ constructor() {
1265
+ super(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "request timed out", arguments.length > 1 ? arguments[1] : void 0), st(this, "code", "ERR_JWKS_TIMEOUT");
1266
+ }
1267
+ };
1268
+ st(mo, "code", "ERR_JWKS_TIMEOUT");
1269
+ var yo = class extends ro {
1270
+ constructor() {
1271
+ super(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "signature verification failed", arguments.length > 1 ? arguments[1] : void 0), st(this, "code", "ERR_JWS_SIGNATURE_VERIFICATION_FAILED");
1272
+ }
1273
+ };
1274
+ st(yo, "code", "ERR_JWS_SIGNATURE_VERIFICATION_FAILED");
1275
+ var wo = function(e2) {
1276
+ let t2 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "algorithm.name";
1277
+ return new TypeError("CryptoKey does not support this operation, its ".concat(t2, " must be ").concat(e2));
1278
+ };
1279
+ var go = (e2, t2) => e2.name === t2;
1280
+ function vo(e2) {
1281
+ return parseInt(e2.name.slice(4), 10);
1282
+ }
1283
+ function bo(e2, t2, n2) {
1284
+ switch (t2) {
1285
+ case "HS256":
1286
+ case "HS384":
1287
+ case "HS512": {
1288
+ if (!go(e2.algorithm, "HMAC")) throw wo("HMAC");
1289
+ const n3 = parseInt(t2.slice(2), 10);
1290
+ if (vo(e2.algorithm.hash) !== n3) throw wo("SHA-".concat(n3), "algorithm.hash");
1291
+ break;
1292
+ }
1293
+ case "RS256":
1294
+ case "RS384":
1295
+ case "RS512": {
1296
+ if (!go(e2.algorithm, "RSASSA-PKCS1-v1_5")) throw wo("RSASSA-PKCS1-v1_5");
1297
+ const n3 = parseInt(t2.slice(2), 10);
1298
+ if (vo(e2.algorithm.hash) !== n3) throw wo("SHA-".concat(n3), "algorithm.hash");
1299
+ break;
1300
+ }
1301
+ case "PS256":
1302
+ case "PS384":
1303
+ case "PS512": {
1304
+ if (!go(e2.algorithm, "RSA-PSS")) throw wo("RSA-PSS");
1305
+ const n3 = parseInt(t2.slice(2), 10);
1306
+ if (vo(e2.algorithm.hash) !== n3) throw wo("SHA-".concat(n3), "algorithm.hash");
1307
+ break;
1308
+ }
1309
+ case "Ed25519":
1310
+ case "EdDSA":
1311
+ if (!go(e2.algorithm, "Ed25519")) throw wo("Ed25519");
1312
+ break;
1313
+ case "ML-DSA-44":
1314
+ case "ML-DSA-65":
1315
+ case "ML-DSA-87":
1316
+ if (!go(e2.algorithm, t2)) throw wo(t2);
1317
+ break;
1318
+ case "ES256":
1319
+ case "ES384":
1320
+ case "ES512": {
1321
+ if (!go(e2.algorithm, "ECDSA")) throw wo("ECDSA");
1322
+ const n3 = (function(e3) {
1323
+ switch (e3) {
1324
+ case "ES256":
1325
+ return "P-256";
1326
+ case "ES384":
1327
+ return "P-384";
1328
+ case "ES512":
1329
+ return "P-521";
1330
+ default:
1331
+ throw new Error("unreachable");
1332
+ }
1333
+ })(t2);
1334
+ if (e2.algorithm.namedCurve !== n3) throw wo(n3, "algorithm.namedCurve");
1335
+ break;
1336
+ }
1337
+ default:
1338
+ throw new TypeError("CryptoKey does not support this operation");
1339
+ }
1340
+ !(function(e3, t3) {
1341
+ if (t3 && !e3.usages.includes(t3)) throw new TypeError("CryptoKey does not support this operation, its usages must include ".concat(t3, "."));
1342
+ })(e2, n2);
1343
+ }
1344
+ function _o(e2, t2) {
1345
+ for (var n2 = arguments.length, o2 = new Array(n2 > 2 ? n2 - 2 : 0), r2 = 2; r2 < n2; r2++) o2[r2 - 2] = arguments[r2];
1346
+ if ((o2 = o2.filter(Boolean)).length > 2) {
1347
+ const t3 = o2.pop();
1348
+ e2 += "one of type ".concat(o2.join(", "), ", or ").concat(t3, ".");
1349
+ } else 2 === o2.length ? e2 += "one of type ".concat(o2[0], " or ").concat(o2[1], ".") : e2 += "of type ".concat(o2[0], ".");
1350
+ if (null == t2) e2 += " Received ".concat(t2);
1351
+ else if ("function" == typeof t2 && t2.name) e2 += " Received function ".concat(t2.name);
1352
+ else if ("object" == typeof t2 && null != t2) {
1353
+ var i2;
1354
+ null !== (i2 = t2.constructor) && void 0 !== i2 && i2.name && (e2 += " Received an instance of ".concat(t2.constructor.name));
1355
+ }
1356
+ return e2;
1357
+ }
1358
+ var ko = function(e2, t2) {
1359
+ for (var n2 = arguments.length, o2 = new Array(n2 > 2 ? n2 - 2 : 0), r2 = 2; r2 < n2; r2++) o2[r2 - 2] = arguments[r2];
1360
+ return _o("Key for the ".concat(e2, " algorithm must be "), t2, ...o2);
1361
+ };
1362
+ var So = (e2) => {
1363
+ if ("CryptoKey" === (null == e2 ? void 0 : e2[Symbol.toStringTag])) return true;
1364
+ try {
1365
+ return e2 instanceof CryptoKey;
1366
+ } catch (e3) {
1367
+ return false;
1368
+ }
1369
+ };
1370
+ var Eo = (e2) => "KeyObject" === (null == e2 ? void 0 : e2[Symbol.toStringTag]);
1371
+ var Ao = (e2) => So(e2) || Eo(e2);
1372
+ function To(e2) {
1373
+ if ("object" != typeof (t2 = e2) || null === t2 || "[object Object]" !== Object.prototype.toString.call(e2)) return false;
1374
+ var t2;
1375
+ if (null === Object.getPrototypeOf(e2)) return true;
1376
+ let n2 = e2;
1377
+ for (; null !== Object.getPrototypeOf(n2); ) n2 = Object.getPrototypeOf(n2);
1378
+ return Object.getPrototypeOf(e2) === n2;
1379
+ }
1380
+ var Po = (e2, t2) => {
1381
+ if (e2.byteLength !== t2.length) return false;
1382
+ for (let n2 = 0; n2 < e2.byteLength; n2++) if (e2[n2] !== t2[n2]) return false;
1383
+ return true;
1384
+ };
1385
+ var Ro = (e2) => {
1386
+ const t2 = e2.data[e2.pos++];
1387
+ if (128 & t2) {
1388
+ const n2 = 127 & t2;
1389
+ let o2 = 0;
1390
+ for (let t3 = 0; t3 < n2; t3++) o2 = o2 << 8 | e2.data[e2.pos++];
1391
+ return o2;
1392
+ }
1393
+ return t2;
1394
+ };
1395
+ var Io = (e2, t2, n2) => {
1396
+ if (e2.data[e2.pos++] !== t2) throw new Error(n2);
1397
+ };
1398
+ var Oo = (e2, t2) => {
1399
+ const n2 = e2.data.subarray(e2.pos, e2.pos + t2);
1400
+ return e2.pos += t2, n2;
1401
+ };
1402
+ var xo = (e2) => {
1403
+ const t2 = ((e3) => {
1404
+ Io(e3, 6, "Expected algorithm OID");
1405
+ const t3 = Ro(e3);
1406
+ return Oo(e3, t3);
1407
+ })(e2);
1408
+ if (Po(t2, [43, 101, 110])) return "X25519";
1409
+ if (!Po(t2, [42, 134, 72, 206, 61, 2, 1])) throw new Error("Unsupported key algorithm");
1410
+ Io(e2, 6, "Expected curve OID");
1411
+ const n2 = Ro(e2), o2 = Oo(e2, n2);
1412
+ for (const { name: e3, oid: t3 } of [{ name: "P-256", oid: [42, 134, 72, 206, 61, 3, 1, 7] }, { name: "P-384", oid: [43, 129, 4, 0, 34] }, { name: "P-521", oid: [43, 129, 4, 0, 35] }]) if (Po(o2, t3)) return e3;
1413
+ throw new Error("Unsupported named curve");
1414
+ };
1415
+ var Co = async (e2, t2, n2, o2) => {
1416
+ var r2;
1417
+ let i2, a2;
1418
+ const s2 = "spki" === e2, c2 = () => s2 ? ["verify"] : ["sign"];
1419
+ switch (n2) {
1420
+ case "PS256":
1421
+ case "PS384":
1422
+ case "PS512":
1423
+ i2 = { name: "RSA-PSS", hash: "SHA-".concat(n2.slice(-3)) }, a2 = c2();
1424
+ break;
1425
+ case "RS256":
1426
+ case "RS384":
1427
+ case "RS512":
1428
+ i2 = { name: "RSASSA-PKCS1-v1_5", hash: "SHA-".concat(n2.slice(-3)) }, a2 = c2();
1429
+ break;
1430
+ case "RSA-OAEP":
1431
+ case "RSA-OAEP-256":
1432
+ case "RSA-OAEP-384":
1433
+ case "RSA-OAEP-512":
1434
+ i2 = { name: "RSA-OAEP", hash: "SHA-".concat(parseInt(n2.slice(-3), 10) || 1) }, a2 = s2 ? ["encrypt", "wrapKey"] : ["decrypt", "unwrapKey"];
1435
+ break;
1436
+ case "ES256":
1437
+ case "ES384":
1438
+ case "ES512":
1439
+ i2 = { name: "ECDSA", namedCurve: { ES256: "P-256", ES384: "P-384", ES512: "P-521" }[n2] }, a2 = c2();
1440
+ break;
1441
+ case "ECDH-ES":
1442
+ case "ECDH-ES+A128KW":
1443
+ case "ECDH-ES+A192KW":
1444
+ case "ECDH-ES+A256KW":
1445
+ try {
1446
+ const e3 = o2.getNamedCurve(t2);
1447
+ i2 = "X25519" === e3 ? { name: "X25519" } : { name: "ECDH", namedCurve: e3 };
1448
+ } catch (e3) {
1449
+ throw new co("Invalid or unsupported key format");
1450
+ }
1451
+ a2 = s2 ? [] : ["deriveBits"];
1452
+ break;
1453
+ case "Ed25519":
1454
+ case "EdDSA":
1455
+ i2 = { name: "Ed25519" }, a2 = c2();
1456
+ break;
1457
+ case "ML-DSA-44":
1458
+ case "ML-DSA-65":
1459
+ case "ML-DSA-87":
1460
+ i2 = { name: n2 }, a2 = c2();
1461
+ break;
1462
+ default:
1463
+ throw new co('Invalid or unsupported "alg" (Algorithm) value');
1464
+ }
1465
+ return crypto.subtle.importKey(e2, t2, i2, null !== (r2 = null == o2 ? void 0 : o2.extractable) && void 0 !== r2 ? r2 : !!s2, a2);
1466
+ };
1467
+ var jo = (e2, t2, n2) => {
1468
+ var o2;
1469
+ const r2 = ((e3, t3) => no(e3.replace(t3, "")))(e2, /(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g);
1470
+ let i2 = n2;
1471
+ return null != t2 && null !== (o2 = t2.startsWith) && void 0 !== o2 && o2.call(t2, "ECDH-ES") && (i2 || (i2 = {}), i2.getNamedCurve = (e3) => {
1472
+ const t3 = { data: e3, pos: 0 };
1473
+ return (function(e4) {
1474
+ Io(e4, 48, "Invalid PKCS#8 structure"), Ro(e4), Io(e4, 2, "Expected version field");
1475
+ const t4 = Ro(e4);
1476
+ e4.pos += t4, Io(e4, 48, "Expected algorithm identifier");
1477
+ Ro(e4);
1478
+ e4.pos;
1479
+ })(t3), xo(t3);
1480
+ }), Co("pkcs8", r2, t2, i2);
1481
+ };
1482
+ async function Do(e2) {
1483
+ var t2, n2;
1484
+ if (!e2.alg) throw new TypeError('"alg" argument is required when "jwk.alg" is not present');
1485
+ const { algorithm: o2, keyUsages: r2 } = (function(e3) {
1486
+ let t3, n3;
1487
+ switch (e3.kty) {
1488
+ case "AKP":
1489
+ switch (e3.alg) {
1490
+ case "ML-DSA-44":
1491
+ case "ML-DSA-65":
1492
+ case "ML-DSA-87":
1493
+ t3 = { name: e3.alg }, n3 = e3.priv ? ["sign"] : ["verify"];
1494
+ break;
1495
+ default:
1496
+ throw new co('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
1497
+ }
1498
+ break;
1499
+ case "RSA":
1500
+ switch (e3.alg) {
1501
+ case "PS256":
1502
+ case "PS384":
1503
+ case "PS512":
1504
+ t3 = { name: "RSA-PSS", hash: "SHA-".concat(e3.alg.slice(-3)) }, n3 = e3.d ? ["sign"] : ["verify"];
1505
+ break;
1506
+ case "RS256":
1507
+ case "RS384":
1508
+ case "RS512":
1509
+ t3 = { name: "RSASSA-PKCS1-v1_5", hash: "SHA-".concat(e3.alg.slice(-3)) }, n3 = e3.d ? ["sign"] : ["verify"];
1510
+ break;
1511
+ case "RSA-OAEP":
1512
+ case "RSA-OAEP-256":
1513
+ case "RSA-OAEP-384":
1514
+ case "RSA-OAEP-512":
1515
+ t3 = { name: "RSA-OAEP", hash: "SHA-".concat(parseInt(e3.alg.slice(-3), 10) || 1) }, n3 = e3.d ? ["decrypt", "unwrapKey"] : ["encrypt", "wrapKey"];
1516
+ break;
1517
+ default:
1518
+ throw new co('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
1519
+ }
1520
+ break;
1521
+ case "EC":
1522
+ switch (e3.alg) {
1523
+ case "ES256":
1524
+ t3 = { name: "ECDSA", namedCurve: "P-256" }, n3 = e3.d ? ["sign"] : ["verify"];
1525
+ break;
1526
+ case "ES384":
1527
+ t3 = { name: "ECDSA", namedCurve: "P-384" }, n3 = e3.d ? ["sign"] : ["verify"];
1528
+ break;
1529
+ case "ES512":
1530
+ t3 = { name: "ECDSA", namedCurve: "P-521" }, n3 = e3.d ? ["sign"] : ["verify"];
1531
+ break;
1532
+ case "ECDH-ES":
1533
+ case "ECDH-ES+A128KW":
1534
+ case "ECDH-ES+A192KW":
1535
+ case "ECDH-ES+A256KW":
1536
+ t3 = { name: "ECDH", namedCurve: e3.crv }, n3 = e3.d ? ["deriveBits"] : [];
1537
+ break;
1538
+ default:
1539
+ throw new co('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
1540
+ }
1541
+ break;
1542
+ case "OKP":
1543
+ switch (e3.alg) {
1544
+ case "Ed25519":
1545
+ case "EdDSA":
1546
+ t3 = { name: "Ed25519" }, n3 = e3.d ? ["sign"] : ["verify"];
1547
+ break;
1548
+ case "ECDH-ES":
1549
+ case "ECDH-ES+A128KW":
1550
+ case "ECDH-ES+A192KW":
1551
+ case "ECDH-ES+A256KW":
1552
+ t3 = { name: e3.crv }, n3 = e3.d ? ["deriveBits"] : [];
1553
+ break;
1554
+ default:
1555
+ throw new co('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
1556
+ }
1557
+ break;
1558
+ default:
1559
+ throw new co('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
1560
+ }
1561
+ return { algorithm: t3, keyUsages: n3 };
1562
+ })(e2), i2 = ut({}, e2);
1563
+ return "AKP" !== i2.kty && delete i2.alg, delete i2.use, crypto.subtle.importKey("jwk", i2, o2, null !== (t2 = e2.ext) && void 0 !== t2 ? t2 : !e2.d && !e2.priv, null !== (n2 = e2.key_ops) && void 0 !== n2 ? n2 : r2);
1564
+ }
1565
+ var Ko = (e2) => To(e2) && "string" == typeof e2.kty;
1566
+ var Lo;
1567
+ var Uo = async function(e2, t2, n2) {
1568
+ let o2 = arguments.length > 3 && void 0 !== arguments[3] && arguments[3];
1569
+ Lo || (Lo = /* @__PURE__ */ new WeakMap());
1570
+ let r2 = Lo.get(e2);
1571
+ if (null != r2 && r2[n2]) return r2[n2];
1572
+ const i2 = await Do(ut(ut({}, t2), {}, { alg: n2 }));
1573
+ return o2 && Object.freeze(e2), r2 ? r2[n2] = i2 : Lo.set(e2, { [n2]: i2 }), i2;
1574
+ };
1575
+ async function No(e2, t2) {
1576
+ if (e2 instanceof Uint8Array) return e2;
1577
+ if (So(e2)) return e2;
1578
+ if (Eo(e2)) {
1579
+ if ("secret" === e2.type) return e2.export();
1580
+ if ("toCryptoKey" in e2 && "function" == typeof e2.toCryptoKey) try {
1581
+ return ((e3, t3) => {
1582
+ Lo || (Lo = /* @__PURE__ */ new WeakMap());
1583
+ let n3 = Lo.get(e3);
1584
+ if (null != n3 && n3[t3]) return n3[t3];
1585
+ const o2 = "public" === e3.type, r2 = !!o2;
1586
+ let i2;
1587
+ if ("x25519" === e3.asymmetricKeyType) {
1588
+ switch (t3) {
1589
+ case "ECDH-ES":
1590
+ case "ECDH-ES+A128KW":
1591
+ case "ECDH-ES+A192KW":
1592
+ case "ECDH-ES+A256KW":
1593
+ break;
1594
+ default:
1595
+ throw new TypeError("given KeyObject instance cannot be used for this algorithm");
1596
+ }
1597
+ i2 = e3.toCryptoKey(e3.asymmetricKeyType, r2, o2 ? [] : ["deriveBits"]);
1598
+ }
1599
+ if ("ed25519" === e3.asymmetricKeyType) {
1600
+ if ("EdDSA" !== t3 && "Ed25519" !== t3) throw new TypeError("given KeyObject instance cannot be used for this algorithm");
1601
+ i2 = e3.toCryptoKey(e3.asymmetricKeyType, r2, [o2 ? "verify" : "sign"]);
1602
+ }
1603
+ switch (e3.asymmetricKeyType) {
1604
+ case "ml-dsa-44":
1605
+ case "ml-dsa-65":
1606
+ case "ml-dsa-87":
1607
+ if (t3 !== e3.asymmetricKeyType.toUpperCase()) throw new TypeError("given KeyObject instance cannot be used for this algorithm");
1608
+ i2 = e3.toCryptoKey(e3.asymmetricKeyType, r2, [o2 ? "verify" : "sign"]);
1609
+ }
1610
+ if ("rsa" === e3.asymmetricKeyType) {
1611
+ let n4;
1612
+ switch (t3) {
1613
+ case "RSA-OAEP":
1614
+ n4 = "SHA-1";
1615
+ break;
1616
+ case "RS256":
1617
+ case "PS256":
1618
+ case "RSA-OAEP-256":
1619
+ n4 = "SHA-256";
1620
+ break;
1621
+ case "RS384":
1622
+ case "PS384":
1623
+ case "RSA-OAEP-384":
1624
+ n4 = "SHA-384";
1625
+ break;
1626
+ case "RS512":
1627
+ case "PS512":
1628
+ case "RSA-OAEP-512":
1629
+ n4 = "SHA-512";
1630
+ break;
1631
+ default:
1632
+ throw new TypeError("given KeyObject instance cannot be used for this algorithm");
1633
+ }
1634
+ if (t3.startsWith("RSA-OAEP")) return e3.toCryptoKey({ name: "RSA-OAEP", hash: n4 }, r2, o2 ? ["encrypt"] : ["decrypt"]);
1635
+ i2 = e3.toCryptoKey({ name: t3.startsWith("PS") ? "RSA-PSS" : "RSASSA-PKCS1-v1_5", hash: n4 }, r2, [o2 ? "verify" : "sign"]);
1636
+ }
1637
+ if ("ec" === e3.asymmetricKeyType) {
1638
+ var a2;
1639
+ const n4 = (/* @__PURE__ */ new Map([["prime256v1", "P-256"], ["secp384r1", "P-384"], ["secp521r1", "P-521"]])).get(null === (a2 = e3.asymmetricKeyDetails) || void 0 === a2 ? void 0 : a2.namedCurve);
1640
+ if (!n4) throw new TypeError("given KeyObject instance cannot be used for this algorithm");
1641
+ "ES256" === t3 && "P-256" === n4 && (i2 = e3.toCryptoKey({ name: "ECDSA", namedCurve: n4 }, r2, [o2 ? "verify" : "sign"])), "ES384" === t3 && "P-384" === n4 && (i2 = e3.toCryptoKey({ name: "ECDSA", namedCurve: n4 }, r2, [o2 ? "verify" : "sign"])), "ES512" === t3 && "P-521" === n4 && (i2 = e3.toCryptoKey({ name: "ECDSA", namedCurve: n4 }, r2, [o2 ? "verify" : "sign"])), t3.startsWith("ECDH-ES") && (i2 = e3.toCryptoKey({ name: "ECDH", namedCurve: n4 }, r2, o2 ? [] : ["deriveBits"]));
1642
+ }
1643
+ if (!i2) throw new TypeError("given KeyObject instance cannot be used for this algorithm");
1644
+ return n3 ? n3[t3] = i2 : Lo.set(e3, { [t3]: i2 }), i2;
1645
+ })(e2, t2);
1646
+ } catch (e3) {
1647
+ if (e3 instanceof TypeError) throw e3;
1648
+ }
1649
+ let n2 = e2.export({ format: "jwk" });
1650
+ return Uo(e2, n2, t2);
1651
+ }
1652
+ if (Ko(e2)) return e2.k ? oo(e2.k) : Uo(e2, e2, t2, true);
1653
+ throw new Error("unreachable");
1654
+ }
1655
+ var Wo = (e2) => null == e2 ? void 0 : e2[Symbol.toStringTag];
1656
+ var Ho = (e2, t2, n2) => {
1657
+ if (void 0 !== t2.use) {
1658
+ let e3;
1659
+ switch (n2) {
1660
+ case "sign":
1661
+ case "verify":
1662
+ e3 = "sig";
1663
+ break;
1664
+ case "encrypt":
1665
+ case "decrypt":
1666
+ e3 = "enc";
1667
+ }
1668
+ if (t2.use !== e3) throw new TypeError('Invalid key for this operation, its "use" must be "'.concat(e3, '" when present'));
1669
+ }
1670
+ if (void 0 !== t2.alg && t2.alg !== e2) throw new TypeError('Invalid key for this operation, its "alg" must be "'.concat(e2, '" when present'));
1671
+ if (Array.isArray(t2.key_ops)) {
1672
+ var o2, r2;
1673
+ let i2;
1674
+ switch (true) {
1675
+ case ("sign" === n2 || "verify" === n2):
1676
+ case "dir" === e2:
1677
+ case e2.includes("CBC-HS"):
1678
+ i2 = n2;
1679
+ break;
1680
+ case e2.startsWith("PBES2"):
1681
+ i2 = "deriveBits";
1682
+ break;
1683
+ case /^A\d{3}(?:GCM)?(?:KW)?$/.test(e2):
1684
+ i2 = !e2.includes("GCM") && e2.endsWith("KW") ? "encrypt" === n2 ? "wrapKey" : "unwrapKey" : n2;
1685
+ break;
1686
+ case ("encrypt" === n2 && e2.startsWith("RSA")):
1687
+ i2 = "wrapKey";
1688
+ break;
1689
+ case "decrypt" === n2:
1690
+ i2 = e2.startsWith("RSA") ? "unwrapKey" : "deriveBits";
1691
+ }
1692
+ if (i2 && false === (null === (o2 = t2.key_ops) || void 0 === o2 || null === (r2 = o2.includes) || void 0 === r2 ? void 0 : r2.call(o2, i2))) throw new TypeError('Invalid key for this operation, its "key_ops" must include "'.concat(i2, '" when present'));
1693
+ }
1694
+ return true;
1695
+ };
1696
+ function zo(e2, t2, n2) {
1697
+ switch (e2.substring(0, 2)) {
1698
+ case "A1":
1699
+ case "A2":
1700
+ case "di":
1701
+ case "HS":
1702
+ case "PB":
1703
+ ((e3, t3, n3) => {
1704
+ if (!(t3 instanceof Uint8Array)) {
1705
+ if (Ko(t3)) {
1706
+ if (((e4) => "oct" === e4.kty && "string" == typeof e4.k)(t3) && Ho(e3, t3, n3)) return;
1707
+ throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present');
1708
+ }
1709
+ if (!Ao(t3)) throw new TypeError(ko(e3, t3, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array"));
1710
+ if ("secret" !== t3.type) throw new TypeError("".concat(Wo(t3), ' instances for symmetric algorithms must be of type "secret"'));
1711
+ }
1712
+ })(e2, t2, n2);
1713
+ break;
1714
+ default:
1715
+ ((e3, t3, n3) => {
1716
+ if (Ko(t3)) switch (n3) {
1717
+ case "decrypt":
1718
+ case "sign":
1719
+ if (((e4) => "oct" !== e4.kty && ("AKP" === e4.kty && "string" == typeof e4.priv || "string" == typeof e4.d))(t3) && Ho(e3, t3, n3)) return;
1720
+ throw new TypeError("JSON Web Key for this operation must be a private JWK");
1721
+ case "encrypt":
1722
+ case "verify":
1723
+ if (((e4) => "oct" !== e4.kty && void 0 === e4.d && void 0 === e4.priv)(t3) && Ho(e3, t3, n3)) return;
1724
+ throw new TypeError("JSON Web Key for this operation must be a public JWK");
1725
+ }
1726
+ if (!Ao(t3)) throw new TypeError(ko(e3, t3, "CryptoKey", "KeyObject", "JSON Web Key"));
1727
+ if ("secret" === t3.type) throw new TypeError("".concat(Wo(t3), ' instances for asymmetric algorithms must not be of type "secret"'));
1728
+ if ("public" === t3.type) switch (n3) {
1729
+ case "sign":
1730
+ throw new TypeError("".concat(Wo(t3), ' instances for asymmetric algorithm signing must be of type "private"'));
1731
+ case "decrypt":
1732
+ throw new TypeError("".concat(Wo(t3), ' instances for asymmetric algorithm decryption must be of type "private"'));
1733
+ }
1734
+ if ("private" === t3.type) switch (n3) {
1735
+ case "verify":
1736
+ throw new TypeError("".concat(Wo(t3), ' instances for asymmetric algorithm verifying must be of type "public"'));
1737
+ case "encrypt":
1738
+ throw new TypeError("".concat(Wo(t3), ' instances for asymmetric algorithm encryption must be of type "public"'));
1739
+ }
1740
+ })(e2, t2, n2);
1741
+ }
1742
+ }
1743
+ var Jo;
1744
+ var Mo;
1745
+ var Vo;
1746
+ var Go;
1747
+ if ("undefined" == typeof navigator || null === (Jo = navigator.userAgent) || void 0 === Jo || null === (Mo = Jo.startsWith) || void 0 === Mo || !Mo.call(Jo, "Mozilla/5.0 ")) {
1748
+ const e2 = "v6.8.1";
1749
+ Go = "".concat("openid-client", "/").concat(e2), Vo = { "user-agent": Go };
1750
+ }
1751
+ var Fo = (e2) => Zo.get(e2);
1752
+ var Zo;
1753
+ var qo;
1754
+ function Bo(e2) {
1755
+ return void 0 !== e2 ? Zt(e2) : (qo || (qo = /* @__PURE__ */ new WeakMap()), (e3, t2, n2, o2) => {
1756
+ let r2;
1757
+ return (r2 = qo.get(t2)) || (!(function(e4, t3) {
1758
+ if ("string" != typeof e4) throw $o("".concat(t3, " must be a string"), Qo);
1759
+ if (0 === e4.length) throw $o("".concat(t3, " must not be empty"), Yo);
1760
+ })(t2.client_secret, '"metadata.client_secret"'), r2 = Zt(t2.client_secret), qo.set(t2, r2)), r2(e3, t2, n2, o2);
1761
+ });
1762
+ }
1763
+ var Xo = vt;
1764
+ var Yo = "ERR_INVALID_ARG_VALUE";
1765
+ var Qo = "ERR_INVALID_ARG_TYPE";
1766
+ function $o(e2, t2, n2) {
1767
+ const o2 = new TypeError(e2, { cause: n2 });
1768
+ return Object.assign(o2, { code: t2 }), o2;
1769
+ }
1770
+ function er(e2) {
1771
+ return (async function(e3) {
1772
+ return Nt(e3, "codeVerifier"), Pt(await crypto.subtle.digest("SHA-256", Et(e3)));
1773
+ })(e2);
1774
+ }
1775
+ function tr() {
1776
+ return Ht();
1777
+ }
1778
+ var nr = class extends Error {
1779
+ constructor(e2, t2) {
1780
+ var n2;
1781
+ super(e2, t2), st(this, "code", void 0), this.name = this.constructor.name, this.code = null == t2 ? void 0 : t2.code, null === (n2 = Error.captureStackTrace) || void 0 === n2 || n2.call(Error, this, this.constructor);
1782
+ }
1783
+ };
1784
+ function or(e2, t2, n2) {
1785
+ return new nr(e2, { cause: t2, code: n2 });
1786
+ }
1787
+ function rr(e2) {
1788
+ if (e2 instanceof TypeError || e2 instanceof nr || e2 instanceof $t || e2 instanceof en || e2 instanceof tn) throw e2;
1789
+ if (e2 instanceof It) switch (e2.code) {
1790
+ case Dn:
1791
+ throw or("only requests to HTTPS are allowed", e2, e2.code);
1792
+ case Kn:
1793
+ throw or("only requests to HTTP or HTTPS are allowed", e2, e2.code);
1794
+ case jn:
1795
+ throw or("unexpected HTTP response status code", e2.cause, e2.code);
1796
+ case Cn:
1797
+ throw or("unexpected response content-type", e2.cause, e2.code);
1798
+ case On:
1799
+ throw or("parsing error occured", e2, e2.code);
1800
+ case xn:
1801
+ throw or("invalid response encountered", e2, e2.code);
1802
+ case Un:
1803
+ throw or("unexpected JWT claim value encountered", e2, e2.code);
1804
+ case Nn:
1805
+ throw or("unexpected JSON attribute value encountered", e2, e2.code);
1806
+ case Ln:
1807
+ throw or("JWT timestamp claim value failed validation", e2, e2.code);
1808
+ default:
1809
+ throw or(e2.message, e2, e2.code);
1810
+ }
1811
+ if (e2 instanceof Rt) throw or("unsupported operation", e2, e2.code);
1812
+ if (e2 instanceof DOMException) switch (e2.name) {
1813
+ case "OperationError":
1814
+ throw or("runtime operation error", e2, Rn);
1815
+ case "NotSupportedError":
1816
+ throw or("runtime unsupported operation", e2, Rn);
1817
+ case "TimeoutError":
1818
+ throw or("operation timed out", e2, "OAUTH_TIMEOUT");
1819
+ case "AbortError":
1820
+ throw or("operation aborted", e2, "OAUTH_ABORT");
1821
+ }
1822
+ throw new nr("something went wrong", { cause: e2 });
1823
+ }
1824
+ async function ir(e2, t2, n2, o2, r2) {
1825
+ const i2 = await (async function(e3, t3) {
1826
+ var n3, o3;
1827
+ if (!(e3 instanceof URL)) throw $o('"server" must be an instance of URL', Qo);
1828
+ const r3 = !e3.href.includes("/.well-known/"), i3 = null !== (n3 = null == t3 ? void 0 : t3.timeout) && void 0 !== n3 ? n3 : 30, a3 = AbortSignal.timeout(1e3 * i3), s3 = await (r3 ? Lt(e3, { algorithm: null == t3 ? void 0 : t3.algorithm, [vt]: null == t3 ? void 0 : t3[Xo], [yt]: null == t3 || null === (o3 = t3.execute) || void 0 === o3 ? void 0 : o3.includes(pr), signal: a3, headers: new Headers(Vo) }) : ((null == t3 ? void 0 : t3[Xo]) || fetch)((Xt(e3, null == t3 || null === (c2 = t3.execute) || void 0 === c2 || !c2.includes(pr)), e3.href), { headers: Object.fromEntries(new Headers(ut({ accept: "application/json" }, Vo)).entries()), body: void 0, method: "GET", redirect: "manual", signal: a3 })).then(((e4) => (async function(e5, t4) {
1829
+ const n4 = e5;
1830
+ if (!(n4 instanceof URL) && n4 !== Yn) throw mt('"expectedIssuerIdentifier" must be an instance of URL', "ERR_INVALID_ARG_TYPE");
1831
+ if (!ft(t4, Response)) throw mt('"response" must be an instance of Response', "ERR_INVALID_ARG_TYPE");
1832
+ if (200 !== t4.status) throw Ot('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)', jn, t4);
1833
+ zn(t4);
1834
+ const o4 = await Xn(t4);
1835
+ if (Nt(o4.issuer, '"response" body "issuer" property', xn, { body: o4 }), n4 !== Yn && new URL(o4.issuer).href !== n4.href) throw Ot('"response" body "issuer" property does not match the expected value', Nn, { expected: n4.href, body: o4, attribute: "issuer" });
1836
+ return o4;
1837
+ })(Yn, e4))).catch(rr);
1838
+ var c2;
1839
+ r3 && new URL(s3.issuer).href !== e3.href && ((function(e4, t4, n4) {
1840
+ return !("https://login.microsoftonline.com" !== e4.origin || null != n4 && n4.algorithm && "oidc" !== n4.algorithm || (t4[ar] = true, 0));
1841
+ })(e3, s3, t3) || (function(e4, t4) {
1842
+ return !(!e4.hostname.endsWith(".b2clogin.com") || null != t4 && t4.algorithm && "oidc" !== t4.algorithm);
1843
+ })(e3, t3) || (() => {
1844
+ throw new nr("discovered metadata issuer does not match the expected issuer", { code: Nn, cause: { expected: e3.href, body: s3, attribute: "issuer" } });
1845
+ })());
1846
+ return s3;
1847
+ })(e2, r2), a2 = new sr(i2, t2, n2, o2);
1848
+ let s2 = Fo(a2);
1849
+ if (null != r2 && r2[Xo] && (s2.fetch = r2[Xo]), null != r2 && r2.timeout && (s2.timeout = r2.timeout), null != r2 && r2.execute) for (const e3 of r2.execute) e3(a2);
1850
+ return a2;
1851
+ }
1852
+ new TextDecoder();
1853
+ var ar = /* @__PURE__ */ Symbol();
1854
+ var sr = class {
1855
+ constructor(e2, t2, n2, o2) {
1856
+ var r2, i2, a2, s2, c2;
1857
+ if ("string" != typeof t2 || !t2.length) throw $o('"clientId" must be a non-empty string', Qo);
1858
+ if ("string" == typeof n2 && (n2 = { client_secret: n2 }), void 0 !== (null === (r2 = n2) || void 0 === r2 ? void 0 : r2.client_id) && t2 !== n2.client_id) throw $o('"clientId" and "metadata.client_id" must be the same', Yo);
1859
+ const u2 = ut(ut({}, structuredClone(n2)), {}, { client_id: t2 });
1860
+ let l2;
1861
+ u2[wt] = null !== (i2 = null === (a2 = n2) || void 0 === a2 ? void 0 : a2[wt]) && void 0 !== i2 ? i2 : 0, u2[gt] = null !== (s2 = null === (c2 = n2) || void 0 === c2 ? void 0 : c2[gt]) && void 0 !== s2 ? s2 : 30, l2 = o2 || ("string" == typeof u2.client_secret && u2.client_secret.length ? Bo(u2.client_secret) : (e3, t3, n3, o3) => {
1862
+ n3.set("client_id", t3.client_id);
1863
+ });
1864
+ let d2 = Object.freeze(u2);
1865
+ const h2 = structuredClone(e2);
1866
+ ar in e2 && (h2[Qn] = (t3) => {
1867
+ let { claims: { tid: n3 } } = t3;
1868
+ return e2.issuer.replace("{tenantid}", n3);
1869
+ });
1870
+ let p2 = Object.freeze(h2);
1871
+ Zo || (Zo = /* @__PURE__ */ new WeakMap()), Zo.set(this, { __proto__: null, as: p2, c: d2, auth: l2, tlsOnly: true, jwksCache: {} });
1872
+ }
1873
+ serverMetadata() {
1874
+ const e2 = structuredClone(Fo(this).as);
1875
+ return (function(e3) {
1876
+ Object.defineProperties(e3, /* @__PURE__ */ (function(e4) {
1877
+ return { supportsPKCE: { __proto__: null, value() {
1878
+ var t2;
1879
+ let n2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "S256";
1880
+ return true === (null === (t2 = e4.code_challenge_methods_supported) || void 0 === t2 ? void 0 : t2.includes(n2));
1881
+ } } };
1882
+ })(e3));
1883
+ })(e2), e2;
1884
+ }
1885
+ clientMetadata() {
1886
+ return structuredClone(Fo(this).c);
1887
+ }
1888
+ get timeout() {
1889
+ return Fo(this).timeout;
1890
+ }
1891
+ set timeout(e2) {
1892
+ Fo(this).timeout = e2;
1893
+ }
1894
+ get [Xo]() {
1895
+ return Fo(this).fetch;
1896
+ }
1897
+ set [Xo](e2) {
1898
+ Fo(this).fetch = e2;
1899
+ }
1900
+ };
1901
+ function cr(e2) {
1902
+ Object.defineProperties(e2, (function(e3) {
1903
+ let t2;
1904
+ if (void 0 !== e3.expires_in) {
1905
+ const n2 = /* @__PURE__ */ new Date();
1906
+ n2.setSeconds(n2.getSeconds() + e3.expires_in), t2 = n2.getTime();
1907
+ }
1908
+ return { expiresIn: { __proto__: null, value() {
1909
+ if (t2) {
1910
+ const e4 = Date.now();
1911
+ return t2 > e4 ? Math.floor((t2 - e4) / 1e3) : 0;
1912
+ }
1913
+ } }, claims: { __proto__: null, value() {
1914
+ try {
1915
+ return mn(this);
1916
+ } catch (e4) {
1917
+ return;
1918
+ }
1919
+ } } };
1920
+ })(e2));
1921
+ }
1922
+ async function ur(e2, t2, n2) {
1923
+ var o2;
1924
+ let r2 = arguments.length > 3 && void 0 !== arguments[3] && arguments[3];
1925
+ const i2 = null === (o2 = e2.headers.get("retry-after")) || void 0 === o2 ? void 0 : o2.trim();
1926
+ if (void 0 === i2) return;
1927
+ let a2;
1928
+ if (/^\d+$/.test(i2)) a2 = parseInt(i2, 10);
1929
+ else {
1930
+ const e3 = new Date(i2);
1931
+ if (Number.isFinite(e3.getTime())) {
1932
+ const t3 = /* @__PURE__ */ new Date(), n3 = e3.getTime() - t3.getTime();
1933
+ n3 > 0 && (a2 = Math.ceil(n3 / 1e3));
1934
+ }
1935
+ }
1936
+ if (r2 && !Number.isFinite(a2)) throw new It("invalid Retry-After header value", { cause: e2 });
1937
+ a2 > t2 && await lr(a2 - t2, n2);
1938
+ }
1939
+ function lr(e2, t2) {
1940
+ return new Promise(((n2, o2) => {
1941
+ const r2 = (e3) => {
1942
+ try {
1943
+ t2.throwIfAborted();
1944
+ } catch (e4) {
1945
+ return void o2(e4);
1946
+ }
1947
+ if (e3 <= 0) return void n2();
1948
+ const i2 = Math.min(e3, 5);
1949
+ setTimeout((() => r2(e3 - i2)), 1e3 * i2);
1950
+ };
1951
+ r2(e2);
1952
+ }));
1953
+ }
1954
+ async function dr(e2, t2) {
1955
+ vr(e2);
1956
+ const { as: n2, c: o2, auth: r2, fetch: i2, tlsOnly: a2, timeout: s2 } = Fo(e2);
1957
+ return (async function(e3, t3, n3, o3, r3) {
1958
+ Gt(e3), Ft(t3);
1959
+ const i3 = Qt(e3, "backchannel_authentication_endpoint", t3.use_mtls_endpoint_aliases, true !== (null == r3 ? void 0 : r3[yt])), a3 = new URLSearchParams(o3);
1960
+ a3.set("client_id", t3.client_id);
1961
+ const s3 = jt(null == r3 ? void 0 : r3.headers);
1962
+ return s3.set("accept", "application/json"), dn(e3, t3, n3, i3, a3, s3, r3);
1963
+ })(n2, o2, r2, t2, { [vt]: i2, [yt]: !a2, headers: new Headers(Vo), signal: br(s2) }).then(((e3) => (async function(e4, t3, n3) {
1964
+ if (Gt(e4), Ft(t3), !ft(n3, Response)) throw mt('"response" must be an instance of Response', "ERR_INVALID_ARG_TYPE");
1965
+ await cn(n3, 200, "Backchannel Authentication Endpoint"), zn(n3);
1966
+ const o3 = await Xn(n3);
1967
+ Nt(o3.auth_req_id, '"response" body "auth_req_id" property', xn, { body: o3 });
1968
+ let r3 = "number" != typeof o3.expires_in ? parseFloat(o3.expires_in) : o3.expires_in;
1969
+ return Ut(r3, true, '"response" body "expires_in" property', xn, { body: o3 }), o3.expires_in = r3, void 0 !== o3.interval && Ut(o3.interval, false, '"response" body "interval" property', xn, { body: o3 }), o3;
1970
+ })(n2, o2, e3))).catch(rr);
1971
+ }
1972
+ async function hr(e2, t2, n2, o2) {
1973
+ var r2, i2;
1974
+ vr(e2), n2 = new URLSearchParams(n2);
1975
+ let a2 = null !== (r2 = t2.interval) && void 0 !== r2 ? r2 : 5;
1976
+ const s2 = null !== (i2 = null == o2 ? void 0 : o2.signal) && void 0 !== i2 ? i2 : AbortSignal.timeout(1e3 * t2.expires_in);
1977
+ try {
1978
+ await lr(a2, s2);
1979
+ } catch (e3) {
1980
+ rr(e3);
1981
+ }
1982
+ const { as: c2, c: u2, auth: l2, fetch: d2, tlsOnly: h2, nonRepudiation: p2, timeout: f, decrypt: m } = Fo(e2), y = (r3, i3) => hr(e2, ut(ut({}, t2), {}, { interval: r3 }), n2, ut(ut({}, o2), {}, { signal: s2, flag: i3 })), w = await (async function(e3, t3, n3, o3, r3) {
1983
+ Gt(e3), Ft(t3), Nt(o3, '"authReqId"');
1984
+ const i3 = new URLSearchParams(null == r3 ? void 0 : r3.additionalParameters);
1985
+ return i3.set("auth_req_id", o3), hn(e3, t3, n3, "urn:openid:params:grant-type:ciba", i3, r3);
1986
+ })(c2, u2, l2, t2.auth_req_id, { [vt]: d2, [yt]: !h2, additionalParameters: n2, DPoP: null == o2 ? void 0 : o2.DPoP, headers: new Headers(Vo), signal: s2.aborted ? s2 : br(f) }).catch(rr);
1987
+ var g;
1988
+ if (503 === w.status && w.headers.has("retry-after")) return await ur(w, a2, s2, true), await (null === (g = w.body) || void 0 === g ? void 0 : g.cancel()), y(a2);
1989
+ const v = (async function(e3, t3, n3, o3) {
1990
+ return yn(e3, t3, n3, void 0, null == o3 ? void 0 : o3[_t], null == o3 ? void 0 : o3.recognizedTokenTypes);
1991
+ })(c2, u2, w, { [_t]: m });
1992
+ let b;
1993
+ try {
1994
+ b = await v;
1995
+ } catch (e3) {
1996
+ if (_r(e3, o2)) return y(a2, kr);
1997
+ if (e3 instanceof $t) switch (e3.error) {
1998
+ case "slow_down":
1999
+ a2 += 5;
2000
+ case "authorization_pending":
2001
+ return await ur(e3.response, a2, s2), y(a2);
2002
+ }
2003
+ rr(e3);
2004
+ }
2005
+ return b.id_token && await (null == p2 ? void 0 : p2(w)), cr(b), b;
2006
+ }
2007
+ function pr(e2) {
2008
+ Fo(e2).tlsOnly = false;
2009
+ }
2010
+ async function fr(e2, t2, n2, o2, r2) {
2011
+ if (vr(e2), !((null == r2 ? void 0 : r2.flag) === kr || t2 instanceof URL || (function(e3, t3) {
2012
+ try {
2013
+ return Object.getPrototypeOf(e3)[Symbol.toStringTag] === t3;
2014
+ } catch (e4) {
2015
+ return false;
2016
+ }
2017
+ })(t2, "Request"))) throw $o('"currentUrl" must be an instance of URL, or Request', Qo);
2018
+ let i2, a2;
2019
+ const { as: s2, c: c2, auth: u2, fetch: l2, tlsOnly: d2, jarm: h2, hybrid: p2, nonRepudiation: f, timeout: m, decrypt: y, implicit: w } = Fo(e2);
2020
+ if ((null == r2 ? void 0 : r2.flag) === kr) i2 = r2.authResponse, a2 = r2.redirectUri;
2021
+ else {
2022
+ if (!(t2 instanceof URL)) {
2023
+ const e3 = t2;
2024
+ switch (t2 = new URL(t2.url), e3.method) {
2025
+ case "GET":
2026
+ break;
2027
+ case "POST":
2028
+ const n3 = new URLSearchParams(await Vn(e3));
2029
+ if (p2) t2.hash = n3.toString();
2030
+ else for (const [e4, o3] of n3.entries()) t2.searchParams.append(e4, o3);
2031
+ break;
2032
+ default:
2033
+ throw $o("unexpected Request HTTP method", Yo);
2034
+ }
2035
+ }
2036
+ switch (a2 = (function(e3) {
2037
+ return (e3 = new URL(e3)).search = "", e3.hash = "", e3.href;
2038
+ })(t2), true) {
2039
+ case !!h2:
2040
+ i2 = await h2(t2, null == n2 ? void 0 : n2.expectedState);
2041
+ break;
2042
+ case !!p2:
2043
+ i2 = await p2(t2, null == n2 ? void 0 : n2.expectedNonce, null == n2 ? void 0 : n2.expectedState, null == n2 ? void 0 : n2.maxAge);
2044
+ break;
2045
+ case !!w:
2046
+ throw new TypeError("authorizationCodeGrant() cannot be used by response_type=id_token clients");
2047
+ default:
2048
+ try {
2049
+ i2 = Bn(s2, c2, t2.searchParams, null == n2 ? void 0 : n2.expectedState);
2050
+ } catch (e3) {
2051
+ rr(e3);
2052
+ }
2053
+ }
2054
+ }
2055
+ const g = await (async function(e3, t3, n3, o3, r3, i3, a3) {
2056
+ if (Gt(e3), Ft(t3), !vn.has(o3)) throw mt('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()', "ERR_INVALID_ARG_VALUE");
2057
+ Nt(r3, '"redirectUri"');
2058
+ const s3 = Fn(o3, "code");
2059
+ if (!s3) throw Ot('no authorization code in "callbackParameters"', xn);
2060
+ const c3 = new URLSearchParams(null == a3 ? void 0 : a3.additionalParameters);
2061
+ return c3.set("redirect_uri", r3), c3.set("code", s3), i3 !== bn && (Nt(i3, '"codeVerifier"'), c3.set("code_verifier", i3)), hn(e3, t3, n3, "authorization_code", c3, a3);
2062
+ })(s2, c2, u2, i2, a2, (null == n2 ? void 0 : n2.pkceCodeVerifier) || bn, { additionalParameters: o2, [vt]: l2, [yt]: !d2, DPoP: null == r2 ? void 0 : r2.DPoP, headers: new Headers(Vo), signal: br(m) }).catch(rr);
2063
+ "string" != typeof (null == n2 ? void 0 : n2.expectedNonce) && "number" != typeof (null == n2 ? void 0 : n2.maxAge) || (n2.idTokenExpected = true);
2064
+ const v = An(s2, c2, g, { expectedNonce: null == n2 ? void 0 : n2.expectedNonce, maxAge: null == n2 ? void 0 : n2.maxAge, requireIdToken: null == n2 ? void 0 : n2.idTokenExpected, [_t]: y });
2065
+ let b;
2066
+ try {
2067
+ b = await v;
2068
+ } catch (t3) {
2069
+ if (_r(t3, r2)) return fr(e2, void 0, n2, o2, ut(ut({}, r2), {}, { flag: kr, authResponse: i2, redirectUri: a2 }));
2070
+ rr(t3);
2071
+ }
2072
+ return b.id_token && await (null == f ? void 0 : f(g)), cr(b), b;
2073
+ }
2074
+ async function mr(e2, t2, n2, o2) {
2075
+ vr(e2), n2 = new URLSearchParams(n2);
2076
+ const { as: r2, c: i2, auth: a2, fetch: s2, tlsOnly: c2, nonRepudiation: u2, timeout: l2, decrypt: d2 } = Fo(e2), h2 = await (async function(e3, t3, n3, o3, r3) {
2077
+ Gt(e3), Ft(t3), Nt(o3, '"refreshToken"');
2078
+ const i3 = new URLSearchParams(null == r3 ? void 0 : r3.additionalParameters);
2079
+ return i3.set("refresh_token", o3), hn(e3, t3, n3, "refresh_token", i3, r3);
2080
+ })(r2, i2, a2, t2, { [vt]: s2, [yt]: !c2, additionalParameters: n2, DPoP: null == o2 ? void 0 : o2.DPoP, headers: new Headers(Vo), signal: br(l2) }).catch(rr), p2 = (async function(e3, t3, n3, o3) {
2081
+ return yn(e3, t3, n3, void 0, null == o3 ? void 0 : o3[_t], null == o3 ? void 0 : o3.recognizedTokenTypes);
2082
+ })(r2, i2, h2, { [_t]: d2 });
2083
+ let f;
2084
+ try {
2085
+ f = await p2;
2086
+ } catch (r3) {
2087
+ if (_r(r3, o2)) return mr(e2, t2, n2, ut(ut({}, o2), {}, { flag: kr }));
2088
+ rr(r3);
2089
+ }
2090
+ return f.id_token && await (null == u2 ? void 0 : u2(h2)), cr(f), f;
2091
+ }
2092
+ async function yr(e2, t2, n2) {
2093
+ vr(e2), t2 = new URLSearchParams(t2);
2094
+ const { as: o2, c: r2, auth: i2, fetch: a2, tlsOnly: s2, timeout: c2 } = Fo(e2), u2 = await (async function(e3, t3, n3, o3, r3) {
2095
+ return Gt(e3), Ft(t3), hn(e3, t3, n3, "client_credentials", new URLSearchParams(o3), r3);
2096
+ })(o2, r2, i2, t2, { [vt]: a2, [yt]: !s2, DPoP: null == n2 ? void 0 : n2.DPoP, headers: new Headers(Vo), signal: br(c2) }).catch(rr), l2 = (async function(e3, t3, n3, o3) {
2097
+ return yn(e3, t3, n3, void 0, null == o3 ? void 0 : o3[_t], null == o3 ? void 0 : o3.recognizedTokenTypes);
2098
+ })(o2, r2, u2);
2099
+ let d2;
2100
+ try {
2101
+ d2 = await l2;
2102
+ } catch (o3) {
2103
+ if (_r(o3, n2)) return yr(e2, t2, ut(ut({}, n2), {}, { flag: kr }));
2104
+ rr(o3);
2105
+ }
2106
+ return cr(d2), d2;
2107
+ }
2108
+ function wr(e2, t2) {
2109
+ vr(e2);
2110
+ const { as: n2, c: o2, tlsOnly: r2, hybrid: i2, jarm: a2, implicit: s2 } = Fo(e2), c2 = Qt(n2, "authorization_endpoint", false, r2);
2111
+ if ((t2 = new URLSearchParams(t2)).has("client_id") || t2.set("client_id", o2.client_id), !t2.has("request_uri") && !t2.has("request")) {
2112
+ if (t2.has("response_type") || t2.set("response_type", i2 ? "code id_token" : s2 ? "id_token" : "code"), s2 && !t2.has("nonce")) throw $o("response_type=id_token clients must provide a nonce parameter in their authorization request parameters", Yo);
2113
+ a2 && t2.set("response_mode", "jwt");
2114
+ }
2115
+ for (const [e3, n3] of t2.entries()) c2.searchParams.append(e3, n3);
2116
+ return c2;
2117
+ }
2118
+ async function gr(e2, t2, n2) {
2119
+ vr(e2);
2120
+ const o2 = wr(e2, t2), { as: r2, c: i2, auth: a2, fetch: s2, tlsOnly: c2, timeout: u2 } = Fo(e2), l2 = await (async function(e3, t3, n3, o3, r3) {
2121
+ var i3;
2122
+ Gt(e3), Ft(t3);
2123
+ const a3 = Qt(e3, "pushed_authorization_request_endpoint", t3.use_mtls_endpoint_aliases, true !== (null == r3 ? void 0 : r3[yt])), s3 = new URLSearchParams(o3);
2124
+ s3.set("client_id", t3.client_id);
2125
+ const c3 = jt(null == r3 ? void 0 : r3.headers);
2126
+ c3.set("accept", "application/json"), void 0 !== (null == r3 ? void 0 : r3.DPoP) && (un(r3.DPoP), await r3.DPoP.addProof(a3, c3, "POST"));
2127
+ const u3 = await dn(e3, t3, n3, a3, s3, c3, r3);
2128
+ return null == r3 || null === (i3 = r3.DPoP) || void 0 === i3 || i3.cacheNonce(u3, a3), u3;
2129
+ })(r2, i2, a2, o2.searchParams, { [vt]: s2, [yt]: !c2, DPoP: null == n2 ? void 0 : n2.DPoP, headers: new Headers(Vo), signal: br(u2) }).catch(rr), d2 = (async function(e3, t3, n3) {
2130
+ if (Gt(e3), Ft(t3), !ft(n3, Response)) throw mt('"response" must be an instance of Response', "ERR_INVALID_ARG_TYPE");
2131
+ await cn(n3, 201, "Pushed Authorization Request Endpoint"), zn(n3);
2132
+ const o3 = await Xn(n3);
2133
+ Nt(o3.request_uri, '"response" body "request_uri" property', xn, { body: o3 });
2134
+ let r3 = "number" != typeof o3.expires_in ? parseFloat(o3.expires_in) : o3.expires_in;
2135
+ return Ut(r3, true, '"response" body "expires_in" property', xn, { body: o3 }), o3.expires_in = r3, o3;
2136
+ })(r2, i2, l2);
2137
+ let h2;
2138
+ try {
2139
+ h2 = await d2;
2140
+ } catch (o3) {
2141
+ if (_r(o3, n2)) return gr(e2, t2, ut(ut({}, n2), {}, { flag: kr }));
2142
+ rr(o3);
2143
+ }
2144
+ return wr(e2, { request_uri: h2.request_uri });
2145
+ }
2146
+ function vr(e2) {
2147
+ if (!(e2 instanceof sr)) throw $o('"config" must be an instance of Configuration', Qo);
2148
+ if (Object.getPrototypeOf(e2) !== sr.prototype) throw $o("subclassing Configuration is not allowed", Yo);
2149
+ }
2150
+ function br(e2) {
2151
+ return e2 ? AbortSignal.timeout(1e3 * e2) : void 0;
2152
+ }
2153
+ function _r(e2, t2) {
2154
+ return !(null == t2 || !t2.DPoP || t2.flag === kr) && (function(e3) {
2155
+ if (e3 instanceof tn) {
2156
+ const { 0: t3, length: n2 } = e3.cause;
2157
+ return 1 === n2 && "dpop" === t3.scheme && "use_dpop_nonce" === t3.parameters.error;
2158
+ }
2159
+ return e3 instanceof $t && "use_dpop_nonce" === e3.error;
2160
+ })(e2);
2161
+ }
2162
+ Object.freeze(sr.prototype);
2163
+ var kr = /* @__PURE__ */ Symbol();
2164
+ async function Sr(e2, t2, n2, o2) {
2165
+ vr(e2);
2166
+ const { as: r2, c: i2, auth: a2, fetch: s2, tlsOnly: c2, timeout: u2, decrypt: l2 } = Fo(e2), d2 = await (async function(e3, t3, n3, o3, r3, i3) {
2167
+ return Gt(e3), Ft(t3), Nt(o3, '"grantType"'), hn(e3, t3, n3, o3, new URLSearchParams(r3), i3);
2168
+ })(r2, i2, a2, t2, new URLSearchParams(n2), { [vt]: s2, [yt]: !c2, DPoP: null == o2 ? void 0 : o2.DPoP, headers: new Headers(Vo), signal: br(u2) }).then(((e3) => {
2169
+ let n3;
2170
+ return "urn:ietf:params:oauth:grant-type:token-exchange" === t2 && (n3 = { n_a: () => {
2171
+ } }), (async function(e4, t3, n4, o3) {
2172
+ return yn(e4, t3, n4, void 0, null == o3 ? void 0 : o3[_t], null == o3 ? void 0 : o3.recognizedTokenTypes);
2173
+ })(r2, i2, e3, { [_t]: l2, recognizedTokenTypes: n3 });
2174
+ })).catch(rr);
2175
+ return cr(d2), d2;
2176
+ }
2177
+ async function Er(e2, t2, n2) {
2178
+ if (t2 instanceof Uint8Array) {
2179
+ if (!e2.startsWith("HS")) throw new TypeError((function(e3) {
2180
+ for (var t3 = arguments.length, n3 = new Array(t3 > 1 ? t3 - 1 : 0), o2 = 1; o2 < t3; o2++) n3[o2 - 1] = arguments[o2];
2181
+ return _o("Key must be ", e3, ...n3);
2182
+ })(t2, "CryptoKey", "KeyObject", "JSON Web Key"));
2183
+ return crypto.subtle.importKey("raw", t2, { hash: "SHA-".concat(e2.slice(-3)), name: "HMAC" }, false, [n2]);
2184
+ }
2185
+ return bo(t2, e2, n2), t2;
2186
+ }
2187
+ async function Ar(e2, t2, n2, o2) {
2188
+ const r2 = await Er(e2, t2, "verify");
2189
+ !(function(e3, t3) {
2190
+ if (e3.startsWith("RS") || e3.startsWith("PS")) {
2191
+ const { modulusLength: n3 } = t3.algorithm;
2192
+ if ("number" != typeof n3 || n3 < 2048) throw new TypeError("".concat(e3, " requires key modulusLength to be 2048 bits or larger"));
2193
+ }
2194
+ })(e2, r2);
2195
+ const i2 = (function(e3, t3) {
2196
+ const n3 = "SHA-".concat(e3.slice(-3));
2197
+ switch (e3) {
2198
+ case "HS256":
2199
+ case "HS384":
2200
+ case "HS512":
2201
+ return { hash: n3, name: "HMAC" };
2202
+ case "PS256":
2203
+ case "PS384":
2204
+ case "PS512":
2205
+ return { hash: n3, name: "RSA-PSS", saltLength: parseInt(e3.slice(-3), 10) >> 3 };
2206
+ case "RS256":
2207
+ case "RS384":
2208
+ case "RS512":
2209
+ return { hash: n3, name: "RSASSA-PKCS1-v1_5" };
2210
+ case "ES256":
2211
+ case "ES384":
2212
+ case "ES512":
2213
+ return { hash: n3, name: "ECDSA", namedCurve: t3.namedCurve };
2214
+ case "Ed25519":
2215
+ case "EdDSA":
2216
+ return { name: "Ed25519" };
2217
+ case "ML-DSA-44":
2218
+ case "ML-DSA-65":
2219
+ case "ML-DSA-87":
2220
+ return { name: e3 };
2221
+ default:
2222
+ throw new co("alg ".concat(e3, " is not supported either by JOSE or your javascript runtime"));
2223
+ }
2224
+ })(e2, r2.algorithm);
2225
+ try {
2226
+ return await crypto.subtle.verify(i2, r2, n2, o2);
2227
+ } catch (e3) {
2228
+ return false;
2229
+ }
2230
+ }
2231
+ async function Tr(e2, t2, n2) {
2232
+ if (!To(e2)) throw new uo("Flattened JWS must be an object");
2233
+ if (void 0 === e2.protected && void 0 === e2.header) throw new uo('Flattened JWS must have either of the "protected" or "header" members');
2234
+ if (void 0 !== e2.protected && "string" != typeof e2.protected) throw new uo("JWS Protected Header incorrect type");
2235
+ if (void 0 === e2.payload) throw new uo("JWS Payload missing");
2236
+ if ("string" != typeof e2.signature) throw new uo("JWS Signature missing or incorrect type");
2237
+ if (void 0 !== e2.header && !To(e2.header)) throw new uo("JWS Unprotected Header incorrect type");
2238
+ let o2 = {};
2239
+ if (e2.protected) try {
2240
+ const t3 = oo(e2.protected);
2241
+ o2 = JSON.parse(eo.decode(t3));
2242
+ } catch (e3) {
2243
+ throw new uo("JWS Protected Header is invalid");
2244
+ }
2245
+ if (!(function() {
2246
+ for (var e3 = arguments.length, t3 = new Array(e3), n3 = 0; n3 < e3; n3++) t3[n3] = arguments[n3];
2247
+ const o3 = t3.filter(Boolean);
2248
+ if (0 === o3.length || 1 === o3.length) return true;
2249
+ let r3;
2250
+ for (const e4 of o3) {
2251
+ const t4 = Object.keys(e4);
2252
+ if (r3 && 0 !== r3.size) for (const e5 of t4) {
2253
+ if (r3.has(e5)) return false;
2254
+ r3.add(e5);
2255
+ }
2256
+ else r3 = new Set(t4);
2257
+ }
2258
+ return true;
2259
+ })(o2, e2.header)) throw new uo("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
2260
+ const r2 = ut(ut({}, o2), e2.header), i2 = (function(e3, t3, n3, o3, r3) {
2261
+ if (void 0 !== r3.crit && void 0 === (null == o3 ? void 0 : o3.crit)) throw new e3('"crit" (Critical) Header Parameter MUST be integrity protected');
2262
+ if (!o3 || void 0 === o3.crit) return /* @__PURE__ */ new Set();
2263
+ if (!Array.isArray(o3.crit) || 0 === o3.crit.length || o3.crit.some(((e4) => "string" != typeof e4 || 0 === e4.length))) throw new e3('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
2264
+ let i3;
2265
+ i3 = void 0 !== n3 ? new Map([...Object.entries(n3), ...t3.entries()]) : t3;
2266
+ for (const t4 of o3.crit) {
2267
+ if (!i3.has(t4)) throw new co('Extension Header Parameter "'.concat(t4, '" is not recognized'));
2268
+ if (void 0 === r3[t4]) throw new e3('Extension Header Parameter "'.concat(t4, '" is missing'));
2269
+ if (i3.get(t4) && void 0 === o3[t4]) throw new e3('Extension Header Parameter "'.concat(t4, '" MUST be integrity protected'));
2270
+ }
2271
+ return new Set(o3.crit);
2272
+ })(uo, /* @__PURE__ */ new Map([["b64", true]]), null == n2 ? void 0 : n2.crit, o2, r2);
2273
+ let a2 = true;
2274
+ if (i2.has("b64") && (a2 = o2.b64, "boolean" != typeof a2)) throw new uo('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
2275
+ const { alg: s2 } = r2;
2276
+ if ("string" != typeof s2 || !s2) throw new uo('JWS "alg" (Algorithm) Header Parameter missing or invalid');
2277
+ const c2 = n2 && (function(e3, t3) {
2278
+ if (void 0 !== t3 && (!Array.isArray(t3) || t3.some(((e4) => "string" != typeof e4)))) throw new TypeError('"'.concat(e3, '" option must be an array of strings'));
2279
+ if (t3) return new Set(t3);
2280
+ })("algorithms", n2.algorithms);
2281
+ if (c2 && !c2.has(s2)) throw new so('"alg" (Algorithm) Header Parameter value not allowed');
2282
+ if (a2) {
2283
+ if ("string" != typeof e2.payload) throw new uo("JWS Payload must be a string");
2284
+ } else if ("string" != typeof e2.payload && !(e2.payload instanceof Uint8Array)) throw new uo("JWS Payload must be a string or an Uint8Array instance");
2285
+ let u2 = false;
2286
+ "function" == typeof t2 && (t2 = await t2(o2, e2), u2 = true), zo(s2, t2, "verify");
2287
+ const l2 = (function() {
2288
+ for (var e3 = arguments.length, t3 = new Array(e3), n3 = 0; n3 < e3; n3++) t3[n3] = arguments[n3];
2289
+ const o3 = t3.reduce(((e4, t4) => {
2290
+ let { length: n4 } = t4;
2291
+ return e4 + n4;
2292
+ }), 0), r3 = new Uint8Array(o3);
2293
+ let i3 = 0;
2294
+ for (const e4 of t3) r3.set(e4, i3), i3 += e4.length;
2295
+ return r3;
2296
+ })(void 0 !== e2.protected ? to(e2.protected) : new Uint8Array(), to("."), "string" == typeof e2.payload ? a2 ? to(e2.payload) : $n.encode(e2.payload) : e2.payload);
2297
+ let d2;
2298
+ try {
2299
+ d2 = oo(e2.signature);
2300
+ } catch (e3) {
2301
+ throw new uo("Failed to base64url decode the signature");
2302
+ }
2303
+ const h2 = await No(t2, s2);
2304
+ if (!await Ar(s2, h2, d2, l2)) throw new yo();
2305
+ let p2;
2306
+ if (a2) try {
2307
+ p2 = oo(e2.payload);
2308
+ } catch (e3) {
2309
+ throw new uo("Failed to base64url decode the payload");
2310
+ }
2311
+ else p2 = "string" == typeof e2.payload ? $n.encode(e2.payload) : e2.payload;
2312
+ const f = { payload: p2 };
2313
+ return void 0 !== e2.protected && (f.protectedHeader = o2), void 0 !== e2.header && (f.unprotectedHeader = e2.header), u2 ? ut(ut({}, f), {}, { key: h2 }) : f;
2314
+ }
2315
+ var Pr = (e2) => Math.floor(e2.getTime() / 1e3);
2316
+ var Rr = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;
2317
+ function Ir(e2) {
2318
+ const t2 = Rr.exec(e2);
2319
+ if (!t2 || t2[4] && t2[1]) throw new TypeError("Invalid time period format");
2320
+ const n2 = parseFloat(t2[2]);
2321
+ let o2;
2322
+ switch (t2[3].toLowerCase()) {
2323
+ case "sec":
2324
+ case "secs":
2325
+ case "second":
2326
+ case "seconds":
2327
+ case "s":
2328
+ o2 = Math.round(n2);
2329
+ break;
2330
+ case "minute":
2331
+ case "minutes":
2332
+ case "min":
2333
+ case "mins":
2334
+ case "m":
2335
+ o2 = Math.round(60 * n2);
2336
+ break;
2337
+ case "hour":
2338
+ case "hours":
2339
+ case "hr":
2340
+ case "hrs":
2341
+ case "h":
2342
+ o2 = Math.round(3600 * n2);
2343
+ break;
2344
+ case "day":
2345
+ case "days":
2346
+ case "d":
2347
+ o2 = Math.round(86400 * n2);
2348
+ break;
2349
+ case "week":
2350
+ case "weeks":
2351
+ case "w":
2352
+ o2 = Math.round(604800 * n2);
2353
+ break;
2354
+ default:
2355
+ o2 = Math.round(31557600 * n2);
2356
+ }
2357
+ return "-" === t2[1] || "ago" === t2[4] ? -o2 : o2;
2358
+ }
2359
+ var Or = (e2) => e2.includes("/") ? e2.toLowerCase() : "application/".concat(e2.toLowerCase());
2360
+ var xr = (e2, t2) => "string" == typeof e2 ? t2.includes(e2) : !!Array.isArray(e2) && t2.some(Set.prototype.has.bind(new Set(e2)));
2361
+ async function Cr(e2, t2, n2) {
2362
+ var o2;
2363
+ const r2 = await (async function(e3, t3, n3) {
2364
+ if (e3 instanceof Uint8Array && (e3 = eo.decode(e3)), "string" != typeof e3) throw new uo("Compact JWS must be a string or Uint8Array");
2365
+ const { 0: o3, 1: r3, 2: i3, length: a3 } = e3.split(".");
2366
+ if (3 !== a3) throw new uo("Invalid Compact JWS");
2367
+ const s2 = await Tr({ payload: r3, protected: o3, signature: i3 }, t3, n3), c2 = { payload: s2.payload, protectedHeader: s2.protectedHeader };
2368
+ return "function" == typeof t3 ? ut(ut({}, c2), {}, { key: s2.key }) : c2;
2369
+ })(e2, t2, n2);
2370
+ if (null !== (o2 = r2.protectedHeader.crit) && void 0 !== o2 && o2.includes("b64") && false === r2.protectedHeader.b64) throw new lo("JWTs MUST NOT use unencoded payload");
2371
+ const i2 = (function(e3, t3) {
2372
+ let n3, o3 = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
2373
+ try {
2374
+ n3 = JSON.parse(eo.decode(t3));
2375
+ } catch (e4) {
2376
+ }
2377
+ if (!To(n3)) throw new lo("JWT Claims Set must be a top-level JSON object");
2378
+ const { typ: r3 } = o3;
2379
+ if (r3 && ("string" != typeof e3.typ || Or(e3.typ) !== Or(r3))) throw new io('unexpected "typ" JWT header value', n3, "typ", "check_failed");
2380
+ const { requiredClaims: i3 = [], issuer: a3, subject: s2, audience: c2, maxTokenAge: u2 } = o3, l2 = [...i3];
2381
+ void 0 !== u2 && l2.push("iat"), void 0 !== c2 && l2.push("aud"), void 0 !== s2 && l2.push("sub"), void 0 !== a3 && l2.push("iss");
2382
+ for (const e4 of new Set(l2.reverse())) if (!(e4 in n3)) throw new io('missing required "'.concat(e4, '" claim'), n3, e4, "missing");
2383
+ if (a3 && !(Array.isArray(a3) ? a3 : [a3]).includes(n3.iss)) throw new io('unexpected "iss" claim value', n3, "iss", "check_failed");
2384
+ if (s2 && n3.sub !== s2) throw new io('unexpected "sub" claim value', n3, "sub", "check_failed");
2385
+ if (c2 && !xr(n3.aud, "string" == typeof c2 ? [c2] : c2)) throw new io('unexpected "aud" claim value', n3, "aud", "check_failed");
2386
+ let d2;
2387
+ switch (typeof o3.clockTolerance) {
2388
+ case "string":
2389
+ d2 = Ir(o3.clockTolerance);
2390
+ break;
2391
+ case "number":
2392
+ d2 = o3.clockTolerance;
2393
+ break;
2394
+ case "undefined":
2395
+ d2 = 0;
2396
+ break;
2397
+ default:
2398
+ throw new TypeError("Invalid clockTolerance option type");
2399
+ }
2400
+ const { currentDate: h2 } = o3, p2 = Pr(h2 || /* @__PURE__ */ new Date());
2401
+ if ((void 0 !== n3.iat || u2) && "number" != typeof n3.iat) throw new io('"iat" claim must be a number', n3, "iat", "invalid");
2402
+ if (void 0 !== n3.nbf) {
2403
+ if ("number" != typeof n3.nbf) throw new io('"nbf" claim must be a number', n3, "nbf", "invalid");
2404
+ if (n3.nbf > p2 + d2) throw new io('"nbf" claim timestamp check failed', n3, "nbf", "check_failed");
2405
+ }
2406
+ if (void 0 !== n3.exp) {
2407
+ if ("number" != typeof n3.exp) throw new io('"exp" claim must be a number', n3, "exp", "invalid");
2408
+ if (n3.exp <= p2 - d2) throw new ao('"exp" claim timestamp check failed', n3, "exp", "check_failed");
2409
+ }
2410
+ if (u2) {
2411
+ const e4 = p2 - n3.iat;
2412
+ if (e4 - d2 > ("number" == typeof u2 ? u2 : Ir(u2))) throw new ao('"iat" claim timestamp check failed (too far in the past)', n3, "iat", "check_failed");
2413
+ if (e4 < 0 - d2) throw new io('"iat" claim timestamp check failed (it should be in the past)', n3, "iat", "check_failed");
2414
+ }
2415
+ return n3;
2416
+ })(r2.protectedHeader, r2.payload, n2), a2 = { payload: i2, protectedHeader: r2.protectedHeader };
2417
+ return "function" == typeof t2 ? ut(ut({}, a2), {}, { key: r2.key }) : a2;
2418
+ }
2419
+ function jr(e2) {
2420
+ return To(e2);
2421
+ }
2422
+ var Dr;
2423
+ var Kr;
2424
+ var Lr = /* @__PURE__ */ new WeakMap();
2425
+ var Ur = /* @__PURE__ */ new WeakMap();
2426
+ var Nr = class {
2427
+ constructor(e2) {
2428
+ if (it(this, Lr, void 0), it(this, Ur, /* @__PURE__ */ new WeakMap()), !(function(e3) {
2429
+ return e3 && "object" == typeof e3 && Array.isArray(e3.keys) && e3.keys.every(jr);
2430
+ })(e2)) throw new ho("JSON Web Key Set malformed");
2431
+ at(Lr, this, structuredClone(e2));
2432
+ }
2433
+ jwks() {
2434
+ return rt(Lr, this);
2435
+ }
2436
+ async getKey(e2, t2) {
2437
+ const { alg: n2, kid: o2 } = ut(ut({}, e2), null == t2 ? void 0 : t2.header), r2 = (function(e3) {
2438
+ switch ("string" == typeof e3 && e3.slice(0, 2)) {
2439
+ case "RS":
2440
+ case "PS":
2441
+ return "RSA";
2442
+ case "ES":
2443
+ return "EC";
2444
+ case "Ed":
2445
+ return "OKP";
2446
+ case "ML":
2447
+ return "AKP";
2448
+ default:
2449
+ throw new co('Unsupported "alg" value for a JSON Web Key Set');
2450
+ }
2451
+ })(n2), i2 = rt(Lr, this).keys.filter(((e3) => {
2452
+ let t3 = r2 === e3.kty;
2453
+ if (t3 && "string" == typeof o2 && (t3 = o2 === e3.kid), !t3 || "string" != typeof e3.alg && "AKP" !== r2 || (t3 = n2 === e3.alg), t3 && "string" == typeof e3.use && (t3 = "sig" === e3.use), t3 && Array.isArray(e3.key_ops) && (t3 = e3.key_ops.includes("verify")), t3) switch (n2) {
2454
+ case "ES256":
2455
+ t3 = "P-256" === e3.crv;
2456
+ break;
2457
+ case "ES384":
2458
+ t3 = "P-384" === e3.crv;
2459
+ break;
2460
+ case "ES512":
2461
+ t3 = "P-521" === e3.crv;
2462
+ break;
2463
+ case "Ed25519":
2464
+ case "EdDSA":
2465
+ t3 = "Ed25519" === e3.crv;
2466
+ }
2467
+ return t3;
2468
+ })), { 0: a2, length: s2 } = i2;
2469
+ if (0 === s2) throw new po();
2470
+ if (1 !== s2) {
2471
+ const e3 = new fo(), t3 = rt(Ur, this);
2472
+ throw e3[Symbol.asyncIterator] = dt((function* () {
2473
+ for (const e4 of i2) try {
2474
+ yield yield nt(Wr(t3, e4, n2));
2475
+ } catch (e5) {
2476
+ }
2477
+ })), e3;
2478
+ }
2479
+ return Wr(rt(Ur, this), a2, n2);
2480
+ }
2481
+ };
2482
+ async function Wr(e2, t2, n2) {
2483
+ const o2 = e2.get(t2) || e2.set(t2, {}).get(t2);
2484
+ if (void 0 === o2[n2]) {
2485
+ const e3 = await (async function(e4, t3, n3) {
2486
+ var o3;
2487
+ if (!To(e4)) throw new TypeError("JWK must be an object");
2488
+ let r2;
2489
+ switch (null != t3 || (t3 = e4.alg), null != r2 || (r2 = null !== (o3 = null == n3 ? void 0 : n3.extractable) && void 0 !== o3 ? o3 : e4.ext), e4.kty) {
2490
+ case "oct":
2491
+ if ("string" != typeof e4.k || !e4.k) throw new TypeError('missing "k" (Key Value) Parameter value');
2492
+ return oo(e4.k);
2493
+ case "RSA":
2494
+ if ("oth" in e4 && void 0 !== e4.oth) throw new co('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');
2495
+ return Do(ut(ut({}, e4), {}, { alg: t3, ext: r2 }));
2496
+ case "AKP":
2497
+ if ("string" != typeof e4.alg || !e4.alg) throw new TypeError('missing "alg" (Algorithm) Parameter value');
2498
+ if (void 0 !== t3 && t3 !== e4.alg) throw new TypeError("JWK alg and alg option value mismatch");
2499
+ return Do(ut(ut({}, e4), {}, { ext: r2 }));
2500
+ case "EC":
2501
+ case "OKP":
2502
+ return Do(ut(ut({}, e4), {}, { alg: t3, ext: r2 }));
2503
+ default:
2504
+ throw new co('Unsupported "kty" (Key Type) Parameter value');
2505
+ }
2506
+ })(ut(ut({}, t2), {}, { ext: true }), n2);
2507
+ if (e3 instanceof Uint8Array || "public" !== e3.type) throw new ho("JSON Web Key Set members must be public keys");
2508
+ o2[n2] = e3;
2509
+ }
2510
+ return o2[n2];
2511
+ }
2512
+ function Hr(e2) {
2513
+ const t2 = new Nr(e2), n2 = async (e3, n3) => t2.getKey(e3, n3);
2514
+ return Object.defineProperties(n2, { jwks: { value: () => structuredClone(t2.jwks()), enumerable: false, configurable: false, writable: false } }), n2;
2515
+ }
2516
+ var zr;
2517
+ if ("undefined" == typeof navigator || null === (Dr = navigator.userAgent) || void 0 === Dr || null === (Kr = Dr.startsWith) || void 0 === Kr || !Kr.call(Dr, "Mozilla/5.0 ")) {
2518
+ const e2 = "v6.1.3";
2519
+ zr = "".concat("jose", "/").concat(e2);
2520
+ }
2521
+ var Jr = /* @__PURE__ */ Symbol();
2522
+ var Mr = /* @__PURE__ */ Symbol();
2523
+ var Vr = /* @__PURE__ */ new WeakMap();
2524
+ var Gr = /* @__PURE__ */ new WeakMap();
2525
+ var Fr = /* @__PURE__ */ new WeakMap();
2526
+ var Zr = /* @__PURE__ */ new WeakMap();
2527
+ var qr = /* @__PURE__ */ new WeakMap();
2528
+ var Br = /* @__PURE__ */ new WeakMap();
2529
+ var Xr = /* @__PURE__ */ new WeakMap();
2530
+ var Yr = /* @__PURE__ */ new WeakMap();
2531
+ var Qr = /* @__PURE__ */ new WeakMap();
2532
+ var $r = /* @__PURE__ */ new WeakMap();
2533
+ var ei = class {
2534
+ constructor(e2, t2) {
2535
+ if (it(this, Vr, void 0), it(this, Gr, void 0), it(this, Fr, void 0), it(this, Zr, void 0), it(this, qr, void 0), it(this, Br, void 0), it(this, Xr, void 0), it(this, Yr, void 0), it(this, Qr, void 0), it(this, $r, void 0), !(e2 instanceof URL)) throw new TypeError("url must be an instance of URL");
2536
+ var n2, o2;
2537
+ at(Vr, this, new URL(e2.href)), at(Gr, this, "number" == typeof (null == t2 ? void 0 : t2.timeoutDuration) ? null == t2 ? void 0 : t2.timeoutDuration : 5e3), at(Fr, this, "number" == typeof (null == t2 ? void 0 : t2.cooldownDuration) ? null == t2 ? void 0 : t2.cooldownDuration : 3e4), at(Zr, this, "number" == typeof (null == t2 ? void 0 : t2.cacheMaxAge) ? null == t2 ? void 0 : t2.cacheMaxAge : 6e5), at(Xr, this, new Headers(null == t2 ? void 0 : t2.headers)), zr && !rt(Xr, this).has("User-Agent") && rt(Xr, this).set("User-Agent", zr), rt(Xr, this).has("accept") || (rt(Xr, this).set("accept", "application/json"), rt(Xr, this).append("accept", "application/jwk-set+json")), at(Yr, this, null == t2 ? void 0 : t2[Jr]), void 0 !== (null == t2 ? void 0 : t2[Mr]) && (at($r, this, null == t2 ? void 0 : t2[Mr]), n2 = null == t2 ? void 0 : t2[Mr], o2 = rt(Zr, this), "object" == typeof n2 && null !== n2 && "uat" in n2 && "number" == typeof n2.uat && !(Date.now() - n2.uat >= o2) && "jwks" in n2 && To(n2.jwks) && Array.isArray(n2.jwks.keys) && Array.prototype.every.call(n2.jwks.keys, To) && (at(qr, this, rt($r, this).uat), at(Qr, this, Hr(rt($r, this).jwks))));
2538
+ }
2539
+ pendingFetch() {
2540
+ return !!rt(Br, this);
2541
+ }
2542
+ coolingDown() {
2543
+ return "number" == typeof rt(qr, this) && Date.now() < rt(qr, this) + rt(Fr, this);
2544
+ }
2545
+ fresh() {
2546
+ return "number" == typeof rt(qr, this) && Date.now() < rt(qr, this) + rt(Zr, this);
2547
+ }
2548
+ jwks() {
2549
+ var e2;
2550
+ return null === (e2 = rt(Qr, this)) || void 0 === e2 ? void 0 : e2.jwks();
2551
+ }
2552
+ async getKey(e2, t2) {
2553
+ rt(Qr, this) && this.fresh() || await this.reload();
2554
+ try {
2555
+ return await rt(Qr, this).call(this, e2, t2);
2556
+ } catch (n2) {
2557
+ if (n2 instanceof po && false === this.coolingDown()) return await this.reload(), rt(Qr, this).call(this, e2, t2);
2558
+ throw n2;
2559
+ }
2560
+ }
2561
+ async reload() {
2562
+ rt(Br, this) && ("undefined" != typeof WebSocketPair || "undefined" != typeof navigator && "Cloudflare-Workers" === navigator.userAgent || "undefined" != typeof EdgeRuntime && "vercel" === EdgeRuntime) && at(Br, this, void 0), rt(Br, this) || at(Br, this, (async function(e2, t2, n2) {
2563
+ let o2 = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : fetch;
2564
+ const r2 = await o2(e2, { method: "GET", signal: n2, redirect: "manual", headers: t2 }).catch(((e3) => {
2565
+ if ("TimeoutError" === e3.name) throw new mo();
2566
+ throw e3;
2567
+ }));
2568
+ if (200 !== r2.status) throw new ro("Expected 200 OK from the JSON Web Key Set HTTP response");
2569
+ try {
2570
+ return await r2.json();
2571
+ } catch (e3) {
2572
+ throw new ro("Failed to parse the JSON Web Key Set HTTP response as JSON");
2573
+ }
2574
+ })(rt(Vr, this).href, rt(Xr, this), AbortSignal.timeout(rt(Gr, this)), rt(Yr, this)).then(((e2) => {
2575
+ at(Qr, this, Hr(e2)), rt($r, this) && (rt($r, this).uat = Date.now(), rt($r, this).jwks = e2), at(qr, this, Date.now()), at(Br, this, void 0);
2576
+ })).catch(((e2) => {
2577
+ throw at(Br, this, void 0), e2;
2578
+ }))), await rt(Br, this);
2579
+ }
2580
+ };
2581
+ var ti = ["mfaToken"];
2582
+ var ni = ["mfaToken"];
2583
+ var oi;
2584
+ var ri;
2585
+ var ii;
2586
+ var ai;
2587
+ var si;
2588
+ var ci;
2589
+ var ui;
2590
+ var li;
2591
+ var di = class extends Error {
2592
+ constructor(e2, t2) {
2593
+ super(t2), st(this, "code", void 0), this.name = "NotSupportedError", this.code = e2;
2594
+ }
2595
+ };
2596
+ var hi = class extends Error {
2597
+ constructor(e2, t2, n2) {
2598
+ super(t2), st(this, "cause", void 0), st(this, "code", void 0), this.code = e2, this.cause = n2 && { error: n2.error, error_description: n2.error_description, message: n2.message };
2599
+ }
2600
+ };
2601
+ var pi = class extends hi {
2602
+ constructor(e2, t2) {
2603
+ super("token_by_code_error", e2, t2), this.name = "TokenByCodeError";
2604
+ }
2605
+ };
2606
+ var fi = class extends hi {
2607
+ constructor(e2, t2) {
2608
+ super("token_by_client_credentials_error", e2, t2), this.name = "TokenByClientCredentialsError";
2609
+ }
2610
+ };
2611
+ var mi = class extends hi {
2612
+ constructor(e2, t2) {
2613
+ super("token_by_refresh_token_error", e2, t2), this.name = "TokenByRefreshTokenError";
2614
+ }
2615
+ };
2616
+ var yi = class extends hi {
2617
+ constructor(e2, t2) {
2618
+ super("token_for_connection_error", e2, t2), this.name = "TokenForConnectionErrorCode";
2619
+ }
2620
+ };
2621
+ var wi = class extends hi {
2622
+ constructor(e2, t2) {
2623
+ super("token_exchange_error", e2, t2), this.name = "TokenExchangeError";
2624
+ }
2625
+ };
2626
+ var gi = class extends Error {
2627
+ constructor(e2) {
2628
+ super(e2), st(this, "code", "verify_logout_token_error"), this.name = "VerifyLogoutTokenError";
2629
+ }
2630
+ };
2631
+ var vi = class extends hi {
2632
+ constructor(e2) {
2633
+ super("backchannel_authentication_error", "There was an error when trying to use Client-Initiated Backchannel Authentication.", e2), st(this, "code", "backchannel_authentication_error"), this.name = "BackchannelAuthenticationError";
2634
+ }
2635
+ };
2636
+ var bi = class extends hi {
2637
+ constructor(e2) {
2638
+ super("build_authorization_url_error", "There was an error when trying to build the authorization URL.", e2), this.name = "BuildAuthorizationUrlError";
2639
+ }
2640
+ };
2641
+ var _i = class extends hi {
2642
+ constructor(e2) {
2643
+ super("build_link_user_url_error", "There was an error when trying to build the Link User URL.", e2), this.name = "BuildLinkUserUrlError";
2644
+ }
2645
+ };
2646
+ var ki = class extends hi {
2647
+ constructor(e2) {
2648
+ super("build_unlink_user_url_error", "There was an error when trying to build the Unlink User URL.", e2), this.name = "BuildUnlinkUserUrlError";
2649
+ }
2650
+ };
2651
+ var Si = class extends Error {
2652
+ constructor() {
2653
+ super("The client secret or client assertion signing key must be provided."), st(this, "code", "missing_client_auth_error"), this.name = "MissingClientAuthError";
2654
+ }
2655
+ };
2656
+ function Ei(e2) {
2657
+ return Object.entries(e2).filter(((e3) => {
2658
+ let [, t2] = e3;
2659
+ return void 0 !== t2;
2660
+ })).reduce(((e3, t2) => ut(ut({}, e3), {}, { [t2[0]]: t2[1] })), {});
2661
+ }
2662
+ var Ai = class extends Error {
2663
+ constructor(e2, t2, n2) {
2664
+ super(t2), st(this, "cause", void 0), st(this, "code", void 0), this.code = e2, this.cause = n2 && { error: n2.error, error_description: n2.error_description, message: n2.message };
2665
+ }
2666
+ };
2667
+ var Ti = class extends Ai {
2668
+ constructor(e2, t2) {
2669
+ super("mfa_list_authenticators_error", e2, t2), this.name = "MfaListAuthenticatorsError";
2670
+ }
2671
+ };
2672
+ var Pi = class extends Ai {
2673
+ constructor(e2, t2) {
2674
+ super("mfa_enrollment_error", e2, t2), this.name = "MfaEnrollmentError";
2675
+ }
2676
+ };
2677
+ var Ri = class extends Ai {
2678
+ constructor(e2, t2) {
2679
+ super("mfa_delete_authenticator_error", e2, t2), this.name = "MfaDeleteAuthenticatorError";
2680
+ }
2681
+ };
2682
+ var Ii = class extends Ai {
2683
+ constructor(e2, t2) {
2684
+ super("mfa_challenge_error", e2, t2), this.name = "MfaChallengeError";
2685
+ }
2686
+ };
2687
+ function Oi(e2) {
2688
+ return { id: e2.id, authenticatorType: e2.authenticator_type, active: e2.active, name: e2.name, oobChannels: e2.oob_channels, type: e2.type };
2689
+ }
2690
+ var xi = (oi = /* @__PURE__ */ new WeakMap(), ri = /* @__PURE__ */ new WeakMap(), ii = /* @__PURE__ */ new WeakMap(), class {
2691
+ constructor(e2) {
2692
+ var t2;
2693
+ it(this, oi, void 0), it(this, ri, void 0), it(this, ii, void 0), at(oi, this, "https://".concat(e2.domain)), at(ri, this, e2.clientId), at(ii, this, null !== (t2 = e2.customFetch) && void 0 !== t2 ? t2 : function() {
2694
+ return fetch(...arguments);
2695
+ });
2696
+ }
2697
+ async listAuthenticators(e2) {
2698
+ const t2 = "".concat(rt(oi, this), "/mfa/authenticators"), { mfaToken: n2 } = e2, o2 = await rt(ii, this).call(this, t2, { method: "GET", headers: { Authorization: "Bearer ".concat(n2), "Content-Type": "application/json" } });
2699
+ if (!o2.ok) {
2700
+ const e3 = await o2.json();
2701
+ throw new Ti(e3.error_description || "Failed to list authenticators", e3);
2702
+ }
2703
+ return (await o2.json()).map(Oi);
2704
+ }
2705
+ async enrollAuthenticator(e2) {
2706
+ const t2 = "".concat(rt(oi, this), "/mfa/associate"), { mfaToken: n2 } = e2, o2 = lt(e2, ti), r2 = { authenticator_types: o2.authenticatorTypes };
2707
+ "oobChannels" in o2 && (r2.oob_channels = o2.oobChannels), "phoneNumber" in o2 && o2.phoneNumber && (r2.phone_number = o2.phoneNumber), "email" in o2 && o2.email && (r2.email = o2.email);
2708
+ const i2 = await rt(ii, this).call(this, t2, { method: "POST", headers: { Authorization: "Bearer ".concat(n2), "Content-Type": "application/json" }, body: JSON.stringify(r2) });
2709
+ if (!i2.ok) {
2710
+ const e3 = await i2.json();
2711
+ throw new Pi(e3.error_description || "Failed to enroll authenticator", e3);
2712
+ }
2713
+ return (function(e3) {
2714
+ if ("otp" === e3.authenticator_type) return { authenticatorType: "otp", secret: e3.secret, barcodeUri: e3.barcode_uri, recoveryCodes: e3.recovery_codes, id: e3.id };
2715
+ if ("oob" === e3.authenticator_type) return { authenticatorType: "oob", oobChannel: e3.oob_channel, oobCode: e3.oob_code, bindingMethod: e3.binding_method, id: e3.id };
2716
+ throw new Error("Unexpected authenticator type: ".concat(e3.authenticator_type));
2717
+ })(await i2.json());
2718
+ }
2719
+ async deleteAuthenticator(e2) {
2720
+ const { authenticatorId: t2, mfaToken: n2 } = e2, o2 = "".concat(rt(oi, this), "/mfa/authenticators/").concat(encodeURIComponent(t2)), r2 = await rt(ii, this).call(this, o2, { method: "DELETE", headers: { Authorization: "Bearer ".concat(n2), "Content-Type": "application/json" } });
2721
+ if (!r2.ok) {
2722
+ const e3 = await r2.json();
2723
+ throw new Ri(e3.error_description || "Failed to delete authenticator", e3);
2724
+ }
2725
+ }
2726
+ async challengeAuthenticator(e2) {
2727
+ const t2 = "".concat(rt(oi, this), "/mfa/challenge"), { mfaToken: n2 } = e2, o2 = lt(e2, ni), r2 = { mfa_token: n2, client_id: rt(ri, this), challenge_type: o2.challengeType };
2728
+ o2.authenticatorId && (r2.authenticator_id = o2.authenticatorId);
2729
+ const i2 = await rt(ii, this).call(this, t2, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(r2) });
2730
+ if (!i2.ok) {
2731
+ const e3 = await i2.json();
2732
+ throw new Ii(e3.error_description || "Failed to challenge authenticator", e3);
2733
+ }
2734
+ return (function(e3) {
2735
+ const t3 = { challengeType: e3.challenge_type };
2736
+ return void 0 !== e3.oob_code && (t3.oobCode = e3.oob_code), void 0 !== e3.binding_method && (t3.bindingMethod = e3.binding_method), t3;
2737
+ })(await i2.json());
2738
+ }
2739
+ });
2740
+ var Ci = class e {
2741
+ constructor(e2, t2, n2, o2, r2, i2, a2) {
2742
+ st(this, "accessToken", void 0), st(this, "idToken", void 0), st(this, "refreshToken", void 0), st(this, "expiresAt", void 0), st(this, "scope", void 0), st(this, "claims", void 0), st(this, "authorizationDetails", void 0), st(this, "tokenType", void 0), st(this, "issuedTokenType", void 0), this.accessToken = e2, this.idToken = n2, this.refreshToken = o2, this.expiresAt = t2, this.scope = r2, this.claims = i2, this.authorizationDetails = a2;
2743
+ }
2744
+ static fromTokenEndpointResponse(t2) {
2745
+ const n2 = t2.id_token ? t2.claims() : void 0, o2 = new e(t2.access_token, Math.floor(Date.now() / 1e3) + Number(t2.expires_in), t2.id_token, t2.refresh_token, t2.scope, n2, t2.authorization_details);
2746
+ return o2.tokenType = t2.token_type, o2.issuedTokenType = t2.issued_token_type, o2;
2747
+ }
2748
+ };
2749
+ var ji = "openid profile email offline_access";
2750
+ var Di = Object.freeze(/* @__PURE__ */ new Set(["grant_type", "client_id", "client_secret", "client_assertion", "client_assertion_type", "subject_token", "subject_token_type", "requested_token_type", "actor_token", "actor_token_type", "audience", "aud", "resource", "resources", "resource_indicator", "scope", "connection", "login_hint", "organization", "assertion"]));
2751
+ function Ki(e2) {
2752
+ if (null == e2) throw new wi("subject_token is required");
2753
+ if ("string" != typeof e2) throw new wi("subject_token must be a string");
2754
+ if (0 === e2.trim().length) throw new wi("subject_token cannot be blank or whitespace");
2755
+ if (e2 !== e2.trim()) throw new wi("subject_token must not include leading or trailing whitespace");
2756
+ if (/^bearer\s+/i.test(e2)) throw new wi("subject_token must not include the 'Bearer ' prefix");
2757
+ }
2758
+ function Li(e2, t2) {
2759
+ if (t2) {
2760
+ for (const [n2, o2] of Object.entries(t2)) if (!Di.has(n2)) if (Array.isArray(o2)) {
2761
+ if (o2.length > 20) throw new wi("Parameter '".concat(n2, "' exceeds maximum array size of ").concat(20));
2762
+ o2.forEach(((t3) => {
2763
+ e2.append(n2, t3);
2764
+ }));
2765
+ } else e2.append(n2, o2);
2766
+ }
2767
+ }
2768
+ var Ui = (ai = /* @__PURE__ */ new WeakMap(), si = /* @__PURE__ */ new WeakMap(), ci = /* @__PURE__ */ new WeakMap(), ui = /* @__PURE__ */ new WeakMap(), li = /* @__PURE__ */ new WeakSet(), class {
2769
+ constructor(e2) {
2770
+ if ((function(e3, t2) {
2771
+ ot(e3, t2), t2.add(e3);
2772
+ })(this, li), it(this, ai, void 0), it(this, si, void 0), it(this, ci, void 0), it(this, ui, void 0), st(this, "mfa", void 0), at(ci, this, e2), e2.useMtls && !e2.customFetch) throw new di("mtls_without_custom_fetch_not_supported", "Using mTLS without a custom fetch implementation is not supported");
2773
+ this.mfa = new xi({ domain: rt(ci, this).domain, clientId: rt(ci, this).clientId, customFetch: rt(ci, this).customFetch });
2774
+ }
2775
+ async buildAuthorizationUrl(e2) {
2776
+ const { serverMetadata: t2 } = await tt(li, this, Ni).call(this);
2777
+ if (null != e2 && e2.pushedAuthorizationRequests && !t2.pushed_authorization_request_endpoint) throw new di("par_not_supported_error", "The Auth0 tenant does not have pushed authorization requests enabled. Learn how to enable it here: https://auth0.com/docs/get-started/applications/configure-par");
2778
+ try {
2779
+ return await tt(li, this, Ji).call(this, e2);
2780
+ } catch (e3) {
2781
+ throw new bi(e3);
2782
+ }
2783
+ }
2784
+ async buildLinkUserUrl(e2) {
2785
+ try {
2786
+ const t2 = await tt(li, this, Ji).call(this, { authorizationParams: ut(ut({}, e2.authorizationParams), {}, { requested_connection: e2.connection, requested_connection_scope: e2.connectionScope, scope: "openid link_account offline_access", id_token_hint: e2.idToken }) });
2787
+ return { linkUserUrl: t2.authorizationUrl, codeVerifier: t2.codeVerifier };
2788
+ } catch (e3) {
2789
+ throw new _i(e3);
2790
+ }
2791
+ }
2792
+ async buildUnlinkUserUrl(e2) {
2793
+ try {
2794
+ const t2 = await tt(li, this, Ji).call(this, { authorizationParams: ut(ut({}, e2.authorizationParams), {}, { requested_connection: e2.connection, scope: "openid unlink_account", id_token_hint: e2.idToken }) });
2795
+ return { unlinkUserUrl: t2.authorizationUrl, codeVerifier: t2.codeVerifier };
2796
+ } catch (e3) {
2797
+ throw new ki(e3);
2798
+ }
2799
+ }
2800
+ async backchannelAuthentication(e2) {
2801
+ const { configuration: t2, serverMetadata: n2 } = await tt(li, this, Ni).call(this), o2 = Ei(ut(ut({}, rt(ci, this).authorizationParams), null == e2 ? void 0 : e2.authorizationParams)), r2 = new URLSearchParams(ut(ut({ scope: ji }, o2), {}, { client_id: rt(ci, this).clientId, binding_message: e2.bindingMessage, login_hint: JSON.stringify({ format: "iss_sub", iss: n2.issuer, sub: e2.loginHint.sub }) }));
2802
+ e2.requestedExpiry && r2.append("requested_expiry", e2.requestedExpiry.toString()), e2.authorizationDetails && r2.append("authorization_details", JSON.stringify(e2.authorizationDetails));
2803
+ try {
2804
+ const e3 = await dr(t2, r2), n3 = await hr(t2, e3);
2805
+ return Ci.fromTokenEndpointResponse(n3);
2806
+ } catch (e3) {
2807
+ throw new vi(e3);
2808
+ }
2809
+ }
2810
+ async initiateBackchannelAuthentication(e2) {
2811
+ const { configuration: t2, serverMetadata: n2 } = await tt(li, this, Ni).call(this), o2 = Ei(ut(ut({}, rt(ci, this).authorizationParams), null == e2 ? void 0 : e2.authorizationParams)), r2 = new URLSearchParams(ut(ut({ scope: ji }, o2), {}, { client_id: rt(ci, this).clientId, binding_message: e2.bindingMessage, login_hint: JSON.stringify({ format: "iss_sub", iss: n2.issuer, sub: e2.loginHint.sub }) }));
2812
+ e2.requestedExpiry && r2.append("requested_expiry", e2.requestedExpiry.toString()), e2.authorizationDetails && r2.append("authorization_details", JSON.stringify(e2.authorizationDetails));
2813
+ try {
2814
+ const e3 = await dr(t2, r2);
2815
+ return { authReqId: e3.auth_req_id, expiresIn: e3.expires_in, interval: e3.interval };
2816
+ } catch (e3) {
2817
+ throw new vi(e3);
2818
+ }
2819
+ }
2820
+ async backchannelAuthenticationGrant(e2) {
2821
+ let { authReqId: t2 } = e2;
2822
+ const { configuration: n2 } = await tt(li, this, Ni).call(this), o2 = new URLSearchParams({ auth_req_id: t2 });
2823
+ try {
2824
+ const e3 = await Sr(n2, "urn:openid:params:grant-type:ciba", o2);
2825
+ return Ci.fromTokenEndpointResponse(e3);
2826
+ } catch (e3) {
2827
+ throw new vi(e3);
2828
+ }
2829
+ }
2830
+ async getTokenForConnection(e2) {
2831
+ var t2;
2832
+ if (e2.refreshToken && e2.accessToken) throw new yi("Either a refresh or access token should be specified, but not both.");
2833
+ const n2 = null !== (t2 = e2.accessToken) && void 0 !== t2 ? t2 : e2.refreshToken;
2834
+ if (!n2) throw new yi("Either a refresh or access token must be specified.");
2835
+ try {
2836
+ return await this.exchangeToken({ connection: e2.connection, subjectToken: n2, subjectTokenType: e2.accessToken ? "urn:ietf:params:oauth:token-type:access_token" : "urn:ietf:params:oauth:token-type:refresh_token", loginHint: e2.loginHint });
2837
+ } catch (e3) {
2838
+ if (e3 instanceof wi) throw new yi(e3.message, e3.cause);
2839
+ throw e3;
2840
+ }
2841
+ }
2842
+ async exchangeToken(e2) {
2843
+ return "connection" in e2 ? tt(li, this, Wi).call(this, e2) : tt(li, this, Hi).call(this, e2);
2844
+ }
2845
+ async getTokenByCode(e2, t2) {
2846
+ const { configuration: n2 } = await tt(li, this, Ni).call(this);
2847
+ try {
2848
+ const o2 = await fr(n2, e2, { pkceCodeVerifier: t2.codeVerifier });
2849
+ return Ci.fromTokenEndpointResponse(o2);
2850
+ } catch (e3) {
2851
+ throw new pi("There was an error while trying to request a token.", e3);
2852
+ }
2853
+ }
2854
+ async getTokenByRefreshToken(e2) {
2855
+ const { configuration: t2 } = await tt(li, this, Ni).call(this);
2856
+ try {
2857
+ const n2 = await mr(t2, e2.refreshToken);
2858
+ return Ci.fromTokenEndpointResponse(n2);
2859
+ } catch (e3) {
2860
+ throw new mi("The access token has expired and there was an error while trying to refresh it.", e3);
2861
+ }
2862
+ }
2863
+ async getTokenByClientCredentials(e2) {
2864
+ const { configuration: t2 } = await tt(li, this, Ni).call(this);
2865
+ try {
2866
+ const n2 = new URLSearchParams({ audience: e2.audience });
2867
+ e2.organization && n2.append("organization", e2.organization);
2868
+ const o2 = await yr(t2, n2);
2869
+ return Ci.fromTokenEndpointResponse(o2);
2870
+ } catch (e3) {
2871
+ throw new fi("There was an error while trying to request a token.", e3);
2872
+ }
2873
+ }
2874
+ async buildLogoutUrl(e2) {
2875
+ const { configuration: t2, serverMetadata: n2 } = await tt(li, this, Ni).call(this);
2876
+ if (!n2.end_session_endpoint) {
2877
+ const t3 = new URL("https://".concat(rt(ci, this).domain, "/v2/logout"));
2878
+ return t3.searchParams.set("returnTo", e2.returnTo), t3.searchParams.set("client_id", rt(ci, this).clientId), t3;
2879
+ }
2880
+ return (function(e3, t3) {
2881
+ vr(e3);
2882
+ const { as: n3, c: o2, tlsOnly: r2 } = Fo(e3), i2 = Qt(n3, "end_session_endpoint", false, r2);
2883
+ (t3 = new URLSearchParams(t3)).has("client_id") || t3.set("client_id", o2.client_id);
2884
+ for (const [e4, n4] of t3.entries()) i2.searchParams.append(e4, n4);
2885
+ return i2;
2886
+ })(t2, { post_logout_redirect_uri: e2.returnTo });
2887
+ }
2888
+ async verifyLogoutToken(e2) {
2889
+ const { serverMetadata: t2 } = await tt(li, this, Ni).call(this);
2890
+ rt(ui, this) || at(ui, this, (function(e3, t3) {
2891
+ const n3 = new ei(e3, t3), o2 = async (e4, t4) => n3.getKey(e4, t4);
2892
+ return Object.defineProperties(o2, { coolingDown: { get: () => n3.coolingDown(), enumerable: true, configurable: false }, fresh: { get: () => n3.fresh(), enumerable: true, configurable: false }, reload: { value: () => n3.reload(), enumerable: true, configurable: false, writable: false }, reloading: { get: () => n3.pendingFetch(), enumerable: true, configurable: false }, jwks: { value: () => n3.jwks(), enumerable: true, configurable: false, writable: false } }), o2;
2893
+ })(new URL(t2.jwks_uri), { [Jr]: rt(ci, this).customFetch }));
2894
+ const { payload: n2 } = await Cr(e2.logoutToken, rt(ui, this), { issuer: t2.issuer, audience: rt(ci, this).clientId, algorithms: ["RS256"], requiredClaims: ["iat"] });
2895
+ if (!("sid" in n2) && !("sub" in n2)) throw new gi('either "sid" or "sub" (or both) claims must be present');
2896
+ if ("sid" in n2 && "string" != typeof n2.sid) throw new gi('"sid" claim must be a string');
2897
+ if ("sub" in n2 && "string" != typeof n2.sub) throw new gi('"sub" claim must be a string');
2898
+ if ("nonce" in n2) throw new gi('"nonce" claim is prohibited');
2899
+ if (!("events" in n2)) throw new gi('"events" claim is missing');
2900
+ if ("object" != typeof n2.events || null === n2.events) throw new gi('"events" claim must be an object');
2901
+ if (!("http://schemas.openid.net/event/backchannel-logout" in n2.events)) throw new gi('"http://schemas.openid.net/event/backchannel-logout" member is missing in the "events" claim');
2902
+ if ("object" != typeof n2.events["http://schemas.openid.net/event/backchannel-logout"]) throw new gi('"http://schemas.openid.net/event/backchannel-logout" member in the "events" claim must be an object');
2903
+ return { sid: n2.sid, sub: n2.sub };
2904
+ }
2905
+ });
2906
+ async function Ni() {
2907
+ if (rt(ai, this) && rt(si, this)) return { configuration: rt(ai, this), serverMetadata: rt(si, this) };
2908
+ const e2 = await tt(li, this, zi).call(this);
2909
+ return at(ai, this, await ir(new URL("https://".concat(rt(ci, this).domain)), rt(ci, this).clientId, { use_mtls_endpoint_aliases: rt(ci, this).useMtls }, e2, { [Xo]: rt(ci, this).customFetch })), at(si, this, rt(ai, this).serverMetadata()), rt(ai, this)[Xo] = rt(ci, this).customFetch || fetch, { configuration: rt(ai, this), serverMetadata: rt(si, this) };
2910
+ }
2911
+ async function Wi(e2) {
2912
+ var t2, n2;
2913
+ const { configuration: o2 } = await tt(li, this, Ni).call(this);
2914
+ if ("audience" in e2 || "resource" in e2) throw new wi("audience and resource parameters are not supported for Token Vault exchanges");
2915
+ Ki(e2.subjectToken);
2916
+ const r2 = new URLSearchParams({ connection: e2.connection, subject_token: e2.subjectToken, subject_token_type: null !== (t2 = e2.subjectTokenType) && void 0 !== t2 ? t2 : "urn:ietf:params:oauth:token-type:access_token", requested_token_type: null !== (n2 = e2.requestedTokenType) && void 0 !== n2 ? n2 : "http://auth0.com/oauth/token-type/federated-connection-access-token" });
2917
+ e2.loginHint && r2.append("login_hint", e2.loginHint), e2.scope && r2.append("scope", e2.scope), Li(r2, e2.extra);
2918
+ try {
2919
+ const e3 = await Sr(o2, "urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token", r2);
2920
+ return Ci.fromTokenEndpointResponse(e3);
2921
+ } catch (t3) {
2922
+ throw new wi("Failed to exchange token for connection '".concat(e2.connection, "'."), t3);
2923
+ }
2924
+ }
2925
+ async function Hi(e2) {
2926
+ const { configuration: t2 } = await tt(li, this, Ni).call(this);
2927
+ Ki(e2.subjectToken);
2928
+ const n2 = new URLSearchParams({ subject_token_type: e2.subjectTokenType, subject_token: e2.subjectToken });
2929
+ e2.audience && n2.append("audience", e2.audience), e2.scope && n2.append("scope", e2.scope), e2.requestedTokenType && n2.append("requested_token_type", e2.requestedTokenType), e2.organization && n2.append("organization", e2.organization), Li(n2, e2.extra);
2930
+ try {
2931
+ const e3 = await Sr(t2, "urn:ietf:params:oauth:grant-type:token-exchange", n2);
2932
+ return Ci.fromTokenEndpointResponse(e3);
2933
+ } catch (t3) {
2934
+ throw new wi("Failed to exchange token of type '".concat(e2.subjectTokenType, "'").concat(e2.audience ? " for audience '".concat(e2.audience, "'") : "", "."), t3);
2935
+ }
2936
+ }
2937
+ async function zi() {
2938
+ if (!rt(ci, this).clientSecret && !rt(ci, this).clientAssertionSigningKey && !rt(ci, this).useMtls) throw new Si();
2939
+ if (rt(ci, this).useMtls) return (e3, t2, n2, o2) => {
2940
+ n2.set("client_id", t2.client_id);
2941
+ };
2942
+ let e2 = rt(ci, this).clientAssertionSigningKey;
2943
+ return !e2 || e2 instanceof CryptoKey || (e2 = await (async function(e3, t2, n2) {
2944
+ if ("string" != typeof e3 || 0 !== e3.indexOf("-----BEGIN PRIVATE KEY-----")) throw new TypeError('"pkcs8" must be PKCS#8 formatted string');
2945
+ return jo(e3, t2, n2);
2946
+ })(e2, rt(ci, this).clientAssertionSigningAlg || "RS256")), e2 ? (function(e3, t2) {
2947
+ return qt(e3, t2);
2948
+ })(e2) : Bo(rt(ci, this).clientSecret);
2949
+ }
2950
+ async function Ji(e2) {
2951
+ const { configuration: t2 } = await tt(li, this, Ni).call(this), n2 = tr(), o2 = await er(n2), r2 = Ei(ut(ut({}, rt(ci, this).authorizationParams), null == e2 ? void 0 : e2.authorizationParams)), i2 = new URLSearchParams(ut(ut({ scope: ji }, r2), {}, { client_id: rt(ci, this).clientId, code_challenge: o2, code_challenge_method: "S256" }));
2952
+ return { authorizationUrl: null != e2 && e2.pushedAuthorizationRequests ? await gr(t2, i2) : await wr(t2, i2), codeVerifier: n2 };
2953
+ }
2954
+ var Mi = new p();
2955
+ var initialAuthState = {
2956
+ isAuthenticated: false,
2957
+ isLoading: true,
2958
+ error: void 0,
2959
+ user: void 0
2960
+ };
2961
+ var stub = function() {
2962
+ throw new Error("You forgot to wrap your component in <Auth0Provider>.");
2963
+ };
2964
+ var initialContext = __assign(__assign({}, initialAuthState), { buildAuthorizeUrl: stub, buildLogoutUrl: stub, getAccessTokenSilently: stub, getAccessTokenWithPopup: stub, getIdTokenClaims: stub, exchangeToken: stub, loginWithRedirect: stub, loginWithPopup: stub, connectAccountWithRedirect: stub, logout: stub, handleRedirectCallback: stub, getDpopNonce: stub, setDpopNonce: stub, generateDpopProof: stub, createFetcher: stub, getConfiguration: stub });
2965
+ var Auth0Context = (0, import_react.createContext)(initialContext);
2966
+ var OAuthError = (
2967
+ /** @class */
2968
+ (function(_super) {
2969
+ __extends(OAuthError2, _super);
2970
+ function OAuthError2(error, error_description) {
2971
+ var _this = _super.call(this, error_description !== null && error_description !== void 0 ? error_description : error) || this;
2972
+ _this.error = error;
2973
+ _this.error_description = error_description;
2974
+ Object.setPrototypeOf(_this, OAuthError2.prototype);
2975
+ return _this;
2976
+ }
2977
+ return OAuthError2;
2978
+ })(Error)
2979
+ );
2980
+ var normalizeErrorFn = function(fallbackMessage) {
2981
+ return function(error) {
2982
+ if (error instanceof Error) {
2983
+ return error;
2984
+ }
2985
+ if (error !== null && typeof error === "object" && "error" in error && typeof error.error === "string") {
2986
+ if ("error_description" in error && typeof error.error_description === "string") {
2987
+ var e_1 = error;
2988
+ return new OAuthError(e_1.error, e_1.error_description);
2989
+ }
2990
+ var e2 = error;
2991
+ return new OAuthError(e2.error);
2992
+ }
2993
+ return new Error(fallbackMessage);
2994
+ };
2995
+ };
2996
+ var loginError = normalizeErrorFn("Login failed");
2997
+ var tokenError = normalizeErrorFn("Get access token failed");
2998
+ var useAuth0 = function(context) {
2999
+ if (context === void 0) {
3000
+ context = Auth0Context;
3001
+ }
3002
+ return (0, import_react.useContext)(context);
3003
+ };
3004
+
3005
+ // src/bridges/auth0/index.ts
3006
+ function useAuth0User() {
3007
+ const { user, isAuthenticated, isLoading, error } = useAuth0();
3008
+ return { user, isAuthenticated, isLoading, error };
3009
+ }
3010
+ // Annotate the CommonJS export names for ESM import in node:
3011
+ 0 && (module.exports = {
3012
+ useAuth0,
3013
+ useAuth0User
3014
+ });
3015
+ //# sourceMappingURL=auth0.js.map