fix: only require userId on hello; add package-lock
This commit is contained in:
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user