socketio-jwt
Advanced tools
Comparing version 4.2.1 to 4.3.0
@@ -10,7 +10,7 @@ var xtend = require('xtend'); | ||
return function (socket) { | ||
var server = this; | ||
var server = this.server || socket.server; | ||
if (!server.$emit) { | ||
//then is socket.io 1.0 | ||
var Namespace = Object.getPrototypeOf(server.server.sockets).constructor; | ||
var Namespace = Object.getPrototypeOf(server.sockets).constructor; | ||
if (!~Namespace.events.indexOf('authenticated')) { | ||
@@ -57,3 +57,9 @@ Namespace.events.push('authenticated'); | ||
} else { | ||
server.server.sockets.emit('authenticated', socket); | ||
//try getting the current namespace otherwise fallback to all sockets. | ||
var namespace = (server.nsps && socket.nsp && | ||
server.nsps[socket.nsp.name]) || | ||
server.sockets; | ||
// explicit namespace | ||
namespace.emit('authenticated', socket); | ||
} | ||
@@ -60,0 +66,0 @@ }; |
{ | ||
"name": "socketio-jwt", | ||
"version": "4.2.1", | ||
"version": "4.3.0", | ||
"description": "authenticate socket.io connections using JWTs", | ||
@@ -34,2 +34,3 @@ "main": "lib/index.js", | ||
"request": "~2.19.0", | ||
"server-destroy": "~1.0.1", | ||
"should": "~1.2.2", | ||
@@ -36,0 +37,0 @@ "socket.io": "^1.0.4", |
@@ -19,4 +19,6 @@ var fixture = require('./fixture'); | ||
it('should close the connection after a timeout if no auth message is received', function (done){ | ||
var socket = io.connect('http://localhost:9000'); | ||
socket.on('disconnect', function () { | ||
var socket = io.connect('http://localhost:9000', { | ||
forceNew: true | ||
}); | ||
socket.once('disconnect', function () { | ||
done(); | ||
@@ -23,0 +25,0 @@ }); |
@@ -12,2 +12,3 @@ var express = require('express'); | ||
var server, sio; | ||
var enableDestroy = require('server-destroy'); | ||
@@ -53,7 +54,4 @@ exports.start = function (options, callback) { | ||
if (options.handshake) { | ||
// this.set('authorization', socketio_jwt.authorize(options)); | ||
sio.use(socketio_jwt.authorize(options)); | ||
} | ||
if (options.handshake) { | ||
sio.sockets.on('echo', function (m) { | ||
@@ -77,2 +75,3 @@ sio.sockets.emit('echo-response', m); | ||
server.listen(9000, callback); | ||
enableDestroy(server); | ||
}; | ||
@@ -82,3 +81,4 @@ | ||
sio.close(); | ||
server.destroy(); | ||
callback(); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24804
16
454
9
3