Replace `x-pubkey` with `x-identity`.
This commit is contained in:
parent
72e61ee7c1
commit
0235eb3a7c
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,4 +32,4 @@ app.get('/pizzas', function(req, res) {
|
|||
res.send(200, pizzas);
|
||||
});
|
||||
|
||||
app.listen(3000);
|
||||
app.listen(3000);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue