🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

ws

Package Overview
Dependencies
Maintainers
4
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ws - npm Package Compare versions

Comparing version
6.2.3
to
6.2.4
+37
-1
lib/receiver.js

@@ -34,4 +34,14 @@ 'use strict';

* @param {Number} maxPayload The maximum allowed message length
* @param {Number} [maxBufferedChunks=0] The maximum number of
* buffered data chunks
* @param {Number} [maxFragments=0] The maximum number of message
* fragments
*/
constructor(binaryType, extensions, maxPayload) {
constructor(
binaryType,
extensions,
maxPayload,
maxBufferedChunks,
maxFragments
) {
super();

@@ -42,2 +52,4 @@

this._extensions = extensions || {};
this._maxBufferedChunks = maxBufferedChunks | 0;
this._maxFragments = maxFragments | 0;
this._maxPayload = maxPayload | 0;

@@ -74,2 +86,9 @@

if (
this._maxBufferedChunks > 0 &&
this._buffers.length >= this._maxBufferedChunks
) {
return cb(error(RangeError, 'Too many buffered chunks', false, 1008));
}
this._bufferedBytes += chunk.length;

@@ -347,2 +366,10 @@ this._buffers.push(chunk);

if (data.length) {
if (
this._maxFragments > 0 &&
this._fragments.length >= this._maxFragments
) {
this._loop = false;
return error(RangeError, 'Too many message fragments', false, 1008);
}
//

@@ -380,2 +407,11 @@ // This message is not compressed so its lenght is the sum of the payload

if (
this._maxFragments > 0 &&
this._fragments.length >= this._maxFragments
) {
return cb(
error(RangeError, 'Too many message fragments', false, 1008)
);
}
this._fragments.push(buf);

@@ -382,0 +418,0 @@ }

@@ -30,2 +30,6 @@ 'use strict';

* @param {String} options.host The hostname where to bind the server
* @param {Number} [options.maxBufferedChunks=1048576] The maximum number of
* buffered data chunks
* @param {Number} [options.maxFragments=131072] The maximum number of message
* fragments
* @param {Number} options.maxPayload The maximum allowed message size

@@ -46,2 +50,4 @@ * @param {Boolean} options.noServer Enable no server mode

{
maxBufferedChunks: 1024 * 1024,
maxFragments: 128 * 1024,
maxPayload: 100 * 1024 * 1024,

@@ -321,3 +327,9 @@ perMessageDeflate: false,

ws.setSocket(socket, head, this.options.maxPayload);
ws.setSocket(
socket,
head,
this.options.maxPayload,
this.options.maxBufferedChunks,
this.options.maxFragments
);

@@ -324,0 +336,0 @@ if (this.clients) {

@@ -136,9 +136,15 @@ 'use strict';

* @param {Number} maxPayload The maximum allowed message size
* @param {Number} [maxBufferedChunks=0] The maximum number of
* buffered data chunks
* @param {Number} [maxFragments=0] The maximum number of message
* fragments
* @private
*/
setSocket(socket, head, maxPayload) {
setSocket(socket, head, maxPayload, maxBufferedChunks, maxFragments) {
const receiver = new Receiver(
this._binaryType,
this._extensions,
maxPayload
maxPayload,
maxBufferedChunks,
maxFragments
);

@@ -440,2 +446,6 @@

* `Sec-WebSocket-Origin` header
* @param {Number} [options.maxBufferedChunks=1048576] The maximum number of
* buffered data chunks
* @param {Number} [options.maxFragments=131072] The maximum number of message
* fragments
* @param {Number} options.maxPayload The maximum allowed message size

@@ -450,2 +460,4 @@ * @param {Boolean} options.followRedirects Whether or not to follow redirects

protocolVersion: protocolVersions[1],
maxBufferedChunks: 1024 * 1024,
maxFragments: 128 * 1024,
maxPayload: 100 * 1024 * 1024,

@@ -668,3 +680,9 @@ perMessageDeflate: true,

websocket.setSocket(socket, head, opts.maxPayload);
websocket.setSocket(
socket,
head,
opts.maxPayload,
opts.maxBufferedChunks,
opts.maxFragments
);
});

@@ -671,0 +689,0 @@ }

+1
-1
{
"name": "ws",
"version": "6.2.3",
"version": "6.2.4",
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",

@@ -5,0 +5,0 @@ "keywords": [