1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-25 18:32:20 -05:00

bugfix import keypair after new generation

This commit is contained in:
Tankred Hase 2013-10-13 19:04:49 +02:00
parent df24d4f7a5
commit 0e17bd4f26
3 changed files with 30 additions and 14 deletions

View File

@ -76,20 +76,32 @@ define(function(require) {
return;
}
// persist newly generated keypair
var newKeypair = {
publicKey: {
_id: generatedKeypair.keyId,
userId: self._account.emailAddress,
publicKey: generatedKeypair.publicKeyArmored
},
privateKey: {
_id: generatedKeypair.keyId,
userId: self._account.emailAddress,
encryptedKey: generatedKeypair.privateKeyArmored
// import the new key pair into crypto module
self._crypto.importKeys({
passphrase: passphrase,
privateKeyArmored: generatedKeypair.privateKeyArmored,
publicKeyArmored: generatedKeypair.publicKeyArmored
}, function(err) {
if (err) {
callback(err);
return;
}
};
self._keychain.putUserKeyPair(newKeypair, callback);
// persist newly generated keypair
var newKeypair = {
publicKey: {
_id: generatedKeypair.keyId,
userId: self._account.emailAddress,
publicKey: generatedKeypair.publicKeyArmored
},
privateKey: {
_id: generatedKeypair.keyId,
userId: self._account.emailAddress,
encryptedKey: generatedKeypair.privateKeyArmored
}
};
self._keychain.putUserKeyPair(newKeypair, callback);
});
});
}
};

View File

@ -1,7 +1,7 @@
{
"name": "Whiteout Mail",
"description": "Simple & elegant email client with integrated end-to-end encryption. Keeping your emails safe has never been so easy.",
"version": "0.0.5.1",
"version": "0.0.6.0",
"manifest_version": 2,
"offline_enabled": true,
"icons": {

View File

@ -73,12 +73,14 @@ define(function(require) {
devicestorageStub.init.yields();
keychainStub.getUserKeyPair.yields();
pgpStub.generateKeys.yields(null, {});
pgpStub.importKeys.yields();
keychainStub.putUserKeyPair.yields();
emailDao.init(account, emaildaoTest.passphrase, function(err) {
expect(devicestorageStub.init.calledOnce).to.be.true;
expect(keychainStub.getUserKeyPair.calledOnce).to.be.true;
expect(pgpStub.generateKeys.calledOnce).to.be.true;
expect(pgpStub.importKeys.calledOnce).to.be.true;
expect(keychainStub.putUserKeyPair.calledOnce).to.be.true;
expect(err).to.not.exist;
done();
@ -136,12 +138,14 @@ define(function(require) {
devicestorageStub.init.yields();
keychainStub.getUserKeyPair.yields();
pgpStub.generateKeys.yields(null, {});
pgpStub.importKeys.yields();
keychainStub.putUserKeyPair.yields();
emailDao.init(account, emaildaoTest.passphrase, function(err) {
expect(devicestorageStub.init.calledOnce).to.be.true;
expect(keychainStub.getUserKeyPair.calledOnce).to.be.true;
expect(pgpStub.generateKeys.calledOnce).to.be.true;
expect(pgpStub.importKeys.calledOnce).to.be.true;
expect(keychainStub.putUserKeyPair.calledOnce).to.be.true;
expect(err).to.not.exist;
done();