Registry / security / cordova-plugin-secure-storage

cordova-plugin-secure-storage

JSON →
library3.0.2jsnpmunverified

A plugin for Apache Cordova that provides secure storage of sensitive strings (usernames, passwords, tokens) on iOS, Android, and Windows using platform-native keychains. Version 3.0.2 is the latest stable release. The plugin wraps iOS Keychain via SAMKeychain, Android EncryptedSharedPreferences, and Windows PasswordVault. Differentiates from other Cordova storage plugins by focusing solely on secure credential storage and supporting a wide range of Windows platforms including WP8.1. Active maintenance with no major changes since v3.

npm install cordova-plugin-secure-storage
INSTALL
IMPORT
SIG · CORDOVA-PLUGIN-SEC
C
cordova-plugin-secure-storage
securityjavascriptv3.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SecureStorage
var ss = new cordova.plugins.SecureStorage(successCallback, errorCallback, 'namespace');
var ss = new SecureStorage(...);
SecureStorage is accessed via cordova.plugins, not as a global. The plugin adds it to the cordova object after device ready.
set
ss.set(successCallback, errorCallback, 'key', 'value');
ss.set('key', 'value');
All methods require both success and error callbacks as the first two arguments.
get
ss.get(successCallback, errorCallback, 'key');
var value = ss.get('key');
get is asynchronous and returns via callback, not a return value.

Shows full lifecycle: create a SecureStorage instance after device ready, then set and get a key. All operations are asynchronous with callbacks.

// Wait for device ready document.addEventListener('deviceready', function() { // Create a namespaced storage instance var ss = new cordova.plugins.SecureStorage( function() { console.log('Storage ready'); }, function(err) { console.log('Error: ' + err); }, 'myApp' ); // Store a secret ss.set( function(key) { console.log('Set ' + key); }, function(err) { console.log('Error: ' + err); }, 'mykey', 'myvalue' ); // Retrieve the secret ss.get( function(value) { console.log('Got ' + value); }, function(err) { console.log('Error: ' + err); }, 'mykey' ); });
Debug
Known issues
gotchaAll methods require success and error callbacks as first two parameters. Omitting them or passing undefined will cause runtime errors.
fix
Always provide both callbacks, even if empty functions.
affects: >=2.0
gotchaThe plugin does not support synchronous access. Do not attempt to use return values.
fix
Use callbacks or wrap with promises/async.
affects: >=2.0
breakingVersion 3.0 changed the Android implementation from using a SQLCipher-based internal database to Android EncryptedSharedPreferences. Existing data stored with v2 is not migrated automatically.
fix
Implement migration logic or accept data loss on upgrade.
affects: 3.0
deprecatedWindows Phone 8.0 support was removed in v3. Only Windows 8.x/10 UWP and WP8.1+ are supported.
fix
Upgrade Windows target to 8.1 or later.
affects: >=3.0
gotchaOn iOS, the 'WhenPasscodeSetThisDeviceOnly' accessibility option crashes on iOS 7 and earlier.
fix
Use a different accessibility option or check iOS version before setting.
affects: >=2.0
gotchaThe plugin must be called after the 'deviceready' event fires. Using it before will result in 'cordova.plugins.SecureStorage is undefined'.
fix
Wrap all plugin calls inside a deviceready listener.
affects: >=2.0
Errors
Common errors & fixes
cordova.plugins.SecureStorage is not a constructor
Called before deviceready event, or cordova.js not loaded.
fix
Ensure code runs inside document.addEventListener('deviceready', function() { ... });
ERROR: Can't set/retrieve value: no storage object initialized
The secure storage instance was not successfully initialized (error callback was called during constructor).
fix
Check that the success callback of the constructor fired. The namespace must be unique and the underlying keychain/storage must be accessible.
No keychain access. Will not store. This is normal when running on a simulator or not from a signed app.
iOS simulator or unsigned app: keychain not available.
fix
Run on a real device or signed app. For testing, ignore the error.
Upgrade
Version history
3.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
26
Resources
cordova-plugin-secure-storage — npm install cordova-plugin-secure-storage · libregistry