Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Separate personal aliases from shared aliases (#2159)

Leendert de Borste1e4e50abf89
diff --git a/apps/browser-extension/src/utils/db/queries/EncryptionKeyQueries.ts b/apps/browser-extension/src/utils/db/queries/EncryptionKeyQueries.ts
index b3f2ea81e..66378f816 100644
--- a/apps/browser-extension/src/utils/db/queries/EncryptionKeyQueries.ts
+++ b/apps/browser-extension/src/utils/db/queries/EncryptionKeyQueries.ts
@@ -14,21 +14,6 @@ export class EncryptionKeyQueries {
FROM EncryptionKeys x
WHERE x.IsDeleted = 0`;
- /**
- * Count one manifest's encryption keys carrying a given public key, to keep retained copies idempotent.
- */
- public static readonly COUNT_BY_PUBLIC_KEY = `
- SELECT COUNT(*) as count
- FROM EncryptionKeys x
- WHERE x.ManifestId = ? AND x.PublicKey = ?`;
-
- /**
- * Retain a copy of a key in a manifest, explicitly NOT primary.
- */
- public static readonly INSERT_NON_PRIMARY = `
- INSERT INTO EncryptionKeys (Id, ManifestId, PublicKey, PrivateKey, IsPrimary, CreatedAt, UpdatedAt, IsDeleted)
- VALUES (?, ?, ?, ?, 0, ?, ?, 0)`;
-
/**
* Get one manifest's active keypair: the key whose public half is published for SMTP delivery. Passed
* the root manifest's id, this is the user's personal keypair — `IsPrimary` alone would not identify it,
diff --git a/apps/browser-extension/src/utils/db/repositories/EncryptionKeyRepository.ts b/apps/browser-extension/src/utils/db/repositories/EncryptionKeyRepository.ts
index e3fa19822..0e4b1b813 100644
--- a/apps/browser-extension/src/utils/db/repositories/EncryptionKeyRepository.ts
+++ b/apps/browser-extension/src/utils/db/repositories/EncryptionKeyRepository.ts
@@ -51,28 +51,4 @@ export class EncryptionKeyRepository extends BaseRepository {
this.client.executeUpdate(EncryptionKeyQueries.DEMOTE_FOR_MANIFEST, [now, manifestId]);
this.client.executeUpdate(EncryptionKeyQueries.INSERT_FOR_MANIFEST, [this.generateId(), manifestId, publicKey, privateKey, now, now]);
}
-
- /**
- * Retain a copy of a keypair among the personal keys as a non-primary row.
- *
- * Used by the owner of a shared manifest to keep its delivery keys. The originals live only in the
- * shared manifest itself, so unsharing or deleting the anchor folder takes them out of the vault and would leave the
- * owner unable to decrypt mail their own alias received while it was shared.
- * @param publicKey - The public half, used as the identity of the key
- * @param privateKey - The private half
- */
- public retainNonPrimary(publicKey: string, privateKey: string): void {
- const personalManifestId = this.personalManifestId();
- if (!personalManifestId) {
- return;
- }
-
- const existing = this.client.executeQuery<{ count: number }>(EncryptionKeyQueries.COUNT_BY_PUBLIC_KEY, [personalManifestId, publicKey]);
- if ((existing[0]?.count ?? 0) > 0) {
- return;
- }
-
- const now = this.now();
- this.client.executeUpdate(EncryptionKeyQueries.INSERT_NON_PRIMARY, [this.generateId(), personalManifestId, publicKey, privateKey, now, now]);
- }
}