diff --git a/dist/index.js b/dist/index.js index c6eace6..2dfb633 100644 --- a/dist/index.js +++ b/dist/index.js @@ -38532,7 +38532,7 @@ const response_INTERNALS = Symbol('Response internals'); * @param Object opts Response options * @return Void */ -class response_Response extends Body { +class Response extends Body { constructor(body = null, options = {}) { super(body, options); @@ -38600,7 +38600,7 @@ class response_Response extends Body { * @return Response */ clone() { - return new response_Response(clone(this, this.highWaterMark), { + return new Response(clone(this, this.highWaterMark), { type: this.type, url: this.url, status: this.status, @@ -38623,7 +38623,7 @@ class response_Response extends Body { throw new RangeError('Failed to execute "redirect" on "response": Invalid status code'); } - return new response_Response(null, { + return new Response(null, { headers: { location: new URL(url).toString() }, @@ -38632,7 +38632,7 @@ class response_Response extends Body { } static error() { - const response = new response_Response(null, {status: 0, statusText: ''}); + const response = new Response(null, {status: 0, statusText: ''}); response[response_INTERNALS].type = 'error'; return response; } @@ -38650,7 +38650,7 @@ class response_Response extends Body { headers.set('content-type', 'application/json'); } - return new response_Response(body, { + return new Response(body, { ...init, headers }); @@ -38661,7 +38661,7 @@ class response_Response extends Body { } } -Object.defineProperties(response_Response.prototype, { +Object.defineProperties(Response.prototype, { type: {enumerable: true}, url: {enumerable: true}, status: {enumerable: true}, @@ -39074,7 +39074,7 @@ const doBadDataWarn = (0,external_node_util_.deprecate)(() => {}, * @param Object init Custom options * @return Void */ -class request_Request extends Body { +class Request extends Body { constructor(input, init = {}) { let parsedURL; @@ -39228,7 +39228,7 @@ class request_Request extends Body { * @return Request */ clone() { - return new request_Request(this); + return new Request(this); } get [Symbol.toStringTag]() { @@ -39236,7 +39236,7 @@ class request_Request extends Body { } } -Object.defineProperties(request_Request.prototype, { +Object.defineProperties(Request.prototype, { method: {enumerable: true}, url: {enumerable: true}, headers: {enumerable: true}, @@ -39400,7 +39400,7 @@ const supportedSchemas = new Set(['data:', 'http:', 'https:']); async function src_fetch(url, options_) { return new Promise((resolve, reject) => { // Build request object - const request = new request_Request(url, options_); + const request = new Request(url, options_); const {parsedURL, options} = getNodeRequestOptions(request); if (!supportedSchemas.has(parsedURL.protocol)) { throw new TypeError(`node-fetch cannot load ${url}. URL scheme "${parsedURL.protocol.replace(/:$/, '')}" is not supported.`); @@ -39408,7 +39408,7 @@ async function src_fetch(url, options_) { if (parsedURL.protocol === 'data:') { const data = dist(request.url); - const response = new response_Response(data, {headers: {'Content-Type': data.typeFull}}); + const response = new Response(data, {headers: {'Content-Type': data.typeFull}}); resolve(response); return; } @@ -39585,7 +39585,7 @@ async function src_fetch(url, options_) { } // HTTP-redirect fetch step 15 - resolve(src_fetch(new request_Request(locationURL, requestOptions))); + resolve(src_fetch(new Request(locationURL, requestOptions))); finalize(); return; } @@ -39635,7 +39635,7 @@ async function src_fetch(url, options_) { // 4. no content response (204) // 5. content not modified response (304) if (!request.compress || request.method === 'HEAD' || codings === null || response_.statusCode === 204 || response_.statusCode === 304) { - response = new response_Response(body, responseOptions); + response = new Response(body, responseOptions); resolve(response); return; } @@ -39657,7 +39657,7 @@ async function src_fetch(url, options_) { reject(error); } }); - response = new response_Response(body, responseOptions); + response = new Response(body, responseOptions); resolve(response); return; } @@ -39687,14 +39687,14 @@ async function src_fetch(url, options_) { }); } - response = new response_Response(body, responseOptions); + response = new Response(body, responseOptions); resolve(response); }); raw.once('end', () => { // Some old IIS servers return zero-length OK deflate responses, so // 'data' is never emitted. See https://github.com/node-fetch/node-fetch/pull/903 if (!response) { - response = new response_Response(body, responseOptions); + response = new Response(body, responseOptions); resolve(response); } }); @@ -39708,13 +39708,13 @@ async function src_fetch(url, options_) { reject(error); } }); - response = new response_Response(body, responseOptions); + response = new Response(body, responseOptions); resolve(response); return; } // Otherwise, use response as-is - response = new response_Response(body, responseOptions); + response = new Response(body, responseOptions); resolve(response); }); @@ -39916,6 +39916,27 @@ const isPlainObject = (val) => { return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val); } +/** + * Determine if a value is an empty object (safely handles Buffers) + * + * @param {*} val The value to test + * + * @returns {boolean} True if value is an empty object, otherwise false + */ +const isEmptyObject = (val) => { + // Early return for non-objects or Buffers to prevent RangeError + if (!isObject(val) || isBuffer(val)) { + return false; + } + + try { + return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype; + } catch (e) { + // Fallback for any other objects that might cause RangeError with Object.keys() + return false; + } +} + /** * Determine if a value is a Date * @@ -40038,6 +40059,11 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) { fn.call(null, obj[i], i, obj); } } else { + // Buffer check + if (isBuffer(obj)) { + return; + } + // Iterate over object keys const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj); const len = keys.length; @@ -40051,6 +40077,10 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) { } function findKey(obj, key) { + if (isBuffer(obj)){ + return null; + } + key = key.toLowerCase(); const keys = Object.keys(obj); let i = keys.length; @@ -40091,7 +40121,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob * @returns {Object} Result of all merge properties */ function merge(/* obj1, obj2, obj3, ... */) { - const {caseless} = isContextDefined(this) && this || {}; + const {caseless, skipUndefined} = isContextDefined(this) && this || {}; const result = {}; const assignValue = (val, key) => { const targetKey = caseless && findKey(result, key) || key; @@ -40101,7 +40131,7 @@ function merge(/* obj1, obj2, obj3, ... */) { result[targetKey] = merge({}, val); } else if (isArray(val)) { result[targetKey] = val.slice(); - } else { + } else if (!skipUndefined || !isUndefined(val)) { result[targetKey] = val; } } @@ -40383,6 +40413,8 @@ const toFiniteNumber = (value, defaultValue) => { return value != null && Number.isFinite(value = +value) ? value : defaultValue; } + + /** * If the thing is a FormData object, return true, otherwise return false. * @@ -40404,6 +40436,11 @@ const toJSONObject = (obj) => { return; } + //Buffer check + if (isBuffer(source)) { + return source; + } + if(!('toJSON' in source)) { stack[i] = source; const target = isArray(source) ? [] : {}; @@ -40475,6 +40512,7 @@ const isIterable = (thing) => thing != null && isFunction(thing[iterator]); isBoolean, isObject, isPlainObject, + isEmptyObject, isReadableStream, isRequest: utils_isRequest, isResponse, @@ -40615,11 +40653,18 @@ AxiosError.from = (error, code, config, request, response, customProps) => { return prop !== 'isAxiosError'; }); - AxiosError.call(axiosError, error.message, code, config, request, response); + const msg = error && error.message ? error.message : 'Error'; + + // Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED) + const errCode = code == null && error ? error.code : code; + AxiosError.call(axiosError, msg, errCode, config, request, response); - axiosError.cause = error; + // Chain the original error on the standard field; non-enumerable to avoid JSON noise + if (error && axiosError.cause == null) { + Object.defineProperty(axiosError, 'cause', { value: error, configurable: true }); + } - axiosError.name = error.name; + axiosError.name = (error && error.name) || 'Error'; customProps && Object.assign(axiosError, customProps); @@ -40758,6 +40803,10 @@ function toFormData(obj, formData, options) { return value.toISOString(); } + if (utils.isBoolean(value)) { + return value.toString(); + } + if (!useBlob && utils.isBlob(value)) { throw new core_AxiosError('Blob is not supported. Use a Buffer instead.'); } @@ -40935,9 +40984,7 @@ function buildURL_encode(val) { replace(/%3A/gi, ':'). replace(/%24/g, '$'). replace(/%2C/gi, ','). - replace(/%20/g, '+'). - replace(/%5B/gi, '['). - replace(/%5D/gi, ']'); + replace(/%20/g, '+'); } /** @@ -41183,7 +41230,7 @@ const origin = hasBrowserEnv && window.location.href || 'http://localhost'; function toURLEncodedForm(data, options) { - return helpers_toFormData(data, new platform.classes.URLSearchParams(), Object.assign({ + return helpers_toFormData(data, new platform.classes.URLSearchParams(), { visitor: function(value, key, path, helpers) { if (platform.isNode && utils.isBuffer(value)) { this.append(key, value.toString('base64')); @@ -41191,8 +41238,9 @@ function toURLEncodedForm(data, options) { } return helpers.defaultVisitor.apply(this, arguments); - } - }, options)); + }, + ...options + }); } ;// CONCATENATED MODULE: ./node_modules/axios/lib/helpers/formDataToJSON.js @@ -41406,7 +41454,7 @@ const defaults = { const strictJSONParsing = !silentJSONParsing && JSONRequested; try { - return JSON.parse(data); + return JSON.parse(data, this.parseReviver); } catch (e) { if (strictJSONParsing) { if (e.name === 'SyntaxError') { @@ -41992,7 +42040,7 @@ var follow_redirects = __nccwpck_require__(1573); // EXTERNAL MODULE: external "zlib" var external_zlib_ = __nccwpck_require__(3106); ;// CONCATENATED MODULE: ./node_modules/axios/lib/env/data.js -const VERSION = "1.9.0"; +const VERSION = "1.12.2"; ;// CONCATENATED MODULE: ./node_modules/axios/lib/helpers/parseProtocol.js @@ -42461,7 +42509,7 @@ function throttle(fn, freq) { clearTimeout(timer); timer = null; } - fn.apply(null, args); + fn(...args); } const throttled = (...args) => { @@ -42533,6 +42581,81 @@ const progressEventDecorator = (total, throttled) => { const asyncDecorator = (fn) => (...args) => utils.asap(() => fn(...args)); +;// CONCATENATED MODULE: ./node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +/** + * Estimate decoded byte length of a data:// URL *without* allocating large buffers. + * - For base64: compute exact decoded size using length and padding; + * handle %XX at the character-count level (no string allocation). + * - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound. + * + * @param {string} url + * @returns {number} + */ +function estimateDataURLDecodedBytes(url) { + if (!url || typeof url !== 'string') return 0; + if (!url.startsWith('data:')) return 0; + + const comma = url.indexOf(','); + if (comma < 0) return 0; + + const meta = url.slice(5, comma); + const body = url.slice(comma + 1); + const isBase64 = /;base64/i.test(meta); + + if (isBase64) { + let effectiveLen = body.length; + const len = body.length; // cache length + + for (let i = 0; i < len; i++) { + if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) { + const a = body.charCodeAt(i + 1); + const b = body.charCodeAt(i + 2); + const isHex = + ((a >= 48 && a <= 57) || (a >= 65 && a <= 70) || (a >= 97 && a <= 102)) && + ((b >= 48 && b <= 57) || (b >= 65 && b <= 70) || (b >= 97 && b <= 102)); + + if (isHex) { + effectiveLen -= 2; + i += 2; + } + } + } + + let pad = 0; + let idx = len - 1; + + const tailIsPct3D = (j) => + j >= 2 && + body.charCodeAt(j - 2) === 37 && // '%' + body.charCodeAt(j - 1) === 51 && // '3' + (body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd' + + if (idx >= 0) { + if (body.charCodeAt(idx) === 61 /* '=' */) { + pad++; + idx--; + } else if (tailIsPct3D(idx)) { + pad++; + idx -= 3; + } + } + + if (pad === 1 && idx >= 0) { + if (body.charCodeAt(idx) === 61 /* '=' */) { + pad++; + } else if (tailIsPct3D(idx)) { + pad++; + } + } + + const groups = Math.floor(effectiveLen / 4); + const bytes = groups * 3 - (pad || 0); + return bytes > 0 ? bytes : 0; + } + + return Buffer.byteLength(body, 'utf8'); +} + ;// CONCATENATED MODULE: ./node_modules/axios/lib/adapters/http.js @@ -42560,6 +42683,7 @@ const asyncDecorator = (fn) => (...args) => utils.asap(() => fn(...args)); + const zlibOptions = { @@ -42582,6 +42706,7 @@ const supportedProtocols = platform.protocols.map(protocol => { return protocol + ':'; }); + const flushOnFinish = (stream, [throttled, flush]) => { stream .on('end', flush) @@ -42590,6 +42715,7 @@ const flushOnFinish = (stream, [throttled, flush]) => { return throttled; } + /** * If the proxy or config beforeRedirects functions are defined, call them with the options * object. @@ -42769,6 +42895,21 @@ const buildAddressEntry = (address, family) => resolveFamily(utils.isObject(addr const protocol = parsed.protocol || supportedProtocols[0]; if (protocol === 'data:') { + // Apply the same semantics as HTTP: only enforce if a finite, non-negative cap is set. + if (config.maxContentLength > -1) { + // Use the exact string passed to fromDataURI (config.url); fall back to fullPath if needed. + const dataUrl = String(config.url || fullPath || ''); + const estimated = estimateDataURLDecodedBytes(dataUrl); + + if (estimated > config.maxContentLength) { + return reject(new core_AxiosError( + 'maxContentLength size of ' + config.maxContentLength + ' exceeded', + core_AxiosError.ERR_BAD_RESPONSE, + config + )); + } + } + let convertedData; if (method !== 'GET') { @@ -43389,7 +43530,7 @@ function mergeConfig(config1, config2) { headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true) }; - utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) { + utils.forEach(Object.keys({...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); @@ -43411,7 +43552,7 @@ function mergeConfig(config1, config2) { /* harmony default export */ const resolveConfig = ((config) => { const newConfig = mergeConfig({}, config); - let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig; + let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig; newConfig.headers = headers = core_AxiosHeaders.from(headers); @@ -43424,17 +43565,21 @@ function mergeConfig(config1, config2) { ); } - let contentType; - if (utils.isFormData(data)) { if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) { - headers.setContentType(undefined); // Let the browser set it - } else if ((contentType = headers.getContentType()) !== false) { - // fix semicolon duplication issue for ReactNative FormData implementation - const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : []; - headers.setContentType([type || 'multipart/form-data', ...tokens].join('; ')); + headers.setContentType(undefined); // browser handles it + } else if (utils.isFunction(data.getHeaders)) { + // Node.js FormData (like form-data package) + const formHeaders = data.getHeaders(); + // Only set safe headers to avoid overwriting security headers + const allowedHeaders = ['content-type', 'content-length']; + Object.entries(formHeaders).forEach(([key, val]) => { + if (allowedHeaders.includes(key.toLowerCase())) { + headers.set(key, val); + } + }); } - } + } // Add xsrf header // This is only done if running in a standard browser environment. @@ -43564,15 +43709,18 @@ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined'; }; // Handle low level network errors - request.onerror = function handleError() { - // Real errors are hidden from us by the browser - // onerror should only fire if it's a network error - reject(new core_AxiosError('Network Error', core_AxiosError.ERR_NETWORK, config, request)); - - // Clean up request - request = null; + request.onerror = function handleError(event) { + // Browsers deliver a ProgressEvent in XHR onerror + // (message may be empty; when present, surface it) + // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event + const msg = event && event.message ? event.message : 'Network Error'; + const err = new core_AxiosError(msg, core_AxiosError.ERR_NETWORK, config, request); + // attach the underlying event for consumers who want details + err.event = event || null; + reject(err); + request = null; }; - + // Handle timeout request.ontimeout = function handleTimeout() { let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded'; @@ -43806,14 +43954,18 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => { -const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function'; -const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function'; +const DEFAULT_CHUNK_SIZE = 64 * 1024; + +const {isFunction: fetch_isFunction} = utils; + +const globalFetchAPI = (({Request, Response}) => ({ + Request, Response +}))(utils.global); + +const { + ReadableStream: fetch_ReadableStream, TextEncoder: fetch_TextEncoder +} = utils.global; -// used only inside the fetch adapter -const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ? - ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : - async (str) => new Uint8Array(await new Response(str).arrayBuffer()) -); const test = (fn, ...args) => { try { @@ -43823,208 +43975,263 @@ const test = (fn, ...args) => { } } -const supportsRequestStream = isReadableStreamSupported && test(() => { - let duplexAccessed = false; +const factory = (env) => { + env = utils.merge.call({ + skipUndefined: true + }, globalFetchAPI, env); - const hasContentType = new Request(platform.origin, { - body: new ReadableStream(), - method: 'POST', - get duplex() { - duplexAccessed = true; - return 'half'; - }, - }).headers.has('Content-Type'); + const {fetch: envFetch, Request, Response} = env; + const isFetchSupported = envFetch ? fetch_isFunction(envFetch) : typeof fetch === 'function'; + const isRequestSupported = fetch_isFunction(Request); + const isResponseSupported = fetch_isFunction(Response); - return duplexAccessed && !hasContentType; -}); + if (!isFetchSupported) { + return false; + } -const DEFAULT_CHUNK_SIZE = 64 * 1024; + const isReadableStreamSupported = isFetchSupported && fetch_isFunction(fetch_ReadableStream); -const supportsResponseStream = isReadableStreamSupported && - test(() => utils.isReadableStream(new Response('').body)); + const encodeText = isFetchSupported && (typeof fetch_TextEncoder === 'function' ? + ((encoder) => (str) => encoder.encode(str))(new fetch_TextEncoder()) : + async (str) => new Uint8Array(await new Request(str).arrayBuffer()) + ); + const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => { + let duplexAccessed = false; -const resolvers = { - stream: supportsResponseStream && ((res) => res.body) -}; + const hasContentType = new Request(platform.origin, { + body: new fetch_ReadableStream(), + method: 'POST', + get duplex() { + duplexAccessed = true; + return 'half'; + }, + }).headers.has('Content-Type'); -isFetchSupported && (((res) => { - ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => { - !resolvers[type] && (resolvers[type] = utils.isFunction(res[type]) ? (res) => res[type]() : - (_, config) => { - throw new core_AxiosError(`Response type '${type}' is not supported`, core_AxiosError.ERR_NOT_SUPPORT, config); - }) + return duplexAccessed && !hasContentType; }); -})(new Response)); -const getBodyLength = async (body) => { - if (body == null) { - return 0; - } + const supportsResponseStream = isResponseSupported && isReadableStreamSupported && + test(() => utils.isReadableStream(new Response('').body)); - if(utils.isBlob(body)) { - return body.size; - } + const resolvers = { + stream: supportsResponseStream && ((res) => res.body) + }; - if(utils.isSpecCompliantForm(body)) { - const _request = new Request(platform.origin, { - method: 'POST', - body, + isFetchSupported && ((() => { + ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => { + !resolvers[type] && (resolvers[type] = (res, config) => { + let method = res && res[type]; + + if (method) { + return method.call(res); + } + + throw new core_AxiosError(`Response type '${type}' is not supported`, core_AxiosError.ERR_NOT_SUPPORT, config); + }) }); - return (await _request.arrayBuffer()).byteLength; - } + })()); - if(utils.isArrayBufferView(body) || utils.isArrayBuffer(body)) { - return body.byteLength; - } + const getBodyLength = async (body) => { + if (body == null) { + return 0; + } - if(utils.isURLSearchParams(body)) { - body = body + ''; - } + if (utils.isBlob(body)) { + return body.size; + } + + if (utils.isSpecCompliantForm(body)) { + const _request = new Request(platform.origin, { + method: 'POST', + body, + }); + return (await _request.arrayBuffer()).byteLength; + } + + if (utils.isArrayBufferView(body) || utils.isArrayBuffer(body)) { + return body.byteLength; + } - if(utils.isString(body)) { - return (await encodeText(body)).byteLength; + if (utils.isURLSearchParams(body)) { + body = body + ''; + } + + if (utils.isString(body)) { + return (await encodeText(body)).byteLength; + } } -} -const resolveBodyLength = async (headers, body) => { - const length = utils.toFiniteNumber(headers.getContentLength()); + const resolveBodyLength = async (headers, body) => { + const length = utils.toFiniteNumber(headers.getContentLength()); - return length == null ? getBodyLength(body) : length; -} + return length == null ? getBodyLength(body) : length; + } -/* harmony default export */ const adapters_fetch = (isFetchSupported && (async (config) => { - let { - url, - method, - data, - signal, - cancelToken, - timeout, - onDownloadProgress, - onUploadProgress, - responseType, - headers, - withCredentials = 'same-origin', - fetchOptions - } = resolveConfig(config); + return async (config) => { + let { + url, + method, + data, + signal, + cancelToken, + timeout, + onDownloadProgress, + onUploadProgress, + responseType, + headers, + withCredentials = 'same-origin', + fetchOptions + } = resolveConfig(config); - responseType = responseType ? (responseType + '').toLowerCase() : 'text'; + let _fetch = envFetch || fetch; - let composedSignal = helpers_composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout); + responseType = responseType ? (responseType + '').toLowerCase() : 'text'; - let request; + let composedSignal = helpers_composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout); - const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => { + let request = null; + + const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => { composedSignal.unsubscribe(); - }); + }); - let requestContentLength; + let requestContentLength; - try { - if ( - onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' && - (requestContentLength = await resolveBodyLength(headers, data)) !== 0 - ) { - let _request = new Request(url, { - method: 'POST', - body: data, - duplex: "half" - }); + try { + if ( + onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' && + (requestContentLength = await resolveBodyLength(headers, data)) !== 0 + ) { + let _request = new Request(url, { + method: 'POST', + body: data, + duplex: "half" + }); - let contentTypeHeader; + let contentTypeHeader; - if (utils.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) { - headers.setContentType(contentTypeHeader) - } + if (utils.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) { + headers.setContentType(contentTypeHeader) + } - if (_request.body) { - const [onProgress, flush] = progressEventDecorator( - requestContentLength, - progressEventReducer(asyncDecorator(onUploadProgress)) - ); + if (_request.body) { + const [onProgress, flush] = progressEventDecorator( + requestContentLength, + progressEventReducer(asyncDecorator(onUploadProgress)) + ); - data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush); + data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush); + } } - } - if (!utils.isString(withCredentials)) { - withCredentials = withCredentials ? 'include' : 'omit'; - } + if (!utils.isString(withCredentials)) { + withCredentials = withCredentials ? 'include' : 'omit'; + } - // Cloudflare Workers throws when credentials are defined - // see https://github.com/cloudflare/workerd/issues/902 - const isCredentialsSupported = "credentials" in Request.prototype; - request = new Request(url, { - ...fetchOptions, - signal: composedSignal, - method: method.toUpperCase(), - headers: headers.normalize().toJSON(), - body: data, - duplex: "half", - credentials: isCredentialsSupported ? withCredentials : undefined - }); + // Cloudflare Workers throws when credentials are defined + // see https://github.com/cloudflare/workerd/issues/902 + const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype; + + const resolvedOptions = { + ...fetchOptions, + signal: composedSignal, + method: method.toUpperCase(), + headers: headers.normalize().toJSON(), + body: data, + duplex: "half", + credentials: isCredentialsSupported ? withCredentials : undefined + }; - let response = await fetch(request); + request = isRequestSupported && new Request(url, resolvedOptions); - const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response'); + let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions)); - if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) { - const options = {}; + const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response'); - ['status', 'statusText', 'headers'].forEach(prop => { - options[prop] = response[prop]; - }); + if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) { + const options = {}; - const responseContentLength = utils.toFiniteNumber(response.headers.get('content-length')); + ['status', 'statusText', 'headers'].forEach(prop => { + options[prop] = response[prop]; + }); - const [onProgress, flush] = onDownloadProgress && progressEventDecorator( - responseContentLength, - progressEventReducer(asyncDecorator(onDownloadProgress), true) - ) || []; + const responseContentLength = utils.toFiniteNumber(response.headers.get('content-length')); - response = new Response( - trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => { - flush && flush(); - unsubscribe && unsubscribe(); - }), - options - ); - } + const [onProgress, flush] = onDownloadProgress && progressEventDecorator( + responseContentLength, + progressEventReducer(asyncDecorator(onDownloadProgress), true) + ) || []; - responseType = responseType || 'text'; + response = new Response( + trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => { + flush && flush(); + unsubscribe && unsubscribe(); + }), + options + ); + } - let responseData = await resolvers[utils.findKey(resolvers, responseType) || 'text'](response, config); + responseType = responseType || 'text'; - !isStreamResponse && unsubscribe && unsubscribe(); + let responseData = await resolvers[utils.findKey(resolvers, responseType) || 'text'](response, config); - return await new Promise((resolve, reject) => { - settle(resolve, reject, { - data: responseData, - headers: core_AxiosHeaders.from(response.headers), - status: response.status, - statusText: response.statusText, - config, - request + !isStreamResponse && unsubscribe && unsubscribe(); + + return await new Promise((resolve, reject) => { + settle(resolve, reject, { + data: responseData, + headers: core_AxiosHeaders.from(response.headers), + status: response.status, + statusText: response.statusText, + config, + request + }) }) - }) - } catch (err) { - unsubscribe && unsubscribe(); + } catch (err) { + unsubscribe && unsubscribe(); - if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) { - throw Object.assign( - new core_AxiosError('Network Error', core_AxiosError.ERR_NETWORK, config, request), - { - cause: err.cause || err - } - ) + if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) { + throw Object.assign( + new core_AxiosError('Network Error', core_AxiosError.ERR_NETWORK, config, request), + { + cause: err.cause || err + } + ) + } + + throw core_AxiosError.from(err, err && err.code, config, request); } + } +} + +const seedCache = new Map(); - throw core_AxiosError.from(err, err && err.code, config, request); +const getFetch = (config) => { + let env = config ? config.env : {}; + const {fetch, Request, Response} = env; + const seeds = [ + Request, Response, fetch + ]; + + let len = seeds.length, i = len, + seed, target, map = seedCache; + + while (i--) { + seed = seeds[i]; + target = map.get(seed); + + target === undefined && map.set(seed, target = (i ? new Map() : factory(env))) + + map = target; } -})); + return target; +}; + +const adapter = getFetch(); +/* harmony default export */ const adapters_fetch = ((/* unused pure expression or super */ null && (adapter))); ;// CONCATENATED MODULE: ./node_modules/axios/lib/adapters/adapters.js @@ -44036,7 +44243,9 @@ const resolveBodyLength = async (headers, body) => { const knownAdapters = { http: http, xhr: xhr, - fetch: adapters_fetch + fetch: { + get: getFetch, + } } utils.forEach(knownAdapters, (fn, value) => { @@ -44055,7 +44264,7 @@ const renderReason = (reason) => `- ${reason}`; const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === null || adapter === false; /* harmony default export */ const adapters = ({ - getAdapter: (adapters) => { + getAdapter: (adapters, config) => { adapters = utils.isArray(adapters) ? adapters : [adapters]; const {length} = adapters; @@ -44078,7 +44287,7 @@ const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === n } } - if (adapter) { + if (adapter && (utils.isFunction(adapter) || (adapter = adapter.get(config)))) { break; } @@ -44156,7 +44365,7 @@ function dispatchRequest(config) { config.headers.setContentType('application/x-www-form-urlencoded', false); } - const adapter = adapters.getAdapter(config.adapter || lib_defaults.adapter); + const adapter = adapters.getAdapter(config.adapter || lib_defaults.adapter, config); return adapter(config).then(function onAdapterResolution(response) { throwIfCancellationRequested(config); @@ -44447,8 +44656,8 @@ class Axios { if (!synchronousRequestInterceptors) { const chain = [dispatchRequest.bind(this), undefined]; - chain.unshift.apply(chain, requestInterceptorChain); - chain.push.apply(chain, responseInterceptorChain); + chain.unshift(...requestInterceptorChain); + chain.push(...responseInterceptorChain); len = chain.length; promise = Promise.resolve(config); @@ -44464,8 +44673,6 @@ class Axios { let newConfig = config; - i = 0; - while (i < len) { const onFulfilled = requestInterceptorChain[i++]; const onRejected = requestInterceptorChain[i++]; diff --git a/yarn.lock b/yarn.lock index e568cde..ee75ed5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -297,12 +297,12 @@ asynckit@^0.4.0: integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== axios@^1.9.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.9.0.tgz#25534e3b72b54540077d33046f77e3b8d7081901" - integrity sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg== + version "1.12.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.12.2.tgz#6c307390136cf7a2278d09cec63b136dfc6e6da7" + integrity "sha1-bDBzkBNs96InjQnOxjsTbfxubac= sha512-vMJzPewAlRyOgxV2dU0Cuz2O8zzzx9VYtbJOaBgXFeLc4IV/Eg50n4LowmehOOR61S8ZMpc2K5Sa7g6A4jfkUw==" dependencies: follow-redirects "^1.15.6" - form-data "^4.0.0" + form-data "^4.0.4" proxy-from-env "^1.1.0" balanced-match@^1.0.0: @@ -791,10 +791,10 @@ follow-redirects@^1.15.6: resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1" integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ== -form-data@^4.0.0: +form-data@^4.0.4: version "4.0.4" resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.4.tgz#784cdcce0669a9d68e94d11ac4eea98088edd2c4" - integrity "sha1-eEzczgZpqdaOlNEaxO6pgIjt0sQ= sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==" + integrity sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow== dependencies: asynckit "^0.4.0" combined-stream "^1.0.8"