Socket
Socket
Sign inDemoInstall

sockjs

Package Overview
Dependencies
68
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.3 to 0.3.4

8

lib/sockjs.js

@@ -30,10 +30,10 @@ (function() {

sockjsVersion = function() {
var package;
var pkg;
try {
package = fs.readFileSync(__dirname + '/../package.json', 'utf-8');
pkg = fs.readFileSync(__dirname + '/../package.json', 'utf-8');
} catch (x) {
}
if (package) {
return JSON.parse(package).version;
if (pkg) {
return JSON.parse(pkg).version;
} else {

@@ -40,0 +40,0 @@ return null;

@@ -35,3 +35,3 @@ (function() {

res.write('\r\n');
transport.register(req, this, new EventSourceReceiver(res, this.options));
transport.register(req, this, new EventSourceReceiver(req, res, this.options));
return true;

@@ -38,0 +38,0 @@ }

@@ -53,3 +53,3 @@ (function() {

res.write(iframe_template.replace(/{{ callback }}/g, callback));
transport.register(req, this, new HtmlFileReceiver(res, this.options));
transport.register(req, this, new HtmlFileReceiver(req, res, this.options));
return true;

@@ -56,0 +56,0 @@ }

@@ -16,5 +16,5 @@ (function() {

function JsonpReceiver(res, options, callback) {
function JsonpReceiver(req, res, options, callback) {
this.callback = callback;
JsonpReceiver.__super__.constructor.call(this, res, options);
JsonpReceiver.__super__.constructor.call(this, req, res, options);
}

@@ -48,3 +48,3 @@

res.writeHead(200);
transport.register(req, this, new JsonpReceiver(res, this.options, callback));
transport.register(req, this, new JsonpReceiver(req, res, this.options, callback));
return true;

@@ -63,3 +63,3 @@ },

d = JSON.parse(query);
} catch (e) {
} catch (x) {
throw {

@@ -76,3 +76,3 @@ status: 500,

d = JSON.parse(d);
} catch (e) {
} catch (x) {
throw {

@@ -79,0 +79,0 @@ status: 500,

@@ -123,3 +123,3 @@ (function() {

return true;
} catch (e) {
} catch (x) {

@@ -193,3 +193,3 @@ }

RawWebsocketSessionReceiver.prototype.didClose = function() {
if (this.ws) return;
if (!this.ws) return;
this.ws.removeEventListener('message', this._message_cb);

@@ -202,3 +202,7 @@ this.ws.removeEventListener('close', this._end_cb);

}
return this.ws = null;
this.ws = null;
this.readyState = Transport.CLOSED;
this.connection.emit('end');
this.connection.emit('close');
return this.connection = null;
};

@@ -205,0 +209,0 @@

@@ -61,3 +61,3 @@ (function() {

d = JSON.parse(data);
} catch (e) {
} catch (x) {
throw {

@@ -105,3 +105,3 @@ status: 500,

res.writeHead(200);
transport.register(req, this, new XhrPollingReceiver(res, this.options));
transport.register(req, this, new XhrPollingReceiver(req, res, this.options));
return true;

@@ -113,3 +113,3 @@ },

res.write(Array(2049).join('h') + '\n');
transport.register(req, this, new XhrStreamingReceiver(res, this.options));
transport.register(req, this, new XhrStreamingReceiver(req, res, this.options));
return true;

@@ -116,0 +116,0 @@ }

@@ -140,11 +140,14 @@ (function() {

Session.prototype.decorateConnection = function(req) {
var headers, key, socket, _i, _len, _ref;
var address, headers, key, remoteAddress, remotePort, socket, _i, _len, _ref;
if (!(socket = this.recv.connection)) socket = this.recv.response.connection;
this.connection.remoteAddress = socket.remoteAddress;
this.connection.remotePort = socket.remotePort;
try {
this.connection.address = socket.address();
} catch (e) {
this.connection.address = {};
remoteAddress = socket.remoteAddress;
remotePort = socket.remotePort;
address = socket.address();
} catch (x) {
return;
}
this.connection.remoteAddress = remoteAddress;
this.connection.remotePort = remotePort;
this.connection.address = address;
this.connection.url = req.url;

@@ -227,3 +230,3 @@ this.connection.pathname = req.pathname;

this.recv.doSendFrame(this.close_frame);
this.recv.didClose();
if (this.recv) this.recv.didClose();
if (this.recv) this.unregister();

@@ -319,3 +322,4 @@ }

function ResponseReceiver(response, options) {
function ResponseReceiver(request, response, options) {
this.request = request;
this.response = response;

@@ -325,7 +329,7 @@ this.options = options;

try {
this.response.connection.setKeepAlive(true, 5000);
this.request.connection.setKeepAlive(true, 5000);
} catch (x) {
}
ResponseReceiver.__super__.constructor.call(this, this.response.connection);
ResponseReceiver.__super__.constructor.call(this, this.request.connection);
if (this.max_response_size === void 0) {

@@ -332,0 +336,0 @@ this.max_response_size = this.options.response_limit;

@@ -9,3 +9,3 @@ (function() {

} catch (x) {
null;
}

@@ -32,3 +32,3 @@

} catch (x) {
null;
}

@@ -159,4 +159,4 @@ return false;

if (rbytes) {
x = rbytes.randomBytes(4);
v = [x[0], x[1], x[2], x[3]];
foo = rbytes.randomBytes(4);
v = [foo[0], foo[1], foo[2], foo[3]];
} else {

@@ -168,6 +168,5 @@ foo = function() {

}
x = v[0] + (v[1] * 256) + (v[2] * 256 * 256) + (v[3] * 256 * 256 * 256);
return x;
return v[0] + (v[1] * 256) + (v[2] * 256 * 256) + (v[3] * 256 * 256 * 256);
};
}).call(this);

@@ -57,9 +57,9 @@ (function() {

res.write(r.join('\r\n'));
} catch (e) {
null;
} catch (x) {
}
try {
return res.end();
} catch (e) {
return null;
} catch (x) {
}

@@ -141,3 +141,3 @@ };

res.end("500 - Internal Server Error");
} catch (y) {
} catch (x) {

@@ -144,0 +144,0 @@ }

{
"name" : "sockjs",
"author" : "Marek Majkowski",
"version" : "0.3.3",
"version" : "0.3.4",
"description" : "SockJS-node is a server counterpart of SockJS-client a JavaScript library that provides a WebSocket-like object in the browser. SockJS gives you a coherent, cross-browser, Javascript API which creates a low latency, full duplex, cross-domain communication channel between the browser and the web server.",

@@ -15,5 +15,2 @@ "keywords" : ["websockets", "websocket"],

},
"optionalDependencies": {
"rbytes" : "0.0.2"
},
"devDependencies": {

@@ -20,0 +17,0 @@ "coffee-script" : "1.2.x"

@@ -14,3 +14,3 @@ SockJS family:

* [SockJS-netty](https://github.com/cgbystrom/sockjs-netty)
* [SockJS-gevent](https://github.com/sdiehl/sockjs-gevent)
* [SockJS-gevent](https://github.com/sdiehl/sockjs-gevent) ([and a fork](https://github.com/njoyce/sockjs-gevent))
* [pyramid-SockJS](https://github.com/fafhrd91/pyramid_sockjs)

@@ -43,4 +43,8 @@ * [wildcloud-websockets](https://github.com/wildcloud/wildcloud-websockets)

(If you see `rbytes` dependecy failing, don't worry, it's optional, SockJS-node will work fine without it.)
For additional security (true random numbers) you might want to
install `rbytes` package - SockJS will use it if available:
npm install rbytes
An simplified echo SockJS server could look more or less like:

@@ -47,0 +51,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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