Skip to content

Commit e8e9917

Browse files
committed
feat: add expo support
1 parent d6fb07d commit e8e9917

File tree

113 files changed

+12440
-40
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+12440
-40
lines changed

README.md

+100-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div align="center">
2-
<h1 align="center">🔐 Undecryptable .ENVs variables</h1>
2+
<img width="500" src="./media/keys.png">
33
</div>
44

55
<div align="center">
@@ -19,11 +19,8 @@
1919
We should use **react-native-keys** instead of **react-native-config** because **react-native-keys** gives guarantee of undecryptable **envs** whereas **react-native-config** **envs** can be decompile and hack
2020

2121
**Note:** We highly recommend utilizing `third-party client-side API KEYS`, such as `Google Map` or `Branch.io`, in the secure section of this package.
22-
#### See the [ Migration from react-native-config](docs/react-native-config-migration-guide.md)
2322

24-
<div align="center">
25-
<img align="right" width="250" style="margin-right: 55px;" src="./media/key.png">
26-
</div>
23+
#### See the [ Migration from react-native-config](docs/react-native-config-migration-guide.md)
2724

2825
Making undecryptable **Envs** library for React Native.
2926

@@ -62,6 +59,8 @@ We can Manage **secure**(undecryptable) and **public** enviroment through **reac
6259
<summary>Open Table of Contents</summary>
6360

