@hexclave/dashboard-ui-components 1.0.6 → 1.0.8

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.
@@ -4448,1326 +4448,448 @@ This is likely an error in Hexclave. Please make sure you are running the newest
4448
4448
  return Object.assign(Result.error(new RetryError(errors)), { attempts: totalAttempts });
4449
4449
  }
4450
4450
 
4451
- // ../shared/dist/esm/utils/maps.js
4452
- var _Symbol$toStringTag;
4453
- var _Symbol$toStringTag2;
4454
- var _Symbol$toStringTag3;
4455
- var WeakRefIfAvailable = class {
4456
- constructor(value) {
4457
- if (typeof WeakRef === "undefined") this._ref = { deref: () => value };
4458
- else this._ref = new WeakRef(value);
4459
- }
4460
- deref() {
4461
- return this._ref.deref();
4462
- }
4463
- };
4464
- var _a2;
4465
- var IterableWeakMap = (_a2 = class {
4466
- constructor(entries) {
4467
- this[_Symbol$toStringTag] = "IterableWeakMap";
4468
- const mappedEntries = entries?.map((e40) => [e40[0], {
4469
- value: e40[1],
4470
- keyRef: new WeakRefIfAvailable(e40[0])
4471
- }]);
4472
- this._weakMap = new WeakMap(mappedEntries ?? []);
4473
- this._keyRefs = new Set(mappedEntries?.map((e40) => e40[1].keyRef) ?? []);
4474
- }
4475
- get(key) {
4476
- return this._weakMap.get(key)?.value;
4477
- }
4478
- set(key, value) {
4479
- const updated = {
4480
- value,
4481
- keyRef: this._weakMap.get(key)?.keyRef ?? new WeakRefIfAvailable(key)
4482
- };
4483
- this._weakMap.set(key, updated);
4484
- this._keyRefs.add(updated.keyRef);
4485
- return this;
4486
- }
4487
- delete(key) {
4488
- const res = this._weakMap.get(key);
4489
- if (res) {
4490
- this._weakMap.delete(key);
4491
- this._keyRefs.delete(res.keyRef);
4492
- return true;
4493
- }
4494
- return false;
4495
- }
4496
- has(key) {
4497
- return this._weakMap.has(key) && this._keyRefs.has(this._weakMap.get(key).keyRef);
4498
- }
4499
- *[Symbol.iterator]() {
4500
- for (const keyRef of this._keyRefs) {
4501
- const key = keyRef.deref();
4502
- const existing = key ? this._weakMap.get(key) : void 0;
4503
- if (!key) this._keyRefs.delete(keyRef);
4504
- else if (existing) yield [key, existing.value];
4505
- }
4451
+ // ../shared/dist/esm/utils/bytes.js
4452
+ function decodeBase64(input) {
4453
+ return new Uint8Array(atob(input).split("").map((char) => char.charCodeAt(0)));
4454
+ }
4455
+ function isBase64(input) {
4456
+ return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(input);
4457
+ }
4458
+
4459
+ // ../shared/dist/esm/utils/urls.js
4460
+ function createUrlIfValid(...args) {
4461
+ try {
4462
+ return new URL(...args);
4463
+ } catch (e40) {
4464
+ return null;
4506
4465
  }
4507
- }, _Symbol$toStringTag = Symbol.toStringTag, _a2);
4508
- var _a3;
4509
- var MaybeWeakMap = (_a3 = class {
4510
- constructor(entries) {
4511
- this[_Symbol$toStringTag2] = "MaybeWeakMap";
4512
- const entriesArray = [...entries ?? []];
4513
- this._primitiveMap = new Map(entriesArray.filter((e40) => !this._isAllowedInWeakMap(e40[0])));
4514
- this._weakMap = new IterableWeakMap(entriesArray.filter((e40) => this._isAllowedInWeakMap(e40[0])));
4466
+ }
4467
+ function isValidUrl(url) {
4468
+ return !!createUrlIfValid(url);
4469
+ }
4470
+ function isValidHostname(hostname) {
4471
+ if (!hostname || hostname.startsWith(".") || hostname.endsWith(".") || hostname.includes("..")) return false;
4472
+ const url = createUrlIfValid(`https://${hostname}`);
4473
+ if (!url) return false;
4474
+ return url.hostname === hostname;
4475
+ }
4476
+ function isValidHostnameWithWildcards(hostname) {
4477
+ if (!hostname) return false;
4478
+ if (!hostname.includes("*")) return isValidHostname(hostname);
4479
+ if (hostname.startsWith(".") || hostname.endsWith(".")) return false;
4480
+ if (hostname.includes("..")) return false;
4481
+ const testHostname = hostname.replace(/\*+/g, "wildcard");
4482
+ if (!/^[a-zA-Z0-9.-]+$/.test(testHostname)) return false;
4483
+ const segments = hostname.split(/\*+/);
4484
+ for (let i = 0; i < segments.length; i++) {
4485
+ const segment = segments[i];
4486
+ if (segment === "") continue;
4487
+ if (i === 0 && segment.startsWith(".")) return false;
4488
+ if (i === segments.length - 1 && segment.endsWith(".")) return false;
4489
+ if (segment.includes("..")) return false;
4515
4490
  }
4516
- _isAllowedInWeakMap(key) {
4517
- return typeof key === "object" && key !== null || typeof key === "symbol" && Symbol.keyFor(key) === void 0;
4491
+ return true;
4492
+ }
4493
+
4494
+ // ../shared/dist/esm/known-errors.js
4495
+ var KnownError = class extends StatusError {
4496
+ constructor(statusCode, humanReadableMessage, details) {
4497
+ super(statusCode, humanReadableMessage);
4498
+ this.statusCode = statusCode;
4499
+ this.humanReadableMessage = humanReadableMessage;
4500
+ this.details = details;
4501
+ this.__stackKnownErrorBrand = "stack-known-error-brand-sentinel";
4502
+ this.name = "KnownError";
4518
4503
  }
4519
- get(key) {
4520
- if (this._isAllowedInWeakMap(key)) return this._weakMap.get(key);
4521
- else return this._primitiveMap.get(key);
4504
+ static isKnownError(error) {
4505
+ return typeof error === "object" && error !== null && "__stackKnownErrorBrand" in error && error.__stackKnownErrorBrand === "stack-known-error-brand-sentinel";
4522
4506
  }
4523
- set(key, value) {
4524
- if (this._isAllowedInWeakMap(key)) this._weakMap.set(key, value);
4525
- else this._primitiveMap.set(key, value);
4526
- return this;
4507
+ getBody() {
4508
+ return new TextEncoder().encode(JSON.stringify(this.toDescriptiveJson(), void 0, 2));
4527
4509
  }
4528
- delete(key) {
4529
- if (this._isAllowedInWeakMap(key)) return this._weakMap.delete(key);
4530
- else return this._primitiveMap.delete(key);
4510
+ getHeaders() {
4511
+ return {
4512
+ "Content-Type": ["application/json; charset=utf-8"],
4513
+ "X-Stack-Known-Error": [this.errorCode],
4514
+ "X-Hexclave-Known-Error": [this.errorCode]
4515
+ };
4531
4516
  }
4532
- has(key) {
4533
- if (this._isAllowedInWeakMap(key)) return this._weakMap.has(key);
4534
- else return this._primitiveMap.has(key);
4517
+ toDescriptiveJson() {
4518
+ return {
4519
+ code: this.errorCode,
4520
+ ...this.details ? { details: this.details } : {},
4521
+ error: this.humanReadableMessage
4522
+ };
4535
4523
  }
4536
- *[Symbol.iterator]() {
4537
- yield* this._primitiveMap;
4538
- yield* this._weakMap;
4524
+ get errorCode() {
4525
+ return this.constructor.errorCode ?? throwErr(`Can't find error code for this KnownError. Is its constructor a KnownErrorConstructor? ${this}`);
4539
4526
  }
4540
- }, _Symbol$toStringTag2 = Symbol.toStringTag, _a3);
4541
- var _a4;
4542
- var DependenciesMap = (_a4 = class {
4543
- constructor() {
4544
- this._inner = {
4545
- map: new MaybeWeakMap(),
4546
- hasValue: false,
4547
- value: void 0
4548
- };
4549
- this[_Symbol$toStringTag3] = "DependenciesMap";
4527
+ static constructorArgsFromJson(json) {
4528
+ return [
4529
+ 400,
4530
+ json.message,
4531
+ json
4532
+ ];
4550
4533
  }
4551
- _valueToResult(inner) {
4552
- if (inner.hasValue) return Result.ok(inner.value);
4553
- else return Result.error(void 0);
4534
+ static fromJson(json) {
4535
+ for (const [_, KnownErrorType] of Object.entries(KnownErrors)) if (json.code === KnownErrorType.prototype.errorCode) return new KnownErrorType(...KnownErrorType.constructorArgsFromJson(json));
4536
+ throw new Error(`An error occurred. Please update your version of the Hexclave SDK. ${json.code}: ${json.message}`);
4554
4537
  }
4555
- _unwrapFromInner(dependencies, inner) {
4556
- if (dependencies.length === 0) return this._valueToResult(inner);
4557
- else {
4558
- const [key, ...rest] = dependencies;
4559
- const newInner = inner.map.get(key);
4560
- if (!newInner) return Result.error(void 0);
4561
- return this._unwrapFromInner(rest, newInner);
4538
+ };
4539
+ function createKnownErrorConstructor(SuperClass, errorCode, create, constructorArgsFromJson) {
4540
+ const createFn = create === "inherit" ? identityArgs : create;
4541
+ const constructorArgsFromJsonFn = constructorArgsFromJson === "inherit" ? SuperClass.constructorArgsFromJson : constructorArgsFromJson;
4542
+ const _KnownErrorImpl = class _KnownErrorImpl extends SuperClass {
4543
+ constructor(...args) {
4544
+ super(...createFn(...args));
4545
+ this.name = `KnownError<${errorCode}>`;
4546
+ this.constructorArgs = args;
4562
4547
  }
4563
- }
4564
- _setInInner(dependencies, value, inner) {
4565
- if (dependencies.length === 0) {
4566
- const res = this._valueToResult(inner);
4567
- if (value.status === "ok") {
4568
- inner.hasValue = true;
4569
- inner.value = value.data;
4570
- } else {
4571
- inner.hasValue = false;
4572
- inner.value = void 0;
4573
- }
4574
- return res;
4575
- } else {
4576
- const [key, ...rest] = dependencies;
4577
- let newInner = inner.map.get(key);
4578
- if (!newInner) inner.map.set(key, newInner = {
4579
- map: new MaybeWeakMap(),
4580
- hasValue: false,
4581
- value: void 0
4582
- });
4583
- return this._setInInner(rest, value, newInner);
4548
+ static constructorArgsFromJson(json) {
4549
+ return constructorArgsFromJsonFn(json.details);
4584
4550
  }
4585
- }
4586
- *_iterateInner(dependencies, inner) {
4587
- if (inner.hasValue) yield [dependencies, inner.value];
4588
- for (const [key, value] of inner.map) yield* this._iterateInner([...dependencies, key], value);
4589
- }
4590
- get(dependencies) {
4591
- return Result.or(this._unwrapFromInner(dependencies, this._inner), void 0);
4592
- }
4593
- set(dependencies, value) {
4594
- this._setInInner(dependencies, Result.ok(value), this._inner);
4595
- return this;
4596
- }
4597
- delete(dependencies) {
4598
- return this._setInInner(dependencies, Result.error(void 0), this._inner).status === "ok";
4599
- }
4600
- has(dependencies) {
4601
- return this._unwrapFromInner(dependencies, this._inner).status === "ok";
4602
- }
4603
- clear() {
4604
- this._inner = {
4605
- map: new MaybeWeakMap(),
4606
- hasValue: false,
4607
- value: void 0
4608
- };
4609
- }
4610
- *[Symbol.iterator]() {
4611
- yield* this._iterateInner([], this._inner);
4612
- }
4613
- }, _Symbol$toStringTag3 = Symbol.toStringTag, _a4);
4614
-
4615
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/platform/browser/globalThis.js
4616
- var _globalThis = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
4617
-
4618
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/version.js
4619
- var VERSION = "1.9.0";
4620
-
4621
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/semver.js
4622
- var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
4623
- function _makeCompatibilityCheck(ownVersion) {
4624
- var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
4625
- var rejectedVersions = /* @__PURE__ */ new Set();
4626
- var myVersionMatch = ownVersion.match(re);
4627
- if (!myVersionMatch) {
4628
- return function() {
4551
+ static isInstance(error) {
4552
+ if (!KnownError.isKnownError(error)) return false;
4553
+ let current = error;
4554
+ while (true) {
4555
+ current = Object.getPrototypeOf(current);
4556
+ if (!current) break;
4557
+ if ("errorCode" in current.constructor && current.constructor.errorCode === errorCode) return true;
4558
+ }
4629
4559
  return false;
4630
- };
4631
- }
4632
- var ownVersionParsed = {
4633
- major: +myVersionMatch[1],
4634
- minor: +myVersionMatch[2],
4635
- patch: +myVersionMatch[3],
4636
- prerelease: myVersionMatch[4]
4637
- };
4638
- if (ownVersionParsed.prerelease != null) {
4639
- return function isExactmatch(globalVersion) {
4640
- return globalVersion === ownVersion;
4641
- };
4642
- }
4643
- function _reject(v) {
4644
- rejectedVersions.add(v);
4645
- return false;
4646
- }
4647
- function _accept(v) {
4648
- acceptedVersions.add(v);
4649
- return true;
4650
- }
4651
- return function isCompatible2(globalVersion) {
4652
- if (acceptedVersions.has(globalVersion)) {
4653
- return true;
4654
- }
4655
- if (rejectedVersions.has(globalVersion)) {
4656
- return false;
4657
- }
4658
- var globalVersionMatch = globalVersion.match(re);
4659
- if (!globalVersionMatch) {
4660
- return _reject(globalVersion);
4661
- }
4662
- var globalVersionParsed = {
4663
- major: +globalVersionMatch[1],
4664
- minor: +globalVersionMatch[2],
4665
- patch: +globalVersionMatch[3],
4666
- prerelease: globalVersionMatch[4]
4667
- };
4668
- if (globalVersionParsed.prerelease != null) {
4669
- return _reject(globalVersion);
4670
- }
4671
- if (ownVersionParsed.major !== globalVersionParsed.major) {
4672
- return _reject(globalVersion);
4673
- }
4674
- if (ownVersionParsed.major === 0) {
4675
- if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
4676
- return _accept(globalVersion);
4677
- }
4678
- return _reject(globalVersion);
4679
- }
4680
- if (ownVersionParsed.minor <= globalVersionParsed.minor) {
4681
- return _accept(globalVersion);
4682
4560
  }
4683
- return _reject(globalVersion);
4684
4561
  };
4562
+ _KnownErrorImpl.errorCode = errorCode;
4563
+ let KnownErrorImpl = _KnownErrorImpl;
4564
+ return KnownErrorImpl;
4685
4565
  }
4686
- var isCompatible = _makeCompatibilityCheck(VERSION);
4566
+ var UnsupportedError = createKnownErrorConstructor(KnownError, "UNSUPPORTED_ERROR", (originalErrorCode) => [
4567
+ 500,
4568
+ `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}`,
4569
+ { originalErrorCode }
4570
+ ], (json) => [json?.originalErrorCode ?? throwErr("originalErrorCode not found in UnsupportedError details")]);
4571
+ var BodyParsingError = createKnownErrorConstructor(KnownError, "BODY_PARSING_ERROR", (message) => [400, message], (json) => [json.message]);
4572
+ var SchemaError = createKnownErrorConstructor(KnownError, "SCHEMA_ERROR", (message) => [
4573
+ 400,
4574
+ message || throwErr("SchemaError requires a message"),
4575
+ { message }
4576
+ ], (json) => [json.message]);
4577
+ var AllOverloadsFailed = createKnownErrorConstructor(KnownError, "ALL_OVERLOADS_FAILED", (overloadErrors) => [
4578
+ 400,
4579
+ deindent`
4580
+ This endpoint has multiple overloads, but they all failed to process the request.
4687
4581
 
4688
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
4689
- var major = VERSION.split(".")[0];
4690
- var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
4691
- var _global = _globalThis;
4692
- function registerGlobal(type, instance, diag, allowOverride) {
4693
- var _a5;
4694
- if (allowOverride === void 0) {
4695
- allowOverride = false;
4696
- }
4697
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a5 !== void 0 ? _a5 : {
4698
- version: VERSION
4699
- };
4700
- if (!allowOverride && api[type]) {
4701
- var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
4702
- diag.error(err.stack || err.message);
4703
- return false;
4704
- }
4705
- if (api.version !== VERSION) {
4706
- var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
4707
- diag.error(err.stack || err.message);
4708
- return false;
4709
- }
4710
- api[type] = instance;
4711
- diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
4712
- return true;
4713
- }
4714
- function getGlobal(type) {
4715
- var _a5, _b;
4716
- var globalVersion = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a5 === void 0 ? void 0 : _a5.version;
4717
- if (!globalVersion || !isCompatible(globalVersion)) {
4718
- return;
4719
- }
4720
- return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
4721
- }
4722
- function unregisterGlobal(type, diag) {
4723
- diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
4724
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
4725
- if (api) {
4726
- delete api[type];
4582
+ ${overloadErrors.map((e40, i) => deindent`
4583
+ Overload ${i + 1}: ${JSON.stringify(e40, void 0, 2)}
4584
+ `).join("\n\n")}
4585
+ `,
4586
+ { overload_errors: overloadErrors }
4587
+ ], (json) => [json?.overload_errors ?? throwErr("overload_errors not found in AllOverloadsFailed details")]);
4588
+ var ProjectAuthenticationError = createKnownErrorConstructor(KnownError, "PROJECT_AUTHENTICATION_ERROR", "inherit", "inherit");
4589
+ var InvalidProjectAuthentication = createKnownErrorConstructor(ProjectAuthenticationError, "INVALID_PROJECT_AUTHENTICATION", "inherit", "inherit");
4590
+ 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.)"], () => []);
4591
+ 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")]);
4592
+ var AccessTypeWithoutProjectId = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_WITHOUT_PROJECT_ID", (accessType) => [
4593
+ 400,
4594
+ deindent`
4595
+ 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.)
4596
+
4597
+ For more information, see the docs on REST API authentication: https://docs.hexclave.com/api/overview#authentication
4598
+ `,
4599
+ { request_type: accessType }
4600
+ ], (json) => [json.request_type]);
4601
+ var AccessTypeRequired = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_REQUIRED", () => [400, deindent`
4602
+ 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.)
4603
+
4604
+ For more information, see the docs on REST API authentication: https://docs.hexclave.com/api/overview#authentication
4605
+ `], () => []);
4606
+ var InsufficientAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "INSUFFICIENT_ACCESS_TYPE", (actualAccessType, allowedAccessTypes) => [
4607
+ 401,
4608
+ `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.)`,
4609
+ {
4610
+ actual_access_type: actualAccessType,
4611
+ allowed_access_types: allowedAccessTypes
4727
4612
  }
4728
- }
4613
+ ], (json) => [json.actual_access_type, json.allowed_access_types]);
4614
+ var InvalidPublishableClientKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_PUBLISHABLE_CLIENT_KEY", (projectId) => [
4615
+ 401,
4616
+ `The publishable key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
4617
+ { project_id: projectId }
4618
+ ], (json) => [json.project_id]);
4619
+ var InvalidSecretServerKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SECRET_SERVER_KEY", (projectId) => [
4620
+ 401,
4621
+ `The secret server key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
4622
+ { project_id: projectId }
4623
+ ], (json) => [json.project_id]);
4624
+ var InvalidSuperSecretAdminKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SUPER_SECRET_ADMIN_KEY", (projectId) => [
4625
+ 401,
4626
+ `The super secret admin key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
4627
+ { project_id: projectId }
4628
+ ], (json) => [json.project_id]);
4629
+ var InvalidAdminAccessToken = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_ADMIN_ACCESS_TOKEN", "inherit", "inherit");
4630
+ var UnparsableAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "UNPARSABLE_ADMIN_ACCESS_TOKEN", () => [401, "Admin access token is not parsable."], () => []);
4631
+ var AdminAccessTokenExpired = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_EXPIRED", (expiredAt) => [
4632
+ 401,
4633
+ `Admin access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)` : ""}`,
4634
+ { expired_at_millis: expiredAt?.getTime() ?? null }
4635
+ ], (json) => [json.expired_at_millis ? new Date(json.expired_at_millis) : void 0]);
4636
+ var InvalidProjectForAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "INVALID_PROJECT_FOR_ADMIN_ACCESS_TOKEN", () => [401, "Admin access tokens must be created on the internal project."], () => []);
4637
+ var AdminAccessTokenIsNotAdmin = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_IS_NOT_ADMIN", () => [401, "Admin access token does not have the required permissions to access this project."], () => []);
4638
+ var ProjectAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationError, "PROJECT_AUTHENTICATION_REQUIRED", "inherit", "inherit");
4639
+ var ClientAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_AUTHENTICATION_REQUIRED", () => [401, "The publishable client key must be provided."], () => []);
4640
+ var PublishableClientKeyRequiredForProject = createKnownErrorConstructor(ProjectAuthenticationRequired, "PUBLISHABLE_CLIENT_KEY_REQUIRED_FOR_PROJECT", (projectId) => [
4641
+ 401,
4642
+ "Publishable client keys are required for this project. Create one in Project Keys, or disable this requirement there to allow keyless client access.",
4643
+ { project_id: projectId ?? null }
4644
+ ], (json) => [json.project_id ?? void 0]);
4645
+ var ServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "SERVER_AUTHENTICATION_REQUIRED", () => [401, "The secret server key must be provided."], () => []);
4646
+ var ClientOrServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_SERVER_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the secret server key must be provided."], () => []);
4647
+ var ClientOrAdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_ADMIN_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the super secret admin key must be provided."], () => []);
4648
+ 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."], () => []);
4649
+ var AdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "ADMIN_AUTHENTICATION_REQUIRED", () => [401, "The super secret admin key must be provided."], () => []);
4650
+ var ExpectedInternalProject = createKnownErrorConstructor(ProjectAuthenticationError, "EXPECTED_INTERNAL_PROJECT", () => [401, "The project ID is expected to be internal."], () => []);
4651
+ var SessionAuthenticationError = createKnownErrorConstructor(KnownError, "SESSION_AUTHENTICATION_ERROR", "inherit", "inherit");
4652
+ var InvalidSessionAuthentication = createKnownErrorConstructor(SessionAuthenticationError, "INVALID_SESSION_AUTHENTICATION", "inherit", "inherit");
4653
+ var InvalidAccessToken = createKnownErrorConstructor(InvalidSessionAuthentication, "INVALID_ACCESS_TOKEN", "inherit", "inherit");
4654
+ var UnparsableAccessToken = createKnownErrorConstructor(InvalidAccessToken, "UNPARSABLE_ACCESS_TOKEN", () => [401, "Access token is not parsable."], () => []);
4655
+ var AccessTokenExpired = createKnownErrorConstructor(InvalidAccessToken, "ACCESS_TOKEN_EXPIRED", (expiredAt, projectId, userId, refreshTokenId) => [
4656
+ 401,
4657
+ deindent`
4658
+ 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}.` : ""}
4729
4659
 
4730
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
4731
- var __read = function(o21, n9) {
4732
- var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
4733
- if (!m5) return o21;
4734
- var i = m5.call(o21), r7, ar = [], e40;
4735
- try {
4736
- while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
4737
- } catch (error) {
4738
- e40 = { error };
4739
- } finally {
4740
- try {
4741
- if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
4742
- } finally {
4743
- if (e40) throw e40.error;
4744
- }
4660
+ 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.
4661
+ `,
4662
+ {
4663
+ expired_at_millis: expiredAt?.getTime() ?? null,
4664
+ project_id: projectId ?? null,
4665
+ user_id: userId ?? null,
4666
+ refresh_token_id: refreshTokenId ?? null
4745
4667
  }
4746
- return ar;
4747
- };
4748
- var __spreadArray = function(to, from, pack) {
4749
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
4750
- if (ar || !(i in from)) {
4751
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
4752
- ar[i] = from[i];
4753
- }
4668
+ ], (json) => [
4669
+ json.expired_at_millis ? new Date(json.expired_at_millis) : void 0,
4670
+ json.project_id ?? void 0,
4671
+ json.user_id ?? void 0,
4672
+ json.refresh_token_id ?? void 0
4673
+ ]);
4674
+ var InvalidProjectForAccessToken = createKnownErrorConstructor(InvalidAccessToken, "INVALID_PROJECT_FOR_ACCESS_TOKEN", (expectedProjectId, actualProjectId) => [
4675
+ 401,
4676
+ `Access token not valid for this project. Expected project ID ${JSON.stringify(expectedProjectId)}, but the token is for project ID ${JSON.stringify(actualProjectId)}.`,
4677
+ {
4678
+ expected_project_id: expectedProjectId,
4679
+ actual_project_id: actualProjectId
4754
4680
  }
4755
- return to.concat(ar || Array.prototype.slice.call(from));
4756
- };
4757
- var DiagComponentLogger = (
4758
- /** @class */
4759
- function() {
4760
- function DiagComponentLogger2(props) {
4761
- this._namespace = props.namespace || "DiagComponentLogger";
4762
- }
4763
- DiagComponentLogger2.prototype.debug = function() {
4764
- var args = [];
4765
- for (var _i = 0; _i < arguments.length; _i++) {
4766
- args[_i] = arguments[_i];
4767
- }
4768
- return logProxy("debug", this._namespace, args);
4769
- };
4770
- DiagComponentLogger2.prototype.error = function() {
4771
- var args = [];
4772
- for (var _i = 0; _i < arguments.length; _i++) {
4773
- args[_i] = arguments[_i];
4774
- }
4775
- return logProxy("error", this._namespace, args);
4776
- };
4777
- DiagComponentLogger2.prototype.info = function() {
4778
- var args = [];
4779
- for (var _i = 0; _i < arguments.length; _i++) {
4780
- args[_i] = arguments[_i];
4781
- }
4782
- return logProxy("info", this._namespace, args);
4783
- };
4784
- DiagComponentLogger2.prototype.warn = function() {
4785
- var args = [];
4786
- for (var _i = 0; _i < arguments.length; _i++) {
4787
- args[_i] = arguments[_i];
4788
- }
4789
- return logProxy("warn", this._namespace, args);
4790
- };
4791
- DiagComponentLogger2.prototype.verbose = function() {
4792
- var args = [];
4793
- for (var _i = 0; _i < arguments.length; _i++) {
4794
- args[_i] = arguments[_i];
4795
- }
4796
- return logProxy("verbose", this._namespace, args);
4797
- };
4798
- return DiagComponentLogger2;
4799
- }()
4800
- );
4801
- function logProxy(funcName, namespace, args) {
4802
- var logger = getGlobal("diag");
4803
- if (!logger) {
4804
- return;
4681
+ ], (json) => [json.expected_project_id, json.actual_project_id]);
4682
+ var RefreshTokenError = createKnownErrorConstructor(KnownError, "REFRESH_TOKEN_ERROR", "inherit", "inherit");
4683
+ 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."], () => []);
4684
+ var CannotDeleteCurrentSession = createKnownErrorConstructor(RefreshTokenError, "CANNOT_DELETE_CURRENT_SESSION", () => [400, "Cannot delete the current session."], () => []);
4685
+ 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."], () => []);
4686
+ var UserWithEmailAlreadyExists = createKnownErrorConstructor(KnownError, "USER_EMAIL_ALREADY_EXISTS", (email, wouldWorkIfEmailWasVerified = false) => [
4687
+ 409,
4688
+ `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." : "."}`,
4689
+ {
4690
+ email,
4691
+ would_work_if_email_was_verified: wouldWorkIfEmailWasVerified
4805
4692
  }
4806
- args.unshift(namespace);
4807
- return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
4808
- }
4809
-
4810
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/types.js
4811
- var DiagLogLevel;
4812
- (function(DiagLogLevel2) {
4813
- DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
4814
- DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
4815
- DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
4816
- DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
4817
- DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
4818
- DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
4819
- DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
4820
- })(DiagLogLevel || (DiagLogLevel = {}));
4821
-
4822
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
4823
- function createLogLevelDiagLogger(maxLevel, logger) {
4824
- if (maxLevel < DiagLogLevel.NONE) {
4825
- maxLevel = DiagLogLevel.NONE;
4826
- } else if (maxLevel > DiagLogLevel.ALL) {
4827
- maxLevel = DiagLogLevel.ALL;
4693
+ ], (json) => [json.email, json.would_work_if_email_was_verified ?? false]);
4694
+ var EmailNotVerified = createKnownErrorConstructor(KnownError, "EMAIL_NOT_VERIFIED", () => [400, "The email is not verified."], () => []);
4695
+ 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."], () => []);
4696
+ var UserIdDoesNotExist = createKnownErrorConstructor(KnownError, "USER_ID_DOES_NOT_EXIST", (userId) => [
4697
+ 400,
4698
+ `The given user with the ID ${userId} does not exist.`,
4699
+ { user_id: userId }
4700
+ ], (json) => [json.user_id]);
4701
+ var UserNotFound = createKnownErrorConstructor(KnownError, "USER_NOT_FOUND", () => [404, "User not found."], () => []);
4702
+ var RestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
4703
+ 403,
4704
+ `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.`,
4705
+ { restricted_reason: restrictedReason }
4706
+ ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
4707
+ var ProjectNotFound = createKnownErrorConstructor(KnownError, "PROJECT_NOT_FOUND", (projectId) => {
4708
+ if (typeof projectId !== "string") throw new HexclaveAssertionError("projectId of KnownErrors.ProjectNotFound must be a string");
4709
+ return [
4710
+ 404,
4711
+ `Project ${projectId} not found or is not accessible with the current user.`,
4712
+ { project_id: projectId }
4713
+ ];
4714
+ }, (json) => [json.project_id]);
4715
+ var CurrentProjectNotFound = createKnownErrorConstructor(KnownError, "CURRENT_PROJECT_NOT_FOUND", (projectId) => [
4716
+ 400,
4717
+ `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.)`,
4718
+ { project_id: projectId }
4719
+ ], (json) => [json.project_id]);
4720
+ var BranchDoesNotExist = createKnownErrorConstructor(KnownError, "BRANCH_DOES_NOT_EXIST", (branchId) => [
4721
+ 400,
4722
+ `The branch with ID ${branchId} does not exist.`,
4723
+ { branch_id: branchId }
4724
+ ], (json) => [json.branch_id]);
4725
+ 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."], () => []);
4726
+ var SignUpRejected = createKnownErrorConstructor(KnownError, "SIGN_UP_REJECTED", (message) => [
4727
+ 403,
4728
+ message ?? "Your sign up was rejected by an administrator's sign-up rule.",
4729
+ { message: message ?? "Your sign up was rejected by an administrator's sign-up rule." }
4730
+ ], (json) => [json.message]);
4731
+ var BotChallengeRequired = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_REQUIRED", () => [409, "An additional bot challenge is required before sign-up can continue."], () => []);
4732
+ var BotChallengeFailed = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_FAILED", (message) => [
4733
+ 400,
4734
+ message,
4735
+ { message }
4736
+ ], (json) => [json.message]);
4737
+ var PasswordAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSWORD_AUTHENTICATION_NOT_ENABLED", () => [400, "Password authentication is not enabled for this project."], () => []);
4738
+ var DataVaultStoreDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_DOES_NOT_EXIST", (storeId) => [
4739
+ 400,
4740
+ `Data vault store with ID ${storeId} does not exist.`,
4741
+ { store_id: storeId }
4742
+ ], (json) => [json.store_id]);
4743
+ var DataVaultStoreHashedKeyDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_HASHED_KEY_DOES_NOT_EXIST", (storeId, hashedKey) => [
4744
+ 400,
4745
+ `Data vault store with ID ${storeId} does not contain a key with hash ${hashedKey}.`,
4746
+ {
4747
+ store_id: storeId,
4748
+ hashed_key: hashedKey
4828
4749
  }
