@nocobase/plugin-ai-gigachat 2.2.19 → 2.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/externalVersion.js +5 -5
- package/dist/node_modules/gigachat/package.json +1 -1
- package/dist/node_modules/langchain-gigachat/index.cjs +2 -2
- package/dist/node_modules/langchain-gigachat/package.json +1 -1
- package/package.json +2 -2
- package/dist/node_modules/gigachat/node_modules/axios/dist/axios.js +0 -5249
- package/dist/node_modules/gigachat/node_modules/axios/dist/axios.min.js +0 -5
- package/dist/node_modules/gigachat/node_modules/axios/dist/browser/axios.cjs +0 -5146
- package/dist/node_modules/gigachat/node_modules/axios/dist/esm/axios.js +0 -5167
- package/dist/node_modules/gigachat/node_modules/axios/dist/esm/axios.min.js +0 -3
- package/dist/node_modules/gigachat/node_modules/axios/dist/node/axios.cjs +0 -5996
- package/dist/node_modules/gigachat/node_modules/axios/index.d.cts +0 -738
- package/dist/node_modules/gigachat/node_modules/axios/index.d.ts +0 -755
- package/dist/node_modules/gigachat/node_modules/axios/index.js +0 -45
- package/dist/node_modules/gigachat/node_modules/axios/lib/adapters/adapters.js +0 -132
- package/dist/node_modules/gigachat/node_modules/axios/lib/adapters/fetch.js +0 -643
- package/dist/node_modules/gigachat/node_modules/axios/lib/adapters/http.js +0 -1417
- package/dist/node_modules/gigachat/node_modules/axios/lib/adapters/xhr.js +0 -228
- package/dist/node_modules/gigachat/node_modules/axios/lib/axios.js +0 -89
- package/dist/node_modules/gigachat/node_modules/axios/lib/cancel/CancelToken.js +0 -135
- package/dist/node_modules/gigachat/node_modules/axios/lib/cancel/CanceledError.js +0 -22
- package/dist/node_modules/gigachat/node_modules/axios/lib/cancel/isCancel.js +0 -5
- package/dist/node_modules/gigachat/node_modules/axios/lib/core/Axios.js +0 -283
- package/dist/node_modules/gigachat/node_modules/axios/lib/core/AxiosError.js +0 -188
- package/dist/node_modules/gigachat/node_modules/axios/lib/core/AxiosHeaders.js +0 -351
- package/dist/node_modules/gigachat/node_modules/axios/lib/core/InterceptorManager.js +0 -72
- package/dist/node_modules/gigachat/node_modules/axios/lib/core/buildFullPath.js +0 -50
- package/dist/node_modules/gigachat/node_modules/axios/lib/core/dispatchRequest.js +0 -89
- package/dist/node_modules/gigachat/node_modules/axios/lib/core/mergeConfig.js +0 -159
- package/dist/node_modules/gigachat/node_modules/axios/lib/core/settle.js +0 -27
- package/dist/node_modules/gigachat/node_modules/axios/lib/core/transformData.js +0 -28
- package/dist/node_modules/gigachat/node_modules/axios/lib/defaults/index.js +0 -177
- package/dist/node_modules/gigachat/node_modules/axios/lib/defaults/transitional.js +0 -10
- package/dist/node_modules/gigachat/node_modules/axios/lib/env/classes/FormData.js +0 -2
- package/dist/node_modules/gigachat/node_modules/axios/lib/env/data.js +0 -1
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/AxiosTransformStream.js +0 -156
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -59
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/Http2Sessions.js +0 -119
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -77
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/ZlibHeaderTransformStream.js +0 -29
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/bind.js +0 -14
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/buildURL.js +0 -69
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/callbackify.js +0 -18
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/combineURLs.js +0 -15
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/composeSignals.js +0 -57
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/cookies.js +0 -64
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/deprecatedMethod.js +0 -31
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +0 -105
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/formDataToJSON.js +0 -119
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/formDataToStream.js +0 -119
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/fromDataURI.js +0 -68
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -19
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/isAxiosError.js +0 -14
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -16
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/null.js +0 -2
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/parseHeaders.js +0 -69
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/parseProtocol.js +0 -6
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/progressEventReducer.js +0 -54
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/readBlob.js +0 -15
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/resolveConfig.js +0 -119
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/sanitizeHeaderValue.js +0 -60
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/shouldBypassProxy.js +0 -210
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/speedometer.js +0 -55
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/spread.js +0 -28
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/throttle.js +0 -44
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/toFormData.js +0 -285
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -19
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/trackStream.js +0 -89
- package/dist/node_modules/gigachat/node_modules/axios/lib/helpers/validator.js +0 -112
- package/dist/node_modules/gigachat/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -3
- package/dist/node_modules/gigachat/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -3
- package/dist/node_modules/gigachat/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -4
- package/dist/node_modules/gigachat/node_modules/axios/lib/platform/browser/index.js +0 -13
- package/dist/node_modules/gigachat/node_modules/axios/lib/platform/common/utils.js +0 -52
- package/dist/node_modules/gigachat/node_modules/axios/lib/platform/index.js +0 -7
- package/dist/node_modules/gigachat/node_modules/axios/lib/platform/node/classes/FormData.js +0 -3
- package/dist/node_modules/gigachat/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +0 -4
- package/dist/node_modules/gigachat/node_modules/axios/lib/platform/node/index.js +0 -37
- package/dist/node_modules/gigachat/node_modules/axios/lib/utils.js +0 -1017
- package/dist/node_modules/gigachat/node_modules/axios/package.json +0 -201
- package/dist/node_modules/gigachat/node_modules/follow-redirects/debug.js +0 -15
- package/dist/node_modules/gigachat/node_modules/follow-redirects/http.js +0 -1
- package/dist/node_modules/gigachat/node_modules/follow-redirects/https.js +0 -1
- package/dist/node_modules/gigachat/node_modules/follow-redirects/index.js +0 -709
- package/dist/node_modules/gigachat/node_modules/follow-redirects/package.json +0 -58
- package/dist/node_modules/gigachat/node_modules/proxy-from-env/index.cjs +0 -105
- package/dist/node_modules/gigachat/node_modules/proxy-from-env/index.js +0 -103
- package/dist/node_modules/gigachat/node_modules/proxy-from-env/package.json +0 -43
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import utils from '../utils.js';
|
|
4
|
-
import AxiosError from '../core/AxiosError.js';
|
|
5
|
-
import { DEFAULT_FORM_DATA_MAX_DEPTH } from './toFormData.js';
|
|
6
|
-
|
|
7
|
-
const MAX_DEPTH = DEFAULT_FORM_DATA_MAX_DEPTH;
|
|
8
|
-
|
|
9
|
-
function throwIfDepthExceeded(index) {
|
|
10
|
-
if (index > MAX_DEPTH) {
|
|
11
|
-
throw new AxiosError(
|
|
12
|
-
'FormData field is too deeply nested (' + index + ' levels). Max depth: ' + MAX_DEPTH,
|
|
13
|
-
AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
|
|
20
|
-
*
|
|
21
|
-
* @param {string} name - The name of the property to get.
|
|
22
|
-
*
|
|
23
|
-
* @returns An array of strings.
|
|
24
|
-
*/
|
|
25
|
-
function parsePropPath(name) {
|
|
26
|
-
// foo[x][y][z]
|
|
27
|
-
// foo.x.y.z
|
|
28
|
-
// foo-x-y-z
|
|
29
|
-
// foo x y z
|
|
30
|
-
const path = [];
|
|
31
|
-
const pattern = /\w+|\[(\w*)]/g;
|
|
32
|
-
let match;
|
|
33
|
-
|
|
34
|
-
while ((match = pattern.exec(name)) !== null) {
|
|
35
|
-
throwIfDepthExceeded(path.length);
|
|
36
|
-
path.push(match[0] === '[]' ? '' : match[1] || match[0]);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return path;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Convert an array to an object.
|
|
44
|
-
*
|
|
45
|
-
* @param {Array<any>} arr - The array to convert to an object.
|
|
46
|
-
*
|
|
47
|
-
* @returns An object with the same keys and values as the array.
|
|
48
|
-
*/
|
|
49
|
-
function arrayToObject(arr) {
|
|
50
|
-
const obj = {};
|
|
51
|
-
const keys = Object.keys(arr);
|
|
52
|
-
let i;
|
|
53
|
-
const len = keys.length;
|
|
54
|
-
let key;
|
|
55
|
-
for (i = 0; i < len; i++) {
|
|
56
|
-
key = keys[i];
|
|
57
|
-
obj[key] = arr[key];
|
|
58
|
-
}
|
|
59
|
-
return obj;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* It takes a FormData object and returns a JavaScript object
|
|
64
|
-
*
|
|
65
|
-
* @param {string} formData The FormData object to convert to JSON.
|
|
66
|
-
*
|
|
67
|
-
* @returns {Object<string, any> | null} The converted object.
|
|
68
|
-
*/
|
|
69
|
-
function formDataToJSON(formData) {
|
|
70
|
-
function buildPath(path, value, target, index) {
|
|
71
|
-
throwIfDepthExceeded(index);
|
|
72
|
-
|
|
73
|
-
let name = path[index++];
|
|
74
|
-
|
|
75
|
-
if (name === '__proto__') return true;
|
|
76
|
-
|
|
77
|
-
const isNumericKey = Number.isFinite(+name);
|
|
78
|
-
const isLast = index >= path.length;
|
|
79
|
-
name = !name && utils.isArray(target) ? target.length : name;
|
|
80
|
-
|
|
81
|
-
if (isLast) {
|
|
82
|
-
if (utils.hasOwnProp(target, name)) {
|
|
83
|
-
target[name] = utils.isArray(target[name])
|
|
84
|
-
? target[name].concat(value)
|
|
85
|
-
: [target[name], value];
|
|
86
|
-
} else {
|
|
87
|
-
target[name] = value;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return !isNumericKey;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (!utils.hasOwnProp(target, name) || !utils.isObject(target[name])) {
|
|
94
|
-
target[name] = [];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const result = buildPath(path, value, target[name], index);
|
|
98
|
-
|
|
99
|
-
if (result && utils.isArray(target[name])) {
|
|
100
|
-
target[name] = arrayToObject(target[name]);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return !isNumericKey;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
|
|
107
|
-
const obj = {};
|
|
108
|
-
|
|
109
|
-
utils.forEachEntry(formData, (name, value) => {
|
|
110
|
-
buildPath(parsePropPath(name), value, obj, 0);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
return obj;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export default formDataToJSON;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import util from 'util';
|
|
2
|
-
import { Readable } from 'stream';
|
|
3
|
-
import utils from '../utils.js';
|
|
4
|
-
import readBlob from './readBlob.js';
|
|
5
|
-
import platform from '../platform/index.js';
|
|
6
|
-
|
|
7
|
-
const BOUNDARY_ALPHABET = platform.ALPHABET.ALPHA_DIGIT + '-_';
|
|
8
|
-
|
|
9
|
-
const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new util.TextEncoder();
|
|
10
|
-
|
|
11
|
-
const CRLF = '\r\n';
|
|
12
|
-
const CRLF_BYTES = textEncoder.encode(CRLF);
|
|
13
|
-
const CRLF_BYTES_COUNT = 2;
|
|
14
|
-
|
|
15
|
-
class FormDataPart {
|
|
16
|
-
constructor(name, value) {
|
|
17
|
-
const { escapeName } = this.constructor;
|
|
18
|
-
const isStringValue = utils.isString(value);
|
|
19
|
-
|
|
20
|
-
let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${
|
|
21
|
-
!isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : ''
|
|
22
|
-
}${CRLF}`;
|
|
23
|
-
|
|
24
|
-
if (isStringValue) {
|
|
25
|
-
value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
|
|
26
|
-
} else {
|
|
27
|
-
const safeType = String(value.type || 'application/octet-stream').replace(/[\r\n]/g, '');
|
|
28
|
-
headers += `Content-Type: ${safeType}${CRLF}`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
this.headers = textEncoder.encode(headers + CRLF);
|
|
32
|
-
|
|
33
|
-
this.contentLength = isStringValue ? value.byteLength : value.size;
|
|
34
|
-
|
|
35
|
-
this.size = this.headers.byteLength + this.contentLength + CRLF_BYTES_COUNT;
|
|
36
|
-
|
|
37
|
-
this.name = name;
|
|
38
|
-
this.value = value;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async *encode() {
|
|
42
|
-
yield this.headers;
|
|
43
|
-
|
|
44
|
-
const { value } = this;
|
|
45
|
-
|
|
46
|
-
if (utils.isTypedArray(value)) {
|
|
47
|
-
yield value;
|
|
48
|
-
} else {
|
|
49
|
-
yield* readBlob(value);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
yield CRLF_BYTES;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
static escapeName(name) {
|
|
56
|
-
return String(name).replace(
|
|
57
|
-
/[\r\n"]/g,
|
|
58
|
-
(match) =>
|
|
59
|
-
({
|
|
60
|
-
'\r': '%0D',
|
|
61
|
-
'\n': '%0A',
|
|
62
|
-
'"': '%22',
|
|
63
|
-
})[match]
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const formDataToStream = (form, headersHandler, options) => {
|
|
69
|
-
const {
|
|
70
|
-
tag = 'form-data-boundary',
|
|
71
|
-
size = 25,
|
|
72
|
-
boundary = tag + '-' + platform.generateString(size, BOUNDARY_ALPHABET),
|
|
73
|
-
} = options || {};
|
|
74
|
-
|
|
75
|
-
if (!utils.isFormData(form)) {
|
|
76
|
-
throw new TypeError('FormData instance required');
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (boundary.length < 1 || boundary.length > 70) {
|
|
80
|
-
throw new Error('boundary must be 1-70 characters long');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
|
|
84
|
-
const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF);
|
|
85
|
-
let contentLength = footerBytes.byteLength;
|
|
86
|
-
|
|
87
|
-
const parts = Array.from(form.entries()).map(([name, value]) => {
|
|
88
|
-
const part = new FormDataPart(name, value);
|
|
89
|
-
contentLength += part.size;
|
|
90
|
-
return part;
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
contentLength += boundaryBytes.byteLength * parts.length;
|
|
94
|
-
|
|
95
|
-
contentLength = utils.toFiniteNumber(contentLength);
|
|
96
|
-
|
|
97
|
-
const computedHeaders = {
|
|
98
|
-
'Content-Type': `multipart/form-data; boundary=${boundary}`,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
if (Number.isFinite(contentLength)) {
|
|
102
|
-
computedHeaders['Content-Length'] = contentLength;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
headersHandler && headersHandler(computedHeaders);
|
|
106
|
-
|
|
107
|
-
return Readable.from(
|
|
108
|
-
(async function* () {
|
|
109
|
-
for (const part of parts) {
|
|
110
|
-
yield boundaryBytes;
|
|
111
|
-
yield* part.encode();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
yield footerBytes;
|
|
115
|
-
})()
|
|
116
|
-
);
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export default formDataToStream;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import AxiosError from '../core/AxiosError.js';
|
|
4
|
-
import parseProtocol from './parseProtocol.js';
|
|
5
|
-
import platform from '../platform/index.js';
|
|
6
|
-
|
|
7
|
-
// RFC 2397: data:[<mediatype>][;base64],<data>
|
|
8
|
-
// mediatype = type/subtype followed by optional ;name=value parameters
|
|
9
|
-
const DATA_URL_PATTERN = /^([^,;]+\/[^,;]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Parse data uri to a Buffer or Blob
|
|
13
|
-
*
|
|
14
|
-
* @param {String} uri
|
|
15
|
-
* @param {?Boolean} asBlob
|
|
16
|
-
* @param {?Object} options
|
|
17
|
-
* @param {?Function} options.Blob
|
|
18
|
-
*
|
|
19
|
-
* @returns {Buffer|Blob}
|
|
20
|
-
*/
|
|
21
|
-
export default function fromDataURI(uri, asBlob, options) {
|
|
22
|
-
const _Blob = (options && options.Blob) || platform.classes.Blob;
|
|
23
|
-
const protocol = parseProtocol(uri);
|
|
24
|
-
|
|
25
|
-
if (asBlob === undefined && _Blob) {
|
|
26
|
-
asBlob = true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (protocol === 'data') {
|
|
30
|
-
uri = protocol.length ? uri.slice(protocol.length + 1) : uri;
|
|
31
|
-
|
|
32
|
-
const match = DATA_URL_PATTERN.exec(uri);
|
|
33
|
-
|
|
34
|
-
if (!match) {
|
|
35
|
-
throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const type = match[1];
|
|
39
|
-
const params = match[2];
|
|
40
|
-
const encoding = match[3] ? 'base64' : 'utf8';
|
|
41
|
-
const body = match[4];
|
|
42
|
-
|
|
43
|
-
// RFC 2397 section 3: default mediatype is text/plain;charset=US-ASCII
|
|
44
|
-
// Bare `data:,` leaves mime undefined; Blob normalises that to "" per spec.
|
|
45
|
-
let mime = '';
|
|
46
|
-
if (type) {
|
|
47
|
-
mime = params ? type + params : type;
|
|
48
|
-
} else if (params) {
|
|
49
|
-
mime = 'text/plain' + params;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const buffer = encoding === 'base64'
|
|
53
|
-
? Buffer.from(body, 'base64')
|
|
54
|
-
: Buffer.from(decodeURIComponent(body), encoding);
|
|
55
|
-
|
|
56
|
-
if (asBlob) {
|
|
57
|
-
if (!_Blob) {
|
|
58
|
-
throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return new _Blob([buffer], { type: mime });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return buffer;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT);
|
|
68
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Determines whether the specified URL is absolute
|
|
5
|
-
*
|
|
6
|
-
* @param {string} url The URL to test
|
|
7
|
-
*
|
|
8
|
-
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
9
|
-
*/
|
|
10
|
-
export default function isAbsoluteURL(url) {
|
|
11
|
-
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
12
|
-
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
13
|
-
// by any combination of letters, digits, plus, period, or hyphen.
|
|
14
|
-
if (typeof url !== 'string') {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
19
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import utils from '../utils.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Determines whether the payload is an error thrown by Axios
|
|
7
|
-
*
|
|
8
|
-
* @param {*} payload The value to test
|
|
9
|
-
*
|
|
10
|
-
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
|
11
|
-
*/
|
|
12
|
-
export default function isAxiosError(payload) {
|
|
13
|
-
return utils.isObject(payload) && payload.isAxiosError === true;
|
|
14
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import platform from '../platform/index.js';
|
|
2
|
-
|
|
3
|
-
export default platform.hasStandardBrowserEnv
|
|
4
|
-
? ((origin, isMSIE) => (url) => {
|
|
5
|
-
url = new URL(url, platform.origin);
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
origin.protocol === url.protocol &&
|
|
9
|
-
origin.host === url.host &&
|
|
10
|
-
(isMSIE || origin.port === url.port)
|
|
11
|
-
);
|
|
12
|
-
})(
|
|
13
|
-
new URL(platform.origin),
|
|
14
|
-
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
15
|
-
)
|
|
16
|
-
: () => true;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import utils from '../utils.js';
|
|
4
|
-
|
|
5
|
-
// RawAxiosHeaders whose duplicates are ignored by node
|
|
6
|
-
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
|
7
|
-
const ignoreDuplicateOf = utils.toObjectSet([
|
|
8
|
-
'age',
|
|
9
|
-
'authorization',
|
|
10
|
-
'content-length',
|
|
11
|
-
'content-type',
|
|
12
|
-
'etag',
|
|
13
|
-
'expires',
|
|
14
|
-
'from',
|
|
15
|
-
'host',
|
|
16
|
-
'if-modified-since',
|
|
17
|
-
'if-unmodified-since',
|
|
18
|
-
'last-modified',
|
|
19
|
-
'location',
|
|
20
|
-
'max-forwards',
|
|
21
|
-
'proxy-authorization',
|
|
22
|
-
'referer',
|
|
23
|
-
'retry-after',
|
|
24
|
-
'user-agent',
|
|
25
|
-
]);
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Parse headers into an object
|
|
29
|
-
*
|
|
30
|
-
* ```
|
|
31
|
-
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
|
32
|
-
* Content-Type: application/json
|
|
33
|
-
* Connection: keep-alive
|
|
34
|
-
* Transfer-Encoding: chunked
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @param {String} rawHeaders Headers needing to be parsed
|
|
38
|
-
*
|
|
39
|
-
* @returns {Object} Headers parsed into an object
|
|
40
|
-
*/
|
|
41
|
-
export default (rawHeaders) => {
|
|
42
|
-
const parsed = {};
|
|
43
|
-
let key;
|
|
44
|
-
let val;
|
|
45
|
-
let i;
|
|
46
|
-
|
|
47
|
-
rawHeaders &&
|
|
48
|
-
rawHeaders.split('\n').forEach(function parser(line) {
|
|
49
|
-
i = line.indexOf(':');
|
|
50
|
-
key = line.substring(0, i).trim().toLowerCase();
|
|
51
|
-
val = line.substring(i + 1).trim();
|
|
52
|
-
|
|
53
|
-
if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (key === 'set-cookie') {
|
|
58
|
-
if (parsed[key]) {
|
|
59
|
-
parsed[key].push(val);
|
|
60
|
-
} else {
|
|
61
|
-
parsed[key] = [val];
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
return parsed;
|
|
69
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import speedometer from './speedometer.js';
|
|
2
|
-
import throttle from './throttle.js';
|
|
3
|
-
import utils from '../utils.js';
|
|
4
|
-
|
|
5
|
-
export const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
6
|
-
let bytesNotified = 0;
|
|
7
|
-
const _speedometer = speedometer(50, 250);
|
|
8
|
-
|
|
9
|
-
return throttle((e) => {
|
|
10
|
-
if (!e || typeof e.loaded !== 'number') {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const rawLoaded = e.loaded;
|
|
14
|
-
const total = e.lengthComputable ? e.total : undefined;
|
|
15
|
-
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
16
|
-
const progressBytes = Math.max(0, loaded - bytesNotified);
|
|
17
|
-
const rate = _speedometer(progressBytes);
|
|
18
|
-
|
|
19
|
-
bytesNotified = Math.max(bytesNotified, loaded);
|
|
20
|
-
|
|
21
|
-
const data = {
|
|
22
|
-
loaded,
|
|
23
|
-
total,
|
|
24
|
-
progress: total ? loaded / total : undefined,
|
|
25
|
-
bytes: progressBytes,
|
|
26
|
-
rate: rate ? rate : undefined,
|
|
27
|
-
estimated: rate && total ? (total - loaded) / rate : undefined,
|
|
28
|
-
event: e,
|
|
29
|
-
lengthComputable: total != null,
|
|
30
|
-
[isDownloadStream ? 'download' : 'upload']: true,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
listener(data);
|
|
34
|
-
}, freq);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const progressEventDecorator = (total, throttled) => {
|
|
38
|
-
const lengthComputable = total != null;
|
|
39
|
-
|
|
40
|
-
return [
|
|
41
|
-
(loaded) =>
|
|
42
|
-
throttled[0]({
|
|
43
|
-
lengthComputable,
|
|
44
|
-
total,
|
|
45
|
-
loaded,
|
|
46
|
-
}),
|
|
47
|
-
throttled[1],
|
|
48
|
-
];
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const asyncDecorator =
|
|
52
|
-
(fn) =>
|
|
53
|
-
(...args) =>
|
|
54
|
-
utils.asap(() => fn(...args));
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const { asyncIterator } = Symbol;
|
|
2
|
-
|
|
3
|
-
const readBlob = async function* (blob) {
|
|
4
|
-
if (blob.stream) {
|
|
5
|
-
yield* blob.stream();
|
|
6
|
-
} else if (blob.arrayBuffer) {
|
|
7
|
-
yield await blob.arrayBuffer();
|
|
8
|
-
} else if (blob[asyncIterator]) {
|
|
9
|
-
yield* blob[asyncIterator]();
|
|
10
|
-
} else {
|
|
11
|
-
yield blob;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default readBlob;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import platform from '../platform/index.js';
|
|
2
|
-
import utils from '../utils.js';
|
|
3
|
-
import AxiosError from '../core/AxiosError.js';
|
|
4
|
-
import isURLSameOrigin from './isURLSameOrigin.js';
|
|
5
|
-
import cookies from './cookies.js';
|
|
6
|
-
import buildFullPath from '../core/buildFullPath.js';
|
|
7
|
-
import mergeConfig from '../core/mergeConfig.js';
|
|
8
|
-
import AxiosHeaders from '../core/AxiosHeaders.js';
|
|
9
|
-
import buildURL from './buildURL.js';
|
|
10
|
-
|
|
11
|
-
const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
|
|
12
|
-
|
|
13
|
-
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
14
|
-
if (policy !== 'content-only') {
|
|
15
|
-
headers.set(formHeaders);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
Object.entries(formHeaders || {}).forEach(([key, val]) => {
|
|
20
|
-
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
21
|
-
headers.set(key, val);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
|
|
28
|
-
* This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
|
|
29
|
-
*
|
|
30
|
-
* @param {string} str The string to encode
|
|
31
|
-
*
|
|
32
|
-
* @returns {string} UTF-8 bytes as a Latin-1 string
|
|
33
|
-
*/
|
|
34
|
-
const encodeUTF8 = (str) =>
|
|
35
|
-
encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, (_, hex) =>
|
|
36
|
-
String.fromCharCode(parseInt(hex, 16))
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
function resolveConfig(config) {
|
|
40
|
-
const newConfig = mergeConfig({}, config);
|
|
41
|
-
|
|
42
|
-
// Read only own properties to prevent prototype pollution gadgets
|
|
43
|
-
// (e.g. Object.prototype.baseURL = 'https://evil.com').
|
|
44
|
-
const own = (key) => (utils.hasOwnProp(newConfig, key) ? newConfig[key] : undefined);
|
|
45
|
-
|
|
46
|
-
const data = own('data');
|
|
47
|
-
let withXSRFToken = own('withXSRFToken');
|
|
48
|
-
const xsrfHeaderName = own('xsrfHeaderName');
|
|
49
|
-
const xsrfCookieName = own('xsrfCookieName');
|
|
50
|
-
let headers = own('headers');
|
|
51
|
-
const auth = own('auth');
|
|
52
|
-
const baseURL = own('baseURL');
|
|
53
|
-
const allowAbsoluteUrls = own('allowAbsoluteUrls');
|
|
54
|
-
const url = own('url');
|
|
55
|
-
|
|
56
|
-
newConfig.headers = headers = AxiosHeaders.from(headers);
|
|
57
|
-
|
|
58
|
-
newConfig.url = buildURL(
|
|
59
|
-
buildFullPath(baseURL, url, allowAbsoluteUrls, newConfig),
|
|
60
|
-
own('params'),
|
|
61
|
-
own('paramsSerializer')
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
// HTTP basic authentication
|
|
65
|
-
if (auth) {
|
|
66
|
-
const username = utils.getSafeProp(auth, 'username') || '';
|
|
67
|
-
const password = utils.getSafeProp(auth, 'password') || '';
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
headers.set(
|
|
71
|
-
'Authorization',
|
|
72
|
-
'Basic ' + btoa(username + ':' + (password ? encodeUTF8(password) : ''))
|
|
73
|
-
);
|
|
74
|
-
} catch (e) {
|
|
75
|
-
throw AxiosError.from(e, AxiosError.ERR_BAD_OPTION_VALUE, config);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (utils.isFormData(data)) {
|
|
80
|
-
if (
|
|
81
|
-
platform.hasStandardBrowserEnv ||
|
|
82
|
-
platform.hasStandardBrowserWebWorkerEnv ||
|
|
83
|
-
utils.isReactNative(data)
|
|
84
|
-
) {
|
|
85
|
-
headers.setContentType(undefined); // browser/web worker/RN handles it
|
|
86
|
-
} else if (utils.isFunction(data.getHeaders)) {
|
|
87
|
-
// Node.js FormData (like form-data package)
|
|
88
|
-
setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Add xsrf header
|
|
93
|
-
// This is only done if running in a standard browser environment.
|
|
94
|
-
// Specifically not if we're in a web worker, or react-native.
|
|
95
|
-
|
|
96
|
-
if (platform.hasStandardBrowserEnv) {
|
|
97
|
-
if (utils.isFunction(withXSRFToken)) {
|
|
98
|
-
withXSRFToken = withXSRFToken(newConfig);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Strict boolean check — prevents proto-pollution gadgets (e.g. Object.prototype.withXSRFToken = 1)
|
|
102
|
-
// and misconfigurations (e.g. "false") from short-circuiting the same-origin check and leaking
|
|
103
|
-
// the XSRF token cross-origin.
|
|
104
|
-
const shouldSendXSRF =
|
|
105
|
-
withXSRFToken === true || (withXSRFToken == null && isURLSameOrigin(newConfig.url));
|
|
106
|
-
|
|
107
|
-
if (shouldSendXSRF) {
|
|
108
|
-
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
109
|
-
|
|
110
|
-
if (xsrfValue) {
|
|
111
|
-
headers.set(xsrfHeaderName, xsrfValue);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return newConfig;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export default resolveConfig;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import utils from '../utils.js';
|
|
4
|
-
|
|
5
|
-
function trimSPorHTAB(str) {
|
|
6
|
-
let start = 0;
|
|
7
|
-
let end = str.length;
|
|
8
|
-
|
|
9
|
-
while (start < end) {
|
|
10
|
-
const code = str.charCodeAt(start);
|
|
11
|
-
|
|
12
|
-
if (code !== 0x09 && code !== 0x20) {
|
|
13
|
-
break;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
start += 1;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
while (end > start) {
|
|
20
|
-
const code = str.charCodeAt(end - 1);
|
|
21
|
-
|
|
22
|
-
if (code !== 0x09 && code !== 0x20) {
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
end -= 1;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// The control-code ranges are intentional: header sanitization strips C0/DEL bytes.
|
|
33
|
-
// eslint-disable-next-line no-control-regex
|
|
34
|
-
const INVALID_UNICODE_HEADER_VALUE_CHARS = new RegExp('[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+', 'g');
|
|
35
|
-
// eslint-disable-next-line no-control-regex
|
|
36
|
-
const INVALID_BYTE_STRING_HEADER_VALUE_CHARS = new RegExp('[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+', 'g');
|
|
37
|
-
|
|
38
|
-
function sanitizeValue(value, invalidChars) {
|
|
39
|
-
if (utils.isArray(value)) {
|
|
40
|
-
return value.map((item) => sanitizeValue(item, invalidChars));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return trimSPorHTAB(String(value).replace(invalidChars, ''));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const sanitizeHeaderValue = (value) =>
|
|
47
|
-
sanitizeValue(value, INVALID_UNICODE_HEADER_VALUE_CHARS);
|
|
48
|
-
|
|
49
|
-
export const sanitizeByteStringHeaderValue = (value) =>
|
|
50
|
-
sanitizeValue(value, INVALID_BYTE_STRING_HEADER_VALUE_CHARS);
|
|
51
|
-
|
|
52
|
-
export function toByteStringHeaderObject(headers) {
|
|
53
|
-
const byteStringHeaders = Object.create(null);
|
|
54
|
-
|
|
55
|
-
utils.forEach(headers.toJSON(), (value, header) => {
|
|
56
|
-
byteStringHeaders[header] = sanitizeByteStringHeaderValue(value);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
return byteStringHeaders;
|
|
60
|
-
}
|