Socket
Socket
Sign inDemoInstall

require-analyzer

Package Overview
Dependencies
102
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.0-1 to 0.4.0-2

.npmignore

62

lib/require-analyzer.js

@@ -302,3 +302,5 @@ /*

analyzer.package = function (options, callback) {
var pkgDeps = {};
var deps = {},
pkgDeps = {},
devDeps = {};
//

@@ -335,3 +337,3 @@ // Attempt to read the package.json in the current directory

function dequeue (err) {
function dequeue(err) {
todo--;

@@ -343,3 +345,3 @@ if (todo === 0) {

function processOptions (options) {
function processOptions(options) {
todo++;

@@ -385,12 +387,50 @@

var newoptions = analyzer.clone(options);
try {
newoptions.target = require.resolve(path.join(newoptions.target, path.normalize(pkg.main || '/')));
function setMain(files, pkg, newoptions, callback) {
var file=null;
function nextFile() {
file = files.shift();
if (typeof file === 'undefined') {
return callback(pkg, newoptions);
}
checkFile(file);
}
function checkFile(file) {
path.exists(file, fileExists)
}
function fileExists(exists) {
if (exists) {
pkg.main=file;
return callback(pkg, newoptions);
}
nextFile();
}
nextFile();
return;
}
catch (e) {
todo = 1;
deps = null;
dequeue(e);
function setTarget(pkg, newoptions) {
try {
newoptions.target = require.resolve(path.join(newoptions.target, path.normalize(pkg.main || '/')));
}
catch (e) {
todo = 1;
deps = null;
dequeue(e);
}
return processOptions(newoptions);
}
processOptions(newoptions);
//add logic to default to app.js or server.js for main if main is not present.
if (typeof pkg.main === 'undefined' || pkg.main === '') {
var files=["app.js", "server.js", "index.js"]
setMain(files, pkg, newoptions, setTarget);
}
else {
setTarget(pkg, newoptions);
}
}

@@ -397,0 +437,0 @@ catch (ex) {

2

package.json
{
"name": "require-analyzer",
"description": "Determine dependencies for a given node.js file, directory tree, or module in code or on the command line",
"version": "0.4.0-1",
"version": "0.4.0-2",
"author": "Charlie Robbins <charlie.robbins@gmail.com>",

@@ -6,0 +6,0 @@ "contributors": [

@@ -1,9 +0,2 @@

/**
* Bootstrap app.
*/
require.paths.unshift(__dirname + '/../../lib/');
/**
* Module dependencies.

@@ -15,3 +8,3 @@ */

, nib = require('nib')
, sio = require('socket.io');
, sio = require('../../lib/socket.io');

@@ -29,3 +22,3 @@ /**

app.configure(function () {
app.use(stylus.middleware({ src: __dirname + '/public', compile: compile }))
app.use(stylus.middleware({ src: __dirname + '/public', compile: compile }));
app.use(express.static(__dirname + '/public'));

@@ -32,0 +25,0 @@ app.set('views', __dirname);

@@ -6,7 +6,7 @@ {

, "dependencies": {
"express": "2.3.11"
, "jade": "0.12.1"
, "stylus": "0.13.3"
, "nib": "0.0.8"
"express": "2.5.0"
, "jade": "0.16.4"
, "stylus": "0.19.0"
, "nib": "0.2.0"
}
}

@@ -1,9 +0,2 @@

/**
* Bootstrap app.
*/
require.paths.unshift(__dirname + '/../../lib/');
/**
* Module dependencies.

@@ -15,3 +8,3 @@ */

, nib = require('nib')
, sio = require('socket.io')
, sio = require('../../lib/socket.io')
, irc = require('./irc');

@@ -18,0 +11,0 @@

