npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-keychain-storage

v1.1.6

Published

Allows to keep data on install / uninstall or app updates

Downloads

66

Readme

Keychain storage Plugin for Apache Cordova

Plugin helps to store data across app updates, install/uninstall processes on the device On iOS save in keychain On Android save in hidden file on external storage, stored values are encrypted

Install

cordova plugin add cordova-plugin-keychain-storage

The plugin's JavaScript functions are called after creating the plugin object thus:

    var kc = new Keychain();
    kc.getForKey(win, fail, "some_key", "some_servicename");

iCloud keychain enabled

iCloud keychain synchonizing is enabled, so the keychain will be mirrored across all devices if the user is signed in to iCloud (Settings > iCloud) and has iCloud keychain turned on (Settings > iCloud > Keychain)

Android API 29+ support

Add android:requestLegacyExternalStorage="true" to <application tag in manifest

And permissions:

Usage

Important:

If you are saving a JSON string value in setForKey, for example after applying JSON.stringify on an object, you must escape the characters in that string, if not you cannot retrieve it using getForKey.        

var obj = { foo: 'bar' };
var value = JSON.stringify(obj);
value = value 
      .replace(/[\\]/g, '\\\\')
      .replace(/[\"]/g, '\\\"')
      .replace(/[\/]/g, '\\/')
      .replace(/[\b]/g, '\\b')
      .replace(/[\f]/g, '\\f')
      .replace(/[\n]/g, '\\n')
      .replace(/[\r]/g, '\\r')
      .replace(/[\t]/g, '\\t');

See the example folder for example usage.

// Get a reference to the plugin first
// Use optional string parameter 'encryptionRequired' to specify if Android keys should be stored encrypted 
// (no affect on iOS)
// Keychain() or Keychain('true') will use encryption to store keys
// Keychain('false') will store unencrypted keys
// If Android screen lock is not configured then an attempt to use Keychain with encrypted keys will fail with error:
// "failed: Android keystore must be in initialized and unlocked state if encryption is required"
var kc = new Keychain();

/*
 Retrieves a value for a key and servicename.
 
 @param successCallback returns the value as the argument to the callback when successful
 @param failureCallback returns the error string as the argument to the callback, for a failure
 @param key the key to retrieve
 @param servicename the servicename to use
 */
kc.getForKey(successCallback, failureCallback, 'key', 'servicename');

/*
 Sets a value for a key and servicename.
 
 @param successCallback returns when successful
 @param failureCallback returns the error string as the argument to the callback, for a failure
 @param key the key to set
 @param servicename the servicename to use
 @param value the value to set
 */
kc.setForKey(successCallback, failureCallback, 'key', 'servicename', 'value');

/*
 Removes a value for a key and servicename.
 
 @param successCallback returns when successful
 @param failureCallback returns the error string as the argument to the callback
 @param key the key to remove
 @param servicename the servicename to use
 */
kc.removeForKey(successCallback, failureCallback, 'key', 'servicename');

based on plugins by David Williams (ADI Health) extending work by Shazron Abdullah (Copyright 2012) to include support for Android Keystore. Requires Android API level 18 (4.3) for Keystore support

Apache 2.0 License except for the SFHFKeychainUtils code that is under src/ios/SFHFKeychainUtils

Follows the Cordova Plugin spec, so that it works with Plugman, or you can install it manually below.

Manually importing the plugin is not supported anymore, please use Plugman or the Cordova CLI tool

The "Keychain" object definition is installed globally.