4829
- logger = logger || {};
4830
- function _filterFunc(funcName, theLevel) {
4831
- var theFunc = logger[funcName];
4832
- if (typeof theFunc === "function" && maxLevel >= theLevel) {
4833
- return theFunc.bind(logger);
4834
- }
4835
- return function() {
4836
- };
4750
+ ], (json) => [json.store_id, json.hashed_key]);
4751
+ var PasskeyAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_NOT_ENABLED", () => [400, "Passkey authentication is not enabled for this project."], () => []);
4752
+ var AnonymousAccountsNotEnabled = createKnownErrorConstructor(KnownError, "ANONYMOUS_ACCOUNTS_NOT_ENABLED", () => [400, "Anonymous accounts are not enabled for this project."], () => []);
4753
+ 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."], () => []);
4754
+ var EmailPasswordMismatch = createKnownErrorConstructor(KnownError, "EMAIL_PASSWORD_MISMATCH", () => [400, "Wrong e-mail or password."], () => []);
4755
+ var RedirectUrlNotWhitelisted = createKnownErrorConstructor(KnownError, "REDIRECT_URL_NOT_WHITELISTED", (redirectUrl) => [
4756
+ 400,
4757
+ "Redirect URL not whitelisted. Did you forget to add this domain to the trusted domains list on the Hexclave dashboard?",
4758
+ redirectUrl === void 0 ? void 0 : { redirect_url: redirectUrl }
4759
+ ], (json) => [json?.redirect_url]);
4760
+ var PasswordRequirementsNotMet = createKnownErrorConstructor(KnownError, "PASSWORD_REQUIREMENTS_NOT_MET", "inherit", "inherit");
4761
+ var PasswordTooShort = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_SHORT", (minLength) => [
4762
+ 400,
4763
+ `Password too short. Minimum length is ${minLength}.`,
4764
+ { min_length: minLength }
4765
+ ], (json) => [json?.min_length ?? throwErr("min_length not found in PasswordTooShort details")]);
4766
+ var PasswordTooLong = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_LONG", (maxLength) => [
4767
+ 400,
4768
+ `Password too long. Maximum length is ${maxLength}.`,
4769
+ { maxLength }
4770
+ ], (json) => [json?.maxLength ?? throwErr("maxLength not found in PasswordTooLong details")]);
4771
+ var UserDoesNotHavePassword = createKnownErrorConstructor(KnownError, "USER_DOES_NOT_HAVE_PASSWORD", () => [400, "This user does not have password authentication enabled."], () => []);
4772
+ var VerificationCodeError = createKnownErrorConstructor(KnownError, "VERIFICATION_ERROR", "inherit", "inherit");
4773
+ var VerificationCodeNotFound = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_NOT_FOUND", () => [404, "The verification code does not exist for this project."], () => []);
4774
+ var VerificationCodeExpired = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_EXPIRED", () => [400, "The verification code has expired."], () => []);
4775
+ var VerificationCodeAlreadyUsed = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_ALREADY_USED", () => [409, "The verification link has already been used."], () => []);
4776
+ 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."], () => []);
4777
+ var PasswordConfirmationMismatch = createKnownErrorConstructor(KnownError, "PASSWORD_CONFIRMATION_MISMATCH", () => [400, "Passwords do not match."], () => []);
4778
+ var EmailAlreadyVerified = createKnownErrorConstructor(KnownError, "EMAIL_ALREADY_VERIFIED", () => [409, "The e-mail is already verified."], () => []);
4779
+ 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."], () => []);
4780
+ var EmailIsNotPrimaryEmail = createKnownErrorConstructor(KnownError, "EMAIL_IS_NOT_PRIMARY_EMAIL", (email, primaryEmail) => [
4781
+ 400,
4782
+ `The given e-mail (${email}) must equal the user's primary e-mail (${primaryEmail}).`,
4783
+ {
4784
+ email,
4785
+ primary_email: primaryEmail
4837
4786
  }
4838
- return {
4839
- error: _filterFunc("error", DiagLogLevel.ERROR),
4840
- warn: _filterFunc("warn", DiagLogLevel.WARN),
4841
- info: _filterFunc("info", DiagLogLevel.INFO),
4842
- debug: _filterFunc("debug", DiagLogLevel.DEBUG),
4843
- verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
4844
- };
4845
- }
4846
-
4847
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/diag.js
4848
- var __read2 = function(o21, n9) {
4849
- var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
4850
- if (!m5) return o21;
4851
- var i = m5.call(o21), r7, ar = [], e40;
4852
- try {
4853
- while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
4854
- } catch (error) {
4855
- e40 = { error };
4856
- } finally {
4857
- try {
4858
- if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
4859
- } finally {
4860
- if (e40) throw e40.error;
4861
- }
4787
+ ], (json) => [json.email, json.primary_email]);
4788
+ var PasskeyRegistrationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_REGISTRATION_FAILED", (message) => [400, message], (json) => [json.message]);
4789
+ var PasskeyWebAuthnError = createKnownErrorConstructor(KnownError, "PASSKEY_WEBAUTHN_ERROR", (message, code) => [
4790
+ 400,
4791
+ message,
4792
+ {
4793
+ message,
4794
+ code
4862
4795
  }
4863
- return ar;
4864
- };
4865
- var __spreadArray2 = function(to, from, pack) {
4866
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
4867
- if (ar || !(i in from)) {
4868
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
4869
- ar[i] = from[i];
4870
- }
4796
+ ], (json) => [json.message, json.code]);
4797
+ var PasskeyAuthenticationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_FAILED", (message) => [400, message], (json) => [json.message]);
4798
+ var PermissionNotFound = createKnownErrorConstructor(KnownError, "PERMISSION_NOT_FOUND", (permissionId) => [
4799
+ 404,
4800
+ `Permission "${permissionId}" not found. Make sure you created it on the dashboard.`,
4801
+ { permission_id: permissionId }
4802
+ ], (json) => [json.permission_id]);
4803
+ var PermissionScopeMismatch = createKnownErrorConstructor(KnownError, "WRONG_PERMISSION_SCOPE", (permissionId, expectedScope, actualScope) => [
4804
+ 404,
4805
+ `Permission ${JSON.stringify(permissionId)} not found. (It was found for a different scope ${JSON.stringify(actualScope)}, but scope ${JSON.stringify(expectedScope)} was expected.)`,
4806
+ {
4807
+ permission_id: permissionId,
4808
+ expected_scope: expectedScope,
4809
+ actual_scope: actualScope
4871
4810
  }
4872
- return to.concat(ar || Array.prototype.slice.call(from));
4873
- };
4874
- var API_NAME = "diag";
4875
- var DiagAPI = (
4876
- /** @class */
4877
- function() {
4878
- function DiagAPI2() {
4879
- function _logProxy(funcName) {
4880
- return function() {
4881
- var args = [];
4882
- for (var _i = 0; _i < arguments.length; _i++) {
4883
- args[_i] = arguments[_i];
4884
- }
4885
- var logger = getGlobal("diag");
4886
- if (!logger)
4887
- return;
4888
- return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
4889
- };
4890
- }
4891
- var self2 = this;
4892
- var setLogger = function(logger, optionsOrLogLevel) {
4893
- var _a5, _b, _c;
4894
- if (optionsOrLogLevel === void 0) {
4895
- optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
4896
- }
4897
- if (logger === self2) {
4898
- var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
4899
- self2.error((_a5 = err.stack) !== null && _a5 !== void 0 ? _a5 : err.message);
4900
- return false;
4901
- }
4902
- if (typeof optionsOrLogLevel === "number") {
4903
- optionsOrLogLevel = {
4904
- logLevel: optionsOrLogLevel
4905
- };
4906
- }
4907
- var oldLogger = getGlobal("diag");
4908
- var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
4909
- if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
4910
- var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
4911
- oldLogger.warn("Current logger will be overwritten from " + stack);
4912
- newLogger.warn("Current logger will overwrite one already registered from " + stack);
4913
- }
4914
- return registerGlobal("diag", newLogger, self2, true);
4915
- };
4916
- self2.setLogger = setLogger;
4917
- self2.disable = function() {
4918
- unregisterGlobal(API_NAME, self2);
4919
- };
4920
- self2.createComponentLogger = function(options) {
4921
- return new DiagComponentLogger(options);
4922
- };
4923
- self2.verbose = _logProxy("verbose");
4924
- self2.debug = _logProxy("debug");
4925
- self2.info = _logProxy("info");
4926
- self2.warn = _logProxy("warn");
4927
- self2.error = _logProxy("error");
4928
- }
4929
- DiagAPI2.instance = function() {
4930
- if (!this._instance) {
4931
- this._instance = new DiagAPI2();
4932
- }
4933
- return this._instance;
4934
- };
4935
- return DiagAPI2;
4936
- }()
4937
- );
4938
-
4939
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/context.js
4940
- function createContextKey(description) {
4941
- return Symbol.for(description);
4942
- }
4943
- var BaseContext = (
4944
- /** @class */
4945
- /* @__PURE__ */ function() {
4946
- function BaseContext2(parentContext) {
4947
- var self2 = this;
4948
- self2._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
4949
- self2.getValue = function(key) {
4950
- return self2._currentContext.get(key);
4951
- };
4952
- self2.setValue = function(key, value) {
4953
- var context = new BaseContext2(self2._currentContext);
4954
- context._currentContext.set(key, value);
4955
- return context;
4956
- };
4957
- self2.deleteValue = function(key) {
4958
- var context = new BaseContext2(self2._currentContext);
4959
- context._currentContext.delete(key);
4960
- return context;
4961
- };
4962
- }
4963
- return BaseContext2;
4964
- }()
4965
- );
4966
- var ROOT_CONTEXT = new BaseContext();
4967
-
4968
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js
4969
- var __read3 = function(o21, n9) {
4970
- var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
4971
- if (!m5) return o21;
4972
- var i = m5.call(o21), r7, ar = [], e40;
4973
- try {
4974
- while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
4975
- } catch (error) {
4976
- e40 = { error };
4977
- } finally {
4978
- try {
4979
- if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
4980
- } finally {
4981
- if (e40) throw e40.error;
4982
- }
4811
+ ], (json) => [
4812
+ json.permission_id,
4813
+ json.expected_scope,
4814
+ json.actual_scope
4815
+ ]);
4816
+ var ContainedPermissionNotFound = createKnownErrorConstructor(KnownError, "CONTAINED_PERMISSION_NOT_FOUND", (permissionId) => [
4817
+ 400,
4818
+ `Contained permission with ID "${permissionId}" not found. Make sure you created it on the dashboard.`,
4819
+ { permission_id: permissionId }
4820
+ ], (json) => [json.permission_id]);
4821
+ var TeamNotFound = createKnownErrorConstructor(KnownError, "TEAM_NOT_FOUND", (teamId) => [
4822
+ 404,
4823
+ `Team ${teamId} not found.`,
4824
+ { team_id: teamId }
4825
+ ], (json) => [json.team_id]);
4826
+ createKnownErrorConstructor(KnownError, "TEAM_ALREADY_EXISTS", (teamId) => [
4827
+ 409,
4828
+ `Team ${teamId} already exists.`,
4829
+ { team_id: teamId }
4830
+ ], (json) => [json.team_id]);
4831
+ var TeamMembershipNotFound = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_NOT_FOUND", (teamId, userId) => [
4832
+ 404,
4833
+ `User ${userId} is not found in team ${teamId}.`,
4834
+ {
4835
+ team_id: teamId,
4836
+ user_id: userId
4983
4837
  }
4984
- return ar;
4985
- };
4986
- var __spreadArray3 = function(to, from, pack) {
4987
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
4988
- if (ar || !(i in from)) {
4989
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
4990
- ar[i] = from[i];
4991
- }
4838
+ ], (json) => [json.team_id, json.user_id]);
4839
+ var TeamInvitationRestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "TEAM_INVITATION_RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
4840
+ 403,
4841
+ `Restricted users cannot accept team invitations. Reason: ${restrictedReason.type}. Please complete the onboarding process before accepting team invitations.`,
4842
+ { restricted_reason: restrictedReason }
4843
+ ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
4844
+ 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."], () => []);
4845
+ var EmailTemplateAlreadyExists = createKnownErrorConstructor(KnownError, "EMAIL_TEMPLATE_ALREADY_EXISTS", () => [409, "Email template already exists."], () => []);
4846
+ var OAuthConnectionNotConnectedToUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_NOT_CONNECTED_TO_USER", () => [400, "The OAuth connection is not connected to any user."], () => []);
4847
+ var OAuthConnectionAlreadyConnectedToAnotherUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_ALREADY_CONNECTED_TO_ANOTHER_USER", () => [409, "The OAuth connection is already connected to another user."], () => []);
4848
+ var OAuthConnectionDoesNotHaveRequiredScope = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_DOES_NOT_HAVE_REQUIRED_SCOPE", () => [400, "The OAuth connection does not have the required scope."], () => []);
4849
+ var OAuthAccessTokenNotAvailable = createKnownErrorConstructor(KnownError, "OAUTH_ACCESS_TOKEN_NOT_AVAILABLE", (provider, details) => [
4850
+ 400,
4851
+ `Failed to retrieve an OAuth access token for the connected account (provider: ${provider}). ${details}`,
4852
+ {
4853
+ provider,
4854
+ details
4992
4855
  }
4993
- return to.concat(ar || Array.prototype.slice.call(from));
4994
- };
4995
- var NoopContextManager = (
4996
- /** @class */
4997
- function() {
4998
- function NoopContextManager2() {
4999
- }
5000
- NoopContextManager2.prototype.active = function() {
5001
- return ROOT_CONTEXT;
5002
- };
5003
- NoopContextManager2.prototype.with = function(_context, fn, thisArg) {
5004
- var args = [];
5005
- for (var _i = 3; _i < arguments.length; _i++) {
5006
- args[_i - 3] = arguments[_i];
5007
- }
5008
- return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
5009
- };
5010
- NoopContextManager2.prototype.bind = function(_context, target) {
5011
- return target;
5012
- };
5013
- NoopContextManager2.prototype.enable = function() {
5014
- return this;
5015
- };
5016
- NoopContextManager2.prototype.disable = function() {
5017
- return this;
5018
- };
5019
- return NoopContextManager2;
5020
- }()
5021
- );
5022
-
5023
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/context.js
5024
- var __read4 = function(o21, n9) {
5025
- var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
5026
- if (!m5) return o21;
5027
- var i = m5.call(o21), r7, ar = [], e40;
5028
- try {
5029
- while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
5030
- } catch (error) {
5031
- e40 = { error };
5032
- } finally {
5033
- try {
5034
- if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
5035
- } finally {
5036
- if (e40) throw e40.error;
5037
- }
4856
+ ], (json) => [json.provider, json.details]);
4857
+ 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."], () => []);
4858
+ 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."], () => []);
4859
+ var InvalidOAuthClientIdOrSecret = createKnownErrorConstructor(KnownError, "INVALID_OAUTH_CLIENT_ID_OR_SECRET", (clientId) => [
4860
+ 400,
4861
+ "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.",
4862
+ { client_id: clientId ?? null }
4863
+ ], (json) => [json.client_id ?? void 0]);
4864
+ var InvalidScope = createKnownErrorConstructor(KnownError, "INVALID_SCOPE", (scope) => [400, `The scope "${scope}" is not a valid OAuth scope for Stack.`], (json) => [json.scope]);
4865
+ 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?"], () => []);
4866
+ var OuterOAuthTimeout = createKnownErrorConstructor(KnownError, "OUTER_OAUTH_TIMEOUT", () => [408, "The OAuth flow has timed out. Please sign in again."], () => []);
4867
+ var OAuthProviderNotFoundOrNotEnabled = createKnownErrorConstructor(KnownError, "OAUTH_PROVIDER_NOT_FOUND_OR_NOT_ENABLED", () => [400, "The OAuth provider is not found or not enabled."], () => []);
4868
+ 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."], () => []);
4869
+ 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.`], () => []);
4870
+ var MultiFactorAuthenticationRequired = createKnownErrorConstructor(KnownError, "MULTI_FACTOR_AUTHENTICATION_REQUIRED", (attemptCode) => [
4871
+ 400,
4872
+ `Multi-factor authentication is required for this user.`,
4873
+ { attempt_code: attemptCode }
4874
+ ], (json) => [json.attempt_code]);
4875
+ var InvalidTotpCode = createKnownErrorConstructor(KnownError, "INVALID_TOTP_CODE", () => [400, "The TOTP code is invalid. Please try again."], () => []);
4876
+ var UserAuthenticationRequired = createKnownErrorConstructor(KnownError, "USER_AUTHENTICATION_REQUIRED", () => [401, "User authentication required for this endpoint."], () => []);
4877
+ var TeamMembershipAlreadyExists = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_ALREADY_EXISTS", () => [409, "Team membership already exists."], () => []);
4878
+ var ProjectPermissionRequired = createKnownErrorConstructor(KnownError, "PROJECT_PERMISSION_REQUIRED", (userId, permissionId) => [
4879
+ 401,
4880
+ `User ${userId} does not have permission ${permissionId}.`,
4881
+ {
4882
+ user_id: userId,
4883
+ permission_id: permissionId
5038
4884
  }
5039
- return ar;
5040
- };
5041
- var __spreadArray4 = function(to, from, pack) {
5042
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
5043
- if (ar || !(i in from)) {
5044
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5045
- ar[i] = from[i];
5046
- }
5047
- }
5048
- return to.concat(ar || Array.prototype.slice.call(from));
5049
- };
5050
- var API_NAME2 = "context";
5051
- var NOOP_CONTEXT_MANAGER = new NoopContextManager();
5052
- var ContextAPI = (
5053
- /** @class */
5054
- function() {
5055
- function ContextAPI2() {
5056
- }
5057
- ContextAPI2.getInstance = function() {
5058
- if (!this._instance) {
5059
- this._instance = new ContextAPI2();
5060
- }
5061
- return this._instance;
5062
- };
5063
- ContextAPI2.prototype.setGlobalContextManager = function(contextManager) {
5064
- return registerGlobal(API_NAME2, contextManager, DiagAPI.instance());
5065
- };
5066
- ContextAPI2.prototype.active = function() {
5067
- return this._getContextManager().active();
5068
- };
5069
- ContextAPI2.prototype.with = function(context, fn, thisArg) {
5070
- var _a5;
5071
- var args = [];
5072
- for (var _i = 3; _i < arguments.length; _i++) {
5073
- args[_i - 3] = arguments[_i];
5074
- }
5075
- return (_a5 = this._getContextManager()).with.apply(_a5, __spreadArray4([context, fn, thisArg], __read4(args), false));
5076
- };
5077
- ContextAPI2.prototype.bind = function(context, target) {
5078
- return this._getContextManager().bind(context, target);
5079
- };
5080
- ContextAPI2.prototype._getContextManager = function() {
5081
- return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
5082
- };
5083
- ContextAPI2.prototype.disable = function() {
5084
- this._getContextManager().disable();
5085
- unregisterGlobal(API_NAME2, DiagAPI.instance());
5086
- };
5087
- return ContextAPI2;
5088
- }()
5089
- );
5090
-
5091
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js
5092
- var TraceFlags;
5093
- (function(TraceFlags2) {
5094
- TraceFlags2[TraceFlags2["NONE"] = 0] = "NONE";
5095
- TraceFlags2[TraceFlags2["SAMPLED"] = 1] = "SAMPLED";
5096
- })(TraceFlags || (TraceFlags = {}));
5097
-
5098
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js
5099
- var INVALID_SPANID = "0000000000000000";
5100
- var INVALID_TRACEID = "00000000000000000000000000000000";
5101
- var INVALID_SPAN_CONTEXT = {
5102
- traceId: INVALID_TRACEID,
5103
- spanId: INVALID_SPANID,
5104
- traceFlags: TraceFlags.NONE
5105
- };
5106
-
5107
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js
5108
- var NonRecordingSpan = (
5109
- /** @class */
5110
- function() {
5111
- function NonRecordingSpan2(_spanContext) {
5112
- if (_spanContext === void 0) {
5113
- _spanContext = INVALID_SPAN_CONTEXT;
5114
- }
5115
- this._spanContext = _spanContext;
5116
- }
5117
- NonRecordingSpan2.prototype.spanContext = function() {
5118
- return this._spanContext;
5119
- };
5120
- NonRecordingSpan2.prototype.setAttribute = function(_key, _value) {
5121
- return this;
5122
- };
5123
- NonRecordingSpan2.prototype.setAttributes = function(_attributes) {
5124
- return this;
5125
- };
5126
- NonRecordingSpan2.prototype.addEvent = function(_name, _attributes) {
5127
- return this;
5128
- };
5129
- NonRecordingSpan2.prototype.addLink = function(_link) {
5130
- return this;
5131
- };
5132
- NonRecordingSpan2.prototype.addLinks = function(_links) {
5133
- return this;
5134
- };
5135
- NonRecordingSpan2.prototype.setStatus = function(_status) {
5136
- return this;
5137
- };
5138
- NonRecordingSpan2.prototype.updateName = function(_name) {
5139
- return this;
5140
- };
5141
- NonRecordingSpan2.prototype.end = function(_endTime) {
5142
- };
5143
- NonRecordingSpan2.prototype.isRecording = function() {
5144
- return false;
5145
- };
5146
- NonRecordingSpan2.prototype.recordException = function(_exception, _time) {
5147
- };
5148
- return NonRecordingSpan2;
5149
- }()
5150
- );
5151
-
5152
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js
5153
- var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
5154
- function getSpan(context) {
5155
- return context.getValue(SPAN_KEY) || void 0;
5156
- }
5157
- function getActiveSpan() {
5158
- return getSpan(ContextAPI.getInstance().active());
5159
- }
5160
- function setSpan(context, span) {
5161
- return context.setValue(SPAN_KEY, span);
5162
- }
5163
- function deleteSpan(context) {
5164
- return context.deleteValue(SPAN_KEY);
5165
- }
5166
- function setSpanContext(context, spanContext) {
5167
- return setSpan(context, new NonRecordingSpan(spanContext));
5168
- }
5169
- function getSpanContext(context) {
5170
- var _a5;
5171
- return (_a5 = getSpan(context)) === null || _a5 === void 0 ? void 0 : _a5.spanContext();
5172
- }
5173
-
5174
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
5175
- var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
5176
- var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
5177
- function isValidTraceId(traceId) {
5178
- return VALID_TRACEID_REGEX.test(traceId) && traceId !== INVALID_TRACEID;
5179
- }
5180
- function isValidSpanId(spanId) {
5181
- return VALID_SPANID_REGEX.test(spanId) && spanId !== INVALID_SPANID;
5182
- }
5183
- function isSpanContextValid(spanContext) {
5184
- return isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);
5185
- }
5186
- function wrapSpanContext(spanContext) {
5187
- return new NonRecordingSpan(spanContext);
5188
- }
5189
-
5190
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js
5191
- var contextApi = ContextAPI.getInstance();
5192
- var NoopTracer = (
5193
- /** @class */
5194
- function() {
5195
- function NoopTracer2() {
5196
- }
5197
- NoopTracer2.prototype.startSpan = function(name, options, context) {
5198
- if (context === void 0) {
5199
- context = contextApi.active();
5200
- }
5201
- var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
5202
- if (root) {
5203
- return new NonRecordingSpan();
5204
- }
5205
- var parentFromContext = context && getSpanContext(context);
5206
- if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
5207
- return new NonRecordingSpan(parentFromContext);
5208
- } else {
5209
- return new NonRecordingSpan();
5210
- }
5211
- };
5212
- NoopTracer2.prototype.startActiveSpan = function(name, arg2, arg3, arg4) {
5213
- var opts;
5214
- var ctx;
5215
- var fn;
5216
- if (arguments.length < 2) {
5217
- return;
5218
- } else if (arguments.length === 2) {
5219
- fn = arg2;
5220
- } else if (arguments.length === 3) {
5221
- opts = arg2;
5222
- fn = arg3;
5223
- } else {
5224
- opts = arg2;
5225
- ctx = arg3;
5226
- fn = arg4;
5227
- }
5228
- var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
5229
- var span = this.startSpan(name, opts, parentContext);
5230
- var contextWithSpanSet = setSpan(parentContext, span);
5231
- return contextApi.with(contextWithSpanSet, fn, void 0, span);
5232
- };
5233
- return NoopTracer2;
5234
- }()
5235
- );
5236
- function isSpanContext(spanContext) {
5237
- return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
5238
- }
5239
-
5240
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js
5241
- var NOOP_TRACER = new NoopTracer();
5242
- var ProxyTracer = (
5243
- /** @class */
5244
- function() {
5245
- function ProxyTracer2(_provider, name, version, options) {
5246
- this._provider = _provider;
5247
- this.name = name;
5248
- this.version = version;
5249
- this.options = options;
5250
- }
5251
- ProxyTracer2.prototype.startSpan = function(name, options, context) {
5252
- return this._getTracer().startSpan(name, options, context);
5253
- };
5254
- ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
5255
- var tracer2 = this._getTracer();
5256
- return Reflect.apply(tracer2.startActiveSpan, tracer2, arguments);
5257
- };
5258
- ProxyTracer2.prototype._getTracer = function() {
5259
- if (this._delegate) {
5260
- return this._delegate;
5261
- }
5262
- var tracer2 = this._provider.getDelegateTracer(this.name, this.version, this.options);
5263
- if (!tracer2) {
5264
- return NOOP_TRACER;
5265
- }
5266
- this._delegate = tracer2;
5267
- return this._delegate;
5268
- };
5269
- return ProxyTracer2;
5270
- }()
5271
- );
5272
-
5273
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js
5274
- var NoopTracerProvider = (
5275
- /** @class */
5276
- function() {
5277
- function NoopTracerProvider2() {
5278
- }
5279
- NoopTracerProvider2.prototype.getTracer = function(_name, _version, _options) {
5280
- return new NoopTracer();
5281
- };
5282
- return NoopTracerProvider2;
5283
- }()
5284
- );
5285
-
5286
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js
5287
- var NOOP_TRACER_PROVIDER = new NoopTracerProvider();
5288
- var ProxyTracerProvider = (
5289
- /** @class */
5290
- function() {
5291
- function ProxyTracerProvider2() {
5292
- }
5293
- ProxyTracerProvider2.prototype.getTracer = function(name, version, options) {
5294
- var _a5;
5295
- return (_a5 = this.getDelegateTracer(name, version, options)) !== null && _a5 !== void 0 ? _a5 : new ProxyTracer(this, name, version, options);
5296
- };
5297
- ProxyTracerProvider2.prototype.getDelegate = function() {
5298
- var _a5;
5299
- return (_a5 = this._delegate) !== null && _a5 !== void 0 ? _a5 : NOOP_TRACER_PROVIDER;
5300
- };
5301
- ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
5302
- this._delegate = delegate;
5303
- };
5304
- ProxyTracerProvider2.prototype.getDelegateTracer = function(name, version, options) {
5305
- var _a5;
5306
- return (_a5 = this._delegate) === null || _a5 === void 0 ? void 0 : _a5.getTracer(name, version, options);
5307
- };
5308
- return ProxyTracerProvider2;
5309
- }()
5310
- );
5311
-
5312
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/trace.js
5313
- var API_NAME3 = "trace";
5314
- var TraceAPI = (
5315
- /** @class */
5316
- function() {
5317
- function TraceAPI2() {
5318
- this._proxyTracerProvider = new ProxyTracerProvider();
5319
- this.wrapSpanContext = wrapSpanContext;
5320
- this.isSpanContextValid = isSpanContextValid;
5321
- this.deleteSpan = deleteSpan;
5322
- this.getSpan = getSpan;
5323
- this.getActiveSpan = getActiveSpan;
5324
- this.getSpanContext = getSpanContext;
5325
- this.setSpan = setSpan;
5326
- this.setSpanContext = setSpanContext;
5327
- }
5328
- TraceAPI2.getInstance = function() {
5329
- if (!this._instance) {
5330
- this._instance = new TraceAPI2();
5331
- }
5332
- return this._instance;
5333
- };
5334
- TraceAPI2.prototype.setGlobalTracerProvider = function(provider) {
5335
- var success = registerGlobal(API_NAME3, this._proxyTracerProvider, DiagAPI.instance());
5336
- if (success) {
5337
- this._proxyTracerProvider.setDelegate(provider);
5338
- }
5339
- return success;
5340
- };
5341
- TraceAPI2.prototype.getTracerProvider = function() {
5342
- return getGlobal(API_NAME3) || this._proxyTracerProvider;
5343
- };
5344
- TraceAPI2.prototype.getTracer = function(name, version) {
5345
- return this.getTracerProvider().getTracer(name, version);
5346
- };
5347
- TraceAPI2.prototype.disable = function() {
5348
- unregisterGlobal(API_NAME3, DiagAPI.instance());
5349
- this._proxyTracerProvider = new ProxyTracerProvider();
5350
- };
5351
- return TraceAPI2;
5352
- }()
5353
- );
5354
-
5355
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace-api.js
5356
- var trace = TraceAPI.getInstance();
5357
-
5358
- // ../shared/dist/esm/utils/telemetry.js
5359
- var tracer = trace.getTracer("stack-tracer");
5360
- async function traceSpan(optionsOrDescription, fn) {
5361
- let options = typeof optionsOrDescription === "string" ? { description: optionsOrDescription } : optionsOrDescription;
5362
- return await tracer.startActiveSpan(`STACK: ${options.description}`, async (span) => {
5363
- if (options.attributes) for (const [key, value] of Object.entries(options.attributes)) span.setAttribute(key, value);
5364
- try {
5365
- return await fn(span);
5366
- } finally {
5367
- span.end();
5368
- }
5369
- });
5370
- }
5371
-
5372
- // ../shared/dist/esm/known-errors.js
5373
- var KnownError = class extends StatusError {
5374
- constructor(statusCode, humanReadableMessage, details) {
5375
- super(statusCode, humanReadableMessage);
5376
- this.statusCode = statusCode;
5377
- this.humanReadableMessage = humanReadableMessage;
5378
- this.details = details;
5379
- this.__stackKnownErrorBrand = "stack-known-error-brand-sentinel";
5380
- this.name = "KnownError";
5381
- }
5382
- static isKnownError(error) {
5383
- return typeof error === "object" && error !== null && "__stackKnownErrorBrand" in error && error.__stackKnownErrorBrand === "stack-known-error-brand-sentinel";
5384
- }
5385
- getBody() {
5386
- return new TextEncoder().encode(JSON.stringify(this.toDescriptiveJson(), void 0, 2));
5387
- }
5388
- getHeaders() {
5389
- return {
5390
- "Content-Type": ["application/json; charset=utf-8"],
5391
- "X-Stack-Known-Error": [this.errorCode],
5392
- "X-Hexclave-Known-Error": [this.errorCode]
5393
- };
5394
- }
5395
- toDescriptiveJson() {
5396
- return {
5397
- code: this.errorCode,
5398
- ...this.details ? { details: this.details } : {},
5399
- error: this.humanReadableMessage
5400
- };
5401
- }
5402
- get errorCode() {
5403
- return this.constructor.errorCode ?? throwErr(`Can't find error code for this KnownError. Is its constructor a KnownErrorConstructor? ${this}`);
5404
- }
5405
- static constructorArgsFromJson(json) {
5406
- return [
5407
- 400,
5408
- json.message,
5409
- json
5410
- ];
5411
- }
5412
- static fromJson(json) {
5413
- for (const [_, KnownErrorType] of Object.entries(KnownErrors)) if (json.code === KnownErrorType.prototype.errorCode) return new KnownErrorType(...KnownErrorType.constructorArgsFromJson(json));
5414
- throw new Error(`An error occurred. Please update your version of the Hexclave SDK. ${json.code}: ${json.message}`);
5415
- }
5416
- };
5417
- function createKnownErrorConstructor(SuperClass, errorCode, create, constructorArgsFromJson) {
5418
- const createFn = create === "inherit" ? identityArgs : create;
5419
- const constructorArgsFromJsonFn = constructorArgsFromJson === "inherit" ? SuperClass.constructorArgsFromJson : constructorArgsFromJson;
5420
- const _KnownErrorImpl = class _KnownErrorImpl extends SuperClass {
5421
- constructor(...args) {
5422
- super(...createFn(...args));
5423
- this.name = `KnownError<${errorCode}>`;
5424
- this.constructorArgs = args;
5425
- }
5426
- static constructorArgsFromJson(json) {
5427
- return constructorArgsFromJsonFn(json.details);
5428
- }
5429
- static isInstance(error) {
5430
- if (!KnownError.isKnownError(error)) return false;
5431
- let current = error;
5432
- while (true) {
5433
- current = Object.getPrototypeOf(current);
5434
- if (!current) break;
5435
- if ("errorCode" in current.constructor && current.constructor.errorCode === errorCode) return true;
5436
- }
5437
- return false;
5438
- }
5439
- };
5440
- _KnownErrorImpl.errorCode = errorCode;
5441
- let KnownErrorImpl = _KnownErrorImpl;
5442
- return KnownErrorImpl;
5443
- }
5444
- var UnsupportedError = createKnownErrorConstructor(KnownError, "UNSUPPORTED_ERROR", (originalErrorCode) => [
5445
- 500,
5446
- `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}`,
5447
- { originalErrorCode }
5448
- ], (json) => [json?.originalErrorCode ?? throwErr("originalErrorCode not found in UnsupportedError details")]);
5449
- var BodyParsingError = createKnownErrorConstructor(KnownError, "BODY_PARSING_ERROR", (message) => [400, message], (json) => [json.message]);
5450
- var SchemaError = createKnownErrorConstructor(KnownError, "SCHEMA_ERROR", (message) => [
5451
- 400,
5452
- message || throwErr("SchemaError requires a message"),
5453
- { message }
5454
- ], (json) => [json.message]);
5455
- var AllOverloadsFailed = createKnownErrorConstructor(KnownError, "ALL_OVERLOADS_FAILED", (overloadErrors) => [
5456
- 400,
5457
- deindent`
5458
- This endpoint has multiple overloads, but they all failed to process the request.
5459
-
5460
- ${overloadErrors.map((e40, i) => deindent`
5461
- Overload ${i + 1}: ${JSON.stringify(e40, void 0, 2)}
5462
- `).join("\n\n")}
5463
- `,
5464
- { overload_errors: overloadErrors }
5465
- ], (json) => [json?.overload_errors ?? throwErr("overload_errors not found in AllOverloadsFailed details")]);
5466
- var ProjectAuthenticationError = createKnownErrorConstructor(KnownError, "PROJECT_AUTHENTICATION_ERROR", "inherit", "inherit");
5467
- var InvalidProjectAuthentication = createKnownErrorConstructor(ProjectAuthenticationError, "INVALID_PROJECT_AUTHENTICATION", "inherit", "inherit");
5468
- 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.)"], () => []);
5469
- 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")]);
5470
- var AccessTypeWithoutProjectId = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_WITHOUT_PROJECT_ID", (accessType) => [
5471
- 400,
5472
- deindent`
5473
- 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.)
5474
-
5475
- For more information, see the docs on REST API authentication: https://docs.hexclave.com/api/overview#authentication
5476
- `,
5477
- { request_type: accessType }
5478
- ], (json) => [json.request_type]);
5479
- var AccessTypeRequired = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_REQUIRED", () => [400, deindent`
5480
- 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.)
5481
-
5482
- For more information, see the docs on REST API authentication: https://docs.hexclave.com/api/overview#authentication
5483
- `], () => []);
5484
- var InsufficientAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "INSUFFICIENT_ACCESS_TYPE", (actualAccessType, allowedAccessTypes) => [
5485
- 401,
5486
- `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.)`,
5487
- {
5488
- actual_access_type: actualAccessType,
5489
- allowed_access_types: allowedAccessTypes
5490
- }
5491
- ], (json) => [json.actual_access_type, json.allowed_access_types]);
5492
- var InvalidPublishableClientKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_PUBLISHABLE_CLIENT_KEY", (projectId) => [
5493
- 401,
5494
- `The publishable key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
5495
- { project_id: projectId }
5496
- ], (json) => [json.project_id]);
5497
- var InvalidSecretServerKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SECRET_SERVER_KEY", (projectId) => [
5498
- 401,
5499
- `The secret server key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
5500
- { project_id: projectId }
5501
- ], (json) => [json.project_id]);
5502
- var InvalidSuperSecretAdminKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SUPER_SECRET_ADMIN_KEY", (projectId) => [
5503
- 401,
5504
- `The super secret admin key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
5505
- { project_id: projectId }
5506
- ], (json) => [json.project_id]);
5507
- var InvalidAdminAccessToken = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_ADMIN_ACCESS_TOKEN", "inherit", "inherit");
5508
- var UnparsableAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "UNPARSABLE_ADMIN_ACCESS_TOKEN", () => [401, "Admin access token is not parsable."], () => []);
5509
- var AdminAccessTokenExpired = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_EXPIRED", (expiredAt) => [
5510
- 401,
5511
- `Admin access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)` : ""}`,
5512
- { expired_at_millis: expiredAt?.getTime() ?? null }
5513
- ], (json) => [json.expired_at_millis ? new Date(json.expired_at_millis) : void 0]);
5514
- var InvalidProjectForAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "INVALID_PROJECT_FOR_ADMIN_ACCESS_TOKEN", () => [401, "Admin access tokens must be created on the internal project."], () => []);
5515
- var AdminAccessTokenIsNotAdmin = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_IS_NOT_ADMIN", () => [401, "Admin access token does not have the required permissions to access this project."], () => []);
5516
- var ProjectAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationError, "PROJECT_AUTHENTICATION_REQUIRED", "inherit", "inherit");
5517
- var ClientAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_AUTHENTICATION_REQUIRED", () => [401, "The publishable client key must be provided."], () => []);
5518
- var PublishableClientKeyRequiredForProject = createKnownErrorConstructor(ProjectAuthenticationRequired, "PUBLISHABLE_CLIENT_KEY_REQUIRED_FOR_PROJECT", (projectId) => [
5519
- 401,
5520
- "Publishable client keys are required for this project. Create one in Project Keys, or disable this requirement there to allow keyless client access.",
5521
- { project_id: projectId ?? null }
5522
- ], (json) => [json.project_id ?? void 0]);
5523
- var ServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "SERVER_AUTHENTICATION_REQUIRED", () => [401, "The secret server key must be provided."], () => []);
5524
- var ClientOrServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_SERVER_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the secret server key must be provided."], () => []);
5525
- var ClientOrAdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_ADMIN_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the super secret admin key must be provided."], () => []);
5526
- 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."], () => []);
5527
- var AdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "ADMIN_AUTHENTICATION_REQUIRED", () => [401, "The super secret admin key must be provided."], () => []);
5528
- var ExpectedInternalProject = createKnownErrorConstructor(ProjectAuthenticationError, "EXPECTED_INTERNAL_PROJECT", () => [401, "The project ID is expected to be internal."], () => []);
5529
- var SessionAuthenticationError = createKnownErrorConstructor(KnownError, "SESSION_AUTHENTICATION_ERROR", "inherit", "inherit");
5530
- var InvalidSessionAuthentication = createKnownErrorConstructor(SessionAuthenticationError, "INVALID_SESSION_AUTHENTICATION", "inherit", "inherit");
5531
- var InvalidAccessToken = createKnownErrorConstructor(InvalidSessionAuthentication, "INVALID_ACCESS_TOKEN", "inherit", "inherit");
5532
- var UnparsableAccessToken = createKnownErrorConstructor(InvalidAccessToken, "UNPARSABLE_ACCESS_TOKEN", () => [401, "Access token is not parsable."], () => []);
5533
- var AccessTokenExpired = createKnownErrorConstructor(InvalidAccessToken, "ACCESS_TOKEN_EXPIRED", (expiredAt, projectId, userId, refreshTokenId) => [
5534
- 401,
5535
- deindent`
5536
- 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}.` : ""}
5537
-
5538
- 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.
5539
- `,
5540
- {
5541
- expired_at_millis: expiredAt?.getTime() ?? null,
5542
- project_id: projectId ?? null,
5543
- user_id: userId ?? null,
5544
- refresh_token_id: refreshTokenId ?? null
5545
- }
5546
- ], (json) => [
5547
- json.expired_at_millis ? new Date(json.expired_at_millis) : void 0,
5548
- json.project_id ?? void 0,
5549
- json.user_id ?? void 0,
5550
- json.refresh_token_id ?? void 0
5551
- ]);
5552
- var InvalidProjectForAccessToken = createKnownErrorConstructor(InvalidAccessToken, "INVALID_PROJECT_FOR_ACCESS_TOKEN", (expectedProjectId, actualProjectId) => [
5553
- 401,
5554
- `Access token not valid for this project. Expected project ID ${JSON.stringify(expectedProjectId)}, but the token is for project ID ${JSON.stringify(actualProjectId)}.`,
5555
- {
5556
- expected_project_id: expectedProjectId,
5557
- actual_project_id: actualProjectId
5558
- }
5559
- ], (json) => [json.expected_project_id, json.actual_project_id]);
5560
- var RefreshTokenError = createKnownErrorConstructor(KnownError, "REFRESH_TOKEN_ERROR", "inherit", "inherit");
5561
- 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."], () => []);
5562
- var CannotDeleteCurrentSession = createKnownErrorConstructor(RefreshTokenError, "CANNOT_DELETE_CURRENT_SESSION", () => [400, "Cannot delete the current session."], () => []);
5563
- 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."], () => []);
5564
- var UserWithEmailAlreadyExists = createKnownErrorConstructor(KnownError, "USER_EMAIL_ALREADY_EXISTS", (email, wouldWorkIfEmailWasVerified = false) => [
5565
- 409,
5566
- `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." : "."}`,
5567
- {
5568
- email,
5569
- would_work_if_email_was_verified: wouldWorkIfEmailWasVerified
5570
- }
5571
- ], (json) => [json.email, json.would_work_if_email_was_verified ?? false]);
5572
- var EmailNotVerified = createKnownErrorConstructor(KnownError, "EMAIL_NOT_VERIFIED", () => [400, "The email is not verified."], () => []);
5573
- 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."], () => []);
5574
- var UserIdDoesNotExist = createKnownErrorConstructor(KnownError, "USER_ID_DOES_NOT_EXIST", (userId) => [
5575
- 400,
5576
- `The given user with the ID ${userId} does not exist.`,
5577
- { user_id: userId }
5578
- ], (json) => [json.user_id]);
5579
- var UserNotFound = createKnownErrorConstructor(KnownError, "USER_NOT_FOUND", () => [404, "User not found."], () => []);
5580
- var RestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
5581
- 403,
5582
- `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.`,
5583
- { restricted_reason: restrictedReason }
5584
- ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
5585
- var ProjectNotFound = createKnownErrorConstructor(KnownError, "PROJECT_NOT_FOUND", (projectId) => {
5586
- if (typeof projectId !== "string") throw new HexclaveAssertionError("projectId of KnownErrors.ProjectNotFound must be a string");
5587
- return [
5588
- 404,
5589
- `Project ${projectId} not found or is not accessible with the current user.`,
5590
- { project_id: projectId }
5591
- ];
5592
- }, (json) => [json.project_id]);
5593
- var CurrentProjectNotFound = createKnownErrorConstructor(KnownError, "CURRENT_PROJECT_NOT_FOUND", (projectId) => [
5594
- 400,
5595
- `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.)`,
5596
- { project_id: projectId }
5597
- ], (json) => [json.project_id]);
5598
- var BranchDoesNotExist = createKnownErrorConstructor(KnownError, "BRANCH_DOES_NOT_EXIST", (branchId) => [
5599
- 400,
5600
- `The branch with ID ${branchId} does not exist.`,
5601
- { branch_id: branchId }
5602
- ], (json) => [json.branch_id]);
5603
- 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."], () => []);
5604
- var SignUpRejected = createKnownErrorConstructor(KnownError, "SIGN_UP_REJECTED", (message) => [
5605
- 403,
5606
- message ?? "Your sign up was rejected by an administrator's sign-up rule.",
5607
- { message: message ?? "Your sign up was rejected by an administrator's sign-up rule." }
5608
- ], (json) => [json.message]);
5609
- var BotChallengeRequired = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_REQUIRED", () => [409, "An additional bot challenge is required before sign-up can continue."], () => []);
5610
- var BotChallengeFailed = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_FAILED", (message) => [
5611
- 400,
5612
- message,
5613
- { message }
5614
- ], (json) => [json.message]);
5615
- var PasswordAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSWORD_AUTHENTICATION_NOT_ENABLED", () => [400, "Password authentication is not enabled for this project."], () => []);
5616
- var DataVaultStoreDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_DOES_NOT_EXIST", (storeId) => [
5617
- 400,
5618
- `Data vault store with ID ${storeId} does not exist.`,
5619
- { store_id: storeId }
5620
- ], (json) => [json.store_id]);
5621
- var DataVaultStoreHashedKeyDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_HASHED_KEY_DOES_NOT_EXIST", (storeId, hashedKey) => [
5622
- 400,
5623
- `Data vault store with ID ${storeId} does not contain a key with hash ${hashedKey}.`,
5624
- {
5625
- store_id: storeId,
5626
- hashed_key: hashedKey
5627
- }
5628
- ], (json) => [json.store_id, json.hashed_key]);
5629
- var PasskeyAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_NOT_ENABLED", () => [400, "Passkey authentication is not enabled for this project."], () => []);
5630
- var AnonymousAccountsNotEnabled = createKnownErrorConstructor(KnownError, "ANONYMOUS_ACCOUNTS_NOT_ENABLED", () => [400, "Anonymous accounts are not enabled for this project."], () => []);
5631
- 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."], () => []);
5632
- var EmailPasswordMismatch = createKnownErrorConstructor(KnownError, "EMAIL_PASSWORD_MISMATCH", () => [400, "Wrong e-mail or password."], () => []);
5633
- var RedirectUrlNotWhitelisted = createKnownErrorConstructor(KnownError, "REDIRECT_URL_NOT_WHITELISTED", (redirectUrl) => [
5634
- 400,
5635
- "Redirect URL not whitelisted. Did you forget to add this domain to the trusted domains list on the Hexclave dashboard?",
5636
- redirectUrl === void 0 ? void 0 : { redirect_url: redirectUrl }
5637
- ], (json) => [json?.redirect_url]);
5638
- var PasswordRequirementsNotMet = createKnownErrorConstructor(KnownError, "PASSWORD_REQUIREMENTS_NOT_MET", "inherit", "inherit");
5639
- var PasswordTooShort = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_SHORT", (minLength) => [
5640
- 400,
5641
- `Password too short. Minimum length is ${minLength}.`,
5642
- { min_length: minLength }
5643
- ], (json) => [json?.min_length ?? throwErr("min_length not found in PasswordTooShort details")]);
5644
- var PasswordTooLong = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_LONG", (maxLength) => [
5645
- 400,
5646
- `Password too long. Maximum length is ${maxLength}.`,
5647
- { maxLength }
5648
- ], (json) => [json?.maxLength ?? throwErr("maxLength not found in PasswordTooLong details")]);
5649
- var UserDoesNotHavePassword = createKnownErrorConstructor(KnownError, "USER_DOES_NOT_HAVE_PASSWORD", () => [400, "This user does not have password authentication enabled."], () => []);
5650
- var VerificationCodeError = createKnownErrorConstructor(KnownError, "VERIFICATION_ERROR", "inherit", "inherit");
5651
- var VerificationCodeNotFound = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_NOT_FOUND", () => [404, "The verification code does not exist for this project."], () => []);
5652
- var VerificationCodeExpired = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_EXPIRED", () => [400, "The verification code has expired."], () => []);
5653
- var VerificationCodeAlreadyUsed = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_ALREADY_USED", () => [409, "The verification link has already been used."], () => []);
5654
- 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."], () => []);
5655
- var PasswordConfirmationMismatch = createKnownErrorConstructor(KnownError, "PASSWORD_CONFIRMATION_MISMATCH", () => [400, "Passwords do not match."], () => []);
5656
- var EmailAlreadyVerified = createKnownErrorConstructor(KnownError, "EMAIL_ALREADY_VERIFIED", () => [409, "The e-mail is already verified."], () => []);
5657
- 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."], () => []);
5658
- var EmailIsNotPrimaryEmail = createKnownErrorConstructor(KnownError, "EMAIL_IS_NOT_PRIMARY_EMAIL", (email, primaryEmail) => [
5659
- 400,
5660
- `The given e-mail (${email}) must equal the user's primary e-mail (${primaryEmail}).`,
5661
- {
5662
- email,
5663
- primary_email: primaryEmail
5664
- }
5665
- ], (json) => [json.email, json.primary_email]);
5666
- var PasskeyRegistrationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_REGISTRATION_FAILED", (message) => [400, message], (json) => [json.message]);
5667
- var PasskeyWebAuthnError = createKnownErrorConstructor(KnownError, "PASSKEY_WEBAUTHN_ERROR", (message, code) => [
5668
- 400,
5669
- message,
5670
- {
5671
- message,
5672
- code
5673
- }
5674
- ], (json) => [json.message, json.code]);
5675
- var PasskeyAuthenticationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_FAILED", (message) => [400, message], (json) => [json.message]);
5676
- var PermissionNotFound = createKnownErrorConstructor(KnownError, "PERMISSION_NOT_FOUND", (permissionId) => [
5677
- 404,
5678
- `Permission "${permissionId}" not found. Make sure you created it on the dashboard.`,
5679
- { permission_id: permissionId }
5680
- ], (json) => [json.permission_id]);
5681
- var PermissionScopeMismatch = createKnownErrorConstructor(KnownError, "WRONG_PERMISSION_SCOPE", (permissionId, expectedScope, actualScope) => [
5682
- 404,
5683
- `Permission ${JSON.stringify(permissionId)} not found. (It was found for a different scope ${JSON.stringify(actualScope)}, but scope ${JSON.stringify(expectedScope)} was expected.)`,
5684
- {
5685
- permission_id: permissionId,
5686
- expected_scope: expectedScope,
5687
- actual_scope: actualScope
5688
- }
5689
- ], (json) => [
5690
- json.permission_id,
5691
- json.expected_scope,
5692
- json.actual_scope
5693
- ]);
5694
- var ContainedPermissionNotFound = createKnownErrorConstructor(KnownError, "CONTAINED_PERMISSION_NOT_FOUND", (permissionId) => [
5695
- 400,
5696
- `Contained permission with ID "${permissionId}" not found. Make sure you created it on the dashboard.`,
5697
- { permission_id: permissionId }
5698
- ], (json) => [json.permission_id]);
5699
- var TeamNotFound = createKnownErrorConstructor(KnownError, "TEAM_NOT_FOUND", (teamId) => [
5700
- 404,
5701
- `Team ${teamId} not found.`,
5702
- { team_id: teamId }
5703
- ], (json) => [json.team_id]);
5704
- createKnownErrorConstructor(KnownError, "TEAM_ALREADY_EXISTS", (teamId) => [
5705
- 409,
5706
- `Team ${teamId} already exists.`,
5707
- { team_id: teamId }
5708
- ], (json) => [json.team_id]);
5709
- var TeamMembershipNotFound = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_NOT_FOUND", (teamId, userId) => [
5710
- 404,
5711
- `User ${userId} is not found in team ${teamId}.`,
5712
- {
5713
- team_id: teamId,
5714
- user_id: userId
5715
- }
5716
- ], (json) => [json.team_id, json.user_id]);
5717
- var TeamInvitationRestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "TEAM_INVITATION_RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
5718
- 403,
5719
- `Restricted users cannot accept team invitations. Reason: ${restrictedReason.type}. Please complete the onboarding process before accepting team invitations.`,
5720
- { restricted_reason: restrictedReason }
5721
- ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
5722
- 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."], () => []);
5723
- var EmailTemplateAlreadyExists = createKnownErrorConstructor(KnownError, "EMAIL_TEMPLATE_ALREADY_EXISTS", () => [409, "Email template already exists."], () => []);
5724
- var OAuthConnectionNotConnectedToUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_NOT_CONNECTED_TO_USER", () => [400, "The OAuth connection is not connected to any user."], () => []);
5725
- var OAuthConnectionAlreadyConnectedToAnotherUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_ALREADY_CONNECTED_TO_ANOTHER_USER", () => [409, "The OAuth connection is already connected to another user."], () => []);
5726
- var OAuthConnectionDoesNotHaveRequiredScope = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_DOES_NOT_HAVE_REQUIRED_SCOPE", () => [400, "The OAuth connection does not have the required scope."], () => []);
5727
- var OAuthAccessTokenNotAvailable = createKnownErrorConstructor(KnownError, "OAUTH_ACCESS_TOKEN_NOT_AVAILABLE", (provider, details) => [
5728
- 400,
5729
- `Failed to retrieve an OAuth access token for the connected account (provider: ${provider}). ${details}`,
5730
- {
5731
- provider,
5732
- details
5733
- }
5734
- ], (json) => [json.provider, json.details]);
5735
- 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."], () => []);
5736
- 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."], () => []);
5737
- var InvalidOAuthClientIdOrSecret = createKnownErrorConstructor(KnownError, "INVALID_OAUTH_CLIENT_ID_OR_SECRET", (clientId) => [
5738
- 400,
5739
- "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.",
5740
- { client_id: clientId ?? null }
5741
- ], (json) => [json.client_id ?? void 0]);
5742
- var InvalidScope = createKnownErrorConstructor(KnownError, "INVALID_SCOPE", (scope) => [400, `The scope "${scope}" is not a valid OAuth scope for Stack.`], (json) => [json.scope]);
5743
- 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?"], () => []);
5744
- var OuterOAuthTimeout = createKnownErrorConstructor(KnownError, "OUTER_OAUTH_TIMEOUT", () => [408, "The OAuth flow has timed out. Please sign in again."], () => []);
5745
- var OAuthProviderNotFoundOrNotEnabled = createKnownErrorConstructor(KnownError, "OAUTH_PROVIDER_NOT_FOUND_OR_NOT_ENABLED", () => [400, "The OAuth provider is not found or not enabled."], () => []);
5746
- 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."], () => []);
5747
- 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.`], () => []);
5748
- var MultiFactorAuthenticationRequired = createKnownErrorConstructor(KnownError, "MULTI_FACTOR_AUTHENTICATION_REQUIRED", (attemptCode) => [
5749
- 400,
5750
- `Multi-factor authentication is required for this user.`,
5751
- { attempt_code: attemptCode }
5752
- ], (json) => [json.attempt_code]);
5753
- var InvalidTotpCode = createKnownErrorConstructor(KnownError, "INVALID_TOTP_CODE", () => [400, "The TOTP code is invalid. Please try again."], () => []);
5754
- var UserAuthenticationRequired = createKnownErrorConstructor(KnownError, "USER_AUTHENTICATION_REQUIRED", () => [401, "User authentication required for this endpoint."], () => []);
5755
- var TeamMembershipAlreadyExists = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_ALREADY_EXISTS", () => [409, "Team membership already exists."], () => []);
5756
- var ProjectPermissionRequired = createKnownErrorConstructor(KnownError, "PROJECT_PERMISSION_REQUIRED", (userId, permissionId) => [
5757
- 401,
5758
- `User ${userId} does not have permission ${permissionId}.`,
5759
- {
5760
- user_id: userId,
5761
- permission_id: permissionId
5762
- }
5763
- ], (json) => [json.user_id, json.permission_id]);
5764
- var TeamPermissionRequired = createKnownErrorConstructor(KnownError, "TEAM_PERMISSION_REQUIRED", (teamId, userId, permissionId) => [
5765
- 401,
5766
- `User ${userId} does not have permission ${permissionId} in team ${teamId}.`,
5767
- {
5768
- team_id: teamId,
5769
- user_id: userId,
5770
- permission_id: permissionId
4885
+ ], (json) => [json.user_id, json.permission_id]);
4886
+ var TeamPermissionRequired = createKnownErrorConstructor(KnownError, "TEAM_PERMISSION_REQUIRED", (teamId, userId, permissionId) => [
4887
+ 401,
4888
+ `User ${userId} does not have permission ${permissionId} in team ${teamId}.`,
4889
+ {
4890
+ team_id: teamId,
4891
+ user_id: userId,
4892
+ permission_id: permissionId
5771
4893
  }
5772
4894
  ], (json) => [
5773
4895
  json.team_id,
@@ -6127,49 +5249,6 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6127
5249
  knownErrorCodes.add(KnownError2.errorCode);
6128
5250
  }
6129
5251
 
6130
- // ../shared/dist/esm/utils/bytes.js
6131
- function decodeBase64(input) {
6132
- return new Uint8Array(atob(input).split("").map((char) => char.charCodeAt(0)));
6133
- }
6134
- function isBase64(input) {
6135
- return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(input);
6136
- }
6137
-
6138
- // ../shared/dist/esm/utils/urls.js
6139
- function createUrlIfValid(...args) {
6140
- try {
6141
- return new URL(...args);
6142
- } catch (e40) {
6143
- return null;
6144
- }
6145
- }
6146
- function isValidUrl(url) {
6147
- return !!createUrlIfValid(url);
6148
- }
6149
- function isValidHostname(hostname) {
6150
- if (!hostname || hostname.startsWith(".") || hostname.endsWith(".") || hostname.includes("..")) return false;
6151
- const url = createUrlIfValid(`https://${hostname}`);
6152
- if (!url) return false;
6153
- return url.hostname === hostname;
6154
- }
6155
- function isValidHostnameWithWildcards(hostname) {
6156
- if (!hostname) return false;
6157
- if (!hostname.includes("*")) return isValidHostname(hostname);
6158
- if (hostname.startsWith(".") || hostname.endsWith(".")) return false;
6159
- if (hostname.includes("..")) return false;
6160
- const testHostname = hostname.replace(/\*+/g, "wildcard");
6161
- if (!/^[a-zA-Z0-9.-]+$/.test(testHostname)) return false;
6162
- const segments = hostname.split(/\*+/);
6163
- for (let i = 0; i < segments.length; i++) {
6164
- const segment = segments[i];
6165
- if (segment === "") continue;
6166
- if (i === 0 && segment.startsWith(".")) return false;
6167
- if (i === segments.length - 1 && segment.endsWith(".")) return false;
6168
- if (segment.includes("..")) return false;
6169
- }
6170
- return true;
6171
- }
6172
-
6173
5252
  // ../../node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.esm.js
