mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 14:07:04 +03:00
#89 OpenPGP.js sign cleartext
This commit is contained in:
parent
66340614b5
commit
f625abe0b2
3 changed files with 52 additions and 26 deletions
|
|
@ -236,4 +236,21 @@ export const OpenPGPUserStore = new class {
|
|||
}
|
||||
}
|
||||
|
||||
async signCleartext(text, privateKey) {
|
||||
const passphrase = prompt('OpenPGP.js Passphrase for ' + privateKey.id + ' ' + privateKey.emails[0]);
|
||||
if (null !== passphrase) {
|
||||
privateKey = await openpgp.decryptKey({
|
||||
privateKey: privateKey.key,
|
||||
passphrase
|
||||
});
|
||||
const unsignedMessage = await openpgp.createCleartextMessage({ text: text });
|
||||
return await openpgp.sign({
|
||||
message: unsignedMessage, // CleartextMessage or Message object
|
||||
signingKeys: privateKey
|
||||
// detached: false
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -106,17 +106,18 @@ export const PgpUserStore = new class {
|
|||
* Returns the first library that can.
|
||||
*/
|
||||
async getKeyForSigning(email) {
|
||||
/*
|
||||
let key = GnuPGUserStore.getPrivateKeyFor(email, 1);
|
||||
if (key) {
|
||||
return ['gnupg', key];
|
||||
}
|
||||
|
||||
key = OpenPGPUserStore.getPrivateKeyFor(email, 1);
|
||||
*/
|
||||
let key = OpenPGPUserStore.getPrivateKeyFor(email, 1);
|
||||
if (key) {
|
||||
return ['openpgp', key];
|
||||
}
|
||||
|
||||
return await this.getMailvelopePrivateKeyFor(email, 1);
|
||||
// return await this.getMailvelopePrivateKeyFor(email, 1);
|
||||
}
|
||||
|
||||
async decrypt(message) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue