vlt
Version:
The vlt CLI
1,428 lines (1,421 loc) • 993 kB
JavaScript
var global = globalThis;
import {Buffer} from "node:buffer";
import {setTimeout,clearTimeout,setImmediate,clearImmediate,setInterval,clearInterval} from "node:timers";
import {createRequire as _vlt_createRequire} from "node:module";
var require = _vlt_createRequire(import.meta.filename);
import {
rimraf
} from "./chunk-KPA4XNCN.js";
import {
loadPackageJson
} from "./chunk-VYJVN3B6.js";
import {
LRUCache,
promiseSpawn,
which
} from "./chunk-B4MAUXR2.js";
import {
logRequest
} from "./chunk-O57KIW5U.js";
import {
asError
} from "./chunk-JBBINXAZ.js";
import {
XDG
} from "./chunk-BA67AKYJ.js";
import {
error
} from "./chunk-KVH5ECIG.js";
import {
__commonJS,
__require,
__toESM
} from "./chunk-AECDW3EJ.js";
// ../../node_modules/.pnpm/cache-control-parser@2.0.6/node_modules/cache-control-parser/dist/index.js
var require_dist = __commonJS({
"../../node_modules/.pnpm/cache-control-parser@2.0.6/node_modules/cache-control-parser/dist/index.js"(exports, module) {
!(function(e, t) {
"object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.cacheControl = t() : e.cacheControl = t();
})(exports, (function() {
return (function(e) {
var t = {};
function r(n) {
if (t[n]) return t[n].exports;
var o = t[n] = { i: n, l: false, exports: {} };
return e[n].call(o.exports, o, o.exports, r), o.l = true, o.exports;
}
return r.m = e, r.c = t, r.d = function(e2, t2, n) {
r.o(e2, t2) || Object.defineProperty(e2, t2, { enumerable: true, get: n });
}, r.r = function(e2) {
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e2, "__esModule", { value: true });
}, r.t = function(e2, t2) {
if (1 & t2 && (e2 = r(e2)), 8 & t2) return e2;
if (4 & t2 && "object" == typeof e2 && e2 && e2.__esModule) return e2;
var n = /* @__PURE__ */ Object.create(null);
if (r.r(n), Object.defineProperty(n, "default", { enumerable: true, value: e2 }), 2 & t2 && "string" != typeof e2) for (var o in e2) r.d(n, o, function(t3) {
return e2[t3];
}.bind(null, o));
return n;
}, r.n = function(e2) {
var t2 = e2 && e2.__esModule ? function() {
return e2.default;
} : function() {
return e2;
};
return r.d(t2, "a", t2), t2;
}, r.o = function(e2, t2) {
return Object.prototype.hasOwnProperty.call(e2, t2);
}, r.p = "", r(r.s = 1);
})([function(e, t) {
}, function(e, t, r) {
"use strict";
function n(e2) {
return (n = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e3) {
return typeof e3;
} : function(e3) {
return e3 && "function" == typeof Symbol && e3.constructor === Symbol && e3 !== Symbol.prototype ? "symbol" : typeof e3;
})(e2);
}
function o(e2, t2) {
return (function(e3) {
if (Array.isArray(e3)) return e3;
})(e2) || (function(e3, t3) {
if (!(Symbol.iterator in Object(e3) || "[object Arguments]" === Object.prototype.toString.call(e3))) return;
var r2 = [], n2 = true, o2 = false, a2 = void 0;
try {
for (var i2, u2 = e3[Symbol.iterator](); !(n2 = (i2 = u2.next()).done) && (r2.push(i2.value), !t3 || r2.length !== t3); n2 = true) ;
} catch (e4) {
o2 = true, a2 = e4;
} finally {
try {
n2 || null == u2.return || u2.return();
} finally {
if (o2) throw a2;
}
}
return r2;
})(e2, t2) || (function() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
})();
}
r.r(t);
var a = ["max-age", "s-maxage", "stale-while-revalidate", "stale-if-error", "public", "private", "no-store", "no-cache", "must-revalidate", "proxy-revalidate", "immutable", "no-transform"], i = function(e2) {
var t2 = {}, r2 = e2.toLowerCase().split(",").map((function(e3) {
return e3.trim().split("=").map((function(e4) {
return e4.trim();
}));
})), n2 = true, a2 = false, i2 = void 0;
try {
for (var u2, c2 = r2[Symbol.iterator](); !(n2 = (u2 = c2.next()).done); n2 = true) {
var l = o(u2.value, 2), f = l[0], s = l[1];
switch (f) {
case "max-age":
var p = parseInt(s, 10);
if (isNaN(p)) continue;
t2["max-age"] = p;
break;
case "s-maxage":
var b = parseInt(s, 10);
if (isNaN(b)) continue;
t2["s-maxage"] = b;
break;
case "stale-while-revalidate":
var y = parseInt(s, 10);
if (isNaN(y)) continue;
t2["stale-while-revalidate"] = y;
break;
case "stale-if-error":
var m = parseInt(s, 10);
if (isNaN(m)) continue;
t2["stale-if-error"] = m;
break;
case "public":
t2.public = true;
break;
case "private":
t2.private = true;
break;
case "no-store":
t2["no-store"] = true;
break;
case "no-cache":
t2["no-cache"] = true;
break;
case "must-revalidate":
t2["must-revalidate"] = true;
break;
case "proxy-revalidate":
t2["proxy-revalidate"] = true;
break;
case "immutable":
t2.immutable = true;
break;
case "no-transform":
t2["no-transform"] = true;
}
}
} catch (e3) {
a2 = true, i2 = e3;
} finally {
try {
n2 || null == c2.return || c2.return();
} finally {
if (a2) throw i2;
}
}
return t2;
}, u = function(e2) {
for (var t2 = [], r2 = 0, i2 = Object.entries(e2); r2 < i2.length; r2++) {
var u2 = o(i2[r2], 2), c2 = u2[0], l = u2[1];
if (a.includes(c2)) switch (n(l)) {
case "boolean":
l && t2.push("".concat(c2));
break;
case "number":
t2.push("".concat(c2, "=").concat(l));
}
}
return t2.join(", ");
}, c = r(0);
r.d(t, "parse", (function() {
return i;
})), r.d(t, "stringify", (function() {
return u;
})), r.d(t, "CacheControl", (function() {
return c.CacheControl;
}));
}]);
}));
}
});
// ../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/core/symbols.js
var require_symbols = __commonJS({
"../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/core/symbols.js"(exports, module) {
"use strict";
module.exports = {
kClose: Symbol("close"),
kDestroy: Symbol("destroy"),
kDispatch: Symbol("dispatch"),
kUrl: Symbol("url"),
kWriting: Symbol("writing"),
kResuming: Symbol("resuming"),
kQueue: Symbol("queue"),
kConnect: Symbol("connect"),
kConnecting: Symbol("connecting"),
kKeepAliveDefaultTimeout: Symbol("default keep alive timeout"),
kKeepAliveMaxTimeout: Symbol("max keep alive timeout"),
kKeepAliveTimeoutThreshold: Symbol("keep alive timeout threshold"),
kKeepAliveTimeoutValue: Symbol("keep alive timeout"),
kKeepAlive: Symbol("keep alive"),
kHeadersTimeout: Symbol("headers timeout"),
kBodyTimeout: Symbol("body timeout"),
kServerName: Symbol("server name"),
kLocalAddress: Symbol("local address"),
kHost: Symbol("host"),
kNoRef: Symbol("no ref"),
kBodyUsed: Symbol("used"),
kBody: Symbol("abstracted request body"),
kRunning: Symbol("running"),
kBlocking: Symbol("blocking"),
kPending: Symbol("pending"),
kSize: Symbol("size"),
kBusy: Symbol("busy"),
kQueued: Symbol("queued"),
kFree: Symbol("free"),
kConnected: Symbol("connected"),
kClosed: Symbol("closed"),
kNeedDrain: Symbol("need drain"),
kReset: Symbol("reset"),
kDestroyed: Symbol.for("nodejs.stream.destroyed"),
kResume: Symbol("resume"),
kOnError: Symbol("on error"),
kMaxHeadersSize: Symbol("max headers size"),
kRunningIdx: Symbol("running index"),
kPendingIdx: Symbol("pending index"),
kError: Symbol("error"),
kClients: Symbol("clients"),
kClient: Symbol("client"),
kParser: Symbol("parser"),
kOnDestroyed: Symbol("destroy callbacks"),
kPipelining: Symbol("pipelining"),
kSocket: Symbol("socket"),
kHostHeader: Symbol("host header"),
kConnector: Symbol("connector"),
kStrictContentLength: Symbol("strict content length"),
kMaxRedirections: Symbol("maxRedirections"),
kMaxRequests: Symbol("maxRequestsPerClient"),
kProxy: Symbol("proxy agent options"),
kCounter: Symbol("socket request counter"),
kMaxResponseSize: Symbol("max response size"),
kHTTP2Session: Symbol("http2Session"),
kHTTP2SessionState: Symbol("http2Session state"),
kRetryHandlerDefaultRetry: Symbol("retry agent default retry"),
kConstruct: Symbol("constructable"),
kListeners: Symbol("listeners"),
kHTTPContext: Symbol("http context"),
kMaxConcurrentStreams: Symbol("max concurrent streams"),
kNoProxyAgent: Symbol("no proxy agent"),
kHttpProxyAgent: Symbol("http proxy agent"),
kHttpsProxyAgent: Symbol("https proxy agent")
};
}
});
// ../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/util/timers.js
var require_timers = __commonJS({
"../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/util/timers.js"(exports, module) {
"use strict";
var fastNow = 0;
var RESOLUTION_MS = 1e3;
var TICK_MS = (RESOLUTION_MS >> 1) - 1;
var fastNowTimeout;
var kFastTimer = Symbol("kFastTimer");
var fastTimers = [];
var NOT_IN_LIST = -2;
var TO_BE_CLEARED = -1;
var PENDING = 0;
var ACTIVE = 1;
function onTick() {
fastNow += TICK_MS;
let idx = 0;
let len = fastTimers.length;
while (idx < len) {
const timer = fastTimers[idx];
if (timer._state === PENDING) {
timer._idleStart = fastNow - TICK_MS;
timer._state = ACTIVE;
} else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) {
timer._state = TO_BE_CLEARED;
timer._idleStart = -1;
timer._onTimeout(timer._timerArg);
}
if (timer._state === TO_BE_CLEARED) {
timer._state = NOT_IN_LIST;
if (--len !== 0) {
fastTimers[idx] = fastTimers[len];
}
} else {
++idx;
}
}
fastTimers.length = len;
if (fastTimers.length !== 0) {
refreshTimeout();
}
}
function refreshTimeout() {
if (fastNowTimeout?.refresh) {
fastNowTimeout.refresh();
} else {
clearTimeout(fastNowTimeout);
fastNowTimeout = setTimeout(onTick, TICK_MS);
fastNowTimeout?.unref();
}
}
var FastTimer = class {
[kFastTimer] = true;
/**
* The state of the timer, which can be one of the following:
* - NOT_IN_LIST (-2)
* - TO_BE_CLEARED (-1)
* - PENDING (0)
* - ACTIVE (1)
*
* @type {-2|-1|0|1}
* @private
*/
_state = NOT_IN_LIST;
/**
* The number of milliseconds to wait before calling the callback.
*
* @type {number}
* @private
*/
_idleTimeout = -1;
/**
* The time in milliseconds when the timer was started. This value is used to
* calculate when the timer should expire.
*
* @type {number}
* @default -1
* @private
*/
_idleStart = -1;
/**
* The function to be executed when the timer expires.
* @type {Function}
* @private
*/
_onTimeout;
/**
* The argument to be passed to the callback when the timer expires.
*
* @type {*}
* @private
*/
_timerArg;
/**
* @constructor
* @param {Function} callback A function to be executed after the timer
* expires.
* @param {number} delay The time, in milliseconds that the timer should wait
* before the specified function or code is executed.
* @param {*} arg
*/
constructor(callback, delay, arg) {
this._onTimeout = callback;
this._idleTimeout = delay;
this._timerArg = arg;
this.refresh();
}
/**
* Sets the timer's start time to the current time, and reschedules the timer
* to call its callback at the previously specified duration adjusted to the
* current time.
* Using this on a timer that has already called its callback will reactivate
* the timer.
*
* @returns {void}
*/
refresh() {
if (this._state === NOT_IN_LIST) {
fastTimers.push(this);
}
if (!fastNowTimeout || fastTimers.length === 1) {
refreshTimeout();
}
this._state = PENDING;
}
/**
* The `clear` method cancels the timer, preventing it from executing.
*
* @returns {void}
* @private
*/
clear() {
this._state = TO_BE_CLEARED;
this._idleStart = -1;
}
};
module.exports = {
/**
* The setTimeout() method sets a timer which executes a function once the
* timer expires.
* @param {Function} callback A function to be executed after the timer
* expires.
* @param {number} delay The time, in milliseconds that the timer should
* wait before the specified function or code is executed.
* @param {*} [arg] An optional argument to be passed to the callback function
* when the timer expires.
* @returns {NodeJS.Timeout|FastTimer}
*/
setTimeout(callback, delay, arg) {
return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg);
},
/**
* The clearTimeout method cancels an instantiated Timer previously created
* by calling setTimeout.
*
* @param {NodeJS.Timeout|FastTimer} timeout
*/
clearTimeout(timeout) {
if (timeout[kFastTimer]) {
timeout.clear();
} else {
clearTimeout(timeout);
}
},
/**
* The setFastTimeout() method sets a fastTimer which executes a function once
* the timer expires.
* @param {Function} callback A function to be executed after the timer
* expires.
* @param {number} delay The time, in milliseconds that the timer should
* wait before the specified function or code is executed.
* @param {*} [arg] An optional argument to be passed to the callback function
* when the timer expires.
* @returns {FastTimer}
*/
setFastTimeout(callback, delay, arg) {
return new FastTimer(callback, delay, arg);
},
/**
* The clearTimeout method cancels an instantiated FastTimer previously
* created by calling setFastTimeout.
*
* @param {FastTimer} timeout
*/
clearFastTimeout(timeout) {
timeout.clear();
},
/**
* The now method returns the value of the internal fast timer clock.
*
* @returns {number}
*/
now() {
return fastNow;
},
/**
* Trigger the onTick function to process the fastTimers array.
* Exported for testing purposes only.
* Marking as deprecated to discourage any use outside of testing.
* @deprecated
* @param {number} [delay=0] The delay in milliseconds to add to the now value.
*/
tick(delay = 0) {
fastNow += delay - RESOLUTION_MS + 1;
onTick();
onTick();
},
/**
* Reset FastTimers.
* Exported for testing purposes only.
* Marking as deprecated to discourage any use outside of testing.
* @deprecated
*/
reset() {
fastNow = 0;
fastTimers.length = 0;
clearTimeout(fastNowTimeout);
fastNowTimeout = null;
},
/**
* Exporting for testing purposes only.
* Marking as deprecated to discourage any use outside of testing.
* @deprecated
*/
kFastTimer
};
}
});
// ../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/core/errors.js
var require_errors = __commonJS({
"../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/core/errors.js"(exports, module) {
"use strict";
var kUndiciError = Symbol.for("undici.error.UND_ERR");
var UndiciError = class extends Error {
constructor(message, options) {
super(message, options);
this.name = "UndiciError";
this.code = "UND_ERR";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kUndiciError] === true;
}
get [kUndiciError]() {
return true;
}
};
var kConnectTimeoutError = Symbol.for("undici.error.UND_ERR_CONNECT_TIMEOUT");
var ConnectTimeoutError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "ConnectTimeoutError";
this.message = message || "Connect Timeout Error";
this.code = "UND_ERR_CONNECT_TIMEOUT";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kConnectTimeoutError] === true;
}
get [kConnectTimeoutError]() {
return true;
}
};
var kHeadersTimeoutError = Symbol.for("undici.error.UND_ERR_HEADERS_TIMEOUT");
var HeadersTimeoutError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "HeadersTimeoutError";
this.message = message || "Headers Timeout Error";
this.code = "UND_ERR_HEADERS_TIMEOUT";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kHeadersTimeoutError] === true;
}
get [kHeadersTimeoutError]() {
return true;
}
};
var kHeadersOverflowError = Symbol.for("undici.error.UND_ERR_HEADERS_OVERFLOW");
var HeadersOverflowError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "HeadersOverflowError";
this.message = message || "Headers Overflow Error";
this.code = "UND_ERR_HEADERS_OVERFLOW";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kHeadersOverflowError] === true;
}
get [kHeadersOverflowError]() {
return true;
}
};
var kBodyTimeoutError = Symbol.for("undici.error.UND_ERR_BODY_TIMEOUT");
var BodyTimeoutError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "BodyTimeoutError";
this.message = message || "Body Timeout Error";
this.code = "UND_ERR_BODY_TIMEOUT";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kBodyTimeoutError] === true;
}
get [kBodyTimeoutError]() {
return true;
}
};
var kInvalidArgumentError = Symbol.for("undici.error.UND_ERR_INVALID_ARG");
var InvalidArgumentError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "InvalidArgumentError";
this.message = message || "Invalid Argument Error";
this.code = "UND_ERR_INVALID_ARG";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kInvalidArgumentError] === true;
}
get [kInvalidArgumentError]() {
return true;
}
};
var kInvalidReturnValueError = Symbol.for("undici.error.UND_ERR_INVALID_RETURN_VALUE");
var InvalidReturnValueError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "InvalidReturnValueError";
this.message = message || "Invalid Return Value Error";
this.code = "UND_ERR_INVALID_RETURN_VALUE";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kInvalidReturnValueError] === true;
}
get [kInvalidReturnValueError]() {
return true;
}
};
var kAbortError = Symbol.for("undici.error.UND_ERR_ABORT");
var AbortError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "AbortError";
this.message = message || "The operation was aborted";
this.code = "UND_ERR_ABORT";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kAbortError] === true;
}
get [kAbortError]() {
return true;
}
};
var kRequestAbortedError = Symbol.for("undici.error.UND_ERR_ABORTED");
var RequestAbortedError = class extends AbortError {
constructor(message) {
super(message);
this.name = "AbortError";
this.message = message || "Request aborted";
this.code = "UND_ERR_ABORTED";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kRequestAbortedError] === true;
}
get [kRequestAbortedError]() {
return true;
}
};
var kInformationalError = Symbol.for("undici.error.UND_ERR_INFO");
var InformationalError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "InformationalError";
this.message = message || "Request information";
this.code = "UND_ERR_INFO";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kInformationalError] === true;
}
get [kInformationalError]() {
return true;
}
};
var kRequestContentLengthMismatchError = Symbol.for("undici.error.UND_ERR_REQ_CONTENT_LENGTH_MISMATCH");
var RequestContentLengthMismatchError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "RequestContentLengthMismatchError";
this.message = message || "Request body length does not match content-length header";
this.code = "UND_ERR_REQ_CONTENT_LENGTH_MISMATCH";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kRequestContentLengthMismatchError] === true;
}
get [kRequestContentLengthMismatchError]() {
return true;
}
};
var kResponseContentLengthMismatchError = Symbol.for("undici.error.UND_ERR_RES_CONTENT_LENGTH_MISMATCH");
var ResponseContentLengthMismatchError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "ResponseContentLengthMismatchError";
this.message = message || "Response body length does not match content-length header";
this.code = "UND_ERR_RES_CONTENT_LENGTH_MISMATCH";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kResponseContentLengthMismatchError] === true;
}
get [kResponseContentLengthMismatchError]() {
return true;
}
};
var kClientDestroyedError = Symbol.for("undici.error.UND_ERR_DESTROYED");
var ClientDestroyedError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "ClientDestroyedError";
this.message = message || "The client is destroyed";
this.code = "UND_ERR_DESTROYED";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kClientDestroyedError] === true;
}
get [kClientDestroyedError]() {
return true;
}
};
var kClientClosedError = Symbol.for("undici.error.UND_ERR_CLOSED");
var ClientClosedError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "ClientClosedError";
this.message = message || "The client is closed";
this.code = "UND_ERR_CLOSED";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kClientClosedError] === true;
}
get [kClientClosedError]() {
return true;
}
};
var kSocketError = Symbol.for("undici.error.UND_ERR_SOCKET");
var SocketError = class extends UndiciError {
constructor(message, socket) {
super(message);
this.name = "SocketError";
this.message = message || "Socket error";
this.code = "UND_ERR_SOCKET";
this.socket = socket;
}
static [Symbol.hasInstance](instance) {
return instance && instance[kSocketError] === true;
}
get [kSocketError]() {
return true;
}
};
var kNotSupportedError = Symbol.for("undici.error.UND_ERR_NOT_SUPPORTED");
var NotSupportedError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "NotSupportedError";
this.message = message || "Not supported error";
this.code = "UND_ERR_NOT_SUPPORTED";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kNotSupportedError] === true;
}
get [kNotSupportedError]() {
return true;
}
};
var kBalancedPoolMissingUpstreamError = Symbol.for("undici.error.UND_ERR_BPL_MISSING_UPSTREAM");
var BalancedPoolMissingUpstreamError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "MissingUpstreamError";
this.message = message || "No upstream has been added to the BalancedPool";
this.code = "UND_ERR_BPL_MISSING_UPSTREAM";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kBalancedPoolMissingUpstreamError] === true;
}
get [kBalancedPoolMissingUpstreamError]() {
return true;
}
};
var kHTTPParserError = Symbol.for("undici.error.UND_ERR_HTTP_PARSER");
var HTTPParserError = class extends Error {
constructor(message, code, data) {
super(message);
this.name = "HTTPParserError";
this.code = code ? `HPE_${code}` : void 0;
this.data = data ? data.toString() : void 0;
}
static [Symbol.hasInstance](instance) {
return instance && instance[kHTTPParserError] === true;
}
get [kHTTPParserError]() {
return true;
}
};
var kResponseExceededMaxSizeError = Symbol.for("undici.error.UND_ERR_RES_EXCEEDED_MAX_SIZE");
var ResponseExceededMaxSizeError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "ResponseExceededMaxSizeError";
this.message = message || "Response content exceeded max size";
this.code = "UND_ERR_RES_EXCEEDED_MAX_SIZE";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kResponseExceededMaxSizeError] === true;
}
get [kResponseExceededMaxSizeError]() {
return true;
}
};
var kRequestRetryError = Symbol.for("undici.error.UND_ERR_REQ_RETRY");
var RequestRetryError = class extends UndiciError {
constructor(message, code, { headers, data }) {
super(message);
this.name = "RequestRetryError";
this.message = message || "Request retry error";
this.code = "UND_ERR_REQ_RETRY";
this.statusCode = code;
this.data = data;
this.headers = headers;
}
static [Symbol.hasInstance](instance) {
return instance && instance[kRequestRetryError] === true;
}
get [kRequestRetryError]() {
return true;
}
};
var kResponseError = Symbol.for("undici.error.UND_ERR_RESPONSE");
var ResponseError = class extends UndiciError {
constructor(message, code, { headers, body }) {
super(message);
this.name = "ResponseError";
this.message = message || "Response error";
this.code = "UND_ERR_RESPONSE";
this.statusCode = code;
this.body = body;
this.headers = headers;
}
static [Symbol.hasInstance](instance) {
return instance && instance[kResponseError] === true;
}
get [kResponseError]() {
return true;
}
};
var kSecureProxyConnectionError = Symbol.for("undici.error.UND_ERR_PRX_TLS");
var SecureProxyConnectionError = class extends UndiciError {
constructor(cause, message, options = {}) {
super(message, { cause, ...options });
this.name = "SecureProxyConnectionError";
this.message = message || "Secure Proxy Connection failed";
this.code = "UND_ERR_PRX_TLS";
this.cause = cause;
}
static [Symbol.hasInstance](instance) {
return instance && instance[kSecureProxyConnectionError] === true;
}
get [kSecureProxyConnectionError]() {
return true;
}
};
var kMaxOriginsReachedError = Symbol.for("undici.error.UND_ERR_MAX_ORIGINS_REACHED");
var MaxOriginsReachedError = class extends UndiciError {
constructor(message) {
super(message);
this.name = "MaxOriginsReachedError";
this.message = message || "Maximum allowed origins reached";
this.code = "UND_ERR_MAX_ORIGINS_REACHED";
}
static [Symbol.hasInstance](instance) {
return instance && instance[kMaxOriginsReachedError] === true;
}
get [kMaxOriginsReachedError]() {
return true;
}
};
module.exports = {
AbortError,
HTTPParserError,
UndiciError,
HeadersTimeoutError,
HeadersOverflowError,
BodyTimeoutError,
RequestContentLengthMismatchError,
ConnectTimeoutError,
InvalidArgumentError,
InvalidReturnValueError,
RequestAbortedError,
ClientDestroyedError,
ClientClosedError,
InformationalError,
SocketError,
NotSupportedError,
ResponseContentLengthMismatchError,
BalancedPoolMissingUpstreamError,
ResponseExceededMaxSizeError,
RequestRetryError,
ResponseError,
SecureProxyConnectionError,
MaxOriginsReachedError
};
}
});
// ../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/core/constants.js
var require_constants = __commonJS({
"../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/core/constants.js"(exports, module) {
"use strict";
var wellknownHeaderNames = (
/** @type {const} */
[
"Accept",
"Accept-Encoding",
"Accept-Language",
"Accept-Ranges",
"Access-Control-Allow-Credentials",
"Access-Control-Allow-Headers",
"Access-Control-Allow-Methods",
"Access-Control-Allow-Origin",
"Access-Control-Expose-Headers",
"Access-Control-Max-Age",
"Access-Control-Request-Headers",
"Access-Control-Request-Method",
"Age",
"Allow",
"Alt-Svc",
"Alt-Used",
"Authorization",
"Cache-Control",
"Clear-Site-Data",
"Connection",
"Content-Disposition",
"Content-Encoding",
"Content-Language",
"Content-Length",
"Content-Location",
"Content-Range",
"Content-Security-Policy",
"Content-Security-Policy-Report-Only",
"Content-Type",
"Cookie",
"Cross-Origin-Embedder-Policy",
"Cross-Origin-Opener-Policy",
"Cross-Origin-Resource-Policy",
"Date",
"Device-Memory",
"Downlink",
"ECT",
"ETag",
"Expect",
"Expect-CT",
"Expires",
"Forwarded",
"From",
"Host",
"If-Match",
"If-Modified-Since",
"If-None-Match",
"If-Range",
"If-Unmodified-Since",
"Keep-Alive",
"Last-Modified",
"Link",
"Location",
"Max-Forwards",
"Origin",
"Permissions-Policy",
"Pragma",
"Proxy-Authenticate",
"Proxy-Authorization",
"RTT",
"Range",
"Referer",
"Referrer-Policy",
"Refresh",
"Retry-After",
"Sec-WebSocket-Accept",
"Sec-WebSocket-Extensions",
"Sec-WebSocket-Key",
"Sec-WebSocket-Protocol",
"Sec-WebSocket-Version",
"Server",
"Server-Timing",
"Service-Worker-Allowed",
"Service-Worker-Navigation-Preload",
"Set-Cookie",
"SourceMap",
"Strict-Transport-Security",
"Supports-Loading-Mode",
"TE",
"Timing-Allow-Origin",
"Trailer",
"Transfer-Encoding",
"Upgrade",
"Upgrade-Insecure-Requests",
"User-Agent",
"Vary",
"Via",
"WWW-Authenticate",
"X-Content-Type-Options",
"X-DNS-Prefetch-Control",
"X-Frame-Options",
"X-Permitted-Cross-Domain-Policies",
"X-Powered-By",
"X-Requested-With",
"X-XSS-Protection"
]
);
var headerNameLowerCasedRecord = {};
Object.setPrototypeOf(headerNameLowerCasedRecord, null);
var wellknownHeaderNameBuffers = {};
Object.setPrototypeOf(wellknownHeaderNameBuffers, null);
function getHeaderNameAsBuffer(header) {
let buffer = wellknownHeaderNameBuffers[header];
if (buffer === void 0) {
buffer = Buffer.from(header);
}
return buffer;
}
for (let i = 0; i < wellknownHeaderNames.length; ++i) {
const key = wellknownHeaderNames[i];
const lowerCasedKey = key.toLowerCase();
headerNameLowerCasedRecord[key] = headerNameLowerCasedRecord[lowerCasedKey] = lowerCasedKey;
}
module.exports = {
wellknownHeaderNames,
headerNameLowerCasedRecord,
getHeaderNameAsBuffer
};
}
});
// ../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/core/tree.js
var require_tree = __commonJS({
"../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/core/tree.js"(exports, module) {
"use strict";
var {
wellknownHeaderNames,
headerNameLowerCasedRecord
} = require_constants();
var TstNode = class _TstNode {
/** @type {any} */
value = null;
/** @type {null | TstNode} */
left = null;
/** @type {null | TstNode} */
middle = null;
/** @type {null | TstNode} */
right = null;
/** @type {number} */
code;
/**
* @param {string} key
* @param {any} value
* @param {number} index
*/
constructor(key, value, index) {
if (index === void 0 || index >= key.length) {
throw new TypeError("Unreachable");
}
const code = this.code = key.charCodeAt(index);
if (code > 127) {
throw new TypeError("key must be ascii string");
}
if (key.length !== ++index) {
this.middle = new _TstNode(key, value, index);
} else {
this.value = value;
}
}
/**
* @param {string} key
* @param {any} value
* @returns {void}
*/
add(key, value) {
const length = key.length;
if (length === 0) {
throw new TypeError("Unreachable");
}
let index = 0;
let node2 = this;
while (true) {
const code = key.charCodeAt(index);
if (code > 127) {
throw new TypeError("key must be ascii string");
}
if (node2.code === code) {
if (length === ++index) {
node2.value = value;
break;
} else if (node2.middle !== null) {
node2 = node2.middle;
} else {
node2.middle = new _TstNode(key, value, index);
break;
}
} else if (node2.code < code) {
if (node2.left !== null) {
node2 = node2.left;
} else {
node2.left = new _TstNode(key, value, index);
break;
}
} else if (node2.right !== null) {
node2 = node2.right;
} else {
node2.right = new _TstNode(key, value, index);
break;
}
}
}
/**
* @param {Uint8Array} key
* @returns {TstNode | null}
*/
search(key) {
const keylength = key.length;
let index = 0;
let node2 = this;
while (node2 !== null && index < keylength) {
let code = key[index];
if (code <= 90 && code >= 65) {
code |= 32;
}
while (node2 !== null) {
if (code === node2.code) {
if (keylength === ++index) {
return node2;
}
node2 = node2.middle;
break;
}
node2 = node2.code < code ? node2.left : node2.right;
}
}
return null;
}
};
var TernarySearchTree = class {
/** @type {TstNode | null} */
node = null;
/**
* @param {string} key
* @param {any} value
* @returns {void}
* */
insert(key, value) {
if (this.node === null) {
this.node = new TstNode(key, value, 0);
} else {
this.node.add(key, value);
}
}
/**
* @param {Uint8Array} key
* @returns {any}
*/
lookup(key) {
return this.node?.search(key)?.value ?? null;
}
};
var tree = new TernarySearchTree();
for (let i = 0; i < wellknownHeaderNames.length; ++i) {
const key = headerNameLowerCasedRecord[wellknownHeaderNames[i]];
tree.insert(key, key);
}
module.exports = {
TernarySearchTree,
tree
};
}
});
// ../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/core/util.js
var require_util = __commonJS({
"../../node_modules/.pnpm/undici@7.16.0/node_modules/undici/lib/core/util.js"(exports, module) {
"use strict";
var assert = __require("node:assert");
var { kDestroyed, kBodyUsed, kListeners, kBody } = require_symbols();
var { IncomingMessage } = __require("node:http");
var stream = __require("node:stream");
var net = __require("node:net");
var { stringify } = __require("node:querystring");
var { EventEmitter: EE } = __require("node:events");
var timers = require_timers();
var { InvalidArgumentError, ConnectTimeoutError } = require_errors();
var { headerNameLowerCasedRecord } = require_constants();
var { tree } = require_tree();
var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v));
var BodyAsyncIterable = class {
constructor(body) {
this[kBody] = body;
this[kBodyUsed] = false;
}
async *[Symbol.asyncIterator]() {
assert(!this[kBodyUsed], "disturbed");
this[kBodyUsed] = true;
yield* this[kBody];
}
};
function noop() {
}
function wrapRequestBody(body) {
if (isStream(body)) {
if (bodyLength(body) === 0) {
body.on("data", function() {
assert(false);
});
}
if (typeof body.readableDidRead !== "boolean") {
body[kBodyUsed] = false;
EE.prototype.on.call(body, "data", function() {
this[kBodyUsed] = true;
});
}
return body;
} else if (body && typeof body.pipeTo === "function") {
return new BodyAsyncIterable(body);
} else if (body && typeof body !== "string" && !ArrayBuffer.isView(body) && isIterable2(body)) {
return new BodyAsyncIterable(body);
} else {
return body;
}
}
function isStream(obj) {
return obj && typeof obj === "object" && typeof obj.pipe === "function" && typeof obj.on === "function";
}
function isBlobLike(object) {
if (object === null) {
return false;
} else if (object instanceof Blob) {
return true;
} else if (typeof object !== "object") {
return false;
} else {
const sTag = object[Symbol.toStringTag];
return (sTag === "Blob" || sTag === "File") && ("stream" in object && typeof object.stream === "function" || "arrayBuffer" in object && typeof object.arrayBuffer === "function");
}
}
function pathHasQueryOrFragment(url) {
return url.includes("?") || url.includes("#");
}
function serializePathWithQuery(url, queryParams) {
if (pathHasQueryOrFragment(url)) {
throw new Error('Query params cannot be passed when url already contains "?" or "#".');
}
const stringified = stringify(queryParams);
if (stringified) {
url += "?" + stringified;
}
return url;
}
function isValidPort(port) {
const value = parseInt(port, 10);
return value === Number(port) && value >= 0 && value <= 65535;
}
function isHttpOrHttpsPrefixed(value) {
return value != null && value[0] === "h" && value[1] === "t" && value[2] === "t" && value[3] === "p" && (value[4] === ":" || value[4] === "s" && value[5] === ":");
}
function parseURL(url) {
if (typeof url === "string") {
url = new URL(url);
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
}
return url;
}
if (!url || typeof url !== "object") {
throw new InvalidArgumentError("Invalid URL: The URL argument must be a non-null object.");
}
if (!(url instanceof URL)) {
if (url.port != null && url.port !== "" && isValidPort(url.port) === false) {
throw new InvalidArgumentError("Invalid URL: port must be a valid integer or a string representation of an integer.");
}
if (url.path != null && typeof url.path !== "string") {
throw new InvalidArgumentError("Invalid URL path: the path must be a string or null/undefined.");
}
if (url.pathname != null && typeof url.pathname !== "string") {
throw new InvalidArgumentError("Invalid URL pathname: the pathname must be a string or null/undefined.");
}
if (url.hostname != null && typeof url.hostname !== "string") {
throw new InvalidArgumentError("Invalid URL hostname: the hostname must be a string or null/undefined.");
}
if (url.origin != null && typeof url.origin !== "string") {
throw new InvalidArgumentError("Invalid URL origin: the origin must be a string or null/undefined.");
}
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
}
const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
let origin = url.origin != null ? url.origin : `${url.protocol || ""}//${url.hostname || ""}:${port}`;
let path = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
if (origin[origin.length - 1] === "/") {
origin = origin.slice(0, origin.length - 1);
}
if (path && path[0] !== "/") {
path = `/${path}`;
}
return new URL(`${origin}${path}`);
}
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
}
return url;
}
function parseOrigin(url) {
url = parseURL(url);
if (url.pathname !== "/" || url.search || url.hash) {
throw new InvalidArgumentError("invalid url");
}
return url;
}
function getHostname(host) {
if (host[0] === "[") {
const idx2 = host.indexOf("]");
assert(idx2 !== -1);
return host.substring(1, idx2);
}
const idx = host.indexOf(":");
if (idx === -1) return host;
return host.substring(0, idx);
}
function getServerName(host) {
if (!host) {
return null;
}
assert(typeof host === "string");
const servername = getHostname(host);
if (net.isIP(servername)) {
return "";
}
return servername;
}
function deepClone(obj) {
return JSON.parse(JSON.stringify(obj));
}
function isAsyncIterable(obj) {
return !!(obj != null && typeof obj[Symbol.asyncIterator] === "function");
}
function isIterable2(obj) {
return !!(obj != null && (typeof obj[Symbol.iterator] === "function" || typeof obj[Symbol.asyncIterator] === "function"));
}
function bodyLength(body) {
if (body == null) {
return 0;
} else if (isStream(body)) {
const state = body._readableState;
return state && state.objectMode === false && state.ended === true && Number.isFinite(state.length) ? state.length : null;
} else if (isBlobLike(body)) {
return body.size != null ? body.size : null;
} else if (isBuffer(body)) {
return body.byteLength;
}
return null;
}
function isDestroyed(body) {
return body && !!(body.destroyed || body[kDestroyed] || stream.isDestroyed?.(body));
}
function destroy(stream2, err) {
if (stream2 == null || !isStream(stream2) || isDestroyed(stream2)) {
return;
}
if (typeof stream2.destroy === "function") {
if (Object.getPrototypeOf(stream2).constructor === IncomingMessage) {
stream2.socket = null;
}
stream2.destroy(err);
} else if (err) {
queueMicrotask(() => {
stream2.emit("error", err);
});
}
if (stream2.destroyed !== true) {
stream2[kDestroyed] = true;
}
}
var KEEPALIVE_TIMEOUT_EXPR = /timeout=(\d+)/;
function parseKeepAliveTimeout(val) {
const m = val.match(KEEPALIVE_TIMEOUT_EXPR);
return m ? parseInt(m[1], 10) * 1e3 : null;
}
function headerNameToString(value) {
return typeof value === "string" ? headerNameLowerCasedRecord[value] ?? value.toLowerCase() : tree.lookup(value) ?? value.toString("latin1").toLowerCase();
}
function bufferToLowerCasedHeaderName(value) {
return tree.lookup(value) ?? value.toString("latin1").toLowerCase();
}
function parseHeaders(headers, obj) {
if (obj === void 0) obj = {};
for (let i = 0; i < headers.length; i += 2) {
const key = headerNameToString(headers[i]);
let val = obj[key];
if (val) {
if (typeof val === "string") {
val = [val];
obj[key] = val;
}
val.push(headers[i + 1].toString("utf8"));
} else {
const headersValue = headers[i + 1];
if (typeof headersValue === "string") {
obj[key] = headersValue;
} else {
obj[key] = Array.isArray(headersValue) ? headersValue.map((x) => x.toString("utf8")) : headersValue.toString("utf8");
}
}
}
if ("content-length" in obj && "content-disposition" in obj) {
obj["content-disposition"] = Buffer.from(obj["content-disposition"]).toString("latin1");
}
return obj;
}
function parseRawHeaders(headers) {
const headersLength = headers.length;
const ret = new Array(headersLength);
let hasContentLength = false;
let contentDispositionIdx = -1;
let key;
let val;
let kLen = 0;
for (let n = 0; n < headersLength; n += 2) {
key = headers[n];
val = headers[n + 1];
typeof key !== "string" && (key = key.toString());
typeof val !== "string" && (val = val.toString("utf8"));
kLen = key.length;
if (kLen === 14 && key[7] === "-" && (key === "content-length" || key.toLowerCase() === "content-length")) {
hasContentLength = true;
} else if (kLen === 19 && key[7] === "-" && (key === "content-disposition" || key.toLowerCase() === "content-disposition")) {
contentDispositionIdx = n + 1;
}
ret[n] = key;
ret[n + 1] = val;
}
if (hasContentLength && contentDispositionIdx !== -1) {
ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString("latin1");
}
return ret;
}
function encodeRawHeaders(headers) {
if (!Array.isArray(headers)) {
throw new TypeError("expected headers to be an array");
}
return headers.map((x) => Buffer.from(x));
}
function isBuffer(buffer) {
return buffer instanceof Uint8Array || Buffer.isBuffer(buffer);
}
function assertRequestHandler(handler, method, upgrade) {
if (!handler || typeof handler !== "object") {
throw new InvalidArgumentError("handler must be an object");
}
if (typ