fix: only require userId on hello; add package-lock
This commit is contained in:
Generated
+40
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "dshwatch-server",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "dshwatch-server",
|
||||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ws": "^8.18.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.21.3",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.21.3.tgz",
|
||||
"integrity": "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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