From a3a8b021ec6433744eb6cbc0ba4fe00af15f8d3f Mon Sep 17 00:00:00 2001 From: bhavanakarwade Date: Tue, 17 Dec 2024 17:30:59 +0530 Subject: [PATCH] fix: added variables in import metadata interface Signed-off-by: bhavanakarwade --- src/api/Auth.ts | 6 +++--- src/app/LayoutCommon.astro | 4 ++-- src/env.d.ts | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/api/Auth.ts b/src/api/Auth.ts index 45e158e80..86e3554f3 100644 --- a/src/api/Auth.ts +++ b/src/api/Auth.ts @@ -221,14 +221,14 @@ export const addPasskeyUserDetails = async(payload: AddPassword, email:string) = } export const passwordEncryption = (password: string): string => { - const CRYPTO_PRIVATE_KEY: string = `${envConfig.PUBLIC_CRYPTO_PRIVATE_KEY}` + const CRYPTO_PRIVATE_KEY: string = import.meta.env.PUBLIC_CRYPTO_PRIVATE_KEY; const encryptedPassword: string = CryptoJS.AES.encrypt(JSON.stringify(password), CRYPTO_PRIVATE_KEY).toString() return encryptedPassword } export const encryptData = (value: any): string => { - const CRYPTO_PRIVATE_KEY: string = `${envConfig.PUBLIC_CRYPTO_PRIVATE_KEY}` + const CRYPTO_PRIVATE_KEY = import.meta.env.PUBLIC_CRYPTO_PRIVATE_KEY; try { if (typeof (value) !== 'string') { @@ -243,7 +243,7 @@ export const encryptData = (value: any): string => { } export const decryptData = (value: any): string => { - const CRYPTO_PRIVATE_KEY: string = `${envConfig.PUBLIC_CRYPTO_PRIVATE_KEY}` + const CRYPTO_PRIVATE_KEY: string = import.meta.env.PUBLIC_CRYPTO_PRIVATE_KEY; try { let bytes = CryptoJS.AES.decrypt(value, CRYPTO_PRIVATE_KEY); diff --git a/src/app/LayoutCommon.astro b/src/app/LayoutCommon.astro index 8b125d24d..3be44d16a 100644 --- a/src/app/LayoutCommon.astro +++ b/src/app/LayoutCommon.astro @@ -15,7 +15,7 @@ const excludeKeys = ['PUBLIC_CRYPTO_PRIVATE_KEY', 'PUBLIC_KEYCLOAK_MANAGEMENT_CL const envKeys = allEnvKeys.filter((key) => !excludeKeys.includes(key)); envKeys.forEach((item) => { - initData[item] = process.env[item] || import.meta.env[item]; + initData[item] = process.env[item] || import.meta.env[item]; }); const sessionToken = getFromCookies(Astro.cookies, 'session'); @@ -105,4 +105,4 @@ const refreshToken = getFromCookies(Astro.cookies, 'refresh'); } - + \ No newline at end of file diff --git a/src/env.d.ts b/src/env.d.ts index 0b6428c56..640fe1127 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -5,6 +5,30 @@ interface ImportMetaEnv { readonly SITE: string; readonly PUBLIC_BASE_URL:string; + readonly PUBLIC_CRYPTO_PRIVATE_KEY: string; + readonly PUBLIC_ECOSYSTEM_BASE_URL: string; + readonly PUBLIC_REDIRECT_FROM_URL: string; + readonly PUBLIC_POLYGON_TESTNET_URL: string; + readonly PUBLIC_POLYGON_MAINNET_URL: string; + readonly PUBLIC_SHOW_NAME_AS_LOGO: string; + readonly PUBLIC_PLATFORM_NAME: string, + readonly PUBLIC_PLATFORM_LOGO: string, + readonly PUBLIC_POWERED_BY: string, + readonly PUBLIC_PLATFORM_WEB_URL: string, + readonly PUBLIC_POWERED_BY_URL: string, + readonly PUBLIC_PLATFORM_DOCS_URL: string, + readonly PUBLIC_PLATFORM_GIT: string, + readonly PUBLIC_PLATFORM_SUPPORT_EMAIL: string, + readonly PUBLIC_PLATFORM_TWITTER_URL: string, + readonly PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID: string, + readonly PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET: string, + readonly PUBLIC_PLATFORM_SUPPORT_INVITE: string, + readonly PUBLIC_PLATFORM_DISCORD_URL: string, + readonly PUBLIC_ALLOW_DOMAIN: string, + readonly PUBLIC_ECOSYSTEM_BASE_URL: string, + readonly PUBLIC_MODE: string, + readonly PUBLIC_REDIRECT_FROM_URL: string, + readonly PUBLIC_REDIRECTION_TARGET_URL: string } interface ImportMeta {