fix: only require userId on hello; add package-lock

This commit is contained in:
2026-09-01 14:28:20 +08:00
parent 180d74c005
commit 3ea27d747f
2 changed files with 52 additions and 6 deletions
+12 -6
View File
@@ -170,17 +170,23 @@ function handleMessage(ws, raw) {
return;
}
if (!msg || typeof msg !== 'object') return;
const userId = msg.userId;
if (typeof userId !== 'string' || userId.length === 0) {
send(ws, { type: 'auth-error', message: 'missing userId' });
ws.close();
return;
}
if (msg.type === 'hello' && !ws.role) {
const userId = msg.userId;
if (typeof userId !== 'string' || userId.length === 0) {
send(ws, { type: 'auth-error', message: 'missing userId' });
ws.close();
return;
}
if (msg.role === 'dsh') handleDshHello(userId, ws, msg);
else handleClientHello(userId, ws, msg);
return;
}
const userId = userIdOf(ws);
if (!userId) {
send(ws, { type: 'auth-error', message: 'hello required' });
ws.close();
return;
}
if (ws.role === 'dsh') {
handleHarnessMessage(userId, ws, msg);
} else if (ws.role === 'client') {