@hexclave/dashboard-ui-components 1.0.56 → 1.0.57

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.
@@ -4665,1326 +4665,448 @@ This is likely an error in Hexclave. Please make sure you are running the newest
4665
4665
  return Object.assign(Result.error(new RetryError(errors)), { attempts: totalAttempts });
4666
4666
  }
4667
4667
 
4668
- // ../shared/dist/esm/utils/maps.js
4669
- var _Symbol$toStringTag;
4670
- var _Symbol$toStringTag2;
4671
- var _Symbol$toStringTag3;
4672
- var WeakRefIfAvailable = class {
4673
- constructor(value) {
4674
- if (typeof WeakRef === "undefined") this._ref = { deref: () => value };
4675
- else this._ref = new WeakRef(value);
4676
- }
4677
- deref() {
4678
- return this._ref.deref();
4679
- }
4680
- };
4681
- var _a2;
4682
- var IterableWeakMap = (_a2 = class {
4683
- constructor(entries) {
4684
- this[_Symbol$toStringTag] = "IterableWeakMap";
4685
- const mappedEntries = entries?.map((e40) => [e40[0], {
4686
- value: e40[1],
4687
- keyRef: new WeakRefIfAvailable(e40[0])
4688
- }]);
4689
- this._weakMap = new WeakMap(mappedEntries ?? []);
4690
- this._keyRefs = new Set(mappedEntries?.map((e40) => e40[1].keyRef) ?? []);
4691
- }
4692
- get(key) {
4693
- return this._weakMap.get(key)?.value;
4694
- }
4695
- set(key, value) {
4696
- const updated = {
4697
- value,
4698
- keyRef: this._weakMap.get(key)?.keyRef ?? new WeakRefIfAvailable(key)
4699
- };
4700
- this._weakMap.set(key, updated);
4701
- this._keyRefs.add(updated.keyRef);
4702
- return this;
4703
- }
4704
- delete(key) {
4705
- const res = this._weakMap.get(key);
4706
- if (res) {
4707
- this._weakMap.delete(key);
4708
- this._keyRefs.delete(res.keyRef);
4709
- return true;
4710
- }
4711
- return false;
4712
- }
4713
- has(key) {
4714
- return this._weakMap.has(key) && this._keyRefs.has(this._weakMap.get(key).keyRef);
4715
- }
4716
- *[Symbol.iterator]() {
4717
- for (const keyRef of this._keyRefs) {
4718
- const key = keyRef.deref();
4719
- const existing = key ? this._weakMap.get(key) : void 0;
4720
- if (!key) this._keyRefs.delete(keyRef);
4721
- else if (existing) yield [key, existing.value];
4722
- }
4668
+ // ../shared/dist/esm/utils/bytes.js
4669
+ function decodeBase64(input) {
4670
+ return new Uint8Array(atob(input).split("").map((char) => char.charCodeAt(0)));
4671
+ }
4672
+ function isBase64(input) {
4673
+ return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(input);
4674
+ }
4675
+
4676
+ // ../shared/dist/esm/utils/urls.js
4677
+ function createUrlIfValid(...args) {
4678
+ try {
4679
+ return new URL(...args);
4680
+ } catch (e40) {
4681
+ return null;
4723
4682
  }
4724
- }, _Symbol$toStringTag = Symbol.toStringTag, _a2);
4725
- var _a3;
4726
- var MaybeWeakMap = (_a3 = class {
4727
- constructor(entries) {
4728
- this[_Symbol$toStringTag2] = "MaybeWeakMap";
4729
- const entriesArray = [...entries ?? []];
4730
- this._primitiveMap = new Map(entriesArray.filter((e40) => !this._isAllowedInWeakMap(e40[0])));
4731
- this._weakMap = new IterableWeakMap(entriesArray.filter((e40) => this._isAllowedInWeakMap(e40[0])));
4683
+ }
4684
+ function isValidUrl(url) {
4685
+ return !!createUrlIfValid(url);
4686
+ }
4687
+ function isValidHostname(hostname) {
4688
+ if (!hostname || hostname.startsWith(".") || hostname.endsWith(".") || hostname.includes("..")) return false;
4689
+ const url = createUrlIfValid(`https://${hostname}`);
4690
+ if (!url) return false;
4691
+ return url.hostname === hostname;
4692
+ }
4693
+ function isValidHostnameWithWildcards(hostname) {
4694
+ if (!hostname) return false;
4695
+ if (!hostname.includes("*")) return isValidHostname(hostname);
4696
+ if (hostname.startsWith(".") || hostname.endsWith(".")) return false;
4697
+ if (hostname.includes("..")) return false;
4698
+ const testHostname = hostname.replace(/\*+/g, "wildcard");
4699
+ if (!/^[a-zA-Z0-9.-]+$/.test(testHostname)) return false;
4700
+ const segments = hostname.split(/\*+/);
4701
+ for (let i = 0; i < segments.length; i++) {
4702
+ const segment = segments[i];
4703
+ if (segment === "") continue;
4704
+ if (i === 0 && segment.startsWith(".")) return false;
4705
+ if (i === segments.length - 1 && segment.endsWith(".")) return false;
4706
+ if (segment.includes("..")) return false;
4732
4707
  }
4733
- _isAllowedInWeakMap(key) {
4734
- return typeof key === "object" && key !== null || typeof key === "symbol" && Symbol.keyFor(key) === void 0;
4708
+ return true;
4709
+ }
4710
+
4711
+ // ../shared/dist/esm/known-errors.js
4712
+ var KnownError = class extends StatusError {
4713
+ constructor(statusCode, humanReadableMessage, details) {
4714
+ super(statusCode, humanReadableMessage);
4715
+ this.statusCode = statusCode;
4716
+ this.humanReadableMessage = humanReadableMessage;
4717
+ this.details = details;
4718
+ this.__stackKnownErrorBrand = "stack-known-error-brand-sentinel";
4719
+ this.name = "KnownError";
4735
4720
  }
4736
- get(key) {
4737
- if (this._isAllowedInWeakMap(key)) return this._weakMap.get(key);
4738
- else return this._primitiveMap.get(key);
4721
+ static isKnownError(error) {
4722
+ return typeof error === "object" && error !== null && "__stackKnownErrorBrand" in error && error.__stackKnownErrorBrand === "stack-known-error-brand-sentinel";
4739
4723
  }
4740
- set(key, value) {
4741
- if (this._isAllowedInWeakMap(key)) this._weakMap.set(key, value);
4742
- else this._primitiveMap.set(key, value);
4743
- return this;
4724
+ getBody() {
4725
+ return new TextEncoder().encode(JSON.stringify(this.toDescriptiveJson(), void 0, 2));
4744
4726
  }
4745
- delete(key) {
4746
- if (this._isAllowedInWeakMap(key)) return this._weakMap.delete(key);
4747
- else return this._primitiveMap.delete(key);
4727
+ getHeaders() {
4728
+ return {
4729
+ "Content-Type": ["application/json; charset=utf-8"],
4730
+ "X-Stack-Known-Error": [this.errorCode],
4731
+ "X-Hexclave-Known-Error": [this.errorCode]
4732
+ };
4748
4733
  }
4749
- has(key) {
4750
- if (this._isAllowedInWeakMap(key)) return this._weakMap.has(key);
4751
- else return this._primitiveMap.has(key);
4734
+ toDescriptiveJson() {
4735
+ return {
4736
+ code: this.errorCode,
4737
+ ...this.details ? { details: this.details } : {},
4738
+ error: this.humanReadableMessage
4739
+ };
4752
4740
  }
4753
- *[Symbol.iterator]() {
4754
- yield* this._primitiveMap;
4755
- yield* this._weakMap;
4741
+ get errorCode() {
4742
+ return this.constructor.errorCode ?? throwErr(`Can't find error code for this KnownError. Is its constructor a KnownErrorConstructor? ${this}`);
4756
4743
  }
4757
- }, _Symbol$toStringTag2 = Symbol.toStringTag, _a3);
4758
- var _a4;
4759
- var DependenciesMap = (_a4 = class {
4760
- constructor() {
4761
- this._inner = {
4762
- map: new MaybeWeakMap(),
4763
- hasValue: false,
4764
- value: void 0
4765
- };
4766
- this[_Symbol$toStringTag3] = "DependenciesMap";
4744
+ static constructorArgsFromJson(json) {
4745
+ return [
4746
+ 400,
4747
+ json.message,
4748
+ json
4749
+ ];
4767
4750
  }
4768
- _valueToResult(inner) {
4769
- if (inner.hasValue) return Result.ok(inner.value);
4770
- else return Result.error(void 0);
4751
+ static fromJson(json) {
4752
+ for (const [_, KnownErrorType] of Object.entries(KnownErrors)) if (json.code === KnownErrorType.prototype.errorCode) return new KnownErrorType(...KnownErrorType.constructorArgsFromJson(json));
4753
+ throw new Error(`An error occurred. Please update your version of the Hexclave SDK. ${json.code}: ${json.message}`);
4771
4754
  }
4772
- _unwrapFromInner(dependencies, inner) {
4773
- if (dependencies.length === 0) return this._valueToResult(inner);
4774
- else {
4775
- const [key, ...rest] = dependencies;
4776
- const newInner = inner.map.get(key);
4777
- if (!newInner) return Result.error(void 0);
4778
- return this._unwrapFromInner(rest, newInner);
4755
+ };
4756
+ function createKnownErrorConstructor(SuperClass, errorCode, create, constructorArgsFromJson) {
4757
+ const createFn = create === "inherit" ? identityArgs : create;
4758
+ const constructorArgsFromJsonFn = constructorArgsFromJson === "inherit" ? SuperClass.constructorArgsFromJson : constructorArgsFromJson;
4759
+ const _KnownErrorImpl = class _KnownErrorImpl extends SuperClass {
4760
+ constructor(...args) {
4761
+ super(...createFn(...args));
4762
+ this.name = `KnownError<${errorCode}>`;
4763
+ this.constructorArgs = args;
4779
4764
  }
4780
- }
4781
- _setInInner(dependencies, value, inner) {
4782
- if (dependencies.length === 0) {
4783
- const res = this._valueToResult(inner);
4784
- if (value.status === "ok") {
4785
- inner.hasValue = true;
4786
- inner.value = value.data;
4787
- } else {
4788
- inner.hasValue = false;
4789
- inner.value = void 0;
4790
- }
4791
- return res;
4792
- } else {
4793
- const [key, ...rest] = dependencies;
4794
- let newInner = inner.map.get(key);
4795
- if (!newInner) inner.map.set(key, newInner = {
4796
- map: new MaybeWeakMap(),
4797
- hasValue: false,
4798
- value: void 0
4799
- });
4800
- return this._setInInner(rest, value, newInner);
4765
+ static constructorArgsFromJson(json) {
4766
+ return constructorArgsFromJsonFn(json.details);
4801
4767
  }
4802
- }
4803
- *_iterateInner(dependencies, inner) {
4804
- if (inner.hasValue) yield [dependencies, inner.value];
4805
- for (const [key, value] of inner.map) yield* this._iterateInner([...dependencies, key], value);
4806
- }
4807
- get(dependencies) {
4808
- return Result.or(this._unwrapFromInner(dependencies, this._inner), void 0);
4809
- }
4810
- set(dependencies, value) {
4811
- this._setInInner(dependencies, Result.ok(value), this._inner);
4812
- return this;
4813
- }
4814
- delete(dependencies) {
4815
- return this._setInInner(dependencies, Result.error(void 0), this._inner).status === "ok";
4816
- }
4817
- has(dependencies) {
4818
- return this._unwrapFromInner(dependencies, this._inner).status === "ok";
4819
- }
4820
- clear() {
4821
- this._inner = {
4822
- map: new MaybeWeakMap(),
4823
- hasValue: false,
4824
- value: void 0
4825
- };
4826
- }
4827
- *[Symbol.iterator]() {
4828
- yield* this._iterateInner([], this._inner);
4829
- }
4830
- }, _Symbol$toStringTag3 = Symbol.toStringTag, _a4);
4831
-
4832
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/platform/browser/globalThis.js
4833
- var _globalThis = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
4834
-
4835
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/version.js
4836
- var VERSION = "1.9.0";
4837
-
4838
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/semver.js
4839
- var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
4840
- function _makeCompatibilityCheck(ownVersion) {
4841
- var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
4842
- var rejectedVersions = /* @__PURE__ */ new Set();
4843
- var myVersionMatch = ownVersion.match(re);
4844
- if (!myVersionMatch) {
4845
- return function() {
4768
+ static isInstance(error) {
4769
+ if (!KnownError.isKnownError(error)) return false;
4770
+ let current = error;
4771
+ while (true) {
4772
+ current = Object.getPrototypeOf(current);
4773
+ if (!current) break;
4774
+ if ("errorCode" in current.constructor && current.constructor.errorCode === errorCode) return true;
4775
+ }
4846
4776
  return false;
4847
- };
4848
- }
4849
- var ownVersionParsed = {
4850
- major: +myVersionMatch[1],
4851
- minor: +myVersionMatch[2],
4852
- patch: +myVersionMatch[3],
4853
- prerelease: myVersionMatch[4]
4854
- };
4855
- if (ownVersionParsed.prerelease != null) {
4856
- return function isExactmatch(globalVersion) {
4857
- return globalVersion === ownVersion;
4858
- };
4859
- }
4860
- function _reject(v) {
4861
- rejectedVersions.add(v);
4862
- return false;
4863
- }
4864
- function _accept(v) {
4865
- acceptedVersions.add(v);
4866
- return true;
4867
- }
4868
- return function isCompatible2(globalVersion) {
4869
- if (acceptedVersions.has(globalVersion)) {
4870
- return true;
4871
- }
4872
- if (rejectedVersions.has(globalVersion)) {
4873
- return false;
4874
- }
4875
- var globalVersionMatch = globalVersion.match(re);
4876
- if (!globalVersionMatch) {
4877
- return _reject(globalVersion);
4878
- }
4879
- var globalVersionParsed = {
4880
- major: +globalVersionMatch[1],
4881
- minor: +globalVersionMatch[2],
4882
- patch: +globalVersionMatch[3],
4883
- prerelease: globalVersionMatch[4]
4884
- };
4885
- if (globalVersionParsed.prerelease != null) {
4886
- return _reject(globalVersion);
4887
- }
4888
- if (ownVersionParsed.major !== globalVersionParsed.major) {
4889
- return _reject(globalVersion);
4890
- }
4891
- if (ownVersionParsed.major === 0) {
4892
- if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
4893
- return _accept(globalVersion);
4894
- }
4895
- return _reject(globalVersion);
4896
- }
4897
- if (ownVersionParsed.minor <= globalVersionParsed.minor) {
4898
- return _accept(globalVersion);
4899
4777
  }
4900
- return _reject(globalVersion);
4901
4778
  };
4779
+ _KnownErrorImpl.errorCode = errorCode;
4780
+ let KnownErrorImpl = _KnownErrorImpl;
4781
+ return KnownErrorImpl;
4902
4782
  }
4903
- var isCompatible = _makeCompatibilityCheck(VERSION);
4783
+ var UnsupportedError = createKnownErrorConstructor(KnownError, "UNSUPPORTED_ERROR", (originalErrorCode) => [
4784
+ 500,
4785
+ `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}`,
4786
+ { originalErrorCode }
4787
+ ], (json) => [json?.originalErrorCode ?? throwErr("originalErrorCode not found in UnsupportedError details")]);
4788
+ var BodyParsingError = createKnownErrorConstructor(KnownError, "BODY_PARSING_ERROR", (message2) => [400, message2], (json) => [json.message]);
4789
+ var SchemaError = createKnownErrorConstructor(KnownError, "SCHEMA_ERROR", (message2) => [
4790
+ 400,
4791
+ message2 || throwErr("SchemaError requires a message"),
4792
+ { message: message2 }
4793
+ ], (json) => [json.message]);
4794
+ var AllOverloadsFailed = createKnownErrorConstructor(KnownError, "ALL_OVERLOADS_FAILED", (overloadErrors) => [
4795
+ 400,
4796
+ deindent`
4797
+ This endpoint has multiple overloads, but they all failed to process the request.
4904
4798
 
4905
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
4906
- var major = VERSION.split(".")[0];
4907
- var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
4908
- var _global = _globalThis;
4909
- function registerGlobal(type, instance, diag, allowOverride) {
4910
- var _a5;
4911
- if (allowOverride === void 0) {
4912
- allowOverride = false;
4913
- }
4914
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a5 !== void 0 ? _a5 : {
4915
- version: VERSION
4916
- };
4917
- if (!allowOverride && api[type]) {
4918
- var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
4919
- diag.error(err.stack || err.message);
4920
- return false;
4921
- }
4922
- if (api.version !== VERSION) {
4923
- var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
4924
- diag.error(err.stack || err.message);
4925
- return false;
4926
- }
4927
- api[type] = instance;
4928
- diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
4929
- return true;
4930
- }
4931
- function getGlobal(type) {
4932
- var _a5, _b;
4933
- var globalVersion = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a5 === void 0 ? void 0 : _a5.version;
4934
- if (!globalVersion || !isCompatible(globalVersion)) {
4935
- return;
4936
- }
4937
- return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
4938
- }
4939
- function unregisterGlobal(type, diag) {
4940
- diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
4941
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
4942
- if (api) {
4943
- delete api[type];
4799
+ ${overloadErrors.map((e40, i) => deindent`
4800
+ Overload ${i + 1}: ${JSON.stringify(e40, void 0, 2)}
4801
+ `).join("\n\n")}
4802
+ `,
4803
+ { overload_errors: overloadErrors }
4804
+ ], (json) => [json?.overload_errors ?? throwErr("overload_errors not found in AllOverloadsFailed details")]);
4805
+ var ProjectAuthenticationError = createKnownErrorConstructor(KnownError, "PROJECT_AUTHENTICATION_ERROR", "inherit", "inherit");
4806
+ var InvalidProjectAuthentication = createKnownErrorConstructor(ProjectAuthenticationError, "INVALID_PROJECT_AUTHENTICATION", "inherit", "inherit");
4807
+ 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.)"], () => []);
4808
+ 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")]);
4809
+ var AccessTypeWithoutProjectId = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_WITHOUT_PROJECT_ID", (accessType) => [
4810
+ 400,
4811
+ deindent`
4812
+ 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.)
4813
+
4814
+ For more information, see the docs on REST API authentication: https://docs.hexclave.com/api/overview#authentication
4815
+ `,
4816
+ { request_type: accessType }
4817
+ ], (json) => [json.request_type]);
4818
+ var AccessTypeRequired = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_REQUIRED", () => [400, deindent`
4819
+ 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.)
4820
+
4821
+ For more information, see the docs on REST API authentication: https://docs.hexclave.com/api/overview#authentication
4822
+ `], () => []);
4823
+ var InsufficientAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "INSUFFICIENT_ACCESS_TYPE", (actualAccessType, allowedAccessTypes) => [
4824
+ 401,
4825
+ `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.)`,
4826
+ {
4827
+ actual_access_type: actualAccessType,
4828
+ allowed_access_types: allowedAccessTypes
4944
4829
  }
4945
- }
4830
+ ], (json) => [json.actual_access_type, json.allowed_access_types]);
4831
+ var InvalidPublishableClientKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_PUBLISHABLE_CLIENT_KEY", (projectId) => [
4832
+ 401,
4833
+ `The publishable key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
4834
+ { project_id: projectId }
4835
+ ], (json) => [json.project_id]);
4836
+ var InvalidSecretServerKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SECRET_SERVER_KEY", (projectId) => [
4837
+ 401,
4838
+ `The secret server key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
4839
+ { project_id: projectId }
4840
+ ], (json) => [json.project_id]);
4841
+ var InvalidSuperSecretAdminKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SUPER_SECRET_ADMIN_KEY", (projectId) => [
4842
+ 401,
4843
+ `The super secret admin key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
4844
+ { project_id: projectId }
4845
+ ], (json) => [json.project_id]);
4846
+ var InvalidAdminAccessToken = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_ADMIN_ACCESS_TOKEN", "inherit", "inherit");
4847
+ var UnparsableAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "UNPARSABLE_ADMIN_ACCESS_TOKEN", () => [401, "Admin access token is not parsable."], () => []);
4848
+ var AdminAccessTokenExpired = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_EXPIRED", (expiredAt) => [
4849
+ 401,
4850
+ `Admin access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)` : ""}`,
4851
+ { expired_at_millis: expiredAt?.getTime() ?? null }
4852
+ ], (json) => [json.expired_at_millis ? new Date(json.expired_at_millis) : void 0]);
4853
+ var InvalidProjectForAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "INVALID_PROJECT_FOR_ADMIN_ACCESS_TOKEN", () => [401, "Admin access tokens must be created on the internal project."], () => []);
4854
+ var AdminAccessTokenIsNotAdmin = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_IS_NOT_ADMIN", () => [401, "Admin access token does not have the required permissions to access this project."], () => []);
4855
+ var ProjectAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationError, "PROJECT_AUTHENTICATION_REQUIRED", "inherit", "inherit");
4856
+ var ClientAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_AUTHENTICATION_REQUIRED", () => [401, "The publishable client key must be provided."], () => []);
4857
+ var PublishableClientKeyRequiredForProject = createKnownErrorConstructor(ProjectAuthenticationRequired, "PUBLISHABLE_CLIENT_KEY_REQUIRED_FOR_PROJECT", (projectId) => [
4858
+ 401,
4859
+ "Publishable client keys are required for this project. Create one in Project Keys, or disable this requirement there to allow keyless client access.",
4860
+ { project_id: projectId ?? null }
4861
+ ], (json) => [json.project_id ?? void 0]);
4862
+ var ServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "SERVER_AUTHENTICATION_REQUIRED", () => [401, "The secret server key must be provided."], () => []);
4863
+ var ClientOrServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_SERVER_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the secret server key must be provided."], () => []);
4864
+ var ClientOrAdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_ADMIN_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the super secret admin key must be provided."], () => []);
4865
+ 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."], () => []);
4866
+ var AdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "ADMIN_AUTHENTICATION_REQUIRED", () => [401, "The super secret admin key must be provided."], () => []);
4867
+ var ExpectedInternalProject = createKnownErrorConstructor(ProjectAuthenticationError, "EXPECTED_INTERNAL_PROJECT", () => [401, "The project ID is expected to be internal."], () => []);
4868
+ var SessionAuthenticationError = createKnownErrorConstructor(KnownError, "SESSION_AUTHENTICATION_ERROR", "inherit", "inherit");
4869
+ var InvalidSessionAuthentication = createKnownErrorConstructor(SessionAuthenticationError, "INVALID_SESSION_AUTHENTICATION", "inherit", "inherit");
4870
+ var InvalidAccessToken = createKnownErrorConstructor(InvalidSessionAuthentication, "INVALID_ACCESS_TOKEN", "inherit", "inherit");
4871
+ var UnparsableAccessToken = createKnownErrorConstructor(InvalidAccessToken, "UNPARSABLE_ACCESS_TOKEN", () => [401, "Access token is not parsable."], () => []);
4872
+ var AccessTokenExpired = createKnownErrorConstructor(InvalidAccessToken, "ACCESS_TOKEN_EXPIRED", (expiredAt, projectId, userId, refreshTokenId) => [
4873
+ 401,
4874
+ deindent`
4875
+ 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}.` : ""}
4946
4876
 
4947
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
4948
- var __read = function(o21, n10) {
4949
- var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
4950
- if (!m6) return o21;
4951
- var i = m6.call(o21), r7, ar = [], e40;
4952
- try {
4953
- while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
4954
- } catch (error) {
4955
- e40 = { error };
4956
- } finally {
4957
- try {
4958
- if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
4959
- } finally {
4960
- if (e40) throw e40.error;
4961
- }
4877
+ 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.
4878
+ `,
4879
+ {
4880
+ expired_at_millis: expiredAt?.getTime() ?? null,
4881
+ project_id: projectId ?? null,
4882
+ user_id: userId ?? null,
4883
+ refresh_token_id: refreshTokenId ?? null
4962
4884
  }
4963
- return ar;
4964
- };
4965
- var __spreadArray = function(to, from, pack) {
4966
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
4967
- if (ar || !(i in from)) {
4968
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
4969
- ar[i] = from[i];
4970
- }
4885
+ ], (json) => [
4886
+ json.expired_at_millis ? new Date(json.expired_at_millis) : void 0,
4887
+ json.project_id ?? void 0,
4888
+ json.user_id ?? void 0,
4889
+ json.refresh_token_id ?? void 0
4890
+ ]);
4891
+ var InvalidProjectForAccessToken = createKnownErrorConstructor(InvalidAccessToken, "INVALID_PROJECT_FOR_ACCESS_TOKEN", (expectedProjectId, actualProjectId) => [
4892
+ 401,
4893
+ `Access token not valid for this project. Expected project ID ${JSON.stringify(expectedProjectId)}, but the token is for project ID ${JSON.stringify(actualProjectId)}.`,
4894
+ {
4895
+ expected_project_id: expectedProjectId,
4896
+ actual_project_id: actualProjectId
4971
4897
  }
4972
- return to.concat(ar || Array.prototype.slice.call(from));
4973
- };
4974
- var DiagComponentLogger = (
4975
- /** @class */
4976
- function() {
4977
- function DiagComponentLogger2(props2) {
4978
- this._namespace = props2.namespace || "DiagComponentLogger";
4979
- }
4980
- DiagComponentLogger2.prototype.debug = function() {
4981
- var args = [];
4982
- for (var _i = 0; _i < arguments.length; _i++) {
4983
- args[_i] = arguments[_i];
4984
- }
4985
- return logProxy("debug", this._namespace, args);
4986
- };
4987
- DiagComponentLogger2.prototype.error = function() {
4988
- var args = [];
4989
- for (var _i = 0; _i < arguments.length; _i++) {
4990
- args[_i] = arguments[_i];
4991
- }
4992
- return logProxy("error", this._namespace, args);
4993
- };
4994
- DiagComponentLogger2.prototype.info = function() {
4995
- var args = [];
4996
- for (var _i = 0; _i < arguments.length; _i++) {
4997
- args[_i] = arguments[_i];
4998
- }
4999
- return logProxy("info", this._namespace, args);
5000
- };
5001
- DiagComponentLogger2.prototype.warn = function() {
5002
- var args = [];
5003
- for (var _i = 0; _i < arguments.length; _i++) {
5004
- args[_i] = arguments[_i];
5005
- }
5006
- return logProxy("warn", this._namespace, args);
5007
- };
5008
- DiagComponentLogger2.prototype.verbose = function() {
5009
- var args = [];
5010
- for (var _i = 0; _i < arguments.length; _i++) {
5011
- args[_i] = arguments[_i];
5012
- }
5013
- return logProxy("verbose", this._namespace, args);
5014
- };
5015
- return DiagComponentLogger2;
5016
- }()
5017
- );
5018
- function logProxy(funcName, namespace, args) {
5019
- var logger = getGlobal("diag");
5020
- if (!logger) {
5021
- return;
4898
+ ], (json) => [json.expected_project_id, json.actual_project_id]);
4899
+ var RefreshTokenError = createKnownErrorConstructor(KnownError, "REFRESH_TOKEN_ERROR", "inherit", "inherit");
4900
+ 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."], () => []);
4901
+ var CannotDeleteCurrentSession = createKnownErrorConstructor(RefreshTokenError, "CANNOT_DELETE_CURRENT_SESSION", () => [400, "Cannot delete the current session."], () => []);
4902
+ 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."], () => []);
4903
+ var UserWithEmailAlreadyExists = createKnownErrorConstructor(KnownError, "USER_EMAIL_ALREADY_EXISTS", (email, wouldWorkIfEmailWasVerified = false) => [
4904
+ 409,
4905
+ `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." : "."}`,
4906
+ {
4907
+ email,
4908
+ would_work_if_email_was_verified: wouldWorkIfEmailWasVerified
5022
4909
  }
5023
- args.unshift(namespace);
5024
- return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
5025
- }
5026
-
5027
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/types.js
5028
- var DiagLogLevel;
5029
- (function(DiagLogLevel2) {
5030
- DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
5031
- DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
5032
- DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
5033
- DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
5034
- DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
5035
- DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
5036
- DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
5037
- })(DiagLogLevel || (DiagLogLevel = {}));
5038
-
5039
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
5040
- function createLogLevelDiagLogger(maxLevel, logger) {
5041
- if (maxLevel < DiagLogLevel.NONE) {
5042
- maxLevel = DiagLogLevel.NONE;
5043
- } else if (maxLevel > DiagLogLevel.ALL) {
5044
- maxLevel = DiagLogLevel.ALL;
4910
+ ], (json) => [json.email, json.would_work_if_email_was_verified ?? false]);
4911
+ var EmailNotVerified = createKnownErrorConstructor(KnownError, "EMAIL_NOT_VERIFIED", () => [400, "The email is not verified."], () => []);
4912
+ 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."], () => []);
4913
+ var UserIdDoesNotExist = createKnownErrorConstructor(KnownError, "USER_ID_DOES_NOT_EXIST", (userId) => [
4914
+ 400,
4915
+ `The given user with the ID ${userId} does not exist.`,
4916
+ { user_id: userId }
4917
+ ], (json) => [json.user_id]);
4918
+ var UserNotFound = createKnownErrorConstructor(KnownError, "USER_NOT_FOUND", () => [404, "User not found."], () => []);
4919
+ var RestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
4920
+ 403,
4921
+ `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.`,
4922
+ { restricted_reason: restrictedReason }
4923
+ ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
4924
+ var ProjectNotFound = createKnownErrorConstructor(KnownError, "PROJECT_NOT_FOUND", (projectId) => {
4925
+ if (typeof projectId !== "string") throw new HexclaveAssertionError("projectId of KnownErrors.ProjectNotFound must be a string");
4926
+ return [
4927
+ 404,
4928
+ `Project ${projectId} not found or is not accessible with the current user.`,
4929
+ { project_id: projectId }
4930
+ ];
4931
+ }, (json) => [json.project_id]);
4932
+ var CurrentProjectNotFound = createKnownErrorConstructor(KnownError, "CURRENT_PROJECT_NOT_FOUND", (projectId) => [
4933
+ 400,
4934
+ `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.)`,
4935
+ { project_id: projectId }
4936
+ ], (json) => [json.project_id]);
4937
+ var BranchDoesNotExist = createKnownErrorConstructor(KnownError, "BRANCH_DOES_NOT_EXIST", (branchId) => [
4938
+ 400,
4939
+ `The branch with ID ${branchId} does not exist.`,
4940
+ { branch_id: branchId }
4941
+ ], (json) => [json.branch_id]);
4942
+ 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."], () => []);
4943
+ var SignUpRejected = createKnownErrorConstructor(KnownError, "SIGN_UP_REJECTED", (message2) => [
4944
+ 403,
4945
+ message2 ?? "Your sign up was rejected by an administrator's sign-up rule.",
4946
+ { message: message2 ?? "Your sign up was rejected by an administrator's sign-up rule." }
4947
+ ], (json) => [json.message]);
4948
+ var BotChallengeRequired = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_REQUIRED", () => [409, "An additional bot challenge is required before sign-up can continue."], () => []);
4949
+ var BotChallengeFailed = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_FAILED", (message2) => [
4950
+ 400,
4951
+ message2,
4952
+ { message: message2 }
4953
+ ], (json) => [json.message]);
4954
+ var PasswordAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSWORD_AUTHENTICATION_NOT_ENABLED", () => [400, "Password authentication is not enabled for this project."], () => []);
4955
+ var DataVaultStoreDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_DOES_NOT_EXIST", (storeId) => [
4956
+ 400,
4957
+ `Data vault store with ID ${storeId} does not exist.`,
4958
+ { store_id: storeId }
4959
+ ], (json) => [json.store_id]);
4960
+ var DataVaultStoreHashedKeyDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_HASHED_KEY_DOES_NOT_EXIST", (storeId, hashedKey) => [
4961
+ 400,
4962
+ `Data vault store with ID ${storeId} does not contain a key with hash ${hashedKey}.`,
4963
+ {
4964
+ store_id: storeId,
4965
+ hashed_key: hashedKey
5045
4966
  }
5046
- logger = logger || {};
5047
- function _filterFunc(funcName, theLevel) {
5048
- var theFunc = logger[funcName];
5049
- if (typeof theFunc === "function" && maxLevel >= theLevel) {
5050
- return theFunc.bind(logger);
5051
- }
5052
- return function() {
5053
- };
4967
+ ], (json) => [json.store_id, json.hashed_key]);
4968
+ var PasskeyAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_NOT_ENABLED", () => [400, "Passkey authentication is not enabled for this project."], () => []);
4969
+ var AnonymousAccountsNotEnabled = createKnownErrorConstructor(KnownError, "ANONYMOUS_ACCOUNTS_NOT_ENABLED", () => [400, "Anonymous accounts are not enabled for this project."], () => []);
4970
+ 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."], () => []);
4971
+ var EmailPasswordMismatch = createKnownErrorConstructor(KnownError, "EMAIL_PASSWORD_MISMATCH", () => [400, "Wrong e-mail or password."], () => []);
4972
+ var RedirectUrlNotWhitelisted = createKnownErrorConstructor(KnownError, "REDIRECT_URL_NOT_WHITELISTED", (redirectUrl) => [
4973
+ 400,
4974
+ "Redirect URL not whitelisted. Did you forget to add this domain to the trusted domains list on the Hexclave dashboard?",
4975
+ redirectUrl === void 0 ? void 0 : { redirect_url: redirectUrl }
4976
+ ], (json) => [json?.redirect_url]);
4977
+ var PasswordRequirementsNotMet = createKnownErrorConstructor(KnownError, "PASSWORD_REQUIREMENTS_NOT_MET", "inherit", "inherit");
4978
+ var PasswordTooShort = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_SHORT", (minLength) => [
4979
+ 400,
4980
+ `Password too short. Minimum length is ${minLength}.`,
4981
+ { min_length: minLength }
4982
+ ], (json) => [json?.min_length ?? throwErr("min_length not found in PasswordTooShort details")]);
4983
+ var PasswordTooLong = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_LONG", (maxLength) => [
4984
+ 400,
4985
+ `Password too long. Maximum length is ${maxLength}.`,
4986
+ { maxLength }
4987
+ ], (json) => [json?.maxLength ?? throwErr("maxLength not found in PasswordTooLong details")]);
4988
+ var UserDoesNotHavePassword = createKnownErrorConstructor(KnownError, "USER_DOES_NOT_HAVE_PASSWORD", () => [400, "This user does not have password authentication enabled."], () => []);
4989
+ var VerificationCodeError = createKnownErrorConstructor(KnownError, "VERIFICATION_ERROR", "inherit", "inherit");
4990
+ var VerificationCodeNotFound = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_NOT_FOUND", () => [404, "The verification code does not exist for this project."], () => []);
4991
+ var VerificationCodeExpired = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_EXPIRED", () => [400, "The verification code has expired."], () => []);
4992
+ var VerificationCodeAlreadyUsed = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_ALREADY_USED", () => [409, "The verification link has already been used."], () => []);
4993
+ 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."], () => []);
4994
+ var PasswordConfirmationMismatch = createKnownErrorConstructor(KnownError, "PASSWORD_CONFIRMATION_MISMATCH", () => [400, "Passwords do not match."], () => []);
4995
+ var EmailAlreadyVerified = createKnownErrorConstructor(KnownError, "EMAIL_ALREADY_VERIFIED", () => [409, "The e-mail is already verified."], () => []);
4996
+ 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."], () => []);
4997
+ var EmailIsNotPrimaryEmail = createKnownErrorConstructor(KnownError, "EMAIL_IS_NOT_PRIMARY_EMAIL", (email, primaryEmail) => [
4998
+ 400,
4999
+ `The given e-mail (${email}) must equal the user's primary e-mail (${primaryEmail}).`,
5000
+ {
5001
+ email,
5002
+ primary_email: primaryEmail
5054
5003
  }
5055
- return {
5056
- error: _filterFunc("error", DiagLogLevel.ERROR),
5057
- warn: _filterFunc("warn", DiagLogLevel.WARN),
5058
- info: _filterFunc("info", DiagLogLevel.INFO),
5059
- debug: _filterFunc("debug", DiagLogLevel.DEBUG),
5060
- verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
5061
- };
5062
- }
5063
-
5064
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/diag.js
5065
- var __read2 = function(o21, n10) {
5066
- var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
5067
- if (!m6) return o21;
5068
- var i = m6.call(o21), r7, ar = [], e40;
5069
- try {
5070
- while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
5071
- } catch (error) {
5072
- e40 = { error };
5073
- } finally {
5074
- try {
5075
- if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
5076
- } finally {
5077
- if (e40) throw e40.error;
5078
- }
5004
+ ], (json) => [json.email, json.primary_email]);
5005
+ var PasskeyRegistrationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_REGISTRATION_FAILED", (message2) => [400, message2], (json) => [json.message]);
5006
+ var PasskeyWebAuthnError = createKnownErrorConstructor(KnownError, "PASSKEY_WEBAUTHN_ERROR", (message2, code) => [
5007
+ 400,
5008
+ message2,
5009
+ {
5010
+ message: message2,
5011
+ code
5079
5012
  }
5080
- return ar;
5081
- };
5082
- var __spreadArray2 = function(to, from, pack) {
5083
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
5084
- if (ar || !(i in from)) {
5085
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5086
- ar[i] = from[i];
5087
- }
5013
+ ], (json) => [json.message, json.code]);
5014
+ var PasskeyAuthenticationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_FAILED", (message2) => [400, message2], (json) => [json.message]);
5015
+ var PermissionNotFound = createKnownErrorConstructor(KnownError, "PERMISSION_NOT_FOUND", (permissionId) => [
5016
+ 404,
5017
+ `Permission "${permissionId}" not found. Make sure you created it on the dashboard.`,
5018
+ { permission_id: permissionId }
5019
+ ], (json) => [json.permission_id]);
5020
+ var PermissionScopeMismatch = createKnownErrorConstructor(KnownError, "WRONG_PERMISSION_SCOPE", (permissionId, expectedScope, actualScope) => [
5021
+ 404,
5022
+ `Permission ${JSON.stringify(permissionId)} not found. (It was found for a different scope ${JSON.stringify(actualScope)}, but scope ${JSON.stringify(expectedScope)} was expected.)`,
5023
+ {
5024
+ permission_id: permissionId,
5025
+ expected_scope: expectedScope,
5026
+ actual_scope: actualScope
5088
5027
  }
5089
- return to.concat(ar || Array.prototype.slice.call(from));
5090
- };
5091
- var API_NAME = "diag";
5092
- var DiagAPI = (
5093
- /** @class */
5094
- function() {
5095
- function DiagAPI2() {
5096
- function _logProxy(funcName) {
5097
- return function() {
5098
- var args = [];
5099
- for (var _i = 0; _i < arguments.length; _i++) {
5100
- args[_i] = arguments[_i];
5101
- }
5102
- var logger = getGlobal("diag");
5103
- if (!logger)
5104
- return;
5105
- return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
5106
- };
5107
- }
5108
- var self2 = this;
5109
- var setLogger = function(logger, optionsOrLogLevel) {
5110
- var _a5, _b, _c;
5111
- if (optionsOrLogLevel === void 0) {
5112
- optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
5113
- }
5114
- if (logger === self2) {
5115
- var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
5116
- self2.error((_a5 = err.stack) !== null && _a5 !== void 0 ? _a5 : err.message);
5117
- return false;
5118
- }
5119
- if (typeof optionsOrLogLevel === "number") {
5120
- optionsOrLogLevel = {
5121
- logLevel: optionsOrLogLevel
5122
- };
5123
- }
5124
- var oldLogger = getGlobal("diag");
5125
- var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
5126
- if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
5127
- var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
5128
- oldLogger.warn("Current logger will be overwritten from " + stack);
5129
- newLogger.warn("Current logger will overwrite one already registered from " + stack);
5130
- }
5131
- return registerGlobal("diag", newLogger, self2, true);
5132
- };
5133
- self2.setLogger = setLogger;
5134
- self2.disable = function() {
5135
- unregisterGlobal(API_NAME, self2);
5136
- };
5137
- self2.createComponentLogger = function(options) {
5138
- return new DiagComponentLogger(options);
5139
- };
5140
- self2.verbose = _logProxy("verbose");
5141
- self2.debug = _logProxy("debug");
5142
- self2.info = _logProxy("info");
5143
- self2.warn = _logProxy("warn");
5144
- self2.error = _logProxy("error");
5145
- }
5146
- DiagAPI2.instance = function() {
5147
- if (!this._instance) {
5148
- this._instance = new DiagAPI2();
5149
- }
5150
- return this._instance;
5151
- };
5152
- return DiagAPI2;
5153
- }()
5154
- );
5155
-
5156
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/context.js
5157
- function createContextKey(description) {
5158
- return Symbol.for(description);
5159
- }
5160
- var BaseContext = (
5161
- /** @class */
5162
- /* @__PURE__ */ function() {
5163
- function BaseContext2(parentContext) {
5164
- var self2 = this;
5165
- self2._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
5166
- self2.getValue = function(key) {
5167
- return self2._currentContext.get(key);
5168
- };
5169
- self2.setValue = function(key, value) {
5170
- var context = new BaseContext2(self2._currentContext);
5171
- context._currentContext.set(key, value);
5172
- return context;
5173
- };
5174
- self2.deleteValue = function(key) {
5175
- var context = new BaseContext2(self2._currentContext);
5176
- context._currentContext.delete(key);
5177
- return context;
5178
- };
5179
- }
5180
- return BaseContext2;
5181
- }()
5182
- );
5183
- var ROOT_CONTEXT = new BaseContext();
5184
-
5185
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js
5186
- var __read3 = function(o21, n10) {
5187
- var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
5188
- if (!m6) return o21;
5189
- var i = m6.call(o21), r7, ar = [], e40;
5190
- try {
5191
- while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
5192
- } catch (error) {
5193
- e40 = { error };
5194
- } finally {
5195
- try {
5196
- if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
5197
- } finally {
5198
- if (e40) throw e40.error;
5199
- }
5028
+ ], (json) => [
5029
+ json.permission_id,
5030
+ json.expected_scope,
5031
+ json.actual_scope
5032
+ ]);
5033
+ var ContainedPermissionNotFound = createKnownErrorConstructor(KnownError, "CONTAINED_PERMISSION_NOT_FOUND", (permissionId) => [
5034
+ 400,
5035
+ `Contained permission with ID "${permissionId}" not found. Make sure you created it on the dashboard.`,
5036
+ { permission_id: permissionId }
5037
+ ], (json) => [json.permission_id]);
5038
+ var TeamNotFound = createKnownErrorConstructor(KnownError, "TEAM_NOT_FOUND", (teamId) => [
5039
+ 404,
5040
+ `Team ${teamId} not found.`,
5041
+ { team_id: teamId }
5042
+ ], (json) => [json.team_id]);
5043
+ createKnownErrorConstructor(KnownError, "TEAM_ALREADY_EXISTS", (teamId) => [
5044
+ 409,
5045
+ `Team ${teamId} already exists.`,
5046
+ { team_id: teamId }
5047
+ ], (json) => [json.team_id]);
5048
+ var TeamMembershipNotFound = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_NOT_FOUND", (teamId, userId) => [
5049
+ 404,
5050
+ `User ${userId} is not found in team ${teamId}.`,
5051
+ {
5052
+ team_id: teamId,
5053
+ user_id: userId
5200
5054
  }
5201
- return ar;
5202
- };
5203
- var __spreadArray3 = function(to, from, pack) {
5204
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
5205
- if (ar || !(i in from)) {
5206
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5207
- ar[i] = from[i];
5208
- }
5055
+ ], (json) => [json.team_id, json.user_id]);
5056
+ var TeamInvitationRestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "TEAM_INVITATION_RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
5057
+ 403,
5058
+ `Restricted users cannot accept team invitations. Reason: ${restrictedReason.type}. Please complete the onboarding process before accepting team invitations.`,
5059
+ { restricted_reason: restrictedReason }
5060
+ ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
5061
+ 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."], () => []);
5062
+ var EmailTemplateAlreadyExists = createKnownErrorConstructor(KnownError, "EMAIL_TEMPLATE_ALREADY_EXISTS", () => [409, "Email template already exists."], () => []);
5063
+ var OAuthConnectionNotConnectedToUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_NOT_CONNECTED_TO_USER", () => [400, "The OAuth connection is not connected to any user."], () => []);
5064
+ var OAuthConnectionAlreadyConnectedToAnotherUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_ALREADY_CONNECTED_TO_ANOTHER_USER", () => [409, "The OAuth connection is already connected to another user."], () => []);
5065
+ var OAuthConnectionDoesNotHaveRequiredScope = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_DOES_NOT_HAVE_REQUIRED_SCOPE", () => [400, "The OAuth connection does not have the required scope."], () => []);
5066
+ var OAuthAccessTokenNotAvailable = createKnownErrorConstructor(KnownError, "OAUTH_ACCESS_TOKEN_NOT_AVAILABLE", (provider, details) => [
5067
+ 400,
5068
+ `Failed to retrieve an OAuth access token for the connected account (provider: ${provider}). ${details}`,
5069
+ {
5070
+ provider,
5071
+ details
5209
5072
  }
5210
- return to.concat(ar || Array.prototype.slice.call(from));
5211
- };
5212
- var NoopContextManager = (
5213
- /** @class */
5214
- function() {
5215
- function NoopContextManager2() {
5216
- }
5217
- NoopContextManager2.prototype.active = function() {
5218
- return ROOT_CONTEXT;
5219
- };
5220
- NoopContextManager2.prototype.with = function(_context, fn, thisArg) {
5221
- var args = [];
5222
- for (var _i = 3; _i < arguments.length; _i++) {
5223
- args[_i - 3] = arguments[_i];
5224
- }
5225
- return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
5226
- };
5227
- NoopContextManager2.prototype.bind = function(_context, target) {
5228
- return target;
5229
- };
5230
- NoopContextManager2.prototype.enable = function() {
5231
- return this;
5232
- };
5233
- NoopContextManager2.prototype.disable = function() {
5234
- return this;
5235
- };
5236
- return NoopContextManager2;
5237
- }()
5238
- );
5239
-
5240
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/context.js
5241
- var __read4 = function(o21, n10) {
5242
- var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
5243
- if (!m6) return o21;
5244
- var i = m6.call(o21), r7, ar = [], e40;
5245
- try {
5246
- while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
5247
- } catch (error) {
5248
- e40 = { error };
5249
- } finally {
5250
- try {
5251
- if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
5252
- } finally {
5253
- if (e40) throw e40.error;
5254
- }
5073
+ ], (json) => [json.provider, json.details]);
5074
+ 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."], () => []);
5075
+ 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."], () => []);
5076
+ var InvalidOAuthClientIdOrSecret = createKnownErrorConstructor(KnownError, "INVALID_OAUTH_CLIENT_ID_OR_SECRET", (clientId) => [
5077
+ 400,
5078
+ "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.",
5079
+ { client_id: clientId ?? null }
5080
+ ], (json) => [json.client_id ?? void 0]);
5081
+ var InvalidScope = createKnownErrorConstructor(KnownError, "INVALID_SCOPE", (scope) => [400, `The scope "${scope}" is not a valid OAuth scope for Stack.`], (json) => [json.scope]);
5082
+ 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?"], () => []);
5083
+ var OuterOAuthTimeout = createKnownErrorConstructor(KnownError, "OUTER_OAUTH_TIMEOUT", () => [408, "The OAuth flow has timed out. Please sign in again."], () => []);
5084
+ var OAuthProviderNotFoundOrNotEnabled = createKnownErrorConstructor(KnownError, "OAUTH_PROVIDER_NOT_FOUND_OR_NOT_ENABLED", () => [400, "The OAuth provider is not found or not enabled."], () => []);
5085
+ 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."], () => []);
5086
+ 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.`], () => []);
5087
+ var MultiFactorAuthenticationRequired = createKnownErrorConstructor(KnownError, "MULTI_FACTOR_AUTHENTICATION_REQUIRED", (attemptCode) => [
5088
+ 400,
5089
+ `Multi-factor authentication is required for this user.`,
5090
+ { attempt_code: attemptCode }
5091
+ ], (json) => [json.attempt_code]);
5092
+ var InvalidTotpCode = createKnownErrorConstructor(KnownError, "INVALID_TOTP_CODE", () => [400, "The TOTP code is invalid. Please try again."], () => []);
5093
+ var UserAuthenticationRequired = createKnownErrorConstructor(KnownError, "USER_AUTHENTICATION_REQUIRED", () => [401, "User authentication required for this endpoint."], () => []);
5094
+ var TeamMembershipAlreadyExists = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_ALREADY_EXISTS", () => [409, "Team membership already exists."], () => []);
5095
+ var ProjectPermissionRequired = createKnownErrorConstructor(KnownError, "PROJECT_PERMISSION_REQUIRED", (userId, permissionId) => [
5096
+ 401,
5097
+ `User ${userId} does not have permission ${permissionId}.`,
5098
+ {
5099
+ user_id: userId,
5100
+ permission_id: permissionId
5255
5101
  }
5256
- return ar;
5257
- };
5258
- var __spreadArray4 = function(to, from, pack) {
5259
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
5260
- if (ar || !(i in from)) {
5261
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5262
- ar[i] = from[i];
5263
- }
5264
- }
5265
- return to.concat(ar || Array.prototype.slice.call(from));
5266
- };
5267
- var API_NAME2 = "context";
5268
- var NOOP_CONTEXT_MANAGER = new NoopContextManager();
5269
- var ContextAPI = (
5270
- /** @class */
5271
- function() {
5272
- function ContextAPI2() {
5273
- }
5274
- ContextAPI2.getInstance = function() {
5275
- if (!this._instance) {
5276
- this._instance = new ContextAPI2();
5277
- }
5278
- return this._instance;
5279
- };
5280
- ContextAPI2.prototype.setGlobalContextManager = function(contextManager) {
5281
- return registerGlobal(API_NAME2, contextManager, DiagAPI.instance());
5282
- };
5283
- ContextAPI2.prototype.active = function() {
5284
- return this._getContextManager().active();
5285
- };
5286
- ContextAPI2.prototype.with = function(context, fn, thisArg) {
5287
- var _a5;
5288
- var args = [];
5289
- for (var _i = 3; _i < arguments.length; _i++) {
5290
- args[_i - 3] = arguments[_i];
5291
- }
5292
- return (_a5 = this._getContextManager()).with.apply(_a5, __spreadArray4([context, fn, thisArg], __read4(args), false));
5293
- };
5294
- ContextAPI2.prototype.bind = function(context, target) {
5295
- return this._getContextManager().bind(context, target);
5296
- };
5297
- ContextAPI2.prototype._getContextManager = function() {
5298
- return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
5299
- };
5300
- ContextAPI2.prototype.disable = function() {
5301
- this._getContextManager().disable();
5302
- unregisterGlobal(API_NAME2, DiagAPI.instance());
5303
- };
5304
- return ContextAPI2;
5305
- }()
5306
- );
5307
-
5308
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js
5309
- var TraceFlags;
5310
- (function(TraceFlags2) {
5311
- TraceFlags2[TraceFlags2["NONE"] = 0] = "NONE";
5312
- TraceFlags2[TraceFlags2["SAMPLED"] = 1] = "SAMPLED";
5313
- })(TraceFlags || (TraceFlags = {}));
5314
-
5315
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js
5316
- var INVALID_SPANID = "0000000000000000";
5317
- var INVALID_TRACEID = "00000000000000000000000000000000";
5318
- var INVALID_SPAN_CONTEXT = {
5319
- traceId: INVALID_TRACEID,
5320
- spanId: INVALID_SPANID,
5321
- traceFlags: TraceFlags.NONE
5322
- };
5323
-
5324
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js
5325
- var NonRecordingSpan = (
5326
- /** @class */
5327
- function() {
5328
- function NonRecordingSpan2(_spanContext) {
5329
- if (_spanContext === void 0) {
5330
- _spanContext = INVALID_SPAN_CONTEXT;
5331
- }
5332
- this._spanContext = _spanContext;
5333
- }
5334
- NonRecordingSpan2.prototype.spanContext = function() {
5335
- return this._spanContext;
5336
- };
5337
- NonRecordingSpan2.prototype.setAttribute = function(_key, _value) {
5338
- return this;
5339
- };
5340
- NonRecordingSpan2.prototype.setAttributes = function(_attributes) {
5341
- return this;
5342
- };
5343
- NonRecordingSpan2.prototype.addEvent = function(_name, _attributes) {
5344
- return this;
5345
- };
5346
- NonRecordingSpan2.prototype.addLink = function(_link) {
5347
- return this;
5348
- };
5349
- NonRecordingSpan2.prototype.addLinks = function(_links) {
5350
- return this;
5351
- };
5352
- NonRecordingSpan2.prototype.setStatus = function(_status) {
5353
- return this;
5354
- };
5355
- NonRecordingSpan2.prototype.updateName = function(_name) {
5356
- return this;
5357
- };
5358
- NonRecordingSpan2.prototype.end = function(_endTime) {
5359
- };
5360
- NonRecordingSpan2.prototype.isRecording = function() {
5361
- return false;
5362
- };
5363
- NonRecordingSpan2.prototype.recordException = function(_exception, _time) {
5364
- };
5365
- return NonRecordingSpan2;
5366
- }()
5367
- );
5368
-
5369
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js
5370
- var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
5371
- function getSpan(context) {
5372
- return context.getValue(SPAN_KEY) || void 0;
5373
- }
5374
- function getActiveSpan() {
5375
- return getSpan(ContextAPI.getInstance().active());
5376
- }
5377
- function setSpan(context, span) {
5378
- return context.setValue(SPAN_KEY, span);
5379
- }
5380
- function deleteSpan(context) {
5381
- return context.deleteValue(SPAN_KEY);
5382
- }
5383
- function setSpanContext(context, spanContext) {
5384
- return setSpan(context, new NonRecordingSpan(spanContext));
5385
- }
5386
- function getSpanContext(context) {
5387
- var _a5;
5388
- return (_a5 = getSpan(context)) === null || _a5 === void 0 ? void 0 : _a5.spanContext();
5389
- }
5390
-
5391
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
5392
- var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
5393
- var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
5394
- function isValidTraceId(traceId) {
5395
- return VALID_TRACEID_REGEX.test(traceId) && traceId !== INVALID_TRACEID;
5396
- }
5397
- function isValidSpanId(spanId) {
5398
- return VALID_SPANID_REGEX.test(spanId) && spanId !== INVALID_SPANID;
5399
- }
5400
- function isSpanContextValid(spanContext) {
5401
- return isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);
5402
- }
5403
- function wrapSpanContext(spanContext) {
5404
- return new NonRecordingSpan(spanContext);
5405
- }
5406
-
5407
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js
5408
- var contextApi = ContextAPI.getInstance();
5409
- var NoopTracer = (
5410
- /** @class */
5411
- function() {
5412
- function NoopTracer2() {
5413
- }
5414
- NoopTracer2.prototype.startSpan = function(name, options, context) {
5415
- if (context === void 0) {
5416
- context = contextApi.active();
5417
- }
5418
- var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
5419
- if (root) {
5420
- return new NonRecordingSpan();
5421
- }
5422
- var parentFromContext = context && getSpanContext(context);
5423
- if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
5424
- return new NonRecordingSpan(parentFromContext);
5425
- } else {
5426
- return new NonRecordingSpan();
5427
- }
5428
- };
5429
- NoopTracer2.prototype.startActiveSpan = function(name, arg2, arg3, arg4) {
5430
- var opts;
5431
- var ctx;
5432
- var fn;
5433
- if (arguments.length < 2) {
5434
- return;
5435
- } else if (arguments.length === 2) {
5436
- fn = arg2;
5437
- } else if (arguments.length === 3) {
5438
- opts = arg2;
5439
- fn = arg3;
5440
- } else {
5441
- opts = arg2;
5442
- ctx = arg3;
5443
- fn = arg4;
5444
- }
5445
- var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
5446
- var span = this.startSpan(name, opts, parentContext);
5447
- var contextWithSpanSet = setSpan(parentContext, span);
5448
- return contextApi.with(contextWithSpanSet, fn, void 0, span);
5449
- };
5450
- return NoopTracer2;
5451
- }()
5452
- );
5453
- function isSpanContext(spanContext) {
5454
- return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
5455
- }
5456
-
5457
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js
5458
- var NOOP_TRACER = new NoopTracer();
5459
- var ProxyTracer = (
5460
- /** @class */
5461
- function() {
5462
- function ProxyTracer2(_provider, name, version, options) {
5463
- this._provider = _provider;
5464
- this.name = name;
5465
- this.version = version;
5466
- this.options = options;
5467
- }
5468
- ProxyTracer2.prototype.startSpan = function(name, options, context) {
5469
- return this._getTracer().startSpan(name, options, context);
5470
- };
5471
- ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
5472
- var tracer2 = this._getTracer();
5473
- return Reflect.apply(tracer2.startActiveSpan, tracer2, arguments);
5474
- };
5475
- ProxyTracer2.prototype._getTracer = function() {
5476
- if (this._delegate) {
5477
- return this._delegate;
5478
- }
5479
- var tracer2 = this._provider.getDelegateTracer(this.name, this.version, this.options);
5480
- if (!tracer2) {
5481
- return NOOP_TRACER;
5482
- }
5483
- this._delegate = tracer2;
5484
- return this._delegate;
5485
- };
5486
- return ProxyTracer2;
5487
- }()
5488
- );
5489
-
5490
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js
5491
- var NoopTracerProvider = (
5492
- /** @class */
5493
- function() {
5494
- function NoopTracerProvider2() {
5495
- }
5496
- NoopTracerProvider2.prototype.getTracer = function(_name, _version, _options) {
5497
- return new NoopTracer();
5498
- };
5499
- return NoopTracerProvider2;
5500
- }()
5501
- );
5502
-
5503
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js
5504
- var NOOP_TRACER_PROVIDER = new NoopTracerProvider();
5505
- var ProxyTracerProvider = (
5506
- /** @class */
5507
- function() {
5508
- function ProxyTracerProvider2() {
5509
- }
5510
- ProxyTracerProvider2.prototype.getTracer = function(name, version, options) {
5511
- var _a5;
5512
- return (_a5 = this.getDelegateTracer(name, version, options)) !== null && _a5 !== void 0 ? _a5 : new ProxyTracer(this, name, version, options);
5513
- };
5514
- ProxyTracerProvider2.prototype.getDelegate = function() {
5515
- var _a5;
5516
- return (_a5 = this._delegate) !== null && _a5 !== void 0 ? _a5 : NOOP_TRACER_PROVIDER;
5517
- };
5518
- ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
5519
- this._delegate = delegate;
5520
- };
5521
- ProxyTracerProvider2.prototype.getDelegateTracer = function(name, version, options) {
5522
- var _a5;
5523
- return (_a5 = this._delegate) === null || _a5 === void 0 ? void 0 : _a5.getTracer(name, version, options);
5524
- };
5525
- return ProxyTracerProvider2;
5526
- }()
5527
- );
5528
-
5529
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/trace.js
5530
- var API_NAME3 = "trace";
5531
- var TraceAPI = (
5532
- /** @class */
5533
- function() {
5534
- function TraceAPI2() {
5535
- this._proxyTracerProvider = new ProxyTracerProvider();
5536
- this.wrapSpanContext = wrapSpanContext;
5537
- this.isSpanContextValid = isSpanContextValid;
5538
- this.deleteSpan = deleteSpan;
5539
- this.getSpan = getSpan;
5540
- this.getActiveSpan = getActiveSpan;
5541
- this.getSpanContext = getSpanContext;
5542
- this.setSpan = setSpan;
5543
- this.setSpanContext = setSpanContext;
5544
- }
5545
- TraceAPI2.getInstance = function() {
5546
- if (!this._instance) {
5547
- this._instance = new TraceAPI2();
5548
- }
5549
- return this._instance;
5550
- };
5551
- TraceAPI2.prototype.setGlobalTracerProvider = function(provider) {
5552
- var success = registerGlobal(API_NAME3, this._proxyTracerProvider, DiagAPI.instance());
5553
- if (success) {
5554
- this._proxyTracerProvider.setDelegate(provider);
5555
- }
5556
- return success;
5557
- };
5558
- TraceAPI2.prototype.getTracerProvider = function() {
5559
- return getGlobal(API_NAME3) || this._proxyTracerProvider;
5560
- };
5561
- TraceAPI2.prototype.getTracer = function(name, version) {
5562
- return this.getTracerProvider().getTracer(name, version);
5563
- };
5564
- TraceAPI2.prototype.disable = function() {
5565
- unregisterGlobal(API_NAME3, DiagAPI.instance());
5566
- this._proxyTracerProvider = new ProxyTracerProvider();
5567
- };
5568
- return TraceAPI2;
5569
- }()
5570
- );
5571
-
5572
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace-api.js
5573
- var trace = TraceAPI.getInstance();
5574
-
5575
- // ../shared/dist/esm/utils/telemetry.js
5576
- var tracer = trace.getTracer("stack-tracer");
5577
- async function traceSpan(optionsOrDescription, fn) {
5578
- let options = typeof optionsOrDescription === "string" ? { description: optionsOrDescription } : optionsOrDescription;
5579
- return await tracer.startActiveSpan(`STACK: ${options.description}`, async (span) => {
5580
- if (options.attributes) for (const [key, value] of Object.entries(options.attributes)) span.setAttribute(key, value);
5581
- try {
5582
- return await fn(span);
5583
- } finally {
5584
- span.end();
5585
- }
5586
- });
5587
- }
5588
-
5589
- // ../shared/dist/esm/known-errors.js
5590
- var KnownError = class extends StatusError {
5591
- constructor(statusCode, humanReadableMessage, details) {
5592
- super(statusCode, humanReadableMessage);
5593
- this.statusCode = statusCode;
5594
- this.humanReadableMessage = humanReadableMessage;
5595
- this.details = details;
5596
- this.__stackKnownErrorBrand = "stack-known-error-brand-sentinel";
5597
- this.name = "KnownError";
5598
- }
5599
- static isKnownError(error) {
5600
- return typeof error === "object" && error !== null && "__stackKnownErrorBrand" in error && error.__stackKnownErrorBrand === "stack-known-error-brand-sentinel";
5601
- }
5602
- getBody() {
5603
- return new TextEncoder().encode(JSON.stringify(this.toDescriptiveJson(), void 0, 2));
5604
- }
5605
- getHeaders() {
5606
- return {
5607
- "Content-Type": ["application/json; charset=utf-8"],
5608
- "X-Stack-Known-Error": [this.errorCode],
5609
- "X-Hexclave-Known-Error": [this.errorCode]
5610
- };
5611
- }
5612
- toDescriptiveJson() {
5613
- return {
5614
- code: this.errorCode,
5615
- ...this.details ? { details: this.details } : {},
5616
- error: this.humanReadableMessage
5617
- };
5618
- }
5619
- get errorCode() {
5620
- return this.constructor.errorCode ?? throwErr(`Can't find error code for this KnownError. Is its constructor a KnownErrorConstructor? ${this}`);
5621
- }
5622
- static constructorArgsFromJson(json) {
5623
- return [
5624
- 400,
5625
- json.message,
5626
- json
5627
- ];
5628
- }
5629
- static fromJson(json) {
5630
- for (const [_, KnownErrorType] of Object.entries(KnownErrors)) if (json.code === KnownErrorType.prototype.errorCode) return new KnownErrorType(...KnownErrorType.constructorArgsFromJson(json));
5631
- throw new Error(`An error occurred. Please update your version of the Hexclave SDK. ${json.code}: ${json.message}`);
5632
- }
5633
- };
5634
- function createKnownErrorConstructor(SuperClass, errorCode, create, constructorArgsFromJson) {
5635
- const createFn = create === "inherit" ? identityArgs : create;
5636
- const constructorArgsFromJsonFn = constructorArgsFromJson === "inherit" ? SuperClass.constructorArgsFromJson : constructorArgsFromJson;
5637
- const _KnownErrorImpl = class _KnownErrorImpl extends SuperClass {
5638
- constructor(...args) {
5639
- super(...createFn(...args));
5640
- this.name = `KnownError<${errorCode}>`;
5641
- this.constructorArgs = args;
5642
- }
5643
- static constructorArgsFromJson(json) {
5644
- return constructorArgsFromJsonFn(json.details);
5645
- }
5646
- static isInstance(error) {
5647
- if (!KnownError.isKnownError(error)) return false;
5648
- let current = error;
5649
- while (true) {
5650
- current = Object.getPrototypeOf(current);
5651
- if (!current) break;
5652
- if ("errorCode" in current.constructor && current.constructor.errorCode === errorCode) return true;
5653
- }
5654
- return false;
5655
- }
5656
- };
5657
- _KnownErrorImpl.errorCode = errorCode;
5658
- let KnownErrorImpl = _KnownErrorImpl;
5659
- return KnownErrorImpl;
5660
- }
5661
- var UnsupportedError = createKnownErrorConstructor(KnownError, "UNSUPPORTED_ERROR", (originalErrorCode) => [
5662
- 500,
5663
- `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}`,
5664
- { originalErrorCode }
5665
- ], (json) => [json?.originalErrorCode ?? throwErr("originalErrorCode not found in UnsupportedError details")]);
5666
- var BodyParsingError = createKnownErrorConstructor(KnownError, "BODY_PARSING_ERROR", (message2) => [400, message2], (json) => [json.message]);
5667
- var SchemaError = createKnownErrorConstructor(KnownError, "SCHEMA_ERROR", (message2) => [
5668
- 400,
5669
- message2 || throwErr("SchemaError requires a message"),
5670
- { message: message2 }
5671
- ], (json) => [json.message]);
5672
- var AllOverloadsFailed = createKnownErrorConstructor(KnownError, "ALL_OVERLOADS_FAILED", (overloadErrors) => [
5673
- 400,
5674
- deindent`
5675
- This endpoint has multiple overloads, but they all failed to process the request.
5676
-
5677
- ${overloadErrors.map((e40, i) => deindent`
5678
- Overload ${i + 1}: ${JSON.stringify(e40, void 0, 2)}
5679
- `).join("\n\n")}
5680
- `,
5681
- { overload_errors: overloadErrors }
5682
- ], (json) => [json?.overload_errors ?? throwErr("overload_errors not found in AllOverloadsFailed details")]);
5683
- var ProjectAuthenticationError = createKnownErrorConstructor(KnownError, "PROJECT_AUTHENTICATION_ERROR", "inherit", "inherit");
5684
- var InvalidProjectAuthentication = createKnownErrorConstructor(ProjectAuthenticationError, "INVALID_PROJECT_AUTHENTICATION", "inherit", "inherit");
5685
- 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.)"], () => []);
5686
- 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")]);
5687
- var AccessTypeWithoutProjectId = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_WITHOUT_PROJECT_ID", (accessType) => [
5688
- 400,
5689
- deindent`
5690
- 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.)
5691
-
5692
- For more information, see the docs on REST API authentication: https://docs.hexclave.com/api/overview#authentication
5693
- `,
5694
- { request_type: accessType }
5695
- ], (json) => [json.request_type]);
5696
- var AccessTypeRequired = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_REQUIRED", () => [400, deindent`
5697
- 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.)
5698
-
5699
- For more information, see the docs on REST API authentication: https://docs.hexclave.com/api/overview#authentication
5700
- `], () => []);
5701
- var InsufficientAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "INSUFFICIENT_ACCESS_TYPE", (actualAccessType, allowedAccessTypes) => [
5702
- 401,
5703
- `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.)`,
5704
- {
5705
- actual_access_type: actualAccessType,
5706
- allowed_access_types: allowedAccessTypes
5707
- }
5708
- ], (json) => [json.actual_access_type, json.allowed_access_types]);
5709
- var InvalidPublishableClientKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_PUBLISHABLE_CLIENT_KEY", (projectId) => [
5710
- 401,
5711
- `The publishable key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
5712
- { project_id: projectId }
5713
- ], (json) => [json.project_id]);
5714
- var InvalidSecretServerKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SECRET_SERVER_KEY", (projectId) => [
5715
- 401,
5716
- `The secret server key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
5717
- { project_id: projectId }
5718
- ], (json) => [json.project_id]);
5719
- var InvalidSuperSecretAdminKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SUPER_SECRET_ADMIN_KEY", (projectId) => [
5720
- 401,
5721
- `The super secret admin key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
5722
- { project_id: projectId }
5723
- ], (json) => [json.project_id]);
5724
- var InvalidAdminAccessToken = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_ADMIN_ACCESS_TOKEN", "inherit", "inherit");
5725
- var UnparsableAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "UNPARSABLE_ADMIN_ACCESS_TOKEN", () => [401, "Admin access token is not parsable."], () => []);
5726
- var AdminAccessTokenExpired = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_EXPIRED", (expiredAt) => [
5727
- 401,
5728
- `Admin access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)` : ""}`,
5729
- { expired_at_millis: expiredAt?.getTime() ?? null }
5730
- ], (json) => [json.expired_at_millis ? new Date(json.expired_at_millis) : void 0]);
5731
- var InvalidProjectForAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "INVALID_PROJECT_FOR_ADMIN_ACCESS_TOKEN", () => [401, "Admin access tokens must be created on the internal project."], () => []);
5732
- var AdminAccessTokenIsNotAdmin = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_IS_NOT_ADMIN", () => [401, "Admin access token does not have the required permissions to access this project."], () => []);
5733
- var ProjectAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationError, "PROJECT_AUTHENTICATION_REQUIRED", "inherit", "inherit");
5734
- var ClientAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_AUTHENTICATION_REQUIRED", () => [401, "The publishable client key must be provided."], () => []);
5735
- var PublishableClientKeyRequiredForProject = createKnownErrorConstructor(ProjectAuthenticationRequired, "PUBLISHABLE_CLIENT_KEY_REQUIRED_FOR_PROJECT", (projectId) => [
5736
- 401,
5737
- "Publishable client keys are required for this project. Create one in Project Keys, or disable this requirement there to allow keyless client access.",
5738
- { project_id: projectId ?? null }
5739
- ], (json) => [json.project_id ?? void 0]);
5740
- var ServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "SERVER_AUTHENTICATION_REQUIRED", () => [401, "The secret server key must be provided."], () => []);
5741
- var ClientOrServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_SERVER_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the secret server key must be provided."], () => []);
5742
- var ClientOrAdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_ADMIN_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the super secret admin key must be provided."], () => []);
5743
- 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."], () => []);
5744
- var AdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "ADMIN_AUTHENTICATION_REQUIRED", () => [401, "The super secret admin key must be provided."], () => []);
5745
- var ExpectedInternalProject = createKnownErrorConstructor(ProjectAuthenticationError, "EXPECTED_INTERNAL_PROJECT", () => [401, "The project ID is expected to be internal."], () => []);
5746
- var SessionAuthenticationError = createKnownErrorConstructor(KnownError, "SESSION_AUTHENTICATION_ERROR", "inherit", "inherit");
5747
- var InvalidSessionAuthentication = createKnownErrorConstructor(SessionAuthenticationError, "INVALID_SESSION_AUTHENTICATION", "inherit", "inherit");
5748
- var InvalidAccessToken = createKnownErrorConstructor(InvalidSessionAuthentication, "INVALID_ACCESS_TOKEN", "inherit", "inherit");
5749
- var UnparsableAccessToken = createKnownErrorConstructor(InvalidAccessToken, "UNPARSABLE_ACCESS_TOKEN", () => [401, "Access token is not parsable."], () => []);
5750
- var AccessTokenExpired = createKnownErrorConstructor(InvalidAccessToken, "ACCESS_TOKEN_EXPIRED", (expiredAt, projectId, userId, refreshTokenId) => [
5751
- 401,
5752
- deindent`
5753
- 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}.` : ""}
5754
-
5755
- 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.
5756
- `,
5757
- {
5758
- expired_at_millis: expiredAt?.getTime() ?? null,
5759
- project_id: projectId ?? null,
5760
- user_id: userId ?? null,
5761
- refresh_token_id: refreshTokenId ?? null
5762
- }
5763
- ], (json) => [
5764
- json.expired_at_millis ? new Date(json.expired_at_millis) : void 0,
5765
- json.project_id ?? void 0,
5766
- json.user_id ?? void 0,
5767
- json.refresh_token_id ?? void 0
5768
- ]);
5769
- var InvalidProjectForAccessToken = createKnownErrorConstructor(InvalidAccessToken, "INVALID_PROJECT_FOR_ACCESS_TOKEN", (expectedProjectId, actualProjectId) => [
5770
- 401,
5771
- `Access token not valid for this project. Expected project ID ${JSON.stringify(expectedProjectId)}, but the token is for project ID ${JSON.stringify(actualProjectId)}.`,
5772
- {
5773
- expected_project_id: expectedProjectId,
5774
- actual_project_id: actualProjectId
5775
- }
5776
- ], (json) => [json.expected_project_id, json.actual_project_id]);
5777
- var RefreshTokenError = createKnownErrorConstructor(KnownError, "REFRESH_TOKEN_ERROR", "inherit", "inherit");
5778
- 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."], () => []);
5779
- var CannotDeleteCurrentSession = createKnownErrorConstructor(RefreshTokenError, "CANNOT_DELETE_CURRENT_SESSION", () => [400, "Cannot delete the current session."], () => []);
5780
- 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."], () => []);
5781
- var UserWithEmailAlreadyExists = createKnownErrorConstructor(KnownError, "USER_EMAIL_ALREADY_EXISTS", (email, wouldWorkIfEmailWasVerified = false) => [
5782
- 409,
5783
- `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." : "."}`,
5784
- {
5785
- email,
5786
- would_work_if_email_was_verified: wouldWorkIfEmailWasVerified
5787
- }
5788
- ], (json) => [json.email, json.would_work_if_email_was_verified ?? false]);
5789
- var EmailNotVerified = createKnownErrorConstructor(KnownError, "EMAIL_NOT_VERIFIED", () => [400, "The email is not verified."], () => []);
5790
- 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."], () => []);
5791
- var UserIdDoesNotExist = createKnownErrorConstructor(KnownError, "USER_ID_DOES_NOT_EXIST", (userId) => [
5792
- 400,
5793
- `The given user with the ID ${userId} does not exist.`,
5794
- { user_id: userId }
5795
- ], (json) => [json.user_id]);
5796
- var UserNotFound = createKnownErrorConstructor(KnownError, "USER_NOT_FOUND", () => [404, "User not found."], () => []);
5797
- var RestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
5798
- 403,
5799
- `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.`,
5800
- { restricted_reason: restrictedReason }
5801
- ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
5802
- var ProjectNotFound = createKnownErrorConstructor(KnownError, "PROJECT_NOT_FOUND", (projectId) => {
5803
- if (typeof projectId !== "string") throw new HexclaveAssertionError("projectId of KnownErrors.ProjectNotFound must be a string");
5804
- return [
5805
- 404,
5806
- `Project ${projectId} not found or is not accessible with the current user.`,
5807
- { project_id: projectId }
5808
- ];
5809
- }, (json) => [json.project_id]);
5810
- var CurrentProjectNotFound = createKnownErrorConstructor(KnownError, "CURRENT_PROJECT_NOT_FOUND", (projectId) => [
5811
- 400,
5812
- `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.)`,
5813
- { project_id: projectId }
5814
- ], (json) => [json.project_id]);
5815
- var BranchDoesNotExist = createKnownErrorConstructor(KnownError, "BRANCH_DOES_NOT_EXIST", (branchId) => [
5816
- 400,
5817
- `The branch with ID ${branchId} does not exist.`,
5818
- { branch_id: branchId }
5819
- ], (json) => [json.branch_id]);
5820
- 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."], () => []);
5821
- var SignUpRejected = createKnownErrorConstructor(KnownError, "SIGN_UP_REJECTED", (message2) => [
5822
- 403,
5823
- message2 ?? "Your sign up was rejected by an administrator's sign-up rule.",
5824
- { message: message2 ?? "Your sign up was rejected by an administrator's sign-up rule." }
5825
- ], (json) => [json.message]);
5826
- var BotChallengeRequired = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_REQUIRED", () => [409, "An additional bot challenge is required before sign-up can continue."], () => []);
5827
- var BotChallengeFailed = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_FAILED", (message2) => [
5828
- 400,
5829
- message2,
5830
- { message: message2 }
5831
- ], (json) => [json.message]);
5832
- var PasswordAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSWORD_AUTHENTICATION_NOT_ENABLED", () => [400, "Password authentication is not enabled for this project."], () => []);
5833
- var DataVaultStoreDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_DOES_NOT_EXIST", (storeId) => [
5834
- 400,
5835
- `Data vault store with ID ${storeId} does not exist.`,
5836
- { store_id: storeId }
5837
- ], (json) => [json.store_id]);
5838
- var DataVaultStoreHashedKeyDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_HASHED_KEY_DOES_NOT_EXIST", (storeId, hashedKey) => [
5839
- 400,
5840
- `Data vault store with ID ${storeId} does not contain a key with hash ${hashedKey}.`,
5841
- {
5842
- store_id: storeId,
5843
- hashed_key: hashedKey
5844
- }
5845
- ], (json) => [json.store_id, json.hashed_key]);
5846
- var PasskeyAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_NOT_ENABLED", () => [400, "Passkey authentication is not enabled for this project."], () => []);
5847
- var AnonymousAccountsNotEnabled = createKnownErrorConstructor(KnownError, "ANONYMOUS_ACCOUNTS_NOT_ENABLED", () => [400, "Anonymous accounts are not enabled for this project."], () => []);
5848
- 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."], () => []);
5849
- var EmailPasswordMismatch = createKnownErrorConstructor(KnownError, "EMAIL_PASSWORD_MISMATCH", () => [400, "Wrong e-mail or password."], () => []);
5850
- var RedirectUrlNotWhitelisted = createKnownErrorConstructor(KnownError, "REDIRECT_URL_NOT_WHITELISTED", (redirectUrl) => [
5851
- 400,
5852
- "Redirect URL not whitelisted. Did you forget to add this domain to the trusted domains list on the Hexclave dashboard?",
5853
- redirectUrl === void 0 ? void 0 : { redirect_url: redirectUrl }
5854
- ], (json) => [json?.redirect_url]);
5855
- var PasswordRequirementsNotMet = createKnownErrorConstructor(KnownError, "PASSWORD_REQUIREMENTS_NOT_MET", "inherit", "inherit");
5856
- var PasswordTooShort = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_SHORT", (minLength) => [
5857
- 400,
5858
- `Password too short. Minimum length is ${minLength}.`,
5859
- { min_length: minLength }
5860
- ], (json) => [json?.min_length ?? throwErr("min_length not found in PasswordTooShort details")]);
5861
- var PasswordTooLong = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_LONG", (maxLength) => [
5862
- 400,
5863
- `Password too long. Maximum length is ${maxLength}.`,
5864
- { maxLength }
5865
- ], (json) => [json?.maxLength ?? throwErr("maxLength not found in PasswordTooLong details")]);
5866
- var UserDoesNotHavePassword = createKnownErrorConstructor(KnownError, "USER_DOES_NOT_HAVE_PASSWORD", () => [400, "This user does not have password authentication enabled."], () => []);
5867
- var VerificationCodeError = createKnownErrorConstructor(KnownError, "VERIFICATION_ERROR", "inherit", "inherit");
5868
- var VerificationCodeNotFound = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_NOT_FOUND", () => [404, "The verification code does not exist for this project."], () => []);
5869
- var VerificationCodeExpired = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_EXPIRED", () => [400, "The verification code has expired."], () => []);
5870
- var VerificationCodeAlreadyUsed = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_ALREADY_USED", () => [409, "The verification link has already been used."], () => []);
5871
- 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."], () => []);
5872
- var PasswordConfirmationMismatch = createKnownErrorConstructor(KnownError, "PASSWORD_CONFIRMATION_MISMATCH", () => [400, "Passwords do not match."], () => []);
5873
- var EmailAlreadyVerified = createKnownErrorConstructor(KnownError, "EMAIL_ALREADY_VERIFIED", () => [409, "The e-mail is already verified."], () => []);
5874
- 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."], () => []);
5875
- var EmailIsNotPrimaryEmail = createKnownErrorConstructor(KnownError, "EMAIL_IS_NOT_PRIMARY_EMAIL", (email, primaryEmail) => [
5876
- 400,
5877
- `The given e-mail (${email}) must equal the user's primary e-mail (${primaryEmail}).`,
5878
- {
5879
- email,
5880
- primary_email: primaryEmail
5881
- }
5882
- ], (json) => [json.email, json.primary_email]);
5883
- var PasskeyRegistrationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_REGISTRATION_FAILED", (message2) => [400, message2], (json) => [json.message]);
5884
- var PasskeyWebAuthnError = createKnownErrorConstructor(KnownError, "PASSKEY_WEBAUTHN_ERROR", (message2, code) => [
5885
- 400,
5886
- message2,
5887
- {
5888
- message: message2,
5889
- code
5890
- }
5891
- ], (json) => [json.message, json.code]);
5892
- var PasskeyAuthenticationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_FAILED", (message2) => [400, message2], (json) => [json.message]);
5893
- var PermissionNotFound = createKnownErrorConstructor(KnownError, "PERMISSION_NOT_FOUND", (permissionId) => [
5894
- 404,
5895
- `Permission "${permissionId}" not found. Make sure you created it on the dashboard.`,
5896
- { permission_id: permissionId }
5897
- ], (json) => [json.permission_id]);
5898
- var PermissionScopeMismatch = createKnownErrorConstructor(KnownError, "WRONG_PERMISSION_SCOPE", (permissionId, expectedScope, actualScope) => [
5899
- 404,
5900
- `Permission ${JSON.stringify(permissionId)} not found. (It was found for a different scope ${JSON.stringify(actualScope)}, but scope ${JSON.stringify(expectedScope)} was expected.)`,
5901
- {
5902
- permission_id: permissionId,
5903
- expected_scope: expectedScope,
5904
- actual_scope: actualScope
5905
- }
5906
- ], (json) => [
5907
- json.permission_id,
5908
- json.expected_scope,
5909
- json.actual_scope
5910
- ]);
5911
- var ContainedPermissionNotFound = createKnownErrorConstructor(KnownError, "CONTAINED_PERMISSION_NOT_FOUND", (permissionId) => [
5912
- 400,
5913
- `Contained permission with ID "${permissionId}" not found. Make sure you created it on the dashboard.`,
5914
- { permission_id: permissionId }
5915
- ], (json) => [json.permission_id]);
5916
- var TeamNotFound = createKnownErrorConstructor(KnownError, "TEAM_NOT_FOUND", (teamId) => [
5917
- 404,
5918
- `Team ${teamId} not found.`,
5919
- { team_id: teamId }
5920
- ], (json) => [json.team_id]);
5921
- createKnownErrorConstructor(KnownError, "TEAM_ALREADY_EXISTS", (teamId) => [
5922
- 409,
5923
- `Team ${teamId} already exists.`,
5924
- { team_id: teamId }
5925
- ], (json) => [json.team_id]);
5926
- var TeamMembershipNotFound = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_NOT_FOUND", (teamId, userId) => [
5927
- 404,
5928
- `User ${userId} is not found in team ${teamId}.`,
5929
- {
5930
- team_id: teamId,
5931
- user_id: userId
5932
- }
5933
- ], (json) => [json.team_id, json.user_id]);
5934
- var TeamInvitationRestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "TEAM_INVITATION_RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
5935
- 403,
5936
- `Restricted users cannot accept team invitations. Reason: ${restrictedReason.type}. Please complete the onboarding process before accepting team invitations.`,
5937
- { restricted_reason: restrictedReason }
5938
- ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
5939
- 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."], () => []);
5940
- var EmailTemplateAlreadyExists = createKnownErrorConstructor(KnownError, "EMAIL_TEMPLATE_ALREADY_EXISTS", () => [409, "Email template already exists."], () => []);
5941
- var OAuthConnectionNotConnectedToUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_NOT_CONNECTED_TO_USER", () => [400, "The OAuth connection is not connected to any user."], () => []);
5942
- var OAuthConnectionAlreadyConnectedToAnotherUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_ALREADY_CONNECTED_TO_ANOTHER_USER", () => [409, "The OAuth connection is already connected to another user."], () => []);
5943
- var OAuthConnectionDoesNotHaveRequiredScope = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_DOES_NOT_HAVE_REQUIRED_SCOPE", () => [400, "The OAuth connection does not have the required scope."], () => []);
5944
- var OAuthAccessTokenNotAvailable = createKnownErrorConstructor(KnownError, "OAUTH_ACCESS_TOKEN_NOT_AVAILABLE", (provider, details) => [
5945
- 400,
5946
- `Failed to retrieve an OAuth access token for the connected account (provider: ${provider}). ${details}`,
5947
- {
5948
- provider,
5949
- details
5950
- }
5951
- ], (json) => [json.provider, json.details]);
5952
- 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."], () => []);
5953
- 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."], () => []);
5954
- var InvalidOAuthClientIdOrSecret = createKnownErrorConstructor(KnownError, "INVALID_OAUTH_CLIENT_ID_OR_SECRET", (clientId) => [
5955
- 400,
5956
- "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.",
5957
- { client_id: clientId ?? null }
5958
- ], (json) => [json.client_id ?? void 0]);
5959
- var InvalidScope = createKnownErrorConstructor(KnownError, "INVALID_SCOPE", (scope) => [400, `The scope "${scope}" is not a valid OAuth scope for Stack.`], (json) => [json.scope]);
5960
- 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?"], () => []);
5961
- var OuterOAuthTimeout = createKnownErrorConstructor(KnownError, "OUTER_OAUTH_TIMEOUT", () => [408, "The OAuth flow has timed out. Please sign in again."], () => []);
5962
- var OAuthProviderNotFoundOrNotEnabled = createKnownErrorConstructor(KnownError, "OAUTH_PROVIDER_NOT_FOUND_OR_NOT_ENABLED", () => [400, "The OAuth provider is not found or not enabled."], () => []);
5963
- 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."], () => []);
5964
- 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.`], () => []);
5965
- var MultiFactorAuthenticationRequired = createKnownErrorConstructor(KnownError, "MULTI_FACTOR_AUTHENTICATION_REQUIRED", (attemptCode) => [
5966
- 400,
5967
- `Multi-factor authentication is required for this user.`,
5968
- { attempt_code: attemptCode }
5969
- ], (json) => [json.attempt_code]);
5970
- var InvalidTotpCode = createKnownErrorConstructor(KnownError, "INVALID_TOTP_CODE", () => [400, "The TOTP code is invalid. Please try again."], () => []);
5971
- var UserAuthenticationRequired = createKnownErrorConstructor(KnownError, "USER_AUTHENTICATION_REQUIRED", () => [401, "User authentication required for this endpoint."], () => []);
5972
- var TeamMembershipAlreadyExists = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_ALREADY_EXISTS", () => [409, "Team membership already exists."], () => []);
5973
- var ProjectPermissionRequired = createKnownErrorConstructor(KnownError, "PROJECT_PERMISSION_REQUIRED", (userId, permissionId) => [
5974
- 401,
5975
- `User ${userId} does not have permission ${permissionId}.`,
5976
- {
5977
- user_id: userId,
5978
- permission_id: permissionId
5979
- }
5980
- ], (json) => [json.user_id, json.permission_id]);
5981
- var TeamPermissionRequired = createKnownErrorConstructor(KnownError, "TEAM_PERMISSION_REQUIRED", (teamId, userId, permissionId) => [
5982
- 401,
5983
- `User ${userId} does not have permission ${permissionId} in team ${teamId}.`,
5984
- {
5985
- team_id: teamId,
5986
- user_id: userId,
5987
- permission_id: permissionId
5102
+ ], (json) => [json.user_id, json.permission_id]);
5103
+ var TeamPermissionRequired = createKnownErrorConstructor(KnownError, "TEAM_PERMISSION_REQUIRED", (teamId, userId, permissionId) => [
5104
+ 401,
5105
+ `User ${userId} does not have permission ${permissionId} in team ${teamId}.`,
5106
+ {
5107
+ team_id: teamId,
5108
+ user_id: userId,
5109
+ permission_id: permissionId
5988
5110
  }
5989
5111
  ], (json) => [
5990
5112
  json.team_id,
@@ -6342,49 +5464,6 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6342
5464
  knownErrorCodes.add(KnownError2.errorCode);
6343
5465
  }
6344
5466
 
6345
- // ../shared/dist/esm/utils/bytes.js
6346
- function decodeBase64(input) {
6347
- return new Uint8Array(atob(input).split("").map((char) => char.charCodeAt(0)));
6348
- }
6349
- function isBase64(input) {
6350
- return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(input);
6351
- }
6352
-
6353
- // ../shared/dist/esm/utils/urls.js
6354
- function createUrlIfValid(...args) {
6355
- try {
6356
- return new URL(...args);
6357
- } catch (e40) {
6358
- return null;
6359
- }
6360
- }
6361
- function isValidUrl(url) {
6362
- return !!createUrlIfValid(url);
6363
- }
6364
- function isValidHostname(hostname) {
6365
- if (!hostname || hostname.startsWith(".") || hostname.endsWith(".") || hostname.includes("..")) return false;
6366
- const url = createUrlIfValid(`https://${hostname}`);
6367
- if (!url) return false;
6368
- return url.hostname === hostname;
6369
- }
6370
- function isValidHostnameWithWildcards(hostname) {
6371
- if (!hostname) return false;
6372
- if (!hostname.includes("*")) return isValidHostname(hostname);
6373
- if (hostname.startsWith(".") || hostname.endsWith(".")) return false;
6374
- if (hostname.includes("..")) return false;
6375
- const testHostname = hostname.replace(/\*+/g, "wildcard");
6376
- if (!/^[a-zA-Z0-9.-]+$/.test(testHostname)) return false;
6377
- const segments = hostname.split(/\*+/);
6378
- for (let i = 0; i < segments.length; i++) {
6379
- const segment = segments[i];
6380
- if (segment === "") continue;
6381
- if (i === 0 && segment.startsWith(".")) return false;
6382
- if (i === segments.length - 1 && segment.endsWith(".")) return false;
6383
- if (segment.includes("..")) return false;
6384
- }
6385
- return true;
6386
- }
6387
-
6388
5467
  // ../../node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.esm.js
