UNPKG

@cloudbase/cloudbase-mcp

Version:

CloudBase MCP Server — operate Tencent CloudBase (database, auth, functions, storage, hosting) from AI coding tools via the Model Context Protocol. Part of CloudBase AI Toolkit.

2,229 lines (1,822 loc) 878 kB
exports.id = 508; exports.ids = [508]; exports.modules = { /***/ 920: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var $TypeError = __webpack_require__(69675); var inspect = __webpack_require__(58859); var getSideChannelList = __webpack_require__(14803); var getSideChannelMap = __webpack_require__(80507); var getSideChannelWeakMap = __webpack_require__(72271); var makeChannel = getSideChannelWeakMap || getSideChannelMap || getSideChannelList; /** @type {import('.')} */ module.exports = function getSideChannel() { /** @typedef {ReturnType<typeof getSideChannel>} Channel */ /** @type {Channel | undefined} */ var $channelData; /** @type {Channel} */ var channel = { assert: function (key) { if (!channel.has(key)) { var keyDesc = key && Object(key) === key ? 'the given object key' : inspect(key); throw new $TypeError('Side channel does not contain ' + keyDesc); } }, 'delete': function (key) { return !!$channelData && $channelData['delete'](key); }, get: function (key) { return $channelData && $channelData.get(key); }, has: function (key) { return !!$channelData && $channelData.has(key); }, set: function (key, value) { if (!$channelData) { $channelData = makeChannel(); } $channelData.set(key, value); } }; return channel; }; /***/ }), /***/ 3026: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; /*! * body-parser * Copyright(c) 2014-2015 Douglas Christopher Wilson * MIT Licensed */ /** * Module dependencies. */ const debug = __webpack_require__(45753)('body-parser:raw') const read = __webpack_require__(93524) const { normalizeOptions, passthrough } = __webpack_require__(61283) /** * Module exports. */ module.exports = raw /** * Create a middleware to parse raw bodies. * * @param {Object} [options] * @returns {Function} * @public */ function raw (options) { const normalizedOptions = normalizeOptions(options, 'application/octet-stream') const readOptions = { ...normalizedOptions, // Skip charset validation and parse the body as is skipCharset: true } return function rawParser (req, res, next) { read(req, res, next, passthrough, debug, readOptions) } } /***/ }), /***/ 3719: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^WebSocket$" }] */ const WebSocket = __webpack_require__(91060); const { Duplex } = __webpack_require__(27910); /** * Emits the `'close'` event on a stream. * * @param {Duplex} stream The stream. * @private */ function emitClose(stream) { stream.emit('close'); } /** * The listener of the `'end'` event. * * @private */ function duplexOnEnd() { if (!this.destroyed && this._writableState.finished) { this.destroy(); } } /** * The listener of the `'error'` event. * * @param {Error} err The error * @private */ function duplexOnError(err) { this.removeListener('error', duplexOnError); this.destroy(); if (this.listenerCount('error') === 0) { // Do not suppress the throwing behavior. this.emit('error', err); } } /** * Wraps a `WebSocket` in a duplex stream. * * @param {WebSocket} ws The `WebSocket` to wrap * @param {Object} [options] The options for the `Duplex` constructor * @return {Duplex} The duplex stream * @public */ function createWebSocketStream(ws, options) { let terminateOnDestroy = true; const duplex = new Duplex({ ...options, autoDestroy: false, emitClose: false, objectMode: false, writableObjectMode: false }); ws.on('message', function message(msg, isBinary) { const data = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg; if (!duplex.push(data)) ws.pause(); }); ws.once('error', function error(err) { if (duplex.destroyed) return; // Prevent `ws.terminate()` from being called by `duplex._destroy()`. // // - If the `'error'` event is emitted before the `'open'` event, then // `ws.terminate()` is a noop as no socket is assigned. // - Otherwise, the error is re-emitted by the listener of the `'error'` // event of the `Receiver` object. The listener already closes the // connection by calling `ws.close()`. This allows a close frame to be // sent to the other peer. If `ws.terminate()` is called right after this, // then the close frame might not be sent. terminateOnDestroy = false; duplex.destroy(err); }); ws.once('close', function close() { if (duplex.destroyed) return; duplex.push(null); }); duplex._destroy = function (err, callback) { if (ws.readyState === ws.CLOSED) { callback(err); process.nextTick(emitClose, duplex); return; } let called = false; ws.once('error', function error(err) { called = true; callback(err); }); ws.once('close', function close() { if (!called) callback(err); process.nextTick(emitClose, duplex); }); if (terminateOnDestroy) ws.terminate(); }; duplex._final = function (callback) { if (ws.readyState === ws.CONNECTING) { ws.once('open', function open() { duplex._final(callback); }); return; } // If the value of the `_socket` property is `null` it means that `ws` is a // client websocket and the handshake failed. In fact, when this happens, a // socket is never assigned to the websocket. Wait for the `'error'` event // that will be emitted by the websocket. if (ws._socket === null) return; if (ws._socket._writableState.finished) { callback(); if (duplex._readableState.endEmitted) duplex.destroy(); } else { ws._socket.once('finish', function finish() { // `duplex` is not destroyed here because the `'end'` event will be // emitted on `duplex` after this `'finish'` event. The EOF signaling // `null` chunk is, in fact, pushed when the websocket emits `'close'`. callback(); }); ws.close(); } }; duplex._read = function () { if (ws.isPaused) ws.resume(); }; duplex._write = function (chunk, encoding, callback) { if (ws.readyState === ws.CONNECTING) { ws.once('open', function open() { duplex._write(chunk, encoding, callback); }); return; } ws.send(chunk, callback); }; duplex.on('end', duplexOnEnd); duplex.on('error', duplexOnError); return duplex; } module.exports = createWebSocketStream; /***/ }), /***/ 4759: /***/ ((module) => { "use strict"; const kDone = Symbol('kDone'); const kRun = Symbol('kRun'); /** * A very simple job queue with adjustable concurrency. Adapted from * https://github.com/STRML/async-limiter */ class Limiter { /** * Creates a new `Limiter`. * * @param {Number} [concurrency=Infinity] The maximum number of jobs allowed * to run concurrently */ constructor(concurrency) { this[kDone] = () => { this.pending--; this[kRun](); }; this.concurrency = concurrency || Infinity; this.jobs = []; this.pending = 0; } /** * Adds a job to the queue. * * @param {Function} job The job to run * @public */ add(job) { this.jobs.push(job); this[kRun](); } /** * Removes a job from the queue and runs it if possible. * * @private */ [kRun]() { if (this.pending === this.concurrency) return; if (this.jobs.length) { const job = this.jobs.shift(); this.pending++; job(this[kDone]); } } } module.exports = Limiter; /***/ }), /***/ 7680: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; /*! * raw-body * Copyright(c) 2013-2014 Jonathan Ong * Copyright(c) 2014-2022 Douglas Christopher Wilson * MIT Licensed */ /** * Module dependencies. * @private */ var asyncHooks = tryRequireAsyncHooks() var bytes = __webpack_require__(25508) var createError = __webpack_require__(76336) var iconv = __webpack_require__(95249) var unpipe = __webpack_require__(71170) /** * Module exports. * @public */ module.exports = getRawBody /** * Module variables. * @private */ var ICONV_ENCODING_MESSAGE_REGEXP = /^Encoding not recognized: / /** * Get the decoder for a given encoding. * * @param {string} encoding * @private */ function getDecoder (encoding) { if (!encoding) return null try { return iconv.getDecoder(encoding) } catch (e) { // error getting decoder if (!ICONV_ENCODING_MESSAGE_REGEXP.test(e.message)) throw e // the encoding was not found throw createError(415, 'specified encoding unsupported', { encoding: encoding, type: 'encoding.unsupported' }) } } /** * Get the raw body of a stream (typically HTTP). * * @param {object} stream * @param {object|string|function} [options] * @param {function} [callback] * @public */ function getRawBody (stream, options, callback) { var done = callback var opts = options || {} // light validation if (stream === undefined) { throw new TypeError('argument stream is required') } else if (typeof stream !== 'object' || stream === null || typeof stream.on !== 'function') { throw new TypeError('argument stream must be a stream') } if (options === true || typeof options === 'string') { // short cut for encoding opts = { encoding: options } } if (typeof options === 'function') { done = options opts = {} } // validate callback is a function, if provided if (done !== undefined && typeof done !== 'function') { throw new TypeError('argument callback must be a function') } // require the callback without promises if (!done && !global.Promise) { throw new TypeError('argument callback is required') } // get encoding var encoding = opts.encoding !== true ? opts.encoding : 'utf-8' // convert the limit to an integer var limit = bytes.parse(opts.limit) // convert the expected length to an integer var length = opts.length != null && !isNaN(opts.length) ? parseInt(opts.length, 10) : null if (done) { // classic callback style return readStream(stream, encoding, length, limit, wrap(done)) } return new Promise(function executor (resolve, reject) { readStream(stream, encoding, length, limit, function onRead (err, buf) { if (err) return reject(err) resolve(buf) }) }) } /** * Halt a stream. * * @param {Object} stream * @private */ function halt (stream) { // unpipe everything from the stream unpipe(stream) // pause stream if (typeof stream.pause === 'function') { stream.pause() } } /** * Read the data from the stream. * * @param {object} stream * @param {string} encoding * @param {number} length * @param {number} limit * @param {function} callback * @public */ function readStream (stream, encoding, length, limit, callback) { var complete = false var sync = true // check the length and limit options. // note: we intentionally leave the stream paused, // so users should handle the stream themselves. if (limit !== null && length !== null && length > limit) { return done(createError(413, 'request entity too large', { expected: length, length: length, limit: limit, type: 'entity.too.large' })) } // streams1: assert request encoding is buffer. // streams2+: assert the stream encoding is buffer. // stream._decoder: streams1 // state.encoding: streams2 // state.decoder: streams2, specifically < 0.10.6 var state = stream._readableState if (stream._decoder || (state && (state.encoding || state.decoder))) { // developer error return done(createError(500, 'stream encoding should not be set', { type: 'stream.encoding.set' })) } if (typeof stream.readable !== 'undefined' && !stream.readable) { return done(createError(500, 'stream is not readable', { type: 'stream.not.readable' })) } var received = 0 var decoder try { decoder = getDecoder(encoding) } catch (err) { return done(err) } var buffer = decoder ? '' : [] // attach listeners stream.on('aborted', onAborted) stream.on('close', cleanup) stream.on('data', onData) stream.on('end', onEnd) stream.on('error', onEnd) // mark sync section complete sync = false function done () { var args = new Array(arguments.length) // copy arguments for (var i = 0; i < args.length; i++) { args[i] = arguments[i] } // mark complete complete = true if (sync) { process.nextTick(invokeCallback) } else { invokeCallback() } function invokeCallback () { cleanup() if (args[0]) { // halt the stream on error halt(stream) } callback.apply(null, args) } } function onAborted () { if (complete) return done(createError(400, 'request aborted', { code: 'ECONNABORTED', expected: length, length: length, received: received, type: 'request.aborted' })) } function onData (chunk) { if (complete) return received += chunk.length if (limit !== null && received > limit) { done(createError(413, 'request entity too large', { limit: limit, received: received, type: 'entity.too.large' })) } else if (decoder) { buffer += decoder.write(chunk) } else { buffer.push(chunk) } } function onEnd (err) { if (complete) return if (err) return done(err) if (length !== null && received !== length) { done(createError(400, 'request size did not match content length', { expected: length, length: length, received: received, type: 'request.size.invalid' })) } else { var string = decoder ? buffer + (decoder.end() || '') : Buffer.concat(buffer) done(null, string) } } function cleanup () { buffer = null stream.removeListener('aborted', onAborted) stream.removeListener('data', onData) stream.removeListener('end', onEnd) stream.removeListener('error', onEnd) stream.removeListener('close', cleanup) } } /** * Try to require async_hooks * @private */ function tryRequireAsyncHooks () { try { return __webpack_require__(84297) } catch (e) { return {} } } /** * Wrap function with async resource, if possible. * AsyncResource.bind static method backported. * @private */ function wrap (fn) { var res // create anonymous resource if (asyncHooks.AsyncResource) { res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn') } // incompatible node.js if (!res || !res.runInAsyncScope) { return fn } // return bound function return res.runInAsyncScope.bind(res, fn, null) } /***/ }), /***/ 9874: /***/ ((__unused_webpack_module, exports) => { "use strict"; /*! * content-type * Copyright(c) 2015 Douglas Christopher Wilson * MIT Licensed */ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.format = format; exports.parse = parse; const TEXT_REGEXP = /^[\u0009\u0020-\u007e\u0080-\u00ff]*$/; const TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; /** * RegExp to match chars that must be quoted-pair in RFC 9110 sec 5.6.4 */ const QUOTE_REGEXP = /[\\"]/g; /** * RegExp to match type in RFC 9110 sec 8.3.1 * * media-type = type "/" subtype * type = token * subtype = token */ const TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; /** * Null object perf optimization. Faster than `Object.create(null)` and `{ __proto__: null }`. */ const NullObject = /* @__PURE__ */ (() => { const C = function () { }; C.prototype = Object.create(null); return C; })(); /** * Format an object into a `Content-Type` header. */ function format(obj) { const { type, parameters } = obj; if (!type || !TYPE_REGEXP.test(type)) { throw new TypeError(`Invalid type: ${type}`); } let result = type; if (parameters) { for (const param of Object.keys(parameters)) { if (!TOKEN_REGEXP.test(param)) { throw new TypeError(`Invalid parameter name: ${param}`); } result += `; ${param}=${qstring(parameters[param])}`; } } return result; } /** * Parse a `Content-Type` header. */ function parse(header, options) { const len = header.length; let index = skipOWS(header, 0, len); const valueStart = index; index = skipValue(header, index, len); const valueEnd = trailingOWS(header, valueStart, index); const type = header.slice(valueStart, valueEnd).toLowerCase(); const parameters = options?.parameters === false ? new NullObject() : parseParameters(header, index, len); return { type, parameters }; } const SP = 32; // " " const HTAB = 9; // "\t" const SEMI = 59; // ";" const EQ = 61; // "=" const DQUOTE = 34; // '"' const BSLASH = 92; // "\\" /** * Parses the parameters of a `Content-Type` header starting at the given index. */ function parseParameters(header, index, len) { const parameters = new NullObject(); parameter: while (index < len) { index = skipOWS(header, index + 1 /* Skip over ; */, len); const keyStart = index; while (index < len) { const code = header.charCodeAt(index); if (code === SEMI) continue parameter; if (code === EQ) { const keyEnd = trailingOWS(header, keyStart, index); const key = header.slice(keyStart, keyEnd).toLowerCase(); index = skipOWS(header, index + 1, len); if (index < len && header.charCodeAt(index) === DQUOTE) { index++; let value = ""; while (index < len) { const code = header.charCodeAt(index++); if (code === DQUOTE) { index = skipValue(header, index, len); if (parameters[key] === undefined) parameters[key] = value; break; } if (code === BSLASH && index < len) { value += header[index++]; continue; } value += String.fromCharCode(code); } continue parameter; } const valueStart = index; index = skipValue(header, index, len); if (parameters[key] === undefined) { const valueEnd = trailingOWS(header, valueStart, index); parameters[key] = header.slice(valueStart, valueEnd); } continue parameter; } index++; } } return parameters; } /** * Skip over characters until a semicolon. */ function skipValue(str, index, len) { while (index < len) { const char = str.charCodeAt(index); if (char === SEMI) break; index++; } return index; } /** * Skip optional whitespace (OWS) in an HTTP header value. * * OWS is defined in RFC 9110 sec 5.6.3 as SP (" ") or HTAB ("\t"). */ function skipOWS(header, index, len) { while (index < len) { const char = header.charCodeAt(index); if (char !== SP && char !== HTAB) break; index++; } return index; } /** * Trim optional whitespace (OWS) from the end of a substring. * * OWS is defined in RFC 9110 sec 5.6.3 as SP (" ") or HTAB ("\t"). */ function trailingOWS(header, start, end) { while (end > start) { const char = header.charCodeAt(end - 1); if (char !== SP && char !== HTAB) break; end--; } return end; } /** * Serialize a parameter value. */ function qstring(str) { if (TOKEN_REGEXP.test(str)) return str; if (TEXT_REGEXP.test(str)) return `"${str.replace(QUOTE_REGEXP, "\\$&")}"`; throw new TypeError(`Invalid parameter value: ${str}`); } //# sourceMappingURL=index.js.map /***/ }), /***/ 12577: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; /*! * serve-static * Copyright(c) 2010 Sencha Inc. * Copyright(c) 2011 TJ Holowaychuk * Copyright(c) 2014-2016 Douglas Christopher Wilson * MIT Licensed */ /** * Module dependencies. * @private */ var encodeUrl = __webpack_require__(52224) var escapeHtml = __webpack_require__(70580) var parseUrl = __webpack_require__(93189) var resolve = (__webpack_require__(33873).resolve) var send = __webpack_require__(57667) var url = __webpack_require__(79551) /** * Module exports. * @public */ module.exports = serveStatic /** * @param {string} root * @param {object} [options] * @return {function} * @public */ function serveStatic (root, options) { if (!root) { throw new TypeError('root path required') } if (typeof root !== 'string') { throw new TypeError('root path must be a string') } // copy options object var opts = Object.create(options || null) // fall-though var fallthrough = opts.fallthrough !== false // default redirect var redirect = opts.redirect !== false // headers listener var setHeaders = opts.setHeaders if (setHeaders && typeof setHeaders !== 'function') { throw new TypeError('option setHeaders must be function') } // setup options for send opts.maxage = opts.maxage || opts.maxAge || 0 opts.root = resolve(root) // construct directory listener var onDirectory = redirect ? createRedirectDirectoryListener() : createNotFoundDirectoryListener() return function serveStatic (req, res, next) { if (req.method !== 'GET' && req.method !== 'HEAD') { if (fallthrough) { return next() } // method not allowed res.statusCode = 405 res.setHeader('Allow', 'GET, HEAD') res.setHeader('Content-Length', '0') res.end() return } var forwardError = !fallthrough var originalUrl = parseUrl.original(req) var path = parseUrl(req).pathname // make sure redirect occurs at mount if (path === '/' && originalUrl.pathname.substr(-1) !== '/') { path = '' } // create send stream var stream = send(req, path, opts) // add directory handler stream.on('directory', onDirectory) // add headers listener if (setHeaders) { stream.on('headers', setHeaders) } // add file listener for fallthrough if (fallthrough) { stream.on('file', function onFile () { // once file is determined, always forward error forwardError = true }) } // forward errors stream.on('error', function error (err) { if (forwardError || !(err.statusCode < 500)) { next(err) return } next() }) // pipe stream.pipe(res) } } /** * Collapse all leading slashes into a single slash * @private */ function collapseLeadingSlashes (str) { for (var i = 0; i < str.length; i++) { if (str.charCodeAt(i) !== 0x2f /* / */) { break } } return i > 1 ? '/' + str.substr(i) : str } /** * Create a minimal HTML document. * * @param {string} title * @param {string} body * @private */ function createHtmlDocument (title, body) { return '<!DOCTYPE html>\n' + '<html lang="en">\n' + '<head>\n' + '<meta charset="utf-8">\n' + '<title>' + title + '</title>\n' + '</head>\n' + '<body>\n' + '<pre>' + body + '</pre>\n' + '</body>\n' + '</html>\n' } /** * Create a directory listener that just 404s. * @private */ function createNotFoundDirectoryListener () { return function notFound () { this.error(404) } } /** * Create a directory listener that performs a redirect. * @private */ function createRedirectDirectoryListener () { return function redirect (res) { if (this.hasTrailingSlash()) { this.error(404) return } // get original URL var originalUrl = parseUrl.original(this.req) // append trailing slash originalUrl.path = null originalUrl.pathname = collapseLeadingSlashes(originalUrl.pathname + '/') // reformat the URL var loc = encodeUrl(url.format(originalUrl)) var doc = createHtmlDocument('Redirecting', 'Redirecting to ' + escapeHtml(loc)) // send redirect response res.statusCode = 301 res.setHeader('Content-Type', 'text/html; charset=UTF-8') res.setHeader('Content-Length', Buffer.byteLength(doc)) res.setHeader('Content-Security-Policy', "default-src 'none'") res.setHeader('X-Content-Type-Options', 'nosniff') res.setHeader('Location', loc) res.end(doc) } } /***/ }), /***/ 12800: /***/ ((module) => { "use strict"; function mergeDescriptors(destination, source, overwrite = true) { if (!destination) { throw new TypeError('The `destination` argument is required.'); } if (!source) { throw new TypeError('The `source` argument is required.'); } for (const name of Object.getOwnPropertyNames(source)) { if (!overwrite && Object.hasOwn(destination, name)) { // Skip descriptor continue; } // Copy descriptor const descriptor = Object.getOwnPropertyDescriptor(source, name); Object.defineProperty(destination, name, descriptor); } return destination; } module.exports = mergeDescriptors; /***/ }), /***/ 12878: /***/ ((module) => { "use strict"; /*! * range-parser * Copyright(c) 2012-2014 TJ Holowaychuk * Copyright(c) 2015-2016 Douglas Christopher Wilson * MIT Licensed */ /** * Module exports. * @public */ module.exports = rangeParser /** * Parse "Range" header `str` relative to the given file `size`. * * @param {Number} size * @param {String} str * @param {Object} [options] * @return {Array} * @public */ function rangeParser (size, str, options) { if (typeof str !== 'string') { throw new TypeError('argument str must be a string') } var index = str.indexOf('=') if (index === -1) { return -2 } // split the range string var arr = str.slice(index + 1).split(',') var ranges = [] // add ranges type ranges.type = str.slice(0, index) // parse all ranges for (var i = 0; i < arr.length; i++) { var range = arr[i].split('-') var start = parseInt(range[0], 10) var end = parseInt(range[1], 10) // -nnn if (isNaN(start)) { start = size - end end = size - 1 // nnn- } else if (isNaN(end)) { end = size - 1 } // limit last-byte-pos to current length if (end > size - 1) { end = size - 1 } // invalid or unsatisifiable if (isNaN(start) || isNaN(end) || start > end || start < 0) { continue } // add range ranges.push({ start: start, end: end }) } if (ranges.length < 1) { // unsatisifiable return -1 } return options && options.combine ? combineRanges(ranges) : ranges } /** * Combine overlapping & adjacent ranges. * @private */ function combineRanges (ranges) { var ordered = ranges.map(mapWithIndex).sort(sortByRangeStart) for (var j = 0, i = 1; i < ordered.length; i++) { var range = ordered[i] var current = ordered[j] if (range.start > current.end + 1) { // next range ordered[++j] = range } else if (range.end > current.end) { // extend range current.end = range.end current.index = Math.min(current.index, range.index) } } // trim ordered array ordered.length = j + 1 // generate combined range var combined = ordered.sort(sortByRangeIndex).map(mapWithoutIndex) // copy ranges type combined.type = ranges.type return combined } /** * Map function to add index value to ranges. * @private */ function mapWithIndex (range, index) { return { start: range.start, end: range.end, index: index } } /** * Map function to remove index value from ranges. * @private */ function mapWithoutIndex (range) { return { start: range.start, end: range.end } } /** * Sort function to sort ranges by index. * @private */ function sortByRangeIndex (a, b) { return a.index - b.index } /** * Sort function to sort ranges by start position. * @private */ function sortByRangeStart (a, b) { return a.start - b.start } /***/ }), /***/ 14276: /***/ ((module) => { "use strict"; /*! * ee-first * Copyright(c) 2014 Jonathan Ong * MIT Licensed */ /** * Module exports. * @public */ module.exports = first /** * Get the first event in a set of event emitters and event pairs. * * @param {array} stuff * @param {function} done * @public */ function first(stuff, done) { if (!Array.isArray(stuff)) throw new TypeError('arg must be an array of [ee, events...] arrays') var cleanups = [] for (var i = 0; i < stuff.length; i++) { var arr = stuff[i] if (!Array.isArray(arr) || arr.length < 2) throw new TypeError('each array member must be [ee, events...]') var ee = arr[0] for (var j = 1; j < arr.length; j++) { var event = arr[j] var fn = listener(event, callback) // listen to the event ee.on(event, fn) // push this listener to the list of cleanups cleanups.push({ ee: ee, event: event, fn: fn, }) } } function callback() { cleanup() done.apply(null, arguments) } function cleanup() { var x for (var i = 0; i < cleanups.length; i++) { x = cleanups[i] x.ee.removeListener(x.event, x.fn) } } function thunk(fn) { done = fn } thunk.cancel = cleanup return thunk } /** * Create the event listener. * @private */ function listener(event, done) { return function onevent(arg1) { var args = new Array(arguments.length) var ee = this var err = event === 'error' ? arg1 : null // copy args to prevent arguments escaping scope for (var i = 0; i < args.length; i++) { args[i] = arguments[i] } done(err, ee, event, args) } } /***/ }), /***/ 14803: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var inspect = __webpack_require__(58859); var $TypeError = __webpack_require__(69675); /* * This function traverses the list returning the node corresponding to the given key. * * That node is also moved to the head of the list, so that if it's accessed again we don't need to traverse the whole list. * By doing so, all the recently used nodes can be accessed relatively quickly. */ /** @type {import('./list.d.ts').listGetNode} */ // eslint-disable-next-line consistent-return var listGetNode = function (list, key, isDelete) { /** @type {typeof list | NonNullable<(typeof list)['next']>} */ var prev = list; /** @type {(typeof list)['next']} */ var curr; // eslint-disable-next-line eqeqeq for (; (curr = prev.next) != null; prev = curr) { if (curr.key === key) { prev.next = curr.next; if (!isDelete) { // eslint-disable-next-line no-extra-parens curr.next = /** @type {NonNullable<typeof list.next>} */ (list.next); list.next = curr; // eslint-disable-line no-param-reassign } return curr; } } }; /** @type {import('./list.d.ts').listGet} */ var listGet = function (objects, key) { if (!objects) { return void undefined; } var node = listGetNode(objects, key); return node && node.value; }; /** @type {import('./list.d.ts').listSet} */ var listSet = function (objects, key, value) { var node = listGetNode(objects, key); if (node) { node.value = value; } else { // Prepend the new node to the beginning of the list objects.next = /** @type {import('./list.d.ts').ListNode<typeof value, typeof key>} */ ({ // eslint-disable-line no-param-reassign, no-extra-parens key: key, next: objects.next, value: value }); } }; /** @type {import('./list.d.ts').listHas} */ var listHas = function (objects, key) { if (!objects) { return false; } return !!listGetNode(objects, key); }; /** @type {import('./list.d.ts').listDelete} */ // eslint-disable-next-line consistent-return var listDelete = function (objects, key) { if (objects) { return listGetNode(objects, key, true); } }; /** @type {import('.')} */ module.exports = function getSideChannelList() { /** @typedef {ReturnType<typeof getSideChannelList>} Channel */ /** @typedef {Parameters<Channel['get']>[0]} K */ /** @typedef {Parameters<Channel['set']>[1]} V */ /** @type {import('./list.d.ts').RootNode<V, K> | undefined} */ var $o; /** @type {Channel} */ var channel = { assert: function (key) { if (!channel.has(key)) { throw new $TypeError('Side channel does not contain ' + inspect(key)); } }, 'delete': function (key) { var deletedNode = listDelete($o, key); if (deletedNode && $o && !$o.next) { $o = void undefined; } return !!deletedNode; }, get: function (key) { return listGet($o, key); }, has: function (key) { return listHas($o, key); }, set: function (key, value) { if (!$o) { // Initialize the linked list as an empty node, so that we don't have to special-case handling of the first node: we can always refer to it as (previous node).next, instead of something like (list).head $o = { next: void undefined }; } // eslint-disable-next-line no-extra-parens listSet(/** @type {NonNullable<typeof $o>} */ ($o), key, value); } }; return channel; }; /***/ }), /***/ 15082: /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; var Buffer = (__webpack_require__(54774).Buffer) // Note: UTF16-LE (or UCS2) codec is Node.js native. See encodings/internal.js // == UTF16-BE codec. ========================================================== exports.utf16be = Utf16BECodec function Utf16BECodec () { } Utf16BECodec.prototype.encoder = Utf16BEEncoder Utf16BECodec.prototype.decoder = Utf16BEDecoder Utf16BECodec.prototype.bomAware = true // -- Encoding function Utf16BEEncoder () { } Utf16BEEncoder.prototype.write = function (str) { var buf = Buffer.from(str, "ucs2") for (var i = 0; i < buf.length; i += 2) { var tmp = buf[i]; buf[i] = buf[i + 1]; buf[i + 1] = tmp } return buf } Utf16BEEncoder.prototype.end = function () { } // -- Decoding function Utf16BEDecoder () { this.overflowByte = -1 } Utf16BEDecoder.prototype.write = function (buf) { if (buf.length == 0) { return "" } var buf2 = Buffer.alloc(buf.length + 1) var i = 0; var j = 0 if (this.overflowByte !== -1) { buf2[0] = buf[0] buf2[1] = this.overflowByte i = 1; j = 2 } for (; i < buf.length - 1; i += 2, j += 2) { buf2[j] = buf[i + 1] buf2[j + 1] = buf[i] } this.overflowByte = (i == buf.length - 1) ? buf[buf.length - 1] : -1 return buf2.slice(0, j).toString("ucs2") } Utf16BEDecoder.prototype.end = function () { this.overflowByte = -1 } // == UTF-16 codec ============================================================= // Decoder chooses automatically from UTF-16LE and UTF-16BE using BOM and space-based heuristic. // Defaults to UTF-16LE, as it's prevalent and default in Node. // http://en.wikipedia.org/wiki/UTF-16 and http://encoding.spec.whatwg.org/#utf-16le // Decoder default can be changed: iconv.decode(buf, 'utf16', {defaultEncoding: 'utf-16be'}); // Encoder uses UTF-16LE and prepends BOM (which can be overridden with addBOM: false). exports.utf16 = Utf16Codec function Utf16Codec (codecOptions, iconv) { this.iconv = iconv } Utf16Codec.prototype.encoder = Utf16Encoder Utf16Codec.prototype.decoder = Utf16Decoder // -- Encoding (pass-through) function Utf16Encoder (options, codec) { options = options || {} if (options.addBOM === undefined) { options.addBOM = true } this.encoder = codec.iconv.getEncoder("utf-16le", options) } Utf16Encoder.prototype.write = function (str) { return this.encoder.write(str) } Utf16Encoder.prototype.end = function () { return this.encoder.end() } // -- Decoding function Utf16Decoder (options, codec) { this.decoder = null this.initialBufs = [] this.initialBufsLen = 0 this.options = options || {} this.iconv = codec.iconv } Utf16Decoder.prototype.write = function (buf) { if (!this.decoder) { // Codec is not chosen yet. Accumulate initial bytes. this.initialBufs.push(buf) this.initialBufsLen += buf.length if (this.initialBufsLen < 16) // We need more bytes to use space heuristic (see below) { return "" } // We have enough bytes -> detect endianness. var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding) this.decoder = this.iconv.getDecoder(encoding, this.options) var resStr = "" for (var i = 0; i < this.initialBufs.length; i++) { resStr += this.decoder.write(this.initialBufs[i]) } this.initialBufs.length = this.initialBufsLen = 0 return resStr } return this.decoder.write(buf) } Utf16Decoder.prototype.end = function () { if (!this.decoder) { var encoding = detectEncoding(this.initialBufs, this.options.defaultEncoding) this.decoder = this.iconv.getDecoder(encoding, this.options) var resStr = "" for (var i = 0; i < this.initialBufs.length; i++) { resStr += this.decoder.write(this.initialBufs[i]) } var trail = this.decoder.end() if (trail) { resStr += trail } this.initialBufs.length = this.initialBufsLen = 0 return resStr } return this.decoder.end() } function detectEncoding (bufs, defaultEncoding) { var b = [] var charsProcessed = 0 // Number of ASCII chars when decoded as LE or BE. var asciiCharsLE = 0 var asciiCharsBE = 0 outerLoop: for (var i = 0; i < bufs.length; i++) { var buf = bufs[i] for (var j = 0; j < buf.length; j++) { b.push(buf[j]) if (b.length === 2) { if (charsProcessed === 0) { // Check BOM first. if (b[0] === 0xFF && b[1] === 0xFE) return "utf-16le" if (b[0] === 0xFE && b[1] === 0xFF) return "utf-16be" } if (b[0] === 0 && b[1] !== 0) asciiCharsBE++ if (b[0] !== 0 && b[1] === 0) asciiCharsLE++ b.length = 0 charsProcessed++ if (charsProcessed >= 100) { break outerLoop } } } } // Make decisions. // Most of the time, the content has ASCII chars (U+00**), but the opposite (U+**00) is uncommon. // So, we count ASCII as if it was LE or BE, and decide from that. if (asciiCharsBE > asciiCharsLE) return "utf-16be" if (asciiCharsBE < asciiCharsLE) return "utf-16le" // Couldn't decide (likely all zeros or not enough data). return defaultEncoding || "utf-16le" } /***/ }), /***/ 15649: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; /*! * on-finished * Copyright(c) 2013 Jonathan Ong * Copyright(c) 2014 Douglas Christopher Wilson * MIT Licensed */ /** * Module exports. * @public */ module.exports = onFinished module.exports.isFinished = isFinished /** * Module dependencies. * @private */ var asyncHooks = tryRequireAsyncHooks() var first = __webpack_require__(14276) /** * Variables. * @private */ /* istanbul ignore next */ var defer = typeof setImmediate === 'function' ? setImmediate : function (fn) { process.nextTick(fn.bind.apply(fn, arguments)) } /** * Invoke callback when the response has finished, useful for * cleaning up resources afterwards. * * @param {object} msg * @param {function} listener * @return {object} * @public */ function onFinished (msg, listener) { if (isFinished(msg) !== false) { defer(listener, null, msg) return msg } // attach the listener to the message attachListener(msg, wrap(listener)) return msg } /** * Determine if message is already finished. * * @param {object} msg * @return {boolean} * @public */ function isFinished (msg) { var socket = msg.socket if (typeof msg.finished === 'boolean') { // OutgoingMessage return Boolean(msg.finished || (socket && !socket.writable)) } if (typeof msg.complete === 'boolean') { // IncomingMessage return Boolean(msg.upgrade || !socket || !socket.readable || (msg.complete && !msg.readable)) } // don't know return undefined } /** * Attach a finished listener to the message. * * @param {object} msg * @param {function} callback * @private */ function attachFinishedListener (msg, callback) { var eeMsg var eeSocket var finished = false function onFinish (error) { eeMsg.cancel() eeSocket.cancel() finished = true callback(error) } // finished on first message event eeMsg = eeSocket = first([[msg, 'end', 'finish']], onFinish) function onSocket (socket) { // remove listener msg.removeListener('socket', onSocket) if (finished) return if (eeMsg !== eeSocket) return // finished on first socket event eeSocket = first([[socket, 'error', 'close']], onFinish) } if (msg.socket) { // socket already assigned onSocket(msg.socket) return } // wait for socket to be assigned msg.on('socket', onSocket) if (msg.socket === undefined) { // istanbul ignore next: node.js 0.8 patch patchAssignSocket(msg, onSocket) } } /** * Attach the listener to the message. * * @param {object} msg * @return {function} * @private */ function attachListener (msg, listener) { var attached = msg.__onFinished // create a private single listener with queue if (!attached || !attached.queue) { attached = msg.__onFinished = createListener(msg) attachFinishedListener(msg, attached) } attached.queue.push(listener) } /** * Create listener on message. * * @param {object} msg * @return {function} * @private */ function createListener (msg) { function listener (err) { if (msg.__onFinished === listener) msg.__onFinished = null if (!listener.queue) return var queue = listener.queue listener.queue = null for (var i = 0; i < queue.length; i++) { queue[i](err, msg) } } listener.queue = [] return listener } /** * Patch ServerResponse.prototype.assignSocket for node.js 0.8. * * @param {ServerResponse} res * @param {function} callback * @private */ // istanbul ignore next: node.js 0.8 patch function patchAssignSocket (res, callback) { var assignSocket = res.assignSocket if (typeof assignSocket !== 'function') return // res.on('socket', callback) is broken in 0.8 res.assignSocket = function _assignSocket (socket) { assignSocket.call(this, socket) callback(socket) } } /** * Try to require async_hooks * @private */ function tryRequireAsyncHooks () { try { return __webpack_require__(84297) } catch (e) { return {} } } /** * Wrap function with async resource, if possible. * AsyncResource.bind static method backported. * @private */ function wrap (fn) { var res // create anonymous resource if (asyncHooks.AsyncResource) { res = new asyncHooks.AsyncResource(fn.name || 'bound-anonymous-fn') } // incompatible node.js if (!res || !res.runInAsyncScope) { return fn } // return bound function return res.runInAsyncScope.bind(res, fn, null) } /***/ }), /***/ 16963: /***/ ((module) => { "use strict"; /*! * toidentifier * Copyright(c) 2016 Douglas Christopher Wilson * MIT Licensed */ /** * Module exports. * @public */ module.exports = toIdentifier /** * Trasform the given string into a JavaScript identifier * * @param {string} str * @returns {string} * @public */ function toIdentifier (str) { return str .split(' ') .map(function (token) { return token.slice(0, 1).toUpperCase() + token.slice(1) }) .join('') .replace(/[^ _0-9a-z]/gi, '') } /***/ }), /***/ 17058: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; /*! * express * Copyright(c) 2009-2013 TJ Holowaychuk * Copyright(c) 2013 Roman Shtylman * Copyright(c) 2014-2015 Douglas Christopher Wilson * MIT Licensed */ /** * Module dependencies. * @private */ var accepts = __webpack_require__(22594); var isIP = (__webpack_require__(29427).isIP); var typeis = __webpack_require__(81592); var http = __webpack_require__(50588); var fresh = __webpack_require__(71427); var parseRange = __webpack_require__(12878); var parse = __webpack_require__(93189); var proxyaddr = __webpack_require__(21729); /** * Request prototype. * @public */ var req = Object.create(http.IncomingMessage.prototype) /** * Module exports. * @public */ module.exports = req /** * Return request header. * * The `Referrer` header field is special-cased, * both `Referrer` and `Referer` are interchangeable. * * Examples: * * req.get('Content-Type'); * // => "text/plain" * * req.get('content-type'); * // => "text/plain" * * req.get('Something'); * // => undefined * * Aliased as `req.header()`. * * @param {String} name * @return {String} * @public */ req.get = req.header = function header(name) { if (!name) { throw new TypeError('name argument is required to req.get'); } if (typeof name !== 'string') { throw new TypeError('name must be a string to req.get'); } var lc = name.toLowerCase(); switch (lc) { case 'referer': case 'referrer': return this.headers.referrer || this.headers.referer; default: return this.headers[lc]; } }; /** * To do: update docs. * * Check if the given `type(s)` is acceptable, returning * the best match when true, otherwise `undefined`, in which * case you should respond with 406 "Not Acceptable". * * The `type` value may be a single MIME type string * such as "application/json", an extension name * such as "json", a comma-delimited list such as "json, html, text/plain", * an argument list such as `"json", "html", "text/plain"`, * or an array `["json", "html", "text/plain"]`. When a list * or array is given, the _best_ match, if any is returned. * * Examples: * * // Accept: text/html * req.accepts('html'); * // => "html" * * // Accept: text/*, application/json * req.accepts('html'); * // => "html" * req.accepts('text/html'); * // => "text/html" * req.accepts('json, text'); * // => "json" * req.accepts('application/json'); * // => "application/json" * * // Accept: text/*, application/json * req.accepts('image/png'); * req.accepts('png'); * // => undefined * * // Accept: text/*;q=.5, application/json * req.accepts(['html', 'json']); * req.accepts('html', 'json'); * req.accepts('html, json'); * // => "json" * * @param {String|Array} type(s) * @return {String|Array|Boolean} * @public */ req.accepts = function(){ var accept = accepts(this); return accept.types.apply(accept, arguments); }; /** * Check if the given `encoding`s are accepted. * * @param {String} ...encoding * @return {String|Array} * @public */ req.acceptsEncodings = function(){ var accept = accepts(this); return accept.encodings.apply(accept, arguments); }; /** * Check if the given `charset`s are acceptable, * otherwise you should respond with 406 "Not Acceptable". * * @param {String} ...charset * @return {String|Array} * @public */ req.acceptsCharsets = function(){ var accept = accepts(this); return accept.charsets.apply(accept, arguments); }; /** * Check if the given `lang`s are acceptable, * otherwise you should respond with 406 "Not Acceptable". * * @param {String} ...lang * @return {String|Array} * @public */ req.acceptsLanguages = function(){ var accept = accepts(this); return accept.languages.apply(accept, arguments); }; /** * Parse Range header field, capping to the given `size`. * * Unspecified ranges such as "0-" require knowledge of your resource length. In * the case of a byte range this is of course the total number of bytes. If the * Range header field is not given `undefined` is returned, `-1` when unsatisfiable, * and `-2` when syntactically invalid. * * When ranges are returned, the array has a "type" property which is the type of * range that is required (most commonly, "bytes"). Each array element is an object * with a "start" and "end" property for the portion of the range. * * The "combine" option can be set to `true` and overlapping & adjacent ranges * will be combined into a single range. * * NOTE: remember that ranges are inclusive, so for example "Range: users=0-3" * should respond with 4 users when available, not 3. * * @param {number} size * @param {object} [options] * @param {boolean} [options.combine=false] * @return {number|array} * @public */ req.range = function range(size, options) { var range = this.get('Range'); if (!range) return; return parseRange(size, range, options); }; /** * Parse the query string of `req.url`. * * This uses the "query parser" setting to parse the raw * string into an object. * * @return {String} * @api public */ defineGetter(req, 'query', function query(){ var queryparse = this.app.get('query parser fn'); if (!queryparse) { // parsing is disabled return Object.create(null); } var querystring = parse(this).query; return queryparse(querystring); }); /** * Check if the incoming request contains the "Content-Type" * header field, and it contains the given mime `type`. * * Examples: * * // With Content-Type: text/html; charset=utf-8 * req.is('html'); * req.is('text/html'); * req.is('text/*'); * // => true * * // When Content-Type is application/json * req.is('json'); * req