ccjk 13.3.5 → 13.3.7
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/dist/chunks/agent-teams.mjs +7 -5
- package/dist/chunks/agent.mjs +2 -2
- package/dist/chunks/agents.mjs +16 -16
- package/dist/chunks/api-cli.mjs +6 -6
- package/dist/chunks/api-providers.mjs +1 -1
- package/dist/chunks/api.mjs +4 -4
- package/dist/chunks/auto-bootstrap.mjs +1 -1
- package/dist/chunks/auto-fix.mjs +49 -4
- package/dist/chunks/auto-fixer.mjs +7 -5
- package/dist/chunks/auto-init.mjs +9 -7208
- package/dist/chunks/auto-memory-bridge.mjs +9 -3
- package/dist/chunks/auto-updater.mjs +9 -9
- package/dist/chunks/auto-upgrade.mjs +5 -3
- package/dist/chunks/banner.mjs +4 -3
- package/dist/chunks/boost.mjs +118 -62
- package/dist/chunks/ccjk-agents.mjs +3 -3
- package/dist/chunks/ccjk-all.mjs +7 -7
- package/dist/chunks/ccjk-config.mjs +2 -2
- package/dist/chunks/ccjk-hooks.mjs +4 -4
- package/dist/chunks/ccjk-mcp.mjs +5 -5
- package/dist/chunks/ccjk-setup.mjs +5 -5
- package/dist/chunks/ccjk-skills.mjs +5 -5
- package/dist/chunks/ccr.mjs +18 -16
- package/dist/chunks/ccu.mjs +2 -2
- package/dist/chunks/check-updates.mjs +8 -8
- package/dist/chunks/claude-code-config-manager.mjs +11 -8
- package/dist/chunks/claude-code-incremental-manager.mjs +7 -7
- package/dist/chunks/claude-config.mjs +1 -1
- package/dist/chunks/claude-wrapper.mjs +1 -1
- package/dist/chunks/cli-hook.mjs +15 -15
- package/dist/chunks/codex-config-switch.mjs +7 -7
- package/dist/chunks/codex-provider-manager.mjs +7 -7
- package/dist/chunks/codex-uninstaller.mjs +2 -2
- package/dist/chunks/codex.mjs +5 -5
- package/dist/chunks/commands.mjs +2 -2
- package/dist/chunks/commands2.mjs +3 -3
- package/dist/chunks/commit.mjs +2 -2
- package/dist/chunks/completion.mjs +2 -2
- package/dist/chunks/config-consolidator.mjs +2 -2
- package/dist/chunks/config-switch.mjs +8 -8
- package/dist/chunks/config.mjs +6 -5
- package/dist/chunks/config2.mjs +5 -5
- package/dist/chunks/config3.mjs +4 -4
- package/dist/chunks/constants.mjs +1 -1
- package/dist/chunks/context-opt.mjs +92 -90
- package/dist/chunks/context.mjs +659 -0
- package/dist/chunks/dashboard.mjs +14 -9
- package/dist/chunks/doctor.mjs +4 -4
- package/dist/chunks/eval.mjs +502 -0
- package/dist/chunks/evolution.mjs +46 -39
- package/dist/chunks/health-alerts.mjs +9 -9
- package/dist/chunks/help.mjs +1 -1
- package/dist/chunks/hook-installer.mjs +6 -3
- package/dist/chunks/index.mjs +23 -0
- package/dist/chunks/index10.mjs +634 -571
- package/dist/chunks/index11.mjs +1061 -569
- package/dist/chunks/index12.mjs +914 -1076
- package/dist/chunks/index13.mjs +136 -951
- package/dist/chunks/index14.mjs +209 -185
- package/dist/chunks/index2.mjs +19 -24
- package/dist/chunks/index3.mjs +19085 -12
- package/dist/chunks/index4.mjs +16 -19092
- package/dist/chunks/index5.mjs +7602 -16
- package/dist/chunks/index6.mjs +159 -7590
- package/dist/chunks/index7.mjs +1602 -171
- package/dist/chunks/index8.mjs +19 -1602
- package/dist/chunks/index9.mjs +612 -15
- package/dist/chunks/init.mjs +26 -19
- package/dist/chunks/installer.mjs +5 -5
- package/dist/chunks/installer2.mjs +2 -2
- package/dist/chunks/intent-engine.mjs +1 -1
- package/dist/chunks/interview.mjs +4 -4
- package/dist/chunks/manager.mjs +1 -1
- package/dist/chunks/marketplace.mjs +2 -2
- package/dist/chunks/mcp-cli.mjs +12 -12
- package/dist/chunks/mcp.mjs +8 -8
- package/dist/chunks/memory.mjs +8 -8
- package/dist/chunks/menu-hierarchical.mjs +24 -22
- package/dist/chunks/menu.mjs +27 -22
- package/dist/chunks/metrics-display.mjs +2 -2
- package/dist/chunks/migrator.mjs +1 -1
- package/dist/chunks/monitor.mjs +2 -2
- package/dist/chunks/notification.mjs +6 -6
- package/dist/chunks/onboarding-wizard.mjs +6 -5
- package/dist/chunks/onboarding.mjs +4 -4
- package/dist/chunks/package.mjs +1 -1
- package/dist/chunks/paradigm.mjs +2 -2
- package/dist/chunks/permission-manager.mjs +2 -2
- package/dist/chunks/permissions.mjs +3 -3
- package/dist/chunks/persistence-manager.mjs +19 -12
- package/dist/chunks/persistence.mjs +5 -3
- package/dist/chunks/plugin.mjs +2 -2
- package/dist/chunks/prompts.mjs +5 -5
- package/dist/chunks/providers.mjs +2 -2
- package/dist/chunks/quick-actions.mjs +7 -6
- package/dist/chunks/quick-provider.mjs +5 -4
- package/dist/chunks/quick-setup.mjs +20 -15
- package/dist/chunks/remote.mjs +15 -16
- package/dist/chunks/{convoy-manager.mjs → session-manager.mjs} +1129 -1095
- package/dist/chunks/session.mjs +2 -2
- package/dist/chunks/sessions.mjs +3 -3
- package/dist/chunks/silent-updater.mjs +1 -1
- package/dist/chunks/simple-config.mjs +2 -2
- package/dist/chunks/skill2.mjs +3 -3
- package/dist/chunks/skills-sync.mjs +5 -5
- package/dist/chunks/skills.mjs +3 -3
- package/dist/chunks/slash-commands.mjs +9 -8
- package/dist/chunks/smart-defaults.mjs +9 -5
- package/dist/chunks/startup.mjs +1 -1
- package/dist/chunks/stats.mjs +2 -2
- package/dist/chunks/status.mjs +37 -22
- package/dist/chunks/team.mjs +3 -3
- package/dist/chunks/thinking.mjs +4 -4
- package/dist/chunks/trace.mjs +2 -2
- package/dist/chunks/uninstall.mjs +9 -9
- package/dist/chunks/update.mjs +14 -11
- package/dist/chunks/upgrade-manager.mjs +3 -3
- package/dist/chunks/upgrade.mjs +25 -9
- package/dist/chunks/version-checker.mjs +4 -4
- package/dist/chunks/vim.mjs +3 -3
- package/dist/chunks/workflows.mjs +1 -1
- package/dist/chunks/wsl.mjs +1 -1
- package/dist/chunks/zero-config.mjs +4 -4
- package/dist/cli.mjs +60 -26
- package/dist/index.d.mts +4392 -4392
- package/dist/index.d.ts +4392 -4392
- package/dist/index.mjs +4314 -4314
- package/dist/shared/{ccjk.DcKLglJQ.mjs → ccjk.BIxuVL3_.mjs} +2 -2
- package/dist/shared/{ccjk.DJdmgr2d.mjs → ccjk.BJMRY2Ra.mjs} +5 -3
- package/dist/shared/{ccjk.B1TwPltj.mjs → ccjk.BOu1yav7.mjs} +3 -2
- package/dist/shared/{ccjk.mJpVRDZ8.mjs → ccjk.BWFpnOr3.mjs} +1 -1
- package/dist/shared/{ccjk.BfIpomdz.mjs → ccjk.CHUEFqmw.mjs} +3 -2
- package/dist/shared/{ccjk.CqdbaXqU.mjs → ccjk.CLUL0pAV.mjs} +9 -5
- package/dist/shared/{ccjk.Cot9p9_n.mjs → ccjk.Cjj8SVrn.mjs} +1 -1
- package/dist/shared/{ccjk.CfrpIIKy.mjs → ccjk.Crd_nEfj.mjs} +38 -20
- package/dist/shared/{ccjk.DCw2WnZU.mjs → ccjk.CvChMYvB.mjs} +1 -1
- package/dist/shared/{ccjk.CXzjn01x.mjs → ccjk.D8ZLYSZZ.mjs} +1 -1
- package/dist/shared/{ccjk.BrPUmTqm.mjs → ccjk.DJuyfrlL.mjs} +164 -82
- package/dist/shared/{ccjk.DHXfsrwn.mjs → ccjk.DRfdq6yl.mjs} +4 -4
- package/dist/shared/{ccjk.DXRAZcix.mjs → ccjk.DScm_NnL.mjs} +8 -4
- package/dist/shared/{ccjk.XsJWJuQP.mjs → ccjk.DfZKjHvG.mjs} +6 -128
- package/dist/shared/{ccjk.BFxsJM0k.mjs → ccjk.DwSebGy0.mjs} +4 -3
- package/dist/shared/ccjk.DxWqH-EF.mjs +170 -0
- package/dist/shared/{ccjk.Cwa_FiTX.mjs → ccjk.I6IuYdc_.mjs} +2 -2
- package/dist/shared/{ccjk.DpstNaeR.mjs → ccjk.KpFl2RDA.mjs} +3 -3
- package/dist/shared/{ccjk.dYDLfmph.mjs → ccjk._dESH4Rk.mjs} +1 -1
- package/dist/shared/{ccjk.BxSmJ8B7.mjs → ccjk.wLJHO0Af.mjs} +2 -1
- package/package.json +65 -67
- package/dist/chunks/index15.mjs +0 -218
- package/dist/shared/{ccjk.c-ETfBZ_.mjs → ccjk.eIn-g1yI.mjs} +96 -96
package/dist/chunks/index15.mjs
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { promisify } from 'node:util';
|
|
2
|
-
import childProcess from 'node:child_process';
|
|
3
|
-
import fs, { constants } from 'node:fs/promises';
|
|
4
|
-
import process__default from 'node:process';
|
|
5
|
-
import os__default from 'node:os';
|
|
6
|
-
import fs__default from 'node:fs';
|
|
7
|
-
import 'node:buffer';
|
|
8
|
-
|
|
9
|
-
let isDockerCached;
|
|
10
|
-
|
|
11
|
-
function hasDockerEnv() {
|
|
12
|
-
try {
|
|
13
|
-
fs__default.statSync('/.dockerenv');
|
|
14
|
-
return true;
|
|
15
|
-
} catch {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function hasDockerCGroup() {
|
|
21
|
-
try {
|
|
22
|
-
return fs__default.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
|
|
23
|
-
} catch {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function isDocker() {
|
|
29
|
-
// TODO: Use `??=` when targeting Node.js 16.
|
|
30
|
-
if (isDockerCached === undefined) {
|
|
31
|
-
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return isDockerCached;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let cachedResult;
|
|
38
|
-
|
|
39
|
-
// Podman detection
|
|
40
|
-
const hasContainerEnv = () => {
|
|
41
|
-
try {
|
|
42
|
-
fs__default.statSync('/run/.containerenv');
|
|
43
|
-
return true;
|
|
44
|
-
} catch {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
function isInsideContainer() {
|
|
50
|
-
// TODO: Use `??=` when targeting Node.js 16.
|
|
51
|
-
if (cachedResult === undefined) {
|
|
52
|
-
cachedResult = hasContainerEnv() || isDocker();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return cachedResult;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const isWsl = () => {
|
|
59
|
-
if (process__default.platform !== 'linux') {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (os__default.release().toLowerCase().includes('microsoft')) {
|
|
64
|
-
if (isInsideContainer()) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
if (fs__default.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft')) {
|
|
73
|
-
return !isInsideContainer();
|
|
74
|
-
}
|
|
75
|
-
} catch {}
|
|
76
|
-
|
|
77
|
-
// Fallback for custom kernels: check WSL-specific paths.
|
|
78
|
-
if (
|
|
79
|
-
fs__default.existsSync('/proc/sys/fs/binfmt_misc/WSLInterop')
|
|
80
|
-
|| fs__default.existsSync('/run/WSL')
|
|
81
|
-
) {
|
|
82
|
-
return !isInsideContainer();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return false;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const isWsl$1 = process__default.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
89
|
-
|
|
90
|
-
promisify(childProcess.execFile);
|
|
91
|
-
|
|
92
|
-
const powerShellPath$1 = () => `${process__default.env.SYSTEMROOT || process__default.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
93
|
-
|
|
94
|
-
function parseMountPointFromConfig(content) {
|
|
95
|
-
for (const line of content.split('\n')) {
|
|
96
|
-
// Skip comment lines
|
|
97
|
-
if (/^\s*#/.test(line)) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Match root at start of line (after optional whitespace)
|
|
102
|
-
const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
103
|
-
if (!match) {
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return match.groups.mountPoint
|
|
108
|
-
.trim()
|
|
109
|
-
// Strip surrounding quotes
|
|
110
|
-
.replaceAll(/^["']|["']$/g, '');
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const execFile = promisify(childProcess.execFile);
|
|
115
|
-
|
|
116
|
-
const wslDrivesMountPoint = (() => {
|
|
117
|
-
// Default value for "root" param
|
|
118
|
-
// according to https://docs.microsoft.com/en-us/windows/wsl/wsl-config
|
|
119
|
-
const defaultMountPoint = '/mnt/';
|
|
120
|
-
|
|
121
|
-
let mountPoint;
|
|
122
|
-
|
|
123
|
-
return async function () {
|
|
124
|
-
if (mountPoint) {
|
|
125
|
-
// Return memoized mount point value
|
|
126
|
-
return mountPoint;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const configFilePath = '/etc/wsl.conf';
|
|
130
|
-
|
|
131
|
-
let isConfigFileExists = false;
|
|
132
|
-
try {
|
|
133
|
-
await fs.access(configFilePath, constants.F_OK);
|
|
134
|
-
isConfigFileExists = true;
|
|
135
|
-
} catch {}
|
|
136
|
-
|
|
137
|
-
if (!isConfigFileExists) {
|
|
138
|
-
return defaultMountPoint;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const configContent = await fs.readFile(configFilePath, {encoding: 'utf8'});
|
|
142
|
-
const parsedMountPoint = parseMountPointFromConfig(configContent);
|
|
143
|
-
|
|
144
|
-
if (parsedMountPoint === undefined) {
|
|
145
|
-
return defaultMountPoint;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
mountPoint = parsedMountPoint;
|
|
149
|
-
mountPoint = mountPoint.endsWith('/') ? mountPoint : `${mountPoint}/`;
|
|
150
|
-
|
|
151
|
-
return mountPoint;
|
|
152
|
-
};
|
|
153
|
-
})();
|
|
154
|
-
|
|
155
|
-
const powerShellPathFromWsl = async () => {
|
|
156
|
-
const mountPoint = await wslDrivesMountPoint();
|
|
157
|
-
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const powerShellPath = isWsl$1 ? powerShellPathFromWsl : powerShellPath$1;
|
|
161
|
-
|
|
162
|
-
// Cache for PowerShell accessibility check
|
|
163
|
-
let canAccessPowerShellPromise;
|
|
164
|
-
|
|
165
|
-
const canAccessPowerShell = async () => {
|
|
166
|
-
canAccessPowerShellPromise ??= (async () => {
|
|
167
|
-
try {
|
|
168
|
-
const psPath = await powerShellPath();
|
|
169
|
-
await fs.access(psPath, constants.X_OK);
|
|
170
|
-
return true;
|
|
171
|
-
} catch {
|
|
172
|
-
// PowerShell is not accessible (either doesn't exist, no execute permission, or other error)
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
})();
|
|
176
|
-
|
|
177
|
-
return canAccessPowerShellPromise;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
const isUrl = path => /^[a-z]+:\/\//i.test(path);
|
|
181
|
-
|
|
182
|
-
const convertWslPathToWindows = async paths => {
|
|
183
|
-
const isBatch = Array.isArray(paths);
|
|
184
|
-
const pathArray = isBatch ? paths : [paths];
|
|
185
|
-
|
|
186
|
-
// Find indices of non-URL paths that need conversion
|
|
187
|
-
const indicesToConvert = [];
|
|
188
|
-
const pathsToConvert = [];
|
|
189
|
-
|
|
190
|
-
for (const [index, path] of pathArray.entries()) {
|
|
191
|
-
if (!isUrl(path)) {
|
|
192
|
-
indicesToConvert.push(index);
|
|
193
|
-
pathsToConvert.push(path);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Start with original paths (URLs stay as-is)
|
|
198
|
-
const results = [...pathArray];
|
|
199
|
-
|
|
200
|
-
if (pathsToConvert.length > 0) {
|
|
201
|
-
try {
|
|
202
|
-
const {stdout} = await execFile('wslpath', ['-aw', ...pathsToConvert], {encoding: 'utf8'});
|
|
203
|
-
const convertedPaths = stdout.split(/\r?\n/).filter(Boolean);
|
|
204
|
-
|
|
205
|
-
for (const [index, originalIndex] of indicesToConvert.entries()) {
|
|
206
|
-
results[originalIndex] = convertedPaths[index] ?? pathArray[originalIndex];
|
|
207
|
-
}
|
|
208
|
-
} catch {
|
|
209
|
-
// If wslpath fails, keep original paths
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return isBatch ? results : results[0];
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
const isUncPath = path => /^\\\\/u.test(path);
|
|
217
|
-
|
|
218
|
-
export { canAccessPowerShell, convertWslPathToWindows, isUncPath, isWsl$1 as isWsl, powerShellPath, powerShellPathFromWsl, wslDrivesMountPoint };
|
|
@@ -1,106 +1,11 @@
|
|
|
1
1
|
import { existsSync, readFileSync, mkdirSync, unlinkSync } from 'node:fs';
|
|
2
2
|
import os__default, { homedir } from 'node:os';
|
|
3
|
+
import { c as createDefaultGateway } from './ccjk.BtB1e5jm.mjs';
|
|
3
4
|
import { writeFileAtomic } from '../chunks/fs-operations.mjs';
|
|
4
5
|
import { Buffer } from 'node:buffer';
|
|
5
6
|
import crypto from 'node:crypto';
|
|
6
|
-
import { c as createDefaultGateway } from './ccjk.BtB1e5jm.mjs';
|
|
7
7
|
import { j as join } from './ccjk.bQ7Dh1g4.mjs';
|
|
8
8
|
|
|
9
|
-
const TOKEN_PREFIX = "ccjk_";
|
|
10
|
-
const TOKEN_LENGTH = 64;
|
|
11
|
-
const TOKEN_VERSION = 1;
|
|
12
|
-
function generateDeviceToken() {
|
|
13
|
-
const randomBytes = crypto.randomBytes(TOKEN_LENGTH / 2);
|
|
14
|
-
const randomHex = randomBytes.toString("hex");
|
|
15
|
-
return `${TOKEN_PREFIX}${TOKEN_VERSION}${randomHex}`;
|
|
16
|
-
}
|
|
17
|
-
function isValidTokenFormat(token) {
|
|
18
|
-
if (!token || typeof token !== "string") {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
if (!token.startsWith(TOKEN_PREFIX)) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
const expectedLength = TOKEN_PREFIX.length + 1 + TOKEN_LENGTH;
|
|
25
|
-
if (token.length !== expectedLength) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
const version = token[TOKEN_PREFIX.length];
|
|
29
|
-
if (!/^\d$/.test(version)) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
const hexPart = token.slice(TOKEN_PREFIX.length + 1);
|
|
33
|
-
if (!/^[a-f0-9]+$/i.test(hexPart)) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
function getDeviceInfo() {
|
|
39
|
-
return {
|
|
40
|
-
name: os__default.hostname(),
|
|
41
|
-
platform: os__default.platform(),
|
|
42
|
-
osVersion: os__default.release(),
|
|
43
|
-
arch: os__default.arch(),
|
|
44
|
-
username: os__default.userInfo().username,
|
|
45
|
-
machineId: generateMachineId()
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function generateMachineId() {
|
|
49
|
-
const components = [
|
|
50
|
-
os__default.hostname(),
|
|
51
|
-
os__default.platform(),
|
|
52
|
-
os__default.arch(),
|
|
53
|
-
os__default.cpus()[0]?.model || "unknown",
|
|
54
|
-
os__default.userInfo().username,
|
|
55
|
-
// Add network interface MAC addresses for uniqueness
|
|
56
|
-
...Object.values(os__default.networkInterfaces()).flat().filter((iface) => iface && !iface.internal && iface.mac !== "00:00:00:00:00:00").map((iface) => iface?.mac).filter(Boolean).slice(0, 3)
|
|
57
|
-
// Limit to first 3 MACs
|
|
58
|
-
];
|
|
59
|
-
const combined = components.join("|");
|
|
60
|
-
return crypto.createHash("sha256").update(combined).digest("hex").slice(0, 32);
|
|
61
|
-
}
|
|
62
|
-
function deriveEncryptionKey() {
|
|
63
|
-
const machineId = generateMachineId();
|
|
64
|
-
const salt = "ccjk-notification-token-v1";
|
|
65
|
-
return crypto.pbkdf2Sync(machineId, salt, 1e5, 32, "sha256");
|
|
66
|
-
}
|
|
67
|
-
function encryptToken(token) {
|
|
68
|
-
const key = deriveEncryptionKey();
|
|
69
|
-
const iv = crypto.randomBytes(16);
|
|
70
|
-
const cipher = crypto.createCipheriv("aes-256-gcm", key, iv);
|
|
71
|
-
let encrypted = cipher.update(token, "utf8", "hex");
|
|
72
|
-
encrypted += cipher.final("hex");
|
|
73
|
-
const authTag = cipher.getAuthTag();
|
|
74
|
-
return `${iv.toString("hex")}:${authTag.toString("hex")}:${encrypted}`;
|
|
75
|
-
}
|
|
76
|
-
function decryptToken(encryptedToken) {
|
|
77
|
-
try {
|
|
78
|
-
const parts = encryptedToken.split(":");
|
|
79
|
-
if (parts.length !== 3) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
const [ivHex, authTagHex, encrypted] = parts;
|
|
83
|
-
const key = deriveEncryptionKey();
|
|
84
|
-
const iv = Buffer.from(ivHex, "hex");
|
|
85
|
-
const authTag = Buffer.from(authTagHex, "hex");
|
|
86
|
-
const decipher = crypto.createDecipheriv("aes-256-gcm", key, iv);
|
|
87
|
-
decipher.setAuthTag(authTag);
|
|
88
|
-
let decrypted = decipher.update(encrypted, "hex", "utf8");
|
|
89
|
-
decrypted += decipher.final("utf8");
|
|
90
|
-
return decrypted;
|
|
91
|
-
} catch {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function maskToken(token) {
|
|
96
|
-
if (!token || token.length < 12) {
|
|
97
|
-
return "***";
|
|
98
|
-
}
|
|
99
|
-
const prefix = token.slice(0, TOKEN_PREFIX.length + 1);
|
|
100
|
-
const suffix = token.slice(-4);
|
|
101
|
-
return `${prefix}***...***${suffix}`;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
9
|
function validateBindRequest(request) {
|
|
105
10
|
const errors = [];
|
|
106
11
|
if (!request.code || typeof request.code !== "string") {
|
|
@@ -237,6 +142,101 @@ function validatePollResponse(response) {
|
|
|
237
142
|
};
|
|
238
143
|
}
|
|
239
144
|
|
|
145
|
+
const TOKEN_PREFIX = "ccjk_";
|
|
146
|
+
const TOKEN_LENGTH = 64;
|
|
147
|
+
const TOKEN_VERSION = 1;
|
|
148
|
+
function generateDeviceToken() {
|
|
149
|
+
const randomBytes = crypto.randomBytes(TOKEN_LENGTH / 2);
|
|
150
|
+
const randomHex = randomBytes.toString("hex");
|
|
151
|
+
return `${TOKEN_PREFIX}${TOKEN_VERSION}${randomHex}`;
|
|
152
|
+
}
|
|
153
|
+
function isValidTokenFormat(token) {
|
|
154
|
+
if (!token || typeof token !== "string") {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
if (!token.startsWith(TOKEN_PREFIX)) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const expectedLength = TOKEN_PREFIX.length + 1 + TOKEN_LENGTH;
|
|
161
|
+
if (token.length !== expectedLength) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
const version = token[TOKEN_PREFIX.length];
|
|
165
|
+
if (!/^\d$/.test(version)) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
const hexPart = token.slice(TOKEN_PREFIX.length + 1);
|
|
169
|
+
if (!/^[a-f0-9]+$/i.test(hexPart)) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
function getDeviceInfo() {
|
|
175
|
+
return {
|
|
176
|
+
name: os__default.hostname(),
|
|
177
|
+
platform: os__default.platform(),
|
|
178
|
+
osVersion: os__default.release(),
|
|
179
|
+
arch: os__default.arch(),
|
|
180
|
+
username: os__default.userInfo().username,
|
|
181
|
+
machineId: generateMachineId()
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function generateMachineId() {
|
|
185
|
+
const components = [
|
|
186
|
+
os__default.hostname(),
|
|
187
|
+
os__default.platform(),
|
|
188
|
+
os__default.arch(),
|
|
189
|
+
os__default.cpus()[0]?.model || "unknown",
|
|
190
|
+
os__default.userInfo().username,
|
|
191
|
+
// Add network interface MAC addresses for uniqueness
|
|
192
|
+
...Object.values(os__default.networkInterfaces()).flat().filter((iface) => iface && !iface.internal && iface.mac !== "00:00:00:00:00:00").map((iface) => iface?.mac).filter(Boolean).slice(0, 3)
|
|
193
|
+
// Limit to first 3 MACs
|
|
194
|
+
];
|
|
195
|
+
const combined = components.join("|");
|
|
196
|
+
return crypto.createHash("sha256").update(combined).digest("hex").slice(0, 32);
|
|
197
|
+
}
|
|
198
|
+
function deriveEncryptionKey() {
|
|
199
|
+
const machineId = generateMachineId();
|
|
200
|
+
const salt = "ccjk-notification-token-v1";
|
|
201
|
+
return crypto.pbkdf2Sync(machineId, salt, 1e5, 32, "sha256");
|
|
202
|
+
}
|
|
203
|
+
function encryptToken(token) {
|
|
204
|
+
const key = deriveEncryptionKey();
|
|
205
|
+
const iv = crypto.randomBytes(16);
|
|
206
|
+
const cipher = crypto.createCipheriv("aes-256-gcm", key, iv);
|
|
207
|
+
let encrypted = cipher.update(token, "utf8", "hex");
|
|
208
|
+
encrypted += cipher.final("hex");
|
|
209
|
+
const authTag = cipher.getAuthTag();
|
|
210
|
+
return `${iv.toString("hex")}:${authTag.toString("hex")}:${encrypted}`;
|
|
211
|
+
}
|
|
212
|
+
function decryptToken(encryptedToken) {
|
|
213
|
+
try {
|
|
214
|
+
const parts = encryptedToken.split(":");
|
|
215
|
+
if (parts.length !== 3) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
const [ivHex, authTagHex, encrypted] = parts;
|
|
219
|
+
const key = deriveEncryptionKey();
|
|
220
|
+
const iv = Buffer.from(ivHex, "hex");
|
|
221
|
+
const authTag = Buffer.from(authTagHex, "hex");
|
|
222
|
+
const decipher = crypto.createDecipheriv("aes-256-gcm", key, iv);
|
|
223
|
+
decipher.setAuthTag(authTag);
|
|
224
|
+
let decrypted = decipher.update(encrypted, "hex", "utf8");
|
|
225
|
+
decrypted += decipher.final("utf8");
|
|
226
|
+
return decrypted;
|
|
227
|
+
} catch {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function maskToken(token) {
|
|
232
|
+
if (!token || token.length < 12) {
|
|
233
|
+
return "***";
|
|
234
|
+
}
|
|
235
|
+
const prefix = token.slice(0, TOKEN_PREFIX.length + 1);
|
|
236
|
+
const suffix = token.slice(-4);
|
|
237
|
+
return `${prefix}***...***${suffix}`;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
240
|
const CLOUD_API_BASE_URL = "https://api.claudehome.cn";
|
|
241
241
|
const POLL_TIMEOUT = 6e4;
|
|
242
242
|
const TOKEN_FILE_PATH = join(homedir(), ".ccjk", "cloud-token.json");
|