1 var createServer = require('http').createServer
2 , request = require('../index')
3 , hawk = require('hawk')
4 , assert = require('assert')
7 var server = createServer(function (req, resp) {
9 var getCred = function (id, callback) {
10 assert.equal(id, 'dh37fgj492je')
12 { key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn'
16 return callback(null, credentials)
19 hawk.server.authenticate(req, getCred, {}, function (err, credentials, attributes) {
20 resp.writeHead(!err ? 200 : 401, { 'Content-Type': 'text/plain' })
21 resp.end(!err ? 'Hello ' + credentials.user : 'Shoosh!')
26 server.listen(8080, function () {
27 var creds = {key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn', algorithm: 'sha256', id:'dh37fgj492je'}
28 request('http://localhost:8080', {hawk:{credentials:creds}}, function (e, r, b) {
29 assert.equal(200, r.statusCode)
30 assert.equal(b, 'Hello Steve')