@@ -5,3 +5,3 @@ /**

var sys = require('sys');
var sys = require('util');
var tcp = require('net');

@@ -8,0 +8,0 @@ var irc = exports;

@@ -5,7 +5,7 @@ {

, "dependencies": {
"express": "2.3.11"
, "jade": "0.12.1"
, "stylus": "0.13.3"
, "nib": "0.0.8"
"express": "2.5.0"
, "jade": "0.16.4"
, "stylus": "0.19.0"
, "nib": "0.2.0"
}
}
0.8.7 / 2011-11-05
==================
* Fixed memory leaks in closed clients.
* Fixed memory leaks in namespaces.
* Fixed websocket handling for malformed requests from proxies. [einaros]
* Node 0.6 compatibility. [einaros] [3rd-Eden]
* Adapted tests and examples.
0.8.6 / 2011-10-27
==================
* Added JSON decoding on jsonp-polling transport.
* Fixed README example.
* Major speed optimizations [3rd-Eden] [einaros] [visionmedia]
* Added decode/encode benchmarks [visionmedia]
* Added support for black-listing client sent events.
* Fixed logging options, closes #540 [3rd-Eden]
* Added vary header for gzip [3rd-Eden]
* Properly cleaned up async websocket / flashsocket tests, after patching node-websocket-client
* Patched to properly shut down when a finishClose call is made during connection establishment
* Added support for socket.io version on url and far-future Expires [3rd-Eden] [getify]
* Began IE10 compatibility [einaros] [tbranyen]
* Misc WebSocket fixes [einaros]
* Added UTF8 to respone headers for htmlfile [3rd-Eden]
0.8.5 / 2011-10-07

@@ -3,0 +29,0 @@ ==================

@@ -63,2 +63,3 @@

this.level = 3;
this.enabled = true;
};

@@ -75,3 +76,3 @@

if (index > this.level)
if (index > this.level || !this.enabled)
return this;

@@ -78,0 +79,0 @@

@@ -70,3 +70,5 @@ /*!

, authorization: false
, blacklist: ['disconnect']
, 'log level': 3
, 'log colors': true
, 'close timeout': 25

@@ -83,2 +85,3 @@ , 'heartbeat timeout': 15

, 'browser client etag': false
, 'browser client expires': 315360000
, 'browser client gzip': false

@@ -95,2 +98,7 @@ , 'browser client handler': false

// default error handler
server.on('error', function(err) {
self.log.warn('error raised: ' + err);
});
this.initStore();

@@ -152,6 +160,7 @@

Manager.prototype.__defineGetter__('log', function () {
if (this.disabled('log')) return;
var logger = this.get('logger');
var logger = this.get('logger');
logger.level = this.get('log level') || -1;
logger.colors = this.get('log colors');
logger.enabled = this.enabled('log');

@@ -265,3 +274,2 @@ return logger;

this.closed = {};
this.closedA = [];
this.rooms = {};

@@ -338,4 +346,2 @@ this.roomClients = {};

this.closedA.splice(this.closedA.indexOf(id), 1);
this.store.unsubscribe('dispatch:' + id, function () {

@@ -429,3 +435,2 @@ delete self.closed[id];

this.closed[id] = [];
this.closedA.push(id);

@@ -473,5 +478,3 @@ var self = this;

for (var name in this.namespaces) {
if (this.roomClients[id][name]) {
this.namespaces[name].handleDisconnect(id, reason);
}
this.namespaces[name].handleDisconnect(id, reason, typeof this.roomClients[id][name] !== 'undefined');
}

@@ -506,3 +509,2 @@

delete this.closed[id];
this.closedA.splice(this.closedA.indexOf(id), 1);
}

@@ -509,0 +511,0 @@

@@ -37,3 +37,3 @@ /**

/**
* Copies emit since we override it
* Copies emit since we override it.
*

@@ -107,3 +107,3 @@ * @api private

/**
* Overrides the room to relay messages to (flag)
* Overrides the room to relay messages to (flag).
*

@@ -119,3 +119,3 @@ * @api public

/**
* Adds a session id we should prevent relaying messages to (flag)
* Adds a session id we should prevent relaying messages to (flag).
*

@@ -145,3 +145,3 @@ * @api public

/**
* Sends out a packet
* Sends out a packet.
*

@@ -182,5 +182,5 @@ * @api private

/**
* Emits to everyone (override)
* Emits to everyone (override).
*
* @api private
* @api public
*/

@@ -204,3 +204,3 @@

* @param {Boolean} whether the socket will be readable when initialized
* @api private
* @api public
*/

@@ -217,3 +217,3 @@

