@dsh-mobile/mobile-remote 3.2.4 → 3.2.5
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/CHANGELOG.md +204 -0
- package/FAQ.md +4 -0
- package/README.md +21 -14
- package/docs/01-PRD.md +4 -4
- package/docs/02-architecture.md +1 -1
- package/docs/03-api.md +49 -1
- package/docs/05-test-cases.md +7 -7
- package/docs/06-install-run.md +16 -3
- package/docs/07-user-manual.md +23 -1
- package/docs/08-/346/211/251/345/261/225/345/274/200/345/217/221/346/214/207/345/215/227.md +2 -2
- package/docs/09-compatibility.md +3 -3
- package/docs/10-remote-access-and-launch-plan.md +216 -0
- package/docs/11-remote-relay-guide.md +82 -0
- package/docs/APP-ENCRYPTION-DESCRIPTION.md +50 -0
- package/docs/APP-ENCRYPTION-DESCRIPTION.pdf +0 -0
- package/docs/AUDIT-2026-11-node.md +181 -0
- package/docs/AUDIT-2026-11.md +167 -0
- package/docs/BRAND-ASSETS.md +142 -0
- package/docs/BUILD-ENVIRONMENT.md +15 -4
- package/docs/FEATURE-PARITY.md +2 -2
- package/docs/PRIVACY-POLICY.en.md +143 -0
- package/docs/PRIVACY-POLICY.md +108 -30
- package/docs/STORE-LAUNCH.md +169 -21
- package/docs/STORE-LISTING.md +150 -0
- package/docs/SUPPORT.md +4 -3
- package/docs/TERMS-OF-SERVICE.en.md +70 -0
- package/docs/TERMS-OF-SERVICE.md +70 -0
- package/docs/screenshots/01-home.png +0 -0
- package/docs/screenshots/02-notifications.png +0 -0
- package/docs/screenshots/03-sessions.png +0 -0
- package/docs/screenshots/04-chat.png +0 -0
- package/docs/screenshots/05-settings.png +0 -0
- package/docs/screenshots/06-new-session.png +0 -0
- package/docs/screenshots/07-connect.png +0 -0
- package/lib/account-usage-query.js +278 -0
- package/lib/api-helpers.js +333 -0
- package/lib/client.js +284 -1
- package/lib/config.js +211 -0
- package/lib/host-compat.js +133 -0
- package/lib/http-util.js +69 -0
- package/lib/index.js +179 -2009
- package/lib/push.js +73 -0
- package/lib/rate-limit.js +46 -0
- package/lib/relay/connector.js +300 -0
- package/lib/relay/crypto.js +117 -0
- package/lib/relay/devices.js +138 -0
- package/lib/relay/identity.js +60 -0
- package/lib/relay/mux.js +411 -0
- package/lib/relay/noise.js +178 -0
- package/lib/relay/pairing.js +64 -0
- package/lib/relay/phone.js +114 -0
- package/lib/relay/serve.js +105 -0
- package/lib/rpc-adapter.js +88 -0
- package/lib/session-list.js +77 -0
- package/lib/timeline.js +476 -0
- package/lib/turn-outline.js +289 -0
- package/package.json +1 -1
package/lib/http-util.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON 响应 / 请求体读取 / 方法检查 / 响应防崩守卫。从 lib/index.js 原样拆出(行为不变;`error` 在模块内更名为 `sendError`)。
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** 响应防崩守卫(写已销毁响应时 error 事件有监听)。 */
|
|
6
|
+
export const guardRes = (res) => {
|
|
7
|
+
if (!res.__dshErrGuarded) {
|
|
8
|
+
res.__dshErrGuarded = true;
|
|
9
|
+
res.on("error", () => {});
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const sendJson = (res, status, body, headers = {}) => {
|
|
14
|
+
// v2.7.2 review(S2):客户端中途断开后对已销毁响应 writeHead/end 会 emit 'error',
|
|
15
|
+
// 无监听时 Node 抛未捕获异常 → 崩进程;挂一次性 noop 监听兜底
|
|
16
|
+
guardRes(res);
|
|
17
|
+
const text = JSON.stringify(body);
|
|
18
|
+
res.writeHead(status, {
|
|
19
|
+
"content-type": "application/json; charset=utf-8",
|
|
20
|
+
"cache-control": "no-store",
|
|
21
|
+
// v3.0.0(热修 04):响应即断(connection: close)——关闭 keep-alive 复用窗口:
|
|
22
|
+
// 手机 dart:io 连接池 idle 15s 与服务端 keep-alive 5s 存在半关竞态,
|
|
23
|
+
// 复用半关 socket 表现为「Connection reset by peer」:消息已送达却报失败。
|
|
24
|
+
// 移动端 API 均为一问一答短请求,无 keep-alive 收益。
|
|
25
|
+
"connection": "close",
|
|
26
|
+
"content-length": Buffer.byteLength(text),
|
|
27
|
+
...headers,
|
|
28
|
+
});
|
|
29
|
+
res.end(text);
|
|
30
|
+
};
|
|
31
|
+
export const sendError = (res, status, err, detail) => sendJson(res, status, detail ? { error: err, detail } : { error: err });
|
|
32
|
+
|
|
33
|
+
export const readBody = (req, limit = 64 * 1024) =>
|
|
34
|
+
new Promise((resolve, reject) => {
|
|
35
|
+
let size = 0;
|
|
36
|
+
const chunks = [];
|
|
37
|
+
req.on("data", (chunk) => {
|
|
38
|
+
size += chunk.length;
|
|
39
|
+
if (size > limit) {
|
|
40
|
+
reject(Object.assign(new Error("body too large"), { status: 413 }));
|
|
41
|
+
// v3.0.0 修复:超限先停读并让 handler 回 413——此前先 req.destroy()
|
|
42
|
+
// 会把连接直接掐断,客户端看到的是"连接意外关闭/连接重置"而非 413
|
|
43
|
+
// (592KB 图片上传即此症状:上游看到连接被切断 → 桥回 502 bridge-unavailable)
|
|
44
|
+
req.pause();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
chunks.push(chunk);
|
|
48
|
+
});
|
|
49
|
+
req.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
|
|
50
|
+
req.on("error", reject);
|
|
51
|
+
// review:客户端断开且不触发 error 时也要 settle,避免 handler 悬挂
|
|
52
|
+
req.on("close", () => reject(Object.assign(new Error("request closed"), { status: 400 })));
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Phase 1(S6):方法检查收敛——不匹配时已响应 405 并返回 true,调用点 `if (requireGet(method, res)) return;`
|
|
56
|
+
export const requireGet = (method, res) => {
|
|
57
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
58
|
+
sendError(res, 405, "method-not-allowed");
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
};
|
|
63
|
+
export const requirePost = (method, res) => {
|
|
64
|
+
if (method !== "POST") {
|
|
65
|
+
sendError(res, 405, "method-not-allowed");
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
};
|