Skip to content

Commit

Permalink
Test branch (#166)
Browse files Browse the repository at this point in the history

Signed-off-by: Gloria Delgado <gloriad@vmware.com>
  • Loading branch information
gdelgadot committed Nov 21, 2023
1 parent be16b53 commit faa2bfa
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 50 deletions.
183 changes: 134 additions & 49 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27989,7 +27989,7 @@ module.exports = require("zlib");
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

"use strict";
// Axios v1.3.5 Copyright (c) 2023 Matt Zabriskie and contributors
// Axios v1.6.0 Copyright (c) 2023 Matt Zabriskie and contributors


const FormData$1 = __nccwpck_require__(4334);
Expand Down Expand Up @@ -28207,12 +28207,16 @@ const isStream = (val) => isObject(val) && isFunction(val.pipe);
* @returns {boolean} True if value is an FormData, otherwise false
*/
const isFormData = (thing) => {
const pattern = '[object FormData]';
let kind;
return thing && (
(typeof FormData === 'function' && thing instanceof FormData) ||
toString.call(thing) === pattern ||
(isFunction(thing.toString) && thing.toString() === pattern)
);
(typeof FormData === 'function' && thing instanceof FormData) || (
isFunction(thing.append) && (
(kind = kindOf(thing)) === 'formdata' ||
// detect form-data instance
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
)
)
)
};

/**
Expand Down Expand Up @@ -28555,8 +28559,9 @@ const reduceDescriptors = (obj, reducer) => {
const reducedDescriptors = {};

forEach(descriptors, (descriptor, name) => {
if (reducer(descriptor, name, obj) !== false) {
reducedDescriptors[name] = descriptor;
let ret;
if ((ret = reducer(descriptor, name, obj)) !== false) {
reducedDescriptors[name] = ret || descriptor;
}
});

Expand Down Expand Up @@ -28677,6 +28682,11 @@ const toJSONObject = (obj) => {
return visit(obj, 0);
};

const isAsyncFn = kindOfTest('AsyncFunction');

const isThenable = (thing) =>
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);

const utils = {
isArray,
isArrayBuffer,
Expand Down Expand Up @@ -28726,7 +28736,9 @@ const utils = {
ALPHABET,
generateString,
isSpecCompliantForm,
toJSONObject
toJSONObject,
isAsyncFn,
isThenable
};

/**
Expand Down Expand Up @@ -29333,10 +29345,6 @@ function formDataToJSON(formData) {
return null;
}

const DEFAULT_CONTENT_TYPE = {
'Content-Type': undefined
};

/**
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
* of the input
Expand Down Expand Up @@ -29475,19 +29483,16 @@ const defaults = {

headers: {
common: {
'Accept': 'application/json, text/plain, */*'
'Accept': 'application/json, text/plain, */*',
'Content-Type': undefined
}
}
};

utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
defaults.headers[method] = {};
});

utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
});

const defaults$1 = defaults;

// RawAxiosHeaders whose duplicates are ignored by node
Expand Down Expand Up @@ -29821,7 +29826,17 @@ class AxiosHeaders {

AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);

utils.freezeMethods(AxiosHeaders.prototype);
// reserved names hotfix
utils.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
return {
get: () => value,
set(headerValue) {
this[mapped] = headerValue;
}
}
});

utils.freezeMethods(AxiosHeaders);

const AxiosHeaders$1 = AxiosHeaders;
Expand Down Expand Up @@ -29941,7 +29956,7 @@ function buildFullPath(baseURL, requestedURL) {
return requestedURL;
}

const VERSION = "1.3.5";
const VERSION = "1.6.0";

function parseProtocol(url) {
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
Expand Down Expand Up @@ -30411,6 +30426,21 @@ class ZlibHeaderTransformStream extends stream__default["default"].Transform {

const ZlibHeaderTransformStream$1 = ZlibHeaderTransformStream;

const callbackify = (fn, reducer) => {
return utils.isAsyncFn(fn) ? function (...args) {
const cb = args.pop();
fn.apply(this, args).then((value) => {
try {
reducer ? cb(null, ...reducer(value)) : cb(null, value);
} catch (err) {
cb(err);
}
}, cb);
} : fn;
};

const callbackify$1 = callbackify;

const zlibOptions = {
flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
Expand Down Expand Up @@ -30530,16 +30560,40 @@ const wrapAsync = (asyncExecutor) => {
})
};

const resolveFamily = ({address, family}) => {
if (!utils.isString(address)) {
throw TypeError('address must be a string');
}
return ({
address,
family: family || (address.indexOf('.') < 0 ? 6 : 4)
});
};

const buildAddressEntry = (address, family) => resolveFamily(utils.isObject(address) ? address : {address, family});

/*eslint consistent-return:0*/
const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
let {data} = config;
let {data, lookup, family} = config;
const {responseType, responseEncoding} = config;
const method = config.method.toUpperCase();
let isDone;
let rejected = false;
let req;

if (lookup) {
const _lookup = callbackify$1(lookup, (value) => utils.isArray(value) ? value : [value]);
// hotfix to support opt.all option which is required for node 20.x
lookup = (hostname, opt, cb) => {
_lookup(hostname, opt, (err, arg0, arg1) => {
const addresses = utils.isArray(arg0) ? arg0.map(addr => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];

opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
});
};
}

// temporary internal emitter until the AxiosRequest class will be implemented
const emitter = new EventEmitter__default["default"]();

Expand Down Expand Up @@ -30763,10 +30817,14 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
agents: { http: config.httpAgent, https: config.httpsAgent },
auth,
protocol,
family,
beforeRedirect: dispatchBeforeRedirect,
beforeRedirects: {}
};

