Skip to content

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

Update core/client and cleanup unused methods that have been migrated to Rust (#2159)

Leendert de Borst28c2ffdc24a2
diff --git a/core/client/src/database/SqliteClient.ts b/core/client/src/database/SqliteClient.ts
index 947c5235e..3f18e5864 100644
--- a/core/client/src/database/SqliteClient.ts
+++ b/core/client/src/database/SqliteClient.ts
@@ -122,7 +122,7 @@ export class SqliteClient implements ISyncDatabaseClient {
*/
public get folders(): SyncRepository<FolderRepository> {
if (!this._folders) {
- this._folders = syncRepository(new FolderRepository(this, this.logoRepository), this);
+ this._folders = syncRepository(new FolderRepository(this), this);
}
return this._folders;
}
@@ -158,7 +158,7 @@ export class SqliteClient implements ISyncDatabaseClient {
}
/**
- * The logo repository itself, which the item and folder repositories call into.
+ * The logo repository itself, which the item repository calls into.
*/
private get logoRepository(): LogoRepository {
if (!this._logoRepository) {
diff --git a/core/client/src/database/queries/BaseQueries.ts b/core/client/src/database/queries/BaseQueries.ts
index 214b8fa3b..95835459d 100644
--- a/core/client/src/database/queries/BaseQueries.ts
+++ b/core/client/src/database/queries/BaseQueries.ts
@@ -22,33 +22,4 @@ export class BaseQueries {
* own manifest.
*/
public static readonly MANIFEST_OF_ITEM = 'COALESCE((SELECT ManifestId FROM Items WHERE Id = ?), ?)';
-
- /**
- * Re-stamp a folder's whole subtree with `?` (a manifest id).
- * Used when a folder is shared (its subtree joins that manifest's namespace) and when the share is
- * removed (the subtree returns to the personal manifest).
- */
- public static readonly RESTAMP_SUBTREE_FOLDERS = `
- UPDATE Folders SET ManifestId = ?
- WHERE Id IN (
- WITH RECURSIVE subtree(Id) AS (
- SELECT Id FROM Folders WHERE Id = ?
- UNION ALL
- SELECT f.Id FROM Folders f INNER JOIN subtree s ON f.ParentFolderId = s.Id
- )
- SELECT Id FROM subtree
- )`;
-
- /** Companion of {@link RESTAMP_SUBTREE_FOLDERS} for the items inside that subtree. */
- public static readonly RESTAMP_SUBTREE_ITEMS = `
- UPDATE Items SET ManifestId = ?
- WHERE FolderId IN (
- WITH RECURSIVE subtree(Id) AS (
- SELECT Id FROM Folders WHERE Id = ?
- UNION ALL
- SELECT f.Id FROM Folders f INNER JOIN subtree s ON f.ParentFolderId = s.Id
- )
- SELECT Id FROM subtree
- )`;
-
}
diff --git a/core/client/src/database/queries/EncryptionKeyQueries.ts b/core/client/src/database/queries/EncryptionKeyQueries.ts
index 53cf605f3..ac58ca832 100644
--- a/core/client/src/database/queries/EncryptionKeyQueries.ts
+++ b/core/client/src/database/queries/EncryptionKeyQueries.ts
@@ -25,21 +25,4 @@ export class EncryptionKeyQueries {
FROM EncryptionKeys x
WHERE x.ManifestId = ? AND x.PublicKey = ? AND x.IsDeleted = 0
LIMIT 1`;
-
- /**
- * Demote a manifest's current keypair. Rotation demotes rather than deletes, so mail received before the
- * rotation stays decryptable by the members who still hold the folder.
- */
- public static readonly DEMOTE_FOR_MANIFEST = `
- UPDATE EncryptionKeys
- SET IsPrimary = 0, UpdatedAt = ?
- WHERE ManifestId = ? AND IsPrimary = 1`;
-
- /**
- * Insert a manifest's new active keypair, stamped with the manifest's id so the codec routes it into that
- * manifest (private half encrypted under the manifest's VEK, readable by exactly its members).
- */
- public static readonly INSERT_FOR_MANIFEST = `
- INSERT INTO EncryptionKeys (Id, ManifestId, PublicKey, PrivateKey, IsPrimary, CreatedAt, UpdatedAt, IsDeleted)
- VALUES (?, ?, ?, ?, 1, ?, ?, 0)`;
}
diff --git a/core/client/src/database/repositories/EncryptionKeyRepository.ts b/core/client/src/database/repositories/EncryptionKeyRepository.ts
index b2886bd02..545cb8e28 100644
--- a/core/client/src/database/repositories/EncryptionKeyRepository.ts
+++ b/core/client/src/database/repositories/EncryptionKeyRepository.ts
@@ -33,17 +33,4 @@ export class EncryptionKeyRepository extends BaseRepository {
const results = yield* this.query<EncryptionKey>(EncryptionKeyQueries.GET_ACCOUNT_KEY_BY_PUBLIC_KEY, [personalManifestId, publicKey]);
return results.length > 0 ? results[0] : null;
}
-
- /**
- * Make the given keypair the manifest's active one, demoting (never deleting) whatever it supersedes so
- * mail received before the rotation stays decryptable.
- * @param manifestId - The manifest id to stamp the keypair with
- * @param publicKey - The public half, published to the server for delivery
- * @param privateKey - The private half, which never leaves the manifest
- */
- public *setActiveForManifest(manifestId: string, publicKey: string, privateKey: string): DbOp<void> {
- const now = this.now();
- yield* this.execute(EncryptionKeyQueries.DEMOTE_FOR_MANIFEST, [now, manifestId]);
- yield* this.execute(EncryptionKeyQueries.INSERT_FOR_MANIFEST, [this.generateId(), manifestId, publicKey, privateKey, now, now]);
- }
}
diff --git a/core/client/src/database/repositories/FolderRepository.ts b/core/client/src/database/repositories/FolderRepository.ts
index f5548a8c3..ecfa46da2 100644
--- a/core/client/src/database/repositories/FolderRepository.ts
+++ b/core/client/src/database/repositories/FolderRepository.ts
@@ -2,12 +2,9 @@ import { getPlatform } from '../../platform/ClientPlatform';
import { TranslatableMessage } from '../../platform/TranslatableMessage';
import { multiManifestRendering } from '../../sharing/MultiManifestRendering';
import { BaseRepository } from '../BaseRepository';
-import { BaseQueries } from '../queries/BaseQueries';
import { FolderQueries } from '../queries/FolderQueries';
-import type { IDatabaseClient } from '../BaseRepository';
import type { DbOp } from '../DbOp';
-import type { LogoRepository } from './LogoRepository';
/**
* Folder entity type.
@@ -24,15 +21,6 @@ export type Folder = {
* Repository for Folder CRUD operations.
*/
export class FolderRepository extends BaseRepository {
- /**
- * Constructor for the FolderRepository class.
- * @param client - The database client to use for the repository
- * @param logoRepository - The logo repository, to follow items across manifest boundaries
- */
- public constructor(client: IDatabaseClient, private logoRepository: LogoRepository) {
- super(client);
- }
-
/**
* Create a new folder.
* @param name - The name of the folder
@@ -214,20 +202,4 @@ export class FolderRepository extends BaseRepository {
throw new Error(await getPlatform().translate(TranslatableMessage.SharedFolderDeleteRefused));
}
}
-
- /**
- * Re-stamp a folder's whole subtree into `manifestId`.
- * @param folderId - The root of the subtree to re-stamp
- * @param manifestId - The manifest the subtree now belongs to
- * @returns The number of folder + item rows re-stamped
- */
- public async restampSubtree(folderId: string, manifestId: string): Promise<number> {
- return this.withTransaction(async () => {
- const folders = await this.run(this.execute(BaseQueries.RESTAMP_SUBTREE_FOLDERS, [manifestId, folderId]));
- const items = await this.run(this.execute(BaseQueries.RESTAMP_SUBTREE_ITEMS, [manifestId, folderId]));
- // The items moved; the images they point at have to follow them into the new manifest.
- await this.logoRepository.reconcileItemLogoScopes(this.now());
- return folders + items;
- });
- }
}