Skip to content

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

Refactor ints to enum strings and convert all enum typing to kebab case for consistency (#2469)

Leendert de Borst341ac15e4c09
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/settings/security/AuthLogsSettings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/settings/security/AuthLogsSettings.tsx
index 572a8f520..6f84117e9 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/settings/security/AuthLogsSettings.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/settings/security/AuthLogsSettings.tsx
@@ -1,5 +1,5 @@
import { toLocalDisplayFormat } from '@aliasvault/client/utilities/DateFormatter';
-import { AuthEventType } from '@aliasvault/models/webapi';
+import { authEventTypeName } from '@aliasvault/models/webapi';
import React, { useCallback, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -54,7 +54,7 @@ const AuthLogsSettings: React.FC = () => {
{logs.map((log) => (
<div key={log.id} className="p-4">
<div className="flex items-center justify-between gap-3">
- <p className="font-medium text-gray-900 dark:text-white break-words">{AuthEventType[log.eventType] ?? log.eventType}</p>
+ <p className="font-medium text-gray-900 dark:text-white break-words">{authEventTypeName(log.eventType)}</p>
<span className={`shrink-0 text-sm font-semibold ${log.isSuccess ? 'text-green-600 dark:text-green-400' : 'text-red-600 dark:text-red-400'}`}>
{log.isSuccess ? t('settings.securitySettings.authLogs.success') : t('settings.securitySettings.authLogs.failed')}
</span>
diff --git a/apps/browser-extension/tests/e2e/90-vault-upgrade.spec.ts b/apps/browser-extension/tests/e2e/90-vault-upgrade.spec.ts
index b9413e94e..0793139f4 100644
--- a/apps/browser-extension/tests/e2e/90-vault-upgrade.spec.ts
+++ b/apps/browser-extension/tests/e2e/90-vault-upgrade.spec.ts
@@ -225,8 +225,8 @@ test.describe.serial('90. Vault upgrades', () => {
// The migration push may still be on its way when the vault list shows.
await expect.poll(async () => {
const response = await fetch(`${apiUrl.replace(/\/$/, '')}/v2/Vault`, { headers: { Authorization: `Bearer ${accessToken}` } });
- return response.ok ? ((await response.json()) as { storageFormat?: number }).storageFormat : `HTTP ${response.status}`;
- }, { timeout: Timeouts.LONG }).toBe(1);
+ return response.ok ? ((await response.json()) as { storageFormat?: string }).storageFormat : `HTTP ${response.status}`;
+ }, { timeout: Timeouts.LONG }).toBe('manifest');
});
});
diff --git a/apps/browser-extension/tests/helpers/manifest-v2-api.ts b/apps/browser-extension/tests/helpers/manifest-v2-api.ts
index 9d1e4fdc2..016be4054 100644
--- a/apps/browser-extension/tests/helpers/manifest-v2-api.ts
+++ b/apps/browser-extension/tests/helpers/manifest-v2-api.ts
@@ -25,9 +25,7 @@ export type SnapshotManifest = {
/** The v2 GET /Vault snapshot (fields relevant to these tests). */
export type VaultSnapshot = {
- status: number;
- /** Server StorageFormat enum: 0 = legacy sqlite-blob, 1 = manifest-v1. */
- storageFormat: number;
+ storageFormat: 'sqlite-blob' | 'manifest';
manifests?: SnapshotManifest[];
/** The manifest owned by the caller's personal group; every other entry is a shared one. */
personalManifestId?: string | null;
@@ -70,7 +68,7 @@ type BucketWrite = {
/** The result of a POST /v2/Vault write. */
type VaultWriteResult = {
- status: number;
+ status: 'ok' | 'outdated';
manifestRevisions?: Array<{ manifestId: string; revision: number }>;
missingBlobHashes?: string[];
};
@@ -100,7 +98,7 @@ export async function getVaultSnapshot(apiBaseUrl: string, token: string): Promi
*/
export function requirePersonalManifest(snapshot: VaultSnapshot): SnapshotManifest {
const personal = (snapshot.manifests ?? []).find((m) => m.manifestId === snapshot.personalManifestId);
- if (snapshot.storageFormat !== 1 || !personal?.blob) {
+ if (snapshot.storageFormat !== 'manifest' || !personal?.blob) {
throw new Error(`Snapshot is not manifest-v1 yet (storageFormat=${snapshot.storageFormat}, manifests=${snapshot.manifests?.length ?? 0}).`);
}
return personal;
@@ -343,7 +341,7 @@ async function postVaultWrite(
}
const result = (await response.json()) as VaultWriteResult;
- if (result.status !== 0 || (result.missingBlobHashes?.length ?? 0) > 0) {
+ if (result.status !== 'ok' || (result.missingBlobHashes?.length ?? 0) > 0) {
throw new Error(`Vault write rejected: status=${result.status}, missingBlobs=${result.missingBlobHashes?.join(',') ?? 'none'}`);
}
return result;
diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/ManifestKeyType.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/ManifestKeyType.kt
index 4c302834a..ca7ccc467 100644
--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/ManifestKeyType.kt
+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/ManifestKeyType.kt
@@ -12,12 +12,12 @@ object ManifestKeyType {
/**
* The VEK is encrypted with the user's own Account Key, which their unlock chain produces.
*/
- const val ACCOUNT_KEY = "accountkey"
+ const val ACCOUNT_KEY = "account-key"
/**
* A grant: the VEK is encrypted to a public key of the user, so only its holder's private half can open it.
*/
- const val GRANT_KEY = "grantkey"
+ const val GRANT_KEY = "grant-key"
/**
* All known ManifestKeyType tokens.
diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/VaultDataBucketCategory.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/VaultDataBucketCategory.kt
index d2a035b02..cc8ccc8a1 100644
--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/VaultDataBucketCategory.kt
+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/models/VaultDataBucketCategory.kt
@@ -12,12 +12,12 @@ object VaultDataBucketCategory {
/**
* User client settings (sort order, autofill prefs, identity defaults, etc.).
*/
- const val SETTINGS = "Settings"
+ const val SETTINGS = "settings"
/**
* Per-item usage statistics (last used, use counts).
*/
- const val STATS = "Stats"
+ const val STATS = "stats"
/**
* All known data bucket categories.
diff --git a/apps/mobile-app/app/(tabs)/settings/security/auth-logs.tsx b/apps/mobile-app/app/(tabs)/settings/security/auth-logs.tsx
index 12200f023..21ad19f31 100644
--- a/apps/mobile-app/app/(tabs)/settings/security/auth-logs.tsx
+++ b/apps/mobile-app/app/(tabs)/settings/security/auth-logs.tsx
@@ -1,4 +1,4 @@
-import { AuthEventType } from '@aliasvault/models/webapi';
+import { authEventTypeName } from '@aliasvault/models/webapi';
import { useState, useEffect, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { StyleSheet, View, RefreshControl } from 'react-native';
@@ -153,7 +153,7 @@ export default function AuthLogsScreen() : React.ReactNode {
}
return logs.map((item) => {
- const eventType = AuthEventType[item.eventType];
+ const eventType = authEventTypeName(item.eventType);
return (
<View key={item.id} style={styles.logItem}>
diff --git a/apps/mobile-app/ios/VaultModels/ManifestKeyType.swift b/apps/mobile-app/ios/VaultModels/ManifestKeyType.swift
index 34848e4b4..67c372261 100644
--- a/apps/mobile-app/ios/VaultModels/ManifestKeyType.swift
+++ b/apps/mobile-app/ios/VaultModels/ManifestKeyType.swift
@@ -8,10 +8,10 @@ import Foundation
/// exactly one of these, and the token decides where the client looks for the key that opens the manifest.
public struct ManifestKeyType {
/// The VEK is encrypted with the user's own Account Key, which their unlock chain produces.
- public static let accountKey = "accountkey"
+ public static let accountKey = "account-key"
/// A grant: the VEK is encrypted to a public key of the user, so only its holder's private half can open it.
- public static let grantKey = "grantkey"
+ public static let grantKey = "grant-key"
/// All known ManifestKeyType tokens.
public static let all = [accountKey, grantKey]
diff --git a/apps/mobile-app/ios/VaultModels/VaultDataBucketCategory.swift b/apps/mobile-app/ios/VaultModels/VaultDataBucketCategory.swift
index 725a22e86..6ed6c91cd 100644
--- a/apps/mobile-app/ios/VaultModels/VaultDataBucketCategory.swift
+++ b/apps/mobile-app/ios/VaultModels/VaultDataBucketCategory.swift
@@ -8,10 +8,10 @@ import Foundation
/// The canonical list lives in the vault table registry (core/models).
public struct VaultDataBucketCategory {
/// User client settings (sort order, autofill prefs, identity defaults, etc.).
- public static let settings = "Settings"
+ public static let settings = "settings"
/// Per-item usage statistics (last used, use counts).
- public static let stats = "Stats"
+ public static let stats = "stats"
/// All known data bucket categories.
public static let all = [settings, stats]
diff --git a/apps/server/AliasVault.Api/Controllers/V2/FaviconController.cs b/apps/server/AliasVault.Api/Controllers/V2/FaviconController.cs
index c491a764a..c31202232 100644
--- a/apps/server/AliasVault.Api/Controllers/V2/FaviconController.cs
+++ b/apps/server/AliasVault.Api/Controllers/V2/FaviconController.cs
@@ -10,7 +10,7 @@ namespace AliasVault.Api.Controllers.V2;
using AliasServerDb;
using AliasVault.Api.Controllers.Abstracts;
using AliasVault.Api.Services;
-using AliasVault.Shared.Models.WebApi.V1.Favicon;
+using AliasVault.Shared.Models.WebApi.V2.Favicon;
using Asp.Versioning;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
diff --git a/apps/server/AliasVault.Api/Controllers/V2/GroupsController.cs b/apps/server/AliasVault.Api/Controllers/V2/GroupsController.cs
index d146b806e..98ce7631c 100644
--- a/apps/server/AliasVault.Api/Controllers/V2/GroupsController.cs
+++ b/apps/server/AliasVault.Api/Controllers/V2/GroupsController.cs
@@ -16,6 +16,7 @@ using AliasVault.Auth;
using AliasVault.Cryptography;
using AliasVault.Shared.Models.Enums;
using AliasVault.Shared.Models.WebApi;
+using AliasVault.Shared.Models.WebApi.V2;
using AliasVault.Shared.Models.WebApi.V2.Auth;
using AliasVault.Shared.Models.WebApi.V2.Groups;
using AliasVault.Shared.Server.Capabilities;
@@ -101,7 +102,7 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
response.Groups.Add(new GroupInfo
{
GroupId = membership.GroupId,
- Role = membership.Role.ToString(),
+ Role = KebabCaseEnumConverter.ToToken(membership.Role),
Manifests = [.. manifests
.Where(m => m.OwnerGroupId == membership.GroupId)
.Select(m => new { Manifest = m, Holders = grantHolders.GetValueOrDefault(m.ManifestId) ?? [] })
@@ -118,7 +119,7 @@ public class GroupsController(IAliasServerDbContextFactory dbContextFactory, Use
{
UserId = m.UserId,
Username = usernames.GetValueOrDefault(m.UserId, string.Empty),
- Role = m.Role.ToString(),
+ Role = KebabCaseEnumConverter.ToToken(m.Role),
PublicKeyId = canAdminister ? publicKeys.GetValueOrDefault(m.UserId)?.PublicKeyId : null,
PublicKey = canAdminister ? publicKeys.GetValueOrDefault(m.UserId)?.PublicKey : null,
PublicKeySignature = canAdminister ? publicKeys.GetValueOrDefault(m.UserId)?.PublicKeySignature : null,
diff --git a/apps/server/AliasVault.Api/Controllers/V2/Security/SecurityController.cs b/apps/server/AliasVault.Api/Controllers/V2/Security/SecurityController.cs
index 76d909133..252096cd8 100644
--- a/apps/server/AliasVault.Api/Controllers/V2/Security/SecurityController.cs
+++ b/apps/server/AliasVault.Api/Controllers/V2/Security/SecurityController.cs
@@ -10,7 +10,7 @@ namespace AliasVault.Api.Controllers.V2.Security;
using AliasServerDb;
using AliasVault.Api.Controllers.Abstracts;
using AliasVault.Shared.Models.Enums;
-using AliasVault.Shared.Models.WebApi.V1.Security;
+using AliasVault.Shared.Models.WebApi.V2.Security;
using Asp.Versioning;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
diff --git a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs b/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
index 3e3da8dc9..610fcb3f7 100644
--- a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
+++ b/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
@@ -102,7 +102,6 @@ public class VaultController(
return Ok(new GetResponse
{
- Status = VaultStatus.Ok,
StorageFormat = StorageFormat.SqliteBlob,
LegacyVaultBlob = legacy?.VaultBlob ?? string.Empty,
Version = legacy?.Version ?? string.Empty,
@@ -164,7 +163,6 @@ public class VaultController(
return Ok(new GetResponse
{
- Status = VaultStatus.Ok,
StorageFormat = StorageFormat.Manifest,
Manifests = manifests,
PersonalManifestId = latestManifests.First(m => m.OwnerGroupId == user.PersonalGroupId).ManifestId,
@@ -434,7 +432,7 @@ public class VaultController(
var staleRoutingOnly = routingStale.Where(id => resolved.All(r => r.Row.ManifestId != id));
return Ok(new VaultWriteResponse
{
- Status = VaultStatus.Outdated,
+ Status = VaultWriteStatus.Outdated,
ManifestRevisions = resolved.Select(r => new ManifestWriteResult { ManifestId = r.Write.ManifestId, Revision = r.Row.RevisionNumber })
.Concat(staleRoutingOnly.Select(id => new ManifestWriteResult { ManifestId = id, Revision = routingCurrentRevisions[id] }))
.ToList(),
@@ -481,7 +479,7 @@ public class VaultController(
await tx.RollbackAsync();
return Ok(new VaultWriteResponse
{
- Status = VaultStatus.Ok,
+ Status = VaultWriteStatus.Ok,
MissingBlobHashes = missing,
ManifestRevisions = resolved.Select(r => new ManifestWriteResult { ManifestId = r.Write.ManifestId, Revision = r.Row.RevisionNumber }).ToList(),
});
@@ -665,7 +663,7 @@ public class VaultController(
return Ok(new VaultWriteResponse
{
- Status = VaultStatus.Ok,
+ Status = VaultWriteStatus.Ok,
ManifestRevisions = manifestResults,
BucketRevisions = newBucketRevisions,
});
diff --git a/apps/server/AliasVault.Api/Helpers/ClientActionHelper.cs b/apps/server/AliasVault.Api/Helpers/ClientActionHelper.cs
index 0830f7bf5..9a2dc89f4 100644
--- a/apps/server/AliasVault.Api/Helpers/ClientActionHelper.cs
+++ b/apps/server/AliasVault.Api/Helpers/ClientActionHelper.cs
@@ -8,6 +8,7 @@
namespace AliasVault.Api.Helpers;
using AliasServerDb;
+using AliasVault.Shared.Models.WebApi.V2;
using AliasVault.Shared.Models.WebApi.V2.ClientActions;
using Microsoft.EntityFrameworkCore;
@@ -31,7 +32,7 @@ public static class ClientActionHelper
.OrderBy(a => a.CreatedAt)
.ToListAsync();
- return actions.ConvertAll(a => new PendingClientAction { Id = a.Id, Type = a.Type.ToString(), ManifestId = a.ManifestId, Payload = a.Payload });
+ return actions.ConvertAll(a => new PendingClientAction { Id = a.Id, Type = KebabCaseEnumConverter.ToToken(a.Type), ManifestId = a.ManifestId, Payload = a.Payload });
}
/// <summary>
diff --git a/apps/server/Shared/AliasVault.Shared/Models/Enums/ManifestKeyType.cs b/apps/server/Shared/AliasVault.Shared/Models/Enums/ManifestKeyType.cs
index d87147562..f19d9f943 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/Enums/ManifestKeyType.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/Enums/ManifestKeyType.cs
@@ -36,8 +36,8 @@ public static class ManifestKeyTypes
/// <returns>The token.</returns>
public static string ToToken(ManifestKeyType type) => type switch
{
- ManifestKeyType.AccountKey => "accountkey",
- ManifestKeyType.GrantKey => "grantkey",
+ ManifestKeyType.AccountKey => "account-key",
+ ManifestKeyType.GrantKey => "grant-key",
_ => throw new ArgumentOutOfRangeException(nameof(type), type, "Unknown ManifestKeyType."),
};
@@ -51,10 +51,10 @@ public static class ManifestKeyTypes
{
switch (token)
{
- case "accountkey":
+ case "account-key":
type = ManifestKeyType.AccountKey;
return true;
- case "grantkey":
+ case "grant-key":
type = ManifestKeyType.GrantKey;
return true;
default:
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Vault/VaultGetResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Vault/VaultGetResponse.cs
index 6965cad40..d5da8cdde 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Vault/VaultGetResponse.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Vault/VaultGetResponse.cs
@@ -7,8 +7,6 @@
namespace AliasVault.Shared.Models.WebApi.V1.Vault;
-using AliasVault.Shared.Models.Enums;
-
/// <summary>
/// Vault get response model.
/// </summary>
diff --git a/apps/server/Shared/AliasVault.Shared/Models/Enums/VaultStatus.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Vault/VaultStatus.cs
similarity index 77%
rename from apps/server/Shared/AliasVault.Shared/Models/Enums/VaultStatus.cs
rename to apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Vault/VaultStatus.cs
index 1f6f30f91..281910387 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/Enums/VaultStatus.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Vault/VaultStatus.cs
@@ -5,10 +5,11 @@
// </copyright>
//-----------------------------------------------------------------------
-namespace AliasVault.Shared.Models.Enums;
+namespace AliasVault.Shared.Models.WebApi.V1.Vault;
/// <summary>
-/// Enum representing the status of a vault during get/update operations.
+/// LEGACY (v1 API only): status of a vault get/update, serialized as an int. V2 uses VaultWriteStatus.
+/// Remove together with the v1 vault endpoints once v1 API login is no longer supported.
/// </summary>
public enum VaultStatus
{
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Vault/VaultUpdateResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Vault/VaultUpdateResponse.cs
index cdd4537e8..0b3b2b08f 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Vault/VaultUpdateResponse.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V1/Vault/VaultUpdateResponse.cs
@@ -7,8 +7,6 @@
namespace AliasVault.Shared.Models.WebApi.V1.Vault;
-using AliasVault.Shared.Models.Enums;
-
/// <summary>
/// Vault update response model.
/// </summary>
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginStatus.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginStatus.cs
index bcfc8efe3..8579520d5 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginStatus.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Auth/MobileLoginStatus.cs
@@ -12,7 +12,7 @@ using System.Text.Json.Serialization;
/// <summary>
/// State of a mobile login request as seen by the polling client.
/// </summary>
-[JsonConverter(typeof(JsonStringEnumConverter))]
+[JsonConverter(typeof(KebabCaseEnumConverter))]
public enum MobileLoginStatus
{
/// <summary>
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractBatchRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractBatchRequest.cs
new file mode 100644
index 000000000..6abe24b6e
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractBatchRequest.cs
@@ -0,0 +1,22 @@
+//-----------------------------------------------------------------------
+// <copyright file="FaviconExtractBatchRequest.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.Favicon;
+
+using System.Collections.Generic;
+
+/// <summary>
+/// Request payload for batch favicon extraction.
+/// </summary>
+public class FaviconExtractBatchRequest
+{
+ /// <summary>
+ /// Gets or sets the URLs to extract favicons for. The server caps the number of URLs
+ /// it processes per request; callers should chunk larger inputs into multiple requests.
+ /// </summary>
+ public List<string> Urls { get; set; } = new();
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractBatchResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractBatchResponse.cs
new file mode 100644
index 000000000..093c3503d
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractBatchResponse.cs
@@ -0,0 +1,22 @@
+//-----------------------------------------------------------------------
+// <copyright file="FaviconExtractBatchResponse.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.Favicon;
+
+using System.Collections.Generic;
+
+/// <summary>
+/// Response payload for batch favicon extraction. Each result lines up with the URL at the
+/// same index in the request, with a null Image when extraction failed for that URL.
+/// </summary>
+public class FaviconExtractBatchResponse
+{
+ /// <summary>
+ /// Gets or sets the per-URL extraction results.
+ /// </summary>
+ public List<FaviconExtractBatchResult> Results { get; set; } = new();
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractBatchResult.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractBatchResult.cs
new file mode 100644
index 000000000..857515a4d
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractBatchResult.cs
@@ -0,0 +1,24 @@
+//-----------------------------------------------------------------------
+// <copyright file="FaviconExtractBatchResult.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.Favicon;
+
+/// <summary>
+/// Per-URL favicon extraction result.
+/// </summary>
+public class FaviconExtractBatchResult
+{
+ /// <summary>
+ /// Gets or sets the URL the favicon was requested for (echoed back so the client can correlate).
+ /// </summary>
+ public string Url { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the favicon image bytes, or null if extraction failed.
+ /// </summary>
+ public byte[]? Image { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractModel.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractModel.cs
new file mode 100644
index 000000000..9c956e7bd
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Favicon/FaviconExtractModel.cs
@@ -0,0 +1,19 @@
+//-----------------------------------------------------------------------
+// <copyright file="FaviconExtractModel.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.Favicon;
+
+/// <summary>
+/// FaviconExtractModel model.
+/// </summary>
+public class FaviconExtractModel
+{
+ /// <summary>
+ /// Gets or sets favicon image as byte array.
+ /// </summary>
+ public byte[]? Image { get; set; } = null!;
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/KebabCaseEnumConverter.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/KebabCaseEnumConverter.cs
new file mode 100644
index 000000000..44ee8ab28
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/KebabCaseEnumConverter.cs
@@ -0,0 +1,32 @@
+//-----------------------------------------------------------------------
+// <copyright file="KebabCaseEnumConverter.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;
+
+using System.Text.Json;
+using System.Text.Json.Serialization;
+
+/// <summary>
+/// Serializes a V2 enum as its kebab-case name and rejects integers.
+/// </summary>
+public sealed class KebabCaseEnumConverter : JsonStringEnumConverter
+{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="KebabCaseEnumConverter"/> class.
+ /// </summary>
+ public KebabCaseEnumConverter()
+ : base(JsonNamingPolicy.KebabCaseLower, allowIntegerValues: false)
+ {
+ }
+
+ /// <summary>
+ /// The kebab-case token of an enum value.
+ /// </summary>
+ /// <param name="value">The enum value.</param>
+ /// <returns>The kebab-case token.</returns>
+ public static string ToToken(Enum value) => JsonNamingPolicy.KebabCaseLower.ConvertName(value.ToString());
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Security/AuthLogModel.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Security/AuthLogModel.cs
new file mode 100644
index 000000000..fd0939868
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Security/AuthLogModel.cs
@@ -0,0 +1,53 @@
+//-----------------------------------------------------------------------
+// <copyright file="AuthLogModel.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.Security;
+
+using System.Text.Json.Serialization;
+using AliasVault.Shared.Models.Enums;
+
+/// <summary>
+/// Auth Log model.
+/// </summary>
+public class AuthLogModel
+{
+ /// <summary>
+ /// Gets or sets the primary key for the auth log entry.
+ /// </summary>
+ public int Id { get; set; }
+
+ /// <summary>
+ /// Gets or sets the timestamp of the auth log entry.
+ /// </summary>
+ public DateTime Timestamp { get; set; }
+
+ /// <summary>
+ /// Gets or sets the type of authentication event.
+ /// </summary>
+ [JsonConverter(typeof(KebabCaseEnumConverter))]
+ public AuthEventType EventType { get; set; }
+
+ /// <summary>
+ /// Gets or sets the username associated with the auth log entry.
+ /// </summary>
+ public string Username { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the IP address from which the authentication attempt was made.
+ /// </summary>
+ public string IpAddress { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the client application name and version.
+ /// </summary>
+ public string Client { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the authentication attempt was successful.
+ /// </summary>
+ public bool IsSuccess { get; set; }
+}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Security/RefreshTokenModel.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Security/RefreshTokenModel.cs
new file mode 100644
index 000000000..1ec2061a4
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Security/RefreshTokenModel.cs
@@ -0,0 +1,34 @@
+//-----------------------------------------------------------------------
+// <copyright file="RefreshTokenModel.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.Security;
+
+/// <summary>
+/// RefreshToken (user session) model.
+/// </summary>
+public class RefreshTokenModel
+{
+ /// <summary>
+ /// Gets or sets the unique identifier for the refresh token.
+ /// </summary>
+ public Guid Id { get; set; }
+
+ /// <summary>
+ /// Gets or sets the device identifier associated with the refresh token.
+ /// </summary>
+ public string DeviceIdentifier { get; set; } = null!;
+
+ /// <summary>
+ /// Gets or sets the expiration date of the refresh token.
+ /// </summary>
+ public DateTime ExpireDate { get; set; }
+
+ /// <summary>
+ /// Gets or sets the creation date of the refresh token.
+ /// </summary>
+ public DateTime CreatedAt { 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 64ca479a3..43b668315 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
@@ -7,16 +7,11 @@
namespace AliasVault.Shared.Models.WebApi.V2.Vault;
-using AliasVault.Shared.Models.Enums;
-
/// <summary>
/// Atomic snapshot returned by GET /v2/Vault.
/// </summary>
public class GetResponse
{
- /// <summary>Gets or sets the operation status.</summary>
- public required VaultStatus Status { get; set; }
-
/// <summary>
/// Gets or sets the storage format of the returned vault.
/// </summary>
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/StorageFormat.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/StorageFormat.cs
index 132157dea..97a23442d 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/StorageFormat.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/StorageFormat.cs
@@ -7,9 +7,12 @@
namespace AliasVault.Shared.Models.WebApi.V2.Vault;
+using System.Text.Json.Serialization;
+
/// <summary>
/// Storage format the server has recorded for the user's vault.
/// </summary>
+[JsonConverter(typeof(KebabCaseEnumConverter))]
public enum StorageFormat
{
/// <summary>Legacy v1 (full encrypted SQLite blob).</summary>
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultDataBucketCategory.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultDataBucketCategory.cs
index b7e3dbd53..036f73cdf 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultDataBucketCategory.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultDataBucketCategory.cs
@@ -13,7 +13,7 @@ using System.Text.Json.Serialization;
/// Adding a new kind requires a server-side rollout first, because the server reasons about kinds for
/// per-kind retention policies. The canonical list lives in the vault table registry (core/models).
/// </summary>
-[JsonConverter(typeof(JsonStringEnumConverter))]
+[JsonConverter(typeof(KebabCaseEnumConverter))]
public enum VaultDataBucketCategory
{
/// <summary>User client settings (sort order, autofill prefs, identity defaults, etc.).</summary>
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultWriteResponse.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultWriteResponse.cs
index 3f900dc41..00c0f0c08 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultWriteResponse.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultWriteResponse.cs
@@ -7,15 +7,13 @@
namespace AliasVault.Shared.Models.WebApi.V2.Vault;
-using AliasVault.Shared.Models.Enums;
-
/// <summary>
/// Response for POST /v2/Vault.
/// </summary>
public class VaultWriteResponse
{
/// <summary>Gets or sets the overall status.</summary>
- public required VaultStatus Status { get; set; }
+ public required VaultWriteStatus Status { get; set; }
/// <summary>Gets or sets the per-manifest revisions.</summary>
public List<ManifestWriteResult> ManifestRevisions { get; set; } = [];
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultWriteStatus.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultWriteStatus.cs
new file mode 100644
index 000000000..a068e0959
--- /dev/null
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultWriteStatus.cs
@@ -0,0 +1,23 @@
+//-----------------------------------------------------------------------
+// <copyright file="VaultWriteStatus.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;
+
+using System.Text.Json.Serialization;
+
+/// <summary>
+/// Outcome of a POST /v2/Vault write.
+/// </summary>
+[JsonConverter(typeof(KebabCaseEnumConverter))]
+public enum VaultWriteStatus
+{
+ /// <summary>The write was accepted.</summary>
+ Ok,
+
+ /// <summary>A manifest, bucket or email routing revision is stale; the client pulls, merges and retries.</summary>
+ Outdated,
+}
diff --git a/apps/web/src/components/settings/security/RecentAuthLogsSection.tsx b/apps/web/src/components/settings/security/RecentAuthLogsSection.tsx
index 0cfe4fde7..7d62cc743 100644
--- a/apps/web/src/components/settings/security/RecentAuthLogsSection.tsx
+++ b/apps/web/src/components/settings/security/RecentAuthLogsSection.tsx
@@ -1,4 +1,4 @@
-import { AuthEventType } from '@aliasvault/models/webapi';
+import { authEventTypeName } from '@aliasvault/models/webapi';
import React, { useCallback, useImperativeHandle, useState, forwardRef } from 'react';
import { useTranslation } from 'react-i18next';
@@ -53,7 +53,7 @@ const RecentAuthLogsSection = forwardRef<SectionHandle>((_, ref) => {
{logs.map(log => (
<tr key={log.id} className="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<td className="px-6 py-4">{formatDateTime(log.timestamp)}</td>
- <td className="px-6 py-4">{AuthEventType[log.eventType] ?? log.eventType}</td>
+ <td className="px-6 py-4">{authEventTypeName(log.eventType)}</td>
<td className="px-6 py-4">{log.client}</td>
<td className="px-6 py-4">{log.ipAddress}</td>
<td className="px-4 py-4"><StatusPill enabled={log.isSuccess} textTrue={t('settings.securitySettings.authLogs.success')} textFalse={t('settings.securitySettings.authLogs.failed')} /></td>
diff --git a/apps/web/tests/e2e/90-vault-upgrade.spec.ts b/apps/web/tests/e2e/90-vault-upgrade.spec.ts
index 986ee5cf8..89a462480 100644
--- a/apps/web/tests/e2e/90-vault-upgrade.spec.ts
+++ b/apps/web/tests/e2e/90-vault-upgrade.spec.ts
@@ -218,7 +218,7 @@ test.describe('90. Vault upgrades', () => {
await test.step('the server holds the vault in the manifest storage format', async () => {
const response = await fetch(`${apiUrl}/v2/Vault`, { headers: { Authorization: `Bearer ${testUser.token}` } });
expect(response.ok).toBe(true);
- expect(((await response.json()) as { storageFormat?: number }).storageFormat).toBe(1);
+ expect(((await response.json()) as { storageFormat?: string }).storageFormat).toBe('manifest');
});
await test.step('the upgraded vault opens again after a reload', async () => {
diff --git a/core/client/src/auth/MobileLoginService.ts b/core/client/src/auth/MobileLoginService.ts
index 3841f9714..a542e2c8c 100644
--- a/core/client/src/auth/MobileLoginService.ts
+++ b/core/client/src/auth/MobileLoginService.ts
@@ -142,13 +142,13 @@ export class MobileLoginService {
const data = await response.json() as MobileLoginPollResponse;
- if (data.status === 'Declined') {
+ if (data.status === 'declined') {
this.cleanup();
onError(MobileLoginErrorCode.DECLINED);
return;
}
- if (data.status === 'Approved' && data.encryptedSymmetricKey && data.encryptedPayload && data.encryptedAccountKey) {
+ if (data.status === 'approved' && data.encryptedSymmetricKey && data.encryptedPayload && data.encryptedAccountKey) {
// Capture the key locally.
const privateKey = this.privateKey!;
this.cleanup();
diff --git a/core/client/src/sharing/FamilySharingView.ts b/core/client/src/sharing/FamilySharingView.ts
index 49637b743..fb1123b35 100644
--- a/core/client/src/sharing/FamilySharingView.ts
+++ b/core/client/src/sharing/FamilySharingView.ts
@@ -110,7 +110,7 @@ export type MemberAccess = {
* @param group - the group as served by the API.
*/
export function canAdministerGroup(group: Pick<GroupInfo, 'role'>): boolean {
- return group.role === 'Owner' || group.role === 'Admin';
+ return group.role === 'owner' || group.role === 'admin';
}
/**
@@ -165,8 +165,8 @@ export function describeMemberAccess(group: GroupInfo, manifest: SharedManifestI
*/
export function roleLabel(member: Pick<GroupMemberInfo, 'role'>): string {
switch (member.role) {
- case 'Owner': return familySharingText.owner;
- case 'Admin': return familySharingText.admin;
+ case 'owner': return familySharingText.owner;
+ case 'admin': return familySharingText.admin;
default: return familySharingText.member;
}
}
diff --git a/core/models/scripts/generate-key-vocabulary.cjs b/core/models/scripts/generate-key-vocabulary.cjs
index 700f5d348..10b6aed1b 100644
--- a/core/models/scripts/generate-key-vocabulary.cjs
+++ b/core/models/scripts/generate-key-vocabulary.cjs
@@ -67,13 +67,13 @@ const VOCABULARIES = [
members: [
{
name: 'AccountKey',
- token: 'accountkey',
+ token: 'account-key',
summary: 'The VEK is encrypted with the user\'s own Account Key, which their unlock chain produces.',
flags: { VekTravelsWithManifest: false },
},
{
name: 'GrantKey',
- token: 'grantkey',
+ token: 'grant-key',
summary: 'A grant: the VEK is encrypted to a public key of the user, so only its holder\'s private half can open it.',
flags: { VekTravelsWithManifest: true },
},
diff --git a/core/models/scripts/lib/vault-table-registry-emit.cjs b/core/models/scripts/lib/vault-table-registry-emit.cjs
index a9d00331d..b900ee246 100644
--- a/core/models/scripts/lib/vault-table-registry-emit.cjs
+++ b/core/models/scripts/lib/vault-table-registry-emit.cjs
@@ -68,6 +68,11 @@ function validateRegistry(registry) {
if (JSON.stringify(declaredCategories) !== JSON.stringify(registryCategories)) {
throw new Error(`VaultDataBucketCategory (${declaredCategories}) and VAULT_BUCKET_CATEGORIES (${registryCategories}) have drifted apart.`);
}
+ for (const category of registry.VAULT_BUCKET_CATEGORIES) {
+ if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(category)) {
+ throw new Error(`Bucket category '${category}' is not kebab-case.`);
+ }
+ }
}
/** Render one VAULT_TABLES entry as a Rust TableConfig builder chain. */
@@ -262,13 +267,19 @@ function describeBucketCategory(registry, category) {
return (registry.VaultDataBucketCategoryDescriptions || {})[category] || BUCKET_DEFAULT_DESCRIPTION;
}
-/** Convert a PascalCase category to camelCase (Swift). */
-function toCamelCase(name) {
- return name.charAt(0).toLowerCase() + name.slice(1);
+/** Convert a category to PascalCase (C#). */
+function toPascalCase(token) {
+ return token.split('-').map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('');
+}
+
+/** Convert a category to camelCase (Swift). */
+function toCamelCase(token) {
+ const pascal = toPascalCase(token);
+ return pascal.charAt(0).toLowerCase() + pascal.slice(1);
}
/**
- * Emit the C# VaultDataBucketCategory enum. Serialized as its string name (JsonStringEnumConverter)
+ * Emit the C# VaultDataBucketCategory enum. Serialized as its string name (KebabCaseEnumConverter)
* and stored as a string in the database, so the numeric backing is cosmetic; ordinals follow
* declaration order.
*/
@@ -276,7 +287,7 @@ function emitBucketCategoryCSharp(registry) {
validateRegistry(registry);
const members = registry.VAULT_BUCKET_CATEGORIES
.map((category, index) => ` /// <summary>${describeBucketCategory(registry, category)}</summary>
- ${category} = ${index},`)
+ ${toPascalCase(category)} = ${index},`)
.join('\n\n');
return `// <auto-generated />
@@ -294,7 +305,7 @@ using System.Text.Json.Serialization;
/// Adding a new kind requires a server-side rollout first, because the server reasons about kinds for
/// per-kind retention policies. The canonical list lives in the vault table registry (core/models).
/// </summary>
-[JsonConverter(typeof(JsonStringEnumConverter))]
+[JsonConverter(typeof(KebabCaseEnumConverter))]
public enum VaultDataBucketCategory
{
${members}
@@ -336,7 +347,7 @@ function emitBucketCategoryKotlin(registry) {
.map((category) => ` /**
* ${describeBucketCategory(registry, category)}
*/
- const val ${toScreamingSnakeCase(category)} = "${category}"`)
+ const val ${toScreamingSnakeCase(toPascalCase(category))} = "${category}"`)
.join('\n\n');
return `// <auto-generated />
@@ -355,7 +366,7 @@ ${members}
/**
* All known data bucket categories.
*/
- val all = listOf(${categories.map(toScreamingSnakeCase).join(', ')})
+ val all = listOf(${categories.map((c) => toScreamingSnakeCase(toPascalCase(c))).join(', ')})
}
`;
}
diff --git a/core/models/src/vault/VaultDataBucketCategory.ts b/core/models/src/vault/VaultDataBucketCategory.ts
index f69480ee9..159ae80db 100644
--- a/core/models/src/vault/VaultDataBucketCategory.ts
+++ b/core/models/src/vault/VaultDataBucketCategory.ts
@@ -7,12 +7,12 @@ export const VaultDataBucketCategory = {
/**
* User client settings (sort order, autofill prefs, identity defaults, etc.).
*/
- Settings: 'Settings',
+ Settings: 'settings',
/**
* Per-item usage statistics (last used, use counts).
*/
- Stats: 'Stats',
+ Stats: 'stats',
} as const;
/**
@@ -24,6 +24,6 @@ export type VaultDataBucketCategoryValue = typeof VaultDataBucketCategory[keyof
* Human-readable description per category, emitted into the generated platform variants' doc comments.
*/
export const VaultDataBucketCategoryDescriptions: Record<VaultDataBucketCategoryValue, string> = {
- Settings: 'User client settings (sort order, autofill prefs, identity defaults, etc.).',
- Stats: 'Per-item usage statistics (last used, use counts).',
+ settings: 'User client settings (sort order, autofill prefs, identity defaults, etc.).',
+ stats: 'Per-item usage statistics (last used, use counts).',
};
diff --git a/core/models/src/vault/VaultTableRegistry.ts b/core/models/src/vault/VaultTableRegistry.ts
index ab970251e..2e25cdf92 100644
--- a/core/models/src/vault/VaultTableRegistry.ts
+++ b/core/models/src/vault/VaultTableRegistry.ts
@@ -64,7 +64,7 @@ export const VAULT_TABLES: VaultTableDefinition[] = [
* upsert and two devices never create competing rows. Listed after Items so a merge inserts the
* item first.
*/
- { Name: 'ItemStats', ManifestScoped: true, PrimaryKey: ['Id'], ItemChild: true, BucketCategory: 'Stats' },
+ { Name: 'ItemStats', ManifestScoped: true, PrimaryKey: ['Id'], ItemChild: true, BucketCategory: 'stats' },
/*
* FieldValues: a field value matches on the field it belongs to (FieldKey for system fields,
* FieldDefinitionId for custom ones; exactly one is set), so independently created rows of the
@@ -133,7 +133,7 @@ export const VAULT_TABLES: VaultTableDefinition[] = [
ManifestScoped: true,
PrimaryKey: ['Key'],
ItemChild: false,
- BucketCategory: 'Settings',
+ BucketCategory: 'settings',
},
];
@@ -169,7 +169,7 @@ export const VAULT_COLUMN_NAMES: string[] = [
* Data-bucket categories in declaration order. This order, not the table order, decides the order
* buckets are emitted in; every category must be used by at least one VAULT_TABLES entry.
*/
-export const VAULT_BUCKET_CATEGORIES: string[] = ['Settings', 'Stats'];
+export const VAULT_BUCKET_CATEGORIES: string[] = ['settings', 'stats'];
/**
* Tables never serialized into the server-stored manifest: internal SQLite, platform, or EF
diff --git a/core/models/src/webapi/AuthEventType.ts b/core/models/src/webapi/AuthEventType.ts
index b535bd531..d39f96c64 100644
--- a/core/models/src/webapi/AuthEventType.ts
+++ b/core/models/src/webapi/AuthEventType.ts
@@ -5,65 +5,73 @@ export enum AuthEventType {
/**
* Represents a standard login attempt.
*/
- Login = 1,
+ Login = 'login',
/**
* Represents a two-factor authentication attempt.
*/
- TwoFactorAuthentication = 2,
+ TwoFactorAuthentication = 'two-factor-authentication',
/**
* Represents a user logout event.
*/
- Logout = 3,
+ Logout = 'logout',
/**
* Represents a mobile login attempt (login via QR code from mobile app).
*/
- MobileLogin = 4,
+ MobileLogin = 'mobile-login',
/**
* Represents JWT access token refresh event issued by client to API.
*/
- TokenRefresh = 10,
+ TokenRefresh = 'token-refresh',
/**
* Represents a password reset event.
*/
- PasswordReset = 20,
+ PasswordReset = 'password-reset',
/**
* Represents a password change event.
*/
- PasswordChange = 21,
+ PasswordChange = 'password-change',
/**
* Represents enabling two-factor authentication in settings.
*/
- TwoFactorAuthEnable = 22,
+ TwoFactorAuthEnable = 'two-factor-auth-enable',
/**
* Represents disabling two-factor authentication in settings.
*/
- TwoFactorAuthDisable = 23,
+ TwoFactorAuthDisable = 'two-factor-auth-disable',
/**
* Represents a user registration event.
*/
- Register = 30,
+ Register = 'register',
/**
* Represents creation of a shared manifest.
*/
- SharedVaultCreation = 50,
+ SharedVaultCreation = 'shared-vault-creation',
/**
* Represents deletion of a shared manifest, confirmed with the master password.
*/
- SharedVaultDeletion = 51,
+ SharedVaultDeletion = 'shared-vault-deletion',
/**
* Represents a user account deletion event.
*/
- AccountDeletion = 99,
-}
\ No newline at end of file
+ AccountDeletion = 'account-deletion',
+}
+
+/**
+ * The enum member name of an event type, or the value itself when this build does not know it.
+ * @param eventType - the event type as sent by the server.
+ */
+export function authEventTypeName(eventType: string): string {
+ return Object.keys(AuthEventType).find((key) => AuthEventType[key as keyof typeof AuthEventType] === eventType) ?? eventType;
+}
diff --git a/core/models/src/webapi/AuthLog.ts b/core/models/src/webapi/AuthLog.ts
index d12aa9249..e1347c356 100644
--- a/core/models/src/webapi/AuthLog.ts
+++ b/core/models/src/webapi/AuthLog.ts
@@ -15,7 +15,7 @@ export type AuthLogModel = {
/**
* Gets or sets the type of authentication event.
*/
- eventType: number;
+ eventType: string;
/**
* Gets or sets the username associated with the auth log entry.
diff --git a/core/models/src/webapi/Groups.ts b/core/models/src/webapi/Groups.ts
index 6137c6696..38f51613f 100644
--- a/core/models/src/webapi/Groups.ts
+++ b/core/models/src/webapi/Groups.ts
@@ -7,7 +7,7 @@ import type { VaultKeyAlgorithmValue } from './VaultKeyAlgorithm';
/**
* A member's role in a group.
*/
-export type GroupRole = 'Owner' | 'Admin' | 'Member';
+export type GroupRole = 'owner' | 'admin' | 'member';
/**
* One member of a group.
diff --git a/core/models/src/webapi/ManifestKeyType.ts b/core/models/src/webapi/ManifestKeyType.ts
index b777d6446..53428a2a8 100644
--- a/core/models/src/webapi/ManifestKeyType.ts
+++ b/core/models/src/webapi/ManifestKeyType.ts
@@ -12,12 +12,12 @@ export const ManifestKeyType = {
/**
* The VEK is encrypted with the user's own Account Key, which their unlock chain produces.
*/
- AccountKey: 'accountkey',
+ AccountKey: 'account-key',
/**
* A grant: the VEK is encrypted to a public key of the user, so only its holder's private half can open it.
*/
- GrantKey: 'grantkey',
+ GrantKey: 'grant-key',
} as const;
/**
diff --git a/core/models/src/webapi/MobileLogin.ts b/core/models/src/webapi/MobileLogin.ts
index 61af849dd..440f1b1d6 100644
--- a/core/models/src/webapi/MobileLogin.ts
+++ b/core/models/src/webapi/MobileLogin.ts
@@ -24,7 +24,7 @@ export type MobileLoginPollRequest = {
/**
* State of a mobile login request as seen by the polling client.
*/
-export type MobileLoginStatus = 'Pending' | 'Approved' | 'Declined';
+export type MobileLoginStatus = 'pending' | 'approved' | 'declined';
/**
* Mobile login poll response type. The encrypted fields are only set when the status is Approved.
diff --git a/core/rust/src/crypto/aad.rs b/core/rust/src/crypto/aad.rs
index 0f1a113d4..71c24d574 100644
--- a/core/rust/src/crypto/aad.rs
+++ b/core/rust/src/crypto/aad.rs
@@ -63,7 +63,7 @@ mod tests {
#[test]
fn labels_are_stable_and_case_insensitive_on_ids() {
assert_eq!(manifest("0A1B2C3D-0000-0000-0000-000000000001"), b"aliasvault/v1/manifest/0a1b2c3d-0000-0000-0000-000000000001".to_vec());
- assert_eq!(bucket("0a1b2c3d-0000-0000-0000-000000000001", "Logos"), b"aliasvault/v1/bucket/0a1b2c3d-0000-0000-0000-000000000001/Logos".to_vec());
+ assert_eq!(bucket("0a1b2c3d-0000-0000-0000-000000000001", "settings"), b"aliasvault/v1/bucket/0a1b2c3d-0000-0000-0000-000000000001/settings".to_vec());
assert_eq!(blob_data("ID", "ABCD"), b"aliasvault/v1/blob/id/abcd".to_vec());
assert_eq!(blob_key("ID", "ABCD"), b"aliasvault/v1/blob-key/id/abcd".to_vec());
assert_eq!(manifest_name("ID"), b"aliasvault/v1/manifest-name/id".to_vec());
diff --git a/core/rust/src/vault_codec/sharing_tests.rs b/core/rust/src/vault_codec/sharing_tests.rs
index ce396e357..a8c92fdec 100644
--- a/core/rust/src/vault_codec/sharing_tests.rs
+++ b/core/rust/src/vault_codec/sharing_tests.rs
@@ -545,7 +545,7 @@ fn split_keeps_bucketed_and_foreign_key_tables_out_of_shared_manifests() {
* here, since the single Settings row belongs to the personal manifest. Leaving a manifest's bucket
* out would read as "unchanged" rather than "emptied", so its last row could never be deleted.
*/
- let settings: Vec<&DataBucket> = out.data_buckets.iter().filter(|b| b.category == "Settings").collect();
+ let settings: Vec<&DataBucket> = out.data_buckets.iter().filter(|b| b.category == "settings").collect();
assert_eq!(settings.iter().map(|b| b.manifest_id.as_str()).collect::<Vec<&str>>(), vec!["m-f-shared", PERSONAL_M]);
assert_eq!(settings[0].tables["Settings"].len(), 0, "the shared manifest holds no settings of its own, and says so");
assert_eq!(settings[1].tables["Settings"].len(), 1);
@@ -567,7 +567,7 @@ fn split_routes_bucket_rows_to_the_manifest_that_owns_them() {
let out = canonicalize_from_sqlite(input_with_shares(tables, vec![spec("f-shared")])).unwrap();
let bucket_of = |manifest_id: &str| -> Option<&DataBucket> {
- out.data_buckets.iter().find(|b| b.category == "Settings" && b.manifest_id == manifest_id)
+ out.data_buckets.iter().find(|b| b.category == "settings" && b.manifest_id == manifest_id)
};
let keys = |b: &DataBucket| -> Vec<String> {
let mut out: Vec<String> = b.tables["Settings"].iter().filter_map(|r| r.get("Key").and_then(|v| v.as_str()).map(str::to_string)).collect();
@@ -593,7 +593,7 @@ fn combine_stamps_bucket_rows_with_the_manifest_that_delivered_them() {
* so its rows claim that manifest. A bucket whose rows name someone else cannot move them there.
*/
let out = canonicalize_owner();
- let mut evil = out.data_buckets.iter().find(|b| b.category == "Settings" && b.manifest_id == PERSONAL_M).expect("personal settings bucket").clone();
+ let mut evil = out.data_buckets.iter().find(|b| b.category == "settings" && b.manifest_id == PERSONAL_M).expect("personal settings bucket").clone();
evil.manifest_id = "m-f-shared".to_string();
let re = materialize_as_sqlite(materialize_input(out.first().manifest.clone(), out.rest().iter().map(|s| s.manifest.clone()).collect(), vec![evil])).unwrap();
@@ -606,7 +606,7 @@ fn combine_stamps_bucket_rows_with_the_manifest_that_delivered_them() {
fn combine_keeps_two_manifests_settings_side_by_side() {
// Two manifests holding the same setting key are two rows: (ManifestId, Key) keeps them apart.
let out = canonicalize_owner();
- let personal_bucket = out.data_buckets.iter().find(|b| b.category == "Settings" && b.manifest_id == PERSONAL_M).expect("personal settings bucket").clone();
+ let personal_bucket = out.data_buckets.iter().find(|b| b.category == "settings" && b.manifest_id == PERSONAL_M).expect("personal settings bucket").clone();
let mut shared_bucket = personal_bucket.clone();
shared_bucket.manifest_id = "m-f-shared".to_string();
@@ -635,7 +635,7 @@ fn extract_buckets_splits_a_category_the_way_canonicalize_does() {
let settings = |rows: Vec<CodecRecord>| -> HashMap<String, Vec<CodecRecord>> { [("Settings".to_string(), rows)].into_iter().collect() };
let buckets = extract_buckets(
- "Settings".to_string(),
+ "settings".to_string(),
vec![PERSONAL_M.to_string(), "m-f-shared".to_string()],
settings(vec![
row(&[("Key", json!("sort")), ("Value", json!("name")), ("ManifestId", json!("M-F-SHARED"))]),
@@ -659,11 +659,11 @@ fn extract_buckets_splits_a_category_the_way_canonicalize_does() {
assert_eq!(personal.tables["Settings"][0]["Key"], json!("theme"));
// A manifest holding nothing still gets its bucket, with the category's tables declared empty.
- let empty = extract_buckets("Settings".to_string(), vec![PERSONAL_M.to_string()], settings(vec![])).unwrap();
+ let empty = extract_buckets("settings".to_string(), vec![PERSONAL_M.to_string()], settings(vec![])).unwrap();
assert_eq!(empty.len(), 1);
assert_eq!(empty[0].tables["Settings"].len(), 0, "an emptied table is declared, so the delete reaches the server");
- let unstamped = extract_buckets("Settings".to_string(), vec![PERSONAL_M.to_string()], settings(vec![row(&[("Key", json!("k")), ("Value", json!("v"))])]))
+ let unstamped = extract_buckets("settings".to_string(), vec![PERSONAL_M.to_string()], settings(vec![row(&[("Key", json!("k")), ("Value", json!("v"))])]))
.unwrap_err()
.to_string();
assert!(unstamped.contains("name no manifest"), "the error says what is wrong: {unstamped}");
@@ -704,7 +704,7 @@ fn split_refuses_unregistered_rows_that_name_no_manifest() {
#[test]
fn validate_rejects_an_unaddressed_or_cross_stamped_bucket() {
let out = canonicalize_owner();
- let bucket = out.data_buckets.iter().find(|b| b.category == "Settings" && b.manifest_id == PERSONAL_M).expect("personal settings bucket");
+ let bucket = out.data_buckets.iter().find(|b| b.category == "settings" && b.manifest_id == PERSONAL_M).expect("personal settings bucket");
let mut unaddressed = bucket.clone();
unaddressed.manifest_id = String::new();
diff --git a/core/rust/src/vault_codec/tests.rs b/core/rust/src/vault_codec/tests.rs
index 08f171c4c..14825b705 100644
--- a/core/rust/src/vault_codec/tests.rs
+++ b/core/rust/src/vault_codec/tests.rs
@@ -44,7 +44,7 @@ fn canonicalize_from_sqlite_splits_settings_into_data_bucket() {
let out = canonicalize_from_sqlite(input).unwrap();
assert!(out.first().manifest.tables.contains_key("Items"));
assert!(!out.first().manifest.tables.contains_key("Settings"));
- assert_eq!(bucket_rows(&out, "Settings", "Settings").len(), 1);
+ assert_eq!(bucket_rows(&out, "settings", "Settings").len(), 1);
}
#[test]
@@ -59,7 +59,7 @@ fn bucket_layout_matches_bucket_tables_source_of_truth() {
assert_eq!(bucket_category_for(table), Some(entry.category.as_str()));
}
}
- assert_eq!(layout.iter().map(|e| e.category.as_str()).collect::<Vec<_>>(), vec!["Settings", "Stats"]);
+ assert_eq!(layout.iter().map(|e| e.category.as_str()).collect::<Vec<_>>(), vec!["settings", "stats"]);
assert_eq!(serde_json::to_string(&bucket_layout()).unwrap(), serde_json::to_string(&layout).unwrap());
}
@@ -540,16 +540,16 @@ fn materialize_splits_unknown_tables_into_overflow_and_canonicalize_reemits() {
// in this client's schema; both must round-trip through the overflow row back to their original place.
let mut out = canonicalize_from_sqlite(basic_input(vec![CodecTableData { name: "Items".to_string(), records: vec![row(&[("Id", json!("i1"))])] }])).unwrap();
out.manifests[0].manifest.tables.insert("NewTable".to_string(), vec![row(&[("Id", json!("n1")), ("Data", json!("x"))])]);
- let settings_bucket = out.data_buckets.iter_mut().find(|b| b.category == "Settings").expect("Settings bucket");
+ let settings_bucket = out.data_buckets.iter_mut().find(|b| b.category == "settings").expect("settings bucket");
settings_bucket.tables.insert("Preferences".to_string(), vec![row(&[("Key", json!("p1"))])]);
let re = materialize_as_sqlite(MaterializeInput { manifests: vec![out.first().manifest.clone()], data_buckets: out.data_buckets.clone(), schema_columns: narrow_client_schema() }).unwrap();
assert!(!re.tables.iter().any(|t| t.name == "NewTable" || t.name == "Preferences"), "unknown tables never reach the insert set");
assert_eq!(re.overflow.tables["NewTable"].len(), 1);
- assert_eq!(re.overflow.bucket_tables["Settings"]["Preferences"].len(), 1);
+ assert_eq!(re.overflow.bucket_tables["settings"]["Preferences"].len(), 1);
// Materialize stamps every row with the manifest it arrived in, unknown tables included. The stamp is what routes the row back to its own manifest on the next canonicalize.
assert_eq!(re.overflow.tables["NewTable"][0]["ManifestId"], json!(PERSONAL_MANIFEST));
- assert_eq!(re.overflow.bucket_tables["Settings"]["Preferences"][0]["ManifestId"], json!(PERSONAL_MANIFEST));
+ assert_eq!(re.overflow.bucket_tables["settings"]["Preferences"][0]["ManifestId"], json!(PERSONAL_MANIFEST));
let overflow_table = overflow_table_of(&re).expect("overflow emitted as a regular table row").clone();
let pushed = canonicalize_from_sqlite(basic_input(vec![
@@ -558,11 +558,11 @@ fn materialize_splits_unknown_tables_into_overflow_and_canonicalize_reemits() {
]))
.unwrap();
assert_eq!(pushed.first().manifest.tables["NewTable"].len(), 1, "unknown manifest table re-emitted into the manifest its stamp names");
- assert_eq!(bucket_rows(&pushed, "Settings", "Preferences").len(), 1, "unknown bucket table re-emitted into its category");
+ assert_eq!(bucket_rows(&pushed, "settings", "Preferences").len(), 1, "unknown bucket table re-emitted into its category");
// Bucket-only push path: extract_buckets consumes the overflow row read alongside the category's tables.
let buckets = extract_buckets(
- "Settings".to_string(),
+ "settings".to_string(),
vec![PERSONAL_MANIFEST.to_string()],
[
("Settings".to_string(), vec![row(&[("ManifestId", json!(PERSONAL_MANIFEST)), ("Key", json!("k")), ("Value", json!("v"))])]),
@@ -588,7 +588,7 @@ fn extract_buckets_remerges_overflow_columns() {
..Default::default()
};
let buckets = extract_buckets(
- "Settings".to_string(),
+ "settings".to_string(),
vec![PERSONAL_MANIFEST.to_string()],
[
(
@@ -653,7 +653,7 @@ fn item_stats_route_into_the_stats_bucket_of_the_manifest_that_owns_the_item() {
let stats_bucket = |manifest_id: &str| -> &[CodecRecord] {
out.data_buckets
.iter()
- .find(|b| b.category == "Stats" && b.manifest_id == manifest_id)
+ .find(|b| b.category == "stats" && b.manifest_id == manifest_id)
.and_then(|b| b.tables.get("ItemStats"))
.map(Vec::as_slice)
.unwrap_or(&[])
diff --git a/core/rust/src/vault_merge/tests.rs b/core/rust/src/vault_merge/tests.rs
index 31f17adb7..6b02d41f1 100644
--- a/core/rust/src/vault_merge/tests.rs
+++ b/core/rust/src/vault_merge/tests.rs
@@ -341,10 +341,10 @@ fn bucketed_tables_merge_and_come_back_as_buckets() {
let output = merge_canonical(CanonicalMergeInput {
server_manifests: vec![items_manifest(PERSONAL, vec![])],
- server_buckets: vec![DataBucket::new(PERSONAL, "Settings", [("Settings".to_string(), vec![setting("light", "2024-01-01T00:00:00Z")])].into_iter().collect())],
+ server_buckets: vec![DataBucket::new(PERSONAL, "settings", [("Settings".to_string(), vec![setting("light", "2024-01-01T00:00:00Z")])].into_iter().collect())],
contentless_server_manifest_ids: vec![],
local_manifests: vec![items_manifest(PERSONAL, vec![])],
- local_buckets: vec![DataBucket::new(PERSONAL, "Settings", [("Settings".to_string(), vec![setting("dark", "2024-01-09T00:00:00Z")])].into_iter().collect())],
+ local_buckets: vec![DataBucket::new(PERSONAL, "settings", [("Settings".to_string(), vec![setting("dark", "2024-01-09T00:00:00Z")])].into_iter().collect())],
schema_columns: schema(),
})
.unwrap();
@@ -352,7 +352,7 @@ fn bucketed_tables_merge_and_come_back_as_buckets() {
let merged = &output.manifests[0];
assert!(!merged.manifest.tables.contains_key("Settings"), "bucketed tables never surface in manifest.tables");
assert_eq!(merged.buckets.len(), 1);
- assert_eq!(merged.buckets[0].category, "Settings");
+ assert_eq!(merged.buckets[0].category, "settings");
assert_eq!(merged.buckets[0].tables["Settings"][0]["Value"], json!("dark"), "the newer local setting wins inside the bucket");
assert!(crate::vault_codec::validate_data_bucket(&merged.buckets[0]).ok);
}
@@ -369,7 +369,7 @@ fn an_empty_table_the_server_carried_stays_in_the_merged_manifest() {
// The empty tables of a bucket the server served come back as that bucket, not as a missing one.
let output = merge_canonical(CanonicalMergeInput {
server_manifests: vec![items_manifest(PERSONAL, vec![])],
- server_buckets: vec![DataBucket::new(PERSONAL, "Settings", [("Settings".to_string(), vec![])].into_iter().collect())],
+ server_buckets: vec![DataBucket::new(PERSONAL, "settings", [("Settings".to_string(), vec![])].into_iter().collect())],
contentless_server_manifest_ids: vec![],
local_manifests: vec![items_manifest(PERSONAL, vec![])],
local_buckets: vec![],
diff --git a/core/rust/src/vault_model/generated.rs b/core/rust/src/vault_model/generated.rs
index 0cb02934e..71e8743e5 100644
--- a/core/rust/src/vault_model/generated.rs
+++ b/core/rust/src/vault_model/generated.rs
@@ -70,8 +70,8 @@ pub static SKIP_TABLES: &[&str] = &[
/// own server revision without rewriting the manifest. Tuple form `(table_name, bucket_category)`;
/// `category` mirrors the server `VaultDataBucketCategory`. Several tables may share a category to sync together.
pub static BUCKET_TABLES: &[(&str, &str)] = &[
- ("Settings", "Settings"),
- ("ItemStats", "Stats"),
+ ("Settings", "settings"),
+ ("ItemStats", "stats"),
];
/// Tables that belong exclusively to the user's own (personal) vault, never to a shared manifest.
diff --git a/core/rust/src/vault_sync/engine.rs b/core/rust/src/vault_sync/engine.rs
index 6fc96904a..78daffeb3 100644
--- a/core/rust/src/vault_sync/engine.rs
+++ b/core/rust/src/vault_sync/engine.rs
@@ -23,7 +23,7 @@ use crate::vault_model::{id_key, ids_equal};
const MAX_OUTDATED_RESYNCS: u32 = 3;
/// The pending action type this build carries out.
-const ACTION_ROTATE_MANIFEST_DELIVERY_KEY: &str = "RotateManifestDeliveryKey";
+const ACTION_ROTATE_MANIFEST_DELIVERY_KEY: &str = "rotate-manifest-delivery-key";
/// Run one operation to completion; the value is the `done` command's result.
pub(crate) async fn run(host: Host, request: SyncRequest) -> Value {
diff --git a/core/rust/src/vault_sync/legacy.rs b/core/rust/src/vault_sync/legacy.rs
index 53078a528..72c82818e 100644
--- a/core/rust/src/vault_sync/legacy.rs
+++ b/core/rust/src/vault_sync/legacy.rs
@@ -19,11 +19,11 @@ use crate::sqlite_host::SqlStatement;
use crate::vault_codec::row::inline_bytes;
/// The `storageFormat` of a legacy sqlite-blob snapshot; an absent value means the same.
-const STORAGE_FORMAT_SQLITE_BLOB: i32 = 0;
+pub(crate) const STORAGE_FORMAT_SQLITE_BLOB: &str = "sqlite-blob";
/// Whether a snapshot is still on the legacy sqlite-blob format.
pub(crate) fn is_legacy_sqlite_blob_snapshot(snapshot: &GetResponse) -> bool {
- matches!(snapshot.storage_format, None | Some(STORAGE_FORMAT_SQLITE_BLOB))
+ matches!(snapshot.storage_format.as_deref(), None | Some(STORAGE_FORMAT_SQLITE_BLOB))
}
/// Take a legacy snapshot apart for local storage: the blob passes through untouched, the manifest-v1 fingerprints
diff --git a/core/rust/src/vault_sync/pull.rs b/core/rust/src/vault_sync/pull.rs
index b0b7e0c17..db778cb02 100644
--- a/core/rust/src/vault_sync/pull.rs
+++ b/core/rust/src/vault_sync/pull.rs
@@ -69,12 +69,12 @@ pub(crate) async fn fetch_snapshot(ctx: &Ctx) -> SyncResult<GetResponse> {
}
/// The `storageFormat` a manifest-v1 snapshot declares.
-const STORAGE_FORMAT_MANIFEST: i32 = 1;
+const STORAGE_FORMAT_MANIFEST: &str = "manifest";
-/// Refuse a snapshot in a storage format newer than this build knows, instead of reading it as legacy (0 or absent).
+/// Refuse a snapshot in a storage format newer than this build knows, instead of reading it as legacy.
fn ensure_known_storage_format(snapshot: &GetResponse) -> SyncResult<()> {
- match snapshot.storage_format {
- None | Some(0) | Some(STORAGE_FORMAT_MANIFEST) => Ok(()),
+ match snapshot.storage_format.as_deref() {
+ None | Some(legacy::STORAGE_FORMAT_SQLITE_BLOB) | Some(STORAGE_FORMAT_MANIFEST) => Ok(()),
Some(format) => Err(SyncError::VaultVersionIncompatible(format!("vault has storage format {}, this app reads up to {}; update the app", format, STORAGE_FORMAT_MANIFEST))),
}
}
diff --git a/core/rust/src/vault_sync/push.rs b/core/rust/src/vault_sync/push.rs
index df7d6f750..a7f29a0d7 100644
--- a/core/rust/src/vault_sync/push.rs
+++ b/core/rust/src/vault_sync/push.rs
@@ -8,7 +8,7 @@ use crate::vault_model::{id_key, ids_equal, OVERFLOW_TABLE, TRASH_RETENTION_DEFA
use super::email_routing::build_email_routing;
use super::errors::{SyncError, SyncResult};
use super::state::{self, Ctx};
-use super::types::{BlobDto, BlobHashesRequest, BlobRef, BlobUploadRequest, BucketRevision, BucketWrite, Db, ManifestRevision, ManifestWrite, MissingBlobsResponse, VaultWriteMigration, VaultWriteRequest, VaultWriteResponse};
+use super::types::{BlobDto, BlobHashesRequest, BlobRef, BlobUploadRequest, BucketRevision, BucketWrite, Db, ManifestRevision, ManifestWrite, MissingBlobsResponse, VaultWriteMigration, VaultWriteRequest, VaultWriteResponse, VaultWriteStatus};
use super::blob_keys::{self, EncryptedBlob};
use super::{db, http, keys};
use crate::crypto;
@@ -492,7 +492,7 @@ async fn push_internal(ctx: &mut Ctx, cached: Option<CanonicalizedSet>, create_v
let payload = VaultWriteRequest { username: ctx.request.username.clone(), manifests: manifest_writes, buckets: bucket_writes, email_routing: Some(email_routing), migration: migration.as_ref().map(|m| VaultWriteMigration { account_keys: Some(m.account_keys.clone()) }) };
let response = write_vault(ctx, &payload, &blobs, gate, &mut uploaded).await?;
- if response.status != 0 {
+ if response.status != VaultWriteStatus::Ok {
// All-or-nothing: a single stale manifest or bucket rejected the whole write; the caller pulls, merges and retries.
return Ok((PushStatus::Outdated, None));
}
@@ -800,7 +800,7 @@ async fn push_data_bucket_only_internal(ctx: &Ctx, bucket: &DataBucket, vek: &st
};
let response: VaultWriteResponse = http::post(&ctx.host, http::VAULT_ENDPOINT, &payload, true).await?;
let reported = response.bucket_revisions.iter().find(|b| ids_equal(&b.manifest_id, &bucket.manifest_id) && b.category == bucket.category).map(|b| b.revision);
- if response.status != 0 {
+ if response.status != VaultWriteStatus::Ok {
ctx.warn(format!("[V2Push] {} outdated (server at revision {}, we assumed {}); pulling and merging before the next attempt.", label, reported.unwrap_or(current_revision), current_revision)).await;
return Ok((PushStatus::Outdated, reported.unwrap_or(current_revision)));
}
diff --git a/core/rust/src/vault_sync/sharing.rs b/core/rust/src/vault_sync/sharing.rs
index 0cdbba6f8..1a4ba7b49 100644
--- a/core/rust/src/vault_sync/sharing.rs
+++ b/core/rust/src/vault_sync/sharing.rs
@@ -13,7 +13,7 @@ use crate::vault_codec;
use crate::vault_model::{id_key, ids_equal};
/// The role of a group member who may not administer it.
-const ROLE_MEMBER: &str = "Member";
+const ROLE_MEMBER: &str = "member";
/// The API error code for a recipient whose account has no keypair yet (legacy non-migrated user account).
const INVITE_RECIPIENT_NOT_READY: &str = "INVITE_RECIPIENT_NOT_READY";
diff --git a/core/rust/src/vault_sync/tests/mod.rs b/core/rust/src/vault_sync/tests/mod.rs
index 66c18b0cd..90cf31e28 100644
--- a/core/rust/src/vault_sync/tests/mod.rs
+++ b/core/rust/src/vault_sync/tests/mod.rs
@@ -95,10 +95,9 @@ fn snapshot_of(conn: &rusqlite::Connection, vek: &str, revision: i64, salt: &str
"capabilities": { "sharing": "on" },
});
let vault = json!({
- "status": 0,
- "storageFormat": 1,
+ "storageFormat": "manifest",
"personalManifestId": PERSONAL_MANIFEST_ID,
- "manifests": [{ "manifestId": PERSONAL_MANIFEST_ID, "blob": blob, "ciphertextHash": ciphertext_hash, "revision": revision, "blobReferences": [], "canAdminister": true, "keyType": "accountkey" }],
+ "manifests": [{ "manifestId": PERSONAL_MANIFEST_ID, "blob": blob, "ciphertextHash": ciphertext_hash, "revision": revision, "blobReferences": [], "canAdminister": true, "keyType": "account-key" }],
"buckets": buckets,
"emailRouting": { "privateEmailDomainList": ["private.io"], "publicEmailDomainList": [], "hiddenPrivateEmailDomainList": [], "emailAddressList": [] },
});
@@ -152,10 +151,9 @@ fn contentless_personal_snapshot(revision: i64) -> (Value, Value) {
"capabilities": {},
});
let vault = json!({
- "status": 0,
- "storageFormat": 1,
+ "storageFormat": "manifest",
"personalManifestId": PERSONAL_MANIFEST_ID,
- "manifests": [{ "manifestId": PERSONAL_MANIFEST_ID, "blob": null, "ciphertextHash": null, "revision": revision, "blobReferences": [], "canAdminister": false, "keyType": "accountkey" }],
+ "manifests": [{ "manifestId": PERSONAL_MANIFEST_ID, "blob": null, "ciphertextHash": null, "revision": revision, "blobReferences": [], "canAdminister": false, "keyType": "account-key" }],
"buckets": [],
"emailRouting": { "privateEmailDomainList": ["private.io"], "publicEmailDomainList": [], "hiddenPrivateEmailDomainList": [], "emailAddressList": [] },
});
@@ -171,7 +169,7 @@ fn new_account_starts_from_an_empty_vault_and_writes_its_first_revision() {
host.respond("GET", "Status", status);
host.respond("GET", "Vault", vault);
host.respond("POST", "Vault/blobs/missing", json!({ "missing": [] }));
- host.respond("POST", "Vault", json!({ "status": 0, "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 1 }], "bucketRevisions": [], "missingBlobHashes": [] }));
+ host.respond("POST", "Vault", json!({ "status": "ok", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 1 }], "bucketRevisions": [], "missingBlobHashes": [] }));
let result = host.drive(&SyncSession::new(&request("fullSync", &vek, false, 0)).unwrap());
@@ -209,7 +207,7 @@ fn new_account_whose_first_write_fails_retries_it_on_the_next_sync() {
assert_eq!(result["success"], true, "{}", result);
assert!(host.is_dirty, "the unwritten new vault stays dirty");
- host.respond("POST", "Vault", json!({ "status": 0, "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 1 }], "bucketRevisions": [], "missingBlobHashes": [] }));
+ host.respond("POST", "Vault", json!({ "status": "ok", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 1 }], "bucketRevisions": [], "missingBlobHashes": [] }));
let mutation_sequence = host.mutation_sequence;
let result = host.drive(&SyncSession::new(&request("fullSync", &vek, true, mutation_sequence)).unwrap());
@@ -244,7 +242,7 @@ fn unknown_storage_format_is_refused_not_read_as_legacy() {
let server_db = test_host::open_schema_db(&host.schema_sql);
insert_item(&server_db, "aaaaaaaa-0000-4000-8000-000000000001", "Server item", PERSONAL_MANIFEST_ID);
let (status, mut vault) = snapshot_of(&server_db, &vek, 7, &vault_codec::generate_manifest_salt());
- vault["storageFormat"] = json!(2);
+ vault["storageFormat"] = json!("manifest-v2");
host.respond("GET", "Status", status);
host.respond("GET", "Vault", vault);
@@ -295,7 +293,7 @@ fn dirty_client_pushes_only_what_changed() {
host.mutation_sequence = 1;
host.is_dirty = true;
host.respond("POST", "Vault/blobs/missing", json!({ "missing": [] }));
- host.respond("POST", "Vault", json!({ "status": 0, "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 8 }], "bucketRevisions": [], "missingBlobHashes": [] }));
+ host.respond("POST", "Vault", json!({ "status": "ok", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 8 }], "bucketRevisions": [], "missingBlobHashes": [] }));
let result = host.drive(&SyncSession::new(&request("fullSync", &vek, true, 1)).unwrap());
@@ -347,7 +345,7 @@ fn pushed_blobs_name_the_manifest_that_owns_them() {
host.is_dirty = true;
host.respond_with(Box::new(|method, path, body| (method == "POST" && path == "Vault/blobs/missing").then(|| (200, json!({ "missing": body.map(|b| b["hashes"].clone()).unwrap_or_default() })))));
host.respond("POST", "Vault/blobs", json!({ "acceptedCount": 1 }));
- host.respond("POST", "Vault", json!({ "status": 0, "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 8 }], "bucketRevisions": [], "missingBlobHashes": [] }));
+ host.respond("POST", "Vault", json!({ "status": "ok", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 8 }], "bucketRevisions": [], "missingBlobHashes": [] }));
let result = host.drive(&SyncSession::new(&request("fullSync", &vek, true, 1)).unwrap());
@@ -414,7 +412,7 @@ fn push_local_edit(host: &mut TestHost, vek: &str, name: &str, scopes: &[&str])
host.mutation_sequence += 1;
host.is_dirty = true;
host.respond("POST", "Vault/blobs/missing", json!({ "missing": [] }));
- host.respond("POST", "Vault", json!({ "status": 0, "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 8 }], "bucketRevisions": [], "missingBlobHashes": [] }));
+ host.respond("POST", "Vault", json!({ "status": "ok", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 8 }], "bucketRevisions": [], "missingBlobHashes": [] }));
let mut sync = serde_json::from_str::<Value>(&request("fullSync", vek, true, host.mutation_sequence)).unwrap();
sync["dirtyScopes"] = json!(scopes);
let result = host.drive(&SyncSession::new(&sync.to_string()).unwrap());
@@ -496,9 +494,9 @@ fn outdated_push_merges_the_server_change_and_retries() {
}
let current = body.and_then(|b| b["manifests"][0]["currentRevision"].as_i64()).unwrap_or(-1);
Some(if current == 8 {
- (200, json!({ "status": 0, "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 9 }], "bucketRevisions": [], "missingBlobHashes": [] }))
+ (200, json!({ "status": "ok", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 9 }], "bucketRevisions": [], "missingBlobHashes": [] }))
} else {
- (200, json!({ "status": 2, "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 8 }], "bucketRevisions": [], "missingBlobHashes": [] }))
+ (200, json!({ "status": "outdated", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 8 }], "bucketRevisions": [], "missingBlobHashes": [] }))
})
}));
@@ -568,11 +566,11 @@ fn outdated_bucket_only_push_merges_the_server_bucket_instead_of_overwriting_it(
}
let current = body.and_then(|b| b["buckets"][0]["currentRevision"].as_i64()).unwrap_or(-1);
let revision = if current == 8 { 9 } else { 8 };
- Some((200, json!({ "status": if current == 8 { 0 } else { 2 }, "manifestRevisions": [], "bucketRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "category": "Stats", "revision": revision }], "missingBlobHashes": [] })))
+ Some((200, json!({ "status": if current == 8 { "ok" } else { "outdated" }, "manifestRevisions": [], "bucketRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "category": "stats", "revision": revision }], "missingBlobHashes": [] })))
}));
let mut bucket_request: Value = serde_json::from_str(&request("fullSync", &vek, true, 1)).unwrap();
- bucket_request["dirtyScopes"] = json!(["Stats"]);
+ bucket_request["dirtyScopes"] = json!(["stats"]);
let result = host.drive(&SyncSession::new(&bucket_request.to_string()).unwrap());
assert_eq!(result["success"], true, "{}", result);
@@ -660,7 +658,7 @@ fn manifest_migration_generates_the_key_hierarchy_and_pushes() {
host.state.insert(state::VAULT_MANIFEST_SALT.to_string(), json!(salt));
host.respond_with(Box::new(|method, path, _| if method == "GET" && path == "VaultKey/Password" { Some((200, json!({ "vaultKey": null }))) } else { None }));
host.respond("POST", "Vault/blobs/missing", json!({ "missing": [] }));
- host.respond("POST", "Vault", json!({ "status": 0, "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 4 }], "bucketRevisions": [], "missingBlobHashes": [] }));
+ host.respond("POST", "Vault", json!({ "status": "ok", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 4 }], "bucketRevisions": [], "missingBlobHashes": [] }));
let result = host.drive(&SyncSession::new(&request("migrateManifest", &unlock_key, false, 0)).unwrap());
@@ -701,7 +699,7 @@ fn account_upgrade_decodes_base64_text_that_0_30_merges_left_in_blob_columns() {
host.respond_with(Box::new(|method, path, _| if method == "GET" && path == "VaultKey/Password" { Some((200, json!({ "vaultKey": null }))) } else { None }));
host.respond("POST", "Vault/blobs/missing", json!({ "missing": [] }));
host.respond("POST", "Vault/blobs", json!({}));
- host.respond("POST", "Vault", json!({ "status": 0, "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 4 }], "bucketRevisions": [], "missingBlobHashes": [] }));
+ host.respond("POST", "Vault", json!({ "status": "ok", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 4 }], "bucketRevisions": [], "missingBlobHashes": [] }));
let result = host.drive(&SyncSession::new(&request("migrateManifest", &unlock_key, false, 0)).unwrap());
@@ -731,7 +729,7 @@ fn schema_rebuild_of_a_stale_vault_pushes_without_touching_the_key_hierarchy() {
host.state.insert(state::VAULT_PERSONAL_MANIFEST_ID.to_string(), json!(PERSONAL_MANIFEST_ID));
host.state.insert(state::VAULT_MANIFEST_SALT.to_string(), json!(vault_codec::generate_manifest_salt()));
host.respond("POST", "Vault/blobs/missing", json!({ "missing": [] }));
- host.respond("POST", "Vault", json!({ "status": 0, "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 4 }], "bucketRevisions": [], "missingBlobHashes": [] }));
+ host.respond("POST", "Vault", json!({ "status": "ok", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 4 }], "bucketRevisions": [], "missingBlobHashes": [] }));
let status = host.drive(&SyncSession::new(&request("migrationStatus", &vek, false, 0)).unwrap());
assert_eq!(status["kind"], "schemaRebuild");
@@ -752,8 +750,7 @@ fn schema_rebuild_of_a_stale_vault_pushes_without_touching_the_key_hierarchy() {
fn legacy_snapshot_of(conn: &rusqlite::Connection, unlock_key: &str, revision: i64) -> Value {
let bytes = conn.serialize(rusqlite::MAIN_DB).unwrap().to_vec();
json!({
- "status": 0,
- "storageFormat": 0,
+ "storageFormat": "sqlite-blob",
"legacyVaultBlob": crypto::symmetric_encrypt_bytes(&bytes, unlock_key).unwrap(),
"legacyRevision": revision,
"personalManifestId": PERSONAL_MANIFEST_ID,
@@ -772,7 +769,7 @@ fn pre_format_session_host(unlock_key: &str, local_item: &str, server_item: &str
host.respond("GET", "Vault", legacy_snapshot_of(&server_db, unlock_key, 3));
host.respond_with(Box::new(|method, path, _| if method == "GET" && path == "VaultKey/Password" { Some((200, json!({ "vaultKey": null }))) } else { None }));
host.respond("POST", "Vault/blobs/missing", json!({ "missing": [] }));
- host.respond("POST", "Vault", json!({ "status": 0, "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 4 }], "bucketRevisions": [], "missingBlobHashes": [] }));
+ host.respond("POST", "Vault", json!({ "status": "ok", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 4 }], "bucketRevisions": [], "missingBlobHashes": [] }));
host
}
@@ -828,8 +825,8 @@ fn session_reports_when_a_response_is_missing() {
#[test]
fn state_helpers_key_buckets_and_fingerprints_like_the_client() {
- assert_eq!(state::bucket_revision_key("m", "Settings"), "m:Settings");
- assert_eq!(state::fingerprint_bucket_key("m", "Stats"), "bucket:m:Stats");
+ assert_eq!(state::bucket_revision_key("m", "settings"), "m:settings");
+ assert_eq!(state::fingerprint_bucket_key("m", "stats"), "bucket:m:stats");
assert_eq!(state::fingerprint_manifest_key("m"), "manifest:m");
let _unused: HashMap<String, String> = HashMap::new();
}
@@ -1053,7 +1050,7 @@ fn dirty_legacy_account_probes_for_a_vault_key_once_per_run() {
host.respond("GET", "Status", json!({ "clientVersionSupported": true, "serverVersion": "0.31.0", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 3 }], "personalManifestId": PERSONAL_MANIFEST_ID, "srpSalt": "salt" }));
host.respond("GET", "VaultKey/Password", json!({ "vaultKey": null }));
host.respond("POST", "Vault/blobs/missing", json!({ "missing": [] }));
- host.respond("POST", "Vault", json!({ "status": 0, "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 4 }], "bucketRevisions": [], "missingBlobHashes": [] }));
+ host.respond("POST", "Vault", json!({ "status": "ok", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 4 }], "bucketRevisions": [], "missingBlobHashes": [] }));
let result = host.drive(&SyncSession::new(&request("fullSync", &unlock_key, true, 1)).unwrap());
diff --git a/core/rust/src/vault_sync/tests/unloaded_blobs.rs b/core/rust/src/vault_sync/tests/unloaded_blobs.rs
index 3b0d56180..69367e2fd 100644
--- a/core/rust/src/vault_sync/tests/unloaded_blobs.rs
+++ b/core/rust/src/vault_sync/tests/unloaded_blobs.rs
@@ -70,10 +70,9 @@ fn snapshot(conn: &rusqlite::Connection, vek: &str, blob_key: &str, salt: &str,
"capabilities": { "sharing": "on" },
});
let vault = json!({
- "status": 0,
- "storageFormat": 1,
+ "storageFormat": "manifest",
"personalManifestId": PERSONAL_MANIFEST_ID,
- "manifests": [{ "manifestId": PERSONAL_MANIFEST_ID, "blob": blob, "ciphertextHash": vault_codec::compute_ciphertext_hash(&blob), "revision": revision, "blobReferences": references, "canAdminister": true, "keyType": "accountkey" }],
+ "manifests": [{ "manifestId": PERSONAL_MANIFEST_ID, "blob": blob, "ciphertextHash": vault_codec::compute_ciphertext_hash(&blob), "revision": revision, "blobReferences": references, "canAdminister": true, "keyType": "account-key" }],
"buckets": [],
"emailRouting": { "privateEmailDomainList": ["private.io"], "publicEmailDomainList": [], "hiddenPrivateEmailDomainList": [], "emailAddressList": [] },
});
@@ -106,7 +105,7 @@ fn sync_dirty(host: &mut TestHost, vek: &str) -> Value {
host.mutation_sequence += 1;
host.is_dirty = true;
host.respond_with(Box::new(|method, path, body| (method == "POST" && path == "Vault/blobs/missing").then(|| (200, json!({ "missing": body.map(|b| b["hashes"].clone()).unwrap_or_default() })))));
- host.respond("POST", "Vault", json!({ "status": 0, "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 9 }], "bucketRevisions": [], "missingBlobHashes": [] }));
+ host.respond("POST", "Vault", json!({ "status": "ok", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 9 }], "bucketRevisions": [], "missingBlobHashes": [] }));
host.drive(&SyncSession::new(&request("fullSync", vek, true, host.mutation_sequence)).unwrap())
}
@@ -231,7 +230,7 @@ fn a_key_migration_push_is_refused_while_a_personal_blob_is_not_loaded() {
host.state.insert(state::VAULT_MANIFEST_SALT.to_string(), json!(vault_codec::generate_manifest_salt()));
host.respond_with(Box::new(|method, path, _| (method == "GET" && path == "VaultKey/Password").then(|| (200, json!({ "vaultKey": null })))));
host.respond("POST", "Vault/blobs/missing", json!({ "missing": [] }));
- host.respond("POST", "Vault", json!({ "status": 0, "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 4 }], "bucketRevisions": [], "missingBlobHashes": [] }));
+ host.respond("POST", "Vault", json!({ "status": "ok", "manifestRevisions": [{ "manifestId": PERSONAL_MANIFEST_ID, "revision": 4 }], "bucketRevisions": [], "missingBlobHashes": [] }));
let result = host.drive(&SyncSession::new(&request("migrateManifest", &unlock_key, false, 0)).unwrap());
diff --git a/core/rust/src/vault_sync/tests/unsupported_grant.rs b/core/rust/src/vault_sync/tests/unsupported_grant.rs
index 5d1aabf83..5cbb54cdb 100644
--- a/core/rust/src/vault_sync/tests/unsupported_grant.rs
+++ b/core/rust/src/vault_sync/tests/unsupported_grant.rs
@@ -37,7 +37,7 @@ fn assert_told_to_update(host: &TestHost, result: &Value) {
#[test]
fn unknown_grant_algorithm_asks_for_an_app_update() {
- let (host, result) = sync_with_shared_grant("future-x", "grantkey", "bm90LXJlYWRhYmxl");
+ let (host, result) = sync_with_shared_grant("future-x", "grant-key", "bm90LXJlYWRhYmxl");
assert_told_to_update(&host, &result);
}
@@ -49,6 +49,6 @@ fn unknown_grant_key_type_asks_for_an_app_update() {
#[test]
fn unknown_grant_algorithm_on_a_contentless_shared_manifest_asks_for_an_app_update() {
- let (host, result) = sync_with_shared_grant("future-x", "grantkey", "");
+ let (host, result) = sync_with_shared_grant("future-x", "grant-key", "");
assert_told_to_update(&host, &result);
}
diff --git a/core/rust/src/vault_sync/types.rs b/core/rust/src/vault_sync/types.rs
index 77effd0ca..6bfcf3c6a 100644
--- a/core/rust/src/vault_sync/types.rs
+++ b/core/rust/src/vault_sync/types.rs
@@ -536,9 +536,9 @@ pub struct PendingAction {
#[derive(Debug, Clone, Default, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct GetResponse {
- /// LEGACY: 0 = sqlite-blob, 1 = manifest-v1; absent on servers predating the field.
+ /// `sqlite-blob` (LEGACY) or `manifest`; absent on servers predating the field.
#[serde(default)]
- pub storage_format: Option<i32>,
+ pub storage_format: Option<String>,
#[serde(default)]
pub legacy_vault_blob: Option<String>,
#[serde(default)]
@@ -620,8 +620,8 @@ pub struct EmailRoutingDto {
pub public_email_domain_list: Vec<String>,
}
-pub const KEY_TYPE_ACCOUNT_KEY: &str = "accountkey";
-pub const KEY_TYPE_GRANT_KEY: &str = "grantkey";
+pub const KEY_TYPE_ACCOUNT_KEY: &str = "account-key";
+pub const KEY_TYPE_GRANT_KEY: &str = "grant-key";
pub const ALGORITHM_RSA_OAEP_SHA256: &str = "rsa-oaep-sha256";
/// One manifest element of `POST v2/Vault`.
@@ -706,8 +706,7 @@ pub struct VaultWriteMigration {
#[derive(Debug, Clone, Default, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct VaultWriteResponse {
- #[serde(default)]
- pub status: i32,
+ pub status: VaultWriteStatus,
#[serde(default)]
pub manifest_revisions: Vec<ManifestRevision>,
#[serde(default)]
@@ -716,6 +715,19 @@ pub struct VaultWriteResponse {
pub missing_blob_hashes: Vec<String>,
}
+/// `status` of a `POST v2/Vault` response.
+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Deserialize)]
+#[serde(rename_all = "kebab-case")]
+pub enum VaultWriteStatus {
+ Ok,
+ /// A manifest or bucket revision is stale; the caller pulls, merges and retries.
+ Outdated,
+ /// A status this build does not know; treated as not accepted.
+ #[default]
+ #[serde(other)]
+ Unknown,
+}
+
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BlobUploadRequest {