frodo-lib
Version:
A library to manage ForgeRock Identity Cloud tenants, ForgeOps deployments, and classic deployments.
1,699 lines (1,690 loc) • 4.39 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 __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require2() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all7) => {
for (var name in all7)
__defProp(target, name, { get: all7[name], enumerable: true });
};
var __copyProps = (to2, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to2, key) && key !== except)
__defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to2;
};
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);
// node_modules/ms/index.js
var require_ms = __commonJS({
"node_modules/ms/index.js"(exports2, module2) {
"use strict";
var s4 = 1e3;
var m2 = s4 * 60;
var h2 = m2 * 60;
var d2 = h2 * 24;
var w2 = d2 * 7;
var y2 = d2 * 365.25;
module2.exports = function(val, options) {
options = options || {};
var type = typeof val;
if (type === "string" && val.length > 0) {
return parse7(val);
} else if (type === "number" && isFinite(val)) {
return options.long ? fmtLong2(val) : fmtShort2(val);
}
throw new Error(
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
);
};
function parse7(str) {
str = String(str);
if (str.length > 100) {
return;
}
var match2 = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
str
);
if (!match2) {
return;
}
var n = parseFloat(match2[1]);
var type = (match2[2] || "ms").toLowerCase();
switch (type) {
case "years":
case "year":
case "yrs":
case "yr":
case "y":
return n * y2;
case "weeks":
case "week":
case "w":
return n * w2;
case "days":
case "day":
case "d":
return n * d2;
case "hours":
case "hour":
case "hrs":
case "hr":
case "h":
return n * h2;
case "minutes":
case "minute":
case "mins":
case "min":
case "m":
return n * m2;
case "seconds":
case "second":
case "secs":
case "sec":
case "s":
return n * s4;
case "milliseconds":
case "millisecond":
case "msecs":
case "msec":
case "ms":
return n;
default:
return void 0;
}
}
function fmtShort2(ms2) {
var msAbs = Math.abs(ms2);
if (msAbs >= d2) {
return Math.round(ms2 / d2) + "d";
}
if (msAbs >= h2) {
return Math.round(ms2 / h2) + "h";
}
if (msAbs >= m2) {
return Math.round(ms2 / m2) + "m";
}
if (msAbs >= s4) {
return Math.round(ms2 / s4) + "s";
}
return ms2 + "ms";
}
function fmtLong2(ms2) {
var msAbs = Math.abs(ms2);
if (msAbs >= d2) {
return plural2(ms2, msAbs, d2, "day");
}
if (msAbs >= h2) {
return plural2(ms2, msAbs, h2, "hour");
}
if (msAbs >= m2) {
return plural2(ms2, msAbs, m2, "minute");
}
if (msAbs >= s4) {
return plural2(ms2, msAbs, s4, "second");
}
return ms2 + " ms";
}
function plural2(ms2, msAbs, n, name) {
var isPlural = msAbs >= n * 1.5;
return Math.round(ms2 / n) + " " + name + (isPlural ? "s" : "");
}
}
});
// node_modules/humanize-ms/index.js
var require_humanize_ms = __commonJS({
"node_modules/humanize-ms/index.js"(exports2, module2) {
"use strict";
var util46 = __require("util");
var ms2 = require_ms();
module2.exports = function(t) {
if (typeof t === "number") return t;
var r = ms2(t);
if (r === void 0) {
var err = new Error(util46.format("humanize-ms(%j) result undefined", t));
console.warn(err.stack);
}
return r;
};
}
});
// node_modules/agentkeepalive/lib/constants.js
var require_constants = __commonJS({
"node_modules/agentkeepalive/lib/constants.js"(exports2, module2) {
"use strict";
module2.exports = {
// agent
CURRENT_ID: Symbol("agentkeepalive#currentId"),
CREATE_ID: Symbol("agentkeepalive#createId"),
INIT_SOCKET: Symbol("agentkeepalive#initSocket"),
CREATE_HTTPS_CONNECTION: Symbol("agentkeepalive#createHttpsConnection"),
// socket
SOCKET_CREATED_TIME: Symbol("agentkeepalive#socketCreatedTime"),
SOCKET_NAME: Symbol("agentkeepalive#socketName"),
SOCKET_REQUEST_COUNT: Symbol("agentkeepalive#socketRequestCount"),
SOCKET_REQUEST_FINISHED_COUNT: Symbol("agentkeepalive#socketRequestFinishedCount")
};
}
});
// node_modules/agentkeepalive/lib/agent.js
var require_agent = __commonJS({
"node_modules/agentkeepalive/lib/agent.js"(exports2, module2) {
"use strict";
var OriginalAgent = __require("http").Agent;
var ms2 = require_humanize_ms();
var debug2 = __require("util").debuglog("agentkeepalive");
var {
INIT_SOCKET,
CURRENT_ID,
CREATE_ID,
SOCKET_CREATED_TIME,
SOCKET_NAME,
SOCKET_REQUEST_COUNT,
SOCKET_REQUEST_FINISHED_COUNT
} = require_constants();
var defaultTimeoutListenerCount = 1;
var majorVersion = parseInt(process.version.split(".", 1)[0].substring(1));
if (majorVersion >= 11 && majorVersion <= 12) {
defaultTimeoutListenerCount = 2;
} else if (majorVersion >= 13) {
defaultTimeoutListenerCount = 3;
}
function deprecate(message) {
console.log("[agentkeepalive:deprecated] %s", message);
}
var Agent3 = class extends OriginalAgent {
constructor(options) {
options = options || {};
options.keepAlive = options.keepAlive !== false;
if (options.freeSocketTimeout === void 0) {
options.freeSocketTimeout = 4e3;
}
if (options.keepAliveTimeout) {
deprecate("options.keepAliveTimeout is deprecated, please use options.freeSocketTimeout instead");
options.freeSocketTimeout = options.keepAliveTimeout;
delete options.keepAliveTimeout;
}
if (options.freeSocketKeepAliveTimeout) {
deprecate("options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead");
options.freeSocketTimeout = options.freeSocketKeepAliveTimeout;
delete options.freeSocketKeepAliveTimeout;
}
if (options.timeout === void 0) {
options.timeout = Math.max(options.freeSocketTimeout * 2, 8e3);
}
options.timeout = ms2(options.timeout);
options.freeSocketTimeout = ms2(options.freeSocketTimeout);
options.socketActiveTTL = options.socketActiveTTL ? ms2(options.socketActiveTTL) : 0;
super(options);
this[CURRENT_ID] = 0;
this.createSocketCount = 0;
this.createSocketCountLastCheck = 0;
this.createSocketErrorCount = 0;
this.createSocketErrorCountLastCheck = 0;
this.closeSocketCount = 0;
this.closeSocketCountLastCheck = 0;
this.errorSocketCount = 0;
this.errorSocketCountLastCheck = 0;
this.requestCount = 0;
this.requestCountLastCheck = 0;
this.timeoutSocketCount = 0;
this.timeoutSocketCountLastCheck = 0;
this.on("free", (socket) => {
const timeout4 = this.calcSocketTimeout(socket);
if (timeout4 > 0 && socket.timeout !== timeout4) {
socket.setTimeout(timeout4);
}
});
}
get freeSocketKeepAliveTimeout() {
deprecate("agent.freeSocketKeepAliveTimeout is deprecated, please use agent.options.freeSocketTimeout instead");
return this.options.freeSocketTimeout;
}
get timeout() {
deprecate("agent.timeout is deprecated, please use agent.options.timeout instead");
return this.options.timeout;
}
get socketActiveTTL() {
deprecate("agent.socketActiveTTL is deprecated, please use agent.options.socketActiveTTL instead");
return this.options.socketActiveTTL;
}
calcSocketTimeout(socket) {
let freeSocketTimeout2 = this.options.freeSocketTimeout;
const socketActiveTTL = this.options.socketActiveTTL;
if (socketActiveTTL) {
const aliveTime = Date.now() - socket[SOCKET_CREATED_TIME];
const diff = socketActiveTTL - aliveTime;
if (diff <= 0) {
return diff;
}
if (freeSocketTimeout2 && diff < freeSocketTimeout2) {
freeSocketTimeout2 = diff;
}
}
if (freeSocketTimeout2) {
const customFreeSocketTimeout = socket.freeSocketTimeout || socket.freeSocketKeepAliveTimeout;
return customFreeSocketTimeout || freeSocketTimeout2;
}
}
keepSocketAlive(socket) {
const result = super.keepSocketAlive(socket);
if (!result) return result;
const customTimeout = this.calcSocketTimeout(socket);
if (typeof customTimeout === "undefined") {
return true;
}
if (customTimeout <= 0) {
debug2(
"%s(requests: %s, finished: %s) free but need to destroy by TTL, request count %s, diff is %s",
socket[SOCKET_NAME],
socket[SOCKET_REQUEST_COUNT],
socket[SOCKET_REQUEST_FINISHED_COUNT],
customTimeout
);
return false;
}
if (socket.timeout !== customTimeout) {
socket.setTimeout(customTimeout);
}
return true;
}
// only call on addRequest
reuseSocket(...args) {
super.reuseSocket(...args);
const socket = args[0];
const req = args[1];
req.reusedSocket = true;
const agentTimeout = this.options.timeout;
if (getSocketTimeout(socket) !== agentTimeout) {
socket.setTimeout(agentTimeout);
debug2("%s reset timeout to %sms", socket[SOCKET_NAME], agentTimeout);
}
socket[SOCKET_REQUEST_COUNT]++;
debug2(
"%s(requests: %s, finished: %s) reuse on addRequest, timeout %sms",
socket[SOCKET_NAME],
socket[SOCKET_REQUEST_COUNT],
socket[SOCKET_REQUEST_FINISHED_COUNT],
getSocketTimeout(socket)
);
}
[CREATE_ID]() {
const id7 = this[CURRENT_ID]++;
if (this[CURRENT_ID] === Number.MAX_SAFE_INTEGER) this[CURRENT_ID] = 0;
return id7;
}
[INIT_SOCKET](socket, options) {
if (options.timeout) {
const timeout4 = getSocketTimeout(socket);
if (!timeout4) {
socket.setTimeout(options.timeout);
}
}
if (this.options.keepAlive) {
socket.setNoDelay(true);
}
this.createSocketCount++;
if (this.options.socketActiveTTL) {
socket[SOCKET_CREATED_TIME] = Date.now();
}
socket[SOCKET_NAME] = `sock[${this[CREATE_ID]()}#${options._agentKey}]`.split("-----BEGIN", 1)[0];
socket[SOCKET_REQUEST_COUNT] = 1;
socket[SOCKET_REQUEST_FINISHED_COUNT] = 0;
installListeners(this, socket, options);
}
createConnection(options, oncreate) {
let called = false;
const onNewCreate = (err, socket) => {
if (called) return;
called = true;
if (err) {
this.createSocketErrorCount++;
return oncreate(err);
}
this[INIT_SOCKET](socket, options);
oncreate(err, socket);
};
const newSocket = super.createConnection(options, onNewCreate);
if (newSocket) onNewCreate(null, newSocket);
return newSocket;
}
get statusChanged() {
const changed = this.createSocketCount !== this.createSocketCountLastCheck || this.createSocketErrorCount !== this.createSocketErrorCountLastCheck || this.closeSocketCount !== this.closeSocketCountLastCheck || this.errorSocketCount !== this.errorSocketCountLastCheck || this.timeoutSocketCount !== this.timeoutSocketCountLastCheck || this.requestCount !== this.requestCountLastCheck;
if (changed) {
this.createSocketCountLastCheck = this.createSocketCount;
this.createSocketErrorCountLastCheck = this.createSocketErrorCount;
this.closeSocketCountLastCheck = this.closeSocketCount;
this.errorSocketCountLastCheck = this.errorSocketCount;
this.timeoutSocketCountLastCheck = this.timeoutSocketCount;
this.requestCountLastCheck = this.requestCount;
}
return changed;
}
getCurrentStatus() {
return {
createSocketCount: this.createSocketCount,
createSocketErrorCount: this.createSocketErrorCount,
closeSocketCount: this.closeSocketCount,
errorSocketCount: this.errorSocketCount,
timeoutSocketCount: this.timeoutSocketCount,
requestCount: this.requestCount,
freeSockets: inspect(this.freeSockets),
sockets: inspect(this.sockets),
requests: inspect(this.requests)
};
}
};
function getSocketTimeout(socket) {
return socket.timeout || socket._idleTimeout;
}
function installListeners(agent, socket, options) {
debug2("%s create, timeout %sms", socket[SOCKET_NAME], getSocketTimeout(socket));
function onFree() {
if (!socket._httpMessage && socket[SOCKET_REQUEST_COUNT] === 1) return;
socket[SOCKET_REQUEST_FINISHED_COUNT]++;
agent.requestCount++;
debug2(
"%s(requests: %s, finished: %s) free",
socket[SOCKET_NAME],
socket[SOCKET_REQUEST_COUNT],
socket[SOCKET_REQUEST_FINISHED_COUNT]
);
const name = agent.getName(options);
if (socket.writable && agent.requests[name] && agent.requests[name].length) {
socket[SOCKET_REQUEST_COUNT]++;
debug2(
"%s(requests: %s, finished: %s) will be reuse on agent free event",
socket[SOCKET_NAME],
socket[SOCKET_REQUEST_COUNT],
socket[SOCKET_REQUEST_FINISHED_COUNT]
);
}
}
socket.on("free", onFree);
function onClose(isError) {
debug2(
"%s(requests: %s, finished: %s) close, isError: %s",
socket[SOCKET_NAME],
socket[SOCKET_REQUEST_COUNT],
socket[SOCKET_REQUEST_FINISHED_COUNT],
isError
);
agent.closeSocketCount++;
}
socket.on("close", onClose);
function onTimeout() {
const listenerCount = socket.listeners("timeout").length;
const timeout4 = getSocketTimeout(socket);
const req = socket._httpMessage;
const reqTimeoutListenerCount = req && req.listeners("timeout").length || 0;
debug2(
"%s(requests: %s, finished: %s) timeout after %sms, listeners %s, defaultTimeoutListenerCount %s, hasHttpRequest %s, HttpRequest timeoutListenerCount %s",
socket[SOCKET_NAME],
socket[SOCKET_REQUEST_COUNT],
socket[SOCKET_REQUEST_FINISHED_COUNT],
timeout4,
listenerCount,
defaultTimeoutListenerCount,
!!req,
reqTimeoutListenerCount
);
if (debug2.enabled) {
debug2("timeout listeners: %s", socket.listeners("timeout").map((f7) => f7.name).join(", "));
}
agent.timeoutSocketCount++;
const name = agent.getName(options);
if (agent.freeSockets[name] && agent.freeSockets[name].indexOf(socket) !== -1) {
socket.destroy();
agent.removeSocket(socket, options);
debug2("%s is free, destroy quietly", socket[SOCKET_NAME]);
} else {
if (reqTimeoutListenerCount === 0) {
const error = new Error("Socket timeout");
error.code = "ERR_SOCKET_TIMEOUT";
error.timeout = timeout4;
socket.destroy(error);
agent.removeSocket(socket, options);
debug2("%s destroy with timeout error", socket[SOCKET_NAME]);
}
}
}
socket.on("timeout", onTimeout);
function onError(err) {
const listenerCount = socket.listeners("error").length;
debug2(
"%s(requests: %s, finished: %s) error: %s, listenerCount: %s",
socket[SOCKET_NAME],
socket[SOCKET_REQUEST_COUNT],
socket[SOCKET_REQUEST_FINISHED_COUNT],
err,
listenerCount
);
agent.errorSocketCount++;
if (listenerCount === 1) {
debug2("%s emit uncaught error event", socket[SOCKET_NAME]);
socket.removeListener("error", onError);
socket.emit("error", err);
}
}
socket.on("error", onError);
function onRemove() {
debug2(
"%s(requests: %s, finished: %s) agentRemove",
socket[SOCKET_NAME],
socket[SOCKET_REQUEST_COUNT],
socket[SOCKET_REQUEST_FINISHED_COUNT]
);
socket.removeListener("close", onClose);
socket.removeListener("error", onError);
socket.removeListener("free", onFree);
socket.removeListener("timeout", onTimeout);
socket.removeListener("agentRemove", onRemove);
}
socket.on("agentRemove", onRemove);
}
module2.exports = Agent3;
function inspect(obj) {
const res = {};
for (const key in obj) {
res[key] = obj[key].length;
}
return res;
}
}
});
// node_modules/agentkeepalive/lib/https_agent.js
var require_https_agent = __commonJS({
"node_modules/agentkeepalive/lib/https_agent.js"(exports2, module2) {
"use strict";
var OriginalHttpsAgent = __require("https").Agent;
var HttpAgent = require_agent();
var {
INIT_SOCKET,
CREATE_HTTPS_CONNECTION
} = require_constants();
var HttpsAgent = class extends HttpAgent {
constructor(options) {
super(options);
this.defaultPort = 443;
this.protocol = "https:";
this.maxCachedSessions = this.options.maxCachedSessions;
if (this.maxCachedSessions === void 0) {
this.maxCachedSessions = 100;
}
this._sessionCache = {
map: {},
list: []
};
}
createConnection(options, oncreate) {
const socket = this[CREATE_HTTPS_CONNECTION](options, oncreate);
this[INIT_SOCKET](socket, options);
return socket;
}
};
HttpsAgent.prototype[CREATE_HTTPS_CONNECTION] = OriginalHttpsAgent.prototype.createConnection;
[
"getName",
"_getSession",
"_cacheSession",
// https://github.com/nodejs/node/pull/4982
"_evictSession"
].forEach(function(method2) {
if (typeof OriginalHttpsAgent.prototype[method2] === "function") {
HttpsAgent.prototype[method2] = OriginalHttpsAgent.prototype[method2];
}
});
module2.exports = HttpsAgent;
}
});
// node_modules/agentkeepalive/index.js
var require_agentkeepalive = __commonJS({
"node_modules/agentkeepalive/index.js"(exports2, module2) {
"use strict";
module2.exports = require_agent();
module2.exports.HttpsAgent = require_https_agent();
module2.exports.constants = require_constants();
}
});
// node_modules/delayed-stream/lib/delayed_stream.js
var require_delayed_stream = __commonJS({
"node_modules/delayed-stream/lib/delayed_stream.js"(exports2, module2) {
"use strict";
var Stream = __require("stream").Stream;
var util46 = __require("util");
module2.exports = DelayedStream;
function DelayedStream() {
this.source = null;
this.dataSize = 0;
this.maxDataSize = 1024 * 1024;
this.pauseStream = true;
this._maxDataSizeExceeded = false;
this._released = false;
this._bufferedEvents = [];
}
util46.inherits(DelayedStream, Stream);
DelayedStream.create = function(source, options) {
var delayedStream = new this();
options = options || {};
for (var option in options) {
delayedStream[option] = options[option];
}
delayedStream.source = source;
var realEmit = source.emit;
source.emit = function() {
delayedStream._handleEmit(arguments);
return realEmit.apply(source, arguments);
};
source.on("error", function() {
});
if (delayedStream.pauseStream) {
source.pause();
}
return delayedStream;
};
Object.defineProperty(DelayedStream.prototype, "readable", {
configurable: true,
enumerable: true,
get: function() {
return this.source.readable;
}
});
DelayedStream.prototype.setEncoding = function() {
return this.source.setEncoding.apply(this.source, arguments);
};
DelayedStream.prototype.resume = function() {
if (!this._released) {
this.release();
}
this.source.resume();
};
DelayedStream.prototype.pause = function() {
this.source.pause();
};
DelayedStream.prototype.release = function() {
this._released = true;
this._bufferedEvents.forEach(function(args) {
this.emit.apply(this, args);
}.bind(this));
this._bufferedEvents = [];
};
DelayedStream.prototype.pipe = function() {
var r = Stream.prototype.pipe.apply(this, arguments);
this.resume();
return r;
};
DelayedStream.prototype._handleEmit = function(args) {
if (this._released) {
this.emit.apply(this, args);
return;
}
if (args[0] === "data") {
this.dataSize += args[1].length;
this._checkIfMaxDataSizeExceeded();
}
this._bufferedEvents.push(args);
};
DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
if (this._maxDataSizeExceeded) {
return;
}
if (this.dataSize <= this.maxDataSize) {
return;
}
this._maxDataSizeExceeded = true;
var message = "DelayedStream#maxDataSize of " + this.maxDataSize + " bytes exceeded.";
this.emit("error", new Error(message));
};
}
});
// node_modules/combined-stream/lib/combined_stream.js
var require_combined_stream = __commonJS({
"node_modules/combined-stream/lib/combined_stream.js"(exports2, module2) {
"use strict";
var util46 = __require("util");
var Stream = __require("stream").Stream;
var DelayedStream = require_delayed_stream();
module2.exports = CombinedStream;
function CombinedStream() {
this.writable = false;
this.readable = true;
this.dataSize = 0;
this.maxDataSize = 2 * 1024 * 1024;
this.pauseStreams = true;
this._released = false;
this._streams = [];
this._currentStream = null;
this._insideLoop = false;
this._pendingNext = false;
}
util46.inherits(CombinedStream, Stream);
CombinedStream.create = function(options) {
var combinedStream = new this();
options = options || {};
for (var option in options) {
combinedStream[option] = options[option];
}
return combinedStream;
};
CombinedStream.isStreamLike = function(stream4) {
return typeof stream4 !== "function" && typeof stream4 !== "string" && typeof stream4 !== "boolean" && typeof stream4 !== "number" && !Buffer.isBuffer(stream4);
};
CombinedStream.prototype.append = function(stream4) {
var isStreamLike = CombinedStream.isStreamLike(stream4);
if (isStreamLike) {
if (!(stream4 instanceof DelayedStream)) {
var newStream = DelayedStream.create(stream4, {
maxDataSize: Infinity,
pauseStream: this.pauseStreams
});
stream4.on("data", this._checkDataSize.bind(this));
stream4 = newStream;
}
this._handleErrors(stream4);
if (this.pauseStreams) {
stream4.pause();
}
}
this._streams.push(stream4);
return this;
};
CombinedStream.prototype.pipe = function(dest, options) {
Stream.prototype.pipe.call(this, dest, options);
this.resume();
return dest;
};
CombinedStream.prototype._getNext = function() {
this._currentStream = null;
if (this._insideLoop) {
this._pendingNext = true;
return;
}
this._insideLoop = true;
try {
do {
this._pendingNext = false;
this._realGetNext();
} while (this._pendingNext);
} finally {
this._insideLoop = false;
}
};
CombinedStream.prototype._realGetNext = function() {
var stream4 = this._streams.shift();
if (typeof stream4 == "undefined") {
this.end();
return;
}
if (typeof stream4 !== "function") {
this._pipeNext(stream4);
return;
}
var getStream = stream4;
getStream(function(stream5) {
var isStreamLike = CombinedStream.isStreamLike(stream5);
if (isStreamLike) {
stream5.on("data", this._checkDataSize.bind(this));
this._handleErrors(stream5);
}
this._pipeNext(stream5);
}.bind(this));
};
CombinedStream.prototype._pipeNext = function(stream4) {
this._currentStream = stream4;
var isStreamLike = CombinedStream.isStreamLike(stream4);
if (isStreamLike) {
stream4.on("end", this._getNext.bind(this));
stream4.pipe(this, { end: false });
return;
}
var value = stream4;
this.write(value);
this._getNext();
};
CombinedStream.prototype._handleErrors = function(stream4) {
var self2 = this;
stream4.on("error", function(err) {
self2._emitError(err);
});
};
CombinedStream.prototype.write = function(data) {
this.emit("data", data);
};
CombinedStream.prototype.pause = function() {
if (!this.pauseStreams) {
return;
}
if (this.pauseStreams && this._currentStream && typeof this._currentStream.pause == "function") this._currentStream.pause();
this.emit("pause");
};
CombinedStream.prototype.resume = function() {
if (!this._released) {
this._released = true;
this.writable = true;
this._getNext();
}
if (this.pauseStreams && this._currentStream && typeof this._currentStream.resume == "function") this._currentStream.resume();
this.emit("resume");
};
CombinedStream.prototype.end = function() {
this._reset();
this.emit("end");
};
CombinedStream.prototype.destroy = function() {
this._reset();
this.emit("close");
};
CombinedStream.prototype._reset = function() {
this.writable = false;
this._streams = [];
this._currentStream = null;
};
CombinedStream.prototype._checkDataSize = function() {
this._updateDataSize();
if (this.dataSize <= this.maxDataSize) {
return;
}
var message = "DelayedStream#maxDataSize of " + this.maxDataSize + " bytes exceeded.";
this._emitError(new Error(message));
};
CombinedStream.prototype._updateDataSize = function() {
this.dataSize = 0;
var self2 = this;
this._streams.forEach(function(stream4) {
if (!stream4.dataSize) {
return;
}
self2.dataSize += stream4.dataSize;
});
if (this._currentStream && this._currentStream.dataSize) {
this.dataSize += this._currentStream.dataSize;
}
};
CombinedStream.prototype._emitError = function(err) {
this._reset();
this.emit("error", err);
};
}
});
// node_modules/mime-db/db.json
var require_db = __commonJS({
"node_modules/mime-db/db.json"(exports2, module2) {
module2.exports = {
"application/1d-interleaved-parityfec": {
source: "iana"
},
"application/3gpdash-qoe-report+xml": {
source: "iana",
charset: "UTF-8",
compressible: true
},
"application/3gpp-ims+xml": {
source: "iana",
compressible: true
},
"application/3gpphal+json": {
source: "iana",
compressible: true
},
"application/3gpphalforms+json": {
source: "iana",
compressible: true
},
"application/a2l": {
source: "iana"
},
"application/ace+cbor": {
source: "iana"
},
"application/activemessage": {
source: "iana"
},
"application/activity+json": {
source: "iana",
compressible: true
},
"application/alto-costmap+json": {
source: "iana",
compressible: true
},
"application/alto-costmapfilter+json": {
source: "iana",
compressible: true
},
"application/alto-directory+json": {
source: "iana",
compressible: true
},
"application/alto-endpointcost+json": {
source: "iana",
compressible: true
},
"application/alto-endpointcostparams+json": {
source: "iana",
compressible: true
},
"application/alto-endpointprop+json": {
source: "iana",
compressible: true
},
"application/alto-endpointpropparams+json": {
source: "iana",
compressible: true
},
"application/alto-error+json": {
source: "iana",
compressible: true
},
"application/alto-networkmap+json": {
source: "iana",
compressible: true
},
"application/alto-networkmapfilter+json": {
source: "iana",
compressible: true
},
"application/alto-updatestreamcontrol+json": {
source: "iana",
compressible: true
},
"application/alto-updatestreamparams+json": {
source: "iana",
compressible: true
},
"application/aml": {
source: "iana"
},
"application/andrew-inset": {
source: "iana",
extensions: ["ez"]
},
"application/applefile": {
source: "iana"
},
"application/applixware": {
source: "apache",
extensions: ["aw"]
},
"application/at+jwt": {
source: "iana"
},
"application/atf": {
source: "iana"
},
"application/atfx": {
source: "iana"
},
"application/atom+xml": {
source: "iana",
compressible: true,
extensions: ["atom"]
},
"application/atomcat+xml": {
source: "iana",
compressible: true,
extensions: ["atomcat"]
},
"application/atomdeleted+xml": {
source: "iana",
compressible: true,
extensions: ["atomdeleted"]
},
"application/atomicmail": {
source: "iana"
},
"application/atomsvc+xml": {
source: "iana",
compressible: true,
extensions: ["atomsvc"]
},
"application/atsc-dwd+xml": {
source: "iana",
compressible: true,
extensions: ["dwd"]
},
"application/atsc-dynamic-event-message": {
source: "iana"
},
"application/atsc-held+xml": {
source: "iana",
compressible: true,
extensions: ["held"]
},
"application/atsc-rdt+json": {
source: "iana",
compressible: true
},
"application/atsc-rsat+xml": {
source: "iana",
compressible: true,
extensions: ["rsat"]
},
"application/atxml": {
source: "iana"
},
"application/auth-policy+xml": {
source: "iana",
compressible: true
},
"application/bacnet-xdd+zip": {
source: "iana",
compressible: false
},
"application/batch-smtp": {
source: "iana"
},
"application/bdoc": {
compressible: false,
extensions: ["bdoc"]
},
"application/beep+xml": {
source: "iana",
charset: "UTF-8",
compressible: true
},
"application/calendar+json": {
source: "iana",
compressible: true
},
"application/calendar+xml": {
source: "iana",
compressible: true,
extensions: ["xcs"]
},
"application/call-completion": {
source: "iana"
},
"application/cals-1840": {
source: "iana"
},
"application/captive+json": {
source: "iana",
compressible: true
},
"application/cbor": {
source: "iana"
},
"application/cbor-seq": {
source: "iana"
},
"application/cccex": {
source: "iana"
},
"application/ccmp+xml": {
source: "iana",
compressible: true
},
"application/ccxml+xml": {
source: "iana",
compressible: true,
extensions: ["ccxml"]
},
"application/cdfx+xml": {
source: "iana",
compressible: true,
extensions: ["cdfx"]
},
"application/cdmi-capability": {
source: "iana",
extensions: ["cdmia"]
},
"application/cdmi-container": {
source: "iana",
extensions: ["cdmic"]
},
"application/cdmi-domain": {
source: "iana",
extensions: ["cdmid"]
},
"application/cdmi-object": {
source: "iana",
extensions: ["cdmio"]
},
"application/cdmi-queue": {
source: "iana",
extensions: ["cdmiq"]
},
"application/cdni": {
source: "iana"
},
"application/cea": {
source: "iana"
},
"application/cea-2018+xml": {
source: "iana",
compressible: true
},
"application/cellml+xml": {
source: "iana",
compressible: true
},
"application/cfw": {
source: "iana"
},
"application/city+json": {
source: "iana",
compressible: true
},
"application/clr": {
source: "iana"
},
"application/clue+xml": {
source: "iana",
compressible: true
},
"application/clue_info+xml": {
source: "iana",
compressible: true
},
"application/cms": {
source: "iana"
},
"application/cnrp+xml": {
source: "iana",
compressible: true
},
"application/coap-group+json": {
source: "iana",
compressible: true
},
"application/coap-payload": {
source: "iana"
},
"application/commonground": {
source: "iana"
},
"application/conference-info+xml": {
source: "iana",
compressible: true
},
"application/cose": {
source: "iana"
},
"application/cose-key": {
source: "iana"
},
"application/cose-key-set": {
source: "iana"
},
"application/cpl+xml": {
source: "iana",
compressible: true,
extensions: ["cpl"]
},
"application/csrattrs": {
source: "iana"
},
"application/csta+xml": {
source: "iana",
compressible: true
},
"application/cstadata+xml": {
source: "iana",
compressible: true
},
"application/csvm+json": {
source: "iana",
compressible: true
},
"application/cu-seeme": {
source: "apache",
extensions: ["cu"]
},
"application/cwt": {
source: "iana"
},
"application/cybercash": {
source: "iana"
},
"application/dart": {
compressible: true
},
"application/dash+xml": {
source: "iana",
compressible: true,
extensions: ["mpd"]
},
"application/dash-patch+xml": {
source: "iana",
compressible: true,
extensions: ["mpp"]
},
"application/dashdelta": {
source: "iana"
},
"application/davmount+xml": {
source: "iana",
compressible: true,
extensions: ["davmount"]
},
"application/dca-rft": {
source: "iana"
},
"application/dcd": {
source: "iana"
},
"application/dec-dx": {
source: "iana"
},
"application/dialog-info+xml": {
source: "iana",
compressible: true
},
"application/dicom": {
source: "iana"
},
"application/dicom+json": {
source: "iana",
compressible: true
},
"application/dicom+xml": {
source: "iana",
compressible: true
},
"application/dii": {
source: "iana"
},
"application/dit": {
source: "iana"
},
"application/dns": {
source: "iana"
},
"application/dns+json": {
source: "iana",
compressible: true
},
"application/dns-message": {
source: "iana"
},
"application/docbook+xml": {
source: "apache",
compressible: true,
extensions: ["dbk"]
},
"application/dots+cbor": {
source: "iana"
},
"application/dskpp+xml": {
source: "iana",
compressible: true
},
"application/dssc+der": {
source: "iana",
extensions: ["dssc"]
},
"application/dssc+xml": {
source: "iana",
compressible: true,
extensions: ["xdssc"]
},
"application/dvcs": {
source: "iana"
},
"application/ecmascript": {
source: "iana",
compressible: true,
extensions: ["es", "ecma"]
},
"application/edi-consent": {
source: "iana"
},
"application/edi-x12": {
source: "iana",
compressible: false
},
"application/edifact": {
source: "iana",
compressible: false
},
"application/efi": {
source: "iana"
},
"application/elm+json": {
source: "iana",
charset: "UTF-8",
compressible: true
},
"application/elm+xml": {
source: "iana",
compressible: true
},
"application/emergencycalldata.cap+xml": {
source: "iana",
charset: "UTF-8",
compressible: true
},
"application/emergencycalldata.comment+xml": {
source: "iana",
compressible: true
},
"application/emergencycalldata.control+xml": {
source: "iana",
compressible: true
},
"application/emergencycalldata.deviceinfo+xml": {
source: "iana",
compressible: true
},
"application/emergencycalldata.ecall.msd": {
source: "iana"
},
"application/emergencycalldata.providerinfo+xml": {
source: "iana",
compressible: true
},
"application/emergencycalldata.serviceinfo+xml": {
source: "iana",
compressible: true
},
"application/emergencycalldata.subscriberinfo+xml": {
source: "iana",
compressible: true
},
"application/emergencycalldata.veds+xml": {
source: "iana",
compressible: true
},
"application/emma+xml": {
source: "iana",
compressible: true,
extensions: ["emma"]
},
"application/emotionml+xml": {
source: "iana",
compressible: true,
extensions: ["emotionml"]
},
"application/encaprtp": {
source: "iana"
},
"application/epp+xml": {
source: "iana",
compressible: true
},
"application/epub+zip": {
source: "iana",
compressible: false,
extensions: ["epub"]
},
"application/eshop": {
source: "iana"
},
"application/exi": {
source: "iana",
extensions: ["exi"]
},
"application/expect-ct-report+json": {
source: "iana",
compressible: true
},
"application/express": {
source: "iana",
extensions: ["exp"]
},
"application/fastinfoset": {
source: "iana"
},
"application/fastsoap": {
source: "iana"
},
"application/fdt+xml": {
source: "iana",
compressible: true,
extensions: ["fdt"]
},
"application/fhir+json": {
source: "iana",
charset: "UTF-8",
compressible: true
},
"application/fhir+xml": {
source: "iana",
charset: "UTF-8",
compressible: true
},
"application/fido.trusted-apps+json": {
compressible: true
},
"application/fits": {
source: "iana"
},
"application/flexfec": {
source: "iana"
},
"application/font-sfnt": {
source: "iana"
},
"application/font-tdpfr": {
source: "iana",
extensions: ["pfr"]
},
"application/font-woff": {
source: "iana",
compressible: false
},
"application/framework-attributes+xml": {
source: "iana",
compressible: true
},
"application/geo+json": {
source: "iana",
compressible: true,
extensions: ["geojson"]
},
"application/geo+json-seq": {
source: "iana"
},
"application/geopackage+sqlite3": {
source: "iana"
},
"application/geoxacml+xml": {
source: "iana",
compressible: true
},
"application/gltf-buffer": {
source: "iana"
},
"application/gml+xml": {
source: "iana",
compressible: true,
extensions: ["gml"]
},
"application/gpx+xml": {
source: "apache",
compressible: true,
extensions: ["gpx"]
},
"application/gxf": {
source: "apache",
extensions: ["gxf"]
},
"application/gzip": {
source: "iana",
compressible: false,
extensions: ["gz"]
},
"application/h224": {
source: "iana"
},
"application/held+xml": {
source: "iana",
compressible: true
},
"application/hjson": {
extensions: ["hjson"]
},
"application/http": {
source: "iana"
},
"application/hyperstudio": {
source: "iana",
extensions: ["stk"]
},
"application/ibe-key-request+xml": {
source: "iana",
compressible: true
},
"application/ibe-pkg-reply+xml": {
source: "iana",
compressible: true
},
"application/ibe-pp-data": {
source: "iana"
},
"application/iges": {
source: "iana"
},
"application/im-iscomposing+xml": {
source: "iana",
charset: "UTF-8",
compressible: true
},
"application/index": {
source: "iana"
},
"application/index.cmd": {
source: "iana"
},
"application/index.obj": {
source: "iana"
},
"application/index.response": {
source: "iana"
},
"application/index.vnd": {
source: "iana"
},
"application/inkml+xml": {
source: "iana",
compressible: true,
extensions: ["ink", "inkml"]
},
"application/iotp": {
source: "iana"
},
"application/ipfix": {
source: "iana",
extensions: ["ipfix"]
},
"application/ipp": {
source: "iana"
},
"application/isup": {
source: "iana"
},
"application/its+xml": {
source: "iana",
compressible: true,
extensions: ["its"]
},
"application/java-archive": {
source: "apache",
compressible: false,
extensions: ["jar", "war", "ear"]
},
"application/java-serialized-object": {
source: "apache",
compressible: false,
extensions: ["ser"]
},
"application/java-vm": {
source: "apache",
compressible: false,
extensions: ["class"]
},
"application/javascript": {
source: "iana",
charset: "UTF-8",
compressible: true,
extensions: ["js", "mjs"]
},
"application/jf2feed+json": {
source: "iana",
compressible: true
},
"application/jose": {
source: "iana"
},
"application/jose+json": {
source: "iana",
compressible: true
},
"application/jrd+json": {
source: "iana",
compressible: true
},
"application/jscalendar+json": {
source: "iana",
compressible: true
},
"application/json": {
source: "iana",
charset: "UTF-8",
compressible: true,
extensions: ["json", "map"]
},
"application/json-patch+json": {
source: "iana",
compressible: true
},
"application/json-seq": {
source: "iana"
},
"application/json5": {
extensions: ["json5"]
},
"application/jsonml+json": {
source: "apache",
compressible: true,
extensions: ["jsonml"]
},
"application/jwk+json": {
source: "iana",
compressible: true
},
"application/jwk-set+json": {
source: "iana",
compressible: true
},
"application/jwt": {
source: "iana"
},
"application/kpml-request+xml": {
source: "iana",
compressible: true
},
"application/kpml-response+xml": {
source: "iana",
compressible: true
},
"application/ld+json": {
source: "iana",
compressible: true,
extensions: ["jsonld"]
},
"application/lgr+xml": {
source: "iana",
compressible: true,
extensions: ["lgr"]
},
"application/link-format": {
source: "iana"
},
"application/load-control+xml": {
source: "iana",
compressible: true
},
"application/lost+xml": {
source: "iana",
compressible: true,
extensions: ["lostxml"]
},
"application/lostsync+xml": {
source: "iana",
compressible: true
},
"application/lpf+zip": {
source: "iana",
compressible: false
},
"application/lxf": {
source: "iana"
},
"application/mac-binhex40": {
source: "iana",
extensions: ["hqx"]
},
"application/mac-compactpro": {
source: "apache",
extensions: ["cpt"]
},
"application/macwriteii": {
source: "iana"
},
"application/mads+xml": {
source: "iana",
compressible: true,
extensions: ["mads"]
},
"application/manifest+json": {
source: "iana",
charset: "UTF-8",
compressible: true,
extensions: ["webmanifest"]
},
"application/marc": {
source: "iana",
extensions: ["mrc"]
},
"application/marcxml+xml": {
source: "iana",
compressible: true,
extensions: ["mrcx"]
},
"application/mathematica": {
source: "iana",
extensions: ["ma", "nb", "mb"]
},
"application/mathml+xml": {
source: "iana",
compressible: true,
extensions: ["mathml"]
},
"application/mathml-content+xml": {
source: "iana",
compressible: true
},
"application/mathml-presentation+xml": {
source: "iana",
compressible: true
},
"application/mbms-associated-procedure-description+xml": {
source: "iana",
compressible: true
},
"application/mbms-deregister+xml": {
source: "iana",
compressible: true
},
"application/mbms-envelope+xml": {
source: "iana",
compressible: true
},
"application/mbms-msk+xml": {
source: "iana",
compressible: true
},
"application/mbms-msk-response+xml": {
source: "iana",
compressible: true
},
"application/mbms-protection-description+xml": {
source: "iana",
compressible: true
},
"application/mbms-reception-report+xml": {
source: "iana",
com