Socket
Socket
Sign inDemoInstall

websocket-driver

Package Overview
Dependencies
3
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.0 to 0.7.1

84

CHANGELOG.md

@@ -0,26 +1,36 @@

### 0.7.1 / 2019-06-10
- Catch any exceptions produced while generating a handshake response and send a
`400 Bad Request` response to the client
- Pick the RFC-6455 protocol version if the request contains any of the headers
used by that version
- Use the `Buffer.alloc()` and `Buffer.from()` functions instead of the unsafe
`Buffer()` constructor
- Handle errors encountered while handling malformed draft-76 requests
### 0.7.0 / 2017-09-11
* Add `ping` and `pong` to the set of events users can listen to
* Replace the bindings to Node's HTTP parser with `http-parser-js`
- Add `ping` and `pong` to the set of events users can listen to
- Replace the bindings to Node's HTTP parser with `http-parser-js`
### 0.6.5 / 2016-05-20
* Don't mutate buffers passed in by the application when masking
- Don't mutate buffers passed in by the application when masking
### 0.6.4 / 2016-01-07
* If a number is given as input for a frame payload, send it as a string
- If a number is given as input for a frame payload, send it as a string
### 0.6.3 / 2015-11-06
* Reject draft-76 handshakes if their Sec-WebSocket-Key headers are invalid
* Throw a more helpful error if a client is created with an invalid URL
- Reject draft-76 handshakes if their Sec-WebSocket-Key headers are invalid
- Throw a more helpful error if a client is created with an invalid URL
### 0.6.2 / 2015-07-18
* When the peer sends a close frame with no error code, emit 1000
- When the peer sends a close frame with no error code, emit 1000
### 0.6.1 / 2015-07-13
* Use the `buffer.{read,write}UInt{16,32}BE` methods for reading/writing numbers
- Use the `buffer.{read,write}UInt{16,32}BE` methods for reading/writing numbers
to buffers rather than including duplicate logic for this

@@ -30,10 +40,10 @@

* Allow the parser to recover cleanly if event listeners raise an error
* Add a `pong` method for sending unsolicited pong frames
- Allow the parser to recover cleanly if event listeners raise an error
- Add a `pong` method for sending unsolicited pong frames
### 0.5.4 / 2015-03-29
* Don't emit extra close frames if we receive a close frame after we already
- Don't emit extra close frames if we receive a close frame after we already
sent one
* Fail the connection when the driver receives an invalid
- Fail the connection when the driver receives an invalid
`Sec-WebSocket-Extensions` header

@@ -43,3 +53,3 @@

* Don't treat incoming data as WebSocket frames if a client driver is closed
- Don't treat incoming data as WebSocket frames if a client driver is closed
before receiving the server handshake

@@ -49,31 +59,31 @@

* Fix compatibility with the HTTP parser on io.js
* Use `websocket-extensions` to make sure messages and close frames are kept in
- Fix compatibility with the HTTP parser on io.js
- Use `websocket-extensions` to make sure messages and close frames are kept in
order
* Don't emit multiple `error` events
- Don't emit multiple `error` events
### 0.5.1 / 2014-12-18
* Don't allow drivers to be created with unrecognized options
- Don't allow drivers to be created with unrecognized options
### 0.5.0 / 2014-12-13
* Support protocol extensions via the websocket-extensions module
- Support protocol extensions via the websocket-extensions module
### 0.4.0 / 2014-11-08
* Support connection via HTTP proxies using `CONNECT`
- Support connection via HTTP proxies using `CONNECT`
### 0.3.6 / 2014-10-04
* It is now possible to call `close()` before `start()` and close the driver
- It is now possible to call `close()` before `start()` and close the driver
### 0.3.5 / 2014-07-06
* Don't hold references to frame buffers after a message has been emitted
* Make sure that `protocol` and `version` are exposed properly by the TCP driver
- Don't hold references to frame buffers after a message has been emitted
- Make sure that `protocol` and `version` are exposed properly by the TCP driver
### 0.3.4 / 2014-05-08
* Don't hold memory-leaking references to I/O buffers after they have been
- Don't hold memory-leaking references to I/O buffers after they have been
parsed

@@ -83,37 +93,37 @@

