2021-05-07 16:07:16 +08:00
|
|
|
|
/******/ (() => { // webpackBootstrap
|
|
|
|
|
/******/ var __webpack_modules__ = ({
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 4812:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
module.exports =
|
|
|
|
|
{
|
|
|
|
|
parallel : __nccwpck_require__(8210),
|
|
|
|
|
serial : __nccwpck_require__(445),
|
|
|
|
|
serialOrdered : __nccwpck_require__(3578)
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 1700:
|
|
|
|
|
/***/ ((module) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// API
|
|
|
|
|
module.exports = abort;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Aborts leftover active jobs
|
|
|
|
|
*
|
|
|
|
|
* @param {object} state - current state object
|
|
|
|
|
*/
|
|
|
|
|
function abort(state)
|
|
|
|
|
{
|
|
|
|
|
Object.keys(state.jobs).forEach(clean.bind(state));
|
|
|
|
|
|
|
|
|
|
// reset leftover jobs
|
|
|
|
|
state.jobs = {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cleans up leftover job by invoking abort function for the provided job id
|
|
|
|
|
*
|
|
|
|
|
* @this state
|
|
|
|
|
* @param {string|number} key - job id to abort
|
|
|
|
|
*/
|
|
|
|
|
function clean(key)
|
|
|
|
|
{
|
|
|
|
|
if (typeof this.jobs[key] == 'function')
|
|
|
|
|
{
|
|
|
|
|
this.jobs[key]();
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 2794:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
var defer = __nccwpck_require__(5295);
|
|
|
|
|
|
|
|
|
|
// API
|
|
|
|
|
module.exports = async;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Runs provided callback asynchronously
|
|
|
|
|
* even if callback itself is not
|
|
|
|
|
*
|
|
|
|
|
* @param {function} callback - callback to invoke
|
|
|
|
|
* @returns {function} - augmented callback
|
|
|
|
|
*/
|
|
|
|
|
function async(callback)
|
|
|
|
|
{
|
|
|
|
|
var isAsync = false;
|
|
|
|
|
|
|
|
|
|
// check if async happened
|
|
|
|
|
defer(function() { isAsync = true; });
|
|
|
|
|
|
|
|
|
|
return function async_callback(err, result)
|
|
|
|
|
{
|
|
|
|
|
if (isAsync)
|
|
|
|
|
{
|
|
|
|
|
callback(err, result);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
defer(function nextTick_callback()
|
|
|
|
|
{
|
|
|
|
|
callback(err, result);
|
|
|
|
|
});
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 5295:
|
|
|
|
|
/***/ ((module) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
module.exports = defer;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Runs provided function on next iteration of the event loop
|
|
|
|
|
*
|
|
|
|
|
* @param {function} fn - function to run
|
|
|
|
|
*/
|
|
|
|
|
function defer(fn)
|
|
|
|
|
{
|
|
|
|
|
var nextTick = typeof setImmediate == 'function'
|
|
|
|
|
? setImmediate
|
|
|
|
|
: (
|
|
|
|
|
typeof process == 'object' && typeof process.nextTick == 'function'
|
|
|
|
|
? process.nextTick
|
|
|
|
|
: null
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (nextTick)
|
|
|
|
|
{
|
|
|
|
|
nextTick(fn);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
setTimeout(fn, 0);
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 9023:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
var async = __nccwpck_require__(2794)
|
|
|
|
|
, abort = __nccwpck_require__(1700)
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// API
|
|
|
|
|
module.exports = iterate;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Iterates over each job object
|
|
|
|
|
*
|
|
|
|
|
* @param {array|object} list - array or object (named list) to iterate over
|
|
|
|
|
* @param {function} iterator - iterator to run
|
|
|
|
|
* @param {object} state - current job status
|
|
|
|
|
* @param {function} callback - invoked when all elements processed
|
|
|
|
|
*/
|
|
|
|
|
function iterate(list, iterator, state, callback)
|
|
|
|
|
{
|
|
|
|
|
// store current index
|
|
|
|
|
var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;
|
|
|
|
|
|
|
|
|
|
state.jobs[key] = runJob(iterator, key, list[key], function(error, output)
|
|
|
|
|
{
|
|
|
|
|
// don't repeat yourself
|
|
|
|
|
// skip secondary callbacks
|
|
|
|
|
if (!(key in state.jobs))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// clean up jobs
|
|
|
|
|
delete state.jobs[key];
|
|
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
|
{
|
|
|
|
|
// don't process rest of the results
|
|
|
|
|
// stop still active jobs
|
|
|
|
|
// and reset the list
|
|
|
|
|
abort(state);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
state.results[key] = output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// return salvaged results
|
|
|
|
|
callback(error, state.results);
|
|
|
|
|
});
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* Runs iterator over provided job element
|
|
|
|
|
*
|
|
|
|
|
* @param {function} iterator - iterator to invoke
|
|
|
|
|
* @param {string|number} key - key/index of the element in the list of jobs
|
|
|
|
|
* @param {mixed} item - job description
|
|
|
|
|
* @param {function} callback - invoked after iterator is done with the job
|
|
|
|
|
* @returns {function|mixed} - job abort function or something else
|
|
|
|
|
*/
|
|
|
|
|
function runJob(iterator, key, item, callback)
|
|
|
|
|
{
|
|
|
|
|
var aborter;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// allow shortcut if iterator expects only two arguments
|
|
|
|
|
if (iterator.length == 2)
|
|
|
|
|
{
|
|
|
|
|
aborter = iterator(item, async(callback));
|
|
|
|
|
}
|
|
|
|
|
// otherwise go with full three arguments
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
aborter = iterator(item, key, async(callback));
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return aborter;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 2474:
|
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
|
|
// API
|
|
|
|
|
module.exports = state;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates initial state object
|
|
|
|
|
* for iteration over list
|
|
|
|
|
*
|
|
|
|
|
* @param {array|object} list - list to iterate over
|
|
|
|
|
* @param {function|null} sortMethod - function to use for keys sort,
|
|
|
|
|
* or `null` to keep them as is
|
|
|
|
|
* @returns {object} - initial state object
|
|
|
|
|
*/
|
|
|
|
|
function state(list, sortMethod)
|
|
|
|
|
{
|
|
|
|
|
var isNamedList = !Array.isArray(list)
|
|
|
|
|
, initState =
|
|
|
|
|
{
|
|
|
|
|
index : 0,
|
|
|
|
|
keyedList: isNamedList || sortMethod ? Object.keys(list) : null,
|
|
|
|
|
jobs : {},
|
|
|
|
|
results : isNamedList ? {} : [],
|
|
|
|
|
size : isNamedList ? Object.keys(list).length : list.length
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
if (sortMethod)
|
|
|
|
|
{
|
|
|
|
|
// sort array keys based on it's values
|
|
|
|
|
// sort object's keys just on own merit
|
|
|
|
|
initState.keyedList.sort(isNamedList ? sortMethod : function(a, b)
|
|
|
|
|
{
|
|
|
|
|
return sortMethod(list[a], list[b]);
|
|
|
|
|
});
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return initState;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 7942:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
var abort = __nccwpck_require__(1700)
|
|
|
|
|
, async = __nccwpck_require__(2794)
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// API
|
|
|
|
|
module.exports = terminator;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Terminates jobs in the attached state context
|
|
|
|
|
*
|
|
|
|
|
* @this AsyncKitState#
|
|
|
|
|
* @param {function} callback - final callback to invoke after termination
|
|
|
|
|
*/
|
|
|
|
|
function terminator(callback)
|
|
|
|
|
{
|
|
|
|
|
if (!Object.keys(this.jobs).length)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// fast forward iteration index
|
|
|
|
|
this.index = this.size;
|
|
|
|
|
|
|
|
|
|
// abort jobs
|
|
|
|
|
abort(this);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// send back results we have so far
|
|
|
|
|
async(callback)(null, this.results);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 8210:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
var iterate = __nccwpck_require__(9023)
|
|
|
|
|
, initState = __nccwpck_require__(2474)
|
|
|
|
|
, terminator = __nccwpck_require__(7942)
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// Public API
|
|
|
|
|
module.exports = parallel;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Runs iterator over provided array elements in parallel
|
|
|
|
|
*
|
|
|
|
|
* @param {array|object} list - array or object (named list) to iterate over
|
|
|
|
|
* @param {function} iterator - iterator to run
|
|
|
|
|
* @param {function} callback - invoked when all elements processed
|
|
|
|
|
* @returns {function} - jobs terminator
|
|
|
|
|
*/
|
|
|
|
|
function parallel(list, iterator, callback)
|
|
|
|
|
{
|
|
|
|
|
var state = initState(list);
|
|
|
|
|
|
|
|
|
|
while (state.index < (state['keyedList'] || list).length)
|
|
|
|
|
{
|
|
|
|
|
iterate(list, iterator, state, function(error, result)
|
|
|
|
|
{
|
|
|
|
|
if (error)
|
|
|
|
|
{
|
|
|
|
|
callback(error, result);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// looks like it's the last one
|
|
|
|
|
if (Object.keys(state.jobs).length === 0)
|
|
|
|
|
{
|
|
|
|
|
callback(null, state.results);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
state.index++;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return terminator.bind(state, callback);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 445:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var serialOrdered = __nccwpck_require__(3578);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Public API
|
|
|
|
|
module.exports = serial;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Runs iterator over provided array elements in series
|
|
|
|
|
*
|
|
|
|
|
* @param {array|object} list - array or object (named list) to iterate over
|
|
|
|
|
* @param {function} iterator - iterator to run
|
|
|
|
|
* @param {function} callback - invoked when all elements processed
|
|
|
|
|
* @returns {function} - jobs terminator
|
|
|
|
|
*/
|
|
|
|
|
function serial(list, iterator, callback)
|
|
|
|
|
{
|
|
|
|
|
return serialOrdered(list, iterator, null, callback);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 3578:
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var iterate = __nccwpck_require__(9023)
|
|
|
|
|
, initState = __nccwpck_require__(2474)
|
|
|
|
|
, terminator = __nccwpck_require__(7942)
|
|
|
|
|
;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Public API
|
|
|
|
|
module.exports = serialOrdered;
|
|
|
|
|
// sorting helpers
|
|
|
|
|
module.exports.ascending = ascending;
|
|
|
|
|
module.exports.descending = descending;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* Runs iterator over provided sorted array elements in series
|
|
|
|
|
*
|
|
|
|
|
* @param {array|object} list - array or object (named list) to iterate over
|
|
|
|
|
* @param {function} iterator - iterator to run
|
|
|
|
|
* @param {function} sortMethod - custom sort function
|
|
|
|
|
* @param {function} callback - invoked when all elements processed
|
|
|
|
|
* @returns {function} - jobs terminator
|
|
|
|
|
*/
|
|
|
|
|
function serialOrdered(list, iterator, sortMethod, callback)
|
|
|
|
|
{
|
|
|
|
|
var state = initState(list, sortMethod);
|
|
|
|
|
|
|
|
|
|
iterate(list, iterator, state, function iteratorHandler(error, result)
|
|
|
|
|
{
|
|
|
|
|
if (error)
|
|
|
|
|
{
|
|
|
|
|
callback(error, result);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
state.index++;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// are we there yet?
|
|
|
|
|
if (state.index < (state['keyedList'] || list).length)
|
|
|
|
|
{
|
|
|
|
|
iterate(list, iterator, state, iteratorHandler);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// done here
|
|
|
|
|
callback(null, state.results);
|
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return terminator.bind(state, callback);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/*
|
|
|
|
|
* -- Sort methods
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* sort helper to sort array elements in ascending order
|
|
|
|
|
*
|
|
|
|
|
* @param {mixed} a - an item to compare
|
|
|
|
|
* @param {mixed} b - an item to compare
|
|
|
|
|
* @returns {number} - comparison result
|
|
|
|
|
*/
|
|
|
|
|
function ascending(a, b)
|
|
|
|
|
{
|
|
|
|
|
return a < b ? -1 : a > b ? 1 : 0;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* sort helper to sort array elements in descending order
|
|
|
|
|
*
|
|
|
|
|
* @param {mixed} a - an item to compare
|
|
|
|
|
* @param {mixed} b - an item to compare
|
|
|
|
|
* @returns {number} - comparison result
|
|
|
|
|
*/
|
|
|
|
|
function descending(a, b)
|
|
|
|
|
{
|
|
|
|
|
return -1 * ascending(a, b);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ 6545:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
module.exports = __nccwpck_require__(2618);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ 8104:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
"use strict";
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
var settle = __nccwpck_require__(3211);
|
|
|
|
|
var buildFullPath = __nccwpck_require__(1934);
|
|
|
|
|
var buildURL = __nccwpck_require__(646);
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var http = __nccwpck_require__(3685);
|
|
|
|
|
var https = __nccwpck_require__(5687);
|
|
|
|
|
var httpFollow = (__nccwpck_require__(7707).http);
|
|
|
|
|
var httpsFollow = (__nccwpck_require__(7707).https);
|
|
|
|
|
var url = __nccwpck_require__(7310);
|
|
|
|
|
var zlib = __nccwpck_require__(9796);
|
|
|
|
|
var VERSION = (__nccwpck_require__(4322).version);
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var transitionalDefaults = __nccwpck_require__(936);
|
|
|
|
|
var AxiosError = __nccwpck_require__(2093);
|
|
|
|
|
var CanceledError = __nccwpck_require__(4098);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var isHttps = /https:?/;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var supportedProtocols = [ 'http:', 'https:', 'file:' ];
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @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;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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);
|
|
|
|
|
};
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/*eslint consistent-return:0*/
|
|
|
|
|
module.exports = function httpAdapter(config) {
|
|
|
|
|
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var onCanceled;
|
|
|
|
|
function done() {
|
|
|
|
|
if (config.cancelToken) {
|
|
|
|
|
config.cancelToken.unsubscribe(onCanceled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config.signal) {
|
|
|
|
|
config.signal.removeEventListener('abort', onCanceled);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var resolve = function resolve(value) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
done();
|
2021-05-07 16:07:16 +08:00
|
|
|
|
resolvePromise(value);
|
|
|
|
|
};
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var rejected = false;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var reject = function reject(value) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
done();
|
2022-04-27 10:20:40 +08:00
|
|
|
|
rejected = true;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
rejectPromise(value);
|
|
|
|
|
};
|
|
|
|
|
var data = config.data;
|
|
|
|
|
var headers = config.headers;
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var headerNames = {};
|
|
|
|
|
|
|
|
|
|
Object.keys(headers).forEach(function storeLowerName(name) {
|
|
|
|
|
headerNames[name.toLowerCase()] = name;
|
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Set User-Agent (required by some servers)
|
|
|
|
|
// See https://github.com/axios/axios/issues/69
|
2021-12-27 13:47:39 +08:00
|
|
|
|
if ('user-agent' in headerNames) {
|
|
|
|
|
// User-Agent is specified; handle case where no UA header is desired
|
|
|
|
|
if (!headers[headerNames['user-agent']]) {
|
|
|
|
|
delete headers[headerNames['user-agent']];
|
|
|
|
|
}
|
|
|
|
|
// Otherwise, use specified value
|
|
|
|
|
} else {
|
|
|
|
|
// Only set header if it hasn't been set in config
|
|
|
|
|
headers['User-Agent'] = 'axios/' + VERSION;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// support for https://www.npmjs.com/package/form-data api
|
|
|
|
|
if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {
|
|
|
|
|
Object.assign(headers, data.getHeaders());
|
|
|
|
|
} else if (data && !utils.isStream(data)) {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
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 {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return reject(new AxiosError(
|
2021-05-07 16:07:16 +08:00
|
|
|
|
'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
|
2022-04-27 10:20:40 +08:00
|
|
|
|
AxiosError.ERR_BAD_REQUEST,
|
|
|
|
|
config
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
|
|
|
|
|
return reject(new AxiosError(
|
|
|
|
|
'Request body larger than maxBodyLength limit',
|
|
|
|
|
AxiosError.ERR_BAD_REQUEST,
|
2021-05-07 16:07:16 +08:00
|
|
|
|
config
|
|
|
|
|
));
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Add Content-Length header if data exists
|
2021-12-27 13:47:39 +08:00
|
|
|
|
if (!headerNames['content-length']) {
|
|
|
|
|
headers['Content-Length'] = data.length;
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// HTTP basic authentication
|
|
|
|
|
var auth = undefined;
|
|
|
|
|
if (config.auth) {
|
|
|
|
|
var username = config.auth.username || '';
|
|
|
|
|
var password = config.auth.password || '';
|
|
|
|
|
auth = username + ':' + password;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Parse url
|
|
|
|
|
var fullPath = buildFullPath(config.baseURL, config.url);
|
|
|
|
|
var parsed = url.parse(fullPath);
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var protocol = parsed.protocol || supportedProtocols[0];
|
|
|
|
|
|
|
|
|
|
if (supportedProtocols.indexOf(protocol) === -1) {
|
|
|
|
|
return reject(new AxiosError(
|
|
|
|
|
'Unsupported protocol ' + protocol,
|
|
|
|
|
AxiosError.ERR_BAD_REQUEST,
|
|
|
|
|
config
|
|
|
|
|
));
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (!auth && parsed.auth) {
|
|
|
|
|
var urlAuth = parsed.auth.split(':');
|
|
|
|
|
var urlUsername = urlAuth[0] || '';
|
|
|
|
|
var urlPassword = urlAuth[1] || '';
|
|
|
|
|
auth = urlUsername + ':' + urlPassword;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
if (auth && headerNames.authorization) {
|
|
|
|
|
delete headers[headerNames.authorization];
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var isHttpsRequest = isHttps.test(protocol);
|
|
|
|
|
var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
try {
|
|
|
|
|
buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, '');
|
|
|
|
|
} catch (err) {
|
|
|
|
|
var customErr = new Error(err.message);
|
|
|
|
|
customErr.config = config;
|
|
|
|
|
customErr.url = config.url;
|
|
|
|
|
customErr.exists = true;
|
|
|
|
|
reject(customErr);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
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
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (config.socketPath) {
|
|
|
|
|
options.socketPath = config.socketPath;
|
|
|
|
|
} else {
|
|
|
|
|
options.hostname = parsed.hostname;
|
|
|
|
|
options.port = parsed.port;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
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;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (noProxyEnv) {
|
|
|
|
|
var noProxy = noProxyEnv.split(',').map(function trim(s) {
|
|
|
|
|
return s.trim();
|
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
return parsed.hostname === proxyElement;
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (shouldProxy) {
|
|
|
|
|
proxy = {
|
|
|
|
|
host: parsedProxyUrl.hostname,
|
|
|
|
|
port: parsedProxyUrl.port,
|
|
|
|
|
protocol: parsedProxyUrl.protocol
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (parsedProxyUrl.auth) {
|
|
|
|
|
var proxyUrlAuth = parsedProxyUrl.auth.split(':');
|
|
|
|
|
proxy.auth = {
|
|
|
|
|
username: proxyUrlAuth[0],
|
|
|
|
|
password: proxyUrlAuth[1]
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (proxy) {
|
|
|
|
|
options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
|
|
|
|
|
setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (config.beforeRedirect) {
|
|
|
|
|
options.beforeRedirect = config.beforeRedirect;
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
transport = isHttpsProxy ? httpsFollow : httpFollow;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (config.maxBodyLength > -1) {
|
|
|
|
|
options.maxBodyLength = config.maxBodyLength;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
if (config.insecureHTTPParser) {
|
|
|
|
|
options.insecureHTTPParser = config.insecureHTTPParser;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Create the request
|
|
|
|
|
var req = transport.request(options, function handleResponse(res) {
|
|
|
|
|
if (req.aborted) return;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// uncompress the response body transparently if required
|
|
|
|
|
var stream = res;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// return the last request in case of redirects
|
|
|
|
|
var lastRequest = res.req || req;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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());
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// remove the content-encoding in order to not confuse downstream operations
|
|
|
|
|
delete res.headers['content-encoding'];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var response = {
|
|
|
|
|
status: res.statusCode,
|
|
|
|
|
statusText: res.statusMessage,
|
|
|
|
|
headers: res.headers,
|
|
|
|
|
config: config,
|
|
|
|
|
request: lastRequest
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (config.responseType === 'stream') {
|
|
|
|
|
response.data = stream;
|
|
|
|
|
settle(resolve, reject, response);
|
|
|
|
|
} else {
|
|
|
|
|
var responseBuffer = [];
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var totalResponseBytes = 0;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
stream.on('data', function handleStreamData(chunk) {
|
|
|
|
|
responseBuffer.push(chunk);
|
2021-12-27 13:47:39 +08:00
|
|
|
|
totalResponseBytes += chunk.length;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// make sure the content length is not over the maxContentLength if specified
|
2021-12-27 13:47:39 +08:00
|
|
|
|
if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// stream.destoy() emit aborted event before calling reject() on Node.js v16
|
|
|
|
|
rejected = true;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
stream.destroy();
|
2022-04-27 10:20:40 +08:00
|
|
|
|
reject(new AxiosError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
|
|
|
|
|
AxiosError.ERR_BAD_RESPONSE, config, lastRequest));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
stream.on('aborted', function handlerStreamAborted() {
|
|
|
|
|
if (rejected) {
|
|
|
|
|
return;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
stream.destroy();
|
|
|
|
|
reject(new AxiosError(
|
|
|
|
|
'maxContentLength size of ' + config.maxContentLength + ' exceeded',
|
|
|
|
|
AxiosError.ERR_BAD_RESPONSE,
|
|
|
|
|
config,
|
|
|
|
|
lastRequest
|
|
|
|
|
));
|
2021-05-07 16:07:16 +08:00
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
stream.on('error', function handleStreamError(err) {
|
|
|
|
|
if (req.aborted) return;
|
2022-04-27 10:20:40 +08:00
|
|
|
|
reject(AxiosError.from(err, null, config, lastRequest));
|
2021-05-07 16:07:16 +08:00
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
stream.on('end', function handleStreamEnd() {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
try {
|
|
|
|
|
var responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
|
|
|
|
|
if (config.responseType !== 'arraybuffer') {
|
|
|
|
|
responseData = responseData.toString(config.responseEncoding);
|
|
|
|
|
if (!config.responseEncoding || config.responseEncoding === 'utf8') {
|
|
|
|
|
responseData = utils.stripBOM(responseData);
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
response.data = responseData;
|
|
|
|
|
} catch (err) {
|
|
|
|
|
reject(AxiosError.from(err, null, config, response.request, response));
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
settle(resolve, reject, response);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Handle errors
|
|
|
|
|
req.on('error', function handleRequestError(err) {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// @todo remove
|
|
|
|
|
// if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return;
|
|
|
|
|
reject(AxiosError.from(err, null, config, req));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// set tcp keep alive to prevent drop connection by peer
|
|
|
|
|
req.on('socket', function handleRequestSocket(socket) {
|
|
|
|
|
// default interval of sending ack packet is 1 minute
|
|
|
|
|
socket.setKeepAlive(true, 1000 * 60);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Handle request timeout
|
|
|
|
|
if (config.timeout) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
|
|
|
|
|
var timeout = parseInt(config.timeout, 10);
|
|
|
|
|
|
|
|
|
|
if (isNaN(timeout)) {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
reject(new AxiosError(
|
2021-12-27 13:47:39 +08:00
|
|
|
|
'error trying to parse `config.timeout` to int',
|
2022-04-27 10:20:40 +08:00
|
|
|
|
AxiosError.ERR_BAD_OPTION_VALUE,
|
2021-12-27 13:47:39 +08:00
|
|
|
|
config,
|
|
|
|
|
req
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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.
|
2021-12-27 13:47:39 +08:00
|
|
|
|
req.setTimeout(timeout, function handleRequestTimeout() {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
req.abort();
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var transitional = config.transitional || transitionalDefaults;
|
|
|
|
|
reject(new AxiosError(
|
2021-12-27 13:47:39 +08:00
|
|
|
|
'timeout of ' + timeout + 'ms exceeded',
|
2022-04-27 10:20:40 +08:00
|
|
|
|
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
2021-12-27 13:47:39 +08:00
|
|
|
|
config,
|
|
|
|
|
req
|
|
|
|
|
));
|
2021-05-07 16:07:16 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
if (config.cancelToken || config.signal) {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Handle cancellation
|
2021-12-27 13:47:39 +08:00
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
onCanceled = function(cancel) {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (req.aborted) return;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
req.abort();
|
2022-04-27 10:20:40 +08:00
|
|
|
|
reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel);
|
2021-12-27 13:47:39 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
|
|
|
|
if (config.signal) {
|
|
|
|
|
config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Send the request
|
|
|
|
|
if (utils.isStream(data)) {
|
|
|
|
|
data.on('error', function handleStreamError(err) {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
reject(AxiosError.from(err, config, null, req));
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}).pipe(req);
|
|
|
|
|
} else {
|
|
|
|
|
req.end(data);
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ 3454:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
"use strict";
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
var settle = __nccwpck_require__(3211);
|
|
|
|
|
var cookies = __nccwpck_require__(1545);
|
|
|
|
|
var buildURL = __nccwpck_require__(646);
|
|
|
|
|
var buildFullPath = __nccwpck_require__(1934);
|
|
|
|
|
var parseHeaders = __nccwpck_require__(6455);
|
|
|
|
|
var isURLSameOrigin = __nccwpck_require__(3608);
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var transitionalDefaults = __nccwpck_require__(936);
|
|
|
|
|
var AxiosError = __nccwpck_require__(2093);
|
|
|
|
|
var CanceledError = __nccwpck_require__(4098);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
module.exports = function xhrAdapter(config) {
|
|
|
|
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
|
|
|
var requestData = config.data;
|
|
|
|
|
var requestHeaders = config.headers;
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var responseType = config.responseType;
|
|
|
|
|
var onCanceled;
|
|
|
|
|
function done() {
|
|
|
|
|
if (config.cancelToken) {
|
|
|
|
|
config.cancelToken.unsubscribe(onCanceled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config.signal) {
|
|
|
|
|
config.signal.removeEventListener('abort', onCanceled);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var request = new XMLHttpRequest();
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var fullPath = buildFullPath(config.baseURL, config.url);
|
2022-04-27 10:20:40 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Set the request timeout in MS
|
|
|
|
|
request.timeout = config.timeout;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
function onloadend() {
|
|
|
|
|
if (!request) {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Prepare the response
|
|
|
|
|
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
|
|
|
|
request.responseText : request.response;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var response = {
|
|
|
|
|
data: responseData,
|
|
|
|
|
status: request.status,
|
|
|
|
|
statusText: request.statusText,
|
|
|
|
|
headers: responseHeaders,
|
|
|
|
|
config: config,
|
|
|
|
|
request: request
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
settle(function _resolve(value) {
|
|
|
|
|
resolve(value);
|
|
|
|
|
done();
|
|
|
|
|
}, function _reject(err) {
|
|
|
|
|
reject(err);
|
|
|
|
|
done();
|
|
|
|
|
}, response);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Clean up request
|
|
|
|
|
request = null;
|
2021-12-27 13:47:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ('onloadend' in request) {
|
|
|
|
|
// Use onloadend if available
|
|
|
|
|
request.onloadend = onloadend;
|
|
|
|
|
} else {
|
|
|
|
|
// Listen for ready state to emulate onloadend
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
// readystate handler is calling before onerror or ontimeout handlers,
|
|
|
|
|
// so we should call onloadend on the next 'tick'
|
|
|
|
|
setTimeout(onloadend);
|
|
|
|
|
};
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Handle browser request cancellation (as opposed to a manual cancellation)
|
|
|
|
|
request.onabort = function handleAbort() {
|
|
|
|
|
if (!request) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Clean up request
|
|
|
|
|
request = null;
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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
|
2022-04-27 10:20:40 +08:00
|
|
|
|
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, request));
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Clean up request
|
|
|
|
|
request = null;
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Handle timeout
|
|
|
|
|
request.ontimeout = function handleTimeout() {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var transitional = config.transitional || transitionalDefaults;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (config.timeoutErrorMessage) {
|
|
|
|
|
timeoutErrorMessage = config.timeoutErrorMessage;
|
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
reject(new AxiosError(
|
2021-12-27 13:47:39 +08:00
|
|
|
|
timeoutErrorMessage,
|
2022-04-27 10:20:40 +08:00
|
|
|
|
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
2021-12-27 13:47:39 +08:00
|
|
|
|
config,
|
2021-05-07 16:07:16 +08:00
|
|
|
|
request));
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Clean up request
|
|
|
|
|
request = null;
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (xsrfValue) {
|
|
|
|
|
requestHeaders[config.xsrfHeaderName] = xsrfValue;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Add withCredentials to request if needed
|
|
|
|
|
if (!utils.isUndefined(config.withCredentials)) {
|
|
|
|
|
request.withCredentials = !!config.withCredentials;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Add responseType to request if needed
|
2021-12-27 13:47:39 +08:00
|
|
|
|
if (responseType && responseType !== 'json') {
|
|
|
|
|
request.responseType = config.responseType;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Handle progress if needed
|
|
|
|
|
if (typeof config.onDownloadProgress === 'function') {
|
|
|
|
|
request.addEventListener('progress', config.onDownloadProgress);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Not all browsers support upload events
|
|
|
|
|
if (typeof config.onUploadProgress === 'function' && request.upload) {
|
|
|
|
|
request.upload.addEventListener('progress', config.onUploadProgress);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
if (config.cancelToken || config.signal) {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Handle cancellation
|
2021-12-27 13:47:39 +08:00
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
onCanceled = function(cancel) {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (!request) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
request.abort();
|
|
|
|
|
request = null;
|
2021-12-27 13:47:39 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
|
|
|
|
if (config.signal) {
|
|
|
|
|
config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (!requestData) {
|
|
|
|
|
requestData = null;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var tokens = fullPath.split(':', 2);
|
|
|
|
|
var protocol = tokens.length > 1 && tokens[0];
|
|
|
|
|
|
|
|
|
|
if (protocol && [ 'http', 'https', 'file' ].indexOf(protocol) === -1) {
|
|
|
|
|
reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Send the request
|
|
|
|
|
request.send(requestData);
|
|
|
|
|
});
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ 2618:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
"use strict";
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
var bind = __nccwpck_require__(7065);
|
|
|
|
|
var Axios = __nccwpck_require__(8178);
|
|
|
|
|
var mergeConfig = __nccwpck_require__(4831);
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var defaults = __nccwpck_require__(1626);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/**
|
|
|
|
|
* 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);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Copy axios.prototype to instance
|
|
|
|
|
utils.extend(instance, Axios.prototype, context);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Copy context to instance
|
|
|
|
|
utils.extend(instance, context);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
// Factory for creating new instances
|
|
|
|
|
instance.create = function create(instanceConfig) {
|
|
|
|
|
return createInstance(mergeConfig(defaultConfig, instanceConfig));
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
return instance;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Create the default instance to be exported
|
|
|
|
|
var axios = createInstance(defaults);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Expose Axios class to allow class inheritance
|
|
|
|
|
axios.Axios = Axios;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Expose Cancel & CancelToken
|
2022-04-27 10:20:40 +08:00
|
|
|
|
axios.CanceledError = __nccwpck_require__(4098);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
axios.CancelToken = __nccwpck_require__(1587);
|
|
|
|
|
axios.isCancel = __nccwpck_require__(4057);
|
2021-12-27 13:47:39 +08:00
|
|
|
|
axios.VERSION = (__nccwpck_require__(4322).version);
|
2022-04-27 10:20:40 +08:00
|
|
|
|
axios.toFormData = __nccwpck_require__(470);
|
|
|
|
|
|
|
|
|
|
// Expose AxiosError class
|
|
|
|
|
axios.AxiosError = __nccwpck_require__(2093);
|
|
|
|
|
|
|
|
|
|
// alias for CanceledError for backward compatibility
|
|
|
|
|
axios.Cancel = axios.CanceledError;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Expose all/spread
|
|
|
|
|
axios.all = function all(promises) {
|
|
|
|
|
return Promise.all(promises);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
};
|
2021-05-07 16:07:16 +08:00
|
|
|
|
axios.spread = __nccwpck_require__(4850);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Expose isAxiosError
|
|
|
|
|
axios.isAxiosError = __nccwpck_require__(650);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
module.exports = axios;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Allow use of default import syntax in TypeScript
|
2021-12-27 13:47:39 +08:00
|
|
|
|
module.exports["default"] = axios;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ 1587:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
"use strict";
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var CanceledError = __nccwpck_require__(4098);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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;
|
2021-12-27 13:47:39 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
|
|
|
resolvePromise = resolve;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var token = this;
|
2021-12-27 13:47:39 +08:00
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
this.promise.then(function(cancel) {
|
|
|
|
|
if (!token._listeners) return;
|
|
|
|
|
|
|
|
|
|
var i;
|
|
|
|
|
var l = token._listeners.length;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < l; i++) {
|
|
|
|
|
token._listeners[i](cancel);
|
|
|
|
|
}
|
|
|
|
|
token._listeners = null;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
this.promise.then = function(onfulfilled) {
|
|
|
|
|
var _resolve;
|
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
var promise = new Promise(function(resolve) {
|
|
|
|
|
token.subscribe(resolve);
|
|
|
|
|
_resolve = resolve;
|
|
|
|
|
}).then(onfulfilled);
|
|
|
|
|
|
|
|
|
|
promise.cancel = function reject() {
|
|
|
|
|
token.unsubscribe(_resolve);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return promise;
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
executor(function cancel(message) {
|
|
|
|
|
if (token.reason) {
|
|
|
|
|
// Cancellation has already been requested
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
token.reason = new CanceledError(message);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
resolvePromise(token.reason);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-04-27 10:20:40 +08:00
|
|
|
|
* Throws a `CanceledError` if cancellation has been requested.
|
2021-05-07 16:07:16 +08:00
|
|
|
|
*/
|
|
|
|
|
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
|
|
|
|
|
if (this.reason) {
|
|
|
|
|
throw this.reason;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
};
|
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
/**
|
|
|
|
|
* Subscribe to the cancel signal
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
CancelToken.prototype.subscribe = function subscribe(listener) {
|
|
|
|
|
if (this.reason) {
|
|
|
|
|
listener(this.reason);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this._listeners) {
|
|
|
|
|
this._listeners.push(listener);
|
|
|
|
|
} else {
|
|
|
|
|
this._listeners = [listener];
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unsubscribe from the cancel signal
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
|
|
|
|
|
if (!this._listeners) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var index = this._listeners.indexOf(listener);
|
|
|
|
|
if (index !== -1) {
|
|
|
|
|
this._listeners.splice(index, 1);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
};
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
module.exports = CancelToken;
|
|
|
|
|
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 4098:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var AxiosError = __nccwpck_require__(2093);
|
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
|
|
|
|
*
|
|
|
|
|
* @class
|
|
|
|
|
* @param {string=} message The message.
|
|
|
|
|
*/
|
|
|
|
|
function CanceledError(message) {
|
|
|
|
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
|
|
|
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED);
|
|
|
|
|
this.name = 'CanceledError';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
utils.inherits(CanceledError, AxiosError, {
|
|
|
|
|
__CANCEL__: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = CanceledError;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 4057:
|
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function isCancel(value) {
|
|
|
|
|
return !!(value && value.__CANCEL__);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ 8178:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
var buildURL = __nccwpck_require__(646);
|
|
|
|
|
var InterceptorManager = __nccwpck_require__(3214);
|
|
|
|
|
var dispatchRequest = __nccwpck_require__(5062);
|
|
|
|
|
var mergeConfig = __nccwpck_require__(4831);
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var buildFullPath = __nccwpck_require__(1934);
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var validator = __nccwpck_require__(1632);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var validators = validator.validators;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
/**
|
2021-05-07 16:07:16 +08:00
|
|
|
|
* Create a new instance of Axios
|
2021-04-29 15:57:10 +08:00
|
|
|
|
*
|
2021-05-07 16:07:16 +08:00
|
|
|
|
* @param {Object} instanceConfig The default config for the instance
|
2021-04-29 15:57:10 +08:00
|
|
|
|
*/
|
2021-05-07 16:07:16 +08:00
|
|
|
|
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)
|
|
|
|
|
*/
|
2022-04-27 10:20:40 +08:00
|
|
|
|
Axios.prototype.request = function request(configOrUrl, config) {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/*eslint no-param-reassign:0*/
|
|
|
|
|
// Allow for axios('example/url'[, config]) a la fetch API
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (typeof configOrUrl === 'string') {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
config = config || {};
|
2022-04-27 10:20:40 +08:00
|
|
|
|
config.url = configOrUrl;
|
|
|
|
|
} else {
|
|
|
|
|
config = configOrUrl || {};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
config = mergeConfig(this.defaults, config);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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';
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var transitional = config.transitional;
|
|
|
|
|
|
|
|
|
|
if (transitional !== undefined) {
|
|
|
|
|
validator.assertOptions(transitional, {
|
|
|
|
|
silentJSONParsing: validators.transitional(validators.boolean),
|
|
|
|
|
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
|
|
|
clarifyTimeoutError: validators.transitional(validators.boolean)
|
|
|
|
|
}, false);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
// filter out skipped interceptors
|
|
|
|
|
var requestInterceptorChain = [];
|
|
|
|
|
var synchronousRequestInterceptors = true;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
|
|
|
|
|
|
|
|
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var responseInterceptorChain = [];
|
2021-05-07 16:07:16 +08:00
|
|
|
|
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var promise;
|
|
|
|
|
|
|
|
|
|
if (!synchronousRequestInterceptors) {
|
|
|
|
|
var chain = [dispatchRequest, undefined];
|
|
|
|
|
|
|
|
|
|
Array.prototype.unshift.apply(chain, requestInterceptorChain);
|
|
|
|
|
chain = chain.concat(responseInterceptorChain);
|
|
|
|
|
|
|
|
|
|
promise = Promise.resolve(config);
|
|
|
|
|
while (chain.length) {
|
|
|
|
|
promise = promise.then(chain.shift(), chain.shift());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return promise;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var newConfig = config;
|
|
|
|
|
while (requestInterceptorChain.length) {
|
|
|
|
|
var onFulfilled = requestInterceptorChain.shift();
|
|
|
|
|
var onRejected = requestInterceptorChain.shift();
|
|
|
|
|
try {
|
|
|
|
|
newConfig = onFulfilled(newConfig);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
onRejected(error);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
promise = dispatchRequest(newConfig);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
return Promise.reject(error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (responseInterceptorChain.length) {
|
|
|
|
|
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
return promise;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
};
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
Axios.prototype.getUri = function getUri(config) {
|
|
|
|
|
config = mergeConfig(this.defaults, config);
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var fullPath = buildFullPath(config.baseURL, config.url);
|
|
|
|
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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
|
|
|
|
|
}));
|
|
|
|
|
};
|
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
|
|
|
/*eslint func-names:0*/
|
2022-04-27 10:20:40 +08:00
|
|
|
|
|
|
|
|
|
function generateHTTPMethod(isForm) {
|
|
|
|
|
return function httpMethod(url, data, config) {
|
|
|
|
|
return this.request(mergeConfig(config || {}, {
|
|
|
|
|
method: method,
|
|
|
|
|
headers: isForm ? {
|
|
|
|
|
'Content-Type': 'multipart/form-data'
|
|
|
|
|
} : {},
|
|
|
|
|
url: url,
|
|
|
|
|
data: data
|
|
|
|
|
}));
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Axios.prototype[method] = generateHTTPMethod();
|
|
|
|
|
|
|
|
|
|
Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
module.exports = Axios;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 2093:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create an Error with the specified message, config, error code, request and response.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} message The error message.
|
|
|
|
|
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
|
|
|
* @param {Object} [config] The config.
|
|
|
|
|
* @param {Object} [request] The request.
|
|
|
|
|
* @param {Object} [response] The response.
|
|
|
|
|
* @returns {Error} The created error.
|
|
|
|
|
*/
|
|
|
|
|
function AxiosError(message, code, config, request, response) {
|
|
|
|
|
Error.call(this);
|
|
|
|
|
this.message = message;
|
|
|
|
|
this.name = 'AxiosError';
|
|
|
|
|
code && (this.code = code);
|
|
|
|
|
config && (this.config = config);
|
|
|
|
|
request && (this.request = request);
|
|
|
|
|
response && (this.response = response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
utils.inherits(AxiosError, 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,
|
|
|
|
|
status: this.response && this.response.status ? this.response.status : null
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var prototype = AxiosError.prototype;
|
|
|
|
|
var descriptors = {};
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
'ERR_BAD_OPTION_VALUE',
|
|
|
|
|
'ERR_BAD_OPTION',
|
|
|
|
|
'ECONNABORTED',
|
|
|
|
|
'ETIMEDOUT',
|
|
|
|
|
'ERR_NETWORK',
|
|
|
|
|
'ERR_FR_TOO_MANY_REDIRECTS',
|
|
|
|
|
'ERR_DEPRECATED',
|
|
|
|
|
'ERR_BAD_RESPONSE',
|
|
|
|
|
'ERR_BAD_REQUEST',
|
|
|
|
|
'ERR_CANCELED'
|
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
].forEach(function(code) {
|
|
|
|
|
descriptors[code] = {value: code};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Object.defineProperties(AxiosError, descriptors);
|
|
|
|
|
Object.defineProperty(prototype, 'isAxiosError', {value: true});
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
AxiosError.from = function(error, code, config, request, response, customProps) {
|
|
|
|
|
var axiosError = Object.create(prototype);
|
|
|
|
|
|
|
|
|
|
utils.toFlatObject(error, axiosError, function filter(obj) {
|
|
|
|
|
return obj !== Error.prototype;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AxiosError.call(axiosError, error.message, code, config, request, response);
|
|
|
|
|
|
|
|
|
|
axiosError.name = error.name;
|
|
|
|
|
|
|
|
|
|
customProps && Object.assign(axiosError, customProps);
|
|
|
|
|
|
|
|
|
|
return axiosError;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = AxiosError;
|
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ 3214:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
"use strict";
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
*/
|
2021-12-27 13:47:39 +08:00
|
|
|
|
InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
this.handlers.push({
|
|
|
|
|
fulfilled: fulfilled,
|
2021-12-27 13:47:39 +08:00
|
|
|
|
rejected: rejected,
|
|
|
|
|
synchronous: options ? options.synchronous : false,
|
|
|
|
|
runWhen: options ? options.runWhen : null
|
2021-05-07 16:07:16 +08:00
|
|
|
|
});
|
|
|
|
|
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;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 1934:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var isAbsoluteURL = __nccwpck_require__(1301);
|
|
|
|
|
var combineURLs = __nccwpck_require__(7189);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
return requestedURL;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ 5062:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
var transformData = __nccwpck_require__(9812);
|
|
|
|
|
var isCancel = __nccwpck_require__(4057);
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var defaults = __nccwpck_require__(1626);
|
|
|
|
|
var CanceledError = __nccwpck_require__(4098);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/**
|
2022-04-27 10:20:40 +08:00
|
|
|
|
* Throws a `CanceledError` if cancellation has been requested.
|
2021-05-07 16:07:16 +08:00
|
|
|
|
*/
|
|
|
|
|
function throwIfCancellationRequested(config) {
|
|
|
|
|
if (config.cancelToken) {
|
|
|
|
|
config.cancelToken.throwIfRequested();
|
|
|
|
|
}
|
2021-12-27 13:47:39 +08:00
|
|
|
|
|
|
|
|
|
if (config.signal && config.signal.aborted) {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
throw new CanceledError();
|
2021-12-27 13:47:39 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-05-07 16:07:16 +08:00
|
|
|
|
* Dispatch a request to the server using the configured adapter.
|
2021-04-29 15:57:10 +08:00
|
|
|
|
*
|
2021-05-07 16:07:16 +08:00
|
|
|
|
* @param {object} config The config that is to be used for the request
|
|
|
|
|
* @returns {Promise} The Promise to be fulfilled
|
2021-04-29 15:57:10 +08:00
|
|
|
|
*/
|
2021-05-07 16:07:16 +08:00
|
|
|
|
module.exports = function dispatchRequest(config) {
|
|
|
|
|
throwIfCancellationRequested(config);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Ensure headers exist
|
|
|
|
|
config.headers = config.headers || {};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Transform request data
|
2021-12-27 13:47:39 +08:00
|
|
|
|
config.data = transformData.call(
|
|
|
|
|
config,
|
2021-05-07 16:07:16 +08:00
|
|
|
|
config.data,
|
|
|
|
|
config.headers,
|
|
|
|
|
config.transformRequest
|
|
|
|
|
);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Flatten headers
|
|
|
|
|
config.headers = utils.merge(
|
|
|
|
|
config.headers.common || {},
|
|
|
|
|
config.headers[config.method] || {},
|
|
|
|
|
config.headers
|
|
|
|
|
);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
utils.forEach(
|
|
|
|
|
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
|
|
|
|
function cleanHeaderConfig(method) {
|
|
|
|
|
delete config.headers[method];
|
|
|
|
|
}
|
|
|
|
|
);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var adapter = config.adapter || defaults.adapter;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
|
|
|
throwIfCancellationRequested(config);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Transform response data
|
2021-12-27 13:47:39 +08:00
|
|
|
|
response.data = transformData.call(
|
|
|
|
|
config,
|
2021-05-07 16:07:16 +08:00
|
|
|
|
response.data,
|
|
|
|
|
response.headers,
|
|
|
|
|
config.transformResponse
|
|
|
|
|
);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
return response;
|
|
|
|
|
}, function onAdapterRejection(reason) {
|
|
|
|
|
if (!isCancel(reason)) {
|
|
|
|
|
throwIfCancellationRequested(config);
|
|
|
|
|
|
|
|
|
|
// Transform response data
|
|
|
|
|
if (reason && reason.response) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
reason.response.data = transformData.call(
|
|
|
|
|
config,
|
2021-05-07 16:07:16 +08:00
|
|
|
|
reason.response.data,
|
|
|
|
|
reason.response.headers,
|
|
|
|
|
config.transformResponse
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Promise.reject(reason);
|
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 4831:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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 = {};
|
|
|
|
|
|
|
|
|
|
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();
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
return source;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
// eslint-disable-next-line consistent-return
|
2021-05-07 16:07:16 +08:00
|
|
|
|
function mergeDeepProperties(prop) {
|
|
|
|
|
if (!utils.isUndefined(config2[prop])) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
return getMergedValue(config1[prop], config2[prop]);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
} else if (!utils.isUndefined(config1[prop])) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
return getMergedValue(undefined, config1[prop]);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
// eslint-disable-next-line consistent-return
|
|
|
|
|
function valueFromConfig2(prop) {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (!utils.isUndefined(config2[prop])) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
return getMergedValue(undefined, config2[prop]);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2021-12-27 13:47:39 +08:00
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
// eslint-disable-next-line consistent-return
|
|
|
|
|
function defaultToConfig2(prop) {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (!utils.isUndefined(config2[prop])) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
return getMergedValue(undefined, config2[prop]);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
} else if (!utils.isUndefined(config1[prop])) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
return getMergedValue(undefined, config1[prop]);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2021-12-27 13:47:39 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
// eslint-disable-next-line consistent-return
|
|
|
|
|
function mergeDirectKeys(prop) {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (prop in config2) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
return getMergedValue(config1[prop], config2[prop]);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
} else if (prop in config1) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
return getMergedValue(undefined, config1[prop]);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2021-12-27 13:47:39 +08:00
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var mergeMap = {
|
|
|
|
|
'url': valueFromConfig2,
|
|
|
|
|
'method': valueFromConfig2,
|
|
|
|
|
'data': valueFromConfig2,
|
|
|
|
|
'baseURL': defaultToConfig2,
|
|
|
|
|
'transformRequest': defaultToConfig2,
|
|
|
|
|
'transformResponse': defaultToConfig2,
|
|
|
|
|
'paramsSerializer': defaultToConfig2,
|
|
|
|
|
'timeout': defaultToConfig2,
|
|
|
|
|
'timeoutMessage': defaultToConfig2,
|
|
|
|
|
'withCredentials': defaultToConfig2,
|
|
|
|
|
'adapter': defaultToConfig2,
|
|
|
|
|
'responseType': defaultToConfig2,
|
|
|
|
|
'xsrfCookieName': defaultToConfig2,
|
|
|
|
|
'xsrfHeaderName': defaultToConfig2,
|
|
|
|
|
'onUploadProgress': defaultToConfig2,
|
|
|
|
|
'onDownloadProgress': defaultToConfig2,
|
|
|
|
|
'decompress': defaultToConfig2,
|
|
|
|
|
'maxContentLength': defaultToConfig2,
|
|
|
|
|
'maxBodyLength': defaultToConfig2,
|
2022-04-27 10:20:40 +08:00
|
|
|
|
'beforeRedirect': defaultToConfig2,
|
2021-12-27 13:47:39 +08:00
|
|
|
|
'transport': defaultToConfig2,
|
|
|
|
|
'httpAgent': defaultToConfig2,
|
|
|
|
|
'httpsAgent': defaultToConfig2,
|
|
|
|
|
'cancelToken': defaultToConfig2,
|
|
|
|
|
'socketPath': defaultToConfig2,
|
|
|
|
|
'responseEncoding': defaultToConfig2,
|
|
|
|
|
'validateStatus': mergeDirectKeys
|
|
|
|
|
};
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
|
|
|
|
|
var merge = mergeMap[prop] || mergeDeepProperties;
|
|
|
|
|
var configValue = merge(prop);
|
|
|
|
|
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
|
|
|
});
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
|
|
|
|
return config;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 3211:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var AxiosError = __nccwpck_require__(2093);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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 {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
reject(new AxiosError(
|
2021-05-07 16:07:16 +08:00
|
|
|
|
'Request failed with status code ' + response.status,
|
2022-04-27 10:20:40 +08:00
|
|
|
|
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
2021-05-07 16:07:16 +08:00
|
|
|
|
response.config,
|
|
|
|
|
response.request,
|
|
|
|
|
response
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 9812:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __nccwpck_require__(328);
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var defaults = __nccwpck_require__(1626);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var context = this || defaults;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/*eslint no-param-reassign:0*/
|
|
|
|
|
utils.forEach(fns, function transform(fn) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
data = fn.call(context, data, headers);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 7024:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line strict
|
|
|
|
|
module.exports = __nccwpck_require__(4334);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 1626:
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
var normalizeHeaderName = __nccwpck_require__(6240);
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var AxiosError = __nccwpck_require__(2093);
|
|
|
|
|
var transitionalDefaults = __nccwpck_require__(936);
|
|
|
|
|
var toFormData = __nccwpck_require__(470);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
|
|
|
|
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 = __nccwpck_require__(3454);
|
|
|
|
|
} else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
|
|
|
|
|
// For node use HTTP adapter
|
|
|
|
|
adapter = __nccwpck_require__(8104);
|
|
|
|
|
}
|
|
|
|
|
return adapter;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
function stringifySafely(rawValue, parser, encoder) {
|
|
|
|
|
if (utils.isString(rawValue)) {
|
|
|
|
|
try {
|
|
|
|
|
(parser || JSON.parse)(rawValue);
|
|
|
|
|
return utils.trim(rawValue);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
if (e.name !== 'SyntaxError') {
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (encoder || JSON.stringify)(rawValue);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var defaults = {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
transitional: transitionalDefaults,
|
2021-12-27 13:47:39 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
adapter: getDefaultAdapter(),
|
|
|
|
|
|
|
|
|
|
transformRequest: [function transformRequest(data, headers) {
|
|
|
|
|
normalizeHeaderName(headers, 'Accept');
|
|
|
|
|
normalizeHeaderName(headers, 'Content-Type');
|
2021-12-27 13:47:39 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
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();
|
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
|
|
|
|
|
var isObjectPayload = utils.isObject(data);
|
|
|
|
|
var contentType = headers && headers['Content-Type'];
|
|
|
|
|
|
|
|
|
|
var isFileList;
|
|
|
|
|
|
|
|
|
|
if ((isFileList = utils.isFileList(data)) || (isObjectPayload && contentType === 'multipart/form-data')) {
|
|
|
|
|
var _FormData = this.env && this.env.FormData;
|
|
|
|
|
return toFormData(isFileList ? {'files[]': data} : data, _FormData && new _FormData());
|
|
|
|
|
} else if (isObjectPayload || contentType === 'application/json') {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
setContentTypeIfUnset(headers, 'application/json');
|
|
|
|
|
return stringifySafely(data);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
return data;
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
|
|
transformResponse: [function transformResponse(data) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
var transitional = this.transitional || defaults.transitional;
|
|
|
|
|
var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
|
|
|
var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
|
|
|
var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
|
|
|
|
|
|
|
|
|
|
if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
try {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
return JSON.parse(data);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
if (strictJSONParsing) {
|
|
|
|
|
if (e.name === 'SyntaxError') {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
2021-12-27 13:47:39 +08:00
|
|
|
|
}
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-12-27 13:47:39 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
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,
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
env: {
|
|
|
|
|
FormData: __nccwpck_require__(7024)
|
|
|
|
|
},
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
validateStatus: function validateStatus(status) {
|
|
|
|
|
return status >= 200 && status < 300;
|
2021-12-27 13:47:39 +08:00
|
|
|
|
},
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
headers: {
|
|
|
|
|
common: {
|
|
|
|
|
'Accept': 'application/json, text/plain, */*'
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 936:
|
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
silentJSONParsing: true,
|
|
|
|
|
forcedJSONParsing: true,
|
|
|
|
|
clarifyTimeoutError: false
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 4322:
|
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
"version": "0.27.1"
|
2021-12-27 13:47:39 +08:00
|
|
|
|
};
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 7065:
|
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
|
|
"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);
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 646:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
|
|
|
|
|
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);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 7189:
|
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
|
|
"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;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 1545:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
|
|
|
|
|
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);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
})() :
|
|
|
|
|
|
|
|
|
|
// 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() {}
|
|
|
|
|
};
|
|
|
|
|
})()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 1301:
|
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
|
|
"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.
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 650:
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/**
|
|
|
|
|
* 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) {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return utils.isObject(payload) && (payload.isAxiosError === true);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 3608:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
|
|
|
|
|
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;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
};
|
|
|
|
|
})()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 6240:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
|
|
|
|
|
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];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 6455:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 4850:
|
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
|
|
"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);
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 470:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var utils = __nccwpck_require__(328);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convert a data object to FormData
|
|
|
|
|
* @param {Object} obj
|
|
|
|
|
* @param {?Object} [formData]
|
|
|
|
|
* @returns {Object}
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
function toFormData(obj, formData) {
|
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
|
|
|
|
formData = formData || new FormData();
|
|
|
|
|
|
|
|
|
|
var stack = [];
|
|
|
|
|
|
|
|
|
|
function convertValue(value) {
|
|
|
|
|
if (value === null) return '';
|
|
|
|
|
|
|
|
|
|
if (utils.isDate(value)) {
|
|
|
|
|
return value.toISOString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
|
|
|
|
|
return typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function build(data, parentKey) {
|
|
|
|
|
if (utils.isPlainObject(data) || utils.isArray(data)) {
|
|
|
|
|
if (stack.indexOf(data) !== -1) {
|
|
|
|
|
throw Error('Circular reference detected in ' + parentKey);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stack.push(data);
|
|
|
|
|
|
|
|
|
|
utils.forEach(data, function each(value, key) {
|
|
|
|
|
if (utils.isUndefined(value)) return;
|
|
|
|
|
var fullKey = parentKey ? parentKey + '.' + key : key;
|
|
|
|
|
var arr;
|
|
|
|
|
|
|
|
|
|
if (value && !parentKey && typeof value === 'object') {
|
|
|
|
|
if (utils.endsWith(key, '{}')) {
|
|
|
|
|
// eslint-disable-next-line no-param-reassign
|
|
|
|
|
value = JSON.stringify(value);
|
|
|
|
|
} else if (utils.endsWith(key, '[]') && (arr = utils.toArray(value))) {
|
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
arr.forEach(function(el) {
|
|
|
|
|
!utils.isUndefined(el) && formData.append(fullKey, convertValue(el));
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
build(value, fullKey);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
stack.pop();
|
|
|
|
|
} else {
|
|
|
|
|
formData.append(parentKey, convertValue(data));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
build(obj);
|
|
|
|
|
|
|
|
|
|
return formData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = toFormData;
|
|
|
|
|
|
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 1632:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var VERSION = (__nccwpck_require__(4322).version);
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var AxiosError = __nccwpck_require__(2093);
|
2021-12-27 13:47:39 +08:00
|
|
|
|
|
|
|
|
|
var validators = {};
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
|
|
|
|
|
validators[type] = function validator(thing) {
|
|
|
|
|
return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var deprecatedWarnings = {};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Transitional option validator
|
|
|
|
|
* @param {function|boolean?} validator - set to false if the transitional option has been removed
|
|
|
|
|
* @param {string?} version - deprecated version / removed since version
|
|
|
|
|
* @param {string?} message - some message with additional info
|
|
|
|
|
* @returns {function}
|
|
|
|
|
*/
|
|
|
|
|
validators.transitional = function transitional(validator, version, message) {
|
|
|
|
|
function formatMessage(opt, desc) {
|
|
|
|
|
return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
return function(value, opt, opts) {
|
|
|
|
|
if (validator === false) {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
throw new AxiosError(
|
|
|
|
|
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
|
|
|
|
|
AxiosError.ERR_DEPRECATED
|
|
|
|
|
);
|
2021-12-27 13:47:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (version && !deprecatedWarnings[opt]) {
|
|
|
|
|
deprecatedWarnings[opt] = true;
|
|
|
|
|
// eslint-disable-next-line no-console
|
|
|
|
|
console.warn(
|
|
|
|
|
formatMessage(
|
|
|
|
|
opt,
|
|
|
|
|
' has been deprecated since v' + version + ' and will be removed in the near future'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return validator ? validator(value, opt, opts) : true;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Assert object's properties type
|
|
|
|
|
* @param {object} options
|
|
|
|
|
* @param {object} schema
|
|
|
|
|
* @param {boolean?} allowUnknown
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function assertOptions(options, schema, allowUnknown) {
|
|
|
|
|
if (typeof options !== 'object') {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
|
2021-12-27 13:47:39 +08:00
|
|
|
|
}
|
|
|
|
|
var keys = Object.keys(options);
|
|
|
|
|
var i = keys.length;
|
|
|
|
|
while (i-- > 0) {
|
|
|
|
|
var opt = keys[i];
|
|
|
|
|
var validator = schema[opt];
|
|
|
|
|
if (validator) {
|
|
|
|
|
var value = options[opt];
|
|
|
|
|
var result = value === undefined || validator(value, opt, options);
|
|
|
|
|
if (result !== true) {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
|
2021-12-27 13:47:39 +08:00
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (allowUnknown !== true) {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
|
2021-12-27 13:47:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
assertOptions: assertOptions,
|
|
|
|
|
validators: validators
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 328:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var bind = __nccwpck_require__(7065);
|
|
|
|
|
|
|
|
|
|
// utils is a library of generic helper functions non-specific to axios
|
|
|
|
|
|
|
|
|
|
var toString = Object.prototype.toString;
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
var kindOf = (function(cache) {
|
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
return function(thing) {
|
|
|
|
|
var str = toString.call(thing);
|
|
|
|
|
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
|
|
|
};
|
|
|
|
|
})(Object.create(null));
|
|
|
|
|
|
|
|
|
|
function kindOfTest(type) {
|
|
|
|
|
type = type.toLowerCase();
|
|
|
|
|
return function isKindOf(thing) {
|
|
|
|
|
return kindOf(thing) === type;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/**
|
|
|
|
|
* 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) {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return Array.isArray(val);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
*
|
2022-04-27 10:20:40 +08:00
|
|
|
|
* @function
|
2021-05-07 16:07:16 +08:00
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
|
|
|
|
*/
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var isArrayBuffer = kindOfTest('ArrayBuffer');
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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 {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
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) {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (kindOf(val) !== 'object') {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var prototype = Object.getPrototypeOf(val);
|
|
|
|
|
return prototype === null || prototype === Object.prototype;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is a Date
|
|
|
|
|
*
|
2022-04-27 10:20:40 +08:00
|
|
|
|
* @function
|
2021-05-07 16:07:16 +08:00
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is a Date, otherwise false
|
|
|
|
|
*/
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var isDate = kindOfTest('Date');
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is a File
|
|
|
|
|
*
|
2022-04-27 10:20:40 +08:00
|
|
|
|
* @function
|
2021-05-07 16:07:16 +08:00
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is a File, otherwise false
|
|
|
|
|
*/
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var isFile = kindOfTest('File');
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is a Blob
|
|
|
|
|
*
|
2022-04-27 10:20:40 +08:00
|
|
|
|
* @function
|
2021-05-07 16:07:16 +08:00
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is a Blob, otherwise false
|
|
|
|
|
*/
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var isBlob = kindOfTest('Blob');
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if a value is a FileList
|
|
|
|
|
*
|
|
|
|
|
* @function
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is a File, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
var isFileList = kindOfTest('FileList');
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-04-27 10:20:40 +08:00
|
|
|
|
* Determine if a value is a FormData
|
2021-05-07 16:07:16 +08:00
|
|
|
|
*
|
2022-04-27 10:20:40 +08:00
|
|
|
|
* @param {Object} thing The value to test
|
|
|
|
|
* @returns {boolean} True if value is an FormData, otherwise false
|
2021-05-07 16:07:16 +08:00
|
|
|
|
*/
|
2022-04-27 10:20:40 +08:00
|
|
|
|
function isFormData(thing) {
|
|
|
|
|
var pattern = '[object FormData]';
|
|
|
|
|
return thing && (
|
|
|
|
|
(typeof FormData === 'function' && thing instanceof FormData) ||
|
|
|
|
|
toString.call(thing) === pattern ||
|
|
|
|
|
(isFunction(thing.toString) && thing.toString() === pattern)
|
|
|
|
|
);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-04-27 10:20:40 +08:00
|
|
|
|
* Determine if a value is a URLSearchParams object
|
|
|
|
|
* @function
|
|
|
|
|
* @param {Object} val The value to test
|
|
|
|
|
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
|
|
|
|
|
*/
|
|
|
|
|
var isURLSearchParams = kindOfTest('URLSearchParams');
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Trim excess whitespace off the beginning and end of a string
|
|
|
|
|
*
|
|
|
|
|
* @param {String} str The String to trim
|
2021-05-07 16:07:16 +08:00
|
|
|
|
* @returns {String} The String freed of excess whitespace
|
|
|
|
|
*/
|
|
|
|
|
function trim(str) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
} 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;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* Inherit the prototype methods from one constructor into another
|
|
|
|
|
* @param {function} constructor
|
|
|
|
|
* @param {function} superConstructor
|
|
|
|
|
* @param {object} [props]
|
|
|
|
|
* @param {object} [descriptors]
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function inherits(constructor, superConstructor, props, descriptors) {
|
|
|
|
|
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
|
|
|
|
constructor.prototype.constructor = constructor;
|
|
|
|
|
props && Object.assign(constructor.prototype, props);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Resolve object with deep prototype chain to a flat object
|
|
|
|
|
* @param {Object} sourceObj source object
|
|
|
|
|
* @param {Object} [destObj]
|
|
|
|
|
* @param {Function} [filter]
|
|
|
|
|
* @returns {Object}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function toFlatObject(sourceObj, destObj, filter) {
|
|
|
|
|
var props;
|
|
|
|
|
var i;
|
|
|
|
|
var prop;
|
|
|
|
|
var merged = {};
|
|
|
|
|
|
|
|
|
|
destObj = destObj || {};
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
props = Object.getOwnPropertyNames(sourceObj);
|
|
|
|
|
i = props.length;
|
|
|
|
|
while (i-- > 0) {
|
|
|
|
|
prop = props[i];
|
|
|
|
|
if (!merged[prop]) {
|
|
|
|
|
destObj[prop] = sourceObj[prop];
|
|
|
|
|
merged[prop] = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sourceObj = Object.getPrototypeOf(sourceObj);
|
|
|
|
|
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
|
|
|
|
|
|
|
|
|
return destObj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* determines whether a string ends with the characters of a specified string
|
|
|
|
|
* @param {String} str
|
|
|
|
|
* @param {String} searchString
|
|
|
|
|
* @param {Number} [position= 0]
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
|
|
|
|
function endsWith(str, searchString, position) {
|
|
|
|
|
str = String(str);
|
|
|
|
|
if (position === undefined || position > str.length) {
|
|
|
|
|
position = str.length;
|
|
|
|
|
}
|
|
|
|
|
position -= searchString.length;
|
|
|
|
|
var lastIndex = str.indexOf(searchString, position);
|
|
|
|
|
return lastIndex !== -1 && lastIndex === position;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns new array from array like object
|
|
|
|
|
* @param {*} [thing]
|
|
|
|
|
* @returns {Array}
|
|
|
|
|
*/
|
|
|
|
|
function toArray(thing) {
|
|
|
|
|
if (!thing) return null;
|
|
|
|
|
var i = thing.length;
|
|
|
|
|
if (isUndefined(i)) return null;
|
|
|
|
|
var arr = new Array(i);
|
|
|
|
|
while (i-- > 0) {
|
|
|
|
|
arr[i] = thing[i];
|
|
|
|
|
}
|
|
|
|
|
return arr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
var isTypedArray = (function(TypedArray) {
|
|
|
|
|
// eslint-disable-next-line func-names
|
|
|
|
|
return function(thing) {
|
|
|
|
|
return TypedArray && thing instanceof TypedArray;
|
|
|
|
|
};
|
|
|
|
|
})(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array));
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
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,
|
2022-04-27 10:20:40 +08:00
|
|
|
|
stripBOM: stripBOM,
|
|
|
|
|
inherits: inherits,
|
|
|
|
|
toFlatObject: toFlatObject,
|
|
|
|
|
kindOf: kindOf,
|
|
|
|
|
kindOfTest: kindOfTest,
|
|
|
|
|
endsWith: endsWith,
|
|
|
|
|
toArray: toArray,
|
|
|
|
|
isTypedArray: isTypedArray,
|
|
|
|
|
isFileList: isFileList
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 5443:
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var util = __nccwpck_require__(3837);
|
|
|
|
|
var Stream = (__nccwpck_require__(2781).Stream);
|
|
|
|
|
var DelayedStream = __nccwpck_require__(8611);
|
|
|
|
|
|
|
|
|
|
module.exports = CombinedStream;
|
|
|
|
|
function CombinedStream() {
|
|
|
|
|
this.writable = false;
|
|
|
|
|
this.readable = true;
|
|
|
|
|
this.dataSize = 0;
|
|
|
|
|
this.maxDataSize = 2 * 1024 * 1024;
|
|
|
|
|
this.pauseStreams = true;
|
|
|
|
|
|
|
|
|
|
this._released = false;
|
|
|
|
|
this._streams = [];
|
|
|
|
|
this._currentStream = null;
|
|
|
|
|
this._insideLoop = false;
|
|
|
|
|
this._pendingNext = false;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
util.inherits(CombinedStream, Stream);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.create = function(options) {
|
|
|
|
|
var combinedStream = new this();
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
options = options || {};
|
|
|
|
|
for (var option in options) {
|
|
|
|
|
combinedStream[option] = options[option];
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return combinedStream;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.isStreamLike = function(stream) {
|
|
|
|
|
return (typeof stream !== 'function')
|
|
|
|
|
&& (typeof stream !== 'string')
|
|
|
|
|
&& (typeof stream !== 'boolean')
|
|
|
|
|
&& (typeof stream !== 'number')
|
|
|
|
|
&& (!Buffer.isBuffer(stream));
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype.append = function(stream) {
|
|
|
|
|
var isStreamLike = CombinedStream.isStreamLike(stream);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (isStreamLike) {
|
|
|
|
|
if (!(stream instanceof DelayedStream)) {
|
|
|
|
|
var newStream = DelayedStream.create(stream, {
|
|
|
|
|
maxDataSize: Infinity,
|
|
|
|
|
pauseStream: this.pauseStreams,
|
|
|
|
|
});
|
|
|
|
|
stream.on('data', this._checkDataSize.bind(this));
|
|
|
|
|
stream = newStream;
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this._handleErrors(stream);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (this.pauseStreams) {
|
|
|
|
|
stream.pause();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this._streams.push(stream);
|
|
|
|
|
return this;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype.pipe = function(dest, options) {
|
|
|
|
|
Stream.prototype.pipe.call(this, dest, options);
|
|
|
|
|
this.resume();
|
|
|
|
|
return dest;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype._getNext = function() {
|
|
|
|
|
this._currentStream = null;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (this._insideLoop) {
|
|
|
|
|
this._pendingNext = true;
|
|
|
|
|
return; // defer call
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this._insideLoop = true;
|
|
|
|
|
try {
|
|
|
|
|
do {
|
|
|
|
|
this._pendingNext = false;
|
|
|
|
|
this._realGetNext();
|
|
|
|
|
} while (this._pendingNext);
|
|
|
|
|
} finally {
|
|
|
|
|
this._insideLoop = false;
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype._realGetNext = function() {
|
|
|
|
|
var stream = this._streams.shift();
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (typeof stream == 'undefined') {
|
|
|
|
|
this.end();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (typeof stream !== 'function') {
|
|
|
|
|
this._pipeNext(stream);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var getStream = stream;
|
|
|
|
|
getStream(function(stream) {
|
|
|
|
|
var isStreamLike = CombinedStream.isStreamLike(stream);
|
|
|
|
|
if (isStreamLike) {
|
|
|
|
|
stream.on('data', this._checkDataSize.bind(this));
|
|
|
|
|
this._handleErrors(stream);
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this._pipeNext(stream);
|
|
|
|
|
}.bind(this));
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype._pipeNext = function(stream) {
|
|
|
|
|
this._currentStream = stream;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var isStreamLike = CombinedStream.isStreamLike(stream);
|
|
|
|
|
if (isStreamLike) {
|
|
|
|
|
stream.on('end', this._getNext.bind(this));
|
|
|
|
|
stream.pipe(this, {end: false});
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var value = stream;
|
|
|
|
|
this.write(value);
|
|
|
|
|
this._getNext();
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype._handleErrors = function(stream) {
|
|
|
|
|
var self = this;
|
|
|
|
|
stream.on('error', function(err) {
|
|
|
|
|
self._emitError(err);
|
|
|
|
|
});
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype.write = function(data) {
|
|
|
|
|
this.emit('data', data);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype.pause = function() {
|
|
|
|
|
if (!this.pauseStreams) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if(this.pauseStreams && this._currentStream && typeof(this._currentStream.pause) == 'function') this._currentStream.pause();
|
|
|
|
|
this.emit('pause');
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype.resume = function() {
|
|
|
|
|
if (!this._released) {
|
|
|
|
|
this._released = true;
|
|
|
|
|
this.writable = true;
|
|
|
|
|
this._getNext();
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if(this.pauseStreams && this._currentStream && typeof(this._currentStream.resume) == 'function') this._currentStream.resume();
|
|
|
|
|
this.emit('resume');
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype.end = function() {
|
|
|
|
|
this._reset();
|
|
|
|
|
this.emit('end');
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype.destroy = function() {
|
|
|
|
|
this._reset();
|
|
|
|
|
this.emit('close');
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype._reset = function() {
|
|
|
|
|
this.writable = false;
|
|
|
|
|
this._streams = [];
|
|
|
|
|
this._currentStream = null;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype._checkDataSize = function() {
|
|
|
|
|
this._updateDataSize();
|
|
|
|
|
if (this.dataSize <= this.maxDataSize) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var message =
|
|
|
|
|
'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.';
|
|
|
|
|
this._emitError(new Error(message));
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype._updateDataSize = function() {
|
|
|
|
|
this.dataSize = 0;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var self = this;
|
|
|
|
|
this._streams.forEach(function(stream) {
|
|
|
|
|
if (!stream.dataSize) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
self.dataSize += stream.dataSize;
|
|
|
|
|
});
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (this._currentStream && this._currentStream.dataSize) {
|
|
|
|
|
this.dataSize += this._currentStream.dataSize;
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.prototype._emitError = function(err) {
|
|
|
|
|
this._reset();
|
|
|
|
|
this.emit('error', err);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 8611:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var Stream = (__nccwpck_require__(2781).Stream);
|
|
|
|
|
var util = __nccwpck_require__(3837);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
module.exports = DelayedStream;
|
|
|
|
|
function DelayedStream() {
|
|
|
|
|
this.source = null;
|
|
|
|
|
this.dataSize = 0;
|
|
|
|
|
this.maxDataSize = 1024 * 1024;
|
|
|
|
|
this.pauseStream = true;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this._maxDataSizeExceeded = false;
|
|
|
|
|
this._released = false;
|
|
|
|
|
this._bufferedEvents = [];
|
|
|
|
|
}
|
|
|
|
|
util.inherits(DelayedStream, Stream);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
DelayedStream.create = function(source, options) {
|
|
|
|
|
var delayedStream = new this();
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
options = options || {};
|
|
|
|
|
for (var option in options) {
|
|
|
|
|
delayedStream[option] = options[option];
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
delayedStream.source = source;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var realEmit = source.emit;
|
|
|
|
|
source.emit = function() {
|
|
|
|
|
delayedStream._handleEmit(arguments);
|
|
|
|
|
return realEmit.apply(source, arguments);
|
|
|
|
|
};
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
source.on('error', function() {});
|
|
|
|
|
if (delayedStream.pauseStream) {
|
|
|
|
|
source.pause();
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return delayedStream;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
Object.defineProperty(DelayedStream.prototype, 'readable', {
|
|
|
|
|
configurable: true,
|
|
|
|
|
enumerable: true,
|
|
|
|
|
get: function() {
|
|
|
|
|
return this.source.readable;
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
DelayedStream.prototype.setEncoding = function() {
|
|
|
|
|
return this.source.setEncoding.apply(this.source, arguments);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
DelayedStream.prototype.resume = function() {
|
|
|
|
|
if (!this._released) {
|
|
|
|
|
this.release();
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this.source.resume();
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
DelayedStream.prototype.pause = function() {
|
|
|
|
|
this.source.pause();
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
DelayedStream.prototype.release = function() {
|
|
|
|
|
this._released = true;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this._bufferedEvents.forEach(function(args) {
|
|
|
|
|
this.emit.apply(this, args);
|
|
|
|
|
}.bind(this));
|
|
|
|
|
this._bufferedEvents = [];
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
DelayedStream.prototype.pipe = function() {
|
|
|
|
|
var r = Stream.prototype.pipe.apply(this, arguments);
|
|
|
|
|
this.resume();
|
|
|
|
|
return r;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
DelayedStream.prototype._handleEmit = function(args) {
|
|
|
|
|
if (this._released) {
|
|
|
|
|
this.emit.apply(this, args);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (args[0] === 'data') {
|
|
|
|
|
this.dataSize += args[1].length;
|
|
|
|
|
this._checkIfMaxDataSizeExceeded();
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this._bufferedEvents.push(args);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
|
|
|
|
|
if (this._maxDataSizeExceeded) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (this.dataSize <= this.maxDataSize) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this._maxDataSizeExceeded = true;
|
|
|
|
|
var message =
|
|
|
|
|
'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.'
|
|
|
|
|
this.emit('error', new Error(message));
|
2021-05-07 16:07:16 +08:00
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 1133:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var debug;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
module.exports = function () {
|
|
|
|
|
if (!debug) {
|
|
|
|
|
try {
|
|
|
|
|
/* eslint global-require: off */
|
|
|
|
|
debug = __nccwpck_require__(9975)("follow-redirects");
|
|
|
|
|
}
|
|
|
|
|
catch (error) { /* */ }
|
|
|
|
|
if (typeof debug !== "function") {
|
|
|
|
|
debug = function () { /* */ };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
debug.apply(null, arguments);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 7707:
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var url = __nccwpck_require__(7310);
|
|
|
|
|
var URL = url.URL;
|
|
|
|
|
var http = __nccwpck_require__(3685);
|
|
|
|
|
var https = __nccwpck_require__(5687);
|
|
|
|
|
var Writable = (__nccwpck_require__(2781).Writable);
|
|
|
|
|
var assert = __nccwpck_require__(9491);
|
|
|
|
|
var debug = __nccwpck_require__(1133);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// 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);
|
|
|
|
|
};
|
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Error types with codes
|
|
|
|
|
var RedirectionError = createErrorType(
|
|
|
|
|
"ERR_FR_REDIRECTION_FAILURE",
|
|
|
|
|
"Redirected request failed"
|
|
|
|
|
);
|
|
|
|
|
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"
|
|
|
|
|
);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// 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 = [];
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Attach a callback if passed
|
|
|
|
|
if (responseCallback) {
|
|
|
|
|
this.on("response", responseCallback);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// React to responses of native requests
|
|
|
|
|
var self = this;
|
|
|
|
|
this._onNativeResponse = function (response) {
|
|
|
|
|
self._processResponse(response);
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Perform the first request
|
|
|
|
|
this._performRequest();
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
RedirectableRequest.prototype = Object.create(Writable.prototype);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
RedirectableRequest.prototype.abort = function () {
|
|
|
|
|
abortRequest(this._currentRequest);
|
|
|
|
|
this.emit("abort");
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// 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();
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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();
|
|
|
|
|
}
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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);
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Clears a header value on the current native request
|
|
|
|
|
RedirectableRequest.prototype.removeHeader = function (name) {
|
|
|
|
|
delete this._options.headers[name];
|
|
|
|
|
this._currentRequest.removeHeader(name);
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Global timeout for all underlying requests
|
|
|
|
|
RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
|
|
|
|
|
var self = this;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
// Destroys the socket on timeout
|
2021-05-07 16:07:16 +08:00
|
|
|
|
function destroyOnTimeout(socket) {
|
|
|
|
|
socket.setTimeout(msecs);
|
|
|
|
|
socket.removeListener("timeout", socket.destroy);
|
|
|
|
|
socket.addListener("timeout", socket.destroy);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Sets up a timer to trigger a timeout event
|
|
|
|
|
function startTimer(socket) {
|
|
|
|
|
if (self._timeout) {
|
|
|
|
|
clearTimeout(self._timeout);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
self._timeout = setTimeout(function () {
|
|
|
|
|
self.emit("timeout");
|
|
|
|
|
clearTimer();
|
|
|
|
|
}, msecs);
|
|
|
|
|
destroyOnTimeout(socket);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
// Stops a timeout from triggering
|
2021-05-07 16:07:16 +08:00
|
|
|
|
function clearTimer() {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
// Clear the timeout
|
|
|
|
|
if (self._timeout) {
|
|
|
|
|
clearTimeout(self._timeout);
|
|
|
|
|
self._timeout = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clean up all attached listeners
|
|
|
|
|
self.removeListener("abort", clearTimer);
|
|
|
|
|
self.removeListener("error", clearTimer);
|
|
|
|
|
self.removeListener("response", clearTimer);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (callback) {
|
|
|
|
|
self.removeListener("timeout", callback);
|
|
|
|
|
}
|
2021-12-27 13:47:39 +08:00
|
|
|
|
if (!self.socket) {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
self._currentRequest.removeListener("socket", startTimer);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
// Attach callback if passed
|
|
|
|
|
if (callback) {
|
|
|
|
|
this.on("timeout", callback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Start the timer if or when the socket is opened
|
2021-05-07 16:07:16 +08:00
|
|
|
|
if (this.socket) {
|
|
|
|
|
startTimer(this.socket);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this._currentRequest.once("socket", startTimer);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
// Clean up on events
|
2021-05-07 16:07:16 +08:00
|
|
|
|
this.on("socket", destroyOnTimeout);
|
2021-12-27 13:47:39 +08:00
|
|
|
|
this.on("abort", clearTimer);
|
|
|
|
|
this.on("error", clearTimer);
|
|
|
|
|
this.on("response", clearTimer);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
return this;
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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);
|
|
|
|
|
};
|
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Proxy all public ClientRequest properties
|
|
|
|
|
["aborted", "connection", "socket"].forEach(function (property) {
|
|
|
|
|
Object.defineProperty(RedirectableRequest.prototype, property, {
|
|
|
|
|
get: function () { return this._currentRequest[property]; },
|
|
|
|
|
});
|
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
RedirectableRequest.prototype._sanitizeOptions = function (options) {
|
|
|
|
|
// Ensure headers are always present
|
|
|
|
|
if (!options.headers) {
|
|
|
|
|
options.headers = {};
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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];
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Create the native request
|
|
|
|
|
var request = this._currentRequest =
|
|
|
|
|
nativeProtocol.request(this._options, this._onNativeResponse);
|
|
|
|
|
this._currentUrl = url.format(this._options);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Set up event handlers
|
|
|
|
|
request._redirectable = this;
|
|
|
|
|
for (var e = 0; e < events.length; e++) {
|
|
|
|
|
request.on(events[e], eventHandlers[events[e]]);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}());
|
|
|
|
|
}
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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,
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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.
|
2022-04-27 10:20:40 +08:00
|
|
|
|
|
|
|
|
|
// If the response is not a redirect; return it as-is
|
2021-05-07 16:07:16 +08:00
|
|
|
|
var location = response.headers.location;
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (!location || this._options.followRedirects === false ||
|
|
|
|
|
statusCode < 300 || statusCode >= 400) {
|
|
|
|
|
response.responseUrl = this._currentUrl;
|
|
|
|
|
response.redirects = this._redirects;
|
|
|
|
|
this.emit("response", response);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Clean up
|
|
|
|
|
this._requestBodyBuffers = [];
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// The response is a redirect, so abort the current request
|
|
|
|
|
abortRequest(this._currentRequest);
|
|
|
|
|
// Discard the remainder of the response to avoid waiting for data
|
|
|
|
|
response.destroy();
|
2021-12-27 13:47:39 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
2021-12-27 13:47:39 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// 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);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Drop the Host header, as the redirect might lead to a different host
|
|
|
|
|
var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// If the redirect is relative, carry over the host of the last request
|
|
|
|
|
var currentUrlParts = url.parse(this._currentUrl);
|
|
|
|
|
var currentHost = currentHostHeader || currentUrlParts.host;
|
|
|
|
|
var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
|
|
|
|
|
url.format(Object.assign(currentUrlParts, { host: currentHost }));
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Determine the URL of the redirection
|
|
|
|
|
var redirectUrl;
|
|
|
|
|
try {
|
|
|
|
|
redirectUrl = url.resolve(currentUrl, location);
|
|
|
|
|
}
|
|
|
|
|
catch (cause) {
|
|
|
|
|
this.emit("error", new RedirectionError(cause));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create the redirected request
|
|
|
|
|
debug("redirecting to", redirectUrl);
|
|
|
|
|
this._isRedirect = true;
|
|
|
|
|
var redirectUrlParts = url.parse(redirectUrl);
|
|
|
|
|
Object.assign(this._options, redirectUrlParts);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Drop confidential headers when redirecting to a less secure protocol
|
|
|
|
|
// or to a different domain that is not a superdomain
|
|
|
|
|
if (redirectUrlParts.protocol !== currentUrlParts.protocol &&
|
|
|
|
|
redirectUrlParts.protocol !== "https:" ||
|
|
|
|
|
redirectUrlParts.host !== currentHost &&
|
|
|
|
|
!isSubdomain(redirectUrlParts.host, currentHost)) {
|
|
|
|
|
removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Evaluate the beforeRedirect callback
|
|
|
|
|
if (typeof this._options.beforeRedirect === "function") {
|
|
|
|
|
var responseDetails = { headers: response.headers };
|
2021-05-07 16:07:16 +08:00
|
|
|
|
try {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this._options.beforeRedirect.call(null, this._options, responseDetails);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
catch (err) {
|
|
|
|
|
this.emit("error", err);
|
|
|
|
|
return;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this._sanitizeOptions(this._options);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Perform the redirected request
|
|
|
|
|
try {
|
|
|
|
|
this._performRequest();
|
|
|
|
|
}
|
|
|
|
|
catch (cause) {
|
|
|
|
|
this.emit("error", new RedirectionError(cause));
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Wraps the key/value object of protocols with redirect functionality
|
|
|
|
|
function wrap(protocols) {
|
|
|
|
|
// Default settings
|
|
|
|
|
var exports = {
|
|
|
|
|
maxRedirects: 21,
|
|
|
|
|
maxBodyLength: 10 * 1024 * 1024,
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Set defaults
|
|
|
|
|
options = Object.assign({
|
|
|
|
|
maxRedirects: exports.maxRedirects,
|
|
|
|
|
maxBodyLength: exports.maxBodyLength,
|
|
|
|
|
}, input, options);
|
|
|
|
|
options.nativeProtocols = nativeProtocols;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
assert.equal(options.protocol, protocol, "protocol mismatch");
|
|
|
|
|
debug("options", options);
|
|
|
|
|
return new RedirectableRequest(options, callback);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Executes a GET request, following redirects
|
|
|
|
|
function get(input, options, callback) {
|
|
|
|
|
var wrappedRequest = wrappedProtocol.request(input, options, callback);
|
|
|
|
|
wrappedRequest.end();
|
|
|
|
|
return wrappedRequest;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/* istanbul ignore next */
|
|
|
|
|
function noop() { /* empty */ }
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// 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;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
function removeMatchingHeaders(regex, headers) {
|
|
|
|
|
var lastValue;
|
|
|
|
|
for (var header in headers) {
|
|
|
|
|
if (regex.test(header)) {
|
|
|
|
|
lastValue = headers[header];
|
|
|
|
|
delete headers[header];
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-12-27 13:47:39 +08:00
|
|
|
|
return (lastValue === null || typeof lastValue === "undefined") ?
|
|
|
|
|
undefined : String(lastValue).trim();
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
function createErrorType(code, defaultMessage) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
function CustomError(cause) {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
Error.captureStackTrace(this, this.constructor);
|
2021-12-27 13:47:39 +08:00
|
|
|
|
if (!cause) {
|
|
|
|
|
this.message = defaultMessage;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.message = defaultMessage + ": " + cause.message;
|
|
|
|
|
this.cause = cause;
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
CustomError.prototype = new Error();
|
|
|
|
|
CustomError.prototype.constructor = CustomError;
|
|
|
|
|
CustomError.prototype.name = "Error [" + code + "]";
|
|
|
|
|
CustomError.prototype.code = code;
|
|
|
|
|
return CustomError;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
function abortRequest(request) {
|
|
|
|
|
for (var e = 0; e < events.length; e++) {
|
|
|
|
|
request.removeListener(events[e], eventHandlers[events[e]]);
|
|
|
|
|
}
|
|
|
|
|
request.on("error", noop);
|
|
|
|
|
request.abort();
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
function isSubdomain(subdomain, domain) {
|
2021-12-27 13:47:39 +08:00
|
|
|
|
const dot = subdomain.length - domain.length - 1;
|
|
|
|
|
return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
// Exports
|
|
|
|
|
module.exports = wrap({ http: http, https: https });
|
|
|
|
|
module.exports.wrap = wrap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 4334:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var CombinedStream = __nccwpck_require__(5443);
|
|
|
|
|
var util = __nccwpck_require__(3837);
|
|
|
|
|
var path = __nccwpck_require__(1017);
|
|
|
|
|
var http = __nccwpck_require__(3685);
|
|
|
|
|
var https = __nccwpck_require__(5687);
|
|
|
|
|
var parseUrl = (__nccwpck_require__(7310).parse);
|
|
|
|
|
var fs = __nccwpck_require__(7147);
|
|
|
|
|
var Stream = (__nccwpck_require__(2781).Stream);
|
|
|
|
|
var mime = __nccwpck_require__(3583);
|
|
|
|
|
var asynckit = __nccwpck_require__(4812);
|
|
|
|
|
var populate = __nccwpck_require__(7142);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Public API
|
|
|
|
|
module.exports = FormData;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// make it a Stream
|
|
|
|
|
util.inherits(FormData, CombinedStream);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* Create readable "multipart/form-data" streams.
|
|
|
|
|
* Can be used to submit forms
|
|
|
|
|
* and file uploads to other web applications.
|
|
|
|
|
*
|
|
|
|
|
* @constructor
|
|
|
|
|
* @param {Object} options - Properties to be added/overriden for FormData and CombinedStream
|
|
|
|
|
*/
|
|
|
|
|
function FormData(options) {
|
|
|
|
|
if (!(this instanceof FormData)) {
|
|
|
|
|
return new FormData(options);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this._overheadLength = 0;
|
|
|
|
|
this._valueLength = 0;
|
|
|
|
|
this._valuesToMeasure = [];
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
CombinedStream.call(this);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
options = options || {};
|
|
|
|
|
for (var option in options) {
|
|
|
|
|
this[option] = options[option];
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.LINE_BREAK = '\r\n';
|
|
|
|
|
FormData.DEFAULT_CONTENT_TYPE = 'application/octet-stream';
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype.append = function(field, value, options) {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
options = options || {};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// allow filename as single option
|
|
|
|
|
if (typeof options == 'string') {
|
|
|
|
|
options = {filename: options};
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var append = CombinedStream.prototype.append.bind(this);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// all that streamy business can't handle numbers
|
|
|
|
|
if (typeof value == 'number') {
|
|
|
|
|
value = '' + value;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// https://github.com/felixge/node-form-data/issues/38
|
|
|
|
|
if (util.isArray(value)) {
|
|
|
|
|
// Please convert your array into string
|
|
|
|
|
// the way web server expects it
|
|
|
|
|
this._error(new Error('Arrays are not supported.'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var header = this._multiPartHeader(field, value, options);
|
|
|
|
|
var footer = this._multiPartFooter();
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
append(header);
|
|
|
|
|
append(value);
|
|
|
|
|
append(footer);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// pass along options.knownLength
|
|
|
|
|
this._trackLength(header, value, options);
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype._trackLength = function(header, value, options) {
|
|
|
|
|
var valueLength = 0;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// used w/ getLengthSync(), when length is known.
|
|
|
|
|
// e.g. for streaming directly from a remote server,
|
|
|
|
|
// w/ a known file a size, and not wanting to wait for
|
|
|
|
|
// incoming file to finish to get its size.
|
|
|
|
|
if (options.knownLength != null) {
|
|
|
|
|
valueLength += +options.knownLength;
|
|
|
|
|
} else if (Buffer.isBuffer(value)) {
|
|
|
|
|
valueLength = value.length;
|
|
|
|
|
} else if (typeof value === 'string') {
|
|
|
|
|
valueLength = Buffer.byteLength(value);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this._valueLength += valueLength;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// @check why add CRLF? does this account for custom/multiple CRLFs?
|
|
|
|
|
this._overheadLength +=
|
|
|
|
|
Buffer.byteLength(header) +
|
|
|
|
|
FormData.LINE_BREAK.length;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// empty or either doesn't have path or not an http response or not a stream
|
|
|
|
|
if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) && !(value instanceof Stream))) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// no need to bother with the length
|
|
|
|
|
if (!options.knownLength) {
|
|
|
|
|
this._valuesToMeasure.push(value);
|
|
|
|
|
}
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype._lengthRetriever = function(value, callback) {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (value.hasOwnProperty('fd')) {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// take read range into a account
|
|
|
|
|
// `end` = Infinity –> read file till the end
|
|
|
|
|
//
|
|
|
|
|
// TODO: Looks like there is bug in Node fs.createReadStream
|
|
|
|
|
// it doesn't respect `end` options without `start` options
|
|
|
|
|
// Fix it when node fixes it.
|
|
|
|
|
// https://github.com/joyent/node/issues/7819
|
|
|
|
|
if (value.end != undefined && value.end != Infinity && value.start != undefined) {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// when end specified
|
|
|
|
|
// no need to calculate range
|
|
|
|
|
// inclusive, starts with 0
|
|
|
|
|
callback(null, value.end + 1 - (value.start ? value.start : 0));
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// not that fast snoopy
|
|
|
|
|
} else {
|
|
|
|
|
// still need to fetch file size from fs
|
|
|
|
|
fs.stat(value.path, function(err, stat) {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var fileSize;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (err) {
|
|
|
|
|
callback(err);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// update final size based on the range options
|
|
|
|
|
fileSize = stat.size - (value.start ? value.start : 0);
|
|
|
|
|
callback(null, fileSize);
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// or http response
|
|
|
|
|
} else if (value.hasOwnProperty('httpVersion')) {
|
|
|
|
|
callback(null, +value.headers['content-length']);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// or request stream http://github.com/mikeal/request
|
|
|
|
|
} else if (value.hasOwnProperty('httpModule')) {
|
|
|
|
|
// wait till response come back
|
|
|
|
|
value.on('response', function(response) {
|
|
|
|
|
value.pause();
|
|
|
|
|
callback(null, +response.headers['content-length']);
|
|
|
|
|
});
|
|
|
|
|
value.resume();
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// something else
|
|
|
|
|
} else {
|
|
|
|
|
callback('Unknown stream');
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype._multiPartHeader = function(field, value, options) {
|
|
|
|
|
// custom header specified (as string)?
|
|
|
|
|
// it becomes responsible for boundary
|
|
|
|
|
// (e.g. to handle extra CRLFs on .NET servers)
|
|
|
|
|
if (typeof options.header == 'string') {
|
|
|
|
|
return options.header;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var contentDisposition = this._getContentDisposition(value, options);
|
|
|
|
|
var contentType = this._getContentType(value, options);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var contents = '';
|
|
|
|
|
var headers = {
|
|
|
|
|
// add custom disposition as third element or keep it two elements if not
|
|
|
|
|
'Content-Disposition': ['form-data', 'name="' + field + '"'].concat(contentDisposition || []),
|
|
|
|
|
// if no content type. allow it to be empty array
|
|
|
|
|
'Content-Type': [].concat(contentType || [])
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// allow custom headers.
|
|
|
|
|
if (typeof options.header == 'object') {
|
|
|
|
|
populate(headers, options.header);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var header;
|
|
|
|
|
for (var prop in headers) {
|
|
|
|
|
if (!headers.hasOwnProperty(prop)) continue;
|
|
|
|
|
header = headers[prop];
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// skip nullish headers.
|
|
|
|
|
if (header == null) {
|
|
|
|
|
continue;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// convert all headers to arrays.
|
|
|
|
|
if (!Array.isArray(header)) {
|
|
|
|
|
header = [header];
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// add non-empty headers.
|
|
|
|
|
if (header.length) {
|
|
|
|
|
contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return '--' + this.getBoundary() + FormData.LINE_BREAK + contents + FormData.LINE_BREAK;
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype._getContentDisposition = function(value, options) {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var filename
|
|
|
|
|
, contentDisposition
|
|
|
|
|
;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (typeof options.filepath === 'string') {
|
|
|
|
|
// custom filepath for relative paths
|
|
|
|
|
filename = path.normalize(options.filepath).replace(/\\/g, '/');
|
|
|
|
|
} else if (options.filename || value.name || value.path) {
|
|
|
|
|
// custom filename take precedence
|
|
|
|
|
// formidable and the browser add a name property
|
|
|
|
|
// fs- and request- streams have path property
|
|
|
|
|
filename = path.basename(options.filename || value.name || value.path);
|
|
|
|
|
} else if (value.readable && value.hasOwnProperty('httpVersion')) {
|
|
|
|
|
// or try http response
|
|
|
|
|
filename = path.basename(value.client._httpMessage.path || '');
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (filename) {
|
|
|
|
|
contentDisposition = 'filename="' + filename + '"';
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return contentDisposition;
|
|
|
|
|
};
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype._getContentType = function(value, options) {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// use custom content-type above all
|
|
|
|
|
var contentType = options.contentType;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// or try `name` from formidable, browser
|
|
|
|
|
if (!contentType && value.name) {
|
|
|
|
|
contentType = mime.lookup(value.name);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// or try `path` from fs-, request- streams
|
|
|
|
|
if (!contentType && value.path) {
|
|
|
|
|
contentType = mime.lookup(value.path);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// or if it's http-reponse
|
|
|
|
|
if (!contentType && value.readable && value.hasOwnProperty('httpVersion')) {
|
|
|
|
|
contentType = value.headers['content-type'];
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// or guess it from the filepath or filename
|
|
|
|
|
if (!contentType && (options.filepath || options.filename)) {
|
|
|
|
|
contentType = mime.lookup(options.filepath || options.filename);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// fallback to the default content type if `value` is not simple value
|
|
|
|
|
if (!contentType && typeof value == 'object') {
|
|
|
|
|
contentType = FormData.DEFAULT_CONTENT_TYPE;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return contentType;
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype._multiPartFooter = function() {
|
|
|
|
|
return function(next) {
|
|
|
|
|
var footer = FormData.LINE_BREAK;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var lastPart = (this._streams.length === 0);
|
|
|
|
|
if (lastPart) {
|
|
|
|
|
footer += this._lastBoundary();
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
next(footer);
|
|
|
|
|
}.bind(this);
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype._lastBoundary = function() {
|
|
|
|
|
return '--' + this.getBoundary() + '--' + FormData.LINE_BREAK;
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype.getHeaders = function(userHeaders) {
|
|
|
|
|
var header;
|
|
|
|
|
var formHeaders = {
|
|
|
|
|
'content-type': 'multipart/form-data; boundary=' + this.getBoundary()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (header in userHeaders) {
|
|
|
|
|
if (userHeaders.hasOwnProperty(header)) {
|
|
|
|
|
formHeaders[header.toLowerCase()] = userHeaders[header];
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return formHeaders;
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype.setBoundary = function(boundary) {
|
|
|
|
|
this._boundary = boundary;
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype.getBoundary = function() {
|
|
|
|
|
if (!this._boundary) {
|
|
|
|
|
this._generateBoundary();
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return this._boundary;
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype.getBuffer = function() {
|
|
|
|
|
var dataBuffer = new Buffer.alloc( 0 );
|
|
|
|
|
var boundary = this.getBoundary();
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Create the form content. Add Line breaks to the end of data.
|
|
|
|
|
for (var i = 0, len = this._streams.length; i < len; i++) {
|
|
|
|
|
if (typeof this._streams[i] !== 'function') {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Add content to the buffer.
|
|
|
|
|
if(Buffer.isBuffer(this._streams[i])) {
|
|
|
|
|
dataBuffer = Buffer.concat( [dataBuffer, this._streams[i]]);
|
|
|
|
|
}else {
|
|
|
|
|
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(this._streams[i])]);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Add break after content.
|
|
|
|
|
if (typeof this._streams[i] !== 'string' || this._streams[i].substring( 2, boundary.length + 2 ) !== boundary) {
|
|
|
|
|
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(FormData.LINE_BREAK)] );
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Add the footer and return the Buffer object.
|
|
|
|
|
return Buffer.concat( [dataBuffer, Buffer.from(this._lastBoundary())] );
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype._generateBoundary = function() {
|
|
|
|
|
// This generates a 50 character boundary similar to those used by Firefox.
|
|
|
|
|
// They are optimized for boyer-moore parsing.
|
|
|
|
|
var boundary = '--------------------------';
|
|
|
|
|
for (var i = 0; i < 24; i++) {
|
|
|
|
|
boundary += Math.floor(Math.random() * 10).toString(16);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this._boundary = boundary;
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Note: getLengthSync DOESN'T calculate streams length
|
|
|
|
|
// As workaround one can calculate file size manually
|
|
|
|
|
// and add it as knownLength option
|
|
|
|
|
FormData.prototype.getLengthSync = function() {
|
|
|
|
|
var knownLength = this._overheadLength + this._valueLength;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Don't get confused, there are 3 "internal" streams for each keyval pair
|
|
|
|
|
// so it basically checks if there is any value added to the form
|
|
|
|
|
if (this._streams.length) {
|
|
|
|
|
knownLength += this._lastBoundary().length;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// https://github.com/form-data/form-data/issues/40
|
|
|
|
|
if (!this.hasKnownLength()) {
|
|
|
|
|
// Some async length retrievers are present
|
|
|
|
|
// therefore synchronous length calculation is false.
|
|
|
|
|
// Please use getLength(callback) to get proper length
|
|
|
|
|
this._error(new Error('Cannot calculate proper length in synchronous way.'));
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return knownLength;
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Public API to check if length of added values is known
|
|
|
|
|
// https://github.com/form-data/form-data/issues/196
|
|
|
|
|
// https://github.com/form-data/form-data/issues/262
|
|
|
|
|
FormData.prototype.hasKnownLength = function() {
|
|
|
|
|
var hasKnownLength = true;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (this._valuesToMeasure.length) {
|
|
|
|
|
hasKnownLength = false;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return hasKnownLength;
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype.getLength = function(cb) {
|
|
|
|
|
var knownLength = this._overheadLength + this._valueLength;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (this._streams.length) {
|
|
|
|
|
knownLength += this._lastBoundary().length;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (!this._valuesToMeasure.length) {
|
|
|
|
|
process.nextTick(cb.bind(this, null, knownLength));
|
|
|
|
|
return;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) {
|
|
|
|
|
if (err) {
|
|
|
|
|
cb(err);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
values.forEach(function(length) {
|
|
|
|
|
knownLength += length;
|
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
cb(null, knownLength);
|
|
|
|
|
});
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype.submit = function(params, cb) {
|
|
|
|
|
var request
|
|
|
|
|
, options
|
|
|
|
|
, defaults = {method: 'post'}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
// parse provided url if it's string
|
|
|
|
|
// or treat it as options object
|
|
|
|
|
if (typeof params == 'string') {
|
|
|
|
|
|
|
|
|
|
params = parseUrl(params);
|
|
|
|
|
options = populate({
|
|
|
|
|
port: params.port,
|
|
|
|
|
path: params.pathname,
|
|
|
|
|
host: params.hostname,
|
|
|
|
|
protocol: params.protocol
|
|
|
|
|
}, defaults);
|
|
|
|
|
|
|
|
|
|
// use custom params
|
|
|
|
|
} else {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
options = populate(params, defaults);
|
|
|
|
|
// if no port provided use default one
|
|
|
|
|
if (!options.port) {
|
|
|
|
|
options.port = options.protocol == 'https:' ? 443 : 80;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// put that good code in getHeaders to some use
|
|
|
|
|
options.headers = this.getHeaders(params.headers);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// https if specified, fallback to http in any other case
|
|
|
|
|
if (options.protocol == 'https:') {
|
|
|
|
|
request = https.request(options);
|
|
|
|
|
} else {
|
|
|
|
|
request = http.request(options);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// get content length and fire away
|
|
|
|
|
this.getLength(function(err, length) {
|
|
|
|
|
if (err && err !== 'Unknown stream') {
|
|
|
|
|
this._error(err);
|
|
|
|
|
return;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// add content length
|
|
|
|
|
if (length) {
|
|
|
|
|
request.setHeader('Content-Length', length);
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
this.pipe(request);
|
|
|
|
|
if (cb) {
|
|
|
|
|
var onResponse;
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var callback = function (error, responce) {
|
|
|
|
|
request.removeListener('error', callback);
|
|
|
|
|
request.removeListener('response', onResponse);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return cb.call(this, error, responce);
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
onResponse = callback.bind(this, null);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
request.on('error', callback);
|
|
|
|
|
request.on('response', onResponse);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
}.bind(this));
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return request;
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype._error = function(err) {
|
|
|
|
|
if (!this.error) {
|
|
|
|
|
this.error = err;
|
|
|
|
|
this.pause();
|
|
|
|
|
this.emit('error', err);
|
2021-04-29 15:57:10 +08:00
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
FormData.prototype.toString = function () {
|
|
|
|
|
return '[object FormData]';
|
|
|
|
|
};
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 7142:
|
|
|
|
|
/***/ ((module) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// populates missing values
|
|
|
|
|
module.exports = function(dst, src) {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
Object.keys(src).forEach(function(prop)
|
|
|
|
|
{
|
|
|
|
|
dst[prop] = dst[prop] || src[prop];
|
|
|
|
|
});
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return dst;
|
|
|
|
|
};
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 7426:
|
|
|
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/*!
|
|
|
|
|
* mime-db
|
|
|
|
|
* Copyright(c) 2014 Jonathan Ong
|
|
|
|
|
* Copyright(c) 2015-2022 Douglas Christopher Wilson
|
|
|
|
|
* MIT Licensed
|
|
|
|
|
*/
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* Module exports.
|
|
|
|
|
*/
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
module.exports = __nccwpck_require__(3765)
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 3583:
|
|
|
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
"use strict";
|
|
|
|
|
/*!
|
|
|
|
|
* mime-types
|
|
|
|
|
* Copyright(c) 2014 Jonathan Ong
|
|
|
|
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
|
|
|
* MIT Licensed
|
|
|
|
|
*/
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* Module dependencies.
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var db = __nccwpck_require__(7426)
|
|
|
|
|
var extname = (__nccwpck_require__(1017).extname)
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* Module variables.
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/
|
|
|
|
|
var TEXT_TYPE_REGEXP = /^text\//i
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* Module exports.
|
|
|
|
|
* @public
|
|
|
|
|
*/
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
exports.charset = charset
|
|
|
|
|
exports.charsets = { lookup: charset }
|
|
|
|
|
exports.contentType = contentType
|
|
|
|
|
exports.extension = extension
|
|
|
|
|
exports.extensions = Object.create(null)
|
|
|
|
|
exports.lookup = lookup
|
|
|
|
|
exports.types = Object.create(null)
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// Populate the extensions/types maps
|
|
|
|
|
populateMaps(exports.extensions, exports.types)
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* Get the default charset for a MIME type.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} type
|
|
|
|
|
* @return {boolean|string}
|
|
|
|
|
*/
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
function charset (type) {
|
|
|
|
|
if (!type || typeof type !== 'string') {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// TODO: use media-typer
|
|
|
|
|
var match = EXTRACT_TYPE_REGEXP.exec(type)
|
|
|
|
|
var mime = match && db[match[1].toLowerCase()]
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (mime && mime.charset) {
|
|
|
|
|
return mime.charset
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// default text/* to utf-8
|
|
|
|
|
if (match && TEXT_TYPE_REGEXP.test(match[1])) {
|
|
|
|
|
return 'UTF-8'
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return false
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* Create a full Content-Type header given a MIME type or extension.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} str
|
|
|
|
|
* @return {boolean|string}
|
|
|
|
|
*/
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
function contentType (str) {
|
|
|
|
|
// TODO: should this even be in this module?
|
|
|
|
|
if (!str || typeof str !== 'string') {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var mime = str.indexOf('/') === -1
|
|
|
|
|
? exports.lookup(str)
|
|
|
|
|
: str
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (!mime) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// TODO: use content-type or other module
|
|
|
|
|
if (mime.indexOf('charset') === -1) {
|
|
|
|
|
var charset = exports.charset(mime)
|
|
|
|
|
if (charset) mime += '; charset=' + charset.toLowerCase()
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return mime
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* Get the default extension for a MIME type.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} type
|
|
|
|
|
* @return {boolean|string}
|
|
|
|
|
*/
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
function extension (type) {
|
|
|
|
|
if (!type || typeof type !== 'string') {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// TODO: use media-typer
|
|
|
|
|
var match = EXTRACT_TYPE_REGEXP.exec(type)
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// get extensions
|
|
|
|
|
var exts = match && exports.extensions[match[1].toLowerCase()]
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (!exts || !exts.length) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return exts[0]
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* Lookup the MIME type for a file path/extension.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} path
|
|
|
|
|
* @return {boolean|string}
|
|
|
|
|
*/
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
function lookup (path) {
|
|
|
|
|
if (!path || typeof path !== 'string') {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// get the extension ("ext" or ".ext" or full path)
|
|
|
|
|
var extension = extname('x.' + path)
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.substr(1)
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (!extension) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
return exports.types[extension] || false
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/**
|
|
|
|
|
* Populate the extensions and types maps.
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
function populateMaps (extensions, types) {
|
|
|
|
|
// source preference (least -> most)
|
|
|
|
|
var preference = ['nginx', 'apache', undefined, 'iana']
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
Object.keys(db).forEach(function forEachMimeType (type) {
|
|
|
|
|
var mime = db[type]
|
|
|
|
|
var exts = mime.extensions
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (!exts || !exts.length) {
|
|
|
|
|
return
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// mime -> extensions
|
|
|
|
|
extensions[type] = exts
|
|
|
|
|
|
|
|
|
|
// extension -> mime
|
|
|
|
|
for (var i = 0; i < exts.length; i++) {
|
|
|
|
|
var extension = exts[i]
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
if (types[extension]) {
|
|
|
|
|
var from = preference.indexOf(db[types[extension]].source)
|
|
|
|
|
var to = preference.indexOf(mime.source)
|
|
|
|
|
|
|
|
|
|
if (types[extension] !== 'application/octet-stream' &&
|
|
|
|
|
(from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {
|
|
|
|
|
// skip the remapping
|
|
|
|
|
continue
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
// set the extension -> mime
|
|
|
|
|
types[extension] = type
|
2021-05-07 16:07:16 +08:00
|
|
|
|
}
|
2022-04-27 10:20:40 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 9975:
|
|
|
|
|
/***/ ((module) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
module.exports = eval("require")("debug");
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 9491:
|
|
|
|
|
/***/ ((module) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
"use strict";
|
|
|
|
|
module.exports = require("assert");
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 7147:
|
|
|
|
|
/***/ ((module) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
"use strict";
|
|
|
|
|
module.exports = require("fs");
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 3685:
|
|
|
|
|
/***/ ((module) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
"use strict";
|
|
|
|
|
module.exports = require("http");
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 5687:
|
|
|
|
|
/***/ ((module) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
"use strict";
|
|
|
|
|
module.exports = require("https");
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 1017:
|
|
|
|
|
/***/ ((module) => {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
"use strict";
|
|
|
|
|
module.exports = require("path");
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 2781:
|
|
|
|
|
/***/ ((module) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
"use strict";
|
|
|
|
|
module.exports = require("stream");
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 7310:
|
|
|
|
|
/***/ ((module) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
"use strict";
|
|
|
|
|
module.exports = require("url");
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 3837:
|
|
|
|
|
/***/ ((module) => {
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
"use strict";
|
|
|
|
|
module.exports = require("util");
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 9796:
|
|
|
|
|
/***/ ((module) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
"use strict";
|
|
|
|
|
module.exports = require("zlib");
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ }),
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/***/ 3765:
|
|
|
|
|
/***/ ((module) => {
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2022-04-27 10:20:40 +08:00
|
|
|
|
"use strict";
|
|
|
|
|
module.exports = JSON.parse('{"application/1d-interleaved-parityfec":{"source":"iana"},"application/3gpdash-qoe-report+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/3gpp-ims+xml":{"source":"iana","compressible":true},"application/3gpphal+json":{"source":"iana","compressible":true},"application/3gpphalforms+json":{"source":"iana","compressible":true},"application/a2l":{"source":"iana"},"application/ace+cbor":{"source":"iana"},"application/activemessage":{"source":"iana"},"application/activity+json":{"source":"iana","compressible":true},"application/alto-costmap+json":{"source":"iana","compressible":true},"application/alto-costmapfilter+json":{"source":"iana","compressible":true},"application/alto-directory+json":{"source":"iana","compressible":true},"application/alto-endpointcost+json":{"source":"iana","compressible":true},"application/alto-endpointcostparams+json":{"source":"iana","compressible":true},"application/alto-endpointprop+json":{"source":"iana","compressible":true},"application/alto-endpointpropparams+json":{"source":"iana","compressible":true},"application/alto-error+json":{"source":"iana","compressible":true},"application/alto-networkmap+json":{"source":"iana","compressible":true},"application/alto-networkmapfilter+json":{"source":"iana","compressible":true},"application/alto-updatestreamcontrol+json":{"source":"iana","compressible":true},"application/alto-updatestreamparams+json":{"source":"iana","compressible":true},"application/aml":{"source":"iana"},"application/andrew-inset":{"source":"iana","extensions":["ez"]},"application/applefile":{"source":"iana"},"application/applixware":{"source":"apache","extensions":["aw"]},"application/at+jwt":{"source":"iana"},"application/atf":{"source":"iana"},"application/atfx":{"source":"iana"},"application/atom+xml":{"source":"iana","compressible":true,"extensions":["atom"]},"application/atomcat+xml":{"source":"iana","compressible":true,"extensions":["atomcat"]},"application/atomdeleted+xml":{"source":"iana","compressible":true,"extensions":["atomdeleted"]},"application/atomicmail":{"source":"iana"},"application/atomsvc+xml":{"source":"iana","compressible":true,"extensions":["atomsvc"]},"application/atsc-dwd+xml":{"source":"iana","compressible":true,"extensions":["dwd"]},"application/atsc-dynamic-event-message":{"source":"iana"},"application/atsc-held+xml":{"source":"iana","compressible":true,"extensions":["held"]},"application/atsc-rdt+json":{"source":"iana","compressible":true},"application/atsc-rsat+xml":{"source":"iana","compressible":true,"extensions":["rsat"]},"application/atxml":{"source":"iana"},"application/auth-policy+xml":{"source":"iana","compressible":true},"application/bacnet-xdd+zip":{"source":"iana","compressible":false},"application/batch-smtp":{"source":"iana"},"application/bdoc":{"compressible":false,"extensions":["bdoc"]},"application/beep+xml":{"source":"iana","charset":"UTF-8","compressible":true},"application/calendar+json":{"source":"iana","compressible":true},"application/calendar+xml":{"source":"iana","compressible":true,"extensions":["xcs"]},"application/call-completion":{"source":"iana"},"application/cals-1840":{"source":"iana"},"application/captive+json":{"source":"iana","compressible":true},"application/cbor":{"source":"iana"},"application/cbor-seq":{"source":"iana"},"application/cccex":{"source":"iana"},"application/ccmp+xml":{"source":"iana","compressible":true},"application/ccxml+xml":{"source":"iana","compressible":true,"extensions":["ccxml"]},"application/cdfx+xml":{"source":"iana","compressible":true,"extensions":["cdfx"]},"application/cdmi-capability":{"source":"iana","extensions":["cdmia"]},"application/cdmi-container":{"source":"iana","extensions":["cdmic"]},"application/cdmi-domain":{"source":"iana","extensions":["cdmid"]},"application/cdmi-object":{"source":"iana","extensions":["cdmio"]},"application/cdmi-queue":{"source":"iana","extensions":["cdmiq"]},"application/cdni":{"source":"iana"},"application/cea":{"source":"iana"},"application/cea-2018+xml":{"source":"iana","compressible":true},"application/c
|
2021-05-07 16:07:16 +08:00
|
|
|
|
|
2021-12-27 13:47:39 +08:00
|
|
|
|
/***/ })
|
2021-04-29 15:57:10 +08:00
|
|
|
|
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/******/ });
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
/******/ // The module cache
|
|
|
|
|
/******/ var __webpack_module_cache__ = {};
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // The require function
|
|
|
|
|
/******/ function __nccwpck_require__(moduleId) {
|
|
|
|
|
/******/ // Check if module is in cache
|
|
|
|
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
|
|
|
/******/ if (cachedModule !== undefined) {
|
|
|
|
|
/******/ return cachedModule.exports;
|
|
|
|
|
/******/ }
|
|
|
|
|
/******/ // Create a new module (and put it into the cache)
|
|
|
|
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/******/ // no module.id needed
|
|
|
|
|
/******/ // no module.loaded needed
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/******/ exports: {}
|
|
|
|
|
/******/ };
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // Execute the module function
|
|
|
|
|
/******/ var threw = true;
|
|
|
|
|
/******/ try {
|
2022-04-27 10:20:40 +08:00
|
|
|
|
/******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/******/ threw = false;
|
|
|
|
|
/******/ } finally {
|
|
|
|
|
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
|
|
|
|
/******/ }
|
|
|
|
|
/******/
|
|
|
|
|
/******/ // Return the exports of the module
|
|
|
|
|
/******/ return module.exports;
|
|
|
|
|
/******/ }
|
|
|
|
|
/******/
|
|
|
|
|
/************************************************************************/
|
|
|
|
|
/******/ /* webpack/runtime/compat */
|
|
|
|
|
/******/
|
2021-12-27 13:47:39 +08:00
|
|
|
|
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
|
|
|
|
|
/******/
|
|
|
|
|
/************************************************************************/
|
2022-04-27 10:20:40 +08:00
|
|
|
|
var __webpack_exports__ = {};
|
|
|
|
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
|
|
|
(() => {
|
|
|
|
|
const axios = __nccwpck_require__(6545);
|
|
|
|
|
|
|
|
|
|
const payload = {};
|
|
|
|
|
|
|
|
|
|
if (process.env.INPUT_MSGTYPE === 'text') {
|
|
|
|
|
|
|
|
|
|
payload.msgtype = process.env.INPUT_MSGTYPE;
|
|
|
|
|
payload.text = {
|
|
|
|
|
content: process.env.INPUT_CONTENT,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (process.env.INPUT_MENTIONED_LIST) {
|
|
|
|
|
let mentioned_list;
|
|
|
|
|
try {
|
|
|
|
|
mentioned_list = JSON.parse(process.env.INPUT_MENTIONED_LIST);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
mentioned_list = [];
|
|
|
|
|
}
|
|
|
|
|
payload.text.mentioned_list = mentioned_list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (process.env.INPUT_MENTIONED_MOBILE_LIST) {
|
|
|
|
|
let mentioned_mobile_list;
|
|
|
|
|
try {
|
|
|
|
|
mentioned_mobile_list = JSON.parse(process.env.INPUT_MENTIONED_MOBILE_LIST);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
mentioned_mobile_list = [];
|
|
|
|
|
}
|
|
|
|
|
payload.text.mentioned_mobile_list = mentioned_mobile_list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (process.env.INPUT_MSGTYPE === 'markdown') {
|
|
|
|
|
|
|
|
|
|
payload.msgtype = process.env.INPUT_MSGTYPE;
|
|
|
|
|
payload.markdown = {
|
|
|
|
|
content: process.env.INPUT_CONTENT,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (process.env.INPUT_MSGTYPE === 'image') {
|
|
|
|
|
|
|
|
|
|
payload.msgtype = process.env.INPUT_MSGTYPE;
|
|
|
|
|
payload.image = {
|
|
|
|
|
base64: process.env.INPUT_BASE64,
|
|
|
|
|
md5: process.env.INPUT_MD5,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (process.env.INPUT_MSGTYPE === 'news') {
|
|
|
|
|
|
|
|
|
|
payload.msgtype = process.env.INPUT_MSGTYPE;
|
|
|
|
|
|
|
|
|
|
let articles;
|
|
|
|
|
try {
|
|
|
|
|
articles = JSON.parse(process.env.INPUT_ARTICLES);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
articles = [];
|
|
|
|
|
}
|
|
|
|
|
payload.news = {
|
|
|
|
|
articles,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (process.env.INPUT_MSGTYPE === 'file') {
|
|
|
|
|
|
|
|
|
|
payload.msgtype = process.env.INPUT_MSGTYPE;
|
|
|
|
|
payload.file = {
|
|
|
|
|
media_id: process.env.INPUT_MEDIA_ID,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log('The message content in JSON format...');
|
|
|
|
|
console.log(JSON.stringify(payload));
|
|
|
|
|
|
|
|
|
|
const url = process.env.WECHAT_WORK_BOT_WEBHOOK;
|
|
|
|
|
|
|
|
|
|
(async () => {
|
|
|
|
|
console.log('Sending message ...');
|
|
|
|
|
await axios.post(url, JSON.stringify(payload), {
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
console.log('Message sent Success! Shutting down ...');
|
|
|
|
|
process.exit(0);
|
|
|
|
|
})()
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
console.error('Message sent error:');
|
|
|
|
|
err.message && console.error(err.message);
|
|
|
|
|
err.response && err.response.data && console.error(err.response.data);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
module.exports = __webpack_exports__;
|
2021-05-07 16:07:16 +08:00
|
|
|
|
/******/ })()
|
|
|
|
|
;
|