@orkestrel/websocket 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,7 @@ npm install @orkestrel/websocket
13
13
 
14
14
  ## Requirements
15
15
 
16
- - Node.js >= 24
16
+ - Node.js >= 22.12.0
17
17
  - Ships dual ESM + CommonJS builds (see `exports` in `package.json`)
18
18
  - Server-only — a single Node-native surface
19
19
 
@@ -27,9 +27,14 @@ import { createNodeWebSocket } from '@orkestrel/websocket'
27
27
  // from there. Passing the client's `sec-websocket-key` selects SERVER mode — the
28
28
  // wrapper writes the 101 handshake, marks the connection open, and decodes frames.
29
29
  createServer().on('upgrade', (request, socket, head) => {
30
+ const key = request.headers['sec-websocket-key']
31
+ if (typeof key !== 'string') {
32
+ socket.destroy()
33
+ return
34
+ }
30
35
  const ws = createNodeWebSocket({
31
36
  socket,
32
- key: request.headers['sec-websocket-key'], // present => server mode + 101 handshake
37
+ key, // present => server mode + 101 handshake
33
38
  head, // any bytes that arrived bundled with the upgrade request
34
39
  on: { message: (text) => ws.send(`echo: ${text}`) }, // wire listeners at construction
35
40
  })
@@ -42,7 +47,7 @@ createServer().on('upgrade', (request, socket, head) => {
42
47
 
43
48
  The full API — factories, the `NodeWebSocket` class, the pure codec helpers,
44
49
  constants, and types — is documented in
45
- [`guides/src/websocket.md`](https://github.com/orkestrel/websocket/blob/main/guides/src/websocket.md).
50
+ [`guides/websocket.md`](https://github.com/orkestrel/websocket/blob/main/guides/websocket.md).
46
51
 
47
52
  ## Package
48
53