hanbiro-react16-sdk 1.0.20 → 1.0.21
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/components/ChatAIDraft/SettingPopper.js +5 -5
- package/dist/components/CountryFlag/flags/KRFlag.js +1 -1
- package/dist/hanbiro-react16-sdk.style.css +1 -1
- package/dist/hanbiro-react16-sdk.umd.js +2 -2
- package/dist/index.js +1 -1
- package/dist/utils/api.d.ts +9 -0
- package/dist/utils/api.js +55 -0
- package/package.json +1 -2
- package/dist/node_modules/axios/index.js +0 -38
- package/dist/node_modules/axios/lib/adapters/adapters.js +0 -71
- package/dist/node_modules/axios/lib/adapters/fetch.js +0 -272
- package/dist/node_modules/axios/lib/adapters/xhr.js +0 -153
- package/dist/node_modules/axios/lib/axios.js +0 -50
- package/dist/node_modules/axios/lib/cancel/CancelToken.js +0 -99
- package/dist/node_modules/axios/lib/cancel/CanceledError.js +0 -20
- package/dist/node_modules/axios/lib/cancel/isCancel.js +0 -6
- package/dist/node_modules/axios/lib/core/Axios.js +0 -220
- package/dist/node_modules/axios/lib/core/AxiosError.js +0 -76
- package/dist/node_modules/axios/lib/core/AxiosHeaders.js +0 -238
- package/dist/node_modules/axios/lib/core/InterceptorManager.js +0 -66
- package/dist/node_modules/axios/lib/core/buildFullPath.js +0 -12
- package/dist/node_modules/axios/lib/core/dispatchRequest.js +0 -48
- package/dist/node_modules/axios/lib/core/mergeConfig.js +0 -100
- package/dist/node_modules/axios/lib/core/settle.js +0 -20
- package/dist/node_modules/axios/lib/core/transformData.js +0 -17
- package/dist/node_modules/axios/lib/defaults/index.js +0 -120
- package/dist/node_modules/axios/lib/defaults/transitional.js +0 -9
- package/dist/node_modules/axios/lib/env/data.js +0 -4
- package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -34
- package/dist/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -77
- package/dist/node_modules/axios/lib/helpers/bind.js +0 -8
- package/dist/node_modules/axios/lib/helpers/buildURL.js +0 -32
- package/dist/node_modules/axios/lib/helpers/combineURLs.js +0 -6
- package/dist/node_modules/axios/lib/helpers/composeSignals.js +0 -41
- package/dist/node_modules/axios/lib/helpers/cookies.js +0 -49
- package/dist/node_modules/axios/lib/helpers/formDataToJSON.js +0 -54
- package/dist/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -9
- package/dist/node_modules/axios/lib/helpers/isAxiosError.js +0 -7
- package/dist/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -11
- package/dist/node_modules/axios/lib/helpers/null.js +0 -4
- package/dist/node_modules/axios/lib/helpers/parseHeaders.js +0 -47
- package/dist/node_modules/axios/lib/helpers/parseProtocol.js +0 -7
- package/dist/node_modules/axios/lib/helpers/progressEventReducer.js +0 -44
- package/dist/node_modules/axios/lib/helpers/resolveConfig.js +0 -52
- package/dist/node_modules/axios/lib/helpers/speedometer.js +0 -36
- package/dist/node_modules/axios/lib/helpers/spread.js +0 -8
- package/dist/node_modules/axios/lib/helpers/throttle.js +0 -35
- package/dist/node_modules/axios/lib/helpers/toFormData.js +0 -120
- package/dist/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -33
- package/dist/node_modules/axios/lib/helpers/trackStream.js +0 -169
- package/dist/node_modules/axios/lib/helpers/validator.js +0 -70
- package/dist/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -4
- package/dist/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -4
- package/dist/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -5
- package/dist/node_modules/axios/lib/platform/browser/index.js +0 -15
- package/dist/node_modules/axios/lib/platform/common/utils.js +0 -15
- package/dist/node_modules/axios/lib/platform/index.js +0 -22
- package/dist/node_modules/axios/lib/utils.js +0 -429
- package/dist/utils/axiosAPI.d.ts +0 -1
- package/dist/utils/axiosAPI.js +0 -89
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import CanceledError from "./CanceledError.js";
|
|
2
|
-
class CancelToken {
|
|
3
|
-
constructor(executor) {
|
|
4
|
-
if (typeof executor !== "function") {
|
|
5
|
-
throw new TypeError("executor must be a function.");
|
|
6
|
-
}
|
|
7
|
-
let resolvePromise;
|
|
8
|
-
this.promise = new Promise(function promiseExecutor(resolve) {
|
|
9
|
-
resolvePromise = resolve;
|
|
10
|
-
});
|
|
11
|
-
const token = this;
|
|
12
|
-
this.promise.then((cancel) => {
|
|
13
|
-
if (!token._listeners) return;
|
|
14
|
-
let i = token._listeners.length;
|
|
15
|
-
while (i-- > 0) {
|
|
16
|
-
token._listeners[i](cancel);
|
|
17
|
-
}
|
|
18
|
-
token._listeners = null;
|
|
19
|
-
});
|
|
20
|
-
this.promise.then = (onfulfilled) => {
|
|
21
|
-
let _resolve;
|
|
22
|
-
const promise = new Promise((resolve) => {
|
|
23
|
-
token.subscribe(resolve);
|
|
24
|
-
_resolve = resolve;
|
|
25
|
-
}).then(onfulfilled);
|
|
26
|
-
promise.cancel = function reject() {
|
|
27
|
-
token.unsubscribe(_resolve);
|
|
28
|
-
};
|
|
29
|
-
return promise;
|
|
30
|
-
};
|
|
31
|
-
executor(function cancel(message, config, request) {
|
|
32
|
-
if (token.reason) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
token.reason = new CanceledError(message, config, request);
|
|
36
|
-
resolvePromise(token.reason);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Throws a `CanceledError` if cancellation has been requested.
|
|
41
|
-
*/
|
|
42
|
-
throwIfRequested() {
|
|
43
|
-
if (this.reason) {
|
|
44
|
-
throw this.reason;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Subscribe to the cancel signal
|
|
49
|
-
*/
|
|
50
|
-
subscribe(listener) {
|
|
51
|
-
if (this.reason) {
|
|
52
|
-
listener(this.reason);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (this._listeners) {
|
|
56
|
-
this._listeners.push(listener);
|
|
57
|
-
} else {
|
|
58
|
-
this._listeners = [listener];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Unsubscribe from the cancel signal
|
|
63
|
-
*/
|
|
64
|
-
unsubscribe(listener) {
|
|
65
|
-
if (!this._listeners) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const index = this._listeners.indexOf(listener);
|
|
69
|
-
if (index !== -1) {
|
|
70
|
-
this._listeners.splice(index, 1);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
toAbortSignal() {
|
|
74
|
-
const controller = new AbortController();
|
|
75
|
-
const abort = (err) => {
|
|
76
|
-
controller.abort(err);
|
|
77
|
-
};
|
|
78
|
-
this.subscribe(abort);
|
|
79
|
-
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
|
80
|
-
return controller.signal;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
84
|
-
* cancels the `CancelToken`.
|
|
85
|
-
*/
|
|
86
|
-
static source() {
|
|
87
|
-
let cancel;
|
|
88
|
-
const token = new CancelToken(function executor(c) {
|
|
89
|
-
cancel = c;
|
|
90
|
-
});
|
|
91
|
-
return {
|
|
92
|
-
token,
|
|
93
|
-
cancel
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
export {
|
|
98
|
-
CancelToken as default
|
|
99
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import AxiosError from "../core/AxiosError.js";
|
|
2
|
-
class CanceledError extends AxiosError {
|
|
3
|
-
/**
|
|
4
|
-
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
|
5
|
-
*
|
|
6
|
-
* @param {string=} message The message.
|
|
7
|
-
* @param {Object=} config The config.
|
|
8
|
-
* @param {Object=} request The request.
|
|
9
|
-
*
|
|
10
|
-
* @returns {CanceledError} The created error.
|
|
11
|
-
*/
|
|
12
|
-
constructor(message, config, request) {
|
|
13
|
-
super(message == null ? "canceled" : message, AxiosError.ERR_CANCELED, config, request);
|
|
14
|
-
this.name = "CanceledError";
|
|
15
|
-
this.__CANCEL__ = true;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
CanceledError as default
|
|
20
|
-
};
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
import utils from "../utils.js";
|
|
22
|
-
import buildURL from "../helpers/buildURL.js";
|
|
23
|
-
import InterceptorManager from "./InterceptorManager.js";
|
|
24
|
-
import dispatchRequest from "./dispatchRequest.js";
|
|
25
|
-
import mergeConfig from "./mergeConfig.js";
|
|
26
|
-
import buildFullPath from "./buildFullPath.js";
|
|
27
|
-
import validator from "../helpers/validator.js";
|
|
28
|
-
import AxiosHeaders from "./AxiosHeaders.js";
|
|
29
|
-
import transitionalDefaults from "../defaults/transitional.js";
|
|
30
|
-
const validators = validator.validators;
|
|
31
|
-
class Axios {
|
|
32
|
-
constructor(instanceConfig) {
|
|
33
|
-
this.defaults = instanceConfig || {};
|
|
34
|
-
this.interceptors = {
|
|
35
|
-
request: new InterceptorManager(),
|
|
36
|
-
response: new InterceptorManager()
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Dispatch a request
|
|
41
|
-
*
|
|
42
|
-
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
|
43
|
-
* @param {?Object} config
|
|
44
|
-
*
|
|
45
|
-
* @returns {Promise} The Promise to be fulfilled
|
|
46
|
-
*/
|
|
47
|
-
request(configOrUrl, config) {
|
|
48
|
-
return __async(this, null, function* () {
|
|
49
|
-
try {
|
|
50
|
-
return yield this._request(configOrUrl, config);
|
|
51
|
-
} catch (err) {
|
|
52
|
-
if (err instanceof Error) {
|
|
53
|
-
let dummy = {};
|
|
54
|
-
Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
|
|
55
|
-
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
|
|
56
|
-
try {
|
|
57
|
-
if (!err.stack) {
|
|
58
|
-
err.stack = stack;
|
|
59
|
-
} else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))) {
|
|
60
|
-
err.stack += "\n" + stack;
|
|
61
|
-
}
|
|
62
|
-
} catch (e) {
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
throw err;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
_request(configOrUrl, config) {
|
|
70
|
-
if (typeof configOrUrl === "string") {
|
|
71
|
-
config = config || {};
|
|
72
|
-
config.url = configOrUrl;
|
|
73
|
-
} else {
|
|
74
|
-
config = configOrUrl || {};
|
|
75
|
-
}
|
|
76
|
-
config = mergeConfig(this.defaults, config);
|
|
77
|
-
const { transitional, paramsSerializer, headers } = config;
|
|
78
|
-
if (transitional !== void 0) {
|
|
79
|
-
validator.assertOptions(
|
|
80
|
-
transitional,
|
|
81
|
-
{
|
|
82
|
-
silentJSONParsing: validators.transitional(validators.boolean),
|
|
83
|
-
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
84
|
-
clarifyTimeoutError: validators.transitional(validators.boolean),
|
|
85
|
-
legacyInterceptorReqResOrdering: validators.transitional(validators.boolean)
|
|
86
|
-
},
|
|
87
|
-
false
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
if (paramsSerializer != null) {
|
|
91
|
-
if (utils.isFunction(paramsSerializer)) {
|
|
92
|
-
config.paramsSerializer = {
|
|
93
|
-
serialize: paramsSerializer
|
|
94
|
-
};
|
|
95
|
-
} else {
|
|
96
|
-
validator.assertOptions(
|
|
97
|
-
paramsSerializer,
|
|
98
|
-
{
|
|
99
|
-
encode: validators.function,
|
|
100
|
-
serialize: validators.function
|
|
101
|
-
},
|
|
102
|
-
true
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (config.allowAbsoluteUrls !== void 0) ;
|
|
107
|
-
else if (this.defaults.allowAbsoluteUrls !== void 0) {
|
|
108
|
-
config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
|
109
|
-
} else {
|
|
110
|
-
config.allowAbsoluteUrls = true;
|
|
111
|
-
}
|
|
112
|
-
validator.assertOptions(
|
|
113
|
-
config,
|
|
114
|
-
{
|
|
115
|
-
baseUrl: validators.spelling("baseURL"),
|
|
116
|
-
withXsrfToken: validators.spelling("withXSRFToken")
|
|
117
|
-
},
|
|
118
|
-
true
|
|
119
|
-
);
|
|
120
|
-
config.method = (config.method || this.defaults.method || "get").toLowerCase();
|
|
121
|
-
let contextHeaders = headers && utils.merge(headers.common, headers[config.method]);
|
|
122
|
-
headers && utils.forEach(["delete", "get", "head", "post", "put", "patch", "common"], (method) => {
|
|
123
|
-
delete headers[method];
|
|
124
|
-
});
|
|
125
|
-
config.headers = AxiosHeaders.concat(contextHeaders, headers);
|
|
126
|
-
const requestInterceptorChain = [];
|
|
127
|
-
let synchronousRequestInterceptors = true;
|
|
128
|
-
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
129
|
-
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
133
|
-
const transitional2 = config.transitional || transitionalDefaults;
|
|
134
|
-
const legacyInterceptorReqResOrdering = transitional2 && transitional2.legacyInterceptorReqResOrdering;
|
|
135
|
-
if (legacyInterceptorReqResOrdering) {
|
|
136
|
-
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
137
|
-
} else {
|
|
138
|
-
requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
const responseInterceptorChain = [];
|
|
142
|
-
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
143
|
-
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
144
|
-
});
|
|
145
|
-
let promise;
|
|
146
|
-
let i = 0;
|
|
147
|
-
let len;
|
|
148
|
-
if (!synchronousRequestInterceptors) {
|
|
149
|
-
const chain = [dispatchRequest.bind(this), void 0];
|
|
150
|
-
chain.unshift(...requestInterceptorChain);
|
|
151
|
-
chain.push(...responseInterceptorChain);
|
|
152
|
-
len = chain.length;
|
|
153
|
-
promise = Promise.resolve(config);
|
|
154
|
-
while (i < len) {
|
|
155
|
-
promise = promise.then(chain[i++], chain[i++]);
|
|
156
|
-
}
|
|
157
|
-
return promise;
|
|
158
|
-
}
|
|
159
|
-
len = requestInterceptorChain.length;
|
|
160
|
-
let newConfig = config;
|
|
161
|
-
while (i < len) {
|
|
162
|
-
const onFulfilled = requestInterceptorChain[i++];
|
|
163
|
-
const onRejected = requestInterceptorChain[i++];
|
|
164
|
-
try {
|
|
165
|
-
newConfig = onFulfilled(newConfig);
|
|
166
|
-
} catch (error) {
|
|
167
|
-
onRejected.call(this, error);
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
try {
|
|
172
|
-
promise = dispatchRequest.call(this, newConfig);
|
|
173
|
-
} catch (error) {
|
|
174
|
-
return Promise.reject(error);
|
|
175
|
-
}
|
|
176
|
-
i = 0;
|
|
177
|
-
len = responseInterceptorChain.length;
|
|
178
|
-
while (i < len) {
|
|
179
|
-
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
|
|
180
|
-
}
|
|
181
|
-
return promise;
|
|
182
|
-
}
|
|
183
|
-
getUri(config) {
|
|
184
|
-
config = mergeConfig(this.defaults, config);
|
|
185
|
-
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
186
|
-
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
utils.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
|
|
190
|
-
Axios.prototype[method] = function(url, config) {
|
|
191
|
-
return this.request(
|
|
192
|
-
mergeConfig(config || {}, {
|
|
193
|
-
method,
|
|
194
|
-
url,
|
|
195
|
-
data: (config || {}).data
|
|
196
|
-
})
|
|
197
|
-
);
|
|
198
|
-
};
|
|
199
|
-
});
|
|
200
|
-
utils.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
|
|
201
|
-
function generateHTTPMethod(isForm) {
|
|
202
|
-
return function httpMethod(url, data, config) {
|
|
203
|
-
return this.request(
|
|
204
|
-
mergeConfig(config || {}, {
|
|
205
|
-
method,
|
|
206
|
-
headers: isForm ? {
|
|
207
|
-
"Content-Type": "multipart/form-data"
|
|
208
|
-
} : {},
|
|
209
|
-
url,
|
|
210
|
-
data
|
|
211
|
-
})
|
|
212
|
-
);
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
Axios.prototype[method] = generateHTTPMethod();
|
|
216
|
-
Axios.prototype[method + "Form"] = generateHTTPMethod(true);
|
|
217
|
-
});
|
|
218
|
-
export {
|
|
219
|
-
Axios as default
|
|
220
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import utils from "../utils.js";
|
|
2
|
-
class AxiosError extends Error {
|
|
3
|
-
static from(error, code, config, request, response, customProps) {
|
|
4
|
-
const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
|
|
5
|
-
axiosError.cause = error;
|
|
6
|
-
axiosError.name = error.name;
|
|
7
|
-
if (error.status != null && axiosError.status == null) {
|
|
8
|
-
axiosError.status = error.status;
|
|
9
|
-
}
|
|
10
|
-
customProps && Object.assign(axiosError, customProps);
|
|
11
|
-
return axiosError;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Create an Error with the specified message, config, error code, request and response.
|
|
15
|
-
*
|
|
16
|
-
* @param {string} message The error message.
|
|
17
|
-
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
|
18
|
-
* @param {Object} [config] The config.
|
|
19
|
-
* @param {Object} [request] The request.
|
|
20
|
-
* @param {Object} [response] The response.
|
|
21
|
-
*
|
|
22
|
-
* @returns {Error} The created error.
|
|
23
|
-
*/
|
|
24
|
-
constructor(message, code, config, request, response) {
|
|
25
|
-
super(message);
|
|
26
|
-
Object.defineProperty(this, "message", {
|
|
27
|
-
value: message,
|
|
28
|
-
enumerable: true,
|
|
29
|
-
writable: true,
|
|
30
|
-
configurable: true
|
|
31
|
-
});
|
|
32
|
-
this.name = "AxiosError";
|
|
33
|
-
this.isAxiosError = true;
|
|
34
|
-
code && (this.code = code);
|
|
35
|
-
config && (this.config = config);
|
|
36
|
-
request && (this.request = request);
|
|
37
|
-
if (response) {
|
|
38
|
-
this.response = response;
|
|
39
|
-
this.status = response.status;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
toJSON() {
|
|
43
|
-
return {
|
|
44
|
-
// Standard
|
|
45
|
-
message: this.message,
|
|
46
|
-
name: this.name,
|
|
47
|
-
// Microsoft
|
|
48
|
-
description: this.description,
|
|
49
|
-
number: this.number,
|
|
50
|
-
// Mozilla
|
|
51
|
-
fileName: this.fileName,
|
|
52
|
-
lineNumber: this.lineNumber,
|
|
53
|
-
columnNumber: this.columnNumber,
|
|
54
|
-
stack: this.stack,
|
|
55
|
-
// Axios
|
|
56
|
-
config: utils.toJSONObject(this.config),
|
|
57
|
-
code: this.code,
|
|
58
|
-
status: this.status
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
AxiosError.ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
|
|
63
|
-
AxiosError.ERR_BAD_OPTION = "ERR_BAD_OPTION";
|
|
64
|
-
AxiosError.ECONNABORTED = "ECONNABORTED";
|
|
65
|
-
AxiosError.ETIMEDOUT = "ETIMEDOUT";
|
|
66
|
-
AxiosError.ERR_NETWORK = "ERR_NETWORK";
|
|
67
|
-
AxiosError.ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
|
|
68
|
-
AxiosError.ERR_DEPRECATED = "ERR_DEPRECATED";
|
|
69
|
-
AxiosError.ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE";
|
|
70
|
-
AxiosError.ERR_BAD_REQUEST = "ERR_BAD_REQUEST";
|
|
71
|
-
AxiosError.ERR_CANCELED = "ERR_CANCELED";
|
|
72
|
-
AxiosError.ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT";
|
|
73
|
-
AxiosError.ERR_INVALID_URL = "ERR_INVALID_URL";
|
|
74
|
-
export {
|
|
75
|
-
AxiosError as default
|
|
76
|
-
};
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import utils from "../utils.js";
|
|
2
|
-
import parseHeaders from "../helpers/parseHeaders.js";
|
|
3
|
-
const $internals = Symbol("internals");
|
|
4
|
-
function normalizeHeader(header) {
|
|
5
|
-
return header && String(header).trim().toLowerCase();
|
|
6
|
-
}
|
|
7
|
-
function normalizeValue(value) {
|
|
8
|
-
if (value === false || value == null) {
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
return utils.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
12
|
-
}
|
|
13
|
-
function parseTokens(str) {
|
|
14
|
-
const tokens = /* @__PURE__ */ Object.create(null);
|
|
15
|
-
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
16
|
-
let match;
|
|
17
|
-
while (match = tokensRE.exec(str)) {
|
|
18
|
-
tokens[match[1]] = match[2];
|
|
19
|
-
}
|
|
20
|
-
return tokens;
|
|
21
|
-
}
|
|
22
|
-
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
23
|
-
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
|
24
|
-
if (utils.isFunction(filter)) {
|
|
25
|
-
return filter.call(this, value, header);
|
|
26
|
-
}
|
|
27
|
-
if (isHeaderNameFilter) {
|
|
28
|
-
value = header;
|
|
29
|
-
}
|
|
30
|
-
if (!utils.isString(value)) return;
|
|
31
|
-
if (utils.isString(filter)) {
|
|
32
|
-
return value.indexOf(filter) !== -1;
|
|
33
|
-
}
|
|
34
|
-
if (utils.isRegExp(filter)) {
|
|
35
|
-
return filter.test(value);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function formatHeader(header) {
|
|
39
|
-
return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
40
|
-
return char.toUpperCase() + str;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
function buildAccessors(obj, header) {
|
|
44
|
-
const accessorName = utils.toCamelCase(" " + header);
|
|
45
|
-
["get", "set", "has"].forEach((methodName) => {
|
|
46
|
-
Object.defineProperty(obj, methodName + accessorName, {
|
|
47
|
-
value: function(arg1, arg2, arg3) {
|
|
48
|
-
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
49
|
-
},
|
|
50
|
-
configurable: true
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
class AxiosHeaders {
|
|
55
|
-
constructor(headers) {
|
|
56
|
-
headers && this.set(headers);
|
|
57
|
-
}
|
|
58
|
-
set(header, valueOrRewrite, rewrite) {
|
|
59
|
-
const self = this;
|
|
60
|
-
function setHeader(_value, _header, _rewrite) {
|
|
61
|
-
const lHeader = normalizeHeader(_header);
|
|
62
|
-
if (!lHeader) {
|
|
63
|
-
throw new Error("header name must be a non-empty string");
|
|
64
|
-
}
|
|
65
|
-
const key = utils.findKey(self, lHeader);
|
|
66
|
-
if (!key || self[key] === void 0 || _rewrite === true || _rewrite === void 0 && self[key] !== false) {
|
|
67
|
-
self[key || _header] = normalizeValue(_value);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const setHeaders = (headers, _rewrite) => utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
71
|
-
if (utils.isPlainObject(header) || header instanceof this.constructor) {
|
|
72
|
-
setHeaders(header, valueOrRewrite);
|
|
73
|
-
} else if (utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
74
|
-
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
75
|
-
} else if (utils.isObject(header) && utils.isIterable(header)) {
|
|
76
|
-
let obj = {}, dest, key;
|
|
77
|
-
for (const entry of header) {
|
|
78
|
-
if (!utils.isArray(entry)) {
|
|
79
|
-
throw TypeError("Object iterator must return a key-value pair");
|
|
80
|
-
}
|
|
81
|
-
obj[key = entry[0]] = (dest = obj[key]) ? utils.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]] : entry[1];
|
|
82
|
-
}
|
|
83
|
-
setHeaders(obj, valueOrRewrite);
|
|
84
|
-
} else {
|
|
85
|
-
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
86
|
-
}
|
|
87
|
-
return this;
|
|
88
|
-
}
|
|
89
|
-
get(header, parser) {
|
|
90
|
-
header = normalizeHeader(header);
|
|
91
|
-
if (header) {
|
|
92
|
-
const key = utils.findKey(this, header);
|
|
93
|
-
if (key) {
|
|
94
|
-
const value = this[key];
|
|
95
|
-
if (!parser) {
|
|
96
|
-
return value;
|
|
97
|
-
}
|
|
98
|
-
if (parser === true) {
|
|
99
|
-
return parseTokens(value);
|
|
100
|
-
}
|
|
101
|
-
if (utils.isFunction(parser)) {
|
|
102
|
-
return parser.call(this, value, key);
|
|
103
|
-
}
|
|
104
|
-
if (utils.isRegExp(parser)) {
|
|
105
|
-
return parser.exec(value);
|
|
106
|
-
}
|
|
107
|
-
throw new TypeError("parser must be boolean|regexp|function");
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
has(header, matcher) {
|
|
112
|
-
header = normalizeHeader(header);
|
|
113
|
-
if (header) {
|
|
114
|
-
const key = utils.findKey(this, header);
|
|
115
|
-
return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
|
116
|
-
}
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
delete(header, matcher) {
|
|
120
|
-
const self = this;
|
|
121
|
-
let deleted = false;
|
|
122
|
-
function deleteHeader(_header) {
|
|
123
|
-
_header = normalizeHeader(_header);
|
|
124
|
-
if (_header) {
|
|
125
|
-
const key = utils.findKey(self, _header);
|
|
126
|
-
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
|
127
|
-
delete self[key];
|
|
128
|
-
deleted = true;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (utils.isArray(header)) {
|
|
133
|
-
header.forEach(deleteHeader);
|
|
134
|
-
} else {
|
|
135
|
-
deleteHeader(header);
|
|
136
|
-
}
|
|
137
|
-
return deleted;
|
|
138
|
-
}
|
|
139
|
-
clear(matcher) {
|
|
140
|
-
const keys = Object.keys(this);
|
|
141
|
-
let i = keys.length;
|
|
142
|
-
let deleted = false;
|
|
143
|
-
while (i--) {
|
|
144
|
-
const key = keys[i];
|
|
145
|
-
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
146
|
-
delete this[key];
|
|
147
|
-
deleted = true;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return deleted;
|
|
151
|
-
}
|
|
152
|
-
normalize(format) {
|
|
153
|
-
const self = this;
|
|
154
|
-
const headers = {};
|
|
155
|
-
utils.forEach(this, (value, header) => {
|
|
156
|
-
const key = utils.findKey(headers, header);
|
|
157
|
-
if (key) {
|
|
158
|
-
self[key] = normalizeValue(value);
|
|
159
|
-
delete self[header];
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
163
|
-
if (normalized !== header) {
|
|
164
|
-
delete self[header];
|
|
165
|
-
}
|
|
166
|
-
self[normalized] = normalizeValue(value);
|
|
167
|
-
headers[normalized] = true;
|
|
168
|
-
});
|
|
169
|
-
return this;
|
|
170
|
-
}
|
|
171
|
-
concat(...targets) {
|
|
172
|
-
return this.constructor.concat(this, ...targets);
|
|
173
|
-
}
|
|
174
|
-
toJSON(asStrings) {
|
|
175
|
-
const obj = /* @__PURE__ */ Object.create(null);
|
|
176
|
-
utils.forEach(this, (value, header) => {
|
|
177
|
-
value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(", ") : value);
|
|
178
|
-
});
|
|
179
|
-
return obj;
|
|
180
|
-
}
|
|
181
|
-
[Symbol.iterator]() {
|
|
182
|
-
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
183
|
-
}
|
|
184
|
-
toString() {
|
|
185
|
-
return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
|
|
186
|
-
}
|
|
187
|
-
getSetCookie() {
|
|
188
|
-
return this.get("set-cookie") || [];
|
|
189
|
-
}
|
|
190
|
-
get [Symbol.toStringTag]() {
|
|
191
|
-
return "AxiosHeaders";
|
|
192
|
-
}
|
|
193
|
-
static from(thing) {
|
|
194
|
-
return thing instanceof this ? thing : new this(thing);
|
|
195
|
-
}
|
|
196
|
-
static concat(first, ...targets) {
|
|
197
|
-
const computed = new this(first);
|
|
198
|
-
targets.forEach((target) => computed.set(target));
|
|
199
|
-
return computed;
|
|
200
|
-
}
|
|
201
|
-
static accessor(header) {
|
|
202
|
-
const internals = this[$internals] = this[$internals] = {
|
|
203
|
-
accessors: {}
|
|
204
|
-
};
|
|
205
|
-
const accessors = internals.accessors;
|
|
206
|
-
const prototype = this.prototype;
|
|
207
|
-
function defineAccessor(_header) {
|
|
208
|
-
const lHeader = normalizeHeader(_header);
|
|
209
|
-
if (!accessors[lHeader]) {
|
|
210
|
-
buildAccessors(prototype, _header);
|
|
211
|
-
accessors[lHeader] = true;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
215
|
-
return this;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
AxiosHeaders.accessor([
|
|
219
|
-
"Content-Type",
|
|
220
|
-
"Content-Length",
|
|
221
|
-
"Accept",
|
|
222
|
-
"Accept-Encoding",
|
|
223
|
-
"User-Agent",
|
|
224
|
-
"Authorization"
|
|
225
|
-
]);
|
|
226
|
-
utils.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
|
|
227
|
-
let mapped = key[0].toUpperCase() + key.slice(1);
|
|
228
|
-
return {
|
|
229
|
-
get: () => value,
|
|
230
|
-
set(headerValue) {
|
|
231
|
-
this[mapped] = headerValue;
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
});
|
|
235
|
-
utils.freezeMethods(AxiosHeaders);
|
|
236
|
-
export {
|
|
237
|
-
AxiosHeaders as default
|
|
238
|
-
};
|