@winner-fed/winner-deploy 4.3.8 → 4.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -28
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/see/bash/scripts/js/confuse.sh +4 -2
- package/templates/see/bash/scripts/js/readme.md +2 -2
- package/templates/see/python/scripts/js/confuse.sh +4 -2
- package/templates/see/python/scripts/js/readme.md +2 -2
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
- 🐳 支持 Docker 容器化部署(`seePackageType: 'docker'`)
|
|
14
14
|
- 🔧 灵活的模板变量配置系统(`variablesFunc` / `tplPath`)
|
|
15
15
|
- 📝 支持 Python 和 Bash 两种脚本类型
|
|
16
|
-
- 🔒 可选的安装后配置 JS 混淆(`enableObfuscation
|
|
16
|
+
- 🔒 可选的安装后配置 JS 混淆(`enableObfuscation`):有 node 走强混淆,无 node 回退 bash 轻量混淆
|
|
17
17
|
- 🎯 可自定义文件拷贝和配置生成逻辑
|
|
18
18
|
|
|
19
19
|
## 安装
|
|
@@ -91,28 +91,28 @@ generateSeePackageZip(
|
|
|
91
91
|
|
|
92
92
|
#### 参数说明
|
|
93
93
|
|
|
94
|
-
| 参数名 | 类型 | 默认值 | 必填 | 说明
|
|
95
|
-
| ----------------- | -------------------------------------- | ------------------------------------ | ---- |
|
|
96
|
-
| system | string | `'winner-front'` | 否 | 系统类型,SEE 平台分组维度
|
|
97
|
-
| type | `'bizframe' \| 'subsystem'` | `'bizframe'` | 否 | 应用类型:外框架或子系统
|
|
98
|
-
| name | string | - | 是 | 发布物名称(子系统标识、脚本目录名等)
|
|
99
|
-
| version | string | - | 是 | 发布包版本
|
|
100
|
-
| description | string | - | 否 | 发布包说明,写入 deploy.xml
|
|
101
|
-
| appType | string | `name` | 否 | 发布物类型
|
|
102
|
-
| appName | string | `name` | 否 | deploy.xml 中 `appName` 标签
|
|
103
|
-
| group | string | `'bizframe'` | 否 | 应用分组
|
|
104
|
-
| configName | string | `'config.local'` | 否 | 配置文件名(不含 `.js`)。为空时可构建不含配置 JS 的静态包,此时 `scriptsType` 应使用 `bash`。实际写入 template 的文件名还会按项目类型自动推断:存在 `dist/config.local.js` 时用 `config.local`,存在 `dist/sysconfig.js`(或子包路径下)时用 `sysconfig`
|
|
105
|
-
| outputName | string | `'dist'` | 否 | 构建产物目录名(相对项目根目录)
|
|
106
|
-
| seePackageName | string | `` `${system}-${name}-${version}` `` | 否 | zip 包文件名(不含 `.zip`)
|
|
107
|
-
| seePackagePath | string | `'package'` | 否 | zip 输出目录,相对项目根目录;设为 `'/'` 时输出到当前目录
|
|
108
|
-
| seePackageType | `'web' \| 'docker'` | `'web'` | 否 | 发布物类型
|
|
109
|
-
| dockerImage | string | - | 否 | Docker 镜像名,`seePackageType` 为 `'docker'` 时生效
|
|
110
|
-
| scriptsType | `'python' \| 'bash'` | `'python'` | 否 | 集群脚本语言
|
|
111
|
-
| enableObfuscation | boolean | `false` | 否 | 为 `true` 时打包 `scripts/{name}/js
|
|
112
|
-
| tplPath | `Record<string, string>` | `{}` | 否 | 自定义模板:`key` 为包内文件名,`value` 为本地绝对路径。`deploy.xml` 同名则覆盖生成的 deploy.xml;`sysconfig.js` / `config.local.js` 会跳过自动生成对应配置
|
|
113
|
-
| copyFiles | `string[]` | - | 否 | 额外拷贝到包内 `source/{name}/` 的文件名列表,源路径为 `` `${outputName}/${name}/${file}` ``
|
|
114
|
-
| templateFunc | `() => string \| undefined` | 见下文 | 否 | 返回待写入 template 的配置 JS 源文件路径
|
|
115
|
-
| variablesFunc | `() => FieldAttributes[] \| undefined` | 见下文 | 否 | 返回 deploy.xml 动态表单项
|
|
94
|
+
| 参数名 | 类型 | 默认值 | 必填 | 说明 |
|
|
95
|
+
| ----------------- | -------------------------------------- | ------------------------------------ | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
96
|
+
| system | string | `'winner-front'` | 否 | 系统类型,SEE 平台分组维度 |
|
|
97
|
+
| type | `'bizframe' \| 'subsystem'` | `'bizframe'` | 否 | 应用类型:外框架或子系统 |
|
|
98
|
+
| name | string | - | 是 | 发布物名称(子系统标识、脚本目录名等) |
|
|
99
|
+
| version | string | - | 是 | 发布包版本 |
|
|
100
|
+
| description | string | - | 否 | 发布包说明,写入 deploy.xml |
|
|
101
|
+
| appType | string | `name` | 否 | 发布物类型 |
|
|
102
|
+
| appName | string | `name` | 否 | deploy.xml 中 `appName` 标签 |
|
|
103
|
+
| group | string | `'bizframe'` | 否 | 应用分组 |
|
|
104
|
+
| configName | string | `'config.local'` | 否 | 配置文件名(不含 `.js`)。为空时可构建不含配置 JS 的静态包,此时 `scriptsType` 应使用 `bash`。实际写入 template 的文件名还会按项目类型自动推断:存在 `dist/config.local.js` 时用 `config.local`,存在 `dist/sysconfig.js`(或子包路径下)时用 `sysconfig` |
|
|
105
|
+
| outputName | string | `'dist'` | 否 | 构建产物目录名(相对项目根目录) |
|
|
106
|
+
| seePackageName | string | `` `${system}-${name}-${version}` `` | 否 | zip 包文件名(不含 `.zip`) |
|
|
107
|
+
| seePackagePath | string | `'package'` | 否 | zip 输出目录,相对项目根目录;设为 `'/'` 时输出到当前目录 |
|
|
108
|
+
| seePackageType | `'web' \| 'docker'` | `'web'` | 否 | 发布物类型 |
|
|
109
|
+
| dockerImage | string | - | 否 | Docker 镜像名,`seePackageType` 为 `'docker'` 时生效 |
|
|
110
|
+
| scriptsType | `'python' \| 'bash'` | `'python'` | 否 | 集群脚本语言 |
|
|
111
|
+
| enableObfuscation | boolean | `false` | 否 | 为 `true` 时打包 `scripts/{name}/js/`,并在 `afterInstall` 中对已注入变量后的配置 JS 做混淆:有 `node` 用 `confuse.js`(javascript-obfuscator 强混淆),无 `node` 用 `confuse.sh`(base64 + `TextDecoder`/`new Function` 轻量包裹,UTF-8 安全,强度较弱);为 `false` 时不拷贝、不执行混淆 |
|
|
112
|
+
| tplPath | `Record<string, string>` | `{}` | 否 | 自定义模板:`key` 为包内文件名,`value` 为本地绝对路径。`deploy.xml` 同名则覆盖生成的 deploy.xml;`sysconfig.js` / `config.local.js` 会跳过自动生成对应配置 |
|
|
113
|
+
| copyFiles | `string[]` | - | 否 | 额外拷贝到包内 `source/{name}/` 的文件名列表,源路径为 `` `${outputName}/${name}/${file}` `` |
|
|
114
|
+
| templateFunc | `() => string \| undefined` | 见下文 | 否 | 返回待写入 template 的配置 JS 源文件路径 |
|
|
115
|
+
| variablesFunc | `() => FieldAttributes[] \| undefined` | 见下文 | 否 | 返回 deploy.xml 动态表单项 |
|
|
116
116
|
|
|
117
117
|
#### templateFunc 默认值
|
|
118
118
|
|
|
@@ -234,8 +234,9 @@ see-package.zip
|
|
|
234
234
|
│ ├── beforeInstall.sh # 仅 python
|
|
235
235
|
│ ├── conf/manifest.*.json # 仅 python 且 dist 含 manifest 时
|
|
236
236
|
│ └── js/ # 仅 enableObfuscation === true
|
|
237
|
-
│ ├── confuse.js
|
|
238
|
-
│
|
|
237
|
+
│ ├── confuse.js # node 强混淆入口
|
|
238
|
+
│ ├── confuse.sh # 无 node 时的 bash 轻量混淆
|
|
239
|
+
│ └── obfuscator.js # javascript-obfuscator 运行时
|
|
239
240
|
└── source/ # 安装脚本从 tmp/source 部署到 workspace
|
|
240
241
|
└── ...
|
|
241
242
|
```
|
|
@@ -276,7 +277,7 @@ generateSeePackageZip(
|
|
|
276
277
|
|
|
277
278
|
### 3. 开启配置 JS 混淆
|
|
278
279
|
|
|
279
|
-
|
|
280
|
+
混淆必须在 SEE 注入配置变量之后执行,因此放在 `afterInstall`,不能提前到打包阶段。
|
|
280
281
|
|
|
281
282
|
```javascript
|
|
282
283
|
generateSeePackageZip(
|
|
@@ -291,6 +292,14 @@ generateSeePackageZip(
|
|
|
291
292
|
);
|
|
292
293
|
```
|
|
293
294
|
|
|
295
|
+
运行时策略(bash / python 脚本一致):
|
|
296
|
+
|
|
297
|
+
1. 检测到 `node` → 执行 `confuse.js`(AST 级强混淆)
|
|
298
|
+
2. 未检测到 `node` → 执行 `confuse.sh`(整文件 base64 + `TextDecoder`/`new Function` 包裹,UTF-8 安全)
|
|
299
|
+
3. 文件已含 `__WINNER_BASH_OBFUSCATED__` 标记时,`confuse.sh` 会跳过,避免重复包裹
|
|
300
|
+
|
|
301
|
+
`confuse.sh` 仅作无 node 环境的兼容兜底,防护强度远低于 `confuse.js`。
|
|
302
|
+
|
|
294
303
|
### 4. Docker 容器化部署
|
|
295
304
|
|
|
296
305
|
```javascript
|
|
@@ -312,8 +321,8 @@ generateSeePackageZip(
|
|
|
312
321
|
2. **configName**:除手动指定外,会根据 `outputName` 下是否存在 `config.local.js` / `sysconfig.js` 自动选用文件名。
|
|
313
322
|
3. **name 特殊字符**:`@`、`/` 会在打包前替换为 `-`。
|
|
314
323
|
4. **Docker**:使用 Docker 部署时需确保镜像已构建并可被 SEE 环境拉取。
|
|
315
|
-
5. **混淆**:`enableObfuscation: true`
|
|
316
|
-
6. **Python 脚本**:目标环境需具备 Python
|
|
324
|
+
5. **混淆**:`enableObfuscation: true` 时打包 `scripts/{name}/js/`;`afterInstall` 优先用 `node`+`confuse.js`,无 `node` 时回退 `bash`+`confuse.sh`。纯 bash 无法复现 javascript-obfuscator 级别的混淆。
|
|
325
|
+
6. **Python 脚本**:目标环境需具备 Python 运行时;开启混淆时建议有 `node`,否则走 bash 轻量混淆(仍需系统有 `bash` / `base64`)。
|
|
317
326
|
|
|
318
327
|
## 更新日志
|
|
319
328
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** build time: Thu Jul 30 2026
|
|
1
|
+
/** build time: Thu Jul 30 2026 11:03:48 GMT+0800 (中国标准时间), build version 4.3.9 **/
|
|
2
2
|
var xe=Object.create;var X=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames,ee=Object.getOwnPropertySymbols,Te=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty,ke=Object.prototype.propertyIsEnumerable;var te=(r,t,n)=>t in r?X(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n,U=(r,t)=>{for(var n in t||(t={}))ne.call(t,n)&&te(r,n,t[n]);if(ee)for(var n of ee(t))ke.call(t,n)&&te(r,n,t[n]);return r};var _e=(r,t)=>{for(var n in t)X(r,n,{get:t[n],enumerable:!0})},oe=(r,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of Oe(t))!ne.call(r,l)&&l!==n&&X(r,l,{get:()=>t[l],enumerable:!(i=be(t,l))||i.enumerable});return r};var O=(r,t,n)=>(n=r!=null?xe(Te(r)):{},oe(t||!r||!r.__esModule?X(n,"default",{value:r,enumerable:!0}):n,r)),Ae=r=>oe(X({},"__esModule",{value:!0}),r);var ve={};_e(ve,{generateSeePackageZip:()=>De});module.exports=Ae(ve);var Se=O(require("chalk"),1),$e=O(require("path"),1),T=O(require("fs-extra"),1);var ye=O(require("path"),1),b=O(require("fs-extra"),1),W=require("rimraf");var C=O(require("path"),1),K=O(require("fs-extra"),1),re=O(require("archiver"),1),q=O(require("xml"),1);var B=process.cwd(),V=function(t){let n={""":'"',"'":"'","<":"<",">":">"},i=/(")|(')|(<)|(>)/g;return t&&t.replace?t.replace(i,function(l){return n[l]}):t},D=function(t,n){let i=n||"",l=C.default.resolve(B,t,i,"sysconfig.js");return K.default.pathExistsSync(l)},L=function(t){let n=C.default.resolve(B,t,"config.local.js");return K.default.pathExistsSync(n)},I=function(t,n,i,l){let o=C.default.join(B,n);n!=="/"&&K.default.ensureDirSync(o);let e=K.default.createWriteStream(`${n==="/"?".":o}/${t}.zip`);e.on("close",function(){setTimeout(function(){l&&l()})});let s=(0,re.default)("zip",{zlib:{level:9}});s.on("error",function(c){console.error(),console.error(c.stack||c),c.details&&console.error(c.details)}),s.pipe(e),s.directory(i,!1),s.finalize()},Z=function(t,n,i){let{type:l,label:o,name:e,tooltip:s="",visible:c="true",required:a="false",fixed:$="false",fold:f="false",options:m="",validate:d="",upgrade:p="false"}=t,P=t.default;if(i==="form"){let k=(0,q.default)({form:[{_attr:{name:e,tooltip:s,visible:c,required:a,fixed:$,fold:f,options:m,validate:d,upgrade:p}},n]});return V(k)}let y=l==="complexSelect"?{default:t.default}:{},g=(0,q.default)({field:[{_attr:U({type:l,label:o,name:e,tooltip:s,visible:c,required:a,fixed:$,fold:f,options:m,validate:d,upgrade:p},y)},n||P]});return V(g)},ie=function(t){let i=t.children.map(l=>{let e=l.children.map(s=>Z(s)).join("");return Z(l,e,"form")}).join("");return Z(t,i)},z=function r(t,n,i="",l=""){for(let o=0;o<t.length;o++){let e=t[o];if(e.type==="complexSelect"?(e.fullName=`${e.name}`,e.fullPath=`${e.type}`):(e.fullName=`${i===""?"":i+"."}${e.name}`,e.fullPath=`${l===""?"":l+"-"}${e.type}`),n(e))return e;if(e.children&&e.children.length>0){let s=r(e.children,n,e.fullName,e.fullPath);if(s)return s}}return null};function le(r="python"){return r==="python"?"py":"sh"}var w=O(require("fs-extra"),1),se=O(require("path"),1),E=O(require("lodash.template"),1),ce=O(require("xml"),1),ae=O(require("@babel/core"),1);var Pe=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],Q=r=>se.default.resolve(__dirname,`../templates/see/${r}`),J=r=>{let t=r.type;if(!Pe.includes(t))return"";let{label:n,name:i,tooltip:l="",visible:o="true",required:e="false",fixed:s="false",fold:c="false",options:a="",validate:$="",upgrade:f="false",expose:m="",algorithm:d="",merge:p="",isomeris:P="",old_name:y=""}=r,g=r.default;if(t==="table"){let u=r.keys||[];g=(r.columns||u).map(x=>J(x)).join(`
|
|
3
3
|
`)}else if(t==="switchForm"||t==="division"){let u=r.children;g=u?u.map(h=>J(h)).join(`
|
|
4
4
|
`):""}else{if(t==="complexSelect")return ie(r);t==="editor"?g=typeof g=="object"?[JSON.stringify(g)]:[g]:g=[g]}let k=t==="switchForm"?{default:r.default}:{},F=U({type:t,label:n,name:i,tooltip:l,visible:o,required:e,fixed:s,fold:c,options:a,validate:$,upgrade:f,expose:m,algorithm:d,merge:p,isomeris:P,old_name:y},k),N=Object.fromEntries(Object.entries(F).filter(([u,h])=>h!==""&&h!==null&&h!==void 0)),j=(0,ce.default)({field:[{_attr:N},...Array.isArray(g)?g:[g]]});return V(j)},fe=function({system:t,type:n,name:i,appType:l,appName:o,group:e,version:s,configFileName:c="config.local",variables:a=[],description:$,scriptsType:f="python"}){let m=w.default.readFileSync(Q(`${f}/deploy.xml`)).toString();return(0,E.default)(m,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:i,appName:o,appType:l,group:e,version:s,configFileName:c,variables:a.map(d=>J(d)).join(`
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** build time: Thu Jul 30 2026
|
|
1
|
+
/** build time: Thu Jul 30 2026 11:03:48 GMT+0800 (中国标准时间), build version 4.3.9 **/
|
|
2
2
|
var fe=Object.defineProperty;var q=Object.getOwnPropertySymbols;var pe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var B=(i,t,n)=>t in i?fe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[t]=n,K=(i,t)=>{for(var n in t||(t={}))pe.call(t,n)&&B(i,n,t[n]);if(q)for(var n of q(t))me.call(t,n)&&B(i,n,t[n]);return i};var W=(i=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(i,{get:(t,n)=>(typeof require!="undefined"?require:t)[n]}):i)(function(i){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});import he from"chalk";import xe from"path";import k from"fs-extra";import $e from"path";import b from"fs-extra";import{rimraf as re}from"rimraf";import z from"path";import L from"fs-extra";import ue from"archiver";import G from"xml";var J=process.cwd(),Q=function(t){let n={""":'"',"'":"'","<":"<",">":">"},r=/(")|(')|(<)|(>)/g;return t&&t.replace?t.replace(r,function(c){return n[c]}):t},j=function(t,n){let r=n||"",c=z.resolve(J,t,r,"sysconfig.js");return L.pathExistsSync(c)},E=function(t){let n=z.resolve(J,t,"config.local.js");return L.pathExistsSync(n)},N=function(t,n,r,c){let o=z.join(J,n);n!=="/"&&L.ensureDirSync(o);let e=L.createWriteStream(`${n==="/"?".":o}/${t}.zip`);e.on("close",function(){setTimeout(function(){c&&c()})});let l=ue("zip",{zlib:{level:9}});l.on("error",function(s){console.error(),console.error(s.stack||s),s.details&&console.error(s.details)}),l.pipe(e),l.directory(r,!1),l.finalize()},C=function(t,n,r){let{type:c,label:o,name:e,tooltip:l="",visible:s="true",required:a="false",fixed:$="false",fold:f="false",options:m="",validate:d="",upgrade:p="false"}=t,A=t.default;if(r==="form"){let O=G({form:[{_attr:{name:e,tooltip:l,visible:s,required:a,fixed:$,fold:f,options:m,validate:d,upgrade:p}},n]});return Q(O)}let y=c==="complexSelect"?{default:t.default}:{},g=G({field:[{_attr:K({type:c,label:o,name:e,tooltip:l,visible:s,required:a,fixed:$,fold:f,options:m,validate:d,upgrade:p},y)},n||A]});return Q(g)},H=function(t){let r=t.children.map(c=>{let e=c.children.map(l=>C(l)).join("");return C(c,e,"form")}).join("");return C(t,r)},U=function i(t,n,r="",c=""){for(let o=0;o<t.length;o++){let e=t[o];if(e.type==="complexSelect"?(e.fullName=`${e.name}`,e.fullPath=`${e.type}`):(e.fullName=`${r===""?"":r+"."}${e.name}`,e.fullPath=`${c===""?"":c+"-"}${e.type}`),n(e))return e;if(e.children&&e.children.length>0){let l=i(e.children,n,e.fullName,e.fullPath);if(l)return l}}return null};function Y(i="python"){return i==="python"?"py":"sh"}import M from"fs-extra";import ye from"path";import R from"lodash.template";import ge from"xml";import de from"@babel/core";var Se=["input","editor","select","switch","smallfile","table","mselect","switchForm","complexSelect","division","password","hidden"],X=i=>ye.resolve(__dirname,`../templates/see/${i}`),V=i=>{let t=i.type;if(!Se.includes(t))return"";let{label:n,name:r,tooltip:c="",visible:o="true",required:e="false",fixed:l="false",fold:s="false",options:a="",validate:$="",upgrade:f="false",expose:m="",algorithm:d="",merge:p="",isomeris:A="",old_name:y=""}=i,g=i.default;if(t==="table"){let u=i.keys||[];g=(i.columns||u).map(x=>V(x)).join(`
|
|
3
3
|
`)}else if(t==="switchForm"||t==="division"){let u=i.children;g=u?u.map(h=>V(h)).join(`
|
|
4
4
|
`):""}else{if(t==="complexSelect")return H(i);t==="editor"?g=typeof g=="object"?[JSON.stringify(g)]:[g]:g=[g]}let O=t==="switchForm"?{default:i.default}:{},P=K({type:t,label:n,name:r,tooltip:c,visible:o,required:e,fixed:l,fold:s,options:a,validate:$,upgrade:f,expose:m,algorithm:d,merge:p,isomeris:A,old_name:y},O),v=Object.fromEntries(Object.entries(P).filter(([u,h])=>h!==""&&h!==null&&h!==void 0)),F=ge({field:[{_attr:v},...Array.isArray(g)?g:[g]]});return Q(F)},ee=function({system:t,type:n,name:r,appType:c,appName:o,group:e,version:l,configFileName:s="config.local",variables:a=[],description:$,scriptsType:f="python"}){let m=M.readFileSync(X(`${f}/deploy.xml`)).toString();return R(m,{interpolate:/{{([\s\S]+?)}}/g})({system:t,type:n,name:r,appName:o,appType:c,group:e,version:l,configFileName:s,variables:a.map(d=>V(d)).join(`
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
# 无 node 时的轻量混淆:整文件 base64 +
|
|
2
|
+
# 无 node 时的轻量混淆:整文件 base64 + TextDecoder/new Function 包裹。
|
|
3
3
|
# 强度远低于 confuse.js(javascript-obfuscator),仅作兼容兜底。
|
|
4
4
|
# 参数:webAppName configBase [pkgRoot]
|
|
5
5
|
|
|
@@ -34,6 +34,7 @@ if grep -q '__WINNER_BASH_OBFUSCATED__' "$filepath" 2>/dev/null; then
|
|
|
34
34
|
exit 0
|
|
35
35
|
fi
|
|
36
36
|
|
|
37
|
+
# 可移植:避免 GNU 专用的 base64 -w 0
|
|
37
38
|
b64=$(base64 < "$filepath" | tr -d '\n\r')
|
|
38
39
|
if [ -z "$b64" ]; then
|
|
39
40
|
echo -e "${ERROR_ICON} base64 编码失败" >&2
|
|
@@ -41,9 +42,10 @@ if [ -z "$b64" ]; then
|
|
|
41
42
|
fi
|
|
42
43
|
|
|
43
44
|
tmpfile="${filepath}.obf.$$"
|
|
45
|
+
# UTF-8 安全:atob → Uint8Array → TextDecoder,再 new Function 执行
|
|
44
46
|
cat > "$tmpfile" <<EOF
|
|
45
47
|
/* __WINNER_BASH_OBFUSCATED__ */
|
|
46
|
-
(
|
|
48
|
+
(new Function(new TextDecoder("utf-8").decode(Uint8Array.from(atob("${b64}"),function(c){return c.charCodeAt(0)}))))();
|
|
47
49
|
EOF
|
|
48
50
|
|
|
49
51
|
if [ $? -ne 0 ]; then
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
依赖 node + javascript-obfuscator(obfuscator.js),强混淆。
|
|
5
5
|
|
|
6
6
|
2. scripts/js/confuse.sh
|
|
7
|
-
无 node 时的 bash 兜底:整文件 base64 + `(
|
|
7
|
+
无 node 时的 bash 兜底:整文件 base64 + `(new Function(new TextDecoder("utf-8").decode(Uint8Array.from(atob("..."), ...))))()` 包裹(UTF-8 安全)。
|
|
8
8
|
参数与 confuse.js 相同。强度远弱于 confuse.js,仅兼容无 node 环境。
|
|
9
|
-
|
|
9
|
+
`base64 | tr -d` 保证 Linux/macOS 可移植;已带 `__WINNER_BASH_OBFUSCATED__` 时跳过。
|
|
10
10
|
|
|
11
11
|
3. scripts/afterInstall.sh
|
|
12
12
|
`enableObfuscation` 为真时:有 node 走 confuse.js,否则走 confuse.sh。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
# 无 node 时的轻量混淆:整文件 base64 +
|
|
2
|
+
# 无 node 时的轻量混淆:整文件 base64 + TextDecoder/new Function 包裹。
|
|
3
3
|
# 强度远低于 confuse.js(javascript-obfuscator),仅作兼容兜底。
|
|
4
4
|
# 参数:webAppName configBase [pkgRoot]
|
|
5
5
|
|
|
@@ -34,6 +34,7 @@ if grep -q '__WINNER_BASH_OBFUSCATED__' "$filepath" 2>/dev/null; then
|
|
|
34
34
|
exit 0
|
|
35
35
|
fi
|
|
36
36
|
|
|
37
|
+
# 可移植:避免 GNU 专用的 base64 -w 0
|
|
37
38
|
b64=$(base64 < "$filepath" | tr -d '\n\r')
|
|
38
39
|
if [ -z "$b64" ]; then
|
|
39
40
|
echo -e "${ERROR_ICON} base64 编码失败" >&2
|
|
@@ -41,9 +42,10 @@ if [ -z "$b64" ]; then
|
|
|
41
42
|
fi
|
|
42
43
|
|
|
43
44
|
tmpfile="${filepath}.obf.$$"
|
|
45
|
+
# UTF-8 安全:atob → Uint8Array → TextDecoder,再 new Function 执行
|
|
44
46
|
cat > "$tmpfile" <<EOF
|
|
45
47
|
/* __WINNER_BASH_OBFUSCATED__ */
|
|
46
|
-
(
|
|
48
|
+
(new Function(new TextDecoder("utf-8").decode(Uint8Array.from(atob("${b64}"),function(c){return c.charCodeAt(0)}))))();
|
|
47
49
|
EOF
|
|
48
50
|
|
|
49
51
|
if [ $? -ne 0 ]; then
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
依赖 node + javascript-obfuscator(obfuscator.js),强混淆。
|
|
5
5
|
|
|
6
6
|
2. scripts/js/confuse.sh
|
|
7
|
-
无 node 时的 bash 兜底:整文件 base64 + `(
|
|
7
|
+
无 node 时的 bash 兜底:整文件 base64 + `(new Function(new TextDecoder("utf-8").decode(Uint8Array.from(atob("..."), ...))))()` 包裹(UTF-8 安全)。
|
|
8
8
|
参数与 confuse.js 相同。强度远弱于 confuse.js,仅兼容无 node 环境。
|
|
9
|
-
|
|
9
|
+
`base64 | tr -d` 保证 Linux/macOS 可移植;已带 `__WINNER_BASH_OBFUSCATED__` 时跳过。
|
|
10
10
|
|
|
11
11
|
3. scripts/afterInstall.sh
|
|
12
12
|
`enableObfuscation` 为真时:有 node 走 confuse.js,否则走 confuse.sh。
|