Automaticaly add PGP key from Autocrypt #89

This commit is contained in:
the-djmaze 2024-02-11 19:23:09 +01:00
parent e28085fbba
commit 17cb093b32
3 changed files with 55 additions and 22 deletions

View file

@ -9,6 +9,8 @@ import { SettingsCapa, SettingsGet } from 'Common/Globals';
import { GnuPGUserStore } from 'Stores/User/GnuPG';
import { OpenPGPUserStore } from 'Stores/User/OpenPGP';
import Remote from 'Remote/User/Fetch';
// https://mailvelope.github.io/mailvelope/Keyring.html
let mailvelopeKeyring = null;
@ -75,6 +77,22 @@ export const
return 0 === text.trim().indexOf(BEGIN_PGP_MESSAGE);
}
importKey(key, gnuPG, backup) {
if (gnuPG || backup) {
Remote.request('PgpImportKey',
(iError, oData) => {
if (gnuPG && oData?.Result/* && (oData.Result.imported || oData.Result.secretimported)*/) {
GnuPGUserStore.loadKeyrings();
}
iError && alert(oData.ErrorMessage);
}, {
key, gnuPG, backup
}
);
}
OpenPGPUserStore.isSupported() && OpenPGPUserStore.importKey(key);
}
async mailvelopeHasPublicKeyForEmails(recipients) {
const
mailvelope = mailvelopeKeyring && await mailvelopeKeyring.validKeyForAddress(recipients)