fixed delete wallet

This commit is contained in:
Ivan Socolsky 2014-10-27 10:49:25 -03:00
parent a8571d5a24
commit 0656c8d7e0
3 changed files with 25 additions and 12 deletions

View File

@ -61,7 +61,7 @@ var defaultConfig = {
}, },
EncryptedInsightStorage: { EncryptedInsightStorage: {
url: 'https://test-insight.bitpay.com:443/api/email' url: 'http://localhost:3001/api/email'
}, },
GoogleDrive: { GoogleDrive: {

View File

@ -224,13 +224,19 @@ Identity.prototype.storeWallet = function(wallet, cb) {
}; };
Identity.prototype.toObj = function() { Identity.prototype.toObj = function() {
return _.extend({walletIds: _.keys(this.wallets)}, return _.extend({
_.pick(this, 'version', 'fullName', 'password', 'email')); walletIds: _.keys(this.wallets)
},
_.pick(this, 'version', 'fullName', 'password', 'email'));
}; };
Identity.prototype.exportWithWalletInfo = function() { Identity.prototype.exportWithWalletInfo = function() {
return _.extend({wallets: _.map(this.wallets, function(wallet) { return wallet.toObj(); })}, return _.extend({
_.pick(this, 'version', 'fullName', 'password', 'email')); wallets: _.map(this.wallets, function(wallet) {
return wallet.toObj();
})
},
_.pick(this, 'version', 'fullName', 'password', 'email'));
}; };
/** /**
@ -493,7 +499,7 @@ Identity.prototype.deleteWallet = function(walletId, cb) {
var self = this; var self = this;
delete this.wallets[walletId]; delete this.wallets[walletId];
this.storage.deleteItem(walletId, function(err) { this.storage.removeItem(Wallet.getStorageKey(walletId), function(err) {
if (err) { if (err) {
return cb(err); return cb(err);
} }

View File

@ -9,13 +9,15 @@ inherits(EncryptedInsightStorage, InsightStorage);
EncryptedInsightStorage.prototype.getItem = function(name, callback) { EncryptedInsightStorage.prototype.getItem = function(name, callback) {
var key = cryptoUtil.kdf(this.password, this.email); var key = cryptoUtil.kdf(this.password, this.email);
InsightStorage.prototype.getItem.apply(this, [name, function(err, body) { InsightStorage.prototype.getItem.apply(this, [name,
var decryptedJson = cryptoUtil.decrypt(key, body); function(err, body) {
if (!decryptedJson) { var decryptedJson = cryptoUtil.decrypt(key, body);
return callback('Internal Error'); if (!decryptedJson) {
return callback('Internal Error');
}
return callback(null, decryptedJson);
} }
return callback(null, decryptedJson); ]);
}]);
}; };
EncryptedInsightStorage.prototype.setItem = function(name, value, callback) { EncryptedInsightStorage.prototype.setItem = function(name, value, callback) {
@ -24,4 +26,9 @@ EncryptedInsightStorage.prototype.setItem = function(name, value, callback) {
InsightStorage.prototype.setItem.apply(this, [name, record, callback]); InsightStorage.prototype.setItem.apply(this, [name, record, callback]);
}; };
EncryptedInsightStorage.prototype.removeItem = function(name, callback) {
var key = cryptoUtil.kdf(this.password, this.email);
InsightStorage.prototype.removeItem.apply(this, [name, callback]);
};
module.exports = EncryptedInsightStorage; module.exports = EncryptedInsightStorage;