fix import wallets and profile form 0.7.2
This commit is contained in:
parent
e614b375e7
commit
b15679c08c
4 changed files with 45 additions and 28 deletions
|
|
@ -198,13 +198,23 @@ Compatibility.importEncryptedWallet = function(identity, cypherText, password, o
|
||||||
var crypto = (opts && opts.cryptoUtil) || cryptoUtils;
|
var crypto = (opts && opts.cryptoUtil) || cryptoUtils;
|
||||||
|
|
||||||
var obj = crypto.decrypt(password, cypherText);
|
var obj = crypto.decrypt(password, cypherText);
|
||||||
|
if (!obj) {
|
||||||
|
// 0.7.3 broken KDF
|
||||||
|
log.debug('Trying legacy encryption 0.7.2...');
|
||||||
|
var passphrase = crypto.kdf(password, 'mjuBtGybi/4=', 100);
|
||||||
|
obj = crypto.decrypt(passphrase, cypherText);
|
||||||
|
}
|
||||||
|
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
log.info("Could not decrypt, trying legacy..");
|
log.info("Could not decrypt, trying legacy..");
|
||||||
obj = Compatibility.importLegacy(cypherText, password);
|
obj = Compatibility.importLegacy(cypherText, password);
|
||||||
if (!obj) {
|
|
||||||
return cb('Could not decrypt', null);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!obj) {
|
||||||
|
return cb('Could not decrypt', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
obj = JSON.parse(obj);
|
obj = JSON.parse(obj);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -285,29 +285,35 @@ Identity.prototype.close = function(cb) {
|
||||||
* @param {string[]} opts.importFunction - for stubbing
|
* @param {string[]} opts.importFunction - for stubbing
|
||||||
* @return {Wallet}
|
* @return {Wallet}
|
||||||
*/
|
*/
|
||||||
Identity.prototype.importEncryptedWallet = function(cypherText, password, opts, cb) {
|
|
||||||
var crypto = opts.cryptoUtil || cryptoUtil;
|
|
||||||
var obj = crypto.decrypt(password, cypherText);
|
|
||||||
console.log('[Identity.js.290:obj:]',obj); //TODO
|
|
||||||
|
|
||||||
if (!obj) {
|
// This is not used in favor of Compatibility. importEncryptedWallet
|
||||||
// 0.7.3 broken KDF
|
|
||||||
log.debug('Trying legacy encryption...');
|
|
||||||
var passphrase = crypto.kdf(password, 'mjuBtGybi/4=', 100);
|
|
||||||
obj = crypto.decrypt(passphrase, ejson);
|
|
||||||
}
|
|
||||||
console.log('[Identity.js.300:obj:]',obj); //TOD
|
|
||||||
|
|
||||||
if (!obj)
|
|
||||||
return cb(new Error('Could not decrypt'));
|
|
||||||
try {
|
|
||||||
obj = JSON.parse(obj);
|
|
||||||
} catch (e) {
|
|
||||||
return cb(new Error('Could not decrypt'));
|
|
||||||
}
|
|
||||||
return this.importWalletFromObj(obj, opts, cb)
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// Identity.prototype.importEncryptedWallet = function(cypherText, password, opts, cb) {
|
||||||
|
// var crypto = opts.cryptoUtil || cryptoUtil;
|
||||||
|
// var obj = crypto.decrypt(password, cypherText);
|
||||||
|
// console.log('[Identity.js.290:obj:]',obj); //TODO
|
||||||
|
//
|
||||||
|
// if (!obj) {
|
||||||
|
// // 0.7.3 broken KDF
|
||||||
|
// log.debug('Trying legacy encryption...');
|
||||||
|
// console.log('[Identity.js.296:password:]',password); //TODO
|
||||||
|
// var passphrase = crypto.kdf(password, 'mjuBtGybi/4=', 100);
|
||||||
|
// console.log('[Identity.js.296:passphrase:]',passphrase); //TODO
|
||||||
|
// obj = crypto.decrypt(passphrase, ejson);
|
||||||
|
// console.log('[Identity.js.297:obj:]',obj); //TODO
|
||||||
|
// }
|
||||||
|
// console.log('[Identity.js.300:obj:]',obj); //TOD
|
||||||
|
//
|
||||||
|
// if (!obj)
|
||||||
|
// return cb(new Error('Could not decrypt'));
|
||||||
|
// try {
|
||||||
|
// obj = JSON.parse(obj);
|
||||||
|
// } catch (e) {
|
||||||
|
// return cb(new Error('Could not decrypt'));
|
||||||
|
// }
|
||||||
|
// return this.importWalletFromObj(obj, opts, cb)
|
||||||
|
// };
|
||||||
|
//
|
||||||
Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
preconditions.checkArgument(cb);
|
preconditions.checkArgument(cb);
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,8 @@ describe('Identity model', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#importWallet', function() {
|
// This is implemented in Compatibility
|
||||||
|
describe.skip('#importWallet', function() {
|
||||||
it('should import a wallet, call the right encryption functions', function(done) {
|
it('should import a wallet, call the right encryption functions', function(done) {
|
||||||
var args = createIdentity();
|
var args = createIdentity();
|
||||||
args.storage.getItem.onFirstCall().callsArgWith(1, null, '{"wallet": "fakeData"}');
|
args.storage.getItem.onFirstCall().callsArgWith(1, null, '{"wallet": "fakeData"}');
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,11 @@
|
||||||
<div class="large-12 columns">
|
<div class="large-12 columns">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<form name="importForm" ng-submit="import(importForm)" novalidate>
|
<form name="importForm" ng-submit="import(importForm)" novalidate>
|
||||||
<p class="text-warning size-12"
|
<div class="text-warning size-12 m20b"
|
||||||
ng-show="error">
|
ng-show="error">
|
||||||
<i class="fi-x"></i>
|
<i class="fi-x"></i>
|
||||||
{{error|translate}}
|
{{error|translate}}
|
||||||
</p>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div ng-show="!is_iOS && !backupOldWallet">
|
<div ng-show="!is_iOS && !backupOldWallet">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue