IO-2921 Adjustment for SFTP Private Key

Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
This commit is contained in:
Allan Carr
2024-11-05 11:02:18 -08:00
parent 73ab02225e
commit 542997b1a7

View File

@@ -135,7 +135,6 @@ exports.default = async (req, res) => {
logger.log("chatter-sftp-error", "ERROR", "api", null, { ...error }); logger.log("chatter-sftp-error", "ERROR", "api", null, { ...error });
} finally { } finally {
sftp.end(); sftp.end();
}
sendServerEmail({ sendServerEmail({
subject: `Chatter Report ${moment().format("MM-DD-YY")}`, subject: `Chatter Report ${moment().format("MM-DD-YY")}`,
text: `Errors: ${allErrors.map((e) => JSON.stringify(e, null, 2))} text: `Errors: ${allErrors.map((e) => JSON.stringify(e, null, 2))}
@@ -146,6 +145,7 @@ exports.default = async (req, res) => {
)}` )}`
}); });
res.sendStatus(200); res.sendStatus(200);
}
} catch (error) { } catch (error) {
res.status(200).json(error); res.status(200).json(error);
} }
@@ -160,8 +160,8 @@ async function getPrivateKey() {
try { try {
const { SecretString, SecretBinary } = await client.send(command); const { SecretString, SecretBinary } = await client.send(command);
if (SecretString || SecretBinary) logger.log("chatter-retrieved-private-key", "DEBUG", "api", null, null); if (SecretString || SecretBinary) logger.log("chatter-retrieved-private-key", "DEBUG", "api", null, null);
const chatterPrivateKey = SecretString ? JSON.parse(SecretString) : JSON.parse(Buffer.from(SecretBinary, "base64").toString("ascii")); const chatterPrivateKey = SecretString ? SecretString : Buffer.from(SecretBinary, "base64").toString("ascii");
return chatterPrivateKey.private_key; return chatterPrivateKey;
} catch (error) { } catch (error) {
logger.log("chatter-get-private-key", "ERROR", "api", null, error); logger.log("chatter-get-private-key", "ERROR", "api", null, error);
throw err; throw err;