Skip to content

Commit cb726ea

Browse files
committed
added more documentation
1 parent c95239b commit cb726ea

9 files changed

Lines changed: 183 additions & 12 deletions

File tree

website/docs/android_options.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
id: android_options
3+
title: Android
4+
sidebar_label: Android
5+
---
6+
7+
Android specific configurations
8+
9+
## showModal & strings
10+
11+
When `showModal` is `true`, an Android native prompt will show up asking for user's authentication. This behavior is similar to that of iOS.
12+
13+
You can control strings associated with a modal prompt via `strings` option:
14+
15+
```javascript
16+
strings: {
17+
header: 'Sign in',
18+
description: 'Place finger to authenticate',
19+
hint: 'Touch',
20+
success: 'Fingerprint recognized',
21+
notRecognized: 'Fingerprint not recognized, try again',
22+
cancel: 'Cancel',
23+
cancelled: 'Authentication was cancelled', // reject error message
24+
}
25+
```
26+
27+
## setInvalidatedByBiometricEnrollment
28+
29+
If you want to control the behaviour on android when new fingers are enrolled or removed on the device on any device with API level greater than 24. You should call during the initialization of your app to the function `setInvalidatedByBiometricEnrollment`. This will re-initialise the internal android Key generator with the flag set to keep/invalidate the credentials upon fingers change.
30+
31+
```javascript
32+
import SInfo from 'react-native-sensitive-info';
33+
34+
SInfo.setInvalidatedByBiometricEnrollment(false);
35+
```
36+
37+
[You can check out more here](https://developer.android.com/reference/android/security/keystore/KeyGenParameterSpec.Builder#setInvalidatedByBiometricEnrollment(boolean))

website/docs/deleteItem.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
id: deleteItem
3+
title: deleteItem
4+
sidebar_label: deleteItem
5+
---
6+
7+
**WIP**
8+
9+
In the meantime checkout our **[README](https://github.com/mCodex/react-native-sensitive-info#methods)** for further information.
10+
11+
Wanna help? Just send a PR 😉

website/docs/getAllItems.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
id: getAllItems
3+
title: getAllItems
4+
sidebar_label: getAllItems
5+
---
6+
7+
**WIP**
8+
9+
In the meantime checkout our **[README](https://github.com/mCodex/react-native-sensitive-info#methods)** for further information.
10+
11+
Wanna help? Just send a PR 😉

website/docs/getItem.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
id: getItem
3+
title: getItem
4+
sidebar_label: getItem
5+
---
6+
7+
**WIP**
8+
9+
In the meantime checkout our **[README](https://github.com/mCodex/react-native-sensitive-info#methods)** for further information.
10+
11+
Wanna help? Just send a PR 😉

website/docs/installation.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ sidebar_label: Installation
66

77
First of all, install it using `npm` or `yarn`
88

9-
```
9+
```bash
1010
npm install --save react-native-sensitive-info
1111
```
1212

13-
```
13+
```bash
1414
yarn add react-native-sensitive-info
1515
```
1616

@@ -22,21 +22,21 @@ yarn add react-native-sensitive-info
2222

2323
Should be automatically linked when you run:
2424

25-
```
25+
```bash
2626
pod install
2727
```
2828

2929
Then:
3030

31-
```
31+
```bash
3232
yarn ios
3333
```
3434

3535
#### Android
3636

3737
Should be automatically linked when you run:
3838

39-
```
39+
```bash
4040
yarn android
4141
```
4242

@@ -46,7 +46,7 @@ yarn android
4646

4747
##### Using cocoapods
4848

49-
```
49+
```pod
5050
pod 'react-native-sensitive-info', path: "../node_modules/react-native-sensitive-info"
5151
```
5252

@@ -69,21 +69,21 @@ In XCode, in the project navigator, select your project.
6969

7070
Go to `settings.gradle` inside your android project folder and paste this lines there:
7171

72-
```
72+
```java
7373
include ':react-native-sensitive-info'
7474

7575
project(':react-native-sensitive-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sensitive-info/android')
7676
```
7777

7878
and paste it into build.gradle:
7979

80-
```
80+
```java
8181
compile project(':react-native-sensitive-info')
8282
```
8383

8484
In your` MainApplication.java` add:
8585

86-
```
86+
```java
8787
import br.com.classapp.RNSensitiveInfo.RNSensitiveInfoPackage; //<- You must import this
8888

8989
protected List<ReactPackage> getPackages() {
@@ -104,7 +104,7 @@ protected List<ReactPackage> getPackages() {
104104
* Check the RNSensitiveInfo you just added and press Ok
105105
* Open MainPage.cs in your app
106106

107-
```
107+
```c#
108108
using RNSqlite2;
109109

110110
get

website/docs/ios_options.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
id: ios_options
3+
title: iOS
4+
sidebar_label: iOS
5+
---
6+
7+
## touchID
8+
9+
Enable touchID support.
10+
11+
```javascript
12+
SInfo.setItem('key1', 'value1', {
13+
...
14+
touchID: true,
15+
});
16+
17+
```
18+
19+
## kSecAccessControl
20+
21+
When passing in the [touchID](#touchID) option as `true`, you can also set `kSecAccessControl`. For example:
22+
23+
24+
```javascript
25+
SInfo.setItem('key1', 'value1', {
26+
keychainService: 'myKeychain',
27+
kSecAccessControl: 'kSecAccessControlTouchIDCurrentSet',
28+
sharedPreferencesName: 'mySharedPrefs',
29+
touchID: true,
30+
});
31+
```
32+
33+
**Note:** By default `kSecAccessControl` will get set to `kSecAccessControlUserPresence`.
34+
35+
## kSecAttrSynchronizable
36+
37+
You can set this to `true` in order to sync the keychain items with iCloud.
38+
39+
**Note:** By default `kSecAttrSynchronizable` will get set to `false`.
40+
41+
## kLocalizedFallbackTitle
42+
43+
You can set this to a string and fallback to pin code authentication.
44+
45+
## Enable Face ID
46+
47+
To enable Face ID, for iOS X and above or iPad Pro, set `kSecAccessControl` to `kSecAccessControlBiometryAny`. For example:
48+
49+
```javascript
50+
SInfo.setItem('key1', 'value1', {
51+
keychainService: 'myKeychain',
52+
kSecAccessControl: 'kSecAccessControlBiometryAny',
53+
...
54+
});
55+
```

website/docs/overview.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,35 @@ RNSInfo is an open-source library developed by many contributors since 2016. ❤
88

99
Securing sensitive data is very important in production-ready applications. So, this is why RNSInfo was created for, to help you focus in what matters most, your application. 😉
1010

11-
Handling sensitive data couldn't be easier in React-Native apps.
11+
Handling sensitive data couldn't be easier in React-Native apps.
12+
13+
## Demo
14+
15+
```javascript
16+
import SInfo from 'react-native-sensitive-info';
17+
18+
SInfo.setItem('key1', 'value1', {
19+
sharedPreferencesName: 'mySharedPrefs',
20+
keychainService: 'myKeychain'
21+
}).then((value) =>
22+
console.log(value) //value 1
23+
);
24+
25+
SInfo.setItem('key2', 'value2', {});
26+
27+
SInfo.getItem('key1', {
28+
sharedPreferencesName: 'mySharedPrefs',
29+
keychainService: 'myKeychain'}).then(value => {
30+
console.log(value) //value1
31+
});
32+
33+
SInfo.getItem('key2',{}).then(value => {
34+
console.log(value) //value2
35+
});
36+
37+
SInfo.getAllItems({
38+
sharedPreferencesName: 'mySharedPrefs',
39+
keychainService: 'myKeychain'}).then(values => {
40+
console.log(values) //value1, value2
41+
});
42+
```

website/docs/security.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
id: security
3+
title: Security
4+
sidebar_label: Security
5+
---
6+
7+
Jailbroken/Rooted devices can access your iOS' Keystore and Android's shared preferences/keystore in plain text, so it is necessary to add another layer of protection.
8+
9+
- **iOS:** it is implemented through [Access Control](https://developer.apple.com/documentation/security/secaccesscontrol). Everytime the app wants to access the protected keychain item, a prompt by iOS will show up. Only after authentication success will return the requested item.
10+
11+
- **Android** it is implemented through [FingerprintManager](https://developer.android.com/reference/android/hardware/fingerprint/FingerprintManager.html) + Keystore. Keystore has a function called `setUserAuthenticationRequired` which makes Keystore requires user authentication before getting value. However, Android doesn't nicely asks user to scan their finger, it just throws error this is why FingerprintManager comes in. However (AGAIN), FingerprintManager doesn't prompt automatically for you, so you need to build UI yourself to let user to know that it is time to scan his/her fingerprint.

website/sidebars.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
module.exports = {
22
someSidebar: {
3-
Introduction: ['overview', 'installation'],
3+
Introduction: ['overview', 'installation', 'security'],
44
API: [
5+
'deleteItem',
6+
'getAllItems',
7+
'getItem',
58
'hasEnrolledFingerprints',
69
'isHardwareDetected',
710
'isSensorAvailable',
811
'setItem',
912
],
13+
Options: ['android_options', 'ios_options']
1014
},
1115
};

0 commit comments

Comments
 (0)