NPM Dependencies UPDATE

This commit is contained in:
Luis Fernando Molina committed 2018-05-02 10:22:14 +02:00
1 parent d3bc5e34f6
commit 5bfb4ff32a
732 files changed
+13367 -62155

No files matched your search

+22 -20
View File
@@ -1,13 +1,15 @@
'use strict';
// Load modules
var Crypto = require('crypto');
var Url = require('url');
var Utils = require('./utils');
const Crypto = require('crypto');
const Url = require('url');
const Utils = require('./utils');
// Declare internals
var internals = {};
const internals = {};
// MAC normalization format version
@@ -44,25 +46,25 @@ exports.algorithms = ['sha1', 'sha256'];
exports.calculateMac = function (type, credentials, options) {
var normalized = exports.generateNormalizedString(type, options);
const normalized = exports.generateNormalizedString(type, options);
var hmac = Crypto.createHmac(credentials.algorithm, credentials.key).update(normalized);
var digest = hmac.digest('base64');
const hmac = Crypto.createHmac(credentials.algorithm, credentials.key).update(normalized);
const digest = hmac.digest('base64');
return digest;
};
exports.generateNormalizedString = function (type, options) {
var resource = options.resource || '';
let resource = options.resource || '';
if (resource &&
resource[0] !== '/') {
var url = Url.parse(resource, false);
const url = Url.parse(resource, false);
resource = url.path; // Includes query
}
var normalized = 'hawk.' + exports.headerVersion + '.' + type + '\n' +
let normalized = 'hawk.' + exports.headerVersion + '.' + type + '\n' +
options.ts + '\n' +
options.nonce + '\n' +
(options.method || '').toUpperCase() + '\n' +
@@ -72,14 +74,14 @@ exports.generateNormalizedString = function (type, options) {
(options.hash || '') + '\n';
if (options.ext) {
normalized += options.ext.replace('\\', '\\\\').replace('\n', '\\n');
normalized = normalized + options.ext.replace('\\', '\\\\').replace('\n', '\\n');
}
normalized += '\n';
normalized = normalized + '\n';
if (options.app) {
normalized += options.app + '\n' +
(options.dlg || '') + '\n';
normalized = normalized + options.app + '\n' +
(options.dlg || '') + '\n';
}
return normalized;
@@ -88,7 +90,7 @@ exports.generateNormalizedString = function (type, options) {
exports.calculatePayloadHash = function (payload, algorithm, contentType) {
var hash = exports.initializePayloadHash(algorithm, contentType);
const hash = exports.initializePayloadHash(algorithm, contentType);
hash.update(payload || '');
return exports.finalizePayloadHash(hash);
};
@@ -96,7 +98,7 @@ exports.calculatePayloadHash = function (payload, algorithm, contentType) {
exports.initializePayloadHash = function (algorithm, contentType) {
var hash = Crypto.createHash(algorithm);
const hash = Crypto.createHash(algorithm);
hash.update('hawk.' + exports.headerVersion + '.payload\n');
hash.update(Utils.parseContentType(contentType) + '\n');
return hash;
@@ -112,7 +114,7 @@ exports.finalizePayloadHash = function (hash) {
exports.calculateTsMac = function (ts, credentials) {
var hmac = Crypto.createHmac(credentials.algorithm, credentials.key);
const hmac = Crypto.createHmac(credentials.algorithm, credentials.key);
hmac.update('hawk.' + exports.headerVersion + '.ts\n' + ts + '\n');
return hmac.digest('base64');
};
@@ -120,7 +122,7 @@ exports.calculateTsMac = function (ts, credentials) {
exports.timestampMessage = function (credentials, localtimeOffsetMsec) {
var now = Utils.nowSecs(localtimeOffsetMsec);
var tsm = exports.calculateTsMac(now, credentials);
return { ts: now, tsm: tsm };
const now = Utils.nowSecs(localtimeOffsetMsec);
const tsm = exports.calculateTsMac(now, credentials);
return { ts: now, tsm };
};