From dd54922ce472db9f6eb884afadba6852510b30fd Mon Sep 17 00:00:00 2001 From: Eran Hammer Date: Thu, 9 Jan 2020 21:30:00 -0800 Subject: [PATCH] Update deps. Closes #267. Closes #268 --- .npmignore | 5 ----- .travis.yml | 3 +-- LICENSE.md | 2 +- lib/client.js | 32 ++++++++++++++++---------------- lib/plugin.js | 2 +- lib/server.js | 20 ++++++++++---------- package.json | 19 +++++++++++-------- test/plugin.js | 2 +- 8 files changed, 41 insertions(+), 44 deletions(-) delete mode 100755 .npmignore diff --git a/.npmignore b/.npmignore deleted file mode 100755 index 20f7f7b..0000000 --- a/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -* -!lib/** -!dist/** -!client.js -!.npmignore diff --git a/.travis.yml b/.travis.yml index 6f59abb..c4d91d0 100755 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: node_js node_js: - - "8" - - "10" - "12" - "node" @@ -14,6 +12,7 @@ install: env: - HAPI_VERSION="18" + - HAPI_VERSION="19" os: - "linux" diff --git a/LICENSE.md b/LICENSE.md index fca451a..15a35a3 100755 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2012-2019, Sideway Inc, and project contributors +Copyright (c) 2012-2020, Sideway Inc, and project contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/lib/client.js b/lib/client.js index d9f3e69..7bd383a 100755 --- a/lib/client.js +++ b/lib/client.js @@ -51,7 +51,7 @@ exports.header = function (uri, method, options) { !method || typeof method !== 'string' || !options || typeof options !== 'object') { - throw new Boom('Invalid argument type'); + throw new Boom.Boom('Invalid argument type'); } // Application time @@ -66,11 +66,11 @@ exports.header = function (uri, method, options) { !credentials.key || !credentials.algorithm) { - throw new Boom('Invalid credentials'); + throw new Boom.Boom('Invalid credentials'); } if (Crypto.algorithms.indexOf(credentials.algorithm) === -1) { - throw new Boom('Unknown algorithm'); + throw new Boom.Boom('Unknown algorithm'); } // Parse URI @@ -150,7 +150,7 @@ exports.authenticate = function (res, credentials, artifacts, options) { var wwwAttributes = Utils.parseAuthorizationHeader(res.headers['www-authenticate'], ['ts', 'tsm', 'error']); } catch (err) { - throw new Boom('Invalid WWW-Authenticate header'); + throw new Boom.Boom('Invalid WWW-Authenticate header'); } result.headers['www-authenticate'] = wwwAttributes; @@ -160,7 +160,7 @@ exports.authenticate = function (res, credentials, artifacts, options) { if (wwwAttributes.ts) { const tsm = Crypto.calculateTsMac(wwwAttributes.ts, credentials); if (tsm !== wwwAttributes.tsm) { - throw new Boom('Invalid server timestamp hash', { decorate: result }); + throw new Boom.Boom('Invalid server timestamp hash', { decorate: result }); } } } @@ -169,7 +169,7 @@ exports.authenticate = function (res, credentials, artifacts, options) { if (!res.headers['server-authorization']) { if (options.required) { - throw new Boom('Missing Server-Authorization header', { decorate: result }); + throw new Boom.Boom('Missing Server-Authorization header', { decorate: result }); } return result; @@ -179,7 +179,7 @@ exports.authenticate = function (res, credentials, artifacts, options) { var serverAuthAttributes = Utils.parseAuthorizationHeader(res.headers['server-authorization'], ['mac', 'ext', 'hash']); } catch (err) { - throw new Boom('Invalid Server-Authorization header', { decorate: result }); + throw new Boom.Boom('Invalid Server-Authorization header', { decorate: result }); } result.headers['server-authorization'] = serverAuthAttributes; @@ -189,7 +189,7 @@ exports.authenticate = function (res, credentials, artifacts, options) { const mac = Crypto.calculateMac('response', credentials, artifacts); if (mac !== serverAuthAttributes.mac) { - throw new Boom('Bad response mac', { decorate: result }); + throw new Boom.Boom('Bad response mac', { decorate: result }); } if (options.payload === null || @@ -199,12 +199,12 @@ exports.authenticate = function (res, credentials, artifacts, options) { } if (!serverAuthAttributes.hash) { - throw new Boom('Missing response hash attribute', { decorate: result }); + throw new Boom.Boom('Missing response hash attribute', { decorate: result }); } const calculatedHash = Crypto.calculatePayloadHash(options.payload, credentials.algorithm, res.headers['content-type']); if (calculatedHash !== serverAuthAttributes.hash) { - throw new Boom('Bad response payload mac', { decorate: result }); + throw new Boom.Boom('Bad response payload mac', { decorate: result }); } return result; @@ -243,7 +243,7 @@ exports.getBewit = function (uri, options) { typeof options !== 'object' || !options.ttlSec) { - throw new Boom('Invalid inputs'); + throw new Boom.Boom('Invalid inputs'); } const ext = (options.ext === null || options.ext === undefined ? '' : options.ext); // Zero is valid value @@ -260,11 +260,11 @@ exports.getBewit = function (uri, options) { !credentials.key || !credentials.algorithm) { - throw new Boom('Invalid credentials'); + throw new Boom.Boom('Invalid credentials'); } if (Crypto.algorithms.indexOf(credentials.algorithm) === -1) { - throw new Boom('Unknown algorithm'); + throw new Boom.Boom('Unknown algorithm'); } // Parse URI @@ -328,7 +328,7 @@ exports.message = function (host, port, message, options) { message === null || message === undefined || typeof message !== 'string' || typeof options !== 'object') { - throw new Boom('Invalid inputs'); + throw new Boom.Boom('Invalid inputs'); } // Application time @@ -343,11 +343,11 @@ exports.message = function (host, port, message, options) { !credentials.key || !credentials.algorithm) { - throw new Boom('Invalid credentials'); + throw new Boom.Boom('Invalid credentials'); } if (Crypto.algorithms.indexOf(credentials.algorithm) === -1) { - throw new Boom('Unknown algorithm'); + throw new Boom.Boom('Unknown algorithm'); } // Calculate signature diff --git a/lib/plugin.js b/lib/plugin.js index e12db5e..44420c8 100755 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -13,7 +13,7 @@ const internals = {}; exports.plugin = { pkg: require('../package.json'), requirements: { - hapi: '>=17.7.0' + hapi: '>=18.4.0' }, register: function (server) { diff --git a/lib/server.js b/lib/server.js index ca80388..30a85ca 100755 --- a/lib/server.js +++ b/lib/server.js @@ -146,11 +146,11 @@ exports.authenticate = async function (req, credentialsFunc, options) { if (!credentials.key || !credentials.algorithm) { - throw new Boom('Invalid credentials', { decorate: result }); + throw new Boom.Boom('Invalid credentials', { decorate: result }); } if (Crypto.algorithms.indexOf(credentials.algorithm) === -1) { - throw new Boom('Unknown algorithm', { decorate: result }); + throw new Boom.Boom('Unknown algorithm', { decorate: result }); } // Calculate MAC @@ -259,7 +259,7 @@ exports.header = function (credentials, artifacts, options) { typeof artifacts !== 'object' || typeof options !== 'object') { - throw new Boom('Invalid inputs'); + throw new Boom.Boom('Invalid inputs'); } artifacts = Hoek.clone(artifacts); @@ -273,11 +273,11 @@ exports.header = function (credentials, artifacts, options) { !credentials.key || !credentials.algorithm) { - throw new Boom('Invalid credentials'); + throw new Boom.Boom('Invalid credentials'); } if (Crypto.algorithms.indexOf(credentials.algorithm) === -1) { - throw new Boom('Unknown algorithm'); + throw new Boom.Boom('Unknown algorithm'); } // Calculate payload hash @@ -408,7 +408,7 @@ exports.authenticateBewit = async function (req, credentialsFunc, options) { var credentials = await credentialsFunc(bewit.id); } catch (err) { - throw new Boom(err, { decorate: { bewit } }); + throw new Boom.Boom(err, { decorate: { bewit } }); } if (!credentials) { @@ -420,11 +420,11 @@ exports.authenticateBewit = async function (req, credentialsFunc, options) { if (!credentials.key || !credentials.algorithm) { - throw new Boom('Invalid credentials', { decorate: result }); + throw new Boom.Boom('Invalid credentials', { decorate: result }); } if (Crypto.algorithms.indexOf(credentials.algorithm) === -1) { - throw new Boom('Unknown algorithm', { decorate: result }); + throw new Boom.Boom('Unknown algorithm', { decorate: result }); } // Calculate MAC @@ -489,11 +489,11 @@ exports.authenticateMessage = async function (host, port, message, authorization if (!credentials.key || !credentials.algorithm) { - throw new Boom('Invalid credentials', { decorate: result }); + throw new Boom.Boom('Invalid credentials', { decorate: result }); } if (Crypto.algorithms.indexOf(credentials.algorithm) === -1) { - throw new Boom('Unknown algorithm', { decorate: result }); + throw new Boom.Boom('Unknown algorithm', { decorate: result }); } // Construct artifacts container diff --git a/package.json b/package.json index 6b7ccc2..2a24a20 100755 --- a/package.json +++ b/package.json @@ -4,6 +4,9 @@ "version": "7.1.2", "repository": "git://github.com/hapijs/hawk", "main": "lib/index.js", + "files": [ + "lib" + ], "keywords": [ "http", "authentication", @@ -11,16 +14,16 @@ "hawk" ], "dependencies": { - "@hapi/hoek": "8.x.x", - "@hapi/b64": "4.x.x", - "@hapi/boom": "7.x.x", - "@hapi/cryptiles": "4.x.x", - "@hapi/sntp": "3.x.x" + "@hapi/hoek": "9.x.x", + "@hapi/b64": "5.x.x", + "@hapi/boom": "9.x.x", + "@hapi/cryptiles": "5.x.x", + "@hapi/sntp": "4.x.x" }, "devDependencies": { - "@hapi/code": "6.x.x", - "@hapi/hapi": "18.x.x", - "@hapi/lab": "20.x.x" + "@hapi/code": "8.x.x", + "@hapi/hapi": "19.x.x", + "@hapi/lab": "22.x.x" }, "scripts": { "test": "lab -a @hapi/code -t 100 -L", diff --git a/test/plugin.js b/test/plugin.js index e5c3fc6..ef97a3e 100755 --- a/test/plugin.js +++ b/test/plugin.js @@ -253,7 +253,7 @@ describe('Plugin', () => { return 'Success'; }, - options: { auth: 'default', validate: { query: {} } } + options: { auth: 'default', validate: { query: false } } }); const authHeader = hawkHeader('john', '/hawkValidate?a=1');