+54
-0
@@ -43,2 +43,6 @@ 'use strict'; | ||
| * client or server mode | ||
| * @param {Number} [options.maxBufferedChunks=0] The maximum number of | ||
| * buffered data chunks | ||
| * @param {Number} [options.maxFragments=0] The maximum number of message | ||
| * fragments | ||
| * @param {Number} [options.maxPayload=0] The maximum allowed message length | ||
@@ -58,2 +62,4 @@ * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or | ||
| this._isServer = !!options.isServer; | ||
| this._maxBufferedChunks = options.maxBufferedChunks | 0; | ||
| this._maxFragments = options.maxFragments | 0; | ||
| this._maxPayload = options.maxPayload | 0; | ||
@@ -94,2 +100,18 @@ this._skipUTF8Validation = !!options.skipUTF8Validation; | ||
| if ( | ||
| this._maxBufferedChunks > 0 && | ||
| this._buffers.length >= this._maxBufferedChunks | ||
| ) { | ||
| cb( | ||
| this.createError( | ||
| RangeError, | ||
| 'Too many buffered chunks', | ||
| false, | ||
| 1008, | ||
| 'WS_ERR_TOO_MANY_BUFFERED_PARTS' | ||
| ) | ||
| ); | ||
| return; | ||
| } | ||
| this._bufferedBytes += chunk.length; | ||
@@ -491,2 +513,18 @@ this._buffers.push(chunk); | ||
| if (data.length) { | ||
| if ( | ||
| this._maxFragments > 0 && | ||
| this._fragments.length >= this._maxFragments | ||
| ) { | ||
| const error = this.createError( | ||
| RangeError, | ||
| 'Too many message fragments', | ||
| false, | ||
| 1008, | ||
| 'WS_ERR_TOO_MANY_BUFFERED_PARTS' | ||
| ); | ||
| cb(error); | ||
| return; | ||
| } | ||
| // | ||
@@ -531,2 +569,18 @@ // This message is not compressed so its length is the sum of the payload | ||
| if ( | ||
| this._maxFragments > 0 && | ||
| this._fragments.length >= this._maxFragments | ||
| ) { | ||
| const error = this.createError( | ||
| RangeError, | ||
| 'Too many message fragments', | ||
| false, | ||
| 1008, | ||
| 'WS_ERR_TOO_MANY_BUFFERED_PARTS' | ||
| ); | ||
| cb(error); | ||
| return; | ||
| } | ||
| this._fragments.push(buf); | ||
@@ -533,0 +587,0 @@ } |
@@ -46,2 +46,6 @@ /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex$", "caughtErrors": "none" }] */ | ||
| * @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=104857600] The maximum allowed message | ||
@@ -69,2 +73,4 @@ * size | ||
| autoPong: true, | ||
| maxBufferedChunks: 1024 * 1024, | ||
| maxFragments: 128 * 1024, | ||
| maxPayload: 100 * 1024 * 1024, | ||
@@ -429,2 +435,4 @@ skipUTF8Validation: false, | ||
| allowSynchronousEvents: this.options.allowSynchronousEvents, | ||
| maxBufferedChunks: this.options.maxBufferedChunks, | ||
| maxFragments: this.options.maxFragments, | ||
| maxPayload: this.options.maxPayload, | ||
@@ -431,0 +439,0 @@ skipUTF8Validation: this.options.skipUTF8Validation |
+14
-0
@@ -204,2 +204,6 @@ /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex|Readable$", "caughtErrors": "none" }] */ | ||
| * masking key | ||
| * @param {Number} [options.maxBufferedChunks=0] The maximum number of | ||
| * buffered data chunks | ||
| * @param {Number} [options.maxFragments=0] The maximum number of message | ||
| * fragments | ||
| * @param {Number} [options.maxPayload=0] The maximum allowed message size | ||
@@ -216,2 +220,4 @@ * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or | ||
| isServer: this._isServer, | ||
| maxBufferedChunks: options.maxBufferedChunks, | ||
| maxFragments: options.maxFragments, | ||
| maxPayload: options.maxPayload, | ||
@@ -645,2 +651,6 @@ skipUTF8Validation: options.skipUTF8Validation | ||
| * handshake request | ||
| * @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=104857600] The maximum allowed message | ||
@@ -666,2 +676,4 @@ * size | ||
| protocolVersion: protocolVersions[1], | ||
| maxBufferedChunks: 1024 * 1024, | ||
| maxFragments: 128 * 1024, | ||
| maxPayload: 100 * 1024 * 1024, | ||
@@ -1024,2 +1036,4 @@ skipUTF8Validation: false, | ||
| generateMask: opts.generateMask, | ||
| maxBufferedChunks: opts.maxBufferedChunks, | ||
| maxFragments: opts.maxFragments, | ||
| maxPayload: opts.maxPayload, | ||
@@ -1026,0 +1040,0 @@ skipUTF8Validation: opts.skipUTF8Validation |
+1
-1
| { | ||
| "name": "ws", | ||
| "version": "8.20.1", | ||
| "version": "8.21.0", | ||
| "description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 2 instances in 1 package
151087
1.59%4347
1.66%3
-25%