Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to protect source code in react-native app before passing the project to the client

For native apps, you can protect your source code by building a framework and access it like a blackbox.

For react-native app, is it possible to build the business logic or some components into something similar? (e.g. npm packages but how to hide the source code? The best way is to obfuscate the npm package with JScrambler?)

I'm building an app for a client, they didn't purchase the license to own the code. And they refuse to let us have access to their certs to publish the app, what are the alternatives to solve this issue?

like image 808
user1872384 Avatar asked Dec 19 '19 07:12

user1872384


People also ask

Are React Native apps secure?

Compared to Native applications, it is highly vulnerable to extorting core logic and source code hacking. Applications developed by React Native has high a vulnerability in extorting core logic and source code hacking. Security per language mainly used in the mobile app is as follows.

Is React Native keychain secure?

Android - Keystore​ react-native-encrypted-storage - uses Keychain on iOS and EncryptedSharedPreferences on Android. react-native-sensitive-info - secure for iOS, but uses Android Shared Preferences for Android (which is not secure by default).


4 Answers

I think that offline bundle make the job:

For ios

react-native bundle --dev false --entry-file index.js --bundle-output ios/main.jsbundle --platform ios

For android

react-native bundle --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --platform android --assets-dest android/app/src/main/res/

With --dev false it is obfuscated (--minify true) by default

Give your clients the android and ios folders for them to compile the native code themselves

like image 108
Alexander Vidaurre Arroyo Avatar answered Oct 23 '22 09:10

Alexander Vidaurre Arroyo


For JavaScript code, the best option is probably obfuscation, and JScrambler probably works well. I do not know any other good solution than obfuscation for this particular issue.

I work on a team that just released a new JavaScript obfuscation product JSDefender, and it has specific support for React Native that maybe you could try as an alternative to JScrambler.

like image 30
Dominik Avatar answered Oct 23 '22 10:10

Dominik


You can use these scripts in your package.json. Also it's good for performance.

"bundle-ios": "react-native ram-bundle --entry-file index.js --platform ios --dev false",

"bundle-android": "react-native ram-bundle --entry-file index.js --platform android --dev false"

And I don't know which version of react you use, but if you use higher than 0.60.4, you should check Hermes which can be used for android, it converts your js to bytecode.

like image 2
Kubilay Kiymaci Avatar answered Oct 23 '22 10:10

Kubilay Kiymaci


use the following obfuscator

react-native-obfuscating-transformer

like image 1
TheEhsanSarshar Avatar answered Oct 23 '22 08:10

TheEhsanSarshar