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

Method decrypt

src/controller/decrypt.controller.js:136–189  ·  view source on GitHub ↗
(armored, keyringId)

Source from the content-addressed store, hash-verified

134 }
135
136 async decrypt(armored, keyringId) {
137 this.ports.dDialog.emit('waiting', {waiting: true});
138 try {
139 const {data, signatures} = await model.decryptMessage({
140 message: this.message,
141 armored,
142 keyringId,
143 unlockKey: this.unlockKey.bind(this),
144 senderAddress: this.sender,
145 uiLogSource: 'security_log_viewer',
146 lookupKey: keyringId ? rotation => lookupKey({keyringId, email: this.sender, rotation}) : undefined
147 });
148 this.signatures = signatures;
149 if (this.ports.dDialog && signatures) {
150 this.ports.dDialog.emit('signature-verification', {signers: signatures});
151 }
152 const {message, attachments} = await parseMessage(data, 'html');
153 this.ports.dDialog.emit('decrypted-message', {message});
154 for (const attachment of attachments) {
155 this.ports.dDialog.emit('add-decrypted-attachment', {attachment});
156 }
157 if (this.ports.decryptCont) {
158 this.ports.decryptCont.emit('decrypt-done');
159 }
160 this.ports.dDialog.emit('waiting', {waiting: false, unlock: true});
161 } catch (error) {
162 if (error.code === 'PWD_DIALOG_CANCEL') {
163 if (this.hasPort('Frame')) {
164 return this.dialogCancel();
165 }
166 }
167 if (this.ports.dDialog) {
168 this.ports.dDialog.emit('error-message', {error: error.message});
169 }
170 if (this.ports.decryptCont) {
171 let err = error;
172 switch (error.code) {
173 case 'ARMOR_PARSE_ERROR':
174 case 'PWD_DIALOG_CANCEL':
175 case 'NO_KEY_FOUND':
176 err = mapError(err);
177 break;
178 default:
179 err = {
180 // don't expose internal errors to API
181 code: 'DECRYPT_ERROR',
182 message: 'Generic decrypt error'
183 };
184 }
185 this.ports.decryptCont.emit('error-message', {error: err});
186 }
187 this.ports.dDialog.emit('waiting', {waiting: false});
188 }
189 }
190
191 async unlockKey({key, message}) {
192 const pwdControl = await createController('pwdDialog');

Callers 12

onDecryptMethod · 0.95
onSetArmoredMethod · 0.95
crypto-test.jsFile · 0.80
symEncryptFunction · 0.80
decryptMessageFunction · 0.80
restorePrivateKeyBackupFunction · 0.80
decryptFileFunction · 0.80
decryptFunction · 0.80
processDataMethod · 0.80
onClippedArmoredMethod · 0.80
onMultipartEncryptedMethod · 0.80

Calls 7

dialogCancelMethod · 0.95
lookupKeyFunction · 0.90
parseMessageFunction · 0.90
mapErrorFunction · 0.90
decryptMessageMethod · 0.80
emitMethod · 0.45
hasPortMethod · 0.45

Tested by

no test coverage detected