New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rn-secure-storage

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rn-secure-storage - npm Package Compare versions

Comparing version

to
3.0.0-beta.0

android/src/main/java/com/taluttasgiran/rnsecurestorage/cipherStorage/CipherStorage.java

4

package.json
{
"name": "rn-secure-storage",
"version": "2.0.5",
"version": "3.0.0-beta.0",
"description": "Secure Storage for React Native (Android & iOS) - Keychain & Keystore",
"main": "index.js",
"types": "typescript/rn-secure-storage.d.ts",
"types": "rn-secure-storage.d.ts",
"keywords": [

@@ -8,0 +8,0 @@ "react-native",

@@ -5,21 +5,4 @@ # RNSecureStorage

### After v2 this package has AndroidX support. If you want to use without AndroidX please use *v1.1.1*
### Facebook RN blog post about v0.60 and AndroidX support: [https://facebook.github.io/react-native/blog/2019/07/03/version-60](https://facebook.github.io/react-native/blog/2019/07/03/version-60)
**[Go to F.A.Q for more information.](#faq)**
**[Not your main language ? Check out the translations here](#translations)**
### IOS
RNSecureStorage is using Keychain for secure storing.
### Android
Under API 23 RNSecureStorage is using [secure-preferences](https://github.com/scottyab/secure-preferences/) by [@scottyab](https://github.com/scottyab)
Above API 23 RNSecureStorage is using [Android Keystore](https://developer.android.com/training/articles/keystore)
## Getting Started

@@ -37,71 +20,177 @@

**IOS**
## If you have experience with Android Cipher please help me to maintenance this library. Contact: _hi@talut.dev_
If you don't have CocoaPods installed: `sudo gem install cocoapods`
### Version 3.0.0 - **THIS VERSION HAS A LOT OF BREAKING CHANGES PLEASE USE CAREFULLY**
- Android part copied & modified from **oblador/react-native-keychain** and added new API's
- IOS part rewrote with Swift and new API's.
- All API's names changed new API's added.
- Some of api return type changed.
- `removeAll` added.
- `getAllKeys` added.
- `multiSet` added.
- `multiGet` added.
- `multiRemove` added.
- `getSupportedBiometryType` added.
```sh
cd ios && pod install
```
##### [Version 2.0.5](https://github.com/talut/rn-secure-storage/tree/2.0.5)
**You can still use v2.0.5**
**Android**
There is no required action for Android.
### Usage
**Manual Linking**
**[Manual Installation](/docs/manual-installation.md)** (If something went wrong with react-native link)
## Usage
Note: Don't use any special chars at key like `test@key`. This kinda key names can be a problem for IOS/Android
```javascript
import RNSecureStorage, { ACCESSIBLE } from 'rn-secure-storage'
// {accessible: ACCESSIBLE.WHEN_UNLOCKED} -> This is only for IOS
import React from "react"
import { Button, SafeAreaView, ScrollView, StatusBar } from "react-native"
import RNSecureStorage, { ACCESSIBLE } from "rn-secure-storage"
const App = () => {
```
**SET**
```javascript
// {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);
});
```
/**
* Set a value from secure storage.
*/
const setItem = () => {
RNSecureStorage.setItem("token", "^W((nXWi~M`$Gtu<s+;$`M1SotPG^~", { accessible: ACCESSIBLE.WHEN_UNLOCKED })
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
}
/**
* Get a value from secure storage.
*/
const getItem = () => {
RNSecureStorage.getItem("token")
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
}
/**
* Remove a value from secure storage.
*/
const removeItem = () => {
RNSecureStorage.removeItem("token")
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
}
/**
* Removes whole RNSecureStorage data (It'll return unremoved keys)
*/
const removeAll = () => {
RNSecureStorage.clear()
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
}
/**
* Checks if a key has been set it'll return tru/false
*/
const itemExist = () => {
RNSecureStorage.exist("@refreshToken")
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
}
/**
* Get all setted keys from secure storage.
*/
const getAllKeys = () => {
RNSecureStorage.getAllKeys()
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
}
/**
* Multiple key pair set for secure storage. Will return unsetted keys.
*/
const multiSet = () => {
const pair_one = ["@idToken", "id_token_value"]
const pair_two = ["@accessToken"]
const pair_three = ["@refreshToken", "refresh_token_value"]
RNSecureStorage.multiSet([pair_one, pair_two, pair_three], { accessible: ACCESSIBLE.WHEN_UNLOCKED })
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
}
/**
* Get multiple values from secure storage.
*/
const multiGet = () => {
RNSecureStorage.multiGet(["@idToken", "@accessToken", "@refreshToken"])
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
}
/**
* Remove values from secure storage (On error will return unremoved keys)
*/
const multiRemove = () => {
RNSecureStorage.multiRemove(["@refreshToken", "token"])
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
}
/**
* Get supported biometry type (Will return FaceID, TouchID or undefined)
*/
const getSupportedBiometryType = () => {
RNSecureStorage.getSupportedBiometryType()
.then(res => {
console.log(res)
})
.catch(err => {
console.log(err)
})
}
**GET**
return (
<SafeAreaView>
<ScrollView>
<Button title="Store Item" onPress={setItem} />
<Button title="Get Item" onPress={getItem} />
<Button title="Remove Item" onPress={removeItem} />
<Button title="Remove All" onPress={removeAll} />
<Button title="Is Item Exist?" onPress={itemExist} />
<Button title="Get All Keys" onPress={getAllKeys} />
<Button title="Multiple Set" onPress={multiSet} />
<Button title="Multiple Get" onPress={multiGet} />
<Button title="Multiple Remove" onPress={multiRemove} />
<Button title="Get Supported Biometry Type" onPress={getSupportedBiometryType} />
</ScrollView>
</SafeAreaView>
)
}
```javascript
RNSecureStorage.get("key1").then((value) => {
console.log(value) // Will return direct value
}).catch((err) => {
console.log(err)
})
```
export default App
**REMOVE**
```javascript
RNSecureStorage.remove("key1").then((val) => {
console.log(val)
}).catch((err) => {
console.log(err)
});
```
**EXISTS**
```javascript
// res -> is can be True or False
RNSecureStorage.exists("key1")
.then((res) => {
console.log(res ? "Key exists": "Key not exists")
}, (err) => {
console.log(err);
});
```
## Options

@@ -126,78 +215,6 @@

### Example
You can find the usage example of the package in the example folder.
```console
git clone https://github.com/talut/rn-secure-package
cd rn-secure-package/example
npm install
react-native run-ios/android
```
### Version 2.0.5
- [https://github.com/talut/rn-secure-storage/pull/51](https://github.com/talut/rn-secure-storage/pull/51) merged.
### Version 2.0.4
- [https://github.com/talut/rn-secure-storage/pull/44](https://github.com/talut/rn-secure-storage/pull/44) merged.
- [https://github.com/talut/rn-secure-storage/pull/46](https://github.com/talut/rn-secure-storage/pull/46) merged.
### Version 2.0.3
- [https://github.com/talut/rn-secure-storage/pull/40](https://github.com/talut/rn-secure-storage/pull/40) merged.
### Version 2.0.2
- When phone default locale including RTL then this workaround is setting English locale before generating a key pair and changing it back after all.
### Version 2.0.1 (AndroidX Support added)
- Update to AndroidX. Make sure to enable it in your project's android/gradle.properties.
#### Version 1.1.1
- Exists method added. Thanks [@kirin-p](https://github.com/kirin-p)
#### Version 1.1.0
- TypeScript support added. Thanks [@akiver](https://github.com/akiver)
#### Version 1.0.9
- Gradle version updated.
- Log messages updated. (For IOS)
- **IOS keychain service name updated right now this package is using main bundle name. If you already using this package in production After this update all IOS user will log out from app automatically.**
#### Version 1.0.82 (a little bug fix)
- google() repo added because Gradle v3.1.4 can't found.
#### Version 1.0.7
- Android & IOS returing value/messages are updated.
- [Issue:1](https://github.com/talut/rn-secure-storage/issues/1) is solved.
### Translations
- [French](docs/README-fr.md) by [@Vinetos](https://github.com/vinetos)
- [Indonesia](docs/README-id.md) by [@mfaridzia](https://github.com/mfaridzia)
- [German](docs/README-de.md) by [@msdeibel](https://github.com/msdeibel)
- [Dutch](docs/README-nl.md) by [@fpkmatthi](https://github.com/fpkmatthi)
- [Brazilian Portuguese](docs/README-ptBR.md) by [@HenryFilho](https://github.com/HenryFilho)
### F.A.Q
- **How can I support you?**
- *You can use Patreon: [patreon.com/talut](https://patreon.com/talut)*
- **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 and password, while with RNSecureStorage you can store a lot of [key,value] pairs*
- **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 set to minSDK:18. Thats means you might encounter some problems ...*
- **Hey can I trust your code/package?**
- *You can see all of my code in the repo and can review it. Also if you want, you can easily can fork my repo and change 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'm planning to do so. But you know time can change everything.*
-**How can I support you?**
-*If you're using my package that's enough for me*
*Note: This package is more improved version of [react-native-secure-key-store](https://github.com/pradeep1991singh/react-native-secure-key-store), RNSecureStorage has "under api 23" support*
## Thanks
- Thanks to you [@cagriyilmaz](https://github.com/cagriyilmaz) for IOS part.
- Thanks to you [@akiver](https://github.com/akiver) for TypeScript definitions.
- Thanks to you [@kirin-p](https://github.com/kirin-p) for exits method.
- [Thanks to you @pradeep1991singh for react-native-secure-key-store](https://github.com/pradeep1991singh/)
## License

@@ -204,0 +221,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet