react-native-obfuscating-transformer
react-native-obfuscating-transformer copied to clipboard
Just Don't Work
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 https://github.com/javascript-obfuscator/react-native-obfuscating-transformer/issues/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 https://github.com/javascript-obfuscator/react-native-obfuscating-transformer/pull/45/commits/10fe3ec28ca8d68a4a2cc4e0455b10f0c08eca26 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 https://github.com/javascript-obfuscator/react-native-obfuscating-transformer/pull/15.