
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
rn-config-reader
Advanced tools
A native library to access configuration variables from JS code.
based on csath project
For react-native@0.60+ versions use react-native-config-reader@4.0+ (Autolinking support enabled now)
For rn 0.60+ Auto Linking will do things for you.
If not follow these:
$ npm install rn-config-reader --save or $ yarn add rn-config-reader
$ react-native link rn-config-reader
Go to android/app/src/main/packageName/MainApplication.java and find line
new RNConfigReaderPackage()
See manual installation below if you have issues with react-native link.
import RNConfigReader from 'rn-config-reader';
// access any of the defined config variables in andoird build gradle or ios info.plist
const configValue = RNConfigReader.ANY_DEFINED_CONFIG_FIELD;
Create a string-array item on strings.xml file with the strings variables you want to expose to JS (res/values/strings.xml)
<resources>
<string-array name="export_variables">
<item>TEST_CONFIG_FIELD</item>
</string-array>
<string name="TEST_CONFIG_FIELD">ConfigValue</string>
</resources>
Create new field inside ios info.plist file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>com.react-native.react-native-config-reader</string>
<key>TEST_CONFIG_FIELD</key>
<string>"Hello I'm your test config value"</string>
</dict>
</plist>
Now you can acess them inside the JS code
import { Platform } from 'react-native';
import RNConfigReader from 'rn-config-reader';
if(Platform.OS === 'ios') {
const iosBundleDisplayName = RNConfigReader.CFBundleDisplayName;
const testConfigValue = RNConfigReader.TEST_CONFIG_FIELD;
}
if(Platform.OS === 'android') {
const androidApplicationID = RNConfigReader.applicationId;
const testConfigValue = RNConfigReader.TEST_CONFIG_FIELD;
}
Libraries ➜ Add Files to [your project's name]node_modules ➜ react-native-config-reader and add RNConfigReader.xcodeprojlibRNConfigReader.a to your project's Build Phases ➜ Link Binary With LibrariesCmd+R)<android/app/src/main/java/[...]/MainApplication.javaimport com.reactlibrary.RNConfigReaderPackage; to the imports at the top of the filenew RNConfigReaderPackage() to the list returned by the getPackages() methodandroid/settings.gradle:
include ':react-native-config-reader'
project(':react-native-config-reader').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config-reader/android')
android/app/build.gradle:
compile project(':react-native-config-reader')
If your app uses an applicationIdSuffix or a different applicationId depending on the build variants, you must append the following line inside the buildTypes block in your android/app/build.gradle file and specify your new package name.
resValue "string", "rn_config_reader_custom_package", "com.yourNewPackage"
Example
buildTypes {
...
debug {
...
applicationIdSuffix ".dev"
resValue "string", "rn_config_reader_custom_package", "com.yourNewPackage"
}
}
RNConfigReader.sln in node_modules/react-native-config-reader/windows/RNConfigReader.sln folder to their solution, reference from their app.MainPage.cs appusing Config.Reader.RNConfigReader; to the usings at the top of the filenew RNConfigReaderPackage() to the List<IReactPackage> returned by the Packages methodWhen Proguard is enabled (which it is by default for Android release builds), it can rename the BuildConfig Java class in the minification process and prevent react-native-config-reader from referencing it. To avoid this, add an exception to android/app/proguard-rules.pro:
-keep class com.yourNewPackage.BuildConfig { *; }
com.yourNewPackage should match the package value in your app/src/main/AndroidManifest.xml file.
If using Dexguard, the shrinking phase will remove resources it thinks are unused. It is necessary to add an exception to preserve the build config package name.
-keepresources string/rn_config_reader_custom_package
MIT License
Copyright (c) 2019 Chanaka Athurugiriya
FAQs
Simply access android resources strings and ios info.plist values in JS
The npm package rn-config-reader receives a total of 324 weekly downloads. As such, rn-config-reader popularity was classified as not popular.
We found that rn-config-reader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.