I'm using Expo Secure Store to store JWT credentials from Supabase:
const ExpoSecureStoreAdapter = {
getItem: (key: string) => {
return SecureStore.getItemAsync(key);
},
setItem: (key: string, value: string) => {
SecureStore.setItemAsync(key, value);
},
removeItem: (key: string) => {
SecureStore.deleteItemAsync(key);
},
};
Which works well for iOS / Android, but is not supported for Expo Web. Therefore, I'm using localStorage
for web clients instead:
const WebLocalStorageAdapter = {
getItem: async (key: string) => {
return localStorage.getItem(key);
},
setItem: async (key: string, value: string) => {
return localStorage.setItem(key, value);
},
removeItem: async (key: string) => {
return localStorage.removeItem(key);
},
}
Then just handling web if needed:
const isWeb = Platform.OS === 'web';
const storageAdapter = isWeb ? WebLocalStorageAdapter : ExpoSecureStoreAdapter;
Is this advisable, or am I opening up an attack vector I'm unaware of, or other issues?