@ackuity/inline-proxy 0.7.4 → 0.7.6
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/dist/mode.js +34 -11
- package/package.json +1 -1
package/dist/mode.js
CHANGED
|
@@ -53,33 +53,56 @@ async function startProxy(agentTransport, serverTransport, onClose) {
|
|
|
53
53
|
return;
|
|
54
54
|
closing = true;
|
|
55
55
|
logToStderr(reason);
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
try {
|
|
57
|
+
agentTransport.close();
|
|
58
|
+
}
|
|
59
|
+
catch (_) { /* already closed */ }
|
|
60
|
+
try {
|
|
61
|
+
serverTransport.close();
|
|
62
|
+
}
|
|
63
|
+
catch (_) { /* already closed */ }
|
|
58
64
|
onClose?.();
|
|
59
65
|
};
|
|
60
66
|
agentTransport.onmessage = async (msg) => {
|
|
61
67
|
const allowed = await inspectRequest(msg);
|
|
62
68
|
if (allowed) {
|
|
63
|
-
|
|
69
|
+
try {
|
|
70
|
+
await serverTransport.send(allowed);
|
|
71
|
+
}
|
|
72
|
+
catch (_) { /* server transport closed or aborted */ }
|
|
64
73
|
}
|
|
65
74
|
else {
|
|
66
75
|
if ("id" in msg && msg.id !== undefined) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
try {
|
|
77
|
+
await agentTransport.send({
|
|
78
|
+
jsonrpc: "2.0",
|
|
79
|
+
id: msg.id,
|
|
80
|
+
error: { code: -32001, message: "Blocked by security policy" },
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
catch (_) { /* client already disconnected */ }
|
|
72
84
|
}
|
|
73
85
|
}
|
|
74
86
|
};
|
|
75
87
|
serverTransport.onmessage = async (msg) => {
|
|
76
88
|
const allowed = inspectResponse(msg);
|
|
77
89
|
if (allowed) {
|
|
78
|
-
|
|
90
|
+
try {
|
|
91
|
+
await agentTransport.send(allowed);
|
|
92
|
+
}
|
|
93
|
+
catch (_) { /* agent transport closed or aborted */ }
|
|
79
94
|
}
|
|
80
95
|
};
|
|
81
|
-
agentTransport.onerror = (err) =>
|
|
82
|
-
|
|
96
|
+
agentTransport.onerror = (err) => {
|
|
97
|
+
if (err.name === "AbortError")
|
|
98
|
+
return;
|
|
99
|
+
logToStderr(`agent error: ${err}`);
|
|
100
|
+
};
|
|
101
|
+
serverTransport.onerror = (err) => {
|
|
102
|
+
if (err.name === "AbortError")
|
|
103
|
+
return;
|
|
104
|
+
logToStderr(`server error: ${err}`);
|
|
105
|
+
};
|
|
83
106
|
agentTransport.onclose = () => closeSession("agent closed");
|
|
84
107
|
serverTransport.onclose = () => closeSession("server closed");
|
|
85
108
|
await serverTransport.start();
|