Socket
Socket
Sign inDemoInstall

sc-ws

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sc-ws - npm Package Compare versions

Comparing version 0.8.0 to 1.0.1

SECURITY.md

2

lib/browser.js

@@ -29,3 +29,3 @@

* @param {Array} protocols (optional)
* @param {Object) opts (optional)
* @param {Object} opts (optional)
* @api public

@@ -32,0 +32,0 @@ */

@@ -72,2 +72,27 @@

/**
* Releases all resources used by the extension
*
* @api public
*/
PerMessageDeflate.prototype.cleanup = function() {
if (this._inflate) {
if (this._inflate.writeInProgress) {
this._inflate.pendingClose = true;
} else {
if (this._inflate.close) this._inflate.close();
this._inflate = null;
}
}
if (this._deflate) {
if (this._deflate.writeInProgress) {
this._deflate.pendingClose = true;
} else {
if (this._deflate.close) this._deflate.close();
this._deflate = null;
}
}
};
/**
* Accept extension offer from client

@@ -211,2 +236,3 @@ *

}
this._inflate.writeInProgress = true;

@@ -236,5 +262,8 @@ var self = this;

function cleanup() {
if (!self._inflate) return;
self._inflate.removeListener('error', onError);
self._inflate.removeListener('data', onData);
if (fin && self.params[endpoint + '_no_context_takeover']) {
self._inflate.writeInProgress = false;
if ((fin && self.params[endpoint + '_no_context_takeover']) || self._inflate.pendingClose) {
if (self._inflate.close) self._inflate.close();
self._inflate = null;

@@ -262,2 +291,3 @@ }

}
this._deflate.writeInProgress = true;

@@ -288,5 +318,8 @@ var self = this;

function cleanup() {
if (!self._deflate) return;
self._deflate.removeListener('error', onError);
self._deflate.removeListener('data', onData);
if (fin && self.params[endpoint + '_no_context_takeover']) {
self._deflate.writeInProgress = false;
if ((fin && self.params[endpoint + '_no_context_takeover']) || self._deflate.pendingClose) {
if (self._deflate.close) self._deflate.close();
self._deflate = null;

@@ -293,0 +326,0 @@ }

@@ -29,3 +29,3 @@ /*!

return fragmentedPoolPrevUsed = fragmentedPoolPrevUsed >= 0 ?
(fragmentedPoolPrevUsed + db.used) / 2 :
Math.ceil((fragmentedPoolPrevUsed + db.used) / 2) :
db.used;

@@ -40,3 +40,3 @@ });

return unfragmentedPoolPrevUsed = unfragmentedPoolPrevUsed >= 0 ?
(unfragmentedPoolPrevUsed + db.used) / 2 :
Math.ceil((unfragmentedPoolPrevUsed + db.used) / 2) :
db.used;

@@ -250,3 +250,3 @@ });

if (!this.state.fragmentedOperation) this.unfragmentedBufferPool.reset(true);
else if (this.state.lastFragment) this.fragmentedBufferPool.reset(false);
else if (this.state.lastFragment) this.fragmentedBufferPool.reset(true);
this.expectOffset = 0;

@@ -253,0 +253,0 @@ this.expectBuffer = null;

@@ -158,2 +158,10 @@ /*!

} else {
//
// If people want to send a number, this would allocate the number in
// bytes as memory size instead of storing the number as buffer value. So
// we need to transform it to string in order to prevent possible
// vulnerabilities / memory attacks.
//
if (typeof data === 'number') data = data.toString();
data = new Buffer(data);

@@ -160,0 +168,0 @@ }

@@ -48,3 +48,3 @@ 'use strict';

if (this instanceof WebSocket === false) {
throw new TypeError("Classes can't be function-called");
return new WebSocket(address, protocols, options);
}

@@ -922,3 +922,3 @@

if (emitClose) {
// If the connection was closed abnormally (with an error), or if
// If the connection was closed abnormally (with an error), or if
// the close control frame was not received then the close code

@@ -958,2 +958,8 @@ // must default to 1006.

if (this.extensions[PerMessageDeflate.extensionName]) {
this.extensions[PerMessageDeflate.extensionName].cleanup();
}
this.extensions = null;
this.removeAllListeners();

@@ -960,0 +966,0 @@ this.on('error', function onerror() {}); // catch all errors after this

@@ -24,3 +24,3 @@ /*!

if (this instanceof WebSocketServer === false) {
throw new TypeError("Classes can't be function-called");
return new WebSocketServer(options, callback);
}

@@ -111,3 +111,3 @@

WebSocketServer.prototype.close = function() {
WebSocketServer.prototype.close = function(callback) {
// terminate all associated clients

@@ -141,3 +141,6 @@ var error = null;

}
if (error) throw error;
if(callback)
callback(error);
else if(error)
throw error;
}

@@ -144,0 +147,0 @@

@@ -5,4 +5,5 @@ {

"description": "simple to use, blazing fast and thoroughly tested websocket client, server and console for node.js, up-to-date against RFC-6455",
"version": "0.8.0",
"version": "1.0.1",
"license": "MIT",
"main": "index.js",
"keywords": [

@@ -28,13 +29,11 @@ "Hixie",

},
"optionalDependencies": {
"bufferutil": "1.2.x",
"utf-8-validate": "1.2.x"
},
"devDependencies": {
"ansi": "0.3.x",
"benchmark": "0.3.x",
"bufferutil": "1.2.x",
"expect.js": "0.3.x",
"mocha": "2.2.x",
"should": "4.3.x",
"tinycolor": "0.0.x"
"mocha": "2.3.x",
"should": "8.0.x",
"tinycolor": "0.0.x",
"utf-8-validate": "1.2.x"
},

@@ -41,0 +40,0 @@ "browser": "./lib/browser.js",

@@ -25,2 +25,19 @@ # ws: a node.js websocket library

### Opt-in for performance
There are 2 optional modules that can be installed along side with the `ws`
module. These modules are binary addons which improve certain operations, but as
they are binary addons they require compilation which can fail if no c++
compiler is installed on the host system.
- `npm install --save bufferutil`: Improves internal buffer operations which
allows for faster processing of masked WebSocket frames and general buffer
operations.
- `npm install --save utf-8-validate`: The specification requires validation of
invalid UTF-8 chars, some of these validations could not be done in JavaScript
hence the need for a binary addon. In most cases you will already be
validating the input that you receive for security purposes leading to double
validation. But if you want to be 100% spec conform and fast validation of UTF-8
then this module is a must.
### Sending and receiving text data

@@ -27,0 +44,0 @@

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