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.
Files changed (77) hide show
  1. package/Engine/artifactEngine.d.ts +12 -12
  2. package/Engine/artifactEngine.js +166 -166
  3. package/Engine/artifactEngineOptions.d.ts +8 -8
  4. package/Engine/artifactEngineOptions.js +13 -15
  5. package/Engine/cilogger.d.ts +6 -6
  6. package/Engine/cilogger.js +44 -46
  7. package/Engine/index.d.ts +2 -2
  8. package/Engine/index.js +6 -8
  9. package/Engine/logger.d.ts +13 -13
  10. package/Engine/logger.js +109 -112
  11. package/Engine/worker.d.ts +10 -10
  12. package/Engine/worker.js +49 -51
  13. package/Models/artifactDownloadTicket.d.ts +11 -11
  14. package/Models/artifactDownloadTicket.js +5 -7
  15. package/Models/artifactItem.d.ts +12 -12
  16. package/Models/artifactItem.js +8 -10
  17. package/Models/artifactprovider.d.ts +10 -11
  18. package/Models/artifactprovider.js +2 -3
  19. package/Models/constants.d.ts +3 -3
  20. package/Models/constants.js +6 -8
  21. package/Models/index.d.ts +6 -6
  22. package/Models/index.js +12 -14
  23. package/Models/itemType.d.ts +5 -5
  24. package/Models/itemType.js +8 -10
  25. package/Models/ticketState.d.ts +7 -7
  26. package/Models/ticketState.js +10 -12
  27. package/Providers/filesystemProvider.d.ts +14 -15
  28. package/Providers/filesystemProvider.js +123 -123
  29. package/Providers/index.d.ts +4 -4
  30. package/Providers/index.js +10 -12
  31. package/Providers/stubProvider.d.ts +20 -21
  32. package/Providers/stubProvider.js +85 -88
  33. package/Providers/typed-rest-client/Handlers.d.ts +4 -4
  34. package/Providers/typed-rest-client/Handlers.js +10 -12
  35. package/Providers/typed-rest-client/HttpClient.d.ts +84 -77
  36. package/Providers/typed-rest-client/HttpClient.js +351 -328
  37. package/Providers/typed-rest-client/Index.d.ts +0 -1
  38. package/Providers/typed-rest-client/Index.js +2 -3
  39. package/Providers/typed-rest-client/Interfaces.d.ts +38 -38
  40. package/Providers/typed-rest-client/Interfaces.js +3 -4
  41. package/Providers/typed-rest-client/RestClient.d.ts +73 -27
  42. package/Providers/typed-rest-client/RestClient.js +186 -134
  43. package/Providers/typed-rest-client/Util.d.ts +7 -1
  44. package/Providers/typed-rest-client/Util.js +24 -18
  45. package/Providers/typed-rest-client/handlers/basiccreds.d.ts +9 -9
  46. package/Providers/typed-rest-client/handlers/basiccreds.js +23 -20
  47. package/Providers/typed-rest-client/handlers/bearertoken.d.ts +8 -8
  48. package/Providers/typed-rest-client/handlers/bearertoken.js +22 -19
  49. package/Providers/typed-rest-client/handlers/ntlm.d.ts +13 -13
  50. package/Providers/typed-rest-client/handlers/ntlm.js +115 -96
  51. package/Providers/typed-rest-client/handlers/personalaccesstoken.d.ts +8 -8
  52. package/Providers/typed-rest-client/handlers/personalaccesstoken.js +22 -19
  53. package/Providers/typed-rest-client/opensource/node-http-ntlm/readme.txt +6 -0
  54. package/Providers/webClient.d.ts +8 -8
  55. package/Providers/webClient.js +60 -60
  56. package/Providers/webClientFactory.d.ts +5 -5
  57. package/Providers/webClientFactory.js +59 -55
  58. package/Providers/webProvider.d.ts +21 -22
  59. package/Providers/webProvider.js +120 -116
  60. package/Providers/zipProvider.d.ts +15 -16
  61. package/Providers/zipProvider.js +53 -55
  62. package/Store/artifactItemStore.d.ts +18 -18
  63. package/Store/artifactItemStore.js +94 -96
  64. package/Store/index.d.ts +1 -1
  65. package/Store/index.js +4 -6
  66. package/Strings/resources.resjson/de-DE/resources.resjson +11 -11
  67. package/Strings/resources.resjson/en-US/resources.resjson +11 -11
  68. package/Strings/resources.resjson/es-ES/resources.resjson +11 -11
  69. package/Strings/resources.resjson/fr-FR/resources.resjson +11 -11
  70. package/Strings/resources.resjson/it-IT/resources.resjson +11 -11
  71. package/Strings/resources.resjson/ja-JP/resources.resjson +11 -11
  72. package/Strings/resources.resjson/ko-KR/resources.resjson +11 -11
  73. package/Strings/resources.resjson/ru-RU/resources.resjson +11 -11
  74. package/Strings/resources.resjson/zh-CN/resources.resjson +11 -11
  75. package/Strings/resources.resjson/zh-TW/resources.resjson +11 -11
  76. package/npm-shrinkwrap.json +1 -1
  77. package/package.json +1 -1
@@ -1,20 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BasicCredentialHandler = void 0;
4
- class BasicCredentialHandler {
5
- constructor(username, password) {
6
- this.username = username;
7
- this.password = password;
8
- }
9
- prepareRequest(options) {
10
- options.headers['Authorization'] = 'Basic ' + new Buffer(this.username + ':' + this.password).toString('base64');
11
- options.headers['X-TFS-FedAuthRedirect'] = 'Suppress';
12
- }
13
- canHandleAuthentication(res) {
14
- return false;
15
- }
16
- handleAuthentication(httpClient, protocol, options, objs, finalCallback) {
17
- }
18
- }
19
- exports.BasicCredentialHandler = BasicCredentialHandler;
20
- //# sourceMappingURL=basiccreds.js.map
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
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BearerCredentialHandler = void 0;
4
- class BearerCredentialHandler {
5
- constructor(token) {
6
- this.token = token;
7
- }
8
- prepareRequest(options) {
9
- options.headers['Authorization'] = 'Bearer ' + this.token;
10
- options.headers['X-TFS-FedAuthRedirect'] = 'Suppress';
11
- }
12
- canHandleAuthentication(res) {
13
- return false;
14
- }
15
- handleAuthentication(httpClient, protocol, options, objs, finalCallback) {
16
- }
17
- }
18
- exports.BearerCredentialHandler = BearerCredentialHandler;
19
- //# sourceMappingURL=bearertoken.js.map
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
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NtlmCredentialHandler = void 0;
4
- const http = require("http");
5
- const https = require("https");
6
- var _ = require("underscore");
7
- var ntlm = require("../opensource/node-http-ntlm/ntlm");
8
- class NtlmCredentialHandler {
9
- constructor(username, password, domain, workstation) {
10
- this.username = username;
11
- this.password = password;
12
- if (domain !== undefined) {
13
- this.domain = domain;
14
- }
15
- if (workstation !== undefined) {
16
- this.workstation = workstation;
17
- }
18
- }
19
- prepareRequest(options) {
20
- if (options.agent) {
21
- delete options.agent;
22
- }
23
- }
24
- canHandleAuthentication(res) {
25
- if (res && res.statusCode === 401) {
26
- var wwwAuthenticate = res.headers['www-authenticate'];
27
- if (wwwAuthenticate !== undefined) {
28
- var mechanisms = wwwAuthenticate.split(', ');
29
- var idx = mechanisms.indexOf("NTLM");
30
- if (idx >= 0) {
31
- if (mechanisms[idx].length == 4) {
32
- return true;
33
- }
34
- }
35
- }
36
- }
37
- return false;
38
- }
39
- handleAuthentication(httpClient, protocol, options, objs, finalCallback) {
40
- var ntlmOptions = _.extend(options, {
41
- username: this.username,
42
- password: this.password,
43
- domain: this.domain || '',
44
- workstation: this.workstation || ''
45
- });
46
- var keepaliveAgent;
47
- if (httpClient.isSsl === true) {
48
- keepaliveAgent = new https.Agent({});
49
- }
50
- else {
51
- keepaliveAgent = new http.Agent({ keepAlive: true });
52
- }
53
- let self = this;
54
- this.sendType1Message(httpClient, protocol, ntlmOptions, objs, keepaliveAgent, function (err, res) {
55
- if (err) {
56
- return finalCallback(err, null, null);
57
- }
58
- setImmediate(function () {
59
- self.sendType3Message(httpClient, protocol, ntlmOptions, objs, keepaliveAgent, res, finalCallback);
60
- });
61
- });
62
- }
63
- sendType1Message(httpClient, protocol, options, objs, keepaliveAgent, callback) {
64
- var type1msg = ntlm.createType1Message(options);
65
- var type1options = {
66
- headers: {
67
- 'Connection': 'keep-alive',
68
- 'Authorization': type1msg
69
- },
70
- timeout: options.timeout || 0,
71
- agent: keepaliveAgent,
72
- allowRedirects: false
73
- };
74
- type1options = _.extend(type1options, _.omit(options, 'headers'));
75
- httpClient.requestInternal(protocol, type1options, objs, callback);
76
- }
77
- sendType3Message(httpClient, protocol, options, objs, keepaliveAgent, res, callback) {
78
- if (!res.headers['www-authenticate']) {
79
- return callback(new Error('www-authenticate not found on response of second request'));
80
- }
81
- var type2msg = ntlm.parseType2Message(res.headers['www-authenticate']);
82
- var type3msg = ntlm.createType3Message(type2msg, options);
83
- var type3options = {
84
- headers: {
85
- 'Authorization': type3msg
86
- },
87
- allowRedirects: false,
88
- agent: keepaliveAgent
89
- };
90
- type3options.headers = _.extend(type3options.headers, options.headers);
91
- type3options = _.extend(type3options, _.omit(options, 'headers'));
92
- httpClient.requestInternal(protocol, type3options, objs, callback);
93
- }
94
- }
95
- exports.NtlmCredentialHandler = NtlmCredentialHandler;
96
- //# sourceMappingURL=ntlm.js.map
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
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PersonalAccessTokenCredentialHandler = void 0;
4
- class PersonalAccessTokenCredentialHandler {
5
- constructor(token) {
6
- this.token = token;
7
- }
8
- prepareRequest(options) {
9
- options.headers['Authorization'] = 'Basic ' + new Buffer('PAT:' + this.token).toString('base64');
10
- options.headers['X-TFS-FedAuthRedirect'] = 'Suppress';
11
- }
12
- canHandleAuthentication(res) {
13
- return false;
14
- }
15
- handleAuthentication(httpClient, protocol, options, objs, finalCallback) {
16
- }
17
- }
18
- exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
19
- //# sourceMappingURL=personalaccesstoken.js.map
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
+ //
@@ -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
+ }
@@ -1,60 +1,60 @@
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.WebClient = void 0;
13
- const httpm = require("./typed-rest-client/HttpClient");
14
- var tl = require('azure-pipelines-task-lib/task');
15
- var packagejson = require('../package.json');
16
- class WebClient {
17
- constructor(handlers, options) {
18
- this.httpc = new httpm.HttpClient('artifact-engine ' + packagejson.version, handlers, options);
19
- }
20
- get(requestUrl, additionalHeaders) {
21
- var promise = new Promise((resolve, reject) => {
22
- this.httpc.get(requestUrl, additionalHeaders).then((res) => {
23
- this.processResponse(res).then(() => {
24
- resolve(res);
25
- }, (err) => {
26
- reject(err);
27
- });
28
- }, (err) => {
29
- reject(err);
30
- });
31
- });
32
- return promise;
33
- }
34
- dispose() {
35
- this.httpc.dispose();
36
- }
37
- processResponse(res) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- const statusCode = res.message.statusCode;
40
- let err;
41
- if (statusCode > 299) {
42
- let obj;
43
- var msg = tl.loc("FailedRequest", statusCode);
44
- err = new Error(msg);
45
- err['statusCode'] = statusCode;
46
- try {
47
- let result = yield res.readBody();
48
- err['result'] = result;
49
- }
50
- catch (error) {
51
- }
52
- }
53
- if (!!err) {
54
- throw err;
55
- }
56
- });
57
- }
58
- }
59
- exports.WebClient = WebClient;
60
- //# sourceMappingURL=webClient.js.map
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
+ }