You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

websocket-driver

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.5 to 0.7.0

LICENSE.md

5

CHANGELOG.md

@@ -0,1 +1,6 @@

### 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`
### 0.6.5 / 2016-05-20

@@ -2,0 +7,0 @@

@@ -147,2 +147,10 @@ 'use strict';

Base.PingEvent = function(data) {
this.data = data;
};
Base.PongEvent = function(data) {
this.data = data;
};
module.exports = Base;

3

lib/websocket/driver/client.js

@@ -96,2 +96,5 @@ 'use strict';

if (this._http.error)
return this._failHandshake(this._http.error.message);
if (this._http.statusCode !== 101)

@@ -98,0 +101,0 @@ return this._failHandshake('Unexpected response code: ' + this._http.statusCode);

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

this.frame(payload, 'pong');
this.emit('ping', new Base.PingEvent(payload.toString()))
}

@@ -434,2 +435,4 @@

if (callback) callback()
this.emit('pong', new Base.PongEvent(payload.toString()))
}

@@ -436,0 +439,0 @@ },

62

lib/websocket/http_parser.js
'use strict';
var NodeHTTPParser = process.binding('http_parser').HTTPParser,
version = NodeHTTPParser.RESPONSE ? 6 : 4;
var NodeHTTPParser = require('http-parser-js').HTTPParser;
var VERSION = process.version.match(/[0-9]+/g).map(function(n) { return parseInt(n, 10) });
var TYPES = {
request: NodeHTTPParser.REQUEST || 'request',
response: NodeHTTPParser.RESPONSE || 'response'
};
var HttpParser = function(type) {
if (type === 'request')
this._parser = new NodeHTTPParser(NodeHTTPParser.REQUEST || 'request');
else
this._parser = new NodeHTTPParser(NodeHTTPParser.RESPONSE || 'response');
this._type = type;
this._parser = new NodeHTTPParser(TYPES[type]);
this._complete = false;

@@ -79,9 +81,34 @@ this.headers = {};

15: 'UNLOCK',
16: 'REPORT',
17: 'MKACTIVITY',
18: 'CHECKOUT',
19: 'MERGE',
24: 'PATCH'
16: 'BIND',
17: 'REBIND',
18: 'UNBIND',
19: 'ACL',
20: 'REPORT',
21: 'MKACTIVITY',
22: 'CHECKOUT',
23: 'MERGE',
24: 'M-SEARCH',
25: 'NOTIFY',
26: 'SUBSCRIBE',
27: 'UNSUBSCRIBE',
28: 'PATCH',
29: 'PURGE',
30: 'MKCALENDAR',
31: 'LINK',
32: 'UNLINK'
};
if (VERSION[0] === 0 && VERSION[1] === 12) {
HttpParser.METHODS[16] = 'REPORT';
HttpParser.METHODS[17] = 'MKACTIVITY';
HttpParser.METHODS[18] = 'CHECKOUT';
HttpParser.METHODS[19] = 'MERGE';
HttpParser.METHODS[20] = 'M-SEARCH';
HttpParser.METHODS[21] = 'NOTIFY';
HttpParser.METHODS[22] = 'SUBSCRIBE';
HttpParser.METHODS[23] = 'UNSUBSCRIBE';
HttpParser.METHODS[24] = 'PATCH';
HttpParser.METHODS[25] = 'PURGE';
}
HttpParser.prototype.isComplete = function() {

@@ -92,5 +119,12 @@ return this._complete;

HttpParser.prototype.parse = function(chunk) {
var offset = (version < 6) ? 1 : 0,
consumed = this._parser.execute(chunk, 0, chunk.length) + offset;
var consumed = this._parser.execute(chunk, 0, chunk.length);
if (typeof consumed !== 'number') {
this.error = consumed;
this._complete = true;
return;
}
if (VERSION[0] === 0 && VERSION[1] < 6) consumed += 1;
if (this._complete)

@@ -97,0 +131,0 @@ this.body = (consumed < chunk.length)

@@ -8,10 +8,16 @@ { "name" : "websocket-driver"

, "version" : "0.6.5"
, "engines" : {"node": ">=0.6.0"}
, "version" : "0.7.0"
, "engines" : { "node": ">=0.8.0" }
, "files" : ["lib"]
, "main" : "./lib/websocket/driver"
, "dependencies" : {"websocket-extensions": ">=0.1.1"}
, "devDependencies" : {"jstest": "", "permessage-deflate": ""}
, "scripts" : {"test": "jstest spec/runner.js"}
, "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"

@@ -18,0 +24,0 @@ , "url" : "git://github.com/faye/websocket-driver-node.git"

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

#### `driver.on('ping', function(event) {})`
Adds a callback block to execute when a ping is received. You do not need to
handle this by sending a pong frame yourself; the driver handles this for you.
#### `driver.on('pong', function(event) {})`
Adds a callback block to execute when a pong is received. If this was in
response to a ping you sent, you can also handle this event via the
`driver.ping(message, function() { ... })` callback.
#### `driver.addExtension(extension)`

@@ -361,25 +372,1 @@

`emit('open')` has fired.
## License
(The MIT License)
Copyright (c) 2010-2016 James Coglan
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:
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.
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc