Git Product home page Git Product logo

keychainplugin's Introduction

Keychain Plugin for Apache Cordova

created by Shazron Abdullah

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.

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 disabled

iCloud keychain synchronizing is disabled, so the keychain won't be mirrored across all devices.

Usage

Important:

Android

  • The plugin requires strings for Password, FileName, and TAG in the KeychainPlugin class, which are left blank in this repo.
  • The Android portion of the plugin only accepts strings and stores them in the Android KeyStore
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
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');

keychainplugin's People

Contributors

allie-wake-up avatar csullivan102 avatar dmcnamara avatar inorganik avatar jagregory avatar rangerrick avatar shazron avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.