Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update mobile login request storage for v2 API (#2159)

Leendert de Borst8746ecfd7890
diff --git a/apps/server/Databases/AliasServerDb/AuthLog.cs b/apps/server/Databases/AliasServerDb/AuthLog.cs
index d1a745213..f4f677fb0 100644
--- a/apps/server/Databases/AliasServerDb/AuthLog.cs
+++ b/apps/server/Databases/AliasServerDb/AuthLog.cs
@@ -73,6 +73,11 @@ public enum AuthFailureReason
/// </summary>
MobileLoginRateLimitExceeded = 11,
+ /// <summary>
+ /// Indicates that the mobile login request was declined on the mobile device.
+ /// </summary>
+ MobileLoginDeclined = 12,
+
/// <summary>
/// Indicates that the failure reason was unknown.
/// </summary>
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260917154825_MobileLoginRequestVerification.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260917154825_MobileLoginRequestVerification.Designer.cs
new file mode 100644
index 000000000..92a70ccce
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260917154825_MobileLoginRequestVerification.Designer.cs
@@ -0,0 +1,2028 @@
+// <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("20260917154825_MobileLoginRequestVerification")]
+ partial class MobileLoginRequestVerification
+ {
+ /// <inheritdoc />
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "10.0.10")
+ .HasAnnotation("Proxies:ChangeTracking", false)
+ .HasAnnotation("Proxies:CheckEquality", false)
+ .HasAnnotation("Proxies:LazyLoading", true)
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("AliasServerDb.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("PersonalGroupId")
+ .IsUnique()
+ .HasDatabaseName("UX_AliasVaultUsers_PersonalGroupId");
+
+ b.ToTable("AliasVaultUsers");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("DeviceIdentifier")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<DateTime>("ExpireDate")
+ .HasMaxLength(255)
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("IpAddress")
+ .HasMaxLength(45)
+ .HasColumnType("character varying(45)");
+
+ b.Property<string>("PreviousTokenValue")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Value")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AliasVaultUserRefreshTokens");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AuthLog", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("AdditionalInfo")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Browser")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("Client")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("Country")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("DeviceType")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<int>("EventType")
+ .HasColumnType("integer");
+
+ b.Property<int?>("FailureReason")
+ .HasColumnType("integer");
+
+ b.Property<string>("IpAddress")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<bool>("IsSuccess")
+ .HasColumnType("boolean");
+
+ b.Property<bool>("IsSuspiciousActivity")
+ .HasColumnType("boolean");
+
+ b.Property<string>("OperatingSystem")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("RequestPath")
+ .HasMaxLength(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<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Address")
+ .IsUnique();
+
+ b.ToTable("EmailClaims");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailClaimLink", b =>
+ {
+ b.Property<Guid>("EmailClaimId")
+ .HasColumnType("uuid");
+
+ b.Property<Guid>("VaultManifestId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("State")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.HasKey("EmailClaimId", "VaultManifestId");
+
+ b.HasIndex("EmailClaimId")
+ .HasDatabaseName("IX_EmailClaimLinks_EmailClaimId_Live")
+ .HasFilter("\"State\" <> 'Removed'");
+
+ b.HasIndex("VaultManifestId", "EmailClaimId");
+
+ b.ToTable("EmailClaimLinks");
+ });
+
+ 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<int>("Type")
+ .HasColumnType("integer");
+
+ 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>("EncryptedVek")
+ .HasColumnType("text");
+
+ 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<int>("Role")
+ .HasColumnType("integer");
+
+ 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<int>("Role")
+ .HasColumnType("integer");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.HasIndex("GroupId", "UserId")
+ .IsUnique();
+
+ b.ToTable("GroupMembers");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Log", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("Application")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("Exception")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("Level")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property<string>("LogEvent")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("LogEvent");
+
+ b.Property<string>("Message")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("MessageTemplate")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("Properties")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("SourceContext")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime>("TimeStamp")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Application");
+
+ b.HasIndex("TimeStamp");
+
+ b.ToTable("Logs", (string)null);
+ });
+
+ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>
+ {
+ b.Property<string>("Id")
+ .HasColumnType("text");
+
+ b.Property<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>("EncryptedUnlockKey")
+ .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.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(4000)
+ .HasColumnType("character varying(4000)");
+
+ b.Property<bool>("IsPrimary")
+ .HasColumnType("boolean");
+
+ b.Property<string>("PublicKey")
+ .IsRequired()
+ .HasMaxLength(2000)
+ .HasColumnType("character varying(2000)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId")
+ .IsUnique()
+ .HasDatabaseName("UX_UserGrantKeys_User_Primary")
+ .HasFilter("\"IsPrimary\"");
+
+ b.ToTable("UserGrantKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserUnlockKey", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<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_UserUnlockKeys_UserId_Type_Label");
+
+ b.ToTable("UserUnlockKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserUnlockKeysHistory", 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>("UnlockKeyId")
+ .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_UserUnlockKeysHistory_ArchivedAt");
+
+ b.HasIndex("UserId", "Type", "ArchivedAt")
+ .HasDatabaseName("IX_UserUnlockKeysHistory_UserId_Type_ArchivedAt");
+
+ b.ToTable("UserUnlockKeysHistory", (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<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>("VaultBlob")
+ .HasColumnType("text");
+
+ b.Property<string>("Verifier")
+ .HasMaxLength(1000)
+ .HasColumnType("character varying(1000)");
+
+ b.Property<string>("Version")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("ManifestId");
+
+ b.HasIndex("OwnerGroupId");
+
+ b.ToTable("VaultManifests");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestAccessKey", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<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<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.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>("VaultBlob")
+ .HasColumnType("text");
+
+ b.Property<string>("Verifier")
+ .HasMaxLength(1000)
+ .HasColumnType("character varying(1000)");
+
+ b.Property<string>("Version")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("ManifestId", "RevisionNumber");
+
+ b.ToTable("VaultManifestsHistory", (string)null);
+ });
+
+ modelBuilder.Entity("AliasVault.WorkerStatus.Database.WorkerServiceStatus", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("CurrentStatus")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<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.EmailClaimLink", b =>
+ {
+ b.HasOne("AliasServerDb.EmailClaim", "EmailClaim")
+ .WithMany("Links")
+ .HasForeignKey("EmailClaimId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")
+ .WithMany()
+ .HasForeignKey("VaultManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("EmailClaim");
+
+ 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.UserUnlockKey", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserUnlockKeysHistory", 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.Navigation("OwnerGroup");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestAccessKey", b =>
+ {
+ b.HasOne("AliasServerDb.UserGrantKey", "UserGrantKey")
+ .WithMany()
+ .HasForeignKey("UserGrantKeyId")
+ .OnDelete(DeleteBehavior.SetNull);
+
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany("VaultManifestAccessKeys")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+
+ b.Navigation("UserGrantKey");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestDeliveryKey", b =>
+ {
+ b.HasOne("AliasServerDb.VaultManifest", "VaultManifest")
+ .WithMany()
+ .HasForeignKey("VaultManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("VaultManifest");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>
+ {
+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")
+ .WithMany()
+ .HasForeignKey("ManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Manifest");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>
+ {
+ b.Navigation("VaultManifestAccessKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Email", b =>
+ {
+ b.Navigation("Attachments");
+
+ b.Navigation("DecryptionKeys");
+
+ b.Navigation("Parts");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailClaim", b =>
+ {
+ b.Navigation("Links");
+ });
+
+ 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/20260917154825_MobileLoginRequestVerification.cs b/apps/server/Databases/AliasServerDb/Migrations/20260917154825_MobileLoginRequestVerification.cs
new file mode 100644
index 000000000..0af00e1b8
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260917154825_MobileLoginRequestVerification.cs
@@ -0,0 +1,84 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace AliasServerDb.Migrations
+{
+ /// <inheritdoc />
+ public partial class MobileLoginRequestVerification : Migration
+ {
+ /// <inheritdoc />
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.RenameColumn(
+ name: "EncryptedDecryptionKey",
+ table: "MobileLoginRequests",
+ newName: "EncryptedUnlockKey");
+
+ migrationBuilder.AddColumn<string>(
+ name: "ClientBrowser",
+ table: "MobileLoginRequests",
+ type: "character varying(100)",
+ maxLength: 100,
+ nullable: true);
+
+ migrationBuilder.AddColumn<string>(
+ name: "ClientName",
+ table: "MobileLoginRequests",
+ type: "character varying(100)",
+ maxLength: 100,
+ nullable: true);
+
+ migrationBuilder.AddColumn<string>(
+ name: "ClientOperatingSystem",
+ table: "MobileLoginRequests",
+ type: "character varying(100)",
+ maxLength: 100,
+ nullable: true);
+
+ migrationBuilder.AddColumn<DateTime>(
+ name: "DeclinedAt",
+ table: "MobileLoginRequests",
+ type: "timestamp with time zone",
+ nullable: true);
+
+ migrationBuilder.AddColumn<string>(
+ name: "PollSecretHash",
+ table: "MobileLoginRequests",
+ type: "character varying(44)",
+ maxLength: 44,
+ nullable: false,
+ defaultValue: "");
+ }
+
+ /// <inheritdoc />
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "ClientBrowser",
+ table: "MobileLoginRequests");
+
+ migrationBuilder.DropColumn(
+ name: "ClientName",
+ table: "MobileLoginRequests");
+
+ migrationBuilder.DropColumn(
+ name: "ClientOperatingSystem",
+ table: "MobileLoginRequests");
+
+ migrationBuilder.DropColumn(
+ name: "DeclinedAt",
+ table: "MobileLoginRequests");
+
+ migrationBuilder.DropColumn(
+ name: "PollSecretHash",
+ table: "MobileLoginRequests");
+
+ migrationBuilder.RenameColumn(
+ name: "EncryptedUnlockKey",
+ table: "MobileLoginRequests",
+ newName: "EncryptedDecryptionKey");
+ }
+ }
+}
diff --git a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs
index 4ee9002ae..2f5f901d5 100644
--- a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs
+++ b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs
@@ -886,9 +886,21 @@ namespace AliasServerDb.Migrations
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");
@@ -896,7 +908,10 @@ namespace AliasServerDb.Migrations
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
- b.Property<string>("EncryptedDecryptionKey")
+ b.Property<DateTime?>("DeclinedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptedUnlockKey")
.HasColumnType("text");
b.Property<DateTime?>("FulfilledAt")
@@ -905,6 +920,11 @@ namespace AliasServerDb.Migrations
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");
diff --git a/apps/server/Databases/AliasServerDb/MobileLoginRequest.cs b/apps/server/Databases/AliasServerDb/MobileLoginRequest.cs
index 386e835e2..46cfe8d41 100644
--- a/apps/server/Databases/AliasServerDb/MobileLoginRequest.cs
+++ b/apps/server/Databases/AliasServerDb/MobileLoginRequest.cs
@@ -21,6 +21,11 @@ using Microsoft.EntityFrameworkCore;
[Index(nameof(UserId), Name = "IX_UserId")]
public class MobileLoginRequest
{
+ /// <summary>
+ /// Maximum length of the client description columns.
+ /// </summary>
+ public const int ClientDescriptionMaxLength = 100;
+
/// <summary>
/// Gets or sets the unique identifier for this login request.
/// </summary>
@@ -28,7 +33,7 @@ public class MobileLoginRequest
/// <summary>
/// Gets or sets the algorithm <see cref="ClientPublicKey"/> is for, which is what the mobile app must
- /// encrypt <see cref="EncryptedDecryptionKey"/> with.
+ /// encrypt <see cref="EncryptedUnlockKey"/> with.
/// </summary>
[StringLength(30)]
public VaultKeyAlgorithm Algorithm { get; set; } = VaultKeyAlgorithm.RsaOaepSha256;
@@ -39,10 +44,16 @@ public class MobileLoginRequest
public string ClientPublicKey { get; set; } = string.Empty;
/// <summary>
- /// Gets or sets the encrypted decryption key from the mobile app (base64 encoded).
+ /// Gets or sets the SHA-256 hash (base64) of the poll secret that only the initiating client holds.
+ /// </summary>
+ [StringLength(44)]
+ public string PollSecretHash { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the account unlock key from the mobile app, encrypted with <see cref="ClientPublicKey"/> (base64 encoded).
/// Will be null until mobile app responds.
/// </summary>
- public string? EncryptedDecryptionKey { get; set; }
+ public string? EncryptedUnlockKey { get; set; }
/// <summary>
/// Gets or sets the created timestamp.
@@ -54,6 +65,11 @@ public class MobileLoginRequest
/// </summary>
public DateTime? FulfilledAt { get; set; }
+ /// <summary>
+ /// Gets or sets the declined timestamp (when the mobile app refused the request).
+ /// </summary>
+ public DateTime? DeclinedAt { get; set; }
+
/// <summary>
/// Gets or sets the retrieved timestamp (when client successfully retrieved and decrypted).
/// </summary>
@@ -61,7 +77,7 @@ public class MobileLoginRequest
/// <summary>
/// Gets or sets the timestamp when sensitive data was cleared from this record.
- /// Sensitive data (ClientPublicKey, EncryptedDecryptionKey, Salt, etc.) is cleared
+ /// Sensitive data (ClientPublicKey, EncryptedUnlockKey) is cleared
/// after a timeout period to minimize risk if server is compromised.
/// </summary>
public DateTime? ClearedAt { get; set; }
@@ -71,6 +87,24 @@ public class MobileLoginRequest
/// </summary>
public string? ClientIpAddress { get; set; }
+ /// <summary>
+ /// Gets or sets the X-AliasVault-Client header of the client that initiated the request, e.g. "chrome-0.30.0".
+ /// </summary>
+ [StringLength(ClientDescriptionMaxLength)]
+ public string? ClientName { get; set; }
+
+ /// <summary>
+ /// Gets or sets the browser of the client that initiated the request, derived from its user agent.
+ /// </summary>
+ [StringLength(ClientDescriptionMaxLength)]
+ public string? ClientBrowser { get; set; }
+
+ /// <summary>
+ /// Gets or sets the operating system of the client that initiated the request, derived from its user agent.
+ /// </summary>
+ [StringLength(ClientDescriptionMaxLength)]
+ public string? ClientOperatingSystem { get; set; }
+
/// <summary>
/// Gets or sets the IP address of the mobile device that fulfilled the request.
/// </summary>
diff --git a/apps/server/Services/AliasVault.TaskRunner/Tasks/LogCleanupTask.cs b/apps/server/Services/AliasVault.TaskRunner/Tasks/LogCleanupTask.cs
index 8f58140bc..4a36ee135 100644
--- a/apps/server/Services/AliasVault.TaskRunner/Tasks/LogCleanupTask.cs
+++ b/apps/server/Services/AliasVault.TaskRunner/Tasks/LogCleanupTask.cs
@@ -98,7 +98,7 @@ public class LogCleanupTask : IMaintenanceTask
{
// Clear all sensitive data
request.ClientPublicKey = string.Empty;
- request.EncryptedDecryptionKey = null;
+ request.EncryptedUnlockKey = null;
request.ClearedAt = now;
}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/MobileLoginPollResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/MobileLoginPollResponse.cs
deleted file mode 100644
index a2c3a3a74..000000000
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/MobileLoginPollResponse.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="MobileLoginPollResponse.cs" company="aliasvault">
-// Copyright (c) aliasvault. All rights reserved.
-// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace AliasVault.Shared.Models.WebApi.V1.Auth;
-
-/// <summary>
-/// Response model for polling mobile login status.
-/// All sensitive data is encrypted with AES-256, and the AES key is encrypted with client's RSA public key.
-/// Client decrypts username to call /login endpoint for salt and encryption settings.
-/// </summary>
-public class MobileLoginPollResponse
-{
- /// <summary>
- /// Gets or sets a value indicating whether the request has been fulfilled by the mobile app.
- /// </summary>
- public required bool Fulfilled { get; set; }
-
- /// <summary>
- /// Gets or sets the AES symmetric key encrypted with client's RSA public key (base64 encoded).
- /// Used to decrypt all encrypted fields. Null if not fulfilled.
- /// </summary>
- public string? EncryptedSymmetricKey { get; set; }
-
- /// <summary>
- /// Gets or sets the JWT token encrypted with AES symmetric key (base64 encoded). Null if not fulfilled.
- /// </summary>
- public string? EncryptedToken { get; set; }
-
- /// <summary>
- /// Gets or sets the refresh token encrypted with AES symmetric key (base64 encoded). Null if not fulfilled.
- /// </summary>
- public string? EncryptedRefreshToken { get; set; }
-
- /// <summary>
- /// Gets or sets the vault decryption key encrypted with client's RSA public key (base64 encoded). Null if not fulfilled.
- /// </summary>
- public string? EncryptedDecryptionKey { get; set; }
-
- /// <summary>
- /// Gets or sets the username encrypted with AES symmetric key (base64 encoded).
- /// Retrieved from User via UserId FK. Null if not fulfilled.
- /// </summary>
- public string? EncryptedUsername { get; set; }
-}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginDetailsResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginDetailsResponse.cs
new file mode 100644
index 000000000..2b4e1cb2a
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginDetailsResponse.cs
@@ -0,0 +1,49 @@
+//-----------------------------------------------------------------------
+// <copyright file="MobileLoginDetailsResponse.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.Shared.Models.WebApi.V2.Auth;
+
+/// <summary>
+/// Response for POST /v2/Auth/mobile-login/details: what the mobile app shows the user before they approve.
+/// </summary>
+public class MobileLoginDetailsResponse
+{
+ /// <summary>
+ /// Gets or sets the RSA public key (JWK) of the initiating client.
+ /// </summary>
+ public required string ClientPublicKey { get; set; }
+
+ /// <summary>
+ /// Gets or sets the anonymized IP address the request came from.
+ /// </summary>
+ public string? IpAddress { get; set; }
+
+ /// <summary>
+ /// Gets or sets the approximate location of the IP address. Always null until a Geo-IP source is available.
+ /// </summary>
+ public string? Location { get; set; }
+
+ /// <summary>
+ /// Gets or sets the AliasVault client that initiated the request, e.g. "chrome-0.30.0".
+ /// </summary>
+ public string? ClientName { get; set; }
+
+ /// <summary>
+ /// Gets or sets the browser of the initiating client.
+ /// </summary>
+ public string? Browser { get; set; }
+
+ /// <summary>
+ /// Gets or sets the operating system of the initiating client.
+ /// </summary>
+ public string? OperatingSystem { get; set; }
+
+ /// <summary>
+ /// Gets or sets when the request was created (UTC).
+ /// </summary>
+ public required DateTime CreatedAt { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/MobileLoginInitiateRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginInitiateRequest.cs
similarity index 66%
rename from apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/MobileLoginInitiateRequest.cs
rename to apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginInitiateRequest.cs
index 95da7d193..b592010c1 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/MobileLoginInitiateRequest.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginInitiateRequest.cs
@@ -5,15 +5,18 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.Shared.Models.WebApi.V1.Auth;
+namespace AliasVault.Shared.Models.WebApi.V2.Auth;
+
+using System.ComponentModel.DataAnnotations;
/// <summary>
-/// Request model for initiating a mobile login request.
+/// Request for POST /v2/Auth/mobile-login/initiate.
/// </summary>
public class MobileLoginInitiateRequest
{
/// <summary>
- /// Gets or sets the public key from the client (base64 encoded).
+ /// Gets or sets the RSA public key (JWK) of the initiating client, which the mobile app encrypts the unlock key with.
/// </summary>
+ [Required]
public required string ClientPublicKey { get; set; }
}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/MobileLoginInitiateResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginInitiateResponse.cs
similarity index 59%
rename from apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/MobileLoginInitiateResponse.cs
rename to apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginInitiateResponse.cs
index 45326c6a8..9a9e32b8c 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/MobileLoginInitiateResponse.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginInitiateResponse.cs
@@ -5,15 +5,20 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.Shared.Models.WebApi.V1.Auth;
+namespace AliasVault.Shared.Models.WebApi.V2.Auth;
/// <summary>
-/// Response model for mobile login initiate request.
+/// Response for POST /v2/Auth/mobile-login/initiate.
/// </summary>
public class MobileLoginInitiateResponse
{
/// <summary>
- /// Gets or sets the unique identifier for this login request.
+ /// Gets or sets the request identifier, which goes into the QR code.
/// </summary>
public required string RequestId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the secret the initiating client must present when polling. It never goes into the QR code.
+ /// </summary>
+ public required string PollSecret { get; set; }
}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginPayload.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginPayload.cs
new file mode 100644
index 000000000..7371a407a
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginPayload.cs
@@ -0,0 +1,44 @@
+//-----------------------------------------------------------------------
+// <copyright file="MobileLoginPayload.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.Shared.Models.WebApi.V2.Auth;
+
+/// <summary>
+/// Session data the server hands to the initiating client once the mobile app approved the request.
+/// </summary>
+public class MobileLoginPayload
+{
+ /// <summary>
+ /// Gets or sets the username of the account that approved the request.
+ /// </summary>
+ public required string Username { get; set; }
+
+ /// <summary>
+ /// Gets or sets the JWT access token.
+ /// </summary>
+ public required string Token { get; set; }
+
+ /// <summary>
+ /// Gets or sets the refresh token.
+ /// </summary>
+ public required string RefreshToken { get; set; }
+
+ /// <summary>
+ /// Gets or sets the salt the unlock key was derived with.
+ /// </summary>
+ public required string Salt { get; set; }
+
+ /// <summary>
+ /// Gets or sets the key derivation type.
+ /// </summary>
+ public required string EncryptionType { get; set; }
+
+ /// <summary>
+ /// Gets or sets the key derivation settings.
+ /// </summary>
+ public required string EncryptionSettings { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginPollRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginPollRequest.cs
new file mode 100644
index 000000000..4433b44ab
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginPollRequest.cs
@@ -0,0 +1,30 @@
+//-----------------------------------------------------------------------
+// <copyright file="MobileLoginPollRequest.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.Shared.Models.WebApi.V2.Auth;
+
+using System.ComponentModel.DataAnnotations;
+
+/// <summary>
+/// Request for POST /v2/Auth/mobile-login/poll.
+/// </summary>
+public class MobileLoginPollRequest
+{
+ /// <summary>
+ /// Gets or sets the request identifier.
+ /// </summary>
+ [Required]
+ [StringLength(32)]
+ public required string RequestId { get; set; }
+
+ /// <summary>
+ /// Gets or sets the poll secret returned by the initiate call.
+ /// </summary>
+ [Required]
+ [StringLength(64)]
+ public required string PollSecret { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginPollResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginPollResponse.cs
new file mode 100644
index 000000000..4fa5b94c8
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginPollResponse.cs
@@ -0,0 +1,34 @@
+//-----------------------------------------------------------------------
+// <copyright file="MobileLoginPollResponse.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.Shared.Models.WebApi.V2.Auth;
+
+/// <summary>
+/// Response for POST /v2/Auth/mobile-login/poll. The encrypted fields are only set when the status is Approved.
+/// </summary>
+public class MobileLoginPollResponse
+{
+ /// <summary>
+ /// Gets or sets the state of the request.
+ /// </summary>
+ public required MobileLoginStatus Status { get; set; }
+
+ /// <summary>
+ /// Gets or sets the symmetric key, encrypted with the client's RSA public key (base64).
+ /// </summary>
+ public string? EncryptedSymmetricKey { get; set; }
+
+ /// <summary>
+ /// Gets or sets the <see cref="MobileLoginPayload"/> JSON, encrypted with the symmetric key (base64).
+ /// </summary>
+ public string? EncryptedPayload { get; set; }
+
+ /// <summary>
+ /// Gets or sets the account unlock key, encrypted by the mobile app with the client's RSA public key (base64).
+ /// </summary>
+ public string? EncryptedUnlockKey { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginRequestReference.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginRequestReference.cs
new file mode 100644
index 000000000..3a7c2f789
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginRequestReference.cs
@@ -0,0 +1,23 @@
+//-----------------------------------------------------------------------
+// <copyright file="MobileLoginRequestReference.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.Shared.Models.WebApi.V2.Auth;
+
+using System.ComponentModel.DataAnnotations;
+
+/// <summary>
+/// Request for the mobile app calls that only name a request: POST /v2/Auth/mobile-login/details and /decline.
+/// </summary>
+public class MobileLoginRequestReference
+{
+ /// <summary>
+ /// Gets or sets the request identifier.
+ /// </summary>
+ [Required]
+ [StringLength(32)]
+ public required string RequestId { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginStatus.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginStatus.cs
new file mode 100644
index 000000000..bcfc8efe3
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginStatus.cs
@@ -0,0 +1,32 @@
+//-----------------------------------------------------------------------
+// <copyright file="MobileLoginStatus.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.Shared.Models.WebApi.V2.Auth;
+
+using System.Text.Json.Serialization;
+
+/// <summary>
+/// State of a mobile login request as seen by the polling client.
+/// </summary>
+[JsonConverter(typeof(JsonStringEnumConverter))]
+public enum MobileLoginStatus
+{
+ /// <summary>
+ /// The mobile app has not answered yet.
+ /// </summary>
+ Pending,
+
+ /// <summary>
+ /// The mobile app approved the request.
+ /// </summary>
+ Approved,
+
+ /// <summary>
+ /// The mobile app declined the request.
+ /// </summary>
+ Declined,
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/MobileLoginSubmitRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginSubmitRequest.cs
similarity index 57%
rename from apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/MobileLoginSubmitRequest.cs
rename to apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginSubmitRequest.cs
index 01c195977..e1a3e3c4a 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/MobileLoginSubmitRequest.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginSubmitRequest.cs
@@ -5,20 +5,26 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.Shared.Models.WebApi.V1.Auth;
+namespace AliasVault.Shared.Models.WebApi.V2.Auth;
+
+using System.ComponentModel.DataAnnotations;
/// <summary>
-/// Request model for submitting mobile login response from mobile app.
+/// Request for POST /v2/Auth/mobile-login/submit.
/// </summary>
public class MobileLoginSubmitRequest
{
/// <summary>
- /// Gets or sets the unique identifier for this login request.
+ /// Gets or sets the request identifier.
/// </summary>
+ [Required]
+ [StringLength(32)]
public required string RequestId { get; set; }
/// <summary>
- /// Gets or sets the encrypted decryption key (base64 encoded).
+ /// Gets or sets the account unlock key, encrypted with the client's RSA public key (base64).
/// </summary>
- public required string EncryptedDecryptionKey { get; set; }
+ [Required]
+ [StringLength(1024)]
+ public required string EncryptedUnlockKey { get; set; }
}
diff --git a/apps/server/Tests/AliasVault.IntegrationTests/TaskRunner/TaskRunnerTests.cs b/apps/server/Tests/AliasVault.IntegrationTests/TaskRunner/TaskRunnerTests.cs
index 1d41c202f..c2468a2f0 100644
--- a/apps/server/Tests/AliasVault.IntegrationTests/TaskRunner/TaskRunnerTests.cs
+++ b/apps/server/Tests/AliasVault.IntegrationTests/TaskRunner/TaskRunnerTests.cs
@@ -597,7 +597,7 @@ public class TaskRunnerTests
{
Id = Guid.NewGuid().ToString(),
ClientPublicKey = "stale-public-key",
- EncryptedDecryptionKey = "encrypted-key-data",
+ EncryptedUnlockKey = "encrypted-key-data",
UserId = user.Id,
CreatedAt = DateTime.UtcNow.AddMinutes(-15),
FulfilledAt = DateTime.UtcNow.AddMinutes(-12), // Fulfilled 12 minutes ago (exceeds 10 min timeout)
@@ -613,7 +613,7 @@ public class TaskRunnerTests
{
Id = Guid.NewGuid().ToString(),
ClientPublicKey = "recent-public-key",
- EncryptedDecryptionKey = "encrypted-key-data",
+ EncryptedUnlockKey = "encrypted-key-data",
UserId = user.Id,
CreatedAt = DateTime.UtcNow.AddMinutes(-6),
FulfilledAt = DateTime.UtcNow.AddMinutes(-5), // Fulfilled 5 minutes ago (under 10 min timeout)
@@ -629,7 +629,7 @@ public class TaskRunnerTests
{
Id = Guid.NewGuid().ToString(),
ClientPublicKey = "completed-public-key",
- EncryptedDecryptionKey = "encrypted-key-data",
+ EncryptedUnlockKey = "encrypted-key-data",
UserId = user.Id,
CreatedAt = DateTime.UtcNow.AddMinutes(-15),
FulfilledAt = DateTime.UtcNow.AddMinutes(-12),
@@ -656,7 +656,7 @@ public class TaskRunnerTests
{
// Stale request should have sensitive data cleared
Assert.That(staleAfterCleanup.ClientPublicKey, Is.Empty, "Stale request ClientPublicKey should be cleared");
- Assert.That(staleAfterCleanup.EncryptedDecryptionKey, Is.Null, "Stale request EncryptedDecryptionKey should be cleared");
+ Assert.That(staleAfterCleanup.EncryptedUnlockKey, Is.Null, "Stale request EncryptedUnlockKey should be cleared");
Assert.That(staleAfterCleanup.ClearedAt, Is.Not.Null, "Stale request ClearedAt should be set");
// Metadata should be preserved for abuse tracking
@@ -670,7 +670,7 @@ public class TaskRunnerTests
{
// Recent request should still have sensitive data (not old enough)
Assert.That(recentAfterCleanup.ClientPublicKey, Is.EqualTo("recent-public-key"), "Recent request should retain sensitive data");
- Assert.That(recentAfterCleanup.EncryptedDecryptionKey, Is.Not.Null, "Recent request should retain encrypted key");
+ Assert.That(recentAfterCleanup.EncryptedUnlockKey, Is.Not.Null, "Recent request should retain encrypted key");
Assert.That(recentAfterCleanup.ClearedAt, Is.Null, "Recent request should not be cleared yet");
});
diff --git a/apps/server/Tests/AliasVault.UnitTests/Utilities/MobileLoginRequestHelperTests.cs b/apps/server/Tests/AliasVault.UnitTests/Utilities/MobileLoginRequestHelperTests.cs
new file mode 100644
index 000000000..3f5bb9625
--- /dev/null
+++ b/apps/server/Tests/AliasVault.UnitTests/Utilities/MobileLoginRequestHelperTests.cs
@@ -0,0 +1,101 @@
+//-----------------------------------------------------------------------
+// <copyright file="MobileLoginRequestHelperTests.cs" company="aliasvault">
+// Copyright (c) aliasvault. All rights reserved.
+// Licensed under the AGPLv3 license. See LICENSE.md file in the project root for full license information.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace AliasVault.UnitTests.Utilities;
+
+using AliasServerDb;
+using AliasVault.Api.Helpers;
+
+/// <summary>
+/// Tests for the rules of the mobile login handshake.
+/// </summary>
+public class MobileLoginRequestHelperTests
+{
+ private static readonly DateTime Now = new(2026, 9, 17, 12, 0, 0, DateTimeKind.Utc);
+
+ /// <summary>
+ /// Only the poll secret that was hashed into the request opens it.
+ /// </summary>
+ [Test]
+ public void PollSecretMustMatchStoredHash()
+ {
+ var request = new MobileLoginRequest { PollSecretHash = MobileLoginRequestHelper.HashPollSecret("secret-of-the-initiating-client") };
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(MobileLoginRequestHelper.IsPollSecretValid(request, "secret-of-the-initiating-client"), Is.True);
+ Assert.That(MobileLoginRequestHelper.IsPollSecretValid(request, "another-secret"), Is.False);
+ Assert.That(MobileLoginRequestHelper.IsPollSecretValid(request, string.Empty), Is.False);
+ Assert.That(MobileLoginRequestHelper.IsPollSecretValid(request, null), Is.False);
+ });
+ }
+
+ /// <summary>
+ /// A request created before the poll secret existed has no hash and can never be polled.
+ /// </summary>
+ [Test]
+ public void RequestWithoutPollSecretHashIsNeverPollable()
+ {
+ var request = new MobileLoginRequest { PollSecretHash = string.Empty };
+
+ Assert.That(MobileLoginRequestHelper.IsPollSecretValid(request, string.Empty), Is.False);
+ }
+
+ /// <summary>
+ /// A request waits for the mobile app until it is answered or the approval window closes.
+ /// </summary>
+ [Test]
+ public void RequestAwaitsApprovalOnlyWhileUnansweredAndFresh()
+ {
+ Assert.Multiple(() =>
+ {
+ Assert.That(MobileLoginRequestHelper.IsAwaitingApproval(new MobileLoginRequest { CreatedAt = Now.AddMinutes(-1) }, Now), Is.True);
+ Assert.That(MobileLoginRequestHelper.IsAwaitingApproval(new MobileLoginRequest { CreatedAt = Now.Add(-MobileLoginRequestHelper.ApprovalWindow).AddSeconds(-1) }, Now), Is.False);
+ Assert.That(MobileLoginRequestHelper.IsAwaitingApproval(new MobileLoginRequest { CreatedAt = Now.AddMinutes(-1), FulfilledAt = Now }, Now), Is.False);
+ Assert.That(MobileLoginRequestHelper.IsAwaitingApproval(new MobileLoginRequest { CreatedAt = Now.AddMinutes(-1), DeclinedAt = Now }, Now), Is.False);
+ });
+ }
+
+ /// <summary>
+ /// An approval can only be collected shortly after it was given.
+ /// </summary>
+ [Test]
+ public void ApprovalCanOnlyBeCollectedWithinRetrievalWindow()
+ {
+ Assert.Multiple(() =>
+ {
+ Assert.That(MobileLoginRequestHelper.IsRetrievalWindowClosed(new MobileLoginRequest { FulfilledAt = Now.AddSeconds(-30) }, Now), Is.False);
+ Assert.That(MobileLoginRequestHelper.IsRetrievalWindowClosed(new MobileLoginRequest { FulfilledAt = Now.Add(-MobileLoginRequestHelper.RetrievalWindow).AddSeconds(-1) }, Now), Is.True);
+ Assert.That(MobileLoginRequestHelper.IsRetrievalWindowClosed(new MobileLoginRequest(), Now), Is.True);
+ });
+ }
+
+ /// <summary>
+ /// The client header is shown on the approval screen, so anything but the expected shape is dropped.
+ /// </summary>
+ /// <param name="header">The raw header value.</param>
+ /// <param name="expected">The expected sanitized value.</param>
+ [TestCase("chrome-0.31.0", "chrome-0.31.0")]
+ [TestCase("web-0.31.0-beta", "web-0.31.0-beta")]
+ [TestCase("Your bank, approve now", null)]
+ [TestCase("chrome-0.31.0\nIP Address: 127.0.0.1", null)]
+ [TestCase("", null)]
+ [TestCase(null, null)]
+ public void ClientNameIsSanitized(string? header, string? expected)
+ {
+ Assert.That(MobileLoginRequestHelper.SanitizeClientName(header), Is.EqualTo(expected));
+ }
+
+ /// <summary>
+ /// An overlong client header is dropped instead of truncated.
+ /// </summary>
+ [Test]
+ public void OverlongClientNameIsDropped()
+ {
+ Assert.That(MobileLoginRequestHelper.SanitizeClientName(new string('a', 51)), Is.Null);
+ }
+}