Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Move EncryptionKeys to its own separate bucket (#2159)
Leendert de Borst1588f7a56d15
diff --git a/apps/browser-extension/src/utils/dist/core/models/vault/index.d.ts b/apps/browser-extension/src/utils/dist/core/models/vault/index.d.tsindex 14afb0668..38b8eb301 100644--- a/apps/browser-extension/src/utils/dist/core/models/vault/index.d.ts+++ b/apps/browser-extension/src/utils/dist/core/models/vault/index.d.ts@@ -290,6 +290,10 @@ declare const VaultDataBucketCategory: {* User client settings (sort order, autofill prefs, identity defaults, etc.).*/readonly Settings: "Settings";+ /**+ * The user's asymmetric keypairs, which are used for both email decryption and to unwrap shared-folder VEKs.+ */+ readonly EncryptionKeys: "EncryptionKeys";};/*** Type representing all valid vault data bucket category values.diff --git a/apps/browser-extension/src/utils/dist/core/models/vault/index.js b/apps/browser-extension/src/utils/dist/core/models/vault/index.jsindex 01064877c..3b4613d9b 100644--- a/apps/browser-extension/src/utils/dist/core/models/vault/index.js+++ b/apps/browser-extension/src/utils/dist/core/models/vault/index.js@@ -86,7 +86,11 @@ var VaultDataBucketCategory = {/*** User client settings (sort order, autofill prefs, identity defaults, etc.).*/- Settings: "Settings"+ Settings: "Settings",+ /**+ * The user's asymmetric keypairs, which are used for both email decryption and to unwrap shared-folder VEKs.+ */+ EncryptionKeys: "EncryptionKeys"};// src/vault/Item.tsdiff --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.ktindex e97c474d5..c7123076c 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@@ -14,8 +14,13 @@ object VaultDataBucketCategory {*/const val SETTINGS = "Settings"+ /**+ * The user's asymmetric keypairs, which are used for both email decryption and to unwrap shared-folder VEKs.+ */+ const val ENCRYPTION_KEYS = "EncryptionKeys"+/*** All known data bucket categories.*/- val all = listOf(SETTINGS)+ val all = listOf(SETTINGS, ENCRYPTION_KEYS)}diff --git a/apps/mobile-app/ios/VaultModels/VaultDataBucketCategory.swift b/apps/mobile-app/ios/VaultModels/VaultDataBucketCategory.swiftindex b2d20b742..8b77228fe 100644--- a/apps/mobile-app/ios/VaultModels/VaultDataBucketCategory.swift+++ b/apps/mobile-app/ios/VaultModels/VaultDataBucketCategory.swift@@ -10,6 +10,9 @@ public struct VaultDataBucketCategory {/// User client settings (sort order, autofill prefs, identity defaults, etc.).public static let settings = "Settings"+ /// The user's asymmetric keypairs, which are used for both email decryption and to unwrap shared-folder VEKs.+ public static let encryptionKeys = "EncryptionKeys"+/// All known data bucket categories.- public static let all = [settings]+ public static let all = [settings, encryptionKeys]}diff --git a/apps/mobile-app/utils/dist/core/models/vault/index.d.ts b/apps/mobile-app/utils/dist/core/models/vault/index.d.tsindex 14afb0668..38b8eb301 100644--- a/apps/mobile-app/utils/dist/core/models/vault/index.d.ts+++ b/apps/mobile-app/utils/dist/core/models/vault/index.d.ts@@ -290,6 +290,10 @@ declare const VaultDataBucketCategory: {* User client settings (sort order, autofill prefs, identity defaults, etc.).*/readonly Settings: "Settings";+ /**+ * The user's asymmetric keypairs, which are used for both email decryption and to unwrap shared-folder VEKs.+ */+ readonly EncryptionKeys: "EncryptionKeys";};/*** Type representing all valid vault data bucket category values.diff --git a/apps/mobile-app/utils/dist/core/models/vault/index.js b/apps/mobile-app/utils/dist/core/models/vault/index.jsindex 01064877c..3b4613d9b 100644--- a/apps/mobile-app/utils/dist/core/models/vault/index.js+++ b/apps/mobile-app/utils/dist/core/models/vault/index.js@@ -86,7 +86,11 @@ var VaultDataBucketCategory = {/*** User client settings (sort order, autofill prefs, identity defaults, etc.).*/- Settings: "Settings"+ Settings: "Settings",+ /**+ * The user's asymmetric keypairs, which are used for both email decryption and to unwrap shared-folder VEKs.+ */+ EncryptionKeys: "EncryptionKeys"};// src/vault/Item.tsdiff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultDataBucketCategory.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/VaultDataBucketCategory.csindex 6f24d21c5..60f91ec85 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@@ -18,4 +18,7 @@ public enum VaultDataBucketCategory{/// <summary>User client settings (sort order, autofill prefs, identity defaults, etc.).</summary>Settings = 0,++ /// <summary>The user's asymmetric keypairs, which are used for both email decryption and to unwrap shared-folder VEKs.</summary>+ EncryptionKeys = 1,}diff --git a/core/models/scripts/generate-bucket-categories.cjs b/core/models/scripts/generate-bucket-categories.cjsindex d23c36150..f5f157cd6 100644--- a/core/models/scripts/generate-bucket-categories.cjs+++ b/core/models/scripts/generate-bucket-categories.cjs@@ -26,6 +26,7 @@ const KOTLIN_OUTPUT = path.join(REPO_ROOT, 'apps/mobile-app/android/app/src/main*/const CATEGORY_DESCRIPTIONS = {Settings: 'User client settings (sort order, autofill prefs, identity defaults, etc.).',+ EncryptionKeys: "The user's asymmetric keypairs, which are used for both email decryption and to unwrap shared-folder VEKs.",};const DEFAULT_DESCRIPTION = 'A manifest-v1 data bucket category.';diff --git a/core/models/src/vault/VaultDataBucketCategory.ts b/core/models/src/vault/VaultDataBucketCategory.tsindex 239b242bb..2d27022db 100644--- a/core/models/src/vault/VaultDataBucketCategory.ts+++ b/core/models/src/vault/VaultDataBucketCategory.ts@@ -15,6 +15,11 @@ export const VaultDataBucketCategory = {* User client settings (sort order, autofill prefs, identity defaults, etc.).*/Settings: 'Settings',++ /**+ * The user's asymmetric keypairs, which are used for both email decryption and to unwrap shared-folder VEKs.+ */+ EncryptionKeys: 'EncryptionKeys',} as const;/**diff --git a/core/rust/src/vault_codec/types.rs b/core/rust/src/vault_codec/types.rsindex 8a207577c..b95231bd8 100644--- a/core/rust/src/vault_codec/types.rs+++ b/core/rust/src/vault_codec/types.rs@@ -2,6 +2,10 @@//!//! These constants are defined here so every platform shares the exact same rules.+// ---------------------------------------------------------------------------+// Static / const definitions+// ---------------------------------------------------------------------------+/// The SQLite columns whose contents are extracted into content-addressed blobs rather than/// kept inline in the manifest. Tuple form `(table_name, blob_column, kind_label)`. The kind label/// is reported to the server on upload (used for metrics / retention).@@ -18,13 +22,48 @@ pub static SKIP_TABLES: &[&str] = &["android_metadata",];-/// Tables split OUT of the manifest into a data bucket, keyed by category, so each bucket syncs on its+/// Tables split out of the manifest into a data bucket, keyed by category, so each bucket syncs on its/// 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"),+ ("EncryptionKeys", "EncryptionKeys"),];+/// Tables that belong exclusively to the user's own (root) vault, never to a shared-folder manifest.+/// Canonicalize never routes these into a shared partition and will refuse to materialize if they+/// are found in a shared manifest anyway.+pub static PERSONAL_TABLES: &[&str] = &["EncryptionKeys"];++/// Manifest / metadata schema version. This is the manifest *wire structure* version and is its own+/// axis, independent of the data-model `version` string (which tracks EF migrations).+/// It starts at 1 for the first manifest generation; bump only on a breaking structural change+/// (field type changes, removed fields).+pub const SCHEMA_VERSION: u32 = 1;++/// Client-local SQLite table that carries the codec overflow inside the vault database itself (see+/// `CodecOverflow`): materialize writes a single row `{ Id: OVERFLOW_ROW_ID, Data: <json> }`, and+/// canonicalize / extract_bucket consume it to build the manifest.+pub const OVERFLOW_TABLE: &str = "CodecOverflows";++/// Fixed sentinel primary key of the single `OVERFLOW_TABLE` row (deterministic on purpose:+/// materialize output must not depend on a random source).+pub const OVERFLOW_ROW_ID: &str = "00000000-0000-0000-0000-00000000c0de";++// ---------------------------------------------------------------------------+// Accessor methods+// ---------------------------------------------------------------------------++/// Returns the blob `(table, column, kind)` tuple for a table, if it owns an extracted blob column.+pub fn blob_spec_for(table_name: &str) -> Option<&'static (&'static str, &'static str, &'static str)> {+ BLOB_COLUMNS.iter().find(|(t, _, _)| *t == table_name)+}++/// True when a table must never be serialized into / inserted from the manifest.+pub fn is_skip_table(table_name: &str) -> bool {+ SKIP_TABLES.contains(&table_name)+}+/// The data-bucket category a table belongs to, if it is bucketed out of the manifest.pub fn bucket_category_for(table_name: &str) -> Option<&'static str> {BUCKET_TABLES.iter().find(|(t, _)| *t == table_name).map(|(_, c)| *c)@@ -47,20 +86,9 @@ pub fn tables_for_category(category: &str) -> Vec<&'static str> {BUCKET_TABLES.iter().filter(|(_, c)| *c == category).map(|(t, _)| *t).collect()}-/// Manifest / metadata schema version. This is the manifest *wire structure* version and is its own-/// axis, independent of the data-model `version` string (which tracks EF migrations).-/// It starts at 1 for the first manifest generation; bump only on a breaking structural change-/// (field type changes, removed fields).-pub const SCHEMA_VERSION: u32 = 1;--/// Returns the blob `(table, column, kind)` tuple for a table, if it owns an extracted blob column.-pub fn blob_spec_for(table_name: &str) -> Option<&'static (&'static str, &'static str, &'static str)> {- BLOB_COLUMNS.iter().find(|(t, _, _)| *t == table_name)-}--/// True when a table must never be serialized into / inserted from the manifest.-pub fn is_skip_table(table_name: &str) -> bool {- SKIP_TABLES.contains(&table_name)+/// True when a table is personal-only (see [`PERSONAL_TABLES`]): never part of a shared-folder manifest.+pub fn is_personal_table(table_name: &str) -> bool {+ PERSONAL_TABLES.contains(&table_name) || bucket_category_for(table_name).is_some()}/// The single-column primary key that addresses a row in `table_name`, shared with the merge layer@@ -69,12 +97,3 @@ pub fn is_skip_table(table_name: &str) -> bool {pub fn primary_key_for(table_name: &str) -> &'static str {crate::vault_merge::SYNCABLE_TABLES.iter().find(|t| t.name == table_name).map(|t| t.primary_key).unwrap_or("Id")}--/// Client-local SQLite table that carries the codec overflow inside the vault database itself (see-/// `CodecOverflow`): materialize writes a single row `{ Id: OVERFLOW_ROW_ID, Data: <json> }`, and-/// canonicalize / extract_bucket consume it to build the manifest.-pub const OVERFLOW_TABLE: &str = "CodecOverflows";--/// Fixed sentinel primary key of the single `OVERFLOW_TABLE` row (deterministic on purpose:-/// materialize output must not depend on a random source).-pub const OVERFLOW_ROW_ID: &str = "00000000-0000-0000-0000-00000000c0de";