6174
5253
  var import_property_expr = __toESM(require_property_expr());
6175
5254
  var import_tiny_case = __toESM(require_tiny_case());
@@ -6209,11 +5288,11 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6209
5288
  function toArray(value) {
6210
5289
  return value == null ? [] : [].concat(value);
6211
5290
  }
6212
- var _Symbol$toStringTag4;
5291
+ var _Symbol$toStringTag;
6213
5292
  var _Symbol$hasInstance;
6214
- var _Symbol$toStringTag22;
5293
+ var _Symbol$toStringTag2;
6215
5294
  var strReg = /\$\{\s*(\w+)\s*\}/g;
6216
- _Symbol$toStringTag4 = Symbol.toStringTag;
5295
+ _Symbol$toStringTag = Symbol.toStringTag;
6217
5296
  var ValidationErrorNoStack = class {
6218
5297
  constructor(errorOrErrors, value, field, type) {
6219
5298
  this.name = void 0;
@@ -6224,7 +5303,7 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6224
5303
  this.params = void 0;
6225
5304
  this.errors = void 0;
6226
5305
  this.inner = void 0;
6227
- this[_Symbol$toStringTag4] = "Error";
5306
+ this[_Symbol$toStringTag] = "Error";
6228
5307
  this.name = "ValidationError";
6229
5308
  this.value = value;
6230
5309
  this.path = field;
@@ -6244,7 +5323,7 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6244
5323
  }
6245
5324
  };
6246
5325
  _Symbol$hasInstance = Symbol.hasInstance;
6247
- _Symbol$toStringTag22 = Symbol.toStringTag;
5326
+ _Symbol$toStringTag2 = Symbol.toStringTag;
6248
5327
  var ValidationError = class _ValidationError extends Error {
6249
5328
  static formatError(message, params) {
6250
5329
  const path = params.label || params.path || "this";
@@ -6271,7 +5350,7 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6271
5350
  this.params = void 0;
6272
5351
  this.errors = [];
6273
5352
  this.inner = [];
6274
- this[_Symbol$toStringTag22] = "Error";
5353
+ this[_Symbol$toStringTag2] = "Error";
6275
5354
  this.name = errorNoStack.name;
6276
5355
  this.message = errorNoStack.message;
6277
5356
  this.type = errorNoStack.type;
@@ -9438,283 +8517,1204 @@ attempted value: ${formattedValue}
9438
8517
  workflow_path: yupString().optional()
9439
8518
  }), yupObject({ type: yupString().oneOf(["pushed-from-unknown"]).defined() }), yupObject({ type: yupString().oneOf(["unlinked"]).defined() }));
9440
8519
 
9441
- // ../../node_modules/.pnpm/async-mutex@0.5.0/node_modules/async-mutex/index.mjs
9442
- var E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
9443
- var E_ALREADY_LOCKED = new Error("mutex already locked");
9444
- var E_CANCELED = new Error("request for lock canceled");
9445
- var __awaiter$2 = function(thisArg, _arguments, P, generator) {
9446
- function adopt(value) {
9447
- return value instanceof P ? value : new P(function(resolve) {
9448
- resolve(value);
9449
- });
9450
- }
9451
- return new (P || (P = Promise))(function(resolve, reject) {
9452
- function fulfilled(value) {
9453
- try {
9454
- step(generator.next(value));
9455
- } catch (e40) {
9456
- reject(e40);
9457
- }
9458
- }
9459
- function rejected2(value) {
9460
- try {
9461
- step(generator["throw"](value));
9462
- } catch (e40) {
9463
- reject(e40);
8520
+ // ../../node_modules/.pnpm/async-mutex@0.5.0/node_modules/async-mutex/index.mjs
8521
+ var E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
8522
+ var E_ALREADY_LOCKED = new Error("mutex already locked");
8523
+ var E_CANCELED = new Error("request for lock canceled");
8524
+ var __awaiter$2 = function(thisArg, _arguments, P, generator) {
8525
+ function adopt(value) {
8526
+ return value instanceof P ? value : new P(function(resolve) {
8527
+ resolve(value);
8528
+ });
8529
+ }
8530
+ return new (P || (P = Promise))(function(resolve, reject) {
8531
+ function fulfilled(value) {
8532
+ try {
8533
+ step(generator.next(value));
8534
+ } catch (e40) {
8535
+ reject(e40);
8536
+ }
8537
+ }
8538
+ function rejected2(value) {
8539
+ try {
8540
+ step(generator["throw"](value));
8541
+ } catch (e40) {
8542
+ reject(e40);
8543
+ }
8544
+ }
8545
+ function step(result) {
8546
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected2);
8547
+ }
8548
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8549
+ });
8550
+ };
8551
+ var Semaphore = class {
8552
+ constructor(_value, _cancelError = E_CANCELED) {
8553
+ this._value = _value;
8554
+ this._cancelError = _cancelError;
8555
+ this._queue = [];
8556
+ this._weightedWaiters = [];
8557
+ }
8558
+ acquire(weight = 1, priority = 0) {
8559
+ if (weight <= 0)
8560
+ throw new Error(`invalid weight ${weight}: must be positive`);
8561
+ return new Promise((resolve, reject) => {
8562
+ const task = { resolve, reject, weight, priority };
8563
+ const i = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
8564
+ if (i === -1 && weight <= this._value) {
8565
+ this._dispatchItem(task);
8566
+ } else {
8567
+ this._queue.splice(i + 1, 0, task);
8568
+ }
8569
+ });
8570
+ }
8571
+ runExclusive(callback_1) {
8572
+ return __awaiter$2(this, arguments, void 0, function* (callback, weight = 1, priority = 0) {
8573
+ const [value, release] = yield this.acquire(weight, priority);
8574
+ try {
8575
+ return yield callback(value);
8576
+ } finally {
8577
+ release();
8578
+ }
8579
+ });
8580
+ }
8581
+ waitForUnlock(weight = 1, priority = 0) {
8582
+ if (weight <= 0)
8583
+ throw new Error(`invalid weight ${weight}: must be positive`);
8584
+ if (this._couldLockImmediately(weight, priority)) {
8585
+ return Promise.resolve();
8586
+ } else {
8587
+ return new Promise((resolve) => {
8588
+ if (!this._weightedWaiters[weight - 1])
8589
+ this._weightedWaiters[weight - 1] = [];
8590
+ insertSorted(this._weightedWaiters[weight - 1], { resolve, priority });
8591
+ });
8592
+ }
8593
+ }
8594
+ isLocked() {
8595
+ return this._value <= 0;
8596
+ }
8597
+ getValue() {
8598
+ return this._value;
8599
+ }
8600
+ setValue(value) {
8601
+ this._value = value;
8602
+ this._dispatchQueue();
8603
+ }
8604
+ release(weight = 1) {
8605
+ if (weight <= 0)
8606
+ throw new Error(`invalid weight ${weight}: must be positive`);
8607
+ this._value += weight;
8608
+ this._dispatchQueue();
8609
+ }
8610
+ cancel() {
8611
+ this._queue.forEach((entry) => entry.reject(this._cancelError));
8612
+ this._queue = [];
8613
+ }
8614
+ _dispatchQueue() {
8615
+ this._drainUnlockWaiters();
8616
+ while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
8617
+ this._dispatchItem(this._queue.shift());
8618
+ this._drainUnlockWaiters();
8619
+ }
8620
+ }
8621
+ _dispatchItem(item) {
8622
+ const previousValue = this._value;
8623
+ this._value -= item.weight;
8624
+ item.resolve([previousValue, this._newReleaser(item.weight)]);
8625
+ }
8626
+ _newReleaser(weight) {
8627
+ let called = false;
8628
+ return () => {
8629
+ if (called)
8630
+ return;
8631
+ called = true;
8632
+ this.release(weight);
8633
+ };
8634
+ }
8635
+ _drainUnlockWaiters() {
8636
+ if (this._queue.length === 0) {
8637
+ for (let weight = this._value; weight > 0; weight--) {
8638
+ const waiters = this._weightedWaiters[weight - 1];
8639
+ if (!waiters)
8640
+ continue;
8641
+ waiters.forEach((waiter) => waiter.resolve());
8642
+ this._weightedWaiters[weight - 1] = [];
8643
+ }
8644
+ } else {
8645
+ const queuedPriority = this._queue[0].priority;
8646
+ for (let weight = this._value; weight > 0; weight--) {
8647
+ const waiters = this._weightedWaiters[weight - 1];
8648
+ if (!waiters)
8649
+ continue;
8650
+ const i = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
8651
+ (i === -1 ? waiters : waiters.splice(0, i)).forEach((waiter) => waiter.resolve());
8652
+ }
8653
+ }
8654
+ }
8655
+ _couldLockImmediately(weight, priority) {
8656
+ return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
8657
+ }
8658
+ };
8659
+ function insertSorted(a26, v) {
8660
+ const i = findIndexFromEnd(a26, (other) => v.priority <= other.priority);
8661
+ a26.splice(i + 1, 0, v);
8662
+ }
8663
+ function findIndexFromEnd(a26, predicate) {
8664
+ for (let i = a26.length - 1; i >= 0; i--) {
8665
+ if (predicate(a26[i])) {
8666
+ return i;
8667
+ }
8668
+ }
8669
+ return -1;
8670
+ }
8671
+
8672
+ // ../shared/dist/esm/utils/locks.js
8673
+ var ReadWriteLock = class {
8674
+ constructor() {
8675
+ this.semaphore = new Semaphore(1);
8676
+ this.readers = 0;
8677
+ this.readersMutex = new Semaphore(1);
8678
+ }
8679
+ async withReadLock(callback) {
8680
+ await this._acquireReadLock();
8681
+ try {
8682
+ return await callback();
8683
+ } finally {
8684
+ await this._releaseReadLock();
8685
+ }
8686
+ }
8687
+ async withWriteLock(callback) {
8688
+ await this._acquireWriteLock();
8689
+ try {
8690
+ return await callback();
8691
+ } finally {
8692
+ await this._releaseWriteLock();
8693
+ }
8694
+ }
8695
+ async _acquireReadLock() {
8696
+ await this.readersMutex.acquire();
8697
+ try {
8698
+ this.readers += 1;
8699
+ if (this.readers === 1) await this.semaphore.acquire();
8700
+ } finally {
8701
+ this.readersMutex.release();
8702
+ }
8703
+ }
8704
+ async _releaseReadLock() {
8705
+ await this.readersMutex.acquire();
8706
+ try {
8707
+ this.readers -= 1;
8708
+ if (this.readers === 0) this.semaphore.release();
8709
+ } finally {
8710
+ this.readersMutex.release();
8711
+ }
8712
+ }
8713
+ async _acquireWriteLock() {
8714
+ await this.semaphore.acquire();
8715
+ }
8716
+ async _releaseWriteLock() {
8717
+ this.semaphore.release();
8718
+ }
8719
+ };
8720
+
8721
+ // ../shared/dist/esm/utils/stores.js
8722
+ var storeLock = new ReadWriteLock();
8723
+
8724
+ // ../shared/dist/esm/interface/client-interface.js
8725
+ var USER_AGENT;
8726
+ if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) USER_AGENT = `oauth4webapi/v3.8.5`;
8727
+ var ERR_INVALID_ARG_VALUE = "ERR_INVALID_ARG_VALUE";
8728
+ function CodedTypeError(message, code, cause) {
8729
+ const err = new TypeError(message, { cause });
8730
+ Object.assign(err, { code });
8731
+ return err;
8732
+ }
8733
+ var allowInsecureRequests = Symbol();
8734
+ var clockSkew = Symbol();
8735
+ var clockTolerance = Symbol();
8736
+ var customFetch = Symbol();
8737
+ var jweDecrypt = Symbol();
8738
+ var encoder = new TextEncoder();
8739
+ var decoder = new TextDecoder();
8740
+ var encodeBase64Url;
8741
+ if (Uint8Array.prototype.toBase64) encodeBase64Url = (input) => {
8742
+ if (input instanceof ArrayBuffer) input = new Uint8Array(input);
8743
+ return input.toBase64({
8744
+ alphabet: "base64url",
8745
+ omitPadding: true
8746
+ });
8747
+ };
8748
+ else {
8749
+ const CHUNK_SIZE = 32768;
8750
+ encodeBase64Url = (input) => {
8751
+ if (input instanceof ArrayBuffer) input = new Uint8Array(input);
8752
+ const arr = [];
8753
+ for (let i = 0; i < input.byteLength; i += CHUNK_SIZE) arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
8754
+ return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
8755
+ };
8756
+ }
8757
+ var decodeBase64Url;
8758
+ if (Uint8Array.fromBase64) decodeBase64Url = (input) => {
8759
+ try {
8760
+ return Uint8Array.fromBase64(input, { alphabet: "base64url" });
8761
+ } catch (cause) {
8762
+ throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
8763
+ }
8764
+ };
8765
+ else decodeBase64Url = (input) => {
8766
+ try {
8767
+ const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
8768
+ const bytes = new Uint8Array(binary.length);
8769
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
8770
+ return bytes;
8771
+ } catch (cause) {
8772
+ throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
8773
+ }
8774
+ };
8775
+ var URLParse = URL.parse ? (url, base) => URL.parse(url, base) : (url, base) => {
8776
+ try {
8777
+ return new URL(url, base);
8778
+ } catch {
8779
+ return null;
8780
+ }
8781
+ };
8782
+ var tokenMatch = "[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+";
8783
+ var token68Match = "[a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2}";
8784
+ var quotedParamMatcher = "(" + tokenMatch + ')\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"';
8785
+ var paramMatcher = "(" + tokenMatch + ")\\s*=\\s*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)";
8786
+ var schemeRE = new RegExp("^[,\\s]*(" + tokenMatch + ")");
8787
+ var quotedParamRE = new RegExp("^[,\\s]*" + quotedParamMatcher + "[,\\s]*(.*)");
8788
+ var unquotedParamRE = new RegExp("^[,\\s]*" + paramMatcher + "[,\\s]*(.*)");
8789
+ var token68ParamRE = new RegExp("^(" + token68Match + ")(?:$|[,\\s])(.*)");
8790
+ var nopkce = Symbol();
8791
+ var expectNoNonce = Symbol();
8792
+ var skipAuthTimeCheck = Symbol();
8793
+ var skipStateCheck = Symbol();
8794
+ var expectNoState = Symbol();
8795
+ var _expectedIssuer = Symbol();
8796
+ var botChallengeKnownErrors = [KnownErrors.BotChallengeRequired, KnownErrors.BotChallengeFailed];
8797
+
8798
+ // ../shared/dist/esm/utils/maps.js
8799
+ var _Symbol$toStringTag3;
8800
+ var _Symbol$toStringTag22;
8801
+ var _Symbol$toStringTag32;
8802
+ var WeakRefIfAvailable = class {
8803
+ constructor(value) {
8804
+ if (typeof WeakRef === "undefined") this._ref = { deref: () => value };
8805
+ else this._ref = new WeakRef(value);
8806
+ }
8807
+ deref() {
8808
+ return this._ref.deref();
8809
+ }
8810
+ };
8811
+ var _a2;
8812
+ var IterableWeakMap = (_a2 = class {
8813
+ constructor(entries) {
8814
+ this[_Symbol$toStringTag3] = "IterableWeakMap";
8815
+ const mappedEntries = entries?.map((e40) => [e40[0], {
8816
+ value: e40[1],
8817
+ keyRef: new WeakRefIfAvailable(e40[0])
8818
+ }]);
8819
+ this._weakMap = new WeakMap(mappedEntries ?? []);
8820
+ this._keyRefs = new Set(mappedEntries?.map((e40) => e40[1].keyRef) ?? []);
8821
+ }
8822
+ get(key) {
8823
+ return this._weakMap.get(key)?.value;
8824
+ }
8825
+ set(key, value) {
8826
+ const updated = {
8827
+ value,
8828
+ keyRef: this._weakMap.get(key)?.keyRef ?? new WeakRefIfAvailable(key)
8829
+ };
8830
+ this._weakMap.set(key, updated);
8831
+ this._keyRefs.add(updated.keyRef);
8832
+ return this;
8833
+ }
8834
+ delete(key) {
8835
+ const res = this._weakMap.get(key);
8836
+ if (res) {
8837
+ this._weakMap.delete(key);
8838
+ this._keyRefs.delete(res.keyRef);
8839
+ return true;
8840
+ }
8841
+ return false;
8842
+ }
8843
+ has(key) {
8844
+ return this._weakMap.has(key) && this._keyRefs.has(this._weakMap.get(key).keyRef);
8845
+ }
8846
+ *[Symbol.iterator]() {
8847
+ for (const keyRef of this._keyRefs) {
8848
+ const key = keyRef.deref();
8849
+ const existing = key ? this._weakMap.get(key) : void 0;
8850
+ if (!key) this._keyRefs.delete(keyRef);
8851
+ else if (existing) yield [key, existing.value];
8852
+ }
8853
+ }
8854
+ }, _Symbol$toStringTag3 = Symbol.toStringTag, _a2);
8855
+ var _a3;
8856
+ var MaybeWeakMap = (_a3 = class {
8857
+ constructor(entries) {
8858
+ this[_Symbol$toStringTag22] = "MaybeWeakMap";
8859
+ const entriesArray = [...entries ?? []];
8860
+ this._primitiveMap = new Map(entriesArray.filter((e40) => !this._isAllowedInWeakMap(e40[0])));
8861
+ this._weakMap = new IterableWeakMap(entriesArray.filter((e40) => this._isAllowedInWeakMap(e40[0])));
8862
+ }
8863
+ _isAllowedInWeakMap(key) {
8864
+ return typeof key === "object" && key !== null || typeof key === "symbol" && Symbol.keyFor(key) === void 0;
8865
+ }
8866
+ get(key) {
8867
+ if (this._isAllowedInWeakMap(key)) return this._weakMap.get(key);
8868
+ else return this._primitiveMap.get(key);
8869
+ }
8870
+ set(key, value) {
8871
+ if (this._isAllowedInWeakMap(key)) this._weakMap.set(key, value);
8872
+ else this._primitiveMap.set(key, value);
8873
+ return this;
8874
+ }
8875
+ delete(key) {
8876
+ if (this._isAllowedInWeakMap(key)) return this._weakMap.delete(key);
8877
+ else return this._primitiveMap.delete(key);
8878
+ }
8879
+ has(key) {
8880
+ if (this._isAllowedInWeakMap(key)) return this._weakMap.has(key);
8881
+ else return this._primitiveMap.has(key);
8882
+ }
8883
+ *[Symbol.iterator]() {
8884
+ yield* this._primitiveMap;
8885
+ yield* this._weakMap;
8886
+ }
8887
+ }, _Symbol$toStringTag22 = Symbol.toStringTag, _a3);
8888
+ var _a4;
8889
+ var DependenciesMap = (_a4 = class {
8890
+ constructor() {
8891
+ this._inner = {
8892
+ map: new MaybeWeakMap(),
8893
+ hasValue: false,
8894
+ value: void 0
8895
+ };
8896
+ this[_Symbol$toStringTag32] = "DependenciesMap";
8897
+ }
8898
+ _valueToResult(inner) {
8899
+ if (inner.hasValue) return Result.ok(inner.value);
8900
+ else return Result.error(void 0);
8901
+ }
8902
+ _unwrapFromInner(dependencies, inner) {
8903
+ if (dependencies.length === 0) return this._valueToResult(inner);
8904
+ else {
8905
+ const [key, ...rest] = dependencies;
8906
+ const newInner = inner.map.get(key);
8907
+ if (!newInner) return Result.error(void 0);
8908
+ return this._unwrapFromInner(rest, newInner);
8909
+ }
8910
+ }
8911
+ _setInInner(dependencies, value, inner) {
8912
+ if (dependencies.length === 0) {
8913
+ const res = this._valueToResult(inner);
8914
+ if (value.status === "ok") {
8915
+ inner.hasValue = true;
8916
+ inner.value = value.data;
8917
+ } else {
8918
+ inner.hasValue = false;
8919
+ inner.value = void 0;
8920
+ }
8921
+ return res;
8922
+ } else {
8923
+ const [key, ...rest] = dependencies;
8924
+ let newInner = inner.map.get(key);
8925
+ if (!newInner) inner.map.set(key, newInner = {
8926
+ map: new MaybeWeakMap(),
8927
+ hasValue: false,
8928
+ value: void 0
8929
+ });
8930
+ return this._setInInner(rest, value, newInner);
8931
+ }
8932
+ }
8933
+ *_iterateInner(dependencies, inner) {
8934
+ if (inner.hasValue) yield [dependencies, inner.value];
8935
+ for (const [key, value] of inner.map) yield* this._iterateInner([...dependencies, key], value);
8936
+ }
8937
+ get(dependencies) {
8938
+ return Result.or(this._unwrapFromInner(dependencies, this._inner), void 0);
8939
+ }
8940
+ set(dependencies, value) {
8941
+ this._setInInner(dependencies, Result.ok(value), this._inner);
8942
+ return this;
8943
+ }
8944
+ delete(dependencies) {
8945
+ return this._setInInner(dependencies, Result.error(void 0), this._inner).status === "ok";
8946
+ }
8947
+ has(dependencies) {
8948
+ return this._unwrapFromInner(dependencies, this._inner).status === "ok";
8949
+ }
8950
+ clear() {
8951
+ this._inner = {
8952
+ map: new MaybeWeakMap(),
8953
+ hasValue: false,
8954
+ value: void 0
8955
+ };
8956
+ }
8957
+ *[Symbol.iterator]() {
8958
+ yield* this._iterateInner([], this._inner);
8959
+ }
8960
+ }, _Symbol$toStringTag32 = Symbol.toStringTag, _a4);
8961
+
8962
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/platform/browser/globalThis.js
8963
+ var _globalThis = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
8964
+
8965
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/version.js
8966
+ var VERSION = "1.9.0";
8967
+
8968
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/semver.js
8969
+ var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
8970
+ function _makeCompatibilityCheck(ownVersion) {
8971
+ var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
8972
+ var rejectedVersions = /* @__PURE__ */ new Set();
8973
+ var myVersionMatch = ownVersion.match(re);
8974
+ if (!myVersionMatch) {
8975
+ return function() {
8976
+ return false;
8977
+ };
8978
+ }
8979
+ var ownVersionParsed = {
8980
+ major: +myVersionMatch[1],
8981
+ minor: +myVersionMatch[2],
8982
+ patch: +myVersionMatch[3],
8983
+ prerelease: myVersionMatch[4]
8984
+ };
8985
+ if (ownVersionParsed.prerelease != null) {
8986
+ return function isExactmatch(globalVersion) {
8987
+ return globalVersion === ownVersion;
8988
+ };
8989
+ }
8990
+ function _reject(v) {
8991
+ rejectedVersions.add(v);
8992
+ return false;
8993
+ }
8994
+ function _accept(v) {
8995
+ acceptedVersions.add(v);
8996
+ return true;
8997
+ }
8998
+ return function isCompatible2(globalVersion) {
8999
+ if (acceptedVersions.has(globalVersion)) {
9000
+ return true;
9001
+ }
9002
+ if (rejectedVersions.has(globalVersion)) {
9003
+ return false;
9004
+ }
9005
+ var globalVersionMatch = globalVersion.match(re);
9006
+ if (!globalVersionMatch) {
9007
+ return _reject(globalVersion);
9008
+ }
9009
+ var globalVersionParsed = {
9010
+ major: +globalVersionMatch[1],
9011
+ minor: +globalVersionMatch[2],
9012
+ patch: +globalVersionMatch[3],
9013
+ prerelease: globalVersionMatch[4]
9014
+ };
9015
+ if (globalVersionParsed.prerelease != null) {
9016
+ return _reject(globalVersion);
9017
+ }
9018
+ if (ownVersionParsed.major !== globalVersionParsed.major) {
9019
+ return _reject(globalVersion);
9020
+ }
9021
+ if (ownVersionParsed.major === 0) {
9022
+ if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
9023
+ return _accept(globalVersion);
9024
+ }
9025
+ return _reject(globalVersion);
9026
+ }
9027
+ if (ownVersionParsed.minor <= globalVersionParsed.minor) {
9028
+ return _accept(globalVersion);
9029
+ }
9030
+ return _reject(globalVersion);
9031
+ };
9032
+ }
9033
+ var isCompatible = _makeCompatibilityCheck(VERSION);
9034
+
9035
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
9036
+ var major = VERSION.split(".")[0];
9037
+ var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
9038
+ var _global = _globalThis;
9039
+ function registerGlobal(type, instance, diag, allowOverride) {
9040
+ var _a5;
9041
+ if (allowOverride === void 0) {
9042
+ allowOverride = false;
9043
+ }
9044
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a5 !== void 0 ? _a5 : {
9045
+ version: VERSION
9046
+ };
9047
+ if (!allowOverride && api[type]) {
9048
+ var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
9049
+ diag.error(err.stack || err.message);
9050
+ return false;
9051
+ }
9052
+ if (api.version !== VERSION) {
9053
+ var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
9054
+ diag.error(err.stack || err.message);
9055
+ return false;
9056
+ }
9057
+ api[type] = instance;
9058
+ diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
9059
+ return true;
9060
+ }
9061
+ function getGlobal(type) {
9062
+ var _a5, _b;
9063
+ var globalVersion = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a5 === void 0 ? void 0 : _a5.version;
9064
+ if (!globalVersion || !isCompatible(globalVersion)) {
9065
+ return;
9066
+ }
9067
+ return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
9068
+ }
9069
+ function unregisterGlobal(type, diag) {
9070
+ diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
9071
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
9072
+ if (api) {
9073
+ delete api[type];
9074
+ }
9075
+ }
9076
+
9077
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
9078
+ var __read = function(o21, n9) {
9079
+ var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
9080
+ if (!m5) return o21;
9081
+ var i = m5.call(o21), r7, ar = [], e40;
9082
+ try {
9083
+ while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9084
+ } catch (error) {
9085
+ e40 = { error };
9086
+ } finally {
9087
+ try {
9088
+ if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
9089
+ } finally {
9090
+ if (e40) throw e40.error;
9091
+ }
9092
+ }
9093
+ return ar;
9094
+ };
9095
+ var __spreadArray = function(to, from, pack) {
9096
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9097
+ if (ar || !(i in from)) {
9098
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9099
+ ar[i] = from[i];
9100
+ }
9101
+ }
9102
+ return to.concat(ar || Array.prototype.slice.call(from));
9103
+ };
9104
+ var DiagComponentLogger = (
9105
+ /** @class */
9106
+ function() {
9107
+ function DiagComponentLogger2(props) {
9108
+ this._namespace = props.namespace || "DiagComponentLogger";
9109
+ }
9110
+ DiagComponentLogger2.prototype.debug = function() {
9111
+ var args = [];
9112
+ for (var _i = 0; _i < arguments.length; _i++) {
9113
+ args[_i] = arguments[_i];
9114
+ }
9115
+ return logProxy("debug", this._namespace, args);
9116
+ };
9117
+ DiagComponentLogger2.prototype.error = function() {
9118
+ var args = [];
9119
+ for (var _i = 0; _i < arguments.length; _i++) {
9120
+ args[_i] = arguments[_i];
9121
+ }
9122
+ return logProxy("error", this._namespace, args);
9123
+ };
9124
+ DiagComponentLogger2.prototype.info = function() {
9125
+ var args = [];
9126
+ for (var _i = 0; _i < arguments.length; _i++) {
9127
+ args[_i] = arguments[_i];
9128
+ }
9129
+ return logProxy("info", this._namespace, args);
9130
+ };
9131
+ DiagComponentLogger2.prototype.warn = function() {
9132
+ var args = [];
9133
+ for (var _i = 0; _i < arguments.length; _i++) {
9134
+ args[_i] = arguments[_i];
9135
+ }
9136
+ return logProxy("warn", this._namespace, args);
9137
+ };
9138
+ DiagComponentLogger2.prototype.verbose = function() {
9139
+ var args = [];
9140
+ for (var _i = 0; _i < arguments.length; _i++) {
9141
+ args[_i] = arguments[_i];
9142
+ }
9143
+ return logProxy("verbose", this._namespace, args);
9144
+ };
9145
+ return DiagComponentLogger2;
9146
+ }()
9147
+ );
9148
+ function logProxy(funcName, namespace, args) {
9149
+ var logger = getGlobal("diag");
9150
+ if (!logger) {
9151
+ return;
9152
+ }
9153
+ args.unshift(namespace);
9154
+ return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
9155
+ }
9156
+
9157
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/types.js
9158
+ var DiagLogLevel;
9159
+ (function(DiagLogLevel2) {
9160
+ DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
9161
+ DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
9162
+ DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
9163
+ DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
9164
+ DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
9165
+ DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
9166
+ DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
9167
+ })(DiagLogLevel || (DiagLogLevel = {}));
9168
+
9169
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
9170
+ function createLogLevelDiagLogger(maxLevel, logger) {
9171
+ if (maxLevel < DiagLogLevel.NONE) {
9172
+ maxLevel = DiagLogLevel.NONE;
9173
+ } else if (maxLevel > DiagLogLevel.ALL) {
9174
+ maxLevel = DiagLogLevel.ALL;
9175
+ }
9176
+ logger = logger || {};
9177
+ function _filterFunc(funcName, theLevel) {
9178
+ var theFunc = logger[funcName];
9179
+ if (typeof theFunc === "function" && maxLevel >= theLevel) {
9180
+ return theFunc.bind(logger);
9181
+ }
9182
+ return function() {
9183
+ };
9184
+ }
9185
+ return {
9186
+ error: _filterFunc("error", DiagLogLevel.ERROR),
9187
+ warn: _filterFunc("warn", DiagLogLevel.WARN),
9188
+ info: _filterFunc("info", DiagLogLevel.INFO),
9189
+ debug: _filterFunc("debug", DiagLogLevel.DEBUG),
9190
+ verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
9191
+ };
9192
+ }
9193
+
9194
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/diag.js
9195
+ var __read2 = function(o21, n9) {
9196
+ var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
9197
+ if (!m5) return o21;
9198
+ var i = m5.call(o21), r7, ar = [], e40;
9199
+ try {
9200
+ while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9201
+ } catch (error) {
9202
+ e40 = { error };
9203
+ } finally {
9204
+ try {
9205
+ if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
9206
+ } finally {
9207
+ if (e40) throw e40.error;
9208
+ }
9209
+ }
9210
+ return ar;
9211
+ };
9212
+ var __spreadArray2 = function(to, from, pack) {
9213
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9214
+ if (ar || !(i in from)) {
9215
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9216
+ ar[i] = from[i];
9217
+ }
9218
+ }
9219
+ return to.concat(ar || Array.prototype.slice.call(from));
9220
+ };
9221
+ var API_NAME = "diag";
9222
+ var DiagAPI = (
9223
+ /** @class */
9224
+ function() {
9225
+ function DiagAPI2() {
9226
+ function _logProxy(funcName) {
9227
+ return function() {
9228
+ var args = [];
9229
+ for (var _i = 0; _i < arguments.length; _i++) {
9230
+ args[_i] = arguments[_i];
9231
+ }
9232
+ var logger = getGlobal("diag");
9233
+ if (!logger)
9234
+ return;
9235
+ return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
9236
+ };
9237
+ }
9238
+ var self2 = this;
9239
+ var setLogger = function(logger, optionsOrLogLevel) {
9240
+ var _a5, _b, _c;
9241
+ if (optionsOrLogLevel === void 0) {
9242
+ optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
9243
+ }
9244
+ if (logger === self2) {
9245
+ var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
9246
+ self2.error((_a5 = err.stack) !== null && _a5 !== void 0 ? _a5 : err.message);
9247
+ return false;
9248
+ }
9249
+ if (typeof optionsOrLogLevel === "number") {
9250
+ optionsOrLogLevel = {
9251
+ logLevel: optionsOrLogLevel
9252
+ };
9253
+ }
9254
+ var oldLogger = getGlobal("diag");
9255
+ var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
9256
+ if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
9257
+ var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
9258
+ oldLogger.warn("Current logger will be overwritten from " + stack);
9259
+ newLogger.warn("Current logger will overwrite one already registered from " + stack);
9260
+ }
9261
+ return registerGlobal("diag", newLogger, self2, true);
9262
+ };
9263
+ self2.setLogger = setLogger;
9264
+ self2.disable = function() {
9265
+ unregisterGlobal(API_NAME, self2);
9266
+ };
9267
+ self2.createComponentLogger = function(options) {
9268
+ return new DiagComponentLogger(options);
9269
+ };
9270
+ self2.verbose = _logProxy("verbose");
9271
+ self2.debug = _logProxy("debug");
9272
+ self2.info = _logProxy("info");
9273
+ self2.warn = _logProxy("warn");
9274
+ self2.error = _logProxy("error");
9275
+ }
9276
+ DiagAPI2.instance = function() {
9277
+ if (!this._instance) {
9278
+ this._instance = new DiagAPI2();
9279
+ }
9280
+ return this._instance;
9281
+ };
9282
+ return DiagAPI2;
9283
+ }()
9284
+ );
9285
+
9286
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/context.js
9287
+ function createContextKey(description) {
9288
+ return Symbol.for(description);
9289
+ }
9290
+ var BaseContext = (
9291
+ /** @class */
9292
+ /* @__PURE__ */ function() {
9293
+ function BaseContext2(parentContext) {
9294
+ var self2 = this;
9295
+ self2._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
9296
+ self2.getValue = function(key) {
9297
+ return self2._currentContext.get(key);
9298
+ };
9299
+ self2.setValue = function(key, value) {
9300
+ var context = new BaseContext2(self2._currentContext);
9301
+ context._currentContext.set(key, value);
9302
+ return context;
9303
+ };
9304
+ self2.deleteValue = function(key) {
9305
+ var context = new BaseContext2(self2._currentContext);
9306
+ context._currentContext.delete(key);
9307
+ return context;
9308
+ };
9309
+ }
9310
+ return BaseContext2;
9311
+ }()
9312
+ );
9313
+ var ROOT_CONTEXT = new BaseContext();
9314
+
9315
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js
9316
+ var __read3 = function(o21, n9) {
9317
+ var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
9318
+ if (!m5) return o21;
9319
+ var i = m5.call(o21), r7, ar = [], e40;
9320
+ try {
9321
+ while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9322
+ } catch (error) {
9323
+ e40 = { error };
9324
+ } finally {
9325
+ try {
9326
+ if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
9327
+ } finally {
9328
+ if (e40) throw e40.error;
9329
+ }
9330
+ }
9331
+ return ar;
9332
+ };
9333
+ var __spreadArray3 = function(to, from, pack) {
9334
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9335
+ if (ar || !(i in from)) {
9336
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9337
+ ar[i] = from[i];
9338
+ }
9339
+ }
9340
+ return to.concat(ar || Array.prototype.slice.call(from));
9341
+ };
9342
+ var NoopContextManager = (
9343
+ /** @class */
9344
+ function() {
9345
+ function NoopContextManager2() {
9346
+ }
9347
+ NoopContextManager2.prototype.active = function() {
9348
+ return ROOT_CONTEXT;
9349
+ };
9350
+ NoopContextManager2.prototype.with = function(_context, fn, thisArg) {
9351
+ var args = [];
9352
+ for (var _i = 3; _i < arguments.length; _i++) {
9353
+ args[_i - 3] = arguments[_i];
9354
+ }
9355
+ return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
9356
+ };
9357
+ NoopContextManager2.prototype.bind = function(_context, target) {
9358
+ return target;
9359
+ };
9360
+ NoopContextManager2.prototype.enable = function() {
9361
+ return this;
9362
+ };
9363
+ NoopContextManager2.prototype.disable = function() {
9364
+ return this;
9365
+ };
9366
+ return NoopContextManager2;
9367
+ }()
9368
+ );
9369
+
9370
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/context.js
9371
+ var __read4 = function(o21, n9) {
9372
+ var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
9373
+ if (!m5) return o21;
9374
+ var i = m5.call(o21), r7, ar = [], e40;
9375
+ try {
9376
+ while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9377
+ } catch (error) {
9378
+ e40 = { error };
9379
+ } finally {
9380
+ try {
9381
+ if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
9382
+ } finally {
9383
+ if (e40) throw e40.error;
9384
+ }
9385
+ }
9386
+ return ar;
9387
+ };
9388
+ var __spreadArray4 = function(to, from, pack) {
9389
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9390
+ if (ar || !(i in from)) {
9391
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9392
+ ar[i] = from[i];
9393
+ }
9394
+ }
9395
+ return to.concat(ar || Array.prototype.slice.call(from));
9396
+ };
9397
+ var API_NAME2 = "context";
9398
+ var NOOP_CONTEXT_MANAGER = new NoopContextManager();
9399
+ var ContextAPI = (
9400
+ /** @class */
9401
+ function() {
9402
+ function ContextAPI2() {
9403
+ }
9404
+ ContextAPI2.getInstance = function() {
9405
+ if (!this._instance) {
9406
+ this._instance = new ContextAPI2();
9407
+ }
9408
+ return this._instance;
9409
+ };
9410
+ ContextAPI2.prototype.setGlobalContextManager = function(contextManager) {
9411
+ return registerGlobal(API_NAME2, contextManager, DiagAPI.instance());
9412
+ };
9413
+ ContextAPI2.prototype.active = function() {
9414
+ return this._getContextManager().active();
9415
+ };
9416
+ ContextAPI2.prototype.with = function(context, fn, thisArg) {
9417
+ var _a5;
9418
+ var args = [];
9419
+ for (var _i = 3; _i < arguments.length; _i++) {
9420
+ args[_i - 3] = arguments[_i];
9421
+ }
9422
+ return (_a5 = this._getContextManager()).with.apply(_a5, __spreadArray4([context, fn, thisArg], __read4(args), false));
9423
+ };
9424
+ ContextAPI2.prototype.bind = function(context, target) {
9425
+ return this._getContextManager().bind(context, target);
9426
+ };
9427
+ ContextAPI2.prototype._getContextManager = function() {
9428
+ return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
9429
+ };
9430
+ ContextAPI2.prototype.disable = function() {
9431
+ this._getContextManager().disable();
9432
+ unregisterGlobal(API_NAME2, DiagAPI.instance());
9433
+ };
9434
+ return ContextAPI2;
9435
+ }()
9436
+ );
9437
+
9438
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js
9439
+ var TraceFlags;
9440
+ (function(TraceFlags2) {
9441
+ TraceFlags2[TraceFlags2["NONE"] = 0] = "NONE";
9442
+ TraceFlags2[TraceFlags2["SAMPLED"] = 1] = "SAMPLED";
9443
+ })(TraceFlags || (TraceFlags = {}));
9444
+
9445
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js
9446
+ var INVALID_SPANID = "0000000000000000";
9447
+ var INVALID_TRACEID = "00000000000000000000000000000000";
9448
+ var INVALID_SPAN_CONTEXT = {
9449
+ traceId: INVALID_TRACEID,
9450
+ spanId: INVALID_SPANID,
9451
+ traceFlags: TraceFlags.NONE
9452
+ };
9453
+
9454
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js
9455
+ var NonRecordingSpan = (
9456
+ /** @class */
9457
+ function() {
9458
+ function NonRecordingSpan2(_spanContext) {
9459
+ if (_spanContext === void 0) {
9460
+ _spanContext = INVALID_SPAN_CONTEXT;
9464
9461
  }
9462
+ this._spanContext = _spanContext;
9465
9463
  }
9466
- function step(result) {
9467
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected2);
9464
+ NonRecordingSpan2.prototype.spanContext = function() {
9465
+ return this._spanContext;
9466
+ };
9467
+ NonRecordingSpan2.prototype.setAttribute = function(_key, _value) {
9468
+ return this;
9469
+ };
9470
+ NonRecordingSpan2.prototype.setAttributes = function(_attributes) {
9471
+ return this;
9472
+ };
9473
+ NonRecordingSpan2.prototype.addEvent = function(_name, _attributes) {
9474
+ return this;
9475
+ };
9476
+ NonRecordingSpan2.prototype.addLink = function(_link) {
9477
+ return this;
9478
+ };
9479
+ NonRecordingSpan2.prototype.addLinks = function(_links) {
9480
+ return this;
9481
+ };
9482
+ NonRecordingSpan2.prototype.setStatus = function(_status) {
9483
+ return this;
9484
+ };
9485
+ NonRecordingSpan2.prototype.updateName = function(_name) {
9486
+ return this;
9487
+ };
9488
+ NonRecordingSpan2.prototype.end = function(_endTime) {
9489
+ };
9490
+ NonRecordingSpan2.prototype.isRecording = function() {
9491
+ return false;
9492
+ };
9493
+ NonRecordingSpan2.prototype.recordException = function(_exception, _time) {
9494
+ };
9495
+ return NonRecordingSpan2;
9496
+ }()
9497
+ );
9498
+
9499
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js
9500
+ var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
9501
+ function getSpan(context) {
9502
+ return context.getValue(SPAN_KEY) || void 0;
9503
+ }
9504
+ function getActiveSpan() {
9505
+ return getSpan(ContextAPI.getInstance().active());
9506
+ }
9507
+ function setSpan(context, span) {
9508
+ return context.setValue(SPAN_KEY, span);
9509
+ }
9510
+ function deleteSpan(context) {
9511
+ return context.deleteValue(SPAN_KEY);
9512
+ }
9513
+ function setSpanContext(context, spanContext) {
9514
+ return setSpan(context, new NonRecordingSpan(spanContext));
9515
+ }
9516
+ function getSpanContext(context) {
9517
+ var _a5;
9518
+ return (_a5 = getSpan(context)) === null || _a5 === void 0 ? void 0 : _a5.spanContext();
9519
+ }
9520
+
9521
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
9522
+ var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
9523
+ var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
9524
+ function isValidTraceId(traceId) {
9525
+ return VALID_TRACEID_REGEX.test(traceId) && traceId !== INVALID_TRACEID;
9526
+ }
9527
+ function isValidSpanId(spanId) {
9528
+ return VALID_SPANID_REGEX.test(spanId) && spanId !== INVALID_SPANID;
9529
+ }
9530
+ function isSpanContextValid(spanContext) {
9531
+ return isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);
9532
+ }
9533
+ function wrapSpanContext(spanContext) {
9534
+ return new NonRecordingSpan(spanContext);
9535
+ }
9536
+
9537
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js
9538
+ var contextApi = ContextAPI.getInstance();
9539
+ var NoopTracer = (
9540
+ /** @class */
9541
+ function() {
9542
+ function NoopTracer2() {
9468
9543
  }
9469
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9470
- });
9471
- };
9472
- var Semaphore = class {
9473
- constructor(_value, _cancelError = E_CANCELED) {
9474
- this._value = _value;
9475
- this._cancelError = _cancelError;
9476
- this._queue = [];
9477
- this._weightedWaiters = [];
9478
- }
9479
- acquire(weight = 1, priority = 0) {
9480
- if (weight <= 0)
9481
- throw new Error(`invalid weight ${weight}: must be positive`);
9482
- return new Promise((resolve, reject) => {
9483
- const task = { resolve, reject, weight, priority };
9484
- const i = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
9485
- if (i === -1 && weight <= this._value) {
9486
- this._dispatchItem(task);
9544
+ NoopTracer2.prototype.startSpan = function(name, options, context) {
9545
+ if (context === void 0) {
9546
+ context = contextApi.active();
9547
+ }
9548
+ var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
9549
+ if (root) {
9550
+ return new NonRecordingSpan();
9551
+ }
9552
+ var parentFromContext = context && getSpanContext(context);
9553
+ if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
9554
+ return new NonRecordingSpan(parentFromContext);
9487
9555
  } else {
9488
- this._queue.splice(i + 1, 0, task);
9556
+ return new NonRecordingSpan();
9489
9557
  }
9490
- });
9491
- }
9492
- runExclusive(callback_1) {
9493
- return __awaiter$2(this, arguments, void 0, function* (callback, weight = 1, priority = 0) {
9494
- const [value, release] = yield this.acquire(weight, priority);
9495
- try {
9496
- return yield callback(value);
9497
- } finally {
9498
- release();
9558
+ };
9559
+ NoopTracer2.prototype.startActiveSpan = function(name, arg2, arg3, arg4) {
9560
+ var opts;
9561
+ var ctx;
9562
+ var fn;
9563
+ if (arguments.length < 2) {
9564
+ return;
9565
+ } else if (arguments.length === 2) {
9566
+ fn = arg2;
9567
+ } else if (arguments.length === 3) {
9568
+ opts = arg2;
9569
+ fn = arg3;
9570
+ } else {
9571
+ opts = arg2;
9572
+ ctx = arg3;
9573
+ fn = arg4;
9499
9574
  }
9500
- });
9501
- }
9502
- waitForUnlock(weight = 1, priority = 0) {
9503
- if (weight <= 0)
9504
- throw new Error(`invalid weight ${weight}: must be positive`);
9505
- if (this._couldLockImmediately(weight, priority)) {
9506
- return Promise.resolve();
9507
- } else {
9508
- return new Promise((resolve) => {
9509
- if (!this._weightedWaiters[weight - 1])
9510
- this._weightedWaiters[weight - 1] = [];
9511
- insertSorted(this._weightedWaiters[weight - 1], { resolve, priority });
9512
- });
9513
- }
9514
- }
9515
- isLocked() {
9516
- return this._value <= 0;
9517
- }
9518
- getValue() {
9519
- return this._value;
9520
- }
9521
- setValue(value) {
9522
- this._value = value;
9523
- this._dispatchQueue();
9524
- }
9525
- release(weight = 1) {
9526
- if (weight <= 0)
9527
- throw new Error(`invalid weight ${weight}: must be positive`);
9528
- this._value += weight;
9529
- this._dispatchQueue();
9530
- }
9531
- cancel() {
9532
- this._queue.forEach((entry) => entry.reject(this._cancelError));
9533
- this._queue = [];
9534
- }
9535
- _dispatchQueue() {
9536
- this._drainUnlockWaiters();
9537
- while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
9538
- this._dispatchItem(this._queue.shift());
9539
- this._drainUnlockWaiters();
9575
+ var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
9576
+ var span = this.startSpan(name, opts, parentContext);
9577
+ var contextWithSpanSet = setSpan(parentContext, span);
9578
+ return contextApi.with(contextWithSpanSet, fn, void 0, span);
9579
+ };
9580
+ return NoopTracer2;
9581
+ }()
9582
+ );
9583
+ function isSpanContext(spanContext) {
9584
+ return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
9585
+ }
9586
+
9587
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js
9588
+ var NOOP_TRACER = new NoopTracer();
9589
+ var ProxyTracer = (
9590
+ /** @class */
9591
+ function() {
9592
+ function ProxyTracer2(_provider, name, version, options) {
9593
+ this._provider = _provider;
9594
+ this.name = name;
9595
+ this.version = version;
9596
+ this.options = options;
9540
9597
  }
9541
- }
9542
- _dispatchItem(item) {
9543
- const previousValue = this._value;
9544
- this._value -= item.weight;
9545
- item.resolve([previousValue, this._newReleaser(item.weight)]);
9546
- }
9547
- _newReleaser(weight) {
9548
- let called = false;
9549
- return () => {
9550
- if (called)
9551
- return;
9552
- called = true;
9553
- this.release(weight);
9598
+ ProxyTracer2.prototype.startSpan = function(name, options, context) {
9599
+ return this._getTracer().startSpan(name, options, context);
9600
+ };
9601
+ ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
9602
+ var tracer2 = this._getTracer();
9603
+ return Reflect.apply(tracer2.startActiveSpan, tracer2, arguments);
9554
9604
  };
9555
- }
9556
- _drainUnlockWaiters() {
9557
- if (this._queue.length === 0) {
9558
- for (let weight = this._value; weight > 0; weight--) {
9559
- const waiters = this._weightedWaiters[weight - 1];
9560
- if (!waiters)
9561
- continue;
9562
- waiters.forEach((waiter) => waiter.resolve());
9563
- this._weightedWaiters[weight - 1] = [];
9605
+ ProxyTracer2.prototype._getTracer = function() {
9606
+ if (this._delegate) {
9607
+ return this._delegate;
9564
9608
  }
9565
- } else {
9566
- const queuedPriority = this._queue[0].priority;
9567
- for (let weight = this._value; weight > 0; weight--) {
9568
- const waiters = this._weightedWaiters[weight - 1];
9569
- if (!waiters)
9570
- continue;
9571
- const i = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
9572
- (i === -1 ? waiters : waiters.splice(0, i)).forEach((waiter) => waiter.resolve());
9609
+ var tracer2 = this._provider.getDelegateTracer(this.name, this.version, this.options);
9610
+ if (!tracer2) {
9611
+ return NOOP_TRACER;
9573
9612
  }
9574
- }
9575
- }
9576
- _couldLockImmediately(weight, priority) {
9577
- return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
9578
- }
9579
- };
9580
- function insertSorted(a26, v) {
9581
- const i = findIndexFromEnd(a26, (other) => v.priority <= other.priority);
9582
- a26.splice(i + 1, 0, v);
9583
- }
9584
- function findIndexFromEnd(a26, predicate) {
9585
- for (let i = a26.length - 1; i >= 0; i--) {
9586
- if (predicate(a26[i])) {
9587
- return i;
9588
- }
9589
- }
9590
- return -1;
9591
- }
9613
+ this._delegate = tracer2;
9614
+ return this._delegate;
9615
+ };
9616
+ return ProxyTracer2;
9617
+ }()
9618
+ );
9592
9619
 
9593
- // ../shared/dist/esm/utils/locks.js
9594
- var ReadWriteLock = class {
9595
- constructor() {
9596
- this.semaphore = new Semaphore(1);
9597
- this.readers = 0;
9598
- this.readersMutex = new Semaphore(1);
9599
- }
9600
- async withReadLock(callback) {
9601
- await this._acquireReadLock();
9602
- try {
9603
- return await callback();
9604
- } finally {
9605
- await this._releaseReadLock();
9620
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js
9621
+ var NoopTracerProvider = (
9622
+ /** @class */
9623
+ function() {
9624
+ function NoopTracerProvider2() {
9606
9625
  }
9607
- }
9608
- async withWriteLock(callback) {
9609
- await this._acquireWriteLock();
9610
- try {
9611
- return await callback();
9612
- } finally {
9613
- await this._releaseWriteLock();
9626
+ NoopTracerProvider2.prototype.getTracer = function(_name, _version, _options) {
9627
+ return new NoopTracer();
9628
+ };
9629
+ return NoopTracerProvider2;
9630
+ }()
9631
+ );
9632
+
9633
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js
9634
+ var NOOP_TRACER_PROVIDER = new NoopTracerProvider();
9635
+ var ProxyTracerProvider = (
9636
+ /** @class */
9637
+ function() {
9638
+ function ProxyTracerProvider2() {
9614
9639
  }
9615
- }
9616
- async _acquireReadLock() {
9617
- await this.readersMutex.acquire();
9618
- try {
9619
- this.readers += 1;
9620
- if (this.readers === 1) await this.semaphore.acquire();
9621
- } finally {
9622
- this.readersMutex.release();
9640
+ ProxyTracerProvider2.prototype.getTracer = function(name, version, options) {
9641
+ var _a5;
9642
+ return (_a5 = this.getDelegateTracer(name, version, options)) !== null && _a5 !== void 0 ? _a5 : new ProxyTracer(this, name, version, options);
9643
+ };
9644
+ ProxyTracerProvider2.prototype.getDelegate = function() {
9645
+ var _a5;
9646
+ return (_a5 = this._delegate) !== null && _a5 !== void 0 ? _a5 : NOOP_TRACER_PROVIDER;
9647
+ };
9648
+ ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
9649
+ this._delegate = delegate;
9650
+ };
9651
+ ProxyTracerProvider2.prototype.getDelegateTracer = function(name, version, options) {
9652
+ var _a5;
9653
+ return (_a5 = this._delegate) === null || _a5 === void 0 ? void 0 : _a5.getTracer(name, version, options);
9654
+ };
9655
+ return ProxyTracerProvider2;
9656
+ }()
9657
+ );
9658
+
9659
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/trace.js
9660
+ var API_NAME3 = "trace";
9661
+ var TraceAPI = (
9662
+ /** @class */
9663
+ function() {
9664
+ function TraceAPI2() {
9665
+ this._proxyTracerProvider = new ProxyTracerProvider();
9666
+ this.wrapSpanContext = wrapSpanContext;
9667
+ this.isSpanContextValid = isSpanContextValid;
9668
+ this.deleteSpan = deleteSpan;
9669
+ this.getSpan = getSpan;
9670
+ this.getActiveSpan = getActiveSpan;
9671
+ this.getSpanContext = getSpanContext;
9672
+ this.setSpan = setSpan;
9673
+ this.setSpanContext = setSpanContext;
9623
9674
  }
9624
- }
9625
- async _releaseReadLock() {
9626
- await this.readersMutex.acquire();
9675
+ TraceAPI2.getInstance = function() {
9676
+ if (!this._instance) {
9677
+ this._instance = new TraceAPI2();
9678
+ }
9679
+ return this._instance;
9680
+ };
9681
+ TraceAPI2.prototype.setGlobalTracerProvider = function(provider) {
9682
+ var success = registerGlobal(API_NAME3, this._proxyTracerProvider, DiagAPI.instance());
9683
+ if (success) {
9684
+ this._proxyTracerProvider.setDelegate(provider);
9685
+ }
9686
+ return success;
9687
+ };
9688
+ TraceAPI2.prototype.getTracerProvider = function() {
9689
+ return getGlobal(API_NAME3) || this._proxyTracerProvider;
9690
+ };
9691
+ TraceAPI2.prototype.getTracer = function(name, version) {
9692
+ return this.getTracerProvider().getTracer(name, version);
9693
+ };
9694
+ TraceAPI2.prototype.disable = function() {
9695
+ unregisterGlobal(API_NAME3, DiagAPI.instance());
9696
+ this._proxyTracerProvider = new ProxyTracerProvider();
9697
+ };
9698
+ return TraceAPI2;
9699
+ }()
9700
+ );
9701
+
9702
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace-api.js
9703
+ var trace = TraceAPI.getInstance();
9704
+
9705
+ // ../shared/dist/esm/utils/telemetry.js
9706
+ var tracer = trace.getTracer("stack-tracer");
9707
+ async function traceSpan(optionsOrDescription, fn) {
9708
+ let options = typeof optionsOrDescription === "string" ? { description: optionsOrDescription } : optionsOrDescription;
9709
+ return await tracer.startActiveSpan(`STACK: ${options.description}`, async (span) => {
9710
+ if (options.attributes) for (const [key, value] of Object.entries(options.attributes)) span.setAttribute(key, value);
9627
9711
  try {
9628
- this.readers -= 1;
9629
- if (this.readers === 0) this.semaphore.release();
9712
+ return await fn(span);
9630
9713
  } finally {
9631
- this.readersMutex.release();
9714
+ span.end();
9632
9715
  }
9633
- }
9634
- async _acquireWriteLock() {
9635
- await this.semaphore.acquire();
9636
- }
9637
- async _releaseWriteLock() {
9638
- this.semaphore.release();
9639
- }
9640
- };
9641
-
9642
- // ../shared/dist/esm/utils/stores.js
9643
- var storeLock = new ReadWriteLock();
9644
-
9645
- // ../shared/dist/esm/interface/client-interface.js
9646
- var USER_AGENT;
9647
- if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) USER_AGENT = `oauth4webapi/v3.8.5`;
9648
- var ERR_INVALID_ARG_VALUE = "ERR_INVALID_ARG_VALUE";
9649
- function CodedTypeError(message, code, cause) {
9650
- const err = new TypeError(message, { cause });
9651
- Object.assign(err, { code });
9652
- return err;
9653
- }
9654
- var allowInsecureRequests = Symbol();
9655
- var clockSkew = Symbol();
9656
- var clockTolerance = Symbol();
9657
- var customFetch = Symbol();
9658
- var jweDecrypt = Symbol();
9659
- var encoder = new TextEncoder();
9660
- var decoder = new TextDecoder();
9661
- var encodeBase64Url;
9662
- if (Uint8Array.prototype.toBase64) encodeBase64Url = (input) => {
9663
- if (input instanceof ArrayBuffer) input = new Uint8Array(input);
9664
- return input.toBase64({
9665
- alphabet: "base64url",
9666
- omitPadding: true
9667
9716
  });
9668
- };
9669
- else {
9670
- const CHUNK_SIZE = 32768;
9671
- encodeBase64Url = (input) => {
9672
- if (input instanceof ArrayBuffer) input = new Uint8Array(input);
9673
- const arr = [];
9674
- for (let i = 0; i < input.byteLength; i += CHUNK_SIZE) arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
9675
- return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
9676
- };
9677
9717
  }
9678
- var decodeBase64Url;
9679
- if (Uint8Array.fromBase64) decodeBase64Url = (input) => {
9680
- try {
9681
- return Uint8Array.fromBase64(input, { alphabet: "base64url" });
9682
- } catch (cause) {
9683
- throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
9684
- }
9685
- };
9686
- else decodeBase64Url = (input) => {
9687
- try {
9688
- const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
9689
- const bytes = new Uint8Array(binary.length);
9690
- for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
9691
- return bytes;
9692
- } catch (cause) {
9693
- throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
9694
- }
9695
- };
9696
- var URLParse = URL.parse ? (url, base) => URL.parse(url, base) : (url, base) => {
9697
- try {
9698
- return new URL(url, base);
9699
- } catch {
9700
- return null;
9701
- }
9702
- };
9703
- var tokenMatch = "[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+";
9704
- var token68Match = "[a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2}";
9705
- var quotedParamMatcher = "(" + tokenMatch + ')\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"';
9706
- var paramMatcher = "(" + tokenMatch + ")\\s*=\\s*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)";
9707
- var schemeRE = new RegExp("^[,\\s]*(" + tokenMatch + ")");
9708
- var quotedParamRE = new RegExp("^[,\\s]*" + quotedParamMatcher + "[,\\s]*(.*)");
9709
- var unquotedParamRE = new RegExp("^[,\\s]*" + paramMatcher + "[,\\s]*(.*)");
9710
- var token68ParamRE = new RegExp("^(" + token68Match + ")(?:$|[,\\s])(.*)");
9711
- var nopkce = Symbol();
9712
- var expectNoNonce = Symbol();
9713
- var skipAuthTimeCheck = Symbol();
9714
- var skipStateCheck = Symbol();
9715
- var expectNoState = Symbol();
9716
- var _expectedIssuer = Symbol();
9717
- var botChallengeKnownErrors = [KnownErrors.BotChallengeRequired, KnownErrors.BotChallengeFailed];
9718
9718
 
9719
9719
  // ../shared/dist/esm/utils/promises.js
9720
9720
  var neverResolvePromise = pending(new Promise(() => {