3897 lines
106 KiB
JavaScript
3897 lines
106 KiB
JavaScript
/******/ (function(modules) { // webpackBootstrap
|
||
/******/ // 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;
|
||
/******/ }
|
||
/******/
|
||
/******/
|
||
/******/ // expose the modules object (__webpack_modules__)
|
||
/******/ __webpack_require__.m = modules;
|
||
/******/
|
||
/******/ // expose the module cache
|
||
/******/ __webpack_require__.c = installedModules;
|
||
/******/
|
||
/******/ // define getter function for harmony exports
|
||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||
/******/ }
|
||
/******/ };
|
||
/******/
|
||
/******/ // define __esModule on exports
|
||
/******/ __webpack_require__.r = function(exports) {
|
||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||
/******/ }
|
||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||
/******/ };
|
||
/******/
|
||
/******/ // create a fake namespace object
|
||
/******/ // mode & 1: value is a module id, require it
|
||
/******/ // mode & 2: merge all properties of value into the ns
|
||
/******/ // mode & 4: return value when already ns object
|
||
/******/ // mode & 8|1: behave like require
|
||
/******/ __webpack_require__.t = function(value, mode) {
|
||
/******/ if(mode & 1) value = __webpack_require__(value);
|
||
/******/ if(mode & 8) return value;
|
||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||
/******/ var ns = Object.create(null);
|
||
/******/ __webpack_require__.r(ns);
|
||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||
/******/ return ns;
|
||
/******/ };
|
||
/******/
|
||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||
/******/ __webpack_require__.n = function(module) {
|
||
/******/ var getter = module && module.__esModule ?
|
||
/******/ function getDefault() { return module['default']; } :
|
||
/******/ function getModuleExports() { return module; };
|
||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||
/******/ return getter;
|
||
/******/ };
|
||
/******/
|
||
/******/ // Object.prototype.hasOwnProperty.call
|
||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||
/******/
|
||
/******/ // __webpack_public_path__
|
||
/******/ __webpack_require__.p = "";
|
||
/******/
|
||
/******/
|
||
/******/ // Load entry module and return exports
|
||
/******/ return __webpack_require__(__webpack_require__.s = 48);
|
||
/******/ })
|
||
/************************************************************************/
|
||
/******/ ([
|
||
/* 0 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var bind = __webpack_require__(4);
|
||
/*global toString:true*/
|
||
// utils is a library of generic helper functions non-specific to axios
|
||
|
||
|
||
var toString = Object.prototype.toString;
|
||
/**
|
||
* Determine if a value is an Array
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if value is an Array, otherwise false
|
||
*/
|
||
|
||
function isArray(val) {
|
||
return toString.call(val) === '[object Array]';
|
||
}
|
||
/**
|
||
* Determine if a value is undefined
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if the value is undefined, otherwise false
|
||
*/
|
||
|
||
|
||
function isUndefined(val) {
|
||
return typeof val === 'undefined';
|
||
}
|
||
/**
|
||
* Determine if a value is a Buffer
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if value is a Buffer, otherwise false
|
||
*/
|
||
|
||
|
||
function isBuffer(val) {
|
||
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
|
||
}
|
||
/**
|
||
* Determine if a value is an ArrayBuffer
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
||
*/
|
||
|
||
|
||
function isArrayBuffer(val) {
|
||
return toString.call(val) === '[object ArrayBuffer]';
|
||
}
|
||
/**
|
||
* Determine if a value is a FormData
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if value is an FormData, otherwise false
|
||
*/
|
||
|
||
|
||
function isFormData(val) {
|
||
return typeof FormData !== 'undefined' && val instanceof FormData;
|
||
}
|
||
/**
|
||
* Determine if a value is a view on an ArrayBuffer
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
||
*/
|
||
|
||
|
||
function isArrayBufferView(val) {
|
||
var result;
|
||
|
||
if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
|
||
result = ArrayBuffer.isView(val);
|
||
} else {
|
||
result = val && val.buffer && val.buffer instanceof ArrayBuffer;
|
||
}
|
||
|
||
return result;
|
||
}
|
||
/**
|
||
* Determine if a value is a String
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if value is a String, otherwise false
|
||
*/
|
||
|
||
|
||
function isString(val) {
|
||
return typeof val === 'string';
|
||
}
|
||
/**
|
||
* Determine if a value is a Number
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if value is a Number, otherwise false
|
||
*/
|
||
|
||
|
||
function isNumber(val) {
|
||
return typeof val === 'number';
|
||
}
|
||
/**
|
||
* Determine if a value is an Object
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if value is an Object, otherwise false
|
||
*/
|
||
|
||
|
||
function isObject(val) {
|
||
return val !== null && typeof val === 'object';
|
||
}
|
||
/**
|
||
* Determine if a value is a plain Object
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @return {boolean} True if value is a plain Object, otherwise false
|
||
*/
|
||
|
||
|
||
function isPlainObject(val) {
|
||
if (toString.call(val) !== '[object Object]') {
|
||
return false;
|
||
}
|
||
|
||
var prototype = Object.getPrototypeOf(val);
|
||
return prototype === null || prototype === Object.prototype;
|
||
}
|
||
/**
|
||
* Determine if a value is a Date
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if value is a Date, otherwise false
|
||
*/
|
||
|
||
|
||
function isDate(val) {
|
||
return toString.call(val) === '[object Date]';
|
||
}
|
||
/**
|
||
* Determine if a value is a File
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if value is a File, otherwise false
|
||
*/
|
||
|
||
|
||
function isFile(val) {
|
||
return toString.call(val) === '[object File]';
|
||
}
|
||
/**
|
||
* Determine if a value is a Blob
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if value is a Blob, otherwise false
|
||
*/
|
||
|
||
|
||
function isBlob(val) {
|
||
return toString.call(val) === '[object Blob]';
|
||
}
|
||
/**
|
||
* Determine if a value is a Function
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if value is a Function, otherwise false
|
||
*/
|
||
|
||
|
||
function isFunction(val) {
|
||
return toString.call(val) === '[object Function]';
|
||
}
|
||
/**
|
||
* Determine if a value is a Stream
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if value is a Stream, otherwise false
|
||
*/
|
||
|
||
|
||
function isStream(val) {
|
||
return isObject(val) && isFunction(val.pipe);
|
||
}
|
||
/**
|
||
* Determine if a value is a URLSearchParams object
|
||
*
|
||
* @param {Object} val The value to test
|
||
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
||
*/
|
||
|
||
|
||
function isURLSearchParams(val) {
|
||
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
|
||
}
|
||
/**
|
||
* Trim excess whitespace off the beginning and end of a string
|
||
*
|
||
* @param {String} str The String to trim
|
||
* @returns {String} The String freed of excess whitespace
|
||
*/
|
||
|
||
|
||
function trim(str) {
|
||
return str.replace(/^\s*/, '').replace(/\s*$/, '');
|
||
}
|
||
/**
|
||
* Determine if we're running in a standard browser environment
|
||
*
|
||
* This allows axios to run in a web worker, and react-native.
|
||
* Both environments support XMLHttpRequest, but not fully standard globals.
|
||
*
|
||
* web workers:
|
||
* typeof window -> undefined
|
||
* typeof document -> undefined
|
||
*
|
||
* react-native:
|
||
* navigator.product -> 'ReactNative'
|
||
* nativescript
|
||
* navigator.product -> 'NativeScript' or 'NS'
|
||
*/
|
||
|
||
|
||
function isStandardBrowserEnv() {
|
||
if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || navigator.product === 'NativeScript' || navigator.product === 'NS')) {
|
||
return false;
|
||
}
|
||
|
||
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
||
}
|
||
/**
|
||
* Iterate over an Array or an Object invoking a function for each item.
|
||
*
|
||
* If `obj` is an Array callback will be called passing
|
||
* the value, index, and complete array for each item.
|
||
*
|
||
* If 'obj' is an Object callback will be called passing
|
||
* the value, key, and complete object for each property.
|
||
*
|
||
* @param {Object|Array} obj The object to iterate
|
||
* @param {Function} fn The callback to invoke for each item
|
||
*/
|
||
|
||
|
||
function forEach(obj, fn) {
|
||
// Don't bother if no value provided
|
||
if (obj === null || typeof obj === 'undefined') {
|
||
return;
|
||
} // Force an array if not already something iterable
|
||
|
||
|
||
if (typeof obj !== 'object') {
|
||
/*eslint no-param-reassign:0*/
|
||
obj = [obj];
|
||
}
|
||
|
||
if (isArray(obj)) {
|
||
// Iterate over array values
|
||
for (var i = 0, l = obj.length; i < l; i++) {
|
||
fn.call(null, obj[i], i, obj);
|
||
}
|
||
} else {
|
||
// Iterate over object keys
|
||
for (var key in obj) {
|
||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||
fn.call(null, obj[key], key, obj);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Accepts varargs expecting each argument to be an object, then
|
||
* immutably merges the properties of each object and returns result.
|
||
*
|
||
* When multiple objects contain the same key the later object in
|
||
* the arguments list will take precedence.
|
||
*
|
||
* Example:
|
||
*
|
||
* ```js
|
||
* var result = merge({foo: 123}, {foo: 456});
|
||
* console.log(result.foo); // outputs 456
|
||
* ```
|
||
*
|
||
* @param {Object} obj1 Object to merge
|
||
* @returns {Object} Result of all merge properties
|
||
*/
|
||
|
||
|
||
function merge()
|
||
/* obj1, obj2, obj3, ... */
|
||
{
|
||
var result = {};
|
||
|
||
function assignValue(val, key) {
|
||
if (isPlainObject(result[key]) && isPlainObject(val)) {
|
||
result[key] = merge(result[key], val);
|
||
} else if (isPlainObject(val)) {
|
||
result[key] = merge({}, val);
|
||
} else if (isArray(val)) {
|
||
result[key] = val.slice();
|
||
} else {
|
||
result[key] = val;
|
||
}
|
||
}
|
||
|
||
for (var i = 0, l = arguments.length; i < l; i++) {
|
||
forEach(arguments[i], assignValue);
|
||
}
|
||
|
||
return result;
|
||
}
|
||
/**
|
||
* Extends object a by mutably adding to it the properties of object b.
|
||
*
|
||
* @param {Object} a The object to be extended
|
||
* @param {Object} b The object to copy properties from
|
||
* @param {Object} thisArg The object to bind function to
|
||
* @return {Object} The resulting value of object a
|
||
*/
|
||
|
||
|
||
function extend(a, b, thisArg) {
|
||
forEach(b, function assignValue(val, key) {
|
||
if (thisArg && typeof val === 'function') {
|
||
a[key] = bind(val, thisArg);
|
||
} else {
|
||
a[key] = val;
|
||
}
|
||
});
|
||
return a;
|
||
}
|
||
/**
|
||
* Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
|
||
*
|
||
* @param {string} content with BOM
|
||
* @return {string} content value without BOM
|
||
*/
|
||
|
||
|
||
function stripBOM(content) {
|
||
if (content.charCodeAt(0) === 0xFEFF) {
|
||
content = content.slice(1);
|
||
}
|
||
|
||
return content;
|
||
}
|
||
|
||
module.exports = {
|
||
isArray: isArray,
|
||
isArrayBuffer: isArrayBuffer,
|
||
isBuffer: isBuffer,
|
||
isFormData: isFormData,
|
||
isArrayBufferView: isArrayBufferView,
|
||
isString: isString,
|
||
isNumber: isNumber,
|
||
isObject: isObject,
|
||
isPlainObject: isPlainObject,
|
||
isUndefined: isUndefined,
|
||
isDate: isDate,
|
||
isFile: isFile,
|
||
isBlob: isBlob,
|
||
isFunction: isFunction,
|
||
isStream: isStream,
|
||
isURLSearchParams: isURLSearchParams,
|
||
isStandardBrowserEnv: isStandardBrowserEnv,
|
||
forEach: forEach,
|
||
merge: merge,
|
||
extend: extend,
|
||
trim: trim,
|
||
stripBOM: stripBOM
|
||
};
|
||
|
||
/***/ }),
|
||
/* 1 */
|
||
/***/ (function(module) {
|
||
|
||
module.exports = JSON.parse("{\"name\":\"cfx-vote-plugin\",\"version\":\"3.0.2\",\"description\":\"A Fivem vote plugin for Top-games.net/Top-serveurs.net platforms\",\"scripts\":{\"build\":\"webpack --progress\",\"dev\":\"webpack --watch --progress\"},\"license\":\"MIT\",\"dependencies\":{\"axios\":\"^0.21.1\"},\"devDependencies\":{\"@babel/core\":\"^7.14.3\",\"@babel/eslint-parser\":\"^7.14.4\",\"@babel/eslint-plugin\":\"^7.13.16\",\"@babel/preset-env\":\"^7.14.4\",\"@citizenfx/server\":\"^1.0.2624-1\",\"babel-eslint\":\"^10.1.0\",\"babel-loader\":\"^8.2.2\",\"babel-plugin-transform-class-properties\":\"^6.24.1\",\"eslint\":\"^6.8.0\",\"webpack\":\"^4.46.0\",\"webpack-cli\":\"^3.3.12\"}}");
|
||
|
||
/***/ }),
|
||
/* 2 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var utils = __webpack_require__(0);
|
||
|
||
function encode(val) {
|
||
return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']');
|
||
}
|
||
/**
|
||
* Build a URL by appending params to the end
|
||
*
|
||
* @param {string} url The base of the url (e.g., http://www.google.com)
|
||
* @param {object} [params] The params to be appended
|
||
* @returns {string} The formatted url
|
||
*/
|
||
|
||
|
||
module.exports = function buildURL(url, params, paramsSerializer) {
|
||
/*eslint no-param-reassign:0*/
|
||
if (!params) {
|
||
return url;
|
||
}
|
||
|
||
var serializedParams;
|
||
|
||
if (paramsSerializer) {
|
||
serializedParams = paramsSerializer(params);
|
||
} else if (utils.isURLSearchParams(params)) {
|
||
serializedParams = params.toString();
|
||
} else {
|
||
var parts = [];
|
||
utils.forEach(params, function serialize(val, key) {
|
||
if (val === null || typeof val === 'undefined') {
|
||
return;
|
||
}
|
||
|
||
if (utils.isArray(val)) {
|
||
key = key + '[]';
|
||
} else {
|
||
val = [val];
|
||
}
|
||
|
||
utils.forEach(val, function parseValue(v) {
|
||
if (utils.isDate(v)) {
|
||
v = v.toISOString();
|
||
} else if (utils.isObject(v)) {
|
||
v = JSON.stringify(v);
|
||
}
|
||
|
||
parts.push(encode(key) + '=' + encode(v));
|
||
});
|
||
});
|
||
serializedParams = parts.join('&');
|
||
}
|
||
|
||
if (serializedParams) {
|
||
var hashmarkIndex = url.indexOf('#');
|
||
|
||
if (hashmarkIndex !== -1) {
|
||
url = url.slice(0, hashmarkIndex);
|
||
}
|
||
|
||
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
||
}
|
||
|
||
return url;
|
||
};
|
||
|
||
/***/ }),
|
||
/* 3 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var enhanceError = __webpack_require__(8);
|
||
/**
|
||
* Create an Error with the specified message, config, error code, request and response.
|
||
*
|
||
* @param {string} message The error message.
|
||
* @param {Object} config The config.
|
||
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
||
* @param {Object} [request] The request.
|
||
* @param {Object} [response] The response.
|
||
* @returns {Error} The created error.
|
||
*/
|
||
|
||
|
||
module.exports = function createError(message, config, code, request, response) {
|
||
var error = new Error(message);
|
||
return enhanceError(error, config, code, request, response);
|
||
};
|
||
|
||
/***/ }),
|
||
/* 4 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
module.exports = function bind(fn, thisArg) {
|
||
return function wrap() {
|
||
var args = new Array(arguments.length);
|
||
|
||
for (var i = 0; i < args.length; i++) {
|
||
args[i] = arguments[i];
|
||
}
|
||
|
||
return fn.apply(thisArg, args);
|
||
};
|
||
};
|
||
|
||
/***/ }),
|
||
/* 5 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
module.exports = function isCancel(value) {
|
||
return !!(value && value.__CANCEL__);
|
||
};
|
||
|
||
/***/ }),
|
||
/* 6 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var utils = __webpack_require__(0);
|
||
|
||
var normalizeHeaderName = __webpack_require__(23);
|
||
|
||
var DEFAULT_CONTENT_TYPE = {
|
||
'Content-Type': 'application/x-www-form-urlencoded'
|
||
};
|
||
|
||
function setContentTypeIfUnset(headers, value) {
|
||
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
|
||
headers['Content-Type'] = value;
|
||
}
|
||
}
|
||
|
||
function getDefaultAdapter() {
|
||
var adapter;
|
||
|
||
if (typeof XMLHttpRequest !== 'undefined') {
|
||
// For browsers use XHR adapter
|
||
adapter = __webpack_require__(24);
|
||
} else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
|
||
// For node use HTTP adapter
|
||
adapter = __webpack_require__(30);
|
||
}
|
||
|
||
return adapter;
|
||
}
|
||
|
||
var defaults = {
|
||
adapter: getDefaultAdapter(),
|
||
transformRequest: [function transformRequest(data, headers) {
|
||
normalizeHeaderName(headers, 'Accept');
|
||
normalizeHeaderName(headers, 'Content-Type');
|
||
|
||
if (utils.isFormData(data) || utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data)) {
|
||
return data;
|
||
}
|
||
|
||
if (utils.isArrayBufferView(data)) {
|
||
return data.buffer;
|
||
}
|
||
|
||
if (utils.isURLSearchParams(data)) {
|
||
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
|
||
return data.toString();
|
||
}
|
||
|
||
if (utils.isObject(data)) {
|
||
setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
|
||
return JSON.stringify(data);
|
||
}
|
||
|
||
return data;
|
||
}],
|
||
transformResponse: [function transformResponse(data) {
|
||
/*eslint no-param-reassign:0*/
|
||
if (typeof data === 'string') {
|
||
try {
|
||
data = JSON.parse(data);
|
||
} catch (e) {
|
||
/* Ignore */
|
||
}
|
||
}
|
||
|
||
return data;
|
||
}],
|
||
|
||
/**
|
||
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
||
* timeout is not created.
|
||
*/
|
||
timeout: 0,
|
||
xsrfCookieName: 'XSRF-TOKEN',
|
||
xsrfHeaderName: 'X-XSRF-TOKEN',
|
||
maxContentLength: -1,
|
||
maxBodyLength: -1,
|
||
validateStatus: function validateStatus(status) {
|
||
return status >= 200 && status < 300;
|
||
}
|
||
};
|
||
defaults.headers = {
|
||
common: {
|
||
'Accept': 'application/json, text/plain, */*'
|
||
}
|
||
};
|
||
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
||
defaults.headers[method] = {};
|
||
});
|
||
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
||
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
||
});
|
||
module.exports = defaults;
|
||
|
||
/***/ }),
|
||
/* 7 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var createError = __webpack_require__(3);
|
||
/**
|
||
* Resolve or reject a Promise based on response status.
|
||
*
|
||
* @param {Function} resolve A function that resolves the promise.
|
||
* @param {Function} reject A function that rejects the promise.
|
||
* @param {object} response The response.
|
||
*/
|
||
|
||
|
||
module.exports = function settle(resolve, reject, response) {
|
||
var validateStatus = response.config.validateStatus;
|
||
|
||
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
||
resolve(response);
|
||
} else {
|
||
reject(createError('Request failed with status code ' + response.status, response.config, null, response.request, response));
|
||
}
|
||
};
|
||
|
||
/***/ }),
|
||
/* 8 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
/**
|
||
* Update an Error with the specified config, error code, and response.
|
||
*
|
||
* @param {Error} error The error to update.
|
||
* @param {Object} config The config.
|
||
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
||
* @param {Object} [request] The request.
|
||
* @param {Object} [response] The response.
|
||
* @returns {Error} The error.
|
||
*/
|
||
|
||
module.exports = function enhanceError(error, config, code, request, response) {
|
||
error.config = config;
|
||
|
||
if (code) {
|
||
error.code = code;
|
||
}
|
||
|
||
error.request = request;
|
||
error.response = response;
|
||
error.isAxiosError = true;
|
||
|
||
error.toJSON = function toJSON() {
|
||
return {
|
||
// Standard
|
||
message: this.message,
|
||
name: this.name,
|
||
// Microsoft
|
||
description: this.description,
|
||
number: this.number,
|
||
// Mozilla
|
||
fileName: this.fileName,
|
||
lineNumber: this.lineNumber,
|
||
columnNumber: this.columnNumber,
|
||
stack: this.stack,
|
||
// Axios
|
||
config: this.config,
|
||
code: this.code
|
||
};
|
||
};
|
||
|
||
return error;
|
||
};
|
||
|
||
/***/ }),
|
||
/* 9 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var isAbsoluteURL = __webpack_require__(26);
|
||
|
||
var combineURLs = __webpack_require__(27);
|
||
/**
|
||
* Creates a new URL by combining the baseURL with the requestedURL,
|
||
* only when the requestedURL is not already an absolute URL.
|
||
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
||
*
|
||
* @param {string} baseURL The base URL
|
||
* @param {string} requestedURL Absolute or relative URL to combine
|
||
* @returns {string} The combined full path
|
||
*/
|
||
|
||
|
||
module.exports = function buildFullPath(baseURL, requestedURL) {
|
||
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
||
return combineURLs(baseURL, requestedURL);
|
||
}
|
||
|
||
return requestedURL;
|
||
};
|
||
|
||
/***/ }),
|
||
/* 10 */
|
||
/***/ (function(module, exports) {
|
||
|
||
module.exports = require("http");
|
||
|
||
/***/ }),
|
||
/* 11 */
|
||
/***/ (function(module, exports) {
|
||
|
||
module.exports = require("https");
|
||
|
||
/***/ }),
|
||
/* 12 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var url = __webpack_require__(13);
|
||
|
||
var URL = url.URL;
|
||
|
||
var http = __webpack_require__(10);
|
||
|
||
var https = __webpack_require__(11);
|
||
|
||
var Writable = __webpack_require__(31).Writable;
|
||
|
||
var assert = __webpack_require__(32);
|
||
|
||
var debug = __webpack_require__(33); // Create handlers that pass events from native requests
|
||
|
||
|
||
var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
|
||
var eventHandlers = Object.create(null);
|
||
events.forEach(function (event) {
|
||
eventHandlers[event] = function (arg1, arg2, arg3) {
|
||
this._redirectable.emit(event, arg1, arg2, arg3);
|
||
};
|
||
}); // Error types with codes
|
||
|
||
var RedirectionError = createErrorType("ERR_FR_REDIRECTION_FAILURE", "");
|
||
var TooManyRedirectsError = createErrorType("ERR_FR_TOO_MANY_REDIRECTS", "Maximum number of redirects exceeded");
|
||
var MaxBodyLengthExceededError = createErrorType("ERR_FR_MAX_BODY_LENGTH_EXCEEDED", "Request body larger than maxBodyLength limit");
|
||
var WriteAfterEndError = createErrorType("ERR_STREAM_WRITE_AFTER_END", "write after end"); // An HTTP(S) request that can be redirected
|
||
|
||
function RedirectableRequest(options, responseCallback) {
|
||
// Initialize the request
|
||
Writable.call(this);
|
||
|
||
this._sanitizeOptions(options);
|
||
|
||
this._options = options;
|
||
this._ended = false;
|
||
this._ending = false;
|
||
this._redirectCount = 0;
|
||
this._redirects = [];
|
||
this._requestBodyLength = 0;
|
||
this._requestBodyBuffers = []; // Attach a callback if passed
|
||
|
||
if (responseCallback) {
|
||
this.on("response", responseCallback);
|
||
} // React to responses of native requests
|
||
|
||
|
||
var self = this;
|
||
|
||
this._onNativeResponse = function (response) {
|
||
self._processResponse(response);
|
||
}; // Perform the first request
|
||
|
||
|
||
this._performRequest();
|
||
}
|
||
|
||
RedirectableRequest.prototype = Object.create(Writable.prototype);
|
||
|
||
RedirectableRequest.prototype.abort = function () {
|
||
abortRequest(this._currentRequest);
|
||
this.emit("abort");
|
||
}; // Writes buffered data to the current native request
|
||
|
||
|
||
RedirectableRequest.prototype.write = function (data, encoding, callback) {
|
||
// Writing is not allowed if end has been called
|
||
if (this._ending) {
|
||
throw new WriteAfterEndError();
|
||
} // Validate input and shift parameters if necessary
|
||
|
||
|
||
if (!(typeof data === "string" || typeof data === "object" && "length" in data)) {
|
||
throw new TypeError("data should be a string, Buffer or Uint8Array");
|
||
}
|
||
|
||
if (typeof encoding === "function") {
|
||
callback = encoding;
|
||
encoding = null;
|
||
} // Ignore empty buffers, since writing them doesn't invoke the callback
|
||
// https://github.com/nodejs/node/issues/22066
|
||
|
||
|
||
if (data.length === 0) {
|
||
if (callback) {
|
||
callback();
|
||
}
|
||
|
||
return;
|
||
} // Only write when we don't exceed the maximum body length
|
||
|
||
|
||
if (this._requestBodyLength + data.length <= this._options.maxBodyLength) {
|
||
this._requestBodyLength += data.length;
|
||
|
||
this._requestBodyBuffers.push({
|
||
data: data,
|
||
encoding: encoding
|
||
});
|
||
|
||
this._currentRequest.write(data, encoding, callback);
|
||
} // Error when we exceed the maximum body length
|
||
else {
|
||
this.emit("error", new MaxBodyLengthExceededError());
|
||
this.abort();
|
||
}
|
||
}; // Ends the current native request
|
||
|
||
|
||
RedirectableRequest.prototype.end = function (data, encoding, callback) {
|
||
// Shift parameters if necessary
|
||
if (typeof data === "function") {
|
||
callback = data;
|
||
data = encoding = null;
|
||
} else if (typeof encoding === "function") {
|
||
callback = encoding;
|
||
encoding = null;
|
||
} // Write data if needed and end
|
||
|
||
|
||
if (!data) {
|
||
this._ended = this._ending = true;
|
||
|
||
this._currentRequest.end(null, null, callback);
|
||
} else {
|
||
var self = this;
|
||
var currentRequest = this._currentRequest;
|
||
this.write(data, encoding, function () {
|
||
self._ended = true;
|
||
currentRequest.end(null, null, callback);
|
||
});
|
||
this._ending = true;
|
||
}
|
||
}; // Sets a header value on the current native request
|
||
|
||
|
||
RedirectableRequest.prototype.setHeader = function (name, value) {
|
||
this._options.headers[name] = value;
|
||
|
||
this._currentRequest.setHeader(name, value);
|
||
}; // Clears a header value on the current native request
|
||
|
||
|
||
RedirectableRequest.prototype.removeHeader = function (name) {
|
||
delete this._options.headers[name];
|
||
|
||
this._currentRequest.removeHeader(name);
|
||
}; // Global timeout for all underlying requests
|
||
|
||
|
||
RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
|
||
var self = this;
|
||
|
||
if (callback) {
|
||
this.on("timeout", callback);
|
||
}
|
||
|
||
function destroyOnTimeout(socket) {
|
||
socket.setTimeout(msecs);
|
||
socket.removeListener("timeout", socket.destroy);
|
||
socket.addListener("timeout", socket.destroy);
|
||
} // Sets up a timer to trigger a timeout event
|
||
|
||
|
||
function startTimer(socket) {
|
||
if (self._timeout) {
|
||
clearTimeout(self._timeout);
|
||
}
|
||
|
||
self._timeout = setTimeout(function () {
|
||
self.emit("timeout");
|
||
clearTimer();
|
||
}, msecs);
|
||
destroyOnTimeout(socket);
|
||
} // Prevent a timeout from triggering
|
||
|
||
|
||
function clearTimer() {
|
||
clearTimeout(this._timeout);
|
||
|
||
if (callback) {
|
||
self.removeListener("timeout", callback);
|
||
}
|
||
|
||
if (!this.socket) {
|
||
self._currentRequest.removeListener("socket", startTimer);
|
||
}
|
||
} // Start the timer when the socket is opened
|
||
|
||
|
||
if (this.socket) {
|
||
startTimer(this.socket);
|
||
} else {
|
||
this._currentRequest.once("socket", startTimer);
|
||
}
|
||
|
||
this.on("socket", destroyOnTimeout);
|
||
this.once("response", clearTimer);
|
||
this.once("error", clearTimer);
|
||
return this;
|
||
}; // Proxy all other public ClientRequest methods
|
||
|
||
|
||
["flushHeaders", "getHeader", "setNoDelay", "setSocketKeepAlive"].forEach(function (method) {
|
||
RedirectableRequest.prototype[method] = function (a, b) {
|
||
return this._currentRequest[method](a, b);
|
||
};
|
||
}); // Proxy all public ClientRequest properties
|
||
|
||
["aborted", "connection", "socket"].forEach(function (property) {
|
||
Object.defineProperty(RedirectableRequest.prototype, property, {
|
||
get: function () {
|
||
return this._currentRequest[property];
|
||
}
|
||
});
|
||
});
|
||
|
||
RedirectableRequest.prototype._sanitizeOptions = function (options) {
|
||
// Ensure headers are always present
|
||
if (!options.headers) {
|
||
options.headers = {};
|
||
} // Since http.request treats host as an alias of hostname,
|
||
// but the url module interprets host as hostname plus port,
|
||
// eliminate the host property to avoid confusion.
|
||
|
||
|
||
if (options.host) {
|
||
// Use hostname if set, because it has precedence
|
||
if (!options.hostname) {
|
||
options.hostname = options.host;
|
||
}
|
||
|
||
delete options.host;
|
||
} // Complete the URL object when necessary
|
||
|
||
|
||
if (!options.pathname && options.path) {
|
||
var searchPos = options.path.indexOf("?");
|
||
|
||
if (searchPos < 0) {
|
||
options.pathname = options.path;
|
||
} else {
|
||
options.pathname = options.path.substring(0, searchPos);
|
||
options.search = options.path.substring(searchPos);
|
||
}
|
||
}
|
||
}; // Executes the next native request (initial or redirect)
|
||
|
||
|
||
RedirectableRequest.prototype._performRequest = function () {
|
||
// Load the native protocol
|
||
var protocol = this._options.protocol;
|
||
var nativeProtocol = this._options.nativeProtocols[protocol];
|
||
|
||
if (!nativeProtocol) {
|
||
this.emit("error", new TypeError("Unsupported protocol " + protocol));
|
||
return;
|
||
} // If specified, use the agent corresponding to the protocol
|
||
// (HTTP and HTTPS use different types of agents)
|
||
|
||
|
||
if (this._options.agents) {
|
||
var scheme = protocol.substr(0, protocol.length - 1);
|
||
this._options.agent = this._options.agents[scheme];
|
||
} // Create the native request
|
||
|
||
|
||
var request = this._currentRequest = nativeProtocol.request(this._options, this._onNativeResponse);
|
||
this._currentUrl = url.format(this._options); // Set up event handlers
|
||
|
||
request._redirectable = this;
|
||
|
||
for (var e = 0; e < events.length; e++) {
|
||
request.on(events[e], eventHandlers[events[e]]);
|
||
} // End a redirected request
|
||
// (The first request must be ended explicitly with RedirectableRequest#end)
|
||
|
||
|
||
if (this._isRedirect) {
|
||
// Write the request entity and end.
|
||
var i = 0;
|
||
var self = this;
|
||
var buffers = this._requestBodyBuffers;
|
||
|
||
(function writeNext(error) {
|
||
// Only write if this request has not been redirected yet
|
||
|
||
/* istanbul ignore else */
|
||
if (request === self._currentRequest) {
|
||
// Report any write errors
|
||
|
||
/* istanbul ignore if */
|
||
if (error) {
|
||
self.emit("error", error);
|
||
} // Write the next buffer if there are still left
|
||
else if (i < buffers.length) {
|
||
var buffer = buffers[i++];
|
||
/* istanbul ignore else */
|
||
|
||
if (!request.finished) {
|
||
request.write(buffer.data, buffer.encoding, writeNext);
|
||
}
|
||
} // End the request if `end` has been called on us
|
||
else if (self._ended) {
|
||
request.end();
|
||
}
|
||
}
|
||
})();
|
||
}
|
||
}; // Processes a response from the current native request
|
||
|
||
|
||
RedirectableRequest.prototype._processResponse = function (response) {
|
||
// Store the redirected response
|
||
var statusCode = response.statusCode;
|
||
|
||
if (this._options.trackRedirects) {
|
||
this._redirects.push({
|
||
url: this._currentUrl,
|
||
headers: response.headers,
|
||
statusCode: statusCode
|
||
});
|
||
} // RFC7231§6.4: The 3xx (Redirection) class of status code indicates
|
||
// that further action needs to be taken by the user agent in order to
|
||
// fulfill the request. If a Location header field is provided,
|
||
// the user agent MAY automatically redirect its request to the URI
|
||
// referenced by the Location field value,
|
||
// even if the specific status code is not understood.
|
||
|
||
|
||
var location = response.headers.location;
|
||
|
||
if (location && this._options.followRedirects !== false && statusCode >= 300 && statusCode < 400) {
|
||
// Abort the current request
|
||
abortRequest(this._currentRequest); // Discard the remainder of the response to avoid waiting for data
|
||
|
||
response.destroy(); // RFC7231§6.4: A client SHOULD detect and intervene
|
||
// in cyclical redirections (i.e., "infinite" redirection loops).
|
||
|
||
if (++this._redirectCount > this._options.maxRedirects) {
|
||
this.emit("error", new TooManyRedirectsError());
|
||
return;
|
||
} // RFC7231§6.4: Automatic redirection needs to done with
|
||
// care for methods not known to be safe, […]
|
||
// RFC7231§6.4.2–3: For historical reasons, a user agent MAY change
|
||
// the request method from POST to GET for the subsequent request.
|
||
|
||
|
||
if ((statusCode === 301 || statusCode === 302) && this._options.method === "POST" || // RFC7231§6.4.4: The 303 (See Other) status code indicates that
|
||
// the server is redirecting the user agent to a different resource […]
|
||
// A user agent can perform a retrieval request targeting that URI
|
||
// (a GET or HEAD request if using HTTP) […]
|
||
statusCode === 303 && !/^(?:GET|HEAD)$/.test(this._options.method)) {
|
||
this._options.method = "GET"; // Drop a possible entity and headers related to it
|
||
|
||
this._requestBodyBuffers = [];
|
||
removeMatchingHeaders(/^content-/i, this._options.headers);
|
||
} // Drop the Host header, as the redirect might lead to a different host
|
||
|
||
|
||
var previousHostName = removeMatchingHeaders(/^host$/i, this._options.headers) || url.parse(this._currentUrl).hostname; // Create the redirected request
|
||
|
||
var redirectUrl = url.resolve(this._currentUrl, location);
|
||
debug("redirecting to", redirectUrl);
|
||
this._isRedirect = true;
|
||
var redirectUrlParts = url.parse(redirectUrl);
|
||
Object.assign(this._options, redirectUrlParts); // Drop the Authorization header if redirecting to another host
|
||
|
||
if (redirectUrlParts.hostname !== previousHostName) {
|
||
removeMatchingHeaders(/^authorization$/i, this._options.headers);
|
||
} // Evaluate the beforeRedirect callback
|
||
|
||
|
||
if (typeof this._options.beforeRedirect === "function") {
|
||
var responseDetails = {
|
||
headers: response.headers
|
||
};
|
||
|
||
try {
|
||
this._options.beforeRedirect.call(null, this._options, responseDetails);
|
||
} catch (err) {
|
||
this.emit("error", err);
|
||
return;
|
||
}
|
||
|
||
this._sanitizeOptions(this._options);
|
||
} // Perform the redirected request
|
||
|
||
|
||
try {
|
||
this._performRequest();
|
||
} catch (cause) {
|
||
var error = new RedirectionError("Redirected request failed: " + cause.message);
|
||
error.cause = cause;
|
||
this.emit("error", error);
|
||
}
|
||
} else {
|
||
// The response is not a redirect; return it as-is
|
||
response.responseUrl = this._currentUrl;
|
||
response.redirects = this._redirects;
|
||
this.emit("response", response); // Clean up
|
||
|
||
this._requestBodyBuffers = [];
|
||
}
|
||
}; // Wraps the key/value object of protocols with redirect functionality
|
||
|
||
|
||
function wrap(protocols) {
|
||
// Default settings
|
||
var exports = {
|
||
maxRedirects: 21,
|
||
maxBodyLength: 10 * 1024 * 1024
|
||
}; // Wrap each protocol
|
||
|
||
var nativeProtocols = {};
|
||
Object.keys(protocols).forEach(function (scheme) {
|
||
var protocol = scheme + ":";
|
||
var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
|
||
var wrappedProtocol = exports[scheme] = Object.create(nativeProtocol); // Executes a request, following redirects
|
||
|
||
function request(input, options, callback) {
|
||
// Parse parameters
|
||
if (typeof input === "string") {
|
||
var urlStr = input;
|
||
|
||
try {
|
||
input = urlToOptions(new URL(urlStr));
|
||
} catch (err) {
|
||
/* istanbul ignore next */
|
||
input = url.parse(urlStr);
|
||
}
|
||
} else if (URL && input instanceof URL) {
|
||
input = urlToOptions(input);
|
||
} else {
|
||
callback = options;
|
||
options = input;
|
||
input = {
|
||
protocol: protocol
|
||
};
|
||
}
|
||
|
||
if (typeof options === "function") {
|
||
callback = options;
|
||
options = null;
|
||
} // Set defaults
|
||
|
||
|
||
options = Object.assign({
|
||
maxRedirects: exports.maxRedirects,
|
||
maxBodyLength: exports.maxBodyLength
|
||
}, input, options);
|
||
options.nativeProtocols = nativeProtocols;
|
||
assert.equal(options.protocol, protocol, "protocol mismatch");
|
||
debug("options", options);
|
||
return new RedirectableRequest(options, callback);
|
||
} // Executes a GET request, following redirects
|
||
|
||
|
||
function get(input, options, callback) {
|
||
var wrappedRequest = wrappedProtocol.request(input, options, callback);
|
||
wrappedRequest.end();
|
||
return wrappedRequest;
|
||
} // Expose the properties on the wrapped protocol
|
||
|
||
|
||
Object.defineProperties(wrappedProtocol, {
|
||
request: {
|
||
value: request,
|
||
configurable: true,
|
||
enumerable: true,
|
||
writable: true
|
||
},
|
||
get: {
|
||
value: get,
|
||
configurable: true,
|
||
enumerable: true,
|
||
writable: true
|
||
}
|
||
});
|
||
});
|
||
return exports;
|
||
}
|
||
/* istanbul ignore next */
|
||
|
||
|
||
function noop() {
|
||
/* empty */
|
||
} // from https://github.com/nodejs/node/blob/master/lib/internal/url.js
|
||
|
||
|
||
function urlToOptions(urlObject) {
|
||
var options = {
|
||
protocol: urlObject.protocol,
|
||
hostname: urlObject.hostname.startsWith("[") ?
|
||
/* istanbul ignore next */
|
||
urlObject.hostname.slice(1, -1) : urlObject.hostname,
|
||
hash: urlObject.hash,
|
||
search: urlObject.search,
|
||
pathname: urlObject.pathname,
|
||
path: urlObject.pathname + urlObject.search,
|
||
href: urlObject.href
|
||
};
|
||
|
||
if (urlObject.port !== "") {
|
||
options.port = Number(urlObject.port);
|
||
}
|
||
|
||
return options;
|
||
}
|
||
|
||
function removeMatchingHeaders(regex, headers) {
|
||
var lastValue;
|
||
|
||
for (var header in headers) {
|
||
if (regex.test(header)) {
|
||
lastValue = headers[header];
|
||
delete headers[header];
|
||
}
|
||
}
|
||
|
||
return lastValue;
|
||
}
|
||
|
||
function createErrorType(code, defaultMessage) {
|
||
function CustomError(message) {
|
||
Error.captureStackTrace(this, this.constructor);
|
||
this.message = message || defaultMessage;
|
||
}
|
||
|
||
CustomError.prototype = new Error();
|
||
CustomError.prototype.constructor = CustomError;
|
||
CustomError.prototype.name = "Error [" + code + "]";
|
||
CustomError.prototype.code = code;
|
||
return CustomError;
|
||
}
|
||
|
||
function abortRequest(request) {
|
||
for (var e = 0; e < events.length; e++) {
|
||
request.removeListener(events[e], eventHandlers[events[e]]);
|
||
}
|
||
|
||
request.on("error", noop);
|
||
request.abort();
|
||
} // Exports
|
||
|
||
|
||
module.exports = wrap({
|
||
http: http,
|
||
https: https
|
||
});
|
||
module.exports.wrap = wrap;
|
||
|
||
/***/ }),
|
||
/* 13 */
|
||
/***/ (function(module, exports) {
|
||
|
||
module.exports = require("url");
|
||
|
||
/***/ }),
|
||
/* 14 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/**
|
||
* This is the common logic for both the Node.js and web browser
|
||
* implementations of `debug()`.
|
||
*/
|
||
function setup(env) {
|
||
createDebug.debug = createDebug;
|
||
createDebug.default = createDebug;
|
||
createDebug.coerce = coerce;
|
||
createDebug.disable = disable;
|
||
createDebug.enable = enable;
|
||
createDebug.enabled = enabled;
|
||
createDebug.humanize = __webpack_require__(36);
|
||
createDebug.destroy = destroy;
|
||
Object.keys(env).forEach(key => {
|
||
createDebug[key] = env[key];
|
||
});
|
||
/**
|
||
* The currently active debug mode names, and names to skip.
|
||
*/
|
||
|
||
createDebug.names = [];
|
||
createDebug.skips = [];
|
||
/**
|
||
* Map of special "%n" handling functions, for the debug "format" argument.
|
||
*
|
||
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
||
*/
|
||
|
||
createDebug.formatters = {};
|
||
/**
|
||
* Selects a color for a debug namespace
|
||
* @param {String} namespace The namespace string for the for the debug instance to be colored
|
||
* @return {Number|String} An ANSI color code for the given namespace
|
||
* @api private
|
||
*/
|
||
|
||
function selectColor(namespace) {
|
||
let hash = 0;
|
||
|
||
for (let i = 0; i < namespace.length; i++) {
|
||
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
||
hash |= 0; // Convert to 32bit integer
|
||
}
|
||
|
||
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
||
}
|
||
|
||
createDebug.selectColor = selectColor;
|
||
/**
|
||
* Create a debugger with the given `namespace`.
|
||
*
|
||
* @param {String} namespace
|
||
* @return {Function}
|
||
* @api public
|
||
*/
|
||
|
||
function createDebug(namespace) {
|
||
let prevTime;
|
||
let enableOverride = null;
|
||
|
||
function debug(...args) {
|
||
// Disabled?
|
||
if (!debug.enabled) {
|
||
return;
|
||
}
|
||
|
||
const self = debug; // Set `diff` timestamp
|
||
|
||
const curr = Number(new Date());
|
||
const ms = curr - (prevTime || curr);
|
||
self.diff = ms;
|
||
self.prev = prevTime;
|
||
self.curr = curr;
|
||
prevTime = curr;
|
||
args[0] = createDebug.coerce(args[0]);
|
||
|
||
if (typeof args[0] !== 'string') {
|
||
// Anything else let's inspect with %O
|
||
args.unshift('%O');
|
||
} // Apply any `formatters` transformations
|
||
|
||
|
||
let index = 0;
|
||
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
||
// If we encounter an escaped % then don't increase the array index
|
||
if (match === '%%') {
|
||
return '%';
|
||
}
|
||
|
||
index++;
|
||
const formatter = createDebug.formatters[format];
|
||
|
||
if (typeof formatter === 'function') {
|
||
const val = args[index];
|
||
match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
|
||
|
||
args.splice(index, 1);
|
||
index--;
|
||
}
|
||
|
||
return match;
|
||
}); // Apply env-specific formatting (colors, etc.)
|
||
|
||
createDebug.formatArgs.call(self, args);
|
||
const logFn = self.log || createDebug.log;
|
||
logFn.apply(self, args);
|
||
}
|
||
|
||
debug.namespace = namespace;
|
||
debug.useColors = createDebug.useColors();
|
||
debug.color = createDebug.selectColor(namespace);
|
||
debug.extend = extend;
|
||
debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
|
||
|
||
Object.defineProperty(debug, 'enabled', {
|
||
enumerable: true,
|
||
configurable: false,
|
||
get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,
|
||
set: v => {
|
||
enableOverride = v;
|
||
}
|
||
}); // Env-specific initialization logic for debug instances
|
||
|
||
if (typeof createDebug.init === 'function') {
|
||
createDebug.init(debug);
|
||
}
|
||
|
||
return debug;
|
||
}
|
||
|
||
function extend(namespace, delimiter) {
|
||
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
||
newDebug.log = this.log;
|
||
return newDebug;
|
||
}
|
||
/**
|
||
* Enables a debug mode by namespaces. This can include modes
|
||
* separated by a colon and wildcards.
|
||
*
|
||
* @param {String} namespaces
|
||
* @api public
|
||
*/
|
||
|
||
|
||
function enable(namespaces) {
|
||
createDebug.save(namespaces);
|
||
createDebug.names = [];
|
||
createDebug.skips = [];
|
||
let i;
|
||
const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
|
||
const len = split.length;
|
||
|
||
for (i = 0; i < len; i++) {
|
||
if (!split[i]) {
|
||
// ignore empty strings
|
||
continue;
|
||
}
|
||
|
||
namespaces = split[i].replace(/\*/g, '.*?');
|
||
|
||
if (namespaces[0] === '-') {
|
||
createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
||
} else {
|
||
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Disable debug output.
|
||
*
|
||
* @return {String} namespaces
|
||
* @api public
|
||
*/
|
||
|
||
|
||
function disable() {
|
||
const namespaces = [...createDebug.names.map(toNamespace), ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)].join(',');
|
||
createDebug.enable('');
|
||
return namespaces;
|
||
}
|
||
/**
|
||
* Returns true if the given mode name is enabled, false otherwise.
|
||
*
|
||
* @param {String} name
|
||
* @return {Boolean}
|
||
* @api public
|
||
*/
|
||
|
||
|
||
function enabled(name) {
|
||
if (name[name.length - 1] === '*') {
|
||
return true;
|
||
}
|
||
|
||
let i;
|
||
let len;
|
||
|
||
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
||
if (createDebug.skips[i].test(name)) {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
||
if (createDebug.names[i].test(name)) {
|
||
return true;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
/**
|
||
* Convert regexp to namespace
|
||
*
|
||
* @param {RegExp} regxep
|
||
* @return {String} namespace
|
||
* @api private
|
||
*/
|
||
|
||
|
||
function toNamespace(regexp) {
|
||
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*');
|
||
}
|
||
/**
|
||
* Coerce `val`.
|
||
*
|
||
* @param {Mixed} val
|
||
* @return {Mixed}
|
||
* @api private
|
||
*/
|
||
|
||
|
||
function coerce(val) {
|
||
if (val instanceof Error) {
|
||
return val.stack || val.message;
|
||
}
|
||
|
||
return val;
|
||
}
|
||
/**
|
||
* XXX DO NOT USE. This is a temporary stub function.
|
||
* XXX It WILL be removed in the next major release.
|
||
*/
|
||
|
||
|
||
function destroy() {
|
||
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
||
}
|
||
|
||
createDebug.enable(createDebug.load());
|
||
return createDebug;
|
||
}
|
||
|
||
module.exports = setup;
|
||
|
||
/***/ }),
|
||
/* 15 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var utils = __webpack_require__(0);
|
||
/**
|
||
* Config-specific merge-function which creates a new config-object
|
||
* by merging two configuration objects together.
|
||
*
|
||
* @param {Object} config1
|
||
* @param {Object} config2
|
||
* @returns {Object} New object resulting from merging config2 to config1
|
||
*/
|
||
|
||
|
||
module.exports = function mergeConfig(config1, config2) {
|
||
// eslint-disable-next-line no-param-reassign
|
||
config2 = config2 || {};
|
||
var config = {};
|
||
var valueFromConfig2Keys = ['url', 'method', 'data'];
|
||
var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
|
||
var defaultToConfig2Keys = ['baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer', 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName', 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress', 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent', 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'];
|
||
var directMergeKeys = ['validateStatus'];
|
||
|
||
function getMergedValue(target, source) {
|
||
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
||
return utils.merge(target, source);
|
||
} else if (utils.isPlainObject(source)) {
|
||
return utils.merge({}, source);
|
||
} else if (utils.isArray(source)) {
|
||
return source.slice();
|
||
}
|
||
|
||
return source;
|
||
}
|
||
|
||
function mergeDeepProperties(prop) {
|
||
if (!utils.isUndefined(config2[prop])) {
|
||
config[prop] = getMergedValue(config1[prop], config2[prop]);
|
||
} else if (!utils.isUndefined(config1[prop])) {
|
||
config[prop] = getMergedValue(undefined, config1[prop]);
|
||
}
|
||
}
|
||
|
||
utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
|
||
if (!utils.isUndefined(config2[prop])) {
|
||
config[prop] = getMergedValue(undefined, config2[prop]);
|
||
}
|
||
});
|
||
utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
|
||
utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
|
||
if (!utils.isUndefined(config2[prop])) {
|
||
config[prop] = getMergedValue(undefined, config2[prop]);
|
||
} else if (!utils.isUndefined(config1[prop])) {
|
||
config[prop] = getMergedValue(undefined, config1[prop]);
|
||
}
|
||
});
|
||
utils.forEach(directMergeKeys, function merge(prop) {
|
||
if (prop in config2) {
|
||
config[prop] = getMergedValue(config1[prop], config2[prop]);
|
||
} else if (prop in config1) {
|
||
config[prop] = getMergedValue(undefined, config1[prop]);
|
||
}
|
||
});
|
||
var axiosKeys = valueFromConfig2Keys.concat(mergeDeepPropertiesKeys).concat(defaultToConfig2Keys).concat(directMergeKeys);
|
||
var otherKeys = Object.keys(config1).concat(Object.keys(config2)).filter(function filterAxiosKeys(key) {
|
||
return axiosKeys.indexOf(key) === -1;
|
||
});
|
||
utils.forEach(otherKeys, mergeDeepProperties);
|
||
return config;
|
||
};
|
||
|
||
/***/ }),
|
||
/* 16 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
/**
|
||
* A `Cancel` is an object that is thrown when an operation is canceled.
|
||
*
|
||
* @class
|
||
* @param {string=} message The message.
|
||
*/
|
||
|
||
function Cancel(message) {
|
||
this.message = message;
|
||
}
|
||
|
||
Cancel.prototype.toString = function toString() {
|
||
return 'Cancel' + (this.message ? ': ' + this.message : '');
|
||
};
|
||
|
||
Cancel.prototype.__CANCEL__ = true;
|
||
module.exports = Cancel;
|
||
|
||
/***/ }),
|
||
/* 17 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
module.exports = __webpack_require__(18);
|
||
|
||
/***/ }),
|
||
/* 18 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var utils = __webpack_require__(0);
|
||
|
||
var bind = __webpack_require__(4);
|
||
|
||
var Axios = __webpack_require__(19);
|
||
|
||
var mergeConfig = __webpack_require__(15);
|
||
|
||
var defaults = __webpack_require__(6);
|
||
/**
|
||
* Create an instance of Axios
|
||
*
|
||
* @param {Object} defaultConfig The default config for the instance
|
||
* @return {Axios} A new instance of Axios
|
||
*/
|
||
|
||
|
||
function createInstance(defaultConfig) {
|
||
var context = new Axios(defaultConfig);
|
||
var instance = bind(Axios.prototype.request, context); // Copy axios.prototype to instance
|
||
|
||
utils.extend(instance, Axios.prototype, context); // Copy context to instance
|
||
|
||
utils.extend(instance, context);
|
||
return instance;
|
||
} // Create the default instance to be exported
|
||
|
||
|
||
var axios = createInstance(defaults); // Expose Axios class to allow class inheritance
|
||
|
||
axios.Axios = Axios; // Factory for creating new instances
|
||
|
||
axios.create = function create(instanceConfig) {
|
||
return createInstance(mergeConfig(axios.defaults, instanceConfig));
|
||
}; // Expose Cancel & CancelToken
|
||
|
||
|
||
axios.Cancel = __webpack_require__(16);
|
||
axios.CancelToken = __webpack_require__(45);
|
||
axios.isCancel = __webpack_require__(5); // Expose all/spread
|
||
|
||
axios.all = function all(promises) {
|
||
return Promise.all(promises);
|
||
};
|
||
|
||
axios.spread = __webpack_require__(46); // Expose isAxiosError
|
||
|
||
axios.isAxiosError = __webpack_require__(47);
|
||
module.exports = axios; // Allow use of default import syntax in TypeScript
|
||
|
||
module.exports.default = axios;
|
||
|
||
/***/ }),
|
||
/* 19 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var utils = __webpack_require__(0);
|
||
|
||
var buildURL = __webpack_require__(2);
|
||
|
||
var InterceptorManager = __webpack_require__(20);
|
||
|
||
var dispatchRequest = __webpack_require__(21);
|
||
|
||
var mergeConfig = __webpack_require__(15);
|
||
/**
|
||
* Create a new instance of Axios
|
||
*
|
||
* @param {Object} instanceConfig The default config for the instance
|
||
*/
|
||
|
||
|
||
function Axios(instanceConfig) {
|
||
this.defaults = instanceConfig;
|
||
this.interceptors = {
|
||
request: new InterceptorManager(),
|
||
response: new InterceptorManager()
|
||
};
|
||
}
|
||
/**
|
||
* Dispatch a request
|
||
*
|
||
* @param {Object} config The config specific for this request (merged with this.defaults)
|
||
*/
|
||
|
||
|
||
Axios.prototype.request = function request(config) {
|
||
/*eslint no-param-reassign:0*/
|
||
// Allow for axios('example/url'[, config]) a la fetch API
|
||
if (typeof config === 'string') {
|
||
config = arguments[1] || {};
|
||
config.url = arguments[0];
|
||
} else {
|
||
config = config || {};
|
||
}
|
||
|
||
config = mergeConfig(this.defaults, config); // Set config.method
|
||
|
||
if (config.method) {
|
||
config.method = config.method.toLowerCase();
|
||
} else if (this.defaults.method) {
|
||
config.method = this.defaults.method.toLowerCase();
|
||
} else {
|
||
config.method = 'get';
|
||
} // Hook up interceptors middleware
|
||
|
||
|
||
var chain = [dispatchRequest, undefined];
|
||
var promise = Promise.resolve(config);
|
||
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
||
chain.unshift(interceptor.fulfilled, interceptor.rejected);
|
||
});
|
||
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
||
chain.push(interceptor.fulfilled, interceptor.rejected);
|
||
});
|
||
|
||
while (chain.length) {
|
||
promise = promise.then(chain.shift(), chain.shift());
|
||
}
|
||
|
||
return promise;
|
||
};
|
||
|
||
Axios.prototype.getUri = function getUri(config) {
|
||
config = mergeConfig(this.defaults, config);
|
||
return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
|
||
}; // Provide aliases for supported request methods
|
||
|
||
|
||
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
||
/*eslint func-names:0*/
|
||
Axios.prototype[method] = function (url, config) {
|
||
return this.request(mergeConfig(config || {}, {
|
||
method: method,
|
||
url: url,
|
||
data: (config || {}).data
|
||
}));
|
||
};
|
||
});
|
||
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
||
/*eslint func-names:0*/
|
||
Axios.prototype[method] = function (url, data, config) {
|
||
return this.request(mergeConfig(config || {}, {
|
||
method: method,
|
||
url: url,
|
||
data: data
|
||
}));
|
||
};
|
||
});
|
||
module.exports = Axios;
|
||
|
||
/***/ }),
|
||
/* 20 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var utils = __webpack_require__(0);
|
||
|
||
function InterceptorManager() {
|
||
this.handlers = [];
|
||
}
|
||
/**
|
||
* Add a new interceptor to the stack
|
||
*
|
||
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
||
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
||
*
|
||
* @return {Number} An ID used to remove interceptor later
|
||
*/
|
||
|
||
|
||
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
|
||
this.handlers.push({
|
||
fulfilled: fulfilled,
|
||
rejected: rejected
|
||
});
|
||
return this.handlers.length - 1;
|
||
};
|
||
/**
|
||
* Remove an interceptor from the stack
|
||
*
|
||
* @param {Number} id The ID that was returned by `use`
|
||
*/
|
||
|
||
|
||
InterceptorManager.prototype.eject = function eject(id) {
|
||
if (this.handlers[id]) {
|
||
this.handlers[id] = null;
|
||
}
|
||
};
|
||
/**
|
||
* Iterate over all the registered interceptors
|
||
*
|
||
* This method is particularly useful for skipping over any
|
||
* interceptors that may have become `null` calling `eject`.
|
||
*
|
||
* @param {Function} fn The function to call for each interceptor
|
||
*/
|
||
|
||
|
||
InterceptorManager.prototype.forEach = function forEach(fn) {
|
||
utils.forEach(this.handlers, function forEachHandler(h) {
|
||
if (h !== null) {
|
||
fn(h);
|
||
}
|
||
});
|
||
};
|
||
|
||
module.exports = InterceptorManager;
|
||
|
||
/***/ }),
|
||
/* 21 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var utils = __webpack_require__(0);
|
||
|
||
var transformData = __webpack_require__(22);
|
||
|
||
var isCancel = __webpack_require__(5);
|
||
|
||
var defaults = __webpack_require__(6);
|
||
/**
|
||
* Throws a `Cancel` if cancellation has been requested.
|
||
*/
|
||
|
||
|
||
function throwIfCancellationRequested(config) {
|
||
if (config.cancelToken) {
|
||
config.cancelToken.throwIfRequested();
|
||
}
|
||
}
|
||
/**
|
||
* Dispatch a request to the server using the configured adapter.
|
||
*
|
||
* @param {object} config The config that is to be used for the request
|
||
* @returns {Promise} The Promise to be fulfilled
|
||
*/
|
||
|
||
|
||
module.exports = function dispatchRequest(config) {
|
||
throwIfCancellationRequested(config); // Ensure headers exist
|
||
|
||
config.headers = config.headers || {}; // Transform request data
|
||
|
||
config.data = transformData(config.data, config.headers, config.transformRequest); // Flatten headers
|
||
|
||
config.headers = utils.merge(config.headers.common || {}, config.headers[config.method] || {}, config.headers);
|
||
utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], function cleanHeaderConfig(method) {
|
||
delete config.headers[method];
|
||
});
|
||
var adapter = config.adapter || defaults.adapter;
|
||
return adapter(config).then(function onAdapterResolution(response) {
|
||
throwIfCancellationRequested(config); // Transform response data
|
||
|
||
response.data = transformData(response.data, response.headers, config.transformResponse);
|
||
return response;
|
||
}, function onAdapterRejection(reason) {
|
||
if (!isCancel(reason)) {
|
||
throwIfCancellationRequested(config); // Transform response data
|
||
|
||
if (reason && reason.response) {
|
||
reason.response.data = transformData(reason.response.data, reason.response.headers, config.transformResponse);
|
||
}
|
||
}
|
||
|
||
return Promise.reject(reason);
|
||
});
|
||
};
|
||
|
||
/***/ }),
|
||
/* 22 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var utils = __webpack_require__(0);
|
||
/**
|
||
* Transform the data for a request or a response
|
||
*
|
||
* @param {Object|String} data The data to be transformed
|
||
* @param {Array} headers The headers for the request or response
|
||
* @param {Array|Function} fns A single function or Array of functions
|
||
* @returns {*} The resulting transformed data
|
||
*/
|
||
|
||
|
||
module.exports = function transformData(data, headers, fns) {
|
||
/*eslint no-param-reassign:0*/
|
||
utils.forEach(fns, function transform(fn) {
|
||
data = fn(data, headers);
|
||
});
|
||
return data;
|
||
};
|
||
|
||
/***/ }),
|
||
/* 23 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var utils = __webpack_require__(0);
|
||
|
||
module.exports = function normalizeHeaderName(headers, normalizedName) {
|
||
utils.forEach(headers, function processHeader(value, name) {
|
||
if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
|
||
headers[normalizedName] = value;
|
||
delete headers[name];
|
||
}
|
||
});
|
||
};
|
||
|
||
/***/ }),
|
||
/* 24 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var utils = __webpack_require__(0);
|
||
|
||
var settle = __webpack_require__(7);
|
||
|
||
var cookies = __webpack_require__(25);
|
||
|
||
var buildURL = __webpack_require__(2);
|
||
|
||
var buildFullPath = __webpack_require__(9);
|
||
|
||
var parseHeaders = __webpack_require__(28);
|
||
|
||
var isURLSameOrigin = __webpack_require__(29);
|
||
|
||
var createError = __webpack_require__(3);
|
||
|
||
module.exports = function xhrAdapter(config) {
|
||
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
||
var requestData = config.data;
|
||
var requestHeaders = config.headers;
|
||
|
||
if (utils.isFormData(requestData)) {
|
||
delete requestHeaders['Content-Type']; // Let the browser set it
|
||
}
|
||
|
||
var request = new XMLHttpRequest(); // HTTP basic authentication
|
||
|
||
if (config.auth) {
|
||
var username = config.auth.username || '';
|
||
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
|
||
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
|
||
}
|
||
|
||
var fullPath = buildFullPath(config.baseURL, config.url);
|
||
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); // Set the request timeout in MS
|
||
|
||
request.timeout = config.timeout; // Listen for ready state
|
||
|
||
request.onreadystatechange = function handleLoad() {
|
||
if (!request || request.readyState !== 4) {
|
||
return;
|
||
} // The request errored out and we didn't get a response, this will be
|
||
// handled by onerror instead
|
||
// With one exception: request that using file: protocol, most browsers
|
||
// will return status as 0 even though it's a successful request
|
||
|
||
|
||
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
||
return;
|
||
} // Prepare the response
|
||
|
||
|
||
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
|
||
var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
|
||
var response = {
|
||
data: responseData,
|
||
status: request.status,
|
||
statusText: request.statusText,
|
||
headers: responseHeaders,
|
||
config: config,
|
||
request: request
|
||
};
|
||
settle(resolve, reject, response); // Clean up request
|
||
|
||
request = null;
|
||
}; // Handle browser request cancellation (as opposed to a manual cancellation)
|
||
|
||
|
||
request.onabort = function handleAbort() {
|
||
if (!request) {
|
||
return;
|
||
}
|
||
|
||
reject(createError('Request aborted', config, 'ECONNABORTED', request)); // Clean up request
|
||
|
||
request = null;
|
||
}; // Handle low level network errors
|
||
|
||
|
||
request.onerror = function handleError() {
|
||
// Real errors are hidden from us by the browser
|
||
// onerror should only fire if it's a network error
|
||
reject(createError('Network Error', config, null, request)); // Clean up request
|
||
|
||
request = null;
|
||
}; // Handle timeout
|
||
|
||
|
||
request.ontimeout = function handleTimeout() {
|
||
var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
|
||
|
||
if (config.timeoutErrorMessage) {
|
||
timeoutErrorMessage = config.timeoutErrorMessage;
|
||
}
|
||
|
||
reject(createError(timeoutErrorMessage, config, 'ECONNABORTED', request)); // Clean up request
|
||
|
||
request = null;
|
||
}; // Add xsrf header
|
||
// This is only done if running in a standard browser environment.
|
||
// Specifically not if we're in a web worker, or react-native.
|
||
|
||
|
||
if (utils.isStandardBrowserEnv()) {
|
||
// Add xsrf header
|
||
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? cookies.read(config.xsrfCookieName) : undefined;
|
||
|
||
if (xsrfValue) {
|
||
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
||
}
|
||
} // Add headers to the request
|
||
|
||
|
||
if ('setRequestHeader' in request) {
|
||
utils.forEach(requestHeaders, function setRequestHeader(val, key) {
|
||
if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
|
||
// Remove Content-Type if data is undefined
|
||
delete requestHeaders[key];
|
||
} else {
|
||
// Otherwise add header to the request
|
||
request.setRequestHeader(key, val);
|
||
}
|
||
});
|
||
} // Add withCredentials to request if needed
|
||
|
||
|
||
if (!utils.isUndefined(config.withCredentials)) {
|
||
request.withCredentials = !!config.withCredentials;
|
||
} // Add responseType to request if needed
|
||
|
||
|
||
if (config.responseType) {
|
||
try {
|
||
request.responseType = config.responseType;
|
||
} catch (e) {
|
||
// Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
|
||
// But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
|
||
if (config.responseType !== 'json') {
|
||
throw e;
|
||
}
|
||
}
|
||
} // Handle progress if needed
|
||
|
||
|
||
if (typeof config.onDownloadProgress === 'function') {
|
||
request.addEventListener('progress', config.onDownloadProgress);
|
||
} // Not all browsers support upload events
|
||
|
||
|
||
if (typeof config.onUploadProgress === 'function' && request.upload) {
|
||
request.upload.addEventListener('progress', config.onUploadProgress);
|
||
}
|
||
|
||
if (config.cancelToken) {
|
||
// Handle cancellation
|
||
config.cancelToken.promise.then(function onCanceled(cancel) {
|
||
if (!request) {
|
||
return;
|
||
}
|
||
|
||
request.abort();
|
||
reject(cancel); // Clean up request
|
||
|
||
request = null;
|
||
});
|
||
}
|
||
|
||
if (!requestData) {
|
||
requestData = null;
|
||
} // Send the request
|
||
|
||
|
||
request.send(requestData);
|
||
});
|
||
};
|
||
|
||
/***/ }),
|
||
/* 25 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var utils = __webpack_require__(0);
|
||
|
||
module.exports = utils.isStandardBrowserEnv() ? // Standard browser envs support document.cookie
|
||
function standardBrowserEnv() {
|
||
return {
|
||
write: function write(name, value, expires, path, domain, secure) {
|
||
var cookie = [];
|
||
cookie.push(name + '=' + encodeURIComponent(value));
|
||
|
||
if (utils.isNumber(expires)) {
|
||
cookie.push('expires=' + new Date(expires).toGMTString());
|
||
}
|
||
|
||
if (utils.isString(path)) {
|
||
cookie.push('path=' + path);
|
||
}
|
||
|
||
if (utils.isString(domain)) {
|
||
cookie.push('domain=' + domain);
|
||
}
|
||
|
||
if (secure === true) {
|
||
cookie.push('secure');
|
||
}
|
||
|
||
document.cookie = cookie.join('; ');
|
||
},
|
||
read: function read(name) {
|
||
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
||
return match ? decodeURIComponent(match[3]) : null;
|
||
},
|
||
remove: function remove(name) {
|
||
this.write(name, '', Date.now() - 86400000);
|
||
}
|
||
};
|
||
}() : // Non standard browser env (web workers, react-native) lack needed support.
|
||
function nonStandardBrowserEnv() {
|
||
return {
|
||
write: function write() {},
|
||
read: function read() {
|
||
return null;
|
||
},
|
||
remove: function remove() {}
|
||
};
|
||
}();
|
||
|
||
/***/ }),
|
||
/* 26 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
/**
|
||
* Determines whether the specified URL is absolute
|
||
*
|
||
* @param {string} url The URL to test
|
||
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
||
*/
|
||
|
||
module.exports = function isAbsoluteURL(url) {
|
||
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
||
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
||
// by any combination of letters, digits, plus, period, or hyphen.
|
||
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
||
};
|
||
|
||
/***/ }),
|
||
/* 27 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
/**
|
||
* Creates a new URL by combining the specified URLs
|
||
*
|
||
* @param {string} baseURL The base URL
|
||
* @param {string} relativeURL The relative URL
|
||
* @returns {string} The combined URL
|
||
*/
|
||
|
||
module.exports = function combineURLs(baseURL, relativeURL) {
|
||
return relativeURL ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
|
||
};
|
||
|
||
/***/ }),
|
||
/* 28 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var utils = __webpack_require__(0); // Headers whose duplicates are ignored by node
|
||
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
||
|
||
|
||
var ignoreDuplicateOf = ['age', 'authorization', 'content-length', 'content-type', 'etag', 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 'referer', 'retry-after', 'user-agent'];
|
||
/**
|
||
* Parse headers into an object
|
||
*
|
||
* ```
|
||
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
||
* Content-Type: application/json
|
||
* Connection: keep-alive
|
||
* Transfer-Encoding: chunked
|
||
* ```
|
||
*
|
||
* @param {String} headers Headers needing to be parsed
|
||
* @returns {Object} Headers parsed into an object
|
||
*/
|
||
|
||
module.exports = function parseHeaders(headers) {
|
||
var parsed = {};
|
||
var key;
|
||
var val;
|
||
var i;
|
||
|
||
if (!headers) {
|
||
return parsed;
|
||
}
|
||
|
||
utils.forEach(headers.split('\n'), function parser(line) {
|
||
i = line.indexOf(':');
|
||
key = utils.trim(line.substr(0, i)).toLowerCase();
|
||
val = utils.trim(line.substr(i + 1));
|
||
|
||
if (key) {
|
||
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
|
||
return;
|
||
}
|
||
|
||
if (key === 'set-cookie') {
|
||
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
|
||
} else {
|
||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
||
}
|
||
}
|
||
});
|
||
return parsed;
|
||
};
|
||
|
||
/***/ }),
|
||
/* 29 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var utils = __webpack_require__(0);
|
||
|
||
module.exports = utils.isStandardBrowserEnv() ? // Standard browser envs have full support of the APIs needed to test
|
||
// whether the request URL is of the same origin as current location.
|
||
function standardBrowserEnv() {
|
||
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
||
var urlParsingNode = document.createElement('a');
|
||
var originURL;
|
||
/**
|
||
* Parse a URL to discover it's components
|
||
*
|
||
* @param {String} url The URL to be parsed
|
||
* @returns {Object}
|
||
*/
|
||
|
||
function resolveURL(url) {
|
||
var href = url;
|
||
|
||
if (msie) {
|
||
// IE needs attribute set twice to normalize properties
|
||
urlParsingNode.setAttribute('href', href);
|
||
href = urlParsingNode.href;
|
||
}
|
||
|
||
urlParsingNode.setAttribute('href', href); // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
||
|
||
return {
|
||
href: urlParsingNode.href,
|
||
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
||
host: urlParsingNode.host,
|
||
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
||
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
||
hostname: urlParsingNode.hostname,
|
||
port: urlParsingNode.port,
|
||
pathname: urlParsingNode.pathname.charAt(0) === '/' ? urlParsingNode.pathname : '/' + urlParsingNode.pathname
|
||
};
|
||
}
|
||
|
||
originURL = resolveURL(window.location.href);
|
||
/**
|
||
* Determine if a URL shares the same origin as the current location
|
||
*
|
||
* @param {String} requestURL The URL to test
|
||
* @returns {boolean} True if URL shares the same origin, otherwise false
|
||
*/
|
||
|
||
return function isURLSameOrigin(requestURL) {
|
||
var parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
||
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
||
};
|
||
}() : // Non standard browser envs (web workers, react-native) lack needed support.
|
||
function nonStandardBrowserEnv() {
|
||
return function isURLSameOrigin() {
|
||
return true;
|
||
};
|
||
}();
|
||
|
||
/***/ }),
|
||
/* 30 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var utils = __webpack_require__(0);
|
||
|
||
var settle = __webpack_require__(7);
|
||
|
||
var buildFullPath = __webpack_require__(9);
|
||
|
||
var buildURL = __webpack_require__(2);
|
||
|
||
var http = __webpack_require__(10);
|
||
|
||
var https = __webpack_require__(11);
|
||
|
||
var httpFollow = __webpack_require__(12).http;
|
||
|
||
var httpsFollow = __webpack_require__(12).https;
|
||
|
||
var url = __webpack_require__(13);
|
||
|
||
var zlib = __webpack_require__(43);
|
||
|
||
var pkg = __webpack_require__(44);
|
||
|
||
var createError = __webpack_require__(3);
|
||
|
||
var enhanceError = __webpack_require__(8);
|
||
|
||
var isHttps = /https:?/;
|
||
/**
|
||
*
|
||
* @param {http.ClientRequestArgs} options
|
||
* @param {AxiosProxyConfig} proxy
|
||
* @param {string} location
|
||
*/
|
||
|
||
function setProxy(options, proxy, location) {
|
||
options.hostname = proxy.host;
|
||
options.host = proxy.host;
|
||
options.port = proxy.port;
|
||
options.path = location; // Basic proxy authorization
|
||
|
||
if (proxy.auth) {
|
||
var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
|
||
options.headers['Proxy-Authorization'] = 'Basic ' + base64;
|
||
} // If a proxy is used, any redirects must also pass through the proxy
|
||
|
||
|
||
options.beforeRedirect = function beforeRedirect(redirection) {
|
||
redirection.headers.host = redirection.host;
|
||
setProxy(redirection, proxy, redirection.href);
|
||
};
|
||
}
|
||
/*eslint consistent-return:0*/
|
||
|
||
|
||
module.exports = function httpAdapter(config) {
|
||
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
|
||
var resolve = function resolve(value) {
|
||
resolvePromise(value);
|
||
};
|
||
|
||
var reject = function reject(value) {
|
||
rejectPromise(value);
|
||
};
|
||
|
||
var data = config.data;
|
||
var headers = config.headers; // Set User-Agent (required by some servers)
|
||
// Only set header if it hasn't been set in config
|
||
// See https://github.com/axios/axios/issues/69
|
||
|
||
if (!headers['User-Agent'] && !headers['user-agent']) {
|
||
headers['User-Agent'] = 'axios/' + pkg.version;
|
||
}
|
||
|
||
if (data && !utils.isStream(data)) {
|
||
if (Buffer.isBuffer(data)) {// Nothing to do...
|
||
} else if (utils.isArrayBuffer(data)) {
|
||
data = Buffer.from(new Uint8Array(data));
|
||
} else if (utils.isString(data)) {
|
||
data = Buffer.from(data, 'utf-8');
|
||
} else {
|
||
return reject(createError('Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream', config));
|
||
} // Add Content-Length header if data exists
|
||
|
||
|
||
headers['Content-Length'] = data.length;
|
||
} // HTTP basic authentication
|
||
|
||
|
||
var auth = undefined;
|
||
|
||
if (config.auth) {
|
||
var username = config.auth.username || '';
|
||
var password = config.auth.password || '';
|
||
auth = username + ':' + password;
|
||
} // Parse url
|
||
|
||
|
||
var fullPath = buildFullPath(config.baseURL, config.url);
|
||
var parsed = url.parse(fullPath);
|
||
var protocol = parsed.protocol || 'http:';
|
||
|
||
if (!auth && parsed.auth) {
|
||
var urlAuth = parsed.auth.split(':');
|
||
var urlUsername = urlAuth[0] || '';
|
||
var urlPassword = urlAuth[1] || '';
|
||
auth = urlUsername + ':' + urlPassword;
|
||
}
|
||
|
||
if (auth) {
|
||
delete headers.Authorization;
|
||
}
|
||
|
||
var isHttpsRequest = isHttps.test(protocol);
|
||
var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
||
var options = {
|
||
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
|
||
method: config.method.toUpperCase(),
|
||
headers: headers,
|
||
agent: agent,
|
||
agents: {
|
||
http: config.httpAgent,
|
||
https: config.httpsAgent
|
||
},
|
||
auth: auth
|
||
};
|
||
|
||
if (config.socketPath) {
|
||
options.socketPath = config.socketPath;
|
||
} else {
|
||
options.hostname = parsed.hostname;
|
||
options.port = parsed.port;
|
||
}
|
||
|
||
var proxy = config.proxy;
|
||
|
||
if (!proxy && proxy !== false) {
|
||
var proxyEnv = protocol.slice(0, -1) + '_proxy';
|
||
var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
|
||
|
||
if (proxyUrl) {
|
||
var parsedProxyUrl = url.parse(proxyUrl);
|
||
var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
|
||
var shouldProxy = true;
|
||
|
||
if (noProxyEnv) {
|
||
var noProxy = noProxyEnv.split(',').map(function trim(s) {
|
||
return s.trim();
|
||
});
|
||
shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
|
||
if (!proxyElement) {
|
||
return false;
|
||
}
|
||
|
||
if (proxyElement === '*') {
|
||
return true;
|
||
}
|
||
|
||
if (proxyElement[0] === '.' && parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) {
|
||
return true;
|
||
}
|
||
|
||
return parsed.hostname === proxyElement;
|
||
});
|
||
}
|
||
|
||
if (shouldProxy) {
|
||
proxy = {
|
||
host: parsedProxyUrl.hostname,
|
||
port: parsedProxyUrl.port,
|
||
protocol: parsedProxyUrl.protocol
|
||
};
|
||
|
||
if (parsedProxyUrl.auth) {
|
||
var proxyUrlAuth = parsedProxyUrl.auth.split(':');
|
||
proxy.auth = {
|
||
username: proxyUrlAuth[0],
|
||
password: proxyUrlAuth[1]
|
||
};
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (proxy) {
|
||
options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
|
||
setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
|
||
}
|
||
|
||
var transport;
|
||
var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
|
||
|
||
if (config.transport) {
|
||
transport = config.transport;
|
||
} else if (config.maxRedirects === 0) {
|
||
transport = isHttpsProxy ? https : http;
|
||
} else {
|
||
if (config.maxRedirects) {
|
||
options.maxRedirects = config.maxRedirects;
|
||
}
|
||
|
||
transport = isHttpsProxy ? httpsFollow : httpFollow;
|
||
}
|
||
|
||
if (config.maxBodyLength > -1) {
|
||
options.maxBodyLength = config.maxBodyLength;
|
||
} // Create the request
|
||
|
||
|
||
var req = transport.request(options, function handleResponse(res) {
|
||
if (req.aborted) return; // uncompress the response body transparently if required
|
||
|
||
var stream = res; // return the last request in case of redirects
|
||
|
||
var lastRequest = res.req || req; // if no content, is HEAD request or decompress disabled we should not decompress
|
||
|
||
if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {
|
||
switch (res.headers['content-encoding']) {
|
||
/*eslint default-case:0*/
|
||
case 'gzip':
|
||
case 'compress':
|
||
case 'deflate':
|
||
// add the unzipper to the body stream processing pipeline
|
||
stream = stream.pipe(zlib.createUnzip()); // remove the content-encoding in order to not confuse downstream operations
|
||
|
||
delete res.headers['content-encoding'];
|
||
break;
|
||
}
|
||
}
|
||
|
||
var response = {
|
||
status: res.statusCode,
|
||
statusText: res.statusMessage,
|
||
headers: res.headers,
|
||
config: config,
|
||
request: lastRequest
|
||
};
|
||
|
||
if (config.responseType === 'stream') {
|
||
response.data = stream;
|
||
settle(resolve, reject, response);
|
||
} else {
|
||
var responseBuffer = [];
|
||
stream.on('data', function handleStreamData(chunk) {
|
||
responseBuffer.push(chunk); // make sure the content length is not over the maxContentLength if specified
|
||
|
||
if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) {
|
||
stream.destroy();
|
||
reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded', config, null, lastRequest));
|
||
}
|
||
});
|
||
stream.on('error', function handleStreamError(err) {
|
||
if (req.aborted) return;
|
||
reject(enhanceError(err, config, null, lastRequest));
|
||
});
|
||
stream.on('end', function handleStreamEnd() {
|
||
var responseData = Buffer.concat(responseBuffer);
|
||
|
||
if (config.responseType !== 'arraybuffer') {
|
||
responseData = responseData.toString(config.responseEncoding);
|
||
|
||
if (!config.responseEncoding || config.responseEncoding === 'utf8') {
|
||
responseData = utils.stripBOM(responseData);
|
||
}
|
||
}
|
||
|
||
response.data = responseData;
|
||
settle(resolve, reject, response);
|
||
});
|
||
}
|
||
}); // Handle errors
|
||
|
||
req.on('error', function handleRequestError(err) {
|
||
if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return;
|
||
reject(enhanceError(err, config, null, req));
|
||
}); // Handle request timeout
|
||
|
||
if (config.timeout) {
|
||
// Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
|
||
// And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
|
||
// At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
|
||
// And then these socket which be hang up will devoring CPU little by little.
|
||
// ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
|
||
req.setTimeout(config.timeout, function handleRequestTimeout() {
|
||
req.abort();
|
||
reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req));
|
||
});
|
||
}
|
||
|
||
if (config.cancelToken) {
|
||
// Handle cancellation
|
||
config.cancelToken.promise.then(function onCanceled(cancel) {
|
||
if (req.aborted) return;
|
||
req.abort();
|
||
reject(cancel);
|
||
});
|
||
} // Send the request
|
||
|
||
|
||
if (utils.isStream(data)) {
|
||
data.on('error', function handleStreamError(err) {
|
||
reject(enhanceError(err, config, null, req));
|
||
}).pipe(req);
|
||
} else {
|
||
req.end(data);
|
||
}
|
||
});
|
||
};
|
||
|
||
/***/ }),
|
||
/* 31 */
|
||
/***/ (function(module, exports) {
|
||
|
||
module.exports = require("stream");
|
||
|
||
/***/ }),
|
||
/* 32 */
|
||
/***/ (function(module, exports) {
|
||
|
||
module.exports = require("assert");
|
||
|
||
/***/ }),
|
||
/* 33 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
var debug;
|
||
|
||
module.exports = function () {
|
||
if (!debug) {
|
||
try {
|
||
/* eslint global-require: off */
|
||
debug = __webpack_require__(34)("follow-redirects");
|
||
} catch (error) {
|
||
debug = function () {
|
||
/* */
|
||
};
|
||
}
|
||
}
|
||
|
||
debug.apply(null, arguments);
|
||
};
|
||
|
||
/***/ }),
|
||
/* 34 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/**
|
||
* Detect Electron renderer / nwjs process, which is node, but we should
|
||
* treat as a browser.
|
||
*/
|
||
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
||
module.exports = __webpack_require__(35);
|
||
} else {
|
||
module.exports = __webpack_require__(37);
|
||
}
|
||
|
||
/***/ }),
|
||
/* 35 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/* eslint-env browser */
|
||
|
||
/**
|
||
* This is the web browser implementation of `debug()`.
|
||
*/
|
||
exports.formatArgs = formatArgs;
|
||
exports.save = save;
|
||
exports.load = load;
|
||
exports.useColors = useColors;
|
||
exports.storage = localstorage();
|
||
|
||
exports.destroy = (() => {
|
||
let warned = false;
|
||
return () => {
|
||
if (!warned) {
|
||
warned = true;
|
||
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
||
}
|
||
};
|
||
})();
|
||
/**
|
||
* Colors.
|
||
*/
|
||
|
||
|
||
exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
|
||
/**
|
||
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
||
* and the Firebug extension (any Firefox version) are known
|
||
* to support "%c" CSS customizations.
|
||
*
|
||
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
||
*/
|
||
// eslint-disable-next-line complexity
|
||
|
||
function useColors() {
|
||
// NB: In an Electron preload script, document will be defined but not fully
|
||
// initialized. Since we know we're in Chrome, we'll just detect this case
|
||
// explicitly
|
||
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
||
return true;
|
||
} // Internet Explorer and Edge do not support colors.
|
||
|
||
|
||
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
||
return false;
|
||
} // Is webkit? http://stackoverflow.com/a/16459606/376773
|
||
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
||
|
||
|
||
return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
|
||
typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
|
||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
|
||
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
||
}
|
||
/**
|
||
* Colorize log arguments if enabled.
|
||
*
|
||
* @api public
|
||
*/
|
||
|
||
|
||
function formatArgs(args) {
|
||
args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
|
||
|
||
if (!this.useColors) {
|
||
return;
|
||
}
|
||
|
||
const c = 'color: ' + this.color;
|
||
args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
|
||
// arguments passed either before or after the %c, so we need to
|
||
// figure out the correct index to insert the CSS into
|
||
|
||
let index = 0;
|
||
let lastC = 0;
|
||
args[0].replace(/%[a-zA-Z%]/g, match => {
|
||
if (match === '%%') {
|
||
return;
|
||
}
|
||
|
||
index++;
|
||
|
||
if (match === '%c') {
|
||
// We only are interested in the *last* %c
|
||
// (the user may have provided their own)
|
||
lastC = index;
|
||
}
|
||
});
|
||
args.splice(lastC, 0, c);
|
||
}
|
||
/**
|
||
* Invokes `console.debug()` when available.
|
||
* No-op when `console.debug` is not a "function".
|
||
* If `console.debug` is not available, falls back
|
||
* to `console.log`.
|
||
*
|
||
* @api public
|
||
*/
|
||
|
||
|
||
exports.log = console.debug || console.log || (() => {});
|
||
/**
|
||
* Save `namespaces`.
|
||
*
|
||
* @param {String} namespaces
|
||
* @api private
|
||
*/
|
||
|
||
|
||
function save(namespaces) {
|
||
try {
|
||
if (namespaces) {
|
||
exports.storage.setItem('debug', namespaces);
|
||
} else {
|
||
exports.storage.removeItem('debug');
|
||
}
|
||
} catch (error) {// Swallow
|
||
// XXX (@Qix-) should we be logging these?
|
||
}
|
||
}
|
||
/**
|
||
* Load `namespaces`.
|
||
*
|
||
* @return {String} returns the previously persisted debug modes
|
||
* @api private
|
||
*/
|
||
|
||
|
||
function load() {
|
||
let r;
|
||
|
||
try {
|
||
r = exports.storage.getItem('debug');
|
||
} catch (error) {// Swallow
|
||
// XXX (@Qix-) should we be logging these?
|
||
} // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
||
|
||
|
||
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
||
r = process.env.DEBUG;
|
||
}
|
||
|
||
return r;
|
||
}
|
||
/**
|
||
* Localstorage attempts to return the localstorage.
|
||
*
|
||
* This is necessary because safari throws
|
||
* when a user disables cookies/localstorage
|
||
* and you attempt to access it.
|
||
*
|
||
* @return {LocalStorage}
|
||
* @api private
|
||
*/
|
||
|
||
|
||
function localstorage() {
|
||
try {
|
||
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
||
// The Browser also has localStorage in the global context.
|
||
return localStorage;
|
||
} catch (error) {// Swallow
|
||
// XXX (@Qix-) should we be logging these?
|
||
}
|
||
}
|
||
|
||
module.exports = __webpack_require__(14)(exports);
|
||
const {
|
||
formatters
|
||
} = module.exports;
|
||
/**
|
||
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
||
*/
|
||
|
||
formatters.j = function (v) {
|
||
try {
|
||
return JSON.stringify(v);
|
||
} catch (error) {
|
||
return '[UnexpectedJSONParseError]: ' + error.message;
|
||
}
|
||
};
|
||
|
||
/***/ }),
|
||
/* 36 */
|
||
/***/ (function(module, exports) {
|
||
|
||
/**
|
||
* Helpers.
|
||
*/
|
||
var s = 1000;
|
||
var m = s * 60;
|
||
var h = m * 60;
|
||
var d = h * 24;
|
||
var w = d * 7;
|
||
var y = d * 365.25;
|
||
/**
|
||
* Parse or format the given `val`.
|
||
*
|
||
* Options:
|
||
*
|
||
* - `long` verbose formatting [false]
|
||
*
|
||
* @param {String|Number} val
|
||
* @param {Object} [options]
|
||
* @throws {Error} throw an error if val is not a non-empty string or a number
|
||
* @return {String|Number}
|
||
* @api public
|
||
*/
|
||
|
||
module.exports = function (val, options) {
|
||
options = options || {};
|
||
var type = typeof val;
|
||
|
||
if (type === 'string' && val.length > 0) {
|
||
return parse(val);
|
||
} else if (type === 'number' && isFinite(val)) {
|
||
return options.long ? fmtLong(val) : fmtShort(val);
|
||
}
|
||
|
||
throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
|
||
};
|
||
/**
|
||
* Parse the given `str` and return milliseconds.
|
||
*
|
||
* @param {String} str
|
||
* @return {Number}
|
||
* @api private
|
||
*/
|
||
|
||
|
||
function parse(str) {
|
||
str = String(str);
|
||
|
||
if (str.length > 100) {
|
||
return;
|
||
}
|
||
|
||
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
||
|
||
if (!match) {
|
||
return;
|
||
}
|
||
|
||
var n = parseFloat(match[1]);
|
||
var type = (match[2] || 'ms').toLowerCase();
|
||
|
||
switch (type) {
|
||
case 'years':
|
||
case 'year':
|
||
case 'yrs':
|
||
case 'yr':
|
||
case 'y':
|
||
return n * y;
|
||
|
||
case 'weeks':
|
||
case 'week':
|
||
case 'w':
|
||
return n * w;
|
||
|
||
case 'days':
|
||
case 'day':
|
||
case 'd':
|
||
return n * d;
|
||
|
||
case 'hours':
|
||
case 'hour':
|
||
case 'hrs':
|
||
case 'hr':
|
||
case 'h':
|
||
return n * h;
|
||
|
||
case 'minutes':
|
||
case 'minute':
|
||
case 'mins':
|
||
case 'min':
|
||
case 'm':
|
||
return n * m;
|
||
|
||
case 'seconds':
|
||
case 'second':
|
||
case 'secs':
|
||
case 'sec':
|
||
case 's':
|
||
return n * s;
|
||
|
||
case 'milliseconds':
|
||
case 'millisecond':
|
||
case 'msecs':
|
||
case 'msec':
|
||
case 'ms':
|
||
return n;
|
||
|
||
default:
|
||
return undefined;
|
||
}
|
||
}
|
||
/**
|
||
* Short format for `ms`.
|
||
*
|
||
* @param {Number} ms
|
||
* @return {String}
|
||
* @api private
|
||
*/
|
||
|
||
|
||
function fmtShort(ms) {
|
||
var msAbs = Math.abs(ms);
|
||
|
||
if (msAbs >= d) {
|
||
return Math.round(ms / d) + 'd';
|
||
}
|
||
|
||
if (msAbs >= h) {
|
||
return Math.round(ms / h) + 'h';
|
||
}
|
||
|
||
if (msAbs >= m) {
|
||
return Math.round(ms / m) + 'm';
|
||
}
|
||
|
||
if (msAbs >= s) {
|
||
return Math.round(ms / s) + 's';
|
||
}
|
||
|
||
return ms + 'ms';
|
||
}
|
||
/**
|
||
* Long format for `ms`.
|
||
*
|
||
* @param {Number} ms
|
||
* @return {String}
|
||
* @api private
|
||
*/
|
||
|
||
|
||
function fmtLong(ms) {
|
||
var msAbs = Math.abs(ms);
|
||
|
||
if (msAbs >= d) {
|
||
return plural(ms, msAbs, d, 'day');
|
||
}
|
||
|
||
if (msAbs >= h) {
|
||
return plural(ms, msAbs, h, 'hour');
|
||
}
|
||
|
||
if (msAbs >= m) {
|
||
return plural(ms, msAbs, m, 'minute');
|
||
}
|
||
|
||
if (msAbs >= s) {
|
||
return plural(ms, msAbs, s, 'second');
|
||
}
|
||
|
||
return ms + ' ms';
|
||
}
|
||
/**
|
||
* Pluralization helper.
|
||
*/
|
||
|
||
|
||
function plural(ms, msAbs, n, name) {
|
||
var isPlural = msAbs >= n * 1.5;
|
||
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
||
}
|
||
|
||
/***/ }),
|
||
/* 37 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
/**
|
||
* Module dependencies.
|
||
*/
|
||
const tty = __webpack_require__(38);
|
||
|
||
const util = __webpack_require__(39);
|
||
/**
|
||
* This is the Node.js implementation of `debug()`.
|
||
*/
|
||
|
||
|
||
exports.init = init;
|
||
exports.log = log;
|
||
exports.formatArgs = formatArgs;
|
||
exports.save = save;
|
||
exports.load = load;
|
||
exports.useColors = useColors;
|
||
exports.destroy = util.deprecate(() => {}, 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
||
/**
|
||
* Colors.
|
||
*/
|
||
|
||
exports.colors = [6, 2, 3, 4, 5, 1];
|
||
|
||
try {
|
||
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||
const supportsColor = __webpack_require__(40);
|
||
|
||
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
||
exports.colors = [20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221];
|
||
}
|
||
} catch (error) {// Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
||
}
|
||
/**
|
||
* Build up the default `inspectOpts` object from the environment variables.
|
||
*
|
||
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
||
*/
|
||
|
||
|
||
exports.inspectOpts = Object.keys(process.env).filter(key => {
|
||
return /^debug_/i.test(key);
|
||
}).reduce((obj, key) => {
|
||
// Camel-case
|
||
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
|
||
return k.toUpperCase();
|
||
}); // Coerce string value into JS value
|
||
|
||
let val = process.env[key];
|
||
|
||
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
||
val = true;
|
||
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
||
val = false;
|
||
} else if (val === 'null') {
|
||
val = null;
|
||
} else {
|
||
val = Number(val);
|
||
}
|
||
|
||
obj[prop] = val;
|
||
return obj;
|
||
}, {});
|
||
/**
|
||
* Is stdout a TTY? Colored output is enabled when `true`.
|
||
*/
|
||
|
||
function useColors() {
|
||
return 'colors' in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
||
}
|
||
/**
|
||
* Adds ANSI color escape codes if enabled.
|
||
*
|
||
* @api public
|
||
*/
|
||
|
||
|
||
function formatArgs(args) {
|
||
const {
|
||
namespace: name,
|
||
useColors
|
||
} = this;
|
||
|
||
if (useColors) {
|
||
const c = this.color;
|
||
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
|
||
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
||
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
||
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
||
} else {
|
||
args[0] = getDate() + name + ' ' + args[0];
|
||
}
|
||
}
|
||
|
||
function getDate() {
|
||
if (exports.inspectOpts.hideDate) {
|
||
return '';
|
||
}
|
||
|
||
return new Date().toISOString() + ' ';
|
||
}
|
||
/**
|
||
* Invokes `util.format()` with the specified arguments and writes to stderr.
|
||
*/
|
||
|
||
|
||
function log(...args) {
|
||
return process.stderr.write(util.format(...args) + '\n');
|
||
}
|
||
/**
|
||
* Save `namespaces`.
|
||
*
|
||
* @param {String} namespaces
|
||
* @api private
|
||
*/
|
||
|
||
|
||
function save(namespaces) {
|
||
if (namespaces) {
|
||
process.env.DEBUG = namespaces;
|
||
} else {
|
||
// If you set a process.env field to null or undefined, it gets cast to the
|
||
// string 'null' or 'undefined'. Just delete instead.
|
||
delete process.env.DEBUG;
|
||
}
|
||
}
|
||
/**
|
||
* Load `namespaces`.
|
||
*
|
||
* @return {String} returns the previously persisted debug modes
|
||
* @api private
|
||
*/
|
||
|
||
|
||
function load() {
|
||
return process.env.DEBUG;
|
||
}
|
||
/**
|
||
* Init logic for `debug` instances.
|
||
*
|
||
* Create a new `inspectOpts` object in case `useColors` is set
|
||
* differently for a particular `debug` instance.
|
||
*/
|
||
|
||
|
||
function init(debug) {
|
||
debug.inspectOpts = {};
|
||
const keys = Object.keys(exports.inspectOpts);
|
||
|
||
for (let i = 0; i < keys.length; i++) {
|
||
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
||
}
|
||
}
|
||
|
||
module.exports = __webpack_require__(14)(exports);
|
||
const {
|
||
formatters
|
||
} = module.exports;
|
||
/**
|
||
* Map %o to `util.inspect()`, all on a single line.
|
||
*/
|
||
|
||
formatters.o = function (v) {
|
||
this.inspectOpts.colors = this.useColors;
|
||
return util.inspect(v, this.inspectOpts).split('\n').map(str => str.trim()).join(' ');
|
||
};
|
||
/**
|
||
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
||
*/
|
||
|
||
|
||
formatters.O = function (v) {
|
||
this.inspectOpts.colors = this.useColors;
|
||
return util.inspect(v, this.inspectOpts);
|
||
};
|
||
|
||
/***/ }),
|
||
/* 38 */
|
||
/***/ (function(module, exports) {
|
||
|
||
module.exports = require("tty");
|
||
|
||
/***/ }),
|
||
/* 39 */
|
||
/***/ (function(module, exports) {
|
||
|
||
module.exports = require("util");
|
||
|
||
/***/ }),
|
||
/* 40 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
const os = __webpack_require__(41);
|
||
|
||
const hasFlag = __webpack_require__(42);
|
||
|
||
const env = process.env;
|
||
let forceColor;
|
||
|
||
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
|
||
forceColor = false;
|
||
} else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
|
||
forceColor = true;
|
||
}
|
||
|
||
if ('FORCE_COLOR' in env) {
|
||
forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
|
||
}
|
||
|
||
function translateLevel(level) {
|
||
if (level === 0) {
|
||
return false;
|
||
}
|
||
|
||
return {
|
||
level,
|
||
hasBasic: true,
|
||
has256: level >= 2,
|
||
has16m: level >= 3
|
||
};
|
||
}
|
||
|
||
function supportsColor(stream) {
|
||
if (forceColor === false) {
|
||
return 0;
|
||
}
|
||
|
||
if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
|
||
return 3;
|
||
}
|
||
|
||
if (hasFlag('color=256')) {
|
||
return 2;
|
||
}
|
||
|
||
if (stream && !stream.isTTY && forceColor !== true) {
|
||
return 0;
|
||
}
|
||
|
||
const min = forceColor ? 1 : 0;
|
||
|
||
if (process.platform === 'win32') {
|
||
// Node.js 7.5.0 is the first version of Node.js to include a patch to
|
||
// libuv that enables 256 color output on Windows. Anything earlier and it
|
||
// won't work. However, here we target Node.js 8 at minimum as it is an LTS
|
||
// release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
|
||
// release that supports 256 colors. Windows 10 build 14931 is the first release
|
||
// that supports 16m/TrueColor.
|
||
const osRelease = os.release().split('.');
|
||
|
||
if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
||
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
||
}
|
||
|
||
return 1;
|
||
}
|
||
|
||
if ('CI' in env) {
|
||
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
||
return 1;
|
||
}
|
||
|
||
return min;
|
||
}
|
||
|
||
if ('TEAMCITY_VERSION' in env) {
|
||
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
||
}
|
||
|
||
if (env.COLORTERM === 'truecolor') {
|
||
return 3;
|
||
}
|
||
|
||
if ('TERM_PROGRAM' in env) {
|
||
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
||
|
||
switch (env.TERM_PROGRAM) {
|
||
case 'iTerm.app':
|
||
return version >= 3 ? 3 : 2;
|
||
|
||
case 'Apple_Terminal':
|
||
return 2;
|
||
// No default
|
||
}
|
||
}
|
||
|
||
if (/-256(color)?$/i.test(env.TERM)) {
|
||
return 2;
|
||
}
|
||
|
||
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
||
return 1;
|
||
}
|
||
|
||
if ('COLORTERM' in env) {
|
||
return 1;
|
||
}
|
||
|
||
if (env.TERM === 'dumb') {
|
||
return min;
|
||
}
|
||
|
||
return min;
|
||
}
|
||
|
||
function getSupportLevel(stream) {
|
||
const level = supportsColor(stream);
|
||
return translateLevel(level);
|
||
}
|
||
|
||
module.exports = {
|
||
supportsColor: getSupportLevel,
|
||
stdout: getSupportLevel(process.stdout),
|
||
stderr: getSupportLevel(process.stderr)
|
||
};
|
||
|
||
/***/ }),
|
||
/* 41 */
|
||
/***/ (function(module, exports) {
|
||
|
||
module.exports = require("os");
|
||
|
||
/***/ }),
|
||
/* 42 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
module.exports = (flag, argv) => {
|
||
argv = argv || process.argv;
|
||
const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
|
||
const pos = argv.indexOf(prefix + flag);
|
||
const terminatorPos = argv.indexOf('--');
|
||
return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
|
||
};
|
||
|
||
/***/ }),
|
||
/* 43 */
|
||
/***/ (function(module, exports) {
|
||
|
||
module.exports = require("zlib");
|
||
|
||
/***/ }),
|
||
/* 44 */
|
||
/***/ (function(module) {
|
||
|
||
module.exports = JSON.parse("{\"_args\":[[\"axios@0.21.1\",\"/Users/cfx-vote-plugin/src\"]],\"_from\":\"axios@0.21.1\",\"_id\":\"axios@0.21.1\",\"_inBundle\":false,\"_integrity\":\"sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==\",\"_location\":\"/axios\",\"_phantomChildren\":{},\"_requested\":{\"type\":\"version\",\"registry\":true,\"raw\":\"axios@0.21.1\",\"name\":\"axios\",\"escapedName\":\"axios\",\"rawSpec\":\"0.21.1\",\"saveSpec\":null,\"fetchSpec\":\"0.21.1\"},\"_requiredBy\":[\"/\"],\"_resolved\":\"https://registry.npmjs.org/axios/-/axios-0.21.1.tgz\",\"_spec\":\"0.21.1\",\"_where\":\"/Users/joe/Projects/cfx-vote-plugin/src\",\"author\":{\"name\":\"Matt Zabriskie\"},\"browser\":{\"./lib/adapters/http.js\":\"./lib/adapters/xhr.js\"},\"bugs\":{\"url\":\"https://github.com/axios/axios/issues\"},\"bundlesize\":[{\"path\":\"./dist/axios.min.js\",\"threshold\":\"5kB\"}],\"dependencies\":{\"follow-redirects\":\"^1.10.0\"},\"description\":\"Promise based HTTP client for the browser and node.js\",\"devDependencies\":{\"bundlesize\":\"^0.17.0\",\"coveralls\":\"^3.0.0\",\"es6-promise\":\"^4.2.4\",\"grunt\":\"^1.0.2\",\"grunt-banner\":\"^0.6.0\",\"grunt-cli\":\"^1.2.0\",\"grunt-contrib-clean\":\"^1.1.0\",\"grunt-contrib-watch\":\"^1.0.0\",\"grunt-eslint\":\"^20.1.0\",\"grunt-karma\":\"^2.0.0\",\"grunt-mocha-test\":\"^0.13.3\",\"grunt-ts\":\"^6.0.0-beta.19\",\"grunt-webpack\":\"^1.0.18\",\"istanbul-instrumenter-loader\":\"^1.0.0\",\"jasmine-core\":\"^2.4.1\",\"karma\":\"^1.3.0\",\"karma-chrome-launcher\":\"^2.2.0\",\"karma-coverage\":\"^1.1.1\",\"karma-firefox-launcher\":\"^1.1.0\",\"karma-jasmine\":\"^1.1.1\",\"karma-jasmine-ajax\":\"^0.1.13\",\"karma-opera-launcher\":\"^1.0.0\",\"karma-safari-launcher\":\"^1.0.0\",\"karma-sauce-launcher\":\"^1.2.0\",\"karma-sinon\":\"^1.0.5\",\"karma-sourcemap-loader\":\"^0.3.7\",\"karma-webpack\":\"^1.7.0\",\"load-grunt-tasks\":\"^3.5.2\",\"minimist\":\"^1.2.0\",\"mocha\":\"^5.2.0\",\"sinon\":\"^4.5.0\",\"typescript\":\"^2.8.1\",\"url-search-params\":\"^0.10.0\",\"webpack\":\"^1.13.1\",\"webpack-dev-server\":\"^1.14.1\"},\"homepage\":\"https://github.com/axios/axios\",\"jsdelivr\":\"dist/axios.min.js\",\"keywords\":[\"xhr\",\"http\",\"ajax\",\"promise\",\"node\"],\"license\":\"MIT\",\"main\":\"index.js\",\"name\":\"axios\",\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/axios/axios.git\"},\"scripts\":{\"build\":\"NODE_ENV=production grunt build\",\"coveralls\":\"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js\",\"examples\":\"node ./examples/server.js\",\"fix\":\"eslint --fix lib/**/*.js\",\"postversion\":\"git push && git push --tags\",\"preversion\":\"npm test\",\"start\":\"node ./sandbox/server.js\",\"test\":\"grunt test && bundlesize\",\"version\":\"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json\"},\"typings\":\"./index.d.ts\",\"unpkg\":\"dist/axios.min.js\",\"version\":\"0.21.1\"}");
|
||
|
||
/***/ }),
|
||
/* 45 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
|
||
var Cancel = __webpack_require__(16);
|
||
/**
|
||
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
||
*
|
||
* @class
|
||
* @param {Function} executor The executor function.
|
||
*/
|
||
|
||
|
||
function CancelToken(executor) {
|
||
if (typeof executor !== 'function') {
|
||
throw new TypeError('executor must be a function.');
|
||
}
|
||
|
||
var resolvePromise;
|
||
this.promise = new Promise(function promiseExecutor(resolve) {
|
||
resolvePromise = resolve;
|
||
});
|
||
var token = this;
|
||
executor(function cancel(message) {
|
||
if (token.reason) {
|
||
// Cancellation has already been requested
|
||
return;
|
||
}
|
||
|
||
token.reason = new Cancel(message);
|
||
resolvePromise(token.reason);
|
||
});
|
||
}
|
||
/**
|
||
* Throws a `Cancel` if cancellation has been requested.
|
||
*/
|
||
|
||
|
||
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
|
||
if (this.reason) {
|
||
throw this.reason;
|
||
}
|
||
};
|
||
/**
|
||
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
||
* cancels the `CancelToken`.
|
||
*/
|
||
|
||
|
||
CancelToken.source = function source() {
|
||
var cancel;
|
||
var token = new CancelToken(function executor(c) {
|
||
cancel = c;
|
||
});
|
||
return {
|
||
token: token,
|
||
cancel: cancel
|
||
};
|
||
};
|
||
|
||
module.exports = CancelToken;
|
||
|
||
/***/ }),
|
||
/* 46 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
/**
|
||
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
||
*
|
||
* Common use case would be to use `Function.prototype.apply`.
|
||
*
|
||
* ```js
|
||
* function f(x, y, z) {}
|
||
* var args = [1, 2, 3];
|
||
* f.apply(null, args);
|
||
* ```
|
||
*
|
||
* With `spread` this example can be re-written.
|
||
*
|
||
* ```js
|
||
* spread(function(x, y, z) {})([1, 2, 3]);
|
||
* ```
|
||
*
|
||
* @param {Function} callback
|
||
* @returns {Function}
|
||
*/
|
||
|
||
module.exports = function spread(callback) {
|
||
return function wrap(arr) {
|
||
return callback.apply(null, arr);
|
||
};
|
||
};
|
||
|
||
/***/ }),
|
||
/* 47 */
|
||
/***/ (function(module, exports, __webpack_require__) {
|
||
|
||
"use strict";
|
||
|
||
/**
|
||
* Determines whether the payload is an error thrown by Axios
|
||
*
|
||
* @param {*} payload The value to test
|
||
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
||
*/
|
||
|
||
module.exports = function isAxiosError(payload) {
|
||
return typeof payload === 'object' && payload.isAxiosError === true;
|
||
};
|
||
|
||
/***/ }),
|
||
/* 48 */
|
||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||
|
||
"use strict";
|
||
// ESM COMPAT FLAG
|
||
__webpack_require__.r(__webpack_exports__);
|
||
|
||
// EXTERNAL MODULE: ./package.json
|
||
var package_0 = __webpack_require__(1);
|
||
|
||
// EXTERNAL MODULE: ./node_modules/axios/index.js
|
||
var axios = __webpack_require__(17);
|
||
var axios_default = /*#__PURE__*/__webpack_require__.n(axios);
|
||
|
||
// CONCATENATED MODULE: ./app/server/Security.js
|
||
|
||
|
||
class Security_Security {
|
||
constructor(env) {
|
||
this.env = env;
|
||
this.trustedIP = ["188.165.45.67", "188.165.46.57"];
|
||
this.loadTrustedIP();
|
||
}
|
||
|
||
loadTrustedIP() {
|
||
axios_default.a.get("https://top-games.net/trusted-ip.json").then(response => {
|
||
const {
|
||
list
|
||
} = response === null || response === void 0 ? void 0 : response.data;
|
||
|
||
if (list) {
|
||
this.trustedIP = list;
|
||
|
||
if (this.env === 'dev') {
|
||
this.trustedIP.push("127.0.0.1");
|
||
}
|
||
} else {
|
||
throw new Error("Invalid JSON");
|
||
}
|
||
}).catch(e => {
|
||
console.error("Unable to get trusted IP list from remote. Using default list.");
|
||
});
|
||
}
|
||
|
||
isTrustedIP(ip) {
|
||
const ipParts = ip.split(':');
|
||
|
||
if (ipParts.length > 1) {
|
||
return this.trustedIP.includes(ipParts[0]);
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
}
|
||
|
||
/* harmony default export */ var server_Security = (Security_Security);
|
||
// CONCATENATED MODULE: ./app/server/VoteReceptor.js
|
||
|
||
|
||
class VoteReceptor_VoteReceptor {
|
||
constructor(token) {
|
||
this.token = token;
|
||
}
|
||
|
||
checkPlayername(playername) {
|
||
const regex = /[A-zÀ-ÿ0-9-_]/g;
|
||
if (!playername) return false;
|
||
if (playername.length > 100) return false;
|
||
return playername.match(regex);
|
||
}
|
||
|
||
checkVersion(version) {
|
||
const regex = /[0-9.]/g;
|
||
if (!version) return false;
|
||
if (version.length > 10) return false;
|
||
return version.match(regex);
|
||
}
|
||
|
||
checkDate(date) {
|
||
const regex = /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/;
|
||
if (!date) return false;
|
||
if (date.length > 25) return false;
|
||
return date.match(regex);
|
||
}
|
||
|
||
hasError({
|
||
Token,
|
||
Playername,
|
||
Version,
|
||
Date
|
||
}) {
|
||
if (Token !== this.token) {
|
||
return "Wrong vote token";
|
||
}
|
||
|
||
if (!this.checkPlayername(Playername)) {
|
||
return "Invalid playername";
|
||
}
|
||
|
||
if (!this.checkVersion(Version)) {
|
||
return "Invalid version";
|
||
}
|
||
|
||
if (!this.checkDate(Date)) {
|
||
return "Invalid date";
|
||
}
|
||
|
||
return null;
|
||
}
|
||
|
||
handleVote(vote) {
|
||
return new Promise((resolve, reject) => {
|
||
const error = this.hasError(vote);
|
||
|
||
if (error) {
|
||
return reject(error);
|
||
}
|
||
|
||
const {
|
||
Playername,
|
||
Date,
|
||
Version
|
||
} = vote;
|
||
emit("onPlayerVote", Playername, Date);
|
||
|
||
if (Version > package_0.version) {
|
||
console.log('WARNING: a new update is available for the vote plugin. Please keep it up to date.');
|
||
}
|
||
|
||
resolve(true);
|
||
});
|
||
}
|
||
|
||
}
|
||
|
||
/* harmony default export */ var server_VoteReceptor = (VoteReceptor_VoteReceptor);
|
||
// CONCATENATED MODULE: ./app/server/Server.js
|
||
|
||
|
||
|
||
|
||
class Server_Server {
|
||
constructor(config) {
|
||
this.handleRequest = (res, data, address) => {
|
||
if (!this.security.isTrustedIP(address)) {
|
||
return this.returnError(res, 'Receving a vote from an untrusted IP');
|
||
}
|
||
|
||
const payload = JSON.parse(data);
|
||
|
||
if (payload.Action === "vote") {
|
||
this.voteReceptor.handleVote(payload).then(() => {
|
||
res.writeHead(200);
|
||
return res.send('success');
|
||
}).catch(error => {
|
||
return this.returnError(res, error);
|
||
});
|
||
} else if (payload.Action === "refresh_ip") {
|
||
this.security.loadTrustedIP();
|
||
} else if (payload.Action === "test") {
|
||
console.log('Test: The vote plugin is correctly linked to Top-games.net/Top-serveurs.net website');
|
||
res.writeHead(200);
|
||
res.send('test-success');
|
||
} else {
|
||
return this.returnError(res, 'No action match the current payload');
|
||
}
|
||
};
|
||
|
||
const {
|
||
token,
|
||
env
|
||
} = config;
|
||
this.security = new server_Security(env);
|
||
this.voteReceptor = new server_VoteReceptor(token);
|
||
}
|
||
|
||
start() {
|
||
console.log(`Initializing vote plugin (v${package_0.version})...`);
|
||
console.log(`Support Top-Games: https://top-games.net/contact`);
|
||
console.log(`Support Top-Serveurs: https://top-serveurs.net/contact`);
|
||
SetHttpHandler((req, res) => {
|
||
if (req.path === '/') {
|
||
req.setDataHandler(data => {
|
||
this.handleRequest(res, data, req.address);
|
||
});
|
||
}
|
||
});
|
||
console.log(`The vote plugin is active on the default server port`);
|
||
}
|
||
|
||
returnError(res, error) {
|
||
console.error(error);
|
||
res.writeHead(400);
|
||
res.send(error);
|
||
}
|
||
|
||
}
|
||
|
||
/* harmony default export */ var server_Server = (Server_Server);
|
||
// CONCATENATED MODULE: ./app/index.js
|
||
|
||
const app_config = {
|
||
token: GetConvar("vote_token", ""),
|
||
env: GetConvar("vote_env", "prod")
|
||
};
|
||
const server = new server_Server(app_config);
|
||
on('onResourceStart', resourceName => {
|
||
if (resourceName === GetCurrentResourceName()) {
|
||
if (app_config.token.length === 0) {
|
||
console.log('\x1b[31m########################\x1b[0m');
|
||
console.error('The vote token is missing in your config file. Please fill it!');
|
||
console.log('\x1b[31m########################\x1b[0m');
|
||
} else if (resourceName !== 'vote') {
|
||
console.log('\x1b[31m########################\x1b[0m');
|
||
console.error('The resource name (directory name) must be "vote". Actual name: ' + resourceName);
|
||
console.log('\x1b[31m########################\x1b[0m');
|
||
} else {
|
||
server.start();
|
||
emit('onVoteReady');
|
||
}
|
||
}
|
||
});
|
||
|
||
/***/ })
|
||
/******/ ]); |