mirror of
https://github.com/microsoft/setup-msbuild.git
synced 2024-11-10 14:01:06 +07:00
56 lines
1.8 KiB
JavaScript
56 lines
1.8 KiB
JavaScript
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
class BasicCredentialHandler {
|
||
|
constructor(username, password) {
|
||
|
this.username = username;
|
||
|
this.password = password;
|
||
|
}
|
||
|
prepareRequest(options) {
|
||
|
options.headers['Authorization'] = 'Basic ' + Buffer.from(this.username + ':' + this.password).toString('base64');
|
||
|
}
|
||
|
// This handler cannot handle 401
|
||
|
canHandleAuthentication(response) {
|
||
|
return false;
|
||
|
}
|
||
|
handleAuthentication(httpClient, requestInfo, objs) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
exports.BasicCredentialHandler = BasicCredentialHandler;
|
||
|
class BearerCredentialHandler {
|
||
|
constructor(token) {
|
||
|
this.token = token;
|
||
|
}
|
||
|
// currently implements pre-authorization
|
||
|
// TODO: support preAuth = false where it hooks on 401
|
||
|
prepareRequest(options) {
|
||
|
options.headers['Authorization'] = 'Bearer ' + this.token;
|
||
|
}
|
||
|
// This handler cannot handle 401
|
||
|
canHandleAuthentication(response) {
|
||
|
return false;
|
||
|
}
|
||
|
handleAuthentication(httpClient, requestInfo, objs) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
exports.BearerCredentialHandler = BearerCredentialHandler;
|
||
|
class PersonalAccessTokenCredentialHandler {
|
||
|
constructor(token) {
|
||
|
this.token = token;
|
||
|
}
|
||
|
// currently implements pre-authorization
|
||
|
// TODO: support preAuth = false where it hooks on 401
|
||
|
prepareRequest(options) {
|
||
|
options.headers['Authorization'] = 'Basic ' + Buffer.from('PAT:' + this.token).toString('base64');
|
||
|
}
|
||
|
// This handler cannot handle 401
|
||
|
canHandleAuthentication(response) {
|
||
|
return false;
|
||
|
}
|
||
|
handleAuthentication(httpClient, requestInfo, objs) {
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|