From abe6eb79d83e6198985408a9e1430f6fe0cd9a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Tr=C3=A1vn=C3=ADk?= Date: Wed, 3 Dec 2025 23:25:53 +0100 Subject: [PATCH] removed duplicate isencrypted check as its handled inside encrypt already --- .../notifications/notifications.service.ts | 16 ++++++++-------- .../modules/repositories/repositories.service.ts | 16 +++------------- app/server/utils/crypto.ts | 5 ----- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/app/server/modules/notifications/notifications.service.ts b/app/server/modules/notifications/notifications.service.ts index 360bca2f..4099d8b4 100644 --- a/app/server/modules/notifications/notifications.service.ts +++ b/app/server/modules/notifications/notifications.service.ts @@ -38,42 +38,42 @@ async function encryptSensitiveFields(config: NotificationConfig): Promise { const encryptConfig = async (config: RepositoryConfig): Promise => { const encryptedConfig: Record = { ...config }; - if (config.customPassword && !cryptoUtils.isEncrypted(config.customPassword)) { + if (config.customPassword) { encryptedConfig.customPassword = await cryptoUtils.encrypt(config.customPassword); } switch (config.backend) { case "s3": case "r2": - if (!cryptoUtils.isEncrypted(config.accessKeyId)) { encryptedConfig.accessKeyId = await cryptoUtils.encrypt(config.accessKeyId); - } - if (!cryptoUtils.isEncrypted(config.secretAccessKey)) { encryptedConfig.secretAccessKey = await cryptoUtils.encrypt(config.secretAccessKey); - } break; case "gcs": - if (!cryptoUtils.isEncrypted(config.credentialsJson)) { encryptedConfig.credentialsJson = await cryptoUtils.encrypt(config.credentialsJson); - } break; case "azure": - if (!cryptoUtils.isEncrypted(config.accountKey)) { encryptedConfig.accountKey = await cryptoUtils.encrypt(config.accountKey); - } break; case "rest": - if (config.username && !cryptoUtils.isEncrypted(config.username)) { + if (config.username) { encryptedConfig.username = await cryptoUtils.encrypt(config.username); } - if (config.password && !cryptoUtils.isEncrypted(config.password)) { + if (config.password) { encryptedConfig.password = await cryptoUtils.encrypt(config.password); } break; case "sftp": - if (!cryptoUtils.isEncrypted(config.privateKey)) { encryptedConfig.privateKey = await cryptoUtils.encrypt(config.privateKey); - } break; } diff --git a/app/server/utils/crypto.ts b/app/server/utils/crypto.ts index 1ed05d2a..651bebe9 100644 --- a/app/server/utils/crypto.ts +++ b/app/server/utils/crypto.ts @@ -5,10 +5,6 @@ const algorithm = "aes-256-gcm" as const; const keyLength = 32; const encryptionPrefix = "encv1"; -const isEncrypted = (val?: string): boolean => { - return typeof val === "string" && val.startsWith(encryptionPrefix); -}; - /** * Given a string, encrypts it using a randomly generated salt */ @@ -62,5 +58,4 @@ const decrypt = async (encryptedData: string) => { export const cryptoUtils = { encrypt, decrypt, - isEncrypted, };