New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

primus

Package Overview
Dependencies
Maintainers
5
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

primus - npm Package Compare versions

Comparing version 2.4.10 to 2.4.11

transformers/engine.io/patches/activex.patch

12

index.js

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

].forEach(function warn(line) {
console.error('primus: '+ line);
console.error('Primus: '+ line);
});

@@ -929,2 +929,12 @@ }

});
} else {
[
'',
'We\'ve detected that you are using the `destroy` method with the',
'`end` option set to `false`. This is deprecated and the ability to',
'leave the connections open will be removed in future releases.',
''
].forEach(function each(line) {
console.error('Primus: '+ line);
});
}

@@ -931,0 +941,0 @@

9

package.json
{
"name": "primus",
"version": "2.4.10",
"version": "2.4.11",
"description": "Primus is a simple abstraction around real-time frameworks. It allows you to easily switch between different frameworks without any code changes.",

@@ -57,3 +57,4 @@ "main": "index.js",

"load": "1.0.x",
"setheader": "0.0.x"
"setheader": "0.0.x",
"ultron": "1.0.x"
},

@@ -63,4 +64,7 @@ "devDependencies": {

"browserchannel": "2.0.x",
"browserify": "6.2.x",
"chai": "1.9.x",
"concat-stream": "1.4.x",
"derequire": "1.2.x",
"deumdify": "0.0.x",
"ejson": "1.0.x",

@@ -70,3 +74,2 @@ "engine.io": "1.4.x",

"faye-websocket": "0.7.x",
"global-wrap": "1.4.x",
"jsonh": "0.0.x",

@@ -73,0 +76,0 @@ "mocha": "2.0.x",

@@ -44,5 +44,6 @@ /*globals require, define */

if (!this._events || !this._events[event]) return [];
if (this._events[event].fn) return [this._events[event].fn];
for (var i = 0, l = this._events[event].length, ee = []; i < l; i++) {
ee.push(this._events[event][i].fn);
for (var i = 0, l = this._events[event].length, ee = new Array(l); i < l; i++) {
ee[i] = this._events[event][i].fn;
}

@@ -64,18 +65,16 @@

var listeners = this._events[event]
, length = listeners.length
, len = arguments.length
, ee = listeners[0]
, args
, i, j;
, i;
if (1 === length) {
if (ee.once) this.removeListener(event, ee.fn, true);
if ('function' === typeof listeners.fn) {
if (listeners.once) this.removeListener(event, listeners.fn, true);
switch (len) {
case 1: return ee.fn.call(ee.context), true;
case 2: return ee.fn.call(ee.context, a1), true;
case 3: return ee.fn.call(ee.context, a1, a2), true;
case 4: return ee.fn.call(ee.context, a1, a2, a3), true;
case 5: return ee.fn.call(ee.context, a1, a2, a3, a4), true;
case 6: return ee.fn.call(ee.context, a1, a2, a3, a4, a5), true;
case 1: return listeners.fn.call(listeners.context), true;
case 2: return listeners.fn.call(listeners.context, a1), true;
case 3: return listeners.fn.call(listeners.context, a1, a2), true;
case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
}

@@ -87,4 +86,7 @@

ee.fn.apply(ee.context, args);
listeners.fn.apply(listeners.context, args);
} else {
var length = listeners.length
, j;
for (i = 0; i < length; i++) {

@@ -119,5 +121,12 @@ if (listeners[i].once) this.removeListener(event, listeners[i].fn, true);

EventEmitter.prototype.on = function on(event, fn, context) {
var listener = new EE(fn, context || this);
if (!this._events) this._events = {};
if (!this._events[event]) this._events[event] = [];
this._events[event].push(new EE( fn, context || this ));
if (!this._events[event]) this._events[event] = listener;
else {
if (!this._events[event].fn) this._events[event].push(listener);
else this._events[event] = [
this._events[event], listener
];
}

@@ -136,5 +145,12 @@ return this;

EventEmitter.prototype.once = function once(event, fn, context) {
var listener = new EE(fn, context || this, true);
if (!this._events) this._events = {};
if (!this._events[event]) this._events[event] = [];
this._events[event].push(new EE(fn, context || this, true ));
if (!this._events[event]) this._events[event] = listener;
else {
if (!this._events[event].fn) this._events[event].push(listener);
else this._events[event] = [
this._events[event], listener
];
}

@@ -158,6 +174,11 @@ return this;

if (fn) for (var i = 0, length = listeners.length; i < length; i++) {
if (listeners[i].fn !== fn && listeners[i].once !== once) {
events.push(listeners[i]);
if (fn) {
if (listeners.fn && (listeners.fn !== fn || (once && !listeners.once))) {
events.push(listeners);
}
if (!listeners.fn) for (var i = 0, length = listeners.length; i < length; i++) {
if (listeners[i].fn !== fn || (once && !listeners[i].once)) {
events.push(listeners[i]);
}
}
}

@@ -168,4 +189,7 @@

//
if (events.length) this._events[event] = events;
else this._events[event] = null;
if (events.length) {
this._events[event] = events.length === 1 ? events[0] : events;
} else {
delete this._events[event];
}

@@ -184,3 +208,3 @@ return this;

if (event) this._events[event] = null;
if (event) delete this._events[event];
else this._events = {};

@@ -818,2 +842,10 @@

primus.end();
//
// It is certainly possible that we're in a reconnection loop and that the
// user goes offline. In this case we want to kill the existing attempt so
// when the user goes online, it will attempt to reconnect freshly again.
//
primus.clearTimeout('reconnect');
primus.attempt = null;
}

@@ -820,0 +852,0 @@

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

, forwarded = require('forwarded-for')
, Ultron = require('ultron')
, fuse = require('fusing')

@@ -38,11 +39,12 @@ , u2028 = /\u2028/g

writable('id', id); // Unique id for socket.
writable('primus', primus); // References to Primus.
writable('remote', address); // The remote address location.
writable('headers', headers); // The request headers.
writable('request', request); // Reference to an HTTP request.
writable('writable', true); // Silly stream compatibility.
writable('readable', true); // Silly stream compatibility.
writable('query', query); // The query string.
writable('timeout', null); // Heartbeat timeout.
writable('id', id); // Unique id for socket.
writable('primus', primus); // References to Primus.
writable('remote', address); // The remote address location.
writable('headers', headers); // The request headers.
writable('request', request); // Reference to an HTTP request.
writable('writable', true); // Silly stream compatibility.
writable('readable', true); // Silly stream compatibility.
writable('query', query); // The query string.
writable('timeout', null); // Heartbeat timeout.
writable('ultron', new Ultron(this)); // Our event listening cleanup.

@@ -177,2 +179,3 @@ //

var primus = this.primus
, ultron = this.ultron
, spark = this;

@@ -191,3 +194,3 @@

//
spark.on('incoming::data', function message(raw) {
ultron.on('incoming::data', function message(raw) {
//

@@ -220,3 +223,3 @@ // New data has arrived so we're certain that the connection is still alive,

//
spark.on('incoming::ping', function ping(time) {
ultron.on('incoming::ping', function ping(time) {
spark.emit('outgoing::pong', time);

@@ -229,3 +232,3 @@ spark._write('primus::pong::'+ time);

//
spark.on('incoming::end', function disconnect() {
ultron.on('incoming::end', function disconnect() {
//

@@ -238,3 +241,3 @@ // The socket is closed, sending data over it will throw an error.

spark.on('incoming::error', function error(err) {
ultron.on('incoming::error', function error(err) {
//

@@ -258,3 +261,3 @@ // Ensure that the error we emit is always an Error instance. There are

//
spark.on('end', function end() {
ultron.on('end', function end() {
clearTimeout(spark.timeout);

@@ -534,3 +537,5 @@ primus.emit('disconnection', spark);

this.emit('end');
return this.removeAllListeners();
this.ultron.destroy();
return this;
});

@@ -537,0 +542,0 @@

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

/**
* Minimum viable BrowserChannel client. This function is stringified and written in
* to our client side library.
* Minimum viable BrowserChannel client. This function is stringified and added
* in our client-side library.
*

@@ -17,3 +17,3 @@ * @runat client

//
// Selects an available BrowserChannel factory.
// Select an available BrowserChannel factory.
//

@@ -29,3 +29,6 @@ var Factory = (function factory() {

if (!Factory) return primus.critical(new Error('Missing required `browserchannel` module. Please run `npm install --save browserchannel`'));
if (!Factory) return primus.critical(new Error(
'Missing required `browserchannel` module. ' +
'Please run `npm install --save browserchannel`'
));

@@ -36,3 +39,3 @@ //

primus.on('outgoing::open', function connect() {
if (socket) socket.close();
primus.emit('outgoing::end');

@@ -42,4 +45,7 @@ var url = primus.uri({ protocol: 'http' });

primus.socket = socket = new Factory(url, primus.merge(primus.transport, {
extraParams: primus.querystring(primus.uri({ protocol: 'http', query: true }).replace(url, '')),
reconnect: false,
extraParams: primus.querystring(primus.uri({
protocol: 'http',
query: true
}).replace(url, '')),
reconnect: false
}));

@@ -66,7 +72,5 @@

//
// Attempt to reconnect the socket. It assumes that the `close` event is
// called if it failed to disconnect.
// Attempt to reconnect the socket.
//
primus.on('outgoing::reconnect', function reconnect() {
if (socket) socket.close();
primus.emit('outgoing::open');

@@ -79,19 +83,20 @@ });

primus.on('outgoing::end', function close() {
if (socket) {
//
// Bug: BrowserChannel cannot close the connection if it's already
// connecting. By passing behaviour by checking the readyState and defer
// the close call.
//
if (socket.readyState === socket.CONNECTING) {
return socket.onopen = function onopen() {
primus.emit('outgoing::end');
};
}
if (!socket) return;
socket.onerror = socket.onopen = socket.onclose = socket.onmessage = function () {};
socket.onerror = socket.onopen = socket.onclose = socket.onmessage = function () {};
//
// Bug: BrowserChannel cannot close the connection if it's already
// connecting. Bypass this behaviour by checking the readyState and
// defer the close call.
//
if (socket.readyState === socket.CONNECTING) {
socket.onopen = function onopen() {
this.close();
};
} else {
socket.close();
socket = null;
}
socket = null;
});
};

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

/**
* Minimum viable WebSocket client. This function is stringified and written in
* to our client side library.
* Minimum viable Engine.IO client. This function is stringified and added in
* our client-side library.
*

@@ -13,7 +13,11 @@ * @runat client

module.exports = function client() {
var primus = this
var onmessage = this.emits('data')
, onerror = this.emits('error')
, onopen = this.emits('open')
, onclose = this.emits('end')
, primus = this
, socket;
//
// Selects an available Engine.IO factory.
// Select an available Engine.IO factory.
//

@@ -29,3 +33,6 @@ var factory = (function factory() {

if (!factory) return primus.critical(new Error('Missing required `engine.io-client` module. Please run `npm install --save engine.io-client`'));
if (!factory) return primus.critical(new Error(
'Missing required `engine.io-client` module. ' +
'Please run `npm install --save engine.io-client`'
));

@@ -86,6 +93,6 @@ //

//
socket.on('open', primus.emits('open'));
socket.on('error', primus.emits('error'));
socket.on('close', primus.emits('end'));
socket.on('message', primus.emits('data'));
socket.on('message', onmessage);
socket.on('error', onerror);
socket.on('close', onclose);
socket.on('open', onopen);
});

@@ -101,12 +108,6 @@

//
// Attempt to reconnect the socket. It assumes that the `close` event is
// called if it failed to disconnect.
// Attempt to reconnect the socket.
//
primus.on('outgoing::reconnect', function reconnect() {
if (socket) {
socket.close();
socket.open();
} else {
primus.emit('outgoing::open');
}
primus.emit('outgoing::open');
});

@@ -118,8 +119,11 @@

primus.on('outgoing::end', function close() {
if (socket) {
socket.removeAllListeners();
socket.close();
socket = null;
}
if (!socket) return;
socket.removeListener('message', onmessage);
socket.removeListener('error', onerror);
socket.removeListener('close', onclose);
socket.removeListener('open', onopen);
socket.close();
socket = null;
});
};

@@ -24,6 +24,6 @@ # Transformer: Engine.IO

We cannot depend on the `engine.io.js` file since it is compiled as a UMD
bundle that doesn't works with Primus when using RequireJS. To compile
engine.io correctly use the `update.sh` utility which builds the library using
the [`global-wrap`](https://github.com/domenic/global-wrap) module.
We cannot depend on the `engine.io.js` file because it uses a UMD wrapper
that doesn't work with Primus when using RequireJS. To compile the
`engine.io-client` correctly use the `update.sh` utility which will build the
library and expose it as a property of the global object.
The steps required are the following:

@@ -30,0 +30,0 @@

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

/**
* Minimum viable WebSocket client. This function is stringified and written in
* to our client side library.
* Minimum viable Faye-WebSocket client. This function is stringified and
* added in our client-side library.
*

@@ -17,3 +17,3 @@ * @runat client

//
// Selects an available WebSocket constructor.
// Select an available Faye-WebSocket factory.
//

@@ -30,3 +30,6 @@ var Factory = (function factory() {

if (!Factory) return primus.critical(new Error('Missing required `faye-websocket` module. Please run `npm install --save faye-websocket`'));
if (!Factory) return primus.critical(new Error(
'Missing required `faye-websocket` module. ' +
'Please run `npm install --save faye-websocket`'
));

@@ -38,3 +41,3 @@

primus.on('outgoing::open', function opening() {
if (socket) socket.close();
primus.emit('outgoing::end');

@@ -59,3 +62,6 @@ //

} else {
primus.socket = socket = new Factory(primus.uri({ protocol: 'ws', query: true }));
primus.socket = socket = new Factory(primus.uri({
protocol: 'ws',
query: true
}));
}

@@ -87,7 +93,5 @@ } catch (e) { return primus.emit('error', e); }

//
// Attempt to reconnect the socket. It assumes that the `outgoing::end` event is
// called if it failed to disconnect.
// Attempt to reconnect the socket.
//
primus.on('outgoing::reconnect', function reconnect() {
if (socket) primus.emit('outgoing::end');
primus.emit('outgoing::open');

@@ -100,8 +104,8 @@ });

primus.on('outgoing::end', function close() {
if (socket) {
socket.onerror = socket.onopen = socket.onclose = socket.onmessage = null;
socket.close();
socket = null;
}
if (!socket) return;
socket.onerror = socket.onopen = socket.onclose = socket.onmessage = function () {};
socket.close();
socket = null;
});
};

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

/**
* Minimum viable Socket.IO client. This function is stringified and written in
* to our client side library.
* Minimum viable Socket.IO client. This function is stringified and added
* in our client-side library.
*

@@ -13,7 +13,11 @@ * @runat client

module.exports = function client() {
var primus = this
var ondisconnect = this.emits('end')
, onconnect = this.emits('open')
, onmessage = this.emits('data')
, onerror = this.emits('error')
, primus = this
, socket;
//
// Selects an available Socket.IO constructor.
// Select an available Socket.IO factory.
//

@@ -29,3 +33,6 @@ var factory = (function factory() {

if (!factory) return primus.critical(new Error('Missing required `socket.io-client` module. Please run `npm install --save socket.io-client`'));
if (!factory) return primus.critical(new Error(
'Missing required `socket.io-client` module. ' +
'Please run `npm install --save socket.io-client`'
));

@@ -63,7 +70,7 @@ //

//
socket.on('error', primus.emits('error'));
socket.on('connect', primus.emits('open'));
socket.on('message', primus.emits('data'));
socket.on('disconnect', primus.emits('end'));
socket.on('connect_failed', primus.emits('error'));
socket.on('disconnect', ondisconnect);
socket.on('connect_failed', onerror);
socket.on('connect', onconnect);
socket.on('message', onmessage);
socket.on('error', onerror);
});

@@ -79,14 +86,6 @@

//
// Attempt to reconnect the socket. It assumes that the `close` event is
// called if it failed to disconnect. Bypass the namespaces and use
// socket.socket.
// Attempt to reconnect the socket.
//
primus.on('outgoing::reconnect', function reconnect() {
try {
socket.socket.disconnect();
socket.connected = socket.socket.connecting = socket.socket.reconnecting = false;
socket.socket.connect();
} catch (e) {
primus.emit('outgoing::open');
}
primus.emit('outgoing::open');
});

@@ -99,14 +98,18 @@

primus.on('outgoing::end', function close() {
if (socket) {
socket.removeAllListeners();
if (!socket) return;
//
// This method can throw an error if it failed to connect to the server.
//
try { socket.socket.disconnect(); }
catch (e) {}
socket.removeListener('disconnect', ondisconnect);
socket.removeListener('connect_failed', onerror);
socket.removeListener('connect', onconnect);
socket.removeListener('message', onmessage);
socket.removeListener('error', onerror);
socket = null;
}
//
// This method can throw an error if it failed to connect to the server.
//
try { socket.socket.disconnect(); }
catch (e) {}
socket = null;
});
};

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

/**
* Minimum viable SockJS client. This function is stringified and written in
* to our client side library.
* Minimum viable SockJS client. This function is stringified and added
* in our client-side library.
*

@@ -17,3 +17,3 @@ * @runat client

//
// Selects an available Engine.IO factory.
// Select an available SockJS factory.
//

@@ -29,3 +29,6 @@ var Factory = (function Factory() {

if (!Factory) return primus.critical(new Error('Missing required `sockjs-client-node` module. Please run `npm install --save sockjs-client-node`'));
if (!Factory) return primus.critical(new Error(
'Missing required `sockjs-client-node` module. ' +
'Please run `npm install --save sockjs-client-node`'
));

@@ -76,7 +79,5 @@ //

//
// Attempt to reconnect the socket. It assumes that the `outgoing::end` event is
// called if it failed to disconnect.
// Attempt to reconnect the socket.
//
primus.on('outgoing::reconnect', function reconnect() {
primus.emit('outgoing::end');
primus.emit('outgoing::open');

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

primus.on('outgoing::end', function close() {
if (socket) {
socket.onerror = socket.onopen = socket.onclose = socket.onmessage = function () {};
socket.close();
socket = null;
}
if (!socket) return;
socket.onerror = socket.onopen = socket.onclose = socket.onmessage = function () {};
socket.close();
socket = null;
});
};

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

/**
* Minimum viable WebSocket client. This function is stringified and written in
* to our client side library.
* Minimum viable WebSocket client. This function is stringified and added
* in our client-side library.
*

@@ -17,3 +17,3 @@ * @runat client

//
// Selects an available WebSocket constructor.
// Select an available WebSocket factory.
//

@@ -30,3 +30,5 @@ var Factory = (function factory() {

if (!Factory) return primus.critical(new Error('Missing required `ws` module. Please run `npm install --save ws`'));
if (!Factory) return primus.critical(new Error(
'Missing required `ws` module. Please run `npm install --save ws`'
));

@@ -61,3 +63,6 @@

} else {
primus.socket = socket = new Factory(primus.uri({ protocol: prot, query: qsa }));
primus.socket = socket = new Factory(primus.uri({
protocol: prot,
query: qsa
}));
}

@@ -89,7 +94,5 @@ } catch (e) { return primus.emit('error', e); }

//
// Attempt to reconnect the socket. It assumes that the `outgoing::end` event is
// called if it failed to disconnect.
// Attempt to reconnect the socket.
//
primus.on('outgoing::reconnect', function reconnect() {
primus.emit('outgoing::end');
primus.emit('outgoing::open');

@@ -102,8 +105,8 @@ });

primus.on('outgoing::end', function close() {
if (socket) {
socket.onerror = socket.onopen = socket.onclose = socket.onmessage = function () {};
socket.close();
socket = null;
}
if (!socket) return;
socket.onerror = socket.onopen = socket.onclose = socket.onmessage = function () {};
socket.close();
socket = null;
});
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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