artifact-engine 2.273.0 → 2.279.1

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 (45) hide show
  1. package/Providers/filesystemProvider.js +17 -1
  2. package/Providers/jenkins.handlebars +10 -10
  3. package/Providers/teamcity.handlebars +24 -24
  4. package/Providers/vsts.handlebars +15 -15
  5. package/Providers/webClient.d.ts +1 -1
  6. package/Providers/webClient.js +1 -1
  7. package/Providers/webClientFactory.js +7 -7
  8. package/Providers/webProvider.d.ts +7 -1
  9. package/Providers/webProvider.js +5 -0
  10. package/Providers/zipProvider.d.ts +1 -1
  11. package/README.md +40 -39
  12. package/Strings/resources.resjson/de-DE/resources.resjson +12 -11
  13. package/Strings/resources.resjson/en-US/resources.resjson +12 -11
  14. package/Strings/resources.resjson/es-ES/resources.resjson +12 -11
  15. package/Strings/resources.resjson/fr-FR/resources.resjson +12 -11
  16. package/Strings/resources.resjson/it-IT/resources.resjson +12 -11
  17. package/Strings/resources.resjson/ja-JP/resources.resjson +12 -11
  18. package/Strings/resources.resjson/ko-KR/resources.resjson +12 -11
  19. package/Strings/resources.resjson/ru-RU/resources.resjson +12 -11
  20. package/Strings/resources.resjson/zh-CN/resources.resjson +12 -11
  21. package/Strings/resources.resjson/zh-TW/resources.resjson +12 -11
  22. package/ThirdPartyNotices.txt +925 -925
  23. package/lib.json +14 -13
  24. package/package.json +62 -64
  25. package/Providers/typed-rest-client/Handlers.d.ts +0 -4
  26. package/Providers/typed-rest-client/Handlers.js +0 -11
  27. package/Providers/typed-rest-client/HttpClient.d.ts +0 -87
  28. package/Providers/typed-rest-client/HttpClient.js +0 -353
  29. package/Providers/typed-rest-client/Index.d.ts +0 -1
  30. package/Providers/typed-rest-client/Index.js +0 -2
  31. package/Providers/typed-rest-client/Interfaces.d.ts +0 -39
  32. package/Providers/typed-rest-client/Interfaces.js +0 -3
  33. package/Providers/typed-rest-client/RestClient.d.ts +0 -74
  34. package/Providers/typed-rest-client/RestClient.js +0 -188
  35. package/Providers/typed-rest-client/Util.d.ts +0 -7
  36. package/Providers/typed-rest-client/Util.js +0 -25
  37. package/Providers/typed-rest-client/handlers/basiccreds.d.ts +0 -9
  38. package/Providers/typed-rest-client/handlers/basiccreds.js +0 -24
  39. package/Providers/typed-rest-client/handlers/bearertoken.d.ts +0 -8
  40. package/Providers/typed-rest-client/handlers/bearertoken.js +0 -23
  41. package/Providers/typed-rest-client/handlers/ntlm.d.ts +0 -13
  42. package/Providers/typed-rest-client/handlers/ntlm.js +0 -127
  43. package/Providers/typed-rest-client/handlers/personalaccesstoken.d.ts +0 -8
  44. package/Providers/typed-rest-client/handlers/personalaccesstoken.js +0 -23
  45. package/Providers/typed-rest-client/opensource/node-http-ntlm/ntlm.js +0 -386
package/lib.json CHANGED
@@ -1,14 +1,15 @@
1
- {
2
- "messages": {
3
- "DownloadSummary": "Total Files: %s, Processed: %s, Skipped: %s, Failed: %s, Download time: %s secs, Download size: %s",
4
- "FailedToParseResponse": "Failed to parse response body: %s, got error : %s",
5
- "DownloadingTo": "Downloading %s to %s",
6
- "DownloadedTo": "Downloaded %s to %s",
7
- "UnableToReadDirectory": "Unable to read directory %s. Error: %s",
8
- "RetryingDownload": "Retrying download of %s, retry count: %s",
9
- "SkippingItem": "Skipped processing item %s",
10
- "UnhandledRejection": "artifact-engine-v2: unhandled rejection %s",
11
- "UnhandledException": "artifact-engine-v2: unhandled exception %s",
12
- "FailedRequest": "Failed request: (statusCode)"
13
- }
1
+ {
2
+ "messages": {
3
+ "DownloadSummary": "Total Files: %s, Processed: %s, Skipped: %s, Failed: %s, Download time: %s secs, Download size: %s",
4
+ "FailedToParseResponse": "Failed to parse response body: %s, got error : %s",
5
+ "DownloadingTo": "Downloading %s to %s",
6
+ "DownloadedTo": "Downloaded %s to %s",
7
+ "InvalidArtifactPath": "Artifact path %s resolves outside the download directory.",
8
+ "UnableToReadDirectory": "Unable to read directory %s. Error: %s",
9
+ "RetryingDownload": "Retrying download of %s, retry count: %s",
10
+ "SkippingItem": "Skipped processing item %s",
11
+ "UnhandledRejection": "artifact-engine-v2: unhandled rejection %s",
12
+ "UnhandledException": "artifact-engine-v2: unhandled exception %s",
13
+ "FailedRequest": "Failed request: (statusCode)"
14
+ }
14
15
  }
package/package.json CHANGED
@@ -1,64 +1,62 @@
1
- {
2
- "name": "artifact-engine",
3
- "version": "2.273.0",
4
- "description": "Artifact Engine to download artifacts from jenkins, teamcity, vsts",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/Microsoft/azure-pipelines-extensions/tree/master/Extensions/ArtifactEngineV2"
8
- },
9
- "keywords": [
10
- "artifact"
11
- ],
12
- "license": "MIT",
13
- "main": "",
14
- "author": {
15
- "name": "omeshp",
16
- "email": "omeshp@microsoft.com"
17
- },
18
- "dependencies": {
19
- "azure-pipelines-task-lib": "^5.2.8",
20
- "handlebars": "4.7.9",
21
- "hash-wasm": "^4.12.0",
22
- "minimatch": "^10.0.1",
23
- "tunnel": "0.0.4"
24
- },
25
- "overrides": {
26
- "picomatch": "2.3.2"
27
- },
28
- "devDependencies": {
29
- "@types/minimatch": "^5.1.2",
30
- "@types/mocha": "^10.0.10",
31
- "@types/node": "^22.10.5",
32
- "@types/xml2js": "^0.4.8",
33
- "assert": "1.4.1",
34
- "mocha": "^11.7.5",
35
- "mocha-tap-reporter": "0.1.3",
36
- "nconf": "^0.12.0",
37
- "nock": "^13.5.6",
38
- "nyc": "^17.1.0",
39
- "sinon": "^19.0.2",
40
- "typescript": "^5.7.2",
41
- "xml2js": "^0.6.2"
42
- },
43
- "files": [
44
- "Engine/**/*.js",
45
- "Models/**/*.js",
46
- "Store/**/*.js",
47
- "Providers/**/*.js",
48
- "Providers/*.handlebars",
49
- "Engine/**/*.d.ts",
50
- "Models/**/*.d.ts",
51
- "Store/**/*.d.ts",
52
- "Providers/**/*d.ts",
53
- "LICENSE",
54
- "README.md",
55
- "ThirdPartyNotices.txt",
56
- "lib.json",
57
- "Strings/**"
58
- ],
59
- "scripts": {
60
- "test": "mocha",
61
- "test:coverage": "nyc mocha",
62
- "build": "tsc"
63
- }
64
- }
1
+ {
2
+ "name": "artifact-engine",
3
+ "version": "2.279.1",
4
+ "description": "Artifact Engine to download artifacts from jenkins, teamcity, vsts",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/Microsoft/azure-pipelines-extensions/tree/master/Extensions/ArtifactEngineV2"
8
+ },
9
+ "keywords": [
10
+ "artifact"
11
+ ],
12
+ "license": "MIT",
13
+ "main": "",
14
+ "author": {
15
+ "name": "omeshp",
16
+ "email": "omeshp@microsoft.com"
17
+ },
18
+ "dependencies": {
19
+ "azure-pipelines-task-lib": "^5.278.0",
20
+ "handlebars": "4.7.9",
21
+ "typed-rest-client": "^3.0.0"
22
+ },
23
+ "overrides": {
24
+ "picomatch": "2.3.2"
25
+ },
26
+ "devDependencies": {
27
+ "@types/minimatch": "^5.1.2",
28
+ "@types/mocha": "^10.0.10",
29
+ "@types/node": "^22.10.5",
30
+ "@types/xml2js": "^0.4.8",
31
+ "assert": "1.4.1",
32
+ "mocha": "^11.7.5",
33
+ "mocha-tap-reporter": "0.1.3",
34
+ "nconf": "^0.12.0",
35
+ "nock": "^13.5.6",
36
+ "nyc": "^17.1.0",
37
+ "sinon": "^19.0.2",
38
+ "typescript": "^5.7.2",
39
+ "xml2js": "^0.6.2"
40
+ },
41
+ "files": [
42
+ "Engine/**/*.js",
43
+ "Models/**/*.js",
44
+ "Store/**/*.js",
45
+ "Providers/**/*.js",
46
+ "Providers/*.handlebars",
47
+ "Engine/**/*.d.ts",
48
+ "Models/**/*.d.ts",
49
+ "Store/**/*.d.ts",
50
+ "Providers/**/*d.ts",
51
+ "LICENSE",
52
+ "README.md",
53
+ "ThirdPartyNotices.txt",
54
+ "lib.json",
55
+ "Strings/**"
56
+ ],
57
+ "scripts": {
58
+ "test": "mocha",
59
+ "test:coverage": "nyc mocha",
60
+ "build": "tsc"
61
+ }
62
+ }
@@ -1,4 +0,0 @@
1
- export { BasicCredentialHandler } from "./handlers/basiccreds";
2
- export { BearerCredentialHandler } from "./handlers/bearertoken";
3
- export { NtlmCredentialHandler } from "./handlers/ntlm";
4
- export { PersonalAccessTokenCredentialHandler } from "./handlers/personalaccesstoken";
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PersonalAccessTokenCredentialHandler = exports.NtlmCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0;
4
- var basiccreds_1 = require("./handlers/basiccreds");
5
- Object.defineProperty(exports, "BasicCredentialHandler", { enumerable: true, get: function () { return basiccreds_1.BasicCredentialHandler; } });
6
- var bearertoken_1 = require("./handlers/bearertoken");
7
- Object.defineProperty(exports, "BearerCredentialHandler", { enumerable: true, get: function () { return bearertoken_1.BearerCredentialHandler; } });
8
- var ntlm_1 = require("./handlers/ntlm");
9
- Object.defineProperty(exports, "NtlmCredentialHandler", { enumerable: true, get: function () { return ntlm_1.NtlmCredentialHandler; } });
10
- var personalaccesstoken_1 = require("./handlers/personalaccesstoken");
11
- Object.defineProperty(exports, "PersonalAccessTokenCredentialHandler", { enumerable: true, get: function () { return personalaccesstoken_1.PersonalAccessTokenCredentialHandler; } });
@@ -1,87 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import url = require("url");
5
- import http = require("http");
6
- import ifm = require('./Interfaces');
7
- export declare enum HttpCodes {
8
- OK = 200,
9
- MultipleChoices = 300,
10
- MovedPermanently = 301,
11
- ResourceMoved = 302,
12
- NotModified = 304,
13
- UseProxy = 305,
14
- SwitchProxy = 306,
15
- TemporaryRedirect = 307,
16
- PermanentRedirect = 308,
17
- BadRequest = 400,
18
- Unauthorized = 401,
19
- PaymentRequired = 402,
20
- Forbidden = 403,
21
- NotFound = 404,
22
- MethodNotAllowed = 405,
23
- NotAcceptable = 406,
24
- ProxyAuthenticationRequired = 407,
25
- RequestTimeout = 408,
26
- Conflict = 409,
27
- Gone = 410,
28
- InternalServerError = 500,
29
- NotImplemented = 501,
30
- BadGateway = 502,
31
- ServiceUnavailable = 503,
32
- GatewayTimeout = 504
33
- }
34
- export declare class HttpClientResponse {
35
- constructor(message: http.IncomingMessage);
36
- message: http.IncomingMessage;
37
- readBody(): Promise<string>;
38
- }
39
- export interface RequestInfo {
40
- options: http.RequestOptions;
41
- parsedUrl: url.Url;
42
- httpModule: any;
43
- }
44
- export declare function isHttps(requestUrl: string): boolean;
45
- export declare class HttpClient {
46
- userAgent: string;
47
- handlers: ifm.IRequestHandler[];
48
- requestOptions: ifm.IRequestOptions;
49
- private _ignoreSslError;
50
- private _socketTimeout;
51
- private _httpProxy;
52
- private _httpProxyBypassHosts;
53
- private _allowRedirects;
54
- private _maxRedirects;
55
- private _agent;
56
- private _proxyAgent;
57
- private _keepAlive;
58
- private _disposed;
59
- private _certConfig;
60
- private _ca;
61
- private _cert;
62
- private _key;
63
- constructor(userAgent: string, handlers?: ifm.IRequestHandler[], requestOptions?: ifm.IRequestOptions);
64
- options(requestUrl: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
65
- get(requestUrl: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
66
- del(requestUrl: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
67
- post(requestUrl: string, data: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
68
- patch(requestUrl: string, data: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
69
- put(requestUrl: string, data: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
70
- head(requestUrl: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
71
- sendStream(verb: string, requestUrl: string, stream: NodeJS.ReadableStream, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
72
- /**
73
- * Makes a raw http request.
74
- * All other methods such as get, post, patch, and request ultimately call this.
75
- * Prefer get, del, post and patch
76
- */
77
- request(verb: string, requestUrl: string, data: string | NodeJS.ReadableStream, headers: ifm.IHeaders): Promise<HttpClientResponse>;
78
- /**
79
- * Needs to be called if keepAlive is set to true in request options.
80
- */
81
- dispose(): void;
82
- private _requestRaw;
83
- private _prepareRequest;
84
- private _getAgent;
85
- private _getProxy;
86
- private _isBypassProxy;
87
- }
@@ -1,353 +0,0 @@
1
- "use strict";
2
- // Copyright (c) Microsoft. All rights reserved.
3
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
4
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
- return new (P || (P = Promise))(function (resolve, reject) {
7
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
- step((generator = generator.apply(thisArg, _arguments || [])).next());
11
- });
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpCodes = void 0;
15
- const url = require("url");
16
- const http = require("http");
17
- const https = require("https");
18
- var tunnel = require("tunnel");
19
- const fs = require("fs");
20
- var HttpCodes;
21
- (function (HttpCodes) {
22
- HttpCodes[HttpCodes["OK"] = 200] = "OK";
23
- HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
24
- HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
25
- HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
26
- HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
27
- HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
28
- HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
29
- HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
30
- HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
31
- HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
32
- HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
33
- HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
34
- HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
35
- HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
36
- HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
37
- HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
38
- HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
39
- HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
40
- HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
41
- HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
42
- HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
43
- HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
44
- HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
45
- HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
46
- HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
47
- })(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));
48
- const HttpRedirectCodes = [HttpCodes.MovedPermanently, HttpCodes.ResourceMoved, HttpCodes.TemporaryRedirect, HttpCodes.PermanentRedirect];
49
- class HttpClientResponse {
50
- constructor(message) {
51
- this.message = message;
52
- }
53
- readBody() {
54
- return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
55
- let output = '';
56
- this.message.on('data', (chunk) => {
57
- output += chunk;
58
- });
59
- this.message.on('end', () => {
60
- resolve(output);
61
- });
62
- }));
63
- }
64
- }
65
- exports.HttpClientResponse = HttpClientResponse;
66
- function isHttps(requestUrl) {
67
- let parsedUrl = url.parse(requestUrl);
68
- return parsedUrl.protocol === 'https:';
69
- }
70
- exports.isHttps = isHttps;
71
- var EnvironmentVariables;
72
- (function (EnvironmentVariables) {
73
- EnvironmentVariables[EnvironmentVariables["HTTP_PROXY"] = "HTTP_PROXY"] = "HTTP_PROXY";
74
- EnvironmentVariables[EnvironmentVariables["HTTPS_PROXY"] = "HTTPS_PROXY"] = "HTTPS_PROXY";
75
- })(EnvironmentVariables || (EnvironmentVariables = {}));
76
- class HttpClient {
77
- constructor(userAgent, handlers, requestOptions) {
78
- this._ignoreSslError = false;
79
- this._allowRedirects = true;
80
- this._maxRedirects = 50;
81
- this._keepAlive = false;
82
- this._disposed = false;
83
- this.userAgent = userAgent;
84
- this.handlers = handlers;
85
- this.requestOptions = requestOptions;
86
- if (requestOptions) {
87
- if (requestOptions.ignoreSslError != null) {
88
- this._ignoreSslError = requestOptions.ignoreSslError;
89
- }
90
- this._socketTimeout = requestOptions.socketTimeout;
91
- this._httpProxy = requestOptions.proxy;
92
- if (requestOptions.proxy && requestOptions.proxy.proxyBypassHosts) {
93
- this._httpProxyBypassHosts = [];
94
- requestOptions.proxy.proxyBypassHosts.forEach(bypass => {
95
- this._httpProxyBypassHosts.push(new RegExp(bypass, 'i'));
96
- });
97
- }
98
- this._certConfig = requestOptions.cert;
99
- // cache the cert content into memory, so we don't have to read it from disk every time
100
- if (this._certConfig && this._certConfig.caFile && fs.existsSync(this._certConfig.caFile)) {
101
- this._ca = fs.readFileSync(this._certConfig.caFile, 'utf8');
102
- }
103
- if (this._certConfig && this._certConfig.certFile && fs.existsSync(this._certConfig.certFile)) {
104
- this._cert = fs.readFileSync(this._certConfig.certFile, 'utf8');
105
- }
106
- if (this._certConfig && this._certConfig.keyFile && fs.existsSync(this._certConfig.keyFile)) {
107
- this._key = fs.readFileSync(this._certConfig.keyFile, 'utf8');
108
- }
109
- if (requestOptions.allowRedirects != null) {
110
- this._allowRedirects = requestOptions.allowRedirects;
111
- }
112
- if (requestOptions.maxRedirects != null) {
113
- this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
114
- }
115
- if (requestOptions.keepAlive != null) {
116
- this._keepAlive = requestOptions.keepAlive;
117
- }
118
- }
119
- }
120
- options(requestUrl, additionalHeaders) {
121
- return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
122
- }
123
- get(requestUrl, additionalHeaders) {
124
- return this.request('GET', requestUrl, null, additionalHeaders || {});
125
- }
126
- del(requestUrl, additionalHeaders) {
127
- return this.request('DELETE', requestUrl, null, additionalHeaders || {});
128
- }
129
- post(requestUrl, data, additionalHeaders) {
130
- return this.request('POST', requestUrl, data, additionalHeaders || {});
131
- }
132
- patch(requestUrl, data, additionalHeaders) {
133
- return this.request('PATCH', requestUrl, data, additionalHeaders || {});
134
- }
135
- put(requestUrl, data, additionalHeaders) {
136
- return this.request('PUT', requestUrl, data, additionalHeaders || {});
137
- }
138
- head(requestUrl, additionalHeaders) {
139
- return this.request('HEAD', requestUrl, null, additionalHeaders || {});
140
- }
141
- sendStream(verb, requestUrl, stream, additionalHeaders) {
142
- return this.request(verb, requestUrl, stream, additionalHeaders);
143
- }
144
- /**
145
- * Makes a raw http request.
146
- * All other methods such as get, post, patch, and request ultimately call this.
147
- * Prefer get, del, post and patch
148
- */
149
- request(verb, requestUrl, data, headers) {
150
- return __awaiter(this, void 0, void 0, function* () {
151
- if (this._disposed) {
152
- throw new Error("Client has already been disposed");
153
- }
154
- let info = this._prepareRequest(verb, requestUrl, headers);
155
- let response = yield this._requestRaw(info, data);
156
- let redirectsRemaining = this._maxRedirects;
157
- while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1
158
- && this._allowRedirects
159
- && redirectsRemaining > 0) {
160
- const redirectUrl = response.message.headers["location"];
161
- if (!redirectUrl) {
162
- // if there's no location to redirect to, we won't
163
- break;
164
- }
165
- // we need to finish reading the response before reassigning response
166
- // which will leak the open socket.
167
- yield response.readBody();
168
- // let's make the request with the new redirectUrl
169
- info = this._prepareRequest(verb, redirectUrl, headers);
170
- response = yield this._requestRaw(info, data);
171
- redirectsRemaining--;
172
- }
173
- return response;
174
- });
175
- }
176
- /**
177
- * Needs to be called if keepAlive is set to true in request options.
178
- */
179
- dispose() {
180
- if (this._agent) {
181
- this._agent.destroy();
182
- }
183
- this._disposed = true;
184
- }
185
- _requestRaw(info, data) {
186
- return new Promise((resolve, reject) => {
187
- let socket;
188
- let isDataString = typeof (data) === 'string';
189
- if (typeof (data) === 'string') {
190
- info.options.headers["Content-Length"] = Buffer.byteLength(data, 'utf8');
191
- }
192
- let req = info.httpModule.request(info.options, (msg) => {
193
- let res = new HttpClientResponse(msg);
194
- resolve(res);
195
- });
196
- req.on('socket', (sock) => {
197
- socket = sock;
198
- });
199
- // If we ever get disconnected, we want the socket to timeout eventually
200
- req.setTimeout(this._socketTimeout || 3 * 60000, () => {
201
- if (socket) {
202
- socket.end();
203
- }
204
- reject(new Error('Request timeout: ' + info.options.path));
205
- });
206
- req.on('error', function (err) {
207
- // err has statusCode property
208
- // res should have headers
209
- reject(err);
210
- });
211
- if (data && typeof (data) === 'string') {
212
- req.write(data, 'utf8');
213
- }
214
- if (data && typeof (data) !== 'string') {
215
- data.on('close', function () {
216
- req.end();
217
- });
218
- data.pipe(req);
219
- }
220
- else {
221
- req.end();
222
- }
223
- });
224
- }
225
- _prepareRequest(method, requestUrl, headers) {
226
- let info = {};
227
- info.parsedUrl = url.parse(requestUrl);
228
- let usingSsl = info.parsedUrl.protocol === 'https:';
229
- info.httpModule = usingSsl ? https : http;
230
- var defaultPort = usingSsl ? 443 : 80;
231
- info.options = {};
232
- info.options.host = info.parsedUrl.hostname;
233
- info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort;
234
- info.options.path = (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
235
- info.options.method = method;
236
- info.options.headers = headers || {};
237
- info.options.headers["User-Agent"] = this.userAgent;
238
- info.options.agent = this._getAgent(requestUrl);
239
- // gives handlers an opportunity to participate
240
- if (this.handlers) {
241
- this.handlers.forEach((handler) => {
242
- handler.prepareRequest(info.options);
243
- });
244
- }
245
- return info;
246
- }
247
- _getAgent(requestUrl) {
248
- let agent;
249
- let proxy = this._getProxy(requestUrl);
250
- let useProxy = proxy.proxyUrl && proxy.proxyUrl.hostname && !this._isBypassProxy(requestUrl);
251
- if (this._keepAlive && useProxy) {
252
- agent = this._proxyAgent;
253
- }
254
- if (this._keepAlive && !useProxy) {
255
- agent = this._agent;
256
- }
257
- // if agent is already assigned use that agent.
258
- if (!!agent) {
259
- return agent;
260
- }
261
- var parsedUrl = url.parse(requestUrl);
262
- let usingSsl = parsedUrl.protocol === 'https:';
263
- let maxSockets = 100;
264
- if (!!this.requestOptions) {
265
- maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
266
- }
267
- if (useProxy) {
268
- var agentOptions = {
269
- maxSockets: maxSockets,
270
- keepAlive: this._keepAlive,
271
- proxy: {
272
- proxyAuth: proxy.proxyAuth,
273
- host: proxy.proxyUrl.hostname,
274
- port: proxy.proxyUrl.port
275
- },
276
- };
277
- var tunnelAgent;
278
- var overHttps = proxy.proxyUrl.protocol === 'https:';
279
- if (usingSsl) {
280
- tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
281
- }
282
- else {
283
- tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
284
- }
285
- agent = tunnelAgent(agentOptions);
286
- this._proxyAgent = agent;
287
- }
288
- // if reusing agent across request and tunneling agent isn't assigned create a new agent
289
- if (this._keepAlive && !agent) {
290
- var options = { keepAlive: this._keepAlive, maxSockets: maxSockets };
291
- agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
292
- this._agent = agent;
293
- }
294
- // if not using private agent and tunnel agent isn't setup then use global agent
295
- if (!agent) {
296
- agent = usingSsl ? https.globalAgent : http.globalAgent;
297
- }
298
- if (usingSsl && this._ignoreSslError) {
299
- // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
300
- // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
301
- // we have to cast it to any and change it directly
302
- agent.options = Object.assign(agent.options || {}, { rejectUnauthorized: false });
303
- }
304
- if (usingSsl && this._certConfig) {
305
- agent.options = Object.assign(agent.options || {}, { ca: this._ca, cert: this._cert, key: this._key, passphrase: this._certConfig.passphrase });
306
- }
307
- return agent;
308
- }
309
- _getProxy(requestUrl) {
310
- var parsedUrl = url.parse(requestUrl);
311
- let usingSsl = parsedUrl.protocol === 'https:';
312
- let proxyConfig = this._httpProxy;
313
- // fallback to http_proxy and https_proxy env
314
- let https_proxy = process.env[EnvironmentVariables.HTTPS_PROXY];
315
- let http_proxy = process.env[EnvironmentVariables.HTTP_PROXY];
316
- if (!proxyConfig) {
317
- if (https_proxy && usingSsl) {
318
- proxyConfig = {
319
- proxyUrl: https_proxy
320
- };
321
- }
322
- else if (http_proxy) {
323
- proxyConfig = {
324
- proxyUrl: http_proxy
325
- };
326
- }
327
- }
328
- let proxyUrl;
329
- let proxyAuth;
330
- if (proxyConfig) {
331
- if (proxyConfig.proxyUrl.length > 0) {
332
- proxyUrl = url.parse(proxyConfig.proxyUrl);
333
- }
334
- if (proxyConfig.proxyUsername || proxyConfig.proxyPassword) {
335
- proxyAuth = proxyConfig.proxyUsername + ":" + proxyConfig.proxyPassword;
336
- }
337
- }
338
- return { proxyUrl: proxyUrl, proxyAuth: proxyAuth };
339
- }
340
- _isBypassProxy(requestUrl) {
341
- if (!this._httpProxyBypassHosts) {
342
- return false;
343
- }
344
- let bypass = false;
345
- this._httpProxyBypassHosts.forEach(bypassHost => {
346
- if (bypassHost.test(requestUrl)) {
347
- bypass = true;
348
- }
349
- });
350
- return bypass;
351
- }
352
- }
353
- exports.HttpClient = HttpClient;
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,39 +0,0 @@
1
- export interface IHeaders {
2
- [key: string]: any;
3
- }
4
- export interface IBasicCredentials {
5
- username: string;
6
- password: string;
7
- }
8
- export interface IRequestHandler {
9
- prepareRequest(options: any): void;
10
- canHandleAuthentication(res: IHttpResponse): boolean;
11
- handleAuthentication(httpClient: any, protocol: any, options: any, objs: any, finalCallback: any): void;
12
- }
13
- export interface IHttpResponse {
14
- statusCode?: number;
15
- headers: any;
16
- }
17
- export interface IRequestOptions {
18
- socketTimeout?: number;
19
- ignoreSslError?: boolean;
20
- proxy?: IProxyConfiguration;
21
- cert?: ICertConfiguration;
22
- allowRedirects?: boolean;
23
- maxRedirects?: number;
24
- maxSockets?: number;
25
- keepAlive?: boolean;
26
- requestCompressionForDownloads?: boolean;
27
- }
28
- export interface IProxyConfiguration {
29
- proxyUrl: string;
30
- proxyUsername?: string;
31
- proxyPassword?: string;
32
- proxyBypassHosts?: string[];
33
- }
34
- export interface ICertConfiguration {
35
- caFile?: string;
36
- certFile?: string;
37
- keyFile?: string;
38
- passphrase?: string;
39
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- ;