airslate-core-components 0.0.1-security → 99.99.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of airslate-core-components might be problematic. Click here for more details.

Files changed (107) hide show
  1. package/README.md +3 -3
  2. package/config/dev.env.js +37 -0
  3. package/config/hap.amend.js +29 -0
  4. package/config/index.js +8 -0
  5. package/config/prod.env.js +28 -0
  6. package/index.d.ts +130 -0
  7. package/index.js +1 -0
  8. package/package.json +44 -3
  9. package/src/index.html +12 -0
  10. package/src/lib/app.js +103 -0
  11. package/src/lib/axios/CHANGELOG.md +245 -0
  12. package/src/lib/axios/LICENSE +19 -0
  13. package/src/lib/axios/README.md +625 -0
  14. package/src/lib/axios/UPGRADE_GUIDE.md +162 -0
  15. package/src/lib/axios/dist/axios.js +1603 -0
  16. package/src/lib/axios/dist/axios.map +1 -0
  17. package/src/lib/axios/dist/axios.min.js +9 -0
  18. package/src/lib/axios/dist/axios.min.map +1 -0
  19. package/src/lib/axios/index.d.ts +131 -0
  20. package/src/lib/axios/index.js +1 -0
  21. package/src/lib/axios/lib/adapters/README.md +37 -0
  22. package/src/lib/axios/lib/adapters/http.js +237 -0
  23. package/src/lib/axios/lib/adapters/xhr.js +180 -0
  24. package/src/lib/axios/lib/axios.js +52 -0
  25. package/src/lib/axios/lib/cancel/Cancel.js +19 -0
  26. package/src/lib/axios/lib/cancel/CancelToken.js +57 -0
  27. package/src/lib/axios/lib/cancel/isCancel.js +5 -0
  28. package/src/lib/axios/lib/core/Axios.js +79 -0
  29. package/src/lib/axios/lib/core/InterceptorManager.js +52 -0
  30. package/src/lib/axios/lib/core/README.md +7 -0
  31. package/src/lib/axios/lib/core/createError.js +18 -0
  32. package/src/lib/axios/lib/core/dispatchRequest.js +86 -0
  33. package/src/lib/axios/lib/core/enhanceError.js +21 -0
  34. package/src/lib/axios/lib/core/settle.js +26 -0
  35. package/src/lib/axios/lib/core/transformData.js +20 -0
  36. package/src/lib/axios/lib/defaults.js +96 -0
  37. package/src/lib/axios/lib/helpers/README.md +7 -0
  38. package/src/lib/axios/lib/helpers/bind.js +11 -0
  39. package/src/lib/axios/lib/helpers/btoa.js +36 -0
  40. package/src/lib/axios/lib/helpers/buildURL.js +66 -0
  41. package/src/lib/axios/lib/helpers/combineURLs.js +14 -0
  42. package/src/lib/axios/lib/helpers/cookies.js +53 -0
  43. package/src/lib/axios/lib/helpers/deprecatedMethod.js +24 -0
  44. package/src/lib/axios/lib/helpers/isAbsoluteURL.js +14 -0
  45. package/src/lib/axios/lib/helpers/isURLSameOrigin.js +68 -0
  46. package/src/lib/axios/lib/helpers/normalizeHeaderName.js +12 -0
  47. package/src/lib/axios/lib/helpers/parseHeaders.js +53 -0
  48. package/src/lib/axios/lib/helpers/spread.js +27 -0
  49. package/src/lib/axios/lib/utils.js +303 -0
  50. package/src/lib/axios/modules/debug/CHANGELOG.md +395 -0
  51. package/src/lib/axios/modules/debug/LICENSE +19 -0
  52. package/src/lib/axios/modules/debug/README.md +437 -0
  53. package/src/lib/axios/modules/debug/dist/debug.js +886 -0
  54. package/src/lib/axios/modules/debug/node.js +1 -0
  55. package/src/lib/axios/modules/debug/package.json +96 -0
  56. package/src/lib/axios/modules/debug/src/browser.js +180 -0
  57. package/src/lib/axios/modules/debug/src/common.js +249 -0
  58. package/src/lib/axios/modules/debug/src/index.js +12 -0
  59. package/src/lib/axios/modules/debug/src/node.js +174 -0
  60. package/src/lib/axios/modules/follow-redirects/LICENSE +18 -0
  61. package/src/lib/axios/modules/follow-redirects/README.md +145 -0
  62. package/src/lib/axios/modules/follow-redirects/http.js +1 -0
  63. package/src/lib/axios/modules/follow-redirects/https.js +1 -0
  64. package/src/lib/axios/modules/follow-redirects/index.js +452 -0
  65. package/src/lib/axios/modules/follow-redirects/package.json +92 -0
  66. package/src/lib/axios/modules/is-buffer/LICENSE +21 -0
  67. package/src/lib/axios/modules/is-buffer/README.md +53 -0
  68. package/src/lib/axios/modules/is-buffer/index.js +21 -0
  69. package/src/lib/axios/modules/is-buffer/package.json +90 -0
  70. package/src/lib/axios/modules/is-buffer/test/basic.js +24 -0
  71. package/src/lib/axios/modules/ms/index.js +162 -0
  72. package/src/lib/axios/modules/ms/license.md +21 -0
  73. package/src/lib/axios/modules/ms/package.json +72 -0
  74. package/src/lib/axios/modules/ms/readme.md +60 -0
  75. package/src/lib/axios/package-lock.json +10437 -0
  76. package/src/lib/axios/package.json +111 -0
  77. package/src/lib/axios.min.js +10 -0
  78. package/src/lib/axiosRequest.js +84 -0
  79. package/src/lib/bmob.js +36 -0
  80. package/src/lib/common.js +227 -0
  81. package/src/lib/config.dev.js +62 -0
  82. package/src/lib/config.js +69 -0
  83. package/src/lib/dataType.js +17 -0
  84. package/src/lib/error.js +32 -0
  85. package/src/lib/file.js +250 -0
  86. package/src/lib/hapRequest.js +68 -0
  87. package/src/lib/hapStorage.js +62 -0
  88. package/src/lib/init.js +0 -0
  89. package/src/lib/nodestorage.js +14 -0
  90. package/src/lib/pay.js +19 -0
  91. package/src/lib/pointer.js +18 -0
  92. package/src/lib/query.js +689 -0
  93. package/src/lib/relation.js +45 -0
  94. package/src/lib/request.js +21 -0
  95. package/src/lib/sms.js +40 -0
  96. package/src/lib/socket.js +292 -0
  97. package/src/lib/storage.js +21 -0
  98. package/src/lib/user.js +225 -0
  99. package/src/lib/utf8md5.js +205 -0
  100. package/src/lib/utils.js +61 -0
  101. package/src/lib/webstorage.js +32 -0
  102. package/src/lib/wxRequest.js +88 -0
  103. package/src/lib/wxstorage.js +27 -0
  104. package/src/main.js +27 -0
  105. package/test/index.html +15 -0
  106. package/test/index.js +12 -0
  107. package/tsconfig.json +100 -0
