mirror of
https://github.com/crazy-max/ghaction-upx.git
synced 2024-11-25 03:36:08 -07:00
27105 lines
877 KiB
JavaScript
Generated
27105 lines
877 KiB
JavaScript
Generated
module.exports =
|
|
/******/ (function(modules, runtime) { // webpackBootstrap
|
|
/******/ "use strict";
|
|
/******/ // The module cache
|
|
/******/ var installedModules = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __webpack_require__(moduleId) {
|
|
/******/
|
|
/******/ // Check if module is in cache
|
|
/******/ if(installedModules[moduleId]) {
|
|
/******/ return installedModules[moduleId].exports;
|
|
/******/ }
|
|
/******/ // Create a new module (and put it into the cache)
|
|
/******/ var module = installedModules[moduleId] = {
|
|
/******/ i: moduleId,
|
|
/******/ l: false,
|
|
/******/ exports: {}
|
|
/******/ };
|
|
/******/
|
|
/******/ // Execute the module function
|
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
/******/
|
|
/******/ // Flag the module as loaded
|
|
/******/ module.l = true;
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/******/
|
|
/******/ __webpack_require__.ab = __dirname + "/";
|
|
/******/
|
|
/******/ // the startup function
|
|
/******/ function startup() {
|
|
/******/ // Load entry module and return exports
|
|
/******/ return __webpack_require__(198);
|
|
/******/ };
|
|
/******/
|
|
/******/ // run startup
|
|
/******/ return startup();
|
|
/******/ })
|
|
/************************************************************************/
|
|
/******/ ({
|
|
|
|
/***/ 1:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const childProcess = __webpack_require__(129);
|
|
const path = __webpack_require__(622);
|
|
const util_1 = __webpack_require__(669);
|
|
const ioUtil = __webpack_require__(672);
|
|
const exec = util_1.promisify(childProcess.exec);
|
|
/**
|
|
* Copies a file or folder.
|
|
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
|
|
*
|
|
* @param source source path
|
|
* @param dest destination path
|
|
* @param options optional. See CopyOptions.
|
|
*/
|
|
function cp(source, dest, options = {}) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const { force, recursive } = readCopyOptions(options);
|
|
const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
|
|
// Dest is an existing file, but not forcing
|
|
if (destStat && destStat.isFile() && !force) {
|
|
return;
|
|
}
|
|
// If dest is an existing directory, should copy inside.
|
|
const newDest = destStat && destStat.isDirectory()
|
|
? path.join(dest, path.basename(source))
|
|
: dest;
|
|
if (!(yield ioUtil.exists(source))) {
|
|
throw new Error(`no such file or directory: ${source}`);
|
|
}
|
|
const sourceStat = yield ioUtil.stat(source);
|
|
if (sourceStat.isDirectory()) {
|
|
if (!recursive) {
|
|
throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`);
|
|
}
|
|
else {
|
|
yield cpDirRecursive(source, newDest, 0, force);
|
|
}
|
|
}
|
|
else {
|
|
if (path.relative(source, newDest) === '') {
|
|
// a file cannot be copied to itself
|
|
throw new Error(`'${newDest}' and '${source}' are the same file`);
|
|
}
|
|
yield copyFile(source, newDest, force);
|
|
}
|
|
});
|
|
}
|
|
exports.cp = cp;
|
|
/**
|
|
* Moves a path.
|
|
*
|
|
* @param source source path
|
|
* @param dest destination path
|
|
* @param options optional. See MoveOptions.
|
|
*/
|
|
function mv(source, dest, options = {}) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (yield ioUtil.exists(dest)) {
|
|
let destExists = true;
|
|
if (yield ioUtil.isDirectory(dest)) {
|
|
// If dest is directory copy src into dest
|
|
dest = path.join(dest, path.basename(source));
|
|
destExists = yield ioUtil.exists(dest);
|
|
}
|
|
if (destExists) {
|
|
if (options.force == null || options.force) {
|
|
yield rmRF(dest);
|
|
}
|
|
else {
|
|
throw new Error('Destination already exists');
|
|
}
|
|
}
|
|
}
|
|
yield mkdirP(path.dirname(dest));
|
|
yield ioUtil.rename(source, dest);
|
|
});
|
|
}
|
|
exports.mv = mv;
|
|
/**
|
|
* Remove a path recursively with force
|
|
*
|
|
* @param inputPath path to remove
|
|
*/
|
|
function rmRF(inputPath) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (ioUtil.IS_WINDOWS) {
|
|
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
|
|
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
|
|
try {
|
|
if (yield ioUtil.isDirectory(inputPath, true)) {
|
|
yield exec(`rd /s /q "${inputPath}"`);
|
|
}
|
|
else {
|
|
yield exec(`del /f /a "${inputPath}"`);
|
|
}
|
|
}
|
|
catch (err) {
|
|
// if you try to delete a file that doesn't exist, desired result is achieved
|
|
// other errors are valid
|
|
if (err.code !== 'ENOENT')
|
|
throw err;
|
|
}
|
|
// Shelling out fails to remove a symlink folder with missing source, this unlink catches that
|
|
try {
|
|
yield ioUtil.unlink(inputPath);
|
|
}
|
|
catch (err) {
|
|
// if you try to delete a file that doesn't exist, desired result is achieved
|
|
// other errors are valid
|
|
if (err.code !== 'ENOENT')
|
|
throw err;
|
|
}
|
|
}
|
|
else {
|
|
let isDir = false;
|
|
try {
|
|
isDir = yield ioUtil.isDirectory(inputPath);
|
|
}
|
|
catch (err) {
|
|
// if you try to delete a file that doesn't exist, desired result is achieved
|
|
// other errors are valid
|
|
if (err.code !== 'ENOENT')
|
|
throw err;
|
|
return;
|
|
}
|
|
if (isDir) {
|
|
yield exec(`rm -rf "${inputPath}"`);
|
|
}
|
|
else {
|
|
yield ioUtil.unlink(inputPath);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
exports.rmRF = rmRF;
|
|
/**
|
|
* Make a directory. Creates the full path with folders in between
|
|
* Will throw if it fails
|
|
*
|
|
* @param fsPath path to create
|
|
* @returns Promise<void>
|
|
*/
|
|
function mkdirP(fsPath) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield ioUtil.mkdirP(fsPath);
|
|
});
|
|
}
|
|
exports.mkdirP = mkdirP;
|
|
/**
|
|
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
|
|
* If you check and the tool does not exist, it will throw.
|
|
*
|
|
* @param tool name of the tool
|
|
* @param check whether to check if tool exists
|
|
* @returns Promise<string> path to tool
|
|
*/
|
|
function which(tool, check) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (!tool) {
|
|
throw new Error("parameter 'tool' is required");
|
|
}
|
|
// recursive when check=true
|
|
if (check) {
|
|
const result = yield which(tool, false);
|
|
if (!result) {
|
|
if (ioUtil.IS_WINDOWS) {
|
|
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`);
|
|
}
|
|
else {
|
|
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
|
|
}
|
|
}
|
|
}
|
|
try {
|
|
// build the list of extensions to try
|
|
const extensions = [];
|
|
if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
|
|
for (const extension of process.env.PATHEXT.split(path.delimiter)) {
|
|
if (extension) {
|
|
extensions.push(extension);
|
|
}
|
|
}
|
|
}
|
|
// if it's rooted, return it if exists. otherwise return empty.
|
|
if (ioUtil.isRooted(tool)) {
|
|
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
|
|
if (filePath) {
|
|
return filePath;
|
|
}
|
|
return '';
|
|
}
|
|
// if any path separators, return empty
|
|
if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
|
|
return '';
|
|
}
|
|
// build the list of directories
|
|
//
|
|
// Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
|
|
// it feels like we should not do this. Checking the current directory seems like more of a use
|
|
// case of a shell, and the which() function exposed by the toolkit should strive for consistency
|
|
// across platforms.
|
|
const directories = [];
|
|
if (process.env.PATH) {
|
|
for (const p of process.env.PATH.split(path.delimiter)) {
|
|
if (p) {
|
|
directories.push(p);
|
|
}
|
|
}
|
|
}
|
|
// return the first match
|
|
for (const directory of directories) {
|
|
const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
|
|
if (filePath) {
|
|
return filePath;
|
|
}
|
|
}
|
|
return '';
|
|
}
|
|
catch (err) {
|
|
throw new Error(`which failed with message ${err.message}`);
|
|
}
|
|
});
|
|
}
|
|
exports.which = which;
|
|
function readCopyOptions(options) {
|
|
const force = options.force == null ? true : options.force;
|
|
const recursive = Boolean(options.recursive);
|
|
return { force, recursive };
|
|
}
|
|
function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
// Ensure there is not a run away recursive copy
|
|
if (currentDepth >= 255)
|
|
return;
|
|
currentDepth++;
|
|
yield mkdirP(destDir);
|
|
const files = yield ioUtil.readdir(sourceDir);
|
|
for (const fileName of files) {
|
|
const srcFile = `${sourceDir}/${fileName}`;
|
|
const destFile = `${destDir}/${fileName}`;
|
|
const srcFileStat = yield ioUtil.lstat(srcFile);
|
|
if (srcFileStat.isDirectory()) {
|
|
// Recurse
|
|
yield cpDirRecursive(srcFile, destFile, currentDepth, force);
|
|
}
|
|
else {
|
|
yield copyFile(srcFile, destFile, force);
|
|
}
|
|
}
|
|
// Change the mode for the newly created directory
|
|
yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode);
|
|
});
|
|
}
|
|
// Buffered file copy
|
|
function copyFile(srcFile, destFile, force) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) {
|
|
// unlink/re-link it
|
|
try {
|
|
yield ioUtil.lstat(destFile);
|
|
yield ioUtil.unlink(destFile);
|
|
}
|
|
catch (e) {
|
|
// Try to override file permission
|
|
if (e.code === 'EPERM') {
|
|
yield ioUtil.chmod(destFile, '0666');
|
|
yield ioUtil.unlink(destFile);
|
|
}
|
|
// other errors = it doesn't exist, no work to do
|
|
}
|
|
// Copy over symlink
|
|
const symlinkFull = yield ioUtil.readlink(srcFile);
|
|
yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? 'junction' : null);
|
|
}
|
|
else if (!(yield ioUtil.exists(destFile)) || force) {
|
|
yield ioUtil.copyFile(srcFile, destFile);
|
|
}
|
|
});
|
|
}
|
|
//# sourceMappingURL=io.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 9:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var once = __webpack_require__(49);
|
|
|
|
var noop = function() {};
|
|
|
|
var isRequest = function(stream) {
|
|
return stream.setHeader && typeof stream.abort === 'function';
|
|
};
|
|
|
|
var isChildProcess = function(stream) {
|
|
return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3
|
|
};
|
|
|
|
var eos = function(stream, opts, callback) {
|
|
if (typeof opts === 'function') return eos(stream, null, opts);
|
|
if (!opts) opts = {};
|
|
|
|
callback = once(callback || noop);
|
|
|
|
var ws = stream._writableState;
|
|
var rs = stream._readableState;
|
|
var readable = opts.readable || (opts.readable !== false && stream.readable);
|
|
var writable = opts.writable || (opts.writable !== false && stream.writable);
|
|
|
|
var onlegacyfinish = function() {
|
|
if (!stream.writable) onfinish();
|
|
};
|
|
|
|
var onfinish = function() {
|
|
writable = false;
|
|
if (!readable) callback.call(stream);
|
|
};
|
|
|
|
var onend = function() {
|
|
readable = false;
|
|
if (!writable) callback.call(stream);
|
|
};
|
|
|
|
var onexit = function(exitCode) {
|
|
callback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null);
|
|
};
|
|
|
|
var onerror = function(err) {
|
|
callback.call(stream, err);
|
|
};
|
|
|
|
var onclose = function() {
|
|
if (readable && !(rs && rs.ended)) return callback.call(stream, new Error('premature close'));
|
|
if (writable && !(ws && ws.ended)) return callback.call(stream, new Error('premature close'));
|
|
};
|
|
|
|
var onrequest = function() {
|
|
stream.req.on('finish', onfinish);
|
|
};
|
|
|
|
if (isRequest(stream)) {
|
|
stream.on('complete', onfinish);
|
|
stream.on('abort', onclose);
|
|
if (stream.req) onrequest();
|
|
else stream.on('request', onrequest);
|
|
} else if (writable && !ws) { // legacy streams
|
|
stream.on('end', onlegacyfinish);
|
|
stream.on('close', onlegacyfinish);
|
|
}
|
|
|
|
if (isChildProcess(stream)) stream.on('exit', onexit);
|
|
|
|
stream.on('end', onend);
|
|
stream.on('finish', onfinish);
|
|
if (opts.error !== false) stream.on('error', onerror);
|
|
stream.on('close', onclose);
|
|
|
|
return function() {
|
|
stream.removeListener('complete', onfinish);
|
|
stream.removeListener('abort', onclose);
|
|
stream.removeListener('request', onrequest);
|
|
if (stream.req) stream.req.removeListener('finish', onfinish);
|
|
stream.removeListener('end', onlegacyfinish);
|
|
stream.removeListener('close', onlegacyfinish);
|
|
stream.removeListener('finish', onfinish);
|
|
stream.removeListener('exit', onexit);
|
|
stream.removeListener('end', onend);
|
|
stream.removeListener('error', onerror);
|
|
stream.removeListener('close', onclose);
|
|
};
|
|
};
|
|
|
|
module.exports = eos;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 11:
|
|
/***/ (function(module) {
|
|
|
|
// Returns a wrapper function that returns a wrapped callback
|
|
// The wrapper function should do some stuff, and return a
|
|
// presumably different callback function.
|
|
// This makes sure that own properties are retained, so that
|
|
// decorations and such are not lost along the way.
|
|
module.exports = wrappy
|
|
function wrappy (fn, cb) {
|
|
if (fn && cb) return wrappy(fn)(cb)
|
|
|
|
if (typeof fn !== 'function')
|
|
throw new TypeError('need wrapper function')
|
|
|
|
Object.keys(fn).forEach(function (k) {
|
|
wrapper[k] = fn[k]
|
|
})
|
|
|
|
return wrapper
|
|
|
|
function wrapper() {
|
|
var args = new Array(arguments.length)
|
|
for (var i = 0; i < args.length; i++) {
|
|
args[i] = arguments[i]
|
|
}
|
|
var ret = fn.apply(this, args)
|
|
var cb = args[args.length-1]
|
|
if (typeof ret === 'function' && ret !== cb) {
|
|
Object.keys(cb).forEach(function (k) {
|
|
ret[k] = cb[k]
|
|
})
|
|
}
|
|
return ret
|
|
}
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 13:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var replace = String.prototype.replace;
|
|
var percentTwenties = /%20/g;
|
|
|
|
var util = __webpack_require__(581);
|
|
|
|
var Format = {
|
|
RFC1738: 'RFC1738',
|
|
RFC3986: 'RFC3986'
|
|
};
|
|
|
|
module.exports = util.assign(
|
|
{
|
|
'default': Format.RFC3986,
|
|
formatters: {
|
|
RFC1738: function (value) {
|
|
return replace.call(value, percentTwenties, '+');
|
|
},
|
|
RFC3986: function (value) {
|
|
return String(value);
|
|
}
|
|
}
|
|
},
|
|
Format
|
|
);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 16:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const bufferStream = __webpack_require__(375);
|
|
|
|
function getStream(inputStream, opts) {
|
|
if (!inputStream) {
|
|
return Promise.reject(new Error('Expected a stream'));
|
|
}
|
|
|
|
opts = Object.assign({maxBuffer: Infinity}, opts);
|
|
|
|
const maxBuffer = opts.maxBuffer;
|
|
let stream;
|
|
let clean;
|
|
|
|
const p = new Promise((resolve, reject) => {
|
|
const error = err => {
|
|
if (err) { // null check
|
|
err.bufferedData = stream.getBufferedValue();
|
|
}
|
|
|
|
reject(err);
|
|
};
|
|
|
|
stream = bufferStream(opts);
|
|
inputStream.once('error', error);
|
|
inputStream.pipe(stream);
|
|
|
|
stream.on('data', () => {
|
|
if (stream.getBufferedLength() > maxBuffer) {
|
|
reject(new Error('maxBuffer exceeded'));
|
|
}
|
|
});
|
|
stream.once('error', error);
|
|
stream.on('end', resolve);
|
|
|
|
clean = () => {
|
|
// some streams doesn't implement the `stream.Readable` interface correctly
|
|
if (inputStream.unpipe) {
|
|
inputStream.unpipe(stream);
|
|
}
|
|
};
|
|
});
|
|
|
|
p.then(clean, clean);
|
|
|
|
return p.then(() => stream.getBufferedValue());
|
|
}
|
|
|
|
module.exports = getStream;
|
|
module.exports.buffer = (stream, opts) => getStream(stream, Object.assign({}, opts, {encoding: 'buffer'}));
|
|
module.exports.array = (stream, opts) => getStream(stream, Object.assign({}, opts, {array: true}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 27:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
// rfc7231 6.1
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var statusCodeCacheableByDefault = [200, 203, 204, 206, 300, 301, 404, 405, 410, 414, 501];
|
|
|
|
// This implementation does not understand partial responses (206)
|
|
var understoodStatuses = [200, 203, 204, 300, 301, 302, 303, 307, 308, 404, 405, 410, 414, 501];
|
|
|
|
var hopByHopHeaders = { 'connection': true, 'keep-alive': true, 'proxy-authenticate': true, 'proxy-authorization': true, 'te': true, 'trailer': true, 'transfer-encoding': true, 'upgrade': true };
|
|
var excludedFromRevalidationUpdate = {
|
|
// Since the old body is reused, it doesn't make sense to change properties of the body
|
|
'content-length': true, 'content-encoding': true, 'transfer-encoding': true,
|
|
'content-range': true
|
|
};
|
|
|
|
function parseCacheControl(header) {
|
|
var cc = {};
|
|
if (!header) return cc;
|
|
|
|
// TODO: When there is more than one value present for a given directive (e.g., two Expires header fields, multiple Cache-Control: max-age directives),
|
|
// the directive's value is considered invalid. Caches are encouraged to consider responses that have invalid freshness information to be stale
|
|
var parts = header.trim().split(/\s*,\s*/); // TODO: lame parsing
|
|
for (var _iterator = parts, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
|
var _ref;
|
|
|
|
if (_isArray) {
|
|
if (_i >= _iterator.length) break;
|
|
_ref = _iterator[_i++];
|
|
} else {
|
|
_i = _iterator.next();
|
|
if (_i.done) break;
|
|
_ref = _i.value;
|
|
}
|
|
|
|
var part = _ref;
|
|
|
|
var _part$split = part.split(/\s*=\s*/, 2),
|
|
k = _part$split[0],
|
|
v = _part$split[1];
|
|
|
|
cc[k] = v === undefined ? true : v.replace(/^"|"$/g, ''); // TODO: lame unquoting
|
|
}
|
|
|
|
return cc;
|
|
}
|
|
|
|
function formatCacheControl(cc) {
|
|
var parts = [];
|
|
for (var k in cc) {
|
|
var v = cc[k];
|
|
parts.push(v === true ? k : k + '=' + v);
|
|
}
|
|
if (!parts.length) {
|
|
return undefined;
|
|
}
|
|
return parts.join(', ');
|
|
}
|
|
|
|
module.exports = function () {
|
|
function CachePolicy(req, res) {
|
|
var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
shared = _ref2.shared,
|
|
cacheHeuristic = _ref2.cacheHeuristic,
|
|
immutableMinTimeToLive = _ref2.immutableMinTimeToLive,
|
|
ignoreCargoCult = _ref2.ignoreCargoCult,
|
|
_fromObject = _ref2._fromObject;
|
|
|
|
_classCallCheck(this, CachePolicy);
|
|
|
|
if (_fromObject) {
|
|
this._fromObject(_fromObject);
|
|
return;
|
|
}
|
|
|
|
if (!res || !res.headers) {
|
|
throw Error("Response headers missing");
|
|
}
|
|
this._assertRequestHasHeaders(req);
|
|
|
|
this._responseTime = this.now();
|
|
this._isShared = shared !== false;
|
|
this._cacheHeuristic = undefined !== cacheHeuristic ? cacheHeuristic : 0.1; // 10% matches IE
|
|
this._immutableMinTtl = undefined !== immutableMinTimeToLive ? immutableMinTimeToLive : 24 * 3600 * 1000;
|
|
|
|
this._status = 'status' in res ? res.status : 200;
|
|
this._resHeaders = res.headers;
|
|
this._rescc = parseCacheControl(res.headers['cache-control']);
|
|
this._method = 'method' in req ? req.method : 'GET';
|
|
this._url = req.url;
|
|
this._host = req.headers.host;
|
|
this._noAuthorization = !req.headers.authorization;
|
|
this._reqHeaders = res.headers.vary ? req.headers : null; // Don't keep all request headers if they won't be used
|
|
this._reqcc = parseCacheControl(req.headers['cache-control']);
|
|
|
|
// Assume that if someone uses legacy, non-standard uncecessary options they don't understand caching,
|
|
// so there's no point stricly adhering to the blindly copy&pasted directives.
|
|
if (ignoreCargoCult && "pre-check" in this._rescc && "post-check" in this._rescc) {
|
|
delete this._rescc['pre-check'];
|
|
delete this._rescc['post-check'];
|
|
delete this._rescc['no-cache'];
|
|
delete this._rescc['no-store'];
|
|
delete this._rescc['must-revalidate'];
|
|
this._resHeaders = Object.assign({}, this._resHeaders, { 'cache-control': formatCacheControl(this._rescc) });
|
|
delete this._resHeaders.expires;
|
|
delete this._resHeaders.pragma;
|
|
}
|
|
|
|
// When the Cache-Control header field is not present in a request, caches MUST consider the no-cache request pragma-directive
|
|
// as having the same effect as if "Cache-Control: no-cache" were present (see Section 5.2.1).
|
|
if (!res.headers['cache-control'] && /no-cache/.test(res.headers.pragma)) {
|
|
this._rescc['no-cache'] = true;
|
|
}
|
|
}
|
|
|
|
CachePolicy.prototype.now = function now() {
|
|
return Date.now();
|
|
};
|
|
|
|
CachePolicy.prototype.storable = function storable() {
|
|
// The "no-store" request directive indicates that a cache MUST NOT store any part of either this request or any response to it.
|
|
return !!(!this._reqcc['no-store'] && (
|
|
// A cache MUST NOT store a response to any request, unless:
|
|
// The request method is understood by the cache and defined as being cacheable, and
|
|
'GET' === this._method || 'HEAD' === this._method || 'POST' === this._method && this._hasExplicitExpiration()) &&
|
|
// the response status code is understood by the cache, and
|
|
understoodStatuses.indexOf(this._status) !== -1 &&
|
|
// the "no-store" cache directive does not appear in request or response header fields, and
|
|
!this._rescc['no-store'] && (
|
|
// the "private" response directive does not appear in the response, if the cache is shared, and
|
|
!this._isShared || !this._rescc.private) && (
|
|
// the Authorization header field does not appear in the request, if the cache is shared,
|
|
!this._isShared || this._noAuthorization || this._allowsStoringAuthenticated()) && (
|
|
// the response either:
|
|
|
|
// contains an Expires header field, or
|
|
this._resHeaders.expires ||
|
|
// contains a max-age response directive, or
|
|
// contains a s-maxage response directive and the cache is shared, or
|
|
// contains a public response directive.
|
|
this._rescc.public || this._rescc['max-age'] || this._rescc['s-maxage'] ||
|
|
// has a status code that is defined as cacheable by default
|
|
statusCodeCacheableByDefault.indexOf(this._status) !== -1));
|
|
};
|
|
|
|
CachePolicy.prototype._hasExplicitExpiration = function _hasExplicitExpiration() {
|
|
// 4.2.1 Calculating Freshness Lifetime
|
|
return this._isShared && this._rescc['s-maxage'] || this._rescc['max-age'] || this._resHeaders.expires;
|
|
};
|
|
|
|
CachePolicy.prototype._assertRequestHasHeaders = function _assertRequestHasHeaders(req) {
|
|
if (!req || !req.headers) {
|
|
throw Error("Request headers missing");
|
|
}
|
|
};
|
|
|
|
CachePolicy.prototype.satisfiesWithoutRevalidation = function satisfiesWithoutRevalidation(req) {
|
|
this._assertRequestHasHeaders(req);
|
|
|
|
// When presented with a request, a cache MUST NOT reuse a stored response, unless:
|
|
// the presented request does not contain the no-cache pragma (Section 5.4), nor the no-cache cache directive,
|
|
// unless the stored response is successfully validated (Section 4.3), and
|
|
var requestCC = parseCacheControl(req.headers['cache-control']);
|
|
if (requestCC['no-cache'] || /no-cache/.test(req.headers.pragma)) {
|
|
return false;
|
|
}
|
|
|
|
if (requestCC['max-age'] && this.age() > requestCC['max-age']) {
|
|
return false;
|
|
}
|
|
|
|
if (requestCC['min-fresh'] && this.timeToLive() < 1000 * requestCC['min-fresh']) {
|
|
return false;
|
|
}
|
|
|
|
// the stored response is either:
|
|
// fresh, or allowed to be served stale
|
|
if (this.stale()) {
|
|
var allowsStale = requestCC['max-stale'] && !this._rescc['must-revalidate'] && (true === requestCC['max-stale'] || requestCC['max-stale'] > this.age() - this.maxAge());
|
|
if (!allowsStale) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return this._requestMatches(req, false);
|
|
};
|
|
|
|
CachePolicy.prototype._requestMatches = function _requestMatches(req, allowHeadMethod) {
|
|
// The presented effective request URI and that of the stored response match, and
|
|
return (!this._url || this._url === req.url) && this._host === req.headers.host && (
|
|
// the request method associated with the stored response allows it to be used for the presented request, and
|
|
!req.method || this._method === req.method || allowHeadMethod && 'HEAD' === req.method) &&
|
|
// selecting header fields nominated by the stored response (if any) match those presented, and
|
|
this._varyMatches(req);
|
|
};
|
|
|
|
CachePolicy.prototype._allowsStoringAuthenticated = function _allowsStoringAuthenticated() {
|
|
// following Cache-Control response directives (Section 5.2.2) have such an effect: must-revalidate, public, and s-maxage.
|
|
return this._rescc['must-revalidate'] || this._rescc.public || this._rescc['s-maxage'];
|
|
};
|
|
|
|
CachePolicy.prototype._varyMatches = function _varyMatches(req) {
|
|
if (!this._resHeaders.vary) {
|
|
return true;
|
|
}
|
|
|
|
// A Vary header field-value of "*" always fails to match
|
|
if (this._resHeaders.vary === '*') {
|
|
return false;
|
|
}
|
|
|
|
var fields = this._resHeaders.vary.trim().toLowerCase().split(/\s*,\s*/);
|
|
for (var _iterator2 = fields, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
|
|
var _ref3;
|
|
|
|
if (_isArray2) {
|
|
if (_i2 >= _iterator2.length) break;
|
|
_ref3 = _iterator2[_i2++];
|
|
} else {
|
|
_i2 = _iterator2.next();
|
|
if (_i2.done) break;
|
|
_ref3 = _i2.value;
|
|
}
|
|
|
|
var name = _ref3;
|
|
|
|
if (req.headers[name] !== this._reqHeaders[name]) return false;
|
|
}
|
|
return true;
|
|
};
|
|
|
|
CachePolicy.prototype._copyWithoutHopByHopHeaders = function _copyWithoutHopByHopHeaders(inHeaders) {
|
|
var headers = {};
|
|
for (var name in inHeaders) {
|
|
if (hopByHopHeaders[name]) continue;
|
|
headers[name] = inHeaders[name];
|
|
}
|
|
// 9.1. Connection
|
|
if (inHeaders.connection) {
|
|
var tokens = inHeaders.connection.trim().split(/\s*,\s*/);
|
|
for (var _iterator3 = tokens, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
|
|
var _ref4;
|
|
|
|
if (_isArray3) {
|
|
if (_i3 >= _iterator3.length) break;
|
|
_ref4 = _iterator3[_i3++];
|
|
} else {
|
|
_i3 = _iterator3.next();
|
|
if (_i3.done) break;
|
|
_ref4 = _i3.value;
|
|
}
|
|
|
|
var _name = _ref4;
|
|
|
|
delete headers[_name];
|
|
}
|
|
}
|
|
if (headers.warning) {
|
|
var warnings = headers.warning.split(/,/).filter(function (warning) {
|
|
return !/^\s*1[0-9][0-9]/.test(warning);
|
|
});
|
|
if (!warnings.length) {
|
|
delete headers.warning;
|
|
} else {
|
|
headers.warning = warnings.join(',').trim();
|
|
}
|
|
}
|
|
return headers;
|
|
};
|
|
|
|
CachePolicy.prototype.responseHeaders = function responseHeaders() {
|
|
var headers = this._copyWithoutHopByHopHeaders(this._resHeaders);
|
|
var age = this.age();
|
|
|
|
// A cache SHOULD generate 113 warning if it heuristically chose a freshness
|
|
// lifetime greater than 24 hours and the response's age is greater than 24 hours.
|
|
if (age > 3600 * 24 && !this._hasExplicitExpiration() && this.maxAge() > 3600 * 24) {
|
|
headers.warning = (headers.warning ? `${headers.warning}, ` : '') + '113 - "rfc7234 5.5.4"';
|
|
}
|
|
headers.age = `${Math.round(age)}`;
|
|
return headers;
|
|
};
|
|
|
|
/**
|
|
* Value of the Date response header or current time if Date was demed invalid
|
|
* @return timestamp
|
|
*/
|
|
|
|
|
|
CachePolicy.prototype.date = function date() {
|
|
var dateValue = Date.parse(this._resHeaders.date);
|
|
var maxClockDrift = 8 * 3600 * 1000;
|
|
if (Number.isNaN(dateValue) || dateValue < this._responseTime - maxClockDrift || dateValue > this._responseTime + maxClockDrift) {
|
|
return this._responseTime;
|
|
}
|
|
return dateValue;
|
|
};
|
|
|
|
/**
|
|
* Value of the Age header, in seconds, updated for the current time.
|
|
* May be fractional.
|
|
*
|
|
* @return Number
|
|
*/
|
|
|
|
|
|
CachePolicy.prototype.age = function age() {
|
|
var age = Math.max(0, (this._responseTime - this.date()) / 1000);
|
|
if (this._resHeaders.age) {
|
|
var ageValue = this._ageValue();
|
|
if (ageValue > age) age = ageValue;
|
|
}
|
|
|
|
var residentTime = (this.now() - this._responseTime) / 1000;
|
|
return age + residentTime;
|
|
};
|
|
|
|
CachePolicy.prototype._ageValue = function _ageValue() {
|
|
var ageValue = parseInt(this._resHeaders.age);
|
|
return isFinite(ageValue) ? ageValue : 0;
|
|
};
|
|
|
|
/**
|
|
* Value of applicable max-age (or heuristic equivalent) in seconds. This counts since response's `Date`.
|
|
*
|
|
* For an up-to-date value, see `timeToLive()`.
|
|
*
|
|
* @return Number
|
|
*/
|
|
|
|
|
|
CachePolicy.prototype.maxAge = function maxAge() {
|
|
if (!this.storable() || this._rescc['no-cache']) {
|
|
return 0;
|
|
}
|
|
|
|
// Shared responses with cookies are cacheable according to the RFC, but IMHO it'd be unwise to do so by default
|
|
// so this implementation requires explicit opt-in via public header
|
|
if (this._isShared && this._resHeaders['set-cookie'] && !this._rescc.public && !this._rescc.immutable) {
|
|
return 0;
|
|
}
|
|
|
|
if (this._resHeaders.vary === '*') {
|
|
return 0;
|
|
}
|
|
|
|
if (this._isShared) {
|
|
if (this._rescc['proxy-revalidate']) {
|
|
return 0;
|
|
}
|
|
// if a response includes the s-maxage directive, a shared cache recipient MUST ignore the Expires field.
|
|
if (this._rescc['s-maxage']) {
|
|
return parseInt(this._rescc['s-maxage'], 10);
|
|
}
|
|
}
|
|
|
|
// If a response includes a Cache-Control field with the max-age directive, a recipient MUST ignore the Expires field.
|
|
if (this._rescc['max-age']) {
|
|
return parseInt(this._rescc['max-age'], 10);
|
|
}
|
|
|
|
var defaultMinTtl = this._rescc.immutable ? this._immutableMinTtl : 0;
|
|
|
|
var dateValue = this.date();
|
|
if (this._resHeaders.expires) {
|
|
var expires = Date.parse(this._resHeaders.expires);
|
|
// A cache recipient MUST interpret invalid date formats, especially the value "0", as representing a time in the past (i.e., "already expired").
|
|
if (Number.isNaN(expires) || expires < dateValue) {
|
|
return 0;
|
|
}
|
|
return Math.max(defaultMinTtl, (expires - dateValue) / 1000);
|
|
}
|
|
|
|
if (this._resHeaders['last-modified']) {
|
|
var lastModified = Date.parse(this._resHeaders['last-modified']);
|
|
if (isFinite(lastModified) && dateValue > lastModified) {
|
|
return Math.max(defaultMinTtl, (dateValue - lastModified) / 1000 * this._cacheHeuristic);
|
|
}
|
|
}
|
|
|
|
return defaultMinTtl;
|
|
};
|
|
|
|
CachePolicy.prototype.timeToLive = function timeToLive() {
|
|
return Math.max(0, this.maxAge() - this.age()) * 1000;
|
|
};
|
|
|
|
CachePolicy.prototype.stale = function stale() {
|
|
return this.maxAge() <= this.age();
|
|
};
|
|
|
|
CachePolicy.fromObject = function fromObject(obj) {
|
|
return new this(undefined, undefined, { _fromObject: obj });
|
|
};
|
|
|
|
CachePolicy.prototype._fromObject = function _fromObject(obj) {
|
|
if (this._responseTime) throw Error("Reinitialized");
|
|
if (!obj || obj.v !== 1) throw Error("Invalid serialization");
|
|
|
|
this._responseTime = obj.t;
|
|
this._isShared = obj.sh;
|
|
this._cacheHeuristic = obj.ch;
|
|
this._immutableMinTtl = obj.imm !== undefined ? obj.imm : 24 * 3600 * 1000;
|
|
this._status = obj.st;
|
|
this._resHeaders = obj.resh;
|
|
this._rescc = obj.rescc;
|
|
this._method = obj.m;
|
|
this._url = obj.u;
|
|
this._host = obj.h;
|
|
this._noAuthorization = obj.a;
|
|
this._reqHeaders = obj.reqh;
|
|
this._reqcc = obj.reqcc;
|
|
};
|
|
|
|
CachePolicy.prototype.toObject = function toObject() {
|
|
return {
|
|
v: 1,
|
|
t: this._responseTime,
|
|
sh: this._isShared,
|
|
ch: this._cacheHeuristic,
|
|
imm: this._immutableMinTtl,
|
|
st: this._status,
|
|
resh: this._resHeaders,
|
|
rescc: this._rescc,
|
|
m: this._method,
|
|
u: this._url,
|
|
h: this._host,
|
|
a: this._noAuthorization,
|
|
reqh: this._reqHeaders,
|
|
reqcc: this._reqcc
|
|
};
|
|
};
|
|
|
|
/**
|
|
* Headers for sending to the origin server to revalidate stale response.
|
|
* Allows server to return 304 to allow reuse of the previous response.
|
|
*
|
|
* Hop by hop headers are always stripped.
|
|
* Revalidation headers may be added or removed, depending on request.
|
|
*/
|
|
|
|
|
|
CachePolicy.prototype.revalidationHeaders = function revalidationHeaders(incomingReq) {
|
|
this._assertRequestHasHeaders(incomingReq);
|
|
var headers = this._copyWithoutHopByHopHeaders(incomingReq.headers);
|
|
|
|
// This implementation does not understand range requests
|
|
delete headers['if-range'];
|
|
|
|
if (!this._requestMatches(incomingReq, true) || !this.storable()) {
|
|
// revalidation allowed via HEAD
|
|
// not for the same resource, or wasn't allowed to be cached anyway
|
|
delete headers['if-none-match'];
|
|
delete headers['if-modified-since'];
|
|
return headers;
|
|
}
|
|
|
|
/* MUST send that entity-tag in any cache validation request (using If-Match or If-None-Match) if an entity-tag has been provided by the origin server. */
|
|
if (this._resHeaders.etag) {
|
|
headers['if-none-match'] = headers['if-none-match'] ? `${headers['if-none-match']}, ${this._resHeaders.etag}` : this._resHeaders.etag;
|
|
}
|
|
|
|
// Clients MAY issue simple (non-subrange) GET requests with either weak validators or strong validators. Clients MUST NOT use weak validators in other forms of request.
|
|
var forbidsWeakValidators = headers['accept-ranges'] || headers['if-match'] || headers['if-unmodified-since'] || this._method && this._method != 'GET';
|
|
|
|
/* SHOULD send the Last-Modified value in non-subrange cache validation requests (using If-Modified-Since) if only a Last-Modified value has been provided by the origin server.
|
|
Note: This implementation does not understand partial responses (206) */
|
|
if (forbidsWeakValidators) {
|
|
delete headers['if-modified-since'];
|
|
|
|
if (headers['if-none-match']) {
|
|
var etags = headers['if-none-match'].split(/,/).filter(function (etag) {
|
|
return !/^\s*W\//.test(etag);
|
|
});
|
|
if (!etags.length) {
|
|
delete headers['if-none-match'];
|
|
} else {
|
|
headers['if-none-match'] = etags.join(',').trim();
|
|
}
|
|
}
|
|
} else if (this._resHeaders['last-modified'] && !headers['if-modified-since']) {
|
|
headers['if-modified-since'] = this._resHeaders['last-modified'];
|
|
}
|
|
|
|
return headers;
|
|
};
|
|
|
|
/**
|
|
* Creates new CachePolicy with information combined from the previews response,
|
|
* and the new revalidation response.
|
|
*
|
|
* Returns {policy, modified} where modified is a boolean indicating
|
|
* whether the response body has been modified, and old cached body can't be used.
|
|
*
|
|
* @return {Object} {policy: CachePolicy, modified: Boolean}
|
|
*/
|
|
|
|
|
|
CachePolicy.prototype.revalidatedPolicy = function revalidatedPolicy(request, response) {
|
|
this._assertRequestHasHeaders(request);
|
|
if (!response || !response.headers) {
|
|
throw Error("Response headers missing");
|
|
}
|
|
|
|
// These aren't going to be supported exactly, since one CachePolicy object
|
|
// doesn't know about all the other cached objects.
|
|
var matches = false;
|
|
if (response.status !== undefined && response.status != 304) {
|
|
matches = false;
|
|
} else if (response.headers.etag && !/^\s*W\//.test(response.headers.etag)) {
|
|
// "All of the stored responses with the same strong validator are selected.
|
|
// If none of the stored responses contain the same strong validator,
|
|
// then the cache MUST NOT use the new response to update any stored responses."
|
|
matches = this._resHeaders.etag && this._resHeaders.etag.replace(/^\s*W\//, '') === response.headers.etag;
|
|
} else if (this._resHeaders.etag && response.headers.etag) {
|
|
// "If the new response contains a weak validator and that validator corresponds
|
|
// to one of the cache's stored responses,
|
|
// then the most recent of those matching stored responses is selected for update."
|
|
matches = this._resHeaders.etag.replace(/^\s*W\//, '') === response.headers.etag.replace(/^\s*W\//, '');
|
|
} else if (this._resHeaders['last-modified']) {
|
|
matches = this._resHeaders['last-modified'] === response.headers['last-modified'];
|
|
} else {
|
|
// If the new response does not include any form of validator (such as in the case where
|
|
// a client generates an If-Modified-Since request from a source other than the Last-Modified
|
|
// response header field), and there is only one stored response, and that stored response also
|
|
// lacks a validator, then that stored response is selected for update.
|
|
if (!this._resHeaders.etag && !this._resHeaders['last-modified'] && !response.headers.etag && !response.headers['last-modified']) {
|
|
matches = true;
|
|
}
|
|
}
|
|
|
|
if (!matches) {
|
|
return {
|
|
policy: new this.constructor(request, response),
|
|
modified: true
|
|
};
|
|
}
|
|
|
|
// use other header fields provided in the 304 (Not Modified) response to replace all instances
|
|
// of the corresponding header fields in the stored response.
|
|
var headers = {};
|
|
for (var k in this._resHeaders) {
|
|
headers[k] = k in response.headers && !excludedFromRevalidationUpdate[k] ? response.headers[k] : this._resHeaders[k];
|
|
}
|
|
|
|
var newResponse = Object.assign({}, response, {
|
|
status: this._status,
|
|
method: this._method,
|
|
headers
|
|
});
|
|
return {
|
|
policy: new this.constructor(request, newResponse),
|
|
modified: false
|
|
};
|
|
};
|
|
|
|
return CachePolicy;
|
|
}();
|
|
|
|
/***/ }),
|
|
|
|
/***/ 49:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var wrappy = __webpack_require__(11)
|
|
module.exports = wrappy(once)
|
|
module.exports.strict = wrappy(onceStrict)
|
|
|
|
once.proto = once(function () {
|
|
Object.defineProperty(Function.prototype, 'once', {
|
|
value: function () {
|
|
return once(this)
|
|
},
|
|
configurable: true
|
|
})
|
|
|
|
Object.defineProperty(Function.prototype, 'onceStrict', {
|
|
value: function () {
|
|
return onceStrict(this)
|
|
},
|
|
configurable: true
|
|
})
|
|
})
|
|
|
|
function once (fn) {
|
|
var f = function () {
|
|
if (f.called) return f.value
|
|
f.called = true
|
|
return f.value = fn.apply(this, arguments)
|
|
}
|
|
f.called = false
|
|
return f
|
|
}
|
|
|
|
function onceStrict (fn) {
|
|
var f = function () {
|
|
if (f.called)
|
|
throw new Error(f.onceError)
|
|
f.called = true
|
|
return f.value = fn.apply(this, arguments)
|
|
}
|
|
var name = fn.name || 'Function wrapped with `once`'
|
|
f.onceError = name + " shouldn't be called more than once"
|
|
f.called = false
|
|
return f
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 53:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const url = __webpack_require__(835);
|
|
const punycode = __webpack_require__(213);
|
|
const queryString = __webpack_require__(183);
|
|
const prependHttp = __webpack_require__(128);
|
|
const sortKeys = __webpack_require__(741);
|
|
|
|
const DEFAULT_PORTS = {
|
|
'http:': 80,
|
|
'https:': 443,
|
|
'ftp:': 21
|
|
};
|
|
|
|
// Protocols that always contain a `//`` bit
|
|
const slashedProtocol = {
|
|
http: true,
|
|
https: true,
|
|
ftp: true,
|
|
gopher: true,
|
|
file: true,
|
|
'http:': true,
|
|
'https:': true,
|
|
'ftp:': true,
|
|
'gopher:': true,
|
|
'file:': true
|
|
};
|
|
|
|
function testParameter(name, filters) {
|
|
return filters.some(filter => filter instanceof RegExp ? filter.test(name) : filter === name);
|
|
}
|
|
|
|
module.exports = (str, opts) => {
|
|
opts = Object.assign({
|
|
normalizeProtocol: true,
|
|
normalizeHttps: false,
|
|
stripFragment: true,
|
|
stripWWW: true,
|
|
removeQueryParameters: [/^utm_\w+/i],
|
|
removeTrailingSlash: true,
|
|
removeDirectoryIndex: false,
|
|
sortQueryParameters: true
|
|
}, opts);
|
|
|
|
if (typeof str !== 'string') {
|
|
throw new TypeError('Expected a string');
|
|
}
|
|
|
|
const hasRelativeProtocol = str.startsWith('//');
|
|
|
|
// Prepend protocol
|
|
str = prependHttp(str.trim()).replace(/^\/\//, 'http://');
|
|
|
|
const urlObj = url.parse(str);
|
|
|
|
if (opts.normalizeHttps && urlObj.protocol === 'https:') {
|
|
urlObj.protocol = 'http:';
|
|
}
|
|
|
|
if (!urlObj.hostname && !urlObj.pathname) {
|
|
throw new Error('Invalid URL');
|
|
}
|
|
|
|
// Prevent these from being used by `url.format`
|
|
delete urlObj.host;
|
|
delete urlObj.query;
|
|
|
|
// Remove fragment
|
|
if (opts.stripFragment) {
|
|
delete urlObj.hash;
|
|
}
|
|
|
|
// Remove default port
|
|
const port = DEFAULT_PORTS[urlObj.protocol];
|
|
if (Number(urlObj.port) === port) {
|
|
delete urlObj.port;
|
|
}
|
|
|
|
// Remove duplicate slashes
|
|
if (urlObj.pathname) {
|
|
urlObj.pathname = urlObj.pathname.replace(/\/{2,}/g, '/');
|
|
}
|
|
|
|
// Decode URI octets
|
|
if (urlObj.pathname) {
|
|
urlObj.pathname = decodeURI(urlObj.pathname);
|
|
}
|
|
|
|
// Remove directory index
|
|
if (opts.removeDirectoryIndex === true) {
|
|
opts.removeDirectoryIndex = [/^index\.[a-z]+$/];
|
|
}
|
|
|
|
if (Array.isArray(opts.removeDirectoryIndex) && opts.removeDirectoryIndex.length > 0) {
|
|
let pathComponents = urlObj.pathname.split('/');
|
|
const lastComponent = pathComponents[pathComponents.length - 1];
|
|
|
|
if (testParameter(lastComponent, opts.removeDirectoryIndex)) {
|
|
pathComponents = pathComponents.slice(0, pathComponents.length - 1);
|
|
urlObj.pathname = pathComponents.slice(1).join('/') + '/';
|
|
}
|
|
}
|
|
|
|
// Resolve relative paths, but only for slashed protocols
|
|
if (slashedProtocol[urlObj.protocol]) {
|
|
const domain = urlObj.protocol + '//' + urlObj.hostname;
|
|
const relative = url.resolve(domain, urlObj.pathname);
|
|
urlObj.pathname = relative.replace(domain, '');
|
|
}
|
|
|
|
if (urlObj.hostname) {
|
|
// IDN to Unicode
|
|
urlObj.hostname = punycode.toUnicode(urlObj.hostname).toLowerCase();
|
|
|
|
// Remove trailing dot
|
|
urlObj.hostname = urlObj.hostname.replace(/\.$/, '');
|
|
|
|
// Remove `www.`
|
|
if (opts.stripWWW) {
|
|
urlObj.hostname = urlObj.hostname.replace(/^www\./, '');
|
|
}
|
|
}
|
|
|
|
// Remove URL with empty query string
|
|
if (urlObj.search === '?') {
|
|
delete urlObj.search;
|
|
}
|
|
|
|
const queryParameters = queryString.parse(urlObj.search);
|
|
|
|
// Remove query unwanted parameters
|
|
if (Array.isArray(opts.removeQueryParameters)) {
|
|
for (const key in queryParameters) {
|
|
if (testParameter(key, opts.removeQueryParameters)) {
|
|
delete queryParameters[key];
|
|
}
|
|
}
|
|
}
|
|
|
|
// Sort query parameters
|
|
if (opts.sortQueryParameters) {
|
|
urlObj.search = queryString.stringify(sortKeys(queryParameters));
|
|
}
|
|
|
|
// Decode query parameters
|
|
if (urlObj.search !== null) {
|
|
urlObj.search = decodeURIComponent(urlObj.search);
|
|
}
|
|
|
|
// Take advantage of many of the Node `url` normalizations
|
|
str = url.format(urlObj);
|
|
|
|
// Remove ending `/`
|
|
if (opts.removeTrailingSlash || urlObj.pathname === '/') {
|
|
str = str.replace(/\/$/, '');
|
|
}
|
|
|
|
// Restore relative protocol, if applicable
|
|
if (hasRelativeProtocol && !opts.normalizeProtocol) {
|
|
str = str.replace(/^http:\/\//, '//');
|
|
}
|
|
|
|
return str;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 65:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
var token = '%[a-f0-9]{2}';
|
|
var singleMatcher = new RegExp(token, 'gi');
|
|
var multiMatcher = new RegExp('(' + token + ')+', 'gi');
|
|
|
|
function decodeComponents(components, split) {
|
|
try {
|
|
// Try to decode the entire string first
|
|
return decodeURIComponent(components.join(''));
|
|
} catch (err) {
|
|
// Do nothing
|
|
}
|
|
|
|
if (components.length === 1) {
|
|
return components;
|
|
}
|
|
|
|
split = split || 1;
|
|
|
|
// Split the array in 2 parts
|
|
var left = components.slice(0, split);
|
|
var right = components.slice(split);
|
|
|
|
return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
|
|
}
|
|
|
|
function decode(input) {
|
|
try {
|
|
return decodeURIComponent(input);
|
|
} catch (err) {
|
|
var tokens = input.match(singleMatcher);
|
|
|
|
for (var i = 1; i < tokens.length; i++) {
|
|
input = decodeComponents(tokens, i).join('');
|
|
|
|
tokens = input.match(singleMatcher);
|
|
}
|
|
|
|
return input;
|
|
}
|
|
}
|
|
|
|
function customDecodeURIComponent(input) {
|
|
// Keep track of all the replacements and prefill the map with the `BOM`
|
|
var replaceMap = {
|
|
'%FE%FF': '\uFFFD\uFFFD',
|
|
'%FF%FE': '\uFFFD\uFFFD'
|
|
};
|
|
|
|
var match = multiMatcher.exec(input);
|
|
while (match) {
|
|
try {
|
|
// Decode as big chunks as possible
|
|
replaceMap[match[0]] = decodeURIComponent(match[0]);
|
|
} catch (err) {
|
|
var result = decode(match[0]);
|
|
|
|
if (result !== match[0]) {
|
|
replaceMap[match[0]] = result;
|
|
}
|
|
}
|
|
|
|
match = multiMatcher.exec(input);
|
|
}
|
|
|
|
// Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else
|
|
replaceMap['%C2'] = '\uFFFD';
|
|
|
|
var entries = Object.keys(replaceMap);
|
|
|
|
for (var i = 0; i < entries.length; i++) {
|
|
// Replace all decoded components
|
|
var key = entries[i];
|
|
input = input.replace(new RegExp(key, 'g'), replaceMap[key]);
|
|
}
|
|
|
|
return input;
|
|
}
|
|
|
|
module.exports = function (encodedURI) {
|
|
if (typeof encodedURI !== 'string') {
|
|
throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`');
|
|
}
|
|
|
|
try {
|
|
encodedURI = encodedURI.replace(/\+/g, ' ');
|
|
|
|
// Try the built in decoder first
|
|
return decodeURIComponent(encodedURI);
|
|
} catch (err) {
|
|
// Fallback to a more advanced decoder
|
|
return customDecodeURIComponent(encodedURI);
|
|
}
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 72:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const PassThrough = __webpack_require__(413).PassThrough;
|
|
|
|
module.exports = opts => {
|
|
opts = Object.assign({}, opts);
|
|
|
|
const array = opts.array;
|
|
let encoding = opts.encoding;
|
|
const buffer = encoding === 'buffer';
|
|
let objectMode = false;
|
|
|
|
if (array) {
|
|
objectMode = !(encoding || buffer);
|
|
} else {
|
|
encoding = encoding || 'utf8';
|
|
}
|
|
|
|
if (buffer) {
|
|
encoding = null;
|
|
}
|
|
|
|
let len = 0;
|
|
const ret = [];
|
|
const stream = new PassThrough({objectMode});
|
|
|
|
if (encoding) {
|
|
stream.setEncoding(encoding);
|
|
}
|
|
|
|
stream.on('data', chunk => {
|
|
ret.push(chunk);
|
|
|
|
if (objectMode) {
|
|
len = ret.length;
|
|
} else {
|
|
len += chunk.length;
|
|
}
|
|
});
|
|
|
|
stream.getBufferedValue = () => {
|
|
if (array) {
|
|
return ret;
|
|
}
|
|
|
|
return buffer ? Buffer.concat(ret, len) : ret.join('');
|
|
};
|
|
|
|
stream.getBufferedLength = () => len;
|
|
|
|
return stream;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 73:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var Promise = __webpack_require__(420);
|
|
var objectAssign = __webpack_require__(999);
|
|
var bufferStream = __webpack_require__(317);
|
|
|
|
function getStream(inputStream, opts) {
|
|
if (!inputStream) {
|
|
return Promise.reject(new Error('Expected a stream'));
|
|
}
|
|
|
|
opts = objectAssign({maxBuffer: Infinity}, opts);
|
|
var maxBuffer = opts.maxBuffer;
|
|
var stream;
|
|
var clean;
|
|
|
|
var p = new Promise(function (resolve, reject) {
|
|
stream = bufferStream(opts);
|
|
inputStream.once('error', error);
|
|
inputStream.pipe(stream);
|
|
|
|
stream.on('data', function () {
|
|
if (stream.getBufferedLength() > maxBuffer) {
|
|
reject(new Error('maxBuffer exceeded'));
|
|
}
|
|
});
|
|
stream.once('error', error);
|
|
stream.on('end', resolve);
|
|
|
|
clean = function () {
|
|
// some streams doesn't implement the stream.Readable interface correctly
|
|
if (inputStream.unpipe) {
|
|
inputStream.unpipe(stream);
|
|
}
|
|
};
|
|
|
|
function error(err) {
|
|
if (err) { // null check
|
|
err.bufferedData = stream.getBufferedValue();
|
|
}
|
|
reject(err);
|
|
}
|
|
});
|
|
|
|
p.then(clean, clean);
|
|
|
|
return p.then(function () {
|
|
return stream.getBufferedValue();
|
|
});
|
|
}
|
|
|
|
module.exports = getStream;
|
|
|
|
module.exports.buffer = function (stream, opts) {
|
|
return getStream(stream, objectAssign({}, opts, {encoding: 'buffer'}));
|
|
};
|
|
|
|
module.exports.array = function (stream, opts) {
|
|
return getStream(stream, objectAssign({}, opts, {array: true}));
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 79:
|
|
/***/ (function(module) {
|
|
|
|
/* very simple input/output stream interface */
|
|
var Stream = function() {
|
|
};
|
|
|
|
// input streams //////////////
|
|
/** Returns the next byte, or -1 for EOF. */
|
|
Stream.prototype.readByte = function() {
|
|
throw new Error("abstract method readByte() not implemented");
|
|
};
|
|
/** Attempts to fill the buffer; returns number of bytes read, or
|
|
* -1 for EOF. */
|
|
Stream.prototype.read = function(buffer, bufOffset, length) {
|
|
var bytesRead = 0;
|
|
while (bytesRead < length) {
|
|
var c = this.readByte();
|
|
if (c < 0) { // EOF
|
|
return (bytesRead===0) ? -1 : bytesRead;
|
|
}
|
|
buffer[bufOffset++] = c;
|
|
bytesRead++;
|
|
}
|
|
return bytesRead;
|
|
};
|
|
Stream.prototype.seek = function(new_pos) {
|
|
throw new Error("abstract method seek() not implemented");
|
|
};
|
|
|
|
// output streams ///////////
|
|
Stream.prototype.writeByte = function(_byte) {
|
|
throw new Error("abstract method readByte() not implemented");
|
|
};
|
|
Stream.prototype.write = function(buffer, bufOffset, length) {
|
|
var i;
|
|
for (i=0; i<length; i++) {
|
|
this.writeByte(buffer[bufOffset++]);
|
|
}
|
|
return length;
|
|
};
|
|
Stream.prototype.flush = function() {
|
|
};
|
|
|
|
module.exports = Stream;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 83:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const path = __webpack_require__(622);
|
|
const trimRepeated = __webpack_require__(567);
|
|
const filenameReservedRegex = __webpack_require__(634);
|
|
const stripOuter = __webpack_require__(448);
|
|
|
|
// Doesn't make sense to have longer filenames
|
|
const MAX_FILENAME_LENGTH = 100;
|
|
|
|
const reControlChars = /[\u0000-\u001f\u0080-\u009f]/g; // eslint-disable-line no-control-regex
|
|
const reRelativePath = /^\.+/;
|
|
|
|
const filenamify = (string, options = {}) => {
|
|
if (typeof string !== 'string') {
|
|
throw new TypeError('Expected a string');
|
|
}
|
|
|
|
const replacement = options.replacement === undefined ? '!' : options.replacement;
|
|
|
|
if (filenameReservedRegex().test(replacement) && reControlChars.test(replacement)) {
|
|
throw new Error('Replacement string cannot contain reserved filename characters');
|
|
}
|
|
|
|
string = string.replace(filenameReservedRegex(), replacement);
|
|
string = string.replace(reControlChars, replacement);
|
|
string = string.replace(reRelativePath, replacement);
|
|
|
|
if (replacement.length > 0) {
|
|
string = trimRepeated(string, replacement);
|
|
string = string.length > 1 ? stripOuter(string, replacement) : string;
|
|
}
|
|
|
|
string = filenameReservedRegex.windowsNames().test(string) ? string + replacement : string;
|
|
string = string.slice(0, MAX_FILENAME_LENGTH);
|
|
|
|
return string;
|
|
};
|
|
|
|
filenamify.path = (filePath, options) => {
|
|
filePath = path.resolve(filePath);
|
|
return path.join(path.dirname(filePath), filenamify(path.basename(filePath), options));
|
|
};
|
|
|
|
module.exports = filenamify;
|
|
module.exports.default = filenamify;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 87:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("os");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 89:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
// We define these manually to ensure they're always copied
|
|
// even if they would move up the prototype chain
|
|
// https://nodejs.org/api/http.html#http_class_http_incomingmessage
|
|
const knownProps = [
|
|
'destroy',
|
|
'setTimeout',
|
|
'socket',
|
|
'headers',
|
|
'trailers',
|
|
'rawHeaders',
|
|
'statusCode',
|
|
'httpVersion',
|
|
'httpVersionMinor',
|
|
'httpVersionMajor',
|
|
'rawTrailers',
|
|
'statusMessage'
|
|
];
|
|
|
|
module.exports = (fromStream, toStream) => {
|
|
const fromProps = new Set(Object.keys(fromStream).concat(knownProps));
|
|
|
|
for (const prop of fromProps) {
|
|
// Don't overwrite existing properties
|
|
if (prop in toStream) {
|
|
continue;
|
|
}
|
|
|
|
toStream[prop] = typeof fromStream[prop] === 'function' ? fromStream[prop].bind(fromStream) : fromStream[prop];
|
|
}
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 93:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var Stream = __webpack_require__(413).Stream
|
|
|
|
module.exports = legacy
|
|
|
|
function legacy (fs) {
|
|
return {
|
|
ReadStream: ReadStream,
|
|
WriteStream: WriteStream
|
|
}
|
|
|
|
function ReadStream (path, options) {
|
|
if (!(this instanceof ReadStream)) return new ReadStream(path, options);
|
|
|
|
Stream.call(this);
|
|
|
|
var self = this;
|
|
|
|
this.path = path;
|
|
this.fd = null;
|
|
this.readable = true;
|
|
this.paused = false;
|
|
|
|
this.flags = 'r';
|
|
this.mode = 438; /*=0666*/
|
|
this.bufferSize = 64 * 1024;
|
|
|
|
options = options || {};
|
|
|
|
// Mixin options into this
|
|
var keys = Object.keys(options);
|
|
for (var index = 0, length = keys.length; index < length; index++) {
|
|
var key = keys[index];
|
|
this[key] = options[key];
|
|
}
|
|
|
|
if (this.encoding) this.setEncoding(this.encoding);
|
|
|
|
if (this.start !== undefined) {
|
|
if ('number' !== typeof this.start) {
|
|
throw TypeError('start must be a Number');
|
|
}
|
|
if (this.end === undefined) {
|
|
this.end = Infinity;
|
|
} else if ('number' !== typeof this.end) {
|
|
throw TypeError('end must be a Number');
|
|
}
|
|
|
|
if (this.start > this.end) {
|
|
throw new Error('start must be <= end');
|
|
}
|
|
|
|
this.pos = this.start;
|
|
}
|
|
|
|
if (this.fd !== null) {
|
|
process.nextTick(function() {
|
|
self._read();
|
|
});
|
|
return;
|
|
}
|
|
|
|
fs.open(this.path, this.flags, this.mode, function (err, fd) {
|
|
if (err) {
|
|
self.emit('error', err);
|
|
self.readable = false;
|
|
return;
|
|
}
|
|
|
|
self.fd = fd;
|
|
self.emit('open', fd);
|
|
self._read();
|
|
})
|
|
}
|
|
|
|
function WriteStream (path, options) {
|
|
if (!(this instanceof WriteStream)) return new WriteStream(path, options);
|
|
|
|
Stream.call(this);
|
|
|
|
this.path = path;
|
|
this.fd = null;
|
|
this.writable = true;
|
|
|
|
this.flags = 'w';
|
|
this.encoding = 'binary';
|
|
this.mode = 438; /*=0666*/
|
|
this.bytesWritten = 0;
|
|
|
|
options = options || {};
|
|
|
|
// Mixin options into this
|
|
var keys = Object.keys(options);
|
|
for (var index = 0, length = keys.length; index < length; index++) {
|
|
var key = keys[index];
|
|
this[key] = options[key];
|
|
}
|
|
|
|
if (this.start !== undefined) {
|
|
if ('number' !== typeof this.start) {
|
|
throw TypeError('start must be a Number');
|
|
}
|
|
if (this.start < 0) {
|
|
throw new Error('start must be >= zero');
|
|
}
|
|
|
|
this.pos = this.start;
|
|
}
|
|
|
|
this.busy = false;
|
|
this._queue = [];
|
|
|
|
if (this.fd === null) {
|
|
this._open = fs.open;
|
|
this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
|
|
this.flush();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 97:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
module.exports = function (obj) {
|
|
var ret = {};
|
|
var keys = Object.keys(Object(obj));
|
|
|
|
for (var i = 0; i < keys.length; i++) {
|
|
ret[keys[i].toLowerCase()] = obj[keys[i]];
|
|
}
|
|
|
|
return ret;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 105:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const httpm = __webpack_require__(874);
|
|
const util = __webpack_require__(729);
|
|
class RestClient {
|
|
/**
|
|
* Creates an instance of the RestClient
|
|
* @constructor
|
|
* @param {string} userAgent - userAgent for requests
|
|
* @param {string} baseUrl - (Optional) If not specified, use full urls per request. If supplied and a function passes a relative url, it will be appended to this
|
|
* @param {ifm.IRequestHandler[]} handlers - handlers are typically auth handlers (basic, bearer, ntlm supplied)
|
|
* @param {ifm.IRequestOptions} requestOptions - options for each http requests (http proxy setting, socket timeout)
|
|
*/
|
|
constructor(userAgent, baseUrl, handlers, requestOptions) {
|
|
this.client = new httpm.HttpClient(userAgent, handlers, requestOptions);
|
|
if (baseUrl) {
|
|
this._baseUrl = baseUrl;
|
|
}
|
|
}
|
|
/**
|
|
* Gets a resource from an endpoint
|
|
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
* @param {string} requestUrl - fully qualified or relative url
|
|
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
*/
|
|
options(requestUrl, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
let url = util.getUrl(requestUrl, this._baseUrl);
|
|
let res = yield this.client.options(url, this._headersFromOptions(options));
|
|
return this.processResponse(res, options);
|
|
});
|
|
}
|
|
/**
|
|
* Gets a resource from an endpoint
|
|
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
* @param {string} resource - fully qualified url or relative path
|
|
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
*/
|
|
get(resource, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
let url = util.getUrl(resource, this._baseUrl, (options || {}).queryParameters);
|
|
let res = yield this.client.get(url, this._headersFromOptions(options));
|
|
return this.processResponse(res, options);
|
|
});
|
|
}
|
|
/**
|
|
* Deletes a resource from an endpoint
|
|
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
* @param {string} resource - fully qualified or relative url
|
|
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
*/
|
|
del(resource, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
let url = util.getUrl(resource, this._baseUrl);
|
|
let res = yield this.client.del(url, this._headersFromOptions(options));
|
|
return this.processResponse(res, options);
|
|
});
|
|
}
|
|
/**
|
|
* Creates resource(s) from an endpoint
|
|
* T type of object returned.
|
|
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
* @param {string} resource - fully qualified or relative url
|
|
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
*/
|
|
create(resource, resources, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
let url = util.getUrl(resource, this._baseUrl);
|
|
let headers = this._headersFromOptions(options, true);
|
|
let data = JSON.stringify(resources, null, 2);
|
|
let res = yield this.client.post(url, data, headers);
|
|
return this.processResponse(res, options);
|
|
});
|
|
}
|
|
/**
|
|
* Updates resource(s) from an endpoint
|
|
* T type of object returned.
|
|
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
* @param {string} resource - fully qualified or relative url
|
|
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
*/
|
|
update(resource, resources, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
let url = util.getUrl(resource, this._baseUrl);
|
|
let headers = this._headersFromOptions(options, true);
|
|
let data = JSON.stringify(resources, null, 2);
|
|
let res = yield this.client.patch(url, data, headers);
|
|
return this.processResponse(res, options);
|
|
});
|
|
}
|
|
/**
|
|
* Replaces resource(s) from an endpoint
|
|
* T type of object returned.
|
|
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
* @param {string} resource - fully qualified or relative url
|
|
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
*/
|
|
replace(resource, resources, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
let url = util.getUrl(resource, this._baseUrl);
|
|
let headers = this._headersFromOptions(options, true);
|
|
let data = JSON.stringify(resources, null, 2);
|
|
let res = yield this.client.put(url, data, headers);
|
|
return this.processResponse(res, options);
|
|
});
|
|
}
|
|
uploadStream(verb, requestUrl, stream, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
let url = util.getUrl(requestUrl, this._baseUrl);
|
|
let headers = this._headersFromOptions(options, true);
|
|
let res = yield this.client.sendStream(verb, url, stream, headers);
|
|
return this.processResponse(res, options);
|
|
});
|
|
}
|
|
_headersFromOptions(options, contentType) {
|
|
options = options || {};
|
|
let headers = options.additionalHeaders || {};
|
|
headers["Accept"] = options.acceptHeader || "application/json";
|
|
if (contentType) {
|
|
let found = false;
|
|
for (let header in headers) {
|
|
if (header.toLowerCase() == "content-type") {
|
|
found = true;
|
|
}
|
|
}
|
|
if (!found) {
|
|
headers["Content-Type"] = 'application/json; charset=utf-8';
|
|
}
|
|
}
|
|
return headers;
|
|
}
|
|
static dateTimeDeserializer(key, value) {
|
|
if (typeof value === 'string') {
|
|
let a = new Date(value);
|
|
if (!isNaN(a.valueOf())) {
|
|
return a;
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
processResponse(res, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
const statusCode = res.message.statusCode;
|
|
const response = {
|
|
statusCode: statusCode,
|
|
result: null,
|
|
headers: {}
|
|
};
|
|
// not found leads to null obj returned
|
|
if (statusCode == httpm.HttpCodes.NotFound) {
|
|
resolve(response);
|
|
}
|
|
let obj;
|
|
let contents;
|
|
// get the result from the body
|
|
try {
|
|
contents = yield res.readBody();
|
|
if (contents && contents.length > 0) {
|
|
if (options && options.deserializeDates) {
|
|
obj = JSON.parse(contents, RestClient.dateTimeDeserializer);
|
|
}
|
|
else {
|
|
obj = JSON.parse(contents);
|
|
}
|
|
if (options && options.responseProcessor) {
|
|
response.result = options.responseProcessor(obj);
|
|
}
|
|
else {
|
|
response.result = obj;
|
|
}
|
|
}
|
|
response.headers = res.message.headers;
|
|
}
|
|
catch (err) {
|
|
// Invalid resource (contents not json); leaving result obj null
|
|
}
|
|
// note that 3xx redirects are handled by the http layer.
|
|
if (statusCode > 299) {
|
|
let msg;
|
|
// if exception/error in body, attempt to get better error
|
|
if (obj && obj.message) {
|
|
msg = obj.message;
|
|
}
|
|
else if (contents && contents.length > 0) {
|
|
// it may be the case that the exception is in the body message as string
|
|
msg = contents;
|
|
}
|
|
else {
|
|
msg = "Failed request: (" + statusCode + ")";
|
|
}
|
|
let err = new Error(msg);
|
|
// attach statusCode and body obj (if available) to the error object
|
|
err['statusCode'] = statusCode;
|
|
if (response.result) {
|
|
err['result'] = response.result;
|
|
}
|
|
reject(err);
|
|
}
|
|
else {
|
|
resolve(response);
|
|
}
|
|
}));
|
|
});
|
|
}
|
|
}
|
|
exports.RestClient = RestClient;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 108:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
module.exports = function (req, time) {
|
|
if (req.timeoutTimer) {
|
|
return req;
|
|
}
|
|
|
|
var delays = isNaN(time) ? time : {socket: time, connect: time};
|
|
var host = req._headers ? (' to ' + req._headers.host) : '';
|
|
|
|
if (delays.connect !== undefined) {
|
|
req.timeoutTimer = setTimeout(function timeoutHandler() {
|
|
req.abort();
|
|
var e = new Error('Connection timed out on request' + host);
|
|
e.code = 'ETIMEDOUT';
|
|
req.emit('error', e);
|
|
}, delays.connect);
|
|
}
|
|
|
|
// Clear the connection timeout timer once a socket is assigned to the
|
|
// request and is connected.
|
|
req.on('socket', function assign(socket) {
|
|
// Socket may come from Agent pool and may be already connected.
|
|
if (!(socket.connecting || socket._connecting)) {
|
|
connect();
|
|
return;
|
|
}
|
|
|
|
socket.once('connect', connect);
|
|
});
|
|
|
|
function clear() {
|
|
if (req.timeoutTimer) {
|
|
clearTimeout(req.timeoutTimer);
|
|
req.timeoutTimer = null;
|
|
}
|
|
}
|
|
|
|
function connect() {
|
|
clear();
|
|
|
|
if (delays.socket !== undefined) {
|
|
// Abort the request if there is no activity on the socket for more
|
|
// than `delays.socket` milliseconds.
|
|
req.setTimeout(delays.socket, function socketTimeoutHandler() {
|
|
req.abort();
|
|
var e = new Error('Socket timed out on request' + host);
|
|
e.code = 'ESOCKETTIMEDOUT';
|
|
req.emit('error', e);
|
|
});
|
|
}
|
|
}
|
|
|
|
return req.on('error', clear);
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 128:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
module.exports = (url, opts) => {
|
|
if (typeof url !== 'string') {
|
|
throw new TypeError(`Expected \`url\` to be of type \`string\`, got \`${typeof url}\``);
|
|
}
|
|
|
|
url = url.trim();
|
|
opts = Object.assign({https: false}, opts);
|
|
|
|
if (/^\.*\/|^(?!localhost)\w+:/.test(url)) {
|
|
return url;
|
|
}
|
|
|
|
return url.replace(/^(?!(?:\w+:)?\/\/)/, opts.https ? 'https://' : 'http://');
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 129:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("child_process");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 138:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
|
|
|
|
module.exports = function (str) {
|
|
if (typeof str !== 'string') {
|
|
throw new TypeError('Expected a string');
|
|
}
|
|
|
|
return str.replace(matchOperatorsRe, '\\$&');
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 139:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
// Unique ID creation requires a high quality random # generator. In node.js
|
|
// this is pretty straight-forward - we use the crypto API.
|
|
|
|
var crypto = __webpack_require__(417);
|
|
|
|
module.exports = function nodeRNG() {
|
|
return crypto.randomBytes(16);
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 141:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
const Readable = __webpack_require__(413).Readable;
|
|
const lowercaseKeys = __webpack_require__(474);
|
|
|
|
class Response extends Readable {
|
|
constructor(statusCode, headers, body, url) {
|
|
if (typeof statusCode !== 'number') {
|
|
throw new TypeError('Argument `statusCode` should be a number');
|
|
}
|
|
if (typeof headers !== 'object') {
|
|
throw new TypeError('Argument `headers` should be an object');
|
|
}
|
|
if (!(body instanceof Buffer)) {
|
|
throw new TypeError('Argument `body` should be a buffer');
|
|
}
|
|
if (typeof url !== 'string') {
|
|
throw new TypeError('Argument `url` should be a string');
|
|
}
|
|
|
|
super();
|
|
this.statusCode = statusCode;
|
|
this.headers = lowercaseKeys(headers);
|
|
this.body = body;
|
|
this.url = url;
|
|
}
|
|
|
|
_read() {
|
|
this.push(this.body);
|
|
this.push(null);
|
|
}
|
|
}
|
|
|
|
module.exports = Response;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 145:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const pump = __webpack_require__(453);
|
|
const bufferStream = __webpack_require__(966);
|
|
|
|
class MaxBufferError extends Error {
|
|
constructor() {
|
|
super('maxBuffer exceeded');
|
|
this.name = 'MaxBufferError';
|
|
}
|
|
}
|
|
|
|
function getStream(inputStream, options) {
|
|
if (!inputStream) {
|
|
return Promise.reject(new Error('Expected a stream'));
|
|
}
|
|
|
|
options = Object.assign({maxBuffer: Infinity}, options);
|
|
|
|
const {maxBuffer} = options;
|
|
|
|
let stream;
|
|
return new Promise((resolve, reject) => {
|
|
const rejectPromise = error => {
|
|
if (error) { // A null check
|
|
error.bufferedData = stream.getBufferedValue();
|
|
}
|
|
reject(error);
|
|
};
|
|
|
|
stream = pump(inputStream, bufferStream(options), error => {
|
|
if (error) {
|
|
rejectPromise(error);
|
|
return;
|
|
}
|
|
|
|
resolve();
|
|
});
|
|
|
|
stream.on('data', () => {
|
|
if (stream.getBufferedLength() > maxBuffer) {
|
|
rejectPromise(new MaxBufferError());
|
|
}
|
|
});
|
|
}).then(() => stream.getBufferedValue());
|
|
}
|
|
|
|
module.exports = getStream;
|
|
module.exports.buffer = (stream, options) => getStream(stream, Object.assign({}, options, {encoding: 'buffer'}));
|
|
module.exports.array = (stream, options) => getStream(stream, Object.assign({}, options, {array: true}));
|
|
module.exports.MaxBufferError = MaxBufferError;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 147:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const urlLib = __webpack_require__(835);
|
|
const http = __webpack_require__(605);
|
|
const PCancelable = __webpack_require__(557);
|
|
const is = __webpack_require__(564);
|
|
|
|
class GotError extends Error {
|
|
constructor(message, error, opts) {
|
|
super(message);
|
|
Error.captureStackTrace(this, this.constructor);
|
|
this.name = 'GotError';
|
|
|
|
if (!is.undefined(error.code)) {
|
|
this.code = error.code;
|
|
}
|
|
|
|
Object.assign(this, {
|
|
host: opts.host,
|
|
hostname: opts.hostname,
|
|
method: opts.method,
|
|
path: opts.path,
|
|
protocol: opts.protocol,
|
|
url: opts.href
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports.GotError = GotError;
|
|
|
|
module.exports.CacheError = class extends GotError {
|
|
constructor(error, opts) {
|
|
super(error.message, error, opts);
|
|
this.name = 'CacheError';
|
|
}
|
|
};
|
|
|
|
module.exports.RequestError = class extends GotError {
|
|
constructor(error, opts) {
|
|
super(error.message, error, opts);
|
|
this.name = 'RequestError';
|
|
}
|
|
};
|
|
|
|
module.exports.ReadError = class extends GotError {
|
|
constructor(error, opts) {
|
|
super(error.message, error, opts);
|
|
this.name = 'ReadError';
|
|
}
|
|
};
|
|
|
|
module.exports.ParseError = class extends GotError {
|
|
constructor(error, statusCode, opts, data) {
|
|
super(`${error.message} in "${urlLib.format(opts)}": \n${data.slice(0, 77)}...`, error, opts);
|
|
this.name = 'ParseError';
|
|
this.statusCode = statusCode;
|
|
this.statusMessage = http.STATUS_CODES[this.statusCode];
|
|
}
|
|
};
|
|
|
|
module.exports.HTTPError = class extends GotError {
|
|
constructor(statusCode, statusMessage, headers, opts) {
|
|
if (statusMessage) {
|
|
statusMessage = statusMessage.replace(/\r?\n/g, ' ').trim();
|
|
} else {
|
|
statusMessage = http.STATUS_CODES[statusCode];
|
|
}
|
|
super(`Response code ${statusCode} (${statusMessage})`, {}, opts);
|
|
this.name = 'HTTPError';
|
|
this.statusCode = statusCode;
|
|
this.statusMessage = statusMessage;
|
|
this.headers = headers;
|
|
}
|
|
};
|
|
|
|
module.exports.MaxRedirectsError = class extends GotError {
|
|
constructor(statusCode, redirectUrls, opts) {
|
|
super('Redirected 10 times. Aborting.', {}, opts);
|
|
this.name = 'MaxRedirectsError';
|
|
this.statusCode = statusCode;
|
|
this.statusMessage = http.STATUS_CODES[this.statusCode];
|
|
this.redirectUrls = redirectUrls;
|
|
}
|
|
};
|
|
|
|
module.exports.UnsupportedProtocolError = class extends GotError {
|
|
constructor(opts) {
|
|
super(`Unsupported protocol "${opts.protocol}"`, {}, opts);
|
|
this.name = 'UnsupportedProtocolError';
|
|
}
|
|
};
|
|
|
|
module.exports.CancelError = PCancelable.CancelError;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 148:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const pTimeout = __webpack_require__(654);
|
|
|
|
const symbolAsyncIterator = Symbol.asyncIterator || '@@asyncIterator';
|
|
|
|
const normalizeEmitter = emitter => {
|
|
const addListener = emitter.on || emitter.addListener || emitter.addEventListener;
|
|
const removeListener = emitter.off || emitter.removeListener || emitter.removeEventListener;
|
|
|
|
if (!addListener || !removeListener) {
|
|
throw new TypeError('Emitter is not compatible');
|
|
}
|
|
|
|
return {
|
|
addListener: addListener.bind(emitter),
|
|
removeListener: removeListener.bind(emitter)
|
|
};
|
|
};
|
|
|
|
const normalizeEvents = event => Array.isArray(event) ? event : [event];
|
|
|
|
const multiple = (emitter, event, options) => {
|
|
let cancel;
|
|
const ret = new Promise((resolve, reject) => {
|
|
options = Object.assign({
|
|
rejectionEvents: ['error'],
|
|
multiArgs: false,
|
|
resolveImmediately: false
|
|
}, options);
|
|
|
|
if (!(options.count >= 0 && (options.count === Infinity || Number.isInteger(options.count)))) {
|
|
throw new TypeError('The `count` option should be at least 0 or more');
|
|
}
|
|
|
|
// Allow multiple events
|
|
const events = normalizeEvents(event);
|
|
|
|
const items = [];
|
|
const {addListener, removeListener} = normalizeEmitter(emitter);
|
|
|
|
const onItem = (...args) => {
|
|
const value = options.multiArgs ? args : args[0];
|
|
|
|
if (options.filter && !options.filter(value)) {
|
|
return;
|
|
}
|
|
|
|
items.push(value);
|
|
|
|
if (options.count === items.length) {
|
|
cancel();
|
|
resolve(items);
|
|
}
|
|
};
|
|
|
|
const rejectHandler = error => {
|
|
cancel();
|
|
reject(error);
|
|
};
|
|
|
|
cancel = () => {
|
|
for (const event of events) {
|
|
removeListener(event, onItem);
|
|
}
|
|
|
|
for (const rejectionEvent of options.rejectionEvents) {
|
|
removeListener(rejectionEvent, rejectHandler);
|
|
}
|
|
};
|
|
|
|
for (const event of events) {
|
|
addListener(event, onItem);
|
|
}
|
|
|
|
for (const rejectionEvent of options.rejectionEvents) {
|
|
addListener(rejectionEvent, rejectHandler);
|
|
}
|
|
|
|
if (options.resolveImmediately) {
|
|
resolve(items);
|
|
}
|
|
});
|
|
|
|
ret.cancel = cancel;
|
|
|
|
if (typeof options.timeout === 'number') {
|
|
const timeout = pTimeout(ret, options.timeout);
|
|
timeout.cancel = cancel;
|
|
return timeout;
|
|
}
|
|
|
|
return ret;
|
|
};
|
|
|
|
module.exports = (emitter, event, options) => {
|
|
if (typeof options === 'function') {
|
|
options = {filter: options};
|
|
}
|
|
|
|
options = Object.assign({}, options, {
|
|
count: 1,
|
|
resolveImmediately: false
|
|
});
|
|
|
|
const arrayPromise = multiple(emitter, event, options);
|
|
|
|
const promise = arrayPromise.then(array => array[0]);
|
|
promise.cancel = arrayPromise.cancel;
|
|
|
|
return promise;
|
|
};
|
|
|
|
module.exports.multiple = multiple;
|
|
|
|
module.exports.iterator = (emitter, event, options) => {
|
|
if (typeof options === 'function') {
|
|
options = {filter: options};
|
|
}
|
|
|
|
// Allow multiple events
|
|
const events = normalizeEvents(event);
|
|
|
|
options = Object.assign({
|
|
rejectionEvents: ['error'],
|
|
resolutionEvents: [],
|
|
limit: Infinity,
|
|
multiArgs: false
|
|
}, options);
|
|
|
|
const {limit} = options;
|
|
const isValidLimit = limit >= 0 && (limit === Infinity || Number.isInteger(limit));
|
|
if (!isValidLimit) {
|
|
throw new TypeError('The `limit` option should be a non-negative integer or Infinity');
|
|
}
|
|
|
|
if (limit === 0) {
|
|
// Return an empty async iterator to avoid any further cost
|
|
return {
|
|
[Symbol.asyncIterator]() {
|
|
return this;
|
|
},
|
|
next() {
|
|
return Promise.resolve({done: true, value: undefined});
|
|
}
|
|
};
|
|
}
|
|
|
|
let isLimitReached = false;
|
|
|
|
const {addListener, removeListener} = normalizeEmitter(emitter);
|
|
|
|
let done = false;
|
|
let error;
|
|
let hasPendingError = false;
|
|
const nextQueue = [];
|
|
const valueQueue = [];
|
|
let eventCount = 0;
|
|
|
|
const valueHandler = (...args) => {
|
|
eventCount++;
|
|
isLimitReached = eventCount === limit;
|
|
|
|
const value = options.multiArgs ? args : args[0];
|
|
|
|
if (nextQueue.length > 0) {
|
|
const {resolve} = nextQueue.shift();
|
|
|
|
resolve({done: false, value});
|
|
|
|
if (isLimitReached) {
|
|
cancel();
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
valueQueue.push(value);
|
|
|
|
if (isLimitReached) {
|
|
cancel();
|
|
}
|
|
};
|
|
|
|
const cancel = () => {
|
|
done = true;
|
|
for (const event of events) {
|
|
removeListener(event, valueHandler);
|
|
}
|
|
|
|
for (const rejectionEvent of options.rejectionEvents) {
|
|
removeListener(rejectionEvent, rejectHandler);
|
|
}
|
|
|
|
for (const resolutionEvent of options.resolutionEvents) {
|
|
removeListener(resolutionEvent, resolveHandler);
|
|
}
|
|
|
|
while (nextQueue.length > 0) {
|
|
const {resolve} = nextQueue.shift();
|
|
resolve({done: true, value: undefined});
|
|
}
|
|
};
|
|
|
|
const rejectHandler = (...args) => {
|
|
error = options.multiArgs ? args : args[0];
|
|
|
|
if (nextQueue.length > 0) {
|
|
const {reject} = nextQueue.shift();
|
|
reject(error);
|
|
} else {
|
|
hasPendingError = true;
|
|
}
|
|
|
|
cancel();
|
|
};
|
|
|
|
const resolveHandler = (...args) => {
|
|
const value = options.multiArgs ? args : args[0];
|
|
|
|
if (options.filter && !options.filter(value)) {
|
|
return;
|
|
}
|
|
|
|
if (nextQueue.length > 0) {
|
|
const {resolve} = nextQueue.shift();
|
|
resolve({done: true, value});
|
|
} else {
|
|
valueQueue.push(value);
|
|
}
|
|
|
|
cancel();
|
|
};
|
|
|
|
for (const event of events) {
|
|
addListener(event, valueHandler);
|
|
}
|
|
|
|
for (const rejectionEvent of options.rejectionEvents) {
|
|
addListener(rejectionEvent, rejectHandler);
|
|
}
|
|
|
|
for (const resolutionEvent of options.resolutionEvents) {
|
|
addListener(resolutionEvent, resolveHandler);
|
|
}
|
|
|
|
return {
|
|
[symbolAsyncIterator]() {
|
|
return this;
|
|
},
|
|
next() {
|
|
if (valueQueue.length > 0) {
|
|
const value = valueQueue.shift();
|
|
return Promise.resolve({done: done && valueQueue.length === 0 && !isLimitReached, value});
|
|
}
|
|
|
|
if (hasPendingError) {
|
|
hasPendingError = false;
|
|
return Promise.reject(error);
|
|
}
|
|
|
|
if (done) {
|
|
return Promise.resolve({done: true, value: undefined});
|
|
}
|
|
|
|
return new Promise((resolve, reject) => nextQueue.push({resolve, reject}));
|
|
},
|
|
return(value) {
|
|
cancel();
|
|
return Promise.resolve({done, value});
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 149:
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
/* eslint-disable node/no-deprecated-api */
|
|
var buffer = __webpack_require__(293)
|
|
var Buffer = buffer.Buffer
|
|
|
|
// alternative to using Object.keys for old browsers
|
|
function copyProps (src, dst) {
|
|
for (var key in src) {
|
|
dst[key] = src[key]
|
|
}
|
|
}
|
|
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
|
module.exports = buffer
|
|
} else {
|
|
// Copy properties from require('buffer')
|
|
copyProps(buffer, exports)
|
|
exports.Buffer = SafeBuffer
|
|
}
|
|
|
|
function SafeBuffer (arg, encodingOrOffset, length) {
|
|
return Buffer(arg, encodingOrOffset, length)
|
|
}
|
|
|
|
SafeBuffer.prototype = Object.create(Buffer.prototype)
|
|
|
|
// Copy static methods from Buffer
|
|
copyProps(Buffer, SafeBuffer)
|
|
|
|
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
|
if (typeof arg === 'number') {
|
|
throw new TypeError('Argument must not be a number')
|
|
}
|
|
return Buffer(arg, encodingOrOffset, length)
|
|
}
|
|
|
|
SafeBuffer.alloc = function (size, fill, encoding) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('Argument must be a number')
|
|
}
|
|
var buf = Buffer(size)
|
|
if (fill !== undefined) {
|
|
if (typeof encoding === 'string') {
|
|
buf.fill(fill, encoding)
|
|
} else {
|
|
buf.fill(fill)
|
|
}
|
|
} else {
|
|
buf.fill(0)
|
|
}
|
|
return buf
|
|
}
|
|
|
|
SafeBuffer.allocUnsafe = function (size) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('Argument must be a number')
|
|
}
|
|
return Buffer(size)
|
|
}
|
|
|
|
SafeBuffer.allocUnsafeSlow = function (size) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('Argument must be a number')
|
|
}
|
|
return buffer.SlowBuffer(size)
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 154:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
var toBuffer = __webpack_require__(376)
|
|
var alloc = __webpack_require__(345)
|
|
|
|
var ZEROS = '0000000000000000000'
|
|
var SEVENS = '7777777777777777777'
|
|
var ZERO_OFFSET = '0'.charCodeAt(0)
|
|
var USTAR = 'ustar\x0000'
|
|
var MASK = parseInt('7777', 8)
|
|
|
|
var clamp = function (index, len, defaultValue) {
|
|
if (typeof index !== 'number') return defaultValue
|
|
index = ~~index // Coerce to integer.
|
|
if (index >= len) return len
|
|
if (index >= 0) return index
|
|
index += len
|
|
if (index >= 0) return index
|
|
return 0
|
|
}
|
|
|
|
var toType = function (flag) {
|
|
switch (flag) {
|
|
case 0:
|
|
return 'file'
|
|
case 1:
|
|
return 'link'
|
|
case 2:
|
|
return 'symlink'
|
|
case 3:
|
|
return 'character-device'
|
|
case 4:
|
|
return 'block-device'
|
|
case 5:
|
|
return 'directory'
|
|
case 6:
|
|
return 'fifo'
|
|
case 7:
|
|
return 'contiguous-file'
|
|
case 72:
|
|
return 'pax-header'
|
|
case 55:
|
|
return 'pax-global-header'
|
|
case 27:
|
|
return 'gnu-long-link-path'
|
|
case 28:
|
|
case 30:
|
|
return 'gnu-long-path'
|
|
}
|
|
|
|
return null
|
|
}
|
|
|
|
var toTypeflag = function (flag) {
|
|
switch (flag) {
|
|
case 'file':
|
|
return 0
|
|
case 'link':
|
|
return 1
|
|
case 'symlink':
|
|
return 2
|
|
case 'character-device':
|
|
return 3
|
|
case 'block-device':
|
|
return 4
|
|
case 'directory':
|
|
return 5
|
|
case 'fifo':
|
|
return 6
|
|
case 'contiguous-file':
|
|
return 7
|
|
case 'pax-header':
|
|
return 72
|
|
}
|
|
|
|
return 0
|
|
}
|
|
|
|
var indexOf = function (block, num, offset, end) {
|
|
for (; offset < end; offset++) {
|
|
if (block[offset] === num) return offset
|
|
}
|
|
return end
|
|
}
|
|
|
|
var cksum = function (block) {
|
|
var sum = 8 * 32
|
|
for (var i = 0; i < 148; i++) sum += block[i]
|
|
for (var j = 156; j < 512; j++) sum += block[j]
|
|
return sum
|
|
}
|
|
|
|
var encodeOct = function (val, n) {
|
|
val = val.toString(8)
|
|
if (val.length > n) return SEVENS.slice(0, n) + ' '
|
|
else return ZEROS.slice(0, n - val.length) + val + ' '
|
|
}
|
|
|
|
/* Copied from the node-tar repo and modified to meet
|
|
* tar-stream coding standard.
|
|
*
|
|
* Source: https://github.com/npm/node-tar/blob/51b6627a1f357d2eb433e7378e5f05e83b7aa6cd/lib/header.js#L349
|
|
*/
|
|
function parse256 (buf) {
|
|
// first byte MUST be either 80 or FF
|
|
// 80 for positive, FF for 2's comp
|
|
var positive
|
|
if (buf[0] === 0x80) positive = true
|
|
else if (buf[0] === 0xFF) positive = false
|
|
else return null
|
|
|
|
// build up a base-256 tuple from the least sig to the highest
|
|
var zero = false
|
|
var tuple = []
|
|
for (var i = buf.length - 1; i > 0; i--) {
|
|
var byte = buf[i]
|
|
if (positive) tuple.push(byte)
|
|
else if (zero && byte === 0) tuple.push(0)
|
|
else if (zero) {
|
|
zero = false
|
|
tuple.push(0x100 - byte)
|
|
} else tuple.push(0xFF - byte)
|
|
}
|
|
|
|
var sum = 0
|
|
var l = tuple.length
|
|
for (i = 0; i < l; i++) {
|
|
sum += tuple[i] * Math.pow(256, i)
|
|
}
|
|
|
|
return positive ? sum : -1 * sum
|
|
}
|
|
|
|
var decodeOct = function (val, offset, length) {
|
|
val = val.slice(offset, offset + length)
|
|
offset = 0
|
|
|
|
// If prefixed with 0x80 then parse as a base-256 integer
|
|
if (val[offset] & 0x80) {
|
|
return parse256(val)
|
|
} else {
|
|
// Older versions of tar can prefix with spaces
|
|
while (offset < val.length && val[offset] === 32) offset++
|
|
var end = clamp(indexOf(val, 32, offset, val.length), val.length, val.length)
|
|
while (offset < end && val[offset] === 0) offset++
|
|
if (end === offset) return 0
|
|
return parseInt(val.slice(offset, end).toString(), 8)
|
|
}
|
|
}
|
|
|
|
var decodeStr = function (val, offset, length, encoding) {
|
|
return val.slice(offset, indexOf(val, 0, offset, offset + length)).toString(encoding)
|
|
}
|
|
|
|
var addLength = function (str) {
|
|
var len = Buffer.byteLength(str)
|
|
var digits = Math.floor(Math.log(len) / Math.log(10)) + 1
|
|
if (len + digits >= Math.pow(10, digits)) digits++
|
|
|
|
return (len + digits) + str
|
|
}
|
|
|
|
exports.decodeLongPath = function (buf, encoding) {
|
|
return decodeStr(buf, 0, buf.length, encoding)
|
|
}
|
|
|
|
exports.encodePax = function (opts) { // TODO: encode more stuff in pax
|
|
var result = ''
|
|
if (opts.name) result += addLength(' path=' + opts.name + '\n')
|
|
if (opts.linkname) result += addLength(' linkpath=' + opts.linkname + '\n')
|
|
var pax = opts.pax
|
|
if (pax) {
|
|
for (var key in pax) {
|
|
result += addLength(' ' + key + '=' + pax[key] + '\n')
|
|
}
|
|
}
|
|
return toBuffer(result)
|
|
}
|
|
|
|
exports.decodePax = function (buf) {
|
|
var result = {}
|
|
|
|
while (buf.length) {
|
|
var i = 0
|
|
while (i < buf.length && buf[i] !== 32) i++
|
|
var len = parseInt(buf.slice(0, i).toString(), 10)
|
|
if (!len) return result
|
|
|
|
var b = buf.slice(i + 1, len - 1).toString()
|
|
var keyIndex = b.indexOf('=')
|
|
if (keyIndex === -1) return result
|
|
result[b.slice(0, keyIndex)] = b.slice(keyIndex + 1)
|
|
|
|
buf = buf.slice(len)
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
exports.encode = function (opts) {
|
|
var buf = alloc(512)
|
|
var name = opts.name
|
|
var prefix = ''
|
|
|
|
if (opts.typeflag === 5 && name[name.length - 1] !== '/') name += '/'
|
|
if (Buffer.byteLength(name) !== name.length) return null // utf-8
|
|
|
|
while (Buffer.byteLength(name) > 100) {
|
|
var i = name.indexOf('/')
|
|
if (i === -1) return null
|
|
prefix += prefix ? '/' + name.slice(0, i) : name.slice(0, i)
|
|
name = name.slice(i + 1)
|
|
}
|
|
|
|
if (Buffer.byteLength(name) > 100 || Buffer.byteLength(prefix) > 155) return null
|
|
if (opts.linkname && Buffer.byteLength(opts.linkname) > 100) return null
|
|
|
|
buf.write(name)
|
|
buf.write(encodeOct(opts.mode & MASK, 6), 100)
|
|
buf.write(encodeOct(opts.uid, 6), 108)
|
|
buf.write(encodeOct(opts.gid, 6), 116)
|
|
buf.write(encodeOct(opts.size, 11), 124)
|
|
buf.write(encodeOct((opts.mtime.getTime() / 1000) | 0, 11), 136)
|
|
|
|
buf[156] = ZERO_OFFSET + toTypeflag(opts.type)
|
|
|
|
if (opts.linkname) buf.write(opts.linkname, 157)
|
|
|
|
buf.write(USTAR, 257)
|
|
if (opts.uname) buf.write(opts.uname, 265)
|
|
if (opts.gname) buf.write(opts.gname, 297)
|
|
buf.write(encodeOct(opts.devmajor || 0, 6), 329)
|
|
buf.write(encodeOct(opts.devminor || 0, 6), 337)
|
|
|
|
if (prefix) buf.write(prefix, 345)
|
|
|
|
buf.write(encodeOct(cksum(buf), 6), 148)
|
|
|
|
return buf
|
|
}
|
|
|
|
exports.decode = function (buf, filenameEncoding) {
|
|
var typeflag = buf[156] === 0 ? 0 : buf[156] - ZERO_OFFSET
|
|
|
|
var name = decodeStr(buf, 0, 100, filenameEncoding)
|
|
var mode = decodeOct(buf, 100, 8)
|
|
var uid = decodeOct(buf, 108, 8)
|
|
var gid = decodeOct(buf, 116, 8)
|
|
var size = decodeOct(buf, 124, 12)
|
|
var mtime = decodeOct(buf, 136, 12)
|
|
var type = toType(typeflag)
|
|
var linkname = buf[157] === 0 ? null : decodeStr(buf, 157, 100, filenameEncoding)
|
|
var uname = decodeStr(buf, 265, 32)
|
|
var gname = decodeStr(buf, 297, 32)
|
|
var devmajor = decodeOct(buf, 329, 8)
|
|
var devminor = decodeOct(buf, 337, 8)
|
|
|
|
if (buf[345]) name = decodeStr(buf, 345, 155, filenameEncoding) + '/' + name
|
|
|
|
// to support old tar versions that use trailing / to indicate dirs
|
|
if (typeflag === 0 && name && name[name.length - 1] === '/') typeflag = 5
|
|
|
|
var c = cksum(buf)
|
|
|
|
// checksum is still initial value if header was null.
|
|
if (c === 8 * 32) return null
|
|
|
|
// valid checksum
|
|
if (c !== decodeOct(buf, 148, 8)) throw new Error('Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?')
|
|
|
|
return {
|
|
name: name,
|
|
mode: mode,
|
|
uid: uid,
|
|
gid: gid,
|
|
size: size,
|
|
mtime: new Date(1000 * mtime),
|
|
type: type,
|
|
linkname: linkname,
|
|
uname: uname,
|
|
gname: gname,
|
|
devmajor: devmajor,
|
|
devminor: devminor
|
|
}
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 163:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
module.exports = function isObject(x) {
|
|
return typeof x === "object" && x !== null;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 173:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const url = __webpack_require__(835);
|
|
const prependHttp = __webpack_require__(128);
|
|
|
|
module.exports = (input, options) => {
|
|
if (typeof input !== 'string') {
|
|
throw new TypeError(`Expected \`url\` to be of type \`string\`, got \`${typeof input}\` instead.`);
|
|
}
|
|
|
|
const finalUrl = prependHttp(input, Object.assign({https: true}, options));
|
|
return url.parse(finalUrl);
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 183:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var strictUriEncode = __webpack_require__(881);
|
|
var objectAssign = __webpack_require__(999);
|
|
var decodeComponent = __webpack_require__(65);
|
|
|
|
function encoderForArrayFormat(opts) {
|
|
switch (opts.arrayFormat) {
|
|
case 'index':
|
|
return function (key, value, index) {
|
|
return value === null ? [
|
|
encode(key, opts),
|
|
'[',
|
|
index,
|
|
']'
|
|
].join('') : [
|
|
encode(key, opts),
|
|
'[',
|
|
encode(index, opts),
|
|
']=',
|
|
encode(value, opts)
|
|
].join('');
|
|
};
|
|
|
|
case 'bracket':
|
|
return function (key, value) {
|
|
return value === null ? encode(key, opts) : [
|
|
encode(key, opts),
|
|
'[]=',
|
|
encode(value, opts)
|
|
].join('');
|
|
};
|
|
|
|
default:
|
|
return function (key, value) {
|
|
return value === null ? encode(key, opts) : [
|
|
encode(key, opts),
|
|
'=',
|
|
encode(value, opts)
|
|
].join('');
|
|
};
|
|
}
|
|
}
|
|
|
|
function parserForArrayFormat(opts) {
|
|
var result;
|
|
|
|
switch (opts.arrayFormat) {
|
|
case 'index':
|
|
return function (key, value, accumulator) {
|
|
result = /\[(\d*)\]$/.exec(key);
|
|
|
|
key = key.replace(/\[\d*\]$/, '');
|
|
|
|
if (!result) {
|
|
accumulator[key] = value;
|
|
return;
|
|
}
|
|
|
|
if (accumulator[key] === undefined) {
|
|
accumulator[key] = {};
|
|
}
|
|
|
|
accumulator[key][result[1]] = value;
|
|
};
|
|
|
|
case 'bracket':
|
|
return function (key, value, accumulator) {
|
|
result = /(\[\])$/.exec(key);
|
|
key = key.replace(/\[\]$/, '');
|
|
|
|
if (!result) {
|
|
accumulator[key] = value;
|
|
return;
|
|
} else if (accumulator[key] === undefined) {
|
|
accumulator[key] = [value];
|
|
return;
|
|
}
|
|
|
|
accumulator[key] = [].concat(accumulator[key], value);
|
|
};
|
|
|
|
default:
|
|
return function (key, value, accumulator) {
|
|
if (accumulator[key] === undefined) {
|
|
accumulator[key] = value;
|
|
return;
|
|
}
|
|
|
|
accumulator[key] = [].concat(accumulator[key], value);
|
|
};
|
|
}
|
|
}
|
|
|
|
function encode(value, opts) {
|
|
if (opts.encode) {
|
|
return opts.strict ? strictUriEncode(value) : encodeURIComponent(value);
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
function keysSorter(input) {
|
|
if (Array.isArray(input)) {
|
|
return input.sort();
|
|
} else if (typeof input === 'object') {
|
|
return keysSorter(Object.keys(input)).sort(function (a, b) {
|
|
return Number(a) - Number(b);
|
|
}).map(function (key) {
|
|
return input[key];
|
|
});
|
|
}
|
|
|
|
return input;
|
|
}
|
|
|
|
function extract(str) {
|
|
var queryStart = str.indexOf('?');
|
|
if (queryStart === -1) {
|
|
return '';
|
|
}
|
|
return str.slice(queryStart + 1);
|
|
}
|
|
|
|
function parse(str, opts) {
|
|
opts = objectAssign({arrayFormat: 'none'}, opts);
|
|
|
|
var formatter = parserForArrayFormat(opts);
|
|
|
|
// Create an object with no prototype
|
|
// https://github.com/sindresorhus/query-string/issues/47
|
|
var ret = Object.create(null);
|
|
|
|
if (typeof str !== 'string') {
|
|
return ret;
|
|
}
|
|
|
|
str = str.trim().replace(/^[?#&]/, '');
|
|
|
|
if (!str) {
|
|
return ret;
|
|
}
|
|
|
|
str.split('&').forEach(function (param) {
|
|
var parts = param.replace(/\+/g, ' ').split('=');
|
|
// Firefox (pre 40) decodes `%3D` to `=`
|
|
// https://github.com/sindresorhus/query-string/pull/37
|
|
var key = parts.shift();
|
|
var val = parts.length > 0 ? parts.join('=') : undefined;
|
|
|
|
// missing `=` should be `null`:
|
|
// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
|
|
val = val === undefined ? null : decodeComponent(val);
|
|
|
|
formatter(decodeComponent(key), val, ret);
|
|
});
|
|
|
|
return Object.keys(ret).sort().reduce(function (result, key) {
|
|
var val = ret[key];
|
|
if (Boolean(val) && typeof val === 'object' && !Array.isArray(val)) {
|
|
// Sort object keys, not values
|
|
result[key] = keysSorter(val);
|
|
} else {
|
|
result[key] = val;
|
|
}
|
|
|
|
return result;
|
|
}, Object.create(null));
|
|
}
|
|
|
|
exports.extract = extract;
|
|
exports.parse = parse;
|
|
|
|
exports.stringify = function (obj, opts) {
|
|
var defaults = {
|
|
encode: true,
|
|
strict: true,
|
|
arrayFormat: 'none'
|
|
};
|
|
|
|
opts = objectAssign(defaults, opts);
|
|
|
|
if (opts.sort === false) {
|
|
opts.sort = function () {};
|
|
}
|
|
|
|
var formatter = encoderForArrayFormat(opts);
|
|
|
|
return obj ? Object.keys(obj).sort(opts.sort).map(function (key) {
|
|
var val = obj[key];
|
|
|
|
if (val === undefined) {
|
|
return '';
|
|
}
|
|
|
|
if (val === null) {
|
|
return encode(key, opts);
|
|
}
|
|
|
|
if (Array.isArray(val)) {
|
|
var result = [];
|
|
|
|
val.slice().forEach(function (val2) {
|
|
if (val2 === undefined) {
|
|
return;
|
|
}
|
|
|
|
result.push(formatter(key, val2, result.length));
|
|
});
|
|
|
|
return result.join('&');
|
|
}
|
|
|
|
return encode(key, opts) + '=' + encode(val, opts);
|
|
}).filter(function (x) {
|
|
return x.length > 0;
|
|
}).join('&') : '';
|
|
};
|
|
|
|
exports.parseUrl = function (str, opts) {
|
|
return {
|
|
url: str.split('?')[0] || '',
|
|
query: parse(extract(str), opts)
|
|
};
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 191:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("querystring");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 198:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
result["default"] = mod;
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const installer = __importStar(__webpack_require__(749));
|
|
const fs = __importStar(__webpack_require__(747));
|
|
const os = __importStar(__webpack_require__(87));
|
|
const core = __importStar(__webpack_require__(470));
|
|
const exec = __importStar(__webpack_require__(986));
|
|
function run(silent) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
try {
|
|
if (os.platform() == 'darwin') {
|
|
core.setFailed('Not supported on darwin platform');
|
|
return;
|
|
}
|
|
const version = core.getInput('version') || 'latest';
|
|
const file = core.getInput('file', { required: true });
|
|
const args = core.getInput('args');
|
|
const upx = yield installer.getUPX(version);
|
|
if (!fs.existsSync(file)) {
|
|
core.setFailed(`⛔ File to compress not found: ${file}`);
|
|
}
|
|
console.log('🏃 Running UPX...');
|
|
yield exec.exec(`${upx} ${args} ${file}`, undefined, {
|
|
silent: silent
|
|
});
|
|
}
|
|
catch (error) {
|
|
core.setFailed(error.message);
|
|
}
|
|
});
|
|
}
|
|
exports.run = run;
|
|
run();
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 203:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
/*!
|
|
* is-natural-number.js | MIT (c) Shinnosuke Watanabe
|
|
* https://github.com/shinnn/is-natural-number.js
|
|
*/
|
|
|
|
|
|
module.exports = function isNaturalNumber(val, option) {
|
|
if (option) {
|
|
if (typeof option !== 'object') {
|
|
throw new TypeError(
|
|
String(option) +
|
|
' is not an object. Expected an object that has boolean `includeZero` property.'
|
|
);
|
|
}
|
|
|
|
if ('includeZero' in option) {
|
|
if (typeof option.includeZero !== 'boolean') {
|
|
throw new TypeError(
|
|
String(option.includeZero) +
|
|
' is neither true nor false. `includeZero` option must be a Boolean value.'
|
|
);
|
|
}
|
|
|
|
if (option.includeZero && val === 0) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return Number.isSafeInteger(val) && val >= 1;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 205:
|
|
/***/ (function(__unusedmodule, exports) {
|
|
|
|
//TODO: handle reviver/dehydrate function like normal
|
|
//and handle indentation, like normal.
|
|
//if anyone needs this... please send pull request.
|
|
|
|
exports.stringify = function stringify (o) {
|
|
if('undefined' == typeof o) return o
|
|
|
|
if(o && Buffer.isBuffer(o))
|
|
return JSON.stringify(':base64:' + o.toString('base64'))
|
|
|
|
if(o && o.toJSON)
|
|
o = o.toJSON()
|
|
|
|
if(o && 'object' === typeof o) {
|
|
var s = ''
|
|
var array = Array.isArray(o)
|
|
s = array ? '[' : '{'
|
|
var first = true
|
|
|
|
for(var k in o) {
|
|
var ignore = 'function' == typeof o[k] || (!array && 'undefined' === typeof o[k])
|
|
if(Object.hasOwnProperty.call(o, k) && !ignore) {
|
|
if(!first)
|
|
s += ','
|
|
first = false
|
|
if (array) {
|
|
if(o[k] == undefined)
|
|
s += 'null'
|
|
else
|
|
s += stringify(o[k])
|
|
} else if (o[k] !== void(0)) {
|
|
s += stringify(k) + ':' + stringify(o[k])
|
|
}
|
|
}
|
|
}
|
|
|
|
s += array ? ']' : '}'
|
|
|
|
return s
|
|
} else if ('string' === typeof o) {
|
|
return JSON.stringify(/^:/.test(o) ? ':' + o : o)
|
|
} else if ('undefined' === typeof o) {
|
|
return 'null';
|
|
} else
|
|
return JSON.stringify(o)
|
|
}
|
|
|
|
exports.parse = function (s) {
|
|
return JSON.parse(s, function (key, value) {
|
|
if('string' === typeof value) {
|
|
if(/^:base64:/.test(value))
|
|
return new Buffer(value.substring(8), 'base64')
|
|
else
|
|
return /^:/.test(value) ? value.substring(1) : value
|
|
}
|
|
return value
|
|
})
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 210:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var sortKeys = __webpack_require__(338);
|
|
|
|
/**
|
|
* Sort object keys by length
|
|
*
|
|
* @param obj
|
|
* @api public
|
|
*/
|
|
|
|
module.exports.desc = function (obj) {
|
|
return sortKeys(obj, function (a, b) {
|
|
return b.length - a.length;
|
|
});
|
|
}
|
|
|
|
module.exports.asc = function (obj) {
|
|
return sortKeys(obj, function (a, b) {
|
|
return a.length - b.length;
|
|
});
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 211:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("https");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 213:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("punycode");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 223:
|
|
/***/ (function(module) {
|
|
|
|
/*
|
|
node-bzip - a pure-javascript Node.JS module for decoding bzip2 data
|
|
|
|
Copyright (C) 2012 Eli Skeggs
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with this library; if not, see
|
|
http://www.gnu.org/licenses/lgpl-2.1.html
|
|
|
|
Adapted from bzip2.js, copyright 2011 antimatter15 (antimatter15@gmail.com).
|
|
|
|
Based on micro-bunzip by Rob Landley (rob@landley.net).
|
|
|
|
Based on bzip2 decompression code by Julian R Seward (jseward@acm.org),
|
|
which also acknowledges contributions by Mike Burrows, David Wheeler,
|
|
Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten,
|
|
Robert Sedgewick, and Jon L. Bentley.
|
|
*/
|
|
|
|
var BITMASK = [0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF];
|
|
|
|
// offset in bytes
|
|
var BitReader = function(stream) {
|
|
this.stream = stream;
|
|
this.bitOffset = 0;
|
|
this.curByte = 0;
|
|
this.hasByte = false;
|
|
};
|
|
|
|
BitReader.prototype._ensureByte = function() {
|
|
if (!this.hasByte) {
|
|
this.curByte = this.stream.readByte();
|
|
this.hasByte = true;
|
|
}
|
|
};
|
|
|
|
// reads bits from the buffer
|
|
BitReader.prototype.read = function(bits) {
|
|
var result = 0;
|
|
while (bits > 0) {
|
|
this._ensureByte();
|
|
var remaining = 8 - this.bitOffset;
|
|
// if we're in a byte
|
|
if (bits >= remaining) {
|
|
result <<= remaining;
|
|
result |= BITMASK[remaining] & this.curByte;
|
|
this.hasByte = false;
|
|
this.bitOffset = 0;
|
|
bits -= remaining;
|
|
} else {
|
|
result <<= bits;
|
|
var shift = remaining - bits;
|
|
result |= (this.curByte & (BITMASK[bits] << shift)) >> shift;
|
|
this.bitOffset += bits;
|
|
bits = 0;
|
|
}
|
|
}
|
|
return result;
|
|
};
|
|
|
|
// seek to an arbitrary point in the buffer (expressed in bits)
|
|
BitReader.prototype.seek = function(pos) {
|
|
var n_bit = pos % 8;
|
|
var n_byte = (pos - n_bit) / 8;
|
|
this.bitOffset = n_bit;
|
|
this.stream.seek(n_byte);
|
|
this.hasByte = false;
|
|
};
|
|
|
|
// reads 6 bytes worth of data using the read method
|
|
BitReader.prototype.pi = function() {
|
|
var buf = new Buffer(6), i;
|
|
for (i = 0; i < buf.length; i++) {
|
|
buf[i] = this.read(8);
|
|
}
|
|
return buf.toString('hex');
|
|
};
|
|
|
|
module.exports = BitReader;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 226:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
// copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
// following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included
|
|
// in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
/*<replacement>*/
|
|
|
|
var pna = __webpack_require__(822);
|
|
/*</replacement>*/
|
|
|
|
module.exports = Readable;
|
|
|
|
/*<replacement>*/
|
|
var isArray = __webpack_require__(262);
|
|
/*</replacement>*/
|
|
|
|
/*<replacement>*/
|
|
var Duplex;
|
|
/*</replacement>*/
|
|
|
|
Readable.ReadableState = ReadableState;
|
|
|
|
/*<replacement>*/
|
|
var EE = __webpack_require__(614).EventEmitter;
|
|
|
|
var EElistenerCount = function (emitter, type) {
|
|
return emitter.listeners(type).length;
|
|
};
|
|
/*</replacement>*/
|
|
|
|
/*<replacement>*/
|
|
var Stream = __webpack_require__(427);
|
|
/*</replacement>*/
|
|
|
|
/*<replacement>*/
|
|
|
|
var Buffer = __webpack_require__(321).Buffer;
|
|
var OurUint8Array = global.Uint8Array || function () {};
|
|
function _uint8ArrayToBuffer(chunk) {
|
|
return Buffer.from(chunk);
|
|
}
|
|
function _isUint8Array(obj) {
|
|
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
}
|
|
|
|
/*</replacement>*/
|
|
|
|
/*<replacement>*/
|
|
var util = Object.create(__webpack_require__(286));
|
|
util.inherits = __webpack_require__(689);
|
|
/*</replacement>*/
|
|
|
|
/*<replacement>*/
|
|
var debugUtil = __webpack_require__(669);
|
|
var debug = void 0;
|
|
if (debugUtil && debugUtil.debuglog) {
|
|
debug = debugUtil.debuglog('stream');
|
|
} else {
|
|
debug = function () {};
|
|
}
|
|
/*</replacement>*/
|
|
|
|
var BufferList = __webpack_require__(931);
|
|
var destroyImpl = __webpack_require__(232);
|
|
var StringDecoder;
|
|
|
|
util.inherits(Readable, Stream);
|
|
|
|
var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
|
|
|
|
function prependListener(emitter, event, fn) {
|
|
// Sadly this is not cacheable as some libraries bundle their own
|
|
// event emitter implementation with them.
|
|
if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
|
|
|
|
// This is a hack to make sure that our error handler is attached before any
|
|
// userland ones. NEVER DO THIS. This is here only because this code needs
|
|
// to continue to work with older versions of Node.js that do not include
|
|
// the prependListener() method. The goal is to eventually remove this hack.
|
|
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
|
|
}
|
|
|
|
function ReadableState(options, stream) {
|
|
Duplex = Duplex || __webpack_require__(831);
|
|
|
|
options = options || {};
|
|
|
|
// Duplex streams are both readable and writable, but share
|
|
// the same options object.
|
|
// However, some cases require setting options to different
|
|
// values for the readable and the writable sides of the duplex stream.
|
|
// These options can be provided separately as readableXXX and writableXXX.
|
|
var isDuplex = stream instanceof Duplex;
|
|
|
|
// object stream flag. Used to make read(n) ignore n and to
|
|
// make all the buffer merging and length checks go away
|
|
this.objectMode = !!options.objectMode;
|
|
|
|
if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
|
|
|
|
// the point at which it stops calling _read() to fill the buffer
|
|
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
|
var hwm = options.highWaterMark;
|
|
var readableHwm = options.readableHighWaterMark;
|
|
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
|
|
|
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
|
|
|
|
// cast to ints.
|
|
this.highWaterMark = Math.floor(this.highWaterMark);
|
|
|
|
// A linked list is used to store data chunks instead of an array because the
|
|
// linked list can remove elements from the beginning faster than
|
|
// array.shift()
|
|
this.buffer = new BufferList();
|
|
this.length = 0;
|
|
this.pipes = null;
|
|
this.pipesCount = 0;
|
|
this.flowing = null;
|
|
this.ended = false;
|
|
this.endEmitted = false;
|
|
this.reading = false;
|
|
|
|
// a flag to be able to tell if the event 'readable'/'data' is emitted
|
|
// immediately, or on a later tick. We set this to true at first, because
|
|
// any actions that shouldn't happen until "later" should generally also
|
|
// not happen before the first read call.
|
|
this.sync = true;
|
|
|
|
// whenever we return null, then we set a flag to say
|
|
// that we're awaiting a 'readable' event emission.
|
|
this.needReadable = false;
|
|
this.emittedReadable = false;
|
|
this.readableListening = false;
|
|
this.resumeScheduled = false;
|
|
|
|
// has it been destroyed
|
|
this.destroyed = false;
|
|
|
|
// Crypto is kind of old and crusty. Historically, its default string
|
|
// encoding is 'binary' so we have to make this configurable.
|
|
// Everything else in the universe uses 'utf8', though.
|
|
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
|
|
// the number of writers that are awaiting a drain event in .pipe()s
|
|
this.awaitDrain = 0;
|
|
|
|
// if true, a maybeReadMore has been scheduled
|
|
this.readingMore = false;
|
|
|
|
this.decoder = null;
|
|
this.encoding = null;
|
|
if (options.encoding) {
|
|
if (!StringDecoder) StringDecoder = __webpack_require__(674).StringDecoder;
|
|
this.decoder = new StringDecoder(options.encoding);
|
|
this.encoding = options.encoding;
|
|
}
|
|
}
|
|
|
|
function Readable(options) {
|
|
Duplex = Duplex || __webpack_require__(831);
|
|
|
|
if (!(this instanceof Readable)) return new Readable(options);
|
|
|
|
this._readableState = new ReadableState(options, this);
|
|
|
|
// legacy
|
|
this.readable = true;
|
|
|
|
if (options) {
|
|
if (typeof options.read === 'function') this._read = options.read;
|
|
|
|
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
|
}
|
|
|
|
Stream.call(this);
|
|
}
|
|
|
|
Object.defineProperty(Readable.prototype, 'destroyed', {
|
|
get: function () {
|
|
if (this._readableState === undefined) {
|
|
return false;
|
|
}
|
|
return this._readableState.destroyed;
|
|
},
|
|
set: function (value) {
|
|
// we ignore the value if the stream
|
|
// has not been initialized yet
|
|
if (!this._readableState) {
|
|
return;
|
|
}
|
|
|
|
// backward compatibility, the user is explicitly
|
|
// managing destroyed
|
|
this._readableState.destroyed = value;
|
|
}
|
|
});
|
|
|
|
Readable.prototype.destroy = destroyImpl.destroy;
|
|
Readable.prototype._undestroy = destroyImpl.undestroy;
|
|
Readable.prototype._destroy = function (err, cb) {
|
|
this.push(null);
|
|
cb(err);
|
|
};
|
|
|
|
// Manually shove something into the read() buffer.
|
|
// This returns true if the highWaterMark has not been hit yet,
|
|
// similar to how Writable.write() returns true if you should
|
|
// write() some more.
|
|
Readable.prototype.push = function (chunk, encoding) {
|
|
var state = this._readableState;
|
|
var skipChunkCheck;
|
|
|
|
if (!state.objectMode) {
|
|
if (typeof chunk === 'string') {
|
|
encoding = encoding || state.defaultEncoding;
|
|
if (encoding !== state.encoding) {
|
|
chunk = Buffer.from(chunk, encoding);
|
|
encoding = '';
|
|
}
|
|
skipChunkCheck = true;
|
|
}
|
|
} else {
|
|
skipChunkCheck = true;
|
|
}
|
|
|
|
return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
|
|
};
|
|
|
|
// Unshift should *always* be something directly out of read()
|
|
Readable.prototype.unshift = function (chunk) {
|
|
return readableAddChunk(this, chunk, null, true, false);
|
|
};
|
|
|
|
function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
|
|
var state = stream._readableState;
|
|
if (chunk === null) {
|
|
state.reading = false;
|
|
onEofChunk(stream, state);
|
|
} else {
|
|
var er;
|
|
if (!skipChunkCheck) er = chunkInvalid(state, chunk);
|
|
if (er) {
|
|
stream.emit('error', er);
|
|
} else if (state.objectMode || chunk && chunk.length > 0) {
|
|
if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
|
|
chunk = _uint8ArrayToBuffer(chunk);
|
|
}
|
|
|
|
if (addToFront) {
|
|
if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
|
|
} else if (state.ended) {
|
|
stream.emit('error', new Error('stream.push() after EOF'));
|
|
} else {
|
|
state.reading = false;
|
|
if (state.decoder && !encoding) {
|
|
chunk = state.decoder.write(chunk);
|
|
if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
|
|
} else {
|
|
addChunk(stream, state, chunk, false);
|
|
}
|
|
}
|
|
} else if (!addToFront) {
|
|
state.reading = false;
|
|
}
|
|
}
|
|
|
|
return needMoreData(state);
|
|
}
|
|
|
|
function addChunk(stream, state, chunk, addToFront) {
|
|
if (state.flowing && state.length === 0 && !state.sync) {
|
|
stream.emit('data', chunk);
|
|
stream.read(0);
|
|
} else {
|
|
// update the buffer info.
|
|
state.length += state.objectMode ? 1 : chunk.length;
|
|
if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
|
|
|
|
if (state.needReadable) emitReadable(stream);
|
|
}
|
|
maybeReadMore(stream, state);
|
|
}
|
|
|
|
function chunkInvalid(state, chunk) {
|
|
var er;
|
|
if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
|
er = new TypeError('Invalid non-string/buffer chunk');
|
|
}
|
|
return er;
|
|
}
|
|
|
|
// if it's past the high water mark, we can push in some more.
|
|
// Also, if we have no data yet, we can stand some
|
|
// more bytes. This is to work around cases where hwm=0,
|
|
// such as the repl. Also, if the push() triggered a
|
|
// readable event, and the user called read(largeNumber) such that
|
|
// needReadable was set, then we ought to push more, so that another
|
|
// 'readable' event will be triggered.
|
|
function needMoreData(state) {
|
|
return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
|
|
}
|
|
|
|
Readable.prototype.isPaused = function () {
|
|
return this._readableState.flowing === false;
|
|
};
|
|
|
|
// backwards compatibility.
|
|
Readable.prototype.setEncoding = function (enc) {
|
|
if (!StringDecoder) StringDecoder = __webpack_require__(674).StringDecoder;
|
|
this._readableState.decoder = new StringDecoder(enc);
|
|
this._readableState.encoding = enc;
|
|
return this;
|
|
};
|
|
|
|
// Don't raise the hwm > 8MB
|
|
var MAX_HWM = 0x800000;
|
|
function computeNewHighWaterMark(n) {
|
|
if (n >= MAX_HWM) {
|
|
n = MAX_HWM;
|
|
} else {
|
|
// Get the next highest power of 2 to prevent increasing hwm excessively in
|
|
// tiny amounts
|
|
n--;
|
|
n |= n >>> 1;
|
|
n |= n >>> 2;
|
|
n |= n >>> 4;
|
|
n |= n >>> 8;
|
|
n |= n >>> 16;
|
|
n++;
|
|
}
|
|
return n;
|
|
}
|
|
|
|
// This function is designed to be inlinable, so please take care when making
|
|
// changes to the function body.
|
|
function howMuchToRead(n, state) {
|
|
if (n <= 0 || state.length === 0 && state.ended) return 0;
|
|
if (state.objectMode) return 1;
|
|
if (n !== n) {
|
|
// Only flow one buffer at a time
|
|
if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
|
|
}
|
|
// If we're asking for more than the current hwm, then raise the hwm.
|
|
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
|
|
if (n <= state.length) return n;
|
|
// Don't have enough
|
|
if (!state.ended) {
|
|
state.needReadable = true;
|
|
return 0;
|
|
}
|
|
return state.length;
|
|
}
|
|
|
|
// you can override either this method, or the async _read(n) below.
|
|
Readable.prototype.read = function (n) {
|
|
debug('read', n);
|
|
n = parseInt(n, 10);
|
|
var state = this._readableState;
|
|
var nOrig = n;
|
|
|
|
if (n !== 0) state.emittedReadable = false;
|
|
|
|
// if we're doing read(0) to trigger a readable event, but we
|
|
// already have a bunch of data in the buffer, then just trigger
|
|
// the 'readable' event and move on.
|
|
if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
|
|
debug('read: emitReadable', state.length, state.ended);
|
|
if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
|
|
return null;
|
|
}
|
|
|
|
n = howMuchToRead(n, state);
|
|
|
|
// if we've ended, and we're now clear, then finish it up.
|
|
if (n === 0 && state.ended) {
|
|
if (state.length === 0) endReadable(this);
|
|
return null;
|
|
}
|
|
|
|
// All the actual chunk generation logic needs to be
|
|
// *below* the call to _read. The reason is that in certain
|
|
// synthetic stream cases, such as passthrough streams, _read
|
|
// may be a completely synchronous operation which may change
|
|
// the state of the read buffer, providing enough data when
|
|
// before there was *not* enough.
|
|
//
|
|
// So, the steps are:
|
|
// 1. Figure out what the state of things will be after we do
|
|
// a read from the buffer.
|
|
//
|
|
// 2. If that resulting state will trigger a _read, then call _read.
|
|
// Note that this may be asynchronous, or synchronous. Yes, it is
|
|
// deeply ugly to write APIs this way, but that still doesn't mean
|
|
// that the Readable class should behave improperly, as streams are
|
|
// designed to be sync/async agnostic.
|
|
// Take note if the _read call is sync or async (ie, if the read call
|
|
// has returned yet), so that we know whether or not it's safe to emit
|
|
// 'readable' etc.
|
|
//
|
|
// 3. Actually pull the requested chunks out of the buffer and return.
|
|
|
|
// if we need a readable event, then we need to do some reading.
|
|
var doRead = state.needReadable;
|
|
debug('need readable', doRead);
|
|
|
|
// if we currently have less than the highWaterMark, then also read some
|
|
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
doRead = true;
|
|
debug('length less than watermark', doRead);
|
|
}
|
|
|
|
// however, if we've ended, then there's no point, and if we're already
|
|
// reading, then it's unnecessary.
|
|
if (state.ended || state.reading) {
|
|
doRead = false;
|
|
debug('reading or ended', doRead);
|
|
} else if (doRead) {
|
|
debug('do read');
|
|
state.reading = true;
|
|
state.sync = true;
|
|
// if the length is currently zero, then we *need* a readable event.
|
|
if (state.length === 0) state.needReadable = true;
|
|
// call internal read method
|
|
this._read(state.highWaterMark);
|
|
state.sync = false;
|
|
// If _read pushed data synchronously, then `reading` will be false,
|
|
// and we need to re-evaluate how much data we can return to the user.
|
|
if (!state.reading) n = howMuchToRead(nOrig, state);
|
|
}
|
|
|
|
var ret;
|
|
if (n > 0) ret = fromList(n, state);else ret = null;
|
|
|
|
if (ret === null) {
|
|
state.needReadable = true;
|
|
n = 0;
|
|
} else {
|
|
state.length -= n;
|
|
}
|
|
|
|
if (state.length === 0) {
|
|
// If we have nothing in the buffer, then we want to know
|
|
// as soon as we *do* get something into the buffer.
|
|
if (!state.ended) state.needReadable = true;
|
|
|
|
// If we tried to read() past the EOF, then emit end on the next tick.
|
|
if (nOrig !== n && state.ended) endReadable(this);
|
|
}
|
|
|
|
if (ret !== null) this.emit('data', ret);
|
|
|
|
return ret;
|
|
};
|
|
|
|
function onEofChunk(stream, state) {
|
|
if (state.ended) return;
|
|
if (state.decoder) {
|
|
var chunk = state.decoder.end();
|
|
if (chunk && chunk.length) {
|
|
state.buffer.push(chunk);
|
|
state.length += state.objectMode ? 1 : chunk.length;
|
|
}
|
|
}
|
|
state.ended = true;
|
|
|
|
// emit 'readable' now to make sure it gets picked up.
|
|
emitReadable(stream);
|
|
}
|
|
|
|
// Don't emit readable right away in sync mode, because this can trigger
|
|
// another read() call => stack overflow. This way, it might trigger
|
|
// a nextTick recursion warning, but that's not so bad.
|
|
function emitReadable(stream) {
|
|
var state = stream._readableState;
|
|
state.needReadable = false;
|
|
if (!state.emittedReadable) {
|
|
debug('emitReadable', state.flowing);
|
|
state.emittedReadable = true;
|
|
if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
|
|
}
|
|
}
|
|
|
|
function emitReadable_(stream) {
|
|
debug('emit readable');
|
|
stream.emit('readable');
|
|
flow(stream);
|
|
}
|
|
|
|
// at this point, the user has presumably seen the 'readable' event,
|
|
// and called read() to consume some data. that may have triggered
|
|
// in turn another _read(n) call, in which case reading = true if
|
|
// it's in progress.
|
|
// However, if we're not ended, or reading, and the length < hwm,
|
|
// then go ahead and try to read some more preemptively.
|
|
function maybeReadMore(stream, state) {
|
|
if (!state.readingMore) {
|
|
state.readingMore = true;
|
|
pna.nextTick(maybeReadMore_, stream, state);
|
|
}
|
|
}
|
|
|
|
function maybeReadMore_(stream, state) {
|
|
var len = state.length;
|
|
while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
|
|
debug('maybeReadMore read 0');
|
|
stream.read(0);
|
|
if (len === state.length)
|
|
// didn't get any data, stop spinning.
|
|
break;else len = state.length;
|
|
}
|
|
state.readingMore = false;
|
|
}
|
|
|
|
// abstract method. to be overridden in specific implementation classes.
|
|
// call cb(er, data) where data is <= n in length.
|
|
// for virtual (non-string, non-buffer) streams, "length" is somewhat
|
|
// arbitrary, and perhaps not very meaningful.
|
|
Readable.prototype._read = function (n) {
|
|
this.emit('error', new Error('_read() is not implemented'));
|
|
};
|
|
|
|
Readable.prototype.pipe = function (dest, pipeOpts) {
|
|
var src = this;
|
|
var state = this._readableState;
|
|
|
|
switch (state.pipesCount) {
|
|
case 0:
|
|
state.pipes = dest;
|
|
break;
|
|
case 1:
|
|
state.pipes = [state.pipes, dest];
|
|
break;
|
|
default:
|
|
state.pipes.push(dest);
|
|
break;
|
|
}
|
|
state.pipesCount += 1;
|
|
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
|
|
|
|
var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
|
|
|
|
var endFn = doEnd ? onend : unpipe;
|
|
if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
|
|
|
|
dest.on('unpipe', onunpipe);
|
|
function onunpipe(readable, unpipeInfo) {
|
|
debug('onunpipe');
|
|
if (readable === src) {
|
|
if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
|
|
unpipeInfo.hasUnpiped = true;
|
|
cleanup();
|
|
}
|
|
}
|
|
}
|
|
|
|
function onend() {
|
|
debug('onend');
|
|
dest.end();
|
|
}
|
|
|
|
// when the dest drains, it reduces the awaitDrain counter
|
|
// on the source. This would be more elegant with a .once()
|
|
// handler in flow(), but adding and removing repeatedly is
|
|
// too slow.
|
|
var ondrain = pipeOnDrain(src);
|
|
dest.on('drain', ondrain);
|
|
|
|
var cleanedUp = false;
|
|
function cleanup() {
|
|
debug('cleanup');
|
|
// cleanup event handlers once the pipe is broken
|
|
dest.removeListener('close', onclose);
|
|
dest.removeListener('finish', onfinish);
|
|
dest.removeListener('drain', ondrain);
|
|
dest.removeListener('error', onerror);
|
|
dest.removeListener('unpipe', onunpipe);
|
|
src.removeListener('end', onend);
|
|
src.removeListener('end', unpipe);
|
|
src.removeListener('data', ondata);
|
|
|
|
cleanedUp = true;
|
|
|
|
// if the reader is waiting for a drain event from this
|
|
// specific writer, then it would cause it to never start
|
|
// flowing again.
|
|
// So, if this is awaiting a drain, then we just call it now.
|
|
// If we don't know, then assume that we are waiting for one.
|
|
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
|
|
}
|
|
|
|
// If the user pushes more data while we're writing to dest then we'll end up
|
|
// in ondata again. However, we only want to increase awaitDrain once because
|
|
// dest will only emit one 'drain' event for the multiple writes.
|
|
// => Introduce a guard on increasing awaitDrain.
|
|
var increasedAwaitDrain = false;
|
|
src.on('data', ondata);
|
|
function ondata(chunk) {
|
|
debug('ondata');
|
|
increasedAwaitDrain = false;
|
|
var ret = dest.write(chunk);
|
|
if (false === ret && !increasedAwaitDrain) {
|
|
// If the user unpiped during `dest.write()`, it is possible
|
|
// to get stuck in a permanently paused state if that write
|
|
// also returned false.
|
|
// => Check whether `dest` is still a piping destination.
|
|
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
|
|
debug('false write response, pause', src._readableState.awaitDrain);
|
|
src._readableState.awaitDrain++;
|
|
increasedAwaitDrain = true;
|
|
}
|
|
src.pause();
|
|
}
|
|
}
|
|
|
|
// if the dest has an error, then stop piping into it.
|
|
// however, don't suppress the throwing behavior for this.
|
|
function onerror(er) {
|
|
debug('onerror', er);
|
|
unpipe();
|
|
dest.removeListener('error', onerror);
|
|
if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
|
|
}
|
|
|
|
// Make sure our error handler is attached before userland ones.
|
|
prependListener(dest, 'error', onerror);
|
|
|
|
// Both close and finish should trigger unpipe, but only once.
|
|
function onclose() {
|
|
dest.removeListener('finish', onfinish);
|
|
unpipe();
|
|
}
|
|
dest.once('close', onclose);
|
|
function onfinish() {
|
|
debug('onfinish');
|
|
dest.removeListener('close', onclose);
|
|
unpipe();
|
|
}
|
|
dest.once('finish', onfinish);
|
|
|
|
function unpipe() {
|
|
debug('unpipe');
|
|
src.unpipe(dest);
|
|
}
|
|
|
|
// tell the dest that it's being piped to
|
|
dest.emit('pipe', src);
|
|
|
|
// start the flow if it hasn't been started already.
|
|
if (!state.flowing) {
|
|
debug('pipe resume');
|
|
src.resume();
|
|
}
|
|
|
|
return dest;
|
|
};
|
|
|
|
function pipeOnDrain(src) {
|
|
return function () {
|
|
var state = src._readableState;
|
|
debug('pipeOnDrain', state.awaitDrain);
|
|
if (state.awaitDrain) state.awaitDrain--;
|
|
if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
|
|
state.flowing = true;
|
|
flow(src);
|
|
}
|
|
};
|
|
}
|
|
|
|
Readable.prototype.unpipe = function (dest) {
|
|
var state = this._readableState;
|
|
var unpipeInfo = { hasUnpiped: false };
|
|
|
|
// if we're not piping anywhere, then do nothing.
|
|
if (state.pipesCount === 0) return this;
|
|
|
|
// just one destination. most common case.
|
|
if (state.pipesCount === 1) {
|
|
// passed in one, but it's not the right one.
|
|
if (dest && dest !== state.pipes) return this;
|
|
|
|
if (!dest) dest = state.pipes;
|
|
|
|
// got a match.
|
|
state.pipes = null;
|
|
state.pipesCount = 0;
|
|
state.flowing = false;
|
|
if (dest) dest.emit('unpipe', this, unpipeInfo);
|
|
return this;
|
|
}
|
|
|
|
// slow case. multiple pipe destinations.
|
|
|
|
if (!dest) {
|
|
// remove all.
|
|
var dests = state.pipes;
|
|
var len = state.pipesCount;
|
|
state.pipes = null;
|
|
state.pipesCount = 0;
|
|
state.flowing = false;
|
|
|
|
for (var i = 0; i < len; i++) {
|
|
dests[i].emit('unpipe', this, unpipeInfo);
|
|
}return this;
|
|
}
|
|
|
|
// try to find the right one.
|
|
var index = indexOf(state.pipes, dest);
|
|
if (index === -1) return this;
|
|
|
|
state.pipes.splice(index, 1);
|
|
state.pipesCount -= 1;
|
|
if (state.pipesCount === 1) state.pipes = state.pipes[0];
|
|
|
|
dest.emit('unpipe', this, unpipeInfo);
|
|
|
|
return this;
|
|
};
|
|
|
|
// set up data events if they are asked for
|
|
// Ensure readable listeners eventually get something
|
|
Readable.prototype.on = function (ev, fn) {
|
|
var res = Stream.prototype.on.call(this, ev, fn);
|
|
|
|
if (ev === 'data') {
|
|
// Start flowing on next tick if stream isn't explicitly paused
|
|
if (this._readableState.flowing !== false) this.resume();
|
|
} else if (ev === 'readable') {
|
|
var state = this._readableState;
|
|
if (!state.endEmitted && !state.readableListening) {
|
|
state.readableListening = state.needReadable = true;
|
|
state.emittedReadable = false;
|
|
if (!state.reading) {
|
|
pna.nextTick(nReadingNextTick, this);
|
|
} else if (state.length) {
|
|
emitReadable(this);
|
|
}
|
|
}
|
|
}
|
|
|
|
return res;
|
|
};
|
|
Readable.prototype.addListener = Readable.prototype.on;
|
|
|
|
function nReadingNextTick(self) {
|
|
debug('readable nexttick read 0');
|
|
self.read(0);
|
|
}
|
|
|
|
// pause() and resume() are remnants of the legacy readable stream API
|
|
// If the user uses them, then switch into old mode.
|
|
Readable.prototype.resume = function () {
|
|
var state = this._readableState;
|
|
if (!state.flowing) {
|
|
debug('resume');
|
|
state.flowing = true;
|
|
resume(this, state);
|
|
}
|
|
return this;
|
|
};
|
|
|
|
function resume(stream, state) {
|
|
if (!state.resumeScheduled) {
|
|
state.resumeScheduled = true;
|
|
pna.nextTick(resume_, stream, state);
|
|
}
|
|
}
|
|
|
|
function resume_(stream, state) {
|
|
if (!state.reading) {
|
|
debug('resume read 0');
|
|
stream.read(0);
|
|
}
|
|
|
|
state.resumeScheduled = false;
|
|
state.awaitDrain = 0;
|
|
stream.emit('resume');
|
|
flow(stream);
|
|
if (state.flowing && !state.reading) stream.read(0);
|
|
}
|
|
|
|
Readable.prototype.pause = function () {
|
|
debug('call pause flowing=%j', this._readableState.flowing);
|
|
if (false !== this._readableState.flowing) {
|
|
debug('pause');
|
|
this._readableState.flowing = false;
|
|
this.emit('pause');
|
|
}
|
|
return this;
|
|
};
|
|
|
|
function flow(stream) {
|
|
var state = stream._readableState;
|
|
debug('flow', state.flowing);
|
|
while (state.flowing && stream.read() !== null) {}
|
|
}
|
|
|
|
// wrap an old-style stream as the async data source.
|
|
// This is *not* part of the readable stream interface.
|
|
// It is an ugly unfortunate mess of history.
|
|
Readable.prototype.wrap = function (stream) {
|
|
var _this = this;
|
|
|
|
var state = this._readableState;
|
|
var paused = false;
|
|
|
|
stream.on('end', function () {
|
|
debug('wrapped end');
|
|
if (state.decoder && !state.ended) {
|
|
var chunk = state.decoder.end();
|
|
if (chunk && chunk.length) _this.push(chunk);
|
|
}
|
|
|
|
_this.push(null);
|
|
});
|
|
|
|
stream.on('data', function (chunk) {
|
|
debug('wrapped data');
|
|
if (state.decoder) chunk = state.decoder.write(chunk);
|
|
|
|
// don't skip over falsy values in objectMode
|
|
if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
|
|
|
|
var ret = _this.push(chunk);
|
|
if (!ret) {
|
|
paused = true;
|
|
stream.pause();
|
|
}
|
|
});
|
|
|
|
// proxy all the other methods.
|
|
// important when wrapping filters and duplexes.
|
|
for (var i in stream) {
|
|
if (this[i] === undefined && typeof stream[i] === 'function') {
|
|
this[i] = function (method) {
|
|
return function () {
|
|
return stream[method].apply(stream, arguments);
|
|
};
|
|
}(i);
|
|
}
|
|
}
|
|
|
|
// proxy certain important events.
|
|
for (var n = 0; n < kProxyEvents.length; n++) {
|
|
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
|
|
}
|
|
|
|
// when we try to consume some more bytes, simply unpause the
|
|
// underlying stream.
|
|
this._read = function (n) {
|
|
debug('wrapped _read', n);
|
|
if (paused) {
|
|
paused = false;
|
|
stream.resume();
|
|
}
|
|
};
|
|
|
|
return this;
|
|
};
|
|
|
|
Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
|
|
// making it explicit this property is not enumerable
|
|
// because otherwise some prototype manipulation in
|
|
// userland will fail
|
|
enumerable: false,
|
|
get: function () {
|
|
return this._readableState.highWaterMark;
|
|
}
|
|
});
|
|
|
|
// exposed for testing purposes only.
|
|
Readable._fromList = fromList;
|
|
|
|
// Pluck off n bytes from an array of buffers.
|
|
// Length is the combined lengths of all the buffers in the list.
|
|
// This function is designed to be inlinable, so please take care when making
|
|
// changes to the function body.
|
|
function fromList(n, state) {
|
|
// nothing buffered
|
|
if (state.length === 0) return null;
|
|
|
|
var ret;
|
|
if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
|
|
// read it all, truncate the list
|
|
if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
|
|
state.buffer.clear();
|
|
} else {
|
|
// read part of list
|
|
ret = fromListPartial(n, state.buffer, state.decoder);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
// Extracts only enough buffered data to satisfy the amount requested.
|
|
// This function is designed to be inlinable, so please take care when making
|
|
// changes to the function body.
|
|
function fromListPartial(n, list, hasStrings) {
|
|
var ret;
|
|
if (n < list.head.data.length) {
|
|
// slice is the same for buffers and strings
|
|
ret = list.head.data.slice(0, n);
|
|
list.head.data = list.head.data.slice(n);
|
|
} else if (n === list.head.data.length) {
|
|
// first chunk is a perfect match
|
|
ret = list.shift();
|
|
} else {
|
|
// result spans more than one buffer
|
|
ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
// Copies a specified amount of characters from the list of buffered data
|
|
// chunks.
|
|
// This function is designed to be inlinable, so please take care when making
|
|
// changes to the function body.
|
|
function copyFromBufferString(n, list) {
|
|
var p = list.head;
|
|
var c = 1;
|
|
var ret = p.data;
|
|
n -= ret.length;
|
|
while (p = p.next) {
|
|
var str = p.data;
|
|
var nb = n > str.length ? str.length : n;
|
|
if (nb === str.length) ret += str;else ret += str.slice(0, n);
|
|
n -= nb;
|
|
if (n === 0) {
|
|
if (nb === str.length) {
|
|
++c;
|
|
if (p.next) list.head = p.next;else list.head = list.tail = null;
|
|
} else {
|
|
list.head = p;
|
|
p.data = str.slice(nb);
|
|
}
|
|
break;
|
|
}
|
|
++c;
|
|
}
|
|
list.length -= c;
|
|
return ret;
|
|
}
|
|
|
|
// Copies a specified amount of bytes from the list of buffered data chunks.
|
|
// This function is designed to be inlinable, so please take care when making
|
|
// changes to the function body.
|
|
function copyFromBuffer(n, list) {
|
|
var ret = Buffer.allocUnsafe(n);
|
|
var p = list.head;
|
|
var c = 1;
|
|
p.data.copy(ret);
|
|
n -= p.data.length;
|
|
while (p = p.next) {
|
|
var buf = p.data;
|
|
var nb = n > buf.length ? buf.length : n;
|
|
buf.copy(ret, ret.length - n, 0, nb);
|
|
n -= nb;
|
|
if (n === 0) {
|
|
if (nb === buf.length) {
|
|
++c;
|
|
if (p.next) list.head = p.next;else list.head = list.tail = null;
|
|
} else {
|
|
list.head = p;
|
|
p.data = buf.slice(nb);
|
|
}
|
|
break;
|
|
}
|
|
++c;
|
|
}
|
|
list.length -= c;
|
|
return ret;
|
|
}
|
|
|
|
function endReadable(stream) {
|
|
var state = stream._readableState;
|
|
|
|
// If we get here before consuming all the bytes, then that is a
|
|
// bug in node. Should never happen.
|
|
if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
|
|
|
|
if (!state.endEmitted) {
|
|
state.ended = true;
|
|
pna.nextTick(endReadableNT, state, stream);
|
|
}
|
|
}
|
|
|
|
function endReadableNT(state, stream) {
|
|
// Check that we didn't get one last unshift.
|
|
if (!state.endEmitted && state.length === 0) {
|
|
state.endEmitted = true;
|
|
stream.readable = false;
|
|
stream.emit('end');
|
|
}
|
|
}
|
|
|
|
function indexOf(xs, x) {
|
|
for (var i = 0, l = xs.length; i < l; i++) {
|
|
if (xs[i] === x) return i;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 231:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
/*!
|
|
* strip-dirs | MIT (c) Shinnosuke Watanabe
|
|
* https://github.com/shinnn/node-strip-dirs
|
|
*/
|
|
|
|
|
|
const path = __webpack_require__(622);
|
|
const util = __webpack_require__(669);
|
|
|
|
const isNaturalNumber = __webpack_require__(203);
|
|
|
|
module.exports = function stripDirs(pathStr, count, option) {
|
|
if (typeof pathStr !== 'string') {
|
|
throw new TypeError(
|
|
util.inspect(pathStr) +
|
|
' is not a string. First argument to strip-dirs must be a path string.'
|
|
);
|
|
}
|
|
|
|
if (path.posix.isAbsolute(pathStr) || path.win32.isAbsolute(pathStr)) {
|
|
throw new Error(`${pathStr} is an absolute path. strip-dirs requires a relative path.`);
|
|
}
|
|
|
|
if (!isNaturalNumber(count, {includeZero: true})) {
|
|
throw new Error(
|
|
'The Second argument of strip-dirs must be a natural number or 0, but received ' +
|
|
util.inspect(count) +
|
|
'.'
|
|
);
|
|
}
|
|
|
|
if (option) {
|
|
if (typeof option !== 'object') {
|
|
throw new TypeError(
|
|
util.inspect(option) +
|
|
' is not an object. Expected an object with a boolean `disallowOverflow` property.'
|
|
);
|
|
}
|
|
|
|
if (Array.isArray(option)) {
|
|
throw new TypeError(
|
|
util.inspect(option) +
|
|
' is an array. Expected an object with a boolean `disallowOverflow` property.'
|
|
);
|
|
}
|
|
|
|
if ('disallowOverflow' in option && typeof option.disallowOverflow !== 'boolean') {
|
|
throw new TypeError(
|
|
util.inspect(option.disallowOverflow) +
|
|
' is neither true nor false. `disallowOverflow` option must be a Boolean value.'
|
|
);
|
|
}
|
|
} else {
|
|
option = {disallowOverflow: false};
|
|
}
|
|
|
|
const pathComponents = path.normalize(pathStr).split(path.sep);
|
|
|
|
if (pathComponents.length > 1 && pathComponents[0] === '.') {
|
|
pathComponents.shift();
|
|
}
|
|
|
|
if (count > pathComponents.length - 1) {
|
|
if (option.disallowOverflow) {
|
|
throw new RangeError('Cannot strip more directories than there are.');
|
|
}
|
|
|
|
count = pathComponents.length - 1;
|
|
}
|
|
|
|
return path.join.apply(null, pathComponents.slice(count));
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 232:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
/*<replacement>*/
|
|
|
|
var pna = __webpack_require__(822);
|
|
/*</replacement>*/
|
|
|
|
// undocumented cb() API, needed for core, not for public API
|
|
function destroy(err, cb) {
|
|
var _this = this;
|
|
|
|
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
|
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
|
|
|
if (readableDestroyed || writableDestroyed) {
|
|
if (cb) {
|
|
cb(err);
|
|
} else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
|
|
pna.nextTick(emitErrorNT, this, err);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
// we set destroyed to true before firing error callbacks in order
|
|
// to make it re-entrance safe in case destroy() is called within callbacks
|
|
|
|
if (this._readableState) {
|
|
this._readableState.destroyed = true;
|
|
}
|
|
|
|
// if this is a duplex stream mark the writable part as destroyed as well
|
|
if (this._writableState) {
|
|
this._writableState.destroyed = true;
|
|
}
|
|
|
|
this._destroy(err || null, function (err) {
|
|
if (!cb && err) {
|
|
pna.nextTick(emitErrorNT, _this, err);
|
|
if (_this._writableState) {
|
|
_this._writableState.errorEmitted = true;
|
|
}
|
|
} else if (cb) {
|
|
cb(err);
|
|
}
|
|
});
|
|
|
|
return this;
|
|
}
|
|
|
|
function undestroy() {
|
|
if (this._readableState) {
|
|
this._readableState.destroyed = false;
|
|
this._readableState.reading = false;
|
|
this._readableState.ended = false;
|
|
this._readableState.endEmitted = false;
|
|
}
|
|
|
|
if (this._writableState) {
|
|
this._writableState.destroyed = false;
|
|
this._writableState.ended = false;
|
|
this._writableState.ending = false;
|
|
this._writableState.finished = false;
|
|
this._writableState.errorEmitted = false;
|
|
}
|
|
}
|
|
|
|
function emitErrorNT(self, err) {
|
|
self.emit('error', err);
|
|
}
|
|
|
|
module.exports = {
|
|
destroy: destroy,
|
|
undestroy: undestroy
|
|
};
|
|
|
|
/***/ }),
|
|
|
|
/***/ 233:
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
/* eslint-disable node/no-deprecated-api */
|
|
var buffer = __webpack_require__(293)
|
|
var Buffer = buffer.Buffer
|
|
|
|
// alternative to using Object.keys for old browsers
|
|
function copyProps (src, dst) {
|
|
for (var key in src) {
|
|
dst[key] = src[key]
|
|
}
|
|
}
|
|
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
|
module.exports = buffer
|
|
} else {
|
|
// Copy properties from require('buffer')
|
|
copyProps(buffer, exports)
|
|
exports.Buffer = SafeBuffer
|
|
}
|
|
|
|
function SafeBuffer (arg, encodingOrOffset, length) {
|
|
return Buffer(arg, encodingOrOffset, length)
|
|
}
|
|
|
|
// Copy static methods from Buffer
|
|
copyProps(Buffer, SafeBuffer)
|
|
|
|
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
|
if (typeof arg === 'number') {
|
|
throw new TypeError('Argument must not be a number')
|
|
}
|
|
return Buffer(arg, encodingOrOffset, length)
|
|
}
|
|
|
|
SafeBuffer.alloc = function (size, fill, encoding) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('Argument must be a number')
|
|
}
|
|
var buf = Buffer(size)
|
|
if (fill !== undefined) {
|
|
if (typeof encoding === 'string') {
|
|
buf.fill(fill, encoding)
|
|
} else {
|
|
buf.fill(fill)
|
|
}
|
|
} else {
|
|
buf.fill(0)
|
|
}
|
|
return buf
|
|
}
|
|
|
|
SafeBuffer.allocUnsafe = function (size) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('Argument must be a number')
|
|
}
|
|
return Buffer(size)
|
|
}
|
|
|
|
SafeBuffer.allocUnsafeSlow = function (size) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('Argument must be a number')
|
|
}
|
|
return buffer.SlowBuffer(size)
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 241:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
// copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
// following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included
|
|
// in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
// A bit simpler than readable streams.
|
|
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
|
|
// the drain event emission and buffering.
|
|
|
|
|
|
|
|
/*<replacement>*/
|
|
|
|
var pna = __webpack_require__(822);
|
|
/*</replacement>*/
|
|
|
|
module.exports = Writable;
|
|
|
|
/* <replacement> */
|
|
function WriteReq(chunk, encoding, cb) {
|
|
this.chunk = chunk;
|
|
this.encoding = encoding;
|
|
this.callback = cb;
|
|
this.next = null;
|
|
}
|
|
|
|
// It seems a linked list but it is not
|
|
// there will be only 2 of these for each stream
|
|
function CorkedRequest(state) {
|
|
var _this = this;
|
|
|
|
this.next = null;
|
|
this.entry = null;
|
|
this.finish = function () {
|
|
onCorkedFinish(_this, state);
|
|
};
|
|
}
|
|
/* </replacement> */
|
|
|
|
/*<replacement>*/
|
|
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
|
|
/*</replacement>*/
|
|
|
|
/*<replacement>*/
|
|
var Duplex;
|
|
/*</replacement>*/
|
|
|
|
Writable.WritableState = WritableState;
|
|
|
|
/*<replacement>*/
|
|
var util = Object.create(__webpack_require__(286));
|
|
util.inherits = __webpack_require__(689);
|
|
/*</replacement>*/
|
|
|
|
/*<replacement>*/
|
|
var internalUtil = {
|
|
deprecate: __webpack_require__(917)
|
|
};
|
|
/*</replacement>*/
|
|
|
|
/*<replacement>*/
|
|
var Stream = __webpack_require__(427);
|
|
/*</replacement>*/
|
|
|
|
/*<replacement>*/
|
|
|
|
var Buffer = __webpack_require__(321).Buffer;
|
|
var OurUint8Array = global.Uint8Array || function () {};
|
|
function _uint8ArrayToBuffer(chunk) {
|
|
return Buffer.from(chunk);
|
|
}
|
|
function _isUint8Array(obj) {
|
|
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
|
}
|
|
|
|
/*</replacement>*/
|
|
|
|
var destroyImpl = __webpack_require__(232);
|
|
|
|
util.inherits(Writable, Stream);
|
|
|
|
function nop() {}
|
|
|
|
function WritableState(options, stream) {
|
|
Duplex = Duplex || __webpack_require__(831);
|
|
|
|
options = options || {};
|
|
|
|
// Duplex streams are both readable and writable, but share
|
|
// the same options object.
|
|
// However, some cases require setting options to different
|
|
// values for the readable and the writable sides of the duplex stream.
|
|
// These options can be provided separately as readableXXX and writableXXX.
|
|
var isDuplex = stream instanceof Duplex;
|
|
|
|
// object stream flag to indicate whether or not this stream
|
|
// contains buffers or objects.
|
|
this.objectMode = !!options.objectMode;
|
|
|
|
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
|
|
|
// the point at which write() starts returning false
|
|
// Note: 0 is a valid value, means that we always return false if
|
|
// the entire buffer is not flushed immediately on write()
|
|
var hwm = options.highWaterMark;
|
|
var writableHwm = options.writableHighWaterMark;
|
|
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
|
|
|
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
|
|
|
|
// cast to ints.
|
|
this.highWaterMark = Math.floor(this.highWaterMark);
|
|
|
|
// if _final has been called
|
|
this.finalCalled = false;
|
|
|
|
// drain event flag.
|
|
this.needDrain = false;
|
|
// at the start of calling end()
|
|
this.ending = false;
|
|
// when end() has been called, and returned
|
|
this.ended = false;
|
|
// when 'finish' is emitted
|
|
this.finished = false;
|
|
|
|
// has it been destroyed
|
|
this.destroyed = false;
|
|
|
|
// should we decode strings into buffers before passing to _write?
|
|
// this is here so that some node-core streams can optimize string
|
|
// handling at a lower level.
|
|
var noDecode = options.decodeStrings === false;
|
|
this.decodeStrings = !noDecode;
|
|
|
|
// Crypto is kind of old and crusty. Historically, its default string
|
|
// encoding is 'binary' so we have to make this configurable.
|
|
// Everything else in the universe uses 'utf8', though.
|
|
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
|
|
// not an actual buffer we keep track of, but a measurement
|
|
// of how much we're waiting to get pushed to some underlying
|
|
// socket or file.
|
|
this.length = 0;
|
|
|
|
// a flag to see when we're in the middle of a write.
|
|
this.writing = false;
|
|
|
|
// when true all writes will be buffered until .uncork() call
|
|
this.corked = 0;
|
|
|
|
// a flag to be able to tell if the onwrite cb is called immediately,
|
|
// or on a later tick. We set this to true at first, because any
|
|
// actions that shouldn't happen until "later" should generally also
|
|
// not happen before the first write call.
|
|
this.sync = true;
|
|
|
|
// a flag to know if we're processing previously buffered items, which
|
|
// may call the _write() callback in the same tick, so that we don't
|
|
// end up in an overlapped onwrite situation.
|
|
this.bufferProcessing = false;
|
|
|
|
// the callback that's passed to _write(chunk,cb)
|
|
this.onwrite = function (er) {
|
|
onwrite(stream, er);
|
|
};
|
|
|
|
// the callback that the user supplies to write(chunk,encoding,cb)
|
|
this.writecb = null;
|
|
|
|
// the amount that is being written when _write is called.
|
|
this.writelen = 0;
|
|
|
|
this.bufferedRequest = null;
|
|
this.lastBufferedRequest = null;
|
|
|
|
// number of pending user-supplied write callbacks
|
|
// this must be 0 before 'finish' can be emitted
|
|
this.pendingcb = 0;
|
|
|
|
// emit prefinish if the only thing we're waiting for is _write cbs
|
|
// This is relevant for synchronous Transform streams
|
|
this.prefinished = false;
|
|
|
|
// True if the error was already emitted and should not be thrown again
|
|
this.errorEmitted = false;
|
|
|
|
// count buffered requests
|
|
this.bufferedRequestCount = 0;
|
|
|
|
// allocate the first CorkedRequest, there is always
|
|
// one allocated and free to use, and we maintain at most two
|
|
this.corkedRequestsFree = new CorkedRequest(this);
|
|
}
|
|
|
|
WritableState.prototype.getBuffer = function getBuffer() {
|
|
var current = this.bufferedRequest;
|
|
var out = [];
|
|
while (current) {
|
|
out.push(current);
|
|
current = current.next;
|
|
}
|
|
return out;
|
|
};
|
|
|
|
(function () {
|
|
try {
|
|
Object.defineProperty(WritableState.prototype, 'buffer', {
|
|
get: internalUtil.deprecate(function () {
|
|
return this.getBuffer();
|
|
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
|
|
});
|
|
} catch (_) {}
|
|
})();
|
|
|
|
// Test _writableState for inheritance to account for Duplex streams,
|
|
// whose prototype chain only points to Readable.
|
|
var realHasInstance;
|
|
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
|
|
realHasInstance = Function.prototype[Symbol.hasInstance];
|
|
Object.defineProperty(Writable, Symbol.hasInstance, {
|
|
value: function (object) {
|
|
if (realHasInstance.call(this, object)) return true;
|
|
if (this !== Writable) return false;
|
|
|
|
return object && object._writableState instanceof WritableState;
|
|
}
|
|
});
|
|
} else {
|
|
realHasInstance = function (object) {
|
|
return object instanceof this;
|
|
};
|
|
}
|
|
|
|
function Writable(options) {
|
|
Duplex = Duplex || __webpack_require__(831);
|
|
|
|
// Writable ctor is applied to Duplexes, too.
|
|
// `realHasInstance` is necessary because using plain `instanceof`
|
|
// would return false, as no `_writableState` property is attached.
|
|
|
|
// Trying to use the custom `instanceof` for Writable here will also break the
|
|
// Node.js LazyTransform implementation, which has a non-trivial getter for
|
|
// `_writableState` that would lead to infinite recursion.
|
|
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
|
|
return new Writable(options);
|
|
}
|
|
|
|
this._writableState = new WritableState(options, this);
|
|
|
|
// legacy.
|
|
this.writable = true;
|
|
|
|
if (options) {
|
|
if (typeof options.write === 'function') this._write = options.write;
|
|
|
|
if (typeof options.writev === 'function') this._writev = options.writev;
|
|
|
|
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
|
|
|
if (typeof options.final === 'function') this._final = options.final;
|
|
}
|
|
|
|
Stream.call(this);
|
|
}
|
|
|
|
// Otherwise people can pipe Writable streams, which is just wrong.
|
|
Writable.prototype.pipe = function () {
|
|
this.emit('error', new Error('Cannot pipe, not readable'));
|
|
};
|
|
|
|
function writeAfterEnd(stream, cb) {
|
|
var er = new Error('write after end');
|
|
// TODO: defer error events consistently everywhere, not just the cb
|
|
stream.emit('error', er);
|
|
pna.nextTick(cb, er);
|
|
}
|
|
|
|
// Checks that a user-supplied chunk is valid, especially for the particular
|
|
// mode the stream is in. Currently this means that `null` is never accepted
|
|
// and undefined/non-string values are only allowed in object mode.
|
|
function validChunk(stream, state, chunk, cb) {
|
|
var valid = true;
|
|
var er = false;
|
|
|
|
if (chunk === null) {
|
|
er = new TypeError('May not write null values to stream');
|
|
} else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
|
er = new TypeError('Invalid non-string/buffer chunk');
|
|
}
|
|
if (er) {
|
|
stream.emit('error', er);
|
|
pna.nextTick(cb, er);
|
|
valid = false;
|
|
}
|
|
return valid;
|
|
}
|
|
|
|
Writable.prototype.write = function (chunk, encoding, cb) {
|
|
var state = this._writableState;
|
|
var ret = false;
|
|
var isBuf = !state.objectMode && _isUint8Array(chunk);
|
|
|
|
if (isBuf && !Buffer.isBuffer(chunk)) {
|
|
chunk = _uint8ArrayToBuffer(chunk);
|
|
}
|
|
|
|
if (typeof encoding === 'function') {
|
|
cb = encoding;
|
|
encoding = null;
|
|
}
|
|
|
|
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
|
|
|
|
if (typeof cb !== 'function') cb = nop;
|
|
|
|
if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
|
|
state.pendingcb++;
|
|
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
|
|
}
|
|
|
|
return ret;
|
|
};
|
|
|
|
Writable.prototype.cork = function () {
|
|
var state = this._writableState;
|
|
|
|
state.corked++;
|
|
};
|
|
|
|
Writable.prototype.uncork = function () {
|
|
var state = this._writableState;
|
|
|
|
if (state.corked) {
|
|
state.corked--;
|
|
|
|
if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
|
}
|
|
};
|
|
|
|
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
|
// node::ParseEncoding() requires lower case.
|
|
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
|
|
if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
|
|
this._writableState.defaultEncoding = encoding;
|
|
return this;
|
|
};
|
|
|
|
function decodeChunk(state, chunk, encoding) {
|
|
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
|
|
chunk = Buffer.from(chunk, encoding);
|
|
}
|
|
return chunk;
|
|
}
|
|
|
|
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
|
|
// making it explicit this property is not enumerable
|
|
// because otherwise some prototype manipulation in
|
|
// userland will fail
|
|
enumerable: false,
|
|
get: function () {
|
|
return this._writableState.highWaterMark;
|
|
}
|
|
});
|
|
|
|
// if we're already writing something, then just put this
|
|
// in the queue, and wait our turn. Otherwise, call _write
|
|
// If we return false, then we need a drain event, so set that flag.
|
|
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
|
|
if (!isBuf) {
|
|
var newChunk = decodeChunk(state, chunk, encoding);
|
|
if (chunk !== newChunk) {
|
|
isBuf = true;
|
|
encoding = 'buffer';
|
|
chunk = newChunk;
|
|
}
|
|
}
|
|
var len = state.objectMode ? 1 : chunk.length;
|
|
|
|
state.length += len;
|
|
|
|
var ret = state.length < state.highWaterMark;
|
|
// we must ensure that previous needDrain will not be reset to false.
|
|
if (!ret) state.needDrain = true;
|
|
|
|
if (state.writing || state.corked) {
|
|
var last = state.lastBufferedRequest;
|
|
state.lastBufferedRequest = {
|
|
chunk: chunk,
|
|
encoding: encoding,
|
|
isBuf: isBuf,
|
|
callback: cb,
|
|
next: null
|
|
};
|
|
if (last) {
|
|
last.next = state.lastBufferedRequest;
|
|
} else {
|
|
state.bufferedRequest = state.lastBufferedRequest;
|
|
}
|
|
state.bufferedRequestCount += 1;
|
|
} else {
|
|
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
|
state.writelen = len;
|
|
state.writecb = cb;
|
|
state.writing = true;
|
|
state.sync = true;
|
|
if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
|
|
state.sync = false;
|
|
}
|
|
|
|
function onwriteError(stream, state, sync, er, cb) {
|
|
--state.pendingcb;
|
|
|
|
if (sync) {
|
|
// defer the callback if we are being called synchronously
|
|
// to avoid piling up things on the stack
|
|
pna.nextTick(cb, er);
|
|
// this can emit finish, and it will always happen
|
|
// after error
|
|
pna.nextTick(finishMaybe, stream, state);
|
|
stream._writableState.errorEmitted = true;
|
|
stream.emit('error', er);
|
|
} else {
|
|
// the caller expect this to happen before if
|
|
// it is async
|
|
cb(er);
|
|
stream._writableState.errorEmitted = true;
|
|
stream.emit('error', er);
|
|
// this can emit finish, but finish must
|
|
// always follow error
|
|
finishMaybe(stream, state);
|
|
}
|
|
}
|
|
|
|
function onwriteStateUpdate(state) {
|
|
state.writing = false;
|
|
state.writecb = null;
|
|
state.length -= state.writelen;
|
|
state.writelen = 0;
|
|
}
|
|
|
|
function onwrite(stream, er) {
|
|
var state = stream._writableState;
|
|
var sync = state.sync;
|
|
var cb = state.writecb;
|
|
|
|
onwriteStateUpdate(state);
|
|
|
|
if (er) onwriteError(stream, state, sync, er, cb);else {
|
|
// Check if we're actually ready to finish, but don't emit yet
|
|
var finished = needFinish(state);
|
|
|
|
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
|
clearBuffer(stream, state);
|
|
}
|
|
|
|
if (sync) {
|
|
/*<replacement>*/
|
|
asyncWrite(afterWrite, stream, state, finished, cb);
|
|
/*</replacement>*/
|
|
} else {
|
|
afterWrite(stream, state, finished, cb);
|
|
}
|
|
}
|
|
}
|
|
|
|
function afterWrite(stream, state, finished, cb) {
|
|
if (!finished) onwriteDrain(stream, state);
|
|
state.pendingcb--;
|
|
cb();
|
|
finishMaybe(stream, state);
|
|
}
|
|
|
|
// Must force callback to be called on nextTick, so that we don't
|
|
// emit 'drain' before the write() consumer gets the 'false' return
|
|
// value, and has a chance to attach a 'drain' listener.
|
|
function onwriteDrain(stream, state) {
|
|
if (state.length === 0 && state.needDrain) {
|
|
state.needDrain = false;
|
|
stream.emit('drain');
|
|
}
|
|
}
|
|
|
|
// if there's something in the buffer waiting, then process it
|
|
function clearBuffer(stream, state) {
|
|
state.bufferProcessing = true;
|
|
var entry = state.bufferedRequest;
|
|
|
|
if (stream._writev && entry && entry.next) {
|
|
// Fast case, write everything using _writev()
|
|
var l = state.bufferedRequestCount;
|
|
var buffer = new Array(l);
|
|
var holder = state.corkedRequestsFree;
|
|
holder.entry = entry;
|
|
|
|
var count = 0;
|
|
var allBuffers = true;
|
|
while (entry) {
|
|
buffer[count] = entry;
|
|
if (!entry.isBuf) allBuffers = false;
|
|
entry = entry.next;
|
|
count += 1;
|
|
}
|
|
buffer.allBuffers = allBuffers;
|
|
|
|
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
|
|
|
|
// doWrite is almost always async, defer these to save a bit of time
|
|
// as the hot path ends with doWrite
|
|
state.pendingcb++;
|
|
state.lastBufferedRequest = null;
|
|
if (holder.next) {
|
|
state.corkedRequestsFree = holder.next;
|
|
holder.next = null;
|
|
} else {
|
|
state.corkedRequestsFree = new CorkedRequest(state);
|
|
}
|
|
state.bufferedRequestCount = 0;
|
|
} else {
|
|
// Slow case, write chunks one-by-one
|
|
while (entry) {
|
|
var chunk = entry.chunk;
|
|
var encoding = entry.encoding;
|
|
var cb = entry.callback;
|
|
var len = state.objectMode ? 1 : chunk.length;
|
|
|
|
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
entry = entry.next;
|
|
state.bufferedRequestCount--;
|
|
// if we didn't call the onwrite immediately, then
|
|
// it means that we need to wait until it does.
|
|
// also, that means that the chunk and cb are currently
|
|
// being processed, so move the buffer counter past them.
|
|
if (state.writing) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (entry === null) state.lastBufferedRequest = null;
|
|
}
|
|
|
|
state.bufferedRequest = entry;
|
|
state.bufferProcessing = false;
|
|
}
|
|
|
|
Writable.prototype._write = function (chunk, encoding, cb) {
|
|
cb(new Error('_write() is not implemented'));
|
|
};
|
|
|
|
Writable.prototype._writev = null;
|
|
|
|
Writable.prototype.end = function (chunk, encoding, cb) {
|
|
var state = this._writableState;
|
|
|
|
if (typeof chunk === 'function') {
|
|
cb = chunk;
|
|
chunk = null;
|
|
encoding = null;
|
|
} else if (typeof encoding === 'function') {
|
|
cb = encoding;
|
|
encoding = null;
|
|
}
|
|
|
|
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
|
|
|
|
// .end() fully uncorks
|
|
if (state.corked) {
|
|
state.corked = 1;
|
|
this.uncork();
|
|
}
|
|
|
|
// ignore unnecessary end() calls.
|
|
if (!state.ending && !state.finished) endWritable(this, state, cb);
|
|
};
|
|
|
|
function needFinish(state) {
|
|
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
|
}
|
|
function callFinal(stream, state) {
|
|
stream._final(function (err) {
|
|
state.pendingcb--;
|
|
if (err) {
|
|
stream.emit('error', err);
|
|
}
|
|
state.prefinished = true;
|
|
stream.emit('prefinish');
|
|
finishMaybe(stream, state);
|
|
});
|
|
}
|
|
function prefinish(stream, state) {
|
|
if (!state.prefinished && !state.finalCalled) {
|
|
if (typeof stream._final === 'function') {
|
|
state.pendingcb++;
|
|
state.finalCalled = true;
|
|
pna.nextTick(callFinal, stream, state);
|
|
} else {
|
|
state.prefinished = true;
|
|
stream.emit('prefinish');
|
|
}
|
|
}
|
|
}
|
|
|
|
function finishMaybe(stream, state) {
|
|
var need = needFinish(state);
|
|
if (need) {
|
|
prefinish(stream, state);
|
|
if (state.pendingcb === 0) {
|
|
state.finished = true;
|
|
stream.emit('finish');
|
|
}
|
|
}
|
|
return need;
|
|
}
|
|
|
|
function endWritable(stream, state, cb) {
|
|
state.ending = true;
|
|
finishMaybe(stream, state);
|
|
if (cb) {
|
|
if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
|
|
}
|
|
state.ended = true;
|
|
stream.writable = false;
|
|
}
|
|
|
|
function onCorkedFinish(corkReq, state, err) {
|
|
var entry = corkReq.entry;
|
|
corkReq.entry = null;
|
|
while (entry) {
|
|
var cb = entry.callback;
|
|
state.pendingcb--;
|
|
cb(err);
|
|
entry = entry.next;
|
|
}
|
|
if (state.corkedRequestsFree) {
|
|
state.corkedRequestsFree.next = corkReq;
|
|
} else {
|
|
state.corkedRequestsFree = corkReq;
|
|
}
|
|
}
|
|
|
|
Object.defineProperty(Writable.prototype, 'destroyed', {
|
|
get: function () {
|
|
if (this._writableState === undefined) {
|
|
return false;
|
|
}
|
|
return this._writableState.destroyed;
|
|
},
|
|
set: function (value) {
|
|
// we ignore the value if the stream
|
|
// has not been initialized yet
|
|
if (!this._writableState) {
|
|
return;
|
|
}
|
|
|
|
// backward compatibility, the user is explicitly
|
|
// managing destroyed
|
|
this._writableState.destroyed = value;
|
|
}
|
|
});
|
|
|
|
Writable.prototype.destroy = destroyImpl.destroy;
|
|
Writable.prototype._undestroy = destroyImpl.undestroy;
|
|
Writable.prototype._destroy = function (err, cb) {
|
|
this.end();
|
|
cb(err);
|
|
};
|
|
|
|
/***/ }),
|
|
|
|
/***/ 250:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var constants = __webpack_require__(619)
|
|
|
|
var origCwd = process.cwd
|
|
var cwd = null
|
|
|
|
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform
|
|
|
|
process.cwd = function() {
|
|
if (!cwd)
|
|
cwd = origCwd.call(process)
|
|
return cwd
|
|
}
|
|
try {
|
|
process.cwd()
|
|
} catch (er) {}
|
|
|
|
var chdir = process.chdir
|
|
process.chdir = function(d) {
|
|
cwd = null
|
|
chdir.call(process, d)
|
|
}
|
|
|
|
module.exports = patch
|
|
|
|
function patch (fs) {
|
|
// (re-)implement some things that are known busted or missing.
|
|
|
|
// lchmod, broken prior to 0.6.2
|
|
// back-port the fix here.
|
|
if (constants.hasOwnProperty('O_SYMLINK') &&
|
|
process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
patchLchmod(fs)
|
|
}
|
|
|
|
// lutimes implementation, or no-op
|
|
if (!fs.lutimes) {
|
|
patchLutimes(fs)
|
|
}
|
|
|
|
// https://github.com/isaacs/node-graceful-fs/issues/4
|
|
// Chown should not fail on einval or eperm if non-root.
|
|
// It should not fail on enosys ever, as this just indicates
|
|
// that a fs doesn't support the intended operation.
|
|
|
|
fs.chown = chownFix(fs.chown)
|
|
fs.fchown = chownFix(fs.fchown)
|
|
fs.lchown = chownFix(fs.lchown)
|
|
|
|
fs.chmod = chmodFix(fs.chmod)
|
|
fs.fchmod = chmodFix(fs.fchmod)
|
|
fs.lchmod = chmodFix(fs.lchmod)
|
|
|
|
fs.chownSync = chownFixSync(fs.chownSync)
|
|
fs.fchownSync = chownFixSync(fs.fchownSync)
|
|
fs.lchownSync = chownFixSync(fs.lchownSync)
|
|
|
|
fs.chmodSync = chmodFixSync(fs.chmodSync)
|
|
fs.fchmodSync = chmodFixSync(fs.fchmodSync)
|
|
fs.lchmodSync = chmodFixSync(fs.lchmodSync)
|
|
|
|
fs.stat = statFix(fs.stat)
|
|
fs.fstat = statFix(fs.fstat)
|
|
fs.lstat = statFix(fs.lstat)
|
|
|
|
fs.statSync = statFixSync(fs.statSync)
|
|
fs.fstatSync = statFixSync(fs.fstatSync)
|
|
fs.lstatSync = statFixSync(fs.lstatSync)
|
|
|
|
// if lchmod/lchown do not exist, then make them no-ops
|
|
if (!fs.lchmod) {
|
|
fs.lchmod = function (path, mode, cb) {
|
|
if (cb) process.nextTick(cb)
|
|
}
|
|
fs.lchmodSync = function () {}
|
|
}
|
|
if (!fs.lchown) {
|
|
fs.lchown = function (path, uid, gid, cb) {
|
|
if (cb) process.nextTick(cb)
|
|
}
|
|
fs.lchownSync = function () {}
|
|
}
|
|
|
|
// on Windows, A/V software can lock the directory, causing this
|
|
// to fail with an EACCES or EPERM if the directory contains newly
|
|
// created files. Try again on failure, for up to 60 seconds.
|
|
|
|
// Set the timeout this long because some Windows Anti-Virus, such as Parity
|
|
// bit9, may lock files for up to a minute, causing npm package install
|
|
// failures. Also, take care to yield the scheduler. Windows scheduling gives
|
|
// CPU to a busy looping process, which can cause the program causing the lock
|
|
// contention to be starved of CPU by node, so the contention doesn't resolve.
|
|
if (platform === "win32") {
|
|
fs.rename = (function (fs$rename) { return function (from, to, cb) {
|
|
var start = Date.now()
|
|
var backoff = 0;
|
|
fs$rename(from, to, function CB (er) {
|
|
if (er
|
|
&& (er.code === "EACCES" || er.code === "EPERM")
|
|
&& Date.now() - start < 60000) {
|
|
setTimeout(function() {
|
|
fs.stat(to, function (stater, st) {
|
|
if (stater && stater.code === "ENOENT")
|
|
fs$rename(from, to, CB);
|
|
else
|
|
cb(er)
|
|
})
|
|
}, backoff)
|
|
if (backoff < 100)
|
|
backoff += 10;
|
|
return;
|
|
}
|
|
if (cb) cb(er)
|
|
})
|
|
}})(fs.rename)
|
|
}
|
|
|
|
// if read() returns EAGAIN, then just try it again.
|
|
fs.read = (function (fs$read) {
|
|
function read (fd, buffer, offset, length, position, callback_) {
|
|
var callback
|
|
if (callback_ && typeof callback_ === 'function') {
|
|
var eagCounter = 0
|
|
callback = function (er, _, __) {
|
|
if (er && er.code === 'EAGAIN' && eagCounter < 10) {
|
|
eagCounter ++
|
|
return fs$read.call(fs, fd, buffer, offset, length, position, callback)
|
|
}
|
|
callback_.apply(this, arguments)
|
|
}
|
|
}
|
|
return fs$read.call(fs, fd, buffer, offset, length, position, callback)
|
|
}
|
|
|
|
// This ensures `util.promisify` works as it does for native `fs.read`.
|
|
read.__proto__ = fs$read
|
|
return read
|
|
})(fs.read)
|
|
|
|
fs.readSync = (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
|
|
var eagCounter = 0
|
|
while (true) {
|
|
try {
|
|
return fs$readSync.call(fs, fd, buffer, offset, length, position)
|
|
} catch (er) {
|
|
if (er.code === 'EAGAIN' && eagCounter < 10) {
|
|
eagCounter ++
|
|
continue
|
|
}
|
|
throw er
|
|
}
|
|
}
|
|
}})(fs.readSync)
|
|
|
|
function patchLchmod (fs) {
|
|
fs.lchmod = function (path, mode, callback) {
|
|
fs.open( path
|
|
, constants.O_WRONLY | constants.O_SYMLINK
|
|
, mode
|
|
, function (err, fd) {
|
|
if (err) {
|
|
if (callback) callback(err)
|
|
return
|
|
}
|
|
// prefer to return the chmod error, if one occurs,
|
|
// but still try to close, and report closing errors if they occur.
|
|
fs.fchmod(fd, mode, function (err) {
|
|
fs.close(fd, function(err2) {
|
|
if (callback) callback(err || err2)
|
|
})
|
|
})
|
|
})
|
|
}
|
|
|
|
fs.lchmodSync = function (path, mode) {
|
|
var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode)
|
|
|
|
// prefer to return the chmod error, if one occurs,
|
|
// but still try to close, and report closing errors if they occur.
|
|
var threw = true
|
|
var ret
|
|
try {
|
|
ret = fs.fchmodSync(fd, mode)
|
|
threw = false
|
|
} finally {
|
|
if (threw) {
|
|
try {
|
|
fs.closeSync(fd)
|
|
} catch (er) {}
|
|
} else {
|
|
fs.closeSync(fd)
|
|
}
|
|
}
|
|
return ret
|
|
}
|
|
}
|
|
|
|
function patchLutimes (fs) {
|
|
if (constants.hasOwnProperty("O_SYMLINK")) {
|
|
fs.lutimes = function (path, at, mt, cb) {
|
|
fs.open(path, constants.O_SYMLINK, function (er, fd) {
|
|
if (er) {
|
|
if (cb) cb(er)
|
|
return
|
|
}
|
|
fs.futimes(fd, at, mt, function (er) {
|
|
fs.close(fd, function (er2) {
|
|
if (cb) cb(er || er2)
|
|
})
|
|
})
|
|
})
|
|
}
|
|
|
|
fs.lutimesSync = function (path, at, mt) {
|
|
var fd = fs.openSync(path, constants.O_SYMLINK)
|
|
var ret
|
|
var threw = true
|
|
try {
|
|
ret = fs.futimesSync(fd, at, mt)
|
|
threw = false
|
|
} finally {
|
|
if (threw) {
|
|
try {
|
|
fs.closeSync(fd)
|
|
} catch (er) {}
|
|
} else {
|
|
fs.closeSync(fd)
|
|
}
|
|
}
|
|
return ret
|
|
}
|
|
|
|
} else {
|
|
fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) }
|
|
fs.lutimesSync = function () {}
|
|
}
|
|
}
|
|
|
|
function chmodFix (orig) {
|
|
if (!orig) return orig
|
|
return function (target, mode, cb) {
|
|
return orig.call(fs, target, mode, function (er) {
|
|
if (chownErOk(er)) er = null
|
|
if (cb) cb.apply(this, arguments)
|
|
})
|
|
}
|
|
}
|
|
|
|
function chmodFixSync (orig) {
|
|
if (!orig) return orig
|
|
return function (target, mode) {
|
|
try {
|
|
return orig.call(fs, target, mode)
|
|
} catch (er) {
|
|
if (!chownErOk(er)) throw er
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function chownFix (orig) {
|
|
if (!orig) return orig
|
|
return function (target, uid, gid, cb) {
|
|
return orig.call(fs, target, uid, gid, function (er) {
|
|
if (chownErOk(er)) er = null
|
|
if (cb) cb.apply(this, arguments)
|
|
})
|
|
}
|
|
}
|
|
|
|
function chownFixSync (orig) {
|
|
if (!orig) return orig
|
|
return function (target, uid, gid) {
|
|
try {
|
|
return orig.call(fs, target, uid, gid)
|
|
} catch (er) {
|
|
if (!chownErOk(er)) throw er
|
|
}
|
|
}
|
|
}
|
|
|
|
function statFix (orig) {
|
|
if (!orig) return orig
|
|
// Older versions of Node erroneously returned signed integers for
|
|
// uid + gid.
|
|
return function (target, options, cb) {
|
|
if (typeof options === 'function') {
|
|
cb = options
|
|
options = null
|
|
}
|
|
function callback (er, stats) {
|
|
if (stats) {
|
|
if (stats.uid < 0) stats.uid += 0x100000000
|
|
if (stats.gid < 0) stats.gid += 0x100000000
|
|
}
|
|
if (cb) cb.apply(this, arguments)
|
|
}
|
|
return options ? orig.call(fs, target, options, callback)
|
|
: orig.call(fs, target, callback)
|
|
}
|
|
}
|
|
|
|
function statFixSync (orig) {
|
|
if (!orig) return orig
|
|
// Older versions of Node erroneously returned signed integers for
|
|
// uid + gid.
|
|
return function (target, options) {
|
|
var stats = options ? orig.call(fs, target, options)
|
|
: orig.call(fs, target)
|
|
if (stats.uid < 0) stats.uid += 0x100000000
|
|
if (stats.gid < 0) stats.gid += 0x100000000
|
|
return stats;
|
|
}
|
|
}
|
|
|
|
// ENOSYS means that the fs doesn't support the op. Just ignore
|
|
// that, because it doesn't matter.
|
|
//
|
|
// if there's no getuid, or if getuid() is something other
|
|
// than 0, and the error is EINVAL or EPERM, then just ignore
|
|
// it.
|
|
//
|
|
// This specific case is a silent failure in cp, install, tar,
|
|
// and most other unix tools that manage permissions.
|
|
//
|
|
// When running as root, or if other types of errors are
|
|
// encountered, then it's strict.
|
|
function chownErOk (er) {
|
|
if (!er)
|
|
return true
|
|
|
|
if (er.code === "ENOSYS")
|
|
return true
|
|
|
|
var nonroot = !process.getuid || process.getuid() !== 0
|
|
if (nonroot) {
|
|
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 262:
|
|
/***/ (function(module) {
|
|
|
|
var toString = {}.toString;
|
|
|
|
module.exports = Array.isArray || function (arr) {
|
|
return toString.call(arr) == '[object Array]';
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 277:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const hasToStringTag = __webpack_require__(458);
|
|
const isObject = __webpack_require__(163);
|
|
|
|
const toString = Object.prototype.toString;
|
|
const urlClass = "[object URL]";
|
|
|
|
const hash = "hash";
|
|
const host = "host";
|
|
const hostname = "hostname";
|
|
const href = "href";
|
|
const password = "password";
|
|
const pathname = "pathname";
|
|
const port = "port";
|
|
const protocol = "protocol";
|
|
const search = "search";
|
|
const username = "username";
|
|
|
|
|
|
|
|
const isURL = (url, supportIncomplete/*=false*/) =>
|
|
{
|
|
if (!isObject(url)) return false;
|
|
|
|
// Native implementation in older browsers
|
|
if (!hasToStringTag && toString.call(url) === urlClass) return true;
|
|
|
|
if (!(href in url)) return false;
|
|
if (!(protocol in url)) return false;
|
|
if (!(username in url)) return false;
|
|
if (!(password in url)) return false;
|
|
if (!(hostname in url)) return false;
|
|
if (!(port in url)) return false;
|
|
if (!(host in url)) return false;
|
|
if (!(pathname in url)) return false;
|
|
if (!(search in url)) return false;
|
|
if (!(hash in url)) return false;
|
|
|
|
if (supportIncomplete !== true)
|
|
{
|
|
if (!isObject(url.searchParams)) return false;
|
|
|
|
// TODO :: write a separate isURLSearchParams ?
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
isURL.lenient = url =>
|
|
{
|
|
return isURL(url, true);
|
|
};
|
|
|
|
|
|
|
|
module.exports = isURL;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 280:
|
|
/***/ (function(module, exports) {
|
|
|
|
exports = module.exports = SemVer
|
|
|
|
var debug
|
|
/* istanbul ignore next */
|
|
if (typeof process === 'object' &&
|
|
process.env &&
|
|
process.env.NODE_DEBUG &&
|
|
/\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
|
debug = function () {
|
|
var args = Array.prototype.slice.call(arguments, 0)
|
|
args.unshift('SEMVER')
|
|
console.log.apply(console, args)
|
|
}
|
|
} else {
|
|
debug = function () {}
|
|
}
|
|
|
|
// Note: this is the semver.org version of the spec that it implements
|
|
// Not necessarily the package version of this code.
|
|
exports.SEMVER_SPEC_VERSION = '2.0.0'
|
|
|
|
var MAX_LENGTH = 256
|
|
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
|
/* istanbul ignore next */ 9007199254740991
|
|
|
|
// Max safe segment length for coercion.
|
|
var MAX_SAFE_COMPONENT_LENGTH = 16
|
|
|
|
// The actual regexps go on exports.re
|
|
var re = exports.re = []
|
|
var src = exports.src = []
|
|
var t = exports.tokens = {}
|
|
var R = 0
|
|
|
|
function tok (n) {
|
|
t[n] = R++
|
|
}
|
|
|
|
// The following Regular Expressions can be used for tokenizing,
|
|
// validating, and parsing SemVer version strings.
|
|
|
|
// ## Numeric Identifier
|
|
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
|
|
tok('NUMERICIDENTIFIER')
|
|
src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*'
|
|
tok('NUMERICIDENTIFIERLOOSE')
|
|
src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+'
|
|
|
|
// ## Non-numeric Identifier
|
|
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
// more letters, digits, or hyphens.
|
|
|
|
tok('NONNUMERICIDENTIFIER')
|
|
src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'
|
|
|
|
// ## Main Version
|
|
// Three dot-separated numeric identifiers.
|
|
|
|
tok('MAINVERSION')
|
|
src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
|
|
'(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
|
|
'(' + src[t.NUMERICIDENTIFIER] + ')'
|
|
|
|
tok('MAINVERSIONLOOSE')
|
|
src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
|
'(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
|
'(' + src[t.NUMERICIDENTIFIERLOOSE] + ')'
|
|
|
|
// ## Pre-release Version Identifier
|
|
// A numeric identifier, or a non-numeric identifier.
|
|
|
|
tok('PRERELEASEIDENTIFIER')
|
|
src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
|
|
'|' + src[t.NONNUMERICIDENTIFIER] + ')'
|
|
|
|
tok('PRERELEASEIDENTIFIERLOOSE')
|
|
src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
|
|
'|' + src[t.NONNUMERICIDENTIFIER] + ')'
|
|
|
|
// ## Pre-release Version
|
|
// Hyphen, followed by one or more dot-separated pre-release version
|
|
// identifiers.
|
|
|
|
tok('PRERELEASE')
|
|
src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
|
|
'(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))'
|
|
|
|
tok('PRERELEASELOOSE')
|
|
src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
|
|
'(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))'
|
|
|
|
// ## Build Metadata Identifier
|
|
// Any combination of digits, letters, or hyphens.
|
|
|
|
tok('BUILDIDENTIFIER')
|
|
src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+'
|
|
|
|
// ## Build Metadata
|
|
// Plus sign, followed by one or more period-separated build metadata
|
|
// identifiers.
|
|
|
|
tok('BUILD')
|
|
src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
|
|
'(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))'
|
|
|
|
// ## Full Version String
|
|
// A main version, followed optionally by a pre-release version and
|
|
// build metadata.
|
|
|
|
// Note that the only major, minor, patch, and pre-release sections of
|
|
// the version string are capturing groups. The build metadata is not a
|
|
// capturing group, because it should not ever be used in version
|
|
// comparison.
|
|
|
|
tok('FULL')
|
|
tok('FULLPLAIN')
|
|
src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
|
|
src[t.PRERELEASE] + '?' +
|
|
src[t.BUILD] + '?'
|
|
|
|
src[t.FULL] = '^' + src[t.FULLPLAIN] + '$'
|
|
|
|
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
// common in the npm registry.
|
|
tok('LOOSEPLAIN')
|
|
src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
|
|
src[t.PRERELEASELOOSE] + '?' +
|
|
src[t.BUILD] + '?'
|
|
|
|
tok('LOOSE')
|
|
src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$'
|
|
|
|
tok('GTLT')
|
|
src[t.GTLT] = '((?:<|>)?=?)'
|
|
|
|
// Something like "2.*" or "1.2.x".
|
|
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
// Only the first item is strictly required.
|
|
tok('XRANGEIDENTIFIERLOOSE')
|
|
src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'
|
|
tok('XRANGEIDENTIFIER')
|
|
src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*'
|
|
|
|
tok('XRANGEPLAIN')
|
|
src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
|
|
'(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
|
|
'(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
|
|
'(?:' + src[t.PRERELEASE] + ')?' +
|
|
src[t.BUILD] + '?' +
|
|
')?)?'
|
|
|
|
tok('XRANGEPLAINLOOSE')
|
|
src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
|
'(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
|
'(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
|
'(?:' + src[t.PRERELEASELOOSE] + ')?' +
|
|
src[t.BUILD] + '?' +
|
|
')?)?'
|
|
|
|
tok('XRANGE')
|
|
src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$'
|
|
tok('XRANGELOOSE')
|
|
src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$'
|
|
|
|
// Coercion.
|
|
// Extract anything that could conceivably be a part of a valid semver
|
|
tok('COERCE')
|
|
src[t.COERCE] = '(^|[^\\d])' +
|
|
'(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
|
|
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
|
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
|
'(?:$|[^\\d])'
|
|
tok('COERCERTL')
|
|
re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g')
|
|
|
|
// Tilde ranges.
|
|
// Meaning is "reasonably at or greater than"
|
|
tok('LONETILDE')
|
|
src[t.LONETILDE] = '(?:~>?)'
|
|
|
|
tok('TILDETRIM')
|
|
src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+'
|
|
re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g')
|
|
var tildeTrimReplace = '$1~'
|
|
|
|
tok('TILDE')
|
|
src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$'
|
|
tok('TILDELOOSE')
|
|
src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$'
|
|
|
|
// Caret ranges.
|
|
// Meaning is "at least and backwards compatible with"
|
|
tok('LONECARET')
|
|
src[t.LONECARET] = '(?:\\^)'
|
|
|
|
tok('CARETTRIM')
|
|
src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+'
|
|
re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g')
|
|
var caretTrimReplace = '$1^'
|
|
|
|
tok('CARET')
|
|
src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$'
|
|
tok('CARETLOOSE')
|
|
src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$'
|
|
|
|
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
tok('COMPARATORLOOSE')
|
|
src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$'
|
|
tok('COMPARATOR')
|
|
src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$'
|
|
|
|
// An expression to strip any whitespace between the gtlt and the thing
|
|
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
tok('COMPARATORTRIM')
|
|
src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
|
|
'\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')'
|
|
|
|
// this one has to use the /g flag
|
|
re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g')
|
|
var comparatorTrimReplace = '$1$2$3'
|
|
|
|
// Something like `1.2.3 - 1.2.4`
|
|
// Note that these all use the loose form, because they'll be
|
|
// checked against either the strict or loose comparator form
|
|
// later.
|
|
tok('HYPHENRANGE')
|
|
src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
|
|
'\\s+-\\s+' +
|
|
'(' + src[t.XRANGEPLAIN] + ')' +
|
|
'\\s*$'
|
|
|
|
tok('HYPHENRANGELOOSE')
|
|
src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
|
|
'\\s+-\\s+' +
|
|
'(' + src[t.XRANGEPLAINLOOSE] + ')' +
|
|
'\\s*$'
|
|
|
|
// Star ranges basically just allow anything at all.
|
|
tok('STAR')
|
|
src[t.STAR] = '(<|>)?=?\\s*\\*'
|
|
|
|
// Compile to actual regexp objects.
|
|
// All are flag-free, unless they were created above with a flag.
|
|
for (var i = 0; i < R; i++) {
|
|
debug(i, src[i])
|
|
if (!re[i]) {
|
|
re[i] = new RegExp(src[i])
|
|
}
|
|
}
|
|
|
|
exports.parse = parse
|
|
function parse (version, options) {
|
|
if (!options || typeof options !== 'object') {
|
|
options = {
|
|
loose: !!options,
|
|
includePrerelease: false
|
|
}
|
|
}
|
|
|
|
if (version instanceof SemVer) {
|
|
return version
|
|
}
|
|
|
|
if (typeof version !== 'string') {
|
|
return null
|
|
}
|
|
|
|
if (version.length > MAX_LENGTH) {
|
|
return null
|
|
}
|
|
|
|
var r = options.loose ? re[t.LOOSE] : re[t.FULL]
|
|
if (!r.test(version)) {
|
|
return null
|
|
}
|
|
|
|
try {
|
|
return new SemVer(version, options)
|
|
} catch (er) {
|
|
return null
|
|
}
|
|
}
|
|
|
|
exports.valid = valid
|
|
function valid (version, options) {
|
|
var v = parse(version, options)
|
|
return v ? v.version : null
|
|
}
|
|
|
|
exports.clean = clean
|
|
function clean (version, options) {
|
|
var s = parse(version.trim().replace(/^[=v]+/, ''), options)
|
|
return s ? s.version : null
|
|
}
|
|
|
|
exports.SemVer = SemVer
|
|
|
|
function SemVer (version, options) {
|
|
if (!options || typeof options !== 'object') {
|
|
options = {
|
|
loose: !!options,
|
|
includePrerelease: false
|
|
}
|
|
}
|
|
if (version instanceof SemVer) {
|
|
if (version.loose === options.loose) {
|
|
return version
|
|
} else {
|
|
version = version.version
|
|
}
|
|
} else if (typeof version !== 'string') {
|
|
throw new TypeError('Invalid Version: ' + version)
|
|
}
|
|
|
|
if (version.length > MAX_LENGTH) {
|
|
throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
|
|
}
|
|
|
|
if (!(this instanceof SemVer)) {
|
|
return new SemVer(version, options)
|
|
}
|
|
|
|
debug('SemVer', version, options)
|
|
this.options = options
|
|
this.loose = !!options.loose
|
|
|
|
var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])
|
|
|
|
if (!m) {
|
|
throw new TypeError('Invalid Version: ' + version)
|
|
}
|
|
|
|
this.raw = version
|
|
|
|
// these are actually numbers
|
|
this.major = +m[1]
|
|
this.minor = +m[2]
|
|
this.patch = +m[3]
|
|
|
|
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
throw new TypeError('Invalid major version')
|
|
}
|
|
|
|
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
throw new TypeError('Invalid minor version')
|
|
}
|
|
|
|
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
throw new TypeError('Invalid patch version')
|
|
}
|
|
|
|
// numberify any prerelease numeric ids
|
|
if (!m[4]) {
|
|
this.prerelease = []
|
|
} else {
|
|
this.prerelease = m[4].split('.').map(function (id) {
|
|
if (/^[0-9]+$/.test(id)) {
|
|
var num = +id
|
|
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
return num
|
|
}
|
|
}
|
|
return id
|
|
})
|
|
}
|
|
|
|
this.build = m[5] ? m[5].split('.') : []
|
|
this.format()
|
|
}
|
|
|
|
SemVer.prototype.format = function () {
|
|
this.version = this.major + '.' + this.minor + '.' + this.patch
|
|
if (this.prerelease.length) {
|
|
this.version += '-' + this.prerelease.join('.')
|
|
}
|
|
return this.version
|
|
}
|
|
|
|
SemVer.prototype.toString = function () {
|
|
return this.version
|
|
}
|
|
|
|
SemVer.prototype.compare = function (other) {
|
|
debug('SemVer.compare', this.version, this.options, other)
|
|
if (!(other instanceof SemVer)) {
|
|
other = new SemVer(other, this.options)
|
|
}
|
|
|
|
return this.compareMain(other) || this.comparePre(other)
|
|
}
|
|
|
|
SemVer.prototype.compareMain = function (other) {
|
|
if (!(other instanceof SemVer)) {
|
|
other = new SemVer(other, this.options)
|
|
}
|
|
|
|
return compareIdentifiers(this.major, other.major) ||
|
|
compareIdentifiers(this.minor, other.minor) ||
|
|
compareIdentifiers(this.patch, other.patch)
|
|
}
|
|
|
|
SemVer.prototype.comparePre = function (other) {
|
|
if (!(other instanceof SemVer)) {
|
|
other = new SemVer(other, this.options)
|
|
}
|
|
|
|
// NOT having a prerelease is > having one
|
|
if (this.prerelease.length && !other.prerelease.length) {
|
|
return -1
|
|
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
return 1
|
|
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
return 0
|
|
}
|
|
|
|
var i = 0
|
|
do {
|
|
var a = this.prerelease[i]
|
|
var b = other.prerelease[i]
|
|
debug('prerelease compare', i, a, b)
|
|
if (a === undefined && b === undefined) {
|
|
return 0
|
|
} else if (b === undefined) {
|
|
return 1
|
|
} else if (a === undefined) {
|
|
return -1
|
|
} else if (a === b) {
|
|
continue
|
|
} else {
|
|
return compareIdentifiers(a, b)
|
|
}
|
|
} while (++i)
|
|
}
|
|
|
|
SemVer.prototype.compareBuild = function (other) {
|
|
if (!(other instanceof SemVer)) {
|
|
other = new SemVer(other, this.options)
|
|
}
|
|
|
|
var i = 0
|
|
do {
|
|
var a = this.build[i]
|
|
var b = other.build[i]
|
|
debug('prerelease compare', i, a, b)
|
|
if (a === undefined && b === undefined) {
|
|
return 0
|
|
} else if (b === undefined) {
|
|
return 1
|
|
} else if (a === undefined) {
|
|
return -1
|
|
} else if (a === b) {
|
|
continue
|
|
} else {
|
|
return compareIdentifiers(a, b)
|
|
}
|
|
} while (++i)
|
|
}
|
|
|
|
// preminor will bump the version up to the next minor release, and immediately
|
|
// down to pre-release. premajor and prepatch work the same way.
|
|
SemVer.prototype.inc = function (release, identifier) {
|
|
switch (release) {
|
|
case 'premajor':
|
|
this.prerelease.length = 0
|
|
this.patch = 0
|
|
this.minor = 0
|
|
this.major++
|
|
this.inc('pre', identifier)
|
|
break
|
|
case 'preminor':
|
|
this.prerelease.length = 0
|
|
this.patch = 0
|
|
this.minor++
|
|
this.inc('pre', identifier)
|
|
break
|
|
case 'prepatch':
|
|
// If this is already a prerelease, it will bump to the next version
|
|
// drop any prereleases that might already exist, since they are not
|
|
// relevant at this point.
|
|
this.prerelease.length = 0
|
|
this.inc('patch', identifier)
|
|
this.inc('pre', identifier)
|
|
break
|
|
// If the input is a non-prerelease version, this acts the same as
|
|
// prepatch.
|
|
case 'prerelease':
|
|
if (this.prerelease.length === 0) {
|
|
this.inc('patch', identifier)
|
|
}
|
|
this.inc('pre', identifier)
|
|
break
|
|
|
|
case 'major':
|
|
// If this is a pre-major version, bump up to the same major version.
|
|
// Otherwise increment major.
|
|
// 1.0.0-5 bumps to 1.0.0
|
|
// 1.1.0 bumps to 2.0.0
|
|
if (this.minor !== 0 ||
|
|
this.patch !== 0 ||
|
|
this.prerelease.length === 0) {
|
|
this.major++
|
|
}
|
|
this.minor = 0
|
|
this.patch = 0
|
|
this.prerelease = []
|
|
break
|
|
case 'minor':
|
|
// If this is a pre-minor version, bump up to the same minor version.
|
|
// Otherwise increment minor.
|
|
// 1.2.0-5 bumps to 1.2.0
|
|
// 1.2.1 bumps to 1.3.0
|
|
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
this.minor++
|
|
}
|
|
this.patch = 0
|
|
this.prerelease = []
|
|
break
|
|
case 'patch':
|
|
// If this is not a pre-release version, it will increment the patch.
|
|
// If it is a pre-release it will bump up to the same patch version.
|
|
// 1.2.0-5 patches to 1.2.0
|
|
// 1.2.0 patches to 1.2.1
|
|
if (this.prerelease.length === 0) {
|
|
this.patch++
|
|
}
|
|
this.prerelease = []
|
|
break
|
|
// This probably shouldn't be used publicly.
|
|
// 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
|
|
case 'pre':
|
|
if (this.prerelease.length === 0) {
|
|
this.prerelease = [0]
|
|
} else {
|
|
var i = this.prerelease.length
|
|
while (--i >= 0) {
|
|
if (typeof this.prerelease[i] === 'number') {
|
|
this.prerelease[i]++
|
|
i = -2
|
|
}
|
|
}
|
|
if (i === -1) {
|
|
// didn't increment anything
|
|
this.prerelease.push(0)
|
|
}
|
|
}
|
|
if (identifier) {
|
|
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
if (this.prerelease[0] === identifier) {
|
|
if (isNaN(this.prerelease[1])) {
|
|
this.prerelease = [identifier, 0]
|
|
}
|
|
} else {
|
|
this.prerelease = [identifier, 0]
|
|
}
|
|
}
|
|
break
|
|
|
|
default:
|
|
throw new Error('invalid increment argument: ' + release)
|
|
}
|
|
this.format()
|
|
this.raw = this.version
|
|
return this
|
|
}
|
|
|
|
exports.inc = inc
|
|
function inc (version, release, loose, identifier) {
|
|
if (typeof (loose) === 'string') {
|
|
identifier = loose
|
|
loose = undefined
|
|
}
|
|
|
|
try {
|
|
return new SemVer(version, loose).inc(release, identifier).version
|
|
} catch (er) {
|
|
return null
|
|
}
|
|
}
|
|
|
|
exports.diff = diff
|
|
function diff (version1, version2) {
|
|
if (eq(version1, version2)) {
|
|
return null
|
|
} else {
|
|
var v1 = parse(version1)
|
|
var v2 = parse(version2)
|
|
var prefix = ''
|
|
if (v1.prerelease.length || v2.prerelease.length) {
|
|
prefix = 'pre'
|
|
var defaultResult = 'prerelease'
|
|
}
|
|
for (var key in v1) {
|
|
if (key === 'major' || key === 'minor' || key === 'patch') {
|
|
if (v1[key] !== v2[key]) {
|
|
return prefix + key
|
|
}
|
|
}
|
|
}
|
|
return defaultResult // may be undefined
|
|
}
|
|
}
|
|
|
|
exports.compareIdentifiers = compareIdentifiers
|
|
|
|
var numeric = /^[0-9]+$/
|
|
function compareIdentifiers (a, b) {
|
|
var anum = numeric.test(a)
|
|
var bnum = numeric.test(b)
|
|
|
|
if (anum && bnum) {
|
|
a = +a
|
|
b = +b
|
|
}
|
|
|
|
return a === b ? 0
|
|
: (anum && !bnum) ? -1
|
|
: (bnum && !anum) ? 1
|
|
: a < b ? -1
|
|
: 1
|
|
}
|
|
|
|
exports.rcompareIdentifiers = rcompareIdentifiers
|
|
function rcompareIdentifiers (a, b) {
|
|
return compareIdentifiers(b, a)
|
|
}
|
|
|
|
exports.major = major
|
|
function major (a, loose) {
|
|
return new SemVer(a, loose).major
|
|
}
|
|
|
|
exports.minor = minor
|
|
function minor (a, loose) {
|
|
return new SemVer(a, loose).minor
|
|
}
|
|
|
|
exports.patch = patch
|
|
function patch (a, loose) {
|
|
return new SemVer(a, loose).patch
|
|
}
|
|
|
|
exports.compare = compare
|
|
function compare (a, b, loose) {
|
|
return new SemVer(a, loose).compare(new SemVer(b, loose))
|
|
}
|
|
|
|
exports.compareLoose = compareLoose
|
|
function compareLoose (a, b) {
|
|
return compare(a, b, true)
|
|
}
|
|
|
|
exports.compareBuild = compareBuild
|
|
function compareBuild (a, b, loose) {
|
|
var versionA = new SemVer(a, loose)
|
|
var versionB = new SemVer(b, loose)
|
|
return versionA.compare(versionB) || versionA.compareBuild(versionB)
|
|
}
|
|
|
|
exports.rcompare = rcompare
|
|
function rcompare (a, b, loose) {
|
|
return compare(b, a, loose)
|
|
}
|
|
|
|
exports.sort = sort
|
|
function sort (list, loose) {
|
|
return list.sort(function (a, b) {
|
|
return exports.compareBuild(a, b, loose)
|
|
})
|
|
}
|
|
|
|
exports.rsort = rsort
|
|
function rsort (list, loose) {
|
|
return list.sort(function (a, b) {
|
|
return exports.compareBuild(b, a, loose)
|
|
})
|
|
}
|
|
|
|
exports.gt = gt
|
|
function gt (a, b, loose) {
|
|
return compare(a, b, loose) > 0
|
|
}
|
|
|
|
exports.lt = lt
|
|
function lt (a, b, loose) {
|
|
return compare(a, b, loose) < 0
|
|
}
|
|
|
|
exports.eq = eq
|
|
function eq (a, b, loose) {
|
|
return compare(a, b, loose) === 0
|
|
}
|
|
|
|
exports.neq = neq
|
|
function neq (a, b, loose) {
|
|
return compare(a, b, loose) !== 0
|
|
}
|
|
|
|
exports.gte = gte
|
|
function gte (a, b, loose) {
|
|
return compare(a, b, loose) >= 0
|
|
}
|
|
|
|
exports.lte = lte
|
|
function lte (a, b, loose) {
|
|
return compare(a, b, loose) <= 0
|
|
}
|
|
|
|
exports.cmp = cmp
|
|
function cmp (a, op, b, loose) {
|
|
switch (op) {
|
|
case '===':
|
|
if (typeof a === 'object')
|
|
a = a.version
|
|
if (typeof b === 'object')
|
|
b = b.version
|
|
return a === b
|
|
|
|
case '!==':
|
|
if (typeof a === 'object')
|
|
a = a.version
|
|
if (typeof b === 'object')
|
|
b = b.version
|
|
return a !== b
|
|
|
|
case '':
|
|
case '=':
|
|
case '==':
|
|
return eq(a, b, loose)
|
|
|
|
case '!=':
|
|
return neq(a, b, loose)
|
|
|
|
case '>':
|
|
return gt(a, b, loose)
|
|
|
|
case '>=':
|
|
return gte(a, b, loose)
|
|
|
|
case '<':
|
|
return lt(a, b, loose)
|
|
|
|
case '<=':
|
|
return lte(a, b, loose)
|
|
|
|
default:
|
|
throw new TypeError('Invalid operator: ' + op)
|
|
}
|
|
}
|
|
|
|
exports.Comparator = Comparator
|
|
function Comparator (comp, options) {
|
|
if (!options || typeof options !== 'object') {
|
|
options = {
|
|
loose: !!options,
|
|
includePrerelease: false
|
|
}
|
|
}
|
|
|
|
if (comp instanceof Comparator) {
|
|
if (comp.loose === !!options.loose) {
|
|
return comp
|
|
} else {
|
|
comp = comp.value
|
|
}
|
|
}
|
|
|
|
if (!(this instanceof Comparator)) {
|
|
return new Comparator(comp, options)
|
|
}
|
|
|
|
debug('comparator', comp, options)
|
|
this.options = options
|
|
this.loose = !!options.loose
|
|
this.parse(comp)
|
|
|
|
if (this.semver === ANY) {
|
|
this.value = ''
|
|
} else {
|
|
this.value = this.operator + this.semver.version
|
|
}
|
|
|
|
debug('comp', this)
|
|
}
|
|
|
|
var ANY = {}
|
|
Comparator.prototype.parse = function (comp) {
|
|
var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
|
|
var m = comp.match(r)
|
|
|
|
if (!m) {
|
|
throw new TypeError('Invalid comparator: ' + comp)
|
|
}
|
|
|
|
this.operator = m[1] !== undefined ? m[1] : ''
|
|
if (this.operator === '=') {
|
|
this.operator = ''
|
|
}
|
|
|
|
// if it literally is just '>' or '' then allow anything.
|
|
if (!m[2]) {
|
|
this.semver = ANY
|
|
} else {
|
|
this.semver = new SemVer(m[2], this.options.loose)
|
|
}
|
|
}
|
|
|
|
Comparator.prototype.toString = function () {
|
|
return this.value
|
|
}
|
|
|
|
Comparator.prototype.test = function (version) {
|
|
debug('Comparator.test', version, this.options.loose)
|
|
|
|
if (this.semver === ANY || version === ANY) {
|
|
return true
|
|
}
|
|
|
|
if (typeof version === 'string') {
|
|
try {
|
|
version = new SemVer(version, this.options)
|
|
} catch (er) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return cmp(version, this.operator, this.semver, this.options)
|
|
}
|
|
|
|
Comparator.prototype.intersects = function (comp, options) {
|
|
if (!(comp instanceof Comparator)) {
|
|
throw new TypeError('a Comparator is required')
|
|
}
|
|
|
|
if (!options || typeof options !== 'object') {
|
|
options = {
|
|
loose: !!options,
|
|
includePrerelease: false
|
|
}
|
|
}
|
|
|
|
var rangeTmp
|
|
|
|
if (this.operator === '') {
|
|
if (this.value === '') {
|
|
return true
|
|
}
|
|
rangeTmp = new Range(comp.value, options)
|
|
return satisfies(this.value, rangeTmp, options)
|
|
} else if (comp.operator === '') {
|
|
if (comp.value === '') {
|
|
return true
|
|
}
|
|
rangeTmp = new Range(this.value, options)
|
|
return satisfies(comp.semver, rangeTmp, options)
|
|
}
|
|
|
|
var sameDirectionIncreasing =
|
|
(this.operator === '>=' || this.operator === '>') &&
|
|
(comp.operator === '>=' || comp.operator === '>')
|
|
var sameDirectionDecreasing =
|
|
(this.operator === '<=' || this.operator === '<') &&
|
|
(comp.operator === '<=' || comp.operator === '<')
|
|
var sameSemVer = this.semver.version === comp.semver.version
|
|
var differentDirectionsInclusive =
|
|
(this.operator === '>=' || this.operator === '<=') &&
|
|
(comp.operator === '>=' || comp.operator === '<=')
|
|
var oppositeDirectionsLessThan =
|
|
cmp(this.semver, '<', comp.semver, options) &&
|
|
((this.operator === '>=' || this.operator === '>') &&
|
|
(comp.operator === '<=' || comp.operator === '<'))
|
|
var oppositeDirectionsGreaterThan =
|
|
cmp(this.semver, '>', comp.semver, options) &&
|
|
((this.operator === '<=' || this.operator === '<') &&
|
|
(comp.operator === '>=' || comp.operator === '>'))
|
|
|
|
return sameDirectionIncreasing || sameDirectionDecreasing ||
|
|
(sameSemVer && differentDirectionsInclusive) ||
|
|
oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
|
|
}
|
|
|
|
exports.Range = Range
|
|
function Range (range, options) {
|
|
if (!options || typeof options !== 'object') {
|
|
options = {
|
|
loose: !!options,
|
|
includePrerelease: false
|
|
}
|
|
}
|
|
|
|
if (range instanceof Range) {
|
|
if (range.loose === !!options.loose &&
|
|
range.includePrerelease === !!options.includePrerelease) {
|
|
return range
|
|
} else {
|
|
return new Range(range.raw, options)
|
|
}
|
|
}
|
|
|
|
if (range instanceof Comparator) {
|
|
return new Range(range.value, options)
|
|
}
|
|
|
|
if (!(this instanceof Range)) {
|
|
return new Range(range, options)
|
|
}
|
|
|
|
this.options = options
|
|
this.loose = !!options.loose
|
|
this.includePrerelease = !!options.includePrerelease
|
|
|
|
// First, split based on boolean or ||
|
|
this.raw = range
|
|
this.set = range.split(/\s*\|\|\s*/).map(function (range) {
|
|
return this.parseRange(range.trim())
|
|
}, this).filter(function (c) {
|
|
// throw out any that are not relevant for whatever reason
|
|
return c.length
|
|
})
|
|
|
|
if (!this.set.length) {
|
|
throw new TypeError('Invalid SemVer Range: ' + range)
|
|
}
|
|
|
|
this.format()
|
|
}
|
|
|
|
Range.prototype.format = function () {
|
|
this.range = this.set.map(function (comps) {
|
|
return comps.join(' ').trim()
|
|
}).join('||').trim()
|
|
return this.range
|
|
}
|
|
|
|
Range.prototype.toString = function () {
|
|
return this.range
|
|
}
|
|
|
|
Range.prototype.parseRange = function (range) {
|
|
var loose = this.options.loose
|
|
range = range.trim()
|
|
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
|
|
range = range.replace(hr, hyphenReplace)
|
|
debug('hyphen replace', range)
|
|
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
|
|
debug('comparator trim', range, re[t.COMPARATORTRIM])
|
|
|
|
// `~ 1.2.3` => `~1.2.3`
|
|
range = range.replace(re[t.TILDETRIM], tildeTrimReplace)
|
|
|
|
// `^ 1.2.3` => `^1.2.3`
|
|
range = range.replace(re[t.CARETTRIM], caretTrimReplace)
|
|
|
|
// normalize spaces
|
|
range = range.split(/\s+/).join(' ')
|
|
|
|
// At this point, the range is completely trimmed and
|
|
// ready to be split into comparators.
|
|
|
|
var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
|
|
var set = range.split(' ').map(function (comp) {
|
|
return parseComparator(comp, this.options)
|
|
}, this).join(' ').split(/\s+/)
|
|
if (this.options.loose) {
|
|
// in loose mode, throw out any that are not valid comparators
|
|
set = set.filter(function (comp) {
|
|
return !!comp.match(compRe)
|
|
})
|
|
}
|
|
set = set.map(function (comp) {
|
|
return new Comparator(comp, this.options)
|
|
}, this)
|
|
|
|
return set
|
|
}
|
|
|
|
Range.prototype.intersects = function (range, options) {
|
|
if (!(range instanceof Range)) {
|
|
throw new TypeError('a Range is required')
|
|
}
|
|
|
|
return this.set.some(function (thisComparators) {
|
|
return (
|
|
isSatisfiable(thisComparators, options) &&
|
|
range.set.some(function (rangeComparators) {
|
|
return (
|
|
isSatisfiable(rangeComparators, options) &&
|
|
thisComparators.every(function (thisComparator) {
|
|
return rangeComparators.every(function (rangeComparator) {
|
|
return thisComparator.intersects(rangeComparator, options)
|
|
})
|
|
})
|
|
)
|
|
})
|
|
)
|
|
})
|
|
}
|
|
|
|
// take a set of comparators and determine whether there
|
|
// exists a version which can satisfy it
|
|
function isSatisfiable (comparators, options) {
|
|
var result = true
|
|
var remainingComparators = comparators.slice()
|
|
var testComparator = remainingComparators.pop()
|
|
|
|
while (result && remainingComparators.length) {
|
|
result = remainingComparators.every(function (otherComparator) {
|
|
return testComparator.intersects(otherComparator, options)
|
|
})
|
|
|
|
testComparator = remainingComparators.pop()
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
// Mostly just for testing and legacy API reasons
|
|
exports.toComparators = toComparators
|
|
function toComparators (range, options) {
|
|
return new Range(range, options).set.map(function (comp) {
|
|
return comp.map(function (c) {
|
|
return c.value
|
|
}).join(' ').trim().split(' ')
|
|
})
|
|
}
|
|
|
|
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
|
// already replaced the hyphen ranges
|
|
// turn into a set of JUST comparators.
|
|
function parseComparator (comp, options) {
|
|
debug('comp', comp, options)
|
|
comp = replaceCarets(comp, options)
|
|
debug('caret', comp)
|
|
comp = replaceTildes(comp, options)
|
|
debug('tildes', comp)
|
|
comp = replaceXRanges(comp, options)
|
|
debug('xrange', comp)
|
|
comp = replaceStars(comp, options)
|
|
debug('stars', comp)
|
|
return comp
|
|
}
|
|
|
|
function isX (id) {
|
|
return !id || id.toLowerCase() === 'x' || id === '*'
|
|
}
|
|
|
|
// ~, ~> --> * (any, kinda silly)
|
|
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
|
|
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
|
|
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
|
|
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
|
|
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
|
|
function replaceTildes (comp, options) {
|
|
return comp.trim().split(/\s+/).map(function (comp) {
|
|
return replaceTilde(comp, options)
|
|
}).join(' ')
|
|
}
|
|
|
|
function replaceTilde (comp, options) {
|
|
var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
|
|
return comp.replace(r, function (_, M, m, p, pr) {
|
|
debug('tilde', comp, _, M, m, p, pr)
|
|
var ret
|
|
|
|
if (isX(M)) {
|
|
ret = ''
|
|
} else if (isX(m)) {
|
|
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
|
} else if (isX(p)) {
|
|
// ~1.2 == >=1.2.0 <1.3.0
|
|
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
|
} else if (pr) {
|
|
debug('replaceTilde pr', pr)
|
|
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
' <' + M + '.' + (+m + 1) + '.0'
|
|
} else {
|
|
// ~1.2.3 == >=1.2.3 <1.3.0
|
|
ret = '>=' + M + '.' + m + '.' + p +
|
|
' <' + M + '.' + (+m + 1) + '.0'
|
|
}
|
|
|
|
debug('tilde return', ret)
|
|
return ret
|
|
})
|
|
}
|
|
|
|
// ^ --> * (any, kinda silly)
|
|
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
|
|
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
|
|
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
|
|
// ^1.2.3 --> >=1.2.3 <2.0.0
|
|
// ^1.2.0 --> >=1.2.0 <2.0.0
|
|
function replaceCarets (comp, options) {
|
|
return comp.trim().split(/\s+/).map(function (comp) {
|
|
return replaceCaret(comp, options)
|
|
}).join(' ')
|
|
}
|
|
|
|
function replaceCaret (comp, options) {
|
|
debug('caret', comp, options)
|
|
var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]
|
|
return comp.replace(r, function (_, M, m, p, pr) {
|
|
debug('caret', comp, _, M, m, p, pr)
|
|
var ret
|
|
|
|
if (isX(M)) {
|
|
ret = ''
|
|
} else if (isX(m)) {
|
|
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
|
} else if (isX(p)) {
|
|
if (M === '0') {
|
|
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
|
} else {
|
|
ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0'
|
|
}
|
|
} else if (pr) {
|
|
debug('replaceCaret pr', pr)
|
|
if (M === '0') {
|
|
if (m === '0') {
|
|
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
' <' + M + '.' + m + '.' + (+p + 1)
|
|
} else {
|
|
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
' <' + M + '.' + (+m + 1) + '.0'
|
|
}
|
|
} else {
|
|
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
' <' + (+M + 1) + '.0.0'
|
|
}
|
|
} else {
|
|
debug('no pr')
|
|
if (M === '0') {
|
|
if (m === '0') {
|
|
ret = '>=' + M + '.' + m + '.' + p +
|
|
' <' + M + '.' + m + '.' + (+p + 1)
|
|
} else {
|
|
ret = '>=' + M + '.' + m + '.' + p +
|
|
' <' + M + '.' + (+m + 1) + '.0'
|
|
}
|
|
} else {
|
|
ret = '>=' + M + '.' + m + '.' + p +
|
|
' <' + (+M + 1) + '.0.0'
|
|
}
|
|
}
|
|
|
|
debug('caret return', ret)
|
|
return ret
|
|
})
|
|
}
|
|
|
|
function replaceXRanges (comp, options) {
|
|
debug('replaceXRanges', comp, options)
|
|
return comp.split(/\s+/).map(function (comp) {
|
|
return replaceXRange(comp, options)
|
|
}).join(' ')
|
|
}
|
|
|
|
function replaceXRange (comp, options) {
|
|
comp = comp.trim()
|
|
var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]
|
|
return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
|
|
debug('xRange', comp, ret, gtlt, M, m, p, pr)
|
|
var xM = isX(M)
|
|
var xm = xM || isX(m)
|
|
var xp = xm || isX(p)
|
|
var anyX = xp
|
|
|
|
if (gtlt === '=' && anyX) {
|
|
gtlt = ''
|
|
}
|
|
|
|
// if we're including prereleases in the match, then we need
|
|
// to fix this to -0, the lowest possible prerelease value
|
|
pr = options.includePrerelease ? '-0' : ''
|
|
|
|
if (xM) {
|
|
if (gtlt === '>' || gtlt === '<') {
|
|
// nothing is allowed
|
|
ret = '<0.0.0-0'
|
|
} else {
|
|
// nothing is forbidden
|
|
ret = '*'
|
|
}
|
|
} else if (gtlt && anyX) {
|
|
// we know patch is an x, because we have any x at all.
|
|
// replace X with 0
|
|
if (xm) {
|
|
m = 0
|
|
}
|
|
p = 0
|
|
|
|
if (gtlt === '>') {
|
|
// >1 => >=2.0.0
|
|
// >1.2 => >=1.3.0
|
|
// >1.2.3 => >= 1.2.4
|
|
gtlt = '>='
|
|
if (xm) {
|
|
M = +M + 1
|
|
m = 0
|
|
p = 0
|
|
} else {
|
|
m = +m + 1
|
|
p = 0
|
|
}
|
|
} else if (gtlt === '<=') {
|
|
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
|
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
|
gtlt = '<'
|
|
if (xm) {
|
|
M = +M + 1
|
|
} else {
|
|
m = +m + 1
|
|
}
|
|
}
|
|
|
|
ret = gtlt + M + '.' + m + '.' + p + pr
|
|
} else if (xm) {
|
|
ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr
|
|
} else if (xp) {
|
|
ret = '>=' + M + '.' + m + '.0' + pr +
|
|
' <' + M + '.' + (+m + 1) + '.0' + pr
|
|
}
|
|
|
|
debug('xRange return', ret)
|
|
|
|
return ret
|
|
})
|
|
}
|
|
|
|
// Because * is AND-ed with everything else in the comparator,
|
|
// and '' means "any version", just remove the *s entirely.
|
|
function replaceStars (comp, options) {
|
|
debug('replaceStars', comp, options)
|
|
// Looseness is ignored here. star is always as loose as it gets!
|
|
return comp.trim().replace(re[t.STAR], '')
|
|
}
|
|
|
|
// This function is passed to string.replace(re[t.HYPHENRANGE])
|
|
// M, m, patch, prerelease, build
|
|
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
|
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
|
|
// 1.2 - 3.4 => >=1.2.0 <3.5.0
|
|
function hyphenReplace ($0,
|
|
from, fM, fm, fp, fpr, fb,
|
|
to, tM, tm, tp, tpr, tb) {
|
|
if (isX(fM)) {
|
|
from = ''
|
|
} else if (isX(fm)) {
|
|
from = '>=' + fM + '.0.0'
|
|
} else if (isX(fp)) {
|
|
from = '>=' + fM + '.' + fm + '.0'
|
|
} else {
|
|
from = '>=' + from
|
|
}
|
|
|
|
if (isX(tM)) {
|
|
to = ''
|
|
} else if (isX(tm)) {
|
|
to = '<' + (+tM + 1) + '.0.0'
|
|
} else if (isX(tp)) {
|
|
to = '<' + tM + '.' + (+tm + 1) + '.0'
|
|
} else if (tpr) {
|
|
to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr
|
|
} else {
|
|
to = '<=' + to
|
|
}
|
|
|
|
return (from + ' ' + to).trim()
|
|
}
|
|
|
|
// if ANY of the sets match ALL of its comparators, then pass
|
|
Range.prototype.test = function (version) {
|
|
if (!version) {
|
|
return false
|
|
}
|
|
|
|
if (typeof version === 'string') {
|
|
try {
|
|
version = new SemVer(version, this.options)
|
|
} catch (er) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
for (var i = 0; i < this.set.length; i++) {
|
|
if (testSet(this.set[i], version, this.options)) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
function testSet (set, version, options) {
|
|
for (var i = 0; i < set.length; i++) {
|
|
if (!set[i].test(version)) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
if (version.prerelease.length && !options.includePrerelease) {
|
|
// Find the set of versions that are allowed to have prereleases
|
|
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
|
// That should allow `1.2.3-pr.2` to pass.
|
|
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
|
// even though it's within the range set by the comparators.
|
|
for (i = 0; i < set.length; i++) {
|
|
debug(set[i].semver)
|
|
if (set[i].semver === ANY) {
|
|
continue
|
|
}
|
|
|
|
if (set[i].semver.prerelease.length > 0) {
|
|
var allowed = set[i].semver
|
|
if (allowed.major === version.major &&
|
|
allowed.minor === version.minor &&
|
|
allowed.patch === version.patch) {
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
|
|
// Version has a -pre, but it's not one of the ones we like.
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
exports.satisfies = satisfies
|
|
function satisfies (version, range, options) {
|
|
try {
|
|
range = new Range(range, options)
|
|
} catch (er) {
|
|
return false
|
|
}
|
|
return range.test(version)
|
|
}
|
|
|
|
exports.maxSatisfying = maxSatisfying
|
|
function maxSatisfying (versions, range, options) {
|
|
var max = null
|
|
var maxSV = null
|
|
try {
|
|
var rangeObj = new Range(range, options)
|
|
} catch (er) {
|
|
return null
|
|
}
|
|
versions.forEach(function (v) {
|
|
if (rangeObj.test(v)) {
|
|
// satisfies(v, range, options)
|
|
if (!max || maxSV.compare(v) === -1) {
|
|
// compare(max, v, true)
|
|
max = v
|
|
maxSV = new SemVer(max, options)
|
|
}
|
|
}
|
|
})
|
|
return max
|
|
}
|
|
|
|
exports.minSatisfying = minSatisfying
|
|
function minSatisfying (versions, range, options) {
|
|
var min = null
|
|
var minSV = null
|
|
try {
|
|
var rangeObj = new Range(range, options)
|
|
} catch (er) {
|
|
return null
|
|
}
|
|
versions.forEach(function (v) {
|
|
if (rangeObj.test(v)) {
|
|
// satisfies(v, range, options)
|
|
if (!min || minSV.compare(v) === 1) {
|
|
// compare(min, v, true)
|
|
min = v
|
|
minSV = new SemVer(min, options)
|
|
}
|
|
}
|
|
})
|
|
return min
|
|
}
|
|
|
|
exports.minVersion = minVersion
|
|
function minVersion (range, loose) {
|
|
range = new Range(range, loose)
|
|
|
|
var minver = new SemVer('0.0.0')
|
|
if (range.test(minver)) {
|
|
return minver
|
|
}
|
|
|
|
minver = new SemVer('0.0.0-0')
|
|
if (range.test(minver)) {
|
|
return minver
|
|
}
|
|
|
|
minver = null
|
|
for (var i = 0; i < range.set.length; ++i) {
|
|
var comparators = range.set[i]
|
|
|
|
comparators.forEach(function (comparator) {
|
|
// Clone to avoid manipulating the comparator's semver object.
|
|
var compver = new SemVer(comparator.semver.version)
|
|
switch (comparator.operator) {
|
|
case '>':
|
|
if (compver.prerelease.length === 0) {
|
|
compver.patch++
|
|
} else {
|
|
compver.prerelease.push(0)
|
|
}
|
|
compver.raw = compver.format()
|
|
/* fallthrough */
|
|
case '':
|
|
case '>=':
|
|
if (!minver || gt(minver, compver)) {
|
|
minver = compver
|
|
}
|
|
break
|
|
case '<':
|
|
case '<=':
|
|
/* Ignore maximum versions */
|
|
break
|
|
/* istanbul ignore next */
|
|
default:
|
|
throw new Error('Unexpected operation: ' + comparator.operator)
|
|
}
|
|
})
|
|
}
|
|
|
|
if (minver && range.test(minver)) {
|
|
return minver
|
|
}
|
|
|
|
return null
|
|
}
|
|
|
|
exports.validRange = validRange
|
|
function validRange (range, options) {
|
|
try {
|
|
// Return '*' instead of '' so that truthiness works.
|
|
// This will throw if it's invalid anyway
|
|
return new Range(range, options).range || '*'
|
|
} catch (er) {
|
|
return null
|
|
}
|
|
}
|
|
|
|
// Determine if version is less than all the versions possible in the range
|
|
exports.ltr = ltr
|
|
function ltr (version, range, options) {
|
|
return outside(version, range, '<', options)
|
|
}
|
|
|
|
// Determine if version is greater than all the versions possible in the range.
|
|
exports.gtr = gtr
|
|
function gtr (version, range, options) {
|
|
return outside(version, range, '>', options)
|
|
}
|
|
|
|
exports.outside = outside
|
|
function outside (version, range, hilo, options) {
|
|
version = new SemVer(version, options)
|
|
range = new Range(range, options)
|
|
|
|
var gtfn, ltefn, ltfn, comp, ecomp
|
|
switch (hilo) {
|
|
case '>':
|
|
gtfn = gt
|
|
ltefn = lte
|
|
ltfn = lt
|
|
comp = '>'
|
|
ecomp = '>='
|
|
break
|
|
case '<':
|
|
gtfn = lt
|
|
ltefn = gte
|
|
ltfn = gt
|
|
comp = '<'
|
|
ecomp = '<='
|
|
break
|
|
default:
|
|
throw new TypeError('Must provide a hilo val of "<" or ">"')
|
|
}
|
|
|
|
// If it satisifes the range it is not outside
|
|
if (satisfies(version, range, options)) {
|
|
return false
|
|
}
|
|
|
|
// From now on, variable terms are as if we're in "gtr" mode.
|
|
// but note that everything is flipped for the "ltr" function.
|
|
|
|
for (var i = 0; i < range.set.length; ++i) {
|
|
var comparators = range.set[i]
|
|
|
|
var high = null
|
|
var low = null
|
|
|
|
comparators.forEach(function (comparator) {
|
|
if (comparator.semver === ANY) {
|
|
comparator = new Comparator('>=0.0.0')
|
|
}
|
|
high = high || comparator
|
|
low = low || comparator
|
|
if (gtfn(comparator.semver, high.semver, options)) {
|
|
high = comparator
|
|
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
low = comparator
|
|
}
|
|
})
|
|
|
|
// If the edge version comparator has a operator then our version
|
|
// isn't outside it
|
|
if (high.operator === comp || high.operator === ecomp) {
|
|
return false
|
|
}
|
|
|
|
// If the lowest version comparator has an operator and our version
|
|
// is less than it then it isn't higher than the range
|
|
if ((!low.operator || low.operator === comp) &&
|
|
ltefn(version, low.semver)) {
|
|
return false
|
|
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
exports.prerelease = prerelease
|
|
function prerelease (version, options) {
|
|
var parsed = parse(version, options)
|
|
return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
|
|
}
|
|
|
|
exports.intersects = intersects
|
|
function intersects (r1, r2, options) {
|
|
r1 = new Range(r1, options)
|
|
r2 = new Range(r2, options)
|
|
return r1.intersects(r2)
|
|
}
|
|
|
|
exports.coerce = coerce
|
|
function coerce (version, options) {
|
|
if (version instanceof SemVer) {
|
|
return version
|
|
}
|
|
|
|
if (typeof version === 'number') {
|
|
version = String(version)
|
|
}
|
|
|
|
if (typeof version !== 'string') {
|
|
return null
|
|
}
|
|
|
|
options = options || {}
|
|
|
|
var match = null
|
|
if (!options.rtl) {
|
|
match = version.match(re[t.COERCE])
|
|
} else {
|
|
// Find the right-most coercible string that does not share
|
|
// a terminus with a more left-ward coercible string.
|
|
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
|
|
//
|
|
// Walk through the string checking with a /g regexp
|
|
// Manually set the index so as to pick up overlapping matches.
|
|
// Stop when we get a match that ends at the string end, since no
|
|
// coercible string can be more right-ward without the same terminus.
|
|
var next
|
|
while ((next = re[t.COERCERTL].exec(version)) &&
|
|
(!match || match.index + match[0].length !== version.length)
|
|
) {
|
|
if (!match ||
|
|
next.index + next[0].length !== match.index + match[0].length) {
|
|
match = next
|
|
}
|
|
re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length
|
|
}
|
|
// leave it in a clean state
|
|
re[t.COERCERTL].lastIndex = -1
|
|
}
|
|
|
|
if (match === null) {
|
|
return null
|
|
}
|
|
|
|
return parse(match[2] +
|
|
'.' + (match[3] || '0') +
|
|
'.' + (match[4] || '0'), options)
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 285:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
module.exports = input => {
|
|
const buf = new Uint8Array(input);
|
|
|
|
if (!(buf && buf.length > 1)) {
|
|
return null;
|
|
}
|
|
|
|
const check = (header, opts) => {
|
|
opts = Object.assign({
|
|
offset: 0
|
|
}, opts);
|
|
|
|
for (let i = 0; i < header.length; i++) {
|
|
if (header[i] !== buf[i + opts.offset]) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
if (check([0xFF, 0xD8, 0xFF])) {
|
|
return {
|
|
ext: 'jpg',
|
|
mime: 'image/jpeg'
|
|
};
|
|
}
|
|
|
|
if (check([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])) {
|
|
return {
|
|
ext: 'png',
|
|
mime: 'image/png'
|
|
};
|
|
}
|
|
|
|
if (check([0x47, 0x49, 0x46])) {
|
|
return {
|
|
ext: 'gif',
|
|
mime: 'image/gif'
|
|
};
|
|
}
|
|
|
|
if (check([0x57, 0x45, 0x42, 0x50], {offset: 8})) {
|
|
return {
|
|
ext: 'webp',
|
|
mime: 'image/webp'
|
|
};
|
|
}
|
|
|
|
if (check([0x46, 0x4C, 0x49, 0x46])) {
|
|
return {
|
|
ext: 'flif',
|
|
mime: 'image/flif'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `tif` check
|
|
if (
|
|
(check([0x49, 0x49, 0x2A, 0x0]) || check([0x4D, 0x4D, 0x0, 0x2A])) &&
|
|
check([0x43, 0x52], {offset: 8})
|
|
) {
|
|
return {
|
|
ext: 'cr2',
|
|
mime: 'image/x-canon-cr2'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x49, 0x49, 0x2A, 0x0]) ||
|
|
check([0x4D, 0x4D, 0x0, 0x2A])
|
|
) {
|
|
return {
|
|
ext: 'tif',
|
|
mime: 'image/tiff'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x4D])) {
|
|
return {
|
|
ext: 'bmp',
|
|
mime: 'image/bmp'
|
|
};
|
|
}
|
|
|
|
if (check([0x49, 0x49, 0xBC])) {
|
|
return {
|
|
ext: 'jxr',
|
|
mime: 'image/vnd.ms-photo'
|
|
};
|
|
}
|
|
|
|
if (check([0x38, 0x42, 0x50, 0x53])) {
|
|
return {
|
|
ext: 'psd',
|
|
mime: 'image/vnd.adobe.photoshop'
|
|
};
|
|
}
|
|
|
|
// Needs to be before the `zip` check
|
|
if (
|
|
check([0x50, 0x4B, 0x3, 0x4]) &&
|
|
check([0x6D, 0x69, 0x6D, 0x65, 0x74, 0x79, 0x70, 0x65, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x65, 0x70, 0x75, 0x62, 0x2B, 0x7A, 0x69, 0x70], {offset: 30})
|
|
) {
|
|
return {
|
|
ext: 'epub',
|
|
mime: 'application/epub+zip'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `zip` check
|
|
// Assumes signed `.xpi` from addons.mozilla.org
|
|
if (
|
|
check([0x50, 0x4B, 0x3, 0x4]) &&
|
|
check([0x4D, 0x45, 0x54, 0x41, 0x2D, 0x49, 0x4E, 0x46, 0x2F, 0x6D, 0x6F, 0x7A, 0x69, 0x6C, 0x6C, 0x61, 0x2E, 0x72, 0x73, 0x61], {offset: 30})
|
|
) {
|
|
return {
|
|
ext: 'xpi',
|
|
mime: 'application/x-xpinstall'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x50, 0x4B]) &&
|
|
(buf[2] === 0x3 || buf[2] === 0x5 || buf[2] === 0x7) &&
|
|
(buf[3] === 0x4 || buf[3] === 0x6 || buf[3] === 0x8)
|
|
) {
|
|
return {
|
|
ext: 'zip',
|
|
mime: 'application/zip'
|
|
};
|
|
}
|
|
|
|
if (check([0x75, 0x73, 0x74, 0x61, 0x72], {offset: 257})) {
|
|
return {
|
|
ext: 'tar',
|
|
mime: 'application/x-tar'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x52, 0x61, 0x72, 0x21, 0x1A, 0x7]) &&
|
|
(buf[6] === 0x0 || buf[6] === 0x1)
|
|
) {
|
|
return {
|
|
ext: 'rar',
|
|
mime: 'application/x-rar-compressed'
|
|
};
|
|
}
|
|
|
|
if (check([0x1F, 0x8B, 0x8])) {
|
|
return {
|
|
ext: 'gz',
|
|
mime: 'application/gzip'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x5A, 0x68])) {
|
|
return {
|
|
ext: 'bz2',
|
|
mime: 'application/x-bzip2'
|
|
};
|
|
}
|
|
|
|
if (check([0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C])) {
|
|
return {
|
|
ext: '7z',
|
|
mime: 'application/x-7z-compressed'
|
|
};
|
|
}
|
|
|
|
if (check([0x78, 0x01])) {
|
|
return {
|
|
ext: 'dmg',
|
|
mime: 'application/x-apple-diskimage'
|
|
};
|
|
}
|
|
|
|
if (
|
|
(
|
|
check([0x0, 0x0, 0x0]) &&
|
|
(buf[3] === 0x18 || buf[3] === 0x20) &&
|
|
check([0x66, 0x74, 0x79, 0x70], {offset: 4})
|
|
) ||
|
|
check([0x33, 0x67, 0x70, 0x35]) ||
|
|
(
|
|
check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x6D, 0x70, 0x34, 0x32]) &&
|
|
check([0x6D, 0x70, 0x34, 0x31, 0x6D, 0x70, 0x34, 0x32, 0x69, 0x73, 0x6F, 0x6D], {offset: 16})
|
|
) ||
|
|
check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x69, 0x73, 0x6F, 0x6D]) ||
|
|
check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x6D, 0x70, 0x34, 0x32, 0x0, 0x0, 0x0, 0x0])
|
|
) {
|
|
return {
|
|
ext: 'mp4',
|
|
mime: 'video/mp4'
|
|
};
|
|
}
|
|
|
|
if (check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x56])) {
|
|
return {
|
|
ext: 'm4v',
|
|
mime: 'video/x-m4v'
|
|
};
|
|
}
|
|
|
|
if (check([0x4D, 0x54, 0x68, 0x64])) {
|
|
return {
|
|
ext: 'mid',
|
|
mime: 'audio/midi'
|
|
};
|
|
}
|
|
|
|
// https://github.com/threatstack/libmagic/blob/master/magic/Magdir/matroska
|
|
if (check([0x1A, 0x45, 0xDF, 0xA3])) {
|
|
const sliced = buf.subarray(4, 4 + 4096);
|
|
const idPos = sliced.findIndex((el, i, arr) => arr[i] === 0x42 && arr[i + 1] === 0x82);
|
|
|
|
if (idPos >= 0) {
|
|
const docTypePos = idPos + 3;
|
|
const findDocType = type => Array.from(type).every((c, i) => sliced[docTypePos + i] === c.charCodeAt(0));
|
|
|
|
if (findDocType('matroska')) {
|
|
return {
|
|
ext: 'mkv',
|
|
mime: 'video/x-matroska'
|
|
};
|
|
}
|
|
|
|
if (findDocType('webm')) {
|
|
return {
|
|
ext: 'webm',
|
|
mime: 'video/webm'
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
if (check([0x0, 0x0, 0x0, 0x14, 0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20]) ||
|
|
check([0x66, 0x72, 0x65, 0x65], {offset: 4}) ||
|
|
check([0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20], {offset: 4}) ||
|
|
check([0x6D, 0x64, 0x61, 0x74], {offset: 4}) || // MJPEG
|
|
check([0x77, 0x69, 0x64, 0x65], {offset: 4})) {
|
|
return {
|
|
ext: 'mov',
|
|
mime: 'video/quicktime'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x52, 0x49, 0x46, 0x46]) &&
|
|
check([0x41, 0x56, 0x49], {offset: 8})
|
|
) {
|
|
return {
|
|
ext: 'avi',
|
|
mime: 'video/x-msvideo'
|
|
};
|
|
}
|
|
|
|
if (check([0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xA6, 0xD9])) {
|
|
return {
|
|
ext: 'wmv',
|
|
mime: 'video/x-ms-wmv'
|
|
};
|
|
}
|
|
|
|
if (check([0x0, 0x0, 0x1, 0xBA])) {
|
|
return {
|
|
ext: 'mpg',
|
|
mime: 'video/mpeg'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x49, 0x44, 0x33]) ||
|
|
check([0xFF, 0xFB])
|
|
) {
|
|
return {
|
|
ext: 'mp3',
|
|
mime: 'audio/mpeg'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41], {offset: 4}) ||
|
|
check([0x4D, 0x34, 0x41, 0x20])
|
|
) {
|
|
return {
|
|
ext: 'm4a',
|
|
mime: 'audio/m4a'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `ogg` check
|
|
if (check([0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64], {offset: 28})) {
|
|
return {
|
|
ext: 'opus',
|
|
mime: 'audio/opus'
|
|
};
|
|
}
|
|
|
|
if (check([0x4F, 0x67, 0x67, 0x53])) {
|
|
return {
|
|
ext: 'ogg',
|
|
mime: 'audio/ogg'
|
|
};
|
|
}
|
|
|
|
if (check([0x66, 0x4C, 0x61, 0x43])) {
|
|
return {
|
|
ext: 'flac',
|
|
mime: 'audio/x-flac'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x52, 0x49, 0x46, 0x46]) &&
|
|
check([0x57, 0x41, 0x56, 0x45], {offset: 8})
|
|
) {
|
|
return {
|
|
ext: 'wav',
|
|
mime: 'audio/x-wav'
|
|
};
|
|
}
|
|
|
|
if (check([0x23, 0x21, 0x41, 0x4D, 0x52, 0x0A])) {
|
|
return {
|
|
ext: 'amr',
|
|
mime: 'audio/amr'
|
|
};
|
|
}
|
|
|
|
if (check([0x25, 0x50, 0x44, 0x46])) {
|
|
return {
|
|
ext: 'pdf',
|
|
mime: 'application/pdf'
|
|
};
|
|
}
|
|
|
|
if (check([0x4D, 0x5A])) {
|
|
return {
|
|
ext: 'exe',
|
|
mime: 'application/x-msdownload'
|
|
};
|
|
}
|
|
|
|
if (
|
|
(buf[0] === 0x43 || buf[0] === 0x46) &&
|
|
check([0x57, 0x53], {offset: 1})
|
|
) {
|
|
return {
|
|
ext: 'swf',
|
|
mime: 'application/x-shockwave-flash'
|
|
};
|
|
}
|
|
|
|
if (check([0x7B, 0x5C, 0x72, 0x74, 0x66])) {
|
|
return {
|
|
ext: 'rtf',
|
|
mime: 'application/rtf'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x61, 0x73, 0x6D])) {
|
|
return {
|
|
ext: 'wasm',
|
|
mime: 'application/wasm'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x77, 0x4F, 0x46, 0x46]) &&
|
|
(
|
|
check([0x00, 0x01, 0x00, 0x00], {offset: 4}) ||
|
|
check([0x4F, 0x54, 0x54, 0x4F], {offset: 4})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'woff',
|
|
mime: 'font/woff'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x77, 0x4F, 0x46, 0x32]) &&
|
|
(
|
|
check([0x00, 0x01, 0x00, 0x00], {offset: 4}) ||
|
|
check([0x4F, 0x54, 0x54, 0x4F], {offset: 4})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'woff2',
|
|
mime: 'font/woff2'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x4C, 0x50], {offset: 34}) &&
|
|
(
|
|
check([0x00, 0x00, 0x01], {offset: 8}) ||
|
|
check([0x01, 0x00, 0x02], {offset: 8}) ||
|
|
check([0x02, 0x00, 0x02], {offset: 8})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'eot',
|
|
mime: 'application/octet-stream'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x01, 0x00, 0x00, 0x00])) {
|
|
return {
|
|
ext: 'ttf',
|
|
mime: 'font/ttf'
|
|
};
|
|
}
|
|
|
|
if (check([0x4F, 0x54, 0x54, 0x4F, 0x00])) {
|
|
return {
|
|
ext: 'otf',
|
|
mime: 'font/otf'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x00, 0x01, 0x00])) {
|
|
return {
|
|
ext: 'ico',
|
|
mime: 'image/x-icon'
|
|
};
|
|
}
|
|
|
|
if (check([0x46, 0x4C, 0x56, 0x01])) {
|
|
return {
|
|
ext: 'flv',
|
|
mime: 'video/x-flv'
|
|
};
|
|
}
|
|
|
|
if (check([0x25, 0x21])) {
|
|
return {
|
|
ext: 'ps',
|
|
mime: 'application/postscript'
|
|
};
|
|
}
|
|
|
|
if (check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) {
|
|
return {
|
|
ext: 'xz',
|
|
mime: 'application/x-xz'
|
|
};
|
|
}
|
|
|
|
if (check([0x53, 0x51, 0x4C, 0x69])) {
|
|
return {
|
|
ext: 'sqlite',
|
|
mime: 'application/x-sqlite3'
|
|
};
|
|
}
|
|
|
|
if (check([0x4E, 0x45, 0x53, 0x1A])) {
|
|
return {
|
|
ext: 'nes',
|
|
mime: 'application/x-nintendo-nes-rom'
|
|
};
|
|
}
|
|
|
|
if (check([0x43, 0x72, 0x32, 0x34])) {
|
|
return {
|
|
ext: 'crx',
|
|
mime: 'application/x-google-chrome-extension'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x4D, 0x53, 0x43, 0x46]) ||
|
|
check([0x49, 0x53, 0x63, 0x28])
|
|
) {
|
|
return {
|
|
ext: 'cab',
|
|
mime: 'application/vnd.ms-cab-compressed'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `ar` check
|
|
if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E, 0x0A, 0x64, 0x65, 0x62, 0x69, 0x61, 0x6E, 0x2D, 0x62, 0x69, 0x6E, 0x61, 0x72, 0x79])) {
|
|
return {
|
|
ext: 'deb',
|
|
mime: 'application/x-deb'
|
|
};
|
|
}
|
|
|
|
if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E])) {
|
|
return {
|
|
ext: 'ar',
|
|
mime: 'application/x-unix-archive'
|
|
};
|
|
}
|
|
|
|
if (check([0xED, 0xAB, 0xEE, 0xDB])) {
|
|
return {
|
|
ext: 'rpm',
|
|
mime: 'application/x-rpm'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x1F, 0xA0]) ||
|
|
check([0x1F, 0x9D])
|
|
) {
|
|
return {
|
|
ext: 'Z',
|
|
mime: 'application/x-compress'
|
|
};
|
|
}
|
|
|
|
if (check([0x4C, 0x5A, 0x49, 0x50])) {
|
|
return {
|
|
ext: 'lz',
|
|
mime: 'application/x-lzip'
|
|
};
|
|
}
|
|
|
|
if (check([0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1])) {
|
|
return {
|
|
ext: 'msi',
|
|
mime: 'application/x-msi'
|
|
};
|
|
}
|
|
|
|
if (check([0x06, 0x0E, 0x2B, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0D, 0x01, 0x02, 0x01, 0x01, 0x02])) {
|
|
return {
|
|
ext: 'mxf',
|
|
mime: 'application/mxf'
|
|
};
|
|
}
|
|
|
|
if (check([0x47], {offset: 4}) && (check([0x47], {offset: 192}) || check([0x47], {offset: 196}))) {
|
|
return {
|
|
ext: 'mts',
|
|
mime: 'video/mp2t'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x4C, 0x45, 0x4E, 0x44, 0x45, 0x52])) {
|
|
return {
|
|
ext: 'blend',
|
|
mime: 'application/x-blender'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x50, 0x47, 0xFB])) {
|
|
return {
|
|
ext: 'bpg',
|
|
mime: 'image/bpg'
|
|
};
|
|
}
|
|
|
|
return null;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 286:
|
|
/***/ (function(__unusedmodule, exports) {
|
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
// copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
// following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included
|
|
// in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
// NOTE: These type checking functions intentionally don't use `instanceof`
|
|
// because it is fragile and can be easily faked with `Object.create()`.
|
|
|
|
function isArray(arg) {
|
|
if (Array.isArray) {
|
|
return Array.isArray(arg);
|
|
}
|
|
return objectToString(arg) === '[object Array]';
|
|
}
|
|
exports.isArray = isArray;
|
|
|
|
function isBoolean(arg) {
|
|
return typeof arg === 'boolean';
|
|
}
|
|
exports.isBoolean = isBoolean;
|
|
|
|
function isNull(arg) {
|
|
return arg === null;
|
|
}
|
|
exports.isNull = isNull;
|
|
|
|
function isNullOrUndefined(arg) {
|
|
return arg == null;
|
|
}
|
|
exports.isNullOrUndefined = isNullOrUndefined;
|
|
|
|
function isNumber(arg) {
|
|
return typeof arg === 'number';
|
|
}
|
|
exports.isNumber = isNumber;
|
|
|
|
function isString(arg) {
|
|
return typeof arg === 'string';
|
|
}
|
|
exports.isString = isString;
|
|
|
|
function isSymbol(arg) {
|
|
return typeof arg === 'symbol';
|
|
}
|
|
exports.isSymbol = isSymbol;
|
|
|
|
function isUndefined(arg) {
|
|
return arg === void 0;
|
|
}
|
|
exports.isUndefined = isUndefined;
|
|
|
|
function isRegExp(re) {
|
|
return objectToString(re) === '[object RegExp]';
|
|
}
|
|
exports.isRegExp = isRegExp;
|
|
|
|
function isObject(arg) {
|
|
return typeof arg === 'object' && arg !== null;
|
|
}
|
|
exports.isObject = isObject;
|
|
|
|
function isDate(d) {
|
|
return objectToString(d) === '[object Date]';
|
|
}
|
|
exports.isDate = isDate;
|
|
|
|
function isError(e) {
|
|
return (objectToString(e) === '[object Error]' || e instanceof Error);
|
|
}
|
|
exports.isError = isError;
|
|
|
|
function isFunction(arg) {
|
|
return typeof arg === 'function';
|
|
}
|
|
exports.isFunction = isFunction;
|
|
|
|
function isPrimitive(arg) {
|
|
return arg === null ||
|
|
typeof arg === 'boolean' ||
|
|
typeof arg === 'number' ||
|
|
typeof arg === 'string' ||
|
|
typeof arg === 'symbol' || // ES6 symbol
|
|
typeof arg === 'undefined';
|
|
}
|
|
exports.isPrimitive = isPrimitive;
|
|
|
|
exports.isBuffer = Buffer.isBuffer;
|
|
|
|
function objectToString(o) {
|
|
return Object.prototype.toString.call(o);
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 293:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("buffer");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 303:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
const EventEmitter = __webpack_require__(614);
|
|
const JSONB = __webpack_require__(205);
|
|
|
|
const loadStore = opts => {
|
|
const adapters = {
|
|
redis: '@keyv/redis',
|
|
mongodb: '@keyv/mongo',
|
|
mongo: '@keyv/mongo',
|
|
sqlite: '@keyv/sqlite',
|
|
postgresql: '@keyv/postgres',
|
|
postgres: '@keyv/postgres',
|
|
mysql: '@keyv/mysql'
|
|
};
|
|
if (opts.adapter || opts.uri) {
|
|
const adapter = opts.adapter || /^[^:]*/.exec(opts.uri)[0];
|
|
return new (require(adapters[adapter]))(opts);
|
|
}
|
|
return new Map();
|
|
};
|
|
|
|
class Keyv extends EventEmitter {
|
|
constructor(uri, opts) {
|
|
super();
|
|
this.opts = Object.assign(
|
|
{ namespace: 'keyv' },
|
|
(typeof uri === 'string') ? { uri } : uri,
|
|
opts
|
|
);
|
|
|
|
if (!this.opts.store) {
|
|
const adapterOpts = Object.assign({}, this.opts);
|
|
this.opts.store = loadStore(adapterOpts);
|
|
}
|
|
|
|
if (typeof this.opts.store.on === 'function') {
|
|
this.opts.store.on('error', err => this.emit('error', err));
|
|
}
|
|
|
|
this.opts.store.namespace = this.opts.namespace;
|
|
}
|
|
|
|
_getKeyPrefix(key) {
|
|
return `${this.opts.namespace}:${key}`;
|
|
}
|
|
|
|
get(key) {
|
|
key = this._getKeyPrefix(key);
|
|
const store = this.opts.store;
|
|
return Promise.resolve()
|
|
.then(() => store.get(key))
|
|
.then(data => {
|
|
data = (typeof data === 'string') ? JSONB.parse(data) : data;
|
|
if (data === undefined) {
|
|
return undefined;
|
|
}
|
|
if (typeof data.expires === 'number' && Date.now() > data.expires) {
|
|
this.delete(key);
|
|
return undefined;
|
|
}
|
|
return data.value;
|
|
});
|
|
}
|
|
|
|
set(key, value, ttl) {
|
|
key = this._getKeyPrefix(key);
|
|
if (typeof ttl === 'undefined') {
|
|
ttl = this.opts.ttl;
|
|
}
|
|
if (ttl === 0) {
|
|
ttl = undefined;
|
|
}
|
|
const store = this.opts.store;
|
|
|
|
return Promise.resolve()
|
|
.then(() => {
|
|
const expires = (typeof ttl === 'number') ? (Date.now() + ttl) : null;
|
|
value = { value, expires };
|
|
return store.set(key, JSONB.stringify(value), ttl);
|
|
})
|
|
.then(() => true);
|
|
}
|
|
|
|
delete(key) {
|
|
key = this._getKeyPrefix(key);
|
|
const store = this.opts.store;
|
|
return Promise.resolve()
|
|
.then(() => store.delete(key));
|
|
}
|
|
|
|
clear() {
|
|
const store = this.opts.store;
|
|
return Promise.resolve()
|
|
.then(() => store.clear());
|
|
}
|
|
}
|
|
|
|
module.exports = Keyv;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 304:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("string_decoder");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 308:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var WHITELIST = [
|
|
'ETIMEDOUT',
|
|
'ECONNRESET',
|
|
'EADDRINUSE',
|
|
'ESOCKETTIMEDOUT',
|
|
'ECONNREFUSED',
|
|
'EPIPE',
|
|
'EHOSTUNREACH',
|
|
'EAI_AGAIN'
|
|
];
|
|
|
|
var BLACKLIST = [
|
|
'ENOTFOUND',
|
|
'ENETUNREACH',
|
|
|
|
// SSL errors from https://github.com/nodejs/node/blob/ed3d8b13ee9a705d89f9e0397d9e96519e7e47ac/src/node_crypto.cc#L1950
|
|
'UNABLE_TO_GET_ISSUER_CERT',
|
|
'UNABLE_TO_GET_CRL',
|
|
'UNABLE_TO_DECRYPT_CERT_SIGNATURE',
|
|
'UNABLE_TO_DECRYPT_CRL_SIGNATURE',
|
|
'UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY',
|
|
'CERT_SIGNATURE_FAILURE',
|
|
'CRL_SIGNATURE_FAILURE',
|
|
'CERT_NOT_YET_VALID',
|
|
'CERT_HAS_EXPIRED',
|
|
'CRL_NOT_YET_VALID',
|
|
'CRL_HAS_EXPIRED',
|
|
'ERROR_IN_CERT_NOT_BEFORE_FIELD',
|
|
'ERROR_IN_CERT_NOT_AFTER_FIELD',
|
|
'ERROR_IN_CRL_LAST_UPDATE_FIELD',
|
|
'ERROR_IN_CRL_NEXT_UPDATE_FIELD',
|
|
'OUT_OF_MEM',
|
|
'DEPTH_ZERO_SELF_SIGNED_CERT',
|
|
'SELF_SIGNED_CERT_IN_CHAIN',
|
|
'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
|
|
'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
|
|
'CERT_CHAIN_TOO_LONG',
|
|
'CERT_REVOKED',
|
|
'INVALID_CA',
|
|
'PATH_LENGTH_EXCEEDED',
|
|
'INVALID_PURPOSE',
|
|
'CERT_UNTRUSTED',
|
|
'CERT_REJECTED'
|
|
];
|
|
|
|
module.exports = function (err) {
|
|
if (!err || !err.code) {
|
|
return true;
|
|
}
|
|
|
|
if (WHITELIST.indexOf(err.code) !== -1) {
|
|
return true;
|
|
}
|
|
|
|
if (BLACKLIST.indexOf(err.code) !== -1) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 309:
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
/* eslint-disable node/no-deprecated-api */
|
|
var buffer = __webpack_require__(293)
|
|
var Buffer = buffer.Buffer
|
|
|
|
// alternative to using Object.keys for old browsers
|
|
function copyProps (src, dst) {
|
|
for (var key in src) {
|
|
dst[key] = src[key]
|
|
}
|
|
}
|
|
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
|
module.exports = buffer
|
|
} else {
|
|
// Copy properties from require('buffer')
|
|
copyProps(buffer, exports)
|
|
exports.Buffer = SafeBuffer
|
|
}
|
|
|
|
function SafeBuffer (arg, encodingOrOffset, length) {
|
|
return Buffer(arg, encodingOrOffset, length)
|
|
}
|
|
|
|
// Copy static methods from Buffer
|
|
copyProps(Buffer, SafeBuffer)
|
|
|
|
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
|
if (typeof arg === 'number') {
|
|
throw new TypeError('Argument must not be a number')
|
|
}
|
|
return Buffer(arg, encodingOrOffset, length)
|
|
}
|
|
|
|
SafeBuffer.alloc = function (size, fill, encoding) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('Argument must be a number')
|
|
}
|
|
var buf = Buffer(size)
|
|
if (fill !== undefined) {
|
|
if (typeof encoding === 'string') {
|
|
buf.fill(fill, encoding)
|
|
} else {
|
|
buf.fill(fill)
|
|
}
|
|
} else {
|
|
buf.fill(0)
|
|
}
|
|
return buf
|
|
}
|
|
|
|
SafeBuffer.allocUnsafe = function (size) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('Argument must be a number')
|
|
}
|
|
return Buffer(size)
|
|
}
|
|
|
|
SafeBuffer.allocUnsafeSlow = function (size) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('Argument must be a number')
|
|
}
|
|
return buffer.SlowBuffer(size)
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 315:
|
|
/***/ (function(module) {
|
|
|
|
if (typeof Object.create === 'function') {
|
|
// implementation from standard node.js 'util' module
|
|
module.exports = function inherits(ctor, superCtor) {
|
|
if (superCtor) {
|
|
ctor.super_ = superCtor
|
|
ctor.prototype = Object.create(superCtor.prototype, {
|
|
constructor: {
|
|
value: ctor,
|
|
enumerable: false,
|
|
writable: true,
|
|
configurable: true
|
|
}
|
|
})
|
|
}
|
|
};
|
|
} else {
|
|
// old school shim for old browsers
|
|
module.exports = function inherits(ctor, superCtor) {
|
|
if (superCtor) {
|
|
ctor.super_ = superCtor
|
|
var TempCtor = function () {}
|
|
TempCtor.prototype = superCtor.prototype
|
|
ctor.prototype = new TempCtor()
|
|
ctor.prototype.constructor = ctor
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 317:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var PassThrough = __webpack_require__(413).PassThrough;
|
|
var objectAssign = __webpack_require__(999);
|
|
|
|
module.exports = function (opts) {
|
|
opts = objectAssign({}, opts);
|
|
|
|
var array = opts.array;
|
|
var encoding = opts.encoding;
|
|
|
|
var buffer = encoding === 'buffer';
|
|
var objectMode = false;
|
|
|
|
if (array) {
|
|
objectMode = !(encoding || buffer);
|
|
} else {
|
|
encoding = encoding || 'utf8';
|
|
}
|
|
|
|
if (buffer) {
|
|
encoding = null;
|
|
}
|
|
|
|
var len = 0;
|
|
var ret = [];
|
|
|
|
var stream = new PassThrough({objectMode: objectMode});
|
|
|
|
if (encoding) {
|
|
stream.setEncoding(encoding);
|
|
}
|
|
|
|
stream.on('data', function (chunk) {
|
|
ret.push(chunk);
|
|
|
|
if (objectMode) {
|
|
len = ret.length;
|
|
} else {
|
|
len += chunk.length;
|
|
}
|
|
});
|
|
|
|
stream.getBufferedValue = function () {
|
|
if (array) {
|
|
return ret;
|
|
}
|
|
return buffer ? Buffer.concat(ret, len) : ret.join('');
|
|
};
|
|
|
|
stream.getBufferedLength = function () {
|
|
return len;
|
|
};
|
|
|
|
return stream;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 321:
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
/* eslint-disable node/no-deprecated-api */
|
|
var buffer = __webpack_require__(293)
|
|
var Buffer = buffer.Buffer
|
|
|
|
// alternative to using Object.keys for old browsers
|
|
function copyProps (src, dst) {
|
|
for (var key in src) {
|
|
dst[key] = src[key]
|
|
}
|
|
}
|
|
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
|
module.exports = buffer
|
|
} else {
|
|
// Copy properties from require('buffer')
|
|
copyProps(buffer, exports)
|
|
exports.Buffer = SafeBuffer
|
|
}
|
|
|
|
function SafeBuffer (arg, encodingOrOffset, length) {
|
|
return Buffer(arg, encodingOrOffset, length)
|
|
}
|
|
|
|
// Copy static methods from Buffer
|
|
copyProps(Buffer, SafeBuffer)
|
|
|
|
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
|
if (typeof arg === 'number') {
|
|
throw new TypeError('Argument must not be a number')
|
|
}
|
|
return Buffer(arg, encodingOrOffset, length)
|
|
}
|
|
|
|
SafeBuffer.alloc = function (size, fill, encoding) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('Argument must be a number')
|
|
}
|
|
var buf = Buffer(size)
|
|
if (fill !== undefined) {
|
|
if (typeof encoding === 'string') {
|
|
buf.fill(fill, encoding)
|
|
} else {
|
|
buf.fill(fill)
|
|
}
|
|
} else {
|
|
buf.fill(0)
|
|
}
|
|
return buf
|
|
}
|
|
|
|
SafeBuffer.allocUnsafe = function (size) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('Argument must be a number')
|
|
}
|
|
return Buffer(size)
|
|
}
|
|
|
|
SafeBuffer.allocUnsafeSlow = function (size) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('Argument must be a number')
|
|
}
|
|
return buffer.SlowBuffer(size)
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 323:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var isStream = module.exports = function (stream) {
|
|
return stream !== null && typeof stream === 'object' && typeof stream.pipe === 'function';
|
|
};
|
|
|
|
isStream.writable = function (stream) {
|
|
return isStream(stream) && stream.writable !== false && typeof stream._write === 'function' && typeof stream._writableState === 'object';
|
|
};
|
|
|
|
isStream.readable = function (stream) {
|
|
return isStream(stream) && stream.readable !== false && typeof stream._read === 'function' && typeof stream._readableState === 'object';
|
|
};
|
|
|
|
isStream.duplex = function (stream) {
|
|
return isStream.writable(stream) && isStream.readable(stream);
|
|
};
|
|
|
|
isStream.transform = function (stream) {
|
|
return isStream.duplex(stream) && typeof stream._transform === 'function' && typeof stream._transformState === 'object';
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 324:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
var fs = __webpack_require__(747);
|
|
var util = __webpack_require__(669);
|
|
var stream = __webpack_require__(413);
|
|
var Readable = stream.Readable;
|
|
var Writable = stream.Writable;
|
|
var PassThrough = stream.PassThrough;
|
|
var Pend = __webpack_require__(965);
|
|
var EventEmitter = __webpack_require__(614).EventEmitter;
|
|
|
|
exports.createFromBuffer = createFromBuffer;
|
|
exports.createFromFd = createFromFd;
|
|
exports.BufferSlicer = BufferSlicer;
|
|
exports.FdSlicer = FdSlicer;
|
|
|
|
util.inherits(FdSlicer, EventEmitter);
|
|
function FdSlicer(fd, options) {
|
|
options = options || {};
|
|
EventEmitter.call(this);
|
|
|
|
this.fd = fd;
|
|
this.pend = new Pend();
|
|
this.pend.max = 1;
|
|
this.refCount = 0;
|
|
this.autoClose = !!options.autoClose;
|
|
}
|
|
|
|
FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
var self = this;
|
|
self.pend.go(function(cb) {
|
|
fs.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer) {
|
|
cb();
|
|
callback(err, bytesRead, buffer);
|
|
});
|
|
});
|
|
};
|
|
|
|
FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
var self = this;
|
|
self.pend.go(function(cb) {
|
|
fs.write(self.fd, buffer, offset, length, position, function(err, written, buffer) {
|
|
cb();
|
|
callback(err, written, buffer);
|
|
});
|
|
});
|
|
};
|
|
|
|
FdSlicer.prototype.createReadStream = function(options) {
|
|
return new ReadStream(this, options);
|
|
};
|
|
|
|
FdSlicer.prototype.createWriteStream = function(options) {
|
|
return new WriteStream(this, options);
|
|
};
|
|
|
|
FdSlicer.prototype.ref = function() {
|
|
this.refCount += 1;
|
|
};
|
|
|
|
FdSlicer.prototype.unref = function() {
|
|
var self = this;
|
|
self.refCount -= 1;
|
|
|
|
if (self.refCount > 0) return;
|
|
if (self.refCount < 0) throw new Error("invalid unref");
|
|
|
|
if (self.autoClose) {
|
|
fs.close(self.fd, onCloseDone);
|
|
}
|
|
|
|
function onCloseDone(err) {
|
|
if (err) {
|
|
self.emit('error', err);
|
|
} else {
|
|
self.emit('close');
|
|
}
|
|
}
|
|
};
|
|
|
|
util.inherits(ReadStream, Readable);
|
|
function ReadStream(context, options) {
|
|
options = options || {};
|
|
Readable.call(this, options);
|
|
|
|
this.context = context;
|
|
this.context.ref();
|
|
|
|
this.start = options.start || 0;
|
|
this.endOffset = options.end;
|
|
this.pos = this.start;
|
|
this.destroyed = false;
|
|
}
|
|
|
|
ReadStream.prototype._read = function(n) {
|
|
var self = this;
|
|
if (self.destroyed) return;
|
|
|
|
var toRead = Math.min(self._readableState.highWaterMark, n);
|
|
if (self.endOffset != null) {
|
|
toRead = Math.min(toRead, self.endOffset - self.pos);
|
|
}
|
|
if (toRead <= 0) {
|
|
self.destroyed = true;
|
|
self.push(null);
|
|
self.context.unref();
|
|
return;
|
|
}
|
|
self.context.pend.go(function(cb) {
|
|
if (self.destroyed) return cb();
|
|
var buffer = new Buffer(toRead);
|
|
fs.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
|
|
if (err) {
|
|
self.destroy(err);
|
|
} else if (bytesRead === 0) {
|
|
self.destroyed = true;
|
|
self.push(null);
|
|
self.context.unref();
|
|
} else {
|
|
self.pos += bytesRead;
|
|
self.push(buffer.slice(0, bytesRead));
|
|
}
|
|
cb();
|
|
});
|
|
});
|
|
};
|
|
|
|
ReadStream.prototype.destroy = function(err) {
|
|
if (this.destroyed) return;
|
|
err = err || new Error("stream destroyed");
|
|
this.destroyed = true;
|
|
this.emit('error', err);
|
|
this.context.unref();
|
|
};
|
|
|
|
util.inherits(WriteStream, Writable);
|
|
function WriteStream(context, options) {
|
|
options = options || {};
|
|
Writable.call(this, options);
|
|
|
|
this.context = context;
|
|
this.context.ref();
|
|
|
|
this.start = options.start || 0;
|
|
this.endOffset = (options.end == null) ? Infinity : +options.end;
|
|
this.bytesWritten = 0;
|
|
this.pos = this.start;
|
|
this.destroyed = false;
|
|
|
|
this.on('finish', this.destroy.bind(this));
|
|
}
|
|
|
|
WriteStream.prototype._write = function(buffer, encoding, callback) {
|
|
var self = this;
|
|
if (self.destroyed) return;
|
|
|
|
if (self.pos + buffer.length > self.endOffset) {
|
|
var err = new Error("maximum file length exceeded");
|
|
err.code = 'ETOOBIG';
|
|
self.destroy();
|
|
callback(err);
|
|
return;
|
|
}
|
|
self.context.pend.go(function(cb) {
|
|
if (self.destroyed) return cb();
|
|
fs.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err, bytes) {
|
|
if (err) {
|
|
self.destroy();
|
|
cb();
|
|
callback(err);
|
|
} else {
|
|
self.bytesWritten += bytes;
|
|
self.pos += bytes;
|
|
self.emit('progress');
|
|
cb();
|
|
callback();
|
|
}
|
|
});
|
|
});
|
|
};
|
|
|
|
WriteStream.prototype.destroy = function() {
|
|
if (this.destroyed) return;
|
|
this.destroyed = true;
|
|
this.context.unref();
|
|
};
|
|
|
|
util.inherits(BufferSlicer, EventEmitter);
|
|
function BufferSlicer(buffer, options) {
|
|
EventEmitter.call(this);
|
|
|
|
options = options || {};
|
|
this.refCount = 0;
|
|
this.buffer = buffer;
|
|
this.maxChunkSize = options.maxChunkSize || Number.MAX_SAFE_INTEGER;
|
|
}
|
|
|
|
BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
|
|
var end = position + length;
|
|
var delta = end - this.buffer.length;
|
|
var written = (delta > 0) ? delta : length;
|
|
this.buffer.copy(buffer, offset, position, end);
|
|
setImmediate(function() {
|
|
callback(null, written);
|
|
});
|
|
};
|
|
|
|
BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
|
|
buffer.copy(this.buffer, position, offset, offset + length);
|
|
setImmediate(function() {
|
|
callback(null, length, buffer);
|
|
});
|
|
};
|
|
|
|
BufferSlicer.prototype.createReadStream = function(options) {
|
|
options = options || {};
|
|
var readStream = new PassThrough(options);
|
|
readStream.destroyed = false;
|
|
readStream.start = options.start || 0;
|
|
readStream.endOffset = options.end;
|
|
// by the time this function returns, we'll be done.
|
|
readStream.pos = readStream.endOffset || this.buffer.length;
|
|
|
|
// respect the maxChunkSize option to slice up the chunk into smaller pieces.
|
|
var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
|
|
var offset = 0;
|
|
while (true) {
|
|
var nextOffset = offset + this.maxChunkSize;
|
|
if (nextOffset >= entireSlice.length) {
|
|
// last chunk
|
|
if (offset < entireSlice.length) {
|
|
readStream.write(entireSlice.slice(offset, entireSlice.length));
|
|
}
|
|
break;
|
|
}
|
|
readStream.write(entireSlice.slice(offset, nextOffset));
|
|
offset = nextOffset;
|
|
}
|
|
|
|
readStream.end();
|
|
readStream.destroy = function() {
|
|
readStream.destroyed = true;
|
|
};
|
|
return readStream;
|
|
};
|
|
|
|
BufferSlicer.prototype.createWriteStream = function(options) {
|
|
var bufferSlicer = this;
|
|
options = options || {};
|
|
var writeStream = new Writable(options);
|
|
writeStream.start = options.start || 0;
|
|
writeStream.endOffset = (options.end == null) ? this.buffer.length : +options.end;
|
|
writeStream.bytesWritten = 0;
|
|
writeStream.pos = writeStream.start;
|
|
writeStream.destroyed = false;
|
|
writeStream._write = function(buffer, encoding, callback) {
|
|
if (writeStream.destroyed) return;
|
|
|
|
var end = writeStream.pos + buffer.length;
|
|
if (end > writeStream.endOffset) {
|
|
var err = new Error("maximum file length exceeded");
|
|
err.code = 'ETOOBIG';
|
|
writeStream.destroyed = true;
|
|
callback(err);
|
|
return;
|
|
}
|
|
buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
|
|
|
|
writeStream.bytesWritten += buffer.length;
|
|
writeStream.pos = end;
|
|
writeStream.emit('progress');
|
|
callback();
|
|
};
|
|
writeStream.destroy = function() {
|
|
writeStream.destroyed = true;
|
|
};
|
|
return writeStream;
|
|
};
|
|
|
|
BufferSlicer.prototype.ref = function() {
|
|
this.refCount += 1;
|
|
};
|
|
|
|
BufferSlicer.prototype.unref = function() {
|
|
this.refCount -= 1;
|
|
|
|
if (this.refCount < 0) {
|
|
throw new Error("invalid unref");
|
|
}
|
|
};
|
|
|
|
function createFromBuffer(buffer, options) {
|
|
return new BufferSlicer(buffer, options);
|
|
}
|
|
|
|
function createFromFd(fd, options) {
|
|
return new FdSlicer(fd, options);
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 325:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
const PassThrough = __webpack_require__(413).PassThrough;
|
|
const mimicResponse = __webpack_require__(89);
|
|
|
|
const cloneResponse = response => {
|
|
if (!(response && response.pipe)) {
|
|
throw new TypeError('Parameter `response` must be a response stream.');
|
|
}
|
|
|
|
const clone = new PassThrough();
|
|
mimicResponse(response, clone);
|
|
|
|
return response.pipe(clone);
|
|
};
|
|
|
|
module.exports = cloneResponse;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 335:
|
|
/***/ (function(module) {
|
|
|
|
function allocUnsafe (size) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('"size" argument must be a number')
|
|
}
|
|
|
|
if (size < 0) {
|
|
throw new RangeError('"size" argument must not be negative')
|
|
}
|
|
|
|
if (Buffer.allocUnsafe) {
|
|
return Buffer.allocUnsafe(size)
|
|
} else {
|
|
return new Buffer(size)
|
|
}
|
|
}
|
|
|
|
module.exports = allocUnsafe
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 338:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var isPlainObj = __webpack_require__(727);
|
|
|
|
module.exports = function (obj, opts) {
|
|
if (!isPlainObj(obj)) {
|
|
throw new TypeError('Expected a plain object');
|
|
}
|
|
|
|
opts = opts || {};
|
|
|
|
// DEPRECATED
|
|
if (typeof opts === 'function') {
|
|
opts = {compare: opts};
|
|
}
|
|
|
|
var deep = opts.deep;
|
|
var seenInput = [];
|
|
var seenOutput = [];
|
|
|
|
var sortKeys = function (x) {
|
|
var seenIndex = seenInput.indexOf(x);
|
|
|
|
if (seenIndex !== -1) {
|
|
return seenOutput[seenIndex];
|
|
}
|
|
|
|
var ret = {};
|
|
var keys = Object.keys(x).sort(opts.compare);
|
|
|
|
seenInput.push(x);
|
|
seenOutput.push(ret);
|
|
|
|
for (var i = 0; i < keys.length; i++) {
|
|
var key = keys[i];
|
|
var val = x[key];
|
|
|
|
ret[key] = deep && isPlainObj(val) ? sortKeys(val) : val;
|
|
}
|
|
|
|
return ret;
|
|
};
|
|
|
|
return sortKeys(obj);
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 345:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var bufferFill = __webpack_require__(425)
|
|
var allocUnsafe = __webpack_require__(335)
|
|
|
|
module.exports = function alloc (size, fill, encoding) {
|
|
if (typeof size !== 'number') {
|
|
throw new TypeError('"size" argument must be a number')
|
|
}
|
|
|
|
if (size < 0) {
|
|
throw new RangeError('"size" argument must not be negative')
|
|
}
|
|
|
|
if (Buffer.alloc) {
|
|
return Buffer.alloc(size, fill, encoding)
|
|
}
|
|
|
|
var buffer = allocUnsafe(size)
|
|
|
|
if (size === 0) {
|
|
return buffer
|
|
}
|
|
|
|
if (fill === undefined) {
|
|
return bufferFill(buffer, 0)
|
|
}
|
|
|
|
if (typeof encoding !== 'string') {
|
|
encoding = undefined
|
|
}
|
|
|
|
return bufferFill(buffer, fill, encoding)
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 351:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const from = __webpack_require__(868);
|
|
const pIsPromise = __webpack_require__(520);
|
|
|
|
module.exports = x => {
|
|
if (Array.isArray(x)) {
|
|
x = x.slice();
|
|
}
|
|
|
|
let promise;
|
|
let iterator;
|
|
|
|
prepare(x);
|
|
|
|
function prepare(value) {
|
|
x = value;
|
|
promise = pIsPromise(x) ? x : null;
|
|
// we don't iterate on strings and buffers since slicing them is ~7x faster
|
|
const shouldIterate = !promise && x[Symbol.iterator] && typeof x !== 'string' && !Buffer.isBuffer(x);
|
|
iterator = shouldIterate ? x[Symbol.iterator]() : null;
|
|
}
|
|
|
|
return from(function reader(size, cb) {
|
|
if (promise) {
|
|
promise.then(prepare).then(() => reader.call(this, size, cb), cb);
|
|
return;
|
|
}
|
|
|
|
if (iterator) {
|
|
const obj = iterator.next();
|
|
setImmediate(cb, null, obj.done ? null : obj.value);
|
|
return;
|
|
}
|
|
|
|
if (x.length === 0) {
|
|
setImmediate(cb, null, null);
|
|
return;
|
|
}
|
|
|
|
const chunk = x.slice(0, size);
|
|
x = x.slice(size);
|
|
|
|
setImmediate(cb, null, chunk);
|
|
});
|
|
};
|
|
|
|
module.exports.obj = x => {
|
|
if (Array.isArray(x)) {
|
|
x = x.slice();
|
|
}
|
|
|
|
let promise;
|
|
let iterator;
|
|
|
|
prepare(x);
|
|
|
|
function prepare(value) {
|
|
x = value;
|
|
promise = pIsPromise(x) ? x : null;
|
|
iterator = !promise && x[Symbol.iterator] ? x[Symbol.iterator]() : null;
|
|
}
|
|
|
|
return from.obj(function reader(size, cb) {
|
|
if (promise) {
|
|
promise.then(prepare).then(() => reader.call(this, size, cb), cb);
|
|
return;
|
|
}
|
|
|
|
if (iterator) {
|
|
const obj = iterator.next();
|
|
setImmediate(cb, null, obj.done ? null : obj.value);
|
|
return;
|
|
}
|
|
|
|
this.push(x);
|
|
|
|
setImmediate(cb, null, null);
|
|
});
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 357:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("assert");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 361:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const decompressTar = __webpack_require__(791);
|
|
const fileType = __webpack_require__(550);
|
|
const isStream = __webpack_require__(323);
|
|
const seekBzip = __webpack_require__(829);
|
|
const unbzip2Stream = __webpack_require__(849);
|
|
|
|
module.exports = () => input => {
|
|
if (!Buffer.isBuffer(input) && !isStream(input)) {
|
|
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`));
|
|
}
|
|
|
|
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'bz2')) {
|
|
return Promise.resolve([]);
|
|
}
|
|
|
|
if (Buffer.isBuffer(input)) {
|
|
return decompressTar()(seekBzip.decode(input));
|
|
}
|
|
|
|
return decompressTar()(input.pipe(unbzip2Stream()));
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 364:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var util = __webpack_require__(669)
|
|
var bl = __webpack_require__(954)
|
|
var xtend = __webpack_require__(940)
|
|
var headers = __webpack_require__(154)
|
|
|
|
var Writable = __webpack_require__(574).Writable
|
|
var PassThrough = __webpack_require__(574).PassThrough
|
|
|
|
var noop = function () {}
|
|
|
|
var overflow = function (size) {
|
|
size &= 511
|
|
return size && 512 - size
|
|
}
|
|
|
|
var emptyStream = function (self, offset) {
|
|
var s = new Source(self, offset)
|
|
s.end()
|
|
return s
|
|
}
|
|
|
|
var mixinPax = function (header, pax) {
|
|
if (pax.path) header.name = pax.path
|
|
if (pax.linkpath) header.linkname = pax.linkpath
|
|
if (pax.size) header.size = parseInt(pax.size, 10)
|
|
header.pax = pax
|
|
return header
|
|
}
|
|
|
|
var Source = function (self, offset) {
|
|
this._parent = self
|
|
this.offset = offset
|
|
PassThrough.call(this)
|
|
}
|
|
|
|
util.inherits(Source, PassThrough)
|
|
|
|
Source.prototype.destroy = function (err) {
|
|
this._parent.destroy(err)
|
|
}
|
|
|
|
var Extract = function (opts) {
|
|
if (!(this instanceof Extract)) return new Extract(opts)
|
|
Writable.call(this, opts)
|
|
|
|
opts = opts || {}
|
|
|
|
this._offset = 0
|
|
this._buffer = bl()
|
|
this._missing = 0
|
|
this._partial = false
|
|
this._onparse = noop
|
|
this._header = null
|
|
this._stream = null
|
|
this._overflow = null
|
|
this._cb = null
|
|
this._locked = false
|
|
this._destroyed = false
|
|
this._pax = null
|
|
this._paxGlobal = null
|
|
this._gnuLongPath = null
|
|
this._gnuLongLinkPath = null
|
|
|
|
var self = this
|
|
var b = self._buffer
|
|
|
|
var oncontinue = function () {
|
|
self._continue()
|
|
}
|
|
|
|
var onunlock = function (err) {
|
|
self._locked = false
|
|
if (err) return self.destroy(err)
|
|
if (!self._stream) oncontinue()
|
|
}
|
|
|
|
var onstreamend = function () {
|
|
self._stream = null
|
|
var drain = overflow(self._header.size)
|
|
if (drain) self._parse(drain, ondrain)
|
|
else self._parse(512, onheader)
|
|
if (!self._locked) oncontinue()
|
|
}
|
|
|
|
var ondrain = function () {
|
|
self._buffer.consume(overflow(self._header.size))
|
|
self._parse(512, onheader)
|
|
oncontinue()
|
|
}
|
|
|
|
var onpaxglobalheader = function () {
|
|
var size = self._header.size
|
|
self._paxGlobal = headers.decodePax(b.slice(0, size))
|
|
b.consume(size)
|
|
onstreamend()
|
|
}
|
|
|
|
var onpaxheader = function () {
|
|
var size = self._header.size
|
|
self._pax = headers.decodePax(b.slice(0, size))
|
|
if (self._paxGlobal) self._pax = xtend(self._paxGlobal, self._pax)
|
|
b.consume(size)
|
|
onstreamend()
|
|
}
|
|
|
|
var ongnulongpath = function () {
|
|
var size = self._header.size
|
|
this._gnuLongPath = headers.decodeLongPath(b.slice(0, size), opts.filenameEncoding)
|
|
b.consume(size)
|
|
onstreamend()
|
|
}
|
|
|
|
var ongnulonglinkpath = function () {
|
|
var size = self._header.size
|
|
this._gnuLongLinkPath = headers.decodeLongPath(b.slice(0, size), opts.filenameEncoding)
|
|
b.consume(size)
|
|
onstreamend()
|
|
}
|
|
|
|
var onheader = function () {
|
|
var offset = self._offset
|
|
var header
|
|
try {
|
|
header = self._header = headers.decode(b.slice(0, 512), opts.filenameEncoding)
|
|
} catch (err) {
|
|
self.emit('error', err)
|
|
}
|
|
b.consume(512)
|
|
|
|
if (!header) {
|
|
self._parse(512, onheader)
|
|
oncontinue()
|
|
return
|
|
}
|
|
if (header.type === 'gnu-long-path') {
|
|
self._parse(header.size, ongnulongpath)
|
|
oncontinue()
|
|
return
|
|
}
|
|
if (header.type === 'gnu-long-link-path') {
|
|
self._parse(header.size, ongnulonglinkpath)
|
|
oncontinue()
|
|
return
|
|
}
|
|
if (header.type === 'pax-global-header') {
|
|
self._parse(header.size, onpaxglobalheader)
|
|
oncontinue()
|
|
return
|
|
}
|
|
if (header.type === 'pax-header') {
|
|
self._parse(header.size, onpaxheader)
|
|
oncontinue()
|
|
return
|
|
}
|
|
|
|
if (self._gnuLongPath) {
|
|
header.name = self._gnuLongPath
|
|
self._gnuLongPath = null
|
|
}
|
|
|
|
if (self._gnuLongLinkPath) {
|
|
header.linkname = self._gnuLongLinkPath
|
|
self._gnuLongLinkPath = null
|
|
}
|
|
|
|
if (self._pax) {
|
|
self._header = header = mixinPax(header, self._pax)
|
|
self._pax = null
|
|
}
|
|
|
|
self._locked = true
|
|
|
|
if (!header.size || header.type === 'directory') {
|
|
self._parse(512, onheader)
|
|
self.emit('entry', header, emptyStream(self, offset), onunlock)
|
|
return
|
|
}
|
|
|
|
self._stream = new Source(self, offset)
|
|
|
|
self.emit('entry', header, self._stream, onunlock)
|
|
self._parse(header.size, onstreamend)
|
|
oncontinue()
|
|
}
|
|
|
|
this._onheader = onheader
|
|
this._parse(512, onheader)
|
|
}
|
|
|
|
util.inherits(Extract, Writable)
|
|
|
|
Extract.prototype.destroy = function (err) {
|
|
if (this._destroyed) return
|
|
this._destroyed = true
|
|
|
|
if (err) this.emit('error', err)
|
|
this.emit('close')
|
|
if (this._stream) this._stream.emit('close')
|
|
}
|
|
|
|
Extract.prototype._parse = function (size, onparse) {
|
|
if (this._destroyed) return
|
|
this._offset += size
|
|
this._missing = size
|
|
if (onparse === this._onheader) this._partial = false
|
|
this._onparse = onparse
|
|
}
|
|
|
|
Extract.prototype._continue = function () {
|
|
if (this._destroyed) return
|
|
var cb = this._cb
|
|
this._cb = noop
|
|
if (this._overflow) this._write(this._overflow, undefined, cb)
|
|
else cb()
|
|
}
|
|
|
|
Extract.prototype._write = function (data, enc, cb) {
|
|
if (this._destroyed) return
|
|
|
|
var s = this._stream
|
|
var b = this._buffer
|
|
var missing = this._missing
|
|
if (data.length) this._partial = true
|
|
|
|
// we do not reach end-of-chunk now. just forward it
|
|
|
|
if (data.length < missing) {
|
|
this._missing -= data.length
|
|
this._overflow = null
|
|
if (s) return s.write(data, cb)
|
|
b.append(data)
|
|
return cb()
|
|
}
|
|
|
|
// end-of-chunk. the parser should call cb.
|
|
|
|
this._cb = cb
|
|
this._missing = 0
|
|
|
|
var overflow = null
|
|
if (data.length > missing) {
|
|
overflow = data.slice(missing)
|
|
data = data.slice(0, missing)
|
|
}
|
|
|
|
if (s) s.end(data)
|
|
else b.append(data)
|
|
|
|
this._overflow = overflow
|
|
this._onparse()
|
|
}
|
|
|
|
Extract.prototype._final = function (cb) {
|
|
if (this._partial) return this.destroy(new Error('Unexpected end of data'))
|
|
cb()
|
|
}
|
|
|
|
module.exports = Extract
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 370:
|
|
/***/ (function(module) {
|
|
|
|
/*
|
|
bzip2.js - a small bzip2 decompression implementation
|
|
|
|
Copyright 2011 by antimatter15 (antimatter15@gmail.com)
|
|
|
|
Based on micro-bunzip by Rob Landley (rob@landley.net).
|
|
|
|
Copyright (c) 2011 by antimatter15 (antimatter15@gmail.com).
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a
|
|
copy of this software and associated documentation files (the "Software"),
|
|
to deal in the Software without restriction, including without limitation
|
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
and/or sell copies of the Software, and to permit persons to whom the
|
|
Software is furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included
|
|
in all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
|
|
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
function Bzip2Error(message) {
|
|
this.name = 'Bzip2Error';
|
|
this.message = message;
|
|
this.stack = (new Error()).stack;
|
|
}
|
|
Bzip2Error.prototype = new Error;
|
|
|
|
var message = {
|
|
Error: function(message) {throw new Bzip2Error(message);}
|
|
};
|
|
|
|
var bzip2 = {};
|
|
bzip2.Bzip2Error = Bzip2Error;
|
|
|
|
bzip2.crcTable =
|
|
[
|
|
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9,
|
|
0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
|
|
0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
|
|
0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
|
|
0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9,
|
|
0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
|
|
0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011,
|
|
0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd,
|
|
0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
|
|
0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5,
|
|
0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81,
|
|
0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
|
|
0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49,
|
|
0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
|
|
0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1,
|
|
0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d,
|
|
0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae,
|
|
0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
|
|
0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16,
|
|
0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca,
|
|
0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde,
|
|
0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02,
|
|
0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066,
|
|
0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
|
|
0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e,
|
|
0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692,
|
|
0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6,
|
|
0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a,
|
|
0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e,
|
|
0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
|
|
0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686,
|
|
0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a,
|
|
0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637,
|
|
0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
|
|
0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f,
|
|
0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
|
|
0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47,
|
|
0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b,
|
|
0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
|
|
0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623,
|
|
0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7,
|
|
0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
|
|
0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f,
|
|
0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
|
|
0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7,
|
|
0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b,
|
|
0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f,
|
|
0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
|
|
0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640,
|
|
0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c,
|
|
0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8,
|
|
0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24,
|
|
0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30,
|
|
0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
|
|
0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088,
|
|
0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654,
|
|
0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0,
|
|
0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c,
|
|
0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18,
|
|
0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
|
|
0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0,
|
|
0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
|
|
0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
|
|
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
|
|
];
|
|
|
|
bzip2.array = function(bytes) {
|
|
var bit = 0, byte = 0;
|
|
var BITMASK = [0, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF ];
|
|
return function(n) {
|
|
var result = 0;
|
|
while(n > 0) {
|
|
var left = 8 - bit;
|
|
if (n >= left) {
|
|
result <<= left;
|
|
result |= (BITMASK[left] & bytes[byte++]);
|
|
bit = 0;
|
|
n -= left;
|
|
} else {
|
|
result <<= n;
|
|
result |= ((bytes[byte] & (BITMASK[n] << (8 - n - bit))) >> (8 - n - bit));
|
|
bit += n;
|
|
n = 0;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
bzip2.simple = function(srcbuffer, stream) {
|
|
var bits = bzip2.array(srcbuffer);
|
|
var size = bzip2.header(bits);
|
|
var ret = false;
|
|
var bufsize = 100000 * size;
|
|
var buf = new Int32Array(bufsize);
|
|
|
|
do {
|
|
ret = bzip2.decompress(bits, stream, buf, bufsize);
|
|
} while(!ret);
|
|
}
|
|
|
|
bzip2.header = function(bits) {
|
|
this.byteCount = new Int32Array(256);
|
|
this.symToByte = new Uint8Array(256);
|
|
this.mtfSymbol = new Int32Array(256);
|
|
this.selectors = new Uint8Array(0x8000);
|
|
|
|
if (bits(8*3) != 4348520) message.Error("No magic number found");
|
|
|
|
var i = bits(8) - 48;
|
|
if (i < 1 || i > 9) message.Error("Not a BZIP archive");
|
|
return i;
|
|
};
|
|
|
|
|
|
//takes a function for reading the block data (starting with 0x314159265359)
|
|
//a block size (0-9) (optional, defaults to 9)
|
|
//a length at which to stop decompressing and return the output
|
|
bzip2.decompress = function(bits, stream, buf, bufsize, streamCRC) {
|
|
var MAX_HUFCODE_BITS = 20;
|
|
var MAX_SYMBOLS = 258;
|
|
var SYMBOL_RUNA = 0;
|
|
var SYMBOL_RUNB = 1;
|
|
var GROUP_SIZE = 50;
|
|
var crc = 0 ^ (-1);
|
|
|
|
for(var h = '', i = 0; i < 6; i++) h += bits(8).toString(16);
|
|
if (h == "177245385090") {
|
|
var finalCRC = bits(32)|0;
|
|
if (finalCRC !== streamCRC) message.Error("Error in bzip2: crc32 do not match");
|
|
// align stream to byte
|
|
bits(null);
|
|
return null; // reset streamCRC for next call
|
|
}
|
|
if (h != "314159265359") message.Error("eek not valid bzip data");
|
|
var crcblock = bits(32)|0; // CRC code
|
|
if (bits(1)) message.Error("unsupported obsolete version");
|
|
var origPtr = bits(24);
|
|
if (origPtr > bufsize) message.Error("Initial position larger than buffer size");
|
|
var t = bits(16);
|
|
var symTotal = 0;
|
|
for (i = 0; i < 16; i++) {
|
|
if (t & (1 << (15 - i))) {
|
|
var k = bits(16);
|
|
for(j = 0; j < 16; j++) {
|
|
if (k & (1 << (15 - j))) {
|
|
this.symToByte[symTotal++] = (16 * i) + j;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
var groupCount = bits(3);
|
|
if (groupCount < 2 || groupCount > 6) message.Error("another error");
|
|
var nSelectors = bits(15);
|
|
if (nSelectors == 0) message.Error("meh");
|
|
for(var i = 0; i < groupCount; i++) this.mtfSymbol[i] = i;
|
|
|
|
for(var i = 0; i < nSelectors; i++) {
|
|
for(var j = 0; bits(1); j++) if (j >= groupCount) message.Error("whoops another error");
|
|
var uc = this.mtfSymbol[j];
|
|
for(var k = j-1; k>=0; k--) {
|
|
this.mtfSymbol[k+1] = this.mtfSymbol[k];
|
|
}
|
|
this.mtfSymbol[0] = uc;
|
|
this.selectors[i] = uc;
|
|
}
|
|
|
|
var symCount = symTotal + 2;
|
|
var groups = [];
|
|
var length = new Uint8Array(MAX_SYMBOLS),
|
|
temp = new Uint16Array(MAX_HUFCODE_BITS+1);
|
|
|
|
var hufGroup;
|
|
|
|
for(var j = 0; j < groupCount; j++) {
|
|
t = bits(5); //lengths
|
|
for(var i = 0; i < symCount; i++) {
|
|
while(true){
|
|
if (t < 1 || t > MAX_HUFCODE_BITS) message.Error("I gave up a while ago on writing error messages");
|
|
if (!bits(1)) break;
|
|
if (!bits(1)) t++;
|
|
else t--;
|
|
}
|
|
length[i] = t;
|
|
}
|
|
var minLen, maxLen;
|
|
minLen = maxLen = length[0];
|
|
for(var i = 1; i < symCount; i++) {
|
|
if (length[i] > maxLen) maxLen = length[i];
|
|
else if (length[i] < minLen) minLen = length[i];
|
|
}
|
|
hufGroup = groups[j] = {};
|
|
hufGroup.permute = new Int32Array(MAX_SYMBOLS);
|
|
hufGroup.limit = new Int32Array(MAX_HUFCODE_BITS + 1);
|
|
hufGroup.base = new Int32Array(MAX_HUFCODE_BITS + 1);
|
|
|
|
hufGroup.minLen = minLen;
|
|
hufGroup.maxLen = maxLen;
|
|
var base = hufGroup.base.subarray(1);
|
|
var limit = hufGroup.limit.subarray(1);
|
|
var pp = 0;
|
|
for(var i = minLen; i <= maxLen; i++)
|
|
for(var t = 0; t < symCount; t++)
|
|
if (length[t] == i) hufGroup.permute[pp++] = t;
|
|
for(i = minLen; i <= maxLen; i++) temp[i] = limit[i] = 0;
|
|
for(i = 0; i < symCount; i++) temp[length[i]]++;
|
|
pp = t = 0;
|
|
for(i = minLen; i < maxLen; i++) {
|
|
pp += temp[i];
|
|
limit[i] = pp - 1;
|
|
pp <<= 1;
|
|
base[i+1] = pp - (t += temp[i]);
|
|
}
|
|
limit[maxLen] = pp + temp[maxLen] - 1;
|
|
base[minLen] = 0;
|
|
}
|
|
|
|
for(var i = 0; i < 256; i++) {
|
|
this.mtfSymbol[i] = i;
|
|
this.byteCount[i] = 0;
|
|
}
|
|
var runPos, count, symCount, selector;
|
|
runPos = count = symCount = selector = 0;
|
|
while(true) {
|
|
if (!(symCount--)) {
|
|
symCount = GROUP_SIZE - 1;
|
|
if (selector >= nSelectors) message.Error("meow i'm a kitty, that's an error");
|
|
hufGroup = groups[this.selectors[selector++]];
|
|
base = hufGroup.base.subarray(1);
|
|
limit = hufGroup.limit.subarray(1);
|
|
}
|
|
i = hufGroup.minLen;
|
|
j = bits(i);
|
|
while(true) {
|
|
if (i > hufGroup.maxLen) message.Error("rawr i'm a dinosaur");
|
|
if (j <= limit[i]) break;
|
|
i++;
|
|
j = (j << 1) | bits(1);
|
|
}
|
|
j -= base[i];
|
|
if (j < 0 || j >= MAX_SYMBOLS) message.Error("moo i'm a cow");
|
|
var nextSym = hufGroup.permute[j];
|
|
if (nextSym == SYMBOL_RUNA || nextSym == SYMBOL_RUNB) {
|
|
if (!runPos){
|
|
runPos = 1;
|
|
t = 0;
|
|
}
|
|
if (nextSym == SYMBOL_RUNA) t += runPos;
|
|
else t += 2 * runPos;
|
|
runPos <<= 1;
|
|
continue;
|
|
}
|
|
if (runPos) {
|
|
runPos = 0;
|
|
if (count + t > bufsize) message.Error("Boom.");
|
|
uc = this.symToByte[this.mtfSymbol[0]];
|
|
this.byteCount[uc] += t;
|
|
while(t--) buf[count++] = uc;
|
|
}
|
|
if (nextSym > symTotal) break;
|
|
if (count >= bufsize) message.Error("I can't think of anything. Error");
|
|
i = nextSym - 1;
|
|
uc = this.mtfSymbol[i];
|
|
for(var k = i-1; k>=0; k--) {
|
|
this.mtfSymbol[k+1] = this.mtfSymbol[k];
|
|
}
|
|
this.mtfSymbol[0] = uc
|
|
uc = this.symToByte[uc];
|
|
this.byteCount[uc]++;
|
|
buf[count++] = uc;
|
|
}
|
|
if (origPtr < 0 || origPtr >= count) message.Error("I'm a monkey and I'm throwing something at someone, namely you");
|
|
var j = 0;
|
|
for(var i = 0; i < 256; i++) {
|
|
k = j + this.byteCount[i];
|
|
this.byteCount[i] = j;
|
|
j = k;
|
|
}
|
|
for(var i = 0; i < count; i++) {
|
|
uc = buf[i] & 0xff;
|
|
buf[this.byteCount[uc]] |= (i << 8);
|
|
this.byteCount[uc]++;
|
|
}
|
|
var pos = 0, current = 0, run = 0;
|
|
if (count) {
|
|
pos = buf[origPtr];
|
|
current = (pos & 0xff);
|
|
pos >>= 8;
|
|
run = -1;
|
|
}
|
|
count = count;
|
|
var copies, previous, outbyte;
|
|
while(count) {
|
|
count--;
|
|
previous = current;
|
|
pos = buf[pos];
|
|
current = pos & 0xff;
|
|
pos >>= 8;
|
|
if (run++ == 3) {
|
|
copies = current;
|
|
outbyte = previous;
|
|
current = -1;
|
|
} else {
|
|
copies = 1;
|
|
outbyte = current;
|
|
}
|
|
while(copies--) {
|
|
crc = ((crc << 8) ^ this.crcTable[((crc>>24) ^ outbyte) & 0xFF])&0xFFFFFFFF; // crc32
|
|
stream(outbyte);
|
|
}
|
|
if (current != previous) run = 0;
|
|
}
|
|
|
|
crc = (crc ^ (-1)) >>> 0;
|
|
if ((crc|0) != (crcblock|0)) message.Error("Error in bzip2: crc32 do not match");
|
|
streamCRC = (crc ^ ((streamCRC << 1) | (streamCRC >>> 31))) & 0xFFFFFFFF;
|
|
return streamCRC;
|
|
}
|
|
|
|
module.exports = bzip2;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 375:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const PassThrough = __webpack_require__(413).PassThrough;
|
|
|
|
module.exports = opts => {
|
|
opts = Object.assign({}, opts);
|
|
|
|
const array = opts.array;
|
|
let encoding = opts.encoding;
|
|
const buffer = encoding === 'buffer';
|
|
let objectMode = false;
|
|
|
|
if (array) {
|
|
objectMode = !(encoding || buffer);
|
|
} else {
|
|
encoding = encoding || 'utf8';
|
|
}
|
|
|
|
if (buffer) {
|
|
encoding = null;
|
|
}
|
|
|
|
let len = 0;
|
|
const ret = [];
|
|
const stream = new PassThrough({objectMode});
|
|
|
|
if (encoding) {
|
|
stream.setEncoding(encoding);
|
|
}
|
|
|
|
stream.on('data', chunk => {
|
|
ret.push(chunk);
|
|
|
|
if (objectMode) {
|
|
len = ret.length;
|
|
} else {
|
|
len += chunk.length;
|
|
}
|
|
});
|
|
|
|
stream.getBufferedValue = () => {
|
|
if (array) {
|
|
return ret;
|
|
}
|
|
|
|
return buffer ? Buffer.concat(ret, len) : ret.join('');
|
|
};
|
|
|
|
stream.getBufferedLength = () => len;
|
|
|
|
return stream;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 376:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = toBuffer
|
|
|
|
var makeBuffer = Buffer.from && Buffer.from !== Uint8Array.from ? Buffer.from : bufferFrom
|
|
|
|
function bufferFrom (buf, enc) {
|
|
return new Buffer(buf, enc)
|
|
}
|
|
|
|
function toBuffer (buf, enc) {
|
|
if (Buffer.isBuffer(buf)) return buf
|
|
if (typeof buf === 'string') return makeBuffer(buf, enc)
|
|
if (Array.isArray(buf)) return makeBuffer(buf)
|
|
throw new Error('Input should be a buffer or a string')
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 383:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var constants = __webpack_require__(534)
|
|
var eos = __webpack_require__(9)
|
|
var util = __webpack_require__(669)
|
|
var alloc = __webpack_require__(345)
|
|
var toBuffer = __webpack_require__(376)
|
|
|
|
var Readable = __webpack_require__(574).Readable
|
|
var Writable = __webpack_require__(574).Writable
|
|
var StringDecoder = __webpack_require__(304).StringDecoder
|
|
|
|
var headers = __webpack_require__(154)
|
|
|
|
var DMODE = parseInt('755', 8)
|
|
var FMODE = parseInt('644', 8)
|
|
|
|
var END_OF_TAR = alloc(1024)
|
|
|
|
var noop = function () {}
|
|
|
|
var overflow = function (self, size) {
|
|
size &= 511
|
|
if (size) self.push(END_OF_TAR.slice(0, 512 - size))
|
|
}
|
|
|
|
function modeToType (mode) {
|
|
switch (mode & constants.S_IFMT) {
|
|
case constants.S_IFBLK: return 'block-device'
|
|
case constants.S_IFCHR: return 'character-device'
|
|
case constants.S_IFDIR: return 'directory'
|
|
case constants.S_IFIFO: return 'fifo'
|
|
case constants.S_IFLNK: return 'symlink'
|
|
}
|
|
|
|
return 'file'
|
|
}
|
|
|
|
var Sink = function (to) {
|
|
Writable.call(this)
|
|
this.written = 0
|
|
this._to = to
|
|
this._destroyed = false
|
|
}
|
|
|
|
util.inherits(Sink, Writable)
|
|
|
|
Sink.prototype._write = function (data, enc, cb) {
|
|
this.written += data.length
|
|
if (this._to.push(data)) return cb()
|
|
this._to._drain = cb
|
|
}
|
|
|
|
Sink.prototype.destroy = function () {
|
|
if (this._destroyed) return
|
|
this._destroyed = true
|
|
this.emit('close')
|
|
}
|
|
|
|
var LinkSink = function () {
|
|
Writable.call(this)
|
|
this.linkname = ''
|
|
this._decoder = new StringDecoder('utf-8')
|
|
this._destroyed = false
|
|
}
|
|
|
|
util.inherits(LinkSink, Writable)
|
|
|
|
LinkSink.prototype._write = function (data, enc, cb) {
|
|
this.linkname += this._decoder.write(data)
|
|
cb()
|
|
}
|
|
|
|
LinkSink.prototype.destroy = function () {
|
|
if (this._destroyed) return
|
|
this._destroyed = true
|
|
this.emit('close')
|
|
}
|
|
|
|
var Void = function () {
|
|
Writable.call(this)
|
|
this._destroyed = false
|
|
}
|
|
|
|
util.inherits(Void, Writable)
|
|
|
|
Void.prototype._write = function (data, enc, cb) {
|
|
cb(new Error('No body allowed for this entry'))
|
|
}
|
|
|
|
Void.prototype.destroy = function () {
|
|
if (this._destroyed) return
|
|
this._destroyed = true
|
|
this.emit('close')
|
|
}
|
|
|
|
var Pack = function (opts) {
|
|
if (!(this instanceof Pack)) return new Pack(opts)
|
|
Readable.call(this, opts)
|
|
|
|
this._drain = noop
|
|
this._finalized = false
|
|
this._finalizing = false
|
|
this._destroyed = false
|
|
this._stream = null
|
|
}
|
|
|
|
util.inherits(Pack, Readable)
|
|
|
|
Pack.prototype.entry = function (header, buffer, callback) {
|
|
if (this._stream) throw new Error('already piping an entry')
|
|
if (this._finalized || this._destroyed) return
|
|
|
|
if (typeof buffer === 'function') {
|
|
callback = buffer
|
|
buffer = null
|
|
}
|
|
|
|
if (!callback) callback = noop
|
|
|
|
var self = this
|
|
|
|
if (!header.size || header.type === 'symlink') header.size = 0
|
|
if (!header.type) header.type = modeToType(header.mode)
|
|
if (!header.mode) header.mode = header.type === 'directory' ? DMODE : FMODE
|
|
if (!header.uid) header.uid = 0
|
|
if (!header.gid) header.gid = 0
|
|
if (!header.mtime) header.mtime = new Date()
|
|
|
|
if (typeof buffer === 'string') buffer = toBuffer(buffer)
|
|
if (Buffer.isBuffer(buffer)) {
|
|
header.size = buffer.length
|
|
this._encode(header)
|
|
this.push(buffer)
|
|
overflow(self, header.size)
|
|
process.nextTick(callback)
|
|
return new Void()
|
|
}
|
|
|
|
if (header.type === 'symlink' && !header.linkname) {
|
|
var linkSink = new LinkSink()
|
|
eos(linkSink, function (err) {
|
|
if (err) { // stream was closed
|
|
self.destroy()
|
|
return callback(err)
|
|
}
|
|
|
|
header.linkname = linkSink.linkname
|
|
self._encode(header)
|
|
callback()
|
|
})
|
|
|
|
return linkSink
|
|
}
|
|
|
|
this._encode(header)
|
|
|
|
if (header.type !== 'file' && header.type !== 'contiguous-file') {
|
|
process.nextTick(callback)
|
|
return new Void()
|
|
}
|
|
|
|
var sink = new Sink(this)
|
|
|
|
this._stream = sink
|
|
|
|
eos(sink, function (err) {
|
|
self._stream = null
|
|
|
|
if (err) { // stream was closed
|
|
self.destroy()
|
|
return callback(err)
|
|
}
|
|
|
|
if (sink.written !== header.size) { // corrupting tar
|
|
self.destroy()
|
|
return callback(new Error('size mismatch'))
|
|
}
|
|
|
|
overflow(self, header.size)
|
|
if (self._finalizing) self.finalize()
|
|
callback()
|
|
})
|
|
|
|
return sink
|
|
}
|
|
|
|
Pack.prototype.finalize = function () {
|
|
if (this._stream) {
|
|
this._finalizing = true
|
|
return
|
|
}
|
|
|
|
if (this._finalized) return
|
|
this._finalized = true
|
|
this.push(END_OF_TAR)
|
|
this.push(null)
|
|
}
|
|
|
|
Pack.prototype.destroy = function (err) {
|
|
if (this._destroyed) return
|
|
this._destroyed = true
|
|
|
|
if (err) this.emit('error', err)
|
|
this.emit('close')
|
|
if (this._stream && this._stream.destroy) this._stream.destroy()
|
|
}
|
|
|
|
Pack.prototype._encode = function (header) {
|
|
if (!header.pax) {
|
|
var buf = headers.encode(header)
|
|
if (buf) {
|
|
this.push(buf)
|
|
return
|
|
}
|
|
}
|
|
this._encodePax(header)
|
|
}
|
|
|
|
Pack.prototype._encodePax = function (header) {
|
|
var paxHeader = headers.encodePax({
|
|
name: header.name,
|
|
linkname: header.linkname,
|
|
pax: header.pax
|
|
})
|
|
|
|
var newHeader = {
|
|
name: 'PaxHeader',
|
|
mode: header.mode,
|
|
uid: header.uid,
|
|
gid: header.gid,
|
|
size: paxHeader.length,
|
|
mtime: header.mtime,
|
|
type: 'pax-header',
|
|
linkname: header.linkname && 'PaxHeader',
|
|
uname: header.uname,
|
|
gname: header.gname,
|
|
devmajor: header.devmajor,
|
|
devminor: header.devminor
|
|
}
|
|
|
|
this.push(headers.encode(newHeader))
|
|
this.push(paxHeader)
|
|
overflow(this, paxHeader.length)
|
|
|
|
newHeader.size = header.size
|
|
newHeader.type = header.type
|
|
this.push(headers.encode(newHeader))
|
|
}
|
|
|
|
Pack.prototype._read = function (n) {
|
|
var drain = this._drain
|
|
this._drain = noop
|
|
drain()
|
|
}
|
|
|
|
module.exports = Pack
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 385:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
const processFn = (fn, opts) => function () {
|
|
const P = opts.promiseModule;
|
|
const args = new Array(arguments.length);
|
|
|
|
for (let i = 0; i < arguments.length; i++) {
|
|
args[i] = arguments[i];
|
|
}
|
|
|
|
return new P((resolve, reject) => {
|
|
if (opts.errorFirst) {
|
|
args.push(function (err, result) {
|
|
if (opts.multiArgs) {
|
|
const results = new Array(arguments.length - 1);
|
|
|
|
for (let i = 1; i < arguments.length; i++) {
|
|
results[i - 1] = arguments[i];
|
|
}
|
|
|
|
if (err) {
|
|
results.unshift(err);
|
|
reject(results);
|
|
} else {
|
|
resolve(results);
|
|
}
|
|
} else if (err) {
|
|
reject(err);
|
|
} else {
|
|
resolve(result);
|
|
}
|
|
});
|
|
} else {
|
|
args.push(function (result) {
|
|
if (opts.multiArgs) {
|
|
const results = new Array(arguments.length - 1);
|
|
|
|
for (let i = 0; i < arguments.length; i++) {
|
|
results[i] = arguments[i];
|
|
}
|
|
|
|
resolve(results);
|
|
} else {
|
|
resolve(result);
|
|
}
|
|
});
|
|
}
|
|
|
|
fn.apply(this, args);
|
|
});
|
|
};
|
|
|
|
module.exports = (obj, opts) => {
|
|
opts = Object.assign({
|
|
exclude: [/.+(Sync|Stream)$/],
|
|
errorFirst: true,
|
|
promiseModule: Promise
|
|
}, opts);
|
|
|
|
const filter = key => {
|
|
const match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key);
|
|
return opts.include ? opts.include.some(match) : !opts.exclude.some(match);
|
|
};
|
|
|
|
let ret;
|
|
if (typeof obj === 'function') {
|
|
ret = function () {
|
|
if (opts.excludeMain) {
|
|
return obj.apply(this, arguments);
|
|
}
|
|
|
|
return processFn(obj, opts).apply(this, arguments);
|
|
};
|
|
} else {
|
|
ret = Object.create(Object.getPrototypeOf(obj));
|
|
}
|
|
|
|
for (const key in obj) { // eslint-disable-line guard-for-in
|
|
const x = obj[key];
|
|
ret[key] = typeof x === 'function' && filter(key) ? processFn(x, opts) : x;
|
|
}
|
|
|
|
return ret;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 386:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var stringify = __webpack_require__(897);
|
|
var parse = __webpack_require__(755);
|
|
var formats = __webpack_require__(13);
|
|
|
|
module.exports = {
|
|
formats: formats,
|
|
parse: parse,
|
|
stringify: stringify
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 394:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
exports.extract = __webpack_require__(364)
|
|
exports.pack = __webpack_require__(383)
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 400:
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var Stream = __webpack_require__(413)
|
|
|
|
// through
|
|
//
|
|
// a stream that does nothing but re-emit the input.
|
|
// useful for aggregating a series of changing but not ending streams into one stream)
|
|
|
|
exports = module.exports = through
|
|
through.through = through
|
|
|
|
//create a readable writable stream.
|
|
|
|
function through (write, end, opts) {
|
|
write = write || function (data) { this.queue(data) }
|
|
end = end || function () { this.queue(null) }
|
|
|
|
var ended = false, destroyed = false, buffer = [], _ended = false
|
|
var stream = new Stream()
|
|
stream.readable = stream.writable = true
|
|
stream.paused = false
|
|
|
|
// stream.autoPause = !(opts && opts.autoPause === false)
|
|
stream.autoDestroy = !(opts && opts.autoDestroy === false)
|
|
|
|
stream.write = function (data) {
|
|
write.call(this, data)
|
|
return !stream.paused
|
|
}
|
|
|
|
function drain() {
|
|
while(buffer.length && !stream.paused) {
|
|
var data = buffer.shift()
|
|
if(null === data)
|
|
return stream.emit('end')
|
|
else
|
|
stream.emit('data', data)
|
|
}
|
|
}
|
|
|
|
stream.queue = stream.push = function (data) {
|
|
// console.error(ended)
|
|
if(_ended) return stream
|
|
if(data === null) _ended = true
|
|
buffer.push(data)
|
|
drain()
|
|
return stream
|
|
}
|
|
|
|
//this will be registered as the first 'end' listener
|
|
//must call destroy next tick, to make sure we're after any
|
|
//stream piped from here.
|
|
//this is only a problem if end is not emitted synchronously.
|
|
//a nicer way to do this is to make sure this is the last listener for 'end'
|
|
|
|
stream.on('end', function () {
|
|
stream.readable = false
|
|
if(!stream.writable && stream.autoDestroy)
|
|
process.nextTick(function () {
|
|
stream.destroy()
|
|
})
|
|
})
|
|
|
|
function _end () {
|
|
stream.writable = false
|
|
end.call(stream)
|
|
if(!stream.readable && stream.autoDestroy)
|
|
stream.destroy()
|
|
}
|
|
|
|
stream.end = function (data) {
|
|
if(ended) return
|
|
ended = true
|
|
if(arguments.length) stream.write(data)
|
|
_end() // will emit or queue
|
|
return stream
|
|
}
|
|
|
|
stream.destroy = function () {
|
|
if(destroyed) return
|
|
destroyed = true
|
|
ended = true
|
|
buffer.length = 0
|
|
stream.writable = stream.readable = false
|
|
stream.emit('close')
|
|
return stream
|
|
}
|
|
|
|
stream.pause = function () {
|
|
if(stream.paused) return
|
|
stream.paused = true
|
|
return stream
|
|
}
|
|
|
|
stream.resume = function () {
|
|
if(stream.paused) {
|
|
stream.paused = false
|
|
stream.emit('resume')
|
|
}
|
|
drain()
|
|
//may have become paused again,
|
|
//as drain emits 'data'.
|
|
if(!stream.paused)
|
|
stream.emit('drain')
|
|
return stream
|
|
}
|
|
return stream
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 413:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("stream");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 417:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("crypto");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 420:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
module.exports = typeof Promise === 'function' ? Promise : __webpack_require__(501);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 425:
|
|
/***/ (function(module) {
|
|
|
|
/* Node.js 6.4.0 and up has full support */
|
|
var hasFullSupport = (function () {
|
|
try {
|
|
if (!Buffer.isEncoding('latin1')) {
|
|
return false
|
|
}
|
|
|
|
var buf = Buffer.alloc ? Buffer.alloc(4) : new Buffer(4)
|
|
|
|
buf.fill('ab', 'ucs2')
|
|
|
|
return (buf.toString('hex') === '61006200')
|
|
} catch (_) {
|
|
return false
|
|
}
|
|
}())
|
|
|
|
function isSingleByte (val) {
|
|
return (val.length === 1 && val.charCodeAt(0) < 256)
|
|
}
|
|
|
|
function fillWithNumber (buffer, val, start, end) {
|
|
if (start < 0 || end > buffer.length) {
|
|
throw new RangeError('Out of range index')
|
|
}
|
|
|
|
start = start >>> 0
|
|
end = end === undefined ? buffer.length : end >>> 0
|
|
|
|
if (end > start) {
|
|
buffer.fill(val, start, end)
|
|
}
|
|
|
|
return buffer
|
|
}
|
|
|
|
function fillWithBuffer (buffer, val, start, end) {
|
|
if (start < 0 || end > buffer.length) {
|
|
throw new RangeError('Out of range index')
|
|
}
|
|
|
|
if (end <= start) {
|
|
return buffer
|
|
}
|
|
|
|
start = start >>> 0
|
|
end = end === undefined ? buffer.length : end >>> 0
|
|
|
|
var pos = start
|
|
var len = val.length
|
|
while (pos <= (end - len)) {
|
|
val.copy(buffer, pos)
|
|
pos += len
|
|
}
|
|
|
|
if (pos !== end) {
|
|
val.copy(buffer, pos, 0, end - pos)
|
|
}
|
|
|
|
return buffer
|
|
}
|
|
|
|
function fill (buffer, val, start, end, encoding) {
|
|
if (hasFullSupport) {
|
|
return buffer.fill(val, start, end, encoding)
|
|
}
|
|
|
|
if (typeof val === 'number') {
|
|
return fillWithNumber(buffer, val, start, end)
|
|
}
|
|
|
|
if (typeof val === 'string') {
|
|
if (typeof start === 'string') {
|
|
encoding = start
|
|
start = 0
|
|
end = buffer.length
|
|
} else if (typeof end === 'string') {
|
|
encoding = end
|
|
end = buffer.length
|
|
}
|
|
|
|
if (encoding !== undefined && typeof encoding !== 'string') {
|
|
throw new TypeError('encoding must be a string')
|
|
}
|
|
|
|
if (encoding === 'latin1') {
|
|
encoding = 'binary'
|
|
}
|
|
|
|
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
|
throw new TypeError('Unknown encoding: ' + encoding)
|
|
}
|
|
|
|
if (val === '') {
|
|
return fillWithNumber(buffer, 0, start, end)
|
|
}
|
|
|
|
if (isSingleByte(val)) {
|
|
return fillWithNumber(buffer, val.charCodeAt(0), start, end)
|
|
}
|
|
|
|
val = new Buffer(val, encoding)
|
|
}
|
|
|
|
if (Buffer.isBuffer(val)) {
|
|
return fillWithBuffer(buffer, val, start, end)
|
|
}
|
|
|
|
// Other values (e.g. undefined, boolean, object) results in zero-fill
|
|
return fillWithNumber(buffer, 0, start, end)
|
|
}
|
|
|
|
module.exports = fill
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 427:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
module.exports = __webpack_require__(413);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 431:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
result["default"] = mod;
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const os = __importStar(__webpack_require__(87));
|
|
/**
|
|
* Commands
|
|
*
|
|
* Command Format:
|
|
* ::name key=value,key=value::message
|
|
*
|
|
* Examples:
|
|
* ::warning::This is the message
|
|
* ::set-env name=MY_VAR::some value
|
|
*/
|
|
function issueCommand(command, properties, message) {
|
|
const cmd = new Command(command, properties, message);
|
|
process.stdout.write(cmd.toString() + os.EOL);
|
|
}
|
|
exports.issueCommand = issueCommand;
|
|
function issue(name, message = '') {
|
|
issueCommand(name, {}, message);
|
|
}
|
|
exports.issue = issue;
|
|
const CMD_STRING = '::';
|
|
class Command {
|
|
constructor(command, properties, message) {
|
|
if (!command) {
|
|
command = 'missing.command';
|
|
}
|
|
this.command = command;
|
|
this.properties = properties;
|
|
this.message = message;
|
|
}
|
|
toString() {
|
|
let cmdStr = CMD_STRING + this.command;
|
|
if (this.properties && Object.keys(this.properties).length > 0) {
|
|
cmdStr += ' ';
|
|
let first = true;
|
|
for (const key in this.properties) {
|
|
if (this.properties.hasOwnProperty(key)) {
|
|
const val = this.properties[key];
|
|
if (val) {
|
|
if (first) {
|
|
first = false;
|
|
}
|
|
else {
|
|
cmdStr += ',';
|
|
}
|
|
cmdStr += `${key}=${escapeProperty(val)}`;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
|
|
return cmdStr;
|
|
}
|
|
}
|
|
function escapeData(s) {
|
|
return (s || '')
|
|
.replace(/%/g, '%25')
|
|
.replace(/\r/g, '%0D')
|
|
.replace(/\n/g, '%0A');
|
|
}
|
|
function escapeProperty(s) {
|
|
return (s || '')
|
|
.replace(/%/g, '%25')
|
|
.replace(/\r/g, '%0D')
|
|
.replace(/\n/g, '%0A')
|
|
.replace(/:/g, '%3A')
|
|
.replace(/,/g, '%2C');
|
|
}
|
|
//# sourceMappingURL=command.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 446:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const fileType = __webpack_require__(794);
|
|
|
|
const exts = new Set([
|
|
'7z',
|
|
'bz2',
|
|
'gz',
|
|
'rar',
|
|
'tar',
|
|
'zip',
|
|
'xz',
|
|
'gz'
|
|
]);
|
|
|
|
module.exports = input => {
|
|
const ret = fileType(input);
|
|
return exts.has(ret && ret.ext) ? ret : null;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 448:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var escapeStringRegexp = __webpack_require__(138);
|
|
|
|
module.exports = function (str, sub) {
|
|
if (typeof str !== 'string' || typeof sub !== 'string') {
|
|
throw new TypeError();
|
|
}
|
|
|
|
sub = escapeStringRegexp(sub);
|
|
return str.replace(new RegExp('^' + sub + '|' + sub + '$', 'g'), '');
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 453:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var once = __webpack_require__(49)
|
|
var eos = __webpack_require__(9)
|
|
var fs = __webpack_require__(747) // we only need fs to get the ReadStream and WriteStream prototypes
|
|
|
|
var noop = function () {}
|
|
var ancient = /^v?\.0/.test(process.version)
|
|
|
|
var isFn = function (fn) {
|
|
return typeof fn === 'function'
|
|
}
|
|
|
|
var isFS = function (stream) {
|
|
if (!ancient) return false // newer node version do not need to care about fs is a special way
|
|
if (!fs) return false // browser
|
|
return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close)
|
|
}
|
|
|
|
var isRequest = function (stream) {
|
|
return stream.setHeader && isFn(stream.abort)
|
|
}
|
|
|
|
var destroyer = function (stream, reading, writing, callback) {
|
|
callback = once(callback)
|
|
|
|
var closed = false
|
|
stream.on('close', function () {
|
|
closed = true
|
|
})
|
|
|
|
eos(stream, {readable: reading, writable: writing}, function (err) {
|
|
if (err) return callback(err)
|
|
closed = true
|
|
callback()
|
|
})
|
|
|
|
var destroyed = false
|
|
return function (err) {
|
|
if (closed) return
|
|
if (destroyed) return
|
|
destroyed = true
|
|
|
|
if (isFS(stream)) return stream.close(noop) // use close for fs streams to avoid fd leaks
|
|
if (isRequest(stream)) return stream.abort() // request.destroy just do .end - .abort is what we want
|
|
|
|
if (isFn(stream.destroy)) return stream.destroy()
|
|
|
|
callback(err || new Error('stream was destroyed'))
|
|
}
|
|
}
|
|
|
|
var call = function (fn) {
|
|
fn()
|
|
}
|
|
|
|
var pipe = function (from, to) {
|
|
return from.pipe(to)
|
|
}
|
|
|
|
var pump = function () {
|
|
var streams = Array.prototype.slice.call(arguments)
|
|
var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop
|
|
|
|
if (Array.isArray(streams[0])) streams = streams[0]
|
|
if (streams.length < 2) throw new Error('pump requires two streams per minimum')
|
|
|
|
var error
|
|
var destroys = streams.map(function (stream, i) {
|
|
var reading = i < streams.length - 1
|
|
var writing = i > 0
|
|
return destroyer(stream, reading, writing, function (err) {
|
|
if (!error) error = err
|
|
if (err) destroys.forEach(call)
|
|
if (reading) return
|
|
destroys.forEach(call)
|
|
callback(error)
|
|
})
|
|
})
|
|
|
|
return streams.reduce(pipe)
|
|
}
|
|
|
|
module.exports = pump
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 458:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
/**
|
|
* @file Tests if ES6 @@toStringTag is supported.
|
|
* @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-@@tostringtag|26.3.1 @@toStringTag}
|
|
* @version 1.4.1
|
|
* @author Xotic750 <Xotic750@gmail.com>
|
|
* @copyright Xotic750
|
|
* @license {@link <https://opensource.org/licenses/MIT> MIT}
|
|
* @module has-to-string-tag-x
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
* Indicates if `Symbol.toStringTag`exists and is the correct type.
|
|
* `true`, if it exists and is the correct type, otherwise `false`.
|
|
*
|
|
* @type boolean
|
|
*/
|
|
module.exports = __webpack_require__(565) && typeof Symbol.toStringTag === 'symbol';
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 462:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
// Copied from https://github.com/nodejs/node/blob/master/lib/internal/url.js
|
|
|
|
function urlToOptions(url) {
|
|
var options = {
|
|
protocol: url.protocol,
|
|
hostname: url.hostname,
|
|
hash: url.hash,
|
|
search: url.search,
|
|
pathname: url.pathname,
|
|
path: `${url.pathname}${url.search}`,
|
|
href: url.href
|
|
};
|
|
if (url.port !== '') {
|
|
options.port = Number(url.port);
|
|
}
|
|
if (url.username || url.password) {
|
|
options.auth = `${url.username}:${url.password}`;
|
|
}
|
|
return options;
|
|
}
|
|
|
|
|
|
|
|
module.exports = urlToOptions;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 464:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var processFn = function (fn, P, opts) {
|
|
return function () {
|
|
var that = this;
|
|
var args = new Array(arguments.length);
|
|
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
args[i] = arguments[i];
|
|
}
|
|
|
|
return new P(function (resolve, reject) {
|
|
args.push(function (err, result) {
|
|
if (err) {
|
|
reject(err);
|
|
} else if (opts.multiArgs) {
|
|
var results = new Array(arguments.length - 1);
|
|
|
|
for (var i = 1; i < arguments.length; i++) {
|
|
results[i - 1] = arguments[i];
|
|
}
|
|
|
|
resolve(results);
|
|
} else {
|
|
resolve(result);
|
|
}
|
|
});
|
|
|
|
fn.apply(that, args);
|
|
});
|
|
};
|
|
};
|
|
|
|
var pify = module.exports = function (obj, P, opts) {
|
|
if (typeof P !== 'function') {
|
|
opts = P;
|
|
P = Promise;
|
|
}
|
|
|
|
opts = opts || {};
|
|
opts.exclude = opts.exclude || [/.+Sync$/];
|
|
|
|
var filter = function (key) {
|
|
var match = function (pattern) {
|
|
return typeof pattern === 'string' ? key === pattern : pattern.test(key);
|
|
};
|
|
|
|
return opts.include ? opts.include.some(match) : !opts.exclude.some(match);
|
|
};
|
|
|
|
var ret = typeof obj === 'function' ? function () {
|
|
if (opts.excludeMain) {
|
|
return obj.apply(this, arguments);
|
|
}
|
|
|
|
return processFn(obj, P, opts).apply(this, arguments);
|
|
} : {};
|
|
|
|
return Object.keys(obj).reduce(function (ret, key) {
|
|
var x = obj[key];
|
|
|
|
ret[key] = typeof x === 'function' && filter(key) ? processFn(x, P, opts) : x;
|
|
|
|
return ret;
|
|
}, ret);
|
|
};
|
|
|
|
pify.all = pify;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 470:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
result["default"] = mod;
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const command_1 = __webpack_require__(431);
|
|
const os = __importStar(__webpack_require__(87));
|
|
const path = __importStar(__webpack_require__(622));
|
|
/**
|
|
* The code to exit an action
|
|
*/
|
|
var ExitCode;
|
|
(function (ExitCode) {
|
|
/**
|
|
* A code indicating that the action was successful
|
|
*/
|
|
ExitCode[ExitCode["Success"] = 0] = "Success";
|
|
/**
|
|
* A code indicating that the action was a failure
|
|
*/
|
|
ExitCode[ExitCode["Failure"] = 1] = "Failure";
|
|
})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
|
|
//-----------------------------------------------------------------------
|
|
// Variables
|
|
//-----------------------------------------------------------------------
|
|
/**
|
|
* Sets env variable for this action and future actions in the job
|
|
* @param name the name of the variable to set
|
|
* @param val the value of the variable
|
|
*/
|
|
function exportVariable(name, val) {
|
|
process.env[name] = val;
|
|
command_1.issueCommand('set-env', { name }, val);
|
|
}
|
|
exports.exportVariable = exportVariable;
|
|
/**
|
|
* Registers a secret which will get masked from logs
|
|
* @param secret value of the secret
|
|
*/
|
|
function setSecret(secret) {
|
|
command_1.issueCommand('add-mask', {}, secret);
|
|
}
|
|
exports.setSecret = setSecret;
|
|
/**
|
|
* Prepends inputPath to the PATH (for this action and future actions)
|
|
* @param inputPath
|
|
*/
|
|
function addPath(inputPath) {
|
|
command_1.issueCommand('add-path', {}, inputPath);
|
|
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
|
}
|
|
exports.addPath = addPath;
|
|
/**
|
|
* Gets the value of an input. The value is also trimmed.
|
|
*
|
|
* @param name name of the input to get
|
|
* @param options optional. See InputOptions.
|
|
* @returns string
|
|
*/
|
|
function getInput(name, options) {
|
|
const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
|
|
if (options && options.required && !val) {
|
|
throw new Error(`Input required and not supplied: ${name}`);
|
|
}
|
|
return val.trim();
|
|
}
|
|
exports.getInput = getInput;
|
|
/**
|
|
* Sets the value of an output.
|
|
*
|
|
* @param name name of the output to set
|
|
* @param value value to store
|
|
*/
|
|
function setOutput(name, value) {
|
|
command_1.issueCommand('set-output', { name }, value);
|
|
}
|
|
exports.setOutput = setOutput;
|
|
//-----------------------------------------------------------------------
|
|
// Results
|
|
//-----------------------------------------------------------------------
|
|
/**
|
|
* Sets the action status to failed.
|
|
* When the action exits it will be with an exit code of 1
|
|
* @param message add error issue message
|
|
*/
|
|
function setFailed(message) {
|
|
process.exitCode = ExitCode.Failure;
|
|
error(message);
|
|
}
|
|
exports.setFailed = setFailed;
|
|
//-----------------------------------------------------------------------
|
|
// Logging Commands
|
|
//-----------------------------------------------------------------------
|
|
/**
|
|
* Gets whether Actions Step Debug is on or not
|
|
*/
|
|
function isDebug() {
|
|
return process.env['RUNNER_DEBUG'] === '1';
|
|
}
|
|
exports.isDebug = isDebug;
|
|
/**
|
|
* Writes debug message to user log
|
|
* @param message debug message
|
|
*/
|
|
function debug(message) {
|
|
command_1.issueCommand('debug', {}, message);
|
|
}
|
|
exports.debug = debug;
|
|
/**
|
|
* Adds an error issue
|
|
* @param message error issue message
|
|
*/
|
|
function error(message) {
|
|
command_1.issue('error', message);
|
|
}
|
|
exports.error = error;
|
|
/**
|
|
* Adds an warning issue
|
|
* @param message warning issue message
|
|
*/
|
|
function warning(message) {
|
|
command_1.issue('warning', message);
|
|
}
|
|
exports.warning = warning;
|
|
/**
|
|
* Writes info to log with console.log.
|
|
* @param message info message
|
|
*/
|
|
function info(message) {
|
|
process.stdout.write(message + os.EOL);
|
|
}
|
|
exports.info = info;
|
|
/**
|
|
* Begin an output group.
|
|
*
|
|
* Output until the next `groupEnd` will be foldable in this group
|
|
*
|
|
* @param name The name of the output group
|
|
*/
|
|
function startGroup(name) {
|
|
command_1.issue('group', name);
|
|
}
|
|
exports.startGroup = startGroup;
|
|
/**
|
|
* End an output group.
|
|
*/
|
|
function endGroup() {
|
|
command_1.issue('endgroup');
|
|
}
|
|
exports.endGroup = endGroup;
|
|
/**
|
|
* Wrap an asynchronous function call in a group.
|
|
*
|
|
* Returns the same type as the function itself.
|
|
*
|
|
* @param name The name of the group
|
|
* @param fn The function to wrap in the group
|
|
*/
|
|
function group(name, fn) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
startGroup(name);
|
|
let result;
|
|
try {
|
|
result = yield fn();
|
|
}
|
|
finally {
|
|
endGroup();
|
|
}
|
|
return result;
|
|
});
|
|
}
|
|
exports.group = group;
|
|
//-----------------------------------------------------------------------
|
|
// Wrapper action state
|
|
//-----------------------------------------------------------------------
|
|
/**
|
|
* Saves state for current action, the state can only be retrieved by this action's post job execution.
|
|
*
|
|
* @param name name of the state to store
|
|
* @param value value to store
|
|
*/
|
|
function saveState(name, value) {
|
|
command_1.issueCommand('save-state', { name }, value);
|
|
}
|
|
exports.saveState = saveState;
|
|
/**
|
|
* Gets the value of an state set by this action's main execution.
|
|
*
|
|
* @param name name of the state to get
|
|
* @returns string
|
|
*/
|
|
function getState(name) {
|
|
return process.env[`STATE_${name}`] || '';
|
|
}
|
|
exports.getState = getState;
|
|
//# sourceMappingURL=core.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 474:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
module.exports = function (obj) {
|
|
var ret = {};
|
|
var keys = Object.keys(Object(obj));
|
|
|
|
for (var i = 0; i < keys.length; i++) {
|
|
ret[keys[i].toLowerCase()] = obj[keys[i]];
|
|
}
|
|
|
|
return ret;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 482:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = {"_args":[["got@8.3.2","/home/runner/work/ghaction-upx/ghaction-upx"]],"_from":"got@8.3.2","_id":"got@8.3.2","_inBundle":false,"_integrity":"sha512-qjUJ5U/hawxosMryILofZCkm3C84PLJS/0grRIpjAwu+Lkxxj5cxeCU25BG0/3mDSpXKTyZr8oh8wIgLaH0QCw==","_location":"/got","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"got@8.3.2","name":"got","escapedName":"got","rawSpec":"8.3.2","saveSpec":null,"fetchSpec":"8.3.2"},"_requiredBy":["/download"],"_resolved":"https://registry.npmjs.org/got/-/got-8.3.2.tgz","_spec":"8.3.2","_where":"/home/runner/work/ghaction-upx/ghaction-upx","ava":{"concurrency":4},"browser":{"decompress-response":false,"electron":false},"bugs":{"url":"https://github.com/sindresorhus/got/issues"},"dependencies":{"@sindresorhus/is":"^0.7.0","cacheable-request":"^2.1.1","decompress-response":"^3.3.0","duplexer3":"^0.1.4","get-stream":"^3.0.0","into-stream":"^3.1.0","is-retry-allowed":"^1.1.0","isurl":"^1.0.0-alpha5","lowercase-keys":"^1.0.0","mimic-response":"^1.0.0","p-cancelable":"^0.4.0","p-timeout":"^2.0.1","pify":"^3.0.0","safe-buffer":"^5.1.1","timed-out":"^4.0.1","url-parse-lax":"^3.0.0","url-to-options":"^1.0.1"},"description":"Simplified HTTP requests","devDependencies":{"ava":"^0.25.0","coveralls":"^3.0.0","form-data":"^2.1.1","get-port":"^3.0.0","nyc":"^11.0.2","p-event":"^1.3.0","pem":"^1.4.4","proxyquire":"^1.8.0","sinon":"^4.0.0","slow-stream":"0.0.4","tempfile":"^2.0.0","tempy":"^0.2.1","universal-url":"1.0.0-alpha","xo":"^0.20.0"},"engines":{"node":">=4"},"files":["index.js","errors.js"],"homepage":"https://github.com/sindresorhus/got#readme","keywords":["http","https","get","got","url","uri","request","util","utility","simple","curl","wget","fetch","net","network","electron"],"license":"MIT","maintainers":[{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},{"name":"Vsevolod Strukchinsky","email":"floatdrop@gmail.com","url":"github.com/floatdrop"},{"name":"Alexander Tesfamichael","email":"alex.tesfamichael@gmail.com","url":"alextes.me"}],"name":"got","repository":{"type":"git","url":"git+https://github.com/sindresorhus/got.git"},"scripts":{"coveralls":"nyc report --reporter=text-lcov | coveralls","test":"xo && nyc ava"},"version":"8.3.2"};
|
|
|
|
/***/ }),
|
|
|
|
/***/ 489:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const fs = __webpack_require__(747);
|
|
const path = __webpack_require__(622);
|
|
const pify = __webpack_require__(385);
|
|
|
|
const defaults = {
|
|
mode: 0o777 & (~process.umask()),
|
|
fs
|
|
};
|
|
|
|
// https://github.com/nodejs/node/issues/8987
|
|
// https://github.com/libuv/libuv/pull/1088
|
|
const checkPath = pth => {
|
|
if (process.platform === 'win32') {
|
|
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''));
|
|
|
|
if (pathHasInvalidWinCharacters) {
|
|
const err = new Error(`Path contains invalid characters: ${pth}`);
|
|
err.code = 'EINVAL';
|
|
throw err;
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = (input, opts) => Promise.resolve().then(() => {
|
|
checkPath(input);
|
|
opts = Object.assign({}, defaults, opts);
|
|
|
|
const mkdir = pify(opts.fs.mkdir);
|
|
const stat = pify(opts.fs.stat);
|
|
|
|
const make = pth => {
|
|
return mkdir(pth, opts.mode)
|
|
.then(() => pth)
|
|
.catch(err => {
|
|
if (err.code === 'ENOENT') {
|
|
if (err.message.includes('null bytes') || path.dirname(pth) === pth) {
|
|
throw err;
|
|
}
|
|
|
|
return make(path.dirname(pth)).then(() => make(pth));
|
|
}
|
|
|
|
return stat(pth)
|
|
.then(stats => stats.isDirectory() ? pth : Promise.reject())
|
|
.catch(() => {
|
|
throw err;
|
|
});
|
|
});
|
|
};
|
|
|
|
return make(path.resolve(input));
|
|
});
|
|
|
|
module.exports.sync = (input, opts) => {
|
|
checkPath(input);
|
|
opts = Object.assign({}, defaults, opts);
|
|
|
|
const make = pth => {
|
|
try {
|
|
opts.fs.mkdirSync(pth, opts.mode);
|
|
} catch (err) {
|
|
if (err.code === 'ENOENT') {
|
|
if (err.message.includes('null bytes') || path.dirname(pth) === pth) {
|
|
throw err;
|
|
}
|
|
|
|
make(path.dirname(pth));
|
|
return make(pth);
|
|
}
|
|
|
|
try {
|
|
if (!opts.fs.statSync(pth).isDirectory()) {
|
|
throw new Error('The path is not a directory');
|
|
}
|
|
} catch (_) {
|
|
throw err;
|
|
}
|
|
}
|
|
|
|
return pth;
|
|
};
|
|
|
|
return make(path.resolve(input));
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 492:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
/*!
|
|
* content-disposition
|
|
* Copyright(c) 2014-2017 Douglas Christopher Wilson
|
|
* MIT Licensed
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
* Module exports.
|
|
* @public
|
|
*/
|
|
|
|
module.exports = contentDisposition
|
|
module.exports.parse = parse
|
|
|
|
/**
|
|
* Module dependencies.
|
|
* @private
|
|
*/
|
|
|
|
var basename = __webpack_require__(622).basename
|
|
var Buffer = __webpack_require__(309).Buffer
|
|
|
|
/**
|
|
* RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including "%")
|
|
* @private
|
|
*/
|
|
|
|
var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g // eslint-disable-line no-control-regex
|
|
|
|
/**
|
|
* RegExp to match percent encoding escape.
|
|
* @private
|
|
*/
|
|
|
|
var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/
|
|
var HEX_ESCAPE_REPLACE_REGEXP = /%([0-9A-Fa-f]{2})/g
|
|
|
|
/**
|
|
* RegExp to match non-latin1 characters.
|
|
* @private
|
|
*/
|
|
|
|
var NON_LATIN1_REGEXP = /[^\x20-\x7e\xa0-\xff]/g
|
|
|
|
/**
|
|
* RegExp to match quoted-pair in RFC 2616
|
|
*
|
|
* quoted-pair = "\" CHAR
|
|
* CHAR = <any US-ASCII character (octets 0 - 127)>
|
|
* @private
|
|
*/
|
|
|
|
var QESC_REGEXP = /\\([\u0000-\u007f])/g // eslint-disable-line no-control-regex
|
|
|
|
/**
|
|
* RegExp to match chars that must be quoted-pair in RFC 2616
|
|
* @private
|
|
*/
|
|
|
|
var QUOTE_REGEXP = /([\\"])/g
|
|
|
|
/**
|
|
* RegExp for various RFC 2616 grammar
|
|
*
|
|
* parameter = token "=" ( token | quoted-string )
|
|
* token = 1*<any CHAR except CTLs or separators>
|
|
* separators = "(" | ")" | "<" | ">" | "@"
|
|
* | "," | ";" | ":" | "\" | <">
|
|
* | "/" | "[" | "]" | "?" | "="
|
|
* | "{" | "}" | SP | HT
|
|
* quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
|
|
* qdtext = <any TEXT except <">>
|
|
* quoted-pair = "\" CHAR
|
|
* CHAR = <any US-ASCII character (octets 0 - 127)>
|
|
* TEXT = <any OCTET except CTLs, but including LWS>
|
|
* LWS = [CRLF] 1*( SP | HT )
|
|
* CRLF = CR LF
|
|
* CR = <US-ASCII CR, carriage return (13)>
|
|
* LF = <US-ASCII LF, linefeed (10)>
|
|
* SP = <US-ASCII SP, space (32)>
|
|
* HT = <US-ASCII HT, horizontal-tab (9)>
|
|
* CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>
|
|
* OCTET = <any 8-bit sequence of data>
|
|
* @private
|
|
*/
|
|
|
|
var PARAM_REGEXP = /;[\x09\x20]*([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*=[\x09\x20]*("(?:[\x20!\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*/g // eslint-disable-line no-control-regex
|
|
var TEXT_REGEXP = /^[\x20-\x7e\x80-\xff]+$/
|
|
var TOKEN_REGEXP = /^[!#$%&'*+.0-9A-Z^_`a-z|~-]+$/
|
|
|
|
/**
|
|
* RegExp for various RFC 5987 grammar
|
|
*
|
|
* ext-value = charset "'" [ language ] "'" value-chars
|
|
* charset = "UTF-8" / "ISO-8859-1" / mime-charset
|
|
* mime-charset = 1*mime-charsetc
|
|
* mime-charsetc = ALPHA / DIGIT
|
|
* / "!" / "#" / "$" / "%" / "&"
|
|
* / "+" / "-" / "^" / "_" / "`"
|
|
* / "{" / "}" / "~"
|
|
* language = ( 2*3ALPHA [ extlang ] )
|
|
* / 4ALPHA
|
|
* / 5*8ALPHA
|
|
* extlang = *3( "-" 3ALPHA )
|
|
* value-chars = *( pct-encoded / attr-char )
|
|
* pct-encoded = "%" HEXDIG HEXDIG
|
|
* attr-char = ALPHA / DIGIT
|
|
* / "!" / "#" / "$" / "&" / "+" / "-" / "."
|
|
* / "^" / "_" / "`" / "|" / "~"
|
|
* @private
|
|
*/
|
|
|
|
var EXT_VALUE_REGEXP = /^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+.^_`|~-])+)$/
|
|
|
|
/**
|
|
* RegExp for various RFC 6266 grammar
|
|
*
|
|
* disposition-type = "inline" | "attachment" | disp-ext-type
|
|
* disp-ext-type = token
|
|
* disposition-parm = filename-parm | disp-ext-parm
|
|
* filename-parm = "filename" "=" value
|
|
* | "filename*" "=" ext-value
|
|
* disp-ext-parm = token "=" value
|
|
* | ext-token "=" ext-value
|
|
* ext-token = <the characters in token, followed by "*">
|
|
* @private
|
|
*/
|
|
|
|
var DISPOSITION_TYPE_REGEXP = /^([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*(?:$|;)/ // eslint-disable-line no-control-regex
|
|
|
|
/**
|
|
* Create an attachment Content-Disposition header.
|
|
*
|
|
* @param {string} [filename]
|
|
* @param {object} [options]
|
|
* @param {string} [options.type=attachment]
|
|
* @param {string|boolean} [options.fallback=true]
|
|
* @return {string}
|
|
* @public
|
|
*/
|
|
|
|
function contentDisposition (filename, options) {
|
|
var opts = options || {}
|
|
|
|
// get type
|
|
var type = opts.type || 'attachment'
|
|
|
|
// get parameters
|
|
var params = createparams(filename, opts.fallback)
|
|
|
|
// format into string
|
|
return format(new ContentDisposition(type, params))
|
|
}
|
|
|
|
/**
|
|
* Create parameters object from filename and fallback.
|
|
*
|
|
* @param {string} [filename]
|
|
* @param {string|boolean} [fallback=true]
|
|
* @return {object}
|
|
* @private
|
|
*/
|
|
|
|
function createparams (filename, fallback) {
|
|
if (filename === undefined) {
|
|
return
|
|
}
|
|
|
|
var params = {}
|
|
|
|
if (typeof filename !== 'string') {
|
|
throw new TypeError('filename must be a string')
|
|
}
|
|
|
|
// fallback defaults to true
|
|
if (fallback === undefined) {
|
|
fallback = true
|
|
}
|
|
|
|
if (typeof fallback !== 'string' && typeof fallback !== 'boolean') {
|
|
throw new TypeError('fallback must be a string or boolean')
|
|
}
|
|
|
|
if (typeof fallback === 'string' && NON_LATIN1_REGEXP.test(fallback)) {
|
|
throw new TypeError('fallback must be ISO-8859-1 string')
|
|
}
|
|
|
|
// restrict to file base name
|
|
var name = basename(filename)
|
|
|
|
// determine if name is suitable for quoted string
|
|
var isQuotedString = TEXT_REGEXP.test(name)
|
|
|
|
// generate fallback name
|
|
var fallbackName = typeof fallback !== 'string'
|
|
? fallback && getlatin1(name)
|
|
: basename(fallback)
|
|
var hasFallback = typeof fallbackName === 'string' && fallbackName !== name
|
|
|
|
// set extended filename parameter
|
|
if (hasFallback || !isQuotedString || HEX_ESCAPE_REGEXP.test(name)) {
|
|
params['filename*'] = name
|
|
}
|
|
|
|
// set filename parameter
|
|
if (isQuotedString || hasFallback) {
|
|
params.filename = hasFallback
|
|
? fallbackName
|
|
: name
|
|
}
|
|
|
|
return params
|
|
}
|
|
|
|
/**
|
|
* Format object to Content-Disposition header.
|
|
*
|
|
* @param {object} obj
|
|
* @param {string} obj.type
|
|
* @param {object} [obj.parameters]
|
|
* @return {string}
|
|
* @private
|
|
*/
|
|
|
|
function format (obj) {
|
|
var parameters = obj.parameters
|
|
var type = obj.type
|
|
|
|
if (!type || typeof type !== 'string' || !TOKEN_REGEXP.test(type)) {
|
|
throw new TypeError('invalid type')
|
|
}
|
|
|
|
// start with normalized type
|
|
var string = String(type).toLowerCase()
|
|
|
|
// append parameters
|
|
if (parameters && typeof parameters === 'object') {
|
|
var param
|
|
var params = Object.keys(parameters).sort()
|
|
|
|
for (var i = 0; i < params.length; i++) {
|
|
param = params[i]
|
|
|
|
var val = param.substr(-1) === '*'
|
|
? ustring(parameters[param])
|
|
: qstring(parameters[param])
|
|
|
|
string += '; ' + param + '=' + val
|
|
}
|
|
}
|
|
|
|
return string
|
|
}
|
|
|
|
/**
|
|
* Decode a RFC 6987 field value (gracefully).
|
|
*
|
|
* @param {string} str
|
|
* @return {string}
|
|
* @private
|
|
*/
|
|
|
|
function decodefield (str) {
|
|
var match = EXT_VALUE_REGEXP.exec(str)
|
|
|
|
if (!match) {
|
|
throw new TypeError('invalid extended field value')
|
|
}
|
|
|
|
var charset = match[1].toLowerCase()
|
|
var encoded = match[2]
|
|
var value
|
|
|
|
// to binary string
|
|
var binary = encoded.replace(HEX_ESCAPE_REPLACE_REGEXP, pdecode)
|
|
|
|
switch (charset) {
|
|
case 'iso-8859-1':
|
|
value = getlatin1(binary)
|
|
break
|
|
case 'utf-8':
|
|
value = Buffer.from(binary, 'binary').toString('utf8')
|
|
break
|
|
default:
|
|
throw new TypeError('unsupported charset in extended field')
|
|
}
|
|
|
|
return value
|
|
}
|
|
|
|
/**
|
|
* Get ISO-8859-1 version of string.
|
|
*
|
|
* @param {string} val
|
|
* @return {string}
|
|
* @private
|
|
*/
|
|
|
|
function getlatin1 (val) {
|
|
// simple Unicode -> ISO-8859-1 transformation
|
|
return String(val).replace(NON_LATIN1_REGEXP, '?')
|
|
}
|
|
|
|
/**
|
|
* Parse Content-Disposition header string.
|
|
*
|
|
* @param {string} string
|
|
* @return {object}
|
|
* @public
|
|
*/
|
|
|
|
function parse (string) {
|
|
if (!string || typeof string !== 'string') {
|
|
throw new TypeError('argument string is required')
|
|
}
|
|
|
|
var match = DISPOSITION_TYPE_REGEXP.exec(string)
|
|
|
|
if (!match) {
|
|
throw new TypeError('invalid type format')
|
|
}
|
|
|
|
// normalize type
|
|
var index = match[0].length
|
|
var type = match[1].toLowerCase()
|
|
|
|
var key
|
|
var names = []
|
|
var params = {}
|
|
var value
|
|
|
|
// calculate index to start at
|
|
index = PARAM_REGEXP.lastIndex = match[0].substr(-1) === ';'
|
|
? index - 1
|
|
: index
|
|
|
|
// match parameters
|
|
while ((match = PARAM_REGEXP.exec(string))) {
|
|
if (match.index !== index) {
|
|
throw new TypeError('invalid parameter format')
|
|
}
|
|
|
|
index += match[0].length
|
|
key = match[1].toLowerCase()
|
|
value = match[2]
|
|
|
|
if (names.indexOf(key) !== -1) {
|
|
throw new TypeError('invalid duplicate parameter')
|
|
}
|
|
|
|
names.push(key)
|
|
|
|
if (key.indexOf('*') + 1 === key.length) {
|
|
// decode extended value
|
|
key = key.slice(0, -1)
|
|
value = decodefield(value)
|
|
|
|
// overwrite existing value
|
|
params[key] = value
|
|
continue
|
|
}
|
|
|
|
if (typeof params[key] === 'string') {
|
|
continue
|
|
}
|
|
|
|
if (value[0] === '"') {
|
|
// remove quotes and escapes
|
|
value = value
|
|
.substr(1, value.length - 2)
|
|
.replace(QESC_REGEXP, '$1')
|
|
}
|
|
|
|
params[key] = value
|
|
}
|
|
|
|
if (index !== -1 && index !== string.length) {
|
|
throw new TypeError('invalid parameter format')
|
|
}
|
|
|
|
return new ContentDisposition(type, params)
|
|
}
|
|
|
|
/**
|
|
* Percent decode a single character.
|
|
*
|
|
* @param {string} str
|
|
* @param {string} hex
|
|
* @return {string}
|
|
* @private
|
|
*/
|
|
|
|
function pdecode (str, hex) {
|
|
return String.fromCharCode(parseInt(hex, 16))
|
|
}
|
|
|
|
/**
|
|
* Percent encode a single character.
|
|
*
|
|
* @param {string} char
|
|
* @return {string}
|
|
* @private
|
|
*/
|
|
|
|
function pencode (char) {
|
|
return '%' + String(char)
|
|
.charCodeAt(0)
|
|
.toString(16)
|
|
.toUpperCase()
|
|
}
|
|
|
|
/**
|
|
* Quote a string for HTTP.
|
|
*
|
|
* @param {string} val
|
|
* @return {string}
|
|
* @private
|
|
*/
|
|
|
|
function qstring (val) {
|
|
var str = String(val)
|
|
|
|
return '"' + str.replace(QUOTE_REGEXP, '\\$1') + '"'
|
|
}
|
|
|
|
/**
|
|
* Encode a Unicode string for HTTP (RFC 5987).
|
|
*
|
|
* @param {string} val
|
|
* @return {string}
|
|
* @private
|
|
*/
|
|
|
|
function ustring (val) {
|
|
var str = String(val)
|
|
|
|
// percent encode as UTF-8
|
|
var encoded = encodeURIComponent(str)
|
|
.replace(ENCODE_URL_ATTR_CHAR_REGEXP, pencode)
|
|
|
|
return 'UTF-8\'\'' + encoded
|
|
}
|
|
|
|
/**
|
|
* Class for parsed Content-Disposition header for v8 optimization
|
|
*
|
|
* @public
|
|
* @param {string} type
|
|
* @param {object} parameters
|
|
* @constructor
|
|
*/
|
|
|
|
function ContentDisposition (type, parameters) {
|
|
this.type = type
|
|
this.parameters = parameters
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 496:
|
|
/***/ (function(module) {
|
|
|
|
/* CRC32, used in Bzip2 implementation.
|
|
* This is a port of CRC32.java from the jbzip2 implementation at
|
|
* https://code.google.com/p/jbzip2
|
|
* which is:
|
|
* Copyright (c) 2011 Matthew Francis
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person
|
|
* obtaining a copy of this software and associated documentation
|
|
* files (the "Software"), to deal in the Software without
|
|
* restriction, including without limitation the rights to use,
|
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following
|
|
* conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be
|
|
* included in all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
* This JavaScript implementation is:
|
|
* Copyright (c) 2013 C. Scott Ananian
|
|
* with the same licensing terms as Matthew Francis' original implementation.
|
|
*/
|
|
module.exports = (function() {
|
|
|
|
/**
|
|
* A static CRC lookup table
|
|
*/
|
|
var crc32Lookup = new Uint32Array([
|
|
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005,
|
|
0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
|
|
0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75,
|
|
0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd,
|
|
0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5,
|
|
0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d,
|
|
0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
|
|
0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d,
|
|
0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072,
|
|
0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca,
|
|
0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02,
|
|
0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
|
|
0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692,
|
|
0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a,
|
|
0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2,
|
|
0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a,
|
|
0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
|
|
0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53,
|
|
0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b,
|
|
0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623,
|
|
0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b,
|
|
0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
|
|
0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b,
|
|
0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3,
|
|
0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c,
|
|
0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24,
|
|
0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
|
|
0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654,
|
|
0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c,
|
|
0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4,
|
|
0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c,
|
|
0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
|
|
]);
|
|
|
|
var CRC32 = function() {
|
|
/**
|
|
* The current CRC
|
|
*/
|
|
var crc = 0xffffffff;
|
|
|
|
/**
|
|
* @return The current CRC
|
|
*/
|
|
this.getCRC = function() {
|
|
return (~crc) >>> 0; // return an unsigned value
|
|
};
|
|
|
|
/**
|
|
* Update the CRC with a single byte
|
|
* @param value The value to update the CRC with
|
|
*/
|
|
this.updateCRC = function(value) {
|
|
crc = (crc << 8) ^ crc32Lookup[((crc >>> 24) ^ value) & 0xff];
|
|
};
|
|
|
|
/**
|
|
* Update the CRC with a sequence of identical bytes
|
|
* @param value The value to update the CRC with
|
|
* @param count The number of bytes
|
|
*/
|
|
this.updateCRCRun = function(value, count) {
|
|
while (count-- > 0) {
|
|
crc = (crc << 8) ^ crc32Lookup[((crc >>> 24) ^ value) & 0xff];
|
|
}
|
|
};
|
|
};
|
|
return CRC32;
|
|
})();
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 501:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var PENDING = 'pending';
|
|
var SETTLED = 'settled';
|
|
var FULFILLED = 'fulfilled';
|
|
var REJECTED = 'rejected';
|
|
var NOOP = function () {};
|
|
var isNode = typeof global !== 'undefined' && typeof global.process !== 'undefined' && typeof global.process.emit === 'function';
|
|
|
|
var asyncSetTimer = typeof setImmediate === 'undefined' ? setTimeout : setImmediate;
|
|
var asyncQueue = [];
|
|
var asyncTimer;
|
|
|
|
function asyncFlush() {
|
|
// run promise callbacks
|
|
for (var i = 0; i < asyncQueue.length; i++) {
|
|
asyncQueue[i][0](asyncQueue[i][1]);
|
|
}
|
|
|
|
// reset async asyncQueue
|
|
asyncQueue = [];
|
|
asyncTimer = false;
|
|
}
|
|
|
|
function asyncCall(callback, arg) {
|
|
asyncQueue.push([callback, arg]);
|
|
|
|
if (!asyncTimer) {
|
|
asyncTimer = true;
|
|
asyncSetTimer(asyncFlush, 0);
|
|
}
|
|
}
|
|
|
|
function invokeResolver(resolver, promise) {
|
|
function resolvePromise(value) {
|
|
resolve(promise, value);
|
|
}
|
|
|
|
function rejectPromise(reason) {
|
|
reject(promise, reason);
|
|
}
|
|
|
|
try {
|
|
resolver(resolvePromise, rejectPromise);
|
|
} catch (e) {
|
|
rejectPromise(e);
|
|
}
|
|
}
|
|
|
|
function invokeCallback(subscriber) {
|
|
var owner = subscriber.owner;
|
|
var settled = owner._state;
|
|
var value = owner._data;
|
|
var callback = subscriber[settled];
|
|
var promise = subscriber.then;
|
|
|
|
if (typeof callback === 'function') {
|
|
settled = FULFILLED;
|
|
try {
|
|
value = callback(value);
|
|
} catch (e) {
|
|
reject(promise, e);
|
|
}
|
|
}
|
|
|
|
if (!handleThenable(promise, value)) {
|
|
if (settled === FULFILLED) {
|
|
resolve(promise, value);
|
|
}
|
|
|
|
if (settled === REJECTED) {
|
|
reject(promise, value);
|
|
}
|
|
}
|
|
}
|
|
|
|
function handleThenable(promise, value) {
|
|
var resolved;
|
|
|
|
try {
|
|
if (promise === value) {
|
|
throw new TypeError('A promises callback cannot return that same promise.');
|
|
}
|
|
|
|
if (value && (typeof value === 'function' || typeof value === 'object')) {
|
|
// then should be retrieved only once
|
|
var then = value.then;
|
|
|
|
if (typeof then === 'function') {
|
|
then.call(value, function (val) {
|
|
if (!resolved) {
|
|
resolved = true;
|
|
|
|
if (value === val) {
|
|
fulfill(promise, val);
|
|
} else {
|
|
resolve(promise, val);
|
|
}
|
|
}
|
|
}, function (reason) {
|
|
if (!resolved) {
|
|
resolved = true;
|
|
|
|
reject(promise, reason);
|
|
}
|
|
});
|
|
|
|
return true;
|
|
}
|
|
}
|
|
} catch (e) {
|
|
if (!resolved) {
|
|
reject(promise, e);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
function resolve(promise, value) {
|
|
if (promise === value || !handleThenable(promise, value)) {
|
|
fulfill(promise, value);
|
|
}
|
|
}
|
|
|
|
function fulfill(promise, value) {
|
|
if (promise._state === PENDING) {
|
|
promise._state = SETTLED;
|
|
promise._data = value;
|
|
|
|
asyncCall(publishFulfillment, promise);
|
|
}
|
|
}
|
|
|
|
function reject(promise, reason) {
|
|
if (promise._state === PENDING) {
|
|
promise._state = SETTLED;
|
|
promise._data = reason;
|
|
|
|
asyncCall(publishRejection, promise);
|
|
}
|
|
}
|
|
|
|
function publish(promise) {
|
|
promise._then = promise._then.forEach(invokeCallback);
|
|
}
|
|
|
|
function publishFulfillment(promise) {
|
|
promise._state = FULFILLED;
|
|
publish(promise);
|
|
}
|
|
|
|
function publishRejection(promise) {
|
|
promise._state = REJECTED;
|
|
publish(promise);
|
|
if (!promise._handled && isNode) {
|
|
global.process.emit('unhandledRejection', promise._data, promise);
|
|
}
|
|
}
|
|
|
|
function notifyRejectionHandled(promise) {
|
|
global.process.emit('rejectionHandled', promise);
|
|
}
|
|
|
|
/**
|
|
* @class
|
|
*/
|
|
function Promise(resolver) {
|
|
if (typeof resolver !== 'function') {
|
|
throw new TypeError('Promise resolver ' + resolver + ' is not a function');
|
|
}
|
|
|
|
if (this instanceof Promise === false) {
|
|
throw new TypeError('Failed to construct \'Promise\': Please use the \'new\' operator, this object constructor cannot be called as a function.');
|
|
}
|
|
|
|
this._then = [];
|
|
|
|
invokeResolver(resolver, this);
|
|
}
|
|
|
|
Promise.prototype = {
|
|
constructor: Promise,
|
|
|
|
_state: PENDING,
|
|
_then: null,
|
|
_data: undefined,
|
|
_handled: false,
|
|
|
|
then: function (onFulfillment, onRejection) {
|
|
var subscriber = {
|
|
owner: this,
|
|
then: new this.constructor(NOOP),
|
|
fulfilled: onFulfillment,
|
|
rejected: onRejection
|
|
};
|
|
|
|
if ((onRejection || onFulfillment) && !this._handled) {
|
|
this._handled = true;
|
|
if (this._state === REJECTED && isNode) {
|
|
asyncCall(notifyRejectionHandled, this);
|
|
}
|
|
}
|
|
|
|
if (this._state === FULFILLED || this._state === REJECTED) {
|
|
// already resolved, call callback async
|
|
asyncCall(invokeCallback, subscriber);
|
|
} else {
|
|
// subscribe
|
|
this._then.push(subscriber);
|
|
}
|
|
|
|
return subscriber.then;
|
|
},
|
|
|
|
catch: function (onRejection) {
|
|
return this.then(null, onRejection);
|
|
}
|
|
};
|
|
|
|
Promise.all = function (promises) {
|
|
if (!Array.isArray(promises)) {
|
|
throw new TypeError('You must pass an array to Promise.all().');
|
|
}
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
var results = [];
|
|
var remaining = 0;
|
|
|
|
function resolver(index) {
|
|
remaining++;
|
|
return function (value) {
|
|
results[index] = value;
|
|
if (!--remaining) {
|
|
resolve(results);
|
|
}
|
|
};
|
|
}
|
|
|
|
for (var i = 0, promise; i < promises.length; i++) {
|
|
promise = promises[i];
|
|
|
|
if (promise && typeof promise.then === 'function') {
|
|
promise.then(resolver(i), reject);
|
|
} else {
|
|
results[i] = promise;
|
|
}
|
|
}
|
|
|
|
if (!remaining) {
|
|
resolve(results);
|
|
}
|
|
});
|
|
};
|
|
|
|
Promise.race = function (promises) {
|
|
if (!Array.isArray(promises)) {
|
|
throw new TypeError('You must pass an array to Promise.race().');
|
|
}
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
for (var i = 0, promise; i < promises.length; i++) {
|
|
promise = promises[i];
|
|
|
|
if (promise && typeof promise.then === 'function') {
|
|
promise.then(resolve, reject);
|
|
} else {
|
|
resolve(promise);
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
Promise.resolve = function (value) {
|
|
if (value && typeof value === 'object' && value.constructor === Promise) {
|
|
return value;
|
|
}
|
|
|
|
return new Promise(function (resolve) {
|
|
resolve(value);
|
|
});
|
|
};
|
|
|
|
Promise.reject = function (reason) {
|
|
return new Promise(function (resolve, reject) {
|
|
reject(reason);
|
|
});
|
|
};
|
|
|
|
module.exports = Promise;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 512:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = {"application/1d-interleaved-parityfec":{"source":"iana"},"application/3gpdash-qoe-report+xml":{"source":"iana","compressible":true},"application/3gpp-ims+xml":{"source":"iana","compressible":true},"application/a2l":{"source":"iana"},"application/activemessage":{"source":"iana"},"application/activity+json":{"source":"iana","compressible":true},"application/alto-costmap+json":{"source":"iana","compressible":true},"application/alto-costmapfilter+json":{"source":"iana","compressible":true},"application/alto-directory+json":{"source":"iana","compressible":true},"application/alto-endpointcost+json":{"source":"iana","compressible":true},"application/alto-endpointcostparams+json":{"source":"iana","compressible":true},"application/alto-endpointprop+json":{"source":"iana","compressible":true},"application/alto-endpointpropparams+json":{"source":"iana","compressible":true},"application/alto-error+json":{"source":"iana","compressible":true},"application/alto-networkmap+json":{"source":"iana","compressible":true},"application/alto-networkmapfilter+json":{"source":"iana","compressible":true},"application/aml":{"source":"iana"},"application/andrew-inset":{"source":"iana","extensions":["ez"]},"application/applefile":{"source":"iana"},"application/applixware":{"source":"apache","extensions":["aw"]},"application/atf":{"source":"iana"},"application/atfx":{"source":"iana"},"application/atom+xml":{"source":"iana","compressible":true,"extensions":["atom"]},"application/atomcat+xml":{"source":"iana","compressible":true,"extensions":["atomcat"]},"application/atomdeleted+xml":{"source":"iana","compressible":true,"extensions":["atomdeleted"]},"application/atomicmail":{"source":"iana"},"application/atomsvc+xml":{"source":"iana","compressible":true,"extensions":["atomsvc"]},"application/atsc-dwd+xml":{"source":"iana","compressible":true,"extensions":["dwd"]},"application/atsc-held+xml":{"source":"iana","compressible":true,"extensions":["held"]},"application/atsc-rdt+json":{"source":"iana","compressible":true},"application/atsc-rsat+xml":{"source":"iana","compressible":true,"extensions":["rsat"]},"application/atxml":{"source":"iana"},"application/auth-policy+xml":{"source":"iana","compressible":true},"application/bacnet-xdd+zip":{"source":"iana","compressible":false},"application/batch-smtp":{"source":"iana"},"application/bdoc":{"compressible":false,"extensions":["bdoc"]},"application/beep+xml":{"source":"iana","compressible":true},"application/calendar+json":{"source":"iana","compressible":true},"application/calendar+xml":{"source":"iana","compressible":true,"extensions":["xcs"]},"application/call-completion":{"source":"iana"},"application/cals-1840":{"source":"iana"},"application/cbor":{"source":"iana"},"application/cbor-seq":{"source":"iana"},"application/cccex":{"source":"iana"},"application/ccmp+xml":{"source":"iana","compressible":true},"application/ccxml+xml":{"source":"iana","compressible":true,"extensions":["ccxml"]},"application/cdfx+xml":{"source":"iana","compressible":true,"extensions":["cdfx"]},"application/cdmi-capability":{"source":"iana","extensions":["cdmia"]},"application/cdmi-container":{"source":"iana","extensions":["cdmic"]},"application/cdmi-domain":{"source":"iana","extensions":["cdmid"]},"application/cdmi-object":{"source":"iana","extensions":["cdmio"]},"application/cdmi-queue":{"source":"iana","extensions":["cdmiq"]},"application/cdni":{"source":"iana"},"application/cea":{"source":"iana"},"application/cea-2018+xml":{"source":"iana","compressible":true},"application/cellml+xml":{"source":"iana","compressible":true},"application/cfw":{"source":"iana"},"application/clue+xml":{"source":"iana","compressible":true},"application/clue_info+xml":{"source":"iana","compressible":true},"application/cms":{"source":"iana"},"application/cnrp+xml":{"source":"iana","compressible":true},"application/coap-group+json":{"source":"iana","compressible":true},"application/coap-payload":{"source":"iana"},"application/commonground":{"source":"iana"},"application/conference-info+xml":{"source":"iana","compressible":true},"application/cose":{"source":"iana"},"application/cose-key":{"source":"iana"},"application/cose-key-set":{"source":"iana"},"application/cpl+xml":{"source":"iana","compressible":true},"application/csrattrs":{"source":"iana"},"application/csta+xml":{"source":"iana","compressible":true},"application/cstadata+xml":{"source":"iana","compressible":true},"application/csvm+json":{"source":"iana","compressible":true},"application/cu-seeme":{"source":"apache","extensions":["cu"]},"application/cwt":{"source":"iana"},"application/cybercash":{"source":"iana"},"application/dart":{"compressible":true},"application/dash+xml":{"source":"iana","compressible":true,"extensions":["mpd"]},"application/dashdelta":{"source":"iana"},"application/davmount+xml":{"source":"iana","compressible":true,"extensions":["davmount"]},"application/dca-rft":{"source":"iana"},"application/dcd":{"source":"iana"},"application/dec-dx":{"source":"iana"},"application/dialog-info+xml":{"source":"iana","compressible":true},"application/dicom":{"source":"iana"},"application/dicom+json":{"source":"iana","compressible":true},"application/dicom+xml":{"source":"iana","compressible":true},"application/dii":{"source":"iana"},"application/dit":{"source":"iana"},"application/dns":{"source":"iana"},"application/dns+json":{"source":"iana","compressible":true},"application/dns-message":{"source":"iana"},"application/docbook+xml":{"source":"apache","compressible":true,"extensions":["dbk"]},"application/dskpp+xml":{"source":"iana","compressible":true},"application/dssc+der":{"source":"iana","extensions":["dssc"]},"application/dssc+xml":{"source":"iana","compressible":true,"extensions":["xdssc"]},"application/dvcs":{"source":"iana"},"application/ecmascript":{"source":"iana","compressible":true,"extensions":["ecma","es"]},"application/edi-consent":{"source":"iana"},"application/edi-x12":{"source":"iana","compressible":false},"application/edifact":{"source":"iana","compressible":false},"application/efi":{"source":"iana"},"application/emergencycalldata.comment+xml":{"source":"iana","compressible":true},"application/emergencycalldata.control+xml":{"source":"iana","compressible":true},"application/emergencycalldata.deviceinfo+xml":{"source":"iana","compressible":true},"application/emergencycalldata.ecall.msd":{"source":"iana"},"application/emergencycalldata.providerinfo+xml":{"source":"iana","compressible":true},"application/emergencycalldata.serviceinfo+xml":{"source":"iana","compressible":true},"application/emergencycalldata.subscriberinfo+xml":{"source":"iana","compressible":true},"application/emergencycalldata.veds+xml":{"source":"iana","compressible":true},"application/emma+xml":{"source":"iana","compressible":true,"extensions":["emma"]},"application/emotionml+xml":{"source":"iana","compressible":true,"extensions":["emotionml"]},"application/encaprtp":{"source":"iana"},"application/epp+xml":{"source":"iana","compressible":true},"application/epub+zip":{"source":"iana","compressible":false,"extensions":["epub"]},"application/eshop":{"source":"iana"},"application/exi":{"source":"iana","extensions":["exi"]},"application/expect-ct-report+json":{"source":"iana","compressible":true},"application/fastinfoset":{"source":"iana"},"application/fastsoap":{"source":"iana"},"application/fdt+xml":{"source":"iana","compressible":true,"extensions":["fdt"]},"application/fhir+json":{"source":"iana","compressible":true},"application/fhir+xml":{"source":"iana","compressible":true},"application/fido.trusted-apps+json":{"compressible":true},"application/fits":{"source":"iana"},"application/flexfec":{"source":"iana"},"application/font-sfnt":{"source":"iana"},"application/font-tdpfr":{"source":"iana","extensions":["pfr"]},"application/font-woff":{"source":"iana","compressible":false},"application/framework-attributes+xml":{"source":"iana","compressible":true},"application/geo+json":{"source":"iana","compressible":true,"extensions":["geojson"]},"application/geo+json-seq":{"source":"iana"},"application/geopackage+sqlite3":{"source":"iana"},"application/geoxacml+xml":{"source":"iana","compressible":true},"application/gltf-buffer":{"source":"iana"},"application/gml+xml":{"source":"iana","compressible":true,"extensions":["gml"]},"application/gpx+xml":{"source":"apache","compressible":true,"extensions":["gpx"]},"application/gxf":{"source":"apache","extensions":["gxf"]},"application/gzip":{"source":"iana","compressible":false,"extensions":["gz"]},"application/h224":{"source":"iana"},"application/held+xml":{"source":"iana","compressible":true},"application/hjson":{"extensions":["hjson"]},"application/http":{"source":"iana"},"application/hyperstudio":{"source":"iana","extensions":["stk"]},"application/ibe-key-request+xml":{"source":"iana","compressible":true},"application/ibe-pkg-reply+xml":{"source":"iana","compressible":true},"application/ibe-pp-data":{"source":"iana"},"application/iges":{"source":"iana"},"application/im-iscomposing+xml":{"source":"iana","compressible":true},"application/index":{"source":"iana"},"application/index.cmd":{"source":"iana"},"application/index.obj":{"source":"iana"},"application/index.response":{"source":"iana"},"application/index.vnd":{"source":"iana"},"application/inkml+xml":{"source":"iana","compressible":true,"extensions":["ink","inkml"]},"application/iotp":{"source":"iana"},"application/ipfix":{"source":"iana","extensions":["ipfix"]},"application/ipp":{"source":"iana"},"application/isup":{"source":"iana"},"application/its+xml":{"source":"iana","compressible":true,"extensions":["its"]},"application/java-archive":{"source":"apache","compressible":false,"extensions":["jar","war","ear"]},"application/java-serialized-object":{"source":"apache","compressible":false,"extensions":["ser"]},"application/java-vm":{"source":"apache","compressible":false,"extensions":["class"]},"application/javascript":{"source":"iana","charset":"UTF-8","compressible":true,"extensions":["js","mjs"]},"application/jf2feed+json":{"source":"iana","compressible":true},"application/jose":{"source":"iana"},"application/jose+json":{"source":"iana","compressible":true},"application/jrd+json":{"source":"iana","compressible":true},"application/json":{"source":"iana","charset":"UTF-8","compressible":true,"extensions":["json","map"]},"application/json-patch+json":{"source":"iana","compressible":true},"application/json-seq":{"source":"iana"},"application/json5":{"extensions":["json5"]},"application/jsonml+json":{"source":"apache","compressible":true,"extensions":["jsonml"]},"application/jwk+json":{"source":"iana","compressible":true},"application/jwk-set+json":{"source":"iana","compressible":true},"application/jwt":{"source":"iana"},"application/kpml-request+xml":{"source":"iana","compressible":true},"application/kpml-response+xml":{"source":"iana","compressible":true},"application/ld+json":{"source":"iana","compressible":true,"extensions":["jsonld"]},"application/lgr+xml":{"source":"iana","compressible":true,"extensions":["lgr"]},"application/link-format":{"source":"iana"},"application/load-control+xml":{"source":"iana","compressible":true},"application/lost+xml":{"source":"iana","compressible":true,"extensions":["lostxml"]},"application/lostsync+xml":{"source":"iana","compressible":true},"application/lxf":{"source":"iana"},"application/mac-binhex40":{"source":"iana","extensions":["hqx"]},"application/mac-compactpro":{"source":"apache","extensions":["cpt"]},"application/macwriteii":{"source":"iana"},"application/mads+xml":{"source":"iana","compressible":true,"extensions":["mads"]},"application/manifest+json":{"charset":"UTF-8","compressible":true,"extensions":["webmanifest"]},"application/marc":{"source":"iana","extensions":["mrc"]},"application/marcxml+xml":{"source":"iana","compressible":true,"extensions":["mrcx"]},"application/mathematica":{"source":"iana","extensions":["ma","nb","mb"]},"application/mathml+xml":{"source":"iana","compressible":true,"extensions":["mathml"]},"application/mathml-content+xml":{"source":"iana","compressible":true},"application/mathml-presentation+xml":{"source":"iana","compressible":true},"application/mbms-associated-procedure-description+xml":{"source":"iana","compressible":true},"application/mbms-deregister+xml":{"source":"iana","compressible":true},"application/mbms-envelope+xml":{"source":"iana","compressible":true},"application/mbms-msk+xml":{"source":"iana","compressible":true},"application/mbms-msk-response+xml":{"source":"iana","compressible":true},"application/mbms-protection-description+xml":{"source":"iana","compressible":true},"application/mbms-reception-report+xml":{"source":"iana","compressible":true},"application/mbms-register+xml":{"source":"iana","compressible":true},"application/mbms-register-response+xml":{"source":"iana","compressible":true},"application/mbms-schedule+xml":{"source":"iana","compressible":true},"application/mbms-user-service-description+xml":{"source":"iana","compressible":true},"application/mbox":{"source":"iana","extensions":["mbox"]},"application/media-policy-dataset+xml":{"source":"iana","compressible":true},"application/media_control+xml":{"source":"iana","compressible":true},"application/mediaservercontrol+xml":{"source":"iana","compressible":true,"extensions":["mscml"]},"application/merge-patch+json":{"source":"iana","compressible":true},"application/metalink+xml":{"source":"apache","compressible":true,"extensions":["metalink"]},"application/metalink4+xml":{"source":"iana","compressible":true,"extensions":["meta4"]},"application/mets+xml":{"source":"iana","compressible":true,"extensions":["mets"]},"application/mf4":{"source":"iana"},"application/mikey":{"source":"iana"},"application/mipc":{"source":"iana"},"application/mmt-aei+xml":{"source":"iana","compressible":true,"extensions":["maei"]},"application/mmt-usd+xml":{"source":"iana","compressible":true,"extensions":["musd"]},"application/mods+xml":{"source":"iana","compressible":true,"extensions":["mods"]},"application/moss-keys":{"source":"iana"},"application/moss-signature":{"source":"iana"},"application/mosskey-data":{"source":"iana"},"application/mosskey-request":{"source":"iana"},"application/mp21":{"source":"iana","extensions":["m21","mp21"]},"application/mp4":{"source":"iana","extensions":["mp4s","m4p"]},"application/mpeg4-generic":{"source":"iana"},"application/mpeg4-iod":{"source":"iana"},"application/mpeg4-iod-xmt":{"source":"iana"},"application/mrb-consumer+xml":{"source":"iana","compressible":true,"extensions":["xdf"]},"application/mrb-publish+xml":{"source":"iana","compressible":true,"extensions":["xdf"]},"application/msc-ivr+xml":{"source":"iana","compressible":true},"application/msc-mixer+xml":{"source":"iana","compressible":true},"application/msword":{"source":"iana","compressible":false,"extensions":["doc","dot"]},"application/mud+json":{"source":"iana","compressible":true},"application/multipart-core":{"source":"iana"},"application/mxf":{"source":"iana","extensions":["mxf"]},"application/n-quads":{"source":"iana","extensions":["nq"]},"application/n-triples":{"source":"iana","extensions":["nt"]},"application/nasdata":{"source":"iana"},"application/news-checkgroups":{"source":"iana"},"application/news-groupinfo":{"source":"iana"},"application/news-transmission":{"source":"iana"},"application/nlsml+xml":{"source":"iana","compressible":true},"application/node":{"source":"iana"},"application/nss":{"source":"iana"},"application/ocsp-request":{"source":"iana"},"application/ocsp-response":{"source":"iana"},"application/octet-stream":{"source":"iana","compressible":false,"extensions":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"]},"application/oda":{"source":"iana","extensions":["oda"]},"application/odm+xml":{"source":"iana","compressible":true},"application/odx":{"source":"iana"},"application/oebps-package+xml":{"source":"iana","compressible":true,"extensions":["opf"]},"application/ogg":{"source":"iana","compressible":false,"extensions":["ogx"]},"application/omdoc+xml":{"source":"apache","compressible":true,"extensions":["omdoc"]},"application/onenote":{"source":"apache","extensions":["onetoc","onetoc2","onetmp","onepkg"]},"application/oscore":{"source":"iana"},"application/oxps":{"source":"iana","extensions":["oxps"]},"application/p2p-overlay+xml":{"source":"iana","compressible":true,"extensions":["relo"]},"application/parityfec":{"source":"iana"},"application/passport":{"source":"iana"},"application/patch-ops-error+xml":{"source":"iana","compressible":true,"extensions":["xer"]},"application/pdf":{"source":"iana","compressible":false,"extensions":["pdf"]},"application/pdx":{"source":"iana"},"application/pem-certificate-chain":{"source":"iana"},"application/pgp-encrypted":{"source":"iana","compressible":false,"extensions":["pgp"]},"application/pgp-keys":{"source":"iana"},"application/pgp-signature":{"source":"iana","extensions":["asc","sig"]},"application/pics-rules":{"source":"apache","extensions":["prf"]},"application/pidf+xml":{"source":"iana","compressible":true},"application/pidf-diff+xml":{"source":"iana","compressible":true},"application/pkcs10":{"source":"iana","extensions":["p10"]},"application/pkcs12":{"source":"iana"},"application/pkcs7-mime":{"source":"iana","extensions":["p7m","p7c"]},"application/pkcs7-signature":{"source":"iana","extensions":["p7s"]},"application/pkcs8":{"source":"iana","extensions":["p8"]},"application/pkcs8-encrypted":{"source":"iana"},"application/pkix-attr-cert":{"source":"iana","extensions":["ac"]},"application/pkix-cert":{"source":"iana","extensions":["cer"]},"application/pkix-crl":{"source":"iana","extensions":["crl"]},"application/pkix-pkipath":{"source":"iana","extensions":["pkipath"]},"application/pkixcmp":{"source":"iana","extensions":["pki"]},"application/pls+xml":{"source":"iana","compressible":true,"extensions":["pls"]},"application/poc-settings+xml":{"source":"iana","compressible":true},"application/postscript":{"source":"iana","compressible":true,"extensions":["ai","eps","ps"]},"application/ppsp-tracker+json":{"source":"iana","compressible":true},"application/problem+json":{"source":"iana","compressible":true},"application/problem+xml":{"source":"iana","compressible":true},"application/provenance+xml":{"source":"iana","compressible":true,"extensions":["provx"]},"application/prs.alvestrand.titrax-sheet":{"source":"iana"},"application/prs.cww":{"source":"iana","extensions":["cww"]},"application/prs.hpub+zip":{"source":"iana","compressible":false},"application/prs.nprend":{"source":"iana"},"application/prs.plucker":{"source":"iana"},"application/prs.rdf-xml-crypt":{"source":"iana"},"application/prs.xsf+xml":{"source":"iana","compressible":true},"application/pskc+xml":{"source":"iana","compressible":true,"extensions":["pskcxml"]},"application/qsig":{"source":"iana"},"application/raml+yaml":{"compressible":true,"extensions":["raml"]},"application/raptorfec":{"source":"iana"},"application/rdap+json":{"source":"iana","compressible":true},"application/rdf+xml":{"source":"iana","compressible":true,"extensions":["rdf","owl"]},"application/reginfo+xml":{"source":"iana","compressible":true,"extensions":["rif"]},"application/relax-ng-compact-syntax":{"source":"iana","extensions":["rnc"]},"application/remote-printing":{"source":"iana"},"application/reputon+json":{"source":"iana","compressible":true},"application/resource-lists+xml":{"source":"iana","compressible":true,"extensions":["rl"]},"application/resource-lists-diff+xml":{"source":"iana","compressible":true,"extensions":["rld"]},"application/rfc+xml":{"source":"iana","compressible":true},"application/riscos":{"source":"iana"},"application/rlmi+xml":{"source":"iana","compressible":true},"application/rls-services+xml":{"source":"iana","compressible":true,"extensions":["rs"]},"application/route-apd+xml":{"source":"iana","compressible":true,"extensions":["rapd"]},"application/route-s-tsid+xml":{"source":"iana","compressible":true,"extensions":["sls"]},"application/route-usd+xml":{"source":"iana","compressible":true,"extensions":["rusd"]},"application/rpki-ghostbusters":{"source":"iana","extensions":["gbr"]},"application/rpki-manifest":{"source":"iana","extensions":["mft"]},"application/rpki-publication":{"source":"iana"},"application/rpki-roa":{"source":"iana","extensions":["roa"]},"application/rpki-updown":{"source":"iana"},"application/rsd+xml":{"source":"apache","compressible":true,"extensions":["rsd"]},"application/rss+xml":{"source":"apache","compressible":true,"extensions":["rss"]},"application/rtf":{"source":"iana","compressible":true,"extensions":["rtf"]},"application/rtploopback":{"source":"iana"},"application/rtx":{"source":"iana"},"application/samlassertion+xml":{"source":"iana","compressible":true},"application/samlmetadata+xml":{"source":"iana","compressible":true},"application/sbml+xml":{"source":"iana","compressible":true,"extensions":["sbml"]},"application/scaip+xml":{"source":"iana","compressible":true},"application/scim+json":{"source":"iana","compressible":true},"application/scvp-cv-request":{"source":"iana","extensions":["scq"]},"application/scvp-cv-response":{"source":"iana","extensions":["scs"]},"application/scvp-vp-request":{"source":"iana","extensions":["spq"]},"application/scvp-vp-response":{"source":"iana","extensions":["spp"]},"application/sdp":{"source":"iana","extensions":["sdp"]},"application/secevent+jwt":{"source":"iana"},"application/senml+cbor":{"source":"iana"},"application/senml+json":{"source":"iana","compressible":true},"application/senml+xml":{"source":"iana","compressible":true,"extensions":["senmlx"]},"application/senml-exi":{"source":"iana"},"application/sensml+cbor":{"source":"iana"},"application/sensml+json":{"source":"iana","compressible":true},"application/sensml+xml":{"source":"iana","compressible":true,"extensions":["sensmlx"]},"application/sensml-exi":{"source":"iana"},"application/sep+xml":{"source":"iana","compressible":true},"application/sep-exi":{"source":"iana"},"application/session-info":{"source":"iana"},"application/set-payment":{"source":"iana"},"application/set-payment-initiation":{"source":"iana","extensions":["setpay"]},"application/set-registration":{"source":"iana"},"application/set-registration-initiation":{"source":"iana","extensions":["setreg"]},"application/sgml":{"source":"iana"},"application/sgml-open-catalog":{"source":"iana"},"application/shf+xml":{"source":"iana","compressible":true,"extensions":["shf"]},"application/sieve":{"source":"iana","extensions":["siv","sieve"]},"application/simple-filter+xml":{"source":"iana","compressible":true},"application/simple-message-summary":{"source":"iana"},"application/simplesymbolcontainer":{"source":"iana"},"application/sipc":{"source":"iana"},"application/slate":{"source":"iana"},"application/smil":{"source":"iana"},"application/smil+xml":{"source":"iana","compressible":true,"extensions":["smi","smil"]},"application/smpte336m":{"source":"iana"},"application/soap+fastinfoset":{"source":"iana"},"application/soap+xml":{"source":"iana","compressible":true},"application/sparql-query":{"source":"iana","extensions":["rq"]},"application/sparql-results+xml":{"source":"iana","compressible":true,"extensions":["srx"]},"application/spirits-event+xml":{"source":"iana","compressible":true},"application/sql":{"source":"iana"},"application/srgs":{"source":"iana","extensions":["gram"]},"application/srgs+xml":{"source":"iana","compressible":true,"extensions":["grxml"]},"application/sru+xml":{"source":"iana","compressible":true,"extensions":["sru"]},"application/ssdl+xml":{"source":"apache","compressible":true,"extensions":["ssdl"]},"application/ssml+xml":{"source":"iana","compressible":true,"extensions":["ssml"]},"application/stix+json":{"source":"iana","compressible":true},"application/swid+xml":{"source":"iana","compressible":true,"extensions":["swidtag"]},"application/tamp-apex-update":{"source":"iana"},"application/tamp-apex-update-confirm":{"source":"iana"},"application/tamp-community-update":{"source":"iana"},"application/tamp-community-update-confirm":{"source":"iana"},"application/tamp-error":{"source":"iana"},"application/tamp-sequence-adjust":{"source":"iana"},"application/tamp-sequence-adjust-confirm":{"source":"iana"},"application/tamp-status-query":{"source":"iana"},"application/tamp-status-response":{"source":"iana"},"application/tamp-update":{"source":"iana"},"application/tamp-update-confirm":{"source":"iana"},"application/tar":{"compressible":true},"application/taxii+json":{"source":"iana","compressible":true},"application/tei+xml":{"source":"iana","compressible":true,"extensions":["tei","teicorpus"]},"application/tetra_isi":{"source":"iana"},"application/thraud+xml":{"source":"iana","compressible":true,"extensions":["tfi"]},"application/timestamp-query":{"source":"iana"},"application/timestamp-reply":{"source":"iana"},"application/timestamped-data":{"source":"iana","extensions":["tsd"]},"application/tlsrpt+gzip":{"source":"iana"},"application/tlsrpt+json":{"source":"iana","compressible":true},"application/tnauthlist":{"source":"iana"},"application/toml":{"compressible":true,"extensions":["toml"]},"application/trickle-ice-sdpfrag":{"source":"iana"},"application/trig":{"source":"iana"},"application/ttml+xml":{"source":"iana","compressible":true,"extensions":["ttml"]},"application/tve-trigger":{"source":"iana"},"application/tzif":{"source":"iana"},"application/tzif-leap":{"source":"iana"},"application/ulpfec":{"source":"iana"},"application/urc-grpsheet+xml":{"source":"iana","compressible":true},"application/urc-ressheet+xml":{"source":"iana","compressible":true,"extensions":["rsheet"]},"application/urc-targetdesc+xml":{"source":"iana","compressible":true},"application/urc-uisocketdesc+xml":{"source":"iana","compressible":true},"application/vcard+json":{"source":"iana","compressible":true},"application/vcard+xml":{"source":"iana","compressible":true},"application/vemmi":{"source":"iana"},"application/vividence.scriptfile":{"source":"apache"},"application/vnd.1000minds.decision-model+xml":{"source":"iana","compressible":true,"extensions":["1km"]},"application/vnd.3gpp-prose+xml":{"source":"iana","compressible":true},"application/vnd.3gpp-prose-pc3ch+xml":{"source":"iana","compressible":true},"application/vnd.3gpp-v2x-local-service-information":{"source":"iana"},"application/vnd.3gpp.access-transfer-events+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.bsf+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.gmop+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mc-signalling-ear":{"source":"iana"},"application/vnd.3gpp.mcdata-affiliation-command+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcdata-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcdata-payload":{"source":"iana"},"application/vnd.3gpp.mcdata-service-config+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcdata-signalling":{"source":"iana"},"application/vnd.3gpp.mcdata-ue-config+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcdata-user-profile+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-affiliation-command+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-floor-request+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-location-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-mbms-usage-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-service-config+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-signed+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-ue-config+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-ue-init-config+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcptt-user-profile+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-affiliation-command+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-affiliation-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-location-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-mbms-usage-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-service-config+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-transmission-request+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-ue-config+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mcvideo-user-profile+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.mid-call+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.pic-bw-large":{"source":"iana","extensions":["plb"]},"application/vnd.3gpp.pic-bw-small":{"source":"iana","extensions":["psb"]},"application/vnd.3gpp.pic-bw-var":{"source":"iana","extensions":["pvb"]},"application/vnd.3gpp.sms":{"source":"iana"},"application/vnd.3gpp.sms+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.srvcc-ext+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.srvcc-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.state-and-event-info+xml":{"source":"iana","compressible":true},"application/vnd.3gpp.ussd+xml":{"source":"iana","compressible":true},"application/vnd.3gpp2.bcmcsinfo+xml":{"source":"iana","compressible":true},"application/vnd.3gpp2.sms":{"source":"iana"},"application/vnd.3gpp2.tcap":{"source":"iana","extensions":["tcap"]},"application/vnd.3lightssoftware.imagescal":{"source":"iana"},"application/vnd.3m.post-it-notes":{"source":"iana","extensions":["pwn"]},"application/vnd.accpac.simply.aso":{"source":"iana","extensions":["aso"]},"application/vnd.accpac.simply.imp":{"source":"iana","extensions":["imp"]},"application/vnd.acucobol":{"source":"iana","extensions":["acu"]},"application/vnd.acucorp":{"source":"iana","extensions":["atc","acutc"]},"application/vnd.adobe.air-application-installer-package+zip":{"source":"apache","compressible":false,"extensions":["air"]},"application/vnd.adobe.flash.movie":{"source":"iana"},"application/vnd.adobe.formscentral.fcdt":{"source":"iana","extensions":["fcdt"]},"application/vnd.adobe.fxp":{"source":"iana","extensions":["fxp","fxpl"]},"application/vnd.adobe.partial-upload":{"source":"iana"},"application/vnd.adobe.xdp+xml":{"source":"iana","compressible":true,"extensions":["xdp"]},"application/vnd.adobe.xfdf":{"source":"iana","extensions":["xfdf"]},"application/vnd.aether.imp":{"source":"iana"},"application/vnd.afpc.afplinedata":{"source":"iana"},"application/vnd.afpc.afplinedata-pagedef":{"source":"iana"},"application/vnd.afpc.foca-charset":{"source":"iana"},"application/vnd.afpc.foca-codedfont":{"source":"iana"},"application/vnd.afpc.foca-codepage":{"source":"iana"},"application/vnd.afpc.modca":{"source":"iana"},"application/vnd.afpc.modca-formdef":{"source":"iana"},"application/vnd.afpc.modca-mediummap":{"source":"iana"},"application/vnd.afpc.modca-objectcontainer":{"source":"iana"},"application/vnd.afpc.modca-overlay":{"source":"iana"},"application/vnd.afpc.modca-pagesegment":{"source":"iana"},"application/vnd.ah-barcode":{"source":"iana"},"application/vnd.ahead.space":{"source":"iana","extensions":["ahead"]},"application/vnd.airzip.filesecure.azf":{"source":"iana","extensions":["azf"]},"application/vnd.airzip.filesecure.azs":{"source":"iana","extensions":["azs"]},"application/vnd.amadeus+json":{"source":"iana","compressible":true},"application/vnd.amazon.ebook":{"source":"apache","extensions":["azw"]},"application/vnd.amazon.mobi8-ebook":{"source":"iana"},"application/vnd.americandynamics.acc":{"source":"iana","extensions":["acc"]},"application/vnd.amiga.ami":{"source":"iana","extensions":["ami"]},"application/vnd.amundsen.maze+xml":{"source":"iana","compressible":true},"application/vnd.android.ota":{"source":"iana"},"application/vnd.android.package-archive":{"source":"apache","compressible":false,"extensions":["apk"]},"application/vnd.anki":{"source":"iana"},"application/vnd.anser-web-certificate-issue-initiation":{"source":"iana","extensions":["cii"]},"application/vnd.anser-web-funds-transfer-initiation":{"source":"apache","extensions":["fti"]},"application/vnd.antix.game-component":{"source":"iana","extensions":["atx"]},"application/vnd.apache.thrift.binary":{"source":"iana"},"application/vnd.apache.thrift.compact":{"source":"iana"},"application/vnd.apache.thrift.json":{"source":"iana"},"application/vnd.api+json":{"source":"iana","compressible":true},"application/vnd.aplextor.warrp+json":{"source":"iana","compressible":true},"application/vnd.apothekende.reservation+json":{"source":"iana","compressible":true},"application/vnd.apple.installer+xml":{"source":"iana","compressible":true,"extensions":["mpkg"]},"application/vnd.apple.keynote":{"source":"iana","extensions":["keynote"]},"application/vnd.apple.mpegurl":{"source":"iana","extensions":["m3u8"]},"application/vnd.apple.numbers":{"source":"iana","extensions":["numbers"]},"application/vnd.apple.pages":{"source":"iana","extensions":["pages"]},"application/vnd.apple.pkpass":{"compressible":false,"extensions":["pkpass"]},"application/vnd.arastra.swi":{"source":"iana"},"application/vnd.aristanetworks.swi":{"source":"iana","extensions":["swi"]},"application/vnd.artisan+json":{"source":"iana","compressible":true},"application/vnd.artsquare":{"source":"iana"},"application/vnd.astraea-software.iota":{"source":"iana","extensions":["iota"]},"application/vnd.audiograph":{"source":"iana","extensions":["aep"]},"application/vnd.autopackage":{"source":"iana"},"application/vnd.avalon+json":{"source":"iana","compressible":true},"application/vnd.avistar+xml":{"source":"iana","compressible":true},"application/vnd.balsamiq.bmml+xml":{"source":"iana","compressible":true,"extensions":["bmml"]},"application/vnd.balsamiq.bmpr":{"source":"iana"},"application/vnd.banana-accounting":{"source":"iana"},"application/vnd.bbf.usp.error":{"source":"iana"},"application/vnd.bbf.usp.msg":{"source":"iana"},"application/vnd.bbf.usp.msg+json":{"source":"iana","compressible":true},"application/vnd.bekitzur-stech+json":{"source":"iana","compressible":true},"application/vnd.bint.med-content":{"source":"iana"},"application/vnd.biopax.rdf+xml":{"source":"iana","compressible":true},"application/vnd.blink-idb-value-wrapper":{"source":"iana"},"application/vnd.blueice.multipass":{"source":"iana","extensions":["mpm"]},"application/vnd.bluetooth.ep.oob":{"source":"iana"},"application/vnd.bluetooth.le.oob":{"source":"iana"},"application/vnd.bmi":{"source":"iana","extensions":["bmi"]},"application/vnd.bpf":{"source":"iana"},"application/vnd.bpf3":{"source":"iana"},"application/vnd.businessobjects":{"source":"iana","extensions":["rep"]},"application/vnd.byu.uapi+json":{"source":"iana","compressible":true},"application/vnd.cab-jscript":{"source":"iana"},"application/vnd.canon-cpdl":{"source":"iana"},"application/vnd.canon-lips":{"source":"iana"},"application/vnd.capasystems-pg+json":{"source":"iana","compressible":true},"application/vnd.cendio.thinlinc.clientconf":{"source":"iana"},"application/vnd.century-systems.tcp_stream":{"source":"iana"},"application/vnd.chemdraw+xml":{"source":"iana","compressible":true,"extensions":["cdxml"]},"application/vnd.chess-pgn":{"source":"iana"},"application/vnd.chipnuts.karaoke-mmd":{"source":"iana","extensions":["mmd"]},"application/vnd.ciedi":{"source":"iana"},"application/vnd.cinderella":{"source":"iana","extensions":["cdy"]},"application/vnd.cirpack.isdn-ext":{"source":"iana"},"application/vnd.citationstyles.style+xml":{"source":"iana","compressible":true,"extensions":["csl"]},"application/vnd.claymore":{"source":"iana","extensions":["cla"]},"application/vnd.cloanto.rp9":{"source":"iana","extensions":["rp9"]},"application/vnd.clonk.c4group":{"source":"iana","extensions":["c4g","c4d","c4f","c4p","c4u"]},"application/vnd.cluetrust.cartomobile-config":{"source":"iana","extensions":["c11amc"]},"application/vnd.cluetrust.cartomobile-config-pkg":{"source":"iana","extensions":["c11amz"]},"application/vnd.coffeescript":{"source":"iana"},"application/vnd.collabio.xodocuments.document":{"source":"iana"},"application/vnd.collabio.xodocuments.document-template":{"source":"iana"},"application/vnd.collabio.xodocuments.presentation":{"source":"iana"},"application/vnd.collabio.xodocuments.presentation-template":{"source":"iana"},"application/vnd.collabio.xodocuments.spreadsheet":{"source":"iana"},"application/vnd.collabio.xodocuments.spreadsheet-template":{"source":"iana"},"application/vnd.collection+json":{"source":"iana","compressible":true},"application/vnd.collection.doc+json":{"source":"iana","compressible":true},"application/vnd.collection.next+json":{"source":"iana","compressible":true},"application/vnd.comicbook+zip":{"source":"iana","compressible":false},"application/vnd.comicbook-rar":{"source":"iana"},"application/vnd.commerce-battelle":{"source":"iana"},"application/vnd.commonspace":{"source":"iana","extensions":["csp"]},"application/vnd.contact.cmsg":{"source":"iana","extensions":["cdbcmsg"]},"application/vnd.coreos.ignition+json":{"source":"iana","compressible":true},"application/vnd.cosmocaller":{"source":"iana","extensions":["cmc"]},"application/vnd.crick.clicker":{"source":"iana","extensions":["clkx"]},"application/vnd.crick.clicker.keyboard":{"source":"iana","extensions":["clkk"]},"application/vnd.crick.clicker.palette":{"source":"iana","extensions":["clkp"]},"application/vnd.crick.clicker.template":{"source":"iana","extensions":["clkt"]},"application/vnd.crick.clicker.wordbank":{"source":"iana","extensions":["clkw"]},"application/vnd.criticaltools.wbs+xml":{"source":"iana","compressible":true,"extensions":["wbs"]},"application/vnd.cryptii.pipe+json":{"source":"iana","compressible":true},"application/vnd.crypto-shade-file":{"source":"iana"},"application/vnd.ctc-posml":{"source":"iana","extensions":["pml"]},"application/vnd.ctct.ws+xml":{"source":"iana","compressible":true},"application/vnd.cups-pdf":{"source":"iana"},"application/vnd.cups-postscript":{"source":"iana"},"application/vnd.cups-ppd":{"source":"iana","extensions":["ppd"]},"application/vnd.cups-raster":{"source":"iana"},"application/vnd.cups-raw":{"source":"iana"},"application/vnd.curl":{"source":"iana"},"application/vnd.curl.car":{"source":"apache","extensions":["car"]},"application/vnd.curl.pcurl":{"source":"apache","extensions":["pcurl"]},"application/vnd.cyan.dean.root+xml":{"source":"iana","compressible":true},"application/vnd.cybank":{"source":"iana"},"application/vnd.d2l.coursepackage1p0+zip":{"source":"iana","compressible":false},"application/vnd.dart":{"source":"iana","compressible":true,"extensions":["dart"]},"application/vnd.data-vision.rdz":{"source":"iana","extensions":["rdz"]},"application/vnd.datapackage+json":{"source":"iana","compressible":true},"application/vnd.dataresource+json":{"source":"iana","compressible":true},"application/vnd.debian.binary-package":{"source":"iana"},"application/vnd.dece.data":{"source":"iana","extensions":["uvf","uvvf","uvd","uvvd"]},"application/vnd.dece.ttml+xml":{"source":"iana","compressible":true,"extensions":["uvt","uvvt"]},"application/vnd.dece.unspecified":{"source":"iana","extensions":["uvx","uvvx"]},"application/vnd.dece.zip":{"source":"iana","extensions":["uvz","uvvz"]},"application/vnd.denovo.fcselayout-link":{"source":"iana","extensions":["fe_launch"]},"application/vnd.desmume.movie":{"source":"iana"},"application/vnd.dir-bi.plate-dl-nosuffix":{"source":"iana"},"application/vnd.dm.delegation+xml":{"source":"iana","compressible":true},"application/vnd.dna":{"source":"iana","extensions":["dna"]},"application/vnd.document+json":{"source":"iana","compressible":true},"application/vnd.dolby.mlp":{"source":"apache","extensions":["mlp"]},"application/vnd.dolby.mobile.1":{"source":"iana"},"application/vnd.dolby.mobile.2":{"source":"iana"},"application/vnd.doremir.scorecloud-binary-document":{"source":"iana"},"application/vnd.dpgraph":{"source":"iana","extensions":["dpg"]},"application/vnd.dreamfactory":{"source":"iana","extensions":["dfac"]},"application/vnd.drive+json":{"source":"iana","compressible":true},"application/vnd.ds-keypoint":{"source":"apache","extensions":["kpxx"]},"application/vnd.dtg.local":{"source":"iana"},"application/vnd.dtg.local.flash":{"source":"iana"},"application/vnd.dtg.local.html":{"source":"iana"},"application/vnd.dvb.ait":{"source":"iana","extensions":["ait"]},"application/vnd.dvb.dvbj":{"source":"iana"},"application/vnd.dvb.esgcontainer":{"source":"iana"},"application/vnd.dvb.ipdcdftnotifaccess":{"source":"iana"},"application/vnd.dvb.ipdcesgaccess":{"source":"iana"},"application/vnd.dvb.ipdcesgaccess2":{"source":"iana"},"application/vnd.dvb.ipdcesgpdd":{"source":"iana"},"application/vnd.dvb.ipdcroaming":{"source":"iana"},"application/vnd.dvb.iptv.alfec-base":{"source":"iana"},"application/vnd.dvb.iptv.alfec-enhancement":{"source":"iana"},"application/vnd.dvb.notif-aggregate-root+xml":{"source":"iana","compressible":true},"application/vnd.dvb.notif-container+xml":{"source":"iana","compressible":true},"application/vnd.dvb.notif-generic+xml":{"source":"iana","compressible":true},"application/vnd.dvb.notif-ia-msglist+xml":{"source":"iana","compressible":true},"application/vnd.dvb.notif-ia-registration-request+xml":{"source":"iana","compressible":true},"application/vnd.dvb.notif-ia-registration-response+xml":{"source":"iana","compressible":true},"application/vnd.dvb.notif-init+xml":{"source":"iana","compressible":true},"application/vnd.dvb.pfr":{"source":"iana"},"application/vnd.dvb.service":{"source":"iana","extensions":["svc"]},"application/vnd.dxr":{"source":"iana"},"application/vnd.dynageo":{"source":"iana","extensions":["geo"]},"application/vnd.dzr":{"source":"iana"},"application/vnd.easykaraoke.cdgdownload":{"source":"iana"},"application/vnd.ecdis-update":{"source":"iana"},"application/vnd.ecip.rlp":{"source":"iana"},"application/vnd.ecowin.chart":{"source":"iana","extensions":["mag"]},"application/vnd.ecowin.filerequest":{"source":"iana"},"application/vnd.ecowin.fileupdate":{"source":"iana"},"application/vnd.ecowin.series":{"source":"iana"},"application/vnd.ecowin.seriesrequest":{"source":"iana"},"application/vnd.ecowin.seriesupdate":{"source":"iana"},"application/vnd.efi.img":{"source":"iana"},"application/vnd.efi.iso":{"source":"iana"},"application/vnd.emclient.accessrequest+xml":{"source":"iana","compressible":true},"application/vnd.enliven":{"source":"iana","extensions":["nml"]},"application/vnd.enphase.envoy":{"source":"iana"},"application/vnd.eprints.data+xml":{"source":"iana","compressible":true},"application/vnd.epson.esf":{"source":"iana","extensions":["esf"]},"application/vnd.epson.msf":{"source":"iana","extensions":["msf"]},"application/vnd.epson.quickanime":{"source":"iana","extensions":["qam"]},"application/vnd.epson.salt":{"source":"iana","extensions":["slt"]},"application/vnd.epson.ssf":{"source":"iana","extensions":["ssf"]},"application/vnd.ericsson.quickcall":{"source":"iana"},"application/vnd.espass-espass+zip":{"source":"iana","compressible":false},"application/vnd.eszigno3+xml":{"source":"iana","compressible":true,"extensions":["es3","et3"]},"application/vnd.etsi.aoc+xml":{"source":"iana","compressible":true},"application/vnd.etsi.asic-e+zip":{"source":"iana","compressible":false},"application/vnd.etsi.asic-s+zip":{"source":"iana","compressible":false},"application/vnd.etsi.cug+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvcommand+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvdiscovery+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvprofile+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvsad-bc+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvsad-cod+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvsad-npvr+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvservice+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvsync+xml":{"source":"iana","compressible":true},"application/vnd.etsi.iptvueprofile+xml":{"source":"iana","compressible":true},"application/vnd.etsi.mcid+xml":{"source":"iana","compressible":true},"application/vnd.etsi.mheg5":{"source":"iana"},"application/vnd.etsi.overload-control-policy-dataset+xml":{"source":"iana","compressible":true},"application/vnd.etsi.pstn+xml":{"source":"iana","compressible":true},"application/vnd.etsi.sci+xml":{"source":"iana","compressible":true},"application/vnd.etsi.simservs+xml":{"source":"iana","compressible":true},"application/vnd.etsi.timestamp-token":{"source":"iana"},"application/vnd.etsi.tsl+xml":{"source":"iana","compressible":true},"application/vnd.etsi.tsl.der":{"source":"iana"},"application/vnd.eudora.data":{"source":"iana"},"application/vnd.evolv.ecig.profile":{"source":"iana"},"application/vnd.evolv.ecig.settings":{"source":"iana"},"application/vnd.evolv.ecig.theme":{"source":"iana"},"application/vnd.exstream-empower+zip":{"source":"iana","compressible":false},"application/vnd.exstream-package":{"source":"iana"},"application/vnd.ezpix-album":{"source":"iana","extensions":["ez2"]},"application/vnd.ezpix-package":{"source":"iana","extensions":["ez3"]},"application/vnd.f-secure.mobile":{"source":"iana"},"application/vnd.fastcopy-disk-image":{"source":"iana"},"application/vnd.fdf":{"source":"iana","extensions":["fdf"]},"application/vnd.fdsn.mseed":{"source":"iana","extensions":["mseed"]},"application/vnd.fdsn.seed":{"source":"iana","extensions":["seed","dataless"]},"application/vnd.ffsns":{"source":"iana"},"application/vnd.ficlab.flb+zip":{"source":"iana","compressible":false},"application/vnd.filmit.zfc":{"source":"iana"},"application/vnd.fints":{"source":"iana"},"application/vnd.firemonkeys.cloudcell":{"source":"iana"},"application/vnd.flographit":{"source":"iana","extensions":["gph"]},"application/vnd.fluxtime.clip":{"source":"iana","extensions":["ftc"]},"application/vnd.font-fontforge-sfd":{"source":"iana"},"application/vnd.framemaker":{"source":"iana","extensions":["fm","frame","maker","book"]},"application/vnd.frogans.fnc":{"source":"iana","extensions":["fnc"]},"application/vnd.frogans.ltf":{"source":"iana","extensions":["ltf"]},"application/vnd.fsc.weblaunch":{"source":"iana","extensions":["fsc"]},"application/vnd.fujitsu.oasys":{"source":"iana","extensions":["oas"]},"application/vnd.fujitsu.oasys2":{"source":"iana","extensions":["oa2"]},"application/vnd.fujitsu.oasys3":{"source":"iana","extensions":["oa3"]},"application/vnd.fujitsu.oasysgp":{"source":"iana","extensions":["fg5"]},"application/vnd.fujitsu.oasysprs":{"source":"iana","extensions":["bh2"]},"application/vnd.fujixerox.art-ex":{"source":"iana"},"application/vnd.fujixerox.art4":{"source":"iana"},"application/vnd.fujixerox.ddd":{"source":"iana","extensions":["ddd"]},"application/vnd.fujixerox.docuworks":{"source":"iana","extensions":["xdw"]},"application/vnd.fujixerox.docuworks.binder":{"source":"iana","extensions":["xbd"]},"application/vnd.fujixerox.docuworks.container":{"source":"iana"},"application/vnd.fujixerox.hbpl":{"source":"iana"},"application/vnd.fut-misnet":{"source":"iana"},"application/vnd.futoin+cbor":{"source":"iana"},"application/vnd.futoin+json":{"source":"iana","compressible":true},"application/vnd.fuzzysheet":{"source":"iana","extensions":["fzs"]},"application/vnd.genomatix.tuxedo":{"source":"iana","extensions":["txd"]},"application/vnd.gentics.grd+json":{"source":"iana","compressible":true},"application/vnd.geo+json":{"source":"iana","compressible":true},"application/vnd.geocube+xml":{"source":"iana","compressible":true},"application/vnd.geogebra.file":{"source":"iana","extensions":["ggb"]},"application/vnd.geogebra.tool":{"source":"iana","extensions":["ggt"]},"application/vnd.geometry-explorer":{"source":"iana","extensions":["gex","gre"]},"application/vnd.geonext":{"source":"iana","extensions":["gxt"]},"application/vnd.geoplan":{"source":"iana","extensions":["g2w"]},"application/vnd.geospace":{"source":"iana","extensions":["g3w"]},"application/vnd.gerber":{"source":"iana"},"application/vnd.globalplatform.card-content-mgt":{"source":"iana"},"application/vnd.globalplatform.card-content-mgt-response":{"source":"iana"},"application/vnd.gmx":{"source":"iana","extensions":["gmx"]},"application/vnd.google-apps.document":{"compressible":false,"extensions":["gdoc"]},"application/vnd.google-apps.presentation":{"compressible":false,"extensions":["gslides"]},"application/vnd.google-apps.spreadsheet":{"compressible":false,"extensions":["gsheet"]},"application/vnd.google-earth.kml+xml":{"source":"iana","compressible":true,"extensions":["kml"]},"application/vnd.google-earth.kmz":{"source":"iana","compressible":false,"extensions":["kmz"]},"application/vnd.gov.sk.e-form+xml":{"source":"iana","compressible":true},"application/vnd.gov.sk.e-form+zip":{"source":"iana","compressible":false},"application/vnd.gov.sk.xmldatacontainer+xml":{"source":"iana","compressible":true},"application/vnd.grafeq":{"source":"iana","extensions":["gqf","gqs"]},"application/vnd.gridmp":{"source":"iana"},"application/vnd.groove-account":{"source":"iana","extensions":["gac"]},"application/vnd.groove-help":{"source":"iana","extensions":["ghf"]},"application/vnd.groove-identity-message":{"source":"iana","extensions":["gim"]},"application/vnd.groove-injector":{"source":"iana","extensions":["grv"]},"application/vnd.groove-tool-message":{"source":"iana","extensions":["gtm"]},"application/vnd.groove-tool-template":{"source":"iana","extensions":["tpl"]},"application/vnd.groove-vcard":{"source":"iana","extensions":["vcg"]},"application/vnd.hal+json":{"source":"iana","compressible":true},"application/vnd.hal+xml":{"source":"iana","compressible":true,"extensions":["hal"]},"application/vnd.handheld-entertainment+xml":{"source":"iana","compressible":true,"extensions":["zmm"]},"application/vnd.hbci":{"source":"iana","extensions":["hbci"]},"application/vnd.hc+json":{"source":"iana","compressible":true},"application/vnd.hcl-bireports":{"source":"iana"},"application/vnd.hdt":{"source":"iana"},"application/vnd.heroku+json":{"source":"iana","compressible":true},"application/vnd.hhe.lesson-player":{"source":"iana","extensions":["les"]},"application/vnd.hp-hpgl":{"source":"iana","extensions":["hpgl"]},"application/vnd.hp-hpid":{"source":"iana","extensions":["hpid"]},"application/vnd.hp-hps":{"source":"iana","extensions":["hps"]},"application/vnd.hp-jlyt":{"source":"iana","extensions":["jlt"]},"application/vnd.hp-pcl":{"source":"iana","extensions":["pcl"]},"application/vnd.hp-pclxl":{"source":"iana","extensions":["pclxl"]},"application/vnd.httphone":{"source":"iana"},"application/vnd.hydrostatix.sof-data":{"source":"iana","extensions":["sfd-hdstx"]},"application/vnd.hyper+json":{"source":"iana","compressible":true},"application/vnd.hyper-item+json":{"source":"iana","compressible":true},"application/vnd.hyperdrive+json":{"source":"iana","compressible":true},"application/vnd.hzn-3d-crossword":{"source":"iana"},"application/vnd.ibm.afplinedata":{"source":"iana"},"application/vnd.ibm.electronic-media":{"source":"iana"},"application/vnd.ibm.minipay":{"source":"iana","extensions":["mpy"]},"application/vnd.ibm.modcap":{"source":"iana","extensions":["afp","listafp","list3820"]},"application/vnd.ibm.rights-management":{"source":"iana","extensions":["irm"]},"application/vnd.ibm.secure-container":{"source":"iana","extensions":["sc"]},"application/vnd.iccprofile":{"source":"iana","extensions":["icc","icm"]},"application/vnd.ieee.1905":{"source":"iana"},"application/vnd.igloader":{"source":"iana","extensions":["igl"]},"application/vnd.imagemeter.folder+zip":{"source":"iana","compressible":false},"application/vnd.imagemeter.image+zip":{"source":"iana","compressible":false},"application/vnd.immervision-ivp":{"source":"iana","extensions":["ivp"]},"application/vnd.immervision-ivu":{"source":"iana","extensions":["ivu"]},"application/vnd.ims.imsccv1p1":{"source":"iana"},"application/vnd.ims.imsccv1p2":{"source":"iana"},"application/vnd.ims.imsccv1p3":{"source":"iana"},"application/vnd.ims.lis.v2.result+json":{"source":"iana","compressible":true},"application/vnd.ims.lti.v2.toolconsumerprofile+json":{"source":"iana","compressible":true},"application/vnd.ims.lti.v2.toolproxy+json":{"source":"iana","compressible":true},"application/vnd.ims.lti.v2.toolproxy.id+json":{"source":"iana","compressible":true},"application/vnd.ims.lti.v2.toolsettings+json":{"source":"iana","compressible":true},"application/vnd.ims.lti.v2.toolsettings.simple+json":{"source":"iana","compressible":true},"application/vnd.informedcontrol.rms+xml":{"source":"iana","compressible":true},"application/vnd.informix-visionary":{"source":"iana"},"application/vnd.infotech.project":{"source":"iana"},"application/vnd.infotech.project+xml":{"source":"iana","compressible":true},"application/vnd.innopath.wamp.notification":{"source":"iana"},"application/vnd.insors.igm":{"source":"iana","extensions":["igm"]},"application/vnd.intercon.formnet":{"source":"iana","extensions":["xpw","xpx"]},"application/vnd.intergeo":{"source":"iana","extensions":["i2g"]},"application/vnd.intertrust.digibox":{"source":"iana"},"application/vnd.intertrust.nncp":{"source":"iana"},"application/vnd.intu.qbo":{"source":"iana","extensions":["qbo"]},"application/vnd.intu.qfx":{"source":"iana","extensions":["qfx"]},"application/vnd.iptc.g2.catalogitem+xml":{"source":"iana","compressible":true},"application/vnd.iptc.g2.conceptitem+xml":{"source":"iana","compressible":true},"application/vnd.iptc.g2.knowledgeitem+xml":{"source":"iana","compressible":true},"application/vnd.iptc.g2.newsitem+xml":{"source":"iana","compressible":true},"application/vnd.iptc.g2.newsmessage+xml":{"source":"iana","compressible":true},"application/vnd.iptc.g2.packageitem+xml":{"source":"iana","compressible":true},"application/vnd.iptc.g2.planningitem+xml":{"source":"iana","compressible":true},"application/vnd.ipunplugged.rcprofile":{"source":"iana","extensions":["rcprofile"]},"application/vnd.irepository.package+xml":{"source":"iana","compressible":true,"extensions":["irp"]},"application/vnd.is-xpr":{"source":"iana","extensions":["xpr"]},"application/vnd.isac.fcs":{"source":"iana","extensions":["fcs"]},"application/vnd.iso11783-10+zip":{"source":"iana","compressible":false},"application/vnd.jam":{"source":"iana","extensions":["jam"]},"application/vnd.japannet-directory-service":{"source":"iana"},"application/vnd.japannet-jpnstore-wakeup":{"source":"iana"},"application/vnd.japannet-payment-wakeup":{"source":"iana"},"application/vnd.japannet-registration":{"source":"iana"},"application/vnd.japannet-registration-wakeup":{"source":"iana"},"application/vnd.japannet-setstore-wakeup":{"source":"iana"},"application/vnd.japannet-verification":{"source":"iana"},"application/vnd.japannet-verification-wakeup":{"source":"iana"},"application/vnd.jcp.javame.midlet-rms":{"source":"iana","extensions":["rms"]},"application/vnd.jisp":{"source":"iana","extensions":["jisp"]},"application/vnd.joost.joda-archive":{"source":"iana","extensions":["joda"]},"application/vnd.jsk.isdn-ngn":{"source":"iana"},"application/vnd.kahootz":{"source":"iana","extensions":["ktz","ktr"]},"application/vnd.kde.karbon":{"source":"iana","extensions":["karbon"]},"application/vnd.kde.kchart":{"source":"iana","extensions":["chrt"]},"application/vnd.kde.kformula":{"source":"iana","extensions":["kfo"]},"application/vnd.kde.kivio":{"source":"iana","extensions":["flw"]},"application/vnd.kde.kontour":{"source":"iana","extensions":["kon"]},"application/vnd.kde.kpresenter":{"source":"iana","extensions":["kpr","kpt"]},"application/vnd.kde.kspread":{"source":"iana","extensions":["ksp"]},"application/vnd.kde.kword":{"source":"iana","extensions":["kwd","kwt"]},"application/vnd.kenameaapp":{"source":"iana","extensions":["htke"]},"application/vnd.kidspiration":{"source":"iana","extensions":["kia"]},"application/vnd.kinar":{"source":"iana","extensions":["kne","knp"]},"application/vnd.koan":{"source":"iana","extensions":["skp","skd","skt","skm"]},"application/vnd.kodak-descriptor":{"source":"iana","extensions":["sse"]},"application/vnd.las":{"source":"iana"},"application/vnd.las.las+json":{"source":"iana","compressible":true},"application/vnd.las.las+xml":{"source":"iana","compressible":true,"extensions":["lasxml"]},"application/vnd.laszip":{"source":"iana"},"application/vnd.leap+json":{"source":"iana","compressible":true},"application/vnd.liberty-request+xml":{"source":"iana","compressible":true},"application/vnd.llamagraphics.life-balance.desktop":{"source":"iana","extensions":["lbd"]},"application/vnd.llamagraphics.life-balance.exchange+xml":{"source":"iana","compressible":true,"extensions":["lbe"]},"application/vnd.logipipe.circuit+zip":{"source":"iana","compressible":false},"application/vnd.loom":{"source":"iana"},"application/vnd.lotus-1-2-3":{"source":"iana","extensions":["123"]},"application/vnd.lotus-approach":{"source":"iana","extensions":["apr"]},"application/vnd.lotus-freelance":{"source":"iana","extensions":["pre"]},"application/vnd.lotus-notes":{"source":"iana","extensions":["nsf"]},"application/vnd.lotus-organizer":{"source":"iana","extensions":["org"]},"application/vnd.lotus-screencam":{"source":"iana","extensions":["scm"]},"application/vnd.lotus-wordpro":{"source":"iana","extensions":["lwp"]},"application/vnd.macports.portpkg":{"source":"iana","extensions":["portpkg"]},"application/vnd.mapbox-vector-tile":{"source":"iana"},"application/vnd.marlin.drm.actiontoken+xml":{"source":"iana","compressible":true},"application/vnd.marlin.drm.conftoken+xml":{"source":"iana","compressible":true},"application/vnd.marlin.drm.license+xml":{"source":"iana","compressible":true},"application/vnd.marlin.drm.mdcf":{"source":"iana"},"application/vnd.mason+json":{"source":"iana","compressible":true},"application/vnd.maxmind.maxmind-db":{"source":"iana"},"application/vnd.mcd":{"source":"iana","extensions":["mcd"]},"application/vnd.medcalcdata":{"source":"iana","extensions":["mc1"]},"application/vnd.mediastation.cdkey":{"source":"iana","extensions":["cdkey"]},"application/vnd.meridian-slingshot":{"source":"iana"},"application/vnd.mfer":{"source":"iana","extensions":["mwf"]},"application/vnd.mfmp":{"source":"iana","extensions":["mfm"]},"application/vnd.micro+json":{"source":"iana","compressible":true},"application/vnd.micrografx.flo":{"source":"iana","extensions":["flo"]},"application/vnd.micrografx.igx":{"source":"iana","extensions":["igx"]},"application/vnd.microsoft.portable-executable":{"source":"iana"},"application/vnd.microsoft.windows.thumbnail-cache":{"source":"iana"},"application/vnd.miele+json":{"source":"iana","compressible":true},"application/vnd.mif":{"source":"iana","extensions":["mif"]},"application/vnd.minisoft-hp3000-save":{"source":"iana"},"application/vnd.mitsubishi.misty-guard.trustweb":{"source":"iana"},"application/vnd.mobius.daf":{"source":"iana","extensions":["daf"]},"application/vnd.mobius.dis":{"source":"iana","extensions":["dis"]},"application/vnd.mobius.mbk":{"source":"iana","extensions":["mbk"]},"application/vnd.mobius.mqy":{"source":"iana","extensions":["mqy"]},"application/vnd.mobius.msl":{"source":"iana","extensions":["msl"]},"application/vnd.mobius.plc":{"source":"iana","extensions":["plc"]},"application/vnd.mobius.txf":{"source":"iana","extensions":["txf"]},"application/vnd.mophun.application":{"source":"iana","extensions":["mpn"]},"application/vnd.mophun.certificate":{"source":"iana","extensions":["mpc"]},"application/vnd.motorola.flexsuite":{"source":"iana"},"application/vnd.motorola.flexsuite.adsi":{"source":"iana"},"application/vnd.motorola.flexsuite.fis":{"source":"iana"},"application/vnd.motorola.flexsuite.gotap":{"source":"iana"},"application/vnd.motorola.flexsuite.kmr":{"source":"iana"},"application/vnd.motorola.flexsuite.ttc":{"source":"iana"},"application/vnd.motorola.flexsuite.wem":{"source":"iana"},"application/vnd.motorola.iprm":{"source":"iana"},"application/vnd.mozilla.xul+xml":{"source":"iana","compressible":true,"extensions":["xul"]},"application/vnd.ms-3mfdocument":{"source":"iana"},"application/vnd.ms-artgalry":{"source":"iana","extensions":["cil"]},"application/vnd.ms-asf":{"source":"iana"},"application/vnd.ms-cab-compressed":{"source":"iana","extensions":["cab"]},"application/vnd.ms-color.iccprofile":{"source":"apache"},"application/vnd.ms-excel":{"source":"iana","compressible":false,"extensions":["xls","xlm","xla","xlc","xlt","xlw"]},"application/vnd.ms-excel.addin.macroenabled.12":{"source":"iana","extensions":["xlam"]},"application/vnd.ms-excel.sheet.binary.macroenabled.12":{"source":"iana","extensions":["xlsb"]},"application/vnd.ms-excel.sheet.macroenabled.12":{"source":"iana","extensions":["xlsm"]},"application/vnd.ms-excel.template.macroenabled.12":{"source":"iana","extensions":["xltm"]},"application/vnd.ms-fontobject":{"source":"iana","compressible":true,"extensions":["eot"]},"application/vnd.ms-htmlhelp":{"source":"iana","extensions":["chm"]},"application/vnd.ms-ims":{"source":"iana","extensions":["ims"]},"application/vnd.ms-lrm":{"source":"iana","extensions":["lrm"]},"application/vnd.ms-office.activex+xml":{"source":"iana","compressible":true},"application/vnd.ms-officetheme":{"source":"iana","extensions":["thmx"]},"application/vnd.ms-opentype":{"source":"apache","compressible":true},"application/vnd.ms-outlook":{"compressible":false,"extensions":["msg"]},"application/vnd.ms-package.obfuscated-opentype":{"source":"apache"},"application/vnd.ms-pki.seccat":{"source":"apache","extensions":["cat"]},"application/vnd.ms-pki.stl":{"source":"apache","extensions":["stl"]},"application/vnd.ms-playready.initiator+xml":{"source":"iana","compressible":true},"application/vnd.ms-powerpoint":{"source":"iana","compressible":false,"extensions":["ppt","pps","pot"]},"application/vnd.ms-powerpoint.addin.macroenabled.12":{"source":"iana","extensions":["ppam"]},"application/vnd.ms-powerpoint.presentation.macroenabled.12":{"source":"iana","extensions":["pptm"]},"application/vnd.ms-powerpoint.slide.macroenabled.12":{"source":"iana","extensions":["sldm"]},"application/vnd.ms-powerpoint.slideshow.macroenabled.12":{"source":"iana","extensions":["ppsm"]},"application/vnd.ms-powerpoint.template.macroenabled.12":{"source":"iana","extensions":["potm"]},"application/vnd.ms-printdevicecapabilities+xml":{"source":"iana","compressible":true},"application/vnd.ms-printing.printticket+xml":{"source":"apache","compressible":true},"application/vnd.ms-printschematicket+xml":{"source":"iana","compressible":true},"application/vnd.ms-project":{"source":"iana","extensions":["mpp","mpt"]},"application/vnd.ms-tnef":{"source":"iana"},"application/vnd.ms-windows.devicepairing":{"source":"iana"},"application/vnd.ms-windows.nwprinting.oob":{"source":"iana"},"application/vnd.ms-windows.printerpairing":{"source":"iana"},"application/vnd.ms-windows.wsd.oob":{"source":"iana"},"application/vnd.ms-wmdrm.lic-chlg-req":{"source":"iana"},"application/vnd.ms-wmdrm.lic-resp":{"source":"iana"},"application/vnd.ms-wmdrm.meter-chlg-req":{"source":"iana"},"application/vnd.ms-wmdrm.meter-resp":{"source":"iana"},"application/vnd.ms-word.document.macroenabled.12":{"source":"iana","extensions":["docm"]},"application/vnd.ms-word.template.macroenabled.12":{"source":"iana","extensions":["dotm"]},"application/vnd.ms-works":{"source":"iana","extensions":["wps","wks","wcm","wdb"]},"application/vnd.ms-wpl":{"source":"iana","extensions":["wpl"]},"application/vnd.ms-xpsdocument":{"source":"iana","compressible":false,"extensions":["xps"]},"application/vnd.msa-disk-image":{"source":"iana"},"application/vnd.mseq":{"source":"iana","extensions":["mseq"]},"application/vnd.msign":{"source":"iana"},"application/vnd.multiad.creator":{"source":"iana"},"application/vnd.multiad.creator.cif":{"source":"iana"},"application/vnd.music-niff":{"source":"iana"},"application/vnd.musician":{"source":"iana","extensions":["mus"]},"application/vnd.muvee.style":{"source":"iana","extensions":["msty"]},"application/vnd.mynfc":{"source":"iana","extensions":["taglet"]},"application/vnd.ncd.control":{"source":"iana"},"application/vnd.ncd.reference":{"source":"iana"},"application/vnd.nearst.inv+json":{"source":"iana","compressible":true},"application/vnd.nervana":{"source":"iana"},"application/vnd.netfpx":{"source":"iana"},"application/vnd.neurolanguage.nlu":{"source":"iana","extensions":["nlu"]},"application/vnd.nimn":{"source":"iana"},"application/vnd.nintendo.nitro.rom":{"source":"iana"},"application/vnd.nintendo.snes.rom":{"source":"iana"},"application/vnd.nitf":{"source":"iana","extensions":["ntf","nitf"]},"application/vnd.noblenet-directory":{"source":"iana","extensions":["nnd"]},"application/vnd.noblenet-sealer":{"source":"iana","extensions":["nns"]},"application/vnd.noblenet-web":{"source":"iana","extensions":["nnw"]},"application/vnd.nokia.catalogs":{"source":"iana"},"application/vnd.nokia.conml+wbxml":{"source":"iana"},"application/vnd.nokia.conml+xml":{"source":"iana","compressible":true},"application/vnd.nokia.iptv.config+xml":{"source":"iana","compressible":true},"application/vnd.nokia.isds-radio-presets":{"source":"iana"},"application/vnd.nokia.landmark+wbxml":{"source":"iana"},"application/vnd.nokia.landmark+xml":{"source":"iana","compressible":true},"application/vnd.nokia.landmarkcollection+xml":{"source":"iana","compressible":true},"application/vnd.nokia.n-gage.ac+xml":{"source":"iana","compressible":true,"extensions":["ac"]},"application/vnd.nokia.n-gage.data":{"source":"iana","extensions":["ngdat"]},"application/vnd.nokia.n-gage.symbian.install":{"source":"iana","extensions":["n-gage"]},"application/vnd.nokia.ncd":{"source":"iana"},"application/vnd.nokia.pcd+wbxml":{"source":"iana"},"application/vnd.nokia.pcd+xml":{"source":"iana","compressible":true},"application/vnd.nokia.radio-preset":{"source":"iana","extensions":["rpst"]},"application/vnd.nokia.radio-presets":{"source":"iana","extensions":["rpss"]},"application/vnd.novadigm.edm":{"source":"iana","extensions":["edm"]},"application/vnd.novadigm.edx":{"source":"iana","extensions":["edx"]},"application/vnd.novadigm.ext":{"source":"iana","extensions":["ext"]},"application/vnd.ntt-local.content-share":{"source":"iana"},"application/vnd.ntt-local.file-transfer":{"source":"iana"},"application/vnd.ntt-local.ogw_remote-access":{"source":"iana"},"application/vnd.ntt-local.sip-ta_remote":{"source":"iana"},"application/vnd.ntt-local.sip-ta_tcp_stream":{"source":"iana"},"application/vnd.oasis.opendocument.chart":{"source":"iana","extensions":["odc"]},"application/vnd.oasis.opendocument.chart-template":{"source":"iana","extensions":["otc"]},"application/vnd.oasis.opendocument.database":{"source":"iana","extensions":["odb"]},"application/vnd.oasis.opendocument.formula":{"source":"iana","extensions":["odf"]},"application/vnd.oasis.opendocument.formula-template":{"source":"iana","extensions":["odft"]},"application/vnd.oasis.opendocument.graphics":{"source":"iana","compressible":false,"extensions":["odg"]},"application/vnd.oasis.opendocument.graphics-template":{"source":"iana","extensions":["otg"]},"application/vnd.oasis.opendocument.image":{"source":"iana","extensions":["odi"]},"application/vnd.oasis.opendocument.image-template":{"source":"iana","extensions":["oti"]},"application/vnd.oasis.opendocument.presentation":{"source":"iana","compressible":false,"extensions":["odp"]},"application/vnd.oasis.opendocument.presentation-template":{"source":"iana","extensions":["otp"]},"application/vnd.oasis.opendocument.spreadsheet":{"source":"iana","compressible":false,"extensions":["ods"]},"application/vnd.oasis.opendocument.spreadsheet-template":{"source":"iana","extensions":["ots"]},"application/vnd.oasis.opendocument.text":{"source":"iana","compressible":false,"extensions":["odt"]},"application/vnd.oasis.opendocument.text-master":{"source":"iana","extensions":["odm"]},"application/vnd.oasis.opendocument.text-template":{"source":"iana","extensions":["ott"]},"application/vnd.oasis.opendocument.text-web":{"source":"iana","extensions":["oth"]},"application/vnd.obn":{"source":"iana"},"application/vnd.ocf+cbor":{"source":"iana"},"application/vnd.oftn.l10n+json":{"source":"iana","compressible":true},"application/vnd.oipf.contentaccessdownload+xml":{"source":"iana","compressible":true},"application/vnd.oipf.contentaccessstreaming+xml":{"source":"iana","compressible":true},"application/vnd.oipf.cspg-hexbinary":{"source":"iana"},"application/vnd.oipf.dae.svg+xml":{"source":"iana","compressible":true},"application/vnd.oipf.dae.xhtml+xml":{"source":"iana","compressible":true},"application/vnd.oipf.mippvcontrolmessage+xml":{"source":"iana","compressible":true},"application/vnd.oipf.pae.gem":{"source":"iana"},"application/vnd.oipf.spdiscovery+xml":{"source":"iana","compressible":true},"application/vnd.oipf.spdlist+xml":{"source":"iana","compressible":true},"application/vnd.oipf.ueprofile+xml":{"source":"iana","compressible":true},"application/vnd.oipf.userprofile+xml":{"source":"iana","compressible":true},"application/vnd.olpc-sugar":{"source":"iana","extensions":["xo"]},"application/vnd.oma-scws-config":{"source":"iana"},"application/vnd.oma-scws-http-request":{"source":"iana"},"application/vnd.oma-scws-http-response":{"source":"iana"},"application/vnd.oma.bcast.associated-procedure-parameter+xml":{"source":"iana","compressible":true},"application/vnd.oma.bcast.drm-trigger+xml":{"source":"iana","compressible":true},"application/vnd.oma.bcast.imd+xml":{"source":"iana","compressible":true},"application/vnd.oma.bcast.ltkm":{"source":"iana"},"application/vnd.oma.bcast.notification+xml":{"source":"iana","compressible":true},"application/vnd.oma.bcast.provisioningtrigger":{"source":"iana"},"application/vnd.oma.bcast.sgboot":{"source":"iana"},"application/vnd.oma.bcast.sgdd+xml":{"source":"iana","compressible":true},"application/vnd.oma.bcast.sgdu":{"source":"iana"},"application/vnd.oma.bcast.simple-symbol-container":{"source":"iana"},"application/vnd.oma.bcast.smartcard-trigger+xml":{"source":"iana","compressible":true},"application/vnd.oma.bcast.sprov+xml":{"source":"iana","compressible":true},"application/vnd.oma.bcast.stkm":{"source":"iana"},"application/vnd.oma.cab-address-book+xml":{"source":"iana","compressible":true},"application/vnd.oma.cab-feature-handler+xml":{"source":"iana","compressible":true},"application/vnd.oma.cab-pcc+xml":{"source":"iana","compressible":true},"application/vnd.oma.cab-subs-invite+xml":{"source":"iana","compressible":true},"application/vnd.oma.cab-user-prefs+xml":{"source":"iana","compressible":true},"application/vnd.oma.dcd":{"source":"iana"},"application/vnd.oma.dcdc":{"source":"iana"},"application/vnd.oma.dd2+xml":{"source":"iana","compressible":true,"extensions":["dd2"]},"application/vnd.oma.drm.risd+xml":{"source":"iana","compressible":true},"application/vnd.oma.group-usage-list+xml":{"source":"iana","compressible":true},"application/vnd.oma.lwm2m+json":{"source":"iana","compressible":true},"application/vnd.oma.lwm2m+tlv":{"source":"iana"},"application/vnd.oma.pal+xml":{"source":"iana","compressible":true},"application/vnd.oma.poc.detailed-progress-report+xml":{"source":"iana","compressible":true},"application/vnd.oma.poc.final-report+xml":{"source":"iana","compressible":true},"application/vnd.oma.poc.groups+xml":{"source":"iana","compressible":true},"application/vnd.oma.poc.invocation-descriptor+xml":{"source":"iana","compressible":true},"application/vnd.oma.poc.optimized-progress-report+xml":{"source":"iana","compressible":true},"application/vnd.oma.push":{"source":"iana"},"application/vnd.oma.scidm.messages+xml":{"source":"iana","compressible":true},"application/vnd.oma.xcap-directory+xml":{"source":"iana","compressible":true},"application/vnd.omads-email+xml":{"source":"iana","compressible":true},"application/vnd.omads-file+xml":{"source":"iana","compressible":true},"application/vnd.omads-folder+xml":{"source":"iana","compressible":true},"application/vnd.omaloc-supl-init":{"source":"iana"},"application/vnd.onepager":{"source":"iana"},"application/vnd.onepagertamp":{"source":"iana"},"application/vnd.onepagertamx":{"source":"iana"},"application/vnd.onepagertat":{"source":"iana"},"application/vnd.onepagertatp":{"source":"iana"},"application/vnd.onepagertatx":{"source":"iana"},"application/vnd.openblox.game+xml":{"source":"iana","compressible":true,"extensions":["obgx"]},"application/vnd.openblox.game-binary":{"source":"iana"},"application/vnd.openeye.oeb":{"source":"iana"},"application/vnd.openofficeorg.extension":{"source":"apache","extensions":["oxt"]},"application/vnd.openstreetmap.data+xml":{"source":"iana","compressible":true,"extensions":["osm"]},"application/vnd.openxmlformats-officedocument.custom-properties+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.customxmlproperties+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.drawing+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.drawingml.chart+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.extended-properties+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.comments+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{"source":"iana","compressible":false,"extensions":["pptx"]},"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.presprops+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.slide":{"source":"iana","extensions":["sldx"]},"application/vnd.openxmlformats-officedocument.presentationml.slide+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.slideshow":{"source":"iana","extensions":["ppsx"]},"application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.tags+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.template":{"source":"iana","extensions":["potx"]},"application/vnd.openxmlformats-officedocument.presentationml.template.main+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{"source":"iana","compressible":false,"extensions":["xlsx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.template":{"source":"iana","extensions":["xltx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.theme+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.themeoverride+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.vmldrawing":{"source":"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{"source":"iana","compressible":false,"extensions":["docx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.template":{"source":"iana","extensions":["dotx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-package.core-properties+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml":{"source":"iana","compressible":true},"application/vnd.openxmlformats-package.relationships+xml":{"source":"iana","compressible":true},"application/vnd.oracle.resource+json":{"source":"iana","compressible":true},"application/vnd.orange.indata":{"source":"iana"},"application/vnd.osa.netdeploy":{"source":"iana"},"application/vnd.osgeo.mapguide.package":{"source":"iana","extensions":["mgp"]},"application/vnd.osgi.bundle":{"source":"iana"},"application/vnd.osgi.dp":{"source":"iana","extensions":["dp"]},"application/vnd.osgi.subsystem":{"source":"iana","extensions":["esa"]},"application/vnd.otps.ct-kip+xml":{"source":"iana","compressible":true},"application/vnd.oxli.countgraph":{"source":"iana"},"application/vnd.pagerduty+json":{"source":"iana","compressible":true},"application/vnd.palm":{"source":"iana","extensions":["pdb","pqa","oprc"]},"application/vnd.panoply":{"source":"iana"},"application/vnd.paos.xml":{"source":"iana"},"application/vnd.patentdive":{"source":"iana"},"application/vnd.patientecommsdoc":{"source":"iana"},"application/vnd.pawaafile":{"source":"iana","extensions":["paw"]},"application/vnd.pcos":{"source":"iana"},"application/vnd.pg.format":{"source":"iana","extensions":["str"]},"application/vnd.pg.osasli":{"source":"iana","extensions":["ei6"]},"application/vnd.piaccess.application-licence":{"source":"iana"},"application/vnd.picsel":{"source":"iana","extensions":["efif"]},"application/vnd.pmi.widget":{"source":"iana","extensions":["wg"]},"application/vnd.poc.group-advertisement+xml":{"source":"iana","compressible":true},"application/vnd.pocketlearn":{"source":"iana","extensions":["plf"]},"application/vnd.powerbuilder6":{"source":"iana","extensions":["pbd"]},"application/vnd.powerbuilder6-s":{"source":"iana"},"application/vnd.powerbuilder7":{"source":"iana"},"application/vnd.powerbuilder7-s":{"source":"iana"},"application/vnd.powerbuilder75":{"source":"iana"},"application/vnd.powerbuilder75-s":{"source":"iana"},"application/vnd.preminet":{"source":"iana"},"application/vnd.previewsystems.box":{"source":"iana","extensions":["box"]},"application/vnd.proteus.magazine":{"source":"iana","extensions":["mgz"]},"application/vnd.psfs":{"source":"iana"},"application/vnd.publishare-delta-tree":{"source":"iana","extensions":["qps"]},"application/vnd.pvi.ptid1":{"source":"iana","extensions":["ptid"]},"application/vnd.pwg-multiplexed":{"source":"iana"},"application/vnd.pwg-xhtml-print+xml":{"source":"iana","compressible":true},"application/vnd.qualcomm.brew-app-res":{"source":"iana"},"application/vnd.quarantainenet":{"source":"iana"},"application/vnd.quark.quarkxpress":{"source":"iana","extensions":["qxd","qxt","qwd","qwt","qxl","qxb"]},"application/vnd.quobject-quoxdocument":{"source":"iana"},"application/vnd.radisys.moml+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-audit+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-audit-conf+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-audit-conn+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-audit-dialog+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-audit-stream+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-conf+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-dialog+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-dialog-base+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-dialog-fax-detect+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-dialog-fax-sendrecv+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-dialog-group+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-dialog-speech+xml":{"source":"iana","compressible":true},"application/vnd.radisys.msml-dialog-transform+xml":{"source":"iana","compressible":true},"application/vnd.rainstor.data":{"source":"iana"},"application/vnd.rapid":{"source":"iana"},"application/vnd.rar":{"source":"iana"},"application/vnd.realvnc.bed":{"source":"iana","extensions":["bed"]},"application/vnd.recordare.musicxml":{"source":"iana","extensions":["mxl"]},"application/vnd.recordare.musicxml+xml":{"source":"iana","compressible":true,"extensions":["musicxml"]},"application/vnd.renlearn.rlprint":{"source":"iana"},"application/vnd.restful+json":{"source":"iana","compressible":true},"application/vnd.rig.cryptonote":{"source":"iana","extensions":["cryptonote"]},"application/vnd.rim.cod":{"source":"apache","extensions":["cod"]},"application/vnd.rn-realmedia":{"source":"apache","extensions":["rm"]},"application/vnd.rn-realmedia-vbr":{"source":"apache","extensions":["rmvb"]},"application/vnd.route66.link66+xml":{"source":"iana","compressible":true,"extensions":["link66"]},"application/vnd.rs-274x":{"source":"iana"},"application/vnd.ruckus.download":{"source":"iana"},"application/vnd.s3sms":{"source":"iana"},"application/vnd.sailingtracker.track":{"source":"iana","extensions":["st"]},"application/vnd.sbm.cid":{"source":"iana"},"application/vnd.sbm.mid2":{"source":"iana"},"application/vnd.scribus":{"source":"iana"},"application/vnd.sealed.3df":{"source":"iana"},"application/vnd.sealed.csf":{"source":"iana"},"application/vnd.sealed.doc":{"source":"iana"},"application/vnd.sealed.eml":{"source":"iana"},"application/vnd.sealed.mht":{"source":"iana"},"application/vnd.sealed.net":{"source":"iana"},"application/vnd.sealed.ppt":{"source":"iana"},"application/vnd.sealed.tiff":{"source":"iana"},"application/vnd.sealed.xls":{"source":"iana"},"application/vnd.sealedmedia.softseal.html":{"source":"iana"},"application/vnd.sealedmedia.softseal.pdf":{"source":"iana"},"application/vnd.seemail":{"source":"iana","extensions":["see"]},"application/vnd.sema":{"source":"iana","extensions":["sema"]},"application/vnd.semd":{"source":"iana","extensions":["semd"]},"application/vnd.semf":{"source":"iana","extensions":["semf"]},"application/vnd.shade-save-file":{"source":"iana"},"application/vnd.shana.informed.formdata":{"source":"iana","extensions":["ifm"]},"application/vnd.shana.informed.formtemplate":{"source":"iana","extensions":["itp"]},"application/vnd.shana.informed.interchange":{"source":"iana","extensions":["iif"]},"application/vnd.shana.informed.package":{"source":"iana","extensions":["ipk"]},"application/vnd.shootproof+json":{"source":"iana","compressible":true},"application/vnd.shopkick+json":{"source":"iana","compressible":true},"application/vnd.sigrok.session":{"source":"iana"},"application/vnd.simtech-mindmapper":{"source":"iana","extensions":["twd","twds"]},"application/vnd.siren+json":{"source":"iana","compressible":true},"application/vnd.smaf":{"source":"iana","extensions":["mmf"]},"application/vnd.smart.notebook":{"source":"iana"},"application/vnd.smart.teacher":{"source":"iana","extensions":["teacher"]},"application/vnd.software602.filler.form+xml":{"source":"iana","compressible":true,"extensions":["fo"]},"application/vnd.software602.filler.form-xml-zip":{"source":"iana"},"application/vnd.solent.sdkm+xml":{"source":"iana","compressible":true,"extensions":["sdkm","sdkd"]},"application/vnd.spotfire.dxp":{"source":"iana","extensions":["dxp"]},"application/vnd.spotfire.sfs":{"source":"iana","extensions":["sfs"]},"application/vnd.sqlite3":{"source":"iana"},"application/vnd.sss-cod":{"source":"iana"},"application/vnd.sss-dtf":{"source":"iana"},"application/vnd.sss-ntf":{"source":"iana"},"application/vnd.stardivision.calc":{"source":"apache","extensions":["sdc"]},"application/vnd.stardivision.draw":{"source":"apache","extensions":["sda"]},"application/vnd.stardivision.impress":{"source":"apache","extensions":["sdd"]},"application/vnd.stardivision.math":{"source":"apache","extensions":["smf"]},"application/vnd.stardivision.writer":{"source":"apache","extensions":["sdw","vor"]},"application/vnd.stardivision.writer-global":{"source":"apache","extensions":["sgl"]},"application/vnd.stepmania.package":{"source":"iana","extensions":["smzip"]},"application/vnd.stepmania.stepchart":{"source":"iana","extensions":["sm"]},"application/vnd.street-stream":{"source":"iana"},"application/vnd.sun.wadl+xml":{"source":"iana","compressible":true,"extensions":["wadl"]},"application/vnd.sun.xml.calc":{"source":"apache","extensions":["sxc"]},"application/vnd.sun.xml.calc.template":{"source":"apache","extensions":["stc"]},"application/vnd.sun.xml.draw":{"source":"apache","extensions":["sxd"]},"application/vnd.sun.xml.draw.template":{"source":"apache","extensions":["std"]},"application/vnd.sun.xml.impress":{"source":"apache","extensions":["sxi"]},"application/vnd.sun.xml.impress.template":{"source":"apache","extensions":["sti"]},"application/vnd.sun.xml.math":{"source":"apache","extensions":["sxm"]},"application/vnd.sun.xml.writer":{"source":"apache","extensions":["sxw"]},"application/vnd.sun.xml.writer.global":{"source":"apache","extensions":["sxg"]},"application/vnd.sun.xml.writer.template":{"source":"apache","extensions":["stw"]},"application/vnd.sus-calendar":{"source":"iana","extensions":["sus","susp"]},"application/vnd.svd":{"source":"iana","extensions":["svd"]},"application/vnd.swiftview-ics":{"source":"iana"},"application/vnd.symbian.install":{"source":"apache","extensions":["sis","sisx"]},"application/vnd.syncml+xml":{"source":"iana","compressible":true,"extensions":["xsm"]},"application/vnd.syncml.dm+wbxml":{"source":"iana","extensions":["bdm"]},"application/vnd.syncml.dm+xml":{"source":"iana","compressible":true,"extensions":["xdm"]},"application/vnd.syncml.dm.notification":{"source":"iana"},"application/vnd.syncml.dmddf+wbxml":{"source":"iana"},"application/vnd.syncml.dmddf+xml":{"source":"iana","compressible":true,"extensions":["ddf"]},"application/vnd.syncml.dmtnds+wbxml":{"source":"iana"},"application/vnd.syncml.dmtnds+xml":{"source":"iana","compressible":true},"application/vnd.syncml.ds.notification":{"source":"iana"},"application/vnd.tableschema+json":{"source":"iana","compressible":true},"application/vnd.tao.intent-module-archive":{"source":"iana","extensions":["tao"]},"application/vnd.tcpdump.pcap":{"source":"iana","extensions":["pcap","cap","dmp"]},"application/vnd.think-cell.ppttc+json":{"source":"iana","compressible":true},"application/vnd.tmd.mediaflex.api+xml":{"source":"iana","compressible":true},"application/vnd.tml":{"source":"iana"},"application/vnd.tmobile-livetv":{"source":"iana","extensions":["tmo"]},"application/vnd.tri.onesource":{"source":"iana"},"application/vnd.trid.tpt":{"source":"iana","extensions":["tpt"]},"application/vnd.triscape.mxs":{"source":"iana","extensions":["mxs"]},"application/vnd.trueapp":{"source":"iana","extensions":["tra"]},"application/vnd.truedoc":{"source":"iana"},"application/vnd.ubisoft.webplayer":{"source":"iana"},"application/vnd.ufdl":{"source":"iana","extensions":["ufd","ufdl"]},"application/vnd.uiq.theme":{"source":"iana","extensions":["utz"]},"application/vnd.umajin":{"source":"iana","extensions":["umj"]},"application/vnd.unity":{"source":"iana","extensions":["unityweb"]},"application/vnd.uoml+xml":{"source":"iana","compressible":true,"extensions":["uoml"]},"application/vnd.uplanet.alert":{"source":"iana"},"application/vnd.uplanet.alert-wbxml":{"source":"iana"},"application/vnd.uplanet.bearer-choice":{"source":"iana"},"application/vnd.uplanet.bearer-choice-wbxml":{"source":"iana"},"application/vnd.uplanet.cacheop":{"source":"iana"},"application/vnd.uplanet.cacheop-wbxml":{"source":"iana"},"application/vnd.uplanet.channel":{"source":"iana"},"application/vnd.uplanet.channel-wbxml":{"source":"iana"},"application/vnd.uplanet.list":{"source":"iana"},"application/vnd.uplanet.list-wbxml":{"source":"iana"},"application/vnd.uplanet.listcmd":{"source":"iana"},"application/vnd.uplanet.listcmd-wbxml":{"source":"iana"},"application/vnd.uplanet.signal":{"source":"iana"},"application/vnd.uri-map":{"source":"iana"},"application/vnd.valve.source.material":{"source":"iana"},"application/vnd.vcx":{"source":"iana","extensions":["vcx"]},"application/vnd.vd-study":{"source":"iana"},"application/vnd.vectorworks":{"source":"iana"},"application/vnd.vel+json":{"source":"iana","compressible":true},"application/vnd.verimatrix.vcas":{"source":"iana"},"application/vnd.veryant.thin":{"source":"iana"},"application/vnd.ves.encrypted":{"source":"iana"},"application/vnd.vidsoft.vidconference":{"source":"iana"},"application/vnd.visio":{"source":"iana","extensions":["vsd","vst","vss","vsw"]},"application/vnd.visionary":{"source":"iana","extensions":["vis"]},"application/vnd.vividence.scriptfile":{"source":"iana"},"application/vnd.vsf":{"source":"iana","extensions":["vsf"]},"application/vnd.wap.sic":{"source":"iana"},"application/vnd.wap.slc":{"source":"iana"},"application/vnd.wap.wbxml":{"source":"iana","extensions":["wbxml"]},"application/vnd.wap.wmlc":{"source":"iana","extensions":["wmlc"]},"application/vnd.wap.wmlscriptc":{"source":"iana","extensions":["wmlsc"]},"application/vnd.webturbo":{"source":"iana","extensions":["wtb"]},"application/vnd.wfa.p2p":{"source":"iana"},"application/vnd.wfa.wsc":{"source":"iana"},"application/vnd.windows.devicepairing":{"source":"iana"},"application/vnd.wmc":{"source":"iana"},"application/vnd.wmf.bootstrap":{"source":"iana"},"application/vnd.wolfram.mathematica":{"source":"iana"},"application/vnd.wolfram.mathematica.package":{"source":"iana"},"application/vnd.wolfram.player":{"source":"iana","extensions":["nbp"]},"application/vnd.wordperfect":{"source":"iana","extensions":["wpd"]},"application/vnd.wqd":{"source":"iana","extensions":["wqd"]},"application/vnd.wrq-hp3000-labelled":{"source":"iana"},"application/vnd.wt.stf":{"source":"iana","extensions":["stf"]},"application/vnd.wv.csp+wbxml":{"source":"iana"},"application/vnd.wv.csp+xml":{"source":"iana","compressible":true},"application/vnd.wv.ssp+xml":{"source":"iana","compressible":true},"application/vnd.xacml+json":{"source":"iana","compressible":true},"application/vnd.xara":{"source":"iana","extensions":["xar"]},"application/vnd.xfdl":{"source":"iana","extensions":["xfdl"]},"application/vnd.xfdl.webform":{"source":"iana"},"application/vnd.xmi+xml":{"source":"iana","compressible":true},"application/vnd.xmpie.cpkg":{"source":"iana"},"application/vnd.xmpie.dpkg":{"source":"iana"},"application/vnd.xmpie.plan":{"source":"iana"},"application/vnd.xmpie.ppkg":{"source":"iana"},"application/vnd.xmpie.xlim":{"source":"iana"},"application/vnd.yamaha.hv-dic":{"source":"iana","extensions":["hvd"]},"application/vnd.yamaha.hv-script":{"source":"iana","extensions":["hvs"]},"application/vnd.yamaha.hv-voice":{"source":"iana","extensions":["hvp"]},"application/vnd.yamaha.openscoreformat":{"source":"iana","extensions":["osf"]},"application/vnd.yamaha.openscoreformat.osfpvg+xml":{"source":"iana","compressible":true,"extensions":["osfpvg"]},"application/vnd.yamaha.remote-setup":{"source":"iana"},"application/vnd.yamaha.smaf-audio":{"source":"iana","extensions":["saf"]},"application/vnd.yamaha.smaf-phrase":{"source":"iana","extensions":["spf"]},"application/vnd.yamaha.through-ngn":{"source":"iana"},"application/vnd.yamaha.tunnel-udpencap":{"source":"iana"},"application/vnd.yaoweme":{"source":"iana"},"application/vnd.yellowriver-custom-menu":{"source":"iana","extensions":["cmp"]},"application/vnd.youtube.yt":{"source":"iana"},"application/vnd.zul":{"source":"iana","extensions":["zir","zirz"]},"application/vnd.zzazz.deck+xml":{"source":"iana","compressible":true,"extensions":["zaz"]},"application/voicexml+xml":{"source":"iana","compressible":true,"extensions":["vxml"]},"application/voucher-cms+json":{"source":"iana","compressible":true},"application/vq-rtcpxr":{"source":"iana"},"application/wasm":{"compressible":true,"extensions":["wasm"]},"application/watcherinfo+xml":{"source":"iana","compressible":true},"application/webpush-options+json":{"source":"iana","compressible":true},"application/whoispp-query":{"source":"iana"},"application/whoispp-response":{"source":"iana"},"application/widget":{"source":"iana","extensions":["wgt"]},"application/winhlp":{"source":"apache","extensions":["hlp"]},"application/wita":{"source":"iana"},"application/wordperfect5.1":{"source":"iana"},"application/wsdl+xml":{"source":"iana","compressible":true,"extensions":["wsdl"]},"application/wspolicy+xml":{"source":"iana","compressible":true,"extensions":["wspolicy"]},"application/x-7z-compressed":{"source":"apache","compressible":false,"extensions":["7z"]},"application/x-abiword":{"source":"apache","extensions":["abw"]},"application/x-ace-compressed":{"source":"apache","extensions":["ace"]},"application/x-amf":{"source":"apache"},"application/x-apple-diskimage":{"source":"apache","extensions":["dmg"]},"application/x-arj":{"compressible":false,"extensions":["arj"]},"application/x-authorware-bin":{"source":"apache","extensions":["aab","x32","u32","vox"]},"application/x-authorware-map":{"source":"apache","extensions":["aam"]},"application/x-authorware-seg":{"source":"apache","extensions":["aas"]},"application/x-bcpio":{"source":"apache","extensions":["bcpio"]},"application/x-bdoc":{"compressible":false,"extensions":["bdoc"]},"application/x-bittorrent":{"source":"apache","extensions":["torrent"]},"application/x-blorb":{"source":"apache","extensions":["blb","blorb"]},"application/x-bzip":{"source":"apache","compressible":false,"extensions":["bz"]},"application/x-bzip2":{"source":"apache","compressible":false,"extensions":["bz2","boz"]},"application/x-cbr":{"source":"apache","extensions":["cbr","cba","cbt","cbz","cb7"]},"application/x-cdlink":{"source":"apache","extensions":["vcd"]},"application/x-cfs-compressed":{"source":"apache","extensions":["cfs"]},"application/x-chat":{"source":"apache","extensions":["chat"]},"application/x-chess-pgn":{"source":"apache","extensions":["pgn"]},"application/x-chrome-extension":{"extensions":["crx"]},"application/x-cocoa":{"source":"nginx","extensions":["cco"]},"application/x-compress":{"source":"apache"},"application/x-conference":{"source":"apache","extensions":["nsc"]},"application/x-cpio":{"source":"apache","extensions":["cpio"]},"application/x-csh":{"source":"apache","extensions":["csh"]},"application/x-deb":{"compressible":false},"application/x-debian-package":{"source":"apache","extensions":["deb","udeb"]},"application/x-dgc-compressed":{"source":"apache","extensions":["dgc"]},"application/x-director":{"source":"apache","extensions":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"]},"application/x-doom":{"source":"apache","extensions":["wad"]},"application/x-dtbncx+xml":{"source":"apache","compressible":true,"extensions":["ncx"]},"application/x-dtbook+xml":{"source":"apache","compressible":true,"extensions":["dtb"]},"application/x-dtbresource+xml":{"source":"apache","compressible":true,"extensions":["res"]},"application/x-dvi":{"source":"apache","compressible":false,"extensions":["dvi"]},"application/x-envoy":{"source":"apache","extensions":["evy"]},"application/x-eva":{"source":"apache","extensions":["eva"]},"application/x-font-bdf":{"source":"apache","extensions":["bdf"]},"application/x-font-dos":{"source":"apache"},"application/x-font-framemaker":{"source":"apache"},"application/x-font-ghostscript":{"source":"apache","extensions":["gsf"]},"application/x-font-libgrx":{"source":"apache"},"application/x-font-linux-psf":{"source":"apache","extensions":["psf"]},"application/x-font-pcf":{"source":"apache","extensions":["pcf"]},"application/x-font-snf":{"source":"apache","extensions":["snf"]},"application/x-font-speedo":{"source":"apache"},"application/x-font-sunos-news":{"source":"apache"},"application/x-font-type1":{"source":"apache","extensions":["pfa","pfb","pfm","afm"]},"application/x-font-vfont":{"source":"apache"},"application/x-freearc":{"source":"apache","extensions":["arc"]},"application/x-futuresplash":{"source":"apache","extensions":["spl"]},"application/x-gca-compressed":{"source":"apache","extensions":["gca"]},"application/x-glulx":{"source":"apache","extensions":["ulx"]},"application/x-gnumeric":{"source":"apache","extensions":["gnumeric"]},"application/x-gramps-xml":{"source":"apache","extensions":["gramps"]},"application/x-gtar":{"source":"apache","extensions":["gtar"]},"application/x-gzip":{"source":"apache"},"application/x-hdf":{"source":"apache","extensions":["hdf"]},"application/x-httpd-php":{"compressible":true,"extensions":["php"]},"application/x-install-instructions":{"source":"apache","extensions":["install"]},"application/x-iso9660-image":{"source":"apache","extensions":["iso"]},"application/x-java-archive-diff":{"source":"nginx","extensions":["jardiff"]},"application/x-java-jnlp-file":{"source":"apache","compressible":false,"extensions":["jnlp"]},"application/x-javascript":{"compressible":true},"application/x-keepass2":{"extensions":["kdbx"]},"application/x-latex":{"source":"apache","compressible":false,"extensions":["latex"]},"application/x-lua-bytecode":{"extensions":["luac"]},"application/x-lzh-compressed":{"source":"apache","extensions":["lzh","lha"]},"application/x-makeself":{"source":"nginx","extensions":["run"]},"application/x-mie":{"source":"apache","extensions":["mie"]},"application/x-mobipocket-ebook":{"source":"apache","extensions":["prc","mobi"]},"application/x-mpegurl":{"compressible":false},"application/x-ms-application":{"source":"apache","extensions":["application"]},"application/x-ms-shortcut":{"source":"apache","extensions":["lnk"]},"application/x-ms-wmd":{"source":"apache","extensions":["wmd"]},"application/x-ms-wmz":{"source":"apache","extensions":["wmz"]},"application/x-ms-xbap":{"source":"apache","extensions":["xbap"]},"application/x-msaccess":{"source":"apache","extensions":["mdb"]},"application/x-msbinder":{"source":"apache","extensions":["obd"]},"application/x-mscardfile":{"source":"apache","extensions":["crd"]},"application/x-msclip":{"source":"apache","extensions":["clp"]},"application/x-msdos-program":{"extensions":["exe"]},"application/x-msdownload":{"source":"apache","extensions":["exe","dll","com","bat","msi"]},"application/x-msmediaview":{"source":"apache","extensions":["mvb","m13","m14"]},"application/x-msmetafile":{"source":"apache","extensions":["wmf","wmz","emf","emz"]},"application/x-msmoney":{"source":"apache","extensions":["mny"]},"application/x-mspublisher":{"source":"apache","extensions":["pub"]},"application/x-msschedule":{"source":"apache","extensions":["scd"]},"application/x-msterminal":{"source":"apache","extensions":["trm"]},"application/x-mswrite":{"source":"apache","extensions":["wri"]},"application/x-netcdf":{"source":"apache","extensions":["nc","cdf"]},"application/x-ns-proxy-autoconfig":{"compressible":true,"extensions":["pac"]},"application/x-nzb":{"source":"apache","extensions":["nzb"]},"application/x-perl":{"source":"nginx","extensions":["pl","pm"]},"application/x-pilot":{"source":"nginx","extensions":["prc","pdb"]},"application/x-pkcs12":{"source":"apache","compressible":false,"extensions":["p12","pfx"]},"application/x-pkcs7-certificates":{"source":"apache","extensions":["p7b","spc"]},"application/x-pkcs7-certreqresp":{"source":"apache","extensions":["p7r"]},"application/x-rar-compressed":{"source":"apache","compressible":false,"extensions":["rar"]},"application/x-redhat-package-manager":{"source":"nginx","extensions":["rpm"]},"application/x-research-info-systems":{"source":"apache","extensions":["ris"]},"application/x-sea":{"source":"nginx","extensions":["sea"]},"application/x-sh":{"source":"apache","compressible":true,"extensions":["sh"]},"application/x-shar":{"source":"apache","extensions":["shar"]},"application/x-shockwave-flash":{"source":"apache","compressible":false,"extensions":["swf"]},"application/x-silverlight-app":{"source":"apache","extensions":["xap"]},"application/x-sql":{"source":"apache","extensions":["sql"]},"application/x-stuffit":{"source":"apache","compressible":false,"extensions":["sit"]},"application/x-stuffitx":{"source":"apache","extensions":["sitx"]},"application/x-subrip":{"source":"apache","extensions":["srt"]},"application/x-sv4cpio":{"source":"apache","extensions":["sv4cpio"]},"application/x-sv4crc":{"source":"apache","extensions":["sv4crc"]},"application/x-t3vm-image":{"source":"apache","extensions":["t3"]},"application/x-tads":{"source":"apache","extensions":["gam"]},"application/x-tar":{"source":"apache","compressible":true,"extensions":["tar"]},"application/x-tcl":{"source":"apache","extensions":["tcl","tk"]},"application/x-tex":{"source":"apache","extensions":["tex"]},"application/x-tex-tfm":{"source":"apache","extensions":["tfm"]},"application/x-texinfo":{"source":"apache","extensions":["texinfo","texi"]},"application/x-tgif":{"source":"apache","extensions":["obj"]},"application/x-ustar":{"source":"apache","extensions":["ustar"]},"application/x-virtualbox-hdd":{"compressible":true,"extensions":["hdd"]},"application/x-virtualbox-ova":{"compressible":true,"extensions":["ova"]},"application/x-virtualbox-ovf":{"compressible":true,"extensions":["ovf"]},"application/x-virtualbox-vbox":{"compressible":true,"extensions":["vbox"]},"application/x-virtualbox-vbox-extpack":{"compressible":false,"extensions":["vbox-extpack"]},"application/x-virtualbox-vdi":{"compressible":true,"extensions":["vdi"]},"application/x-virtualbox-vhd":{"compressible":true,"extensions":["vhd"]},"application/x-virtualbox-vmdk":{"compressible":true,"extensions":["vmdk"]},"application/x-wais-source":{"source":"apache","extensions":["src"]},"application/x-web-app-manifest+json":{"compressible":true,"extensions":["webapp"]},"application/x-www-form-urlencoded":{"source":"iana","compressible":true},"application/x-x509-ca-cert":{"source":"apache","extensions":["der","crt","pem"]},"application/x-xfig":{"source":"apache","extensions":["fig"]},"application/x-xliff+xml":{"source":"apache","compressible":true,"extensions":["xlf"]},"application/x-xpinstall":{"source":"apache","compressible":false,"extensions":["xpi"]},"application/x-xz":{"source":"apache","extensions":["xz"]},"application/x-zmachine":{"source":"apache","extensions":["z1","z2","z3","z4","z5","z6","z7","z8"]},"application/x400-bp":{"source":"iana"},"application/xacml+xml":{"source":"iana","compressible":true},"application/xaml+xml":{"source":"apache","compressible":true,"extensions":["xaml"]},"application/xcap-att+xml":{"source":"iana","compressible":true,"extensions":["xav"]},"application/xcap-caps+xml":{"source":"iana","compressible":true,"extensions":["xca"]},"application/xcap-diff+xml":{"source":"iana","compressible":true,"extensions":["xdf"]},"application/xcap-el+xml":{"source":"iana","compressible":true,"extensions":["xel"]},"application/xcap-error+xml":{"source":"iana","compressible":true,"extensions":["xer"]},"application/xcap-ns+xml":{"source":"iana","compressible":true,"extensions":["xns"]},"application/xcon-conference-info+xml":{"source":"iana","compressible":true},"application/xcon-conference-info-diff+xml":{"source":"iana","compressible":true},"application/xenc+xml":{"source":"iana","compressible":true,"extensions":["xenc"]},"application/xhtml+xml":{"source":"iana","compressible":true,"extensions":["xhtml","xht"]},"application/xhtml-voice+xml":{"source":"apache","compressible":true},"application/xliff+xml":{"source":"iana","compressible":true,"extensions":["xlf"]},"application/xml":{"source":"iana","compressible":true,"extensions":["xml","xsl","xsd","rng"]},"application/xml-dtd":{"source":"iana","compressible":true,"extensions":["dtd"]},"application/xml-external-parsed-entity":{"source":"iana"},"application/xml-patch+xml":{"source":"iana","compressible":true},"application/xmpp+xml":{"source":"iana","compressible":true},"application/xop+xml":{"source":"iana","compressible":true,"extensions":["xop"]},"application/xproc+xml":{"source":"apache","compressible":true,"extensions":["xpl"]},"application/xslt+xml":{"source":"iana","compressible":true,"extensions":["xslt"]},"application/xspf+xml":{"source":"apache","compressible":true,"extensions":["xspf"]},"application/xv+xml":{"source":"iana","compressible":true,"extensions":["mxml","xhvml","xvml","xvm"]},"application/yang":{"source":"iana","extensions":["yang"]},"application/yang-data+json":{"source":"iana","compressible":true},"application/yang-data+xml":{"source":"iana","compressible":true},"application/yang-patch+json":{"source":"iana","compressible":true},"application/yang-patch+xml":{"source":"iana","compressible":true},"application/yin+xml":{"source":"iana","compressible":true,"extensions":["yin"]},"application/zip":{"source":"iana","compressible":false,"extensions":["zip"]},"application/zlib":{"source":"iana"},"application/zstd":{"source":"iana"},"audio/1d-interleaved-parityfec":{"source":"iana"},"audio/32kadpcm":{"source":"iana"},"audio/3gpp":{"source":"iana","compressible":false,"extensions":["3gpp"]},"audio/3gpp2":{"source":"iana"},"audio/aac":{"source":"iana"},"audio/ac3":{"source":"iana"},"audio/adpcm":{"source":"apache","extensions":["adp"]},"audio/amr":{"source":"iana"},"audio/amr-wb":{"source":"iana"},"audio/amr-wb+":{"source":"iana"},"audio/aptx":{"source":"iana"},"audio/asc":{"source":"iana"},"audio/atrac-advanced-lossless":{"source":"iana"},"audio/atrac-x":{"source":"iana"},"audio/atrac3":{"source":"iana"},"audio/basic":{"source":"iana","compressible":false,"extensions":["au","snd"]},"audio/bv16":{"source":"iana"},"audio/bv32":{"source":"iana"},"audio/clearmode":{"source":"iana"},"audio/cn":{"source":"iana"},"audio/dat12":{"source":"iana"},"audio/dls":{"source":"iana"},"audio/dsr-es201108":{"source":"iana"},"audio/dsr-es202050":{"source":"iana"},"audio/dsr-es202211":{"source":"iana"},"audio/dsr-es202212":{"source":"iana"},"audio/dv":{"source":"iana"},"audio/dvi4":{"source":"iana"},"audio/eac3":{"source":"iana"},"audio/encaprtp":{"source":"iana"},"audio/evrc":{"source":"iana"},"audio/evrc-qcp":{"source":"iana"},"audio/evrc0":{"source":"iana"},"audio/evrc1":{"source":"iana"},"audio/evrcb":{"source":"iana"},"audio/evrcb0":{"source":"iana"},"audio/evrcb1":{"source":"iana"},"audio/evrcnw":{"source":"iana"},"audio/evrcnw0":{"source":"iana"},"audio/evrcnw1":{"source":"iana"},"audio/evrcwb":{"source":"iana"},"audio/evrcwb0":{"source":"iana"},"audio/evrcwb1":{"source":"iana"},"audio/evs":{"source":"iana"},"audio/flexfec":{"source":"iana"},"audio/fwdred":{"source":"iana"},"audio/g711-0":{"source":"iana"},"audio/g719":{"source":"iana"},"audio/g722":{"source":"iana"},"audio/g7221":{"source":"iana"},"audio/g723":{"source":"iana"},"audio/g726-16":{"source":"iana"},"audio/g726-24":{"source":"iana"},"audio/g726-32":{"source":"iana"},"audio/g726-40":{"source":"iana"},"audio/g728":{"source":"iana"},"audio/g729":{"source":"iana"},"audio/g7291":{"source":"iana"},"audio/g729d":{"source":"iana"},"audio/g729e":{"source":"iana"},"audio/gsm":{"source":"iana"},"audio/gsm-efr":{"source":"iana"},"audio/gsm-hr-08":{"source":"iana"},"audio/ilbc":{"source":"iana"},"audio/ip-mr_v2.5":{"source":"iana"},"audio/isac":{"source":"apache"},"audio/l16":{"source":"iana"},"audio/l20":{"source":"iana"},"audio/l24":{"source":"iana","compressible":false},"audio/l8":{"source":"iana"},"audio/lpc":{"source":"iana"},"audio/melp":{"source":"iana"},"audio/melp1200":{"source":"iana"},"audio/melp2400":{"source":"iana"},"audio/melp600":{"source":"iana"},"audio/midi":{"source":"apache","extensions":["mid","midi","kar","rmi"]},"audio/mobile-xmf":{"source":"iana","extensions":["mxmf"]},"audio/mp3":{"compressible":false,"extensions":["mp3"]},"audio/mp4":{"source":"iana","compressible":false,"extensions":["m4a","mp4a"]},"audio/mp4a-latm":{"source":"iana"},"audio/mpa":{"source":"iana"},"audio/mpa-robust":{"source":"iana"},"audio/mpeg":{"source":"iana","compressible":false,"extensions":["mpga","mp2","mp2a","mp3","m2a","m3a"]},"audio/mpeg4-generic":{"source":"iana"},"audio/musepack":{"source":"apache"},"audio/ogg":{"source":"iana","compressible":false,"extensions":["oga","ogg","spx"]},"audio/opus":{"source":"iana"},"audio/parityfec":{"source":"iana"},"audio/pcma":{"source":"iana"},"audio/pcma-wb":{"source":"iana"},"audio/pcmu":{"source":"iana"},"audio/pcmu-wb":{"source":"iana"},"audio/prs.sid":{"source":"iana"},"audio/qcelp":{"source":"iana"},"audio/raptorfec":{"source":"iana"},"audio/red":{"source":"iana"},"audio/rtp-enc-aescm128":{"source":"iana"},"audio/rtp-midi":{"source":"iana"},"audio/rtploopback":{"source":"iana"},"audio/rtx":{"source":"iana"},"audio/s3m":{"source":"apache","extensions":["s3m"]},"audio/silk":{"source":"apache","extensions":["sil"]},"audio/smv":{"source":"iana"},"audio/smv-qcp":{"source":"iana"},"audio/smv0":{"source":"iana"},"audio/sp-midi":{"source":"iana"},"audio/speex":{"source":"iana"},"audio/t140c":{"source":"iana"},"audio/t38":{"source":"iana"},"audio/telephone-event":{"source":"iana"},"audio/tetra_acelp":{"source":"iana"},"audio/tone":{"source":"iana"},"audio/uemclip":{"source":"iana"},"audio/ulpfec":{"source":"iana"},"audio/usac":{"source":"iana"},"audio/vdvi":{"source":"iana"},"audio/vmr-wb":{"source":"iana"},"audio/vnd.3gpp.iufp":{"source":"iana"},"audio/vnd.4sb":{"source":"iana"},"audio/vnd.audiokoz":{"source":"iana"},"audio/vnd.celp":{"source":"iana"},"audio/vnd.cisco.nse":{"source":"iana"},"audio/vnd.cmles.radio-events":{"source":"iana"},"audio/vnd.cns.anp1":{"source":"iana"},"audio/vnd.cns.inf1":{"source":"iana"},"audio/vnd.dece.audio":{"source":"iana","extensions":["uva","uvva"]},"audio/vnd.digital-winds":{"source":"iana","extensions":["eol"]},"audio/vnd.dlna.adts":{"source":"iana"},"audio/vnd.dolby.heaac.1":{"source":"iana"},"audio/vnd.dolby.heaac.2":{"source":"iana"},"audio/vnd.dolby.mlp":{"source":"iana"},"audio/vnd.dolby.mps":{"source":"iana"},"audio/vnd.dolby.pl2":{"source":"iana"},"audio/vnd.dolby.pl2x":{"source":"iana"},"audio/vnd.dolby.pl2z":{"source":"iana"},"audio/vnd.dolby.pulse.1":{"source":"iana"},"audio/vnd.dra":{"source":"iana","extensions":["dra"]},"audio/vnd.dts":{"source":"iana","extensions":["dts"]},"audio/vnd.dts.hd":{"source":"iana","extensions":["dtshd"]},"audio/vnd.dts.uhd":{"source":"iana"},"audio/vnd.dvb.file":{"source":"iana"},"audio/vnd.everad.plj":{"source":"iana"},"audio/vnd.hns.audio":{"source":"iana"},"audio/vnd.lucent.voice":{"source":"iana","extensions":["lvp"]},"audio/vnd.ms-playready.media.pya":{"source":"iana","extensions":["pya"]},"audio/vnd.nokia.mobile-xmf":{"source":"iana"},"audio/vnd.nortel.vbk":{"source":"iana"},"audio/vnd.nuera.ecelp4800":{"source":"iana","extensions":["ecelp4800"]},"audio/vnd.nuera.ecelp7470":{"source":"iana","extensions":["ecelp7470"]},"audio/vnd.nuera.ecelp9600":{"source":"iana","extensions":["ecelp9600"]},"audio/vnd.octel.sbc":{"source":"iana"},"audio/vnd.presonus.multitrack":{"source":"iana"},"audio/vnd.qcelp":{"source":"iana"},"audio/vnd.rhetorex.32kadpcm":{"source":"iana"},"audio/vnd.rip":{"source":"iana","extensions":["rip"]},"audio/vnd.rn-realaudio":{"compressible":false},"audio/vnd.sealedmedia.softseal.mpeg":{"source":"iana"},"audio/vnd.vmx.cvsd":{"source":"iana"},"audio/vnd.wave":{"compressible":false},"audio/vorbis":{"source":"iana","compressible":false},"audio/vorbis-config":{"source":"iana"},"audio/wav":{"compressible":false,"extensions":["wav"]},"audio/wave":{"compressible":false,"extensions":["wav"]},"audio/webm":{"source":"apache","compressible":false,"extensions":["weba"]},"audio/x-aac":{"source":"apache","compressible":false,"extensions":["aac"]},"audio/x-aiff":{"source":"apache","extensions":["aif","aiff","aifc"]},"audio/x-caf":{"source":"apache","compressible":false,"extensions":["caf"]},"audio/x-flac":{"source":"apache","extensions":["flac"]},"audio/x-m4a":{"source":"nginx","extensions":["m4a"]},"audio/x-matroska":{"source":"apache","extensions":["mka"]},"audio/x-mpegurl":{"source":"apache","extensions":["m3u"]},"audio/x-ms-wax":{"source":"apache","extensions":["wax"]},"audio/x-ms-wma":{"source":"apache","extensions":["wma"]},"audio/x-pn-realaudio":{"source":"apache","extensions":["ram","ra"]},"audio/x-pn-realaudio-plugin":{"source":"apache","extensions":["rmp"]},"audio/x-realaudio":{"source":"nginx","extensions":["ra"]},"audio/x-tta":{"source":"apache"},"audio/x-wav":{"source":"apache","extensions":["wav"]},"audio/xm":{"source":"apache","extensions":["xm"]},"chemical/x-cdx":{"source":"apache","extensions":["cdx"]},"chemical/x-cif":{"source":"apache","extensions":["cif"]},"chemical/x-cmdf":{"source":"apache","extensions":["cmdf"]},"chemical/x-cml":{"source":"apache","extensions":["cml"]},"chemical/x-csml":{"source":"apache","extensions":["csml"]},"chemical/x-pdb":{"source":"apache"},"chemical/x-xyz":{"source":"apache","extensions":["xyz"]},"font/collection":{"source":"iana","extensions":["ttc"]},"font/otf":{"source":"iana","compressible":true,"extensions":["otf"]},"font/sfnt":{"source":"iana"},"font/ttf":{"source":"iana","compressible":true,"extensions":["ttf"]},"font/woff":{"source":"iana","extensions":["woff"]},"font/woff2":{"source":"iana","extensions":["woff2"]},"image/aces":{"source":"iana","extensions":["exr"]},"image/apng":{"compressible":false,"extensions":["apng"]},"image/avci":{"source":"iana"},"image/avcs":{"source":"iana"},"image/bmp":{"source":"iana","compressible":true,"extensions":["bmp"]},"image/cgm":{"source":"iana","extensions":["cgm"]},"image/dicom-rle":{"source":"iana","extensions":["drle"]},"image/emf":{"source":"iana","extensions":["emf"]},"image/fits":{"source":"iana","extensions":["fits"]},"image/g3fax":{"source":"iana","extensions":["g3"]},"image/gif":{"source":"iana","compressible":false,"extensions":["gif"]},"image/heic":{"source":"iana","extensions":["heic"]},"image/heic-sequence":{"source":"iana","extensions":["heics"]},"image/heif":{"source":"iana","extensions":["heif"]},"image/heif-sequence":{"source":"iana","extensions":["heifs"]},"image/hej2k":{"source":"iana","extensions":["hej2"]},"image/hsj2":{"source":"iana","extensions":["hsj2"]},"image/ief":{"source":"iana","extensions":["ief"]},"image/jls":{"source":"iana","extensions":["jls"]},"image/jp2":{"source":"iana","compressible":false,"extensions":["jp2","jpg2"]},"image/jpeg":{"source":"iana","compressible":false,"extensions":["jpeg","jpg","jpe"]},"image/jph":{"source":"iana","extensions":["jph"]},"image/jphc":{"source":"iana","extensions":["jhc"]},"image/jpm":{"source":"iana","compressible":false,"extensions":["jpm"]},"image/jpx":{"source":"iana","compressible":false,"extensions":["jpx","jpf"]},"image/jxr":{"source":"iana","extensions":["jxr"]},"image/jxra":{"source":"iana","extensions":["jxra"]},"image/jxrs":{"source":"iana","extensions":["jxrs"]},"image/jxs":{"source":"iana","extensions":["jxs"]},"image/jxsc":{"source":"iana","extensions":["jxsc"]},"image/jxsi":{"source":"iana","extensions":["jxsi"]},"image/jxss":{"source":"iana","extensions":["jxss"]},"image/ktx":{"source":"iana","extensions":["ktx"]},"image/naplps":{"source":"iana"},"image/pjpeg":{"compressible":false},"image/png":{"source":"iana","compressible":false,"extensions":["png"]},"image/prs.btif":{"source":"iana","extensions":["btif"]},"image/prs.pti":{"source":"iana","extensions":["pti"]},"image/pwg-raster":{"source":"iana"},"image/sgi":{"source":"apache","extensions":["sgi"]},"image/svg+xml":{"source":"iana","compressible":true,"extensions":["svg","svgz"]},"image/t38":{"source":"iana","extensions":["t38"]},"image/tiff":{"source":"iana","compressible":false,"extensions":["tif","tiff"]},"image/tiff-fx":{"source":"iana","extensions":["tfx"]},"image/vnd.adobe.photoshop":{"source":"iana","compressible":true,"extensions":["psd"]},"image/vnd.airzip.accelerator.azv":{"source":"iana","extensions":["azv"]},"image/vnd.cns.inf2":{"source":"iana"},"image/vnd.dece.graphic":{"source":"iana","extensions":["uvi","uvvi","uvg","uvvg"]},"image/vnd.djvu":{"source":"iana","extensions":["djvu","djv"]},"image/vnd.dvb.subtitle":{"source":"iana","extensions":["sub"]},"image/vnd.dwg":{"source":"iana","extensions":["dwg"]},"image/vnd.dxf":{"source":"iana","extensions":["dxf"]},"image/vnd.fastbidsheet":{"source":"iana","extensions":["fbs"]},"image/vnd.fpx":{"source":"iana","extensions":["fpx"]},"image/vnd.fst":{"source":"iana","extensions":["fst"]},"image/vnd.fujixerox.edmics-mmr":{"source":"iana","extensions":["mmr"]},"image/vnd.fujixerox.edmics-rlc":{"source":"iana","extensions":["rlc"]},"image/vnd.globalgraphics.pgb":{"source":"iana"},"image/vnd.microsoft.icon":{"source":"iana","extensions":["ico"]},"image/vnd.mix":{"source":"iana"},"image/vnd.mozilla.apng":{"source":"iana"},"image/vnd.ms-dds":{"extensions":["dds"]},"image/vnd.ms-modi":{"source":"iana","extensions":["mdi"]},"image/vnd.ms-photo":{"source":"apache","extensions":["wdp"]},"image/vnd.net-fpx":{"source":"iana","extensions":["npx"]},"image/vnd.radiance":{"source":"iana"},"image/vnd.sealed.png":{"source":"iana"},"image/vnd.sealedmedia.softseal.gif":{"source":"iana"},"image/vnd.sealedmedia.softseal.jpg":{"source":"iana"},"image/vnd.svf":{"source":"iana"},"image/vnd.tencent.tap":{"source":"iana","extensions":["tap"]},"image/vnd.valve.source.texture":{"source":"iana","extensions":["vtf"]},"image/vnd.wap.wbmp":{"source":"iana","extensions":["wbmp"]},"image/vnd.xiff":{"source":"iana","extensions":["xif"]},"image/vnd.zbrush.pcx":{"source":"iana","extensions":["pcx"]},"image/webp":{"source":"apache","extensions":["webp"]},"image/wmf":{"source":"iana","extensions":["wmf"]},"image/x-3ds":{"source":"apache","extensions":["3ds"]},"image/x-cmu-raster":{"source":"apache","extensions":["ras"]},"image/x-cmx":{"source":"apache","extensions":["cmx"]},"image/x-freehand":{"source":"apache","extensions":["fh","fhc","fh4","fh5","fh7"]},"image/x-icon":{"source":"apache","compressible":true,"extensions":["ico"]},"image/x-jng":{"source":"nginx","extensions":["jng"]},"image/x-mrsid-image":{"source":"apache","extensions":["sid"]},"image/x-ms-bmp":{"source":"nginx","compressible":true,"extensions":["bmp"]},"image/x-pcx":{"source":"apache","extensions":["pcx"]},"image/x-pict":{"source":"apache","extensions":["pic","pct"]},"image/x-portable-anymap":{"source":"apache","extensions":["pnm"]},"image/x-portable-bitmap":{"source":"apache","extensions":["pbm"]},"image/x-portable-graymap":{"source":"apache","extensions":["pgm"]},"image/x-portable-pixmap":{"source":"apache","extensions":["ppm"]},"image/x-rgb":{"source":"apache","extensions":["rgb"]},"image/x-tga":{"source":"apache","extensions":["tga"]},"image/x-xbitmap":{"source":"apache","extensions":["xbm"]},"image/x-xcf":{"compressible":false},"image/x-xpixmap":{"source":"apache","extensions":["xpm"]},"image/x-xwindowdump":{"source":"apache","extensions":["xwd"]},"message/cpim":{"source":"iana"},"message/delivery-status":{"source":"iana"},"message/disposition-notification":{"source":"iana","extensions":["disposition-notification"]},"message/external-body":{"source":"iana"},"message/feedback-report":{"source":"iana"},"message/global":{"source":"iana","extensions":["u8msg"]},"message/global-delivery-status":{"source":"iana","extensions":["u8dsn"]},"message/global-disposition-notification":{"source":"iana","extensions":["u8mdn"]},"message/global-headers":{"source":"iana","extensions":["u8hdr"]},"message/http":{"source":"iana","compressible":false},"message/imdn+xml":{"source":"iana","compressible":true},"message/news":{"source":"iana"},"message/partial":{"source":"iana","compressible":false},"message/rfc822":{"source":"iana","compressible":true,"extensions":["eml","mime"]},"message/s-http":{"source":"iana"},"message/sip":{"source":"iana"},"message/sipfrag":{"source":"iana"},"message/tracking-status":{"source":"iana"},"message/vnd.si.simp":{"source":"iana"},"message/vnd.wfa.wsc":{"source":"iana","extensions":["wsc"]},"model/3mf":{"source":"iana","extensions":["3mf"]},"model/gltf+json":{"source":"iana","compressible":true,"extensions":["gltf"]},"model/gltf-binary":{"source":"iana","compressible":true,"extensions":["glb"]},"model/iges":{"source":"iana","compressible":false,"extensions":["igs","iges"]},"model/mesh":{"source":"iana","compressible":false,"extensions":["msh","mesh","silo"]},"model/stl":{"source":"iana","extensions":["stl"]},"model/vnd.collada+xml":{"source":"iana","compressible":true,"extensions":["dae"]},"model/vnd.dwf":{"source":"iana","extensions":["dwf"]},"model/vnd.flatland.3dml":{"source":"iana"},"model/vnd.gdl":{"source":"iana","extensions":["gdl"]},"model/vnd.gs-gdl":{"source":"apache"},"model/vnd.gs.gdl":{"source":"iana"},"model/vnd.gtw":{"source":"iana","extensions":["gtw"]},"model/vnd.moml+xml":{"source":"iana","compressible":true},"model/vnd.mts":{"source":"iana","extensions":["mts"]},"model/vnd.opengex":{"source":"iana","extensions":["ogex"]},"model/vnd.parasolid.transmit.binary":{"source":"iana","extensions":["x_b"]},"model/vnd.parasolid.transmit.text":{"source":"iana","extensions":["x_t"]},"model/vnd.rosette.annotated-data-model":{"source":"iana"},"model/vnd.usdz+zip":{"source":"iana","compressible":false,"extensions":["usdz"]},"model/vnd.valve.source.compiled-map":{"source":"iana","extensions":["bsp"]},"model/vnd.vtu":{"source":"iana","extensions":["vtu"]},"model/vrml":{"source":"iana","compressible":false,"extensions":["wrl","vrml"]},"model/x3d+binary":{"source":"apache","compressible":false,"extensions":["x3db","x3dbz"]},"model/x3d+fastinfoset":{"source":"iana","extensions":["x3db"]},"model/x3d+vrml":{"source":"apache","compressible":false,"extensions":["x3dv","x3dvz"]},"model/x3d+xml":{"source":"iana","compressible":true,"extensions":["x3d","x3dz"]},"model/x3d-vrml":{"source":"iana","extensions":["x3dv"]},"multipart/alternative":{"source":"iana","compressible":false},"multipart/appledouble":{"source":"iana"},"multipart/byteranges":{"source":"iana"},"multipart/digest":{"source":"iana"},"multipart/encrypted":{"source":"iana","compressible":false},"multipart/form-data":{"source":"iana","compressible":false},"multipart/header-set":{"source":"iana"},"multipart/mixed":{"source":"iana"},"multipart/multilingual":{"source":"iana"},"multipart/parallel":{"source":"iana"},"multipart/related":{"source":"iana","compressible":false},"multipart/report":{"source":"iana"},"multipart/signed":{"source":"iana","compressible":false},"multipart/vnd.bint.med-plus":{"source":"iana"},"multipart/voice-message":{"source":"iana"},"multipart/x-mixed-replace":{"source":"iana"},"text/1d-interleaved-parityfec":{"source":"iana"},"text/cache-manifest":{"source":"iana","compressible":true,"extensions":["appcache","manifest"]},"text/calendar":{"source":"iana","extensions":["ics","ifb"]},"text/calender":{"compressible":true},"text/cmd":{"compressible":true},"text/coffeescript":{"extensions":["coffee","litcoffee"]},"text/css":{"source":"iana","charset":"UTF-8","compressible":true,"extensions":["css"]},"text/csv":{"source":"iana","compressible":true,"extensions":["csv"]},"text/csv-schema":{"source":"iana"},"text/directory":{"source":"iana"},"text/dns":{"source":"iana"},"text/ecmascript":{"source":"iana"},"text/encaprtp":{"source":"iana"},"text/enriched":{"source":"iana"},"text/flexfec":{"source":"iana"},"text/fwdred":{"source":"iana"},"text/grammar-ref-list":{"source":"iana"},"text/html":{"source":"iana","compressible":true,"extensions":["html","htm","shtml"]},"text/jade":{"extensions":["jade"]},"text/javascript":{"source":"iana","compressible":true},"text/jcr-cnd":{"source":"iana"},"text/jsx":{"compressible":true,"extensions":["jsx"]},"text/less":{"compressible":true,"extensions":["less"]},"text/markdown":{"source":"iana","compressible":true,"extensions":["markdown","md"]},"text/mathml":{"source":"nginx","extensions":["mml"]},"text/mdx":{"compressible":true,"extensions":["mdx"]},"text/mizar":{"source":"iana"},"text/n3":{"source":"iana","compressible":true,"extensions":["n3"]},"text/parameters":{"source":"iana"},"text/parityfec":{"source":"iana"},"text/plain":{"source":"iana","compressible":true,"extensions":["txt","text","conf","def","list","log","in","ini"]},"text/provenance-notation":{"source":"iana"},"text/prs.fallenstein.rst":{"source":"iana"},"text/prs.lines.tag":{"source":"iana","extensions":["dsc"]},"text/prs.prop.logic":{"source":"iana"},"text/raptorfec":{"source":"iana"},"text/red":{"source":"iana"},"text/rfc822-headers":{"source":"iana"},"text/richtext":{"source":"iana","compressible":true,"extensions":["rtx"]},"text/rtf":{"source":"iana","compressible":true,"extensions":["rtf"]},"text/rtp-enc-aescm128":{"source":"iana"},"text/rtploopback":{"source":"iana"},"text/rtx":{"source":"iana"},"text/sgml":{"source":"iana","extensions":["sgml","sgm"]},"text/shex":{"extensions":["shex"]},"text/slim":{"extensions":["slim","slm"]},"text/strings":{"source":"iana"},"text/stylus":{"extensions":["stylus","styl"]},"text/t140":{"source":"iana"},"text/tab-separated-values":{"source":"iana","compressible":true,"extensions":["tsv"]},"text/troff":{"source":"iana","extensions":["t","tr","roff","man","me","ms"]},"text/turtle":{"source":"iana","charset":"UTF-8","extensions":["ttl"]},"text/ulpfec":{"source":"iana"},"text/uri-list":{"source":"iana","compressible":true,"extensions":["uri","uris","urls"]},"text/vcard":{"source":"iana","compressible":true,"extensions":["vcard"]},"text/vnd.a":{"source":"iana"},"text/vnd.abc":{"source":"iana"},"text/vnd.ascii-art":{"source":"iana"},"text/vnd.curl":{"source":"iana","extensions":["curl"]},"text/vnd.curl.dcurl":{"source":"apache","extensions":["dcurl"]},"text/vnd.curl.mcurl":{"source":"apache","extensions":["mcurl"]},"text/vnd.curl.scurl":{"source":"apache","extensions":["scurl"]},"text/vnd.debian.copyright":{"source":"iana"},"text/vnd.dmclientscript":{"source":"iana"},"text/vnd.dvb.subtitle":{"source":"iana","extensions":["sub"]},"text/vnd.esmertec.theme-descriptor":{"source":"iana"},"text/vnd.ficlab.flt":{"source":"iana"},"text/vnd.fly":{"source":"iana","extensions":["fly"]},"text/vnd.fmi.flexstor":{"source":"iana","extensions":["flx"]},"text/vnd.gml":{"source":"iana"},"text/vnd.graphviz":{"source":"iana","extensions":["gv"]},"text/vnd.hgl":{"source":"iana"},"text/vnd.in3d.3dml":{"source":"iana","extensions":["3dml"]},"text/vnd.in3d.spot":{"source":"iana","extensions":["spot"]},"text/vnd.iptc.newsml":{"source":"iana"},"text/vnd.iptc.nitf":{"source":"iana"},"text/vnd.latex-z":{"source":"iana"},"text/vnd.motorola.reflex":{"source":"iana"},"text/vnd.ms-mediapackage":{"source":"iana"},"text/vnd.net2phone.commcenter.command":{"source":"iana"},"text/vnd.radisys.msml-basic-layout":{"source":"iana"},"text/vnd.senx.warpscript":{"source":"iana"},"text/vnd.si.uricatalogue":{"source":"iana"},"text/vnd.sosi":{"source":"iana"},"text/vnd.sun.j2me.app-descriptor":{"source":"iana","extensions":["jad"]},"text/vnd.trolltech.linguist":{"source":"iana"},"text/vnd.wap.si":{"source":"iana"},"text/vnd.wap.sl":{"source":"iana"},"text/vnd.wap.wml":{"source":"iana","extensions":["wml"]},"text/vnd.wap.wmlscript":{"source":"iana","extensions":["wmls"]},"text/vtt":{"source":"iana","charset":"UTF-8","compressible":true,"extensions":["vtt"]},"text/x-asm":{"source":"apache","extensions":["s","asm"]},"text/x-c":{"source":"apache","extensions":["c","cc","cxx","cpp","h","hh","dic"]},"text/x-component":{"source":"nginx","extensions":["htc"]},"text/x-fortran":{"source":"apache","extensions":["f","for","f77","f90"]},"text/x-gwt-rpc":{"compressible":true},"text/x-handlebars-template":{"extensions":["hbs"]},"text/x-java-source":{"source":"apache","extensions":["java"]},"text/x-jquery-tmpl":{"compressible":true},"text/x-lua":{"extensions":["lua"]},"text/x-markdown":{"compressible":true,"extensions":["mkd"]},"text/x-nfo":{"source":"apache","extensions":["nfo"]},"text/x-opml":{"source":"apache","extensions":["opml"]},"text/x-org":{"compressible":true,"extensions":["org"]},"text/x-pascal":{"source":"apache","extensions":["p","pas"]},"text/x-processing":{"compressible":true,"extensions":["pde"]},"text/x-sass":{"extensions":["sass"]},"text/x-scss":{"extensions":["scss"]},"text/x-setext":{"source":"apache","extensions":["etx"]},"text/x-sfv":{"source":"apache","extensions":["sfv"]},"text/x-suse-ymp":{"compressible":true,"extensions":["ymp"]},"text/x-uuencode":{"source":"apache","extensions":["uu"]},"text/x-vcalendar":{"source":"apache","extensions":["vcs"]},"text/x-vcard":{"source":"apache","extensions":["vcf"]},"text/xml":{"source":"iana","compressible":true,"extensions":["xml"]},"text/xml-external-parsed-entity":{"source":"iana"},"text/yaml":{"extensions":["yaml","yml"]},"video/1d-interleaved-parityfec":{"source":"iana"},"video/3gpp":{"source":"iana","extensions":["3gp","3gpp"]},"video/3gpp-tt":{"source":"iana"},"video/3gpp2":{"source":"iana","extensions":["3g2"]},"video/bmpeg":{"source":"iana"},"video/bt656":{"source":"iana"},"video/celb":{"source":"iana"},"video/dv":{"source":"iana"},"video/encaprtp":{"source":"iana"},"video/flexfec":{"source":"iana"},"video/h261":{"source":"iana","extensions":["h261"]},"video/h263":{"source":"iana","extensions":["h263"]},"video/h263-1998":{"source":"iana"},"video/h263-2000":{"source":"iana"},"video/h264":{"source":"iana","extensions":["h264"]},"video/h264-rcdo":{"source":"iana"},"video/h264-svc":{"source":"iana"},"video/h265":{"source":"iana"},"video/iso.segment":{"source":"iana"},"video/jpeg":{"source":"iana","extensions":["jpgv"]},"video/jpeg2000":{"source":"iana"},"video/jpm":{"source":"apache","extensions":["jpm","jpgm"]},"video/mj2":{"source":"iana","extensions":["mj2","mjp2"]},"video/mp1s":{"source":"iana"},"video/mp2p":{"source":"iana"},"video/mp2t":{"source":"iana","extensions":["ts"]},"video/mp4":{"source":"iana","compressible":false,"extensions":["mp4","mp4v","mpg4"]},"video/mp4v-es":{"source":"iana"},"video/mpeg":{"source":"iana","compressible":false,"extensions":["mpeg","mpg","mpe","m1v","m2v"]},"video/mpeg4-generic":{"source":"iana"},"video/mpv":{"source":"iana"},"video/nv":{"source":"iana"},"video/ogg":{"source":"iana","compressible":false,"extensions":["ogv"]},"video/parityfec":{"source":"iana"},"video/pointer":{"source":"iana"},"video/quicktime":{"source":"iana","compressible":false,"extensions":["qt","mov"]},"video/raptorfec":{"source":"iana"},"video/raw":{"source":"iana"},"video/rtp-enc-aescm128":{"source":"iana"},"video/rtploopback":{"source":"iana"},"video/rtx":{"source":"iana"},"video/smpte291":{"source":"iana"},"video/smpte292m":{"source":"iana"},"video/ulpfec":{"source":"iana"},"video/vc1":{"source":"iana"},"video/vc2":{"source":"iana"},"video/vnd.cctv":{"source":"iana"},"video/vnd.dece.hd":{"source":"iana","extensions":["uvh","uvvh"]},"video/vnd.dece.mobile":{"source":"iana","extensions":["uvm","uvvm"]},"video/vnd.dece.mp4":{"source":"iana"},"video/vnd.dece.pd":{"source":"iana","extensions":["uvp","uvvp"]},"video/vnd.dece.sd":{"source":"iana","extensions":["uvs","uvvs"]},"video/vnd.dece.video":{"source":"iana","extensions":["uvv","uvvv"]},"video/vnd.directv.mpeg":{"source":"iana"},"video/vnd.directv.mpeg-tts":{"source":"iana"},"video/vnd.dlna.mpeg-tts":{"source":"iana"},"video/vnd.dvb.file":{"source":"iana","extensions":["dvb"]},"video/vnd.fvt":{"source":"iana","extensions":["fvt"]},"video/vnd.hns.video":{"source":"iana"},"video/vnd.iptvforum.1dparityfec-1010":{"source":"iana"},"video/vnd.iptvforum.1dparityfec-2005":{"source":"iana"},"video/vnd.iptvforum.2dparityfec-1010":{"source":"iana"},"video/vnd.iptvforum.2dparityfec-2005":{"source":"iana"},"video/vnd.iptvforum.ttsavc":{"source":"iana"},"video/vnd.iptvforum.ttsmpeg2":{"source":"iana"},"video/vnd.motorola.video":{"source":"iana"},"video/vnd.motorola.videop":{"source":"iana"},"video/vnd.mpegurl":{"source":"iana","extensions":["mxu","m4u"]},"video/vnd.ms-playready.media.pyv":{"source":"iana","extensions":["pyv"]},"video/vnd.nokia.interleaved-multimedia":{"source":"iana"},"video/vnd.nokia.mp4vr":{"source":"iana"},"video/vnd.nokia.videovoip":{"source":"iana"},"video/vnd.objectvideo":{"source":"iana"},"video/vnd.radgamettools.bink":{"source":"iana"},"video/vnd.radgamettools.smacker":{"source":"iana"},"video/vnd.sealed.mpeg1":{"source":"iana"},"video/vnd.sealed.mpeg4":{"source":"iana"},"video/vnd.sealed.swf":{"source":"iana"},"video/vnd.sealedmedia.softseal.mov":{"source":"iana"},"video/vnd.uvvu.mp4":{"source":"iana","extensions":["uvu","uvvu"]},"video/vnd.vivo":{"source":"iana","extensions":["viv"]},"video/vnd.youtube.yt":{"source":"iana"},"video/vp8":{"source":"iana"},"video/webm":{"source":"apache","compressible":false,"extensions":["webm"]},"video/x-f4v":{"source":"apache","extensions":["f4v"]},"video/x-fli":{"source":"apache","extensions":["fli"]},"video/x-flv":{"source":"apache","compressible":false,"extensions":["flv"]},"video/x-m4v":{"source":"apache","extensions":["m4v"]},"video/x-matroska":{"source":"apache","compressible":false,"extensions":["mkv","mk3d","mks"]},"video/x-mng":{"source":"apache","extensions":["mng"]},"video/x-ms-asf":{"source":"apache","extensions":["asf","asx"]},"video/x-ms-vob":{"source":"apache","extensions":["vob"]},"video/x-ms-wm":{"source":"apache","extensions":["wm"]},"video/x-ms-wmv":{"source":"apache","compressible":false,"extensions":["wmv"]},"video/x-ms-wmx":{"source":"apache","extensions":["wmx"]},"video/x-ms-wvx":{"source":"apache","extensions":["wvx"]},"video/x-msvideo":{"source":"apache","extensions":["avi"]},"video/x-sgi-movie":{"source":"apache","extensions":["movie"]},"video/x-smv":{"source":"apache","extensions":["smv"]},"x-conference/x-cooltalk":{"source":"apache","extensions":["ice"]},"x-shader/x-fragment":{"compressible":true},"x-shader/x-vertex":{"compressible":true}};
|
|
|
|
/***/ }),
|
|
|
|
/***/ 517:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
module.exports = function (buf) {
|
|
if (!(buf && buf.length > 1)) {
|
|
return null;
|
|
}
|
|
|
|
if (buf[0] === 0xFF && buf[1] === 0xD8 && buf[2] === 0xFF) {
|
|
return {
|
|
ext: 'jpg',
|
|
mime: 'image/jpeg'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4E && buf[3] === 0x47) {
|
|
return {
|
|
ext: 'png',
|
|
mime: 'image/png'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x47 && buf[1] === 0x49 && buf[2] === 0x46) {
|
|
return {
|
|
ext: 'gif',
|
|
mime: 'image/gif'
|
|
};
|
|
}
|
|
|
|
if (buf[8] === 0x57 && buf[9] === 0x45 && buf[10] === 0x42 && buf[11] === 0x50) {
|
|
return {
|
|
ext: 'webp',
|
|
mime: 'image/webp'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x46 && buf[1] === 0x4C && buf[2] === 0x49 && buf[3] === 0x46) {
|
|
return {
|
|
ext: 'flif',
|
|
mime: 'image/flif'
|
|
};
|
|
}
|
|
|
|
// needs to be before `tif` check
|
|
if (((buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0x2A && buf[3] === 0x0) || (buf[0] === 0x4D && buf[1] === 0x4D && buf[2] === 0x0 && buf[3] === 0x2A)) && buf[8] === 0x43 && buf[9] === 0x52) {
|
|
return {
|
|
ext: 'cr2',
|
|
mime: 'image/x-canon-cr2'
|
|
};
|
|
}
|
|
|
|
if ((buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0x2A && buf[3] === 0x0) || (buf[0] === 0x4D && buf[1] === 0x4D && buf[2] === 0x0 && buf[3] === 0x2A)) {
|
|
return {
|
|
ext: 'tif',
|
|
mime: 'image/tiff'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x42 && buf[1] === 0x4D) {
|
|
return {
|
|
ext: 'bmp',
|
|
mime: 'image/bmp'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0xBC) {
|
|
return {
|
|
ext: 'jxr',
|
|
mime: 'image/vnd.ms-photo'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x38 && buf[1] === 0x42 && buf[2] === 0x50 && buf[3] === 0x53) {
|
|
return {
|
|
ext: 'psd',
|
|
mime: 'image/vnd.adobe.photoshop'
|
|
};
|
|
}
|
|
|
|
// needs to be before `zip` check
|
|
if (buf[0] === 0x50 && buf[1] === 0x4B && buf[2] === 0x3 && buf[3] === 0x4 && buf[30] === 0x6D && buf[31] === 0x69 && buf[32] === 0x6D && buf[33] === 0x65 && buf[34] === 0x74 && buf[35] === 0x79 && buf[36] === 0x70 && buf[37] === 0x65 && buf[38] === 0x61 && buf[39] === 0x70 && buf[40] === 0x70 && buf[41] === 0x6C && buf[42] === 0x69 && buf[43] === 0x63 && buf[44] === 0x61 && buf[45] === 0x74 && buf[46] === 0x69 && buf[47] === 0x6F && buf[48] === 0x6E && buf[49] === 0x2F && buf[50] === 0x65 && buf[51] === 0x70 && buf[52] === 0x75 && buf[53] === 0x62 && buf[54] === 0x2B && buf[55] === 0x7A && buf[56] === 0x69 && buf[57] === 0x70) {
|
|
return {
|
|
ext: 'epub',
|
|
mime: 'application/epub+zip'
|
|
};
|
|
}
|
|
|
|
// needs to be before `zip` check
|
|
// assumes signed .xpi from addons.mozilla.org
|
|
if (buf[0] === 0x50 && buf[1] === 0x4B && buf[2] === 0x3 && buf[3] === 0x4 && buf[30] === 0x4D && buf[31] === 0x45 && buf[32] === 0x54 && buf[33] === 0x41 && buf[34] === 0x2D && buf[35] === 0x49 && buf[36] === 0x4E && buf[37] === 0x46 && buf[38] === 0x2F && buf[39] === 0x6D && buf[40] === 0x6F && buf[41] === 0x7A && buf[42] === 0x69 && buf[43] === 0x6C && buf[44] === 0x6C && buf[45] === 0x61 && buf[46] === 0x2E && buf[47] === 0x72 && buf[48] === 0x73 && buf[49] === 0x61) {
|
|
return {
|
|
ext: 'xpi',
|
|
mime: 'application/x-xpinstall'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x50 && buf[1] === 0x4B && (buf[2] === 0x3 || buf[2] === 0x5 || buf[2] === 0x7) && (buf[3] === 0x4 || buf[3] === 0x6 || buf[3] === 0x8)) {
|
|
return {
|
|
ext: 'zip',
|
|
mime: 'application/zip'
|
|
};
|
|
}
|
|
|
|
if (buf[257] === 0x75 && buf[258] === 0x73 && buf[259] === 0x74 && buf[260] === 0x61 && buf[261] === 0x72) {
|
|
return {
|
|
ext: 'tar',
|
|
mime: 'application/x-tar'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x52 && buf[1] === 0x61 && buf[2] === 0x72 && buf[3] === 0x21 && buf[4] === 0x1A && buf[5] === 0x7 && (buf[6] === 0x0 || buf[6] === 0x1)) {
|
|
return {
|
|
ext: 'rar',
|
|
mime: 'application/x-rar-compressed'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x1F && buf[1] === 0x8B && buf[2] === 0x8) {
|
|
return {
|
|
ext: 'gz',
|
|
mime: 'application/gzip'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x42 && buf[1] === 0x5A && buf[2] === 0x68) {
|
|
return {
|
|
ext: 'bz2',
|
|
mime: 'application/x-bzip2'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x37 && buf[1] === 0x7A && buf[2] === 0xBC && buf[3] === 0xAF && buf[4] === 0x27 && buf[5] === 0x1C) {
|
|
return {
|
|
ext: '7z',
|
|
mime: 'application/x-7z-compressed'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x78 && buf[1] === 0x01) {
|
|
return {
|
|
ext: 'dmg',
|
|
mime: 'application/x-apple-diskimage'
|
|
};
|
|
}
|
|
|
|
if (
|
|
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && (buf[3] === 0x18 || buf[3] === 0x20) && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70) ||
|
|
(buf[0] === 0x33 && buf[1] === 0x67 && buf[2] === 0x70 && buf[3] === 0x35) ||
|
|
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x6D && buf[9] === 0x70 && buf[10] === 0x34 && buf[11] === 0x32 && buf[16] === 0x6D && buf[17] === 0x70 && buf[18] === 0x34 && buf[19] === 0x31 && buf[20] === 0x6D && buf[21] === 0x70 && buf[22] === 0x34 && buf[23] === 0x32 && buf[24] === 0x69 && buf[25] === 0x73 && buf[26] === 0x6F && buf[27] === 0x6D) ||
|
|
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x69 && buf[9] === 0x73 && buf[10] === 0x6F && buf[11] === 0x6D) ||
|
|
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1c && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x6D && buf[9] === 0x70 && buf[10] === 0x34 && buf[11] === 0x32 && buf[12] === 0x0 && buf[13] === 0x0 && buf[14] === 0x0 && buf[15] === 0x0)
|
|
) {
|
|
return {
|
|
ext: 'mp4',
|
|
mime: 'video/mp4'
|
|
};
|
|
}
|
|
|
|
if ((buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x4D && buf[9] === 0x34 && buf[10] === 0x56)) {
|
|
return {
|
|
ext: 'm4v',
|
|
mime: 'video/x-m4v'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x4D && buf[1] === 0x54 && buf[2] === 0x68 && buf[3] === 0x64) {
|
|
return {
|
|
ext: 'mid',
|
|
mime: 'audio/midi'
|
|
};
|
|
}
|
|
|
|
// needs to be before the `webm` check
|
|
if (buf[31] === 0x6D && buf[32] === 0x61 && buf[33] === 0x74 && buf[34] === 0x72 && buf[35] === 0x6f && buf[36] === 0x73 && buf[37] === 0x6B && buf[38] === 0x61) {
|
|
return {
|
|
ext: 'mkv',
|
|
mime: 'video/x-matroska'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x1A && buf[1] === 0x45 && buf[2] === 0xDF && buf[3] === 0xA3) {
|
|
return {
|
|
ext: 'webm',
|
|
mime: 'video/webm'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x14 && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70) {
|
|
return {
|
|
ext: 'mov',
|
|
mime: 'video/quicktime'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x41 && buf[9] === 0x56 && buf[10] === 0x49) {
|
|
return {
|
|
ext: 'avi',
|
|
mime: 'video/x-msvideo'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x30 && buf[1] === 0x26 && buf[2] === 0xB2 && buf[3] === 0x75 && buf[4] === 0x8E && buf[5] === 0x66 && buf[6] === 0xCF && buf[7] === 0x11 && buf[8] === 0xA6 && buf[9] === 0xD9) {
|
|
return {
|
|
ext: 'wmv',
|
|
mime: 'video/x-ms-wmv'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x1 && buf[3].toString(16)[0] === 'b') {
|
|
return {
|
|
ext: 'mpg',
|
|
mime: 'video/mpeg'
|
|
};
|
|
}
|
|
|
|
if ((buf[0] === 0x49 && buf[1] === 0x44 && buf[2] === 0x33) || (buf[0] === 0xFF && buf[1] === 0xfb)) {
|
|
return {
|
|
ext: 'mp3',
|
|
mime: 'audio/mpeg'
|
|
};
|
|
}
|
|
|
|
if ((buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x4D && buf[9] === 0x34 && buf[10] === 0x41) || (buf[0] === 0x4D && buf[1] === 0x34 && buf[2] === 0x41 && buf[3] === 0x20)) {
|
|
return {
|
|
ext: 'm4a',
|
|
mime: 'audio/m4a'
|
|
};
|
|
}
|
|
|
|
// needs to be before `ogg` check
|
|
if (buf[28] === 0x4F && buf[29] === 0x70 && buf[30] === 0x75 && buf[31] === 0x73 && buf[32] === 0x48 && buf[33] === 0x65 && buf[34] === 0x61 && buf[35] === 0x64) {
|
|
return {
|
|
ext: 'opus',
|
|
mime: 'audio/opus'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x4F && buf[1] === 0x67 && buf[2] === 0x67 && buf[3] === 0x53) {
|
|
return {
|
|
ext: 'ogg',
|
|
mime: 'audio/ogg'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x66 && buf[1] === 0x4C && buf[2] === 0x61 && buf[3] === 0x43) {
|
|
return {
|
|
ext: 'flac',
|
|
mime: 'audio/x-flac'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x57 && buf[9] === 0x41 && buf[10] === 0x56 && buf[11] === 0x45) {
|
|
return {
|
|
ext: 'wav',
|
|
mime: 'audio/x-wav'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x23 && buf[1] === 0x21 && buf[2] === 0x41 && buf[3] === 0x4D && buf[4] === 0x52 && buf[5] === 0x0A) {
|
|
return {
|
|
ext: 'amr',
|
|
mime: 'audio/amr'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x25 && buf[1] === 0x50 && buf[2] === 0x44 && buf[3] === 0x46) {
|
|
return {
|
|
ext: 'pdf',
|
|
mime: 'application/pdf'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x4D && buf[1] === 0x5A) {
|
|
return {
|
|
ext: 'exe',
|
|
mime: 'application/x-msdownload'
|
|
};
|
|
}
|
|
|
|
if ((buf[0] === 0x43 || buf[0] === 0x46) && buf[1] === 0x57 && buf[2] === 0x53) {
|
|
return {
|
|
ext: 'swf',
|
|
mime: 'application/x-shockwave-flash'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x7B && buf[1] === 0x5C && buf[2] === 0x72 && buf[3] === 0x74 && buf[4] === 0x66) {
|
|
return {
|
|
ext: 'rtf',
|
|
mime: 'application/rtf'
|
|
};
|
|
}
|
|
|
|
if (
|
|
(buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x46) &&
|
|
(
|
|
(buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) ||
|
|
(buf[4] === 0x4F && buf[5] === 0x54 && buf[6] === 0x54 && buf[7] === 0x4F)
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'woff',
|
|
mime: 'application/font-woff'
|
|
};
|
|
}
|
|
|
|
if (
|
|
(buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x32) &&
|
|
(
|
|
(buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) ||
|
|
(buf[4] === 0x4F && buf[5] === 0x54 && buf[6] === 0x54 && buf[7] === 0x4F)
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'woff2',
|
|
mime: 'application/font-woff'
|
|
};
|
|
}
|
|
|
|
if (
|
|
(buf[34] === 0x4C && buf[35] === 0x50) &&
|
|
(
|
|
(buf[8] === 0x00 && buf[9] === 0x00 && buf[10] === 0x01) ||
|
|
(buf[8] === 0x01 && buf[9] === 0x00 && buf[10] === 0x02) ||
|
|
(buf[8] === 0x02 && buf[9] === 0x00 && buf[10] === 0x02)
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'eot',
|
|
mime: 'application/octet-stream'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x00 && buf[1] === 0x01 && buf[2] === 0x00 && buf[3] === 0x00 && buf[4] === 0x00) {
|
|
return {
|
|
ext: 'ttf',
|
|
mime: 'application/font-sfnt'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x4F && buf[1] === 0x54 && buf[2] === 0x54 && buf[3] === 0x4F && buf[4] === 0x00) {
|
|
return {
|
|
ext: 'otf',
|
|
mime: 'application/font-sfnt'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x00 && buf[1] === 0x00 && buf[2] === 0x01 && buf[3] === 0x00) {
|
|
return {
|
|
ext: 'ico',
|
|
mime: 'image/x-icon'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x46 && buf[1] === 0x4C && buf[2] === 0x56 && buf[3] === 0x01) {
|
|
return {
|
|
ext: 'flv',
|
|
mime: 'video/x-flv'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x25 && buf[1] === 0x21) {
|
|
return {
|
|
ext: 'ps',
|
|
mime: 'application/postscript'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0xFD && buf[1] === 0x37 && buf[2] === 0x7A && buf[3] === 0x58 && buf[4] === 0x5A && buf[5] === 0x00) {
|
|
return {
|
|
ext: 'xz',
|
|
mime: 'application/x-xz'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x53 && buf[1] === 0x51 && buf[2] === 0x4C && buf[3] === 0x69) {
|
|
return {
|
|
ext: 'sqlite',
|
|
mime: 'application/x-sqlite3'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x4E && buf[1] === 0x45 && buf[2] === 0x53 && buf[3] === 0x1A) {
|
|
return {
|
|
ext: 'nes',
|
|
mime: 'application/x-nintendo-nes-rom'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x43 && buf[1] === 0x72 && buf[2] === 0x32 && buf[3] === 0x34) {
|
|
return {
|
|
ext: 'crx',
|
|
mime: 'application/x-google-chrome-extension'
|
|
};
|
|
}
|
|
|
|
if (
|
|
(buf[0] === 0x4D && buf[1] === 0x53 && buf[2] === 0x43 && buf[3] === 0x46) ||
|
|
(buf[0] === 0x49 && buf[1] === 0x53 && buf[2] === 0x63 && buf[3] === 0x28)
|
|
) {
|
|
return {
|
|
ext: 'cab',
|
|
mime: 'application/vnd.ms-cab-compressed'
|
|
};
|
|
}
|
|
|
|
// needs to be before `ar` check
|
|
if (buf[0] === 0x21 && buf[1] === 0x3C && buf[2] === 0x61 && buf[3] === 0x72 && buf[4] === 0x63 && buf[5] === 0x68 && buf[6] === 0x3E && buf[7] === 0x0A && buf[8] === 0x64 && buf[9] === 0x65 && buf[10] === 0x62 && buf[11] === 0x69 && buf[12] === 0x61 && buf[13] === 0x6E && buf[14] === 0x2D && buf[15] === 0x62 && buf[16] === 0x69 && buf[17] === 0x6E && buf[18] === 0x61 && buf[19] === 0x72 && buf[20] === 0x79) {
|
|
return {
|
|
ext: 'deb',
|
|
mime: 'application/x-deb'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x21 && buf[1] === 0x3C && buf[2] === 0x61 && buf[3] === 0x72 && buf[4] === 0x63 && buf[5] === 0x68 && buf[6] === 0x3E) {
|
|
return {
|
|
ext: 'ar',
|
|
mime: 'application/x-unix-archive'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0xED && buf[1] === 0xAB && buf[2] === 0xEE && buf[3] === 0xDB) {
|
|
return {
|
|
ext: 'rpm',
|
|
mime: 'application/x-rpm'
|
|
};
|
|
}
|
|
|
|
if (
|
|
(buf[0] === 0x1F && buf[1] === 0xA0) ||
|
|
(buf[0] === 0x1F && buf[1] === 0x9D)
|
|
) {
|
|
return {
|
|
ext: 'Z',
|
|
mime: 'application/x-compress'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0x4C && buf[1] === 0x5A && buf[2] === 0x49 && buf[3] === 0x50) {
|
|
return {
|
|
ext: 'lz',
|
|
mime: 'application/x-lzip'
|
|
};
|
|
}
|
|
|
|
if (buf[0] === 0xD0 && buf[1] === 0xCF && buf[2] === 0x11 && buf[3] === 0xE0 && buf[4] === 0xA1 && buf[5] === 0xB1 && buf[6] === 0x1A && buf[7] === 0xE1) {
|
|
return {
|
|
ext: 'msi',
|
|
mime: 'application/x-msi'
|
|
};
|
|
}
|
|
|
|
return null;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 519:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
module.exports = __webpack_require__(574).Duplex
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 520:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
module.exports = x => (
|
|
x instanceof Promise ||
|
|
(
|
|
x !== null &&
|
|
typeof x === 'object' &&
|
|
typeof x.then === 'function' &&
|
|
typeof x.catch === 'function'
|
|
)
|
|
);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 525:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
const processFn = (fn, opts) => function () {
|
|
const P = opts.promiseModule;
|
|
const args = new Array(arguments.length);
|
|
|
|
for (let i = 0; i < arguments.length; i++) {
|
|
args[i] = arguments[i];
|
|
}
|
|
|
|
return new P((resolve, reject) => {
|
|
if (opts.errorFirst) {
|
|
args.push(function (err, result) {
|
|
if (opts.multiArgs) {
|
|
const results = new Array(arguments.length - 1);
|
|
|
|
for (let i = 1; i < arguments.length; i++) {
|
|
results[i - 1] = arguments[i];
|
|
}
|
|
|
|
if (err) {
|
|
results.unshift(err);
|
|
reject(results);
|
|
} else {
|
|
resolve(results);
|
|
}
|
|
} else if (err) {
|
|
reject(err);
|
|
} else {
|
|
resolve(result);
|
|
}
|
|
});
|
|
} else {
|
|
args.push(function (result) {
|
|
if (opts.multiArgs) {
|
|
const results = new Array(arguments.length - 1);
|
|
|
|
for (let i = 0; i < arguments.length; i++) {
|
|
results[i] = arguments[i];
|
|
}
|
|
|
|
resolve(results);
|
|
} else {
|
|
resolve(result);
|
|
}
|
|
});
|
|
}
|
|
|
|
fn.apply(this, args);
|
|
});
|
|
};
|
|
|
|
module.exports = (obj, opts) => {
|
|
opts = Object.assign({
|
|
exclude: [/.+(Sync|Stream)$/],
|
|
errorFirst: true,
|
|
promiseModule: Promise
|
|
}, opts);
|
|
|
|
const filter = key => {
|
|
const match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key);
|
|
return opts.include ? opts.include.some(match) : !opts.exclude.some(match);
|
|
};
|
|
|
|
let ret;
|
|
if (typeof obj === 'function') {
|
|
ret = function () {
|
|
if (opts.excludeMain) {
|
|
return obj.apply(this, arguments);
|
|
}
|
|
|
|
return processFn(obj, opts).apply(this, arguments);
|
|
};
|
|
} else {
|
|
ret = Object.create(Object.getPrototypeOf(obj));
|
|
}
|
|
|
|
for (const key in obj) { // eslint-disable-line guard-for-in
|
|
const x = obj[key];
|
|
ret[key] = typeof x === 'function' && filter(key) ? processFn(x, opts) : x;
|
|
}
|
|
|
|
return ret;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 533:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
result["default"] = mod;
|
|
return result;
|
|
};
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const core = __importStar(__webpack_require__(470));
|
|
const io = __importStar(__webpack_require__(1));
|
|
const fs = __importStar(__webpack_require__(747));
|
|
const os = __importStar(__webpack_require__(87));
|
|
const path = __importStar(__webpack_require__(622));
|
|
const httpm = __importStar(__webpack_require__(539));
|
|
const semver = __importStar(__webpack_require__(280));
|
|
const stream = __importStar(__webpack_require__(413));
|
|
const util = __importStar(__webpack_require__(669));
|
|
const v4_1 = __importDefault(__webpack_require__(826));
|
|
const exec_1 = __webpack_require__(986);
|
|
const assert_1 = __webpack_require__(357);
|
|
const retry_helper_1 = __webpack_require__(979);
|
|
class HTTPError extends Error {
|
|
constructor(httpStatusCode) {
|
|
super(`Unexpected HTTP response: ${httpStatusCode}`);
|
|
this.httpStatusCode = httpStatusCode;
|
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
}
|
|
}
|
|
exports.HTTPError = HTTPError;
|
|
const IS_WINDOWS = process.platform === 'win32';
|
|
const userAgent = 'actions/tool-cache';
|
|
/**
|
|
* Download a tool from an url and stream it into a file
|
|
*
|
|
* @param url url of tool to download
|
|
* @param dest path to download tool
|
|
* @returns path to downloaded tool
|
|
*/
|
|
function downloadTool(url, dest) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
dest = dest || path.join(_getTempDirectory(), v4_1.default());
|
|
yield io.mkdirP(path.dirname(dest));
|
|
core.debug(`Downloading ${url}`);
|
|
core.debug(`Destination ${dest}`);
|
|
const maxAttempts = 3;
|
|
const minSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS', 10);
|
|
const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20);
|
|
const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds);
|
|
return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
|
|
return yield downloadToolAttempt(url, dest || '');
|
|
}), (err) => {
|
|
if (err instanceof HTTPError && err.httpStatusCode) {
|
|
// Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests
|
|
if (err.httpStatusCode < 500 &&
|
|
err.httpStatusCode !== 408 &&
|
|
err.httpStatusCode !== 429) {
|
|
return false;
|
|
}
|
|
}
|
|
// Otherwise retry
|
|
return true;
|
|
});
|
|
});
|
|
}
|
|
exports.downloadTool = downloadTool;
|
|
function downloadToolAttempt(url, dest) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (fs.existsSync(dest)) {
|
|
throw new Error(`Destination file path ${dest} already exists`);
|
|
}
|
|
// Get the response headers
|
|
const http = new httpm.HttpClient(userAgent, [], {
|
|
allowRetries: false
|
|
});
|
|
const response = yield http.get(url);
|
|
if (response.message.statusCode !== 200) {
|
|
const err = new HTTPError(response.message.statusCode);
|
|
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
|
throw err;
|
|
}
|
|
// Download the response body
|
|
const pipeline = util.promisify(stream.pipeline);
|
|
const responseMessageFactory = _getGlobal('TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY', () => response.message);
|
|
const readStream = responseMessageFactory();
|
|
let succeeded = false;
|
|
try {
|
|
yield pipeline(readStream, fs.createWriteStream(dest));
|
|
core.debug('download complete');
|
|
succeeded = true;
|
|
return dest;
|
|
}
|
|
finally {
|
|
// Error, delete dest before retry
|
|
if (!succeeded) {
|
|
core.debug('download failed');
|
|
try {
|
|
yield io.rmRF(dest);
|
|
}
|
|
catch (err) {
|
|
core.debug(`Failed to delete '${dest}'. ${err.message}`);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
/**
|
|
* Extract a .7z file
|
|
*
|
|
* @param file path to the .7z file
|
|
* @param dest destination directory. Optional.
|
|
* @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this
|
|
* problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will
|
|
* gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is
|
|
* bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line
|
|
* interface, it is smaller than the full command line interface, and it does support long paths. At the
|
|
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
|
|
* Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path
|
|
* to 7zr.exe can be pass to this function.
|
|
* @returns path to the destination directory
|
|
*/
|
|
function extract7z(file, dest, _7zPath) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS');
|
|
assert_1.ok(file, 'parameter "file" is required');
|
|
dest = yield _createExtractFolder(dest);
|
|
const originalCwd = process.cwd();
|
|
process.chdir(dest);
|
|
if (_7zPath) {
|
|
try {
|
|
const args = [
|
|
'x',
|
|
'-bb1',
|
|
'-bd',
|
|
'-sccUTF-8',
|
|
file
|
|
];
|
|
const options = {
|
|
silent: true
|
|
};
|
|
yield exec_1.exec(`"${_7zPath}"`, args, options);
|
|
}
|
|
finally {
|
|
process.chdir(originalCwd);
|
|
}
|
|
}
|
|
else {
|
|
const escapedScript = path
|
|
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
|
|
.replace(/'/g, "''")
|
|
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
|
|
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
|
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
|
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
|
|
const args = [
|
|
'-NoLogo',
|
|
'-Sta',
|
|
'-NoProfile',
|
|
'-NonInteractive',
|
|
'-ExecutionPolicy',
|
|
'Unrestricted',
|
|
'-Command',
|
|
command
|
|
];
|
|
const options = {
|
|
silent: true
|
|
};
|
|
try {
|
|
const powershellPath = yield io.which('powershell', true);
|
|
yield exec_1.exec(`"${powershellPath}"`, args, options);
|
|
}
|
|
finally {
|
|
process.chdir(originalCwd);
|
|
}
|
|
}
|
|
return dest;
|
|
});
|
|
}
|
|
exports.extract7z = extract7z;
|
|
/**
|
|
* Extract a compressed tar archive
|
|
*
|
|
* @param file path to the tar
|
|
* @param dest destination directory. Optional.
|
|
* @param flags flags for the tar command to use for extraction. Defaults to 'xz' (extracting gzipped tars). Optional.
|
|
* @returns path to the destination directory
|
|
*/
|
|
function extractTar(file, dest, flags = 'xz') {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (!file) {
|
|
throw new Error("parameter 'file' is required");
|
|
}
|
|
// Create dest
|
|
dest = yield _createExtractFolder(dest);
|
|
// Determine whether GNU tar
|
|
core.debug('Checking tar --version');
|
|
let versionOutput = '';
|
|
yield exec_1.exec('tar --version', [], {
|
|
ignoreReturnCode: true,
|
|
silent: true,
|
|
listeners: {
|
|
stdout: (data) => (versionOutput += data.toString()),
|
|
stderr: (data) => (versionOutput += data.toString())
|
|
}
|
|
});
|
|
core.debug(versionOutput.trim());
|
|
const isGnuTar = versionOutput.toUpperCase().includes('GNU TAR');
|
|
// Initialize args
|
|
const args = [flags];
|
|
let destArg = dest;
|
|
let fileArg = file;
|
|
if (IS_WINDOWS && isGnuTar) {
|
|
args.push('--force-local');
|
|
destArg = dest.replace(/\\/g, '/');
|
|
// Technically only the dest needs to have `/` but for aesthetic consistency
|
|
// convert slashes in the file arg too.
|
|
fileArg = file.replace(/\\/g, '/');
|
|
}
|
|
if (isGnuTar) {
|
|
// Suppress warnings when using GNU tar to extract archives created by BSD tar
|
|
args.push('--warning=no-unknown-keyword');
|
|
}
|
|
args.push('-C', destArg, '-f', fileArg);
|
|
yield exec_1.exec(`tar`, args);
|
|
return dest;
|
|
});
|
|
}
|
|
exports.extractTar = extractTar;
|
|
/**
|
|
* Extract a zip
|
|
*
|
|
* @param file path to the zip
|
|
* @param dest destination directory. Optional.
|
|
* @returns path to the destination directory
|
|
*/
|
|
function extractZip(file, dest) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (!file) {
|
|
throw new Error("parameter 'file' is required");
|
|
}
|
|
dest = yield _createExtractFolder(dest);
|
|
if (IS_WINDOWS) {
|
|
yield extractZipWin(file, dest);
|
|
}
|
|
else {
|
|
yield extractZipNix(file, dest);
|
|
}
|
|
return dest;
|
|
});
|
|
}
|
|
exports.extractZip = extractZip;
|
|
function extractZipWin(file, dest) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
// build the powershell command
|
|
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
|
|
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
|
const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`;
|
|
// run powershell
|
|
const powershellPath = yield io.which('powershell');
|
|
const args = [
|
|
'-NoLogo',
|
|
'-Sta',
|
|
'-NoProfile',
|
|
'-NonInteractive',
|
|
'-ExecutionPolicy',
|
|
'Unrestricted',
|
|
'-Command',
|
|
command
|
|
];
|
|
yield exec_1.exec(`"${powershellPath}"`, args);
|
|
});
|
|
}
|
|
function extractZipNix(file, dest) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const unzipPath = yield io.which('unzip');
|
|
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
|
|
});
|
|
}
|
|
/**
|
|
* Caches a directory and installs it into the tool cacheDir
|
|
*
|
|
* @param sourceDir the directory to cache into tools
|
|
* @param tool tool name
|
|
* @param version version of the tool. semver format
|
|
* @param arch architecture of the tool. Optional. Defaults to machine architecture
|
|
*/
|
|
function cacheDir(sourceDir, tool, version, arch) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
version = semver.clean(version) || version;
|
|
arch = arch || os.arch();
|
|
core.debug(`Caching tool ${tool} ${version} ${arch}`);
|
|
core.debug(`source dir: ${sourceDir}`);
|
|
if (!fs.statSync(sourceDir).isDirectory()) {
|
|
throw new Error('sourceDir is not a directory');
|
|
}
|
|
// Create the tool dir
|
|
const destPath = yield _createToolPath(tool, version, arch);
|
|
// copy each child item. do not move. move can fail on Windows
|
|
// due to anti-virus software having an open handle on a file.
|
|
for (const itemName of fs.readdirSync(sourceDir)) {
|
|
const s = path.join(sourceDir, itemName);
|
|
yield io.cp(s, destPath, { recursive: true });
|
|
}
|
|
// write .complete
|
|
_completeToolPath(tool, version, arch);
|
|
return destPath;
|
|
});
|
|
}
|
|
exports.cacheDir = cacheDir;
|
|
/**
|
|
* Caches a downloaded file (GUID) and installs it
|
|
* into the tool cache with a given targetName
|
|
*
|
|
* @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid.
|
|
* @param targetFile the name of the file name in the tools directory
|
|
* @param tool tool name
|
|
* @param version version of the tool. semver format
|
|
* @param arch architecture of the tool. Optional. Defaults to machine architecture
|
|
*/
|
|
function cacheFile(sourceFile, targetFile, tool, version, arch) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
version = semver.clean(version) || version;
|
|
arch = arch || os.arch();
|
|
core.debug(`Caching tool ${tool} ${version} ${arch}`);
|
|
core.debug(`source file: ${sourceFile}`);
|
|
if (!fs.statSync(sourceFile).isFile()) {
|
|
throw new Error('sourceFile is not a file');
|
|
}
|
|
// create the tool dir
|
|
const destFolder = yield _createToolPath(tool, version, arch);
|
|
// copy instead of move. move can fail on Windows due to
|
|
// anti-virus software having an open handle on a file.
|
|
const destPath = path.join(destFolder, targetFile);
|
|
core.debug(`destination file ${destPath}`);
|
|
yield io.cp(sourceFile, destPath);
|
|
// write .complete
|
|
_completeToolPath(tool, version, arch);
|
|
return destFolder;
|
|
});
|
|
}
|
|
exports.cacheFile = cacheFile;
|
|
/**
|
|
* Finds the path to a tool version in the local installed tool cache
|
|
*
|
|
* @param toolName name of the tool
|
|
* @param versionSpec version of the tool
|
|
* @param arch optional arch. defaults to arch of computer
|
|
*/
|
|
function find(toolName, versionSpec, arch) {
|
|
if (!toolName) {
|
|
throw new Error('toolName parameter is required');
|
|
}
|
|
if (!versionSpec) {
|
|
throw new Error('versionSpec parameter is required');
|
|
}
|
|
arch = arch || os.arch();
|
|
// attempt to resolve an explicit version
|
|
if (!_isExplicitVersion(versionSpec)) {
|
|
const localVersions = findAllVersions(toolName, arch);
|
|
const match = _evaluateVersions(localVersions, versionSpec);
|
|
versionSpec = match;
|
|
}
|
|
// check for the explicit version in the cache
|
|
let toolPath = '';
|
|
if (versionSpec) {
|
|
versionSpec = semver.clean(versionSpec) || '';
|
|
const cachePath = path.join(_getCacheDirectory(), toolName, versionSpec, arch);
|
|
core.debug(`checking cache: ${cachePath}`);
|
|
if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) {
|
|
core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`);
|
|
toolPath = cachePath;
|
|
}
|
|
else {
|
|
core.debug('not found');
|
|
}
|
|
}
|
|
return toolPath;
|
|
}
|
|
exports.find = find;
|
|
/**
|
|
* Finds the paths to all versions of a tool that are installed in the local tool cache
|
|
*
|
|
* @param toolName name of the tool
|
|
* @param arch optional arch. defaults to arch of computer
|
|
*/
|
|
function findAllVersions(toolName, arch) {
|
|
const versions = [];
|
|
arch = arch || os.arch();
|
|
const toolPath = path.join(_getCacheDirectory(), toolName);
|
|
if (fs.existsSync(toolPath)) {
|
|
const children = fs.readdirSync(toolPath);
|
|
for (const child of children) {
|
|
if (_isExplicitVersion(child)) {
|
|
const fullPath = path.join(toolPath, child, arch || '');
|
|
if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) {
|
|
versions.push(child);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return versions;
|
|
}
|
|
exports.findAllVersions = findAllVersions;
|
|
function _createExtractFolder(dest) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (!dest) {
|
|
// create a temp dir
|
|
dest = path.join(_getTempDirectory(), v4_1.default());
|
|
}
|
|
yield io.mkdirP(dest);
|
|
return dest;
|
|
});
|
|
}
|
|
function _createToolPath(tool, version, arch) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || '');
|
|
core.debug(`destination ${folderPath}`);
|
|
const markerPath = `${folderPath}.complete`;
|
|
yield io.rmRF(folderPath);
|
|
yield io.rmRF(markerPath);
|
|
yield io.mkdirP(folderPath);
|
|
return folderPath;
|
|
});
|
|
}
|
|
function _completeToolPath(tool, version, arch) {
|
|
const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || '');
|
|
const markerPath = `${folderPath}.complete`;
|
|
fs.writeFileSync(markerPath, '');
|
|
core.debug('finished caching tool');
|
|
}
|
|
function _isExplicitVersion(versionSpec) {
|
|
const c = semver.clean(versionSpec) || '';
|
|
core.debug(`isExplicit: ${c}`);
|
|
const valid = semver.valid(c) != null;
|
|
core.debug(`explicit? ${valid}`);
|
|
return valid;
|
|
}
|
|
function _evaluateVersions(versions, versionSpec) {
|
|
let version = '';
|
|
core.debug(`evaluating ${versions.length} versions`);
|
|
versions = versions.sort((a, b) => {
|
|
if (semver.gt(a, b)) {
|
|
return 1;
|
|
}
|
|
return -1;
|
|
});
|
|
for (let i = versions.length - 1; i >= 0; i--) {
|
|
const potential = versions[i];
|
|
const satisfied = semver.satisfies(potential, versionSpec);
|
|
if (satisfied) {
|
|
version = potential;
|
|
break;
|
|
}
|
|
}
|
|
if (version) {
|
|
core.debug(`matched: ${version}`);
|
|
}
|
|
else {
|
|
core.debug('match not found');
|
|
}
|
|
return version;
|
|
}
|
|
/**
|
|
* Gets RUNNER_TOOL_CACHE
|
|
*/
|
|
function _getCacheDirectory() {
|
|
const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || '';
|
|
assert_1.ok(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined');
|
|
return cacheDirectory;
|
|
}
|
|
/**
|
|
* Gets RUNNER_TEMP
|
|
*/
|
|
function _getTempDirectory() {
|
|
const tempDirectory = process.env['RUNNER_TEMP'] || '';
|
|
assert_1.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined');
|
|
return tempDirectory;
|
|
}
|
|
/**
|
|
* Gets a global variable
|
|
*/
|
|
function _getGlobal(key, defaultValue) {
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
const value = global[key];
|
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
return value !== undefined ? value : defaultValue;
|
|
}
|
|
//# sourceMappingURL=tool-cache.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 534:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
module.exports = __webpack_require__(747).constants || __webpack_require__(619)
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 538:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var Buffer = __webpack_require__(293).Buffer;
|
|
|
|
var CRC_TABLE = [
|
|
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
|
|
0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
|
|
0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
|
|
0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
|
|
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
|
|
0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
|
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
|
|
0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
|
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
|
|
0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
|
|
0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
|
|
0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
|
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
|
|
0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
|
|
0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
|
|
0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
|
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
|
|
0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
|
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
|
|
0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
|
|
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
|
|
0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
|
|
0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
|
|
0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
|
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
|
|
0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
|
|
0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
|
|
0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
|
|
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
|
|
0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
|
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
|
|
0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
|
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
|
|
0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
|
|
0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
|
|
0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
|
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
|
|
0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
|
|
0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
|
|
0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
|
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
|
|
0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
|
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
|
|
0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
|
|
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
|
|
0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
|
|
0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
|
|
0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
|
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
|
|
0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
|
|
0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
|
|
0x2d02ef8d
|
|
];
|
|
|
|
if (typeof Int32Array !== 'undefined') {
|
|
CRC_TABLE = new Int32Array(CRC_TABLE);
|
|
}
|
|
|
|
function ensureBuffer(input) {
|
|
if (Buffer.isBuffer(input)) {
|
|
return input;
|
|
}
|
|
|
|
var hasNewBufferAPI =
|
|
typeof Buffer.alloc === "function" &&
|
|
typeof Buffer.from === "function";
|
|
|
|
if (typeof input === "number") {
|
|
return hasNewBufferAPI ? Buffer.alloc(input) : new Buffer(input);
|
|
}
|
|
else if (typeof input === "string") {
|
|
return hasNewBufferAPI ? Buffer.from(input) : new Buffer(input);
|
|
}
|
|
else {
|
|
throw new Error("input must be buffer, number, or string, received " +
|
|
typeof input);
|
|
}
|
|
}
|
|
|
|
function bufferizeInt(num) {
|
|
var tmp = ensureBuffer(4);
|
|
tmp.writeInt32BE(num, 0);
|
|
return tmp;
|
|
}
|
|
|
|
function _crc32(buf, previous) {
|
|
buf = ensureBuffer(buf);
|
|
if (Buffer.isBuffer(previous)) {
|
|
previous = previous.readUInt32BE(0);
|
|
}
|
|
var crc = ~~previous ^ -1;
|
|
for (var n = 0; n < buf.length; n++) {
|
|
crc = CRC_TABLE[(crc ^ buf[n]) & 0xff] ^ (crc >>> 8);
|
|
}
|
|
return (crc ^ -1);
|
|
}
|
|
|
|
function crc32() {
|
|
return bufferizeInt(_crc32.apply(null, arguments));
|
|
}
|
|
crc32.signed = function () {
|
|
return _crc32.apply(null, arguments);
|
|
};
|
|
crc32.unsigned = function () {
|
|
return _crc32.apply(null, arguments) >>> 0;
|
|
};
|
|
|
|
module.exports = crc32;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 539:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const url = __webpack_require__(835);
|
|
const http = __webpack_require__(605);
|
|
const https = __webpack_require__(211);
|
|
const pm = __webpack_require__(950);
|
|
let tunnel;
|
|
var HttpCodes;
|
|
(function (HttpCodes) {
|
|
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
|
HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
|
|
HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
|
|
HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
|
|
HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
|
|
HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
|
|
HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
|
|
HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
|
|
HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
|
|
HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
|
|
HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
|
|
HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
|
|
HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
|
|
HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
|
|
HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
|
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
|
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
|
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
|
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
|
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
|
HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));
|
|
var Headers;
|
|
(function (Headers) {
|
|
Headers["Accept"] = "accept";
|
|
Headers["ContentType"] = "content-type";
|
|
})(Headers = exports.Headers || (exports.Headers = {}));
|
|
var MediaTypes;
|
|
(function (MediaTypes) {
|
|
MediaTypes["ApplicationJson"] = "application/json";
|
|
})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}));
|
|
/**
|
|
* Returns the proxy URL, depending upon the supplied url and proxy environment variables.
|
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
|
*/
|
|
function getProxyUrl(serverUrl) {
|
|
let proxyUrl = pm.getProxyUrl(url.parse(serverUrl));
|
|
return proxyUrl ? proxyUrl.href : '';
|
|
}
|
|
exports.getProxyUrl = getProxyUrl;
|
|
const HttpRedirectCodes = [HttpCodes.MovedPermanently, HttpCodes.ResourceMoved, HttpCodes.SeeOther, HttpCodes.TemporaryRedirect, HttpCodes.PermanentRedirect];
|
|
const HttpResponseRetryCodes = [HttpCodes.BadGateway, HttpCodes.ServiceUnavailable, HttpCodes.GatewayTimeout];
|
|
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
|
const ExponentialBackoffCeiling = 10;
|
|
const ExponentialBackoffTimeSlice = 5;
|
|
class HttpClientResponse {
|
|
constructor(message) {
|
|
this.message = message;
|
|
}
|
|
readBody() {
|
|
return new Promise(async (resolve, reject) => {
|
|
let output = Buffer.alloc(0);
|
|
this.message.on('data', (chunk) => {
|
|
output = Buffer.concat([output, chunk]);
|
|
});
|
|
this.message.on('end', () => {
|
|
resolve(output.toString());
|
|
});
|
|
});
|
|
}
|
|
}
|
|
exports.HttpClientResponse = HttpClientResponse;
|
|
function isHttps(requestUrl) {
|
|
let parsedUrl = url.parse(requestUrl);
|
|
return parsedUrl.protocol === 'https:';
|
|
}
|
|
exports.isHttps = isHttps;
|
|
class HttpClient {
|
|
constructor(userAgent, handlers, requestOptions) {
|
|
this._ignoreSslError = false;
|
|
this._allowRedirects = true;
|
|
this._allowRedirectDowngrade = false;
|
|
this._maxRedirects = 50;
|
|
this._allowRetries = false;
|
|
this._maxRetries = 1;
|
|
this._keepAlive = false;
|
|
this._disposed = false;
|
|
this.userAgent = userAgent;
|
|
this.handlers = handlers || [];
|
|
this.requestOptions = requestOptions;
|
|
if (requestOptions) {
|
|
if (requestOptions.ignoreSslError != null) {
|
|
this._ignoreSslError = requestOptions.ignoreSslError;
|
|
}
|
|
this._socketTimeout = requestOptions.socketTimeout;
|
|
if (requestOptions.allowRedirects != null) {
|
|
this._allowRedirects = requestOptions.allowRedirects;
|
|
}
|
|
if (requestOptions.allowRedirectDowngrade != null) {
|
|
this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
|
|
}
|
|
if (requestOptions.maxRedirects != null) {
|
|
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
|
|
}
|
|
if (requestOptions.keepAlive != null) {
|
|
this._keepAlive = requestOptions.keepAlive;
|
|
}
|
|
if (requestOptions.allowRetries != null) {
|
|
this._allowRetries = requestOptions.allowRetries;
|
|
}
|
|
if (requestOptions.maxRetries != null) {
|
|
this._maxRetries = requestOptions.maxRetries;
|
|
}
|
|
}
|
|
}
|
|
options(requestUrl, additionalHeaders) {
|
|
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
|
}
|
|
get(requestUrl, additionalHeaders) {
|
|
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
|
}
|
|
del(requestUrl, additionalHeaders) {
|
|
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
|
}
|
|
post(requestUrl, data, additionalHeaders) {
|
|
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
|
}
|
|
patch(requestUrl, data, additionalHeaders) {
|
|
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
|
}
|
|
put(requestUrl, data, additionalHeaders) {
|
|
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
|
}
|
|
head(requestUrl, additionalHeaders) {
|
|
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
|
}
|
|
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
|
return this.request(verb, requestUrl, stream, additionalHeaders);
|
|
}
|
|
/**
|
|
* Gets a typed object from an endpoint
|
|
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
|
*/
|
|
async getJson(requestUrl, additionalHeaders = {}) {
|
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
let res = await this.get(requestUrl, additionalHeaders);
|
|
return this._processResponse(res, this.requestOptions);
|
|
}
|
|
async postJson(requestUrl, obj, additionalHeaders = {}) {
|
|
let data = JSON.stringify(obj, null, 2);
|
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
let res = await this.post(requestUrl, data, additionalHeaders);
|
|
return this._processResponse(res, this.requestOptions);
|
|
}
|
|
async putJson(requestUrl, obj, additionalHeaders = {}) {
|
|
let data = JSON.stringify(obj, null, 2);
|
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
let res = await this.put(requestUrl, data, additionalHeaders);
|
|
return this._processResponse(res, this.requestOptions);
|
|
}
|
|
async patchJson(requestUrl, obj, additionalHeaders = {}) {
|
|
let data = JSON.stringify(obj, null, 2);
|
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
let res = await this.patch(requestUrl, data, additionalHeaders);
|
|
return this._processResponse(res, this.requestOptions);
|
|
}
|
|
/**
|
|
* Makes a raw http request.
|
|
* All other methods such as get, post, patch, and request ultimately call this.
|
|
* Prefer get, del, post and patch
|
|
*/
|
|
async request(verb, requestUrl, data, headers) {
|
|
if (this._disposed) {
|
|
throw new Error("Client has already been disposed.");
|
|
}
|
|
let parsedUrl = url.parse(requestUrl);
|
|
let info = this._prepareRequest(verb, parsedUrl, headers);
|
|
// Only perform retries on reads since writes may not be idempotent.
|
|
let maxTries = (this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1) ? this._maxRetries + 1 : 1;
|
|
let numTries = 0;
|
|
let response;
|
|
while (numTries < maxTries) {
|
|
response = await this.requestRaw(info, data);
|
|
// Check if it's an authentication challenge
|
|
if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) {
|
|
let authenticationHandler;
|
|
for (let i = 0; i < this.handlers.length; i++) {
|
|
if (this.handlers[i].canHandleAuthentication(response)) {
|
|
authenticationHandler = this.handlers[i];
|
|
break;
|
|
}
|
|
}
|
|
if (authenticationHandler) {
|
|
return authenticationHandler.handleAuthentication(this, info, data);
|
|
}
|
|
else {
|
|
// We have received an unauthorized response but have no handlers to handle it.
|
|
// Let the response return to the caller.
|
|
return response;
|
|
}
|
|
}
|
|
let redirectsRemaining = this._maxRedirects;
|
|
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1
|
|
&& this._allowRedirects
|
|
&& redirectsRemaining > 0) {
|
|
const redirectUrl = response.message.headers["location"];
|
|
if (!redirectUrl) {
|
|
// if there's no location to redirect to, we won't
|
|
break;
|
|
}
|
|
let parsedRedirectUrl = url.parse(redirectUrl);
|
|
if (parsedUrl.protocol == 'https:' && parsedUrl.protocol != parsedRedirectUrl.protocol && !this._allowRedirectDowngrade) {
|
|
throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.");
|
|
}
|
|
// we need to finish reading the response before reassigning response
|
|
// which will leak the open socket.
|
|
await response.readBody();
|
|
// let's make the request with the new redirectUrl
|
|
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
|
response = await this.requestRaw(info, data);
|
|
redirectsRemaining--;
|
|
}
|
|
if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) {
|
|
// If not a retry code, return immediately instead of retrying
|
|
return response;
|
|
}
|
|
numTries += 1;
|
|
if (numTries < maxTries) {
|
|
await response.readBody();
|
|
await this._performExponentialBackoff(numTries);
|
|
}
|
|
}
|
|
return response;
|
|
}
|
|
/**
|
|
* Needs to be called if keepAlive is set to true in request options.
|
|
*/
|
|
dispose() {
|
|
if (this._agent) {
|
|
this._agent.destroy();
|
|
}
|
|
this._disposed = true;
|
|
}
|
|
/**
|
|
* Raw request.
|
|
* @param info
|
|
* @param data
|
|
*/
|
|
requestRaw(info, data) {
|
|
return new Promise((resolve, reject) => {
|
|
let callbackForResult = function (err, res) {
|
|
if (err) {
|
|
reject(err);
|
|
}
|
|
resolve(res);
|
|
};
|
|
this.requestRawWithCallback(info, data, callbackForResult);
|
|
});
|
|
}
|
|
/**
|
|
* Raw request with callback.
|
|
* @param info
|
|
* @param data
|
|
* @param onResult
|
|
*/
|
|
requestRawWithCallback(info, data, onResult) {
|
|
let socket;
|
|
if (typeof (data) === 'string') {
|
|
info.options.headers["Content-Length"] = Buffer.byteLength(data, 'utf8');
|
|
}
|
|
let callbackCalled = false;
|
|
let handleResult = (err, res) => {
|
|
if (!callbackCalled) {
|
|
callbackCalled = true;
|
|
onResult(err, res);
|
|
}
|
|
};
|
|
let req = info.httpModule.request(info.options, (msg) => {
|
|
let res = new HttpClientResponse(msg);
|
|
handleResult(null, res);
|
|
});
|
|
req.on('socket', (sock) => {
|
|
socket = sock;
|
|
});
|
|
// If we ever get disconnected, we want the socket to timeout eventually
|
|
req.setTimeout(this._socketTimeout || 3 * 60000, () => {
|
|
if (socket) {
|
|
socket.end();
|
|
}
|
|
handleResult(new Error('Request timeout: ' + info.options.path), null);
|
|
});
|
|
req.on('error', function (err) {
|
|
// err has statusCode property
|
|
// res should have headers
|
|
handleResult(err, null);
|
|
});
|
|
if (data && typeof (data) === 'string') {
|
|
req.write(data, 'utf8');
|
|
}
|
|
if (data && typeof (data) !== 'string') {
|
|
data.on('close', function () {
|
|
req.end();
|
|
});
|
|
data.pipe(req);
|
|
}
|
|
else {
|
|
req.end();
|
|
}
|
|
}
|
|
/**
|
|
* Gets an http agent. This function is useful when you need an http agent that handles
|
|
* routing through a proxy server - depending upon the url and proxy environment variables.
|
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
|
*/
|
|
getAgent(serverUrl) {
|
|
let parsedUrl = url.parse(serverUrl);
|
|
return this._getAgent(parsedUrl);
|
|
}
|
|
_prepareRequest(method, requestUrl, headers) {
|
|
const info = {};
|
|
info.parsedUrl = requestUrl;
|
|
const usingSsl = info.parsedUrl.protocol === 'https:';
|
|
info.httpModule = usingSsl ? https : http;
|
|
const defaultPort = usingSsl ? 443 : 80;
|
|
info.options = {};
|
|
info.options.host = info.parsedUrl.hostname;
|
|
info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort;
|
|
info.options.path = (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
|
info.options.method = method;
|
|
info.options.headers = this._mergeHeaders(headers);
|
|
if (this.userAgent != null) {
|
|
info.options.headers["user-agent"] = this.userAgent;
|
|
}
|
|
info.options.agent = this._getAgent(info.parsedUrl);
|
|
// gives handlers an opportunity to participate
|
|
if (this.handlers) {
|
|
this.handlers.forEach((handler) => {
|
|
handler.prepareRequest(info.options);
|
|
});
|
|
}
|
|
return info;
|
|
}
|
|
_mergeHeaders(headers) {
|
|
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {});
|
|
if (this.requestOptions && this.requestOptions.headers) {
|
|
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));
|
|
}
|
|
return lowercaseKeys(headers || {});
|
|
}
|
|
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
|
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {});
|
|
let clientHeader;
|
|
if (this.requestOptions && this.requestOptions.headers) {
|
|
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
|
}
|
|
return additionalHeaders[header] || clientHeader || _default;
|
|
}
|
|
_getAgent(parsedUrl) {
|
|
let agent;
|
|
let proxyUrl = pm.getProxyUrl(parsedUrl);
|
|
let useProxy = proxyUrl && proxyUrl.hostname;
|
|
if (this._keepAlive && useProxy) {
|
|
agent = this._proxyAgent;
|
|
}
|
|
if (this._keepAlive && !useProxy) {
|
|
agent = this._agent;
|
|
}
|
|
// if agent is already assigned use that agent.
|
|
if (!!agent) {
|
|
return agent;
|
|
}
|
|
const usingSsl = parsedUrl.protocol === 'https:';
|
|
let maxSockets = 100;
|
|
if (!!this.requestOptions) {
|
|
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
|
}
|
|
if (useProxy) {
|
|
// If using proxy, need tunnel
|
|
if (!tunnel) {
|
|
tunnel = __webpack_require__(856);
|
|
}
|
|
const agentOptions = {
|
|
maxSockets: maxSockets,
|
|
keepAlive: this._keepAlive,
|
|
proxy: {
|
|
proxyAuth: proxyUrl.auth,
|
|
host: proxyUrl.hostname,
|
|
port: proxyUrl.port
|
|
},
|
|
};
|
|
let tunnelAgent;
|
|
const overHttps = proxyUrl.protocol === 'https:';
|
|
if (usingSsl) {
|
|
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
|
|
}
|
|
else {
|
|
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
|
|
}
|
|
agent = tunnelAgent(agentOptions);
|
|
this._proxyAgent = agent;
|
|
}
|
|
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
|
if (this._keepAlive && !agent) {
|
|
const options = { keepAlive: this._keepAlive, maxSockets: maxSockets };
|
|
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
|
this._agent = agent;
|
|
}
|
|
// if not using private agent and tunnel agent isn't setup then use global agent
|
|
if (!agent) {
|
|
agent = usingSsl ? https.globalAgent : http.globalAgent;
|
|
}
|
|
if (usingSsl && this._ignoreSslError) {
|
|
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
|
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
|
// we have to cast it to any and change it directly
|
|
agent.options = Object.assign(agent.options || {}, { rejectUnauthorized: false });
|
|
}
|
|
return agent;
|
|
}
|
|
_performExponentialBackoff(retryNumber) {
|
|
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
|
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
|
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
|
}
|
|
static dateTimeDeserializer(key, value) {
|
|
if (typeof value === 'string') {
|
|
let a = new Date(value);
|
|
if (!isNaN(a.valueOf())) {
|
|
return a;
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
async _processResponse(res, options) {
|
|
return new Promise(async (resolve, reject) => {
|
|
const statusCode = res.message.statusCode;
|
|
const response = {
|
|
statusCode: statusCode,
|
|
result: null,
|
|
headers: {}
|
|
};
|
|
// not found leads to null obj returned
|
|
if (statusCode == HttpCodes.NotFound) {
|
|
resolve(response);
|
|
}
|
|
let obj;
|
|
let contents;
|
|
// get the result from the body
|
|
try {
|
|
contents = await res.readBody();
|
|
if (contents && contents.length > 0) {
|
|
if (options && options.deserializeDates) {
|
|
obj = JSON.parse(contents, HttpClient.dateTimeDeserializer);
|
|
}
|
|
else {
|
|
obj = JSON.parse(contents);
|
|
}
|
|
response.result = obj;
|
|
}
|
|
response.headers = res.message.headers;
|
|
}
|
|
catch (err) {
|
|
// Invalid resource (contents not json); leaving result obj null
|
|
}
|
|
// note that 3xx redirects are handled by the http layer.
|
|
if (statusCode > 299) {
|
|
let msg;
|
|
// if exception/error in body, attempt to get better error
|
|
if (obj && obj.message) {
|
|
msg = obj.message;
|
|
}
|
|
else if (contents && contents.length > 0) {
|
|
// it may be the case that the exception is in the body message as string
|
|
msg = contents;
|
|
}
|
|
else {
|
|
msg = "Failed request: (" + statusCode + ")";
|
|
}
|
|
let err = new Error(msg);
|
|
// attach statusCode and body obj (if available) to the error object
|
|
err['statusCode'] = statusCode;
|
|
if (response.result) {
|
|
err['result'] = response.result;
|
|
}
|
|
reject(err);
|
|
}
|
|
else {
|
|
resolve(response);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
exports.HttpClient = HttpClient;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 547:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const extList = __webpack_require__(944);
|
|
const sortKeysLength = __webpack_require__(210);
|
|
|
|
module.exports = str => {
|
|
const obj = sortKeysLength.desc(extList());
|
|
const exts = Object.keys(obj).filter(x => str.endsWith(x));
|
|
|
|
if (exts.length === 0) {
|
|
return [];
|
|
}
|
|
|
|
return exts.map(x => ({
|
|
ext: x,
|
|
mime: obj[x]
|
|
}));
|
|
};
|
|
|
|
module.exports.mime = str => {
|
|
const obj = sortKeysLength.desc(extList());
|
|
const exts = Object.keys(obj).filter(x => obj[x] === str);
|
|
|
|
if (exts.length === 0) {
|
|
return [];
|
|
}
|
|
|
|
return exts.map(x => ({
|
|
ext: x,
|
|
mime: obj[x]
|
|
}));
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 550:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
const toBytes = s => Array.from(s).map(c => c.charCodeAt(0));
|
|
const xpiZipFilename = toBytes('META-INF/mozilla.rsa');
|
|
const oxmlContentTypes = toBytes('[Content_Types].xml');
|
|
const oxmlRels = toBytes('_rels/.rels');
|
|
|
|
module.exports = input => {
|
|
const buf = new Uint8Array(input);
|
|
|
|
if (!(buf && buf.length > 1)) {
|
|
return null;
|
|
}
|
|
|
|
const check = (header, opts) => {
|
|
opts = Object.assign({
|
|
offset: 0
|
|
}, opts);
|
|
|
|
for (let i = 0; i < header.length; i++) {
|
|
// If a bitmask is set
|
|
if (opts.mask) {
|
|
// If header doesn't equal `buf` with bits masked off
|
|
if (header[i] !== (opts.mask[i] & buf[i + opts.offset])) {
|
|
return false;
|
|
}
|
|
} else if (header[i] !== buf[i + opts.offset]) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
if (check([0xFF, 0xD8, 0xFF])) {
|
|
return {
|
|
ext: 'jpg',
|
|
mime: 'image/jpeg'
|
|
};
|
|
}
|
|
|
|
if (check([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])) {
|
|
return {
|
|
ext: 'png',
|
|
mime: 'image/png'
|
|
};
|
|
}
|
|
|
|
if (check([0x47, 0x49, 0x46])) {
|
|
return {
|
|
ext: 'gif',
|
|
mime: 'image/gif'
|
|
};
|
|
}
|
|
|
|
if (check([0x57, 0x45, 0x42, 0x50], {offset: 8})) {
|
|
return {
|
|
ext: 'webp',
|
|
mime: 'image/webp'
|
|
};
|
|
}
|
|
|
|
if (check([0x46, 0x4C, 0x49, 0x46])) {
|
|
return {
|
|
ext: 'flif',
|
|
mime: 'image/flif'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `tif` check
|
|
if (
|
|
(check([0x49, 0x49, 0x2A, 0x0]) || check([0x4D, 0x4D, 0x0, 0x2A])) &&
|
|
check([0x43, 0x52], {offset: 8})
|
|
) {
|
|
return {
|
|
ext: 'cr2',
|
|
mime: 'image/x-canon-cr2'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x49, 0x49, 0x2A, 0x0]) ||
|
|
check([0x4D, 0x4D, 0x0, 0x2A])
|
|
) {
|
|
return {
|
|
ext: 'tif',
|
|
mime: 'image/tiff'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x4D])) {
|
|
return {
|
|
ext: 'bmp',
|
|
mime: 'image/bmp'
|
|
};
|
|
}
|
|
|
|
if (check([0x49, 0x49, 0xBC])) {
|
|
return {
|
|
ext: 'jxr',
|
|
mime: 'image/vnd.ms-photo'
|
|
};
|
|
}
|
|
|
|
if (check([0x38, 0x42, 0x50, 0x53])) {
|
|
return {
|
|
ext: 'psd',
|
|
mime: 'image/vnd.adobe.photoshop'
|
|
};
|
|
}
|
|
|
|
// Zip-based file formats
|
|
// Need to be before the `zip` check
|
|
if (check([0x50, 0x4B, 0x3, 0x4])) {
|
|
if (
|
|
check([0x6D, 0x69, 0x6D, 0x65, 0x74, 0x79, 0x70, 0x65, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x65, 0x70, 0x75, 0x62, 0x2B, 0x7A, 0x69, 0x70], {offset: 30})
|
|
) {
|
|
return {
|
|
ext: 'epub',
|
|
mime: 'application/epub+zip'
|
|
};
|
|
}
|
|
|
|
// Assumes signed `.xpi` from addons.mozilla.org
|
|
if (check(xpiZipFilename, {offset: 30})) {
|
|
return {
|
|
ext: 'xpi',
|
|
mime: 'application/x-xpinstall'
|
|
};
|
|
}
|
|
|
|
// https://github.com/file/file/blob/master/magic/Magdir/msooxml
|
|
if (check(oxmlContentTypes, {offset: 30}) || check(oxmlRels, {offset: 30})) {
|
|
const sliced = buf.subarray(4, 4 + 2000);
|
|
const nextZipHeaderIndex = arr => arr.findIndex((el, i, arr) => arr[i] === 0x50 && arr[i + 1] === 0x4B && arr[i + 2] === 0x3 && arr[i + 3] === 0x4);
|
|
const header2Pos = nextZipHeaderIndex(sliced);
|
|
|
|
if (header2Pos !== -1) {
|
|
const slicedAgain = buf.subarray(header2Pos + 8, header2Pos + 8 + 1000);
|
|
const header3Pos = nextZipHeaderIndex(slicedAgain);
|
|
|
|
if (header3Pos !== -1) {
|
|
const offset = 8 + header2Pos + header3Pos + 30;
|
|
|
|
if (check(toBytes('word/'), {offset})) {
|
|
return {
|
|
ext: 'docx',
|
|
mime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
|
};
|
|
}
|
|
|
|
if (check(toBytes('ppt/'), {offset})) {
|
|
return {
|
|
ext: 'pptx',
|
|
mime: 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
|
|
};
|
|
}
|
|
|
|
if (check(toBytes('xl/'), {offset})) {
|
|
return {
|
|
ext: 'xlsx',
|
|
mime: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
};
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (
|
|
check([0x50, 0x4B]) &&
|
|
(buf[2] === 0x3 || buf[2] === 0x5 || buf[2] === 0x7) &&
|
|
(buf[3] === 0x4 || buf[3] === 0x6 || buf[3] === 0x8)
|
|
) {
|
|
return {
|
|
ext: 'zip',
|
|
mime: 'application/zip'
|
|
};
|
|
}
|
|
|
|
if (check([0x75, 0x73, 0x74, 0x61, 0x72], {offset: 257})) {
|
|
return {
|
|
ext: 'tar',
|
|
mime: 'application/x-tar'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x52, 0x61, 0x72, 0x21, 0x1A, 0x7]) &&
|
|
(buf[6] === 0x0 || buf[6] === 0x1)
|
|
) {
|
|
return {
|
|
ext: 'rar',
|
|
mime: 'application/x-rar-compressed'
|
|
};
|
|
}
|
|
|
|
if (check([0x1F, 0x8B, 0x8])) {
|
|
return {
|
|
ext: 'gz',
|
|
mime: 'application/gzip'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x5A, 0x68])) {
|
|
return {
|
|
ext: 'bz2',
|
|
mime: 'application/x-bzip2'
|
|
};
|
|
}
|
|
|
|
if (check([0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C])) {
|
|
return {
|
|
ext: '7z',
|
|
mime: 'application/x-7z-compressed'
|
|
};
|
|
}
|
|
|
|
if (check([0x78, 0x01])) {
|
|
return {
|
|
ext: 'dmg',
|
|
mime: 'application/x-apple-diskimage'
|
|
};
|
|
}
|
|
|
|
if (check([0x33, 0x67, 0x70, 0x35]) || // 3gp5
|
|
(
|
|
check([0x0, 0x0, 0x0]) && check([0x66, 0x74, 0x79, 0x70], {offset: 4}) &&
|
|
(
|
|
check([0x6D, 0x70, 0x34, 0x31], {offset: 8}) || // MP41
|
|
check([0x6D, 0x70, 0x34, 0x32], {offset: 8}) || // MP42
|
|
check([0x69, 0x73, 0x6F, 0x6D], {offset: 8}) || // ISOM
|
|
check([0x69, 0x73, 0x6F, 0x32], {offset: 8}) || // ISO2
|
|
check([0x6D, 0x6D, 0x70, 0x34], {offset: 8}) || // MMP4
|
|
check([0x4D, 0x34, 0x56], {offset: 8}) || // M4V
|
|
check([0x64, 0x61, 0x73, 0x68], {offset: 8}) // DASH
|
|
)
|
|
)) {
|
|
return {
|
|
ext: 'mp4',
|
|
mime: 'video/mp4'
|
|
};
|
|
}
|
|
|
|
if (check([0x4D, 0x54, 0x68, 0x64])) {
|
|
return {
|
|
ext: 'mid',
|
|
mime: 'audio/midi'
|
|
};
|
|
}
|
|
|
|
// https://github.com/threatstack/libmagic/blob/master/magic/Magdir/matroska
|
|
if (check([0x1A, 0x45, 0xDF, 0xA3])) {
|
|
const sliced = buf.subarray(4, 4 + 4096);
|
|
const idPos = sliced.findIndex((el, i, arr) => arr[i] === 0x42 && arr[i + 1] === 0x82);
|
|
|
|
if (idPos !== -1) {
|
|
const docTypePos = idPos + 3;
|
|
const findDocType = type => Array.from(type).every((c, i) => sliced[docTypePos + i] === c.charCodeAt(0));
|
|
|
|
if (findDocType('matroska')) {
|
|
return {
|
|
ext: 'mkv',
|
|
mime: 'video/x-matroska'
|
|
};
|
|
}
|
|
|
|
if (findDocType('webm')) {
|
|
return {
|
|
ext: 'webm',
|
|
mime: 'video/webm'
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
if (check([0x0, 0x0, 0x0, 0x14, 0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20]) ||
|
|
check([0x66, 0x72, 0x65, 0x65], {offset: 4}) ||
|
|
check([0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20], {offset: 4}) ||
|
|
check([0x6D, 0x64, 0x61, 0x74], {offset: 4}) || // MJPEG
|
|
check([0x77, 0x69, 0x64, 0x65], {offset: 4})) {
|
|
return {
|
|
ext: 'mov',
|
|
mime: 'video/quicktime'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x52, 0x49, 0x46, 0x46]) &&
|
|
check([0x41, 0x56, 0x49], {offset: 8})
|
|
) {
|
|
return {
|
|
ext: 'avi',
|
|
mime: 'video/x-msvideo'
|
|
};
|
|
}
|
|
|
|
if (check([0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xA6, 0xD9])) {
|
|
return {
|
|
ext: 'wmv',
|
|
mime: 'video/x-ms-wmv'
|
|
};
|
|
}
|
|
|
|
if (check([0x0, 0x0, 0x1, 0xBA])) {
|
|
return {
|
|
ext: 'mpg',
|
|
mime: 'video/mpeg'
|
|
};
|
|
}
|
|
|
|
// Check for MP3 header at different starting offsets
|
|
for (let start = 0; start < 2 && start < (buf.length - 16); start++) {
|
|
if (
|
|
check([0x49, 0x44, 0x33], {offset: start}) || // ID3 header
|
|
check([0xFF, 0xE2], {offset: start, mask: [0xFF, 0xE2]}) // MPEG 1 or 2 Layer 3 header
|
|
) {
|
|
return {
|
|
ext: 'mp3',
|
|
mime: 'audio/mpeg'
|
|
};
|
|
}
|
|
}
|
|
|
|
if (
|
|
check([0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41], {offset: 4}) ||
|
|
check([0x4D, 0x34, 0x41, 0x20])
|
|
) {
|
|
return {
|
|
ext: 'm4a',
|
|
mime: 'audio/m4a'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `ogg` check
|
|
if (check([0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64], {offset: 28})) {
|
|
return {
|
|
ext: 'opus',
|
|
mime: 'audio/opus'
|
|
};
|
|
}
|
|
|
|
if (check([0x4F, 0x67, 0x67, 0x53])) {
|
|
return {
|
|
ext: 'ogg',
|
|
mime: 'audio/ogg'
|
|
};
|
|
}
|
|
|
|
if (check([0x66, 0x4C, 0x61, 0x43])) {
|
|
return {
|
|
ext: 'flac',
|
|
mime: 'audio/x-flac'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x52, 0x49, 0x46, 0x46]) &&
|
|
check([0x57, 0x41, 0x56, 0x45], {offset: 8})
|
|
) {
|
|
return {
|
|
ext: 'wav',
|
|
mime: 'audio/x-wav'
|
|
};
|
|
}
|
|
|
|
if (check([0x23, 0x21, 0x41, 0x4D, 0x52, 0x0A])) {
|
|
return {
|
|
ext: 'amr',
|
|
mime: 'audio/amr'
|
|
};
|
|
}
|
|
|
|
if (check([0x25, 0x50, 0x44, 0x46])) {
|
|
return {
|
|
ext: 'pdf',
|
|
mime: 'application/pdf'
|
|
};
|
|
}
|
|
|
|
if (check([0x4D, 0x5A])) {
|
|
return {
|
|
ext: 'exe',
|
|
mime: 'application/x-msdownload'
|
|
};
|
|
}
|
|
|
|
if (
|
|
(buf[0] === 0x43 || buf[0] === 0x46) &&
|
|
check([0x57, 0x53], {offset: 1})
|
|
) {
|
|
return {
|
|
ext: 'swf',
|
|
mime: 'application/x-shockwave-flash'
|
|
};
|
|
}
|
|
|
|
if (check([0x7B, 0x5C, 0x72, 0x74, 0x66])) {
|
|
return {
|
|
ext: 'rtf',
|
|
mime: 'application/rtf'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x61, 0x73, 0x6D])) {
|
|
return {
|
|
ext: 'wasm',
|
|
mime: 'application/wasm'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x77, 0x4F, 0x46, 0x46]) &&
|
|
(
|
|
check([0x00, 0x01, 0x00, 0x00], {offset: 4}) ||
|
|
check([0x4F, 0x54, 0x54, 0x4F], {offset: 4})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'woff',
|
|
mime: 'font/woff'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x77, 0x4F, 0x46, 0x32]) &&
|
|
(
|
|
check([0x00, 0x01, 0x00, 0x00], {offset: 4}) ||
|
|
check([0x4F, 0x54, 0x54, 0x4F], {offset: 4})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'woff2',
|
|
mime: 'font/woff2'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x4C, 0x50], {offset: 34}) &&
|
|
(
|
|
check([0x00, 0x00, 0x01], {offset: 8}) ||
|
|
check([0x01, 0x00, 0x02], {offset: 8}) ||
|
|
check([0x02, 0x00, 0x02], {offset: 8})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'eot',
|
|
mime: 'application/octet-stream'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x01, 0x00, 0x00, 0x00])) {
|
|
return {
|
|
ext: 'ttf',
|
|
mime: 'font/ttf'
|
|
};
|
|
}
|
|
|
|
if (check([0x4F, 0x54, 0x54, 0x4F, 0x00])) {
|
|
return {
|
|
ext: 'otf',
|
|
mime: 'font/otf'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x00, 0x01, 0x00])) {
|
|
return {
|
|
ext: 'ico',
|
|
mime: 'image/x-icon'
|
|
};
|
|
}
|
|
|
|
if (check([0x46, 0x4C, 0x56, 0x01])) {
|
|
return {
|
|
ext: 'flv',
|
|
mime: 'video/x-flv'
|
|
};
|
|
}
|
|
|
|
if (check([0x25, 0x21])) {
|
|
return {
|
|
ext: 'ps',
|
|
mime: 'application/postscript'
|
|
};
|
|
}
|
|
|
|
if (check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) {
|
|
return {
|
|
ext: 'xz',
|
|
mime: 'application/x-xz'
|
|
};
|
|
}
|
|
|
|
if (check([0x53, 0x51, 0x4C, 0x69])) {
|
|
return {
|
|
ext: 'sqlite',
|
|
mime: 'application/x-sqlite3'
|
|
};
|
|
}
|
|
|
|
if (check([0x4E, 0x45, 0x53, 0x1A])) {
|
|
return {
|
|
ext: 'nes',
|
|
mime: 'application/x-nintendo-nes-rom'
|
|
};
|
|
}
|
|
|
|
if (check([0x43, 0x72, 0x32, 0x34])) {
|
|
return {
|
|
ext: 'crx',
|
|
mime: 'application/x-google-chrome-extension'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x4D, 0x53, 0x43, 0x46]) ||
|
|
check([0x49, 0x53, 0x63, 0x28])
|
|
) {
|
|
return {
|
|
ext: 'cab',
|
|
mime: 'application/vnd.ms-cab-compressed'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `ar` check
|
|
if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E, 0x0A, 0x64, 0x65, 0x62, 0x69, 0x61, 0x6E, 0x2D, 0x62, 0x69, 0x6E, 0x61, 0x72, 0x79])) {
|
|
return {
|
|
ext: 'deb',
|
|
mime: 'application/x-deb'
|
|
};
|
|
}
|
|
|
|
if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E])) {
|
|
return {
|
|
ext: 'ar',
|
|
mime: 'application/x-unix-archive'
|
|
};
|
|
}
|
|
|
|
if (check([0xED, 0xAB, 0xEE, 0xDB])) {
|
|
return {
|
|
ext: 'rpm',
|
|
mime: 'application/x-rpm'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x1F, 0xA0]) ||
|
|
check([0x1F, 0x9D])
|
|
) {
|
|
return {
|
|
ext: 'Z',
|
|
mime: 'application/x-compress'
|
|
};
|
|
}
|
|
|
|
if (check([0x4C, 0x5A, 0x49, 0x50])) {
|
|
return {
|
|
ext: 'lz',
|
|
mime: 'application/x-lzip'
|
|
};
|
|
}
|
|
|
|
if (check([0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1])) {
|
|
return {
|
|
ext: 'msi',
|
|
mime: 'application/x-msi'
|
|
};
|
|
}
|
|
|
|
if (check([0x06, 0x0E, 0x2B, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0D, 0x01, 0x02, 0x01, 0x01, 0x02])) {
|
|
return {
|
|
ext: 'mxf',
|
|
mime: 'application/mxf'
|
|
};
|
|
}
|
|
|
|
if (check([0x47], {offset: 4}) && (check([0x47], {offset: 192}) || check([0x47], {offset: 196}))) {
|
|
return {
|
|
ext: 'mts',
|
|
mime: 'video/mp2t'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x4C, 0x45, 0x4E, 0x44, 0x45, 0x52])) {
|
|
return {
|
|
ext: 'blend',
|
|
mime: 'application/x-blender'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x50, 0x47, 0xFB])) {
|
|
return {
|
|
ext: 'bpg',
|
|
mime: 'image/bpg'
|
|
};
|
|
}
|
|
|
|
return null;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 557:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
class CancelError extends Error {
|
|
constructor() {
|
|
super('Promise was canceled');
|
|
this.name = 'CancelError';
|
|
}
|
|
|
|
get isCanceled() {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
class PCancelable {
|
|
static fn(userFn) {
|
|
return function () {
|
|
const args = [].slice.apply(arguments);
|
|
return new PCancelable((resolve, reject, onCancel) => {
|
|
args.push(onCancel);
|
|
userFn.apply(null, args).then(resolve, reject);
|
|
});
|
|
};
|
|
}
|
|
|
|
constructor(executor) {
|
|
this._cancelHandlers = [];
|
|
this._isPending = true;
|
|
this._isCanceled = false;
|
|
|
|
this._promise = new Promise((resolve, reject) => {
|
|
this._reject = reject;
|
|
|
|
return executor(
|
|
value => {
|
|
this._isPending = false;
|
|
resolve(value);
|
|
},
|
|
error => {
|
|
this._isPending = false;
|
|
reject(error);
|
|
},
|
|
handler => {
|
|
this._cancelHandlers.push(handler);
|
|
}
|
|
);
|
|
});
|
|
}
|
|
|
|
then(onFulfilled, onRejected) {
|
|
return this._promise.then(onFulfilled, onRejected);
|
|
}
|
|
|
|
catch(onRejected) {
|
|
return this._promise.catch(onRejected);
|
|
}
|
|
|
|
finally(onFinally) {
|
|
return this._promise.finally(onFinally);
|
|
}
|
|
|
|
cancel() {
|
|
if (!this._isPending || this._isCanceled) {
|
|
return;
|
|
}
|
|
|
|
if (this._cancelHandlers.length > 0) {
|
|
try {
|
|
for (const handler of this._cancelHandlers) {
|
|
handler();
|
|
}
|
|
} catch (err) {
|
|
this._reject(err);
|
|
}
|
|
}
|
|
|
|
this._isCanceled = true;
|
|
this._reject(new CancelError());
|
|
}
|
|
|
|
get isCanceled() {
|
|
return this._isCanceled;
|
|
}
|
|
}
|
|
|
|
Object.setPrototypeOf(PCancelable.prototype, Promise.prototype);
|
|
|
|
module.exports = PCancelable;
|
|
module.exports.CancelError = CancelError;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 564:
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const util = __webpack_require__(669);
|
|
const toString = Object.prototype.toString;
|
|
const isOfType = (type) => (value) => typeof value === type; // tslint:disable-line:strict-type-predicates
|
|
const getObjectType = (value) => {
|
|
const objectName = toString.call(value).slice(8, -1);
|
|
if (objectName) {
|
|
return objectName;
|
|
}
|
|
return null;
|
|
};
|
|
const isObjectOfType = (typeName) => (value) => {
|
|
return getObjectType(value) === typeName;
|
|
};
|
|
function is(value) {
|
|
if (value === null) {
|
|
return "null" /* null */;
|
|
}
|
|
if (value === true || value === false) {
|
|
return "boolean" /* boolean */;
|
|
}
|
|
const type = typeof value;
|
|
if (type === 'undefined') {
|
|
return "undefined" /* undefined */;
|
|
}
|
|
if (type === 'string') {
|
|
return "string" /* string */;
|
|
}
|
|
if (type === 'number') {
|
|
return "number" /* number */;
|
|
}
|
|
if (type === 'symbol') {
|
|
return "symbol" /* symbol */;
|
|
}
|
|
if (is.function_(value)) {
|
|
return "Function" /* Function */;
|
|
}
|
|
if (Array.isArray(value)) {
|
|
return "Array" /* Array */;
|
|
}
|
|
if (Buffer.isBuffer(value)) {
|
|
return "Buffer" /* Buffer */;
|
|
}
|
|
const tagType = getObjectType(value);
|
|
if (tagType) {
|
|
return tagType;
|
|
}
|
|
if (value instanceof String || value instanceof Boolean || value instanceof Number) {
|
|
throw new TypeError('Please don\'t use object wrappers for primitive types');
|
|
}
|
|
return "Object" /* Object */;
|
|
}
|
|
(function (is) {
|
|
const isObject = (value) => typeof value === 'object';
|
|
// tslint:disable:variable-name
|
|
is.undefined = isOfType('undefined');
|
|
is.string = isOfType('string');
|
|
is.number = isOfType('number');
|
|
is.function_ = isOfType('function');
|
|
is.null_ = (value) => value === null;
|
|
is.class_ = (value) => is.function_(value) && value.toString().startsWith('class ');
|
|
is.boolean = (value) => value === true || value === false;
|
|
// tslint:enable:variable-name
|
|
is.symbol = isOfType('symbol');
|
|
is.array = Array.isArray;
|
|
is.buffer = Buffer.isBuffer;
|
|
is.nullOrUndefined = (value) => is.null_(value) || is.undefined(value);
|
|
is.object = (value) => !is.nullOrUndefined(value) && (is.function_(value) || isObject(value));
|
|
is.iterable = (value) => !is.nullOrUndefined(value) && is.function_(value[Symbol.iterator]);
|
|
is.generator = (value) => is.iterable(value) && is.function_(value.next) && is.function_(value.throw);
|
|
is.nativePromise = isObjectOfType("Promise" /* Promise */);
|
|
const hasPromiseAPI = (value) => !is.null_(value) &&
|
|
isObject(value) &&
|
|
is.function_(value.then) &&
|
|
is.function_(value.catch);
|
|
is.promise = (value) => is.nativePromise(value) || hasPromiseAPI(value);
|
|
// TODO: Change to use `isObjectOfType` once Node.js 6 or higher is targeted
|
|
const isFunctionOfType = (type) => (value) => is.function_(value) && is.function_(value.constructor) && value.constructor.name === type;
|
|
is.generatorFunction = isFunctionOfType('GeneratorFunction');
|
|
is.asyncFunction = isFunctionOfType('AsyncFunction');
|
|
is.boundFunction = (value) => is.function_(value) && !value.hasOwnProperty('prototype');
|
|
is.regExp = isObjectOfType("RegExp" /* RegExp */);
|
|
is.date = isObjectOfType("Date" /* Date */);
|
|
is.error = isObjectOfType("Error" /* Error */);
|
|
is.map = isObjectOfType("Map" /* Map */);
|
|
is.set = isObjectOfType("Set" /* Set */);
|
|
is.weakMap = isObjectOfType("WeakMap" /* WeakMap */);
|
|
is.weakSet = isObjectOfType("WeakSet" /* WeakSet */);
|
|
is.int8Array = isObjectOfType("Int8Array" /* Int8Array */);
|
|
is.uint8Array = isObjectOfType("Uint8Array" /* Uint8Array */);
|
|
is.uint8ClampedArray = isObjectOfType("Uint8ClampedArray" /* Uint8ClampedArray */);
|
|
is.int16Array = isObjectOfType("Int16Array" /* Int16Array */);
|
|
is.uint16Array = isObjectOfType("Uint16Array" /* Uint16Array */);
|
|
is.int32Array = isObjectOfType("Int32Array" /* Int32Array */);
|
|
is.uint32Array = isObjectOfType("Uint32Array" /* Uint32Array */);
|
|
is.float32Array = isObjectOfType("Float32Array" /* Float32Array */);
|
|
is.float64Array = isObjectOfType("Float64Array" /* Float64Array */);
|
|
is.arrayBuffer = isObjectOfType("ArrayBuffer" /* ArrayBuffer */);
|
|
is.sharedArrayBuffer = isObjectOfType("SharedArrayBuffer" /* SharedArrayBuffer */);
|
|
is.dataView = isObjectOfType("DataView" /* DataView */);
|
|
// TODO: Remove `object` checks when targeting ES2015 or higher
|
|
// See `Notes`: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf
|
|
is.directInstanceOf = (instance, klass) => is.object(instance) && is.object(klass) && Object.getPrototypeOf(instance) === klass.prototype;
|
|
is.truthy = (value) => Boolean(value);
|
|
is.falsy = (value) => !value;
|
|
is.nan = (value) => Number.isNaN(value);
|
|
const primitiveTypes = new Set([
|
|
'undefined',
|
|
'string',
|
|
'number',
|
|
'boolean',
|
|
'symbol'
|
|
]);
|
|
is.primitive = (value) => is.null_(value) || primitiveTypes.has(typeof value);
|
|
is.integer = (value) => Number.isInteger(value);
|
|
is.safeInteger = (value) => Number.isSafeInteger(value);
|
|
is.plainObject = (value) => {
|
|
// From: https://github.com/sindresorhus/is-plain-obj/blob/master/index.js
|
|
let prototype;
|
|
return getObjectType(value) === "Object" /* Object */ &&
|
|
(prototype = Object.getPrototypeOf(value), prototype === null || // tslint:disable-line:ban-comma-operator
|
|
prototype === Object.getPrototypeOf({}));
|
|
};
|
|
const typedArrayTypes = new Set([
|
|
"Int8Array" /* Int8Array */,
|
|
"Uint8Array" /* Uint8Array */,
|
|
"Uint8ClampedArray" /* Uint8ClampedArray */,
|
|
"Int16Array" /* Int16Array */,
|
|
"Uint16Array" /* Uint16Array */,
|
|
"Int32Array" /* Int32Array */,
|
|
"Uint32Array" /* Uint32Array */,
|
|
"Float32Array" /* Float32Array */,
|
|
"Float64Array" /* Float64Array */
|
|
]);
|
|
is.typedArray = (value) => {
|
|
const objectType = getObjectType(value);
|
|
if (objectType === null) {
|
|
return false;
|
|
}
|
|
return typedArrayTypes.has(objectType);
|
|
};
|
|
const isValidLength = (value) => is.safeInteger(value) && value > -1;
|
|
is.arrayLike = (value) => !is.nullOrUndefined(value) && !is.function_(value) && isValidLength(value.length);
|
|
is.inRange = (value, range) => {
|
|
if (is.number(range)) {
|
|
return value >= Math.min(0, range) && value <= Math.max(range, 0);
|
|
}
|
|
if (is.array(range) && range.length === 2) {
|
|
// TODO: Use spread operator here when targeting Node.js 6 or higher
|
|
return value >= Math.min.apply(null, range) && value <= Math.max.apply(null, range);
|
|
}
|
|
throw new TypeError(`Invalid range: ${util.inspect(range)}`);
|
|
};
|
|
const NODE_TYPE_ELEMENT = 1;
|
|
const DOM_PROPERTIES_TO_CHECK = [
|
|
'innerHTML',
|
|
'ownerDocument',
|
|
'style',
|
|
'attributes',
|
|
'nodeValue'
|
|
];
|
|
is.domElement = (value) => is.object(value) && value.nodeType === NODE_TYPE_ELEMENT && is.string(value.nodeName) &&
|
|
!is.plainObject(value) && DOM_PROPERTIES_TO_CHECK.every(property => property in value);
|
|
is.nodeStream = (value) => !is.nullOrUndefined(value) && isObject(value) && is.function_(value.pipe);
|
|
is.infinite = (value) => value === Infinity || value === -Infinity;
|
|
const isAbsoluteMod2 = (value) => (rem) => is.integer(rem) && Math.abs(rem % 2) === value;
|
|
is.even = isAbsoluteMod2(0);
|
|
is.odd = isAbsoluteMod2(1);
|
|
const isWhiteSpaceString = (value) => is.string(value) && /\S/.test(value) === false;
|
|
const isEmptyStringOrArray = (value) => (is.string(value) || is.array(value)) && value.length === 0;
|
|
const isEmptyObject = (value) => !is.map(value) && !is.set(value) && is.object(value) && Object.keys(value).length === 0;
|
|
const isEmptyMapOrSet = (value) => (is.map(value) || is.set(value)) && value.size === 0;
|
|
is.empty = (value) => is.falsy(value) || isEmptyStringOrArray(value) || isEmptyObject(value) || isEmptyMapOrSet(value);
|
|
is.emptyOrWhitespace = (value) => is.empty(value) || isWhiteSpaceString(value);
|
|
const predicateOnArray = (method, predicate, args) => {
|
|
// `args` is the calling function's "arguments object".
|
|
// We have to do it this way to keep node v4 support.
|
|
// So here we convert it to an array and slice off the first item.
|
|
const values = Array.prototype.slice.call(args, 1);
|
|
if (is.function_(predicate) === false) {
|
|
throw new TypeError(`Invalid predicate: ${util.inspect(predicate)}`);
|
|
}
|
|
if (values.length === 0) {
|
|
throw new TypeError('Invalid number of values');
|
|
}
|
|
return method.call(values, predicate);
|
|
};
|
|
function any(predicate) {
|
|
return predicateOnArray(Array.prototype.some, predicate, arguments);
|
|
}
|
|
is.any = any;
|
|
function all(predicate) {
|
|
return predicateOnArray(Array.prototype.every, predicate, arguments);
|
|
}
|
|
is.all = all;
|
|
// tslint:enable:only-arrow-functions no-function-expression
|
|
})(is || (is = {}));
|
|
// Some few keywords are reserved, but we'll populate them for Node.js users
|
|
// See https://github.com/Microsoft/TypeScript/issues/2536
|
|
Object.defineProperties(is, {
|
|
class: {
|
|
value: is.class_
|
|
},
|
|
function: {
|
|
value: is.function_
|
|
},
|
|
null: {
|
|
value: is.null_
|
|
}
|
|
});
|
|
exports.default = is;
|
|
// For CommonJS default export support
|
|
module.exports = is;
|
|
module.exports.default = is;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 565:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
/**
|
|
* @file Tests if ES6 Symbol is supported.
|
|
* @version 1.4.2
|
|
* @author Xotic750 <Xotic750@gmail.com>
|
|
* @copyright Xotic750
|
|
* @license {@link <https://opensource.org/licenses/MIT> MIT}
|
|
* @module has-symbol-support-x
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
* Indicates if `Symbol`exists and creates the correct type.
|
|
* `true`, if it exists and creates the correct type, otherwise `false`.
|
|
*
|
|
* @type boolean
|
|
*/
|
|
module.exports = typeof Symbol === 'function' && typeof Symbol('') === 'symbol';
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 567:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var escapeStringRegexp = __webpack_require__(138);
|
|
|
|
module.exports = function (str, target) {
|
|
if (typeof str !== 'string' || typeof target !== 'string') {
|
|
throw new TypeError('Expected a string');
|
|
}
|
|
|
|
return str.replace(new RegExp('(?:' + escapeStringRegexp(target) + '){2,}', 'g'), target);
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 574:
|
|
/***/ (function(module, exports, __webpack_require__) {
|
|
|
|
var Stream = __webpack_require__(413);
|
|
if (process.env.READABLE_STREAM === 'disable' && Stream) {
|
|
module.exports = Stream;
|
|
exports = module.exports = Stream.Readable;
|
|
exports.Readable = Stream.Readable;
|
|
exports.Writable = Stream.Writable;
|
|
exports.Duplex = Stream.Duplex;
|
|
exports.Transform = Stream.Transform;
|
|
exports.PassThrough = Stream.PassThrough;
|
|
exports.Stream = Stream;
|
|
} else {
|
|
exports = module.exports = __webpack_require__(226);
|
|
exports.Stream = Stream || exports;
|
|
exports.Readable = exports;
|
|
exports.Writable = __webpack_require__(241);
|
|
exports.Duplex = __webpack_require__(831);
|
|
exports.Transform = __webpack_require__(925);
|
|
exports.PassThrough = __webpack_require__(882);
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 578:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = {"_args":[["seek-bzip@1.0.5","/home/runner/work/ghaction-upx/ghaction-upx"]],"_from":"seek-bzip@1.0.5","_id":"seek-bzip@1.0.5","_inBundle":false,"_integrity":"sha1-z+kXyz0nS8/6x5J1ivUxc+sfq9w=","_location":"/seek-bzip","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"seek-bzip@1.0.5","name":"seek-bzip","escapedName":"seek-bzip","rawSpec":"1.0.5","saveSpec":null,"fetchSpec":"1.0.5"},"_requiredBy":["/decompress-tarbz2"],"_resolved":"https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.5.tgz","_spec":"1.0.5","_where":"/home/runner/work/ghaction-upx/ghaction-upx","bin":{"seek-bunzip":"bin/seek-bunzip","seek-table":"bin/seek-bzip-table"},"bugs":{"url":"https://github.com/cscott/seek-bzip/issues"},"contributors":[{"name":"C. Scott Ananian","url":"http://cscott.net"},{"name":"Eli Skeggs"},{"name":"Kevin Kwok"},{"name":"Rob Landley","url":"http://landley.net"}],"dependencies":{"commander":"~2.8.1"},"description":"a pure-JavaScript Node.JS module for random-access decoding bzip2 data","devDependencies":{"fibers":"~1.0.6","mocha":"~2.2.5"},"directories":{"test":"test"},"homepage":"https://github.com/cscott/seek-bzip#readme","license":"MIT","main":"./lib/index.js","name":"seek-bzip","repository":{"type":"git","url":"git+https://github.com/cscott/seek-bzip.git"},"scripts":{"test":"mocha"},"version":"1.0.5"};
|
|
|
|
/***/ }),
|
|
|
|
/***/ 581:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var has = Object.prototype.hasOwnProperty;
|
|
var isArray = Array.isArray;
|
|
|
|
var hexTable = (function () {
|
|
var array = [];
|
|
for (var i = 0; i < 256; ++i) {
|
|
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
|
}
|
|
|
|
return array;
|
|
}());
|
|
|
|
var compactQueue = function compactQueue(queue) {
|
|
while (queue.length > 1) {
|
|
var item = queue.pop();
|
|
var obj = item.obj[item.prop];
|
|
|
|
if (isArray(obj)) {
|
|
var compacted = [];
|
|
|
|
for (var j = 0; j < obj.length; ++j) {
|
|
if (typeof obj[j] !== 'undefined') {
|
|
compacted.push(obj[j]);
|
|
}
|
|
}
|
|
|
|
item.obj[item.prop] = compacted;
|
|
}
|
|
}
|
|
};
|
|
|
|
var arrayToObject = function arrayToObject(source, options) {
|
|
var obj = options && options.plainObjects ? Object.create(null) : {};
|
|
for (var i = 0; i < source.length; ++i) {
|
|
if (typeof source[i] !== 'undefined') {
|
|
obj[i] = source[i];
|
|
}
|
|
}
|
|
|
|
return obj;
|
|
};
|
|
|
|
var merge = function merge(target, source, options) {
|
|
/* eslint no-param-reassign: 0 */
|
|
if (!source) {
|
|
return target;
|
|
}
|
|
|
|
if (typeof source !== 'object') {
|
|
if (isArray(target)) {
|
|
target.push(source);
|
|
} else if (target && typeof target === 'object') {
|
|
if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
|
|
target[source] = true;
|
|
}
|
|
} else {
|
|
return [target, source];
|
|
}
|
|
|
|
return target;
|
|
}
|
|
|
|
if (!target || typeof target !== 'object') {
|
|
return [target].concat(source);
|
|
}
|
|
|
|
var mergeTarget = target;
|
|
if (isArray(target) && !isArray(source)) {
|
|
mergeTarget = arrayToObject(target, options);
|
|
}
|
|
|
|
if (isArray(target) && isArray(source)) {
|
|
source.forEach(function (item, i) {
|
|
if (has.call(target, i)) {
|
|
var targetItem = target[i];
|
|
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
target[i] = merge(targetItem, item, options);
|
|
} else {
|
|
target.push(item);
|
|
}
|
|
} else {
|
|
target[i] = item;
|
|
}
|
|
});
|
|
return target;
|
|
}
|
|
|
|
return Object.keys(source).reduce(function (acc, key) {
|
|
var value = source[key];
|
|
|
|
if (has.call(acc, key)) {
|
|
acc[key] = merge(acc[key], value, options);
|
|
} else {
|
|
acc[key] = value;
|
|
}
|
|
return acc;
|
|
}, mergeTarget);
|
|
};
|
|
|
|
var assign = function assignSingleSource(target, source) {
|
|
return Object.keys(source).reduce(function (acc, key) {
|
|
acc[key] = source[key];
|
|
return acc;
|
|
}, target);
|
|
};
|
|
|
|
var decode = function (str, decoder, charset) {
|
|
var strWithoutPlus = str.replace(/\+/g, ' ');
|
|
if (charset === 'iso-8859-1') {
|
|
// unescape never throws, no try...catch needed:
|
|
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
|
}
|
|
// utf-8
|
|
try {
|
|
return decodeURIComponent(strWithoutPlus);
|
|
} catch (e) {
|
|
return strWithoutPlus;
|
|
}
|
|
};
|
|
|
|
var encode = function encode(str, defaultEncoder, charset) {
|
|
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
|
|
// It has been adapted here for stricter adherence to RFC 3986
|
|
if (str.length === 0) {
|
|
return str;
|
|
}
|
|
|
|
var string = str;
|
|
if (typeof str === 'symbol') {
|
|
string = Symbol.prototype.toString.call(str);
|
|
} else if (typeof str !== 'string') {
|
|
string = String(str);
|
|
}
|
|
|
|
if (charset === 'iso-8859-1') {
|
|
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
|
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
|
});
|
|
}
|
|
|
|
var out = '';
|
|
for (var i = 0; i < string.length; ++i) {
|
|
var c = string.charCodeAt(i);
|
|
|
|
if (
|
|
c === 0x2D // -
|
|
|| c === 0x2E // .
|
|
|| c === 0x5F // _
|
|
|| c === 0x7E // ~
|
|
|| (c >= 0x30 && c <= 0x39) // 0-9
|
|
|| (c >= 0x41 && c <= 0x5A) // a-z
|
|
|| (c >= 0x61 && c <= 0x7A) // A-Z
|
|
) {
|
|
out += string.charAt(i);
|
|
continue;
|
|
}
|
|
|
|
if (c < 0x80) {
|
|
out = out + hexTable[c];
|
|
continue;
|
|
}
|
|
|
|
if (c < 0x800) {
|
|
out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
|
|
continue;
|
|
}
|
|
|
|
if (c < 0xD800 || c >= 0xE000) {
|
|
out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
|
|
continue;
|
|
}
|
|
|
|
i += 1;
|
|
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
|
|
out += hexTable[0xF0 | (c >> 18)]
|
|
+ hexTable[0x80 | ((c >> 12) & 0x3F)]
|
|
+ hexTable[0x80 | ((c >> 6) & 0x3F)]
|
|
+ hexTable[0x80 | (c & 0x3F)];
|
|
}
|
|
|
|
return out;
|
|
};
|
|
|
|
var compact = function compact(value) {
|
|
var queue = [{ obj: { o: value }, prop: 'o' }];
|
|
var refs = [];
|
|
|
|
for (var i = 0; i < queue.length; ++i) {
|
|
var item = queue[i];
|
|
var obj = item.obj[item.prop];
|
|
|
|
var keys = Object.keys(obj);
|
|
for (var j = 0; j < keys.length; ++j) {
|
|
var key = keys[j];
|
|
var val = obj[key];
|
|
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
queue.push({ obj: obj, prop: key });
|
|
refs.push(val);
|
|
}
|
|
}
|
|
}
|
|
|
|
compactQueue(queue);
|
|
|
|
return value;
|
|
};
|
|
|
|
var isRegExp = function isRegExp(obj) {
|
|
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
|
};
|
|
|
|
var isBuffer = function isBuffer(obj) {
|
|
if (!obj || typeof obj !== 'object') {
|
|
return false;
|
|
}
|
|
|
|
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
|
};
|
|
|
|
var combine = function combine(a, b) {
|
|
return [].concat(a, b);
|
|
};
|
|
|
|
module.exports = {
|
|
arrayToObject: arrayToObject,
|
|
assign: assign,
|
|
combine: combine,
|
|
compact: compact,
|
|
decode: decode,
|
|
encode: encode,
|
|
isBuffer: isBuffer,
|
|
isRegExp: isRegExp,
|
|
merge: merge
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 598:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var fs = __webpack_require__(747)
|
|
var polyfills = __webpack_require__(250)
|
|
var legacy = __webpack_require__(93)
|
|
var clone = __webpack_require__(608)
|
|
|
|
var util = __webpack_require__(669)
|
|
|
|
/* istanbul ignore next - node 0.x polyfill */
|
|
var gracefulQueue
|
|
var previousSymbol
|
|
|
|
/* istanbul ignore else - node 0.x polyfill */
|
|
if (typeof Symbol === 'function' && typeof Symbol.for === 'function') {
|
|
gracefulQueue = Symbol.for('graceful-fs.queue')
|
|
// This is used in testing by future versions
|
|
previousSymbol = Symbol.for('graceful-fs.previous')
|
|
} else {
|
|
gracefulQueue = '___graceful-fs.queue'
|
|
previousSymbol = '___graceful-fs.previous'
|
|
}
|
|
|
|
function noop () {}
|
|
|
|
var debug = noop
|
|
if (util.debuglog)
|
|
debug = util.debuglog('gfs4')
|
|
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ''))
|
|
debug = function() {
|
|
var m = util.format.apply(util, arguments)
|
|
m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ')
|
|
console.error(m)
|
|
}
|
|
|
|
// Once time initialization
|
|
if (!global[gracefulQueue]) {
|
|
// This queue can be shared by multiple loaded instances
|
|
var queue = []
|
|
Object.defineProperty(global, gracefulQueue, {
|
|
get: function() {
|
|
return queue
|
|
}
|
|
})
|
|
|
|
// Patch fs.close/closeSync to shared queue version, because we need
|
|
// to retry() whenever a close happens *anywhere* in the program.
|
|
// This is essential when multiple graceful-fs instances are
|
|
// in play at the same time.
|
|
fs.close = (function (fs$close) {
|
|
function close (fd, cb) {
|
|
return fs$close.call(fs, fd, function (err) {
|
|
// This function uses the graceful-fs shared queue
|
|
if (!err) {
|
|
retry()
|
|
}
|
|
|
|
if (typeof cb === 'function')
|
|
cb.apply(this, arguments)
|
|
})
|
|
}
|
|
|
|
Object.defineProperty(close, previousSymbol, {
|
|
value: fs$close
|
|
})
|
|
return close
|
|
})(fs.close)
|
|
|
|
fs.closeSync = (function (fs$closeSync) {
|
|
function closeSync (fd) {
|
|
// This function uses the graceful-fs shared queue
|
|
fs$closeSync.apply(fs, arguments)
|
|
retry()
|
|
}
|
|
|
|
Object.defineProperty(closeSync, previousSymbol, {
|
|
value: fs$closeSync
|
|
})
|
|
return closeSync
|
|
})(fs.closeSync)
|
|
|
|
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
|
|
process.on('exit', function() {
|
|
debug(global[gracefulQueue])
|
|
__webpack_require__(357).equal(global[gracefulQueue].length, 0)
|
|
})
|
|
}
|
|
}
|
|
|
|
module.exports = patch(clone(fs))
|
|
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
|
|
module.exports = patch(fs)
|
|
fs.__patched = true;
|
|
}
|
|
|
|
function patch (fs) {
|
|
// Everything that references the open() function needs to be in here
|
|
polyfills(fs)
|
|
fs.gracefulify = patch
|
|
|
|
fs.createReadStream = createReadStream
|
|
fs.createWriteStream = createWriteStream
|
|
var fs$readFile = fs.readFile
|
|
fs.readFile = readFile
|
|
function readFile (path, options, cb) {
|
|
if (typeof options === 'function')
|
|
cb = options, options = null
|
|
|
|
return go$readFile(path, options, cb)
|
|
|
|
function go$readFile (path, options, cb) {
|
|
return fs$readFile(path, options, function (err) {
|
|
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
|
enqueue([go$readFile, [path, options, cb]])
|
|
else {
|
|
if (typeof cb === 'function')
|
|
cb.apply(this, arguments)
|
|
retry()
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
var fs$writeFile = fs.writeFile
|
|
fs.writeFile = writeFile
|
|
function writeFile (path, data, options, cb) {
|
|
if (typeof options === 'function')
|
|
cb = options, options = null
|
|
|
|
return go$writeFile(path, data, options, cb)
|
|
|
|
function go$writeFile (path, data, options, cb) {
|
|
return fs$writeFile(path, data, options, function (err) {
|
|
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
|
enqueue([go$writeFile, [path, data, options, cb]])
|
|
else {
|
|
if (typeof cb === 'function')
|
|
cb.apply(this, arguments)
|
|
retry()
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
var fs$appendFile = fs.appendFile
|
|
if (fs$appendFile)
|
|
fs.appendFile = appendFile
|
|
function appendFile (path, data, options, cb) {
|
|
if (typeof options === 'function')
|
|
cb = options, options = null
|
|
|
|
return go$appendFile(path, data, options, cb)
|
|
|
|
function go$appendFile (path, data, options, cb) {
|
|
return fs$appendFile(path, data, options, function (err) {
|
|
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
|
enqueue([go$appendFile, [path, data, options, cb]])
|
|
else {
|
|
if (typeof cb === 'function')
|
|
cb.apply(this, arguments)
|
|
retry()
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
var fs$readdir = fs.readdir
|
|
fs.readdir = readdir
|
|
function readdir (path, options, cb) {
|
|
var args = [path]
|
|
if (typeof options !== 'function') {
|
|
args.push(options)
|
|
} else {
|
|
cb = options
|
|
}
|
|
args.push(go$readdir$cb)
|
|
|
|
return go$readdir(args)
|
|
|
|
function go$readdir$cb (err, files) {
|
|
if (files && files.sort)
|
|
files.sort()
|
|
|
|
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
|
enqueue([go$readdir, [args]])
|
|
|
|
else {
|
|
if (typeof cb === 'function')
|
|
cb.apply(this, arguments)
|
|
retry()
|
|
}
|
|
}
|
|
}
|
|
|
|
function go$readdir (args) {
|
|
return fs$readdir.apply(fs, args)
|
|
}
|
|
|
|
if (process.version.substr(0, 4) === 'v0.8') {
|
|
var legStreams = legacy(fs)
|
|
ReadStream = legStreams.ReadStream
|
|
WriteStream = legStreams.WriteStream
|
|
}
|
|
|
|
var fs$ReadStream = fs.ReadStream
|
|
if (fs$ReadStream) {
|
|
ReadStream.prototype = Object.create(fs$ReadStream.prototype)
|
|
ReadStream.prototype.open = ReadStream$open
|
|
}
|
|
|
|
var fs$WriteStream = fs.WriteStream
|
|
if (fs$WriteStream) {
|
|
WriteStream.prototype = Object.create(fs$WriteStream.prototype)
|
|
WriteStream.prototype.open = WriteStream$open
|
|
}
|
|
|
|
Object.defineProperty(fs, 'ReadStream', {
|
|
get: function () {
|
|
return ReadStream
|
|
},
|
|
set: function (val) {
|
|
ReadStream = val
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
})
|
|
Object.defineProperty(fs, 'WriteStream', {
|
|
get: function () {
|
|
return WriteStream
|
|
},
|
|
set: function (val) {
|
|
WriteStream = val
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
})
|
|
|
|
// legacy names
|
|
var FileReadStream = ReadStream
|
|
Object.defineProperty(fs, 'FileReadStream', {
|
|
get: function () {
|
|
return FileReadStream
|
|
},
|
|
set: function (val) {
|
|
FileReadStream = val
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
})
|
|
var FileWriteStream = WriteStream
|
|
Object.defineProperty(fs, 'FileWriteStream', {
|
|
get: function () {
|
|
return FileWriteStream
|
|
},
|
|
set: function (val) {
|
|
FileWriteStream = val
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
})
|
|
|
|
function ReadStream (path, options) {
|
|
if (this instanceof ReadStream)
|
|
return fs$ReadStream.apply(this, arguments), this
|
|
else
|
|
return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
|
|
}
|
|
|
|
function ReadStream$open () {
|
|
var that = this
|
|
open(that.path, that.flags, that.mode, function (err, fd) {
|
|
if (err) {
|
|
if (that.autoClose)
|
|
that.destroy()
|
|
|
|
that.emit('error', err)
|
|
} else {
|
|
that.fd = fd
|
|
that.emit('open', fd)
|
|
that.read()
|
|
}
|
|
})
|
|
}
|
|
|
|
function WriteStream (path, options) {
|
|
if (this instanceof WriteStream)
|
|
return fs$WriteStream.apply(this, arguments), this
|
|
else
|
|
return WriteStream.apply(Object.create(WriteStream.prototype), arguments)
|
|
}
|
|
|
|
function WriteStream$open () {
|
|
var that = this
|
|
open(that.path, that.flags, that.mode, function (err, fd) {
|
|
if (err) {
|
|
that.destroy()
|
|
that.emit('error', err)
|
|
} else {
|
|
that.fd = fd
|
|
that.emit('open', fd)
|
|
}
|
|
})
|
|
}
|
|
|
|
function createReadStream (path, options) {
|
|
return new fs.ReadStream(path, options)
|
|
}
|
|
|
|
function createWriteStream (path, options) {
|
|
return new fs.WriteStream(path, options)
|
|
}
|
|
|
|
var fs$open = fs.open
|
|
fs.open = open
|
|
function open (path, flags, mode, cb) {
|
|
if (typeof mode === 'function')
|
|
cb = mode, mode = null
|
|
|
|
return go$open(path, flags, mode, cb)
|
|
|
|
function go$open (path, flags, mode, cb) {
|
|
return fs$open(path, flags, mode, function (err, fd) {
|
|
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
|
enqueue([go$open, [path, flags, mode, cb]])
|
|
else {
|
|
if (typeof cb === 'function')
|
|
cb.apply(this, arguments)
|
|
retry()
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
return fs
|
|
}
|
|
|
|
function enqueue (elem) {
|
|
debug('ENQUEUE', elem[0].name, elem[1])
|
|
global[gracefulQueue].push(elem)
|
|
}
|
|
|
|
function retry () {
|
|
var elem = global[gracefulQueue].shift()
|
|
if (elem) {
|
|
debug('RETRY', elem[0].name, elem[1])
|
|
elem[0].apply(null, elem[1])
|
|
}
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 605:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("http");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 608:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
module.exports = clone
|
|
|
|
function clone (obj) {
|
|
if (obj === null || typeof obj !== 'object')
|
|
return obj
|
|
|
|
if (obj instanceof Object)
|
|
var copy = { __proto__: obj.__proto__ }
|
|
else
|
|
var copy = Object.create(null)
|
|
|
|
Object.getOwnPropertyNames(obj).forEach(function (key) {
|
|
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key))
|
|
})
|
|
|
|
return copy
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 614:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("events");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 619:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("constants");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 622:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("path");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 631:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const {stringToBytes, readUInt64LE, tarHeaderChecksumMatches, uint8ArrayUtf8ByteString} = __webpack_require__(716);
|
|
|
|
const xpiZipFilename = stringToBytes('META-INF/mozilla.rsa');
|
|
const oxmlContentTypes = stringToBytes('[Content_Types].xml');
|
|
const oxmlRels = stringToBytes('_rels/.rels');
|
|
|
|
const fileType = input => {
|
|
if (!(input instanceof Uint8Array || input instanceof ArrayBuffer || Buffer.isBuffer(input))) {
|
|
throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`Buffer\` or \`ArrayBuffer\`, got \`${typeof input}\``);
|
|
}
|
|
|
|
const buffer = input instanceof Uint8Array ? input : new Uint8Array(input);
|
|
|
|
if (!(buffer && buffer.length > 1)) {
|
|
return;
|
|
}
|
|
|
|
const check = (header, options) => {
|
|
options = Object.assign({
|
|
offset: 0
|
|
}, options);
|
|
|
|
for (let i = 0; i < header.length; i++) {
|
|
// If a bitmask is set
|
|
if (options.mask) {
|
|
// If header doesn't equal `buf` with bits masked off
|
|
if (header[i] !== (options.mask[i] & buffer[i + options.offset])) {
|
|
return false;
|
|
}
|
|
} else if (header[i] !== buffer[i + options.offset]) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
const checkString = (header, options) => check(stringToBytes(header), options);
|
|
|
|
if (check([0xFF, 0xD8, 0xFF])) {
|
|
return {
|
|
ext: 'jpg',
|
|
mime: 'image/jpeg'
|
|
};
|
|
}
|
|
|
|
if (check([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])) {
|
|
return {
|
|
ext: 'png',
|
|
mime: 'image/png'
|
|
};
|
|
}
|
|
|
|
if (check([0x47, 0x49, 0x46])) {
|
|
return {
|
|
ext: 'gif',
|
|
mime: 'image/gif'
|
|
};
|
|
}
|
|
|
|
if (check([0x57, 0x45, 0x42, 0x50], {offset: 8})) {
|
|
return {
|
|
ext: 'webp',
|
|
mime: 'image/webp'
|
|
};
|
|
}
|
|
|
|
if (check([0x46, 0x4C, 0x49, 0x46])) {
|
|
return {
|
|
ext: 'flif',
|
|
mime: 'image/flif'
|
|
};
|
|
}
|
|
|
|
// `cr2`, `orf`, and `arw` need to be before `tif` check
|
|
if (
|
|
(check([0x49, 0x49, 0x2A, 0x0]) || check([0x4D, 0x4D, 0x0, 0x2A])) &&
|
|
check([0x43, 0x52], {offset: 8})
|
|
) {
|
|
return {
|
|
ext: 'cr2',
|
|
mime: 'image/x-canon-cr2'
|
|
};
|
|
}
|
|
|
|
if (check([0x49, 0x49, 0x52, 0x4F, 0x08, 0x00, 0x00, 0x00, 0x18])) {
|
|
return {
|
|
ext: 'orf',
|
|
mime: 'image/x-olympus-orf'
|
|
};
|
|
}
|
|
|
|
if (check([0x49, 0x49, 0x2A, 0x00, 0x10, 0xFB, 0x86, 0x01])) {
|
|
return {
|
|
ext: 'arw',
|
|
mime: 'image/x-sony-arw'
|
|
};
|
|
}
|
|
|
|
if (check([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2D])) {
|
|
return {
|
|
ext: 'dng',
|
|
mime: 'image/x-adobe-dng'
|
|
};
|
|
}
|
|
|
|
if (check([0x49, 0x49, 0x2A, 0x00, 0x30, 0x3D, 0x72, 0x01, 0x1C])) {
|
|
return {
|
|
ext: 'nef',
|
|
mime: 'image/x-nikon-nef'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x49, 0x49, 0x2A, 0x0]) ||
|
|
check([0x4D, 0x4D, 0x0, 0x2A])
|
|
) {
|
|
return {
|
|
ext: 'tif',
|
|
mime: 'image/tiff'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x4D])) {
|
|
return {
|
|
ext: 'bmp',
|
|
mime: 'image/bmp'
|
|
};
|
|
}
|
|
|
|
if (check([0x49, 0x49, 0xBC])) {
|
|
return {
|
|
ext: 'jxr',
|
|
mime: 'image/vnd.ms-photo'
|
|
};
|
|
}
|
|
|
|
if (check([0x38, 0x42, 0x50, 0x53])) {
|
|
return {
|
|
ext: 'psd',
|
|
mime: 'image/vnd.adobe.photoshop'
|
|
};
|
|
}
|
|
|
|
// Zip-based file formats
|
|
// Need to be before the `zip` check
|
|
if (check([0x50, 0x4B, 0x3, 0x4])) {
|
|
if (
|
|
check([0x6D, 0x69, 0x6D, 0x65, 0x74, 0x79, 0x70, 0x65, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x65, 0x70, 0x75, 0x62, 0x2B, 0x7A, 0x69, 0x70], {offset: 30})
|
|
) {
|
|
return {
|
|
ext: 'epub',
|
|
mime: 'application/epub+zip'
|
|
};
|
|
}
|
|
|
|
// Assumes signed `.xpi` from addons.mozilla.org
|
|
if (check(xpiZipFilename, {offset: 30})) {
|
|
return {
|
|
ext: 'xpi',
|
|
mime: 'application/x-xpinstall'
|
|
};
|
|
}
|
|
|
|
if (checkString('mimetypeapplication/vnd.oasis.opendocument.text', {offset: 30})) {
|
|
return {
|
|
ext: 'odt',
|
|
mime: 'application/vnd.oasis.opendocument.text'
|
|
};
|
|
}
|
|
|
|
if (checkString('mimetypeapplication/vnd.oasis.opendocument.spreadsheet', {offset: 30})) {
|
|
return {
|
|
ext: 'ods',
|
|
mime: 'application/vnd.oasis.opendocument.spreadsheet'
|
|
};
|
|
}
|
|
|
|
if (checkString('mimetypeapplication/vnd.oasis.opendocument.presentation', {offset: 30})) {
|
|
return {
|
|
ext: 'odp',
|
|
mime: 'application/vnd.oasis.opendocument.presentation'
|
|
};
|
|
}
|
|
|
|
// The docx, xlsx and pptx file types extend the Office Open XML file format:
|
|
// https://en.wikipedia.org/wiki/Office_Open_XML_file_formats
|
|
// We look for:
|
|
// - one entry named '[Content_Types].xml' or '_rels/.rels',
|
|
// - one entry indicating specific type of file.
|
|
// MS Office, OpenOffice and LibreOffice may put the parts in different order, so the check should not rely on it.
|
|
const findNextZipHeaderIndex = (arr, startAt = 0) => arr.findIndex((el, i, arr) => i >= startAt && arr[i] === 0x50 && arr[i + 1] === 0x4B && arr[i + 2] === 0x3 && arr[i + 3] === 0x4);
|
|
|
|
let zipHeaderIndex = 0; // The first zip header was already found at index 0
|
|
let oxmlFound = false;
|
|
let type;
|
|
|
|
do {
|
|
const offset = zipHeaderIndex + 30;
|
|
|
|
if (!oxmlFound) {
|
|
oxmlFound = (check(oxmlContentTypes, {offset}) || check(oxmlRels, {offset}));
|
|
}
|
|
|
|
if (!type) {
|
|
if (checkString('word/', {offset})) {
|
|
type = {
|
|
ext: 'docx',
|
|
mime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
|
};
|
|
} else if (checkString('ppt/', {offset})) {
|
|
type = {
|
|
ext: 'pptx',
|
|
mime: 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
|
|
};
|
|
} else if (checkString('xl/', {offset})) {
|
|
type = {
|
|
ext: 'xlsx',
|
|
mime: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
};
|
|
}
|
|
}
|
|
|
|
if (oxmlFound && type) {
|
|
return type;
|
|
}
|
|
|
|
zipHeaderIndex = findNextZipHeaderIndex(buffer, offset);
|
|
} while (zipHeaderIndex >= 0);
|
|
|
|
// No more zip parts available in the buffer, but maybe we are almost certain about the type?
|
|
if (type) {
|
|
return type;
|
|
}
|
|
}
|
|
|
|
if (
|
|
check([0x50, 0x4B]) &&
|
|
(buffer[2] === 0x3 || buffer[2] === 0x5 || buffer[2] === 0x7) &&
|
|
(buffer[3] === 0x4 || buffer[3] === 0x6 || buffer[3] === 0x8)
|
|
) {
|
|
return {
|
|
ext: 'zip',
|
|
mime: 'application/zip'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x30, 0x30, 0x30, 0x30, 0x30, 0x30], {offset: 148, mask: [0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8]}) && // Valid tar checksum
|
|
tarHeaderChecksumMatches(buffer)
|
|
) {
|
|
return {
|
|
ext: 'tar',
|
|
mime: 'application/x-tar'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x52, 0x61, 0x72, 0x21, 0x1A, 0x7]) &&
|
|
(buffer[6] === 0x0 || buffer[6] === 0x1)
|
|
) {
|
|
return {
|
|
ext: 'rar',
|
|
mime: 'application/x-rar-compressed'
|
|
};
|
|
}
|
|
|
|
if (check([0x1F, 0x8B, 0x8])) {
|
|
return {
|
|
ext: 'gz',
|
|
mime: 'application/gzip'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x5A, 0x68])) {
|
|
return {
|
|
ext: 'bz2',
|
|
mime: 'application/x-bzip2'
|
|
};
|
|
}
|
|
|
|
if (check([0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C])) {
|
|
return {
|
|
ext: '7z',
|
|
mime: 'application/x-7z-compressed'
|
|
};
|
|
}
|
|
|
|
if (check([0x78, 0x01])) {
|
|
return {
|
|
ext: 'dmg',
|
|
mime: 'application/x-apple-diskimage'
|
|
};
|
|
}
|
|
|
|
// `mov` format variants
|
|
if (
|
|
check([0x66, 0x72, 0x65, 0x65], {offset: 4}) || // `free`
|
|
check([0x6D, 0x64, 0x61, 0x74], {offset: 4}) || // `mdat` MJPEG
|
|
check([0x6D, 0x6F, 0x6F, 0x76], {offset: 4}) || // `moov`
|
|
check([0x77, 0x69, 0x64, 0x65], {offset: 4}) // `wide`
|
|
) {
|
|
return {
|
|
ext: 'mov',
|
|
mime: 'video/quicktime'
|
|
};
|
|
}
|
|
|
|
// File Type Box (https://en.wikipedia.org/wiki/ISO_base_media_file_format)
|
|
// It's not required to be first, but it's recommended to be. Almost all ISO base media files start with `ftyp` box.
|
|
// `ftyp` box must contain a brand major identifier, which must consist of ISO 8859-1 printable characters.
|
|
// Here we check for 8859-1 printable characters (for simplicity, it's a mask which also catches one non-printable character).
|
|
if (
|
|
check([0x66, 0x74, 0x79, 0x70], {offset: 4}) && // `ftyp`
|
|
(buffer[8] & 0x60) !== 0x00 && (buffer[9] & 0x60) !== 0x00 && (buffer[10] & 0x60) !== 0x00 && (buffer[11] & 0x60) !== 0x00 // Brand major
|
|
) {
|
|
// They all can have MIME `video/mp4` except `application/mp4` special-case which is hard to detect.
|
|
// For some cases, we're specific, everything else falls to `video/mp4` with `mp4` extension.
|
|
const brandMajor = uint8ArrayUtf8ByteString(buffer, 8, 12);
|
|
switch (brandMajor) {
|
|
case 'mif1':
|
|
return {ext: 'heic', mime: 'image/heif'};
|
|
case 'msf1':
|
|
return {ext: 'heic', mime: 'image/heif-sequence'};
|
|
case 'heic': case 'heix':
|
|
return {ext: 'heic', mime: 'image/heic'};
|
|
case 'hevc': case 'hevx':
|
|
return {ext: 'heic', mime: 'image/heic-sequence'};
|
|
case 'qt ':
|
|
return {ext: 'mov', mime: 'video/quicktime'};
|
|
case 'M4V ': case 'M4VH': case 'M4VP':
|
|
return {ext: 'm4v', mime: 'video/x-m4v'};
|
|
case 'M4P ':
|
|
return {ext: 'm4p', mime: 'video/mp4'};
|
|
case 'M4B ':
|
|
return {ext: 'm4b', mime: 'audio/mp4'};
|
|
case 'M4A ':
|
|
return {ext: 'm4a', mime: 'audio/x-m4a'};
|
|
case 'F4V ':
|
|
return {ext: 'f4v', mime: 'video/mp4'};
|
|
case 'F4P ':
|
|
return {ext: 'f4p', mime: 'video/mp4'};
|
|
case 'F4A ':
|
|
return {ext: 'f4a', mime: 'audio/mp4'};
|
|
case 'F4B ':
|
|
return {ext: 'f4b', mime: 'audio/mp4'};
|
|
default:
|
|
if (brandMajor.startsWith('3g')) {
|
|
if (brandMajor.startsWith('3g2')) {
|
|
return {ext: '3g2', mime: 'video/3gpp2'};
|
|
}
|
|
|
|
return {ext: '3gp', mime: 'video/3gpp'};
|
|
}
|
|
|
|
return {ext: 'mp4', mime: 'video/mp4'};
|
|
}
|
|
}
|
|
|
|
if (check([0x4D, 0x54, 0x68, 0x64])) {
|
|
return {
|
|
ext: 'mid',
|
|
mime: 'audio/midi'
|
|
};
|
|
}
|
|
|
|
// https://github.com/threatstack/libmagic/blob/master/magic/Magdir/matroska
|
|
if (check([0x1A, 0x45, 0xDF, 0xA3])) {
|
|
const sliced = buffer.subarray(4, 4 + 4096);
|
|
const idPos = sliced.findIndex((el, i, arr) => arr[i] === 0x42 && arr[i + 1] === 0x82);
|
|
|
|
if (idPos !== -1) {
|
|
const docTypePos = idPos + 3;
|
|
const findDocType = type => [...type].every((c, i) => sliced[docTypePos + i] === c.charCodeAt(0));
|
|
|
|
if (findDocType('matroska')) {
|
|
return {
|
|
ext: 'mkv',
|
|
mime: 'video/x-matroska'
|
|
};
|
|
}
|
|
|
|
if (findDocType('webm')) {
|
|
return {
|
|
ext: 'webm',
|
|
mime: 'video/webm'
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
// RIFF file format which might be AVI, WAV, QCP, etc
|
|
if (check([0x52, 0x49, 0x46, 0x46])) {
|
|
if (check([0x41, 0x56, 0x49], {offset: 8})) {
|
|
return {
|
|
ext: 'avi',
|
|
mime: 'video/vnd.avi'
|
|
};
|
|
}
|
|
|
|
if (check([0x57, 0x41, 0x56, 0x45], {offset: 8})) {
|
|
return {
|
|
ext: 'wav',
|
|
mime: 'audio/vnd.wave'
|
|
};
|
|
}
|
|
|
|
// QLCM, QCP file
|
|
if (check([0x51, 0x4C, 0x43, 0x4D], {offset: 8})) {
|
|
return {
|
|
ext: 'qcp',
|
|
mime: 'audio/qcelp'
|
|
};
|
|
}
|
|
}
|
|
|
|
// ASF_Header_Object first 80 bytes
|
|
if (check([0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xA6, 0xD9])) {
|
|
// Search for header should be in first 1KB of file.
|
|
|
|
let offset = 30;
|
|
do {
|
|
const objectSize = readUInt64LE(buffer, offset + 16);
|
|
if (check([0x91, 0x07, 0xDC, 0xB7, 0xB7, 0xA9, 0xCF, 0x11, 0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65], {offset})) {
|
|
// Sync on Stream-Properties-Object (B7DC0791-A9B7-11CF-8EE6-00C00C205365)
|
|
if (check([0x40, 0x9E, 0x69, 0xF8, 0x4D, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B], {offset: offset + 24})) {
|
|
// Found audio:
|
|
return {
|
|
ext: 'wma',
|
|
mime: 'audio/x-ms-wma'
|
|
};
|
|
}
|
|
|
|
if (check([0xC0, 0xEF, 0x19, 0xBC, 0x4D, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B], {offset: offset + 24})) {
|
|
// Found video:
|
|
return {
|
|
ext: 'wmv',
|
|
mime: 'video/x-ms-asf'
|
|
};
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
offset += objectSize;
|
|
} while (offset + 24 <= buffer.length);
|
|
|
|
// Default to ASF generic extension
|
|
return {
|
|
ext: 'asf',
|
|
mime: 'application/vnd.ms-asf'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x0, 0x0, 0x1, 0xBA]) ||
|
|
check([0x0, 0x0, 0x1, 0xB3])
|
|
) {
|
|
return {
|
|
ext: 'mpg',
|
|
mime: 'video/mpeg'
|
|
};
|
|
}
|
|
|
|
// Check for MPEG header at different starting offsets
|
|
for (let start = 0; start < 2 && start < (buffer.length - 16); start++) {
|
|
if (
|
|
check([0x49, 0x44, 0x33], {offset: start}) || // ID3 header
|
|
check([0xFF, 0xE2], {offset: start, mask: [0xFF, 0xE6]}) // MPEG 1 or 2 Layer 3 header
|
|
) {
|
|
return {
|
|
ext: 'mp3',
|
|
mime: 'audio/mpeg'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0xFF, 0xE4], {offset: start, mask: [0xFF, 0xE6]}) // MPEG 1 or 2 Layer 2 header
|
|
) {
|
|
return {
|
|
ext: 'mp2',
|
|
mime: 'audio/mpeg'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0xFF, 0xF8], {offset: start, mask: [0xFF, 0xFC]}) // MPEG 2 layer 0 using ADTS
|
|
) {
|
|
return {
|
|
ext: 'mp2',
|
|
mime: 'audio/mpeg'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0xFF, 0xF0], {offset: start, mask: [0xFF, 0xFC]}) // MPEG 4 layer 0 using ADTS
|
|
) {
|
|
return {
|
|
ext: 'mp4',
|
|
mime: 'audio/mpeg'
|
|
};
|
|
}
|
|
}
|
|
|
|
// Needs to be before `ogg` check
|
|
if (check([0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64], {offset: 28})) {
|
|
return {
|
|
ext: 'opus',
|
|
mime: 'audio/opus'
|
|
};
|
|
}
|
|
|
|
// If 'OggS' in first bytes, then OGG container
|
|
if (check([0x4F, 0x67, 0x67, 0x53])) {
|
|
// This is a OGG container
|
|
|
|
// If ' theora' in header.
|
|
if (check([0x80, 0x74, 0x68, 0x65, 0x6F, 0x72, 0x61], {offset: 28})) {
|
|
return {
|
|
ext: 'ogv',
|
|
mime: 'video/ogg'
|
|
};
|
|
}
|
|
|
|
// If '\x01video' in header.
|
|
if (check([0x01, 0x76, 0x69, 0x64, 0x65, 0x6F, 0x00], {offset: 28})) {
|
|
return {
|
|
ext: 'ogm',
|
|
mime: 'video/ogg'
|
|
};
|
|
}
|
|
|
|
// If ' FLAC' in header https://xiph.org/flac/faq.html
|
|
if (check([0x7F, 0x46, 0x4C, 0x41, 0x43], {offset: 28})) {
|
|
return {
|
|
ext: 'oga',
|
|
mime: 'audio/ogg'
|
|
};
|
|
}
|
|
|
|
// 'Speex ' in header https://en.wikipedia.org/wiki/Speex
|
|
if (check([0x53, 0x70, 0x65, 0x65, 0x78, 0x20, 0x20], {offset: 28})) {
|
|
return {
|
|
ext: 'spx',
|
|
mime: 'audio/ogg'
|
|
};
|
|
}
|
|
|
|
// If '\x01vorbis' in header
|
|
if (check([0x01, 0x76, 0x6F, 0x72, 0x62, 0x69, 0x73], {offset: 28})) {
|
|
return {
|
|
ext: 'ogg',
|
|
mime: 'audio/ogg'
|
|
};
|
|
}
|
|
|
|
// Default OGG container https://www.iana.org/assignments/media-types/application/ogg
|
|
return {
|
|
ext: 'ogx',
|
|
mime: 'application/ogg'
|
|
};
|
|
}
|
|
|
|
if (check([0x66, 0x4C, 0x61, 0x43])) {
|
|
return {
|
|
ext: 'flac',
|
|
mime: 'audio/x-flac'
|
|
};
|
|
}
|
|
|
|
if (check([0x4D, 0x41, 0x43, 0x20])) { // 'MAC '
|
|
return {
|
|
ext: 'ape',
|
|
mime: 'audio/ape'
|
|
};
|
|
}
|
|
|
|
if (check([0x77, 0x76, 0x70, 0x6B])) { // 'wvpk'
|
|
return {
|
|
ext: 'wv',
|
|
mime: 'audio/wavpack'
|
|
};
|
|
}
|
|
|
|
if (check([0x23, 0x21, 0x41, 0x4D, 0x52, 0x0A])) {
|
|
return {
|
|
ext: 'amr',
|
|
mime: 'audio/amr'
|
|
};
|
|
}
|
|
|
|
if (check([0x25, 0x50, 0x44, 0x46])) {
|
|
return {
|
|
ext: 'pdf',
|
|
mime: 'application/pdf'
|
|
};
|
|
}
|
|
|
|
if (check([0x4D, 0x5A])) {
|
|
return {
|
|
ext: 'exe',
|
|
mime: 'application/x-msdownload'
|
|
};
|
|
}
|
|
|
|
if (
|
|
(buffer[0] === 0x43 || buffer[0] === 0x46) &&
|
|
check([0x57, 0x53], {offset: 1})
|
|
) {
|
|
return {
|
|
ext: 'swf',
|
|
mime: 'application/x-shockwave-flash'
|
|
};
|
|
}
|
|
|
|
if (check([0x7B, 0x5C, 0x72, 0x74, 0x66])) {
|
|
return {
|
|
ext: 'rtf',
|
|
mime: 'application/rtf'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x61, 0x73, 0x6D])) {
|
|
return {
|
|
ext: 'wasm',
|
|
mime: 'application/wasm'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x77, 0x4F, 0x46, 0x46]) &&
|
|
(
|
|
check([0x00, 0x01, 0x00, 0x00], {offset: 4}) ||
|
|
check([0x4F, 0x54, 0x54, 0x4F], {offset: 4})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'woff',
|
|
mime: 'font/woff'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x77, 0x4F, 0x46, 0x32]) &&
|
|
(
|
|
check([0x00, 0x01, 0x00, 0x00], {offset: 4}) ||
|
|
check([0x4F, 0x54, 0x54, 0x4F], {offset: 4})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'woff2',
|
|
mime: 'font/woff2'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x4C, 0x50], {offset: 34}) &&
|
|
(
|
|
check([0x00, 0x00, 0x01], {offset: 8}) ||
|
|
check([0x01, 0x00, 0x02], {offset: 8}) ||
|
|
check([0x02, 0x00, 0x02], {offset: 8})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'eot',
|
|
mime: 'application/vnd.ms-fontobject'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x01, 0x00, 0x00, 0x00])) {
|
|
return {
|
|
ext: 'ttf',
|
|
mime: 'font/ttf'
|
|
};
|
|
}
|
|
|
|
if (check([0x4F, 0x54, 0x54, 0x4F, 0x00])) {
|
|
return {
|
|
ext: 'otf',
|
|
mime: 'font/otf'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x00, 0x01, 0x00])) {
|
|
return {
|
|
ext: 'ico',
|
|
mime: 'image/x-icon'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x00, 0x02, 0x00])) {
|
|
return {
|
|
ext: 'cur',
|
|
mime: 'image/x-icon'
|
|
};
|
|
}
|
|
|
|
if (check([0x46, 0x4C, 0x56, 0x01])) {
|
|
return {
|
|
ext: 'flv',
|
|
mime: 'video/x-flv'
|
|
};
|
|
}
|
|
|
|
if (check([0x25, 0x21])) {
|
|
return {
|
|
ext: 'ps',
|
|
mime: 'application/postscript'
|
|
};
|
|
}
|
|
|
|
if (check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) {
|
|
return {
|
|
ext: 'xz',
|
|
mime: 'application/x-xz'
|
|
};
|
|
}
|
|
|
|
if (check([0x53, 0x51, 0x4C, 0x69])) {
|
|
return {
|
|
ext: 'sqlite',
|
|
mime: 'application/x-sqlite3'
|
|
};
|
|
}
|
|
|
|
if (check([0x4E, 0x45, 0x53, 0x1A])) {
|
|
return {
|
|
ext: 'nes',
|
|
mime: 'application/x-nintendo-nes-rom'
|
|
};
|
|
}
|
|
|
|
if (check([0x43, 0x72, 0x32, 0x34])) {
|
|
return {
|
|
ext: 'crx',
|
|
mime: 'application/x-google-chrome-extension'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x4D, 0x53, 0x43, 0x46]) ||
|
|
check([0x49, 0x53, 0x63, 0x28])
|
|
) {
|
|
return {
|
|
ext: 'cab',
|
|
mime: 'application/vnd.ms-cab-compressed'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `ar` check
|
|
if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E, 0x0A, 0x64, 0x65, 0x62, 0x69, 0x61, 0x6E, 0x2D, 0x62, 0x69, 0x6E, 0x61, 0x72, 0x79])) {
|
|
return {
|
|
ext: 'deb',
|
|
mime: 'application/x-deb'
|
|
};
|
|
}
|
|
|
|
if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E])) {
|
|
return {
|
|
ext: 'ar',
|
|
mime: 'application/x-unix-archive'
|
|
};
|
|
}
|
|
|
|
if (check([0xED, 0xAB, 0xEE, 0xDB])) {
|
|
return {
|
|
ext: 'rpm',
|
|
mime: 'application/x-rpm'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x1F, 0xA0]) ||
|
|
check([0x1F, 0x9D])
|
|
) {
|
|
return {
|
|
ext: 'Z',
|
|
mime: 'application/x-compress'
|
|
};
|
|
}
|
|
|
|
if (check([0x4C, 0x5A, 0x49, 0x50])) {
|
|
return {
|
|
ext: 'lz',
|
|
mime: 'application/x-lzip'
|
|
};
|
|
}
|
|
|
|
if (check([0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1])) {
|
|
return {
|
|
ext: 'msi',
|
|
mime: 'application/x-msi'
|
|
};
|
|
}
|
|
|
|
if (check([0x06, 0x0E, 0x2B, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0D, 0x01, 0x02, 0x01, 0x01, 0x02])) {
|
|
return {
|
|
ext: 'mxf',
|
|
mime: 'application/mxf'
|
|
};
|
|
}
|
|
|
|
if (check([0x47], {offset: 4}) && (check([0x47], {offset: 192}) || check([0x47], {offset: 196}))) {
|
|
return {
|
|
ext: 'mts',
|
|
mime: 'video/mp2t'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x4C, 0x45, 0x4E, 0x44, 0x45, 0x52])) {
|
|
return {
|
|
ext: 'blend',
|
|
mime: 'application/x-blender'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x50, 0x47, 0xFB])) {
|
|
return {
|
|
ext: 'bpg',
|
|
mime: 'image/bpg'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x00, 0x00, 0x0C, 0x6A, 0x50, 0x20, 0x20, 0x0D, 0x0A, 0x87, 0x0A])) {
|
|
// JPEG-2000 family
|
|
|
|
if (check([0x6A, 0x70, 0x32, 0x20], {offset: 20})) {
|
|
return {
|
|
ext: 'jp2',
|
|
mime: 'image/jp2'
|
|
};
|
|
}
|
|
|
|
if (check([0x6A, 0x70, 0x78, 0x20], {offset: 20})) {
|
|
return {
|
|
ext: 'jpx',
|
|
mime: 'image/jpx'
|
|
};
|
|
}
|
|
|
|
if (check([0x6A, 0x70, 0x6D, 0x20], {offset: 20})) {
|
|
return {
|
|
ext: 'jpm',
|
|
mime: 'image/jpm'
|
|
};
|
|
}
|
|
|
|
if (check([0x6D, 0x6A, 0x70, 0x32], {offset: 20})) {
|
|
return {
|
|
ext: 'mj2',
|
|
mime: 'image/mj2'
|
|
};
|
|
}
|
|
}
|
|
|
|
if (check([0x46, 0x4F, 0x52, 0x4D])) {
|
|
return {
|
|
ext: 'aif',
|
|
mime: 'audio/aiff'
|
|
};
|
|
}
|
|
|
|
if (checkString('<?xml ')) {
|
|
return {
|
|
ext: 'xml',
|
|
mime: 'application/xml'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x4F, 0x4F, 0x4B, 0x4D, 0x4F, 0x42, 0x49], {offset: 60})) {
|
|
return {
|
|
ext: 'mobi',
|
|
mime: 'application/x-mobipocket-ebook'
|
|
};
|
|
}
|
|
|
|
if (check([0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A])) {
|
|
return {
|
|
ext: 'ktx',
|
|
mime: 'image/ktx'
|
|
};
|
|
}
|
|
|
|
if (check([0x44, 0x49, 0x43, 0x4D], {offset: 128})) {
|
|
return {
|
|
ext: 'dcm',
|
|
mime: 'application/dicom'
|
|
};
|
|
}
|
|
|
|
// Musepack, SV7
|
|
if (check([0x4D, 0x50, 0x2B])) {
|
|
return {
|
|
ext: 'mpc',
|
|
mime: 'audio/x-musepack'
|
|
};
|
|
}
|
|
|
|
// Musepack, SV8
|
|
if (check([0x4D, 0x50, 0x43, 0x4B])) {
|
|
return {
|
|
ext: 'mpc',
|
|
mime: 'audio/x-musepack'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x45, 0x47, 0x49, 0x4E, 0x3A])) {
|
|
return {
|
|
ext: 'ics',
|
|
mime: 'text/calendar'
|
|
};
|
|
}
|
|
|
|
if (check([0x67, 0x6C, 0x54, 0x46, 0x02, 0x00, 0x00, 0x00])) {
|
|
return {
|
|
ext: 'glb',
|
|
mime: 'model/gltf-binary'
|
|
};
|
|
}
|
|
|
|
if (check([0xD4, 0xC3, 0xB2, 0xA1]) || check([0xA1, 0xB2, 0xC3, 0xD4])) {
|
|
return {
|
|
ext: 'pcap',
|
|
mime: 'application/vnd.tcpdump.pcap'
|
|
};
|
|
}
|
|
|
|
// Sony DSD Stream File (DSF)
|
|
if (check([0x44, 0x53, 0x44, 0x20])) {
|
|
return {
|
|
ext: 'dsf',
|
|
mime: 'audio/x-dsf' // Non-standard
|
|
};
|
|
}
|
|
|
|
if (check([0x4C, 0x00, 0x00, 0x00, 0x01, 0x14, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46])) {
|
|
return {
|
|
ext: 'lnk',
|
|
mime: 'application/x.ms.shortcut' // Invented by us
|
|
};
|
|
}
|
|
|
|
if (check([0x62, 0x6F, 0x6F, 0x6B, 0x00, 0x00, 0x00, 0x00, 0x6D, 0x61, 0x72, 0x6B, 0x00, 0x00, 0x00, 0x00])) {
|
|
return {
|
|
ext: 'alias',
|
|
mime: 'application/x.apple.alias' // Invented by us
|
|
};
|
|
}
|
|
|
|
if (checkString('Creative Voice File')) {
|
|
return {
|
|
ext: 'voc',
|
|
mime: 'audio/x-voc'
|
|
};
|
|
}
|
|
|
|
if (check([0x0B, 0x77])) {
|
|
return {
|
|
ext: 'ac3',
|
|
mime: 'audio/vnd.dolby.dd-raw'
|
|
};
|
|
}
|
|
};
|
|
|
|
module.exports = fileType;
|
|
|
|
Object.defineProperty(fileType, 'minimumBytes', {value: 4100});
|
|
|
|
fileType.stream = readableStream => new Promise((resolve, reject) => {
|
|
// Using `eval` to work around issues when bundling with Webpack
|
|
const stream = eval('require')('stream'); // eslint-disable-line no-eval
|
|
|
|
readableStream.once('readable', () => {
|
|
const pass = new stream.PassThrough();
|
|
const chunk = readableStream.read(module.exports.minimumBytes) || readableStream.read();
|
|
try {
|
|
pass.fileType = fileType(chunk);
|
|
} catch (error) {
|
|
reject(error);
|
|
}
|
|
|
|
readableStream.unshift(chunk);
|
|
|
|
if (stream.pipeline) {
|
|
resolve(stream.pipeline(readableStream, pass, () => {}));
|
|
} else {
|
|
resolve(readableStream.pipe(pass));
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 634:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
/* eslint-disable no-control-regex */
|
|
// TODO: remove parens when Node.js 6 is targeted. Node.js 4 barfs at it.
|
|
module.exports = () => (/[<>:"\/\\|?*\x00-\x1F]/g);
|
|
module.exports.windowsNames = () => (/^(con|prn|aux|nul|com[0-9]|lpt[0-9])$/i);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 654:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const pFinally = __webpack_require__(697);
|
|
|
|
class TimeoutError extends Error {
|
|
constructor(message) {
|
|
super(message);
|
|
this.name = 'TimeoutError';
|
|
}
|
|
}
|
|
|
|
module.exports = (promise, ms, fallback) => new Promise((resolve, reject) => {
|
|
if (typeof ms !== 'number' || ms < 0) {
|
|
throw new TypeError('Expected `ms` to be a positive number');
|
|
}
|
|
|
|
const timer = setTimeout(() => {
|
|
if (typeof fallback === 'function') {
|
|
try {
|
|
resolve(fallback());
|
|
} catch (err) {
|
|
reject(err);
|
|
}
|
|
return;
|
|
}
|
|
|
|
const message = typeof fallback === 'string' ? fallback : `Promise timed out after ${ms} milliseconds`;
|
|
const err = fallback instanceof Error ? fallback : new TimeoutError(message);
|
|
|
|
if (typeof promise.cancel === 'function') {
|
|
promise.cancel();
|
|
}
|
|
|
|
reject(err);
|
|
}, ms);
|
|
|
|
pFinally(
|
|
promise.then(resolve, reject),
|
|
() => {
|
|
clearTimeout(timer);
|
|
}
|
|
);
|
|
});
|
|
|
|
module.exports.TimeoutError = TimeoutError;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 669:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("util");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 672:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var _a;
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const assert_1 = __webpack_require__(357);
|
|
const fs = __webpack_require__(747);
|
|
const path = __webpack_require__(622);
|
|
_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
|
|
exports.IS_WINDOWS = process.platform === 'win32';
|
|
function exists(fsPath) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
try {
|
|
yield exports.stat(fsPath);
|
|
}
|
|
catch (err) {
|
|
if (err.code === 'ENOENT') {
|
|
return false;
|
|
}
|
|
throw err;
|
|
}
|
|
return true;
|
|
});
|
|
}
|
|
exports.exists = exists;
|
|
function isDirectory(fsPath, useStat = false) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath);
|
|
return stats.isDirectory();
|
|
});
|
|
}
|
|
exports.isDirectory = isDirectory;
|
|
/**
|
|
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
|
|
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
|
|
*/
|
|
function isRooted(p) {
|
|
p = normalizeSeparators(p);
|
|
if (!p) {
|
|
throw new Error('isRooted() parameter "p" cannot be empty');
|
|
}
|
|
if (exports.IS_WINDOWS) {
|
|
return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello
|
|
); // e.g. C: or C:\hello
|
|
}
|
|
return p.startsWith('/');
|
|
}
|
|
exports.isRooted = isRooted;
|
|
/**
|
|
* Recursively create a directory at `fsPath`.
|
|
*
|
|
* This implementation is optimistic, meaning it attempts to create the full
|
|
* path first, and backs up the path stack from there.
|
|
*
|
|
* @param fsPath The path to create
|
|
* @param maxDepth The maximum recursion depth
|
|
* @param depth The current recursion depth
|
|
*/
|
|
function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
assert_1.ok(fsPath, 'a path argument must be provided');
|
|
fsPath = path.resolve(fsPath);
|
|
if (depth >= maxDepth)
|
|
return exports.mkdir(fsPath);
|
|
try {
|
|
yield exports.mkdir(fsPath);
|
|
return;
|
|
}
|
|
catch (err) {
|
|
switch (err.code) {
|
|
case 'ENOENT': {
|
|
yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
|
|
yield exports.mkdir(fsPath);
|
|
return;
|
|
}
|
|
default: {
|
|
let stats;
|
|
try {
|
|
stats = yield exports.stat(fsPath);
|
|
}
|
|
catch (err2) {
|
|
throw err;
|
|
}
|
|
if (!stats.isDirectory())
|
|
throw err;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
exports.mkdirP = mkdirP;
|
|
/**
|
|
* Best effort attempt to determine whether a file exists and is executable.
|
|
* @param filePath file path to check
|
|
* @param extensions additional file extensions to try
|
|
* @return if file exists and is executable, returns the file path. otherwise empty string.
|
|
*/
|
|
function tryGetExecutablePath(filePath, extensions) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
let stats = undefined;
|
|
try {
|
|
// test file exists
|
|
stats = yield exports.stat(filePath);
|
|
}
|
|
catch (err) {
|
|
if (err.code !== 'ENOENT') {
|
|
// eslint-disable-next-line no-console
|
|
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
|
|
}
|
|
}
|
|
if (stats && stats.isFile()) {
|
|
if (exports.IS_WINDOWS) {
|
|
// on Windows, test for valid extension
|
|
const upperExt = path.extname(filePath).toUpperCase();
|
|
if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) {
|
|
return filePath;
|
|
}
|
|
}
|
|
else {
|
|
if (isUnixExecutable(stats)) {
|
|
return filePath;
|
|
}
|
|
}
|
|
}
|
|
// try each extension
|
|
const originalFilePath = filePath;
|
|
for (const extension of extensions) {
|
|
filePath = originalFilePath + extension;
|
|
stats = undefined;
|
|
try {
|
|
stats = yield exports.stat(filePath);
|
|
}
|
|
catch (err) {
|
|
if (err.code !== 'ENOENT') {
|
|
// eslint-disable-next-line no-console
|
|
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
|
|
}
|
|
}
|
|
if (stats && stats.isFile()) {
|
|
if (exports.IS_WINDOWS) {
|
|
// preserve the case of the actual file (since an extension was appended)
|
|
try {
|
|
const directory = path.dirname(filePath);
|
|
const upperName = path.basename(filePath).toUpperCase();
|
|
for (const actualName of yield exports.readdir(directory)) {
|
|
if (upperName === actualName.toUpperCase()) {
|
|
filePath = path.join(directory, actualName);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (err) {
|
|
// eslint-disable-next-line no-console
|
|
console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
|
|
}
|
|
return filePath;
|
|
}
|
|
else {
|
|
if (isUnixExecutable(stats)) {
|
|
return filePath;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return '';
|
|
});
|
|
}
|
|
exports.tryGetExecutablePath = tryGetExecutablePath;
|
|
function normalizeSeparators(p) {
|
|
p = p || '';
|
|
if (exports.IS_WINDOWS) {
|
|
// convert slashes on Windows
|
|
p = p.replace(/\//g, '\\');
|
|
// remove redundant slashes
|
|
return p.replace(/\\\\+/g, '\\');
|
|
}
|
|
// remove redundant slashes
|
|
return p.replace(/\/\/+/g, '/');
|
|
}
|
|
// on Mac/Linux, test the execute bit
|
|
// R W X R W X R W X
|
|
// 256 128 64 32 16 8 4 2 1
|
|
function isUnixExecutable(stats) {
|
|
return ((stats.mode & 1) > 0 ||
|
|
((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
|
|
((stats.mode & 64) > 0 && stats.uid === process.getuid()));
|
|
}
|
|
//# sourceMappingURL=io-util.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 674:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
// copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
// following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included
|
|
// in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
/*<replacement>*/
|
|
|
|
var Buffer = __webpack_require__(233).Buffer;
|
|
/*</replacement>*/
|
|
|
|
var isEncoding = Buffer.isEncoding || function (encoding) {
|
|
encoding = '' + encoding;
|
|
switch (encoding && encoding.toLowerCase()) {
|
|
case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
};
|
|
|
|
function _normalizeEncoding(enc) {
|
|
if (!enc) return 'utf8';
|
|
var retried;
|
|
while (true) {
|
|
switch (enc) {
|
|
case 'utf8':
|
|
case 'utf-8':
|
|
return 'utf8';
|
|
case 'ucs2':
|
|
case 'ucs-2':
|
|
case 'utf16le':
|
|
case 'utf-16le':
|
|
return 'utf16le';
|
|
case 'latin1':
|
|
case 'binary':
|
|
return 'latin1';
|
|
case 'base64':
|
|
case 'ascii':
|
|
case 'hex':
|
|
return enc;
|
|
default:
|
|
if (retried) return; // undefined
|
|
enc = ('' + enc).toLowerCase();
|
|
retried = true;
|
|
}
|
|
}
|
|
};
|
|
|
|
// Do not cache `Buffer.isEncoding` when checking encoding names as some
|
|
// modules monkey-patch it to support additional encodings
|
|
function normalizeEncoding(enc) {
|
|
var nenc = _normalizeEncoding(enc);
|
|
if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
|
|
return nenc || enc;
|
|
}
|
|
|
|
// StringDecoder provides an interface for efficiently splitting a series of
|
|
// buffers into a series of JS strings without breaking apart multi-byte
|
|
// characters.
|
|
exports.StringDecoder = StringDecoder;
|
|
function StringDecoder(encoding) {
|
|
this.encoding = normalizeEncoding(encoding);
|
|
var nb;
|
|
switch (this.encoding) {
|
|
case 'utf16le':
|
|
this.text = utf16Text;
|
|
this.end = utf16End;
|
|
nb = 4;
|
|
break;
|
|
case 'utf8':
|
|
this.fillLast = utf8FillLast;
|
|
nb = 4;
|
|
break;
|
|
case 'base64':
|
|
this.text = base64Text;
|
|
this.end = base64End;
|
|
nb = 3;
|
|
break;
|
|
default:
|
|
this.write = simpleWrite;
|
|
this.end = simpleEnd;
|
|
return;
|
|
}
|
|
this.lastNeed = 0;
|
|
this.lastTotal = 0;
|
|
this.lastChar = Buffer.allocUnsafe(nb);
|
|
}
|
|
|
|
StringDecoder.prototype.write = function (buf) {
|
|
if (buf.length === 0) return '';
|
|
var r;
|
|
var i;
|
|
if (this.lastNeed) {
|
|
r = this.fillLast(buf);
|
|
if (r === undefined) return '';
|
|
i = this.lastNeed;
|
|
this.lastNeed = 0;
|
|
} else {
|
|
i = 0;
|
|
}
|
|
if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
|
|
return r || '';
|
|
};
|
|
|
|
StringDecoder.prototype.end = utf8End;
|
|
|
|
// Returns only complete characters in a Buffer
|
|
StringDecoder.prototype.text = utf8Text;
|
|
|
|
// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
|
|
StringDecoder.prototype.fillLast = function (buf) {
|
|
if (this.lastNeed <= buf.length) {
|
|
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
|
|
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
|
}
|
|
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
|
|
this.lastNeed -= buf.length;
|
|
};
|
|
|
|
// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
|
|
// continuation byte. If an invalid byte is detected, -2 is returned.
|
|
function utf8CheckByte(byte) {
|
|
if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
|
|
return byte >> 6 === 0x02 ? -1 : -2;
|
|
}
|
|
|
|
// Checks at most 3 bytes at the end of a Buffer in order to detect an
|
|
// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
|
|
// needed to complete the UTF-8 character (if applicable) are returned.
|
|
function utf8CheckIncomplete(self, buf, i) {
|
|
var j = buf.length - 1;
|
|
if (j < i) return 0;
|
|
var nb = utf8CheckByte(buf[j]);
|
|
if (nb >= 0) {
|
|
if (nb > 0) self.lastNeed = nb - 1;
|
|
return nb;
|
|
}
|
|
if (--j < i || nb === -2) return 0;
|
|
nb = utf8CheckByte(buf[j]);
|
|
if (nb >= 0) {
|
|
if (nb > 0) self.lastNeed = nb - 2;
|
|
return nb;
|
|
}
|
|
if (--j < i || nb === -2) return 0;
|
|
nb = utf8CheckByte(buf[j]);
|
|
if (nb >= 0) {
|
|
if (nb > 0) {
|
|
if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
|
|
}
|
|
return nb;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// Validates as many continuation bytes for a multi-byte UTF-8 character as
|
|
// needed or are available. If we see a non-continuation byte where we expect
|
|
// one, we "replace" the validated continuation bytes we've seen so far with
|
|
// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
|
|
// behavior. The continuation byte check is included three times in the case
|
|
// where all of the continuation bytes for a character exist in the same buffer.
|
|
// It is also done this way as a slight performance increase instead of using a
|
|
// loop.
|
|
function utf8CheckExtraBytes(self, buf, p) {
|
|
if ((buf[0] & 0xC0) !== 0x80) {
|
|
self.lastNeed = 0;
|
|
return '\ufffd';
|
|
}
|
|
if (self.lastNeed > 1 && buf.length > 1) {
|
|
if ((buf[1] & 0xC0) !== 0x80) {
|
|
self.lastNeed = 1;
|
|
return '\ufffd';
|
|
}
|
|
if (self.lastNeed > 2 && buf.length > 2) {
|
|
if ((buf[2] & 0xC0) !== 0x80) {
|
|
self.lastNeed = 2;
|
|
return '\ufffd';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
|
|
function utf8FillLast(buf) {
|
|
var p = this.lastTotal - this.lastNeed;
|
|
var r = utf8CheckExtraBytes(this, buf, p);
|
|
if (r !== undefined) return r;
|
|
if (this.lastNeed <= buf.length) {
|
|
buf.copy(this.lastChar, p, 0, this.lastNeed);
|
|
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
|
}
|
|
buf.copy(this.lastChar, p, 0, buf.length);
|
|
this.lastNeed -= buf.length;
|
|
}
|
|
|
|
// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
|
|
// partial character, the character's bytes are buffered until the required
|
|
// number of bytes are available.
|
|
function utf8Text(buf, i) {
|
|
var total = utf8CheckIncomplete(this, buf, i);
|
|
if (!this.lastNeed) return buf.toString('utf8', i);
|
|
this.lastTotal = total;
|
|
var end = buf.length - (total - this.lastNeed);
|
|
buf.copy(this.lastChar, 0, end);
|
|
return buf.toString('utf8', i, end);
|
|
}
|
|
|
|
// For UTF-8, a replacement character is added when ending on a partial
|
|
// character.
|
|
function utf8End(buf) {
|
|
var r = buf && buf.length ? this.write(buf) : '';
|
|
if (this.lastNeed) return r + '\ufffd';
|
|
return r;
|
|
}
|
|
|
|
// UTF-16LE typically needs two bytes per character, but even if we have an even
|
|
// number of bytes available, we need to check if we end on a leading/high
|
|
// surrogate. In that case, we need to wait for the next two bytes in order to
|
|
// decode the last character properly.
|
|
function utf16Text(buf, i) {
|
|
if ((buf.length - i) % 2 === 0) {
|
|
var r = buf.toString('utf16le', i);
|
|
if (r) {
|
|
var c = r.charCodeAt(r.length - 1);
|
|
if (c >= 0xD800 && c <= 0xDBFF) {
|
|
this.lastNeed = 2;
|
|
this.lastTotal = 4;
|
|
this.lastChar[0] = buf[buf.length - 2];
|
|
this.lastChar[1] = buf[buf.length - 1];
|
|
return r.slice(0, -1);
|
|
}
|
|
}
|
|
return r;
|
|
}
|
|
this.lastNeed = 1;
|
|
this.lastTotal = 2;
|
|
this.lastChar[0] = buf[buf.length - 1];
|
|
return buf.toString('utf16le', i, buf.length - 1);
|
|
}
|
|
|
|
// For UTF-16LE we do not explicitly append special replacement characters if we
|
|
// end on a partial character, we simply let v8 handle that.
|
|
function utf16End(buf) {
|
|
var r = buf && buf.length ? this.write(buf) : '';
|
|
if (this.lastNeed) {
|
|
var end = this.lastTotal - this.lastNeed;
|
|
return r + this.lastChar.toString('utf16le', 0, end);
|
|
}
|
|
return r;
|
|
}
|
|
|
|
function base64Text(buf, i) {
|
|
var n = (buf.length - i) % 3;
|
|
if (n === 0) return buf.toString('base64', i);
|
|
this.lastNeed = 3 - n;
|
|
this.lastTotal = 3;
|
|
if (n === 1) {
|
|
this.lastChar[0] = buf[buf.length - 1];
|
|
} else {
|
|
this.lastChar[0] = buf[buf.length - 2];
|
|
this.lastChar[1] = buf[buf.length - 1];
|
|
}
|
|
return buf.toString('base64', i, buf.length - n);
|
|
}
|
|
|
|
function base64End(buf) {
|
|
var r = buf && buf.length ? this.write(buf) : '';
|
|
if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
|
|
return r;
|
|
}
|
|
|
|
// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
|
|
function simpleWrite(buf) {
|
|
return buf.toString(this.encoding);
|
|
}
|
|
|
|
function simpleEnd(buf) {
|
|
return buf && buf.length ? this.write(buf) : '';
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 683:
|
|
/***/ (function(module, exports) {
|
|
|
|
exports = module.exports = SemVer
|
|
|
|
var debug
|
|
/* istanbul ignore next */
|
|
if (typeof process === 'object' &&
|
|
process.env &&
|
|
process.env.NODE_DEBUG &&
|
|
/\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
|
debug = function () {
|
|
var args = Array.prototype.slice.call(arguments, 0)
|
|
args.unshift('SEMVER')
|
|
console.log.apply(console, args)
|
|
}
|
|
} else {
|
|
debug = function () {}
|
|
}
|
|
|
|
// Note: this is the semver.org version of the spec that it implements
|
|
// Not necessarily the package version of this code.
|
|
exports.SEMVER_SPEC_VERSION = '2.0.0'
|
|
|
|
var MAX_LENGTH = 256
|
|
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
|
/* istanbul ignore next */ 9007199254740991
|
|
|
|
// Max safe segment length for coercion.
|
|
var MAX_SAFE_COMPONENT_LENGTH = 16
|
|
|
|
// The actual regexps go on exports.re
|
|
var re = exports.re = []
|
|
var src = exports.src = []
|
|
var R = 0
|
|
|
|
// The following Regular Expressions can be used for tokenizing,
|
|
// validating, and parsing SemVer version strings.
|
|
|
|
// ## Numeric Identifier
|
|
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
|
|
var NUMERICIDENTIFIER = R++
|
|
src[NUMERICIDENTIFIER] = '0|[1-9]\\d*'
|
|
var NUMERICIDENTIFIERLOOSE = R++
|
|
src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'
|
|
|
|
// ## Non-numeric Identifier
|
|
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
// more letters, digits, or hyphens.
|
|
|
|
var NONNUMERICIDENTIFIER = R++
|
|
src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'
|
|
|
|
// ## Main Version
|
|
// Three dot-separated numeric identifiers.
|
|
|
|
var MAINVERSION = R++
|
|
src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' +
|
|
'(' + src[NUMERICIDENTIFIER] + ')\\.' +
|
|
'(' + src[NUMERICIDENTIFIER] + ')'
|
|
|
|
var MAINVERSIONLOOSE = R++
|
|
src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
|
'(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
|
'(' + src[NUMERICIDENTIFIERLOOSE] + ')'
|
|
|
|
// ## Pre-release Version Identifier
|
|
// A numeric identifier, or a non-numeric identifier.
|
|
|
|
var PRERELEASEIDENTIFIER = R++
|
|
src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] +
|
|
'|' + src[NONNUMERICIDENTIFIER] + ')'
|
|
|
|
var PRERELEASEIDENTIFIERLOOSE = R++
|
|
src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] +
|
|
'|' + src[NONNUMERICIDENTIFIER] + ')'
|
|
|
|
// ## Pre-release Version
|
|
// Hyphen, followed by one or more dot-separated pre-release version
|
|
// identifiers.
|
|
|
|
var PRERELEASE = R++
|
|
src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] +
|
|
'(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))'
|
|
|
|
var PRERELEASELOOSE = R++
|
|
src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] +
|
|
'(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'
|
|
|
|
// ## Build Metadata Identifier
|
|
// Any combination of digits, letters, or hyphens.
|
|
|
|
var BUILDIDENTIFIER = R++
|
|
src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'
|
|
|
|
// ## Build Metadata
|
|
// Plus sign, followed by one or more period-separated build metadata
|
|
// identifiers.
|
|
|
|
var BUILD = R++
|
|
src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] +
|
|
'(?:\\.' + src[BUILDIDENTIFIER] + ')*))'
|
|
|
|
// ## Full Version String
|
|
// A main version, followed optionally by a pre-release version and
|
|
// build metadata.
|
|
|
|
// Note that the only major, minor, patch, and pre-release sections of
|
|
// the version string are capturing groups. The build metadata is not a
|
|
// capturing group, because it should not ever be used in version
|
|
// comparison.
|
|
|
|
var FULL = R++
|
|
var FULLPLAIN = 'v?' + src[MAINVERSION] +
|
|
src[PRERELEASE] + '?' +
|
|
src[BUILD] + '?'
|
|
|
|
src[FULL] = '^' + FULLPLAIN + '$'
|
|
|
|
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
// common in the npm registry.
|
|
var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] +
|
|
src[PRERELEASELOOSE] + '?' +
|
|
src[BUILD] + '?'
|
|
|
|
var LOOSE = R++
|
|
src[LOOSE] = '^' + LOOSEPLAIN + '$'
|
|
|
|
var GTLT = R++
|
|
src[GTLT] = '((?:<|>)?=?)'
|
|
|
|
// Something like "2.*" or "1.2.x".
|
|
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
// Only the first item is strictly required.
|
|
var XRANGEIDENTIFIERLOOSE = R++
|
|
src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'
|
|
var XRANGEIDENTIFIER = R++
|
|
src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*'
|
|
|
|
var XRANGEPLAIN = R++
|
|
src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' +
|
|
'(?:\\.(' + src[XRANGEIDENTIFIER] + ')' +
|
|
'(?:\\.(' + src[XRANGEIDENTIFIER] + ')' +
|
|
'(?:' + src[PRERELEASE] + ')?' +
|
|
src[BUILD] + '?' +
|
|
')?)?'
|
|
|
|
var XRANGEPLAINLOOSE = R++
|
|
src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
|
'(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
|
'(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
|
'(?:' + src[PRERELEASELOOSE] + ')?' +
|
|
src[BUILD] + '?' +
|
|
')?)?'
|
|
|
|
var XRANGE = R++
|
|
src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$'
|
|
var XRANGELOOSE = R++
|
|
src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'
|
|
|
|
// Coercion.
|
|
// Extract anything that could conceivably be a part of a valid semver
|
|
var COERCE = R++
|
|
src[COERCE] = '(?:^|[^\\d])' +
|
|
'(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
|
|
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
|
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
|
'(?:$|[^\\d])'
|
|
|
|
// Tilde ranges.
|
|
// Meaning is "reasonably at or greater than"
|
|
var LONETILDE = R++
|
|
src[LONETILDE] = '(?:~>?)'
|
|
|
|
var TILDETRIM = R++
|
|
src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+'
|
|
re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g')
|
|
var tildeTrimReplace = '$1~'
|
|
|
|
var TILDE = R++
|
|
src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$'
|
|
var TILDELOOSE = R++
|
|
src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'
|
|
|
|
// Caret ranges.
|
|
// Meaning is "at least and backwards compatible with"
|
|
var LONECARET = R++
|
|
src[LONECARET] = '(?:\\^)'
|
|
|
|
var CARETTRIM = R++
|
|
src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+'
|
|
re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g')
|
|
var caretTrimReplace = '$1^'
|
|
|
|
var CARET = R++
|
|
src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$'
|
|
var CARETLOOSE = R++
|
|
src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'
|
|
|
|
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
var COMPARATORLOOSE = R++
|
|
src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$'
|
|
var COMPARATOR = R++
|
|
src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'
|
|
|
|
// An expression to strip any whitespace between the gtlt and the thing
|
|
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
var COMPARATORTRIM = R++
|
|
src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] +
|
|
'\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'
|
|
|
|
// this one has to use the /g flag
|
|
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g')
|
|
var comparatorTrimReplace = '$1$2$3'
|
|
|
|
// Something like `1.2.3 - 1.2.4`
|
|
// Note that these all use the loose form, because they'll be
|
|
// checked against either the strict or loose comparator form
|
|
// later.
|
|
var HYPHENRANGE = R++
|
|
src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' +
|
|
'\\s+-\\s+' +
|
|
'(' + src[XRANGEPLAIN] + ')' +
|
|
'\\s*$'
|
|
|
|
var HYPHENRANGELOOSE = R++
|
|
src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' +
|
|
'\\s+-\\s+' +
|
|
'(' + src[XRANGEPLAINLOOSE] + ')' +
|
|
'\\s*$'
|
|
|
|
// Star ranges basically just allow anything at all.
|
|
var STAR = R++
|
|
src[STAR] = '(<|>)?=?\\s*\\*'
|
|
|
|
// Compile to actual regexp objects.
|
|
// All are flag-free, unless they were created above with a flag.
|
|
for (var i = 0; i < R; i++) {
|
|
debug(i, src[i])
|
|
if (!re[i]) {
|
|
re[i] = new RegExp(src[i])
|
|
}
|
|
}
|
|
|
|
exports.parse = parse
|
|
function parse (version, options) {
|
|
if (!options || typeof options !== 'object') {
|
|
options = {
|
|
loose: !!options,
|
|
includePrerelease: false
|
|
}
|
|
}
|
|
|
|
if (version instanceof SemVer) {
|
|
return version
|
|
}
|
|
|
|
if (typeof version !== 'string') {
|
|
return null
|
|
}
|
|
|
|
if (version.length > MAX_LENGTH) {
|
|
return null
|
|
}
|
|
|
|
var r = options.loose ? re[LOOSE] : re[FULL]
|
|
if (!r.test(version)) {
|
|
return null
|
|
}
|
|
|
|
try {
|
|
return new SemVer(version, options)
|
|
} catch (er) {
|
|
return null
|
|
}
|
|
}
|
|
|
|
exports.valid = valid
|
|
function valid (version, options) {
|
|
var v = parse(version, options)
|
|
return v ? v.version : null
|
|
}
|
|
|
|
exports.clean = clean
|
|
function clean (version, options) {
|
|
var s = parse(version.trim().replace(/^[=v]+/, ''), options)
|
|
return s ? s.version : null
|
|
}
|
|
|
|
exports.SemVer = SemVer
|
|
|
|
function SemVer (version, options) {
|
|
if (!options || typeof options !== 'object') {
|
|
options = {
|
|
loose: !!options,
|
|
includePrerelease: false
|
|
}
|
|
}
|
|
if (version instanceof SemVer) {
|
|
if (version.loose === options.loose) {
|
|
return version
|
|
} else {
|
|
version = version.version
|
|
}
|
|
} else if (typeof version !== 'string') {
|
|
throw new TypeError('Invalid Version: ' + version)
|
|
}
|
|
|
|
if (version.length > MAX_LENGTH) {
|
|
throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
|
|
}
|
|
|
|
if (!(this instanceof SemVer)) {
|
|
return new SemVer(version, options)
|
|
}
|
|
|
|
debug('SemVer', version, options)
|
|
this.options = options
|
|
this.loose = !!options.loose
|
|
|
|
var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL])
|
|
|
|
if (!m) {
|
|
throw new TypeError('Invalid Version: ' + version)
|
|
}
|
|
|
|
this.raw = version
|
|
|
|
// these are actually numbers
|
|
this.major = +m[1]
|
|
this.minor = +m[2]
|
|
this.patch = +m[3]
|
|
|
|
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
throw new TypeError('Invalid major version')
|
|
}
|
|
|
|
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
throw new TypeError('Invalid minor version')
|
|
}
|
|
|
|
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
throw new TypeError('Invalid patch version')
|
|
}
|
|
|
|
// numberify any prerelease numeric ids
|
|
if (!m[4]) {
|
|
this.prerelease = []
|
|
} else {
|
|
this.prerelease = m[4].split('.').map(function (id) {
|
|
if (/^[0-9]+$/.test(id)) {
|
|
var num = +id
|
|
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
return num
|
|
}
|
|
}
|
|
return id
|
|
})
|
|
}
|
|
|
|
this.build = m[5] ? m[5].split('.') : []
|
|
this.format()
|
|
}
|
|
|
|
SemVer.prototype.format = function () {
|
|
this.version = this.major + '.' + this.minor + '.' + this.patch
|
|
if (this.prerelease.length) {
|
|
this.version += '-' + this.prerelease.join('.')
|
|
}
|
|
return this.version
|
|
}
|
|
|
|
SemVer.prototype.toString = function () {
|
|
return this.version
|
|
}
|
|
|
|
SemVer.prototype.compare = function (other) {
|
|
debug('SemVer.compare', this.version, this.options, other)
|
|
if (!(other instanceof SemVer)) {
|
|
other = new SemVer(other, this.options)
|
|
}
|
|
|
|
return this.compareMain(other) || this.comparePre(other)
|
|
}
|
|
|
|
SemVer.prototype.compareMain = function (other) {
|
|
if (!(other instanceof SemVer)) {
|
|
other = new SemVer(other, this.options)
|
|
}
|
|
|
|
return compareIdentifiers(this.major, other.major) ||
|
|
compareIdentifiers(this.minor, other.minor) ||
|
|
compareIdentifiers(this.patch, other.patch)
|
|
}
|
|
|
|
SemVer.prototype.comparePre = function (other) {
|
|
if (!(other instanceof SemVer)) {
|
|
other = new SemVer(other, this.options)
|
|
}
|
|
|
|
// NOT having a prerelease is > having one
|
|
if (this.prerelease.length && !other.prerelease.length) {
|
|
return -1
|
|
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
return 1
|
|
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
return 0
|
|
}
|
|
|
|
var i = 0
|
|
do {
|
|
var a = this.prerelease[i]
|
|
var b = other.prerelease[i]
|
|
debug('prerelease compare', i, a, b)
|
|
if (a === undefined && b === undefined) {
|
|
return 0
|
|
} else if (b === undefined) {
|
|
return 1
|
|
} else if (a === undefined) {
|
|
return -1
|
|
} else if (a === b) {
|
|
continue
|
|
} else {
|
|
return compareIdentifiers(a, b)
|
|
}
|
|
} while (++i)
|
|
}
|
|
|
|
// preminor will bump the version up to the next minor release, and immediately
|
|
// down to pre-release. premajor and prepatch work the same way.
|
|
SemVer.prototype.inc = function (release, identifier) {
|
|
switch (release) {
|
|
case 'premajor':
|
|
this.prerelease.length = 0
|
|
this.patch = 0
|
|
this.minor = 0
|
|
this.major++
|
|
this.inc('pre', identifier)
|
|
break
|
|
case 'preminor':
|
|
this.prerelease.length = 0
|
|
this.patch = 0
|
|
this.minor++
|
|
this.inc('pre', identifier)
|
|
break
|
|
case 'prepatch':
|
|
// If this is already a prerelease, it will bump to the next version
|
|
// drop any prereleases that might already exist, since they are not
|
|
// relevant at this point.
|
|
this.prerelease.length = 0
|
|
this.inc('patch', identifier)
|
|
this.inc('pre', identifier)
|
|
break
|
|
// If the input is a non-prerelease version, this acts the same as
|
|
// prepatch.
|
|
case 'prerelease':
|
|
if (this.prerelease.length === 0) {
|
|
this.inc('patch', identifier)
|
|
}
|
|
this.inc('pre', identifier)
|
|
break
|
|
|
|
case 'major':
|
|
// If this is a pre-major version, bump up to the same major version.
|
|
// Otherwise increment major.
|
|
// 1.0.0-5 bumps to 1.0.0
|
|
// 1.1.0 bumps to 2.0.0
|
|
if (this.minor !== 0 ||
|
|
this.patch !== 0 ||
|
|
this.prerelease.length === 0) {
|
|
this.major++
|
|
}
|
|
this.minor = 0
|
|
this.patch = 0
|
|
this.prerelease = []
|
|
break
|
|
case 'minor':
|
|
// If this is a pre-minor version, bump up to the same minor version.
|
|
// Otherwise increment minor.
|
|
// 1.2.0-5 bumps to 1.2.0
|
|
// 1.2.1 bumps to 1.3.0
|
|
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
this.minor++
|
|
}
|
|
this.patch = 0
|
|
this.prerelease = []
|
|
break
|
|
case 'patch':
|
|
// If this is not a pre-release version, it will increment the patch.
|
|
// If it is a pre-release it will bump up to the same patch version.
|
|
// 1.2.0-5 patches to 1.2.0
|
|
// 1.2.0 patches to 1.2.1
|
|
if (this.prerelease.length === 0) {
|
|
this.patch++
|
|
}
|
|
this.prerelease = []
|
|
break
|
|
// This probably shouldn't be used publicly.
|
|
// 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
|
|
case 'pre':
|
|
if (this.prerelease.length === 0) {
|
|
this.prerelease = [0]
|
|
} else {
|
|
var i = this.prerelease.length
|
|
while (--i >= 0) {
|
|
if (typeof this.prerelease[i] === 'number') {
|
|
this.prerelease[i]++
|
|
i = -2
|
|
}
|
|
}
|
|
if (i === -1) {
|
|
// didn't increment anything
|
|
this.prerelease.push(0)
|
|
}
|
|
}
|
|
if (identifier) {
|
|
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
if (this.prerelease[0] === identifier) {
|
|
if (isNaN(this.prerelease[1])) {
|
|
this.prerelease = [identifier, 0]
|
|
}
|
|
} else {
|
|
this.prerelease = [identifier, 0]
|
|
}
|
|
}
|
|
break
|
|
|
|
default:
|
|
throw new Error('invalid increment argument: ' + release)
|
|
}
|
|
this.format()
|
|
this.raw = this.version
|
|
return this
|
|
}
|
|
|
|
exports.inc = inc
|
|
function inc (version, release, loose, identifier) {
|
|
if (typeof (loose) === 'string') {
|
|
identifier = loose
|
|
loose = undefined
|
|
}
|
|
|
|
try {
|
|
return new SemVer(version, loose).inc(release, identifier).version
|
|
} catch (er) {
|
|
return null
|
|
}
|
|
}
|
|
|
|
exports.diff = diff
|
|
function diff (version1, version2) {
|
|
if (eq(version1, version2)) {
|
|
return null
|
|
} else {
|
|
var v1 = parse(version1)
|
|
var v2 = parse(version2)
|
|
var prefix = ''
|
|
if (v1.prerelease.length || v2.prerelease.length) {
|
|
prefix = 'pre'
|
|
var defaultResult = 'prerelease'
|
|
}
|
|
for (var key in v1) {
|
|
if (key === 'major' || key === 'minor' || key === 'patch') {
|
|
if (v1[key] !== v2[key]) {
|
|
return prefix + key
|
|
}
|
|
}
|
|
}
|
|
return defaultResult // may be undefined
|
|
}
|
|
}
|
|
|
|
exports.compareIdentifiers = compareIdentifiers
|
|
|
|
var numeric = /^[0-9]+$/
|
|
function compareIdentifiers (a, b) {
|
|
var anum = numeric.test(a)
|
|
var bnum = numeric.test(b)
|
|
|
|
if (anum && bnum) {
|
|
a = +a
|
|
b = +b
|
|
}
|
|
|
|
return a === b ? 0
|
|
: (anum && !bnum) ? -1
|
|
: (bnum && !anum) ? 1
|
|
: a < b ? -1
|
|
: 1
|
|
}
|
|
|
|
exports.rcompareIdentifiers = rcompareIdentifiers
|
|
function rcompareIdentifiers (a, b) {
|
|
return compareIdentifiers(b, a)
|
|
}
|
|
|
|
exports.major = major
|
|
function major (a, loose) {
|
|
return new SemVer(a, loose).major
|
|
}
|
|
|
|
exports.minor = minor
|
|
function minor (a, loose) {
|
|
return new SemVer(a, loose).minor
|
|
}
|
|
|
|
exports.patch = patch
|
|
function patch (a, loose) {
|
|
return new SemVer(a, loose).patch
|
|
}
|
|
|
|
exports.compare = compare
|
|
function compare (a, b, loose) {
|
|
return new SemVer(a, loose).compare(new SemVer(b, loose))
|
|
}
|
|
|
|
exports.compareLoose = compareLoose
|
|
function compareLoose (a, b) {
|
|
return compare(a, b, true)
|
|
}
|
|
|
|
exports.rcompare = rcompare
|
|
function rcompare (a, b, loose) {
|
|
return compare(b, a, loose)
|
|
}
|
|
|
|
exports.sort = sort
|
|
function sort (list, loose) {
|
|
return list.sort(function (a, b) {
|
|
return exports.compare(a, b, loose)
|
|
})
|
|
}
|
|
|
|
exports.rsort = rsort
|
|
function rsort (list, loose) {
|
|
return list.sort(function (a, b) {
|
|
return exports.rcompare(a, b, loose)
|
|
})
|
|
}
|
|
|
|
exports.gt = gt
|
|
function gt (a, b, loose) {
|
|
return compare(a, b, loose) > 0
|
|
}
|
|
|
|
exports.lt = lt
|
|
function lt (a, b, loose) {
|
|
return compare(a, b, loose) < 0
|
|
}
|
|
|
|
exports.eq = eq
|
|
function eq (a, b, loose) {
|
|
return compare(a, b, loose) === 0
|
|
}
|
|
|
|
exports.neq = neq
|
|
function neq (a, b, loose) {
|
|
return compare(a, b, loose) !== 0
|
|
}
|
|
|
|
exports.gte = gte
|
|
function gte (a, b, loose) {
|
|
return compare(a, b, loose) >= 0
|
|
}
|
|
|
|
exports.lte = lte
|
|
function lte (a, b, loose) {
|
|
return compare(a, b, loose) <= 0
|
|
}
|
|
|
|
exports.cmp = cmp
|
|
function cmp (a, op, b, loose) {
|
|
switch (op) {
|
|
case '===':
|
|
if (typeof a === 'object')
|
|
a = a.version
|
|
if (typeof b === 'object')
|
|
b = b.version
|
|
return a === b
|
|
|
|
case '!==':
|
|
if (typeof a === 'object')
|
|
a = a.version
|
|
if (typeof b === 'object')
|
|
b = b.version
|
|
return a !== b
|
|
|
|
case '':
|
|
case '=':
|
|
case '==':
|
|
return eq(a, b, loose)
|
|
|
|
case '!=':
|
|
return neq(a, b, loose)
|
|
|
|
case '>':
|
|
return gt(a, b, loose)
|
|
|
|
case '>=':
|
|
return gte(a, b, loose)
|
|
|
|
case '<':
|
|
return lt(a, b, loose)
|
|
|
|
case '<=':
|
|
return lte(a, b, loose)
|
|
|
|
default:
|
|
throw new TypeError('Invalid operator: ' + op)
|
|
}
|
|
}
|
|
|
|
exports.Comparator = Comparator
|
|
function Comparator (comp, options) {
|
|
if (!options || typeof options !== 'object') {
|
|
options = {
|
|
loose: !!options,
|
|
includePrerelease: false
|
|
}
|
|
}
|
|
|
|
if (comp instanceof Comparator) {
|
|
if (comp.loose === !!options.loose) {
|
|
return comp
|
|
} else {
|
|
comp = comp.value
|
|
}
|
|
}
|
|
|
|
if (!(this instanceof Comparator)) {
|
|
return new Comparator(comp, options)
|
|
}
|
|
|
|
debug('comparator', comp, options)
|
|
this.options = options
|
|
this.loose = !!options.loose
|
|
this.parse(comp)
|
|
|
|
if (this.semver === ANY) {
|
|
this.value = ''
|
|
} else {
|
|
this.value = this.operator + this.semver.version
|
|
}
|
|
|
|
debug('comp', this)
|
|
}
|
|
|
|
var ANY = {}
|
|
Comparator.prototype.parse = function (comp) {
|
|
var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
|
|
var m = comp.match(r)
|
|
|
|
if (!m) {
|
|
throw new TypeError('Invalid comparator: ' + comp)
|
|
}
|
|
|
|
this.operator = m[1]
|
|
if (this.operator === '=') {
|
|
this.operator = ''
|
|
}
|
|
|
|
// if it literally is just '>' or '' then allow anything.
|
|
if (!m[2]) {
|
|
this.semver = ANY
|
|
} else {
|
|
this.semver = new SemVer(m[2], this.options.loose)
|
|
}
|
|
}
|
|
|
|
Comparator.prototype.toString = function () {
|
|
return this.value
|
|
}
|
|
|
|
Comparator.prototype.test = function (version) {
|
|
debug('Comparator.test', version, this.options.loose)
|
|
|
|
if (this.semver === ANY) {
|
|
return true
|
|
}
|
|
|
|
if (typeof version === 'string') {
|
|
version = new SemVer(version, this.options)
|
|
}
|
|
|
|
return cmp(version, this.operator, this.semver, this.options)
|
|
}
|
|
|
|
Comparator.prototype.intersects = function (comp, options) {
|
|
if (!(comp instanceof Comparator)) {
|
|
throw new TypeError('a Comparator is required')
|
|
}
|
|
|
|
if (!options || typeof options !== 'object') {
|
|
options = {
|
|
loose: !!options,
|
|
includePrerelease: false
|
|
}
|
|
}
|
|
|
|
var rangeTmp
|
|
|
|
if (this.operator === '') {
|
|
rangeTmp = new Range(comp.value, options)
|
|
return satisfies(this.value, rangeTmp, options)
|
|
} else if (comp.operator === '') {
|
|
rangeTmp = new Range(this.value, options)
|
|
return satisfies(comp.semver, rangeTmp, options)
|
|
}
|
|
|
|
var sameDirectionIncreasing =
|
|
(this.operator === '>=' || this.operator === '>') &&
|
|
(comp.operator === '>=' || comp.operator === '>')
|
|
var sameDirectionDecreasing =
|
|
(this.operator === '<=' || this.operator === '<') &&
|
|
(comp.operator === '<=' || comp.operator === '<')
|
|
var sameSemVer = this.semver.version === comp.semver.version
|
|
var differentDirectionsInclusive =
|
|
(this.operator === '>=' || this.operator === '<=') &&
|
|
(comp.operator === '>=' || comp.operator === '<=')
|
|
var oppositeDirectionsLessThan =
|
|
cmp(this.semver, '<', comp.semver, options) &&
|
|
((this.operator === '>=' || this.operator === '>') &&
|
|
(comp.operator === '<=' || comp.operator === '<'))
|
|
var oppositeDirectionsGreaterThan =
|
|
cmp(this.semver, '>', comp.semver, options) &&
|
|
((this.operator === '<=' || this.operator === '<') &&
|
|
(comp.operator === '>=' || comp.operator === '>'))
|
|
|
|
return sameDirectionIncreasing || sameDirectionDecreasing ||
|
|
(sameSemVer && differentDirectionsInclusive) ||
|
|
oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
|
|
}
|
|
|
|
exports.Range = Range
|
|
function Range (range, options) {
|
|
if (!options || typeof options !== 'object') {
|
|
options = {
|
|
loose: !!options,
|
|
includePrerelease: false
|
|
}
|
|
}
|
|
|
|
if (range instanceof Range) {
|
|
if (range.loose === !!options.loose &&
|
|
range.includePrerelease === !!options.includePrerelease) {
|
|
return range
|
|
} else {
|
|
return new Range(range.raw, options)
|
|
}
|
|
}
|
|
|
|
if (range instanceof Comparator) {
|
|
return new Range(range.value, options)
|
|
}
|
|
|
|
if (!(this instanceof Range)) {
|
|
return new Range(range, options)
|
|
}
|
|
|
|
this.options = options
|
|
this.loose = !!options.loose
|
|
this.includePrerelease = !!options.includePrerelease
|
|
|
|
// First, split based on boolean or ||
|
|
this.raw = range
|
|
this.set = range.split(/\s*\|\|\s*/).map(function (range) {
|
|
return this.parseRange(range.trim())
|
|
}, this).filter(function (c) {
|
|
// throw out any that are not relevant for whatever reason
|
|
return c.length
|
|
})
|
|
|
|
if (!this.set.length) {
|
|
throw new TypeError('Invalid SemVer Range: ' + range)
|
|
}
|
|
|
|
this.format()
|
|
}
|
|
|
|
Range.prototype.format = function () {
|
|
this.range = this.set.map(function (comps) {
|
|
return comps.join(' ').trim()
|
|
}).join('||').trim()
|
|
return this.range
|
|
}
|
|
|
|
Range.prototype.toString = function () {
|
|
return this.range
|
|
}
|
|
|
|
Range.prototype.parseRange = function (range) {
|
|
var loose = this.options.loose
|
|
range = range.trim()
|
|
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE]
|
|
range = range.replace(hr, hyphenReplace)
|
|
debug('hyphen replace', range)
|
|
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace)
|
|
debug('comparator trim', range, re[COMPARATORTRIM])
|
|
|
|
// `~ 1.2.3` => `~1.2.3`
|
|
range = range.replace(re[TILDETRIM], tildeTrimReplace)
|
|
|
|
// `^ 1.2.3` => `^1.2.3`
|
|
range = range.replace(re[CARETTRIM], caretTrimReplace)
|
|
|
|
// normalize spaces
|
|
range = range.split(/\s+/).join(' ')
|
|
|
|
// At this point, the range is completely trimmed and
|
|
// ready to be split into comparators.
|
|
|
|
var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
|
|
var set = range.split(' ').map(function (comp) {
|
|
return parseComparator(comp, this.options)
|
|
}, this).join(' ').split(/\s+/)
|
|
if (this.options.loose) {
|
|
// in loose mode, throw out any that are not valid comparators
|
|
set = set.filter(function (comp) {
|
|
return !!comp.match(compRe)
|
|
})
|
|
}
|
|
set = set.map(function (comp) {
|
|
return new Comparator(comp, this.options)
|
|
}, this)
|
|
|
|
return set
|
|
}
|
|
|
|
Range.prototype.intersects = function (range, options) {
|
|
if (!(range instanceof Range)) {
|
|
throw new TypeError('a Range is required')
|
|
}
|
|
|
|
return this.set.some(function (thisComparators) {
|
|
return thisComparators.every(function (thisComparator) {
|
|
return range.set.some(function (rangeComparators) {
|
|
return rangeComparators.every(function (rangeComparator) {
|
|
return thisComparator.intersects(rangeComparator, options)
|
|
})
|
|
})
|
|
})
|
|
})
|
|
}
|
|
|
|
// Mostly just for testing and legacy API reasons
|
|
exports.toComparators = toComparators
|
|
function toComparators (range, options) {
|
|
return new Range(range, options).set.map(function (comp) {
|
|
return comp.map(function (c) {
|
|
return c.value
|
|
}).join(' ').trim().split(' ')
|
|
})
|
|
}
|
|
|
|
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
|
// already replaced the hyphen ranges
|
|
// turn into a set of JUST comparators.
|
|
function parseComparator (comp, options) {
|
|
debug('comp', comp, options)
|
|
comp = replaceCarets(comp, options)
|
|
debug('caret', comp)
|
|
comp = replaceTildes(comp, options)
|
|
debug('tildes', comp)
|
|
comp = replaceXRanges(comp, options)
|
|
debug('xrange', comp)
|
|
comp = replaceStars(comp, options)
|
|
debug('stars', comp)
|
|
return comp
|
|
}
|
|
|
|
function isX (id) {
|
|
return !id || id.toLowerCase() === 'x' || id === '*'
|
|
}
|
|
|
|
// ~, ~> --> * (any, kinda silly)
|
|
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
|
|
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
|
|
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
|
|
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
|
|
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
|
|
function replaceTildes (comp, options) {
|
|
return comp.trim().split(/\s+/).map(function (comp) {
|
|
return replaceTilde(comp, options)
|
|
}).join(' ')
|
|
}
|
|
|
|
function replaceTilde (comp, options) {
|
|
var r = options.loose ? re[TILDELOOSE] : re[TILDE]
|
|
return comp.replace(r, function (_, M, m, p, pr) {
|
|
debug('tilde', comp, _, M, m, p, pr)
|
|
var ret
|
|
|
|
if (isX(M)) {
|
|
ret = ''
|
|
} else if (isX(m)) {
|
|
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
|
} else if (isX(p)) {
|
|
// ~1.2 == >=1.2.0 <1.3.0
|
|
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
|
} else if (pr) {
|
|
debug('replaceTilde pr', pr)
|
|
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
' <' + M + '.' + (+m + 1) + '.0'
|
|
} else {
|
|
// ~1.2.3 == >=1.2.3 <1.3.0
|
|
ret = '>=' + M + '.' + m + '.' + p +
|
|
' <' + M + '.' + (+m + 1) + '.0'
|
|
}
|
|
|
|
debug('tilde return', ret)
|
|
return ret
|
|
})
|
|
}
|
|
|
|
// ^ --> * (any, kinda silly)
|
|
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
|
|
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
|
|
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
|
|
// ^1.2.3 --> >=1.2.3 <2.0.0
|
|
// ^1.2.0 --> >=1.2.0 <2.0.0
|
|
function replaceCarets (comp, options) {
|
|
return comp.trim().split(/\s+/).map(function (comp) {
|
|
return replaceCaret(comp, options)
|
|
}).join(' ')
|
|
}
|
|
|
|
function replaceCaret (comp, options) {
|
|
debug('caret', comp, options)
|
|
var r = options.loose ? re[CARETLOOSE] : re[CARET]
|
|
return comp.replace(r, function (_, M, m, p, pr) {
|
|
debug('caret', comp, _, M, m, p, pr)
|
|
var ret
|
|
|
|
if (isX(M)) {
|
|
ret = ''
|
|
} else if (isX(m)) {
|
|
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
|
} else if (isX(p)) {
|
|
if (M === '0') {
|
|
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
|
} else {
|
|
ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0'
|
|
}
|
|
} else if (pr) {
|
|
debug('replaceCaret pr', pr)
|
|
if (M === '0') {
|
|
if (m === '0') {
|
|
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
' <' + M + '.' + m + '.' + (+p + 1)
|
|
} else {
|
|
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
' <' + M + '.' + (+m + 1) + '.0'
|
|
}
|
|
} else {
|
|
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
' <' + (+M + 1) + '.0.0'
|
|
}
|
|
} else {
|
|
debug('no pr')
|
|
if (M === '0') {
|
|
if (m === '0') {
|
|
ret = '>=' + M + '.' + m + '.' + p +
|
|
' <' + M + '.' + m + '.' + (+p + 1)
|
|
} else {
|
|
ret = '>=' + M + '.' + m + '.' + p +
|
|
' <' + M + '.' + (+m + 1) + '.0'
|
|
}
|
|
} else {
|
|
ret = '>=' + M + '.' + m + '.' + p +
|
|
' <' + (+M + 1) + '.0.0'
|
|
}
|
|
}
|
|
|
|
debug('caret return', ret)
|
|
return ret
|
|
})
|
|
}
|
|
|
|
function replaceXRanges (comp, options) {
|
|
debug('replaceXRanges', comp, options)
|
|
return comp.split(/\s+/).map(function (comp) {
|
|
return replaceXRange(comp, options)
|
|
}).join(' ')
|
|
}
|
|
|
|
function replaceXRange (comp, options) {
|
|
comp = comp.trim()
|
|
var r = options.loose ? re[XRANGELOOSE] : re[XRANGE]
|
|
return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
|
|
debug('xRange', comp, ret, gtlt, M, m, p, pr)
|
|
var xM = isX(M)
|
|
var xm = xM || isX(m)
|
|
var xp = xm || isX(p)
|
|
var anyX = xp
|
|
|
|
if (gtlt === '=' && anyX) {
|
|
gtlt = ''
|
|
}
|
|
|
|
if (xM) {
|
|
if (gtlt === '>' || gtlt === '<') {
|
|
// nothing is allowed
|
|
ret = '<0.0.0'
|
|
} else {
|
|
// nothing is forbidden
|
|
ret = '*'
|
|
}
|
|
} else if (gtlt && anyX) {
|
|
// we know patch is an x, because we have any x at all.
|
|
// replace X with 0
|
|
if (xm) {
|
|
m = 0
|
|
}
|
|
p = 0
|
|
|
|
if (gtlt === '>') {
|
|
// >1 => >=2.0.0
|
|
// >1.2 => >=1.3.0
|
|
// >1.2.3 => >= 1.2.4
|
|
gtlt = '>='
|
|
if (xm) {
|
|
M = +M + 1
|
|
m = 0
|
|
p = 0
|
|
} else {
|
|
m = +m + 1
|
|
p = 0
|
|
}
|
|
} else if (gtlt === '<=') {
|
|
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
|
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
|
gtlt = '<'
|
|
if (xm) {
|
|
M = +M + 1
|
|
} else {
|
|
m = +m + 1
|
|
}
|
|
}
|
|
|
|
ret = gtlt + M + '.' + m + '.' + p
|
|
} else if (xm) {
|
|
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
|
} else if (xp) {
|
|
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
|
}
|
|
|
|
debug('xRange return', ret)
|
|
|
|
return ret
|
|
})
|
|
}
|
|
|
|
// Because * is AND-ed with everything else in the comparator,
|
|
// and '' means "any version", just remove the *s entirely.
|
|
function replaceStars (comp, options) {
|
|
debug('replaceStars', comp, options)
|
|
// Looseness is ignored here. star is always as loose as it gets!
|
|
return comp.trim().replace(re[STAR], '')
|
|
}
|
|
|
|
// This function is passed to string.replace(re[HYPHENRANGE])
|
|
// M, m, patch, prerelease, build
|
|
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
|
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
|
|
// 1.2 - 3.4 => >=1.2.0 <3.5.0
|
|
function hyphenReplace ($0,
|
|
from, fM, fm, fp, fpr, fb,
|
|
to, tM, tm, tp, tpr, tb) {
|
|
if (isX(fM)) {
|
|
from = ''
|
|
} else if (isX(fm)) {
|
|
from = '>=' + fM + '.0.0'
|
|
} else if (isX(fp)) {
|
|
from = '>=' + fM + '.' + fm + '.0'
|
|
} else {
|
|
from = '>=' + from
|
|
}
|
|
|
|
if (isX(tM)) {
|
|
to = ''
|
|
} else if (isX(tm)) {
|
|
to = '<' + (+tM + 1) + '.0.0'
|
|
} else if (isX(tp)) {
|
|
to = '<' + tM + '.' + (+tm + 1) + '.0'
|
|
} else if (tpr) {
|
|
to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr
|
|
} else {
|
|
to = '<=' + to
|
|
}
|
|
|
|
return (from + ' ' + to).trim()
|
|
}
|
|
|
|
// if ANY of the sets match ALL of its comparators, then pass
|
|
Range.prototype.test = function (version) {
|
|
if (!version) {
|
|
return false
|
|
}
|
|
|
|
if (typeof version === 'string') {
|
|
version = new SemVer(version, this.options)
|
|
}
|
|
|
|
for (var i = 0; i < this.set.length; i++) {
|
|
if (testSet(this.set[i], version, this.options)) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
function testSet (set, version, options) {
|
|
for (var i = 0; i < set.length; i++) {
|
|
if (!set[i].test(version)) {
|
|
return false
|
|
}
|
|
}
|
|
|
|
if (version.prerelease.length && !options.includePrerelease) {
|
|
// Find the set of versions that are allowed to have prereleases
|
|
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
|
// That should allow `1.2.3-pr.2` to pass.
|
|
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
|
// even though it's within the range set by the comparators.
|
|
for (i = 0; i < set.length; i++) {
|
|
debug(set[i].semver)
|
|
if (set[i].semver === ANY) {
|
|
continue
|
|
}
|
|
|
|
if (set[i].semver.prerelease.length > 0) {
|
|
var allowed = set[i].semver
|
|
if (allowed.major === version.major &&
|
|
allowed.minor === version.minor &&
|
|
allowed.patch === version.patch) {
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
|
|
// Version has a -pre, but it's not one of the ones we like.
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
exports.satisfies = satisfies
|
|
function satisfies (version, range, options) {
|
|
try {
|
|
range = new Range(range, options)
|
|
} catch (er) {
|
|
return false
|
|
}
|
|
return range.test(version)
|
|
}
|
|
|
|
exports.maxSatisfying = maxSatisfying
|
|
function maxSatisfying (versions, range, options) {
|
|
var max = null
|
|
var maxSV = null
|
|
try {
|
|
var rangeObj = new Range(range, options)
|
|
} catch (er) {
|
|
return null
|
|
}
|
|
versions.forEach(function (v) {
|
|
if (rangeObj.test(v)) {
|
|
// satisfies(v, range, options)
|
|
if (!max || maxSV.compare(v) === -1) {
|
|
// compare(max, v, true)
|
|
max = v
|
|
maxSV = new SemVer(max, options)
|
|
}
|
|
}
|
|
})
|
|
return max
|
|
}
|
|
|
|
exports.minSatisfying = minSatisfying
|
|
function minSatisfying (versions, range, options) {
|
|
var min = null
|
|
var minSV = null
|
|
try {
|
|
var rangeObj = new Range(range, options)
|
|
} catch (er) {
|
|
return null
|
|
}
|
|
versions.forEach(function (v) {
|
|
if (rangeObj.test(v)) {
|
|
// satisfies(v, range, options)
|
|
if (!min || minSV.compare(v) === 1) {
|
|
// compare(min, v, true)
|
|
min = v
|
|
minSV = new SemVer(min, options)
|
|
}
|
|
}
|
|
})
|
|
return min
|
|
}
|
|
|
|
exports.minVersion = minVersion
|
|
function minVersion (range, loose) {
|
|
range = new Range(range, loose)
|
|
|
|
var minver = new SemVer('0.0.0')
|
|
if (range.test(minver)) {
|
|
return minver
|
|
}
|
|
|
|
minver = new SemVer('0.0.0-0')
|
|
if (range.test(minver)) {
|
|
return minver
|
|
}
|
|
|
|
minver = null
|
|
for (var i = 0; i < range.set.length; ++i) {
|
|
var comparators = range.set[i]
|
|
|
|
comparators.forEach(function (comparator) {
|
|
// Clone to avoid manipulating the comparator's semver object.
|
|
var compver = new SemVer(comparator.semver.version)
|
|
switch (comparator.operator) {
|
|
case '>':
|
|
if (compver.prerelease.length === 0) {
|
|
compver.patch++
|
|
} else {
|
|
compver.prerelease.push(0)
|
|
}
|
|
compver.raw = compver.format()
|
|
/* fallthrough */
|
|
case '':
|
|
case '>=':
|
|
if (!minver || gt(minver, compver)) {
|
|
minver = compver
|
|
}
|
|
break
|
|
case '<':
|
|
case '<=':
|
|
/* Ignore maximum versions */
|
|
break
|
|
/* istanbul ignore next */
|
|
default:
|
|
throw new Error('Unexpected operation: ' + comparator.operator)
|
|
}
|
|
})
|
|
}
|
|
|
|
if (minver && range.test(minver)) {
|
|
return minver
|
|
}
|
|
|
|
return null
|
|
}
|
|
|
|
exports.validRange = validRange
|
|
function validRange (range, options) {
|
|
try {
|
|
// Return '*' instead of '' so that truthiness works.
|
|
// This will throw if it's invalid anyway
|
|
return new Range(range, options).range || '*'
|
|
} catch (er) {
|
|
return null
|
|
}
|
|
}
|
|
|
|
// Determine if version is less than all the versions possible in the range
|
|
exports.ltr = ltr
|
|
function ltr (version, range, options) {
|
|
return outside(version, range, '<', options)
|
|
}
|
|
|
|
// Determine if version is greater than all the versions possible in the range.
|
|
exports.gtr = gtr
|
|
function gtr (version, range, options) {
|
|
return outside(version, range, '>', options)
|
|
}
|
|
|
|
exports.outside = outside
|
|
function outside (version, range, hilo, options) {
|
|
version = new SemVer(version, options)
|
|
range = new Range(range, options)
|
|
|
|
var gtfn, ltefn, ltfn, comp, ecomp
|
|
switch (hilo) {
|
|
case '>':
|
|
gtfn = gt
|
|
ltefn = lte
|
|
ltfn = lt
|
|
comp = '>'
|
|
ecomp = '>='
|
|
break
|
|
case '<':
|
|
gtfn = lt
|
|
ltefn = gte
|
|
ltfn = gt
|
|
comp = '<'
|
|
ecomp = '<='
|
|
break
|
|
default:
|
|
throw new TypeError('Must provide a hilo val of "<" or ">"')
|
|
}
|
|
|
|
// If it satisifes the range it is not outside
|
|
if (satisfies(version, range, options)) {
|
|
return false
|
|
}
|
|
|
|
// From now on, variable terms are as if we're in "gtr" mode.
|
|
// but note that everything is flipped for the "ltr" function.
|
|
|
|
for (var i = 0; i < range.set.length; ++i) {
|
|
var comparators = range.set[i]
|
|
|
|
var high = null
|
|
var low = null
|
|
|
|
comparators.forEach(function (comparator) {
|
|
if (comparator.semver === ANY) {
|
|
comparator = new Comparator('>=0.0.0')
|
|
}
|
|
high = high || comparator
|
|
low = low || comparator
|
|
if (gtfn(comparator.semver, high.semver, options)) {
|
|
high = comparator
|
|
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
low = comparator
|
|
}
|
|
})
|
|
|
|
// If the edge version comparator has a operator then our version
|
|
// isn't outside it
|
|
if (high.operator === comp || high.operator === ecomp) {
|
|
return false
|
|
}
|
|
|
|
// If the lowest version comparator has an operator and our version
|
|
// is less than it then it isn't higher than the range
|
|
if ((!low.operator || low.operator === comp) &&
|
|
ltefn(version, low.semver)) {
|
|
return false
|
|
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
exports.prerelease = prerelease
|
|
function prerelease (version, options) {
|
|
var parsed = parse(version, options)
|
|
return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
|
|
}
|
|
|
|
exports.intersects = intersects
|
|
function intersects (r1, r2, options) {
|
|
r1 = new Range(r1, options)
|
|
r2 = new Range(r2, options)
|
|
return r1.intersects(r2)
|
|
}
|
|
|
|
exports.coerce = coerce
|
|
function coerce (version) {
|
|
if (version instanceof SemVer) {
|
|
return version
|
|
}
|
|
|
|
if (typeof version !== 'string') {
|
|
return null
|
|
}
|
|
|
|
var match = version.match(re[COERCE])
|
|
|
|
if (match == null) {
|
|
return null
|
|
}
|
|
|
|
return parse(match[1] +
|
|
'.' + (match[2] || '0') +
|
|
'.' + (match[3] || '0'))
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 686:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const os = __webpack_require__(87);
|
|
const events = __webpack_require__(614);
|
|
const child = __webpack_require__(129);
|
|
const path = __webpack_require__(622);
|
|
const io = __webpack_require__(1);
|
|
const ioUtil = __webpack_require__(672);
|
|
/* eslint-disable @typescript-eslint/unbound-method */
|
|
const IS_WINDOWS = process.platform === 'win32';
|
|
/*
|
|
* Class for running command line tools. Handles quoting and arg parsing in a platform agnostic way.
|
|
*/
|
|
class ToolRunner extends events.EventEmitter {
|
|
constructor(toolPath, args, options) {
|
|
super();
|
|
if (!toolPath) {
|
|
throw new Error("Parameter 'toolPath' cannot be null or empty.");
|
|
}
|
|
this.toolPath = toolPath;
|
|
this.args = args || [];
|
|
this.options = options || {};
|
|
}
|
|
_debug(message) {
|
|
if (this.options.listeners && this.options.listeners.debug) {
|
|
this.options.listeners.debug(message);
|
|
}
|
|
}
|
|
_getCommandString(options, noPrefix) {
|
|
const toolPath = this._getSpawnFileName();
|
|
const args = this._getSpawnArgs(options);
|
|
let cmd = noPrefix ? '' : '[command]'; // omit prefix when piped to a second tool
|
|
if (IS_WINDOWS) {
|
|
// Windows + cmd file
|
|
if (this._isCmdFile()) {
|
|
cmd += toolPath;
|
|
for (const a of args) {
|
|
cmd += ` ${a}`;
|
|
}
|
|
}
|
|
// Windows + verbatim
|
|
else if (options.windowsVerbatimArguments) {
|
|
cmd += `"${toolPath}"`;
|
|
for (const a of args) {
|
|
cmd += ` ${a}`;
|
|
}
|
|
}
|
|
// Windows (regular)
|
|
else {
|
|
cmd += this._windowsQuoteCmdArg(toolPath);
|
|
for (const a of args) {
|
|
cmd += ` ${this._windowsQuoteCmdArg(a)}`;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
// OSX/Linux - this can likely be improved with some form of quoting.
|
|
// creating processes on Unix is fundamentally different than Windows.
|
|
// on Unix, execvp() takes an arg array.
|
|
cmd += toolPath;
|
|
for (const a of args) {
|
|
cmd += ` ${a}`;
|
|
}
|
|
}
|
|
return cmd;
|
|
}
|
|
_processLineBuffer(data, strBuffer, onLine) {
|
|
try {
|
|
let s = strBuffer + data.toString();
|
|
let n = s.indexOf(os.EOL);
|
|
while (n > -1) {
|
|
const line = s.substring(0, n);
|
|
onLine(line);
|
|
// the rest of the string ...
|
|
s = s.substring(n + os.EOL.length);
|
|
n = s.indexOf(os.EOL);
|
|
}
|
|
strBuffer = s;
|
|
}
|
|
catch (err) {
|
|
// streaming lines to console is best effort. Don't fail a build.
|
|
this._debug(`error processing line. Failed with error ${err}`);
|
|
}
|
|
}
|
|
_getSpawnFileName() {
|
|
if (IS_WINDOWS) {
|
|
if (this._isCmdFile()) {
|
|
return process.env['COMSPEC'] || 'cmd.exe';
|
|
}
|
|
}
|
|
return this.toolPath;
|
|
}
|
|
_getSpawnArgs(options) {
|
|
if (IS_WINDOWS) {
|
|
if (this._isCmdFile()) {
|
|
let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;
|
|
for (const a of this.args) {
|
|
argline += ' ';
|
|
argline += options.windowsVerbatimArguments
|
|
? a
|
|
: this._windowsQuoteCmdArg(a);
|
|
}
|
|
argline += '"';
|
|
return [argline];
|
|
}
|
|
}
|
|
return this.args;
|
|
}
|
|
_endsWith(str, end) {
|
|
return str.endsWith(end);
|
|
}
|
|
_isCmdFile() {
|
|
const upperToolPath = this.toolPath.toUpperCase();
|
|
return (this._endsWith(upperToolPath, '.CMD') ||
|
|
this._endsWith(upperToolPath, '.BAT'));
|
|
}
|
|
_windowsQuoteCmdArg(arg) {
|
|
// for .exe, apply the normal quoting rules that libuv applies
|
|
if (!this._isCmdFile()) {
|
|
return this._uvQuoteCmdArg(arg);
|
|
}
|
|
// otherwise apply quoting rules specific to the cmd.exe command line parser.
|
|
// the libuv rules are generic and are not designed specifically for cmd.exe
|
|
// command line parser.
|
|
//
|
|
// for a detailed description of the cmd.exe command line parser, refer to
|
|
// http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/7970912#7970912
|
|
// need quotes for empty arg
|
|
if (!arg) {
|
|
return '""';
|
|
}
|
|
// determine whether the arg needs to be quoted
|
|
const cmdSpecialChars = [
|
|
' ',
|
|
'\t',
|
|
'&',
|
|
'(',
|
|
')',
|
|
'[',
|
|
']',
|
|
'{',
|
|
'}',
|
|
'^',
|
|
'=',
|
|
';',
|
|
'!',
|
|
"'",
|
|
'+',
|
|
',',
|
|
'`',
|
|
'~',
|
|
'|',
|
|
'<',
|
|
'>',
|
|
'"'
|
|
];
|
|
let needsQuotes = false;
|
|
for (const char of arg) {
|
|
if (cmdSpecialChars.some(x => x === char)) {
|
|
needsQuotes = true;
|
|
break;
|
|
}
|
|
}
|
|
// short-circuit if quotes not needed
|
|
if (!needsQuotes) {
|
|
return arg;
|
|
}
|
|
// the following quoting rules are very similar to the rules that by libuv applies.
|
|
//
|
|
// 1) wrap the string in quotes
|
|
//
|
|
// 2) double-up quotes - i.e. " => ""
|
|
//
|
|
// this is different from the libuv quoting rules. libuv replaces " with \", which unfortunately
|
|
// doesn't work well with a cmd.exe command line.
|
|
//
|
|
// note, replacing " with "" also works well if the arg is passed to a downstream .NET console app.
|
|
// for example, the command line:
|
|
// foo.exe "myarg:""my val"""
|
|
// is parsed by a .NET console app into an arg array:
|
|
// [ "myarg:\"my val\"" ]
|
|
// which is the same end result when applying libuv quoting rules. although the actual
|
|
// command line from libuv quoting rules would look like:
|
|
// foo.exe "myarg:\"my val\""
|
|
//
|
|
// 3) double-up slashes that precede a quote,
|
|
// e.g. hello \world => "hello \world"
|
|
// hello\"world => "hello\\""world"
|
|
// hello\\"world => "hello\\\\""world"
|
|
// hello world\ => "hello world\\"
|
|
//
|
|
// technically this is not required for a cmd.exe command line, or the batch argument parser.
|
|
// the reasons for including this as a .cmd quoting rule are:
|
|
//
|
|
// a) this is optimized for the scenario where the argument is passed from the .cmd file to an
|
|
// external program. many programs (e.g. .NET console apps) rely on the slash-doubling rule.
|
|
//
|
|
// b) it's what we've been doing previously (by deferring to node default behavior) and we
|
|
// haven't heard any complaints about that aspect.
|
|
//
|
|
// note, a weakness of the quoting rules chosen here, is that % is not escaped. in fact, % cannot be
|
|
// escaped when used on the command line directly - even though within a .cmd file % can be escaped
|
|
// by using %%.
|
|
//
|
|
// the saving grace is, on the command line, %var% is left as-is if var is not defined. this contrasts
|
|
// the line parsing rules within a .cmd file, where if var is not defined it is replaced with nothing.
|
|
//
|
|
// one option that was explored was replacing % with ^% - i.e. %var% => ^%var^%. this hack would
|
|
// often work, since it is unlikely that var^ would exist, and the ^ character is removed when the
|
|
// variable is used. the problem, however, is that ^ is not removed when %* is used to pass the args
|
|
// to an external program.
|
|
//
|
|
// an unexplored potential solution for the % escaping problem, is to create a wrapper .cmd file.
|
|
// % can be escaped within a .cmd file.
|
|
let reverse = '"';
|
|
let quoteHit = true;
|
|
for (let i = arg.length; i > 0; i--) {
|
|
// walk the string in reverse
|
|
reverse += arg[i - 1];
|
|
if (quoteHit && arg[i - 1] === '\\') {
|
|
reverse += '\\'; // double the slash
|
|
}
|
|
else if (arg[i - 1] === '"') {
|
|
quoteHit = true;
|
|
reverse += '"'; // double the quote
|
|
}
|
|
else {
|
|
quoteHit = false;
|
|
}
|
|
}
|
|
reverse += '"';
|
|
return reverse
|
|
.split('')
|
|
.reverse()
|
|
.join('');
|
|
}
|
|
_uvQuoteCmdArg(arg) {
|
|
// Tool runner wraps child_process.spawn() and needs to apply the same quoting as
|
|
// Node in certain cases where the undocumented spawn option windowsVerbatimArguments
|
|
// is used.
|
|
//
|
|
// Since this function is a port of quote_cmd_arg from Node 4.x (technically, lib UV,
|
|
// see https://github.com/nodejs/node/blob/v4.x/deps/uv/src/win/process.c for details),
|
|
// pasting copyright notice from Node within this function:
|
|
//
|
|
// Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to
|
|
// deal in the Software without restriction, including without limitation the
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
// IN THE SOFTWARE.
|
|
if (!arg) {
|
|
// Need double quotation for empty argument
|
|
return '""';
|
|
}
|
|
if (!arg.includes(' ') && !arg.includes('\t') && !arg.includes('"')) {
|
|
// No quotation needed
|
|
return arg;
|
|
}
|
|
if (!arg.includes('"') && !arg.includes('\\')) {
|
|
// No embedded double quotes or backslashes, so I can just wrap
|
|
// quote marks around the whole thing.
|
|
return `"${arg}"`;
|
|
}
|
|
// Expected input/output:
|
|
// input : hello"world
|
|
// output: "hello\"world"
|
|
// input : hello""world
|
|
// output: "hello\"\"world"
|
|
// input : hello\world
|
|
// output: hello\world
|
|
// input : hello\\world
|
|
// output: hello\\world
|
|
// input : hello\"world
|
|
// output: "hello\\\"world"
|
|
// input : hello\\"world
|
|
// output: "hello\\\\\"world"
|
|
// input : hello world\
|
|
// output: "hello world\\" - note the comment in libuv actually reads "hello world\"
|
|
// but it appears the comment is wrong, it should be "hello world\\"
|
|
let reverse = '"';
|
|
let quoteHit = true;
|
|
for (let i = arg.length; i > 0; i--) {
|
|
// walk the string in reverse
|
|
reverse += arg[i - 1];
|
|
if (quoteHit && arg[i - 1] === '\\') {
|
|
reverse += '\\';
|
|
}
|
|
else if (arg[i - 1] === '"') {
|
|
quoteHit = true;
|
|
reverse += '\\';
|
|
}
|
|
else {
|
|
quoteHit = false;
|
|
}
|
|
}
|
|
reverse += '"';
|
|
return reverse
|
|
.split('')
|
|
.reverse()
|
|
.join('');
|
|
}
|
|
_cloneExecOptions(options) {
|
|
options = options || {};
|
|
const result = {
|
|
cwd: options.cwd || process.cwd(),
|
|
env: options.env || process.env,
|
|
silent: options.silent || false,
|
|
windowsVerbatimArguments: options.windowsVerbatimArguments || false,
|
|
failOnStdErr: options.failOnStdErr || false,
|
|
ignoreReturnCode: options.ignoreReturnCode || false,
|
|
delay: options.delay || 10000
|
|
};
|
|
result.outStream = options.outStream || process.stdout;
|
|
result.errStream = options.errStream || process.stderr;
|
|
return result;
|
|
}
|
|
_getSpawnOptions(options, toolPath) {
|
|
options = options || {};
|
|
const result = {};
|
|
result.cwd = options.cwd;
|
|
result.env = options.env;
|
|
result['windowsVerbatimArguments'] =
|
|
options.windowsVerbatimArguments || this._isCmdFile();
|
|
if (options.windowsVerbatimArguments) {
|
|
result.argv0 = `"${toolPath}"`;
|
|
}
|
|
return result;
|
|
}
|
|
/**
|
|
* Exec a tool.
|
|
* Output will be streamed to the live console.
|
|
* Returns promise with return code
|
|
*
|
|
* @param tool path to tool to exec
|
|
* @param options optional exec options. See ExecOptions
|
|
* @returns number
|
|
*/
|
|
exec() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
// root the tool path if it is unrooted and contains relative pathing
|
|
if (!ioUtil.isRooted(this.toolPath) &&
|
|
(this.toolPath.includes('/') ||
|
|
(IS_WINDOWS && this.toolPath.includes('\\')))) {
|
|
// prefer options.cwd if it is specified, however options.cwd may also need to be rooted
|
|
this.toolPath = path.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath);
|
|
}
|
|
// if the tool is only a file name, then resolve it from the PATH
|
|
// otherwise verify it exists (add extension on Windows if necessary)
|
|
this.toolPath = yield io.which(this.toolPath, true);
|
|
return new Promise((resolve, reject) => {
|
|
this._debug(`exec tool: ${this.toolPath}`);
|
|
this._debug('arguments:');
|
|
for (const arg of this.args) {
|
|
this._debug(` ${arg}`);
|
|
}
|
|
const optionsNonNull = this._cloneExecOptions(this.options);
|
|
if (!optionsNonNull.silent && optionsNonNull.outStream) {
|
|
optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL);
|
|
}
|
|
const state = new ExecState(optionsNonNull, this.toolPath);
|
|
state.on('debug', (message) => {
|
|
this._debug(message);
|
|
});
|
|
const fileName = this._getSpawnFileName();
|
|
const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
|
|
const stdbuffer = '';
|
|
if (cp.stdout) {
|
|
cp.stdout.on('data', (data) => {
|
|
if (this.options.listeners && this.options.listeners.stdout) {
|
|
this.options.listeners.stdout(data);
|
|
}
|
|
if (!optionsNonNull.silent && optionsNonNull.outStream) {
|
|
optionsNonNull.outStream.write(data);
|
|
}
|
|
this._processLineBuffer(data, stdbuffer, (line) => {
|
|
if (this.options.listeners && this.options.listeners.stdline) {
|
|
this.options.listeners.stdline(line);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
const errbuffer = '';
|
|
if (cp.stderr) {
|
|
cp.stderr.on('data', (data) => {
|
|
state.processStderr = true;
|
|
if (this.options.listeners && this.options.listeners.stderr) {
|
|
this.options.listeners.stderr(data);
|
|
}
|
|
if (!optionsNonNull.silent &&
|
|
optionsNonNull.errStream &&
|
|
optionsNonNull.outStream) {
|
|
const s = optionsNonNull.failOnStdErr
|
|
? optionsNonNull.errStream
|
|
: optionsNonNull.outStream;
|
|
s.write(data);
|
|
}
|
|
this._processLineBuffer(data, errbuffer, (line) => {
|
|
if (this.options.listeners && this.options.listeners.errline) {
|
|
this.options.listeners.errline(line);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
cp.on('error', (err) => {
|
|
state.processError = err.message;
|
|
state.processExited = true;
|
|
state.processClosed = true;
|
|
state.CheckComplete();
|
|
});
|
|
cp.on('exit', (code) => {
|
|
state.processExitCode = code;
|
|
state.processExited = true;
|
|
this._debug(`Exit code ${code} received from tool '${this.toolPath}'`);
|
|
state.CheckComplete();
|
|
});
|
|
cp.on('close', (code) => {
|
|
state.processExitCode = code;
|
|
state.processExited = true;
|
|
state.processClosed = true;
|
|
this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);
|
|
state.CheckComplete();
|
|
});
|
|
state.on('done', (error, exitCode) => {
|
|
if (stdbuffer.length > 0) {
|
|
this.emit('stdline', stdbuffer);
|
|
}
|
|
if (errbuffer.length > 0) {
|
|
this.emit('errline', errbuffer);
|
|
}
|
|
cp.removeAllListeners();
|
|
if (error) {
|
|
reject(error);
|
|
}
|
|
else {
|
|
resolve(exitCode);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}
|
|
exports.ToolRunner = ToolRunner;
|
|
/**
|
|
* Convert an arg string to an array of args. Handles escaping
|
|
*
|
|
* @param argString string of arguments
|
|
* @returns string[] array of arguments
|
|
*/
|
|
function argStringToArray(argString) {
|
|
const args = [];
|
|
let inQuotes = false;
|
|
let escaped = false;
|
|
let arg = '';
|
|
function append(c) {
|
|
// we only escape double quotes.
|
|
if (escaped && c !== '"') {
|
|
arg += '\\';
|
|
}
|
|
arg += c;
|
|
escaped = false;
|
|
}
|
|
for (let i = 0; i < argString.length; i++) {
|
|
const c = argString.charAt(i);
|
|
if (c === '"') {
|
|
if (!escaped) {
|
|
inQuotes = !inQuotes;
|
|
}
|
|
else {
|
|
append(c);
|
|
}
|
|
continue;
|
|
}
|
|
if (c === '\\' && escaped) {
|
|
append(c);
|
|
continue;
|
|
}
|
|
if (c === '\\' && inQuotes) {
|
|
escaped = true;
|
|
continue;
|
|
}
|
|
if (c === ' ' && !inQuotes) {
|
|
if (arg.length > 0) {
|
|
args.push(arg);
|
|
arg = '';
|
|
}
|
|
continue;
|
|
}
|
|
append(c);
|
|
}
|
|
if (arg.length > 0) {
|
|
args.push(arg.trim());
|
|
}
|
|
return args;
|
|
}
|
|
exports.argStringToArray = argStringToArray;
|
|
class ExecState extends events.EventEmitter {
|
|
constructor(options, toolPath) {
|
|
super();
|
|
this.processClosed = false; // tracks whether the process has exited and stdio is closed
|
|
this.processError = '';
|
|
this.processExitCode = 0;
|
|
this.processExited = false; // tracks whether the process has exited
|
|
this.processStderr = false; // tracks whether stderr was written to
|
|
this.delay = 10000; // 10 seconds
|
|
this.done = false;
|
|
this.timeout = null;
|
|
if (!toolPath) {
|
|
throw new Error('toolPath must not be empty');
|
|
}
|
|
this.options = options;
|
|
this.toolPath = toolPath;
|
|
if (options.delay) {
|
|
this.delay = options.delay;
|
|
}
|
|
}
|
|
CheckComplete() {
|
|
if (this.done) {
|
|
return;
|
|
}
|
|
if (this.processClosed) {
|
|
this._setResult();
|
|
}
|
|
else if (this.processExited) {
|
|
this.timeout = setTimeout(ExecState.HandleTimeout, this.delay, this);
|
|
}
|
|
}
|
|
_debug(message) {
|
|
this.emit('debug', message);
|
|
}
|
|
_setResult() {
|
|
// determine whether there is an error
|
|
let error;
|
|
if (this.processExited) {
|
|
if (this.processError) {
|
|
error = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`);
|
|
}
|
|
else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) {
|
|
error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`);
|
|
}
|
|
else if (this.processStderr && this.options.failOnStdErr) {
|
|
error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`);
|
|
}
|
|
}
|
|
// clear the timeout
|
|
if (this.timeout) {
|
|
clearTimeout(this.timeout);
|
|
this.timeout = null;
|
|
}
|
|
this.done = true;
|
|
this.emit('done', error, this.processExitCode);
|
|
}
|
|
static HandleTimeout(state) {
|
|
if (state.done) {
|
|
return;
|
|
}
|
|
if (!state.processClosed && state.processExited) {
|
|
const message = `The STDIO streams did not close within ${state.delay /
|
|
1000} seconds of the exit event from process '${state.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;
|
|
state._debug(message);
|
|
}
|
|
state._setResult();
|
|
}
|
|
}
|
|
//# sourceMappingURL=toolrunner.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 689:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
try {
|
|
var util = __webpack_require__(669);
|
|
/* istanbul ignore next */
|
|
if (typeof util.inherits !== 'function') throw '';
|
|
module.exports = util.inherits;
|
|
} catch (e) {
|
|
/* istanbul ignore next */
|
|
module.exports = __webpack_require__(315);
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 690:
|
|
/***/ (function(module) {
|
|
|
|
var BITMASK = [0, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF];
|
|
|
|
// returns a function that reads bits.
|
|
// takes a buffer iterator as input
|
|
module.exports = function bitIterator(nextBuffer) {
|
|
var bit = 0, byte = 0;
|
|
var bytes = nextBuffer();
|
|
var f = function(n) {
|
|
if (n === null && bit != 0) { // align to byte boundary
|
|
bit = 0
|
|
byte++;
|
|
return;
|
|
}
|
|
var result = 0;
|
|
while(n > 0) {
|
|
if (byte >= bytes.length) {
|
|
byte = 0;
|
|
bytes = nextBuffer();
|
|
}
|
|
var left = 8 - bit;
|
|
if (bit === 0 && n > 0)
|
|
f.bytesRead++;
|
|
if (n >= left) {
|
|
result <<= left;
|
|
result |= (BITMASK[left] & bytes[byte++]);
|
|
bit = 0;
|
|
n -= left;
|
|
} else {
|
|
result <<= n;
|
|
result |= ((bytes[byte] & (BITMASK[n] << (8 - n - bit))) >> (8 - n - bit));
|
|
bit += n;
|
|
n = 0;
|
|
}
|
|
}
|
|
return result;
|
|
};
|
|
f.bytesRead = 0;
|
|
return f;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 697:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
module.exports = (promise, onFinally) => {
|
|
onFinally = onFinally || (() => {});
|
|
|
|
return promise.then(
|
|
val => new Promise(resolve => {
|
|
resolve(onFinally());
|
|
}).then(() => val),
|
|
err => new Promise(resolve => {
|
|
resolve(onFinally());
|
|
}).then(() => {
|
|
throw err;
|
|
})
|
|
);
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 705:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const bufferStream = __webpack_require__(72);
|
|
|
|
function getStream(inputStream, opts) {
|
|
if (!inputStream) {
|
|
return Promise.reject(new Error('Expected a stream'));
|
|
}
|
|
|
|
opts = Object.assign({maxBuffer: Infinity}, opts);
|
|
|
|
const maxBuffer = opts.maxBuffer;
|
|
let stream;
|
|
let clean;
|
|
|
|
const p = new Promise((resolve, reject) => {
|
|
const error = err => {
|
|
if (err) { // null check
|
|
err.bufferedData = stream.getBufferedValue();
|
|
}
|
|
|
|
reject(err);
|
|
};
|
|
|
|
stream = bufferStream(opts);
|
|
inputStream.once('error', error);
|
|
inputStream.pipe(stream);
|
|
|
|
stream.on('data', () => {
|
|
if (stream.getBufferedLength() > maxBuffer) {
|
|
reject(new Error('maxBuffer exceeded'));
|
|
}
|
|
});
|
|
stream.once('error', error);
|
|
stream.on('end', resolve);
|
|
|
|
clean = () => {
|
|
// some streams doesn't implement the `stream.Readable` interface correctly
|
|
if (inputStream.unpipe) {
|
|
inputStream.unpipe(stream);
|
|
}
|
|
};
|
|
});
|
|
|
|
p.then(clean, clean);
|
|
|
|
return p.then(() => stream.getBufferedValue());
|
|
}
|
|
|
|
module.exports = getStream;
|
|
module.exports.buffer = (stream, opts) => getStream(stream, Object.assign({}, opts, {encoding: 'buffer'}));
|
|
module.exports.array = (stream, opts) => getStream(stream, Object.assign({}, opts, {array: true}));
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 716:
|
|
/***/ (function(__unusedmodule, exports) {
|
|
|
|
"use strict";
|
|
|
|
|
|
exports.stringToBytes = string => [...string].map(character => character.charCodeAt(0));
|
|
|
|
const uint8ArrayUtf8ByteString = (array, start, end) => {
|
|
return String.fromCharCode(...array.slice(start, end));
|
|
};
|
|
|
|
exports.readUInt64LE = (buffer, offset = 0) => {
|
|
let n = buffer[offset];
|
|
let mul = 1;
|
|
let i = 0;
|
|
|
|
while (++i < 8) {
|
|
mul *= 0x100;
|
|
n += buffer[offset + i] * mul;
|
|
}
|
|
|
|
return n;
|
|
};
|
|
|
|
exports.tarHeaderChecksumMatches = buffer => { // Does not check if checksum field characters are valid
|
|
if (buffer.length < 512) { // `tar` header size, cannot compute checksum without it
|
|
return false;
|
|
}
|
|
|
|
const MASK_8TH_BIT = 0x80;
|
|
|
|
let sum = 256; // Intitalize sum, with 256 as sum of 8 spaces in checksum field
|
|
let signedBitSum = 0; // Initialize signed bit sum
|
|
|
|
for (let i = 0; i < 148; i++) {
|
|
const byte = buffer[i];
|
|
sum += byte;
|
|
signedBitSum += byte & MASK_8TH_BIT; // Add signed bit to signed bit sum
|
|
}
|
|
|
|
// Skip checksum field
|
|
|
|
for (let i = 156; i < 512; i++) {
|
|
const byte = buffer[i];
|
|
sum += byte;
|
|
signedBitSum += byte & MASK_8TH_BIT; // Add signed bit to signed bit sum
|
|
}
|
|
|
|
const readSum = parseInt(uint8ArrayUtf8ByteString(buffer, 148, 154), 8); // Read sum in header
|
|
|
|
// Some implementations compute checksum incorrectly using signed bytes
|
|
return (
|
|
// Checksum in header equals the sum we calculated
|
|
readSum === sum ||
|
|
|
|
// Checksum in header equals sum we calculated plus signed-to-unsigned delta
|
|
readSum === (sum - (signedBitSum << 1))
|
|
);
|
|
};
|
|
|
|
exports.uint8ArrayUtf8ByteString = uint8ArrayUtf8ByteString;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 718:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var stream = __webpack_require__(413);
|
|
|
|
function DuplexWrapper(options, writable, readable) {
|
|
if (typeof readable === "undefined") {
|
|
readable = writable;
|
|
writable = options;
|
|
options = null;
|
|
}
|
|
|
|
stream.Duplex.call(this, options);
|
|
|
|
if (typeof readable.read !== "function") {
|
|
readable = (new stream.Readable(options)).wrap(readable);
|
|
}
|
|
|
|
this._writable = writable;
|
|
this._readable = readable;
|
|
this._waiting = false;
|
|
|
|
var self = this;
|
|
|
|
writable.once("finish", function() {
|
|
self.end();
|
|
});
|
|
|
|
this.once("finish", function() {
|
|
writable.end();
|
|
});
|
|
|
|
readable.on("readable", function() {
|
|
if (self._waiting) {
|
|
self._waiting = false;
|
|
self._read();
|
|
}
|
|
});
|
|
|
|
readable.once("end", function() {
|
|
self.push(null);
|
|
});
|
|
|
|
if (!options || typeof options.bubbleErrors === "undefined" || options.bubbleErrors) {
|
|
writable.on("error", function(err) {
|
|
self.emit("error", err);
|
|
});
|
|
|
|
readable.on("error", function(err) {
|
|
self.emit("error", err);
|
|
});
|
|
}
|
|
}
|
|
|
|
DuplexWrapper.prototype = Object.create(stream.Duplex.prototype, {constructor: {value: DuplexWrapper}});
|
|
|
|
DuplexWrapper.prototype._write = function _write(input, encoding, done) {
|
|
this._writable.write(input, encoding, done);
|
|
};
|
|
|
|
DuplexWrapper.prototype._read = function _read() {
|
|
var buf;
|
|
var reads = 0;
|
|
while ((buf = this._readable.read()) !== null) {
|
|
this.push(buf);
|
|
reads++;
|
|
}
|
|
if (reads === 0) {
|
|
this._waiting = true;
|
|
}
|
|
};
|
|
|
|
module.exports = function duplex2(options, writable, readable) {
|
|
return new DuplexWrapper(options, writable, readable);
|
|
};
|
|
|
|
module.exports.DuplexWrapper = DuplexWrapper;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 722:
|
|
/***/ (function(module) {
|
|
|
|
/**
|
|
* Convert array of 16 byte values to UUID string format of the form:
|
|
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
*/
|
|
var byteToHex = [];
|
|
for (var i = 0; i < 256; ++i) {
|
|
byteToHex[i] = (i + 0x100).toString(16).substr(1);
|
|
}
|
|
|
|
function bytesToUuid(buf, offset) {
|
|
var i = offset || 0;
|
|
var bth = byteToHex;
|
|
// join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
|
|
return ([bth[buf[i++]], bth[buf[i++]],
|
|
bth[buf[i++]], bth[buf[i++]], '-',
|
|
bth[buf[i++]], bth[buf[i++]], '-',
|
|
bth[buf[i++]], bth[buf[i++]], '-',
|
|
bth[buf[i++]], bth[buf[i++]], '-',
|
|
bth[buf[i++]], bth[buf[i++]],
|
|
bth[buf[i++]], bth[buf[i++]],
|
|
bth[buf[i++]], bth[buf[i++]]]).join('');
|
|
}
|
|
|
|
module.exports = bytesToUuid;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 727:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
var toString = Object.prototype.toString;
|
|
|
|
module.exports = function (x) {
|
|
var prototype;
|
|
return toString.call(x) === '[object Object]' && (prototype = Object.getPrototypeOf(x), prototype === null || prototype === Object.getPrototypeOf({}));
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 729:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const qs = __webpack_require__(386);
|
|
const url = __webpack_require__(835);
|
|
const path = __webpack_require__(622);
|
|
const zlib = __webpack_require__(761);
|
|
/**
|
|
* creates an url from a request url and optional base url (http://server:8080)
|
|
* @param {string} resource - a fully qualified url or relative path
|
|
* @param {string} baseUrl - an optional baseUrl (http://server:8080)
|
|
* @param {IRequestOptions} options - an optional options object, could include QueryParameters e.g.
|
|
* @return {string} - resultant url
|
|
*/
|
|
function getUrl(resource, baseUrl, queryParams) {
|
|
const pathApi = path.posix || path;
|
|
let requestUrl = '';
|
|
if (!baseUrl) {
|
|
requestUrl = resource;
|
|
}
|
|
else if (!resource) {
|
|
requestUrl = baseUrl;
|
|
}
|
|
else {
|
|
const base = url.parse(baseUrl);
|
|
const resultantUrl = url.parse(resource);
|
|
// resource (specific per request) elements take priority
|
|
resultantUrl.protocol = resultantUrl.protocol || base.protocol;
|
|
resultantUrl.auth = resultantUrl.auth || base.auth;
|
|
resultantUrl.host = resultantUrl.host || base.host;
|
|
resultantUrl.pathname = pathApi.resolve(base.pathname, resultantUrl.pathname);
|
|
if (!resultantUrl.pathname.endsWith('/') && resource.endsWith('/')) {
|
|
resultantUrl.pathname += '/';
|
|
}
|
|
requestUrl = url.format(resultantUrl);
|
|
}
|
|
return queryParams ?
|
|
getUrlWithParsedQueryParams(requestUrl, queryParams) :
|
|
requestUrl;
|
|
}
|
|
exports.getUrl = getUrl;
|
|
/**
|
|
*
|
|
* @param {string} requestUrl
|
|
* @param {IRequestQueryParams} queryParams
|
|
* @return {string} - Request's URL with Query Parameters appended/parsed.
|
|
*/
|
|
function getUrlWithParsedQueryParams(requestUrl, queryParams) {
|
|
const url = requestUrl.replace(/\?$/g, ''); // Clean any extra end-of-string "?" character
|
|
const parsedQueryParams = qs.stringify(queryParams.params, buildParamsStringifyOptions(queryParams));
|
|
return `${url}${parsedQueryParams}`;
|
|
}
|
|
/**
|
|
* Build options for QueryParams Stringifying.
|
|
*
|
|
* @param {IRequestQueryParams} queryParams
|
|
* @return {object}
|
|
*/
|
|
function buildParamsStringifyOptions(queryParams) {
|
|
let options = {
|
|
addQueryPrefix: true,
|
|
delimiter: (queryParams.options || {}).separator || '&',
|
|
allowDots: (queryParams.options || {}).shouldAllowDots || false,
|
|
arrayFormat: (queryParams.options || {}).arrayFormat || 'repeat',
|
|
encodeValuesOnly: (queryParams.options || {}).shouldOnlyEncodeValues || true
|
|
};
|
|
return options;
|
|
}
|
|
/**
|
|
* Decompress/Decode gzip encoded JSON
|
|
* Using Node.js built-in zlib module
|
|
*
|
|
* @param {Buffer} buffer
|
|
* @param {string} charset? - optional; defaults to 'utf-8'
|
|
* @return {Promise<string>}
|
|
*/
|
|
function decompressGzippedContent(buffer, charset) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
zlib.gunzip(buffer, function (error, buffer) {
|
|
if (error) {
|
|
reject(error);
|
|
}
|
|
resolve(buffer.toString(charset || 'utf-8'));
|
|
});
|
|
}));
|
|
});
|
|
}
|
|
exports.decompressGzippedContent = decompressGzippedContent;
|
|
/**
|
|
* Obtain Response's Content Charset.
|
|
* Through inspecting `content-type` response header.
|
|
* It Returns 'utf-8' if NO charset specified/matched.
|
|
*
|
|
* @param {IHttpClientResponse} response
|
|
* @return {string} - Content Encoding Charset; Default=utf-8
|
|
*/
|
|
function obtainContentCharset(response) {
|
|
// Find the charset, if specified.
|
|
// Search for the `charset=CHARSET` string, not including `;,\r\n`
|
|
// Example: content-type: 'application/json;charset=utf-8'
|
|
// |__ matches would be ['charset=utf-8', 'utf-8', index: 18, input: 'application/json; charset=utf-8']
|
|
// |_____ matches[1] would have the charset :tada: , in our example it's utf-8
|
|
// However, if the matches Array was empty or no charset found, 'utf-8' would be returned by default.
|
|
const nodeSupportedEncodings = ['ascii', 'utf8', 'utf16le', 'ucs2', 'base64', 'binary', 'hex'];
|
|
const contentType = response.message.headers['content-type'] || '';
|
|
const matches = contentType.match(/charset=([^;,\r\n]+)/i);
|
|
return (matches && matches[1] && nodeSupportedEncodings.indexOf(matches[1]) != -1) ? matches[1] : 'utf-8';
|
|
}
|
|
exports.obtainContentCharset = obtainContentCharset;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 741:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const isPlainObj = __webpack_require__(727);
|
|
|
|
module.exports = (obj, opts) => {
|
|
if (!isPlainObj(obj)) {
|
|
throw new TypeError('Expected a plain object');
|
|
}
|
|
|
|
opts = opts || {};
|
|
|
|
// DEPRECATED
|
|
if (typeof opts === 'function') {
|
|
throw new TypeError('Specify the compare function as an option instead');
|
|
}
|
|
|
|
const deep = opts.deep;
|
|
const seenInput = [];
|
|
const seenOutput = [];
|
|
|
|
const sortKeys = x => {
|
|
const seenIndex = seenInput.indexOf(x);
|
|
|
|
if (seenIndex !== -1) {
|
|
return seenOutput[seenIndex];
|
|
}
|
|
|
|
const ret = {};
|
|
const keys = Object.keys(x).sort(opts.compare);
|
|
|
|
seenInput.push(x);
|
|
seenOutput.push(ret);
|
|
|
|
for (let i = 0; i < keys.length; i++) {
|
|
const key = keys[i];
|
|
const val = x[key];
|
|
|
|
if (deep && Array.isArray(val)) {
|
|
const retArr = [];
|
|
|
|
for (let j = 0; j < val.length; j++) {
|
|
retArr[j] = isPlainObj(val[j]) ? sortKeys(val[j]) : val[j];
|
|
}
|
|
|
|
ret[key] = retArr;
|
|
continue;
|
|
}
|
|
|
|
ret[key] = deep && isPlainObj(val) ? sortKeys(val) : val;
|
|
}
|
|
|
|
return ret;
|
|
};
|
|
|
|
return sortKeys(obj);
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 747:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("fs");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 749:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
result["default"] = mod;
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const download = __importStar(__webpack_require__(927));
|
|
const fs = __importStar(__webpack_require__(747));
|
|
const os = __importStar(__webpack_require__(87));
|
|
const path = __importStar(__webpack_require__(622));
|
|
const util = __importStar(__webpack_require__(669));
|
|
const restm = __importStar(__webpack_require__(105));
|
|
const core = __importStar(__webpack_require__(470));
|
|
const tc = __importStar(__webpack_require__(533));
|
|
let osPlat = os.platform();
|
|
let osArch = os.arch();
|
|
function getUPX(version) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const selected = yield determineVersion(version);
|
|
if (selected) {
|
|
version = selected;
|
|
}
|
|
core.info(`✅ UPX version found: ${version}`);
|
|
const tmpdir = fs.mkdtempSync(path.join(os.tmpdir(), 'upx-'));
|
|
const fileName = getFileName(version);
|
|
const downloadUrl = util.format('https://github.com/upx/upx/releases/download/v%s/%s', version, fileName);
|
|
core.info(`⬇️ Downloading ${downloadUrl}...`);
|
|
yield download.default(downloadUrl, tmpdir, { filename: fileName });
|
|
core.info('📦 Extracting UPX...');
|
|
let extPath = tmpdir;
|
|
if (osPlat == 'win32') {
|
|
extPath = yield tc.extractZip(`${tmpdir}/${fileName}`);
|
|
}
|
|
else {
|
|
extPath = yield tc.extractTar(`${tmpdir}/${fileName}`, undefined, 'x');
|
|
}
|
|
return path.join(extPath, getFileNameWithoutExt(version), osPlat == 'win32' ? 'upx.exe' : 'upx');
|
|
});
|
|
}
|
|
exports.getUPX = getUPX;
|
|
function getFileName(version) {
|
|
const ext = osPlat == 'win32' ? 'zip' : 'tar.xz';
|
|
return util.format('%s.%s', getFileNameWithoutExt(version), ext);
|
|
}
|
|
function getFileNameWithoutExt(version) {
|
|
let platform = '';
|
|
if (osPlat == 'win32') {
|
|
platform = osArch == 'x64' ? 'win64' : 'win32';
|
|
}
|
|
else if (osPlat == 'linux') {
|
|
platform = osArch == 'x64' ? 'amd64_linux' : 'i386_linux';
|
|
}
|
|
return util.format('upx-%s-%s', version, platform);
|
|
}
|
|
function determineVersion(version) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
let rest = new restm.RestClient('ghaction-upx', 'https://github.com', undefined, {
|
|
headers: {
|
|
Accept: 'application/json'
|
|
}
|
|
});
|
|
if (version !== 'latest') {
|
|
version = `v${version}`;
|
|
}
|
|
let res = yield rest.get(`/upx/upx/releases/${version}`);
|
|
if (res.statusCode != 200 || res.result === null) {
|
|
throw new Error(`Cannot find UPX ${version} release (http ${res.statusCode})`);
|
|
}
|
|
return res.result.tag_name.replace(/^v/, '');
|
|
});
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 755:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var utils = __webpack_require__(581);
|
|
|
|
var has = Object.prototype.hasOwnProperty;
|
|
var isArray = Array.isArray;
|
|
|
|
var defaults = {
|
|
allowDots: false,
|
|
allowPrototypes: false,
|
|
arrayLimit: 20,
|
|
charset: 'utf-8',
|
|
charsetSentinel: false,
|
|
comma: false,
|
|
decoder: utils.decode,
|
|
delimiter: '&',
|
|
depth: 5,
|
|
ignoreQueryPrefix: false,
|
|
interpretNumericEntities: false,
|
|
parameterLimit: 1000,
|
|
parseArrays: true,
|
|
plainObjects: false,
|
|
strictNullHandling: false
|
|
};
|
|
|
|
var interpretNumericEntities = function (str) {
|
|
return str.replace(/&#(\d+);/g, function ($0, numberStr) {
|
|
return String.fromCharCode(parseInt(numberStr, 10));
|
|
});
|
|
};
|
|
|
|
var parseArrayValue = function (val, options) {
|
|
if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
|
|
return val.split(',');
|
|
}
|
|
|
|
return val;
|
|
};
|
|
|
|
var maybeMap = function maybeMap(val, fn) {
|
|
if (isArray(val)) {
|
|
var mapped = [];
|
|
for (var i = 0; i < val.length; i += 1) {
|
|
mapped.push(fn(val[i]));
|
|
}
|
|
return mapped;
|
|
}
|
|
return fn(val);
|
|
};
|
|
|
|
// This is what browsers will submit when the ✓ character occurs in an
|
|
// application/x-www-form-urlencoded body and the encoding of the page containing
|
|
// the form is iso-8859-1, or when the submitted form has an accept-charset
|
|
// attribute of iso-8859-1. Presumably also with other charsets that do not contain
|
|
// the ✓ character, such as us-ascii.
|
|
var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓')
|
|
|
|
// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
|
|
var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
|
|
|
|
var parseValues = function parseQueryStringValues(str, options) {
|
|
var obj = {};
|
|
var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
|
|
var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
|
|
var parts = cleanStr.split(options.delimiter, limit);
|
|
var skipIndex = -1; // Keep track of where the utf8 sentinel was found
|
|
var i;
|
|
|
|
var charset = options.charset;
|
|
if (options.charsetSentinel) {
|
|
for (i = 0; i < parts.length; ++i) {
|
|
if (parts[i].indexOf('utf8=') === 0) {
|
|
if (parts[i] === charsetSentinel) {
|
|
charset = 'utf-8';
|
|
} else if (parts[i] === isoSentinel) {
|
|
charset = 'iso-8859-1';
|
|
}
|
|
skipIndex = i;
|
|
i = parts.length; // The eslint settings do not allow break;
|
|
}
|
|
}
|
|
}
|
|
|
|
for (i = 0; i < parts.length; ++i) {
|
|
if (i === skipIndex) {
|
|
continue;
|
|
}
|
|
var part = parts[i];
|
|
|
|
var bracketEqualsPos = part.indexOf(']=');
|
|
var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
|
|
|
|
var key, val;
|
|
if (pos === -1) {
|
|
key = options.decoder(part, defaults.decoder, charset, 'key');
|
|
val = options.strictNullHandling ? null : '';
|
|
} else {
|
|
key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key');
|
|
val = maybeMap(
|
|
parseArrayValue(part.slice(pos + 1), options),
|
|
function (encodedVal) {
|
|
return options.decoder(encodedVal, defaults.decoder, charset, 'value');
|
|
}
|
|
);
|
|
}
|
|
|
|
if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
|
|
val = interpretNumericEntities(val);
|
|
}
|
|
|
|
if (part.indexOf('[]=') > -1) {
|
|
val = isArray(val) ? [val] : val;
|
|
}
|
|
|
|
if (has.call(obj, key)) {
|
|
obj[key] = utils.combine(obj[key], val);
|
|
} else {
|
|
obj[key] = val;
|
|
}
|
|
}
|
|
|
|
return obj;
|
|
};
|
|
|
|
var parseObject = function (chain, val, options, valuesParsed) {
|
|
var leaf = valuesParsed ? val : parseArrayValue(val, options);
|
|
|
|
for (var i = chain.length - 1; i >= 0; --i) {
|
|
var obj;
|
|
var root = chain[i];
|
|
|
|
if (root === '[]' && options.parseArrays) {
|
|
obj = [].concat(leaf);
|
|
} else {
|
|
obj = options.plainObjects ? Object.create(null) : {};
|
|
var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
|
|
var index = parseInt(cleanRoot, 10);
|
|
if (!options.parseArrays && cleanRoot === '') {
|
|
obj = { 0: leaf };
|
|
} else if (
|
|
!isNaN(index)
|
|
&& root !== cleanRoot
|
|
&& String(index) === cleanRoot
|
|
&& index >= 0
|
|
&& (options.parseArrays && index <= options.arrayLimit)
|
|
) {
|
|
obj = [];
|
|
obj[index] = leaf;
|
|
} else {
|
|
obj[cleanRoot] = leaf;
|
|
}
|
|
}
|
|
|
|
leaf = obj; // eslint-disable-line no-param-reassign
|
|
}
|
|
|
|
return leaf;
|
|
};
|
|
|
|
var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
|
|
if (!givenKey) {
|
|
return;
|
|
}
|
|
|
|
// Transform dot notation to bracket notation
|
|
var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
|
|
|
|
// The regex chunks
|
|
|
|
var brackets = /(\[[^[\]]*])/;
|
|
var child = /(\[[^[\]]*])/g;
|
|
|
|
// Get the parent
|
|
|
|
var segment = options.depth > 0 && brackets.exec(key);
|
|
var parent = segment ? key.slice(0, segment.index) : key;
|
|
|
|
// Stash the parent if it exists
|
|
|
|
var keys = [];
|
|
if (parent) {
|
|
// If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
|
|
if (!options.plainObjects && has.call(Object.prototype, parent)) {
|
|
if (!options.allowPrototypes) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
keys.push(parent);
|
|
}
|
|
|
|
// Loop through children appending to the array until we hit depth
|
|
|
|
var i = 0;
|
|
while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
|
|
i += 1;
|
|
if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
|
|
if (!options.allowPrototypes) {
|
|
return;
|
|
}
|
|
}
|
|
keys.push(segment[1]);
|
|
}
|
|
|
|
// If there's a remainder, just add whatever is left
|
|
|
|
if (segment) {
|
|
keys.push('[' + key.slice(segment.index) + ']');
|
|
}
|
|
|
|
return parseObject(keys, val, options, valuesParsed);
|
|
};
|
|
|
|
var normalizeParseOptions = function normalizeParseOptions(opts) {
|
|
if (!opts) {
|
|
return defaults;
|
|
}
|
|
|
|
if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
|
|
throw new TypeError('Decoder has to be a function.');
|
|
}
|
|
|
|
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
|
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
|
|
}
|
|
var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
|
|
|
|
return {
|
|
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
|
|
allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
|
|
arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
|
|
charset: charset,
|
|
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
|
|
comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma,
|
|
decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder,
|
|
delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter,
|
|
// eslint-disable-next-line no-implicit-coercion, no-extra-parens
|
|
depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth,
|
|
ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
|
|
interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities,
|
|
parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit,
|
|
parseArrays: opts.parseArrays !== false,
|
|
plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects,
|
|
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
|
|
};
|
|
};
|
|
|
|
module.exports = function (str, opts) {
|
|
var options = normalizeParseOptions(opts);
|
|
|
|
if (str === '' || str === null || typeof str === 'undefined') {
|
|
return options.plainObjects ? Object.create(null) : {};
|
|
}
|
|
|
|
var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
|
|
var obj = options.plainObjects ? Object.create(null) : {};
|
|
|
|
// Iterate over the keys and setup the new object
|
|
|
|
var keys = Object.keys(tempObj);
|
|
for (var i = 0; i < keys.length; ++i) {
|
|
var key = keys[i];
|
|
var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
|
|
obj = utils.merge(obj, newObj, options);
|
|
}
|
|
|
|
return utils.compact(obj);
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 761:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("zlib");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 766:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
var fs = __webpack_require__(747);
|
|
var zlib = __webpack_require__(761);
|
|
var fd_slicer = __webpack_require__(324);
|
|
var crc32 = __webpack_require__(538);
|
|
var util = __webpack_require__(669);
|
|
var EventEmitter = __webpack_require__(614).EventEmitter;
|
|
var Transform = __webpack_require__(413).Transform;
|
|
var PassThrough = __webpack_require__(413).PassThrough;
|
|
var Writable = __webpack_require__(413).Writable;
|
|
|
|
exports.open = open;
|
|
exports.fromFd = fromFd;
|
|
exports.fromBuffer = fromBuffer;
|
|
exports.fromRandomAccessReader = fromRandomAccessReader;
|
|
exports.dosDateTimeToDate = dosDateTimeToDate;
|
|
exports.validateFileName = validateFileName;
|
|
exports.ZipFile = ZipFile;
|
|
exports.Entry = Entry;
|
|
exports.RandomAccessReader = RandomAccessReader;
|
|
|
|
function open(path, options, callback) {
|
|
if (typeof options === "function") {
|
|
callback = options;
|
|
options = null;
|
|
}
|
|
if (options == null) options = {};
|
|
if (options.autoClose == null) options.autoClose = true;
|
|
if (options.lazyEntries == null) options.lazyEntries = false;
|
|
if (options.decodeStrings == null) options.decodeStrings = true;
|
|
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
if (callback == null) callback = defaultCallback;
|
|
fs.open(path, "r", function(err, fd) {
|
|
if (err) return callback(err);
|
|
fromFd(fd, options, function(err, zipfile) {
|
|
if (err) fs.close(fd, defaultCallback);
|
|
callback(err, zipfile);
|
|
});
|
|
});
|
|
}
|
|
|
|
function fromFd(fd, options, callback) {
|
|
if (typeof options === "function") {
|
|
callback = options;
|
|
options = null;
|
|
}
|
|
if (options == null) options = {};
|
|
if (options.autoClose == null) options.autoClose = false;
|
|
if (options.lazyEntries == null) options.lazyEntries = false;
|
|
if (options.decodeStrings == null) options.decodeStrings = true;
|
|
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
if (callback == null) callback = defaultCallback;
|
|
fs.fstat(fd, function(err, stats) {
|
|
if (err) return callback(err);
|
|
var reader = fd_slicer.createFromFd(fd, {autoClose: true});
|
|
fromRandomAccessReader(reader, stats.size, options, callback);
|
|
});
|
|
}
|
|
|
|
function fromBuffer(buffer, options, callback) {
|
|
if (typeof options === "function") {
|
|
callback = options;
|
|
options = null;
|
|
}
|
|
if (options == null) options = {};
|
|
options.autoClose = false;
|
|
if (options.lazyEntries == null) options.lazyEntries = false;
|
|
if (options.decodeStrings == null) options.decodeStrings = true;
|
|
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
// limit the max chunk size. see https://github.com/thejoshwolfe/yauzl/issues/87
|
|
var reader = fd_slicer.createFromBuffer(buffer, {maxChunkSize: 0x10000});
|
|
fromRandomAccessReader(reader, buffer.length, options, callback);
|
|
}
|
|
|
|
function fromRandomAccessReader(reader, totalSize, options, callback) {
|
|
if (typeof options === "function") {
|
|
callback = options;
|
|
options = null;
|
|
}
|
|
if (options == null) options = {};
|
|
if (options.autoClose == null) options.autoClose = true;
|
|
if (options.lazyEntries == null) options.lazyEntries = false;
|
|
if (options.decodeStrings == null) options.decodeStrings = true;
|
|
var decodeStrings = !!options.decodeStrings;
|
|
if (options.validateEntrySizes == null) options.validateEntrySizes = true;
|
|
if (options.strictFileNames == null) options.strictFileNames = false;
|
|
if (callback == null) callback = defaultCallback;
|
|
if (typeof totalSize !== "number") throw new Error("expected totalSize parameter to be a number");
|
|
if (totalSize > Number.MAX_SAFE_INTEGER) {
|
|
throw new Error("zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.");
|
|
}
|
|
|
|
// the matching unref() call is in zipfile.close()
|
|
reader.ref();
|
|
|
|
// eocdr means End of Central Directory Record.
|
|
// search backwards for the eocdr signature.
|
|
// the last field of the eocdr is a variable-length comment.
|
|
// the comment size is encoded in a 2-byte field in the eocdr, which we can't find without trudging backwards through the comment to find it.
|
|
// as a consequence of this design decision, it's possible to have ambiguous zip file metadata if a coherent eocdr was in the comment.
|
|
// we search backwards for a eocdr signature, and hope that whoever made the zip file was smart enough to forbid the eocdr signature in the comment.
|
|
var eocdrWithoutCommentSize = 22;
|
|
var maxCommentSize = 0xffff; // 2-byte size
|
|
var bufferSize = Math.min(eocdrWithoutCommentSize + maxCommentSize, totalSize);
|
|
var buffer = newBuffer(bufferSize);
|
|
var bufferReadStart = totalSize - buffer.length;
|
|
readAndAssertNoEof(reader, buffer, 0, bufferSize, bufferReadStart, function(err) {
|
|
if (err) return callback(err);
|
|
for (var i = bufferSize - eocdrWithoutCommentSize; i >= 0; i -= 1) {
|
|
if (buffer.readUInt32LE(i) !== 0x06054b50) continue;
|
|
// found eocdr
|
|
var eocdrBuffer = buffer.slice(i);
|
|
|
|
// 0 - End of central directory signature = 0x06054b50
|
|
// 4 - Number of this disk
|
|
var diskNumber = eocdrBuffer.readUInt16LE(4);
|
|
if (diskNumber !== 0) {
|
|
return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
|
|
}
|
|
// 6 - Disk where central directory starts
|
|
// 8 - Number of central directory records on this disk
|
|
// 10 - Total number of central directory records
|
|
var entryCount = eocdrBuffer.readUInt16LE(10);
|
|
// 12 - Size of central directory (bytes)
|
|
// 16 - Offset of start of central directory, relative to start of archive
|
|
var centralDirectoryOffset = eocdrBuffer.readUInt32LE(16);
|
|
// 20 - Comment length
|
|
var commentLength = eocdrBuffer.readUInt16LE(20);
|
|
var expectedCommentLength = eocdrBuffer.length - eocdrWithoutCommentSize;
|
|
if (commentLength !== expectedCommentLength) {
|
|
return callback(new Error("invalid comment length. expected: " + expectedCommentLength + ". found: " + commentLength));
|
|
}
|
|
// 22 - Comment
|
|
// the encoding is always cp437.
|
|
var comment = decodeStrings ? decodeBuffer(eocdrBuffer, 22, eocdrBuffer.length, false)
|
|
: eocdrBuffer.slice(22);
|
|
|
|
if (!(entryCount === 0xffff || centralDirectoryOffset === 0xffffffff)) {
|
|
return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
|
|
}
|
|
|
|
// ZIP64 format
|
|
|
|
// ZIP64 Zip64 end of central directory locator
|
|
var zip64EocdlBuffer = newBuffer(20);
|
|
var zip64EocdlOffset = bufferReadStart + i - zip64EocdlBuffer.length;
|
|
readAndAssertNoEof(reader, zip64EocdlBuffer, 0, zip64EocdlBuffer.length, zip64EocdlOffset, function(err) {
|
|
if (err) return callback(err);
|
|
|
|
// 0 - zip64 end of central dir locator signature = 0x07064b50
|
|
if (zip64EocdlBuffer.readUInt32LE(0) !== 0x07064b50) {
|
|
return callback(new Error("invalid zip64 end of central directory locator signature"));
|
|
}
|
|
// 4 - number of the disk with the start of the zip64 end of central directory
|
|
// 8 - relative offset of the zip64 end of central directory record
|
|
var zip64EocdrOffset = readUInt64LE(zip64EocdlBuffer, 8);
|
|
// 16 - total number of disks
|
|
|
|
// ZIP64 end of central directory record
|
|
var zip64EocdrBuffer = newBuffer(56);
|
|
readAndAssertNoEof(reader, zip64EocdrBuffer, 0, zip64EocdrBuffer.length, zip64EocdrOffset, function(err) {
|
|
if (err) return callback(err);
|
|
|
|
// 0 - zip64 end of central dir signature 4 bytes (0x06064b50)
|
|
if (zip64EocdrBuffer.readUInt32LE(0) !== 0x06064b50) {
|
|
return callback(new Error("invalid zip64 end of central directory record signature"));
|
|
}
|
|
// 4 - size of zip64 end of central directory record 8 bytes
|
|
// 12 - version made by 2 bytes
|
|
// 14 - version needed to extract 2 bytes
|
|
// 16 - number of this disk 4 bytes
|
|
// 20 - number of the disk with the start of the central directory 4 bytes
|
|
// 24 - total number of entries in the central directory on this disk 8 bytes
|
|
// 32 - total number of entries in the central directory 8 bytes
|
|
entryCount = readUInt64LE(zip64EocdrBuffer, 32);
|
|
// 40 - size of the central directory 8 bytes
|
|
// 48 - offset of start of central directory with respect to the starting disk number 8 bytes
|
|
centralDirectoryOffset = readUInt64LE(zip64EocdrBuffer, 48);
|
|
// 56 - zip64 extensible data sector (variable size)
|
|
return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
|
|
});
|
|
});
|
|
return;
|
|
}
|
|
callback(new Error("end of central directory record signature not found"));
|
|
});
|
|
}
|
|
|
|
util.inherits(ZipFile, EventEmitter);
|
|
function ZipFile(reader, centralDirectoryOffset, fileSize, entryCount, comment, autoClose, lazyEntries, decodeStrings, validateEntrySizes, strictFileNames) {
|
|
var self = this;
|
|
EventEmitter.call(self);
|
|
self.reader = reader;
|
|
// forward close events
|
|
self.reader.on("error", function(err) {
|
|
// error closing the fd
|
|
emitError(self, err);
|
|
});
|
|
self.reader.once("close", function() {
|
|
self.emit("close");
|
|
});
|
|
self.readEntryCursor = centralDirectoryOffset;
|
|
self.fileSize = fileSize;
|
|
self.entryCount = entryCount;
|
|
self.comment = comment;
|
|
self.entriesRead = 0;
|
|
self.autoClose = !!autoClose;
|
|
self.lazyEntries = !!lazyEntries;
|
|
self.decodeStrings = !!decodeStrings;
|
|
self.validateEntrySizes = !!validateEntrySizes;
|
|
self.strictFileNames = !!strictFileNames;
|
|
self.isOpen = true;
|
|
self.emittedError = false;
|
|
|
|
if (!self.lazyEntries) self._readEntry();
|
|
}
|
|
ZipFile.prototype.close = function() {
|
|
if (!this.isOpen) return;
|
|
this.isOpen = false;
|
|
this.reader.unref();
|
|
};
|
|
|
|
function emitErrorAndAutoClose(self, err) {
|
|
if (self.autoClose) self.close();
|
|
emitError(self, err);
|
|
}
|
|
function emitError(self, err) {
|
|
if (self.emittedError) return;
|
|
self.emittedError = true;
|
|
self.emit("error", err);
|
|
}
|
|
|
|
ZipFile.prototype.readEntry = function() {
|
|
if (!this.lazyEntries) throw new Error("readEntry() called without lazyEntries:true");
|
|
this._readEntry();
|
|
};
|
|
ZipFile.prototype._readEntry = function() {
|
|
var self = this;
|
|
if (self.entryCount === self.entriesRead) {
|
|
// done with metadata
|
|
setImmediate(function() {
|
|
if (self.autoClose) self.close();
|
|
if (self.emittedError) return;
|
|
self.emit("end");
|
|
});
|
|
return;
|
|
}
|
|
if (self.emittedError) return;
|
|
var buffer = newBuffer(46);
|
|
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err) {
|
|
if (err) return emitErrorAndAutoClose(self, err);
|
|
if (self.emittedError) return;
|
|
var entry = new Entry();
|
|
// 0 - Central directory file header signature
|
|
var signature = buffer.readUInt32LE(0);
|
|
if (signature !== 0x02014b50) return emitErrorAndAutoClose(self, new Error("invalid central directory file header signature: 0x" + signature.toString(16)));
|
|
// 4 - Version made by
|
|
entry.versionMadeBy = buffer.readUInt16LE(4);
|
|
// 6 - Version needed to extract (minimum)
|
|
entry.versionNeededToExtract = buffer.readUInt16LE(6);
|
|
// 8 - General purpose bit flag
|
|
entry.generalPurposeBitFlag = buffer.readUInt16LE(8);
|
|
// 10 - Compression method
|
|
entry.compressionMethod = buffer.readUInt16LE(10);
|
|
// 12 - File last modification time
|
|
entry.lastModFileTime = buffer.readUInt16LE(12);
|
|
// 14 - File last modification date
|
|
entry.lastModFileDate = buffer.readUInt16LE(14);
|
|
// 16 - CRC-32
|
|
entry.crc32 = buffer.readUInt32LE(16);
|
|
// 20 - Compressed size
|
|
entry.compressedSize = buffer.readUInt32LE(20);
|
|
// 24 - Uncompressed size
|
|
entry.uncompressedSize = buffer.readUInt32LE(24);
|
|
// 28 - File name length (n)
|
|
entry.fileNameLength = buffer.readUInt16LE(28);
|
|
// 30 - Extra field length (m)
|
|
entry.extraFieldLength = buffer.readUInt16LE(30);
|
|
// 32 - File comment length (k)
|
|
entry.fileCommentLength = buffer.readUInt16LE(32);
|
|
// 34 - Disk number where file starts
|
|
// 36 - Internal file attributes
|
|
entry.internalFileAttributes = buffer.readUInt16LE(36);
|
|
// 38 - External file attributes
|
|
entry.externalFileAttributes = buffer.readUInt32LE(38);
|
|
// 42 - Relative offset of local file header
|
|
entry.relativeOffsetOfLocalHeader = buffer.readUInt32LE(42);
|
|
|
|
if (entry.generalPurposeBitFlag & 0x40) return emitErrorAndAutoClose(self, new Error("strong encryption is not supported"));
|
|
|
|
self.readEntryCursor += 46;
|
|
|
|
buffer = newBuffer(entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
|
|
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err) {
|
|
if (err) return emitErrorAndAutoClose(self, err);
|
|
if (self.emittedError) return;
|
|
// 46 - File name
|
|
var isUtf8 = (entry.generalPurposeBitFlag & 0x800) !== 0;
|
|
entry.fileName = self.decodeStrings ? decodeBuffer(buffer, 0, entry.fileNameLength, isUtf8)
|
|
: buffer.slice(0, entry.fileNameLength);
|
|
|
|
// 46+n - Extra field
|
|
var fileCommentStart = entry.fileNameLength + entry.extraFieldLength;
|
|
var extraFieldBuffer = buffer.slice(entry.fileNameLength, fileCommentStart);
|
|
entry.extraFields = [];
|
|
var i = 0;
|
|
while (i < extraFieldBuffer.length - 3) {
|
|
var headerId = extraFieldBuffer.readUInt16LE(i + 0);
|
|
var dataSize = extraFieldBuffer.readUInt16LE(i + 2);
|
|
var dataStart = i + 4;
|
|
var dataEnd = dataStart + dataSize;
|
|
if (dataEnd > extraFieldBuffer.length) return emitErrorAndAutoClose(self, new Error("extra field length exceeds extra field buffer size"));
|
|
var dataBuffer = newBuffer(dataSize);
|
|
extraFieldBuffer.copy(dataBuffer, 0, dataStart, dataEnd);
|
|
entry.extraFields.push({
|
|
id: headerId,
|
|
data: dataBuffer,
|
|
});
|
|
i = dataEnd;
|
|
}
|
|
|
|
// 46+n+m - File comment
|
|
entry.fileComment = self.decodeStrings ? decodeBuffer(buffer, fileCommentStart, fileCommentStart + entry.fileCommentLength, isUtf8)
|
|
: buffer.slice(fileCommentStart, fileCommentStart + entry.fileCommentLength);
|
|
// compatibility hack for https://github.com/thejoshwolfe/yauzl/issues/47
|
|
entry.comment = entry.fileComment;
|
|
|
|
self.readEntryCursor += buffer.length;
|
|
self.entriesRead += 1;
|
|
|
|
if (entry.uncompressedSize === 0xffffffff ||
|
|
entry.compressedSize === 0xffffffff ||
|
|
entry.relativeOffsetOfLocalHeader === 0xffffffff) {
|
|
// ZIP64 format
|
|
// find the Zip64 Extended Information Extra Field
|
|
var zip64EiefBuffer = null;
|
|
for (var i = 0; i < entry.extraFields.length; i++) {
|
|
var extraField = entry.extraFields[i];
|
|
if (extraField.id === 0x0001) {
|
|
zip64EiefBuffer = extraField.data;
|
|
break;
|
|
}
|
|
}
|
|
if (zip64EiefBuffer == null) {
|
|
return emitErrorAndAutoClose(self, new Error("expected zip64 extended information extra field"));
|
|
}
|
|
var index = 0;
|
|
// 0 - Original Size 8 bytes
|
|
if (entry.uncompressedSize === 0xffffffff) {
|
|
if (index + 8 > zip64EiefBuffer.length) {
|
|
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include uncompressed size"));
|
|
}
|
|
entry.uncompressedSize = readUInt64LE(zip64EiefBuffer, index);
|
|
index += 8;
|
|
}
|
|
// 8 - Compressed Size 8 bytes
|
|
if (entry.compressedSize === 0xffffffff) {
|
|
if (index + 8 > zip64EiefBuffer.length) {
|
|
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include compressed size"));
|
|
}
|
|
entry.compressedSize = readUInt64LE(zip64EiefBuffer, index);
|
|
index += 8;
|
|
}
|
|
// 16 - Relative Header Offset 8 bytes
|
|
if (entry.relativeOffsetOfLocalHeader === 0xffffffff) {
|
|
if (index + 8 > zip64EiefBuffer.length) {
|
|
return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include relative header offset"));
|
|
}
|
|
entry.relativeOffsetOfLocalHeader = readUInt64LE(zip64EiefBuffer, index);
|
|
index += 8;
|
|
}
|
|
// 24 - Disk Start Number 4 bytes
|
|
}
|
|
|
|
// check for Info-ZIP Unicode Path Extra Field (0x7075)
|
|
// see https://github.com/thejoshwolfe/yauzl/issues/33
|
|
if (self.decodeStrings) {
|
|
for (var i = 0; i < entry.extraFields.length; i++) {
|
|
var extraField = entry.extraFields[i];
|
|
if (extraField.id === 0x7075) {
|
|
if (extraField.data.length < 6) {
|
|
// too short to be meaningful
|
|
continue;
|
|
}
|
|
// Version 1 byte version of this extra field, currently 1
|
|
if (extraField.data.readUInt8(0) !== 1) {
|
|
// > Changes may not be backward compatible so this extra
|
|
// > field should not be used if the version is not recognized.
|
|
continue;
|
|
}
|
|
// NameCRC32 4 bytes File Name Field CRC32 Checksum
|
|
var oldNameCrc32 = extraField.data.readUInt32LE(1);
|
|
if (crc32.unsigned(buffer.slice(0, entry.fileNameLength)) !== oldNameCrc32) {
|
|
// > If the CRC check fails, this UTF-8 Path Extra Field should be
|
|
// > ignored and the File Name field in the header should be used instead.
|
|
continue;
|
|
}
|
|
// UnicodeName Variable UTF-8 version of the entry File Name
|
|
entry.fileName = decodeBuffer(extraField.data, 5, extraField.data.length, true);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// validate file size
|
|
if (self.validateEntrySizes && entry.compressionMethod === 0) {
|
|
var expectedCompressedSize = entry.uncompressedSize;
|
|
if (entry.isEncrypted()) {
|
|
// traditional encryption prefixes the file data with a header
|
|
expectedCompressedSize += 12;
|
|
}
|
|
if (entry.compressedSize !== expectedCompressedSize) {
|
|
var msg = "compressed/uncompressed size mismatch for stored file: " + entry.compressedSize + " != " + entry.uncompressedSize;
|
|
return emitErrorAndAutoClose(self, new Error(msg));
|
|
}
|
|
}
|
|
|
|
if (self.decodeStrings) {
|
|
if (!self.strictFileNames) {
|
|
// allow backslash
|
|
entry.fileName = entry.fileName.replace(/\\/g, "/");
|
|
}
|
|
var errorMessage = validateFileName(entry.fileName, self.validateFileNameOptions);
|
|
if (errorMessage != null) return emitErrorAndAutoClose(self, new Error(errorMessage));
|
|
}
|
|
self.emit("entry", entry);
|
|
|
|
if (!self.lazyEntries) self._readEntry();
|
|
});
|
|
});
|
|
};
|
|
|
|
ZipFile.prototype.openReadStream = function(entry, options, callback) {
|
|
var self = this;
|
|
// parameter validation
|
|
var relativeStart = 0;
|
|
var relativeEnd = entry.compressedSize;
|
|
if (callback == null) {
|
|
callback = options;
|
|
options = {};
|
|
} else {
|
|
// validate options that the caller has no excuse to get wrong
|
|
if (options.decrypt != null) {
|
|
if (!entry.isEncrypted()) {
|
|
throw new Error("options.decrypt can only be specified for encrypted entries");
|
|
}
|
|
if (options.decrypt !== false) throw new Error("invalid options.decrypt value: " + options.decrypt);
|
|
if (entry.isCompressed()) {
|
|
if (options.decompress !== false) throw new Error("entry is encrypted and compressed, and options.decompress !== false");
|
|
}
|
|
}
|
|
if (options.decompress != null) {
|
|
if (!entry.isCompressed()) {
|
|
throw new Error("options.decompress can only be specified for compressed entries");
|
|
}
|
|
if (!(options.decompress === false || options.decompress === true)) {
|
|
throw new Error("invalid options.decompress value: " + options.decompress);
|
|
}
|
|
}
|
|
if (options.start != null || options.end != null) {
|
|
if (entry.isCompressed() && options.decompress !== false) {
|
|
throw new Error("start/end range not allowed for compressed entry without options.decompress === false");
|
|
}
|
|
if (entry.isEncrypted() && options.decrypt !== false) {
|
|
throw new Error("start/end range not allowed for encrypted entry without options.decrypt === false");
|
|
}
|
|
}
|
|
if (options.start != null) {
|
|
relativeStart = options.start;
|
|
if (relativeStart < 0) throw new Error("options.start < 0");
|
|
if (relativeStart > entry.compressedSize) throw new Error("options.start > entry.compressedSize");
|
|
}
|
|
if (options.end != null) {
|
|
relativeEnd = options.end;
|
|
if (relativeEnd < 0) throw new Error("options.end < 0");
|
|
if (relativeEnd > entry.compressedSize) throw new Error("options.end > entry.compressedSize");
|
|
if (relativeEnd < relativeStart) throw new Error("options.end < options.start");
|
|
}
|
|
}
|
|
// any further errors can either be caused by the zipfile,
|
|
// or were introduced in a minor version of yauzl,
|
|
// so should be passed to the client rather than thrown.
|
|
if (!self.isOpen) return callback(new Error("closed"));
|
|
if (entry.isEncrypted()) {
|
|
if (options.decrypt !== false) return callback(new Error("entry is encrypted, and options.decrypt !== false"));
|
|
}
|
|
// make sure we don't lose the fd before we open the actual read stream
|
|
self.reader.ref();
|
|
var buffer = newBuffer(30);
|
|
readAndAssertNoEof(self.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader, function(err) {
|
|
try {
|
|
if (err) return callback(err);
|
|
// 0 - Local file header signature = 0x04034b50
|
|
var signature = buffer.readUInt32LE(0);
|
|
if (signature !== 0x04034b50) {
|
|
return callback(new Error("invalid local file header signature: 0x" + signature.toString(16)));
|
|
}
|
|
// all this should be redundant
|
|
// 4 - Version needed to extract (minimum)
|
|
// 6 - General purpose bit flag
|
|
// 8 - Compression method
|
|
// 10 - File last modification time
|
|
// 12 - File last modification date
|
|
// 14 - CRC-32
|
|
// 18 - Compressed size
|
|
// 22 - Uncompressed size
|
|
// 26 - File name length (n)
|
|
var fileNameLength = buffer.readUInt16LE(26);
|
|
// 28 - Extra field length (m)
|
|
var extraFieldLength = buffer.readUInt16LE(28);
|
|
// 30 - File name
|
|
// 30+n - Extra field
|
|
var localFileHeaderEnd = entry.relativeOffsetOfLocalHeader + buffer.length + fileNameLength + extraFieldLength;
|
|
var decompress;
|
|
if (entry.compressionMethod === 0) {
|
|
// 0 - The file is stored (no compression)
|
|
decompress = false;
|
|
} else if (entry.compressionMethod === 8) {
|
|
// 8 - The file is Deflated
|
|
decompress = options.decompress != null ? options.decompress : true;
|
|
} else {
|
|
return callback(new Error("unsupported compression method: " + entry.compressionMethod));
|
|
}
|
|
var fileDataStart = localFileHeaderEnd;
|
|
var fileDataEnd = fileDataStart + entry.compressedSize;
|
|
if (entry.compressedSize !== 0) {
|
|
// bounds check now, because the read streams will probably not complain loud enough.
|
|
// since we're dealing with an unsigned offset plus an unsigned size,
|
|
// we only have 1 thing to check for.
|
|
if (fileDataEnd > self.fileSize) {
|
|
return callback(new Error("file data overflows file bounds: " +
|
|
fileDataStart + " + " + entry.compressedSize + " > " + self.fileSize));
|
|
}
|
|
}
|
|
var readStream = self.reader.createReadStream({
|
|
start: fileDataStart + relativeStart,
|
|
end: fileDataStart + relativeEnd,
|
|
});
|
|
var endpointStream = readStream;
|
|
if (decompress) {
|
|
var destroyed = false;
|
|
var inflateFilter = zlib.createInflateRaw();
|
|
readStream.on("error", function(err) {
|
|
// setImmediate here because errors can be emitted during the first call to pipe()
|
|
setImmediate(function() {
|
|
if (!destroyed) inflateFilter.emit("error", err);
|
|
});
|
|
});
|
|
readStream.pipe(inflateFilter);
|
|
|
|
if (self.validateEntrySizes) {
|
|
endpointStream = new AssertByteCountStream(entry.uncompressedSize);
|
|
inflateFilter.on("error", function(err) {
|
|
// forward zlib errors to the client-visible stream
|
|
setImmediate(function() {
|
|
if (!destroyed) endpointStream.emit("error", err);
|
|
});
|
|
});
|
|
inflateFilter.pipe(endpointStream);
|
|
} else {
|
|
// the zlib filter is the client-visible stream
|
|
endpointStream = inflateFilter;
|
|
}
|
|
// this is part of yauzl's API, so implement this function on the client-visible stream
|
|
endpointStream.destroy = function() {
|
|
destroyed = true;
|
|
if (inflateFilter !== endpointStream) inflateFilter.unpipe(endpointStream);
|
|
readStream.unpipe(inflateFilter);
|
|
// TODO: the inflateFilter may cause a memory leak. see Issue #27.
|
|
readStream.destroy();
|
|
};
|
|
}
|
|
callback(null, endpointStream);
|
|
} finally {
|
|
self.reader.unref();
|
|
}
|
|
});
|
|
};
|
|
|
|
function Entry() {
|
|
}
|
|
Entry.prototype.getLastModDate = function() {
|
|
return dosDateTimeToDate(this.lastModFileDate, this.lastModFileTime);
|
|
};
|
|
Entry.prototype.isEncrypted = function() {
|
|
return (this.generalPurposeBitFlag & 0x1) !== 0;
|
|
};
|
|
Entry.prototype.isCompressed = function() {
|
|
return this.compressionMethod === 8;
|
|
};
|
|
|
|
function dosDateTimeToDate(date, time) {
|
|
var day = date & 0x1f; // 1-31
|
|
var month = (date >> 5 & 0xf) - 1; // 1-12, 0-11
|
|
var year = (date >> 9 & 0x7f) + 1980; // 0-128, 1980-2108
|
|
|
|
var millisecond = 0;
|
|
var second = (time & 0x1f) * 2; // 0-29, 0-58 (even numbers)
|
|
var minute = time >> 5 & 0x3f; // 0-59
|
|
var hour = time >> 11 & 0x1f; // 0-23
|
|
|
|
return new Date(year, month, day, hour, minute, second, millisecond);
|
|
}
|
|
|
|
function validateFileName(fileName) {
|
|
if (fileName.indexOf("\\") !== -1) {
|
|
return "invalid characters in fileName: " + fileName;
|
|
}
|
|
if (/^[a-zA-Z]:/.test(fileName) || /^\//.test(fileName)) {
|
|
return "absolute path: " + fileName;
|
|
}
|
|
if (fileName.split("/").indexOf("..") !== -1) {
|
|
return "invalid relative path: " + fileName;
|
|
}
|
|
// all good
|
|
return null;
|
|
}
|
|
|
|
function readAndAssertNoEof(reader, buffer, offset, length, position, callback) {
|
|
if (length === 0) {
|
|
// fs.read will throw an out-of-bounds error if you try to read 0 bytes from a 0 byte file
|
|
return setImmediate(function() { callback(null, newBuffer(0)); });
|
|
}
|
|
reader.read(buffer, offset, length, position, function(err, bytesRead) {
|
|
if (err) return callback(err);
|
|
if (bytesRead < length) {
|
|
return callback(new Error("unexpected EOF"));
|
|
}
|
|
callback();
|
|
});
|
|
}
|
|
|
|
util.inherits(AssertByteCountStream, Transform);
|
|
function AssertByteCountStream(byteCount) {
|
|
Transform.call(this);
|
|
this.actualByteCount = 0;
|
|
this.expectedByteCount = byteCount;
|
|
}
|
|
AssertByteCountStream.prototype._transform = function(chunk, encoding, cb) {
|
|
this.actualByteCount += chunk.length;
|
|
if (this.actualByteCount > this.expectedByteCount) {
|
|
var msg = "too many bytes in the stream. expected " + this.expectedByteCount + ". got at least " + this.actualByteCount;
|
|
return cb(new Error(msg));
|
|
}
|
|
cb(null, chunk);
|
|
};
|
|
AssertByteCountStream.prototype._flush = function(cb) {
|
|
if (this.actualByteCount < this.expectedByteCount) {
|
|
var msg = "not enough bytes in the stream. expected " + this.expectedByteCount + ". got only " + this.actualByteCount;
|
|
return cb(new Error(msg));
|
|
}
|
|
cb();
|
|
};
|
|
|
|
util.inherits(RandomAccessReader, EventEmitter);
|
|
function RandomAccessReader() {
|
|
EventEmitter.call(this);
|
|
this.refCount = 0;
|
|
}
|
|
RandomAccessReader.prototype.ref = function() {
|
|
this.refCount += 1;
|
|
};
|
|
RandomAccessReader.prototype.unref = function() {
|
|
var self = this;
|
|
self.refCount -= 1;
|
|
|
|
if (self.refCount > 0) return;
|
|
if (self.refCount < 0) throw new Error("invalid unref");
|
|
|
|
self.close(onCloseDone);
|
|
|
|
function onCloseDone(err) {
|
|
if (err) return self.emit('error', err);
|
|
self.emit('close');
|
|
}
|
|
};
|
|
RandomAccessReader.prototype.createReadStream = function(options) {
|
|
var start = options.start;
|
|
var end = options.end;
|
|
if (start === end) {
|
|
var emptyStream = new PassThrough();
|
|
setImmediate(function() {
|
|
emptyStream.end();
|
|
});
|
|
return emptyStream;
|
|
}
|
|
var stream = this._readStreamForRange(start, end);
|
|
|
|
var destroyed = false;
|
|
var refUnrefFilter = new RefUnrefFilter(this);
|
|
stream.on("error", function(err) {
|
|
setImmediate(function() {
|
|
if (!destroyed) refUnrefFilter.emit("error", err);
|
|
});
|
|
});
|
|
refUnrefFilter.destroy = function() {
|
|
stream.unpipe(refUnrefFilter);
|
|
refUnrefFilter.unref();
|
|
stream.destroy();
|
|
};
|
|
|
|
var byteCounter = new AssertByteCountStream(end - start);
|
|
refUnrefFilter.on("error", function(err) {
|
|
setImmediate(function() {
|
|
if (!destroyed) byteCounter.emit("error", err);
|
|
});
|
|
});
|
|
byteCounter.destroy = function() {
|
|
destroyed = true;
|
|
refUnrefFilter.unpipe(byteCounter);
|
|
refUnrefFilter.destroy();
|
|
};
|
|
|
|
return stream.pipe(refUnrefFilter).pipe(byteCounter);
|
|
};
|
|
RandomAccessReader.prototype._readStreamForRange = function(start, end) {
|
|
throw new Error("not implemented");
|
|
};
|
|
RandomAccessReader.prototype.read = function(buffer, offset, length, position, callback) {
|
|
var readStream = this.createReadStream({start: position, end: position + length});
|
|
var writeStream = new Writable();
|
|
var written = 0;
|
|
writeStream._write = function(chunk, encoding, cb) {
|
|
chunk.copy(buffer, offset + written, 0, chunk.length);
|
|
written += chunk.length;
|
|
cb();
|
|
};
|
|
writeStream.on("finish", callback);
|
|
readStream.on("error", function(error) {
|
|
callback(error);
|
|
});
|
|
readStream.pipe(writeStream);
|
|
};
|
|
RandomAccessReader.prototype.close = function(callback) {
|
|
setImmediate(callback);
|
|
};
|
|
|
|
util.inherits(RefUnrefFilter, PassThrough);
|
|
function RefUnrefFilter(context) {
|
|
PassThrough.call(this);
|
|
this.context = context;
|
|
this.context.ref();
|
|
this.unreffedYet = false;
|
|
}
|
|
RefUnrefFilter.prototype._flush = function(cb) {
|
|
this.unref();
|
|
cb();
|
|
};
|
|
RefUnrefFilter.prototype.unref = function(cb) {
|
|
if (this.unreffedYet) return;
|
|
this.unreffedYet = true;
|
|
this.context.unref();
|
|
};
|
|
|
|
var cp437 = '\u0000☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ';
|
|
function decodeBuffer(buffer, start, end, isUtf8) {
|
|
if (isUtf8) {
|
|
return buffer.toString("utf8", start, end);
|
|
} else {
|
|
var result = "";
|
|
for (var i = start; i < end; i++) {
|
|
result += cp437[buffer[i]];
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
|
|
function readUInt64LE(buffer, offset) {
|
|
// there is no native function for this, because we can't actually store 64-bit integers precisely.
|
|
// after 53 bits, JavaScript's Number type (IEEE 754 double) can't store individual integers anymore.
|
|
// but since 53 bits is a whole lot more than 32 bits, we do our best anyway.
|
|
var lower32 = buffer.readUInt32LE(offset);
|
|
var upper32 = buffer.readUInt32LE(offset + 4);
|
|
// we can't use bitshifting here, because JavaScript bitshifting only works on 32-bit integers.
|
|
return upper32 * 0x100000000 + lower32;
|
|
// as long as we're bounds checking the result of this function against the total file size,
|
|
// we'll catch any overflow errors, because we already made sure the total file size was within reason.
|
|
}
|
|
|
|
// Node 10 deprecated new Buffer().
|
|
var newBuffer;
|
|
if (typeof Buffer.allocUnsafe === "function") {
|
|
newBuffer = function(len) {
|
|
return Buffer.allocUnsafe(len);
|
|
};
|
|
} else {
|
|
newBuffer = function(len) {
|
|
return new Buffer(len);
|
|
};
|
|
}
|
|
|
|
function defaultCallback(err) {
|
|
if (err) throw err;
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 791:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const fileType = __webpack_require__(902);
|
|
const isStream = __webpack_require__(323);
|
|
const tarStream = __webpack_require__(394);
|
|
|
|
module.exports = () => input => {
|
|
if (!Buffer.isBuffer(input) && !isStream(input)) {
|
|
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`));
|
|
}
|
|
|
|
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'tar')) {
|
|
return Promise.resolve([]);
|
|
}
|
|
|
|
const extract = tarStream.extract();
|
|
const files = [];
|
|
|
|
extract.on('entry', (header, stream, cb) => {
|
|
const chunk = [];
|
|
|
|
stream.on('data', data => chunk.push(data));
|
|
stream.on('end', () => {
|
|
const file = {
|
|
data: Buffer.concat(chunk),
|
|
mode: header.mode,
|
|
mtime: header.mtime,
|
|
path: header.name,
|
|
type: header.type
|
|
};
|
|
|
|
if (header.type === 'symlink' || header.type === 'link') {
|
|
file.linkname = header.linkname;
|
|
}
|
|
|
|
files.push(file);
|
|
cb();
|
|
});
|
|
});
|
|
|
|
const promise = new Promise((resolve, reject) => {
|
|
if (!Buffer.isBuffer(input)) {
|
|
input.on('error', reject);
|
|
}
|
|
|
|
extract.on('finish', () => resolve(files));
|
|
extract.on('error', reject);
|
|
});
|
|
|
|
extract.then = promise.then.bind(promise);
|
|
extract.catch = promise.catch.bind(promise);
|
|
|
|
if (Buffer.isBuffer(input)) {
|
|
extract.end(input);
|
|
} else {
|
|
input.pipe(extract);
|
|
}
|
|
|
|
return extract;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 794:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
module.exports = input => {
|
|
const buf = new Uint8Array(input);
|
|
|
|
if (!(buf && buf.length > 1)) {
|
|
return null;
|
|
}
|
|
|
|
const check = (header, opts) => {
|
|
opts = Object.assign({
|
|
offset: 0
|
|
}, opts);
|
|
|
|
for (let i = 0; i < header.length; i++) {
|
|
if (header[i] !== buf[i + opts.offset]) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
if (check([0xFF, 0xD8, 0xFF])) {
|
|
return {
|
|
ext: 'jpg',
|
|
mime: 'image/jpeg'
|
|
};
|
|
}
|
|
|
|
if (check([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])) {
|
|
return {
|
|
ext: 'png',
|
|
mime: 'image/png'
|
|
};
|
|
}
|
|
|
|
if (check([0x47, 0x49, 0x46])) {
|
|
return {
|
|
ext: 'gif',
|
|
mime: 'image/gif'
|
|
};
|
|
}
|
|
|
|
if (check([0x57, 0x45, 0x42, 0x50], {offset: 8})) {
|
|
return {
|
|
ext: 'webp',
|
|
mime: 'image/webp'
|
|
};
|
|
}
|
|
|
|
if (check([0x46, 0x4C, 0x49, 0x46])) {
|
|
return {
|
|
ext: 'flif',
|
|
mime: 'image/flif'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `tif` check
|
|
if (
|
|
(check([0x49, 0x49, 0x2A, 0x0]) || check([0x4D, 0x4D, 0x0, 0x2A])) &&
|
|
check([0x43, 0x52], {offset: 8})
|
|
) {
|
|
return {
|
|
ext: 'cr2',
|
|
mime: 'image/x-canon-cr2'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x49, 0x49, 0x2A, 0x0]) ||
|
|
check([0x4D, 0x4D, 0x0, 0x2A])
|
|
) {
|
|
return {
|
|
ext: 'tif',
|
|
mime: 'image/tiff'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x4D])) {
|
|
return {
|
|
ext: 'bmp',
|
|
mime: 'image/bmp'
|
|
};
|
|
}
|
|
|
|
if (check([0x49, 0x49, 0xBC])) {
|
|
return {
|
|
ext: 'jxr',
|
|
mime: 'image/vnd.ms-photo'
|
|
};
|
|
}
|
|
|
|
if (check([0x38, 0x42, 0x50, 0x53])) {
|
|
return {
|
|
ext: 'psd',
|
|
mime: 'image/vnd.adobe.photoshop'
|
|
};
|
|
}
|
|
|
|
// Needs to be before the `zip` check
|
|
if (
|
|
check([0x50, 0x4B, 0x3, 0x4]) &&
|
|
check([0x6D, 0x69, 0x6D, 0x65, 0x74, 0x79, 0x70, 0x65, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x65, 0x70, 0x75, 0x62, 0x2B, 0x7A, 0x69, 0x70], {offset: 30})
|
|
) {
|
|
return {
|
|
ext: 'epub',
|
|
mime: 'application/epub+zip'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `zip` check
|
|
// Assumes signed `.xpi` from addons.mozilla.org
|
|
if (
|
|
check([0x50, 0x4B, 0x3, 0x4]) &&
|
|
check([0x4D, 0x45, 0x54, 0x41, 0x2D, 0x49, 0x4E, 0x46, 0x2F, 0x6D, 0x6F, 0x7A, 0x69, 0x6C, 0x6C, 0x61, 0x2E, 0x72, 0x73, 0x61], {offset: 30})
|
|
) {
|
|
return {
|
|
ext: 'xpi',
|
|
mime: 'application/x-xpinstall'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x50, 0x4B]) &&
|
|
(buf[2] === 0x3 || buf[2] === 0x5 || buf[2] === 0x7) &&
|
|
(buf[3] === 0x4 || buf[3] === 0x6 || buf[3] === 0x8)
|
|
) {
|
|
return {
|
|
ext: 'zip',
|
|
mime: 'application/zip'
|
|
};
|
|
}
|
|
|
|
if (check([0x75, 0x73, 0x74, 0x61, 0x72], {offset: 257})) {
|
|
return {
|
|
ext: 'tar',
|
|
mime: 'application/x-tar'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x52, 0x61, 0x72, 0x21, 0x1A, 0x7]) &&
|
|
(buf[6] === 0x0 || buf[6] === 0x1)
|
|
) {
|
|
return {
|
|
ext: 'rar',
|
|
mime: 'application/x-rar-compressed'
|
|
};
|
|
}
|
|
|
|
if (check([0x1F, 0x8B, 0x8])) {
|
|
return {
|
|
ext: 'gz',
|
|
mime: 'application/gzip'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x5A, 0x68])) {
|
|
return {
|
|
ext: 'bz2',
|
|
mime: 'application/x-bzip2'
|
|
};
|
|
}
|
|
|
|
if (check([0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C])) {
|
|
return {
|
|
ext: '7z',
|
|
mime: 'application/x-7z-compressed'
|
|
};
|
|
}
|
|
|
|
if (check([0x78, 0x01])) {
|
|
return {
|
|
ext: 'dmg',
|
|
mime: 'application/x-apple-diskimage'
|
|
};
|
|
}
|
|
|
|
if (
|
|
(
|
|
check([0x0, 0x0, 0x0]) &&
|
|
(buf[3] === 0x18 || buf[3] === 0x20) &&
|
|
check([0x66, 0x74, 0x79, 0x70], {offset: 4})
|
|
) ||
|
|
check([0x33, 0x67, 0x70, 0x35]) ||
|
|
(
|
|
check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x6D, 0x70, 0x34, 0x32]) &&
|
|
check([0x6D, 0x70, 0x34, 0x31, 0x6D, 0x70, 0x34, 0x32, 0x69, 0x73, 0x6F, 0x6D], {offset: 16})
|
|
) ||
|
|
check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x69, 0x73, 0x6F, 0x6D]) ||
|
|
check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x6D, 0x70, 0x34, 0x32, 0x0, 0x0, 0x0, 0x0])
|
|
) {
|
|
return {
|
|
ext: 'mp4',
|
|
mime: 'video/mp4'
|
|
};
|
|
}
|
|
|
|
if (check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x56])) {
|
|
return {
|
|
ext: 'm4v',
|
|
mime: 'video/x-m4v'
|
|
};
|
|
}
|
|
|
|
if (check([0x4D, 0x54, 0x68, 0x64])) {
|
|
return {
|
|
ext: 'mid',
|
|
mime: 'audio/midi'
|
|
};
|
|
}
|
|
|
|
// https://github.com/threatstack/libmagic/blob/master/magic/Magdir/matroska
|
|
if (check([0x1A, 0x45, 0xDF, 0xA3])) {
|
|
const sliced = buf.subarray(4, 4 + 4096);
|
|
const idPos = sliced.findIndex((el, i, arr) => arr[i] === 0x42 && arr[i + 1] === 0x82);
|
|
|
|
if (idPos >= 0) {
|
|
const docTypePos = idPos + 3;
|
|
const findDocType = type => Array.from(type).every((c, i) => sliced[docTypePos + i] === c.charCodeAt(0));
|
|
|
|
if (findDocType('matroska')) {
|
|
return {
|
|
ext: 'mkv',
|
|
mime: 'video/x-matroska'
|
|
};
|
|
}
|
|
|
|
if (findDocType('webm')) {
|
|
return {
|
|
ext: 'webm',
|
|
mime: 'video/webm'
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
if (check([0x0, 0x0, 0x0, 0x14, 0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20]) ||
|
|
check([0x66, 0x72, 0x65, 0x65], {offset: 4}) ||
|
|
check([0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20], {offset: 4}) ||
|
|
check([0x6D, 0x64, 0x61, 0x74], {offset: 4}) || // MJPEG
|
|
check([0x77, 0x69, 0x64, 0x65], {offset: 4})) {
|
|
return {
|
|
ext: 'mov',
|
|
mime: 'video/quicktime'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x52, 0x49, 0x46, 0x46]) &&
|
|
check([0x41, 0x56, 0x49], {offset: 8})
|
|
) {
|
|
return {
|
|
ext: 'avi',
|
|
mime: 'video/x-msvideo'
|
|
};
|
|
}
|
|
|
|
if (check([0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xA6, 0xD9])) {
|
|
return {
|
|
ext: 'wmv',
|
|
mime: 'video/x-ms-wmv'
|
|
};
|
|
}
|
|
|
|
if (check([0x0, 0x0, 0x1, 0xBA])) {
|
|
return {
|
|
ext: 'mpg',
|
|
mime: 'video/mpeg'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x49, 0x44, 0x33]) ||
|
|
check([0xFF, 0xFB])
|
|
) {
|
|
return {
|
|
ext: 'mp3',
|
|
mime: 'audio/mpeg'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41], {offset: 4}) ||
|
|
check([0x4D, 0x34, 0x41, 0x20])
|
|
) {
|
|
return {
|
|
ext: 'm4a',
|
|
mime: 'audio/m4a'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `ogg` check
|
|
if (check([0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64], {offset: 28})) {
|
|
return {
|
|
ext: 'opus',
|
|
mime: 'audio/opus'
|
|
};
|
|
}
|
|
|
|
if (check([0x4F, 0x67, 0x67, 0x53])) {
|
|
return {
|
|
ext: 'ogg',
|
|
mime: 'audio/ogg'
|
|
};
|
|
}
|
|
|
|
if (check([0x66, 0x4C, 0x61, 0x43])) {
|
|
return {
|
|
ext: 'flac',
|
|
mime: 'audio/x-flac'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x52, 0x49, 0x46, 0x46]) &&
|
|
check([0x57, 0x41, 0x56, 0x45], {offset: 8})
|
|
) {
|
|
return {
|
|
ext: 'wav',
|
|
mime: 'audio/x-wav'
|
|
};
|
|
}
|
|
|
|
if (check([0x23, 0x21, 0x41, 0x4D, 0x52, 0x0A])) {
|
|
return {
|
|
ext: 'amr',
|
|
mime: 'audio/amr'
|
|
};
|
|
}
|
|
|
|
if (check([0x25, 0x50, 0x44, 0x46])) {
|
|
return {
|
|
ext: 'pdf',
|
|
mime: 'application/pdf'
|
|
};
|
|
}
|
|
|
|
if (check([0x4D, 0x5A])) {
|
|
return {
|
|
ext: 'exe',
|
|
mime: 'application/x-msdownload'
|
|
};
|
|
}
|
|
|
|
if (
|
|
(buf[0] === 0x43 || buf[0] === 0x46) &&
|
|
check([0x57, 0x53], {offset: 1})
|
|
) {
|
|
return {
|
|
ext: 'swf',
|
|
mime: 'application/x-shockwave-flash'
|
|
};
|
|
}
|
|
|
|
if (check([0x7B, 0x5C, 0x72, 0x74, 0x66])) {
|
|
return {
|
|
ext: 'rtf',
|
|
mime: 'application/rtf'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x61, 0x73, 0x6D])) {
|
|
return {
|
|
ext: 'wasm',
|
|
mime: 'application/wasm'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x77, 0x4F, 0x46, 0x46]) &&
|
|
(
|
|
check([0x00, 0x01, 0x00, 0x00], {offset: 4}) ||
|
|
check([0x4F, 0x54, 0x54, 0x4F], {offset: 4})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'woff',
|
|
mime: 'application/font-woff'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x77, 0x4F, 0x46, 0x32]) &&
|
|
(
|
|
check([0x00, 0x01, 0x00, 0x00], {offset: 4}) ||
|
|
check([0x4F, 0x54, 0x54, 0x4F], {offset: 4})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'woff2',
|
|
mime: 'application/font-woff'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x4C, 0x50], {offset: 34}) &&
|
|
(
|
|
check([0x00, 0x00, 0x01], {offset: 8}) ||
|
|
check([0x01, 0x00, 0x02], {offset: 8}) ||
|
|
check([0x02, 0x00, 0x02], {offset: 8})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'eot',
|
|
mime: 'application/octet-stream'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x01, 0x00, 0x00, 0x00])) {
|
|
return {
|
|
ext: 'ttf',
|
|
mime: 'application/font-sfnt'
|
|
};
|
|
}
|
|
|
|
if (check([0x4F, 0x54, 0x54, 0x4F, 0x00])) {
|
|
return {
|
|
ext: 'otf',
|
|
mime: 'application/font-sfnt'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x00, 0x01, 0x00])) {
|
|
return {
|
|
ext: 'ico',
|
|
mime: 'image/x-icon'
|
|
};
|
|
}
|
|
|
|
if (check([0x46, 0x4C, 0x56, 0x01])) {
|
|
return {
|
|
ext: 'flv',
|
|
mime: 'video/x-flv'
|
|
};
|
|
}
|
|
|
|
if (check([0x25, 0x21])) {
|
|
return {
|
|
ext: 'ps',
|
|
mime: 'application/postscript'
|
|
};
|
|
}
|
|
|
|
if (check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) {
|
|
return {
|
|
ext: 'xz',
|
|
mime: 'application/x-xz'
|
|
};
|
|
}
|
|
|
|
if (check([0x53, 0x51, 0x4C, 0x69])) {
|
|
return {
|
|
ext: 'sqlite',
|
|
mime: 'application/x-sqlite3'
|
|
};
|
|
}
|
|
|
|
if (check([0x4E, 0x45, 0x53, 0x1A])) {
|
|
return {
|
|
ext: 'nes',
|
|
mime: 'application/x-nintendo-nes-rom'
|
|
};
|
|
}
|
|
|
|
if (check([0x43, 0x72, 0x32, 0x34])) {
|
|
return {
|
|
ext: 'crx',
|
|
mime: 'application/x-google-chrome-extension'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x4D, 0x53, 0x43, 0x46]) ||
|
|
check([0x49, 0x53, 0x63, 0x28])
|
|
) {
|
|
return {
|
|
ext: 'cab',
|
|
mime: 'application/vnd.ms-cab-compressed'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `ar` check
|
|
if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E, 0x0A, 0x64, 0x65, 0x62, 0x69, 0x61, 0x6E, 0x2D, 0x62, 0x69, 0x6E, 0x61, 0x72, 0x79])) {
|
|
return {
|
|
ext: 'deb',
|
|
mime: 'application/x-deb'
|
|
};
|
|
}
|
|
|
|
if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E])) {
|
|
return {
|
|
ext: 'ar',
|
|
mime: 'application/x-unix-archive'
|
|
};
|
|
}
|
|
|
|
if (check([0xED, 0xAB, 0xEE, 0xDB])) {
|
|
return {
|
|
ext: 'rpm',
|
|
mime: 'application/x-rpm'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x1F, 0xA0]) ||
|
|
check([0x1F, 0x9D])
|
|
) {
|
|
return {
|
|
ext: 'Z',
|
|
mime: 'application/x-compress'
|
|
};
|
|
}
|
|
|
|
if (check([0x4C, 0x5A, 0x49, 0x50])) {
|
|
return {
|
|
ext: 'lz',
|
|
mime: 'application/x-lzip'
|
|
};
|
|
}
|
|
|
|
if (check([0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1])) {
|
|
return {
|
|
ext: 'msi',
|
|
mime: 'application/x-msi'
|
|
};
|
|
}
|
|
|
|
if (check([0x06, 0x0E, 0x2B, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0D, 0x01, 0x02, 0x01, 0x01, 0x02])) {
|
|
return {
|
|
ext: 'mxf',
|
|
mime: 'application/mxf'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x4C, 0x45, 0x4E, 0x44, 0x45, 0x52])) {
|
|
return {
|
|
ext: 'blend',
|
|
mime: 'application/x-blender'
|
|
};
|
|
}
|
|
|
|
return null;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 802:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
const processFn = (fn, options) => function (...args) {
|
|
const P = options.promiseModule;
|
|
|
|
return new P((resolve, reject) => {
|
|
if (options.multiArgs) {
|
|
args.push((...result) => {
|
|
if (options.errorFirst) {
|
|
if (result[0]) {
|
|
reject(result);
|
|
} else {
|
|
result.shift();
|
|
resolve(result);
|
|
}
|
|
} else {
|
|
resolve(result);
|
|
}
|
|
});
|
|
} else if (options.errorFirst) {
|
|
args.push((error, result) => {
|
|
if (error) {
|
|
reject(error);
|
|
} else {
|
|
resolve(result);
|
|
}
|
|
});
|
|
} else {
|
|
args.push(resolve);
|
|
}
|
|
|
|
fn.apply(this, args);
|
|
});
|
|
};
|
|
|
|
module.exports = (input, options) => {
|
|
options = Object.assign({
|
|
exclude: [/.+(Sync|Stream)$/],
|
|
errorFirst: true,
|
|
promiseModule: Promise
|
|
}, options);
|
|
|
|
const objType = typeof input;
|
|
if (!(input !== null && (objType === 'object' || objType === 'function'))) {
|
|
throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${input === null ? 'null' : objType}\``);
|
|
}
|
|
|
|
const filter = key => {
|
|
const match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key);
|
|
return options.include ? options.include.some(match) : !options.exclude.some(match);
|
|
};
|
|
|
|
let ret;
|
|
if (objType === 'function') {
|
|
ret = function (...args) {
|
|
return options.excludeMain ? input(...args) : processFn(input, options).apply(this, args);
|
|
};
|
|
} else {
|
|
ret = Object.create(Object.getPrototypeOf(input));
|
|
}
|
|
|
|
for (const key in input) { // eslint-disable-line guard-for-in
|
|
const property = input[key];
|
|
ret[key] = typeof property === 'function' && filter(key) ? processFn(property, options) : property;
|
|
}
|
|
|
|
return ret;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 809:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var processFn = function (fn, P, opts) {
|
|
return function () {
|
|
var that = this;
|
|
var args = new Array(arguments.length);
|
|
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
args[i] = arguments[i];
|
|
}
|
|
|
|
return new P(function (resolve, reject) {
|
|
args.push(function (err, result) {
|
|
if (err) {
|
|
reject(err);
|
|
} else if (opts.multiArgs) {
|
|
var results = new Array(arguments.length - 1);
|
|
|
|
for (var i = 1; i < arguments.length; i++) {
|
|
results[i - 1] = arguments[i];
|
|
}
|
|
|
|
resolve(results);
|
|
} else {
|
|
resolve(result);
|
|
}
|
|
});
|
|
|
|
fn.apply(that, args);
|
|
});
|
|
};
|
|
};
|
|
|
|
var pify = module.exports = function (obj, P, opts) {
|
|
if (typeof P !== 'function') {
|
|
opts = P;
|
|
P = Promise;
|
|
}
|
|
|
|
opts = opts || {};
|
|
opts.exclude = opts.exclude || [/.+Sync$/];
|
|
|
|
var filter = function (key) {
|
|
var match = function (pattern) {
|
|
return typeof pattern === 'string' ? key === pattern : pattern.test(key);
|
|
};
|
|
|
|
return opts.include ? opts.include.some(match) : !opts.exclude.some(match);
|
|
};
|
|
|
|
var ret = typeof obj === 'function' ? function () {
|
|
if (opts.excludeMain) {
|
|
return obj.apply(this, arguments);
|
|
}
|
|
|
|
return processFn(obj, P, opts).apply(this, arguments);
|
|
} : {};
|
|
|
|
return Object.keys(obj).reduce(function (ret, key) {
|
|
var x = obj[key];
|
|
|
|
ret[key] = typeof x === 'function' && filter(key) ? processFn(x, P, opts) : x;
|
|
|
|
return ret;
|
|
}, ret);
|
|
};
|
|
|
|
pify.all = pify;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 818:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("tls");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 820:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const path = __webpack_require__(622);
|
|
const fs = __webpack_require__(598);
|
|
const decompressTar = __webpack_require__(791);
|
|
const decompressTarbz2 = __webpack_require__(361);
|
|
const decompressTargz = __webpack_require__(850);
|
|
const decompressUnzip = __webpack_require__(898);
|
|
const makeDir = __webpack_require__(489);
|
|
const pify = __webpack_require__(809);
|
|
const stripDirs = __webpack_require__(231);
|
|
|
|
const fsP = pify(fs);
|
|
|
|
const runPlugins = (input, opts) => {
|
|
if (opts.plugins.length === 0) {
|
|
return Promise.resolve([]);
|
|
}
|
|
|
|
return Promise.all(opts.plugins.map(x => x(input, opts))).then(files => files.reduce((a, b) => a.concat(b)));
|
|
};
|
|
|
|
const safeMakeDir = (dir, realOutputPath) => {
|
|
return fsP.realpath(dir)
|
|
.catch(_ => {
|
|
const parent = path.dirname(dir);
|
|
return safeMakeDir(parent, realOutputPath);
|
|
})
|
|
.then(realParentPath => {
|
|
if (realParentPath.indexOf(realOutputPath) !== 0) {
|
|
throw (new Error('Refusing to create a directory outside the output path.'));
|
|
}
|
|
|
|
return makeDir(dir).then(fsP.realpath);
|
|
});
|
|
};
|
|
|
|
const preventWritingThroughSymlink = (destination, realOutputPath) => {
|
|
return fsP.readlink(destination)
|
|
.catch(_ => {
|
|
// Either no file exists, or it's not a symlink. In either case, this is
|
|
// not an escape we need to worry about in this phase.
|
|
return null;
|
|
})
|
|
.then(symlinkPointsTo => {
|
|
if (symlinkPointsTo) {
|
|
throw new Error('Refusing to write into a symlink');
|
|
}
|
|
|
|
// No symlink exists at `destination`, so we can continue
|
|
return realOutputPath;
|
|
});
|
|
};
|
|
|
|
const extractFile = (input, output, opts) => runPlugins(input, opts).then(files => {
|
|
if (opts.strip > 0) {
|
|
files = files
|
|
.map(x => {
|
|
x.path = stripDirs(x.path, opts.strip);
|
|
return x;
|
|
})
|
|
.filter(x => x.path !== '.');
|
|
}
|
|
|
|
if (typeof opts.filter === 'function') {
|
|
files = files.filter(opts.filter);
|
|
}
|
|
|
|
if (typeof opts.map === 'function') {
|
|
files = files.map(opts.map);
|
|
}
|
|
|
|
if (!output) {
|
|
return files;
|
|
}
|
|
|
|
return Promise.all(files.map(x => {
|
|
const dest = path.join(output, x.path);
|
|
const mode = x.mode & ~process.umask();
|
|
const now = new Date();
|
|
|
|
if (x.type === 'directory') {
|
|
return makeDir(output)
|
|
.then(outputPath => fsP.realpath(outputPath))
|
|
.then(realOutputPath => safeMakeDir(dest, realOutputPath))
|
|
.then(() => fsP.utimes(dest, now, x.mtime))
|
|
.then(() => x);
|
|
}
|
|
|
|
return makeDir(output)
|
|
.then(outputPath => fsP.realpath(outputPath))
|
|
.then(realOutputPath => {
|
|
// Attempt to ensure parent directory exists (failing if it's outside the output dir)
|
|
return safeMakeDir(path.dirname(dest), realOutputPath)
|
|
.then(() => realOutputPath);
|
|
})
|
|
.then(realOutputPath => {
|
|
if (x.type === 'file') {
|
|
return preventWritingThroughSymlink(dest, realOutputPath);
|
|
}
|
|
|
|
return realOutputPath;
|
|
})
|
|
.then(realOutputPath => {
|
|
return fsP.realpath(path.dirname(dest))
|
|
.then(realDestinationDir => {
|
|
if (realDestinationDir.indexOf(realOutputPath) !== 0) {
|
|
throw (new Error('Refusing to write outside output directory: ' + realDestinationDir));
|
|
}
|
|
});
|
|
})
|
|
.then(() => {
|
|
if (x.type === 'link') {
|
|
return fsP.link(x.linkname, dest);
|
|
}
|
|
|
|
if (x.type === 'symlink' && process.platform === 'win32') {
|
|
return fsP.link(x.linkname, dest);
|
|
}
|
|
|
|
if (x.type === 'symlink') {
|
|
return fsP.symlink(x.linkname, dest);
|
|
}
|
|
|
|
return fsP.writeFile(dest, x.data, {mode});
|
|
})
|
|
.then(() => x.type === 'file' && fsP.utimes(dest, now, x.mtime))
|
|
.then(() => x);
|
|
}));
|
|
});
|
|
|
|
module.exports = (input, output, opts) => {
|
|
if (typeof input !== 'string' && !Buffer.isBuffer(input)) {
|
|
return Promise.reject(new TypeError('Input file required'));
|
|
}
|
|
|
|
if (typeof output === 'object') {
|
|
opts = output;
|
|
output = null;
|
|
}
|
|
|
|
opts = Object.assign({plugins: [
|
|
decompressTar(),
|
|
decompressTarbz2(),
|
|
decompressTargz(),
|
|
decompressUnzip()
|
|
]}, opts);
|
|
|
|
const read = typeof input === 'string' ? fsP.readFile(input) : Promise.resolve(input);
|
|
|
|
return read.then(buf => extractFile(buf, output, opts));
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 822:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
if (typeof process === 'undefined' ||
|
|
!process.version ||
|
|
process.version.indexOf('v0.') === 0 ||
|
|
process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
|
|
module.exports = { nextTick: nextTick };
|
|
} else {
|
|
module.exports = process
|
|
}
|
|
|
|
function nextTick(fn, arg1, arg2, arg3) {
|
|
if (typeof fn !== 'function') {
|
|
throw new TypeError('"callback" argument must be a function');
|
|
}
|
|
var len = arguments.length;
|
|
var args, i;
|
|
switch (len) {
|
|
case 0:
|
|
case 1:
|
|
return process.nextTick(fn);
|
|
case 2:
|
|
return process.nextTick(function afterTickOne() {
|
|
fn.call(null, arg1);
|
|
});
|
|
case 3:
|
|
return process.nextTick(function afterTickTwo() {
|
|
fn.call(null, arg1, arg2);
|
|
});
|
|
case 4:
|
|
return process.nextTick(function afterTickThree() {
|
|
fn.call(null, arg1, arg2, arg3);
|
|
});
|
|
default:
|
|
args = new Array(len - 1);
|
|
i = 0;
|
|
while (i < args.length) {
|
|
args[i++] = arguments[i];
|
|
}
|
|
return process.nextTick(function afterTick() {
|
|
fn.apply(null, args);
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 826:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var rng = __webpack_require__(139);
|
|
var bytesToUuid = __webpack_require__(722);
|
|
|
|
function v4(options, buf, offset) {
|
|
var i = buf && offset || 0;
|
|
|
|
if (typeof(options) == 'string') {
|
|
buf = options === 'binary' ? new Array(16) : null;
|
|
options = null;
|
|
}
|
|
options = options || {};
|
|
|
|
var rnds = options.random || (options.rng || rng)();
|
|
|
|
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
|
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
|
|
// Copy bytes to buffer, if provided
|
|
if (buf) {
|
|
for (var ii = 0; ii < 16; ++ii) {
|
|
buf[i + ii] = rnds[ii];
|
|
}
|
|
}
|
|
|
|
return buf || bytesToUuid(rnds);
|
|
}
|
|
|
|
module.exports = v4;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 829:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
/*
|
|
seek-bzip - a pure-javascript module for seeking within bzip2 data
|
|
|
|
Copyright (C) 2013 C. Scott Ananian
|
|
Copyright (C) 2012 Eli Skeggs
|
|
Copyright (C) 2011 Kevin Kwok
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with this library; if not, see
|
|
http://www.gnu.org/licenses/lgpl-2.1.html
|
|
|
|
Adapted from node-bzip, copyright 2012 Eli Skeggs.
|
|
Adapted from bzip2.js, copyright 2011 Kevin Kwok (antimatter15@gmail.com).
|
|
|
|
Based on micro-bunzip by Rob Landley (rob@landley.net).
|
|
|
|
Based on bzip2 decompression code by Julian R Seward (jseward@acm.org),
|
|
which also acknowledges contributions by Mike Burrows, David Wheeler,
|
|
Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten,
|
|
Robert Sedgewick, and Jon L. Bentley.
|
|
*/
|
|
|
|
var BitReader = __webpack_require__(223);
|
|
var Stream = __webpack_require__(79);
|
|
var CRC32 = __webpack_require__(496);
|
|
var pjson = __webpack_require__(578);
|
|
|
|
var MAX_HUFCODE_BITS = 20;
|
|
var MAX_SYMBOLS = 258;
|
|
var SYMBOL_RUNA = 0;
|
|
var SYMBOL_RUNB = 1;
|
|
var MIN_GROUPS = 2;
|
|
var MAX_GROUPS = 6;
|
|
var GROUP_SIZE = 50;
|
|
|
|
var WHOLEPI = "314159265359";
|
|
var SQRTPI = "177245385090";
|
|
|
|
var mtf = function(array, index) {
|
|
var src = array[index], i;
|
|
for (i = index; i > 0; i--) {
|
|
array[i] = array[i-1];
|
|
}
|
|
array[0] = src;
|
|
return src;
|
|
};
|
|
|
|
var Err = {
|
|
OK: 0,
|
|
LAST_BLOCK: -1,
|
|
NOT_BZIP_DATA: -2,
|
|
UNEXPECTED_INPUT_EOF: -3,
|
|
UNEXPECTED_OUTPUT_EOF: -4,
|
|
DATA_ERROR: -5,
|
|
OUT_OF_MEMORY: -6,
|
|
OBSOLETE_INPUT: -7,
|
|
END_OF_BLOCK: -8
|
|
};
|
|
var ErrorMessages = {};
|
|
ErrorMessages[Err.LAST_BLOCK] = "Bad file checksum";
|
|
ErrorMessages[Err.NOT_BZIP_DATA] = "Not bzip data";
|
|
ErrorMessages[Err.UNEXPECTED_INPUT_EOF] = "Unexpected input EOF";
|
|
ErrorMessages[Err.UNEXPECTED_OUTPUT_EOF] = "Unexpected output EOF";
|
|
ErrorMessages[Err.DATA_ERROR] = "Data error";
|
|
ErrorMessages[Err.OUT_OF_MEMORY] = "Out of memory";
|
|
ErrorMessages[Err.OBSOLETE_INPUT] = "Obsolete (pre 0.9.5) bzip format not supported.";
|
|
|
|
var _throw = function(status, optDetail) {
|
|
var msg = ErrorMessages[status] || 'unknown error';
|
|
if (optDetail) { msg += ': '+optDetail; }
|
|
var e = new TypeError(msg);
|
|
e.errorCode = status;
|
|
throw e;
|
|
};
|
|
|
|
var Bunzip = function(inputStream, outputStream) {
|
|
this.writePos = this.writeCurrent = this.writeCount = 0;
|
|
|
|
this._start_bunzip(inputStream, outputStream);
|
|
};
|
|
Bunzip.prototype._init_block = function() {
|
|
var moreBlocks = this._get_next_block();
|
|
if ( !moreBlocks ) {
|
|
this.writeCount = -1;
|
|
return false; /* no more blocks */
|
|
}
|
|
this.blockCRC = new CRC32();
|
|
return true;
|
|
};
|
|
/* XXX micro-bunzip uses (inputStream, inputBuffer, len) as arguments */
|
|
Bunzip.prototype._start_bunzip = function(inputStream, outputStream) {
|
|
/* Ensure that file starts with "BZh['1'-'9']." */
|
|
var buf = new Buffer(4);
|
|
if (inputStream.read(buf, 0, 4) !== 4 ||
|
|
String.fromCharCode(buf[0], buf[1], buf[2]) !== 'BZh')
|
|
_throw(Err.NOT_BZIP_DATA, 'bad magic');
|
|
|
|
var level = buf[3] - 0x30;
|
|
if (level < 1 || level > 9)
|
|
_throw(Err.NOT_BZIP_DATA, 'level out of range');
|
|
|
|
this.reader = new BitReader(inputStream);
|
|
|
|
/* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
|
|
uncompressed data. Allocate intermediate buffer for block. */
|
|
this.dbufSize = 100000 * level;
|
|
this.nextoutput = 0;
|
|
this.outputStream = outputStream;
|
|
this.streamCRC = 0;
|
|
};
|
|
Bunzip.prototype._get_next_block = function() {
|
|
var i, j, k;
|
|
var reader = this.reader;
|
|
// this is get_next_block() function from micro-bunzip:
|
|
/* Read in header signature and CRC, then validate signature.
|
|
(last block signature means CRC is for whole file, return now) */
|
|
var h = reader.pi();
|
|
if (h === SQRTPI) { // last block
|
|
return false; /* no more blocks */
|
|
}
|
|
if (h !== WHOLEPI)
|
|
_throw(Err.NOT_BZIP_DATA);
|
|
this.targetBlockCRC = reader.read(32) >>> 0; // (convert to unsigned)
|
|
this.streamCRC = (this.targetBlockCRC ^
|
|
((this.streamCRC << 1) | (this.streamCRC>>>31))) >>> 0;
|
|
/* We can add support for blockRandomised if anybody complains. There was
|
|
some code for this in busybox 1.0.0-pre3, but nobody ever noticed that
|
|
it didn't actually work. */
|
|
if (reader.read(1))
|
|
_throw(Err.OBSOLETE_INPUT);
|
|
var origPointer = reader.read(24);
|
|
if (origPointer > this.dbufSize)
|
|
_throw(Err.DATA_ERROR, 'initial position out of bounds');
|
|
/* mapping table: if some byte values are never used (encoding things
|
|
like ascii text), the compression code removes the gaps to have fewer
|
|
symbols to deal with, and writes a sparse bitfield indicating which
|
|
values were present. We make a translation table to convert the symbols
|
|
back to the corresponding bytes. */
|
|
var t = reader.read(16);
|
|
var symToByte = new Buffer(256), symTotal = 0;
|
|
for (i = 0; i < 16; i++) {
|
|
if (t & (1 << (0xF - i))) {
|
|
var o = i * 16;
|
|
k = reader.read(16);
|
|
for (j = 0; j < 16; j++)
|
|
if (k & (1 << (0xF - j)))
|
|
symToByte[symTotal++] = o + j;
|
|
}
|
|
}
|
|
|
|
/* How many different huffman coding groups does this block use? */
|
|
var groupCount = reader.read(3);
|
|
if (groupCount < MIN_GROUPS || groupCount > MAX_GROUPS)
|
|
_throw(Err.DATA_ERROR);
|
|
/* nSelectors: Every GROUP_SIZE many symbols we select a new huffman coding
|
|
group. Read in the group selector list, which is stored as MTF encoded
|
|
bit runs. (MTF=Move To Front, as each value is used it's moved to the
|
|
start of the list.) */
|
|
var nSelectors = reader.read(15);
|
|
if (nSelectors === 0)
|
|
_throw(Err.DATA_ERROR);
|
|
|
|
var mtfSymbol = new Buffer(256);
|
|
for (i = 0; i < groupCount; i++)
|
|
mtfSymbol[i] = i;
|
|
|
|
var selectors = new Buffer(nSelectors); // was 32768...
|
|
|
|
for (i = 0; i < nSelectors; i++) {
|
|
/* Get next value */
|
|
for (j = 0; reader.read(1); j++)
|
|
if (j >= groupCount) _throw(Err.DATA_ERROR);
|
|
/* Decode MTF to get the next selector */
|
|
selectors[i] = mtf(mtfSymbol, j);
|
|
}
|
|
|
|
/* Read the huffman coding tables for each group, which code for symTotal
|
|
literal symbols, plus two run symbols (RUNA, RUNB) */
|
|
var symCount = symTotal + 2;
|
|
var groups = [], hufGroup;
|
|
for (j = 0; j < groupCount; j++) {
|
|
var length = new Buffer(symCount), temp = new Uint16Array(MAX_HUFCODE_BITS + 1);
|
|
/* Read huffman code lengths for each symbol. They're stored in
|
|
a way similar to mtf; record a starting value for the first symbol,
|
|
and an offset from the previous value for everys symbol after that. */
|
|
t = reader.read(5); // lengths
|
|
for (i = 0; i < symCount; i++) {
|
|
for (;;) {
|
|
if (t < 1 || t > MAX_HUFCODE_BITS) _throw(Err.DATA_ERROR);
|
|
/* If first bit is 0, stop. Else second bit indicates whether
|
|
to increment or decrement the value. */
|
|
if(!reader.read(1))
|
|
break;
|
|
if(!reader.read(1))
|
|
t++;
|
|
else
|
|
t--;
|
|
}
|
|
length[i] = t;
|
|
}
|
|
|
|
/* Find largest and smallest lengths in this group */
|
|
var minLen, maxLen;
|
|
minLen = maxLen = length[0];
|
|
for (i = 1; i < symCount; i++) {
|
|
if (length[i] > maxLen)
|
|
maxLen = length[i];
|
|
else if (length[i] < minLen)
|
|
minLen = length[i];
|
|
}
|
|
|
|
/* Calculate permute[], base[], and limit[] tables from length[].
|
|
*
|
|
* permute[] is the lookup table for converting huffman coded symbols
|
|
* into decoded symbols. base[] is the amount to subtract from the
|
|
* value of a huffman symbol of a given length when using permute[].
|
|
*
|
|
* limit[] indicates the largest numerical value a symbol with a given
|
|
* number of bits can have. This is how the huffman codes can vary in
|
|
* length: each code with a value>limit[length] needs another bit.
|
|
*/
|
|
hufGroup = {};
|
|
groups.push(hufGroup);
|
|
hufGroup.permute = new Uint16Array(MAX_SYMBOLS);
|
|
hufGroup.limit = new Uint32Array(MAX_HUFCODE_BITS + 2);
|
|
hufGroup.base = new Uint32Array(MAX_HUFCODE_BITS + 1);
|
|
hufGroup.minLen = minLen;
|
|
hufGroup.maxLen = maxLen;
|
|
/* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
|
|
var pp = 0;
|
|
for (i = minLen; i <= maxLen; i++) {
|
|
temp[i] = hufGroup.limit[i] = 0;
|
|
for (t = 0; t < symCount; t++)
|
|
if (length[t] === i)
|
|
hufGroup.permute[pp++] = t;
|
|
}
|
|
/* Count symbols coded for at each bit length */
|
|
for (i = 0; i < symCount; i++)
|
|
temp[length[i]]++;
|
|
/* Calculate limit[] (the largest symbol-coding value at each bit
|
|
* length, which is (previous limit<<1)+symbols at this level), and
|
|
* base[] (number of symbols to ignore at each bit length, which is
|
|
* limit minus the cumulative count of symbols coded for already). */
|
|
pp = t = 0;
|
|
for (i = minLen; i < maxLen; i++) {
|
|
pp += temp[i];
|
|
/* We read the largest possible symbol size and then unget bits
|
|
after determining how many we need, and those extra bits could
|
|
be set to anything. (They're noise from future symbols.) At
|
|
each level we're really only interested in the first few bits,
|
|
so here we set all the trailing to-be-ignored bits to 1 so they
|
|
don't affect the value>limit[length] comparison. */
|
|
hufGroup.limit[i] = pp - 1;
|
|
pp <<= 1;
|
|
t += temp[i];
|
|
hufGroup.base[i + 1] = pp - t;
|
|
}
|
|
hufGroup.limit[maxLen + 1] = Number.MAX_VALUE; /* Sentinal value for reading next sym. */
|
|
hufGroup.limit[maxLen] = pp + temp[maxLen] - 1;
|
|
hufGroup.base[minLen] = 0;
|
|
}
|
|
/* We've finished reading and digesting the block header. Now read this
|
|
block's huffman coded symbols from the file and undo the huffman coding
|
|
and run length encoding, saving the result into dbuf[dbufCount++]=uc */
|
|
|
|
/* Initialize symbol occurrence counters and symbol Move To Front table */
|
|
var byteCount = new Uint32Array(256);
|
|
for (i = 0; i < 256; i++)
|
|
mtfSymbol[i] = i;
|
|
/* Loop through compressed symbols. */
|
|
var runPos = 0, dbufCount = 0, selector = 0, uc;
|
|
var dbuf = this.dbuf = new Uint32Array(this.dbufSize);
|
|
symCount = 0;
|
|
for (;;) {
|
|
/* Determine which huffman coding group to use. */
|
|
if (!(symCount--)) {
|
|
symCount = GROUP_SIZE - 1;
|
|
if (selector >= nSelectors) { _throw(Err.DATA_ERROR); }
|
|
hufGroup = groups[selectors[selector++]];
|
|
}
|
|
/* Read next huffman-coded symbol. */
|
|
i = hufGroup.minLen;
|
|
j = reader.read(i);
|
|
for (;;i++) {
|
|
if (i > hufGroup.maxLen) { _throw(Err.DATA_ERROR); }
|
|
if (j <= hufGroup.limit[i])
|
|
break;
|
|
j = (j << 1) | reader.read(1);
|
|
}
|
|
/* Huffman decode value to get nextSym (with bounds checking) */
|
|
j -= hufGroup.base[i];
|
|
if (j < 0 || j >= MAX_SYMBOLS) { _throw(Err.DATA_ERROR); }
|
|
var nextSym = hufGroup.permute[j];
|
|
/* We have now decoded the symbol, which indicates either a new literal
|
|
byte, or a repeated run of the most recent literal byte. First,
|
|
check if nextSym indicates a repeated run, and if so loop collecting
|
|
how many times to repeat the last literal. */
|
|
if (nextSym === SYMBOL_RUNA || nextSym === SYMBOL_RUNB) {
|
|
/* If this is the start of a new run, zero out counter */
|
|
if (!runPos){
|
|
runPos = 1;
|
|
t = 0;
|
|
}
|
|
/* Neat trick that saves 1 symbol: instead of or-ing 0 or 1 at
|
|
each bit position, add 1 or 2 instead. For example,
|
|
1011 is 1<<0 + 1<<1 + 2<<2. 1010 is 2<<0 + 2<<1 + 1<<2.
|
|
You can make any bit pattern that way using 1 less symbol than
|
|
the basic or 0/1 method (except all bits 0, which would use no
|
|
symbols, but a run of length 0 doesn't mean anything in this
|
|
context). Thus space is saved. */
|
|
if (nextSym === SYMBOL_RUNA)
|
|
t += runPos;
|
|
else
|
|
t += 2 * runPos;
|
|
runPos <<= 1;
|
|
continue;
|
|
}
|
|
/* When we hit the first non-run symbol after a run, we now know
|
|
how many times to repeat the last literal, so append that many
|
|
copies to our buffer of decoded symbols (dbuf) now. (The last
|
|
literal used is the one at the head of the mtfSymbol array.) */
|
|
if (runPos){
|
|
runPos = 0;
|
|
if (dbufCount + t > this.dbufSize) { _throw(Err.DATA_ERROR); }
|
|
uc = symToByte[mtfSymbol[0]];
|
|
byteCount[uc] += t;
|
|
while (t--)
|
|
dbuf[dbufCount++] = uc;
|
|
}
|
|
/* Is this the terminating symbol? */
|
|
if (nextSym > symTotal)
|
|
break;
|
|
/* At this point, nextSym indicates a new literal character. Subtract
|
|
one to get the position in the MTF array at which this literal is
|
|
currently to be found. (Note that the result can't be -1 or 0,
|
|
because 0 and 1 are RUNA and RUNB. But another instance of the
|
|
first symbol in the mtf array, position 0, would have been handled
|
|
as part of a run above. Therefore 1 unused mtf position minus
|
|
2 non-literal nextSym values equals -1.) */
|
|
if (dbufCount >= this.dbufSize) { _throw(Err.DATA_ERROR); }
|
|
i = nextSym - 1;
|
|
uc = mtf(mtfSymbol, i);
|
|
uc = symToByte[uc];
|
|
/* We have our literal byte. Save it into dbuf. */
|
|
byteCount[uc]++;
|
|
dbuf[dbufCount++] = uc;
|
|
}
|
|
/* At this point, we've read all the huffman-coded symbols (and repeated
|
|
runs) for this block from the input stream, and decoded them into the
|
|
intermediate buffer. There are dbufCount many decoded bytes in dbuf[].
|
|
Now undo the Burrows-Wheeler transform on dbuf.
|
|
See http://dogma.net/markn/articles/bwt/bwt.htm
|
|
*/
|
|
if (origPointer < 0 || origPointer >= dbufCount) { _throw(Err.DATA_ERROR); }
|
|
/* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
|
|
j = 0;
|
|
for (i = 0; i < 256; i++) {
|
|
k = j + byteCount[i];
|
|
byteCount[i] = j;
|
|
j = k;
|
|
}
|
|
/* Figure out what order dbuf would be in if we sorted it. */
|
|
for (i = 0; i < dbufCount; i++) {
|
|
uc = dbuf[i] & 0xff;
|
|
dbuf[byteCount[uc]] |= (i << 8);
|
|
byteCount[uc]++;
|
|
}
|
|
/* Decode first byte by hand to initialize "previous" byte. Note that it
|
|
doesn't get output, and if the first three characters are identical
|
|
it doesn't qualify as a run (hence writeRunCountdown=5). */
|
|
var pos = 0, current = 0, run = 0;
|
|
if (dbufCount) {
|
|
pos = dbuf[origPointer];
|
|
current = (pos & 0xff);
|
|
pos >>= 8;
|
|
run = -1;
|
|
}
|
|
this.writePos = pos;
|
|
this.writeCurrent = current;
|
|
this.writeCount = dbufCount;
|
|
this.writeRun = run;
|
|
|
|
return true; /* more blocks to come */
|
|
};
|
|
/* Undo burrows-wheeler transform on intermediate buffer to produce output.
|
|
If start_bunzip was initialized with out_fd=-1, then up to len bytes of
|
|
data are written to outbuf. Return value is number of bytes written or
|
|
error (all errors are negative numbers). If out_fd!=-1, outbuf and len
|
|
are ignored, data is written to out_fd and return is RETVAL_OK or error.
|
|
*/
|
|
Bunzip.prototype._read_bunzip = function(outputBuffer, len) {
|
|
var copies, previous, outbyte;
|
|
/* james@jamestaylor.org: writeCount goes to -1 when the buffer is fully
|
|
decoded, which results in this returning RETVAL_LAST_BLOCK, also
|
|
equal to -1... Confusing, I'm returning 0 here to indicate no
|
|
bytes written into the buffer */
|
|
if (this.writeCount < 0) { return 0; }
|
|
|
|
var gotcount = 0;
|
|
var dbuf = this.dbuf, pos = this.writePos, current = this.writeCurrent;
|
|
var dbufCount = this.writeCount, outputsize = this.outputsize;
|
|
var run = this.writeRun;
|
|
|
|
while (dbufCount) {
|
|
dbufCount--;
|
|
previous = current;
|
|
pos = dbuf[pos];
|
|
current = pos & 0xff;
|
|
pos >>= 8;
|
|
if (run++ === 3){
|
|
copies = current;
|
|
outbyte = previous;
|
|
current = -1;
|
|
} else {
|
|
copies = 1;
|
|
outbyte = current;
|
|
}
|
|
this.blockCRC.updateCRCRun(outbyte, copies);
|
|
while (copies--) {
|
|
this.outputStream.writeByte(outbyte);
|
|
this.nextoutput++;
|
|
}
|
|
if (current != previous)
|
|
run = 0;
|
|
}
|
|
this.writeCount = dbufCount;
|
|
// check CRC
|
|
if (this.blockCRC.getCRC() !== this.targetBlockCRC) {
|
|
_throw(Err.DATA_ERROR, "Bad block CRC "+
|
|
"(got "+this.blockCRC.getCRC().toString(16)+
|
|
" expected "+this.targetBlockCRC.toString(16)+")");
|
|
}
|
|
return this.nextoutput;
|
|
};
|
|
|
|
var coerceInputStream = function(input) {
|
|
if ('readByte' in input) { return input; }
|
|
var inputStream = new Stream();
|
|
inputStream.pos = 0;
|
|
inputStream.readByte = function() { return input[this.pos++]; };
|
|
inputStream.seek = function(pos) { this.pos = pos; };
|
|
inputStream.eof = function() { return this.pos >= input.length; };
|
|
return inputStream;
|
|
};
|
|
var coerceOutputStream = function(output) {
|
|
var outputStream = new Stream();
|
|
var resizeOk = true;
|
|
if (output) {
|
|
if (typeof(output)==='number') {
|
|
outputStream.buffer = new Buffer(output);
|
|
resizeOk = false;
|
|
} else if ('writeByte' in output) {
|
|
return output;
|
|
} else {
|
|
outputStream.buffer = output;
|
|
resizeOk = false;
|
|
}
|
|
} else {
|
|
outputStream.buffer = new Buffer(16384);
|
|
}
|
|
outputStream.pos = 0;
|
|
outputStream.writeByte = function(_byte) {
|
|
if (resizeOk && this.pos >= this.buffer.length) {
|
|
var newBuffer = new Buffer(this.buffer.length*2);
|
|
this.buffer.copy(newBuffer);
|
|
this.buffer = newBuffer;
|
|
}
|
|
this.buffer[this.pos++] = _byte;
|
|
};
|
|
outputStream.getBuffer = function() {
|
|
// trim buffer
|
|
if (this.pos !== this.buffer.length) {
|
|
if (!resizeOk)
|
|
throw new TypeError('outputsize does not match decoded input');
|
|
var newBuffer = new Buffer(this.pos);
|
|
this.buffer.copy(newBuffer, 0, 0, this.pos);
|
|
this.buffer = newBuffer;
|
|
}
|
|
return this.buffer;
|
|
};
|
|
outputStream._coerced = true;
|
|
return outputStream;
|
|
};
|
|
|
|
/* Static helper functions */
|
|
Bunzip.Err = Err;
|
|
// 'input' can be a stream or a buffer
|
|
// 'output' can be a stream or a buffer or a number (buffer size)
|
|
Bunzip.decode = function(input, output, multistream) {
|
|
// make a stream from a buffer, if necessary
|
|
var inputStream = coerceInputStream(input);
|
|
var outputStream = coerceOutputStream(output);
|
|
|
|
var bz = new Bunzip(inputStream, outputStream);
|
|
while (true) {
|
|
if ('eof' in inputStream && inputStream.eof()) break;
|
|
if (bz._init_block()) {
|
|
bz._read_bunzip();
|
|
} else {
|
|
var targetStreamCRC = bz.reader.read(32) >>> 0; // (convert to unsigned)
|
|
if (targetStreamCRC !== bz.streamCRC) {
|
|
_throw(Err.DATA_ERROR, "Bad stream CRC "+
|
|
"(got "+bz.streamCRC.toString(16)+
|
|
" expected "+targetStreamCRC.toString(16)+")");
|
|
}
|
|
if (multistream &&
|
|
'eof' in inputStream &&
|
|
!inputStream.eof()) {
|
|
// note that start_bunzip will also resync the bit reader to next byte
|
|
bz._start_bunzip(inputStream, outputStream);
|
|
} else break;
|
|
}
|
|
}
|
|
if ('getBuffer' in outputStream)
|
|
return outputStream.getBuffer();
|
|
};
|
|
Bunzip.decodeBlock = function(input, pos, output) {
|
|
// make a stream from a buffer, if necessary
|
|
var inputStream = coerceInputStream(input);
|
|
var outputStream = coerceOutputStream(output);
|
|
var bz = new Bunzip(inputStream, outputStream);
|
|
bz.reader.seek(pos);
|
|
/* Fill the decode buffer for the block */
|
|
var moreBlocks = bz._get_next_block();
|
|
if (moreBlocks) {
|
|
/* Init the CRC for writing */
|
|
bz.blockCRC = new CRC32();
|
|
|
|
/* Zero this so the current byte from before the seek is not written */
|
|
bz.writeCopies = 0;
|
|
|
|
/* Decompress the block and write to stdout */
|
|
bz._read_bunzip();
|
|
// XXX keep writing?
|
|
}
|
|
if ('getBuffer' in outputStream)
|
|
return outputStream.getBuffer();
|
|
};
|
|
/* Reads bzip2 file from stream or buffer `input`, and invoke
|
|
* `callback(position, size)` once for each bzip2 block,
|
|
* where position gives the starting position (in *bits*)
|
|
* and size gives uncompressed size of the block (in *bytes*). */
|
|
Bunzip.table = function(input, callback, multistream) {
|
|
// make a stream from a buffer, if necessary
|
|
var inputStream = new Stream();
|
|
inputStream.delegate = coerceInputStream(input);
|
|
inputStream.pos = 0;
|
|
inputStream.readByte = function() {
|
|
this.pos++;
|
|
return this.delegate.readByte();
|
|
};
|
|
if (inputStream.delegate.eof) {
|
|
inputStream.eof = inputStream.delegate.eof.bind(inputStream.delegate);
|
|
}
|
|
var outputStream = new Stream();
|
|
outputStream.pos = 0;
|
|
outputStream.writeByte = function() { this.pos++; };
|
|
|
|
var bz = new Bunzip(inputStream, outputStream);
|
|
var blockSize = bz.dbufSize;
|
|
while (true) {
|
|
if ('eof' in inputStream && inputStream.eof()) break;
|
|
|
|
var position = inputStream.pos*8 + bz.reader.bitOffset;
|
|
if (bz.reader.hasByte) { position -= 8; }
|
|
|
|
if (bz._init_block()) {
|
|
var start = outputStream.pos;
|
|
bz._read_bunzip();
|
|
callback(position, outputStream.pos - start);
|
|
} else {
|
|
var crc = bz.reader.read(32); // (but we ignore the crc)
|
|
if (multistream &&
|
|
'eof' in inputStream &&
|
|
!inputStream.eof()) {
|
|
// note that start_bunzip will also resync the bit reader to next byte
|
|
bz._start_bunzip(inputStream, outputStream);
|
|
console.assert(bz.dbufSize === blockSize,
|
|
"shouldn't change block size within multistream file");
|
|
} else break;
|
|
}
|
|
}
|
|
};
|
|
|
|
Bunzip.Stream = Stream;
|
|
|
|
Bunzip.version = pjson.version;
|
|
Bunzip.license = pjson.license;
|
|
|
|
module.exports = Bunzip;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 831:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
// copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
// following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included
|
|
// in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
// a duplex stream is just a stream that is both readable and writable.
|
|
// Since JS doesn't have multiple prototypal inheritance, this class
|
|
// prototypally inherits from Readable, and then parasitically from
|
|
// Writable.
|
|
|
|
|
|
|
|
/*<replacement>*/
|
|
|
|
var pna = __webpack_require__(822);
|
|
/*</replacement>*/
|
|
|
|
/*<replacement>*/
|
|
var objectKeys = Object.keys || function (obj) {
|
|
var keys = [];
|
|
for (var key in obj) {
|
|
keys.push(key);
|
|
}return keys;
|
|
};
|
|
/*</replacement>*/
|
|
|
|
module.exports = Duplex;
|
|
|
|
/*<replacement>*/
|
|
var util = Object.create(__webpack_require__(286));
|
|
util.inherits = __webpack_require__(689);
|
|
/*</replacement>*/
|
|
|
|
var Readable = __webpack_require__(226);
|
|
var Writable = __webpack_require__(241);
|
|
|
|
util.inherits(Duplex, Readable);
|
|
|
|
{
|
|
// avoid scope creep, the keys array can then be collected
|
|
var keys = objectKeys(Writable.prototype);
|
|
for (var v = 0; v < keys.length; v++) {
|
|
var method = keys[v];
|
|
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
|
}
|
|
}
|
|
|
|
function Duplex(options) {
|
|
if (!(this instanceof Duplex)) return new Duplex(options);
|
|
|
|
Readable.call(this, options);
|
|
Writable.call(this, options);
|
|
|
|
if (options && options.readable === false) this.readable = false;
|
|
|
|
if (options && options.writable === false) this.writable = false;
|
|
|
|
this.allowHalfOpen = true;
|
|
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
|
|
|
|
this.once('end', onend);
|
|
}
|
|
|
|
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
|
|
// making it explicit this property is not enumerable
|
|
// because otherwise some prototype manipulation in
|
|
// userland will fail
|
|
enumerable: false,
|
|
get: function () {
|
|
return this._writableState.highWaterMark;
|
|
}
|
|
});
|
|
|
|
// the no-half-open enforcer
|
|
function onend() {
|
|
// if we allow half-open state, or if the writable side ended,
|
|
// then we're ok.
|
|
if (this.allowHalfOpen || this._writableState.ended) return;
|
|
|
|
// no more data can be written.
|
|
// But allow more writes to happen in this tick.
|
|
pna.nextTick(onEndNT, this);
|
|
}
|
|
|
|
function onEndNT(self) {
|
|
self.end();
|
|
}
|
|
|
|
Object.defineProperty(Duplex.prototype, 'destroyed', {
|
|
get: function () {
|
|
if (this._readableState === undefined || this._writableState === undefined) {
|
|
return false;
|
|
}
|
|
return this._readableState.destroyed && this._writableState.destroyed;
|
|
},
|
|
set: function (value) {
|
|
// we ignore the value if the stream
|
|
// has not been initialized yet
|
|
if (this._readableState === undefined || this._writableState === undefined) {
|
|
return;
|
|
}
|
|
|
|
// backward compatibility, the user is explicitly
|
|
// managing destroyed
|
|
this._readableState.destroyed = value;
|
|
this._writableState.destroyed = value;
|
|
}
|
|
});
|
|
|
|
Duplex.prototype._destroy = function (err, cb) {
|
|
this.push(null);
|
|
this.end();
|
|
|
|
pna.nextTick(cb, err);
|
|
};
|
|
|
|
/***/ }),
|
|
|
|
/***/ 835:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("url");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 849:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var through = __webpack_require__(400);
|
|
var bz2 = __webpack_require__(370);
|
|
var bitIterator = __webpack_require__(690);
|
|
|
|
module.exports = unbzip2Stream;
|
|
|
|
function unbzip2Stream() {
|
|
var bufferQueue = [];
|
|
var hasBytes = 0;
|
|
var blockSize = 0;
|
|
var broken = false;
|
|
var done = false;
|
|
var bitReader = null;
|
|
var streamCRC = null;
|
|
|
|
function decompressBlock(push){
|
|
if(!blockSize){
|
|
blockSize = bz2.header(bitReader);
|
|
//console.error("got header of", blockSize);
|
|
streamCRC = 0;
|
|
return true;
|
|
}else{
|
|
var bufsize = 100000 * blockSize;
|
|
var buf = new Int32Array(bufsize);
|
|
|
|
var chunk = [];
|
|
var f = function(b) {
|
|
chunk.push(b);
|
|
};
|
|
|
|
streamCRC = bz2.decompress(bitReader, f, buf, bufsize, streamCRC);
|
|
if (streamCRC === null) {
|
|
// reset for next bzip2 header
|
|
blockSize = 0;
|
|
return false;
|
|
}else{
|
|
//console.error('decompressed', chunk.length,'bytes');
|
|
push(Buffer.from(chunk));
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
var outlength = 0;
|
|
function decompressAndQueue(stream) {
|
|
if (broken) return;
|
|
try {
|
|
return decompressBlock(function(d) {
|
|
stream.queue(d);
|
|
if (d !== null) {
|
|
//console.error('write at', outlength.toString(16));
|
|
outlength += d.length;
|
|
} else {
|
|
//console.error('written EOS');
|
|
}
|
|
});
|
|
} catch(e) {
|
|
//console.error(e);
|
|
stream.emit('error', e);
|
|
broken = true;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return through(
|
|
function write(data) {
|
|
//console.error('received', data.length,'bytes in', typeof data);
|
|
bufferQueue.push(data);
|
|
hasBytes += data.length;
|
|
if (bitReader === null) {
|
|
bitReader = bitIterator(function() {
|
|
return bufferQueue.shift();
|
|
});
|
|
}
|
|
while (!broken && hasBytes - bitReader.bytesRead + 1 >= ((25000 + 100000 * blockSize) || 4)){
|
|
//console.error('decompressing with', hasBytes - bitReader.bytesRead + 1, 'bytes in buffer');
|
|
decompressAndQueue(this);
|
|
}
|
|
},
|
|
function end(x) {
|
|
//console.error(x,'last compressing with', hasBytes, 'bytes in buffer');
|
|
while (!broken && bitReader && hasBytes > bitReader.bytesRead){
|
|
decompressAndQueue(this);
|
|
}
|
|
if (!broken) {
|
|
if (streamCRC !== null)
|
|
this.emit('error', new Error("input stream ended prematurely"));
|
|
this.queue(null);
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 850:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const zlib = __webpack_require__(761);
|
|
const decompressTar = __webpack_require__(791);
|
|
const fileType = __webpack_require__(285);
|
|
const isStream = __webpack_require__(323);
|
|
|
|
module.exports = () => input => {
|
|
if (!Buffer.isBuffer(input) && !isStream(input)) {
|
|
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`));
|
|
}
|
|
|
|
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'gz')) {
|
|
return Promise.resolve([]);
|
|
}
|
|
|
|
const unzip = zlib.createGunzip();
|
|
const result = decompressTar()(unzip);
|
|
|
|
if (Buffer.isBuffer(input)) {
|
|
unzip.end(input);
|
|
} else {
|
|
input.pipe(unzip);
|
|
}
|
|
|
|
return result;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 852:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
/*!
|
|
* mime-db
|
|
* Copyright(c) 2014 Jonathan Ong
|
|
* MIT Licensed
|
|
*/
|
|
|
|
/**
|
|
* Module exports.
|
|
*/
|
|
|
|
module.exports = __webpack_require__(512)
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 856:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
module.exports = __webpack_require__(982);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 861:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const PassThrough = __webpack_require__(413).PassThrough;
|
|
const zlib = __webpack_require__(761);
|
|
const mimicResponse = __webpack_require__(89);
|
|
|
|
module.exports = response => {
|
|
// TODO: Use Array#includes when targeting Node.js 6
|
|
if (['gzip', 'deflate'].indexOf(response.headers['content-encoding']) === -1) {
|
|
return response;
|
|
}
|
|
|
|
const unzip = zlib.createUnzip();
|
|
const stream = new PassThrough();
|
|
|
|
mimicResponse(response, stream);
|
|
|
|
unzip.on('error', err => {
|
|
if (err.code === 'Z_BUF_ERROR') {
|
|
stream.end();
|
|
return;
|
|
}
|
|
|
|
stream.emit('error', err);
|
|
});
|
|
|
|
response.pipe(unzip).pipe(stream);
|
|
|
|
return stream;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 868:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var Readable = __webpack_require__(574).Readable
|
|
var inherits = __webpack_require__(689)
|
|
|
|
module.exports = from2
|
|
|
|
from2.ctor = ctor
|
|
from2.obj = obj
|
|
|
|
var Proto = ctor()
|
|
|
|
function toFunction(list) {
|
|
list = list.slice()
|
|
return function (_, cb) {
|
|
var err = null
|
|
var item = list.length ? list.shift() : null
|
|
if (item instanceof Error) {
|
|
err = item
|
|
item = null
|
|
}
|
|
|
|
cb(err, item)
|
|
}
|
|
}
|
|
|
|
function from2(opts, read) {
|
|
if (typeof opts !== 'object' || Array.isArray(opts)) {
|
|
read = opts
|
|
opts = {}
|
|
}
|
|
|
|
var rs = new Proto(opts)
|
|
rs._from = Array.isArray(read) ? toFunction(read) : (read || noop)
|
|
return rs
|
|
}
|
|
|
|
function ctor(opts, read) {
|
|
if (typeof opts === 'function') {
|
|
read = opts
|
|
opts = {}
|
|
}
|
|
|
|
opts = defaults(opts)
|
|
|
|
inherits(Class, Readable)
|
|
function Class(override) {
|
|
if (!(this instanceof Class)) return new Class(override)
|
|
this._reading = false
|
|
this._callback = check
|
|
this.destroyed = false
|
|
Readable.call(this, override || opts)
|
|
|
|
var self = this
|
|
var hwm = this._readableState.highWaterMark
|
|
|
|
function check(err, data) {
|
|
if (self.destroyed) return
|
|
if (err) return self.destroy(err)
|
|
if (data === null) return self.push(null)
|
|
self._reading = false
|
|
if (self.push(data)) self._read(hwm)
|
|
}
|
|
}
|
|
|
|
Class.prototype._from = read || noop
|
|
Class.prototype._read = function(size) {
|
|
if (this._reading || this.destroyed) return
|
|
this._reading = true
|
|
this._from(size, this._callback)
|
|
}
|
|
|
|
Class.prototype.destroy = function(err) {
|
|
if (this.destroyed) return
|
|
this.destroyed = true
|
|
|
|
var self = this
|
|
process.nextTick(function() {
|
|
if (err) self.emit('error', err)
|
|
self.emit('close')
|
|
})
|
|
}
|
|
|
|
return Class
|
|
}
|
|
|
|
function obj(opts, read) {
|
|
if (typeof opts === 'function' || Array.isArray(opts)) {
|
|
read = opts
|
|
opts = {}
|
|
}
|
|
|
|
opts = defaults(opts)
|
|
opts.objectMode = true
|
|
opts.highWaterMark = 16
|
|
|
|
return from2(opts, read)
|
|
}
|
|
|
|
function noop () {}
|
|
|
|
function defaults(opts) {
|
|
opts = opts || {}
|
|
return opts
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 874:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const url = __webpack_require__(835);
|
|
const http = __webpack_require__(605);
|
|
const https = __webpack_require__(211);
|
|
const util = __webpack_require__(729);
|
|
let fs;
|
|
let tunnel;
|
|
var HttpCodes;
|
|
(function (HttpCodes) {
|
|
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
|
HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
|
|
HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
|
|
HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
|
|
HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
|
|
HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
|
|
HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
|
|
HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
|
|
HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
|
|
HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
|
|
HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
|
|
HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
|
|
HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
|
|
HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
|
|
HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
|
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
|
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
|
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
|
|
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
|
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
|
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
|
HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));
|
|
const HttpRedirectCodes = [HttpCodes.MovedPermanently, HttpCodes.ResourceMoved, HttpCodes.SeeOther, HttpCodes.TemporaryRedirect, HttpCodes.PermanentRedirect];
|
|
const HttpResponseRetryCodes = [HttpCodes.BadGateway, HttpCodes.ServiceUnavailable, HttpCodes.GatewayTimeout];
|
|
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
|
const ExponentialBackoffCeiling = 10;
|
|
const ExponentialBackoffTimeSlice = 5;
|
|
class HttpClientResponse {
|
|
constructor(message) {
|
|
this.message = message;
|
|
}
|
|
readBody() {
|
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
let buffer = Buffer.alloc(0);
|
|
const encodingCharset = util.obtainContentCharset(this);
|
|
// Extract Encoding from header: 'content-encoding'
|
|
// Match `gzip`, `gzip, deflate` variations of GZIP encoding
|
|
const contentEncoding = this.message.headers['content-encoding'] || '';
|
|
const isGzippedEncoded = new RegExp('(gzip$)|(gzip, *deflate)').test(contentEncoding);
|
|
this.message.on('data', function (data) {
|
|
const chunk = (typeof data === 'string') ? Buffer.from(data, encodingCharset) : data;
|
|
buffer = Buffer.concat([buffer, chunk]);
|
|
}).on('end', function () {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (isGzippedEncoded) { // Process GZipped Response Body HERE
|
|
const gunzippedBody = yield util.decompressGzippedContent(buffer, encodingCharset);
|
|
resolve(gunzippedBody);
|
|
}
|
|
else {
|
|
resolve(buffer.toString(encodingCharset));
|
|
}
|
|
});
|
|
}).on('error', function (err) {
|
|
reject(err);
|
|
});
|
|
}));
|
|
}
|
|
}
|
|
exports.HttpClientResponse = HttpClientResponse;
|
|
function isHttps(requestUrl) {
|
|
let parsedUrl = url.parse(requestUrl);
|
|
return parsedUrl.protocol === 'https:';
|
|
}
|
|
exports.isHttps = isHttps;
|
|
var EnvironmentVariables;
|
|
(function (EnvironmentVariables) {
|
|
EnvironmentVariables["HTTP_PROXY"] = "HTTP_PROXY";
|
|
EnvironmentVariables["HTTPS_PROXY"] = "HTTPS_PROXY";
|
|
EnvironmentVariables["NO_PROXY"] = "NO_PROXY";
|
|
})(EnvironmentVariables || (EnvironmentVariables = {}));
|
|
class HttpClient {
|
|
constructor(userAgent, handlers, requestOptions) {
|
|
this._ignoreSslError = false;
|
|
this._allowRedirects = true;
|
|
this._allowRedirectDowngrade = false;
|
|
this._maxRedirects = 50;
|
|
this._allowRetries = false;
|
|
this._maxRetries = 1;
|
|
this._keepAlive = false;
|
|
this._disposed = false;
|
|
this.userAgent = userAgent;
|
|
this.handlers = handlers || [];
|
|
let no_proxy = process.env[EnvironmentVariables.NO_PROXY];
|
|
if (no_proxy) {
|
|
this._httpProxyBypassHosts = [];
|
|
no_proxy.split(',').forEach(bypass => {
|
|
this._httpProxyBypassHosts.push(new RegExp(bypass, 'i'));
|
|
});
|
|
}
|
|
this.requestOptions = requestOptions;
|
|
if (requestOptions) {
|
|
if (requestOptions.ignoreSslError != null) {
|
|
this._ignoreSslError = requestOptions.ignoreSslError;
|
|
}
|
|
this._socketTimeout = requestOptions.socketTimeout;
|
|
this._httpProxy = requestOptions.proxy;
|
|
if (requestOptions.proxy && requestOptions.proxy.proxyBypassHosts) {
|
|
this._httpProxyBypassHosts = [];
|
|
requestOptions.proxy.proxyBypassHosts.forEach(bypass => {
|
|
this._httpProxyBypassHosts.push(new RegExp(bypass, 'i'));
|
|
});
|
|
}
|
|
this._certConfig = requestOptions.cert;
|
|
if (this._certConfig) {
|
|
// If using cert, need fs
|
|
fs = __webpack_require__(747);
|
|
// cache the cert content into memory, so we don't have to read it from disk every time
|
|
if (this._certConfig.caFile && fs.existsSync(this._certConfig.caFile)) {
|
|
this._ca = fs.readFileSync(this._certConfig.caFile, 'utf8');
|
|
}
|
|
if (this._certConfig.certFile && fs.existsSync(this._certConfig.certFile)) {
|
|
this._cert = fs.readFileSync(this._certConfig.certFile, 'utf8');
|
|
}
|
|
if (this._certConfig.keyFile && fs.existsSync(this._certConfig.keyFile)) {
|
|
this._key = fs.readFileSync(this._certConfig.keyFile, 'utf8');
|
|
}
|
|
}
|
|
if (requestOptions.allowRedirects != null) {
|
|
this._allowRedirects = requestOptions.allowRedirects;
|
|
}
|
|
if (requestOptions.allowRedirectDowngrade != null) {
|
|
this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
|
|
}
|
|
if (requestOptions.maxRedirects != null) {
|
|
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
|
|
}
|
|
if (requestOptions.keepAlive != null) {
|
|
this._keepAlive = requestOptions.keepAlive;
|
|
}
|
|
if (requestOptions.allowRetries != null) {
|
|
this._allowRetries = requestOptions.allowRetries;
|
|
}
|
|
if (requestOptions.maxRetries != null) {
|
|
this._maxRetries = requestOptions.maxRetries;
|
|
}
|
|
}
|
|
}
|
|
options(requestUrl, additionalHeaders) {
|
|
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
|
}
|
|
get(requestUrl, additionalHeaders) {
|
|
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
|
}
|
|
del(requestUrl, additionalHeaders) {
|
|
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
|
}
|
|
post(requestUrl, data, additionalHeaders) {
|
|
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
|
}
|
|
patch(requestUrl, data, additionalHeaders) {
|
|
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
|
}
|
|
put(requestUrl, data, additionalHeaders) {
|
|
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
|
}
|
|
head(requestUrl, additionalHeaders) {
|
|
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
|
}
|
|
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
|
return this.request(verb, requestUrl, stream, additionalHeaders);
|
|
}
|
|
/**
|
|
* Makes a raw http request.
|
|
* All other methods such as get, post, patch, and request ultimately call this.
|
|
* Prefer get, del, post and patch
|
|
*/
|
|
request(verb, requestUrl, data, headers) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (this._disposed) {
|
|
throw new Error("Client has already been disposed.");
|
|
}
|
|
let parsedUrl = url.parse(requestUrl);
|
|
let info = this._prepareRequest(verb, parsedUrl, headers);
|
|
// Only perform retries on reads since writes may not be idempotent.
|
|
let maxTries = (this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1) ? this._maxRetries + 1 : 1;
|
|
let numTries = 0;
|
|
let response;
|
|
while (numTries < maxTries) {
|
|
response = yield this.requestRaw(info, data);
|
|
// Check if it's an authentication challenge
|
|
if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) {
|
|
let authenticationHandler;
|
|
for (let i = 0; i < this.handlers.length; i++) {
|
|
if (this.handlers[i].canHandleAuthentication(response)) {
|
|
authenticationHandler = this.handlers[i];
|
|
break;
|
|
}
|
|
}
|
|
if (authenticationHandler) {
|
|
return authenticationHandler.handleAuthentication(this, info, data);
|
|
}
|
|
else {
|
|
// We have received an unauthorized response but have no handlers to handle it.
|
|
// Let the response return to the caller.
|
|
return response;
|
|
}
|
|
}
|
|
let redirectsRemaining = this._maxRedirects;
|
|
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1
|
|
&& this._allowRedirects
|
|
&& redirectsRemaining > 0) {
|
|
const redirectUrl = response.message.headers["location"];
|
|
if (!redirectUrl) {
|
|
// if there's no location to redirect to, we won't
|
|
break;
|
|
}
|
|
let parsedRedirectUrl = url.parse(redirectUrl);
|
|
if (parsedUrl.protocol == 'https:' && parsedUrl.protocol != parsedRedirectUrl.protocol && !this._allowRedirectDowngrade) {
|
|
throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.");
|
|
}
|
|
// we need to finish reading the response before reassigning response
|
|
// which will leak the open socket.
|
|
yield response.readBody();
|
|
// let's make the request with the new redirectUrl
|
|
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
|
response = yield this.requestRaw(info, data);
|
|
redirectsRemaining--;
|
|
}
|
|
if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) {
|
|
// If not a retry code, return immediately instead of retrying
|
|
return response;
|
|
}
|
|
numTries += 1;
|
|
if (numTries < maxTries) {
|
|
yield response.readBody();
|
|
yield this._performExponentialBackoff(numTries);
|
|
}
|
|
}
|
|
return response;
|
|
});
|
|
}
|
|
/**
|
|
* Needs to be called if keepAlive is set to true in request options.
|
|
*/
|
|
dispose() {
|
|
if (this._agent) {
|
|
this._agent.destroy();
|
|
}
|
|
this._disposed = true;
|
|
}
|
|
/**
|
|
* Raw request.
|
|
* @param info
|
|
* @param data
|
|
*/
|
|
requestRaw(info, data) {
|
|
return new Promise((resolve, reject) => {
|
|
let callbackForResult = function (err, res) {
|
|
if (err) {
|
|
reject(err);
|
|
}
|
|
resolve(res);
|
|
};
|
|
this.requestRawWithCallback(info, data, callbackForResult);
|
|
});
|
|
}
|
|
/**
|
|
* Raw request with callback.
|
|
* @param info
|
|
* @param data
|
|
* @param onResult
|
|
*/
|
|
requestRawWithCallback(info, data, onResult) {
|
|
let socket;
|
|
if (typeof (data) === 'string') {
|
|
info.options.headers["Content-Length"] = Buffer.byteLength(data, 'utf8');
|
|
}
|
|
let callbackCalled = false;
|
|
let handleResult = (err, res) => {
|
|
if (!callbackCalled) {
|
|
callbackCalled = true;
|
|
onResult(err, res);
|
|
}
|
|
};
|
|
let req = info.httpModule.request(info.options, (msg) => {
|
|
let res = new HttpClientResponse(msg);
|
|
handleResult(null, res);
|
|
});
|
|
req.on('socket', (sock) => {
|
|
socket = sock;
|
|
});
|
|
// If we ever get disconnected, we want the socket to timeout eventually
|
|
req.setTimeout(this._socketTimeout || 3 * 60000, () => {
|
|
if (socket) {
|
|
socket.destroy();
|
|
}
|
|
handleResult(new Error('Request timeout: ' + info.options.path), null);
|
|
});
|
|
req.on('error', function (err) {
|
|
// err has statusCode property
|
|
// res should have headers
|
|
handleResult(err, null);
|
|
});
|
|
if (data && typeof (data) === 'string') {
|
|
req.write(data, 'utf8');
|
|
}
|
|
if (data && typeof (data) !== 'string') {
|
|
data.on('close', function () {
|
|
req.end();
|
|
});
|
|
data.pipe(req);
|
|
}
|
|
else {
|
|
req.end();
|
|
}
|
|
}
|
|
_prepareRequest(method, requestUrl, headers) {
|
|
const info = {};
|
|
info.parsedUrl = requestUrl;
|
|
const usingSsl = info.parsedUrl.protocol === 'https:';
|
|
info.httpModule = usingSsl ? https : http;
|
|
const defaultPort = usingSsl ? 443 : 80;
|
|
info.options = {};
|
|
info.options.host = info.parsedUrl.hostname;
|
|
info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort;
|
|
info.options.path = (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
|
info.options.method = method;
|
|
info.options.headers = this._mergeHeaders(headers);
|
|
if (this.userAgent != null) {
|
|
info.options.headers["user-agent"] = this.userAgent;
|
|
}
|
|
info.options.agent = this._getAgent(info.parsedUrl);
|
|
// gives handlers an opportunity to participate
|
|
if (this.handlers && !this._isPresigned(url.format(requestUrl))) {
|
|
this.handlers.forEach((handler) => {
|
|
handler.prepareRequest(info.options);
|
|
});
|
|
}
|
|
return info;
|
|
}
|
|
_isPresigned(requestUrl) {
|
|
if (this.requestOptions && this.requestOptions.presignedUrlPatterns) {
|
|
const patterns = this.requestOptions.presignedUrlPatterns;
|
|
for (let i = 0; i < patterns.length; i++) {
|
|
if (requestUrl.match(patterns[i])) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
_mergeHeaders(headers) {
|
|
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {});
|
|
if (this.requestOptions && this.requestOptions.headers) {
|
|
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));
|
|
}
|
|
return lowercaseKeys(headers || {});
|
|
}
|
|
_getAgent(parsedUrl) {
|
|
let agent;
|
|
let proxy = this._getProxy(parsedUrl);
|
|
let useProxy = proxy.proxyUrl && proxy.proxyUrl.hostname && !this._isMatchInBypassProxyList(parsedUrl);
|
|
if (this._keepAlive && useProxy) {
|
|
agent = this._proxyAgent;
|
|
}
|
|
if (this._keepAlive && !useProxy) {
|
|
agent = this._agent;
|
|
}
|
|
// if agent is already assigned use that agent.
|
|
if (!!agent) {
|
|
return agent;
|
|
}
|
|
const usingSsl = parsedUrl.protocol === 'https:';
|
|
let maxSockets = 100;
|
|
if (!!this.requestOptions) {
|
|
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
|
}
|
|
if (useProxy) {
|
|
// If using proxy, need tunnel
|
|
if (!tunnel) {
|
|
tunnel = __webpack_require__(856);
|
|
}
|
|
const agentOptions = {
|
|
maxSockets: maxSockets,
|
|
keepAlive: this._keepAlive,
|
|
proxy: {
|
|
proxyAuth: proxy.proxyAuth,
|
|
host: proxy.proxyUrl.hostname,
|
|
port: proxy.proxyUrl.port
|
|
},
|
|
};
|
|
let tunnelAgent;
|
|
const overHttps = proxy.proxyUrl.protocol === 'https:';
|
|
if (usingSsl) {
|
|
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
|
|
}
|
|
else {
|
|
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
|
|
}
|
|
agent = tunnelAgent(agentOptions);
|
|
this._proxyAgent = agent;
|
|
}
|
|
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
|
if (this._keepAlive && !agent) {
|
|
const options = { keepAlive: this._keepAlive, maxSockets: maxSockets };
|
|
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
|
this._agent = agent;
|
|
}
|
|
// if not using private agent and tunnel agent isn't setup then use global agent
|
|
if (!agent) {
|
|
agent = usingSsl ? https.globalAgent : http.globalAgent;
|
|
}
|
|
if (usingSsl && this._ignoreSslError) {
|
|
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
|
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
|
// we have to cast it to any and change it directly
|
|
agent.options = Object.assign(agent.options || {}, { rejectUnauthorized: false });
|
|
}
|
|
if (usingSsl && this._certConfig) {
|
|
agent.options = Object.assign(agent.options || {}, { ca: this._ca, cert: this._cert, key: this._key, passphrase: this._certConfig.passphrase });
|
|
}
|
|
return agent;
|
|
}
|
|
_getProxy(parsedUrl) {
|
|
let usingSsl = parsedUrl.protocol === 'https:';
|
|
let proxyConfig = this._httpProxy;
|
|
// fallback to http_proxy and https_proxy env
|
|
let https_proxy = process.env[EnvironmentVariables.HTTPS_PROXY];
|
|
let http_proxy = process.env[EnvironmentVariables.HTTP_PROXY];
|
|
if (!proxyConfig) {
|
|
if (https_proxy && usingSsl) {
|
|
proxyConfig = {
|
|
proxyUrl: https_proxy
|
|
};
|
|
}
|
|
else if (http_proxy) {
|
|
proxyConfig = {
|
|
proxyUrl: http_proxy
|
|
};
|
|
}
|
|
}
|
|
let proxyUrl;
|
|
let proxyAuth;
|
|
if (proxyConfig) {
|
|
if (proxyConfig.proxyUrl.length > 0) {
|
|
proxyUrl = url.parse(proxyConfig.proxyUrl);
|
|
}
|
|
if (proxyConfig.proxyUsername || proxyConfig.proxyPassword) {
|
|
proxyAuth = proxyConfig.proxyUsername + ":" + proxyConfig.proxyPassword;
|
|
}
|
|
}
|
|
return { proxyUrl: proxyUrl, proxyAuth: proxyAuth };
|
|
}
|
|
_isMatchInBypassProxyList(parsedUrl) {
|
|
if (!this._httpProxyBypassHosts) {
|
|
return false;
|
|
}
|
|
let bypass = false;
|
|
this._httpProxyBypassHosts.forEach(bypassHost => {
|
|
if (bypassHost.test(parsedUrl.href)) {
|
|
bypass = true;
|
|
}
|
|
});
|
|
return bypass;
|
|
}
|
|
_performExponentialBackoff(retryNumber) {
|
|
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
|
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
|
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
|
}
|
|
}
|
|
exports.HttpClient = HttpClient;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 881:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
module.exports = function (str) {
|
|
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
|
|
return '%' + c.charCodeAt(0).toString(16).toUpperCase();
|
|
});
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 882:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
// copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
// following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included
|
|
// in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
// a passthrough stream.
|
|
// basically just the most minimal sort of Transform stream.
|
|
// Every written chunk gets output as-is.
|
|
|
|
|
|
|
|
module.exports = PassThrough;
|
|
|
|
var Transform = __webpack_require__(925);
|
|
|
|
/*<replacement>*/
|
|
var util = Object.create(__webpack_require__(286));
|
|
util.inherits = __webpack_require__(689);
|
|
/*</replacement>*/
|
|
|
|
util.inherits(PassThrough, Transform);
|
|
|
|
function PassThrough(options) {
|
|
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
|
|
|
Transform.call(this, options);
|
|
}
|
|
|
|
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
|
cb(null, chunk);
|
|
};
|
|
|
|
/***/ }),
|
|
|
|
/***/ 883:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = eval("require")("electron");
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 897:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var utils = __webpack_require__(581);
|
|
var formats = __webpack_require__(13);
|
|
var has = Object.prototype.hasOwnProperty;
|
|
|
|
var arrayPrefixGenerators = {
|
|
brackets: function brackets(prefix) {
|
|
return prefix + '[]';
|
|
},
|
|
comma: 'comma',
|
|
indices: function indices(prefix, key) {
|
|
return prefix + '[' + key + ']';
|
|
},
|
|
repeat: function repeat(prefix) {
|
|
return prefix;
|
|
}
|
|
};
|
|
|
|
var isArray = Array.isArray;
|
|
var push = Array.prototype.push;
|
|
var pushToArray = function (arr, valueOrArray) {
|
|
push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
|
|
};
|
|
|
|
var toISO = Date.prototype.toISOString;
|
|
|
|
var defaultFormat = formats['default'];
|
|
var defaults = {
|
|
addQueryPrefix: false,
|
|
allowDots: false,
|
|
charset: 'utf-8',
|
|
charsetSentinel: false,
|
|
delimiter: '&',
|
|
encode: true,
|
|
encoder: utils.encode,
|
|
encodeValuesOnly: false,
|
|
format: defaultFormat,
|
|
formatter: formats.formatters[defaultFormat],
|
|
// deprecated
|
|
indices: false,
|
|
serializeDate: function serializeDate(date) {
|
|
return toISO.call(date);
|
|
},
|
|
skipNulls: false,
|
|
strictNullHandling: false
|
|
};
|
|
|
|
var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
|
|
return typeof v === 'string'
|
|
|| typeof v === 'number'
|
|
|| typeof v === 'boolean'
|
|
|| typeof v === 'symbol'
|
|
|| typeof v === 'bigint';
|
|
};
|
|
|
|
var stringify = function stringify(
|
|
object,
|
|
prefix,
|
|
generateArrayPrefix,
|
|
strictNullHandling,
|
|
skipNulls,
|
|
encoder,
|
|
filter,
|
|
sort,
|
|
allowDots,
|
|
serializeDate,
|
|
formatter,
|
|
encodeValuesOnly,
|
|
charset
|
|
) {
|
|
var obj = object;
|
|
if (typeof filter === 'function') {
|
|
obj = filter(prefix, obj);
|
|
} else if (obj instanceof Date) {
|
|
obj = serializeDate(obj);
|
|
} else if (generateArrayPrefix === 'comma' && isArray(obj)) {
|
|
obj = obj.join(',');
|
|
}
|
|
|
|
if (obj === null) {
|
|
if (strictNullHandling) {
|
|
return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key') : prefix;
|
|
}
|
|
|
|
obj = '';
|
|
}
|
|
|
|
if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
|
|
if (encoder) {
|
|
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key');
|
|
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value'))];
|
|
}
|
|
return [formatter(prefix) + '=' + formatter(String(obj))];
|
|
}
|
|
|
|
var values = [];
|
|
|
|
if (typeof obj === 'undefined') {
|
|
return values;
|
|
}
|
|
|
|
var objKeys;
|
|
if (isArray(filter)) {
|
|
objKeys = filter;
|
|
} else {
|
|
var keys = Object.keys(obj);
|
|
objKeys = sort ? keys.sort(sort) : keys;
|
|
}
|
|
|
|
for (var i = 0; i < objKeys.length; ++i) {
|
|
var key = objKeys[i];
|
|
|
|
if (skipNulls && obj[key] === null) {
|
|
continue;
|
|
}
|
|
|
|
if (isArray(obj)) {
|
|
pushToArray(values, stringify(
|
|
obj[key],
|
|
typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix,
|
|
generateArrayPrefix,
|
|
strictNullHandling,
|
|
skipNulls,
|
|
encoder,
|
|
filter,
|
|
sort,
|
|
allowDots,
|
|
serializeDate,
|
|
formatter,
|
|
encodeValuesOnly,
|
|
charset
|
|
));
|
|
} else {
|
|
pushToArray(values, stringify(
|
|
obj[key],
|
|
prefix + (allowDots ? '.' + key : '[' + key + ']'),
|
|
generateArrayPrefix,
|
|
strictNullHandling,
|
|
skipNulls,
|
|
encoder,
|
|
filter,
|
|
sort,
|
|
allowDots,
|
|
serializeDate,
|
|
formatter,
|
|
encodeValuesOnly,
|
|
charset
|
|
));
|
|
}
|
|
}
|
|
|
|
return values;
|
|
};
|
|
|
|
var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
|
|
if (!opts) {
|
|
return defaults;
|
|
}
|
|
|
|
if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
|
|
throw new TypeError('Encoder has to be a function.');
|
|
}
|
|
|
|
var charset = opts.charset || defaults.charset;
|
|
if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
|
|
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
|
|
}
|
|
|
|
var format = formats['default'];
|
|
if (typeof opts.format !== 'undefined') {
|
|
if (!has.call(formats.formatters, opts.format)) {
|
|
throw new TypeError('Unknown format option provided.');
|
|
}
|
|
format = opts.format;
|
|
}
|
|
var formatter = formats.formatters[format];
|
|
|
|
var filter = defaults.filter;
|
|
if (typeof opts.filter === 'function' || isArray(opts.filter)) {
|
|
filter = opts.filter;
|
|
}
|
|
|
|
return {
|
|
addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix,
|
|
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
|
|
charset: charset,
|
|
charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel,
|
|
delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter,
|
|
encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode,
|
|
encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder,
|
|
encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly,
|
|
filter: filter,
|
|
formatter: formatter,
|
|
serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate,
|
|
skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls,
|
|
sort: typeof opts.sort === 'function' ? opts.sort : null,
|
|
strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling
|
|
};
|
|
};
|
|
|
|
module.exports = function (object, opts) {
|
|
var obj = object;
|
|
var options = normalizeStringifyOptions(opts);
|
|
|
|
var objKeys;
|
|
var filter;
|
|
|
|
if (typeof options.filter === 'function') {
|
|
filter = options.filter;
|
|
obj = filter('', obj);
|
|
} else if (isArray(options.filter)) {
|
|
filter = options.filter;
|
|
objKeys = filter;
|
|
}
|
|
|
|
var keys = [];
|
|
|
|
if (typeof obj !== 'object' || obj === null) {
|
|
return '';
|
|
}
|
|
|
|
var arrayFormat;
|
|
if (opts && opts.arrayFormat in arrayPrefixGenerators) {
|
|
arrayFormat = opts.arrayFormat;
|
|
} else if (opts && 'indices' in opts) {
|
|
arrayFormat = opts.indices ? 'indices' : 'repeat';
|
|
} else {
|
|
arrayFormat = 'indices';
|
|
}
|
|
|
|
var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
|
|
|
|
if (!objKeys) {
|
|
objKeys = Object.keys(obj);
|
|
}
|
|
|
|
if (options.sort) {
|
|
objKeys.sort(options.sort);
|
|
}
|
|
|
|
for (var i = 0; i < objKeys.length; ++i) {
|
|
var key = objKeys[i];
|
|
|
|
if (options.skipNulls && obj[key] === null) {
|
|
continue;
|
|
}
|
|
pushToArray(keys, stringify(
|
|
obj[key],
|
|
key,
|
|
generateArrayPrefix,
|
|
options.strictNullHandling,
|
|
options.skipNulls,
|
|
options.encode ? options.encoder : null,
|
|
options.filter,
|
|
options.sort,
|
|
options.allowDots,
|
|
options.serializeDate,
|
|
options.formatter,
|
|
options.encodeValuesOnly,
|
|
options.charset
|
|
));
|
|
}
|
|
|
|
var joined = keys.join(options.delimiter);
|
|
var prefix = options.addQueryPrefix === true ? '?' : '';
|
|
|
|
if (options.charsetSentinel) {
|
|
if (options.charset === 'iso-8859-1') {
|
|
// encodeURIComponent('✓'), the "numeric entity" representation of a checkmark
|
|
prefix += 'utf8=%26%2310003%3B&';
|
|
} else {
|
|
// encodeURIComponent('✓')
|
|
prefix += 'utf8=%E2%9C%93&';
|
|
}
|
|
}
|
|
|
|
return joined.length > 0 ? prefix + joined : '';
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 898:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const fileType = __webpack_require__(517);
|
|
const getStream = __webpack_require__(73);
|
|
const pify = __webpack_require__(464);
|
|
const yauzl = __webpack_require__(766);
|
|
|
|
const getType = (entry, mode) => {
|
|
const IFMT = 61440;
|
|
const IFDIR = 16384;
|
|
const IFLNK = 40960;
|
|
const madeBy = entry.versionMadeBy >> 8;
|
|
|
|
if ((mode & IFMT) === IFLNK) {
|
|
return 'symlink';
|
|
}
|
|
|
|
if ((mode & IFMT) === IFDIR || (madeBy === 0 && entry.externalFileAttributes === 16)) {
|
|
return 'directory';
|
|
}
|
|
|
|
return 'file';
|
|
};
|
|
|
|
const extractEntry = (entry, zip) => {
|
|
const file = {
|
|
mode: (entry.externalFileAttributes >> 16) & 0xFFFF,
|
|
mtime: entry.getLastModDate(),
|
|
path: entry.fileName
|
|
};
|
|
|
|
file.type = getType(entry, file.mode);
|
|
|
|
if (file.mode === 0 && file.type === 'directory') {
|
|
file.mode = 493;
|
|
}
|
|
|
|
if (file.mode === 0) {
|
|
file.mode = 420;
|
|
}
|
|
|
|
return pify(zip.openReadStream.bind(zip))(entry)
|
|
.then(getStream.buffer)
|
|
.then(buf => {
|
|
file.data = buf;
|
|
|
|
if (file.type === 'symlink') {
|
|
file.linkname = buf.toString();
|
|
}
|
|
|
|
return file;
|
|
})
|
|
.catch(err => {
|
|
zip.close();
|
|
throw err;
|
|
});
|
|
};
|
|
|
|
const extractFile = zip => new Promise((resolve, reject) => {
|
|
const files = [];
|
|
|
|
zip.readEntry();
|
|
|
|
zip.on('entry', entry => {
|
|
extractEntry(entry, zip)
|
|
.catch(reject)
|
|
.then(file => {
|
|
files.push(file);
|
|
zip.readEntry();
|
|
});
|
|
});
|
|
|
|
zip.on('error', reject);
|
|
zip.on('end', () => resolve(files));
|
|
});
|
|
|
|
module.exports = () => buf => {
|
|
if (!Buffer.isBuffer(buf)) {
|
|
return Promise.reject(new TypeError(`Expected a Buffer, got ${typeof buf}`));
|
|
}
|
|
|
|
if (!fileType(buf) || fileType(buf).ext !== 'zip') {
|
|
return Promise.resolve([]);
|
|
}
|
|
|
|
return pify(yauzl.fromBuffer)(buf, {lazyEntries: true}).then(extractFile);
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 902:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
|
|
|
|
module.exports = input => {
|
|
const buf = new Uint8Array(input);
|
|
|
|
if (!(buf && buf.length > 1)) {
|
|
return null;
|
|
}
|
|
|
|
const check = (header, opts) => {
|
|
opts = Object.assign({
|
|
offset: 0
|
|
}, opts);
|
|
|
|
for (let i = 0; i < header.length; i++) {
|
|
if (header[i] !== buf[i + opts.offset]) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
if (check([0xFF, 0xD8, 0xFF])) {
|
|
return {
|
|
ext: 'jpg',
|
|
mime: 'image/jpeg'
|
|
};
|
|
}
|
|
|
|
if (check([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])) {
|
|
return {
|
|
ext: 'png',
|
|
mime: 'image/png'
|
|
};
|
|
}
|
|
|
|
if (check([0x47, 0x49, 0x46])) {
|
|
return {
|
|
ext: 'gif',
|
|
mime: 'image/gif'
|
|
};
|
|
}
|
|
|
|
if (check([0x57, 0x45, 0x42, 0x50], {offset: 8})) {
|
|
return {
|
|
ext: 'webp',
|
|
mime: 'image/webp'
|
|
};
|
|
}
|
|
|
|
if (check([0x46, 0x4C, 0x49, 0x46])) {
|
|
return {
|
|
ext: 'flif',
|
|
mime: 'image/flif'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `tif` check
|
|
if (
|
|
(check([0x49, 0x49, 0x2A, 0x0]) || check([0x4D, 0x4D, 0x0, 0x2A])) &&
|
|
check([0x43, 0x52], {offset: 8})
|
|
) {
|
|
return {
|
|
ext: 'cr2',
|
|
mime: 'image/x-canon-cr2'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x49, 0x49, 0x2A, 0x0]) ||
|
|
check([0x4D, 0x4D, 0x0, 0x2A])
|
|
) {
|
|
return {
|
|
ext: 'tif',
|
|
mime: 'image/tiff'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x4D])) {
|
|
return {
|
|
ext: 'bmp',
|
|
mime: 'image/bmp'
|
|
};
|
|
}
|
|
|
|
if (check([0x49, 0x49, 0xBC])) {
|
|
return {
|
|
ext: 'jxr',
|
|
mime: 'image/vnd.ms-photo'
|
|
};
|
|
}
|
|
|
|
if (check([0x38, 0x42, 0x50, 0x53])) {
|
|
return {
|
|
ext: 'psd',
|
|
mime: 'image/vnd.adobe.photoshop'
|
|
};
|
|
}
|
|
|
|
// Needs to be before the `zip` check
|
|
if (
|
|
check([0x50, 0x4B, 0x3, 0x4]) &&
|
|
check([0x6D, 0x69, 0x6D, 0x65, 0x74, 0x79, 0x70, 0x65, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x65, 0x70, 0x75, 0x62, 0x2B, 0x7A, 0x69, 0x70], {offset: 30})
|
|
) {
|
|
return {
|
|
ext: 'epub',
|
|
mime: 'application/epub+zip'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `zip` check
|
|
// Assumes signed `.xpi` from addons.mozilla.org
|
|
if (
|
|
check([0x50, 0x4B, 0x3, 0x4]) &&
|
|
check([0x4D, 0x45, 0x54, 0x41, 0x2D, 0x49, 0x4E, 0x46, 0x2F, 0x6D, 0x6F, 0x7A, 0x69, 0x6C, 0x6C, 0x61, 0x2E, 0x72, 0x73, 0x61], {offset: 30})
|
|
) {
|
|
return {
|
|
ext: 'xpi',
|
|
mime: 'application/x-xpinstall'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x50, 0x4B]) &&
|
|
(buf[2] === 0x3 || buf[2] === 0x5 || buf[2] === 0x7) &&
|
|
(buf[3] === 0x4 || buf[3] === 0x6 || buf[3] === 0x8)
|
|
) {
|
|
return {
|
|
ext: 'zip',
|
|
mime: 'application/zip'
|
|
};
|
|
}
|
|
|
|
if (check([0x75, 0x73, 0x74, 0x61, 0x72], {offset: 257})) {
|
|
return {
|
|
ext: 'tar',
|
|
mime: 'application/x-tar'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x52, 0x61, 0x72, 0x21, 0x1A, 0x7]) &&
|
|
(buf[6] === 0x0 || buf[6] === 0x1)
|
|
) {
|
|
return {
|
|
ext: 'rar',
|
|
mime: 'application/x-rar-compressed'
|
|
};
|
|
}
|
|
|
|
if (check([0x1F, 0x8B, 0x8])) {
|
|
return {
|
|
ext: 'gz',
|
|
mime: 'application/gzip'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x5A, 0x68])) {
|
|
return {
|
|
ext: 'bz2',
|
|
mime: 'application/x-bzip2'
|
|
};
|
|
}
|
|
|
|
if (check([0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C])) {
|
|
return {
|
|
ext: '7z',
|
|
mime: 'application/x-7z-compressed'
|
|
};
|
|
}
|
|
|
|
if (check([0x78, 0x01])) {
|
|
return {
|
|
ext: 'dmg',
|
|
mime: 'application/x-apple-diskimage'
|
|
};
|
|
}
|
|
|
|
if (
|
|
(
|
|
check([0x0, 0x0, 0x0]) &&
|
|
(buf[3] === 0x18 || buf[3] === 0x20) &&
|
|
check([0x66, 0x74, 0x79, 0x70], {offset: 4})
|
|
) ||
|
|
check([0x33, 0x67, 0x70, 0x35]) ||
|
|
(
|
|
check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x6D, 0x70, 0x34, 0x32]) &&
|
|
check([0x6D, 0x70, 0x34, 0x31, 0x6D, 0x70, 0x34, 0x32, 0x69, 0x73, 0x6F, 0x6D], {offset: 16})
|
|
) ||
|
|
check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x69, 0x73, 0x6F, 0x6D]) ||
|
|
check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x6D, 0x70, 0x34, 0x32, 0x0, 0x0, 0x0, 0x0])
|
|
) {
|
|
return {
|
|
ext: 'mp4',
|
|
mime: 'video/mp4'
|
|
};
|
|
}
|
|
|
|
if (check([0x0, 0x0, 0x0, 0x1C, 0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x56])) {
|
|
return {
|
|
ext: 'm4v',
|
|
mime: 'video/x-m4v'
|
|
};
|
|
}
|
|
|
|
if (check([0x4D, 0x54, 0x68, 0x64])) {
|
|
return {
|
|
ext: 'mid',
|
|
mime: 'audio/midi'
|
|
};
|
|
}
|
|
|
|
// https://github.com/threatstack/libmagic/blob/master/magic/Magdir/matroska
|
|
if (check([0x1A, 0x45, 0xDF, 0xA3])) {
|
|
const sliced = buf.subarray(4, 4 + 4096);
|
|
const idPos = sliced.findIndex((el, i, arr) => arr[i] === 0x42 && arr[i + 1] === 0x82);
|
|
|
|
if (idPos >= 0) {
|
|
const docTypePos = idPos + 3;
|
|
const findDocType = type => Array.from(type).every((c, i) => sliced[docTypePos + i] === c.charCodeAt(0));
|
|
|
|
if (findDocType('matroska')) {
|
|
return {
|
|
ext: 'mkv',
|
|
mime: 'video/x-matroska'
|
|
};
|
|
}
|
|
|
|
if (findDocType('webm')) {
|
|
return {
|
|
ext: 'webm',
|
|
mime: 'video/webm'
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
if (check([0x0, 0x0, 0x0, 0x14, 0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20]) ||
|
|
check([0x66, 0x72, 0x65, 0x65], {offset: 4}) ||
|
|
check([0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20], {offset: 4}) ||
|
|
check([0x6D, 0x64, 0x61, 0x74], {offset: 4}) || // MJPEG
|
|
check([0x77, 0x69, 0x64, 0x65], {offset: 4})) {
|
|
return {
|
|
ext: 'mov',
|
|
mime: 'video/quicktime'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x52, 0x49, 0x46, 0x46]) &&
|
|
check([0x41, 0x56, 0x49], {offset: 8})
|
|
) {
|
|
return {
|
|
ext: 'avi',
|
|
mime: 'video/x-msvideo'
|
|
};
|
|
}
|
|
|
|
if (check([0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xA6, 0xD9])) {
|
|
return {
|
|
ext: 'wmv',
|
|
mime: 'video/x-ms-wmv'
|
|
};
|
|
}
|
|
|
|
if (check([0x0, 0x0, 0x1, 0xBA])) {
|
|
return {
|
|
ext: 'mpg',
|
|
mime: 'video/mpeg'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x49, 0x44, 0x33]) ||
|
|
check([0xFF, 0xFB])
|
|
) {
|
|
return {
|
|
ext: 'mp3',
|
|
mime: 'audio/mpeg'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41], {offset: 4}) ||
|
|
check([0x4D, 0x34, 0x41, 0x20])
|
|
) {
|
|
return {
|
|
ext: 'm4a',
|
|
mime: 'audio/m4a'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `ogg` check
|
|
if (check([0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64], {offset: 28})) {
|
|
return {
|
|
ext: 'opus',
|
|
mime: 'audio/opus'
|
|
};
|
|
}
|
|
|
|
if (check([0x4F, 0x67, 0x67, 0x53])) {
|
|
return {
|
|
ext: 'ogg',
|
|
mime: 'audio/ogg'
|
|
};
|
|
}
|
|
|
|
if (check([0x66, 0x4C, 0x61, 0x43])) {
|
|
return {
|
|
ext: 'flac',
|
|
mime: 'audio/x-flac'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x52, 0x49, 0x46, 0x46]) &&
|
|
check([0x57, 0x41, 0x56, 0x45], {offset: 8})
|
|
) {
|
|
return {
|
|
ext: 'wav',
|
|
mime: 'audio/x-wav'
|
|
};
|
|
}
|
|
|
|
if (check([0x23, 0x21, 0x41, 0x4D, 0x52, 0x0A])) {
|
|
return {
|
|
ext: 'amr',
|
|
mime: 'audio/amr'
|
|
};
|
|
}
|
|
|
|
if (check([0x25, 0x50, 0x44, 0x46])) {
|
|
return {
|
|
ext: 'pdf',
|
|
mime: 'application/pdf'
|
|
};
|
|
}
|
|
|
|
if (check([0x4D, 0x5A])) {
|
|
return {
|
|
ext: 'exe',
|
|
mime: 'application/x-msdownload'
|
|
};
|
|
}
|
|
|
|
if (
|
|
(buf[0] === 0x43 || buf[0] === 0x46) &&
|
|
check([0x57, 0x53], {offset: 1})
|
|
) {
|
|
return {
|
|
ext: 'swf',
|
|
mime: 'application/x-shockwave-flash'
|
|
};
|
|
}
|
|
|
|
if (check([0x7B, 0x5C, 0x72, 0x74, 0x66])) {
|
|
return {
|
|
ext: 'rtf',
|
|
mime: 'application/rtf'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x61, 0x73, 0x6D])) {
|
|
return {
|
|
ext: 'wasm',
|
|
mime: 'application/wasm'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x77, 0x4F, 0x46, 0x46]) &&
|
|
(
|
|
check([0x00, 0x01, 0x00, 0x00], {offset: 4}) ||
|
|
check([0x4F, 0x54, 0x54, 0x4F], {offset: 4})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'woff',
|
|
mime: 'font/woff'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x77, 0x4F, 0x46, 0x32]) &&
|
|
(
|
|
check([0x00, 0x01, 0x00, 0x00], {offset: 4}) ||
|
|
check([0x4F, 0x54, 0x54, 0x4F], {offset: 4})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'woff2',
|
|
mime: 'font/woff2'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x4C, 0x50], {offset: 34}) &&
|
|
(
|
|
check([0x00, 0x00, 0x01], {offset: 8}) ||
|
|
check([0x01, 0x00, 0x02], {offset: 8}) ||
|
|
check([0x02, 0x00, 0x02], {offset: 8})
|
|
)
|
|
) {
|
|
return {
|
|
ext: 'eot',
|
|
mime: 'application/octet-stream'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x01, 0x00, 0x00, 0x00])) {
|
|
return {
|
|
ext: 'ttf',
|
|
mime: 'font/ttf'
|
|
};
|
|
}
|
|
|
|
if (check([0x4F, 0x54, 0x54, 0x4F, 0x00])) {
|
|
return {
|
|
ext: 'otf',
|
|
mime: 'font/otf'
|
|
};
|
|
}
|
|
|
|
if (check([0x00, 0x00, 0x01, 0x00])) {
|
|
return {
|
|
ext: 'ico',
|
|
mime: 'image/x-icon'
|
|
};
|
|
}
|
|
|
|
if (check([0x46, 0x4C, 0x56, 0x01])) {
|
|
return {
|
|
ext: 'flv',
|
|
mime: 'video/x-flv'
|
|
};
|
|
}
|
|
|
|
if (check([0x25, 0x21])) {
|
|
return {
|
|
ext: 'ps',
|
|
mime: 'application/postscript'
|
|
};
|
|
}
|
|
|
|
if (check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) {
|
|
return {
|
|
ext: 'xz',
|
|
mime: 'application/x-xz'
|
|
};
|
|
}
|
|
|
|
if (check([0x53, 0x51, 0x4C, 0x69])) {
|
|
return {
|
|
ext: 'sqlite',
|
|
mime: 'application/x-sqlite3'
|
|
};
|
|
}
|
|
|
|
if (check([0x4E, 0x45, 0x53, 0x1A])) {
|
|
return {
|
|
ext: 'nes',
|
|
mime: 'application/x-nintendo-nes-rom'
|
|
};
|
|
}
|
|
|
|
if (check([0x43, 0x72, 0x32, 0x34])) {
|
|
return {
|
|
ext: 'crx',
|
|
mime: 'application/x-google-chrome-extension'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x4D, 0x53, 0x43, 0x46]) ||
|
|
check([0x49, 0x53, 0x63, 0x28])
|
|
) {
|
|
return {
|
|
ext: 'cab',
|
|
mime: 'application/vnd.ms-cab-compressed'
|
|
};
|
|
}
|
|
|
|
// Needs to be before `ar` check
|
|
if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E, 0x0A, 0x64, 0x65, 0x62, 0x69, 0x61, 0x6E, 0x2D, 0x62, 0x69, 0x6E, 0x61, 0x72, 0x79])) {
|
|
return {
|
|
ext: 'deb',
|
|
mime: 'application/x-deb'
|
|
};
|
|
}
|
|
|
|
if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E])) {
|
|
return {
|
|
ext: 'ar',
|
|
mime: 'application/x-unix-archive'
|
|
};
|
|
}
|
|
|
|
if (check([0xED, 0xAB, 0xEE, 0xDB])) {
|
|
return {
|
|
ext: 'rpm',
|
|
mime: 'application/x-rpm'
|
|
};
|
|
}
|
|
|
|
if (
|
|
check([0x1F, 0xA0]) ||
|
|
check([0x1F, 0x9D])
|
|
) {
|
|
return {
|
|
ext: 'Z',
|
|
mime: 'application/x-compress'
|
|
};
|
|
}
|
|
|
|
if (check([0x4C, 0x5A, 0x49, 0x50])) {
|
|
return {
|
|
ext: 'lz',
|
|
mime: 'application/x-lzip'
|
|
};
|
|
}
|
|
|
|
if (check([0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1])) {
|
|
return {
|
|
ext: 'msi',
|
|
mime: 'application/x-msi'
|
|
};
|
|
}
|
|
|
|
if (check([0x06, 0x0E, 0x2B, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0D, 0x01, 0x02, 0x01, 0x01, 0x02])) {
|
|
return {
|
|
ext: 'mxf',
|
|
mime: 'application/mxf'
|
|
};
|
|
}
|
|
|
|
if (check([0x47], {offset: 4}) && (check([0x47], {offset: 192}) || check([0x47], {offset: 196}))) {
|
|
return {
|
|
ext: 'mts',
|
|
mime: 'video/mp2t'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x4C, 0x45, 0x4E, 0x44, 0x45, 0x52])) {
|
|
return {
|
|
ext: 'blend',
|
|
mime: 'application/x-blender'
|
|
};
|
|
}
|
|
|
|
if (check([0x42, 0x50, 0x47, 0xFB])) {
|
|
return {
|
|
ext: 'bpg',
|
|
mime: 'image/bpg'
|
|
};
|
|
}
|
|
|
|
return null;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 917:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
|
|
/**
|
|
* For Node.js, simply re-export the core `util.deprecate` function.
|
|
*/
|
|
|
|
module.exports = __webpack_require__(669).deprecate;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 925:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
// copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
// following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included
|
|
// in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
// a transform stream is a readable/writable stream where you do
|
|
// something with the data. Sometimes it's called a "filter",
|
|
// but that's not a great name for it, since that implies a thing where
|
|
// some bits pass through, and others are simply ignored. (That would
|
|
// be a valid example of a transform, of course.)
|
|
//
|
|
// While the output is causally related to the input, it's not a
|
|
// necessarily symmetric or synchronous transformation. For example,
|
|
// a zlib stream might take multiple plain-text writes(), and then
|
|
// emit a single compressed chunk some time in the future.
|
|
//
|
|
// Here's how this works:
|
|
//
|
|
// The Transform stream has all the aspects of the readable and writable
|
|
// stream classes. When you write(chunk), that calls _write(chunk,cb)
|
|
// internally, and returns false if there's a lot of pending writes
|
|
// buffered up. When you call read(), that calls _read(n) until
|
|
// there's enough pending readable data buffered up.
|
|
//
|
|
// In a transform stream, the written data is placed in a buffer. When
|
|
// _read(n) is called, it transforms the queued up data, calling the
|
|
// buffered _write cb's as it consumes chunks. If consuming a single
|
|
// written chunk would result in multiple output chunks, then the first
|
|
// outputted bit calls the readcb, and subsequent chunks just go into
|
|
// the read buffer, and will cause it to emit 'readable' if necessary.
|
|
//
|
|
// This way, back-pressure is actually determined by the reading side,
|
|
// since _read has to be called to start processing a new chunk. However,
|
|
// a pathological inflate type of transform can cause excessive buffering
|
|
// here. For example, imagine a stream where every byte of input is
|
|
// interpreted as an integer from 0-255, and then results in that many
|
|
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
|
|
// 1kb of data being output. In this case, you could write a very small
|
|
// amount of input, and end up with a very large amount of output. In
|
|
// such a pathological inflating mechanism, there'd be no way to tell
|
|
// the system to stop doing the transform. A single 4MB write could
|
|
// cause the system to run out of memory.
|
|
//
|
|
// However, even in such a pathological case, only a single written chunk
|
|
// would be consumed, and then the rest would wait (un-transformed) until
|
|
// the results of the previous transformed chunk were consumed.
|
|
|
|
|
|
|
|
module.exports = Transform;
|
|
|
|
var Duplex = __webpack_require__(831);
|
|
|
|
/*<replacement>*/
|
|
var util = Object.create(__webpack_require__(286));
|
|
util.inherits = __webpack_require__(689);
|
|
/*</replacement>*/
|
|
|
|
util.inherits(Transform, Duplex);
|
|
|
|
function afterTransform(er, data) {
|
|
var ts = this._transformState;
|
|
ts.transforming = false;
|
|
|
|
var cb = ts.writecb;
|
|
|
|
if (!cb) {
|
|
return this.emit('error', new Error('write callback called multiple times'));
|
|
}
|
|
|
|
ts.writechunk = null;
|
|
ts.writecb = null;
|
|
|
|
if (data != null) // single equals check for both `null` and `undefined`
|
|
this.push(data);
|
|
|
|
cb(er);
|
|
|
|
var rs = this._readableState;
|
|
rs.reading = false;
|
|
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
|
this._read(rs.highWaterMark);
|
|
}
|
|
}
|
|
|
|
function Transform(options) {
|
|
if (!(this instanceof Transform)) return new Transform(options);
|
|
|
|
Duplex.call(this, options);
|
|
|
|
this._transformState = {
|
|
afterTransform: afterTransform.bind(this),
|
|
needTransform: false,
|
|
transforming: false,
|
|
writecb: null,
|
|
writechunk: null,
|
|
writeencoding: null
|
|
};
|
|
|
|
// start out asking for a readable event once data is transformed.
|
|
this._readableState.needReadable = true;
|
|
|
|
// we have implemented the _read method, and done the other things
|
|
// that Readable wants before the first _read call, so unset the
|
|
// sync guard flag.
|
|
this._readableState.sync = false;
|
|
|
|
if (options) {
|
|
if (typeof options.transform === 'function') this._transform = options.transform;
|
|
|
|
if (typeof options.flush === 'function') this._flush = options.flush;
|
|
}
|
|
|
|
// When the writable side finishes, then flush out anything remaining.
|
|
this.on('prefinish', prefinish);
|
|
}
|
|
|
|
function prefinish() {
|
|
var _this = this;
|
|
|
|
if (typeof this._flush === 'function') {
|
|
this._flush(function (er, data) {
|
|
done(_this, er, data);
|
|
});
|
|
} else {
|
|
done(this, null, null);
|
|
}
|
|
}
|
|
|
|
Transform.prototype.push = function (chunk, encoding) {
|
|
this._transformState.needTransform = false;
|
|
return Duplex.prototype.push.call(this, chunk, encoding);
|
|
};
|
|
|
|
// This is the part where you do stuff!
|
|
// override this function in implementation classes.
|
|
// 'chunk' is an input chunk.
|
|
//
|
|
// Call `push(newChunk)` to pass along transformed output
|
|
// to the readable side. You may call 'push' zero or more times.
|
|
//
|
|
// Call `cb(err)` when you are done with this chunk. If you pass
|
|
// an error, then that'll put the hurt on the whole operation. If you
|
|
// never call cb(), then you'll never get another chunk.
|
|
Transform.prototype._transform = function (chunk, encoding, cb) {
|
|
throw new Error('_transform() is not implemented');
|
|
};
|
|
|
|
Transform.prototype._write = function (chunk, encoding, cb) {
|
|
var ts = this._transformState;
|
|
ts.writecb = cb;
|
|
ts.writechunk = chunk;
|
|
ts.writeencoding = encoding;
|
|
if (!ts.transforming) {
|
|
var rs = this._readableState;
|
|
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
|
|
}
|
|
};
|
|
|
|
// Doesn't matter what the args are here.
|
|
// _transform does all the work.
|
|
// That we got here means that the readable side wants more data.
|
|
Transform.prototype._read = function (n) {
|
|
var ts = this._transformState;
|
|
|
|
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
|
|
ts.transforming = true;
|
|
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
|
} else {
|
|
// mark that we need a transform, so that any data that comes in
|
|
// will get processed, now that we've asked for it.
|
|
ts.needTransform = true;
|
|
}
|
|
};
|
|
|
|
Transform.prototype._destroy = function (err, cb) {
|
|
var _this2 = this;
|
|
|
|
Duplex.prototype._destroy.call(this, err, function (err2) {
|
|
cb(err2);
|
|
_this2.emit('close');
|
|
});
|
|
};
|
|
|
|
function done(stream, er, data) {
|
|
if (er) return stream.emit('error', er);
|
|
|
|
if (data != null) // single equals check for both `null` and `undefined`
|
|
stream.push(data);
|
|
|
|
// if there's nothing in the write buffer, then that means
|
|
// that nothing more will ever be provided
|
|
if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
|
|
|
|
if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
|
|
|
|
return stream.push(null);
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 927:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const fs = __webpack_require__(747);
|
|
const path = __webpack_require__(622);
|
|
const {URL} = __webpack_require__(835);
|
|
const contentDisposition = __webpack_require__(492);
|
|
const archiveType = __webpack_require__(446);
|
|
const decompress = __webpack_require__(820);
|
|
const filenamify = __webpack_require__(83);
|
|
const getStream = __webpack_require__(145);
|
|
const got = __webpack_require__(984);
|
|
const makeDir = __webpack_require__(938);
|
|
const pify = __webpack_require__(802);
|
|
const pEvent = __webpack_require__(148);
|
|
const fileType = __webpack_require__(631);
|
|
const extName = __webpack_require__(547);
|
|
|
|
const fsP = pify(fs);
|
|
const filenameFromPath = res => path.basename(new URL(res.requestUrl).pathname);
|
|
|
|
const getExtFromMime = res => {
|
|
const header = res.headers['content-type'];
|
|
|
|
if (!header) {
|
|
return null;
|
|
}
|
|
|
|
const exts = extName.mime(header);
|
|
|
|
if (exts.length !== 1) {
|
|
return null;
|
|
}
|
|
|
|
return exts[0].ext;
|
|
};
|
|
|
|
const getFilename = (res, data) => {
|
|
const header = res.headers['content-disposition'];
|
|
|
|
if (header) {
|
|
const parsed = contentDisposition.parse(header);
|
|
|
|
if (parsed.parameters && parsed.parameters.filename) {
|
|
return parsed.parameters.filename;
|
|
}
|
|
}
|
|
|
|
let filename = filenameFromPath(res);
|
|
|
|
if (!path.extname(filename)) {
|
|
const ext = (fileType(data) || {}).ext || getExtFromMime(res);
|
|
|
|
if (ext) {
|
|
filename = `${filename}.${ext}`;
|
|
}
|
|
}
|
|
|
|
return filename;
|
|
};
|
|
|
|
module.exports = (uri, output, opts) => {
|
|
if (typeof output === 'object') {
|
|
opts = output;
|
|
output = null;
|
|
}
|
|
|
|
opts = Object.assign({
|
|
encoding: null,
|
|
rejectUnauthorized: process.env.npm_config_strict_ssl !== 'false'
|
|
}, opts);
|
|
|
|
const stream = got.stream(uri, opts);
|
|
|
|
const promise = pEvent(stream, 'response').then(res => {
|
|
const encoding = opts.encoding === null ? 'buffer' : opts.encoding;
|
|
return Promise.all([getStream(stream, {encoding}), res]);
|
|
}).then(result => {
|
|
const [data, res] = result;
|
|
|
|
if (!output) {
|
|
return opts.extract && archiveType(data) ? decompress(data, opts) : data;
|
|
}
|
|
|
|
const filename = opts.filename || filenamify(getFilename(res, data));
|
|
const outputFilepath = path.join(output, filename);
|
|
|
|
if (opts.extract && archiveType(data)) {
|
|
return decompress(data, path.dirname(outputFilepath), opts);
|
|
}
|
|
|
|
return makeDir(path.dirname(outputFilepath))
|
|
.then(() => fsP.writeFile(outputFilepath, data))
|
|
.then(() => data);
|
|
});
|
|
|
|
stream.then = promise.then.bind(promise);
|
|
stream.catch = promise.catch.bind(promise);
|
|
|
|
return stream;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 931:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var Buffer = __webpack_require__(321).Buffer;
|
|
var util = __webpack_require__(669);
|
|
|
|
function copyBuffer(src, target, offset) {
|
|
src.copy(target, offset);
|
|
}
|
|
|
|
module.exports = function () {
|
|
function BufferList() {
|
|
_classCallCheck(this, BufferList);
|
|
|
|
this.head = null;
|
|
this.tail = null;
|
|
this.length = 0;
|
|
}
|
|
|
|
BufferList.prototype.push = function push(v) {
|
|
var entry = { data: v, next: null };
|
|
if (this.length > 0) this.tail.next = entry;else this.head = entry;
|
|
this.tail = entry;
|
|
++this.length;
|
|
};
|
|
|
|
BufferList.prototype.unshift = function unshift(v) {
|
|
var entry = { data: v, next: this.head };
|
|
if (this.length === 0) this.tail = entry;
|
|
this.head = entry;
|
|
++this.length;
|
|
};
|
|
|
|
BufferList.prototype.shift = function shift() {
|
|
if (this.length === 0) return;
|
|
var ret = this.head.data;
|
|
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
|
|
--this.length;
|
|
return ret;
|
|
};
|
|
|
|
BufferList.prototype.clear = function clear() {
|
|
this.head = this.tail = null;
|
|
this.length = 0;
|
|
};
|
|
|
|
BufferList.prototype.join = function join(s) {
|
|
if (this.length === 0) return '';
|
|
var p = this.head;
|
|
var ret = '' + p.data;
|
|
while (p = p.next) {
|
|
ret += s + p.data;
|
|
}return ret;
|
|
};
|
|
|
|
BufferList.prototype.concat = function concat(n) {
|
|
if (this.length === 0) return Buffer.alloc(0);
|
|
if (this.length === 1) return this.head.data;
|
|
var ret = Buffer.allocUnsafe(n >>> 0);
|
|
var p = this.head;
|
|
var i = 0;
|
|
while (p) {
|
|
copyBuffer(p.data, ret, i);
|
|
i += p.data.length;
|
|
p = p.next;
|
|
}
|
|
return ret;
|
|
};
|
|
|
|
return BufferList;
|
|
}();
|
|
|
|
if (util && util.inspect && util.inspect.custom) {
|
|
module.exports.prototype[util.inspect.custom] = function () {
|
|
var obj = util.inspect({ length: this.length });
|
|
return this.constructor.name + ' ' + obj;
|
|
};
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 937:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = require("net");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 938:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const fs = __webpack_require__(747);
|
|
const path = __webpack_require__(622);
|
|
const pify = __webpack_require__(802);
|
|
const semver = __webpack_require__(683);
|
|
|
|
const defaults = {
|
|
mode: 0o777 & (~process.umask()),
|
|
fs
|
|
};
|
|
|
|
const useNativeRecursiveOption = semver.satisfies(process.version, '>=10.12.0');
|
|
|
|
// https://github.com/nodejs/node/issues/8987
|
|
// https://github.com/libuv/libuv/pull/1088
|
|
const checkPath = pth => {
|
|
if (process.platform === 'win32') {
|
|
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''));
|
|
|
|
if (pathHasInvalidWinCharacters) {
|
|
const error = new Error(`Path contains invalid characters: ${pth}`);
|
|
error.code = 'EINVAL';
|
|
throw error;
|
|
}
|
|
}
|
|
};
|
|
|
|
const permissionError = pth => {
|
|
// This replicates the exception of `fs.mkdir` with native the
|
|
// `recusive` option when run on an invalid drive under Windows.
|
|
const error = new Error(`operation not permitted, mkdir '${pth}'`);
|
|
error.code = 'EPERM';
|
|
error.errno = -4048;
|
|
error.path = pth;
|
|
error.syscall = 'mkdir';
|
|
return error;
|
|
};
|
|
|
|
const makeDir = (input, options) => Promise.resolve().then(() => {
|
|
checkPath(input);
|
|
options = Object.assign({}, defaults, options);
|
|
|
|
// TODO: Use util.promisify when targeting Node.js 8
|
|
const mkdir = pify(options.fs.mkdir);
|
|
const stat = pify(options.fs.stat);
|
|
|
|
if (useNativeRecursiveOption && options.fs.mkdir === fs.mkdir) {
|
|
const pth = path.resolve(input);
|
|
|
|
return mkdir(pth, {
|
|
mode: options.mode,
|
|
recursive: true
|
|
}).then(() => pth);
|
|
}
|
|
|
|
const make = pth => {
|
|
return mkdir(pth, options.mode)
|
|
.then(() => pth)
|
|
.catch(error => {
|
|
if (error.code === 'EPERM') {
|
|
throw error;
|
|
}
|
|
|
|
if (error.code === 'ENOENT') {
|
|
if (path.dirname(pth) === pth) {
|
|
throw permissionError(pth);
|
|
}
|
|
|
|
if (error.message.includes('null bytes')) {
|
|
throw error;
|
|
}
|
|
|
|
return make(path.dirname(pth)).then(() => make(pth));
|
|
}
|
|
|
|
return stat(pth)
|
|
.then(stats => stats.isDirectory() ? pth : Promise.reject())
|
|
.catch(() => {
|
|
throw error;
|
|
});
|
|
});
|
|
};
|
|
|
|
return make(path.resolve(input));
|
|
});
|
|
|
|
module.exports = makeDir;
|
|
module.exports.default = makeDir;
|
|
|
|
module.exports.sync = (input, options) => {
|
|
checkPath(input);
|
|
options = Object.assign({}, defaults, options);
|
|
|
|
if (useNativeRecursiveOption && options.fs.mkdirSync === fs.mkdirSync) {
|
|
const pth = path.resolve(input);
|
|
|
|
fs.mkdirSync(pth, {
|
|
mode: options.mode,
|
|
recursive: true
|
|
});
|
|
|
|
return pth;
|
|
}
|
|
|
|
const make = pth => {
|
|
try {
|
|
options.fs.mkdirSync(pth, options.mode);
|
|
} catch (error) {
|
|
if (error.code === 'EPERM') {
|
|
throw error;
|
|
}
|
|
|
|
if (error.code === 'ENOENT') {
|
|
if (path.dirname(pth) === pth) {
|
|
throw permissionError(pth);
|
|
}
|
|
|
|
if (error.message.includes('null bytes')) {
|
|
throw error;
|
|
}
|
|
|
|
make(path.dirname(pth));
|
|
return make(pth);
|
|
}
|
|
|
|
try {
|
|
if (!options.fs.statSync(pth).isDirectory()) {
|
|
throw new Error('The path is not a directory');
|
|
}
|
|
} catch (_) {
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
return pth;
|
|
};
|
|
|
|
return make(path.resolve(input));
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 940:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = extend
|
|
|
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
|
|
function extend() {
|
|
var target = {}
|
|
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
var source = arguments[i]
|
|
|
|
for (var key in source) {
|
|
if (hasOwnProperty.call(source, key)) {
|
|
target[key] = source[key]
|
|
}
|
|
}
|
|
}
|
|
|
|
return target
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 944:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var mimeDb = __webpack_require__(852);
|
|
|
|
module.exports = function () {
|
|
var ret = {};
|
|
|
|
Object.keys(mimeDb).forEach(function (x) {
|
|
var val = mimeDb[x];
|
|
|
|
if (val.extensions && val.extensions.length > 0) {
|
|
val.extensions.forEach(function (y) {
|
|
ret[y] = x;
|
|
});
|
|
}
|
|
});
|
|
|
|
return ret;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 946:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
const EventEmitter = __webpack_require__(614);
|
|
const urlLib = __webpack_require__(835);
|
|
const normalizeUrl = __webpack_require__(53);
|
|
const getStream = __webpack_require__(16);
|
|
const CachePolicy = __webpack_require__(27);
|
|
const Response = __webpack_require__(141);
|
|
const lowercaseKeys = __webpack_require__(97);
|
|
const cloneResponse = __webpack_require__(325);
|
|
const Keyv = __webpack_require__(303);
|
|
|
|
class CacheableRequest {
|
|
constructor(request, cacheAdapter) {
|
|
if (typeof request !== 'function') {
|
|
throw new TypeError('Parameter `request` must be a function');
|
|
}
|
|
|
|
this.cache = new Keyv({
|
|
uri: typeof cacheAdapter === 'string' && cacheAdapter,
|
|
store: typeof cacheAdapter !== 'string' && cacheAdapter,
|
|
namespace: 'cacheable-request'
|
|
});
|
|
|
|
return this.createCacheableRequest(request);
|
|
}
|
|
|
|
createCacheableRequest(request) {
|
|
return (opts, cb) => {
|
|
if (typeof opts === 'string') {
|
|
opts = urlLib.parse(opts);
|
|
}
|
|
opts = Object.assign({
|
|
headers: {},
|
|
method: 'GET',
|
|
cache: true,
|
|
strictTtl: false,
|
|
automaticFailover: false
|
|
}, opts);
|
|
opts.headers = lowercaseKeys(opts.headers);
|
|
|
|
const ee = new EventEmitter();
|
|
const url = normalizeUrl(urlLib.format(opts));
|
|
const key = `${opts.method}:${url}`;
|
|
let revalidate = false;
|
|
let madeRequest = false;
|
|
|
|
const makeRequest = opts => {
|
|
madeRequest = true;
|
|
const handler = response => {
|
|
if (revalidate) {
|
|
const revalidatedPolicy = CachePolicy.fromObject(revalidate.cachePolicy).revalidatedPolicy(opts, response);
|
|
if (!revalidatedPolicy.modified) {
|
|
const headers = revalidatedPolicy.policy.responseHeaders();
|
|
response = new Response(response.statusCode, headers, revalidate.body, revalidate.url);
|
|
response.cachePolicy = revalidatedPolicy.policy;
|
|
response.fromCache = true;
|
|
}
|
|
}
|
|
|
|
if (!response.fromCache) {
|
|
response.cachePolicy = new CachePolicy(opts, response);
|
|
response.fromCache = false;
|
|
}
|
|
|
|
let clonedResponse;
|
|
if (opts.cache && response.cachePolicy.storable()) {
|
|
clonedResponse = cloneResponse(response);
|
|
getStream.buffer(response)
|
|
.then(body => {
|
|
const value = {
|
|
cachePolicy: response.cachePolicy.toObject(),
|
|
url: response.url,
|
|
statusCode: response.fromCache ? revalidate.statusCode : response.statusCode,
|
|
body
|
|
};
|
|
const ttl = opts.strictTtl ? response.cachePolicy.timeToLive() : undefined;
|
|
return this.cache.set(key, value, ttl);
|
|
})
|
|
.catch(err => ee.emit('error', new CacheableRequest.CacheError(err)));
|
|
} else if (opts.cache && revalidate) {
|
|
this.cache.delete(key)
|
|
.catch(err => ee.emit('error', new CacheableRequest.CacheError(err)));
|
|
}
|
|
|
|
ee.emit('response', clonedResponse || response);
|
|
if (typeof cb === 'function') {
|
|
cb(clonedResponse || response);
|
|
}
|
|
};
|
|
|
|
try {
|
|
const req = request(opts, handler);
|
|
ee.emit('request', req);
|
|
} catch (err) {
|
|
ee.emit('error', new CacheableRequest.RequestError(err));
|
|
}
|
|
};
|
|
|
|
const get = opts => Promise.resolve()
|
|
.then(() => opts.cache ? this.cache.get(key) : undefined)
|
|
.then(cacheEntry => {
|
|
if (typeof cacheEntry === 'undefined') {
|
|
return makeRequest(opts);
|
|
}
|
|
|
|
const policy = CachePolicy.fromObject(cacheEntry.cachePolicy);
|
|
if (policy.satisfiesWithoutRevalidation(opts)) {
|
|
const headers = policy.responseHeaders();
|
|
const response = new Response(cacheEntry.statusCode, headers, cacheEntry.body, cacheEntry.url);
|
|
response.cachePolicy = policy;
|
|
response.fromCache = true;
|
|
|
|
ee.emit('response', response);
|
|
if (typeof cb === 'function') {
|
|
cb(response);
|
|
}
|
|
} else {
|
|
revalidate = cacheEntry;
|
|
opts.headers = policy.revalidationHeaders(opts);
|
|
makeRequest(opts);
|
|
}
|
|
});
|
|
|
|
this.cache.on('error', err => ee.emit('error', new CacheableRequest.CacheError(err)));
|
|
|
|
get(opts).catch(err => {
|
|
if (opts.automaticFailover && !madeRequest) {
|
|
makeRequest(opts);
|
|
}
|
|
ee.emit('error', new CacheableRequest.CacheError(err));
|
|
});
|
|
|
|
return ee;
|
|
};
|
|
}
|
|
}
|
|
|
|
CacheableRequest.RequestError = class extends Error {
|
|
constructor(err) {
|
|
super(err.message);
|
|
this.name = 'RequestError';
|
|
Object.assign(this, err);
|
|
}
|
|
};
|
|
|
|
CacheableRequest.CacheError = class extends Error {
|
|
constructor(err) {
|
|
super(err.message);
|
|
this.name = 'CacheError';
|
|
Object.assign(this, err);
|
|
}
|
|
};
|
|
|
|
module.exports = CacheableRequest;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 950:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const url = __webpack_require__(835);
|
|
function getProxyUrl(reqUrl) {
|
|
let usingSsl = reqUrl.protocol === 'https:';
|
|
let proxyUrl;
|
|
if (checkBypass(reqUrl)) {
|
|
return proxyUrl;
|
|
}
|
|
let proxyVar;
|
|
if (usingSsl) {
|
|
proxyVar = process.env["https_proxy"] ||
|
|
process.env["HTTPS_PROXY"];
|
|
}
|
|
else {
|
|
proxyVar = process.env["http_proxy"] ||
|
|
process.env["HTTP_PROXY"];
|
|
}
|
|
if (proxyVar) {
|
|
proxyUrl = url.parse(proxyVar);
|
|
}
|
|
return proxyUrl;
|
|
}
|
|
exports.getProxyUrl = getProxyUrl;
|
|
function checkBypass(reqUrl) {
|
|
if (!reqUrl.hostname) {
|
|
return false;
|
|
}
|
|
let noProxy = process.env["no_proxy"] || process.env["NO_PROXY"] || '';
|
|
if (!noProxy) {
|
|
return false;
|
|
}
|
|
// Determine the request port
|
|
let reqPort;
|
|
if (reqUrl.port) {
|
|
reqPort = Number(reqUrl.port);
|
|
}
|
|
else if (reqUrl.protocol === 'http:') {
|
|
reqPort = 80;
|
|
}
|
|
else if (reqUrl.protocol === 'https:') {
|
|
reqPort = 443;
|
|
}
|
|
// Format the request hostname and hostname with port
|
|
let upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
|
if (typeof reqPort === 'number') {
|
|
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
|
}
|
|
// Compare request host against noproxy
|
|
for (let upperNoProxyItem of noProxy.split(',').map(x => x.trim().toUpperCase()).filter(x => x)) {
|
|
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
exports.checkBypass = checkBypass;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 954:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
var DuplexStream = __webpack_require__(519)
|
|
, util = __webpack_require__(669)
|
|
, Buffer = __webpack_require__(149).Buffer
|
|
|
|
|
|
function BufferList (callback) {
|
|
if (!(this instanceof BufferList))
|
|
return new BufferList(callback)
|
|
|
|
this._bufs = []
|
|
this.length = 0
|
|
|
|
if (typeof callback == 'function') {
|
|
this._callback = callback
|
|
|
|
var piper = function piper (err) {
|
|
if (this._callback) {
|
|
this._callback(err)
|
|
this._callback = null
|
|
}
|
|
}.bind(this)
|
|
|
|
this.on('pipe', function onPipe (src) {
|
|
src.on('error', piper)
|
|
})
|
|
this.on('unpipe', function onUnpipe (src) {
|
|
src.removeListener('error', piper)
|
|
})
|
|
} else {
|
|
this.append(callback)
|
|
}
|
|
|
|
DuplexStream.call(this)
|
|
}
|
|
|
|
|
|
util.inherits(BufferList, DuplexStream)
|
|
|
|
|
|
BufferList.prototype._offset = function _offset (offset) {
|
|
var tot = 0, i = 0, _t
|
|
if (offset === 0) return [ 0, 0 ]
|
|
for (; i < this._bufs.length; i++) {
|
|
_t = tot + this._bufs[i].length
|
|
if (offset < _t || i == this._bufs.length - 1)
|
|
return [ i, offset - tot ]
|
|
tot = _t
|
|
}
|
|
}
|
|
|
|
|
|
BufferList.prototype.append = function append (buf) {
|
|
var i = 0
|
|
|
|
if (Buffer.isBuffer(buf)) {
|
|
this._appendBuffer(buf);
|
|
} else if (Array.isArray(buf)) {
|
|
for (; i < buf.length; i++)
|
|
this.append(buf[i])
|
|
} else if (buf instanceof BufferList) {
|
|
// unwrap argument into individual BufferLists
|
|
for (; i < buf._bufs.length; i++)
|
|
this.append(buf._bufs[i])
|
|
} else if (buf != null) {
|
|
// coerce number arguments to strings, since Buffer(number) does
|
|
// uninitialized memory allocation
|
|
if (typeof buf == 'number')
|
|
buf = buf.toString()
|
|
|
|
this._appendBuffer(Buffer.from(buf));
|
|
}
|
|
|
|
return this
|
|
}
|
|
|
|
|
|
BufferList.prototype._appendBuffer = function appendBuffer (buf) {
|
|
this._bufs.push(buf)
|
|
this.length += buf.length
|
|
}
|
|
|
|
|
|
BufferList.prototype._write = function _write (buf, encoding, callback) {
|
|
this._appendBuffer(buf)
|
|
|
|
if (typeof callback == 'function')
|
|
callback()
|
|
}
|
|
|
|
|
|
BufferList.prototype._read = function _read (size) {
|
|
if (!this.length)
|
|
return this.push(null)
|
|
|
|
size = Math.min(size, this.length)
|
|
this.push(this.slice(0, size))
|
|
this.consume(size)
|
|
}
|
|
|
|
|
|
BufferList.prototype.end = function end (chunk) {
|
|
DuplexStream.prototype.end.call(this, chunk)
|
|
|
|
if (this._callback) {
|
|
this._callback(null, this.slice())
|
|
this._callback = null
|
|
}
|
|
}
|
|
|
|
|
|
BufferList.prototype.get = function get (index) {
|
|
return this.slice(index, index + 1)[0]
|
|
}
|
|
|
|
|
|
BufferList.prototype.slice = function slice (start, end) {
|
|
if (typeof start == 'number' && start < 0)
|
|
start += this.length
|
|
if (typeof end == 'number' && end < 0)
|
|
end += this.length
|
|
return this.copy(null, 0, start, end)
|
|
}
|
|
|
|
|
|
BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
|
|
if (typeof srcStart != 'number' || srcStart < 0)
|
|
srcStart = 0
|
|
if (typeof srcEnd != 'number' || srcEnd > this.length)
|
|
srcEnd = this.length
|
|
if (srcStart >= this.length)
|
|
return dst || Buffer.alloc(0)
|
|
if (srcEnd <= 0)
|
|
return dst || Buffer.alloc(0)
|
|
|
|
var copy = !!dst
|
|
, off = this._offset(srcStart)
|
|
, len = srcEnd - srcStart
|
|
, bytes = len
|
|
, bufoff = (copy && dstStart) || 0
|
|
, start = off[1]
|
|
, l
|
|
, i
|
|
|
|
// copy/slice everything
|
|
if (srcStart === 0 && srcEnd == this.length) {
|
|
if (!copy) { // slice, but full concat if multiple buffers
|
|
return this._bufs.length === 1
|
|
? this._bufs[0]
|
|
: Buffer.concat(this._bufs, this.length)
|
|
}
|
|
|
|
// copy, need to copy individual buffers
|
|
for (i = 0; i < this._bufs.length; i++) {
|
|
this._bufs[i].copy(dst, bufoff)
|
|
bufoff += this._bufs[i].length
|
|
}
|
|
|
|
return dst
|
|
}
|
|
|
|
// easy, cheap case where it's a subset of one of the buffers
|
|
if (bytes <= this._bufs[off[0]].length - start) {
|
|
return copy
|
|
? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)
|
|
: this._bufs[off[0]].slice(start, start + bytes)
|
|
}
|
|
|
|
if (!copy) // a slice, we need something to copy in to
|
|
dst = Buffer.allocUnsafe(len)
|
|
|
|
for (i = off[0]; i < this._bufs.length; i++) {
|
|
l = this._bufs[i].length - start
|
|
|
|
if (bytes > l) {
|
|
this._bufs[i].copy(dst, bufoff, start)
|
|
} else {
|
|
this._bufs[i].copy(dst, bufoff, start, start + bytes)
|
|
break
|
|
}
|
|
|
|
bufoff += l
|
|
bytes -= l
|
|
|
|
if (start)
|
|
start = 0
|
|
}
|
|
|
|
return dst
|
|
}
|
|
|
|
BufferList.prototype.shallowSlice = function shallowSlice (start, end) {
|
|
start = start || 0
|
|
end = end || this.length
|
|
|
|
if (start < 0)
|
|
start += this.length
|
|
if (end < 0)
|
|
end += this.length
|
|
|
|
var startOffset = this._offset(start)
|
|
, endOffset = this._offset(end)
|
|
, buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1)
|
|
|
|
if (endOffset[1] == 0)
|
|
buffers.pop()
|
|
else
|
|
buffers[buffers.length-1] = buffers[buffers.length-1].slice(0, endOffset[1])
|
|
|
|
if (startOffset[1] != 0)
|
|
buffers[0] = buffers[0].slice(startOffset[1])
|
|
|
|
return new BufferList(buffers)
|
|
}
|
|
|
|
BufferList.prototype.toString = function toString (encoding, start, end) {
|
|
return this.slice(start, end).toString(encoding)
|
|
}
|
|
|
|
BufferList.prototype.consume = function consume (bytes) {
|
|
while (this._bufs.length) {
|
|
if (bytes >= this._bufs[0].length) {
|
|
bytes -= this._bufs[0].length
|
|
this.length -= this._bufs[0].length
|
|
this._bufs.shift()
|
|
} else {
|
|
this._bufs[0] = this._bufs[0].slice(bytes)
|
|
this.length -= bytes
|
|
break
|
|
}
|
|
}
|
|
return this
|
|
}
|
|
|
|
|
|
BufferList.prototype.duplicate = function duplicate () {
|
|
var i = 0
|
|
, copy = new BufferList()
|
|
|
|
for (; i < this._bufs.length; i++)
|
|
copy.append(this._bufs[i])
|
|
|
|
return copy
|
|
}
|
|
|
|
|
|
BufferList.prototype.destroy = function destroy () {
|
|
this._bufs.length = 0
|
|
this.length = 0
|
|
this.push(null)
|
|
}
|
|
|
|
|
|
;(function () {
|
|
var methods = {
|
|
'readDoubleBE' : 8
|
|
, 'readDoubleLE' : 8
|
|
, 'readFloatBE' : 4
|
|
, 'readFloatLE' : 4
|
|
, 'readInt32BE' : 4
|
|
, 'readInt32LE' : 4
|
|
, 'readUInt32BE' : 4
|
|
, 'readUInt32LE' : 4
|
|
, 'readInt16BE' : 2
|
|
, 'readInt16LE' : 2
|
|
, 'readUInt16BE' : 2
|
|
, 'readUInt16LE' : 2
|
|
, 'readInt8' : 1
|
|
, 'readUInt8' : 1
|
|
}
|
|
|
|
for (var m in methods) {
|
|
(function (m) {
|
|
BufferList.prototype[m] = function (offset) {
|
|
return this.slice(offset, offset + methods[m])[m](0)
|
|
}
|
|
}(m))
|
|
}
|
|
}())
|
|
|
|
|
|
module.exports = BufferList
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 965:
|
|
/***/ (function(module) {
|
|
|
|
module.exports = Pend;
|
|
|
|
function Pend() {
|
|
this.pending = 0;
|
|
this.max = Infinity;
|
|
this.listeners = [];
|
|
this.waiting = [];
|
|
this.error = null;
|
|
}
|
|
|
|
Pend.prototype.go = function(fn) {
|
|
if (this.pending < this.max) {
|
|
pendGo(this, fn);
|
|
} else {
|
|
this.waiting.push(fn);
|
|
}
|
|
};
|
|
|
|
Pend.prototype.wait = function(cb) {
|
|
if (this.pending === 0) {
|
|
cb(this.error);
|
|
} else {
|
|
this.listeners.push(cb);
|
|
}
|
|
};
|
|
|
|
Pend.prototype.hold = function() {
|
|
return pendHold(this);
|
|
};
|
|
|
|
function pendHold(self) {
|
|
self.pending += 1;
|
|
var called = false;
|
|
return onCb;
|
|
function onCb(err) {
|
|
if (called) throw new Error("callback called twice");
|
|
called = true;
|
|
self.error = self.error || err;
|
|
self.pending -= 1;
|
|
if (self.waiting.length > 0 && self.pending < self.max) {
|
|
pendGo(self, self.waiting.shift());
|
|
} else if (self.pending === 0) {
|
|
var listeners = self.listeners;
|
|
self.listeners = [];
|
|
listeners.forEach(cbListener);
|
|
}
|
|
}
|
|
function cbListener(listener) {
|
|
listener(self.error);
|
|
}
|
|
}
|
|
|
|
function pendGo(self, fn) {
|
|
fn(pendHold(self));
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 966:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const {PassThrough} = __webpack_require__(413);
|
|
|
|
module.exports = options => {
|
|
options = Object.assign({}, options);
|
|
|
|
const {array} = options;
|
|
let {encoding} = options;
|
|
const buffer = encoding === 'buffer';
|
|
let objectMode = false;
|
|
|
|
if (array) {
|
|
objectMode = !(encoding || buffer);
|
|
} else {
|
|
encoding = encoding || 'utf8';
|
|
}
|
|
|
|
if (buffer) {
|
|
encoding = null;
|
|
}
|
|
|
|
let len = 0;
|
|
const ret = [];
|
|
const stream = new PassThrough({objectMode});
|
|
|
|
if (encoding) {
|
|
stream.setEncoding(encoding);
|
|
}
|
|
|
|
stream.on('data', chunk => {
|
|
ret.push(chunk);
|
|
|
|
if (objectMode) {
|
|
len = ret.length;
|
|
} else {
|
|
len += chunk.length;
|
|
}
|
|
});
|
|
|
|
stream.getBufferedValue = () => {
|
|
if (array) {
|
|
return ret;
|
|
}
|
|
|
|
return buffer ? Buffer.concat(ret, len) : ret.join('');
|
|
};
|
|
|
|
stream.getBufferedLength = () => len;
|
|
|
|
return stream;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 979:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
result["default"] = mod;
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const core = __importStar(__webpack_require__(470));
|
|
/**
|
|
* Internal class for retries
|
|
*/
|
|
class RetryHelper {
|
|
constructor(maxAttempts, minSeconds, maxSeconds) {
|
|
if (maxAttempts < 1) {
|
|
throw new Error('max attempts should be greater than or equal to 1');
|
|
}
|
|
this.maxAttempts = maxAttempts;
|
|
this.minSeconds = Math.floor(minSeconds);
|
|
this.maxSeconds = Math.floor(maxSeconds);
|
|
if (this.minSeconds > this.maxSeconds) {
|
|
throw new Error('min seconds should be less than or equal to max seconds');
|
|
}
|
|
}
|
|
execute(action, isRetryable) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
let attempt = 1;
|
|
while (attempt < this.maxAttempts) {
|
|
// Try
|
|
try {
|
|
return yield action();
|
|
}
|
|
catch (err) {
|
|
if (isRetryable && !isRetryable(err)) {
|
|
throw err;
|
|
}
|
|
core.info(err.message);
|
|
}
|
|
// Sleep
|
|
const seconds = this.getSleepAmount();
|
|
core.info(`Waiting ${seconds} seconds before trying again`);
|
|
yield this.sleep(seconds);
|
|
attempt++;
|
|
}
|
|
// Last attempt
|
|
return yield action();
|
|
});
|
|
}
|
|
getSleepAmount() {
|
|
return (Math.floor(Math.random() * (this.maxSeconds - this.minSeconds + 1)) +
|
|
this.minSeconds);
|
|
}
|
|
sleep(seconds) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
|
|
});
|
|
}
|
|
}
|
|
exports.RetryHelper = RetryHelper;
|
|
//# sourceMappingURL=retry-helper.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 982:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
|
|
var net = __webpack_require__(937);
|
|
var tls = __webpack_require__(818);
|
|
var http = __webpack_require__(605);
|
|
var https = __webpack_require__(211);
|
|
var events = __webpack_require__(614);
|
|
var assert = __webpack_require__(357);
|
|
var util = __webpack_require__(669);
|
|
|
|
|
|
exports.httpOverHttp = httpOverHttp;
|
|
exports.httpsOverHttp = httpsOverHttp;
|
|
exports.httpOverHttps = httpOverHttps;
|
|
exports.httpsOverHttps = httpsOverHttps;
|
|
|
|
|
|
function httpOverHttp(options) {
|
|
var agent = new TunnelingAgent(options);
|
|
agent.request = http.request;
|
|
return agent;
|
|
}
|
|
|
|
function httpsOverHttp(options) {
|
|
var agent = new TunnelingAgent(options);
|
|
agent.request = http.request;
|
|
agent.createSocket = createSecureSocket;
|
|
agent.defaultPort = 443;
|
|
return agent;
|
|
}
|
|
|
|
function httpOverHttps(options) {
|
|
var agent = new TunnelingAgent(options);
|
|
agent.request = https.request;
|
|
return agent;
|
|
}
|
|
|
|
function httpsOverHttps(options) {
|
|
var agent = new TunnelingAgent(options);
|
|
agent.request = https.request;
|
|
agent.createSocket = createSecureSocket;
|
|
agent.defaultPort = 443;
|
|
return agent;
|
|
}
|
|
|
|
|
|
function TunnelingAgent(options) {
|
|
var self = this;
|
|
self.options = options || {};
|
|
self.proxyOptions = self.options.proxy || {};
|
|
self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets;
|
|
self.requests = [];
|
|
self.sockets = [];
|
|
|
|
self.on('free', function onFree(socket, host, port, localAddress) {
|
|
var options = toOptions(host, port, localAddress);
|
|
for (var i = 0, len = self.requests.length; i < len; ++i) {
|
|
var pending = self.requests[i];
|
|
if (pending.host === options.host && pending.port === options.port) {
|
|
// Detect the request to connect same origin server,
|
|
// reuse the connection.
|
|
self.requests.splice(i, 1);
|
|
pending.request.onSocket(socket);
|
|
return;
|
|
}
|
|
}
|
|
socket.destroy();
|
|
self.removeSocket(socket);
|
|
});
|
|
}
|
|
util.inherits(TunnelingAgent, events.EventEmitter);
|
|
|
|
TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) {
|
|
var self = this;
|
|
var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress));
|
|
|
|
if (self.sockets.length >= this.maxSockets) {
|
|
// We are over limit so we'll add it to the queue.
|
|
self.requests.push(options);
|
|
return;
|
|
}
|
|
|
|
// If we are under maxSockets create a new one.
|
|
self.createSocket(options, function(socket) {
|
|
socket.on('free', onFree);
|
|
socket.on('close', onCloseOrRemove);
|
|
socket.on('agentRemove', onCloseOrRemove);
|
|
req.onSocket(socket);
|
|
|
|
function onFree() {
|
|
self.emit('free', socket, options);
|
|
}
|
|
|
|
function onCloseOrRemove(err) {
|
|
self.removeSocket(socket);
|
|
socket.removeListener('free', onFree);
|
|
socket.removeListener('close', onCloseOrRemove);
|
|
socket.removeListener('agentRemove', onCloseOrRemove);
|
|
}
|
|
});
|
|
};
|
|
|
|
TunnelingAgent.prototype.createSocket = function createSocket(options, cb) {
|
|
var self = this;
|
|
var placeholder = {};
|
|
self.sockets.push(placeholder);
|
|
|
|
var connectOptions = mergeOptions({}, self.proxyOptions, {
|
|
method: 'CONNECT',
|
|
path: options.host + ':' + options.port,
|
|
agent: false,
|
|
headers: {
|
|
host: options.host + ':' + options.port
|
|
}
|
|
});
|
|
if (options.localAddress) {
|
|
connectOptions.localAddress = options.localAddress;
|
|
}
|
|
if (connectOptions.proxyAuth) {
|
|
connectOptions.headers = connectOptions.headers || {};
|
|
connectOptions.headers['Proxy-Authorization'] = 'Basic ' +
|
|
new Buffer(connectOptions.proxyAuth).toString('base64');
|
|
}
|
|
|
|
debug('making CONNECT request');
|
|
var connectReq = self.request(connectOptions);
|
|
connectReq.useChunkedEncodingByDefault = false; // for v0.6
|
|
connectReq.once('response', onResponse); // for v0.6
|
|
connectReq.once('upgrade', onUpgrade); // for v0.6
|
|
connectReq.once('connect', onConnect); // for v0.7 or later
|
|
connectReq.once('error', onError);
|
|
connectReq.end();
|
|
|
|
function onResponse(res) {
|
|
// Very hacky. This is necessary to avoid http-parser leaks.
|
|
res.upgrade = true;
|
|
}
|
|
|
|
function onUpgrade(res, socket, head) {
|
|
// Hacky.
|
|
process.nextTick(function() {
|
|
onConnect(res, socket, head);
|
|
});
|
|
}
|
|
|
|
function onConnect(res, socket, head) {
|
|
connectReq.removeAllListeners();
|
|
socket.removeAllListeners();
|
|
|
|
if (res.statusCode !== 200) {
|
|
debug('tunneling socket could not be established, statusCode=%d',
|
|
res.statusCode);
|
|
socket.destroy();
|
|
var error = new Error('tunneling socket could not be established, ' +
|
|
'statusCode=' + res.statusCode);
|
|
error.code = 'ECONNRESET';
|
|
options.request.emit('error', error);
|
|
self.removeSocket(placeholder);
|
|
return;
|
|
}
|
|
if (head.length > 0) {
|
|
debug('got illegal response body from proxy');
|
|
socket.destroy();
|
|
var error = new Error('got illegal response body from proxy');
|
|
error.code = 'ECONNRESET';
|
|
options.request.emit('error', error);
|
|
self.removeSocket(placeholder);
|
|
return;
|
|
}
|
|
debug('tunneling connection has established');
|
|
self.sockets[self.sockets.indexOf(placeholder)] = socket;
|
|
return cb(socket);
|
|
}
|
|
|
|
function onError(cause) {
|
|
connectReq.removeAllListeners();
|
|
|
|
debug('tunneling socket could not be established, cause=%s\n',
|
|
cause.message, cause.stack);
|
|
var error = new Error('tunneling socket could not be established, ' +
|
|
'cause=' + cause.message);
|
|
error.code = 'ECONNRESET';
|
|
options.request.emit('error', error);
|
|
self.removeSocket(placeholder);
|
|
}
|
|
};
|
|
|
|
TunnelingAgent.prototype.removeSocket = function removeSocket(socket) {
|
|
var pos = this.sockets.indexOf(socket)
|
|
if (pos === -1) {
|
|
return;
|
|
}
|
|
this.sockets.splice(pos, 1);
|
|
|
|
var pending = this.requests.shift();
|
|
if (pending) {
|
|
// If we have pending requests and a socket gets closed a new one
|
|
// needs to be created to take over in the pool for the one that closed.
|
|
this.createSocket(pending, function(socket) {
|
|
pending.request.onSocket(socket);
|
|
});
|
|
}
|
|
};
|
|
|
|
function createSecureSocket(options, cb) {
|
|
var self = this;
|
|
TunnelingAgent.prototype.createSocket.call(self, options, function(socket) {
|
|
var hostHeader = options.request.getHeader('host');
|
|
var tlsOptions = mergeOptions({}, self.options, {
|
|
socket: socket,
|
|
servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host
|
|
});
|
|
|
|
// 0 is dummy port for v0.6
|
|
var secureSocket = tls.connect(0, tlsOptions);
|
|
self.sockets[self.sockets.indexOf(socket)] = secureSocket;
|
|
cb(secureSocket);
|
|
});
|
|
}
|
|
|
|
|
|
function toOptions(host, port, localAddress) {
|
|
if (typeof host === 'string') { // since v0.10
|
|
return {
|
|
host: host,
|
|
port: port,
|
|
localAddress: localAddress
|
|
};
|
|
}
|
|
return host; // for v0.11 or later
|
|
}
|
|
|
|
function mergeOptions(target) {
|
|
for (var i = 1, len = arguments.length; i < len; ++i) {
|
|
var overrides = arguments[i];
|
|
if (typeof overrides === 'object') {
|
|
var keys = Object.keys(overrides);
|
|
for (var j = 0, keyLen = keys.length; j < keyLen; ++j) {
|
|
var k = keys[j];
|
|
if (overrides[k] !== undefined) {
|
|
target[k] = overrides[k];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return target;
|
|
}
|
|
|
|
|
|
var debug;
|
|
if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) {
|
|
debug = function() {
|
|
var args = Array.prototype.slice.call(arguments);
|
|
if (typeof args[0] === 'string') {
|
|
args[0] = 'TUNNEL: ' + args[0];
|
|
} else {
|
|
args.unshift('TUNNEL:');
|
|
}
|
|
console.error.apply(console, args);
|
|
}
|
|
} else {
|
|
debug = function() {};
|
|
}
|
|
exports.debug = debug; // for test
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 984:
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
const EventEmitter = __webpack_require__(614);
|
|
const http = __webpack_require__(605);
|
|
const https = __webpack_require__(211);
|
|
const PassThrough = __webpack_require__(413).PassThrough;
|
|
const Transform = __webpack_require__(413).Transform;
|
|
const urlLib = __webpack_require__(835);
|
|
const fs = __webpack_require__(747);
|
|
const querystring = __webpack_require__(191);
|
|
const CacheableRequest = __webpack_require__(946);
|
|
const duplexer3 = __webpack_require__(718);
|
|
const intoStream = __webpack_require__(351);
|
|
const is = __webpack_require__(564);
|
|
const getStream = __webpack_require__(705);
|
|
const timedOut = __webpack_require__(108);
|
|
const urlParseLax = __webpack_require__(173);
|
|
const urlToOptions = __webpack_require__(462);
|
|
const lowercaseKeys = __webpack_require__(474);
|
|
const decompressResponse = __webpack_require__(861);
|
|
const mimicResponse = __webpack_require__(89);
|
|
const isRetryAllowed = __webpack_require__(308);
|
|
const isURL = __webpack_require__(277);
|
|
const PCancelable = __webpack_require__(557);
|
|
const pTimeout = __webpack_require__(654);
|
|
const pify = __webpack_require__(525);
|
|
const Buffer = __webpack_require__(149).Buffer;
|
|
const pkg = __webpack_require__(482);
|
|
const errors = __webpack_require__(147);
|
|
|
|
const getMethodRedirectCodes = new Set([300, 301, 302, 303, 304, 305, 307, 308]);
|
|
const allMethodRedirectCodes = new Set([300, 303, 307, 308]);
|
|
|
|
const isFormData = body => is.nodeStream(body) && is.function(body.getBoundary);
|
|
|
|
const getBodySize = opts => {
|
|
const body = opts.body;
|
|
|
|
if (opts.headers['content-length']) {
|
|
return Number(opts.headers['content-length']);
|
|
}
|
|
|
|
if (!body && !opts.stream) {
|
|
return 0;
|
|
}
|
|
|
|
if (is.string(body)) {
|
|
return Buffer.byteLength(body);
|
|
}
|
|
|
|
if (isFormData(body)) {
|
|
return pify(body.getLength.bind(body))();
|
|
}
|
|
|
|
if (body instanceof fs.ReadStream) {
|
|
return pify(fs.stat)(body.path).then(stat => stat.size);
|
|
}
|
|
|
|
if (is.nodeStream(body) && is.buffer(body._buffer)) {
|
|
return body._buffer.length;
|
|
}
|
|
|
|
return null;
|
|
};
|
|
|
|
function requestAsEventEmitter(opts) {
|
|
opts = opts || {};
|
|
|
|
const ee = new EventEmitter();
|
|
const requestUrl = opts.href || urlLib.resolve(urlLib.format(opts), opts.path);
|
|
const redirects = [];
|
|
const agents = is.object(opts.agent) ? opts.agent : null;
|
|
let retryCount = 0;
|
|
let redirectUrl;
|
|
let uploadBodySize;
|
|
let uploaded = 0;
|
|
|
|
const get = opts => {
|
|
if (opts.protocol !== 'http:' && opts.protocol !== 'https:') {
|
|
ee.emit('error', new got.UnsupportedProtocolError(opts));
|
|
return;
|
|
}
|
|
|
|
let fn = opts.protocol === 'https:' ? https : http;
|
|
|
|
if (agents) {
|
|
const protocolName = opts.protocol === 'https:' ? 'https' : 'http';
|
|
opts.agent = agents[protocolName] || opts.agent;
|
|
}
|
|
|
|
if (opts.useElectronNet && process.versions.electron) {
|
|
const electron = __webpack_require__(883);
|
|
fn = electron.net || electron.remote.net;
|
|
}
|
|
|
|
let progressInterval;
|
|
|
|
const cacheableRequest = new CacheableRequest(fn.request, opts.cache);
|
|
const cacheReq = cacheableRequest(opts, res => {
|
|
clearInterval(progressInterval);
|
|
|
|
ee.emit('uploadProgress', {
|
|
percent: 1,
|
|
transferred: uploaded,
|
|
total: uploadBodySize
|
|
});
|
|
|
|
const statusCode = res.statusCode;
|
|
|
|
res.url = redirectUrl || requestUrl;
|
|
res.requestUrl = requestUrl;
|
|
|
|
const followRedirect = opts.followRedirect && 'location' in res.headers;
|
|
const redirectGet = followRedirect && getMethodRedirectCodes.has(statusCode);
|
|
const redirectAll = followRedirect && allMethodRedirectCodes.has(statusCode);
|
|
|
|
if (redirectAll || (redirectGet && (opts.method === 'GET' || opts.method === 'HEAD'))) {
|
|
res.resume();
|
|
|
|
if (statusCode === 303) {
|
|
// Server responded with "see other", indicating that the resource exists at another location,
|
|
// and the client should request it from that location via GET or HEAD.
|
|
opts.method = 'GET';
|
|
}
|
|
|
|
if (redirects.length >= 10) {
|
|
ee.emit('error', new got.MaxRedirectsError(statusCode, redirects, opts), null, res);
|
|
return;
|
|
}
|
|
|
|
const bufferString = Buffer.from(res.headers.location, 'binary').toString();
|
|
|
|
redirectUrl = urlLib.resolve(urlLib.format(opts), bufferString);
|
|
|
|
redirects.push(redirectUrl);
|
|
|
|
const redirectOpts = Object.assign({}, opts, urlLib.parse(redirectUrl));
|
|
|
|
ee.emit('redirect', res, redirectOpts);
|
|
|
|
get(redirectOpts);
|
|
|
|
return;
|
|
}
|
|
|
|
setImmediate(() => {
|
|
try {
|
|
getResponse(res, opts, ee, redirects);
|
|
} catch (e) {
|
|
ee.emit('error', e);
|
|
}
|
|
});
|
|
});
|
|
|
|
cacheReq.on('error', err => {
|
|
if (err instanceof CacheableRequest.RequestError) {
|
|
ee.emit('error', new got.RequestError(err, opts));
|
|
} else {
|
|
ee.emit('error', new got.CacheError(err, opts));
|
|
}
|
|
});
|
|
|
|
cacheReq.once('request', req => {
|
|
let aborted = false;
|
|
req.once('abort', _ => {
|
|
aborted = true;
|
|
});
|
|
|
|
req.once('error', err => {
|
|
clearInterval(progressInterval);
|
|
|
|
if (aborted) {
|
|
return;
|
|
}
|
|
|
|
const backoff = opts.retries(++retryCount, err);
|
|
|
|
if (backoff) {
|
|
setTimeout(get, backoff, opts);
|
|
return;
|
|
}
|
|
|
|
ee.emit('error', new got.RequestError(err, opts));
|
|
});
|
|
|
|
ee.once('request', req => {
|
|
ee.emit('uploadProgress', {
|
|
percent: 0,
|
|
transferred: 0,
|
|
total: uploadBodySize
|
|
});
|
|
|
|
const socket = req.connection;
|
|
if (socket) {
|
|
// `._connecting` was the old property which was made public in node v6.1.0
|
|
const isConnecting = socket.connecting === undefined ? socket._connecting : socket.connecting;
|
|
|
|
const onSocketConnect = () => {
|
|
const uploadEventFrequency = 150;
|
|
|
|
progressInterval = setInterval(() => {
|
|
if (socket.destroyed) {
|
|
clearInterval(progressInterval);
|
|
return;
|
|
}
|
|
|
|
const lastUploaded = uploaded;
|
|
const headersSize = req._header ? Buffer.byteLength(req._header) : 0;
|
|
uploaded = socket.bytesWritten - headersSize;
|
|
|
|
// Prevent the known issue of `bytesWritten` being larger than body size
|
|
if (uploadBodySize && uploaded > uploadBodySize) {
|
|
uploaded = uploadBodySize;
|
|
}
|
|
|
|
// Don't emit events with unchanged progress and
|
|
// prevent last event from being emitted, because
|
|
// it's emitted when `response` is emitted
|
|
if (uploaded === lastUploaded || uploaded === uploadBodySize) {
|
|
return;
|
|
}
|
|
|
|
ee.emit('uploadProgress', {
|
|
percent: uploadBodySize ? uploaded / uploadBodySize : 0,
|
|
transferred: uploaded,
|
|
total: uploadBodySize
|
|
});
|
|
}, uploadEventFrequency);
|
|
};
|
|
|
|
// Only subscribe to 'connect' event if we're actually connecting a new
|
|
// socket, otherwise if we're already connected (because this is a
|
|
// keep-alive connection) do not bother. This is important since we won't
|
|
// get a 'connect' event for an already connected socket.
|
|
if (isConnecting) {
|
|
socket.once('connect', onSocketConnect);
|
|
} else {
|
|
onSocketConnect();
|
|
}
|
|
}
|
|
});
|
|
|
|
if (opts.gotTimeout) {
|
|
clearInterval(progressInterval);
|
|
timedOut(req, opts.gotTimeout);
|
|
}
|
|
|
|
setImmediate(() => {
|
|
ee.emit('request', req);
|
|
});
|
|
});
|
|
};
|
|
|
|
setImmediate(() => {
|
|
Promise.resolve(getBodySize(opts))
|
|
.then(size => {
|
|
uploadBodySize = size;
|
|
|
|
if (
|
|
is.undefined(opts.headers['content-length']) &&
|
|
is.undefined(opts.headers['transfer-encoding']) &&
|
|
isFormData(opts.body)
|
|
) {
|
|
opts.headers['content-length'] = size;
|
|
}
|
|
|
|
get(opts);
|
|
})
|
|
.catch(err => {
|
|
ee.emit('error', err);
|
|
});
|
|
});
|
|
|
|
return ee;
|
|
}
|
|
|
|
function getResponse(res, opts, ee, redirects) {
|
|
const downloadBodySize = Number(res.headers['content-length']) || null;
|
|
let downloaded = 0;
|
|
|
|
const progressStream = new Transform({
|
|
transform(chunk, encoding, callback) {
|
|
downloaded += chunk.length;
|
|
|
|
const percent = downloadBodySize ? downloaded / downloadBodySize : 0;
|
|
|
|
// Let flush() be responsible for emitting the last event
|
|
if (percent < 1) {
|
|
ee.emit('downloadProgress', {
|
|
percent,
|
|
transferred: downloaded,
|
|
total: downloadBodySize
|
|
});
|
|
}
|
|
|
|
callback(null, chunk);
|
|
},
|
|
|
|
flush(callback) {
|
|
ee.emit('downloadProgress', {
|
|
percent: 1,
|
|
transferred: downloaded,
|
|
total: downloadBodySize
|
|
});
|
|
|
|
callback();
|
|
}
|
|
});
|
|
|
|
mimicResponse(res, progressStream);
|
|
progressStream.redirectUrls = redirects;
|
|
|
|
const response = opts.decompress === true &&
|
|
is.function(decompressResponse) &&
|
|
opts.method !== 'HEAD' ? decompressResponse(progressStream) : progressStream;
|
|
|
|
if (!opts.decompress && ['gzip', 'deflate'].indexOf(res.headers['content-encoding']) !== -1) {
|
|
opts.encoding = null;
|
|
}
|
|
|
|
ee.emit('response', response);
|
|
|
|
ee.emit('downloadProgress', {
|
|
percent: 0,
|
|
transferred: 0,
|
|
total: downloadBodySize
|
|
});
|
|
|
|
res.pipe(progressStream);
|
|
}
|
|
|
|
function asPromise(opts) {
|
|
const timeoutFn = requestPromise => opts.gotTimeout && opts.gotTimeout.request ?
|
|
pTimeout(requestPromise, opts.gotTimeout.request, new got.RequestError({message: 'Request timed out', code: 'ETIMEDOUT'}, opts)) :
|
|
requestPromise;
|
|
|
|
const proxy = new EventEmitter();
|
|
|
|
const cancelable = new PCancelable((resolve, reject, onCancel) => {
|
|
const ee = requestAsEventEmitter(opts);
|
|
let cancelOnRequest = false;
|
|
|
|
onCancel(() => {
|
|
cancelOnRequest = true;
|
|
});
|
|
|
|
ee.on('request', req => {
|
|
if (cancelOnRequest) {
|
|
req.abort();
|
|
}
|
|
|
|
onCancel(() => {
|
|
req.abort();
|
|
});
|
|
|
|
if (is.nodeStream(opts.body)) {
|
|
opts.body.pipe(req);
|
|
opts.body = undefined;
|
|
return;
|
|
}
|
|
|
|
req.end(opts.body);
|
|
});
|
|
|
|
ee.on('response', res => {
|
|
const stream = is.null(opts.encoding) ? getStream.buffer(res) : getStream(res, opts);
|
|
|
|
stream
|
|
.catch(err => reject(new got.ReadError(err, opts)))
|
|
.then(data => {
|
|
const statusCode = res.statusCode;
|
|
const limitStatusCode = opts.followRedirect ? 299 : 399;
|
|
|
|
res.body = data;
|
|
|
|
if (opts.json && res.body) {
|
|
try {
|
|
res.body = JSON.parse(res.body);
|
|
} catch (err) {
|
|
if (statusCode >= 200 && statusCode < 300) {
|
|
throw new got.ParseError(err, statusCode, opts, data);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (opts.throwHttpErrors && statusCode !== 304 && (statusCode < 200 || statusCode > limitStatusCode)) {
|
|
throw new got.HTTPError(statusCode, res.statusMessage, res.headers, opts);
|
|
}
|
|
|
|
resolve(res);
|
|
})
|
|
.catch(err => {
|
|
Object.defineProperty(err, 'response', {value: res});
|
|
reject(err);
|
|
});
|
|
});
|
|
|
|
ee.once('error', reject);
|
|
ee.on('redirect', proxy.emit.bind(proxy, 'redirect'));
|
|
ee.on('uploadProgress', proxy.emit.bind(proxy, 'uploadProgress'));
|
|
ee.on('downloadProgress', proxy.emit.bind(proxy, 'downloadProgress'));
|
|
});
|
|
|
|
// Preserve backwards-compatibility
|
|
// TODO: Remove this in the next major version
|
|
Object.defineProperty(cancelable, 'canceled', {
|
|
get() {
|
|
return cancelable.isCanceled;
|
|
}
|
|
});
|
|
|
|
const promise = timeoutFn(cancelable);
|
|
|
|
promise.cancel = cancelable.cancel.bind(cancelable);
|
|
|
|
promise.on = (name, fn) => {
|
|
proxy.on(name, fn);
|
|
return promise;
|
|
};
|
|
|
|
return promise;
|
|
}
|
|
|
|
function asStream(opts) {
|
|
opts.stream = true;
|
|
|
|
const input = new PassThrough();
|
|
const output = new PassThrough();
|
|
const proxy = duplexer3(input, output);
|
|
let timeout;
|
|
|
|
if (opts.gotTimeout && opts.gotTimeout.request) {
|
|
timeout = setTimeout(() => {
|
|
proxy.emit('error', new got.RequestError({message: 'Request timed out', code: 'ETIMEDOUT'}, opts));
|
|
}, opts.gotTimeout.request);
|
|
}
|
|
|
|
if (opts.json) {
|
|
throw new Error('Got can not be used as a stream when the `json` option is used');
|
|
}
|
|
|
|
if (opts.body) {
|
|
proxy.write = () => {
|
|
throw new Error('Got\'s stream is not writable when the `body` option is used');
|
|
};
|
|
}
|
|
|
|
const ee = requestAsEventEmitter(opts);
|
|
|
|
ee.on('request', req => {
|
|
proxy.emit('request', req);
|
|
|
|
if (is.nodeStream(opts.body)) {
|
|
opts.body.pipe(req);
|
|
return;
|
|
}
|
|
|
|
if (opts.body) {
|
|
req.end(opts.body);
|
|
return;
|
|
}
|
|
|
|
if (opts.method === 'POST' || opts.method === 'PUT' || opts.method === 'PATCH') {
|
|
input.pipe(req);
|
|
return;
|
|
}
|
|
|
|
req.end();
|
|
});
|
|
|
|
ee.on('response', res => {
|
|
clearTimeout(timeout);
|
|
|
|
const statusCode = res.statusCode;
|
|
|
|
res.on('error', err => {
|
|
proxy.emit('error', new got.ReadError(err, opts));
|
|
});
|
|
|
|
res.pipe(output);
|
|
|
|
if (opts.throwHttpErrors && statusCode !== 304 && (statusCode < 200 || statusCode > 299)) {
|
|
proxy.emit('error', new got.HTTPError(statusCode, res.statusMessage, res.headers, opts), null, res);
|
|
return;
|
|
}
|
|
|
|
proxy.emit('response', res);
|
|
});
|
|
|
|
ee.on('error', proxy.emit.bind(proxy, 'error'));
|
|
ee.on('redirect', proxy.emit.bind(proxy, 'redirect'));
|
|
ee.on('uploadProgress', proxy.emit.bind(proxy, 'uploadProgress'));
|
|
ee.on('downloadProgress', proxy.emit.bind(proxy, 'downloadProgress'));
|
|
|
|
return proxy;
|
|
}
|
|
|
|
function normalizeArguments(url, opts) {
|
|
if (!is.string(url) && !is.object(url)) {
|
|
throw new TypeError(`Parameter \`url\` must be a string or object, not ${is(url)}`);
|
|
} else if (is.string(url)) {
|
|
url = url.replace(/^unix:/, 'http://$&');
|
|
|
|
try {
|
|
decodeURI(url);
|
|
} catch (err) {
|
|
throw new Error('Parameter `url` must contain valid UTF-8 character sequences');
|
|
}
|
|
|
|
url = urlParseLax(url);
|
|
if (url.auth) {
|
|
throw new Error('Basic authentication must be done with the `auth` option');
|
|
}
|
|
} else if (isURL.lenient(url)) {
|
|
url = urlToOptions(url);
|
|
}
|
|
|
|
opts = Object.assign(
|
|
{
|
|
path: '',
|
|
retries: 2,
|
|
cache: false,
|
|
decompress: true,
|
|
useElectronNet: false,
|
|
throwHttpErrors: true
|
|
},
|
|
url,
|
|
{
|
|
protocol: url.protocol || 'http:' // Override both null/undefined with default protocol
|
|
},
|
|
opts
|
|
);
|
|
|
|
const headers = lowercaseKeys(opts.headers);
|
|
for (const key of Object.keys(headers)) {
|
|
if (is.nullOrUndefined(headers[key])) {
|
|
delete headers[key];
|
|
}
|
|
}
|
|
|
|
opts.headers = Object.assign({
|
|
'user-agent': `${pkg.name}/${pkg.version} (https://github.com/sindresorhus/got)`
|
|
}, headers);
|
|
|
|
if (opts.decompress && is.undefined(opts.headers['accept-encoding'])) {
|
|
opts.headers['accept-encoding'] = 'gzip, deflate';
|
|
}
|
|
|
|
const query = opts.query;
|
|
|
|
if (query) {
|
|
if (!is.string(query)) {
|
|
opts.query = querystring.stringify(query);
|
|
}
|
|
|
|
opts.path = `${opts.path.split('?')[0]}?${opts.query}`;
|
|
delete opts.query;
|
|
}
|
|
|
|
if (opts.json && is.undefined(opts.headers.accept)) {
|
|
opts.headers.accept = 'application/json';
|
|
}
|
|
|
|
const body = opts.body;
|
|
if (is.nullOrUndefined(body)) {
|
|
opts.method = (opts.method || 'GET').toUpperCase();
|
|
} else {
|
|
const headers = opts.headers;
|
|
if (!is.nodeStream(body) && !is.string(body) && !is.buffer(body) && !(opts.form || opts.json)) {
|
|
throw new TypeError('The `body` option must be a stream.Readable, string, Buffer or plain Object');
|
|
}
|
|
|
|
const canBodyBeStringified = is.plainObject(body) || is.array(body);
|
|
if ((opts.form || opts.json) && !canBodyBeStringified) {
|
|
throw new TypeError('The `body` option must be a plain Object or Array when the `form` or `json` option is used');
|
|
}
|
|
|
|
if (isFormData(body)) {
|
|
// Special case for https://github.com/form-data/form-data
|
|
headers['content-type'] = headers['content-type'] || `multipart/form-data; boundary=${body.getBoundary()}`;
|
|
} else if (opts.form && canBodyBeStringified) {
|
|
headers['content-type'] = headers['content-type'] || 'application/x-www-form-urlencoded';
|
|
opts.body = querystring.stringify(body);
|
|
} else if (opts.json && canBodyBeStringified) {
|
|
headers['content-type'] = headers['content-type'] || 'application/json';
|
|
opts.body = JSON.stringify(body);
|
|
}
|
|
|
|
if (is.undefined(headers['content-length']) && is.undefined(headers['transfer-encoding']) && !is.nodeStream(body)) {
|
|
const length = is.string(opts.body) ? Buffer.byteLength(opts.body) : opts.body.length;
|
|
headers['content-length'] = length;
|
|
}
|
|
|
|
// Convert buffer to stream to receive upload progress events
|
|
// see https://github.com/sindresorhus/got/pull/322
|
|
if (is.buffer(body)) {
|
|
opts.body = intoStream(body);
|
|
opts.body._buffer = body;
|
|
}
|
|
|
|
opts.method = (opts.method || 'POST').toUpperCase();
|
|
}
|
|
|
|
if (opts.hostname === 'unix') {
|
|
const matches = /(.+?):(.+)/.exec(opts.path);
|
|
|
|
if (matches) {
|
|
opts.socketPath = matches[1];
|
|
opts.path = matches[2];
|
|
opts.host = null;
|
|
}
|
|
}
|
|
|
|
if (!is.function(opts.retries)) {
|
|
const retries = opts.retries;
|
|
|
|
opts.retries = (iter, err) => {
|
|
if (iter > retries || !isRetryAllowed(err)) {
|
|
return 0;
|
|
}
|
|
|
|
const noise = Math.random() * 100;
|
|
|
|
return ((1 << iter) * 1000) + noise;
|
|
};
|
|
}
|
|
|
|
if (is.undefined(opts.followRedirect)) {
|
|
opts.followRedirect = true;
|
|
}
|
|
|
|
if (opts.timeout) {
|
|
if (is.number(opts.timeout)) {
|
|
opts.gotTimeout = {request: opts.timeout};
|
|
} else {
|
|
opts.gotTimeout = opts.timeout;
|
|
}
|
|
delete opts.timeout;
|
|
}
|
|
|
|
return opts;
|
|
}
|
|
|
|
function got(url, opts) {
|
|
try {
|
|
const normalizedArgs = normalizeArguments(url, opts);
|
|
|
|
if (normalizedArgs.stream) {
|
|
return asStream(normalizedArgs);
|
|
}
|
|
|
|
return asPromise(normalizedArgs);
|
|
} catch (err) {
|
|
return Promise.reject(err);
|
|
}
|
|
}
|
|
|
|
got.stream = (url, opts) => asStream(normalizeArguments(url, opts));
|
|
|
|
const methods = [
|
|
'get',
|
|
'post',
|
|
'put',
|
|
'patch',
|
|
'head',
|
|
'delete'
|
|
];
|
|
|
|
for (const method of methods) {
|
|
got[method] = (url, opts) => got(url, Object.assign({}, opts, {method}));
|
|
got.stream[method] = (url, opts) => got.stream(url, Object.assign({}, opts, {method}));
|
|
}
|
|
|
|
Object.assign(got, errors);
|
|
|
|
module.exports = got;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 986:
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const tr = __webpack_require__(686);
|
|
/**
|
|
* Exec a command.
|
|
* Output will be streamed to the live console.
|
|
* Returns promise with return code
|
|
*
|
|
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
|
* @param args optional arguments for tool. Escaping is handled by the lib.
|
|
* @param options optional exec options. See ExecOptions
|
|
* @returns Promise<number> exit code
|
|
*/
|
|
function exec(commandLine, args, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const commandArgs = tr.argStringToArray(commandLine);
|
|
if (commandArgs.length === 0) {
|
|
throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
|
|
}
|
|
// Path to tool to execute should be first arg
|
|
const toolPath = commandArgs[0];
|
|
args = commandArgs.slice(1).concat(args || []);
|
|
const runner = new tr.ToolRunner(toolPath, args, options);
|
|
return runner.exec();
|
|
});
|
|
}
|
|
exports.exec = exec;
|
|
//# sourceMappingURL=exec.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 999:
|
|
/***/ (function(module) {
|
|
|
|
"use strict";
|
|
/*
|
|
object-assign
|
|
(c) Sindre Sorhus
|
|
@license MIT
|
|
*/
|
|
|
|
|
|
/* eslint-disable no-unused-vars */
|
|
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
|
|
function toObject(val) {
|
|
if (val === null || val === undefined) {
|
|
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
}
|
|
|
|
return Object(val);
|
|
}
|
|
|
|
function shouldUseNative() {
|
|
try {
|
|
if (!Object.assign) {
|
|
return false;
|
|
}
|
|
|
|
// Detect buggy property enumeration order in older V8 versions.
|
|
|
|
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
|
|
test1[5] = 'de';
|
|
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
return false;
|
|
}
|
|
|
|
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
var test2 = {};
|
|
for (var i = 0; i < 10; i++) {
|
|
test2['_' + String.fromCharCode(i)] = i;
|
|
}
|
|
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
return test2[n];
|
|
});
|
|
if (order2.join('') !== '0123456789') {
|
|
return false;
|
|
}
|
|
|
|
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
var test3 = {};
|
|
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
test3[letter] = letter;
|
|
});
|
|
if (Object.keys(Object.assign({}, test3)).join('') !==
|
|
'abcdefghijklmnopqrst') {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
} catch (err) {
|
|
// We don't expect any of the above to throw, but better to be safe.
|
|
return false;
|
|
}
|
|
}
|
|
|
|
module.exports = shouldUseNative() ? Object.assign : function (target, source) {
|
|
var from;
|
|
var to = toObject(target);
|
|
var symbols;
|
|
|
|
for (var s = 1; s < arguments.length; s++) {
|
|
from = Object(arguments[s]);
|
|
|
|
for (var key in from) {
|
|
if (hasOwnProperty.call(from, key)) {
|
|
to[key] = from[key];
|
|
}
|
|
}
|
|
|
|
if (getOwnPropertySymbols) {
|
|
symbols = getOwnPropertySymbols(from);
|
|
for (var i = 0; i < symbols.length; i++) {
|
|
if (propIsEnumerable.call(from, symbols[i])) {
|
|
to[symbols[i]] = from[symbols[i]];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return to;
|
|
};
|
|
|
|
|
|
/***/ })
|
|
|
|
/******/ }); |