Comparing version 2.2.3 to 2.3.0
@@ -143,7 +143,7 @@ /*! | ||
this.sendFrame(Sender.frame(data, { | ||
readOnly: false, | ||
fin: true, | ||
rsv1: false, | ||
opcode: 0x08, | ||
rsv1: false, | ||
fin: true, | ||
mask | ||
mask, | ||
readOnly: false | ||
}), cb); | ||
@@ -190,7 +190,7 @@ } | ||
this.sendFrame(Sender.frame(data, { | ||
fin: true, | ||
rsv1: false, | ||
opcode: 0x09, | ||
rsv1: false, | ||
fin: true, | ||
readOnly, | ||
mask | ||
mask, | ||
readOnly | ||
})); | ||
@@ -237,7 +237,7 @@ } | ||
this.sendFrame(Sender.frame(data, { | ||
fin: true, | ||
rsv1: false, | ||
opcode: 0x0a, | ||
rsv1: false, | ||
fin: true, | ||
readOnly, | ||
mask | ||
mask, | ||
readOnly | ||
})); | ||
@@ -289,22 +289,21 @@ } | ||
const opts = { | ||
compress: this.compress, | ||
mask: options.mask, | ||
fin: options.fin, | ||
readOnly, | ||
rsv1, | ||
opcode, | ||
rsv1 | ||
mask: options.mask, | ||
readOnly | ||
}; | ||
if (this.deflating) { | ||
this.enqueue([this.dispatch, data, opts, cb]); | ||
this.enqueue([this.dispatch, data, this.compress, opts, cb]); | ||
} else { | ||
this.dispatch(data, opts, cb); | ||
this.dispatch(data, this.compress, opts, cb); | ||
} | ||
} else { | ||
this.sendFrame(Sender.frame(data, { | ||
mask: options.mask, | ||
fin: options.fin, | ||
rsv1: false, | ||
readOnly, | ||
opcode | ||
opcode, | ||
mask: options.mask, | ||
readOnly | ||
}), cb); | ||
@@ -318,2 +317,3 @@ } | ||
* @param {Buffer} data The message to send | ||
* @param {Boolean} compress Specifies whether or not to compress `data` | ||
* @param {Object} options Options object | ||
@@ -323,3 +323,2 @@ * @param {Number} options.opcode The opcode | ||
* @param {Boolean} options.fin Specifies whether or not to set the FIN bit | ||
* @param {Boolean} options.compress Specifies whether or not to compress `data` | ||
* @param {Boolean} options.mask Specifies whether or not to mask `data` | ||
@@ -330,4 +329,4 @@ * @param {Boolean} options.rsv1 Specifies whether or not to set the RSV1 bit | ||
*/ | ||
dispatch (data, options, cb) { | ||
if (!options.compress) { | ||
dispatch (data, compress, options, cb) { | ||
if (!compress) { | ||
this.sendFrame(Sender.frame(data, options), cb); | ||
@@ -334,0 +333,0 @@ return; |
@@ -658,2 +658,4 @@ /*! | ||
this.emit('headers', res.headers, res); | ||
const digest = crypto.createHash('sha1') | ||
@@ -660,0 +662,0 @@ .update(key + constants.GUID, 'binary') |
@@ -171,3 +171,3 @@ /*! | ||
if (this.options.handleProtocols) { | ||
protocol = this.options.handleProtocols(protocol); | ||
protocol = this.options.handleProtocols(protocol, req); | ||
if (protocol === false) return abortConnection(socket, 401); | ||
@@ -256,7 +256,7 @@ } else { | ||
// | ||
this.emit('headers', headers); | ||
this.emit('headers', headers, req); | ||
socket.write(headers.concat('', '').join('\r\n')); | ||
const client = new WebSocket([req, socket, head], { | ||
const client = new WebSocket([req, socket, head], null, { | ||
maxPayload: this.options.maxPayload, | ||
@@ -263,0 +263,0 @@ protocolVersion: version, |
{ | ||
"author": "Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)", | ||
"name": "ws", | ||
"version": "2.3.0", | ||
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js", | ||
"version": "2.2.3", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"keywords": [ | ||
@@ -16,6 +13,12 @@ "HyBi", | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/websockets/ws.git" | ||
}, | ||
"homepage": "https://github.com/websockets/ws", | ||
"bugs": "https://github.com/websockets/ws/issues", | ||
"repository": "websockets/ws", | ||
"author": "Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"files": [ | ||
"index.js", | ||
"lib" | ||
], | ||
"scripts": { | ||
@@ -34,7 +37,7 @@ "test": "eslint . && nyc --reporter=html --reporter=text mocha test/*.test.js", | ||
"eslint": "~3.19.0", | ||
"eslint-config-standard": "~8.0.0-beta.1", | ||
"eslint-config-standard": "~10.2.0", | ||
"eslint-plugin-import": "~2.2.0", | ||
"eslint-plugin-node": "~4.2.0", | ||
"eslint-plugin-promise": "~3.5.0", | ||
"eslint-plugin-standard": "~2.1.0", | ||
"eslint-plugin-standard": "~3.0.0", | ||
"mocha": "~3.2.0", | ||
@@ -41,0 +44,0 @@ "nyc": "~10.2.0", |
@@ -14,2 +14,7 @@ # ws: a Node.js WebSocket library | ||
**Note**: This module does not work in the browser. The client in the docs is a | ||
reference to a back end with the role of a client in the WebSocket | ||
communication. Browser clients must use the native | ||
[`WebSocket`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) object. | ||
## Protocol support | ||
@@ -26,18 +31,14 @@ | ||
### Opt-in for performance | ||
### Opt-in for performance and spec compliance | ||
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. | ||
module. These modules are binary addons which improve certain operations. | ||
Prebuilt binaries are available for the most popular platforms so you don't | ||
necessarily need to have a C++ compiler installed on your machine. | ||
- `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-conforming and have fast | ||
validation of UTF-8 then this module is a must. | ||
- `npm install --save-optional bufferutil`: Allows to efficiently perform | ||
operations such as masking and unmasking the data payload of the WebSocket | ||
frames. | ||
- `npm install --save-optional utf-8-validate`: Allows to efficiently check | ||
if a message contains valid UTF-8 as required by the spec. | ||
@@ -51,5 +52,5 @@ ## API Docs | ||
`ws` supports the [permessage-deflate extension][permessage-deflate] extension | ||
which enables the client and server to negotiate a compression algorithm and | ||
its parameters, and then selectively apply it to the data payloads of each | ||
`ws` supports the [permessage-deflate extension][permessage-deflate] which | ||
enables the client and server to negotiate a compression algorithm and its | ||
parameters, and then selectively apply it to the data payloads of each | ||
WebSocket message. | ||
@@ -56,0 +57,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
0
261
82932
15
1