wrangler
Version:
Command-line interface for all things Cloudflare Workers
1,409 lines (1,398 loc) • 5.67 MB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb2, mod) => function __require() {
return mod || (0, cb2[__getOwnPropNames(cb2)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all2) => {
for (var name2 in all2)
__defProp(target, name2, { get: all2[name2], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// import_meta_url.js
var import_meta_url;
var init_import_meta_url = __esm({
"import_meta_url.js"() {
import_meta_url = require("url").pathToFileURL(__filename);
}
});
// ../../node_modules/.pnpm/undici@5.28.5/node_modules/undici/lib/core/symbols.js
var require_symbols = __commonJS({
"../../node_modules/.pnpm/undici@5.28.5/node_modules/undici/lib/core/symbols.js"(exports2, module3) {
init_import_meta_url();
module3.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"),
kHeadersList: Symbol("headers list"),
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"),
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"),
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"),
kInterceptors: Symbol("dispatch interceptors"),
kMaxResponseSize: Symbol("max response size"),
kHTTP2Session: Symbol("http2Session"),
kHTTP2SessionState: Symbol("http2Session state"),
kHTTP2BuildRequest: Symbol("http2 build request"),
kHTTP1BuildRequest: Symbol("http1 build request"),
kHTTP2CopyHeaders: Symbol("http2 copy headers"),
kHTTPConnVersion: Symbol("http connection version"),
kRetryHandlerDefaultRetry: Symbol("retry agent default retry"),
kConstruct: Symbol("constructable")
};
}
});
// ../../node_modules/.pnpm/undici@5.28.5/node_modules/undici/lib/core/errors.js
var require_errors = __commonJS({
"../../node_modules/.pnpm/undici@5.28.5/node_modules/undici/lib/core/errors.js"(exports2, module3) {
"use strict";
init_import_meta_url();
var UndiciError = class extends Error {
static {
__name(this, "UndiciError");
}
constructor(message) {
super(message);
this.name = "UndiciError";
this.code = "UND_ERR";
}
};
var ConnectTimeoutError = class _ConnectTimeoutError extends UndiciError {
static {
__name(this, "ConnectTimeoutError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, _ConnectTimeoutError);
this.name = "ConnectTimeoutError";
this.message = message || "Connect Timeout Error";
this.code = "UND_ERR_CONNECT_TIMEOUT";
}
};
var HeadersTimeoutError = class _HeadersTimeoutError extends UndiciError {
static {
__name(this, "HeadersTimeoutError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, _HeadersTimeoutError);
this.name = "HeadersTimeoutError";
this.message = message || "Headers Timeout Error";
this.code = "UND_ERR_HEADERS_TIMEOUT";
}
};
var HeadersOverflowError = class _HeadersOverflowError extends UndiciError {
static {
__name(this, "HeadersOverflowError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, _HeadersOverflowError);
this.name = "HeadersOverflowError";
this.message = message || "Headers Overflow Error";
this.code = "UND_ERR_HEADERS_OVERFLOW";
}
};
var BodyTimeoutError = class _BodyTimeoutError extends UndiciError {
static {
__name(this, "BodyTimeoutError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, _BodyTimeoutError);
this.name = "BodyTimeoutError";
this.message = message || "Body Timeout Error";
this.code = "UND_ERR_BODY_TIMEOUT";
}
};
var ResponseStatusCodeError = class _ResponseStatusCodeError extends UndiciError {
static {
__name(this, "ResponseStatusCodeError");
}
constructor(message, statusCode, headers, body) {
super(message);
Error.captureStackTrace(this, _ResponseStatusCodeError);
this.name = "ResponseStatusCodeError";
this.message = message || "Response Status Code Error";
this.code = "UND_ERR_RESPONSE_STATUS_CODE";
this.body = body;
this.status = statusCode;
this.statusCode = statusCode;
this.headers = headers;
}
};
var InvalidArgumentError = class _InvalidArgumentError extends UndiciError {
static {
__name(this, "InvalidArgumentError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, _InvalidArgumentError);
this.name = "InvalidArgumentError";
this.message = message || "Invalid Argument Error";
this.code = "UND_ERR_INVALID_ARG";
}
};
var InvalidReturnValueError = class _InvalidReturnValueError extends UndiciError {
static {
__name(this, "InvalidReturnValueError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, _InvalidReturnValueError);
this.name = "InvalidReturnValueError";
this.message = message || "Invalid Return Value Error";
this.code = "UND_ERR_INVALID_RETURN_VALUE";
}
};
var RequestAbortedError = class _RequestAbortedError extends UndiciError {
static {
__name(this, "RequestAbortedError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, _RequestAbortedError);
this.name = "AbortError";
this.message = message || "Request aborted";
this.code = "UND_ERR_ABORTED";
}
};
var InformationalError = class _InformationalError extends UndiciError {
static {
__name(this, "InformationalError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, _InformationalError);
this.name = "InformationalError";
this.message = message || "Request information";
this.code = "UND_ERR_INFO";
}
};
var RequestContentLengthMismatchError = class _RequestContentLengthMismatchError extends UndiciError {
static {
__name(this, "RequestContentLengthMismatchError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, _RequestContentLengthMismatchError);
this.name = "RequestContentLengthMismatchError";
this.message = message || "Request body length does not match content-length header";
this.code = "UND_ERR_REQ_CONTENT_LENGTH_MISMATCH";
}
};
var ResponseContentLengthMismatchError = class _ResponseContentLengthMismatchError extends UndiciError {
static {
__name(this, "ResponseContentLengthMismatchError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, _ResponseContentLengthMismatchError);
this.name = "ResponseContentLengthMismatchError";
this.message = message || "Response body length does not match content-length header";
this.code = "UND_ERR_RES_CONTENT_LENGTH_MISMATCH";
}
};
var ClientDestroyedError = class _ClientDestroyedError extends UndiciError {
static {
__name(this, "ClientDestroyedError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, _ClientDestroyedError);
this.name = "ClientDestroyedError";
this.message = message || "The client is destroyed";
this.code = "UND_ERR_DESTROYED";
}
};
var ClientClosedError = class _ClientClosedError extends UndiciError {
static {
__name(this, "ClientClosedError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, _ClientClosedError);
this.name = "ClientClosedError";
this.message = message || "The client is closed";
this.code = "UND_ERR_CLOSED";
}
};
var SocketError = class _SocketError extends UndiciError {
static {
__name(this, "SocketError");
}
constructor(message, socket) {
super(message);
Error.captureStackTrace(this, _SocketError);
this.name = "SocketError";
this.message = message || "Socket error";
this.code = "UND_ERR_SOCKET";
this.socket = socket;
}
};
var NotSupportedError = class _NotSupportedError extends UndiciError {
static {
__name(this, "NotSupportedError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, _NotSupportedError);
this.name = "NotSupportedError";
this.message = message || "Not supported error";
this.code = "UND_ERR_NOT_SUPPORTED";
}
};
var BalancedPoolMissingUpstreamError = class extends UndiciError {
static {
__name(this, "BalancedPoolMissingUpstreamError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, NotSupportedError);
this.name = "MissingUpstreamError";
this.message = message || "No upstream has been added to the BalancedPool";
this.code = "UND_ERR_BPL_MISSING_UPSTREAM";
}
};
var HTTPParserError = class _HTTPParserError extends Error {
static {
__name(this, "HTTPParserError");
}
constructor(message, code, data) {
super(message);
Error.captureStackTrace(this, _HTTPParserError);
this.name = "HTTPParserError";
this.code = code ? `HPE_${code}` : void 0;
this.data = data ? data.toString() : void 0;
}
};
var ResponseExceededMaxSizeError = class _ResponseExceededMaxSizeError extends UndiciError {
static {
__name(this, "ResponseExceededMaxSizeError");
}
constructor(message) {
super(message);
Error.captureStackTrace(this, _ResponseExceededMaxSizeError);
this.name = "ResponseExceededMaxSizeError";
this.message = message || "Response content exceeded max size";
this.code = "UND_ERR_RES_EXCEEDED_MAX_SIZE";
}
};
var RequestRetryError = class _RequestRetryError extends UndiciError {
static {
__name(this, "RequestRetryError");
}
constructor(message, code, { headers, data }) {
super(message);
Error.captureStackTrace(this, _RequestRetryError);
this.name = "RequestRetryError";
this.message = message || "Request retry error";
this.code = "UND_ERR_REQ_RETRY";
this.statusCode = code;
this.data = data;
this.headers = headers;
}
};
module3.exports = {
HTTPParserError,
UndiciError,
HeadersTimeoutError,
HeadersOverflowError,
BodyTimeoutError,
RequestContentLengthMismatchError,
ConnectTimeoutError,
ResponseStatusCodeError,
InvalidArgumentError,
InvalidReturnValueError,
RequestAbortedError,
ClientDestroyedError,
ClientClosedError,
InformationalError,
SocketError,
NotSupportedError,
ResponseContentLengthMismatchError,
BalancedPoolMissingUpstreamError,
ResponseExceededMaxSizeError,
RequestRetryError
};
}
});
// ../../node_modules/.pnpm/undici@5.28.5/node_modules/undici/lib/core/constants.js
var require_constants = __commonJS({
"../../node_modules/.pnpm/undici@5.28.5/node_modules/undici/lib/core/constants.js"(exports2, module3) {
"use strict";
init_import_meta_url();
var headerNameLowerCasedRecord = {};
var wellknownHeaderNames = [
"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"
];
for (let i5 = 0; i5 < wellknownHeaderNames.length; ++i5) {
const key = wellknownHeaderNames[i5];
const lowerCasedKey = key.toLowerCase();
headerNameLowerCasedRecord[key] = headerNameLowerCasedRecord[lowerCasedKey] = lowerCasedKey;
}
Object.setPrototypeOf(headerNameLowerCasedRecord, null);
module3.exports = {
wellknownHeaderNames,
headerNameLowerCasedRecord
};
}
});
// ../../node_modules/.pnpm/undici@5.28.5/node_modules/undici/lib/core/util.js
var require_util = __commonJS({
"../../node_modules/.pnpm/undici@5.28.5/node_modules/undici/lib/core/util.js"(exports2, module3) {
"use strict";
init_import_meta_url();
var assert37 = require("assert");
var { kDestroyed, kBodyUsed } = require_symbols();
var { IncomingMessage } = require("http");
var stream2 = require("stream");
var net2 = require("net");
var { InvalidArgumentError } = require_errors();
var { Blob: Blob6 } = require("buffer");
var nodeUtil = require("util");
var { stringify } = require("querystring");
var { headerNameLowerCasedRecord } = require_constants();
var [nodeMajor, nodeMinor] = process.versions.node.split(".").map((v7) => Number(v7));
function nop() {
}
__name(nop, "nop");
function isStream2(obj) {
return obj && typeof obj === "object" && typeof obj.pipe === "function" && typeof obj.on === "function";
}
__name(isStream2, "isStream");
function isBlobLike(object) {
return Blob6 && object instanceof Blob6 || object && typeof object === "object" && (typeof object.stream === "function" || typeof object.arrayBuffer === "function") && /^(Blob|File)$/.test(object[Symbol.toStringTag]);
}
__name(isBlobLike, "isBlobLike");
function buildURL(url4, queryParams) {
if (url4.includes("?") || url4.includes("#")) {
throw new Error('Query params cannot be passed when url already contains "?" or "#".');
}
const stringified = stringify(queryParams);
if (stringified) {
url4 += "?" + stringified;
}
return url4;
}
__name(buildURL, "buildURL");
function parseURL2(url4) {
if (typeof url4 === "string") {
url4 = new URL(url4);
if (!/^https?:/.test(url4.origin || url4.protocol)) {
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
}
return url4;
}
if (!url4 || typeof url4 !== "object") {
throw new InvalidArgumentError("Invalid URL: The URL argument must be a non-null object.");
}
if (!/^https?:/.test(url4.origin || url4.protocol)) {
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
}
if (!(url4 instanceof URL)) {
if (url4.port != null && url4.port !== "" && !Number.isFinite(parseInt(url4.port))) {
throw new InvalidArgumentError("Invalid URL: port must be a valid integer or a string representation of an integer.");
}
if (url4.path != null && typeof url4.path !== "string") {
throw new InvalidArgumentError("Invalid URL path: the path must be a string or null/undefined.");
}
if (url4.pathname != null && typeof url4.pathname !== "string") {
throw new InvalidArgumentError("Invalid URL pathname: the pathname must be a string or null/undefined.");
}
if (url4.hostname != null && typeof url4.hostname !== "string") {
throw new InvalidArgumentError("Invalid URL hostname: the hostname must be a string or null/undefined.");
}
if (url4.origin != null && typeof url4.origin !== "string") {
throw new InvalidArgumentError("Invalid URL origin: the origin must be a string or null/undefined.");
}
const port = url4.port != null ? url4.port : url4.protocol === "https:" ? 443 : 80;
let origin = url4.origin != null ? url4.origin : `${url4.protocol}//${url4.hostname}:${port}`;
let path69 = url4.path != null ? url4.path : `${url4.pathname || ""}${url4.search || ""}`;
if (origin.endsWith("/")) {
origin = origin.substring(0, origin.length - 1);
}
if (path69 && !path69.startsWith("/")) {
path69 = `/${path69}`;
}
url4 = new URL(origin + path69);
}
return url4;
}
__name(parseURL2, "parseURL");
function parseOrigin(url4) {
url4 = parseURL2(url4);
if (url4.pathname !== "/" || url4.search || url4.hash) {
throw new InvalidArgumentError("invalid url");
}
return url4;
}
__name(parseOrigin, "parseOrigin");
function getHostname(host) {
if (host[0] === "[") {
const idx2 = host.indexOf("]");
assert37(idx2 !== -1);
return host.substring(1, idx2);
}
const idx = host.indexOf(":");
if (idx === -1) return host;
return host.substring(0, idx);
}
__name(getHostname, "getHostname");
function getServerName(host) {
if (!host) {
return null;
}
assert37.strictEqual(typeof host, "string");
const servername = getHostname(host);
if (net2.isIP(servername)) {
return "";
}
return servername;
}
__name(getServerName, "getServerName");
function deepClone(obj) {
return JSON.parse(JSON.stringify(obj));
}
__name(deepClone, "deepClone");
function isAsyncIterable(obj) {
return !!(obj != null && typeof obj[Symbol.asyncIterator] === "function");
}
__name(isAsyncIterable, "isAsyncIterable");
function isIterable(obj) {
return !!(obj != null && (typeof obj[Symbol.iterator] === "function" || typeof obj[Symbol.asyncIterator] === "function"));
}
__name(isIterable, "isIterable");
function bodyLength(body) {
if (body == null) {
return 0;
} else if (isStream2(body)) {
const state2 = body._readableState;
return state2 && state2.objectMode === false && state2.ended === true && Number.isFinite(state2.length) ? state2.length : null;
} else if (isBlobLike(body)) {
return body.size != null ? body.size : null;
} else if (isBuffer(body)) {
return body.byteLength;
}
return null;
}
__name(bodyLength, "bodyLength");
function isDestroyed(stream3) {
return !stream3 || !!(stream3.destroyed || stream3[kDestroyed]);
}
__name(isDestroyed, "isDestroyed");
function isReadableAborted(stream3) {
const state2 = stream3 && stream3._readableState;
return isDestroyed(stream3) && state2 && !state2.endEmitted;
}
__name(isReadableAborted, "isReadableAborted");
function destroy(stream3, err) {
if (stream3 == null || !isStream2(stream3) || isDestroyed(stream3)) {
return;
}
if (typeof stream3.destroy === "function") {
if (Object.getPrototypeOf(stream3).constructor === IncomingMessage) {
stream3.socket = null;
}
stream3.destroy(err);
} else if (err) {
process.nextTick((stream4, err2) => {
stream4.emit("error", err2);
}, stream3, err);
}
if (stream3.destroyed !== true) {
stream3[kDestroyed] = true;
}
}
__name(destroy, "destroy");
var KEEPALIVE_TIMEOUT_EXPR = /timeout=(\d+)/;
function parseKeepAliveTimeout(val2) {
const m6 = val2.toString().match(KEEPALIVE_TIMEOUT_EXPR);
return m6 ? parseInt(m6[1], 10) * 1e3 : null;
}
__name(parseKeepAliveTimeout, "parseKeepAliveTimeout");
function headerNameToString(value) {
return headerNameLowerCasedRecord[value] || value.toLowerCase();
}
__name(headerNameToString, "headerNameToString");
function parseHeaders2(headers, obj = {}) {
if (!Array.isArray(headers)) return headers;
for (let i5 = 0; i5 < headers.length; i5 += 2) {
const key = headers[i5].toString().toLowerCase();
let val2 = obj[key];
if (!val2) {
if (Array.isArray(headers[i5 + 1])) {
obj[key] = headers[i5 + 1].map((x6) => x6.toString("utf8"));
} else {
obj[key] = headers[i5 + 1].toString("utf8");
}
} else {
if (!Array.isArray(val2)) {
val2 = [val2];
obj[key] = val2;
}
val2.push(headers[i5 + 1].toString("utf8"));
}
}
if ("content-length" in obj && "content-disposition" in obj) {
obj["content-disposition"] = Buffer.from(obj["content-disposition"]).toString("latin1");
}
return obj;
}
__name(parseHeaders2, "parseHeaders");
function parseRawHeaders(headers) {
const ret = [];
let hasContentLength = false;
let contentDispositionIdx = -1;
for (let n6 = 0; n6 < headers.length; n6 += 2) {
const key = headers[n6 + 0].toString();
const val2 = headers[n6 + 1].toString("utf8");
if (key.length === 14 && (key === "content-length" || key.toLowerCase() === "content-length")) {
ret.push(key, val2);
hasContentLength = true;
} else if (key.length === 19 && (key === "content-disposition" || key.toLowerCase() === "content-disposition")) {
contentDispositionIdx = ret.push(key, val2) - 1;
} else {
ret.push(key, val2);
}
}
if (hasContentLength && contentDispositionIdx !== -1) {
ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString("latin1");
}
return ret;
}
__name(parseRawHeaders, "parseRawHeaders");
function isBuffer(buffer) {
return buffer instanceof Uint8Array || Buffer.isBuffer(buffer);
}
__name(isBuffer, "isBuffer");
function validateHandler(handler32, method, upgrade) {
if (!handler32 || typeof handler32 !== "object") {
throw new InvalidArgumentError("handler must be an object");
}
if (typeof handler32.onConnect !== "function") {
throw new InvalidArgumentError("invalid onConnect method");
}
if (typeof handler32.onError !== "function") {
throw new InvalidArgumentError("invalid onError method");
}
if (typeof handler32.onBodySent !== "function" && handler32.onBodySent !== void 0) {
throw new InvalidArgumentError("invalid onBodySent method");
}
if (upgrade || method === "CONNECT") {
if (typeof handler32.onUpgrade !== "function") {
throw new InvalidArgumentError("invalid onUpgrade method");
}
} else {
if (typeof handler32.onHeaders !== "function") {
throw new InvalidArgumentError("invalid onHeaders method");
}
if (typeof handler32.onData !== "function") {
throw new InvalidArgumentError("invalid onData method");
}
if (typeof handler32.onComplete !== "function") {
throw new InvalidArgumentError("invalid onComplete method");
}
}
}
__name(validateHandler, "validateHandler");
function isDisturbed(body) {
return !!(body && (stream2.isDisturbed ? stream2.isDisturbed(body) || body[kBodyUsed] : body[kBodyUsed] || body.readableDidRead || body._readableState && body._readableState.dataEmitted || isReadableAborted(body)));
}
__name(isDisturbed, "isDisturbed");
function isErrored(body) {
return !!(body && (stream2.isErrored ? stream2.isErrored(body) : /state: 'errored'/.test(
nodeUtil.inspect(body)
)));
}
__name(isErrored, "isErrored");
function isReadable(body) {
return !!(body && (stream2.isReadable ? stream2.isReadable(body) : /state: 'readable'/.test(
nodeUtil.inspect(body)
)));
}
__name(isReadable, "isReadable");
function getSocketInfo(socket) {
return {
localAddress: socket.localAddress,
localPort: socket.localPort,
remoteAddress: socket.remoteAddress,
remotePort: socket.remotePort,
remoteFamily: socket.remoteFamily,
timeout: socket.timeout,
bytesWritten: socket.bytesWritten,
bytesRead: socket.bytesRead
};
}
__name(getSocketInfo, "getSocketInfo");
async function* convertIterableToBuffer(iterable) {
for await (const chunk of iterable) {
yield Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
}
}
__name(convertIterableToBuffer, "convertIterableToBuffer");
var ReadableStream3;
function ReadableStreamFrom(iterable) {
if (!ReadableStream3) {
ReadableStream3 = require("stream/web").ReadableStream;
}
if (ReadableStream3.from) {
return ReadableStream3.from(convertIterableToBuffer(iterable));
}
let iterator;
return new ReadableStream3(
{
async start() {
iterator = iterable[Symbol.asyncIterator]();
},
async pull(controller) {
const { done, value } = await iterator.next();
if (done) {
queueMicrotask(() => {
controller.close();
});
} else {
const buf = Buffer.isBuffer(value) ? value : Buffer.from(value);
controller.enqueue(new Uint8Array(buf));
}
return controller.desiredSize > 0;
},
async cancel(reason) {
await iterator.return();
}
},
0
);
}
__name(ReadableStreamFrom, "ReadableStreamFrom");
function isFormDataLike(object) {
return object && typeof object === "object" && typeof object.append === "function" && typeof object.delete === "function" && typeof object.get === "function" && typeof object.getAll === "function" && typeof object.has === "function" && typeof object.set === "function" && object[Symbol.toStringTag] === "FormData";
}
__name(isFormDataLike, "isFormDataLike");
function throwIfAborted(signal) {
if (!signal) {
return;
}
if (typeof signal.throwIfAborted === "function") {
signal.throwIfAborted();
} else {
if (signal.aborted) {
const err = new Error("The operation was aborted");
err.name = "AbortError";
throw err;
}
}
}
__name(throwIfAborted, "throwIfAborted");
function addAbortListener(signal, listener) {
if ("addEventListener" in signal) {
signal.addEventListener("abort", listener, { once: true });
return () => signal.removeEventListener("abort", listener);
}
signal.addListener("abort", listener);
return () => signal.removeListener("abort", listener);
}
__name(addAbortListener, "addAbortListener");
var hasToWellFormed = !!String.prototype.toWellFormed;
function toUSVString(val2) {
if (hasToWellFormed) {
return `${val2}`.toWellFormed();
} else if (nodeUtil.toUSVString) {
return nodeUtil.toUSVString(val2);
}
return `${val2}`;
}
__name(toUSVString, "toUSVString");
function parseRangeHeader(range) {
if (range == null || range === "") return { start: 0, end: null, size: null };
const m6 = range ? range.match(/^bytes (\d+)-(\d+)\/(\d+)?$/) : null;
return m6 ? {
start: parseInt(m6[1]),
end: m6[2] ? parseInt(m6[2]) : null,
size: m6[3] ? parseInt(m6[3]) : null
} : null;
}
__name(parseRangeHeader, "parseRangeHeader");
var kEnumerableProperty = /* @__PURE__ */ Object.create(null);
kEnumerableProperty.enumerable = true;
module3.exports = {
kEnumerableProperty,
nop,
isDisturbed,
isErrored,
isReadable,
toUSVString,
isReadableAborted,
isBlobLike,
parseOrigin,
parseURL: parseURL2,
getServerName,
isStream: isStream2,
isIterable,
isAsyncIterable,
isDestroyed,
headerNameToString,
parseRawHeaders,
parseHeaders: parseHeaders2,
parseKeepAliveTimeout,
destroy,
bodyLength,
deepClone,
ReadableStreamFrom,
isBuffer,
validateHandler,
getSocketInfo,
isFormDataLike,
buildURL,
throwIfAborted,
addAbortListener,
parseRangeHeader,
nodeMajor,
nodeMinor,
nodeHasAutoSelectFamily: nodeMajor > 18 || nodeMajor === 18 && nodeMinor >= 13,
safeHTTPMethods: ["GET", "HEAD", "OPTIONS", "TRACE"]
};
}
});
// ../../node_modules/.pnpm/undici@5.28.5/node_modules/undici/lib/timers.js
var require_timers = __commonJS({
"../../node_modules/.pnpm/undici@5.28.5/node_modules/undici/lib/timers.js"(exports2, module3) {
"use strict";
init_import_meta_url();
var fastNow = Date.now();
var fastNowTimeout;
var fastTimers = [];
function onTimeout() {
fastNow = Date.now();
let len = fastTimers.length;
let idx = 0;
while (idx < len) {
const timer = fastTimers[idx];
if (timer.state === 0) {
timer.state = fastNow + timer.delay;
} else if (timer.state > 0 && fastNow >= timer.state) {
timer.state = -1;
timer.callback(timer.opaque);
}
if (timer.state === -1) {
timer.state = -2;
if (idx !== len - 1) {
fastTimers[idx] = fastTimers.pop();
} else {
fastTimers.pop();
}
len -= 1;
} else {
idx += 1;
}
}
if (fastTimers.length > 0) {
refreshTimeout();
}
}
__name(onTimeout, "onTimeout");
function refreshTimeout() {
if (fastNowTimeout && fastNowTimeout.refresh) {
fastNowTimeout.refresh();
} else {
clearTimeout(fastNowTimeout);
fastNowTimeout = setTimeout(onTimeout, 1e3);
if (fastNowTimeout.unref) {
fastNowTimeout.unref();
}
}
}
__name(refreshTimeout, "refreshTimeout");
var Timeout = class {
static {
__name(this, "Timeout");
}
constructor(callback, delay, opaque) {
this.callback = callback;
this.delay = delay;
this.opaque = opaque;
this.state = -2;
this.refresh();
}
refresh() {
if (this.state === -2) {
fastTimers.push(this);
if (!fastNowTimeout || fastTimers.length === 1) {
refreshTimeout();
}
}
this.state = 0;
}
clear() {
this.state = -1;
}
};
module3.exports = {
setTimeout(callback, delay, opaque) {
return delay < 1e3 ? setTimeout(callback, delay, opaque) : new Timeout(callback, delay, opaque);
},
clearTimeout(timeout2) {
if (timeout2 instanceof Timeout) {
timeout2.clear();
} else {
clearTimeout(timeout2);
}
}
};
}
});
// ../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/deps/streamsearch/sbmh.js
var require_sbmh = __commonJS({
"../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/deps/streamsearch/sbmh.js"(exports2, module3) {
"use strict";
init_import_meta_url();
var EventEmitter5 = require("node:events").EventEmitter;
var inherits = require("node:util").inherits;
function SBMH(needle) {
if (typeof needle === "string") {
needle = Buffer.from(needle);
}
if (!Buffer.isBuffer(needle)) {
throw new TypeError("The needle has to be a String or a Buffer.");
}
const needleLength = needle.length;
if (needleLength === 0) {
throw new Error("The needle cannot be an empty String/Buffer.");
}
if (needleLength > 256) {
throw new Error("The needle cannot have a length bigger than 256.");
}
this.maxMatches = Infinity;
this.matches = 0;
this._occ = new Array(256).fill(needleLength);
this._lookbehind_size = 0;
this._needle = needle;
this._bufpos = 0;
this._lookbehind = Buffer.alloc(needleLength);
for (var i5 = 0; i5 < needleLength - 1; ++i5) {
this._occ[needle[i5]] = needleLength - 1 - i5;
}
}
__name(SBMH, "SBMH");
inherits(SBMH, EventEmitter5);
SBMH.prototype.reset = function() {
this._lookbehind_size = 0;
this.matches = 0;
this._bufpos = 0;
};
SBMH.prototype.push = function(chunk, pos) {
if (!Buffer.isBuffer(chunk)) {
chunk = Buffer.from(chunk, "binary");
}
const chlen = chunk.length;
this._bufpos = pos || 0;
let r7;
while (r7 !== chlen && this.matches < this.maxMatches) {
r7 = this._sbmh_feed(chunk);
}
return r7;
};
SBMH.prototype._sbmh_feed = function(data) {
const len = data.length;
const needle = this._needle;
const needleLength = needle.length;
const lastNeedleChar = needle[needleLength - 1];
let pos = -this._lookbehind_size;
let ch2;
if (pos < 0) {
while (pos < 0 && pos <= len - needleLength) {
ch2 = this._sbmh_lookup_char(data, pos + needleLength - 1);
if (ch2 === lastNeedleChar && this._sbmh_memcmp(data, pos, needleLength - 1)) {
this._lookbehind_size = 0;
++this.matches;
this.emit("info", true);
return this._bufpos = pos + needleLength;
}
pos += this._occ[ch2];
}
if (pos < 0) {
while (pos < 0 && !this._sbmh_memcmp(data, pos, len - pos)) {
++pos;
}
}
if (pos >= 0) {
this.emit("info", false, this._lookbehind, 0, this._lookbehind_size);
this._lookbehind_size = 0;
} else {
const bytesToCutOff = this._lookbehind_size + pos;
if (bytesToCutOff > 0) {
this.emit("info", false, this._lookbehind, 0, bytesToCutOff);
}
this._lookbehind.copy(
this._lookbehind,
0,
bytesToCutOff,
this._lookbehind_size - bytesToCutOff
);
this._lookbehind_size -= bytesToCutOff;
data.copy(this._lookbehind, this._lookbehind_size);
this._lookbehind_size += len;
this._bufpos = len;
return len;
}
}
pos += (pos >= 0) * this._bufpos;
if (data.indexOf(needle, pos) !== -1) {
pos = data.indexOf(needle, pos);
++this.matches;
if (pos > 0) {
this.emit("info", true, data, this._bufpos, pos);
} else {
this.emit("info", true);
}
return this._bufpos = pos + needleLength;
} else {
pos = len - needleLength;
}
while (pos < len && (data[pos] !== needle[0] || Buffer.compare(
data.subarray(pos, pos + len - pos),
needle.subarray(0, len - pos)
) !== 0)) {
++pos;
}
if (pos < len) {
data.copy(this._lookbehind, 0, pos, pos + (len - pos));
this._lookbehind_size = len - pos;
}
if (pos > 0) {
this.emit("info", false, data, this._bufpos, pos < len ? pos : len);
}
this._bufpos = len;
return len;
};
SBMH.prototype._sbmh_lookup_char = function(data, pos) {
return pos < 0 ? this._lookbehind[this._lookbehind_size + pos] : data[pos];
};
SBMH.prototype._sbmh_memcmp = function(data, pos, len) {
for (var i5 = 0; i5 < len; ++i5) {
if (this._sbmh_lookup_char(data, pos + i5) !== this._needle[i5]) {
return false;
}
}
return true;
};
module3.exports = SBMH;
}
});
// ../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/deps/dicer/lib/PartStream.js
var require_PartStream = __commonJS({
"../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/deps/dicer/lib/PartStream.js"(exports2, module3) {
"use strict";
init_import_meta_url();
var inherits = require("node:util").inherits;
var ReadableStream3 = require("node:stream").Readable;
function PartStream(opts) {
ReadableStream3.call(this, opts);
}
__name(PartStream, "PartStream");
inherits(PartStream, ReadableStream3);
PartStream.prototype._read = function(n6) {
};
module3.exports = PartStream;
}
});
// ../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/lib/utils/getLimit.js
var require_getLimit = __commonJS({
"../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/lib/utils/getLimit.js"(exports2, module3) {
"use strict";
init_import_meta_url();
module3.exports = /* @__PURE__ */ __name(function getLimit(limits, name2, defaultLimit) {
if (!limits || limits[name2] === void 0 || limits[name2] === null) {
return defaultLimit;
}
if (typeof limits[name2] !== "number" || isNaN(limits[name2])) {
throw new TypeError("Limit " + name2 + " is not a valid number");
}
return limits[name2];
}, "getLimit");
}
});
// ../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/deps/dicer/lib/HeaderParser.js
var require_HeaderParser = __commonJS({
"../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/deps/dicer/lib/HeaderParser.js"(exports2, module3) {
"use strict";
init_import_meta_url();
var EventEmitter5 = require("node:events").EventEmitter;
var inherits = require("node:util").inherits;
var getLimit = require_getLimit();
var StreamSearch = require_sbmh();
var B_DCRLF = Buffer.from("\r\n\r\n");
var RE_CRLF = /\r\n/g;
var RE_HDR = /^([^:]+):[ \t]?([\x00-\xFF]+)?$/;
function HeaderParser(cfg) {
EventEmitter5.call(this);
cfg = cfg || {};
const self2 = this;
this.nread = 0;
this.maxed = false;
this.npairs = 0;
this.maxHeaderPairs = getLimit(cfg, "maxHeaderPairs", 2e3);
this.maxHeaderSize = getLimit(cfg, "maxHeaderSize", 80 * 1024);
this.buffer = "";
this.header = {};
this.finished = false;
this.ss = new StreamSearch(B_DCRLF);
this.ss.on("info", function(isMatch, data, start, end) {
if (data && !self2.maxed) {
if (self2.nread + end - start >= self2.maxHeaderSize) {
end = self2.maxHeaderSize - self2.nread + start;
self2.nread = self2.maxHeaderSize;
self2.maxed = true;
} else {
self2.nread += end - start;
}
self2.buffer += data.toString("binary", start, end);
}
if (isMatch) {
self2._finish();
}
});
}
__name(HeaderParser, "HeaderParser");
inherits(HeaderParser, EventEmitter5);
HeaderParser.prototype.push = function(data) {
const r7 = this.ss.push(data);
if (this.finished) {
return r7;
}
};
HeaderParser.prototype.reset = function() {
this.finished = false;
this.buffer = "";
this.header = {};
this.ss.reset();
};
HeaderParser.prototype._finish = function() {
if (this.buffer) {
this._parseHeader();
}
this.ss.matches = this.ss.maxMatches;
const header = this.header;
this.header = {};
this.buffer = "";
this.finished = true;
this.nread = this.npairs = 0;
this.maxed = false;
this.emit("header", header);
};
HeaderParser.prototype._parseHeader = function() {
if (this.npairs === this.maxHeaderPairs) {
return;
}
const lines = this.buffer.split(RE_CRLF);
const len = lines.length;
let m6, h6;
for (var i5 = 0; i5 < len; ++i5) {
if (lines[i5].length === 0) {
continue;
}
if (lines[i5][0] === " " || lines[i5][0] === " ") {
if (h6) {
this.header[h6][this.header[h6].length - 1] += lines[i5];
continue;
}
}
const posColon = lines[i5].indexOf(":");
if (posColon === -1 || posColon === 0) {
return;
}
m6 = RE_HDR.exec(lines[i5]);
h6 = m6[1].toLowerCase();
this.header[h6] = this.header[h6] || [];
this.header[h6].push(m6[2] || "");
if (++this.npairs === this.maxHeaderPairs) {
break;
}
}
};
module3.exports = HeaderParser;
}
});
// ../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js
var require_Dicer = __commonJS({
"../../node_modules/.pnpm/@fastify+busboy@2.1.1/node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js"(exports2, module3) {
"use strict";
init_import_meta_url();
var WritableStream = require("node:stream").Writable;
var inherits = require("node:util").inherits;
var StreamSearch = require_sbmh();
var PartStream = require_PartStream();
var HeaderParser = require_HeaderParser();
var DASH = 45;
var B_ONEDASH = Buffer.from("-");
var B_CRLF = Buffer.from("\r\n");
var EMPTY_FN2 = /* @__PURE__ */ __name(function() {
}, "EMPTY_FN");
function Dicer(cfg) {
if (!(this instanceof Dicer)) {
return new Dicer(cfg);
}
WritableStream.call(this, cfg);
if (!cfg || !cfg.headerFirst && typeof cfg.boundary !== "string") {
throw new TypeError("Boundary required");
}
if (typeof cfg.boundary === "string") {
this.setBoundary(cfg.boundary);
} else {
this._bparser = void 0;
}
this._headerFirst = cfg.headerFirst;
this._dashes = 0;
this._parts = 0;
this._finished = false;
this._realFinish = false;
this._isPreamble = true;
this._justMatched = false;
this._firstWrite = true;
this._inHeader = true;
this._part = void 0;
this._cb = void 0;
this._ignoreData = false;
this._partOpts = { highWaterMark: cfg.partHwm };
this._pause = false;
const self2 = this;
this._hparser = new HeaderParser(cfg);
this._hparser.on("header", function(header) {
self2._inHeader = false;
self2._part.emit("header", header);
});
}
__name(Dicer, "Dicer");
inherits(Dicer, WritableStream);
Dicer.prototype.emit = function(ev) {
if (ev === "finish" && !this._realFinish) {
if (!this._finished) {
const self2 = this;
process.nextTick(function() {
self2.emit("error", new Error("Unexpected end of multipart data"));
if (self2._part && !self2._ignoreData) {
const type = self2._isPreamble ? "Preamble" : "Part";
self2._part.emit("error", new Error(type + " terminated early due to unexpected end of multipart data"));
self2._part.push(null);
process.nextTick(function() {
self2._realFinish = true;
self2.emit("finish");
self2._realFinish = false;
});
return;
}
self2._realFinish = true;
self2.emit("finish");
self2._realFinish = false;
});
}
} else {
WritableStream.prototype.emit.apply(this, arguments);
}
};
Dicer.prototype._write = function(data, encoding, cb2) {
if (!this._hparser && !this._bparser) {
return cb2();
}
if (this._headerFirst && this._isPreamble) {
if (!this._part) {
this._part = new PartStream(this._partOpts);
if (this.listenerCount("preamble") !== 0) {
this.emit("preamble", this._part);
} else {
this._ignore();
}
}
const r7 = this._hparser.push(data);
if (!this._inHeader && r7 !== void 0 && r7 < data.length) {
data = data.slice(r7);
} else {
return cb2();
}
}
if (this._firstWrite) {
this._bparser.push(B_CRLF);
this._firstWrite = false;
}
this._bparser.push(data);
if (this._pause) {
this._cb = cb2;
} else {
cb2();
}
};
Dicer.prototype.reset = function() {
this._part = void 0;
this._bparser = void 0;
this._hparser = void 0;
};
Dicer.prototype.setBoundary = function(boundary) {
const self2 = this;
this._bparser = new StreamSearch("\r\n--" + boundary);
this._bparser.on("info", function(isMatch, data, start, end) {
self2._oninfo(isMatch, data, start, end);
});
};
Dicer.prototype._ignore = function() {
if (this._part && !this._igno