Merge pull request #15 from isocolsky/http_method
add http method to request signature
This commit is contained in:
commit
864b45f098
2
app.js
2
app.js
|
@ -83,7 +83,7 @@ function getServerWithAuth(req, res, cb) {
|
||||||
var credentials = getCredentials(req);
|
var credentials = getCredentials(req);
|
||||||
var auth = {
|
var auth = {
|
||||||
copayerId: credentials.copayerId,
|
copayerId: credentials.copayerId,
|
||||||
message: req.url + '|' + JSON.stringify(req.body),
|
message: req.method.toLowerCase() + '|' + req.url + '|' + JSON.stringify(req.body),
|
||||||
signature: credentials.signature,
|
signature: credentials.signature,
|
||||||
};
|
};
|
||||||
CopayServer.getInstanceWithAuth(auth, function(err, server) {
|
CopayServer.getInstanceWithAuth(auth, function(err, server) {
|
||||||
|
|
|
@ -38,8 +38,8 @@ function _parseError(body) {
|
||||||
log.error(code, message);
|
log.error(code, message);
|
||||||
};
|
};
|
||||||
|
|
||||||
function _signRequest(url, args, privKey) {
|
function _signRequest(method, url, args, privKey) {
|
||||||
var message = url + '|' + JSON.stringify(args);
|
var message = method.toLowerCase() + '|' + url + '|' + JSON.stringify(args);
|
||||||
return SignUtils.sign(message, privKey);
|
return SignUtils.sign(message, privKey);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,16 +83,16 @@ ClientLib.prototype._loadAndCheck = function() {
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
ClientLib.prototype._doRequest = function(type, url, args, data, cb) {
|
ClientLib.prototype._doRequest = function(method, url, args, data, cb) {
|
||||||
var reqSignature = _signRequest(url, args, data.signingPrivKey);
|
var reqSignature = _signRequest(method, url, args, data.signingPrivKey);
|
||||||
var absUrl = _getUrl(url);
|
var absUrl = _getUrl(url);
|
||||||
request({
|
request({
|
||||||
headers: {
|
headers: {
|
||||||
'x-identity': data.copayerId,
|
'x-identity': data.copayerId,
|
||||||
'x-signature': reqSignature,
|
'x-signature': reqSignature,
|
||||||
},
|
},
|
||||||
method: type,
|
method: method,
|
||||||
url: absUrl,
|
url: absUrl,
|
||||||
body: args,
|
body: args,
|
||||||
json: true,
|
json: true,
|
||||||
|
|
Loading…
Reference in New Issue