Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/email-search/indexedDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const encryptAndStoreEmail = async (
esDB: MailDB,
): Promise<void> => {
try {
const aux = getAux(newEmailToStore.params);
const aux = getAux(newEmailToStore.params, false);
const enc = await encryptEmailContentSymmetricallyWithKey(newEmailToStore.body, indexKey, aux, newEmailToStore.id);
const encryptedEmail: StoredEmail = { enc, params: newEmailToStore.params, id: newEmailToStore.id };
await esDB.put(DB_LABEL, encryptedEmail);
Expand All @@ -114,7 +114,7 @@ export const encryptAndStoreManyEmail = async (
try {
const encryptedEmails = await Promise.all(
newEmailsToStore.map(async (email: Email) => {
const aux = getAux(email.params);
const aux = getAux(email.params, false);
const enc = await encryptEmailContentSymmetricallyWithKey(email.body, indexKey, aux, email.id);

return { enc, params: email.params, id: email.id };
Expand All @@ -137,7 +137,7 @@ export const encryptAndStoreManyEmail = async (
*/
const decryptEmail = async (indexKey: CryptoKey, encryptedEmail: StoredEmail): Promise<Email> => {
try {
const aux = getAux(encryptedEmail.params);
const aux = getAux(encryptedEmail.params, false);
const email = await decryptEmailSymmetrically(indexKey, aux, encryptedEmail.enc);
return { body: email, params: encryptedEmail.params, id: encryptedEmail.id };
} catch (error) {
Expand Down Expand Up @@ -178,7 +178,7 @@ export const getAndDecryptAllEmails = async (indexKey: CryptoKey, esDB: MailDB):

const decryptedEmails = await Promise.all(
encryptedEmails.map(async (encEmail) => {
const aux = getAux(encEmail.params);
const aux = getAux(encEmail.params, false);
const body = await decryptEmailSymmetrically(indexKey, aux, encEmail.enc);
return { body, params: encEmail.params, id: encEmail.id };
}),
Expand Down
5 changes: 3 additions & 2 deletions src/keystore-crypto/emailEncryptionKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { generateEmailKeys } from '../email-crypto';
* The main keystore encryption key is derived from the base key (stored in session storage)
* The recovery keystore encryption key is derived from the recovery codes
*
* @returns The encryption and recovery keystores
* @returns The encryption and recovery keystores, recovery codes and email keys
*/
export async function createEncryptionAndRecoveryKeystores(
userEmail: string,
Expand All @@ -17,6 +17,7 @@ export async function createEncryptionAndRecoveryKeystores(
encryptionKeystore: EncryptedKeystore;
recoveryKeystore: EncryptedKeystore;
recoveryCodes: string;
keys: EmailKeys;
}> {
try {
const keys = await generateEmailKeys();
Expand All @@ -28,7 +29,7 @@ export async function createEncryptionAndRecoveryKeystores(
const recoveryKey = await deriveRecoveryKey(recoveryCodes);
const recoveryKeystore = await encryptKeystoreContent(recoveryKey, keys, userEmail, KeystoreType.RECOVERY);

return { encryptionKeystore, recoveryKeystore, recoveryCodes };
return { encryptionKeystore, recoveryKeystore, recoveryCodes, keys };
} catch (error) {
throw new Error('Failed to create encryption and recovery keystores', { cause: error });
}
Expand Down