* Correct the draft-76 status line reason phrase
- Correct the draft-76 status line reason phrase
### 0.3.2 / 2013-12-29
* Expand `maxLength` to cover sequences of continuation frames and
- Expand `maxLength` to cover sequences of continuation frames and
`draft-{75,76}`
* Decrease default maximum frame buffer size to 64MB
* Stop parsing when the protocol enters a failure mode, to save CPU cycles
- Decrease default maximum frame buffer size to 64MB
- Stop parsing when the protocol enters a failure mode, to save CPU cycles
### 0.3.1 / 2013-12-03
* Add a `maxLength` option to limit allowed frame size
* Don't pre-allocate a message buffer until the whole frame has arrived
* Fix compatibility with Node v0.11 `HTTPParser`
- Add a `maxLength` option to limit allowed frame size
- Don't pre-allocate a message buffer until the whole frame has arrived
- Fix compatibility with Node v0.11 `HTTPParser`
### 0.3.0 / 2013-09-09
* Support client URLs with Basic Auth credentials
- Support client URLs with Basic Auth credentials
### 0.2.2 / 2013-07-05
* No functional changes, just updates to package.json
- No functional changes, just updates to package.json
### 0.2.1 / 2013-05-17
* Export the isSecureRequest() method since faye-websocket relies on it
* Queue sent messages in the client's initial state
- Export the isSecureRequest() method since faye-websocket relies on it
- Queue sent messages in the client's initial state
### 0.2.0 / 2013-05-12
* Add API for setting and reading headers
* Add Driver.server() method for getting a driver for TCP servers
- Add API for setting and reading headers
- Add Driver.server() method for getting a driver for TCP servers
### 0.1.0 / 2013-05-04
* First stable release
- First stable release

@@ -35,10 +35,3 @@ 'use strict';

isWebSocket: function(request) {
if (request.method !== 'GET') return false;
var connection = request.headers.connection || '',
upgrade = request.headers.upgrade || '';
return request.method === 'GET' &&
connection.toLowerCase().split(/ *, */).indexOf('upgrade') >= 0 &&
upgrade.toLowerCase() === 'websocket';
return Base.isWebSocket(request);
},

@@ -45,0 +38,0 @@

'use strict';
var Emitter = require('events').EventEmitter,
var Buffer = require('safe-buffer').Buffer,
Emitter = require('events').EventEmitter,
util = require('util'),

@@ -28,2 +29,11 @@ streams = require('../streams'),

Base.isWebSocket = function(request) {
var connection = request.headers.connection || '',
upgrade = request.headers.upgrade || '';
return request.method === 'GET' &&
connection.toLowerCase().split(/ *, */).indexOf('upgrade') >= 0 &&
upgrade.toLowerCase() === 'websocket';
};
Base.validateOptions = function(options, validKeys) {

@@ -83,4 +93,14 @@ for (var key in options) {

if (this.readyState !== 0) return false;
var response = this._handshakeResponse();
if (!response) return false;
if (!Base.isWebSocket(this._request))
return this._failHandshake(new Error('Not a WebSocket request'));
var response;
try {
response = this._handshakeResponse();
} catch (error) {
return this._failHandshake(error);
}
this._write(response);

@@ -91,2 +111,14 @@ if (this._stage !== -1) this._open();

_failHandshake: function(error) {
var headers = new Headers();
headers.set('Content-Type', 'text/plain');
headers.set('Content-Length', Buffer.byteLength(error.message, 'utf8'));
headers = ['HTTP/1.1 400 Bad Request', headers.toString(), error.message];
this._write(Buffer.from(headers.join('\r\n'), 'utf8'));
this._fail('protocol_error', error.message);
return false;
},
text: function(message) {

@@ -130,2 +162,8 @@ return this.frame(message);

if (io.readable) io.emit('data', chunk);
},
_fail: function(type, message) {
this.readyState = 2;
this.emit('error', new Error(message));
this.close();
}

@@ -132,0 +170,0 @@ };

'use strict';
var crypto = require('crypto'),
var Buffer = require('safe-buffer').Buffer,
crypto = require('crypto'),
url = require('url'),

@@ -12,3 +13,3 @@ util = require('util'),

var Client = function(_url, options) {
this.version = 'hybi-13';
this.version = 'hybi-' + Hybi.VERSION;
Hybi.call(this, null, _url, options);

@@ -22,3 +23,3 @@

var uri = url.parse(this.url),
auth = uri.auth && new Buffer(uri.auth, 'utf8').toString('base64');
auth = uri.auth && Buffer.from(uri.auth, 'utf8').toString('base64');

@@ -34,3 +35,3 @@ if (this.VALID_PROTOCOLS.indexOf(uri.protocol) < 0)

this._headers.set('Sec-WebSocket-Key', this._key);
this._headers.set('Sec-WebSocket-Version', '13');
this._headers.set('Sec-WebSocket-Version', Hybi.VERSION);

@@ -85,3 +86,3 @@ if (this._protocols.length > 0)

return new Buffer(headers.join('\r\n'), 'utf8');
return Buffer.from(headers.join('\r\n'), 'utf8');
},

@@ -88,0 +89,0 @@

'use strict';
var Base = require('./base'),
util = require('util');
var Buffer = require('safe-buffer').Buffer,
Base = require('./base'),
util = require('util');

@@ -64,3 +65,3 @@ var Draft75 = function(request, url, options) {

this._stage = 0;
message = new Buffer(this._buffer).toString('utf8', 0, this._buffer.length);
message = Buffer.from(this._buffer).toString('utf8', 0, this._buffer.length);
this.emit('message', new Base.MessageEvent(message));

@@ -89,8 +90,8 @@ }

var payload = new Buffer(buffer, 'utf8'),
frame = new Buffer(payload.length + 2);
var length = Buffer.byteLength(buffer),
frame = Buffer.allocUnsafe(length + 2);
frame[0] = 0x00;
frame[payload.length + 1] = 0xFF;
payload.copy(frame, 1);
frame.write(buffer, 1);
frame[frame.length - 1] = 0xFF;

@@ -105,3 +106,3 @@ this._write(frame);

return new Buffer(headers.join('\r\n'), 'utf8');
return Buffer.from(headers.join('\r\n'), 'utf8');
},

@@ -108,0 +109,0 @@

'use strict';
var Base = require('./base'),
var Buffer = require('safe-buffer').Buffer,
Base = require('./base'),
Draft75 = require('./draft75'),

@@ -10,7 +11,7 @@ crypto = require('crypto'),

var numberFromKey = function(key) {
return parseInt(key.match(/[0-9]/g).join(''), 10);
return parseInt((key.match(/[0-9]/g) || []).join(''), 10);
};
var spacesInKey = function(key) {
return key.match(/ /g).length;
return (key.match(/ /g) || []).length;
};

@@ -46,3 +47,3 @@

if (this.readyState === 3) return false;
this._write(new Buffer([0xFF, 0x00]));
if (this.readyState === 1) this._write(Buffer.from([0xFF, 0x00]));
this.readyState = 3;

@@ -55,16 +56,16 @@ this.emit('close', new Base.CloseEvent(null, null));

var headers = this._request.headers,
key1 = headers['sec-websocket-key1'],
key2 = headers['sec-websocket-key2'];
key1 = headers['sec-websocket-key1'],
number1 = numberFromKey(key1),
if (!key1) throw new Error('Missing required header: Sec-WebSocket-Key1');
if (!key2) throw new Error('Missing required header: Sec-WebSocket-Key2');
var number1 = numberFromKey(key1),
spaces1 = spacesInKey(key1),
key2 = headers['sec-websocket-key2'],
number2 = numberFromKey(key2),
spaces2 = spacesInKey(key2);
if (number1 % spaces1 !== 0 || number2 % spaces2 !== 0) {
this.emit('error', new Error('Client sent invalid Sec-WebSocket-Key headers'));
this.close();
return null;
}
if (number1 % spaces1 !== 0 || number2 % spaces2 !== 0)
throw new Error('Client sent invalid Sec-WebSocket-Key headers');

@@ -76,3 +77,3 @@ this._keyValues = [number1 / spaces1, number2 / spaces2];

return new Buffer(headers.join('\r\n'), 'binary');
return Buffer.from(headers.join('\r\n'), 'binary');
},

@@ -84,10 +85,10 @@

var md5 = crypto.createHash('md5'),
buffer = new Buffer(8 + this.BODY_SIZE);
buffer = Buffer.allocUnsafe(8 + this.BODY_SIZE);
buffer.writeUInt32BE(this._keyValues[0], 0);
buffer.writeUInt32BE(this._keyValues[1], 4);
new Buffer(this._body).copy(buffer, 8, 0, this.BODY_SIZE);
Buffer.from(this._body).copy(buffer, 8, 0, this.BODY_SIZE);
md5.update(buffer);
return new Buffer(md5.digest('binary'), 'binary');
return Buffer.from(md5.digest('binary'), 'binary');
},

@@ -94,0 +95,0 @@

'use strict';
var crypto = require('crypto'),
var Buffer = require('safe-buffer').Buffer,
crypto = require('crypto'),
util = require('util'),

@@ -25,21 +26,16 @@ Extensions = require('websocket-extensions'),

var secKey = this._request.headers['sec-websocket-key'],
protos = this._request.headers['sec-websocket-protocol'],
version = this._request.headers['sec-websocket-version'],
var protos = this._request.headers['sec-websocket-protocol'],
supported = this._protocols;
this._headers.set('Upgrade', 'websocket');
this._headers.set('Connection', 'Upgrade');
this._headers.set('Sec-WebSocket-Accept', Hybi.generateAccept(secKey));
if (protos !== undefined) {
if (typeof protos === 'string') protos = protos.split(/ *, */);
this.protocol = protos.filter(function(p) { return supported.indexOf(p) >= 0 })[0];
if (this.protocol) this._headers.set('Sec-WebSocket-Protocol', this.protocol);
}
this.version = 'hybi-' + version;
this.version = 'hybi-' + Hybi.VERSION;
};
util.inherits(Hybi, Base);
Hybi.VERSION = '13';
Hybi.mask = function(payload, mask, offset) {

@@ -196,3 +192,3 @@ if (!mask || mask.length === 0) return payload;

if (buffer instanceof Array) buffer = new Buffer(buffer);
if (buffer instanceof Array) buffer = Buffer.from(buffer);
if (typeof buffer === 'number') buffer = buffer.toString();

@@ -207,7 +203,7 @@

payload = isText ? new Buffer(buffer, 'utf8') : buffer;
payload = isText ? Buffer.from(buffer, 'utf8') : buffer;
if (code) {
copy = payload;
payload = new Buffer(2 + copy.length);
payload = Buffer.allocUnsafe(2 + copy.length);
payload.writeUInt16BE(code, 0);

@@ -250,3 +246,3 @@ copy.copy(payload, 2);

offset = header + (frame.masked ? 4 : 0),
buffer = new Buffer(offset + length),
buffer = Buffer.allocUnsafe(offset + length),
masked = frame.masked ? this.MASK : 0;

@@ -282,8 +278,18 @@

_handshakeResponse: function() {
try {
var extensions = this._extensions.generateResponse(this._request.headers['sec-websocket-extensions']);
} catch (e) {
return this._fail('protocol_error', e.message);
}
var secKey = this._request.headers['sec-websocket-key'],
version = this._request.headers['sec-websocket-version'];
if (version !== Hybi.VERSION)
throw new Error('Unsupported WebSocket version: ' + version);
if (typeof secKey !== 'string')
throw new Error('Missing handshake request header: Sec-WebSocket-Key');
this._headers.set('Upgrade', 'websocket');
this._headers.set('Connection', 'Upgrade');
this._headers.set('Sec-WebSocket-Accept', Hybi.generateAccept(secKey));
if (this.protocol) this._headers.set('Sec-WebSocket-Protocol', this.protocol);
var extensions = this._extensions.generateResponse(this._request.headers['sec-websocket-extensions']);
if (extensions) this._headers.set('Sec-WebSocket-Extensions', extensions);

@@ -294,3 +300,3 @@

return new Buffer(headers.join('\r\n'), 'utf8');
return Buffer.from(headers.join('\r\n'), 'utf8');
},

@@ -297,0 +303,0 @@

'use strict';
var Buffer = require('safe-buffer').Buffer;
var Message = function() {

@@ -7,3 +9,3 @@ this.rsv1 = false;

this.rsv3 = false;
this.opcode = null
this.opcode = null;
this.length = 0;

@@ -15,12 +17,3 @@ this._chunks = [];

read: function() {
if (this.data) return this.data;
this.data = new Buffer(this.length);
var offset = 0;
for (var i = 0, n = this._chunks.length; i < n; i++) {
this._chunks[i].copy(this.data, offset);
offset += this._chunks[i].length;
}
return this.data;
return this.data = this.data || Buffer.concat(this._chunks, this.length);
},

@@ -27,0 +20,0 @@

'use strict';
var Stream = require('stream').Stream,
var Buffer = require('safe-buffer').Buffer,
Stream = require('stream').Stream,
url = require('url'),

@@ -28,3 +29,3 @@ util = require('util'),

var auth = this._url.auth && new Buffer(this._url.auth, 'utf8').toString('base64');
var auth = this._url.auth && Buffer.from(this._url.auth, 'utf8').toString('base64');
if (auth) this._headers.set('Proxy-Authorization', 'Basic ' + auth);

@@ -51,3 +52,3 @@ };

this.emit('data', new Buffer(headers.join('\r\n'), 'utf8'));
this.emit('data', Buffer.from(headers.join('\r\n'), 'utf8'));
return true;

@@ -54,0 +55,0 @@ },

@@ -98,7 +98,11 @@ 'use strict';

var headers = request.headers,
version = headers['sec-websocket-version'],
key = headers['sec-websocket-key'],
key1 = headers['sec-websocket-key1'],
key2 = headers['sec-websocket-key2'],
url = this.determineUrl(request);
if (headers['sec-websocket-version'])
if (version || key)
return new Hybi(request, url, options);
else if (headers['sec-websocket-key1'])
else if (key1 || key2)
return new Draft76(request, url, options);

@@ -105,0 +109,0 @@ else

'use strict';
var Buffer = require('safe-buffer').Buffer;
var StreamReader = function() {

@@ -11,3 +13,3 @@ this._queue = [];

if (!buffer || buffer.length === 0) return;
if (!buffer.copy) buffer = new Buffer(buffer);
if (!Buffer.isBuffer(buffer)) buffer = Buffer.from(buffer);
this._queue.push(buffer);

@@ -19,3 +21,3 @@ this._queueSize += buffer.length;

if (length > this._queueSize) return null;
if (length === 0) return new Buffer(0);
if (length === 0) return Buffer.alloc(0);

@@ -49,3 +51,3 @@ this._queueSize -= length;

}
return this._concat(buffers, length);
return Buffer.concat(buffers, length);
};

@@ -70,15 +72,2 @@

StreamReader.prototype._concat = function(buffers, length) {
if (Buffer.concat) return Buffer.concat(buffers, length);
var buffer = new Buffer(length),
offset = 0;
for (var i = 0, n = buffers.length; i < n; i++) {
buffers[i].copy(buffer, offset);
offset += buffers[i].length;
}
return buffer;
};
module.exports = StreamReader;
'use strict';
var NodeHTTPParser = require('http-parser-js').HTTPParser;
var NodeHTTPParser = require('http-parser-js').HTTPParser,
Buffer = require('safe-buffer').Buffer;
var VERSION = process.version.match(/[0-9]+/g).map(function(n) { return parseInt(n, 10) });
var TYPES = {

@@ -100,2 +99,6 @@ request: NodeHTTPParser.REQUEST || 'request',

var VERSION = (process.version || '')
.match(/[0-9]+/g)
.map(function(n) { return parseInt(n, 10) });
if (VERSION[0] === 0 && VERSION[1] === 12) {

@@ -127,10 +130,8 @@ HttpParser.METHODS[16] = 'REPORT';

if (VERSION[0] === 0 && VERSION[1] < 6) consumed += 1;
if (this._complete)
this.body = (consumed < chunk.length)
? chunk.slice(consumed)
: new Buffer(0);
: Buffer.alloc(0);
};
module.exports = HttpParser;

@@ -1,20 +0,12 @@

# The MIT License
Copyright 2010-2019 James Coglan
Copyright (c) 2010-2017 James Coglan
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the 'Software'), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
http://www.apache.org/licenses/LICENSE-2.0
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

@@ -1,27 +0,35 @@

{ "name" : "websocket-driver"
, "description" : "WebSocket protocol handler with pluggable I/O"
, "homepage" : "https://github.com/faye/websocket-driver-node"
, "author" : "James Coglan <jcoglan@gmail.com> (http://jcoglan.com/)"
, "keywords" : ["websocket"]
, "license" : "MIT"
, "version" : "0.7.0"
, "engines" : { "node": ">=0.8.0" }
, "files" : ["lib"]
, "main" : "./lib/websocket/driver"
, "dependencies" : { "http-parser-js": ">=0.4.0"
, "websocket-extensions": ">=0.1.1"
}
, "devDependencies" : { "jstest": "*"
, "permessage-deflate": "*"
}
, "scripts" : { "test": "jstest spec/runner.js" }
, "repository" : { "type" : "git"
, "url" : "git://github.com/faye/websocket-driver-node.git"
}
, "bugs" : "https://github.com/faye/websocket-driver-node/issues"
{
"name": "websocket-driver",
"description": "WebSocket protocol handler with pluggable I/O",
"homepage": "https://github.com/faye/websocket-driver-node",
"author": "James Coglan <jcoglan@gmail.com> (http://jcoglan.com/)",
"keywords": [
"websocket"
],
"license": "Apache-2.0",
"version": "0.7.1",
"engines": {
"node": ">=0.8.0"
},
"files": [
"lib"
],
"main": "./lib/websocket/driver",
"dependencies": {
"http-parser-js": ">=0.4.0",
"safe-buffer": ">=5.1.1",
"websocket-extensions": ">=0.1.1"
},
"devDependencies": {
"jstest": "*",
"permessage-deflate": "*"
},
"scripts": {
"test": "jstest spec/runner.js"
},
"repository": {
"type": "git",
"url": "git://github.com/faye/websocket-driver-node.git"
},
"bugs": "https://github.com/faye/websocket-driver-node/issues"
}

@@ -13,17 +13,17 @@ # websocket-driver [![Build Status](https://travis-ci.org/faye/websocket-driver-node.svg)](https://travis-ci.org/faye/websocket-driver-node)

* Select the correct server-side driver to talk to the client
* Generate and send both server- and client-side handshakes
* Recognize when the handshake phase completes and the WS protocol begins
* Negotiate subprotocol selection based on `Sec-WebSocket-Protocol`
* Negotiate and use extensions via the
- Select the correct server-side driver to talk to the client
- Generate and send both server- and client-side handshakes
- Recognize when the handshake phase completes and the WS protocol begins
- Negotiate subprotocol selection based on `Sec-WebSocket-Protocol`
- Negotiate and use extensions via the
[websocket-extensions](https://github.com/faye/websocket-extensions-node)
module
* Buffer sent messages until the handshake process is finished
* Deal with proxies that defer delivery of the draft-76 handshake body
* Notify you when the socket is open and closed and when messages arrive
* Recombine fragmented messages
* Dispatch text, binary, ping, pong and close frames
* Manage the socket-closing handshake process
* Automatically reply to ping frames with a matching pong
* Apply masking to messages sent by the client
- Buffer sent messages until the handshake process is finished
- Deal with proxies that defer delivery of the draft-76 handshake body
- Notify you when the socket is open and closed and when messages arrive
- Recombine fragmented messages
- Dispatch text, binary, ping, pong and close frames
- Manage the socket-closing handshake process
- Automatically reply to ping frames with a matching pong
- Apply masking to messages sent by the client

@@ -157,4 +157,4 @@ This library was originally extracted from the [Faye](http://faye.jcoglan.com)

* `driver.statusCode` - the integer value of the HTTP status code
* `driver.headers` - an object containing the response headers
- `driver.statusCode` - the integer value of the HTTP status code
- `driver.headers` - an object containing the response headers

@@ -240,5 +240,5 @@

* `maxLength` - the maximum allowed size of incoming message frames, in bytes.
- `maxLength` - the maximum allowed size of incoming message frames, in bytes.
The default value is `2^26 - 1`, or 1 byte short of 64 MiB.
* `protocols` - an array of strings representing acceptable subprotocols for use
- `protocols` - an array of strings representing acceptable subprotocols for use
over the socket. The driver will negotiate one of these to use via the

@@ -249,6 +249,6 @@ `Sec-WebSocket-Protocol` header if supported by the other peer.

* <b>`driver.io`</b> - this stream should be attached to an I/O socket like a
TCP stream. Pipe incoming TCP chunks to this stream for them to be parsed, and
- **`driver.io`** - this stream should be attached to an I/O socket like a TCP
stream. Pipe incoming TCP chunks to this stream for them to be parsed, and
pipe this stream back into TCP to send outgoing frames.
* <b>`driver.messages`</b> - this stream emits messages received over the
- **`driver.messages`** - this stream emits messages received over the
WebSocket. Writing to it sends messages to the other peer by emitting frames

@@ -255,0 +255,0 @@ via the `driver.io` stream.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc