@hexclave/dashboard-ui-components 1.0.99 → 1.0.100

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.
@@ -4050,236 +4050,6 @@ var DashboardUI = (() => {
4050
4050
  return Object.fromEntries(Object.entries(obj).filter(([k3]) => !keys.includes(k3)));
4051
4051
  }
4052
4052
 
4053
- // ../shared/dist/esm/utils/arrays.js
4054
- function findLastIndex(arr, predicate) {
4055
- for (let i = arr.length - 1; i >= 0; i--) if (predicate(arr[i])) return i;
4056
- return -1;
4057
- }
4058
- function unique(arr) {
4059
- return [...new Set(arr)];
4060
- }
4061
-
4062
- // ../shared/dist/esm/utils/strings.js
4063
- function stringCompare(a26, b) {
4064
- if (typeof a26 !== "string" || typeof b !== "string") throw new HexclaveAssertionError(`Expected two strings for stringCompare, found ${typeof a26} and ${typeof b}`, {
4065
- a: a26,
4066
- b
4067
- });
4068
- const cmp = (a27, b2) => a27 < b2 ? -1 : a27 > b2 ? 1 : 0;
4069
- return cmp(a26.toUpperCase(), b.toUpperCase()) || cmp(b, a26);
4070
- }
4071
- function getWhitespacePrefix(s8) {
4072
- return s8.substring(0, s8.length - s8.trimStart().length);
4073
- }
4074
- function trimEmptyLinesStart(s8) {
4075
- const lines = s8.split("\n");
4076
- const firstNonEmptyLineIndex = lines.findIndex((line) => line.trim() !== "");
4077
- if (firstNonEmptyLineIndex === -1) return "";
4078
- return lines.slice(firstNonEmptyLineIndex).join("\n");
4079
- }
4080
- function trimEmptyLinesEnd(s8) {
4081
- const lines = s8.split("\n");
4082
- const lastNonEmptyLineIndex = findLastIndex(lines, (line) => line.trim() !== "");
4083
- return lines.slice(0, lastNonEmptyLineIndex + 1).join("\n");
4084
- }
4085
- function templateIdentity(strings, ...values) {
4086
- if (values.length !== strings.length - 1) throw new HexclaveAssertionError("Invalid number of values; must be one less than strings", {
4087
- strings,
4088
- values
4089
- });
4090
- return strings.reduce((result, str, i) => result + str + (values[i] ?? ""), "");
4091
- }
4092
- function deindent(strings, ...values) {
4093
- if (typeof strings === "string") return deindent([strings]);
4094
- return templateIdentity(...deindentTemplate(strings, ...values));
4095
- }
4096
- function deindentTemplate(strings, ...values) {
4097
- if (values.length !== strings.length - 1) throw new HexclaveAssertionError("Invalid number of values; must be one less than strings", {
4098
- strings,
4099
- values
4100
- });
4101
- const trimmedStrings = [...strings];
4102
- trimmedStrings[0] = trimEmptyLinesStart(trimmedStrings[0] + "+").slice(0, -1);
4103
- trimmedStrings[trimmedStrings.length - 1] = trimEmptyLinesEnd("+" + trimmedStrings[trimmedStrings.length - 1]).slice(1);
4104
- const indentation = trimmedStrings.join("${SOME_VALUE}").split("\n").filter((line) => line.trim() !== "").map((line) => getWhitespacePrefix(line).length).reduce((min4, current) => Math.min(min4, current), Infinity);
4105
- const deindentedStrings = trimmedStrings.map((string2, stringIndex) => {
4106
- return string2.split("\n").map((line, lineIndex) => stringIndex !== 0 && lineIndex === 0 ? line : line.substring(indentation)).join("\n");
4107
- });
4108
- return [deindentedStrings, ...values.map((value, i) => {
4109
- const firstLineIndentation = getWhitespacePrefix(deindentedStrings[i].split("\n").at(-1));
4110
- return `${value}`.replaceAll("\n", `
4111
- ${firstLineIndentation}`);
4112
- })];
4113
- }
4114
- function escapeTemplateLiteral(s8) {
4115
- return s8.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${");
4116
- }
4117
- var nicifiableClassNameOverrides = new Map(Object.entries({ Headers }).map(([k3, v]) => [v, k3]));
4118
- function nicify(value, options = {}) {
4119
- const fullOptions = {
4120
- maxDepth: 5,
4121
- currentIndent: "",
4122
- lineIndent: " ",
4123
- multiline: true,
4124
- refs: /* @__PURE__ */ new Map(),
4125
- path: "value",
4126
- parent: null,
4127
- overrides: () => null,
4128
- keyInParent: null,
4129
- hideFields: [],
4130
- ...filterUndefined(options)
4131
- };
4132
- const { maxDepth, currentIndent, lineIndent, multiline, refs, path, overrides, hideFields } = fullOptions;
4133
- const nl = `
4134
- ${currentIndent}`;
4135
- const overrideResult = overrides(value, options);
4136
- if (overrideResult !== null) return overrideResult;
4137
- if ([
4138
- "function",
4139
- "object",
4140
- "symbol"
4141
- ].includes(typeof value) && value !== null) {
4142
- if (refs.has(value)) return `Ref<${refs.get(value)}>`;
4143
- refs.set(value, path);
4144
- }
4145
- const newOptions = {
4146
- maxDepth: maxDepth - 1,
4147
- currentIndent,
4148
- lineIndent,
4149
- multiline,
4150
- refs,
4151
- path: path + "->[unknown property]",
4152
- overrides,
4153
- parent: {
4154
- value,
4155
- options: fullOptions
4156
- },
4157
- keyInParent: null,
4158
- hideFields: []
4159
- };
4160
- const nestedNicify = (newValue, newPath, keyInParent, options2 = {}) => {
4161
- return nicify(newValue, {
4162
- ...newOptions,
4163
- path: newPath,
4164
- currentIndent: currentIndent + lineIndent,
4165
- keyInParent,
4166
- ...options2
4167
- });
4168
- };
4169
- switch (typeof value) {
4170
- case "boolean":
4171
- case "number":
4172
- return JSON.stringify(value);
4173
- case "string": {
4174
- const isDeindentable = (v) => deindent(v) === v && v.includes("\n");
4175
- const wrapInDeindent = (v) => deindent`
4176
- deindent\`
4177
- ${currentIndent + lineIndent}${escapeTemplateLiteral(v).replaceAll("\n", nl + lineIndent)}
4178
- ${currentIndent}\`
4179
- `;
4180
- if (isDeindentable(value)) return wrapInDeindent(value);
4181
- else if (value.endsWith("\n") && isDeindentable(value.slice(0, -1))) return wrapInDeindent(value.slice(0, -1)) + ' + "\\n"';
4182
- else return JSON.stringify(value);
4183
- }
4184
- case "undefined":
4185
- return "undefined";
4186
- case "symbol":
4187
- return value.toString();
4188
- case "bigint":
4189
- return `${value}n`;
4190
- case "function":
4191
- if (value.name) return `function ${value.name}(...) { ... }`;
4192
- return `(...) => { ... }`;
4193
- case "object": {
4194
- if (value === null) return "null";
4195
- if (Array.isArray(value)) {
4196
- const extraLines2 = getNicifiedObjectExtraLines(value);
4197
- const resValueLength2 = value.length + extraLines2.length;
4198
- if (resValueLength2 === 0) return "[]";
4199
- if (maxDepth <= 0) return `[...]`;
4200
- const resValues2 = value.map((v, i) => nestedNicify(v, `${path}[${i}]`, i));
4201
- resValues2.push(...extraLines2);
4202
- if (resValues2.length !== resValueLength2) throw new HexclaveAssertionError("nicify of object: resValues.length !== resValueLength", {
4203
- value,
4204
- resValues: resValues2,
4205
- resValueLength: resValueLength2
4206
- });
4207
- if (resValues2.length > 4 || resValues2.some((x) => resValues2.length > 1 && x.length > 4 || x.includes("\n"))) return `[${nl}${resValues2.map((x) => `${lineIndent}${x},${nl}`).join("")}]`;
4208
- else return `[${resValues2.join(", ")}]`;
4209
- }
4210
- if (value instanceof Date) return `Date(${nestedNicify(value.toISOString(), `${path}.toISOString()`, null)})`;
4211
- if (value instanceof URL) return `URL(${nestedNicify(value.toString(), `${path}.toString()`, null)})`;
4212
- if (ArrayBuffer.isView(value)) return `${value.constructor.name}([${value.toString()}])`;
4213
- if (value instanceof ArrayBuffer) return `ArrayBuffer [${new Uint8Array(value).toString()}]`;
4214
- if (value instanceof Error) {
4215
- let stack = value.stack ?? "";
4216
- const toString3 = value.toString();
4217
- if (!stack.startsWith(toString3)) stack = `${toString3}
4218
- ${stack}`;
4219
- stack = stack.trimEnd();
4220
- stack = stack.replace(/\n\s+/g, `
4221
- ${lineIndent}${lineIndent}`);
4222
- stack = stack.replace("\n", `
4223
- ${lineIndent}Stack:
4224
- `);
4225
- if (Object.keys(value).length > 0) stack += `
4226
- ${lineIndent}Extra properties: ${nestedNicify(Object.fromEntries(Object.entries(value)), path, null)}`;
4227
- if (value.cause) stack += `
4228
- ${lineIndent}Cause:
4229
- ${lineIndent}${lineIndent}${nestedNicify(value.cause, path, null, { currentIndent: currentIndent + lineIndent + lineIndent })}`;
4230
- stack = stack.replaceAll("\n", `
4231
- ${currentIndent}`);
4232
- return stack;
4233
- }
4234
- const constructorName = [null, Object.prototype].includes(Object.getPrototypeOf(value)) ? null : nicifiableClassNameOverrides.get(value.constructor) ?? value.constructor.name;
4235
- const constructorString = constructorName ? `${constructorName} ` : "";
4236
- const entries = getNicifiableEntries(value).filter(([k3]) => !hideFields.includes(k3));
4237
- const extraLines = [...getNicifiedObjectExtraLines(value), ...hideFields.length > 0 ? [`<some fields may have been hidden>`] : []];
4238
- const resValueLength = entries.length + extraLines.length;
4239
- if (resValueLength === 0) return `${constructorString}{}`;
4240
- if (maxDepth <= 0) return `${constructorString}{ ... }`;
4241
- const resValues = entries.map(([k3, v], keyIndex) => {
4242
- const keyNicified = nestedNicify(k3, `Object.keys(${path})[${keyIndex}]`, null);
4243
- const keyInObjectLiteral = typeof k3 === "string" ? nicifyPropertyString(k3) : `[${keyNicified}]`;
4244
- if (typeof v === "function" && v.name === k3) return `${keyInObjectLiteral}(...): { ... }`;
4245
- else return `${keyInObjectLiteral}: ${nestedNicify(v, `${path}[${keyNicified}]`, k3)}`;
4246
- });
4247
- resValues.push(...extraLines);
4248
- if (resValues.length !== resValueLength) throw new HexclaveAssertionError("nicify of object: resValues.length !== resValueLength", {
4249
- value,
4250
- resValues,
4251
- resValueLength
4252
- });
4253
- const shouldIndent = resValues.length > 1 || resValues.some((x) => x.includes("\n"));
4254
- if (resValues.length === 0) return `${constructorString}{}`;
4255
- if (shouldIndent) return `${constructorString}{${nl}${resValues.map((x) => `${lineIndent}${x},${nl}`).join("")}}`;
4256
- else return `${constructorString}{ ${resValues.join(", ")} }`;
4257
- }
4258
- default:
4259
- return `${typeof value}<${value}>`;
4260
- }
4261
- }
4262
- function nicifyPropertyString(str) {
4263
- return JSON.stringify(str);
4264
- }
4265
- function getNicifiableKeys(value) {
4266
- const overridden = ("getNicifiableKeys" in value ? value.getNicifiableKeys?.bind(value) : null)?.();
4267
- if (overridden != null) return overridden;
4268
- if (value instanceof Response) return ["status", "headers"];
4269
- return unique(Object.keys(value).sort());
4270
- }
4271
- function getNicifiableEntries(value) {
4272
- const recordLikes = [Headers];
4273
- function isRecordLike(value2) {
4274
- return recordLikes.some((x) => value2 instanceof x);
4275
- }
4276
- if (isRecordLike(value)) return [...value.entries()].sort(([a26], [b]) => stringCompare(`${a26}`, `${b}`));
4277
- return getNicifiableKeys(value).map((k3) => [k3, value[k3]]);
4278
- }
4279
- function getNicifiedObjectExtraLines(value) {
4280
- return ("getNicifiedObjectExtraLines" in value ? value.getNicifiedObjectExtraLines : null)?.() ?? [];
4281
- }
4282
-
4283
4053
  // ../shared/dist/esm/utils/globals.js
4284
4054
  var globalVar = typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {};
4285
4055
  if (typeof globalThis === "undefined") globalVar.globalThis = globalVar;
@@ -4554,29 +4324,238 @@ This is likely an error in Hexclave. Please make sure you are running the newest
4554
4324
  }, _a);
4555
4325
  StatusError.prototype.name = "StatusError";
4556
4326
 
4557
- // ../shared/dist/esm/utils/env.js
4558
- function resolveHexclaveStackEnvVarValue(hexclaveName, stackName, hexclaveValue, stackValue) {
4559
- if (hexclaveValue && stackValue && hexclaveValue !== stackValue) throw new Error(`Environment variables ${hexclaveName} and ${stackName} are both set to different values. Remove one of them or set them to the same value.`);
4560
- return hexclaveValue || stackValue || void 0;
4561
- }
4562
- function getEnvVarWithHexclaveFallback(name) {
4563
- if (name.includes("STACK_")) {
4564
- const hexclaveName = name.replace("STACK_", "HEXCLAVE_");
4565
- return resolveHexclaveStackEnvVarValue(hexclaveName, name, process.env[hexclaveName], process.env[name]);
4566
- }
4567
- if (name.includes("HEXCLAVE_")) {
4568
- const stackName = name.replace("HEXCLAVE_", "STACK_");
4569
- return resolveHexclaveStackEnvVarValue(name, stackName, process.env[name], process.env[stackName]);
4570
- }
4571
- return process.env[name];
4327
+ // ../shared/dist/esm/utils/arrays.js
4328
+ function findLastIndex(arr, predicate) {
4329
+ for (let i = arr.length - 1; i >= 0; i--) if (predicate(arr[i])) return i;
4330
+ return -1;
4572
4331
  }
4573
- function getProcessEnv(name) {
4574
- if (typeof process === "undefined" || typeof process.env === "undefined") return;
4575
- return getEnvVarWithHexclaveFallback(name);
4332
+ function unique(arr) {
4333
+ return [...new Set(arr)];
4576
4334
  }
4577
4335
 
4578
- // ../shared/dist/esm/utils/results.js
4579
- var Result = {
4336
+ // ../shared/dist/esm/utils/strings.js
4337
+ function stringCompare(a26, b) {
4338
+ if (typeof a26 !== "string" || typeof b !== "string") throw new HexclaveAssertionError(`Expected two strings for stringCompare, found ${typeof a26} and ${typeof b}`, {
4339
+ a: a26,
4340
+ b
4341
+ });
4342
+ const cmp = (a27, b2) => a27 < b2 ? -1 : a27 > b2 ? 1 : 0;
4343
+ return cmp(a26.toUpperCase(), b.toUpperCase()) || cmp(b, a26);
4344
+ }
4345
+ function getWhitespacePrefix(s8) {
4346
+ return s8.substring(0, s8.length - s8.trimStart().length);
4347
+ }
4348
+ function trimEmptyLinesStart(s8) {
4349
+ const lines = s8.split("\n");
4350
+ const firstNonEmptyLineIndex = lines.findIndex((line) => line.trim() !== "");
4351
+ if (firstNonEmptyLineIndex === -1) return "";
4352
+ return lines.slice(firstNonEmptyLineIndex).join("\n");
4353
+ }
4354
+ function trimEmptyLinesEnd(s8) {
4355
+ const lines = s8.split("\n");
4356
+ const lastNonEmptyLineIndex = findLastIndex(lines, (line) => line.trim() !== "");
4357
+ return lines.slice(0, lastNonEmptyLineIndex + 1).join("\n");
4358
+ }
4359
+ function templateIdentity(strings, ...values) {
4360
+ if (values.length !== strings.length - 1) throw new HexclaveAssertionError("Invalid number of values; must be one less than strings", {
4361
+ strings,
4362
+ values
4363
+ });
4364
+ return strings.reduce((result, str, i) => result + str + (values[i] ?? ""), "");
4365
+ }
4366
+ function deindent(strings, ...values) {
4367
+ if (typeof strings === "string") return deindent([strings]);
4368
+ return templateIdentity(...deindentTemplate(strings, ...values));
4369
+ }
4370
+ function deindentTemplate(strings, ...values) {
4371
+ if (values.length !== strings.length - 1) throw new HexclaveAssertionError("Invalid number of values; must be one less than strings", {
4372
+ strings,
4373
+ values
4374
+ });
4375
+ const trimmedStrings = [...strings];
4376
+ trimmedStrings[0] = trimEmptyLinesStart(trimmedStrings[0] + "+").slice(0, -1);
4377
+ trimmedStrings[trimmedStrings.length - 1] = trimEmptyLinesEnd("+" + trimmedStrings[trimmedStrings.length - 1]).slice(1);
4378
+ const indentation = trimmedStrings.join("${SOME_VALUE}").split("\n").filter((line) => line.trim() !== "").map((line) => getWhitespacePrefix(line).length).reduce((min4, current) => Math.min(min4, current), Infinity);
4379
+ const deindentedStrings = trimmedStrings.map((string2, stringIndex) => {
4380
+ return string2.split("\n").map((line, lineIndex) => stringIndex !== 0 && lineIndex === 0 ? line : line.substring(indentation)).join("\n");
4381
+ });
4382
+ return [deindentedStrings, ...values.map((value, i) => {
4383
+ const firstLineIndentation = getWhitespacePrefix(deindentedStrings[i].split("\n").at(-1));
4384
+ return `${value}`.replaceAll("\n", `
4385
+ ${firstLineIndentation}`);
4386
+ })];
4387
+ }
4388
+ function escapeTemplateLiteral(s8) {
4389
+ return s8.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${");
4390
+ }
4391
+ var nicifiableClassNameOverrides = new Map(Object.entries({ Headers }).map(([k3, v]) => [v, k3]));
4392
+ function nicify(value, options = {}) {
4393
+ const fullOptions = {
4394
+ maxDepth: 5,
4395
+ currentIndent: "",
4396
+ lineIndent: " ",
4397
+ multiline: true,
4398
+ refs: /* @__PURE__ */ new Map(),
4399
+ path: "value",
4400
+ parent: null,
4401
+ overrides: () => null,
4402
+ keyInParent: null,
4403
+ hideFields: [],
4404
+ ...filterUndefined(options)
4405
+ };
4406
+ const { maxDepth, currentIndent, lineIndent, multiline, refs, path, overrides, hideFields } = fullOptions;
4407
+ const nl = `
4408
+ ${currentIndent}`;
4409
+ const overrideResult = overrides(value, options);
4410
+ if (overrideResult !== null) return overrideResult;
4411
+ if ([
4412
+ "function",
4413
+ "object",
4414
+ "symbol"
4415
+ ].includes(typeof value) && value !== null) {
4416
+ if (refs.has(value)) return `Ref<${refs.get(value)}>`;
4417
+ refs.set(value, path);
4418
+ }
4419
+ const newOptions = {
4420
+ maxDepth: maxDepth - 1,
4421
+ currentIndent,
4422
+ lineIndent,
4423
+ multiline,
4424
+ refs,
4425
+ path: path + "->[unknown property]",
4426
+ overrides,
4427
+ parent: {
4428
+ value,
4429
+ options: fullOptions
4430
+ },
4431
+ keyInParent: null,
4432
+ hideFields: []
4433
+ };
4434
+ const nestedNicify = (newValue, newPath, keyInParent, options2 = {}) => {
4435
+ return nicify(newValue, {
4436
+ ...newOptions,
4437
+ path: newPath,
4438
+ currentIndent: currentIndent + lineIndent,
4439
+ keyInParent,
4440
+ ...options2
4441
+ });
4442
+ };
4443
+ switch (typeof value) {
4444
+ case "boolean":
4445
+ case "number":
4446
+ return JSON.stringify(value);
4447
+ case "string": {
4448
+ const isDeindentable = (v) => deindent(v) === v && v.includes("\n");
4449
+ const wrapInDeindent = (v) => deindent`
4450
+ deindent\`
4451
+ ${currentIndent + lineIndent}${escapeTemplateLiteral(v).replaceAll("\n", nl + lineIndent)}
4452
+ ${currentIndent}\`
4453
+ `;
4454
+ if (isDeindentable(value)) return wrapInDeindent(value);
4455
+ else if (value.endsWith("\n") && isDeindentable(value.slice(0, -1))) return wrapInDeindent(value.slice(0, -1)) + ' + "\\n"';
4456
+ else return JSON.stringify(value);
4457
+ }
4458
+ case "undefined":
4459
+ return "undefined";
4460
+ case "symbol":
4461
+ return value.toString();
4462
+ case "bigint":
4463
+ return `${value}n`;
4464
+ case "function":
4465
+ if (value.name) return `function ${value.name}(...) { ... }`;
4466
+ return `(...) => { ... }`;
4467
+ case "object": {
4468
+ if (value === null) return "null";
4469
+ if (Array.isArray(value)) {
4470
+ const extraLines2 = getNicifiedObjectExtraLines(value);
4471
+ const resValueLength2 = value.length + extraLines2.length;
4472
+ if (resValueLength2 === 0) return "[]";
4473
+ if (maxDepth <= 0) return `[...]`;
4474
+ const resValues2 = value.map((v, i) => nestedNicify(v, `${path}[${i}]`, i));
4475
+ resValues2.push(...extraLines2);
4476
+ if (resValues2.length !== resValueLength2) throw new HexclaveAssertionError("nicify of object: resValues.length !== resValueLength", {
4477
+ value,
4478
+ resValues: resValues2,
4479
+ resValueLength: resValueLength2
4480
+ });
4481
+ if (resValues2.length > 4 || resValues2.some((x) => resValues2.length > 1 && x.length > 4 || x.includes("\n"))) return `[${nl}${resValues2.map((x) => `${lineIndent}${x},${nl}`).join("")}]`;
4482
+ else return `[${resValues2.join(", ")}]`;
4483
+ }
4484
+ if (value instanceof Date) return `Date(${nestedNicify(value.toISOString(), `${path}.toISOString()`, null)})`;
4485
+ if (value instanceof URL) return `URL(${nestedNicify(value.toString(), `${path}.toString()`, null)})`;
4486
+ if (ArrayBuffer.isView(value)) return `${value.constructor.name}([${value.toString()}])`;
4487
+ if (value instanceof ArrayBuffer) return `ArrayBuffer [${new Uint8Array(value).toString()}]`;
4488
+ if (value instanceof Error) {
4489
+ let stack = value.stack ?? "";
4490
+ const toString3 = value.toString();
4491
+ if (!stack.startsWith(toString3)) stack = `${toString3}
4492
+ ${stack}`;
4493
+ stack = stack.trimEnd();
4494
+ stack = stack.replace(/\n\s+/g, `
4495
+ ${lineIndent}${lineIndent}`);
4496
+ stack = stack.replace("\n", `
4497
+ ${lineIndent}Stack:
4498
+ `);
4499
+ if (Object.keys(value).length > 0) stack += `
4500
+ ${lineIndent}Extra properties: ${nestedNicify(Object.fromEntries(Object.entries(value)), path, null)}`;
4501
+ if (value.cause) stack += `
4502
+ ${lineIndent}Cause:
4503
+ ${lineIndent}${lineIndent}${nestedNicify(value.cause, path, null, { currentIndent: currentIndent + lineIndent + lineIndent })}`;
4504
+ stack = stack.replaceAll("\n", `
4505
+ ${currentIndent}`);
4506
+ return stack;
4507
+ }
4508
+ const constructorName = [null, Object.prototype].includes(Object.getPrototypeOf(value)) ? null : nicifiableClassNameOverrides.get(value.constructor) ?? value.constructor.name;
4509
+ const constructorString = constructorName ? `${constructorName} ` : "";
4510
+ const entries = getNicifiableEntries(value).filter(([k3]) => !hideFields.includes(k3));
4511
+ const extraLines = [...getNicifiedObjectExtraLines(value), ...hideFields.length > 0 ? [`<some fields may have been hidden>`] : []];
4512
+ const resValueLength = entries.length + extraLines.length;
4513
+ if (resValueLength === 0) return `${constructorString}{}`;
4514
+ if (maxDepth <= 0) return `${constructorString}{ ... }`;
4515
+ const resValues = entries.map(([k3, v], keyIndex) => {
4516
+ const keyNicified = nestedNicify(k3, `Object.keys(${path})[${keyIndex}]`, null);
4517
+ const keyInObjectLiteral = typeof k3 === "string" ? nicifyPropertyString(k3) : `[${keyNicified}]`;
4518
+ if (typeof v === "function" && v.name === k3) return `${keyInObjectLiteral}(...): { ... }`;
4519
+ else return `${keyInObjectLiteral}: ${nestedNicify(v, `${path}[${keyNicified}]`, k3)}`;
4520
+ });
4521
+ resValues.push(...extraLines);
4522
+ if (resValues.length !== resValueLength) throw new HexclaveAssertionError("nicify of object: resValues.length !== resValueLength", {
4523
+ value,
4524
+ resValues,
4525
+ resValueLength
4526
+ });
4527
+ const shouldIndent = resValues.length > 1 || resValues.some((x) => x.includes("\n"));
4528
+ if (resValues.length === 0) return `${constructorString}{}`;
4529
+ if (shouldIndent) return `${constructorString}{${nl}${resValues.map((x) => `${lineIndent}${x},${nl}`).join("")}}`;
4530
+ else return `${constructorString}{ ${resValues.join(", ")} }`;
4531
+ }
4532
+ default:
4533
+ return `${typeof value}<${value}>`;
4534
+ }
4535
+ }
4536
+ function nicifyPropertyString(str) {
4537
+ return JSON.stringify(str);
4538
+ }
4539
+ function getNicifiableKeys(value) {
4540
+ const overridden = ("getNicifiableKeys" in value ? value.getNicifiableKeys?.bind(value) : null)?.();
4541
+ if (overridden != null) return overridden;
4542
+ if (value instanceof Response) return ["status", "headers"];
4543
+ return unique(Object.keys(value).sort());
4544
+ }
4545
+ function getNicifiableEntries(value) {
4546
+ const recordLikes = [Headers];
4547
+ function isRecordLike(value2) {
4548
+ return recordLikes.some((x) => value2 instanceof x);
4549
+ }
4550
+ if (isRecordLike(value)) return [...value.entries()].sort(([a26], [b]) => stringCompare(`${a26}`, `${b}`));
4551
+ return getNicifiableKeys(value).map((k3) => [k3, value[k3]]);
4552
+ }
4553
+ function getNicifiedObjectExtraLines(value) {
4554
+ return ("getNicifiedObjectExtraLines" in value ? value.getNicifiedObjectExtraLines : null)?.() ?? [];
4555
+ }
4556
+
4557
+ // ../shared/dist/esm/utils/results.js
4558
+ var Result = {
4580
4559
  fromThrowing,
4581
4560
  fromThrowingAsync,
4582
4561
  fromPromise: promiseToResult,
@@ -4697,1326 +4676,448 @@ This is likely an error in Hexclave. Please make sure you are running the newest
4697
4676
  return Object.assign(Result.error(new RetryError(errors)), { attempts: totalAttempts });
4698
4677
  }
4699
4678
 
4700
- // ../shared/dist/esm/utils/maps.js
4701
- var _Symbol$toStringTag;
4702
- var _Symbol$toStringTag2;
4703
- var _Symbol$toStringTag3;
4704
- var WeakRefIfAvailable = class {
4705
- constructor(value) {
4706
- if (typeof WeakRef === "undefined") this._ref = { deref: () => value };
4707
- else this._ref = new WeakRef(value);
4708
- }
4709
- deref() {
4710
- return this._ref.deref();
4679
+ // ../shared/dist/esm/utils/bytes.js
4680
+ function decodeBase64(input) {
4681
+ return new Uint8Array(atob(input).split("").map((char) => char.charCodeAt(0)));
4682
+ }
4683
+ function isBase64(input) {
4684
+ return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(input);
4685
+ }
4686
+
4687
+ // ../shared/dist/esm/utils/urls.js
4688
+ function createUrlIfValid(...args) {
4689
+ try {
4690
+ return new URL(...args);
4691
+ } catch (e40) {
4692
+ return null;
4711
4693
  }
4712
- };
4713
- var _a2;
4714
- var IterableWeakMap = (_a2 = class {
4715
- constructor(entries) {
4716
- this[_Symbol$toStringTag] = "IterableWeakMap";
4717
- const mappedEntries = entries?.map((e40) => [e40[0], {
4718
- value: e40[1],
4719
- keyRef: new WeakRefIfAvailable(e40[0])
4720
- }]);
4721
- this._weakMap = new WeakMap(mappedEntries ?? []);
4722
- this._keyRefs = new Set(mappedEntries?.map((e40) => e40[1].keyRef) ?? []);
4723
- }
4724
- get(key) {
4725
- return this._weakMap.get(key)?.value;
4726
- }
4727
- set(key, value) {
4728
- const updated = {
4729
- value,
4730
- keyRef: this._weakMap.get(key)?.keyRef ?? new WeakRefIfAvailable(key)
4731
- };
4732
- this._weakMap.set(key, updated);
4733
- this._keyRefs.add(updated.keyRef);
4734
- return this;
4735
- }
4736
- delete(key) {
4737
- const res = this._weakMap.get(key);
4738
- if (res) {
4739
- this._weakMap.delete(key);
4740
- this._keyRefs.delete(res.keyRef);
4741
- return true;
4742
- }
4743
- return false;
4744
- }
4745
- has(key) {
4746
- return this._weakMap.has(key) && this._keyRefs.has(this._weakMap.get(key).keyRef);
4747
- }
4748
- *[Symbol.iterator]() {
4749
- for (const keyRef of this._keyRefs) {
4750
- const key = keyRef.deref();
4751
- const existing = key ? this._weakMap.get(key) : void 0;
4752
- if (!key) this._keyRefs.delete(keyRef);
4753
- else if (existing) yield [key, existing.value];
4754
- }
4755
- }
4756
- }, _Symbol$toStringTag = Symbol.toStringTag, _a2);
4757
- var _a3;
4758
- var MaybeWeakMap = (_a3 = class {
4759
- constructor(entries) {
4760
- this[_Symbol$toStringTag2] = "MaybeWeakMap";
4761
- const entriesArray = [...entries ?? []];
4762
- this._primitiveMap = new Map(entriesArray.filter((e40) => !this._isAllowedInWeakMap(e40[0])));
4763
- this._weakMap = new IterableWeakMap(entriesArray.filter((e40) => this._isAllowedInWeakMap(e40[0])));
4764
- }
4765
- _isAllowedInWeakMap(key) {
4766
- return typeof key === "object" && key !== null || typeof key === "symbol" && Symbol.keyFor(key) === void 0;
4767
- }
4768
- get(key) {
4769
- if (this._isAllowedInWeakMap(key)) return this._weakMap.get(key);
4770
- else return this._primitiveMap.get(key);
4771
- }
4772
- set(key, value) {
4773
- if (this._isAllowedInWeakMap(key)) this._weakMap.set(key, value);
4774
- else this._primitiveMap.set(key, value);
4775
- return this;
4776
- }
4777
- delete(key) {
4778
- if (this._isAllowedInWeakMap(key)) return this._weakMap.delete(key);
4779
- else return this._primitiveMap.delete(key);
4780
- }
4781
- has(key) {
4782
- if (this._isAllowedInWeakMap(key)) return this._weakMap.has(key);
4783
- else return this._primitiveMap.has(key);
4784
- }
4785
- *[Symbol.iterator]() {
4786
- yield* this._primitiveMap;
4787
- yield* this._weakMap;
4788
- }
4789
- }, _Symbol$toStringTag2 = Symbol.toStringTag, _a3);
4790
- var _a4;
4791
- var DependenciesMap = (_a4 = class {
4792
- constructor() {
4793
- this._inner = {
4794
- map: new MaybeWeakMap(),
4795
- hasValue: false,
4796
- value: void 0
4797
- };
4798
- this[_Symbol$toStringTag3] = "DependenciesMap";
4799
- }
4800
- _valueToResult(inner) {
4801
- if (inner.hasValue) return Result.ok(inner.value);
4802
- else return Result.error(void 0);
4803
- }
4804
- _unwrapFromInner(dependencies, inner) {
4805
- if (dependencies.length === 0) return this._valueToResult(inner);
4806
- else {
4807
- const [key, ...rest] = dependencies;
4808
- const newInner = inner.map.get(key);
4809
- if (!newInner) return Result.error(void 0);
4810
- return this._unwrapFromInner(rest, newInner);
4811
- }
4812
- }
4813
- _setInInner(dependencies, value, inner) {
4814
- if (dependencies.length === 0) {
4815
- const res = this._valueToResult(inner);
4816
- if (value.status === "ok") {
4817
- inner.hasValue = true;
4818
- inner.value = value.data;
4819
- } else {
4820
- inner.hasValue = false;
4821
- inner.value = void 0;
4822
- }
4823
- return res;
4824
- } else {
4825
- const [key, ...rest] = dependencies;
4826
- let newInner = inner.map.get(key);
4827
- if (!newInner) inner.map.set(key, newInner = {
4828
- map: new MaybeWeakMap(),
4829
- hasValue: false,
4830
- value: void 0
4831
- });
4832
- return this._setInInner(rest, value, newInner);
4833
- }
4834
- }
4835
- *_iterateInner(dependencies, inner) {
4836
- if (inner.hasValue) yield [dependencies, inner.value];
4837
- for (const [key, value] of inner.map) yield* this._iterateInner([...dependencies, key], value);
4838
- }
4839
- get(dependencies) {
4840
- return Result.or(this._unwrapFromInner(dependencies, this._inner), void 0);
4694
+ }
4695
+ function isValidUrl(url) {
4696
+ return !!createUrlIfValid(url);
4697
+ }
4698
+ function isValidHostname(hostname) {
4699
+ if (!hostname || hostname.startsWith(".") || hostname.endsWith(".") || hostname.includes("..")) return false;
4700
+ const url = createUrlIfValid(`https://${hostname}`);
4701
+ if (!url) return false;
4702
+ return url.hostname === hostname;
4703
+ }
4704
+ function isValidHostnameWithWildcards(hostname) {
4705
+ if (!hostname) return false;
4706
+ if (!hostname.includes("*")) return isValidHostname(hostname);
4707
+ if (hostname.startsWith(".") || hostname.endsWith(".")) return false;
4708
+ if (hostname.includes("..")) return false;
4709
+ const testHostname = hostname.replace(/\*+/g, "wildcard");
4710
+ if (!/^[a-zA-Z0-9.-]+$/.test(testHostname)) return false;
4711
+ const segments = hostname.split(/\*+/);
4712
+ for (let i = 0; i < segments.length; i++) {
4713
+ const segment = segments[i];
4714
+ if (segment === "") continue;
4715
+ if (i === 0 && segment.startsWith(".")) return false;
4716
+ if (i === segments.length - 1 && segment.endsWith(".")) return false;
4717
+ if (segment.includes("..")) return false;
4841
4718
  }
4842
- set(dependencies, value) {
4843
- this._setInInner(dependencies, Result.ok(value), this._inner);
4844
- return this;
4719
+ return true;
4720
+ }
4721
+
4722
+ // ../shared/dist/esm/known-errors.js
4723
+ var KnownError = class extends StatusError {
4724
+ constructor(statusCode, humanReadableMessage, details) {
4725
+ super(statusCode, humanReadableMessage);
4726
+ this.statusCode = statusCode;
4727
+ this.humanReadableMessage = humanReadableMessage;
4728
+ this.details = details;
4729
+ this.__stackKnownErrorBrand = "stack-known-error-brand-sentinel";
4730
+ this.name = "KnownError";
4845
4731
  }
4846
- delete(dependencies) {
4847
- return this._setInInner(dependencies, Result.error(void 0), this._inner).status === "ok";
4732
+ static isKnownError(error) {
4733
+ return typeof error === "object" && error !== null && "__stackKnownErrorBrand" in error && error.__stackKnownErrorBrand === "stack-known-error-brand-sentinel";
4848
4734
  }
4849
- has(dependencies) {
4850
- return this._unwrapFromInner(dependencies, this._inner).status === "ok";
4735
+ getBody() {
4736
+ return new TextEncoder().encode(JSON.stringify(this.toDescriptiveJson(), void 0, 2));
4851
4737
  }
4852
- clear() {
4853
- this._inner = {
4854
- map: new MaybeWeakMap(),
4855
- hasValue: false,
4856
- value: void 0
4738
+ getHeaders() {
4739
+ return {
4740
+ "Content-Type": ["application/json; charset=utf-8"],
4741
+ "X-Stack-Known-Error": [this.errorCode],
4742
+ "X-Hexclave-Known-Error": [this.errorCode]
4857
4743
  };
4858
4744
  }
4859
- *[Symbol.iterator]() {
4860
- yield* this._iterateInner([], this._inner);
4861
- }
4862
- }, _Symbol$toStringTag3 = Symbol.toStringTag, _a4);
4863
-
4864
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/platform/browser/globalThis.js
4865
- var _globalThis = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
4866
-
4867
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/version.js
4868
- var VERSION = "1.9.0";
4869
-
4870
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/semver.js
4871
- var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
4872
- function _makeCompatibilityCheck(ownVersion) {
4873
- var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
4874
- var rejectedVersions = /* @__PURE__ */ new Set();
4875
- var myVersionMatch = ownVersion.match(re);
4876
- if (!myVersionMatch) {
4877
- return function() {
4878
- return false;
4745
+ toDescriptiveJson() {
4746
+ return {
4747
+ code: this.errorCode,
4748
+ ...this.details ? { details: this.details } : {},
4749
+ error: this.humanReadableMessage
4879
4750
  };
4880
4751
  }
4881
- var ownVersionParsed = {
4882
- major: +myVersionMatch[1],
4883
- minor: +myVersionMatch[2],
4884
- patch: +myVersionMatch[3],
4885
- prerelease: myVersionMatch[4]
4886
- };
4887
- if (ownVersionParsed.prerelease != null) {
4888
- return function isExactmatch(globalVersion) {
4889
- return globalVersion === ownVersion;
4890
- };
4752
+ get errorCode() {
4753
+ return this.constructor.errorCode ?? throwErr(`Can't find error code for this KnownError. Is its constructor a KnownErrorConstructor? ${this}`);
4891
4754
  }
4892
- function _reject(v) {
4893
- rejectedVersions.add(v);
4894
- return false;
4755
+ static constructorArgsFromJson(json) {
4756
+ return [
4757
+ 400,
4758
+ json.message,
4759
+ json
4760
+ ];
4895
4761
  }
4896
- function _accept(v) {
4897
- acceptedVersions.add(v);
4898
- return true;
4762
+ static fromJson(json) {
4763
+ for (const [_, KnownErrorType] of Object.entries(KnownErrors)) if (json.code === KnownErrorType.prototype.errorCode) return new KnownErrorType(...KnownErrorType.constructorArgsFromJson(json));
4764
+ throw new Error(`An error occurred. Please update your version of the Hexclave SDK. ${json.code}: ${json.message}`);
4899
4765
  }
4900
- return function isCompatible2(globalVersion) {
4901
- if (acceptedVersions.has(globalVersion)) {
4902
- return true;
4766
+ };
4767
+ function createKnownErrorConstructor(SuperClass, errorCode, create, constructorArgsFromJson) {
4768
+ const createFn = create === "inherit" ? identityArgs : create;
4769
+ const constructorArgsFromJsonFn = constructorArgsFromJson === "inherit" ? SuperClass.constructorArgsFromJson : constructorArgsFromJson;
4770
+ const _KnownErrorImpl = class _KnownErrorImpl extends SuperClass {
4771
+ constructor(...args) {
4772
+ super(...createFn(...args));
4773
+ this.name = `KnownError<${errorCode}>`;
4774
+ this.constructorArgs = args;
4903
4775
  }
4904
- if (rejectedVersions.has(globalVersion)) {
4905
- return false;
4776
+ static constructorArgsFromJson(json) {
4777
+ return constructorArgsFromJsonFn(json.details);
4906
4778
  }
4907
- var globalVersionMatch = globalVersion.match(re);
4908
- if (!globalVersionMatch) {
4909
- return _reject(globalVersion);
4779
+ static isInstance(error) {
4780
+ if (!KnownError.isKnownError(error)) return false;
4781
+ let current = error;
4782
+ while (true) {
4783
+ current = Object.getPrototypeOf(current);
4784
+ if (!current) break;
4785
+ if ("errorCode" in current.constructor && current.constructor.errorCode === errorCode) return true;
4786
+ }
4787
+ return false;
4910
4788
  }
4911
- var globalVersionParsed = {
4912
- major: +globalVersionMatch[1],
4913
- minor: +globalVersionMatch[2],
4914
- patch: +globalVersionMatch[3],
4915
- prerelease: globalVersionMatch[4]
4916
- };
4917
- if (globalVersionParsed.prerelease != null) {
4918
- return _reject(globalVersion);
4919
- }
4920
- if (ownVersionParsed.major !== globalVersionParsed.major) {
4921
- return _reject(globalVersion);
4922
- }
4923
- if (ownVersionParsed.major === 0) {
4924
- if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
4925
- return _accept(globalVersion);
4926
- }
4927
- return _reject(globalVersion);
4928
- }
4929
- if (ownVersionParsed.minor <= globalVersionParsed.minor) {
4930
- return _accept(globalVersion);
4931
- }
4932
- return _reject(globalVersion);
4933
4789
  };
4790
+ _KnownErrorImpl.errorCode = errorCode;
4791
+ let KnownErrorImpl = _KnownErrorImpl;
4792
+ return KnownErrorImpl;
4934
4793
  }
4935
- var isCompatible = _makeCompatibilityCheck(VERSION);
4794
+ var UnsupportedError = createKnownErrorConstructor(KnownError, "UNSUPPORTED_ERROR", (originalErrorCode) => [
4795
+ 500,
4796
+ `An error occurred that is not currently supported (possibly because it was added in a version of Stack that is newer than this client). The original unsupported error code was: ${originalErrorCode}`,
4797
+ { originalErrorCode }
4798
+ ], (json) => [json?.originalErrorCode ?? throwErr("originalErrorCode not found in UnsupportedError details")]);
4799
+ var BodyParsingError = createKnownErrorConstructor(KnownError, "BODY_PARSING_ERROR", (message2) => [400, message2], (json) => [json.message]);
4800
+ var SchemaError = createKnownErrorConstructor(KnownError, "SCHEMA_ERROR", (message2) => [
4801
+ 400,
4802
+ message2 || throwErr("SchemaError requires a message"),
4803
+ { message: message2 }
4804
+ ], (json) => [json.message]);
4805
+ var AllOverloadsFailed = createKnownErrorConstructor(KnownError, "ALL_OVERLOADS_FAILED", (overloadErrors) => [
4806
+ 400,
4807
+ deindent`
4808
+ This endpoint has multiple overloads, but they all failed to process the request.
4936
4809
 
4937
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
4938
- var major = VERSION.split(".")[0];
4939
- var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
4940
- var _global = _globalThis;
4941
- function registerGlobal(type, instance, diag, allowOverride) {
4942
- var _a5;
4943
- if (allowOverride === void 0) {
4944
- allowOverride = false;
4945
- }
4946
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a5 !== void 0 ? _a5 : {
4947
- version: VERSION
4948
- };
4949
- if (!allowOverride && api[type]) {
4950
- var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
4951
- diag.error(err.stack || err.message);
4952
- return false;
4953
- }
4954
- if (api.version !== VERSION) {
4955
- var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
4956
- diag.error(err.stack || err.message);
4957
- return false;
4958
- }
4959
- api[type] = instance;
4960
- diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
4961
- return true;
4962
- }
4963
- function getGlobal(type) {
4964
- var _a5, _b;
4965
- var globalVersion = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a5 === void 0 ? void 0 : _a5.version;
4966
- if (!globalVersion || !isCompatible(globalVersion)) {
4967
- return;
4968
- }
4969
- return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
4970
- }
4971
- function unregisterGlobal(type, diag) {
4972
- diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
4973
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
4974
- if (api) {
4975
- delete api[type];
4810
+ ${overloadErrors.map((e40, i) => deindent`
4811
+ Overload ${i + 1}: ${JSON.stringify(e40, void 0, 2)}
4812
+ `).join("\n\n")}
4813
+ `,
4814
+ { overload_errors: overloadErrors }
4815
+ ], (json) => [json?.overload_errors ?? throwErr("overload_errors not found in AllOverloadsFailed details")]);
4816
+ var ProjectAuthenticationError = createKnownErrorConstructor(KnownError, "PROJECT_AUTHENTICATION_ERROR", "inherit", "inherit");
4817
+ var InvalidProjectAuthentication = createKnownErrorConstructor(ProjectAuthenticationError, "INVALID_PROJECT_AUTHENTICATION", "inherit", "inherit");
4818
+ var ProjectKeyWithoutAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "PROJECT_KEY_WITHOUT_ACCESS_TYPE", () => [400, "Either an API key or an admin access token was provided, but the x-hexclave-access-type header is missing. Set it to 'client', 'server', or 'admin' as appropriate. (The legacy x-stack-access-type header is also accepted.)"], () => []);
4819
+ var InvalidAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_ACCESS_TYPE", (accessType) => [400, `The x-hexclave-access-type header must be 'client', 'server', or 'admin', but was '${accessType}'. (The legacy x-stack-access-type header is also accepted.)`], (json) => [json?.accessType ?? throwErr("accessType not found in InvalidAccessType details")]);
4820
+ var AccessTypeWithoutProjectId = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_WITHOUT_PROJECT_ID", (accessType) => [
4821
+ 400,
4822
+ deindent`
4823
+ The x-hexclave-access-type header was '${accessType}', but the x-hexclave-project-id header was not provided. (The legacy x-stack-access-type and x-stack-project-id headers are also accepted.)
4824
+
4825
+ For more information, see the docs on REST API authentication: https://docs.hexclave.com/api/overview#authentication
4826
+ `,
4827
+ { request_type: accessType }
4828
+ ], (json) => [json.request_type]);
4829
+ var AccessTypeRequired = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_REQUIRED", () => [400, deindent`
4830
+ You must specify an access level for this Hexclave project. Make sure project API keys are provided (eg. x-hexclave-publishable-client-key) and you set the x-hexclave-access-type header to 'client', 'server', or 'admin'. (The legacy x-stack-* equivalents are also accepted.)
4831
+
4832
+ For more information, see the docs on REST API authentication: https://docs.hexclave.com/api/overview#authentication
4833
+ `], () => []);
4834
+ var InsufficientAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "INSUFFICIENT_ACCESS_TYPE", (actualAccessType, allowedAccessTypes) => [
4835
+ 401,
4836
+ `The x-hexclave-access-type header must be ${allowedAccessTypes.map((s8) => `'${s8}'`).join(" or ")}, but was '${actualAccessType}'. (The legacy x-stack-access-type header is also accepted.)`,
4837
+ {
4838
+ actual_access_type: actualAccessType,
4839
+ allowed_access_types: allowedAccessTypes
4976
4840
  }
4977
- }
4841
+ ], (json) => [json.actual_access_type, json.allowed_access_types]);
4842
+ var InvalidPublishableClientKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_PUBLISHABLE_CLIENT_KEY", (projectId) => [
4843
+ 401,
4844
+ `The publishable key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
4845
+ { project_id: projectId }
4846
+ ], (json) => [json.project_id]);
4847
+ var InvalidSecretServerKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SECRET_SERVER_KEY", (projectId) => [
4848
+ 401,
4849
+ `The secret server key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
4850
+ { project_id: projectId }
4851
+ ], (json) => [json.project_id]);
4852
+ var InvalidSuperSecretAdminKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SUPER_SECRET_ADMIN_KEY", (projectId) => [
4853
+ 401,
4854
+ `The super secret admin key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
4855
+ { project_id: projectId }
4856
+ ], (json) => [json.project_id]);
4857
+ var InvalidAdminAccessToken = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_ADMIN_ACCESS_TOKEN", "inherit", "inherit");
4858
+ var UnparsableAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "UNPARSABLE_ADMIN_ACCESS_TOKEN", () => [401, "Admin access token is not parsable."], () => []);
4859
+ var AdminAccessTokenExpired = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_EXPIRED", (expiredAt) => [
4860
+ 401,
4861
+ `Admin access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)` : ""}`,
4862
+ { expired_at_millis: expiredAt?.getTime() ?? null }
4863
+ ], (json) => [json.expired_at_millis ? new Date(json.expired_at_millis) : void 0]);
4864
+ var InvalidProjectForAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "INVALID_PROJECT_FOR_ADMIN_ACCESS_TOKEN", () => [401, "Admin access tokens must be created on the internal project."], () => []);
4865
+ var AdminAccessTokenIsNotAdmin = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_IS_NOT_ADMIN", () => [401, "Admin access token does not have the required permissions to access this project."], () => []);
4866
+ var ProjectAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationError, "PROJECT_AUTHENTICATION_REQUIRED", "inherit", "inherit");
4867
+ var ClientAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_AUTHENTICATION_REQUIRED", () => [401, "The publishable client key must be provided."], () => []);
4868
+ var PublishableClientKeyRequiredForProject = createKnownErrorConstructor(ProjectAuthenticationRequired, "PUBLISHABLE_CLIENT_KEY_REQUIRED_FOR_PROJECT", (projectId) => [
4869
+ 401,
4870
+ "Publishable client keys are required for this project. Create one in Project Keys, or disable this requirement there to allow keyless client access.",
4871
+ { project_id: projectId ?? null }
4872
+ ], (json) => [json.project_id ?? void 0]);
4873
+ var ServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "SERVER_AUTHENTICATION_REQUIRED", () => [401, "The secret server key must be provided."], () => []);
4874
+ var ClientOrServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_SERVER_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the secret server key must be provided."], () => []);
4875
+ var ClientOrAdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_ADMIN_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the super secret admin key must be provided."], () => []);
4876
+ var ClientOrServerOrAdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_SERVER_OR_ADMIN_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key, the secret server key, or the super secret admin key must be provided."], () => []);
4877
+ var AdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "ADMIN_AUTHENTICATION_REQUIRED", () => [401, "The super secret admin key must be provided."], () => []);
4878
+ var ExpectedInternalProject = createKnownErrorConstructor(ProjectAuthenticationError, "EXPECTED_INTERNAL_PROJECT", () => [401, "The project ID is expected to be internal."], () => []);
4879
+ var SessionAuthenticationError = createKnownErrorConstructor(KnownError, "SESSION_AUTHENTICATION_ERROR", "inherit", "inherit");
4880
+ var InvalidSessionAuthentication = createKnownErrorConstructor(SessionAuthenticationError, "INVALID_SESSION_AUTHENTICATION", "inherit", "inherit");
4881
+ var InvalidAccessToken = createKnownErrorConstructor(InvalidSessionAuthentication, "INVALID_ACCESS_TOKEN", "inherit", "inherit");
4882
+ var UnparsableAccessToken = createKnownErrorConstructor(InvalidAccessToken, "UNPARSABLE_ACCESS_TOKEN", () => [401, "Access token is not parsable."], () => []);
4883
+ var AccessTokenExpired = createKnownErrorConstructor(InvalidAccessToken, "ACCESS_TOKEN_EXPIRED", (expiredAt, projectId, userId, refreshTokenId) => [
4884
+ 401,
4885
+ deindent`
4886
+ Access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)` : ""}${projectId ? ` Project ID: ${projectId}.` : ""}${userId ? ` User ID: ${userId}.` : ""}${refreshTokenId ? ` Refresh token ID: ${refreshTokenId}.` : ""}
4978
4887
 
4979
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
4980
- var __read = function(o21, n10) {
4981
- var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
4982
- if (!m6) return o21;
4983
- var i = m6.call(o21), r7, ar = [], e40;
4984
- try {
4985
- while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
4986
- } catch (error) {
4987
- e40 = { error };
4988
- } finally {
4989
- try {
4990
- if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
4991
- } finally {
4992
- if (e40) throw e40.error;
4993
- }
4888
+ Debug info: Most likely, you fetched the access token before it expired (for example, in a server component, pre-rendered page, or on page load), but then didn't refresh it before it expired. If this is the case, and you're using the SDK, make sure you call getAccessToken() every time you need to use the access token. If you're not using the SDK, make sure you refresh the access token with the refresh endpoint.
4889
+ `,
4890
+ {
4891
+ expired_at_millis: expiredAt?.getTime() ?? null,
4892
+ project_id: projectId ?? null,
4893
+ user_id: userId ?? null,
4894
+ refresh_token_id: refreshTokenId ?? null
4994
4895
  }
4995
- return ar;
4996
- };
4997
- var __spreadArray = function(to, from, pack) {
4998
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
4999
- if (ar || !(i in from)) {
5000
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5001
- ar[i] = from[i];
5002
- }
4896
+ ], (json) => [
4897
+ json.expired_at_millis ? new Date(json.expired_at_millis) : void 0,
4898
+ json.project_id ?? void 0,
4899
+ json.user_id ?? void 0,
4900
+ json.refresh_token_id ?? void 0
4901
+ ]);
4902
+ var InvalidProjectForAccessToken = createKnownErrorConstructor(InvalidAccessToken, "INVALID_PROJECT_FOR_ACCESS_TOKEN", (expectedProjectId, actualProjectId) => [
4903
+ 401,
4904
+ `Access token not valid for this project. Expected project ID ${JSON.stringify(expectedProjectId)}, but the token is for project ID ${JSON.stringify(actualProjectId)}.`,
4905
+ {
4906
+ expected_project_id: expectedProjectId,
4907
+ actual_project_id: actualProjectId
5003
4908
  }
5004
- return to.concat(ar || Array.prototype.slice.call(from));
5005
- };
5006
- var DiagComponentLogger = (
5007
- /** @class */
5008
- function() {
5009
- function DiagComponentLogger2(props2) {
5010
- this._namespace = props2.namespace || "DiagComponentLogger";
5011
- }
5012
- DiagComponentLogger2.prototype.debug = function() {
5013
- var args = [];
5014
- for (var _i = 0; _i < arguments.length; _i++) {
5015
- args[_i] = arguments[_i];
5016
- }
5017
- return logProxy("debug", this._namespace, args);
5018
- };
5019
- DiagComponentLogger2.prototype.error = function() {
5020
- var args = [];
5021
- for (var _i = 0; _i < arguments.length; _i++) {
5022
- args[_i] = arguments[_i];
5023
- }
5024
- return logProxy("error", this._namespace, args);
5025
- };
5026
- DiagComponentLogger2.prototype.info = function() {
5027
- var args = [];
5028
- for (var _i = 0; _i < arguments.length; _i++) {
5029
- args[_i] = arguments[_i];
5030
- }
5031
- return logProxy("info", this._namespace, args);
5032
- };
5033
- DiagComponentLogger2.prototype.warn = function() {
5034
- var args = [];
5035
- for (var _i = 0; _i < arguments.length; _i++) {
5036
- args[_i] = arguments[_i];
5037
- }
5038
- return logProxy("warn", this._namespace, args);
5039
- };
5040
- DiagComponentLogger2.prototype.verbose = function() {
5041
- var args = [];
5042
- for (var _i = 0; _i < arguments.length; _i++) {
5043
- args[_i] = arguments[_i];
5044
- }
5045
- return logProxy("verbose", this._namespace, args);
5046
- };
5047
- return DiagComponentLogger2;
5048
- }()
5049
- );
5050
- function logProxy(funcName, namespace, args) {
5051
- var logger = getGlobal("diag");
5052
- if (!logger) {
5053
- return;
4909
+ ], (json) => [json.expected_project_id, json.actual_project_id]);
4910
+ var RefreshTokenError = createKnownErrorConstructor(KnownError, "REFRESH_TOKEN_ERROR", "inherit", "inherit");
4911
+ var RefreshTokenNotFoundOrExpired = createKnownErrorConstructor(RefreshTokenError, "REFRESH_TOKEN_NOT_FOUND_OR_EXPIRED", () => [401, "Refresh token not found for this project, or the session has expired/been revoked."], () => []);
4912
+ var CannotDeleteCurrentSession = createKnownErrorConstructor(RefreshTokenError, "CANNOT_DELETE_CURRENT_SESSION", () => [400, "Cannot delete the current session."], () => []);
4913
+ var ProviderRejected = createKnownErrorConstructor(RefreshTokenError, "PROVIDER_REJECTED", () => [401, "The provider refused to refresh their token. This usually means that the provider used to authenticate the user no longer regards this session as valid, and the user must re-authenticate."], () => []);
4914
+ var UserWithEmailAlreadyExists = createKnownErrorConstructor(KnownError, "USER_EMAIL_ALREADY_EXISTS", (email, wouldWorkIfEmailWasVerified = false) => [
4915
+ 409,
4916
+ `A user with email ${JSON.stringify(email)} already exists${wouldWorkIfEmailWasVerified ? " but the email is not verified. Please login to your existing account with the method you used to sign up, and then verify your email to sign in with this login method." : "."}`,
4917
+ {
4918
+ email,
4919
+ would_work_if_email_was_verified: wouldWorkIfEmailWasVerified
5054
4920
  }
5055
- args.unshift(namespace);
5056
- return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
5057
- }
5058
-
5059
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/types.js
5060
- var DiagLogLevel;
5061
- (function(DiagLogLevel2) {
5062
- DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
5063
- DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
5064
- DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
5065
- DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
5066
- DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
5067
- DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
5068
- DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
5069
- })(DiagLogLevel || (DiagLogLevel = {}));
5070
-
5071
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
5072
- function createLogLevelDiagLogger(maxLevel, logger) {
5073
- if (maxLevel < DiagLogLevel.NONE) {
5074
- maxLevel = DiagLogLevel.NONE;
5075
- } else if (maxLevel > DiagLogLevel.ALL) {
5076
- maxLevel = DiagLogLevel.ALL;
4921
+ ], (json) => [json.email, json.would_work_if_email_was_verified ?? false]);
4922
+ var EmailNotVerified = createKnownErrorConstructor(KnownError, "EMAIL_NOT_VERIFIED", () => [400, "The email is not verified."], () => []);
4923
+ var CannotGetOwnUserWithoutUser = createKnownErrorConstructor(KnownError, "CANNOT_GET_OWN_USER_WITHOUT_USER", () => [400, "You have specified 'me' as a userId, but did not provide authentication for a user."], () => []);
4924
+ var UserIdDoesNotExist = createKnownErrorConstructor(KnownError, "USER_ID_DOES_NOT_EXIST", (userId) => [
4925
+ 400,
4926
+ `The given user with the ID ${userId} does not exist.`,
4927
+ { user_id: userId }
4928
+ ], (json) => [json.user_id]);
4929
+ var UserNotFound = createKnownErrorConstructor(KnownError, "USER_NOT_FOUND", () => [404, "User not found."], () => []);
4930
+ var RestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
4931
+ 403,
4932
+ `The user in the access token is in restricted state. Reason: ${restrictedReason.type}. Please pass the X-Stack-Allow-Restricted-User header if this is intended.`,
4933
+ { restricted_reason: restrictedReason }
4934
+ ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
4935
+ var ProjectNotFound = createKnownErrorConstructor(KnownError, "PROJECT_NOT_FOUND", (projectId) => {
4936
+ if (typeof projectId !== "string") throw new HexclaveAssertionError("projectId of KnownErrors.ProjectNotFound must be a string");
4937
+ return [
4938
+ 404,
4939
+ `Project ${projectId} not found or is not accessible with the current user.`,
4940
+ { project_id: projectId }
4941
+ ];
4942
+ }, (json) => [json.project_id]);
4943
+ var CurrentProjectNotFound = createKnownErrorConstructor(KnownError, "CURRENT_PROJECT_NOT_FOUND", (projectId) => [
4944
+ 400,
4945
+ `The current project with ID ${projectId} was not found. Please check the value of the x-hexclave-project-id header. (The legacy x-stack-project-id header is also accepted.)`,
4946
+ { project_id: projectId }
4947
+ ], (json) => [json.project_id]);
4948
+ var BranchDoesNotExist = createKnownErrorConstructor(KnownError, "BRANCH_DOES_NOT_EXIST", (branchId) => [
4949
+ 400,
4950
+ `The branch with ID ${branchId} does not exist.`,
4951
+ { branch_id: branchId }
4952
+ ], (json) => [json.branch_id]);
4953
+ var SignUpNotEnabled = createKnownErrorConstructor(KnownError, "SIGN_UP_NOT_ENABLED", () => [400, "Creation of new accounts is not enabled for this project. Please ask the project owner to enable it."], () => []);
4954
+ var SignUpRejected = createKnownErrorConstructor(KnownError, "SIGN_UP_REJECTED", (message2) => [
4955
+ 403,
4956
+ message2 ?? "Your sign up was rejected by an administrator's sign-up rule.",
4957
+ { message: message2 ?? "Your sign up was rejected by an administrator's sign-up rule." }
4958
+ ], (json) => [json.message]);
4959
+ var BotChallengeRequired = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_REQUIRED", () => [409, "An additional bot challenge is required before sign-up can continue."], () => []);
4960
+ var BotChallengeFailed = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_FAILED", (message2) => [
4961
+ 400,
4962
+ message2,
4963
+ { message: message2 }
4964
+ ], (json) => [json.message]);
4965
+ var PasswordAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSWORD_AUTHENTICATION_NOT_ENABLED", () => [400, "Password authentication is not enabled for this project."], () => []);
4966
+ var DataVaultStoreDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_DOES_NOT_EXIST", (storeId) => [
4967
+ 400,
4968
+ `Data vault store with ID ${storeId} does not exist.`,
4969
+ { store_id: storeId }
4970
+ ], (json) => [json.store_id]);
4971
+ var DataVaultStoreHashedKeyDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_HASHED_KEY_DOES_NOT_EXIST", (storeId, hashedKey) => [
4972
+ 400,
4973
+ `Data vault store with ID ${storeId} does not contain a key with hash ${hashedKey}.`,
4974
+ {
4975
+ store_id: storeId,
4976
+ hashed_key: hashedKey
5077
4977
  }
5078
- logger = logger || {};
5079
- function _filterFunc(funcName, theLevel) {
5080
- var theFunc = logger[funcName];
5081
- if (typeof theFunc === "function" && maxLevel >= theLevel) {
5082
- return theFunc.bind(logger);
5083
- }
5084
- return function() {
5085
- };
4978
+ ], (json) => [json.store_id, json.hashed_key]);
4979
+ var PasskeyAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_NOT_ENABLED", () => [400, "Passkey authentication is not enabled for this project."], () => []);
4980
+ var AnonymousAccountsNotEnabled = createKnownErrorConstructor(KnownError, "ANONYMOUS_ACCOUNTS_NOT_ENABLED", () => [400, "Anonymous accounts are not enabled for this project."], () => []);
4981
+ var AnonymousAuthenticationNotAllowed = createKnownErrorConstructor(KnownError, "ANONYMOUS_AUTHENTICATION_NOT_ALLOWED", () => [401, "X-Stack-Access-Token is for an anonymous user, but anonymous users are not enabled. Set the X-Stack-Allow-Anonymous-User header of this request to 'true' to allow anonymous users."], () => []);
4982
+ var EmailPasswordMismatch = createKnownErrorConstructor(KnownError, "EMAIL_PASSWORD_MISMATCH", () => [400, "Wrong e-mail or password."], () => []);
4983
+ var RedirectUrlNotWhitelisted = createKnownErrorConstructor(KnownError, "REDIRECT_URL_NOT_WHITELISTED", (redirectUrl) => [
4984
+ 400,
4985
+ "Redirect URL not whitelisted. Did you forget to add this domain to the trusted domains list on the Hexclave dashboard?",
4986
+ redirectUrl === void 0 ? void 0 : { redirect_url: redirectUrl }
4987
+ ], (json) => [json?.redirect_url]);
4988
+ var PasswordRequirementsNotMet = createKnownErrorConstructor(KnownError, "PASSWORD_REQUIREMENTS_NOT_MET", "inherit", "inherit");
4989
+ var PasswordTooShort = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_SHORT", (minLength) => [
4990
+ 400,
4991
+ `Password too short. Minimum length is ${minLength}.`,
4992
+ { min_length: minLength }
4993
+ ], (json) => [json?.min_length ?? throwErr("min_length not found in PasswordTooShort details")]);
4994
+ var PasswordTooLong = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_LONG", (maxLength) => [
4995
+ 400,
4996
+ `Password too long. Maximum length is ${maxLength}.`,
4997
+ { maxLength }
4998
+ ], (json) => [json?.maxLength ?? throwErr("maxLength not found in PasswordTooLong details")]);
4999
+ var UserDoesNotHavePassword = createKnownErrorConstructor(KnownError, "USER_DOES_NOT_HAVE_PASSWORD", () => [400, "This user does not have password authentication enabled."], () => []);
5000
+ var VerificationCodeError = createKnownErrorConstructor(KnownError, "VERIFICATION_ERROR", "inherit", "inherit");
5001
+ var VerificationCodeNotFound = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_NOT_FOUND", () => [404, "The verification code does not exist for this project."], () => []);
5002
+ var VerificationCodeExpired = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_EXPIRED", () => [400, "The verification code has expired."], () => []);
5003
+ var VerificationCodeAlreadyUsed = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_ALREADY_USED", () => [409, "The verification link has already been used."], () => []);
5004
+ var VerificationCodeMaxAttemptsReached = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_MAX_ATTEMPTS_REACHED", () => [400, "The verification code nonce has reached the maximum number of attempts. This code is not valid anymore."], () => []);
5005
+ var PasswordConfirmationMismatch = createKnownErrorConstructor(KnownError, "PASSWORD_CONFIRMATION_MISMATCH", () => [400, "Passwords do not match."], () => []);
5006
+ var EmailAlreadyVerified = createKnownErrorConstructor(KnownError, "EMAIL_ALREADY_VERIFIED", () => [409, "The e-mail is already verified."], () => []);
5007
+ var EmailNotAssociatedWithUser = createKnownErrorConstructor(KnownError, "EMAIL_NOT_ASSOCIATED_WITH_USER", () => [400, "The e-mail is not associated with a user that could log in with that e-mail."], () => []);
5008
+ var EmailIsNotPrimaryEmail = createKnownErrorConstructor(KnownError, "EMAIL_IS_NOT_PRIMARY_EMAIL", (email, primaryEmail) => [
5009
+ 400,
5010
+ `The given e-mail (${email}) must equal the user's primary e-mail (${primaryEmail}).`,
5011
+ {
5012
+ email,
5013
+ primary_email: primaryEmail
5086
5014
  }
5087
- return {
5088
- error: _filterFunc("error", DiagLogLevel.ERROR),
5089
- warn: _filterFunc("warn", DiagLogLevel.WARN),
5090
- info: _filterFunc("info", DiagLogLevel.INFO),
5091
- debug: _filterFunc("debug", DiagLogLevel.DEBUG),
5092
- verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
5093
- };
5094
- }
5095
-
5096
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/diag.js
5097
- var __read2 = function(o21, n10) {
5098
- var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
5099
- if (!m6) return o21;
5100
- var i = m6.call(o21), r7, ar = [], e40;
5101
- try {
5102
- while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
5103
- } catch (error) {
5104
- e40 = { error };
5105
- } finally {
5106
- try {
5107
- if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
5108
- } finally {
5109
- if (e40) throw e40.error;
5110
- }
5015
+ ], (json) => [json.email, json.primary_email]);
5016
+ var PasskeyRegistrationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_REGISTRATION_FAILED", (message2) => [400, message2], (json) => [json.message]);
5017
+ var PasskeyWebAuthnError = createKnownErrorConstructor(KnownError, "PASSKEY_WEBAUTHN_ERROR", (message2, code) => [
5018
+ 400,
5019
+ message2,
5020
+ {
5021
+ message: message2,
5022
+ code
5111
5023
  }
5112
- return ar;
5113
- };
5114
- var __spreadArray2 = function(to, from, pack) {
5115
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
5116
- if (ar || !(i in from)) {
5117
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5118
- ar[i] = from[i];
5119
- }
5024
+ ], (json) => [json.message, json.code]);
5025
+ var PasskeyAuthenticationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_FAILED", (message2) => [400, message2], (json) => [json.message]);
5026
+ var PermissionNotFound = createKnownErrorConstructor(KnownError, "PERMISSION_NOT_FOUND", (permissionId) => [
5027
+ 404,
5028
+ `Permission "${permissionId}" not found. Make sure you created it on the dashboard.`,
5029
+ { permission_id: permissionId }
5030
+ ], (json) => [json.permission_id]);
5031
+ var PermissionScopeMismatch = createKnownErrorConstructor(KnownError, "WRONG_PERMISSION_SCOPE", (permissionId, expectedScope, actualScope) => [
5032
+ 404,
5033
+ `Permission ${JSON.stringify(permissionId)} not found. (It was found for a different scope ${JSON.stringify(actualScope)}, but scope ${JSON.stringify(expectedScope)} was expected.)`,
5034
+ {
5035
+ permission_id: permissionId,
5036
+ expected_scope: expectedScope,
5037
+ actual_scope: actualScope
5120
5038
  }
5121
- return to.concat(ar || Array.prototype.slice.call(from));
5122
- };
5123
- var API_NAME = "diag";
5124
- var DiagAPI = (
5125
- /** @class */
5126
- function() {
5127
- function DiagAPI2() {
5128
- function _logProxy(funcName) {
5129
- return function() {
5130
- var args = [];
5131
- for (var _i = 0; _i < arguments.length; _i++) {
5132
- args[_i] = arguments[_i];
5133
- }
5134
- var logger = getGlobal("diag");
5135
- if (!logger)
5136
- return;
5137
- return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
5138
- };
5139
- }
5140
- var self2 = this;
5141
- var setLogger = function(logger, optionsOrLogLevel) {
5142
- var _a5, _b, _c;
5143
- if (optionsOrLogLevel === void 0) {
5144
- optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
5145
- }
5146
- if (logger === self2) {
5147
- var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
5148
- self2.error((_a5 = err.stack) !== null && _a5 !== void 0 ? _a5 : err.message);
5149
- return false;
5150
- }
5151
- if (typeof optionsOrLogLevel === "number") {
5152
- optionsOrLogLevel = {
5153
- logLevel: optionsOrLogLevel
5154
- };
5155
- }
5156
- var oldLogger = getGlobal("diag");
5157
- var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
5158
- if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
5159
- var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
5160
- oldLogger.warn("Current logger will be overwritten from " + stack);
5161
- newLogger.warn("Current logger will overwrite one already registered from " + stack);
5162
- }
5163
- return registerGlobal("diag", newLogger, self2, true);
5164
- };
5165
- self2.setLogger = setLogger;
5166
- self2.disable = function() {
5167
- unregisterGlobal(API_NAME, self2);
5168
- };
5169
- self2.createComponentLogger = function(options) {
5170
- return new DiagComponentLogger(options);
5171
- };
5172
- self2.verbose = _logProxy("verbose");
5173
- self2.debug = _logProxy("debug");
5174
- self2.info = _logProxy("info");
5175
- self2.warn = _logProxy("warn");
5176
- self2.error = _logProxy("error");
5177
- }
5178
- DiagAPI2.instance = function() {
5179
- if (!this._instance) {
5180
- this._instance = new DiagAPI2();
5181
- }
5182
- return this._instance;
5183
- };
5184
- return DiagAPI2;
5185
- }()
5186
- );
5187
-
5188
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/context.js
5189
- function createContextKey(description) {
5190
- return Symbol.for(description);
5191
- }
5192
- var BaseContext = (
5193
- /** @class */
5194
- /* @__PURE__ */ function() {
5195
- function BaseContext2(parentContext) {
5196
- var self2 = this;
5197
- self2._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
5198
- self2.getValue = function(key) {
5199
- return self2._currentContext.get(key);
5200
- };
5201
- self2.setValue = function(key, value) {
5202
- var context = new BaseContext2(self2._currentContext);
5203
- context._currentContext.set(key, value);
5204
- return context;
5205
- };
5206
- self2.deleteValue = function(key) {
5207
- var context = new BaseContext2(self2._currentContext);
5208
- context._currentContext.delete(key);
5209
- return context;
5210
- };
5211
- }
5212
- return BaseContext2;
5213
- }()
5214
- );
5215
- var ROOT_CONTEXT = new BaseContext();
5216
-
5217
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js
5218
- var __read3 = function(o21, n10) {
5219
- var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
5220
- if (!m6) return o21;
5221
- var i = m6.call(o21), r7, ar = [], e40;
5222
- try {
5223
- while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
5224
- } catch (error) {
5225
- e40 = { error };
5226
- } finally {
5227
- try {
5228
- if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
5229
- } finally {
5230
- if (e40) throw e40.error;
5231
- }
5039
+ ], (json) => [
5040
+ json.permission_id,
5041
+ json.expected_scope,
5042
+ json.actual_scope
5043
+ ]);
5044
+ var ContainedPermissionNotFound = createKnownErrorConstructor(KnownError, "CONTAINED_PERMISSION_NOT_FOUND", (permissionId) => [
5045
+ 400,
5046
+ `Contained permission with ID "${permissionId}" not found. Make sure you created it on the dashboard.`,
5047
+ { permission_id: permissionId }
5048
+ ], (json) => [json.permission_id]);
5049
+ var TeamNotFound = createKnownErrorConstructor(KnownError, "TEAM_NOT_FOUND", (teamId) => [
5050
+ 404,
5051
+ `Team ${teamId} not found.`,
5052
+ { team_id: teamId }
5053
+ ], (json) => [json.team_id]);
5054
+ createKnownErrorConstructor(KnownError, "TEAM_ALREADY_EXISTS", (teamId) => [
5055
+ 409,
5056
+ `Team ${teamId} already exists.`,
5057
+ { team_id: teamId }
5058
+ ], (json) => [json.team_id]);
5059
+ var TeamMembershipNotFound = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_NOT_FOUND", (teamId, userId) => [
5060
+ 404,
5061
+ `User ${userId} is not found in team ${teamId}.`,
5062
+ {
5063
+ team_id: teamId,
5064
+ user_id: userId
5232
5065
  }
5233
- return ar;
5234
- };
5235
- var __spreadArray3 = function(to, from, pack) {
5236
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
5237
- if (ar || !(i in from)) {
5238
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5239
- ar[i] = from[i];
5240
- }
5066
+ ], (json) => [json.team_id, json.user_id]);
5067
+ var TeamInvitationRestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "TEAM_INVITATION_RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
5068
+ 403,
5069
+ `Restricted users cannot accept team invitations. Reason: ${restrictedReason.type}. Please complete the onboarding process before accepting team invitations.`,
5070
+ { restricted_reason: restrictedReason }
5071
+ ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
5072
+ var TeamInvitationEmailMismatch = createKnownErrorConstructor(KnownError, "TEAM_INVITATION_EMAIL_MISMATCH", () => [403, "This team invitation was sent to a different email address. Sign in with the invited email, or add and verify that email on your account, then try again."], () => []);
5073
+ var EmailTemplateAlreadyExists = createKnownErrorConstructor(KnownError, "EMAIL_TEMPLATE_ALREADY_EXISTS", () => [409, "Email template already exists."], () => []);
5074
+ var OAuthConnectionNotConnectedToUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_NOT_CONNECTED_TO_USER", () => [400, "The OAuth connection is not connected to any user."], () => []);
5075
+ var OAuthConnectionAlreadyConnectedToAnotherUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_ALREADY_CONNECTED_TO_ANOTHER_USER", () => [409, "The OAuth connection is already connected to another user."], () => []);
5076
+ var OAuthConnectionDoesNotHaveRequiredScope = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_DOES_NOT_HAVE_REQUIRED_SCOPE", () => [400, "The OAuth connection does not have the required scope."], () => []);
5077
+ var OAuthAccessTokenNotAvailable = createKnownErrorConstructor(KnownError, "OAUTH_ACCESS_TOKEN_NOT_AVAILABLE", (provider, details) => [
5078
+ 400,
5079
+ `Failed to retrieve an OAuth access token for the connected account (provider: ${provider}). ${details}`,
5080
+ {
5081
+ provider,
5082
+ details
5241
5083
  }
5242
- return to.concat(ar || Array.prototype.slice.call(from));
5243
- };
5244
- var NoopContextManager = (
5245
- /** @class */
5246
- function() {
5247
- function NoopContextManager2() {
5248
- }
5249
- NoopContextManager2.prototype.active = function() {
5250
- return ROOT_CONTEXT;
5251
- };
5252
- NoopContextManager2.prototype.with = function(_context, fn, thisArg) {
5253
- var args = [];
5254
- for (var _i = 3; _i < arguments.length; _i++) {
5255
- args[_i - 3] = arguments[_i];
5256
- }
5257
- return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
5258
- };
5259
- NoopContextManager2.prototype.bind = function(_context, target) {
5260
- return target;
5261
- };
5262
- NoopContextManager2.prototype.enable = function() {
5263
- return this;
5264
- };
5265
- NoopContextManager2.prototype.disable = function() {
5266
- return this;
5267
- };
5268
- return NoopContextManager2;
5269
- }()
5270
- );
5271
-
5272
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/context.js
5273
- var __read4 = function(o21, n10) {
5274
- var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
5275
- if (!m6) return o21;
5276
- var i = m6.call(o21), r7, ar = [], e40;
5277
- try {
5278
- while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
5279
- } catch (error) {
5280
- e40 = { error };
5281
- } finally {
5282
- try {
5283
- if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
5284
- } finally {
5285
- if (e40) throw e40.error;
5286
- }
5084
+ ], (json) => [json.provider, json.details]);
5085
+ var OAuthExtraScopeNotAvailableWithSharedOAuthKeys = createKnownErrorConstructor(KnownError, "OAUTH_EXTRA_SCOPE_NOT_AVAILABLE_WITH_SHARED_OAUTH_KEYS", () => [400, "Extra scopes are not available with shared OAuth keys. Please add your own OAuth keys on the Hexclave dashboard to use extra scopes."], () => []);
5086
+ var OAuthAccessTokenNotAvailableWithSharedOAuthKeys = createKnownErrorConstructor(KnownError, "OAUTH_ACCESS_TOKEN_NOT_AVAILABLE_WITH_SHARED_OAUTH_KEYS", () => [400, "Access tokens are not available with shared OAuth keys. Please add your own OAuth keys on the Hexclave dashboard to use access tokens."], () => []);
5087
+ var InvalidOAuthClientIdOrSecret = createKnownErrorConstructor(KnownError, "INVALID_OAUTH_CLIENT_ID_OR_SECRET", (clientId) => [
5088
+ 400,
5089
+ "The OAuth client ID or secret is invalid. The client ID must be equal to the project ID (potentially with a hash and a branch ID), and the client secret must be a publishable client key.",
5090
+ { client_id: clientId ?? null }
5091
+ ], (json) => [json.client_id ?? void 0]);
5092
+ var InvalidScope = createKnownErrorConstructor(KnownError, "INVALID_SCOPE", (scope) => [400, `The scope "${scope}" is not a valid OAuth scope for Stack.`], (json) => [json.scope]);
5093
+ var UserAlreadyConnectedToAnotherOAuthConnection = createKnownErrorConstructor(KnownError, "USER_ALREADY_CONNECTED_TO_ANOTHER_OAUTH_CONNECTION", () => [409, "The user is already connected to another OAuth account. Did you maybe selected the wrong account?"], () => []);
5094
+ var OuterOAuthTimeout = createKnownErrorConstructor(KnownError, "OUTER_OAUTH_TIMEOUT", () => [408, "The OAuth flow has timed out. Please sign in again."], () => []);
5095
+ var OAuthProviderNotFoundOrNotEnabled = createKnownErrorConstructor(KnownError, "OAUTH_PROVIDER_NOT_FOUND_OR_NOT_ENABLED", () => [400, "The OAuth provider is not found or not enabled."], () => []);
5096
+ var AppleBundleIdNotConfigured = createKnownErrorConstructor(KnownError, "APPLE_BUNDLE_ID_NOT_CONFIGURED", () => [400, "Apple Sign In is enabled, but no Bundle IDs are configured. Please add your app's Bundle ID in the Hexclave dashboard under OAuth Providers > Apple > Apple Bundle IDs."], () => []);
5097
+ var OAuthProviderAccountIdAlreadyUsedForSignIn = createKnownErrorConstructor(KnownError, "OAUTH_PROVIDER_ACCOUNT_ID_ALREADY_USED_FOR_SIGN_IN", () => [400, `A provider with the same account ID is already used for signing in.`], () => []);
5098
+ var MultiFactorAuthenticationRequired = createKnownErrorConstructor(KnownError, "MULTI_FACTOR_AUTHENTICATION_REQUIRED", (attemptCode) => [
5099
+ 400,
5100
+ `Multi-factor authentication is required for this user.`,
5101
+ { attempt_code: attemptCode }
5102
+ ], (json) => [json.attempt_code]);
5103
+ var InvalidTotpCode = createKnownErrorConstructor(KnownError, "INVALID_TOTP_CODE", () => [400, "The TOTP code is invalid. Please try again."], () => []);
5104
+ var UserAuthenticationRequired = createKnownErrorConstructor(KnownError, "USER_AUTHENTICATION_REQUIRED", () => [401, "User authentication required for this endpoint."], () => []);
5105
+ var TeamMembershipAlreadyExists = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_ALREADY_EXISTS", () => [409, "Team membership already exists."], () => []);
5106
+ var ProjectPermissionRequired = createKnownErrorConstructor(KnownError, "PROJECT_PERMISSION_REQUIRED", (userId, permissionId) => [
5107
+ 401,
5108
+ `User ${userId} does not have permission ${permissionId}.`,
5109
+ {
5110
+ user_id: userId,
5111
+ permission_id: permissionId
5287
5112
  }
5288
- return ar;
5289
- };
5290
- var __spreadArray4 = function(to, from, pack) {
5291
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
5292
- if (ar || !(i in from)) {
5293
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5294
- ar[i] = from[i];
5295
- }
5296
- }
5297
- return to.concat(ar || Array.prototype.slice.call(from));
5298
- };
5299
- var API_NAME2 = "context";
5300
- var NOOP_CONTEXT_MANAGER = new NoopContextManager();
5301
- var ContextAPI = (
5302
- /** @class */
5303
- function() {
5304
- function ContextAPI2() {
5305
- }
5306
- ContextAPI2.getInstance = function() {
5307
- if (!this._instance) {
5308
- this._instance = new ContextAPI2();
5309
- }
5310
- return this._instance;
5311
- };
5312
- ContextAPI2.prototype.setGlobalContextManager = function(contextManager) {
5313
- return registerGlobal(API_NAME2, contextManager, DiagAPI.instance());
5314
- };
5315
- ContextAPI2.prototype.active = function() {
5316
- return this._getContextManager().active();
5317
- };
5318
- ContextAPI2.prototype.with = function(context, fn, thisArg) {
5319
- var _a5;
5320
- var args = [];
5321
- for (var _i = 3; _i < arguments.length; _i++) {
5322
- args[_i - 3] = arguments[_i];
5323
- }
5324
- return (_a5 = this._getContextManager()).with.apply(_a5, __spreadArray4([context, fn, thisArg], __read4(args), false));
5325
- };
5326
- ContextAPI2.prototype.bind = function(context, target) {
5327
- return this._getContextManager().bind(context, target);
5328
- };
5329
- ContextAPI2.prototype._getContextManager = function() {
5330
- return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
5331
- };
5332
- ContextAPI2.prototype.disable = function() {
5333
- this._getContextManager().disable();
5334
- unregisterGlobal(API_NAME2, DiagAPI.instance());
5335
- };
5336
- return ContextAPI2;
5337
- }()
5338
- );
5339
-
5340
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js
5341
- var TraceFlags;
5342
- (function(TraceFlags2) {
5343
- TraceFlags2[TraceFlags2["NONE"] = 0] = "NONE";
5344
- TraceFlags2[TraceFlags2["SAMPLED"] = 1] = "SAMPLED";
5345
- })(TraceFlags || (TraceFlags = {}));
5346
-
5347
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js
5348
- var INVALID_SPANID = "0000000000000000";
5349
- var INVALID_TRACEID = "00000000000000000000000000000000";
5350
- var INVALID_SPAN_CONTEXT = {
5351
- traceId: INVALID_TRACEID,
5352
- spanId: INVALID_SPANID,
5353
- traceFlags: TraceFlags.NONE
5354
- };
5355
-
5356
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js
5357
- var NonRecordingSpan = (
5358
- /** @class */
5359
- function() {
5360
- function NonRecordingSpan2(_spanContext) {
5361
- if (_spanContext === void 0) {
5362
- _spanContext = INVALID_SPAN_CONTEXT;
5363
- }
5364
- this._spanContext = _spanContext;
5365
- }
5366
- NonRecordingSpan2.prototype.spanContext = function() {
5367
- return this._spanContext;
5368
- };
5369
- NonRecordingSpan2.prototype.setAttribute = function(_key, _value) {
5370
- return this;
5371
- };
5372
- NonRecordingSpan2.prototype.setAttributes = function(_attributes) {
5373
- return this;
5374
- };
5375
- NonRecordingSpan2.prototype.addEvent = function(_name, _attributes) {
5376
- return this;
5377
- };
5378
- NonRecordingSpan2.prototype.addLink = function(_link) {
5379
- return this;
5380
- };
5381
- NonRecordingSpan2.prototype.addLinks = function(_links) {
5382
- return this;
5383
- };
5384
- NonRecordingSpan2.prototype.setStatus = function(_status) {
5385
- return this;
5386
- };
5387
- NonRecordingSpan2.prototype.updateName = function(_name) {
5388
- return this;
5389
- };
5390
- NonRecordingSpan2.prototype.end = function(_endTime) {
5391
- };
5392
- NonRecordingSpan2.prototype.isRecording = function() {
5393
- return false;
5394
- };
5395
- NonRecordingSpan2.prototype.recordException = function(_exception, _time) {
5396
- };
5397
- return NonRecordingSpan2;
5398
- }()
5399
- );
5400
-
5401
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js
5402
- var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
5403
- function getSpan(context) {
5404
- return context.getValue(SPAN_KEY) || void 0;
5405
- }
5406
- function getActiveSpan() {
5407
- return getSpan(ContextAPI.getInstance().active());
5408
- }
5409
- function setSpan(context, span) {
5410
- return context.setValue(SPAN_KEY, span);
5411
- }
5412
- function deleteSpan(context) {
5413
- return context.deleteValue(SPAN_KEY);
5414
- }
5415
- function setSpanContext(context, spanContext) {
5416
- return setSpan(context, new NonRecordingSpan(spanContext));
5417
- }
5418
- function getSpanContext(context) {
5419
- var _a5;
5420
- return (_a5 = getSpan(context)) === null || _a5 === void 0 ? void 0 : _a5.spanContext();
5421
- }
5422
-
5423
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
5424
- var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
5425
- var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
5426
- function isValidTraceId(traceId) {
5427
- return VALID_TRACEID_REGEX.test(traceId) && traceId !== INVALID_TRACEID;
5428
- }
5429
- function isValidSpanId(spanId) {
5430
- return VALID_SPANID_REGEX.test(spanId) && spanId !== INVALID_SPANID;
5431
- }
5432
- function isSpanContextValid(spanContext) {
5433
- return isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);
5434
- }
5435
- function wrapSpanContext(spanContext) {
5436
- return new NonRecordingSpan(spanContext);
5437
- }
5438
-
5439
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js
5440
- var contextApi = ContextAPI.getInstance();
5441
- var NoopTracer = (
5442
- /** @class */
5443
- function() {
5444
- function NoopTracer2() {
5445
- }
5446
- NoopTracer2.prototype.startSpan = function(name, options, context) {
5447
- if (context === void 0) {
5448
- context = contextApi.active();
5449
- }
5450
- var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
5451
- if (root) {
5452
- return new NonRecordingSpan();
5453
- }
5454
- var parentFromContext = context && getSpanContext(context);
5455
- if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
5456
- return new NonRecordingSpan(parentFromContext);
5457
- } else {
5458
- return new NonRecordingSpan();
5459
- }
5460
- };
5461
- NoopTracer2.prototype.startActiveSpan = function(name, arg2, arg3, arg4) {
5462
- var opts;
5463
- var ctx;
5464
- var fn;
5465
- if (arguments.length < 2) {
5466
- return;
5467
- } else if (arguments.length === 2) {
5468
- fn = arg2;
5469
- } else if (arguments.length === 3) {
5470
- opts = arg2;
5471
- fn = arg3;
5472
- } else {
5473
- opts = arg2;
5474
- ctx = arg3;
5475
- fn = arg4;
5476
- }
5477
- var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
5478
- var span = this.startSpan(name, opts, parentContext);
5479
- var contextWithSpanSet = setSpan(parentContext, span);
5480
- return contextApi.with(contextWithSpanSet, fn, void 0, span);
5481
- };
5482
- return NoopTracer2;
5483
- }()
5484
- );
5485
- function isSpanContext(spanContext) {
5486
- return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
5487
- }
5488
-
5489
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js
5490
- var NOOP_TRACER = new NoopTracer();
5491
- var ProxyTracer = (
5492
- /** @class */
5493
- function() {
5494
- function ProxyTracer2(_provider, name, version, options) {
5495
- this._provider = _provider;
5496
- this.name = name;
5497
- this.version = version;
5498
- this.options = options;
5499
- }
5500
- ProxyTracer2.prototype.startSpan = function(name, options, context) {
5501
- return this._getTracer().startSpan(name, options, context);
5502
- };
5503
- ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
5504
- var tracer2 = this._getTracer();
5505
- return Reflect.apply(tracer2.startActiveSpan, tracer2, arguments);
5506
- };
5507
- ProxyTracer2.prototype._getTracer = function() {
5508
- if (this._delegate) {
5509
- return this._delegate;
5510
- }
5511
- var tracer2 = this._provider.getDelegateTracer(this.name, this.version, this.options);
5512
- if (!tracer2) {
5513
- return NOOP_TRACER;
5514
- }
5515
- this._delegate = tracer2;
5516
- return this._delegate;
5517
- };
5518
- return ProxyTracer2;
5519
- }()
5520
- );
5521
-
5522
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js
5523
- var NoopTracerProvider = (
5524
- /** @class */
5525
- function() {
5526
- function NoopTracerProvider2() {
5527
- }
5528
- NoopTracerProvider2.prototype.getTracer = function(_name, _version, _options) {
5529
- return new NoopTracer();
5530
- };
5531
- return NoopTracerProvider2;
5532
- }()
5533
- );
5534
-
5535
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js
5536
- var NOOP_TRACER_PROVIDER = new NoopTracerProvider();
5537
- var ProxyTracerProvider = (
5538
- /** @class */
5539
- function() {
5540
- function ProxyTracerProvider2() {
5541
- }
5542
- ProxyTracerProvider2.prototype.getTracer = function(name, version, options) {
5543
- var _a5;
5544
- return (_a5 = this.getDelegateTracer(name, version, options)) !== null && _a5 !== void 0 ? _a5 : new ProxyTracer(this, name, version, options);
5545
- };
5546
- ProxyTracerProvider2.prototype.getDelegate = function() {
5547
- var _a5;
5548
- return (_a5 = this._delegate) !== null && _a5 !== void 0 ? _a5 : NOOP_TRACER_PROVIDER;
5549
- };
5550
- ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
5551
- this._delegate = delegate;
5552
- };
5553
- ProxyTracerProvider2.prototype.getDelegateTracer = function(name, version, options) {
5554
- var _a5;
5555
- return (_a5 = this._delegate) === null || _a5 === void 0 ? void 0 : _a5.getTracer(name, version, options);
5556
- };
5557
- return ProxyTracerProvider2;
5558
- }()
5559
- );
5560
-
5561
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/trace.js
5562
- var API_NAME3 = "trace";
5563
- var TraceAPI = (
5564
- /** @class */
5565
- function() {
5566
- function TraceAPI2() {
5567
- this._proxyTracerProvider = new ProxyTracerProvider();
5568
- this.wrapSpanContext = wrapSpanContext;
5569
- this.isSpanContextValid = isSpanContextValid;
5570
- this.deleteSpan = deleteSpan;
5571
- this.getSpan = getSpan;
5572
- this.getActiveSpan = getActiveSpan;
5573
- this.getSpanContext = getSpanContext;
5574
- this.setSpan = setSpan;
5575
- this.setSpanContext = setSpanContext;
5576
- }
5577
- TraceAPI2.getInstance = function() {
5578
- if (!this._instance) {
5579
- this._instance = new TraceAPI2();
5580
- }
5581
- return this._instance;
5582
- };
5583
- TraceAPI2.prototype.setGlobalTracerProvider = function(provider) {
5584
- var success = registerGlobal(API_NAME3, this._proxyTracerProvider, DiagAPI.instance());
5585
- if (success) {
5586
- this._proxyTracerProvider.setDelegate(provider);
5587
- }
5588
- return success;
5589
- };
5590
- TraceAPI2.prototype.getTracerProvider = function() {
5591
- return getGlobal(API_NAME3) || this._proxyTracerProvider;
5592
- };
5593
- TraceAPI2.prototype.getTracer = function(name, version) {
5594
- return this.getTracerProvider().getTracer(name, version);
5595
- };
5596
- TraceAPI2.prototype.disable = function() {
5597
- unregisterGlobal(API_NAME3, DiagAPI.instance());
5598
- this._proxyTracerProvider = new ProxyTracerProvider();
5599
- };
5600
- return TraceAPI2;
5601
- }()
5602
- );
5603
-
5604
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace-api.js
5605
- var trace = TraceAPI.getInstance();
5606
-
5607
- // ../shared/dist/esm/utils/telemetry.js
5608
- var tracer = trace.getTracer("stack-tracer");
5609
- async function traceSpan(optionsOrDescription, fn) {
5610
- let options = typeof optionsOrDescription === "string" ? { description: optionsOrDescription } : optionsOrDescription;
5611
- return await tracer.startActiveSpan(`STACK: ${options.description}`, async (span) => {
5612
- if (options.attributes) for (const [key, value] of Object.entries(options.attributes)) span.setAttribute(key, value);
5613
- try {
5614
- return await fn(span);
5615
- } finally {
5616
- span.end();
5617
- }
5618
- });
5619
- }
5620
-
5621
- // ../shared/dist/esm/known-errors.js
5622
- var KnownError = class extends StatusError {
5623
- constructor(statusCode, humanReadableMessage, details) {
5624
- super(statusCode, humanReadableMessage);
5625
- this.statusCode = statusCode;
5626
- this.humanReadableMessage = humanReadableMessage;
5627
- this.details = details;
5628
- this.__stackKnownErrorBrand = "stack-known-error-brand-sentinel";
5629
- this.name = "KnownError";
5630
- }
5631
- static isKnownError(error) {
5632
- return typeof error === "object" && error !== null && "__stackKnownErrorBrand" in error && error.__stackKnownErrorBrand === "stack-known-error-brand-sentinel";
5633
- }
5634
- getBody() {
5635
- return new TextEncoder().encode(JSON.stringify(this.toDescriptiveJson(), void 0, 2));
5636
- }
5637
- getHeaders() {
5638
- return {
5639
- "Content-Type": ["application/json; charset=utf-8"],
5640
- "X-Stack-Known-Error": [this.errorCode],
5641
- "X-Hexclave-Known-Error": [this.errorCode]
5642
- };
5643
- }
5644
- toDescriptiveJson() {
5645
- return {
5646
- code: this.errorCode,
5647
- ...this.details ? { details: this.details } : {},
5648
- error: this.humanReadableMessage
5649
- };
5650
- }
5651
- get errorCode() {
5652
- return this.constructor.errorCode ?? throwErr(`Can't find error code for this KnownError. Is its constructor a KnownErrorConstructor? ${this}`);
5653
- }
5654
- static constructorArgsFromJson(json) {
5655
- return [
5656
- 400,
5657
- json.message,
5658
- json
5659
- ];
5660
- }
5661
- static fromJson(json) {
5662
- for (const [_, KnownErrorType] of Object.entries(KnownErrors)) if (json.code === KnownErrorType.prototype.errorCode) return new KnownErrorType(...KnownErrorType.constructorArgsFromJson(json));
5663
- throw new Error(`An error occurred. Please update your version of the Hexclave SDK. ${json.code}: ${json.message}`);
5664
- }
5665
- };
5666
- function createKnownErrorConstructor(SuperClass, errorCode, create, constructorArgsFromJson) {
5667
- const createFn = create === "inherit" ? identityArgs : create;
5668
- const constructorArgsFromJsonFn = constructorArgsFromJson === "inherit" ? SuperClass.constructorArgsFromJson : constructorArgsFromJson;
5669
- const _KnownErrorImpl = class _KnownErrorImpl extends SuperClass {
5670
- constructor(...args) {
5671
- super(...createFn(...args));
5672
- this.name = `KnownError<${errorCode}>`;
5673
- this.constructorArgs = args;
5674
- }
5675
- static constructorArgsFromJson(json) {
5676
- return constructorArgsFromJsonFn(json.details);
5677
- }
5678
- static isInstance(error) {
5679
- if (!KnownError.isKnownError(error)) return false;
5680
- let current = error;
5681
- while (true) {
5682
- current = Object.getPrototypeOf(current);
5683
- if (!current) break;
5684
- if ("errorCode" in current.constructor && current.constructor.errorCode === errorCode) return true;
5685
- }
5686
- return false;
5687
- }
5688
- };
5689
- _KnownErrorImpl.errorCode = errorCode;
5690
- let KnownErrorImpl = _KnownErrorImpl;
5691
- return KnownErrorImpl;
5692
- }
5693
- var UnsupportedError = createKnownErrorConstructor(KnownError, "UNSUPPORTED_ERROR", (originalErrorCode) => [
5694
- 500,
5695
- `An error occurred that is not currently supported (possibly because it was added in a version of Stack that is newer than this client). The original unsupported error code was: ${originalErrorCode}`,
5696
- { originalErrorCode }
5697
- ], (json) => [json?.originalErrorCode ?? throwErr("originalErrorCode not found in UnsupportedError details")]);
5698
- var BodyParsingError = createKnownErrorConstructor(KnownError, "BODY_PARSING_ERROR", (message2) => [400, message2], (json) => [json.message]);
5699
- var SchemaError = createKnownErrorConstructor(KnownError, "SCHEMA_ERROR", (message2) => [
5700
- 400,
5701
- message2 || throwErr("SchemaError requires a message"),
5702
- { message: message2 }
5703
- ], (json) => [json.message]);
5704
- var AllOverloadsFailed = createKnownErrorConstructor(KnownError, "ALL_OVERLOADS_FAILED", (overloadErrors) => [
5705
- 400,
5706
- deindent`
5707
- This endpoint has multiple overloads, but they all failed to process the request.
5708
-
5709
- ${overloadErrors.map((e40, i) => deindent`
5710
- Overload ${i + 1}: ${JSON.stringify(e40, void 0, 2)}
5711
- `).join("\n\n")}
5712
- `,
5713
- { overload_errors: overloadErrors }
5714
- ], (json) => [json?.overload_errors ?? throwErr("overload_errors not found in AllOverloadsFailed details")]);
5715
- var ProjectAuthenticationError = createKnownErrorConstructor(KnownError, "PROJECT_AUTHENTICATION_ERROR", "inherit", "inherit");
5716
- var InvalidProjectAuthentication = createKnownErrorConstructor(ProjectAuthenticationError, "INVALID_PROJECT_AUTHENTICATION", "inherit", "inherit");
5717
- var ProjectKeyWithoutAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "PROJECT_KEY_WITHOUT_ACCESS_TYPE", () => [400, "Either an API key or an admin access token was provided, but the x-hexclave-access-type header is missing. Set it to 'client', 'server', or 'admin' as appropriate. (The legacy x-stack-access-type header is also accepted.)"], () => []);
5718
- var InvalidAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_ACCESS_TYPE", (accessType) => [400, `The x-hexclave-access-type header must be 'client', 'server', or 'admin', but was '${accessType}'. (The legacy x-stack-access-type header is also accepted.)`], (json) => [json?.accessType ?? throwErr("accessType not found in InvalidAccessType details")]);
5719
- var AccessTypeWithoutProjectId = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_WITHOUT_PROJECT_ID", (accessType) => [
5720
- 400,
5721
- deindent`
5722
- The x-hexclave-access-type header was '${accessType}', but the x-hexclave-project-id header was not provided. (The legacy x-stack-access-type and x-stack-project-id headers are also accepted.)
5723
-
5724
- For more information, see the docs on REST API authentication: https://docs.hexclave.com/api/overview#authentication
5725
- `,
5726
- { request_type: accessType }
5727
- ], (json) => [json.request_type]);
5728
- var AccessTypeRequired = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_REQUIRED", () => [400, deindent`
5729
- You must specify an access level for this Hexclave project. Make sure project API keys are provided (eg. x-hexclave-publishable-client-key) and you set the x-hexclave-access-type header to 'client', 'server', or 'admin'. (The legacy x-stack-* equivalents are also accepted.)
5730
-
5731
- For more information, see the docs on REST API authentication: https://docs.hexclave.com/api/overview#authentication
5732
- `], () => []);
5733
- var InsufficientAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "INSUFFICIENT_ACCESS_TYPE", (actualAccessType, allowedAccessTypes) => [
5734
- 401,
5735
- `The x-hexclave-access-type header must be ${allowedAccessTypes.map((s8) => `'${s8}'`).join(" or ")}, but was '${actualAccessType}'. (The legacy x-stack-access-type header is also accepted.)`,
5736
- {
5737
- actual_access_type: actualAccessType,
5738
- allowed_access_types: allowedAccessTypes
5739
- }
5740
- ], (json) => [json.actual_access_type, json.allowed_access_types]);
5741
- var InvalidPublishableClientKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_PUBLISHABLE_CLIENT_KEY", (projectId) => [
5742
- 401,
5743
- `The publishable key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
5744
- { project_id: projectId }
5745
- ], (json) => [json.project_id]);
5746
- var InvalidSecretServerKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SECRET_SERVER_KEY", (projectId) => [
5747
- 401,
5748
- `The secret server key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
5749
- { project_id: projectId }
5750
- ], (json) => [json.project_id]);
5751
- var InvalidSuperSecretAdminKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SUPER_SECRET_ADMIN_KEY", (projectId) => [
5752
- 401,
5753
- `The super secret admin key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
5754
- { project_id: projectId }
5755
- ], (json) => [json.project_id]);
5756
- var InvalidAdminAccessToken = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_ADMIN_ACCESS_TOKEN", "inherit", "inherit");
5757
- var UnparsableAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "UNPARSABLE_ADMIN_ACCESS_TOKEN", () => [401, "Admin access token is not parsable."], () => []);
5758
- var AdminAccessTokenExpired = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_EXPIRED", (expiredAt) => [
5759
- 401,
5760
- `Admin access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)` : ""}`,
5761
- { expired_at_millis: expiredAt?.getTime() ?? null }
5762
- ], (json) => [json.expired_at_millis ? new Date(json.expired_at_millis) : void 0]);
5763
- var InvalidProjectForAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "INVALID_PROJECT_FOR_ADMIN_ACCESS_TOKEN", () => [401, "Admin access tokens must be created on the internal project."], () => []);
5764
- var AdminAccessTokenIsNotAdmin = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_IS_NOT_ADMIN", () => [401, "Admin access token does not have the required permissions to access this project."], () => []);
5765
- var ProjectAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationError, "PROJECT_AUTHENTICATION_REQUIRED", "inherit", "inherit");
5766
- var ClientAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_AUTHENTICATION_REQUIRED", () => [401, "The publishable client key must be provided."], () => []);
5767
- var PublishableClientKeyRequiredForProject = createKnownErrorConstructor(ProjectAuthenticationRequired, "PUBLISHABLE_CLIENT_KEY_REQUIRED_FOR_PROJECT", (projectId) => [
5768
- 401,
5769
- "Publishable client keys are required for this project. Create one in Project Keys, or disable this requirement there to allow keyless client access.",
5770
- { project_id: projectId ?? null }
5771
- ], (json) => [json.project_id ?? void 0]);
5772
- var ServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "SERVER_AUTHENTICATION_REQUIRED", () => [401, "The secret server key must be provided."], () => []);
5773
- var ClientOrServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_SERVER_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the secret server key must be provided."], () => []);
5774
- var ClientOrAdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_ADMIN_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the super secret admin key must be provided."], () => []);
5775
- var ClientOrServerOrAdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_SERVER_OR_ADMIN_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key, the secret server key, or the super secret admin key must be provided."], () => []);
5776
- var AdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "ADMIN_AUTHENTICATION_REQUIRED", () => [401, "The super secret admin key must be provided."], () => []);
5777
- var ExpectedInternalProject = createKnownErrorConstructor(ProjectAuthenticationError, "EXPECTED_INTERNAL_PROJECT", () => [401, "The project ID is expected to be internal."], () => []);
5778
- var SessionAuthenticationError = createKnownErrorConstructor(KnownError, "SESSION_AUTHENTICATION_ERROR", "inherit", "inherit");
5779
- var InvalidSessionAuthentication = createKnownErrorConstructor(SessionAuthenticationError, "INVALID_SESSION_AUTHENTICATION", "inherit", "inherit");
5780
- var InvalidAccessToken = createKnownErrorConstructor(InvalidSessionAuthentication, "INVALID_ACCESS_TOKEN", "inherit", "inherit");
5781
- var UnparsableAccessToken = createKnownErrorConstructor(InvalidAccessToken, "UNPARSABLE_ACCESS_TOKEN", () => [401, "Access token is not parsable."], () => []);
5782
- var AccessTokenExpired = createKnownErrorConstructor(InvalidAccessToken, "ACCESS_TOKEN_EXPIRED", (expiredAt, projectId, userId, refreshTokenId) => [
5783
- 401,
5784
- deindent`
5785
- Access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)` : ""}${projectId ? ` Project ID: ${projectId}.` : ""}${userId ? ` User ID: ${userId}.` : ""}${refreshTokenId ? ` Refresh token ID: ${refreshTokenId}.` : ""}
5786
-
5787
- Debug info: Most likely, you fetched the access token before it expired (for example, in a server component, pre-rendered page, or on page load), but then didn't refresh it before it expired. If this is the case, and you're using the SDK, make sure you call getAccessToken() every time you need to use the access token. If you're not using the SDK, make sure you refresh the access token with the refresh endpoint.
5788
- `,
5789
- {
5790
- expired_at_millis: expiredAt?.getTime() ?? null,
5791
- project_id: projectId ?? null,
5792
- user_id: userId ?? null,
5793
- refresh_token_id: refreshTokenId ?? null
5794
- }
5795
- ], (json) => [
5796
- json.expired_at_millis ? new Date(json.expired_at_millis) : void 0,
5797
- json.project_id ?? void 0,
5798
- json.user_id ?? void 0,
5799
- json.refresh_token_id ?? void 0
5800
- ]);
5801
- var InvalidProjectForAccessToken = createKnownErrorConstructor(InvalidAccessToken, "INVALID_PROJECT_FOR_ACCESS_TOKEN", (expectedProjectId, actualProjectId) => [
5802
- 401,
5803
- `Access token not valid for this project. Expected project ID ${JSON.stringify(expectedProjectId)}, but the token is for project ID ${JSON.stringify(actualProjectId)}.`,
5804
- {
5805
- expected_project_id: expectedProjectId,
5806
- actual_project_id: actualProjectId
5807
- }
5808
- ], (json) => [json.expected_project_id, json.actual_project_id]);
5809
- var RefreshTokenError = createKnownErrorConstructor(KnownError, "REFRESH_TOKEN_ERROR", "inherit", "inherit");
5810
- var RefreshTokenNotFoundOrExpired = createKnownErrorConstructor(RefreshTokenError, "REFRESH_TOKEN_NOT_FOUND_OR_EXPIRED", () => [401, "Refresh token not found for this project, or the session has expired/been revoked."], () => []);
5811
- var CannotDeleteCurrentSession = createKnownErrorConstructor(RefreshTokenError, "CANNOT_DELETE_CURRENT_SESSION", () => [400, "Cannot delete the current session."], () => []);
5812
- var ProviderRejected = createKnownErrorConstructor(RefreshTokenError, "PROVIDER_REJECTED", () => [401, "The provider refused to refresh their token. This usually means that the provider used to authenticate the user no longer regards this session as valid, and the user must re-authenticate."], () => []);
5813
- var UserWithEmailAlreadyExists = createKnownErrorConstructor(KnownError, "USER_EMAIL_ALREADY_EXISTS", (email, wouldWorkIfEmailWasVerified = false) => [
5814
- 409,
5815
- `A user with email ${JSON.stringify(email)} already exists${wouldWorkIfEmailWasVerified ? " but the email is not verified. Please login to your existing account with the method you used to sign up, and then verify your email to sign in with this login method." : "."}`,
5816
- {
5817
- email,
5818
- would_work_if_email_was_verified: wouldWorkIfEmailWasVerified
5819
- }
5820
- ], (json) => [json.email, json.would_work_if_email_was_verified ?? false]);
5821
- var EmailNotVerified = createKnownErrorConstructor(KnownError, "EMAIL_NOT_VERIFIED", () => [400, "The email is not verified."], () => []);
5822
- var CannotGetOwnUserWithoutUser = createKnownErrorConstructor(KnownError, "CANNOT_GET_OWN_USER_WITHOUT_USER", () => [400, "You have specified 'me' as a userId, but did not provide authentication for a user."], () => []);
5823
- var UserIdDoesNotExist = createKnownErrorConstructor(KnownError, "USER_ID_DOES_NOT_EXIST", (userId) => [
5824
- 400,
5825
- `The given user with the ID ${userId} does not exist.`,
5826
- { user_id: userId }
5827
- ], (json) => [json.user_id]);
5828
- var UserNotFound = createKnownErrorConstructor(KnownError, "USER_NOT_FOUND", () => [404, "User not found."], () => []);
5829
- var RestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
5830
- 403,
5831
- `The user in the access token is in restricted state. Reason: ${restrictedReason.type}. Please pass the X-Stack-Allow-Restricted-User header if this is intended.`,
5832
- { restricted_reason: restrictedReason }
5833
- ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
5834
- var ProjectNotFound = createKnownErrorConstructor(KnownError, "PROJECT_NOT_FOUND", (projectId) => {
5835
- if (typeof projectId !== "string") throw new HexclaveAssertionError("projectId of KnownErrors.ProjectNotFound must be a string");
5836
- return [
5837
- 404,
5838
- `Project ${projectId} not found or is not accessible with the current user.`,
5839
- { project_id: projectId }
5840
- ];
5841
- }, (json) => [json.project_id]);
5842
- var CurrentProjectNotFound = createKnownErrorConstructor(KnownError, "CURRENT_PROJECT_NOT_FOUND", (projectId) => [
5843
- 400,
5844
- `The current project with ID ${projectId} was not found. Please check the value of the x-hexclave-project-id header. (The legacy x-stack-project-id header is also accepted.)`,
5845
- { project_id: projectId }
5846
- ], (json) => [json.project_id]);
5847
- var BranchDoesNotExist = createKnownErrorConstructor(KnownError, "BRANCH_DOES_NOT_EXIST", (branchId) => [
5848
- 400,
5849
- `The branch with ID ${branchId} does not exist.`,
5850
- { branch_id: branchId }
5851
- ], (json) => [json.branch_id]);
5852
- var SignUpNotEnabled = createKnownErrorConstructor(KnownError, "SIGN_UP_NOT_ENABLED", () => [400, "Creation of new accounts is not enabled for this project. Please ask the project owner to enable it."], () => []);
5853
- var SignUpRejected = createKnownErrorConstructor(KnownError, "SIGN_UP_REJECTED", (message2) => [
5854
- 403,
5855
- message2 ?? "Your sign up was rejected by an administrator's sign-up rule.",
5856
- { message: message2 ?? "Your sign up was rejected by an administrator's sign-up rule." }
5857
- ], (json) => [json.message]);
5858
- var BotChallengeRequired = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_REQUIRED", () => [409, "An additional bot challenge is required before sign-up can continue."], () => []);
5859
- var BotChallengeFailed = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_FAILED", (message2) => [
5860
- 400,
5861
- message2,
5862
- { message: message2 }
5863
- ], (json) => [json.message]);
5864
- var PasswordAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSWORD_AUTHENTICATION_NOT_ENABLED", () => [400, "Password authentication is not enabled for this project."], () => []);
5865
- var DataVaultStoreDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_DOES_NOT_EXIST", (storeId) => [
5866
- 400,
5867
- `Data vault store with ID ${storeId} does not exist.`,
5868
- { store_id: storeId }
5869
- ], (json) => [json.store_id]);
5870
- var DataVaultStoreHashedKeyDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_HASHED_KEY_DOES_NOT_EXIST", (storeId, hashedKey) => [
5871
- 400,
5872
- `Data vault store with ID ${storeId} does not contain a key with hash ${hashedKey}.`,
5873
- {
5874
- store_id: storeId,
5875
- hashed_key: hashedKey
5876
- }
5877
- ], (json) => [json.store_id, json.hashed_key]);
5878
- var PasskeyAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_NOT_ENABLED", () => [400, "Passkey authentication is not enabled for this project."], () => []);
5879
- var AnonymousAccountsNotEnabled = createKnownErrorConstructor(KnownError, "ANONYMOUS_ACCOUNTS_NOT_ENABLED", () => [400, "Anonymous accounts are not enabled for this project."], () => []);
5880
- var AnonymousAuthenticationNotAllowed = createKnownErrorConstructor(KnownError, "ANONYMOUS_AUTHENTICATION_NOT_ALLOWED", () => [401, "X-Stack-Access-Token is for an anonymous user, but anonymous users are not enabled. Set the X-Stack-Allow-Anonymous-User header of this request to 'true' to allow anonymous users."], () => []);
5881
- var EmailPasswordMismatch = createKnownErrorConstructor(KnownError, "EMAIL_PASSWORD_MISMATCH", () => [400, "Wrong e-mail or password."], () => []);
5882
- var RedirectUrlNotWhitelisted = createKnownErrorConstructor(KnownError, "REDIRECT_URL_NOT_WHITELISTED", (redirectUrl) => [
5883
- 400,
5884
- "Redirect URL not whitelisted. Did you forget to add this domain to the trusted domains list on the Hexclave dashboard?",
5885
- redirectUrl === void 0 ? void 0 : { redirect_url: redirectUrl }
5886
- ], (json) => [json?.redirect_url]);
5887
- var PasswordRequirementsNotMet = createKnownErrorConstructor(KnownError, "PASSWORD_REQUIREMENTS_NOT_MET", "inherit", "inherit");
5888
- var PasswordTooShort = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_SHORT", (minLength) => [
5889
- 400,
5890
- `Password too short. Minimum length is ${minLength}.`,
5891
- { min_length: minLength }
5892
- ], (json) => [json?.min_length ?? throwErr("min_length not found in PasswordTooShort details")]);
5893
- var PasswordTooLong = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_LONG", (maxLength) => [
5894
- 400,
5895
- `Password too long. Maximum length is ${maxLength}.`,
5896
- { maxLength }
5897
- ], (json) => [json?.maxLength ?? throwErr("maxLength not found in PasswordTooLong details")]);
5898
- var UserDoesNotHavePassword = createKnownErrorConstructor(KnownError, "USER_DOES_NOT_HAVE_PASSWORD", () => [400, "This user does not have password authentication enabled."], () => []);
5899
- var VerificationCodeError = createKnownErrorConstructor(KnownError, "VERIFICATION_ERROR", "inherit", "inherit");
5900
- var VerificationCodeNotFound = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_NOT_FOUND", () => [404, "The verification code does not exist for this project."], () => []);
5901
- var VerificationCodeExpired = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_EXPIRED", () => [400, "The verification code has expired."], () => []);
5902
- var VerificationCodeAlreadyUsed = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_ALREADY_USED", () => [409, "The verification link has already been used."], () => []);
5903
- var VerificationCodeMaxAttemptsReached = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_MAX_ATTEMPTS_REACHED", () => [400, "The verification code nonce has reached the maximum number of attempts. This code is not valid anymore."], () => []);
5904
- var PasswordConfirmationMismatch = createKnownErrorConstructor(KnownError, "PASSWORD_CONFIRMATION_MISMATCH", () => [400, "Passwords do not match."], () => []);
5905
- var EmailAlreadyVerified = createKnownErrorConstructor(KnownError, "EMAIL_ALREADY_VERIFIED", () => [409, "The e-mail is already verified."], () => []);
5906
- var EmailNotAssociatedWithUser = createKnownErrorConstructor(KnownError, "EMAIL_NOT_ASSOCIATED_WITH_USER", () => [400, "The e-mail is not associated with a user that could log in with that e-mail."], () => []);
5907
- var EmailIsNotPrimaryEmail = createKnownErrorConstructor(KnownError, "EMAIL_IS_NOT_PRIMARY_EMAIL", (email, primaryEmail) => [
5908
- 400,
5909
- `The given e-mail (${email}) must equal the user's primary e-mail (${primaryEmail}).`,
5910
- {
5911
- email,
5912
- primary_email: primaryEmail
5913
- }
5914
- ], (json) => [json.email, json.primary_email]);
5915
- var PasskeyRegistrationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_REGISTRATION_FAILED", (message2) => [400, message2], (json) => [json.message]);
5916
- var PasskeyWebAuthnError = createKnownErrorConstructor(KnownError, "PASSKEY_WEBAUTHN_ERROR", (message2, code) => [
5917
- 400,
5918
- message2,
5919
- {
5920
- message: message2,
5921
- code
5922
- }
5923
- ], (json) => [json.message, json.code]);
5924
- var PasskeyAuthenticationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_FAILED", (message2) => [400, message2], (json) => [json.message]);
5925
- var PermissionNotFound = createKnownErrorConstructor(KnownError, "PERMISSION_NOT_FOUND", (permissionId) => [
5926
- 404,
5927
- `Permission "${permissionId}" not found. Make sure you created it on the dashboard.`,
5928
- { permission_id: permissionId }
5929
- ], (json) => [json.permission_id]);
5930
- var PermissionScopeMismatch = createKnownErrorConstructor(KnownError, "WRONG_PERMISSION_SCOPE", (permissionId, expectedScope, actualScope) => [
5931
- 404,
5932
- `Permission ${JSON.stringify(permissionId)} not found. (It was found for a different scope ${JSON.stringify(actualScope)}, but scope ${JSON.stringify(expectedScope)} was expected.)`,
5933
- {
5934
- permission_id: permissionId,
5935
- expected_scope: expectedScope,
5936
- actual_scope: actualScope
5937
- }
5938
- ], (json) => [
5939
- json.permission_id,
5940
- json.expected_scope,
5941
- json.actual_scope
5942
- ]);
5943
- var ContainedPermissionNotFound = createKnownErrorConstructor(KnownError, "CONTAINED_PERMISSION_NOT_FOUND", (permissionId) => [
5944
- 400,
5945
- `Contained permission with ID "${permissionId}" not found. Make sure you created it on the dashboard.`,
5946
- { permission_id: permissionId }
5947
- ], (json) => [json.permission_id]);
5948
- var TeamNotFound = createKnownErrorConstructor(KnownError, "TEAM_NOT_FOUND", (teamId) => [
5949
- 404,
5950
- `Team ${teamId} not found.`,
5951
- { team_id: teamId }
5952
- ], (json) => [json.team_id]);
5953
- createKnownErrorConstructor(KnownError, "TEAM_ALREADY_EXISTS", (teamId) => [
5954
- 409,
5955
- `Team ${teamId} already exists.`,
5956
- { team_id: teamId }
5957
- ], (json) => [json.team_id]);
5958
- var TeamMembershipNotFound = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_NOT_FOUND", (teamId, userId) => [
5959
- 404,
5960
- `User ${userId} is not found in team ${teamId}.`,
5961
- {
5962
- team_id: teamId,
5963
- user_id: userId
5964
- }
5965
- ], (json) => [json.team_id, json.user_id]);
5966
- var TeamInvitationRestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "TEAM_INVITATION_RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
5967
- 403,
5968
- `Restricted users cannot accept team invitations. Reason: ${restrictedReason.type}. Please complete the onboarding process before accepting team invitations.`,
5969
- { restricted_reason: restrictedReason }
5970
- ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
5971
- var TeamInvitationEmailMismatch = createKnownErrorConstructor(KnownError, "TEAM_INVITATION_EMAIL_MISMATCH", () => [403, "This team invitation was sent to a different email address. Sign in with the invited email, or add and verify that email on your account, then try again."], () => []);
5972
- var EmailTemplateAlreadyExists = createKnownErrorConstructor(KnownError, "EMAIL_TEMPLATE_ALREADY_EXISTS", () => [409, "Email template already exists."], () => []);
5973
- var OAuthConnectionNotConnectedToUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_NOT_CONNECTED_TO_USER", () => [400, "The OAuth connection is not connected to any user."], () => []);
5974
- var OAuthConnectionAlreadyConnectedToAnotherUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_ALREADY_CONNECTED_TO_ANOTHER_USER", () => [409, "The OAuth connection is already connected to another user."], () => []);
5975
- var OAuthConnectionDoesNotHaveRequiredScope = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_DOES_NOT_HAVE_REQUIRED_SCOPE", () => [400, "The OAuth connection does not have the required scope."], () => []);
5976
- var OAuthAccessTokenNotAvailable = createKnownErrorConstructor(KnownError, "OAUTH_ACCESS_TOKEN_NOT_AVAILABLE", (provider, details) => [
5977
- 400,
5978
- `Failed to retrieve an OAuth access token for the connected account (provider: ${provider}). ${details}`,
5979
- {
5980
- provider,
5981
- details
5982
- }
5983
- ], (json) => [json.provider, json.details]);
5984
- var OAuthExtraScopeNotAvailableWithSharedOAuthKeys = createKnownErrorConstructor(KnownError, "OAUTH_EXTRA_SCOPE_NOT_AVAILABLE_WITH_SHARED_OAUTH_KEYS", () => [400, "Extra scopes are not available with shared OAuth keys. Please add your own OAuth keys on the Hexclave dashboard to use extra scopes."], () => []);
5985
- var OAuthAccessTokenNotAvailableWithSharedOAuthKeys = createKnownErrorConstructor(KnownError, "OAUTH_ACCESS_TOKEN_NOT_AVAILABLE_WITH_SHARED_OAUTH_KEYS", () => [400, "Access tokens are not available with shared OAuth keys. Please add your own OAuth keys on the Hexclave dashboard to use access tokens."], () => []);
5986
- var InvalidOAuthClientIdOrSecret = createKnownErrorConstructor(KnownError, "INVALID_OAUTH_CLIENT_ID_OR_SECRET", (clientId) => [
5987
- 400,
5988
- "The OAuth client ID or secret is invalid. The client ID must be equal to the project ID (potentially with a hash and a branch ID), and the client secret must be a publishable client key.",
5989
- { client_id: clientId ?? null }
5990
- ], (json) => [json.client_id ?? void 0]);
5991
- var InvalidScope = createKnownErrorConstructor(KnownError, "INVALID_SCOPE", (scope) => [400, `The scope "${scope}" is not a valid OAuth scope for Stack.`], (json) => [json.scope]);
5992
- var UserAlreadyConnectedToAnotherOAuthConnection = createKnownErrorConstructor(KnownError, "USER_ALREADY_CONNECTED_TO_ANOTHER_OAUTH_CONNECTION", () => [409, "The user is already connected to another OAuth account. Did you maybe selected the wrong account?"], () => []);
5993
- var OuterOAuthTimeout = createKnownErrorConstructor(KnownError, "OUTER_OAUTH_TIMEOUT", () => [408, "The OAuth flow has timed out. Please sign in again."], () => []);
5994
- var OAuthProviderNotFoundOrNotEnabled = createKnownErrorConstructor(KnownError, "OAUTH_PROVIDER_NOT_FOUND_OR_NOT_ENABLED", () => [400, "The OAuth provider is not found or not enabled."], () => []);
5995
- var AppleBundleIdNotConfigured = createKnownErrorConstructor(KnownError, "APPLE_BUNDLE_ID_NOT_CONFIGURED", () => [400, "Apple Sign In is enabled, but no Bundle IDs are configured. Please add your app's Bundle ID in the Hexclave dashboard under OAuth Providers > Apple > Apple Bundle IDs."], () => []);
5996
- var OAuthProviderAccountIdAlreadyUsedForSignIn = createKnownErrorConstructor(KnownError, "OAUTH_PROVIDER_ACCOUNT_ID_ALREADY_USED_FOR_SIGN_IN", () => [400, `A provider with the same account ID is already used for signing in.`], () => []);
5997
- var MultiFactorAuthenticationRequired = createKnownErrorConstructor(KnownError, "MULTI_FACTOR_AUTHENTICATION_REQUIRED", (attemptCode) => [
5998
- 400,
5999
- `Multi-factor authentication is required for this user.`,
6000
- { attempt_code: attemptCode }
6001
- ], (json) => [json.attempt_code]);
6002
- var InvalidTotpCode = createKnownErrorConstructor(KnownError, "INVALID_TOTP_CODE", () => [400, "The TOTP code is invalid. Please try again."], () => []);
6003
- var UserAuthenticationRequired = createKnownErrorConstructor(KnownError, "USER_AUTHENTICATION_REQUIRED", () => [401, "User authentication required for this endpoint."], () => []);
6004
- var TeamMembershipAlreadyExists = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_ALREADY_EXISTS", () => [409, "Team membership already exists."], () => []);
6005
- var ProjectPermissionRequired = createKnownErrorConstructor(KnownError, "PROJECT_PERMISSION_REQUIRED", (userId, permissionId) => [
6006
- 401,
6007
- `User ${userId} does not have permission ${permissionId}.`,
6008
- {
6009
- user_id: userId,
6010
- permission_id: permissionId
6011
- }
6012
- ], (json) => [json.user_id, json.permission_id]);
6013
- var TeamPermissionRequired = createKnownErrorConstructor(KnownError, "TEAM_PERMISSION_REQUIRED", (teamId, userId, permissionId) => [
6014
- 401,
6015
- `User ${userId} does not have permission ${permissionId} in team ${teamId}.`,
6016
- {
6017
- team_id: teamId,
6018
- user_id: userId,
6019
- permission_id: permissionId
5113
+ ], (json) => [json.user_id, json.permission_id]);
5114
+ var TeamPermissionRequired = createKnownErrorConstructor(KnownError, "TEAM_PERMISSION_REQUIRED", (teamId, userId, permissionId) => [
5115
+ 401,
5116
+ `User ${userId} does not have permission ${permissionId} in team ${teamId}.`,
5117
+ {
5118
+ team_id: teamId,
5119
+ user_id: userId,
5120
+ permission_id: permissionId
6020
5121
  }
6021
5122
  ], (json) => [
6022
5123
  json.team_id,
@@ -6374,49 +5475,6 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6374
5475
  knownErrorCodes.add(KnownError2.errorCode);
6375
5476
  }
6376
5477
 
6377
- // ../shared/dist/esm/utils/bytes.js
6378
- function decodeBase64(input) {
6379
- return new Uint8Array(atob(input).split("").map((char) => char.charCodeAt(0)));
6380
- }
6381
- function isBase64(input) {
6382
- return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(input);
6383
- }
6384
-
6385
- // ../shared/dist/esm/utils/urls.js
6386
- function createUrlIfValid(...args) {
6387
- try {
6388
- return new URL(...args);
6389
- } catch (e40) {
6390
- return null;
6391
- }
6392
- }
6393
- function isValidUrl(url) {
6394
- return !!createUrlIfValid(url);
6395
- }
6396
- function isValidHostname(hostname) {
6397
- if (!hostname || hostname.startsWith(".") || hostname.endsWith(".") || hostname.includes("..")) return false;
6398
- const url = createUrlIfValid(`https://${hostname}`);
6399
- if (!url) return false;
6400
- return url.hostname === hostname;
6401
- }
6402
- function isValidHostnameWithWildcards(hostname) {
6403
- if (!hostname) return false;
6404
- if (!hostname.includes("*")) return isValidHostname(hostname);
6405
- if (hostname.startsWith(".") || hostname.endsWith(".")) return false;
6406
- if (hostname.includes("..")) return false;
6407
- const testHostname = hostname.replace(/\*+/g, "wildcard");
6408
- if (!/^[a-zA-Z0-9.-]+$/.test(testHostname)) return false;
6409
- const segments = hostname.split(/\*+/);
6410
- for (let i = 0; i < segments.length; i++) {
6411
- const segment = segments[i];
6412
- if (segment === "") continue;
6413
- if (i === 0 && segment.startsWith(".")) return false;
6414
- if (i === segments.length - 1 && segment.endsWith(".")) return false;
6415
- if (segment.includes("..")) return false;
6416
- }
6417
- return true;
6418
- }
6419
-
6420
5478
  // ../../node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.esm.js
6421
5479
  var import_property_expr = __toESM(require_property_expr());
6422
5480
  var import_tiny_case = __toESM(require_tiny_case());
@@ -6456,11 +5514,11 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6456
5514
  function toArray(value) {
6457
5515
  return value == null ? [] : [].concat(value);
6458
5516
  }
6459
- var _Symbol$toStringTag4;
5517
+ var _Symbol$toStringTag;
6460
5518
  var _Symbol$hasInstance;
6461
- var _Symbol$toStringTag22;
5519
+ var _Symbol$toStringTag2;
6462
5520
  var strReg = /\$\{\s*(\w+)\s*\}/g;
6463
- _Symbol$toStringTag4 = Symbol.toStringTag;
5521
+ _Symbol$toStringTag = Symbol.toStringTag;
6464
5522
  var ValidationErrorNoStack = class {
6465
5523
  constructor(errorOrErrors, value, field, type) {
6466
5524
  this.name = void 0;
@@ -6471,7 +5529,7 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6471
5529
  this.params = void 0;
6472
5530
  this.errors = void 0;
6473
5531
  this.inner = void 0;
6474
- this[_Symbol$toStringTag4] = "Error";
5532
+ this[_Symbol$toStringTag] = "Error";
6475
5533
  this.name = "ValidationError";
6476
5534
  this.value = value;
6477
5535
  this.path = field;
@@ -6491,7 +5549,7 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6491
5549
  }
6492
5550
  };
6493
5551
  _Symbol$hasInstance = Symbol.hasInstance;
6494
- _Symbol$toStringTag22 = Symbol.toStringTag;
5552
+ _Symbol$toStringTag2 = Symbol.toStringTag;
6495
5553
  var ValidationError = class _ValidationError extends Error {
6496
5554
  static formatError(message2, params) {
6497
5555
  const path = params.label || params.path || "this";
@@ -6518,7 +5576,7 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6518
5576
  this.params = void 0;
6519
5577
  this.errors = [];
6520
5578
  this.inner = [];
6521
- this[_Symbol$toStringTag22] = "Error";
5579
+ this[_Symbol$toStringTag2] = "Error";
6522
5580
  this.name = errorNoStack.name;
6523
5581
  this.message = errorNoStack.message;
6524
5582
  this.type = errorNoStack.type;
@@ -8770,6 +7828,27 @@ attempted value: ${formattedValue}
8770
7828
  }
8771
7829
  ];
8772
7830
 
7831
+ // ../shared/dist/esm/utils/env.js
7832
+ function resolveHexclaveStackEnvVarValue(hexclaveName, stackName, hexclaveValue, stackValue) {
7833
+ if (hexclaveValue && stackValue && hexclaveValue !== stackValue) throw new Error(`Environment variables ${hexclaveName} and ${stackName} are both set to different values. Remove one of them or set them to the same value.`);
7834
+ return hexclaveValue || stackValue || void 0;
7835
+ }
7836
+ function getEnvVarWithHexclaveFallback(name) {
7837
+ if (name.includes("STACK_")) {
7838
+ const hexclaveName = name.replace("STACK_", "HEXCLAVE_");
7839
+ return resolveHexclaveStackEnvVarValue(hexclaveName, name, process.env[hexclaveName], process.env[name]);
7840
+ }
7841
+ if (name.includes("HEXCLAVE_")) {
7842
+ const stackName = name.replace("HEXCLAVE_", "STACK_");
7843
+ return resolveHexclaveStackEnvVarValue(name, stackName, process.env[name], process.env[stackName]);
7844
+ }
7845
+ return process.env[name];
7846
+ }
7847
+ function getProcessEnv(name) {
7848
+ if (typeof process === "undefined" || typeof process.env === "undefined") return;
7849
+ return getEnvVarWithHexclaveFallback(name);
7850
+ }
7851
+
8773
7852
  // ../shared/dist/esm/utils/http.js
8774
7853
  function decodeBasicAuthorizationHeader(value) {
8775
7854
  const [type, encoded, ...rest] = value.split(" ");
@@ -9763,71 +8842,992 @@ attempted value: ${formattedValue}
9763
8842
  diff: yupString().optional()
9764
8843
  });
9765
8844
 
9766
- // ../shared/dist/esm/interface/client-interface.js
9767
- var USER_AGENT;
9768
- if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) USER_AGENT = `oauth4webapi/v3.8.5`;
9769
- var ERR_INVALID_ARG_VALUE = "ERR_INVALID_ARG_VALUE";
9770
- function CodedTypeError(message2, code, cause) {
9771
- const err = new TypeError(message2, { cause });
9772
- Object.assign(err, { code });
9773
- return err;
8845
+ // ../shared/dist/esm/interface/client-interface.js
8846
+ var USER_AGENT;
8847
+ if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) USER_AGENT = `oauth4webapi/v3.8.5`;
8848
+ var ERR_INVALID_ARG_VALUE = "ERR_INVALID_ARG_VALUE";
8849
+ function CodedTypeError(message2, code, cause) {
8850
+ const err = new TypeError(message2, { cause });
8851
+ Object.assign(err, { code });
8852
+ return err;
8853
+ }
8854
+ var allowInsecureRequests = Symbol();
8855
+ var clockSkew = Symbol();
8856
+ var clockTolerance = Symbol();
8857
+ var customFetch = Symbol();
8858
+ var jweDecrypt = Symbol();
8859
+ var encoder = new TextEncoder();
8860
+ var decoder = new TextDecoder();
8861
+ var encodeBase64Url;
8862
+ if (Uint8Array.prototype.toBase64) encodeBase64Url = (input) => {
8863
+ if (input instanceof ArrayBuffer) input = new Uint8Array(input);
8864
+ return input.toBase64({
8865
+ alphabet: "base64url",
8866
+ omitPadding: true
8867
+ });
8868
+ };
8869
+ else {
8870
+ const CHUNK_SIZE = 32768;
8871
+ encodeBase64Url = (input) => {
8872
+ if (input instanceof ArrayBuffer) input = new Uint8Array(input);
8873
+ const arr = [];
8874
+ for (let i = 0; i < input.byteLength; i += CHUNK_SIZE) arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
8875
+ return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
8876
+ };
8877
+ }
8878
+ var decodeBase64Url;
8879
+ if (Uint8Array.fromBase64) decodeBase64Url = (input) => {
8880
+ try {
8881
+ return Uint8Array.fromBase64(input, { alphabet: "base64url" });
8882
+ } catch (cause) {
8883
+ throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
8884
+ }
8885
+ };
8886
+ else decodeBase64Url = (input) => {
8887
+ try {
8888
+ const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
8889
+ const bytes = new Uint8Array(binary.length);
8890
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
8891
+ return bytes;
8892
+ } catch (cause) {
8893
+ throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
8894
+ }
8895
+ };
8896
+ var URLParse = URL.parse ? (url, base) => URL.parse(url, base) : (url, base) => {
8897
+ try {
8898
+ return new URL(url, base);
8899
+ } catch {
8900
+ return null;
8901
+ }
8902
+ };
8903
+ var nopkce = Symbol();
8904
+ var expectNoNonce = Symbol();
8905
+ var skipAuthTimeCheck = Symbol();
8906
+ var skipStateCheck = Symbol();
8907
+ var expectNoState = Symbol();
8908
+ var _expectedIssuer = Symbol();
8909
+ var botChallengeKnownErrors = [KnownErrors.BotChallengeRequired, KnownErrors.BotChallengeFailed];
8910
+
8911
+ // ../shared/dist/esm/utils/maps.js
8912
+ var _Symbol$toStringTag3;
8913
+ var _Symbol$toStringTag22;
8914
+ var _Symbol$toStringTag32;
8915
+ var WeakRefIfAvailable = class {
8916
+ constructor(value) {
8917
+ if (typeof WeakRef === "undefined") this._ref = { deref: () => value };
8918
+ else this._ref = new WeakRef(value);
8919
+ }
8920
+ deref() {
8921
+ return this._ref.deref();
8922
+ }
8923
+ };
8924
+ var _a2;
8925
+ var IterableWeakMap = (_a2 = class {
8926
+ constructor(entries) {
8927
+ this[_Symbol$toStringTag3] = "IterableWeakMap";
8928
+ const mappedEntries = entries?.map((e40) => [e40[0], {
8929
+ value: e40[1],
8930
+ keyRef: new WeakRefIfAvailable(e40[0])
8931
+ }]);
8932
+ this._weakMap = new WeakMap(mappedEntries ?? []);
8933
+ this._keyRefs = new Set(mappedEntries?.map((e40) => e40[1].keyRef) ?? []);
8934
+ }
8935
+ get(key) {
8936
+ return this._weakMap.get(key)?.value;
8937
+ }
8938
+ set(key, value) {
8939
+ const updated = {
8940
+ value,
8941
+ keyRef: this._weakMap.get(key)?.keyRef ?? new WeakRefIfAvailable(key)
8942
+ };
8943
+ this._weakMap.set(key, updated);
8944
+ this._keyRefs.add(updated.keyRef);
8945
+ return this;
8946
+ }
8947
+ delete(key) {
8948
+ const res = this._weakMap.get(key);
8949
+ if (res) {
8950
+ this._weakMap.delete(key);
8951
+ this._keyRefs.delete(res.keyRef);
8952
+ return true;
8953
+ }
8954
+ return false;
8955
+ }
8956
+ has(key) {
8957
+ return this._weakMap.has(key) && this._keyRefs.has(this._weakMap.get(key).keyRef);
8958
+ }
8959
+ *[Symbol.iterator]() {
8960
+ for (const keyRef of this._keyRefs) {
8961
+ const key = keyRef.deref();
8962
+ const existing = key ? this._weakMap.get(key) : void 0;
8963
+ if (!key) this._keyRefs.delete(keyRef);
8964
+ else if (existing) yield [key, existing.value];
8965
+ }
8966
+ }
8967
+ }, _Symbol$toStringTag3 = Symbol.toStringTag, _a2);
8968
+ var _a3;
8969
+ var MaybeWeakMap = (_a3 = class {
8970
+ constructor(entries) {
8971
+ this[_Symbol$toStringTag22] = "MaybeWeakMap";
8972
+ const entriesArray = [...entries ?? []];
8973
+ this._primitiveMap = new Map(entriesArray.filter((e40) => !this._isAllowedInWeakMap(e40[0])));
8974
+ this._weakMap = new IterableWeakMap(entriesArray.filter((e40) => this._isAllowedInWeakMap(e40[0])));
8975
+ }
8976
+ _isAllowedInWeakMap(key) {
8977
+ return typeof key === "object" && key !== null || typeof key === "symbol" && Symbol.keyFor(key) === void 0;
8978
+ }
8979
+ get(key) {
8980
+ if (this._isAllowedInWeakMap(key)) return this._weakMap.get(key);
8981
+ else return this._primitiveMap.get(key);
8982
+ }
8983
+ set(key, value) {
8984
+ if (this._isAllowedInWeakMap(key)) this._weakMap.set(key, value);
8985
+ else this._primitiveMap.set(key, value);
8986
+ return this;
8987
+ }
8988
+ delete(key) {
8989
+ if (this._isAllowedInWeakMap(key)) return this._weakMap.delete(key);
8990
+ else return this._primitiveMap.delete(key);
8991
+ }
8992
+ has(key) {
8993
+ if (this._isAllowedInWeakMap(key)) return this._weakMap.has(key);
8994
+ else return this._primitiveMap.has(key);
8995
+ }
8996
+ *[Symbol.iterator]() {
8997
+ yield* this._primitiveMap;
8998
+ yield* this._weakMap;
8999
+ }
9000
+ }, _Symbol$toStringTag22 = Symbol.toStringTag, _a3);
9001
+ var _a4;
9002
+ var DependenciesMap = (_a4 = class {
9003
+ constructor() {
9004
+ this._inner = {
9005
+ map: new MaybeWeakMap(),
9006
+ hasValue: false,
9007
+ value: void 0
9008
+ };
9009
+ this[_Symbol$toStringTag32] = "DependenciesMap";
9010
+ }
9011
+ _valueToResult(inner) {
9012
+ if (inner.hasValue) return Result.ok(inner.value);
9013
+ else return Result.error(void 0);
9014
+ }
9015
+ _unwrapFromInner(dependencies, inner) {
9016
+ if (dependencies.length === 0) return this._valueToResult(inner);
9017
+ else {
9018
+ const [key, ...rest] = dependencies;
9019
+ const newInner = inner.map.get(key);
9020
+ if (!newInner) return Result.error(void 0);
9021
+ return this._unwrapFromInner(rest, newInner);
9022
+ }
9023
+ }
9024
+ _setInInner(dependencies, value, inner) {
9025
+ if (dependencies.length === 0) {
9026
+ const res = this._valueToResult(inner);
9027
+ if (value.status === "ok") {
9028
+ inner.hasValue = true;
9029
+ inner.value = value.data;
9030
+ } else {
9031
+ inner.hasValue = false;
9032
+ inner.value = void 0;
9033
+ }
9034
+ return res;
9035
+ } else {
9036
+ const [key, ...rest] = dependencies;
9037
+ let newInner = inner.map.get(key);
9038
+ if (!newInner) inner.map.set(key, newInner = {
9039
+ map: new MaybeWeakMap(),
9040
+ hasValue: false,
9041
+ value: void 0
9042
+ });
9043
+ return this._setInInner(rest, value, newInner);
9044
+ }
9045
+ }
9046
+ *_iterateInner(dependencies, inner) {
9047
+ if (inner.hasValue) yield [dependencies, inner.value];
9048
+ for (const [key, value] of inner.map) yield* this._iterateInner([...dependencies, key], value);
9049
+ }
9050
+ get(dependencies) {
9051
+ return Result.or(this._unwrapFromInner(dependencies, this._inner), void 0);
9052
+ }
9053
+ set(dependencies, value) {
9054
+ this._setInInner(dependencies, Result.ok(value), this._inner);
9055
+ return this;
9056
+ }
9057
+ delete(dependencies) {
9058
+ return this._setInInner(dependencies, Result.error(void 0), this._inner).status === "ok";
9059
+ }
9060
+ has(dependencies) {
9061
+ return this._unwrapFromInner(dependencies, this._inner).status === "ok";
9062
+ }
9063
+ clear() {
9064
+ this._inner = {
9065
+ map: new MaybeWeakMap(),
9066
+ hasValue: false,
9067
+ value: void 0
9068
+ };
9069
+ }
9070
+ *[Symbol.iterator]() {
9071
+ yield* this._iterateInner([], this._inner);
9072
+ }
9073
+ }, _Symbol$toStringTag32 = Symbol.toStringTag, _a4);
9074
+
9075
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/platform/browser/globalThis.js
9076
+ var _globalThis = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
9077
+
9078
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/version.js
9079
+ var VERSION = "1.9.0";
9080
+
9081
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/semver.js
9082
+ var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
9083
+ function _makeCompatibilityCheck(ownVersion) {
9084
+ var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
9085
+ var rejectedVersions = /* @__PURE__ */ new Set();
9086
+ var myVersionMatch = ownVersion.match(re);
9087
+ if (!myVersionMatch) {
9088
+ return function() {
9089
+ return false;
9090
+ };
9091
+ }
9092
+ var ownVersionParsed = {
9093
+ major: +myVersionMatch[1],
9094
+ minor: +myVersionMatch[2],
9095
+ patch: +myVersionMatch[3],
9096
+ prerelease: myVersionMatch[4]
9097
+ };
9098
+ if (ownVersionParsed.prerelease != null) {
9099
+ return function isExactmatch(globalVersion) {
9100
+ return globalVersion === ownVersion;
9101
+ };
9102
+ }
9103
+ function _reject(v) {
9104
+ rejectedVersions.add(v);
9105
+ return false;
9106
+ }
9107
+ function _accept(v) {
9108
+ acceptedVersions.add(v);
9109
+ return true;
9110
+ }
9111
+ return function isCompatible2(globalVersion) {
9112
+ if (acceptedVersions.has(globalVersion)) {
9113
+ return true;
9114
+ }
9115
+ if (rejectedVersions.has(globalVersion)) {
9116
+ return false;
9117
+ }
9118
+ var globalVersionMatch = globalVersion.match(re);
9119
+ if (!globalVersionMatch) {
9120
+ return _reject(globalVersion);
9121
+ }
9122
+ var globalVersionParsed = {
9123
+ major: +globalVersionMatch[1],
9124
+ minor: +globalVersionMatch[2],
9125
+ patch: +globalVersionMatch[3],
9126
+ prerelease: globalVersionMatch[4]
9127
+ };
9128
+ if (globalVersionParsed.prerelease != null) {
9129
+ return _reject(globalVersion);
9130
+ }
9131
+ if (ownVersionParsed.major !== globalVersionParsed.major) {
9132
+ return _reject(globalVersion);
9133
+ }
9134
+ if (ownVersionParsed.major === 0) {
9135
+ if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
9136
+ return _accept(globalVersion);
9137
+ }
9138
+ return _reject(globalVersion);
9139
+ }
9140
+ if (ownVersionParsed.minor <= globalVersionParsed.minor) {
9141
+ return _accept(globalVersion);
9142
+ }
9143
+ return _reject(globalVersion);
9144
+ };
9145
+ }
9146
+ var isCompatible = _makeCompatibilityCheck(VERSION);
9147
+
9148
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
9149
+ var major = VERSION.split(".")[0];
9150
+ var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
9151
+ var _global = _globalThis;
9152
+ function registerGlobal(type, instance, diag, allowOverride) {
9153
+ var _a5;
9154
+ if (allowOverride === void 0) {
9155
+ allowOverride = false;
9156
+ }
9157
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a5 !== void 0 ? _a5 : {
9158
+ version: VERSION
9159
+ };
9160
+ if (!allowOverride && api[type]) {
9161
+ var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
9162
+ diag.error(err.stack || err.message);
9163
+ return false;
9164
+ }
9165
+ if (api.version !== VERSION) {
9166
+ var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
9167
+ diag.error(err.stack || err.message);
9168
+ return false;
9169
+ }
9170
+ api[type] = instance;
9171
+ diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
9172
+ return true;
9173
+ }
9174
+ function getGlobal(type) {
9175
+ var _a5, _b;
9176
+ var globalVersion = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a5 === void 0 ? void 0 : _a5.version;
9177
+ if (!globalVersion || !isCompatible(globalVersion)) {
9178
+ return;
9179
+ }
9180
+ return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
9181
+ }
9182
+ function unregisterGlobal(type, diag) {
9183
+ diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
9184
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
9185
+ if (api) {
9186
+ delete api[type];
9187
+ }
9188
+ }
9189
+
9190
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
9191
+ var __read = function(o21, n10) {
9192
+ var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
9193
+ if (!m6) return o21;
9194
+ var i = m6.call(o21), r7, ar = [], e40;
9195
+ try {
9196
+ while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9197
+ } catch (error) {
9198
+ e40 = { error };
9199
+ } finally {
9200
+ try {
9201
+ if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
9202
+ } finally {
9203
+ if (e40) throw e40.error;
9204
+ }
9205
+ }
9206
+ return ar;
9207
+ };
9208
+ var __spreadArray = function(to, from, pack) {
9209
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9210
+ if (ar || !(i in from)) {
9211
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9212
+ ar[i] = from[i];
9213
+ }
9214
+ }
9215
+ return to.concat(ar || Array.prototype.slice.call(from));
9216
+ };
9217
+ var DiagComponentLogger = (
9218
+ /** @class */
9219
+ function() {
9220
+ function DiagComponentLogger2(props2) {
9221
+ this._namespace = props2.namespace || "DiagComponentLogger";
9222
+ }
9223
+ DiagComponentLogger2.prototype.debug = function() {
9224
+ var args = [];
9225
+ for (var _i = 0; _i < arguments.length; _i++) {
9226
+ args[_i] = arguments[_i];
9227
+ }
9228
+ return logProxy("debug", this._namespace, args);
9229
+ };
9230
+ DiagComponentLogger2.prototype.error = function() {
9231
+ var args = [];
9232
+ for (var _i = 0; _i < arguments.length; _i++) {
9233
+ args[_i] = arguments[_i];
9234
+ }
9235
+ return logProxy("error", this._namespace, args);
9236
+ };
9237
+ DiagComponentLogger2.prototype.info = function() {
9238
+ var args = [];
9239
+ for (var _i = 0; _i < arguments.length; _i++) {
9240
+ args[_i] = arguments[_i];
9241
+ }
9242
+ return logProxy("info", this._namespace, args);
9243
+ };
9244
+ DiagComponentLogger2.prototype.warn = function() {
9245
+ var args = [];
9246
+ for (var _i = 0; _i < arguments.length; _i++) {
9247
+ args[_i] = arguments[_i];
9248
+ }
9249
+ return logProxy("warn", this._namespace, args);
9250
+ };
9251
+ DiagComponentLogger2.prototype.verbose = function() {
9252
+ var args = [];
9253
+ for (var _i = 0; _i < arguments.length; _i++) {
9254
+ args[_i] = arguments[_i];
9255
+ }
9256
+ return logProxy("verbose", this._namespace, args);
9257
+ };
9258
+ return DiagComponentLogger2;
9259
+ }()
9260
+ );
9261
+ function logProxy(funcName, namespace, args) {
9262
+ var logger = getGlobal("diag");
9263
+ if (!logger) {
9264
+ return;
9265
+ }
9266
+ args.unshift(namespace);
9267
+ return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
9268
+ }
9269
+
9270
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/types.js
9271
+ var DiagLogLevel;
9272
+ (function(DiagLogLevel2) {
9273
+ DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
9274
+ DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
9275
+ DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
9276
+ DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
9277
+ DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
9278
+ DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
9279
+ DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
9280
+ })(DiagLogLevel || (DiagLogLevel = {}));
9281
+
9282
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
9283
+ function createLogLevelDiagLogger(maxLevel, logger) {
9284
+ if (maxLevel < DiagLogLevel.NONE) {
9285
+ maxLevel = DiagLogLevel.NONE;
9286
+ } else if (maxLevel > DiagLogLevel.ALL) {
9287
+ maxLevel = DiagLogLevel.ALL;
9288
+ }
9289
+ logger = logger || {};
9290
+ function _filterFunc(funcName, theLevel) {
9291
+ var theFunc = logger[funcName];
9292
+ if (typeof theFunc === "function" && maxLevel >= theLevel) {
9293
+ return theFunc.bind(logger);
9294
+ }
9295
+ return function() {
9296
+ };
9297
+ }
9298
+ return {
9299
+ error: _filterFunc("error", DiagLogLevel.ERROR),
9300
+ warn: _filterFunc("warn", DiagLogLevel.WARN),
9301
+ info: _filterFunc("info", DiagLogLevel.INFO),
9302
+ debug: _filterFunc("debug", DiagLogLevel.DEBUG),
9303
+ verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
9304
+ };
9305
+ }
9306
+
9307
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/diag.js
9308
+ var __read2 = function(o21, n10) {
9309
+ var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
9310
+ if (!m6) return o21;
9311
+ var i = m6.call(o21), r7, ar = [], e40;
9312
+ try {
9313
+ while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9314
+ } catch (error) {
9315
+ e40 = { error };
9316
+ } finally {
9317
+ try {
9318
+ if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
9319
+ } finally {
9320
+ if (e40) throw e40.error;
9321
+ }
9322
+ }
9323
+ return ar;
9324
+ };
9325
+ var __spreadArray2 = function(to, from, pack) {
9326
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9327
+ if (ar || !(i in from)) {
9328
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9329
+ ar[i] = from[i];
9330
+ }
9331
+ }
9332
+ return to.concat(ar || Array.prototype.slice.call(from));
9333
+ };
9334
+ var API_NAME = "diag";
9335
+ var DiagAPI = (
9336
+ /** @class */
9337
+ function() {
9338
+ function DiagAPI2() {
9339
+ function _logProxy(funcName) {
9340
+ return function() {
9341
+ var args = [];
9342
+ for (var _i = 0; _i < arguments.length; _i++) {
9343
+ args[_i] = arguments[_i];
9344
+ }
9345
+ var logger = getGlobal("diag");
9346
+ if (!logger)
9347
+ return;
9348
+ return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
9349
+ };
9350
+ }
9351
+ var self2 = this;
9352
+ var setLogger = function(logger, optionsOrLogLevel) {
9353
+ var _a5, _b, _c;
9354
+ if (optionsOrLogLevel === void 0) {
9355
+ optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
9356
+ }
9357
+ if (logger === self2) {
9358
+ var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
9359
+ self2.error((_a5 = err.stack) !== null && _a5 !== void 0 ? _a5 : err.message);
9360
+ return false;
9361
+ }
9362
+ if (typeof optionsOrLogLevel === "number") {
9363
+ optionsOrLogLevel = {
9364
+ logLevel: optionsOrLogLevel
9365
+ };
9366
+ }
9367
+ var oldLogger = getGlobal("diag");
9368
+ var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
9369
+ if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
9370
+ var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
9371
+ oldLogger.warn("Current logger will be overwritten from " + stack);
9372
+ newLogger.warn("Current logger will overwrite one already registered from " + stack);
9373
+ }
9374
+ return registerGlobal("diag", newLogger, self2, true);
9375
+ };
9376
+ self2.setLogger = setLogger;
9377
+ self2.disable = function() {
9378
+ unregisterGlobal(API_NAME, self2);
9379
+ };
9380
+ self2.createComponentLogger = function(options) {
9381
+ return new DiagComponentLogger(options);
9382
+ };
9383
+ self2.verbose = _logProxy("verbose");
9384
+ self2.debug = _logProxy("debug");
9385
+ self2.info = _logProxy("info");
9386
+ self2.warn = _logProxy("warn");
9387
+ self2.error = _logProxy("error");
9388
+ }
9389
+ DiagAPI2.instance = function() {
9390
+ if (!this._instance) {
9391
+ this._instance = new DiagAPI2();
9392
+ }
9393
+ return this._instance;
9394
+ };
9395
+ return DiagAPI2;
9396
+ }()
9397
+ );
9398
+
9399
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/context.js
9400
+ function createContextKey(description) {
9401
+ return Symbol.for(description);
9402
+ }
9403
+ var BaseContext = (
9404
+ /** @class */
9405
+ /* @__PURE__ */ function() {
9406
+ function BaseContext2(parentContext) {
9407
+ var self2 = this;
9408
+ self2._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
9409
+ self2.getValue = function(key) {
9410
+ return self2._currentContext.get(key);
9411
+ };
9412
+ self2.setValue = function(key, value) {
9413
+ var context = new BaseContext2(self2._currentContext);
9414
+ context._currentContext.set(key, value);
9415
+ return context;
9416
+ };
9417
+ self2.deleteValue = function(key) {
9418
+ var context = new BaseContext2(self2._currentContext);
9419
+ context._currentContext.delete(key);
9420
+ return context;
9421
+ };
9422
+ }
9423
+ return BaseContext2;
9424
+ }()
9425
+ );
9426
+ var ROOT_CONTEXT = new BaseContext();
9427
+
9428
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js
9429
+ var __read3 = function(o21, n10) {
9430
+ var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
9431
+ if (!m6) return o21;
9432
+ var i = m6.call(o21), r7, ar = [], e40;
9433
+ try {
9434
+ while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9435
+ } catch (error) {
9436
+ e40 = { error };
9437
+ } finally {
9438
+ try {
9439
+ if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
9440
+ } finally {
9441
+ if (e40) throw e40.error;
9442
+ }
9443
+ }
9444
+ return ar;
9445
+ };
9446
+ var __spreadArray3 = function(to, from, pack) {
9447
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9448
+ if (ar || !(i in from)) {
9449
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9450
+ ar[i] = from[i];
9451
+ }
9452
+ }
9453
+ return to.concat(ar || Array.prototype.slice.call(from));
9454
+ };
9455
+ var NoopContextManager = (
9456
+ /** @class */
9457
+ function() {
9458
+ function NoopContextManager2() {
9459
+ }
9460
+ NoopContextManager2.prototype.active = function() {
9461
+ return ROOT_CONTEXT;
9462
+ };
9463
+ NoopContextManager2.prototype.with = function(_context, fn, thisArg) {
9464
+ var args = [];
9465
+ for (var _i = 3; _i < arguments.length; _i++) {
9466
+ args[_i - 3] = arguments[_i];
9467
+ }
9468
+ return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
9469
+ };
9470
+ NoopContextManager2.prototype.bind = function(_context, target) {
9471
+ return target;
9472
+ };
9473
+ NoopContextManager2.prototype.enable = function() {
9474
+ return this;
9475
+ };
9476
+ NoopContextManager2.prototype.disable = function() {
9477
+ return this;
9478
+ };
9479
+ return NoopContextManager2;
9480
+ }()
9481
+ );
9482
+
9483
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/context.js
9484
+ var __read4 = function(o21, n10) {
9485
+ var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
9486
+ if (!m6) return o21;
9487
+ var i = m6.call(o21), r7, ar = [], e40;
9488
+ try {
9489
+ while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9490
+ } catch (error) {
9491
+ e40 = { error };
9492
+ } finally {
9493
+ try {
9494
+ if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
9495
+ } finally {
9496
+ if (e40) throw e40.error;
9497
+ }
9498
+ }
9499
+ return ar;
9500
+ };
9501
+ var __spreadArray4 = function(to, from, pack) {
9502
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9503
+ if (ar || !(i in from)) {
9504
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9505
+ ar[i] = from[i];
9506
+ }
9507
+ }
9508
+ return to.concat(ar || Array.prototype.slice.call(from));
9509
+ };
9510
+ var API_NAME2 = "context";
9511
+ var NOOP_CONTEXT_MANAGER = new NoopContextManager();
9512
+ var ContextAPI = (
9513
+ /** @class */
9514
+ function() {
9515
+ function ContextAPI2() {
9516
+ }
9517
+ ContextAPI2.getInstance = function() {
9518
+ if (!this._instance) {
9519
+ this._instance = new ContextAPI2();
9520
+ }
9521
+ return this._instance;
9522
+ };
9523
+ ContextAPI2.prototype.setGlobalContextManager = function(contextManager) {
9524
+ return registerGlobal(API_NAME2, contextManager, DiagAPI.instance());
9525
+ };
9526
+ ContextAPI2.prototype.active = function() {
9527
+ return this._getContextManager().active();
9528
+ };
9529
+ ContextAPI2.prototype.with = function(context, fn, thisArg) {
9530
+ var _a5;
9531
+ var args = [];
9532
+ for (var _i = 3; _i < arguments.length; _i++) {
9533
+ args[_i - 3] = arguments[_i];
9534
+ }
9535
+ return (_a5 = this._getContextManager()).with.apply(_a5, __spreadArray4([context, fn, thisArg], __read4(args), false));
9536
+ };
9537
+ ContextAPI2.prototype.bind = function(context, target) {
9538
+ return this._getContextManager().bind(context, target);
9539
+ };
9540
+ ContextAPI2.prototype._getContextManager = function() {
9541
+ return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
9542
+ };
9543
+ ContextAPI2.prototype.disable = function() {
9544
+ this._getContextManager().disable();
9545
+ unregisterGlobal(API_NAME2, DiagAPI.instance());
9546
+ };
9547
+ return ContextAPI2;
9548
+ }()
9549
+ );
9550
+
9551
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js
9552
+ var TraceFlags;
9553
+ (function(TraceFlags2) {
9554
+ TraceFlags2[TraceFlags2["NONE"] = 0] = "NONE";
9555
+ TraceFlags2[TraceFlags2["SAMPLED"] = 1] = "SAMPLED";
9556
+ })(TraceFlags || (TraceFlags = {}));
9557
+
9558
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js
9559
+ var INVALID_SPANID = "0000000000000000";
9560
+ var INVALID_TRACEID = "00000000000000000000000000000000";
9561
+ var INVALID_SPAN_CONTEXT = {
9562
+ traceId: INVALID_TRACEID,
9563
+ spanId: INVALID_SPANID,
9564
+ traceFlags: TraceFlags.NONE
9565
+ };
9566
+
9567
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js
9568
+ var NonRecordingSpan = (
9569
+ /** @class */
9570
+ function() {
9571
+ function NonRecordingSpan2(_spanContext) {
9572
+ if (_spanContext === void 0) {
9573
+ _spanContext = INVALID_SPAN_CONTEXT;
9574
+ }
9575
+ this._spanContext = _spanContext;
9576
+ }
9577
+ NonRecordingSpan2.prototype.spanContext = function() {
9578
+ return this._spanContext;
9579
+ };
9580
+ NonRecordingSpan2.prototype.setAttribute = function(_key, _value) {
9581
+ return this;
9582
+ };
9583
+ NonRecordingSpan2.prototype.setAttributes = function(_attributes) {
9584
+ return this;
9585
+ };
9586
+ NonRecordingSpan2.prototype.addEvent = function(_name, _attributes) {
9587
+ return this;
9588
+ };
9589
+ NonRecordingSpan2.prototype.addLink = function(_link) {
9590
+ return this;
9591
+ };
9592
+ NonRecordingSpan2.prototype.addLinks = function(_links) {
9593
+ return this;
9594
+ };
9595
+ NonRecordingSpan2.prototype.setStatus = function(_status) {
9596
+ return this;
9597
+ };
9598
+ NonRecordingSpan2.prototype.updateName = function(_name) {
9599
+ return this;
9600
+ };
9601
+ NonRecordingSpan2.prototype.end = function(_endTime) {
9602
+ };
9603
+ NonRecordingSpan2.prototype.isRecording = function() {
9604
+ return false;
9605
+ };
9606
+ NonRecordingSpan2.prototype.recordException = function(_exception, _time) {
9607
+ };
9608
+ return NonRecordingSpan2;
9609
+ }()
9610
+ );
9611
+
9612
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js
9613
+ var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
9614
+ function getSpan(context) {
9615
+ return context.getValue(SPAN_KEY) || void 0;
9616
+ }
9617
+ function getActiveSpan() {
9618
+ return getSpan(ContextAPI.getInstance().active());
9619
+ }
9620
+ function setSpan(context, span) {
9621
+ return context.setValue(SPAN_KEY, span);
9622
+ }
9623
+ function deleteSpan(context) {
9624
+ return context.deleteValue(SPAN_KEY);
9625
+ }
9626
+ function setSpanContext(context, spanContext) {
9627
+ return setSpan(context, new NonRecordingSpan(spanContext));
9628
+ }
9629
+ function getSpanContext(context) {
9630
+ var _a5;
9631
+ return (_a5 = getSpan(context)) === null || _a5 === void 0 ? void 0 : _a5.spanContext();
9632
+ }
9633
+
9634
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
9635
+ var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
9636
+ var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
9637
+ function isValidTraceId(traceId) {
9638
+ return VALID_TRACEID_REGEX.test(traceId) && traceId !== INVALID_TRACEID;
9774
9639
  }
9775
- var allowInsecureRequests = Symbol();
9776
- var clockSkew = Symbol();
9777
- var clockTolerance = Symbol();
9778
- var customFetch = Symbol();
9779
- var jweDecrypt = Symbol();
9780
- var encoder = new TextEncoder();
9781
- var decoder = new TextDecoder();
9782
- var encodeBase64Url;
9783
- if (Uint8Array.prototype.toBase64) encodeBase64Url = (input) => {
9784
- if (input instanceof ArrayBuffer) input = new Uint8Array(input);
9785
- return input.toBase64({
9786
- alphabet: "base64url",
9787
- omitPadding: true
9640
+ function isValidSpanId(spanId) {
9641
+ return VALID_SPANID_REGEX.test(spanId) && spanId !== INVALID_SPANID;
9642
+ }
9643
+ function isSpanContextValid(spanContext) {
9644
+ return isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);
9645
+ }
9646
+ function wrapSpanContext(spanContext) {
9647
+ return new NonRecordingSpan(spanContext);
9648
+ }
9649
+
9650
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js
9651
+ var contextApi = ContextAPI.getInstance();
9652
+ var NoopTracer = (
9653
+ /** @class */
9654
+ function() {
9655
+ function NoopTracer2() {
9656
+ }
9657
+ NoopTracer2.prototype.startSpan = function(name, options, context) {
9658
+ if (context === void 0) {
9659
+ context = contextApi.active();
9660
+ }
9661
+ var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
9662
+ if (root) {
9663
+ return new NonRecordingSpan();
9664
+ }
9665
+ var parentFromContext = context && getSpanContext(context);
9666
+ if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
9667
+ return new NonRecordingSpan(parentFromContext);
9668
+ } else {
9669
+ return new NonRecordingSpan();
9670
+ }
9671
+ };
9672
+ NoopTracer2.prototype.startActiveSpan = function(name, arg2, arg3, arg4) {
9673
+ var opts;
9674
+ var ctx;
9675
+ var fn;
9676
+ if (arguments.length < 2) {
9677
+ return;
9678
+ } else if (arguments.length === 2) {
9679
+ fn = arg2;
9680
+ } else if (arguments.length === 3) {
9681
+ opts = arg2;
9682
+ fn = arg3;
9683
+ } else {
9684
+ opts = arg2;
9685
+ ctx = arg3;
9686
+ fn = arg4;
9687
+ }
9688
+ var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
9689
+ var span = this.startSpan(name, opts, parentContext);
9690
+ var contextWithSpanSet = setSpan(parentContext, span);
9691
+ return contextApi.with(contextWithSpanSet, fn, void 0, span);
9692
+ };
9693
+ return NoopTracer2;
9694
+ }()
9695
+ );
9696
+ function isSpanContext(spanContext) {
9697
+ return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
9698
+ }
9699
+
9700
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js
9701
+ var NOOP_TRACER = new NoopTracer();
9702
+ var ProxyTracer = (
9703
+ /** @class */
9704
+ function() {
9705
+ function ProxyTracer2(_provider, name, version, options) {
9706
+ this._provider = _provider;
9707
+ this.name = name;
9708
+ this.version = version;
9709
+ this.options = options;
9710
+ }
9711
+ ProxyTracer2.prototype.startSpan = function(name, options, context) {
9712
+ return this._getTracer().startSpan(name, options, context);
9713
+ };
9714
+ ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
9715
+ var tracer2 = this._getTracer();
9716
+ return Reflect.apply(tracer2.startActiveSpan, tracer2, arguments);
9717
+ };
9718
+ ProxyTracer2.prototype._getTracer = function() {
9719
+ if (this._delegate) {
9720
+ return this._delegate;
9721
+ }
9722
+ var tracer2 = this._provider.getDelegateTracer(this.name, this.version, this.options);
9723
+ if (!tracer2) {
9724
+ return NOOP_TRACER;
9725
+ }
9726
+ this._delegate = tracer2;
9727
+ return this._delegate;
9728
+ };
9729
+ return ProxyTracer2;
9730
+ }()
9731
+ );
9732
+
9733
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js
9734
+ var NoopTracerProvider = (
9735
+ /** @class */
9736
+ function() {
9737
+ function NoopTracerProvider2() {
9738
+ }
9739
+ NoopTracerProvider2.prototype.getTracer = function(_name, _version, _options) {
9740
+ return new NoopTracer();
9741
+ };
9742
+ return NoopTracerProvider2;
9743
+ }()
9744
+ );
9745
+
9746
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js
9747
+ var NOOP_TRACER_PROVIDER = new NoopTracerProvider();
9748
+ var ProxyTracerProvider = (
9749
+ /** @class */
9750
+ function() {
9751
+ function ProxyTracerProvider2() {
9752
+ }
9753
+ ProxyTracerProvider2.prototype.getTracer = function(name, version, options) {
9754
+ var _a5;
9755
+ return (_a5 = this.getDelegateTracer(name, version, options)) !== null && _a5 !== void 0 ? _a5 : new ProxyTracer(this, name, version, options);
9756
+ };
9757
+ ProxyTracerProvider2.prototype.getDelegate = function() {
9758
+ var _a5;
9759
+ return (_a5 = this._delegate) !== null && _a5 !== void 0 ? _a5 : NOOP_TRACER_PROVIDER;
9760
+ };
9761
+ ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
9762
+ this._delegate = delegate;
9763
+ };
9764
+ ProxyTracerProvider2.prototype.getDelegateTracer = function(name, version, options) {
9765
+ var _a5;
9766
+ return (_a5 = this._delegate) === null || _a5 === void 0 ? void 0 : _a5.getTracer(name, version, options);
9767
+ };
9768
+ return ProxyTracerProvider2;
9769
+ }()
9770
+ );
9771
+
9772
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/trace.js
9773
+ var API_NAME3 = "trace";
9774
+ var TraceAPI = (
9775
+ /** @class */
9776
+ function() {
9777
+ function TraceAPI2() {
9778
+ this._proxyTracerProvider = new ProxyTracerProvider();
9779
+ this.wrapSpanContext = wrapSpanContext;
9780
+ this.isSpanContextValid = isSpanContextValid;
9781
+ this.deleteSpan = deleteSpan;
9782
+ this.getSpan = getSpan;
9783
+ this.getActiveSpan = getActiveSpan;
9784
+ this.getSpanContext = getSpanContext;
9785
+ this.setSpan = setSpan;
9786
+ this.setSpanContext = setSpanContext;
9787
+ }
9788
+ TraceAPI2.getInstance = function() {
9789
+ if (!this._instance) {
9790
+ this._instance = new TraceAPI2();
9791
+ }
9792
+ return this._instance;
9793
+ };
9794
+ TraceAPI2.prototype.setGlobalTracerProvider = function(provider) {
9795
+ var success = registerGlobal(API_NAME3, this._proxyTracerProvider, DiagAPI.instance());
9796
+ if (success) {
9797
+ this._proxyTracerProvider.setDelegate(provider);
9798
+ }
9799
+ return success;
9800
+ };
9801
+ TraceAPI2.prototype.getTracerProvider = function() {
9802
+ return getGlobal(API_NAME3) || this._proxyTracerProvider;
9803
+ };
9804
+ TraceAPI2.prototype.getTracer = function(name, version) {
9805
+ return this.getTracerProvider().getTracer(name, version);
9806
+ };
9807
+ TraceAPI2.prototype.disable = function() {
9808
+ unregisterGlobal(API_NAME3, DiagAPI.instance());
9809
+ this._proxyTracerProvider = new ProxyTracerProvider();
9810
+ };
9811
+ return TraceAPI2;
9812
+ }()
9813
+ );
9814
+
9815
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace-api.js
9816
+ var trace = TraceAPI.getInstance();
9817
+
9818
+ // ../shared/dist/esm/utils/telemetry.js
9819
+ var tracer = trace.getTracer("stack-tracer");
9820
+ async function traceSpan(optionsOrDescription, fn) {
9821
+ let options = typeof optionsOrDescription === "string" ? { description: optionsOrDescription } : optionsOrDescription;
9822
+ return await tracer.startActiveSpan(`STACK: ${options.description}`, async (span) => {
9823
+ if (options.attributes) for (const [key, value] of Object.entries(options.attributes)) span.setAttribute(key, value);
9824
+ try {
9825
+ return await fn(span);
9826
+ } finally {
9827
+ span.end();
9828
+ }
9788
9829
  });
9789
- };
9790
- else {
9791
- const CHUNK_SIZE = 32768;
9792
- encodeBase64Url = (input) => {
9793
- if (input instanceof ArrayBuffer) input = new Uint8Array(input);
9794
- const arr = [];
9795
- for (let i = 0; i < input.byteLength; i += CHUNK_SIZE) arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
9796
- return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
9797
- };
9798
9830
  }
9799
- var decodeBase64Url;
9800
- if (Uint8Array.fromBase64) decodeBase64Url = (input) => {
9801
- try {
9802
- return Uint8Array.fromBase64(input, { alphabet: "base64url" });
9803
- } catch (cause) {
9804
- throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
9805
- }
9806
- };
9807
- else decodeBase64Url = (input) => {
9808
- try {
9809
- const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
9810
- const bytes = new Uint8Array(binary.length);
9811
- for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
9812
- return bytes;
9813
- } catch (cause) {
9814
- throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
9815
- }
9816
- };
9817
- var URLParse = URL.parse ? (url, base) => URL.parse(url, base) : (url, base) => {
9818
- try {
9819
- return new URL(url, base);
9820
- } catch {
9821
- return null;
9822
- }
9823
- };
9824
- var nopkce = Symbol();
9825
- var expectNoNonce = Symbol();
9826
- var skipAuthTimeCheck = Symbol();
9827
- var skipStateCheck = Symbol();
9828
- var expectNoState = Symbol();
9829
- var _expectedIssuer = Symbol();
9830
- var botChallengeKnownErrors = [KnownErrors.BotChallengeRequired, KnownErrors.BotChallengeFailed];
9831
9831
 
9832
9832
  // ../shared/dist/esm/utils/promises.js
9833
9833
  var neverResolvePromise = pending(new Promise(() => {