Node v6
Starting with v0.19 Astro must be used with Node v6+!
Menu

Secure Store Plugin

The secure store plugin allows you to securely store and retrieve items. It is currently best suited for storing cryptographic keys, but is also able to store other types of data.

On iOS, the items are stored in the system keychain and are decrypted and available for use only when the device is unlocked. Note that multiple instances of the secure store plugin are backed by the same system store.

On Android, the items are stored in a shared preference file that is created specifically for secure store plugin. This shared preference file is protected so that only the app that creates it may access it. The items are encrypted with a generated asymmetric key. The asymmetric key is stored in Android's KeyStore system. Note that multiple instances of the secure store plugin are backed by the same system store.

On some older Android devices (ex. Samsung S3) the Android Keystore can become corrupted and then the secure store becomes unusable. In this case SecureStorePlugin.init() throws an exception and a SecureStorePlugin cannot be instantiated. An alternative is to use the SettingsStore to store data which needs to be persisted but is not sensitive information (SettingsStore is not secure).

The secure store plugin is useful if you need to store data that is accessible only while the app is in the foreground and that does not migrate to a new device. One example use is to securely store OAuth tokens.

Sample Usage

const secureStore = await SecureStorePlugin.init()
await secureStore.set('some key', 'some super secret value')
const response = await secureStore.get('some key')
alert('Retrieved value: ' + response) //'some super secret value'

Methods

SecureStorePlugin.init() #

Creates and returns a promise that resolves to an instance of the secure store plugin. Throws an exception if SecureStorePlugin not available on the device.

const secureStorePromise = SecureStorePlugin.init()

set(key, value) #

Sets an item in the secure store. Returns a promise that resolves to the result of the setting operation.

await secureStore.set('value', 'key')
//Value was successfully set

get(key) #

Gets an item from the secure store. Returns a promise that resolves to the value of the item with the given key in the secure store.

const response = await secureStore.get('some key')
alert('Retrieved value: ' + response)

delete(key) #

Deletes an item with the given key from the secure store. Returns a promise that resolves once the value has been deleted.

const key = "some key";
await secureStore.delete(key)
alert('Deleted value for key: "' + key + '"')

clear() #

Clears all items in the secure store. Returns a promise that resolves once the store has been cleared.

await secureStore.clear()
alert('Cleared all items from store.');