/**
* Sets authorization for this namespace
* Sets authorization for this namespace.
*

@@ -234,5 +234,5 @@ * @api public

SocketNamespace.prototype.handleDisconnect = function (sid, reason) {
SocketNamespace.prototype.handleDisconnect = function (sid, reason, raiseOnDisconnect) {
if (this.sockets[sid] && this.sockets[sid].readable) {
this.sockets[sid].onDisconnect(reason);
if (raiseOnDisconnect) this.sockets[sid].onDisconnect(reason);
delete this.sockets[sid];

@@ -275,2 +275,3 @@ }

, dataAck = packet.ack == 'data'
, manager = this.manager
, self = this;

@@ -308,4 +309,3 @@

} else {
var manager = this.manager
, handshakeData = manager.handshaken[sessid];
var handshakeData = manager.handshaken[sessid];

@@ -335,9 +335,14 @@ this.authorize(handshakeData, function (err, authorized, newData) {

case 'event':
var params = [packet.name].concat(packet.args);
// check if the emitted event is not blacklisted
if (-~manager.get('blacklist').indexOf(packet.name)) {
this.log.debug('ignoring blacklisted event `' + packet.name + '`');
} else {
var params = [packet.name].concat(packet.args);
if (dataAck) {
params.push(ack);
if (dataAck) {
params.push(ack);
}
socket.$emit.apply(socket, params);
}
socket.$emit.apply(socket, params);
break;

@@ -344,0 +349,0 @@

@@ -16,13 +16,14 @@

var packets = exports.packets = [
'disconnect'
, 'connect'
, 'heartbeat'
, 'message'
, 'json'
, 'event'
, 'ack'
, 'error'
, 'noop'
];
var packets = exports.packets = {
'disconnect': 0
, 'connect': 1
, 'heartbeat': 2
, 'message': 3
, 'json': 4
, 'event': 5
, 'ack': 6
, 'error': 7
, 'noop': 8
}
, packetslist = Object.keys(packets);

@@ -33,7 +34,8 @@ /**

var reasons = exports.reasons = [
'transport not supported'
, 'client not handshaken'
, 'unauthorized'
];
var reasons = exports.reasons = {
'transport not supported': 0
, 'client not handshaken': 1
, 'unauthorized': 2
}
, reasonslist = Object.keys(reasons);

@@ -44,5 +46,6 @@ /**

var advice = exports.advice = [
'reconnect'
];
var advice = exports.advice = {
'reconnect': 0
}
, advicelist = Object.keys(advice);

@@ -56,3 +59,3 @@ /**

exports.encodePacket = function (packet) {
var type = packets.indexOf(packet.type)
var type = packets[packet.type]
, id = packet.id || ''

@@ -64,11 +67,2 @@ , endpoint = packet.endpoint || ''

switch (packet.type) {
case 'error':
var reason = packet.reason ? reasons.indexOf(packet.reason) : ''
, adv = packet.advice ? advice.indexOf(packet.advice) : ''
if (reason !== '' || adv !== '')
data = reason + (adv !== '' ? ('+' + adv) : '')
break;
case 'message':

@@ -93,2 +87,8 @@ if (packet.data !== '')

case 'ack':
data = packet.ackId
+ (packet.args && packet.args.length
? '+' + JSON.stringify(packet.args) : '');
break;
case 'connect':

@@ -99,6 +99,9 @@ if (packet.qs)

case 'ack':
data = packet.ackId
+ (packet.args && packet.args.length
? '+' + JSON.stringify(packet.args) : '');
case 'error':
var reason = packet.reason ? reasons[packet.reason] : ''
, adv = packet.advice ? advice[packet.advice] : ''
if (reason !== '' || adv !== '')
data = reason + (adv !== '' ? ('+' + adv) : '')
break;

@@ -108,13 +111,9 @@ }

// construct packet with required fragments
var encoded = [
type
, id + (ack == 'data' ? '+' : '')
, endpoint
];
var encoded = type + ':' + id + (ack == 'data' ? '+' : '') + ':' + endpoint;
// data fragment is optional
if (data !== null && data !== undefined)
encoded.push(data);
encoded += ':' + data;
return encoded.join(':');
return encoded;
};

@@ -151,2 +150,14 @@

/**
* Wrap the JSON.parse in a seperate function the crankshaft optimizer will
* only punish this function for the usage for try catch
*
* @api private
*/
function parse (data) {
try { return JSON.parse(data) }
catch (e) { return false }
}
exports.decodePacket = function (data) {

@@ -160,3 +171,3 @@ var pieces = data.match(regexp);

, packet = {
type: packets[pieces[1]]
type: packetslist[pieces[1]]
, endpoint: pieces[4] || ''

@@ -176,8 +187,2 @@ };

switch (packet.type) {
case 'error':
var pieces = data.split('+');
packet.reason = reasons[pieces[0]] || '';
packet.advice = advice[pieces[1]] || '';
break;
case 'message':

@@ -188,7 +193,7 @@ packet.data = data || '';

case 'event':
try {
var opts = JSON.parse(data);
packet.name = opts.name;
packet.args = opts.args;
} catch (e) { }
pieces = parse(data);
if (pieces) {
packet.name = pieces.name;
packet.args = pieces.args;
}

@@ -199,5 +204,3 @@ packet.args = packet.args || [];

case 'json':
try {
packet.data = JSON.parse(data);
} catch (e) { }
packet.data = parse(data);
break;

@@ -210,3 +213,3 @@

case 'ack':
var pieces = data.match(/^([0-9]+)(\+)?(.*)/);
pieces = data.match(/^([0-9]+)(\+)?(.*)/);
if (pieces) {

@@ -217,5 +220,3 @@ packet.ackId = pieces[1];

if (pieces[3]) {
try {
packet.args = pieces[3] ? JSON.parse(pieces[3]) : [];
} catch (e) { }
packet.args = parse(pieces[3]) || [];
}

@@ -225,6 +226,7 @@ }

case 'disconnect':
case 'heartbeat':
break;
};
case 'error':
pieces = data.split('+');
packet.reason = reasonslist[pieces[0]] || '';
packet.advice = advicelist[pieces[1]] || '';
}

@@ -231,0 +233,0 @@ return packet;

@@ -18,3 +18,3 @@

exports.version = '0.8.5';
exports.version = '0.8.7';

@@ -21,0 +21,0 @@ /**

@@ -45,3 +45,4 @@

var bundle = /\+((?:\+)?[\w\-]+)*(?:\.js)$/g;
var bundle = /\+((?:\+)?[\w\-]+)*(?:\.v\d+\.\d+\.\d+)?(?:\.js)$/
, versioning = /\.v\d+\.\d+\.\d+(?:\.js)$/;

@@ -124,6 +125,10 @@ /**

this.add('/socket.io.v', { mime: mime.js }, function (path, callback) {
build(self.manager.get('transports'), callback);
});
// allow custom builds based on url paths
this.add('/socket.io+', { mime: mime.js }, function (path, callback) {
var available = self.manager.get('transports')
, matches = bundle.exec(path)
, matches = path.match(bundle)
, transports = [];

@@ -222,3 +227,3 @@

while (i--) {
if (!!~path.indexOf(keys[i])) return this.paths[keys[i]];
if (-~path.indexOf(keys[i])) return this.paths[keys[i]];
}

@@ -277,3 +282,9 @@

res.writeHead(status, headers || undefined);
res.end(content || '', encoding || undefined);
// only write content if it's not a HEAD request and we actually have
// some content to write (304's doesn't have content).
res.end(
req.method !== 'HEAD' && content ? content : ''
, encoding || undefined
);
} catch (e) {}

@@ -298,2 +309,3 @@ }

, mime = reply.mime
, versioned = reply.versioned
, headers = {

@@ -304,10 +316,18 @@ 'Content-Type': mime.type

// check if we can add a etag
if (self.manager.enabled('browser client etag') && reply.etag) {
if (self.manager.enabled('browser client etag') && reply.etag && !versioned) {
headers['Etag'] = reply.etag;
}
// check if we can send gzip data
// see if we need to set Expire headers because the path is versioned
if (versioned) {
var expires = self.manager.get('browser client expires');
headers['Cache-Control'] = 'private, x-gzip-ok="", max-age=' + expires;
headers['Date'] = new Date().toUTCString();
headers['Expires'] = new Date(Date.now() + (expires * 1000)).toUTCString();
}
if (gzip && reply.gzip) {
headers['Content-Length'] = reply.gzip.length;
headers['Content-Encoding'] = 'gzip';
headers['Vary'] = 'Accept-Encoding';
write(200, headers, reply.gzip.content, mime.encoding);

@@ -351,2 +371,3 @@ } else {

, etag: etag || client.version
, versioned: versioning.test(path)
};

@@ -353,0 +374,0 @@

@@ -87,2 +87,5 @@

Store.call(this, opts);
this.sub.setMaxListeners(0);
this.setMaxListeners(0);
};

@@ -89,0 +92,0 @@

@@ -52,5 +52,5 @@

var server;
FlashSocket.init = function (manager) {
var server;
function create () {

@@ -84,6 +84,11 @@ server = require('policyfile').createServer({

var transports = manager.get('transports');
if (server && server.port !== value && ~transports.indexOf('flashsocket')) {
// destroy the server and rebuild it on a new port
server.close();
if (~transports.indexOf('flashsocket')) {
if (server) {
if (server.port === value) return;
// destroy the server and rebuild it on a new port
try {
server.close();
}
catch (e) { /* ignore exception. could e.g. be that the server isn't started yet */ }
}
create();

