This commit is contained in:
Eran Hammer 2014-09-05 13:21:05 -07:00
Родитель 227b5ff2a4
Коммит 7b050d7920
13 изменённых файлов: 60 добавлений и 76 удалений

14
LICENSE
Просмотреть файл

@ -1,4 +1,4 @@
Copyright (c) 2012-2014, Eran Hammer.
Copyright (c) 2012-2014, Eran Hammer and other contributors.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -8,17 +8,21 @@ modification, are permitted provided that the following conditions are met:
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Eran Hammer nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
* The names of any contributors may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL ERAN HAMMER BE LIABLE FOR ANY
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* * *
The complete list of contributors can be found at: https://github.com/hueniverse/hawk/graphs/contributors

Просмотреть файл

@ -134,31 +134,27 @@ hawk.client = {
return result;
},
// Generate a bewit value for a given URI
// Generate a bewit value for a given URI
/*
* credentials is an object with the following keys: 'id, 'key', 'algorithm'.
* options is an object with the following optional keys: 'ext', 'localtimeOffsetMsec'
*/
/*
uri: 'http://example.com/resource?a=b'
options: {
uri: 'http://example.com/resource?a=b'
options: {
// Required
// Required
credentials: {
id: 'dh37fgj492je',
key: 'aoijedoaijsdlaksjdl',
algorithm: 'sha256' // 'sha1', 'sha256'
},
ttlSec: 60 * 60, // TTL in seconds
credentials: {
id: 'dh37fgj492je',
key: 'aoijedoaijsdlaksjdl',
algorithm: 'sha256' // 'sha1', 'sha256'
},
ttlSec: 60 * 60, // TTL in seconds
// Optional
// Optional
ext: 'application-specific', // Application specific data sent via the ext attribute
localtimeOffsetMsec: 400 // Time offset to sync with server time
};
*/
ext: 'application-specific', // Application specific data sent via the ext attribute
localtimeOffsetMsec: 400 // Time offset to sync with server time
};
*/
bewit: function (uri, options) {
@ -214,9 +210,6 @@ hawk.client = {
// Construct bewit: id\exp\mac\ext
var bewit = credentials.id + '\\' + exp + '\\' + mac + '\\' + options.ext;
console.log('Bewit: '+bewit);
return hawk.utils.base64urlEncode(bewit);
},
@ -484,13 +477,6 @@ hawk.utils = {
}
},
base64urlEncode: function (value) {
var wordArray = CryptoJS.enc.Utf8.parse(value);
var encoded = CryptoJS.enc.Base64.stringify(wordArray);
return encoded.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '');
//return wordArray.toString(CryptoJS.enc.Base64); //.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '');
},
setNtpOffset: function (offset) {
try {
@ -619,6 +605,13 @@ hawk.utils = {
}
return uri;
},
base64urlEncode: function (value) {
var wordArray = CryptoJS.enc.Utf8.parse(value);
var encoded = CryptoJS.enc.Base64.stringify(wordArray);
return encoded.replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '');
}
};

Просмотреть файл

@ -206,10 +206,6 @@ exports.authenticate = function (res, credentials, artifacts, options) {
// Generate a bewit value for a given URI
/*
* credentials is an object with the following keys: 'id, 'key', 'algorithm'.
* options is an object with the following optional keys: 'ext', 'localtimeOffsetMsec'
*/
/*
uri: 'http://example.com/resource?a=b' or object from Url.parse()
options: {

Просмотреть файл

@ -1,7 +1,7 @@
{
"name": "hawk",
"description": "HTTP Hawk Authentication Scheme",
"version": "2.2.3",
"version": "2.3.0",
"author": "Eran Hammer <eran@hammer.io> (http://hueniverse.com)",
"contributors": [],
"repository": "git://github.com/hueniverse/hawk",
@ -23,7 +23,7 @@
"sntp": "1.x.x"
},
"devDependencies": {
"lab": "3.x.x"
"lab": "4.x.x"
},
"scripts": {
"test": "make test-cov"

Просмотреть файл

@ -14,11 +14,10 @@ var internals = {};
// Test shortcuts
var lab = exports.lab = Lab.script();
var describe = lab.experiment;
var it = lab.test;
var expect = Lab.expect;
var before = Lab.before;
var after = Lab.after;
var describe = Lab.experiment;
var it = Lab.test;
describe('Browser', function () {

Просмотреть файл

@ -12,11 +12,10 @@ var internals = {};
// Test shortcuts
var lab = exports.lab = Lab.script();
var describe = lab.experiment;
var it = lab.test;
var expect = Lab.expect;
var before = Lab.before;
var after = Lab.after;
var describe = Lab.experiment;
var it = Lab.test;
describe('Hawk', function () {

Просмотреть файл

@ -11,11 +11,10 @@ var internals = {};
// Test shortcuts
var lab = exports.lab = Lab.script();
var describe = lab.experiment;
var it = lab.test;
var expect = Lab.expect;
var before = Lab.before;
var after = Lab.after;
var describe = Lab.experiment;
var it = Lab.test;
describe('Hawk', function () {

Просмотреть файл

@ -12,11 +12,10 @@ var internals = {};
// Test shortcuts
var lab = exports.lab = Lab.script();
var describe = lab.experiment;
var it = lab.test;
var expect = Lab.expect;
var before = Lab.before;
var after = Lab.after;
var describe = Lab.experiment;
var it = Lab.test;
describe('Hawk', function () {

Просмотреть файл

@ -13,11 +13,10 @@ var internals = {};
// Test shortcuts
var lab = exports.lab = Lab.script();
var describe = lab.experiment;
var it = lab.test;
var expect = Lab.expect;
var before = Lab.before;
var after = Lab.after;
var describe = Lab.experiment;
var it = Lab.test;
describe('Hawk', function () {

Просмотреть файл

@ -12,11 +12,10 @@ var internals = {};
// Test shortcuts
var lab = exports.lab = Lab.script();
var describe = lab.experiment;
var it = lab.test;
var expect = Lab.expect;
var before = Lab.before;
var after = Lab.after;
var describe = Lab.experiment;
var it = Lab.test;
describe('Hawk', function () {

Просмотреть файл

@ -12,11 +12,10 @@ var internals = {};
// Test shortcuts
var lab = exports.lab = Lab.script();
var describe = lab.experiment;
var it = lab.test;
var expect = Lab.expect;
var before = Lab.before;
var after = Lab.after;
var describe = Lab.experiment;
var it = Lab.test;
describe('Hawk', function () {

Просмотреть файл

@ -14,11 +14,10 @@ var internals = {};
// Test shortcuts
var lab = exports.lab = Lab.script();
var describe = lab.experiment;
var it = lab.test;
var expect = Lab.expect;
var before = Lab.before;
var after = Lab.after;
var describe = Lab.experiment;
var it = Lab.test;
describe('Hawk', function () {

Просмотреть файл

@ -12,11 +12,10 @@ var internals = {};
// Test shortcuts
var lab = exports.lab = Lab.script();
var describe = lab.experiment;
var it = lab.test;
var expect = Lab.expect;
var before = Lab.before;
var after = Lab.after;
var describe = Lab.experiment;
var it = Lab.test;
describe('Hawk', function () {