Skip to content

Commit acddb9c

Browse files
authored
Merge pull request #45 from numandev1/docs/update-1
docs: update
2 parents b2702ac + aaba7e0 commit acddb9c

File tree

2 files changed

+105
-65
lines changed

2 files changed

+105
-65
lines changed

README.md

+103-64
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<div align="center">
66

7-
[![GitHub Repo stars](https://img.shields.io/static/v1?style=for-the-badge&message=Discord&color=5865F2&logo=Discord&logoColor=FFFFFF&label=)](https://discord.gg/dtYzk8sp)
7+
[![GitHub Repo stars](https://img.shields.io/static/v1?style=for-the-badge&message=Discord&color=5865F2&logo=Discord&logoColor=FFFFFF&label=)](https://discord.gg/fgPHnZpH9d)
88
[![GitHub Repo stars](https://img.shields.io/github/stars/numandev1/react-native-keys?style=for-the-badge&logo=github)](https://github.com/numandev1/react-native-keys/stargazers)
99
[![GitHub Repo stars](https://img.shields.io/npm/v/react-native-keys?style=for-the-badge&message=npm&&color=CB3837&logo=npm&logoColor=FFFFFF&label=)](https://www.npmjs.com/package/react-native-keys)
1010
![npm](https://img.shields.io/static/v1?style=for-the-badge&message=TypeScript&color=3178C6&logo=TypeScript&logoColor=FFFFFF&label=)
@@ -56,18 +56,44 @@ We can Manage **secure**(undecryptable) and **public** enviroment through **reac
5656

5757
#### See the [How we are protecting ENVs on the app side?](docs/workflow.md)
5858

59+
# Table of Contents
60+
61+
<details>
62+
<summary>Open Table of Contents</summary>
63+
64+
- [Installation](#installation)
65+
- [Basic Usage](#basic-usage)
66+
- [Javascript](#javascript)
67+
- [Public Keys](#public-keys)
68+
- [Secure Keys](#secure-keys)
69+
- [Setup](#video)
70+
- [IOS](#ios)
71+
- [Android](#android)
72+
- [Native Usage](#native-usage)
73+
- [Android](#android-1)
74+
- [Public Keys](#public-keys-1)
75+
- [Secure Keys](#secure-keys-jni)
76+
- [IOS](#ios-1)
77+
- [Public Keys](#public-keys-2)
78+
- [Secure Keys](#secure-keys-1)
79+
- [Different environments](#different-environments)
80+
- [Advanced Android Setup](#advanced-android-setup-1)
81+
- [Advanced IOS Setup](#ios-2)
82+
- [Test Security](#test-security)
83+
- [Problems with Proguard](#problems-with-proguard)
84+
- [Using node with nvm, fnm or notion](#using-node-with-nvm-fnm-or-notion)
85+
- [Star on GitHub](#consider-supporting-with-a-%EF%B8%8F-star-on-github)
86+
- [How we are protecting ENVs on the app side?](#see-the-how-we-are-protecting-envs-on-the-app-side)
87+
</details>
88+
5989
## Installation
6090

6191
```sh
6292
yarn add react-native-keys
6393
```
6494

65-
### OR if you wanna test [New Architecture (Turbo Module)](https://reactnative.dev/docs/new-architecture-intro)
66-
then install alpha version like this and give feedback on [Discord channel](https://discord.gg/dtYzk8sp)
67-
68-
```sh
69-
yarn add react-native-keys@alpha
70-
```
95+
##### [New Architecture (Turbo Module) Supported](https://reactnative.dev/docs/new-architecture-intro)
96+
You can give feedback on [Discord channel](https://discord.gg/fgPHnZpH9d)
7197

7298
## Basic Usage
7399

@@ -133,6 +159,8 @@ or later. For earlier versions you need to manually link the module.)
133159
react-native link react-native-keys
134160
```
135161

162+
### IOS
163+
136164
if cocoapods are used in the project then pod has to be installed as well:
137165

138166
```
@@ -143,7 +171,7 @@ if cocoapods are used in the project then pod has to be installed as well:
143171
>
144172
> Solution: [StackOverFlow](https://stackoverflow.com/a/76455587/8079868)
145173
146-
- Manual Link (iOS)
174+
- **Manual Link (iOS)**
147175

148176
1. In XCode, in the project navigator, right click `Libraries``Add Files to [your project's name]`
149177
2. Go to `node_modules``react-native-keys` and add `Keys.xcodeproj`
@@ -152,7 +180,58 @@ if cocoapods are used in the project then pod has to be installed as well:
152180
5. And go the Build Settings tab. Make sure All is toggled on (instead of Basic)
153181
6. Look for Header Search Paths and add `$(SRCROOT)/../node_modules/react-native-keys/ios/**` as `non-recursive`
154182

155-
- Manual Link (Android)
183+
- **Mandatory Step**
184+
185+
With one extra step environment values can be exposed to "Info.plist" and Build settings in the native project.
186+
187+
1. click on the file tree and create new file of type XCConfig
188+
![img](./media/1.png)
189+
![img](./media/2.png)
190+
2. save it under `ios` folder as "Config.xcconfig" with the following content:
191+
192+
```
193+
#include? "tmp.xcconfig"
194+
```
195+
196+
3. add the following to your ".gitignore":
197+
198+
```
199+
ios/tmp.xcconfig
200+
201+
```
202+
203+
4. go to project settings
204+
5. apply config to your configurations
205+
![img](./media/3.png)
206+
6. Go to _Edit scheme..._ -> _Build_ -> _Pre-actions_, click _+_ and select _New Run Script Action_. Paste below code which will generate "tmp.xcconfig" before each build exposing values to Build Settings and Info.plist. Make sure to select your target under _Provide build settings from_, so `$SRCROOT` environment variables is available to the script..
207+
208+
```
209+
"${SRCROOT}/../node_modules/react-native-keys/keysIOS.js"
210+
```
211+
212+
![img](./media/4.png)
213+
214+
7. You can now access your env variables in the Info.plist, for example `$(MY_ENV_VARIABLE)`. If you face issues accessing variables, please open a new issue and provide as much details as possible so above steps can be improved.
215+
216+
- Go to _Edit scheme..._ -> _Build_ -> _Pre-actions_, click _+_ and select _New Run Script Action_. Paste below code which will generate KEYS keys on native ios side (into node*modules) Make sure to select your target under \_Provide build settings from*, so `$SRCROOT` environment variables is available to the script.
217+
218+
```sh
219+
export KEYSFILE=keys.development.json
220+
221+
"${SRCROOT}/../node_modules/react-native-keys/keysIOS.js"
222+
```
223+
224+
Alternatively, you can define a map in `Pre-actions` associating builds with env files:
225+
226+
```sh
227+
export KEYSFILE = "path_to_env"
228+
"${SRCROOT}/../node_modules/react-native-keys/keysIOS.js"
229+
```
230+
231+
232+
### Android
233+
234+
- **Manual Link (Android)**
156235

157236
**android/settings.gradle**
158237

@@ -184,6 +263,21 @@ if cocoapods are used in the project then pod has to be installed as well:
184263
}
185264
```
186265

266+
- **Mandatory Step**
267+
268+
**app/build.gradle**
269+
270+
you can define a map in `build.gradle` associating builds with env files. Do it before the `apply from` call, and use build cases in lowercase, like:
271+
272+
```groovy
273+
project.ext.keyFiles = [
274+
debug: "keys.development.json",
275+
release: "keys.staging.json",
276+
]
277+
278+
apply from: project(':react-native-keys').projectDir.getPath() + "/RNKeys.gradle"
279+
```
280+
187281
## Native Usage
188282

189283
### Android
@@ -265,50 +359,6 @@ NSDictionary *allKeys = [Keys public_keys];
265359
NSString *value = [Keys secureFor:@"BRANCH_KEY"]; //key_test_omQ7YYKiq57vOqEJsdcsdfeEsiWkwxE
266360
```
267361

268-
With one extra step environment values can be exposed to "Info.plist" and Build settings in the native project.
269-
270-
1. click on the file tree and create new file of type XCConfig
271-
![img](./media/1.png)
272-
![img](./media/2.png)
273-
2. save it under `ios` folder as "Config.xcconfig" with the following content:
274-
275-
```
276-
#include? "tmp.xcconfig"
277-
```
278-
279-
3. add the following to your ".gitignore":
280-
281-
```
282-
ios/tmp.xcconfig
283-
284-
```
285-
286-
4. go to project settings
287-
5. apply config to your configurations
288-
![img](./media/3.png)
289-
6. Go to _Edit scheme..._ -> _Build_ -> _Pre-actions_, click _+_ and select _New Run Script Action_. Paste below code which will generate "tmp.xcconfig" before each build exposing values to Build Settings and Info.plist. Make sure to select your target under _Provide build settings from_, so `$SRCROOT` environment variables is available to the script..
290-
291-
```
292-
"${SRCROOT}/../node_modules/react-native-keys/keysIOS.js"
293-
```
294-
295-
![img](./media/4.png)
296-
297-
7. You can now access your env variables in the Info.plist, for example `$(MY_ENV_VARIABLE)`. If you face issues accessing variables, please open a new issue and provide as much details as possible so above steps can be improved.
298-
299-
- Go to _Edit scheme..._ -> _Build_ -> _Pre-actions_, click _+_ and select _New Run Script Action_. Paste below code which will generate KEYS keys on native ios side (into node*modules) Make sure to select your target under \_Provide build settings from*, so `$SRCROOT` environment variables is available to the script.
300-
301-
```sh
302-
"${SRCROOT}/../node_modules/react-native-keys/keysIOS.js"
303-
```
304-
305-
Alternatively, you can define a map in `Pre-actions` associating builds with env files:
306-
307-
```sh
308-
export KEYSFILE = "path_to_env"
309-
"${SRCROOT}/../node_modules/react-native-keys/keysIOS.js"
310-
```
311-
312362
call, and use build cases in lowercase, like:
313363

314364
### Different environments
@@ -335,17 +385,6 @@ The same environment variable can be used to assemble releases with a different
335385
cd android && KEYSFILE=keys.staging.json ./gradlew assembleRelease
336386
```
337387

338-
Alternatively, you can define a map in `build.gradle` associating builds with env files. Do it before the `apply from` call, and use build cases in lowercase, like:
339-
340-
```groovy
341-
project.ext.keyFiles = [
342-
debug: "keys.development.json",
343-
release: "keys.staging.json",
344-
]
345-
346-
apply from: project(':react-native-keys').projectDir.getPath() + "/RNKeys.gradle"
347-
```
348-
349388
#### Advanced Android Setup
350389

351390
In `android/app/build.gradle`, if you use `applicationIdSuffix` or `applicationId` that is different from the package name indicated in `AndroidManifest.xml` in `<manifest package="...">` tag, for example, to support different build variants:

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"dotenv",
5151
"config-var",
5252
"12factor",
53-
"undecryptable"
53+
"undecryptable",
54+
"envs"
5455
],
5556
"repository": "https://github.com/numandev1/react-native-keys",
5657
"author": "numandev1 <[email protected]> (https://github.com/numandev1)",

0 commit comments

Comments
 (0)