Skip to content

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

Refactor manifest revision local tracking (#2159)

Leendert de Borst7c6e2ebe7d02
diff --git a/apps/browser-extension/src/entrypoints/background.ts b/apps/browser-extension/src/entrypoints/background.ts
index caf9301b0..a0a703560 100644
--- a/apps/browser-extension/src/entrypoints/background.ts
+++ b/apps/browser-extension/src/entrypoints/background.ts
@@ -9,7 +9,7 @@ import { handleGetWebAuthnSettings, handleWebAuthnCreate, handleWebAuthnGet, han
import { handleOpenPopup, handlePopupWithItem, handleOpenPopupCreateCredential, handleToggleContextMenu } from '@/entrypoints/background/PopupMessageHandler';
import { handleStoreSavePromptState, handleGetSavePromptState, handleClearSavePromptState, handleStoreLastAutofilled, handleGetLastAutofilled, handleClearLastAutofilled } from '@/entrypoints/background/SavePromptStateHandler';
import { handleStoreTwoFactorState, handleGetTwoFactorState, handleClearTwoFactorState } from '@/entrypoints/background/TwoFactorStateHandler';
-import { handleCheckAuthStatus, handleClearPersistedFormValues, handleClearSession, handleClearVaultData, handleLockVault, handleGetFilteredItems, handleGetSearchItems, handleGetDefaultEmailDomain, handleGetDefaultIdentitySettings, handleGetEncryptionKey, handleGetEncryptionKeyDerivationParams, handleGetPasswordSettings, handleGeneratePassword, handleGetPersistedFormValues, handleGetVault, handlePersistFormValues, handleStoreEncryptionKey, handleStoreEncryptionKeyDerivationParams, handleStoreVaultMetadata, handleSyncVault, handleUploadVault, handleGetEncryptedVault, handleStoreEncryptedVault, handleGetSyncState, handleMarkVaultClean, handleMigrateVaultManifest, handleGetServerRevision, handleFullVaultSync, handleCheckLoginDuplicate, handleSaveLoginCredential, handleAddUrlToCredential, handleIsUrlLinkedToCredential, handleGetLoginSaveSettings, handleSetLoginSaveEnabled, handleGetItemsWithTotp, handleSearchItemsWithTotp, handleGetTotpSecrets, handleGenerateTotpCode, handleSetRecentlySelected, handleGetRecentlySelected, handleRecordItemUsage } from '@/entrypoints/background/VaultMessageHandler';
+import { handleCheckAuthStatus, handleClearPersistedFormValues, handleClearSession, handleClearVaultData, handleLockVault, handleGetFilteredItems, handleGetSearchItems, handleGetDefaultEmailDomain, handleGetDefaultIdentitySettings, handleGetEncryptionKey, handleGetEncryptionKeyDerivationParams, handleGetPasswordSettings, handleGeneratePassword, handleGetPersistedFormValues, handleGetVault, handlePersistFormValues, handleStoreEncryptionKey, handleStoreEncryptionKeyDerivationParams, handleStoreVaultMetadata, handleSyncVault, handleUploadVault, handleGetEncryptedVault, handleStoreEncryptedVault, handleGetSyncState, handleMarkVaultClean, handleMigrateVaultManifest, handleFullVaultSync, handleCheckLoginDuplicate, handleSaveLoginCredential, handleAddUrlToCredential, handleIsUrlLinkedToCredential, handleGetLoginSaveSettings, handleSetLoginSaveEnabled, handleGetItemsWithTotp, handleSearchItemsWithTotp, handleGetTotpSecrets, handleGenerateTotpCode, handleSetRecentlySelected, handleGetRecentlySelected, handleRecordItemUsage } from '@/entrypoints/background/VaultMessageHandler';
import { LocalPreferencesService } from '@/utils/LocalPreferencesService';
import { onMessage, sendMessage } from "@/utils/messaging/ExtensionMessaging";
@@ -243,7 +243,6 @@ export default defineBackground({
onMessage('STORE_ENCRYPTED_VAULT', ({ data }) => handleStoreEncryptedVault(data));
onMessage('GET_SYNC_STATE', () => handleGetSyncState());
onMessage('MARK_VAULT_CLEAN', ({ data }) => handleMarkVaultClean(data));
- onMessage('GET_SERVER_REVISION', () => handleGetServerRevision());
onMessage('UPLOAD_VAULT', () => handleUploadVault());
onMessage('SYNC_VAULT', () => handleSyncVault());
diff --git a/apps/browser-extension/src/entrypoints/popup/context/DbContext.tsx b/apps/browser-extension/src/entrypoints/popup/context/DbContext.tsx
index c36743b3a..96a2404a4 100644
--- a/apps/browser-extension/src/entrypoints/popup/context/DbContext.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/context/DbContext.tsx
@@ -21,13 +21,12 @@ import { storage } from '#imports';
const GET_VAULT_TIMEOUT_MS = 3500;
/**
- * Vault metadata including the server revision.
+ * Vault metadata: the email domain lists the server published on the last sync.
*/
type VaultMetadata = {
publicEmailDomains: string[];
privateEmailDomains: string[];
hiddenPrivateEmailDomains: string[];
- serverRevision: number;
};
type DbContextType = {
@@ -51,10 +50,6 @@ type DbContextType = {
* True if an upload to server is in progress.
*/
isUploading: boolean;
- /**
- * Current server revision number.
- */
- serverRevision: number;
setIsOffline: (offline: boolean) => Promise<void>;
/**
* Set the syncing (download) state.
@@ -84,7 +79,7 @@ type DbContextType = {
clearDatabase: () => void;
getVaultMetadata: () => Promise<VaultMetadata | null>;
/**
- * Refresh sync state (isDirty, serverRevision) from storage.
+ * Refresh sync state (isDirty) from storage.
*/
refreshSyncState: () => Promise<void>;
requiresLegacySqliteBlobMigration: () => Promise<boolean>;
@@ -144,11 +139,6 @@ export const DbProvider: React.FC<{ children: React.ReactNode }> = ({ children }
*/
const [isUploading, setIsUploading] = useState(false);
- /**
- * Server revision number.
- */
- const [serverRevision, setServerRevision] = useState(0);
-
/**
* Last sync error written by the background sync. Driven by storage so background-only
* syncs (e.g. follow-up syncs after pending mutations) reach the user.
@@ -182,16 +172,14 @@ export const DbProvider: React.FC<{ children: React.ReactNode }> = ({ children }
* Load the offline mode and sync state from local storage.
*/
const loadSyncState = async (): Promise<void> => {
- const [offlineMode, dirty, revision, lastError] = await Promise.all([
+ const [offlineMode, dirty, lastError] = await Promise.all([
storage.getItem(StorageKeys.IS_OFFLINE_MODE) as Promise<boolean | null>,
storage.getItem(StorageKeys.IS_DIRTY) as Promise<boolean | null>,
- storage.getItem(StorageKeys.SERVER_REVISION) as Promise<number | null>,
storage.getItem(StorageKeys.LAST_SYNC_ERROR) as Promise<string | null>
]);
isOfflineRef.current = offlineMode ?? false;
setIsOfflineState(offlineMode ?? false);
setIsDirty(dirty ?? false);
- setServerRevision(revision ?? 0);
setSyncError(lastError ?? null);
};
loadSyncState();
@@ -322,7 +310,6 @@ export const DbProvider: React.FC<{ children: React.ReactNode }> = ({ children }
const publicEmailDomains = await getStorageItem<string[]>(StorageKeys.PUBLIC_EMAIL_DOMAINS);
const privateEmailDomains = await getStorageItem<string[]>(StorageKeys.PRIVATE_EMAIL_DOMAINS);
const hiddenPrivateEmailDomains = await getStorageItem<string[]>(StorageKeys.HIDDEN_PRIVATE_EMAIL_DOMAINS);
- const revision = await storage.getItem(StorageKeys.SERVER_REVISION) as number | null;
if (!publicEmailDomains && !privateEmailDomains) {
return null;
@@ -332,7 +319,6 @@ export const DbProvider: React.FC<{ children: React.ReactNode }> = ({ children }
publicEmailDomains: publicEmailDomains ?? [],
privateEmailDomains: privateEmailDomains ?? [],
hiddenPrivateEmailDomains: hiddenPrivateEmailDomains ?? [],
- serverRevision: revision ?? 0,
};
} catch (error) {
console.error('Error getting vault metadata from local storage:', error);
@@ -344,12 +330,7 @@ export const DbProvider: React.FC<{ children: React.ReactNode }> = ({ children }
* Refresh sync state from storage (called after background updates it).
*/
const refreshSyncState = useCallback(async (): Promise<void> => {
- const [dirty, revision] = await Promise.all([
- storage.getItem(StorageKeys.IS_DIRTY) as Promise<boolean | null>,
- storage.getItem(StorageKeys.SERVER_REVISION) as Promise<number | null>
- ]);
- setIsDirty(dirty ?? false);
- setServerRevision(revision ?? 0);
+ setIsDirty((await storage.getItem(StorageKeys.IS_DIRTY) as boolean | null) ?? false);
}, []);
/**
@@ -425,7 +406,6 @@ export const DbProvider: React.FC<{ children: React.ReactNode }> = ({ children }
isDirty,
isSyncing,
isUploading,
- serverRevision,
setIsOffline,
setIsSyncing,
setIsUploading,
@@ -441,7 +421,7 @@ export const DbProvider: React.FC<{ children: React.ReactNode }> = ({ children }
requiresManifestMigration,
syncError,
clearSyncError,
- }), [sqliteClient, dbInitialized, dbAvailable, isOffline, getIsOffline, isDirty, isSyncing, isUploading, serverRevision, setIsOffline, shouldSuppressEmailErrors, loadDatabase, loadStoredDatabase, storeEncryptionKey, storeEncryptionKeyDerivationParams, clearDatabase, getVaultMetadata, refreshSyncState, requiresLegacySqliteBlobMigration, requiresManifestMigration, syncError, clearSyncError]);
+ }), [sqliteClient, dbInitialized, dbAvailable, isOffline, getIsOffline, isDirty, isSyncing, isUploading, setIsOffline, shouldSuppressEmailErrors, loadDatabase, loadStoredDatabase, storeEncryptionKey, storeEncryptionKeyDerivationParams, clearDatabase, getVaultMetadata, refreshSyncState, requiresLegacySqliteBlobMigration, requiresManifestMigration, syncError, clearSyncError]);
return (
<DbContext.Provider value={contextValue}>
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx
index da9c26894..2e2a91bad 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx
@@ -21,6 +21,7 @@ import { SrpAuthService } from '@/utils/auth/SrpAuthService';
import { StorageKeys } from '@/utils/constants/storageKeys';
import type { VaultResponse, LoginResponse } from '@/utils/dist/core/models/webapi';
import { EncryptionUtility } from '@/utils/EncryptionUtility';
+import { getManifestRevisions, getPersonalManifestId } from '@/utils/ManifestRevisions';
import { sendMessage } from '@/utils/messaging/ExtensionMessaging';
import { ApiAuthError } from '@/utils/types/errors/ApiAuthError';
import { hasErrorCode, getErrorMessage } from '@/utils/types/errors/AppErrorCodes';
@@ -76,8 +77,9 @@ const Login: React.FC = () => {
const persistAndLoadVault = async (vaultResponse: VaultResponse, encryptionKey: string, loginUsername: string): Promise<void> => {
// Check if there's existing vault data (from forced logout)
const existingVault = await storage.getItem(StorageKeys.ENCRYPTED_VAULT) as string | null;
- const existingRevision = await storage.getItem(StorageKeys.SERVER_REVISION) as number | null;
const storedUsername = await storage.getItem(StorageKeys.USERNAME) as string | null;
+ const personalManifestId = await getPersonalManifestId();
+ const existingRevision = personalManifestId ? (await getManifestRevisions())[personalManifestId] ?? null : null;
let vaultToLoad = vaultResponse.vault.blob;
@@ -130,7 +132,7 @@ const Login: React.FC = () => {
// Normal flow: persist server vault to local storage
await sendMessage('STORE_ENCRYPTED_VAULT', {
vaultBlob: vaultResponse.vault.blob,
- serverRevision: vaultResponse.vault.currentRevisionNumber,
+ personalManifestRevision: vaultResponse.vault.currentRevisionNumber,
});
await sendMessage('STORE_VAULT_METADATA', {
diff --git a/apps/browser-extension/src/utils/ManifestRevisions.ts b/apps/browser-extension/src/utils/ManifestRevisions.ts
new file mode 100644
index 000000000..00c177d0d
--- /dev/null
+++ b/apps/browser-extension/src/utils/ManifestRevisions.ts
@@ -0,0 +1,60 @@
+/**
+ * ManifestRevisions.
+ *
+ * The client's last-known server revision per manifest.
+ */
+
+import { storage } from 'wxt/utils/storage';
+
+import { StorageKeys } from '@/utils/constants/storageKeys';
+import { devWarn } from '@/utils/devLogger/DevLogger';
+
+/**
+ * Every manifest's last-known server revision, keyed by manifest id; empty when nothing has been pulled yet.
+ */
+export async function getManifestRevisions(): Promise<Record<string, number>> {
+ return ((await storage.getItem(StorageKeys.SERVER_MANIFEST_REVISIONS)) as Record<string, number> | null) ?? {};
+}
+
+/**
+ * Replace with new data (from server).
+ * @param revisions - the full set of manifest revisions from the snapshot
+ */
+export async function replaceManifestRevisions(revisions: Record<string, number>): Promise<void> {
+ await storage.setItem(StorageKeys.SERVER_MANIFEST_REVISIONS, revisions);
+}
+
+/**
+ * Merge new revisions into the stored map, used after a write where only the manifests actually written advanced.
+ * @param revisions - the manifest revisions to record
+ */
+export async function recordManifestRevisions(revisions: Record<string, number>): Promise<void> {
+ await replaceManifestRevisions({ ...await getManifestRevisions(), ...revisions });
+}
+
+/**
+ * The id of this vault's own (personal) manifest, as reported by the server on the last pull.
+ */
+export async function getPersonalManifestId(): Promise<string | null> {
+ return (await storage.getItem(StorageKeys.VAULT_PERSONAL_MANIFEST_ID)) as string | null;
+}
+
+/** The personal manifest's last-known server revision. */
+export async function getPersonalManifestRevision(): Promise<number> {
+ const personalManifestId = await getPersonalManifestId();
+ return personalManifestId ? (await getManifestRevisions())[personalManifestId] ?? 0 : 0;
+}
+
+/**
+ * Record the personal manifest's revision.
+ * @param revision - the revision the server reported for the personal manifest
+ */
+export async function recordPersonalManifestRevision(revision: number): Promise<void> {
+ const personalManifestId = await getPersonalManifestId();
+ if (!personalManifestId) {
+ devWarn(`[VaultSync] No personal manifest id known, dropping personal revision ${revision}; the next sync pulls to rebuild the baseline.`);
+ return;
+ }
+
+ await recordManifestRevisions({ [personalManifestId]: revision });
+}
diff --git a/apps/browser-extension/src/utils/VaultSyncService.ts b/apps/browser-extension/src/utils/VaultSyncService.ts
index f96fd583c..77ae2736f 100644
--- a/apps/browser-extension/src/utils/VaultSyncService.ts
+++ b/apps/browser-extension/src/utils/VaultSyncService.ts
@@ -13,6 +13,7 @@ import { VaultSqlGenerator } from '@/utils/dist/core/vault';
import { buildEmailRouting } from '@/utils/EmailRouting';
import { EncryptionUtility } from '@/utils/EncryptionUtility';
import { completeLegacyAccountKeyMigration, isLegacySqliteBlobSnapshot, legacyUnstampedRowAdoption, openLegacySqliteBlobSnapshot, prepareLegacyAccountKeyMigration, withOutdatedServerGuard, type LegacyAccountKeyMigration, type LegacySqliteBlobSnapshot } from '@/utils/legacy/LegacyStorageModelMigration';
+import { getManifestRevisions, getPersonalManifestId, getPersonalManifestRevision, recordManifestRevisions, replaceManifestRevisions } from '@/utils/ManifestRevisions';
import {vaultCodecComputeCiphertextHash, vaultCodecComputeContentFingerprint, vaultCodecCanonicalizeFromSqlite, vaultCodecExtractEncryptionKeyForPublicKey, vaultCodecGenerateManifestSalt, vaultCodecUnpackPayload, vaultCodecMaterializeAsSqlite, vaultCodecPackPayload, vaultCodecValidateManifest, vaultCodecValidateDataBucket, type CodecBlobEntry, type CodecCanonicalized, type CodecManifest, type CodecManifestSpec} from '@/utils/RustCore';
import { SharingService, type SessionSharedManifest } from '@/utils/SharingService';
import { SqliteClient } from '@/utils/SqliteClient';
@@ -524,11 +525,9 @@ export class VaultSyncService {
pulledFingerprints[fingerprintManifestKey(entry.manifestId)] = entry.contentFingerprint;
}
- // Persist the revision of every manifest so sync can detect when one is added or updated server-side.
- await storage.setItem(StorageKeys.SERVER_REVISION, personal.revision);
- const sharedManifestRevisions = Object.fromEntries(resolved.filter(m => !m.isPersonal).map(m => [m.manifestId, m.revision]));
- await storage.setItem(StorageKeys.SERVER_MANIFEST_REVISIONS, sharedManifestRevisions);
- devLog(`[V2Pull] Stored local shared-manifest revisions from snapshot: ${Object.keys(sharedManifestRevisions).length === 0 ? '(none)' : Object.entries(sharedManifestRevisions).map(([id, rev]) => `${id}=${rev}`).join(', ')}. Next status check compares against these.`);
+ const manifestRevisions = Object.fromEntries(resolved.map(m => [m.manifestId, m.revision]));
+ await replaceManifestRevisions(manifestRevisions);
+ devLog(`[V2Pull] Stored local manifest revisions from snapshot: ${Object.entries(manifestRevisions).map(([id, rev]) => `${id}=${rev}`).join(', ')}. Next status check compares against these.`);
// Fetch any referenced blobs that aren't already in the local (encrypted) cache.
const refOwners = new Map<string, ResolvedManifest>();
@@ -785,7 +784,7 @@ export class VaultSyncService {
}
/**
- * The push implementation; {@link push} encrypts it with the outdated-server guard.
+ * The push implementation; {@link push} wraps it with the outdated-server guard.
* @param sqliteClient - the in-memory SQLite the user has been editing
* @param vek - the symmetric encryption key
* @param username - the user's username
@@ -842,17 +841,14 @@ export class VaultSyncService {
* The revision each manifest rebases on, re-read here rather than taken off the records: canonicalize may have
* run earlier (the pre-push no-op check caches its result) and a write in between advances them.
*/
- const currentManifestRevision = await this.currentPersonalRevision();
- const storedSharedRevisions = ((await storage.getItem(StorageKeys.SERVER_MANIFEST_REVISIONS)) as Record<string, number> | null) ?? {};
+ const storedRevisions = await getManifestRevisions();
+ const currentManifestRevision = storedRevisions[await this.resolvePersonalManifestId()] ?? 0;
/**
* The revision one manifest's write rebases on, falling back to the revision its grant was resolved at.
* @param record - the manifest record
*/
- const revisionOf = (record: ManifestRecord): number => record.isPersonal ? currentManifestRevision : storedSharedRevisions[record.manifestId] ?? record.revision;
+ const revisionOf = (record: ManifestRecord): number => record.isPersonal ? currentManifestRevision : storedRevisions[record.manifestId] ?? record.revision;
- // Every manifest canonicalize produced, joined to its record: one candidate list the whole write is derived from.
- // A canonicalized manifest with no record is one this vault cannot write and is dropped rather than pushed with a
- // key or revision we would have to invent.
const recordByManifestId = new Map(manifestRecords.map(r => [r.manifestId, r]));
const candidates: PushManifest[] = canonicalized.manifests.flatMap(({ manifest, blobs }): PushManifest[] => {
const record = recordByManifestId.get(manifest.manifestId);
@@ -1103,7 +1099,6 @@ export class VaultSyncService {
}
// 5) Update local persisted state on success.
- await storage.setItem(StorageKeys.SERVER_REVISION, newPersonalRevision);
if ((resp.bucketRevisions ?? []).length > 0) {
const bucketRevisions = await this.loadBucketRevisions();
for (const br of resp.bucketRevisions) {
@@ -1112,23 +1107,15 @@ export class VaultSyncService {
await storage.setItem(StorageKeys.VAULT_BUCKET_REVISIONS, bucketRevisions);
}
- /*
- * Persist the new revision of every shared manifest written, mirrored onto the session records so a subsequent
- * push in the same session rebases on the right revision.
- */
- const persistedSharedRevisions = ((await storage.getItem(StorageKeys.SERVER_MANIFEST_REVISIONS)) as Record<string, number> | null) ?? {};
const sessionShared = await SharingService.getSessionSharedManifests();
const writtenRevisions = new Map((resp.manifestRevisions ?? []).filter(r => r.manifestId !== personalRecord.manifestId).map(r => [r.manifestId, r.revision]));
- for (const [manifestId, revision] of writtenRevisions) {
- persistedSharedRevisions[manifestId] = revision;
- }
+ await recordManifestRevisions({ ...Object.fromEntries(writtenRevisions), [await this.resolvePersonalManifestId()]: newPersonalRevision });
for (const record of Object.values(sessionShared)) {
const revision = writtenRevisions.get(record.manifestId);
if (revision !== undefined) {
record.revision = revision;
}
}
- await storage.setItem(StorageKeys.SERVER_MANIFEST_REVISIONS, persistedSharedRevisions);
await SharingService.setSessionSharedManifests(sessionShared);
/*
@@ -1358,7 +1345,7 @@ export class VaultSyncService {
salt: manifestSalt,
folderId: null,
vek: null,
- revision: await this.currentPersonalRevision(),
+ revision: await getPersonalManifestRevision(),
name: null,
// The personal manifest's own delivery key is published as the account-level key, not per manifest.
canAdminister: false,
@@ -1385,20 +1372,11 @@ export class VaultSyncService {
}
/**
- * The personal manifest's last-known server revision. It lives under its own storage key rather than in the
- * per-manifest revision map: the server addresses it by the auth session, never by id.
- */
- private async currentPersonalRevision(): Promise<number> {
- return ((await storage.getItem(StorageKeys.SERVER_REVISION)) as number | null) ?? 0;
- }
-
- /**
- * The id of this vault's own (personal) manifest, as reported by the server on the last pull. It is client state
- * rather than vault content, so local storage is its only home; the vault carries no copy that could go stale or
- * outlive the account.
+ * The id of this vault's own (personal) manifest, as reported by the server on the last pull. Pushing without it
+ * is impossible: it addresses the write and keys the revision the write rebases on.
*/
private async resolvePersonalManifestId(): Promise<string> {
- const personalManifestId = (await storage.getItem(StorageKeys.VAULT_PERSONAL_MANIFEST_ID)) as string | null;
+ const personalManifestId = await getPersonalManifestId();
if (!personalManifestId) {
throw new Error('VaultSyncService: no personal manifest id available (no snapshot baseline recorded); pull once before pushing.');
}
diff --git a/apps/browser-extension/src/utils/constants/legacyStorageKeys.ts b/apps/browser-extension/src/utils/constants/legacyStorageKeys.ts
index 4882bd1b2..98df3d574 100644
--- a/apps/browser-extension/src/utils/constants/legacyStorageKeys.ts
+++ b/apps/browser-extension/src/utils/constants/legacyStorageKeys.ts
@@ -1,7 +1,8 @@
/**
- * Storage keys that ONLY exist to read state written by an older extension version. Nothing writes them any
- * more: every one of them is read once, migrated onto its current {@link StorageKeys} counterpart, and then
- * dropped. They live apart from `storageKeys.ts` so the current key set stays readable at a glance.
+ * Storage keys that ONLY exist because an older extension version wrote them. Nothing writes them any more:
+ * each is either read once and migrated onto its current {@link StorageKeys} counterpart, or kept purely so a
+ * logout still purges the value an upgrade left behind. They live apart from `storageKeys.ts` so the current key
+ * set stays readable at a glance.
*
* Deleting this file is the whole cleanup for these one-time reads: the compiler then points at every
* remaining reader (all of which live in `@/utils/legacy/LegacyStorageKeyFallbacks`).
@@ -10,10 +11,10 @@
import type { StorageKey } from '@/utils/constants/storageKeys';
export const LegacyStorageKeys = {
- /** Pre-v0.20 revision key, in the string format `"250"` or `"250+1"`; migrated to `StorageKeys.SERVER_REVISION`. */
- VAULT_REVISION_NUMBER: 'local:vaultRevisionNumber',
/** Pre-v0.22 encryption key location; read as a fallback for `StorageKeys.ENCRYPTION_KEY`. */
DERIVED_KEY: 'session:derivedKey',
+ /** Pre-v0.31 server revision location; read as a fallback for `StorageKeys.SERVER_MANIFEST_REVISIONS`. */
+ SERVER_REVISION: 'local:serverRevision',
/*
* -- Session locations migrated to local: in v0.26.0, removable in v0.27.0+ (see readLegacyStorageFallback) --
@@ -34,5 +35,5 @@ export const LegacyStorageKeys = {
* clears them alongside the current ones.
*/
export const LEGACY_VAULT_DATA_STORAGE_KEYS: readonly StorageKey[] = [
- LegacyStorageKeys.VAULT_REVISION_NUMBER,
+ LegacyStorageKeys.SERVER_REVISION,
];
diff --git a/apps/browser-extension/src/utils/constants/storageKeys.ts b/apps/browser-extension/src/utils/constants/storageKeys.ts
index bf3e64b34..8f3482c97 100644
--- a/apps/browser-extension/src/utils/constants/storageKeys.ts
+++ b/apps/browser-extension/src/utils/constants/storageKeys.ts
@@ -33,8 +33,6 @@ export const StorageKeys = {
/** The encrypted vault blob. */
ENCRYPTED_VAULT: 'local:encryptedVault',
- /** Revision number of the personal manifest as known by the server. */
- SERVER_REVISION: 'local:serverRevision',
/** Public email domains supported by the server. */
PUBLIC_EMAIL_DOMAINS: 'local:publicEmailDomains',
/** Private email domains supported by the server. */
@@ -64,7 +62,7 @@ export const StorageKeys = {
IS_OFFLINE_MODE: 'local:isOfflineMode',
/** Message of the last failed sync attempt, shown in the UI. */
LAST_SYNC_ERROR: 'local:lastSyncError',
- /** The client's last known revision per manifest. */
+ /** The client's last known server revision per manifest. */
SERVER_MANIFEST_REVISIONS: 'local:serverManifestRevisions',
/** The client's last known revision per data bucket. */
VAULT_BUCKET_REVISIONS: 'local:vaultBucketRevisions',
@@ -260,7 +258,6 @@ export const allVaultDataStorageKeys = (): StorageKey[] => [
StorageKeys.PUBLIC_EMAIL_DOMAINS,
StorageKeys.PRIVATE_EMAIL_DOMAINS,
StorageKeys.HIDDEN_PRIVATE_EMAIL_DOMAINS,
- StorageKeys.SERVER_REVISION,
StorageKeys.SERVER_MANIFEST_REVISIONS,
StorageKeys.VAULT_BUCKET_REVISIONS,
StorageKeys.VAULT_MANIFEST_SALT,
diff --git a/apps/browser-extension/src/utils/legacy/LegacyStorageKeyFallbacks.ts b/apps/browser-extension/src/utils/legacy/LegacyStorageKeyFallbacks.ts
index 8ff2f4c86..953ef2fe8 100644
--- a/apps/browser-extension/src/utils/legacy/LegacyStorageKeyFallbacks.ts
+++ b/apps/browser-extension/src/utils/legacy/LegacyStorageKeyFallbacks.ts
@@ -52,21 +52,3 @@ export async function readLegacyStorageFallback<T>(key: StorageKey): Promise<T |
export async function readLegacySessionEncryptionKey(): Promise<string | null> {
return await storage.getItem(LegacyStorageKeys.DERIVED_KEY) as string | null;
}
-
-/**
- * The server revision as stored before v0.20, where it was a string in the `"250"` or `"250+1"` format (server
- * revision plus local edit count). Migrates whatever it finds onto {@link StorageKeys.SERVER_REVISION}. Read
- * only after that key came up empty.
- * @returns The migrated server revision, or null when no legacy value exists
- */
-export async function readLegacyServerRevision(): Promise<number | null> {
- const legacyRevision = await storage.getItem(LegacyStorageKeys.VAULT_REVISION_NUMBER) as string | number | null;
- if (legacyRevision === null) {
- return null;
- }
-
- // Only the server part before the '+' is the server revision; the suffix counted unpushed local edits.
- const revision = typeof legacyRevision === 'number' ? legacyRevision : parseInt(legacyRevision.split('+')[0], 10) || 0;
- await storage.setItem(StorageKeys.SERVER_REVISION, revision);
- return revision;
-}
diff --git a/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts b/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
index 8fb9ae742..575e2ef47 100644
--- a/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
+++ b/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
@@ -71,15 +71,14 @@ export interface IExtensionMessageProtocol {
GET_REQUEST_DATA(data: any): PendingPasskeyRequest | null;
GET_SAVE_PROMPT_STATE(): { success: boolean; state: SavePromptPersistedState | null };
GET_SEARCH_ITEMS(data: { searchTerm: string }): ItemsResponse;
- GET_SERVER_REVISION(): number;
- GET_SYNC_STATE(): { isDirty: boolean; mutationSequence: number; serverRevision: number; isSyncInProgress: boolean };
+ GET_SYNC_STATE(): { isDirty: boolean; mutationSequence: number; isSyncInProgress: boolean };
GET_TOTP_SECRETS(data: { itemIds: string[] }): { success: boolean; secrets?: Record<string, string>; error?: string };
GET_TWO_FACTOR_STATE(): TwoFactorState | null;
GET_VAULT(): VaultResponse;
GET_WEBAUTHN_SETTINGS(data: any): WebAuthnSettingsResponse;
IS_URL_LINKED_TO_CREDENTIAL(data: { itemId: string; url: string }): { linked: boolean };
LOCK_VAULT(): BoolResponse;
- MARK_VAULT_CLEAN(data: { mutationSeqAtStart: number; newServerRevision: number }): { cleared: boolean; currentMutationSeq: number };
+ MARK_VAULT_CLEAN(data: { mutationSeqAtStart: number; newPersonalManifestRevision: number }): { cleared: boolean; currentMutationSeq: number };
MIGRATE_VAULT_MANIFEST(): VaultManifestMigrationResult;
OPEN_AUTOFILL_POPUP(data: { elementIdentifier: string; popupType?: string }): BoolResponse;
OPEN_POPUP(): BoolResponse;
@@ -96,7 +95,7 @@ export interface IExtensionMessageProtocol {
SET_CLIPBOARD_CLEAR_TIMEOUT(data: number): boolean;
SET_LOGIN_SAVE_ENABLED(data: boolean): BoolResponse;
SET_RECENTLY_SELECTED(data: { itemId: string; domain: string }): { success: boolean };
- STORE_ENCRYPTED_VAULT(data: { vaultBlob: string; markDirty?: boolean; serverRevision?: number; expectedMutationSeq?: number; scope?: VaultMutationScope }): { success: boolean; mutationSequence: number };
+ STORE_ENCRYPTED_VAULT(data: { vaultBlob: string; markDirty?: boolean; personalManifestRevision?: number; expectedMutationSeq?: number; scope?: VaultMutationScope }): { success: boolean; mutationSequence: number };
STORE_ENCRYPTION_KEY(data: string): BoolResponse;
STORE_ENCRYPTION_KEY_DERIVATION_PARAMS(data: EncryptionKeyDerivationParams): BoolResponse;
STORE_LAST_AUTOFILLED(data: LastAutofilledCredential): { success: boolean };
diff --git a/apps/browser-extension/src/utils/types/messaging/VaultResponse.ts b/apps/browser-extension/src/utils/types/messaging/VaultResponse.ts
index 0fdb285ec..b9405a0d3 100644
--- a/apps/browser-extension/src/utils/types/messaging/VaultResponse.ts
+++ b/apps/browser-extension/src/utils/types/messaging/VaultResponse.ts
@@ -3,6 +3,5 @@ export type VaultResponse = {
vault?: string,
publicEmailDomains?: string[],
privateEmailDomains?: string[],
- hiddenPrivateEmailDomains?: string[],
- serverRevision?: number
+ hiddenPrivateEmailDomains?: string[]
};