
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
rn-secure-storage
Advanced tools
Secure Storage for React Native (Android & iOS) - Keychain & Keystore
Secure Storage for React Native (Android & iOS) - Keychain & Keystore
Go to F.A.Q for more information.
Not your main language ? Check out the translations here
RNSecureStorage is using Keychain for secure storing.
Under API 23 RNSecureStorage is using secure-preferences by @scottyab
Above API 23 RNSecureStorage is using Android Keystore
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)
Note: Don't use any special chars at key like test@key
. This kinda key names can be a problem for IOS/Android
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)
});
EXISTS
// res -> is can be True or False
RNSecureStorage.exists("key1")
.then((res) => {
console.log(res ? "Key exists": "Key not exists")
}, (err) => {
console.log(err);
});
Key | Platform | Description | Default |
---|---|---|---|
accessible | iOS only | This indicates when a keychain item is accessible, see possible values in Keychain.ACCESSIBLE . | Keychain.ACCESSIBLE.WHEN_UNLOCKED |
Keychain.ACCESSIBLE
enumKey | 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. |
You can find the usage example of the package in the example folder.
git clone https://github.com/talut/rn-secure-package
cd rn-secure-package/example
npm install
react-native run-ios/android
Note: This package is more improved version of react-native-secure-key-store, RNSecureStorage has "under api 23" support
This project is licensed under the MIT License - see the LICENSE.md file for details
FAQs
Secure Storage for React Native (Android & iOS) - Keychain & Keystore
The npm package rn-secure-storage receives a total of 2,791 weekly downloads. As such, rn-secure-storage popularity was classified as popular.
We found that rn-secure-storage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.