[_] Remove public parameters from email encryption#42
Conversation
src/email-crypto/core.ts
Outdated
|
|
||
| if (body.attachments) { | ||
| const encryptedAttachments = await Promise.all( | ||
| body.attachments.map((attachment) => { |
There was a problem hiding this comment.
What about extracting this map to a constant like encryptSymetricallyPromises and then: Promise.all[encryptSymetricallyPromises?
src/email-crypto/core.ts
Outdated
| if (encEmailBody.encAttachments) { | ||
| const encAttachments = encEmailBody.encAttachments?.map(base64ToUint8Array); | ||
| const decryptedAttachments = await Promise.all( | ||
| encAttachments.map((attachment) => { |
| import { genSymmetricKey } from '../../src/symmetric-crypto'; | ||
|
|
||
| describe('Test email crypto functions', () => { | ||
| const emailBody: EmailBody = { |
There was a problem hiding this comment.
nit: consider extracting all this mocks in, for example, a fixtures.ts so you can reuse them in all tests (avoiding duplicated mocks). You can do something like this, so you can override any param by passing it as a Prop.
There was a problem hiding this comment.
Only mock in this file is this one, nothing else:
const emailBody: EmailBody = {
text: 'test body',
subject: 'test subject',
};
const aux = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
For the search tests, there is a helper that generates mock emails, but here it just needs texts and a subject, even aux is optional
|



Description
This PR removes all public parameters from email encryption and only focuses on the email body (text, subject, attachments). This is done to make encryption independent of the email structure.
Related Pull Requests
Builds on top of another PR, which simplified symmetric encryption: #41
Checklist
Testing Process
unit tests