From 9b5aab0ca1b0425e36e71f88657f94b5242952ab Mon Sep 17 00:00:00 2001 From: tamarafinogina Date: Tue, 2 Jun 2026 13:01:07 +0200 Subject: [PATCH] remove attachements --- README.md | 2 -- package.json | 2 +- src/email-crypto/core.ts | 21 ++----------------- src/types.ts | 2 -- .../pwdProtectedEmailCoreErrors.test.ts | 2 -- 5 files changed, 3 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 3a43ab0..5ba3981 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,6 @@ const { key, salt } = await getKeyFromPassword(password); // Hybrid email encryption const email: Email = { text: 'email text', - attachments: ['email attachements'], }; const { secretKey: bobPrivateKeys, publicKey: bobPublicKeys } = await generateEmailKeys(); const bobWithPublicKeys = { @@ -125,7 +124,6 @@ expect(decryptedEmail).toStrictEqual(email); const emailAndSubject: EmailAndSubject = { text: 'email text', subject: 'email subject' - attachments: ['email attachements'], }; const encryptedEmailAndSubject = await encryptEmailAndSubjectHybrid(emailAndSubject, bobWithPublicKeys); const decryptedEmailAndSubject = await decryptEmailAndSubjectHybrid(encryptedEmailAndSubject, bobPrivateKeys); diff --git a/package.json b/package.json index ed8683a..3bd6699 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "internxt-crypto", - "version": "1.4.0", + "version": "1.5.0", "main": "dist/index.js", "types": "dist/index.d.ts", "module": "dist/index.js", diff --git a/src/email-crypto/core.ts b/src/email-crypto/core.ts index 9f4c138..9e33e02 100644 --- a/src/email-crypto/core.ts +++ b/src/email-crypto/core.ts @@ -59,16 +59,7 @@ export async function encryptEmailWithKey( const encryptedText = await encryptSymmetrically(encryptionKey, text, aux); const encText = uint8ArrayToBase64(encryptedText); - const enc: EmailEncrypted = { encText }; - if (email.attachments) { - const promises = email.attachments.map((attachment) => { - const binaryAttachment = UTF8ToUint8(attachment); - return encryptSymmetrically(encryptionKey, binaryAttachment, aux); - }); - const encryptedAttachments = await Promise.all(promises); - enc.encAttachments = encryptedAttachments?.map(uint8ArrayToBase64); - } - return enc; + return { encText }; } catch (error) { throw new EmailSymmetricEncryptionError(error instanceof Error ? error.message : String(error)); } @@ -91,16 +82,8 @@ export async function decryptEmail( const encText = base64ToUint8Array(encEmail.encText); const textArray = await decryptSymmetrically(encryptionKey, encText, aux); const text = uint8ToUTF8(textArray); - const email: Email = { text }; - if (encEmail.encAttachments) { - const encAttachments = encEmail.encAttachments?.map(base64ToUint8Array); - const promises = encAttachments?.map((encAtt) => decryptSymmetrically(encryptionKey, encAtt, aux)); - const decryptedAttachments = await Promise.all(promises); - email.attachments = decryptedAttachments?.map((att) => uint8ToUTF8(att)); - } - - return email; + return { text }; } catch (error) { throw new EmailSymmetricDecryptionError(error instanceof Error ? error.message : String(error)); } diff --git a/src/types.ts b/src/types.ts index 47e7843..82c49ba 100644 --- a/src/types.ts +++ b/src/types.ts @@ -48,7 +48,6 @@ export type PwdProtectedKey = { export type EmailEncrypted = { encText: string; - encAttachments?: string[]; }; export type EmailAndSubjectEncrypted = EmailEncrypted & { @@ -57,7 +56,6 @@ export type EmailAndSubjectEncrypted = EmailEncrypted & { export type Email = { text: string; - attachments?: string[]; }; export type EmailAndSubject = Email & { diff --git a/tests/email-crypto/pwdProtectedEmailCoreErrors.test.ts b/tests/email-crypto/pwdProtectedEmailCoreErrors.test.ts index b00e558..1a13c65 100644 --- a/tests/email-crypto/pwdProtectedEmailCoreErrors.test.ts +++ b/tests/email-crypto/pwdProtectedEmailCoreErrors.test.ts @@ -26,12 +26,10 @@ describe('Test email crypto functions', () => { const email: Email = { text: 'Hi Bob, This is a test message. -Alice.', - attachments: ['file1.txt', 'file2.txt'], }; const emailAndSubject: EmailAndSubject = { text: 'Hi Bob, This is a test message. -Alice.', - attachments: ['file1.txt', 'file2.txt'], subject: 'test subject', };