@tina_summer/codepocket 2.6.1 → 2.6.2
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 +4 -0
- package/bin/codepocket.js +6 -1
- package/package.json +5 -5
- package/src/index.ts +11 -1
- package/src/mcp-server.js +1 -4
package/README.md
CHANGED
|
@@ -63,6 +63,10 @@ codepocket
|
|
|
63
63
|
- **YOLO 模式** — 全自动审批,无人值守运行
|
|
64
64
|
- **手机工具** — GPS、日历、剪贴板、地图等原生能力通过 MCP 暴露给 Claude
|
|
65
65
|
|
|
66
|
+
## 安全
|
|
67
|
+
|
|
68
|
+
自 v2.6.1 起,CLI 与小程序之间经由 Relay 的所有业务流量都端到端加密(X25519 + XSalsa20-Poly1305)。Relay 服务器只转发密文信封,无法解密会话内容、文件读取或命令输出。配对时双方通过 Relay 交换 X25519 临时公钥派生共享密钥,Nonce 使用计数器 + 方向标签避免重用。详见根目录 [why-codepocket.md](../why-codepocket.md#为什么端到端加密)。
|
|
69
|
+
|
|
66
70
|
## 可选:CC-Switch
|
|
67
71
|
|
|
68
72
|
[CC-Switch](https://github.com/farion1231/cc-switch) 是管理 Claude Code 多 API 密钥/中转服务商的切换工具,下载地址:[Releases](https://github.com/farion1231/cc-switch/releases/latest)
|
package/bin/codepocket.js
CHANGED
|
@@ -496,7 +496,12 @@ async function authenticateHub(token) {
|
|
|
496
496
|
async function startSSE() {
|
|
497
497
|
const url = `${hubUrl}/api/events?all=true`
|
|
498
498
|
try {
|
|
499
|
-
|
|
499
|
+
let res = await fetch(url, { headers: { Accept: 'text/event-stream', ...(jwt ? { Authorization: `Bearer ${jwt}` } : {}) } })
|
|
500
|
+
// JWT expired — refresh and retry once before entering the retry loop
|
|
501
|
+
if (res.status === 401) {
|
|
502
|
+
try { const token = await findHubToken(); jwt = await authenticateHub(token) } catch {}
|
|
503
|
+
res = await fetch(url, { headers: { Accept: 'text/event-stream', ...(jwt ? { Authorization: `Bearer ${jwt}` } : {}) } })
|
|
504
|
+
}
|
|
500
505
|
if (!res.ok || !res.body) { setTimeout(startSSE, 5000); return }
|
|
501
506
|
const reader = res.body.getReader()
|
|
502
507
|
const decoder = new TextDecoder()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tina_summer/codepocket",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "CodePocket — 基于ClaudeCode的微信小程序工作台",
|
|
5
5
|
"bin": {
|
|
6
6
|
"codepocket": "bin/codepocket.js",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"ws": "^8.18.0"
|
|
21
21
|
},
|
|
22
22
|
"optionalDependencies": {
|
|
23
|
-
"@tina_summer/codepocket-darwin-arm64": "2.6.
|
|
24
|
-
"@tina_summer/codepocket-darwin-x64": "2.6.
|
|
25
|
-
"@tina_summer/codepocket-linux-x64": "2.6.
|
|
26
|
-
"@tina_summer/codepocket-win32-x64": "2.6.
|
|
23
|
+
"@tina_summer/codepocket-darwin-arm64": "2.6.2",
|
|
24
|
+
"@tina_summer/codepocket-darwin-x64": "2.6.2",
|
|
25
|
+
"@tina_summer/codepocket-linux-x64": "2.6.2",
|
|
26
|
+
"@tina_summer/codepocket-win32-x64": "2.6.2"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
29
|
"node": ">=18"
|
package/src/index.ts
CHANGED
|
@@ -80,13 +80,23 @@ function startSSE() {
|
|
|
80
80
|
|
|
81
81
|
;(async () => {
|
|
82
82
|
try {
|
|
83
|
-
|
|
83
|
+
let res = await fetch(url, {
|
|
84
84
|
signal: sseController!.signal,
|
|
85
85
|
headers: { Accept: 'text/event-stream' },
|
|
86
86
|
})
|
|
87
87
|
|
|
88
|
+
// JWT expired — refresh and retry once
|
|
89
|
+
if (res.status === 401) {
|
|
90
|
+
try { jwt = await authenticateHub() } catch {}
|
|
91
|
+
res = await fetch(`${hubUrl}/api/events?token=${encodeURIComponent(jwt)}&all=true`, {
|
|
92
|
+
signal: sseController!.signal,
|
|
93
|
+
headers: { Accept: 'text/event-stream' },
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
88
97
|
if (!res.ok || !res.body) {
|
|
89
98
|
console.error(`[SSE] connection failed: ${res.status}`)
|
|
99
|
+
setTimeout(startSSE, 5000)
|
|
90
100
|
return
|
|
91
101
|
}
|
|
92
102
|
|
package/src/mcp-server.js
CHANGED
|
@@ -177,10 +177,7 @@ function startMcpServer(relaySender) {
|
|
|
177
177
|
|
|
178
178
|
return new Promise((resolve, reject) => {
|
|
179
179
|
const server = http.createServer((req, res) => {
|
|
180
|
-
// CORS headers
|
|
181
|
-
res.setHeader('Access-Control-Allow-Origin', '*')
|
|
182
|
-
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
|
|
183
|
-
res.setHeader('Access-Control-Allow-Headers', 'Content-Type')
|
|
180
|
+
// No CORS headers — MCP server is local-only (127.0.0.1), Claude Code doesn't need CORS
|
|
184
181
|
if (req.method === 'OPTIONS') { res.writeHead(204); res.end(); return }
|
|
185
182
|
|
|
186
183
|
if (req.url === '/sse' && req.method === 'GET') {
|