@@ -4,11 +4,97 @@ Obfuscate selected source files when building react-native bundles.
44
55## Usage
66
7- TODO
7+ ### /rn-cli.config.js
8+
9+ ``` diff
10+ module.exports = {
11+ + getTransformModulePath() {
12+ + return require.resolve("./transformer")
13+ + },
14+ }
15+ ```
16+
17+ ### /transformer.js
18+
19+ ``` js
20+ const obfuscatingTransformer = require (" react-native-obfuscating-transformer" )
21+
22+ module .exports = obfuscatingTransformer ({
23+ /* options */
24+ })
25+ ```
826
927## Configuration
1028
11- TODO
29+ Options are:
30+
31+ ### ` upstreamTransformer: MetroTransformer `
32+
33+ Defines what the first pass of code transformation is. If you don't use a custom transformer already,
34+ you don't need to set this option.
35+
36+ TypeScript example:
37+
38+ ``` diff
39+ const obfuscatingTransformer = require('react-native-obfuscating-transformer')
40+ + const typescriptTransformer = require('react-native-typescript-transformer')
41+
42+ module.exports = obfuscatingTransformer({
43+ + upstreamTransformer: typescriptTransformer
44+ })
45+ ```
46+
47+ #### Default value: ` require('metro/src/transformer') `
48+
49+ ### ` filter: (filename: string, source: string) => boolean `
50+
51+ Returns true for any files that should be obfuscated and false for any files which should not be obfuscated.
52+
53+ By default, it obfuscates all files in ` src/**/* `
54+
55+ ### ` obfuscatorOptions: ObfuscatorOptions `
56+
57+ ** Warning** — Not all options are guaranteed to produce working code. In particular, ` stringArray ` definitely breaks builds.
58+
59+ See the [ javascript-obfuscator docs] ( https://github.com/javascript-obfuscator/javascript-obfuscator ) for more info about what each option does.
60+
61+ ``` ts
62+ interface ObfuscatorOptions {
63+ compact? : boolean
64+ controlFlowFlattening? : boolean
65+ controlFlowFlatteningThreshold? : 0.75
66+ deadCodeInjection? : boolean
67+ deadCodeInjectionThreshold? : 0.4
68+ debugProtection? : boolean
69+ debugProtectionInterval? : boolean
70+ disableConsoleOutput? : boolean
71+ domainLock? : string []
72+ identifierNamesGenerator? : " hexadecimal" | " mangled"
73+ log? : boolean
74+ renameGlobals? : boolean
75+ reservedNames? : string []
76+ rotateStringArray? : true
77+ seed? : 0
78+ selfDefending? : boolean
79+ sourceMap? : boolean
80+ sourceMapBaseUrl? : string
81+ sourceMapFileName? : string
82+ sourceMapMode? : " separate" | " inline"
83+ stringArray? : boolean
84+ stringArrayEncoding? : boolean
85+ stringArrayThreshold? : 0.75
86+ target? : " browser" | " extension" | " node"
87+ unicodeEscapeSequence? : boolean
88+ }
89+ ```
90+
91+ ### ` trace: boolean `
92+
93+ Iff true, prints a list of files being obfuscated
94+
95+ ### ` emitObfuscatedFiles: boolean `
96+
97+ Iff true, emits the obfuscated versions of files alongside their originals, for comparison.
1298
1399## License
14100
0 commit comments