martinkasa/capacitor-secure-storage-plugin

keys() returns key names with "cap_sec_" prefix on web platform

Closed this issue · 0 comments

Consider below code:

await SecureStoragePlugin.set({ key: 'key', value: 'value' })

const { value: keys } = await SecureStoragePlugin.keys()
// [ 'cap_sec_key' ]

await SecureStoragePlugin.get({ key: keys[0] })
// 'Item with given key does not exist'

It fails, because .keys() function returns keys with cap_sec_ prefix and .get() function adds the prefix again, so it looks for cap_sec_cap_sec_key instead of cap_sec_key.

This affects web platform only. The above code works fine on Android and iOS platforms.