// scripts/obfuscate.ts import JavaScriptObfuscator from 'javascript-obfuscator'; import * as fs from 'fs'; import * as path from 'path'; import { glob } from 'glob'; const obfuscateFile = (filePath) => { const obfuscationResult = JavaScriptObfuscator.obfuscate(fs.readFileSync(filePath, 'utf8'), { compact: true, controlFlowFlattening: false, // Disable control flow flattening controlFlowFlatteningThreshold: 0, deadCodeInjection: false, // Disable dead code injection deadCodeInjectionThreshold: 0, debugProtection: false, disableConsoleOutput: true, identifierNamesGenerator: 'hexadecimal', log: false, renameGlobals: false, selfDefending: false, // Disable self-defending stringArray: false, // Disable string array stringArrayEncoding: [], stringArrayThreshold: 0, unicodeEscapeSequence: false, renameProperties: false, // Disable property renaming renamePropertiesMode: 'safe', simplify: true, // Enable simplification transformObjectKeys: false, // Disable object key transformation unicodeEscapeSequence: false, }); fs.writeFileSync(filePath, obfuscationResult.getObfuscatedCode()); }; const obfuscateFiles = async (pattern) => { const files = await glob(pattern); files.forEach(obfuscateFile); }; (async () => { await obfuscateFiles('dist/**/*.{js,mjs}'); })();