🚀 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
5.2.4
to
5.2.5
+37
-1
lib/receiver.js

@@ -29,4 +29,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();

@@ -37,2 +47,4 @@

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

@@ -69,2 +81,9 @@

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

@@ -341,2 +360,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);
}
//

@@ -372,2 +399,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);

@@ -374,0 +410,0 @@ }

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

* @param {(Boolean|Object)} options.perMessageDeflate Enable/disable permessage-deflate
* @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

@@ -40,2 +44,4 @@ * @param {Function} callback A listener for the `listening` event

options = Object.assign({
maxBufferedChunks: 1024 * 1024,
maxFragments: 128 * 1024,
maxPayload: 100 * 1024 * 1024,

@@ -292,3 +298,9 @@ perMessageDeflate: false,

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

@@ -295,0 +307,0 @@ if (this.clients) {

@@ -117,9 +117,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
);

@@ -415,2 +421,6 @@

* @param {String} options.origin Value of the `Origin` or `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
* @private

@@ -421,2 +431,4 @@ */

protocolVersion: protocolVersions[1],
maxBufferedChunks: 1024 * 1024,
maxFragments: 128 * 1024,
perMessageDeflate: true

@@ -605,3 +617,9 @@ }, options, {

this.setSocket(socket, head, 0);
this.setSocket(
socket,
head,
0,
options.maxBufferedChunks,
options.maxFragments
);
});

@@ -608,0 +626,0 @@ }

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

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