engine.io-client
Advanced tools
Comparing version 0.4.3 to 0.5.0
{ | ||
"name": "engine.io", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"dependencies": { | ||
"component/emitter": "0.0.6", | ||
"LearnBoost/engine.io-protocol": "*", | ||
"component/emitter": "1.0.0", | ||
"LearnBoost/engine.io-protocol": "0.3.0", | ||
"visionmedia/debug": "*" | ||
@@ -8,0 +8,0 @@ }, |
@@ -733,3 +733,2 @@ ;(function(){ | ||
this.query = opts.query || {}; | ||
this.query.uid = rnd(); | ||
this.upgrade = false !== opts.upgrade; | ||
@@ -1189,12 +1188,2 @@ this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/'; | ||
/** | ||
* Generates a random uid. | ||
* | ||
* @api private | ||
*/ | ||
function rnd () { | ||
return String(Math.random()).substr(5) + String(Math.random()).substr(5); | ||
} | ||
}); | ||
@@ -2430,3 +2419,7 @@ require.register("engine.io/lib/transport.js", function(module, exports, require){ | ||
if (self.iframe) { | ||
self.form.removeChild(self.iframe); | ||
try { | ||
self.form.removeChild(self.iframe); | ||
} catch (e) { | ||
self.onError('jsonp polling iframe removal error', e); | ||
} | ||
} | ||
@@ -2909,2 +2902,2 @@ | ||
} | ||
})(); | ||
})(); |
0.5.0 / 2013-03-16 | ||
================== | ||
* socket: implement qs support for `string` | ||
* added query.EIO to take protocol version from parser | ||
* use istanbul for code coverage | ||
* integrated engine.io-protocol 0.3.0 | ||
* updated ws | ||
* fixed JSONPPolling iframe removal error | ||
* changed error message to match xhr error message on jsonp transport script tag | ||
* Added onerror handler for script tag in jsonp transport | ||
* remove uid qs | ||
* Added missing colon in payload. Thanks @lsm | ||
0.4.3 / 2013-02-08 | ||
@@ -3,0 +17,0 @@ ================== |
module.exports = process.env.EIO_COV | ||
? require('./lib-cov/') | ||
: require('./lib/'); | ||
module.exports = require('./lib/'); |
@@ -6,10 +6,4 @@ | ||
var Emitter; | ||
var Emitter = require('emitter'); | ||
try { | ||
Emitter = require('emitter'); | ||
} catch(e){ | ||
Emitter = require('emitter-component'); | ||
} | ||
/** | ||
@@ -44,11 +38,1 @@ * Module exports. | ||
Emitter.prototype.removeListener = Emitter.prototype.off; | ||
/** | ||
* Node-compatible `EventEmitter#removeAllListeners` | ||
* | ||
* @api public | ||
*/ | ||
Emitter.prototype.removeAllListeners = function(){ | ||
this._callbacks = {}; | ||
}; |
@@ -8,3 +8,4 @@ /** | ||
, Emitter = require('./emitter') | ||
, debug = require('debug')('engine-client:socket'); | ||
, debug = require('debug')('engine-client:socket') | ||
, parser = require('engine.io-parser'); | ||
@@ -46,2 +47,3 @@ /** | ||
opts.port = uri.port; | ||
if (uri.query) opts.query = uri.query; | ||
} | ||
@@ -64,3 +66,3 @@ | ||
this.query = opts.query || {}; | ||
this.query.uid = rnd(); | ||
if ('string' == typeof this.query) this.query = util.qsParse(this.query); | ||
this.upgrade = false !== opts.upgrade; | ||
@@ -94,3 +96,3 @@ this.path = (opts.path || '/engine.io').replace(/\/$/, '') + '/'; | ||
Socket.protocol = 1; | ||
Socket.protocol = parser.protocol; // this is an int | ||
@@ -127,7 +129,11 @@ /** | ||
var query = clone(this.query); | ||
// append engine.io protocol identifier | ||
query.EIO = parser.protocol; | ||
// transport name | ||
query.transport = name; | ||
if (this.id) { | ||
query.sid = this.id; | ||
} | ||
// session id if we already have one | ||
if (this.id) query.sid = this.id; | ||
@@ -508,3 +514,3 @@ var transport = new transports[name]({ | ||
* Filters upgrades, returning only those matching client transports. | ||
* | ||
* | ||
* @param {Array} server upgrades | ||
@@ -522,11 +528,1 @@ * @api private | ||
}; | ||
/** | ||
* Generates a random uid. | ||
* | ||
* @api private | ||
*/ | ||
function rnd () { | ||
return String(Math.random()).substr(5) + String(Math.random()).substr(5); | ||
} |
@@ -122,2 +122,3 @@ | ||
JSONPPolling.prototype.doPoll = function () { | ||
var self = this; | ||
var script = document.createElement('script'); | ||
@@ -132,2 +133,5 @@ | ||
script.src = this.uri(); | ||
script.onerror = function(e){ | ||
self.onError('jsonp poll error',e); | ||
} | ||
@@ -138,2 +142,3 @@ var insertAt = document.getElementsByTagName('script')[0]; | ||
if (util.ua.gecko) { | ||
@@ -189,3 +194,7 @@ setTimeout(function () { | ||
if (self.iframe) { | ||
self.form.removeChild(self.iframe); | ||
try { | ||
self.form.removeChild(self.iframe); | ||
} catch (e) { | ||
self.onError('jsonp polling iframe removal error', e); | ||
} | ||
} | ||
@@ -192,0 +201,0 @@ |
@@ -251,2 +251,5 @@ /** | ||
Request.prototype.cleanup = function(){ | ||
if ('undefined' == typeof this.xhr ) { | ||
return; | ||
} | ||
// xmlhttprequest | ||
@@ -253,0 +256,0 @@ this.xhr.onreadystatechange = empty; |
@@ -120,30 +120,33 @@ /** | ||
Polling.prototype.onData = function(data){ | ||
var self = this; | ||
debug('polling got data %s', data); | ||
// decode payload | ||
var packets = parser.decodePayload(data); | ||
for (var i = 0, l = packets.length; i < l; i++) { | ||
// if its the first message we consider the trnasport open | ||
if ('opening' == this.readyState) { | ||
this.onOpen(); | ||
parser.decodePayload(data, function(packet, index, total) { | ||
// if its the first message we consider the transport open | ||
if ('opening' == self.readyState) { | ||
self.onOpen(); | ||
} | ||
// if its a close packet, we close the ongoing requests | ||
if ('close' == packets[i].type) { | ||
this.onClose(); | ||
return; | ||
if ('close' == packet.type) { | ||
self.onClose(); | ||
return false; | ||
} | ||
// otherwise bypass onData and handle the message | ||
this.onPacket(packets[i]); | ||
} | ||
self.onPacket(packet); | ||
}); | ||
// if we got data we're not polling | ||
this.polling = false; | ||
this.emit('pollComplete'); | ||
// if an event did not trigger closing | ||
if ('closed' != this.readyState) { | ||
// if we got data we're not polling | ||
this.polling = false; | ||
this.emit('pollComplete'); | ||
if ('open' == this.readyState) { | ||
this.poll(); | ||
} else { | ||
debug('ignoring poll - transport state "%s"', this.readyState); | ||
if ('open' == this.readyState) { | ||
this.poll(); | ||
} else { | ||
debug('ignoring poll - transport state "%s"', this.readyState); | ||
} | ||
} | ||
@@ -150,0 +153,0 @@ }; |
@@ -111,8 +111,8 @@ /** | ||
var rvalidchars = /^[\],:{}\s]*$/ | ||
, rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g | ||
, rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g | ||
, rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g | ||
, rtrimLeft = /^\s+/ | ||
, rtrimRight = /\s+$/ | ||
var rvalidchars = /^[\],:{}\s]*$/; | ||
var rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g; | ||
var rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g; | ||
var rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g; | ||
var rtrimLeft = /^\s+/; | ||
var rtrimRight = /\s+$/; | ||
@@ -155,4 +155,5 @@ exports.parseJSON = function (data) { | ||
exports.ua.hasCORS = 'undefined' != typeof XMLHttpRequest && (function () { | ||
var a; | ||
try { | ||
var a = new XMLHttpRequest(); | ||
a = new XMLHttpRequest(); | ||
} catch (e) { | ||
@@ -268,3 +269,3 @@ return false; | ||
if (str.length) str += '&'; | ||
str += i + '=' + encodeURIComponent(obj[i]); | ||
str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]); | ||
} | ||
@@ -275,1 +276,18 @@ } | ||
}; | ||
/** | ||
* Parses a simple querystring. | ||
* | ||
* @param {String} qs | ||
* @api private | ||
*/ | ||
exports.qsParse = function(qs){ | ||
var qry = {}; | ||
var pairs = qs.split('&'); | ||
for (var i = 0, l = pairs.length; i < l; i++) { | ||
var pair = pairs[i].split('='); | ||
qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); | ||
} | ||
return qry; | ||
}; |
{ | ||
"name": "engine.io-client", | ||
"description": "Client for the realtime Engine", | ||
"version": "0.4.3", | ||
"version": "0.5.0", | ||
"homepage": "https://github.com/LearnBoost/engine.io-client", | ||
@@ -12,7 +12,7 @@ "contributors": [ | ||
"dependencies": { | ||
"ws": "0.4.20", | ||
"ws": "0.4.25", | ||
"xmlhttprequest": "1.5.0", | ||
"emitter-component": "0.0.6", | ||
"engine.io-parser": "0.1.1", | ||
"debug": "0.6.0" | ||
"emitter": "git://github.com/component/emitter#1.0.0", | ||
"engine.io-parser": "0.3.0", | ||
"debug": "0.7.2" | ||
}, | ||
@@ -23,3 +23,3 @@ "devDependencies": { | ||
"expect.js": "*", | ||
"browserbuild": "*" | ||
"istanbul": "*" | ||
}, | ||
@@ -26,0 +26,0 @@ "component": { |
@@ -148,2 +148,5 @@ # Engine.IO client | ||
These files can be found here | ||
[https://github.com/gimite/web-socket-js.git](https://github.com/gimite/web-socket-js.git) | ||
## Tests | ||
@@ -181,3 +184,3 @@ | ||
## License | ||
## License | ||
@@ -184,0 +187,0 @@ (The MIT License) |
@@ -130,3 +130,3 @@ # Engine.IO SPEC | ||
``` | ||
<length1><packet1>[<length2><packet2>[...]] | ||
<length1>:<packet1>[<length2>:<packet2>[...]] | ||
``` | ||
@@ -133,0 +133,0 @@ * length: length of the packet in __characters__ |
@@ -94,2 +94,14 @@ | ||
var packets, indices, totals; | ||
initCallback = function() { | ||
packets = []; indices = []; totals = []; | ||
} | ||
callback = function(packet, index, total) { | ||
packets.push(packet); | ||
indices.push(index); | ||
totals.push(total); | ||
} | ||
describe('payloads', function () { | ||
@@ -102,3 +114,5 @@ describe('basic functionality', function () { | ||
it('should decode payloads as arrays', function () { | ||
expect(decPayload(encPayload(['1:a', '2:b']))).to.be.an('array'); | ||
initCallback(); | ||
decPayload(encPayload(['1:a', '2:b']), callback) | ||
expect(packets).to.be.an('array'); | ||
}); | ||
@@ -109,9 +123,24 @@ }); | ||
it('should encode/decode packets', function () { | ||
expect(decPayload(encPayload([{ type: 'message', data: 'a' }]))) | ||
.to.eql([{ type: 'message', data: 'a' }]); | ||
initCallback(); | ||
decPayload(encPayload([{ type: 'message', data: 'a' }]), callback); | ||
expect(packets).to.eql([{ type: 'message', data: 'a' }]); | ||
}); | ||
it('should encode/decode empty payloads', function () { | ||
expect(decPayload(encPayload([]))).to.have.length(0); | ||
initCallback(); | ||
decPayload(encPayload([]), callback); | ||
expect(packets).to.have.length(0); | ||
expect(indices).to.have.length(0); | ||
expect(totals).to.have.length(0); | ||
}); | ||
it('should encode/decode multiple packets with correct indices/totals', function () { | ||
initCallback(); | ||
decPayload(encPayload([{ type: 'message', data: 'a' }, | ||
{ type: 'message', data: 'b' }, { type: 'message', data: 'c' }]), callback); | ||
expect(packets).to.eql([{ type: 'message', data: 'a' }, | ||
{ type: 'message', data: 'b' }, { type: 'message', data: 'c' }]); | ||
expect(indices).to.eql([ 3, 7, 11 ]); | ||
expect(totals).to.eql([ 12, 12, 12 ]); | ||
}); | ||
}); | ||
@@ -121,17 +150,34 @@ | ||
var err = [{ type: 'error', data: 'parser error' }]; | ||
it('should err on bad payload format', function () { | ||
initCallback(); | ||
decPayload('1!', callback) | ||
expect(packets).to.eql(err); | ||
it('should err on bad payload format', function () { | ||
expect(decPayload('1!')).to.eql(err); | ||
expect(decPayload('')).to.eql(err); | ||
expect(decPayload('))')).to.eql(err); | ||
initCallback(); | ||
decPayload('', callback); | ||
expect(packets).to.eql(err); | ||
initCallback(); | ||
decPayload('))', callback); | ||
expect(packets).to.eql(err); | ||
}); | ||
it('should err on bad payload length', function () { | ||
expect(decPayload('1:aa')).to.eql(err); | ||
expect(decPayload('1:')).to.eql(err); | ||
expect(decPayload('1:a2:b')).to.eql(err); | ||
initCallback(); | ||
decPayload('1:aa', callback); | ||
expect(packets).to.eql(err); | ||
initCallback(); | ||
decPayload('1:', callback); | ||
expect(packets).to.eql(err); | ||
initCallback(); | ||
decPayload('1:a2:b', callback); | ||
expect(packets).to.eql(err); | ||
}); | ||
it('should err on bad packet format', function () { | ||
expect(decPayload('3:99:')).to.eql(err); | ||
initCallback(); | ||
decPayload('3:99:', callback); | ||
expect(packets).to.eql(err); | ||
}); | ||
@@ -138,0 +184,0 @@ }); |
Sorry, the diff of this file is not supported yet
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
207
6
386293
37
12505
+ Addeddebug@0.7.2(transitive)
+ Addedengine.io-parser@0.3.0(transitive)
+ Addedws@0.4.25(transitive)
- Removedemitter-component@0.0.6
- Removeddebug@0.6.0(transitive)
- Removedemitter-component@0.0.6(transitive)
- Removedengine.io-parser@0.1.1(transitive)
- Removedws@0.4.20(transitive)
Updateddebug@0.7.2
Updatedengine.io-parser@0.3.0
Updatedws@0.4.25