0

How to obfuscate my react-native JS code? I have set the following in my build.gradle file:

release {
      minifyEnabled true
      proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
     }

But still after unzipping the apk I can find my JS components name, variables and url's

1 Answer 1

0

Try Using Obfuscate JavaScript code https://github.com/javascript-obfuscator/react-native-obfuscating-transformer

This would be the most important part of the obfuscation as our actual code is written in JavaScript. The react-native-obfuscating-transformer npm package can be used here:

Add the package to your project

NPM install react-native-obfuscating-transformer Add/update the CLI configuration in rn-cli.config.js at the root of your project, where android and ios folders reside.

module.exports = {
  getTransformModulePath() {
   return require.resolve("./transformer")
  },
}

follow along with the details steps on the Git hub page https://github.com/javascript-obfuscator/react-native-obfuscating-transformer

Some of the options are below

interface ObfuscatorOptions {
 compact?: boolean
 controlFlowFlattening?: boolean
 controlFlowFlatteningThreshold?: 0.75
 deadCodeInjection?: boolean
 deadCodeInjectionThreshold?: 0.4
 debugProtection?: boolean
 debugProtectionInterval?: boolean
 disableConsoleOutput?: boolean
 domainLock?: string[]
 identifierNamesGenerator?: "hexadecimal" | "mangled"
 log?: boolean
 renameGlobals?: boolean
 reservedNames?: string[]
 rotateStringArray?: true
 seed?: 0
 selfDefending?: boolean
 sourceMap?: boolean
 sourceMapBaseUrl?: string
 sourceMapFileName?: string
 sourceMapMode?: "separate" | "inline"
 stringArray?: boolean
 stringArrayEncoding?: boolean
 stringArrayThreshold?: 0.75
 target?: "browser" | "extension" | "node"
 unicodeEscapeSequence?: boolean
 }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .