import * as SecureStore from "expo-secure-store"; import { Platform } from "react-native"; interface Storage { getItem(key: string): Promise; setItem(key: string, value: string): Promise; removeItem(key: string): Promise; } class WebStorage implements Storage { async getItem(key: string): Promise { if (typeof window === "undefined") return null; return window.localStorage.getItem(key); } async setItem(key: string, value: string): Promise { if (typeof window === "undefined") return; window.localStorage.setItem(key, value); } async removeItem(key: string): Promise { if (typeof window === "undefined") return; console.log(`[WebStorage] Removing key: ${key}`); window.localStorage.removeItem(key); console.log(`[WebStorage] Key removed. Verification:`, window.localStorage.getItem(key)); } } class NativeStorage implements Storage { async getItem(key: string): Promise { return await SecureStore.getItemAsync(key); } async setItem(key: string, value: string): Promise { await SecureStore.setItemAsync(key, value); } async removeItem(key: string): Promise { console.log(`[NativeStorage] Removing key: ${key}`); await SecureStore.deleteItemAsync(key); console.log(`[NativeStorage] Key removed`); } } export const storage: Storage = Platform.OS === "web" ? new WebStorage() : new NativeStorage();