Skip to content

[_] Remove public parameters from email encryption#42

Merged
TamaraFinogina merged 4 commits intomasterfrom
simplify_enc_emails
Mar 20, 2026
Merged

[_] Remove public parameters from email encryption#42
TamaraFinogina merged 4 commits intomasterfrom
simplify_enc_emails

Conversation

@TamaraFinogina
Copy link
Contributor

@TamaraFinogina TamaraFinogina commented Mar 19, 2026

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

  • Changes have been tested locally.
  • Unit tests have been written or updated as necessary.
  • The code adheres to the repository's coding standards.
  • Relevant documentation has been added or updated.
  • No new warnings or errors have been introduced.
  • SonarCloud issues have been reviewed and addressed.
  • QA Passed

Testing Process

unit tests

@TamaraFinogina TamaraFinogina self-assigned this Mar 19, 2026

if (body.attachments) {
const encryptedAttachments = await Promise.all(
body.attachments.map((attachment) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about extracting this map to a constant like encryptSymetricallyPromises and then: Promise.all[encryptSymetricallyPromises?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if (encEmailBody.encAttachments) {
const encAttachments = encEmailBody.encAttachments?.map(base64ToUint8Array);
const decryptedAttachments = await Promise.all(
encAttachments.map((attachment) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

import { genSymmetricKey } from '../../src/symmetric-crypto';

describe('Test email crypto functions', () => {
const emailBody: EmailBody = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

@TamaraFinogina TamaraFinogina Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@TamaraFinogina TamaraFinogina changed the base branch from simplify_symmetric to master March 20, 2026 09:08
@sonarqubecloud
Copy link

@TamaraFinogina TamaraFinogina merged commit 9a625ad into master Mar 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants