UNPKG

truffle

Version:

Truffle - Simple development framework for Ethereum

2,344 lines (1,909 loc) 624 kB
#!/usr/bin/env node exports.id = 8299; exports.ids = [8299]; exports.modules = { /***/ 59078: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; /*! * accepts * Copyright(c) 2014 Jonathan Ong * Copyright(c) 2015 Douglas Christopher Wilson * MIT Licensed */ /** * Module dependencies. * @private */ var Negotiator = __webpack_require__(60159) var mime = __webpack_require__(80983) /** * Module exports. * @public */ module.exports = Accepts /** * Create a new Accepts object for the given req. * * @param {object} req * @public */ function Accepts (req) { if (!(this instanceof Accepts)) { return new Accepts(req) } this.headers = req.headers this.negotiator = new Negotiator(req) } /** * 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", the extension name * such as "json" 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 * this.types('html'); * // => "html" * * // Accept: text/*, application/json * this.types('html'); * // => "html" * this.types('text/html'); * // => "text/html" * this.types('json', 'text'); * // => "json" * this.types('application/json'); * // => "application/json" * * // Accept: text/*, application/json * this.types('image/png'); * this.types('png'); * // => undefined * * // Accept: text/*;q=.5, application/json * this.types(['html', 'json']); * this.types('html', 'json'); * // => "json" * * @param {String|Array} types... * @return {String|Array|Boolean} * @public */ Accepts.prototype.type = Accepts.prototype.types = function (types_) { var types = types_ // support flattened arguments if (types && !Array.isArray(types)) { types = new Array(arguments.length) for (var i = 0; i < types.length; i++) { types[i] = arguments[i] } } // no types, return all requested types if (!types || types.length === 0) { return this.negotiator.mediaTypes() } // no accept header, return first given type if (!this.headers.accept) { return types[0] } var mimes = types.map(extToMime) var accepts = this.negotiator.mediaTypes(mimes.filter(validMime)) var first = accepts[0] return first ? types[mimes.indexOf(first)] : false } /** * Return accepted encodings or best fit based on `encodings`. * * Given `Accept-Encoding: gzip, deflate` * an array sorted by quality is returned: * * ['gzip', 'deflate'] * * @param {String|Array} encodings... * @return {String|Array} * @public */ Accepts.prototype.encoding = Accepts.prototype.encodings = function (encodings_) { var encodings = encodings_ // support flattened arguments if (encodings && !Array.isArray(encodings)) { encodings = new Array(arguments.length) for (var i = 0; i < encodings.length; i++) { encodings[i] = arguments[i] } } // no encodings, return all requested encodings if (!encodings || encodings.length === 0) { return this.negotiator.encodings() } return this.negotiator.encodings(encodings)[0] || false } /** * Return accepted charsets or best fit based on `charsets`. * * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5` * an array sorted by quality is returned: * * ['utf-8', 'utf-7', 'iso-8859-1'] * * @param {String|Array} charsets... * @return {String|Array} * @public */ Accepts.prototype.charset = Accepts.prototype.charsets = function (charsets_) { var charsets = charsets_ // support flattened arguments if (charsets && !Array.isArray(charsets)) { charsets = new Array(arguments.length) for (var i = 0; i < charsets.length; i++) { charsets[i] = arguments[i] } } // no charsets, return all requested charsets if (!charsets || charsets.length === 0) { return this.negotiator.charsets() } return this.negotiator.charsets(charsets)[0] || false } /** * Return accepted languages or best fit based on `langs`. * * Given `Accept-Language: en;q=0.8, es, pt` * an array sorted by quality is returned: * * ['es', 'pt', 'en'] * * @param {String|Array} langs... * @return {Array|String} * @public */ Accepts.prototype.lang = Accepts.prototype.langs = Accepts.prototype.language = Accepts.prototype.languages = function (languages_) { var languages = languages_ // support flattened arguments if (languages && !Array.isArray(languages)) { languages = new Array(arguments.length) for (var i = 0; i < languages.length; i++) { languages[i] = arguments[i] } } // no languages, return all requested languages if (!languages || languages.length === 0) { return this.negotiator.languages() } return this.negotiator.languages(languages)[0] || false } /** * Convert extnames to mime. * * @param {String} type * @return {String} * @private */ function extToMime (type) { return type.indexOf('/') === -1 ? mime.lookup(type) : type } /** * Check if mime is valid. * * @param {String} type * @return {String} * @private */ function validMime (type) { return typeof type === 'string' } /***/ }), /***/ 94849: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var os = __webpack_require__(22037); var fs = __webpack_require__(57147); var child = __webpack_require__(32081); var DEFAULT_RESOLV_FILE = '/etc/resolv.conf'; function getInterfaceName() { var val = 'eth'; var platform = os.platform(); if (platform === 'darwin') { val = 'en'; } else if (platform === 'win32') { val = null; } return val; } function getIfconfigCMD() { if (os.platform() === 'win32') { return 'ipconfig/all'; } return '/sbin/ifconfig'; } /** * Get all addresses. * * @param {String} [interfaceName] interface name, default is 'eth' on linux, 'en' on mac os. * @param {Function(err, addr)} callback * - {Object} addr { * - {String} ip * - {String} ipv6 * - {String} mac * } */ function address(interfaceName, callback) { if (typeof interfaceName === 'function') { callback = interfaceName; interfaceName = null; } var addr = { ip: address.ip(interfaceName), ipv6: address.ipv6(interfaceName), mac: null }; address.mac(interfaceName, function (err, mac) { if (mac) { addr.mac = mac; } callback(err, addr); }); } address.interface = function (family, name) { var interfaces = os.networkInterfaces(); var noName = !name; name = name || getInterfaceName(); family = family || 'IPv4'; for (var i = -1; i < 8; i++) { var interfaceName = name + (i >= 0 ? i : ''); // support 'lo' and 'lo0' var items = interfaces[interfaceName]; if (items) { for (var j = 0; j < items.length; j++) { var item = items[j]; if (item.family === family) { return item; } } } } if (noName) { // filter 127.0.0.1, get the first ip for (var k in interfaces) { var items = interfaces[k]; for (var i = 0; i < items.length; i++) { var item = items[i]; if (item.family === family && item.address !== '127.0.0.1') { return item; } } } } return; }; /** * Get current machine IPv4 * * @param {String} [interfaceName] interface name, default is 'eth' on linux, 'en' on mac os. * @return {String} IP address */ address.ip = function (interfaceName) { var item = address.interface('IPv4', interfaceName); return item && item.address; }; /** * Get current machine IPv6 * * @param {String} [interfaceName] interface name, default is 'eth' on linux, 'en' on mac os. * @return {String} IP address */ address.ipv6 = function (interfaceName) { var item = address.interface('IPv6', interfaceName); return item && item.address; }; // osx start line 'en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500' // linux start line 'eth0 Link encap:Ethernet HWaddr 00:16:3E:00:0A:29 ' var MAC_OSX_START_LINE = /^(\w+)\:\s+flags=/; var MAC_LINUX_START_LINE = /^(\w+)\s{2,}link encap:\w+/i; // ether 78:ca:39:b0:e6:7d // HWaddr 00:16:3E:00:0A:29 var MAC_RE = address.MAC_RE = /(?:ether|HWaddr)\s+((?:[a-z0-9]{2}\:){5}[a-z0-9]{2})/i; // osx: inet 192.168.2.104 netmask 0xffffff00 broadcast 192.168.2.255 // linux: inet addr:10.125.5.202 Bcast:10.125.15.255 Mask:255.255.240.0 var MAC_IP_RE = address.MAC_IP_RE = /inet\s(?:addr\:)?(\d+\.\d+\.\d+\.\d+)/; function getMAC(content, interfaceName, matchIP) { var lines = content.split('\n'); for (var i = 0; i < lines.length; i++) { var line = lines[i].trimRight(); var m = MAC_OSX_START_LINE.exec(line) || MAC_LINUX_START_LINE.exec(line); if (!m) { continue; } // check interface name var name = m[1]; if (name.indexOf(interfaceName) !== 0) { continue; } var ip = null; var mac = null; var match = MAC_RE.exec(line); if (match) { mac = match[1]; } i++; while (true) { line = lines[i]; if (!line || MAC_OSX_START_LINE.exec(line) || MAC_LINUX_START_LINE.exec(line)) { i--; break; // hit next interface, handle next interface } if (!mac) { match = MAC_RE.exec(line); if (match) { mac = match[1]; } } if (!ip) { match = MAC_IP_RE.exec(line); if (match) { ip = match[1]; } } i++; } if (ip === matchIP) { return mac; } } } /** * Get current machine MAC address * * @param {String} [interfaceName] interface name, default is 'eth' on linux, 'en' on mac os. * @param {Function(err, address)} callback */ address.mac = function (interfaceName, callback) { if (typeof interfaceName === 'function') { callback = interfaceName; interfaceName = null; } interfaceName = interfaceName || getInterfaceName(); var item = address.interface('IPv4', interfaceName); if (!item) { return callback(); } // https://github.com/nodejs/node/issues/13581 // bug in node 7.x and <= 8.4.0 if (!process.env.CI && (item.mac === 'ff:00:00:00:00:00' || item.mac === '00:00:00:00:00:00')) { // wrong address, ignore it item.mac = ''; } if (item.mac) { return callback(null, item.mac); } child.exec(getIfconfigCMD(), {timeout: 5000}, function (err, stdout, stderr) { if (err || !stdout) { return callback(err); } var mac = getMAC(stdout || '', interfaceName, item.address); callback(null, mac); }); }; // nameserver 172.24.102.254 var DNS_SERVER_RE = /^nameserver\s+(\d+\.\d+\.\d+\.\d+)$/i; /** * Get DNS servers. * * @param {String} [filepath] resolv config file path. default is '/etc/resolv.conf'. * @param {Function(err, servers)} callback */ address.dns = function (filepath, callback) { if (typeof filepath === 'function') { callback = filepath; filepath = null; } filepath = filepath || DEFAULT_RESOLV_FILE; fs.readFile(filepath, 'utf8', function (err, content) { if (err) { return callback(err); } var servers = []; content = content || ''; var lines = content.split('\n'); for (var i = 0; i < lines.length; i++) { var line = lines[i].trim(); var m = DNS_SERVER_RE.exec(line); if (m) { servers.push(m[1]); } } callback(null, servers); }); }; module.exports = address; /***/ }), /***/ 72521: /***/ ((module) => { "use strict"; /** * Expose `arrayFlatten`. */ module.exports = arrayFlatten /** * Recursive flatten function with depth. * * @param {Array} array * @param {Array} result * @param {Number} depth * @return {Array} */ function flattenWithDepth (array, result, depth) { for (var i = 0; i < array.length; i++) { var value = array[i] if (depth > 0 && Array.isArray(value)) { flattenWithDepth(value, result, depth - 1) } else { result.push(value) } } return result } /** * Recursive flatten function. Omitting depth is slightly faster. * * @param {Array} array * @param {Array} result * @return {Array} */ function flattenForever (array, result) { for (var i = 0; i < array.length; i++) { var value = array[i] if (Array.isArray(value)) { flattenForever(value, result) } else { result.push(value) } } return result } /** * Flatten an array, with the ability to define a depth. * * @param {Array} array * @param {Number} depth * @return {Array} */ function arrayFlatten (array, depth) { if (depth == null) { return flattenForever(array, []) } return flattenWithDepth(array, [], depth) } /***/ }), /***/ 87453: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var ArraySpeciesCreate = __webpack_require__(9572); var Call = __webpack_require__(50581); var CreateDataPropertyOrThrow = __webpack_require__(91146); var Get = __webpack_require__(1391); var HasProperty = __webpack_require__(44458); var IsCallable = __webpack_require__(61787); var ToUint32 = __webpack_require__(33306); var ToObject = __webpack_require__(30821); var ToString = __webpack_require__(96846); var callBound = __webpack_require__(21924); var isString = __webpack_require__(29981); // Check failure of by-index access of string characters (IE < 9) and failure of `0 in boxedString` (Rhino) var boxedString = Object('a'); var splitString = boxedString[0] !== 'a' || !(0 in boxedString); var strSplit = callBound('String.prototype.split'); module.exports = function map(callbackfn) { var O = ToObject(this); var self = splitString && isString(O) ? strSplit(O, '') : O; var len = ToUint32(self.length); // If no callback function or if callback is not a callable function if (!IsCallable(callbackfn)) { throw new TypeError('Array.prototype.map callback must be a function'); } var T; if (arguments.length > 1) { T = arguments[1]; } var A = ArraySpeciesCreate(O, len); var k = 0; while (k < len) { var Pk = ToString(k); var kPresent = HasProperty(O, Pk); if (kPresent) { var kValue = Get(O, Pk); var mappedValue = Call(callbackfn, T, [kValue, k, O]); CreateDataPropertyOrThrow(A, Pk, mappedValue); } k += 1; } return A; }; /***/ }), /***/ 14770: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var define = __webpack_require__(4289); var RequireObjectCoercible = __webpack_require__(39619); var callBound = __webpack_require__(21924); var implementation = __webpack_require__(87453); var getPolyfill = __webpack_require__(47373); var polyfill = getPolyfill(); var shim = __webpack_require__(12717); var $slice = callBound('Array.prototype.slice'); // eslint-disable-next-line no-unused-vars var boundMapShim = function map(array, callbackfn) { RequireObjectCoercible(array); return polyfill.apply(array, $slice(arguments, 1)); }; define(boundMapShim, { getPolyfill: getPolyfill, implementation: implementation, shim: shim }); module.exports = boundMapShim; /***/ }), /***/ 47373: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var arrayMethodBoxesProperly = __webpack_require__(72868); var implementation = __webpack_require__(87453); module.exports = function getPolyfill() { var method = Array.prototype.map; return arrayMethodBoxesProperly(method) ? method : implementation; }; /***/ }), /***/ 12717: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var define = __webpack_require__(4289); var getPolyfill = __webpack_require__(47373); module.exports = function shimArrayPrototypeMap() { var polyfill = getPolyfill(); define( Array.prototype, { map: polyfill }, { map: function () { return Array.prototype.map !== polyfill; } } ); return polyfill; }; /***/ }), /***/ 10046: /***/ ((module, exports, __webpack_require__) => { "use strict"; /*! * body-parser * Copyright(c) 2014-2015 Douglas Christopher Wilson * MIT Licensed */ /** * Module dependencies. * @private */ var deprecate = __webpack_require__(19519)('body-parser') /** * Cache of loaded parsers. * @private */ var parsers = Object.create(null) /** * @typedef Parsers * @type {function} * @property {function} json * @property {function} raw * @property {function} text * @property {function} urlencoded */ /** * Module exports. * @type {Parsers} */ exports = module.exports = deprecate.function(bodyParser, 'bodyParser: use individual json/urlencoded middlewares') /** * JSON parser. * @public */ Object.defineProperty(exports, "json", ({ configurable: true, enumerable: true, get: createParserGetter('json') })) /** * Raw parser. * @public */ Object.defineProperty(exports, "raw", ({ configurable: true, enumerable: true, get: createParserGetter('raw') })) /** * Text parser. * @public */ Object.defineProperty(exports, "text", ({ configurable: true, enumerable: true, get: createParserGetter('text') })) /** * URL-encoded parser. * @public */ Object.defineProperty(exports, "urlencoded", ({ configurable: true, enumerable: true, get: createParserGetter('urlencoded') })) /** * Create a middleware to parse json and urlencoded bodies. * * @param {object} [options] * @return {function} * @deprecated * @public */ function bodyParser (options) { // use default type for parsers var opts = Object.create(options || null, { type: { configurable: true, enumerable: true, value: undefined, writable: true } }) var _urlencoded = exports.urlencoded(opts) var _json = exports.json(opts) return function bodyParser (req, res, next) { _json(req, res, function (err) { if (err) return next(err) _urlencoded(req, res, next) }) } } /** * Create a getter for loading a parser. * @private */ function createParserGetter (name) { return function get () { return loadParser(name) } } /** * Load a parser module. * @private */ function loadParser (parserName) { var parser = parsers[parserName] if (parser !== undefined) { return parser } // this uses a switch for static require analysis switch (parserName) { case 'json': parser = __webpack_require__(56035) break case 'raw': parser = __webpack_require__(40187) break case 'text': parser = __webpack_require__(66560) break case 'urlencoded': parser = __webpack_require__(54861) break } // store to prevent invoking require() return (parsers[parserName] = parser) } /***/ }), /***/ 63211: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; /*! * body-parser * Copyright(c) 2014-2015 Douglas Christopher Wilson * MIT Licensed */ /** * Module dependencies. * @private */ var createError = __webpack_require__(69009) var destroy = __webpack_require__(26149) var getBody = __webpack_require__(11045) var iconv = __webpack_require__(4914) var onFinished = __webpack_require__(80338) var unpipe = __webpack_require__(98170) var zlib = __webpack_require__(59796) /** * Module exports. */ module.exports = read /** * Read a request into a buffer and parse. * * @param {object} req * @param {object} res * @param {function} next * @param {function} parse * @param {function} debug * @param {object} options * @private */ function read (req, res, next, parse, debug, options) { var length var opts = options var stream // flag as parsed req._body = true // read options var encoding = opts.encoding !== null ? opts.encoding : null var verify = opts.verify try { // get the content stream stream = contentstream(req, debug, opts.inflate) length = stream.length stream.length = undefined } catch (err) { return next(err) } // set raw-body options opts.length = length opts.encoding = verify ? null : encoding // assert charset is supported if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) { return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', { charset: encoding.toLowerCase(), type: 'charset.unsupported' })) } // read body debug('read body') getBody(stream, opts, function (error, body) { if (error) { var _error if (error.type === 'encoding.unsupported') { // echo back charset _error = createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', { charset: encoding.toLowerCase(), type: 'charset.unsupported' }) } else { // set status code on error _error = createError(400, error) } // unpipe from stream and destroy if (stream !== req) { unpipe(req) destroy(stream, true) } // read off entire request dump(req, function onfinished () { next(createError(400, _error)) }) return } // verify if (verify) { try { debug('verify body') verify(req, res, body, encoding) } catch (err) { next(createError(403, err, { body: body, type: err.type || 'entity.verify.failed' })) return } } // parse var str = body try { debug('parse body') str = typeof body !== 'string' && encoding !== null ? iconv.decode(body, encoding) : body req.body = parse(str) } catch (err) { next(createError(400, err, { body: str, type: err.type || 'entity.parse.failed' })) return } next() }) } /** * Get the content stream of the request. * * @param {object} req * @param {function} debug * @param {boolean} [inflate=true] * @return {object} * @api private */ function contentstream (req, debug, inflate) { var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase() var length = req.headers['content-length'] var stream debug('content-encoding "%s"', encoding) if (inflate === false && encoding !== 'identity') { throw createError(415, 'content encoding unsupported', { encoding: encoding, type: 'encoding.unsupported' }) } switch (encoding) { case 'deflate': stream = zlib.createInflate() debug('inflate body') req.pipe(stream) break case 'gzip': stream = zlib.createGunzip() debug('gunzip body') req.pipe(stream) break case 'identity': stream = req stream.length = length break default: throw createError(415, 'unsupported content encoding "' + encoding + '"', { encoding: encoding, type: 'encoding.unsupported' }) } return stream } /** * Dump the contents of a request. * * @param {object} req * @param {function} callback * @api private */ function dump (req, callback) { if (onFinished.isFinished(req)) { callback(null) } else { onFinished(req, callback) req.resume() } } /***/ }), /***/ 56035: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; /*! * body-parser * Copyright(c) 2014 Jonathan Ong * Copyright(c) 2014-2015 Douglas Christopher Wilson * MIT Licensed */ /** * Module dependencies. * @private */ var bytes = __webpack_require__(79830) var contentType = __webpack_require__(37811) var createError = __webpack_require__(69009) var debug = __webpack_require__(8006)('body-parser:json') var read = __webpack_require__(63211) var typeis = __webpack_require__(40273) /** * Module exports. */ module.exports = json /** * RegExp to match the first non-space in a string. * * Allowed whitespace is defined in RFC 7159: * * ws = *( * %x20 / ; Space * %x09 / ; Horizontal tab * %x0A / ; Line feed or New line * %x0D ) ; Carriage return */ var FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*([^\x20\x09\x0a\x0d])/ // eslint-disable-line no-control-regex /** * Create a middleware to parse JSON bodies. * * @param {object} [options] * @return {function} * @public */ function json (options) { var opts = options || {} var limit = typeof opts.limit !== 'number' ? bytes.parse(opts.limit || '100kb') : opts.limit var inflate = opts.inflate !== false var reviver = opts.reviver var strict = opts.strict !== false var type = opts.type || 'application/json' var verify = opts.verify || false if (verify !== false && typeof verify !== 'function') { throw new TypeError('option verify must be function') } // create the appropriate type checking function var shouldParse = typeof type !== 'function' ? typeChecker(type) : type function parse (body) { if (body.length === 0) { // special-case empty json body, as it's a common client-side mistake // TODO: maybe make this configurable or part of "strict" option return {} } if (strict) { var first = firstchar(body) if (first !== '{' && first !== '[') { debug('strict violation') throw createStrictSyntaxError(body, first) } } try { debug('parse json') return JSON.parse(body, reviver) } catch (e) { throw normalizeJsonSyntaxError(e, { message: e.message, stack: e.stack }) } } return function jsonParser (req, res, next) { if (req._body) { debug('body already parsed') next() return } req.body = req.body || {} // skip requests without bodies if (!typeis.hasBody(req)) { debug('skip empty body') next() return } debug('content-type %j', req.headers['content-type']) // determine if request should be parsed if (!shouldParse(req)) { debug('skip parsing') next() return } // assert charset per RFC 7159 sec 8.1 var charset = getCharset(req) || 'utf-8' if (charset.slice(0, 4) !== 'utf-') { debug('invalid charset') next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', { charset: charset, type: 'charset.unsupported' })) return } // read read(req, res, next, parse, debug, { encoding: charset, inflate: inflate, limit: limit, verify: verify }) } } /** * Create strict violation syntax error matching native error. * * @param {string} str * @param {string} char * @return {Error} * @private */ function createStrictSyntaxError (str, char) { var index = str.indexOf(char) var partial = index !== -1 ? str.substring(0, index) + '#' : '' try { JSON.parse(partial); /* istanbul ignore next */ throw new SyntaxError('strict violation') } catch (e) { return normalizeJsonSyntaxError(e, { message: e.message.replace('#', char), stack: e.stack }) } } /** * Get the first non-whitespace character in a string. * * @param {string} str * @return {function} * @private */ function firstchar (str) { var match = FIRST_CHAR_REGEXP.exec(str) return match ? match[1] : undefined } /** * Get the charset of a request. * * @param {object} req * @api private */ function getCharset (req) { try { return (contentType.parse(req).parameters.charset || '').toLowerCase() } catch (e) { return undefined } } /** * Normalize a SyntaxError for JSON.parse. * * @param {SyntaxError} error * @param {object} obj * @return {SyntaxError} */ function normalizeJsonSyntaxError (error, obj) { var keys = Object.getOwnPropertyNames(error) for (var i = 0; i < keys.length; i++) { var key = keys[i] if (key !== 'stack' && key !== 'message') { delete error[key] } } // replace stack before message for Node.js 0.10 and below error.stack = obj.stack.replace(error.message, obj.message) error.message = obj.message return error } /** * Get the simple type checker. * * @param {string} type * @return {function} */ function typeChecker (type) { return function checkType (req) { return Boolean(typeis(req, type)) } } /***/ }), /***/ 40187: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; /*! * body-parser * Copyright(c) 2014-2015 Douglas Christopher Wilson * MIT Licensed */ /** * Module dependencies. */ var bytes = __webpack_require__(79830) var debug = __webpack_require__(8006)('body-parser:raw') var read = __webpack_require__(63211) var typeis = __webpack_require__(40273) /** * Module exports. */ module.exports = raw /** * Create a middleware to parse raw bodies. * * @param {object} [options] * @return {function} * @api public */ function raw (options) { var opts = options || {} var inflate = opts.inflate !== false var limit = typeof opts.limit !== 'number' ? bytes.parse(opts.limit || '100kb') : opts.limit var type = opts.type || 'application/octet-stream' var verify = opts.verify || false if (verify !== false && typeof verify !== 'function') { throw new TypeError('option verify must be function') } // create the appropriate type checking function var shouldParse = typeof type !== 'function' ? typeChecker(type) : type function parse (buf) { return buf } return function rawParser (req, res, next) { if (req._body) { debug('body already parsed') next() return } req.body = req.body || {} // skip requests without bodies if (!typeis.hasBody(req)) { debug('skip empty body') next() return } debug('content-type %j', req.headers['content-type']) // determine if request should be parsed if (!shouldParse(req)) { debug('skip parsing') next() return } // read read(req, res, next, parse, debug, { encoding: null, inflate: inflate, limit: limit, verify: verify }) } } /** * Get the simple type checker. * * @param {string} type * @return {function} */ function typeChecker (type) { return function checkType (req) { return Boolean(typeis(req, type)) } } /***/ }), /***/ 66560: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; /*! * body-parser * Copyright(c) 2014-2015 Douglas Christopher Wilson * MIT Licensed */ /** * Module dependencies. */ var bytes = __webpack_require__(79830) var contentType = __webpack_require__(37811) var debug = __webpack_require__(8006)('body-parser:text') var read = __webpack_require__(63211) var typeis = __webpack_require__(40273) /** * Module exports. */ module.exports = text /** * Create a middleware to parse text bodies. * * @param {object} [options] * @return {function} * @api public */ function text (options) { var opts = options || {} var defaultCharset = opts.defaultCharset || 'utf-8' var inflate = opts.inflate !== false var limit = typeof opts.limit !== 'number' ? bytes.parse(opts.limit || '100kb') : opts.limit var type = opts.type || 'text/plain' var verify = opts.verify || false if (verify !== false && typeof verify !== 'function') { throw new TypeError('option verify must be function') } // create the appropriate type checking function var shouldParse = typeof type !== 'function' ? typeChecker(type) : type function parse (buf) { return buf } return function textParser (req, res, next) { if (req._body) { debug('body already parsed') next() return } req.body = req.body || {} // skip requests without bodies if (!typeis.hasBody(req)) { debug('skip empty body') next() return } debug('content-type %j', req.headers['content-type']) // determine if request should be parsed if (!shouldParse(req)) { debug('skip parsing') next() return } // get charset var charset = getCharset(req) || defaultCharset // read read(req, res, next, parse, debug, { encoding: charset, inflate: inflate, limit: limit, verify: verify }) } } /** * Get the charset of a request. * * @param {object} req * @api private */ function getCharset (req) { try { return (contentType.parse(req).parameters.charset || '').toLowerCase() } catch (e) { return undefined } } /** * Get the simple type checker. * * @param {string} type * @return {function} */ function typeChecker (type) { return function checkType (req) { return Boolean(typeis(req, type)) } } /***/ }), /***/ 54861: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; /*! * body-parser * Copyright(c) 2014 Jonathan Ong * Copyright(c) 2014-2015 Douglas Christopher Wilson * MIT Licensed */ /** * Module dependencies. * @private */ var bytes = __webpack_require__(79830) var contentType = __webpack_require__(37811) var createError = __webpack_require__(69009) var debug = __webpack_require__(8006)('body-parser:urlencoded') var deprecate = __webpack_require__(19519)('body-parser') var read = __webpack_require__(63211) var typeis = __webpack_require__(40273) /** * Module exports. */ module.exports = urlencoded /** * Cache of parser modules. */ var parsers = Object.create(null) /** * Create a middleware to parse urlencoded bodies. * * @param {object} [options] * @return {function} * @public */ function urlencoded (options) { var opts = options || {} // notice because option default will flip in next major if (opts.extended === undefined) { deprecate('undefined extended: provide extended option') } var extended = opts.extended !== false var inflate = opts.inflate !== false var limit = typeof opts.limit !== 'number' ? bytes.parse(opts.limit || '100kb') : opts.limit var type = opts.type || 'application/x-www-form-urlencoded' var verify = opts.verify || false if (verify !== false && typeof verify !== 'function') { throw new TypeError('option verify must be function') } // create the appropriate query parser var queryparse = extended ? extendedparser(opts) : simpleparser(opts) // create the appropriate type checking function var shouldParse = typeof type !== 'function' ? typeChecker(type) : type function parse (body) { return body.length ? queryparse(body) : {} } return function urlencodedParser (req, res, next) { if (req._body) { debug('body already parsed') next() return } req.body = req.body || {} // skip requests without bodies if (!typeis.hasBody(req)) { debug('skip empty body') next() return } debug('content-type %j', req.headers['content-type']) // determine if request should be parsed if (!shouldParse(req)) { debug('skip parsing') next() return } // assert charset var charset = getCharset(req) || 'utf-8' if (charset !== 'utf-8') { debug('invalid charset') next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', { charset: charset, type: 'charset.unsupported' })) return } // read read(req, res, next, parse, debug, { debug: debug, encoding: charset, inflate: inflate, limit: limit, verify: verify }) } } /** * Get the extended query parser. * * @param {object} options */ function extendedparser (options) { var parameterLimit = options.parameterLimit !== undefined ? options.parameterLimit : 1000 var parse = parser('qs') if (isNaN(parameterLimit) || parameterLimit < 1) { throw new TypeError('option parameterLimit must be a positive number') } if (isFinite(parameterLimit)) { parameterLimit = parameterLimit | 0 } return function queryparse (body) { var paramCount = parameterCount(body, parameterLimit) if (paramCount === undefined) { debug('too many parameters') throw createError(413, 'too many parameters', { type: 'parameters.too.many' }) } var arrayLimit = Math.max(100, paramCount) debug('parse extended urlencoding') return parse(body, { allowPrototypes: true, arrayLimit: arrayLimit, depth: Infinity, parameterLimit: parameterLimit }) } } /** * Get the charset of a request. * * @param {object} req * @api private */ function getCharset (req) { try { return (contentType.parse(req).parameters.charset || '').toLowerCase() } catch (e) { return undefined } } /** * Count the number of parameters, stopping once limit reached * * @param {string} body * @param {number} limit * @api private */ function parameterCount (body, limit) { var count = 0 var index = 0 while ((index = body.indexOf('&', index)) !== -1) { count++ index++ if (count === limit) { return undefined } } return count } /** * Get parser for module name dynamically. * * @param {string} name * @return {function} * @api private */ function parser (name) { var mod = parsers[name] if (mod !== undefined) { return mod.parse } // this uses a switch for static require analysis switch (name) { case 'qs': mod = __webpack_require__(80129) break case 'querystring': mod = __webpack_require__(63477) break } // store to prevent invoking require() parsers[name] = mod return mod.parse } /** * Get the simple query parser. * * @param {object} options */ function simpleparser (options) { var parameterLimit = options.parameterLimit !== undefined ? options.parameterLimit : 1000 var parse = parser('querystring') if (isNaN(parameterLimit) || parameterLimit < 1) { throw new TypeError('option parameterLimit must be a positive number') } if (isFinite(parameterLimit)) { parameterLimit = parameterLimit | 0 } return function queryparse (body) { var paramCount = parameterCount(body, parameterLimit) if (paramCount === undefined) { debug('too many parameters') throw createError(413, 'too many parameters', { type: 'parameters.too.many' }) } debug('parse urlencoding') return parse(body, undefined, undefined, { maxKeys: parameterLimit }) } } /** * Get the simple type checker. * * @param {string} type * @return {function} */ function typeChecker (type) { return function checkType (req) { return Boolean(typeis(req, type)) } } /***/ }), /***/ 17497: /***/ ((module, exports, __webpack_require__) => { /** * This is the web browser implementation of `debug()`. * * Expose `debug()` as the module. */ exports = module.exports = __webpack_require__(29292); exports.log = log; exports.formatArgs = formatArgs; exports.save = save; exports.load = load; exports.useColors = useColors; exports.storage = 'undefined' != typeof chrome && 'undefined' != typeof chrome.storage ? chrome.storage.local : localstorage(); /** * Colors. */ exports.colors = [ 'lightseagreen', 'forestgreen', 'goldenrod', 'dodgerblue', 'darkorchid', 'crimson' ]; /** * Currently only WebKit-based Web Inspectors, Firefox >= v31, * and the Firebug extension (any Firefox version) are known * to support "%c" CSS customizations. * * TODO: add a `localStorage` variable to explicitly enable/disable colors */ function useColors() { // NB: In an Electron preload script, document will be defined but not fully // initialized. Since we know we're in Chrome, we'll just detect this case // explicitly if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { return true; } // is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || // is firebug? http://stackoverflow.com/a/398120/376773 (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || // is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || // double check webkit in userAgent just in case we are in a worker (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } /** * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. */ exports.formatters.j = function(v) { try { return JSON.stringify(v); } catch (err) { return '[UnexpectedJSONParseError]: ' + err.message; } }; /** * Colorize log arguments if enabled. * * @api public */ function formatArgs(args) { var useColors = this.useColors; args[0] = (useColors ? '%c' : '') + this.namespace + (useColors ? ' %c' : ' ') + args[0] + (useColors ? '%c ' : ' ') + '+' + exports.humanize(this.diff); if (!useColors) return; var c = 'color: ' + this.color; args.splice(1, 0, c, 'color: inherit') // the final "%c" is somewhat tricky, because there could be other // arguments passed either before or after the %c, so we need to // figure out the correct index to insert the CSS into var index = 0; var lastC = 0; args[0].replace(/%[a-zA-Z%]/g, function(match) { if ('%%' === match) return; index++; if ('%c' === match) { // we only are interested in the *last* %c // (the user may have provided their own) lastC = index; } }); args.splice(lastC, 0, c); } /** * Invokes `console.log()` when available. * No-op when `console.log` is not a "function". * * @api public */ function log() { // this hackery is required for IE8/9, where // the `console.log` function doesn't have 'apply' return 'object' === typeof console && console.log && Function.prototype.apply.call(console.log, console, arguments); } /** * Save `namespaces`. * * @param {String} namespaces * @api private */ function save(namespaces) { try { if (null == namespaces) { exports.storage.removeItem('debug'); } else { exports.storage.debug = namespaces; } } catch(e) {} } /** * Load `namespaces`. * * @return {String} returns the previously persisted debug modes * @api private */ function load() { var r; try { r = exports.storage.debug; } catch(e) {} // If debug isn't set in LS, and we're in Electron, try to load $DEBUG if (!r && typeof process !== 'undefined' && 'env' in process) { r = process.env.DEBUG; } return r; } /** * Enable namespaces listed in `localStorage.debug` initially. */ exports.enable(load()); /** * Localstorage attempts to return the localstorage. * * This is necessary because safari throws * when a user disables cookies/localstorage * and you attempt to access it. * * @return {LocalStorage} * @api private */ function localstorage() { try { return window.localStorage; } catch (e) {} } /***/ }), /***/ 29292: /***/ ((module, exports, __webpack_require__) => { /** * This is the common logic for both the Node.js and web browser * implementations of `debug()`. * * Expose `debug()` as the module. */ exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; exports.coerce = coerce; exports.disable = disable; exports.enable = enable; exports.enabled = enabled; exports.humanize = __webpack_require__(26214); /** * The currently active debug mode names, and names to skip. */ exports.names = []; exports.skips = []; /** * Map of special "%n" handling functions, for the debug "format" argument. * * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". */ exports.formatters = {}; /** * Previous log timestamp. */ var prevTime; /** * Select a color. * @param {String} namespace * @return {Number} * @api private */ function selectColor(namespace) { var hash = 0, i; for (i in namespace) { hash = ((hash << 5) - hash) + namespace.charCodeAt(i); hash |= 0; // Convert to 32bit integer } return exports.colors[Math.abs(hash) % exports.colors.length]; } /** * Create a debugger with the given `namespace`. * * @param {String} namespace * @return {Function} * @api public */ function createDebug(namespace) { function debug() { // disabled? if (!debug.enabled) return; var self = debug; // set `diff` timestamp var curr = +new Date(); var ms = curr - (prevTime || curr); self.diff = ms; self.prev = prevTime; self.curr = curr; prevTime = curr; // turn the `arguments` into a proper Array var args = new Array(arguments.length); for (var i = 0; i < args.length; i++) { args[i] = arguments[i]; } args[0] = exports.coerce(args[0]); if ('string' !== typeof args[0]) { // anything else let's inspect with %O args.unshift('%O'); } // apply any `formatters` transformations var index = 0; args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { // if we encounter an escaped % then don't increase the array index if (match === '%%') return match; index++; var formatter = exports.formatters[format]; if ('function' === typeof formatter) { var val = args[index]; match = formatter.call(self, val); // now we need to remove `args[index]` since it's inlined in the `format` args.splice(index, 1); index--; } return match; }); // apply env-specific formatting (colors, etc.) exports.formatArgs.call(self, args); var logFn = debug.log || exports.log || console.log.bind(console); logFn.apply(self, args); } debug.namespace = namespace; debug.enabled = exports.enabled(namespace); debug.useColors = exports.useColors(); debug.color = selectColor(namespace); // env-specific initialization logic for debug instances if ('function' === typeof exports.init) { exports.init(debug); } return debug; } /** * Enables a debug mode by namespaces. This can include modes * separated by a colon and wildcards. * * @param {String} namespaces * @api public */ function enable(namespaces) { exports.save(namespaces); exports.names = []; exports.skips = []; var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); var len = split.length; for (var i = 0; i < len; i++) { if (!split[i]) continue; // ignore empty strings namespaces = split[i].replace(/\*/g, '.*?'); if (namespaces[0] === '-') { exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); } else { exports.names.push(new RegExp('^' + namespaces + '$')); } } } /** * Disable debug output. * * @api public */ function disable() { exports.enable(''); } /** * Returns true if the given mode name is enabled, false otherwise. * * @param {String} name * @return {Boolean} * @api public */ function enabled(name) { var i, len; for (i = 0, len = exports.skips.length; i < len; i++) { if (exports.skips[i].test(name)) { return false; } } for (i = 0, len = exports.names.length; i < len; i++) { if (exports.names[i].test(name)) { return true; } } return false; } /** * Coerce `val`. * * @param {Mixed} val * @return {Mixed} * @api private */ function coerce(val) { if (val instanceof Error) return val.stack || val.message; return val; } /***/ }), /***/ 8006: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /** * Detect Electron renderer process, which is node, but we should * treat as a browser. */ if (typeof process !== 'undefined' && process.type === 'renderer') { module.exports = __webpack_require__(17497); } else { module.exports = __webpack_require__(90337); } /***/ }), /***/ 90337: /***/ ((module, exports, __webpack_require__) => { /** * Module dependencies. */ var tty = __webpack_require__(76224); var util = __webpack_require__(73837); /** * This is the Node.js implementation of `debug()`. * * Expose `debug()` as the module. */ exports = module.exports = __webpack_require__(29292); exports.init = init; exports.log = log; exports.formatArgs = formatArgs; exports.save = save; exports.load = load; exports.useColors = useColors; /** * Colors. */ exports.colors = [6, 2, 3, 4, 5, 1]; /** * Build up the default `inspectOpts` object from the environment variables. * * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js */ exports.inspectOpts = Object.keys(process.env).filter(function (key) { return /^debug_/i.test(key); }).reduce(function (obj, key) { // camel-case var prop = key .substring(6) .toLowerCase() .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() }); // coerce string value into JS value var val = process.env[key]; if (/^(yes|on|true|enabled)$/i.test(val)) val = true; else if (/^(no|off|false|disabled)$/i.test(val)) val = false; else if (val === 'null') val = null; else val = Number(val); obj[prop] = val; return obj; }, {}); /** * The file descriptor to write the `debug()` calls to. * Set the `DEBUG_FD` env variable to override with another value. i.e.: *