Skip to content

Commit

Permalink
fix: added variables in import metadata interface
Browse files Browse the repository at this point in the history
Signed-off-by: bhavanakarwade <[email protected]>
  • Loading branch information
bhavanakarwade committed Dec 17, 2024
1 parent cb5c35c commit a3a8b02
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/api/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/app/LayoutCommon.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -105,4 +105,4 @@ const refreshToken = getFromCookies(Astro.cookies, 'refresh');
}
</style>
</body>
</html>
</html>
24 changes: 24 additions & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a3a8b02

Please sign in to comment.