Skip to content

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

Update API to return list of manifests instead of a singular entry (#2159)

Leendert de Borsteefca78b1819
diff --git a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
index 754337d66..0bf27910f 100644
--- a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
+++ b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
@@ -6,7 +6,7 @@ import { TRASH_RETENTION_DAYS } from '@/utils/constants/vault';
import { devError, devLog, devWarn } from '@/utils/devLogger/DevLogger';
import type { EncryptionKeyDerivationParams } from '@/utils/dist/core/models/metadata';
import { FieldKey, ItemTypes, createSystemField, type Item, type PasswordSettings } from '@/utils/dist/core/models/vault';
-import type { VaultResponse, VaultPostResponse } from '@/utils/dist/core/models/webapi';
+import type { VaultResponse, VaultPostResponse, StatusResponseV2 } from '@/utils/dist/core/models/webapi';
import { EncryptionUtility } from '@/utils/EncryptionUtility';
import { LocalPreferencesService } from '@/utils/LocalPreferencesService';
import { RecentlySelectedItemService } from '@/utils/RecentlySelectedItemService';
@@ -54,6 +54,18 @@ import { t } from '@/i18n/StandaloneI18n';
let cachedSqliteClient: SqliteClient | null = null;
let cachedVaultBlob: string | null = null;
+/** The manifest category representing the user's own personal vault. */
+const MAIN_MANIFEST_CATEGORY = 'Main';
+
+/**
+ * The server revision of the user's Main manifest,
+ * @param status - the v2 status response from the server
+ */
+function mainManifestRevision(status: StatusResponseV2): number {
+ const main = (status.manifestRevisions ?? []).find(m => m.category === MAIN_MANIFEST_CATEGORY);
+ return main?.revision ?? 0;
+}
+
/**
* Global sync queue state.
* Prevents multiple simultaneous sync operations and ensures pending changes are synced.
@@ -264,7 +276,7 @@ export async function handleSyncVault(
const localServerRevision = await storage.getItem('local:serverRevision') as number | null ?? 0;
- if (statusResponse.vaultRevision > localServerRevision) {
+ if (mainManifestRevision(statusResponse) > localServerRevision) {
/*
* Retrieve the latest vault from the server.
*/
@@ -1269,7 +1281,7 @@ export async function handleCheckSyncStatus(): Promise<SyncStatusCheckResult> {
return {
success: true,
- hasNewerVault: statusResponse.vaultRevision > syncState.serverRevision,
+ hasNewerVault: mainManifestRevision(statusResponse) > syncState.serverRevision,
hasDirtyChanges: syncState.isDirty,
isOffline: false,
requiresLogout: false
@@ -1360,7 +1372,10 @@ async function handleFullVaultSyncInternal(): Promise<FullVaultSyncResult> {
// Get current sync state
const syncState = await handleGetSyncState();
- devLog(`[VaultSync] Status received (server rev ${statusResponse.vaultRevision}, local rev ${syncState.serverRevision}, isDirty ${syncState.isDirty})`);
+ // Compare the Main manifest's server revision (not the global vaultRevision) against our last-known revision.
+ const serverManifestRevision = mainManifestRevision(statusResponse);
+
+ devLog(`[VaultSync] Status received (server rev ${serverManifestRevision}, local rev ${syncState.serverRevision}, isDirty ${syncState.isDirty})`);
// Check if server is actually available (0.0.0 indicates connection error)
if (statusResponse.serverVersion === '0.0.0') {
@@ -1400,7 +1415,7 @@ async function handleFullVaultSyncInternal(): Promise<FullVaultSyncResult> {
return { success: false, hasNewVault: false, wasOffline: false, upgradeRequired: false, requiresLogout: false, error: await t('common.errors.vaultIsLocked') };
}
- if (statusResponse.vaultRevision > syncState.serverRevision) {
+ if (serverManifestRevision > syncState.serverRevision) {
/*
* Server has a newer vault.
*/
@@ -1514,7 +1529,7 @@ async function handleFullVaultSyncInternal(): Promise<FullVaultSyncResult> {
AppErrorCode.VAULT_DECRYPT_FAILED
));
}
- } else if (statusResponse.vaultRevision === syncState.serverRevision) {
+ } else if (serverManifestRevision === syncState.serverRevision) {
/**
* Server and local vault are at the same revision.
* If we have pending local changes, upload them now.
@@ -1546,13 +1561,13 @@ async function handleFullVaultSyncInternal(): Promise<FullVaultSyncResult> {
}
return { success: true, hasNewVault: false, wasOffline: false, upgradeRequired: false, requiresLogout: false };
- } else if (statusResponse.vaultRevision < syncState.serverRevision) {
+ } else if (serverManifestRevision < syncState.serverRevision) {
/**
* Server revision DECREASED - server data loss/rollback detected.
* Client has more advanced revision - upload to recover server state.
*/
console.warn(
- `Server data loss detected! Server at rev ${statusResponse.vaultRevision}, ` +
+ `Server data loss detected! Server at rev ${serverManifestRevision}, ` +
`client at rev ${syncState.serverRevision}. Uploading to recover server state.`
);
@@ -1565,7 +1580,7 @@ async function handleFullVaultSyncInternal(): Promise<FullVaultSyncResult> {
});
console.info(
- `Server recovery complete: rev ${statusResponse.vaultRevision} → ${uploadResponse.newRevisionNumber}`
+ `Server recovery complete: rev ${serverManifestRevision} → ${uploadResponse.newRevisionNumber}`
);
return { success: true, hasNewVault: uploadResponse.vaultPruned === true, wasOffline: false, upgradeRequired: false, requiresLogout: false };
diff --git a/apps/browser-extension/src/utils/WebApiService.ts b/apps/browser-extension/src/utils/WebApiService.ts
index 5fe490312..b16bb448e 100644
--- a/apps/browser-extension/src/utils/WebApiService.ts
+++ b/apps/browser-extension/src/utils/WebApiService.ts
@@ -1,4 +1,4 @@
-import type { StatusResponse } from '@/utils/dist/core/models/webapi';
+import type { StatusResponseV2 } from '@/utils/dist/core/models/webapi';
import { logoutEventEmitter } from '@/events/LogoutEventEmitter';
@@ -309,9 +309,9 @@ export class WebApiService {
* Returns offline indicator (serverVersion: '0.0.0') for network failures and server errors (5xx, 404, etc.).
* Auth errors (ApiAuthError) are re-thrown to be handled appropriately (e.g., trigger logout).
*/
- public async getStatus(): Promise<StatusResponse> {
+ public async getStatus(): Promise<StatusResponseV2> {
try {
- const status = await this.get<StatusResponse>('Auth/status');
+ const status = await this.get<StatusResponseV2>('Auth/status');
// Persist the server version so it can be shown on the settings page, also while offline.
if (status.serverVersion && status.serverVersion !== '0.0.0') {
await storage.setItem('local:serverVersion', status.serverVersion);
@@ -329,7 +329,7 @@ export class WebApiService {
return {
clientVersionSupported: true,
serverVersion: '0.0.0',
- vaultRevision: 0,
+ manifestRevisions: [],
srpSalt: ''
};
}
@@ -338,7 +338,7 @@ export class WebApiService {
/**
* Validates the status response and returns an error message (as translation key) if validation fails.
*/
- public validateStatusResponse(statusResponse: StatusResponse): string | null {
+ public validateStatusResponse(statusResponse: StatusResponseV2): string | null {
if (!statusResponse.clientVersionSupported) {
return 'clientVersionNotSupported';
}
diff --git a/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts b/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts
index 0bffdace9..8186cbda5 100644
--- a/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts
+++ b/apps/browser-extension/src/utils/dist/core/models/webapi/index.d.ts
@@ -59,7 +59,7 @@ type VaultPostResponse = {
};
/**
- * Status response type.
+ * Status response type (v1). Returned by GET /v1/Auth/status.
*/
type StatusResponse = {
clientVersionSupported: boolean;
@@ -68,6 +68,24 @@ type StatusResponse = {
srpSalt: string;
};
+/**
+ * The latest revision of a single logical manifest.
+ */
+type ManifestRevision = {
+ manifestId: string;
+ category: string;
+ revision: number;
+};
+/**
+ * Status response type (v2). Returned by GET /v2/Auth/status.
+ */
+type StatusResponseV2 = {
+ clientVersionSupported: boolean;
+ serverVersion: string;
+ manifestRevisions: ManifestRevision[];
+ srpSalt: string;
+};
+
/**
* Login request type.
*/
@@ -424,4 +442,4 @@ type MobileLoginPollResponse = {
encryptedUsername: string | null;
};
-export { type ApiErrorResponse, AuthEventType, type AuthLogModel, type BadRequestResponse, type DeleteAccountInitiateRequest, type DeleteAccountInitiateResponse, type DeleteAccountRequest, type Email, type EmailAttachment, type FaviconExtractModel, type LoginRequest, type LoginResponse, type MailboxBulkRequest, type MailboxBulkResponse, type MailboxEmail, type MobileLoginInitiateRequest, type MobileLoginInitiateResponse, type MobileLoginPollResponse, type MobileLoginSubmitRequest, type PasswordChangeInitiateResponse, type RefreshToken, type StatusResponse, type TokenModel, type ValidateLoginRequest, type ValidateLoginRequest2Fa, type ValidateLoginResponse, type Vault, type VaultPasswordChangeRequest, type VaultPostResponse, type VaultResponse };
+export { type ApiErrorResponse, AuthEventType, type AuthLogModel, type BadRequestResponse, type DeleteAccountInitiateRequest, type DeleteAccountInitiateResponse, type DeleteAccountRequest, type Email, type EmailAttachment, type FaviconExtractModel, type LoginRequest, type LoginResponse, type MailboxBulkRequest, type MailboxBulkResponse, type MailboxEmail, type ManifestRevision, type MobileLoginInitiateRequest, type MobileLoginInitiateResponse, type MobileLoginPollResponse, type MobileLoginSubmitRequest, type PasswordChangeInitiateResponse, type RefreshToken, type StatusResponse, type StatusResponseV2, type TokenModel, type ValidateLoginRequest, type ValidateLoginRequest2Fa, type ValidateLoginResponse, type Vault, type VaultPasswordChangeRequest, type VaultPostResponse, type VaultResponse };
diff --git a/apps/mobile-app/utils/dist/core/models/webapi/index.d.ts b/apps/mobile-app/utils/dist/core/models/webapi/index.d.ts
index 0bffdace9..8186cbda5 100644
--- a/apps/mobile-app/utils/dist/core/models/webapi/index.d.ts
+++ b/apps/mobile-app/utils/dist/core/models/webapi/index.d.ts
@@ -59,7 +59,7 @@ type VaultPostResponse = {
};
/**
- * Status response type.
+ * Status response type (v1). Returned by GET /v1/Auth/status.
*/
type StatusResponse = {
clientVersionSupported: boolean;
@@ -68,6 +68,24 @@ type StatusResponse = {
srpSalt: string;
};
+/**
+ * The latest revision of a single logical manifest.
+ */
+type ManifestRevision = {
+ manifestId: string;
+ category: string;
+ revision: number;
+};
+/**
+ * Status response type (v2). Returned by GET /v2/Auth/status.
+ */
+type StatusResponseV2 = {
+ clientVersionSupported: boolean;
+ serverVersion: string;
+ manifestRevisions: ManifestRevision[];
+ srpSalt: string;
+};
+
/**
* Login request type.
*/
@@ -424,4 +442,4 @@ type MobileLoginPollResponse = {
encryptedUsername: string | null;
};
-export { type ApiErrorResponse, AuthEventType, type AuthLogModel, type BadRequestResponse, type DeleteAccountInitiateRequest, type DeleteAccountInitiateResponse, type DeleteAccountRequest, type Email, type EmailAttachment, type FaviconExtractModel, type LoginRequest, type LoginResponse, type MailboxBulkRequest, type MailboxBulkResponse, type MailboxEmail, type MobileLoginInitiateRequest, type MobileLoginInitiateResponse, type MobileLoginPollResponse, type MobileLoginSubmitRequest, type PasswordChangeInitiateResponse, type RefreshToken, type StatusResponse, type TokenModel, type ValidateLoginRequest, type ValidateLoginRequest2Fa, type ValidateLoginResponse, type Vault, type VaultPasswordChangeRequest, type VaultPostResponse, type VaultResponse };
+export { type ApiErrorResponse, AuthEventType, type AuthLogModel, type BadRequestResponse, type DeleteAccountInitiateRequest, type DeleteAccountInitiateResponse, type DeleteAccountRequest, type Email, type EmailAttachment, type FaviconExtractModel, type LoginRequest, type LoginResponse, type MailboxBulkRequest, type MailboxBulkResponse, type MailboxEmail, type ManifestRevision, type MobileLoginInitiateRequest, type MobileLoginInitiateResponse, type MobileLoginPollResponse, type MobileLoginSubmitRequest, type PasswordChangeInitiateResponse, type RefreshToken, type StatusResponse, type StatusResponseV2, type TokenModel, type ValidateLoginRequest, type ValidateLoginRequest2Fa, type ValidateLoginResponse, type Vault, type VaultPasswordChangeRequest, type VaultPostResponse, type VaultResponse };
diff --git a/apps/server/AliasVault.Api/Controllers/V2/AuthController.cs b/apps/server/AliasVault.Api/Controllers/V2/AuthController.cs
index 6cf9de459..cca59c412 100644
--- a/apps/server/AliasVault.Api/Controllers/V2/AuthController.cs
+++ b/apps/server/AliasVault.Api/Controllers/V2/AuthController.cs
@@ -97,9 +97,15 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM
return Unauthorized(ApiErrorCodeHelper.CreateErrorResponse(ApiErrorCode.ACCOUNT_BLOCKED, 401));
}
- // Get latest vault revision number
+ // Latest revision per logical manifest (group by ManifestId, take the max) so the client can compare each
+ // manifest against its own last-known revision.
+ var manifestRevisions = user.VaultManifests
+ .GroupBy(x => new { x.ManifestId, x.Category })
+ .Select(g => new AliasVault.Shared.Models.WebApi.V2.Vault.ManifestRevision { ManifestId = g.Key.ManifestId, Category = g.Key.Category, Revision = g.Max(m => m.RevisionNumber) })
+ .ToList();
+
+ // Still needed for the SRP salt below (unrelated to revision reporting).
var latestVault = user.VaultManifests.OrderByDescending(x => x.RevisionNumber).FirstOrDefault();
- var latestRevision = latestVault?.RevisionNumber ?? 0;
// Check client version compatibility if header is provided
var clientSupported = false;
@@ -112,11 +118,11 @@ public class AuthController(IAliasServerDbContextFactory dbContextFactory, UserM
clientSupported = meetsMinimum && !isBlocked;
}
- return Ok(new StatusResponse
+ return Ok(new AliasVault.Shared.Models.WebApi.V2.Auth.StatusResponse
{
ClientVersionSupported = clientSupported,
ServerVersion = AppInfo.GetFullVersion(),
- VaultRevision = latestRevision,
+ ManifestRevisions = manifestRevisions,
SrpSalt = latestVault?.Salt ?? string.Empty,
});
}
diff --git a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs b/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
index f4b1e0b68..1a500f773 100644
--- a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
+++ b/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
@@ -70,15 +70,12 @@ public class VaultController(
return Unauthorized();
}
- // Check if the user has migrated to v2 by checking if they have any manifest-v1 rows.
- var isV2 = await context.VaultManifests.AnyAsync(x => x.OwnerUserId == user.Id && x.StorageFormat == ManifestFormat);
-
- // Content revision = the highest RevisionNumber among the user's manifest-v1 rows. Null for legacy users.
- var manifestRevision = isV2
- ? await context.VaultManifests
- .Where(x => x.OwnerUserId == user.Id && x.StorageFormat == ManifestFormat)
- .MaxAsync(x => (long?)x.RevisionNumber)
- : null;
+ // Latest revision per logical manifest.
+ var manifestRevisions = await context.VaultManifests
+ .Where(x => x.OwnerUserId == user.Id && x.StorageFormat == ManifestFormat)
+ .GroupBy(x => new { x.ManifestId, x.Category })
+ .Select(g => new ManifestRevision { ManifestId = g.Key.ManifestId, Category = g.Key.Category, Revision = g.Max(m => m.RevisionNumber) })
+ .ToListAsync();
// Latest revision per bucket kind (history table → group by kind, take the max).
var bucketRevisions = await context.VaultDataBuckets
@@ -89,8 +86,8 @@ public class VaultController(
return Ok(new StatusResponse
{
- StorageFormat = isV2 ? StorageFormat.Manifest : StorageFormat.SqliteBlob,
- ManifestRevision = manifestRevision,
+ StorageFormat = manifestRevisions.Count > 0 ? StorageFormat.Manifest : StorageFormat.SqliteBlob,
+ ManifestRevisions = manifestRevisions,
BucketRevisions = bucketRevisions,
});
}
@@ -112,12 +109,17 @@ public class VaultController(
var emailRouting = await BuildEmailRoutingAsync(context, user);
- var latestVault = await context.VaultManifests
- .Where(x => x.OwnerUserId == user.Id && x.StorageFormat == ManifestFormat)
- .OrderByDescending(x => x.RevisionNumber)
- .FirstOrDefaultAsync();
+ // Latest revision per logical manifest: keep only rows whose RevisionNumber equals the max for their
+ // ManifestId.
+ var latestManifests = await context.VaultManifests
+ .Where(x => x.OwnerUserId == user.Id && x.StorageFormat == ManifestFormat
+ && x.RevisionNumber == context.VaultManifests
+ .Where(y => y.OwnerUserId == user.Id && y.StorageFormat == ManifestFormat && y.ManifestId == x.ManifestId)
+ .Max(y => y.RevisionNumber))
+ .Select(x => new { x.RevisionId, x.ManifestId, x.Category, x.ManifestBlob, x.ManifestCiphertextHash, x.RevisionNumber })
+ .ToListAsync();
- if (latestVault == null)
+ if (latestManifests.Count == 0)
{
// User hasn't migrated to manifest-v1 yet. Rather than forcing the client onto the v1 endpoint (which
// would round-trip through the 426 guard), we serve the latest legacy SQLite blob from here with a
@@ -134,7 +136,7 @@ public class VaultController(
StorageFormat = StorageFormat.SqliteBlob,
LegacyVaultBlob = legacy?.VaultBlob ?? string.Empty,
Version = legacy?.Version ?? string.Empty,
- ManifestRevision = legacy?.RevisionNumber ?? 0,
+ LegacyRevision = legacy?.RevisionNumber ?? 0,
EmailRouting = emailRouting,
});
}
@@ -154,8 +156,70 @@ public class VaultController(
})
.ToListAsync();
+ // Blob references are scoped per manifest revision. Fetch them for all latest manifests in one query, then
+ // group them back onto each manifest so every entry in the list carries exactly the blobs it needs.
+ var latestRevisionIds = latestManifests.Select(m => m.RevisionId).ToList();
+ var refsByRevision = (await context.VaultBlobReferences
+ .Where(r => latestRevisionIds.Contains(r.ManifestRevisionId))
+ .Join(
+ context.VaultBlobObjects.Where(b => b.OwnerUserId == user.Id),
+ r => r.BlobHash,
+ b => b.Hash,
+ (r, b) => new { r.ManifestRevisionId, b.Hash, b.Category })
+ .ToListAsync())
+ .GroupBy(x => x.ManifestRevisionId)
+ .ToDictionary(g => g.Key, g => g.Select(x => new BlobReference { Hash = x.Hash, Category = x.Category }).ToList());
+
+ var manifests = latestManifests.Select(m => new Manifest
+ {
+ ManifestId = m.ManifestId,
+ Category = m.Category,
+ Blob = m.ManifestBlob,
+ CiphertextHash = m.ManifestCiphertextHash,
+ Revision = m.RevisionNumber,
+ BlobReferences = refsByRevision.TryGetValue(m.RevisionId, out var refs) ? refs : [],
+ }).ToList();
+
+ return Ok(new GetResponse
+ {
+ Status = VaultStatus.Ok,
+ StorageFormat = StorageFormat.Manifest,
+ Manifests = manifests,
+ Buckets = buckets,
+ EmailRouting = emailRouting,
+ });
+ }
+
+ /// <summary>
+ /// Single-manifest fetch. Returns the latest revision of one logical manifest (by ManifestId) plus its blob
+ /// references, without the rest of the snapshot. Lets a client incrementally refresh just one manifest (e.g. a
+ /// single shared folder) instead of re-pulling the whole vault. The bundled <see cref="Get"/> stays the
+ /// one-round-trip path for fresh init.
+ /// </summary>
+ /// <param name="manifestId">The stable identifier of the logical manifest to fetch.</param>
+ /// <returns>The manifest DTO, or 404 when the user has no such manifest-v1 manifest.</returns>
+ [HttpGet("manifest/{manifestId:guid}")]
+ public async Task<IActionResult> GetManifest(Guid manifestId)
+ {
+ await using var context = await dbContextFactory.CreateDbContextAsync();
+ var user = await GetCurrentUserAsync();
+ if (user == null)
+ {
+ return Unauthorized();
+ }
+
+ var latest = await context.VaultManifests
+ .Where(x => x.OwnerUserId == user.Id && x.StorageFormat == ManifestFormat && x.ManifestId == manifestId)
+ .OrderByDescending(x => x.RevisionNumber)
+ .FirstOrDefaultAsync();
+
+ if (latest == null)
+ {
+ return NotFound();
+ }
+
var blobRefs = await context.VaultBlobReferences
- .Where(r => r.ManifestRevisionId == latestVault.RevisionId)
+ .Where(r => r.ManifestRevisionId == latest.RevisionId)
.Join(
context.VaultBlobObjects.Where(b => b.OwnerUserId == user.Id),
r => r.BlobHash,
@@ -163,16 +227,14 @@ public class VaultController(
(r, b) => new BlobReference { Hash = b.Hash, Category = b.Category })
.ToListAsync();
- return Ok(new GetResponse
+ return Ok(new Manifest
{
- Status = VaultStatus.Ok,
- StorageFormat = StorageFormat.Manifest,
- ManifestBlob = latestVault.ManifestBlob,
- ManifestCiphertextHash = latestVault.ManifestCiphertextHash,
- ManifestRevision = latestVault.RevisionNumber,
- Buckets = buckets,
+ ManifestId = latest.ManifestId,
+ Category = latest.Category,
+ Blob = latest.ManifestBlob,
+ CiphertextHash = latest.ManifestCiphertextHash,
+ Revision = latest.RevisionNumber,
BlobReferences = blobRefs,
- EmailRouting = emailRouting,
});
}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/StatusResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/StatusResponse.cs
index 685137bec..b53233a96 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/StatusResponse.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Auth/StatusResponse.cs
@@ -8,7 +8,8 @@
namespace AliasVault.Shared.Models.WebApi.V1.Auth;
/// <summary>
-/// Response model for the status endpoint.
+/// Response model for the v1 status endpoint. Carries the single global vault revision. v2 clients use
+/// <see cref="AliasVault.Shared.Models.WebApi.V2.Auth.StatusResponse"/> instead, which is manifest-revision based.
/// </summary>
public class StatusResponse
{
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/StatusResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/StatusResponse.cs
new file mode 100644
index 000000000..b0a50038c
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/StatusResponse.cs
@@ -0,0 +1,43 @@
+//-----------------------------------------------------------------------
+// <copyright file="StatusResponse.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 AliasVault.Shared.Models.WebApi.V2.Vault;
+
+/// <summary>
+/// Response model for the v2 status endpoint.
+/// </summary>
+public class StatusResponse
+{
+ /// <summary>
+ /// Gets or sets a value indicating whether the client version is supported by this API, as
+ /// determined by the server based on the client provided header.
+ /// </summary>
+ public required bool ClientVersionSupported { get; set; }
+
+ /// <summary>
+ /// Gets or sets the API version of the server. This is used by the client to determine if it
+ /// is compatible with the server or if the server should be updated to a newer version.
+ /// </summary>
+ public required string ServerVersion { get; set; }
+
+ /// <summary>
+ /// Gets or sets the latest revision for each logical manifest the user has, so the client can compare each
+ /// manifest's server revision against its own last-known revision per manifest. For a not-yet-migrated user
+ /// the server synthesizes a Main entry from their legacy vault, so the list always contains at least one entry
+ /// for an existing user.
+ /// </summary>
+ public List<ManifestRevision> ManifestRevisions { get; set; } = [];
+
+ /// <summary>
+ /// Gets or sets the SRP salt. This is used by the client to validate that the local encryption key
+ /// still matches the latest vault revision. If it doesn't match, the client should trigger a logout
+ /// to make the user re-authenticate with the new password.
+ /// </summary>
+ public required string SrpSalt { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/GetResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/GetResponse.cs
index d09bee614..faaef22a8 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/GetResponse.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/GetResponse.cs
@@ -28,21 +28,17 @@ public class GetResponse
/// <summary>Gets or sets the data-model version string of the returned vault (legacy version for sqlite-blob).</summary>
public string? Version { get; set; }
- /// <summary>Gets or sets the encrypted manifest blob (base64 of AES-GCM ciphertext) — null on empty vault.</summary>
- public string? ManifestBlob { get; set; }
+ /// <summary>Gets or sets the legacy sqlite-blob revision number. Set only when StorageFormat = SqliteBlob.</summary>
+ public long? LegacyRevision { get; set; }
- /// <summary>Gets or sets the SHA-256 (hex) of the manifest ciphertext for client-side storage-integrity check.</summary>
- public string? ManifestCiphertextHash { get; set; }
-
- /// <summary>Gets or sets the manifest revision number.</summary>
- public long? ManifestRevision { get; set; }
+ /// <summary>
+ /// Gets or sets the manifests that make up the user's logical vault. Empty for legacy sqlite-blobs.
+ /// </summary>
+ public List<Manifest> Manifests { get; set; } = [];
/// <summary>Gets or sets the data buckets (e.g. settings) for this user — each with its own kind + revision.</summary>
public List<Bucket> Buckets { get; set; } = [];
- /// <summary>Gets or sets the list of blob references the manifest needs (so the client can detect cache misses).</summary>
- public List<BlobReference> BlobReferences { get; set; } = [];
-
/// <summary>Gets or sets the plaintext email routing data (private/public domains + claimed addresses).</summary>
public EmailRouting EmailRouting { get; set; } = new();
}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.cs
new file mode 100644
index 000000000..9e130bbe3
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/Manifest.cs
@@ -0,0 +1,35 @@
+//-----------------------------------------------------------------------
+// <copyright file="Manifest.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.Vault;
+
+/// <summary>
+/// A single vault manifest as carried in list-based payloads. A user's logical vault is assembled from one or more
+/// manifests: exactly one <see cref="VaultManifestCategory.Main"/> plus (from R2) any number of
+/// <see cref="VaultManifestCategory.SharedFolder"/> manifests the user owns or has been granted access to. Each
+/// manifest is independently encrypted and revisioned, and carries its own blob references.
+/// </summary>
+public class Manifest
+{
+ /// <summary>Gets or sets the stable identifier of the logical manifest (constant across its revisions).</summary>
+ public required Guid ManifestId { get; set; }
+
+ /// <summary>Gets or sets the manifest kind discriminator.</summary>
+ public required VaultManifestCategory Category { get; set; }
+
+ /// <summary>Gets or sets the encrypted manifest blob (base64 of AES-GCM ciphertext) — null on empty vault.</summary>
+ public string? Blob { get; set; }
+
+ /// <summary>Gets or sets the SHA-256 (hex) of the manifest ciphertext for client-side storage-integrity check.</summary>
+ public string? CiphertextHash { get; set; }
+
+ /// <summary>Gets or sets the manifest revision number.</summary>
+ public required long Revision { get; set; }
+
+ /// <summary>Gets or sets the blob references this manifest revision needs (so the client can detect cache misses).</summary>
+ public List<BlobReference> BlobReferences { get; set; } = [];
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestRevision.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestRevision.cs
new file mode 100644
index 000000000..6bb6da782
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/ManifestRevision.cs
@@ -0,0 +1,24 @@
+//-----------------------------------------------------------------------
+// <copyright file="ManifestRevision.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.Vault;
+
+/// <summary>
+/// The current revision of a single logical manifest. Used in lightweight payloads (the status response) that report
+/// per-manifest revisions without carrying the encrypted blobs. Mirrors <see cref="BucketRevision"/>.
+/// </summary>
+public class ManifestRevision
+{
+ /// <summary>Gets or sets the stable identifier of the logical manifest.</summary>
+ public required Guid ManifestId { get; set; }
+
+ /// <summary>Gets or sets the manifest kind discriminator.</summary>
+ public required VaultManifestCategory Category { get; set; }
+
+ /// <summary>Gets or sets the current (latest) revision number for this manifest.</summary>
+ public required long Revision { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/StatusResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/StatusResponse.cs
index 4eea6261b..7d5ca4e7b 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/StatusResponse.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/StatusResponse.cs
@@ -15,8 +15,8 @@ public class StatusResponse
/// <summary>Gets or sets the storage format the server has recorded for the user's latest vault.</summary>
public required StorageFormat StorageFormat { get; set; }
- /// <summary>Gets or sets the latest manifest revision (null for legacy users).</summary>
- public long? ManifestRevision { get; set; }
+ /// <summary>Gets or sets the latest revision for each logical manifest the user has. Empty for legacy users.</summary>
+ public List<ManifestRevision> ManifestRevisions { get; set; } = [];
/// <summary>Gets or sets the latest revision for each data-bucket kind the user has. Empty when none stored.</summary>
public List<BucketRevision> BucketRevisions { get; set; } = [];
diff --git a/core/models/src/webapi/StatusResponse.ts b/core/models/src/webapi/StatusResponse.ts
index 2942ee945..6b0c83d77 100644
--- a/core/models/src/webapi/StatusResponse.ts
+++ b/core/models/src/webapi/StatusResponse.ts
@@ -1,5 +1,5 @@
/**
- * Status response type.
+ * Status response type (v1). Returned by GET /v1/Auth/status.
*/
export type StatusResponse = {
clientVersionSupported: boolean;
diff --git a/core/models/src/webapi/StatusResponseV2.ts b/core/models/src/webapi/StatusResponseV2.ts
new file mode 100644
index 000000000..3a8fcb85e
--- /dev/null
+++ b/core/models/src/webapi/StatusResponseV2.ts
@@ -0,0 +1,18 @@
+/**
+ * The latest revision of a single logical manifest.
+ */
+export type ManifestRevision = {
+ manifestId: string;
+ category: string;
+ revision: number;
+}
+
+/**
+ * Status response type (v2). Returned by GET /v2/Auth/status.
+ */
+export type StatusResponseV2 = {
+ clientVersionSupported: boolean;
+ serverVersion: string;
+ manifestRevisions: ManifestRevision[];
+ srpSalt: string;
+}
diff --git a/core/models/src/webapi/index.ts b/core/models/src/webapi/index.ts
index 43ea8d481..1b9161765 100644
--- a/core/models/src/webapi/index.ts
+++ b/core/models/src/webapi/index.ts
@@ -6,6 +6,7 @@ export * from './VaultResponse';
export * from './Vault';
export * from './VaultPostResponse';
export * from './StatusResponse';
+export * from './StatusResponseV2';
export * from './Login';
export * from './ValidateLogin';
export * from './MailboxBulk';