The EncryptedStorage class is used as a secure local store.
As of version 3.0.3, the datavault managed by the Logon plugin is used to store the encryption keys. This means that no password needs to be provided to the EncrytedStorage plugin. The dependency on Logon's datavault means that Logon must be in an unlocked state for the EncryptedStorage functions to succeed.
If the datavault managed by the Logon plugin gets deleted (eg: the user forgets their passcode), then all encrypted stores will also be deleted.
Applications using EncryptedStorage plugin of version 3.0.2 need to be updated to remove the password parameter which only exists on 3.0.2 EncryptedStorage's constructor. Otherwise a javascript exception will be thrown. In addition, the data in encrypted storage needs to be recreated, as backward compatibility is not supported between encrypted storage versions 3.0.2 and 3.0.3.
Adding and Removing the EncryptedStorage Plugin
The EncryptedStorage plugin is added and removed using the Cordova CLI
To add the EncryptedStorage plugin to your project, use the following command:
cordova plugin add <path to directory containing Kapsel plugins>\encryptedstorage
To remove the EncryptedStorage plugin from your project, use the following command:
cordova plugin rm com.sap.mp.cordova.plugins.encryptedstorage
Name | Description |
COMPLEX_STRING_MAXIMUM_LENGTH | This constant is the length of the largest string that is guaranteed to be successfully stored on Android for plugin version 3.0.2 and earlier (as of version 3.0.3 this size restriction no longer applies). |
ERROR_BAD_PASSWORD | This error code indicates that the operation failed due to an incorrect password. |
ERROR_DATAVAULT_ACCESS_ERROR | This error indicates that the data vault access error. |
ERROR_DATAVAULT_LOCKED | This error indicates that the datavault managed by the Logon plugin is locked. |
ERROR_DB_ERROR | This error indicates that the SQLite database error. |
ERROR_GREATER_THAN_MAXIMUM_SIZE | This error indicates that the string was too large to store. |
ERROR_INVALID_PARAMETER | This error code indicates an invalid parameter was provided. |
ERROR_UNKNOWN | This error code indicates an unknown error occurred. |
SIMPLE_STRING_MAXIMUM_LENGTH | This constant is the length of the largest string that can successfully be stored on Android for plugin version 3.0.2 and earlier (as of version 3.0.3 this size restriction no longer applies). |
Name | Description |
clear( successCallback, errorCallback ) | This function removes all items from the store. |
deleteStore( successCallback, errorCallback ) | Due to changes in the implementation of EncryptedStorage, calling this function is exactly equivalent to calling EncryptedStorage.clear. |
getItem( key, successCallback, errorCallback ) | This function gets the value corresponding to the given key. |
key( index, successCallback, errorCallback ) | This function gets the key corresponding to the given index. |
length( successCallback, errorCallback ) | This function gets the length of the store. |
removeItem( key, successCallback, errorCallback ) | This function removes the item corresponding to the given key. |
setItem( key, value, successCallback, errorCallback ) | This function sets an item with the given key and value. |
Name | Description |
errorCallback( errorCode ) | Callback function that is invoked in case of an error. |
getItemSuccessCallback( value ) | Callback function that is invoked on a successful call to EncryptedStorage.getItem. |
keySuccessCallback( key ) | Callback function that is invoked on a successful call to EncryptedStorage.key. |
lengthSuccessCallback( length ) | Callback function that is invoked on a successful call to EncryptedStorage.length. |
successCallback | Callback function that is invoked on a successful call to a function that does not need to return anything. |