Skip to content

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

Add vault sharing API scaffolding (#2159)

Leendert de Borst8f1b290d55f3
diff --git a/apps/server/AliasVault.Api/Controllers/V2/SharingController.cs b/apps/server/AliasVault.Api/Controllers/V2/SharingController.cs
new file mode 100644
index 000000000..65af71e6d
--- /dev/null
+++ b/apps/server/AliasVault.Api/Controllers/V2/SharingController.cs
@@ -0,0 +1,310 @@
+//-----------------------------------------------------------------------
+// <copyright file="SharingController.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.Api.Controllers.V2;
+
+using AliasServerDb;
+using AliasVault.Api.Controllers.Abstracts;
+using AliasVault.Api.Helpers;
+using AliasVault.Auth;
+using AliasVault.Shared.Models.Enums;
+using AliasVault.Shared.Models.WebApi;
+using AliasVault.Shared.Models.WebApi.V2.Sharing;
+using AliasVault.Shared.Providers.Time;
+using Asp.Versioning;
+using Microsoft.AspNetCore.Identity;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+
+/// <summary>
+/// Vault sharing. A shared folder is a non-root <see cref="VaultManifest"/> owned by a user and
+/// encrypted with its own VEK. Access is granted by persisting that VEK wrapped with a recipient's public key as a
+/// <c>shared</c> <see cref="VaultKey"/> row. The owner keeps their own copy of the folder VEK client-side
+/// (inside their main vault).
+/// </summary>
+/// <param name="dbContextFactory">DbContext factory.</param>
+/// <param name="userManager">UserManager.</param>
+/// <param name="timeProvider">Time provider.</param>
+[ApiVersion("2")]
+public class SharingController(
+ IAliasServerDbContextFactory dbContextFactory,
+ UserManager<AliasVaultUser> userManager,
+ ITimeProvider timeProvider) : AuthenticatedRequestController(userManager)
+{
+ private const string ManifestFormat = "manifest-v1";
+
+ /// <summary>
+ /// Look up a recipient by username and return their primary public key, which the caller uses to wrap a shared
+ /// folder's VEK before granting access.
+ /// </summary>
+ /// <param name="username">The recipient's username.</param>
+ /// <returns>The recipient's id and primary public key.</returns>
+ [HttpGet("recipient")]
+ public async Task<IActionResult> GetRecipient([FromQuery] string username)
+ {
+ await using var context = await dbContextFactory.CreateDbContextAsync();
+ var me = await GetCurrentUserAsync();
+ if (me == null)
+ {
+ return Unauthorized();
+ }
+
+ var recipient = await GetUserManager().FindByNameAsync(UsernameHelper.NormalizeUsername(username ?? string.Empty));
+ if (recipient == null)
+ {
+ return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.USER_NOT_FOUND, 404));
+ }
+
+ var key = await context.UserEncryptionKeys.FirstOrDefaultAsync(x => x.UserId == recipient.Id && x.IsPrimary);
+ if (key == null)
+ {
+ return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.RECIPIENT_KEY_NOT_FOUND, 404));
+ }
+
+ return Ok(new RecipientLookupResponse { UserId = recipient.Id, PublicKeyId = key.Id, PublicKey = key.PublicKey });
+ }
+
+ /// <summary>
+ /// Create a new shared folder manifest owned by the caller. The folder VEK is generated and kept
+ /// client-side; the server only stores the encrypted manifest. Access is granted afterwards via <see cref="Grant"/>.
+ /// </summary>
+ /// <param name="model">The create request.</param>
+ /// <param name="clientHeader">The client identifier header.</param>
+ /// <returns>The created manifest id.</returns>
+ [HttpPost("folders")]
+ public async Task<IActionResult> CreateFolder([FromBody] CreateSharedFolderRequest model, [FromHeader(Name = "X-AliasVault-Client")] string? clientHeader)
+ {
+ await using var context = await dbContextFactory.CreateDbContextAsync();
+ var me = await GetCurrentUserAsync();
+ if (me == null)
+ {
+ return Unauthorized();
+ }
+
+ var manifest = new VaultManifest
+ {
+ ManifestId = Guid.NewGuid(),
+ IsRoot = false,
+ OwnerUserId = me.Id,
+ Name = model.Name,
+ VaultBlob = string.Empty,
+ StorageFormat = ManifestFormat,
+ ManifestBlob = model.ManifestBlob,
+ ManifestCiphertextHash = model.ManifestCiphertextHash,
+ Version = model.Version,
+ RevisionNumber = 1,
+ Salt = string.Empty,
+ Verifier = string.Empty,
+ EncryptionType = string.Empty,
+ EncryptionSettings = string.Empty,
+ FileSize = FileHelper.Base64StringToKilobytes(model.ManifestBlob),
+ Client = clientHeader,
+ CreatedAt = timeProvider.UtcNow,
+ UpdatedAt = timeProvider.UtcNow,
+ };
+ context.VaultManifests.Add(manifest);
+ await context.SaveChangesAsync();
+
+ return Ok(new CreateSharedFolderResponse { ManifestId = manifest.ManifestId, RevisionNumber = manifest.RevisionNumber });
+ }
+
+ /// <summary>
+ /// Grant a recipient access to a shared folder the caller owns, by persisting the folder VEK wrapped with the
+ /// recipient's public key.
+ /// </summary>
+ /// <param name="model">The grant request.</param>
+ /// <returns>Ok on success.</returns>
+ [HttpPost("grant")]
+ public async Task<IActionResult> Grant([FromBody] GrantAccessRequest model)
+ {
+ await using var context = await dbContextFactory.CreateDbContextAsync();
+ var me = await GetCurrentUserAsync();
+ if (me == null)
+ {
+ return Unauthorized();
+ }
+
+ // A shared folder's VEK must be wrapped for the recipient asymmetrically; a symmetric self-unlock scheme is invalid here.
+ if (!AuthHelper.AsymmetricWrapSchemes.Contains(model.WrapScheme))
+ {
+ return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.INVALID_WRAP_SCHEME, 400));
+ }
+
+ // The caller must own the (non-root) manifest being shared.
+ var ownsManifest = await context.VaultManifests.AnyAsync(x => x.ManifestId == model.ManifestId && x.OwnerUserId == me.Id && !x.IsRoot);
+ if (!ownsManifest)
+ {
+ return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.SHARED_MANIFEST_NOT_FOUND, 404));
+ }
+
+ // The referenced public key must exist and belong to the named recipient (guards against wrapping for the wrong key).
+ var keyOwnedByRecipient = await context.UserEncryptionKeys.AnyAsync(x => x.Id == model.RecipientPublicKeyId && x.UserId == model.RecipientUserId);
+ if (!keyOwnedByRecipient)
+ {
+ return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.RECIPIENT_KEY_NOT_FOUND, 404));
+ }
+
+ var alreadyGranted = await context.VaultKeys.AnyAsync(x => x.UserId == model.RecipientUserId && x.VaultManifestId == model.ManifestId && x.KeyType == AuthHelper.VaultKeyTypeShared);
+ if (alreadyGranted)
+ {
+ return BadRequest(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.SHARE_ALREADY_EXISTS, 400));
+ }
+
+ context.VaultKeys.Add(new VaultKey
+ {
+ Id = Guid.NewGuid(),
+ UserId = model.RecipientUserId,
+ VaultManifestId = model.ManifestId,
+ KeyType = AuthHelper.VaultKeyTypeShared,
+ WrapScheme = model.WrapScheme,
+ WrappedVek = model.WrappedVek,
+ RecipientPublicKeyId = model.RecipientPublicKeyId,
+ CreatedAt = timeProvider.UtcNow,
+ UpdatedAt = timeProvider.UtcNow,
+ });
+ await context.SaveChangesAsync();
+
+ return Ok();
+ }
+
+ /// <summary>
+ /// Revoke a recipient's access to a shared folder the caller owns. Deleting the grant stops the recipient from
+ /// fetching a usable wrapped VEK. TODO: implement enforced VEK rotation policy on every shared folder revocation.
+ /// </summary>
+ /// <param name="model">The revoke request.</param>
+ /// <returns>Ok on success.</returns>
+ [HttpPost("revoke")]
+ public async Task<IActionResult> Revoke([FromBody] RevokeAccessRequest model)
+ {
+ await using var context = await dbContextFactory.CreateDbContextAsync();
+ var me = await GetCurrentUserAsync();
+ if (me == null)
+ {
+ return Unauthorized();
+ }
+
+ var ownsManifest = await context.VaultManifests.AnyAsync(x => x.ManifestId == model.ManifestId && x.OwnerUserId == me.Id && !x.IsRoot);
+ if (!ownsManifest)
+ {
+ return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.SHARED_MANIFEST_NOT_FOUND, 404));
+ }
+
+ var grant = await context.VaultKeys.FirstOrDefaultAsync(x => x.UserId == model.RecipientUserId && x.VaultManifestId == model.ManifestId && x.KeyType == AuthHelper.VaultKeyTypeShared);
+ if (grant == null)
+ {
+ return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.SHARE_NOT_FOUND, 404));
+ }
+
+ context.VaultKeys.Remove(grant);
+ await context.SaveChangesAsync();
+
+ return Ok();
+ }
+
+ /// <summary>
+ /// List the members of a shared folder the caller owns: the owner plus every recipient holding a grant.
+ /// </summary>
+ /// <param name="manifestId">The shared folder manifest id.</param>
+ /// <returns>The member list.</returns>
+ [HttpGet("folders/{manifestId:guid}/members")]
+ public async Task<IActionResult> Members(Guid manifestId)
+ {
+ await using var context = await dbContextFactory.CreateDbContextAsync();
+ var me = await GetCurrentUserAsync();
+ if (me == null)
+ {
+ return Unauthorized();
+ }
+
+ var ownsManifest = await context.VaultManifests.AnyAsync(x => x.ManifestId == manifestId && x.OwnerUserId == me.Id && !x.IsRoot);
+ if (!ownsManifest)
+ {
+ return NotFound(ApiErrorCodeHelper.CreateValidationErrorResponse(ApiErrorCode.SHARED_MANIFEST_NOT_FOUND, 404));
+ }
+
+ var grants = await context.VaultKeys
+ .Where(x => x.VaultManifestId == manifestId && x.KeyType == AuthHelper.VaultKeyTypeShared)
+ .ToListAsync();
+
+ var recipientIds = grants.Select(g => g.UserId).ToList();
+ var usernamesById = await context.AliasVaultUsers
+ .Where(u => recipientIds.Contains(u.Id))
+ .ToDictionaryAsync(u => u.Id, u => u.UserName);
+
+ var response = new ShareMembersResponse();
+ response.Members.Add(new ShareMember { UserId = me.Id, Username = me.UserName, IsOwner = true });
+ foreach (var g in grants)
+ {
+ response.Members.Add(new ShareMember
+ {
+ UserId = g.UserId,
+ Username = usernamesById.GetValueOrDefault(g.UserId),
+ IsOwner = false,
+ WrapScheme = g.WrapScheme,
+ GrantedAt = g.CreatedAt,
+ });
+ }
+
+ return Ok(response);
+ }
+
+ /// <summary>
+ /// List the shared folders the caller has been granted access to, each with the wrapped VEK the caller unwraps
+ /// with its private key.
+ /// </summary>
+ /// <returns>The shared folders available to the caller.</returns>
+ [HttpGet("shared-with-me")]
+ public async Task<IActionResult> SharedWithMe()
+ {
+ await using var context = await dbContextFactory.CreateDbContextAsync();
+ var me = await GetCurrentUserAsync();
+ if (me == null)
+ {
+ return Unauthorized();
+ }
+
+ var grants = await context.VaultKeys
+ .Where(x => x.UserId == me.Id && x.KeyType == AuthHelper.VaultKeyTypeShared)
+ .ToListAsync();
+
+ var response = new SharedWithMeResponse();
+ if (grants.Count == 0)
+ {
+ return Ok(response);
+ }
+
+ var manifestIds = grants.Where(g => g.VaultManifestId != null).Select(g => g.VaultManifestId!.Value).ToList();
+ var manifestsById = await context.VaultManifests
+ .Where(m => manifestIds.Contains(m.ManifestId))
+ .ToDictionaryAsync(m => m.ManifestId);
+
+ var ownerIds = manifestsById.Values.Select(m => m.OwnerUserId).Distinct().ToList();
+ var ownerUsernamesById = await context.AliasVaultUsers
+ .Where(u => ownerIds.Contains(u.Id))
+ .ToDictionaryAsync(u => u.Id, u => u.UserName);
+
+ foreach (var g in grants)
+ {
+ if (g.VaultManifestId is null || !manifestsById.TryGetValue(g.VaultManifestId.Value, out var manifest))
+ {
+ continue;
+ }
+
+ response.Folders.Add(new SharedWithMeItem
+ {
+ ManifestId = manifest.ManifestId,
+ Name = manifest.Name,
+ OwnerUserId = manifest.OwnerUserId,
+ OwnerUsername = ownerUsernamesById.GetValueOrDefault(manifest.OwnerUserId),
+ WrappedVek = g.WrappedVek,
+ WrapScheme = g.WrapScheme,
+ });
+ }
+
+ return Ok(response);
+ }
+}
diff --git a/apps/server/AliasVault.Api/Helpers/AuthHelper.cs b/apps/server/AliasVault.Api/Helpers/AuthHelper.cs
index 7087fa52b..9ce8ff96a 100644
--- a/apps/server/AliasVault.Api/Helpers/AuthHelper.cs
+++ b/apps/server/AliasVault.Api/Helpers/AuthHelper.cs
@@ -38,6 +38,16 @@ public static class AuthHelper
/// </summary>
public static readonly string WrapSchemeAesGcmKek = "aesgcm-kek";
+ /// <summary>
+ /// The KeyType value for a folder-access grant: a wrapped VEK held by a member of a shared (non-root) manifest.
+ /// </summary>
+ public static readonly string VaultKeyTypeShared = "shared";
+
+ /// <summary>
+ /// The asymmetric WrapScheme values used when wrapping a shared folder's VEK for a recipient's public key.
+ /// </summary>
+ public static readonly IReadOnlySet<string> AsymmetricWrapSchemes = new HashSet<string>(StringComparer.Ordinal) { "rsa-oaep", "x25519-sealedbox" };
+
/// <summary>
/// Helper method that validates the SRP session based on provided SRP identity, ephemeral and proof.
/// </summary>
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260722145437_AddVaultManifestName.Designer.cs b/apps/server/Databases/AliasServerDb/Migrations/20260722145437_AddVaultManifestName.Designer.cs
new file mode 100644
index 000000000..ab3282fc4
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260722145437_AddVaultManifestName.Designer.cs
@@ -0,0 +1,1437 @@
+// <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("20260722145437_AddVaultManifestName")]
+ partial class AddVaultManifestName
+ {
+ /// <inheritdoc />
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "10.0.10")
+ .HasAnnotation("Proxies:ChangeTracking", false)
+ .HasAnnotation("Proxies:CheckEquality", false)
+ .HasAnnotation("Proxies:LazyLoading", true)
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("AliasServerDb.AdminRole", b =>
+ {
+ b.Property<string>("Id")
+ .HasColumnType("text");
+
+ b.Property<string>("ConcurrencyStamp")
+ .HasColumnType("text");
+
+ b.Property<string>("Name")
+ .HasColumnType("text");
+
+ b.Property<string>("NormalizedName")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("AdminRoles");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AdminUser", b =>
+ {
+ b.Property<string>("Id")
+ .HasColumnType("text");
+
+ b.Property<int>("AccessFailedCount")
+ .HasColumnType("integer");
+
+ b.Property<string>("ConcurrencyStamp")
+ .HasColumnType("text");
+
+ b.Property<string>("Email")
+ .HasColumnType("text");
+
+ b.Property<bool>("EmailConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime?>("LastPasswordChanged")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<bool>("LockoutEnabled")
+ .HasColumnType("boolean");
+
+ b.Property<DateTimeOffset?>("LockoutEnd")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("NormalizedEmail")
+ .HasColumnType("text");
+
+ b.Property<string>("NormalizedUserName")
+ .HasColumnType("text");
+
+ b.Property<string>("PasswordHash")
+ .HasColumnType("text");
+
+ b.Property<string>("PhoneNumber")
+ .HasColumnType("text");
+
+ b.Property<bool>("PhoneNumberConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property<string>("SecurityStamp")
+ .HasColumnType("text");
+
+ b.Property<bool>("TwoFactorEnabled")
+ .HasColumnType("boolean");
+
+ b.Property<string>("UserName")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("AdminUsers");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultRole", b =>
+ {
+ b.Property<string>("Id")
+ .HasColumnType("text");
+
+ b.Property<string>("ConcurrencyStamp")
+ .HasColumnType("text");
+
+ b.Property<string>("Name")
+ .HasColumnType("text");
+
+ b.Property<string>("NormalizedName")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("AliasVaultRoles");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>
+ {
+ b.Property<string>("Id")
+ .HasColumnType("text");
+
+ b.Property<int>("AccessFailedCount")
+ .HasColumnType("integer");
+
+ b.Property<bool>("Blocked")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime?>("BlockedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("ConcurrencyStamp")
+ .HasColumnType("text");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("Email")
+ .HasColumnType("text");
+
+ b.Property<bool>("EmailConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property<int>("EmailsReceived")
+ .HasColumnType("integer");
+
+ b.Property<DateTime?>("LastActivityDate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<bool>("LockoutEnabled")
+ .HasColumnType("boolean");
+
+ b.Property<DateTimeOffset?>("LockoutEnd")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("MaxEmailAgeDays")
+ .HasColumnType("integer");
+
+ b.Property<int>("MaxEmails")
+ .HasColumnType("integer");
+
+ b.Property<string>("NormalizedEmail")
+ .HasColumnType("text");
+
+ b.Property<string>("NormalizedUserName")
+ .HasColumnType("text");
+
+ b.Property<DateTime>("PasswordChangedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("PasswordHash")
+ .HasColumnType("text");
+
+ b.Property<string>("PhoneNumber")
+ .HasColumnType("text");
+
+ b.Property<bool>("PhoneNumberConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property<string>("SecurityStamp")
+ .HasColumnType("text");
+
+ b.Property<bool>("ShadowBlocked")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime?>("ShadowBlockedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("SrpIdentity")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<bool>("TwoFactorEnabled")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserName")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("AliasVaultUsers");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("DeviceIdentifier")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<DateTime>("ExpireDate")
+ .HasMaxLength(255)
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("IpAddress")
+ .HasMaxLength(45)
+ .HasColumnType("character varying(45)");
+
+ b.Property<string>("PreviousTokenValue")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Value")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AliasVaultUserRefreshTokens");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AuthLog", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("AdditionalInfo")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Browser")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("Client")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("Country")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("DeviceType")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<int>("EventType")
+ .HasColumnType("integer");
+
+ b.Property<int?>("FailureReason")
+ .HasColumnType("integer");
+
+ b.Property<string>("IpAddress")
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<bool>("IsSuccess")
+ .HasColumnType("boolean");
+
+ b.Property<bool>("IsSuspiciousActivity")
+ .HasColumnType("boolean");
+
+ b.Property<string>("OperatingSystem")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("RequestPath")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<DateTime>("Timestamp")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("Username")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex(new[] { "EventType" }, "IX_EventType");
+
+ b.HasIndex(new[] { "IpAddress" }, "IX_IpAddress");
+
+ b.HasIndex(new[] { "Timestamp" }, "IX_Timestamp");
+
+ b.HasIndex(new[] { "Username", "IsSuccess", "Timestamp" }, "IX_Username_IsSuccess_Timestamp")
+ .IsDescending(false, false, true);
+
+ b.HasIndex(new[] { "Username", "Timestamp" }, "IX_Username_Timestamp")
+ .IsDescending(false, true);
+
+ b.ToTable("AuthLogs");
+ });
+
+ modelBuilder.Entity("AliasServerDb.BlockedIpRange", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<bool>("BlockLogin")
+ .HasColumnType("boolean");
+
+ b.Property<bool>("BlockRegistration")
+ .HasColumnType("boolean");
+
+ b.Property<bool>("BlockShadow")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("CreatedBy")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<bool>("Enabled")
+ .HasColumnType("boolean");
+
+ b.Property<string>("IpRange")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("Reason")
+ .HasMaxLength(500)
+ .HasColumnType("character varying(500)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex(new[] { "Enabled" }, "IX_BlockedIpRange_Enabled");
+
+ b.HasIndex(new[] { "IpRange" }, "IX_BlockedIpRange_IpRange")
+ .IsUnique();
+
+ b.ToTable("BlockedIpRanges");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Email", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<DateTime>("Date")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<DateTime>("DateSystem")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptedSymmetricKey")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("From")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("FromDomain")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("FromLocal")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("MessageHtml")
+ .HasColumnType("text");
+
+ b.Property<string>("MessagePlain")
+ .HasColumnType("text");
+
+ b.Property<string>("MessagePreview")
+ .HasColumnType("text");
+
+ b.Property<string>("MessageSource")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<bool>("PushNotificationSent")
+ .HasColumnType("boolean");
+
+ b.Property<string>("Subject")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("To")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("ToDomain")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("ToLocal")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<Guid>("UserEncryptionKeyId")
+ .HasMaxLength(255)
+ .HasColumnType("uuid");
+
+ b.Property<bool>("Visible")
+ .HasColumnType("boolean");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Date");
+
+ b.HasIndex("DateSystem");
+
+ b.HasIndex("PushNotificationSent");
+
+ b.HasIndex("UserEncryptionKeyId");
+
+ b.HasIndex("Visible");
+
+ b.HasIndex("To", "DateSystem");
+
+ b.ToTable("Emails");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<byte[]>("Bytes")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.Property<DateTime>("Date")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("EmailId")
+ .HasColumnType("integer");
+
+ b.Property<string>("Filename")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<int>("Filesize")
+ .HasColumnType("integer");
+
+ b.Property<string>("MimeType")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("EmailId");
+
+ b.ToTable("EmailAttachments");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Log", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("Application")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("Exception")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("Level")
+ .IsRequired()
+ .HasMaxLength(128)
+ .HasColumnType("character varying(128)");
+
+ b.Property<string>("LogEvent")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("LogEvent");
+
+ b.Property<string>("Message")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("MessageTemplate")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("Properties")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("SourceContext")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime>("TimeStamp")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Application");
+
+ b.HasIndex("TimeStamp");
+
+ b.ToTable("Logs", (string)null);
+ });
+
+ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>
+ {
+ b.Property<string>("Id")
+ .HasColumnType("text");
+
+ b.Property<DateTime?>("ClearedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("ClientIpAddress")
+ .HasColumnType("text");
+
+ b.Property<string>("ClientPublicKey")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptedDecryptionKey")
+ .HasColumnType("text");
+
+ b.Property<DateTime?>("FulfilledAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("MobileIpAddress")
+ .HasColumnType("text");
+
+ b.Property<DateTime?>("RetrievedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex(new[] { "ClientIpAddress" }, "IX_ClientIpAddress");
+
+ b.HasIndex(new[] { "CreatedAt" }, "IX_CreatedAt");
+
+ b.HasIndex(new[] { "MobileIpAddress" }, "IX_MobileIpAddress");
+
+ b.HasIndex(new[] { "RetrievedAt", "ClearedAt", "FulfilledAt" }, "IX_RetrievedAt_ClearedAt_FulfilledAt");
+
+ b.HasIndex(new[] { "UserId" }, "IX_UserId");
+
+ b.ToTable("MobileLoginRequests");
+ });
+
+ modelBuilder.Entity("AliasServerDb.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<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<string>("UserId")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<int>("WindowSeconds")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Tier");
+
+ b.HasIndex("UserId");
+
+ 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.UserEmailClaim", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<string>("Address")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("AddressDomain")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("AddressLocal")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<bool>("Disabled")
+ .HasColumnType("boolean");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Address")
+ .IsUnique();
+
+ b.HasIndex("UserId", "CreatedAt");
+
+ b.HasIndex("UserId", "Disabled");
+
+ b.ToTable("UserEmailClaims");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<bool>("IsPrimary")
+ .HasColumnType("boolean");
+
+ b.Property<string>("PublicKey")
+ .IsRequired()
+ .HasMaxLength(2000)
+ .HasColumnType("character varying(2000)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("UserEncryptionKeys");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>
+ {
+ b.Property<string>("Hash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property<string>("OwnerUserId")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Category")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<byte[]>("EncryptedData")
+ .IsRequired()
+ .HasColumnType("bytea");
+
+ b.Property<DateTime>("LastReferencedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<int>("SizeBytes")
+ .HasColumnType("integer");
+
+ b.HasKey("Hash", "OwnerUserId");
+
+ b.HasIndex("OwnerUserId", "Category");
+
+ b.ToTable("VaultBlobObjects");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>
+ {
+ b.Property<Guid>("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>("RevisionId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<string>("Category")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("CiphertextHash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptedData")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("OwnerUserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<long>("RevisionNumber")
+ .HasColumnType("bigint");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("RevisionId");
+
+ b.HasIndex("OwnerUserId", "Category", "RevisionNumber")
+ .IsUnique();
+
+ b.ToTable("VaultDataBuckets");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultKey", b =>
+ {
+ b.Property<Guid>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property<DateTime>("CreatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("EncryptionSettings")
+ .HasColumnType("text");
+
+ b.Property<string>("EncryptionType")
+ .HasColumnType("text");
+
+ b.Property<string>("KeyType")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<DateTime?>("LastUsedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("Metadata")
+ .HasColumnType("jsonb");
+
+ b.Property<Guid?>("RecipientPublicKeyId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("Salt")
+ .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.Property<Guid?>("VaultManifestId")
+ .HasColumnType("uuid");
+
+ b.Property<string>("Verifier")
+ .HasMaxLength(1000)
+ .HasColumnType("character varying(1000)");
+
+ b.Property<string>("WrapScheme")
+ .IsRequired()
+ .HasMaxLength(30)
+ .HasColumnType("character varying(30)");
+
+ b.Property<string>("WrappedVek")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("VaultManifestId")
+ .HasDatabaseName("IX_VaultKeys_VaultManifestId");
+
+ b.HasIndex("UserId", "KeyType", "VaultManifestId")
+ .IsUnique()
+ .HasDatabaseName("UX_VaultKeys_UserId_KeyType_Manifest");
+
+ b.ToTable("VaultKeys");
+ });
+
+ 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")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("EncryptionType")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<int>("FileSize")
+ .HasColumnType("integer");
+
+ b.Property<bool>("IsRoot")
+ .HasColumnType("boolean");
+
+ b.Property<string>("ManifestBlob")
+ .HasColumnType("text");
+
+ b.Property<string>("ManifestCiphertextHash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property<string>("Name")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("OwnerUserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<long>("RevisionNumber")
+ .HasColumnType("bigint");
+
+ b.Property<string>("Salt")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("StorageFormat")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("VaultBlob")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("Verifier")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("character varying(1000)");
+
+ b.Property<string>("Version")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("ManifestId");
+
+ b.HasIndex("OwnerUserId")
+ .IsUnique()
+ .HasDatabaseName("UX_VaultManifests_OwnerUserId_Root")
+ .HasFilter("\"IsRoot\"");
+
+ b.ToTable("VaultManifests");
+ });
+
+ 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")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("EncryptionType")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<int>("FileSize")
+ .HasColumnType("integer");
+
+ b.Property<string>("ManifestBlob")
+ .HasColumnType("text");
+
+ b.Property<string>("ManifestCiphertextHash")
+ .HasMaxLength(64)
+ .HasColumnType("character varying(64)");
+
+ b.Property<string>("OwnerUserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.Property<string>("Salt")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property<string>("StorageFormat")
+ .IsRequired()
+ .HasMaxLength(20)
+ .HasColumnType("character varying(20)");
+
+ b.Property<DateTime>("UpdatedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("VaultBlob")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property<string>("Verifier")
+ .IsRequired()
+ .HasMaxLength(1000)
+ .HasColumnType("character varying(1000)");
+
+ b.Property<string>("Version")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("ManifestId", "RevisionNumber");
+
+ b.HasIndex("OwnerUserId");
+
+ b.ToTable("VaultManifestsHistory", (string)null);
+ });
+
+ modelBuilder.Entity("AliasVault.WorkerStatus.Database.WorkerServiceStatus", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("CurrentStatus")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<string>("DesiredStatus")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)");
+
+ b.Property<DateTime>("Heartbeat")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property<string>("ServiceName")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
+ b.HasKey("Id");
+
+ b.ToTable("WorkerServiceStatuses");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("FriendlyName")
+ .HasColumnType("text");
+
+ b.Property<string>("Xml")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("DataProtectionKeys");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("ClaimType")
+ .HasColumnType("text");
+
+ b.Property<string>("ClaimValue")
+ .HasColumnType("text");
+
+ b.Property<string>("RoleId")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("RoleClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
+
+ b.Property<string>("ClaimType")
+ .HasColumnType("text");
+
+ b.Property<string>("ClaimValue")
+ .HasColumnType("text");
+
+ b.Property<string>("UserId")
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("UserClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
+ {
+ b.Property<string>("LoginProvider")
+ .HasColumnType("text");
+
+ b.Property<string>("ProviderKey")
+ .HasColumnType("text");
+
+ b.Property<string>("ProviderDisplayName")
+ .HasColumnType("text");
+
+ b.Property<string>("UserId")
+ .HasColumnType("text");
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.ToTable("UserLogins", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
+ {
+ b.Property<string>("UserId")
+ .HasColumnType("text");
+
+ b.Property<string>("RoleId")
+ .HasColumnType("text");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.ToTable("UserRoles", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
+ {
+ b.Property<string>("UserId")
+ .HasColumnType("text");
+
+ b.Property<string>("LoginProvider")
+ .HasColumnType("text");
+
+ b.Property<string>("Name")
+ .HasColumnType("text");
+
+ b.Property<string>("Value")
+ .HasColumnType("text");
+
+ b.HasKey("UserId", "LoginProvider", "Name");
+
+ b.ToTable("UserTokens", (string)null);
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUserRefreshToken", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Email", b =>
+ {
+ b.HasOne("AliasServerDb.UserEncryptionKey", "EncryptionKey")
+ .WithMany("Emails")
+ .HasForeignKey("UserEncryptionKeyId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("EncryptionKey");
+ });
+
+ modelBuilder.Entity("AliasServerDb.EmailAttachment", b =>
+ {
+ b.HasOne("AliasServerDb.Email", "Email")
+ .WithMany("Attachments")
+ .HasForeignKey("EmailId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Email");
+ });
+
+ modelBuilder.Entity("AliasServerDb.MobileLoginRequest", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.RateLimit", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserEmailClaim", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany("EmailClaims")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.SetNull);
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany("EncryptionKeys")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultBlobObject", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("OwnerUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultBlobReference", b =>
+ {
+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")
+ .WithMany()
+ .HasForeignKey("ManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Manifest");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultDataBucket", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany()
+ .HasForeignKey("OwnerUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultKey", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany("VaultKeys")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifest", b =>
+ {
+ b.HasOne("AliasServerDb.AliasVaultUser", "User")
+ .WithMany("VaultManifests")
+ .HasForeignKey("OwnerUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasServerDb.VaultManifestsHistory", b =>
+ {
+ b.HasOne("AliasServerDb.VaultManifest", "Manifest")
+ .WithMany()
+ .HasForeignKey("ManifestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Manifest");
+ });
+
+ modelBuilder.Entity("AliasServerDb.AliasVaultUser", b =>
+ {
+ b.Navigation("EmailClaims");
+
+ b.Navigation("EncryptionKeys");
+
+ b.Navigation("VaultKeys");
+
+ b.Navigation("VaultManifests");
+ });
+
+ modelBuilder.Entity("AliasServerDb.Email", b =>
+ {
+ b.Navigation("Attachments");
+ });
+
+ modelBuilder.Entity("AliasServerDb.UserEncryptionKey", b =>
+ {
+ b.Navigation("Emails");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/apps/server/Databases/AliasServerDb/Migrations/20260722145437_AddVaultManifestName.cs b/apps/server/Databases/AliasServerDb/Migrations/20260722145437_AddVaultManifestName.cs
new file mode 100644
index 000000000..35d04cd28
--- /dev/null
+++ b/apps/server/Databases/AliasServerDb/Migrations/20260722145437_AddVaultManifestName.cs
@@ -0,0 +1,29 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace AliasServerDb.Migrations
+{
+ /// <inheritdoc />
+ public partial class AddVaultManifestName : Migration
+ {
+ /// <inheritdoc />
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn<string>(
+ name: "Name",
+ table: "VaultManifests",
+ type: "character varying(255)",
+ maxLength: 255,
+ nullable: true);
+ }
+
+ /// <inheritdoc />
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "Name",
+ table: "VaultManifests");
+ }
+ }
+}
diff --git a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs
index 62f64fa77..f8cc00c34 100644
--- a/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs
+++ b/apps/server/Databases/AliasServerDb/Migrations/AliasServerDbContextModelSnapshot.cs
@@ -996,6 +996,10 @@ namespace AliasServerDb.Migrations
.HasMaxLength(64)
.HasColumnType("character varying(64)");
+ b.Property<string>("Name")
+ .HasMaxLength(255)
+ .HasColumnType("character varying(255)");
+
b.Property<string>("OwnerUserId")
.IsRequired()
.HasMaxLength(255)
diff --git a/apps/server/Databases/AliasServerDb/VaultManifest.cs b/apps/server/Databases/AliasServerDb/VaultManifest.cs
index 7e68ff99d..293caf458 100644
--- a/apps/server/Databases/AliasServerDb/VaultManifest.cs
+++ b/apps/server/Databases/AliasServerDb/VaultManifest.cs
@@ -31,6 +31,14 @@ public class VaultManifest : VaultManifestBase
/// </summary>
public required bool IsRoot { get; set; }
+ /// <summary>
+ /// Gets or sets the display name of a shared folder manifest. Null for the root manifest (the user's main vault
+ /// has no name). Set only for non-root manifests, which — by definition — are shareable folders. This is stored
+ /// in plaintext so the sharing/ACL UI can list folders and pending shares without decrypting their content.
+ /// </summary>
+ [StringLength(255)]
+ public string? Name { get; set; }
+
/// <summary>
/// Gets or sets the ID of the owning user.
/// </summary>
diff --git a/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs b/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs
index 1f4e364d3..792ab97f0 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/Enums/ApiErrorCode.cs
@@ -163,4 +163,29 @@ public enum ApiErrorCode
/// The user has no vault key so the requested operation is unavailable; use the legacy v1 flow.
/// </summary>
VAULT_KEY_NOT_FOUND,
+
+ /// <summary>
+ /// The referenced shared folder manifest does not exist or is not owned by the caller.
+ /// </summary>
+ SHARED_MANIFEST_NOT_FOUND,
+
+ /// <summary>
+ /// The recipient already has a share grant for this manifest.
+ /// </summary>
+ SHARE_ALREADY_EXISTS,
+
+ /// <summary>
+ /// No share grant exists for the given recipient and manifest.
+ /// </summary>
+ SHARE_NOT_FOUND,
+
+ /// <summary>
+ /// The recipient has no usable public key to wrap a shared vault key for, or the referenced key is invalid.
+ /// </summary>
+ RECIPIENT_KEY_NOT_FOUND,
+
+ /// <summary>
+ /// The supplied wrap scheme is not valid for the requested operation.
+ /// </summary>
+ INVALID_WRAP_SCHEME,
}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedFolderRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedFolderRequest.cs
new file mode 100644
index 000000000..c350749f2
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedFolderRequest.cs
@@ -0,0 +1,28 @@
+//-----------------------------------------------------------------------
+// <copyright file="CreateSharedFolderRequest.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.Sharing;
+
+/// <summary>
+/// Request for POST /v2/Sharing/folders. Creates a new non-root (shareable) manifest owned by the caller. The
+/// folder's VEK is generated and kept client-side (wrapped into the owner's own vault); the server only stores the
+/// encrypted folder manifest. Access is granted to other users afterwards via POST /v2/Sharing/grant.
+/// </summary>
+public class CreateSharedFolderRequest
+{
+ /// <summary>Gets or sets the plaintext display name of the folder (server-visible for the sharing UI).</summary>
+ public required string Name { get; set; }
+
+ /// <summary>Gets or sets the encrypted folder manifest blob (AES-GCM ciphertext under the folder VEK, base64).</summary>
+ public required string ManifestBlob { get; set; }
+
+ /// <summary>Gets or sets the SHA-256 (hex) of the manifest ciphertext, for storage-layer integrity verification.</summary>
+ public string? ManifestCiphertextHash { get; set; }
+
+ /// <summary>Gets or sets the vault data model version string.</summary>
+ public required string Version { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedFolderResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedFolderResponse.cs
new file mode 100644
index 000000000..65027cd73
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/CreateSharedFolderResponse.cs
@@ -0,0 +1,20 @@
+//-----------------------------------------------------------------------
+// <copyright file="CreateSharedFolderResponse.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.Sharing;
+
+/// <summary>
+/// Response for POST /v2/Sharing/folders. Identifies the newly created shared folder manifest.
+/// </summary>
+public class CreateSharedFolderResponse
+{
+ /// <summary>Gets or sets the id of the created manifest (used to grant/revoke access and to sync the folder).</summary>
+ public required Guid ManifestId { get; set; }
+
+ /// <summary>Gets or sets the manifest's initial revision number.</summary>
+ public required long RevisionNumber { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/GrantAccessRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/GrantAccessRequest.cs
new file mode 100644
index 000000000..78f64d9cc
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/GrantAccessRequest.cs
@@ -0,0 +1,30 @@
+//-----------------------------------------------------------------------
+// <copyright file="GrantAccessRequest.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.Sharing;
+
+/// <summary>
+/// Request for POST /v2/Sharing/grant. Grants a recipient access to a shared folder manifest the caller owns, by
+/// persisting the folder's VEK wrapped with the recipient's public key. The server never sees the plaintext VEK.
+/// </summary>
+public class GrantAccessRequest
+{
+ /// <summary>Gets or sets the shared folder manifest to grant access to (must be owned by the caller).</summary>
+ public required Guid ManifestId { get; set; }
+
+ /// <summary>Gets or sets the recipient user id (from GET /v2/Sharing/recipient).</summary>
+ public required string RecipientUserId { get; set; }
+
+ /// <summary>Gets or sets the folder VEK wrapped with the recipient's public key (base64), decryptable only by the recipient.</summary>
+ public required string WrappedVek { get; set; }
+
+ /// <summary>Gets or sets the id of the recipient public key used to wrap (from GET /v2/Sharing/recipient).</summary>
+ public required Guid RecipientPublicKeyId { get; set; }
+
+ /// <summary>Gets or sets the asymmetric wrap scheme used, e.g. "x25519-sealedbox" or "rsa-oaep".</summary>
+ public required string WrapScheme { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/RecipientLookupResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/RecipientLookupResponse.cs
new file mode 100644
index 000000000..19037693d
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/RecipientLookupResponse.cs
@@ -0,0 +1,24 @@
+//-----------------------------------------------------------------------
+// <copyright file="RecipientLookupResponse.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.Sharing;
+
+/// <summary>
+/// Response for GET /v2/Sharing/recipient. Returns the primary public key a granter uses to wrap a shared folder's
+/// VEK for the recipient.
+/// </summary>
+public class RecipientLookupResponse
+{
+ /// <summary>Gets or sets the recipient's user id.</summary>
+ public required string UserId { get; set; }
+
+ /// <summary>Gets or sets the id of the recipient's primary public key (used as WrappedVek's RecipientPublicKeyId).</summary>
+ public required Guid PublicKeyId { get; set; }
+
+ /// <summary>Gets or sets the recipient's primary public key (the granter wraps the folder VEK with this).</summary>
+ public required string PublicKey { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/RevokeAccessRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/RevokeAccessRequest.cs
new file mode 100644
index 000000000..3c1da343b
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/RevokeAccessRequest.cs
@@ -0,0 +1,20 @@
+//-----------------------------------------------------------------------
+// <copyright file="RevokeAccessRequest.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.Sharing;
+
+/// <summary>
+/// Request for POST /v2/Sharing/revoke. Removes a recipient's access to a shared folder manifest the caller owns.
+/// </summary>
+public class RevokeAccessRequest
+{
+ /// <summary>Gets or sets the shared folder manifest to revoke access from (must be owned by the caller).</summary>
+ public required Guid ManifestId { get; set; }
+
+ /// <summary>Gets or sets the recipient user id whose grant is removed.</summary>
+ public required string RecipientUserId { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ShareMember.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ShareMember.cs
new file mode 100644
index 000000000..1c5c13543
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ShareMember.cs
@@ -0,0 +1,29 @@
+//-----------------------------------------------------------------------
+// <copyright file="ShareMember.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.Sharing;
+
+/// <summary>
+/// One member of a shared folder: the owner plus every recipient holding a grant.
+/// </summary>
+public class ShareMember
+{
+ /// <summary>Gets or sets the member's user id.</summary>
+ public required string UserId { get; set; }
+
+ /// <summary>Gets or sets the member's username.</summary>
+ public string? Username { get; set; }
+
+ /// <summary>Gets or sets a value indicating whether this member is the folder owner.</summary>
+ public required bool IsOwner { get; set; }
+
+ /// <summary>Gets or sets the wrap scheme of the member's grant (null for the owner, whose key is held client-side).</summary>
+ public string? WrapScheme { get; set; }
+
+ /// <summary>Gets or sets the timestamp the member's grant was created (null for the owner).</summary>
+ public DateTime? GrantedAt { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ShareMembersResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ShareMembersResponse.cs
new file mode 100644
index 000000000..e47112eb0
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/ShareMembersResponse.cs
@@ -0,0 +1,17 @@
+//-----------------------------------------------------------------------
+// <copyright file="ShareMembersResponse.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.Sharing;
+
+/// <summary>
+/// Response for GET /v2/Sharing/folders/{manifestId}/members. Lists the owner and every recipient of a shared folder.
+/// </summary>
+public class ShareMembersResponse
+{
+ /// <summary>Gets or sets the members of the shared folder (owner first, then recipients).</summary>
+ public List<ShareMember> Members { get; set; } = [];
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/SharedWithMeItem.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/SharedWithMeItem.cs
new file mode 100644
index 000000000..5adf08f52
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/SharedWithMeItem.cs
@@ -0,0 +1,33 @@
+//-----------------------------------------------------------------------
+// <copyright file="SharedWithMeItem.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.Sharing;
+
+/// <summary>
+/// One shared folder the caller has been granted access to. The caller unwraps <see cref="WrappedVek"/> with the
+/// private key matching the public key it was wrapped for, then uses the resulting VEK to decrypt the folder manifest.
+/// </summary>
+public class SharedWithMeItem
+{
+ /// <summary>Gets or sets the shared folder manifest id.</summary>
+ public required Guid ManifestId { get; set; }
+
+ /// <summary>Gets or sets the folder's display name.</summary>
+ public string? Name { get; set; }
+
+ /// <summary>Gets or sets the owner's user id.</summary>
+ public required string OwnerUserId { get; set; }
+
+ /// <summary>Gets or sets the owner's username.</summary>
+ public string? OwnerUsername { get; set; }
+
+ /// <summary>Gets or sets the folder VEK wrapped with the caller's public key (base64).</summary>
+ public required string WrappedVek { get; set; }
+
+ /// <summary>Gets or sets the wrap scheme of the grant (e.g. "x25519-sealedbox").</summary>
+ public required string WrapScheme { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/SharedWithMeResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/SharedWithMeResponse.cs
new file mode 100644
index 000000000..00e3d3d22
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Sharing/SharedWithMeResponse.cs
@@ -0,0 +1,17 @@
+//-----------------------------------------------------------------------
+// <copyright file="SharedWithMeResponse.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.Sharing;
+
+/// <summary>
+/// Response for GET /v2/Sharing/shared-with-me. Lists every shared folder the caller holds a grant for.
+/// </summary>
+public class SharedWithMeResponse
+{
+ /// <summary>Gets or sets the shared folders the caller has access to.</summary>
+ public List<SharedWithMeItem> Folders { get; set; } = [];
+}