From 7945a5ba12aebbdcff9ff4fded7f0a7d3ccd7862 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Wed, 27 Mar 2024 16:10:00 +0100 Subject: [PATCH] add tips for handling auth and add typings for ws --- bin/server.cjs | 9 +++------ package-lock.json | 10 ++++++++++ package.json | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bin/server.cjs b/bin/server.cjs index cabdf28..ec5f4d8 100755 --- a/bin/server.cjs +++ b/bin/server.cjs @@ -1,8 +1,5 @@ #!/usr/bin/env node -/** - * @type {any} - */ const WebSocket = require('ws') const http = require('http') const number = require('lib0/number') @@ -20,9 +17,9 @@ const server = http.createServer((_request, response) => { wss.on('connection', setupWSConnection) server.on('upgrade', (request, socket, head) => { - // You may check auth of request here.. Call `wss.HandleUpgrade` *after* you - // checked whether the client has access (e.g. by checking cookies, or url - // parameters). + // You may check auth of request here.. + // Call `wss.HandleUpgrade` *after* you checked whether the client has access + // (e.g. by checking cookies, or url parameters). // See https://github.com/websockets/ws#client-authentication wss.handleUpgrade(request, socket, head, /** @param {any} ws */ ws => { wss.emit('connection', ws, request) diff --git a/package-lock.json b/package-lock.json index 3b5e4f6..87a80ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ }, "devDependencies": { "@types/node": "^18.15.0", + "@types/ws": "^8.5.10", "rollup": "^3.19.1", "standard": "^12.0.1", "typescript": "^4.9.5", @@ -46,6 +47,15 @@ "integrity": "sha512-z6nr0TTEOBGkzLGmbypWOGnpSpSIBorEhC4L+4HeQ2iezKCi4f77kyslRwvHeNitymGQ+oFyIWGP96l/DPSV9w==", "dev": true }, + "node_modules/@types/ws": { + "version": "8.5.10", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.10.tgz", + "integrity": "sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/abstract-leveldown": { "version": "6.2.3", "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-6.2.3.tgz", diff --git a/package.json b/package.json index ba9eb8f..ad41ea0 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ }, "devDependencies": { "@types/node": "^18.15.0", + "@types/ws": "^8.5.10", "rollup": "^3.19.1", "standard": "^12.0.1", "typescript": "^4.9.5",