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.
- package/Providers/filesystemProvider.js +17 -1
- package/Providers/jenkins.handlebars +10 -10
- package/Providers/teamcity.handlebars +24 -24
- package/Providers/vsts.handlebars +15 -15
- package/Providers/webClient.d.ts +1 -1
- package/Providers/webClient.js +1 -1
- package/Providers/webClientFactory.js +7 -7
- package/Providers/webProvider.d.ts +7 -1
- package/Providers/webProvider.js +5 -0
- package/Providers/zipProvider.d.ts +1 -1
- package/README.md +40 -39
- 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 -11
- package/Providers/typed-rest-client/HttpClient.d.ts +0 -87
- package/Providers/typed-rest-client/HttpClient.js +0 -353
- package/Providers/typed-rest-client/Index.d.ts +0 -1
- package/Providers/typed-rest-client/Index.js +0 -2
- package/Providers/typed-rest-client/Interfaces.d.ts +0 -39
- package/Providers/typed-rest-client/Interfaces.js +0 -3
- package/Providers/typed-rest-client/RestClient.d.ts +0 -74
- package/Providers/typed-rest-client/RestClient.js +0 -188
- package/Providers/typed-rest-client/Util.d.ts +0 -7
- package/Providers/typed-rest-client/Util.js +0 -25
- package/Providers/typed-rest-client/handlers/basiccreds.d.ts +0 -9
- package/Providers/typed-rest-client/handlers/basiccreds.js +0 -24
- package/Providers/typed-rest-client/handlers/bearertoken.d.ts +0 -8
- package/Providers/typed-rest-client/handlers/bearertoken.js +0 -23
- package/Providers/typed-rest-client/handlers/ntlm.d.ts +0 -13
- package/Providers/typed-rest-client/handlers/ntlm.js +0 -127
- package/Providers/typed-rest-client/handlers/personalaccesstoken.d.ts +0 -8
- package/Providers/typed-rest-client/handlers/personalaccesstoken.js +0 -23
- package/Providers/typed-rest-client/opensource/node-http-ntlm/ntlm.js +0 -386
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import httpm = require('./HttpClient');
|
|
3
|
-
import ifm = require("./Interfaces");
|
|
4
|
-
export interface IRestResponse<T> {
|
|
5
|
-
statusCode: number;
|
|
6
|
-
result: T;
|
|
7
|
-
}
|
|
8
|
-
export interface IRequestOptions {
|
|
9
|
-
acceptHeader?: string;
|
|
10
|
-
additionalHeaders?: ifm.IHeaders;
|
|
11
|
-
responseProcessor?: Function;
|
|
12
|
-
}
|
|
13
|
-
export declare class RestClient {
|
|
14
|
-
client: httpm.HttpClient;
|
|
15
|
-
versionParam: string;
|
|
16
|
-
/**
|
|
17
|
-
* Creates an instance of the RestClient
|
|
18
|
-
* @constructor
|
|
19
|
-
* @param {string} userAgent - userAgent for requests
|
|
20
|
-
* @param {string} baseUrl - (Optional) If not specified, use full urls per request. If supplied and a function passes a relative url, it will be appended to this
|
|
21
|
-
* @param {ifm.IRequestHandler[]} handlers - handlers are typically auth handlers (basic, bearer, ntlm supplied)
|
|
22
|
-
* @param {ifm.IRequestOptions} requestOptions - options for each http requests (http proxy setting, socket timeout)
|
|
23
|
-
*/
|
|
24
|
-
constructor(userAgent: string, baseUrl?: string, handlers?: ifm.IRequestHandler[], requestOptions?: ifm.IRequestOptions);
|
|
25
|
-
private _baseUrl;
|
|
26
|
-
/**
|
|
27
|
-
* Gets a resource from an endpoint
|
|
28
|
-
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
29
|
-
* @param {string} requestUrl - fully qualified or relative url
|
|
30
|
-
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
31
|
-
*/
|
|
32
|
-
options<T>(requestUrl: string, options?: IRequestOptions): Promise<IRestResponse<T>>;
|
|
33
|
-
/**
|
|
34
|
-
* Gets a resource from an endpoint
|
|
35
|
-
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
36
|
-
* @param {string} requestUrl - fully qualified or relative url
|
|
37
|
-
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
38
|
-
*/
|
|
39
|
-
get<T>(requestUrl: string, options?: IRequestOptions): Promise<IRestResponse<T>>;
|
|
40
|
-
/**
|
|
41
|
-
* Deletes a resource from an endpoint
|
|
42
|
-
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
43
|
-
* @param {string} requestUrl - fully qualified or relative url
|
|
44
|
-
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
45
|
-
*/
|
|
46
|
-
del<T>(requestUrl: string, options?: IRequestOptions): Promise<IRestResponse<T>>;
|
|
47
|
-
/**
|
|
48
|
-
* Creates resource(s) from an endpoint
|
|
49
|
-
* T type of object returned.
|
|
50
|
-
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
51
|
-
* @param {string} requestUrl - fully qualified or relative url
|
|
52
|
-
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
53
|
-
*/
|
|
54
|
-
create<T>(requestUrl: string, resources: any, options?: IRequestOptions): Promise<IRestResponse<T>>;
|
|
55
|
-
/**
|
|
56
|
-
* Updates resource(s) from an endpoint
|
|
57
|
-
* T type of object returned.
|
|
58
|
-
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
59
|
-
* @param {string} requestUrl - fully qualified or relative url
|
|
60
|
-
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
61
|
-
*/
|
|
62
|
-
update<T>(requestUrl: string, resources: any, options?: IRequestOptions): Promise<IRestResponse<T>>;
|
|
63
|
-
/**
|
|
64
|
-
* Replaces resource(s) from an endpoint
|
|
65
|
-
* T type of object returned.
|
|
66
|
-
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
67
|
-
* @param {string} requestUrl - fully qualified or relative url
|
|
68
|
-
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
69
|
-
*/
|
|
70
|
-
replace<T>(requestUrl: string, resources: any, options?: IRequestOptions): Promise<IRestResponse<T>>;
|
|
71
|
-
uploadStream<T>(verb: string, requestUrl: string, stream: NodeJS.ReadableStream, options?: IRequestOptions): Promise<IRestResponse<T>>;
|
|
72
|
-
private _headersFromOptions;
|
|
73
|
-
private _processResponse;
|
|
74
|
-
}
|
|
@@ -1,188 +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.RestClient = void 0;
|
|
15
|
-
const httpm = require("./HttpClient");
|
|
16
|
-
const util = require("./Util");
|
|
17
|
-
class RestClient {
|
|
18
|
-
/**
|
|
19
|
-
* Creates an instance of the RestClient
|
|
20
|
-
* @constructor
|
|
21
|
-
* @param {string} userAgent - userAgent for requests
|
|
22
|
-
* @param {string} baseUrl - (Optional) If not specified, use full urls per request. If supplied and a function passes a relative url, it will be appended to this
|
|
23
|
-
* @param {ifm.IRequestHandler[]} handlers - handlers are typically auth handlers (basic, bearer, ntlm supplied)
|
|
24
|
-
* @param {ifm.IRequestOptions} requestOptions - options for each http requests (http proxy setting, socket timeout)
|
|
25
|
-
*/
|
|
26
|
-
constructor(userAgent, baseUrl, handlers, requestOptions) {
|
|
27
|
-
this.client = new httpm.HttpClient(userAgent, handlers, requestOptions);
|
|
28
|
-
if (baseUrl) {
|
|
29
|
-
this._baseUrl = baseUrl;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Gets a resource from an endpoint
|
|
34
|
-
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
35
|
-
* @param {string} requestUrl - fully qualified or relative url
|
|
36
|
-
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
37
|
-
*/
|
|
38
|
-
options(requestUrl, options) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
let url = util.getUrl(requestUrl, this._baseUrl);
|
|
41
|
-
let res = yield this.client.options(url, this._headersFromOptions(options));
|
|
42
|
-
return this._processResponse(res, options);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Gets a resource from an endpoint
|
|
47
|
-
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
48
|
-
* @param {string} requestUrl - fully qualified or relative url
|
|
49
|
-
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
50
|
-
*/
|
|
51
|
-
get(requestUrl, options) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
let url = util.getUrl(requestUrl, this._baseUrl);
|
|
54
|
-
let res = yield this.client.get(url, this._headersFromOptions(options));
|
|
55
|
-
return this._processResponse(res, options);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Deletes a resource from an endpoint
|
|
60
|
-
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
61
|
-
* @param {string} requestUrl - fully qualified or relative url
|
|
62
|
-
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
63
|
-
*/
|
|
64
|
-
del(requestUrl, options) {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
let url = util.getUrl(requestUrl, this._baseUrl);
|
|
67
|
-
let res = yield this.client.del(url, this._headersFromOptions(options));
|
|
68
|
-
return this._processResponse(res, options);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Creates resource(s) from an endpoint
|
|
73
|
-
* T type of object returned.
|
|
74
|
-
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
75
|
-
* @param {string} requestUrl - fully qualified or relative url
|
|
76
|
-
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
77
|
-
*/
|
|
78
|
-
create(requestUrl, resources, options) {
|
|
79
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
let url = util.getUrl(requestUrl, this._baseUrl);
|
|
81
|
-
let headers = this._headersFromOptions(options, true);
|
|
82
|
-
let data = JSON.stringify(resources, null, 2);
|
|
83
|
-
let res = yield this.client.post(url, data, headers);
|
|
84
|
-
return this._processResponse(res, options);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Updates resource(s) from an endpoint
|
|
89
|
-
* T type of object returned.
|
|
90
|
-
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
91
|
-
* @param {string} requestUrl - fully qualified or relative url
|
|
92
|
-
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
93
|
-
*/
|
|
94
|
-
update(requestUrl, resources, options) {
|
|
95
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
let url = util.getUrl(requestUrl, this._baseUrl);
|
|
97
|
-
let headers = this._headersFromOptions(options, true);
|
|
98
|
-
let data = JSON.stringify(resources, null, 2);
|
|
99
|
-
let res = yield this.client.patch(url, data, headers);
|
|
100
|
-
return this._processResponse(res, options);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Replaces resource(s) from an endpoint
|
|
105
|
-
* T type of object returned.
|
|
106
|
-
* Be aware that not found returns a null. Other error conditions reject the promise
|
|
107
|
-
* @param {string} requestUrl - fully qualified or relative url
|
|
108
|
-
* @param {IRequestOptions} requestOptions - (optional) requestOptions object
|
|
109
|
-
*/
|
|
110
|
-
replace(requestUrl, resources, options) {
|
|
111
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
let url = util.getUrl(requestUrl, this._baseUrl);
|
|
113
|
-
let headers = this._headersFromOptions(options, true);
|
|
114
|
-
let data = JSON.stringify(resources, null, 2);
|
|
115
|
-
let res = yield this.client.put(url, data, headers);
|
|
116
|
-
return this._processResponse(res, options);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
uploadStream(verb, requestUrl, stream, options) {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
let url = util.getUrl(requestUrl, this._baseUrl);
|
|
122
|
-
let headers = this._headersFromOptions(options, true);
|
|
123
|
-
let res = yield this.client.sendStream(verb, url, stream, headers);
|
|
124
|
-
return this._processResponse(res, options);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
_headersFromOptions(options, contentType) {
|
|
128
|
-
options = options || {};
|
|
129
|
-
let headers = options.additionalHeaders || {};
|
|
130
|
-
headers["Accept"] = options.acceptHeader || "application/json";
|
|
131
|
-
if (contentType) {
|
|
132
|
-
headers["Content-Type"] = headers["Content-Type"] || 'application/json; charset=utf-8';
|
|
133
|
-
}
|
|
134
|
-
return headers;
|
|
135
|
-
}
|
|
136
|
-
_processResponse(res, options) {
|
|
137
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
let rres = {};
|
|
140
|
-
let statusCode = res.message.statusCode;
|
|
141
|
-
rres.statusCode = statusCode;
|
|
142
|
-
// not found leads to null obj returned
|
|
143
|
-
if (statusCode == httpm.HttpCodes.NotFound) {
|
|
144
|
-
resolve(rres);
|
|
145
|
-
}
|
|
146
|
-
let obj;
|
|
147
|
-
// get the result from the body
|
|
148
|
-
try {
|
|
149
|
-
let contents = yield res.readBody();
|
|
150
|
-
if (contents && contents.length > 0) {
|
|
151
|
-
obj = JSON.parse(contents);
|
|
152
|
-
if (options && options.responseProcessor) {
|
|
153
|
-
rres.result = options.responseProcessor(obj);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
rres.result = obj;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
catch (err) {
|
|
161
|
-
// Invalid resource (contents not json); leaving result obj null
|
|
162
|
-
}
|
|
163
|
-
// note that 3xx redirects are handled by the http layer.
|
|
164
|
-
if (statusCode > 299) {
|
|
165
|
-
let msg;
|
|
166
|
-
// if exception/error in body, attempt to get better error
|
|
167
|
-
if (obj && obj.message) {
|
|
168
|
-
msg = obj.message;
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
msg = "Failed request: (" + statusCode + ")";
|
|
172
|
-
}
|
|
173
|
-
let err = new Error(msg);
|
|
174
|
-
// attach statusCode and body obj (if available) to the error object
|
|
175
|
-
err['statusCode'] = statusCode;
|
|
176
|
-
if (rres.result) {
|
|
177
|
-
err['result'] = rres.result;
|
|
178
|
-
}
|
|
179
|
-
reject(err);
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
resolve(rres);
|
|
183
|
-
}
|
|
184
|
-
}));
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
exports.RestClient = RestClient;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* creates an url from a request url and optional base url (http://server:8080)
|
|
3
|
-
* @param {string} requestUrl - a fully qualified url or relative url
|
|
4
|
-
* @param {string} baseUrl - an optional baseUrl (http://server:8080)
|
|
5
|
-
* @return {string} - resultant url
|
|
6
|
-
*/
|
|
7
|
-
export declare function getUrl(requestUrl: string, baseUrl?: string): string;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUrl = void 0;
|
|
4
|
-
const url = require("url");
|
|
5
|
-
/**
|
|
6
|
-
* creates an url from a request url and optional base url (http://server:8080)
|
|
7
|
-
* @param {string} requestUrl - a fully qualified url or relative url
|
|
8
|
-
* @param {string} baseUrl - an optional baseUrl (http://server:8080)
|
|
9
|
-
* @return {string} - resultant url
|
|
10
|
-
*/
|
|
11
|
-
function getUrl(requestUrl, baseUrl) {
|
|
12
|
-
if (!baseUrl) {
|
|
13
|
-
return requestUrl;
|
|
14
|
-
}
|
|
15
|
-
let base = url.parse(baseUrl);
|
|
16
|
-
// requestUrl (specific per request) always wins
|
|
17
|
-
let combined = url.parse(requestUrl);
|
|
18
|
-
combined.protocol = combined.protocol || base.protocol;
|
|
19
|
-
combined.auth = combined.auth || base.auth;
|
|
20
|
-
combined.host = combined.host || base.host;
|
|
21
|
-
// path from requestUrl always wins
|
|
22
|
-
let res = url.format(combined);
|
|
23
|
-
return res;
|
|
24
|
-
}
|
|
25
|
-
exports.getUrl = getUrl;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import ifm = require('../Interfaces');
|
|
2
|
-
export declare class BasicCredentialHandler implements ifm.IRequestHandler {
|
|
3
|
-
username: string;
|
|
4
|
-
password: string;
|
|
5
|
-
constructor(username: string, password: string);
|
|
6
|
-
prepareRequest(options: any): void;
|
|
7
|
-
canHandleAuthentication(res: ifm.IHttpResponse): boolean;
|
|
8
|
-
handleAuthentication(httpClient: any, protocol: any, options: any, objs: any, finalCallback: any): void;
|
|
9
|
-
}
|
|
@@ -1,24 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.BasicCredentialHandler = void 0;
|
|
6
|
-
class BasicCredentialHandler {
|
|
7
|
-
constructor(username, password) {
|
|
8
|
-
this.username = username;
|
|
9
|
-
this.password = password;
|
|
10
|
-
}
|
|
11
|
-
// currently implements pre-authorization
|
|
12
|
-
// TODO: support preAuth = false where it hooks on 401
|
|
13
|
-
prepareRequest(options) {
|
|
14
|
-
options.headers['Authorization'] = 'Basic ' + Buffer.from(this.username + ':' + this.password, 'utf8').toString('base64');
|
|
15
|
-
options.headers['X-TFS-FedAuthRedirect'] = 'Suppress';
|
|
16
|
-
}
|
|
17
|
-
// This handler cannot handle 401
|
|
18
|
-
canHandleAuthentication(res) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
handleAuthentication(httpClient, protocol, options, objs, finalCallback) {
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.BasicCredentialHandler = BasicCredentialHandler;
|
|
@@ -1,8 +0,0 @@
|
|
|
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,23 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.BearerCredentialHandler = void 0;
|
|
6
|
-
class BearerCredentialHandler {
|
|
7
|
-
constructor(token) {
|
|
8
|
-
this.token = token;
|
|
9
|
-
}
|
|
10
|
-
// currently implements pre-authorization
|
|
11
|
-
// TODO: support preAuth = false where it hooks on 401
|
|
12
|
-
prepareRequest(options) {
|
|
13
|
-
options.headers['Authorization'] = 'Bearer ' + this.token;
|
|
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.BearerCredentialHandler = BearerCredentialHandler;
|
|
@@ -1,13 +0,0 @@
|
|
|
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,127 +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.NtlmCredentialHandler = void 0;
|
|
15
|
-
const http = require("http");
|
|
16
|
-
const https = require("https");
|
|
17
|
-
var _ = require("underscore");
|
|
18
|
-
var ntlm = require("../opensource/node-http-ntlm/ntlm");
|
|
19
|
-
class NtlmCredentialHandler {
|
|
20
|
-
constructor(username, password, domain, workstation) {
|
|
21
|
-
this.username = username;
|
|
22
|
-
this.password = password;
|
|
23
|
-
if (domain !== undefined) {
|
|
24
|
-
this.domain = domain;
|
|
25
|
-
}
|
|
26
|
-
if (workstation !== undefined) {
|
|
27
|
-
this.workstation = workstation;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
prepareRequest(options) {
|
|
31
|
-
// No headers or options need to be set. We keep the credentials on the handler itself.
|
|
32
|
-
// If a (proxy) agent is set, remove it as we don't support proxy for NTLM at this time
|
|
33
|
-
if (options.agent) {
|
|
34
|
-
delete options.agent;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
canHandleAuthentication(res) {
|
|
38
|
-
if (res && res.statusCode === 401) {
|
|
39
|
-
// Ensure that we're talking NTLM here
|
|
40
|
-
// Once we have the www-authenticate header, split it so we can ensure we can talk NTLM
|
|
41
|
-
var wwwAuthenticate = res.headers['www-authenticate'];
|
|
42
|
-
if (wwwAuthenticate !== undefined) {
|
|
43
|
-
var mechanisms = wwwAuthenticate.split(', ');
|
|
44
|
-
var idx = mechanisms.indexOf("NTLM");
|
|
45
|
-
if (idx >= 0) {
|
|
46
|
-
// Check specifically for 'NTLM' since www-authenticate header can also contain
|
|
47
|
-
// the Authorization value to use in the form of 'NTLM TlRMTVNT....AAAADw=='
|
|
48
|
-
if (mechanisms[idx].length == 4) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
// The following method is an adaptation of code found at https://github.com/SamDecrock/node-http-ntlm/blob/master/httpntlm.js
|
|
57
|
-
handleAuthentication(httpClient, protocol, options, objs, finalCallback) {
|
|
58
|
-
// Set up the headers for NTLM authentication
|
|
59
|
-
var ntlmOptions = _.extend(options, {
|
|
60
|
-
username: this.username,
|
|
61
|
-
password: this.password,
|
|
62
|
-
domain: this.domain || '',
|
|
63
|
-
workstation: this.workstation || ''
|
|
64
|
-
});
|
|
65
|
-
var keepaliveAgent;
|
|
66
|
-
if (httpClient.isSsl === true) {
|
|
67
|
-
keepaliveAgent = new https.Agent({});
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
keepaliveAgent = new http.Agent({ keepAlive: true });
|
|
71
|
-
}
|
|
72
|
-
let self = this;
|
|
73
|
-
// The following pattern of sending the type1 message following immediately (in a setImmediate) is
|
|
74
|
-
// critical for the NTLM exchange to happen. If we removed setImmediate (or call in a different manner)
|
|
75
|
-
// the NTLM exchange will always fail with a 401.
|
|
76
|
-
this.sendType1Message(httpClient, protocol, ntlmOptions, objs, keepaliveAgent, function (err, res) {
|
|
77
|
-
if (err) {
|
|
78
|
-
return finalCallback(err, null, null);
|
|
79
|
-
}
|
|
80
|
-
setImmediate(function () {
|
|
81
|
-
self.sendType3Message(httpClient, protocol, ntlmOptions, objs, keepaliveAgent, res, finalCallback);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
// The following method is an adaptation of code found at https://github.com/SamDecrock/node-http-ntlm/blob/master/httpntlm.js
|
|
86
|
-
sendType1Message(httpClient, protocol, options, objs, keepaliveAgent, callback) {
|
|
87
|
-
var type1msg = ntlm.createType1Message(options);
|
|
88
|
-
var type1options = {
|
|
89
|
-
headers: {
|
|
90
|
-
'Connection': 'keep-alive',
|
|
91
|
-
'Authorization': type1msg
|
|
92
|
-
},
|
|
93
|
-
timeout: options.timeout || 0,
|
|
94
|
-
agent: keepaliveAgent,
|
|
95
|
-
// don't redirect because http could change to https which means we need to change the keepaliveAgent
|
|
96
|
-
allowRedirects: false
|
|
97
|
-
};
|
|
98
|
-
type1options = _.extend(type1options, _.omit(options, 'headers'));
|
|
99
|
-
httpClient.requestInternal(protocol, type1options, objs, callback);
|
|
100
|
-
}
|
|
101
|
-
// The following method is an adaptation of code found at https://github.com/SamDecrock/node-http-ntlm/blob/master/httpntlm.js
|
|
102
|
-
sendType3Message(httpClient, protocol, options, objs, keepaliveAgent, res, callback) {
|
|
103
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
if (!res.headers['www-authenticate']) {
|
|
105
|
-
return callback(new Error('www-authenticate not found on response of second request'));
|
|
106
|
-
}
|
|
107
|
-
// parse type2 message from server:
|
|
108
|
-
var type2msg = ntlm.parseType2Message(res.headers['www-authenticate']);
|
|
109
|
-
// create type3 message:
|
|
110
|
-
var type3msg = yield ntlm.createType3Message(type2msg, options);
|
|
111
|
-
// build type3 request:
|
|
112
|
-
var type3options = {
|
|
113
|
-
headers: {
|
|
114
|
-
'Authorization': type3msg
|
|
115
|
-
},
|
|
116
|
-
allowRedirects: false,
|
|
117
|
-
agent: keepaliveAgent
|
|
118
|
-
};
|
|
119
|
-
// pass along other options:
|
|
120
|
-
type3options.headers = _.extend(type3options.headers, options.headers);
|
|
121
|
-
type3options = _.extend(type3options, _.omit(options, 'headers'));
|
|
122
|
-
// send type3 message to server:
|
|
123
|
-
httpClient.requestInternal(protocol, type3options, objs, callback);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
exports.NtlmCredentialHandler = NtlmCredentialHandler;
|
|
@@ -1,8 +0,0 @@
|
|
|
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,23 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.PersonalAccessTokenCredentialHandler = void 0;
|
|
6
|
-
class PersonalAccessTokenCredentialHandler {
|
|
7
|
-
constructor(token) {
|
|
8
|
-
this.token = token;
|
|
9
|
-
}
|
|
10
|
-
// currently implements pre-authorization
|
|
11
|
-
// TODO: support preAuth = false where it hooks on 401
|
|
12
|
-
prepareRequest(options) {
|
|
13
|
-
options.headers['Authorization'] = 'Basic ' + Buffer.from('PAT:' + this.token, 'utf8').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.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|