Skip to content

Commit

Permalink
Update hawk to 7.0.7 (#2880)
Browse files Browse the repository at this point in the history
  • Loading branch information
kornel-kedzierski authored and mikeal committed Mar 6, 2018
1 parent 253c5e5 commit cfd2307
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -35,7 +35,7 @@
"forever-agent": "~0.6.1",
"form-data": "~2.3.1",
"har-validator": "~5.0.3",
"hawk": "~6.0.2",
"hawk": "~7.0.7",
"http-signature": "~1.2.0",
"is-typedarray": "~1.0.0",
"isstream": "~0.1.2",
Expand Down
2 changes: 1 addition & 1 deletion request.js
Expand Up @@ -1426,7 +1426,7 @@ Request.prototype.httpSignature = function (opts) {
}
Request.prototype.hawk = function (opts) {
var self = this
self.setHeader('Authorization', hawk.client.header(self.uri, self.method, opts).field)
self.setHeader('Authorization', hawk.client.header(self.uri, self.method, opts).header)
}
Request.prototype.oauth = function (_oauth) {
var self = this
Expand Down
18 changes: 10 additions & 8 deletions tests/test-hawk.js
Expand Up @@ -7,22 +7,24 @@ var tape = require('tape')
var assert = require('assert')

var server = http.createServer(function (req, res) {
var getCred = function (id, callback) {
var getCred = function (id) {
assert.equal(id, 'dh37fgj492je')
var credentials = {
key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',
algorithm: 'sha256',
user: 'Steve'
}
return callback(null, credentials)
return credentials
}

hawk.server.authenticate(req, getCred, {}, function (err, credentials, attributes) {
res.writeHead(err ? 401 : 200, {
'Content-Type': 'text/plain'
hawk.server.authenticate(req, getCred)
.then((credentials, artifacts) => {
res.writeHead(200, {'Content-Type': 'text/plain'})
res.end('Hello ' + credentials.credentials.user)
})
.catch(() => {
res.writeHead(401, {'Content-Type': 'text/plain'})
res.end('Shoosh!')
})
res.end(err ? 'Shoosh!' : 'Hello ' + credentials.user)
})
})

tape('setup', function (t) {
Expand Down

0 comments on commit cfd2307

Please sign in to comment.