Skip to content

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

Update email routing push logic (#2159)

Leendert de Borst87b95a54d5bf
diff --git a/apps/browser-extension/src/utils/EmailRouting.ts b/apps/browser-extension/src/utils/EmailRouting.ts
index 178b284ac..cee03f96f 100644
Binary files a/apps/browser-extension/src/utils/EmailRouting.ts and b/apps/browser-extension/src/utils/EmailRouting.ts differ
diff --git a/apps/browser-extension/src/utils/types/EmailRoutingPush.ts b/apps/browser-extension/src/utils/types/EmailRoutingPush.ts
index 102f0f5d0..a8675bead 100644
--- a/apps/browser-extension/src/utils/types/EmailRoutingPush.ts
+++ b/apps/browser-extension/src/utils/types/EmailRoutingPush.ts
@@ -2,13 +2,12 @@
* The email-routing set sent on a vault push: one entry per (address, manifest) pair. An address claimed by
* several manifests (personal + shared during family sharing) appears once per manifest; the server links the
* claim to each so incoming mail is key-wrapped per linked manifest.
- *
- * Every alias the vault carries is pushed. Absence from the list means the alias is gone from the vault
- * (the server disables its claim, which starts the retention clock on its stored mail), while `paused: true`
- * in this list means the user only stopped its mail (the claim link survives and its stored mail stays readable).
- *
- * This is the v2 push shape. The frozen v1 push sends a plain address list with no per-alias state.
*/
export type EmailRoutingPush = {
emailAddressList: Array<{ address: string; manifestId: string; paused: boolean }>;
+ /**
+ * The manifests this push speaks for: every manifest that went into the address list above, including the ones
+ * that hold no alias.
+ */
+ coveredManifestIds: string[];
};
diff --git a/apps/browser-extension/tests/helpers/manifest-v2-api.ts b/apps/browser-extension/tests/helpers/manifest-v2-api.ts
index 0e913aaac..58be3bb6f 100644
--- a/apps/browser-extension/tests/helpers/manifest-v2-api.ts
+++ b/apps/browser-extension/tests/helpers/manifest-v2-api.ts
@@ -147,7 +147,7 @@ export async function pushManifest(
}],
buckets: [],
newBlobs: [],
- emailRouting: { emailAddressList: [] },
+ emailRouting: null,
userEncryptionPublicKey: '',
};
diff --git a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs b/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
index c06284844..a3c15db03 100644
--- a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
+++ b/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
@@ -563,8 +563,10 @@ public class VaultController(
await context.SaveChangesAsync();
}
- if (model.EmailRouting is { EmailAddressList.Count: > 0 })
+ if (model.EmailRouting is not null)
{
+ // Only update email claims when the client sends a non-empty routing object. If null has been sent by client, we
+ // do not update the email claims (so to not delete any claims if they have been forgotten by the client).
await UpdateEmailClaimsAsync(context, user, model.EmailRouting);
}
@@ -994,7 +996,7 @@ public class VaultController(
/// </summary>
/// <param name="context">Database context.</param>
/// <param name="user">The calling user.</param>
- /// <param name="routing">The pushed routing data: one entry per (address, manifest) pair.</param>
+ /// <param name="routing">The pushed routing data: one entry per (address, manifest) pair, plus the manifests it speaks for.</param>
private async Task UpdateEmailClaimsAsync(AliasServerDbContext context, AliasVaultUser user, EmailRoutingPush routing)
{
// Get all unique emails with calculated state (active wins from paused in case there are multiple).
@@ -1008,7 +1010,6 @@ public class VaultController(
.Where(m => context.GroupMembers.Any(gm => gm.GroupId == m.OwnerGroupId && gm.UserId == user.Id && gm.Role == GroupRole.Owner))
.Select(m => m.ManifestId)
.ToListAsync()).ToHashSet();
- var updateScope = accessibleManifests.Union(ownedManifests).ToHashSet();
// Resolved server-side and never read off the push: this is what stops a client filing an alias under a manifest it merely named.
var personalManifestId = await GroupHelper.GetPersonalManifestIdAsync(context, user.PersonalGroupId);
@@ -1033,6 +1034,12 @@ public class VaultController(
var assertedManifestIds = assertedPairs.Select(p => p.ManifestId).Distinct().ToList();
var ownerGroupByManifest = await GroupHelper.GetOwnerGroupsAsync(context, assertedManifestIds);
+ // The manifests this push speaks for: the ones the client says it opened, plus any it named an address for.
+ var coveredManifestIds = routing.CoveredManifestIds.ToHashSet();
+ coveredManifestIds.UnionWith(assertedManifestIds);
+
+ var updateScope = accessibleManifests.Union(ownedManifests).Intersect(coveredManifestIds).ToHashSet();
+
// Warn when a shared manifest claims aliases without a published delivery key: it gets no wrap for its mail until one is published.
var manifestsWithDeliveryKey = (await context.VaultManifestDeliveryKeys
.Where(k => assertedManifestIds.Contains(k.VaultManifestId) && k.IsPrimary)
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/EmailRoutingPush.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/EmailRoutingPush.cs
index 3982b14ab..7ecd1b441 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/EmailRoutingPush.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/EmailRoutingPush.cs
@@ -9,7 +9,8 @@ namespace AliasVault.Shared.Models.WebApi.V2.Vault;
/// <summary>
/// The email-routing set a vault push uploads: every alias the client wants routed, each carrying the manifest
-/// that owns it. Aliases missing from a push are disabled, so a push always carries the complete set.
+/// that owns it. Aliases missing from a push are disabled, so a push always carries the complete set of the
+/// manifests it covers (see <see cref="CoveredManifestIds"/>).
/// </summary>
public class EmailRoutingPush
{
@@ -18,4 +19,10 @@ public class EmailRoutingPush
/// are a request, not a grant: the server validates each against what the caller may claim for.
/// </summary>
public List<ClaimedEmailAddress> EmailAddressList { get; set; } = [];
+
+ /// <summary>
+ /// Gets or sets the manifests this push speaks for: every manifest the client opened to build the address list
+ /// above, whether or not it holds any alias.
+ /// </summary>
+ public List<Guid> CoveredManifestIds { get; set; } = [];
}