mirror of
https://github.com/moparisthebest/mail
synced 2025-02-12 05:00:19 -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() {
|
$scope.exportKeyFile = function() {
|
||||||
var userId = emailDao._account.emailAddress;
|
emailDao._crypto.exportKeys(function(err, keys) {
|
||||||
emailDao._keychain.getUserKeyPair(userId, function(err, keypair) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return;
|
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 = {
|
keypair.privateKey = {
|
||||||
_id: keypair.publicKey._id,
|
_id: keypair.publicKey._id,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
encryptedKey: $scope.key
|
encryptedKey: $scope.key.privateKeyArmored
|
||||||
};
|
};
|
||||||
emailDao.unlock(keypair, passphrase, function(err) {
|
emailDao.unlock(keypair, passphrase, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -75,7 +75,18 @@ define(function(require) {
|
|||||||
|
|
||||||
reader.onload = (function(scope) {
|
reader.onload = (function(scope) {
|
||||||
return function(e) {
|
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);
|
})(scope);
|
||||||
reader.readAsText(files[0]);
|
reader.readAsText(files[0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user