Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function publish(cmrFile, creds, bucket, stack) {
let password;
try {
password = await DefaultProvider.decrypt(creds.password, undefined, bucket, stack);
}
catch (e) {
log.error('Decrypting password failed, using unencrypted password');
password = creds.password;
}
const cmr = new CMR(
creds.provider,
creds.clientId,
creds.username,
password
);
const xml = await getMetadata(cmrFile.filename);
const res = await cmr.ingestGranule(xml);
const conceptId = res.result['concept-id'];
async removeGranuleFromCmr(granuleId, collectionId) {
log.info(`granules.removeGranuleFromCmr ${granuleId}`);
const password = await DefaultProvider.decrypt(process.env.cmr_password);
const cmr = new CMR(
process.env.cmr_provider,
process.env.cmr_client_id,
process.env.cmr_username,
password
);
await cmr.deleteGranule(granuleId, collectionId);
await this.update({ granuleId }, { published: false, cmrLink: null });
}