Skip to content

Commit

Permalink
removed commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavanakarwade committed Dec 11, 2024
1 parent 44b8ec8 commit e02ea8d
Showing 1 changed file with 0 additions and 47 deletions.
47 changes: 0 additions & 47 deletions src/api/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,6 @@ export const encryptData = async (value: any): Promise<string> => {
}
};

// **Decrypt Data** using AES-GCM with WebCrypto
// export const decryptData = async (value: string): Promise<string> => {
// 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<string> => {
try {
const CRYPTO_PRIVATE_KEY = `${envConfig.PUBLIC_CRYPTO_PRIVATE_KEY}`;
Expand Down Expand Up @@ -135,28 +111,6 @@ export const setToLocalStorage = async (key: string, value: any): Promise<boolea
}
};

// **Get from Local Storage** (Decrypt and Return)
// export const getFromLocalStorage = async (key: string): Promise<any> => {
// 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<any> => {
try {
const encryptedValue = localStorage.getItem(key);
Expand All @@ -165,7 +119,6 @@ export const getFromLocalStorage = async (key: string): Promise<any> => {
return null;
}

console.log(`Encrypted value retrieved from localStorage: ${encryptedValue}`);
const decryptedValue = await decryptData(encryptedValue);

try {
Expand Down

0 comments on commit e02ea8d

Please sign in to comment.