@artenx/dshb 0.1.53 → 0.1.55
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 +22 -7
- package/lib/auth/decorate-webserver.js +4 -4
- package/lib/auth/decorate-webserver.js.map +1 -1
- package/lib/auth/gate.d.ts +11 -3
- package/lib/auth/gate.js +14 -2
- package/lib/auth/gate.js.map +1 -1
- package/lib/auth/index.js +22 -3
- package/lib/auth/index.js.map +1 -1
- package/lib/auth/webserver.js +4 -4
- package/lib/auth/webserver.js.map +1 -1
- package/lib/{catalog-BPkswHoz.js → catalog-B6Qvy7bH.js} +8 -4
- package/lib/catalog-B6Qvy7bH.js.map +1 -0
- package/lib/client.js +421 -29
- package/lib/client.js.map +1 -1
- package/lib/core/index.js +132 -202
- package/lib/core/index.js.map +1 -1
- package/lib/core/node-registry.js +1 -1
- package/lib/core/routes.d.ts +1 -1
- package/lib/core/sync/coordinator.d.ts +5 -5
- package/lib/core/sync/coordinator.js +1 -1
- package/lib/core/sync/host-key.d.ts +1 -1
- package/lib/core/sync/internal-routes.d.ts +3 -3
- package/lib/core/sync/internal-routes.js +52 -2
- package/lib/core/sync/internal-routes.js.map +1 -1
- package/lib/core/sync/model.d.ts +1 -1
- package/lib/core/sync/model.js.map +1 -1
- package/lib/core/sync/node-sync.d.ts +1 -1
- package/lib/core/sync/offline-archive.d.ts +4 -4
- package/lib/core/sync/offline-archive.js +2 -2
- package/lib/core/sync/offline-routes.js +1 -1
- package/lib/core/sync/peer-manager.d.ts +2 -2
- package/lib/core/sync/routes.d.ts +9 -4
- package/lib/core/sync/routes.js +31 -4
- package/lib/core/sync/routes.js.map +1 -1
- package/lib/core/sync/session-journal.d.ts +1 -1
- package/lib/core/sync/session-open-routes.d.ts +32 -0
- package/lib/core/sync/session-open-routes.js +239 -0
- package/lib/core/sync/session-open-routes.js.map +1 -0
- package/lib/core/sync/session-routes.d.ts +1 -1
- package/lib/core/sync/session-routes.js +1 -1
- package/lib/core/sync/session-sync.d.ts +1 -1
- package/lib/core/sync/session-sync.js +1 -1
- package/lib/core/sync/ssh-transport.d.ts +1 -1
- package/lib/core/sync/ssh-transport.js +44 -1
- package/lib/core/sync/ssh-transport.js.map +1 -1
- package/lib/core/sync/stores.d.ts +1 -1
- package/lib/core/workspace-instruction-context.d.ts +1 -1
- package/lib/core/workspace-instructions.js +9 -1
- package/lib/core/workspace-instructions.js.map +1 -1
- package/lib/core/workspaces.d.ts +1 -1
- package/lib/{host-key-hIj6EY1x.d.ts → host-key-kbG50cnS.d.ts} +2 -2
- package/lib/{index-VF8bcBeX.d.ts → index-D6KDknUV.d.ts} +3 -309
- package/lib/{model-ByASrkzO.d.ts → model-zRfOihS3.d.ts} +4 -1
- package/lib/{node-sync-Cv1Amudy.d.ts → node-sync-Ba4yARei.d.ts} +3 -3
- package/lib/relay-auth-CtwES4Xn.js +240 -0
- package/lib/relay-auth-CtwES4Xn.js.map +1 -0
- package/lib/{session-journal-BnpGWLo2.d.ts → session-journal-BKjaO_1l.d.ts} +2 -2
- package/lib/{session-sync-Bn5ZXU8H.d.ts → session-sync-B5MCI0TW.d.ts} +31 -8
- package/lib/{session-sync-Dwz4dp4U.js → session-sync-Bsv3Qnof.js} +156 -96
- package/lib/session-sync-Bsv3Qnof.js.map +1 -0
- package/lib/{ssh-transport-CcGpOVy5.d.ts → ssh-transport-Uii7j8la.d.ts} +14 -5
- package/lib/{stores-BfruQqD-.d.ts → stores-DnyrIi4h.d.ts} +2 -2
- package/package.json +6 -2
- package/lib/catalog-BPkswHoz.js.map +0 -1
- package/lib/session-sync-Dwz4dp4U.js.map +0 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { isLoopbackRequest } from "./auth/loopback.js";
|
|
2
|
+
import { credentialKey } from "@deepseek-ai/dsh-credentials";
|
|
3
|
+
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
|
|
4
|
+
//#region src/core/sync/relay-auth.ts
|
|
5
|
+
const RELAY_COOKIE_PREFIX = "dsh-auth-";
|
|
6
|
+
const RELAY_COOKIE_VERSION = 1;
|
|
7
|
+
const RELAY_SECRET_BYTES = 32;
|
|
8
|
+
const RELAY_TICKET_MAX_AGE_MS = 6e5;
|
|
9
|
+
const MAX_TICKETS_PER_MINUTE = 30;
|
|
10
|
+
const AUTHORITY_PATTERN = /^(?:[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?|\[(?:[0-9A-Fa-f:.]+)\])(?::\d{1,5})?$/;
|
|
11
|
+
var RelayTicketError = class extends Error {
|
|
12
|
+
code;
|
|
13
|
+
constructor(code, message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.code = code;
|
|
16
|
+
this.name = "RelayTicketError";
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function encodeBase64Url(value) {
|
|
20
|
+
return Buffer.from(value).toString("base64").replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/u, "");
|
|
21
|
+
}
|
|
22
|
+
function decodeBase64Url(value) {
|
|
23
|
+
if (!/^[A-Za-z0-9_-]*$/.test(value) || value.length % 4 === 1) return void 0;
|
|
24
|
+
const decoded = Buffer.from(value.replaceAll("-", "+").replaceAll("_", "/"), "base64");
|
|
25
|
+
return encodeBase64Url(decoded) === value ? decoded : void 0;
|
|
26
|
+
}
|
|
27
|
+
/** 校验并提取 credentials 记录中的浏览器会话签名密钥(32 字节)。 */
|
|
28
|
+
function browserSessionSecret(record) {
|
|
29
|
+
if (record === null || typeof record !== "object" || Array.isArray(record)) throw new RelayTicketError("relay-secret-unavailable", "browser session credential record is missing");
|
|
30
|
+
const payload = record.payload;
|
|
31
|
+
if (payload === null || typeof payload !== "object" || Array.isArray(payload)) throw new RelayTicketError("relay-secret-unavailable", "browser session credential payload is missing");
|
|
32
|
+
const { version, secret } = payload;
|
|
33
|
+
if (version !== RELAY_COOKIE_VERSION || typeof secret !== "string") throw new RelayTicketError("relay-secret-unavailable", "browser session credential payload is unsupported");
|
|
34
|
+
const decoded = decodeBase64Url(secret);
|
|
35
|
+
if (decoded === void 0 || decoded.byteLength !== RELAY_SECRET_BYTES) throw new RelayTicketError("relay-secret-unavailable", "browser session credential secret is invalid");
|
|
36
|
+
return decoded;
|
|
37
|
+
}
|
|
38
|
+
function validateRelayAuthority(value) {
|
|
39
|
+
if (typeof value !== "string" || value.length > 255 || !AUTHORITY_PATTERN.test(value)) throw new RelayTicketError("authority-invalid", "relay authority must be a bare host or host:port");
|
|
40
|
+
const port = value.includes("]:") || !value.includes("]") && value.includes(":") ? Number(value.slice(value.lastIndexOf(":") + 1)) : 80;
|
|
41
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new RelayTicketError("authority-invalid", "relay authority port is invalid");
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
/** 与 browser-auth 相同的 cookie 名派生:dsh-auth- + base64url(sha256(authority))。 */
|
|
45
|
+
function relayCookieName(authority) {
|
|
46
|
+
return RELAY_COOKIE_PREFIX + encodeBase64Url(createHash("sha256").update(authority).digest());
|
|
47
|
+
}
|
|
48
|
+
/** 按远端 Host browser-auth 的格式铸造一个权威名绑定的短时效签名 cookie。 */
|
|
49
|
+
function mintRelayCookie(secret, authority, now, maxAgeMs = RELAY_TICKET_MAX_AGE_MS) {
|
|
50
|
+
const issuedAt = now;
|
|
51
|
+
const expiresAt = issuedAt + maxAgeMs;
|
|
52
|
+
const body = encodeBase64Url(Buffer.from(JSON.stringify({
|
|
53
|
+
version: RELAY_COOKIE_VERSION,
|
|
54
|
+
authority,
|
|
55
|
+
issuedAt,
|
|
56
|
+
expiresAt
|
|
57
|
+
}), "utf8"));
|
|
58
|
+
const signature = createHmac("sha256", secret).update(body).digest();
|
|
59
|
+
return {
|
|
60
|
+
name: relayCookieName(authority),
|
|
61
|
+
value: `v1.${body}.${encodeBase64Url(signature)}`,
|
|
62
|
+
expiresAt,
|
|
63
|
+
maxAgeSeconds: Math.floor(maxAgeMs / 1e3)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function relayCookieHeader(cookie) {
|
|
67
|
+
return `${cookie.name}=${cookie.value}`;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 校验一个 dsh browser-auth 格式的 relay cookie 值是否由本机 secret 为
|
|
71
|
+
* 指定 authority 铸造且未过期。与 mintRelayCookie 对称:拆分 v1.body.sig,
|
|
72
|
+
* 重算 HMAC 做常量时间比较,并校验 body 内的 authority 与过期时间。
|
|
73
|
+
*/
|
|
74
|
+
function verifyRelayCookie(value, secret, authority, now) {
|
|
75
|
+
if (typeof value !== "string" || !value.startsWith("v1.")) return false;
|
|
76
|
+
const firstDot = value.indexOf(".", 3);
|
|
77
|
+
if (firstDot < 0) return false;
|
|
78
|
+
const body = value.slice(3, firstDot);
|
|
79
|
+
const signature = value.slice(firstDot + 1);
|
|
80
|
+
if (!body || !signature) return false;
|
|
81
|
+
if (!constantTimeEquals(signature, encodeBase64Url(createHmac("sha256", secret).update(body).digest()))) return false;
|
|
82
|
+
const decoded = decodeBase64Url(body);
|
|
83
|
+
if (decoded === void 0) return false;
|
|
84
|
+
let payload;
|
|
85
|
+
try {
|
|
86
|
+
payload = JSON.parse(decoded.toString("utf8"));
|
|
87
|
+
} catch {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if (payload.authority !== authority) return false;
|
|
91
|
+
if (typeof payload.expiresAt !== "number" || payload.expiresAt <= now) return false;
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
/** 从请求 Cookie 头中提取并校验绑定到 req Host 的 relay cookie。 */
|
|
95
|
+
function requestHasValidRelayCookie(cookieHeader, secret, host, now) {
|
|
96
|
+
if (!cookieHeader || !host || !secret) return false;
|
|
97
|
+
const name = relayCookieName(host);
|
|
98
|
+
const re = new RegExp(`(?:^|;\\s*)${name}=([^;]+)`);
|
|
99
|
+
const match = cookieHeader.match(re);
|
|
100
|
+
if (!match) return false;
|
|
101
|
+
return verifyRelayCookie(match[1], secret, host, now);
|
|
102
|
+
}
|
|
103
|
+
function constantTimeEquals(actual, expected) {
|
|
104
|
+
const actualBytes = Buffer.from(actual, "utf8");
|
|
105
|
+
const expectedBytes = Buffer.from(expected, "utf8");
|
|
106
|
+
return actualBytes.byteLength === expectedBytes.byteLength && timingSafeEqual(actualBytes, expectedBytes);
|
|
107
|
+
}
|
|
108
|
+
function readJsonBody(req, maxBytes) {
|
|
109
|
+
return new Promise((resolve) => {
|
|
110
|
+
const chunks = [];
|
|
111
|
+
let size = 0;
|
|
112
|
+
let settled = false;
|
|
113
|
+
const fail = () => {
|
|
114
|
+
if (settled) return;
|
|
115
|
+
settled = true;
|
|
116
|
+
resolve(null);
|
|
117
|
+
};
|
|
118
|
+
req.on("data", (chunk) => {
|
|
119
|
+
if (settled) return;
|
|
120
|
+
size += chunk.length;
|
|
121
|
+
if (size > maxBytes) {
|
|
122
|
+
fail();
|
|
123
|
+
req.destroy();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
chunks.push(chunk);
|
|
127
|
+
});
|
|
128
|
+
req.on("end", () => {
|
|
129
|
+
if (settled) return;
|
|
130
|
+
try {
|
|
131
|
+
const value = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
132
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
133
|
+
fail();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
settled = true;
|
|
137
|
+
resolve(value);
|
|
138
|
+
} catch {
|
|
139
|
+
fail();
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
req.on("error", fail);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* 远端侧中继凭据铸造路由:POST /api/dshb/sync/internal/relay-ticket。
|
|
147
|
+
* 仅接受回环请求;用本机 credentials 的浏览器会话密钥为请求指定的
|
|
148
|
+
* authority 铸造 ≤10 分钟签名 cookie。凭据只在响应中返回一次。
|
|
149
|
+
*/
|
|
150
|
+
function registerRelayTicketRoutes(ctx, credentials) {
|
|
151
|
+
const rateLimit = {
|
|
152
|
+
windowStart: 0,
|
|
153
|
+
count: 0
|
|
154
|
+
};
|
|
155
|
+
ctx.effect(() => ctx.webServer.register({
|
|
156
|
+
kind: "exact",
|
|
157
|
+
path: "/api/dshb/sync/internal/relay-ticket",
|
|
158
|
+
handler: async (req, res) => {
|
|
159
|
+
const deny = (status, body) => {
|
|
160
|
+
res.writeHead(status, {
|
|
161
|
+
"content-type": "application/json",
|
|
162
|
+
"cache-control": "no-store"
|
|
163
|
+
});
|
|
164
|
+
res.end(JSON.stringify(body));
|
|
165
|
+
};
|
|
166
|
+
if (!isLoopbackRequest(req.socket.remoteAddress, req.headers.host)) {
|
|
167
|
+
deny(403, {
|
|
168
|
+
ok: false,
|
|
169
|
+
error: "loopback access required"
|
|
170
|
+
});
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (req.method !== "POST") {
|
|
174
|
+
deny(405, {
|
|
175
|
+
ok: false,
|
|
176
|
+
error: "method not allowed"
|
|
177
|
+
});
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const now = Date.now();
|
|
181
|
+
if (now - rateLimit.windowStart > 6e4) {
|
|
182
|
+
rateLimit.windowStart = now;
|
|
183
|
+
rateLimit.count = 0;
|
|
184
|
+
}
|
|
185
|
+
rateLimit.count += 1;
|
|
186
|
+
if (rateLimit.count > MAX_TICKETS_PER_MINUTE) {
|
|
187
|
+
deny(429, {
|
|
188
|
+
ok: false,
|
|
189
|
+
error: "relay ticket rate limit exceeded"
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const body = await readJsonBody(req, 1024);
|
|
194
|
+
let authority;
|
|
195
|
+
try {
|
|
196
|
+
authority = validateRelayAuthority(body?.authority);
|
|
197
|
+
} catch (error) {
|
|
198
|
+
deny(400, {
|
|
199
|
+
ok: false,
|
|
200
|
+
code: error instanceof RelayTicketError ? error.code : "authority-invalid",
|
|
201
|
+
error: error instanceof Error ? error.message : "authority is invalid"
|
|
202
|
+
});
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
try {
|
|
206
|
+
const cookie = mintRelayCookie(browserSessionSecret(await credentials.readRecord(credentialKey("client-connection", "browser-session"))), authority, now);
|
|
207
|
+
res.writeHead(200, {
|
|
208
|
+
"content-type": "application/json",
|
|
209
|
+
"cache-control": "no-store"
|
|
210
|
+
});
|
|
211
|
+
res.end(JSON.stringify({
|
|
212
|
+
ok: true,
|
|
213
|
+
cookie: {
|
|
214
|
+
name: cookie.name,
|
|
215
|
+
value: cookie.value,
|
|
216
|
+
maxAgeSeconds: cookie.maxAgeSeconds
|
|
217
|
+
}
|
|
218
|
+
}));
|
|
219
|
+
} catch (error) {
|
|
220
|
+
if (error instanceof RelayTicketError) {
|
|
221
|
+
deny(503, {
|
|
222
|
+
ok: false,
|
|
223
|
+
code: error.code,
|
|
224
|
+
error: error.message
|
|
225
|
+
});
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
deny(500, {
|
|
229
|
+
ok: false,
|
|
230
|
+
code: "relay-ticket-failed",
|
|
231
|
+
error: "relay ticket minting failed"
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
//#endregion
|
|
238
|
+
export { requestHasValidRelayCookie as a, relayCookieHeader as i, browserSessionSecret as n, registerRelayTicketRoutes as r, RelayTicketError as t };
|
|
239
|
+
|
|
240
|
+
//# sourceMappingURL=relay-auth-CtwES4Xn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-auth-CtwES4Xn.js","names":[],"sources":["../src/core/sync/relay-auth.ts"],"sourcesContent":["import { createHash, createHmac, timingSafeEqual } from 'node:crypto'\nimport type { IncomingMessage, ServerResponse } from 'node:http'\nimport type { Context } from '@deepseek-ai/cordis'\nimport type {} from '@deepseek-ai/dsh-host-webserver'\nimport type { CredentialKey } from '@deepseek-ai/dsh-credentials'\nimport { credentialKey } from '@deepseek-ai/dsh-credentials'\nimport { isLoopbackRequest } from '../../auth/loopback.js'\n\n// 中继凭据的格式与常量复制自 dsh-client-connection 的 browser-auth(本插件\n// 兼容范围内该格式稳定):cookie 名 dsh-auth- + base64url(sha256(authority)),\n// 载荷 v1.<payload>.<hmac>,HMAC-SHA256 密钥存于 credentials 的\n// client-connection/browser-session 记录。铸造只在本机回环内部路由上进行,\n// 凭据有效期 10 分钟且绝不落盘。\n\nconst RELAY_COOKIE_PREFIX = 'dsh-auth-'\nconst RELAY_COOKIE_VERSION = 1\nconst RELAY_SECRET_BYTES = 32\nexport const RELAY_TICKET_MAX_AGE_MS = 10 * 60 * 1000\nconst MAX_TICKETS_PER_MINUTE = 30\n\nconst AUTHORITY_PATTERN = /^(?:[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?|\\[(?:[0-9A-Fa-f:.]+)\\])(?::\\d{1,5})?$/\n\nexport class RelayTicketError extends Error {\n constructor(readonly code: string, message: string) {\n super(message)\n this.name = 'RelayTicketError'\n }\n}\n\nfunction encodeBase64Url(value: Uint8Array): string {\n return Buffer.from(value).toString('base64')\n .replaceAll('+', '-')\n .replaceAll('/', '_')\n .replace(/=+$/u, '')\n}\n\nfunction decodeBase64Url(value: string): Buffer | undefined {\n if (!/^[A-Za-z0-9_-]*$/.test(value) || value.length % 4 === 1) return undefined\n const decoded = Buffer.from(value.replaceAll('-', '+').replaceAll('_', '/'), 'base64')\n return encodeBase64Url(decoded) === value ? decoded : undefined\n}\n\n/** 校验并提取 credentials 记录中的浏览器会话签名密钥(32 字节)。 */\nexport function browserSessionSecret(record: unknown): Buffer {\n if (record === null || typeof record !== 'object' || Array.isArray(record)) {\n throw new RelayTicketError('relay-secret-unavailable', 'browser session credential record is missing')\n }\n const payload = (record as { payload?: unknown }).payload\n if (payload === null || typeof payload !== 'object' || Array.isArray(payload)) {\n throw new RelayTicketError('relay-secret-unavailable', 'browser session credential payload is missing')\n }\n const { version, secret } = payload as { version?: unknown; secret?: unknown }\n if (version !== RELAY_COOKIE_VERSION || typeof secret !== 'string') {\n throw new RelayTicketError('relay-secret-unavailable', 'browser session credential payload is unsupported')\n }\n const decoded = decodeBase64Url(secret)\n if (decoded === undefined || decoded.byteLength !== RELAY_SECRET_BYTES) {\n throw new RelayTicketError('relay-secret-unavailable', 'browser session credential secret is invalid')\n }\n return decoded\n}\n\nexport function validateRelayAuthority(value: unknown): string {\n if (typeof value !== 'string' || value.length > 255 || !AUTHORITY_PATTERN.test(value)) {\n throw new RelayTicketError('authority-invalid', 'relay authority must be a bare host or host:port')\n }\n const port = value.includes(']:') || (!value.includes(']') && value.includes(':'))\n ? Number(value.slice(value.lastIndexOf(':') + 1))\n : 80\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new RelayTicketError('authority-invalid', 'relay authority port is invalid')\n }\n return value\n}\n\nexport interface RelayCookie {\n name: string\n value: string\n expiresAt: number\n maxAgeSeconds: number\n}\n\n/** 与 browser-auth 相同的 cookie 名派生:dsh-auth- + base64url(sha256(authority))。 */\nexport function relayCookieName(authority: string): string {\n return RELAY_COOKIE_PREFIX + encodeBase64Url(createHash('sha256').update(authority).digest())\n}\n\n/** 按远端 Host browser-auth 的格式铸造一个权威名绑定的短时效签名 cookie。 */\nexport function mintRelayCookie(secret: Buffer, authority: string, now: number, maxAgeMs = RELAY_TICKET_MAX_AGE_MS): RelayCookie {\n const issuedAt = now\n const expiresAt = issuedAt + maxAgeMs\n const body = encodeBase64Url(Buffer.from(JSON.stringify({\n version: RELAY_COOKIE_VERSION,\n authority,\n issuedAt,\n expiresAt,\n }), 'utf8'))\n const signature = createHmac('sha256', secret).update(body).digest()\n return {\n name: relayCookieName(authority),\n value: `v1.${body}.${encodeBase64Url(signature)}`,\n expiresAt,\n maxAgeSeconds: Math.floor(maxAgeMs / 1000),\n }\n}\n\nexport function relayCookieHeader(cookie: RelayCookie): string {\n return `${cookie.name}=${cookie.value}`\n}\n\n/**\n * 校验一个 dsh browser-auth 格式的 relay cookie 值是否由本机 secret 为\n * 指定 authority 铸造且未过期。与 mintRelayCookie 对称:拆分 v1.body.sig,\n * 重算 HMAC 做常量时间比较,并校验 body 内的 authority 与过期时间。\n */\nexport function verifyRelayCookie(value: unknown, secret: Buffer, authority: string, now: number): boolean {\n if (typeof value !== 'string' || !value.startsWith('v1.')) return false\n const firstDot = value.indexOf('.', 3)\n if (firstDot < 0) return false\n const body = value.slice(3, firstDot)\n const signature = value.slice(firstDot + 1)\n if (!body || !signature) return false\n const expectedSig = encodeBase64Url(createHmac('sha256', secret).update(body).digest())\n if (!constantTimeEquals(signature, expectedSig)) return false\n const decoded = decodeBase64Url(body)\n if (decoded === undefined) return false\n let payload: { authority?: unknown; expiresAt?: unknown; issuedAt?: unknown }\n try {\n payload = JSON.parse(decoded.toString('utf8'))\n } catch {\n return false\n }\n if (payload.authority !== authority) return false\n if (typeof payload.expiresAt !== 'number' || payload.expiresAt <= now) return false\n return true\n}\n\n/** 从请求 Cookie 头中提取并校验绑定到 req Host 的 relay cookie。 */\nexport function requestHasValidRelayCookie(\n cookieHeader: string | undefined,\n secret: Buffer,\n host: string | undefined,\n now: number,\n): boolean {\n if (!cookieHeader || !host || !secret) return false\n const name = relayCookieName(host)\n const re = new RegExp(`(?:^|;\\\\s*)${name}=([^;]+)`)\n const match = cookieHeader.match(re)\n if (!match) return false\n return verifyRelayCookie(match[1], secret, host, now)\n}\n\nfunction constantTimeEquals(actual: string, expected: string): boolean {\n const actualBytes = Buffer.from(actual, 'utf8')\n const expectedBytes = Buffer.from(expected, 'utf8')\n return actualBytes.byteLength === expectedBytes.byteLength && timingSafeEqual(actualBytes, expectedBytes)\n}\n\nfunction readJsonBody(req: IncomingMessage, maxBytes: number): Promise<Record<string, unknown> | null> {\n return new Promise((resolve) => {\n const chunks: Buffer[] = []\n let size = 0\n let settled = false\n const fail = (): void => {\n if (settled) return\n settled = true\n resolve(null)\n }\n req.on('data', (chunk: Buffer) => {\n if (settled) return\n size += chunk.length\n if (size > maxBytes) {\n fail()\n req.destroy()\n return\n }\n chunks.push(chunk)\n })\n req.on('end', () => {\n if (settled) return\n try {\n const value: unknown = JSON.parse(Buffer.concat(chunks).toString('utf8'))\n if (value === null || typeof value !== 'object' || Array.isArray(value)) {\n fail()\n return\n }\n settled = true\n resolve(value as Record<string, unknown>)\n } catch {\n fail()\n }\n })\n req.on('error', fail)\n })\n}\n\n/**\n * 远端侧中继凭据铸造路由:POST /api/dshb/sync/internal/relay-ticket。\n * 仅接受回环请求;用本机 credentials 的浏览器会话密钥为请求指定的\n * authority 铸造 ≤10 分钟签名 cookie。凭据只在响应中返回一次。\n */\nexport function registerRelayTicketRoutes(ctx: Context, credentials: {\n readRecord(key: CredentialKey): Promise<unknown>\n}): void {\n const rateLimit = { windowStart: 0, count: 0 }\n ctx.effect(() =>\n ctx.webServer.register({\n kind: 'exact',\n path: '/api/dshb/sync/internal/relay-ticket',\n handler: async (req: IncomingMessage, res: ServerResponse) => {\n const deny = (status: number, body: Record<string, unknown>): void => {\n res.writeHead(status, { 'content-type': 'application/json', 'cache-control': 'no-store' })\n res.end(JSON.stringify(body))\n }\n if (!isLoopbackRequest(req.socket.remoteAddress, req.headers.host)) {\n deny(403, { ok: false, error: 'loopback access required' })\n return\n }\n if (req.method !== 'POST') {\n deny(405, { ok: false, error: 'method not allowed' })\n return\n }\n const now = Date.now()\n if (now - rateLimit.windowStart > 60_000) {\n rateLimit.windowStart = now\n rateLimit.count = 0\n }\n rateLimit.count += 1\n if (rateLimit.count > MAX_TICKETS_PER_MINUTE) {\n deny(429, { ok: false, error: 'relay ticket rate limit exceeded' })\n return\n }\n const body = await readJsonBody(req, 1024)\n let authority: string\n try {\n authority = validateRelayAuthority(body?.authority)\n } catch (error) {\n const code = error instanceof RelayTicketError ? error.code : 'authority-invalid'\n deny(400, { ok: false, code, error: error instanceof Error ? error.message : 'authority is invalid' })\n return\n }\n try {\n const record = await credentials.readRecord(credentialKey('client-connection', 'browser-session'))\n const secret = browserSessionSecret(record)\n const cookie = mintRelayCookie(secret, authority, now)\n res.writeHead(200, { 'content-type': 'application/json', 'cache-control': 'no-store' })\n res.end(JSON.stringify({ ok: true, cookie: { name: cookie.name, value: cookie.value, maxAgeSeconds: cookie.maxAgeSeconds } }))\n } catch (error) {\n if (error instanceof RelayTicketError) {\n deny(503, { ok: false, code: error.code, error: error.message })\n return\n }\n deny(500, { ok: false, code: 'relay-ticket-failed', error: 'relay ticket minting failed' })\n }\n },\n }),\n )\n}\n\n/** 导出给测试:校验铸造值与浏览器认证的期望格式逐字节一致。 */\nexport const relayTicketTestKit = { constantTimeEquals }\n"],"mappings":";;;;AAcA,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB;AAC3B,MAAa,0BAA0B;AACvC,MAAM,yBAAyB;AAE/B,MAAM,oBAAoB;AAE1B,IAAa,mBAAb,cAAsC,MAAM;CACrB;CAArB,YAAY,MAAuB,SAAiB;EAClD,MAAM,OAAO;EADM,KAAA,OAAA;EAEnB,KAAK,OAAO;CACd;AACF;AAEA,SAAS,gBAAgB,OAA2B;CAClD,OAAO,OAAO,KAAK,KAAK,CAAC,CAAC,SAAS,QAAQ,CAAC,CACzC,WAAW,KAAK,GAAG,CAAC,CACpB,WAAW,KAAK,GAAG,CAAC,CACpB,QAAQ,QAAQ,EAAE;AACvB;AAEA,SAAS,gBAAgB,OAAmC;CAC1D,IAAI,CAAC,mBAAmB,KAAK,KAAK,KAAK,MAAM,SAAS,MAAM,GAAG,OAAO,KAAA;CACtE,MAAM,UAAU,OAAO,KAAK,MAAM,WAAW,KAAK,GAAG,CAAC,CAAC,WAAW,KAAK,GAAG,GAAG,QAAQ;CACrF,OAAO,gBAAgB,OAAO,MAAM,QAAQ,UAAU,KAAA;AACxD;;AAGA,SAAgB,qBAAqB,QAAyB;CAC5D,IAAI,WAAW,QAAQ,OAAO,WAAW,YAAY,MAAM,QAAQ,MAAM,GACvE,MAAM,IAAI,iBAAiB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,OAAO;IAA8B,CAAC;GAC5F;EACF;CACF,CAAC,CACH;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as SyncImportMethod } from "./model-
|
|
1
|
+
import { s as SyncImportMethod } from "./model-zRfOihS3.js";
|
|
2
2
|
//#region src/core/sync/session-journal.d.ts
|
|
3
3
|
declare class SyncSessionJournalStore {
|
|
4
4
|
private readonly home;
|
|
@@ -45,4 +45,4 @@ declare class SyncSessionJournalStore {
|
|
|
45
45
|
}
|
|
46
46
|
//#endregion
|
|
47
47
|
export { SyncSessionJournalStore as t };
|
|
48
|
-
//# sourceMappingURL=session-journal-
|
|
48
|
+
//# sourceMappingURL=session-journal-BKjaO_1l.d.ts.map
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { o as NodeRegistry } from "./node-registry-BTnnM5-k.js";
|
|
2
2
|
import { r as WorkspaceBindingsStore } from "./workspace-bindings-CsB0TIJB.js";
|
|
3
3
|
import { r as SyncRevision } from "./revision-C9sOlDZ6.js";
|
|
4
|
-
import { _ as SyncSessionArchive, i as SyncCatalogWorkspace, l as SyncOrigin, m as SyncRecordMetadata, r as SyncCatalogSession, s as SyncImportMethod } from "./model-
|
|
5
|
-
import { n as SyncStateStore } from "./stores-
|
|
6
|
-
import { s as SyncNodeService } from "./node-sync-
|
|
7
|
-
import {
|
|
4
|
+
import { _ as SyncSessionArchive, i as SyncCatalogWorkspace, l as SyncOrigin, m as SyncRecordMetadata, r as SyncCatalogSession, s as SyncImportMethod } from "./model-zRfOihS3.js";
|
|
5
|
+
import { n as SyncStateStore } from "./stores-DnyrIi4h.js";
|
|
6
|
+
import { s as SyncNodeService } from "./node-sync-Ba4yARei.js";
|
|
7
|
+
import { _ as TypertLookup, a as SystemPromptUpdate, b as BrandedNumber, c as ToolSchema, d as Message, f as SystemMessage, g as ToolCallId, i as LlmFailure, l as AssistantMessage, m as UserMessage, n as LlmCallConfig, o as TokenUsage, p as ToolResultMessage, r as LlmCallConfigAdapterDefaults, s as ToolHistory, t as AssistantStreamRecord, u as DeveloperMessage, v as TypertResource, y as Branded } from "./index-D6KDknUV.js";
|
|
8
8
|
import { a as SessionInstructionSnapshotStore, s as WorkspaceInstructionStore } from "./workspace-instructions-C_ViytzA.js";
|
|
9
|
-
import { t as SyncSessionJournalStore } from "./session-journal-
|
|
9
|
+
import { t as SyncSessionJournalStore } from "./session-journal-BKjaO_1l.js";
|
|
10
10
|
import { Context, Service } from "@deepseek-ai/cordis";
|
|
11
|
+
import { FileAttachmentRef, ImageAttachmentRef } from "@deepseek-ai/dsh-attachment";
|
|
11
12
|
//#region ../../node_modules/@deepseek-ai/dsh-scope/lib/types/index.d.ts
|
|
12
13
|
declare const ScopedBrand: unique symbol;
|
|
13
14
|
/**
|
|
@@ -1225,6 +1226,7 @@ interface WorkspaceRegistryLike {
|
|
|
1225
1226
|
list(): WorkspaceLike[];
|
|
1226
1227
|
get(id: string): WorkspaceLike | undefined;
|
|
1227
1228
|
create(path: string, title?: string): Promise<WorkspaceLike>;
|
|
1229
|
+
delete?(workspaceId: string): Promise<boolean>;
|
|
1228
1230
|
archiveSession(sessionId: SessionId, options?: {
|
|
1229
1231
|
stopActivity?: boolean;
|
|
1230
1232
|
}): Promise<void>;
|
|
@@ -1300,7 +1302,7 @@ declare class SyncSessionService {
|
|
|
1300
1302
|
private readonly instructions;
|
|
1301
1303
|
private readonly journal;
|
|
1302
1304
|
private readonly now;
|
|
1303
|
-
private readonly
|
|
1305
|
+
private readonly getSessionProjection?;
|
|
1304
1306
|
private operationTail;
|
|
1305
1307
|
private readonly exportCache;
|
|
1306
1308
|
private readonly exportCacheStore;
|
|
@@ -1310,7 +1312,10 @@ declare class SyncSessionService {
|
|
|
1310
1312
|
readonly objectInbox: SyncSessionObjectInbox;
|
|
1311
1313
|
/** 工作区级指令存储:导入采纳写入,驱动该工作区新会话的指令注入。 */
|
|
1312
1314
|
readonly workspaceInstructions: WorkspaceInstructionStore;
|
|
1313
|
-
constructor(state: SyncStateStore, nodes: SyncNodeService, registry: NodeRegistry, bindings: WorkspaceBindingsStore, getWorkspaces: () => WorkspaceRegistryLike | undefined, getPersistence: () => SessionPersistenceLike | undefined, getAttachments: () => AttachmentStoreLike | undefined, getSpills: () => SpillStoreLike | undefined, instructions: SessionInstructionSnapshotStore, journal?: SyncSessionJournalStore, now?: () => number, home?: string, workspaceInstructions?: WorkspaceInstructionStore,
|
|
1315
|
+
constructor(state: SyncStateStore, nodes: SyncNodeService, registry: NodeRegistry, bindings: WorkspaceBindingsStore, getWorkspaces: () => WorkspaceRegistryLike | undefined, getPersistence: () => SessionPersistenceLike | undefined, getAttachments: () => AttachmentStoreLike | undefined, getSpills: () => SpillStoreLike | undefined, instructions: SessionInstructionSnapshotStore, journal?: SyncSessionJournalStore, now?: () => number, home?: string, workspaceInstructions?: WorkspaceInstructionStore, getSessionProjection?: ((header: SessionHeader) => {
|
|
1316
|
+
title?: string;
|
|
1317
|
+
blank?: boolean;
|
|
1318
|
+
} | undefined) | undefined);
|
|
1314
1319
|
exportBundle(): Promise<SyncSessionBundle>;
|
|
1315
1320
|
exportManifest(): Promise<SyncSessionManifest>;
|
|
1316
1321
|
exportEntries(keys: readonly string[], manifestDigest?: string, prefixes?: readonly SyncSessionEventPrefix[], options?: {
|
|
@@ -1327,6 +1332,14 @@ declare class SyncSessionService {
|
|
|
1327
1332
|
* 已应用完成的条目不受影响。
|
|
1328
1333
|
*/
|
|
1329
1334
|
discardPendingBatches(peerId: string): number;
|
|
1335
|
+
/**
|
|
1336
|
+
* 超限会话整文件迁移后的收尾:把已落盘的本地会话挂到工作区并写 membership。
|
|
1337
|
+
* 只做 membership(不重放事件);供 open-session 的 file 迁移路径调用。
|
|
1338
|
+
*/
|
|
1339
|
+
adoptMigratedSession(metadata: SyncRecordMetadata, localSessionId: string, workspaceId: string, sourceName: string): Promise<boolean>;
|
|
1340
|
+
/** registry 注入后补挂迁移会话(由 index.ts 的 inject 回调调用)。 */
|
|
1341
|
+
private pendingMigratedAdoptions;
|
|
1342
|
+
flushPendingMigratedAdoptions(): Promise<void>;
|
|
1330
1343
|
recoverPending(): Promise<void>;
|
|
1331
1344
|
cleanupOrphanedStaging(): void;
|
|
1332
1345
|
listArchives(): SyncSessionArchive[];
|
|
@@ -1334,6 +1347,16 @@ declare class SyncSessionService {
|
|
|
1334
1347
|
workspaces: SyncCatalogWorkspace[];
|
|
1335
1348
|
sessions: SyncCatalogSession[];
|
|
1336
1349
|
}>;
|
|
1350
|
+
/**
|
|
1351
|
+
* Detach metadata-mode imports when their peer is removed. DSH persistence is append-only,
|
|
1352
|
+
* so imported sessions are archived (hidden from active workspaces and still recoverable)
|
|
1353
|
+
* rather than physically erased. Full-sync peers deliberately do not call this method.
|
|
1354
|
+
*/
|
|
1355
|
+
removeMetadataPeerImports(peerInstanceId: string | undefined, trackedLocalSessionIds?: readonly string[], fallbackSourceName?: string): Promise<{
|
|
1356
|
+
sessionsArchived: number;
|
|
1357
|
+
workspacesRemoved: number;
|
|
1358
|
+
workspacesDetached: number;
|
|
1359
|
+
}>;
|
|
1337
1360
|
restoreArchive(branchId: string): Promise<SessionId>;
|
|
1338
1361
|
private reuseCachedManifestEntry;
|
|
1339
1362
|
private exportBundleNow;
|
|
@@ -1380,4 +1403,4 @@ declare class SyncSessionService {
|
|
|
1380
1403
|
}
|
|
1381
1404
|
//#endregion
|
|
1382
1405
|
export { workspaceDigest as A, sessionEventDigest as C, validateObjectPayload as D, syncSessionEntryKey as E, validateSyncSessionBundle as O, planSessionTransfers as S, sessionStateDigest as T, SyncSessionWorkspace as _, SyncSessionBundle as a, makeSyncSessionBundle as b, SyncSessionEventDelta as c, SyncSessionManifest as d, SyncSessionManifestEntry as f, SyncSessionTransferPlan as g, SyncSessionService as h, SyncSessionApplyResult as i, validateSyncSessionManifest as k, SyncSessionEventPrefix as l, SyncSessionObjectInbox as m, SyncObjectInboxWriter as n, SyncSessionEntry as o, SyncSessionObject as p, SyncSessionApplyOptions as r, SyncSessionError as s, ExportObjectCache as t, SyncSessionInstructionSnapshot as u, WorkspaceRegistryLike as v, sessionEventListDigest as w, makeSyncSessionManifest as x, estimateJsonBytes as y };
|
|
1383
|
-
//# sourceMappingURL=session-sync-
|
|
1406
|
+
//# sourceMappingURL=session-sync-B5MCI0TW.d.ts.map
|