From 66c3c13616091ff3cf0291155fa6d0afaf0d0f86 Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Tue, 10 Mar 2026 10:47:31 +0100 Subject: [PATCH 1/4] build(keystore): consolidate dependency tables It's harder to understand when individual dependencies get full sub-tables, so use inline tables for each of them, such that there is one relevant dependency table for each cfg setup. --- keystore/Cargo.toml | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/keystore/Cargo.toml b/keystore/Cargo.toml index 09a27e36f2..fd89132a66 100644 --- a/keystore/Cargo.toml +++ b/keystore/Cargo.toml @@ -55,23 +55,17 @@ core-foundation = "0.10" [target.'cfg(not(target_os = "unknown"))'.dependencies] async-fs = "2.2" blocking = "1.6" - -[target.'cfg(not(target_os = "unknown"))'.dependencies.rusqlite] -version = "0.37" -default-features = false -features = [ +rusqlite = { version = "0.37", default-features = false, features = [ "bundled-sqlcipher-vendored-openssl", "blob", "limits", "unlock_notify", "uuid", "functions", -] - -[target.'cfg(not(target_os = "unknown"))'.dependencies.refinery] -version = "0.9" -default-features = false -features = ["rusqlite"] +] } +refinery = { version = "0.9", default-features = false, features = [ + "rusqlite", +] } [target.'cfg(target_os = "unknown")'.dependencies] idb.workspace = true @@ -98,10 +92,7 @@ smol-macros.workspace = true macro_rules_attribute.workspace = true tempfile = "3.26.0" smol.workspace = true - -[target.'cfg(not(target_os = "unknown"))'.dev-dependencies.criterion] -version = "0.8" -features = ["async_futures", "html_reports"] +criterion = { version = "0.8", features = ["async_futures", "html_reports"] } [target.'cfg(target_os = "unknown")'.dev-dependencies] console_error_panic_hook = "0.1" From 0c19d00507ff13f4138f3fa7656c0f763f1df622 Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Tue, 10 Mar 2026 11:04:27 +0100 Subject: [PATCH 2/4] build(keystore): add sql deps unconditionally Rusqlite and refinery get compiled unconditionally, but we only include sqlcipher in non-os-unknown (i.e. non-wasm) builds. For os-unknown (wasm) builds, we instead include `sqlite-wasm-rs` and `sqlite-wasm-vfs` and the `sqlite3mc` feature. --- Cargo.lock | 193 +++++++++++++++++++++++++++++++++++++++++++- keystore/Cargo.toml | 20 +++-- 2 files changed, 204 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f93347e596..7632352e84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,18 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "accessory" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28e416a3ab45838bac2ab2d81b1088d738d7b2d2c5272a54d39366565a29bd80" +dependencies = [ + "macroific", + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "addr2line" version = "0.24.2" @@ -1162,6 +1174,8 @@ dependencies = [ "sha2", "smol", "smol-macros", + "sqlite-wasm-rs", + "sqlite-wasm-vfs", "tempfile", "thiserror 2.0.18", "twox-hash", @@ -1518,6 +1532,20 @@ dependencies = [ "wire-e2e-identity", ] +[[package]] +name = "delegate-display" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9926686c832494164c33a36bf65118f4bd6e704000b58c94681bf62e9ad67a74" +dependencies = [ + "impartial-ord", + "itoa", + "macroific", + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "der" version = "0.7.10" @@ -1908,6 +1936,18 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" +[[package]] +name = "fancy_constructor" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28a27643a5d05f3a22f5afd6e0d0e6e354f92d37907006f97b84b9cb79082198" +dependencies = [ + "macroific", + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "fantoccini" version = "0.22.1" @@ -2000,6 +2040,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + [[package]] name = "foreign-types" version = "0.3.2" @@ -2293,7 +2339,7 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ - "foldhash", + "foldhash 0.1.5", ] [[package]] @@ -2301,6 +2347,9 @@ name = "hashbrown" version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "foldhash 0.2.0", +] [[package]] name = "hashlink" @@ -2825,12 +2874,57 @@ dependencies = [ "icu_properties", ] +[[package]] +name = "impartial-ord" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab604ee7085efba6efc65e4ebca0e9533e3aff6cb501d7d77b211e3a781c6d5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "indenter" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +[[package]] +name = "indexed_db_futures" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69ff41758cbd104e91033bb53bc449bec7eea65652960c81eddf3fc146ecea19" +dependencies = [ + "accessory", + "cfg-if", + "delegate-display", + "derive_more", + "fancy_constructor", + "indexed_db_futures_macros_internal", + "js-sys", + "sealed", + "smallvec", + "thiserror 2.0.18", + "tokio", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "indexed_db_futures_macros_internal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caeba94923b68f254abef921cea7e7698bf4675fdd89d7c58bf1ed885b49a27d" +dependencies = [ + "macroific", + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -3220,6 +3314,54 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "670fdfda89751bc4a84ac13eaa63e205cf0fd22b4c9a5fbfa085b63c1f1d3a30" +[[package]] +name = "macroific" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89f276537b4b8f981bf1c13d79470980f71134b7bdcc5e6e911e910e556b0285" +dependencies = [ + "macroific_attr_parse", + "macroific_core", + "macroific_macro", +] + +[[package]] +name = "macroific_attr_parse" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad4023761b45fcd36abed8fb7ae6a80456b0a38102d55e89a57d9a594a236be9" +dependencies = [ + "proc-macro2", + "quote", + "sealed", + "syn 2.0.117", +] + +[[package]] +name = "macroific_core" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a7594d3c14916fa55bef7e9d18c5daa9ed410dd37504251e4b75bbdeec33e3" +dependencies = [ + "proc-macro2", + "quote", + "sealed", + "syn 2.0.117", +] + +[[package]] +name = "macroific_macro" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4da6f2ed796261b0a74e2b52b42c693bb6dee1effba3a482c49592659f824b3b" +dependencies = [ + "macroific_attr_parse", + "macroific_core", + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "markup5ever" version = "0.36.1" @@ -4665,6 +4807,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rsqlite-vfs" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8a1f2315036ef6b1fbacd1972e8ee7688030b0a2121edfc2a6550febd41574d" +dependencies = [ + "hashbrown 0.16.1", + "thiserror 2.0.18", +] + [[package]] name = "rstest" version = "0.26.1" @@ -5004,6 +5156,17 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "sealed" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22f968c5ea23d555e670b449c1c5e7b2fc399fdaec1d304a17cd48e288abc107" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "sec1" version = "0.7.3" @@ -5439,6 +5602,34 @@ dependencies = [ "sha2", ] +[[package]] +name = "sqlite-wasm-rs" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4206ed3a67690b9c29b77d728f6acc3ce78f16bf846d83c94f76400320181b" +dependencies = [ + "cc", + "js-sys", + "rsqlite-vfs", + "wasm-bindgen", +] + +[[package]] +name = "sqlite-wasm-vfs" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7a5c9ac229421d577bb5a9bb59048838509958b218dd4e0b3c1214a87c361e" +dependencies = [ + "indexed_db_futures", + "js-sys", + "rsqlite-vfs", + "thiserror 2.0.18", + "tokio", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "stabby" version = "36.2.2" diff --git a/keystore/Cargo.toml b/keystore/Cargo.toml index fd89132a66..7a33ff36b9 100644 --- a/keystore/Cargo.toml +++ b/keystore/Cargo.toml @@ -37,6 +37,16 @@ x509-cert = { workspace = true } openmls_traits = { workspace = true } openmls_basic_credential = { workspace = true } openmls_x509_credential = { workspace = true } +refinery = { version = "0.9", default-features = false, features = [ + "rusqlite", +] } +rusqlite = { version = "0.37", default-features = false, features = [ + "blob", + "limits", + "unlock_notify", + "uuid", + "functions", +] } serde = { workspace = true, features = ["derive"] } log = { workspace = true } proteus-traits = { workspace = true, optional = true } @@ -57,20 +67,14 @@ async-fs = "2.2" blocking = "1.6" rusqlite = { version = "0.37", default-features = false, features = [ "bundled-sqlcipher-vendored-openssl", - "blob", - "limits", - "unlock_notify", - "uuid", - "functions", -] } -refinery = { version = "0.9", default-features = false, features = [ - "rusqlite", ] } [target.'cfg(target_os = "unknown")'.dependencies] idb.workspace = true js-sys = "0.3" serde-wasm-bindgen = "0.6" +sqlite-wasm-rs = { version = "0.5.2", features = ["sqlite3mc"] } +sqlite-wasm-vfs = "0.2.0" wasm-bindgen = "0.2" wasm-bindgen-futures = "0.4" web-sys = { version = "0.3", features = ["console"] } From 13e5b0719d787cd479b6b84b51b9ff787fa3d7dd Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Tue, 10 Mar 2026 11:59:16 +0100 Subject: [PATCH 3/4] build(keystore): upgrade `rusqlite` to v0.38 This necessitates depending on an unreleased revision of `refinery`, unfortunately. --- Cargo.lock | 24 +++++++++++------------- keystore/Cargo.toml | 12 +++++++----- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7632352e84..1d5f4d5872 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2353,11 +2353,11 @@ dependencies = [ [[package]] name = "hashlink" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +checksum = "ea0b22561a9c04a7cb1a302c013e0259cd3b4bb619f145b32f72b8b4bcbed230" dependencies = [ - "hashbrown 0.15.2", + "hashbrown 0.16.1", ] [[package]] @@ -3213,9 +3213,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.35.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "133c182a6a2c87864fe97778797e46c7e999672690dc9fa3ee8e241aa4a9c13f" +checksum = "95b4103cffefa72eb8428cb6b47d6627161e51c2739fc5e3b734584157bc642a" dependencies = [ "cc", "openssl-sys", @@ -4631,8 +4631,7 @@ dependencies = [ [[package]] name = "refinery" version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52c427f2572afe5c6cbfa2b1bf40071c89bf1a8539e958ea582842f6f38dcfae" +source = "git+https://github.com/rust-db/refinery?rev=3abf61ec3836e835012346336fe144ca7fe9e9b7#3abf61ec3836e835012346336fe144ca7fe9e9b7" dependencies = [ "refinery-core", "refinery-macros", @@ -4641,8 +4640,7 @@ dependencies = [ [[package]] name = "refinery-core" version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702655abfc67f93a6f735e9fa4ace7d2e580633f8961f28acbfd7583ddce936c" +source = "git+https://github.com/rust-db/refinery?rev=3abf61ec3836e835012346336fe144ca7fe9e9b7#3abf61ec3836e835012346336fe144ca7fe9e9b7" dependencies = [ "async-trait", "cfg-if", @@ -4659,8 +4657,7 @@ dependencies = [ [[package]] name = "refinery-macros" version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5145756cdf293b5089dc6b4f103f1a1229cc55d67082c866f8c8289531c4b983" +source = "git+https://github.com/rust-db/refinery?rev=3abf61ec3836e835012346336fe144ca7fe9e9b7#3abf61ec3836e835012346336fe144ca7fe9e9b7" dependencies = [ "proc-macro2", "quote", @@ -4859,9 +4856,9 @@ dependencies = [ [[package]] name = "rusqlite" -version = "0.37.0" +version = "0.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "165ca6e57b20e1351573e3729b958bc62f0e48025386970b6e4d29e7a7e71f3f" +checksum = "f1c93dd1c9683b438c392c492109cb702b8090b2bfc8fed6f6e4eb4523f17af3" dependencies = [ "bitflags", "fallible-iterator", @@ -4869,6 +4866,7 @@ dependencies = [ "hashlink", "libsqlite3-sys", "smallvec", + "sqlite-wasm-rs", "uuid", ] diff --git a/keystore/Cargo.toml b/keystore/Cargo.toml index 7a33ff36b9..a6a9b4ce6a 100644 --- a/keystore/Cargo.toml +++ b/keystore/Cargo.toml @@ -19,6 +19,11 @@ serde = [] dummy-entity = [] [dependencies] +# we should depend on a real release instead of a git tag again once refinery +# releases a version containing https://github.com/rust-db/refinery/commit/3abf61ec3836e835012346336fe144ca7fe9e9b7 +refinery = { version = "0.9", git = "https://github.com/rust-db/refinery", rev = "3abf61ec3836e835012346336fe144ca7fe9e9b7", default-features = false, features = [ + "rusqlite", +] } thiserror.workspace = true derive_more.workspace = true hex.workspace = true @@ -37,10 +42,7 @@ x509-cert = { workspace = true } openmls_traits = { workspace = true } openmls_basic_credential = { workspace = true } openmls_x509_credential = { workspace = true } -refinery = { version = "0.9", default-features = false, features = [ - "rusqlite", -] } -rusqlite = { version = "0.37", default-features = false, features = [ +rusqlite = { version = "0.38", default-features = false, features = [ "blob", "limits", "unlock_notify", @@ -65,7 +67,7 @@ core-foundation = "0.10" [target.'cfg(not(target_os = "unknown"))'.dependencies] async-fs = "2.2" blocking = "1.6" -rusqlite = { version = "0.37", default-features = false, features = [ +rusqlite = { version = "0.38", default-features = false, features = [ "bundled-sqlcipher-vendored-openssl", ] } From b013e6371d0835b10cee67c47b1258f4b4e46a72 Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Tue, 10 Mar 2026 16:37:29 +0100 Subject: [PATCH 4/4] build(keystore): add `fallible_uint` feature to rusqlite In v0.38, rusqlite fixed a logical problem: casting values to/from unsigned 64-bit values was sometimes causing runtime errors, because internally sqlite only knows about signed 64-bit integers. The problem: https://github.com/rusqlite/rusqlite/issues/1722 The fix: https://github.com/rusqlite/rusqlite/pull/1732 This was a problem for us because we use u64s to represent timestamps in the keystore. This commit chooses to just add the feature flag which reenables the old behavior. We're not going to be maintaining this code anymore once the potential to overflow an i64 with a unix timestamp is a reasonable possibility, and we're not using that type in other contexts, so we should be fine. I did consider the alternative of changing the underlying type from u64 to i64. However, that would have meant a cascading series of pointless changes all the way up to the ffi layer, and it just did not seem worth it. So I rejected that for now. --- keystore/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/keystore/Cargo.toml b/keystore/Cargo.toml index a6a9b4ce6a..3af89fef15 100644 --- a/keystore/Cargo.toml +++ b/keystore/Cargo.toml @@ -48,6 +48,7 @@ rusqlite = { version = "0.38", default-features = false, features = [ "unlock_notify", "uuid", "functions", + "fallible_uint", ] } serde = { workspace = true, features = ["derive"] } log = { workspace = true }