зеркало из https://github.com/mozilla/hawk.git
Родитель
bbd672b0a5
Коммит
dd54922ce4
|
@ -1,5 +0,0 @@
|
|||
*
|
||||
!lib/**
|
||||
!dist/**
|
||||
!client.js
|
||||
!.npmignore
|
|
@ -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"
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -13,7 +13,7 @@ const internals = {};
|
|||
exports.plugin = {
|
||||
pkg: require('../package.json'),
|
||||
requirements: {
|
||||
hapi: '>=17.7.0'
|
||||
hapi: '>=18.4.0'
|
||||
},
|
||||
register: function (server) {
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
19
package.json
19
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",
|
||||
|
|
|
@ -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');
|
||||
|
|
Загрузка…
Ссылка в новой задаче