artifact-engine 2.275.2 → 2.279.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Engine/artifactEngine.js +4 -2
- package/Engine/artifactEngineOptions.js +0 -1
- package/Engine/cilogger.js +2 -2
- package/Engine/index.js +0 -1
- package/Engine/logger.js +0 -1
- package/Engine/worker.js +0 -1
- package/Models/artifactDownloadTicket.js +0 -1
- package/Models/artifactItem.js +0 -1
- package/Models/artifactprovider.d.ts +1 -0
- package/Models/artifactprovider.js +0 -1
- package/Models/constants.js +0 -1
- package/Models/index.js +0 -1
- package/Models/itemType.js +1 -2
- package/Models/ticketState.js +1 -2
- package/Providers/filesystemProvider.d.ts +1 -0
- package/Providers/filesystemProvider.js +19 -2
- package/Providers/index.js +0 -1
- package/Providers/jenkins.handlebars +10 -10
- package/Providers/stubProvider.d.ts +1 -0
- package/Providers/stubProvider.js +0 -1
- package/Providers/teamcity.handlebars +24 -24
- package/Providers/vsts.handlebars +15 -15
- package/Providers/webClient.d.ts +1 -1
- package/Providers/webClient.js +4 -2
- package/Providers/webClientFactory.js +7 -1
- package/Providers/webProvider.d.ts +8 -1
- package/Providers/webProvider.js +0 -1
- package/Providers/zipProvider.d.ts +2 -1
- package/Providers/zipProvider.js +0 -1
- package/README.md +40 -39
- package/Store/artifactItemStore.js +0 -1
- package/Store/index.js +0 -1
- package/Strings/resources.resjson/de-DE/resources.resjson +12 -11
- package/Strings/resources.resjson/en-US/resources.resjson +12 -11
- package/Strings/resources.resjson/es-ES/resources.resjson +12 -11
- package/Strings/resources.resjson/fr-FR/resources.resjson +12 -11
- package/Strings/resources.resjson/it-IT/resources.resjson +12 -11
- package/Strings/resources.resjson/ja-JP/resources.resjson +12 -11
- package/Strings/resources.resjson/ko-KR/resources.resjson +12 -11
- package/Strings/resources.resjson/ru-RU/resources.resjson +12 -11
- package/Strings/resources.resjson/zh-CN/resources.resjson +12 -11
- package/Strings/resources.resjson/zh-TW/resources.resjson +12 -11
- package/ThirdPartyNotices.txt +925 -925
- package/lib.json +14 -13
- package/package.json +62 -64
- package/Providers/typed-rest-client/Handlers.d.ts +0 -4
- package/Providers/typed-rest-client/Handlers.js +0 -12
- package/Providers/typed-rest-client/HttpClient.d.ts +0 -76
- package/Providers/typed-rest-client/HttpClient.js +0 -328
- package/Providers/typed-rest-client/Index.d.ts +0 -1
- package/Providers/typed-rest-client/Index.js +0 -3
- package/Providers/typed-rest-client/Interfaces.d.ts +0 -39
- package/Providers/typed-rest-client/Interfaces.js +0 -4
- package/Providers/typed-rest-client/RestClient.d.ts +0 -26
- package/Providers/typed-rest-client/RestClient.js +0 -134
- package/Providers/typed-rest-client/Util.d.ts +0 -1
- package/Providers/typed-rest-client/Util.js +0 -17
- package/Providers/typed-rest-client/handlers/basiccreds.d.ts +0 -9
- package/Providers/typed-rest-client/handlers/basiccreds.js +0 -20
- package/Providers/typed-rest-client/handlers/bearertoken.d.ts +0 -8
- package/Providers/typed-rest-client/handlers/bearertoken.js +0 -19
- package/Providers/typed-rest-client/handlers/ntlm.d.ts +0 -13
- package/Providers/typed-rest-client/handlers/ntlm.js +0 -107
- package/Providers/typed-rest-client/handlers/personalaccesstoken.d.ts +0 -8
- package/Providers/typed-rest-client/handlers/personalaccesstoken.js +0 -19
- 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
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
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.
|
|
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.
|
|
20
|
-
"handlebars": "4.7.9",
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"@types/
|
|
30
|
-
"@types/
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "artifact-engine",
|
|
3
|
+
"version": "2.279.2",
|
|
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,12 +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; } });
|
|
12
|
-
//# sourceMappingURL=Handlers.js.map
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import url = require("url");
|
|
2
|
-
import http = require("http");
|
|
3
|
-
import ifm = require('./Interfaces');
|
|
4
|
-
export declare enum HttpCodes {
|
|
5
|
-
OK = 200,
|
|
6
|
-
MultipleChoices = 300,
|
|
7
|
-
MovedPermanently = 301,
|
|
8
|
-
ResourceMoved = 302,
|
|
9
|
-
NotModified = 304,
|
|
10
|
-
UseProxy = 305,
|
|
11
|
-
SwitchProxy = 306,
|
|
12
|
-
TemporaryRedirect = 307,
|
|
13
|
-
PermanentRedirect = 308,
|
|
14
|
-
BadRequest = 400,
|
|
15
|
-
Unauthorized = 401,
|
|
16
|
-
PaymentRequired = 402,
|
|
17
|
-
Forbidden = 403,
|
|
18
|
-
NotFound = 404,
|
|
19
|
-
MethodNotAllowed = 405,
|
|
20
|
-
NotAcceptable = 406,
|
|
21
|
-
ProxyAuthenticationRequired = 407,
|
|
22
|
-
RequestTimeout = 408,
|
|
23
|
-
Conflict = 409,
|
|
24
|
-
Gone = 410,
|
|
25
|
-
InternalServerError = 500,
|
|
26
|
-
NotImplemented = 501,
|
|
27
|
-
BadGateway = 502,
|
|
28
|
-
ServiceUnavailable = 503,
|
|
29
|
-
GatewayTimeout = 504
|
|
30
|
-
}
|
|
31
|
-
export declare class HttpClientResponse {
|
|
32
|
-
constructor(message: http.IncomingMessage);
|
|
33
|
-
message: http.IncomingMessage;
|
|
34
|
-
readBody(): Promise<string>;
|
|
35
|
-
}
|
|
36
|
-
export interface RequestInfo {
|
|
37
|
-
options: http.RequestOptions;
|
|
38
|
-
parsedUrl: url.Url;
|
|
39
|
-
httpModule: any;
|
|
40
|
-
}
|
|
41
|
-
export declare function isHttps(requestUrl: string): boolean;
|
|
42
|
-
export declare class HttpClient {
|
|
43
|
-
userAgent: string;
|
|
44
|
-
handlers: ifm.IRequestHandler[];
|
|
45
|
-
requestOptions: ifm.IRequestOptions;
|
|
46
|
-
private _ignoreSslError;
|
|
47
|
-
private _socketTimeout;
|
|
48
|
-
private _httpProxy;
|
|
49
|
-
private _httpProxyBypassHosts;
|
|
50
|
-
private _allowRedirects;
|
|
51
|
-
private _maxRedirects;
|
|
52
|
-
private _agent;
|
|
53
|
-
private _proxyAgent;
|
|
54
|
-
private _keepAlive;
|
|
55
|
-
private _disposed;
|
|
56
|
-
private _certConfig;
|
|
57
|
-
private _ca;
|
|
58
|
-
private _cert;
|
|
59
|
-
private _key;
|
|
60
|
-
constructor(userAgent: string, handlers?: ifm.IRequestHandler[], requestOptions?: ifm.IRequestOptions);
|
|
61
|
-
options(requestUrl: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
|
|
62
|
-
get(requestUrl: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
|
|
63
|
-
del(requestUrl: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
|
|
64
|
-
post(requestUrl: string, data: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
|
|
65
|
-
patch(requestUrl: string, data: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
|
|
66
|
-
put(requestUrl: string, data: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
|
|
67
|
-
head(requestUrl: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
|
|
68
|
-
sendStream(verb: string, requestUrl: string, stream: NodeJS.ReadableStream, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>;
|
|
69
|
-
request(verb: string, requestUrl: string, data: string | NodeJS.ReadableStream, headers: ifm.IHeaders): Promise<HttpClientResponse>;
|
|
70
|
-
dispose(): void;
|
|
71
|
-
private _requestRaw;
|
|
72
|
-
private _prepareRequest;
|
|
73
|
-
private _getAgent;
|
|
74
|
-
private _getProxy;
|
|
75
|
-
private _isBypassProxy;
|
|
76
|
-
}
|
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.HttpClient = exports.HttpClientResponse = exports.HttpCodes = void 0;
|
|
13
|
-
exports.isHttps = isHttps;
|
|
14
|
-
const url = require("url");
|
|
15
|
-
const http = require("http");
|
|
16
|
-
const https = require("https");
|
|
17
|
-
var tunnel = require("tunnel");
|
|
18
|
-
const fs = require("fs");
|
|
19
|
-
var HttpCodes;
|
|
20
|
-
(function (HttpCodes) {
|
|
21
|
-
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
|
22
|
-
HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
|
|
23
|
-
HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
|
|
24
|
-
HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
|
|
25
|
-
HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
|
|
26
|
-
HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
|
|
27
|
-
HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
|
|
28
|
-
HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
29
|
-
HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
30
|
-
HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
|
|
31
|
-
HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
|
|
32
|
-
HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
|
|
33
|
-
HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
|
|
34
|
-
HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
|
|
35
|
-
HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
36
|
-
HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
|
|
37
|
-
HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
38
|
-
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
|
39
|
-
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
|
40
|
-
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
|
41
|
-
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
|
42
|
-
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
|
43
|
-
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
|
44
|
-
HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
45
|
-
HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
46
|
-
})(HttpCodes || (exports.HttpCodes = HttpCodes = {}));
|
|
47
|
-
const HttpRedirectCodes = [HttpCodes.MovedPermanently, HttpCodes.ResourceMoved, HttpCodes.TemporaryRedirect, HttpCodes.PermanentRedirect];
|
|
48
|
-
class HttpClientResponse {
|
|
49
|
-
constructor(message) {
|
|
50
|
-
this.message = message;
|
|
51
|
-
}
|
|
52
|
-
readBody() {
|
|
53
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
let output = '';
|
|
55
|
-
this.message.on('data', (chunk) => {
|
|
56
|
-
output += chunk;
|
|
57
|
-
});
|
|
58
|
-
this.message.on('end', () => {
|
|
59
|
-
resolve(output);
|
|
60
|
-
});
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.HttpClientResponse = HttpClientResponse;
|
|
65
|
-
function isHttps(requestUrl) {
|
|
66
|
-
let parsedUrl = url.parse(requestUrl);
|
|
67
|
-
return parsedUrl.protocol === 'https:';
|
|
68
|
-
}
|
|
69
|
-
var EnvironmentVariables;
|
|
70
|
-
(function (EnvironmentVariables) {
|
|
71
|
-
EnvironmentVariables[EnvironmentVariables["HTTP_PROXY"] = "HTTP_PROXY"] = "HTTP_PROXY";
|
|
72
|
-
EnvironmentVariables[EnvironmentVariables["HTTPS_PROXY"] = "HTTPS_PROXY"] = "HTTPS_PROXY";
|
|
73
|
-
})(EnvironmentVariables || (EnvironmentVariables = {}));
|
|
74
|
-
class HttpClient {
|
|
75
|
-
constructor(userAgent, handlers, requestOptions) {
|
|
76
|
-
this._ignoreSslError = false;
|
|
77
|
-
this._allowRedirects = true;
|
|
78
|
-
this._maxRedirects = 50;
|
|
79
|
-
this._keepAlive = false;
|
|
80
|
-
this._disposed = false;
|
|
81
|
-
this.userAgent = userAgent;
|
|
82
|
-
this.handlers = handlers;
|
|
83
|
-
this.requestOptions = requestOptions;
|
|
84
|
-
if (requestOptions) {
|
|
85
|
-
if (requestOptions.ignoreSslError != null) {
|
|
86
|
-
this._ignoreSslError = requestOptions.ignoreSslError;
|
|
87
|
-
}
|
|
88
|
-
this._socketTimeout = requestOptions.socketTimeout;
|
|
89
|
-
this._httpProxy = requestOptions.proxy;
|
|
90
|
-
if (requestOptions.proxy && requestOptions.proxy.proxyBypassHosts) {
|
|
91
|
-
this._httpProxyBypassHosts = [];
|
|
92
|
-
requestOptions.proxy.proxyBypassHosts.forEach(bypass => {
|
|
93
|
-
this._httpProxyBypassHosts.push(new RegExp(bypass, 'i'));
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
this._certConfig = requestOptions.cert;
|
|
97
|
-
if (this._certConfig && this._certConfig.caFile && fs.existsSync(this._certConfig.caFile)) {
|
|
98
|
-
this._ca = fs.readFileSync(this._certConfig.caFile, 'utf8');
|
|
99
|
-
}
|
|
100
|
-
if (this._certConfig && this._certConfig.certFile && fs.existsSync(this._certConfig.certFile)) {
|
|
101
|
-
this._cert = fs.readFileSync(this._certConfig.certFile, 'utf8');
|
|
102
|
-
}
|
|
103
|
-
if (this._certConfig && this._certConfig.keyFile && fs.existsSync(this._certConfig.keyFile)) {
|
|
104
|
-
this._key = fs.readFileSync(this._certConfig.keyFile, 'utf8');
|
|
105
|
-
}
|
|
106
|
-
if (requestOptions.allowRedirects != null) {
|
|
107
|
-
this._allowRedirects = requestOptions.allowRedirects;
|
|
108
|
-
}
|
|
109
|
-
if (requestOptions.maxRedirects != null) {
|
|
110
|
-
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
|
|
111
|
-
}
|
|
112
|
-
if (requestOptions.keepAlive != null) {
|
|
113
|
-
this._keepAlive = requestOptions.keepAlive;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
options(requestUrl, additionalHeaders) {
|
|
118
|
-
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
|
119
|
-
}
|
|
120
|
-
get(requestUrl, additionalHeaders) {
|
|
121
|
-
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
|
122
|
-
}
|
|
123
|
-
del(requestUrl, additionalHeaders) {
|
|
124
|
-
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
|
125
|
-
}
|
|
126
|
-
post(requestUrl, data, additionalHeaders) {
|
|
127
|
-
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
|
128
|
-
}
|
|
129
|
-
patch(requestUrl, data, additionalHeaders) {
|
|
130
|
-
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
|
131
|
-
}
|
|
132
|
-
put(requestUrl, data, additionalHeaders) {
|
|
133
|
-
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
|
134
|
-
}
|
|
135
|
-
head(requestUrl, additionalHeaders) {
|
|
136
|
-
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
|
137
|
-
}
|
|
138
|
-
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
|
139
|
-
return this.request(verb, requestUrl, stream, additionalHeaders);
|
|
140
|
-
}
|
|
141
|
-
request(verb, requestUrl, data, headers) {
|
|
142
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
if (this._disposed) {
|
|
144
|
-
throw new Error("Client has already been disposed");
|
|
145
|
-
}
|
|
146
|
-
let info = this._prepareRequest(verb, requestUrl, headers);
|
|
147
|
-
let response = yield this._requestRaw(info, data);
|
|
148
|
-
let redirectsRemaining = this._maxRedirects;
|
|
149
|
-
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1
|
|
150
|
-
&& this._allowRedirects
|
|
151
|
-
&& redirectsRemaining > 0) {
|
|
152
|
-
const redirectUrl = response.message.headers["location"];
|
|
153
|
-
if (!redirectUrl) {
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
yield response.readBody();
|
|
157
|
-
info = this._prepareRequest(verb, redirectUrl, headers);
|
|
158
|
-
response = yield this._requestRaw(info, data);
|
|
159
|
-
redirectsRemaining--;
|
|
160
|
-
}
|
|
161
|
-
return response;
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
dispose() {
|
|
165
|
-
if (this._agent) {
|
|
166
|
-
this._agent.destroy();
|
|
167
|
-
}
|
|
168
|
-
this._disposed = true;
|
|
169
|
-
}
|
|
170
|
-
_requestRaw(info, data) {
|
|
171
|
-
return new Promise((resolve, reject) => {
|
|
172
|
-
let socket;
|
|
173
|
-
let isDataString = typeof (data) === 'string';
|
|
174
|
-
if (typeof (data) === 'string') {
|
|
175
|
-
info.options.headers["Content-Length"] = Buffer.byteLength(data, 'utf8');
|
|
176
|
-
}
|
|
177
|
-
let req = info.httpModule.request(info.options, (msg) => {
|
|
178
|
-
let res = new HttpClientResponse(msg);
|
|
179
|
-
resolve(res);
|
|
180
|
-
});
|
|
181
|
-
req.on('socket', (sock) => {
|
|
182
|
-
socket = sock;
|
|
183
|
-
});
|
|
184
|
-
req.setTimeout(this._socketTimeout || 3 * 60000, () => {
|
|
185
|
-
if (socket) {
|
|
186
|
-
socket.end();
|
|
187
|
-
}
|
|
188
|
-
reject(new Error('Request timeout: ' + info.options.path));
|
|
189
|
-
});
|
|
190
|
-
req.on('error', function (err) {
|
|
191
|
-
reject(err);
|
|
192
|
-
});
|
|
193
|
-
if (data && typeof (data) === 'string') {
|
|
194
|
-
req.write(data, 'utf8');
|
|
195
|
-
}
|
|
196
|
-
if (data && typeof (data) !== 'string') {
|
|
197
|
-
data.on('close', function () {
|
|
198
|
-
req.end();
|
|
199
|
-
});
|
|
200
|
-
data.pipe(req);
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
req.end();
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
_prepareRequest(method, requestUrl, headers) {
|
|
208
|
-
let info = {};
|
|
209
|
-
info.parsedUrl = url.parse(requestUrl);
|
|
210
|
-
let usingSsl = info.parsedUrl.protocol === 'https:';
|
|
211
|
-
info.httpModule = usingSsl ? https : http;
|
|
212
|
-
var defaultPort = usingSsl ? 443 : 80;
|
|
213
|
-
info.options = {};
|
|
214
|
-
info.options.host = info.parsedUrl.hostname;
|
|
215
|
-
info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort;
|
|
216
|
-
info.options.path = (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
|
217
|
-
info.options.method = method;
|
|
218
|
-
info.options.headers = headers || {};
|
|
219
|
-
info.options.headers["User-Agent"] = this.userAgent;
|
|
220
|
-
info.options.agent = this._getAgent(requestUrl);
|
|
221
|
-
if (this.handlers) {
|
|
222
|
-
this.handlers.forEach((handler) => {
|
|
223
|
-
handler.prepareRequest(info.options);
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
return info;
|
|
227
|
-
}
|
|
228
|
-
_getAgent(requestUrl) {
|
|
229
|
-
let agent;
|
|
230
|
-
let proxy = this._getProxy(requestUrl);
|
|
231
|
-
let useProxy = proxy.proxyUrl && proxy.proxyUrl.hostname && !this._isBypassProxy(requestUrl);
|
|
232
|
-
if (this._keepAlive && useProxy) {
|
|
233
|
-
agent = this._proxyAgent;
|
|
234
|
-
}
|
|
235
|
-
if (this._keepAlive && !useProxy) {
|
|
236
|
-
agent = this._agent;
|
|
237
|
-
}
|
|
238
|
-
if (!!agent) {
|
|
239
|
-
return agent;
|
|
240
|
-
}
|
|
241
|
-
var parsedUrl = url.parse(requestUrl);
|
|
242
|
-
let usingSsl = parsedUrl.protocol === 'https:';
|
|
243
|
-
let maxSockets = 100;
|
|
244
|
-
if (!!this.requestOptions) {
|
|
245
|
-
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
|
246
|
-
}
|
|
247
|
-
if (useProxy) {
|
|
248
|
-
var agentOptions = {
|
|
249
|
-
maxSockets: maxSockets,
|
|
250
|
-
keepAlive: this._keepAlive,
|
|
251
|
-
proxy: {
|
|
252
|
-
proxyAuth: proxy.proxyAuth,
|
|
253
|
-
host: proxy.proxyUrl.hostname,
|
|
254
|
-
port: Number(proxy.proxyUrl.port) || (proxy.proxyUrl.protocol === 'https:' ? 443 : 80)
|
|
255
|
-
},
|
|
256
|
-
};
|
|
257
|
-
var tunnelAgent;
|
|
258
|
-
var overHttps = proxy.proxyUrl.protocol === 'https:';
|
|
259
|
-
if (usingSsl) {
|
|
260
|
-
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
|
|
264
|
-
}
|
|
265
|
-
agent = tunnelAgent(agentOptions);
|
|
266
|
-
this._proxyAgent = agent;
|
|
267
|
-
}
|
|
268
|
-
if (this._keepAlive && !agent) {
|
|
269
|
-
var options = { keepAlive: this._keepAlive, maxSockets: maxSockets };
|
|
270
|
-
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
|
271
|
-
this._agent = agent;
|
|
272
|
-
}
|
|
273
|
-
if (!agent) {
|
|
274
|
-
agent = usingSsl ? https.globalAgent : http.globalAgent;
|
|
275
|
-
}
|
|
276
|
-
if (usingSsl && this._ignoreSslError) {
|
|
277
|
-
agent.options = Object.assign(agent.options || {}, { rejectUnauthorized: false });
|
|
278
|
-
}
|
|
279
|
-
if (usingSsl && this._certConfig) {
|
|
280
|
-
agent.options = Object.assign(agent.options || {}, { ca: this._ca, cert: this._cert, key: this._key, passphrase: this._certConfig.passphrase });
|
|
281
|
-
}
|
|
282
|
-
return agent;
|
|
283
|
-
}
|
|
284
|
-
_getProxy(requestUrl) {
|
|
285
|
-
var parsedUrl = url.parse(requestUrl);
|
|
286
|
-
let usingSsl = parsedUrl.protocol === 'https:';
|
|
287
|
-
let proxyConfig = this._httpProxy;
|
|
288
|
-
let https_proxy = process.env[EnvironmentVariables.HTTPS_PROXY];
|
|
289
|
-
let http_proxy = process.env[EnvironmentVariables.HTTP_PROXY];
|
|
290
|
-
if (!proxyConfig) {
|
|
291
|
-
if (https_proxy && usingSsl) {
|
|
292
|
-
proxyConfig = {
|
|
293
|
-
proxyUrl: https_proxy
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
else if (http_proxy) {
|
|
297
|
-
proxyConfig = {
|
|
298
|
-
proxyUrl: http_proxy
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
let proxyUrl;
|
|
303
|
-
let proxyAuth;
|
|
304
|
-
if (proxyConfig) {
|
|
305
|
-
if (proxyConfig.proxyUrl.length > 0) {
|
|
306
|
-
proxyUrl = url.parse(proxyConfig.proxyUrl);
|
|
307
|
-
}
|
|
308
|
-
if (proxyConfig.proxyUsername || proxyConfig.proxyPassword) {
|
|
309
|
-
proxyAuth = proxyConfig.proxyUsername + ":" + proxyConfig.proxyPassword;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return { proxyUrl: proxyUrl, proxyAuth: proxyAuth };
|
|
313
|
-
}
|
|
314
|
-
_isBypassProxy(requestUrl) {
|
|
315
|
-
if (!this._httpProxyBypassHosts) {
|
|
316
|
-
return false;
|
|
317
|
-
}
|
|
318
|
-
let bypass = false;
|
|
319
|
-
this._httpProxyBypassHosts.forEach(bypassHost => {
|
|
320
|
-
if (bypassHost.test(requestUrl)) {
|
|
321
|
-
bypass = true;
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
return bypass;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
exports.HttpClient = HttpClient;
|
|
328
|
-
//# sourceMappingURL=HttpClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -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,26 +0,0 @@
|
|
|
1
|
-
import httpm = require('./HttpClient');
|
|
2
|
-
import ifm = require("./Interfaces");
|
|
3
|
-
export interface IRestResponse<T> {
|
|
4
|
-
statusCode: number;
|
|
5
|
-
result: T;
|
|
6
|
-
}
|
|
7
|
-
export interface IRequestOptions {
|
|
8
|
-
acceptHeader?: string;
|
|
9
|
-
additionalHeaders?: ifm.IHeaders;
|
|
10
|
-
responseProcessor?: Function;
|
|
11
|
-
}
|
|
12
|
-
export declare class RestClient {
|
|
13
|
-
client: httpm.HttpClient;
|
|
14
|
-
versionParam: string;
|
|
15
|
-
constructor(userAgent: string, baseUrl?: string, handlers?: ifm.IRequestHandler[], requestOptions?: ifm.IRequestOptions);
|
|
16
|
-
private _baseUrl;
|
|
17
|
-
options<T>(requestUrl: string, options?: IRequestOptions): Promise<IRestResponse<T>>;
|
|
18
|
-
get<T>(requestUrl: string, options?: IRequestOptions): Promise<IRestResponse<T>>;
|
|
19
|
-
del<T>(requestUrl: string, options?: IRequestOptions): Promise<IRestResponse<T>>;
|
|
20
|
-
create<T>(requestUrl: string, resources: any, options?: IRequestOptions): Promise<IRestResponse<T>>;
|
|
21
|
-
update<T>(requestUrl: string, resources: any, options?: IRequestOptions): Promise<IRestResponse<T>>;
|
|
22
|
-
replace<T>(requestUrl: string, resources: any, options?: IRequestOptions): Promise<IRestResponse<T>>;
|
|
23
|
-
uploadStream<T>(verb: string, requestUrl: string, stream: NodeJS.ReadableStream, options?: IRequestOptions): Promise<IRestResponse<T>>;
|
|
24
|
-
private _headersFromOptions;
|
|
25
|
-
private _processResponse;
|
|
26
|
-
}
|