Luigi Pinca
3ee5349a0b
[api] Convert the isServer and maxPayload parameters to options
...
To simplify the API before exporting the `PerMessageDeflate` class,
reduce the number of positional parameters in the constructor by moving
`isServer` and `maxPayload` into the options object.
2026-03-17 21:43:32 +01:00
Anthony
3f9ffc688f
[feature] Introduce the closeTimeout option ( #2308 )
...
Make graceful close timeout configurable.
2026-01-05 18:38:48 +01:00
yusheng chen
33f5dbaf33
[fix] Respond with the supported protocol versions ( #2291 )
...
Add the `Sec-WebSocket-Version` header, listing all supported versions,
to the response if the client requested version is either invalid or
unacceptable.
2025-06-28 15:00:23 +02:00
Amirali Amirifar
4f20aedbe2
[fix] Handle oversized messages with designated error ( #2285 )
...
Ensure that the correct error is surfaced when the max message size is
exceeded.
2025-05-02 15:03:02 +02:00
Luigi Pinca
cf259541e8
[minor] Fix nit in error message
...
Closes #2276
2025-03-25 16:04:16 +01:00
Luigi Pinca
021f7b8bff
[test] Shorten the path lengths
...
Shorten the length of temporary file and UNIX domain socket paths.
Refs: https://github.com/nodejs/node/pull/57005#issuecomment-2666921592
2025-02-20 15:43:05 +01:00
Luigi Pinca
59b9629b78
[feature] Add support for Blob ( #2229 )
...
Closes #2206
2024-07-02 17:50:16 +02:00
Luigi Pinca
e55e5106f1
[security] Fix crash when the Upgrade header cannot be read ( #2231 )
...
It is possible that the Upgrade header is correctly received and handled
(the `'upgrade'` event is emitted) without its value being returned to
the user. This can happen if the number of received headers exceed the
`server.maxHeadersCount` or `request.maxHeadersCount` threshold. In this
case `incomingMessage.headers.upgrade` may not be set.
Handle the case correctly and abort the handshake.
Fixes #2230
2024-06-16 11:42:59 +02:00
Luigi Pinca
6a00029edd
[test] Increase code coverage
2024-06-13 21:53:40 +02:00
Luigi Pinca
29694a5905
[test] Use the highWaterMark variable
...
Use the value of the `highWaterMark` variable instead of `16384`.
2024-04-26 08:04:47 +02:00
Luigi Pinca
96c9b3dedd
[major] Flip the default value of allowSynchronousEvents ( #2221 )
...
Flip the default value of the `allowSynchronousEvents` option to `true`.
Refs: https://github.com/websockets/ws/pull/2218
2024-04-24 15:42:40 +02:00
Luigi Pinca
e5f32c7e1e
[fix] Emit at most one event per event loop iteration ( #2218 )
...
Fixes #2216
2024-04-24 15:32:43 +02:00
Luigi Pinca
2aa0405a5e
[minor] Fix nits
2024-04-15 15:03:11 +02:00
Tim Perry
53a88881cf
[feature] Allow the createConnection option ( #2219 )
...
Allow passing in a custom `createConnection` function.
2024-04-15 14:20:52 +02:00
Luigi Pinca
391ddf3a9a
[test] Use stream.getDefaultHighWaterMark() when available
...
Refs: https://github.com/nodejs/node/pull/50120
2023-12-26 16:30:43 +01:00
Luigi Pinca
01ba54edae
[feature] Introduce the autoPong option
...
Add the ability to disable the automatic sending of pong responses to
pings.
Fixes #2186
2023-12-26 16:30:22 +01:00
Luigi Pinca
4ed7fe58b4
[major] Rename the allowMultipleEventsPerMicrotask option
...
Rename the `allowMultipleEventsPerMicrotask` option to
`allowSynchronousEvents`.
2023-12-12 19:00:08 +01:00
Luigi Pinca
fccc580061
[fix] Emit the event when the microtask is executed
...
Emit the `'message'`, `'ping'`, and `'pong'` event when the microtask
for that event is executed.
2023-12-12 08:29:34 +01:00
Luigi Pinca
93e3552e95
[feature] Introduce the allowMultipleEventsPerMicrotask option
...
The `allowMultipleEventsPerMicrotask` option allows the `'message'`,
`'ping'`, and `'pong'` events to be emitted more than once per
microtask.
Refs: https://github.com/websockets/ws/pull/2160
2023-12-09 15:49:10 +01:00
Luigi Pinca
c320738b1d
[test] Fix nits
2023-12-09 15:49:10 +01:00
Luigi Pinca
5a3036e3f5
[test] Merge some tests
2023-12-09 15:49:00 +01:00
Luigi Pinca
726abc3d1e
[test] Fix flaky test
2023-12-08 17:43:13 +01:00
Luigi Pinca
7f4e1a75af
[fix] Add missing rejection handler
...
Use `queueMicrotask()` when available and add a rejection handler to the
shim for it.
2023-09-19 15:50:08 +02:00
Luigi Pinca
fd3c64cbd6
[test] Fix flaky tests on Windows
2023-09-08 17:30:59 +02:00
Luigi Pinca
c1d26c372e
[test] Fix failing test
2023-09-06 15:30:33 +02:00
Luigi Pinca
5b577fe665
[pkg] Remove native-duplexpair dev dependency
...
It seems to be no longer maintained.
2023-09-06 15:06:15 +02:00
Luigi Pinca
62521f26d7
[minor] Fix nits
2023-08-31 21:37:11 +02:00
Tim Perry
31da41728f
[fix] Make server.handleUpgrade() work with any duplex stream ( #2165 )
2023-08-31 21:09:31 +02:00
Luigi Pinca
347aab6cd1
[feature] Allow http and https schemes ( #2162 )
...
Allow HTTP(S) URLs to be used in the WebSocket constructor. They are
immediately converted to the ws and wss schemes.
Refs: https://github.com/whatwg/websockets/pull/45
2023-08-28 15:05:57 +02:00
Luigi Pinca
79dab96227
[fix] Emit at most one event per microtask ( #2160 )
...
To improve compatibility with the WHATWG standard, emit at most one of
`'message'`, `'ping'`, and `'pong'` events per tick.
Fixes #2159
2023-08-28 15:05:11 +02:00
Luigi Pinca
67007fc800
[test] Reduce message size from 20 MiB to 4 MiB
2023-08-21 16:50:15 +02:00
Luigi Pinca
8eb2c4754a
[test] Fix nits
2023-08-20 11:13:58 +02:00
Luigi Pinca
5299b0ee6c
[test] Remove redundant tests
2023-08-20 11:13:46 +02:00
Luigi Pinca
23acf8cfaf
[test] Fix nits
2023-03-10 16:13:07 +01:00
Matthijs van Duin
cd89e077f6
[feature] Add option to support late addition of headers ( #2123 )
...
This supports the use-case where headers need to be added that depend on
the socket connection (e.g. for TLS channel binding).
2023-03-10 15:16:35 +01:00
Matthijs van Duin
b4b9d5a76e
[test] Fix failing test when using the domain module ( #2126 )
...
Fix a failure in `test/create-websocket-stream.test.js` if the domain
module is loaded (e.g. due to `NODE_OPTIONS` in environment).
The cause of the failure was that installing an `'uncaughtException'`
event handler on `process` causes the domain module to prepend its own
handler for the same event, which confused the test.
Fixes #2124
2023-03-09 21:24:34 +01:00
Luigi Pinca
8a8fc88430
[minor] Validate the payload length of the close frame sooner
...
Avoid unnecessary work if the payload length is 1.
2022-12-09 14:25:50 +01:00
Luigi Pinca
1cec17da06
[fix] Add the same event listener only once
...
Prevent `WebSocket.prototype.addEventListener()` from adding the same
event listener multiple times.
2022-11-06 19:30:09 +01:00
Luigi Pinca
9ab743aa70
[feature] Add support for objets with a handleEvent() method
...
Make `WebSocket.prototype.addEventListener()` support an event listener
specified as an object with a `handleEvent()` method.
Fixes #2092
2022-11-06 19:30:05 +01:00
Luigi Pinca
e628f2bdb6
[feature] Support Windows named pipes ( #2079 )
...
Document how to connect to a named pipe endpoint and the limitations.
Refs: https://github.com/websockets/ws/pull/1808
Refs: https://github.com/websockets/ws/pull/2075
2022-09-22 22:16:59 +02:00
Luigi Pinca
0da60366f3
[test] Remove leftover from test
...
Refs: https://github.com/websockets/ws/commit/2995349f
2022-09-21 12:05:53 +02:00
Luigi Pinca
2995349f5d
[minor] Simplify the ws+unix: URL form
...
Remove the two forward slashes after the scheme. The URL is parsed in
the same way and it is easier to grok.
2022-09-20 20:57:40 +02:00
Luigi Pinca
bc8bd34e41
[security] Fix same host check for ws+unix: redirects
...
Drop the `Authorization` and `Cookie` headers if the original request
for the opening handshake is sent to an IPC server and the client is
redirected to a TCP server (ws+unix: to ws: or wss:), and vice versa
(ws: or wss: to ws+unix).
Also drop the `Authorization` and `Cookie` headers if the original
request for the opening handshake is sent to an IPC server and the
client is redirected to another IPC server.
Refs: https://github.com/websockets/ws/commit/6946f5fe
2022-07-15 17:23:52 +02:00
Luigi Pinca
0ae302affd
[test] Fix nits
2022-07-15 09:17:41 +02:00
Luigi Pinca
5e4149ec6a
[test] Fix typo
2022-05-30 17:32:18 +02:00
Luigi Pinca
6e5a5ce341
[feature] Introduce the 'wsClientError' event ( #2046 )
...
Add the ability to inspect the invalid handshake requests and respond
to them with a custom HTTP response.
Closes #2045
2022-05-26 18:54:39 +02:00
Luigi Pinca
d68ba9e1aa
[security] Drop sensitive headers when following insecure redirects
...
Drop the `Authorization` and `Cookie` headers if the original request
for the opening handshake is sent over HTTPS and the client is
redirected to the same host over plain HTTP (wss: to ws:).
If an HTTPS server redirects to same host over plain HTTP, the problem
is on the server, but handling this condition is not hard and reduces
the risk of leaking credentials due to MITM issues.
Refs: https://github.com/websockets/ws/commit/6946f5fe
2022-05-26 18:54:34 +02:00
Luigi Pinca
8889e48018
[test] Increase code coverage
2022-05-21 07:46:20 +02:00
Luigi Pinca
fb658bdd11
[minor] Use consistent error messages
...
Make some server error messages consistent with the respective client
error messages.
2022-05-21 07:25:52 +02:00
Luigi Pinca
0fdcc0af78
[fix] Abort the handshake if the Upgrade header is invalid
...
Close the connection if the Upgrade header field in the HTTP response
contains a value that is not an ASCII case-insensitive match for the
value "websocket".
2022-05-21 07:14:20 +02:00