|
1 | 1 | <div align="center">
|
2 |
| - <h1 align="center">🔐 Undecryptable .ENVs variables</h1> |
| 2 | + <img width="500" src="./media/keys.png"> |
3 | 3 | </div>
|
4 | 4 |
|
5 | 5 | <div align="center">
|
|
19 | 19 | 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
|
20 | 20 |
|
21 | 21 | **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) |
23 | 22 |
|
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) |
27 | 24 |
|
28 | 25 | Making undecryptable **Envs** library for React Native.
|
29 | 26 |
|
@@ -62,6 +59,8 @@ We can Manage **secure**(undecryptable) and **public** enviroment through **reac
|
62 | 59 | <summary>Open Table of Contents</summary>
|
63 | 60 |
|
64 | 61 | - [Installation](#installation)
|
| 62 | + - [For React Native](#installation) |
| 63 | + - [Managed Expo](#managed-expo) |
65 | 64 | - [Basic Usage](#basic-usage)
|
66 | 65 | - [Javascript](#javascript)
|
67 | 66 | - [Public Keys](#public-keys)
|
@@ -93,8 +92,100 @@ yarn add react-native-keys
|
93 | 92 | ```
|
94 | 93 |
|
95 | 94 | ##### [New Architecture (Turbo Module) Supported](https://reactnative.dev/docs/new-architecture-intro)
|
| 95 | + |
96 | 96 | You can give feedback on [Discord channel](https://discord.gg/fgPHnZpH9d)
|
97 | 97 |
|
| 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 | + |
98 | 189 | ## Basic Usage
|
99 | 190 |
|
100 | 191 | 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
|
228 | 319 | "${SRCROOT}/../node_modules/react-native-keys/keysIOS.js"
|
229 | 320 | ```
|
230 | 321 |
|
231 |
| - |
232 | 322 | ### Android
|
233 | 323 |
|
234 | 324 | - **Manual Link (Android)**
|
@@ -359,7 +449,7 @@ NSDictionary *allKeys = [Keys public_keys];
|
359 | 449 | NSString *value = [Keys secureFor:@"BRANCH_KEY"]; //key_test_omQ7YYKiq57vOqEJsdcsdfeEsiWkwxE
|
360 | 450 | ```
|
361 | 451 |
|
362 |
| - call, and use build cases in lowercase, like: |
| 452 | +call, and use build cases in lowercase, like: |
363 | 453 |
|
364 | 454 | ### Different environments
|
365 | 455 |
|
@@ -453,10 +543,12 @@ If using Dexguard, the shrinking phase will remove resources it thinks are unuse
|
453 | 543 | -keepresources string/build_config_package
|
454 | 544 |
|
455 | 545 | ### Using node with nvm, fnm or notion
|
| 546 | +
|
456 | 547 | Build failure in Xcode looks something like:
|
| 548 | +
|
457 | 549 | > env: node: No such file or directory
|
458 | 550 |
|
459 |
| -Change the **Pre-actions script** scripts in Xcode to: |
| 551 | +Change the **Pre-actions script** scripts in Xcode to: |
460 | 552 |
|
461 | 553 | ```
|
462 | 554 | # Setup nvm and set node
|
|
0 commit comments