6389
5468
  var import_property_expr = __toESM(require_property_expr());
6390
5469
  var import_tiny_case = __toESM(require_tiny_case());
@@ -6424,11 +5503,11 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6424
5503
  function toArray(value) {
6425
5504
  return value == null ? [] : [].concat(value);
6426
5505
  }
6427
- var _Symbol$toStringTag4;
5506
+ var _Symbol$toStringTag;
6428
5507
  var _Symbol$hasInstance;
6429
- var _Symbol$toStringTag22;
5508
+ var _Symbol$toStringTag2;
6430
5509
  var strReg = /\$\{\s*(\w+)\s*\}/g;
6431
- _Symbol$toStringTag4 = Symbol.toStringTag;
5510
+ _Symbol$toStringTag = Symbol.toStringTag;
6432
5511
  var ValidationErrorNoStack = class {
6433
5512
  constructor(errorOrErrors, value, field, type) {
6434
5513
  this.name = void 0;
@@ -6439,7 +5518,7 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6439
5518
  this.params = void 0;
6440
5519
  this.errors = void 0;
6441
5520
  this.inner = void 0;
6442
- this[_Symbol$toStringTag4] = "Error";
5521
+ this[_Symbol$toStringTag] = "Error";
6443
5522
  this.name = "ValidationError";
6444
5523
  this.value = value;
6445
5524
  this.path = field;
@@ -6459,7 +5538,7 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6459
5538
  }
6460
5539
  };
