Skip to content
This repository has been archived by the owner on Apr 20, 2019. It is now read-only.

Commit

Permalink
Cleanup. Closes #38
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Nov 11, 2018
1 parent 7d110a6 commit 4bcf105
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 77 deletions.
28 changes: 8 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
.idea
*.iml
npm-debug.log
dump.rdb
node_modules
results.tap
results.xml
npm-shrinkwrap.json
config.json
.DS_Store
*/.DS_Store
*/*/.DS_Store
._*
*/._*
*/*/._*
**/node_modules
**/package-lock.json

coverage.*
lib-cov
*.swp
*.swo
*.swn
package-lock.json

**/.DS_Store
**/._*

**/*.pem
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ language: node_js

node_js:
- "8"
- "9"
- "10"
- "11"
- "node"

sudo: false
8 changes: 2 additions & 6 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright (c) 2012-2017, Project contributors.
Copyright (c) 2012-2014, Walmart.
Copyright (c) 2012-2018, Project contributors
Copyright (c) 2012-2014, Walmart
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -23,7 +23,3 @@ 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/hapijs/hapi-auth-hawk/graphs/contributors
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![Build Status](https://secure.travis-ci.org/hapijs/hapi-auth-hawk.png)](http://travis-ci.org/hapijs/hapi-auth-hawk)

Lead Maintainer: [Matt Harrison](https://github.com/mtharrison)
Lead Maintainer: [Eran Hammer](https://github.com/hueniverse)

#### Hawk authentication

Expand Down
12 changes: 5 additions & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
'use strict';

// Load modules

const Boom = require('boom');
const Hawk = require('hawk');
const Hoek = require('hoek');


// Declare internals

const internals = {};


exports.plugin = {
pkg: require('../package.json'),
requirements: {
hapi: '>=17.7.0'
},
register: function (server) {

server.auth.scheme('hawk', internals.hawk);
Expand Down Expand Up @@ -83,9 +82,8 @@ internals.hawk = function (server, options) {

response.header('trailer', 'server-authorization');
response.header('transfer-encoding', 'chunked');
// We must not send a content-length header alongside transfer-encoding.
// see https://tools.ietf.org/html/rfc7230#section-3.3.3
delete response.headers['content-length'];

delete response.headers['content-length']; // Cannot not send a content-length header alongside transfer-encoding (https://tools.ietf.org/html/rfc7230#section-3.3.3)

response.events.on('peek', (chunk) => {

Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@
"hawk",
"bewit"
],
"engines": {
"node": ">=8.9.0"
},
"dependencies": {
"boom": "7.x.x",
"hoek": "5.x.x",
"hoek": "6.x.x",
"hawk": "7.x.x"
},
"peerDependencies": {
Expand All @@ -25,7 +22,7 @@
"devDependencies": {
"code": "5.x.x",
"hapi": "17.x.x",
"lab": "15.x.x"
"lab": "17.x.x"
},
"scripts": {
"test": "lab -r console -t 100 -a code -L",
Expand Down
13 changes: 3 additions & 10 deletions test/bewit.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
'use strict';

// Load modules

const Boom = require('boom');
const Code = require('code');
const Hapi = require('hapi');
const Hawk = require('hawk');
const Lab = require('lab');


// Declare internals

const internals = {};


// Test shortcuts

const lab = exports.lab = Lab.script();
const describe = lab.describe;
const it = lab.it;
const before = lab.before;
const { it, describe, before } = exports.lab = Lab.script();
const expect = Code.expect;


Expand All @@ -44,6 +35,7 @@ describe('bewit scheme', () => {
if (credentials[id].err) {
throw credentials[id].err;
}

return credentials[id].cred;
}
};
Expand All @@ -53,6 +45,7 @@ describe('bewit scheme', () => {
if (credentials[id] && credentials[id].cred) {
return Hawk.uri.getBewit('http://example.com:8080' + path, { credentials: credentials[id].cred, ttlSec: 60 });
}

return '';
};

Expand Down
45 changes: 18 additions & 27 deletions test/hawk.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
'use strict';

// Load modules

const Stream = require('stream');

const Boom = require('boom');
const Code = require('code');
const Hapi = require('hapi');
const Hawk = require('hawk');
const Hoek = require('hoek');
const Lab = require('lab');


// Declare internals

const internals = {};


// Test shortcuts

const lab = exports.lab = Lab.script();
const describe = lab.describe;
const it = lab.it;
const { it, describe } = exports.lab = Lab.script();
const expect = Code.expect;


Expand Down Expand Up @@ -52,6 +44,7 @@ describe('hawk scheme', () => {
if (credentials[id].err) {
throw credentials[id].err;
}

return credentials[id].cred;
}
};
Expand All @@ -61,6 +54,7 @@ describe('hawk scheme', () => {
if (credentials[id] && credentials[id].cred) {
return Hawk.client.header('http://example.com:8080' + path, 'POST', { credentials: credentials[id].cred });
}

return '';
};

Expand Down Expand Up @@ -113,31 +107,28 @@ describe('hawk scheme', () => {

const hawkStreamHandler = function (request, h) {

const TestStream = function () {
const TestStream = class extends Stream.Readable {

Stream.Readable.call(this);
};
_read(size) {

Hoek.inherits(TestStream, Stream.Readable);
const self = this;

TestStream.prototype._read = function (size) {
if (this.isDone) {
return;
}

const self = this;
this.isDone = true;

if (this.isDone) {
return;
}
this.isDone = true;
setTimeout(() => {

setTimeout(() => {
self.push('hi');
}, 2);

self.push('hi');
}, 2);
setTimeout(() => {

setTimeout(() => {

self.push(null);
}, 5);
self.push(null);
}, 5);
}
};

const stream = new TestStream();
Expand Down

0 comments on commit 4bcf105

Please sign in to comment.