diff --git a/lib/client.js b/lib/client.js index 6703d46..c8f8835 100755 --- a/lib/client.js +++ b/lib/client.js @@ -136,7 +136,9 @@ exports.header = function (uri, method, options) { } */ -exports.authenticate = function (res, credentials, artifacts, options = {}) { +exports.authenticate = function (res, credentials, artifacts, options) { + + options = options || {}; artifacts = Hoek.clone(artifacts); @@ -315,7 +317,9 @@ exports.getBewit = function (uri, options) { } */ -exports.message = function (host, port, message, options = {}) { +exports.message = function (host, port, message, options) { + + options = options || {}; // Validate inputs diff --git a/lib/server.js b/lib/server.js index c28f47d..d43214d 100755 --- a/lib/server.js +++ b/lib/server.js @@ -83,7 +83,9 @@ const internals = {}; Return value: { credentials, artifacts } or throws an error. */ -exports.authenticate = async function (req, credentialsFunc, options = {}) { +exports.authenticate = async function (req, credentialsFunc, options) { + + options = options || {}; // Default options @@ -249,7 +251,9 @@ exports.authenticatePayloadHash = function (calculatedHash, artifacts) { } */ -exports.header = function (credentials, artifacts, options = {}) { +exports.header = function (credentials, artifacts, options) { + + options = options || {}; // Prepare inputs @@ -314,7 +318,9 @@ exports.header = function (credentials, artifacts, options = {}) { internals.bewitRegex = /^(\/.*)([\?&])bewit\=([^&$]*)(?:&(.+))?$/; -exports.authenticateBewit = async function (req, credentialsFunc, options = {}) { +exports.authenticateBewit = async function (req, credentialsFunc, options) { + + options = options || {}; // Application time @@ -450,7 +456,9 @@ exports.authenticateBewit = async function (req, credentialsFunc, options = {}) * 'nonceFunc', 'timestampSkewSec', 'localtimeOffsetMsec' */ -exports.authenticateMessage = async function (host, port, message, authorization, credentialsFunc, options = {}) { +exports.authenticateMessage = async function (host, port, message, authorization, credentialsFunc, options) { + + options = options || {}; // Default options diff --git a/package.json b/package.json index 5993251..977ca67 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "hawk", "description": "HTTP Hawk Authentication Scheme", - "version": "7.0.1", + "version": "7.0.2", "author": "Eran Hammer (http://hueniverse.com)", "repository": "git://github.com/hueniverse/hawk", "main": "lib/index.js", diff --git a/test/server.js b/test/server.js index 5ee94a2..ab81a70 100755 --- a/test/server.js +++ b/test/server.js @@ -803,7 +803,7 @@ describe('Server', () => { authorization: 'Hawk id="1", ts="1353788437", nonce="k3j4h2", mac="zy79QQ5/EYFmQqutVnYb73gAc/U=", ext="hello"' }; - const err = await expect(Hawk.server.authenticateBewit(req, credentialsFunc)).to.reject('Resource path exceeds max length'); + const err = await expect(Hawk.server.authenticateBewit(req, credentialsFunc, {})).to.reject('Resource path exceeds max length'); expect(err.output.statusCode).to.equal(400); }); });