@mrrisega/dsh-remote 0.6.0-beta.12 → 0.6.0-beta.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 +3 -43
- package/clients/dsh-remote/dsh-bridge.mjs +5 -335
- package/package.json +2 -2
- package/packages/dsh-remote-web/lib/client.js +183 -607
- package/packages/dsh-remote-web/lib/index.js +10 -139
- package/packages/dsh-remote-web/test/access-key-sessions.test.mjs +11 -81
- package/packages/dsh-remote-web/test/account-switch.test.mjs +1 -1
- package/packages/dsh-remote-web/test/feedback-proxy.test.mjs +1 -2
- package/packages/dsh-remote-web/test/remote-access-ui.test.mjs +3 -175
- package/packages/dsh-remote-web/test/settings-entry.test.mjs +5 -56
- package/packages/dsh-remote-web/test/uninstall-runtime.test.mjs +2 -2
- package/clients/dsh-remote/e2ee-client.mjs +0 -728
- package/clients/dsh-remote/e2ee-shim-script.js +0 -737
- package/clients/dsh-remote/e2ee-shim.mjs +0 -163
- package/clients/dsh-remote/mobile-adapter.mjs +0 -595
- package/clients/dsh-remote/test/bridge-html-inject.test.mjs +0 -110
- package/clients/dsh-remote/test/e2ee-bridge.test.mjs +0 -630
- package/clients/dsh-remote/test/e2ee-client.test.mjs +0 -378
- package/clients/dsh-remote/test/e2ee-shim.test.mjs +0 -507
- package/clients/dsh-remote/test/e2ee-wecrypto-parity.test.mjs +0 -200
- package/clients/dsh-remote/test/lib-e2ee-shim.mjs +0 -59
- package/clients/dsh-remote/test/lib-native-e2ee.mjs +0 -92
- package/clients/dsh-remote/test/mobile-adapter.test.mjs +0 -124
- package/packages/dsh-remote-web/test/e2ee-state.test.mjs +0 -141
- package/packages/dsh-remote-web/test/feedback-account-mine.test.mjs +0 -70
- package/packages/dsh-remote-web/test/password-reset.test.mjs +0 -430
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* bridge HTML 注入集成测试(经 doHttp/handleHttpFrame 全链路):
|
|
4
|
-
* - 官方特征 html 响应 → reply body 含注入的 <style data-dsh-mobile-adapter>;
|
|
5
|
-
* - 同时请求带 gzip Accept-Encoding → 仍是 gzip 且解压后含注入块(注入发生在 gzip 前);
|
|
6
|
-
* - DSH_MOBILE_ADAPTER=0 → 原样回传;
|
|
7
|
-
* - 非 html(SSE/json/二进制)不动。
|
|
8
|
-
*/
|
|
9
|
-
import assert from "node:assert/strict";
|
|
10
|
-
import { mkdtempSync, rmSync } from "node:fs";
|
|
11
|
-
import http from "node:http";
|
|
12
|
-
import os from "node:os";
|
|
13
|
-
import path from "node:path";
|
|
14
|
-
import test, { after } from "node:test";
|
|
15
|
-
import { gunzipSync } from "node:zlib";
|
|
16
|
-
|
|
17
|
-
const OFFICIAL_HTML = `<!doctype html><html><head>
|
|
18
|
-
<script>window.__ModuleLoader__ = { mode: "queue" }</script>
|
|
19
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
20
|
-
<title>DeepSeek Harness</title>
|
|
21
|
-
</head><body><div id="root"></div></body></html>`;
|
|
22
|
-
|
|
23
|
-
const upstream = http.createServer((req, res) => {
|
|
24
|
-
if (req.url === "/page") {
|
|
25
|
-
res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
|
|
26
|
-
res.end(OFFICIAL_HTML);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (req.url === "/events") {
|
|
30
|
-
res.writeHead(200, { "content-type": "text/event-stream" });
|
|
31
|
-
res.end("data: hi\n\n"); // 结束的 SSE 帧(便于缓冲测试)
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (req.url === "/app.js") {
|
|
35
|
-
res.writeHead(200, { "content-type": "application/javascript" });
|
|
36
|
-
res.end("console.log(1)");
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
res.writeHead(404);
|
|
40
|
-
res.end("nope");
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const tmpDir = mkdtempSync(path.join(os.tmpdir(), "dsh-html-inject-"));
|
|
44
|
-
process.env.DSH_BRIDGE_DEVICE_ID = "dev-htmltest0001";
|
|
45
|
-
process.env.DSH_BRIDGE_CONFIG = path.join(tmpDir, "config.json");
|
|
46
|
-
delete process.env.DSH_MOBILE_ADAPTER; // 默认开启
|
|
47
|
-
|
|
48
|
-
const { handleHttpFrame } = await new Promise((resolve, reject) => {
|
|
49
|
-
upstream.listen(0, "127.0.0.1", () => {
|
|
50
|
-
process.env.DSH_BRIDGE_UPSTREAM = `http://127.0.0.1:${upstream.address().port}`;
|
|
51
|
-
import("../dsh-bridge.mjs").then(resolve, reject);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
after(() => {
|
|
56
|
-
try { upstream.close(); } catch {}
|
|
57
|
-
try { rmSync(tmpDir, { recursive: true, force: true }); } catch {}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
async function request(frame) {
|
|
61
|
-
let reply;
|
|
62
|
-
const sender = (obj) => { reply = obj; return true; };
|
|
63
|
-
await handleHttpFrame(sender, { type: "http", ...frame });
|
|
64
|
-
return reply;
|
|
65
|
-
}
|
|
66
|
-
const decode = (reply) => {
|
|
67
|
-
const buf = Buffer.from(reply.body, "base64");
|
|
68
|
-
if (reply.headers["content-encoding"] === "gzip") return gunzipSync(buf).toString("utf8");
|
|
69
|
-
return buf.toString("utf8");
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
test("集成:官方特征 html 经 doHttp 回传时注入适配层", async () => {
|
|
73
|
-
const reply = await request({ id: "h1", method: "GET", path: "/page", headers: { "accept-encoding": "gzip", "user-agent": "phone" } });
|
|
74
|
-
assert.equal(reply.status, 200);
|
|
75
|
-
const text = decode(reply);
|
|
76
|
-
assert.ok(text.includes('data-dsh-mobile-adapter'), "应注入 style/script");
|
|
77
|
-
const headIdx = text.toLowerCase().lastIndexOf("</head>");
|
|
78
|
-
assert.ok(text.indexOf("dsh-mobile-adapter-css") < headIdx, "注入块应位于 </head> 前");
|
|
79
|
-
// 原文其余部分保持(仅 splice)
|
|
80
|
-
const oi = OFFICIAL_HTML.toLowerCase().lastIndexOf("</head>");
|
|
81
|
-
assert.ok(text.startsWith(OFFICIAL_HTML.slice(0, oi)));
|
|
82
|
-
assert.ok(text.endsWith(OFFICIAL_HTML.slice(oi)));
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test("集成:注入在 gzip 前发生,回包仍可 gzip 解压且含注入块", async () => {
|
|
86
|
-
const reply = await request({ id: "h2", method: "GET", path: "/page", headers: { "accept-encoding": "gzip, deflate", "user-agent": "phone" } });
|
|
87
|
-
assert.equal(reply.headers["content-encoding"], "gzip", "压缩后应带 content-encoding");
|
|
88
|
-
const text = decode(reply);
|
|
89
|
-
assert.ok(text.includes("dsh-mobile-adapter-js"));
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test("集成:DSH_MOBILE_ADAPTER=0 关闭注入,原样回传", async () => {
|
|
93
|
-
process.env.DSH_MOBILE_ADAPTER = "0";
|
|
94
|
-
try {
|
|
95
|
-
const reply = await request({ id: "h3", method: "GET", path: "/page", headers: { "user-agent": "phone" } });
|
|
96
|
-
const text = decode(reply);
|
|
97
|
-
assert.ok(!text.includes("data-dsh-mobile-adapter"), "关闭时应原样");
|
|
98
|
-
assert.equal(text, OFFICIAL_HTML);
|
|
99
|
-
} finally {
|
|
100
|
-
delete process.env.DSH_MOBILE_ADAPTER;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
test("集成:非 html(SSE / js / json)不动", async () => {
|
|
105
|
-
const ev = await request({ id: "h4", method: "GET", path: "/events", headers: { "accept-encoding": "gzip", "user-agent": "phone" } });
|
|
106
|
-
assert.equal(decode(ev), "data: hi\n\n");
|
|
107
|
-
const js = await request({ id: "h5", method: "GET", path: "/app.js", headers: { "accept-encoding": "gzip", "user-agent": "phone" } });
|
|
108
|
-
assert.equal(decode(js), "console.log(1)");
|
|
109
|
-
assert.ok(!decode(js).includes("dsh-mobile-adapter"));
|
|
110
|
-
});
|