Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: decryption errors

Andras Bacsai9b67a253f1b3
diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts
index c9ce0e6df4..a2b78bf508 100644
--- a/apps/api/src/lib/common.ts
+++ b/apps/api/src/lib/common.ts
@@ -96,17 +96,23 @@ export const base64Decode = (text: string): string => {
};
export const decrypt = (hashString: string) => {
if (hashString) {
- const hash = JSON.parse(hashString);
- const decipher = crypto.createDecipheriv(
- algorithm,
- process.env['COOLIFY_SECRET_KEY'],
- Buffer.from(hash.iv, 'hex')
- );
- const decrpyted = Buffer.concat([
- decipher.update(Buffer.from(hash.content, 'hex')),
- decipher.final()
- ]);
- return decrpyted.toString();
+ try {
+ const hash = JSON.parse(hashString);
+ const decipher = crypto.createDecipheriv(
+ algorithm,
+ process.env['COOLIFY_SECRET_KEY'],
+ Buffer.from(hash.iv, 'hex')
+ );
+ const decrpyted = Buffer.concat([
+ decipher.update(Buffer.from(hash.content, 'hex')),
+ decipher.final()
+ ]);
+ return decrpyted.toString();
+ } catch (error) {
+ console.log({ decryptionError: error.message })
+ return hashString
+ }
+
}
};
export const encrypt = (text: string) => {