claude-opencode-viewer 2.6.6 → 2.6.8

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.
Files changed (2) hide show
  1. package/package.json +2 -1
  2. package/server.js +20 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-opencode-viewer",
3
- "version": "2.6.6",
3
+ "version": "2.6.8",
4
4
  "description": "A unified terminal viewer for Claude Code and OpenCode with seamless switching",
5
5
  "type": "module",
6
6
  "main": "server.js",
@@ -35,6 +35,7 @@
35
35
  "dependencies": {
36
36
  "better-sqlite3": "^11.8.1",
37
37
  "node-pty": "^1.1.0",
38
+ "selfsigned": "^5.5.0",
38
39
  "ws": "^8.19.0"
39
40
  },
40
41
  "engines": {
package/server.js CHANGED
@@ -19,8 +19,8 @@ const PORT = parseInt(process.argv[2]) || 7008;
19
19
  const IS_PC = process.argv.includes('--pc');
20
20
  const USE_HTTPS = process.argv.includes('--https');
21
21
 
22
- // 自签名证书生成
23
- function getOrCreateCert() {
22
+ // 自签名证书生成(使用 selfsigned 库,不依赖 openssl)
23
+ async function getOrCreateCert() {
24
24
  const certDir = join(homedir(), '.cov-certs');
25
25
  const keyPath = join(certDir, 'key.pem');
26
26
  const certPath = join(certDir, 'cert.pem');
@@ -31,12 +31,24 @@ function getOrCreateCert() {
31
31
 
32
32
  console.log('🔐 首次使用 HTTPS,生成自签名证书...');
33
33
  mkdirSync(certDir, { recursive: true });
34
- execSync(
35
- `openssl req -x509 -newkey rsa:2048 -keyout "${keyPath}" -out "${certPath}" -days 365 -nodes -subj "/CN=cov-self-signed"`,
36
- { stdio: 'pipe' }
37
- );
34
+
35
+ const { default: selfsigned } = await import('selfsigned');
36
+ const attrs = [{ name: 'commonName', value: 'cov-self-signed' }];
37
+ const pems = await selfsigned.generate(attrs, {
38
+ days: 365,
39
+ keySize: 2048,
40
+ extensions: [
41
+ { name: 'subjectAltName', altNames: [
42
+ { type: 7, ip: '127.0.0.1' },
43
+ { type: 2, value: 'localhost' },
44
+ ]}
45
+ ],
46
+ });
47
+
48
+ writeFileSync(keyPath, pems.private);
49
+ writeFileSync(certPath, pems.cert);
38
50
  console.log(`📁 证书已保存到 ${certDir}`);
39
- return { key: readFileSync(keyPath), cert: readFileSync(certPath) };
51
+ return { key: pems.private, cert: pems.cert };
40
52
  }
41
53
 
42
54
  // OpenCode 数据库路径(支持环境变量覆盖,自动检测 /halo 环境)
@@ -582,7 +594,7 @@ const requestHandler = async (req, res) => {
582
594
  };
583
595
 
584
596
  const server = USE_HTTPS
585
- ? createHttpsServer(getOrCreateCert(), requestHandler)
597
+ ? createHttpsServer(await getOrCreateCert(), requestHandler)
586
598
  : createServer(requestHandler);
587
599
 
588
600
  const wss = new WebSocketServer({ server, path: '/ws' });