react-native-security-suite 0.3.3 → 0.4.3
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 +48 -23
- package/package.json +1 -1
- package/ios/SecuritySuite.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/SecuritySuite.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/SecuritySuite.xcodeproj/project.xcworkspace/xcuserdata/mohammadnavabi.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/SecuritySuite.xcodeproj/xcuserdata/mohammadnavabi.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
- package/ios/SecuritySuite.xcodeproj/xcuserdata/mohammadnavabi.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
package/README.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
# react-native-security-suite
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
React Native security solutions for both Android and iOS
|
|
4
|
+
|
|
5
|
+
<ol>
|
|
6
|
+
<li>SSL Pinning</li>
|
|
7
|
+
<li>Secure storage</li>
|
|
8
|
+
<li>Encryption/Decryption</li>
|
|
9
|
+
<li>Root/Jailbreak detection</li>
|
|
10
|
+
</ol>
|
|
7
11
|
|
|
8
12
|
## Installation
|
|
9
13
|
|
|
@@ -17,34 +21,48 @@ npm install react-native-security-suite
|
|
|
17
21
|
|
|
18
22
|
## Usage
|
|
19
23
|
|
|
24
|
+
1. SSL Pinning example:
|
|
25
|
+
|
|
20
26
|
```js
|
|
21
|
-
import {
|
|
22
|
-
getPublicKey,
|
|
23
|
-
getSharedKey,
|
|
24
|
-
encryptBySharedKey,
|
|
25
|
-
decryptBySharedKey,
|
|
26
|
-
encrypt,
|
|
27
|
-
decrypt,
|
|
28
|
-
deviceHasSecurityRisk,
|
|
29
|
-
fetch,
|
|
30
|
-
} from 'react-native-security-suite';
|
|
27
|
+
import { fetch } from 'react-native-security-suite';
|
|
31
28
|
|
|
32
|
-
// SSL Pinning
|
|
33
29
|
const response = await fetch('URL', {
|
|
30
|
+
method: 'GET',
|
|
34
31
|
body: {},
|
|
35
32
|
headers: {},
|
|
36
33
|
certificates: [
|
|
37
|
-
/*
|
|
34
|
+
/* certificates */
|
|
38
35
|
],
|
|
39
36
|
validDomains: [
|
|
40
|
-
/* your valid
|
|
37
|
+
/* your valid domains */
|
|
41
38
|
],
|
|
42
39
|
timeout: 6000,
|
|
43
40
|
});
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
console.log('server response: ', response.json());
|
|
42
|
+
```
|
|
46
43
|
|
|
47
|
-
|
|
44
|
+
\
|
|
45
|
+
2. Secure storage example:
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
import { SecureStorage } from 'react-native-security-suite';
|
|
49
|
+
|
|
50
|
+
SecureStorage.setItem('key', 'value');
|
|
51
|
+
console.log(await SecureStorage.getItem('key'));
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
\
|
|
55
|
+
3. Encryption/Decryption example(with key exchange or without key exchange):
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
import {
|
|
59
|
+
getPublicKey,
|
|
60
|
+
getSharedKey,
|
|
61
|
+
encryptBySharedKey,
|
|
62
|
+
decryptBySharedKey,
|
|
63
|
+
encrypt,
|
|
64
|
+
decrypt,
|
|
65
|
+
} from 'react-native-security-suite';
|
|
48
66
|
|
|
49
67
|
// Hard Encrypt/Decrypt with sharedKey
|
|
50
68
|
const publicKey = await getPublicKey();
|
|
@@ -55,7 +73,8 @@ console.log('Public key: ', publicKey);
|
|
|
55
73
|
*/
|
|
56
74
|
const sharedKey = await getSharedKey('SERVER_PUBLIC_KEY');
|
|
57
75
|
console.log('Shared key: ', sharedKey);
|
|
58
|
-
|
|
76
|
+
|
|
77
|
+
// 1. Hard Encrypt/Decrypt by sharedKey
|
|
59
78
|
const hardEncrypted = await encryptBySharedKey('STR_FOR_ENCRYPT');
|
|
60
79
|
console.log('Encrypted result: ', hardEncrypted);
|
|
61
80
|
const hardDecrypted = await decryptBySharedKey('STR_FOR_DECRYPT');
|
|
@@ -63,13 +82,19 @@ console.log('Decrypted result: ', hardDecrypted);
|
|
|
63
82
|
|
|
64
83
|
// ------- OR --------
|
|
65
84
|
|
|
66
|
-
// Soft Encrypt/Decrypt without sharedKey
|
|
85
|
+
// 2. Soft Encrypt/Decrypt without sharedKey
|
|
67
86
|
const softEncrypted = await encrypt('STR_FOR_ENCRYPT');
|
|
68
87
|
console.log('Encrypted result: ', softEncrypted);
|
|
69
88
|
const softDecrypted = await decrypt('STR_FOR_DECRYPT');
|
|
70
89
|
console.log('Decrypted result: ', softDecrypted);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
\
|
|
93
|
+
4. Root/Jailbreak detection example:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
import { deviceHasSecurityRisk } from 'react-native-security-suite';
|
|
71
97
|
|
|
72
|
-
// Root/Jailbreak detection
|
|
73
98
|
const isRiskyDevice = await deviceHasSecurityRisk();
|
|
74
99
|
console.log('Root/Jailbreak detection result: ', isRiskyDevice);
|
|
75
100
|
```
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>SchemeUserState</key>
|
|
6
|
-
<dict>
|
|
7
|
-
<key>SecuritySuite.xcscheme_^#shared#^_</key>
|
|
8
|
-
<dict>
|
|
9
|
-
<key>orderHint</key>
|
|
10
|
-
<integer>0</integer>
|
|
11
|
-
</dict>
|
|
12
|
-
</dict>
|
|
13
|
-
</dict>
|
|
14
|
-
</plist>
|