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

websocket

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

websocket - npm Package Compare versions

Comparing version 1.0.26 to 1.0.27

7

CHANGELOG.md
Changelog
=========
Version 1.0.27
--------------
*Released 2018-09-19*
* Allowing additional request `headers` to be specified in the `tlsOptions` config parameter for WebSocketClient. See pull request #323
* Resolving deprecation warnings relating to usage of `new Buffer`
Version 1.0.26

@@ -5,0 +12,0 @@ --------------

10

lib/utils.js

@@ -13,6 +13,12 @@ var noop = exports.noop = function(){};

exports.bufferAllocUnsafe = Buffer.allocUnsafe ?
Buffer.allocUnsafe :
function oldBufferAllocUnsafe(size) { return new Buffer(size); };
exports.bufferFromString = Buffer.from ?
Buffer.from :
function oldBufferFromString(string, encoding) {
return new Buffer(string, encoding);
};
exports.BufferingLogger = function createBufferingLogger(identifier, uniqueID) {

@@ -19,0 +25,0 @@ var logFunction = require('debug')(identifier);

27

lib/WebSocketClient.js

@@ -26,2 +26,3 @@ /************************************************************************

var WebSocketConnection = require('./WebSocketConnection');
var bufferAllocUnsafe = utils.bufferAllocUnsafe;

@@ -35,2 +36,4 @@ var protocolSeparators = [

var excludedTlsOptions = ['hostname','port','method','path','headers'];
function WebSocketClient(config) {

@@ -119,2 +122,3 @@ // Superclass Constructor

var self = this;
if (typeof(protocols) === 'string') {

@@ -169,3 +173,3 @@ if (protocols.length > 0) {

var nonce = new Buffer(16);
var nonce = bufferAllocUnsafe(16);
for (var i=0; i < 16; i++) {

@@ -182,3 +186,11 @@ nonce[i] = Math.round(Math.random()*0xFF);

var reqHeaders = headers || {};
var reqHeaders = {};
if (this.secure && this.config.tlsOptions.hasOwnProperty('headers')) {
// Allow for additional headers to be provided when connecting via HTTPS
extend(reqHeaders, this.config.tlsOptions.headers);
}
if (headers) {
// Explicitly provided headers take priority over any from tlsOptions
extend(reqHeaders, headers);
}
extend(reqHeaders, {

@@ -239,7 +251,8 @@ 'Upgrade': 'websocket',

if (this.secure) {
for (var key in self.config.tlsOptions) {
if (self.config.tlsOptions.hasOwnProperty(key)) {
requestOptions[key] = self.config.tlsOptions[key];
}
}
var tlsOptions = this.config.tlsOptions;
for (var key in tlsOptions) {
if (tlsOptions.hasOwnProperty(key) && excludedTlsOptions.indexOf(key) === -1) {
requestOptions[key] = tlsOptions[key];
}
}
}

@@ -246,0 +259,0 @@

@@ -23,2 +23,4 @@ /************************************************************************

var Validation = require('./Validation').Validation;
var bufferAllocUnsafe = utils.bufferAllocUnsafe;
var bufferFromString = utils.bufferFromString;

@@ -77,4 +79,4 @@ // Connected, fully-open, ready to send and receive frames

// frame.
this.maskBytes = new Buffer(4);
this.frameHeader = new Buffer(10);
this.maskBytes = bufferAllocUnsafe(4);
this.frameHeader = bufferAllocUnsafe(10);

@@ -590,3 +592,3 @@ // the BufferList will handle the data streaming in

var bytesCopied = 0;
var binaryPayload = new Buffer(this.fragmentationSize);
var binaryPayload = bufferAllocUnsafe(this.fragmentationSize);
var opcode = this.frameQueue[0].opcode;

@@ -731,3 +733,3 @@ this.frameQueue.forEach(function (currentFrame) {

WebSocketConnection.prototype.sendUTF = function(data, cb) {
data = new Buffer(data.toString(), 'utf8');
data = bufferFromString(data.toString(), 'utf8');
this._debug('sendUTF: %d bytes', data.length);

@@ -758,3 +760,3 @@ var frame = new WebSocketFrame(this.maskBytes, this.frameHeader, this.config);

if (!Buffer.isBuffer(data)) {
data = new Buffer(data.toString(), 'utf8');
data = bufferFromString(data.toString(), 'utf8');
}

@@ -852,3 +854,3 @@ if (data.length > 125) {

if (typeof(description) === 'string') {
frame.binaryPayload = new Buffer(description, 'utf8');
frame.binaryPayload = bufferFromString(description, 'utf8');
}

@@ -855,0 +857,0 @@

@@ -18,2 +18,3 @@ /************************************************************************

var bufferUtil = require('./BufferUtil').BufferUtil;
var bufferAllocUnsafe = require('./utils').bufferAllocUnsafe;

@@ -134,3 +135,3 @@ const DECODE_HEADER = 1;

if (this.length === 0) {
this.binaryPayload = new Buffer(0);
this.binaryPayload = bufferAllocUnsafe(0);
this.parseState = COMPLETE;

@@ -150,3 +151,3 @@ return true;

// Invalid length for a close frame. Must be zero or at least two.
this.binaryPayload = new Buffer(0);
this.binaryPayload = bufferAllocUnsafe(0);
this.invalidCloseFrameLength = true;

@@ -209,3 +210,3 @@ }

}
data = new Buffer(this.length);
data = bufferAllocUnsafe(this.length);
data.writeUInt16BE(this.closeStatus, 0);

@@ -239,3 +240,3 @@ if (this.length > 2) {

var output = new Buffer(this.length + headerLength + (this.mask ? 4 : 0));
var output = bufferAllocUnsafe(this.length + headerLength + (this.mask ? 4 : 0));

@@ -242,0 +243,0 @@ // write the frame header

@@ -16,7 +16,7 @@ {

],
"author": "Brian McKelvey <brian@worlize.com> (https://www.worlize.com/)",
"author": "Brian McKelvey <theturtle32@gmail.com> (https://github.com/theturtle32)",
"contributors": [
"Iñaki Baz Castillo <ibc@aliax.net> (http://dev.sipdoc.net)"
],
"version": "1.0.26",
"version": "1.0.27",
"repository": {

@@ -33,3 +33,3 @@ "type": "git",

"nan": "^2.3.3",
"typedarray-to-buffer": "^3.1.2",
"typedarray-to-buffer": "^3.1.5",
"yaeti": "^0.0.6"

@@ -44,3 +44,3 @@ },

"jshint": "^2.0.0",
"tape": "^4.0.1"
"tape": "^4.9.1"
},

@@ -47,0 +47,0 @@ "config": {

@@ -30,5 +30,6 @@ WebSocket Client & Server Implementation for Node

***Current Version: 1.0.26*** — Released 2018-04-27
***Current Version: 1.0.27*** — Released 2018-09-19
* No longer using the deprecated `noAssert` parameter for functions reading and writing binary numeric data. (Thanks, [@BridgeAR](https://github.com/BridgeAR))
* Allowing additional request `headers` to be specified in the `tlsOptions` config parameter for WebSocketClient. See pull request #323
* Resolving deprecation warnings relating to usage of `new Buffer`

@@ -35,0 +36,0 @@ [View the full changelog](CHANGELOG.md)

@@ -9,2 +9,3 @@ // This file was copied from https://github.com/substack/node-bufferlist

var EventEmitter = require('events').EventEmitter;
var bufferAllocUnsafe = require('../lib/utils').bufferAllocUnsafe;

@@ -25,5 +26,2 @@ module.exports = BufferList;

// constructor to use for Buffer-esque operations
self.construct = opts.construct || Buffer;
var head = { next : null, buffer : null };

@@ -73,3 +71,3 @@ var last = { next : null, buffer : null };

self.forEach = function (fn) {
if (!head.buffer) return new self.construct(0);
if (!head.buffer) return bufferAllocUnsafe(0);

@@ -93,7 +91,7 @@ if (head.buffer.length - offset <= 0) return self;

self.join = function (start, end) {
if (!head.buffer) return new self.construct(0);
if (!head.buffer) return bufferAllocUnsafe(0);
if (start == undefined) start = 0;
if (end == undefined) end = self.length;
var big = new self.construct(end - start);
var big = bufferAllocUnsafe(end - start);
var ix = 0;

@@ -118,3 +116,3 @@ self.forEach(function (buffer) {

self.joinInto = function (targetBuffer, targetStart, sourceStart, sourceEnd) {
if (!head.buffer) return new self.construct(0);
if (!head.buffer) return new bufferAllocUnsafe(0);
if (sourceStart == undefined) sourceStart = 0;

@@ -121,0 +119,0 @@ if (sourceEnd == undefined) sourceEnd = self.length;

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