Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
Replace default value with explicit options. Closes #219
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Oct 27, 2017
1 parent db3a60d commit 6b9b419
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
8 changes: 6 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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

Expand Down
16 changes: 12 additions & 4 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hawk",
"description": "HTTP Hawk Authentication Scheme",
"version": "7.0.1",
"version": "7.0.2",
"author": "Eran Hammer <[email protected]> (http://hueniverse.com)",
"repository": "git://github.com/hueniverse/hawk",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand Down

0 comments on commit 6b9b419

Please sign in to comment.