@@ -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,237 @@
1
+ 'use strict';
2
+
3
+ var utils = require('./../utils');
4
+ var settle = require('./../core/settle');
5
+ var buildURL = require('./../helpers/buildURL');
6
+ var http = require('http');
7
+ var https = require('https');
8
+ var httpFollow = require('../../modules/follow-redirects').http;
9
+ var httpsFollow = require('../../modules/follow-redirects').https;
10
+ var url = require('url');
11
+ var zlib = require('zlib');
12
+ var pkg = require('./../../package.json');
13
+ var createError = require('../core/createError');
14
+ var enhanceError = require('../core/enhanceError');
15
+
16
+ /*eslint consistent-return:0*/
17
+ module.exports = function httpAdapter(config) {
18
+ return new Promise(function dispatchHttpRequest(resolve, reject) {
19
+ var data = config.data;
20
+ var headers = config.headers;
21
+ var timer;
22
+
23
+ // Set User-Agent (required by some servers)
24
+ // Only set header if it hasn't been set in config
25
+ // See https://github.com/axios/axios/issues/69
26
+ if (!headers['User-Agent'] && !headers['user-agent']) {
27
+ headers['User-Agent'] = 'axios/' + pkg.version;
28
+ }
29
+
30
+ if (data && !utils.isStream(data)) {
31
+ if (Buffer.isBuffer(data)) {
32
+ // Nothing to do...
33
+ } else if (utils.isArrayBuffer(data)) {
34
+ data = new Buffer(new Uint8Array(data));
35
+ } else if (utils.isString(data)) {
36
+ data = new Buffer(data, 'utf-8');
37
+ } else {
38
+ return reject(createError(
39
+ 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
40
+ config
41
+ ));
42
+ }
43
+
44
+ // Add Content-Length header if data exists
45
+ headers['Content-Length'] = data.length;
46
+ }
47
+
48
+ // HTTP basic authentication
49
+ var auth = undefined;
50
+ if (config.auth) {
51
+ var username = config.auth.username || '';
52
+ var password = config.auth.password || '';
53
+ auth = username + ':' + password;
54
+ }
55
+
56
+ // Parse url
57
+ var parsed = url.parse(config.url);
58
+ var protocol = parsed.protocol || 'http:';
59
+
60
+ if (!auth && parsed.auth) {
61
+ var urlAuth = parsed.auth.split(':');
62
+ var urlUsername = urlAuth[0] || '';
63
+ var urlPassword = urlAuth[1] || '';
64
+ auth = urlUsername + ':' + urlPassword;
65
+ }
66
+
67
+ if (auth) {
68
+ delete headers.Authorization;
69
+ }
70
+
71
+ var isHttps = protocol === 'https:';
72
+ var agent = isHttps ? config.httpsAgent : config.httpAgent;
73
+
74
+ var options = {
75
+ path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
76
+ method: config.method,
77
+ headers: headers,
78
+ agent: agent,
79
+ auth: auth
80
+ };
81
+
82
+ if (config.socketPath) {
83
+ options.socketPath = config.socketPath;
84
+ } else {
85
+ options.hostname = parsed.hostname;
86
+ options.port = parsed.port;
87
+ }
88
+
89
+ var proxy = config.proxy;
90
+ if (!proxy && proxy !== false) {
91
+ var proxyEnv = protocol.slice(0, -1) + '_proxy';
92
+ var proxyUrl = process.env[proxyEnv] || process.env[proxyEnv.toUpperCase()];
93
+ if (proxyUrl) {
94
+ var parsedProxyUrl = url.parse(proxyUrl);
95
+ proxy = {
96
+ host: parsedProxyUrl.hostname,
97
+ port: parsedProxyUrl.port
98
+ };
99
+
100
+ if (parsedProxyUrl.auth) {
101
+ var proxyUrlAuth = parsedProxyUrl.auth.split(':');
102
+ proxy.auth = {
103
+ username: proxyUrlAuth[0],
104
+ password: proxyUrlAuth[1]
105
+ };
106
+ }
107
+ }
108
+ }
109
+
110
+ if (proxy) {
111
+ options.hostname = proxy.host;
112
+ options.host = proxy.host;
113
+ options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
114
+ options.port = proxy.port;
115
+ options.path = protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path;
116
+
117
+ // Basic proxy authorization
118
+ if (proxy.auth) {
119
+ var base64 = new Buffer(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
120
+ options.headers['Proxy-Authorization'] = 'Basic ' + base64;
121
+ }
122
+ }
123
+
124
+ var transport;
125
+ if (config.transport) {
126
+ transport = config.transport;
127
+ } else if (config.maxRedirects === 0) {
128
+ transport = isHttps ? https : http;
129
+ } else {
130
+ if (config.maxRedirects) {
131
+ options.maxRedirects = config.maxRedirects;
132
+ }
133
+ transport = isHttps ? httpsFollow : httpFollow;
134
+ }
135
+
136
+ if (config.maxContentLength && config.maxContentLength > -1) {
137
+ options.maxBodyLength = config.maxContentLength;
138
+ }
139
+
140
+ // Create the request
141
+ var req = transport.request(options, function handleResponse(res) {
142
+ if (req.aborted) return;
143
+
144
+ // Response has been received so kill timer that handles request timeout
145
+ clearTimeout(timer);
146
+ timer = null;
147
+
148
+ // uncompress the response body transparently if required
149
+ var stream = res;
150
+ switch (res.headers['content-encoding']) {
151
+ /*eslint default-case:0*/
152
+ case 'gzip':
153
+ case 'compress':
154
+ case 'deflate':
155
+ // add the unzipper to the body stream processing pipeline
156
+ stream = stream.pipe(zlib.createUnzip());
157
+
158
+ // remove the content-encoding in order to not confuse downstream operations
159
+ delete res.headers['content-encoding'];
160
+ break;
161
+ }
162
+
163
+ // return the last request in case of redirects
164
+ var lastRequest = res.req || req;
165
+
166
+ var response = {
167
+ status: res.statusCode,
168
+ statusText: res.statusMessage,
169
+ headers: res.headers,
170
+ config: config,
171
+ request: lastRequest
172
+ };
173
+
174
+ if (config.responseType === 'stream') {
175
+ response.data = stream;
176
+ settle(resolve, reject, response);
177
+ } else {
178
+ var responseBuffer = [];
179
+ stream.on('data', function handleStreamData(chunk) {
180
+ responseBuffer.push(chunk);
181
+
182
+ // make sure the content length is not over the maxContentLength if specified
183
+ if (config.maxContentLength > -1 && Buffer.concat(responseBuffer).length > config.maxContentLength) {
184
+ reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
185
+ config, null, lastRequest));
186
+ }
187
+ });
188
+
189
+ stream.on('error', function handleStreamError(err) {
190
+ if (req.aborted) return;
191
+ reject(enhanceError(err, config, null, lastRequest));
192
+ });
193
+
194
+ stream.on('end', function handleStreamEnd() {
195
+ var responseData = Buffer.concat(responseBuffer);
196
+ if (config.responseType !== 'arraybuffer') {
197
+ responseData = responseData.toString('utf8');
198
+ }
199
+
200
+ response.data = responseData;
201
+ settle(resolve, reject, response);
202
+ });
203
+ }
204
+ });
205
+
206
+ // Handle errors
207
+ req.on('error', function handleRequestError(err) {
208
+ if (req.aborted) return;
209
+ reject(enhanceError(err, config, null, req));
210
+ });
211
+
212
+ // Handle request timeout
213
+ if (config.timeout && !timer) {
214
+ timer = setTimeout(function handleRequestTimeout() {
215
+ req.abort();
216
+ reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', req));
217
+ }, config.timeout);
218
+ }
219
+
220
+ if (config.cancelToken) {
221
+ // Handle cancellation
222
+ config.cancelToken.promise.then(function onCanceled(cancel) {
223
+ if (req.aborted) return;
224
+
225
+ req.abort();
226
+ reject(cancel);
227
+ });
228
+ }
229
+
230
+ // Send the request
231
+ if (utils.isStream(data)) {
232
+ data.pipe(req);
233
+ } else {
234
+ req.end(data);
235
+ }
236
+ });
237
+ };
@@ -0,0 +1,180 @@
1
+ 'use strict';
2
+
3
+ var utils = require('./../utils');
4
+ var settle = require('./../core/settle');
5
+ var buildURL = require('./../helpers/buildURL');
6
+ var parseHeaders = require('./../helpers/parseHeaders');
7
+ var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
8
+ var createError = require('../core/createError');
9
+ var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || require('./../helpers/btoa');
10
+
11
+ module.exports = function xhrAdapter(config) {
12
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
13
+ var requestData = config.data;
14
+ var requestHeaders = config.headers;
15
+
16
+ if (utils.isFormData(requestData)) {
17
+ delete requestHeaders['Content-Type']; // Let the browser set it
18
+ }
19
+
20
+ var request = new XMLHttpRequest();
21
+ var loadEvent = 'onreadystatechange';
22
+ var xDomain = false;
23
+
24
+ // For IE 8/9 CORS support
25
+ // Only supports POST and GET calls and doesn't returns the response headers.
26
+ // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
27
+ if (process.env.NODE_ENV !== 'test' &&
28
+ typeof window !== 'undefined' &&
29
+ window.XDomainRequest && !('withCredentials' in request) &&
30
+ !isURLSameOrigin(config.url)) {
31
+ request = new window.XDomainRequest();
32
+ loadEvent = 'onload';
33
+ xDomain = true;
34
+ request.onprogress = function handleProgress() {};
35
+ request.ontimeout = function handleTimeout() {};
36
+ }
37
+
38
+ // HTTP basic authentication
39
+ if (config.auth) {
40
+ var username = config.auth.username || '';
41
+ var password = config.auth.password || '';
42
+ requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
43
+ }
44
+
45
+ request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
46
+
47
+ // Set the request timeout in MS
48
+ request.timeout = config.timeout;
49
+
50
+ // Listen for ready state
51
+ request[loadEvent] = function handleLoad() {
52
+ if (!request || (request.readyState !== 4 && !xDomain)) {
53
+ return;
54
+ }
55
+
56
+ // The request errored out and we didn't get a response, this will be
57
+ // handled by onerror instead
58
+ // With one exception: request that using file: protocol, most browsers
59
+ // will return status as 0 even though it's a successful request
60
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
61
+ return;
62
+ }
63
+
64
+ // Prepare the response
65
+ var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
66
+ var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
67
+ var response = {
68
+ data: responseData,
69
+ // IE sends 1223 instead of 204 (https://github.com/axios/axios/issues/201)
70
+ status: request.status === 1223 ? 204 : request.status,
71
+ statusText: request.status === 1223 ? 'No Content' : request.statusText,
72
+ headers: responseHeaders,
73
+ config: config,
74
+ request: request
75
+ };
76
+
77
+ settle(resolve, reject, response);
78
+
79
+ // Clean up request
80
+ request = null;
81
+ };
82
+
83
+ // Handle low level network errors
84
+ request.onerror = function handleError() {
85
+ // Real errors are hidden from us by the browser
86
+ // onerror should only fire if it's a network error
87
+ reject(createError('Network Error', config, null, request));
88
+
89
+ // Clean up request
90
+ request = null;
91
+ };
92
+
93
+ // Handle timeout
94
+ request.ontimeout = function handleTimeout() {
95
+ reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',
96
+ request));
97
+
98
+ // Clean up request
99
+ request = null;
100
+ };
101
+
102
+ // Add xsrf header
103
+ // This is only done if running in a standard browser environment.
104
+ // Specifically not if we're in a web worker, or react-native.
105
+ if (utils.isStandardBrowserEnv()) {
106
+ var cookies = require('./../helpers/cookies');
107
+
108
+ // Add xsrf header
109
+ var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
110
+ cookies.read(config.xsrfCookieName) :
111
+ undefined;
112
+
113
+ if (xsrfValue) {
114
+ requestHeaders[config.xsrfHeaderName] = xsrfValue;
115
+ }
116
+ }
117
+
118
+ // Add headers to the request
119
+ if ('setRequestHeader' in request) {
120
+ utils.forEach(requestHeaders, function setRequestHeader(val, key) {
121
+ if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
122
+ // Remove Content-Type if data is undefined
123
+ delete requestHeaders[key];
124
+ } else {
125
+ // Otherwise add header to the request
126
+ request.setRequestHeader(key, val);
127
+ }
128
+ });
129
+ }
130
+
131
+ // Add withCredentials to request if needed
132
+ if (config.withCredentials) {
133
+ request.withCredentials = true;
134
+ }
135
+
136
+ // Add responseType to request if needed
137
+ if (config.responseType) {
138
+ try {
139
+ request.responseType = config.responseType;
140
+ } catch (e) {
141
+ // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
142
+ // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
143
+ if (config.responseType !== 'json') {
144
+ throw e;
145
+ }
146
+ }
147
+ }
148
+
149
+ // Handle progress if needed
150
+ if (typeof config.onDownloadProgress === 'function') {
151
+ request.addEventListener('progress', config.onDownloadProgress);
152
+ }
153
+
154
+ // Not all browsers support upload events
155
+ if (typeof config.onUploadProgress === 'function' && request.upload) {
156
+ request.upload.addEventListener('progress', config.onUploadProgress);
157
+ }
158
+
159
+ if (config.cancelToken) {
160
+ // Handle cancellation
161
+ config.cancelToken.promise.then(function onCanceled(cancel) {
162
+ if (!request) {
163
+ return;
164
+ }
165
+
166
+ request.abort();
167
+ reject(cancel);
168
+ // Clean up request
169
+ request = null;
170
+ });
171
+ }
172
+
173
+ if (requestData === undefined) {
174
+ requestData = null;
175
+ }
176
+
177
+ // Send the request
178
+ request.send(requestData);
179
+ });
180
+ };
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ var utils = require('./utils');
4
+ var bind = require('./helpers/bind');
5
+ var Axios = require('./core/Axios');
6
+ var defaults = require('./defaults');
7
+
8
+ /**
9
+ * Create an instance of Axios
10
+ *
11
+ * @param {Object} defaultConfig The default config for the instance
12
+ * @return {Axios} A new instance of Axios
13
+ */
14
+ function createInstance(defaultConfig) {
15
+ var context = new Axios(defaultConfig);
16
+ var instance = bind(Axios.prototype.request, context);
17
+
18
+ // Copy axios.prototype to instance
19
+ utils.extend(instance, Axios.prototype, context);
20
+
21
+ // Copy context to instance
22
+ utils.extend(instance, context);
23
+
24
+ return instance;
25
+ }
26
+
27
+ // Create the default instance to be exported
28
+ var axios = createInstance(defaults);
29
+
30
+ // Expose Axios class to allow class inheritance
31
+ axios.Axios = Axios;
32
+
33
+ // Factory for creating new instances
34
+ axios.create = function create(instanceConfig) {
35
+ return createInstance(utils.merge(defaults, instanceConfig));
36
+ };
37
+
38
+ // Expose Cancel & CancelToken
39
+ axios.Cancel = require('./cancel/Cancel');
40
+ axios.CancelToken = require('./cancel/CancelToken');
41
+ axios.isCancel = require('./cancel/isCancel');
42
+
43
+ // Expose all/spread
44
+ axios.all = function all(promises) {
45
+ return Promise.all(promises);
46
+ };
47
+ axios.spread = require('./helpers/spread');
48
+
49
+ module.exports = axios;
50
+
51
+ // Allow use of default import syntax in TypeScript
52
+ module.exports.default = axios;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * A `Cancel` is an object that is thrown when an operation is canceled.
5
+ *
6
+ * @class
7
+ * @param {string=} message The message.
8
+ */
9
+ function Cancel(message) {
10
+ this.message = message;
11
+ }
12
+
13
+ Cancel.prototype.toString = function toString() {
14
+ return 'Cancel' + (this.message ? ': ' + this.message : '');
15
+ };
16
+
17
+ Cancel.prototype.__CANCEL__ = true;
18
+
19
+ module.exports = Cancel;
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ var Cancel = require('./Cancel');
4
+
5
+ /**
6
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
7
+ *
8
+ * @class
9
+ * @param {Function} executor The executor function.
10
+ */
11
+ function CancelToken(executor) {
12
+ if (typeof executor !== 'function') {
13
+ throw new TypeError('executor must be a function.');
14
+ }
15
+
16
+ var resolvePromise;
17
+ this.promise = new Promise(function promiseExecutor(resolve) {
18
+ resolvePromise = resolve;
19
+ });
20
+
21
+ var token = this;
22
+ executor(function cancel(message) {
23
+ if (token.reason) {
24
+ // Cancellation has already been requested
25
+ return;
26
+ }
27
+
28
+ token.reason = new Cancel(message);
29
+ resolvePromise(token.reason);
30
+ });
31
+ }
32
+
33
+ /**
34
+ * Throws a `Cancel` if cancellation has been requested.
35
+ */
36
+ CancelToken.prototype.throwIfRequested = function throwIfRequested() {
37
+ if (this.reason) {
38
+ throw this.reason;
39
+ }
40
+ };
41
+
42
+ /**
43
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
44
+ * cancels the `CancelToken`.
45
+ */
46
+ CancelToken.source = function source() {
47
+ var cancel;
48
+ var token = new CancelToken(function executor(c) {
49
+ cancel = c;
50
+ });
51
+ return {
52
+ token: token,
53
+ cancel: cancel
54
+ };
55
+ };
56
+
57
+ module.exports = CancelToken;
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = function isCancel(value) {
4
+ return !!(value && value.__CANCEL__);
5
+ };
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+
3
+ var defaults = require('./../defaults');
4
+ var utils = require('./../utils');
5
+ var InterceptorManager = require('./InterceptorManager');
6
+ var dispatchRequest = require('./dispatchRequest');
7
+
8
+ /**
9
+ * Create a new instance of Axios
10
+ *
11
+ * @param {Object} instanceConfig The default config for the instance
12
+ */
13
+ function Axios(instanceConfig) {
14
+ this.defaults = instanceConfig;
15
+ this.interceptors = {
16
+ request: new InterceptorManager(),
17
+ response: new InterceptorManager()
18
+ };
19
+ }
20
+
21
+ /**
22
+ * Dispatch a request
23
+ *
24
+ * @param {Object} config The config specific for this request (merged with this.defaults)
25
+ */
26
+ Axios.prototype.request = function request(config) {
27
+ /*eslint no-param-reassign:0*/
28
+ // Allow for axios('example/url'[, config]) a la fetch API
29
+ if (typeof config === 'string') {
30
+ config = utils.merge({
31
+ url: arguments[0]
32
+ }, arguments[1]);
33
+ }
34
+
35
+ config = utils.merge(defaults, {method: 'get'}, this.defaults, config);
36
+ config.method = config.method.toLowerCase();
37
+
38
+ // Hook up interceptors middleware
39
+ var chain = [dispatchRequest, undefined];
40
+ var promise = Promise.resolve(config);
41
+
42
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
43
+ chain.unshift(interceptor.fulfilled, interceptor.rejected);
44
+ });
45
+
46
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
47
+ chain.push(interceptor.fulfilled, interceptor.rejected);
48
+ });
49
+
50
+ while (chain.length) {
51
+ promise = promise.then(chain.shift(), chain.shift());
52
+ }
53
+
54
+ return promise;
55
+ };
56
+
57
+ // Provide aliases for supported request methods
58
+ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
59
+ /*eslint func-names:0*/
60
+ Axios.prototype[method] = function(url, config) {
61
+ return this.request(utils.merge(config || {}, {
62
+ method: method,
63
+ url: url
64
+ }));
65
+ };
66
+ });
67
+
68
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
69
+ /*eslint func-names:0*/
70
+ Axios.prototype[method] = function(url, data, config) {
71
+ return this.request(utils.merge(config || {}, {
72
+ method: method,
73
+ url: url,
74
+ data: data
75
+ }));
76
+ };
77
+ });
78
+
79
+ module.exports = Axios;