Skip to content

Commit

Permalink
chore(shared): fix obfuscator.js to use default options for obfuscation
Browse files Browse the repository at this point in the history
  • Loading branch information
jikkai committed May 17, 2024
1 parent 8a702f0 commit 8516acb
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions common/shared/vite/obfuscator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,12 @@ exports.obfuscator = function obfuscator() {
return {
name: 'obfuscator',
enforce: 'post',
async generateBundle(options, bundle) {
async generateBundle(_options, bundle) {
if (process.env.BUNDLE_TYPE === 'lite') {
for (const file in bundle) {
if (bundle[file].type === 'chunk' && /\.js$/.test(file)) {
const code = bundle[file].code;
const obfuscationResult = JavaScriptObfuscator.obfuscate(code, {
compact: true,
controlFlowFlattening: true,
deadCodeInjection: true,
disableConsoleOutput: true,
identifierNamesGenerator: 'hexadecimal',
log: false,
numbersToExpressions: true,
renameGlobals: false,
selfDefending: true,
simplify: true,
splitStrings: true,
stringArray: true,
stringArrayEncoding: ['base64'],
stringArrayThreshold: 0.75,
transformObjectKeys: true,
unicodeEscapeSequence: false,
});
const obfuscationResult = JavaScriptObfuscator.obfuscate(code);
bundle[file].code = obfuscationResult.getObfuscatedCode();
}
}
Expand Down

0 comments on commit 8516acb

Please sign in to comment.