From fd64ffadb970cdbc0a465fb51561b09bbf2e313a Mon Sep 17 00:00:00 2001 From: Hrishikesh Vaipurkar Date: Sun, 23 Jun 2024 19:32:10 +0200 Subject: [PATCH] feat: WEB-210 Testing logs for node_options --- netlify.toml | 2 ++ server/routers/utils/encryptValue.ts | 32 ++++++++++++++++------------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/netlify.toml b/netlify.toml index ce2835057..f904f5e1e 100644 --- a/netlify.toml +++ b/netlify.toml @@ -4,6 +4,8 @@ publish = ".next" [context.branch-deploy] command = "npm run lint && npm run build" +[context.branch-deploy.environment] +NODE_OPTIONS = "--openssl-legacy-provider" [context.deploy-preview] command = "npm run lint && npm run build" diff --git a/server/routers/utils/encryptValue.ts b/server/routers/utils/encryptValue.ts index f934825cc..e83d611b0 100644 --- a/server/routers/utils/encryptValue.ts +++ b/server/routers/utils/encryptValue.ts @@ -3,18 +3,22 @@ import crypto from "crypto" import { env } from "@/env/server" export default function encryptValue(originalString: string) { - const encryptionKey = env.BOOKING_ENCRYPTION_KEY - const bufferKey = Buffer.from(encryptionKey, "utf8") - let cipher = crypto.createCipheriv("DES-ECB", bufferKey, null) - cipher.setAutoPadding(false) - let bufferString = Buffer.from(originalString, "utf8") - let paddingSize = bufferKey.length - (bufferString.length % bufferKey.length) - let paddedStr = Buffer.concat([bufferString, Buffer.alloc(paddingSize, 0)]) - let encryptedValue = cipher - .update(paddedStr) - .toString("base64") - .replace(/\+/g, "-") - cipher.final() - - return encryptedValue + let result = "" + console.log(process.env.NODE_OPTIONS) + try { + const encryptionKey = env.BOOKING_ENCRYPTION_KEY + const bufferKey = Buffer.from(encryptionKey, "utf8") + let cipher = crypto.createCipheriv("DES-ECB", bufferKey, null) + cipher.setAutoPadding(false) + let bufferString = Buffer.from(originalString, "utf8") + let paddingSize = + bufferKey.length - (bufferString.length % bufferKey.length) + let paddedStr = Buffer.concat([bufferString, Buffer.alloc(paddingSize, 0)]) + result = cipher.update(paddedStr).toString("base64").replace(/\+/g, "-") + cipher.final() + } catch (e) { + console.log(e) + result = "error" + } + return result }