-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
55 lines (51 loc) · 1.94 KB
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const DEV_MODE = !process.argv.includes('--prod');
const fs = require('fs').promises;
var JavaScriptObfuscator = require('javascript-obfuscator');
const MAX_OBF = {
// domainLock: [],
compact: true,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 0.75,
deadCodeInjection: true,
deadCodeInjectionThreshold: 0.4,
debugProtection: false,
// disableConsoleOutput: true,
disableConsoleOutput: false,
identifierNamesGenerator: 'dictionary',
identifiersDictionary: ['hire_me', 'bereal_please_hire', 'give_me_a_job', 'pleaseandthanks', 'befake', 'fakest', 'real', 'realest'],
log: false,
numbersToExpressions: true,
renameGlobals: false,
rotateStringArray: true,
selfDefending: true,
shuffleStringArray: true,
simplify: true,
splitStrings: true,
splitStringsChunkLength: 10,
stringArray: true,
stringArrayEncoding: ['base64'],
stringArrayIndexShift: true,
stringArrayWrappersCount: 2,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 4,
stringArrayWrappersType: 'function',
stringArrayThreshold: 0.75,
transformObjectKeys: true,
unicodeEscapeSequence: false
};
(async () => {
if (DEV_MODE) console.log("\x1b[43m%s\x1b[0m", 'This is a dev build. To build for production, run node deploy.');
let files = {};
let fileNames = await fs.readdir('client/js');
for (let fileName of fileNames) {
let content = await fs.readFile('client/js/' + fileName, 'utf-8');
files[fileName] = content;
}
let newContent = JavaScriptObfuscator.obfuscateMultiple(files, MAX_OBF);
for (let fileName of fileNames) {
let content = DEV_MODE ? files[fileName] : newContent[fileName].getObfuscatedCode();
await fs.writeFile('public/js/' + fileName, content);
console.log('\x1b[36m%s\x1b[0m', `* Patched ${fileName}`);
}
console.log("\x1b[42m%s\x1b[0m", 'Build Successful');
})();