@depup/ws 8.20.0-depup.0 → 8.21.3-depup.0
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 +2 -2
- package/changes.json +1 -1
- package/lib/permessage-deflate.js +3 -1
- package/lib/receiver.js +37 -0
- package/lib/sender.js +6 -1
- package/lib/websocket-server.js +8 -0
- package/lib/websocket.js +14 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ npm install @depup/ws
|
|
|
13
13
|
|
|
14
14
|
| Field | Value |
|
|
15
15
|
|-------|-------|
|
|
16
|
-
| Original | [ws](https://www.npmjs.com/package/ws) @ 8.
|
|
17
|
-
| Processed | 2026-
|
|
16
|
+
| Original | [ws](https://www.npmjs.com/package/ws) @ 8.21.3 |
|
|
17
|
+
| Processed | 2026-08-09 |
|
|
18
18
|
| Smoke test | passed |
|
|
19
19
|
| Deps updated | 0 |
|
|
20
20
|
|
package/changes.json
CHANGED
|
@@ -167,7 +167,9 @@ class PerMessageDeflate {
|
|
|
167
167
|
(typeof opts.serverMaxWindowBits === 'number' &&
|
|
168
168
|
opts.serverMaxWindowBits > params.server_max_window_bits))) ||
|
|
169
169
|
(typeof opts.clientMaxWindowBits === 'number' &&
|
|
170
|
-
|
|
170
|
+
(typeof params.client_max_window_bits === 'number'
|
|
171
|
+
? opts.clientMaxWindowBits > params.client_max_window_bits
|
|
172
|
+
: !params.client_max_window_bits))
|
|
171
173
|
) {
|
|
172
174
|
return false;
|
|
173
175
|
}
|
package/lib/receiver.js
CHANGED
|
@@ -40,6 +40,10 @@ class Receiver extends Writable {
|
|
|
40
40
|
* extensions
|
|
41
41
|
* @param {Boolean} [options.isServer=false] Specifies whether to operate in
|
|
42
42
|
* client or server mode
|
|
43
|
+
* @param {Number} [options.maxBufferedChunks=0] The maximum number of
|
|
44
|
+
* buffered data chunks
|
|
45
|
+
* @param {Number} [options.maxFragments=0] The maximum number of message
|
|
46
|
+
* fragments
|
|
43
47
|
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
44
48
|
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
45
49
|
* not to skip UTF-8 validation for text and close messages
|
|
@@ -54,6 +58,8 @@ class Receiver extends Writable {
|
|
|
54
58
|
this._binaryType = options.binaryType || BINARY_TYPES[0];
|
|
55
59
|
this._extensions = options.extensions || {};
|
|
56
60
|
this._isServer = !!options.isServer;
|
|
61
|
+
this._maxBufferedChunks = options.maxBufferedChunks | 0;
|
|
62
|
+
this._maxFragments = options.maxFragments | 0;
|
|
57
63
|
this._maxPayload = options.maxPayload | 0;
|
|
58
64
|
this._skipUTF8Validation = !!options.skipUTF8Validation;
|
|
59
65
|
this[kWebSocket] = undefined;
|
|
@@ -71,6 +77,7 @@ class Receiver extends Writable {
|
|
|
71
77
|
|
|
72
78
|
this._totalPayloadLength = 0;
|
|
73
79
|
this._messageLength = 0;
|
|
80
|
+
this._numFragments = 0;
|
|
74
81
|
this._fragments = [];
|
|
75
82
|
|
|
76
83
|
this._errored = false;
|
|
@@ -89,6 +96,22 @@ class Receiver extends Writable {
|
|
|
89
96
|
_write(chunk, encoding, cb) {
|
|
90
97
|
if (this._opcode === 0x08 && this._state == GET_INFO) return cb();
|
|
91
98
|
|
|
99
|
+
if (
|
|
100
|
+
this._maxBufferedChunks > 0 &&
|
|
101
|
+
this._buffers.length >= this._maxBufferedChunks
|
|
102
|
+
) {
|
|
103
|
+
cb(
|
|
104
|
+
this.createError(
|
|
105
|
+
RangeError,
|
|
106
|
+
'Too many buffered chunks',
|
|
107
|
+
false,
|
|
108
|
+
1008,
|
|
109
|
+
'WS_ERR_TOO_MANY_BUFFERED_PARTS'
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
92
115
|
this._bufferedBytes += chunk.length;
|
|
93
116
|
this._buffers.push(chunk);
|
|
94
117
|
this.startLoop(cb);
|
|
@@ -478,6 +501,19 @@ class Receiver extends Writable {
|
|
|
478
501
|
return;
|
|
479
502
|
}
|
|
480
503
|
|
|
504
|
+
if (this._maxFragments > 0 && ++this._numFragments > this._maxFragments) {
|
|
505
|
+
const error = this.createError(
|
|
506
|
+
RangeError,
|
|
507
|
+
'Too many message fragments',
|
|
508
|
+
false,
|
|
509
|
+
1008,
|
|
510
|
+
'WS_ERR_TOO_MANY_BUFFERED_PARTS'
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
cb(error);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
|
|
481
517
|
if (this._compressed) {
|
|
482
518
|
this._state = INFLATING;
|
|
483
519
|
this.decompress(data, cb);
|
|
@@ -550,6 +586,7 @@ class Receiver extends Writable {
|
|
|
550
586
|
this._totalPayloadLength = 0;
|
|
551
587
|
this._messageLength = 0;
|
|
552
588
|
this._fragmented = 0;
|
|
589
|
+
this._numFragments = 0;
|
|
553
590
|
this._fragments = [];
|
|
554
591
|
|
|
555
592
|
if (this._opcode === 2) {
|
package/lib/sender.js
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
const { Duplex } = require('stream');
|
|
6
6
|
const { randomFillSync } = require('crypto');
|
|
7
|
+
const {
|
|
8
|
+
types: { isUint8Array }
|
|
9
|
+
} = require('util');
|
|
7
10
|
|
|
8
11
|
const PerMessageDeflate = require('./permessage-deflate');
|
|
9
12
|
const { EMPTY_BUFFER, kWebSocket, NOOP } = require('./constants');
|
|
@@ -200,8 +203,10 @@ class Sender {
|
|
|
200
203
|
|
|
201
204
|
if (typeof data === 'string') {
|
|
202
205
|
buf.write(data, 2);
|
|
203
|
-
} else {
|
|
206
|
+
} else if (isUint8Array(data)) {
|
|
204
207
|
buf.set(data, 2);
|
|
208
|
+
} else {
|
|
209
|
+
throw new TypeError('Second argument must be a string or a Uint8Array');
|
|
205
210
|
}
|
|
206
211
|
}
|
|
207
212
|
|
package/lib/websocket-server.js
CHANGED
|
@@ -43,6 +43,10 @@ class WebSocketServer extends EventEmitter {
|
|
|
43
43
|
* called
|
|
44
44
|
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
|
45
45
|
* @param {String} [options.host] The hostname where to bind the server
|
|
46
|
+
* @param {Number} [options.maxBufferedChunks=262144] The maximum number of
|
|
47
|
+
* buffered data chunks
|
|
48
|
+
* @param {Number} [options.maxFragments=16384] The maximum number of message
|
|
49
|
+
* fragments
|
|
46
50
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
47
51
|
* size
|
|
48
52
|
* @param {Boolean} [options.noServer=false] Enable no server mode
|
|
@@ -65,6 +69,8 @@ class WebSocketServer extends EventEmitter {
|
|
|
65
69
|
options = {
|
|
66
70
|
allowSynchronousEvents: true,
|
|
67
71
|
autoPong: true,
|
|
72
|
+
maxBufferedChunks: 256 * 1024,
|
|
73
|
+
maxFragments: 16 * 1024,
|
|
68
74
|
maxPayload: 100 * 1024 * 1024,
|
|
69
75
|
skipUTF8Validation: false,
|
|
70
76
|
perMessageDeflate: false,
|
|
@@ -424,6 +430,8 @@ class WebSocketServer extends EventEmitter {
|
|
|
424
430
|
|
|
425
431
|
ws.setSocket(socket, head, {
|
|
426
432
|
allowSynchronousEvents: this.options.allowSynchronousEvents,
|
|
433
|
+
maxBufferedChunks: this.options.maxBufferedChunks,
|
|
434
|
+
maxFragments: this.options.maxFragments,
|
|
427
435
|
maxPayload: this.options.maxPayload,
|
|
428
436
|
skipUTF8Validation: this.options.skipUTF8Validation
|
|
429
437
|
});
|
package/lib/websocket.js
CHANGED
|
@@ -201,6 +201,10 @@ class WebSocket extends EventEmitter {
|
|
|
201
201
|
* multiple times in the same tick
|
|
202
202
|
* @param {Function} [options.generateMask] The function used to generate the
|
|
203
203
|
* masking key
|
|
204
|
+
* @param {Number} [options.maxBufferedChunks=0] The maximum number of
|
|
205
|
+
* buffered data chunks
|
|
206
|
+
* @param {Number} [options.maxFragments=0] The maximum number of message
|
|
207
|
+
* fragments
|
|
204
208
|
* @param {Number} [options.maxPayload=0] The maximum allowed message size
|
|
205
209
|
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
206
210
|
* not to skip UTF-8 validation for text and close messages
|
|
@@ -212,6 +216,8 @@ class WebSocket extends EventEmitter {
|
|
|
212
216
|
binaryType: this.binaryType,
|
|
213
217
|
extensions: this._extensions,
|
|
214
218
|
isServer: this._isServer,
|
|
219
|
+
maxBufferedChunks: options.maxBufferedChunks,
|
|
220
|
+
maxFragments: options.maxFragments,
|
|
215
221
|
maxPayload: options.maxPayload,
|
|
216
222
|
skipUTF8Validation: options.skipUTF8Validation
|
|
217
223
|
});
|
|
@@ -640,6 +646,10 @@ module.exports = WebSocket;
|
|
|
640
646
|
* masking key
|
|
641
647
|
* @param {Number} [options.handshakeTimeout] Timeout in milliseconds for the
|
|
642
648
|
* handshake request
|
|
649
|
+
* @param {Number} [options.maxBufferedChunks=262144] The maximum number of
|
|
650
|
+
* buffered data chunks
|
|
651
|
+
* @param {Number} [options.maxFragments=16384] The maximum number of message
|
|
652
|
+
* fragments
|
|
643
653
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
644
654
|
* size
|
|
645
655
|
* @param {Number} [options.maxRedirects=10] The maximum number of redirects
|
|
@@ -660,6 +670,8 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
660
670
|
autoPong: true,
|
|
661
671
|
closeTimeout: CLOSE_TIMEOUT,
|
|
662
672
|
protocolVersion: protocolVersions[1],
|
|
673
|
+
maxBufferedChunks: 256 * 1024,
|
|
674
|
+
maxFragments: 16 * 1024,
|
|
663
675
|
maxPayload: 100 * 1024 * 1024,
|
|
664
676
|
skipUTF8Validation: false,
|
|
665
677
|
perMessageDeflate: true,
|
|
@@ -1017,6 +1029,8 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
1017
1029
|
websocket.setSocket(socket, head, {
|
|
1018
1030
|
allowSynchronousEvents: opts.allowSynchronousEvents,
|
|
1019
1031
|
generateMask: opts.generateMask,
|
|
1032
|
+
maxBufferedChunks: opts.maxBufferedChunks,
|
|
1033
|
+
maxFragments: opts.maxFragments,
|
|
1020
1034
|
maxPayload: opts.maxPayload,
|
|
1021
1035
|
skipUTF8Validation: opts.skipUTF8Validation
|
|
1022
1036
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depup/ws",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.21.3-depup.0",
|
|
4
4
|
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js (with updated dependencies)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ws",
|
|
@@ -75,12 +75,16 @@
|
|
|
75
75
|
"prettier": "^3.0.0",
|
|
76
76
|
"utf-8-validate": "^6.0.0"
|
|
77
77
|
},
|
|
78
|
+
"allowScripts": {
|
|
79
|
+
"bufferutil": true,
|
|
80
|
+
"utf-8-validate": true
|
|
81
|
+
},
|
|
78
82
|
"depup": {
|
|
79
83
|
"changes": {},
|
|
80
84
|
"depsUpdated": 0,
|
|
81
85
|
"originalPackage": "ws",
|
|
82
|
-
"originalVersion": "8.
|
|
83
|
-
"processedAt": "2026-
|
|
86
|
+
"originalVersion": "8.21.3",
|
|
87
|
+
"processedAt": "2026-08-09T00:37:59.600Z",
|
|
84
88
|
"smokeTest": "passed"
|
|
85
89
|
}
|
|
86
90
|
}
|