Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add rootManifestId to BaseRepository.ts (#2159)
Leendert de Borsta0d568d240b1
diff --git a/apps/browser-extension/src/utils/db/BaseRepository.ts b/apps/browser-extension/src/utils/db/BaseRepository.tsindex 4cd2a711b..7dd83922f 100644--- a/apps/browser-extension/src/utils/db/BaseRepository.ts+++ b/apps/browser-extension/src/utils/db/BaseRepository.ts@@ -1,5 +1,7 @@import * as dateFormatter from '@/utils/DateFormatter';+import { SettingsQueries } from './queries/SettingsQueries';+import type { Database } from 'sql.js';export type SqliteBindValue = string | number | null | Uint8Array;@@ -111,6 +113,20 @@ export abstract class BaseRepository {return results.length > 0;}+ /**+ * Get the vault's root manifest id from the Manifests bookkeeping table, the scope every personal row+ * belongs to. Returns null for a legacy vault whose Manifests row was not written yet (mid-schema+ * migration); the codec adopts such rows at the next sync boundary.+ * @returns The root manifest id, or null when absent+ */+ protected rootManifestId(): string | null {+ if (!this.tableExists('Manifests')) {+ return null;+ }+ const results = this.client.executeQuery<{ Id: string }>(SettingsQueries.GET_ROOT_MANIFEST_ID);+ return results.length > 0 ? results[0].Id : null;+ }+/*** Generate a new UUID in uppercase format.* @returns A new UUID stringdiff --git a/apps/browser-extension/src/utils/db/repositories/LogoRepository.ts b/apps/browser-extension/src/utils/db/repositories/LogoRepository.tsindex cc2ab2569..e4845f80b 100644--- a/apps/browser-extension/src/utils/db/repositories/LogoRepository.ts+++ b/apps/browser-extension/src/utils/db/repositories/LogoRepository.ts@@ -4,7 +4,6 @@ import { vaultCodecLogoContentHash, vaultCodecLogoIdFor } from '@/utils/RustCoreimport { BaseRepository } from '../BaseRepository';import { LogoQueries } from '../queries/LogoQueries';-import { SettingsQueries } from '../queries/SettingsQueries';/*** An uploaded logo as shown in the user's logo library.@@ -69,7 +68,11 @@ export class LogoRepository extends BaseRepository {currentDateTime: string,options: { mimeType?: string | null; name?: string | null } = {}): Promise<string> {- const logoId = await vaultCodecLogoIdFor(this.rootManifestId(), kind, source);+ /*+ * A legacy vault without a Manifests row derives its ids under an empty scope; the codec re-mints+ * them at the next sync boundary, so the placeholder scope is self-healing.+ */+ const logoId = await vaultCodecLogoIdFor(this.rootManifestId() ?? '', kind, source);this.client.executeUpdate(LogoQueries.UPSERT, [logoId,kind,@@ -122,17 +125,6 @@ export class LogoRepository extends BaseRepository {return this.client.executeUpdate(LogoQueries.SOFT_DELETE, [currentDateTime, logoId]);}- /**- * The vault's root manifest id, used as the derivation scope of personal logo ids. Empty for a- * legacy vault whose Manifests row was not written yet — the codec re-mints such ids at the next- * sync boundary, so a temporary placeholder scope is self-healing.- * @returns The root manifest id, or an empty string when absent- */- private rootManifestId(): string {- const rows = this.client.executeQuery<{ Id: string }>(SettingsQueries.GET_ROOT_MANIFEST_ID);- return rows.length > 0 ? rows[0].Id : '';- }-/*** Extract and normalize source domain from a URL string.* Uses lowercase and removes www. prefix for case-insensitive matching.diff --git a/apps/browser-extension/src/utils/db/repositories/SettingsRepository.ts b/apps/browser-extension/src/utils/db/repositories/SettingsRepository.tsindex 2cbf2976b..0b76d29d8 100644--- a/apps/browser-extension/src/utils/db/repositories/SettingsRepository.ts+++ b/apps/browser-extension/src/utils/db/repositories/SettingsRepository.ts@@ -110,15 +110,7 @@ export class SettingsRepository extends BaseRepository {* @returns The root manifest id, or null when the account is legacy*/public getRootManifestId(): string | null {- /*- * A legacy account that predates the Manifests table (mid-schema-migration) has no- * no root manifest id (yet).- */- if (!this.tableExists('Manifests')) {- return null;- }- const results = this.client.executeQuery<{ Id: string }>(SettingsQueries.GET_ROOT_MANIFEST_ID);- return results.length > 0 ? results[0].Id : null;+ return this.rootManifestId();}/**