@testim/testim-cli 3.289.0 → 3.290.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.
Files changed (217) hide show
  1. package/cli.js +22390 -122
  2. package/cli.js.map +1 -0
  3. package/npm-shrinkwrap.json +1951 -203
  4. package/package.json +9 -5
  5. package/OverrideTestDataBuilder.js +0 -117
  6. package/agent/routers/cliJsCode/index.js +0 -13
  7. package/agent/routers/cliJsCode/router.js +0 -63
  8. package/agent/routers/cliJsCode/service.js +0 -705
  9. package/agent/routers/codim/router.js +0 -69
  10. package/agent/routers/codim/router.test.js +0 -60
  11. package/agent/routers/codim/service.js +0 -193
  12. package/agent/routers/general/index.js +0 -36
  13. package/agent/routers/hybrid/registerRoutes.js +0 -81
  14. package/agent/routers/index.js +0 -56
  15. package/agent/routers/playground/router.js +0 -77
  16. package/agent/routers/playground/service.js +0 -96
  17. package/agent/routers/standalone-browser/registerRoutes.js +0 -47
  18. package/agent/server.js +0 -150
  19. package/cdpTestRunner.js +0 -86
  20. package/chromiumInstaller.js +0 -91
  21. package/cli/isCiRun.js +0 -10
  22. package/cli/onExit.js +0 -65
  23. package/cli/writeStackTrace.js +0 -27
  24. package/cliAgentMode.js +0 -384
  25. package/codim/codim-cli.js +0 -91
  26. package/codim/codim-npm-package/index.ts +0 -427
  27. package/codim/codim-npm-package/package-lock.json +0 -14
  28. package/codim/codim-npm-package/package.json +0 -14
  29. package/codim/hybrid-utils.js +0 -28
  30. package/codim/measure-perf.js +0 -41
  31. package/codim/template.js/.idea/workspace.xml +0 -57
  32. package/codim/template.js/.vscode/launch.json +0 -53
  33. package/codim/template.ts/.idea/workspace.xml +0 -57
  34. package/codim/template.ts/.vscode/launch.json +0 -55
  35. package/commons/AbortError.js +0 -12
  36. package/commons/SeleniumPerfStats.js +0 -58
  37. package/commons/chrome-launcher.js +0 -15
  38. package/commons/chromedriverWrapper.js +0 -70
  39. package/commons/config.js +0 -39
  40. package/commons/constants.js +0 -67
  41. package/commons/detectDebugger.js +0 -19
  42. package/commons/featureAvailabilityService.js +0 -26
  43. package/commons/featureFlags.js +0 -132
  44. package/commons/getSessionPlayerRequire.js +0 -28
  45. package/commons/httpRequest.js +0 -261
  46. package/commons/httpRequestCounters.js +0 -98
  47. package/commons/httpRequestCounters.test.js +0 -38
  48. package/commons/initializeUserWithAuth.js +0 -55
  49. package/commons/lazyRequire.js +0 -105
  50. package/commons/logUtils.js +0 -15
  51. package/commons/logUtils.test.js +0 -21
  52. package/commons/logger.js +0 -178
  53. package/commons/mockNetworkRuleFileSchema.json +0 -140
  54. package/commons/npmWrapper.js +0 -174
  55. package/commons/npmWrapper.test.js +0 -374
  56. package/commons/performance-logger.js +0 -71
  57. package/commons/preloadTests.js +0 -29
  58. package/commons/prepareRunner.js +0 -85
  59. package/commons/prepareRunner.test.js +0 -144
  60. package/commons/prepareRunnerAndTestimStartUtils.js +0 -198
  61. package/commons/prepareRunnerAndTestimStartUtils.test.js +0 -73
  62. package/commons/requireWithFallback.js +0 -25
  63. package/commons/runnerFileCache.js +0 -204
  64. package/commons/socket/baseSocketServiceSocketIO.js +0 -197
  65. package/commons/socket/realDataService.js +0 -59
  66. package/commons/socket/realDataServiceSocketIO.js +0 -33
  67. package/commons/socket/remoteStepService.js +0 -55
  68. package/commons/socket/remoteStepServiceSocketIO.js +0 -61
  69. package/commons/socket/socketService.js +0 -175
  70. package/commons/socket/testResultService.js +0 -62
  71. package/commons/socket/testResultServiceSocketIO.js +0 -64
  72. package/commons/testimAnalytics.js +0 -40
  73. package/commons/testimCloudflare.js +0 -83
  74. package/commons/testimCloudflare.test.js +0 -185
  75. package/commons/testimCustomToken.js +0 -124
  76. package/commons/testimDesiredCapabilitiesBuilder.js +0 -647
  77. package/commons/testimNgrok.js +0 -90
  78. package/commons/testimNgrok.test.js +0 -140
  79. package/commons/testimServicesApi.js +0 -631
  80. package/commons/testimTunnel.js +0 -73
  81. package/commons/testimTunnel.test.js +0 -172
  82. package/commons/xhr2.js +0 -897
  83. package/coverage/SummaryToObjectReport.js +0 -19
  84. package/coverage/jsCoverage.js +0 -252
  85. package/credentialsManager.js +0 -142
  86. package/errors.js +0 -161
  87. package/executionQueue.js +0 -37
  88. package/fixLocalBuild.js +0 -24
  89. package/inputFileUtils.js +0 -103
  90. package/lib/coralogix-winston.transport.js +0 -99
  91. package/player/SeleniumProtocolError.js +0 -100
  92. package/player/WebDriverHttpRequest.js +0 -177
  93. package/player/WebdriverioWebDriverApi.js +0 -671
  94. package/player/appiumTestPlayer.js +0 -90
  95. package/player/chromeLauncherTestPlayer.js +0 -67
  96. package/player/constants.js +0 -332
  97. package/player/extensionTestPlayer.js +0 -32
  98. package/player/findElementStrategy.js +0 -154
  99. package/player/scripts/isElementDisplayed.js +0 -252
  100. package/player/seleniumTestPlayer.js +0 -140
  101. package/player/services/frameLocator.js +0 -170
  102. package/player/services/mobileFrameLocatorMock.js +0 -32
  103. package/player/services/playbackTimeoutCalculator.js +0 -175
  104. package/player/services/portSelector.js +0 -19
  105. package/player/services/tabService.js +0 -551
  106. package/player/services/tabServiceMock.js +0 -167
  107. package/player/services/windowCreationListener.js +0 -8
  108. package/player/stepActions/RefreshStepAction.js +0 -16
  109. package/player/stepActions/apiStepAction.js +0 -89
  110. package/player/stepActions/baseCliJsStepAction.js +0 -51
  111. package/player/stepActions/baseJsStepAction.js +0 -277
  112. package/player/stepActions/cliConditionStepAction.js +0 -11
  113. package/player/stepActions/cliJsStepAction.js +0 -11
  114. package/player/stepActions/dropFileStepAction.js +0 -34
  115. package/player/stepActions/evaluateExpressionStepAction.js +0 -52
  116. package/player/stepActions/extensionOnlyStepAction.js +0 -12
  117. package/player/stepActions/extractTextStepAction.js +0 -19
  118. package/player/stepActions/hoverStepAction.js +0 -55
  119. package/player/stepActions/inputFileStepAction.js +0 -199
  120. package/player/stepActions/jsCodeStepAction.js +0 -11
  121. package/player/stepActions/jsConditionStepAction.js +0 -11
  122. package/player/stepActions/locateStepAction.js +0 -159
  123. package/player/stepActions/mouseStepAction.js +0 -370
  124. package/player/stepActions/navigationStepAction.js +0 -29
  125. package/player/stepActions/nodePackageStepAction.js +0 -47
  126. package/player/stepActions/pixelValidationStepAction.js +0 -39
  127. package/player/stepActions/scripts/dispatchEvents.js +0 -282
  128. package/player/stepActions/scripts/doClick.js +0 -221
  129. package/player/stepActions/scripts/doDragPath.js +0 -225
  130. package/player/stepActions/scripts/doubleClick.js +0 -119
  131. package/player/stepActions/scripts/dropEvent.js +0 -63
  132. package/player/stepActions/scripts/focusElement.js +0 -46
  133. package/player/stepActions/scripts/html5dragAction.js +0 -56
  134. package/player/stepActions/scripts/html5dragActionV2.js +0 -312
  135. package/player/stepActions/scripts/runCode.js +0 -147
  136. package/player/stepActions/scripts/scroll.js +0 -90
  137. package/player/stepActions/scripts/selectOption.js +0 -51
  138. package/player/stepActions/scripts/setText.js +0 -415
  139. package/player/stepActions/scripts/wheel.js +0 -61
  140. package/player/stepActions/scrollStepAction.js +0 -96
  141. package/player/stepActions/selectOptionStepAction.js +0 -49
  142. package/player/stepActions/sfdcRecordedStepAction.js +0 -24
  143. package/player/stepActions/sfdcStepAction.js +0 -28
  144. package/player/stepActions/sleepStepAction.js +0 -12
  145. package/player/stepActions/specialKeyStepAction.js +0 -52
  146. package/player/stepActions/stepAction.js +0 -73
  147. package/player/stepActions/stepActionRegistrar.js +0 -111
  148. package/player/stepActions/submitStepAction.js +0 -12
  149. package/player/stepActions/tdkHybridStepAction.js +0 -18
  150. package/player/stepActions/textStepAction.js +0 -110
  151. package/player/stepActions/textValidationStepAction.js +0 -64
  152. package/player/stepActions/wheelStepAction.js +0 -41
  153. package/player/utils/cookieUtils.js +0 -39
  154. package/player/utils/eyeSdkService.js +0 -250
  155. package/player/utils/imageCaptureUtils.js +0 -267
  156. package/player/utils/screenshotUtils.js +0 -68
  157. package/player/utils/stepActionUtils.js +0 -90
  158. package/player/utils/windowUtils.js +0 -195
  159. package/player/webDriverUtils.js +0 -40
  160. package/player/webDriverUtils.test.js +0 -116
  161. package/player/webdriver.js +0 -976
  162. package/polyfills/Array.prototype.at.js +0 -13
  163. package/polyfills/index.js +0 -13
  164. package/processHandler.js +0 -79
  165. package/processHandler.test.js +0 -55
  166. package/reports/chromeReporter.js +0 -17
  167. package/reports/consoleReporter.js +0 -190
  168. package/reports/debugReporter.js +0 -82
  169. package/reports/jsonReporter.js +0 -55
  170. package/reports/junitReporter.js +0 -183
  171. package/reports/reporter.js +0 -166
  172. package/reports/reporterUtils.js +0 -54
  173. package/reports/teamCityReporter.js +0 -73
  174. package/runOptions.d.ts +0 -305
  175. package/runOptions.js +0 -1288
  176. package/runOptionsAgentFlow.js +0 -87
  177. package/runOptionsUtils.js +0 -60
  178. package/runner.js +0 -355
  179. package/runners/ParallelWorkerManager.js +0 -284
  180. package/runners/TestPlanRunner.js +0 -419
  181. package/runners/buildCodeTests.js +0 -159
  182. package/runners/runnerUtils.js +0 -81
  183. package/services/analyticsService.js +0 -96
  184. package/services/branchService.js +0 -29
  185. package/services/gridService.js +0 -357
  186. package/services/gridService.test.js +0 -357
  187. package/services/labFeaturesService.js +0 -64
  188. package/services/lambdatestService.js +0 -227
  189. package/services/lambdatestService.test.js +0 -353
  190. package/services/localRCASaver.js +0 -124
  191. package/stepPlayers/cliJsStepPlayback.js +0 -40
  192. package/stepPlayers/hybridStepPlayback.js +0 -140
  193. package/stepPlayers/nodePackageStepPlayback.js +0 -28
  194. package/stepPlayers/playwrightHybridStepPlayback.js +0 -61
  195. package/stepPlayers/puppeteerHybridStepPlayback.js +0 -76
  196. package/stepPlayers/remoteStepPlayback.js +0 -80
  197. package/stepPlayers/seleniumHybridStepPlayback.js +0 -84
  198. package/stepPlayers/tdkHybridStepPlayback.js +0 -112
  199. package/testRunHandler.js +0 -603
  200. package/testRunStatus.js +0 -567
  201. package/testimNpmDriver.js +0 -52
  202. package/utils/argsUtils.js +0 -91
  203. package/utils/argsUtils.test.js +0 -32
  204. package/utils/fsUtils.js +0 -174
  205. package/utils/index.js +0 -197
  206. package/utils/promiseUtils.js +0 -85
  207. package/utils/stringUtils.js +0 -98
  208. package/utils/stringUtils.test.js +0 -22
  209. package/utils/timeUtils.js +0 -25
  210. package/utils/utils.test.js +0 -27
  211. package/workers/BaseWorker.js +0 -498
  212. package/workers/BaseWorker.test.js +0 -186
  213. package/workers/WorkerAppium.js +0 -180
  214. package/workers/WorkerExtension.js +0 -192
  215. package/workers/WorkerExtensionSingleBrowser.js +0 -77
  216. package/workers/WorkerSelenium.js +0 -253
  217. package/workers/workerUtils.js +0 -20
