mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-02-15 20:34:41 +08:00
feat: add obfuscation
This commit is contained in:
300
obfuscation.config.js
Normal file
300
obfuscation.config.js
Normal file
@@ -0,0 +1,300 @@
|
||||
// 代码混淆配置文件 - 专门针对 Next.js 项目优化
|
||||
module.exports = {
|
||||
// Webpack Obfuscator 配置(包含压缩功能)
|
||||
obfuscator: {
|
||||
// ========== 基础压缩选项 ==========
|
||||
compact: true, // 压缩代码(移除空格、换行等)
|
||||
simplify: true, // 简化代码(合并变量、优化表达式)
|
||||
|
||||
// ========== 字符串混淆选项(保守配置) ==========
|
||||
splitStrings: true, // 分割字符串
|
||||
splitStringsChunkLength: 8, // 减少字符串分割块长度
|
||||
stringArray: true, // 字符串数组
|
||||
stringArrayEncoding: ['base64'], // 字符串数组编码
|
||||
stringArrayThreshold: 0.3, // 大幅降低字符串数组阈值,只混淆长字符串
|
||||
stringArrayWrappersCount: 1, // 减少字符串数组包装器数量
|
||||
stringArrayWrappersType: 'function', // 使用函数包装器
|
||||
stringArrayWrappersParameters: ['index'], // 包装器参数
|
||||
|
||||
// ========== 标识符混淆选项(保守配置) ==========
|
||||
identifierNamesGenerator: 'hexadecimal', // 标识符名称生成器
|
||||
renameGlobals: false, // 不重命名全局变量
|
||||
identifiersPrefix: '_0x', // 标识符前缀
|
||||
identifiersDictionary: [], // 空字典,使用默认生成
|
||||
|
||||
// ========== 完全禁用复杂混淆 ==========
|
||||
controlFlowFlattening: false, // 禁用控制流扁平化
|
||||
deadCodeInjection: false, // 禁用死代码注入
|
||||
debugProtection: false, // 调试保护(生产环境建议关闭)
|
||||
debugProtectionInterval: 0, // 调试保护间隔
|
||||
numbersToExpressions: false, // 禁用数字转表达式
|
||||
selfDefending: false, // 禁用自我保护
|
||||
transformObjectKeys: false, // 禁用转换对象键
|
||||
unicodeEscapeSequence: false, // Unicode 转义序列
|
||||
|
||||
// ========== 日志和调试选项 ==========
|
||||
disableConsoleOutput: false, // 保留控制台输出
|
||||
log: false, // 不输出混淆日志
|
||||
|
||||
// ========== 高级选项 ==========
|
||||
sourceMap: false, // 不生成 source map
|
||||
target: 'node', // 目标环境为 Node.js
|
||||
seed: 0, // 随机种子
|
||||
|
||||
// ========== 保留重要标识符(扩展版) ==========
|
||||
reservedNames: [
|
||||
"require",
|
||||
"module",
|
||||
"exports",
|
||||
"__dirname",
|
||||
"__filename",
|
||||
"global",
|
||||
"process",
|
||||
"Buffer",
|
||||
"setTimeout",
|
||||
"setInterval",
|
||||
"clearTimeout",
|
||||
"clearInterval",
|
||||
"getStaticProps",
|
||||
"getStaticPaths",
|
||||
"getServerSideProps",
|
||||
"getInitialProps",
|
||||
"reportWebVitals",
|
||||
"db",
|
||||
"client",
|
||||
"query",
|
||||
"execute",
|
||||
"connect",
|
||||
"disconnect",
|
||||
"redis",
|
||||
"kvrocks",
|
||||
"upstash",
|
||||
"mongo",
|
||||
"postgres",
|
||||
"mysql",
|
||||
"GET",
|
||||
"POST",
|
||||
"PUT",
|
||||
"DELETE",
|
||||
"PATCH",
|
||||
"OPTIONS",
|
||||
"HEAD",
|
||||
"Request",
|
||||
"Response",
|
||||
"NextRequest",
|
||||
"NextResponse",
|
||||
"Error",
|
||||
"TypeError",
|
||||
"ReferenceError",
|
||||
"SyntaxError",
|
||||
"RangeError",
|
||||
"EvalError",
|
||||
"URIError",
|
||||
"AggregateError",
|
||||
"init",
|
||||
"setup",
|
||||
"config",
|
||||
"start",
|
||||
"stop",
|
||||
"run",
|
||||
"main",
|
||||
"handler",
|
||||
"middleware",
|
||||
"auth",
|
||||
"validate",
|
||||
"parse",
|
||||
"serialize",
|
||||
"console",
|
||||
"log",
|
||||
"error",
|
||||
"warn",
|
||||
"info",
|
||||
"debug",
|
||||
"trace",
|
||||
"assert",
|
||||
"clear",
|
||||
"count",
|
||||
"countReset",
|
||||
"group",
|
||||
"groupCollapsed",
|
||||
"groupEnd",
|
||||
"table",
|
||||
"time",
|
||||
"timeEnd",
|
||||
"timeLog",
|
||||
"profile",
|
||||
"profileEnd",
|
||||
"logger",
|
||||
"logging",
|
||||
"logLevel",
|
||||
"logInfo",
|
||||
"logError",
|
||||
"logWarn",
|
||||
"logDebug",
|
||||
"logTrace",
|
||||
"logFatal",
|
||||
"logCritical",
|
||||
"next",
|
||||
"react",
|
||||
"react-dom",
|
||||
"next-pwa",
|
||||
"next-themes",
|
||||
"import",
|
||||
"export",
|
||||
"from",
|
||||
"as",
|
||||
"webpack",
|
||||
"webpackChunk",
|
||||
"webpackChunkName",
|
||||
"chunk",
|
||||
"chunks",
|
||||
"chunkName",
|
||||
"chunkFilename",
|
||||
"entry",
|
||||
"entries",
|
||||
"entrypoint",
|
||||
"entrypoints",
|
||||
"modules",
|
||||
"moduleId",
|
||||
"moduleIds",
|
||||
"resolve",
|
||||
"resolver",
|
||||
"resolveLoader",
|
||||
"resolveModules",
|
||||
"externals",
|
||||
"externalsType",
|
||||
"externalsPresets",
|
||||
"output",
|
||||
"outputPath",
|
||||
"outputFilename",
|
||||
"outputChunkFilename",
|
||||
"optimization",
|
||||
"minimize",
|
||||
"minimizer",
|
||||
"splitChunks",
|
||||
"plugins",
|
||||
"plugin",
|
||||
"apply",
|
||||
"compiler",
|
||||
"compilation",
|
||||
"loader",
|
||||
"loaders",
|
||||
"use",
|
||||
"test",
|
||||
"include",
|
||||
"exclude",
|
||||
"rules",
|
||||
"rule",
|
||||
"oneOf",
|
||||
"resource",
|
||||
"resourceQuery",
|
||||
"issuer",
|
||||
"issuerLayer",
|
||||
"sideEffects",
|
||||
"parser",
|
||||
"generator",
|
||||
"define",
|
||||
"defined",
|
||||
"definition",
|
||||
"definitions",
|
||||
"factory",
|
||||
"factories",
|
||||
"getter",
|
||||
"getters",
|
||||
"setter",
|
||||
"setters",
|
||||
"amd",
|
||||
"umd",
|
||||
"commonjs",
|
||||
"esm",
|
||||
"es6",
|
||||
"es2015",
|
||||
"es2020",
|
||||
"babel",
|
||||
"babelrc",
|
||||
"tsconfig",
|
||||
"jest",
|
||||
"eslint",
|
||||
"prettier",
|
||||
"rollup",
|
||||
"vite",
|
||||
"parcel",
|
||||
"gulp",
|
||||
"grunt"
|
||||
],
|
||||
|
||||
// ========== 保留重要字符串(扩展版) ==========
|
||||
reservedStrings: [
|
||||
"api",
|
||||
"admin",
|
||||
"user",
|
||||
"auth",
|
||||
"login",
|
||||
"logout",
|
||||
"register",
|
||||
"search",
|
||||
"live",
|
||||
"douban",
|
||||
"favorites",
|
||||
"playrecords",
|
||||
"proxy",
|
||||
"database",
|
||||
"connection",
|
||||
"result",
|
||||
"success",
|
||||
"setting",
|
||||
"option",
|
||||
"parameter",
|
||||
"environment",
|
||||
"file",
|
||||
"path",
|
||||
"directory",
|
||||
"folder",
|
||||
"extension",
|
||||
"logger",
|
||||
"logging",
|
||||
"fatal",
|
||||
"critical",
|
||||
"output",
|
||||
"message",
|
||||
"next",
|
||||
"react",
|
||||
"react-dom",
|
||||
"next-pwa",
|
||||
"next-themes",
|
||||
"webpack",
|
||||
"chunk",
|
||||
"module",
|
||||
"entry",
|
||||
"loader",
|
||||
"plugin",
|
||||
"compiler",
|
||||
"compilation",
|
||||
"require",
|
||||
"import",
|
||||
"export",
|
||||
"default",
|
||||
"from",
|
||||
"as",
|
||||
"use",
|
||||
"test",
|
||||
"include",
|
||||
"define",
|
||||
"factory",
|
||||
"amd",
|
||||
"umd",
|
||||
"commonjs",
|
||||
"esm",
|
||||
"babel",
|
||||
"typescript",
|
||||
"jest",
|
||||
"eslint",
|
||||
"prettier",
|
||||
"rollup",
|
||||
"vite",
|
||||
"parcel",
|
||||
"gulp",
|
||||
"grunt"
|
||||
]
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user