6461
5540
  _Symbol$hasInstance = Symbol.hasInstance;
6462
- _Symbol$toStringTag22 = Symbol.toStringTag;
5541
+ _Symbol$toStringTag2 = Symbol.toStringTag;
6463
5542
  var ValidationError = class _ValidationError extends Error {
6464
5543
  static formatError(message2, params) {
6465
5544
  const path = params.label || params.path || "this";
@@ -6486,7 +5565,7 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6486
5565
  this.params = void 0;
6487
5566
  this.errors = [];
6488
5567
  this.inner = [];
6489
- this[_Symbol$toStringTag22] = "Error";
5568
+ this[_Symbol$toStringTag2] = "Error";
6490
5569
  this.name = errorNoStack.name;
6491
5570
  this.message = errorNoStack.message;
6492
5571
  this.type = errorNoStack.type;
@@ -9692,275 +8771,1196 @@ attempted value: ${formattedValue}
9692
8771
  diff: yupString().optional()
9693
8772
  });
9694
8773
 
9695
- // ../../node_modules/.pnpm/async-mutex@0.5.0/node_modules/async-mutex/index.mjs
9696
- var E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
9697
- var E_ALREADY_LOCKED = new Error("mutex already locked");
9698
- var E_CANCELED = new Error("request for lock canceled");
9699
- var __awaiter$2 = function(thisArg, _arguments, P2, generator) {
9700
- function adopt(value) {
9701
- return value instanceof P2 ? value : new P2(function(resolve) {
9702
- resolve(value);
9703
- });
8774
+ // ../../node_modules/.pnpm/async-mutex@0.5.0/node_modules/async-mutex/index.mjs
8775
+ var E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
8776
+ var E_ALREADY_LOCKED = new Error("mutex already locked");
8777
+ var E_CANCELED = new Error("request for lock canceled");
8778
+ var __awaiter$2 = function(thisArg, _arguments, P2, generator) {
8779
+ function adopt(value) {
8780
+ return value instanceof P2 ? value : new P2(function(resolve) {
8781
+ resolve(value);
8782
+ });
8783
+ }
8784
+ return new (P2 || (P2 = Promise))(function(resolve, reject) {
8785
+ function fulfilled(value) {
8786
+ try {
8787
+ step(generator.next(value));
8788
+ } catch (e40) {
8789
+ reject(e40);
8790
+ }
8791
+ }
8792
+ function rejected2(value) {
8793
+ try {
8794
+ step(generator["throw"](value));
8795
+ } catch (e40) {
8796
+ reject(e40);
8797
+ }
8798
+ }
8799
+ function step(result) {
8800
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected2);
8801
+ }
8802
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8803
+ });
8804
+ };
8805
+ var Semaphore = class {
8806
+ constructor(_value, _cancelError = E_CANCELED) {
8807
+ this._value = _value;
8808
+ this._cancelError = _cancelError;
8809
+ this._queue = [];
8810
+ this._weightedWaiters = [];
8811
+ }
8812
+ acquire(weight = 1, priority = 0) {
8813
+ if (weight <= 0)
8814
+ throw new Error(`invalid weight ${weight}: must be positive`);
8815
+ return new Promise((resolve, reject) => {
8816
+ const task = { resolve, reject, weight, priority };
8817
+ const i = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
8818
+ if (i === -1 && weight <= this._value) {
8819
+ this._dispatchItem(task);
8820
+ } else {
8821
+ this._queue.splice(i + 1, 0, task);
8822
+ }
8823
+ });
8824
+ }
8825
+ runExclusive(callback_1) {
8826
+ return __awaiter$2(this, arguments, void 0, function* (callback, weight = 1, priority = 0) {
8827
+ const [value, release] = yield this.acquire(weight, priority);
8828
+ try {
8829
+ return yield callback(value);
8830
+ } finally {
8831
+ release();
8832
+ }
8833
+ });
8834
+ }
8835
+ waitForUnlock(weight = 1, priority = 0) {
8836
+ if (weight <= 0)
8837
+ throw new Error(`invalid weight ${weight}: must be positive`);
8838
+ if (this._couldLockImmediately(weight, priority)) {
8839
+ return Promise.resolve();
8840
+ } else {
8841
+ return new Promise((resolve) => {
8842
+ if (!this._weightedWaiters[weight - 1])
8843
+ this._weightedWaiters[weight - 1] = [];
8844
+ insertSorted(this._weightedWaiters[weight - 1], { resolve, priority });
8845
+ });
8846
+ }
8847
+ }
8848
+ isLocked() {
8849
+ return this._value <= 0;
8850
+ }
8851
+ getValue() {
8852
+ return this._value;
8853
+ }
8854
+ setValue(value) {
8855
+ this._value = value;
8856
+ this._dispatchQueue();
8857
+ }
8858
+ release(weight = 1) {
8859
+ if (weight <= 0)
8860
+ throw new Error(`invalid weight ${weight}: must be positive`);
8861
+ this._value += weight;
8862
+ this._dispatchQueue();
8863
+ }
8864
+ cancel() {
8865
+ this._queue.forEach((entry) => entry.reject(this._cancelError));
8866
+ this._queue = [];
8867
+ }
8868
+ _dispatchQueue() {
8869
+ this._drainUnlockWaiters();
8870
+ while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
8871
+ this._dispatchItem(this._queue.shift());
8872
+ this._drainUnlockWaiters();
8873
+ }
8874
+ }
8875
+ _dispatchItem(item) {
8876
+ const previousValue = this._value;
8877
+ this._value -= item.weight;
8878
+ item.resolve([previousValue, this._newReleaser(item.weight)]);
8879
+ }
8880
+ _newReleaser(weight) {
8881
+ let called = false;
8882
+ return () => {
8883
+ if (called)
8884
+ return;
8885
+ called = true;
8886
+ this.release(weight);
8887
+ };
8888
+ }
8889
+ _drainUnlockWaiters() {
8890
+ if (this._queue.length === 0) {
8891
+ for (let weight = this._value; weight > 0; weight--) {
8892
+ const waiters = this._weightedWaiters[weight - 1];
8893
+ if (!waiters)
8894
+ continue;
8895
+ waiters.forEach((waiter) => waiter.resolve());
8896
+ this._weightedWaiters[weight - 1] = [];
8897
+ }
8898
+ } else {
8899
+ const queuedPriority = this._queue[0].priority;
8900
+ for (let weight = this._value; weight > 0; weight--) {
8901
+ const waiters = this._weightedWaiters[weight - 1];
8902
+ if (!waiters)
8903
+ continue;
8904
+ const i = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
8905
+ (i === -1 ? waiters : waiters.splice(0, i)).forEach((waiter) => waiter.resolve());
8906
+ }
8907
+ }
8908
+ }
8909
+ _couldLockImmediately(weight, priority) {
8910
+ return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
8911
+ }
8912
+ };
8913
+ function insertSorted(a26, v) {
8914
+ const i = findIndexFromEnd(a26, (other) => v.priority <= other.priority);
8915
+ a26.splice(i + 1, 0, v);
8916
+ }
8917
+ function findIndexFromEnd(a26, predicate) {
8918
+ for (let i = a26.length - 1; i >= 0; i--) {
8919
+ if (predicate(a26[i])) {
8920
+ return i;
8921
+ }
8922
+ }
8923
+ return -1;
8924
+ }
8925
+
8926
+ // ../shared/dist/esm/utils/locks.js
8927
+ var ReadWriteLock = class {
8928
+ constructor() {
8929
+ this.semaphore = new Semaphore(1);
8930
+ this.readers = 0;
8931
+ this.readersMutex = new Semaphore(1);
8932
+ }
8933
+ async withReadLock(callback) {
8934
+ await this._acquireReadLock();
8935
+ try {
8936
+ return await callback();
8937
+ } finally {
8938
+ await this._releaseReadLock();
8939
+ }
8940
+ }
8941
+ async withWriteLock(callback) {
8942
+ await this._acquireWriteLock();
8943
+ try {
8944
+ return await callback();
8945
+ } finally {
8946
+ await this._releaseWriteLock();
8947
+ }
8948
+ }
8949
+ async _acquireReadLock() {
8950
+ await this.readersMutex.acquire();
8951
+ try {
8952
+ this.readers += 1;
8953
+ if (this.readers === 1) await this.semaphore.acquire();
8954
+ } finally {
8955
+ this.readersMutex.release();
8956
+ }
8957
+ }
8958
+ async _releaseReadLock() {
8959
+ await this.readersMutex.acquire();
8960
+ try {
8961
+ this.readers -= 1;
8962
+ if (this.readers === 0) this.semaphore.release();
8963
+ } finally {
8964
+ this.readersMutex.release();
8965
+ }
8966
+ }
8967
+ async _acquireWriteLock() {
8968
+ await this.semaphore.acquire();
8969
+ }
8970
+ async _releaseWriteLock() {
8971
+ this.semaphore.release();
8972
+ }
8973
+ };
8974
+
8975
+ // ../shared/dist/esm/utils/stores.js
8976
+ var storeLock = new ReadWriteLock();
8977
+
8978
+ // ../shared/dist/esm/interface/client-interface.js
8979
+ var USER_AGENT;
8980
+ if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) USER_AGENT = `oauth4webapi/v3.8.5`;
8981
+ var ERR_INVALID_ARG_VALUE = "ERR_INVALID_ARG_VALUE";
8982
+ function CodedTypeError(message2, code, cause) {
8983
+ const err = new TypeError(message2, { cause });
8984
+ Object.assign(err, { code });
8985
+ return err;
8986
+ }
8987
+ var allowInsecureRequests = Symbol();
8988
+ var clockSkew = Symbol();
8989
+ var clockTolerance = Symbol();
8990
+ var customFetch = Symbol();
8991
+ var jweDecrypt = Symbol();
8992
+ var encoder = new TextEncoder();
8993
+ var decoder = new TextDecoder();
8994
+ var encodeBase64Url;
8995
+ if (Uint8Array.prototype.toBase64) encodeBase64Url = (input) => {
8996
+ if (input instanceof ArrayBuffer) input = new Uint8Array(input);
8997
+ return input.toBase64({
8998
+ alphabet: "base64url",
8999
+ omitPadding: true
9000
+ });
9001
+ };
9002
+ else {
9003
+ const CHUNK_SIZE = 32768;
9004
+ encodeBase64Url = (input) => {
9005
+ if (input instanceof ArrayBuffer) input = new Uint8Array(input);
9006
+ const arr = [];
9007
+ for (let i = 0; i < input.byteLength; i += CHUNK_SIZE) arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
9008
+ return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
9009
+ };
9010
+ }
9011
+ var decodeBase64Url;
9012
+ if (Uint8Array.fromBase64) decodeBase64Url = (input) => {
9013
+ try {
9014
+ return Uint8Array.fromBase64(input, { alphabet: "base64url" });
9015
+ } catch (cause) {
9016
+ throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
9017
+ }
9018
+ };
9019
+ else decodeBase64Url = (input) => {
9020
+ try {
9021
+ const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
9022
+ const bytes = new Uint8Array(binary.length);
9023
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
9024
+ return bytes;
9025
+ } catch (cause) {
9026
+ throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
9027
+ }
9028
+ };
9029
+ var URLParse = URL.parse ? (url, base) => URL.parse(url, base) : (url, base) => {
9030
+ try {
9031
+ return new URL(url, base);
9032
+ } catch {
9033
+ return null;
9034
+ }
9035
+ };
9036
+ var nopkce = Symbol();
9037
+ var expectNoNonce = Symbol();
9038
+ var skipAuthTimeCheck = Symbol();
9039
+ var skipStateCheck = Symbol();
9040
+ var expectNoState = Symbol();
9041
+ var _expectedIssuer = Symbol();
9042
+ var botChallengeKnownErrors = [KnownErrors.BotChallengeRequired, KnownErrors.BotChallengeFailed];
9043
+
9044
+ // ../shared/dist/esm/utils/maps.js
9045
+ var _Symbol$toStringTag3;
9046
+ var _Symbol$toStringTag22;
9047
+ var _Symbol$toStringTag32;
9048
+ var WeakRefIfAvailable = class {
9049
+ constructor(value) {
9050
+ if (typeof WeakRef === "undefined") this._ref = { deref: () => value };
9051
+ else this._ref = new WeakRef(value);
9052
+ }
9053
+ deref() {
9054
+ return this._ref.deref();
9055
+ }
9056
+ };
9057
+ var _a2;
9058
+ var IterableWeakMap = (_a2 = class {
9059
+ constructor(entries) {
9060
+ this[_Symbol$toStringTag3] = "IterableWeakMap";
9061
+ const mappedEntries = entries?.map((e40) => [e40[0], {
9062
+ value: e40[1],
9063
+ keyRef: new WeakRefIfAvailable(e40[0])
9064
+ }]);
9065
+ this._weakMap = new WeakMap(mappedEntries ?? []);
9066
+ this._keyRefs = new Set(mappedEntries?.map((e40) => e40[1].keyRef) ?? []);
9067
+ }
9068
+ get(key) {
9069
+ return this._weakMap.get(key)?.value;
9070
+ }
9071
+ set(key, value) {
9072
+ const updated = {
9073
+ value,
9074
+ keyRef: this._weakMap.get(key)?.keyRef ?? new WeakRefIfAvailable(key)
9075
+ };
9076
+ this._weakMap.set(key, updated);
9077
+ this._keyRefs.add(updated.keyRef);
9078
+ return this;
9079
+ }
9080
+ delete(key) {
9081
+ const res = this._weakMap.get(key);
9082
+ if (res) {
9083
+ this._weakMap.delete(key);
9084
+ this._keyRefs.delete(res.keyRef);
9085
+ return true;
9086
+ }
9087
+ return false;
9088
+ }
9089
+ has(key) {
9090
+ return this._weakMap.has(key) && this._keyRefs.has(this._weakMap.get(key).keyRef);
9091
+ }
9092
+ *[Symbol.iterator]() {
9093
+ for (const keyRef of this._keyRefs) {
9094
+ const key = keyRef.deref();
9095
+ const existing = key ? this._weakMap.get(key) : void 0;
9096
+ if (!key) this._keyRefs.delete(keyRef);
9097
+ else if (existing) yield [key, existing.value];
9098
+ }
9099
+ }
9100
+ }, _Symbol$toStringTag3 = Symbol.toStringTag, _a2);
9101
+ var _a3;
9102
+ var MaybeWeakMap = (_a3 = class {
9103
+ constructor(entries) {
9104
+ this[_Symbol$toStringTag22] = "MaybeWeakMap";
9105
+ const entriesArray = [...entries ?? []];
9106
+ this._primitiveMap = new Map(entriesArray.filter((e40) => !this._isAllowedInWeakMap(e40[0])));
9107
+ this._weakMap = new IterableWeakMap(entriesArray.filter((e40) => this._isAllowedInWeakMap(e40[0])));
9108
+ }
9109
+ _isAllowedInWeakMap(key) {
9110
+ return typeof key === "object" && key !== null || typeof key === "symbol" && Symbol.keyFor(key) === void 0;
9111
+ }
9112
+ get(key) {
9113
+ if (this._isAllowedInWeakMap(key)) return this._weakMap.get(key);
9114
+ else return this._primitiveMap.get(key);
9115
+ }
9116
+ set(key, value) {
9117
+ if (this._isAllowedInWeakMap(key)) this._weakMap.set(key, value);
9118
+ else this._primitiveMap.set(key, value);
9119
+ return this;
9120
+ }
9121
+ delete(key) {
9122
+ if (this._isAllowedInWeakMap(key)) return this._weakMap.delete(key);
9123
+ else return this._primitiveMap.delete(key);
9124
+ }
9125
+ has(key) {
9126
+ if (this._isAllowedInWeakMap(key)) return this._weakMap.has(key);
9127
+ else return this._primitiveMap.has(key);
9128
+ }
9129
+ *[Symbol.iterator]() {
9130
+ yield* this._primitiveMap;
9131
+ yield* this._weakMap;
9132
+ }
9133
+ }, _Symbol$toStringTag22 = Symbol.toStringTag, _a3);
9134
+ var _a4;
9135
+ var DependenciesMap = (_a4 = class {
9136
+ constructor() {
9137
+ this._inner = {
9138
+ map: new MaybeWeakMap(),
9139
+ hasValue: false,
9140
+ value: void 0
9141
+ };
9142
+ this[_Symbol$toStringTag32] = "DependenciesMap";
9143
+ }
9144
+ _valueToResult(inner) {
9145
+ if (inner.hasValue) return Result.ok(inner.value);
9146
+ else return Result.error(void 0);
9147
+ }
9148
+ _unwrapFromInner(dependencies, inner) {
9149
+ if (dependencies.length === 0) return this._valueToResult(inner);
9150
+ else {
9151
+ const [key, ...rest] = dependencies;
9152
+ const newInner = inner.map.get(key);
9153
+ if (!newInner) return Result.error(void 0);
9154
+ return this._unwrapFromInner(rest, newInner);
9155
+ }
9156
+ }
9157
+ _setInInner(dependencies, value, inner) {
9158
+ if (dependencies.length === 0) {
9159
+ const res = this._valueToResult(inner);
9160
+ if (value.status === "ok") {
9161
+ inner.hasValue = true;
9162
+ inner.value = value.data;
9163
+ } else {
9164
+ inner.hasValue = false;
9165
+ inner.value = void 0;
9166
+ }
9167
+ return res;
9168
+ } else {
9169
+ const [key, ...rest] = dependencies;
9170
+ let newInner = inner.map.get(key);
9171
+ if (!newInner) inner.map.set(key, newInner = {
9172
+ map: new MaybeWeakMap(),
9173
+ hasValue: false,
9174
+ value: void 0
9175
+ });
9176
+ return this._setInInner(rest, value, newInner);
9177
+ }
9178
+ }
9179
+ *_iterateInner(dependencies, inner) {
9180
+ if (inner.hasValue) yield [dependencies, inner.value];
9181
+ for (const [key, value] of inner.map) yield* this._iterateInner([...dependencies, key], value);
9182
+ }
9183
+ get(dependencies) {
9184
+ return Result.or(this._unwrapFromInner(dependencies, this._inner), void 0);
9185
+ }
9186
+ set(dependencies, value) {
9187
+ this._setInInner(dependencies, Result.ok(value), this._inner);
9188
+ return this;
9189
+ }
9190
+ delete(dependencies) {
9191
+ return this._setInInner(dependencies, Result.error(void 0), this._inner).status === "ok";
9192
+ }
9193
+ has(dependencies) {
9194
+ return this._unwrapFromInner(dependencies, this._inner).status === "ok";
9195
+ }
9196
+ clear() {
9197
+ this._inner = {
9198
+ map: new MaybeWeakMap(),
9199
+ hasValue: false,
9200
+ value: void 0
9201
+ };
9202
+ }
9203
+ *[Symbol.iterator]() {
9204
+ yield* this._iterateInner([], this._inner);
9205
+ }
9206
+ }, _Symbol$toStringTag32 = Symbol.toStringTag, _a4);
9207
+
9208
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/platform/browser/globalThis.js
9209
+ var _globalThis = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
9210
+
9211
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/version.js
9212
+ var VERSION = "1.9.0";
9213
+
9214
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/semver.js
9215
+ var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
9216
+ function _makeCompatibilityCheck(ownVersion) {
9217
+ var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
9218
+ var rejectedVersions = /* @__PURE__ */ new Set();
9219
+ var myVersionMatch = ownVersion.match(re);
9220
+ if (!myVersionMatch) {
9221
+ return function() {
9222
+ return false;
9223
+ };
9224
+ }
9225
+ var ownVersionParsed = {
9226
+ major: +myVersionMatch[1],
9227
+ minor: +myVersionMatch[2],
9228
+ patch: +myVersionMatch[3],
9229
+ prerelease: myVersionMatch[4]
9230
+ };
9231
+ if (ownVersionParsed.prerelease != null) {
9232
+ return function isExactmatch(globalVersion) {
9233
+ return globalVersion === ownVersion;
9234
+ };
9235
+ }
9236
+ function _reject(v) {
9237
+ rejectedVersions.add(v);
9238
+ return false;
9239
+ }
9240
+ function _accept(v) {
9241
+ acceptedVersions.add(v);
9242
+ return true;
9243
+ }
9244
+ return function isCompatible2(globalVersion) {
9245
+ if (acceptedVersions.has(globalVersion)) {
9246
+ return true;
9247
+ }
9248
+ if (rejectedVersions.has(globalVersion)) {
9249
+ return false;
9250
+ }
9251
+ var globalVersionMatch = globalVersion.match(re);
9252
+ if (!globalVersionMatch) {
9253
+ return _reject(globalVersion);
9254
+ }
9255
+ var globalVersionParsed = {
9256
+ major: +globalVersionMatch[1],
9257
+ minor: +globalVersionMatch[2],
9258
+ patch: +globalVersionMatch[3],
9259
+ prerelease: globalVersionMatch[4]
9260
+ };
9261
+ if (globalVersionParsed.prerelease != null) {
9262
+ return _reject(globalVersion);
9263
+ }
9264
+ if (ownVersionParsed.major !== globalVersionParsed.major) {
9265
+ return _reject(globalVersion);
9266
+ }
9267
+ if (ownVersionParsed.major === 0) {
9268
+ if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
9269
+ return _accept(globalVersion);
9270
+ }
9271
+ return _reject(globalVersion);
9272
+ }
9273
+ if (ownVersionParsed.minor <= globalVersionParsed.minor) {
9274
+ return _accept(globalVersion);
9275
+ }
9276
+ return _reject(globalVersion);
9277
+ };
9278
+ }
9279
+ var isCompatible = _makeCompatibilityCheck(VERSION);
9280
+
9281
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
9282
+ var major = VERSION.split(".")[0];
9283
+ var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
9284
+ var _global = _globalThis;
9285
+ function registerGlobal(type, instance, diag, allowOverride) {
9286
+ var _a5;
9287
+ if (allowOverride === void 0) {
9288
+ allowOverride = false;
9289
+ }
9290
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a5 !== void 0 ? _a5 : {
9291
+ version: VERSION
9292
+ };
9293
+ if (!allowOverride && api[type]) {
9294
+ var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
9295
+ diag.error(err.stack || err.message);
9296
+ return false;
9297
+ }
9298
+ if (api.version !== VERSION) {
9299
+ var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
9300
+ diag.error(err.stack || err.message);
9301
+ return false;
9302
+ }
9303
+ api[type] = instance;
9304
+ diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
9305
+ return true;
9306
+ }
9307
+ function getGlobal(type) {
9308
+ var _a5, _b;
9309
+ var globalVersion = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a5 === void 0 ? void 0 : _a5.version;
9310
+ if (!globalVersion || !isCompatible(globalVersion)) {
9311
+ return;
9312
+ }
9313
+ return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
9314
+ }
9315
+ function unregisterGlobal(type, diag) {
9316
+ diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
9317
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
9318
+ if (api) {
9319
+ delete api[type];
9320
+ }
9321
+ }
9322
+
9323
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
9324
+ var __read = function(o21, n10) {
9325
+ var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
9326
+ if (!m6) return o21;
9327
+ var i = m6.call(o21), r7, ar = [], e40;
9328
+ try {
9329
+ while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9330
+ } catch (error) {
9331
+ e40 = { error };
9332
+ } finally {
9333
+ try {
9334
+ if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
9335
+ } finally {
9336
+ if (e40) throw e40.error;
9337
+ }
9338
+ }
9339
+ return ar;
9340
+ };
9341
+ var __spreadArray = function(to, from, pack) {
9342
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9343
+ if (ar || !(i in from)) {
9344
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9345
+ ar[i] = from[i];
9346
+ }
9347
+ }
9348
+ return to.concat(ar || Array.prototype.slice.call(from));
9349
+ };
9350
+ var DiagComponentLogger = (
9351
+ /** @class */
9352
+ function() {
9353
+ function DiagComponentLogger2(props2) {
9354
+ this._namespace = props2.namespace || "DiagComponentLogger";
9355
+ }
9356
+ DiagComponentLogger2.prototype.debug = function() {
9357
+ var args = [];
9358
+ for (var _i = 0; _i < arguments.length; _i++) {
9359
+ args[_i] = arguments[_i];
9360
+ }
9361
+ return logProxy("debug", this._namespace, args);
9362
+ };
9363
+ DiagComponentLogger2.prototype.error = function() {
9364
+ var args = [];
9365
+ for (var _i = 0; _i < arguments.length; _i++) {
9366
+ args[_i] = arguments[_i];
9367
+ }
9368
+ return logProxy("error", this._namespace, args);
9369
+ };
9370
+ DiagComponentLogger2.prototype.info = function() {
9371
+ var args = [];
9372
+ for (var _i = 0; _i < arguments.length; _i++) {
9373
+ args[_i] = arguments[_i];
9374
+ }
9375
+ return logProxy("info", this._namespace, args);
9376
+ };
9377
+ DiagComponentLogger2.prototype.warn = function() {
9378
+ var args = [];
9379
+ for (var _i = 0; _i < arguments.length; _i++) {
9380
+ args[_i] = arguments[_i];
9381
+ }
9382
+ return logProxy("warn", this._namespace, args);
9383
+ };
9384
+ DiagComponentLogger2.prototype.verbose = function() {
9385
+ var args = [];
9386
+ for (var _i = 0; _i < arguments.length; _i++) {
9387
+ args[_i] = arguments[_i];
9388
+ }
9389
+ return logProxy("verbose", this._namespace, args);
9390
+ };
9391
+ return DiagComponentLogger2;
9392
+ }()
9393
+ );
9394
+ function logProxy(funcName, namespace, args) {
9395
+ var logger = getGlobal("diag");
9396
+ if (!logger) {
9397
+ return;
9398
+ }
9399
+ args.unshift(namespace);
9400
+ return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
9401
+ }
9402
+
9403
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/types.js
9404
+ var DiagLogLevel;
9405
+ (function(DiagLogLevel2) {
9406
+ DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
9407
+ DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
9408
+ DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
9409
+ DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
9410
+ DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
9411
+ DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
9412
+ DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
9413
+ })(DiagLogLevel || (DiagLogLevel = {}));
9414
+
9415
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
9416
+ function createLogLevelDiagLogger(maxLevel, logger) {
9417
+ if (maxLevel < DiagLogLevel.NONE) {
9418
+ maxLevel = DiagLogLevel.NONE;
9419
+ } else if (maxLevel > DiagLogLevel.ALL) {
9420
+ maxLevel = DiagLogLevel.ALL;
9421
+ }
9422
+ logger = logger || {};
9423
+ function _filterFunc(funcName, theLevel) {
9424
+ var theFunc = logger[funcName];
9425
+ if (typeof theFunc === "function" && maxLevel >= theLevel) {
9426
+ return theFunc.bind(logger);
9427
+ }
9428
+ return function() {
9429
+ };
9430
+ }
9431
+ return {
9432
+ error: _filterFunc("error", DiagLogLevel.ERROR),
9433
+ warn: _filterFunc("warn", DiagLogLevel.WARN),
9434
+ info: _filterFunc("info", DiagLogLevel.INFO),
9435
+ debug: _filterFunc("debug", DiagLogLevel.DEBUG),
9436
+ verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
9437
+ };
9438
+ }
9439
+
9440
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/diag.js
9441
+ var __read2 = function(o21, n10) {
9442
+ var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
9443
+ if (!m6) return o21;
9444
+ var i = m6.call(o21), r7, ar = [], e40;
9445
+ try {
9446
+ while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9447
+ } catch (error) {
9448
+ e40 = { error };
9449
+ } finally {
9450
+ try {
9451
+ if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
9452
+ } finally {
9453
+ if (e40) throw e40.error;
9454
+ }
9704
9455
  }
9705
- return new (P2 || (P2 = Promise))(function(resolve, reject) {
9706
- function fulfilled(value) {
9707
- try {
9708
- step(generator.next(value));
9709
- } catch (e40) {
9710
- reject(e40);
9456
+ return ar;
9457
+ };
9458
+ var __spreadArray2 = function(to, from, pack) {
9459
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9460
+ if (ar || !(i in from)) {
9461
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9462
+ ar[i] = from[i];
9463
+ }
9464
+ }
9465
+ return to.concat(ar || Array.prototype.slice.call(from));
9466
+ };
9467
+ var API_NAME = "diag";
9468
+ var DiagAPI = (
9469
+ /** @class */
9470
+ function() {
9471
+ function DiagAPI2() {
9472
+ function _logProxy(funcName) {
9473
+ return function() {
9474
+ var args = [];
9475
+ for (var _i = 0; _i < arguments.length; _i++) {
9476
+ args[_i] = arguments[_i];
9477
+ }
9478
+ var logger = getGlobal("diag");
9479
+ if (!logger)
9480
+ return;
9481
+ return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
9482
+ };
9483
+ }
9484
+ var self2 = this;
9485
+ var setLogger = function(logger, optionsOrLogLevel) {
9486
+ var _a5, _b, _c;
9487
+ if (optionsOrLogLevel === void 0) {
9488
+ optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
9489
+ }
9490
+ if (logger === self2) {
9491
+ var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
9492
+ self2.error((_a5 = err.stack) !== null && _a5 !== void 0 ? _a5 : err.message);
9493
+ return false;
9494
+ }
9495
+ if (typeof optionsOrLogLevel === "number") {
9496
+ optionsOrLogLevel = {
9497
+ logLevel: optionsOrLogLevel
9498
+ };
9499
+ }
9500
+ var oldLogger = getGlobal("diag");
9501
+ var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
9502
+ if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
9503
+ var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
9504
+ oldLogger.warn("Current logger will be overwritten from " + stack);
9505
+ newLogger.warn("Current logger will overwrite one already registered from " + stack);
9506
+ }
9507
+ return registerGlobal("diag", newLogger, self2, true);
9508
+ };
9509
+ self2.setLogger = setLogger;
9510
+ self2.disable = function() {
9511
+ unregisterGlobal(API_NAME, self2);
9512
+ };
9513
+ self2.createComponentLogger = function(options) {
9514
+ return new DiagComponentLogger(options);
9515
+ };
9516
+ self2.verbose = _logProxy("verbose");
9517
+ self2.debug = _logProxy("debug");
9518
+ self2.info = _logProxy("info");
9519
+ self2.warn = _logProxy("warn");
9520
+ self2.error = _logProxy("error");
9521
+ }
9522
+ DiagAPI2.instance = function() {
9523
+ if (!this._instance) {
9524
+ this._instance = new DiagAPI2();
9525
+ }
9526
+ return this._instance;
9527
+ };
9528
+ return DiagAPI2;
9529
+ }()
9530
+ );
9531
+
9532
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/context.js
9533
+ function createContextKey(description) {
9534
+ return Symbol.for(description);
9535
+ }
9536
+ var BaseContext = (
9537
+ /** @class */
9538
+ /* @__PURE__ */ function() {
9539
+ function BaseContext2(parentContext) {
9540
+ var self2 = this;
9541
+ self2._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
9542
+ self2.getValue = function(key) {
9543
+ return self2._currentContext.get(key);
9544
+ };
9545
+ self2.setValue = function(key, value) {
9546
+ var context = new BaseContext2(self2._currentContext);
9547
+ context._currentContext.set(key, value);
9548
+ return context;
9549
+ };
9550
+ self2.deleteValue = function(key) {
9551
+ var context = new BaseContext2(self2._currentContext);
9552
+ context._currentContext.delete(key);
9553
+ return context;
9554
+ };
9555
+ }
9556
+ return BaseContext2;
9557
+ }()
9558
+ );
9559
+ var ROOT_CONTEXT = new BaseContext();
9560
+
9561
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js
9562
+ var __read3 = function(o21, n10) {
9563
+ var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
9564
+ if (!m6) return o21;
9565
+ var i = m6.call(o21), r7, ar = [], e40;
9566
+ try {
9567
+ while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9568
+ } catch (error) {
9569
+ e40 = { error };
9570
+ } finally {
9571
+ try {
9572
+ if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
9573
+ } finally {
9574
+ if (e40) throw e40.error;
9575
+ }
9576
+ }
9577
+ return ar;
9578
+ };
9579
+ var __spreadArray3 = function(to, from, pack) {
9580
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9581
+ if (ar || !(i in from)) {
9582
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9583
+ ar[i] = from[i];
9584
+ }
9585
+ }
9586
+ return to.concat(ar || Array.prototype.slice.call(from));
9587
+ };
9588
+ var NoopContextManager = (
9589
+ /** @class */
9590
+ function() {
9591
+ function NoopContextManager2() {
9592
+ }
9593
+ NoopContextManager2.prototype.active = function() {
9594
+ return ROOT_CONTEXT;
9595
+ };
9596
+ NoopContextManager2.prototype.with = function(_context, fn, thisArg) {
9597
+ var args = [];
9598
+ for (var _i = 3; _i < arguments.length; _i++) {
9599
+ args[_i - 3] = arguments[_i];
9600
+ }
9601
+ return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
9602
+ };
9603
+ NoopContextManager2.prototype.bind = function(_context, target) {
9604
+ return target;
9605
+ };
9606
+ NoopContextManager2.prototype.enable = function() {
9607
+ return this;
9608
+ };
9609
+ NoopContextManager2.prototype.disable = function() {
9610
+ return this;
9611
+ };
9612
+ return NoopContextManager2;
9613
+ }()
9614
+ );
9615
+
9616
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/context.js
9617
+ var __read4 = function(o21, n10) {
9618
+ var m6 = typeof Symbol === "function" && o21[Symbol.iterator];
9619
+ if (!m6) return o21;
9620
+ var i = m6.call(o21), r7, ar = [], e40;
9621
+ try {
9622
+ while ((n10 === void 0 || n10-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9623
+ } catch (error) {
9624
+ e40 = { error };
9625
+ } finally {
9626
+ try {
9627
+ if (r7 && !r7.done && (m6 = i["return"])) m6.call(i);
9628
+ } finally {
9629
+ if (e40) throw e40.error;
9630
+ }
9631
+ }
9632
+ return ar;
9633
+ };
9634
+ var __spreadArray4 = function(to, from, pack) {
9635
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9636
+ if (ar || !(i in from)) {
9637
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9638
+ ar[i] = from[i];
9639
+ }
9640
+ }
9641
+ return to.concat(ar || Array.prototype.slice.call(from));
9642
+ };
9643
+ var API_NAME2 = "context";
9644
+ var NOOP_CONTEXT_MANAGER = new NoopContextManager();
9645
+ var ContextAPI = (
9646
+ /** @class */
9647
+ function() {
9648
+ function ContextAPI2() {
9649
+ }
9650
+ ContextAPI2.getInstance = function() {
9651
+ if (!this._instance) {
9652
+ this._instance = new ContextAPI2();
9653
+ }
9654
+ return this._instance;
9655
+ };
9656
+ ContextAPI2.prototype.setGlobalContextManager = function(contextManager) {
9657
+ return registerGlobal(API_NAME2, contextManager, DiagAPI.instance());
9658
+ };
9659
+ ContextAPI2.prototype.active = function() {
9660
+ return this._getContextManager().active();
9661
+ };
9662
+ ContextAPI2.prototype.with = function(context, fn, thisArg) {
9663
+ var _a5;
9664
+ var args = [];
9665
+ for (var _i = 3; _i < arguments.length; _i++) {
9666
+ args[_i - 3] = arguments[_i];
9711
9667
  }
9712
- }
9713
- function rejected2(value) {
9714
- try {
9715
- step(generator["throw"](value));
9716
- } catch (e40) {
9717
- reject(e40);
9668
+ return (_a5 = this._getContextManager()).with.apply(_a5, __spreadArray4([context, fn, thisArg], __read4(args), false));
9669
+ };
9670
+ ContextAPI2.prototype.bind = function(context, target) {
9671
+ return this._getContextManager().bind(context, target);
9672
+ };
9673
+ ContextAPI2.prototype._getContextManager = function() {
9674
+ return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
9675
+ };
9676
+ ContextAPI2.prototype.disable = function() {
9677
+ this._getContextManager().disable();
9678
+ unregisterGlobal(API_NAME2, DiagAPI.instance());
9679
+ };
9680
+ return ContextAPI2;
9681
+ }()
9682
+ );
9683
+
9684
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js
9685
+ var TraceFlags;
9686
+ (function(TraceFlags2) {
9687
+ TraceFlags2[TraceFlags2["NONE"] = 0] = "NONE";
9688
+ TraceFlags2[TraceFlags2["SAMPLED"] = 1] = "SAMPLED";
9689
+ })(TraceFlags || (TraceFlags = {}));
9690
+
9691
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js
9692
+ var INVALID_SPANID = "0000000000000000";
9693
+ var INVALID_TRACEID = "00000000000000000000000000000000";
9694
+ var INVALID_SPAN_CONTEXT = {
9695
+ traceId: INVALID_TRACEID,
9696
+ spanId: INVALID_SPANID,
9697
+ traceFlags: TraceFlags.NONE
9698
+ };
9699
+
9700
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js
9701
+ var NonRecordingSpan = (
9702
+ /** @class */
9703
+ function() {
9704
+ function NonRecordingSpan2(_spanContext) {
9705
+ if (_spanContext === void 0) {
9706
+ _spanContext = INVALID_SPAN_CONTEXT;
9718
9707
  }
9708
+ this._spanContext = _spanContext;
9719
9709
  }
9720
- function step(result) {
9721
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected2);
9710
+ NonRecordingSpan2.prototype.spanContext = function() {
9711
+ return this._spanContext;
9712
+ };
9713
+ NonRecordingSpan2.prototype.setAttribute = function(_key, _value) {
9714
+ return this;
9715
+ };
9716
+ NonRecordingSpan2.prototype.setAttributes = function(_attributes) {
9717
+ return this;
9718
+ };
9719
+ NonRecordingSpan2.prototype.addEvent = function(_name, _attributes) {
9720
+ return this;
9721
+ };
9722
+ NonRecordingSpan2.prototype.addLink = function(_link) {
9723
+ return this;
9724
+ };
9725
+ NonRecordingSpan2.prototype.addLinks = function(_links) {
9726
+ return this;
9727
+ };
9728
+ NonRecordingSpan2.prototype.setStatus = function(_status) {
9729
+ return this;
9730
+ };
9731
+ NonRecordingSpan2.prototype.updateName = function(_name) {
9732
+ return this;
9733
+ };
9734
+ NonRecordingSpan2.prototype.end = function(_endTime) {
9735
+ };
9736
+ NonRecordingSpan2.prototype.isRecording = function() {
9737
+ return false;
9738
+ };
9739
+ NonRecordingSpan2.prototype.recordException = function(_exception, _time) {
9740
+ };
9741
+ return NonRecordingSpan2;
9742
+ }()
9743
+ );
9744
+
9745
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js
9746
+ var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
9747
+ function getSpan(context) {
9748
+ return context.getValue(SPAN_KEY) || void 0;
9749
+ }
9750
+ function getActiveSpan() {
9751
+ return getSpan(ContextAPI.getInstance().active());
9752
+ }
9753
+ function setSpan(context, span) {
9754
+ return context.setValue(SPAN_KEY, span);
9755
+ }
9756
+ function deleteSpan(context) {
9757
+ return context.deleteValue(SPAN_KEY);
9758
+ }
9759
+ function setSpanContext(context, spanContext) {
9760
+ return setSpan(context, new NonRecordingSpan(spanContext));
9761
+ }
9762
+ function getSpanContext(context) {
9763
+ var _a5;
9764
+ return (_a5 = getSpan(context)) === null || _a5 === void 0 ? void 0 : _a5.spanContext();
9765
+ }
9766
+
9767
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
9768
+ var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
9769
+ var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
9770
+ function isValidTraceId(traceId) {
9771
+ return VALID_TRACEID_REGEX.test(traceId) && traceId !== INVALID_TRACEID;
9772
+ }
9773
+ function isValidSpanId(spanId) {
9774
+ return VALID_SPANID_REGEX.test(spanId) && spanId !== INVALID_SPANID;
9775
+ }
9776
+ function isSpanContextValid(spanContext) {
9777
+ return isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);
9778
+ }
9779
+ function wrapSpanContext(spanContext) {
9780
+ return new NonRecordingSpan(spanContext);
9781
+ }
9782
+
9783
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js
9784
+ var contextApi = ContextAPI.getInstance();
9785
+ var NoopTracer = (
9786
+ /** @class */
9787
+ function() {
9788
+ function NoopTracer2() {
9722
9789
  }
9723
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9724
- });
9725
- };
9726
- var Semaphore = class {
9727
- constructor(_value, _cancelError = E_CANCELED) {
9728
- this._value = _value;
9729
- this._cancelError = _cancelError;
9730
- this._queue = [];
9731
- this._weightedWaiters = [];
9732
- }
9733
- acquire(weight = 1, priority = 0) {
9734
- if (weight <= 0)
9735
- throw new Error(`invalid weight ${weight}: must be positive`);
9736
- return new Promise((resolve, reject) => {
9737
- const task = { resolve, reject, weight, priority };
9738
- const i = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
9739
- if (i === -1 && weight <= this._value) {
9740
- this._dispatchItem(task);
9741
- } else {
9742
- this._queue.splice(i + 1, 0, task);
9790
+ NoopTracer2.prototype.startSpan = function(name, options, context) {
9791
+ if (context === void 0) {
9792
+ context = contextApi.active();
9743
9793
  }
9744
- });
9745
- }
9746
- runExclusive(callback_1) {
9747
- return __awaiter$2(this, arguments, void 0, function* (callback, weight = 1, priority = 0) {
9748
- const [value, release] = yield this.acquire(weight, priority);
9749
- try {
9750
- return yield callback(value);
9751
- } finally {
9752
- release();
9794
+ var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
9795
+ if (root) {
9796
+ return new NonRecordingSpan();
9753
9797
  }
9754
- });
9755
- }
9756
- waitForUnlock(weight = 1, priority = 0) {
9757
- if (weight <= 0)
9758
- throw new Error(`invalid weight ${weight}: must be positive`);
9759
- if (this._couldLockImmediately(weight, priority)) {
9760
- return Promise.resolve();
9761
- } else {
9762
- return new Promise((resolve) => {
9763
- if (!this._weightedWaiters[weight - 1])
9764
- this._weightedWaiters[weight - 1] = [];
9765
- insertSorted(this._weightedWaiters[weight - 1], { resolve, priority });
9766
- });
9767
- }
9768
- }
9769
- isLocked() {
9770
- return this._value <= 0;
9771
- }
9772
- getValue() {
9773
- return this._value;
9774
- }
9775
- setValue(value) {
9776
- this._value = value;
9777
- this._dispatchQueue();
9778
- }
9779
- release(weight = 1) {
9780
- if (weight <= 0)
9781
- throw new Error(`invalid weight ${weight}: must be positive`);
9782
- this._value += weight;
9783
- this._dispatchQueue();
9784
- }
9785
- cancel() {
9786
- this._queue.forEach((entry) => entry.reject(this._cancelError));
9787
- this._queue = [];
9788
- }
9789
- _dispatchQueue() {
9790
- this._drainUnlockWaiters();
9791
- while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
9792
- this._dispatchItem(this._queue.shift());
9793
- this._drainUnlockWaiters();
9794
- }
9795
- }
9796
- _dispatchItem(item) {
9797
- const previousValue = this._value;
9798
- this._value -= item.weight;
9799
- item.resolve([previousValue, this._newReleaser(item.weight)]);
9800
- }
9801
- _newReleaser(weight) {
9802
- let called = false;
9803
- return () => {
9804
- if (called)
9798
+ var parentFromContext = context && getSpanContext(context);
9799
+ if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
9800
+ return new NonRecordingSpan(parentFromContext);
9801
+ } else {
9802
+ return new NonRecordingSpan();
9803
+ }
9804
+ };
9805
+ NoopTracer2.prototype.startActiveSpan = function(name, arg2, arg3, arg4) {
9806
+ var opts;
9807
+ var ctx;
9808
+ var fn;
9809
+ if (arguments.length < 2) {
9805
9810
  return;
9806
- called = true;
9807
- this.release(weight);
9811
+ } else if (arguments.length === 2) {
9812
+ fn = arg2;
9813
+ } else if (arguments.length === 3) {
9814
+ opts = arg2;
9815
+ fn = arg3;
9816
+ } else {
9817
+ opts = arg2;
9818
+ ctx = arg3;
9819
+ fn = arg4;
9820
+ }
9821
+ var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
9822
+ var span = this.startSpan(name, opts, parentContext);
9823
+ var contextWithSpanSet = setSpan(parentContext, span);
9824
+ return contextApi.with(contextWithSpanSet, fn, void 0, span);
9825
+ };
9826
+ return NoopTracer2;
9827
+ }()
9828
+ );
9829
+ function isSpanContext(spanContext) {
9830
+ return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
9831
+ }
9832
+
9833
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js
9834
+ var NOOP_TRACER = new NoopTracer();
9835
+ var ProxyTracer = (
9836
+ /** @class */
9837
+ function() {
9838
+ function ProxyTracer2(_provider, name, version, options) {
9839
+ this._provider = _provider;
9840
+ this.name = name;
9841
+ this.version = version;
9842
+ this.options = options;
9843
+ }
9844
+ ProxyTracer2.prototype.startSpan = function(name, options, context) {
9845
+ return this._getTracer().startSpan(name, options, context);
9808
9846
  };
9809
- }
9810
- _drainUnlockWaiters() {
9811
- if (this._queue.length === 0) {
9812
- for (let weight = this._value; weight > 0; weight--) {
9813
- const waiters = this._weightedWaiters[weight - 1];
9814
- if (!waiters)
9815
- continue;
9816
- waiters.forEach((waiter) => waiter.resolve());
9817
- this._weightedWaiters[weight - 1] = [];
9847
+ ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
9848
+ var tracer2 = this._getTracer();
9849
+ return Reflect.apply(tracer2.startActiveSpan, tracer2, arguments);
9850
+ };
9851
+ ProxyTracer2.prototype._getTracer = function() {
9852
+ if (this._delegate) {
9853
+ return this._delegate;
9818
9854
  }
9819
- } else {
9820
- const queuedPriority = this._queue[0].priority;
9821
- for (let weight = this._value; weight > 0; weight--) {
9822
- const waiters = this._weightedWaiters[weight - 1];
9823
- if (!waiters)
9824
- continue;
9825
- const i = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
9826
- (i === -1 ? waiters : waiters.splice(0, i)).forEach((waiter) => waiter.resolve());
9855
+ var tracer2 = this._provider.getDelegateTracer(this.name, this.version, this.options);
9856
+ if (!tracer2) {
9857
+ return NOOP_TRACER;
9827
9858
  }
9828
- }
9829
- }
9830
- _couldLockImmediately(weight, priority) {
9831
- return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
9832
- }
9833
- };
9834
- function insertSorted(a26, v) {
9835
- const i = findIndexFromEnd(a26, (other) => v.priority <= other.priority);
9836
- a26.splice(i + 1, 0, v);
9837
- }
9838
- function findIndexFromEnd(a26, predicate) {
9839
- for (let i = a26.length - 1; i >= 0; i--) {
9840
- if (predicate(a26[i])) {
9841
- return i;
9842
- }
9843
- }
9844
- return -1;
9845
- }
9859
+ this._delegate = tracer2;
9860
+ return this._delegate;
9861
+ };
9862
+ return ProxyTracer2;
9863
+ }()
9864
+ );
9846
9865
 
9847
- // ../shared/dist/esm/utils/locks.js
9848
- var ReadWriteLock = class {
9849
- constructor() {
9850
- this.semaphore = new Semaphore(1);
9851
- this.readers = 0;
9852
- this.readersMutex = new Semaphore(1);
9853
- }
9854
- async withReadLock(callback) {
9855
- await this._acquireReadLock();
9856
- try {
9857
- return await callback();
9858
- } finally {
9859
- await this._releaseReadLock();
9866
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js
9867
+ var NoopTracerProvider = (
9868
+ /** @class */
9869
+ function() {
9870
+ function NoopTracerProvider2() {
9860
9871
  }
9861
- }
9862
- async withWriteLock(callback) {
9863
- await this._acquireWriteLock();
9864
- try {
9865
- return await callback();
9866
- } finally {
9867
- await this._releaseWriteLock();
9872
+ NoopTracerProvider2.prototype.getTracer = function(_name, _version, _options) {
9873
+ return new NoopTracer();
9874
+ };
9875
+ return NoopTracerProvider2;
9876
+ }()
9877
+ );
9878
+
9879
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js
9880
+ var NOOP_TRACER_PROVIDER = new NoopTracerProvider();
9881
+ var ProxyTracerProvider = (
9882
+ /** @class */
9883
+ function() {
9884
+ function ProxyTracerProvider2() {
9868
9885
  }
9869
- }
9870
- async _acquireReadLock() {
9871
- await this.readersMutex.acquire();
9872
- try {
9873
- this.readers += 1;
9874
- if (this.readers === 1) await this.semaphore.acquire();
9875
- } finally {
9876
- this.readersMutex.release();
9886
+ ProxyTracerProvider2.prototype.getTracer = function(name, version, options) {
9887
+ var _a5;
9888
+ return (_a5 = this.getDelegateTracer(name, version, options)) !== null && _a5 !== void 0 ? _a5 : new ProxyTracer(this, name, version, options);
9889
+ };
9890
+ ProxyTracerProvider2.prototype.getDelegate = function() {
9891
+ var _a5;
9892
+ return (_a5 = this._delegate) !== null && _a5 !== void 0 ? _a5 : NOOP_TRACER_PROVIDER;
9893
+ };
9894
+ ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
9895
+ this._delegate = delegate;
9896
+ };
9897
+ ProxyTracerProvider2.prototype.getDelegateTracer = function(name, version, options) {
9898
+ var _a5;
9899
+ return (_a5 = this._delegate) === null || _a5 === void 0 ? void 0 : _a5.getTracer(name, version, options);
9900
+ };
9901
+ return ProxyTracerProvider2;
9902
+ }()
9903
+ );
9904
+
9905
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/trace.js
9906
+ var API_NAME3 = "trace";
9907
+ var TraceAPI = (
9908
+ /** @class */
9909
+ function() {
9910
+ function TraceAPI2() {
9911
+ this._proxyTracerProvider = new ProxyTracerProvider();
9912
+ this.wrapSpanContext = wrapSpanContext;
9913
+ this.isSpanContextValid = isSpanContextValid;
9914
+ this.deleteSpan = deleteSpan;
9915
+ this.getSpan = getSpan;
9916
+ this.getActiveSpan = getActiveSpan;
9917
+ this.getSpanContext = getSpanContext;
9918
+ this.setSpan = setSpan;
9919
+ this.setSpanContext = setSpanContext;
9877
9920
  }
9878
- }
9879
- async _releaseReadLock() {
9880
- await this.readersMutex.acquire();
9921
+ TraceAPI2.getInstance = function() {
9922
+ if (!this._instance) {
9923
+ this._instance = new TraceAPI2();
9924
+ }
9925
+ return this._instance;
9926
+ };
9927
+ TraceAPI2.prototype.setGlobalTracerProvider = function(provider) {
9928
+ var success = registerGlobal(API_NAME3, this._proxyTracerProvider, DiagAPI.instance());
9929
+ if (success) {
9930
+ this._proxyTracerProvider.setDelegate(provider);
9931
+ }
9932
+ return success;
9933
+ };
9934
+ TraceAPI2.prototype.getTracerProvider = function() {
9935
+ return getGlobal(API_NAME3) || this._proxyTracerProvider;
9936
+ };
9937
+ TraceAPI2.prototype.getTracer = function(name, version) {
9938
+ return this.getTracerProvider().getTracer(name, version);
9939
+ };
9940
+ TraceAPI2.prototype.disable = function() {
9941
+ unregisterGlobal(API_NAME3, DiagAPI.instance());
9942
+ this._proxyTracerProvider = new ProxyTracerProvider();
9943
+ };
9944
+ return TraceAPI2;
9945
+ }()
9946
+ );
9947
+
9948
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace-api.js
9949
+ var trace = TraceAPI.getInstance();
9950
+
9951
+ // ../shared/dist/esm/utils/telemetry.js
9952
+ var tracer = trace.getTracer("stack-tracer");
9953
+ async function traceSpan(optionsOrDescription, fn) {
9954
+ let options = typeof optionsOrDescription === "string" ? { description: optionsOrDescription } : optionsOrDescription;
9955
+ return await tracer.startActiveSpan(`STACK: ${options.description}`, async (span) => {
9956
+ if (options.attributes) for (const [key, value] of Object.entries(options.attributes)) span.setAttribute(key, value);
9881
9957
  try {
9882
- this.readers -= 1;
9883
- if (this.readers === 0) this.semaphore.release();
9958
+ return await fn(span);
9884
9959
  } finally {
9885
- this.readersMutex.release();
9960
+ span.end();
9886
9961
  }
9887
- }
9888
- async _acquireWriteLock() {
9889
- await this.semaphore.acquire();
9890
- }
9891
- async _releaseWriteLock() {
9892
- this.semaphore.release();
9893
- }
9894
- };
9895
-
9896
- // ../shared/dist/esm/utils/stores.js
9897
- var storeLock = new ReadWriteLock();
9898
-
9899
- // ../shared/dist/esm/interface/client-interface.js
9900
- var USER_AGENT;
9901
- if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) USER_AGENT = `oauth4webapi/v3.8.5`;
9902
- var ERR_INVALID_ARG_VALUE = "ERR_INVALID_ARG_VALUE";
9903
- function CodedTypeError(message2, code, cause) {
9904
- const err = new TypeError(message2, { cause });
9905
- Object.assign(err, { code });
9906
- return err;
9907
- }
9908
- var allowInsecureRequests = Symbol();
9909
- var clockSkew = Symbol();
9910
- var clockTolerance = Symbol();
9911
- var customFetch = Symbol();
9912
- var jweDecrypt = Symbol();
9913
- var encoder = new TextEncoder();
9914
- var decoder = new TextDecoder();
9915
- var encodeBase64Url;
9916
- if (Uint8Array.prototype.toBase64) encodeBase64Url = (input) => {
9917
- if (input instanceof ArrayBuffer) input = new Uint8Array(input);
9918
- return input.toBase64({
9919
- alphabet: "base64url",
9920
- omitPadding: true
9921
9962
  });
9922
- };
9923
- else {
9924
- const CHUNK_SIZE = 32768;
9925
- encodeBase64Url = (input) => {
9926
- if (input instanceof ArrayBuffer) input = new Uint8Array(input);
9927
- const arr = [];
9928
- for (let i = 0; i < input.byteLength; i += CHUNK_SIZE) arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
9929
- return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
9930
- };
9931
9963
  }
9932
- var decodeBase64Url;
9933
- if (Uint8Array.fromBase64) decodeBase64Url = (input) => {
9934
- try {
9935
- return Uint8Array.fromBase64(input, { alphabet: "base64url" });
9936
- } catch (cause) {
9937
- throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
9938
- }
9939
- };
9940
- else decodeBase64Url = (input) => {
9941
- try {
9942
- const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
9943
- const bytes = new Uint8Array(binary.length);
9944
- for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
9945
- return bytes;
9946
- } catch (cause) {
9947
- throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
9948
- }
9949
- };
9950
- var URLParse = URL.parse ? (url, base) => URL.parse(url, base) : (url, base) => {
9951
- try {
9952
- return new URL(url, base);
9953
- } catch {
9954
- return null;
9955
- }
9956
- };
9957
- var nopkce = Symbol();
9958
- var expectNoNonce = Symbol();
9959
- var skipAuthTimeCheck = Symbol();
9960
- var skipStateCheck = Symbol();
9961
- var expectNoState = Symbol();
9962
- var _expectedIssuer = Symbol();
9963
- var botChallengeKnownErrors = [KnownErrors.BotChallengeRequired, KnownErrors.BotChallengeFailed];
9964
9964
 
9965
9965
  // ../shared/dist/esm/utils/promises.js
9966
9966
  var neverResolvePromise = pending(new Promise(() => {