Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

socketio-jwt

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

socketio-jwt - npm Package Compare versions

Comparing version 4.2.1 to 4.3.0

test/authorizer_namespaces.test.js

12

lib/index.js

@@ -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();
};
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