react-native-security-suite 0.5.9 → 0.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ npm install react-native-security-suite
|
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
1. Android Root or iOS Jailbreak devices detection example:
|
|
27
27
|
|
|
28
28
|
```js
|
|
29
29
|
import { deviceHasSecurityRisk } from 'react-native-security-suite';
|
|
@@ -32,10 +32,10 @@ const isRiskyDevice = await deviceHasSecurityRisk();
|
|
|
32
32
|
console.log('Root/Jailbreak detection result: ', isRiskyDevice);
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
\
|
|
35
|
+
\
|
|
36
|
+
2. Text Encryption/Decryption example:
|
|
36
37
|
|
|
37
38
|
```js
|
|
38
|
-
//
|
|
39
39
|
const softEncrypted = await encrypt('STR_FOR_ENCRYPT');
|
|
40
40
|
console.log('Encrypted result: ', softEncrypted);
|
|
41
41
|
const softDecrypted = await decrypt('STR_FOR_DECRYPT');
|
|
@@ -52,7 +52,8 @@ SecureStorage.setItem('key', 'value');
|
|
|
52
52
|
console.log(await SecureStorage.getItem('key'));
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
\
|
|
55
|
+
\
|
|
56
|
+
4. Diffie–Hellman key exchange:
|
|
56
57
|
|
|
57
58
|
```js
|
|
58
59
|
import {
|
|
@@ -64,7 +65,6 @@ import {
|
|
|
64
65
|
decrypt,
|
|
65
66
|
} from 'react-native-security-suite';
|
|
66
67
|
|
|
67
|
-
// Hard Encrypt/Decrypt with sharedKey
|
|
68
68
|
const publicKey = await getPublicKey();
|
|
69
69
|
console.log('Public key: ', publicKey);
|
|
70
70
|
/*
|
|
@@ -74,14 +74,14 @@ console.log('Public key: ', publicKey);
|
|
|
74
74
|
const sharedKey = await getSharedKey('SERVER_PUBLIC_KEY');
|
|
75
75
|
console.log('Shared key: ', sharedKey);
|
|
76
76
|
|
|
77
|
-
// 1. Hard Encrypt/Decrypt by sharedKey
|
|
78
77
|
const hardEncrypted = await encryptBySharedKey('STR_FOR_ENCRYPT');
|
|
79
78
|
console.log('Encrypted result: ', hardEncrypted);
|
|
80
79
|
const hardDecrypted = await decryptBySharedKey('STR_FOR_DECRYPT');
|
|
81
80
|
console.log('Decrypted result: ', hardDecrypted);
|
|
82
81
|
```
|
|
83
82
|
|
|
84
|
-
\
|
|
83
|
+
\
|
|
84
|
+
5. SSL Pinning example:
|
|
85
85
|
|
|
86
86
|
```js
|
|
87
87
|
import { fetch } from 'react-native-security-suite';
|
|
@@ -89,18 +89,11 @@ import { fetch } from 'react-native-security-suite';
|
|
|
89
89
|
const response = await fetch('URL', {
|
|
90
90
|
method: 'GET', // or any http methods
|
|
91
91
|
headers: {
|
|
92
|
-
/* your request header */
|
|
93
92
|
'Content-Type': 'application/json',
|
|
94
93
|
},
|
|
95
94
|
body: undefiend,
|
|
96
|
-
certificates: [
|
|
97
|
-
|
|
98
|
-
'sha256/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=',
|
|
99
|
-
],
|
|
100
|
-
validDomains: [
|
|
101
|
-
/* your valid domains */
|
|
102
|
-
'example.com',
|
|
103
|
-
],
|
|
95
|
+
certificates: ['sha256/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX='],
|
|
96
|
+
validDomains: ['example.com'],
|
|
104
97
|
timeout: 6000,
|
|
105
98
|
});
|
|
106
99
|
console.log('server response: ', response.json());
|