mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Bugfix: decrypt failed when OpenPGP.js not loaded
This commit is contained in:
parent
44c42ade52
commit
8c356d8154
2 changed files with 28 additions and 24 deletions
|
|
@ -108,6 +108,7 @@ export const OpenPGPUserStore = new class {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadKeyrings() {
|
loadKeyrings() {
|
||||||
|
if (window.openpgp) {
|
||||||
loadOpenPgpKeys(publicKeysItem).then(keys => {
|
loadOpenPgpKeys(publicKeysItem).then(keys => {
|
||||||
this.publicKeys(keys || []);
|
this.publicKeys(keys || []);
|
||||||
console.log('openpgp.js public keys loaded');
|
console.log('openpgp.js public keys loaded');
|
||||||
|
|
@ -117,6 +118,7 @@ export const OpenPGPUserStore = new class {
|
||||||
console.log('openpgp.js private keys loaded');
|
console.log('openpgp.js private keys loaded');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
|
|
@ -126,7 +128,7 @@ export const OpenPGPUserStore = new class {
|
||||||
}
|
}
|
||||||
|
|
||||||
importKey(armoredKey) {
|
importKey(armoredKey) {
|
||||||
openpgp.readKey({armoredKey:armoredKey}).then(key => {
|
window.openpgp && openpgp.readKey({armoredKey:armoredKey}).then(key => {
|
||||||
if (!key.err) {
|
if (!key.err) {
|
||||||
if (key.isPrivate()) {
|
if (key.isPrivate()) {
|
||||||
this.privateKeys.push(new OpenPgpKeyModel(armoredKey, key));
|
this.privateKeys.push(new OpenPgpKeyModel(armoredKey, key));
|
||||||
|
|
@ -145,6 +147,7 @@ export const OpenPGPUserStore = new class {
|
||||||
keyPair.revocationCertificate
|
keyPair.revocationCertificate
|
||||||
*/
|
*/
|
||||||
storeKeyPair(keyPair) {
|
storeKeyPair(keyPair) {
|
||||||
|
if (window.openpgp) {
|
||||||
openpgp.readKey({armoredKey:keyPair.publicKey}).then(key => {
|
openpgp.readKey({armoredKey:keyPair.publicKey}).then(key => {
|
||||||
this.publicKeys.push(new OpenPgpKeyModel(keyPair.publicKey, key));
|
this.publicKeys.push(new OpenPgpKeyModel(keyPair.publicKey, key));
|
||||||
storeOpenPgpKeys(this.publicKeys, publicKeysItem);
|
storeOpenPgpKeys(this.publicKeys, publicKeysItem);
|
||||||
|
|
@ -154,6 +157,7 @@ export const OpenPGPUserStore = new class {
|
||||||
storeOpenPgpKeys(this.privateKeys, privateKeysItem);
|
storeOpenPgpKeys(this.privateKeys, privateKeysItem);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if verifying/encrypting a message is possible with given email addresses.
|
* Checks if verifying/encrypting a message is possible with given email addresses.
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,7 @@ export const
|
||||||
addEventListener('mailvelope', () => this.loadKeyrings(identifier));
|
addEventListener('mailvelope', () => this.loadKeyrings(identifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OpenPGPUserStore.isSupported()) {
|
|
||||||
OpenPGPUserStore.loadKeyrings();
|
OpenPGPUserStore.loadKeyrings();
|
||||||
}
|
|
||||||
|
|
||||||
if (SettingsCapa('GnuPG')) {
|
if (SettingsCapa('GnuPG')) {
|
||||||
GnuPGUserStore.loadKeyrings();
|
GnuPGUserStore.loadKeyrings();
|
||||||
|
|
@ -139,10 +137,12 @@ export const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try OpenPGP.js
|
// Try OpenPGP.js
|
||||||
|
if (OpenPGPUserStore.isSupported()) {
|
||||||
let result = await OpenPGPUserStore.decrypt(armoredText, sender);
|
let result = await OpenPGPUserStore.decrypt(armoredText, sender);
|
||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Try Mailvelope (does not support inline images)
|
// Try Mailvelope (does not support inline images)
|
||||||
try {
|
try {
|
||||||
|
|
@ -161,7 +161,7 @@ export const
|
||||||
*/
|
*/
|
||||||
const body = message.body;
|
const body = message.body;
|
||||||
body.textContent = '';
|
body.textContent = '';
|
||||||
result = await mailvelope.createDisplayContainer(
|
let result = await mailvelope.createDisplayContainer(
|
||||||
'#'+body.id,
|
'#'+body.id,
|
||||||
armoredText,
|
armoredText,
|
||||||
this.mailvelopeKeyring,
|
this.mailvelopeKeyring,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue