Skip to content

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

Cleanup unused methods, tests and artifacts (#2159)

Leendert de Borst888504b276a7
diff --git a/apps/browser-extension/firefox-sources/README.md b/apps/browser-extension/firefox-sources/README.md
deleted file mode 100644
index cf2d434e0..000000000
--- a/apps/browser-extension/firefox-sources/README.md
+++ /dev/null
@@ -1,36 +0,0 @@
-# AliasVault browser extension: source archive
-
-This archive contains the source code of the AliasVault browser extension as submitted to
-addons.mozilla.org, together with the shared packages that the extension is built from. It mirrors the
-layout of the public repository at https://github.com/aliasvault/aliasvault, which also holds the
-server and mobile app sources that are not needed to build the extension.
-
-## Contents
-
-| Path | Description |
-| --- | --- |
-| `apps/browser-extension` | The browser extension itself (WXT, React, TypeScript) |
-| `core/client` | Shared client logic, linked as a `file:` dependency |
-| `core/models` | Shared data models, linked as a `file:` dependency |
-| `core/vault` | Shared vault schema definitions, linked as a `file:` dependency |
-| `core/rust` | Rust sources of the WebAssembly module that the extension bundles |
-
-## How to build
-
-```bash
-cd apps/browser-extension
-npm install
-npm run zip:firefox
-```
-
-This writes the unpacked extension to `apps/browser-extension/dist/firefox-mv2` and the packaged
-extension to `apps/browser-extension/dist/aliasvault-browser-extension-<version>-firefox.zip`.
-
-Node.js and npm are the only requirements; release builds are made with Node.js 24. The `npm install`
-step also installs the dependencies of the linked `core/*` packages, so no other install is needed.
-
-## WebAssembly module
-
-`core/client/wasm` holds the prebuilt WebAssembly module that the extension bundles, and the build above
-uses it as is. To rebuild it from the Rust sources in `core/rust`, install the Rust toolchain
-(https://rustup.rs) and run `npm run build:rust` from `apps/browser-extension`.
diff --git a/apps/mobile-app/utils/SqliteClient.ts b/apps/mobile-app/utils/SqliteClient.ts
index 87462055e..5f85d2e6b 100644
--- a/apps/mobile-app/utils/SqliteClient.ts
+++ b/apps/mobile-app/utils/SqliteClient.ts
@@ -10,7 +10,6 @@ import { PasskeyRepository } from '@aliasvault/client/database/repositories/Pass
import { SettingsRepository } from '@aliasvault/client/database/repositories/SettingsRepository';
import { VaultSqlGenerator, VaultVersion, checkVersionCompatibility, extractVersionFromMigrationId } from '@aliasvault/vault';
import { VaultVersionIncompatibleError } from '@aliasvault/client/api/errors/VaultVersionIncompatibleError';
-import { VaultCodec } from '@aliasvault/client/sync/VaultCodec';
import NativeVaultManager from '@/specs/NativeVaultManager';
import { NativeDatabaseClient } from '@/platform/NativeDatabaseClient';
@@ -300,7 +299,7 @@ class SqliteClient {
}
const localMigrationId = await this.getLatestMigrationId();
- const schemaMigrationId = VaultCodec.getSchemaMigrationId(new VaultSqlGenerator().getCompleteSchemaSql());
+ const schemaMigrationId = new VaultSqlGenerator().getCompleteSchemaMigrationId();
// An unstamped database or an unreadable schema constant gives no evidence of staleness; don't block on a guess.
if (!localMigrationId || !schemaMigrationId) {
diff --git a/core/client/src/crypto/EncryptionUtility.crypto.test.ts b/core/client/src/crypto/EncryptionUtility.crypto.test.ts
index ae2ac34cb..54cc7978b 100644
--- a/core/client/src/crypto/EncryptionUtility.crypto.test.ts
+++ b/core/client/src/crypto/EncryptionUtility.crypto.test.ts
@@ -154,15 +154,6 @@ describe('generateRsaKeyPair (legacy JWK path, used by vault email decrypt)', ()
expect(new TextDecoder().decode(plaintextBytes)).toBe('email body');
});
-
- it('exposes private fields in JS string (leak surface the non-extractable variant closes)', async () => {
- const { privateKey } = await EncryptionUtility.generateRsaKeyPair();
-
- const jwk = JSON.parse(privateKey);
- expect(jwk.d).toBeDefined();
- expect(jwk.p).toBeDefined();
- expect(jwk.q).toBeDefined();
- });
});
describe('email RSA private key cache', () => {
diff --git a/core/client/src/database/SqliteClient.ts b/core/client/src/database/SqliteClient.ts
index 1bf481ac3..554932f2b 100644
--- a/core/client/src/database/SqliteClient.ts
+++ b/core/client/src/database/SqliteClient.ts
@@ -5,7 +5,6 @@ import { VaultVersionIncompatibleError } from '../api/errors/VaultVersionIncompa
import { StorageKeys } from '../constants/StorageKeys';
import { getPlatform } from '../platform/ClientPlatform';
import { TranslatableMessage } from '../platform/TranslatableMessage';
-import { VaultCodec } from '../sync/VaultCodec';
import { base64ToBytes, bytesToBase64 } from '../utilities/Base64';
import { logDefect } from '../utilities/Diagnostics';
import { detectImageMimeType } from '../utilities/ImageType';
@@ -514,8 +513,8 @@ export class SqliteClient implements ISyncDatabaseClient {
return false;
}
- const localMigrationId = VaultCodec.getLatestMigrationId(this);
- const schemaMigrationId = VaultCodec.getSchemaMigrationId(new VaultSqlGenerator().getCompleteSchemaSql());
+ const localMigrationId = this.getLatestMigrationId();
+ const schemaMigrationId = new VaultSqlGenerator().getCompleteSchemaMigrationId();
// An unstamped database or an unreadable schema constant gives no evidence of staleness; don't block on a guess.
if (!localMigrationId || !schemaMigrationId) {
@@ -525,6 +524,17 @@ export class SqliteClient implements ISyncDatabaseClient {
return localMigrationId < schemaMigrationId;
}
+ /**
+ * The latest EF migration id the vault is stamped with, or an empty string when it carries none.
+ */
+ private getLatestMigrationId(): string {
+ try {
+ return this.executeQuery<{ MigrationId: string }>('SELECT MigrationId FROM __EFMigrationsHistory ORDER BY MigrationId DESC LIMIT 1')[0]?.MigrationId ?? '';
+ } catch {
+ return '';
+ }
+ }
+
/**
* Convert binary data to a base64 encoded image source.
* @param bytes - Binary image data
diff --git a/core/client/src/sync/VaultCodec.ts b/core/client/src/sync/VaultCodec.ts
deleted file mode 100644
index 8bee33604..000000000
--- a/core/client/src/sync/VaultCodec.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * VaultCodec: the EF migration ids that tell whether a local vault's schema is current.
- */
-
-import type SqliteClient from '../database/SqliteClient';
-
-/**
- * VaultCodec: reads the migration a vault was stamped with and the one a schema would stamp.
- */
-export class VaultCodec {
- /**
- * Read the latest EF migration ID from `__EFMigrationsHistory` (empty string if not stamped).
- * @param sqliteClient - opened client
- */
- public static getLatestMigrationId(sqliteClient: SqliteClient): string {
- try {
- const rows = sqliteClient.executeQuery<{ MigrationId: string }>(
- 'SELECT MigrationId FROM __EFMigrationsHistory ORDER BY MigrationId DESC LIMIT 1'
- );
- return rows[0]?.MigrationId ?? '';
- } catch {
- return '';
- }
- }
-
- /**
- * The migration ID a freshly created database would be stamped with.
- * @param schemaSql - the COMPLETE_SCHEMA_SQL string for the target client version
- */
- public static getSchemaMigrationId(schemaSql: string): string {
- const ids = [...schemaSql.matchAll(/INSERT\s+INTO\s+"__EFMigrationsHistory"[^;]*?VALUES\s*\(\s*'([^']+)'/gi)].map(m => m[1]);
- return ids.length === 0 ? '' : ids.reduce((a, b) => (b > a ? b : a));
- }
-}
-
-export default VaultCodec;
diff --git a/core/rust/src/vault_codec/sharing_tests.rs b/core/rust/src/vault_codec/sharing_tests.rs
index f38db5e6a..07b93f97f 100644
--- a/core/rust/src/vault_codec/sharing_tests.rs
+++ b/core/rust/src/vault_codec/sharing_tests.rs
@@ -6,8 +6,7 @@
//! local vault holds every row) and a recipient (whose personal manifest knows nothing of the share).
use super::*;
-use super::test_support::{b64, row, table};
-use super::tests::{fitting_schema, materialize_manifests, materialize_input, stamp_unstamped};
+use super::test_support::{b64, materialize_input, materialize_manifests, row, stamp_unstamped, table};
use super::types::{is_bucketed_table, is_personal_table, manifest_scoped_tables, SCHEMA_VERSION};
use crate::vault_model::names::LOGO_KIND_FAVICON;
use crate::vault_model::OVERFLOW_TABLE;
@@ -1426,18 +1425,6 @@ fn extract_encryption_key_for_public_key_skips_deleted_and_returns_none_on_miss(
assert!(extract_encryption_key_for_public_key(&out.first().manifest, "pub-unknown").is_none());
}
-#[test]
-fn extract_encryption_key_for_public_key_json_sibling_roundtrips() {
- let out = canonicalize_from_sqlite(input_with_shares(owner_tables(), vec![])).unwrap();
- let manifest_json = serde_json::to_string(&out.first().manifest).unwrap();
- let key_json = crate::error::json_call(&manifest_json, |m: Manifest| Ok(extract_encryption_key_for_public_key(&m, "pub"))).unwrap();
- let key: serde_json::Value = serde_json::from_str(&key_json).unwrap();
- assert_eq!(key["PrivateKey"], json!("priv"));
-
- let miss = crate::error::json_call(&manifest_json, |m: Manifest| Ok(extract_encryption_key_for_public_key(&m, "nope"))).unwrap();
- assert_eq!(miss, "null");
-}
-
// ─────────────────────────────────────────────────────────────────────────────
// Wire-format compatibility
// ─────────────────────────────────────────────────────────────────────────────
@@ -1472,22 +1459,6 @@ fn manifest_specs_deserialize_from_camel_case_json() {
assert!(value["manifests"][1]["manifest"].get("anchorFolderId").is_none(), "folder anchoring is a client concern, never persisted");
}
-#[test]
-fn materialize_input_accepts_every_manifest_in_one_list_from_json() {
- let owner = canonicalize_owner();
- let schema = fitting_schema([&owner.first().manifest, &owner.rest()[0].manifest], &owner.data_buckets.clone());
- let input_json = json!({
- "manifests": [owner.first().manifest, owner.rest()[0].manifest],
- "dataBuckets": owner.data_buckets.clone(),
- "schemaColumns": schema,
- })
- .to_string();
- let out_json = crate::error::json_call(&input_json, |input: MaterializeInput| materialize_as_sqlite(input)).unwrap();
- let out: MaterializedTables = serde_json::from_str(&out_json).unwrap();
- let items = out.tables.iter().find(|t| t.name == "Items").unwrap();
- assert_eq!(items.records.len(), 4);
-}
-
/// A vault is made of manifests; with none there is nothing to combine into and no data-model version
/// to report, so materialize refuses rather than emitting an empty vault.
#[test]
@@ -1793,19 +1764,6 @@ fn split_routes_folder_keypair_into_its_manifest_and_never_the_personal_one() {
assert_eq!(rows(&out.first().manifest, "EncryptionKeys")[0]["ManifestId"], json!(PERSONAL_M));
}
-#[test]
-fn split_drops_a_keypair_stamped_for_a_manifest_that_is_not_in_this_push() {
- // A key row whose stamp names no manifest being written is dropped, never re-homed into the personal manifest:
- // a stale key falling back would resurrect the old keypair if that manifest is ever re-created.
- let out = canonicalize_from_sqlite(input_with_shares(
- owner_tables_with_folder_keys(vec![folder_key("sfk-gone", "m-deleted", "pub-folder", 1)]),
- vec![spec("f-shared")],
- ))
- .unwrap();
- assert!(rows(&out.rest()[0].manifest, "EncryptionKeys").is_empty());
- assert!(!ids(rows(&out.first().manifest, "EncryptionKeys")).contains(&"sfk-gone"));
-}
-
#[test]
fn split_drops_folder_keypair_whose_scope_is_not_shared() {
// A key row stamped for a manifest that is not part of this push (revoked, deleted, or fabricated
diff --git a/core/rust/src/vault_codec/test_support.rs b/core/rust/src/vault_codec/test_support.rs
index 557730f96..652286446 100644
--- a/core/rust/src/vault_codec/test_support.rs
+++ b/core/rust/src/vault_codec/test_support.rs
@@ -1,6 +1,12 @@
//! Fixtures shared by the codec, sharing and pruner tests.
-use super::manifest::{CodecRecord, CodecTableData};
+use std::collections::{HashMap, HashSet};
+
+use serde_json::json;
+
+use super::manifest::{CodecRecord, CodecTableData, DataBucket, Manifest, MaterializeInput};
+use super::types::manifest_scoped_tables;
+use crate::vault_model::{MANIFESTS_TABLE, MANIFEST_ID_COL};
/// Standard base64 of `bytes`, the inline byte spelling the tests hand the codec.
pub(crate) fn b64(bytes: &[u8]) -> String {
@@ -26,3 +32,57 @@ pub(crate) fn now_iso() -> String {
pub(crate) fn days_ago_iso(days: i64) -> String {
crate::timestamp::iso_utc(&(chrono::Utc::now() - chrono::Duration::days(days)))
}
+
+/// Stamp every row of a manifest-scoped table that carries no `ManifestId`, leaving rows that already name one alone.
+pub(crate) fn stamp_unstamped(mut tables: Vec<CodecTableData>, manifest_id: &str) -> Vec<CodecTableData> {
+ let scoped = manifest_scoped_tables();
+ for table in tables.iter_mut().filter(|t| scoped.contains(&t.name.as_str())) {
+ for record in table.records.iter_mut() {
+ let unstamped = record.get(MANIFEST_ID_COL).and_then(|v| v.as_str()).is_none_or(str::is_empty);
+ if unstamped {
+ record.insert(MANIFEST_ID_COL.to_string(), json!(manifest_id));
+ }
+ }
+ }
+ tables
+}
+
+/// A schema map that knows every table and column the given manifests and buckets carry, so
+/// materialize fits all of it and splits nothing off into overflow.
+pub(crate) fn fitting_schema<'a>(manifests: impl IntoIterator<Item = &'a Manifest>, buckets: &[DataBucket]) -> HashMap<String, Vec<String>> {
+ let mut schema: HashMap<String, HashSet<String>> = HashMap::new();
+ let mut absorb = |tables: &HashMap<String, Vec<CodecRecord>>| {
+ for (name, records) in tables {
+ let columns = schema.entry(name.clone()).or_default();
+ columns.insert(MANIFEST_ID_COL.to_string());
+ for record in records {
+ columns.extend(record.keys().cloned());
+ }
+ }
+ };
+ for manifest in manifests {
+ absorb(&manifest.tables);
+ }
+ for bucket in buckets {
+ absorb(&bucket.tables);
+ }
+
+ // Local bookkeeping materialize emits itself; it is never present in a manifest to be absorbed above.
+ schema.insert(MANIFESTS_TABLE.to_string(), ["Id", "Name"].iter().map(|c| c.to_string()).collect());
+
+ schema.into_iter().map(|(name, columns)| (name, columns.into_iter().collect())).collect()
+}
+
+/// A `MaterializeInput` for a personal manifest plus the other manifests combined into it, with the
+/// buckets hung off it and a schema fitted to everything they carry (see [`fitting_schema`]).
+pub(crate) fn materialize_input(own: Manifest, others: Vec<Manifest>, data_buckets: Vec<DataBucket>) -> MaterializeInput {
+ let schema = fitting_schema(std::iter::once(&own).chain(others.iter()), &data_buckets);
+ MaterializeInput { manifests: std::iter::once(own).chain(others).collect(), data_buckets, schema_columns: schema }
+}
+
+/// A `MaterializeInput` from an explicit manifest list, for the tests that assert on inputs
+/// [`materialize_input`] cannot express (an empty manifest list, for one).
+pub(crate) fn materialize_manifests(manifests: Vec<Manifest>, data_buckets: Vec<DataBucket>) -> MaterializeInput {
+ let schema = fitting_schema(manifests.iter(), &data_buckets);
+ MaterializeInput { manifests, data_buckets, schema_columns: schema }
+}
diff --git a/core/rust/src/vault_codec/tests.rs b/core/rust/src/vault_codec/tests.rs
index a66d1f9af..793d797a1 100644
--- a/core/rust/src/vault_codec/tests.rs
+++ b/core/rust/src/vault_codec/tests.rs
@@ -1,11 +1,11 @@
//! Unit tests for vault_codec, covering the round-trip contract.
use super::*;
-use super::test_support::{b64, row};
+use super::test_support::{b64, materialize_input, row, stamp_unstamped};
use super::types::{bucket_category_for, SCHEMA_VERSION};
use crate::vault_model::names::LOGO_KIND_FAVICON;
use crate::vault_model::{MANIFESTS_TABLE, MANIFEST_ID_COL, OVERFLOW_ROW_ID, OVERFLOW_TABLE};
use serde_json::json;
-use std::collections::{HashMap, HashSet};
+use std::collections::HashMap;
/// The rows of `table` inside the data bucket for `category` (empty if absent).
fn bucket_rows<'a>(out: &'a CanonicalizedVault, category: &str, table: &str) -> &'a [CodecRecord] {
@@ -35,20 +35,6 @@ fn basic_input(tables: Vec<CodecTableData>) -> CanonicalizeInput {
}
}
-/// Stamp every row of a manifest-scoped table that carries no `ManifestId`, leaving rows that already name one alone.
-pub(super) fn stamp_unstamped(mut tables: Vec<CodecTableData>, manifest_id: &str) -> Vec<CodecTableData> {
- let scoped = super::types::manifest_scoped_tables();
- for table in tables.iter_mut().filter(|t| scoped.contains(&t.name.as_str())) {
- for record in table.records.iter_mut() {
- let unstamped = record.get(MANIFEST_ID_COL).and_then(|v| v.as_str()).is_none_or(str::is_empty);
- if unstamped {
- record.insert(MANIFEST_ID_COL.to_string(), json!(manifest_id));
- }
- }
- }
- tables
-}
-
#[test]
fn canonicalize_from_sqlite_splits_settings_into_data_bucket() {
let input = basic_input(vec![
@@ -248,13 +234,6 @@ fn unpack_payload_rejects_tampered_payload() {
assert!(unpack_payload(&packed).is_err());
}
-#[test]
-fn content_hash_is_key_order_independent() {
- let a = json!({ "x": 1, "y": 2 });
- let b = json!({ "y": 2, "x": 1 });
- assert_eq!(hash::content_hash(&a), hash::content_hash(&b));
-}
-
#[test]
fn validate_manifest_catches_broken_fk() {
let mut manifest = canonicalize_from_sqlite(basic_input(vec![
@@ -685,21 +664,6 @@ fn materialize_drops_overflow_table_smuggled_into_a_manifest() {
assert_eq!(overflow_table.records[0]["Id"], json!(OVERFLOW_ROW_ID), "smuggled row dropped, only the codec's own row remains");
}
-#[test]
-fn json_siblings_roundtrip() {
- let input = basic_input(vec![CodecTableData { name: "Items".to_string(), records: vec![row(&[("Id", json!("i1"))])] }]);
- let input_json = serde_json::to_string(&input).unwrap();
- let canonicalized_json = crate::error::json_call(&input_json, |input: CanonicalizeInput| canonicalize_from_sqlite(input)).unwrap();
- let canonicalized: CanonicalizedVault = serde_json::from_str(&canonicalized_json).unwrap();
- assert!(canonicalized.first().manifest.tables.contains_key("Items"));
-
- let schema = fitting_schema(std::iter::once(&canonicalized.first().manifest), &canonicalized.data_buckets.clone());
- let input_value = json!({ "manifests": [canonicalized.first().manifest], "dataBuckets": canonicalized.data_buckets.clone(), "schemaColumns": schema });
- let materialized_json = crate::error::json_call(&input_value.to_string(), |input: MaterializeInput| materialize_as_sqlite(input)).unwrap();
- let materialized: MaterializedTables = serde_json::from_str(&materialized_json).unwrap();
- assert!(materialized.tables.iter().any(|t| t.name == "Items"));
-}
-
#[test]
fn content_fingerprint_ignores_key_order_and_whitespace() {
let a = compute_content_fingerprint(r#"{"schemaVersion":1,"tables":{"Items":[{"Id":"x","Name":"n"}]}}"#);
@@ -724,24 +688,6 @@ fn content_fingerprint_detects_content_change() {
assert_ne!(a, b);
}
-#[test]
-fn content_fingerprint_matches_serialized_manifest_roundtrip() {
- // A manifest serialized by this codec and the same JSON re-parsed/re-serialized by another producer
- // (different key order) must fingerprint identically.
- let manifest = Manifest {
- name: None,
- schema_version: 1,
- manifest_salt: "00ff".into(),
- canonicalized_at: "2026-01-01T00:00:00.000Z".into(),
- manifest_id: "m-fp".into(),
- tables: std::collections::HashMap::from([(String::from("Items"), vec![])]),
- extra: std::collections::HashMap::new(),
- };
- let serialized = serde_json::to_string(&manifest).unwrap();
- let reordered = r#"{"tables":{"Items":[]},"manifestSalt":"00ff","schemaVersion":1,"manifestId":"m-fp","canonicalizedAt":"1999-12-31T23:59:59.000Z"}"#;
- assert_eq!(compute_content_fingerprint(&serialized), compute_content_fingerprint(reordered));
-}
-
#[test]
fn canonicalize_requires_manifest_id() {
let mut input = basic_input(vec![CodecTableData { name: "Items".to_string(), records: vec![] }]);
@@ -789,50 +735,6 @@ fn validate_manifest_requires_manifest_id() {
assert!(result.failed_rules.iter().any(|r| r == "manifestId-missing"));
}
-// ─────────────────────────────────────────────────────────────────────────────
-// Shared test helpers
-// ─────────────────────────────────────────────────────────────────────────────
-
-/// A schema map that knows every table and column the given manifests and buckets carry, so
-/// materialize fits all of it and splits nothing off into overflow.
-pub(super) fn fitting_schema<'a>(manifests: impl IntoIterator<Item = &'a Manifest>, buckets: &[DataBucket]) -> HashMap<String, Vec<String>> {
- let mut schema: HashMap<String, HashSet<String>> = HashMap::new();
- let mut absorb = |tables: &HashMap<String, Vec<CodecRecord>>| {
- for (name, records) in tables {
- let columns = schema.entry(name.clone()).or_default();
- columns.insert(MANIFEST_ID_COL.to_string());
- for record in records {
- columns.extend(record.keys().cloned());
- }
- }
- };
- for manifest in manifests {
- absorb(&manifest.tables);
- }
- for bucket in buckets {
- absorb(&bucket.tables);
- }
-
- // Local bookkeeping materialize emits itself; it is never present in a manifest to be absorbed above.
- schema.insert(MANIFESTS_TABLE.to_string(), ["Id", "Name"].iter().map(|c| c.to_string()).collect());
-
- schema.into_iter().map(|(name, columns)| (name, columns.into_iter().collect())).collect()
-}
-
-/// A `MaterializeInput` for a personal manifest plus the other manifests combined into it, with the
-/// buckets hung off it and a schema fitted to everything they carry (see [`fitting_schema`]).
-pub(super) fn materialize_input(own: Manifest, others: Vec<Manifest>, data_buckets: Vec<DataBucket>) -> MaterializeInput {
- let schema = fitting_schema(std::iter::once(&own).chain(others.iter()), &data_buckets);
- MaterializeInput { manifests: std::iter::once(own).chain(others).collect(), data_buckets, schema_columns: schema }
-}
-
-/// A `MaterializeInput` from an explicit manifest list, for the tests that assert on inputs
-/// [`materialize_input`] cannot express (an empty manifest list, for one).
-pub(super) fn materialize_manifests(manifests: Vec<Manifest>, data_buckets: Vec<DataBucket>) -> MaterializeInput {
- let schema = fitting_schema(manifests.iter(), &data_buckets);
- MaterializeInput { manifests, data_buckets, schema_columns: schema }
-}
-
// ---------------------------------------------------------------------------
// Derived ids + wire shape (see normalize.rs)
// ---------------------------------------------------------------------------
diff --git a/core/vault/src/sql/VaultSqlGenerator.ts b/core/vault/src/sql/VaultSqlGenerator.ts
index ad813b887..6e1dc30a7 100644
--- a/core/vault/src/sql/VaultSqlGenerator.ts
+++ b/core/vault/src/sql/VaultSqlGenerator.ts
@@ -248,4 +248,12 @@ export class VaultSqlGenerator {
getCompleteSchemaSql(): string {
return COMPLETE_SCHEMA_SQL;
}
+
+ /**
+ * Get the EF migration id the complete schema stamps a new vault with (empty string if none).
+ */
+ getCompleteSchemaMigrationId(): string {
+ const ids = [...COMPLETE_SCHEMA_SQL.matchAll(/INSERT\s+INTO\s+"__EFMigrationsHistory"[^;]*?VALUES\s*\(\s*'([^']+)'/gi)].map(m => m[1]);
+ return ids.length === 0 ? '' : ids.reduce((a, b) => (b > a ? b : a));
+ }
}
\ No newline at end of file