mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08: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;
|