cicy-desktop 2.1.248 → 2.1.249

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.
@@ -64,6 +64,7 @@ jobs:
64
64
  shell: bash
65
65
  env:
66
66
  GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67
+ CICY_OBFUSCATE: "1" # 发版混淆 JS(prebuild 主进程 + Vite 渲染层),仅 release CI
67
68
  run: |
68
69
  set -euo pipefail
69
70
  npm run build:linux -- --publish always
@@ -107,6 +107,7 @@ jobs:
107
107
  env:
108
108
  CSC_IDENTITY_AUTO_DISCOVERY: "false"
109
109
  GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110
+ CICY_OBFUSCATE: "1" # 发版混淆 JS(prebuild 主进程 + Vite 渲染层),仅 release CI
110
111
  run: |
111
112
  set -euo pipefail
112
113
  rm -rf dist
@@ -83,6 +83,7 @@ jobs:
83
83
  shell: powershell
84
84
  env:
85
85
  GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86
+ CICY_OBFUSCATE: "1" # 发版混淆 JS(prebuild 主进程 + Vite 渲染层),仅 release CI
86
87
  run: |
87
88
  if (Test-Path dist) { Remove-Item -Recurse -Force dist }
88
89
  if (Test-Path "build\logo.ico") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cicy-desktop",
3
- "version": "2.1.248",
3
+ "version": "2.1.249",
4
4
  "description": "CiCy - AI-powered operating system browser",
5
5
  "main": "src/main.js",
6
6
  "bin": {
@@ -13,9 +13,9 @@
13
13
  "format:check": "prettier --check \"src/**/*.js\"",
14
14
  "build": "electron-builder --publish never",
15
15
  "build:homepage": "node scripts/build-homepage.cjs",
16
- "prebuild:win": "node scripts/build-homepage.cjs",
17
- "prebuild:mac": "node scripts/build-homepage.cjs",
18
- "prebuild:linux": "node scripts/build-homepage.cjs",
16
+ "prebuild:win": "node scripts/build-homepage.cjs && node scripts/obfuscate.cjs",
17
+ "prebuild:mac": "node scripts/build-homepage.cjs && node scripts/obfuscate.cjs",
18
+ "prebuild:linux": "node scripts/build-homepage.cjs && node scripts/obfuscate.cjs",
19
19
  "prepublishOnly": "node scripts/build-homepage.cjs",
20
20
  "build:win": "electron-builder --win",
21
21
  "build:mac": "electron-builder --mac",
@@ -154,6 +154,7 @@
154
154
  "devDependencies": {
155
155
  "electron": "41.0.3",
156
156
  "electron-builder": "^26.7.0",
157
+ "javascript-obfuscator": "^5.4.7",
157
158
  "prettier": "^3.8.1"
158
159
  }
159
160
  }
@@ -0,0 +1,81 @@
1
+ // Copyright 2026 CiCy AI
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Release-time obfuscation of the MAIN-PROCESS source (src/**/*.js), run as part
5
+ // of the prebuild hooks. Electron ships JS as plaintext inside app.asar (anyone can
6
+ // `asar extract` and read it), so on release we obfuscate our authored source.
7
+ //
8
+ // Gated by CICY_OBFUSCATE=1 — set ONLY in the release workflows. Local/dev builds
9
+ // (Loop B on Mac, plain `npm run build:*`) leave the working tree untouched, so this
10
+ // never dirties source you're editing. CI runs on a disposable checkout.
11
+ //
12
+ // The renderer (src/backends/homepage-react) is EXCLUDED here: it's already
13
+ // Vite-minified (identifiers mangled, comments stripped) and additionally obfuscated
14
+ // by vite-plugin-javascript-obfuscator during its own build. Re-obfuscating the
15
+ // bundled React output post-hoc is high-risk / low-reward, so we don't.
16
+
17
+ const fs = require("fs");
18
+ const path = require("path");
19
+
20
+ if (process.env.CICY_OBFUSCATE !== "1") {
21
+ console.log("[obfuscate] CICY_OBFUSCATE != 1 — skipping (dev build, source untouched).");
22
+ process.exit(0);
23
+ }
24
+
25
+ const JavaScriptObfuscator = require("javascript-obfuscator");
26
+ const ROOT = path.join(__dirname, "..");
27
+ const SRC = path.join(ROOT, "src");
28
+ const EXCLUDE_DIRS = [
29
+ path.join(SRC, "backends", "homepage-react"), // Vite-built SPA snapshot (obfuscated by the Vite plugin)
30
+ ];
31
+
32
+ // 保守配置:重命名标识符 + 字符串数组(base64)+ compact。**故意关掉** controlFlowFlattening /
33
+ // deadCodeInjection / selfDefending / debugProtection —— 这几项最容易把代码搞坏、且严重拖慢启动。
34
+ // 目标是"读不懂",不是"跑不动"。renameGlobals=false:绝不动 require/module/exports/process 等全局名。
35
+ const OPTIONS = {
36
+ compact: true,
37
+ simplify: true,
38
+ target: "node",
39
+ identifierNamesGenerator: "hexadecimal",
40
+ renameGlobals: false,
41
+ stringArray: true,
42
+ stringArrayThreshold: 0.75,
43
+ stringArrayEncoding: ["base64"],
44
+ splitStrings: false,
45
+ numbersToExpressions: false,
46
+ controlFlowFlattening: false,
47
+ deadCodeInjection: false,
48
+ selfDefending: false,
49
+ debugProtection: false,
50
+ disableConsoleOutput: false,
51
+ unicodeEscapeSequence: false,
52
+ };
53
+
54
+ function isExcluded(p) {
55
+ return EXCLUDE_DIRS.some((d) => p === d || p.startsWith(d + path.sep));
56
+ }
57
+ function* walkJs(dir) {
58
+ for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
59
+ const full = path.join(dir, e.name);
60
+ if (isExcluded(full)) continue;
61
+ if (e.isDirectory()) yield* walkJs(full);
62
+ else if (e.isFile() && full.endsWith(".js")) yield full;
63
+ }
64
+ }
65
+
66
+ let count = 0;
67
+ let outBytes = 0;
68
+ for (const file of walkJs(SRC)) {
69
+ const code = fs.readFileSync(file, "utf8");
70
+ try {
71
+ const out = JavaScriptObfuscator.obfuscate(code, OPTIONS).getObfuscatedCode();
72
+ fs.writeFileSync(file, out);
73
+ count++;
74
+ outBytes += out.length;
75
+ } catch (e) {
76
+ // Fail the build rather than ship a half-obfuscated app.
77
+ console.error(`[obfuscate] FAILED ${path.relative(ROOT, file)}: ${e.message}`);
78
+ process.exit(1);
79
+ }
80
+ }
81
+ console.log(`[obfuscate] obfuscated ${count} main-process file(s), ${Math.round(outBytes / 1024)}KB total (renderer handled by the Vite plugin).`);