summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/hawk/lib/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/hawk/lib/utils.js')
-rwxr-xr-xdeps/npm/node_modules/hawk/lib/utils.js30
1 files changed, 14 insertions, 16 deletions
diff --git a/deps/npm/node_modules/hawk/lib/utils.js b/deps/npm/node_modules/hawk/lib/utils.js
index 565b1c7a7b..2da3343904 100755
--- a/deps/npm/node_modules/hawk/lib/utils.js
+++ b/deps/npm/node_modules/hawk/lib/utils.js
@@ -1,14 +1,12 @@
-'use strict';
-
// Load modules
-const Sntp = require('sntp');
-const Boom = require('boom');
+var Sntp = require('sntp');
+var Boom = require('boom');
// Declare internals
-const internals = {};
+var internals = {};
exports.version = function () {
@@ -31,7 +29,7 @@ internals.hostHeaderRegex = /^(?:(?:\r\n)?\s)*((?:[^:]+)|(?:\[[^\]]+\]))(?::(\d+
exports.parseHost = function (req, hostHeaderName) {
hostHeaderName = (hostHeaderName ? hostHeaderName.toLowerCase() : 'host');
- const hostHeader = req.headers[hostHeaderName];
+ var hostHeader = req.headers[hostHeaderName];
if (!hostHeader) {
return null;
}
@@ -40,7 +38,7 @@ exports.parseHost = function (req, hostHeaderName) {
return null;
}
- const hostParts = hostHeader.match(internals.hostHeaderRegex);
+ var hostParts = hostHeader.match(internals.hostHeaderRegex);
if (!hostParts) {
return null;
}
@@ -74,7 +72,7 @@ exports.parseRequest = function (req, options) {
// Obtain host and port information
- let host;
+ var host;
if (!options.host ||
!options.port) {
@@ -84,7 +82,7 @@ exports.parseRequest = function (req, options) {
}
}
- const request = {
+ var request = {
method: req.method,
url: req.url,
host: options.host || host.name,
@@ -127,24 +125,24 @@ exports.parseAuthorizationHeader = function (header, keys) {
return Boom.badRequest('Header length too long');
}
- const headerParts = header.match(internals.authHeaderRegex);
+ var headerParts = header.match(internals.authHeaderRegex);
if (!headerParts) {
return Boom.badRequest('Invalid header syntax');
}
- const scheme = headerParts[1];
+ var scheme = headerParts[1];
if (scheme.toLowerCase() !== 'hawk') {
return Boom.unauthorized(null, 'Hawk');
}
- const attributesString = headerParts[2];
+ var attributesString = headerParts[2];
if (!attributesString) {
return Boom.badRequest('Invalid header syntax');
}
- const attributes = {};
- let errorMessage = '';
- const verify = attributesString.replace(/(\w+)="([^"\\]*)"\s*(?:,\s*|$)/g, ($0, $1, $2) => {
+ var attributes = {};
+ var errorMessage = '';
+ var verify = attributesString.replace(/(\w+)="([^"\\]*)"\s*(?:,\s*|$)/g, function ($0, $1, $2) {
// Check valid attribute names
@@ -181,5 +179,5 @@ exports.parseAuthorizationHeader = function (header, keys) {
exports.unauthorized = function (message, attributes) {
- return Boom.unauthorized(message || null, 'Hawk', attributes);
+ return Boom.unauthorized(message, 'Hawk', attributes);
};