// cacheable-lookup integration hotfix
!utils.isUndefined(lookup) && (options.lookup = lookup);

if (config.socketPath) {
options.socketPath = config.socketPath;
} else {
Expand Down Expand Up @@ -30840,7 +30898,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
delete res.headers['content-encoding'];
}

switch (res.headers['content-encoding']) {
switch ((res.headers['content-encoding'] || '').toLowerCase()) {
/*eslint default-case:0*/
case 'gzip':
case 'x-gzip':
Expand Down Expand Up @@ -30936,7 +30994,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
}
response.data = responseData;
} catch (err) {
reject(AxiosError.from(err, null, config, response.request, response));
return reject(AxiosError.from(err, null, config, response.request, response));
}
settle(resolve, reject, response);
});
Expand Down Expand Up @@ -30973,7 +31031,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
const timeout = parseInt(config.timeout, 10);

if (isNaN(timeout)) {
if (Number.isNaN(timeout)) {
reject(new AxiosError(
'error trying to parse `config.timeout` to int',
AxiosError.ERR_BAD_OPTION_VALUE,
Expand Down Expand Up @@ -31192,8 +31250,17 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
}
}

if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
requestHeaders.setContentType(false); // Let the browser set it
let contentType;

if (utils.isFormData(requestData)) {
if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
requestHeaders.setContentType(false); // Let the browser set it
} else if(!requestHeaders.getContentType(/^\s*multipart\/form-data/)){
requestHeaders.setContentType('multipart/form-data'); // mobile/desktop app frameworks
} else if(utils.isString(contentType = requestHeaders.getContentType())){
// fix semicolon duplication issue for ReactNative FormData implementation
requestHeaders.setContentType(contentType.replace(/^\s*(multipart\/form-data);+/, '$1'));
}
}

let request = new XMLHttpRequest();
Expand Down Expand Up @@ -31310,8 +31377,8 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
// Specifically not if we're in a web worker, or react-native.
if (platform.isStandardBrowserEnv) {
// Add xsrf header
const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath))
&& config.xsrfCookieName && cookies.read(config.xsrfCookieName);
// regarding CVE-2023-45857 config.withCredentials condition was removed temporarily
const xsrfValue = isURLSameOrigin(fullPath) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);

if (xsrfValue) {
requestHeaders.set(config.xsrfHeaderName, xsrfValue);
Expand Down Expand Up @@ -31385,7 +31452,7 @@ const knownAdapters = {
};

utils.forEach(knownAdapters, (fn, value) => {
if(fn) {
if (fn) {
try {
Object.defineProperty(fn, 'name', {value});
} catch (e) {
Expand All @@ -31395,6 +31462,10 @@ utils.forEach(knownAdapters, (fn, value) => {
}
});

const renderReason = (reason) => `- ${reason}`;

const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === null || adapter === false;

const adapters = {
getAdapter: (adapters) => {
adapters = utils.isArray(adapters) ? adapters : [adapters];
Expand All @@ -31403,30 +31474,44 @@ const adapters = {
let nameOrAdapter;
let adapter;

const rejectedReasons = {};

for (let i = 0; i < length; i++) {
nameOrAdapter = adapters[i];
if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
let id;

adapter = nameOrAdapter;

if (!isResolvedHandle(nameOrAdapter)) {
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];

if (adapter === undefined) {
throw new AxiosError(`Unknown adapter '${id}'`);
}
}

if (adapter) {
break;
}

rejectedReasons[id || '#' + i] = adapter;
}

if (!adapter) {
if (adapter === false) {
throw new AxiosError(
`Adapter ${nameOrAdapter} is not supported by the environment`,
'ERR_NOT_SUPPORT'

const reasons = Object.entries(rejectedReasons)
.map(([id, state]) => `adapter ${id} ` +
(state === false ? 'is not supported by the environment' : 'is not available in the build')
);
}

throw new Error(
utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
`Adapter '${nameOrAdapter}' is not available in the build` :
`Unknown adapter '${nameOrAdapter}'`
);
}
let s = length ?
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
'as no adapter specified';

if (!utils.isFunction(adapter)) {
throw new TypeError('adapter is not a function');
throw new AxiosError(
`There is no suitable adapter to dispatch the request ` + s,
'ERR_NOT_SUPPORT'
);
}

return adapter;
Expand Down Expand Up @@ -31599,7 +31684,7 @@ function mergeConfig(config1, config2) {
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
};

utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
const merge = mergeMap[prop] || mergeDeepProperties;
const configValue = merge(config1[prop], config2[prop], prop);
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
Expand Down Expand Up @@ -31759,15 +31844,13 @@ class Axios {
// Set config.method
config.method = (config.method || this.defaults.method || 'get').toLowerCase();

let contextHeaders;

// Flatten headers
contextHeaders = headers && utils.merge(
let contextHeaders = headers && utils.merge(
headers.common,
headers[config.method]
);

contextHeaders && utils.forEach(
headers && utils.forEach(
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
(method) => {
delete headers[method];
Expand Down Expand Up @@ -32177,6 +32260,8 @@ axios.AxiosHeaders = AxiosHeaders$1;

axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);

axios.getAdapter = adapters.getAdapter;

axios.HttpStatusCode = HttpStatusCode$1;

axios.default = axios;
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

0 comments on commit faa2bfa

Please sign in to comment.