package/commons/xhr2.js DELETED
@@ -1,897 +0,0 @@
1
- /* eslint-disable */
2
- const FormData = require('form-data');
3
-
4
- (function () {
5
- let InvalidStateError; let NetworkError; let ProgressEvent; let SecurityError; let SyntaxError; let XMLHttpRequest; let XMLHttpRequestEventTarget; let XMLHttpRequestUpload; let http; let https; let os; let url;
6
- const extend = function (child, parent) {
7
- for (const key in parent) {
8
- if (hasProp.call(parent, key)) {
9
- child[key] = parent[key];
10
- }
11
- }
12
- function ctor() {
13
- this.constructor = child;
14
- }
15
-
16
- ctor.prototype = parent.prototype;
17
- child.prototype = new ctor();
18
- child.__super__ = parent.prototype;
19
- return child;
20
- };
21
- var hasProp = {}.hasOwnProperty;
22
-
23
- XMLHttpRequestEventTarget = (function () {
24
- function XMLHttpRequestEventTarget() {
25
- this.onloadstart = null;
26
- this.onprogress = null;
27
- this.onabort = null;
28
- this.onerror = null;
29
- this.onload = null;
30
- this.ontimeout = null;
31
- this.onloadend = null;
32
- this._listeners = {};
33
- }
34
-
35
- XMLHttpRequestEventTarget.prototype.onloadstart = null;
36
-
37
- XMLHttpRequestEventTarget.prototype.onprogress = null;
38
-
39
- XMLHttpRequestEventTarget.prototype.onabort = null;
40
-
41
- XMLHttpRequestEventTarget.prototype.onerror = null;
42
-
43
- XMLHttpRequestEventTarget.prototype.onload = null;
44
-
45
- XMLHttpRequestEventTarget.prototype.ontimeout = null;
46
-
47
- XMLHttpRequestEventTarget.prototype.onloadend = null;
48
-
49
- XMLHttpRequestEventTarget.prototype.addEventListener = function (eventType, listener) {
50
- let base;
51
- eventType = eventType.toLowerCase();
52
- (base = this._listeners)[eventType] || (base[eventType] = []);
53
- this._listeners[eventType].push(listener);
54
- return void 0;
55
- };
56
-
57
- XMLHttpRequestEventTarget.prototype.removeEventListener = function (eventType, listener) {
58
- let index;
59
- eventType = eventType.toLowerCase();
60
- if (this._listeners[eventType]) {
61
- index = this._listeners[eventType].indexOf(listener);
62
- if (index !== -1) {
63
- this._listeners[eventType].splice(index, 1);
64
- }
65
- }
66
- return void 0;
67
- };
68
-
69
- XMLHttpRequestEventTarget.prototype.dispatchEvent = function (event) {
70
- let eventType; let j; let len; let listener; let
71
- listeners;
72
- event.currentTarget = event.target = this;
73
- eventType = event.type;
74
- if (listeners = this._listeners[eventType]) {
75
- for (j = 0, len = listeners.length; j < len; j++) {
76
- listener = listeners[j];
77
- listener.call(this, event);
78
- }
79
- }
80
- if (listener = this[`on${eventType}`]) {
81
- listener.call(this, event);
82
- }
83
- return void 0;
84
- };
85
-
86
- return XMLHttpRequestEventTarget;
87
- }());
88
-
89
- http = require('http');
90
-
91
- https = require('https');
92
-
93
- os = require('os');
94
-
95
- url = require('url');
96
-
97
- XMLHttpRequest = (function (superClass) {
98
- extend(XMLHttpRequest, superClass);
99
-
100
- function XMLHttpRequest(options) {
101
- XMLHttpRequest.__super__.constructor.call(this);
102
- this.onreadystatechange = null;
103
- this._anonymous = options && options.anon;
104
- this.readyState = XMLHttpRequest.UNSENT;
105
- this.response = null;
106
- this.responseText = '';
107
- this.responseType = '';
108
- this.status = 0;
109
- this.statusText = '';
110
- this.timeout = 0;
111
- this.upload = new XMLHttpRequestUpload(this);
112
- this._method = null;
113
- this._url = null;
114
- this._sync = false;
115
- this._headers = null;
116
- this._loweredHeaders = null;
117
- this._mimeOverride = null;
118
- this._request = null;
119
- this._response = null;
120
- this._responseParts = null;
121
- this._responseHeaders = null;
122
- this._aborting = null;
123
- this._error = null;
124
- this._loadedBytes = 0;
125
- this._totalBytes = 0;
126
- this._lengthComputable = false;
127
- }
128
-
129
- XMLHttpRequest.prototype.onreadystatechange = null;
130
-
131
- XMLHttpRequest.prototype.readyState = null;
132
-
133
- XMLHttpRequest.prototype.response = null;
134
-
135
- XMLHttpRequest.prototype.responseText = null;
136
-
137
- XMLHttpRequest.prototype.responseType = null;
138
-
139
- XMLHttpRequest.prototype.status = null;
140
-
141
- XMLHttpRequest.prototype.timeout = null;
142
-
143
- XMLHttpRequest.prototype.upload = null;
144
-
145
- XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
146
- let xhrUrl;
147
- method = method.toUpperCase();
148
- if (method in this._restrictedMethods) {
149
- throw new SecurityError(`HTTP method ${method} is not allowed in XHR`);
150
- }
151
- xhrUrl = this._parseUrl(url);
152
- if (async === void 0) {
153
- async = true;
154
- }
155
- switch (this.readyState) {
156
- case XMLHttpRequest.UNSENT:
157
- case XMLHttpRequest.OPENED:
158
- case XMLHttpRequest.DONE:
159
- null;
160
- break;
161
- case XMLHttpRequest.HEADERS_RECEIVED:
162
- case XMLHttpRequest.LOADING:
163
- null;
164
- }
165
- this._method = method;
166
- this._url = xhrUrl;
167
- this._sync = !async;
168
- this._headers = {};
169
- this._loweredHeaders = {};
170
- this._mimeOverride = null;
171
- this._setReadyState(XMLHttpRequest.OPENED);
172
- this._request = null;
173
- this._response = null;
174
- this.status = 0;
175
- this.statusText = '';
176
- this._responseParts = [];
177
- this._responseHeaders = null;
178
- this._loadedBytes = 0;
179
- this._totalBytes = 0;
180
- this._lengthComputable = false;
181
- return void 0;
182
- };
183
-
184
- XMLHttpRequest.prototype.setRequestHeader = function (name, value) {
185
- let loweredName;
186
- if (this.readyState !== XMLHttpRequest.OPENED) {
187
- throw new InvalidStateError('XHR readyState must be OPENED');
188
- }
189
- loweredName = name.toLowerCase();
190
- if (this._restrictedHeaders[loweredName] || /^sec\-/.test(loweredName) || /^proxy-/.test(loweredName)) {
191
- return void 0;
192
- }
193
- value = value.toString();
194
- if (loweredName in this._loweredHeaders) {
195
- name = this._loweredHeaders[loweredName];
196
- this._headers[name] = `${this._headers[name]}, ${value}`;
197
- } else {
198
- this._loweredHeaders[loweredName] = name;
199
- this._headers[name] = value;
200
- }
201
- return void 0;
202
- };
203
-
204
- XMLHttpRequest.prototype.send = function (data) {
205
- if (this.readyState !== XMLHttpRequest.OPENED) {
206
- throw new InvalidStateError('XHR readyState must be OPENED');
207
- }
208
- if (this._request) {
209
- throw new InvalidStateError('send() already called');
210
- }
211
- switch (this._url.protocol) {
212
- case 'file:':
213
- this._sendFile(data);
214
- break;
215
- case 'http:':
216
- case 'https:':
217
- this._sendHttp(data);
218
- break;
219
- default:
220
- throw new NetworkError(`Unsupported protocol ${this._url.protocol}`);
221
- }
222
- return void 0;
223
- };
224
-
225
- XMLHttpRequest.prototype.abort = function () {
226
- if (!this._request) {
227
- return;
228
- }
229
- this._request.abort();
230
- this._setError();
231
- this._dispatchProgress('abort');
232
- this._dispatchProgress('loadend');
233
- return void 0;
234
- };
235
-
236
- XMLHttpRequest.prototype.getResponseHeader = function (name) {
237
- let loweredName;
238
- if (!this._responseHeaders) {
239
- return null;
240
- }
241
- loweredName = name.toLowerCase();
242
- if (loweredName in this._responseHeaders) {
243
- return this._responseHeaders[loweredName];
244
- }
245
- return null;
246
- };
247
-
248
- XMLHttpRequest.prototype.getAllResponseHeaders = function () {
249
- let lines; let name; let
250
- value;
251
- if (!this._responseHeaders) {
252
- return '';
253
- }
254
- lines = (function () {
255
- let ref; let
256
- results;
257
- ref = this._responseHeaders;
258
- results = [];
259
- for (name in ref) {
260
- value = ref[name];
261
- results.push(`${name}: ${value}`);
262
- }
263
- return results;
264
- }).call(this);
265
- return lines.join('\r\n');
266
- };
267
-
268
- XMLHttpRequest.prototype.overrideMimeType = function (newMimeType) {
269
- if (this.readyState === XMLHttpRequest.LOADING || this.readyState === XMLHttpRequest.DONE) {
270
- throw new InvalidStateError('overrideMimeType() not allowed in LOADING or DONE');
271
- }
272
- this._mimeOverride = newMimeType.toLowerCase();
273
- return void 0;
274
- };
275
-
276
- XMLHttpRequest.prototype.nodejsSet = function (options) {
277
- let baseUrl; let
278
- parsedUrl;
279
- if ('httpAgent' in options) {
280
- this.nodejsHttpAgent = options.httpAgent;
281
- }
282
- if ('httpsAgent' in options) {
283
- this.nodejsHttpsAgent = options.httpsAgent;
284
- }
285
- if ('baseUrl' in options) {
286
- baseUrl = options.baseUrl;
287
- if (baseUrl !== null) {
288
- parsedUrl = url.parse(baseUrl, false, true);
289
- if (!parsedUrl.protocol) {
290
- throw new SyntaxError('baseUrl must be an absolute URL');
291
- }
292
- }
293
- this.nodejsBaseUrl = baseUrl;
294
- }
295
- return void 0;
296
- };
297
-
298
- XMLHttpRequest.nodejsSet = function (options) {
299
- XMLHttpRequest.prototype.nodejsSet(options);
300
- return void 0;
301
- };
302
-
303
- XMLHttpRequest.prototype.UNSENT = 0;
304
-
305
- XMLHttpRequest.UNSENT = 0;
306
-
307
- XMLHttpRequest.prototype.OPENED = 1;
308
-
309
- XMLHttpRequest.OPENED = 1;
310
-
311
- XMLHttpRequest.prototype.HEADERS_RECEIVED = 2;
312
-
313
- XMLHttpRequest.HEADERS_RECEIVED = 2;
314
-
315
- XMLHttpRequest.prototype.LOADING = 3;
316
-
317
- XMLHttpRequest.LOADING = 3;
318
-
319
- XMLHttpRequest.prototype.DONE = 4;
320
-
321
- XMLHttpRequest.DONE = 4;
322
-
323
- XMLHttpRequest.prototype.nodejsHttpAgent = http.globalAgent;
324
-
325
- XMLHttpRequest.prototype.nodejsHttpsAgent = https.globalAgent;
326
-
327
- XMLHttpRequest.prototype.nodejsBaseUrl = null;
328
-
329
- XMLHttpRequest.prototype._restrictedMethods = {
330
- CONNECT: true,
331
- TRACE: true,
332
- TRACK: true,
333
- };
334
-
335
- XMLHttpRequest.prototype._restrictedHeaders = {
336
- 'accept-charset': true,
337
- 'accept-encoding': true,
338
- 'access-control-request-headers': true,
339
- 'access-control-request-method': true,
340
- connection: true,
341
- 'content-length': true,
342
- cookie: true,
343
- cookie2: true,
344
- date: true,
345
- dnt: true,
346
- expect: true,
347
- host: true,
348
- 'keep-alive': true,
349
- origin: true,
350
- referer: true,
351
- te: true,
352
- trailer: true,
353
- 'transfer-encoding': true,
354
- upgrade: true,
355
- 'user-agent': true,
356
- via: true,
357
- };
358
-
359
- XMLHttpRequest.prototype._privateHeaders = {
360
- 'set-cookie': false,
361
- 'set-cookie2': false,
362
- };
363
-
364
- XMLHttpRequest.prototype._userAgent = `Mozilla/5.0 (${os.type()} ${os.arch()}) ` + `node.js/${process.versions.node} v8/${process.versions.v8}`;
365
-
366
- XMLHttpRequest.prototype._setReadyState = function (newReadyState) {
367
- let event;
368
- this.readyState = newReadyState;
369
- event = new ProgressEvent('readystatechange');
370
- this.dispatchEvent(event);
371
- return void 0;
372
- };
373
-
374
- XMLHttpRequest.prototype._sendFile = function () {
375
- if (this._url.method !== 'GET') {
376
- throw new NetworkError('The file protocol only supports GET');
377
- }
378
- throw new Error('Protocol file: not implemented');
379
- };
380
-
381
- XMLHttpRequest.prototype._sendHttp = function (data) {
382
- if (this._sync) {
383
- throw new Error('Synchronous XHR processing not implemented');
384
- }
385
- if ((data != null) && (this._method === 'GET' || this._method === 'HEAD')) {
386
- data = null;
387
- } else {
388
- data || (data = '');
389
- }
390
- this.upload._setData(data);
391
- this._finalizeHeaders(data);
392
- this._sendHxxpRequest(data);
393
- return void 0;
394
- };
395
-
396
- XMLHttpRequest.prototype._sendHxxpRequest = function (data) {
397
- let agent; let hxxp; let
398
- request;
399
- if (this._url.protocol === 'http:') {
400
- hxxp = http;
401
- agent = this.nodejsHttpAgent;
402
- } else {
403
- hxxp = https;
404
- agent = this.nodejsHttpsAgent;
405
- }
406
- request = hxxp.request({
407
- hostname: this._url.hostname,
408
- port: this._url.port,
409
- path: this._url.path,
410
- auth: this._url.auth,
411
- method: this._method,
412
- headers: this._headers,
413
- agent,
414
- });
415
-
416
- if (typeof data === 'object' && data instanceof FormData) {
417
- data.pipe(request);
418
- }
419
-
420
- this._request = request;
421
- if (this.timeout) {
422
- request.setTimeout(this.timeout, (function (_this) {
423
- return function () {
424
- return _this._onHttpTimeout(request);
425
- };
426
- }(this)));
427
- }
428
- request.on('response', (function (_this) {
429
- return function (response) {
430
- return _this._onHttpResponse(request, response);
431
- };
432
- }(this)));
433
- request.on('error', (function (_this) {
434
- return function (error) {
435
- return _this._onHttpRequestError(request, error);
436
- };
437
- }(this)));
438
- this.upload._startUpload(request);
439
- if (this._request === request) {
440
- this._dispatchProgress('loadstart');
441
- }
442
- return void 0;
443
- };
444
-
445
- XMLHttpRequest.prototype._finalizeHeaders = function (data) {
446
- if (typeof data === 'object' && data instanceof FormData) {
447
- Object.assign(this._headers, data.getHeaders());
448
- }
449
- this._headers.Connection = 'keep-alive';
450
- this._headers.Host = this._url.host;
451
- if (this._anonymous) {
452
- this._headers.Referer = 'about:blank';
453
- }
454
- this._headers['User-Agent'] = this._userAgent;
455
- this.upload._finalizeHeaders(this._headers, this._loweredHeaders);
456
- return void 0;
457
- };
458
-
459
- XMLHttpRequest.prototype._onHttpResponse = function (request, response) {
460
- let lengthString;
461
- if (this._request !== request) {
462
- return;
463
- }
464
- switch (response.statusCode) {
465
- case 301:
466
- case 302:
467
- case 303:
468
- case 307:
469
- case 308:
470
- this._url = this._parseUrl(response.headers.location);
471
- this._method = 'GET';
472
- if ('content-type' in this._loweredHeaders) {
473
- delete this._headers[this._loweredHeaders['content-type']];
474
- delete this._loweredHeaders['content-type'];
475
- }
476
- if ('Content-Type' in this._headers) {
477
- delete this._headers['Content-Type'];
478
- }
479
- delete this._headers['Content-Length'];
480
- this.upload._reset();
481
- this._finalizeHeaders();
482
- this._sendHxxpRequest();
483
- return;
484
- }
485
- this._response = response;
486
- this._response.on('data', (function (_this) {
487
- return function (data) {
488
- return _this._onHttpResponseData(response, data);
489
- };
490
- }(this)));
491
- this._response.on('end', (function (_this) {
492
- return function () {
493
- return _this._onHttpResponseEnd(response);
494
- };
495
- }(this)));
496
- this._response.on('close', (function (_this) {
497
- return function () {
498
- return _this._onHttpResponseClose(response);
499
- };
500
- }(this)));
501
- this.status = this._response.statusCode;
502
- this.statusText = http.STATUS_CODES[this.status];
503
- this._parseResponseHeaders(response);
504
- if (lengthString = this._responseHeaders['content-length']) {
505
- this._totalBytes = parseInt(lengthString);
506
- this._lengthComputable = true;
507
- } else {
508
- this._lengthComputable = false;
509
- }
510
- return this._setReadyState(XMLHttpRequest.HEADERS_RECEIVED);
511
- };
512
-
513
- XMLHttpRequest.prototype._onHttpResponseData = function (response, data) {
514
- if (this._response !== response) {
515
- return;
516
- }
517
- this._responseParts.push(data);
518
- this._loadedBytes += data.length;
519
- if (this.readyState !== XMLHttpRequest.LOADING) {
520
- this._setReadyState(XMLHttpRequest.LOADING);
521
- }
522
- return this._dispatchProgress('progress');
523
- };
524
-
525
- XMLHttpRequest.prototype._onHttpResponseEnd = function (response) {
526
- if (this._response !== response) {
527
- return;
528
- }
529
- this._parseResponse();
530
- this._request = null;
531
- this._response = null;
532
- this._setReadyState(XMLHttpRequest.DONE);
533
- this._dispatchProgress('load');
534
- return this._dispatchProgress('loadend');
535
- };
536
-
537
- XMLHttpRequest.prototype._onHttpResponseClose = function (response) {
538
- let request;
539
- if (this._response !== response) {
540
- return;
541
- }
542
- request = this._request;
543
- this._setError();
544
- request.abort();
545
- this._setReadyState(XMLHttpRequest.DONE);
546
- this._dispatchProgress('error');
547
- return this._dispatchProgress('loadend');
548
- };
549
-
550
- XMLHttpRequest.prototype._onHttpTimeout = function (request) {
551
- if (this._request !== request) {
552
- return;
553
- }
554
- this._setError();
555
- request.abort();
556
- this._setReadyState(XMLHttpRequest.DONE);
557
- this._dispatchProgress('timeout');
558
- return this._dispatchProgress('loadend');
559
- };
560
-
561
- XMLHttpRequest.prototype._onHttpRequestError = function (request, error) {
562
- if (this._request !== request) {
563
- return;
564
- }
565
- this._setError();
566
- request.abort();
567
- this._setReadyState(XMLHttpRequest.DONE);
568
- this._dispatchProgress('error');
569
- return this._dispatchProgress('loadend');
570
- };
571
-
572
- XMLHttpRequest.prototype._dispatchProgress = function (eventType) {
573
- let event;
574
- event = new ProgressEvent(eventType);
575
- event.lengthComputable = this._lengthComputable;
576
- event.loaded = this._loadedBytes;
577
- event.total = this._totalBytes;
578
- this.dispatchEvent(event);
579
- return void 0;
580
- };
581
-
582
- XMLHttpRequest.prototype._setError = function () {
583
- this._request = null;
584
- this._response = null;
585
- this._responseHeaders = null;
586
- this._responseParts = null;
587
- return void 0;
588
- };
589
-
590
- XMLHttpRequest.prototype._parseUrl = function (urlString) {
591
- let absoluteUrlString; let index; let password; let user; let
592
- xhrUrl;
593
- if (this.nodejsBaseUrl === null) {
594
- absoluteUrlString = urlString;
595
- } else {
596
- absoluteUrlString = url.resolve(this.nodejsBaseUrl, urlString);
597
- }
598
- xhrUrl = url.parse(absoluteUrlString, false, true);
599
- xhrUrl.hash = null;
600
- if (xhrUrl.auth && ((typeof user !== 'undefined' && user !== null) || (typeof password !== 'undefined' && password !== null))) {
601
- index = xhrUrl.auth.indexOf(':');
602
- if (index === -1) {
603
- if (!user) {
604
- user = xhrUrl.auth;
605
- }
606
- } else {
607
- if (!user) {
608
- user = xhrUrl.substring(0, index);
609
- }
610
- if (!password) {
611
- password = xhrUrl.substring(index + 1);
612
- }
613
- }
614
- }
615
- if (user || password) {
616
- xhrUrl.auth = `${user}:${password}`;
617
- }
618
- return xhrUrl;
619
- };
620
-
621
- XMLHttpRequest.prototype._parseResponseHeaders = function (response) {
622
- let loweredName; let name; let ref; let
623
- value;
624
- this._responseHeaders = {};
625
- ref = response.headers;
626
- for (name in ref) {
627
- value = ref[name];
628
- loweredName = name.toLowerCase();
629
- if (this._privateHeaders[loweredName]) {
630
- continue;
631
- }
632
- if (this._mimeOverride !== null && loweredName === 'content-type') {
633
- value = this._mimeOverride;
634
- }
635
- this._responseHeaders[loweredName] = value;
636
- }
637
- if (this._mimeOverride !== null && !('content-type' in this._responseHeaders)) {
638
- this._responseHeaders['content-type'] = this._mimeOverride;
639
- }
640
- return void 0;
641
- };
642
-
643
- XMLHttpRequest.prototype._parseResponse = function () {
644
- let arrayBuffer; let buffer; let i; let j; let jsonError; let ref; let
645
- view;
646
- if (Buffer.concat) {
647
- buffer = Buffer.concat(this._responseParts);
648
- } else {
649
- buffer = this._concatBuffers(this._responseParts);
650
- }
651
- // temporary workaround for transport encoding parsing
652
- if (this._responseHeaders['content-encoding'] && this._responseHeaders['content-encoding'] === 'gzip') {
653
- buffer = require('zlib').gunzipSync(buffer);
654
- }
655
- this._responseParts = null;
656
- switch (this.responseType) {
657
- case 'text':
658
- this._parseTextResponse(buffer);
659
- break;
660
- case 'json':
661
- this.responseText = null;
662
- try {
663
- this.response = JSON.parse(buffer.toString('utf-8'));
664
- } catch (_error) {
665
- jsonError = _error;
666
- this.response = null;
667
- }
668
- break;
669
- case 'buffer':
670
- this.responseText = null;
671
- this.response = buffer;
672
- break;
673
- case 'arraybuffer':
674
- this.responseText = null;
675
- arrayBuffer = new ArrayBuffer(buffer.length);
676
- view = new Uint8Array(arrayBuffer);
677
- for (i = j = 0, ref = buffer.length; ref >= 0 ? j < ref : j > ref; i = ref >= 0 ? ++j : --j) {
678
- view[i] = buffer[i];
679
- }
680
- this.response = arrayBuffer;
681
- break;
682
- default:
683
- this._parseTextResponse(buffer);
684
- }
685
- return void 0;
686
- };
687
-
688
- XMLHttpRequest.prototype._parseTextResponse = function (buffer) {
689
- let e;
690
- try {
691
- this.responseText = buffer.toString(this._parseResponseEncoding());
692
- } catch (_error) {
693
- e = _error;
694
- this.responseText = buffer.toString('binary');
695
- }
696
- this.response = this.responseText;
697
- return void 0;
698
- };
699
-
700
- XMLHttpRequest.prototype._parseResponseEncoding = function () {
701
- let contentType; let encoding; let
702
- match;
703
- encoding = null;
704
- if ((contentType = this._responseHeaders['content-type']) && (match = /\;\s*charset\=(.*)$/.exec(contentType))) {
705
- return match[1];
706
- }
707
- return 'utf-8';
708
- };
709
-
710
- XMLHttpRequest.prototype._concatBuffers = function (buffers) {
711
- let buffer; let j; let k; let len; let len1; let length; let
712
- target;
713
- if (buffers.length === 0) {
714
- return Buffer.alloc(0);
715
- }
716
- if (buffers.length === 1) {
717
- return buffers[0];
718
- }
719
- length = 0;
720
- for (j = 0, len = buffers.length; j < len; j++) {
721
- buffer = buffers[j];
722
- length += buffer.length;
723
- }
724
- target = Buffer.alloc(length);
725
- length = 0;
726
- for (k = 0, len1 = buffers.length; k < len1; k++) {
727
- buffer = buffers[k];
728
- buffer.copy(target, length);
729
- length += buffer.length;
730
- }
731
- return target;
732
- };
733
-
734
- return XMLHttpRequest;
735
- }(XMLHttpRequestEventTarget));
736
-
737
- module.exports = XMLHttpRequest;
738
-
739
- XMLHttpRequest.XMLHttpRequest = XMLHttpRequest;
740
-
741
- SecurityError = (function (superClass) {
742
- extend(SecurityError, superClass);
743
-
744
- function SecurityError() {
745
- SecurityError.__super__.constructor.apply(this, arguments);
746
- }
747
-
748
- return SecurityError;
749
- }(Error));
750
-
751
- XMLHttpRequest.SecurityError = SecurityError;
752
-
753
- InvalidStateError = (function (superClass) {
754
- extend(InvalidStateError, superClass);
755
-
756
- function InvalidStateError() {
757
- InvalidStateError.__super__.constructor.apply(this, arguments);
758
- }
759
-
760
- return InvalidStateError;
761
- }(Error));
762
-
763
- InvalidStateError = (function (superClass) {
764
- extend(InvalidStateError, superClass);
765
-
766
- function InvalidStateError() {
767
- return InvalidStateError.__super__.constructor.apply(this, arguments);
768
- }
769
-
770
- return InvalidStateError;
771
- }(Error));
772
-
773
- XMLHttpRequest.InvalidStateError = InvalidStateError;
774
-
775
- NetworkError = (function (superClass) {
776
- extend(NetworkError, superClass);
777
-
778
- function NetworkError() {
779
- NetworkError.__super__.constructor.apply(this, arguments);
780
- }
781
-
782
- return NetworkError;
783
- }(Error));
784
-
785
- XMLHttpRequest.SyntaxError = SyntaxError;
786
-
787
- SyntaxError = (function (superClass) {
788
- extend(SyntaxError, superClass);
789
-
790
- function SyntaxError() {
791
- SyntaxError.__super__.constructor.apply(this, arguments);
792
- }
793
-
794
- return SyntaxError;
795
- }(Error));
796
-
797
- ProgressEvent = (function () {
798
- function ProgressEvent(type) {
799
- this.type = type;
800
- this.target = null;
801
- this.currentTarget = null;
802
- this.lengthComputable = false;
803
- this.loaded = 0;
804
- this.total = 0;
805
- }
806
-
807
- ProgressEvent.prototype.bubbles = false;
808
-
809
- ProgressEvent.prototype.cancelable = false;
810
-
811
- ProgressEvent.prototype.target = null;
812
-
813
- ProgressEvent.prototype.loaded = null;
814
-
815
- ProgressEvent.prototype.lengthComputable = null;
816
-
817
- ProgressEvent.prototype.total = null;
818
-
819
- return ProgressEvent;
820
- }());
821
-
822
- XMLHttpRequest.ProgressEvent = ProgressEvent;
823
-
824
- XMLHttpRequestUpload = (function (superClass) {
825
- extend(XMLHttpRequestUpload, superClass);
826
-
827
- function XMLHttpRequestUpload(request) {
828
- XMLHttpRequestUpload.__super__.constructor.call(this);
829
- this._request = request;
830
- this._reset();
831
- }
832
-
833
- XMLHttpRequestUpload.prototype._reset = function () {
834
- this._contentType = null;
835
- this._body = null;
836
- return void 0;
837
- };
838
-
839
- XMLHttpRequestUpload.prototype._setData = function (data) {
840
- let body; let i; let j; let k; let offset; let ref; let ref1; let
841
- view;
842
- if (typeof data === 'undefined' || data === null) {
843
- return;
844
- }
845
- if (typeof data === 'string') {
846
- if (data.length !== 0) {
847
- this._contentType = 'text/plain;charset=UTF-8';
848
- }
849
- this._body = Buffer.from(data, 'utf8');
850
- } else if (Buffer.isBuffer(data)) {
851
- this._body = data;
852
- } else if (data instanceof ArrayBuffer) {
853
- body = Buffer.alloc(data.byteLength);
854
- view = new Uint8Array(data);
855
- for (i = j = 0, ref = data.byteLength; ref >= 0 ? j < ref : j > ref; i = ref >= 0 ? ++j : --j) {
856
- body[i] = view[i];
857
- }
858
- this._body = body;
859
- } else if (data.buffer && data.buffer instanceof ArrayBuffer) {
860
- body = Buffer.alloc(data.byteLength);
861
- offset = data.byteOffset;
862
- view = new Uint8Array(data.buffer);
863
- for (i = k = 0, ref1 = data.byteLength; ref1 >= 0 ? k < ref1 : k > ref1; i = ref1 >= 0 ? ++k : --k) {
864
- body[i] = view[i + offset];
865
- }
866
- this._body = body;
867
- } else if (typeof data === 'object' && data instanceof FormData) {
868
- this._body = null;
869
- } else {
870
- throw new Error(`Unsupported send() data ${data}`);
871
- }
872
- return void 0;
873
- };
874
-
875
- XMLHttpRequestUpload.prototype._finalizeHeaders = function (headers, loweredHeaders) {
876
- if (this._contentType && !('content-type' in loweredHeaders)) {
877
- headers['Content-Type'] = this._contentType;
878
- }
879
- if (this._body) {
880
- headers['Content-Length'] = this._body.length.toString();
881
- }
882
- return void 0;
883
- };
884
-
885
- XMLHttpRequestUpload.prototype._startUpload = function (request) {
886
- if (this._body) {
887
- request.write(this._body);
888
- }
889
- request.end();
890
- return void 0;
891
- };
892
-
893
- return XMLHttpRequestUpload;
894
- }(XMLHttpRequestEventTarget));
895
-
896
- XMLHttpRequest.XMLHttpRequestUpload = XMLHttpRequestUpload;
897
- }).call(this);