feat: WEB-210 Replaced custom env with process.env

This commit is contained in:
Hrishikesh Vaipurkar
2024-06-18 16:33:04 +02:00
parent 46da385950
commit 714d0d91f0
2 changed files with 7 additions and 1 deletions

4
env/server.ts vendored
View File

@@ -57,6 +57,8 @@ export const env = createEnv({
SEAMLESS_LOGOUT_NO: z.string(),
SEAMLESS_LOGOUT_SV: z.string(),
WEBVIEW_ENCRYPTION_KEY: z.string(),
BOOKING_ENCRYPTION_KEY: z.string(),
NODE_OPTIONS: z.string(),
},
emptyStringAsUndefined: true,
runtimeEnv: {
@@ -101,5 +103,7 @@ export const env = createEnv({
SEAMLESS_LOGOUT_NO: process.env.SEAMLESS_LOGOUT_NO,
SEAMLESS_LOGOUT_SV: process.env.SEAMLESS_LOGOUT_SV,
WEBVIEW_ENCRYPTION_KEY: process.env.WEBVIEW_ENCRYPTION_KEY,
BOOKING_ENCRYPTION_KEY: process.env.BOOKING_ENCRYPTION_KEY,
NODE_OPTIONS: process.env.NODE_OPTIONS,
},
})

View File

@@ -1,7 +1,9 @@
import crypto from "crypto"
import { env } from "@/env/server"
export default function encryptValue(originalString: string) {
const encryptionKey = process.env.BOOKING_ENCRYPTION_KEY ?? ""
const encryptionKey = env.BOOKING_ENCRYPTION_KEY
const bufferKey = Buffer.from(encryptionKey, "utf8")
let cipher = crypto.createCipheriv("DES-ECB", bufferKey, null)
cipher.setAutoPadding(false)