UNPKG

bunnel-server

Version:
1,533 lines (1,507 loc) 232 kB
#!/usr/bin/env bun // @bun var __create = Object.create; var __getProtoOf = Object.getPrototypeOf; var __defProp = Object.defineProperty; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __toESM = (mod, isNodeMode, target) => { target = mod != null ? __create(__getProtoOf(mod)) : {}; const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target; for (let key of __getOwnPropNames(mod)) if (!__hasOwnProp.call(to, key)) __defProp(to, key, { get: () => mod[key], enumerable: true }); return to; }; var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports); var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true, configurable: true, set: (newValue) => all[name] = () => newValue }); }; var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res); var __require = import.meta.require; // node_modules/@noble/hashes/_assert.js var require__assert = __commonJS((exports) => { Object.defineProperty(exports, "__esModule", { value: true }); exports.anumber = anumber; exports.abytes = abytes; exports.ahash = ahash; exports.aexists = aexists; exports.aoutput = aoutput; function anumber(n) { if (!Number.isSafeInteger(n) || n < 0) throw new Error("positive integer expected, got " + n); } function isBytes(a) { return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array"; } function abytes(b, ...lengths) { if (!isBytes(b)) throw new Error("Uint8Array expected"); if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length); } function ahash(h) { if (typeof h !== "function" || typeof h.create !== "function") throw new Error("Hash should be wrapped by utils.wrapConstructor"); anumber(h.outputLen); anumber(h.blockLen); } function aexists(instance, checkFinished = true) { if (instance.destroyed) throw new Error("Hash instance has been destroyed"); if (checkFinished && instance.finished) throw new Error("Hash#digest() has already been called"); } function aoutput(out, instance) { abytes(out); const min = instance.outputLen; if (out.length < min) { throw new Error("digestInto() expects output buffer of length at least " + min); } } }); // node_modules/@noble/hashes/_u64.js var require__u64 = __commonJS((exports) => { Object.defineProperty(exports, "__esModule", { value: true }); exports.add5L = exports.add5H = exports.add4H = exports.add4L = exports.add3H = exports.add3L = exports.rotlBL = exports.rotlBH = exports.rotlSL = exports.rotlSH = exports.rotr32L = exports.rotr32H = exports.rotrBL = exports.rotrBH = exports.rotrSL = exports.rotrSH = exports.shrSL = exports.shrSH = exports.toBig = undefined; exports.fromBig = fromBig; exports.split = split; exports.add = add; var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1); var _32n = /* @__PURE__ */ BigInt(32); function fromBig(n, le = false) { if (le) return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) }; return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 }; } function split(lst, le = false) { let Ah = new Uint32Array(lst.length); let Al = new Uint32Array(lst.length); for (let i = 0;i < lst.length; i++) { const { h, l } = fromBig(lst[i], le); [Ah[i], Al[i]] = [h, l]; } return [Ah, Al]; } var toBig = (h, l) => BigInt(h >>> 0) << _32n | BigInt(l >>> 0); exports.toBig = toBig; var shrSH = (h, _l, s) => h >>> s; exports.shrSH = shrSH; var shrSL = (h, l, s) => h << 32 - s | l >>> s; exports.shrSL = shrSL; var rotrSH = (h, l, s) => h >>> s | l << 32 - s; exports.rotrSH = rotrSH; var rotrSL = (h, l, s) => h << 32 - s | l >>> s; exports.rotrSL = rotrSL; var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32; exports.rotrBH = rotrBH; var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s; exports.rotrBL = rotrBL; var rotr32H = (_h, l) => l; exports.rotr32H = rotr32H; var rotr32L = (h, _l) => h; exports.rotr32L = rotr32L; var rotlSH = (h, l, s) => h << s | l >>> 32 - s; exports.rotlSH = rotlSH; var rotlSL = (h, l, s) => l << s | h >>> 32 - s; exports.rotlSL = rotlSL; var rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s; exports.rotlBH = rotlBH; var rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s; exports.rotlBL = rotlBL; function add(Ah, Al, Bh, Bl) { const l = (Al >>> 0) + (Bl >>> 0); return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 }; } var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0); exports.add3L = add3L; var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0; exports.add3H = add3H; var add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0); exports.add4L = add4L; var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0; exports.add4H = add4H; var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0); exports.add5L = add5L; var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0; exports.add5H = add5H; var u64 = { fromBig, split, toBig, shrSH, shrSL, rotrSH, rotrSL, rotrBH, rotrBL, rotr32H, rotr32L, rotlSH, rotlSL, rotlBH, rotlBL, add, add3L, add3H, add4L, add4H, add5H, add5L }; exports.default = u64; }); // node_modules/@noble/hashes/cryptoNode.js var require_cryptoNode = __commonJS((exports) => { Object.defineProperty(exports, "__esModule", { value: true }); exports.crypto = undefined; var nc = __require("crypto"); exports.crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && ("randomBytes" in nc) ? nc : undefined; }); // node_modules/@noble/hashes/utils.js var require_utils = __commonJS((exports) => { /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Hash = exports.nextTick = exports.byteSwapIfBE = exports.isLE = undefined; exports.isBytes = isBytes; exports.u8 = u8; exports.u32 = u32; exports.createView = createView; exports.rotr = rotr; exports.rotl = rotl; exports.byteSwap = byteSwap; exports.byteSwap32 = byteSwap32; exports.bytesToHex = bytesToHex; exports.hexToBytes = hexToBytes; exports.asyncLoop = asyncLoop; exports.utf8ToBytes = utf8ToBytes; exports.toBytes = toBytes; exports.concatBytes = concatBytes; exports.checkOpts = checkOpts; exports.wrapConstructor = wrapConstructor; exports.wrapConstructorWithOpts = wrapConstructorWithOpts; exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts; exports.randomBytes = randomBytes; var crypto_1 = require_cryptoNode(); var _assert_js_1 = require__assert(); function isBytes(a) { return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array"; } function u8(arr) { return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength); } function u32(arr) { return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4)); } function createView(arr) { return new DataView(arr.buffer, arr.byteOffset, arr.byteLength); } function rotr(word, shift) { return word << 32 - shift | word >>> shift; } function rotl(word, shift) { return word << shift | word >>> 32 - shift >>> 0; } exports.isLE = (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)(); function byteSwap(word) { return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255; } exports.byteSwapIfBE = exports.isLE ? (n) => n : (n) => byteSwap(n); function byteSwap32(arr) { for (let i = 0;i < arr.length; i++) { arr[i] = byteSwap(arr[i]); } } var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0")); function bytesToHex(bytes) { (0, _assert_js_1.abytes)(bytes); let hex = ""; for (let i = 0;i < bytes.length; i++) { hex += hexes[bytes[i]]; } return hex; } var asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }; function asciiToBase16(ch) { if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); return; } function hexToBytes(hex) { if (typeof hex !== "string") throw new Error("hex string expected, got " + typeof hex); const hl = hex.length; const al = hl / 2; if (hl % 2) throw new Error("hex string expected, got unpadded hex of length " + hl); const array = new Uint8Array(al); for (let ai = 0, hi = 0;ai < al; ai++, hi += 2) { const n1 = asciiToBase16(hex.charCodeAt(hi)); const n2 = asciiToBase16(hex.charCodeAt(hi + 1)); if (n1 === undefined || n2 === undefined) { const char = hex[hi] + hex[hi + 1]; throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi); } array[ai] = n1 * 16 + n2; } return array; } var nextTick = async () => { }; exports.nextTick = nextTick; async function asyncLoop(iters, tick, cb) { let ts = Date.now(); for (let i = 0;i < iters; i++) { cb(i); const diff = Date.now() - ts; if (diff >= 0 && diff < tick) continue; await (0, exports.nextTick)(); ts += diff; } } function utf8ToBytes(str) { if (typeof str !== "string") throw new Error("utf8ToBytes expected string, got " + typeof str); return new Uint8Array(new TextEncoder().encode(str)); } function toBytes(data) { if (typeof data === "string") data = utf8ToBytes(data); (0, _assert_js_1.abytes)(data); return data; } function concatBytes(...arrays) { let sum = 0; for (let i = 0;i < arrays.length; i++) { const a = arrays[i]; (0, _assert_js_1.abytes)(a); sum += a.length; } const res = new Uint8Array(sum); for (let i = 0, pad = 0;i < arrays.length; i++) { const a = arrays[i]; res.set(a, pad); pad += a.length; } return res; } class Hash { clone() { return this._cloneInto(); } } exports.Hash = Hash; function checkOpts(defaults, opts) { if (opts !== undefined && {}.toString.call(opts) !== "[object Object]") throw new Error("Options should be object or undefined"); const merged = Object.assign(defaults, opts); return merged; } function wrapConstructor(hashCons) { const hashC = (msg) => hashCons().update(toBytes(msg)).digest(); const tmp = hashCons(); hashC.outputLen = tmp.outputLen; hashC.blockLen = tmp.blockLen; hashC.create = () => hashCons(); return hashC; } function wrapConstructorWithOpts(hashCons) { const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); const tmp = hashCons({}); hashC.outputLen = tmp.outputLen; hashC.blockLen = tmp.blockLen; hashC.create = (opts) => hashCons(opts); return hashC; } function wrapXOFConstructorWithOpts(hashCons) { const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); const tmp = hashCons({}); hashC.outputLen = tmp.outputLen; hashC.blockLen = tmp.blockLen; hashC.create = (opts) => hashCons(opts); return hashC; } function randomBytes(bytesLength = 32) { if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === "function") { return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength)); } if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === "function") { return crypto_1.crypto.randomBytes(bytesLength); } throw new Error("crypto.getRandomValues must be defined"); } }); // node_modules/@noble/hashes/sha3.js var require_sha3 = __commonJS((exports) => { Object.defineProperty(exports, "__esModule", { value: true }); exports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = undefined; exports.keccakP = keccakP; var _assert_js_1 = require__assert(); var _u64_js_1 = require__u64(); var utils_js_1 = require_utils(); var SHA3_PI = []; var SHA3_ROTL = []; var _SHA3_IOTA = []; var _0n = /* @__PURE__ */ BigInt(0); var _1n = /* @__PURE__ */ BigInt(1); var _2n = /* @__PURE__ */ BigInt(2); var _7n = /* @__PURE__ */ BigInt(7); var _256n = /* @__PURE__ */ BigInt(256); var _0x71n = /* @__PURE__ */ BigInt(113); for (let round = 0, R = _1n, x = 1, y = 0;round < 24; round++) { [x, y] = [y, (2 * x + 3 * y) % 5]; SHA3_PI.push(2 * (5 * y + x)); SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64); let t = _0n; for (let j = 0;j < 7; j++) { R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n; if (R & _2n) t ^= _1n << (_1n << /* @__PURE__ */ BigInt(j)) - _1n; } _SHA3_IOTA.push(t); } var [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ (0, _u64_js_1.split)(_SHA3_IOTA, true); var rotlH = (h, l, s) => s > 32 ? (0, _u64_js_1.rotlBH)(h, l, s) : (0, _u64_js_1.rotlSH)(h, l, s); var rotlL = (h, l, s) => s > 32 ? (0, _u64_js_1.rotlBL)(h, l, s) : (0, _u64_js_1.rotlSL)(h, l, s); function keccakP(s, rounds = 24) { const B = new Uint32Array(5 * 2); for (let round = 24 - rounds;round < 24; round++) { for (let x = 0;x < 10; x++) B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40]; for (let x = 0;x < 10; x += 2) { const idx1 = (x + 8) % 10; const idx0 = (x + 2) % 10; const B0 = B[idx0]; const B1 = B[idx0 + 1]; const Th = rotlH(B0, B1, 1) ^ B[idx1]; const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1]; for (let y = 0;y < 50; y += 10) { s[x + y] ^= Th; s[x + y + 1] ^= Tl; } } let curH = s[2]; let curL = s[3]; for (let t = 0;t < 24; t++) { const shift = SHA3_ROTL[t]; const Th = rotlH(curH, curL, shift); const Tl = rotlL(curH, curL, shift); const PI = SHA3_PI[t]; curH = s[PI]; curL = s[PI + 1]; s[PI] = Th; s[PI + 1] = Tl; } for (let y = 0;y < 50; y += 10) { for (let x = 0;x < 10; x++) B[x] = s[y + x]; for (let x = 0;x < 10; x++) s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10]; } s[0] ^= SHA3_IOTA_H[round]; s[1] ^= SHA3_IOTA_L[round]; } B.fill(0); } class Keccak extends utils_js_1.Hash { constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) { super(); this.blockLen = blockLen; this.suffix = suffix; this.outputLen = outputLen; this.enableXOF = enableXOF; this.rounds = rounds; this.pos = 0; this.posOut = 0; this.finished = false; this.destroyed = false; (0, _assert_js_1.anumber)(outputLen); if (0 >= this.blockLen || this.blockLen >= 200) throw new Error("Sha3 supports only keccak-f1600 function"); this.state = new Uint8Array(200); this.state32 = (0, utils_js_1.u32)(this.state); } keccak() { if (!utils_js_1.isLE) (0, utils_js_1.byteSwap32)(this.state32); keccakP(this.state32, this.rounds); if (!utils_js_1.isLE) (0, utils_js_1.byteSwap32)(this.state32); this.posOut = 0; this.pos = 0; } update(data) { (0, _assert_js_1.aexists)(this); const { blockLen, state } = this; data = (0, utils_js_1.toBytes)(data); const len = data.length; for (let pos = 0;pos < len; ) { const take = Math.min(blockLen - this.pos, len - pos); for (let i = 0;i < take; i++) state[this.pos++] ^= data[pos++]; if (this.pos === blockLen) this.keccak(); } return this; } finish() { if (this.finished) return; this.finished = true; const { state, suffix, pos, blockLen } = this; state[pos] ^= suffix; if ((suffix & 128) !== 0 && pos === blockLen - 1) this.keccak(); state[blockLen - 1] ^= 128; this.keccak(); } writeInto(out) { (0, _assert_js_1.aexists)(this, false); (0, _assert_js_1.abytes)(out); this.finish(); const bufferOut = this.state; const { blockLen } = this; for (let pos = 0, len = out.length;pos < len; ) { if (this.posOut >= blockLen) this.keccak(); const take = Math.min(blockLen - this.posOut, len - pos); out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos); this.posOut += take; pos += take; } return out; } xofInto(out) { if (!this.enableXOF) throw new Error("XOF is not possible for this instance"); return this.writeInto(out); } xof(bytes) { (0, _assert_js_1.anumber)(bytes); return this.xofInto(new Uint8Array(bytes)); } digestInto(out) { (0, _assert_js_1.aoutput)(out, this); if (this.finished) throw new Error("digest() was already called"); this.writeInto(out); this.destroy(); return out; } digest() { return this.digestInto(new Uint8Array(this.outputLen)); } destroy() { this.destroyed = true; this.state.fill(0); } _cloneInto(to) { const { blockLen, suffix, outputLen, rounds, enableXOF } = this; to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds)); to.state32.set(this.state32); to.pos = this.pos; to.posOut = this.posOut; to.finished = this.finished; to.rounds = rounds; to.suffix = suffix; to.outputLen = outputLen; to.enableXOF = enableXOF; to.destroyed = this.destroyed; return to; } } exports.Keccak = Keccak; var gen = (suffix, blockLen, outputLen) => (0, utils_js_1.wrapConstructor)(() => new Keccak(blockLen, suffix, outputLen)); exports.sha3_224 = gen(6, 144, 224 / 8); exports.sha3_256 = gen(6, 136, 256 / 8); exports.sha3_384 = gen(6, 104, 384 / 8); exports.sha3_512 = gen(6, 72, 512 / 8); exports.keccak_224 = gen(1, 144, 224 / 8); exports.keccak_256 = gen(1, 136, 256 / 8); exports.keccak_384 = gen(1, 104, 384 / 8); exports.keccak_512 = gen(1, 72, 512 / 8); var genShake = (suffix, blockLen, outputLen) => (0, utils_js_1.wrapXOFConstructorWithOpts)((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true)); exports.shake128 = genShake(31, 168, 128 / 8); exports.shake256 = genShake(31, 136, 256 / 8); }); // node_modules/@paralleldrive/cuid2/src/index.js var require_src = __commonJS((exports, module) => { var { sha3_512: sha3 } = require_sha3(); var defaultLength = 24; var bigLength = 32; var createEntropy = (length = 4, random = Math.random) => { let entropy = ""; while (entropy.length < length) { entropy = entropy + Math.floor(random() * 36).toString(36); } return entropy; }; function bufToBigInt(buf) { let bits = 8n; let value = 0n; for (const i of buf.values()) { const bi = BigInt(i); value = (value << bits) + bi; } return value; } var hash = (input = "") => { return bufToBigInt(sha3(input)).toString(36).slice(1); }; var alphabet = Array.from({ length: 26 }, (x, i) => String.fromCharCode(i + 97)); var randomLetter = (random) => alphabet[Math.floor(random() * alphabet.length)]; var createFingerprint = ({ globalObj = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : {}, random = Math.random } = {}) => { const globals = Object.keys(globalObj).toString(); const sourceString = globals.length ? globals + createEntropy(bigLength, random) : createEntropy(bigLength, random); return hash(sourceString).substring(0, bigLength); }; var createCounter = (count) => () => { return count++; }; var initialCountMax = 476782367; var init = ({ random = Math.random, counter = createCounter(Math.floor(random() * initialCountMax)), length = defaultLength, fingerprint = createFingerprint({ random }) } = {}) => { return function cuid2() { const firstLetter = randomLetter(random); const time = Date.now().toString(36); const count = counter().toString(36); const salt = createEntropy(length, random); const hashInput = `${time + salt + count + fingerprint}`; return `${firstLetter + hash(hashInput).substring(1, length)}`; }; }; var createId = init(); var isCuid = (id, { minLength = 2, maxLength = bigLength } = {}) => { const length = id.length; const regex = /^[0-9a-z]+$/; try { if (typeof id === "string" && length >= minLength && length <= maxLength && regex.test(id)) return true; } finally { } return false; }; exports.getConstants = () => ({ defaultLength, bigLength }); exports.init = init; exports.createId = createId; exports.bufToBigInt = bufToBigInt; exports.createCounter = createCounter; exports.createFingerprint = createFingerprint; exports.isCuid = isCuid; }); // node_modules/@paralleldrive/cuid2/index.js var createId, init, getConstants, isCuid, $init; var init_cuid2 = __esm(() => { ({ createId, init, getConstants, isCuid } = require_src()); $init = init; }); // node_modules/pino-std-serializers/lib/err-helpers.js var require_err_helpers = __commonJS((exports, module) => { var isErrorLike = (err) => { return err && typeof err.message === "string"; }; var getErrorCause = (err) => { if (!err) return; const cause = err.cause; if (typeof cause === "function") { const causeResult = err.cause(); return isErrorLike(causeResult) ? causeResult : undefined; } else { return isErrorLike(cause) ? cause : undefined; } }; var _stackWithCauses = (err, seen) => { if (!isErrorLike(err)) return ""; const stack = err.stack || ""; if (seen.has(err)) { return stack + ` causes have become circular...`; } const cause = getErrorCause(err); if (cause) { seen.add(err); return stack + ` caused by: ` + _stackWithCauses(cause, seen); } else { return stack; } }; var stackWithCauses = (err) => _stackWithCauses(err, new Set); var _messageWithCauses = (err, seen, skip) => { if (!isErrorLike(err)) return ""; const message = skip ? "" : err.message || ""; if (seen.has(err)) { return message + ": ..."; } const cause = getErrorCause(err); if (cause) { seen.add(err); const skipIfVErrorStyleCause = typeof err.cause === "function"; return message + (skipIfVErrorStyleCause ? "" : ": ") + _messageWithCauses(cause, seen, skipIfVErrorStyleCause); } else { return message; } }; var messageWithCauses = (err) => _messageWithCauses(err, new Set); module.exports = { isErrorLike, getErrorCause, stackWithCauses, messageWithCauses }; }); // node_modules/pino-std-serializers/lib/err-proto.js var require_err_proto = __commonJS((exports, module) => { var seen = Symbol("circular-ref-tag"); var rawSymbol = Symbol("pino-raw-err-ref"); var pinoErrProto = Object.create({}, { type: { enumerable: true, writable: true, value: undefined }, message: { enumerable: true, writable: true, value: undefined }, stack: { enumerable: true, writable: true, value: undefined }, aggregateErrors: { enumerable: true, writable: true, value: undefined }, raw: { enumerable: false, get: function() { return this[rawSymbol]; }, set: function(val) { this[rawSymbol] = val; } } }); Object.defineProperty(pinoErrProto, rawSymbol, { writable: true, value: {} }); module.exports = { pinoErrProto, pinoErrorSymbols: { seen, rawSymbol } }; }); // node_modules/pino-std-serializers/lib/err.js var require_err = __commonJS((exports, module) => { module.exports = errSerializer; var { messageWithCauses, stackWithCauses, isErrorLike } = require_err_helpers(); var { pinoErrProto, pinoErrorSymbols } = require_err_proto(); var { seen } = pinoErrorSymbols; var { toString } = Object.prototype; function errSerializer(err) { if (!isErrorLike(err)) { return err; } err[seen] = undefined; const _err = Object.create(pinoErrProto); _err.type = toString.call(err.constructor) === "[object Function]" ? err.constructor.name : err.name; _err.message = messageWithCauses(err); _err.stack = stackWithCauses(err); if (Array.isArray(err.errors)) { _err.aggregateErrors = err.errors.map((err2) => errSerializer(err2)); } for (const key in err) { if (_err[key] === undefined) { const val = err[key]; if (isErrorLike(val)) { if (key !== "cause" && !Object.prototype.hasOwnProperty.call(val, seen)) { _err[key] = errSerializer(val); } } else { _err[key] = val; } } } delete err[seen]; _err.raw = err; return _err; } }); // node_modules/pino-std-serializers/lib/err-with-cause.js var require_err_with_cause = __commonJS((exports, module) => { module.exports = errWithCauseSerializer; var { isErrorLike } = require_err_helpers(); var { pinoErrProto, pinoErrorSymbols } = require_err_proto(); var { seen } = pinoErrorSymbols; var { toString } = Object.prototype; function errWithCauseSerializer(err) { if (!isErrorLike(err)) { return err; } err[seen] = undefined; const _err = Object.create(pinoErrProto); _err.type = toString.call(err.constructor) === "[object Function]" ? err.constructor.name : err.name; _err.message = err.message; _err.stack = err.stack; if (Array.isArray(err.errors)) { _err.aggregateErrors = err.errors.map((err2) => errWithCauseSerializer(err2)); } if (isErrorLike(err.cause) && !Object.prototype.hasOwnProperty.call(err.cause, seen)) { _err.cause = errWithCauseSerializer(err.cause); } for (const key in err) { if (_err[key] === undefined) { const val = err[key]; if (isErrorLike(val)) { if (!Object.prototype.hasOwnProperty.call(val, seen)) { _err[key] = errWithCauseSerializer(val); } } else { _err[key] = val; } } } delete err[seen]; _err.raw = err; return _err; } }); // node_modules/pino-std-serializers/lib/req.js var require_req = __commonJS((exports, module) => { module.exports = { mapHttpRequest, reqSerializer }; var rawSymbol = Symbol("pino-raw-req-ref"); var pinoReqProto = Object.create({}, { id: { enumerable: true, writable: true, value: "" }, method: { enumerable: true, writable: true, value: "" }, url: { enumerable: true, writable: true, value: "" }, query: { enumerable: true, writable: true, value: "" }, params: { enumerable: true, writable: true, value: "" }, headers: { enumerable: true, writable: true, value: {} }, remoteAddress: { enumerable: true, writable: true, value: "" }, remotePort: { enumerable: true, writable: true, value: "" }, raw: { enumerable: false, get: function() { return this[rawSymbol]; }, set: function(val) { this[rawSymbol] = val; } } }); Object.defineProperty(pinoReqProto, rawSymbol, { writable: true, value: {} }); function reqSerializer(req) { const connection = req.info || req.socket; const _req = Object.create(pinoReqProto); _req.id = typeof req.id === "function" ? req.id() : req.id || (req.info ? req.info.id : undefined); _req.method = req.method; if (req.originalUrl) { _req.url = req.originalUrl; } else { const path = req.path; _req.url = typeof path === "string" ? path : req.url ? req.url.path || req.url : undefined; } if (req.query) { _req.query = req.query; } if (req.params) { _req.params = req.params; } _req.headers = req.headers; _req.remoteAddress = connection && connection.remoteAddress; _req.remotePort = connection && connection.remotePort; _req.raw = req.raw || req; return _req; } function mapHttpRequest(req) { return { req: reqSerializer(req) }; } }); // node_modules/pino-std-serializers/lib/res.js var require_res = __commonJS((exports, module) => { module.exports = { mapHttpResponse, resSerializer }; var rawSymbol = Symbol("pino-raw-res-ref"); var pinoResProto = Object.create({}, { statusCode: { enumerable: true, writable: true, value: 0 }, headers: { enumerable: true, writable: true, value: "" }, raw: { enumerable: false, get: function() { return this[rawSymbol]; }, set: function(val) { this[rawSymbol] = val; } } }); Object.defineProperty(pinoResProto, rawSymbol, { writable: true, value: {} }); function resSerializer(res) { const _res = Object.create(pinoResProto); _res.statusCode = res.headersSent ? res.statusCode : null; _res.headers = res.getHeaders ? res.getHeaders() : res._headers; _res.raw = res; return _res; } function mapHttpResponse(res) { return { res: resSerializer(res) }; } }); // node_modules/pino-std-serializers/index.js var require_pino_std_serializers = __commonJS((exports, module) => { var errSerializer = require_err(); var errWithCauseSerializer = require_err_with_cause(); var reqSerializers = require_req(); var resSerializers = require_res(); module.exports = { err: errSerializer, errWithCause: errWithCauseSerializer, mapHttpRequest: reqSerializers.mapHttpRequest, mapHttpResponse: resSerializers.mapHttpResponse, req: reqSerializers.reqSerializer, res: resSerializers.resSerializer, wrapErrorSerializer: function wrapErrorSerializer(customSerializer) { if (customSerializer === errSerializer) return customSerializer; return function wrapErrSerializer(err) { return customSerializer(errSerializer(err)); }; }, wrapRequestSerializer: function wrapRequestSerializer(customSerializer) { if (customSerializer === reqSerializers.reqSerializer) return customSerializer; return function wrappedReqSerializer(req) { return customSerializer(reqSerializers.reqSerializer(req)); }; }, wrapResponseSerializer: function wrapResponseSerializer(customSerializer) { if (customSerializer === resSerializers.resSerializer) return customSerializer; return function wrappedResSerializer(res) { return customSerializer(resSerializers.resSerializer(res)); }; } }; }); // node_modules/pino/lib/caller.js var require_caller = __commonJS((exports, module) => { function noOpPrepareStackTrace(_, stack) { return stack; } module.exports = function getCallers() { const originalPrepare = Error.prepareStackTrace; Error.prepareStackTrace = noOpPrepareStackTrace; const stack = new Error().stack; Error.prepareStackTrace = originalPrepare; if (!Array.isArray(stack)) { return; } const entries = stack.slice(2); const fileNames = []; for (const entry of entries) { if (!entry) { continue; } fileNames.push(entry.getFileName()); } return fileNames; }; }); // node_modules/fast-redact/lib/validator.js var require_validator = __commonJS((exports, module) => { module.exports = validator; function validator(opts = {}) { const { ERR_PATHS_MUST_BE_STRINGS = () => "fast-redact - Paths must be (non-empty) strings", ERR_INVALID_PATH = (s) => `fast-redact \u2013 Invalid path (${s})` } = opts; return function validate({ paths }) { paths.forEach((s) => { if (typeof s !== "string") { throw Error(ERR_PATHS_MUST_BE_STRINGS()); } try { if (/\u3007/.test(s)) throw Error(); const expr = (s[0] === "[" ? "" : ".") + s.replace(/^\*/, "\u3007").replace(/\.\*/g, ".\u3007").replace(/\[\*\]/g, "[\u3007]"); if (/\n|\r|;/.test(expr)) throw Error(); if (/\/\*/.test(expr)) throw Error(); Function(` 'use strict' const o = new Proxy({}, { get: () => o, set: () => { throw Error() } }); const \u3007 = null; o${expr} if ([o${expr}].length !== 1) throw Error()`)(); } catch (e) { throw Error(ERR_INVALID_PATH(s)); } }); }; } }); // node_modules/fast-redact/lib/rx.js var require_rx = __commonJS((exports, module) => { module.exports = /[^.[\]]+|\[((?:.)*?)\]/g; }); // node_modules/fast-redact/lib/parse.js var require_parse = __commonJS((exports, module) => { var rx = require_rx(); module.exports = parse; function parse({ paths }) { const wildcards = []; var wcLen = 0; const secret = paths.reduce(function(o, strPath, ix) { var path = strPath.match(rx).map((p) => p.replace(/'|"|`/g, "")); const leadingBracket = strPath[0] === "["; path = path.map((p) => { if (p[0] === "[") return p.substr(1, p.length - 2); else return p; }); const star = path.indexOf("*"); if (star > -1) { const before = path.slice(0, star); const beforeStr = before.join("."); const after = path.slice(star + 1, path.length); const nested = after.length > 0; wcLen++; wildcards.push({ before, beforeStr, after, nested }); } else { o[strPath] = { path, val: undefined, precensored: false, circle: "", escPath: JSON.stringify(strPath), leadingBracket }; } return o; }, {}); return { wildcards, wcLen, secret }; } }); // node_modules/fast-redact/lib/redactor.js var require_redactor = __commonJS((exports, module) => { var rx = require_rx(); module.exports = redactor; function redactor({ secret, serialize, wcLen, strict, isCensorFct, censorFctTakesPath }, state) { const redact = Function("o", ` if (typeof o !== 'object' || o == null) { ${strictImpl(strict, serialize)} } const { censor, secret } = this const originalSecret = {} const secretKeys = Object.keys(secret) for (var i = 0; i < secretKeys.length; i++) { originalSecret[secretKeys[i]] = secret[secretKeys[i]] } ${redactTmpl(secret, isCensorFct, censorFctTakesPath)} this.compileRestore() ${dynamicRedactTmpl(wcLen > 0, isCensorFct, censorFctTakesPath)} this.secret = originalSecret ${resultTmpl(serialize)} `).bind(state); redact.state = state; if (serialize === false) { redact.restore = (o) => state.restore(o); } return redact; } function redactTmpl(secret, isCensorFct, censorFctTakesPath) { return Object.keys(secret).map((path) => { const { escPath, leadingBracket, path: arrPath } = secret[path]; const skip = leadingBracket ? 1 : 0; const delim = leadingBracket ? "" : "."; const hops = []; var match; while ((match = rx.exec(path)) !== null) { const [, ix] = match; const { index, input } = match; if (index > skip) hops.push(input.substring(0, index - (ix ? 0 : 1))); } var existence = hops.map((p) => `o${delim}${p}`).join(" && "); if (existence.length === 0) existence += `o${delim}${path} != null`; else existence += ` && o${delim}${path} != null`; const circularDetection = ` switch (true) { ${hops.reverse().map((p) => ` case o${delim}${p} === censor: secret[${escPath}].circle = ${JSON.stringify(p)} break `).join(` `)} } `; const censorArgs = censorFctTakesPath ? `val, ${JSON.stringify(arrPath)}` : `val`; return ` if (${existence}) { const val = o${delim}${path} if (val === censor) { secret[${escPath}].precensored = true } else { secret[${escPath}].val = val o${delim}${path} = ${isCensorFct ? `censor(${censorArgs})` : "censor"} ${circularDetection} } } `; }).join(` `); } function dynamicRedactTmpl(hasWildcards, isCensorFct, censorFctTakesPath) { return hasWildcards === true ? ` { const { wildcards, wcLen, groupRedact, nestedRedact } = this for (var i = 0; i < wcLen; i++) { const { before, beforeStr, after, nested } = wildcards[i] if (nested === true) { secret[beforeStr] = secret[beforeStr] || [] nestedRedact(secret[beforeStr], o, before, after, censor, ${isCensorFct}, ${censorFctTakesPath}) } else secret[beforeStr] = groupRedact(o, before, censor, ${isCensorFct}, ${censorFctTakesPath}) } } ` : ""; } function resultTmpl(serialize) { return serialize === false ? `return o` : ` var s = this.serialize(o) this.restore(o) return s `; } function strictImpl(strict, serialize) { return strict === true ? `throw Error('fast-redact: primitives cannot be redacted')` : serialize === false ? `return o` : `return this.serialize(o)`; } }); // node_modules/fast-redact/lib/modifiers.js var require_modifiers = __commonJS((exports, module) => { module.exports = { groupRedact, groupRestore, nestedRedact, nestedRestore }; function groupRestore({ keys, values, target }) { if (target == null || typeof target === "string") return; const length = keys.length; for (var i = 0;i < length; i++) { const k = keys[i]; target[k] = values[i]; } } function groupRedact(o, path, censor, isCensorFct, censorFctTakesPath) { const target = get(o, path); if (target == null || typeof target === "string") return { keys: null, values: null, target, flat: true }; const keys = Object.keys(target); const keysLength = keys.length; const pathLength = path.length; const pathWithKey = censorFctTakesPath ? [...path] : undefined; const values = new Array(keysLength); for (var i = 0;i < keysLength; i++) { const key = keys[i]; values[i] = target[key]; if (censorFctTakesPath) { pathWithKey[pathLength] = key; target[key] = censor(target[key], pathWithKey); } else if (isCensorFct) { target[key] = censor(target[key]); } else { target[key] = censor; } } return { keys, values, target, flat: true }; } function nestedRestore(instructions) { for (let i = 0;i < instructions.length; i++) { const { target, path, value } = instructions[i]; let current = target; for (let i2 = path.length - 1;i2 > 0; i2--) { current = current[path[i2]]; } current[path[0]] = value; } } function nestedRedact(store, o, path, ns, censor, isCensorFct, censorFctTakesPath) { const target = get(o, path); if (target == null) return; const keys = Object.keys(target); const keysLength = keys.length; for (var i = 0;i < keysLength; i++) { const key = keys[i]; specialSet(store, target, key, path, ns, censor, isCensorFct, censorFctTakesPath); } return store; } function has(obj, prop) { return obj !== undefined && obj !== null ? "hasOwn" in Object ? Object.hasOwn(obj, prop) : Object.prototype.hasOwnProperty.call(obj, prop) : false; } function specialSet(store, o, k, path, afterPath, censor, isCensorFct, censorFctTakesPath) { const afterPathLen = afterPath.length; const lastPathIndex = afterPathLen - 1; const originalKey = k; var i = -1; var n; var nv; var ov; var oov = null; var wc = null; var kIsWc; var wcov; var consecutive = false; var level = 0; var depth = 0; var redactPathCurrent = tree(); ov = n = o[k]; if (typeof n !== "object") return; while (n != null && ++i < afterPathLen) { depth += 1; k = afterPath[i]; oov = ov; if (k !== "*" && !wc && !(typeof n === "object" && (k in n))) { break; } if (k === "*") { if (wc === "*") { consecutive = true; } wc = k; if (i !== lastPathIndex) { continue; } } if (wc) { const wcKeys = Object.keys(n); for (var j = 0;j < wcKeys.length; j++) { const wck = wcKeys[j]; wcov = n[wck]; kIsWc = k === "*"; if (consecutive) { redactPathCurrent = node(redactPathCurrent, wck, depth); level = i; ov = iterateNthLevel(wcov, level - 1, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, o[originalKey], depth + 1); } else { if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) { if (kIsWc) { ov = wcov; } else { ov = wcov[k]; } nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor; if (kIsWc) { const rv = restoreInstr(node(redactPathCurrent, wck, depth), ov, o[originalKey]); store.push(rv); n[wck] = nv; } else { if (wcov[k] === nv) { } else if (nv === undefined && censor !== undefined || has(wcov, k) && nv === ov) { redactPathCurrent = node(redactPathCurrent, wck, depth); } else { redactPathCurrent = node(redactPathCurrent, wck, depth); const rv = restoreInstr(node(redactPathCurrent, k, depth + 1), ov, o[originalKey]); store.push(rv); wcov[k] = nv; } } } } } wc = null; } else { ov = n[k]; redactPathCurrent = node(redactPathCurrent, k, depth); nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor; if (has(n, k) && nv === ov || nv === undefined && censor !== undefined) { } else { const rv = restoreInstr(redactPathCurrent, ov, o[originalKey]); store.push(rv); n[k] = nv; } n = n[k]; } if (typeof n !== "object") break; if (ov === oov || typeof ov === "undefined") { } } } function get(o, p) { var i = -1; var l = p.length; var n = o; while (n != null && ++i < l) { n = n[p[i]]; } return n; } function iterateNthLevel(wcov, level, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth) { if (level === 0) { if (kIsWc || typeof wcov === "object" && wcov !== null && k in wcov) { if (kIsWc) { ov = wcov; } else { ov = wcov[k]; } nv = i !== lastPathIndex ? ov : isCensorFct ? censorFctTakesPath ? censor(ov, [...path, originalKey, ...afterPath]) : censor(ov) : censor; if (kIsWc) { const rv = restoreInstr(redactPathCurrent, ov, parent); store.push(rv); n[wck] = nv; } else { if (wcov[k] === nv) { } else if (nv === undefined && censor !== undefined || has(wcov, k) && nv === ov) { } else { const rv = restoreInstr(node(redactPathCurrent, k, depth + 1), ov, parent); store.push(rv); wcov[k] = nv; } } } } for (const key in wcov) { if (typeof wcov[key] === "object") { redactPathCurrent = node(redactPathCurrent, key, depth); iterateNthLevel(wcov[key], level - 1, k, path, afterPath, censor, isCensorFct, censorFctTakesPath, originalKey, n, nv, ov, kIsWc, wck, i, lastPathIndex, redactPathCurrent, store, parent, depth + 1); } } } function tree() { return { parent: null, key: null, children: [], depth: 0 }; } function node(parent, key, depth) { if (parent.depth === depth) { return node(parent.parent, key, depth); } var child = { parent, key, depth, children: [] }; parent.children.push(child); return child; } function restoreInstr(node2, value, target) { let current = node2; const path = []; do { path.push(current.key); current = current.parent; } while (current.parent != null); return { path, value, target }; } }); // node_modules/fast-redact/lib/restorer.js var require_restorer = __commonJS((exports, module) => { var { groupRestore, nestedRestore } = require_modifiers(); module.exports = restorer; function restorer() { return function compileRestore() { if (this.restore) { this.restore.state.secret = this.secret; return; } const { secret, wcLen } = this; const paths = Object.keys(secret); const resetters = resetTmpl(secret, paths); const hasWildcards = wcLen > 0; const state = hasWildcards ? { secret, groupRestore, nestedRestore } : { secret }; this.restore = Function("o", restoreTmpl(resetters, paths, hasWildcards)).bind(state); this.restore.state = state; }; } function resetTmpl(secret, paths) { return paths.map((path) => { const { circle, escPath, leadingBracket } = secret[path]; const delim = leadingBracket ? "" : "."; const reset = circle ? `o.${circle} = secret[${escPath}].val` : `o${delim}${path} = secret[${escPath}].val`; const clear = `secret[${escPath}].val = undefined`; return ` if (secret[${escPath}].val !== undefined) { try { ${reset} } catch (e) {} ${clear} } `; }).join(""); } function restoreTmpl(resetters, paths, hasWildcards) { const dynamicReset = hasWildcards === true ? ` const keys = Object.keys(secret) const len = keys.length for (var i = len - 1; i >= ${paths.length}; i--) { const k = keys[i] const o = secret[k] if (o) { if (o.flat === true) this.groupRestore(o) else this.nestedRestore(o) secret[k] = null } } ` : ""; return ` const secret = this.secret ${dynamicReset} ${resetters} return o `; } }); // node_modules/fast-redact/lib/state.js var require_state = __commonJS((exports, module) => { module.exports = state; function state(o) { const { secret, censor, compileRestore, serialize, groupRedact, nestedRedact, wildcards, wcLen } = o; const builder = [{ secret, censor, compileRestore }]; if (serialize !== false) builder.push({ serialize }); if (wcLen > 0) builder.push({ groupRedact, nestedRedact, wildcards, wcLen }); return Object.assign(...builder); } }); // node_modules/fast-redact/index.js var require_fast_redact = __commonJS((exports, module) => { var validator = require_validator(); var parse = require_parse(); var redactor = require_redactor(); var restorer = require_restorer(); var { groupRedact, nestedRedact } = require_modifiers(); var state = require_state(); var rx = require_rx(); var validate = validator(); var noop = (o) => o; noop.restore = noop; var DEFAULT_CENSOR = "[REDACTED]"; fastRedact.rx = rx; fastRedact.validator = validator; module.exports = fastRedact; function fastRedact(opts = {}) { const paths = Array.from(new Set(opts.paths || [])); const serialize = "serialize" in opts ? opts.serialize === false ? opts.serialize : typeof opts.serialize === "function" ? opts.serialize : JSON.stringify : JSON.stringify; const remove = opts.remove; if (remove === true && serialize !== JSON.stringify) { throw Error("fast-redact \u2013 remove option may only be set when serializer is JSON.stringify"); } const censor = remove === true ? undefined : ("censor" in opts) ? opts.censor : DEFAULT_CENSOR; const isCensorFct = typeof censor === "function"; const censorFctTakesPath = isCensorFct && censor.length > 1; if (paths.length === 0) return serialize || noop; validate({ paths, serialize, censor }); const { wildcards, wcLen, secret } = parse({ paths, censor }); const compileRestore = restorer(); const strict = "strict" in opts ? opts.strict : true; return redactor({ secret, wcLen, serialize, strict, isCensorFct, censorFctTakesPath }, state({ secret, censor, compileRestore, se