Comparing version 0.3.0 to 0.6.0
@@ -11,2 +11,3 @@ 'use strict'; | ||
var os = require('os'); | ||
var responseCookie = require('response-cookie'); | ||
var sha256 = require('sha256'); | ||
@@ -24,12 +25,24 @@ | ||
var cookieParserMiddleware = cookieParser(); | ||
var responseCookieMiddleware = responseCookie(); | ||
function middleware(req, res, next) { | ||
var nextMiddleware = _middleware; | ||
if (!res.cookie) { | ||
nextMiddleware = function(req, res, next) { | ||
responseCookieMiddleware(req, res, function() { | ||
_middleware(req, res, next); | ||
}); | ||
}; | ||
} | ||
if (!req.cookies) { | ||
// The cookie-parser middleware hasn't been configured yet. | ||
cookieParserMiddleware(req, res, function() { | ||
_middleware(req, res, next); | ||
nextMiddleware(req, res, next); | ||
}); | ||
return; | ||
} | ||
_middleware(req, res, next); | ||
nextMiddleware(req, res, next); | ||
} | ||
@@ -41,2 +54,9 @@ | ||
function getHeader(req, name) { | ||
if (req.headers) { | ||
return req.headers['user-agent']; | ||
} | ||
return req.get('user-agent'); | ||
} | ||
function _middleware(req, res, next) { | ||
@@ -91,2 +111,3 @@ var linkProbability = RELINK_PROBABILITY; | ||
console.log(req.headers); | ||
cb(null, { | ||
@@ -96,3 +117,3 @@ $endpointURL: req.path, | ||
$localMachineID: localMachineID, | ||
$userAgent: req.get('user-agent') | ||
$userAgent: getHeader(req, 'user-agent') | ||
}); | ||
@@ -99,0 +120,0 @@ } |
{ | ||
"name": "authbox", | ||
"version": "0.3.0", | ||
"version": "0.6.0", | ||
"description": "", | ||
@@ -15,5 +15,7 @@ "main": "lib/index.js", | ||
"bluebird": "^2.3.2", | ||
"connect": "^3.3.3", | ||
"connect-inject": "petehunt/connect-inject", | ||
"cookie-parser": "^1.3.3", | ||
"request": "^2.47.0", | ||
"response-cookie": "0.0.2", | ||
"sha256": "^0.1.1" | ||
@@ -20,0 +22,0 @@ }, |
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
22475
11
251
8
+ Addedconnect@^3.3.3
+ Addedresponse-cookie@0.0.2
+ Addedconnect@3.7.0(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedencodeurl@1.0.2(transitive)
+ Addedescape-html@1.0.3(transitive)
+ Addedfinalhandler@1.1.2(transitive)
+ Addedms@2.0.0(transitive)
+ Addedon-finished@2.3.0(transitive)
+ Addedparseurl@1.3.3(transitive)
+ Addedresponse-cookie@0.0.2(transitive)
+ Addedstatuses@1.5.0(transitive)
+ Addedunpipe@1.0.0(transitive)
+ Addedutils-merge@1.0.1(transitive)