Skip to content

[PB-6629] Add preview decryption + mobile fixes#67

Open
TamaraFinogina wants to merge 8 commits into
masterfrom
add_preview_decryption
Open

[PB-6629] Add preview decryption + mobile fixes#67
TamaraFinogina wants to merge 8 commits into
masterfrom
add_preview_decryption

Conversation

@TamaraFinogina

@TamaraFinogina TamaraFinogina commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Description

Add a function for preview decryption only.

Remove WebCrypto from dec/enc symmetrically for mobile

Change base64 convertion for mobile

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

Additional Notes

Summaries of emails have no encrypted body or sessionKey, so the email decryption function can be called only with a trick of using the same preview 3 times to construct email-like looking structure. It can be avoided with this PR

@TamaraFinogina TamaraFinogina self-assigned this Jul 22, 2026
Comment thread src/email-crypto/hybridEncyptedEmail.ts Outdated
Comment on lines +80 to +82
if (error instanceof EmailHybridDecryptionError) throw error;
if (error instanceof EmailPreviewSymmetricDecryptionError) throw error;
throw new FailedToDecryptEmail(error instanceof Error ? error.message : String(error));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If decryptKeysHybridand decryptPreview throws an error, there's no need to wrap this in a try/catch. The error will be propagated automatically.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, true, I'll remove it then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@xabg2 Done

}
}

export class EmailPreviewSymmetricDecryptionError extends Error {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Also, add the name of the error here:
this.name = 'EmailPreviewSymmetrictDecryptionError' so we can use it in the client if we need to filter errors. Better using the name rather than status codes, messages or whatever.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@TamaraFinogina
TamaraFinogina requested a review from xabg2 July 22, 2026 13:27
@TamaraFinogina TamaraFinogina changed the title [PB-6629] Add preview decryption [PB-6629] Add preview decryption + mobile fixes Jul 23, 2026
@sonarqubecloud

Copy link
Copy Markdown

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