mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 14:07:04 +03:00
Resolve #342
This commit is contained in:
parent
a45cd5904f
commit
7da5692865
11 changed files with 115 additions and 56 deletions
|
|
@ -20,7 +20,7 @@ const
|
|||
? {password:Passphrases.get(key), remember:false}
|
||||
: await AskPopupView.password('GnuPG key<br>' + key + ' ' + privateKey.emails[0], 'OPENPGP/'+btnTxt);
|
||||
pass && pass.remember && Passphrases.set(key, pass.password);
|
||||
return pass.password;
|
||||
return pass?.password;
|
||||
},
|
||||
|
||||
findGnuPGKey = (keys, query/*, sign*/) =>
|
||||
|
|
@ -77,29 +77,31 @@ export const GnuPGUserStore = new class {
|
|||
);
|
||||
}
|
||||
};
|
||||
key.view = () => {
|
||||
const fetch = pass => Remote.request('GnupgExportKey',
|
||||
(iError, oData) => {
|
||||
if (oData?.Result) {
|
||||
key.armor = oData.Result;
|
||||
showScreenPopup(OpenPgpKeyPopupView, [key]);
|
||||
} else {
|
||||
Passphrases.delete(key.id);
|
||||
}
|
||||
}, {
|
||||
keyId: key.id,
|
||||
isPrivate: isPrivate,
|
||||
passphrase: pass
|
||||
}
|
||||
);
|
||||
if (isPrivate) {
|
||||
askPassphrase(key, 'POPUP_VIEW_TITLE').then(passphrase => {
|
||||
(null !== passphrase) && fetch(passphrase);
|
||||
});
|
||||
key.fetch = async callback => {
|
||||
if (key.armor) {
|
||||
callback && callback();
|
||||
} else {
|
||||
fetch('');
|
||||
let pass = '';
|
||||
if (isPrivate) {
|
||||
pass = await askPassphrase(key, 'POPUP_VIEW_TITLE');
|
||||
}
|
||||
if (null != pass) {
|
||||
const result = await Remote.post('GnupgExportKey', null, {
|
||||
keyId: key.id,
|
||||
isPrivate: isPrivate,
|
||||
passphrase: pass
|
||||
});
|
||||
if (result?.Result) {
|
||||
key.armor = result.Result;
|
||||
callback && callback();
|
||||
} else {
|
||||
Passphrases.delete(key.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return key.armor;
|
||||
};
|
||||
key.view = () => key.fetch(() => showScreenPopup(OpenPgpKeyPopupView, [key]));
|
||||
return key;
|
||||
};
|
||||
this.publicKeys(oData.Result.public.map(key => initKey(key, 0)));
|
||||
|
|
|
|||
|
|
@ -106,8 +106,7 @@ export const
|
|||
* Returns the first library that can.
|
||||
*/
|
||||
async hasPublicKeyForEmails(recipients) {
|
||||
const count = recipients.length;
|
||||
if (count) {
|
||||
if (recipients.length) {
|
||||
if (GnuPGUserStore.hasPublicKeyForEmails(recipients)) {
|
||||
return 'gnupg';
|
||||
}
|
||||
|
|
@ -228,12 +227,37 @@ export const
|
|||
}
|
||||
}
|
||||
|
||||
getPublicKeyOfEmails(recipients) {
|
||||
if (recipients.length) {
|
||||
let result = {};
|
||||
recipients.forEach(email => {
|
||||
OpenPGPUserStore.publicKeys().forEach(key => {
|
||||
if (key.emails.includes(email)) {
|
||||
result[email] = key.armor;
|
||||
}
|
||||
});
|
||||
GnuPGUserStore.publicKeys.map(async key => {
|
||||
if (!result[email] && key.emails.includes(email)) {
|
||||
result[email] = await key.fetch();
|
||||
}
|
||||
});
|
||||
});
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns headers that should be added to an outgoing email.
|
||||
* So far this is only the autocrypt header.
|
||||
*/
|
||||
/*
|
||||
mailvelopeKeyring.additionalHeadersForOutgoingEmail(headers)
|
||||
mailvelopeKeyring.additionalHeadersForOutgoingEmail(from: 'abc@web.de')
|
||||
.then(function(additional) {
|
||||
console.log('additionalHeadersForOutgoingEmail', additional);
|
||||
// logs: {autocrypt: "addr=abc@web.de; prefer-encrypt=mutual; keydata=..."}
|
||||
});
|
||||
|
||||
mailvelopeKeyring.addSyncHandler(syncHandlerObj)
|
||||
mailvelopeKeyring.createKeyBackupContainer(selector, options)
|
||||
mailvelopeKeyring.createKeyGenContainer(selector, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue