Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Rename UserUnlockKeys to UserUnlockMethods table definition (#2468)
Leendert de Borst1b9e2080e478
diff --git a/apps/server/AliasVault.Admin/Main/Pages/Settings/Server.razor b/apps/server/AliasVault.Admin/Main/Pages/Settings/Server.razorindex 887e83cc2..16748aaa1 100644--- a/apps/server/AliasVault.Admin/Main/Pages/Settings/Server.razor+++ b/apps/server/AliasVault.Admin/Main/Pages/Settings/Server.razor@@ -62,8 +62,8 @@Number of days to keep mobile login request logs before deletion. Set to 0 to disable automatic cleanup. </p></div><div>- <label for="unlockKeyHistoryRetention" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password Revert Window (days)</label>- <input type="number" @bind="Settings.UnlockKeyHistoryRetentionDays" id="unlockKeyHistoryRetention" min="0" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500">+ <label for="unlockMethodHistoryRetention" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Password Revert Window (days)</label>+ <input type="number" @bind="Settings.UnlockMethodHistoryRetentionDays" id="unlockMethodHistoryRetention" min="0" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600 focus:border-primary-600 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"><p class="mt-1 text-sm text-gray-500 dark:text-gray-400">Number of days a user's previous master password credentials are kept after a password change, so thatan admin can revert the change for a user who can no longer log in. Set to 0 disable retention.diff --git a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/PasswordHistoryTable.razor b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/PasswordHistoryTable.razorindex c6c2c17a2..546e329ed 100644--- a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/PasswordHistoryTable.razor+++ b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Components/PasswordHistoryTable.razor@@ -27,10 +27,10 @@ else@code {/// <summary>- /// Gets or sets the archived unlock keys still within the retention window.+ /// Gets or sets the archived unlock methods still within the retention window./// </summary>[Parameter]- public List<UserUnlockKeysHistory> PasswordHistoryList { get; set; } = [];+ public List<UserUnlockMethodsHistory> PasswordHistoryList { get; set; } = [];/// <summary>/// Gets or sets the retention window in days that produced this list, used to show when each row expires.@@ -42,7 +42,7 @@ else/// Gets or sets the event callback to revert the user's password to an archived credential./// </summary>[Parameter]- public EventCallback<UserUnlockKeysHistory> OnRevert { get; set; }+ public EventCallback<UserUnlockMethodsHistory> OnRevert { get; set; }private string SortColumn { get; set; } = "ArchivedAt";private SortDirection SortDirection { get; set; } = SortDirection.Descending;@@ -54,7 +54,7 @@ elsenew TableColumn { Title = "Actions", Sortable = false },];- private IEnumerable<UserUnlockKeysHistory> SortedPasswordHistoryList => SortList(PasswordHistoryList, SortColumn, SortDirection);+ private IEnumerable<UserUnlockMethodsHistory> SortedPasswordHistoryList => SortList(PasswordHistoryList, SortColumn, SortDirection);private void HandleSortChanged((string column, SortDirection direction) sort){@@ -63,7 +63,7 @@ elseStateHasChanged();}- private static IEnumerable<UserUnlockKeysHistory> SortList(List<UserUnlockKeysHistory> entries, string sortColumn, SortDirection sortDirection)+ private static IEnumerable<UserUnlockMethodsHistory> SortList(List<UserUnlockMethodsHistory> entries, string sortColumn, SortDirection sortDirection){return sortColumn switch{@@ -74,7 +74,7 @@ else};}- private async Task RevertAsync(UserUnlockKeysHistory entry)+ private async Task RevertAsync(UserUnlockMethodsHistory entry){if (await ConfirmModalService.ShowConfirmation(title: "Confirm Password Revert",diff --git a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razorindex 4c6c0fefa..bd1c49337 100644--- a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor+++ b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor@@ -258,7 +258,7 @@ elseAllows to revert a password change in case of a failure. Historic records are automatically deleted after the configured Password Revert Window.</p>- <PasswordHistoryTable PasswordHistoryList="@PasswordHistoryList" RetentionDays="@UnlockKeyHistoryRetentionDays" OnRevert="@RevertPasswordChangeAsync" />+ <PasswordHistoryTable PasswordHistoryList="@PasswordHistoryList" RetentionDays="@UnlockMethodHistoryRetentionDays" OnRevert="@RevertPasswordChangeAsync" /></div></div></div>@@ -312,8 +312,8 @@ elseprivate int TwoFactorKeysCount { get; set; }private List<AliasVaultUserRefreshToken> RefreshTokenList { get; set; } = [];private VaultStorageOverview StorageOverview { get; set; } = new();- private List<UserUnlockKeysHistory> PasswordHistoryList { get; set; } = [];- private int UnlockKeyHistoryRetentionDays { get; set; }+ private List<UserUnlockMethodsHistory> PasswordHistoryList { get; set; } = [];+ private int UnlockMethodHistoryRetentionDays { get; set; }private bool HasManifestAccessKeys { get; set; }private bool TakesPartInSharing { get; set; }private List<AuthLog> AuthLogList { get; set; } = [];@@ -402,9 +402,9 @@ elseTakesPartInSharing = await TakesPartInSharingAsync(dbContext, User.Id);// Load the archived master password credentials that are still inside the retention window.- UnlockKeyHistoryRetentionDays = (await SettingsService.GetAllSettingsAsync()).UnlockKeyHistoryRetentionDays;- PasswordHistoryList = await UnlockKeyHistoryPolicy- .WithinRetention(dbContext.UserUnlockKeysHistory.Where(x => x.UserId == User.Id), UnlockKeyHistoryRetentionDays, DateTime.UtcNow)+ UnlockMethodHistoryRetentionDays = (await SettingsService.GetAllSettingsAsync()).UnlockMethodHistoryRetentionDays;+ PasswordHistoryList = await UnlockMethodHistoryPolicy+ .WithinRetention(dbContext.UserUnlockMethodsHistory.Where(x => x.UserId == User.Id), UnlockMethodHistoryRetentionDays, DateTime.UtcNow).OrderByDescending(x => x.ArchivedAt).ToListAsync();@@ -706,14 +706,14 @@ Do you want to proceed with the revert?"))/// Restore a previous master password credential to the user's current one./// </summary>/// <param name="entry">The archived credential to restore.</param>- private async Task RevertPasswordChangeAsync(UserUnlockKeysHistory entry)+ private async Task RevertPasswordChangeAsync(UserUnlockMethodsHistory entry){await using var dbContext = await DbContextFactory.CreateDbContextAsync();var now = DateTime.UtcNow;// Re-read the row under the retention window to ensure it is still available.- var archived = await UnlockKeyHistoryPolicy- .WithinRetention(dbContext.UserUnlockKeysHistory.Where(x => x.Id == entry.Id && x.UserId == User!.Id), UnlockKeyHistoryRetentionDays, now)+ var archived = await UnlockMethodHistoryPolicy+ .WithinRetention(dbContext.UserUnlockMethodsHistory.Where(x => x.Id == entry.Id && x.UserId == User!.Id), UnlockMethodHistoryRetentionDays, now).FirstOrDefaultAsync();if (archived == null)@@ -723,8 +723,8 @@ Do you want to proceed with the revert?"))return;}- var unlockKey = await dbContext.UserUnlockKeys.FirstOrDefaultAsync(x => x.UserId == User!.Id && x.Type == archived.Type);- if (unlockKey == null)+ var unlockMethod = await dbContext.UserUnlockMethods.FirstOrDefaultAsync(x => x.UserId == User!.Id && x.Type == archived.Type);+ if (unlockMethod == null){GlobalNotificationService.AddErrorMessage("This user no longer has an unlock method of this type to revert.", true);return;@@ -736,14 +736,14 @@ Do you want to proceed with the revert?"))await using var writeContext = await DbContextFactory.CreateDbContextAsync();await using var transaction = await writeContext.Database.BeginTransactionAsync();- var target = await writeContext.UserUnlockKeys.FirstAsync(x => x.Id == unlockKey.Id);- var source = await writeContext.UserUnlockKeysHistory.FirstAsync(x => x.Id == archived.Id);+ var target = await writeContext.UserUnlockMethods.FirstAsync(x => x.Id == unlockMethod.Id);+ var source = await writeContext.UserUnlockMethodsHistory.FirstAsync(x => x.Id == archived.Id);await writeContext.AliasVaultUsers.Where(x => x.Id == User!.Id).ExecuteUpdateAsync(s => s.SetProperty(x => x.PasswordChangedAt, now));await writeContext.AliasVaultUserRefreshTokens.Where(x => x.UserId == User!.Id).ExecuteDeleteAsync();- writeContext.UserUnlockKeysHistory.Remove(source);+ writeContext.UserUnlockMethodsHistory.Remove(source);await writeContext.SaveChangesAsync();- await UnlockKeyHistoryPolicy.ArchiveAsync(writeContext, target, UnlockKeyHistoryRetentionDays, now, "admin-revert");+ await UnlockMethodHistoryPolicy.ArchiveAsync(writeContext, target, UnlockMethodHistoryRetentionDays, now, "admin-revert");source.RestoreOnto(target, now);await writeContext.SaveChangesAsync();diff --git a/apps/server/AliasVault.Api/Controllers/V2/AuthController.cs b/apps/server/AliasVault.Api/Controllers/V2/AuthController.csindex 7ca2dd4b3..bd38ea9b5 100644--- a/apps/server/AliasVault.Api/Controllers/V2/AuthController.cs+++ b/apps/server/AliasVault.Api/Controllers/V2/AuthController.cs@@ -128,7 +128,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM[HttpPost("validate")]public async Task<IActionResult> Validate([FromBody] ValidateLoginRequest model){- var (user, serverSession, unlockKeyId, error) = await ValidateUserAndPassword(model);+ var (user, serverSession, unlockMethodId, error) = await ValidateUserAndPassword(model);if (error is not null){// Error occured during validation, return the error.@@ -151,7 +151,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM// Reset failed login attempts.await userManager.ResetAccessFailedCountAsync(user);await authLoggingService.LogAuthEventSuccessAsync(model.Username, AuthEventType.Login);- await UpgradeLegacySrpVerifierAsync(unlockKeyId, model);+ await UpgradeLegacySrpVerifierAsync(unlockMethodId, model);var tokenModel = await GenerateNewTokensForUser(user, extendedLifetime: model.RememberMe);return Ok(new ValidateLoginResponse(false, serverSession!.Proof, tokenModel));@@ -165,7 +165,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM[HttpPost("validate-2fa")]public async Task<IActionResult> Validate2Fa([FromBody] ValidateLoginRequest2Fa model){- var (user, serverSession, unlockKeyId, error) = await ValidateUserAndPassword(model);+ var (user, serverSession, unlockMethodId, error) = await ValidateUserAndPassword(model);if (error is not null){// Error occured during validation, return the error.@@ -198,7 +198,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM// Validation of 2-FA token is successful, user is authenticated.await userManager.ResetAccessFailedCountAsync(user);await authLoggingService.LogAuthEventSuccessAsync(model.Username, AuthEventType.TwoFactorAuthentication);- await UpgradeLegacySrpVerifierAsync(unlockKeyId, model);+ await UpgradeLegacySrpVerifierAsync(unlockMethodId, model);// Generate and return the JWT token.var tokenModel = await GenerateNewTokensForUser(user, extendedLifetime: model.RememberMe);@@ -213,7 +213,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM[HttpPost("validate-recovery-code")]public async Task<IActionResult> ValidateRecoveryCode([FromBody] ValidateLoginRequestRecoveryCode model){- var (user, serverSession, unlockKeyId, error) = await ValidateUserAndPassword(model);+ var (user, serverSession, unlockMethodId, error) = await ValidateUserAndPassword(model);if (error is not null){// Error occured during validation, return the error.@@ -250,7 +250,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM// Recovery code is valid, user is authenticated.await userManager.ResetAccessFailedCountAsync(user);await authLoggingService.LogAuthEventSuccessAsync(model.Username, AuthEventType.TwoFactorAuthentication);- await UpgradeLegacySrpVerifierAsync(unlockKeyId, model);+ await UpgradeLegacySrpVerifierAsync(unlockMethodId, model);// Generate and return the JWT token.var tokenModel = await GenerateNewTokensForUser(user, extendedLifetime: model.RememberMe);@@ -444,7 +444,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM// Every new account is created on the account-key model, so the client must generate the whole hierarchy up front.// Reject an incomplete or oversized one before any row is written, so a rejected attempt leaves no account behind.var accountKeys = model.ToAccountKeysUpload();- var accountKeysError = AccountKeyHierarchyHelper.Validate(accountKeys, out var unlockKeyAlgorithm);+ var accountKeysError = AccountKeyHierarchyHelper.Validate(accountKeys, out var accountKeyAlgorithm);if (accountKeysError is not null){return ApiError.Result(accountKeysError.Value, 400);@@ -520,7 +520,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM});var srpCredentials = new VaultKeyMetadata { Salt = model.Salt, SrpVerifier = model.Verifier, EncryptionType = model.EncryptionType, EncryptionSettings = model.EncryptionSettings };- AccountKeyHierarchyHelper.AddEntities(context, user.Id, personalManifestId, accountKeys, unlockKeyAlgorithm, srpCredentials, timeProvider.GetUtcNow().UtcDateTime);+ AccountKeyHierarchyHelper.AddEntities(context, user.Id, personalManifestId, accountKeys, accountKeyAlgorithm, srpCredentials, timeProvider.GetUtcNow().UtcDateTime);await context.SaveChangesAsync();}@@ -590,8 +590,8 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM}await using var context = await dbContextFactory.CreateDbContextAsync();- var unlockKey = await context.UserUnlockKeys.FirstOrDefaultAsync(x => x.UserId == user.Id && x.Type == UnlockMethodType.Password);- if (unlockKey == null)+ var unlockMethod = await context.UserUnlockMethods.FirstOrDefaultAsync(x => x.UserId == user.Id && x.Type == UnlockMethodType.Password);+ if (unlockMethod == null){// Legacy users that have not migrated to v2 yet need to use the v1 flow (or migrate first).return ApiError.Result(ApiErrorCode.VAULT_KEY_NOT_FOUND, 400);@@ -604,7 +604,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserMreturn ApiError.Result(ApiErrorCode.INVALID_ENCRYPTION_PARAMETERS, 400);}- if (!VaultKeyAlgorithms.TryParse(model.NewEncryptedAccountKeyAlgorithm, out var newUnlockKeyAlgorithm) || VaultKeyAlgorithms.IsAsymmetric(newUnlockKeyAlgorithm))+ if (!VaultKeyAlgorithms.TryParse(model.NewEncryptedAccountKeyAlgorithm, out var newAccountKeyAlgorithm) || VaultKeyAlgorithms.IsAsymmetric(newAccountKeyAlgorithm)){return ApiError.Result(ApiErrorCode.INVALID_ALGORITHM, 400);}@@ -621,27 +621,27 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserMvar settings = await settingsService.GetAllSettingsAsync();var currentRefreshTokenId = Guid.TryParse(User.FindFirstValue(TokenService.RefreshTokenIdClaim), out var tokenId) ? tokenId : Guid.Empty;- var newMetadata = VaultKeyMetadata.Parse(unlockKey.Metadata);+ var newMetadata = VaultKeyMetadata.Parse(unlockMethod.Metadata);newMetadata.Salt = model.NewPasswordSalt;newMetadata.SrpVerifier = model.NewPasswordVerifier;newMetadata.EncryptionType = model.NewEncryptionType;newMetadata.EncryptionSettings = model.NewEncryptionSettings;var newMetadataJson = newMetadata.ToJson();- // Archive the superseded unlock key and update the current unlock key with the new credentials in a single transaction.+ // Archive the superseded unlock method and update the current unlock method with the new credentials in a single transaction.var strategy = context.Database.CreateExecutionStrategy();await strategy.ExecuteAsync(async () =>{await using var writeContext = await dbContextFactory.CreateDbContextAsync();await using var transaction = await writeContext.Database.BeginTransactionAsync();- await UnlockKeyHistoryPolicy.ArchiveAsync(writeContext, unlockKey, settings.UnlockKeyHistoryRetentionDays, now, ClientHeaderInfo.GetRawValue(Request));+ await UnlockMethodHistoryPolicy.ArchiveAsync(writeContext, unlockMethod, settings.UnlockMethodHistoryRetentionDays, now, ClientHeaderInfo.GetRawValue(Request));await writeContext.SaveChangesAsync();- await writeContext.UserUnlockKeys.Where(x => x.Id == unlockKey.Id).ExecuteUpdateAsync(s => s+ await writeContext.UserUnlockMethods.Where(x => x.Id == unlockMethod.Id).ExecuteUpdateAsync(s => s.SetProperty(x => x.Metadata, newMetadataJson).SetProperty(x => x.EncryptedAccountKey, model.NewEncryptedAccountKey)- .SetProperty(x => x.Algorithm, newUnlockKeyAlgorithm)+ .SetProperty(x => x.Algorithm, newAccountKeyAlgorithm).SetProperty(x => x.UpdatedAt, now));// Update the password last changed at timestamp for user.@@ -902,7 +902,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserMreturn ApiError.Result(ApiErrorCode.MOBILE_LOGIN_REQUEST_EXPIRED, 410);}- // The client needs the key derivation parameters next to the unlock key to be able to unlock offline later.+ // The client needs the key derivation parameters next to the Account Key to be able to unlock offline later.var tokenModel = await GenerateNewTokensForUser(user, extendedLifetime: true);var encryptionSettings = await AuthHelper.GetUserLatestVaultEncryptionSettingsAsync(context, user);var payload = new MobileLoginPayload@@ -962,7 +962,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM}/// <summary>- /// Approves a mobile login request: the mobile app hands in the account unlock key, encrypted with the client's public key.+ /// Approves a mobile login request: the mobile app hands in the Account Key, encrypted with the client's public key./// </summary>/// <param name="model">The mobile login submit request model.</param>/// <returns>IActionResult.</returns>@@ -1167,11 +1167,11 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM}/// <summary>- /// Validates the user and SRP session (password), then records usage of the proven unlock key.+ /// Validates the user and SRP session (password), then records usage of the proven unlock method./// </summary>/// <param name="model">ValidateLoginRequest model.</param>- /// <returns>User, SrpSession and the proven unlock key if validation succeeded, IActionResult as error on error.</returns>- private async Task<(AliasVaultUser? User, SrpSession? ServerSession, Guid? UnlockKeyId, IActionResult? Error)> ValidateUserAndPassword(ValidateLoginRequest model)+ /// <returns>User, SrpSession and the proven unlock method if validation succeeded, IActionResult as error on error.</returns>+ private async Task<(AliasVaultUser? User, SrpSession? ServerSession, Guid? UnlockMethodId, IActionResult? Error)> ValidateUserAndPassword(ValidateLoginRequest model){var result = await tokenService.ValidateUserAndPasswordAsync(model.Username, model.ClientPublicEphemeral, model.ClientSessionProof, model.LoginSessionId);if (result.Error is not null)@@ -1181,34 +1181,34 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM// Record usage of this unlock method for statistics purposes.await using var context = await dbContextFactory.CreateDbContextAsync();- await AuthHelper.TouchUnlockKeyLastUsedAsync(context, result.UnlockKeyId, timeProvider.GetUtcNow().UtcDateTime);+ await AuthHelper.TouchUnlockMethodLastUsedAsync(context, result.UnlockMethodId, timeProvider.GetUtcNow().UtcDateTime);- return (result.User, result.ServerSession, result.UnlockKeyId, null);+ return (result.User, result.ServerSession, result.UnlockMethodId, null);}/// <summary>- /// Replace the legacy verifier of the unlock key a completed login proved with the upgraded one the client sent.+ /// Replace the legacy verifier of the unlock method a completed login proved with the upgraded one the client sent./// </summary>- /// <param name="unlockKeyId">The unlock key the login proved; null for a legacy account, which keeps its verifier.</param>+ /// <param name="unlockMethodId">The unlock method the login proved; null for a legacy account, which keeps its verifier.</param>/// <param name="model">The validate request carrying the upgraded verifier.</param>/// <returns>Task.</returns>- private async Task UpgradeLegacySrpVerifierAsync(Guid? unlockKeyId, ValidateLoginRequest model)+ private async Task UpgradeLegacySrpVerifierAsync(Guid? unlockMethodId, ValidateLoginRequest model){/** Only after the whole login (2FA included): the proof shows the client holds the password, and the upgraded- * verifier keeps that same password and salt, so this is no password change. A legacy account (no unlock key+ * verifier keeps that same password and salt, so this is no password change. A legacy account (no unlock method* row) is skipped on purpose: v1 clients can still sign in to it and only know the legacy verifier.*/var upgrade = model.LegacyVerifierUpgrade;- if (unlockKeyId is null || upgrade is null || upgrade.EncryptionType != Defaults.EncryptionType || string.IsNullOrEmpty(upgrade.SrpVerifier) || upgrade.SrpVerifier.Length > MaxVerifierLength)+ if (unlockMethodId is null || upgrade is null || upgrade.EncryptionType != Defaults.EncryptionType || string.IsNullOrEmpty(upgrade.SrpVerifier) || upgrade.SrpVerifier.Length > MaxVerifierLength){return;}await using var context = await dbContextFactory.CreateDbContextAsync();- var unlockKey = await context.UserUnlockKeys.FirstOrDefaultAsync(x => x.Id == unlockKeyId.Value);- var metadata = VaultKeyMetadata.Parse(unlockKey?.Metadata);- if (unlockKey is null || metadata.EncryptionType != Defaults.LegacyEncryptionType)+ var unlockMethod = await context.UserUnlockMethods.FirstOrDefaultAsync(x => x.Id == unlockMethodId.Value);+ var metadata = VaultKeyMetadata.Parse(unlockMethod?.Metadata);+ if (unlockMethod is null || metadata.EncryptionType != Defaults.LegacyEncryptionType){return;}@@ -1218,7 +1218,7 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserMvar newMetadataJson = metadata.ToJson();// Conditional on the row being unchanged since it was read (a password change bumps UpdatedAt), so a concurrent change wins.- await context.UserUnlockKeys.Where(x => x.Id == unlockKey.Id && x.UpdatedAt == unlockKey.UpdatedAt).ExecuteUpdateAsync(s => s.SetProperty(x => x.Metadata, newMetadataJson));+ await context.UserUnlockMethods.Where(x => x.Id == unlockMethod.Id && x.UpdatedAt == unlockMethod.UpdatedAt).ExecuteUpdateAsync(s => s.SetProperty(x => x.Metadata, newMetadataJson));}/// <summary>diff --git a/apps/server/AliasVault.Api/Controllers/V2/Tests/TestController.cs b/apps/server/AliasVault.Api/Controllers/V2/Tests/TestController.csindex 1786f2dc2..73cf5298f 100644--- a/apps/server/AliasVault.Api/Controllers/V2/Tests/TestController.cs+++ b/apps/server/AliasVault.Api/Controllers/V2/Tests/TestController.cs@@ -374,7 +374,7 @@ public class TestController(}/// <summary>- /// Turn an account into one that predates the unlock-key model and holds a legacy (sqlite-blob) vault: the v2 key+ /// Turn an account into one that predates the unlock-method model and holds a legacy (sqlite-blob) vault: the v2 key/// material is removed so login falls back to the salt and verifier on the vault row, and the personal vault is/// overwritten with the given one./// Only available in DEBUG builds.@@ -401,7 +401,7 @@ public class TestController(await context.AliasVaultUsers.Where(u => u.Id != user.Id && u.SrpIdentity == request.SrpIdentity).ExecuteUpdateAsync(u => u.SetProperty(x => x.SrpIdentity, (string?)null));user.SrpIdentity = request.SrpIdentity;- context.UserUnlockKeys.RemoveRange(context.UserUnlockKeys.Where(x => x.UserId == user.Id));+ context.UserUnlockMethods.RemoveRange(context.UserUnlockMethods.Where(x => x.UserId == user.Id));context.UserGrantKeys.RemoveRange(context.UserGrantKeys.Where(x => x.UserId == user.Id));context.UserSigningKeys.RemoveRange(context.UserSigningKeys.Where(x => x.UserId == user.Id));context.VaultManifestAccessKeys.RemoveRange(context.VaultManifestAccessKeys.Where(x => x.UserId == user.Id));diff --git a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs b/apps/server/AliasVault.Api/Controllers/V2/VaultController.csindex cb2f6a892..d7a81098a 100644--- a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs+++ b/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs@@ -378,12 +378,12 @@ public class VaultController(var personalWrite = resolved.FirstOrDefault(r => r.Row.OwnerGroupId == user.PersonalGroupId).Write;// Account-key migration: a legacy vault's first manifest-v1 push includes a newly created Account Key hierarchy, which is accepted exactly once.- // Every later personal write must find the stored password unlock key. TODO: remove once legacy accounts are no longer supported.+ // Every later personal write must find the stored password unlock method. TODO: remove once legacy accounts are no longer supported.var accountKeys = model.Migration?.AccountKeys;- var hasExistingUnlockKey = await context.UserUnlockKeys.AnyAsync(x => x.UserId == user.Id && x.Type == UnlockMethodType.Password);+ var hasExistingUnlockMethod = await context.UserUnlockMethods.AnyAsync(x => x.UserId == user.Id && x.Type == UnlockMethodType.Password);if (accountKeys != null){- if (hasExistingUnlockKey)+ if (hasExistingUnlockMethod){return ApiError.Result(ApiErrorCode.VAULT_KEY_ALREADY_EXISTS, 400);}@@ -399,7 +399,7 @@ public class VaultController(return ApiError.Result(accountKeysError.Value, 400);}}- else if (personalWrite != null && !hasExistingUnlockKey)+ else if (personalWrite != null && !hasExistingUnlockMethod){return ApiError.Result(ApiErrorCode.VAULT_KEY_NOT_FOUND, 400);}@@ -532,8 +532,8 @@ public class VaultController(if (accountKeys != null){var srpCredentials = new VaultKeyMetadata { Salt = row.Salt, SrpVerifier = row.Verifier, EncryptionType = row.EncryptionType, EncryptionSettings = row.EncryptionSettings };- var unlockKeyAlgorithm = VaultKeyAlgorithms.Parse(accountKeys.EncryptedAccountKeyAlgorithm);- AccountKeyHierarchyHelper.AddEntities(context, user.Id, row.ManifestId, accountKeys, unlockKeyAlgorithm, srpCredentials, timeProvider.GetUtcNow().UtcDateTime);+ var accountKeyAlgorithm = VaultKeyAlgorithms.Parse(accountKeys.EncryptedAccountKeyAlgorithm);+ AccountKeyHierarchyHelper.AddEntities(context, user.Id, row.ManifestId, accountKeys, accountKeyAlgorithm, srpCredentials, timeProvider.GetUtcNow().UtcDateTime);row.Salt = null;row.Verifier = null;@@ -552,7 +552,7 @@ public class VaultController(}catch (DbUpdateException) when (accountKeys != null){- // A concurrent migration push won the race since the unlock key check above.+ // A concurrent migration push won the race since the unlock method check above.await tx.RollbackAsync();return ApiError.Result(ApiErrorCode.VAULT_KEY_ALREADY_EXISTS, 400);}@@ -652,8 +652,8 @@ public class VaultController(return ApiError.Result(ApiErrorCode.INVALID_REQUEST, 400);}- // Only allow overwriting the ciphertext if the user has no unlock key yet (as part of one-time legacy migration).- if (model.Overwrite && await context.UserUnlockKeys.AnyAsync(x => x.UserId == user.Id && x.Type == UnlockMethodType.Password))+ // Only allow overwriting the ciphertext if the user has no unlock method yet (as part of one-time legacy migration).+ if (model.Overwrite && await context.UserUnlockMethods.AnyAsync(x => x.UserId == user.Id && x.Type == UnlockMethodType.Password)){return ApiError.Result(ApiErrorCode.VAULT_KEY_ALREADY_EXISTS, 400);}diff --git a/apps/server/AliasVault.Api/Controllers/V2/VaultKeyController.cs b/apps/server/AliasVault.Api/Controllers/V2/VaultKeyController.csindex 2f62d3755..a20636045 100644--- a/apps/server/AliasVault.Api/Controllers/V2/VaultKeyController.cs+++ b/apps/server/AliasVault.Api/Controllers/V2/VaultKeyController.cs@@ -46,8 +46,8 @@ public class VaultKeyController(IAliasServerDbContextFactory dbContextFactory, Ureturn ApiError.Result(ApiErrorCode.INVALID_REQUEST, 400);}- var unlockKey = await context.UserUnlockKeys.FirstOrDefaultAsync(x => x.UserId == user.Id && x.Type == parsedType);- if (unlockKey == null)+ var unlockMethod = await context.UserUnlockMethods.FirstOrDefaultAsync(x => x.UserId == user.Id && x.Type == parsedType);+ if (unlockMethod == null){return Ok(new VaultKeyGetResponse { VaultKey = null });}@@ -68,15 +68,15 @@ public class VaultKeyController(IAliasServerDbContextFactory dbContextFactory, U.FirstOrDefaultAsync();// Get the KEK derivation parameters.- var credentials = VaultKeyMetadata.Parse(unlockKey.Metadata).RequireSrpCredentials();+ var credentials = VaultKeyMetadata.Parse(unlockMethod.Metadata).RequireSrpCredentials();return Ok(new VaultKeyGetResponse{VaultKey = new VaultKeyResponse{- Type = UnlockMethodTypes.ToToken(unlockKey.Type),- EncryptedAccountKey = unlockKey.EncryptedAccountKey,- Algorithm = VaultKeyAlgorithms.ToToken(unlockKey.Algorithm),+ Type = UnlockMethodTypes.ToToken(unlockMethod.Type),+ EncryptedAccountKey = unlockMethod.EncryptedAccountKey,+ Algorithm = VaultKeyAlgorithms.ToToken(unlockMethod.Algorithm),EncryptedVek = encryptedVek,AccountPublicKey = accountKeypair?.PublicKey,EncryptedAccountPrivateKey = accountKeypair?.EncryptedPrivateKey,diff --git a/apps/server/AliasVault.Api/Helpers/AccountKeyHierarchyHelper.cs b/apps/server/AliasVault.Api/Helpers/AccountKeyHierarchyHelper.csindex afc0cdebc..8777d296a 100644--- a/apps/server/AliasVault.Api/Helpers/AccountKeyHierarchyHelper.cs+++ b/apps/server/AliasVault.Api/Helpers/AccountKeyHierarchyHelper.cs@@ -21,11 +21,11 @@ public static class AccountKeyHierarchyHelper/// Validates an uploaded account key hierarchy, including the signing key's signature over the account public key./// </summary>/// <param name="keys">The uploaded keys.</param>- /// <param name="unlockKeyAlgorithm">The parsed algorithm of the encrypted Account Key, when valid.</param>+ /// <param name="accountKeyAlgorithm">The parsed algorithm of the encrypted Account Key, when valid.</param>/// <returns>Null when valid, else the error code to answer with.</returns>- public static ApiErrorCode? Validate(AccountKeysUpload keys, out VaultKeyAlgorithm unlockKeyAlgorithm)+ public static ApiErrorCode? Validate(AccountKeysUpload keys, out VaultKeyAlgorithm accountKeyAlgorithm){- unlockKeyAlgorithm = default;+ accountKeyAlgorithm = default;// Reject an incomplete or oversized hierarchy before any row is written.if (!keys.IsComplete || !keys.FitsStorageLimits || !RsaPublicKeyValidator.IsValid(keys.AccountPublicKey))@@ -38,7 +38,7 @@ public static class AccountKeyHierarchyHelperreturn ApiErrorCode.INVALID_REQUEST;}- if (!VaultKeyAlgorithms.TryParse(keys.EncryptedAccountKeyAlgorithm, out unlockKeyAlgorithm) || VaultKeyAlgorithms.IsAsymmetric(unlockKeyAlgorithm))+ if (!VaultKeyAlgorithms.TryParse(keys.EncryptedAccountKeyAlgorithm, out accountKeyAlgorithm) || VaultKeyAlgorithms.IsAsymmetric(accountKeyAlgorithm)){return ApiErrorCode.INVALID_ALGORITHM;}@@ -47,23 +47,23 @@ public static class AccountKeyHierarchyHelper}/// <summary>- /// Adds the password unlock key, grant key, signing key and personal manifest access key rows of a validated hierarchy to the context.+ /// Adds the password unlock method, grant key, signing key and personal manifest access key rows of a validated hierarchy to the context./// </summary>/// <param name="context">Database context, inside the caller's unit of work.</param>/// <param name="userId">The account owning the keys.</param>/// <param name="personalManifestId">The account's personal manifest.</param>/// <param name="keys">The keys, already accepted by <see cref="Validate"/>.</param>- /// <param name="unlockKeyAlgorithm">The algorithm returned by <see cref="Validate"/>.</param>- /// <param name="srpCredentials">The password unlock key's KDF parameters and SRP credentials.</param>+ /// <param name="accountKeyAlgorithm">The algorithm returned by <see cref="Validate"/>.</param>+ /// <param name="srpCredentials">The password unlock method's KDF parameters and SRP credentials.</param>/// <param name="now">The creation time.</param>- public static void AddEntities(AliasServerDbContext context, string userId, Guid personalManifestId, AccountKeysUpload keys, VaultKeyAlgorithm unlockKeyAlgorithm, VaultKeyMetadata srpCredentials, DateTime now)+ public static void AddEntities(AliasServerDbContext context, string userId, Guid personalManifestId, AccountKeysUpload keys, VaultKeyAlgorithm accountKeyAlgorithm, VaultKeyMetadata srpCredentials, DateTime now){- context.UserUnlockKeys.Add(new UserUnlockKey+ context.UserUnlockMethods.Add(new UserUnlockMethod{Id = Guid.NewGuid(),UserId = userId,Type = UnlockMethodType.Password,- Algorithm = unlockKeyAlgorithm,+ Algorithm = accountKeyAlgorithm,EncryptedAccountKey = keys.EncryptedAccountKey!,Metadata = srpCredentials.ToJson(),CreatedAt = now,diff --git a/apps/server/AliasVault.Api/Helpers/AuthHelper.cs b/apps/server/AliasVault.Api/Helpers/AuthHelper.csindex 743fd2431..ecc950661 100644--- a/apps/server/AliasVault.Api/Helpers/AuthHelper.cs+++ b/apps/server/AliasVault.Api/Helpers/AuthHelper.cs@@ -65,7 +65,7 @@ public static class AuthHelperpublic static string CreateSrpEphemeral(IMemoryCache cache, AliasVaultUser user, SrpPurpose purpose, UserSrpCredentials credentials, string? sessionId = null){var ephemeral = Srp.GenerateEphemeralServer(credentials.Verifier);- cache.Set(EphemeralCacheKey(purpose, user, sessionId), new CachedEphemeral(ephemeral.Secret, credentials.UnlockKeyId), EphemeralLifetime);+ cache.Set(EphemeralCacheKey(purpose, user, sessionId), new CachedEphemeral(ephemeral.Secret, credentials.UnlockMethodId), EphemeralLifetime);return ephemeral.Public;}@@ -103,7 +103,7 @@ public static class AuthHelper// The proof must answer the unlock method chosen at initiate; if that changed since (legacy account upgraded), the exchange is stale.var credentials = await GetUserLatestVaultEncryptionSettingsAsync(context, user);- if (credentials.UnlockKeyId != cached.UnlockKeyId)+ if (credentials.UnlockMethodId != cached.UnlockMethodId){cache.Remove(cacheKey);return new SrpValidationResult(null, false, null);@@ -125,7 +125,7 @@ public static class AuthHelpercache.Remove(cacheKey);}- return new SrpValidationResult(serverSession, true, credentials.UnlockKeyId);+ return new SrpValidationResult(serverSession, true, credentials.UnlockMethodId);}/// <summary>@@ -176,14 +176,14 @@ public static class AuthHelper/// </summary>/// <param name="context">Database context.</param>/// <param name="user">User object.</param>- /// <returns>The credentials the user authenticates with, and the unlock key they came from.</returns>+ /// <returns>The credentials the user authenticates with, and the unlock method they came from.</returns>public static async Task<UserSrpCredentials> GetUserLatestVaultEncryptionSettingsAsync(AliasServerDbContext context, AliasVaultUser user){// Get the user's current SRP salt/verifier and key derivation settings for the account-key KEK/VEK model.- var passwordKey = await context.UserUnlockKeys.FirstOrDefaultAsync(x => x.UserId == user.Id && x.Type == UnlockMethodType.Password);+ var passwordKey = await context.UserUnlockMethods.FirstOrDefaultAsync(x => x.UserId == user.Id && x.Type == UnlockMethodType.Password);if (passwordKey is not null){- return VaultKeyMetadata.Parse(passwordKey.Metadata).RequireSrpCredentials() with { UnlockKeyId = passwordKey.Id };+ return VaultKeyMetadata.Parse(passwordKey.Metadata).RequireSrpCredentials() with { UnlockMethodId = passwordKey.Id };}// Get the user's current SRP salt/verifier and key derivation settings for the legacy model.@@ -192,7 +192,7 @@ public static class AuthHelper.Select(x => new { x.Salt, x.Verifier, x.EncryptionType, x.EncryptionSettings }).FirstAsync();- // The SRP columns are null once a user moved to the unlock-key model, which the branch above already covers.+ // The SRP columns are null once a user moved to the unlock-method model, which the branch above already covers.return new UserSrpCredentials(latestVault.Salt ?? string.Empty, latestVault.Verifier ?? string.Empty, latestVault.EncryptionType ?? string.Empty, latestVault.EncryptionSettings ?? string.Empty);}@@ -201,17 +201,17 @@ public static class AuthHelper/// unlock methods a user has enrolled./// </summary>/// <param name="context">Database context.</param>- /// <param name="unlockKeyId">The unlock key that was proven, as returned by <see cref="ValidateSrpSessionAsync"/>.</param>+ /// <param name="unlockMethodId">The unlock method that was proven, as returned by <see cref="ValidateSrpSessionAsync"/>.</param>/// <param name="now">The timestamp to record.</param>/// <returns>Task.</returns>- public static async Task TouchUnlockKeyLastUsedAsync(AliasServerDbContext context, Guid? unlockKeyId, DateTime now)+ public static async Task TouchUnlockMethodLastUsedAsync(AliasServerDbContext context, Guid? unlockMethodId, DateTime now){- if (unlockKeyId is null)+ if (unlockMethodId is null){return;}- await context.UserUnlockKeys.Where(x => x.Id == unlockKeyId.Value).ExecuteUpdateAsync(s => s.SetProperty(x => x.LastUsedAt, now));+ await context.UserUnlockMethods.Where(x => x.Id == unlockMethodId.Value).ExecuteUpdateAsync(s => s.SetProperty(x => x.LastUsedAt, now));}/// <summary>@@ -283,7 +283,7 @@ public static class AuthHelper/// <summary>/// A cached server ephemeral and the unlock method whose verifier it was created for (null for a legacy account)./// </summary>- private sealed class CachedEphemeral(string secret, Guid? unlockKeyId)+ private sealed class CachedEphemeral(string secret, Guid? unlockMethodId){private int claimed;@@ -293,9 +293,9 @@ public static class AuthHelperpublic string Secret { get; } = secret;/// <summary>- /// Gets the unlock key the verifier came from.+ /// Gets the unlock method the verifier came from./// </summary>- public Guid? UnlockKeyId { get; } = unlockKeyId;+ public Guid? UnlockMethodId { get; } = unlockMethodId;/// <summary>/// Gets a value indicating whether the exchange has been used up.diff --git a/apps/server/AliasVault.Api/Models/LoginProofResult.cs b/apps/server/AliasVault.Api/Models/LoginProofResult.csindex 5ccad0d87..64f0b62c1 100644--- a/apps/server/AliasVault.Api/Models/LoginProofResult.cs+++ b/apps/server/AliasVault.Api/Models/LoginProofResult.cs@@ -16,6 +16,6 @@ using SecureRemotePassword;/// </summary>/// <param name="User">The user, set on success.</param>/// <param name="ServerSession">The SRP server session, set on success.</param>-/// <param name="UnlockKeyId">The unlock key the proof was checked against; null for a legacy account.</param>+/// <param name="UnlockMethodId">The unlock method the proof was checked against; null for a legacy account.</param>/// <param name="Error">The error code to answer with, null on success.</param>-public sealed record LoginProofResult(AliasVaultUser? User, SrpSession? ServerSession, Guid? UnlockKeyId, ApiErrorCode? Error);+public sealed record LoginProofResult(AliasVaultUser? User, SrpSession? ServerSession, Guid? UnlockMethodId, ApiErrorCode? Error);diff --git a/apps/server/AliasVault.Api/Models/SrpValidationResult.cs b/apps/server/AliasVault.Api/Models/SrpValidationResult.csindex 771c869e1..d9994f46f 100644--- a/apps/server/AliasVault.Api/Models/SrpValidationResult.cs+++ b/apps/server/AliasVault.Api/Models/SrpValidationResult.cs@@ -15,8 +15,8 @@ using SecureRemotePassword;/// </summary>/// <param name="Session">The derived server session, or null when the proof did not validate.</param>/// <param name="ActiveSessionFound">Whether a server ephemeral was still cached, i.e. whether the client actually initiated this exchange.</param>-/// <param name="UnlockKeyId">The unlock method whose secret was proven, or null for a legacy user that has no unlock key yet.</param>-public sealed record SrpValidationResult(SrpSession? Session, bool ActiveSessionFound, Guid? UnlockKeyId)+/// <param name="UnlockMethodId">The unlock method whose secret was proven, or null for a legacy user that has no unlock method yet.</param>+public sealed record SrpValidationResult(SrpSession? Session, bool ActiveSessionFound, Guid? UnlockMethodId){/// <summary>/// Gets a value indicating whether the proof was refused unchecked because the account is locked out.diff --git a/apps/server/AliasVault.Api/Services/TokenService.cs b/apps/server/AliasVault.Api/Services/TokenService.csindex 235c45064..b1c36430b 100644--- a/apps/server/AliasVault.Api/Services/TokenService.cs+++ b/apps/server/AliasVault.Api/Services/TokenService.cs@@ -272,7 +272,7 @@ public class TokenService(IAliasServerDbContextFactory dbContextFactory, UserManreturn new LoginProofResult(null, null, null, ApiErrorCode.USER_NOT_FOUND);}- return new LoginProofResult(user, srpResult.Session, srpResult.UnlockKeyId, null);+ return new LoginProofResult(user, srpResult.Session, srpResult.UnlockMethodId, null);}/// <summary>diff --git a/apps/server/AliasVault.TaskRunner/Tasks/MaintenanceTaskRegistration.cs b/apps/server/AliasVault.TaskRunner/Tasks/MaintenanceTaskRegistration.csindex d61133ba7..2d2c84db2 100644--- a/apps/server/AliasVault.TaskRunner/Tasks/MaintenanceTaskRegistration.cs+++ b/apps/server/AliasVault.TaskRunner/Tasks/MaintenanceTaskRegistration.cs@@ -25,7 +25,7 @@ public static class MaintenanceTaskRegistrationservices.AddTransient<IMaintenanceTask, EmailQuotaCleanupTask>();services.AddTransient<IMaintenanceTask, DisabledEmailCleanupTask>();services.AddTransient<IMaintenanceTask, OrphanedEmailCleanupTask>();- services.AddTransient<IMaintenanceTask, UnlockKeyHistoryCleanupTask>();+ services.AddTransient<IMaintenanceTask, UnlockMethodHistoryCleanupTask>();services.AddTransient<IMaintenanceTask, VaultBlobCleanupTask>();return services;diff --git a/apps/server/AliasVault.TaskRunner/Tasks/UnlockKeyHistoryCleanupTask.cs b/apps/server/AliasVault.TaskRunner/Tasks/UnlockMethodHistoryCleanupTask.cssimilarity index 65%rename from apps/server/AliasVault.TaskRunner/Tasks/UnlockKeyHistoryCleanupTask.csrename to apps/server/AliasVault.TaskRunner/Tasks/UnlockMethodHistoryCleanupTask.csindex a27bde26a..e2e4f852f 100644--- a/apps/server/AliasVault.TaskRunner/Tasks/UnlockKeyHistoryCleanupTask.cs+++ b/apps/server/AliasVault.TaskRunner/Tasks/UnlockMethodHistoryCleanupTask.cs@@ -1,5 +1,5 @@//------------------------------------------------------------------------// <copyright file="UnlockKeyHistoryCleanupTask.cs" company="aliasvault">+// <copyright file="UnlockMethodHistoryCleanupTask.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>@@ -12,26 +12,26 @@ using AliasServerDb.Retention;using AliasVault.Shared.Server.Services;/// <summary>-/// A maintenance task that deletes archived unlock keys which have fallen outside the retention window.+/// A maintenance task that deletes archived unlock methods which have fallen outside the retention window.////// This is the backstop, not the guarantee: the task runs once a day at the configured maintenance time, so the/// consumers of the archive apply the same window themselves and an expired row is already unusable before this/// task gets to remove it./// </summary>-public class UnlockKeyHistoryCleanupTask : IMaintenanceTask+public class UnlockMethodHistoryCleanupTask : IMaintenanceTask{- private readonly ILogger<UnlockKeyHistoryCleanupTask> _logger;+ private readonly ILogger<UnlockMethodHistoryCleanupTask> _logger;private readonly IAliasServerDbContextFactory _dbContextFactory;private readonly ServerSettingsService _settingsService;/// <summary>- /// Initializes a new instance of the <see cref="UnlockKeyHistoryCleanupTask"/> class.+ /// Initializes a new instance of the <see cref="UnlockMethodHistoryCleanupTask"/> class./// </summary>/// <param name="logger">The logger.</param>/// <param name="dbContextFactory">The database context factory.</param>/// <param name="settingsService">The server settings service.</param>- public UnlockKeyHistoryCleanupTask(- ILogger<UnlockKeyHistoryCleanupTask> logger,+ public UnlockMethodHistoryCleanupTask(+ ILogger<UnlockMethodHistoryCleanupTask> logger,IAliasServerDbContextFactory dbContextFactory,ServerSettingsService settingsService){@@ -41,7 +41,7 @@ public class UnlockKeyHistoryCleanupTask : IMaintenanceTask}/// <inheritdoc />- public string Name => "Unlock Key History Cleanup";+ public string Name => "Unlock Method History Cleanup";/// <inheritdoc />public async Task ExecuteAsync(CancellationToken cancellationToken)@@ -49,8 +49,8 @@ public class UnlockKeyHistoryCleanupTask : IMaintenanceTaskvar settings = await _settingsService.GetAllSettingsAsync();await using var dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);- var deletedCount = await UnlockKeyHistoryPolicy.DeleteExpiredAsync(dbContext.UserUnlockKeysHistory, settings.UnlockKeyHistoryRetentionDays, DateTime.UtcNow, cancellationToken);+ var deletedCount = await UnlockMethodHistoryPolicy.DeleteExpiredAsync(dbContext.UserUnlockMethodsHistory, settings.UnlockMethodHistoryRetentionDays, DateTime.UtcNow, cancellationToken);- _logger.LogInformation("Deleted {Count} archived unlock keys older than {Days} days", deletedCount, UnlockKeyHistoryPolicy.EffectiveRetentionDays(settings.UnlockKeyHistoryRetentionDays));+ _logger.LogInformation("Deleted {Count} archived unlock methods older than {Days} days", deletedCount, UnlockMethodHistoryPolicy.EffectiveRetentionDays(settings.UnlockMethodHistoryRetentionDays));}}diff --git a/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs b/apps/server/Databases/AliasServerDb/AliasServerDbContext.csindex 9d64809f7..2b73c5144 100644--- a/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs+++ b/apps/server/Databases/AliasServerDb/AliasServerDbContext.cs@@ -203,14 +203,14 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyConpublic DbSet<CapabilityRule> CapabilityRules { get; set; }/// <summary>- /// Gets or sets the UserUnlockKeys DbSet.+ /// Gets or sets the UserUnlockMethods DbSet./// </summary>- public DbSet<UserUnlockKey> UserUnlockKeys { get; set; }+ public DbSet<UserUnlockMethod> UserUnlockMethods { get; set; }/// <summary>- /// Gets or sets the UserUnlockKeysHistory DbSet.+ /// Gets or sets the UserUnlockMethodsHistory DbSet./// </summary>- public DbSet<UserUnlockKeysHistory> UserUnlockKeysHistory { get; set; }+ public DbSet<UserUnlockMethodsHistory> UserUnlockMethodsHistory { get; set; }/// <summary>/// Gets or sets the UserGrantKeys DbSet.@@ -478,8 +478,8 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyConbuilder.Property(e => e.Tier).HasConversion<string>().HasMaxLength(20);});- // Configure UserUnlockKey: one row per enrolled unlock method, each encrypting the user's Account Key.- modelBuilder.Entity<UserUnlockKey>(builder =>+ // Configure UserUnlockMethod: one row per enrolled unlock method, each encrypting the user's Account Key.+ modelBuilder.Entity<UserUnlockMethod>(builder =>{builder.HasOne(e => e.User).WithMany()@@ -488,23 +488,23 @@ public class AliasServerDbContext : WorkerStatusDbContext, IDataProtectionKeyCon// Label is part of the key so a user can enroll several methods of one type (two hardware keys, say)// while methods that must stay single, the password above all, keep it empty and so stay unique per type.- builder.HasIndex(e => new { e.UserId, e.Type, e.Label }).IsUnique().HasDatabaseName("UX_UserUnlockKeys_UserId_Type_Label");+ builder.HasIndex(e => new { e.UserId, e.Type, e.Label }).IsUnique().HasDatabaseName("UX_UserUnlockMethods_UserId_Type_Label");builder.Property(e => e.Metadata).HasColumnType("jsonb");builder.Property(e => e.Type).HasConversion(v => UnlockMethodTypes.ToToken(v), v => UnlockMethodTypes.Parse(v));builder.Property(e => e.Algorithm).HasConversion(v => VaultKeyAlgorithms.ToToken(v), v => VaultKeyAlgorithms.Parse(v));});- // Configure UserUnlockKeysHistory: superseded unlock keys, retained briefly so a password change can be reverted.- modelBuilder.Entity<UserUnlockKeysHistory>(builder =>+ // Configure UserUnlockMethodsHistory: superseded unlock methods, retained briefly so a password change can be reverted.+ modelBuilder.Entity<UserUnlockMethodsHistory>(builder =>{- builder.ToTable("UserUnlockKeysHistory");+ builder.ToTable("UserUnlockMethodsHistory");builder.HasOne(e => e.User).WithMany().HasForeignKey(e => e.UserId).OnDelete(DeleteBehavior.Cascade);- builder.HasIndex(e => new { e.UserId, e.Type, e.ArchivedAt }).HasDatabaseName("IX_UserUnlockKeysHistory_UserId_Type_ArchivedAt");- builder.HasIndex(e => e.ArchivedAt).HasDatabaseName("IX_UserUnlockKeysHistory_ArchivedAt");+ builder.HasIndex(e => new { e.UserId, e.Type, e.ArchivedAt }).HasDatabaseName("IX_UserUnlockMethodsHistory_UserId_Type_ArchivedAt");+ builder.HasIndex(e => e.ArchivedAt).HasDatabaseName("IX_UserUnlockMethodsHistory_ArchivedAt");builder.Property(e => e.Metadata).HasColumnType("jsonb");builder.Property(e => e.Type).HasConversion(v => UnlockMethodTypes.ToToken(v), v => UnlockMethodTypes.Parse(v));builder.Property(e => e.Algorithm).HasConversion(v => VaultKeyAlgorithms.ToToken(v), v => VaultKeyAlgorithms.Parse(v));diff --git a/apps/server/Databases/AliasServerDb/AliasVaultUser.cs b/apps/server/Databases/AliasServerDb/AliasVaultUser.csindex 843806dba..d48b4b62d 100644--- a/apps/server/Databases/AliasServerDb/AliasVaultUser.cs+++ b/apps/server/Databases/AliasServerDb/AliasVaultUser.cs@@ -66,7 +66,7 @@ public class AliasVaultUser : IdentityUserpublic DateTime? LastActivityDate { get; set; }/// <summary>- /// Gets or sets the collection of vault unlock keys (KEK/VEK model). Empty for users still on the legacy+ /// Gets or sets the encrypted VEKs this user holds, one per manifest. Empty for users still on the legacy/// model where the password-derived key encrypts the vault directly./// </summary>public virtual ICollection<VaultManifestAccessKey> VaultManifestAccessKeys { get; set; } = [];diff --git a/apps/server/Databases/AliasServerDb/Legacy/LegacyVaultRollback.cs b/apps/server/Databases/AliasServerDb/Legacy/LegacyVaultRollback.csindex f5fd0f641..8d30861ed 100644--- a/apps/server/Databases/AliasServerDb/Legacy/LegacyVaultRollback.cs+++ b/apps/server/Databases/AliasServerDb/Legacy/LegacyVaultRollback.cs@@ -66,8 +66,8 @@ public static class LegacyVaultRollbackawait context.VaultManifestAccessKeys.Where(x => x.UserId == userId).ExecuteDeleteAsync();await context.UserGrantKeys.Where(x => x.UserId == userId).ExecuteDeleteAsync();await context.UserSigningKeys.Where(x => x.UserId == userId).ExecuteDeleteAsync();- await context.UserUnlockKeysHistory.Where(x => x.UserId == userId).ExecuteDeleteAsync();- await context.UserUnlockKeys.Where(x => x.UserId == userId).ExecuteDeleteAsync();+ await context.UserUnlockMethodsHistory.Where(x => x.UserId == userId).ExecuteDeleteAsync();+ await context.UserUnlockMethods.Where(x => x.UserId == userId).ExecuteDeleteAsync();// Both the login credentials and the session key change, so every device has to authenticate again.await context.AliasVaultUserRefreshTokens.Where(x => x.UserId == userId).ExecuteDeleteAsync();diff --git a/apps/server/Databases/AliasServerDb/Migrations/20261016094025_RenameUnlockKeysToUnlockMethods.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20261016094025_RenameUnlockKeysToUnlockMethods.Designer.csnew file mode 100644index 000000000..3a0d69df7--- /dev/null+++ b/apps/server/Databases/AliasServerDb/Migrations/20261016094025_RenameUnlockKeysToUnlockMethods.Designer.cs@@ -0,0 +1,2208 @@+// <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("20261016094025_RenameUnlockKeysToUnlockMethods")]+ partial class RenameUnlockKeysToUnlockMethods+ {+ /// <inheritdoc />+ protected override void BuildTargetModel(ModelBuilder modelBuilder)+ {+#pragma warning disable 612, 618+ modelBuilder+ .HasAnnotation("ProductVersion", "10.0.12")+ .HasAnnotation("Proxies:ChangeTracking", false)+ .HasAnnotation("Proxies:CheckEquality", false)+ .HasAnnotation("Proxies:LazyLoading", true)+ .HasAnnotation("Relational:MaxIdentifierLength", 63);++ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);++ 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.AliasVaultUser", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<int>("AccessFailedCount")+ .HasColumnType("integer");++ b.Property<bool>("Blocked")+ .HasColumnType("boolean");++ b.Property<DateTime?>("BlockedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("ConcurrencyStamp")+ .HasColumnType("text");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Email")+ .HasColumnType("text");++ b.Property<bool>("EmailConfirmed")+ .HasColumnType("boolean");++ b.Property<DateTime?>("LastActivityDate")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("LockoutEnabled")+ .HasColumnType("boolean");++ b.Property<DateTimeOffset?>("LockoutEnd")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("NormalizedEmail")+ .HasColumnType("text");++ b.Property<string>("NormalizedUserName")+ .HasColumnType("text");++ b.Property<DateTime>("PasswordChangedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("PasswordHash")+ .HasColumnType("text");++ b.Property<Guid>("PersonalGroupId")+ .HasColumnType("uuid");++ b.Property<string>("PhoneNumber")+ .HasColumnType("text");++ b.Property<bool>("PhoneNumberConfirmed")+ .HasColumnType("boolean");++ b.Property<string>("SecurityStamp")+ .HasColumnType("text");++ b.Property<string>("SrpIdentity")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<bool>("TwoFactorEnabled")+ .HasColumnType("boolean");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserName")+ .HasColumnType("text");++ b.HasKey("Id");++ b.HasIndex("NormalizedUserName")+ .IsUnique()+ .HasDatabaseName("UX_AliasVaultUsers_NormalizedUserName");++ b.HasIndex("PersonalGroupId")+ .IsUnique()+ .HasDatabaseName("UX_AliasVaultUsers_PersonalGroupId");++ b.HasIndex("SrpIdentity")+ .IsUnique()+ .HasDatabaseName("UX_AliasVaultUsers_SrpIdentity");++ 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>("PreviousTokenHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<string>("TokenHash")+ .IsRequired()+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<string>("UserId")+ .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(255)+ .HasColumnType("character varying(255)");++ 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.CapabilityRule", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("CapabilityKey")+ .IsRequired()+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("ClientName")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("CreatedBy")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime?>("EffectiveFrom")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime?>("EffectiveUntil")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("Enabled")+ .HasColumnType("boolean");++ b.Property<Guid?>("GroupId")+ .HasColumnType("uuid");++ b.Property<string>("Kind")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<string>("Notes")+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<string>("Tier")+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Value")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("GroupId");++ b.HasIndex("Tier");++ b.HasIndex("UserId");++ b.HasIndex("CapabilityKey", "Enabled");++ b.ToTable("CapabilityRules");+ });++ modelBuilder.Entity("AliasServerDb.ClientAction", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid?>("ManifestId")+ .HasColumnType("uuid");++ b.Property<string>("Payload")+ .HasColumnType("jsonb");++ b.Property<Guid?>("TargetGroupId")+ .HasColumnType("uuid");++ b.Property<string>("TargetUserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("Type")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("Id");++ b.HasIndex("TargetGroupId");++ b.HasIndex("TargetUserId");++ b.ToTable("ClientActions");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<int>("AttachmentCount")+ .HasColumnType("integer");++ b.Property<DateTime>("Date")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime>("DateSystem")+ .HasColumnType("timestamp with time zone");++ 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")+ .HasColumnType("text");++ b.Property<byte[]>("MessageSourceBytes")+ .HasColumnType("bytea");++ b.Property<bool>("PushNotificationSent")+ .HasColumnType("boolean");++ b.Property<string>("Subject")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("To")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("ToDomain")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("ToLocal")+ .IsRequired()+ .HasColumnType("text");++ b.Property<bool>("Visible")+ .HasColumnType("boolean");++ b.HasKey("Id");++ b.HasIndex("Date");++ b.HasIndex("DateSystem");++ b.HasIndex("PushNotificationSent");++ b.HasIndex("Visible");++ b.HasIndex("To", "DateSystem");++ b.ToTable("Emails");+ });++ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<byte[]>("Bytes")+ .IsRequired()+ .HasColumnType("bytea");++ b.Property<DateTime>("Date")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("EmailId")+ .HasColumnType("integer");++ b.Property<string>("Filename")+ .IsRequired()+ .HasColumnType("text");++ b.Property<int>("Filesize")+ .HasColumnType("integer");++ b.Property<string>("MimeType")+ .IsRequired()+ .HasColumnType("text");++ b.HasKey("Id");++ b.HasIndex("EmailId");++ b.ToTable("EmailAttachments");+ });++ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Address")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("AddressDomain")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("AddressLocal")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<bool>("AnonymizedSenderCounted")+ .HasColumnType("boolean");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("State")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid?>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("Address")+ .IsUnique();++ b.HasIndex("VaultManifestId", "CreatedAt");++ b.HasIndex("VaultManifestId", "State");++ b.ToTable("EmailClaims");+ });++ modelBuilder.Entity("AliasServerDb.EmailDecryptionKey", b =>+ {+ b.Property<int>("EmailId")+ .HasColumnType("integer");++ b.Property<Guid>("VaultManifestDeliveryKeyId")+ .HasColumnType("uuid");++ b.Property<string>("EncryptedSymmetricKey")+ .IsRequired()+ .HasColumnType("text");++ b.HasKey("EmailId", "VaultManifestDeliveryKeyId");++ b.HasIndex("VaultManifestDeliveryKeyId", "EmailId");++ b.ToTable("EmailDecryptionKeys");+ });++ modelBuilder.Entity("AliasServerDb.EmailPart", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<byte[]>("Bytes")+ .IsRequired()+ .HasColumnType("bytea");++ b.Property<int>("EmailId")+ .HasColumnType("integer");++ b.Property<int>("PartIndex")+ .HasColumnType("integer");++ b.HasKey("Id");++ b.HasIndex("EmailId", "PartIndex")+ .IsUnique();++ b.ToTable("EmailParts");+ });++ modelBuilder.Entity("AliasServerDb.Group", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.PrimitiveCollection<int[]>("AnonymizedEmailAliasSenderCounts")+ .IsRequired()+ .ValueGeneratedOnAdd()+ .HasColumnType("integer[]")+ .HasDefaultValueSql("array_fill(0, ARRAY[64])");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("EmailsReceived")+ .HasColumnType("integer");++ b.Property<int>("MaxEmailAgeDays")+ .HasColumnType("integer");++ b.Property<int>("MaxEmails")+ .HasColumnType("integer");++ b.Property<string>("Name")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<bool>("ShadowBlocked")+ .HasColumnType("boolean");++ b.Property<DateTime?>("ShadowBlockedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Type")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("Id");++ b.ToTable("Groups");+ });++ modelBuilder.Entity("AliasServerDb.GroupInvitation", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Algorithm")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedName")+ .HasColumnType("text");++ b.Property<string>("EncryptedNameSignature")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("EncryptedVek")+ .HasColumnType("text");++ b.Property<string>("GrantSignature")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("GrantSignerPublicKey")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<Guid>("GroupId")+ .HasColumnType("uuid");++ b.Property<string>("InviteeUserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("InviterUserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime?>("RespondedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Role")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<string>("State")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid?>("UserGrantKeyId")+ .HasColumnType("uuid");++ b.Property<int>("VaultKeyVersion")+ .HasColumnType("integer");++ b.Property<Guid?>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("GroupId");++ b.HasIndex("InviterUserId");++ b.HasIndex("UserGrantKeyId");++ b.HasIndex("InviteeUserId", "State");++ b.HasIndex("VaultManifestId", "InviteeUserId")+ .IsUnique()+ .HasDatabaseName("UX_GroupInvitations_Manifest_Invitee_Pending")+ .HasFilter("\"State\" = 'Pending'");++ b.ToTable("GroupInvitations");+ });++ modelBuilder.Entity("AliasServerDb.GroupMember", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid>("GroupId")+ .HasColumnType("uuid");++ b.Property<string>("Role")+ .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.HasKey("Id");++ b.HasIndex("UserId");++ b.HasIndex("GroupId", "UserId")+ .IsUnique();++ b.ToTable("GroupMembers");+ });++ modelBuilder.Entity("AliasServerDb.Log", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("Application")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("Exception")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("Level")+ .IsRequired()+ .HasMaxLength(128)+ .HasColumnType("character varying(128)");++ b.Property<string>("LogEvent")+ .IsRequired()+ .HasColumnType("text")+ .HasColumnName("LogEvent");++ b.Property<string>("Message")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("MessageTemplate")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("Properties")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("SourceContext")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("TimeStamp")+ .HasColumnType("timestamp with time zone");++ b.HasKey("Id");++ b.HasIndex("Application");++ b.HasIndex("TimeStamp");++ b.ToTable("Logs", (string)null);+ });++ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>+ {+ b.Property<string>("Id")+ .HasColumnType("text");++ b.Property<string>("Algorithm")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime?>("ClearedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("ClientBrowser")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("ClientIpAddress")+ .HasColumnType("text");++ b.Property<string>("ClientName")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("ClientOperatingSystem")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("ClientPublicKey")+ .IsRequired()+ .HasColumnType("text");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime?>("DeclinedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedAccountKey")+ .HasColumnType("text");++ b.Property<DateTime?>("FulfilledAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("MobileIpAddress")+ .HasColumnType("text");++ b.Property<string>("PollSecretHash")+ .IsRequired()+ .HasMaxLength(44)+ .HasColumnType("character varying(44)");++ b.Property<DateTime?>("RetrievedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .HasColumnType("text");++ b.HasKey("Id");++ b.HasIndex(new[] { "ClientIpAddress" }, "IX_ClientIpAddress");++ b.HasIndex(new[] { "CreatedAt" }, "IX_CreatedAt");++ b.HasIndex(new[] { "MobileIpAddress" }, "IX_MobileIpAddress");++ b.HasIndex(new[] { "RetrievedAt", "ClearedAt", "FulfilledAt" }, "IX_RetrievedAt_ClearedAt_FulfilledAt");++ b.HasIndex(new[] { "UserId" }, "IX_UserId");++ b.ToTable("MobileLoginRequests");+ });++ modelBuilder.Entity("AliasServerDb.RateLimit", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<int?>("AppliesToAccountAgeMaxDays")+ .HasColumnType("integer");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("CreatedBy")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime?>("EffectiveFrom")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime?>("EffectiveUntil")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("Enabled")+ .HasColumnType("boolean");++ b.Property<Guid?>("GroupId")+ .HasColumnType("uuid");++ b.Property<int>("LimitType")+ .HasColumnType("integer");++ b.Property<int>("MaxCount")+ .HasColumnType("integer");++ b.Property<string>("Notes")+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<int?>("Tier")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("WindowSeconds")+ .HasColumnType("integer");++ b.HasKey("Id");++ b.HasIndex("GroupId");++ b.HasIndex("Tier");++ b.HasIndex("LimitType", "Enabled");++ b.ToTable("RateLimits");+ });++ modelBuilder.Entity("AliasServerDb.RegistrationInvite", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Code")+ .IsRequired()+ .HasMaxLength(32)+ .HasColumnType("character varying(32)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("CreatedBy")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime?>("ExpiresAt")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime?>("LastUsedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("MaxUses")+ .HasColumnType("integer");++ b.Property<string>("Note")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<int>("UseCount")+ .HasColumnType("integer");++ b.HasKey("Id");++ b.HasIndex(new[] { "Code" }, "IX_RegistrationInvite_Code")+ .IsUnique();++ b.ToTable("RegistrationInvites");+ });++ modelBuilder.Entity("AliasServerDb.ServerSetting", b =>+ {+ b.Property<string>("Key")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Value")+ .HasColumnType("text");++ b.HasKey("Key");++ b.ToTable("ServerSettings");+ });++ modelBuilder.Entity("AliasServerDb.TaskRunnerJob", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<TimeOnly?>("EndTime")+ .HasColumnType("time without time zone");++ b.Property<string>("ErrorMessage")+ .HasColumnType("text");++ b.Property<bool>("IsOnDemand")+ .HasColumnType("boolean");++ b.Property<string>("Name")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<DateTime>("RunDate")+ .HasColumnType("timestamp with time zone");++ b.Property<TimeOnly>("StartTime")+ .HasColumnType("time without time zone");++ b.Property<int>("Status")+ .HasColumnType("integer");++ b.HasKey("Id");++ b.ToTable("TaskRunnerJobs");+ });++ modelBuilder.Entity("AliasServerDb.UserGrantKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<int>("AccountKeyVersion")+ .HasColumnType("integer");++ b.Property<string>("Algorithm")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedPrivateKey")+ .IsRequired()+ .HasMaxLength(8000)+ .HasColumnType("character varying(8000)");++ b.Property<bool>("IsPrimary")+ .HasColumnType("boolean");++ b.Property<string>("PublicKey")+ .IsRequired()+ .HasMaxLength(2000)+ .HasColumnType("character varying(2000)");++ b.Property<string>("PublicKeySignature")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId")+ .IsUnique()+ .HasDatabaseName("UX_UserGrantKeys_User_Primary")+ .HasFilter("\"IsPrimary\"");++ b.ToTable("UserGrantKeys");+ });++ modelBuilder.Entity("AliasServerDb.UserSigningKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<int>("AccountKeyVersion")+ .HasColumnType("integer");++ b.Property<string>("Algorithm")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedPrivateKey")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<bool>("IsPrimary")+ .HasColumnType("boolean");++ b.Property<string>("PublicKey")+ .IsRequired()+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId")+ .IsUnique()+ .HasDatabaseName("UX_UserSigningKeys_User_Primary")+ .HasFilter("\"IsPrimary\"");++ b.ToTable("UserSigningKeys");+ });++ modelBuilder.Entity("AliasServerDb.UserUnlockMethod", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<int>("AccountKeyVersion")+ .HasColumnType("integer");++ b.Property<string>("Algorithm")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedAccountKey")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("Label")+ .IsRequired()+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<DateTime?>("LastUsedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Metadata")+ .HasColumnType("jsonb");++ b.Property<string>("Type")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("Id");++ b.HasIndex("UserId", "Type", "Label")+ .IsUnique()+ .HasDatabaseName("UX_UserUnlockMethods_UserId_Type_Label");++ b.ToTable("UserUnlockMethods");+ });++ modelBuilder.Entity("AliasServerDb.UserUnlockMethodsHistory", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<int>("AccountKeyVersion")+ .HasColumnType("integer");++ b.Property<string>("Algorithm")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("ArchivedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("ArchivedByClient")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedAccountKey")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("Label")+ .IsRequired()+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("Metadata")+ .HasColumnType("jsonb");++ b.Property<string>("Type")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<Guid>("UnlockMethodId")+ .HasColumnType("uuid");++ 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("ArchivedAt")+ .HasDatabaseName("IX_UserUnlockMethodsHistory_ArchivedAt");++ b.HasIndex("UserId", "Type", "ArchivedAt")+ .HasDatabaseName("IX_UserUnlockMethodsHistory_UserId_Type_ArchivedAt");++ b.ToTable("UserUnlockMethodsHistory", (string)null);+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>+ {+ b.Property<Guid>("ManifestId")+ .HasColumnType("uuid");++ b.Property<string>("Hash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<string>("Category")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedBlobKey")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<byte[]>("EncryptedData")+ .IsRequired()+ .HasColumnType("bytea");++ b.Property<int>("KeyVersion")+ .HasColumnType("integer");++ b.Property<int>("SizeBytes")+ .HasColumnType("integer");++ b.HasKey("ManifestId", "Hash");++ b.ToTable("VaultBlobObjects");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>+ {+ b.Property<Guid>("ManifestId")+ .HasColumnType("uuid");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("BlobHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.HasKey("ManifestId", "RevisionNumber", "BlobHash");++ b.ToTable("VaultBlobReferences");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>+ {+ b.Property<Guid>("ManifestId")+ .HasColumnType("uuid");++ b.Property<string>("Category")+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<string>("CiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<byte[]>("EncryptedData")+ .IsRequired()+ .HasColumnType("bytea");++ b.Property<int>("KeyVersion")+ .HasColumnType("integer");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("ManifestId", "Category");++ b.ToTable("VaultDataBuckets");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucketsHistory", b =>+ {+ b.Property<Guid>("ManifestId")+ .HasColumnType("uuid");++ b.Property<string>("Category")+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("CiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<byte[]>("EncryptedData")+ .IsRequired()+ .HasColumnType("bytea");++ b.Property<int>("KeyVersion")+ .HasColumnType("integer");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("ManifestId", "Category", "RevisionNumber");++ b.ToTable("VaultDataBucketsHistory");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>+ {+ b.Property<Guid>("ManifestId")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Client")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("CredentialsCount")+ .HasColumnType("integer");++ b.Property<int>("EmailClaimsCount")+ .HasColumnType("integer");++ b.Property<string>("EncryptionSettings")+ .HasColumnType("text");++ b.Property<string>("EncryptionType")+ .HasColumnType("text");++ b.Property<int>("FileSize")+ .HasColumnType("integer");++ b.Property<int>("KeyVersion")+ .HasColumnType("integer");++ b.Property<byte[]>("ManifestBlob")+ .HasColumnType("bytea");++ b.Property<string>("ManifestCiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<Guid>("OwnerGroupId")+ .HasColumnType("uuid");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("Salt")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("StorageFormat")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UpdatedByUserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("VaultBlob")+ .HasColumnType("text");++ b.Property<string>("Verifier")+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<string>("Version")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("ManifestId");++ b.HasIndex("OwnerGroupId");++ b.HasIndex("UpdatedByUserId");++ b.ToTable("VaultManifests");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestAccessKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<int?>("AccountKeyVersion")+ .HasColumnType("integer");++ b.Property<string>("Algorithm")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedVek")+ .IsRequired()+ .HasColumnType("text");++ b.Property<string>("GrantSignature")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("GrantSignerPublicKey")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("GrantSignerUserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<int>("KeyVersion")+ .HasColumnType("integer");++ b.Property<DateTime?>("LastUsedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("Metadata")+ .HasColumnType("jsonb");++ b.Property<string>("Type")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid?>("UserGrantKeyId")+ .HasColumnType("uuid");++ b.Property<string>("UserId")+ .IsRequired()+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<Guid>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("UserGrantKeyId");++ b.HasIndex("VaultManifestId")+ .HasDatabaseName("IX_VaultManifestAccessKeys_VaultManifestId");++ b.HasIndex("UserId", "Type", "VaultManifestId", "KeyVersion")+ .IsUnique()+ .HasDatabaseName("UX_VaultManifestAccessKeys_UserId_Type_Manifest_Version");++ b.ToTable("VaultManifestAccessKeys");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>+ {+ b.Property<Guid>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("uuid");++ b.Property<string>("Algorithm")+ .IsRequired()+ .HasMaxLength(30)+ .HasColumnType("character varying(30)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<bool>("IsPrimary")+ .HasColumnType("boolean");++ b.Property<string>("PublicKey")+ .IsRequired()+ .HasMaxLength(2000)+ .HasColumnType("character varying(2000)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<Guid>("VaultManifestId")+ .HasColumnType("uuid");++ b.HasKey("Id");++ b.HasIndex("VaultManifestId")+ .IsUnique()+ .HasDatabaseName("UX_VaultManifestDeliveryKeys_Manifest_Primary")+ .HasFilter("\"IsPrimary\"");++ b.HasIndex("VaultManifestId", "IsPrimary");++ b.ToTable("VaultManifestDeliveryKeys");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestShareDetails", b =>+ {+ b.Property<Guid>("ManifestId")+ .HasColumnType("uuid");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("EncryptedName")+ .HasMaxLength(2000)+ .HasColumnType("character varying(2000)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.HasKey("ManifestId");++ b.ToTable("VaultManifestShareDetails");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>+ {+ b.Property<Guid>("ManifestId")+ .HasColumnType("uuid");++ b.Property<long>("RevisionNumber")+ .HasColumnType("bigint");++ b.Property<string>("Client")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<DateTime>("CreatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<int>("CredentialsCount")+ .HasColumnType("integer");++ b.Property<int>("EmailClaimsCount")+ .HasColumnType("integer");++ b.Property<string>("EncryptionSettings")+ .HasColumnType("text");++ b.Property<string>("EncryptionType")+ .HasColumnType("text");++ b.Property<int>("FileSize")+ .HasColumnType("integer");++ b.Property<int>("KeyVersion")+ .HasColumnType("integer");++ b.Property<byte[]>("ManifestBlob")+ .HasColumnType("bytea");++ b.Property<string>("ManifestCiphertextHash")+ .HasMaxLength(64)+ .HasColumnType("character varying(64)");++ b.Property<string>("Salt")+ .HasMaxLength(100)+ .HasColumnType("character varying(100)");++ b.Property<string>("StorageFormat")+ .IsRequired()+ .HasMaxLength(20)+ .HasColumnType("character varying(20)");++ b.Property<DateTime>("UpdatedAt")+ .HasColumnType("timestamp with time zone");++ b.Property<string>("UpdatedByUserId")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.Property<string>("VaultBlob")+ .HasColumnType("text");++ b.Property<string>("Verifier")+ .HasMaxLength(1000)+ .HasColumnType("character varying(1000)");++ b.Property<string>("Version")+ .HasMaxLength(255)+ .HasColumnType("character varying(255)");++ b.HasKey("ManifestId", "RevisionNumber");++ b.HasIndex("UpdatedByUserId");++ b.ToTable("VaultManifestsHistory", (string)null);+ });++ modelBuilder.Entity("AliasVault.WorkerStatus.Database.WorkerServiceStatus", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("integer");++ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));++ b.Property<string>("CurrentStatus")+ .IsRequired()+ .HasMaxLength(50)+ .HasColumnType("character varying(50)");++ b.Property<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.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.IdentityUserToken<string>", b =>+ {+ b.Property<string>("UserId")+ .HasColumnType("text");++ b.Property<string>("LoginProvider")+ .HasColumnType("text");++ b.Property<string>("Name")+ .HasColumnType("text");++ b.Property<string>("Value")+ .HasColumnType("text");++ b.HasKey("UserId", "LoginProvider", "Name");++ b.ToTable("UserTokens", (string)null);+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.HasOne("AliasServerDb.Group", "PersonalGroup")+ .WithOne()+ .HasForeignKey("AliasServerDb.AliasVaultUser", "PersonalGroupId")+ .OnDelete(DeleteBehavior.Restrict)+ .IsRequired();++ b.Navigation("PersonalGroup");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.CapabilityRule", b =>+ {+ b.HasOne("AliasServerDb.Group", "Group")+ .WithMany()+ .HasForeignKey("GroupId")+ .OnDelete(DeleteBehavior.Cascade);++ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("Group");++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.ClientAction", b =>+ {+ b.HasOne("AliasServerDb.Group", "TargetGroup")+ .WithMany()+ .HasForeignKey("TargetGroupId")+ .OnDelete(DeleteBehavior.Cascade);++ b.HasOne("AliasServerDb.AliasVaultUser", "TargetUser")+ .WithMany()+ .HasForeignKey("TargetUserId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("TargetGroup");++ b.Navigation("TargetUser");+ });++ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>+ {+ b.HasOne("AliasServerDb.Email", "Email")+ .WithMany("Attachments")+ .HasForeignKey("EmailId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Email");+ });++ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")+ .WithMany()+ .HasForeignKey("VaultManifestId")+ .OnDelete(DeleteBehavior.SetNull);++ b.Navigation("VaultManifest");+ });++ modelBuilder.Entity("AliasServerDb.EmailDecryptionKey", b =>+ {+ b.HasOne("AliasServerDb.Email", "Email")+ .WithMany("DecryptionKeys")+ .HasForeignKey("EmailId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("AliasServerDb.VaultManifestDeliveryKey", "VaultManifestDeliveryKey")+ .WithMany("DecryptionKeys")+ .HasForeignKey("VaultManifestDeliveryKeyId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired()+ .HasConstraintName("FK_EmailDecryptionKeys_VaultManifestDeliveryKeys_DeliveryKeyId");++ b.Navigation("Email");++ b.Navigation("VaultManifestDeliveryKey");+ });++ modelBuilder.Entity("AliasServerDb.EmailPart", b =>+ {+ b.HasOne("AliasServerDb.Email", "Email")+ .WithMany("Parts")+ .HasForeignKey("EmailId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Email");+ });++ modelBuilder.Entity("AliasServerDb.GroupInvitation", b =>+ {+ b.HasOne("AliasServerDb.Group", "Group")+ .WithMany()+ .HasForeignKey("GroupId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("AliasServerDb.AliasVaultUser", "Invitee")+ .WithMany()+ .HasForeignKey("InviteeUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("AliasServerDb.AliasVaultUser", "Inviter")+ .WithMany()+ .HasForeignKey("InviterUserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("AliasServerDb.UserGrantKey", "UserGrantKey")+ .WithMany()+ .HasForeignKey("UserGrantKeyId")+ .OnDelete(DeleteBehavior.SetNull);++ b.Navigation("Group");++ b.Navigation("Invitee");++ b.Navigation("Inviter");++ b.Navigation("UserGrantKey");+ });++ modelBuilder.Entity("AliasServerDb.GroupMember", b =>+ {+ b.HasOne("AliasServerDb.Group", "Group")+ .WithMany("Members")+ .HasForeignKey("GroupId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Group");++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.RateLimit", b =>+ {+ b.HasOne("AliasServerDb.Group", "Group")+ .WithMany()+ .HasForeignKey("GroupId")+ .OnDelete(DeleteBehavior.Cascade);++ b.Navigation("Group");+ });++ modelBuilder.Entity("AliasServerDb.UserGrantKey", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.UserSigningKey", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.UserUnlockMethod", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.UserUnlockMethodsHistory", b =>+ {+ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany()+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")+ .WithMany()+ .HasForeignKey("ManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Manifest");+ });++ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")+ .WithMany()+ .HasForeignKey("ManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Manifest");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")+ .WithMany()+ .HasForeignKey("ManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Manifest");+ });++ modelBuilder.Entity("AliasServerDb.VaultDataBucketsHistory", b =>+ {+ b.HasOne("AliasServerDb.VaultDataBucket", "Bucket")+ .WithMany()+ .HasForeignKey("ManifestId", "Category")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("Bucket");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>+ {+ b.HasOne("AliasServerDb.Group", "OwnerGroup")+ .WithMany()+ .HasForeignKey("OwnerGroupId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("AliasServerDb.AliasVaultUser", "UpdatedByUser")+ .WithMany()+ .HasForeignKey("UpdatedByUserId")+ .OnDelete(DeleteBehavior.SetNull);++ b.Navigation("OwnerGroup");++ b.Navigation("UpdatedByUser");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestAccessKey", b =>+ {+ b.HasOne("AliasServerDb.UserGrantKey", "UserGrantKey")+ .WithMany()+ .HasForeignKey("UserGrantKeyId")+ .OnDelete(DeleteBehavior.SetNull);++ b.HasOne("AliasServerDb.AliasVaultUser", "User")+ .WithMany("VaultManifestAccessKeys")+ .HasForeignKey("UserId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("User");++ b.Navigation("UserGrantKey");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")+ .WithMany()+ .HasForeignKey("VaultManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("VaultManifest");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestShareDetails", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")+ .WithOne()+ .HasForeignKey("AliasServerDb.VaultManifestShareDetails", "ManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.Navigation("VaultManifest");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>+ {+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")+ .WithMany()+ .HasForeignKey("ManifestId")+ .OnDelete(DeleteBehavior.Cascade)+ .IsRequired();++ b.HasOne("AliasServerDb.AliasVaultUser", "UpdatedByUser")+ .WithMany()+ .HasForeignKey("UpdatedByUserId")+ .OnDelete(DeleteBehavior.SetNull);++ b.Navigation("Manifest");++ b.Navigation("UpdatedByUser");+ });++ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>+ {+ b.Navigation("VaultManifestAccessKeys");+ });++ modelBuilder.Entity("AliasServerDb.Email", b =>+ {+ b.Navigation("Attachments");++ b.Navigation("DecryptionKeys");++ b.Navigation("Parts");+ });++ modelBuilder.Entity("AliasServerDb.Group", b =>+ {+ b.Navigation("Members");+ });++ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>+ {+ b.Navigation("DecryptionKeys");+ });+#pragma warning restore 612, 618+ }+ }+}diff --git a/apps/server/Databases/AliasServerDb/Migrations/20261016094025_RenameUnlockKeysToUnlockMethods.cs b/apps/server/Databases/AliasServerDb/Migrations/20261016094025_RenameUnlockKeysToUnlockMethods.csnew file mode 100644index 000000000..29fa5c6ee--- /dev/null+++ b/apps/server/Databases/AliasServerDb/Migrations/20261016094025_RenameUnlockKeysToUnlockMethods.cs@@ -0,0 +1,48 @@+using Microsoft.EntityFrameworkCore.Migrations;++#nullable disable++namespace AliasServerDb.Migrations+{+ /// <summary>+ /// Renames UserUnlockKeys to UserUnlockMethods (and its history table and retention setting) in place; rows are kept as-is.+ /// </summary>+ public partial class RenameUnlockKeysToUnlockMethods : Migration+ {+ /// <inheritdoc />+ protected override void Up(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.Sql("""+ ALTER TABLE "UserUnlockKeys" RENAME CONSTRAINT "PK_UserUnlockKeys" TO "PK_UserUnlockMethods";+ ALTER TABLE "UserUnlockKeys" RENAME CONSTRAINT "FK_UserUnlockKeys_AliasVaultUsers_UserId" TO "FK_UserUnlockMethods_AliasVaultUsers_UserId";+ ALTER TABLE "UserUnlockKeysHistory" RENAME CONSTRAINT "PK_UserUnlockKeysHistory" TO "PK_UserUnlockMethodsHistory";+ ALTER TABLE "UserUnlockKeysHistory" RENAME CONSTRAINT "FK_UserUnlockKeysHistory_AliasVaultUsers_UserId" TO "FK_UserUnlockMethodsHistory_AliasVaultUsers_UserId";+ """);+ migrationBuilder.RenameTable(name: "UserUnlockKeys", newName: "UserUnlockMethods");+ migrationBuilder.RenameTable(name: "UserUnlockKeysHistory", newName: "UserUnlockMethodsHistory");+ migrationBuilder.RenameIndex(name: "UX_UserUnlockKeys_UserId_Type_Label", table: "UserUnlockMethods", newName: "UX_UserUnlockMethods_UserId_Type_Label");+ migrationBuilder.RenameIndex(name: "IX_UserUnlockKeysHistory_ArchivedAt", table: "UserUnlockMethodsHistory", newName: "IX_UserUnlockMethodsHistory_ArchivedAt");+ migrationBuilder.RenameIndex(name: "IX_UserUnlockKeysHistory_UserId_Type_ArchivedAt", table: "UserUnlockMethodsHistory", newName: "IX_UserUnlockMethodsHistory_UserId_Type_ArchivedAt");+ migrationBuilder.RenameColumn(name: "UnlockKeyId", table: "UserUnlockMethodsHistory", newName: "UnlockMethodId");+ migrationBuilder.Sql("""UPDATE "ServerSettings" SET "Key" = 'UnlockMethodHistoryRetentionDays' WHERE "Key" = 'UnlockKeyHistoryRetentionDays';""");+ }++ /// <inheritdoc />+ protected override void Down(MigrationBuilder migrationBuilder)+ {+ migrationBuilder.Sql("""UPDATE "ServerSettings" SET "Key" = 'UnlockKeyHistoryRetentionDays' WHERE "Key" = 'UnlockMethodHistoryRetentionDays';""");+ migrationBuilder.RenameColumn(name: "UnlockMethodId", table: "UserUnlockMethodsHistory", newName: "UnlockKeyId");+ migrationBuilder.RenameIndex(name: "IX_UserUnlockMethodsHistory_UserId_Type_ArchivedAt", table: "UserUnlockMethodsHistory", newName: "IX_UserUnlockKeysHistory_UserId_Type_ArchivedAt");+ migrationBuilder.RenameIndex(name: "IX_UserUnlockMethodsHistory_ArchivedAt", table: "UserUnlockMethodsHistory", newName: "IX_UserUnlockKeysHistory_ArchivedAt");+ migrationBuilder.RenameIndex(name: "UX_UserUnlockMethods_UserId_Type_Label", table: "UserUnlockMethods", newName: "UX_UserUnlockKeys_UserId_Type_Label");+ migrationBuilder.RenameTable(name: "UserUnlockMethodsHistory", newName: "UserUnlockKeysHistory");+ migrationBuilder.RenameTable(name: "UserUnlockMethods", newName: "UserUnlockKeys");+ migrationBuilder.Sql("""+ ALTER TABLE "UserUnlockKeys" RENAME CONSTRAINT "PK_UserUnlockMethods" TO "PK_UserUnlockKeys";+ ALTER TABLE "UserUnlockKeys" RENAME CONSTRAINT "FK_UserUnlockMethods_AliasVaultUsers_UserId" TO "FK_UserUnlockKeys_AliasVaultUsers_UserId";+ ALTER TABLE "UserUnlockKeysHistory" RENAME CONSTRAINT "PK_UserUnlockMethodsHistory" TO "PK_UserUnlockKeysHistory";+ ALTER TABLE "UserUnlockKeysHistory" RENAME CONSTRAINT "FK_UserUnlockMethodsHistory_AliasVaultUsers_UserId" TO "FK_UserUnlockKeysHistory_AliasVaultUsers_UserId";+ """);+ }+ }+}diff --git a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.csindex f3792e29d..a3a0893d1 100644--- a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs+++ b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs@@ -17,7 +17,7 @@ namespace AliasServerDb.Migrations{#pragma warning disable 612, 618modelBuilder- .HasAnnotation("ProductVersion", "10.0.10")+ .HasAnnotation("ProductVersion", "10.0.12").HasAnnotation("Proxies:ChangeTracking", false).HasAnnotation("Proxies:CheckEquality", false).HasAnnotation("Proxies:LazyLoading", true)@@ -1217,7 +1217,7 @@ namespace AliasServerDb.Migrationsb.ToTable("UserSigningKeys");});- modelBuilder.Entity("AliasServerDb.UserUnlockKey", b =>+ modelBuilder.Entity("AliasServerDb.UserUnlockMethod", b =>{b.Property<Guid>("Id").ValueGeneratedOnAdd()@@ -1266,12 +1266,12 @@ namespace AliasServerDb.Migrationsb.HasIndex("UserId", "Type", "Label").IsUnique()- .HasDatabaseName("UX_UserUnlockKeys_UserId_Type_Label");+ .HasDatabaseName("UX_UserUnlockMethods_UserId_Type_Label");- b.ToTable("UserUnlockKeys");+ b.ToTable("UserUnlockMethods");});- modelBuilder.Entity("AliasServerDb.UserUnlockKeysHistory", b =>+ modelBuilder.Entity("AliasServerDb.UserUnlockMethodsHistory", b =>{b.Property<Guid>("Id").ValueGeneratedOnAdd()@@ -1312,7 +1312,7 @@ namespace AliasServerDb.Migrations.HasMaxLength(30).HasColumnType("character varying(30)");- b.Property<Guid>("UnlockKeyId")+ b.Property<Guid>("UnlockMethodId").HasColumnType("uuid");b.Property<DateTime>("UpdatedAt")@@ -1326,12 +1326,12 @@ namespace AliasServerDb.Migrationsb.HasKey("Id");b.HasIndex("ArchivedAt")- .HasDatabaseName("IX_UserUnlockKeysHistory_ArchivedAt");+ .HasDatabaseName("IX_UserUnlockMethodsHistory_ArchivedAt");b.HasIndex("UserId", "Type", "ArchivedAt")- .HasDatabaseName("IX_UserUnlockKeysHistory_UserId_Type_ArchivedAt");+ .HasDatabaseName("IX_UserUnlockMethodsHistory_UserId_Type_ArchivedAt");- b.ToTable("UserUnlockKeysHistory", (string)null);+ b.ToTable("UserUnlockMethodsHistory", (string)null);});modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>@@ -2034,7 +2034,7 @@ namespace AliasServerDb.Migrationsb.Navigation("User");});- modelBuilder.Entity("AliasServerDb.UserUnlockKey", b =>+ modelBuilder.Entity("AliasServerDb.UserUnlockMethod", b =>{b.HasOne("AliasServerDb.AliasVaultUser", "User").WithMany()@@ -2045,7 +2045,7 @@ namespace AliasServerDb.Migrationsb.Navigation("User");});- modelBuilder.Entity("AliasServerDb.UserUnlockKeysHistory", b =>+ modelBuilder.Entity("AliasServerDb.UserUnlockMethodsHistory", b =>{b.HasOne("AliasServerDb.AliasVaultUser", "User").WithMany()diff --git a/apps/server/Databases/AliasServerDb/Retention/UnlockKeyHistoryPolicy.cs b/apps/server/Databases/AliasServerDb/Retention/UnlockMethodHistoryPolicy.cssimilarity index 62%rename from apps/server/Databases/AliasServerDb/Retention/UnlockKeyHistoryPolicy.csrename to apps/server/Databases/AliasServerDb/Retention/UnlockMethodHistoryPolicy.csindex 53bde2510..2e8432108 100644--- a/apps/server/Databases/AliasServerDb/Retention/UnlockKeyHistoryPolicy.cs+++ b/apps/server/Databases/AliasServerDb/Retention/UnlockMethodHistoryPolicy.cs@@ -1,5 +1,5 @@//------------------------------------------------------------------------// <copyright file="UnlockKeyHistoryPolicy.cs" company="aliasvault">+// <copyright file="UnlockMethodHistoryPolicy.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>@@ -9,9 +9,9 @@ namespace AliasServerDb.Retention;using Microsoft.EntityFrameworkCore;/// <summary>-/// The retention rule for <see cref="UserUnlockKeysHistory"/> rows.+/// The retention rule for <see cref="UserUnlockMethodsHistory"/> rows./// </summary>-public static class UnlockKeyHistoryPolicy+public static class UnlockMethodHistoryPolicy{/// <summary>/// Archived rows kept per (user, unlock method). Older ones are pruned as soon as a new one is archived.@@ -21,20 +21,20 @@ public static class UnlockKeyHistoryPolicy/// <summary>/// The retention window actually applied based on the server configuration./// </summary>- /// <param name="configuredDays">The configured UnlockKeyHistoryRetentionDays value.</param>+ /// <param name="configuredDays">The configured UnlockMethodHistoryRetentionDays value.</param>/// <returns>The retention window in days, never negative.</returns>public static int EffectiveRetentionDays(int configuredDays) => Math.Max(configuredDays, 0);/// <summary>- /// Archives an unlock key that is about to be overwritten and prunes older rows of that method to stay within <see cref="MaxRowsPerMethod"/>.+ /// Archives an unlock method that is about to be overwritten and prunes older rows of that method to stay within <see cref="MaxRowsPerMethod"/>./// </summary>/// <param name="context">Database context, inside the caller's transaction; the caller saves the added row.</param>- /// <param name="unlockKey">The unlock key as it is before being overwritten.</param>- /// <param name="configuredDays">The configured UnlockKeyHistoryRetentionDays value.</param>+ /// <param name="unlockMethod">The unlock method as it is before being overwritten.</param>+ /// <param name="configuredDays">The configured UnlockMethodHistoryRetentionDays value.</param>/// <param name="now">The current time.</param>/// <param name="client">The client (or marker such as "admin-revert") recorded on the archived row.</param>/// <returns>Task.</returns>- public static async Task ArchiveAsync(AliasServerDbContext context, UserUnlockKey unlockKey, int configuredDays, DateTime now, string? client)+ public static async Task ArchiveAsync(AliasServerDbContext context, UserUnlockMethod unlockMethod, int configuredDays, DateTime now, string? client){if (EffectiveRetentionDays(configuredDays) == 0){@@ -42,8 +42,8 @@ public static class UnlockKeyHistoryPolicy}// Prune first, leaving room for the row added below: the limit counts that row, so one fewer is skipped here.- var supersededIds = await context.UserUnlockKeysHistory- .Where(x => x.UserId == unlockKey.UserId && x.Type == unlockKey.Type)+ var supersededIds = await context.UserUnlockMethodsHistory+ .Where(x => x.UserId == unlockMethod.UserId && x.Type == unlockMethod.Type).OrderByDescending(x => x.ArchivedAt).Skip(MaxRowsPerMethod - 1).Select(x => x.Id)@@ -51,20 +51,20 @@ public static class UnlockKeyHistoryPolicyif (supersededIds.Count > 0){- await context.UserUnlockKeysHistory.Where(x => supersededIds.Contains(x.Id)).ExecuteDeleteAsync();+ await context.UserUnlockMethodsHistory.Where(x => supersededIds.Contains(x.Id)).ExecuteDeleteAsync();}- context.UserUnlockKeysHistory.Add(UserUnlockKeysHistory.CreateFrom(unlockKey, now, client));+ context.UserUnlockMethodsHistory.Add(UserUnlockMethodsHistory.CreateFrom(unlockMethod, now, client));}/// <summary>/// Narrows a query to the archived rows that are still within the retention window. Returns an empty query when archiving is off./// </summary>- /// <param name="query">The query over archived unlock keys.</param>- /// <param name="configuredDays">The configured UnlockKeyHistoryRetentionDays value.</param>+ /// <param name="query">The query over archived unlock methods.</param>+ /// <param name="configuredDays">The configured UnlockMethodHistoryRetentionDays value.</param>/// <param name="now">The current time.</param>/// <returns>The query narrowed to usable rows.</returns>- public static IQueryable<UserUnlockKeysHistory> WithinRetention(IQueryable<UserUnlockKeysHistory> query, int configuredDays, DateTime now)+ public static IQueryable<UserUnlockMethodsHistory> WithinRetention(IQueryable<UserUnlockMethodsHistory> query, int configuredDays, DateTime now){var days = EffectiveRetentionDays(configuredDays);if (days == 0)@@ -77,14 +77,14 @@ public static class UnlockKeyHistoryPolicy}/// <summary>- /// Deletes every archived unlock key that is outside of the retention window.+ /// Deletes every archived unlock method that is outside of the retention window./// </summary>- /// <param name="query">The query over archived unlock keys to sweep.</param>- /// <param name="configuredDays">The configured UnlockKeyHistoryRetentionDays value.</param>+ /// <param name="query">The query over archived unlock methods to sweep.</param>+ /// <param name="configuredDays">The configured UnlockMethodHistoryRetentionDays value.</param>/// <param name="now">The current time.</param>/// <param name="cancellationToken">Cancellation token.</param>/// <returns>The number of rows deleted.</returns>- public static async Task<int> DeleteExpiredAsync(IQueryable<UserUnlockKeysHistory> query, int configuredDays, DateTime now, CancellationToken cancellationToken = default)+ public static async Task<int> DeleteExpiredAsync(IQueryable<UserUnlockMethodsHistory> query, int configuredDays, DateTime now, CancellationToken cancellationToken = default){var days = EffectiveRetentionDays(configuredDays);if (days == 0)diff --git a/apps/server/Databases/AliasServerDb/UserGrantKey.cs b/apps/server/Databases/AliasServerDb/UserGrantKey.csindex 992a4b744..d07752ac1 100644--- a/apps/server/Databases/AliasServerDb/UserGrantKey.cs+++ b/apps/server/Databases/AliasServerDb/UserGrantKey.cs@@ -66,7 +66,7 @@ public class UserGrantKey/// <summary>/// Gets or sets the version of the user's Account Key that <see cref="EncryptedPrivateKey"/> is encrypted with;- /// see <see cref="UserUnlockKey.AccountKeyVersion"/>.+ /// see <see cref="UserUnlockMethod.AccountKeyVersion"/>./// </summary>public int AccountKeyVersion { get; set; }diff --git a/apps/server/Databases/AliasServerDb/UserSigningKey.cs b/apps/server/Databases/AliasServerDb/UserSigningKey.csindex be346a267..bb8bc6715 100644--- a/apps/server/Databases/AliasServerDb/UserSigningKey.cs+++ b/apps/server/Databases/AliasServerDb/UserSigningKey.cs@@ -59,7 +59,7 @@ public class UserSigningKey/// <summary>/// Gets or sets the version of the user's Account Key that <see cref="EncryptedPrivateKey"/> is encrypted with;- /// see <see cref="UserUnlockKey.AccountKeyVersion"/>.+ /// see <see cref="UserUnlockMethod.AccountKeyVersion"/>./// </summary>public int AccountKeyVersion { get; set; }diff --git a/apps/server/Databases/AliasServerDb/UserSrpCredentials.cs b/apps/server/Databases/AliasServerDb/UserSrpCredentials.csindex e68dfe732..beda02b6a 100644--- a/apps/server/Databases/AliasServerDb/UserSrpCredentials.cs+++ b/apps/server/Databases/AliasServerDb/UserSrpCredentials.cs@@ -14,5 +14,5 @@ namespace AliasServerDb;/// <param name="Verifier">The SRP verifier the server checks a client's proof against.</param>/// <param name="EncryptionType">How the client derives the SRP input from the password: Argon2IdHkdf, or legacy Argon2Id.</param>/// <param name="EncryptionSettings">The parameters belonging to the KDF named by <paramref name="EncryptionType"/>.</param>-/// <param name="UnlockKeyId">The <see cref="UserUnlockKey"/> these credentials came from, or null for a legacy user whose credentials still live on the vault manifest.</param>-public sealed record UserSrpCredentials(string Salt, string Verifier, string EncryptionType, string EncryptionSettings, Guid? UnlockKeyId = null);+/// <param name="UnlockMethodId">The <see cref="UserUnlockMethod"/> these credentials came from, or null for a legacy user whose credentials still live on the vault manifest.</param>+public sealed record UserSrpCredentials(string Salt, string Verifier, string EncryptionType, string EncryptionSettings, Guid? UnlockMethodId = null);diff --git a/apps/server/Databases/AliasServerDb/UserUnlockKey.cs b/apps/server/Databases/AliasServerDb/UserUnlockMethod.cssimilarity index 96%rename from apps/server/Databases/AliasServerDb/UserUnlockKey.csrename to apps/server/Databases/AliasServerDb/UserUnlockMethod.csindex d66df2fdb..7bee16a99 100644--- a/apps/server/Databases/AliasServerDb/UserUnlockKey.cs+++ b/apps/server/Databases/AliasServerDb/UserUnlockMethod.cs@@ -1,5 +1,5 @@//------------------------------------------------------------------------// <copyright file="UserUnlockKey.cs" company="aliasvault">+// <copyright file="UserUnlockMethod.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>@@ -14,7 +14,7 @@ using AliasVault.Shared.Models.Enums;/// User tied unlock method that a user uses to login to their own account. Every unlock method encrypts the same Account Key,/// which is then used to actually decrypt owned manifest's and grant keys./// </summary>-public class UserUnlockKey+public class UserUnlockMethod{/// <summary>/// Gets or sets the primary key.diff --git a/apps/server/Databases/AliasServerDb/UserUnlockKeysHistory.cs b/apps/server/Databases/AliasServerDb/UserUnlockMethodsHistory.cssimilarity index 77%rename from apps/server/Databases/AliasServerDb/UserUnlockKeysHistory.csrename to apps/server/Databases/AliasServerDb/UserUnlockMethodsHistory.csindex ce7988899..726abdcf2 100644--- a/apps/server/Databases/AliasServerDb/UserUnlockKeysHistory.cs+++ b/apps/server/Databases/AliasServerDb/UserUnlockMethodsHistory.cs@@ -1,5 +1,5 @@//------------------------------------------------------------------------// <copyright file="UserUnlockKeysHistory.cs" company="aliasvault">+// <copyright file="UserUnlockMethodsHistory.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>@@ -11,11 +11,11 @@ using System.ComponentModel.DataAnnotations.Schema;using AliasVault.Shared.Models.Enums;/// <summary>-/// A superseded <see cref="UserUnlockKey"/>, archived on a credential change to aid in reverting to+/// A superseded <see cref="UserUnlockMethod"/>, archived on a credential change to aid in reverting to/// previous credentials in case of a password change failure. These historic rows are automatically pruned/// after a certain number of days by the TaskRunner as configured by the server administrator./// </summary>-public class UserUnlockKeysHistory+public class UserUnlockMethodsHistory{/// <summary>/// Gets or sets the primary key.@@ -24,12 +24,12 @@ public class UserUnlockKeysHistorypublic Guid Id { get; set; }/// <summary>- /// Gets or sets the id of the <see cref="UserUnlockKey"/> row this is a superseded version of.+ /// Gets or sets the id of the <see cref="UserUnlockMethod"/> row this is a superseded version of./// </summary>- public Guid UnlockKeyId { get; set; }+ public Guid UnlockMethodId { get; set; }/// <summary>- /// Gets or sets the foreign key to the user this archived unlock key belonged to.+ /// Gets or sets the foreign key to the user this archived unlock method belonged to./// </summary>[StringLength(255)]public required string UserId { get; set; }@@ -69,7 +69,7 @@ public class UserUnlockKeysHistorypublic int AccountKeyVersion { get; set; }/// <summary>- /// Gets or sets the superseded unlock key's metadata as JSON: SRP salt and verifier, KDF parameters etc. Read and+ /// Gets or sets the superseded unlock method's metadata as JSON: SRP salt and verifier, KDF parameters etc. Read and/// written through <see cref="VaultKeyMetadata"/>./// </summary>public string? Metadata { get; set; }@@ -80,34 +80,34 @@ public class UserUnlockKeysHistorypublic DateTime CreatedAt { get; set; }/// <summary>- /// Gets or sets the timestamp at which the archived unlock key was last updated before being superseded.+ /// Gets or sets the timestamp at which the archived unlock method was last updated before being superseded./// </summary>public DateTime UpdatedAt { get; set; }/// <summary>- /// Gets or sets the timestamp at which this archived unlock key was archived. Retention is measured from here.+ /// Gets or sets the timestamp at which this archived unlock method was archived. Retention is measured from here./// </summary>public DateTime ArchivedAt { get; set; }/// <summary>- /// Gets or sets the client that performed the credential change which superseded this archived unlock key.+ /// Gets or sets the client that performed the credential change which superseded this archived unlock method./// </summary>[StringLength(255)]public string? ArchivedByClient { get; set; }/// <summary>- /// Creates a history row from an unlock key that is about to be overwritten with new credentials.+ /// Creates a history row from an unlock method that is about to be overwritten with new credentials./// </summary>- /// <param name="current">The unlock key row to archive.</param>+ /// <param name="current">The unlock method row to archive.</param>/// <param name="archivedAt">The timestamp retention is measured from.</param>/// <param name="client">The client performing the credential change, or null when unknown.</param>/// <returns>A new unsaved history entity carrying the current row's credentials.</returns>- public static UserUnlockKeysHistory CreateFrom(UserUnlockKey current, DateTime archivedAt, string? client)+ public static UserUnlockMethodsHistory CreateFrom(UserUnlockMethod current, DateTime archivedAt, string? client){- return new UserUnlockKeysHistory+ return new UserUnlockMethodsHistory{Id = Guid.NewGuid(),- UnlockKeyId = current.Id,+ UnlockMethodId = current.Id,UserId = current.UserId,Type = current.Type,Algorithm = current.Algorithm,@@ -123,11 +123,11 @@ public class UserUnlockKeysHistory}/// <summary>- /// Copies this archived row's credentials back onto a live unlock key, reverting it to these credentials.+ /// Copies this archived row's credentials back onto a live unlock method, reverting it to these credentials./// </summary>- /// <param name="target">The live unlock key row to restore onto.</param>+ /// <param name="target">The live unlock method row to restore onto.</param>/// <param name="now">The timestamp to stamp the restore with.</param>- public void RestoreOnto(UserUnlockKey target, DateTime now)+ public void RestoreOnto(UserUnlockMethod target, DateTime now){target.Algorithm = Algorithm;target.EncryptedAccountKey = EncryptedAccountKey;diff --git a/apps/server/Databases/AliasServerDb/VaultKeyMetadata.cs b/apps/server/Databases/AliasServerDb/VaultKeyMetadata.csindex ceb941389..6fa860089 100644--- a/apps/server/Databases/AliasServerDb/VaultKeyMetadata.cs+++ b/apps/server/Databases/AliasServerDb/VaultKeyMetadata.cs@@ -11,7 +11,7 @@ using System.Text.Json;using System.Text.Json.Serialization;/// <summary>-/// The per-method specific fields of a <see cref="UserUnlockKey"/> stored in a JSON column.+/// The per-method specific fields of a <see cref="UserUnlockMethod"/> stored in a JSON column./// </summary>public sealed class VaultKeyMetadata{@@ -74,7 +74,7 @@ public sealed class VaultKeyMetadata/// <summary>/// Helper method to return the SRP credentials and KDF parameters./// </summary>- /// <returns>The credentials, without the unlock key id which only the caller that loaded the row knows.</returns>+ /// <returns>The credentials, without the unlock method id which only the caller that loaded the row knows.</returns>public UserSrpCredentials RequireSrpCredentials(){if (Salt is null || SrpVerifier is null || EncryptionType is null || EncryptionSettings is null)diff --git a/apps/server/Databases/AliasServerDb/VaultManifestAccessKey.cs b/apps/server/Databases/AliasServerDb/VaultManifestAccessKey.csindex 6a13c241f..3ef1624be 100644--- a/apps/server/Databases/AliasServerDb/VaultManifestAccessKey.cs+++ b/apps/server/Databases/AliasServerDb/VaultManifestAccessKey.cs@@ -62,7 +62,7 @@ public class VaultManifestAccessKey/// <summary>/// Gets or sets the version of the user's Account Key that encrypted <see cref="EncryptedVek"/> (see- /// <see cref="UserUnlockKey.AccountKeyVersion"/>), or null when this row is a grant. Grants are encrypted to a+ /// <see cref="UserUnlockMethod.AccountKeyVersion"/>), or null when this row is a grant. Grants are encrypted to a/// public key rather than to the AK, and name their wrapping key through <see cref="UserGrantKeyId"/> instead./// </summary>public int? AccountKeyVersion { get; set; }@@ -99,8 +99,7 @@ public class VaultManifestAccessKeypublic string? GrantSignerPublicKey { get; set; }/// <summary>- /// Gets or sets optional per-key-type fields as JSON, e.g. SRP salt and verifier, KDF parameters etc. Read and written- /// through <see cref="VaultKeyMetadata"/>.+ /// Gets or sets optional per-key-type fields as JSON. Unused so far; reserved for future key types./// </summary>public string? Metadata { get; set; }diff --git a/apps/server/Databases/AliasServerDb/VaultManifestBase.cs b/apps/server/Databases/AliasServerDb/VaultManifestBase.csindex f252938e6..9cbfdc1a8 100644--- a/apps/server/Databases/AliasServerDb/VaultManifestBase.cs+++ b/apps/server/Databases/AliasServerDb/VaultManifestBase.cs@@ -15,7 +15,7 @@ using System.ComponentModel.DataAnnotations.Schema;/// <para>/// The columns the manifest-v1 format no longer uses are nullable so null reads as "not applicable to this revision":/// a revision with a null <see cref="VaultBlob"/>/<see cref="Version"/> is manifest-v1, and null SRP columns mean the-/// login credentials moved to the unlock-key model. Only legacy sqlite-blob revisions carry values there.+/// login credentials moved to the unlock-method model. Only legacy sqlite-blob revisions carry values there./// </para>/// </summary>public abstract class VaultManifestBase : IVaultRevisiondiff --git a/apps/server/Shared/AliasVault.Shared.Server/Models/ServerSettingsModel.cs b/apps/server/Shared/AliasVault.Shared.Server/Models/ServerSettingsModel.csindex e51b0e907..f65462a3b 100644--- a/apps/server/Shared/AliasVault.Shared.Server/Models/ServerSettingsModel.cs+++ b/apps/server/Shared/AliasVault.Shared.Server/Models/ServerSettingsModel.cs@@ -29,10 +29,10 @@ public class ServerSettingsModelpublic int MobileLoginLogRetentionDays { get; set; } = 30;/// <summary>- /// Gets or sets the number of days a superseded unlock key is kept so an operator can revert a password change.- /// Defaults to 7. Set to 0 to disable retention which means superseded unlock keys are immediately deleted.+ /// Gets or sets the number of days a superseded unlock method is kept so an operator can revert a password change.+ /// Defaults to 7. Set to 0 to disable retention which means superseded unlock methods are immediately deleted./// </summary>- public int UnlockKeyHistoryRetentionDays { get; set; } = 7;+ public int UnlockMethodHistoryRetentionDays { get; set; } = 7;/// <summary>/// Gets or sets the number of hours a freshly uploaded encrypted vault blob is kept while no vault revisiondiff --git a/apps/server/Shared/AliasVault.Shared.Server/Services/ServerSettingsService.cs b/apps/server/Shared/AliasVault.Shared.Server/Services/ServerSettingsService.csindex 585fe26d5..f4ac5a1c0 100644--- a/apps/server/Shared/AliasVault.Shared.Server/Services/ServerSettingsService.cs+++ b/apps/server/Shared/AliasVault.Shared.Server/Services/ServerSettingsService.cs@@ -134,9 +134,9 @@ public class ServerSettingsService(IAliasServerDbContextFactory dbContextFactorymodel.AuthLogRetentionDays = authDays;}- if (int.TryParse(settings.GetValueOrDefault("UnlockKeyHistoryRetentionDays"), out var unlockKeyHistoryDays))+ if (int.TryParse(settings.GetValueOrDefault("UnlockMethodHistoryRetentionDays"), out var unlockMethodHistoryDays)){- model.UnlockKeyHistoryRetentionDays = unlockKeyHistoryDays;+ model.UnlockMethodHistoryRetentionDays = unlockMethodHistoryDays;}if (int.TryParse(settings.GetValueOrDefault("UnreferencedBlobGraceHours"), out var unreferencedBlobHours))@@ -230,7 +230,7 @@ public class ServerSettingsService(IAliasServerDbContextFactory dbContextFactory{await SetSettingAsync("GeneralLogRetentionDays", model.GeneralLogRetentionDays.ToString());await SetSettingAsync("AuthLogRetentionDays", model.AuthLogRetentionDays.ToString());- await SetSettingAsync("UnlockKeyHistoryRetentionDays", model.UnlockKeyHistoryRetentionDays.ToString());+ await SetSettingAsync("UnlockMethodHistoryRetentionDays", model.UnlockMethodHistoryRetentionDays.ToString());await SetSettingAsync("UnreferencedBlobGraceHours", model.UnreferencedBlobGraceHours.ToString());await SetSettingAsync("EmailRetentionDays", model.EmailRetentionDays.ToString());await SetSettingAsync("DisabledEmailRetentionDays", model.DisabledEmailRetentionDays.ToString());diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginInitiateRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginInitiateRequest.csindex b87fad4ff..d351b013f 100644--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginInitiateRequest.cs+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginInitiateRequest.cs@@ -15,7 +15,7 @@ using System.ComponentModel.DataAnnotations;public class MobileLoginInitiateRequest{/// <summary>- /// Gets or sets the RSA public key (JWK) of the initiating client, which the mobile app encrypts the unlock key with.+ /// Gets or sets the RSA public key (JWK) of the initiating client, which the mobile app encrypts the Account Key with./// </summary>[Required]public required string ClientPublicKey { get; set; }diff --git a/apps/server/Tests/AliasVault.IntegrationTests/TaskRunner/Helpers/SeedData.cs b/apps/server/Tests/AliasVault.IntegrationTests/TaskRunner/Helpers/SeedData.csindex 765ba0a06..2766184b5 100644--- a/apps/server/Tests/AliasVault.IntegrationTests/TaskRunner/Helpers/SeedData.cs+++ b/apps/server/Tests/AliasVault.IntegrationTests/TaskRunner/Helpers/SeedData.cs@@ -34,7 +34,7 @@ public static class SeedDatanew() { Key = "MaxEmailsPerUser", Value = "100" },new() { Key = "MaintenanceTime", Value = "00:00" },new() { Key = "TaskRunnerDays", Value = "1,2,3,4,5,6,7" },- new() { Key = "UnlockKeyHistoryRetentionDays", Value = "7" },+ new() { Key = "UnlockMethodHistoryRetentionDays", Value = "7" },new() { Key = "UnreferencedBlobGraceHours", Value = "24" },};@@ -46,7 +46,7 @@ public static class SeedDataawait SeedEmails(dbContext, testUser.DeliveryKey.Id);await SeedLogs(dbContext);await SeedAuthLogs(dbContext);- await SeedUnlockKeyHistory(dbContext, testUser.User.Id);+ await SeedUnlockMethodHistory(dbContext, testUser.User.Id);SeedVaultBlobs(dbContext, testUser.Manifest);await dbContext.SaveChangesAsync();@@ -133,16 +133,16 @@ public static class SeedData}/// <summary>- /// Seeds the database with archived unlock keys on both sides of the 7 day retention window.+ /// Seeds the database with archived unlock methods on both sides of the 7 day retention window./// </summary>/// <param name="dbContext">The database context.</param>/// <param name="userId">The user the archived credentials belong to.</param>/// <returns>Task.</returns>- private static async Task SeedUnlockKeyHistory(AliasServerDbContext dbContext, string userId)+ private static async Task SeedUnlockMethodHistory(AliasServerDbContext dbContext, string userId){- await dbContext.UserUnlockKeysHistory.AddRangeAsync(- CreateTestUnlockKeyHistory(userId, -10, "expired"),- CreateTestUnlockKeyHistory(userId, -1, "recent"));+ await dbContext.UserUnlockMethodsHistory.AddRangeAsync(+ CreateTestUnlockMethodHistory(userId, -10, "expired"),+ CreateTestUnlockMethodHistory(userId, -1, "recent"));}/// <summary>@@ -199,19 +199,19 @@ public static class SeedData}/// <summary>- /// Creates an archived unlock key for the tests.+ /// Creates an archived unlock method for the tests./// </summary>/// <param name="userId">The user the credential belongs to.</param>/// <param name="daysOffset">How long ago the credential was archived.</param>/// <param name="label">Label identifying the row in assertions.</param>- /// <returns>UserUnlockKeysHistory.</returns>- private static UserUnlockKeysHistory CreateTestUnlockKeyHistory(string userId, int daysOffset, string label)+ /// <returns>UserUnlockMethodsHistory.</returns>+ private static UserUnlockMethodsHistory CreateTestUnlockMethodHistory(string userId, int daysOffset, string label){var archivedAt = DateTime.UtcNow.AddDays(daysOffset);- return new UserUnlockKeysHistory+ return new UserUnlockMethodsHistory{Id = Guid.NewGuid(),- UnlockKeyId = Guid.NewGuid(),+ UnlockMethodId = Guid.NewGuid(),UserId = userId,Type = UnlockMethodType.Password,Algorithm = VaultKeyAlgorithm.Aes256Gcm,diff --git a/apps/server/Tests/AliasVault.IntegrationTests/TaskRunner/TaskRunnerTests.cs b/apps/server/Tests/AliasVault.IntegrationTests/TaskRunner/TaskRunnerTests.csindex d1f8f49c4..730bad6ac 100644--- a/apps/server/Tests/AliasVault.IntegrationTests/TaskRunner/TaskRunnerTests.cs+++ b/apps/server/Tests/AliasVault.IntegrationTests/TaskRunner/TaskRunnerTests.cs@@ -142,19 +142,19 @@ public class TaskRunnerTests}/// <summary>- /// Tests that the UnlockKeyHistoryCleanup task discards archived master password credentials once they fall+ /// Tests that the UnlockMethodHistoryCleanup task discards archived master password credentials once they fall/// outside the retention window, while leaving the ones still inside it available for a revert./// </summary>/// <returns>Task.</returns>[Test]- public async Task UnlockKeyHistoryCleanup()+ public async Task UnlockMethodHistoryCleanup(){// Arrangeawait InitializeWithTestData();// Assertawait using var dbContext = await _testHostBuilder.GetDbContextAsync();- var archivedKeys = await dbContext.UserUnlockKeysHistory.ToListAsync();+ var archivedKeys = await dbContext.UserUnlockMethodsHistory.ToListAsync();Assert.That(archivedKeys, Has.Count.EqualTo(1), "Only the archived credential inside the retention window should remain");Assert.That(archivedKeys[0].Label, Is.EqualTo("recent"));diff --git a/apps/server/Tests/AliasVault.UnitTests/Vault/UnlockKeyHistoryPolicyTests.cs b/apps/server/Tests/AliasVault.UnitTests/Vault/UnlockMethodHistoryPolicyTests.cssimilarity index 77%rename from apps/server/Tests/AliasVault.UnitTests/Vault/UnlockKeyHistoryPolicyTests.csrename to apps/server/Tests/AliasVault.UnitTests/Vault/UnlockMethodHistoryPolicyTests.csindex 9c644978f..9339204e1 100644--- a/apps/server/Tests/AliasVault.UnitTests/Vault/UnlockKeyHistoryPolicyTests.cs+++ b/apps/server/Tests/AliasVault.UnitTests/Vault/UnlockMethodHistoryPolicyTests.cs@@ -1,5 +1,5 @@//------------------------------------------------------------------------// <copyright file="UnlockKeyHistoryPolicyTests.cs" company="aliasvault">+// <copyright file="UnlockMethodHistoryPolicyTests.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>@@ -14,7 +14,7 @@ using AliasVault.Shared.Models.Enums;/// <summary>/// Tests for the retention rule that determines how long a superseded master password credential stays recoverable./// </summary>-public class UnlockKeyHistoryPolicyTests+public class UnlockMethodHistoryPolicyTests{private DateTime now;@@ -36,9 +36,9 @@ public class UnlockKeyHistoryPolicyTests{Assert.Multiple(() =>{- Assert.That(UnlockKeyHistoryPolicy.EffectiveRetentionDays(1), Is.EqualTo(1));- Assert.That(UnlockKeyHistoryPolicy.EffectiveRetentionDays(7), Is.EqualTo(7));- Assert.That(UnlockKeyHistoryPolicy.EffectiveRetentionDays(3650), Is.EqualTo(3650));+ Assert.That(UnlockMethodHistoryPolicy.EffectiveRetentionDays(1), Is.EqualTo(1));+ Assert.That(UnlockMethodHistoryPolicy.EffectiveRetentionDays(7), Is.EqualTo(7));+ Assert.That(UnlockMethodHistoryPolicy.EffectiveRetentionDays(3650), Is.EqualTo(3650));});}@@ -50,8 +50,8 @@ public class UnlockKeyHistoryPolicyTests{Assert.Multiple(() =>{- Assert.That(UnlockKeyHistoryPolicy.EffectiveRetentionDays(0), Is.EqualTo(0));- Assert.That(UnlockKeyHistoryPolicy.EffectiveRetentionDays(-5), Is.EqualTo(0));+ Assert.That(UnlockMethodHistoryPolicy.EffectiveRetentionDays(0), Is.EqualTo(0));+ Assert.That(UnlockMethodHistoryPolicy.EffectiveRetentionDays(-5), Is.EqualTo(0));});}@@ -61,7 +61,7 @@ public class UnlockKeyHistoryPolicyTests[Test]public void WithinRetentionExcludesExpiredRows(){- var rows = new List<UserUnlockKeysHistory>+ var rows = new List<UserUnlockMethodsHistory>{CreateRow("fresh", now.AddDays(-1)),CreateRow("nearly-expired", now.AddDays(-7).AddHours(1)),@@ -69,7 +69,7 @@ public class UnlockKeyHistoryPolicyTestsCreateRow("long-expired", now.AddDays(-90)),}.AsQueryable();- var usable = UnlockKeyHistoryPolicy.WithinRetention(rows, 7, now).Select(x => x.Label).ToList();+ var usable = UnlockMethodHistoryPolicy.WithinRetention(rows, 7, now).Select(x => x.Label).ToList();Assert.That(usable, Is.EquivalentTo(new[] { "fresh", "nearly-expired" }));}@@ -81,12 +81,12 @@ public class UnlockKeyHistoryPolicyTests[Test]public void WithinRetentionReturnsNothingForANegativeWindow(){- var rows = new List<UserUnlockKeysHistory>+ var rows = new List<UserUnlockMethodsHistory>{CreateRow("recent", now.AddMinutes(-5)),}.AsQueryable();- Assert.That(UnlockKeyHistoryPolicy.WithinRetention(rows, -5, now), Is.Empty);+ Assert.That(UnlockMethodHistoryPolicy.WithinRetention(rows, -5, now), Is.Empty);}/// <summary>@@ -100,7 +100,7 @@ public class UnlockKeyHistoryPolicyTestsarchived.Metadata = """{"salt":"old-salt","srpVerifier":"old-verifier"}""";archived.AccountKeyVersion = 3;- var live = new UserUnlockKey+ var live = new UserUnlockMethod{Id = Guid.NewGuid(),UserId = archived.UserId,@@ -128,12 +128,12 @@ public class UnlockKeyHistoryPolicyTests}/// <summary>- /// Test that archiving a live unlock key captures the credentials a revert needs.+ /// Test that archiving a live unlock method captures the credentials a revert needs./// </summary>[Test]public void CreateFromCapturesTheSupersededCredentials(){- var live = new UserUnlockKey+ var live = new UserUnlockMethod{Id = Guid.NewGuid(),UserId = "user-1",@@ -146,11 +146,11 @@ public class UnlockKeyHistoryPolicyTestsUpdatedAt = now.AddDays(-2),};- var archived = UserUnlockKeysHistory.CreateFrom(live, now, "chrome-0.29.0");+ var archived = UserUnlockMethodsHistory.CreateFrom(live, now, "chrome-0.29.0");Assert.Multiple(() =>{- Assert.That(archived.UnlockKeyId, Is.EqualTo(live.Id));+ Assert.That(archived.UnlockMethodId, Is.EqualTo(live.Id));Assert.That(archived.UserId, Is.EqualTo("user-1"));Assert.That(archived.Type, Is.EqualTo(UnlockMethodType.Password));Assert.That(archived.EncryptedAccountKey, Is.EqualTo("ak-under-old-kek"));@@ -162,17 +162,17 @@ public class UnlockKeyHistoryPolicyTests}/// <summary>- /// Creates an archived unlock key for the tests, labelled so assertions read clearly.+ /// Creates an archived unlock method for the tests, labelled so assertions read clearly./// </summary>/// <param name="label">Label identifying the row in assertions.</param>/// <param name="archivedAt">When the row was archived.</param>- /// <returns>The archived unlock key.</returns>- private static UserUnlockKeysHistory CreateRow(string label, DateTime archivedAt)+ /// <returns>The archived unlock method.</returns>+ private static UserUnlockMethodsHistory CreateRow(string label, DateTime archivedAt){- return new UserUnlockKeysHistory+ return new UserUnlockMethodsHistory{Id = Guid.NewGuid(),- UnlockKeyId = Guid.NewGuid(),+ UnlockMethodId = Guid.NewGuid(),UserId = "user-1",Type = UnlockMethodType.Password,Algorithm = VaultKeyAlgorithm.Aes256Gcm,diff --git a/apps/server/Utilities/AliasVault.Logging/LoggingConfiguration.cs b/apps/server/Utilities/AliasVault.Logging/LoggingConfiguration.csindex 6d05b02f1..a2f53bc3a 100644--- a/apps/server/Utilities/AliasVault.Logging/LoggingConfiguration.cs+++ b/apps/server/Utilities/AliasVault.Logging/LoggingConfiguration.cs@@ -40,7 +40,7 @@ public static class LoggingConfiguration"AliasVault.TaskRunner.Tasks.LogCleanupTask","AliasVault.TaskRunner.Tasks.RefreshTokenCleanupTask","AliasVault.TaskRunner.Tasks.OrphanedEmailCleanupTask",- "AliasVault.TaskRunner.Tasks.UnlockKeyHistoryCleanupTask",+ "AliasVault.TaskRunner.Tasks.UnlockMethodHistoryCleanupTask","AliasVault.TaskRunner.Tasks.VaultBlobCleanupTask",// Admin actions