#89 added import keys to OpenPGP

This commit is contained in:
the-djmaze 2022-01-28 17:56:44 +01:00
parent fe078174ab
commit 9f125c18c3
3 changed files with 21 additions and 12 deletions

View file

@ -223,6 +223,20 @@ export const PgpUserStore = new class {
return !!(window.openpgp || window.mailvelope || Settings.capa(Capa.GnuPG));
}
openpgpImportKey(armoredKey) {
openpgp && openpgp.readKey({armoredKey:armoredKey}).then(key => {
if (!key.err) {
if (key.isPrivate()) {
this.openpgpPrivateKeys.push(new OpenPgpKeyModel(armoredKey, key));
storeOpenPgpKeys(this.openpgpPrivateKeys, privateKeysItem);
} else {
this.openpgpPublicKeys.push(new OpenPgpKeyModel(armoredKey, key));
storeOpenPgpKeys(PgpUserStore.openpgpPublicKeys, publicKeysItem);
}
}
});
}
gnupgImportKey(key, callback) {
if (Settings.capa(Capa.GnuPG)) {
Remote.request('GnupgImportKey',

View file

@ -16,4 +16,8 @@
.delete-key:not(:hover) {
opacity: 0.7;
}
iframe {
max-width: 991px;
}
}

View file

@ -37,7 +37,7 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
this.keyErrorMessage('');
if (!keyTrimmed) {
return false;
return;
}
let match = null,
@ -54,15 +54,7 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
if (this.saveGnuPG()) {
PgpUserStore.gnupgImportKey(this.key());
}
/*
if (this.canOpenPGP && this.saveOpenPGP()) {
if ('PRIVATE' === match[1]) {
err = PgpUserStore.openpgpKeyring.privateKeys.importKey(match[0]);
} else if ('PUBLIC' === match[1]) {
err = PgpUserStore.openpgpKeyring.publicKeys.importKey(match[0]);
}
}
*/
PgpUserStore.openpgpImportKey(this.key());
if (err) {
this.keyError(true);
this.keyErrorMessage(err && err[0] ? '' + err[0] : '');
@ -78,11 +70,10 @@ export class OpenPgpImportPopupView extends AbstractViewPopup {
} while (!done);
if (this.keyError()) {
return false;
return;
}
this.cancelCommand();
return true;
}
onShow() {