From 0656c8d7e041807fd9793113279db86712dcf13d Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Mon, 27 Oct 2014 10:49:25 -0300 Subject: [PATCH] fixed delete wallet --- config.js | 2 +- js/models/Identity.js | 16 +++++++++++----- js/plugins/EncryptedInsightStorage.js | 19 +++++++++++++------ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/config.js b/config.js index 72e9c6d30..da19b8a87 100644 --- a/config.js +++ b/config.js @@ -61,7 +61,7 @@ var defaultConfig = { }, EncryptedInsightStorage: { - url: 'https://test-insight.bitpay.com:443/api/email' + url: 'http://localhost:3001/api/email' }, GoogleDrive: { diff --git a/js/models/Identity.js b/js/models/Identity.js index 843726495..a87cdcfce 100644 --- a/js/models/Identity.js +++ b/js/models/Identity.js @@ -224,13 +224,19 @@ Identity.prototype.storeWallet = function(wallet, cb) { }; Identity.prototype.toObj = function() { - return _.extend({walletIds: _.keys(this.wallets)}, - _.pick(this, 'version', 'fullName', 'password', 'email')); + return _.extend({ + walletIds: _.keys(this.wallets) + }, + _.pick(this, 'version', 'fullName', 'password', 'email')); }; Identity.prototype.exportWithWalletInfo = function() { - return _.extend({wallets: _.map(this.wallets, function(wallet) { return wallet.toObj(); })}, - _.pick(this, 'version', 'fullName', 'password', 'email')); + return _.extend({ + 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; delete this.wallets[walletId]; - this.storage.deleteItem(walletId, function(err) { + this.storage.removeItem(Wallet.getStorageKey(walletId), function(err) { if (err) { return cb(err); } diff --git a/js/plugins/EncryptedInsightStorage.js b/js/plugins/EncryptedInsightStorage.js index c1c3d998a..bd0d86e28 100644 --- a/js/plugins/EncryptedInsightStorage.js +++ b/js/plugins/EncryptedInsightStorage.js @@ -9,13 +9,15 @@ inherits(EncryptedInsightStorage, InsightStorage); EncryptedInsightStorage.prototype.getItem = function(name, callback) { var key = cryptoUtil.kdf(this.password, this.email); - InsightStorage.prototype.getItem.apply(this, [name, function(err, body) { - var decryptedJson = cryptoUtil.decrypt(key, body); - if (!decryptedJson) { - return callback('Internal Error'); + InsightStorage.prototype.getItem.apply(this, [name, + function(err, body) { + var decryptedJson = cryptoUtil.decrypt(key, body); + if (!decryptedJson) { + return callback('Internal Error'); + } + return callback(null, decryptedJson); } - return callback(null, decryptedJson); - }]); + ]); }; 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]); }; +EncryptedInsightStorage.prototype.removeItem = function(name, callback) { + var key = cryptoUtil.kdf(this.password, this.email); + InsightStorage.prototype.removeItem.apply(this, [name, callback]); +}; + module.exports = EncryptedInsightStorage;