diff --git a/app.js b/app.js index 7eb3f00..7cd3ccb 100644 --- a/app.js +++ b/app.js @@ -83,7 +83,7 @@ function getServerWithAuth(req, res, cb) { var credentials = getCredentials(req); var auth = { copayerId: credentials.copayerId, - message: req.url + '|' + JSON.stringify(req.body), + message: req.method.toLowerCase() + '|' + req.url + '|' + JSON.stringify(req.body), signature: credentials.signature, }; CopayServer.getInstanceWithAuth(auth, function(err, server) { diff --git a/lib/clientlib.js b/lib/clientlib.js index b9e9cf2..6993354 100644 --- a/lib/clientlib.js +++ b/lib/clientlib.js @@ -38,8 +38,8 @@ function _parseError(body) { log.error(code, message); }; -function _signRequest(url, args, privKey) { - var message = url + '|' + JSON.stringify(args); +function _signRequest(method, url, args, privKey) { + var message = method.toLowerCase() + '|' + url + '|' + JSON.stringify(args); return SignUtils.sign(message, privKey); }; @@ -83,16 +83,16 @@ ClientLib.prototype._loadAndCheck = function() { } return data; }; - -ClientLib.prototype._doRequest = function(type, url, args, data, cb) { - var reqSignature = _signRequest(url, args, data.signingPrivKey); + +ClientLib.prototype._doRequest = function(method, url, args, data, cb) { + var reqSignature = _signRequest(method, url, args, data.signingPrivKey); var absUrl = _getUrl(url); request({ headers: { 'x-identity': data.copayerId, 'x-signature': reqSignature, }, - method: type, + method: method, url: absUrl, body: args, json: true,