Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Refactor root to personal (#2159)
Leendert de Borstbf4f5e2c25bf
diff --git a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.tsindex 770cf6c4c..da3c39821 100644--- a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts+++ b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts@@ -61,15 +61,15 @@ let cachedSqliteClient: SqliteClient | null = null;let cachedVaultBlob: string | null = null;/**- * The server revision of the user's root manifest.+ * The server revision of the user's personal manifest.* @param status - the status response from the server*/-function rootManifestRevision(status: StatusResponseV2): number {- const root = (status.manifestRevisions ?? []).find(m => m.isRoot);- return root?.revision ?? 0;+function personalManifestRevision(status: StatusResponseV2): number {+ const personal = (status.manifestRevisions ?? []).find(m => m.manifestId === status.personalManifestId);+ return personal?.revision ?? 0;}-/** The client's last-known revision per non-root manifest (manifestId → revision); empty when no shared manifests. */+/** The client's last-known revision per shared manifest (manifestId → revision); empty when no shared manifests. */async function getLocalSharedManifestRevisions(): Promise<Record<string, number>> {return (await storage.getItem(StorageKeys.SERVER_MANIFEST_REVISIONS)) as Record<string, number> | null ?? {};}@@ -81,15 +81,16 @@ async function getLocalSharedManifestRevisions(): Promise<Record<string, number>* the server, so this returns false until the next server-side change.** @param serverManifests - the per-manifest revisions from the status response- * @param localMainRevision - the client's last-known root manifest revision (local:serverRevision)- * @param localSharedRevisions - the client's last-known revision per non-root manifest+ * @param personalManifestId - the id the server names as the caller's own; every other entry is a shared manifest+ * @param localMainRevision - the client's last-known personal manifest revision (local:serverRevision)+ * @param localSharedRevisions - the client's last-known revision per shared manifest*/-function serverManifestsNeedPull(serverManifests: ManifestRevision[], localMainRevision: number, localSharedRevisions: Record<string, number>): boolean {+function serverManifestsNeedPull(serverManifests: ManifestRevision[], personalManifestId: string | null, localMainRevision: number, localSharedRevisions: Record<string, number>): boolean {const serverShared = new Map<string, number>();- let serverRootRevision: number | null = null;+ let serverPersonalRevision: number | null = null;for (const m of (serverManifests ?? [])) {- if (m.isRoot) {- serverRootRevision = m.revision;+ if (personalManifestId !== null && m.manifestId === personalManifestId) {+ serverPersonalRevision = m.revision;} else {serverShared.set(m.manifestId, m.revision);}@@ -98,8 +99,8 @@ function serverManifestsNeedPull(serverManifests: ManifestRevision[], localMainR/** Decide whether to pull and log the concrete reason.*/- if (serverRootRevision !== null && serverRootRevision > localMainRevision) {- devLog(`[VaultSync] Pull needed: root manifest server rev ${serverRootRevision} > local rev ${localMainRevision}.`);+ if (serverPersonalRevision !== null && serverPersonalRevision > localMainRevision) {+ devLog(`[VaultSync] Pull needed: personal manifest server rev ${serverPersonalRevision} > local rev ${localMainRevision}.`);return true;}@@ -120,7 +121,7 @@ function serverManifestsNeedPull(serverManifests: ManifestRevision[], localMainRreturn true;}- devLog(`[VaultSync] No pull needed: root rev ${serverRootRevision ?? 'n/a'} (local ${localMainRevision}), ${serverShared.size} shared manifest(s) all match local revisions.`);+ devLog(`[VaultSync] No pull needed: personal rev ${serverPersonalRevision ?? 'n/a'} (local ${localMainRevision}), ${serverShared.size} shared manifest(s) all match local revisions.`);return false;}@@ -319,7 +320,7 @@ export async function handleSyncVault(const localServerRevision = await storage.getItem(StorageKeys.SERVER_REVISION) as number | null ?? 0;const localSharedRevisions = await getLocalSharedManifestRevisions();- if (serverManifestsNeedPull(statusResponse.manifestRevisions, localServerRevision, localSharedRevisions)) {+ if (serverManifestsNeedPull(statusResponse.manifestRevisions, statusResponse.personalManifestId, localServerRevision, localSharedRevisions)) {/** Retrieve the latest vault from the server.*/@@ -1504,9 +1505,9 @@ async function handleFullVaultSyncInternal(): Promise<FullVaultSyncResult> {// Get current sync stateconst syncState = await handleGetSyncState();- const serverManifestRevision = rootManifestRevision(statusResponse);+ const serverManifestRevision = personalManifestRevision(statusResponse);const localSharedRevisions = await getLocalSharedManifestRevisions();- const needsPull = serverManifestsNeedPull(statusResponse.manifestRevisions, syncState.serverRevision, localSharedRevisions);+ const needsPull = serverManifestsNeedPull(statusResponse.manifestRevisions, statusResponse.personalManifestId, syncState.serverRevision, localSharedRevisions);devLog(`[VaultSync] Status received (server main rev ${serverManifestRevision}, local rev ${syncState.serverRevision}, needsPull ${needsPull}, isDirty ${syncState.isDirty})`);diff --git a/apps/browser-extension/src/utils/EmailRouting.ts b/apps/browser-extension/src/utils/EmailRouting.tsindex 463c76b32..fd65a6731 100644--- a/apps/browser-extension/src/utils/EmailRouting.ts+++ b/apps/browser-extension/src/utils/EmailRouting.ts@@ -10,11 +10,11 @@ import type { EmailRoutingPush } from '@/utils/types/EmailRoutingPush';* shared alias and everything in the user's own manifest is personal.** @param manifests - every manifest one canonicalize run produced, the user's own included- * @param rootManifestId - the id of the user's own manifest; its addresses stay personal+ * @param personalManifestId - the id of the user's own manifest; its addresses stay personal* @param privateEmailDomains - domains the server hosts mail for; addresses outside them are not claimed* @returns The addresses to claim, each against the manifest that owns it*/-export function buildEmailRouting(manifests: CodecManifest[], rootManifestId: string, privateEmailDomains: string[]): EmailRoutingPush {+export function buildEmailRouting(manifests: CodecManifest[], personalManifestId: string, privateEmailDomains: string[]): EmailRoutingPush {const manifestIdByAddress = new Map<string, string>();/**@@ -41,8 +41,8 @@ export function buildEmailRouting(manifests: CodecManifest[], rootManifestId: stcontinue;}- // A shared manifest always wins the address; the root manifest only claims one nothing else has.- if (manifestId !== rootManifestId || !manifestIdByAddress.has(address)) {+ // A shared manifest always wins the address; the personal manifest only claims one nothing else has.+ if (manifestId !== personalManifestId || !manifestIdByAddress.has(address)) {manifestIdByAddress.set(address, manifestId);}}@@ -53,7 +53,7 @@ export function buildEmailRouting(manifests: CodecManifest[], rootManifestId: st* @param manifest - the manifest to test* @returns True when it is the manifest this vault is written from*/- const isOwn = (manifest: CodecManifest): boolean => manifest.manifestId === rootManifestId;+ const isOwn = (manifest: CodecManifest): boolean => manifest.manifestId === personalManifestId;/** The user's own manifest first: an address it also carries stays personal only while no shared manifestdiff --git a/apps/browser-extension/src/utils/VaultSyncService.ts b/apps/browser-extension/src/utils/VaultSyncService.tsindex 523712e0d..1c64aab33 100644--- a/apps/browser-extension/src/utils/VaultSyncService.ts+++ b/apps/browser-extension/src/utils/VaultSyncService.ts@@ -105,6 +105,15 @@ function topLevelFolderId(manifest: VaultManifest): string | null {return roots.length === 1 ? roots[0] : null;}+/**+ * Whether two manifest ids match.+ * @param a - first manifest id+ * @param b - second manifest id+ */+function manifestIdsEqual(a: string | null | undefined, b: string | null | undefined): boolean {+ return typeof a === 'string' && typeof b === 'string' && a.toLowerCase() === b.toLowerCase();+}+/** Fingerprint record key for a manifest. */const fingerprintManifestKey = (manifestId: string): string => `manifest:${manifestId}`;/** Fingerprint record key for a data bucket. */@@ -141,14 +150,14 @@ type BlobRefDto = { hash: string; category: string };type BlobDto = { hash: string; category: string; encryptedDataBase64: string };/** A plaintext blob staged for upload: its bytes plus the key that encrypts it. */-type UploadBlobEntry = { bytes: Uint8Array; kind: 'favicon' | 'attachment'; vek: string; fromRoot: boolean };+type UploadBlobEntry = { bytes: Uint8Array; kind: 'favicon' | 'attachment'; vek: string; fromPersonal: boolean };/*** One manifest of a pull.*/type ResolvedManifest = {manifestId: string;- isRoot: boolean;+ isPersonal: boolean;manifest: VaultManifest;/** The key that decrypts this manifest and every blob it references. */vek: string;@@ -163,12 +172,11 @@ type ResolvedManifest = {*/type ManifestDto = {manifestId: string;- isRoot: boolean;blob?: string | null;ciphertextHash?: string | null;revision: number;blobReferences?: BlobRefDto[];- /** Plaintext display name of a shared manifest (null for the root manifest). */+ /** 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;@@ -191,12 +199,14 @@ type BucketDto = { category: string; blob?: string | null; ciphertextHash?: stritype BucketRevisionDto = { category: string; revision: number };/**- * Pick the user's root manifest from a snapshot's manifest list. Strict on purpose: when no manifest is flagged as- * root there is no safe fallback (grabbing an arbitrary manifest could assemble the wrong vault), so callers that- * require a root manifest must fail loudly on `undefined`.+ * Pick the user's personal manifest out of a snapshot. The server names it by id rather than flagging each entry, so+ * that one id is the only thing that decides which manifest is the caller's own. Strict on purpose: with no id, or an+ * id matching nothing, there is no safe fallback (grabbing an arbitrary manifest could assemble the wrong vault), so+ * callers that require a personal manifest must fail loudly on `undefined`.*/-function selectRootManifest(manifests: ManifestDto[] | undefined | null): ManifestDto | undefined {- return (manifests ?? []).find(m => m.isRoot);+function selectPersonalManifest(snapshot: GetResponseDto | undefined | null): ManifestDto | undefined {+ const personalId = snapshot?.personalManifestId;+ return personalId ? (snapshot?.manifests ?? []).find(m => m.manifestId === personalId) : undefined;}/**@@ -222,8 +232,11 @@ export type GetResponseDto = {version?: string | null;/** The legacy sqlite-blob revision (set only on the sqlite-blob path). */legacyRevision?: number | null;- /** The caller's root manifest id; set on the sqlite-blob path where the manifests list is empty. */- rootManifestId?: string | null;+ /**+ * The caller's personal manifest id: the one manifest owned by their personal group, every other entry being a+ * shared one. Also set on the sqlite-blob path, where the manifests list is empty.+ */+ personalManifestId?: string | null;/** The manifests making up the logical vault. Each carries its own blob references. */manifests?: ManifestDto[];buckets?: BucketDto[];@@ -236,26 +249,25 @@ export type GetResponseDto = {};/**- * One manifest element in a POST /v2/Vault write. Every manifest is addressed by `manifestId`, root included; `isRoot`- * asserts what kind of target that id is and the server rejects the write when the two disagree.+ * One manifest element in a POST /v2/Vault write. Every manifest is addressed by `manifestId`, the personal manifest+ * included, so the server never has to infer the target; it authorizes each id against what the caller may write.*/type ManifestWriteDto = {- isRoot?: boolean;- manifestId?: string;+ manifestId: string;manifestBlob: string;manifestCiphertextHash: string;currentRevision: number;credentialsCount: number;blobReferences: BlobRefDto[];/**- * The newly generated VEK encrypted with the password-derived KEK. Set on the root write of a legacy user's first manifest-v1 push.+ * The newly generated VEK encrypted with the password-derived KEK. Set on the personal-manifest write of a legacy user's first manifest-v1 push.* TODO: can be deleted once all users have migrated to manifest-v1.*/encryptedVek?: string;};/** Per-manifest result of a write: the new revision (Ok) or the current server revision (Outdated). */-type ManifestWriteResultDto = { isRoot: boolean; manifestId: string | null; revision: number };+type ManifestWriteResultDto = { manifestId: string; revision: number };type VaultWriteResponseDto = {status: number;@@ -271,9 +283,9 @@ type MissingBlobsResponseDto = { missing: string[] };*/type PushManifest = {manifestId: string;- isRoot: boolean;+ isPersonal: boolean;manifest: CodecManifest;- /** The key this manifest and its blobs encrypt with: the vault's content key for the root, the grant's VEK otherwise. */+ /** The key this manifest and its blobs encrypt with: the vault's content key for the personal manifest, the grant's VEK otherwise. */vek: string;blobs: Record<string, CodecBlobEntry>;/** The revision this write rebases on; the server rejects the whole batch when any is stale. */@@ -282,28 +294,28 @@ type PushManifest = {/*** One manifest this vault can write, as resolved from local state before canonicalizing. The list is uniform on- * purpose: the codec treats every manifest alike and the push drives one loop over all of them. `isRoot` marks the+ * purpose: the codec treats every manifest alike and the push drives one loop over all of them. `isPersonal` marks the* few places where the user's own manifest genuinely differs (see {@link resolveManifestRecords}).*/type ManifestRecord = {manifestId: string;- isRoot: boolean;+ isPersonal: boolean;/** Salt this manifest's blob hashes are derived with. */salt: string;- /** The folder this manifest is anchored at; null for the root, which anchors nowhere. */+ /** The folder this manifest is anchored at; null for the personal manifest, which anchors nowhere. */folderId: string | null;- /** The key this manifest encrypts with; null for the root, whose content key the push supplies (it can be freshly minted). */+ /** The key this manifest encrypts with; null for the personal manifest, whose content key the push supplies (it can be freshly minted). */vek: string | null;/** Last-known server revision as of this resolve; the push overlays anything newer it has recorded since. */revision: number;- /** Plaintext display name; null for the root. */+ /** Plaintext display name; null for the personal manifest. */name: string | null;/** Whether the caller may publish this manifest's email delivery key. */canAdminister: boolean;};/**- * The canonicalized vault plus the manifest records it was split against, root first (the order canonicalize+ * The canonicalized vault plus the manifest records it was split against, personal manifest first (the order canonicalize* requires: the first spec is the manifest being written from).*/type CanonicalizedVaultSet = {@@ -326,17 +338,18 @@ function recordOwnManifestId(materialized: CodecMaterialized, manifestId: stringmaterialized.tables.push(settings);}- const existing = settings.records.find(r => r.Key === BaseQueries.ROOT_MANIFEST_SETTING_KEY);+ const now = new Date().toISOString();++ const existing = settings.records.find(r => r.Key === BaseQueries.PERSONAL_MANIFEST_SETTING_KEY);if (existing && existing.Value === manifestId && !existing.IsDeleted) {return;}- const now = new Date().toISOString();if (existing) {Object.assign(existing, { Value: manifestId, UpdatedAt: now, IsDeleted: 0 });return;}- settings.records.push({ Key: BaseQueries.ROOT_MANIFEST_SETTING_KEY, Value: manifestId, CreatedAt: now, UpdatedAt: now, IsDeleted: 0 });+ settings.records.push({ Key: BaseQueries.PERSONAL_MANIFEST_SETTING_KEY, Value: manifestId, CreatedAt: now, UpdatedAt: now, IsDeleted: 0 });}let canonicalizeCache: ({ client: SqliteClient; mutationSequence: number } & CanonicalizedVaultSet) | null = null;@@ -368,8 +381,8 @@ export class VaultSyncService {*/devLog('[V2Pull] Step 1/4: fetching vault snapshot (GET /v2/Vault)...');const snapshot = await this.fetchSnapshot();- const rootManifest = selectRootManifest(snapshot.manifests);- devLog(`[V2Pull] Step 1/4 done: storageFormat=${snapshot.storageFormat}, manifests=${snapshot.manifests?.length ?? 0}, rootRevision=${rootManifest?.revision}, manifestBlob=${rootManifest?.blob?.length ?? 0} chars, buckets=${snapshot.buckets?.length ?? 0}, blobRefs=${rootManifest?.blobReferences?.length ?? 0}`);+ const personalManifest = selectPersonalManifest(snapshot);+ devLog(`[V2Pull] Step 1/4 done: storageFormat=${snapshot.storageFormat}, manifests=${snapshot.manifests?.length ?? 0}, personalRevision=${personalManifest?.revision}, manifestBlob=${personalManifest?.blob?.length ?? 0} chars, buckets=${snapshot.buckets?.length ?? 0}, blobRefs=${personalManifest?.blobReferences?.length ?? 0}`);/** Steps 2–4: decrypt, materialize, and re-encrypt. Any failure here is a client-side vault-processing error@@ -398,8 +411,8 @@ export class VaultSyncService {* Legacy user: the vault has never been materialized, so it carries no record of which manifest is* ours. Persist it in local storage so the first migration canonicalize step can stamp rows with it.*/- if (snapshot.rootManifestId) {- await storage.setItem(StorageKeys.VAULT_ROOT_MANIFEST_ID, snapshot.rootManifestId);+ if (snapshot.personalManifestId) {+ await storage.setItem(StorageKeys.VAULT_PERSONAL_MANIFEST_ID, snapshot.personalManifestId);}devLog('[V2Pull] Step 2/4: legacy blob pass-through (user not yet migrated), returning as-is.');return this.buildResponse(@@ -432,7 +445,7 @@ export class VaultSyncService {* For legacy sqlite-blob migration: the manifest that unstamped rows are adopted into.* TODO: delete this field once the migration is complete.*/- const ownManifestId = await this.resolveRootManifestId(sqliteClient);+ const ownManifestId = await this.resolvePersonalManifestId(sqliteClient);const { canonicalized, manifestRecords } = await this.canonicalizeVault(sqliteClient, { adoptUnstampedInto: ownManifestId });/*@@ -453,7 +466,7 @@ export class VaultSyncService {/** Record which manifest is ours in the migrated vault, exactly as a pull does. A legacy vault has* never been materialized and so carries no such row, while the write path resolves the stamp for- * a new row from it (see `BaseQueries.ROOT_MANIFEST_ID`). Without this, every root-level insert+ * a new row from it (see `BaseQueries.GET_PERSONAL_MANIFEST_ID`). Without this, every top-level insert* between the migration and the next pull resolves its stamp to NULL and is rejected outright by* the column's NOT NULL constraint.*/@@ -496,17 +509,17 @@ export class VaultSyncService {* Materialize a local SQLite database from an already-fetched manifest-v1 snapshot: verify ciphertext integrity,* decrypt every manifest and the data buckets, fetch any missing referenced blobs, then run the codec.* @param snapshot - the raw GET /v2/Vault response- * @param vek - the root manifest's symmetric key (from the unlock chain); decrypts the root manifest and the data buckets+ * @param vek - the personal manifest's symmetric key (from the unlock chain); decrypts the personal manifest and the data buckets*/private async materializeFromSnapshot(snapshot: GetResponseDto, vek: string): Promise<PullResult> {const webApi = new WebApiService();- const rootDto = selectRootManifest(snapshot.manifests);- if (!rootDto) {- throw new Error('VaultSyncService: server returned no root manifest, refusing to assemble.');+ const personalDto = selectPersonalManifest(snapshot);+ if (!personalDto) {+ throw new Error('VaultSyncService: server returned no personal manifest, refusing to assemble.');}- if (!rootDto.blob) {+ if (!personalDto.blob) {throw new Error('VaultSyncService: server returned no manifest blob, nothing to assemble.');}@@ -514,9 +527,9 @@ export class VaultSyncService {const pulledFingerprints: Record<string, string> = {};/*- * Open every manifest in the snapshot through one path, root first.+ * Open every manifest in the snapshot through one path, personal manifest first.*/- const accountKeyVeks = new Map<string, string>([[rootDto.manifestId, vek]]);+ const accountKeyVeks = new Map<string, string>([[personalDto.manifestId, vek]]);const resolved: ResolvedManifest[] = [];const sessionSharedManifests: Record<string, SessionSharedManifest> = {};/*@@ -524,11 +537,12 @@ export class VaultSyncService {* but not yet split into) still resolves to the folder the client renders it at.*/const priorFolderIds = new Map(Object.values(await SharingService.getSessionSharedManifests()).map(r => [r.manifestId, r.folderId]));- for (const dto of [rootDto, ...(snapshot.manifests ?? []).filter(m => m.manifestId !== rootDto.manifestId)]) {- const manifestKey = await this.resolveManifestVek(dto, accountKeyVeks, resolved[0]?.manifest ?? null);+ for (const dto of [personalDto, ...(snapshot.manifests ?? []).filter(m => m.manifestId !== personalDto.manifestId)]) {+ const isPersonal = dto.manifestId === personalDto.manifestId;+ const manifestKey = await this.resolveManifestVek(dto, accountKeyVeks, isPersonal, resolved[0]?.manifest ?? null);if (!manifestKey || !dto.blob) {// Same policy as a manifest that fails to open: a shared one only costs us that folder, the home one is the vault.- if (dto.manifestId === rootDto.manifestId) {+ if (dto.manifestId === personalDto.manifestId) {throw new Error(`VaultSyncService: no key resolved for the home manifest ${dto.manifestId} (key type "${dto.keyType ?? 'unspecified'}"), refusing to assemble.`);}continue;@@ -536,10 +550,10 @@ export class VaultSyncService {let entry: ResolvedManifest;try {- devLog(`[V2Pull] Verifying ciphertext hash; decrypting + opening ${dto.isRoot ? 'root manifest' : `shared manifest ${dto.manifestId}`}...`);- entry = await this.openManifest(dto, manifestKey);+ devLog(`[V2Pull] Verifying ciphertext hash; decrypting + opening ${isPersonal ? 'personal manifest' : `shared manifest ${dto.manifestId}`}...`);+ entry = await this.openManifest(dto, manifestKey, isPersonal);} catch (e) {- if (dto.isRoot) {+ if (isPersonal) {throw e;}devWarn(`[V2Pull] Failed to open shared manifest ${dto.manifestId}, skipping it.`, e);@@ -547,16 +561,16 @@ export class VaultSyncService {}resolved.push(entry);- const folderId = dto.isRoot ? null : (topLevelFolderId(entry.manifest) ?? priorFolderIds.get(dto.manifestId) ?? null);- devLog(`[V2Pull] Manifest ${entry.manifestId} opened (content hash verified, ${dto.isRoot ? 'root' : `folder ${folderId ?? 'unassigned'}`}): tables: ${Object.entries(entry.manifest.tables).map(([t, rows]) => `${t}=${rows.length}`).join(', ')}`);+ const folderId = isPersonal ? null : (topLevelFolderId(entry.manifest) ?? priorFolderIds.get(dto.manifestId) ?? null);+ devLog(`[V2Pull] Manifest ${entry.manifestId} opened (content hash verified, ${isPersonal ? 'personal' : `folder ${folderId ?? 'unassigned'}`}): tables: ${Object.entries(entry.manifest.tables).map(([t, rows]) => `${t}=${rows.length}`).join(', ')}`);- if (dto.isRoot) {+ if (isPersonal) {/*- * Persist the root manifest's blob salt locally so subsequent canonicalizes hash blobs the same way, and the root+ * Persist the personal manifest's blob salt locally so subsequent canonicalizes hash blobs the same way, and the personal* manifest id so a push can resolve it even before the vault DB records it (see `recordOwnManifestId`).*/await storage.setItem(StorageKeys.VAULT_MANIFEST_SALT, entry.manifest.manifestSalt);- await storage.setItem(StorageKeys.VAULT_ROOT_MANIFEST_ID, entry.manifestId);+ await storage.setItem(StorageKeys.VAULT_PERSONAL_MANIFEST_ID, entry.manifestId);continue;}@@ -579,11 +593,11 @@ export class VaultSyncService {}await SharingService.setSessionSharedManifests(sessionSharedManifests);- const root = resolved[0];+ const personal = resolved[0];/*- * Decrypt every data bucket in the snapshot (Settings today; more categories later). Buckets belong to the root- * manifest alone (personal tables are stripped out of every shared manifest), so they all open with the root VEK.+ * Decrypt every data bucket in the snapshot (Settings today; more categories later). Buckets belong to the personal+ * manifest alone (personal tables are stripped out of every shared manifest), so they all open with its VEK.*/const dataBuckets: VaultDataBucket[] = [];for (const bucketDto of (snapshot.buckets ?? [])) {@@ -604,14 +618,14 @@ export class VaultSyncService {devLog('[V2Pull] No data buckets in snapshot.');}- // One fingerprint baseline per opened manifest, addressed by manifest id (root included).+ // One fingerprint baseline per opened manifest, addressed by manifest id (the personal manifest included).for (const entry of resolved) {pulledFingerprints[fingerprintManifestKey(entry.manifestId)] = entry.contentFingerprint;}// Persist the revision of every manifest so sync can detect when one is added or updated server-side.- await storage.setItem(StorageKeys.SERVER_REVISION, root.revision);- const sharedManifestRevisions = Object.fromEntries(resolved.filter(m => !m.isRoot).map(m => [m.manifestId, m.revision]));+ await storage.setItem(StorageKeys.SERVER_REVISION, personal.revision);+ const sharedManifestRevisions = Object.fromEntries(resolved.filter(m => !m.isPersonal).map(m => [m.manifestId, m.revision]));await storage.setItem(StorageKeys.SERVER_MANIFEST_REVISIONS, sharedManifestRevisions);devLog(`[V2Pull] Stored local shared-manifest revisions from snapshot: ${Object.keys(sharedManifestRevisions).length === 0 ? '(none)' : Object.entries(sharedManifestRevisions).map(([id, rev]) => `${id}=${rev}`).join(', ')}. Next status check compares against these.`);@@ -653,11 +667,11 @@ export class VaultSyncService {const owner = refOwners.get(r.hash);const blobKey = owner?.vek ?? vek;/*- * Root-manifest attachments are load-bearing (a NULL insert would propagate data loss on the next push);+ * Personal-manifest attachments are load-bearing (a NULL insert would propagate data loss on the next push);* shared-manifest blob gaps only degrade that folder, so they are logged and skipped. TODO: revisit once* cross-member blob availability is guaranteed (shared attachment gaps currently degrade like favicons).*/- const strict = r.category === 'attachment' && owner?.isRoot === true;+ const strict = r.category === 'attachment' && owner?.isPersonal === true;if (!ciphertext) {if (strict) {throw new Error(`VaultSyncService: attachment blob ${r.hash} is referenced by the manifest but missing on the server, refusing to assemble an incomplete vault.`);@@ -709,28 +723,46 @@ export class VaultSyncService {* Record which of these manifests is ours, inside the vault we are assembling. The codec treats* every manifest alike: a user may own several, and which one a client calls home is its own* state. So this comes from what the server reported in this snapshot, and it is what the local- * write path stamps new rows with (see `BaseQueries.ROOT_MANIFEST_ID`).+ * write path stamps new rows with (see `BaseQueries.GET_PERSONAL_MANIFEST_ID`).*/- recordOwnManifestId(materialized, root.manifestId);+ recordOwnManifestId(materialized, personal.manifestId);const sqliteBase64 = await VaultCodec.insertTables(materialized, blobMap, schemaSql);devLog('[V2Pull] Codec reassembly complete.');- return { sqliteBase64, manifestRevision: root.revision };+ return { sqliteBase64, manifestRevision: personal.revision };}/*** Verify one snapshot manifest's ciphertext, decrypt and open it into a {@link ResolvedManifest}.* @param dto - the snapshot manifest (must carry a blob)* @param vek - the key that decrypts it+ * @param isPersonal - whether this is the manifest the snapshot named as the caller's own*/- private async openManifest(dto: ManifestDto, vek: string): Promise<ResolvedManifest> {- const isRoot = dto.isRoot === true;- const manifestJson = await verifyDecryptUnpack(dto.blob!, vek, dto.ciphertextHash, isRoot ? 'manifest' : `shared manifest ${dto.manifestId}`);+ private async openManifest(dto: ManifestDto, vek: string, isPersonal: boolean): Promise<ResolvedManifest> {+ const manifestJson = await verifyDecryptUnpack(dto.blob!, vek, dto.ciphertextHash, isPersonal ? 'manifest' : `shared manifest ${dto.manifestId}`);+ const manifest = JSON.parse(manifestJson) as VaultManifest;++ /*+ * Bind the payload's self-declared identity to the row the server served it from. This is the only place the+ * two meet: the id inside the blob is what the codec stamps every row of this manifest with (see+ * `claim_manifest_scope`), and the server can never check it — the blob is opaque to it and the id on the row+ * is simply what the creating client sent alongside (POST /v2/Sharing/manifests).+ *+ * Without this check, anyone could create a manifest of their own, embed *another* manifest's id inside it and+ * share it with one of that manifest's members: the recipient would stamp the attacker's rows with the embedded+ * id, and their next push would split those rows straight into a manifest the attacker holds no key for. A+ * revoked member still knows the id (it is stamped on every row of the copy they kept), so revocation alone+ * does not close that door.+ */+ if (!manifestIdsEqual(manifest.manifestId, dto.manifestId)) {+ throw new Error(`VaultSyncService: manifest ${dto.manifestId} declares a different id (${manifest.manifestId}) inside its encrypted payload, refusing to open it.`);+ }+return {manifestId: dto.manifestId,- isRoot,- manifest: JSON.parse(manifestJson) as VaultManifest,+ isPersonal,+ manifest,vek,revision: typeof dto.revision === 'number' ? dto.revision : 0,blobReferences: dto.blobReferences ?? [],@@ -742,12 +774,13 @@ export class VaultSyncService {* The key that opens one snapshot manifest.* @param dto - the snapshot manifest* @param accountKeyVeks - the VEKs already held per manifest id, keyed by the account key hierarchy- * @param rootManifest - the already-decrypted root manifest (the durable home of rotated private keys), or null when none is open yet+ * @param isPersonal - whether this is the manifest the snapshot named as the caller's own+ * @param personalManifest - the already-decrypted personal manifest (the durable home of rotated private keys), or null when none is open yet* @returns The manifest's VEK, or null when this client holds no key for it.*/- private async resolveManifestVek(dto: ManifestDto, accountKeyVeks: Map<string, string>, rootManifest: CodecManifest | null): Promise<string | null> {+ private async resolveManifestVek(dto: ManifestDto, accountKeyVeks: Map<string, string>, isPersonal: boolean, personalManifest: CodecManifest | null): Promise<string | null> {// A server that predates the field says nothing, and there the home manifest is the account-key one by definition.- const keyType = dto.keyType ?? (dto.isRoot ? MANIFEST_KEY_TYPE_ACCOUNT : MANIFEST_KEY_TYPE_GRANT);+ const keyType = dto.keyType ?? (isPersonal ? MANIFEST_KEY_TYPE_ACCOUNT : MANIFEST_KEY_TYPE_GRANT);if (keyType === MANIFEST_KEY_TYPE_ACCOUNT) {const accountKeyVek = accountKeyVeks.get(dto.manifestId);@@ -764,26 +797,26 @@ export class VaultSyncService {return null;}- if (!rootManifest) {- devWarn(`[V2Pull] Manifest ${dto.manifestId} is opened through a grant, but no root manifest is open to resolve the private key from; skipping it.`);+ if (!personalManifest) {+ devWarn(`[V2Pull] Manifest ${dto.manifestId} is opened through a grant, but no personal manifest is open to resolve the private key from; skipping it.`);return null;}- return this.resolveGrantedVek(rootManifest, dto);+ return this.resolveGrantedVek(personalManifest, dto);}/*** Decrypt the VEK the server granted the caller on a manifest.- * @param rootManifest - the already-decrypted root manifest, the durable home of rotated private keys+ * @param personalManifest - the already-decrypted personal manifest, the durable home of rotated private keys* @param dto - the snapshot manifest carrying the grant*/- private async resolveGrantedVek(rootManifest: CodecManifest, dto: ManifestDto): Promise<string | null> {+ private async resolveGrantedVek(personalManifest: CodecManifest, dto: ManifestDto): Promise<string | null> {if (!dto.encryptedVek || !dto.encryptionPublicKey) {devWarn(`[V2Pull] No key available for shared manifest ${dto.manifestId}, skipping it.`);return null;}- const privateKeyJwk = await this.resolvePrivateKeyJwk(rootManifest, dto.encryptionPublicKey);+ const privateKeyJwk = await this.resolvePrivateKeyJwk(personalManifest, dto.encryptionPublicKey);if (!privateKeyJwk) {devWarn(`[V2Pull] No key available for shared manifest ${dto.manifestId}, skipping it.`);return null;@@ -799,10 +832,10 @@ export class VaultSyncService {/*** Resolve the user's asymmetric private key (JWK string) for decrypting a shared manifest's VEK.- * @param rootManifest - the decrypted root manifest+ * @param personalManifest - the decrypted personal manifest* @param encryptionPublicKey - the public key the grant's VEK was encrypted with*/- private async resolvePrivateKeyJwk(rootManifest: CodecManifest, encryptionPublicKey: string): Promise<string | null> {+ private async resolvePrivateKeyJwk(personalManifest: CodecManifest, encryptionPublicKey: string): Promise<string | null> {const accountPublicKey = await VaultKeyService.getAccountPublicKey();if (accountPublicKey === encryptionPublicKey) {const sessionPrivateKey = await VaultKeyService.getSessionAccountPrivateKey();@@ -811,7 +844,7 @@ export class VaultSyncService {}}- const keyRow = await vaultCodecExtractEncryptionKeyForPublicKey(rootManifest, encryptionPublicKey);+ const keyRow = await vaultCodecExtractEncryptionKeyForPublicKey(personalManifest, encryptionPublicKey);return typeof keyRow?.PrivateKey === 'string' ? keyRow.PrivateKey : null;}@@ -846,7 +879,7 @@ export class VaultSyncService {/*** Canonicalize the current SQLite vault, validate, encrypt, and POST /v2/Vault. The write is as narrow as* possible: content-fingerprint gating keeps every manifest and bucket whose canonical content still matches- * its last-known server state OUT of the write, so a credential edit uploads the root manifest alone and a+ * its last-known server state OUT of the write, so a credential edit uploads the personal manifest alone and a* shared-manifest edit uploads that manifest alone. Only blobs the server doesn't* already have are encrypted and pre-uploaded (in size-capped batches) before the manifest POST, so a routine* save of a vault with hundreds of attachments uploads kilobytes, not the whole blob set. If the manifest POST@@ -914,10 +947,10 @@ export class VaultSyncService {devLog('[V2Push] Reusing the canonicalize result from the pre-push no-op check.');}const { canonicalized, manifestRecords } = cachedSet ?? await this.canonicalizeVault(sqliteClient);- // Root first by construction (see `resolveManifestRecords`), which is also the order canonicalize requires.- const [rootRecord, ...sharedRecords] = manifestRecords;+ // Personal manifest first by construction (see `resolveManifestRecords`), which is also the order canonicalize requires.+ const [personalRecord, ...sharedRecords] = manifestRecords;const privateEmailDomains = (await getItemWithFallback<string[]>(StorageKeys.PRIVATE_EMAIL_DOMAINS)) ?? [];- const emailRouting = buildEmailRouting(canonicalized.manifests.map(m => m.manifest), rootRecord.manifestId, privateEmailDomains);+ const emailRouting = buildEmailRouting(canonicalized.manifests.map(m => m.manifest), personalRecord.manifestId, privateEmailDomains);/** Debug: manifest-set summary + full unencrypted manifests + data buckets, inspectable in the console.@@ -927,15 +960,15 @@ export class VaultSyncService {devLog(`[V2Push] Canonicalize produced ${canonicalized.manifests.length} manifest(s) + ${canonicalizedBuckets.length} data bucket(s).`);devLog(`[V2Push] Unencrypted data buckets (${canonicalizedBuckets.length}):`, canonicalizedBuckets);for (const { manifest } of canonicalized.manifests) {- const isRoot = manifest.manifestId === rootRecord.manifestId;- devLog(`[V2Push] Unencrypted ${isRoot ? 'root manifest' : `manifest "${manifest.name ?? manifest.manifestId}"`}: tables: ${Object.entries(manifest.tables).map(([t, rows]) => `${t}=${rows.length}`).join(', ')}`, manifest);+ const isPersonal = manifest.manifestId === personalRecord.manifestId;+ devLog(`[V2Push] Unencrypted ${isPersonal ? 'personal manifest' : `manifest "${manifest.name ?? manifest.manifestId}"`}: tables: ${Object.entries(manifest.tables).map(([t, rows]) => `${t}=${rows.length}`).join(', ')}`, manifest);}/** 2) Content-fingerprint gating: compare every canonicalized target (each manifest below, each data bucket)* against the fingerprint of its last-known server state and only write the targets that actually changed. A* missing baseline means "server state unknown" and always writes. Two cases force a blanket write: a KEK/VEK- * migration re-keys the root manifest and all buckets (their ciphertext must be re-encrypted with the new VEK+ * migration re-keys the personal manifest and all buckets (their ciphertext must be re-encrypted with the new VEK* even when the content is unchanged), and forceFullWrite (server rollback recovery) rewrites everything so* the server is restored from the client's state.*/@@ -946,13 +979,13 @@ export class VaultSyncService {* The revision each manifest rebases on, re-read here rather than taken off the records: canonicalize may have* run earlier (the pre-push no-op check caches its result) and a write in between advances them.*/- const currentManifestRevision = await this.currentRootRevision();+ const currentManifestRevision = await this.currentPersonalRevision();const storedSharedRevisions = ((await storage.getItem(StorageKeys.SERVER_MANIFEST_REVISIONS)) as Record<string, number> | null) ?? {};/*** The revision one manifest's write rebases on, falling back to the revision its grant was resolved at.* @param record - the manifest record*/- const revisionOf = (record: ManifestRecord): number => record.isRoot ? currentManifestRevision : storedSharedRevisions[record.manifestId] ?? record.revision;+ const revisionOf = (record: ManifestRecord): number => record.isPersonal ? currentManifestRevision : storedSharedRevisions[record.manifestId] ?? record.revision;/** Every manifest canonicalize produced, joined to its record: one candidate list the whole write is derived@@ -967,9 +1000,9 @@ export class VaultSyncService {}return [{manifestId: record.manifestId,- isRoot: record.isRoot,+ isPersonal: record.isPersonal,manifest,- // Only the root leaves its key open, for the content key resolved above.+ // Only the personal manifest leaves its key open, for the content key resolved above.vek: record.vek ?? contentKey,blobs,currentRevision: revisionOf(record),@@ -983,7 +1016,7 @@ export class VaultSyncService {if (blobEntries.has(hash)) {continue;}- blobEntries.set(hash, { kind: blob.kind as 'favicon' | 'attachment', bytes: VaultCodec.base64ToBytes(blob.bytesBase64), vek: candidate.vek, fromRoot: candidate.isRoot });+ blobEntries.set(hash, { kind: blob.kind as 'favicon' | 'attachment', bytes: VaultCodec.base64ToBytes(blob.bytesBase64), vek: candidate.vek, fromPersonal: candidate.isPersonal });}}@@ -1027,22 +1060,22 @@ export class VaultSyncService {const manifestWrites: ManifestWriteDto[] = [];const writtenManifestFingerprints: Record<string, string> = {};for (const candidate of candidates) {- const label = candidate.isRoot ? 'Root manifest' : `Shared manifest "${candidate.manifest.name ?? candidate.manifestId}"`;+ const label = candidate.isPersonal ? 'Personal manifest' : `Shared manifest "${candidate.manifest.name ?? candidate.manifestId}"`;const plaintext = await timedStage(`stringify-manifest ${candidate.manifestId}`, () => JSON.stringify(candidate.manifest));const fingerprint = await vaultCodecComputeContentFingerprint(plaintext);/*- * A KEK/VEK migration re-keys the root manifest and all buckets (their ciphertext must be re-encrypted with+ * A KEK/VEK migration re-keys the personal manifest and all buckets (their ciphertext must be re-encrypted with* the new VEK even when the content is unchanged) but not the shared manifests, which keep their own VEK.*/- if (!forceFullWrite && !(migrateToVaultKey && candidate.isRoot) && fingerprints[fingerprintManifestKey(candidate.manifestId)] === fingerprint) {+ if (!forceFullWrite && !(migrateToVaultKey && candidate.isPersonal) && fingerprints[fingerprintManifestKey(candidate.manifestId)] === fingerprint) {devLog(`[V2Push] ${label} unchanged versus server baseline, leaving it out of this write.`);continue;}const validation = await timedStage(`validate-manifest ${candidate.manifestId} (incl. JS→Rust conversion)`, () => vaultCodecValidateManifest(candidate.manifest));if (!validation.ok) {- if (candidate.isRoot) {+ if (candidate.isPersonal) {return {status: 'rejected',newManifestRevision: null,@@ -1059,17 +1092,16 @@ export class VaultSyncService {manifestWrites.push({manifestId: candidate.manifestId,- isRoot: candidate.isRoot,manifestBlob: ciphertext,manifestCiphertextHash: ciphertextHash,currentRevision: candidate.currentRevision,credentialsCount: (candidate.manifest.tables.Items ?? []).length,blobReferences: Object.entries(candidate.blobs).map(([hash, blob]) => ({ hash, category: blob.kind })),/*- * Set only on the KEK/VEK migration push, where the server creates the vault key alongside this root revision.- * A migration always forces a root write (see the gate above), so the key can never be stranded without one.+ * Set only on the KEK/VEK migration push, where the server creates the vault key alongside this personal-manifest revision.+ * A migration always forces a personal-manifest write (see the gate above), so the key can never be stranded without one.*/- ...(candidate.isRoot && encryptedVek ? { encryptedVek } : {}),+ ...(candidate.isPersonal && encryptedVek ? { encryptedVek } : {}),});writtenManifestFingerprints[candidate.manifestId] = fingerprint;}@@ -1084,20 +1116,20 @@ export class VaultSyncService {}/*- * 4) Blob diff across the root manifest and every shared manifest in this write: only encrypt + upload blobs the- * server doesn't already have. On a KEK/VEK migration all ROOT blobs are re-encrypted with the new VEK and+ * 4) Blob diff across the personal manifest and every shared manifest in this write: only encrypt + upload blobs the+ * server doesn't already have. On a KEK/VEK migration all personal-manifest blobs are re-encrypted with the new VEK and* overwritten in place; shared-manifest blobs keep their own (unchanged) VEK and only fill genuine gaps.*/const webApi = new WebApiService();- const rootHashes = Array.from(blobEntries).filter(([, entry]) => entry.fromRoot).map(([hash]) => hash);- const sharedHashes = Array.from(blobEntries).filter(([, entry]) => !entry.fromRoot).map(([hash]) => hash);+ const personalHashes = Array.from(blobEntries).filter(([, entry]) => entry.fromPersonal).map(([hash]) => hash);+ const sharedHashes = Array.from(blobEntries).filter(([, entry]) => !entry.fromPersonal).map(([hash]) => hash);const allBlobHashes = Array.from(blobEntries.keys());const knownServerHashes = new Set(((await storage.getItem(StorageKeys.VAULT_SERVER_BLOB_HASHES)) as string[] | null) ?? []);- let rootToUpload: string[] = [];+ let personalToUpload: string[] = [];let sharedToUpload: string[] = [];if (migrateToVaultKey) {- rootToUpload = rootHashes;+ personalToUpload = personalHashes;const sharedCandidates = sharedHashes.filter(h => !knownServerHashes.has(h));if (sharedCandidates.length > 0) {const missingResp = await webApi.post<{ hashes: string[] }, MissingBlobsResponseDto>(BLOBS_MISSING_ENDPOINT, { hashes: sharedCandidates });@@ -1111,14 +1143,14 @@ export class VaultSyncService {toUpload = missingResp.missing ?? [];}const toUploadSet = new Set(toUpload);- rootToUpload = rootHashes.filter(h => toUploadSet.has(h));+ personalToUpload = personalHashes.filter(h => toUploadSet.has(h));sharedToUpload = sharedHashes.filter(h => toUploadSet.has(h));}- devLog(`[V2Push] Blob diff: ${allBlobHashes.length} blobs across ${candidates.length} manifest(s), uploading ${rootToUpload.length} root + ${sharedToUpload.length} shared${migrateToVaultKey ? ' (root re-encrypted, VEK migration)' : ''}.`);+ devLog(`[V2Push] Blob diff: ${allBlobHashes.length} blobs across ${candidates.length} manifest(s), uploading ${personalToUpload.length} personal + ${sharedToUpload.length} shared${migrateToVaultKey ? ' (personal manifest re-encrypted, VEK migration)' : ''}.`);// Pre-upload the missing bytes so the write below carries references only; each staged entry carries its own key.- const uploadedCiphertexts = await this.uploadBlobs(webApi, blobEntries, rootToUpload, migrateToVaultKey);+ const uploadedCiphertexts = await this.uploadBlobs(webApi, blobEntries, personalToUpload, migrateToVaultKey);for (const [hash, ciphertext] of await this.uploadBlobs(webApi, blobEntries, sharedToUpload)) {uploadedCiphertexts.set(hash, ciphertext);}@@ -1177,9 +1209,9 @@ export class VaultSyncService {}devWarn(`[V2Sync] Server reported ${resp.missingBlobHashes.length} missing blob(s); uploading and retrying once.`);- const retriedRoot = await this.uploadBlobs(webApi, blobEntries, resp.missingBlobHashes.filter(h => blobEntries.get(h)?.fromRoot === true), migrateToVaultKey);- const retriedShared = await this.uploadBlobs(webApi, blobEntries, resp.missingBlobHashes.filter(h => blobEntries.get(h)?.fromRoot === false));- for (const [hash, ciphertext] of [...retriedRoot, ...retriedShared]) {+ const retriedPersonal = await this.uploadBlobs(webApi, blobEntries, resp.missingBlobHashes.filter(h => blobEntries.get(h)?.fromPersonal === true), migrateToVaultKey);+ const retriedShared = await this.uploadBlobs(webApi, blobEntries, resp.missingBlobHashes.filter(h => blobEntries.get(h)?.fromPersonal === false));+ for (const [hash, ciphertext] of [...retriedPersonal, ...retriedShared]) {uploadedCiphertexts.set(hash, ciphertext);}@@ -1189,16 +1221,16 @@ export class VaultSyncService {}}- const rootResult = (resp.manifestRevisions ?? []).find(r => r.isRoot);- const newRootRevision = rootResult?.revision ?? currentManifestRevision;+ const personalResult = (resp.manifestRevisions ?? []).find(r => r.manifestId === personalRecord.manifestId);+ const newPersonalRevision = personalResult?.revision ?? currentManifestRevision;if (resp.status !== 0) {// All-or-nothing: a single stale manifest or bucket rejected the whole write; the orchestrator pulls/merges/retries.- return { status: 'outdated', newManifestRevision: newRootRevision };+ return { status: 'outdated', newManifestRevision: newPersonalRevision };}// 5) Update local persisted state on success.- await storage.setItem(StorageKeys.SERVER_REVISION, newRootRevision);+ await storage.setItem(StorageKeys.SERVER_REVISION, newPersonalRevision);for (const br of (resp.bucketRevisions ?? [])) {await storage.setItem(bucketRevisionStorageKey(br.category), br.revision);}@@ -1209,7 +1241,7 @@ export class VaultSyncService {*/const persistedSharedRevisions = ((await storage.getItem(StorageKeys.SERVER_MANIFEST_REVISIONS)) as Record<string, number> | null) ?? {};const sessionShared = await SharingService.getSessionSharedManifests();- const writtenRevisions = new Map((resp.manifestRevisions ?? []).filter(r => !r.isRoot && r.manifestId != null).map(r => [r.manifestId as string, r.revision]));+ const writtenRevisions = new Map((resp.manifestRevisions ?? []).filter(r => r.manifestId !== personalRecord.manifestId).map(r => [r.manifestId, r.revision]));for (const [manifestId, revision] of writtenRevisions) {persistedSharedRevisions[manifestId] = revision;}@@ -1272,7 +1304,7 @@ export class VaultSyncService {const totalChars = manifestChars + bucketChars + uploadedBlobChars;devLog(`[V2Push] Total pushed (encrypted): ${manifestWrites.length} manifest(s) ${formatKb(manifestChars)} + ${bucketDtos.length} buckets ${formatKb(bucketChars)} + ${uploadedCiphertexts.size} blobs ${formatKb(uploadedBlobChars)} = ${formatKb(totalChars)}.`);- return { status: 'ok', newManifestRevision: newRootRevision, newEncryptionKey: migrateToVaultKey ? contentKey : undefined };+ return { status: 'ok', newManifestRevision: newPersonalRevision, newEncryptionKey: migrateToVaultKey ? contentKey : undefined };}/**@@ -1289,7 +1321,7 @@ export class VaultSyncService {const manifestRecords = await this.resolveManifestRecords(sqliteClient);/** Membership is the ManifestId stamp on each row (written by the repositories at insert, move and share time),- * so a spec only has to name the manifest and supply its blob salt. The root goes first: the codec reads the+ * so a spec only has to name the manifest and supply its blob salt. The personal manifest goes first: the codec reads the* first spec as the manifest being written from, which is the routing key every row is matched against and* which keeps any table the registry does not scope per manifest.*/@@ -1410,7 +1442,7 @@ export class VaultSyncService {}/**- * Resolve every manifest this vault can write, root first, as one uniform list.+ * Resolve every manifest this vault can write, personal manifest first, as one uniform list.* @param sqliteClient - the open local vault DB*/private async resolveManifestRecords(sqliteClient: SqliteClient): Promise<ManifestRecord[]> {@@ -1421,14 +1453,14 @@ export class VaultSyncService {}const records: ManifestRecord[] = [{- manifestId: await this.resolveRootManifestId(sqliteClient),- isRoot: true,+ manifestId: await this.resolvePersonalManifestId(sqliteClient),+ isPersonal: true,salt: manifestSalt,folderId: null,vek: null,- revision: await this.currentRootRevision(),+ revision: await this.currentPersonalRevision(),name: null,- // The root's own delivery key is published as the account-level key, not per manifest.+ // The personal manifest's own delivery key is published as the account-level key, not per manifest.canAdminister: false,}];@@ -1439,7 +1471,7 @@ export class VaultSyncService {}records.push({manifestId: record.manifestId,- isRoot: false,+ isPersonal: false,salt: record.salt,folderId: record.folderId,vek: record.vek,@@ -1453,30 +1485,30 @@ export class VaultSyncService {}/**- * The root manifest's last-known server revision. It lives under its own storage key rather than in the- * per-manifest revision map: the server addresses the root by the auth session, never by id.+ * The personal manifest's last-known server revision. It lives under its own storage key rather than in the+ * per-manifest revision map: the server addresses it by the auth session, never by id.*/- private async currentRootRevision(): Promise<number> {+ private async currentPersonalRevision(): Promise<number> {return ((await storage.getItem(StorageKeys.SERVER_REVISION)) as number | null) ?? 0;}/**- * The id of this vault's own (root) manifest. The vault DB's own setting is the durable source (written on each+ * The id of this vault's own (personal) manifest. The vault DB's own setting is the durable source (written on each* materialize); the storage copy covers the one case where no materialize has run yet: the local schema* migration of a legacy sqlite-blob vault, which canonicalizes before it records the setting row.* @param sqliteClient - the open local vault DB*/- private async resolveRootManifestId(sqliteClient: SqliteClient): Promise<string> {- const rootManifestId = sqliteClient.settings.getRootManifestId() ?? ((await storage.getItem(StorageKeys.VAULT_ROOT_MANIFEST_ID)) as string | null);- if (!rootManifestId) {- throw new Error('VaultSyncService: no root manifest id available (no vault setting and no snapshot baseline); pull once before pushing.');+ private async resolvePersonalManifestId(sqliteClient: SqliteClient): Promise<string> {+ const personalManifestId = sqliteClient.settings.getPersonalManifestId() ?? ((await storage.getItem(StorageKeys.VAULT_PERSONAL_MANIFEST_ID)) as string | null);+ if (!personalManifestId) {+ throw new Error('VaultSyncService: no personal manifest id available (no vault setting and no snapshot baseline); pull once before pushing.');}- return rootManifestId;+ return personalManifestId;}/**- * Encrypt the given blobs (each staged with its own VEK: root VEK or a folder VEK) and upload them via- * POST /v2/Vault/blobs in size-capped batches. `overwrite` is set only for root blobs on a KEK/VEK migration;+ * Encrypt the given blobs (each staged with its own VEK: the personal VEK or a folder VEK) and upload them via+ * POST /v2/Vault/blobs in size-capped batches. `overwrite` is set only for personal-manifest blobs on a KEK/VEK migration;* shared-manifest blobs keep their own VEK across a migration, so their ciphertext is never re-keyed.* @param webApi - API client to reuse* @param entries - hash → staged blob for every candidate (hashes without an entry are skipped)diff --git a/apps/browser-extension/src/utils/WebApiService.ts b/apps/browser-extension/src/utils/WebApiService.tsindex 5b4edcb89..7f8937ca5 100644--- a/apps/browser-extension/src/utils/WebApiService.ts+++ b/apps/browser-extension/src/utils/WebApiService.ts@@ -330,6 +330,7 @@ export class WebApiService {clientVersionSupported: true,serverVersion: '0.0.0',manifestRevisions: [],+ personalManifestId: null,srpSalt: ''};}diff --git a/apps/browser-extension/src/utils/constants/storageKeys.ts b/apps/browser-extension/src/utils/constants/storageKeys.tsindex 02200fa79..349187181 100644--- a/apps/browser-extension/src/utils/constants/storageKeys.ts+++ b/apps/browser-extension/src/utils/constants/storageKeys.ts@@ -32,7 +32,7 @@ export const StorageKeys = {/** The encrypted vault blob. */ENCRYPTED_VAULT: 'local:encryptedVault',- /** Revision number of the root manifest as known by the server. */+ /** Revision number of the personal manifest as known by the server. */SERVER_REVISION: 'local:serverRevision',/** Legacy (pre-v0.20) revision key, only read during migration to {@link StorageKeys.SERVER_REVISION}. */LEGACY_VAULT_REVISION_NUMBER: 'local:vaultRevisionNumber',@@ -65,16 +65,17 @@ export const StorageKeys = {IS_OFFLINE_MODE: 'local:isOfflineMode',/** Message of the last failed sync attempt, shown in the UI. */LAST_SYNC_ERROR: 'local:lastSyncError',- /** The client's last known revision per non-root (shared) manifest. */+ /** The client's last known revision per shared manifest. */SERVER_MANIFEST_REVISIONS: 'local:serverManifestRevisions',- /** The root manifest's blob-hashing salt, cached from the last pull; see `CodecManifest.manifestSalt`. */+ /** The personal manifest's blob-hashing salt, cached from the last pull; see `CodecManifest.manifestSalt`. */VAULT_MANIFEST_SALT: 'local:vaultManifestSalt',/**- * The server-side id of the user's root manifest, learned from GET /v2/Vault. Fallback source for+ * The server-side id of the user's personal manifest, learned from GET /v2/Vault. Fallback source for* canonicalize when the vault DB does not record it yet (legacy migration push).*/- VAULT_ROOT_MANIFEST_ID: 'local:vaultRootManifestId',+ VAULT_PERSONAL_MANIFEST_ID: 'local:vaultPersonalManifestId',+/** Content fingerprints of the last pushed manifests and buckets, used for changed-only writes. */VAULT_CONTENT_FINGERPRINTS: 'local:vaultContentFingerprints',/** Local cache of encrypted blobs (hash to base64 AES-GCM ciphertext). Never stores plaintext at rest. */@@ -276,7 +277,7 @@ export const allVaultDataStorageKeys = (): StorageKey[] => [StorageKeys.LEGACY_VAULT_REVISION_NUMBER,StorageKeys.SERVER_MANIFEST_REVISIONS,StorageKeys.VAULT_MANIFEST_SALT,- StorageKeys.VAULT_ROOT_MANIFEST_ID,+ StorageKeys.VAULT_PERSONAL_MANIFEST_ID,StorageKeys.VAULT_CONTENT_FINGERPRINTS,StorageKeys.VAULT_BLOB_CIPHER_CACHE,StorageKeys.VAULT_SERVER_BLOB_HASHES,diff --git a/apps/browser-extension/src/utils/db/BaseRepository.ts b/apps/browser-extension/src/utils/db/BaseRepository.tsindex 14922f48f..6d8b474bf 100644--- a/apps/browser-extension/src/utils/db/BaseRepository.ts+++ b/apps/browser-extension/src/utils/db/BaseRepository.ts@@ -154,7 +154,7 @@ export abstract class BaseRepository {return null;}- const activeId = this.client.getActiveManifestId() ?? this.rootManifestId();+ const activeId = this.client.getActiveManifestId() ?? this.personalManifestId();return (rows.find(row => row.ManifestId === activeId) ?? rows[0]).ManifestId;}@@ -181,7 +181,7 @@ export abstract class BaseRepository {* @returns The manifest id new rows are stamped with*/protected activeManifestId(): string {- const manifestId = this.client.getActiveManifestId() ?? this.rootManifestId();+ const manifestId = this.client.getActiveManifestId() ?? this.personalManifestId();if (!manifestId) {throw new Error('BaseRepository: the vault has no manifest recorded yet (no active manifest and no personal manifest); sync once before writing.');}@@ -192,11 +192,11 @@ export abstract class BaseRepository {* Get the id of the user's personal manifest, as recorded by the last pull.* @returns The personal manifest id, or null when absent*/- protected rootManifestId(): string | null {+ protected personalManifestId(): string | null {if (!this.tableExists('Settings')) {return null;}- const results = this.client.executeQuery<{ Id: string }>(BaseQueries.GET_ROOT_MANIFEST_ID);+ const results = this.client.executeQuery<{ Id: string }>(BaseQueries.GET_PERSONAL_MANIFEST_ID);return results.length > 0 ? results[0].Id : null;}diff --git a/apps/browser-extension/src/utils/db/__tests__/LogoScoping.test.ts b/apps/browser-extension/src/utils/db/__tests__/LogoScoping.test.tsindex a67620be4..6f9f77981 100644--- a/apps/browser-extension/src/utils/db/__tests__/LogoScoping.test.ts+++ b/apps/browser-extension/src/utils/db/__tests__/LogoScoping.test.ts@@ -6,7 +6,7 @@ import { LogoQueries } from '../queries/LogoQueries';import type { Database } from 'sql.js';-const ROOT = 'ROOT-MANIFEST';+const PERSONAL = 'PERSONAL-MANIFEST';const SHARED = 'SHARED-MANIFEST';/**@@ -23,8 +23,8 @@ async function makeDb(): Promise<Database> {CREATE TABLE Logos (ManifestId TEXT NOT NULL, Id TEXT NOT NULL, Kind TEXT NOT NULL DEFAULT 'favicon', Source TEXT NOT NULL, FileData BLOB, MimeType TEXT, Name TEXT, CreatedAt TEXT NOT NULL, UpdatedAt TEXT NOT NULL, IsDeleted INTEGER NOT NULL, PRIMARY KEY (ManifestId, Id));CREATE UNIQUE INDEX IX_Logos_ManifestId_Kind_Source ON Logos (ManifestId, Kind, Source);CREATE TABLE Items (ManifestId TEXT NOT NULL, Id TEXT NOT NULL, LogoId TEXT, FolderId TEXT, IsDeleted INTEGER NOT NULL, PRIMARY KEY (ManifestId, Id));- INSERT INTO Settings VALUES ('RootManifestId', '${ROOT}', 't', 't', 0);- INSERT INTO Folders VALUES ('${SHARED}', 'FOLDER-SHARED', 'Team', NULL), ('${ROOT}', 'FOLDER-MINE', 'Mine', NULL);+ INSERT INTO Settings VALUES ('PersonalManifestId', '${PERSONAL}', 't', 't', 0);+ INSERT INTO Folders VALUES ('${SHARED}', 'FOLDER-SHARED', 'Team', NULL), ('${PERSONAL}', 'FOLDER-MINE', 'Mine', NULL);`);return db;}@@ -50,29 +50,29 @@ function rows(db: Database, sql: string, params: unknown[] = []): Record<string,describe('logo manifest scoping', () => {it('GET_MANIFEST_OF_FOLDER agrees with what an insert would stamp', async () => {const db = await makeDb();- expect(rows(db, BaseQueries.GET_MANIFEST_OF_FOLDER, ['FOLDER-SHARED', ROOT])[0].ManifestId).toBe(SHARED);- expect(rows(db, BaseQueries.GET_MANIFEST_OF_FOLDER, ['FOLDER-MINE', ROOT])[0].ManifestId).toBe(ROOT);- expect(rows(db, BaseQueries.GET_MANIFEST_OF_FOLDER, [null, ROOT])[0].ManifestId).toBe(ROOT);+ expect(rows(db, BaseQueries.GET_MANIFEST_OF_FOLDER, ['FOLDER-SHARED', PERSONAL])[0].ManifestId).toBe(SHARED);+ expect(rows(db, BaseQueries.GET_MANIFEST_OF_FOLDER, ['FOLDER-MINE', PERSONAL])[0].ManifestId).toBe(PERSONAL);+ expect(rows(db, BaseQueries.GET_MANIFEST_OF_FOLDER, [null, PERSONAL])[0].ManifestId).toBe(PERSONAL);expect(rows(db, BaseQueries.GET_MANIFEST_OF_FOLDER, [null, SHARED])[0].ManifestId).toBe(SHARED);});it('GET_BEST_FOR_KEY prefers the copy that actually carries bytes', async () => {const db = await makeDb();db.run(`INSERT INTO Logos VALUES ('${SHARED}','L-SHARED','favicon','github.com',NULL,NULL,'empty','t','2026-01-02',0)`);- db.run(`INSERT INTO Logos VALUES ('${ROOT}','L-ROOT','favicon','github.com',X'0102',NULL,'real','t','2026-01-01',0)`);+ db.run(`INSERT INTO Logos VALUES ('${PERSONAL}','L-PERSONAL','favicon','github.com',X'0102',NULL,'real','t','2026-01-01',0)`);expect(rows(db, LogoQueries.GET_BEST_FOR_KEY, ['favicon', 'github.com'])[0].Name).toBe('real');});it('finds an item whose logo lives in another manifest, and only that item', async () => {const db = await makeDb();- db.run(`INSERT INTO Logos VALUES ('${ROOT}','L-ROOT','favicon','github.com',X'0102',NULL,NULL,'t','t',0)`);+ db.run(`INSERT INTO Logos VALUES ('${PERSONAL}','L-PERSONAL','favicon','github.com',X'0102',NULL,NULL,'t','t',0)`);db.run(`INSERT INTO Logos VALUES ('${SHARED}','L-SHARED','favicon','gitlab.com',X'0304',NULL,NULL,'t','t',0)`);// Moved into the shared folder by a restamp, still pointing at the personal logo row.- db.run(`INSERT INTO Items VALUES ('${SHARED}','ITEM-MOVED','L-ROOT','FOLDER-SHARED',0)`);+ db.run(`INSERT INTO Items VALUES ('${SHARED}','ITEM-MOVED','L-PERSONAL','FOLDER-SHARED',0)`);// Correctly scoped rows of both kinds, plus one with no logo at all.- db.run(`INSERT INTO Items VALUES ('${ROOT}','ITEM-MINE','L-ROOT','FOLDER-MINE',0)`);+ db.run(`INSERT INTO Items VALUES ('${PERSONAL}','ITEM-MINE','L-PERSONAL','FOLDER-MINE',0)`);db.run(`INSERT INTO Items VALUES ('${SHARED}','ITEM-THEIRS','L-SHARED','FOLDER-SHARED',0)`);- db.run(`INSERT INTO Items VALUES ('${ROOT}','ITEM-BARE',NULL,NULL,0)`);+ db.run(`INSERT INTO Items VALUES ('${PERSONAL}','ITEM-BARE',NULL,NULL,0)`);const found = rows(db, LogoQueries.FIND_ITEMS_WITH_FOREIGN_LOGO);expect(found).toEqual([{ Id: 'ITEM-MOVED', ManifestId: SHARED, Kind: 'favicon', Source: 'github.com' }]);@@ -80,9 +80,9 @@ describe('logo manifest scoping', () => {it('repointing clears the defect and leaves the origin manifest its own copy', async () => {const db = await makeDb();- db.run(`INSERT INTO Logos VALUES ('${ROOT}','L-ROOT','favicon','github.com',X'0102',NULL,NULL,'t','t',0)`);- db.run(`INSERT INTO Items VALUES ('${SHARED}','ITEM-MOVED','L-ROOT','FOLDER-SHARED',0)`);- db.run(`INSERT INTO Items VALUES ('${ROOT}','ITEM-MINE','L-ROOT','FOLDER-MINE',0)`);+ db.run(`INSERT INTO Logos VALUES ('${PERSONAL}','L-PERSONAL','favicon','github.com',X'0102',NULL,NULL,'t','t',0)`);+ db.run(`INSERT INTO Items VALUES ('${SHARED}','ITEM-MOVED','L-PERSONAL','FOLDER-SHARED',0)`);+ db.run(`INSERT INTO Items VALUES ('${PERSONAL}','ITEM-MINE','L-PERSONAL','FOLDER-MINE',0)`);// What adoptIntoScope does: clone under the target manifest's own derived id, then repoint.const clonedId = 'L-SHARED-DERIVED';@@ -91,15 +91,15 @@ describe('logo manifest scoping', () => {expect(rows(db, LogoQueries.FIND_ITEMS_WITH_FOREIGN_LOGO)).toEqual([]);// The personal item is untouched and its own copy still exists.- expect(rows(db, `SELECT LogoId FROM Items WHERE Id = 'ITEM-MINE'`)[0].LogoId).toBe('L-ROOT');- expect(rows(db, LogoQueries.GET_ID_FOR_KEY, [ROOT, 'favicon', 'github.com'])[0].Id).toBe('L-ROOT');+ expect(rows(db, `SELECT LogoId FROM Items WHERE Id = 'ITEM-MINE'`)[0].LogoId).toBe('L-PERSONAL');+ expect(rows(db, LogoQueries.GET_ID_FOR_KEY, [PERSONAL, 'favicon', 'github.com'])[0].Id).toBe('L-PERSONAL');});it('GET_ID_FOR_KEY will not hand one manifest another manifest row', async () => {const db = await makeDb();- db.run(`INSERT INTO Logos VALUES ('${ROOT}','L-ROOT','custom','hash-abc',X'0102',NULL,NULL,'t','t',0)`);+ db.run(`INSERT INTO Logos VALUES ('${PERSONAL}','L-PERSONAL','custom','hash-abc',X'0102',NULL,NULL,'t','t',0)`);expect(rows(db, LogoQueries.GET_ID_FOR_KEY, [SHARED, 'custom', 'hash-abc'])).toEqual([]);// ...but the vault-wide probe still sees it, which is what lets the copy-on-use path find the bytes.- expect(rows(db, LogoQueries.FIND_ANY_ID_FOR_KEY, ['custom', 'hash-abc'])[0].Id).toBe('L-ROOT');+ expect(rows(db, LogoQueries.FIND_ANY_ID_FOR_KEY, ['custom', 'hash-abc'])[0].Id).toBe('L-PERSONAL');});});diff --git a/apps/browser-extension/src/utils/db/queries/BaseQueries.ts b/apps/browser-extension/src/utils/db/queries/BaseQueries.tsindex 42b5e0b01..36b41316f 100644--- a/apps/browser-extension/src/utils/db/queries/BaseQueries.ts+++ b/apps/browser-extension/src/utils/db/queries/BaseQueries.ts@@ -10,14 +10,15 @@ export class BaseQueries {* of the vault. The codec treats every manifest alike and a user may own several; which of them is* *this* client's home is the client's own state, told to it by the server on each pull.*/- public static readonly ROOT_MANIFEST_SETTING_KEY = 'RootManifestId';+ public static readonly PERSONAL_MANIFEST_SETTING_KEY = 'PersonalManifestId';/*** The vault's personal manifest id, written by the sync service from what the server reports on each* pull. It is the default the active manifest falls back to.*/- public static readonly GET_ROOT_MANIFEST_ID = `- SELECT Value AS Id FROM Settings WHERE Key = '${BaseQueries.ROOT_MANIFEST_SETTING_KEY}' AND IsDeleted = 0 LIMIT 1`;+ public static readonly GET_PERSONAL_MANIFEST_ID = `+ SELECT Value AS Id FROM Settings+ WHERE Key = '${BaseQueries.PERSONAL_MANIFEST_SETTING_KEY}' AND IsDeleted = 0 LIMIT 1`;/*** SQL fragment resolving the manifest a row placed in the folder bound to its first `?` (possibly@@ -55,7 +56,7 @@ export class BaseQueries {/*** 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 root manifest).+ * removed (the subtree returns to the personal manifest).*/public static readonly RESTAMP_SUBTREE_FOLDERS = `UPDATE Folders SET ManifestId = ?diff --git a/apps/browser-extension/src/utils/db/repositories/FolderRepository.ts b/apps/browser-extension/src/utils/db/repositories/FolderRepository.tsindex e748d1e17..245119355 100644--- a/apps/browser-extension/src/utils/db/repositories/FolderRepository.ts+++ b/apps/browser-extension/src/utils/db/repositories/FolderRepository.ts@@ -250,13 +250,13 @@ export class FolderRepository extends BaseRepository {}/**- * Re-stamp a folder's whole subtree back into the vault's own (root) manifest.+ * Re-stamp a folder's whole subtree back into the vault's own (personal) manifest.* @param folderId - The root of the subtree to re-stamp- * @returns The number of rows re-stamped, or 0 when the root manifest is not registered yet+ * @returns The number of rows re-stamped, or 0 when the personal manifest is not registered yet*/- public async restampSubtreeToRoot(folderId: string): Promise<number> {- const rootId = this.rootManifestId();- return rootId ? this.restampSubtree(folderId, rootId) : 0;+ public async restampSubtreeToPersonal(folderId: string): Promise<number> {+ const personalId = this.personalManifestId();+ return personalId ? this.restampSubtree(folderId, personalId) : 0;}/**diff --git a/apps/browser-extension/src/utils/db/repositories/LogoRepository.ts b/apps/browser-extension/src/utils/db/repositories/LogoRepository.tsindex 8b54e272b..ca2673025 100644--- a/apps/browser-extension/src/utils/db/repositories/LogoRepository.ts+++ b/apps/browser-extension/src/utils/db/repositories/LogoRepository.ts@@ -27,7 +27,7 @@ export class LogoRepository extends BaseRepository {* @returns The manifest id, or the empty scope when it is not known yet*/private ownScope(): string {- return this.rootManifestId() ?? '';+ return this.personalManifestId() ?? '';}/**diff --git a/apps/browser-extension/src/utils/db/repositories/SettingsRepository.ts b/apps/browser-extension/src/utils/db/repositories/SettingsRepository.tsindex d66bd5488..9d2d70684 100644--- a/apps/browser-extension/src/utils/db/repositories/SettingsRepository.ts+++ b/apps/browser-extension/src/utils/db/repositories/SettingsRepository.ts@@ -98,7 +98,7 @@ export class SettingsRepository extends BaseRepository {}/**- * Fetch every keypair that can decrypt inbound mail (both root manifest and optional shared manifest keys).+ * Fetch every keypair that can decrypt inbound mail (both personal manifest and optional shared manifest keys).* @returns Array of encryption keys*/public getAllEncryptionKeys(): EncryptionKey[] {@@ -106,11 +106,11 @@ export class SettingsRepository extends BaseRepository {}/**- * Get the id of the root/default manifest.- * @returns The root manifest id, or null when not known yet+ * Get the id of the vault's own (personal) manifest.+ * @returns The personal manifest id, or null when not known yet*/- public getRootManifestId(): string | null {- return this.rootManifestId();+ public getPersonalManifestId(): string | null {+ return this.personalManifestId();}/**@@ -118,8 +118,8 @@ export class SettingsRepository extends BaseRepository {* @returns The active personal keypair, or null when absent*/public getPrimaryEncryptionKey(): EncryptionKey | null {- const rootManifestId = this.rootManifestId();- return rootManifestId ? this.getActiveManifestEncryptionKey(rootManifestId) : null;+ const personalManifestId = this.personalManifestId();+ return personalManifestId ? this.getActiveManifestEncryptionKey(personalManifestId) : null;}/**@@ -156,18 +156,18 @@ export class SettingsRepository extends BaseRepository {* @param privateKey - The private half*/public retainNonPrimaryEncryptionKey(publicKey: string, privateKey: string): void {- const rootManifestId = this.rootManifestId();- if (!rootManifestId) {+ const personalManifestId = this.personalManifestId();+ if (!personalManifestId) {return;}- const existing = this.client.executeQuery<{ count: number }>(EncryptionKeyQueries.COUNT_BY_PUBLIC_KEY, [rootManifestId, publicKey]);+ 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(), rootManifestId, publicKey, privateKey, now, now]);+ this.client.executeUpdate(EncryptionKeyQueries.INSERT_NON_PRIMARY, [this.generateId(), personalManifestId, publicKey, privateKey, now, now]);}/**diff --git a/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts b/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.tsindex d30760d24..36fd84d78 100644--- a/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts+++ b/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts@@ -73,7 +73,6 @@ type StatusResponse = {*/type ManifestRevision = {manifestId: string;- isRoot: boolean;revision: number;};/**@@ -83,6 +82,7 @@ type StatusResponseV2 = {clientVersionSupported: boolean;serverVersion: string;manifestRevisions: ManifestRevision[];+ personalManifestId: string | null;srpSalt: string;};diff --git a/apps/browser-extension/tests/e2e/13-forward-compat-overflow.spec.ts b/apps/browser-extension/tests/e2e/13-forward-compat-overflow.spec.tsindex dbc9b9c01..d47cc8d46 100644--- a/apps/browser-extension/tests/e2e/13-forward-compat-overflow.spec.ts+++ b/apps/browser-extension/tests/e2e/13-forward-compat-overflow.spec.ts@@ -16,7 +16,7 @@* 5. The newer client pulls again — the rename is applied AND the unknown column/table are intact*/import { test, expect, TestClient, FieldSelectors } from '../fixtures';-import { getVaultSnapshot, openManifest, pushManifest, pollUntil, requireRootManifest, type DecryptedManifest } from '../helpers/manifest-v2-api';+import { getVaultSnapshot, openManifest, pushManifest, pollUntil, requirePersonalManifest, type DecryptedManifest } from '../helpers/manifest-v2-api';import type { TestUser } from '../helpers/test-api';test.describe.serial('13. Forward-compat overflow', () => {@@ -58,7 +58,7 @@ test.describe.serial('13. Forward-compat overflow', () => {test('13.2 a newer client should inject an unknown column and table into the server manifest', async () => {const token = user.token!.token;- const { manifest, root } = await openLatestManifest(baseApiUrl, token, user.encryptionKey!);+ const { manifest, personal } = await openLatestManifest(baseApiUrl, token, user.encryptionKey!);// Simulate a newer client's schema additions: a column this extension build doesn't know on an// existing row, and a whole table it doesn't know at all.@@ -67,8 +67,8 @@ test.describe.serial('13. Forward-compat overflow', () => {item!.AliasEnabled = true;manifest.tables.FutureFeatures = [futureTableRow];- injectedRevision = await pushManifest(baseApiUrl, token, user.username, manifest, root.revision, root.blobReferences, user.encryptionKey!);- expect(injectedRevision).toBeGreaterThan(root.revision);+ injectedRevision = await pushManifest(baseApiUrl, token, user.username, personal.manifestId, manifest, personal.revision, personal.blobReferences, user.encryptionKey!);+ expect(injectedRevision).toBeGreaterThan(personal.revision);});test('13.3 extension should load the newer manifest without crashing', async () => {@@ -93,9 +93,9 @@ test.describe.serial('13. Forward-compat overflow', () => {test('13.5 the newer client data should survive the extension push (no data loss)', async () => {// Wait for the extension's push to land: a revision beyond the injected one, carrying the rename.const manifest = await pollUntil(async (): Promise<DecryptedManifest | undefined> => {- const { manifest: m, root } = await openLatestManifest(baseApiUrl, user.token!.token, user.encryptionKey!);+ const { manifest: m, personal } = await openLatestManifest(baseApiUrl, user.token!.token, user.encryptionKey!);const renamed = (m.tables.Items ?? []).some((row) => row.Name === renamedCredentialName);- return root.revision > injectedRevision && renamed ? m : undefined;+ return personal.revision > injectedRevision && renamed ? m : undefined;});// The unknown column re-attached to the row the extension itself rewrote (rename bumps the row).@@ -109,17 +109,17 @@ test.describe.serial('13. Forward-compat overflow', () => {});/**- * Polls until the server snapshot is manifest-v1, then decrypts and returns its root manifest.+ * Polls until the server snapshot is manifest-v1, then decrypts and returns its personal manifest.** @param apiUrl - The base URL of the API* @param token - Bearer token* @param encryptionKey - The user's derived vault encryption key* @returns The decrypted manifest and its snapshot entry*/-async function openLatestManifest(apiUrl: string, token: string, encryptionKey: Uint8Array): Promise<{ manifest: DecryptedManifest; root: ReturnType<typeof requireRootManifest> }> {+async function openLatestManifest(apiUrl: string, token: string, encryptionKey: Uint8Array): Promise<{ manifest: DecryptedManifest; personal: ReturnType<typeof requirePersonalManifest> }> {return pollUntil(async () => {const snapshot = await getVaultSnapshot(apiUrl, token);- const root = requireRootManifest(snapshot);- return { manifest: await openManifest(root.blob, encryptionKey), root };+ const personal = requirePersonalManifest(snapshot);+ return { manifest: await openManifest(personal.blob, encryptionKey), personal };});}diff --git a/apps/browser-extension/tests/helpers/manifest-v2-api.ts b/apps/browser-extension/tests/helpers/manifest-v2-api.tsindex 971524f73..72a4b28a9 100644--- a/apps/browser-extension/tests/helpers/manifest-v2-api.ts+++ b/apps/browser-extension/tests/helpers/manifest-v2-api.ts@@ -2,7 +2,7 @@* Node-side manifest-v1 vault client for E2E tests.** Lets a test act as a second, "newer" client against the v2 Vault API: pull the snapshot,- * decrypt + unpack the root manifest, modify it (e.g. inject columns/tables an older client's+ * decrypt + unpack the personal manifest, modify it (e.g. inject columns/tables an older client's* schema doesn't know), and push it back as a new revision. Pack/unpack goes through the real* Rust WASM codec so the integrity envelope's canonical content hash matches exactly what the* extension verifies on pull.@@ -19,7 +19,6 @@ import { normalizeUsername, symmetricDecryptBytes, symmetricEncryptBytes } from/** One manifest entry in the v2 GET snapshot. */export type SnapshotManifest = {manifestId: string;- isRoot: boolean;blob: string;ciphertextHash: string;revision: number;@@ -32,6 +31,8 @@ export type VaultSnapshot = {/** Server StorageFormat enum: 0 = legacy sqlite-blob, 1 = manifest-v1. */storageFormat: number;manifests?: SnapshotManifest[];+ /** The manifest owned by the caller's personal group; every other entry is a shared one. */+ personalManifestId?: string | null;buckets?: Array<{ category: string; blob: string; ciphertextHash: string; revision: number }>;};@@ -76,17 +77,17 @@ export async function getVaultSnapshot(apiBaseUrl: string, token: string): Promi}/**- * Returns the root manifest entry of a snapshot, or throws if the user isn't on manifest-v1 yet.+ * Returns the personal manifest entry of a snapshot, or throws if the user isn't on manifest-v1 yet.** @param snapshot - The v2 snapshot- * @returns The root manifest entry+ * @returns The personal manifest entry*/-export function requireRootManifest(snapshot: VaultSnapshot): SnapshotManifest {- const root = (snapshot.manifests ?? []).find((m) => m.isRoot);- if (snapshot.storageFormat !== 1 || !root?.blob) {+export function requirePersonalManifest(snapshot: VaultSnapshot): SnapshotManifest {+ const personal = (snapshot.manifests ?? []).find((m) => m.manifestId === snapshot.personalManifestId);+ if (snapshot.storageFormat !== 1 || !personal?.blob) {throw new Error(`Snapshot is not manifest-v1 yet (storageFormat=${snapshot.storageFormat}, manifests=${snapshot.manifests?.length ?? 0}).`);}- return root;+ return personal;}/**@@ -110,6 +111,7 @@ export async function openManifest(blobBase64: string, encryptionKey: Uint8Array* @param token - Bearer token* @param username - The vault owner's username* @param manifest - The (modified) manifest object to upload+ * @param manifestId - The manifest this write targets* @param currentRevision - The revision this upload is based on (server assigns currentRevision + 1)* @param blobReferences - Blob references to carry over to the new revision* @param encryptionKey - The user's derived vault encryption key@@ -119,6 +121,7 @@ export async function pushManifest(apiBaseUrl: string,token: string,username: string,+ manifestId: string,manifest: DecryptedManifest,currentRevision: number,blobReferences: Array<{ hash: string; category: string }>,@@ -129,15 +132,22 @@ export async function pushManifest(const manifestBlob = await symmetricEncryptBytes(packedBytes, encryptionKey);const manifestCiphertextHash = createHash('sha256').update(Buffer.from(manifestBlob, 'base64')).digest('hex');+ /*+ * POST /v2/Vault is one atomic write over a list of manifests; every entry names the manifest it targets, so this+ * simulated "newer client" addresses the personal manifest by id exactly as a real client does.+ */const payload = {username: normalizeUsername(username),- manifestBlob,- manifestCiphertextHash,- currentManifestRevision: currentRevision,- credentialsCount: (manifest.tables.Items ?? []).length,+ manifests: [{+ manifestId,+ manifestBlob,+ manifestCiphertextHash,+ currentRevision,+ credentialsCount: (manifest.tables.Items ?? []).length,+ blobReferences,+ }],buckets: [],newBlobs: [],- blobReferences,emailRouting: { emailAddressList: [] },userEncryptionPublicKey: '',};@@ -151,11 +161,20 @@ export async function pushManifest(throw new Error(`POST /v2/Vault failed with status ${response.status}: ${await response.text()}`);}- const result = (await response.json()) as { status: number; newManifestRevision: number; missingBlobHashes?: string[] };+ const result = (await response.json()) as {+ status: number;+ manifestRevisions?: Array<{ manifestId: string; revision: number }>;+ missingBlobHashes?: string[];+ };if (result.status !== 0 || (result.missingBlobHashes?.length ?? 0) > 0) {throw new Error(`Manifest push rejected: status=${result.status}, missingBlobs=${result.missingBlobHashes?.join(',') ?? 'none'}`);}- return result.newManifestRevision;++ const written = (result.manifestRevisions ?? []).find((r) => r.manifestId === manifestId);+ if (!written) {+ throw new Error(`Manifest push returned no revision for ${manifestId}.`);+ }+ return written.revision;}/**diff --git a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razorindex fc8d04ccb..63409973c 100644--- a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor+++ b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor@@ -387,7 +387,6 @@ elsevar currentManifests = await dbContext.VaultManifests.Where(x => x.OwnerGroupId == User.PersonalGroupId).Select(x => new VaultManifest{ManifestId = x.ManifestId,- IsRoot = x.IsRoot,StorageFormat = x.StorageFormat,Version = x.Version,RevisionNumber = x.RevisionNumber,diff --git a/apps/server/AliasVault.Api/Controllers/V1/AuthController.cs b/apps/server/AliasVault.Api/Controllers/V1/AuthController.csindex f759ccaf5..59e6b265f 100644--- a/apps/server/AliasVault.Api/Controllers/V1/AuthController.cs+++ b/apps/server/AliasVault.Api/Controllers/V1/AuthController.cs@@ -97,7 +97,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM// Get latest vault revision number and salt.await using var context = await dbContextFactory.CreateDbContextAsync();var latestVault = await context.VaultManifests- .Where(x => x.IsRoot && x.OwnerGroupId == user.PersonalGroupId)+ .Where(x => x.OwnerGroupId == user.PersonalGroupId).Select(x => new { x.RevisionNumber, x.Salt }).FirstOrDefaultAsync();diff --git a/apps/server/AliasVault.Api/Controllers/V1/Tests/TestController.cs b/apps/server/AliasVault.Api/Controllers/V1/Tests/TestController.csindex 9697d6faa..facba2362 100644--- a/apps/server/AliasVault.Api/Controllers/V1/Tests/TestController.cs+++ b/apps/server/AliasVault.Api/Controllers/V1/Tests/TestController.cs@@ -421,13 +421,13 @@ public class TestController(}/// <summary>- /// Builds the revision info payload for a user: the current revision of the root manifest plus all history+ /// Builds the revision info payload for a user: the current revision of the personal manifest plus all history/// revisions, newest first./// </summary>private static async Task<object> BuildRevisionInfoAsync(AliasServerDbContext context, string userId){var current = await context.VaultManifests- .Where(v => v.IsRoot && context.AliasVaultUsers.Any(u => u.Id == userId && u.PersonalGroupId == v.OwnerGroupId))+ .Where(v => context.AliasVaultUsers.Any(u => u.Id == userId && u.PersonalGroupId == v.OwnerGroupId)).Select(v => new { v.RevisionNumber, v.CreatedAt, v.UpdatedAt }).FirstOrDefaultAsync();@@ -454,14 +454,14 @@ public class TestController(}/// <summary>- /// Deletes the newest <paramref name="count"/> revisions of the user's root manifest by rolling the current row+ /// Deletes the newest <paramref name="count"/> revisions of the user's personal manifest by rolling the current row/// back to the newest history revision each time (the inverse of the archive-then-update upload flow). When no/// history remains, the manifest row itself is deleted. Returns the revision numbers that were discarded./// </summary>private static async Task<List<long>> PopNewestRevisionsAsync(AliasServerDbContext context, string userId, int count){var deletedRevisions = new List<long>();- var current = await context.VaultManifests.FirstOrDefaultAsync(v => v.IsRoot && context.AliasVaultUsers.Any(u => u.Id == userId && u.PersonalGroupId == v.OwnerGroupId));+ var current = await context.VaultManifests.FirstOrDefaultAsync(v => context.AliasVaultUsers.Any(u => u.Id == userId && u.PersonalGroupId == v.OwnerGroupId));for (var i = 0; i < count && current != null; i++){diff --git a/apps/server/AliasVault.Api/Controllers/V1/VaultController.cs b/apps/server/AliasVault.Api/Controllers/V1/VaultController.csindex 5d8e33900..1794bd488 100644--- a/apps/server/AliasVault.Api/Controllers/V1/VaultController.cs+++ b/apps/server/AliasVault.Api/Controllers/V1/VaultController.cs@@ -81,8 +81,8 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbContreturn UpgradeRequired();}- // Logic to retrieve vault for the user: the current revision of the user's root manifest.- var vault = await context.VaultManifests.FirstOrDefaultAsync(x => x.IsRoot && x.OwnerGroupId == user.PersonalGroupId);+ // Logic to retrieve vault for the user: the current revision of the user's personal manifest.+ var vault = await context.VaultManifests.FirstOrDefaultAsync(x => x.OwnerGroupId == user.PersonalGroupId);// If no vault is found on server, return an empty object. This means the client will use an empty vault// as starting point.@@ -163,8 +163,8 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbContreturn BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.USERNAME_MISMATCH, 400));}- // Retrieve the current revision of the user's root manifest, which contains the current encryption settings.- var currentManifest = await context.VaultManifests.FirstAsync(x => x.IsRoot && x.OwnerGroupId == user.PersonalGroupId);+ // Retrieve the current revision of the user's personal manifest, which contains the current encryption settings.+ var currentManifest = await context.VaultManifests.FirstAsync(x => x.OwnerGroupId == user.PersonalGroupId);// Reject vaults with a version that is lower than the last vault version.if (VersionHelper.IsVersionOlder(model.Version, currentManifest.Version ?? string.Empty))@@ -209,7 +209,7 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbContawait UpdateEmailClaims(context, user, currentManifest.ManifestId, model.EmailAddressList);}- // Sync user public key if supplied, scoped to the root manifest (every key row is manifest-scoped).+ // Sync user public key if supplied, scoped to the personal manifest (every key row is manifest-scoped).if (!string.IsNullOrEmpty(model.EncryptionPublicKey)){await UpdateUserPublicKey(context, currentManifest.ManifestId, model.EncryptionPublicKey);@@ -264,7 +264,7 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbCont// Check if the provided revision number is equal to the latest revision number.// If not, then the client is trying to update an older vault which we don't allow to prevent data loss.- var currentManifest = await context.VaultManifests.FirstAsync(x => x.IsRoot && x.OwnerGroupId == user.PersonalGroupId);+ var currentManifest = await context.VaultManifests.FirstAsync(x => x.OwnerGroupId == user.PersonalGroupId);if (VersionHelper.IsVersionOlder(model.Version, currentManifest.Version ?? string.Empty)){return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.VAULT_NOT_UP_TO_DATE, 400));@@ -394,18 +394,18 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbCont/// </summary>/// <param name="context">The database context.</param>/// <param name="user">The user object.</param>- /// <param name="rootManifestId">The caller's root manifest, which every claim is filed against.</param>+ /// <param name="personalManifestId">The caller's personal manifest, which every claim is filed against.</param>/// <param name="newEmailAddresses">The list of new email addresses to claim.</param>/// <returns>A task representing the asynchronous operation.</returns>- private async Task UpdateEmailClaims(AliasServerDbContext context, AliasVaultUser user, Guid rootManifestId, List<string> newEmailAddresses)+ private async Task UpdateEmailClaims(AliasServerDbContext context, AliasVaultUser user, Guid personalManifestId, List<string> newEmailAddresses){// Deduplicate email addresses to prevent unique constraint violations when// multiple credentials share the same private email address.newEmailAddresses = newEmailAddresses.Select(EmailHelper.SanitizeEmail).Distinct().ToList();- // Get list of email claims owned by the user (v1 only supports personal claims in the root manifest).+ // Get list of email claims owned by the user (v1 only supports personal claims in the personal manifest).var userOwnedEmailClaims = await context.EmailClaims- .Where(x => x.VaultManifestId == rootManifestId)+ .Where(x => x.VaultManifestId == personalManifestId).ToListAsync();// Keep track of processed and sanitized email addresses to know which ones still exist.@@ -414,7 +414,7 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbCont// Get list of supported private domains from configvar supportedPrivateDomains = config.PrivateEmailDomains;- // Resolve the alias creation limits for the caller's personal group: v1 only files claims in the root manifest,+ // Resolve the alias creation limits for the caller's personal group: v1 only files claims in the personal manifest,// which that group owns, so it is the only quota subject a v1 push can charge.var personalGroup = await context.Groups.FirstAsync(g => g.Id == user.PersonalGroupId);var rateLimits = await rateLimitService.GetLimitsAsync(personalGroup, RateLimitType.AliasCreation);@@ -507,7 +507,7 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbCont{context.EmailClaims.Add(new EmailClaim{- VaultManifestId = rootManifestId,+ VaultManifestId = personalManifestId,Address = sanitizedEmail,AddressLocal = sanitizedEmail.Split('@')[0],AddressDomain = sanitizedEmail.Split('@')[1],@@ -544,13 +544,13 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbCont/// Updates the user's public key based on the provided public key. If it already exists, do nothing./// </summary>/// <param name="context">The database context.</param>- /// <param name="rootManifestId">The caller's root manifest, which their personal keys are scoped to.</param>+ /// <param name="personalManifestId">The caller's personal manifest, which their personal keys are scoped to.</param>/// <param name="newPublicKey">The new public key to sync and set as default.</param>/// <returns>A task representing the asynchronous operation.</returns>- private async Task UpdateUserPublicKey(AliasServerDbContext context, Guid rootManifestId, string newPublicKey)+ private async Task UpdateUserPublicKey(AliasServerDbContext context, Guid personalManifestId, string newPublicKey){var publicKeyExists = await context.VaultManifestDeliveryKeys- .AnyAsync(x => x.VaultManifestId == rootManifestId && x.IsPrimary && x.PublicKey == newPublicKey);+ .AnyAsync(x => x.VaultManifestId == personalManifestId && x.IsPrimary && x.PublicKey == newPublicKey);// If the public key already exists and is marked as primary (default), do nothing.if (publicKeyExists)@@ -560,7 +560,7 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbCont// Update all existing personal keys to not be primary.var otherKeys = await context.VaultManifestDeliveryKeys- .Where(x => x.VaultManifestId == rootManifestId)+ .Where(x => x.VaultManifestId == personalManifestId).ToListAsync();foreach (var key in otherKeys)@@ -583,7 +583,7 @@ public class VaultController(ILogger<VaultController> logger, IAliasServerDbCont// Public key is new, so create it.var newPublicKeyEntry = new VaultManifestDeliveryKey{- VaultManifestId = rootManifestId,+ VaultManifestId = personalManifestId,PublicKey = newPublicKey,IsPrimary = true,CreatedAt = timeProvider.UtcNow,diff --git a/apps/server/AliasVault.Api/Controllers/V2/AuthController.cs b/apps/server/AliasVault.Api/Controllers/V2/AuthController.csindex fa8a3aeeb..ab7029678 100644--- a/apps/server/AliasVault.Api/Controllers/V2/AuthController.cs+++ b/apps/server/AliasVault.Api/Controllers/V2/AuthController.cs@@ -434,7 +434,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserMreturn BadRequest(ServerValidationErrorResponse.Create(["Account key registration requires encryptedAccountKey, encryptedVek, accountPublicKey and encryptedAccountPrivateKey."], 400));}- var rootManifestId = Guid.NewGuid();+ var personalManifestId = Guid.NewGuid();// Create the personal group before the user row.var personalGroup = GroupHelper.CreatePersonalGroup(user, timeProvider.UtcNow);@@ -448,15 +448,14 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserMif (result.Succeeded){- // Create the owner membership and root manifest.+ // Create the owner membership and personal manifest.await using (var context = await dbContextFactory.CreateDbContextAsync()){context.GroupMembers.Add(GroupHelper.CreateOwnerMembership(personalGroup, user.Id, timeProvider.UtcNow));context.VaultManifests.Add(new AliasServerDb.VaultManifest{- ManifestId = rootManifestId,- IsRoot = true,+ ManifestId = personalManifestId,OwnerGroupId = personalGroup.Id,StorageFormat = "sqlite-blob",Version = "0.0.0",@@ -505,7 +504,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM{Id = Guid.NewGuid(),UserId = user.Id,- VaultManifestId = rootManifestId,+ VaultManifestId = personalManifestId,Type = ManifestKeyType.AccountKey,Algorithm = VaultKeyAlgorithm.Aes256Gcm,EncryptedVek = model.EncryptedVek!,diff --git a/apps/server/AliasVault.Api/Controllers/V2/StatusController.cs b/apps/server/AliasVault.Api/Controllers/V2/StatusController.csindex c3578ce01..5113027b0 100644--- a/apps/server/AliasVault.Api/Controllers/V2/StatusController.cs+++ b/apps/server/AliasVault.Api/Controllers/V2/StatusController.cs@@ -51,8 +51,10 @@ public class StatusController(IAliasServerDbContextFactory dbContextFactory, Useawait using var context = await dbContextFactory.CreateDbContextAsync();- // Manifest revisions for every manifest this user can access, built via the shared helper.+ // Manifest revisions for every manifest this user can access, built via the shared helper, plus which of them+ // is their own: the client needs the id to tell its personal vault from the shared ones it syncs alongside.var manifestRevisions = await VaultStatusHelper.GetManifestRevisionsAsync(context, user.Id);+ var personalManifestId = await GroupHelper.GetPersonalManifestIdAsync(context, user.PersonalGroupId);// Latest revision per bucket kind.var bucketRevisions = await context.VaultDataBuckets@@ -61,7 +63,7 @@ public class StatusController(IAliasServerDbContextFactory dbContextFactory, Use.Select(g => new BucketRevision { Category = g.Key, Revision = g.Max(b => b.RevisionNumber) }).ToListAsync();- // Current SRP salt: lives on the password VaultManifestAccessKey for v2 migrated users, on the root manifest for legacy users.+ // Current SRP salt: lives on the password VaultManifestAccessKey for v2 migrated users, on the personal manifest for legacy users.var encryptionSettings = await AuthHelper.GetUserLatestVaultEncryptionSettingsAsync(context, user);// Check client version compatibility if the header is provided.@@ -81,6 +83,7 @@ public class StatusController(IAliasServerDbContextFactory dbContextFactory, UseServerVersion = AppInfo.GetFullVersion(),SrpSalt = encryptionSettings.Salt,ManifestRevisions = manifestRevisions,+ PersonalManifestId = personalManifestId,BucketRevisions = bucketRevisions,});}diff --git a/apps/server/AliasVault.Api/Controllers/V2/Tests/TestController.cs b/apps/server/AliasVault.Api/Controllers/V2/Tests/TestController.csindex 3bd2333ff..af7c3f387 100644--- a/apps/server/AliasVault.Api/Controllers/V2/Tests/TestController.cs+++ b/apps/server/AliasVault.Api/Controllers/V2/Tests/TestController.cs@@ -421,13 +421,13 @@ public class TestController(}/// <summary>- /// Builds the revision info payload for a user: the current revision of the root manifest plus all history+ /// Builds the revision info payload for a user: the current revision of the personal manifest plus all history/// revisions, newest first./// </summary>private static async Task<object> BuildRevisionInfoAsync(AliasServerDbContext context, string userId){var current = await context.VaultManifests- .Where(v => v.IsRoot && context.AliasVaultUsers.Any(u => u.Id == userId && u.PersonalGroupId == v.OwnerGroupId))+ .Where(v => context.AliasVaultUsers.Any(u => u.Id == userId && u.PersonalGroupId == v.OwnerGroupId)).Select(v => new { v.RevisionNumber, v.CreatedAt, v.UpdatedAt }).FirstOrDefaultAsync();@@ -454,14 +454,14 @@ public class TestController(}/// <summary>- /// Deletes the newest <paramref name="count"/> revisions of the user's root manifest by rolling the current row+ /// Deletes the newest <paramref name="count"/> revisions of the user's personal manifest by rolling the current row/// back to the newest history revision each time (the inverse of the archive-then-update upload flow). When no/// history remains, the manifest row itself is deleted. Returns the revision numbers that were discarded./// </summary>private static async Task<List<long>> PopNewestRevisionsAsync(AliasServerDbContext context, string userId, int count){var deletedRevisions = new List<long>();- var current = await context.VaultManifests.FirstOrDefaultAsync(v => v.IsRoot && context.AliasVaultUsers.Any(u => u.Id == userId && u.PersonalGroupId == v.OwnerGroupId));+ var current = await context.VaultManifests.FirstOrDefaultAsync(v => context.AliasVaultUsers.Any(u => u.Id == userId && u.PersonalGroupId == v.OwnerGroupId));for (var i = 0; i < count && current != null; i++){diff --git a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs b/apps/server/AliasVault.Api/Controllers/V2/VaultController.csindex 9be5c35fb..d0dfca665 100644--- a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs+++ b/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs@@ -92,14 +92,14 @@ public class VaultController(// Every manifest the caller can open.var latestManifests = await AccessibleManifests(context, user.Id)- .Select(x => new { x.ManifestId, x.IsRoot, x.Name, x.ManifestBlob, x.ManifestCiphertextHash, x.RevisionNumber, x.OwnerGroupId })+ .Select(x => new { x.ManifestId, x.Name, x.ManifestBlob, x.ManifestCiphertextHash, x.RevisionNumber, x.OwnerGroupId, OwnerGroupType = x.OwnerGroup.Type }).ToListAsync();- if (!latestManifests.Any(m => m.IsRoot && ownedGroupIds.Contains(m.OwnerGroupId)))+ if (!latestManifests.Any(m => m.OwnerGroupId == user.PersonalGroupId)){// User hasn't migrated to manifest-v1 yet, return the latest legacy SQLite blob.var legacy = await context.VaultManifests- .Where(x => ownedGroupIds.Contains(x.OwnerGroupId) && x.IsRoot)+ .Where(x => x.OwnerGroupId == user.PersonalGroupId).OrderByDescending(x => x.RevisionNumber).FirstOrDefaultAsync();@@ -110,7 +110,7 @@ public class VaultController(LegacyVaultBlob = legacy?.VaultBlob ?? string.Empty,Version = legacy?.Version ?? string.Empty,LegacyRevision = legacy?.RevisionNumber ?? 0,- RootManifestId = legacy?.ManifestId,+ PersonalManifestId = legacy?.ManifestId,EmailRouting = emailRouting,});}@@ -159,14 +159,13 @@ public class VaultController(return new Manifest{ManifestId = m.ManifestId,- IsRoot = m.IsRoot,Name = m.Name,Blob = m.ManifestBlob,CiphertextHash = m.ManifestCiphertextHash,Revision = m.RevisionNumber,BlobReferences = refsByManifest.TryGetValue(m.ManifestId, out var refs) ? refs : [],OwnerUsername = ownerUsernamesByGroupId.GetValueOrDefault(m.OwnerGroupId),- CanAdminister = !m.IsRoot && administeredGroupIds.Contains(m.OwnerGroupId),+ CanAdminister = m.OwnerGroupType == GroupType.Shared && administeredGroupIds.Contains(m.OwnerGroupId),KeyType = accessKey != null ? ManifestKeyTypes.ToToken(accessKey.Type) : null,EncryptedVek = grant?.EncryptedVek,Algorithm = grant != null ? VaultKeyAlgorithms.ToToken(grant.Algorithm) : null,@@ -179,6 +178,7 @@ public class VaultController(Status = VaultStatus.Ok,StorageFormat = StorageFormat.Manifest,Manifests = manifests,+ PersonalManifestId = latestManifests.First(m => m.OwnerGroupId == user.PersonalGroupId).ManifestId,Buckets = buckets,EmailRouting = emailRouting,});@@ -219,7 +219,6 @@ public class VaultController(var manifest = new Manifest{ManifestId = latest.ManifestId,- IsRoot = latest.IsRoot,Name = latest.Name,Blob = latest.ManifestBlob,CiphertextHash = latest.ManifestCiphertextHash,@@ -241,7 +240,7 @@ public class VaultController(}// Ownership display and administer rights are only meaningful on a manifest that is not the caller's own home one.- if (!latest.IsRoot)+ 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);@@ -257,7 +256,7 @@ public class VaultController(}/// <summary>- /// Unified atomic write. Applies any number of changed manifests (root and/or shared manifests), changed data+ /// Unified atomic write. Applies any number of changed manifests (the personal manifest and/or shared manifests), changed data/// buckets, and new blobs in a single all-or-nothing DB transaction./// </summary>/// <param name="model">Vault write request DTO.</param>@@ -285,28 +284,41 @@ public class VaultController(return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.VAULT_NOT_UP_TO_DATE, 400));}- var rootWrite = model.Manifests.FirstOrDefault(m => m.IsRoot);+ var resolved = new List<(ManifestWrite Write, VaultManifest Row)>();+ foreach (var mw in model.Manifests)+ {+ var row = await ManifestAccessHelper.AccessibleManifests(context, user.Id).FirstOrDefaultAsync(x => x.ManifestId == mw.ManifestId);+ if (row == null)+ {+ return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.SHARED_MANIFEST_NOT_FOUND, 404));+ }++ resolved.Add((mw, row));+ }++ // The caller's own manifest is the one owned by their personal group; a personal group owns no other.+ var personalWrite = resolved.FirstOrDefault(r => r.Row.OwnerGroupId == user.PersonalGroupId).Write;/*- * Account-key migration: when writing the root manifest the first time, the client needs to generate a VEK,- * encrypt it with the AccountKey, and store it in the root manifest. AccountKeys blobs (KEK-encrypted AK + AK-encrypted account keypair).- * A non-root write must never carry one. We reject rather than silently ignore, so a misdirected key can never be dropped unnoticed.+ * Account-key migration: when writing the personal manifest the first time, the client needs to generate a VEK,+ * encrypt it with the AccountKey, and store it in the personal manifest. AccountKeys blobs (KEK-encrypted AK + AK-encrypted account keypair).+ * A shared-manifest write must never carry one. We reject rather than silently ignore, so a misdirected key can never be dropped unnoticed.* TODO: these guards can be removed once all users have migrated and we don't support legacy users anymore.*/- if (model.Manifests.Any(m => !m.IsRoot && !string.IsNullOrEmpty(m.EncryptedVek)))+ if (resolved.Any(r => r.Row.OwnerGroupId != user.PersonalGroupId && !string.IsNullOrEmpty(r.Write.EncryptedVek))){return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.VAULT_KEY_NOT_FOUND, 400));}- var migrationEncryptedVek = rootWrite?.EncryptedVek;+ var migrationEncryptedVek = personalWrite?.EncryptedVek;var hasExistingUnlockKey = await context.UserUnlockKeys.AnyAsync(x => x.UserId == user.Id && x.Type == UnlockMethodType.Password);if (!string.IsNullOrEmpty(migrationEncryptedVek) && hasExistingUnlockKey){return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.VAULT_KEY_ALREADY_EXISTS, 400));}- // A root push from a not-yet-migrated user must carry the encrypted VEK to migrate the vault into the manifest-v1 format.- if (rootWrite != null && string.IsNullOrEmpty(migrationEncryptedVek) && !hasExistingUnlockKey)+ // A personal-manifest push from a not-yet-migrated user must carry the encrypted VEK to migrate the vault into the manifest-v1 format.+ if (personalWrite != null && string.IsNullOrEmpty(migrationEncryptedVek) && !hasExistingUnlockKey){return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.VAULT_KEY_NOT_FOUND, 400));}@@ -319,45 +331,6 @@ public class VaultController(return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.VAULT_KEY_NOT_FOUND, 400));}- /*- * Resolve + authorize each manifest write to its stored row.- */- var resolved = new List<(ManifestWrite Write, VaultManifest Row)>();- foreach (var mw in model.Manifests)- {- VaultManifest? row;- if (mw.ManifestId != null)- {- row = await ManifestAccessHelper.AccessibleManifests(context, user.Id).FirstOrDefaultAsync(x => x.ManifestId == mw.ManifestId);- }- else if (mw.IsRoot)- {- row = await context.VaultManifests.FirstOrDefaultAsync(x => x.IsRoot && x.OwnerGroupId == user.PersonalGroupId);- }- else- {- // A non-root write must name its manifest; a missing id must never fall through to the root.- return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.VAULT_NOT_UP_TO_DATE, 400));- }-- if (row == null)- {- // A missing root is a state error on the caller's own vault; a missing shared manifest is a bad target.- return mw.IsRoot- ? BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.VAULT_NOT_UP_TO_DATE, 400))- : NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.SHARED_MANIFEST_NOT_FOUND, 404));- }-- // The target must agree with what its id resolved to, and a root write only ever means the caller's own- // personal root: refuse rather than guess which manifest was intended.- if (row.IsRoot != mw.IsRoot || (mw.IsRoot && row.OwnerGroupId != user.PersonalGroupId))- {- return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.VAULT_NOT_UP_TO_DATE, 400));- }-- resolved.Add((mw, row));- }-// All-or-nothing revision gate: every manifest and bucket must be exactly one ahead of the server's current.// On any staleness, reject the whole write with Outdated and hand back the current revisions to pull/merge.var writeCategories = model.Buckets.Select(b => b.Category).ToList();@@ -371,7 +344,7 @@ public class VaultController(return Ok(new VaultWriteResponse{Status = VaultStatus.Outdated,- ManifestRevisions = resolved.Select(r => new ManifestWriteResult { IsRoot = r.Write.IsRoot, ManifestId = r.Write.ManifestId, Revision = r.Row.RevisionNumber }).ToList(),+ ManifestRevisions = resolved.Select(r => new ManifestWriteResult { ManifestId = r.Write.ManifestId, Revision = r.Row.RevisionNumber }).ToList(),BucketRevisions = model.Buckets.Select(b => new BucketRevision { Category = b.Category, Revision = bucketCurrentRevisions[b.Category] }).ToList(),});}@@ -396,8 +369,8 @@ public class VaultController(}// 2) Validate every referenced hash exists.- var ownScopeHashes = resolved.Where(r => r.Write.IsRoot).SelectMany(r => r.Write.BlobReferences).Select(br => br.Hash).Distinct().ToList();- var anyScopeHashes = resolved.Where(r => !r.Write.IsRoot).SelectMany(r => r.Write.BlobReferences).Select(br => br.Hash).Distinct().ToList();+ var ownScopeHashes = resolved.Where(r => r.Row.OwnerGroupId == user.PersonalGroupId).SelectMany(r => r.Write.BlobReferences).Select(br => br.Hash).Distinct().ToList();+ var anyScopeHashes = resolved.Where(r => r.Row.OwnerGroupId != user.PersonalGroupId).SelectMany(r => r.Write.BlobReferences).Select(br => br.Hash).Distinct().ToList();var missing = new List<string>();if (ownScopeHashes.Count > 0){@@ -419,12 +392,12 @@ public class VaultController({Status = VaultStatus.Ok,MissingBlobHashes = missing,- ManifestRevisions = resolved.Select(r => new ManifestWriteResult { IsRoot = r.Write.IsRoot, ManifestId = r.Write.ManifestId, Revision = r.Row.RevisionNumber }).ToList(),+ ManifestRevisions = resolved.Select(r => new ManifestWriteResult { ManifestId = r.Write.ManifestId, Revision = r.Row.RevisionNumber }).ToList(),});}// 3) Apply each manifest: archive the current revision into history, update the row in place, run the- // root-only side effects (email claims count + KEK/VEK key creation), and prune history per retention.+ // personal-only side effects (email claims count + KEK/VEK key creation), and prune history per retention.var manifestResults = new List<ManifestWriteResult>();foreach (var (mw, row) in resolved){@@ -450,7 +423,7 @@ public class VaultController(row.EmailClaimsCount = model.EmailRouting.EmailAddressList.Count(x => x.ManifestId == row.ManifestId);}- if (row.IsRoot)+ if (row.OwnerGroupId == user.PersonalGroupId){row.CreatedAt = timeProvider.UtcNow;@@ -507,7 +480,7 @@ public class VaultController(}await ApplyVaultRetention(context, row, archivedRevision);- manifestResults.Add(new ManifestWriteResult { IsRoot = mw.IsRoot, ManifestId = mw.ManifestId, Revision = row.RevisionNumber });+ manifestResults.Add(new ManifestWriteResult { ManifestId = mw.ManifestId, Revision = row.RevisionNumber });}await context.SaveChangesAsync();@@ -539,14 +512,14 @@ public class VaultController(newBucketRevisions.Add(new BucketRevision { Category = bucket.Category, Revision = rev });}- // 6) Root-scoped email routing + public keys. The personal key is published scoped to the caller's- // root manifest, the exact same flow as a shared manifest's delivery key below.+ // 6) Personal-scoped email routing + public keys. The personal key is published scoped to the caller's+ // personal manifest, the exact same flow as a shared manifest's delivery key below.if (!string.IsNullOrEmpty(model.UserEncryptionPublicKey)){- var rootManifestId = await GroupHelper.GetRootManifestIdAsync(context, user.PersonalGroupId);- if (rootManifestId is not null)+ var personalManifestId = await GroupHelper.GetPersonalManifestIdAsync(context, user.PersonalGroupId);+ if (personalManifestId is not null){- await PublishManifestPublicKeyAsync(context, rootManifestId.Value, model.UserEncryptionPublicKey);+ await PublishManifestPublicKeyAsync(context, personalManifestId.Value, model.UserEncryptionPublicKey);}}@@ -682,7 +655,7 @@ public class VaultController(if (missing.Count > 0){var accessibleManifests = await AccessibleManifests(context, user.Id)- .Where(m => !m.IsRoot)+ .Where(m => m.OwnerGroup.Type == GroupType.Shared).Select(m => new { m.ManifestId, m.RevisionNumber }).ToListAsync();var accessibleIds = accessibleManifests.Select(m => m.ManifestId).ToList();@@ -734,7 +707,7 @@ public class VaultController(}var administered = await context.VaultManifests- .Where(m => ids.Contains(m.ManifestId) && !m.IsRoot+ .Where(m => ids.Contains(m.ManifestId) && m.OwnerGroup.Type == GroupType.Shared&& context.GroupMembers.Any(gm => gm.GroupId == m.OwnerGroupId && gm.UserId == userId && (gm.Role == GroupRole.Admin || gm.Role == GroupRole.Owner))).Select(m => m.ManifestId).ToListAsync();@@ -1037,10 +1010,10 @@ public class VaultController(var ownerGroupByManifest = await GroupHelper.GetOwnerGroupsAsync(context, accessibleManifests);// Resolved server-side and never read off the push: this is what stops a client filing an alias under a manifest it merely named.- var rootManifestId = await context.VaultManifests.Where(m => m.IsRoot && m.OwnerGroupId == user.PersonalGroupId).Select(m => (Guid?)m.ManifestId).FirstOrDefaultAsync();- if (rootManifestId is null)+ var personalManifestId = await GroupHelper.GetPersonalManifestIdAsync(context, user.PersonalGroupId);+ if (personalManifestId is null){- logger.LogError("No root manifest found for {User}; skipping email claim update.", user.UserName);+ logger.LogError("No personal manifest found for {User}; skipping email claim update.", user.UserName);return;}@@ -1056,12 +1029,12 @@ public class VaultController(var sanitizedClaimed = EmailHelper.SanitizeEmail(claimed.Address);if (!accessibleManifests.Contains(claimed.ManifestId)){- logger.LogWarning("{User} claimed alias {Email} for manifest {Manifest} they cannot access; filing it under their own root manifest instead.", user.UserName, sanitizedClaimed, claimed.ManifestId);+ logger.LogWarning("{User} claimed alias {Email} for manifest {Manifest} they cannot access; filing it under their own personal manifest instead.", user.UserName, sanitizedClaimed, claimed.ManifestId);continue;}manifestByAddress[sanitizedClaimed] = claimed.ManifestId;- if (claimed.ManifestId != rootManifestId.Value && !manifestsWithDeliveryKey.Contains(claimed.ManifestId))+ if (claimed.ManifestId != personalManifestId.Value && !manifestsWithDeliveryKey.Contains(claimed.ManifestId)){logger.LogWarning("{User} claimed shared alias {Email} for manifest {Manifest} with no published delivery key; its mail stays readable by the routing owner alone until a delivery key is published.", user.UserName, sanitizedClaimed, claimed.ManifestId);}@@ -1102,8 +1075,8 @@ public class VaultController(continue;}- // Which manifest the alias is filed against: the one the push named when the caller may claim for it, their own root otherwise.- var resolvedManifestId = manifestByAddress.TryGetValue(sanitized, out var claimedManifestId) ? claimedManifestId : rootManifestId.Value;+ // Which manifest the alias is filed against: the one the push named when the caller may claim for it, their own personal manifest otherwise.+ var resolvedManifestId = manifestByAddress.TryGetValue(sanitized, out var claimedManifestId) ? claimedManifestId : personalManifestId.Value;// The quota subject is the group owning that manifest: the shared manifest's group, or the caller's personal group.var quotaGroupId = ownerGroupByManifest.TryGetValue(resolvedManifestId, out var ownerGroupId) ? ownerGroupId : user.PersonalGroupId;@@ -1224,7 +1197,7 @@ public class VaultController(/// </summary>/// <param name="context">Database context.</param>/// <param name="vaultManifestId">- /// The manifest this key belongs to: the caller's root manifest for their personal key, a shared manifest+ /// The manifest this key belongs to: the caller's personal manifest for their personal key, a shared manifest/// for its delivery key. Everything here is scoped by it, promoting a shared manifest's key must never demote/// the user's personal key, and rotating the personal key must never demote a shared manifest's delivery key. The key/// carries no user owner at all: it must survive the publishing admin deleting their account, and a laterdiff --git a/apps/server/AliasVault.Api/Controllers/V2/VaultKeyController.cs b/apps/server/AliasVault.Api/Controllers/V2/VaultKeyController.csindex 4c72410d4..54462a274 100644--- a/apps/server/AliasVault.Api/Controllers/V2/VaultKeyController.cs+++ b/apps/server/AliasVault.Api/Controllers/V2/VaultKeyController.cs@@ -52,9 +52,9 @@ public class VaultKeyController(IAliasServerDbContextFactory dbContextFactory, U}// Get the encrypted VEK and account keypair.- var rootManifestId = await GroupHelper.GetRootManifestIdAsync(context, user.PersonalGroupId);- var encryptedVek = rootManifestId is null ? null : await context.VaultManifestAccessKeys- .Where(x => x.UserId == user.Id && x.Type == ManifestKeyType.AccountKey && x.VaultManifestId == rootManifestId.Value)+ var personalManifestId = await GroupHelper.GetPersonalManifestIdAsync(context, user.PersonalGroupId);+ var encryptedVek = personalManifestId is null ? null : await context.VaultManifestAccessKeys+ .Where(x => x.UserId == user.Id && x.Type == ManifestKeyType.AccountKey && x.VaultManifestId == personalManifestId.Value).Select(x => x.EncryptedVek).FirstOrDefaultAsync();var accountKeypair = await context.UserGrantKeysdiff --git a/apps/server/AliasVault.Api/Helpers/AuthHelper.cs b/apps/server/AliasVault.Api/Helpers/AuthHelper.csindex 6ca429c00..fdf0b0597 100644--- a/apps/server/AliasVault.Api/Helpers/AuthHelper.cs+++ b/apps/server/AliasVault.Api/Helpers/AuthHelper.cs@@ -86,7 +86,7 @@ public static class AuthHelper// Get the user's current SRP salt/verifier and key derivation settings for the legacy model.var latestVault = await context.VaultManifests- .Where(m => m.IsRoot && m.OwnerGroupId == user.PersonalGroupId)+ .Where(m => m.OwnerGroupId == user.PersonalGroupId).Select(x => new { x.Salt, x.Verifier, x.EncryptionType, x.EncryptionSettings }).FirstAsync();diff --git a/apps/server/AliasVault.Api/Helpers/EmailAccessHelper.cs b/apps/server/AliasVault.Api/Helpers/EmailAccessHelper.csindex 4a0a3cbf6..bb967e3c9 100644--- a/apps/server/AliasVault.Api/Helpers/EmailAccessHelper.cs+++ b/apps/server/AliasVault.Api/Helpers/EmailAccessHelper.cs@@ -30,14 +30,14 @@ public static class EmailAccessHelperreturn false;}- // Holding any access key on the manifest is proof of access: AccountKey on a root manifest, GrantKey on a shared manifest (owner self-grant and recipient alike).+ // Holding any access key on the manifest is proof of access: AccountKey on a personal manifest, GrantKey on a shared manifest (owner self-grant and recipient alike).var hasAccessKey = await context.VaultManifestAccessKeys.AnyAsync(k => k.UserId == userId && k.VaultManifestId == claim.VaultManifestId);if (hasAccessKey){return true;}- // TODO: legacy fallback — pre-KEK/VEK accounts have no AccountKey row on their root manifest yet, so owning the manifest's group is their only proof of access. Delete once all clients have migrated.+ // TODO: legacy fallback — pre-KEK/VEK accounts have no AccountKey row on their personal manifest yet, so owning the manifest's group is their only proof of access. Delete once all clients have migrated.return await context.VaultManifests.AnyAsync(m => m.ManifestId == claim.VaultManifestId && context.GroupMembers.Any(gm => gm.GroupId == m.OwnerGroupId && gm.UserId == userId && gm.Role == GroupRole.Owner));}@@ -65,7 +65,7 @@ public static class EmailAccessHelperreturn [];}- // Holding any access key on the manifest is proof of access: AccountKey on a root manifest, GrantKey on a shared manifest+ // Holding any access key on the manifest is proof of access: AccountKey on a personal manifest, GrantKey on a shared manifest// (owner self-grant and recipient alike).var manifestIds = claims.Select(c => c.ManifestId).Distinct().ToList();var keyedManifestIds = (await context.VaultManifestAccessKeys@@ -73,7 +73,7 @@ public static class EmailAccessHelper.Select(k => k.VaultManifestId).ToListAsync()).ToHashSet();- // Legacy fallback: pre-KEK/VEK accounts have no AccountKey row on their root manifest yet+ // Legacy fallback: pre-KEK/VEK accounts have no AccountKey row on their personal manifest yet// so owning the manifest's group is their only proof of access. TODO: delete once all clients have migrated.var ownedGroupIds = (await GroupHelper.GetOwnedGroupIdsAsync(context, userId)).ToHashSet();@@ -91,7 +91,7 @@ public static class EmailAccessHelper{// Get the ids of the user's personal keys.var personalKeyIds = await context.VaultManifestDeliveryKeys- .Where(k => context.VaultManifests.Any(m => m.ManifestId == k.VaultManifestId && m.IsRoot && context.AliasVaultUsers.Any(u => u.Id == userId && u.PersonalGroupId == m.OwnerGroupId)))+ .Where(k => context.VaultManifests.Any(m => m.ManifestId == k.VaultManifestId && context.AliasVaultUsers.Any(u => u.Id == userId && u.PersonalGroupId == m.OwnerGroupId))).Select(k => k.Id).ToListAsync();diff --git a/apps/server/AliasVault.Api/Helpers/VaultStatusHelper.cs b/apps/server/AliasVault.Api/Helpers/VaultStatusHelper.csindex b494ab2a1..52d8cf290 100644--- a/apps/server/AliasVault.Api/Helpers/VaultStatusHelper.cs+++ b/apps/server/AliasVault.Api/Helpers/VaultStatusHelper.cs@@ -25,7 +25,7 @@ public static class VaultStatusHelperpublic static async Task<List<ManifestRevision>> GetManifestRevisionsAsync(AliasServerDbContext context, string userId){return await ManifestAccessHelper.AccessibleManifests(context, userId)- .Select(x => new ManifestRevision { ManifestId = x.ManifestId, IsRoot = x.IsRoot, Revision = x.RevisionNumber })+ .Select(x => new ManifestRevision { ManifestId = x.ManifestId, Revision = x.RevisionNumber }).ToListAsync();}}diff --git a/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs b/apps/server/Databases/AliasServerDb/AliasServerDbContext.csindex 7ec2e9f71..72f361c3e 100644--- a/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs+++ b/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs@@ -347,7 +347,6 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyCon.HasForeignKey(e => e.OwnerGroupId).OnDelete(DeleteBehavior.Cascade);- builder.HasIndex(e => e.OwnerGroupId).HasFilter("\"IsRoot\"").IsUnique().HasDatabaseName("UX_VaultManifests_OwnerGroupId_Root");builder.HasIndex(e => e.OwnerGroupId);});@@ -423,7 +422,7 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyConmodelBuilder.Entity<VaultManifestDeliveryKey>(builder =>{// A key is removed with its manifest: for a folder that is the folder's delivery keys, for a- // root manifest the user's personal keys (root manifests only disappear with the account).+ // personal manifest the user's personal keys (personal manifests only disappear with the account).builder.HasOne(k => k.VaultManifest).WithMany().HasForeignKey(k => k.VaultManifestId)diff --git a/apps/server/Databases/AliasServerDb/AliasVaultUser.cs b/apps/server/Databases/AliasServerDb/AliasVaultUser.csindex 2a9f91b83..a488f526a 100644--- a/apps/server/Databases/AliasServerDb/AliasVaultUser.cs+++ b/apps/server/Databases/AliasServerDb/AliasVaultUser.cs@@ -22,7 +22,7 @@ public class AliasVaultUser : IdentityUserpublic string? SrpIdentity { get; set; }/// <summary>- /// Gets or sets the user's personal <see cref="Group"/>: the group that owns their root vault and personal+ /// Gets or sets the user's personal <see cref="Group"/>: the group that owns their personal vault and personal/// email claims./// </summary>public Guid PersonalGroupId { get; set; }diff --git a/apps/server/Databases/AliasServerDb/ManifestKeyType.cs b/apps/server/Databases/AliasServerDb/ManifestKeyType.csindex aa706ce47..df7efc1d8 100644--- a/apps/server/Databases/AliasServerDb/ManifestKeyType.cs+++ b/apps/server/Databases/AliasServerDb/ManifestKeyType.cs@@ -13,7 +13,7 @@ namespace AliasServerDb;public enum ManifestKeyType{/// <summary>- /// The user's own root-manifest VEK, encrypted by their Account Key (see <see cref="UserUnlockKey"/>).+ /// The user's own personal-manifest VEK, encrypted by their Account Key (see <see cref="UserUnlockKey"/>)./// </summary>AccountKey = 1,diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260807200945_RenameRootManifestToPersonal.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260807200945_RenameRootManifestToPersonal.Designer.csnew file mode 100644index 000000000..fd2a504d2--- /dev/null+++ b/apps/server/Databases/AliasServerDb/Migrations/20260807200945_RenameRootManifestToPersonal.Designer.cs@@ -0,0 +1,1644 @@+// <auto-generated />+using System;+using AliasServerDb;+using Microsoft.EntityFrameworkCore;+using Microsoft.EntityFrameworkCore.Infrastructure;+using Microsoft.EntityFrameworkCore.Migrations;+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;++#nullable disable++namespace AliasServerDb.Migrations+{+ [DbContext(typeof(AliasServerDbContext))]+ [Migration("20260807200945_RenameRootManifestToPersonal")]+ partial class RenameRootManifestToPersonal+ {+ /// <inheritdoc />+ protected override void BuildTargetModel(ModelBuilder modelBuilder)+ {+#pragma warning disable 612, 618+ modelBuilder+ .HasAnnotation("ProductVersion", "10.0.10")+ .HasAnnotation("Proxies:ChangeTracking", false)+ .HasAnnotation("Proxies:CheckEquality", false)+ .HasAnnotation("Proxies:LazyLoading", true)+ .HasAnnotation("Relational:MaxIdentifierLength", 63);++ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);++ modelBuilder.Entity("AliasServerDb.AdminRole", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("text");++ b.Property<string>("Name")+ .HasColumnType("text");++ b.Property<string>("NormalizedName")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("AdminRoles");+ });++ modelBuilder.Entity("AliasServerDb.AdminUser", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<int>("AccessFailedCount")+ .HasColumnType("integer");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("text");++ b.Property<string>("Email")+ .HasColumnType("text");++ b.Property<bool>("EmailConfirmed")+ .HasColumnType("boolean");++ b.Property<DateTime?>("LastPasswordChanged")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("LockoutEnabled")+ .HasColumnType("boolean");++ b.Property<DateTimeOffset?>("LockoutEnd")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("NormalizedEmail")+ .HasColumnType("text");++ b.Property<string>("NormalizedUserName")+ .HasColumnType("text");++ b.Property<string>("PasswordHash")+ .HasColumnType("text");++ b.Property<string>("PhoneNumber")+ .HasColumnType("text");++ b.Property<bool>("PhoneNumberConfirmed")+ .HasColumnType("boolean");++ b.Property<string>("SecurityStamp")+ .HasColumnType("text");++ b.Property<bool>("TwoFactorEnabled")+ .HasColumnType("boolean");++ b.Property<string>("UserName")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("AdminUsers");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultRole", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("text");++ b.Property<string>("Name")+ .HasColumnType("text");++ b.Property<string>("NormalizedName")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("AliasVaultRoles");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<int>("AccessFailedCount")+ .HasColumnType("integer");++ b.Property<bool>("Blocked")+ .HasColumnType("boolean");++ b.Property<DateTime?>("BlockedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("text");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Email")+ .HasColumnType("text");++ b.Property<bool>("EmailConfirmed")+ .HasColumnType("boolean");++ b.Property<DateTime?>("LastActivityDate")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("LockoutEnabled")+ .HasColumnType("boolean");++ b.Property<DateTimeOffset?>("LockoutEnd")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("NormalizedEmail")+ .HasColumnType("text");++ b.Property<string>("NormalizedUserName")+ .HasColumnType("text");++ b.Property<DateTime>("PasswordChangedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("PasswordHash")+ .HasColumnType("text");++ b.Property<Guid>("PersonalGroupId")+ .HasColumnType("uuid");++ b.Property<string>("PhoneNumber")+ .HasColumnType("text");++ b.Property<bool>("PhoneNumberConfirmed")+ .HasColumnType("boolean");++ b.Property<string>("SecurityStamp")+ .HasColumnType("text");++ b.Property<string>("SrpIdentity")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<bool>("TwoFactorEnabled")+ .HasColumnType("boolean");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserName")+ .HasColumnType("text");++ b.HasKey("Id");++ b.HasIndex("PersonalGroupId")+ .IsUnique()+ .HasDatabaseName("UX_AliasVaultUsers_PersonalGroupId");++ b.ToTable("AliasVaultUsers");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("DeviceIdentifier")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime>("ExpireDate")+ .HasMaxLength(255)+ .HasColumnType("timestamp with time zone");++ b.Property<string>("IpAddress")+ .HasMaxLength(45)+ .HasColumnType("character varying(45)");++ b.Property<string>("PreviousTokenValue")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Value")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.ToTable("AliasVaultUserRefreshTokens");+ });++ modelBuilder.Entity("AliasServerDb.AuthLog", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("AdditionalInfo")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Browser")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("Client")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("Country")+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("DeviceType")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<int>("EventType")+ .HasColumnType("integer");++ b.Property<int?>("FailureReason")+ .HasColumnType("integer");++ b.Property<string>("IpAddress")+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<bool>("IsSuccess")+ .HasColumnType("boolean");++ b.Property<bool>("IsSuspiciousActivity")+ .HasColumnType("boolean");++ b.Property<string>("OperatingSystem")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("RequestPath")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<DateTime>("Timestamp")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Username")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex(new[] { "EventType" }, "IX_EventType");++ b.HasIndex(new[] { "IpAddress" }, "IX_IpAddress");++ b.HasIndex(new[] { "Timestamp" }, "IX_Timestamp");++ b.HasIndex(new[] { "Username", "IsSuccess", "Timestamp" }, "IX_Username_IsSuccess_Timestamp")+ .IsDescending(false, false, true);++ b.HasIndex(new[] { "Username", "Timestamp" }, "IX_Username_Timestamp")+ .IsDescending(false, true);++ b.ToTable("AuthLogs");+ });++ modelBuilder.Entity("AliasServerDb.BlockedIpRange", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<bool>("BlockLogin")+ .HasColumnType("boolean");++ b.Property<bool>("BlockRegistration")+ .HasColumnType("boolean");++ b.Property<bool>("BlockShadow")+ .HasColumnType("boolean");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("CreatedBy")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<bool>("Enabled")+ .HasColumnType("boolean");++ b.Property<string>("IpRange")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("Reason")+ .HasMaxLength(500)+ .HasColumnType("character varying(500)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("Id");++ b.HasIndex(new[] { "Enabled" }, "IX_BlockedIpRange_Enabled");++ b.HasIndex(new[] { "IpRange" }, "IX_BlockedIpRange_IpRange")+ .IsUnique();++ b.ToTable("BlockedIpRanges");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<DateTime>("Date")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime>("DateSystem")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedSymmetricKey")+ .IsRequired()+ .HasColumnType("text");++ b.Property<Guid>("EncryptionKeyId")+ .HasMaxLength(255)+ .HasColumnType("uuid");++ b.Property<string>("From")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("FromDomain")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("FromLocal")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("MessageHtml")+ .HasColumnType("text");++ b.Property<string>("MessagePlain")+ .HasColumnType("text");++ b.Property<string>("MessagePreview")+ .HasColumnType("text");++ b.Property<string>("MessageSource")+ .IsRequired()+ .HasColumnType("text");++ b.Property<bool>("PushNotificationSent")+ .HasColumnType("boolean");++ b.Property<string>("Subject")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("To")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("ToDomain")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("ToLocal")+ .IsRequired()+ .HasColumnType("text");++ b.Property<bool>("Visible")+ .HasColumnType("boolean");++ b.HasKey("Id");++ b.HasIndex("Date");++ b.HasIndex("DateSystem");++ b.HasIndex("EncryptionKeyId");++ b.HasIndex("PushNotificationSent");++ b.HasIndex("Visible");++ b.HasIndex("To", "DateSystem");++ b.ToTable("Emails");+ });++ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<byte[]>("Bytes")+ .IsRequired()+ .HasColumnType("bytea");++ b.Property<DateTime>("Date")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("EmailId")+ .HasColumnType("integer");++ b.Property<string>("Filename")+ .IsRequired()+ .HasColumnType("text");++ b.Property<int>("Filesize")+ .HasColumnType("integer");++ b.Property<string>("MimeType")+ .IsRequired()+ .HasColumnType("text");++ b.HasKey("Id");++ b.HasIndex("EmailId");++ b.ToTable("EmailAttachments");+ });++ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Address")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("AddressDomain")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("AddressLocal")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("Disabled")+ .HasColumnType("boolean");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid?>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("Address")+ .IsUnique();++ b.HasIndex("VaultManifestId", "CreatedAt");++ b.HasIndex("VaultManifestId", "Disabled");++ b.ToTable("EmailClaims");+ });++ modelBuilder.Entity("AliasServerDb.Group", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("EmailsReceived")+ .HasColumnType("integer");++ b.Property<int>("MaxEmailAgeDays")+ .HasColumnType("integer");++ b.Property<int>("MaxEmails")+ .HasColumnType("integer");++ b.Property<string>("Name")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<bool>("ShadowBlocked")+ .HasColumnType("boolean");++ b.Property<DateTime?>("ShadowBlockedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("Type")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("Id");++ b.ToTable("Groups");+ });++ modelBuilder.Entity("AliasServerDb.GroupMember", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid>("GroupId")+ .HasColumnType("uuid");++ b.Property<int>("Role")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.HasIndex("GroupId", "UserId")+ .IsUnique();++ b.ToTable("GroupMembers");+ });++ modelBuilder.Entity("AliasServerDb.Log", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("Application")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("Exception")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("Level")+ .IsRequired()+ .HasMaxLength(128)+ .HasColumnType("character varying(128)");++ b.Property<string>("LogEvent")+ .IsRequired()+ .HasColumnType("text")+ .HasColumnName("LogEvent");++ b.Property<string>("Message")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("MessageTemplate")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("Properties")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("SourceContext")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("TimeStamp")+ .HasColumnType("timestamp with time zone");++ b.HasKey("Id");++ b.HasIndex("Application");++ b.HasIndex("TimeStamp");++ b.ToTable("Logs", (string)null);+ });++ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<DateTime?>("ClearedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("ClientIpAddress")+ .HasColumnType("text");++ b.Property<string>("ClientPublicKey")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedDecryptionKey")+ .HasColumnType("text");++ b.Property<DateTime?>("FulfilledAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("MobileIpAddress")+ .HasColumnType("text");++ b.Property<DateTime?>("RetrievedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .HasColumnType("text");++ b.HasKey("Id");++ b.HasIndex(new[] { "ClientIpAddress" }, "IX_ClientIpAddress");++ b.HasIndex(new[] { "CreatedAt" }, "IX_CreatedAt");++ b.HasIndex(new[] { "MobileIpAddress" }, "IX_MobileIpAddress");++ b.HasIndex(new[] { "RetrievedAt", "ClearedAt", "FulfilledAt" }, "IX_RetrievedAt_ClearedAt_FulfilledAt");++ b.HasIndex(new[] { "UserId" }, "IX_UserId");++ b.ToTable("MobileLoginRequests");+ });++ modelBuilder.Entity("AliasServerDb.RateLimit", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<int?>("AppliesToAccountAgeMaxDays")+ .HasColumnType("integer");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("CreatedBy")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime?>("EffectiveFrom")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime?>("EffectiveUntil")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("Enabled")+ .HasColumnType("boolean");++ b.Property<Guid?>("GroupId")+ .HasColumnType("uuid");++ b.Property<int>("LimitType")+ .HasColumnType("integer");++ b.Property<int>("MaxCount")+ .HasColumnType("integer");++ b.Property<string>("Notes")+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<int?>("Tier")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("WindowSeconds")+ .HasColumnType("integer");++ b.HasKey("Id");++ b.HasIndex("GroupId");++ b.HasIndex("Tier");++ b.HasIndex("LimitType", "Enabled");++ b.ToTable("RateLimits");+ });++ modelBuilder.Entity("AliasServerDb.ServerSetting", b =>+ {+ b.Property<string>("Key")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Value")+ .HasColumnType("text");++ b.HasKey("Key");++ b.ToTable("ServerSettings");+ });++ modelBuilder.Entity("AliasServerDb.TaskRunnerJob", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<TimeOnly?>("EndTime")+ .HasColumnType("time without time zone");++ b.Property<string>("ErrorMessage")+ .HasColumnType("text");++ b.Property<bool>("IsOnDemand")+ .HasColumnType("boolean");++ b.Property<string>("Name")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<DateTime>("RunDate")+ .HasColumnType("timestamp with time zone");++ b.Property<TimeOnly>("StartTime")+ .HasColumnType("time without time zone");++ b.Property<int>("Status")+ .HasColumnType("integer");++ b.HasKey("Id");++ b.ToTable("TaskRunnerJobs");+ });++ modelBuilder.Entity("AliasServerDb.UserGrantKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedPrivateKey")+ .IsRequired()+ .HasMaxLength(4000)+ .HasColumnType("character varying(4000)");++ b.Property<bool>("IsPrimary")+ .HasColumnType("boolean");++ b.Property<string>("PublicKey")+ .IsRequired()+ .HasMaxLength(2000)+ .HasColumnType("character varying(2000)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId")+ .IsUnique()+ .HasDatabaseName("UX_UserGrantKeys_User_Primary")+ .HasFilter("\"IsPrimary\"");++ b.ToTable("UserGrantKeys");+ });++ modelBuilder.Entity("AliasServerDb.UserUnlockKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Algorithm")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedAccountKey")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime?>("LastUsedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Metadata")+ .HasColumnType("jsonb");++ b.Property<int>("Type")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId", "Type")+ .IsUnique()+ .HasDatabaseName("UX_UserUnlockKeys_UserId_Type");++ b.ToTable("UserUnlockKeys");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>+ {+ b.Property<string>("Hash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<string>("OwnerUserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Category")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<byte[]>("EncryptedData")+ .IsRequired()+ .HasColumnType("bytea");++ b.Property<DateTime>("LastReferencedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("SizeBytes")+ .HasColumnType("integer");++ b.HasKey("Hash", "OwnerUserId");++ b.HasIndex("OwnerUserId", "Category");++ b.ToTable("VaultBlobObjects");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>+ {+ b.Property<Guid>("ManifestId")+ .HasColumnType("uuid");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("BlobHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.HasKey("ManifestId", "RevisionNumber", "BlobHash");++ b.ToTable("VaultBlobReferences");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>+ {+ b.Property<string>("OwnerUserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Category")+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("CiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedData")+ .IsRequired()+ .HasColumnType("text");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("OwnerUserId", "Category");++ b.ToTable("VaultDataBuckets");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucketsHistory", b =>+ {+ b.Property<string>("OwnerUserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Category")+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("CiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedData")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("OwnerUserId", "Category", "RevisionNumber");++ b.ToTable("VaultDataBucketsHistory");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>+ {+ b.Property<Guid>("ManifestId")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Client")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("CredentialsCount")+ .HasColumnType("integer");++ b.Property<int>("EmailClaimsCount")+ .HasColumnType("integer");++ b.Property<string>("EncryptionSettings")+ .HasColumnType("text");++ b.Property<string>("EncryptionType")+ .HasColumnType("text");++ b.Property<int>("FileSize")+ .HasColumnType("integer");++ b.Property<bool>("IsPersonal")+ .HasColumnType("boolean");++ b.Property<string>("ManifestBlob")+ .HasColumnType("text");++ b.Property<string>("ManifestCiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<string>("Name")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<Guid>("OwnerGroupId")+ .HasColumnType("uuid");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("Salt")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("StorageFormat")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("VaultBlob")+ .HasColumnType("text");++ b.Property<string>("Verifier")+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<string>("Version")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("ManifestId");++ b.HasIndex("OwnerGroupId")+ .IsUnique()+ .HasDatabaseName("UX_VaultManifests_OwnerGroupId_Personal")+ .HasFilter("\"IsPersonal\"");++ b.ToTable("VaultManifests");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestAccessKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Algorithm")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedVek")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime?>("LastUsedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Metadata")+ .HasColumnType("jsonb");++ b.Property<int>("Type")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid?>("UserGrantKeyId")+ .HasColumnType("uuid");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<Guid>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("UserGrantKeyId");++ b.HasIndex("VaultManifestId")+ .HasDatabaseName("IX_VaultManifestAccessKeys_VaultManifestId");++ b.HasIndex("UserId", "Type", "VaultManifestId")+ .IsUnique()+ .HasDatabaseName("UX_VaultManifestAccessKeys_UserId_Type_Manifest");++ b.ToTable("VaultManifestAccessKeys");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("IsPrimary")+ .HasColumnType("boolean");++ b.Property<string>("PublicKey")+ .IsRequired()+ .HasMaxLength(2000)+ .HasColumnType("character varying(2000)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("VaultManifestId")+ .IsUnique()+ .HasDatabaseName("UX_VaultManifestDeliveryKeys_Manifest_Primary")+ .HasFilter("\"IsPrimary\"");++ b.HasIndex("VaultManifestId", "IsPrimary");++ b.ToTable("VaultManifestDeliveryKeys");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>+ {+ b.Property<Guid>("ManifestId")+ .HasColumnType("uuid");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("Client")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("CredentialsCount")+ .HasColumnType("integer");++ b.Property<int>("EmailClaimsCount")+ .HasColumnType("integer");++ b.Property<string>("EncryptionSettings")+ .HasColumnType("text");++ b.Property<string>("EncryptionType")+ .HasColumnType("text");++ b.Property<int>("FileSize")+ .HasColumnType("integer");++ b.Property<string>("ManifestBlob")+ .HasColumnType("text");++ b.Property<string>("ManifestCiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<string>("Salt")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("StorageFormat")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("VaultBlob")+ .HasColumnType("text");++ b.Property<string>("Verifier")+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<string>("Version")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("ManifestId", "RevisionNumber");++ b.ToTable("VaultManifestsHistory", (string)null);+ });++ modelBuilder.Entity("AliasVault.WorkerStatus.Database.WorkerServiceStatus", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("CurrentStatus")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("DesiredStatus")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<DateTime>("Heartbeat")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("ServiceName")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.ToTable("WorkerServiceStatuses");+ });++ modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("FriendlyName")+ .HasColumnType("text");++ b.Property<string>("Xml")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("DataProtectionKeys");+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("ClaimType")+ .HasColumnType("text");++ b.Property<string>("ClaimValue")+ .HasColumnType("text");++ b.Property<string>("RoleId")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("RoleClaims", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("ClaimType")+ .HasColumnType("text");++ b.Property<string>("ClaimValue")+ .HasColumnType("text");++ b.Property<string>("UserId")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("UserClaims", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>+ {+ b.Property<string>("LoginProvider")+ .HasColumnType("text");++ b.Property<string>("ProviderKey")+ .HasColumnType("text");++ b.Property<string>("ProviderDisplayName")+ .HasColumnType("text");++ b.Property<string>("UserId")+ .HasColumnType("text");++ b.HasKey("LoginProvider", "ProviderKey");++ b.ToTable("UserLogins", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>+ {+ b.Property<string>("UserId")+ .HasColumnType("text");++ b.Property<string>("RoleId")+ .HasColumnType("text");++ b.HasKey("UserId", "RoleId");++ b.ToTable("UserRoles", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>+ {+ b.Property<string>("UserId")+ .HasColumnType("text");++ b.Property<string>("LoginProvider")+ .HasColumnType("text");++ b.Property<string>("Name")+ .HasColumnType("text");++ b.Property<string>("Value")+ .HasColumnType("text");++ b.HasKey("UserId", "LoginProvider", "Name");++ b.ToTable("UserTokens", (string)null);+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.HasOne("AliasServerDb.Group", "PersonalGroup")+ .WithOne()+ .HasForeignKey("AliasServerDb.AliasVaultUser", "PersonalGroupId")+ .OnDelete(DeleteBehavior.Restrict)+ .IsRequired();++ b.Navigation("PersonalGroup");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.HasOne("AliasServerDb.VaultManifestDeliveryKey", "EncryptionKey")+ .WithMany("Emails")+ .HasForeignKey("EncryptionKeyId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("EncryptionKey");+ });++ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>+ {+ b.HasOne("AliasServerDb.Email", "Email")+ .WithMany("Attachments")+ .HasForeignKey("EmailId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Email");+ });++ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")+ .WithMany()+ .HasForeignKey("VaultManifestId")+ .OnDelete(DeleteBehavior.SetNull);++ b.Navigation("VaultManifest");+ });++ modelBuilder.Entity("AliasServerDb.GroupMember", b =>+ {+ b.HasOne("AliasServerDb.Group", "Group")+ .WithMany("Members")+ .HasForeignKey("GroupId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Group");++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.RateLimit", b =>+ {+ b.HasOne("AliasServerDb.Group", "Group")+ .WithMany()+ .HasForeignKey("GroupId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("Group");+ });++ modelBuilder.Entity("AliasServerDb.UserGrantKey", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.UserUnlockKey", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("OwnerUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")+ .WithMany()+ .HasForeignKey("ManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Manifest");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("OwnerUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucketsHistory", b =>+ {+ b.HasOne("AliasServerDb.VaultDataBucket", "Bucket")+ .WithMany()+ .HasForeignKey("OwnerUserId", "Category")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Bucket");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>+ {+ b.HasOne("AliasServerDb.Group", "OwnerGroup")+ .WithMany()+ .HasForeignKey("OwnerGroupId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("OwnerGroup");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestAccessKey", b =>+ {+ b.HasOne("AliasServerDb.UserGrantKey", "UserGrantKey")+ .WithMany()+ .HasForeignKey("UserGrantKeyId")+ .OnDelete(DeleteBehavior.SetNull);++ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("VaultManifestAccessKeys")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");++ b.Navigation("UserGrantKey");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")+ .WithMany()+ .HasForeignKey("VaultManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("VaultManifest");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")+ .WithMany()+ .HasForeignKey("ManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Manifest");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.Navigation("VaultManifestAccessKeys");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.Navigation("Attachments");+ });++ modelBuilder.Entity("AliasServerDb.Group", b =>+ {+ b.Navigation("Members");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>+ {+ b.Navigation("Emails");+ });+#pragma warning restore 612, 618+ }+ }+}diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260807200945_RenameRootManifestToPersonal.cs b/apps/server/Databases/AliasServerDb/Migrations/20260807200945_RenameRootManifestToPersonal.csnew file mode 100644index 000000000..6a4045396--- /dev/null+++ b/apps/server/Databases/AliasServerDb/Migrations/20260807200945_RenameRootManifestToPersonal.cs@@ -0,0 +1,50 @@+using Microsoft.EntityFrameworkCore.Migrations;++#nullable disable++namespace AliasServerDb.Migrations+{+ /// <inheritdoc />+ public partial class RenameRootManifestToPersonal : Migration+ {+ /// <inheritdoc />+ protected override void Up(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.DropIndex(+ name: "UX_VaultManifests_OwnerGroupId_Root",+ table: "VaultManifests");++ migrationBuilder.RenameColumn(+ name: "IsRoot",+ table: "VaultManifests",+ newName: "IsPersonal");++ migrationBuilder.CreateIndex(+ name: "UX_VaultManifests_OwnerGroupId_Personal",+ table: "VaultManifests",+ column: "OwnerGroupId",+ unique: true,+ filter: "\"IsPersonal\"");+ }++ /// <inheritdoc />+ protected override void Down(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.DropIndex(+ name: "UX_VaultManifests_OwnerGroupId_Personal",+ table: "VaultManifests");++ migrationBuilder.RenameColumn(+ name: "IsPersonal",+ table: "VaultManifests",+ newName: "IsRoot");++ migrationBuilder.CreateIndex(+ name: "UX_VaultManifests_OwnerGroupId_Root",+ table: "VaultManifests",+ column: "OwnerGroupId",+ unique: true,+ filter: "\"IsRoot\"");+ }+ }+}diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260807203750_SharedManifestsOwnedBySharedGroups.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260807203750_SharedManifestsOwnedBySharedGroups.Designer.csnew file mode 100644index 000000000..e8bd5bc1c--- /dev/null+++ b/apps/server/Databases/AliasServerDb/Migrations/20260807203750_SharedManifestsOwnedBySharedGroups.Designer.cs@@ -0,0 +1,1638 @@+// <auto-generated />+using System;+using AliasServerDb;+using Microsoft.EntityFrameworkCore;+using Microsoft.EntityFrameworkCore.Infrastructure;+using Microsoft.EntityFrameworkCore.Migrations;+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;++#nullable disable++namespace AliasServerDb.Migrations+{+ [DbContext(typeof(AliasServerDbContext))]+ [Migration("20260807203750_SharedManifestsOwnedBySharedGroups")]+ partial class SharedManifestsOwnedBySharedGroups+ {+ /// <inheritdoc />+ protected override void BuildTargetModel(ModelBuilder modelBuilder)+ {+#pragma warning disable 612, 618+ modelBuilder+ .HasAnnotation("ProductVersion", "10.0.10")+ .HasAnnotation("Proxies:ChangeTracking", false)+ .HasAnnotation("Proxies:CheckEquality", false)+ .HasAnnotation("Proxies:LazyLoading", true)+ .HasAnnotation("Relational:MaxIdentifierLength", 63);++ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);++ modelBuilder.Entity("AliasServerDb.AdminRole", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("text");++ b.Property<string>("Name")+ .HasColumnType("text");++ b.Property<string>("NormalizedName")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("AdminRoles");+ });++ modelBuilder.Entity("AliasServerDb.AdminUser", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<int>("AccessFailedCount")+ .HasColumnType("integer");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("text");++ b.Property<string>("Email")+ .HasColumnType("text");++ b.Property<bool>("EmailConfirmed")+ .HasColumnType("boolean");++ b.Property<DateTime?>("LastPasswordChanged")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("LockoutEnabled")+ .HasColumnType("boolean");++ b.Property<DateTimeOffset?>("LockoutEnd")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("NormalizedEmail")+ .HasColumnType("text");++ b.Property<string>("NormalizedUserName")+ .HasColumnType("text");++ b.Property<string>("PasswordHash")+ .HasColumnType("text");++ b.Property<string>("PhoneNumber")+ .HasColumnType("text");++ b.Property<bool>("PhoneNumberConfirmed")+ .HasColumnType("boolean");++ b.Property<string>("SecurityStamp")+ .HasColumnType("text");++ b.Property<bool>("TwoFactorEnabled")+ .HasColumnType("boolean");++ b.Property<string>("UserName")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("AdminUsers");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultRole", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("text");++ b.Property<string>("Name")+ .HasColumnType("text");++ b.Property<string>("NormalizedName")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("AliasVaultRoles");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<int>("AccessFailedCount")+ .HasColumnType("integer");++ b.Property<bool>("Blocked")+ .HasColumnType("boolean");++ b.Property<DateTime?>("BlockedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("text");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Email")+ .HasColumnType("text");++ b.Property<bool>("EmailConfirmed")+ .HasColumnType("boolean");++ b.Property<DateTime?>("LastActivityDate")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("LockoutEnabled")+ .HasColumnType("boolean");++ b.Property<DateTimeOffset?>("LockoutEnd")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("NormalizedEmail")+ .HasColumnType("text");++ b.Property<string>("NormalizedUserName")+ .HasColumnType("text");++ b.Property<DateTime>("PasswordChangedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("PasswordHash")+ .HasColumnType("text");++ b.Property<Guid>("PersonalGroupId")+ .HasColumnType("uuid");++ b.Property<string>("PhoneNumber")+ .HasColumnType("text");++ b.Property<bool>("PhoneNumberConfirmed")+ .HasColumnType("boolean");++ b.Property<string>("SecurityStamp")+ .HasColumnType("text");++ b.Property<string>("SrpIdentity")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<bool>("TwoFactorEnabled")+ .HasColumnType("boolean");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserName")+ .HasColumnType("text");++ b.HasKey("Id");++ b.HasIndex("PersonalGroupId")+ .IsUnique()+ .HasDatabaseName("UX_AliasVaultUsers_PersonalGroupId");++ b.ToTable("AliasVaultUsers");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("DeviceIdentifier")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime>("ExpireDate")+ .HasMaxLength(255)+ .HasColumnType("timestamp with time zone");++ b.Property<string>("IpAddress")+ .HasMaxLength(45)+ .HasColumnType("character varying(45)");++ b.Property<string>("PreviousTokenValue")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Value")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.ToTable("AliasVaultUserRefreshTokens");+ });++ modelBuilder.Entity("AliasServerDb.AuthLog", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("AdditionalInfo")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Browser")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("Client")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("Country")+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("DeviceType")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<int>("EventType")+ .HasColumnType("integer");++ b.Property<int?>("FailureReason")+ .HasColumnType("integer");++ b.Property<string>("IpAddress")+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<bool>("IsSuccess")+ .HasColumnType("boolean");++ b.Property<bool>("IsSuspiciousActivity")+ .HasColumnType("boolean");++ b.Property<string>("OperatingSystem")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("RequestPath")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<DateTime>("Timestamp")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Username")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex(new[] { "EventType" }, "IX_EventType");++ b.HasIndex(new[] { "IpAddress" }, "IX_IpAddress");++ b.HasIndex(new[] { "Timestamp" }, "IX_Timestamp");++ b.HasIndex(new[] { "Username", "IsSuccess", "Timestamp" }, "IX_Username_IsSuccess_Timestamp")+ .IsDescending(false, false, true);++ b.HasIndex(new[] { "Username", "Timestamp" }, "IX_Username_Timestamp")+ .IsDescending(false, true);++ b.ToTable("AuthLogs");+ });++ modelBuilder.Entity("AliasServerDb.BlockedIpRange", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<bool>("BlockLogin")+ .HasColumnType("boolean");++ b.Property<bool>("BlockRegistration")+ .HasColumnType("boolean");++ b.Property<bool>("BlockShadow")+ .HasColumnType("boolean");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("CreatedBy")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<bool>("Enabled")+ .HasColumnType("boolean");++ b.Property<string>("IpRange")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("Reason")+ .HasMaxLength(500)+ .HasColumnType("character varying(500)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("Id");++ b.HasIndex(new[] { "Enabled" }, "IX_BlockedIpRange_Enabled");++ b.HasIndex(new[] { "IpRange" }, "IX_BlockedIpRange_IpRange")+ .IsUnique();++ b.ToTable("BlockedIpRanges");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<DateTime>("Date")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime>("DateSystem")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedSymmetricKey")+ .IsRequired()+ .HasColumnType("text");++ b.Property<Guid>("EncryptionKeyId")+ .HasMaxLength(255)+ .HasColumnType("uuid");++ b.Property<string>("From")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("FromDomain")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("FromLocal")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("MessageHtml")+ .HasColumnType("text");++ b.Property<string>("MessagePlain")+ .HasColumnType("text");++ b.Property<string>("MessagePreview")+ .HasColumnType("text");++ b.Property<string>("MessageSource")+ .IsRequired()+ .HasColumnType("text");++ b.Property<bool>("PushNotificationSent")+ .HasColumnType("boolean");++ b.Property<string>("Subject")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("To")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("ToDomain")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("ToLocal")+ .IsRequired()+ .HasColumnType("text");++ b.Property<bool>("Visible")+ .HasColumnType("boolean");++ b.HasKey("Id");++ b.HasIndex("Date");++ b.HasIndex("DateSystem");++ b.HasIndex("EncryptionKeyId");++ b.HasIndex("PushNotificationSent");++ b.HasIndex("Visible");++ b.HasIndex("To", "DateSystem");++ b.ToTable("Emails");+ });++ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<byte[]>("Bytes")+ .IsRequired()+ .HasColumnType("bytea");++ b.Property<DateTime>("Date")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("EmailId")+ .HasColumnType("integer");++ b.Property<string>("Filename")+ .IsRequired()+ .HasColumnType("text");++ b.Property<int>("Filesize")+ .HasColumnType("integer");++ b.Property<string>("MimeType")+ .IsRequired()+ .HasColumnType("text");++ b.HasKey("Id");++ b.HasIndex("EmailId");++ b.ToTable("EmailAttachments");+ });++ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Address")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("AddressDomain")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("AddressLocal")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("Disabled")+ .HasColumnType("boolean");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid?>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("Address")+ .IsUnique();++ b.HasIndex("VaultManifestId", "CreatedAt");++ b.HasIndex("VaultManifestId", "Disabled");++ b.ToTable("EmailClaims");+ });++ modelBuilder.Entity("AliasServerDb.Group", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("EmailsReceived")+ .HasColumnType("integer");++ b.Property<int>("MaxEmailAgeDays")+ .HasColumnType("integer");++ b.Property<int>("MaxEmails")+ .HasColumnType("integer");++ b.Property<string>("Name")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<bool>("ShadowBlocked")+ .HasColumnType("boolean");++ b.Property<DateTime?>("ShadowBlockedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("Type")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("Id");++ b.ToTable("Groups");+ });++ modelBuilder.Entity("AliasServerDb.GroupMember", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid>("GroupId")+ .HasColumnType("uuid");++ b.Property<int>("Role")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.HasIndex("GroupId", "UserId")+ .IsUnique();++ b.ToTable("GroupMembers");+ });++ modelBuilder.Entity("AliasServerDb.Log", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("Application")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("Exception")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("Level")+ .IsRequired()+ .HasMaxLength(128)+ .HasColumnType("character varying(128)");++ b.Property<string>("LogEvent")+ .IsRequired()+ .HasColumnType("text")+ .HasColumnName("LogEvent");++ b.Property<string>("Message")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("MessageTemplate")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("Properties")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("SourceContext")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("TimeStamp")+ .HasColumnType("timestamp with time zone");++ b.HasKey("Id");++ b.HasIndex("Application");++ b.HasIndex("TimeStamp");++ b.ToTable("Logs", (string)null);+ });++ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<DateTime?>("ClearedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("ClientIpAddress")+ .HasColumnType("text");++ b.Property<string>("ClientPublicKey")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedDecryptionKey")+ .HasColumnType("text");++ b.Property<DateTime?>("FulfilledAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("MobileIpAddress")+ .HasColumnType("text");++ b.Property<DateTime?>("RetrievedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .HasColumnType("text");++ b.HasKey("Id");++ b.HasIndex(new[] { "ClientIpAddress" }, "IX_ClientIpAddress");++ b.HasIndex(new[] { "CreatedAt" }, "IX_CreatedAt");++ b.HasIndex(new[] { "MobileIpAddress" }, "IX_MobileIpAddress");++ b.HasIndex(new[] { "RetrievedAt", "ClearedAt", "FulfilledAt" }, "IX_RetrievedAt_ClearedAt_FulfilledAt");++ b.HasIndex(new[] { "UserId" }, "IX_UserId");++ b.ToTable("MobileLoginRequests");+ });++ modelBuilder.Entity("AliasServerDb.RateLimit", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<int?>("AppliesToAccountAgeMaxDays")+ .HasColumnType("integer");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("CreatedBy")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime?>("EffectiveFrom")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime?>("EffectiveUntil")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("Enabled")+ .HasColumnType("boolean");++ b.Property<Guid?>("GroupId")+ .HasColumnType("uuid");++ b.Property<int>("LimitType")+ .HasColumnType("integer");++ b.Property<int>("MaxCount")+ .HasColumnType("integer");++ b.Property<string>("Notes")+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<int?>("Tier")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("WindowSeconds")+ .HasColumnType("integer");++ b.HasKey("Id");++ b.HasIndex("GroupId");++ b.HasIndex("Tier");++ b.HasIndex("LimitType", "Enabled");++ b.ToTable("RateLimits");+ });++ modelBuilder.Entity("AliasServerDb.ServerSetting", b =>+ {+ b.Property<string>("Key")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Value")+ .HasColumnType("text");++ b.HasKey("Key");++ b.ToTable("ServerSettings");+ });++ modelBuilder.Entity("AliasServerDb.TaskRunnerJob", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<TimeOnly?>("EndTime")+ .HasColumnType("time without time zone");++ b.Property<string>("ErrorMessage")+ .HasColumnType("text");++ b.Property<bool>("IsOnDemand")+ .HasColumnType("boolean");++ b.Property<string>("Name")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<DateTime>("RunDate")+ .HasColumnType("timestamp with time zone");++ b.Property<TimeOnly>("StartTime")+ .HasColumnType("time without time zone");++ b.Property<int>("Status")+ .HasColumnType("integer");++ b.HasKey("Id");++ b.ToTable("TaskRunnerJobs");+ });++ modelBuilder.Entity("AliasServerDb.UserGrantKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedPrivateKey")+ .IsRequired()+ .HasMaxLength(4000)+ .HasColumnType("character varying(4000)");++ b.Property<bool>("IsPrimary")+ .HasColumnType("boolean");++ b.Property<string>("PublicKey")+ .IsRequired()+ .HasMaxLength(2000)+ .HasColumnType("character varying(2000)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId")+ .IsUnique()+ .HasDatabaseName("UX_UserGrantKeys_User_Primary")+ .HasFilter("\"IsPrimary\"");++ b.ToTable("UserGrantKeys");+ });++ modelBuilder.Entity("AliasServerDb.UserUnlockKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Algorithm")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedAccountKey")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime?>("LastUsedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Metadata")+ .HasColumnType("jsonb");++ b.Property<int>("Type")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId", "Type")+ .IsUnique()+ .HasDatabaseName("UX_UserUnlockKeys_UserId_Type");++ b.ToTable("UserUnlockKeys");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>+ {+ b.Property<string>("Hash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<string>("OwnerUserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Category")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<byte[]>("EncryptedData")+ .IsRequired()+ .HasColumnType("bytea");++ b.Property<DateTime>("LastReferencedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("SizeBytes")+ .HasColumnType("integer");++ b.HasKey("Hash", "OwnerUserId");++ b.HasIndex("OwnerUserId", "Category");++ b.ToTable("VaultBlobObjects");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>+ {+ b.Property<Guid>("ManifestId")+ .HasColumnType("uuid");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("BlobHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.HasKey("ManifestId", "RevisionNumber", "BlobHash");++ b.ToTable("VaultBlobReferences");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>+ {+ b.Property<string>("OwnerUserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Category")+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("CiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedData")+ .IsRequired()+ .HasColumnType("text");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("OwnerUserId", "Category");++ b.ToTable("VaultDataBuckets");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucketsHistory", b =>+ {+ b.Property<string>("OwnerUserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Category")+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("CiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedData")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("OwnerUserId", "Category", "RevisionNumber");++ b.ToTable("VaultDataBucketsHistory");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>+ {+ b.Property<Guid>("ManifestId")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Client")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("CredentialsCount")+ .HasColumnType("integer");++ b.Property<int>("EmailClaimsCount")+ .HasColumnType("integer");++ b.Property<string>("EncryptionSettings")+ .HasColumnType("text");++ b.Property<string>("EncryptionType")+ .HasColumnType("text");++ b.Property<int>("FileSize")+ .HasColumnType("integer");++ b.Property<string>("ManifestBlob")+ .HasColumnType("text");++ b.Property<string>("ManifestCiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<string>("Name")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<Guid>("OwnerGroupId")+ .HasColumnType("uuid");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("Salt")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("StorageFormat")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("VaultBlob")+ .HasColumnType("text");++ b.Property<string>("Verifier")+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<string>("Version")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("ManifestId");++ b.HasIndex("OwnerGroupId");++ b.ToTable("VaultManifests");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestAccessKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Algorithm")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedVek")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime?>("LastUsedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Metadata")+ .HasColumnType("jsonb");++ b.Property<int>("Type")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid?>("UserGrantKeyId")+ .HasColumnType("uuid");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<Guid>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("UserGrantKeyId");++ b.HasIndex("VaultManifestId")+ .HasDatabaseName("IX_VaultManifestAccessKeys_VaultManifestId");++ b.HasIndex("UserId", "Type", "VaultManifestId")+ .IsUnique()+ .HasDatabaseName("UX_VaultManifestAccessKeys_UserId_Type_Manifest");++ b.ToTable("VaultManifestAccessKeys");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("IsPrimary")+ .HasColumnType("boolean");++ b.Property<string>("PublicKey")+ .IsRequired()+ .HasMaxLength(2000)+ .HasColumnType("character varying(2000)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("VaultManifestId")+ .IsUnique()+ .HasDatabaseName("UX_VaultManifestDeliveryKeys_Manifest_Primary")+ .HasFilter("\"IsPrimary\"");++ b.HasIndex("VaultManifestId", "IsPrimary");++ b.ToTable("VaultManifestDeliveryKeys");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>+ {+ b.Property<Guid>("ManifestId")+ .HasColumnType("uuid");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("Client")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("CredentialsCount")+ .HasColumnType("integer");++ b.Property<int>("EmailClaimsCount")+ .HasColumnType("integer");++ b.Property<string>("EncryptionSettings")+ .HasColumnType("text");++ b.Property<string>("EncryptionType")+ .HasColumnType("text");++ b.Property<int>("FileSize")+ .HasColumnType("integer");++ b.Property<string>("ManifestBlob")+ .HasColumnType("text");++ b.Property<string>("ManifestCiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<string>("Salt")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("StorageFormat")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("VaultBlob")+ .HasColumnType("text");++ b.Property<string>("Verifier")+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<string>("Version")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("ManifestId", "RevisionNumber");++ b.ToTable("VaultManifestsHistory", (string)null);+ });++ modelBuilder.Entity("AliasVault.WorkerStatus.Database.WorkerServiceStatus", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("CurrentStatus")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("DesiredStatus")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<DateTime>("Heartbeat")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("ServiceName")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.ToTable("WorkerServiceStatuses");+ });++ modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("FriendlyName")+ .HasColumnType("text");++ b.Property<string>("Xml")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("DataProtectionKeys");+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("ClaimType")+ .HasColumnType("text");++ b.Property<string>("ClaimValue")+ .HasColumnType("text");++ b.Property<string>("RoleId")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("RoleClaims", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("ClaimType")+ .HasColumnType("text");++ b.Property<string>("ClaimValue")+ .HasColumnType("text");++ b.Property<string>("UserId")+ .HasColumnType("text");++ b.HasKey("Id");++ b.ToTable("UserClaims", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>+ {+ b.Property<string>("LoginProvider")+ .HasColumnType("text");++ b.Property<string>("ProviderKey")+ .HasColumnType("text");++ b.Property<string>("ProviderDisplayName")+ .HasColumnType("text");++ b.Property<string>("UserId")+ .HasColumnType("text");++ b.HasKey("LoginProvider", "ProviderKey");++ b.ToTable("UserLogins", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>+ {+ b.Property<string>("UserId")+ .HasColumnType("text");++ b.Property<string>("RoleId")+ .HasColumnType("text");++ b.HasKey("UserId", "RoleId");++ b.ToTable("UserRoles", (string)null);+ });++ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>+ {+ b.Property<string>("UserId")+ .HasColumnType("text");++ b.Property<string>("LoginProvider")+ .HasColumnType("text");++ b.Property<string>("Name")+ .HasColumnType("text");++ b.Property<string>("Value")+ .HasColumnType("text");++ b.HasKey("UserId", "LoginProvider", "Name");++ b.ToTable("UserTokens", (string)null);+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.HasOne("AliasServerDb.Group", "PersonalGroup")+ .WithOne()+ .HasForeignKey("AliasServerDb.AliasVaultUser", "PersonalGroupId")+ .OnDelete(DeleteBehavior.Restrict)+ .IsRequired();++ b.Navigation("PersonalGroup");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.HasOne("AliasServerDb.VaultManifestDeliveryKey", "EncryptionKey")+ .WithMany("Emails")+ .HasForeignKey("EncryptionKeyId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("EncryptionKey");+ });++ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>+ {+ b.HasOne("AliasServerDb.Email", "Email")+ .WithMany("Attachments")+ .HasForeignKey("EmailId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Email");+ });++ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")+ .WithMany()+ .HasForeignKey("VaultManifestId")+ .OnDelete(DeleteBehavior.SetNull);++ b.Navigation("VaultManifest");+ });++ modelBuilder.Entity("AliasServerDb.GroupMember", b =>+ {+ b.HasOne("AliasServerDb.Group", "Group")+ .WithMany("Members")+ .HasForeignKey("GroupId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Group");++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.RateLimit", b =>+ {+ b.HasOne("AliasServerDb.Group", "Group")+ .WithMany()+ .HasForeignKey("GroupId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("Group");+ });++ modelBuilder.Entity("AliasServerDb.UserGrantKey", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.UserUnlockKey", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("OwnerUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")+ .WithMany()+ .HasForeignKey("ManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Manifest");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("OwnerUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucketsHistory", b =>+ {+ b.HasOne("AliasServerDb.VaultDataBucket", "Bucket")+ .WithMany()+ .HasForeignKey("OwnerUserId", "Category")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Bucket");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>+ {+ b.HasOne("AliasServerDb.Group", "OwnerGroup")+ .WithMany()+ .HasForeignKey("OwnerGroupId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("OwnerGroup");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestAccessKey", b =>+ {+ b.HasOne("AliasServerDb.UserGrantKey", "UserGrantKey")+ .WithMany()+ .HasForeignKey("UserGrantKeyId")+ .OnDelete(DeleteBehavior.SetNull);++ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("VaultManifestAccessKeys")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");++ b.Navigation("UserGrantKey");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")+ .WithMany()+ .HasForeignKey("VaultManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("VaultManifest");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")+ .WithMany()+ .HasForeignKey("ManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Manifest");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.Navigation("VaultManifestAccessKeys");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.Navigation("Attachments");+ });++ modelBuilder.Entity("AliasServerDb.Group", b =>+ {+ b.Navigation("Members");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>+ {+ b.Navigation("Emails");+ });+#pragma warning restore 612, 618+ }+ }+}diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260807203750_SharedManifestsOwnedBySharedGroups.cs b/apps/server/Databases/AliasServerDb/Migrations/20260807203750_SharedManifestsOwnedBySharedGroups.csnew file mode 100644index 000000000..bd501d0cf--- /dev/null+++ b/apps/server/Databases/AliasServerDb/Migrations/20260807203750_SharedManifestsOwnedBySharedGroups.cs@@ -0,0 +1,56 @@+using Microsoft.EntityFrameworkCore.Migrations;++#nullable disable++namespace AliasServerDb.Migrations+{+ /// <inheritdoc />+ public partial class SharedManifestsOwnedBySharedGroups : Migration+ {+ /// <inheritdoc />+ protected override void Up(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.DropIndex(+ name: "UX_VaultManifests_OwnerGroupId_Personal",+ table: "VaultManifests");++ migrationBuilder.DropColumn(+ name: "IsPersonal",+ table: "VaultManifests");++ migrationBuilder.CreateIndex(+ name: "IX_VaultManifests_OwnerGroupId",+ table: "VaultManifests",+ column: "OwnerGroupId");+ }++ /// <inheritdoc />+ protected override void Down(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.DropIndex(+ name: "IX_VaultManifests_OwnerGroupId",+ table: "VaultManifests");++ migrationBuilder.AddColumn<bool>(+ name: "IsPersonal",+ table: "VaultManifests",+ type: "boolean",+ nullable: false,+ defaultValue: false);++ migrationBuilder.Sql("""+ UPDATE "VaultManifests" m+ SET "IsPersonal" = TRUE+ FROM "Groups" g+ WHERE g."Id" = m."OwnerGroupId" AND g."Type" = 0;+ """);++ migrationBuilder.CreateIndex(+ name: "UX_VaultManifests_OwnerGroupId_Personal",+ table: "VaultManifests",+ column: "OwnerGroupId",+ unique: true,+ filter: "\"IsPersonal\"");+ }+ }+}diff --git a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.csindex a4ac1b5b1..4e69c51d4 100644--- a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs+++ b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs@@ -1053,9 +1053,6 @@ namespace AliasServerDb.Migrationsb.Property<int>("FileSize").HasColumnType("integer");- b.Property<bool>("IsRoot")- .HasColumnType("boolean");-b.Property<string>("ManifestBlob").HasColumnType("text");@@ -1098,10 +1095,7 @@ namespace AliasServerDb.Migrationsb.HasKey("ManifestId");- b.HasIndex("OwnerGroupId")- .IsUnique()- .HasDatabaseName("UX_VaultManifests_OwnerGroupId_Root")- .HasFilter("\"IsRoot\"");+ b.HasIndex("OwnerGroupId");b.ToTable("VaultManifests");});diff --git a/apps/server/Databases/AliasServerDb/VaultManifest.cs b/apps/server/Databases/AliasServerDb/VaultManifest.csindex 101f49df8..68c036635 100644--- a/apps/server/Databases/AliasServerDb/VaultManifest.cs+++ b/apps/server/Databases/AliasServerDb/VaultManifest.cs@@ -12,8 +12,8 @@ using System.ComponentModel.DataAnnotations.Schema;/// <summary>/// The current revision of a logical vault manifest. Exactly one row per logical manifest; superseded revisions are/// archived in <see cref="VaultManifestsHistory"/> before this row is updated in place, so this table can never hold-/// two rows for the same manifest. A user's logical vault is assembled from one or more manifests: exactly one root-/// manifest plus (from R2, FamilyVault sharing) any number of non-root manifests.+/// two rows for the same manifest. A user's logical vault is assembled from one or more manifests: the single manifest+/// owned by their personal group, plus any number owned by the shared groups they belong to./// </summary>public class VaultManifest : VaultManifestBase{@@ -23,11 +23,6 @@ public class VaultManifest : VaultManifestBase[Key]public Guid ManifestId { get; set; }- /// <summary>- /// Gets or sets a value indicating whether this manifest is the user's root manifest.- /// </summary>- public required bool IsRoot { get; set; }-/// <summary>/// Gets or sets the optional display name of a manifest. Used in e.g. sharing UI./// </summary>diff --git a/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs b/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.csindex a7960e8c5..4b027499e 100644--- a/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs+++ b/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs@@ -188,4 +188,19 @@ public enum ApiErrorCode/// The supplied algorithm is not valid for the requested operation./// </summary>INVALID_ALGORITHM,++ /// <summary>+ /// The supplied manifest id is missing or malformed. Retrying the request unchanged cannot succeed.+ /// </summary>+ MANIFEST_ID_INVALID,++ /// <summary>+ /// The supplied manifest id is already in use by a different manifest. The client must mint a fresh id and retry.+ /// </summary>+ MANIFEST_ID_TAKEN,++ /// <summary>+ /// The referenced group does not exist, is not a shared group, or is not one the caller may administer.+ /// </summary>+ GROUP_NOT_FOUND,}diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedManifestRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedManifestRequest.csindex 74b53c3a7..3703c0442 100644--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedManifestRequest.cs+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedManifestRequest.cs@@ -8,7 +8,7 @@namespace AliasVault.Shared.Models.WebApi.V2.Sharing;/// <summary>-/// Request for POST /v2/Sharing/manifests. Creates a new non-root (shareable) manifest owned by the caller. The+/// Request for POST /v2/Sharing/manifests. Creates a new shared (non-personal) manifest owned by the caller. The/// manifest's VEK is generated client-side and encrypted for the caller's *own* public key, persisted as a/// <c>shared</c> grant in the same call./// </summary>@@ -21,6 +21,11 @@ public class CreateSharedManifestRequest/// <summary>Gets or sets the plaintext display name of the manifest (server-visible for the sharing UI).</summary>public required string Name { get; set; }+ /// <summary>+ /// Gets or sets the shared group to file this manifest under.+ /// </summary>+ public required Guid GroupId { get; set; }+/// <summary>Gets or sets the encrypted manifest blob (AES-GCM ciphertext under the manifest VEK, base64).</summary>public required string ManifestBlob { get; set; }diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Status/StatusResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Status/StatusResponse.csindex 8c009ed62..e4cca832e 100644--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Status/StatusResponse.cs+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Status/StatusResponse.cs@@ -39,6 +39,12 @@ public class StatusResponse/// </summary>public List<ManifestRevision> ManifestRevisions { get; set; } = [];+ /// <summary>+ /// Gets or sets the caller's personal manifest id: the single manifest owned by their personal group. Every other+ /// entry in <see cref="ManifestRevisions"/> is a shared one. Null for a user still on the legacy sqlite-blob format.+ /// </summary>+ public Guid? PersonalManifestId { get; set; }+/// <summary>Gets or sets the latest revision for each data-bucket kind the user has. Empty when none stored.</summary>public List<BucketRevision> BucketRevisions { get; set; } = [];}diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ClaimedEmailAddress.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ClaimedEmailAddress.csindex 42bdba560..40ed19416 100644--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ClaimedEmailAddress.cs+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ClaimedEmailAddress.cs@@ -10,7 +10,7 @@ namespace AliasVault.Shared.Models.WebApi.V2.Vault;/// <summary>/// An email alias the client claims, together with the manifest holding the item it belongs to. The manifest/// decides how the alias's mail is encrypted: a shared manifest's published keypair (readable by every member)-/// or, for the caller's root manifest, their own primary personal key.+/// or, for the caller's personal manifest, their own primary personal key./// </summary>public class ClaimedEmailAddress{diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/GetResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/GetResponse.csindex 99dcf245d..257312c61 100644--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/GetResponse.cs+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/GetResponse.cs@@ -32,9 +32,10 @@ public class GetResponsepublic long? LegacyRevision { get; set; }/// <summary>- /// Gets or sets the caller's root manifest id.+ /// Gets or sets the caller's personal manifest id: the single manifest owned by their personal group. Every other+ /// entry in <see cref="Manifests"/> is a shared one. Also set on the legacy sqlite-blob path, where the list is empty./// </summary>- public Guid? RootManifestId { get; set; }+ public Guid? PersonalManifestId { get; set; }/// <summary>/// Gets or sets the manifests that make up the user's logical vault. Empty for legacy sqlite-blobs.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 c7e810b2c..4fdd43ff7 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@@ -9,19 +9,15 @@ namespace AliasVault.Shared.Models.WebApi.V2.Vault;/// <summary>/// A single vault manifest as carried in list-based payloads. A user's logical vault is assembled from one or more-/// manifests: exactly one root manifest plus, any number of non-root manifests the user owns or has been-/// granted access to. Each manifest is independently encrypted and revisioned, and carries its own blob references.+/// manifests: the one owned by their personal group plus any number owned by shared groups they belong to.+/// Which is which follows from <see cref="GetResponse.PersonalManifestId"/>, not from a flag on each entry. Each+/// manifest is independently encrypted and revisioned, and carries its own blob references./// </summary>public class Manifest{/// <summary>Gets or sets the stable identifier of the logical manifest (constant across its revisions).</summary>public required Guid ManifestId { get; set; }- /// <summary>- /// Gets or sets a value indicating whether this is the user's root manifest.- /// </summary>- public required bool IsRoot { get; set; }-/// <summary>Gets or sets the encrypted manifest blob (base64 of AES-GCM ciphertext) — null on empty vault.</summary>public string? Blob { get; set; }@@ -34,7 +30,7 @@ public class Manifest/// <summary>Gets or sets the blob references this manifest revision needs (so the client can detect cache misses).</summary>public List<BlobReference> BlobReferences { get; set; } = [];- /// <summary>Gets or sets the plaintext display name of a shared manifest. Null for the root manifest.</summary>+ /// <summary>Gets or sets the plaintext display name of a shared manifest. Null for the personal manifest.</summary>public string? Name { get; set; }/// <summary>diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestRevision.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestRevision.csindex 3102795d9..ff733930d 100644--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestRevision.cs+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestRevision.cs@@ -16,9 +16,6 @@ public class ManifestRevision/// <summary>Gets or sets the stable identifier of the logical manifest.</summary>public required Guid ManifestId { get; set; }- /// <summary>Gets or sets a value indicating whether this is the user's root manifest.</summary>- public required bool IsRoot { get; set; }-/// <summary>Gets or sets the current (latest) revision number for this manifest.</summary>public required long Revision { get; set; }}diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestWrite.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestWrite.csindex 0f2255953..97593dd1f 100644--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestWrite.cs+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestWrite.cs@@ -12,11 +12,8 @@ namespace AliasVault.Shared.Models.WebApi.V2.Vault;/// </summary>public class ManifestWrite{- /// <summary>Gets or sets a value indicating whether this write targets the caller's root manifest.</summary>- public bool IsRoot { get; set; }-- /// <summary>Gets or sets the target shared manifest id.</summary>- public Guid? ManifestId { get; set; }+ /// <summary>Gets or sets the manifest this write targets.</summary>+ public required Guid ManifestId { get; set; }/// <summary>Gets or sets the encrypted manifest blob.</summary>public required string ManifestBlob { get; set; }@@ -31,14 +28,14 @@ public class ManifestWritepublic int CredentialsCount { get; set; }/// <summary>Gets or sets the complete list of blob hashes this manifest revision references. The server validates- /// each exists (in the caller's store for the root manifest; in any member's store for a shared manifest) before committing.</summary>+ /// each exists (in the caller's store for their personal manifest; in any member's store for a shared manifest) before committing.</summary>public List<BlobReference> BlobReferences { get; set; } = [];/// <summary>/// Gets or sets the encrypted VEK of the vault encryption key encrypted with the password-derived KEK using AES-256-GCM./// Set on the legacy user's first manifest-v1 write, where the client re-encrypts the whole vault under a fresh VEK;/// the server creates the password VaultKey for this manifest in the same transaction. Null on every subsequent write.- /// Only valid on the root write; a non-root write carrying it is rejected rather than silently ignored.+ /// Only valid on the write targeting the caller's personal manifest; a shared-manifest write carrying it is rejected rather than silently ignored./// TODO: remove once the legacy sqlite-blob format is fully deprecated and we don't support legacy users anymore./// </summary>public string? EncryptedVek { get; set; } // base64(IV | ciphertext | authTag)diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestWriteResult.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestWriteResult.csindex 7addf1b37..5e6ffe170 100644--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestWriteResult.cs+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestWriteResult.cs@@ -12,11 +12,8 @@ namespace AliasVault.Shared.Models.WebApi.V2.Vault;/// </summary>public class ManifestWriteResult{- /// <summary>Gets or sets a value indicating whether this result is for the caller's root manifest.</summary>- public bool IsRoot { get; set; }-- /// <summary>Gets or sets the manifest id (null for the root manifest).</summary>- public Guid? ManifestId { get; set; }+ /// <summary>Gets or sets the manifest this result is for.</summary>+ public required Guid ManifestId { get; set; }/// <summary>Gets or sets the revision.</summary>public required long Revision { get; set; }diff --git a/apps/server/Tests/AliasVault.E2ETests/Tests/Admin/UserManagementTests.cs b/apps/server/Tests/AliasVault.E2ETests/Tests/Admin/UserManagementTests.csindex 849397ebe..ca555c5b2 100644--- a/apps/server/Tests/AliasVault.E2ETests/Tests/Admin/UserManagementTests.cs+++ b/apps/server/Tests/AliasVault.E2ETests/Tests/Admin/UserManagementTests.cs@@ -55,7 +55,6 @@ public class UserManagementTests : AdminPlaywrightTestvar testVault = new VaultManifest{ManifestId = Guid.NewGuid(),- IsRoot = true,OwnerUserId = _testUserId,StorageFormat = "sqlite-blob",Version = "1.0.0",diff --git a/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbSyncTests.cs b/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbSyncTests.csindex f34cdd3c8..28b1af681 100644--- a/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbSyncTests.cs+++ b/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbSyncTests.cs@@ -242,7 +242,7 @@ public class DbSyncTests : ClientPlaywrightTest}/// <summary>- /// Returns a detached snapshot of the current (root) vault manifest row.+ /// Returns a detached snapshot of the current (personal) vault manifest row./// </summary>private async Task<AliasServerDb.VaultManifest> SnapshotCurrentVault(){diff --git a/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbUpgradeTests.cs b/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbUpgradeTests.csindex 39301b25c..21a0eb715 100644--- a/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbUpgradeTests.cs+++ b/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard2/DbUpgradeTests.cs@@ -49,7 +49,7 @@ public class DbUpgradeTests : ClientPlaywrightTest// Overwrite the user's current vault with the static 1.0.0 vault (the current row is updated in place;// the VaultManifests table holds exactly one row per manifest).- var currentVault = ApiDbContext.VaultManifests.First(x => x.OwnerUserId == user.Id && x.IsRoot);+ var currentVault = ApiDbContext.VaultManifests.First(x => x.OwnerUserId == user.Id);currentVault.CopyPayloadFrom(new VaultManifestsHistory{diff --git a/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/VaultUpgradeTests.cs b/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/VaultUpgradeTests.csindex 350f1f418..84e541e61 100644--- a/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/VaultUpgradeTests.cs+++ b/apps/server/Tests/AliasVault.E2ETests/Tests/Extensions/VaultUpgradeTests.cs@@ -52,7 +52,7 @@ public class VaultUpgradeTests : BrowserExtensionPlaywrightTest// Overwrite the user's current vault with the static 1.0.0 vault (the current row is updated in place;// the VaultManifests table holds exactly one row per manifest).- var currentVault = ApiDbContext.VaultManifests.First(x => x.OwnerUserId == user.Id && x.IsRoot);+ var currentVault = ApiDbContext.VaultManifests.First(x => x.OwnerUserId == user.Id);currentVault.CopyPayloadFrom(new VaultManifestsHistory{diff --git a/apps/server/Tests/AliasVault.UnitTests/Vault/RetentionManager/GeneralRetentionTests.cs b/apps/server/Tests/AliasVault.UnitTests/Vault/RetentionManager/GeneralRetentionTests.csindex c5bb23da8..5280ec8c1 100644--- a/apps/server/Tests/AliasVault.UnitTests/Vault/RetentionManager/GeneralRetentionTests.cs+++ b/apps/server/Tests/AliasVault.UnitTests/Vault/RetentionManager/GeneralRetentionTests.cs@@ -242,7 +242,6 @@ public class GeneralRetentionTestsvar now = DateTime.Now;var newVault = new VaultManifest{- IsRoot = true,VaultBlob = string.Empty,StorageFormat = "sqlite-blob",Version = string.Empty,diff --git a/core/models/src/webapi/StatusResponseV2.ts b/core/models/src/webapi/StatusResponseV2.tsindex 5c08bb3ce..c6266c5e3 100644--- a/core/models/src/webapi/StatusResponseV2.ts+++ b/core/models/src/webapi/StatusResponseV2.ts@@ -3,7 +3,6 @@*/export type ManifestRevision = {manifestId: string;- isRoot: boolean;revision: number;}@@ -14,5 +13,7 @@ export type StatusResponseV2 = {clientVersionSupported: boolean;serverVersion: string;manifestRevisions: ManifestRevision[];+ /** The manifest owned by the user's personal group; every other entry is a shared one. */+ personalManifestId: string | null;srpSalt: string;}diff --git a/core/rust/src/vault_codec/scoped_assets.rs b/core/rust/src/vault_codec/scoped_assets.rsindex 0485daed3..60aa9ce3d 100644--- a/core/rust/src/vault_codec/scoped_assets.rs+++ b/core/rust/src/vault_codec/scoped_assets.rs@@ -7,7 +7,7 @@//! - `Kind = "custom"`, `Source` = the sha256 of the image the user uploaded.//!//! A logo is scoped to the manifest that owns it:-//! - `ManifestId` is the owning manifest's id: the root manifest's id for personal logos, the+//! - `ManifestId` is the owning manifest's id: the personal manifest's id for personal logos, the//! owning shared manifest's id for logos living in a shared manifest (no NULL convention);//! - `Id` is derived from `(manifest id, Kind, Source)` (see [`logo_id_for`]), so every writer//! independently mints the same id for the same logo in the same manifest, the uniqueness@@ -56,7 +56,7 @@ const FAVICON_ID_NAMESPACE: &str = "aliasvault:logo:v1";/// devices (or two members of one shared manifest) that fetch the same domain, or upload the very same/// image, produce the same row, which then merges by ordinary LWW.///-/// `manifest_id` is the owning manifest's id — the root manifest's own id for personal logos (every+/// `manifest_id` is the owning manifest's id — the personal manifest's own id for personal logos (every/// vault derives distinct ids for the same domain, so two vaults materialized side by side can never/// collide). `source` is matched case-insensitively (callers already normalize to a lowercase/// hostname or lowercase hex digest; this makes it robust anyway).@@ -112,7 +112,7 @@ fn natural_key(row: &CodecRecord) -> Option<(String, String)> {/// re-mint `Id` from `(scope, Kind, Source)`, collapse rows that now share a natural key (keeping/// the better row, see [`is_better_logo`]), and repoint every `Items.LogoId` at the surviving row.///-/// This runs per manifest — the root's table set with the root manifest id, each shared partition's+/// This runs per manifest — the personal manifest's table set with its own id, each shared partition's/// with its own manifest id — so it never merges a personal logo with a shared one. It both migrates/// legacy rows (random GUIDs, folder-id or NULL scopes) and heals a writer that stamped the wrong scope.pub(super) fn normalize_logo_scope(tables: &mut HashMap<String, Vec<CodecRecord>>, scope: &str) {diff --git a/core/rust/src/vault_codec/types.rs b/core/rust/src/vault_codec/types.rsindex ee0e28deb..974165c37 100644--- a/core/rust/src/vault_codec/types.rs+++ b/core/rust/src/vault_codec/types.rs@@ -30,7 +30,7 @@ pub static BUCKET_TABLES: &[(&str, &str)] = &[("Settings", "Settings"),];-/// Tables that belong exclusively to the user's own (root) vault, never to a shared manifest.+/// Tables that belong exclusively to the user's own (personal) vault, never to a shared manifest./// Canonicalize never routes these into a shared partition and will refuse to materialize if they/// are found in a shared manifest anyway. Empty today (bucketed tables are implicitly personal, see/// [`is_personal_table`]); kept as the declaration point for future personal-only tables.diff --git a/core/rust/src/wasm.rs b/core/rust/src/wasm.rsindex a0394b65f..762217599 100644--- a/core/rust/src/wasm.rs+++ b/core/rust/src/wasm.rs@@ -245,7 +245,7 @@ pub fn vault_codec_compute_content_fingerprint_js(payload_json: &str) -> String}/// Extract the encryption-key row whose `PublicKey` matches `public_key` from a decrypted manifest's-/// `EncryptionKeys` table (scoped to the manifest itself: personal keys on the root manifest, the folder's+/// `EncryptionKeys` table (scoped to the manifest itself: personal keys on the personal manifest, the folder's/// delivery keypair on a shared manifest).#[wasm_bindgen(js_name = vaultCodecExtractEncryptionKeyForPublicKey)]pub fn vault_codec_extract_encryption_key_for_public_key_js(manifest: JsValue, public_key: &str) -> Result<JsValue, JsValue> {