Skip to content

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

Extract browser extension messaging types to their own files (#2159)

Leendert de Borst9e1e62e8c8d8
diff --git a/apps/browser-extension/src/utils/types/messaging/FullVaultSyncRequest.ts b/apps/browser-extension/src/utils/types/messaging/FullVaultSyncRequest.ts
new file mode 100644
index 000000000..b869b4741
--- /dev/null
+++ b/apps/browser-extension/src/utils/types/messaging/FullVaultSyncRequest.ts
@@ -0,0 +1,13 @@
+import type { VaultSyncOptions } from '@aliasvault/client/sync/VaultSyncEngine';
+
+/**
+ * What a caller asks of a full sync: the engine's own options, plus whether a failure is stored for the popup's
+ * sync-error dialog.
+ */
+export type FullVaultSyncRequest = VaultSyncOptions & {
+ /**
+ * Whether a failure is persisted so the popup can surface it later, defaults to true. Only the login pull
+ * opts out: the login page reports the failure itself, and persisting it would report the same failure twice.
+ */
+ reportErrorToPopup?: boolean;
+};
diff --git a/apps/browser-extension/src/utils/types/messaging/FullVaultSyncResult.ts b/apps/browser-extension/src/utils/types/messaging/FullVaultSyncResult.ts
new file mode 100644
index 000000000..7da6826cf
--- /dev/null
+++ b/apps/browser-extension/src/utils/types/messaging/FullVaultSyncResult.ts
@@ -0,0 +1,13 @@
+/**
+ * Result of a full vault sync operation.
+ */
+export type FullVaultSyncResult = {
+ success: boolean;
+ hasNewVault: boolean;
+ wasOffline: boolean;
+ sqliteBlobUpgradeRequired: boolean;
+ manifestMigrationRequired?: boolean;
+ error?: string;
+ errorKey?: string;
+ requiresLogout: boolean;
+};
diff --git a/apps/browser-extension/src/utils/types/messaging/UploadVaultRequest.ts b/apps/browser-extension/src/utils/types/messaging/UploadVaultRequest.ts
deleted file mode 100644
index 84953241b..000000000
--- a/apps/browser-extension/src/utils/types/messaging/UploadVaultRequest.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export type UploadVaultRequest = {
- vaultBlob: string;
-}
diff --git a/apps/browser-extension/src/utils/types/messaging/VaultManifestMigrationResult.ts b/apps/browser-extension/src/utils/types/messaging/VaultManifestMigrationResult.ts
new file mode 100644
index 000000000..6c1d8c47d
--- /dev/null
+++ b/apps/browser-extension/src/utils/types/messaging/VaultManifestMigrationResult.ts
@@ -0,0 +1,8 @@
+/**
+ * Result of the manifest migration.
+ */
+export type VaultManifestMigrationResult = {
+ success: boolean;
+ pushed: boolean;
+ error?: string;
+};
diff --git a/apps/browser-extension/src/utils/types/messaging/VaultSyncPhase.ts b/apps/browser-extension/src/utils/types/messaging/VaultSyncPhase.ts
new file mode 100644
index 000000000..ab9d0d38b
--- /dev/null
+++ b/apps/browser-extension/src/utils/types/messaging/VaultSyncPhase.ts
@@ -0,0 +1,5 @@
+/**
+ * What a running sync is doing, broadcast to the popup so it can show the matching indicator.
+ * 'pull' = downloading a newer server vault, 'push' = uploading local changes, 'idle' = nothing in flight.
+ */
+export type VaultSyncPhase = 'pull' | 'push' | 'idle';
diff --git a/apps/browser-extension/src/utils/types/messaging/VaultSyncState.ts b/apps/browser-extension/src/utils/types/messaging/VaultSyncState.ts
new file mode 100644
index 000000000..7bad4d85d
--- /dev/null
+++ b/apps/browser-extension/src/utils/types/messaging/VaultSyncState.ts
@@ -0,0 +1,9 @@
+/**
+ * Local sync bookkeeping: whether the vault holds changes that still have to be pushed, the mutation counter
+ * they were recorded at, and whether a sync is running right now.
+ */
+export type VaultSyncState = {
+ isDirty: boolean;
+ mutationSequence: number;
+ isSyncInProgress: boolean;
+};
diff --git a/apps/browser-extension/src/utils/types/messaging/VaultUploadResponse.ts b/apps/browser-extension/src/utils/types/messaging/VaultUploadResponse.ts
deleted file mode 100644
index 19692f6a1..000000000
--- a/apps/browser-extension/src/utils/types/messaging/VaultUploadResponse.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export type VaultUploadResponse = {
- success: boolean,
- error?: string,
- status?: number,
- /** Mutation sequence at the start of upload, for race detection */
- mutationSeqAtStart?: number,
- /** Whether expired trash items were pruned from the vault during upload */
- vaultPruned?: boolean
-};