@unito/integration-cli
Version:
Integration CLI
26 lines (25 loc) • 974 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchCredential = fetchCredential;
const tslib_1 = require("tslib");
const errors_1 = require("../errors");
const GlobalConfiguration = tslib_1.__importStar(require("./globalConfiguration"));
const integrationsPlatform_1 = require("./integrationsPlatform");
const integrationsPlatform_2 = require("../services/integrationsPlatform");
async function fetchCredential(environment, configDir, credentialId) {
const globalConfiguration = await GlobalConfiguration.read(configDir);
try {
await (0, integrationsPlatform_1.validateAuthenticated)(globalConfiguration, environment);
}
catch {
throw new errors_1.CredentialAuthenticationError();
}
let credential;
try {
credential = await (0, integrationsPlatform_2.getCredential)(credentialId);
}
catch {
throw new errors_1.CredentialAccessDenied();
}
return credential;
}