diff --git a/tdrive/backend/node/config/test.json b/tdrive/backend/node/config/test.json index 65aadc6f..682f49df 100644 --- a/tdrive/backend/node/config/test.json +++ b/tdrive/backend/node/config/test.json @@ -1,6 +1,6 @@ { "database": { - "secret": "ab63bb3e90c0271c9a1c06651a7c0967eab8851a7a897766", + "secret": "", "mongodb": { "uri": "mongodb://mongo:27017" }, diff --git a/tdrive/backend/node/src/core/crypto/index.ts b/tdrive/backend/node/src/core/crypto/index.ts index 417e7cad..05a5ae02 100644 --- a/tdrive/backend/node/src/core/crypto/index.ts +++ b/tdrive/backend/node/src/core/crypto/index.ts @@ -19,22 +19,26 @@ export type CryptoResult = { }; export function decrypt(data: string, encryptionKey: string): CryptoResult { - let result = v2.decrypt(data, encryptionKey); - if (result.done) { + if (encryptionKey) { + let result = v2.decrypt(data, encryptionKey); + if (result.done) { + return result; + } + + result = v1.decrypt(data, encryptionKey); + if (result.done) { + return result; + } + + result = legacy.decrypt(data, encryptionKey); + if (result.done) { + return result; + } + return result; } - result = v1.decrypt(data, encryptionKey); - if (result.done) { - return result; - } - - result = legacy.decrypt(data, encryptionKey); - if (result.done) { - return result; - } - - return result; + return { data, done: true }; } export function md5(value: string): string { @@ -46,5 +50,6 @@ export function encrypt( encryptionKey: any, options: { disableSalts?: boolean } = {}, ): CryptoResult { + if (!encryptionKey) return { data: `${value}`, done: true }; return v2.encrypt(value, encryptionKey, options); }