diff --git a/src/api/Auth.ts b/src/api/Auth.ts index 880e6fbd..f45ca711 100644 --- a/src/api/Auth.ts +++ b/src/api/Auth.ts @@ -59,30 +59,6 @@ export const encryptData = async (value: any): Promise => { } }; -// **Decrypt Data** using AES-GCM with WebCrypto -// export const decryptData = async (value: string): Promise => { -// try { -// const CRYPTO_PRIVATE_KEY = `${envConfig.PUBLIC_CRYPTO_PRIVATE_KEY}`; -// const key = await getAesKey(CRYPTO_PRIVATE_KEY); - -// const [ivBase64, encryptedBase64] = value.split(':'); - -// const iv = base64ToUint8Array(ivBase64); -// const encryptedData = base64ToUint8Array(encryptedBase64); - -// const decryptedData = await crypto.subtle.decrypt( -// { name: 'AES-GCM', iv }, -// key, -// encryptedData -// ); - -// return DECODER.decode(new Uint8Array(decryptedData)); -// } catch (error) { -// console.error('Decryption error:', error); -// return ''; // Return an empty string to avoid app crashes -// } -// }; - export const decryptData = async (value: string): Promise => { try { const CRYPTO_PRIVATE_KEY = `${envConfig.PUBLIC_CRYPTO_PRIVATE_KEY}`; @@ -135,28 +111,6 @@ export const setToLocalStorage = async (key: string, value: any): Promise => { -// try { -// const encryptedValue = localStorage.getItem(key); -// if (!encryptedValue) { -// console.warn(`No value found in localStorage for key: ${key}`); -// return null; -// } - -// const decryptedValue = await decryptData(encryptedValue); -// try { -// return JSON.parse(decryptedValue); -// } catch { -// return decryptedValue; -// } -// } catch (error) { -// console.error(`Decryption error for key [${key}]:`, error); -// return null; -// } -// }; - - export const getFromLocalStorage = async (key: string): Promise => { try { const encryptedValue = localStorage.getItem(key); @@ -165,7 +119,6 @@ export const getFromLocalStorage = async (key: string): Promise => { return null; } - console.log(`Encrypted value retrieved from localStorage: ${encryptedValue}`); const decryptedValue = await decryptData(encryptedValue); try {