whoami-shubham / obfuscator-io-metro-plugin

A metro plugin to use the javascript-obfuscator library with react-native to obfuscate the bundle after the build.
https://www.npmjs.com/package/obfuscator-io-metro-plugin
MIT License
63 stars 17 forks source link

How to obfuscate in iOS? #20

Closed houmie closed 1 year ago

houmie commented 1 year ago

@whoami-shubham I'm creating a new issue as my comments on an already closed ticket may not be visible.

I would love to verify if this projects works for react Native on iOS. In a previous issue you mentioned that this would work on iOS. How did you decompile the .ipa file to extract the .ios.bundle file, please? This is so I can verify the state before and after this plugin has run.

I also don't understand the proposed solution for iOS - under build-phases of a react-Native iOS project - I can't see "Bundle React Native code".

And what do I do if I want to use this project for obfuscating both Android and iOS? Because I already have this settings for Android in metro.config.js.

const jsoMetroPlugin = require("obfuscator-io-metro-plugin")(
  {
    // for these option look javascript-obfuscator library options from  above url
    compact: false,
    sourceMap: false,
    controlFlowFlattening: true,
    controlFlowFlatteningThreshold: 1,
    numbersToExpressions: true,
    simplify: true,
    stringArrayShuffle: true,
    splitStrings: true,
    stringArrayThreshold: 1,
  },
  {
    runInDev: false /* optional */,
    logObfuscatedFiles: true /* optional generated files will be located at ./.jso */,
    // source Map generated after obfuscation is not useful right now
    sourceMapLocation:
      "./index.android.bundle.map" /* optional  only works if sourceMap: true in obfuscation option */,
  }
);

As you can see sourceMap: false is false for Android. But it seems you suggest to enable it for iOS:

const jsoMetroPlugin = require('obfuscator-io-metro-plugin')(
{
compact: false,
sourceMap: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1,
numbersToExpressions: true,
simplify: true,
shuffleStringArray: true,
splitStrings: true,
stringArrayThreshold: 1,
},
{
runInDev: true,
logObfuscatedFiles: true /* generated files will be located at ./.jso */,
}
);

It would be amazing, if you could clarify this a bit better in the README file. I'm sure it would help many people.

Many Thanks

whoami-shubham commented 1 year ago

when you run the command to create .ipa file, i guess you can find the ios bundle file at Resources/Assets/.../main.jsbundle

sourceMap option is not useful don't use it.