6461
- [Installation](#installation)
62+
- [For React Native](#installation)
63+
- [Managed Expo](#managed-expo)
6564
- [Basic Usage](#basic-usage)
6665
- [Javascript](#javascript)
6766
- [Public Keys](#public-keys)
@@ -93,8 +92,100 @@ yarn add react-native-keys
9392
```
9493

9594
##### [New Architecture (Turbo Module) Supported](https://reactnative.dev/docs/new-architecture-intro)
95+
9696
You can give feedback on [Discord channel](https://discord.gg/fgPHnZpH9d)
9797

98+
<h3>Managed Expo</h3>
99+
<details>
100+
<summary><b>Click here to Expand Managed Expo plugin Config</b></summary>
101+
102+
```
103+
expo install react-native-keys
104+
```
105+
106+
Add `keys.development.json`, `keys.staging.json` and `keys.production.json` at project root directory
107+
108+
Add the Keys plugin to your Expo config (`app.json`, `app.config.json` or `app.config.js`):
109+
110+
```json
111+
{
112+
"name": "my app",
113+
"plugins": [
114+
[
115+
"react-native-keys",
116+
{
117+
"android": {
118+
"defaultKeyFile": "keys.staging.json" //default: keys.development.json
119+
},
120+
"ios": {
121+
"defaultKeyFile": "keys.staging.json" //default: keys.development.json
122+
}
123+
}
124+
]
125+
]
126+
}
127+
```
128+
129+
Finally, compile the mods:
130+
131+
```
132+
expo prebuild
133+
```
134+
135+
**Optional** If you wanna use different [Variants](https://docs.expo.dev/build-reference/variants/) then the you should write `eas.json` like this
136+
137+
```
138+
{
139+
"build": {
140+
"development": {
141+
"env": {
142+
"APP_VARIANT": "development",
143+
"KEYSFILE": "keys.development.json"
144+
}
145+
},
146+
"staging": {
147+
"env": {
148+
"APP_VARIANT": "staging",
149+
"KEYSFILE": "keys.staging.json"
150+
}
151+
},
152+
"production": {
153+
"env": {
154+
"APP_VARIANT": "production",
155+
"KEYSFILE": "keys.production.json"
156+
}
157+
}
158+
},
159+
"submit": {
160+
"production": {}
161+
}
162+
}
163+
```
164+
165+
To apply the changes, build a new binary with EAS:
166+
167+
```
168+
eas build
169+
```
170+
171+
use different [Variants](https://docs.expo.dev/build-reference/variants/) script into `package.json` like this
172+
173+
```
174+
{
175+
"scripts": {
176+
"dev:android": "KEYSFILE=keys.development.json npx expo run:android",
177+
"staging:android": "KEYSFILE=keys.staging.json npx expo run:android",
178+
"prod:android": "KEYSFILE=keys.production.json npx expo run:android",
179+
"dev:ios": "KEYSFILE=keys.development.json npx expo run:ios",
180+
"staging:ios": "KEYSFILE=keys.staging.json npx expo run:ios",
181+
"prod:ios": "KEYSFILE=keys.production.json npx expo run:ios"
182+
}
183+
}
184+
185+
```
186+
187+
</details>
188+
98189
## Basic Usage
99190

100191
Create a new file `keys.development.json` in the root of your React Native app and add Envs in `secure` object for `undecryptable` envs variables and add Envs in public for public usage this:
@@ -228,7 +319,6 @@ Alternatively, you can define a map in `Pre-actions` associating builds with env
228319
"${SRCROOT}/../node_modules/react-native-keys/keysIOS.js"
229320
```
230321

231-
232322
### Android
233323

234324
- **Manual Link (Android)**
@@ -359,7 +449,7 @@ NSDictionary *allKeys = [Keys public_keys];
359449
NSString *value = [Keys secureFor:@"BRANCH_KEY"]; //key_test_omQ7YYKiq57vOqEJsdcsdfeEsiWkwxE
360450
```
361451

362-
call, and use build cases in lowercase, like:
452+
call, and use build cases in lowercase, like:
363453

364454
### Different environments
365455

@@ -453,10 +543,12 @@ If using Dexguard, the shrinking phase will remove resources it thinks are unuse
453543
-keepresources string/build_config_package
454544
455545
### Using node with nvm, fnm or notion
546+
456547
Build failure in Xcode looks something like:
548+
457549
> env: node: No such file or directory
458550
459-
Change the **Pre-actions script** scripts in Xcode to:
551+
Change the **Pre-actions script** scripts in Xcode to:
460552
461553
```
462554
# Setup nvm and set node

android/RNKeys.gradle

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ def loadKeys() {
4747
if (System.env['KEYSFILE']) {
4848
keysFile = System.env['KEYSFILE']
4949
exportCommand = "export KEYSFILE=" + keysFile + " && ";
50+
} else if (System.env['DEFAULT_FILE_NAME']) {
51+
keysFile = System.env['DEFAULT_FILE_NAME']
52+
exportCommand = "export KEYSFILE=" + keysFile + " && ";
53+
} else if (project.hasProperty("DEFAULT_FILE_NAME")) {
54+
keysFile = project.ext.DEFAULT_FILE_NAME
55+
exportCommand = "export KEYSFILE=" + keysFile + " && ";
5056
} else if (project.hasProperty("keyFiles")) {
5157
project.ext.keyFiles.any { pair ->
5258
if (flavor.startsWith(pair.key.toLowerCase())) {

android/src/main/java/com/reactnativekeysjsi/PrivateKey.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
package com.reactnativekeysjsi;
44

55
public class PrivateKey {
6-
public static String privatekey="pZoshfXIdCfwBqsc57d31atAUMf0lxCX5NWnCtWzHwFa4YazE8aHeQ009f8GiurSFBtjDNMSoog33YYHZtebu0+PrCTX8su4Y1df5FK1Rg==";
6+
public static String privatekey="k0bymYdpGsZVFHIEEZVtzWgvGs0R6xxSgFN7wxkm/50HMLQZFQt55CR4VItVw6nrLfXATPXRxSiLHSDXvsvUupzfYPAodZsxx9VxlWBZ7g==";
77
}

app.plugin.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./plugin/build');

cpp/crypto.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
}
1111

1212
string Crypto::getJniJsonStringifyData(string key) {
13-
std::string base64Secret1 = "U2FsdGVkX199+I364h5jWqyctRTxfs71VpO171cahBoWf4m/sExs57WYLzGBfHT7YviRpyAt";
14-
std::string base64Secret2 = "s/Dk7rj1VsY7MvElsDbaLj4jhHT/y0EpT/wCSJw6NgZ3SIlM6eJKqvwDjRCZfMrBoPMwO3Aw";
15-
std::string base64Secret3 = "pj8YZTX+0gzzQ4OhdLiZpOUa8iPTyjSbUwelLLqD2nWAXT+dWzbsAeN8inNXNaJKbFMSpg==";
13+
std::string base64Secret1 = "U2FsdGVkX19lgRN4srwXt2D2LYi+baTRYsKl2mygm7ASNIWFynY+bxsDrbKAr2MZnI0flTXS";
14+
std::string base64Secret2 = "DPWi+ilmqhX7RviqMInOjQ/dRUApNhJW3/Sqk0bymYdpGsZVFHIEEZVtzWgvGs0R6xxSgFN7";
15+
std::string base64Secret3 = "wxkm/50HMLQZFQt55CR4VItVw6nrLfXATPXRxSiLHSDXvsvUupzfYPAodZsxx9VxlWBZ7g==";
1616
std::string base64Secret = base64Secret1 + base64Secret2 + base64Secret3;
17-
std::string password = "3seCzMfVxah8";
17+
std::string password = "u4IxXxapI6zg";
1818
bool binary = false;
1919
std::string plaintext = decryptor::dec(base64Secret, password,binary);
2020

docs/workflow.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ we are using dynamic [Ciper](https://en.wikipedia.org/wiki/Cipher) for encoding
1616
> It’s important to understand that no system is completely secure from attacks, even every wifi device or laptop password is also hackable, I made this for making a good security measurement for preventing 3rd party API key abuse, Good security measure is better than nothing to do
1717
> Before using this package our 3rd party API key had a 99% hackable probability but after using this package hack probability will be 0.5%
1818
19-
as far as I know, we can abuse all types of 3rd parties unless that 3rd party uses
19+
as far as I know, we can abuse all types of 3rd parties unless these 3rd party uses
2020

2121
- DeviceCheck or App Attest for IOS
2222
- Play Integrity or SafetyNet for Android

example/ios/Podfile.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ PODS:
375375
- React-jsinspector (0.72.3)
376376
- React-logger (0.72.3):
377377
- glog
378-
- react-native-keys (0.5.9):
378+
- react-native-keys (0.6.0):
379379
- OpenSSL-Universal
380380
- RCT-Folly (= 2021.07.22.00)
381381
- React-Core
@@ -694,7 +694,7 @@ SPEC CHECKSUMS:
694694
React-jsiexecutor: 59d1eb03af7d30b7d66589c410f13151271e8006
695695
React-jsinspector: b511447170f561157547bc0bef3f169663860be7
696696
React-logger: c5b527272d5f22eaa09bb3c3a690fee8f237ae95
697-
react-native-keys: 593e083793a140f8151db432f0a781d497d5d155
697+
react-native-keys: e9c8e5d5891896181ab692c5f3378d7e90e0bbdc
698698
React-NativeModulesApple: c57f3efe0df288a6532b726ad2d0322a9bf38472
699699
React-perflogger: 6bd153e776e6beed54c56b0847e1220a3ff92ba5
700700
React-RCTActionSheet: c0b62af44e610e69d9a2049a682f5dba4e9dff17
@@ -716,6 +716,6 @@ SPEC CHECKSUMS:
716716
Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce
717717
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
718718

719-
PODFILE CHECKSUM: 781a791ed65dc65c0001147158c0af034ef7c70e
719+
PODFILE CHECKSUM: 713d4856e51f06c61696065aa31f30450735cea9
720720

721-
COCOAPODS: 1.11.3
721+
COCOAPODS: 1.12.1

exampleExpo/App.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './src/App';

exampleExpo/android/.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Android/IntelliJ
6+
#
7+
build/
8+
.idea
9+
.gradle
10+
local.properties
11+
*.iml
12+
*.hprof
13+
14+
# Bundle artifacts
15+
*.jsbundle

0 commit comments

Comments
 (0)