Skip to content

Commit

Permalink
Revert "Update hawk to 7.0.7 (#2880)"
Browse files Browse the repository at this point in the history
This reverts commit cfd2307.
  • Loading branch information
simov committed Mar 12, 2018
1 parent b191514 commit 5ba8eb4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 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": "~7.0.7",
"hawk": "~6.0.2",
"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).header)
self.setHeader('Authorization', hawk.client.header(self.uri, self.method, opts).field)
}
Request.prototype.oauth = function (_oauth) {
var self = this
Expand Down
18 changes: 8 additions & 10 deletions tests/test-hawk.js
Expand Up @@ -7,24 +7,22 @@ var tape = require('tape')
var assert = require('assert')

var server = http.createServer(function (req, res) {
var getCred = function (id) {
var getCred = function (id, callback) {
assert.equal(id, 'dh37fgj492je')
var credentials = {
key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn',
algorithm: 'sha256',
user: 'Steve'
}
return credentials
return callback(null, credentials)
}
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!')

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

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

0 comments on commit 5ba8eb4

Please sign in to comment.