MCPcopy Index your code
hub / github.com/mailvelope/mailvelope / encryptMessage

Function encryptMessage

src/modules/pgpModel.js:184–201  ·  view source on GitHub ↗
({data, keyringId, unlockKey, encryptionKeyFprs, signingKeyFpr, uiLogSource, filename, noCache, allKeyrings})

Source from the content-addressed store, hash-verified

182 * @return {Promise<String>} - armored PGP message
183 */
184export async function encryptMessage({data, keyringId, unlockKey, encryptionKeyFprs, signingKeyFpr, uiLogSource, filename, noCache, allKeyrings}) {
185 const keyring = await getKeyringWithPrivKey(signingKeyFpr, keyringId, noCache);
186 if (!keyring) {
187 throw new MvError('No private key found', 'NO_PRIVATE_KEY_FOUND');
188 }
189 await syncPublicKeys({keyring, keyIds: encryptionKeyFprs, keyringId, allKeyrings});
190 try {
191 const result = await keyring.getPgpBackend().encrypt({data, keyring, unlockKey, encryptionKeyFprs, signingKeyFpr, armor: true, filename});
192 await logEncryption(uiLogSource, keyring, encryptionKeyFprs);
193 return result;
194 } catch (e) {
195 console.log('getPgpBackend().encrypt() error', e);
196 if (e.code === 'PWD_DIALOG_CANCEL') {
197 throw e;
198 }
199 throw new MvError(l10n.get('encrypt_error', [e.message]), 'ENCRYPT_ERROR');
200 }
201}
202
203/**
204 * Log encryption operation

Callers 3

pgpModel-test.jsFile · 0.90
signAndEncryptMethod · 0.90
encryptMessageMethod · 0.90

Calls 6

getKeyringWithPrivKeyFunction · 0.90
syncPublicKeysFunction · 0.90
logEncryptionFunction · 0.85
encryptMethod · 0.45
getPgpBackendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected