2020-01-17 01:36:42 -07:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
class BasicCredentialHandler {
|
|
|
|
constructor(username, password) {
|
|
|
|
this.username = username;
|
|
|
|
this.password = password;
|
|
|
|
}
|
|
|
|
prepareRequest(options) {
|
2020-01-24 02:14:21 -07:00
|
|
|
options.headers['Authorization'] = 'Basic ' + Buffer.from(this.username + ':' + this.password).toString('base64');
|
2020-01-17 01:36:42 -07:00
|
|
|
}
|
|
|
|
// 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) {
|
2020-01-24 02:14:21 -07:00
|
|
|
options.headers['Authorization'] = 'Basic ' + Buffer.from('PAT:' + this.token).toString('base64');
|
2020-01-17 01:36:42 -07:00
|
|
|
}
|
|
|
|
// This handler cannot handle 401
|
|
|
|
canHandleAuthentication(response) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
handleAuthentication(httpClient, requestInfo, objs) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|