Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add additional vault metadata (#168)
Leendert de Borstf84f0631559e
diff --git a/src/AliasVault.Admin/Main/Pages/Users/View.razor b/src/AliasVault.Admin/Main/Pages/Users/View.razorindex a5a299bf5..a9987e3fd 100644--- a/src/AliasVault.Admin/Main/Pages/Users/View.razor+++ b/src/AliasVault.Admin/Main/Pages/Users/View.razor@@ -108,6 +108,8 @@ else<th scope="col" class="px-4 py-3">Updated</th><th scope="col" class="px-4 py-3">Filesize</th><th scope="col" class="px-4 py-3">DB version</th>+ <th scope="col" class="px-4 py-3">Credentials</th>+ <th scope="col" class="px-4 py-3">Email Claims</th><th scope="col" class="px-4 py-3">Status</th><th scope="col" class="px-4 py-3">Actions</th></tr>@@ -124,6 +126,8 @@ else<td class="px-4 py-3">@entry.UpdatedAt.ToString("yyyy-MM-dd HH:mm")</td><td class="px-4 py-3">@Math.Round((double)entry.FileSize / 1024, 1) MB</td><td class="px-4 py-3">@entry.Version</td>+ <td class="px-4 py-3">@entry.CredentialsCount</td>+ <td class="px-4 py-3">@entry.EmailClaimsCount</td><td class="px-4 py-3">@if (entry == LatestVault){@@ -255,6 +259,8 @@ elseUpdatedAt = x.UpdatedAt,Salt = x.Salt,Verifier = x.Verifier,+ CredentialsCount = x.CredentialsCount,+ EmailClaimsCount = x.EmailClaimsCount,}).OrderBy(x => x.UpdatedAt).ToListAsync();diff --git a/src/AliasVault.Api/Controllers/VaultController.cs b/src/AliasVault.Api/Controllers/VaultController.csindex c18c1e8e8..fd53a2dcc 100644--- a/src/AliasVault.Api/Controllers/VaultController.cs+++ b/src/AliasVault.Api/Controllers/VaultController.cs@@ -81,10 +81,28 @@ public class VaultController(ILogger<VaultController> logger, IDbContextFactory<// as starting point.if (vault == null){- return Ok(new Shared.Models.WebApi.Vault(string.Empty, string.Empty, string.Empty, new List<string>(), DateTime.MinValue, DateTime.MinValue));+ return Ok(new Shared.Models.WebApi.Vault+ {+ Blob = string.Empty,+ Version = string.Empty,+ EncryptionPublicKey = string.Empty,+ CredentialsCount = 0,+ EmailAddressList = new List<string>(),+ CreatedAt = DateTime.MinValue,+ UpdatedAt = DateTime.MinValue,+ });}- return Ok(new Shared.Models.WebApi.Vault(vault.VaultBlob, vault.Version, string.Empty, new List<string>(), vault.CreatedAt, vault.UpdatedAt));+ return Ok(new Shared.Models.WebApi.Vault+ {+ Blob = vault.VaultBlob,+ Version = vault.Version,+ EncryptionPublicKey = string.Empty,+ CredentialsCount = 0,+ EmailAddressList = new List<string>(),+ CreatedAt = vault.CreatedAt,+ UpdatedAt = vault.UpdatedAt,+ });}/// <summary>@@ -113,6 +131,8 @@ public class VaultController(ILogger<VaultController> logger, IDbContextFactory<VaultBlob = model.Blob,Version = model.Version,FileSize = FileHelper.Base64StringToKilobytes(model.Blob),+ CredentialsCount = model.CredentialsCount,+ EmailClaimsCount = model.EmailAddressList.Count,Salt = latestVault.Salt,Verifier = latestVault.Verifier,CreatedAt = timeProvider.UtcNow,@@ -168,7 +188,7 @@ public class VaultController(ILogger<VaultController> logger, IDbContextFactory<return Unauthorized();}- // Validate the SRP session (actual password check). ,+ // Validate the SRP session (actual password check).var serverSession = AuthHelper.ValidateSrpSession(cache, user, model.CurrentClientPublicEphemeral, model.CurrentClientSessionProof);if (serverSession is null){@@ -185,6 +205,8 @@ public class VaultController(ILogger<VaultController> logger, IDbContextFactory<UserId = user.Id,VaultBlob = model.Blob,Version = model.Version,+ CredentialsCount = model.CredentialsCount,+ EmailClaimsCount = model.EmailAddressList.Count,FileSize = FileHelper.Base64StringToKilobytes(model.Blob),Salt = model.NewPasswordSalt,Verifier = model.NewPasswordVerifier,diff --git a/src/AliasVault.Client/Main/Pages/Settings/Security/ChangePassword.razor b/src/AliasVault.Client/Main/Pages/Settings/Security/ChangePassword.razorindex 87ff5197e..5687e4e51 100644--- a/src/AliasVault.Client/Main/Pages/Settings/Security/ChangePassword.razor+++ b/src/AliasVault.Client/Main/Pages/Settings/Security/ChangePassword.razor@@ -156,17 +156,26 @@ elsevar srpPasswordChange = Srp.PasswordChangeAsync(client, newSalt, username, newPasswordHashString);// Prepare new vault model to update to.- var databaseVersion = await DbService.GetCurrentDatabaseVersionAsync();var encryptedBase64String = await DbService.GetEncryptedDatabaseBase64String();- var vaultPasswordChangeObject = new VaultPasswordChangeRequest(- encryptedBase64String,- databaseVersion,- DateTime.Now,- DateTime.Now,- ClientEphemeral.Public,- ClientSession.Proof,- srpPasswordChange.Salt,- srpPasswordChange.Verifier);+ var vault = await DbService.PrepareVaultForUploadAsync(encryptedBase64String);++ var vaultPasswordChangeObject = new VaultPasswordChangeRequest+ {+ Blob = vault.Blob,+ Version = vault.Version,+ EncryptionPublicKey = vault.EncryptionPublicKey,+ CredentialsCount = vault.CredentialsCount,+ EmailAddressList = vault.EmailAddressList,+ CreatedAt = vault.CreatedAt,+ UpdatedAt = vault.UpdatedAt,+ CurrentClientPublicEphemeral = ClientEphemeral.Public,+ CurrentClientSessionProof = ClientSession.Proof,+ NewPasswordSalt = srpPasswordChange.Salt,+ NewPasswordVerifier = srpPasswordChange.Verifier+ };++ // Clear form.+ PasswordChangeModel = new PasswordChangeModel();// 4. Client sends proof of session key to server.var response = await Http.PostAsJsonAsync("api/v1/Vault/change-password", vaultPasswordChangeObject);@@ -179,9 +188,6 @@ elseGlobalNotificationService.AddErrorMessage(error, true);}- // Clear form.- PasswordChangeModel = new PasswordChangeModel();-// Set currentPasswordHash back to original, so we're back to the original state.await AuthService.StoreEncryptionKeyAsync(backupPasswordHash);diff --git a/src/AliasVault.Client/Services/Database/DbService.cs b/src/AliasVault.Client/Services/Database/DbService.csindex cf8ef24d1..b1ec83110 100644--- a/src/AliasVault.Client/Services/Database/DbService.cs+++ b/src/AliasVault.Client/Services/Database/DbService.cs@@ -258,6 +258,29 @@ public sealed class DbService : IDisposablereturn "Unknown";}+ /// <summary>+ /// Prepare a vault object for upload to the server.+ /// </summary>+ /// <param name="encryptedDatabase">Encrypted database as string.</param>+ /// <returns>Vault object.</returns>+ public async Task<Vault> PrepareVaultForUploadAsync(string encryptedDatabase)+ {+ var databaseVersion = await GetCurrentDatabaseVersionAsync();+ var encryptionKey = await GetOrCreateEncryptionKeyAsync();+ var credentialsCount = await _dbContext.Credentials.CountAsync();+ var emailAddresses = await GetEmailClaimListAsync();+ return new Vault+ {+ Blob = encryptedDatabase,+ Version = databaseVersion,+ EncryptionPublicKey = encryptionKey.PublicKey,+ CredentialsCount = credentialsCount,+ EmailAddressList = emailAddresses,+ CreatedAt = DateTime.UtcNow,+ UpdatedAt = DateTime.UtcNow,+ };+ }+/// <summary>/// Clears the database connection and creates a new one so that the database is empty./// </summary>@@ -484,25 +507,7 @@ public sealed class DbService : IDisposable/// <returns>True if save action succeeded.</returns>private async Task<bool> SaveToServerAsync(string encryptedDatabase){- // Get the public encryption key that server requires to encrypt data they receive for current user.- var encryptionKey = await GetOrCreateEncryptionKeyAsync();-- // Send list of email addresses that are used in aliases by this vault so they can be- // claimed on the server.- var emailAddresses = await _dbContext.Aliases- .Where(a => a.Email != null)- .Select(a => a.Email)- .Distinct()- .Select(email => email!)- .ToListAsync();-- // Filter the list of email addresses to only include those that are in the allowed domains.- emailAddresses = emailAddresses- .Where(email => _config.PrivateEmailDomains.Exists(domain => email.EndsWith(domain)))- .ToList();-- var databaseVersion = await GetCurrentDatabaseVersionAsync();- var vaultObject = new Vault(encryptedDatabase, databaseVersion, encryptionKey.PublicKey, emailAddresses, DateTime.Now, DateTime.Now);+ var vaultObject = await PrepareVaultForUploadAsync(encryptedDatabase);try{diff --git a/src/AliasVault.Shared/Models/WebApi/PasswordChange/VaultPasswordChangeRequest.cs b/src/AliasVault.Shared/Models/WebApi/PasswordChange/VaultPasswordChangeRequest.csindex ed2d8e9b1..dcf0157d4 100644--- a/src/AliasVault.Shared/Models/WebApi/PasswordChange/VaultPasswordChangeRequest.cs+++ b/src/AliasVault.Shared/Models/WebApi/PasswordChange/VaultPasswordChangeRequest.cs@@ -12,51 +12,23 @@ namespace AliasVault.Shared.Models.WebApi.PasswordChange;/// </summary>public class VaultPasswordChangeRequest : Vault{- /// <summary>- /// Initializes a new instance of the <see cref="VaultPasswordChangeRequest"/> class.- /// </summary>- /// <param name="blob">Blob.</param>- /// <param name="version">Version of the vault data model (migration).</param>- /// <param name="createdAt">CreatedAt.</param>- /// <param name="updatedAt">UpdatedAt.</param>- /// <param name="currentClientPublicEphemeral">Client public ephemeral.</param>- /// <param name="currentClientSessionProof">Client session proof.</param>- /// <param name="newPasswordSalt">New password salt.</param>- /// <param name="newPasswordVerifier">New password verifier.</param>- public VaultPasswordChangeRequest(- string blob,- string version,- DateTime createdAt,- DateTime updatedAt,- string currentClientPublicEphemeral,- string currentClientSessionProof,- string newPasswordSalt,- string newPasswordVerifier)- : base(blob, version, string.Empty, new List<string>(), createdAt, updatedAt)- {- CurrentClientPublicEphemeral = currentClientPublicEphemeral;- CurrentClientSessionProof = currentClientSessionProof;- NewPasswordSalt = newPasswordSalt;- NewPasswordVerifier = newPasswordVerifier;- }-/// <summary>/// Gets or sets the client's public ephemeral for the current password verification./// </summary>- public string CurrentClientPublicEphemeral { get; set; }+ public required string CurrentClientPublicEphemeral { get; set; }/// <summary>/// Gets or sets the client's session proof for the current password verification./// </summary>- public string CurrentClientSessionProof { get; set; }+ public required string CurrentClientSessionProof { get; set; }/// <summary>/// Gets or sets the new password salt./// </summary>- public string NewPasswordSalt { get; set; }+ public required string NewPasswordSalt { get; set; }/// <summary>/// Gets or sets the new password verifier./// </summary>- public string NewPasswordVerifier { get; set; }+ public required string NewPasswordVerifier { get; set; }}diff --git a/src/AliasVault.Shared/Models/WebApi/Vault.cs b/src/AliasVault.Shared/Models/WebApi/Vault.csindex d682f4c70..a0e4152dd 100644--- a/src/AliasVault.Shared/Models/WebApi/Vault.cs+++ b/src/AliasVault.Shared/Models/WebApi/Vault.cs@@ -12,52 +12,39 @@ namespace AliasVault.Shared.Models.WebApi;/// </summary>public class Vault{- /// <summary>- /// Initializes a new instance of the <see cref="Vault"/> class.- /// </summary>- /// <param name="blob">Blob.</param>- /// <param name="version">Version of the vault data model (migration).</param>- /// <param name="encryptionPublicKey">Public encryption key that server requires to encrypt user data such as received emails.</param>- /// <param name="emailAddressList">List of email addresses that are used in the vault and should be registered.</param>- /// <param name="createdAt">CreatedAt.</param>- /// <param name="updatedAt">UpdatedAt.</param>- public Vault(string blob, string version, string encryptionPublicKey, List<string> emailAddressList, DateTime createdAt, DateTime updatedAt)- {- Blob = blob;- Version = version;- EncryptionPublicKey = encryptionPublicKey;- EmailAddressList = emailAddressList;- CreatedAt = createdAt;- UpdatedAt = updatedAt;- }-/// <summary>/// Gets or sets the vault blob./// </summary>- public string Blob { get; set; }+ public required string Blob { get; set; }/// <summary>/// Gets or sets the vault version./// </summary>- public string Version { get; set; }+ public required string Version { get; set; }/// <summary>/// Gets or sets the public encryption key that server requires to encrypt user data such as received emails./// </summary>- public string EncryptionPublicKey { get; set; }+ public required string EncryptionPublicKey { get; set; }++ /// <summary>+ /// Gets or sets the number of credentials stored in the vault. This anonymous data is used in case a vault back-up+ /// needs to be restored to get a better idea of the vault size.+ /// </summary>+ public required int CredentialsCount { get; set; }/// <summary>/// Gets or sets the list of email addresses that are used in the vault and should be registered on the server./// </summary>- public List<string> EmailAddressList { get; set; }+ public required List<string> EmailAddressList { get; set; }/// <summary>/// Gets or sets the date and time of creation./// </summary>- public DateTime CreatedAt { get; set; }+ public required DateTime CreatedAt { get; set; }/// <summary>/// Gets or sets the date and time of last update./// </summary>- public DateTime UpdatedAt { get; set; }+ public required DateTime UpdatedAt { get; set; }}diff --git a/src/Databases/AliasServerDb/Migrations/20240906092833_AddVaultStatisticsColumns.Designer.cs b/src/Databases/AliasServerDb/Migrations/20240906092833_AddVaultStatisticsColumns.Designer.csnew file mode 100644index 000000000..fdd1cdbd0--- /dev/null+++ b/src/Databases/AliasServerDb/Migrations/20240906092833_AddVaultStatisticsColumns.Designer.cs@@ -0,0 +1,812 @@+// <auto-generated />+using System;+using AliasServerDb;+using Microsoft.EntityFrameworkCore;+using Microsoft.EntityFrameworkCore.Infrastructure;+using Microsoft.EntityFrameworkCore.Migrations;+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;++#nullable disable++namespace AliasServerDb.Migrations+{+ [DbContext(typeof(AliasServerDbContext))]+ [Migration("20240906092833_AddVaultStatisticsColumns")]+ partial class AddVaultStatisticsColumns+ {+ /// <inheritdoc />+ protected override void BuildTargetModel(ModelBuilder modelBuilder)+ {+#pragma warning disable 612, 618+ modelBuilder+ .HasAnnotation("ProductVersion", "8.0.8")+ .HasAnnotation("Proxies:ChangeTracking", false)+ .HasAnnotation("Proxies:CheckEquality", false)+ .HasAnnotation("Proxies:LazyLoading", true);++ 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("INTEGER");++ b.Property<DateTime?>("LastPasswordChanged")+ .HasColumnType("TEXT");++ b.Property<bool>("LockoutEnabled")+ .HasColumnType("INTEGER");++ b.Property<DateTimeOffset?>("LockoutEnd")+ .HasColumnType("TEXT");++ 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("INTEGER");++ b.Property<string>("SecurityStamp")+ .HasColumnType("TEXT");++ b.Property<bool>("TwoFactorEnabled")+ .HasColumnType("INTEGER");++ 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<string>("ConcurrencyStamp")+ .HasColumnType("TEXT");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("TEXT");++ b.Property<string>("Email")+ .HasColumnType("TEXT");++ b.Property<bool>("EmailConfirmed")+ .HasColumnType("INTEGER");++ b.Property<bool>("LockoutEnabled")+ .HasColumnType("INTEGER");++ b.Property<DateTimeOffset?>("LockoutEnd")+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedEmail")+ .HasColumnType("TEXT");++ b.Property<string>("NormalizedUserName")+ .HasColumnType("TEXT");++ b.Property<DateTime>("PasswordChangedAt")+ .HasColumnType("TEXT");++ b.Property<string>("PasswordHash")+ .HasColumnType("TEXT");++ b.Property<string>("PhoneNumber")+ .HasColumnType("TEXT");++ b.Property<bool>("PhoneNumberConfirmed")+ .HasColumnType("INTEGER");++ b.Property<string>("SecurityStamp")+ .HasColumnType("TEXT");++ b.Property<bool>("TwoFactorEnabled")+ .HasColumnType("INTEGER");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("TEXT");++ b.Property<string>("UserName")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.ToTable("AliasVaultUsers");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("TEXT");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("TEXT");++ b.Property<string>("DeviceIdentifier")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<DateTime>("ExpireDate")+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("Value")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.ToTable("AliasVaultUserRefreshTokens");+ });++ modelBuilder.Entity("AliasServerDb.AuthLog", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("AdditionalInfo")+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("Browser")+ .HasMaxLength(100)+ .HasColumnType("TEXT");++ b.Property<string>("Country")+ .HasMaxLength(50)+ .HasColumnType("TEXT");++ b.Property<string>("DeviceType")+ .HasMaxLength(100)+ .HasColumnType("TEXT");++ b.Property<int>("EventType")+ .HasColumnType("nvarchar(50)");++ b.Property<int?>("FailureReason")+ .HasColumnType("INTEGER");++ b.Property<string>("IpAddress")+ .HasMaxLength(50)+ .HasColumnType("TEXT");++ b.Property<bool>("IsSuccess")+ .HasColumnType("INTEGER");++ b.Property<bool>("IsSuspiciousActivity")+ .HasColumnType("INTEGER");++ b.Property<string>("OperatingSystem")+ .HasMaxLength(100)+ .HasColumnType("TEXT");++ b.Property<string>("RequestPath")+ .HasMaxLength(100)+ .HasColumnType("TEXT");++ b.Property<DateTime>("Timestamp")+ .HasColumnType("TEXT");++ b.Property<string>("UserAgent")+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("Username")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ 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.Email", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<DateTime>("Date")+ .HasColumnType("TEXT");++ b.Property<DateTime>("DateSystem")+ .HasColumnType("TEXT");++ 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("INTEGER");++ 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("TEXT");++ b.Property<bool>("Visible")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("Date");++ b.HasIndex("DateSystem");++ b.HasIndex("PushNotificationSent");++ b.HasIndex("ToLocal");++ b.HasIndex("UserEncryptionKeyId");++ b.HasIndex("Visible");++ b.ToTable("Emails");+ });++ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<byte[]>("Bytes")+ .IsRequired()+ .HasColumnType("BLOB");++ b.Property<DateTime>("Date")+ .HasColumnType("TEXT");++ 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");++ b.Property<string>("Application")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("TEXT");++ b.Property<string>("Exception")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("Level")+ .IsRequired()+ .HasMaxLength(128)+ .HasColumnType("TEXT");++ 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()+ .HasColumnType("TEXT");++ b.Property<DateTimeOffset>("TimeStamp")+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("Application");++ b.HasIndex("TimeStamp");++ b.ToTable("Logs", (string)null);+ });++ modelBuilder.Entity("AliasServerDb.UserEmailClaim", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("TEXT");++ b.Property<string>("Address")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("AddressDomain")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("AddressLocal")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("TEXT");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("TEXT");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("Address")+ .IsUnique();++ b.HasIndex("UserId");++ b.ToTable("UserEmailClaims");+ });++ modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("TEXT");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("TEXT");++ b.Property<bool>("IsPrimary")+ .HasColumnType("INTEGER");++ b.Property<string>("PublicKey")+ .IsRequired()+ .HasMaxLength(2000)+ .HasColumnType("TEXT");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("TEXT");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.ToTable("UserEncryptionKeys");+ });++ modelBuilder.Entity("AliasServerDb.Vault", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("TEXT");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("TEXT");++ b.Property<int>("CredentialsCount")+ .HasColumnType("INTEGER");++ b.Property<int>("EmailClaimsCount")+ .HasColumnType("INTEGER");++ b.Property<int>("FileSize")+ .HasColumnType("INTEGER");++ b.Property<string>("Salt")+ .IsRequired()+ .HasMaxLength(100)+ .HasColumnType("TEXT");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("TEXT");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.Property<string>("VaultBlob")+ .IsRequired()+ .HasColumnType("TEXT");++ b.Property<string>("Verifier")+ .IsRequired()+ .HasMaxLength(1000)+ .HasColumnType("TEXT");++ b.Property<string>("Version")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("TEXT");++ b.HasKey("Id");++ b.HasIndex("UserId");++ b.ToTable("Vaults");+ });++ modelBuilder.Entity("AliasVault.WorkerStatus.Database.WorkerServiceStatus", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("CurrentStatus")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("TEXT");++ b.Property<string>("DesiredStatus")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("TEXT");++ b.Property<DateTime>("Heartbeat")+ .HasColumnType("TEXT");++ b.Property<string>("ServiceName")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("varchar");++ b.HasKey("Id");++ b.ToTable("WorkerServiceStatuses");+ });++ modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ 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");++ 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");++ 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.NoAction)+ .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.UserEmailClaim", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("EmailClaims")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ 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.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/src/Databases/AliasServerDb/Migrations/20240906092833_AddVaultStatisticsColumns.cs b/src/Databases/AliasServerDb/Migrations/20240906092833_AddVaultStatisticsColumns.csnew file mode 100644index 000000000..b19b70cd2--- /dev/null+++ b/src/Databases/AliasServerDb/Migrations/20240906092833_AddVaultStatisticsColumns.cs@@ -0,0 +1,41 @@+// <auto-generated />+using Microsoft.EntityFrameworkCore.Migrations;++#nullable disable++namespace AliasServerDb.Migrations+{+ /// <inheritdoc />+ public partial class AddVaultStatisticsColumns : Migration+ {+ /// <inheritdoc />+ protected override void Up(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.AddColumn<int>(+ name: "CredentialsCount",+ table: "Vaults",+ type: "INTEGER",+ nullable: false,+ defaultValue: 0);++ migrationBuilder.AddColumn<int>(+ name: "EmailClaimsCount",+ table: "Vaults",+ type: "INTEGER",+ nullable: false,+ defaultValue: 0);+ }++ /// <inheritdoc />+ protected override void Down(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.DropColumn(+ name: "CredentialsCount",+ table: "Vaults");++ migrationBuilder.DropColumn(+ name: "EmailClaimsCount",+ table: "Vaults");+ }+ }+}diff --git a/src/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs b/src/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.csindex 93ad15318..6cb47e5e9 100644--- a/src/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs+++ b/src/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs@@ -539,6 +539,12 @@ namespace AliasServerDb.Migrationsb.Property<DateTime>("CreatedAt").HasColumnType("TEXT");+ b.Property<int>("CredentialsCount")+ .HasColumnType("INTEGER");++ b.Property<int>("EmailClaimsCount")+ .HasColumnType("INTEGER");+b.Property<int>("FileSize").HasColumnType("INTEGER");diff --git a/src/Databases/AliasServerDb/Vault.cs b/src/Databases/AliasServerDb/Vault.csindex 3bba5aa2c..b933ae8ce 100644--- a/src/Databases/AliasServerDb/Vault.cs+++ b/src/Databases/AliasServerDb/Vault.cs@@ -66,6 +66,18 @@ public class Vault[StringLength(1000)]public string Verifier { get; set; } = null!;+ /// <summary>+ /// Gets or sets the number of credentials stored in the vault. This anonymous data is used in case a vault back-up+ /// needs to be restored to get a better idea of the vault size.+ /// </summary>+ public int CredentialsCount { get; set; }++ /// <summary>+ /// Gets or sets the number of email claims stored in the vault. This anonymous data is used in case a vault back-up+ /// needs to be restored to get a better idea of the vault size.+ /// </summary>+ public int EmailClaimsCount { get; set; }+/// <summary>/// Gets or sets created timestamp./// </summary>