dsh-local-link 1.0.0 → 1.1.0
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 +24 -0
- package/README.md +27 -23
- package/SECURITY.md +1 -1
- package/docs/ARCHITECTURE.md +19 -15
- package/docs/COMPATIBILITY.md +31 -25
- package/docs/MOBILE_VIEW.md +4 -4
- package/docs/SECURITY.md +7 -7
- package/lib/client.js +10 -7
- package/lib/client.js.map +1 -1
- package/lib/index.mjs +66 -2
- package/package.json +28 -19
package/lib/index.mjs
CHANGED
|
@@ -594,6 +594,25 @@ const STREAM_PATHS = /* @__PURE__ */ new Set([
|
|
|
594
594
|
"/api/events.host",
|
|
595
595
|
"/api/remote.mux"
|
|
596
596
|
]);
|
|
597
|
+
const LOOPBACK_ONLY_RPC_METHODS = /* @__PURE__ */ new Set([
|
|
598
|
+
"host.pickDirectory",
|
|
599
|
+
"host.openPath",
|
|
600
|
+
"settings.describe",
|
|
601
|
+
"settings.canOpenAgentPresetDirectory",
|
|
602
|
+
"settings.update",
|
|
603
|
+
"settings.replace",
|
|
604
|
+
"settings.mutate",
|
|
605
|
+
"settings.openDocument",
|
|
606
|
+
"settings.openSettingsDocument",
|
|
607
|
+
"settings.openAgentPresetDirectory",
|
|
608
|
+
"credentials.describe",
|
|
609
|
+
"credentials.set",
|
|
610
|
+
"credentials.unset",
|
|
611
|
+
"agentPreset.read",
|
|
612
|
+
"agentPreset.copy",
|
|
613
|
+
"agentPreset.openDocument",
|
|
614
|
+
"agentPreset.remove"
|
|
615
|
+
]);
|
|
597
616
|
const HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
|
|
598
617
|
"connection",
|
|
599
618
|
"keep-alive",
|
|
@@ -685,12 +704,21 @@ function requestKind(pathname) {
|
|
|
685
704
|
function supportedWebSocketTarget(target) {
|
|
686
705
|
return target.search === "" && STREAM_PATHS.has(target.pathname);
|
|
687
706
|
}
|
|
707
|
+
function isLoopbackOnlyRpcTarget(target) {
|
|
708
|
+
if (!target.pathname.startsWith("/api/")) return false;
|
|
709
|
+
try {
|
|
710
|
+
return LOOPBACK_ONLY_RPC_METHODS.has(decodeURIComponent(target.pathname.slice(5)));
|
|
711
|
+
} catch {
|
|
712
|
+
return true;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
688
715
|
var LocalGateway = class {
|
|
689
716
|
config;
|
|
690
717
|
devices;
|
|
691
718
|
pairing;
|
|
692
719
|
diagnostics;
|
|
693
720
|
upgradedSockets = /* @__PURE__ */ new Set();
|
|
721
|
+
deviceSockets = /* @__PURE__ */ new Map();
|
|
694
722
|
server;
|
|
695
723
|
addresses = [];
|
|
696
724
|
browserAuthenticationUrl;
|
|
@@ -755,7 +783,11 @@ var LocalGateway = class {
|
|
|
755
783
|
this.diagnostics.record("error", code);
|
|
756
784
|
}
|
|
757
785
|
async revoke(id) {
|
|
758
|
-
|
|
786
|
+
try {
|
|
787
|
+
return await this.devices.revoke(id);
|
|
788
|
+
} finally {
|
|
789
|
+
this.closeDeviceSockets(id);
|
|
790
|
+
}
|
|
759
791
|
}
|
|
760
792
|
async renameDevice(id, name) {
|
|
761
793
|
return this.devices.renameDevice(id, name);
|
|
@@ -766,6 +798,7 @@ var LocalGateway = class {
|
|
|
766
798
|
if (server === void 0) return;
|
|
767
799
|
for (const socket of this.upgradedSockets) socket.destroy();
|
|
768
800
|
this.upgradedSockets.clear();
|
|
801
|
+
this.deviceSockets.clear();
|
|
769
802
|
await new Promise((resolve, reject) => server.close((error) => error === void 0 ? resolve() : reject(error)));
|
|
770
803
|
}
|
|
771
804
|
requestTrusted(request) {
|
|
@@ -774,6 +807,23 @@ var LocalGateway = class {
|
|
|
774
807
|
authorized(request) {
|
|
775
808
|
return this.config.accessMode === "trusted-lan" || this.devices.authorize(cookieValue(request, COOKIE_NAME)) !== void 0;
|
|
776
809
|
}
|
|
810
|
+
trackDeviceSocket(deviceId, socket) {
|
|
811
|
+
const sockets = this.deviceSockets.get(deviceId) ?? /* @__PURE__ */ new Set();
|
|
812
|
+
sockets.add(socket);
|
|
813
|
+
this.deviceSockets.set(deviceId, sockets);
|
|
814
|
+
}
|
|
815
|
+
untrackDeviceSocket(deviceId, socket) {
|
|
816
|
+
const sockets = this.deviceSockets.get(deviceId);
|
|
817
|
+
if (sockets === void 0) return;
|
|
818
|
+
sockets.delete(socket);
|
|
819
|
+
if (sockets.size === 0) this.deviceSockets.delete(deviceId);
|
|
820
|
+
}
|
|
821
|
+
closeDeviceSockets(deviceId) {
|
|
822
|
+
const sockets = this.deviceSockets.get(deviceId);
|
|
823
|
+
if (sockets === void 0) return;
|
|
824
|
+
this.deviceSockets.delete(deviceId);
|
|
825
|
+
for (const socket of sockets) socket.destroy();
|
|
826
|
+
}
|
|
777
827
|
async handle(request, response) {
|
|
778
828
|
if (!this.requestTrusted(request)) {
|
|
779
829
|
this.diagnostics.record("warn", "REQUEST_REJECTED", { reason: "untrusted_source" });
|
|
@@ -844,6 +894,11 @@ var LocalGateway = class {
|
|
|
844
894
|
}
|
|
845
895
|
return;
|
|
846
896
|
}
|
|
897
|
+
if (isLoopbackOnlyRpcTarget(url)) {
|
|
898
|
+
this.diagnostics.record("warn", "REQUEST_REJECTED", { reason: "loopback_only_rpc" });
|
|
899
|
+
send(response, 403, "This DeepSeek Harness action is available only on the host computer.");
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
847
902
|
const interceptIndex = request.method === "GET" && url.pathname === "/";
|
|
848
903
|
this.proxyHttp(request, response, interceptIndex, interceptIndex && url.searchParams.has("token"));
|
|
849
904
|
}
|
|
@@ -891,7 +946,8 @@ var LocalGateway = class {
|
|
|
891
946
|
}
|
|
892
947
|
async proxyWebSocket(request, client, head) {
|
|
893
948
|
const trusted = this.requestTrusted(request);
|
|
894
|
-
const
|
|
949
|
+
const device = this.config.accessMode === "pairing" ? this.devices.authorize(cookieValue(request, COOKIE_NAME)) : void 0;
|
|
950
|
+
const authorized = trusted && (this.config.accessMode === "trusted-lan" || device !== void 0);
|
|
895
951
|
if (!trusted || !authorized) {
|
|
896
952
|
this.diagnostics.record("warn", "WS_REJECTED", { reason: trusted ? "unauthorized" : "untrusted_source" });
|
|
897
953
|
client.end("HTTP/1.1 401 Unauthorized\r\nConnection: close\r\n\r\n");
|
|
@@ -905,9 +961,17 @@ var LocalGateway = class {
|
|
|
905
961
|
const upstream = connect(Number(this.config.upstreamOrigin.port), this.config.upstreamOrigin.hostname);
|
|
906
962
|
this.upgradedSockets.add(client);
|
|
907
963
|
this.upgradedSockets.add(upstream);
|
|
964
|
+
if (device !== void 0) {
|
|
965
|
+
this.trackDeviceSocket(device.id, client);
|
|
966
|
+
this.trackDeviceSocket(device.id, upstream);
|
|
967
|
+
}
|
|
908
968
|
const cleanup = () => {
|
|
909
969
|
this.upgradedSockets.delete(client);
|
|
910
970
|
this.upgradedSockets.delete(upstream);
|
|
971
|
+
if (device !== void 0) {
|
|
972
|
+
this.untrackDeviceSocket(device.id, client);
|
|
973
|
+
this.untrackDeviceSocket(device.id, upstream);
|
|
974
|
+
}
|
|
911
975
|
};
|
|
912
976
|
client.once("close", cleanup);
|
|
913
977
|
upstream.once("close", cleanup);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-local-link",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "DeepSeek Harness plugin for lightweight LAN access to the current Web UI from phones, tablets, and other computers.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -43,8 +43,9 @@
|
|
|
43
43
|
"client": {
|
|
44
44
|
"platform": "web",
|
|
45
45
|
"inject": [
|
|
46
|
-
"@deepseek-ai/dsh-
|
|
47
|
-
"@deepseek-ai/dsh-client-ui-
|
|
46
|
+
"@deepseek-ai/dsh-api-session-controller",
|
|
47
|
+
"@deepseek-ai/dsh-client-ui-renderer",
|
|
48
|
+
"@deepseek-ai/dsh-client-ui-session",
|
|
48
49
|
"@deepseek-ai/dsh-client-locale",
|
|
49
50
|
"@deepseek-ai/dsh-client-ui-theme",
|
|
50
51
|
"@deepseek-ai/dsh-client-ui-layout",
|
|
@@ -85,8 +86,8 @@
|
|
|
85
86
|
"license": "MIT",
|
|
86
87
|
"author": "DoNotEatMe",
|
|
87
88
|
"peerDependencies": {
|
|
88
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
89
|
-
"@deepseek-ai/dsh-host-webserver": "
|
|
89
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
90
|
+
"@deepseek-ai/dsh-host-webserver": "0.1.0-rc.8 || 0.1.1-rc.2 || 0.1.2-rc.1",
|
|
90
91
|
"react": "^18.2.0"
|
|
91
92
|
},
|
|
92
93
|
"peerDependenciesMeta": {
|
|
@@ -101,23 +102,31 @@
|
|
|
101
102
|
}
|
|
102
103
|
},
|
|
103
104
|
"dependencies": {
|
|
104
|
-
"@deepseek-ai/schemastery": "^3.18.
|
|
105
|
+
"@deepseek-ai/schemastery": "^3.18.2",
|
|
105
106
|
"qrcode": "^1.5.4"
|
|
106
107
|
},
|
|
107
108
|
"devDependencies": {
|
|
108
|
-
"@deepseek-ai/cordis": "
|
|
109
|
-
"@deepseek-ai/dsh-
|
|
110
|
-
"@deepseek-ai/dsh-
|
|
111
|
-
"@deepseek-ai/dsh-client-
|
|
112
|
-
"@deepseek-ai/dsh-client-
|
|
113
|
-
"@deepseek-ai/dsh-client-ui-
|
|
114
|
-
"@deepseek-ai/dsh-client-ui-
|
|
115
|
-
"@deepseek-ai/dsh-client-ui-
|
|
116
|
-
"@deepseek-ai/dsh-client-ui-
|
|
117
|
-
"@deepseek-ai/dsh-client-ui-
|
|
118
|
-
"@deepseek-ai/dsh-client-ui-
|
|
119
|
-
"@deepseek-ai/dsh-
|
|
120
|
-
"@deepseek-ai/dsh-
|
|
109
|
+
"@deepseek-ai/cordis": "4.0.2",
|
|
110
|
+
"@deepseek-ai/dsh-api-session-controller": "0.1.2-rc.1",
|
|
111
|
+
"@deepseek-ai/dsh-attachment": "0.1.2-rc.1",
|
|
112
|
+
"@deepseek-ai/dsh-client-connection": "0.1.2-rc.1",
|
|
113
|
+
"@deepseek-ai/dsh-client-locale": "0.1.2-rc.1",
|
|
114
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.1.2-rc.1",
|
|
115
|
+
"@deepseek-ai/dsh-client-ui-layout": "0.1.2-rc.1",
|
|
116
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.1.2-rc.1",
|
|
117
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.1.2-rc.1",
|
|
118
|
+
"@deepseek-ai/dsh-client-ui-session": "0.1.2-rc.1",
|
|
119
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.1.2-rc.1",
|
|
120
|
+
"@deepseek-ai/dsh-client-ui-sidebar": "0.1.2-rc.1",
|
|
121
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.1.2-rc.1",
|
|
122
|
+
"@deepseek-ai/dsh-client-ui-theme": "0.1.2-rc.1",
|
|
123
|
+
"@deepseek-ai/dsh-host-webserver": "0.1.2-rc.1",
|
|
124
|
+
"@deepseek-ai/dsh-code-runtime": "0.1.2-rc.1",
|
|
125
|
+
"@deepseek-ai/dsh-session-persistence": "0.1.2-rc.1",
|
|
126
|
+
"@deepseek-ai/dsh-session-query": "0.1.2-rc.1",
|
|
127
|
+
"@deepseek-ai/dsh-session-log-export": "0.1.2-rc.1",
|
|
128
|
+
"@deepseek-ai/dsh-settings": "0.1.2-rc.1",
|
|
129
|
+
"@deepseek-ai/dsh-subagent": "0.1.2-rc.1",
|
|
121
130
|
"@types/node": "^24.3.0",
|
|
122
131
|
"@types/qrcode": "^1.5.5",
|
|
123
132
|
"@types/react": "~18.3.1",
|