🔑 Keychain Access for React Native
Go to file
Mark Vayngrib 537d9945a3 scrap peerDeps 2015-12-31 12:10:08 -05:00
Enums Added flow config and fixed error. 2015-08-16 22:56:23 +02:00
KeychainExample RN 0.10.0-rc support. 2015-08-16 23:00:19 +02:00
RNKeychain.xcodeproj
RNKeychainManager
.editorconfig
.flowconfig Added flow config and fixed error. 2015-08-16 22:56:23 +02:00
.gitignore
LICENSE
README.md Adds todolist. 2015-10-29 11:40:11 -04:00
RNKeychain.podspec Released 0.2.6. 2015-10-29 11:41:54 -04:00
index.ios.js
package.json scrap peerDeps 2015-12-31 12:10:08 -05:00

README.md

react-native-keychain

Keychain Access for React Native

Currently functionality is limited to just storing internet and generic passwords.

Installation

$ npm install react-native-keychain

Option: Manually

  • Right click on Libraries, select Add files to "…" and select node_modules/react-native-keychain/RNKeychain.xcodeproj
  • Select your project and under Build Phases -> Link Binary With Libraries, press the + and select libRNKeychain.a.

Option: With CocoaPods

Add the following to your Podfile and run pod update:

pod 'RNKeychain', :path => 'node_modules/react-native-keychain'

Usage

See KeychainExample for fully working project example.

var Keychain = require('react-native-keychain');

var username = 'zuck';
var password = 'poniesRgr8';

// Generic Password, service argument optional
Keychain
  .setGenericPassword(username, password)
  .then(function() {
    console.log('Credentials saved successfully!');
  });

Keychain
  .getGenericPassword()
  .then(function(credentials) {
    console.log('Credentials successfully loaded for user ' + credentials.username);
  });

Keychain
  .resetGenericPassword()
  .then(function() {
    console.log('Credentials successfully deleted');
  });

// Internet Password, server argument required
var server = 'http://facebook.com';
Keychain
  .setInternetCredentials(server, username, password)
  .then(function() {
    console.log('Credentials saved successfully!');
  });

Keychain
  .getInternetCredentials(server)
  .then(function(credentials) {
    console.log('Credentials successfully loaded for user ' + credentials.username);
  });

Keychain
  .resetInternetCredentials(server)
  .then(function() {
    console.log('Credentials successfully deleted');
  });

Todo

  • iOS support
  • Android support
  • Storing objects as JSON
  • Expose wider selection of underlying native APIs

License

MIT © Joel Arvidsson 2015