From 0235eb3a7cd1b1edf1204e1c68165f75859c5e78 Mon Sep 17 00:00:00 2001 From: Eric Martindale Date: Mon, 28 Jul 2014 14:16:02 -0700 Subject: [PATCH] Replace `x-pubkey` with `x-identity`. --- examples/client.js | 6 +++--- examples/server.js | 2 +- lib/middleware/bitauth.js | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/client.js b/examples/client.js index 95bec5e..ae678f0 100644 --- a/examples/client.js +++ b/examples/client.js @@ -15,7 +15,7 @@ for(k in keys) { var options = { url: url, headers: { - 'x-pubkey': bitauth.getPublicKeyFromPrivateKey(keys[k]), + 'x-identity': bitauth.getPublicKeyFromPrivateKey(keys[k]), 'x-signature': bitauth.sign(dataToSign, keys[k]) } }; @@ -41,7 +41,7 @@ for(k in keys) { var options = { url: url, headers: { - 'x-pubkey': bitauth.getPublicKeyFromPrivateKey(keys[k]), + 'x-identity': bitauth.getPublicKeyFromPrivateKey(keys[k]), 'x-signature': bitauth.sign(dataToSign, keys[k]) }, json: data @@ -55,4 +55,4 @@ for(k in keys) { console.log(body); } }); -} \ No newline at end of file +} diff --git a/examples/server.js b/examples/server.js index a9e382c..cfa8e47 100644 --- a/examples/server.js +++ b/examples/server.js @@ -32,4 +32,4 @@ app.get('/pizzas', function(req, res) { res.send(200, pizzas); }); -app.listen(3000); \ No newline at end of file +app.listen(3000); diff --git a/lib/middleware/bitauth.js b/lib/middleware/bitauth.js index b15fb86..7399e17 100644 --- a/lib/middleware/bitauth.js +++ b/lib/middleware/bitauth.js @@ -1,24 +1,24 @@ var bitauth = require('../bitauth'); module.exports = function(req, res, next) { - if(req.headers && req.headers['x-pubkey'] && req.headers['x-signature']) { + if(req.headers && req.headers['x-identity'] && req.headers['x-signature']) { // Check signature is valid // First construct data to check signature on var fullUrl = req.protocol + '://' + req.get('host') + req.url; var data = fullUrl + req.rawBody; - bitauth.verifySignature(data, req.headers['x-pubkey'], req.headers['x-signature'], function(err, result) { + bitauth.verifySignature(data, req.headers['x-identity'], req.headers['x-signature'], function(err, result) { if(err || !result) { return res.send(400, {error: 'Invalid signature'}); } // Get the SIN from the public key - var sin = bitauth.getSinFromPublicKey(req.headers['x-pubkey']); - if(!sin) return res.send(400, {error: 'Bad public key'}); + var sin = bitauth.getSinFromPublicKey(req.headers['x-identity']); + if(!sin) return res.send(400, {error: 'Bad public key from identity'}); req.sin = sin; next(); }); } else { next(); } -}; \ No newline at end of file +};