Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add new core vault storage table definitions (#2159)
Leendert de Borstdf0eaea890c3
diff --git a/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs b/apps/server/Databases/AliasServerDb/AliasServerDbContext.csindex 67216e2dc..2d7e1bc42 100644--- a/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs+++ b/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs@@ -93,9 +93,10 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyConpublic DbSet<AdminRole> AdminRoles { get; set; }/// <summary>- /// Gets or sets the Vaults DbSet.+ /// Gets or sets the VaultManifests DbSet. Each row is one revision of a manifest; rows sharing a ManifestId are+ /// revisions of the same logical manifest (the user's main vault, or an R2 shared folder)./// </summary>- public DbSet<Vault> Vaults { get; set; }+ public DbSet<VaultManifest> VaultManifests { get; set; }/// <summary>/// Gets or sets the Emails DbSet.@@ -147,6 +148,21 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyCon/// </summary>public DbSet<BlockedIpRange> BlockedIpRanges { get; set; }+ /// <summary>+ /// Gets or sets the VaultDataBuckets DbSet. These represent separately-syncable per-user, per-kind sync buckets. Separate from main manifest.+ /// </summary>+ public DbSet<VaultDataBucket> VaultDataBuckets { get; set; }++ /// <summary>+ /// Gets or sets the VaultBlobObjects DbSet. These represent encrypted blobs referenced by one or more vault revisions.+ /// </summary>+ public DbSet<VaultBlobObject> VaultBlobObjects { get; set; }++ /// <summary>+ /// Gets or sets the VaultBlobReferences DbSet. These represent references from vaults to encrypted blobs.+ /// </summary>+ public DbSet<VaultBlobReference> VaultBlobReferences { get; set; }+/// <summary>/// Sets up the connection string if it is not already configured./// </summary>@@ -249,12 +265,18 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyConbuilder.HasIndex(e => e.Application);});- // Configure Vault - AliasVaultUser relationship- modelBuilder.Entity<Vault>()- .HasOne(l => l.User)- .WithMany(c => c.Vaults)- .HasForeignKey(l => l.UserId)- .OnDelete(DeleteBehavior.Cascade);+ // Configure VaultManifest - AliasVaultUser relationship + manifest-lineage indexing.+ modelBuilder.Entity<VaultManifest>(builder =>+ {+ builder.HasOne(l => l.User)+ .WithMany(c => c.VaultManifests)+ .HasForeignKey(l => l.OwnerUserId)+ .OnDelete(DeleteBehavior.Cascade);+ builder.Property(e => e.Category).HasConversion<string>().HasMaxLength(20);++ // Revisions of one logical manifest share a ManifestId; index supports "latest revision of a manifest".+ builder.HasIndex(e => new { e.ManifestId, e.RevisionNumber });+ });// Configure UserEmailClaim - AliasVaultUser relationship// Note: when a user is deleted the email claims user FK's should be set to NULL@@ -285,5 +307,38 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyCon.WithMany().HasForeignKey(m => m.UserId).OnDelete(DeleteBehavior.Cascade);++ // Configure VaultDataBucket - Id PK with a revision history per (UserId, Kind).+ modelBuilder.Entity<VaultDataBucket>(builder =>+ {+ builder.HasKey(e => e.RevisionId);+ builder.Property(e => e.Category).HasConversion<string>().HasMaxLength(50);+ builder.HasIndex(e => new { e.OwnerUserId, e.Category, e.RevisionNumber }).IsUnique();+ builder.HasOne(e => e.User)+ .WithMany()+ .HasForeignKey(e => e.OwnerUserId)+ .OnDelete(DeleteBehavior.Cascade);+ });++ // Configure VaultBlobObject - composite key (Hash, UserId).+ modelBuilder.Entity<VaultBlobObject>(builder =>+ {+ builder.HasKey(e => new { e.Hash, e.OwnerUserId });+ builder.HasIndex(e => new { e.OwnerUserId, e.Category });+ builder.HasOne(e => e.User)+ .WithMany()+ .HasForeignKey(e => e.OwnerUserId)+ .OnDelete(DeleteBehavior.Cascade);+ });++ // Configure VaultBlobReference - composite key (VaultId, BlobHash).+ modelBuilder.Entity<VaultBlobReference>(builder =>+ {+ builder.HasKey(e => new { e.ManifestRevisionId, e.BlobHash });+ builder.HasOne(e => e.ManifestRevision)+ .WithMany()+ .HasForeignKey(e => e.ManifestRevisionId)+ .OnDelete(DeleteBehavior.Cascade);+ });}}diff --git a/apps/server/Databases/AliasServerDb/AliasVaultUser.cs b/apps/server/Databases/AliasServerDb/AliasVaultUser.csindex f98c0fbdb..5e8fb1066 100644--- a/apps/server/Databases/AliasServerDb/AliasVaultUser.cs+++ b/apps/server/Databases/AliasServerDb/AliasVaultUser.cs@@ -83,9 +83,9 @@ public class AliasVaultUser : IdentityUserpublic int EmailsReceived { get; set; } = 0;/// <summary>- /// Gets or sets the collection of vaults.+ /// Gets or sets the collection of vault manifest revisions owned by this user (across all manifests and kinds)./// </summary>- public virtual ICollection<Vault> Vaults { get; set; } = [];+ public virtual ICollection<VaultManifest> VaultManifests { get; set; } = [];/// <summary>/// Gets or sets the collection of EmailClaims.diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260611122937_AddVaultV2Storage.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260611122937_AddVaultV2Storage.Designer.csnew file mode 100644index 000000000..605209034--- /dev/null+++ b/apps/server/Databases/AliasServerDb/Migrations/20260611122937_AddVaultV2Storage.Designer.cs@@ -0,0 +1,1182 @@+// <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("20260611122937_AddVaultV2Storage")]+ partial class AddVaultV2Storage+ {+ /// <inheritdoc />+ protected override void BuildTargetModel(ModelBuilder modelBuilder)+ {+#pragma warning disable 612, 618+ modelBuilder+ .HasAnnotation("ProductVersion", "10.0.6")+ .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<int>("EmailsReceived")+ .HasColumnType("integer");++ 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<int>("MaxEmailAgeDays")+ .HasColumnType("integer");++ b.Property<int>("MaxEmails")+ .HasColumnType("integer");++ 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<string>("PhoneNumber")+ .HasColumnType("text");++ b.Property<bool>("PhoneNumberConfirmed")+ .HasColumnType("boolean");++ b.Property<string>("SecurityStamp")+ .HasColumnType("text");++ b.Property<bool>("ShadowBlocked")+ .HasColumnType("boolean");++ b.Property<DateTime?>("ShadowBlockedAt")+ .HasColumnType("timestamp with time zone");++ 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.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<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<Guid>("UserEncryptionKeyId")+ .HasMaxLength(255)+ .HasColumnType("uuid");++ b.Property<bool>("Visible")+ .HasColumnType("boolean");++ b.HasKey("Id");++ b.HasIndex("Date");++ b.HasIndex("DateSystem");++ b.HasIndex("PushNotificationSent");++ b.HasIndex("UserEncryptionKeyId");++ 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.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.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.UserEmailClaim", 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<string>("UserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("Address")+ .IsUnique();++ b.HasIndex("UserId", "Disabled");++ b.ToTable("UserEmailClaims");+ });++ modelBuilder.Entity("AliasServerDb.UserEncryptionKey", 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<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.ToTable("UserEncryptionKeys");+ });++ modelBuilder.Entity("AliasServerDb.Vault", b =>+ {+ b.Property<Guid>("Id")+ .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")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("EncryptionType")+ .IsRequired()+ .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<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("Salt")+ .IsRequired()+ .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>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("VaultBlob")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("Verifier")+ .IsRequired()+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<string>("Version")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.ToTable("Vaults");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>+ {+ b.Property<string>("Hash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<string>("UserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<byte[]>("EncryptedData")+ .IsRequired()+ .HasColumnType("bytea");++ b.Property<string>("Kind")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("LastReferencedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("SizeBytes")+ .HasColumnType("integer");++ b.HasKey("Hash", "UserId");++ b.HasIndex("UserId", "Kind");++ b.ToTable("VaultBlobObjects");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>+ {+ b.Property<Guid>("VaultId")+ .HasColumnType("uuid");++ b.Property<string>("BlobHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.HasKey("VaultId", "BlobHash");++ b.ToTable("VaultBlobReferences");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ 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<string>("Kind")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ 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", "Kind", "RevisionNumber")+ .IsUnique();++ b.ToTable("VaultDataBuckets");+ });++ 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.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.UserEncryptionKey", "EncryptionKey")+ .WithMany("Emails")+ .HasForeignKey("UserEncryptionKeyId")+ .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.MobileLoginRequest", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.UserEmailClaim", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("EmailClaims")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.SetNull);++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("EncryptionKeys")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.Vault", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("Vaults")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>+ {+ b.HasOne("AliasServerDb.Vault", "Vault")+ .WithMany()+ .HasForeignKey("VaultId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Vault");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.Navigation("EmailClaims");++ b.Navigation("EncryptionKeys");++ b.Navigation("Vaults");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.Navigation("Attachments");+ });++ modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>+ {+ b.Navigation("Emails");+ });+#pragma warning restore 612, 618+ }+ }+}diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260611122937_AddVaultV2Storage.cs b/apps/server/Databases/AliasServerDb/Migrations/20260611122937_AddVaultV2Storage.csnew file mode 100644index 000000000..e5fa5f96c--- /dev/null+++ b/apps/server/Databases/AliasServerDb/Migrations/20260611122937_AddVaultV2Storage.cs@@ -0,0 +1,151 @@+using System;+using Microsoft.EntityFrameworkCore.Migrations;++#nullable disable++namespace AliasServerDb.Migrations+{+ /// <inheritdoc />+ public partial class AddVaultV2Storage : Migration+ {+ /// <inheritdoc />+ protected override void Up(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.AddColumn<string>(+ name: "ManifestBlob",+ table: "Vaults",+ type: "text",+ nullable: true);++ migrationBuilder.AddColumn<string>(+ name: "ManifestCiphertextHash",+ table: "Vaults",+ type: "character varying(64)",+ maxLength: 64,+ nullable: true);++ // Add nullable, backfill every existing (legacy) vault explicitly, then enforce NOT NULL. This avoids+ // leaving a persistent column default — the storage format is always set explicitly by the app.+ migrationBuilder.AddColumn<string>(+ name: "StorageFormat",+ table: "Vaults",+ type: "character varying(20)",+ maxLength: 20,+ nullable: true);++ migrationBuilder.Sql("UPDATE \"Vaults\" SET \"StorageFormat\" = 'sqlite-blob' WHERE \"StorageFormat\" IS NULL;");++ migrationBuilder.AlterColumn<string>(+ name: "StorageFormat",+ table: "Vaults",+ type: "character varying(20)",+ maxLength: 20,+ nullable: false,+ oldClrType: typeof(string),+ oldType: "character varying(20)",+ oldMaxLength: 20,+ oldNullable: true);++ migrationBuilder.CreateTable(+ name: "VaultBlobObjects",+ columns: table => new+ {+ Hash = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),+ UserId = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),+ Kind = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),+ EncryptedData = table.Column<byte[]>(type: "bytea", nullable: false),+ SizeBytes = table.Column<int>(type: "integer", nullable: false),+ CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),+ LastReferencedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)+ },+ constraints: table =>+ {+ table.PrimaryKey("PK_VaultBlobObjects", x => new { x.Hash, x.UserId });+ table.ForeignKey(+ name: "FK_VaultBlobObjects_AliasVaultUsers_UserId",+ column: x => x.UserId,+ principalTable: "AliasVaultUsers",+ principalColumn: "Id",+ onDelete: ReferentialAction.Cascade);+ });++ migrationBuilder.CreateTable(+ name: "VaultBlobReferences",+ columns: table => new+ {+ VaultId = table.Column<Guid>(type: "uuid", nullable: false),+ BlobHash = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false)+ },+ constraints: table =>+ {+ table.PrimaryKey("PK_VaultBlobReferences", x => new { x.VaultId, x.BlobHash });+ table.ForeignKey(+ name: "FK_VaultBlobReferences_Vaults_VaultId",+ column: x => x.VaultId,+ principalTable: "Vaults",+ principalColumn: "Id",+ onDelete: ReferentialAction.Cascade);+ });++ migrationBuilder.CreateTable(+ name: "VaultDataBuckets",+ columns: table => new+ {+ Id = table.Column<Guid>(type: "uuid", nullable: false),+ UserId = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),+ Kind = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),+ EncryptedData = table.Column<string>(type: "text", nullable: false),+ RevisionNumber = table.Column<long>(type: "bigint", nullable: false),+ CiphertextHash = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),+ CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),+ UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)+ },+ constraints: table =>+ {+ table.PrimaryKey("PK_VaultDataBuckets", x => x.Id);+ table.ForeignKey(+ name: "FK_VaultDataBuckets_AliasVaultUsers_UserId",+ column: x => x.UserId,+ principalTable: "AliasVaultUsers",+ principalColumn: "Id",+ onDelete: ReferentialAction.Cascade);+ });++ migrationBuilder.CreateIndex(+ name: "IX_VaultBlobObjects_UserId_Kind",+ table: "VaultBlobObjects",+ columns: new[] { "UserId", "Kind" });++ migrationBuilder.CreateIndex(+ name: "IX_VaultDataBuckets_UserId_Kind_RevisionNumber",+ table: "VaultDataBuckets",+ columns: new[] { "UserId", "Kind", "RevisionNumber" },+ unique: true);+ }++ /// <inheritdoc />+ protected override void Down(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.DropTable(+ name: "VaultBlobObjects");++ migrationBuilder.DropTable(+ name: "VaultBlobReferences");++ migrationBuilder.DropTable(+ name: "VaultDataBuckets");++ migrationBuilder.DropColumn(+ name: "ManifestBlob",+ table: "Vaults");++ migrationBuilder.DropColumn(+ name: "ManifestCiphertextHash",+ table: "Vaults");++ migrationBuilder.DropColumn(+ name: "StorageFormat",+ table: "Vaults");+ }+ }+}diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260611212909_RenameVaultToVaultManifest.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260611212909_RenameVaultToVaultManifest.Designer.csnew file mode 100644index 000000000..4faa3f77c--- /dev/null+++ b/apps/server/Databases/AliasServerDb/Migrations/20260611212909_RenameVaultToVaultManifest.Designer.cs@@ -0,0 +1,1192 @@+// <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("20260611212909_RenameVaultToVaultManifest")]+ partial class RenameVaultToVaultManifest+ {+ /// <inheritdoc />+ protected override void BuildTargetModel(ModelBuilder modelBuilder)+ {+#pragma warning disable 612, 618+ modelBuilder+ .HasAnnotation("ProductVersion", "10.0.6")+ .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<int>("EmailsReceived")+ .HasColumnType("integer");++ 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<int>("MaxEmailAgeDays")+ .HasColumnType("integer");++ b.Property<int>("MaxEmails")+ .HasColumnType("integer");++ 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<string>("PhoneNumber")+ .HasColumnType("text");++ b.Property<bool>("PhoneNumberConfirmed")+ .HasColumnType("boolean");++ b.Property<string>("SecurityStamp")+ .HasColumnType("text");++ b.Property<bool>("ShadowBlocked")+ .HasColumnType("boolean");++ b.Property<DateTime?>("ShadowBlockedAt")+ .HasColumnType("timestamp with time zone");++ 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.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<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<Guid>("UserEncryptionKeyId")+ .HasMaxLength(255)+ .HasColumnType("uuid");++ b.Property<bool>("Visible")+ .HasColumnType("boolean");++ b.HasKey("Id");++ b.HasIndex("Date");++ b.HasIndex("DateSystem");++ b.HasIndex("PushNotificationSent");++ b.HasIndex("UserEncryptionKeyId");++ 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.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.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.UserEmailClaim", 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<string>("UserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("Address")+ .IsUnique();++ b.HasIndex("UserId", "Disabled");++ b.ToTable("UserEmailClaims");+ });++ modelBuilder.Entity("AliasServerDb.UserEncryptionKey", 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<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.ToTable("UserEncryptionKeys");+ });++ 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>("ManifestRevisionId")+ .HasColumnType("uuid");++ b.Property<string>("BlobHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.HasKey("ManifestRevisionId", "BlobHash");++ b.ToTable("VaultBlobReferences");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>+ {+ b.Property<Guid>("RevisionId")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Category")+ .IsRequired()+ .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<string>("OwnerUserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("RevisionId");++ b.HasIndex("OwnerUserId", "Category", "RevisionNumber")+ .IsUnique();++ b.ToTable("VaultDataBuckets");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>+ {+ b.Property<Guid>("RevisionId")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Category")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ 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")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("EncryptionType")+ .IsRequired()+ .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<Guid>("ManifestId")+ .HasColumnType("uuid");++ b.Property<string>("OwnerUserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("Salt")+ .IsRequired()+ .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")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("Verifier")+ .IsRequired()+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<string>("Version")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("RevisionId");++ b.HasIndex("OwnerUserId");++ b.HasIndex("ManifestId", "RevisionNumber");++ b.ToTable("VaultManifests");+ });++ 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.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.UserEncryptionKey", "EncryptionKey")+ .WithMany("Emails")+ .HasForeignKey("UserEncryptionKeyId")+ .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.MobileLoginRequest", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.UserEmailClaim", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("EmailClaims")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.SetNull);++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("EncryptionKeys")+ .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", "ManifestRevision")+ .WithMany()+ .HasForeignKey("ManifestRevisionId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("ManifestRevision");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("OwnerUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("VaultManifests")+ .HasForeignKey("OwnerUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.Navigation("EmailClaims");++ b.Navigation("EncryptionKeys");++ b.Navigation("VaultManifests");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.Navigation("Attachments");+ });++ modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>+ {+ b.Navigation("Emails");+ });+#pragma warning restore 612, 618+ }+ }+}diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260611212909_RenameVaultToVaultManifest.cs b/apps/server/Databases/AliasServerDb/Migrations/20260611212909_RenameVaultToVaultManifest.csnew file mode 100644index 000000000..4a5b400a3--- /dev/null+++ b/apps/server/Databases/AliasServerDb/Migrations/20260611212909_RenameVaultToVaultManifest.cs@@ -0,0 +1,131 @@+using System;+using Microsoft.EntityFrameworkCore.Migrations;++#nullable disable++namespace AliasServerDb.Migrations+{+ /// <inheritdoc />+ public partial class RenameVaultToVaultManifest : Migration+ {+ // NOTE: EF scaffolded the "Vaults" rename as DROP TABLE + CREATE TABLE "VaultManifests", which would destroy+ // every user's vault. We rewrite that part as an in-place rename so existing rows are preserved. The+ // VaultDataBuckets / VaultBlobObjects / VaultBlobReferences renames were scaffolded correctly (those tables+ // are new this release) and are kept. "Vault" no longer maps to a table — a user's logical vault is assembled+ // from one or more VaultManifests (revisions grouped by ManifestId) plus their buckets and blobs.+ // UserId -> OwnerUserId everywhere: ownership is now explicit (R2 sharing lets users access manifests/blobs+ // owned by someone else).+ // "Kind" -> "Category" everywhere (manifest, data bucket, blob object): one consistent term for the+ // discriminator instead of mixing "Kind"/"Category".++ /// <inheritdoc />+ protected override void Up(MigrationBuilder migrationBuilder)+ {+ // Drop the FKs that reference the columns/table we are about to rename; re-added with new names at the end.+ // (Dropping a constraint is metadata-only — no row data is touched.)+ migrationBuilder.DropForeignKey(name: "FK_VaultBlobObjects_AliasVaultUsers_UserId", table: "VaultBlobObjects");+ migrationBuilder.DropForeignKey(name: "FK_VaultBlobReferences_Vaults_VaultId", table: "VaultBlobReferences");+ migrationBuilder.DropForeignKey(name: "FK_VaultDataBuckets_AliasVaultUsers_UserId", table: "VaultDataBuckets");++ // VaultDataBuckets: owner + per-revision PK + category column + index renames.+ migrationBuilder.RenameColumn(name: "UserId", table: "VaultDataBuckets", newName: "OwnerUserId");+ migrationBuilder.RenameColumn(name: "Id", table: "VaultDataBuckets", newName: "RevisionId");+ migrationBuilder.RenameColumn(name: "Kind", table: "VaultDataBuckets", newName: "Category");+ migrationBuilder.RenameIndex(name: "IX_VaultDataBuckets_UserId_Kind_RevisionNumber", table: "VaultDataBuckets", newName: "IX_VaultDataBuckets_OwnerUserId_Category_RevisionNumber");++ // VaultBlobObjects: owner column + blob category column + index rename.+ migrationBuilder.RenameColumn(name: "UserId", table: "VaultBlobObjects", newName: "OwnerUserId");+ migrationBuilder.RenameColumn(name: "Kind", table: "VaultBlobObjects", newName: "Category");+ migrationBuilder.RenameIndex(name: "IX_VaultBlobObjects_UserId_Kind", table: "VaultBlobObjects", newName: "IX_VaultBlobObjects_OwnerUserId_Category");++ // VaultBlobReferences: the FK column now points at a manifest revision.+ migrationBuilder.RenameColumn(name: "VaultId", table: "VaultBlobReferences", newName: "ManifestRevisionId");++ // Vaults -> VaultManifests, IN PLACE (preserves every existing vault row). Postgres keeps constraints/+ // indexes under their old names across a rename, so rename them explicitly to match the EF model.+ migrationBuilder.RenameTable(name: "Vaults", newName: "VaultManifests");+ migrationBuilder.RenameColumn(name: "Id", table: "VaultManifests", newName: "RevisionId");+ migrationBuilder.RenameColumn(name: "UserId", table: "VaultManifests", newName: "OwnerUserId");+ migrationBuilder.Sql(@"ALTER TABLE ""VaultManifests"" RENAME CONSTRAINT ""PK_Vaults"" TO ""PK_VaultManifests"";");+ migrationBuilder.Sql(@"ALTER TABLE ""VaultManifests"" RENAME CONSTRAINT ""FK_Vaults_AliasVaultUsers_UserId"" TO ""FK_VaultManifests_AliasVaultUsers_OwnerUserId"";");+ migrationBuilder.RenameIndex(name: "IX_Vaults_UserId", table: "VaultManifests", newName: "IX_VaultManifests_OwnerUserId");++ // New manifest-lineage columns. Add nullable, backfill every existing row, then enforce NOT NULL — no+ // persisted column default (the app always sets these explicitly).+ migrationBuilder.AddColumn<Guid>(name: "ManifestId", table: "VaultManifests", type: "uuid", nullable: true);+ migrationBuilder.AddColumn<string>(name: "Category", table: "VaultManifests", type: "character varying(20)", maxLength: 20, nullable: true);++ // Every existing revision belongs to the owner's single "Main" manifest. All of an owner's rows must share+ // ONE ManifestId (revisions of the same logical manifest), so assign one new GUID per distinct owner.+ migrationBuilder.Sql(@"UPDATE ""VaultManifests"" v SET ""ManifestId"" = sub.gid FROM (SELECT DISTINCT ""OwnerUserId"", gen_random_uuid() AS gid FROM ""VaultManifests"") sub WHERE v.""OwnerUserId"" = sub.""OwnerUserId"";");+ migrationBuilder.Sql(@"UPDATE ""VaultManifests"" SET ""Category"" = 'Main' WHERE ""Category"" IS NULL;");++ migrationBuilder.AlterColumn<Guid>(+ name: "ManifestId",+ table: "VaultManifests",+ type: "uuid",+ nullable: false,+ oldClrType: typeof(Guid),+ oldType: "uuid",+ oldNullable: true);+ migrationBuilder.AlterColumn<string>(+ name: "Category",+ table: "VaultManifests",+ type: "character varying(20)",+ maxLength: 20,+ nullable: false,+ oldClrType: typeof(string),+ oldType: "character varying(20)",+ oldMaxLength: 20,+ oldNullable: true);++ migrationBuilder.CreateIndex(+ name: "IX_VaultManifests_ManifestId_RevisionNumber",+ table: "VaultManifests",+ columns: new[] { "ManifestId", "RevisionNumber" });++ // Re-add the FKs dropped above, now with their new names/targets.+ migrationBuilder.AddForeignKey(name: "FK_VaultBlobObjects_AliasVaultUsers_OwnerUserId", table: "VaultBlobObjects", column: "OwnerUserId", principalTable: "AliasVaultUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade);+ migrationBuilder.AddForeignKey(name: "FK_VaultBlobReferences_VaultManifests_ManifestRevisionId", table: "VaultBlobReferences", column: "ManifestRevisionId", principalTable: "VaultManifests", principalColumn: "RevisionId", onDelete: ReferentialAction.Cascade);+ migrationBuilder.AddForeignKey(name: "FK_VaultDataBuckets_AliasVaultUsers_OwnerUserId", table: "VaultDataBuckets", column: "OwnerUserId", principalTable: "AliasVaultUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade);+ }++ /// <inheritdoc />+ protected override void Down(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.DropForeignKey(name: "FK_VaultBlobObjects_AliasVaultUsers_OwnerUserId", table: "VaultBlobObjects");+ migrationBuilder.DropForeignKey(name: "FK_VaultBlobReferences_VaultManifests_ManifestRevisionId", table: "VaultBlobReferences");+ migrationBuilder.DropForeignKey(name: "FK_VaultDataBuckets_AliasVaultUsers_OwnerUserId", table: "VaultDataBuckets");++ // Reverse VaultManifests -> Vaults.+ migrationBuilder.DropIndex(name: "IX_VaultManifests_ManifestId_RevisionNumber", table: "VaultManifests");+ migrationBuilder.DropColumn(name: "Category", table: "VaultManifests");+ migrationBuilder.DropColumn(name: "ManifestId", table: "VaultManifests");+ migrationBuilder.RenameIndex(name: "IX_VaultManifests_OwnerUserId", table: "VaultManifests", newName: "IX_Vaults_UserId");+ migrationBuilder.Sql(@"ALTER TABLE ""VaultManifests"" RENAME CONSTRAINT ""FK_VaultManifests_AliasVaultUsers_OwnerUserId"" TO ""FK_Vaults_AliasVaultUsers_UserId"";");+ migrationBuilder.Sql(@"ALTER TABLE ""VaultManifests"" RENAME CONSTRAINT ""PK_VaultManifests"" TO ""PK_Vaults"";");+ migrationBuilder.RenameColumn(name: "OwnerUserId", table: "VaultManifests", newName: "UserId");+ migrationBuilder.RenameColumn(name: "RevisionId", table: "VaultManifests", newName: "Id");+ migrationBuilder.RenameTable(name: "VaultManifests", newName: "Vaults");++ // Reverse VaultBlobReferences.+ migrationBuilder.RenameColumn(name: "ManifestRevisionId", table: "VaultBlobReferences", newName: "VaultId");++ // Reverse VaultBlobObjects.+ migrationBuilder.RenameIndex(name: "IX_VaultBlobObjects_OwnerUserId_Category", table: "VaultBlobObjects", newName: "IX_VaultBlobObjects_UserId_Kind");+ migrationBuilder.RenameColumn(name: "Category", table: "VaultBlobObjects", newName: "Kind");+ migrationBuilder.RenameColumn(name: "OwnerUserId", table: "VaultBlobObjects", newName: "UserId");++ // Reverse VaultDataBuckets.+ migrationBuilder.RenameIndex(name: "IX_VaultDataBuckets_OwnerUserId_Category_RevisionNumber", table: "VaultDataBuckets", newName: "IX_VaultDataBuckets_UserId_Kind_RevisionNumber");+ migrationBuilder.RenameColumn(name: "Category", table: "VaultDataBuckets", newName: "Kind");+ migrationBuilder.RenameColumn(name: "RevisionId", table: "VaultDataBuckets", newName: "Id");+ migrationBuilder.RenameColumn(name: "OwnerUserId", table: "VaultDataBuckets", newName: "UserId");++ // Re-add the original FKs.+ migrationBuilder.AddForeignKey(name: "FK_VaultBlobObjects_AliasVaultUsers_UserId", table: "VaultBlobObjects", column: "UserId", principalTable: "AliasVaultUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade);+ migrationBuilder.AddForeignKey(name: "FK_VaultBlobReferences_Vaults_VaultId", table: "VaultBlobReferences", column: "VaultId", principalTable: "Vaults", principalColumn: "Id", onDelete: ReferentialAction.Cascade);+ migrationBuilder.AddForeignKey(name: "FK_VaultDataBuckets_AliasVaultUsers_UserId", table: "VaultDataBuckets", column: "UserId", principalTable: "AliasVaultUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade);+ }+ }+}diff --git a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.csindex 2518f4688..a8e640233 100644--- a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs+++ b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs@@ -733,12 +733,107 @@ namespace AliasServerDb.Migrationsb.ToTable("UserEncryptionKeys");});- modelBuilder.Entity("AliasServerDb.Vault", b =>+ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>{- b.Property<Guid>("Id")+ 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>("ManifestRevisionId")+ .HasColumnType("uuid");++ b.Property<string>("BlobHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.HasKey("ManifestRevisionId", "BlobHash");++ b.ToTable("VaultBlobReferences");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>+ {+ b.Property<Guid>("RevisionId")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Category")+ .IsRequired()+ .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<string>("OwnerUserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("RevisionId");++ b.HasIndex("OwnerUserId", "Category", "RevisionNumber")+ .IsUnique();++ b.ToTable("VaultDataBuckets");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>+ {+ b.Property<Guid>("RevisionId").ValueGeneratedOnAdd().HasColumnType("uuid");+ b.Property<string>("Category")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");+b.Property<string>("Client").HasMaxLength(255).HasColumnType("character varying(255)");@@ -763,6 +858,21 @@ namespace AliasServerDb.Migrationsb.Property<int>("FileSize").HasColumnType("integer");+ b.Property<string>("ManifestBlob")+ .HasColumnType("text");++ b.Property<string>("ManifestCiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<Guid>("ManifestId")+ .HasColumnType("uuid");++ b.Property<string>("OwnerUserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");+b.Property<long>("RevisionNumber").HasColumnType("bigint");@@ -771,14 +881,14 @@ namespace AliasServerDb.Migrations.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>("UserId")- .IsRequired()- .HasMaxLength(255)- .HasColumnType("character varying(255)");-b.Property<string>("VaultBlob").IsRequired().HasColumnType("text");@@ -793,11 +903,13 @@ namespace AliasServerDb.Migrations.HasMaxLength(255).HasColumnType("character varying(255)");- b.HasKey("Id");+ b.HasKey("RevisionId");- b.HasIndex("UserId");+ b.HasIndex("OwnerUserId");++ b.HasIndex("ManifestId", "RevisionNumber");- b.ToTable("Vaults");+ b.ToTable("VaultManifests");});modelBuilder.Entity("AliasVault.WorkerStatus.Database.WorkerServiceStatus", b =>@@ -1009,11 +1121,44 @@ namespace AliasServerDb.Migrationsb.Navigation("User");});- modelBuilder.Entity("AliasServerDb.Vault", b =>+ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>{b.HasOne("AliasServerDb.AliasVaultUser", "User")- .WithMany("Vaults")- .HasForeignKey("UserId")+ .WithMany()+ .HasForeignKey("OwnerUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "ManifestRevision")+ .WithMany()+ .HasForeignKey("ManifestRevisionId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("ManifestRevision");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("OwnerUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("VaultManifests")+ .HasForeignKey("OwnerUserId").OnDelete(DeleteBehavior.Cascade).IsRequired();@@ -1026,7 +1171,7 @@ namespace AliasServerDb.Migrationsb.Navigation("EncryptionKeys");- b.Navigation("Vaults");+ b.Navigation("VaultManifests");});modelBuilder.Entity("AliasServerDb.Email", b =>diff --git a/apps/server/Databases/AliasServerDb/VaultBlobObject.cs b/apps/server/Databases/AliasServerDb/VaultBlobObject.csnew file mode 100644index 000000000..136a2cd88--- /dev/null+++ b/apps/server/Databases/AliasServerDb/VaultBlobObject.cs@@ -0,0 +1,61 @@+//-----------------------------------------------------------------------+// <copyright file="VaultBlobObject.cs" company="aliasvault">+// Copyright (c) aliasvault. All rights reserved.+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------+namespace AliasServerDb;++using System.ComponentModel.DataAnnotations;+using System.ComponentModel.DataAnnotations.Schema;++/// <summary>+/// Content-addressed encrypted binary blobs (e.g. favicons, attachments, etc.) for the manifest-v1 storage format.+/// </summary>+public class VaultBlobObject+{+ /// <summary>+ /// Gets or sets the per-user salted SHA-256 (hex) of the plaintext payload.+ /// </summary>+ [StringLength(64)]+ public string Hash { get; set; } = null!;++ /// <summary>+ /// Gets or sets the user ID.+ /// </summary>+ [StringLength(255)]+ public string OwnerUserId { get; set; } = null!;++ /// <summary>+ /// Gets or sets the navigation property to the user.+ /// </summary>+ [ForeignKey("OwnerUserId")]+ public virtual AliasVaultUser User { get; set; } = null!;++ /// <summary>+ /// Gets or sets the blob category.+ /// </summary>+ [StringLength(20)]+ public required string Category { get; set; }++ /// <summary>+ /// Gets or sets the encrypted blob payload (AES-GCM ciphertext bytes).+ /// </summary>+ public required byte[] EncryptedData { get; set; }++ /// <summary>+ /// Gets or sets the size of the encrypted payload in bytes (cached for cheap metrics).+ /// </summary>+ public int SizeBytes { get; set; }++ /// <summary>+ /// Gets or sets the created timestamp.+ /// </summary>+ public DateTime CreatedAt { get; set; }++ /// <summary>+ /// Gets or sets the most-recent timestamp this blob was referenced by a successful manifest upload.+ /// Used by the GC sweeper: orphaned blobs older than the grace window are deleted.+ /// </summary>+ public DateTime LastReferencedAt { get; set; }+}diff --git a/apps/server/Databases/AliasServerDb/VaultBlobReference.cs b/apps/server/Databases/AliasServerDb/VaultBlobReference.csnew file mode 100644index 000000000..ec47171c9--- /dev/null+++ b/apps/server/Databases/AliasServerDb/VaultBlobReference.cs@@ -0,0 +1,35 @@+//-----------------------------------------------------------------------+// <copyright file="VaultBlobReference.cs" company="aliasvault">+// Copyright (c) aliasvault. All rights reserved.+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------+namespace AliasServerDb;++using System.ComponentModel.DataAnnotations;+using System.ComponentModel.DataAnnotations.Schema;++/// <summary>+/// Tracks which encrypted blobs a given manifest revision references. Used by the garbage collector+/// sweeper to decide when a VaultBlobObject can be deleted (no surviving revision references it).+/// </summary>+public class VaultBlobReference+{+ /// <summary>+ /// Gets or sets the manifest revision this reference belongs to (FK to <see cref="VaultManifest.RevisionId"/>).+ /// Part of the composite PK.+ /// </summary>+ public Guid ManifestRevisionId { get; set; }++ /// <summary>+ /// Gets or sets the navigation property to the manifest revision.+ /// </summary>+ [ForeignKey("ManifestRevisionId")]+ public virtual VaultManifest ManifestRevision { get; set; } = null!;++ /// <summary>+ /// Gets or sets the blob hash being referenced. Part of the composite PK.+ /// </summary>+ [StringLength(64)]+ public string BlobHash { get; set; } = null!;+}diff --git a/apps/server/Databases/AliasServerDb/VaultDataBucket.cs b/apps/server/Databases/AliasServerDb/VaultDataBucket.csnew file mode 100644index 000000000..3d1e2cbe6--- /dev/null+++ b/apps/server/Databases/AliasServerDb/VaultDataBucket.cs@@ -0,0 +1,68 @@+//-----------------------------------------------------------------------+// <copyright file="VaultDataBucket.cs" company="aliasvault">+// Copyright (c) aliasvault. All rights reserved.+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------+namespace AliasServerDb;++using System.ComponentModel.DataAnnotations;+using System.ComponentModel.DataAnnotations.Schema;+using AliasVault.Shared.Models.WebApi.V2.Vault;++/// <summary>+/// A small, independently-syncable user-scoped data bucket. Each bucket holds one kind of data+/// that we deliberately keep OUT of the main vault content manifest so it can sync separately and faster.+/// </summary>+public class VaultDataBucket+{+ /// <summary>+ /// Gets or sets the per-revision primary key. Each row is one revision of the (OwnerUserId, Category) bucket;+ /// the highest <see cref="RevisionNumber"/> for a given (OwnerUserId, Category) is the current one.+ /// </summary>+ [Key]+ public Guid RevisionId { get; set; }++ /// <summary>+ /// Gets or sets the user ID foreign key.+ /// </summary>+ [StringLength(255)]+ public string OwnerUserId { get; set; } = null!;++ /// <summary>+ /// Gets or sets the navigation property to the user.+ /// </summary>+ [ForeignKey("OwnerUserId")]+ public virtual AliasVaultUser User { get; set; } = null!;++ /// <summary>+ /// Gets or sets the bucket category/kind (e.g. Settings).+ /// </summary>+ public required VaultDataBucketCategory Category { get; set; }++ /// <summary>+ /// Gets or sets the encrypted bucket payload (AES-GCM ciphertext, base64-encoded).+ /// </summary>+ public required string EncryptedData { get; set; }++ /// <summary>+ /// Gets or sets the revision number of this bucket.+ /// </summary>+ public required long RevisionNumber { get; set; }++ /// <summary>+ /// Gets or sets the SHA-256 (hex) of the encrypted ciphertext for storage-layer integrity check.+ /// </summary>+ [StringLength(64)]+ public string? CiphertextHash { get; set; }++ /// <summary>+ /// Gets or sets the created timestamp.+ /// </summary>+ public DateTime CreatedAt { get; set; }++ /// <summary>+ /// Gets or sets the updated timestamp.+ /// </summary>+ public DateTime UpdatedAt { get; set; }+}diff --git a/apps/server/Databases/AliasServerDb/Vault.cs b/apps/server/Databases/AliasServerDb/VaultManifest.cssimilarity index 59%rename from apps/server/Databases/AliasServerDb/Vault.csrename to apps/server/Databases/AliasServerDb/VaultManifest.csindex 5a7518f5f..043b38706 100644--- a/apps/server/Databases/AliasServerDb/Vault.cs+++ b/apps/server/Databases/AliasServerDb/VaultManifest.cs@@ -1,5 +1,5 @@//------------------------------------------------------------------------// <copyright file="Vault.cs" company="aliasvault">+// <copyright file="VaultManifest.cs" company="aliasvault">// Copyright (c) aliasvault. All rights reserved.// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.// </copyright>@@ -8,35 +8,66 @@ namespace AliasServerDb;using System.ComponentModel.DataAnnotations;using System.ComponentModel.DataAnnotations.Schema;+using AliasVault.Shared.Models.WebApi.V2.Vault;/// <summary>-/// Vault object.+/// A single revision of a vault manifest. Each save inserts a new row. All rows sharing a <see cref="ManifestId"/>+/// are revisions of the same logical manifest (e.g. main vault or shared folder)./// </summary>-public class Vault+public class VaultManifest{/// <summary>- /// Gets or sets Login ID.+ /// Gets or sets the per-revision primary key. Unique to this single revision./// </summary>[Key]- public Guid Id { get; set; }+ public Guid RevisionId { get; set; }/// <summary>- /// Gets or sets user ID foreign key.+ /// Gets or sets the stable identifier of the logical manifest this row is a revision of. Constant across every+ /// revision of the same manifest.+ /// </summary>+ public Guid ManifestId { get; set; }++ /// <summary>+ /// Gets or sets the manifest kind.+ /// </summary>+ public required VaultManifestCategory Category { get; set; }++ /// <summary>+ /// Gets or sets the ID of the owning user./// </summary>[StringLength(255)]- public string UserId { get; set; } = null!;+ public string OwnerUserId { get; set; } = null!;/// <summary>/// Gets or sets foreign key to the AliasVaultUser object./// </summary>- [ForeignKey("UserId")]+ [ForeignKey("OwnerUserId")]public virtual AliasVaultUser User { get; set; } = null!;/// <summary>- /// Gets or sets the encrypted vault blob.+ /// Gets or sets the encrypted vault blob (only used by legacy sqlite-blob format). Not used anymore in new format./// </summary>public required string VaultBlob { get; set; }+ /// <summary>+ /// Gets or sets the storage format identifier: "sqlite-blob" (legacy v1) or "manifest-v1" (v2).+ /// </summary>+ [StringLength(20)]+ public required string StorageFormat { get; set; }++ /// <summary>+ /// Gets or sets the encrypted manifest blob (AES-GCM ciphertext, base64-encoded).+ /// </summary>+ public string? ManifestBlob { get; set; }++ /// <summary>+ /// Gets or sets the SHA-256 (hex) of the encrypted manifest ciphertext. Stored for storage-layer integrity+ /// verification (the client sends this on upload and we return it on download; client verifies before decrypt).+ /// </summary>+ [StringLength(64)]+ public string? ManifestCiphertextHash { get; set; }+/// <summary>/// Gets or sets the vault data model version./// </summary>@@ -45,10 +76,7 @@ public class Vault/// <summary>/// Gets or sets the revision number of the vault.- /// This number is incremented with each change to the vault and is used for- /// managing concurrency and merging during the synchronization process.- /// It helps in detecting conflicts and ensuring data consistency if multiple clients- /// update a previous version of the vault simultaneously.+ /// This number is incremented with each change to the vault manifest./// </summary>[Required]public required long RevisionNumber { get; set; }@@ -59,9 +87,9 @@ public class Vaultpublic int FileSize { get; set; }/// <summary>- /// Gets or sets the salt used for SRP authentication. Note: the login credentials are stored with the vault because- /// the vault itself is encrypted with the same key derived from the user's password. So the password the user- /// uses to log in to AliasVault needs to be the same as the vault to keep everything in-sync in case of vault+ /// Gets or sets the salt used for SRP authentication. Note: the login credentials are stored with the vault manifest+ /// because the vault manifest is encrypted with the same key derived from the user's password. So the password the user+ /// uses to log in to AliasVault needs to be the same as the vault manifest to keep everything in-sync in case of vault/// backup restores./// </summary>[StringLength(100)]@@ -69,7 +97,7 @@ public class Vault/// <summary>/// Gets or sets the verifier used for SRP authentication. Note: the login credentials are stored with the vault- /// because the vault itself is encrypted with the same key derived from the user's password. So the password the+ /// manifest because the vault manifest is encrypted with the same key derived from the user's password. So the password the/// user uses to log in to AliasVault needs to be the same as the vault to keep everything in-sync in case of vault/// backup restores./// </summary>diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultDataBucketCategory.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultDataBucketCategory.csnew file mode 100644index 000000000..8d0dc4ae4--- /dev/null+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultDataBucketCategory.cs@@ -0,0 +1,24 @@+//-----------------------------------------------------------------------+// <copyright file="VaultDataBucketCategory.cs" company="aliasvault">+// Copyright (c) aliasvault. All rights reserved.+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------++namespace AliasVault.Shared.Models.WebApi.V2.Vault;++using System.Text.Json.Serialization;++/// <summary>+/// Known data-bucket categories for the avux-v2 storage format. Each value is one small, independently-versioned,+/// user-scoped category of encrypted data kept out of the main vault content manifest so it syncs cheaply.+/// Serialized as its string name on the wire (not the numeric value) and stored as a string in the database.+/// Adding a new kind requires a server-side rollout first, because the server reasons about kinds for+/// per-kind retention policies.+/// </summary>+[JsonConverter(typeof(JsonStringEnumConverter))]+public enum VaultDataBucketCategory+{+ /// <summary>User client settings (sort order, autofill prefs, identity defaults, etc.).</summary>+ Settings = 0,+}diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultManifestCategory.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultManifestCategory.csnew file mode 100644index 000000000..594d38d52--- /dev/null+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultManifestCategory.cs@@ -0,0 +1,25 @@+//-----------------------------------------------------------------------+// <copyright file="VaultManifestCategory.cs" company="aliasvault">+// Copyright (c) aliasvault. All rights reserved.+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------++namespace AliasVault.Shared.Models.WebApi.V2.Vault;++using System.Text.Json.Serialization;++/// <summary>+/// The category of a vault manifest. A user's logical vault is assembled from one or more manifests: exactly one+/// <see cref="Main"/> manifest plus (from R2) any number of <see cref="SharedFolder"/> manifests they own or have+/// been granted access to. Serialized as its string name on the wire and stored as a string in the database.+/// </summary>+[JsonConverter(typeof(JsonStringEnumConverter))]+public enum VaultManifestCategory+{+ /// <summary>The user's own personal vault. Every user has exactly one. The only kind produced in R1.</summary>+ Main = 0,++ /// <summary>A shared folder manifest, owned by one user and shared with others via wrapped keys (R2).</summary>+ SharedFolder = 1,+}