react-native-config-secure-encrypted
Version:
Secure fork of react-native-config-encrypted with crypto-js upgraded to fix vulnerabilities
130 lines (84 loc) • 3.79 kB
Markdown
<div align="center">

[](https://www.npmjs.com/package/react-native-config-secure-encrypted)
[](https://travis-ci.org/react-native-nation/react-native-config-encrypted)
[](https://coveralls.io/github/react-native-nation/react-native-config-encrypted?branch=master)
[](https://github.com/react-native-nation/react-native-config-encrypted/blob/master/LICENSE)
[](https://www.npmjs.com/package/react-native-config-secure-encrypted)
[](https://dependabot.com)
[](https://github.com/react-native-nation/react-native-config-encrypted/pulls)
[](https://github.com/facebook/jest)
</div>
# React Native Config Secure Encrypted
> ⚠️ This is a secure, maintained fork of `react-native-config-encrypted`, with `crypto-js` upgraded to `^4.2.0` to patch known vulnerabilities (CVE-2023-46233, CVE-2020-36732).
This package is a wrapper to encrypt the variables used by the `react-native-config`.
## Table of contents
- [How to install](#howtoinstall)
- [Encrypting env variables](#encrypting)
- [API Methods](#using)
- [Example](#example)
- [Community profile](#community)
- [Contributing](#contributing)
<a name="howtoinstall"></a>
## How to install
`react-native-config` is hard dependency, and must be installed.
```bash
yarn add react-native-config
```
then install the secure encrypted config wrapper:
```bash
yarn add react-native-config-secure-encrypted
```
<a name="encrypting"></a>
## Encrypting env variables
Usage: `example node_modules/.bin/env-config-encrypt <filename> <key> <property>`
```bash
node_modules/.bin/env-config-encrypt .env ^#$%Gg345@$@$ API_KEY_SECRET
```
then you can edit your environment variable
```
.env
API_KEY_SECRET="U2FsdGVkX1+FQEJRNuw8LAIKWQpVRd2Q0UAzJOspgI0fy0zLftyBNi0PdLJfaG1h"
```
<a name="using"></a>
## API Methods
# Get
To access to encrypted variables use the method `get`
```js
Config.get(propertyName, decrypt);
```
# Config
To configure the seed key use `configure`.
```js
import ConfigProvider from "react-native-config";
Config.configure({
key: "your key",
provider: ConfigProvider,
});
```
<a name="example"></a>
## Example
React native example
```js
import Config from "react-native-config-secure-encrypted";
import ConfigProvider from "react-native-config";
// Configure your library to use the seed key
Config.configure({
key: "mysuperkey^$#123123ASDASD",
provider: ConfigProvider,
});
// Get the env property
Config.get("API_KEY_SECRET");
// Get the raw env property
Config.get("API_KEY_SECRET", false);
```
<a name="community"></a>
## Community profile
Please read through our [CODE_OF_CONDUCT.md](/.github/CODE_OF_CONDUCT.md).
<a name="contributing"></a>
## Contributing
Please read through our [CONTRIBUTING.md](/.github/CONTRIBUTING.md).
<a name="reactnativenation"></a>
## React Native Nation
React Native Nation is the best spanish website for react native documentation.
[react-native-nation](https://reactnativenation.com).