mirror of
https://github.com/moparisthebest/mail
synced 2025-02-07 10:30:18 -05:00
[WO-53] change key export to include public key
This commit is contained in:
parent
36c8d1e003
commit
e00b1ab44e
@ -20,14 +20,14 @@ define(function(require) {
|
||||
};
|
||||
|
||||
$scope.exportKeyFile = function() {
|
||||
var userId = emailDao._account.emailAddress;
|
||||
emailDao._keychain.getUserKeyPair(userId, function(err, keypair) {
|
||||
emailDao._crypto.exportKeys(function(err, keys) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
|
||||
download(keypair.privateKey.encryptedKey, 'key_' + userId + '.asc', 'text/plain');
|
||||
var id = keys.keyId.substring(8,keys.keyId.length);
|
||||
download(keys.publicKeyArmored + keys.privateKeyArmored, id + '.asc', 'text/plain');
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -26,7 +26,7 @@ define(function(require) {
|
||||
keypair.privateKey = {
|
||||
_id: keypair.publicKey._id,
|
||||
userId: userId,
|
||||
encryptedKey: $scope.key
|
||||
encryptedKey: $scope.key.privateKeyArmored
|
||||
};
|
||||
emailDao.unlock(keypair, passphrase, function(err) {
|
||||
if (err) {
|
||||
@ -75,7 +75,18 @@ define(function(require) {
|
||||
|
||||
reader.onload = (function(scope) {
|
||||
return function(e) {
|
||||
scope.key = e.target.result;
|
||||
var rawKeys = e.target.result,
|
||||
index = rawKeys.indexOf('-----BEGIN PGP PRIVATE KEY BLOCK-----');
|
||||
|
||||
if (index === -1) {
|
||||
console.error('Erroneous key file format!');
|
||||
return;
|
||||
}
|
||||
|
||||
scope.key = {
|
||||
publicKeyArmored: rawKeys.substring(0,index),
|
||||
privateKeyArmored: rawKeys.substring(index,rawKeys.length)
|
||||
};
|
||||
};
|
||||
})(scope);
|
||||
reader.readAsText(files[0]);
|
||||
|
Loading…
Reference in New Issue
Block a user