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 5.1.0 to 5.1.1

81

lib/buffer-util.js

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

*/
const concat = (list, totalLength) => {
function concat (list, totalLength) {
const target = Buffer.allocUnsafe(totalLength);

@@ -23,41 +23,52 @@ var offset = 0;

return target;
};
}
/**
* Masks a buffer using the given mask.
*
* @param {Buffer} source The buffer to mask
* @param {Buffer} mask The mask to use
* @param {Buffer} output The buffer where to store the result
* @param {Number} offset The offset at which to start writing
* @param {Number} length The number of bytes to mask.
* @public
*/
function _mask (source, mask, output, offset, length) {
for (var i = 0; i < length; i++) {
output[offset + i] = source[i] ^ mask[i & 3];
}
}
/**
* Unmasks a buffer using the given mask.
*
* @param {Buffer} buffer The buffer to unmask
* @param {Buffer} mask The mask to use
* @public
*/
function _unmask (buffer, mask) {
// Required until https://github.com/nodejs/node/issues/9006 is resolved.
const length = buffer.length;
for (var i = 0; i < length; i++) {
buffer[i] ^= mask[i & 3];
}
}
try {
const bufferUtil = require('bufferutil');
const bu = bufferUtil.BufferUtil || bufferUtil;
module.exports = Object.assign({ concat }, bufferUtil.BufferUtil || bufferUtil);
module.exports = {
mask (source, mask, output, offset, length) {
if (length < 48) _mask(source, mask, output, offset, length);
else bu.mask(source, mask, output, offset, length);
},
unmask (buffer, mask) {
if (buffer.length < 32) _unmask(buffer, mask);
else bu.unmask(buffer, mask);
},
concat
};
} catch (e) /* istanbul ignore next */ {
/**
* Masks a buffer using the given mask.
*
* @param {Buffer} source The buffer to mask
* @param {Buffer} mask The mask to use
* @param {Buffer} output The buffer where to store the result
* @param {Number} offset The offset at which to start writing
* @param {Number} length The number of bytes to mask.
* @public
*/
const mask = (source, mask, output, offset, length) => {
for (var i = 0; i < length; i++) {
output[offset + i] = source[i] ^ mask[i & 3];
}
};
/**
* Unmasks a buffer using the given mask.
*
* @param {Buffer} buffer The buffer to unmask
* @param {Buffer} mask The mask to use
* @public
*/
const unmask = (buffer, mask) => {
// Required until https://github.com/nodejs/node/issues/9006 is resolved.
const length = buffer.length;
for (var i = 0; i < length; i++) {
buffer[i] ^= mask[i & 3];
}
};
module.exports = { concat, mask, unmask };
module.exports = { concat, mask: _mask, unmask: _unmask };
}

@@ -468,3 +468,5 @@ 'use strict';

options.port = parsedUrl.port || (isSecure ? 443 : 80);
options.host = parsedUrl.hostname;
options.host = parsedUrl.hostname.startsWith('[')
? parsedUrl.hostname.slice(1, -1)
: parsedUrl.hostname;
options.headers = Object.assign({

@@ -626,2 +628,3 @@ 'Sec-WebSocket-Version': options.protocolVersion,

options.path = options.socketPath || options._socketPath || undefined;
options.servername = options.servername || options.host;
return tls.connect(options);

@@ -628,0 +631,0 @@ }

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

@@ -36,3 +36,3 @@ "keywords": [

"eslint-config-standard": "~11.0.0",
"eslint-plugin-import": "~2.9.0",
"eslint-plugin-import": "~2.10.0",
"eslint-plugin-node": "~6.0.0",

@@ -39,0 +39,0 @@ "eslint-plugin-promise": "~3.7.0",

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