artifact-engine 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Engine/artifactEngine.d.ts +12 -12
- package/Engine/artifactEngine.js +166 -166
- package/Engine/artifactEngineOptions.d.ts +8 -8
- package/Engine/artifactEngineOptions.js +13 -15
- package/Engine/cilogger.d.ts +6 -6
- package/Engine/cilogger.js +44 -46
- package/Engine/index.d.ts +2 -2
- package/Engine/index.js +6 -8
- package/Engine/logger.d.ts +13 -13
- package/Engine/logger.js +109 -112
- package/Engine/worker.d.ts +10 -10
- package/Engine/worker.js +49 -51
- package/Models/artifactDownloadTicket.d.ts +11 -11
- package/Models/artifactDownloadTicket.js +5 -7
- package/Models/artifactItem.d.ts +12 -12
- package/Models/artifactItem.js +8 -10
- package/Models/artifactprovider.d.ts +10 -11
- package/Models/artifactprovider.js +2 -3
- package/Models/constants.d.ts +3 -3
- package/Models/constants.js +6 -8
- package/Models/index.d.ts +6 -6
- package/Models/index.js +12 -14
- package/Models/itemType.d.ts +5 -5
- package/Models/itemType.js +8 -10
- package/Models/ticketState.d.ts +7 -7
- package/Models/ticketState.js +10 -12
- package/Providers/filesystemProvider.d.ts +14 -15
- package/Providers/filesystemProvider.js +123 -123
- package/Providers/index.d.ts +4 -4
- package/Providers/index.js +10 -12
- package/Providers/stubProvider.d.ts +20 -21
- package/Providers/stubProvider.js +85 -88
- package/Providers/typed-rest-client/Handlers.d.ts +4 -4
- package/Providers/typed-rest-client/Handlers.js +10 -12
- package/Providers/typed-rest-client/HttpClient.d.ts +84 -77
- package/Providers/typed-rest-client/HttpClient.js +351 -328
- package/Providers/typed-rest-client/Index.d.ts +0 -1
- package/Providers/typed-rest-client/Index.js +2 -3
- package/Providers/typed-rest-client/Interfaces.d.ts +38 -38
- package/Providers/typed-rest-client/Interfaces.js +3 -4
- package/Providers/typed-rest-client/RestClient.d.ts +73 -27
- package/Providers/typed-rest-client/RestClient.js +186 -134
- package/Providers/typed-rest-client/Util.d.ts +7 -1
- package/Providers/typed-rest-client/Util.js +24 -18
- package/Providers/typed-rest-client/handlers/basiccreds.d.ts +9 -9
- package/Providers/typed-rest-client/handlers/basiccreds.js +23 -20
- package/Providers/typed-rest-client/handlers/bearertoken.d.ts +8 -8
- package/Providers/typed-rest-client/handlers/bearertoken.js +22 -19
- package/Providers/typed-rest-client/handlers/ntlm.d.ts +13 -13
- package/Providers/typed-rest-client/handlers/ntlm.js +115 -96
- package/Providers/typed-rest-client/handlers/personalaccesstoken.d.ts +8 -8
- package/Providers/typed-rest-client/handlers/personalaccesstoken.js +22 -19
- package/Providers/typed-rest-client/opensource/node-http-ntlm/readme.txt +6 -0
- package/Providers/webClient.d.ts +8 -8
- package/Providers/webClient.js +60 -60
- package/Providers/webClientFactory.d.ts +5 -5
- package/Providers/webClientFactory.js +59 -55
- package/Providers/webProvider.d.ts +21 -22
- package/Providers/webProvider.js +120 -116
- package/Providers/zipProvider.d.ts +15 -16
- package/Providers/zipProvider.js +53 -55
- package/Store/artifactItemStore.d.ts +18 -18
- package/Store/artifactItemStore.js +94 -96
- package/Store/index.d.ts +1 -1
- package/Store/index.js +4 -6
- package/Strings/resources.resjson/de-DE/resources.resjson +11 -11
- package/Strings/resources.resjson/en-US/resources.resjson +11 -11
- package/Strings/resources.resjson/es-ES/resources.resjson +11 -11
- package/Strings/resources.resjson/fr-FR/resources.resjson +11 -11
- package/Strings/resources.resjson/it-IT/resources.resjson +11 -11
- package/Strings/resources.resjson/ja-JP/resources.resjson +11 -11
- package/Strings/resources.resjson/ko-KR/resources.resjson +11 -11
- package/Strings/resources.resjson/ru-RU/resources.resjson +11 -11
- package/Strings/resources.resjson/zh-CN/resources.resjson +11 -11
- package/Strings/resources.resjson/zh-TW/resources.resjson +11 -11
- package/npm-shrinkwrap.json +1 -1
- package/package.json +1 -1
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
class BasicCredentialHandler {
|
|
6
|
+
constructor(username, password) {
|
|
7
|
+
this.username = username;
|
|
8
|
+
this.password = password;
|
|
9
|
+
}
|
|
10
|
+
// currently implements pre-authorization
|
|
11
|
+
// TODO: support preAuth = false where it hooks on 401
|
|
12
|
+
prepareRequest(options) {
|
|
13
|
+
options.headers['Authorization'] = 'Basic ' + new Buffer(this.username + ':' + this.password).toString('base64');
|
|
14
|
+
options.headers['X-TFS-FedAuthRedirect'] = 'Suppress';
|
|
15
|
+
}
|
|
16
|
+
// This handler cannot handle 401
|
|
17
|
+
canHandleAuthentication(res) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
handleAuthentication(httpClient, protocol, options, objs, finalCallback) {
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.BasicCredentialHandler = BasicCredentialHandler;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import ifm = require('../Interfaces');
|
|
2
|
-
export declare class BearerCredentialHandler implements ifm.IRequestHandler {
|
|
3
|
-
token: string;
|
|
4
|
-
constructor(token: string);
|
|
5
|
-
prepareRequest(options: any): void;
|
|
6
|
-
canHandleAuthentication(res: ifm.IHttpResponse): boolean;
|
|
7
|
-
handleAuthentication(httpClient: any, protocol: any, options: any, objs: any, finalCallback: any): void;
|
|
8
|
-
}
|
|
1
|
+
import ifm = require('../Interfaces');
|
|
2
|
+
export declare class BearerCredentialHandler implements ifm.IRequestHandler {
|
|
3
|
+
token: string;
|
|
4
|
+
constructor(token: string);
|
|
5
|
+
prepareRequest(options: any): void;
|
|
6
|
+
canHandleAuthentication(res: ifm.IHttpResponse): boolean;
|
|
7
|
+
handleAuthentication(httpClient: any, protocol: any, options: any, objs: any, finalCallback: any): void;
|
|
8
|
+
}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
class BearerCredentialHandler {
|
|
6
|
+
constructor(token) {
|
|
7
|
+
this.token = token;
|
|
8
|
+
}
|
|
9
|
+
// currently implements pre-authorization
|
|
10
|
+
// TODO: support preAuth = false where it hooks on 401
|
|
11
|
+
prepareRequest(options) {
|
|
12
|
+
options.headers['Authorization'] = 'Bearer ' + this.token;
|
|
13
|
+
options.headers['X-TFS-FedAuthRedirect'] = 'Suppress';
|
|
14
|
+
}
|
|
15
|
+
// This handler cannot handle 401
|
|
16
|
+
canHandleAuthentication(res) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
handleAuthentication(httpClient, protocol, options, objs, finalCallback) {
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.BearerCredentialHandler = BearerCredentialHandler;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import ifm = require('../Interfaces');
|
|
2
|
-
export declare class NtlmCredentialHandler implements ifm.IRequestHandler {
|
|
3
|
-
username: string;
|
|
4
|
-
password: string;
|
|
5
|
-
workstation: string;
|
|
6
|
-
domain: string;
|
|
7
|
-
constructor(username: string, password: string, domain?: string, workstation?: string);
|
|
8
|
-
prepareRequest(options: any): void;
|
|
9
|
-
canHandleAuthentication(res: ifm.IHttpResponse): boolean;
|
|
10
|
-
handleAuthentication(httpClient: any, protocol: any, options: any, objs: any, finalCallback: any): void;
|
|
11
|
-
private sendType1Message;
|
|
12
|
-
private sendType3Message;
|
|
13
|
-
}
|
|
1
|
+
import ifm = require('../Interfaces');
|
|
2
|
+
export declare class NtlmCredentialHandler implements ifm.IRequestHandler {
|
|
3
|
+
username: string;
|
|
4
|
+
password: string;
|
|
5
|
+
workstation: string;
|
|
6
|
+
domain: string;
|
|
7
|
+
constructor(username: string, password: string, domain?: string, workstation?: string);
|
|
8
|
+
prepareRequest(options: any): void;
|
|
9
|
+
canHandleAuthentication(res: ifm.IHttpResponse): boolean;
|
|
10
|
+
handleAuthentication(httpClient: any, protocol: any, options: any, objs: any, finalCallback: any): void;
|
|
11
|
+
private sendType1Message(httpClient, protocol, options, objs, keepaliveAgent, callback);
|
|
12
|
+
private sendType3Message(httpClient, protocol, options, objs, keepaliveAgent, res, callback);
|
|
13
|
+
}
|
|
@@ -1,96 +1,115 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const http = require("http");
|
|
6
|
+
const https = require("https");
|
|
7
|
+
var _ = require("underscore");
|
|
8
|
+
var ntlm = require("../opensource/node-http-ntlm/ntlm");
|
|
9
|
+
class NtlmCredentialHandler {
|
|
10
|
+
constructor(username, password, domain, workstation) {
|
|
11
|
+
this.username = username;
|
|
12
|
+
this.password = password;
|
|
13
|
+
if (domain !== undefined) {
|
|
14
|
+
this.domain = domain;
|
|
15
|
+
}
|
|
16
|
+
if (workstation !== undefined) {
|
|
17
|
+
this.workstation = workstation;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
prepareRequest(options) {
|
|
21
|
+
// No headers or options need to be set. We keep the credentials on the handler itself.
|
|
22
|
+
// If a (proxy) agent is set, remove it as we don't support proxy for NTLM at this time
|
|
23
|
+
if (options.agent) {
|
|
24
|
+
delete options.agent;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
canHandleAuthentication(res) {
|
|
28
|
+
if (res && res.statusCode === 401) {
|
|
29
|
+
// Ensure that we're talking NTLM here
|
|
30
|
+
// Once we have the www-authenticate header, split it so we can ensure we can talk NTLM
|
|
31
|
+
var wwwAuthenticate = res.headers['www-authenticate'];
|
|
32
|
+
if (wwwAuthenticate !== undefined) {
|
|
33
|
+
var mechanisms = wwwAuthenticate.split(', ');
|
|
34
|
+
var idx = mechanisms.indexOf("NTLM");
|
|
35
|
+
if (idx >= 0) {
|
|
36
|
+
// Check specifically for 'NTLM' since www-authenticate header can also contain
|
|
37
|
+
// the Authorization value to use in the form of 'NTLM TlRMTVNT....AAAADw=='
|
|
38
|
+
if (mechanisms[idx].length == 4) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
// The following method is an adaptation of code found at https://github.com/SamDecrock/node-http-ntlm/blob/master/httpntlm.js
|
|
47
|
+
handleAuthentication(httpClient, protocol, options, objs, finalCallback) {
|
|
48
|
+
// Set up the headers for NTLM authentication
|
|
49
|
+
var ntlmOptions = _.extend(options, {
|
|
50
|
+
username: this.username,
|
|
51
|
+
password: this.password,
|
|
52
|
+
domain: this.domain || '',
|
|
53
|
+
workstation: this.workstation || ''
|
|
54
|
+
});
|
|
55
|
+
var keepaliveAgent;
|
|
56
|
+
if (httpClient.isSsl === true) {
|
|
57
|
+
keepaliveAgent = new https.Agent({});
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
keepaliveAgent = new http.Agent({ keepAlive: true });
|
|
61
|
+
}
|
|
62
|
+
let self = this;
|
|
63
|
+
// The following pattern of sending the type1 message following immediately (in a setImmediate) is
|
|
64
|
+
// critical for the NTLM exchange to happen. If we removed setImmediate (or call in a different manner)
|
|
65
|
+
// the NTLM exchange will always fail with a 401.
|
|
66
|
+
this.sendType1Message(httpClient, protocol, ntlmOptions, objs, keepaliveAgent, function (err, res) {
|
|
67
|
+
if (err) {
|
|
68
|
+
return finalCallback(err, null, null);
|
|
69
|
+
}
|
|
70
|
+
setImmediate(function () {
|
|
71
|
+
self.sendType3Message(httpClient, protocol, ntlmOptions, objs, keepaliveAgent, res, finalCallback);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
// The following method is an adaptation of code found at https://github.com/SamDecrock/node-http-ntlm/blob/master/httpntlm.js
|
|
76
|
+
sendType1Message(httpClient, protocol, options, objs, keepaliveAgent, callback) {
|
|
77
|
+
var type1msg = ntlm.createType1Message(options);
|
|
78
|
+
var type1options = {
|
|
79
|
+
headers: {
|
|
80
|
+
'Connection': 'keep-alive',
|
|
81
|
+
'Authorization': type1msg
|
|
82
|
+
},
|
|
83
|
+
timeout: options.timeout || 0,
|
|
84
|
+
agent: keepaliveAgent,
|
|
85
|
+
// don't redirect because http could change to https which means we need to change the keepaliveAgent
|
|
86
|
+
allowRedirects: false
|
|
87
|
+
};
|
|
88
|
+
type1options = _.extend(type1options, _.omit(options, 'headers'));
|
|
89
|
+
httpClient.requestInternal(protocol, type1options, objs, callback);
|
|
90
|
+
}
|
|
91
|
+
// The following method is an adaptation of code found at https://github.com/SamDecrock/node-http-ntlm/blob/master/httpntlm.js
|
|
92
|
+
sendType3Message(httpClient, protocol, options, objs, keepaliveAgent, res, callback) {
|
|
93
|
+
if (!res.headers['www-authenticate']) {
|
|
94
|
+
return callback(new Error('www-authenticate not found on response of second request'));
|
|
95
|
+
}
|
|
96
|
+
// parse type2 message from server:
|
|
97
|
+
var type2msg = ntlm.parseType2Message(res.headers['www-authenticate']);
|
|
98
|
+
// create type3 message:
|
|
99
|
+
var type3msg = ntlm.createType3Message(type2msg, options);
|
|
100
|
+
// build type3 request:
|
|
101
|
+
var type3options = {
|
|
102
|
+
headers: {
|
|
103
|
+
'Authorization': type3msg
|
|
104
|
+
},
|
|
105
|
+
allowRedirects: false,
|
|
106
|
+
agent: keepaliveAgent
|
|
107
|
+
};
|
|
108
|
+
// pass along other options:
|
|
109
|
+
type3options.headers = _.extend(type3options.headers, options.headers);
|
|
110
|
+
type3options = _.extend(type3options, _.omit(options, 'headers'));
|
|
111
|
+
// send type3 message to server:
|
|
112
|
+
httpClient.requestInternal(protocol, type3options, objs, callback);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.NtlmCredentialHandler = NtlmCredentialHandler;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import ifm = require('../Interfaces');
|
|
2
|
-
export declare class PersonalAccessTokenCredentialHandler implements ifm.IRequestHandler {
|
|
3
|
-
token: string;
|
|
4
|
-
constructor(token: string);
|
|
5
|
-
prepareRequest(options: any): void;
|
|
6
|
-
canHandleAuthentication(res: ifm.IHttpResponse): boolean;
|
|
7
|
-
handleAuthentication(httpClient: any, protocol: any, options: any, objs: any, finalCallback: any): void;
|
|
8
|
-
}
|
|
1
|
+
import ifm = require('../Interfaces');
|
|
2
|
+
export declare class PersonalAccessTokenCredentialHandler implements ifm.IRequestHandler {
|
|
3
|
+
token: string;
|
|
4
|
+
constructor(token: string);
|
|
5
|
+
prepareRequest(options: any): void;
|
|
6
|
+
canHandleAuthentication(res: ifm.IHttpResponse): boolean;
|
|
7
|
+
handleAuthentication(httpClient: any, protocol: any, options: any, objs: any, finalCallback: any): void;
|
|
8
|
+
}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
class PersonalAccessTokenCredentialHandler {
|
|
6
|
+
constructor(token) {
|
|
7
|
+
this.token = token;
|
|
8
|
+
}
|
|
9
|
+
// currently implements pre-authorization
|
|
10
|
+
// TODO: support preAuth = false where it hooks on 401
|
|
11
|
+
prepareRequest(options) {
|
|
12
|
+
options.headers['Authorization'] = 'Basic ' + new Buffer('PAT:' + this.token).toString('base64');
|
|
13
|
+
options.headers['X-TFS-FedAuthRedirect'] = 'Suppress';
|
|
14
|
+
}
|
|
15
|
+
// This handler cannot handle 401
|
|
16
|
+
canHandleAuthentication(res) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
handleAuthentication(httpClient, protocol, options, objs, finalCallback) {
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// This software (ntlm.js) was copied from a file of the same name at https://github.com/SamDecrock/node-http-ntlm/blob/master/ntlm.js.
|
|
2
|
+
//
|
|
3
|
+
// As of this writing, it is a part of the node-http-ntlm module produced by SamDecrock.
|
|
4
|
+
//
|
|
5
|
+
// It is used as a part of the NTLM support provided by the vso-node-api library.
|
|
6
|
+
//
|
package/Providers/webClient.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as httpm from './typed-rest-client/HttpClient';
|
|
2
|
-
export declare class WebClient {
|
|
3
|
-
private httpc;
|
|
4
|
-
constructor(handlers: any, options: any);
|
|
5
|
-
get(requestUrl: string, additionalHeaders?: any): Promise<httpm.HttpClientResponse>;
|
|
6
|
-
dispose(): void;
|
|
7
|
-
processResponse(res: httpm.HttpClientResponse): Promise<void>;
|
|
8
|
-
}
|
|
1
|
+
import * as httpm from './typed-rest-client/HttpClient';
|
|
2
|
+
export declare class WebClient {
|
|
3
|
+
private httpc;
|
|
4
|
+
constructor(handlers: any, options: any);
|
|
5
|
+
get(requestUrl: string, additionalHeaders?: any): Promise<httpm.HttpClientResponse>;
|
|
6
|
+
dispose(): void;
|
|
7
|
+
processResponse(res: httpm.HttpClientResponse): Promise<void>;
|
|
8
|
+
}
|
package/Providers/webClient.js
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
err =
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
let result = yield res.readBody();
|
|
48
|
-
err['result'] = result;
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
// restrict usage of typed-rest-client to this file
|
|
12
|
+
const httpm = require("./typed-rest-client/HttpClient");
|
|
13
|
+
var tl = require('azure-pipelines-task-lib/task');
|
|
14
|
+
var packagejson = require('../package.json');
|
|
15
|
+
class WebClient {
|
|
16
|
+
constructor(handlers, options) {
|
|
17
|
+
this.httpc = new httpm.HttpClient('artifact-engine ' + packagejson.version, handlers, options);
|
|
18
|
+
}
|
|
19
|
+
get(requestUrl, additionalHeaders) {
|
|
20
|
+
var promise = new Promise((resolve, reject) => {
|
|
21
|
+
this.httpc.get(requestUrl, additionalHeaders).then((res) => {
|
|
22
|
+
this.processResponse(res).then(() => {
|
|
23
|
+
resolve(res);
|
|
24
|
+
}, (err) => {
|
|
25
|
+
reject(err);
|
|
26
|
+
});
|
|
27
|
+
}, (err) => {
|
|
28
|
+
reject(err);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
return promise;
|
|
32
|
+
}
|
|
33
|
+
dispose() {
|
|
34
|
+
this.httpc.dispose();
|
|
35
|
+
}
|
|
36
|
+
processResponse(res) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
const statusCode = res.message.statusCode;
|
|
39
|
+
let err;
|
|
40
|
+
if (statusCode > 299) {
|
|
41
|
+
let obj;
|
|
42
|
+
var msg = tl.loc("FailedRequest", statusCode);
|
|
43
|
+
err = new Error(msg);
|
|
44
|
+
err['statusCode'] = statusCode;
|
|
45
|
+
// get the result from the body
|
|
46
|
+
try {
|
|
47
|
+
let result = yield res.readBody();
|
|
48
|
+
err['result'] = result;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
// Invalid contents; leaving result obj null
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (!!err) {
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.WebClient = WebClient;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare class WebClientFactory {
|
|
2
|
-
static getClient(handlers: any[], options: any): any;
|
|
3
|
-
private static initializeProxy;
|
|
4
|
-
private static _readTaskLibSecrets;
|
|
5
|
-
}
|
|
1
|
+
export declare class WebClientFactory {
|
|
2
|
+
static getClient(handlers: any[], options: any): any;
|
|
3
|
+
private static initializeProxy(options);
|
|
4
|
+
private static _readTaskLibSecrets(lookupKey);
|
|
5
|
+
}
|