Socket
Socket
Sign inDemoInstall

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 7.2.3 to 7.2.5

19

lib/buffer-util.js

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

} else if (ArrayBuffer.isView(data)) {
buf = viewToBuffer(data);
buf = Buffer.from(data.buffer, data.byteOffset, data.byteLength);
} else {

@@ -105,19 +105,2 @@ buf = Buffer.from(data);

/**
* Converts an `ArrayBuffer` view into a buffer.
*
* @param {(DataView|TypedArray)} view The view to convert
* @return {Buffer} Converted view
* @private
*/
function viewToBuffer(view) {
const buf = Buffer.from(view.buffer);
if (view.byteLength !== view.buffer.byteLength) {
return buf.slice(view.byteOffset, view.byteOffset + view.byteLength);
}
return buf;
}
try {

@@ -124,0 +107,0 @@ const bufferUtil = require('bufferutil');

2

lib/stream.js

@@ -128,4 +128,4 @@ 'use strict';

if (ws._socket._writableState.finished) {
callback();
if (duplex._readableState.endEmitted) duplex.destroy();
callback();
} else {

@@ -132,0 +132,0 @@ ws._socket.once('finish', function finish() {

@@ -10,6 +10,5 @@ 'use strict';

const { format, parse } = require('./extension');
const { GUID } = require('./constants');
const { GUID, kWebSocket } = require('./constants');
const keyRegex = /^[+/0-9A-Za-z]{22}==$/;
const kUsedByWebSocketServer = Symbol('kUsedByWebSocketServer');

@@ -83,9 +82,2 @@ /**

} else if (options.server) {
if (options.server[kUsedByWebSocketServer]) {
throw new Error(
'The HTTP/S server is already being used by another WebSocket server'
);
}
options.server[kUsedByWebSocketServer] = true;
this._server = options.server;

@@ -158,4 +150,2 @@ }

}
delete server[kUsedByWebSocketServer];
}

@@ -270,2 +260,3 @@

* @param {Function} cb Callback
* @throws {Error} If called more than once with the same socket
* @private

@@ -279,2 +270,9 @@ */

if (socket[kWebSocket]) {
throw new Error(
'server.handleUpgrade() was called more than once with the same ' +
'socket, possibly due to a misconfiguration'
);
}
const digest = createHash('sha1')

@@ -394,3 +392,3 @@ .update(key + GUID)

Connection: 'close',
'Content-type': 'text/html',
'Content-Type': 'text/html',
'Content-Length': Buffer.byteLength(message),

@@ -397,0 +395,0 @@ ...headers

@@ -459,3 +459,2 @@ 'use strict';

method: undefined,
auth: undefined,
host: undefined,

@@ -462,0 +461,0 @@ path: undefined,

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

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

"scripts": {
"test": "npm run lint && nyc --reporter=html --reporter=text mocha --throw-deprecation test/*.test.js",
"test": "npm run lint && nyc --reporter=lcov --reporter=text mocha --throw-deprecation test/*.test.js",
"integration": "npm run lint && mocha --throw-deprecation test/*.integration.js",

@@ -49,3 +49,2 @@ "lint": "eslint --ignore-path .gitignore . && prettier --check --ignore-path .gitignore \"**/*.{json,md,yaml,yml}\""

"bufferutil": "^4.0.1",
"coveralls": "^3.0.3",
"eslint": "^6.0.0",

@@ -52,0 +51,0 @@ "eslint-config-prettier": "^6.0.0",

# ws: a Node.js WebSocket library
[![Version npm](https://img.shields.io/npm/v/ws.svg?logo=npm)](https://www.npmjs.com/package/ws)
[![Linux Build](https://img.shields.io/travis/websockets/ws/master.svg?logo=travis)](https://travis-ci.com/websockets/ws)
[![Windows Build](https://img.shields.io/appveyor/ci/lpinca/ws/master.svg?logo=appveyor)](https://ci.appveyor.com/project/lpinca/ws)
[![Build](https://github.com/websockets/ws/workflows/.github/workflows/build/badge.svg)](https://github.com/websockets/ws/actions?workflow=build)
[![Windows x86 Build](https://img.shields.io/appveyor/ci/lpinca/ws/master.svg?logo=appveyor)](https://ci.appveyor.com/project/lpinca/ws)
[![Coverage Status](https://img.shields.io/coveralls/websockets/ws/master.svg)](https://coveralls.io/github/websockets/ws)

@@ -269,4 +269,6 @@

server.on('upgrade', function upgrade(request, socket, head) {
// This function is not defined on purpose. Implement it with your own logic.
authenticate(request, (err, client) => {
if (err || !client) {
socket.write('HTTP/1.1 401 Unauthorized\r\n\r\n');
socket.destroy();

@@ -388,3 +390,3 @@ return;

wss.on('connection', function connection(ws, req) {
const ip = req.connection.remoteAddress;
const ip = req.socket.remoteAddress;
});

@@ -391,0 +393,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