node-red-contrib-tak-registration 0.1.0
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/LICENSE +14 -0
- package/README.md +35 -0
- package/node_modules/adm-zip/LICENSE +21 -0
- package/node_modules/adm-zip/README.md +65 -0
- package/node_modules/adm-zip/adm-zip.js +783 -0
- package/node_modules/adm-zip/headers/entryHeader.js +338 -0
- package/node_modules/adm-zip/headers/index.js +2 -0
- package/node_modules/adm-zip/headers/mainHeader.js +129 -0
- package/node_modules/adm-zip/methods/deflater.js +33 -0
- package/node_modules/adm-zip/methods/index.js +3 -0
- package/node_modules/adm-zip/methods/inflater.js +31 -0
- package/node_modules/adm-zip/methods/zipcrypto.js +170 -0
- package/node_modules/adm-zip/package.json +77 -0
- package/node_modules/adm-zip/util/constants.js +142 -0
- package/node_modules/adm-zip/util/errors.js +35 -0
- package/node_modules/adm-zip/util/fattr.js +79 -0
- package/node_modules/adm-zip/util/fileSystem.js +11 -0
- package/node_modules/adm-zip/util/index.js +4 -0
- package/node_modules/adm-zip/util/utils.js +246 -0
- package/node_modules/adm-zip/zipEntry.js +333 -0
- package/node_modules/adm-zip/zipFile.js +384 -0
- package/node_modules/asynckit/LICENSE +21 -0
- package/node_modules/asynckit/README.md +233 -0
- package/node_modules/asynckit/bench.js +76 -0
- package/node_modules/asynckit/index.js +6 -0
- package/node_modules/asynckit/lib/abort.js +29 -0
- package/node_modules/asynckit/lib/async.js +34 -0
- package/node_modules/asynckit/lib/defer.js +26 -0
- package/node_modules/asynckit/lib/iterate.js +75 -0
- package/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/node_modules/asynckit/lib/state.js +37 -0
- package/node_modules/asynckit/lib/streamify.js +141 -0
- package/node_modules/asynckit/lib/terminator.js +29 -0
- package/node_modules/asynckit/package.json +91 -0
- package/node_modules/asynckit/parallel.js +43 -0
- package/node_modules/asynckit/serial.js +17 -0
- package/node_modules/asynckit/serialOrdered.js +75 -0
- package/node_modules/asynckit/stream.js +21 -0
- package/node_modules/axios/CHANGELOG.md +836 -0
- package/node_modules/axios/LICENSE +19 -0
- package/node_modules/axios/README.md +892 -0
- package/node_modules/axios/SECURITY.md +5 -0
- package/node_modules/axios/UPGRADE_GUIDE.md +162 -0
- package/node_modules/axios/dist/axios.js +2275 -0
- package/node_modules/axios/dist/axios.map +1 -0
- package/node_modules/axios/dist/axios.min.js +2 -0
- package/node_modules/axios/dist/axios.min.map +1 -0
- package/node_modules/axios/index.d.ts +206 -0
- package/node_modules/axios/index.js +1 -0
- package/node_modules/axios/lib/adapters/README.md +37 -0
- package/node_modules/axios/lib/adapters/http.js +363 -0
- package/node_modules/axios/lib/adapters/xhr.js +212 -0
- package/node_modules/axios/lib/axios.js +57 -0
- package/node_modules/axios/lib/cancel/Cancel.js +19 -0
- package/node_modules/axios/lib/cancel/CancelToken.js +119 -0
- package/node_modules/axios/lib/cancel/isCancel.js +5 -0
- package/node_modules/axios/lib/core/Axios.js +148 -0
- package/node_modules/axios/lib/core/InterceptorManager.js +54 -0
- package/node_modules/axios/lib/core/README.md +8 -0
- package/node_modules/axios/lib/core/buildFullPath.js +20 -0
- package/node_modules/axios/lib/core/createError.js +18 -0
- package/node_modules/axios/lib/core/dispatchRequest.js +87 -0
- package/node_modules/axios/lib/core/enhanceError.js +43 -0
- package/node_modules/axios/lib/core/mergeConfig.js +99 -0
- package/node_modules/axios/lib/core/settle.js +25 -0
- package/node_modules/axios/lib/core/transformData.js +22 -0
- package/node_modules/axios/lib/defaults.js +134 -0
- package/node_modules/axios/lib/env/README.md +3 -0
- package/node_modules/axios/lib/env/data.js +3 -0
- package/node_modules/axios/lib/helpers/README.md +7 -0
- package/node_modules/axios/lib/helpers/bind.js +11 -0
- package/node_modules/axios/lib/helpers/buildURL.js +70 -0
- package/node_modules/axios/lib/helpers/combineURLs.js +14 -0
- package/node_modules/axios/lib/helpers/cookies.js +53 -0
- package/node_modules/axios/lib/helpers/deprecatedMethod.js +24 -0
- package/node_modules/axios/lib/helpers/isAbsoluteURL.js +14 -0
- package/node_modules/axios/lib/helpers/isAxiosError.js +11 -0
- package/node_modules/axios/lib/helpers/isURLSameOrigin.js +68 -0
- package/node_modules/axios/lib/helpers/normalizeHeaderName.js +12 -0
- package/node_modules/axios/lib/helpers/parseHeaders.js +53 -0
- package/node_modules/axios/lib/helpers/spread.js +27 -0
- package/node_modules/axios/lib/helpers/validator.js +82 -0
- package/node_modules/axios/lib/utils.js +349 -0
- package/node_modules/axios/package.json +113 -0
- package/node_modules/axios/tsconfig.json +14 -0
- package/node_modules/axios/tslint.json +6 -0
- package/node_modules/combined-stream/License +19 -0
- package/node_modules/combined-stream/Readme.md +138 -0
- package/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/node_modules/combined-stream/package.json +57 -0
- package/node_modules/combined-stream/yarn.lock +17 -0
- package/node_modules/delayed-stream/.npmignore +1 -0
- package/node_modules/delayed-stream/License +19 -0
- package/node_modules/delayed-stream/Makefile +7 -0
- package/node_modules/delayed-stream/Readme.md +141 -0
- package/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/node_modules/delayed-stream/package.json +62 -0
- package/node_modules/follow-redirects/LICENSE +18 -0
- package/node_modules/follow-redirects/README.md +148 -0
- package/node_modules/follow-redirects/debug.js +15 -0
- package/node_modules/follow-redirects/http.js +1 -0
- package/node_modules/follow-redirects/https.js +1 -0
- package/node_modules/follow-redirects/index.js +569 -0
- package/node_modules/follow-redirects/package.json +95 -0
- package/node_modules/form-data/License +19 -0
- package/node_modules/form-data/README.md.bak +358 -0
- package/node_modules/form-data/Readme.md +358 -0
- package/node_modules/form-data/index.d.ts +62 -0
- package/node_modules/form-data/lib/browser.js +2 -0
- package/node_modules/form-data/lib/form_data.js +501 -0
- package/node_modules/form-data/lib/populate.js +10 -0
- package/node_modules/form-data/package.json +101 -0
- package/node_modules/mime-db/HISTORY.md +499 -0
- package/node_modules/mime-db/LICENSE +22 -0
- package/node_modules/mime-db/README.md +100 -0
- package/node_modules/mime-db/db.json +8471 -0
- package/node_modules/mime-db/index.js +11 -0
- package/node_modules/mime-db/package.json +102 -0
- package/node_modules/mime-types/HISTORY.md +388 -0
- package/node_modules/mime-types/LICENSE +23 -0
- package/node_modules/mime-types/README.md +113 -0
- package/node_modules/mime-types/index.js +188 -0
- package/node_modules/mime-types/package.json +87 -0
- package/node_modules/uuid/CHANGELOG.md +229 -0
- package/node_modules/uuid/CONTRIBUTING.md +18 -0
- package/node_modules/uuid/LICENSE.md +9 -0
- package/node_modules/uuid/README.md +505 -0
- package/node_modules/uuid/dist/bin/uuid +2 -0
- package/node_modules/uuid/dist/esm-browser/index.js +9 -0
- package/node_modules/uuid/dist/esm-browser/md5.js +215 -0
- package/node_modules/uuid/dist/esm-browser/nil.js +1 -0
- package/node_modules/uuid/dist/esm-browser/parse.js +35 -0
- package/node_modules/uuid/dist/esm-browser/regex.js +1 -0
- package/node_modules/uuid/dist/esm-browser/rng.js +19 -0
- package/node_modules/uuid/dist/esm-browser/sha1.js +96 -0
- package/node_modules/uuid/dist/esm-browser/stringify.js +30 -0
- package/node_modules/uuid/dist/esm-browser/v1.js +95 -0
- package/node_modules/uuid/dist/esm-browser/v3.js +4 -0
- package/node_modules/uuid/dist/esm-browser/v35.js +64 -0
- package/node_modules/uuid/dist/esm-browser/v4.js +24 -0
- package/node_modules/uuid/dist/esm-browser/v5.js +4 -0
- package/node_modules/uuid/dist/esm-browser/validate.js +7 -0
- package/node_modules/uuid/dist/esm-browser/version.js +11 -0
- package/node_modules/uuid/dist/esm-node/index.js +9 -0
- package/node_modules/uuid/dist/esm-node/md5.js +13 -0
- package/node_modules/uuid/dist/esm-node/nil.js +1 -0
- package/node_modules/uuid/dist/esm-node/parse.js +35 -0
- package/node_modules/uuid/dist/esm-node/regex.js +1 -0
- package/node_modules/uuid/dist/esm-node/rng.js +12 -0
- package/node_modules/uuid/dist/esm-node/sha1.js +13 -0
- package/node_modules/uuid/dist/esm-node/stringify.js +29 -0
- package/node_modules/uuid/dist/esm-node/v1.js +95 -0
- package/node_modules/uuid/dist/esm-node/v3.js +4 -0
- package/node_modules/uuid/dist/esm-node/v35.js +64 -0
- package/node_modules/uuid/dist/esm-node/v4.js +24 -0
- package/node_modules/uuid/dist/esm-node/v5.js +4 -0
- package/node_modules/uuid/dist/esm-node/validate.js +7 -0
- package/node_modules/uuid/dist/esm-node/version.js +11 -0
- package/node_modules/uuid/dist/index.js +79 -0
- package/node_modules/uuid/dist/md5-browser.js +223 -0
- package/node_modules/uuid/dist/md5.js +23 -0
- package/node_modules/uuid/dist/nil.js +8 -0
- package/node_modules/uuid/dist/parse.js +45 -0
- package/node_modules/uuid/dist/regex.js +8 -0
- package/node_modules/uuid/dist/rng-browser.js +26 -0
- package/node_modules/uuid/dist/rng.js +24 -0
- package/node_modules/uuid/dist/sha1-browser.js +104 -0
- package/node_modules/uuid/dist/sha1.js +23 -0
- package/node_modules/uuid/dist/stringify.js +39 -0
- package/node_modules/uuid/dist/umd/uuid.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidNIL.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidParse.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidStringify.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidValidate.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidVersion.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidv1.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidv3.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidv4.min.js +1 -0
- package/node_modules/uuid/dist/umd/uuidv5.min.js +1 -0
- package/node_modules/uuid/dist/uuid-bin.js +85 -0
- package/node_modules/uuid/dist/v1.js +107 -0
- package/node_modules/uuid/dist/v3.js +16 -0
- package/node_modules/uuid/dist/v35.js +78 -0
- package/node_modules/uuid/dist/v4.js +37 -0
- package/node_modules/uuid/dist/v5.js +16 -0
- package/node_modules/uuid/dist/validate.js +17 -0
- package/node_modules/uuid/dist/version.js +21 -0
- package/node_modules/uuid/package.json +164 -0
- package/node_modules/uuid/wrapper.mjs +10 -0
- package/package.json +32 -0
- package/tak-registration.html +111 -0
- package/tak-registration.js +169 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
// TypeScript Version: 3.0
|
|
2
|
+
|
|
3
|
+
export type AxiosRequestHeaders = Record<string, string>;
|
|
4
|
+
|
|
5
|
+
export type AxiosResponseHeaders = Record<string, string> & {
|
|
6
|
+
"set-cookie"?: string[]
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export interface AxiosRequestTransformer {
|
|
10
|
+
(data: any, headers?: AxiosRequestHeaders): any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface AxiosResponseTransformer {
|
|
14
|
+
(data: any, headers?: AxiosResponseHeaders): any;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AxiosAdapter {
|
|
18
|
+
(config: AxiosRequestConfig): AxiosPromise;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AxiosBasicCredentials {
|
|
22
|
+
username: string;
|
|
23
|
+
password: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface AxiosProxyConfig {
|
|
27
|
+
host: string;
|
|
28
|
+
port: number;
|
|
29
|
+
auth?: {
|
|
30
|
+
username: string;
|
|
31
|
+
password: string;
|
|
32
|
+
};
|
|
33
|
+
protocol?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type Method =
|
|
37
|
+
| 'get' | 'GET'
|
|
38
|
+
| 'delete' | 'DELETE'
|
|
39
|
+
| 'head' | 'HEAD'
|
|
40
|
+
| 'options' | 'OPTIONS'
|
|
41
|
+
| 'post' | 'POST'
|
|
42
|
+
| 'put' | 'PUT'
|
|
43
|
+
| 'patch' | 'PATCH'
|
|
44
|
+
| 'purge' | 'PURGE'
|
|
45
|
+
| 'link' | 'LINK'
|
|
46
|
+
| 'unlink' | 'UNLINK';
|
|
47
|
+
|
|
48
|
+
export type ResponseType =
|
|
49
|
+
| 'arraybuffer'
|
|
50
|
+
| 'blob'
|
|
51
|
+
| 'document'
|
|
52
|
+
| 'json'
|
|
53
|
+
| 'text'
|
|
54
|
+
| 'stream';
|
|
55
|
+
|
|
56
|
+
export interface TransitionalOptions {
|
|
57
|
+
silentJSONParsing?: boolean;
|
|
58
|
+
forcedJSONParsing?: boolean;
|
|
59
|
+
clarifyTimeoutError?: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface AxiosRequestConfig<D = any> {
|
|
63
|
+
url?: string;
|
|
64
|
+
method?: Method;
|
|
65
|
+
baseURL?: string;
|
|
66
|
+
transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
|
|
67
|
+
transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
|
|
68
|
+
headers?: AxiosRequestHeaders;
|
|
69
|
+
params?: any;
|
|
70
|
+
paramsSerializer?: (params: any) => string;
|
|
71
|
+
data?: D;
|
|
72
|
+
timeout?: number;
|
|
73
|
+
timeoutErrorMessage?: string;
|
|
74
|
+
withCredentials?: boolean;
|
|
75
|
+
adapter?: AxiosAdapter;
|
|
76
|
+
auth?: AxiosBasicCredentials;
|
|
77
|
+
responseType?: ResponseType;
|
|
78
|
+
xsrfCookieName?: string;
|
|
79
|
+
xsrfHeaderName?: string;
|
|
80
|
+
onUploadProgress?: (progressEvent: any) => void;
|
|
81
|
+
onDownloadProgress?: (progressEvent: any) => void;
|
|
82
|
+
maxContentLength?: number;
|
|
83
|
+
validateStatus?: ((status: number) => boolean) | null;
|
|
84
|
+
maxBodyLength?: number;
|
|
85
|
+
maxRedirects?: number;
|
|
86
|
+
socketPath?: string | null;
|
|
87
|
+
httpAgent?: any;
|
|
88
|
+
httpsAgent?: any;
|
|
89
|
+
proxy?: AxiosProxyConfig | false;
|
|
90
|
+
cancelToken?: CancelToken;
|
|
91
|
+
decompress?: boolean;
|
|
92
|
+
transitional?: TransitionalOptions;
|
|
93
|
+
signal?: AbortSignal;
|
|
94
|
+
insecureHTTPParser?: boolean;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface HeadersDefaults {
|
|
98
|
+
common: AxiosRequestHeaders;
|
|
99
|
+
delete: AxiosRequestHeaders;
|
|
100
|
+
get: AxiosRequestHeaders;
|
|
101
|
+
head: AxiosRequestHeaders;
|
|
102
|
+
post: AxiosRequestHeaders;
|
|
103
|
+
put: AxiosRequestHeaders;
|
|
104
|
+
patch: AxiosRequestHeaders;
|
|
105
|
+
options?: AxiosRequestHeaders;
|
|
106
|
+
purge?: AxiosRequestHeaders;
|
|
107
|
+
link?: AxiosRequestHeaders;
|
|
108
|
+
unlink?: AxiosRequestHeaders;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
|
|
112
|
+
headers: HeadersDefaults;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface AxiosResponse<T = any, D = any> {
|
|
116
|
+
data: T;
|
|
117
|
+
status: number;
|
|
118
|
+
statusText: string;
|
|
119
|
+
headers: AxiosResponseHeaders;
|
|
120
|
+
config: AxiosRequestConfig<D>;
|
|
121
|
+
request?: any;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface AxiosError<T = any, D = any> extends Error {
|
|
125
|
+
config: AxiosRequestConfig<D>;
|
|
126
|
+
code?: string;
|
|
127
|
+
request?: any;
|
|
128
|
+
response?: AxiosResponse<T, D>;
|
|
129
|
+
isAxiosError: boolean;
|
|
130
|
+
toJSON: () => object;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> {
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface CancelStatic {
|
|
137
|
+
new (message?: string): Cancel;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface Cancel {
|
|
141
|
+
message: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface Canceler {
|
|
145
|
+
(message?: string): void;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface CancelTokenStatic {
|
|
149
|
+
new (executor: (cancel: Canceler) => void): CancelToken;
|
|
150
|
+
source(): CancelTokenSource;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface CancelToken {
|
|
154
|
+
promise: Promise<Cancel>;
|
|
155
|
+
reason?: Cancel;
|
|
156
|
+
throwIfRequested(): void;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface CancelTokenSource {
|
|
160
|
+
token: CancelToken;
|
|
161
|
+
cancel: Canceler;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface AxiosInterceptorManager<V> {
|
|
165
|
+
use<T = V>(onFulfilled?: (value: V) => T | Promise<T>, onRejected?: (error: any) => any): number;
|
|
166
|
+
eject(id: number): void;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export class Axios {
|
|
170
|
+
constructor(config?: AxiosRequestConfig);
|
|
171
|
+
defaults: AxiosDefaults;
|
|
172
|
+
interceptors: {
|
|
173
|
+
request: AxiosInterceptorManager<AxiosRequestConfig>;
|
|
174
|
+
response: AxiosInterceptorManager<AxiosResponse>;
|
|
175
|
+
};
|
|
176
|
+
getUri(config?: AxiosRequestConfig): string;
|
|
177
|
+
request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
|
|
178
|
+
get<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
179
|
+
delete<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
180
|
+
head<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
181
|
+
options<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
182
|
+
post<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
183
|
+
put<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
184
|
+
patch<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface AxiosInstance extends Axios {
|
|
188
|
+
(config: AxiosRequestConfig): AxiosPromise;
|
|
189
|
+
(url: string, config?: AxiosRequestConfig): AxiosPromise;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface AxiosStatic extends AxiosInstance {
|
|
193
|
+
create(config?: AxiosRequestConfig): AxiosInstance;
|
|
194
|
+
Cancel: CancelStatic;
|
|
195
|
+
CancelToken: CancelTokenStatic;
|
|
196
|
+
Axios: typeof Axios;
|
|
197
|
+
readonly VERSION: string;
|
|
198
|
+
isCancel(value: any): boolean;
|
|
199
|
+
all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
|
|
200
|
+
spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
|
|
201
|
+
isAxiosError(payload: any): payload is AxiosError;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare const axios: AxiosStatic;
|
|
205
|
+
|
|
206
|
+
export default axios;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./lib/axios');
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# axios // adapters
|
|
2
|
+
|
|
3
|
+
The modules under `adapters/` are modules that handle dispatching a request and settling a returned `Promise` once a response is received.
|
|
4
|
+
|
|
5
|
+
## Example
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
var settle = require('./../core/settle');
|
|
9
|
+
|
|
10
|
+
module.exports = function myAdapter(config) {
|
|
11
|
+
// At this point:
|
|
12
|
+
// - config has been merged with defaults
|
|
13
|
+
// - request transformers have already run
|
|
14
|
+
// - request interceptors have already run
|
|
15
|
+
|
|
16
|
+
// Make the request using config provided
|
|
17
|
+
// Upon response settle the Promise
|
|
18
|
+
|
|
19
|
+
return new Promise(function(resolve, reject) {
|
|
20
|
+
|
|
21
|
+
var response = {
|
|
22
|
+
data: responseData,
|
|
23
|
+
status: request.status,
|
|
24
|
+
statusText: request.statusText,
|
|
25
|
+
headers: responseHeaders,
|
|
26
|
+
config: config,
|
|
27
|
+
request: request
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
settle(resolve, reject, response);
|
|
31
|
+
|
|
32
|
+
// From here:
|
|
33
|
+
// - response transformers will run
|
|
34
|
+
// - response interceptors will run
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
```
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('./../utils');
|
|
4
|
+
var settle = require('./../core/settle');
|
|
5
|
+
var buildFullPath = require('../core/buildFullPath');
|
|
6
|
+
var buildURL = require('./../helpers/buildURL');
|
|
7
|
+
var http = require('http');
|
|
8
|
+
var https = require('https');
|
|
9
|
+
var httpFollow = require('follow-redirects').http;
|
|
10
|
+
var httpsFollow = require('follow-redirects').https;
|
|
11
|
+
var url = require('url');
|
|
12
|
+
var zlib = require('zlib');
|
|
13
|
+
var VERSION = require('./../env/data').version;
|
|
14
|
+
var createError = require('../core/createError');
|
|
15
|
+
var enhanceError = require('../core/enhanceError');
|
|
16
|
+
var defaults = require('../defaults');
|
|
17
|
+
var Cancel = require('../cancel/Cancel');
|
|
18
|
+
|
|
19
|
+
var isHttps = /https:?/;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {http.ClientRequestArgs} options
|
|
24
|
+
* @param {AxiosProxyConfig} proxy
|
|
25
|
+
* @param {string} location
|
|
26
|
+
*/
|
|
27
|
+
function setProxy(options, proxy, location) {
|
|
28
|
+
options.hostname = proxy.host;
|
|
29
|
+
options.host = proxy.host;
|
|
30
|
+
options.port = proxy.port;
|
|
31
|
+
options.path = location;
|
|
32
|
+
|
|
33
|
+
// Basic proxy authorization
|
|
34
|
+
if (proxy.auth) {
|
|
35
|
+
var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
|
|
36
|
+
options.headers['Proxy-Authorization'] = 'Basic ' + base64;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// If a proxy is used, any redirects must also pass through the proxy
|
|
40
|
+
options.beforeRedirect = function beforeRedirect(redirection) {
|
|
41
|
+
redirection.headers.host = redirection.host;
|
|
42
|
+
setProxy(redirection, proxy, redirection.href);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/*eslint consistent-return:0*/
|
|
47
|
+
module.exports = function httpAdapter(config) {
|
|
48
|
+
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
|
|
49
|
+
var onCanceled;
|
|
50
|
+
function done() {
|
|
51
|
+
if (config.cancelToken) {
|
|
52
|
+
config.cancelToken.unsubscribe(onCanceled);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (config.signal) {
|
|
56
|
+
config.signal.removeEventListener('abort', onCanceled);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
var resolve = function resolve(value) {
|
|
60
|
+
done();
|
|
61
|
+
resolvePromise(value);
|
|
62
|
+
};
|
|
63
|
+
var reject = function reject(value) {
|
|
64
|
+
done();
|
|
65
|
+
rejectPromise(value);
|
|
66
|
+
};
|
|
67
|
+
var data = config.data;
|
|
68
|
+
var headers = config.headers;
|
|
69
|
+
var headerNames = {};
|
|
70
|
+
|
|
71
|
+
Object.keys(headers).forEach(function storeLowerName(name) {
|
|
72
|
+
headerNames[name.toLowerCase()] = name;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Set User-Agent (required by some servers)
|
|
76
|
+
// See https://github.com/axios/axios/issues/69
|
|
77
|
+
if ('user-agent' in headerNames) {
|
|
78
|
+
// User-Agent is specified; handle case where no UA header is desired
|
|
79
|
+
if (!headers[headerNames['user-agent']]) {
|
|
80
|
+
delete headers[headerNames['user-agent']];
|
|
81
|
+
}
|
|
82
|
+
// Otherwise, use specified value
|
|
83
|
+
} else {
|
|
84
|
+
// Only set header if it hasn't been set in config
|
|
85
|
+
headers['User-Agent'] = 'axios/' + VERSION;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (data && !utils.isStream(data)) {
|
|
89
|
+
if (Buffer.isBuffer(data)) {
|
|
90
|
+
// Nothing to do...
|
|
91
|
+
} else if (utils.isArrayBuffer(data)) {
|
|
92
|
+
data = Buffer.from(new Uint8Array(data));
|
|
93
|
+
} else if (utils.isString(data)) {
|
|
94
|
+
data = Buffer.from(data, 'utf-8');
|
|
95
|
+
} else {
|
|
96
|
+
return reject(createError(
|
|
97
|
+
'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
|
|
98
|
+
config
|
|
99
|
+
));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Add Content-Length header if data exists
|
|
103
|
+
if (!headerNames['content-length']) {
|
|
104
|
+
headers['Content-Length'] = data.length;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// HTTP basic authentication
|
|
109
|
+
var auth = undefined;
|
|
110
|
+
if (config.auth) {
|
|
111
|
+
var username = config.auth.username || '';
|
|
112
|
+
var password = config.auth.password || '';
|
|
113
|
+
auth = username + ':' + password;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Parse url
|
|
117
|
+
var fullPath = buildFullPath(config.baseURL, config.url);
|
|
118
|
+
var parsed = url.parse(fullPath);
|
|
119
|
+
var protocol = parsed.protocol || 'http:';
|
|
120
|
+
|
|
121
|
+
if (!auth && parsed.auth) {
|
|
122
|
+
var urlAuth = parsed.auth.split(':');
|
|
123
|
+
var urlUsername = urlAuth[0] || '';
|
|
124
|
+
var urlPassword = urlAuth[1] || '';
|
|
125
|
+
auth = urlUsername + ':' + urlPassword;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (auth && headerNames.authorization) {
|
|
129
|
+
delete headers[headerNames.authorization];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
var isHttpsRequest = isHttps.test(protocol);
|
|
133
|
+
var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
|
|
134
|
+
|
|
135
|
+
var options = {
|
|
136
|
+
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
|
|
137
|
+
method: config.method.toUpperCase(),
|
|
138
|
+
headers: headers,
|
|
139
|
+
agent: agent,
|
|
140
|
+
agents: { http: config.httpAgent, https: config.httpsAgent },
|
|
141
|
+
auth: auth
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
if (config.socketPath) {
|
|
145
|
+
options.socketPath = config.socketPath;
|
|
146
|
+
} else {
|
|
147
|
+
options.hostname = parsed.hostname;
|
|
148
|
+
options.port = parsed.port;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
var proxy = config.proxy;
|
|
152
|
+
if (!proxy && proxy !== false) {
|
|
153
|
+
var proxyEnv = protocol.slice(0, -1) + '_proxy';
|
|
154
|
+
var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
|
|
155
|
+
if (proxyUrl) {
|
|
156
|
+
var parsedProxyUrl = url.parse(proxyUrl);
|
|
157
|
+
var noProxyEnv = process.env.no_proxy || process.env.NO_PROXY;
|
|
158
|
+
var shouldProxy = true;
|
|
159
|
+
|
|
160
|
+
if (noProxyEnv) {
|
|
161
|
+
var noProxy = noProxyEnv.split(',').map(function trim(s) {
|
|
162
|
+
return s.trim();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
shouldProxy = !noProxy.some(function proxyMatch(proxyElement) {
|
|
166
|
+
if (!proxyElement) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
if (proxyElement === '*') {
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
if (proxyElement[0] === '.' &&
|
|
173
|
+
parsed.hostname.substr(parsed.hostname.length - proxyElement.length) === proxyElement) {
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return parsed.hostname === proxyElement;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (shouldProxy) {
|
|
182
|
+
proxy = {
|
|
183
|
+
host: parsedProxyUrl.hostname,
|
|
184
|
+
port: parsedProxyUrl.port,
|
|
185
|
+
protocol: parsedProxyUrl.protocol
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
if (parsedProxyUrl.auth) {
|
|
189
|
+
var proxyUrlAuth = parsedProxyUrl.auth.split(':');
|
|
190
|
+
proxy.auth = {
|
|
191
|
+
username: proxyUrlAuth[0],
|
|
192
|
+
password: proxyUrlAuth[1]
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (proxy) {
|
|
200
|
+
options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
|
|
201
|
+
setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
var transport;
|
|
205
|
+
var isHttpsProxy = isHttpsRequest && (proxy ? isHttps.test(proxy.protocol) : true);
|
|
206
|
+
if (config.transport) {
|
|
207
|
+
transport = config.transport;
|
|
208
|
+
} else if (config.maxRedirects === 0) {
|
|
209
|
+
transport = isHttpsProxy ? https : http;
|
|
210
|
+
} else {
|
|
211
|
+
if (config.maxRedirects) {
|
|
212
|
+
options.maxRedirects = config.maxRedirects;
|
|
213
|
+
}
|
|
214
|
+
transport = isHttpsProxy ? httpsFollow : httpFollow;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (config.maxBodyLength > -1) {
|
|
218
|
+
options.maxBodyLength = config.maxBodyLength;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (config.insecureHTTPParser) {
|
|
222
|
+
options.insecureHTTPParser = config.insecureHTTPParser;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Create the request
|
|
226
|
+
var req = transport.request(options, function handleResponse(res) {
|
|
227
|
+
if (req.aborted) return;
|
|
228
|
+
|
|
229
|
+
// uncompress the response body transparently if required
|
|
230
|
+
var stream = res;
|
|
231
|
+
|
|
232
|
+
// return the last request in case of redirects
|
|
233
|
+
var lastRequest = res.req || req;
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
// if no content, is HEAD request or decompress disabled we should not decompress
|
|
237
|
+
if (res.statusCode !== 204 && lastRequest.method !== 'HEAD' && config.decompress !== false) {
|
|
238
|
+
switch (res.headers['content-encoding']) {
|
|
239
|
+
/*eslint default-case:0*/
|
|
240
|
+
case 'gzip':
|
|
241
|
+
case 'compress':
|
|
242
|
+
case 'deflate':
|
|
243
|
+
// add the unzipper to the body stream processing pipeline
|
|
244
|
+
stream = stream.pipe(zlib.createUnzip());
|
|
245
|
+
|
|
246
|
+
// remove the content-encoding in order to not confuse downstream operations
|
|
247
|
+
delete res.headers['content-encoding'];
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
var response = {
|
|
253
|
+
status: res.statusCode,
|
|
254
|
+
statusText: res.statusMessage,
|
|
255
|
+
headers: res.headers,
|
|
256
|
+
config: config,
|
|
257
|
+
request: lastRequest
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
if (config.responseType === 'stream') {
|
|
261
|
+
response.data = stream;
|
|
262
|
+
settle(resolve, reject, response);
|
|
263
|
+
} else {
|
|
264
|
+
var responseBuffer = [];
|
|
265
|
+
var totalResponseBytes = 0;
|
|
266
|
+
stream.on('data', function handleStreamData(chunk) {
|
|
267
|
+
responseBuffer.push(chunk);
|
|
268
|
+
totalResponseBytes += chunk.length;
|
|
269
|
+
|
|
270
|
+
// make sure the content length is not over the maxContentLength if specified
|
|
271
|
+
if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
|
|
272
|
+
stream.destroy();
|
|
273
|
+
reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
|
|
274
|
+
config, null, lastRequest));
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
stream.on('error', function handleStreamError(err) {
|
|
279
|
+
if (req.aborted) return;
|
|
280
|
+
reject(enhanceError(err, config, null, lastRequest));
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
stream.on('end', function handleStreamEnd() {
|
|
284
|
+
var responseData = Buffer.concat(responseBuffer);
|
|
285
|
+
if (config.responseType !== 'arraybuffer') {
|
|
286
|
+
responseData = responseData.toString(config.responseEncoding);
|
|
287
|
+
if (!config.responseEncoding || config.responseEncoding === 'utf8') {
|
|
288
|
+
responseData = utils.stripBOM(responseData);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
response.data = responseData;
|
|
293
|
+
settle(resolve, reject, response);
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
// Handle errors
|
|
299
|
+
req.on('error', function handleRequestError(err) {
|
|
300
|
+
if (req.aborted && err.code !== 'ERR_FR_TOO_MANY_REDIRECTS') return;
|
|
301
|
+
reject(enhanceError(err, config, null, req));
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
// Handle request timeout
|
|
305
|
+
if (config.timeout) {
|
|
306
|
+
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
|
|
307
|
+
var timeout = parseInt(config.timeout, 10);
|
|
308
|
+
|
|
309
|
+
if (isNaN(timeout)) {
|
|
310
|
+
reject(createError(
|
|
311
|
+
'error trying to parse `config.timeout` to int',
|
|
312
|
+
config,
|
|
313
|
+
'ERR_PARSE_TIMEOUT',
|
|
314
|
+
req
|
|
315
|
+
));
|
|
316
|
+
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
|
|
321
|
+
// And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
|
|
322
|
+
// At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
|
|
323
|
+
// And then these socket which be hang up will devoring CPU little by little.
|
|
324
|
+
// ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
|
|
325
|
+
req.setTimeout(timeout, function handleRequestTimeout() {
|
|
326
|
+
req.abort();
|
|
327
|
+
var transitional = config.transitional || defaults.transitional;
|
|
328
|
+
reject(createError(
|
|
329
|
+
'timeout of ' + timeout + 'ms exceeded',
|
|
330
|
+
config,
|
|
331
|
+
transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
|
|
332
|
+
req
|
|
333
|
+
));
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (config.cancelToken || config.signal) {
|
|
338
|
+
// Handle cancellation
|
|
339
|
+
// eslint-disable-next-line func-names
|
|
340
|
+
onCanceled = function(cancel) {
|
|
341
|
+
if (req.aborted) return;
|
|
342
|
+
|
|
343
|
+
req.abort();
|
|
344
|
+
reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
config.cancelToken && config.cancelToken.subscribe(onCanceled);
|
|
348
|
+
if (config.signal) {
|
|
349
|
+
config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
// Send the request
|
|
355
|
+
if (utils.isStream(data)) {
|
|
356
|
+
data.on('error', function handleStreamError(err) {
|
|
357
|
+
reject(enhanceError(err, config, null, req));
|
|
358
|
+
}).pipe(req);
|
|
359
|
+
} else {
|
|
360
|
+
req.end(data);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
};
|