fix signature

This commit is contained in:
Ivan Socolsky 2015-02-13 00:50:57 -03:00
parent 18252b2cae
commit 681b8e0bf6
3 changed files with 9 additions and 12 deletions

4
app.js
View File

@ -77,10 +77,9 @@ function getServerWithAuth(req, res, cb) {
var credentials = getCredentials(req);
var auth = {
copayerId: credentials.copayerId,
message: req.url + req.body ? '|' + JSON.stringify(req.body) : '',
message: req.url + '|' + JSON.stringify(req.body),
signature: credentials.signature,
};
CopayServer.getInstanceWithAuth(auth, function(err, server) {
if (err) return returnError(err, res);
return cb(server);
@ -110,7 +109,6 @@ router.post('/v1/wallets/:id/copayers/', function(req, res) {
router.get('/v1/wallets/', function(req, res) {
getServerWithAuth(req, res, function(server) {
if (err) return returnError(err, res);
server.getWallet({}, function(err, wallet) {
if (err) returnError(err, res);
res.json(wallet);

1
copay.dat Normal file
View File

@ -0,0 +1 @@
{"xPrivKey":"xprv9s21ZrQH143K2uyafhWe3R9ZTTmQUyteFd6QGAFbHZTwBS8DeF8f1a6rYDKewR1JJzdWDJcvGZek4yD6rVmSDUjKGY475TGueeo3PQpupCS","m":1,"secret":"182bd4b9-1a2c-4d6d-8a23-f24b57c4fe31|3a7f5a37738bcb397bf23f9c3ee73463c0dac9269ead6bfb31f6fae7a7abc1bd","copayerId":"d9942e96-47c1-49a2-85ad-3543cff84fa6","signingPrivKey":"xpub6AUPGinc75EWpFQGjYMbAUaGGZZYTU2zEZJiyEYtKWb6oVY3DZV8WTstpWarRXXshABeo8G2azn35MfBZCM9dMerg4JhtMi1RTE1hQCMKgq","n":1,"publicKeyRing":["xpub661MyMwAqRbcFQ43mj3eQZ6J1VbttScVcr214YfCqtzv4ETNBnSuZNRLPUcFopCszn5UhYC4PYpqmz2mZEeGb5yL2jcFeDdGEVKMY4jZk16"]}

View File

@ -29,9 +29,7 @@ function _parseError(body) {
};
function _signRequest(url, args, privKey) {
var message = url + (args ? '|' + JSON.stringify(args) : '');
console.log('[clilib.js.32:message:]',message); //TODO
console.log('[clilib.js.34:privKey:]',privKey); //TODO
var message = url + '|' + JSON.stringify(args);
return SignUtils.sign(message, privKey);
};
@ -47,7 +45,7 @@ function CliLib(opts) {
};
CliLib.prototype._save = function (data) {
CliLib.prototype._save = function(data) {
fs.writeFileSync(this.filename, JSON.stringify(data));
};
@ -96,7 +94,7 @@ CliLib.prototype.createWallet = function(walletName, copayerName, m, n, network,
request({
method: 'post',
url: _getUrl('v1/wallets'),
url: _getUrl('/v1/wallets/'),
body: args,
json: true,
}, function(err, res, body) {
@ -142,7 +140,7 @@ CliLib.prototype._joinWallet = function(data, secret, copayerName, cb) {
request({
method: 'post',
url: _getUrl('v1/wallets/' + walletId + '/copayers'),
url: _getUrl('/v1/wallets/' + walletId + '/copayers'),
body: args,
json: true,
}, function(err, res, body) {
@ -181,10 +179,10 @@ CliLib.prototype.status = function(cb) {
var self = this;
var data = this._loadAndCheck();
console.log('[clilib.js.180:data:]',data); //TODO
console.log('[clilib.js.180:data:]', data); //TODO
var url = 'v1/wallets/';
var signature = _signRequest(url, null, data.signingPrivKey);
var url = '/v1/wallets/';
var signature = _signRequest(url, {}, data.signingPrivKey);
request({
headers: {