Git Product home page Git Product logo

rn-secure-storage's Introduction

RNSecureStorage

Secure Storage for React Native (Android & iOS)

Note: This package is more improved version of react-native-secure-key-store, RNSecureStorage has "under api 23" support

Go to F.A.Q for more information.

IOS

RNSecureStorage is using Keychain for secure storaging.

Android

Under API 23 RNSecureStorage is using secure-preferences by @scottyab

Above API 23 RNSecureStorage is using Android Keystore

Getting Started

With NPM

npm install --save rn-secure-storage

With YARN

yarn add rn-secure-storage

Automatic linking

react-native link rn-secure-storage

Manual Linking

Manual Installation (If something went wrong with react-native link)

Usage

import RNSecureStorage, { ACCESSIBLE } from 'rn-secure-storage'

SET

// {accessible: ACCESSIBLE.WHEN_UNLOCKED} -> This for IOS
RNSecureStorage.set("key1", "this is a value", {accessible: ACCESSIBLE.WHEN_UNLOCKED})
.then((res) => {
console.log(res);
}, (err) => {
console.log(err);
});

GET

RNSecureStorage.get("key1").then((value) => {
console.log(value) // Will return direct value
}).catch((err) => {
console.log(err)
})

REMOVE

RNSecureStorage.remove("key1").then((val) => {
console.log(val)
}).catch((err) => {
console.log(err)
});

Options

Key Platform Description Default
accessible iOS only This dictates when a keychain item is accessible, see possible values in Keychain.ACCESSIBLE. Keychain.ACCESSIBLE.WHEN_UNLOCKED

Keychain.ACCESSIBLE enum

Key Description
WHEN_UNLOCKED The data in the keychain item can be accessed only while the device is unlocked by the user.
AFTER_FIRST_UNLOCK The data in the keychain item cannot be accessed after a restart until the device has been unlocked once by the user.
ALWAYS The data in the keychain item can always be accessed regardless of whether the device is locked.
WHEN_PASSCODE_SET_THIS_DEVICE_ONLY The data in the keychain can only be accessed when the device is unlocked. Only available if a passcode is set on the device. Items with this attribute never migrate to a new device.
WHEN_UNLOCKED_THIS_DEVICE_ONLY The data in the keychain item can be accessed only while the device is unlocked by the user. Items with this attribute do not migrate to a new device.
AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY The data in the keychain item cannot be accessed after a restart until the device has been unlocked once by the user. Items with this attribute never migrate to a new device.
ALWAYS_THIS_DEVICE_ONLY The data in the keychain item can always be accessed regardless of whether the device is locked. Items with this attribute never migrate to a new device.

Version 1.0.7

  • Android & IOS returing value/messages are updated.
  • Issue:1 is solved.

F.A.Q

  • Why should I use this package?
  • You can use other packages like react-native-keychain I know that package has more options. But you can store only username, password but you can store a lot of [key,value] with RNSecureStorage
  • Why shouldn't I use react-native-secure-key-store
  • You can use that package but you can't get any good solution with lowest API of Android. Also that package is setted minSDK:18. Thats means you will occur some problems..
  • Hey can I trust you code/package?
  • You can see of my code in repo so you can review my code. Also if you want you can easily can fork my repo and changes what bothers you. This package is under MIT license. So I can't give you any warranty. But you should know, I'm using this package in my projects.
  • Will you maintain this package?
  • Yeah I will planning this. But you know time can change everything. -How can I support you? -If you're using my package that's enough for me

Thanks

License

This project is licensed under the MIT License - see the LICENSE.md file for details

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.