mirror of
https://github.com/ASzc/change-string-case-action.git
synced 2024-11-24 08:03:51 +08:00
59 lines
1.8 KiB
JavaScript
59 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;
|