@suncreation/crush-auth-proxy 1.1.0 → 1.1.1
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/bin/crush-auth-proxy.mjs +28 -8
- package/package.json +1 -1
package/bin/crush-auth-proxy.mjs
CHANGED
|
@@ -871,12 +871,22 @@ const server = http.createServer(async (req, res) => {
|
|
|
871
871
|
},
|
|
872
872
|
(retryRes) => {
|
|
873
873
|
res.writeHead(retryRes.statusCode, retryRes.headers);
|
|
874
|
+
let _retryBuf = "";
|
|
874
875
|
retryRes.on("data", (chunk) => {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
876
|
+
_retryBuf += chunk.toString("utf8");
|
|
877
|
+
let idx;
|
|
878
|
+
while ((idx = _retryBuf.indexOf("\n\n")) !== -1) {
|
|
879
|
+
const event = _retryBuf.slice(0, idx + 2);
|
|
880
|
+
_retryBuf = _retryBuf.slice(idx + 2);
|
|
881
|
+
res.write(event.replace(/"name"\s*:\s*"mcp_([^"]+)"/g, '"name": "$1"'));
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
retryRes.on("end", () => {
|
|
885
|
+
if (_retryBuf) {
|
|
886
|
+
res.write(_retryBuf.replace(/"name"\s*:\s*"mcp_([^"]+)"/g, '"name": "$1"'));
|
|
887
|
+
}
|
|
888
|
+
res.end();
|
|
878
889
|
});
|
|
879
|
-
retryRes.on("end", () => res.end());
|
|
880
890
|
}
|
|
881
891
|
);
|
|
882
892
|
retryReq.on("error", (e) => {
|
|
@@ -894,12 +904,22 @@ const server = http.createServer(async (req, res) => {
|
|
|
894
904
|
}
|
|
895
905
|
|
|
896
906
|
res.writeHead(proxyRes.statusCode, proxyRes.headers);
|
|
907
|
+
let _buf = "";
|
|
897
908
|
proxyRes.on("data", (chunk) => {
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
909
|
+
_buf += chunk.toString("utf8");
|
|
910
|
+
let idx;
|
|
911
|
+
while ((idx = _buf.indexOf("\n\n")) !== -1) {
|
|
912
|
+
const event = _buf.slice(0, idx + 2);
|
|
913
|
+
_buf = _buf.slice(idx + 2);
|
|
914
|
+
res.write(event.replace(/"name"\s*:\s*"mcp_([^"]+)"/g, '"name": "$1"'));
|
|
915
|
+
}
|
|
916
|
+
});
|
|
917
|
+
proxyRes.on("end", () => {
|
|
918
|
+
if (_buf) {
|
|
919
|
+
res.write(_buf.replace(/"name"\s*:\s*"mcp_([^"]+)"/g, '"name": "$1"'));
|
|
920
|
+
}
|
|
921
|
+
res.end();
|
|
901
922
|
});
|
|
902
|
-
proxyRes.on("end", () => res.end());
|
|
903
923
|
}
|
|
904
924
|
);
|
|
905
925
|
|
package/package.json
CHANGED