Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ws

Package Overview
Dependencies
Maintainers
4
Versions
169
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 8.0.0 to 8.1.0

31

lib/receiver.js

@@ -31,16 +31,21 @@ 'use strict';

*
* @param {String} [binaryType=nodebuffer] The type for binary data
* @param {Object} [extensions] An object containing the negotiated extensions
* @param {Boolean} [isServer=false] Specifies whether to operate in client or
* server mode
* @param {Number} [maxPayload=0] The maximum allowed message length
* @param {Object} [options] Options object
* @param {String} [options.binaryType=nodebuffer] The type for binary data
* @param {Object} [options.extensions] An object containing the negotiated
* extensions
* @param {Boolean} [options.isServer=false] Specifies whether to operate in
* client or server mode
* @param {Number} [options.maxPayload=0] The maximum allowed message length
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
* not to skip UTF-8 validation for text and close messages
*/
constructor(binaryType, extensions, isServer, maxPayload) {
constructor(options = {}) {
super();
this._binaryType = binaryType || BINARY_TYPES[0];
this._binaryType = options.binaryType || BINARY_TYPES[0];
this._extensions = options.extensions || {};
this._isServer = !!options.isServer;
this._maxPayload = options.maxPayload | 0;
this._skipUTF8Validation = !!options.skipUTF8Validation;
this[kWebSocket] = undefined;
this._extensions = extensions || {};
this._isServer = !!isServer;
this._maxPayload = maxPayload | 0;

@@ -429,3 +434,3 @@ this._bufferedBytes = 0;

//
// This message is not compressed so its lenght is the sum of the payload
// This message is not compressed so its length is the sum of the payload
// length of all fragments.

@@ -508,3 +513,3 @@ //

if (!isValidUTF8(buf)) {
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
this._loop = false;

@@ -564,3 +569,3 @@ return error(

if (!isValidUTF8(buf)) {
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
return error(

@@ -567,0 +572,0 @@ Error,

@@ -49,2 +49,4 @@ /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^net|tls|https$" }] */

* server to use
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
* not to skip UTF-8 validation for text and close messages
* @param {Function} [options.verifyClient] A hook to reject connections

@@ -58,2 +60,3 @@ * @param {Function} [callback] A listener for the `listening` event

maxPayload: 100 * 1024 * 1024,
skipUTF8Validation: false,
perMessageDeflate: false,

@@ -391,3 +394,6 @@ handleProtocols: null,

ws.setSocket(socket, head, this.options.maxPayload);
ws.setSocket(socket, head, {
maxPayload: this.options.maxPayload,
skipUTF8Validation: this.options.skipUTF8Validation
});

@@ -394,0 +400,0 @@ if (this.clients) {

@@ -183,12 +183,16 @@ 'use strict';

* @param {Buffer} head The first packet of the upgraded stream
* @param {Number} [maxPayload=0] The maximum allowed message size
* @param {Object} options Options object
* @param {Number} [options.maxPayload=0] The maximum allowed message size
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
* not to skip UTF-8 validation for text and close messages
* @private
*/
setSocket(socket, head, maxPayload) {
const receiver = new Receiver(
this.binaryType,
this._extensions,
this._isServer,
maxPayload
);
setSocket(socket, head, options) {
const receiver = new Receiver({
binaryType: this.binaryType,
extensions: this._extensions,
isServer: this._isServer,
maxPayload: options.maxPayload,
skipUTF8Validation: options.skipUTF8Validation
});

@@ -579,2 +583,4 @@ this._sender = new Sender(socket, this._extensions);

* allowed
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
* not to skip UTF-8 validation for text and close messages
* @private

@@ -586,2 +592,3 @@ */

maxPayload: 100 * 1024 * 1024,
skipUTF8Validation: false,
perMessageDeflate: true,

@@ -777,3 +784,3 @@ followRedirects: false,

if (serverProt) {
if (serverProt !== undefined) {
if (!protocolSet.size) {

@@ -839,3 +846,6 @@ protError = 'Server sent a subprotocol but none was requested';

websocket.setSocket(socket, head, opts.maxPayload);
websocket.setSocket(socket, head, {
maxPayload: opts.maxPayload,
skipUTF8Validation: opts.skipUTF8Validation
});
});

@@ -1039,2 +1049,3 @@ }

this.removeListener('close', socketOnClose);
this.removeListener('data', socketOnData);
this.removeListener('end', socketOnEnd);

@@ -1044,2 +1055,4 @@

let chunk;
//

@@ -1052,9 +1065,15 @@ // The close frame might not have been received or the `'end'` event emitted,

// will return `null`. If instead, the socket is paused, any possible buffered
// data will be read as a single chunk and emitted synchronously in a single
// `'data'` event.
// data will be read as a single chunk.
//
websocket._socket.read();
if (
!this._readableState.endEmitted &&
!websocket._closeFrameReceived &&
!websocket._receiver._writableState.errorEmitted &&
(chunk = websocket._socket.read()) !== null
) {
websocket._receiver.write(chunk);
}
websocket._receiver.end();
this.removeListener('data', socketOnData);
this[kWebSocket] = undefined;

@@ -1061,0 +1080,0 @@

{
"name": "ws",
"version": "8.0.0",
"version": "8.1.0",
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc