add tips for handling auth and add typings for ws
This commit is contained in:
parent
af5c36d03a
commit
7945a5ba12
@ -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)
|
||||
|
||||
10
package-lock.json
generated
10
package-lock.json
generated
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user