Open balapkm opened 6 years ago
@balapkm any update with this issue?
I'm using 0.57.2 there's no errors, but it's not obfuscated js bundles either. I can't figure out what's going wrong.
Same. No error, no log, nothing. On RN 0.57.5
I see that the files are being processed (trace: true) and I also printed the output of obfuscateCode and it does obfuscate the code. However:
@tobiarobi Hi tobiarobi, I also set the trace to true but got nothing obfuscated, and I use typescript as well, is it possible to share your transformer.js file? Thanks. Following is my transformer.js file:
const obfuscatingTransformer = require("react-native-obfuscating-transformer")
const typescriptTransformer = require('react-native-typescript-transformer')
module.exports = obfuscatingTransformer({
upstreamTransformer: typescriptTransformer,
obfuscatorOptions: {
compact: true,
controlFlowFlattening: false,
controlFlowFlatteningThreshold: 0.75,
deadCodeInjection: true,
deadCodeInjectionThreshold: 0.4,
debugProtection: false,
debugProtectionInterval: false,
disableConsoleOutput: false,
domainLock: [],
identifierNamesGenerator: 'hexadecimal',
identifiersPrefix: '',
inputFileName: '',
log: true,
renameGlobals: true,
reservedNames: [],
reservedStrings: ['react-native'],
rotateStringArray: true,
seed: 0,
selfDefending: true,
sourceMap: false,
sourceMapBaseUrl: '',
sourceMapFileName: '',
sourceMapMode: 'separate',
stringArray: true,
stringArrayEncoding: false,
stringArrayThreshold: 0.75,
target: 'browser',
transformObjectKeys: false,
unicodeEscapeSequence: false
},
trace: true,
emitObfuscatedFiles: true,
enableInDevelopment: true
})
@wangghon That's because there is a bug in the default filter function. The default function searches for an absolute path of the function (with the help of app-root-path package), while the filename sent to the filter function are with relative path. To fix this I used my own filter function.
const filter = filename => {
return filename.startsWith("src");
};
module.exports = obfuscatingTransformer({
filter: filter,
upstreamTransformer: typescriptTransformer,
trace: true,
})
@tobiarobi Thanks for the response. Your suggestion works.
when I enable trace flag, see the output in console that all the files are obfuscating, however I found that the code is not obfuscated at all, did you experience the similar issue?
@wangghon As I've explained in the first comment. It does work when you print the obfuscated code returned by the transformer (just add console.log for the obfuscated code and you'll see that it works). However somewhere afterwards in the flow (when its bundled together) perhaps its minified afterwards and some of the work that the obfuscator does is lost. I haven't had a chance to investigate this thoroughly, nevertheless I can say that the output is somewhat different than running without the transformer. (for example: for my project the output with the obfuscator was larger than without it)
@tobiarobi Thanks. We tried to log the obfuscated code out, It seems no obfuscation happens. :(
console.log the output of obfuscateCodePreservingSourceMap
see https://github.com/javascript-obfuscator/react-native-obfuscating-transformer/blob/9a0271046c276b0270b57cc2a855103b3ad24def/src/obfuscatingTransformer.ts#L101
I'm experiencing the same problem.
react-native: 0.57.8
Same issue here. No obfuscation takes place at all. I changed filter options, and traced the output, which does not seem to be correct.
I guess the author disable string encryption in src/obfuscatingTransformer.ts. I tried edit it:
And build bundle with the following obfuscator options:
stringArray: true, stringArrayEncoding: 'base64', stringArrayThreshold: 1,
But we will get errors because obfuscator encrypt all strings in "require" function. So I think, the solution for this is split all the code you want to encyript to specific modules an import/require them. Then you change the filter function to encrypt only those files.
Cannot find module 'metro/src/transformer'