@@ -99,3 +104,2 @@ }

});
// check if we need to initialize at start

@@ -102,0 +106,0 @@ if (~manager.get('transports').indexOf('flashsocket')){

@@ -55,3 +55,3 @@

req.res.writeHead(200, {
'Content-Type': 'text/html'
'Content-Type': 'text/html; charset=UTF-8'
, 'Connection': 'keep-alive'

@@ -58,0 +58,0 @@ , 'Transfer-Encoding': 'chunked'

@@ -58,2 +58,20 @@

/**
* Handles incoming data.
* Due to a bug in \n handling by browsers, we expect a JSONified string.
*
* @api private
*/
JSONPPolling.prototype.onData = function (data) {
try {
data = JSON.parse(data);
} catch (e) {
this.error('parse', 'reconnect');
return;
}
HTTPPolling.prototype.onData.call(this, data);
};
/**
* Performs the write.

@@ -60,0 +78,0 @@ *

@@ -44,3 +44,9 @@

// version 8 ping => pong
self.socket.write('\u008a\u0000');
try {
self.socket.write('\u008a\u0000');
}
catch (e) {
self.end();
return;
}
});

@@ -89,3 +95,4 @@ this.parser.on('close', function () {

if (this.req.headers.upgrade !== 'websocket') {
if (typeof this.req.headers.upgrade === 'undefined' ||
this.req.headers.upgrade.toLowerCase() !== 'websocket') {
this.log.warn(this.name + ' connection invalid');

@@ -182,3 +189,9 @@ this.end();

var buf = this.frame(0x81, data);
this.socket.write(buf, 'binary');
try {
this.socket.write(buf, 'binary');
}
catch (e) {
this.end();
return;
}
this.log.debug(this.name + ' writing', data);

@@ -185,0 +198,0 @@ }

@@ -44,3 +44,9 @@

// version 8 ping => pong
self.socket.write('\u008a\u0000');
try {
self.socket.write('\u008a\u0000');
}
catch (e) {
self.end();
return;
}
});

@@ -89,3 +95,4 @@ this.parser.on('close', function () {

if (this.req.headers.upgrade !== 'websocket') {
if (typeof this.req.headers.upgrade === 'undefined' ||
this.req.headers.upgrade.toLowerCase() !== 'websocket') {
this.log.warn(this.name + ' connection invalid');

@@ -182,3 +189,9 @@ this.end();

var buf = this.frame(0x81, data);
this.socket.write(buf, 'binary');
try {
this.socket.write(buf, 'binary');
}
catch (e) {
this.end();
return;
}
this.log.debug(this.name + ' writing', data);

@@ -185,0 +198,0 @@ }

{
"name": "socket.io"
, "version": "0.8.5"
, "version": "0.8.7"
, "description": "Real-time apps made cross-browser & easy with a WebSocket-like API"

@@ -19,10 +19,13 @@ , "homepage": "http://socket.io"

, "dependencies": {
"socket.io-client": "0.8.5"
"socket.io-client": "0.8.7"
, "policyfile": "0.0.4"
, "redis": "0.6.6"
, "redis": "0.6.7"
}
, "devDependencies": {
"expresso": "0.7.7"
"expresso": "0.9.2"
, "should": "0.0.4"
, "assertvanish": "0.0.3-1"
, "benchmark": "0.2.2"
, "microtime": "0.1.3-1"
, "colors": "0.5.1"
}

@@ -29,0 +32,0 @@ , "main": "index"

@@ -70,3 +70,3 @@ # Socket.IO

socket.on('disconnect', function () {
sockets.emit('user disconnected');
io.sockets.emit('user disconnected');
});

@@ -73,0 +73,0 @@ });

@@ -8,3 +8,3 @@ var assert = require('assert');

var urllib = require('url');
var sys = require('sys');
var sys = require('util');

@@ -351,3 +351,2 @@ var FRAME_NO = 0;

readyState = CLOSED;
if (stream) {

@@ -474,9 +473,16 @@ stream.end();

// string as its first argument to connect to a UNIX socket.
var httpClient = undefined;
var opt = {};
var agent = null;
switch (getUrlScheme(url)) {
case 'ws':
var u = urllib.parse(url);
httpClient = http.createClient(u.port || 80, u.hostname);
httpPath = (u.pathname || '/') + (u.search || '');
httpHeaders.Host = u.hostname + (u.port ? (":" + u.port) : "");
agent = new http.Agent({
host: u.hostname,
port: u.port || 80
});
opt.agent = agent;
opt.host = u.hostname;
opt.port = u.port || 80;
opt.path = (u.pathname || '/') + (u.search || '');
opt.headers = httpHeaders;
break;

@@ -486,4 +492,11 @@

var sockPath = url.substring('ws+unix://'.length, url.length);
httpClient = http.createClient(sockPath);
httpHeaders.Host = 'localhost';
var u = urllib.parse(url);
agent = new http.Agent({
host: 'localhost',
port: sockPath
});
opt.agent = agent;
opt.host = 'localhost';
opt.path = sockPath;
opt.headers = httpHeaders;
break;

@@ -495,8 +508,17 @@

httpClient.on('upgrade', (function() {
var httpReq = http.request(opt, function() { });
var upgradeHandler = (function() {
var data = undefined;
return function(req, s, head) {
req.socket.setNoDelay(true);
stream = s;
if (readyState == CLOSED) {
stream.end();
stream.destroy();
stream = undefined;
return;
}
stream.on('data', function(d) {

@@ -555,3 +577,3 @@ if (d.length <= 0) {

// that we added.
httpClient.removeAllListeners('upgrade');
httpReq.removeAllListeners('upgrade');
stream.removeAllListeners('data');

@@ -584,10 +606,6 @@ stream.on('data', dataListener);

};
})());
httpClient.on('error', function(e) {
httpClient.end();
errorListener(e);
});
})();
agent.on('upgrade', upgradeHandler); // node v0.4
httpReq.on('upgrade', upgradeHandler); // node v0.5+
var httpReq = httpClient.request(httpPath, httpHeaders);
httpReq.write(challenge, 'binary');

@@ -594,0 +612,0 @@ httpReq.end();

@@ -65,5 +65,10 @@ /*

var depsFromFile = [
'npm',
'semver',
'findit'
];
var nativeSubjects = {};
Object.getOwnPropertyNames(process.binding('natives'))
.concat(['net', 'tty', 'dgram', 'child_process', 'dns'])
.forEach(function (package) {

@@ -119,3 +124,3 @@ nativeSubjects[package] = {

assert.isNull(err);
assert.deepEqual(pkgs, rawPackages);
assert.deepEqual(pkgs, libDeps);
}

@@ -130,3 +135,3 @@ },

assert.isNull(err);
assert.deepEqual(pkgs, libPackages);
assert.deepEqual(pkgs, depsFromFile);
}

@@ -133,0 +138,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