Permalink
Cannot retrieve contributors at this time
81 lines (81 sloc)
3.05 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/@actions/http-client/lib/auth.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | |
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | |
return new (P || (P = Promise))(function (resolve, reject) { | |
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | |
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | |
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | |
step((generator = generator.apply(thisArg, _arguments || [])).next()); | |
}); | |
}; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0; | |
class BasicCredentialHandler { | |
constructor(username, password) { | |
this.username = username; | |
this.password = password; | |
} | |
prepareRequest(options) { | |
if (!options.headers) { | |
throw Error('The request has no headers'); | |
} | |
options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`; | |
} | |
// This handler cannot handle 401 | |
canHandleAuthentication() { | |
return false; | |
} | |
handleAuthentication() { | |
return __awaiter(this, void 0, void 0, function* () { | |
throw new Error('not implemented'); | |
}); | |
} | |
} | |
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) { | |
if (!options.headers) { | |
throw Error('The request has no headers'); | |
} | |
options.headers['Authorization'] = `Bearer ${this.token}`; | |
} | |
// This handler cannot handle 401 | |
canHandleAuthentication() { | |
return false; | |
} | |
handleAuthentication() { | |
return __awaiter(this, void 0, void 0, function* () { | |
throw new Error('not implemented'); | |
}); | |
} | |
} | |
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) { | |
if (!options.headers) { | |
throw Error('The request has no headers'); | |
} | |
options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`; | |
} | |
// This handler cannot handle 401 | |
canHandleAuthentication() { | |
return false; | |
} | |
handleAuthentication() { | |
return __awaiter(this, void 0, void 0, function* () { | |
throw new Error('not implemented'); | |
}); | |
} | |
} | |
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler; | |
//# sourceMappingURL=auth.js.map |