javascript-obfuscator / react-native-obfuscating-transformer

Obfuscation for React Native bundles

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Just Don't Work

adamalexander opened this issue · comments

The plugin just don't work...

installed other dependencies needed:

npm install babylon --save
npm install --save babel-traverse

transformer.js

const obfuscatingTransformer = require("react-native-obfuscating-transformer")
const filter = filename => { 
  return filename.startsWith("src");
};

module.exports = obfuscatingTransformer({
// this configuration is based on https://github.com/javascript-obfuscator/javascript-obfuscator
  obfuscatorOptions:{
    compact: true,
    controlFlowFlattening: false,
    deadCodeInjection: false,
    debugProtection: false,
    debugProtectionInterval: false,
    disableConsoleOutput: true,
    identifierNamesGenerator: 'hexadecimal',
    log: false,
    renameGlobals: false,
    rotateStringArray: true,
    selfDefending: true,
    shuffleStringArray: true,
    splitStrings: false,
    stringArray: true,
    stringArrayEncoding: false,
    stringArrayThreshold: 0.75,
    unicodeEscapeSequence: false
  },
  upstreamTransformer: require('metro-react-native-babel-transformer'),
  emitObfuscatedFiles: false,
  enableInDevelopment: true,
  filter: filter,
  trace: true
})

metro.config.js

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
    babelTransformerPath: require.resolve("./transformer")   // add here the transformer.js
  },
};

hi, since the maintainer is not maintainig this library anymore and is not releasing it so you're getting the current version via npm (see #27) you have to checkout the repo yourself and build it via "npm run build".

I've got it running with current RN (0.64) by upgrading dependencies + some necessary code changes -> see 10fe3ec and/or just checkout my forked repo, build and overwrite the resources from your node_modules.

I hope that helps. Alternatively you can use javascript-obfuscator directly as mentioned in #15.