Merge pull request #3375 from bitpay/v1.4

v1.4 -> master
This commit is contained in:
Gustavo Maximiliano Cortez 2015-10-30 15:43:17 -03:00
commit f3d12f5a14
17 changed files with 141 additions and 91 deletions

View file

@ -5,27 +5,38 @@ angular.module('copayApp.controllers').controller('wordsController',
var msg = gettext('Are you sure you want to delete the backup words?');
var successMsg = gettext('Backup words deleted');
this.show = false;
var self = this;
self.show = false;
var fc = profileService.focusedClient;
this.toggle = function() {
this.show = !this.show;
if (fc.isPrivKeyEncrypted()) self.credentialsEncrypted = true;
else {
setWords(fc.getMnemonic());
$rootScope.$emit('Local/BackupDone');
}
if (fc.credentials && !fc.credentials.mnemonicEncrypted && !fc.credentials.mnemonic) {
self.deleted = true;
}
if (this.show)
$rootScope.$emit('Local/BackupDone');
self.toggle = function() {
self.error = "";
if (!self.credentialsEncrypted)
self.show = !self.show;
$timeout(function(){
if (self.credentialsEncrypted)
self.passwordRequest();
$timeout(function() {
$scope.$apply();
}, 1);
};
this.delete = function() {
var fc = profileService.focusedClient;
self.delete = function() {
confirmDialog.show(msg, function(ok) {
if (ok) {
fc.clearMnemonic();
profileService.updateCredentialsFC(function() {
self.deleted = true;
notification.success(successMsg);
go.walletHome();
});
@ -33,12 +44,10 @@ angular.module('copayApp.controllers').controller('wordsController',
});
};
$scope.$on('$destroy', function() {
profileService.lockFC();
});
function setWords(words) {
if (words) {
self.mnemonicWords = words.split(/[\u3000\s]+/);
@ -47,26 +56,30 @@ angular.module('copayApp.controllers').controller('wordsController',
}
};
var fc = profileService.focusedClient;
try {
setWords(fc.getMnemonic());
} catch (e) {
if (e.message && e.message.match(/encrypted/) && fc.isPrivKeyEncrypted()) {
self.credentialsEncrypted = true;
self.passwordRequest = function() {
try {
setWords(fc.getMnemonic());
} catch (e) {
if (e.message && e.message.match(/encrypted/) && fc.isPrivKeyEncrypted()) {
self.credentialsEncrypted = true;
$timeout(function(){
$scope.$apply();
}, 1);
$timeout(function() {
$scope.$apply();
}, 1);
profileService.unlockFC(function(err) {
if (err) {
self.error = bwsError.msg(err, gettext('Could not decrypt'));
$log.warn('Error decrypting credentials:',self.error); //TODO
return;
}
self.credentialsEncrypted = false;
setWords(fc.getMnemonic());
});
}
profileService.unlockFC(function(err) {
if (err) {
self.error = bwsError.msg(err, gettext('Could not decrypt'));
$log.warn('Error decrypting credentials:', self.error); //TODO
return;
}
if (!self.show && self.credentialsEncrypted)
self.show = !self.show;
self.credentialsEncrypted = false;
setWords(fc.getMnemonic());
$rootScope.$emit('Local/BackupDone');
});
}
}
}
});
});

View file

@ -1116,13 +1116,16 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.needsBackup = false;
$log.debug('Backup done');
storageService.setBackupFlag(self.walletId, function(err) {
if (err) root.showErrorPopup(err);
$log.debug('Backup done stored');
});
});
$rootScope.$on('Local/DeviceError', function(event, err) {
root.showErrorPopup(err);
self.showErrorPopup(err, function() {
if (self.isCordova && navigator && navigator.app) {
navigator.app.exitApp();
}
});
});
$rootScope.$on('Local/WalletImported', function(event, walletId) {

View file

@ -67,7 +67,11 @@ angular.module('copayApp.directives')
localMediaStreamTrack[i].stop();
}
} else {
localMediaStream.stop();
try {
localMediaStream.stop();
} catch(e) {
// Older Chromium not support the STOP function
};
}
localMediaStream = null;
video.src = '';

View file

@ -515,10 +515,10 @@ angular
// Try to open local profile
profileService.loadAndBindProfile(function(err) {
if (err) {
if (err.message.match('NOPROFILE')) {
if (err.message && err.message.match('NOPROFILE')) {
$log.debug('No profile... redirecting');
$state.transitionTo('splash');
} else if (err.message.match('NONAGREEDDISCLAIMER')) {
} else if (err.message && err.message.match('NONAGREEDDISCLAIMER')) {
$log.debug('Display disclaimer... redirecting');
$state.transitionTo('disclaimer');
} else {
@ -545,4 +545,4 @@ angular
}, 50);
}
});
});
});

View file

@ -14,17 +14,15 @@ angular.module('copayApp.services')
} else {
// Go home reloading the application
if (isChromeApp) {
if (nodeWebkit.isDefined()) {
go.walletHome();
$timeout(function() {
var win = require('nw.gui').Window.get();
win.reload(3);
//or
win.reloadDev();
}, 100);
} else {
chrome.runtime.reload();
}
chrome.runtime.reload();
} else if (nodeWebkit.isDefined()) {
go.walletHome();
$timeout(function() {
var win = require('nw.gui').Window.get();
win.reload(3);
//or
win.reloadDev();
}, 100);
} else {
window.location = window.location.href.substr(0, hashIndex);
}

View file

@ -41,15 +41,23 @@ angular.module('copayApp.services')
json = JSON.parse(text);
} catch (e) {};
if (!json) return cb('Could not access storage')
if (!json.iter || !json.ct)
return cb(null, text);
$log.debug('Profile is encrypted');
getUUID(function(uuid) {
$log.debug('Device UUID:' + uuid);
if (!uuid)
return cb(new Error('Could not decrypt localstorage profile'));
return cb('Could not decrypt storage: could not get device ID');
text = sjcl.decrypt(uuid, text);
try {
text = sjcl.decrypt(uuid, text);
} catch(e) {
$log.warn('Decrypt error: ', e);
return cb('Could not decrypt storage: device ID mismatch');
};
return cb(null, text);
});
};