Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Remove unused manifest properties (#2159)
Leendert de Borst55da42163969
diff --git a/apps/browser-extension/src/utils/RustCore.ts b/apps/browser-extension/src/utils/RustCore.tsindex a6fa19245..45d667525 100644--- a/apps/browser-extension/src/utils/RustCore.ts+++ b/apps/browser-extension/src/utils/RustCore.ts@@ -250,11 +250,16 @@ function urlComparisonKey(url: string): string {/** A single table's rows (byte columns rendered as `{ __b64 }`). */export type CodecTableData = { name: string; records: Array<Record<string, unknown>> };-/** Manifest-v1 manifest. Forward-compat: unknown keys are preserved on round-trip. */+/**+ * Manifest-v1 manifest. Forward-compat: unknown keys are preserved on round-trip.+ *+ * Carries no data-model (EF migration) version: each manifest is written by whichever client last+ * pushed it, and a reader materializes into the schema it ships with anyway (anything that schema+ * cannot hold is preserved structurally by `CodecOverflow`). `schemaVersion` is the wire-structure+ * version and is a separate axis.+ */export type CodecManifest = {schemaVersion: number;- /** Latest EF migration ID; readers derive the data-model version label from it. */- migrationId: string;manifestSalt: string;canonicalizedAt: string;manifestId: string;@@ -311,15 +316,18 @@ export type CodecOverflow = {/** Input for canonicalize. */export type CodecCanonicalizeInput = {tables: CodecTableData[];- migrationId: string;canonicalizedAt: string;manifests: CodecManifestSpec[];/** For legacy sqlite-blob migration: the manifest that unstamped rows are adopted into. TODO: delete this field once the migration is complete. */adoptUnstampedInto?: string | null;};-/** Materialized tables the platform inserts into a fresh SQLite DB (`overflow` is a diagnostics copy). */-export type CodecMaterialized = { tables: CodecTableData[]; migrationId: string; overflow: CodecOverflow };+/**+ * Materialized tables the platform inserts into a fresh SQLite DB (`overflow` is a diagnostics copy).+ * No migration id: the DB is created from this client's own schema, which is the only thing that+ * decides which migration the result is at.+ */+export type CodecMaterialized = { tables: CodecTableData[]; overflow: CodecOverflow };/** One entry in the bucket layout: a category and the tables it owns. */export type CodecBucketLayoutEntry = { category: string; tables: string[] };diff --git a/apps/browser-extension/src/utils/VaultCodec.ts b/apps/browser-extension/src/utils/VaultCodec.tsindex 1c66e9784..5ca96dd0a 100644--- a/apps/browser-extension/src/utils/VaultCodec.ts+++ b/apps/browser-extension/src/utils/VaultCodec.ts@@ -117,7 +117,7 @@ export class VaultCodec {/*** Insert the materialized tables into a fresh SQLite database and export it (base64).- * @param materialized - tables + migration id produced by the Rust `materialize_as_sqlite`+ * @param materialized - tables produced by the Rust `materialize_as_sqlite`* @param blobs - map of `hash -> plaintext bytes` (caller fetched + decrypted these)* @param schemaSql - the COMPLETE_SCHEMA_SQL string for the target client version* @returns A base64-encoded SQLite database identical (in row content) to the original.@@ -130,16 +130,6 @@ export class VaultCodec {db.run(schemaSql);console.info('[VaultCodec] Schema applied.');- // 2) Stamp __EFMigrationsHistory so VaultSqlGenerator pickup of the version matches what was exported.- try {- db.run('INSERT OR IGNORE INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") VALUES (?, ?)', [- materialized.migrationId,- 'manifest-v1',- ]);- } catch {- // Tolerate schema variations — some COMPLETE_SCHEMA_SQL forms stamp it themselves.- }-/** SQLite enforces foreign keys immediately (no deferral), and tables are inserted in the order Rust* emitted them, so child rows (e.g. Attachments) may precede their parents (Items). Disable enforcement@@ -151,7 +141,7 @@ export class VaultCodec {// Tables present in the freshly-created schema; rows for tables outside it cannot be inserted.const schemaTables = new Set<string>(db.exec("SELECT name FROM sqlite_master WHERE type='table'")[0]?.values.map(v => String(v[0])) ?? []);- // 3) Insert every materialized table's rows.+ // 2) Insert every materialized table's rows.for (const { name: tableName, records: rows } of materialized.tables) {if (rows.length === 0) {continue;@@ -190,7 +180,7 @@ export class VaultCodec {db.run('COMMIT');- // 4) Verify referential integrity of the fully-assembled database.+ // 3) Verify referential integrity of the fully-assembled database.const fkViolations = db.exec('PRAGMA foreign_key_check');if (fkViolations.length > 0) {const sample = fkViolations[0].values.slice(0, 5).map(v => `${v[0]} row ${v[1]} → missing parent in ${v[2]}`).join('; ');@@ -198,7 +188,7 @@ export class VaultCodec {}console.info('[VaultCodec] Foreign key check passed.');- // 5) Export.+ // 4) Export.const bytes = db.export();console.info(`[VaultCodec] Reassembly complete: exported SQLite of ${bytes.length} bytes.`);let binaryString = '';diff --git a/apps/browser-extension/src/utils/VaultSyncService.ts b/apps/browser-extension/src/utils/VaultSyncService.tsindex d3402d24d..f96fd583c 100644--- a/apps/browser-extension/src/utils/VaultSyncService.ts+++ b/apps/browser-extension/src/utils/VaultSyncService.ts@@ -164,8 +164,6 @@ type ManifestDto = {blobReferences?: BlobRefDto[];/** Plaintext display name of a shared manifest (null for the personal manifest). */name?: string | null;- /** Username of the manifest owner; set only when the caller is not an owner of the group owning it. Display only. */- ownerUsername?: string | null;/** Whether the caller may grant/revoke access to this manifest and publish its email delivery key. */canAdminister?: boolean;/** How the caller's access to this manifest's VEK is encrypted. */@@ -482,7 +480,6 @@ export class VaultSyncService {salt: entry.manifest.manifestSalt,revision: entry.revision,name: entry.manifest.name ?? dto.name ?? null,- ownerUsername: dto.ownerUsername ?? null,canAdminister: dto.canAdminister ?? false,};}@@ -1185,7 +1182,6 @@ export class VaultSyncService {private async canonicalizeVault(sqliteClient: SqliteClient, options?: { adoptUnstampedInto?: string | null }): Promise<CanonicalizedVaultSet> {// Read tables from the SQLite database and apply the manifest-v1 format rules.const tables = VaultCodec.readTables(sqliteClient);- const migrationId = VaultCodec.getLatestMigrationId(sqliteClient);const manifestRecords = await this.resolveManifestRecords(sqliteClient);/*@@ -1198,7 +1194,6 @@ export class VaultSyncService {const canonicalized = await timedStage('canonicalize (incl. Rust→JS conversion)', () => vaultCodecCanonicalizeFromSqlite({tables,- migrationId,canonicalizedAt: new Date().toISOString(),manifests,adoptUnstampedInto: options?.adoptUnstampedInto ?? null,diff --git a/apps/browser-extension/tests/helpers/manifest-v2-api.ts b/apps/browser-extension/tests/helpers/manifest-v2-api.tsindex 72a4b28a9..0e913aaac 100644--- a/apps/browser-extension/tests/helpers/manifest-v2-api.ts+++ b/apps/browser-extension/tests/helpers/manifest-v2-api.ts@@ -39,7 +39,6 @@ export type VaultSnapshot = {/** A decrypted manifest-v1 manifest: known top-level fields plus free-form tables. */export type DecryptedManifest = {schemaVersion: number;- migrationId: string;manifestSalt: string;canonicalizedAt: string;tables: Record<string, Array<Record<string, unknown>>>;diff --git a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs b/apps/server/AliasVault.Api/Controllers/V2/VaultController.csindex db1ae9e13..98e6e2bc8 100644--- a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs+++ b/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs@@ -88,7 +88,6 @@ public class VaultController(}var emailRouting = await BuildEmailRoutingAsync(context, user);- var ownedGroupIds = await GroupHelper.GetOwnedGroupIdsAsync(context, user.Id);// Every manifest the caller can open.var latestManifests = await AccessibleManifests(context, user.Id)@@ -139,10 +138,6 @@ public class VaultController(var accessKeysByManifest = await GetAccessKeysAsync(context, user.Id, manifestIds);var encryptionPublicKeys = await GetEncryptionPublicKeysAsync(context, accessKeysByManifest.Values.Where(g => g.UserGrantKeyId != null).Select(g => g.UserGrantKeyId!.Value));- // A manifest owned by a group the caller does not own is one shared with them: stamp the owning user's name.- var foreignGroupIds = latestManifests.Where(m => !ownedGroupIds.Contains(m.OwnerGroupId)).Select(m => m.OwnerGroupId).Distinct().ToList();- var ownerUsernamesByGroupId = await GetGroupOwnerUsernamesAsync(context, foreignGroupIds);-// Administering a manifest's shares follows group role, not owner identity: an admin of someone else's group// may manage it, and heading a group means managing the manifests filed under it (see GrantAccess).var administeredGroupIds = await GroupHelper.GetAdministeredGroupIdsAsync(context, user.Id);@@ -161,7 +156,6 @@ public class VaultController(CiphertextHash = m.ManifestCiphertextHash,Revision = m.RevisionNumber,BlobReferences = refsByManifest.TryGetValue(m.ManifestId, out var refs) ? refs : [],- OwnerUsername = ownerUsernamesByGroupId.GetValueOrDefault(m.OwnerGroupId),CanAdminister = m.OwnerGroupType == GroupType.Shared && administeredGroupIds.Contains(m.OwnerGroupId),KeyType = accessKey != null ? ManifestKeyTypes.ToToken(accessKey.Type) : null,EncryptedVek = grant?.EncryptedVek,@@ -236,17 +230,10 @@ public class VaultController(}}- // Ownership display and administer rights are only meaningful on a manifest that is not the caller's own home one.+ // Administer rights are only meaningful on a manifest that is not the caller's own home one.if (latest.OwnerGroupId != user.PersonalGroupId){- // Set owner username for shared manifests for display purposes.- var isOwnedByCaller = await context.GroupMembers.AnyAsync(gm => gm.GroupId == latest.OwnerGroupId && gm.UserId == user.Id && gm.Role == GroupRole.Owner);- if (!isOwnedByCaller)- {- manifest.OwnerUsername = (await GetGroupOwnerUsernamesAsync(context, [latest.OwnerGroupId])).GetValueOrDefault(latest.OwnerGroupId);- }-- manifest.CanAdminister = isOwnedByCaller || await GroupHelper.IsGroupAdminAsync(context, latest.OwnerGroupId, user.Id);+ manifest.CanAdminister = await GroupHelper.IsGroupAdminAsync(context, latest.OwnerGroupId, user.Id);}return Ok(manifest);@@ -782,28 +769,6 @@ public class VaultController(.ToDictionary(g => g.Key, g => g.OrderBy(k => k.Type == ManifestKeyType.AccountKey ? 0 : 1).ThenByDescending(k => k.CreatedAt).ThenBy(k => k.Id).First());}- /// <summary>- /// Gets the display owner of each group: the user who owns it, oldest membership first when co-owned.- /// </summary>- /// <param name="context">Database context.</param>- /// <param name="groupIds">The groups to resolve.</param>- /// <returns>The owner's username per group id.</returns>- private static async Task<Dictionary<Guid, string?>> GetGroupOwnerUsernamesAsync(AliasServerDbContext context, IEnumerable<Guid> groupIds)- {- var ids = groupIds.Distinct().ToList();- if (ids.Count == 0)- {- return [];- }-- return (await context.GroupMembers- .Where(gm => ids.Contains(gm.GroupId) && gm.Role == GroupRole.Owner)- .Join(context.AliasVaultUsers, gm => gm.UserId, u => u.Id, (gm, u) => new { gm.GroupId, gm.CreatedAt, gm.UserId, u.UserName })- .ToListAsync())- .GroupBy(x => x.GroupId)- .ToDictionary(g => g.Key, g => g.OrderBy(x => x.CreatedAt).ThenBy(x => x.UserId).First().UserName);- }-/// <summary>/// Writes a new revision of a (manifest, bucket kind): the current row is copied to the history table and then updated in place./// </summary>diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.csindex 4fdd43ff7..c7a52f9ac 100644--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.cs+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.cs@@ -33,12 +33,6 @@ public class Manifest/// <summary>Gets or sets the plaintext display name of a shared manifest. Null for the personal manifest.</summary>public string? Name { get; set; }- /// <summary>- /// Gets or sets the username of the manifest owner.- /// <see cref="CanAdminister"/>).- /// </summary>- public string? OwnerUsername { get; set; }-/// <summary>/// Gets or sets a value indicating whether the caller may administer this manifest's sharing: grant and revoke/// access and publish its email delivery key. True when the caller is an owner or admin of the group that ownsdiff --git a/core/rust/src/vault_codec/canonicalize.rs b/core/rust/src/vault_codec/canonicalize.rsindex a3ce4f764..cc701c94b 100644--- a/core/rust/src/vault_codec/canonicalize.rs+++ b/core/rust/src/vault_codec/canonicalize.rs@@ -108,7 +108,6 @@ pub fn canonicalize_from_sqlite(input: CanonicalizeInput) -> VaultResult<Canonicmanifests.push(CanonicalizedManifest {manifest: Manifest {schema_version: SCHEMA_VERSION,- migration_id: input.migration_id.clone(),manifest_salt: writing_manifest_salt,canonicalized_at: input.canonicalized_at.clone(),manifest_id: writing_manifest_id,@@ -133,7 +132,6 @@ pub fn canonicalize_from_sqlite(input: CanonicalizeInput) -> VaultResult<Canonicmanifests.push(CanonicalizedManifest {manifest: Manifest {schema_version: SCHEMA_VERSION,- migration_id: input.migration_id.clone(),manifest_salt: partition.manifest_salt,canonicalized_at: input.canonicalized_at.clone(),manifest_id: partition.manifest_id,diff --git a/core/rust/src/vault_codec/manifest.rs b/core/rust/src/vault_codec/manifest.rsindex 318e5a033..257c1a4c1 100644--- a/core/rust/src/vault_codec/manifest.rs+++ b/core/rust/src/vault_codec/manifest.rs@@ -9,13 +9,11 @@ use super::types::SCHEMA_VERSION;/// A codec record is a map of column names to JSON values.pub type CodecRecord = HashMap<String, serde_json::Value>;-/// Manifest-v1 manifest+/// Manifest-v1 manifest.#[derive(Debug, Clone, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct Manifest {pub schema_version: u32,- /// Latest EF migration ID.- pub migration_id: String,/// Per-manifest salt for blob hashing (hex). For a shared manifest this salt is shared by/// every participant (it lives inside the encrypted manifest itself) so all of them compute the/// same content-addressed blob hashes.@@ -189,7 +187,6 @@ impl CodecOverflow {#[serde(rename_all = "camelCase")]pub struct MaterializedTables {pub tables: Vec<CodecTableData>,- pub migration_id: String,#[serde(default)]pub overflow: CodecOverflow,}@@ -202,7 +199,6 @@ pub struct CanonicalizeInput {/// [`OVERFLOW_TABLE`](super::types::OVERFLOW_TABLE) row written by the last materialize, its overflow/// (a newer writer's tables/columns this schema can't hold) is re-merged automatically.pub tables: Vec<CodecTableData>,- pub migration_id: String,pub canonicalized_at: String,pub manifests: Vec<ManifestSpec>,/// For legacy sqlite-blob migration: the manifest that unstamped rows are adopted into.@@ -215,10 +211,6 @@ pub struct CanonicalizeInput {#[derive(Debug, Clone, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct MaterializeInput {- /// Every manifest to materialize, the caller's own first. Order carries no privilege between- /// namespaces (each row routes by its own `ManifestId`); the first entry only supplies the- /// reported `migration_id`. Deserialization is positional, so a caller that skips- /// [`MaterializeInput::new`] must keep that order itself.pub manifests: Vec<Manifest>,#[serde(default)]pub data_buckets: Vec<DataBucket>,diff --git a/core/rust/src/vault_codec/materialize.rs b/core/rust/src/vault_codec/materialize.rsindex c2f95b1df..a9f72aba6 100644--- a/core/rust/src/vault_codec/materialize.rs+++ b/core/rust/src/vault_codec/materialize.rs@@ -44,7 +44,6 @@ pub fn materialize_as_sqlite(input: MaterializeInput) -> VaultResult<Materializelet others: Vec<Manifest> = manifests;let base_manifest_id = base.manifest_id.clone();- let migration_id = base.migration_id;let combined = super::sharing::combine_manifest_tables(base.tables, &base_manifest_id, others);let mut overflow = CodecOverflow::default();@@ -95,11 +94,7 @@ pub fn materialize_as_sqlite(input: MaterializeInput) -> VaultResult<Materializetables.push(CodecTableData { name: MANIFESTS_TABLE.to_string(), records: manifest_records });}- Ok(MaterializedTables {- tables,- migration_id,- overflow,- })+ Ok(MaterializedTables { tables, overflow })}/// One `Manifests` row per materialized manifest: `{ Id, Name }`.diff --git a/core/rust/src/vault_codec/types.rs b/core/rust/src/vault_codec/types.rsindex bd12c4272..33b8f5c0f 100644--- a/core/rust/src/vault_codec/types.rs+++ b/core/rust/src/vault_codec/types.rs@@ -48,10 +48,7 @@ pub const MANIFEST_ID_COL: &str = "ManifestId";/// vault is materialized from (`Id`, `Name`).pub const MANIFESTS_TABLE: &str = "Manifests";-/// Manifest / metadata schema version. This is the manifest *wire structure* version and is its own-/// axis, independent of the data-model version (which readers derive from the manifest's `migrationId`).-/// It starts at 1 for the first manifest generation; bump only on a breaking structural change-/// (field type changes, removed fields).+/// Manifest / metadata schema version.pub const SCHEMA_VERSION: u32 = 1;/// Client-local SQLite table that carries the codec overflow inside the vault database itself (see