π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Consolidate shared binding libraries
Manav Rathic777d2892dc3
diff --git a/mobile/apps/locker/flutter_rust_bridge.yaml b/mobile/apps/locker/flutter_rust_bridge.yamlindex 96edd2ee87..a2589f39ba 100644--- a/mobile/apps/locker/flutter_rust_bridge.yaml+++ b/mobile/apps/locker/flutter_rust_bridge.yaml@@ -1,4 +1,5 @@-rust_input: crate::api, ente-frb-contacts, ente-frb-core+rust_input: crate::api, ente-frb-lib+rust_features: [ente-frb-lib/contacts]rust_root: ../../../rust/bindings/frb/locker/dart_output: lib/src/rustdart_entrypoint_class_name: EnteLockerRustdiff --git a/mobile/apps/locker/lib/services/authenticated_session.dart b/mobile/apps/locker/lib/services/authenticated_session.dartindex e419b49ec7..a81fa0b1cc 100644--- a/mobile/apps/locker/lib/services/authenticated_session.dart+++ b/mobile/apps/locker/lib/services/authenticated_session.dart@@ -1,5 +1,5 @@import 'package:ente_contacts/contacts.dart';-import 'package:locker/src/rust/third_party/ente_frb_core.dart';+import 'package:locker/src/rust/third_party/ente_frb_lib/session.dart';Session? _session;String? _sessionKey;diff --git a/mobile/apps/locker/lib/services/contacts.dart b/mobile/apps/locker/lib/services/contacts.dartindex aa1467ad44..db8e887275 100644--- a/mobile/apps/locker/lib/services/contacts.dart+++ b/mobile/apps/locker/lib/services/contacts.dart@@ -1,8 +1,8 @@import 'dart:typed_data';import 'package:ente_contacts/contacts.dart';-import 'package:locker/src/rust/third_party/ente_frb_contacts.dart' as rust;-import 'package:locker/src/rust/third_party/ente_frb_core.dart';+import 'package:locker/src/rust/third_party/ente_frb_lib/contacts.dart' as rust;+import 'package:locker/src/rust/third_party/ente_frb_lib/session.dart';Future<ContactOutput<ContactRecord>> createContact(Session session,diff --git a/mobile/apps/locker/lib/services/legacy_kit.dart b/mobile/apps/locker/lib/services/legacy_kit.dartindex db5423708a..8b77655d62 100644--- a/mobile/apps/locker/lib/services/legacy_kit.dart+++ b/mobile/apps/locker/lib/services/legacy_kit.dart@@ -2,7 +2,7 @@ import 'package:ente_base/models/key_attributes.dart';import 'package:ente_legacy/errors.dart';import 'package:ente_legacy/models/legacy_kit_models.dart';import 'package:locker/src/rust/api/legacy.dart' as rust;-import 'package:locker/src/rust/third_party/ente_frb_core.dart';+import 'package:locker/src/rust/third_party/ente_frb_lib/session.dart';Future<List<LegacyKit>> getLegacyKits(Session session) async {final kits = await rust.kits(session: session);diff --git a/mobile/apps/photos/flutter_rust_bridge.yaml b/mobile/apps/photos/flutter_rust_bridge.yamlindex 952d6e0d5f..3dec148cf3 100644--- a/mobile/apps/photos/flutter_rust_bridge.yaml+++ b/mobile/apps/photos/flutter_rust_bridge.yaml@@ -1,4 +1,5 @@-rust_input: crate::api, ente-frb-contacts, ente-frb-core+rust_input: crate::api, ente-frb-lib+rust_features: [ente-frb-lib/contacts]rust_root: ../../../rust/bindings/frb/photos/dart_output: lib/src/rustdart_entrypoint_class_name: EntePhotosRustdiff --git a/mobile/apps/photos/lib/services/authenticated_session.dart b/mobile/apps/photos/lib/services/authenticated_session.dartindex 698fb062c7..acd746baca 100644--- a/mobile/apps/photos/lib/services/authenticated_session.dart+++ b/mobile/apps/photos/lib/services/authenticated_session.dart@@ -1,5 +1,5 @@import 'package:ente_contacts/contacts.dart';-import 'package:photos/src/rust/third_party/ente_frb_core.dart';+import 'package:photos/src/rust/third_party/ente_frb_lib/session.dart';Session? _session;String? _sessionKey;diff --git a/mobile/apps/photos/lib/services/contacts.dart b/mobile/apps/photos/lib/services/contacts.dartindex f23e212394..f144a5be26 100644--- a/mobile/apps/photos/lib/services/contacts.dart+++ b/mobile/apps/photos/lib/services/contacts.dart@@ -1,8 +1,8 @@import 'dart:typed_data';import 'package:ente_contacts/contacts.dart';-import 'package:photos/src/rust/third_party/ente_frb_contacts.dart' as rust;-import 'package:photos/src/rust/third_party/ente_frb_core.dart';+import 'package:photos/src/rust/third_party/ente_frb_lib/contacts.dart' as rust;+import 'package:photos/src/rust/third_party/ente_frb_lib/session.dart';Future<ContactOutput<ContactRecord>> createContact(Session session,diff --git a/rust/Cargo.lock b/rust/Cargo.lockindex a3c10ecab2..362f000ca3 100644--- a/rust/Cargo.lock+++ b/rust/Cargo.lock@@ -2568,19 +2568,10 @@ dependencies = [][[package]]-name = "ente-frb-contacts"+name = "ente-frb-lib"version = "0.0.0"dependencies = ["ente-contacts",- "ente-core",- "ente-frb-core",- "flutter_rust_bridge",-]--[[package]]-name = "ente-frb-core"-version = "0.0.0"-dependencies = ["ente-core","flutter_rust_bridge",]@@ -2627,7 +2618,7 @@ dependencies = ["ente-accounts","ente-core","ente-legacy",- "ente-wasm-core",+ "ente-wasm-lib","ente-wasm-log","js-sys","serde",@@ -2651,8 +2642,7 @@ dependencies = ["ente-accounts","ente-assets","ente-core",- "ente-frb-contacts",- "ente-frb-core",+ "ente-frb-lib","ente-frb-log","ente-legacy","ente-ml",@@ -2663,8 +2653,7 @@ dependencies = [name = "ente-locker-wasm"version = "0.0.0"dependencies = [- "ente-wasm-contacts",- "ente-wasm-core",+ "ente-wasm-lib","ente-wasm-log",]@@ -2738,8 +2727,7 @@ name = "ente-photos-frb"version = "0.0.0"dependencies = ["ente-cast",- "ente-frb-contacts",- "ente-frb-core",+ "ente-frb-lib","ente-frb-log","ente-image","ente-location",@@ -2765,8 +2753,7 @@ dependencies = [name = "ente-photos-wasm"version = "0.0.0"dependencies = [- "ente-wasm-contacts",- "ente-wasm-core",+ "ente-wasm-lib","ente-wasm-log",]@@ -2858,12 +2845,11 @@ dependencies = [][[package]]-name = "ente-wasm-contacts"+name = "ente-wasm-lib"version = "0.0.0"dependencies = ["ente-contacts","ente-core",- "ente-wasm-core","js-sys","serde","serde-wasm-bindgen",@@ -2872,16 +2858,6 @@ dependencies = ["wasm-bindgen-futures",]-[[package]]-name = "ente-wasm-core"-version = "0.0.0"-dependencies = [- "ente-core",- "js-sys",- "thiserror 2.0.18",- "wasm-bindgen",-]-[[package]]name = "ente-wasm-log"version = "0.0.0"diff --git a/rust/Cargo.toml b/rust/Cargo.tomlindex 450626a65d..190f843138 100644--- a/rust/Cargo.toml+++ b/rust/Cargo.toml@@ -4,8 +4,7 @@ members = ["apps/cli","apps/codegen","apps/ensu/src-tauri",- "bindings/frb/contacts",- "bindings/frb/core",+ "bindings/frb/lib","bindings/frb/locker","bindings/frb/log","bindings/frb/photos",@@ -14,11 +13,10 @@ members = ["bindings/uniffi/ensu","bindings/uniffi/log","bindings/wasm/cast",- "bindings/wasm/contacts",- "bindings/wasm/core","bindings/wasm/core-wasm","bindings/wasm/ensu","bindings/wasm/legacy",+ "bindings/wasm/lib","bindings/wasm/log","bindings/wasm/locker","bindings/wasm/paste",@@ -49,8 +47,7 @@ ente-contacts = { path = "crates/contacts" }ente-core = { path = "crates/core" }ente-ensu = { path = "crates/ensu" }ente-ensu-crypto = { path = "crates/ensu-crypto" }-ente-frb-contacts = { path = "bindings/frb/contacts" }-ente-frb-core = { path = "bindings/frb/core" }+ente-frb-lib = { path = "bindings/frb/lib" }ente-frb-log = { path = "bindings/frb/log" }ente-image = { path = "crates/image" }ente-legacy = { path = "crates/legacy" }@@ -61,8 +58,7 @@ ente-photos = { path = "crates/photos" }ente-space = { path = "crates/space" }ente-test-support = { path = "crates/test-support" }ente-uniffi-log = { path = "bindings/uniffi/log" }-ente-wasm-core = { path = "bindings/wasm/core" }-ente-wasm-contacts = { path = "bindings/wasm/contacts" }+ente-wasm-lib = { path = "bindings/wasm/lib" }ente-wasm-log = { path = "bindings/wasm/log" }flutter_rust_bridge = "=2.12.0"flutter_rust_bridge_codegen = "=2.12.0"diff --git a/rust/bindings/frb/core/Cargo.toml b/rust/bindings/frb/core/Cargo.tomldeleted file mode 100644index f5216a1eca..0000000000--- a/rust/bindings/frb/core/Cargo.toml+++ /dev/null@@ -1,10 +0,0 @@-[package]-name = "ente-frb-core"-edition = "2024"--[dependencies]-ente-core.workspace = true-flutter_rust_bridge.workspace = true--[lints.rust]-unexpected_cfgs = { level = "warn", check-cfg = ['cfg(frb_expand)'] }diff --git a/rust/bindings/frb/contacts/Cargo.toml b/rust/bindings/frb/lib/Cargo.tomlsimilarity index 61%rename from rust/bindings/frb/contacts/Cargo.tomlrename to rust/bindings/frb/lib/Cargo.tomlindex 482b3acf54..e6ae0a6482 100644--- a/rust/bindings/frb/contacts/Cargo.toml+++ b/rust/bindings/frb/lib/Cargo.toml@@ -1,11 +1,13 @@[package]-name = "ente-frb-contacts"+name = "ente-frb-lib"edition = "2024"+[features]+contacts = ["dep:ente-contacts"]+[dependencies]-ente-contacts.workspace = true+ente-contacts = { workspace = true, optional = true }ente-core.workspace = true-ente-frb-core.workspace = trueflutter_rust_bridge.workspace = true[lints.rust]diff --git a/rust/bindings/frb/contacts/src/lib.rs b/rust/bindings/frb/lib/src/contacts.rssimilarity index 97%rename from rust/bindings/frb/contacts/src/lib.rsrename to rust/bindings/frb/lib/src/contacts.rsindex 7080ff94f8..0712011a82 100644--- a/rust/bindings/frb/contacts/src/lib.rs+++ b/rust/bindings/frb/lib/src/contacts.rs@@ -1,6 +1,6 @@use flutter_rust_bridge::frb;-use ente_frb_core::Session;+use crate::session::Session;#[frb(non_opaque)]pub enum ContactsError {@@ -122,7 +122,8 @@ pub async fn create_contact(data: ContactData,) -> Result<ContactRecordOutput, ContactsError> {let key = wrapped_root_contact_key.map(Into::into);- let output = ente_contacts::create_contact(session.as_ref(), key.as_ref(), &data.into()).await?;+ let output =+ ente_contacts::create_contact(session.as_ref(), key.as_ref(), &data.into()).await?;Ok(ContactRecordOutput {record: output.value.into(),wrapped_root_contact_key: output.wrapped_root_contact_key.map(Into::into),diff --git a/rust/bindings/frb/lib/src/lib.rs b/rust/bindings/frb/lib/src/lib.rsnew file mode 100644index 0000000000..377f032eb4--- /dev/null+++ b/rust/bindings/frb/lib/src/lib.rs@@ -0,0 +1,3 @@+#[cfg(feature = "contacts")]+pub mod contacts;+pub mod session;diff --git a/rust/bindings/frb/core/src/lib.rs b/rust/bindings/frb/lib/src/session.rssimilarity index 100%rename from rust/bindings/frb/core/src/lib.rsrename to rust/bindings/frb/lib/src/session.rsdiff --git a/rust/bindings/frb/locker/Cargo.toml b/rust/bindings/frb/locker/Cargo.tomlindex 0a22ef0ddd..8599c5f563 100644--- a/rust/bindings/frb/locker/Cargo.toml+++ b/rust/bindings/frb/locker/Cargo.toml@@ -9,8 +9,7 @@ crate-type = ["cdylib", "staticlib"]ente-accounts.workspace = trueente-assets.workspace = trueente-core.workspace = true-ente-frb-contacts.workspace = true-ente-frb-core.workspace = true+ente-frb-lib = { workspace = true, features = ["contacts"] }ente-frb-log.workspace = trueente-legacy.workspace = trueente-ml.workspace = truediff --git a/rust/bindings/frb/locker/src/api/legacy.rs b/rust/bindings/frb/locker/src/api/legacy.rsindex 7909662c7d..0df39639ee 100644--- a/rust/bindings/frb/locker/src/api/legacy.rs+++ b/rust/bindings/frb/locker/src/api/legacy.rs@@ -1,6 +1,6 @@use flutter_rust_bridge::frb;-use ente_frb_core::Session;+use ente_frb_lib::session::Session;#[frb]pub enum LegacyError {diff --git a/rust/bindings/frb/photos/Cargo.toml b/rust/bindings/frb/photos/Cargo.tomlindex 6373797f01..09cf0f8066 100644--- a/rust/bindings/frb/photos/Cargo.toml+++ b/rust/bindings/frb/photos/Cargo.toml@@ -7,8 +7,7 @@ crate-type = ["cdylib", "staticlib"][dependencies]ente-cast.workspace = true-ente-frb-contacts.workspace = true-ente-frb-core.workspace = true+ente-frb-lib = { workspace = true, features = ["contacts"] }ente-frb-log.workspace = trueente-image.workspace = trueente-location.workspace = truediff --git a/rust/bindings/wasm/contacts/Cargo.toml b/rust/bindings/wasm/contacts/Cargo.tomldeleted file mode 100644index 5e39ad53f5..0000000000--- a/rust/bindings/wasm/contacts/Cargo.toml+++ /dev/null@@ -1,14 +0,0 @@-[package]-name = "ente-wasm-contacts"-edition = "2024"--[dependencies]-ente-contacts.workspace = true-ente-core.workspace = true-ente-wasm-core.workspace = true-js-sys.workspace = true-serde.workspace = true-serde-wasm-bindgen.workspace = true-thiserror.workspace = true-wasm-bindgen.workspace = true-wasm-bindgen-futures.workspace = truediff --git a/rust/bindings/wasm/core/Cargo.toml b/rust/bindings/wasm/core/Cargo.tomldeleted file mode 100644index bf4cda4a0e..0000000000--- a/rust/bindings/wasm/core/Cargo.toml+++ /dev/null@@ -1,9 +0,0 @@-[package]-name = "ente-wasm-core"-edition = "2024"--[dependencies]-ente-core.workspace = true-js-sys.workspace = true-thiserror.workspace = true-wasm-bindgen.workspace = truediff --git a/rust/bindings/wasm/legacy/Cargo.toml b/rust/bindings/wasm/legacy/Cargo.tomlindex 950f17de72..2fb1f39707 100644--- a/rust/bindings/wasm/legacy/Cargo.toml+++ b/rust/bindings/wasm/legacy/Cargo.toml@@ -9,7 +9,7 @@ crate-type = ["cdylib"]ente-accounts.workspace = trueente-core.workspace = trueente-legacy.workspace = true-ente-wasm-core.workspace = true+ente-wasm-lib.workspace = trueente-wasm-log.workspace = truejs-sys.workspace = trueserde.workspace = truediff --git a/rust/bindings/wasm/legacy/src/lib.rs b/rust/bindings/wasm/legacy/src/lib.rsindex 1bd4b18703..f1c250ad06 100644--- a/rust/bindings/wasm/legacy/src/lib.rs+++ b/rust/bindings/wasm/legacy/src/lib.rs@@ -1,7 +1,7 @@use ente_accounts::auth::KeyAttributes;use ente_core::b64;use ente_legacy::{LegacyContactState, LegacyKitRecoveryClient, LegacyKitShare};-use ente_wasm_core::Session;+use ente_wasm_lib::session::Session;use serde::Deserialize;use serde_wasm_bindgen as swb;use wasm_bindgen::prelude::*;diff --git a/rust/bindings/wasm/lib/Cargo.toml b/rust/bindings/wasm/lib/Cargo.tomlnew file mode 100644index 0000000000..ddefe87a5d--- /dev/null+++ b/rust/bindings/wasm/lib/Cargo.toml@@ -0,0 +1,21 @@+[package]+name = "ente-wasm-lib"+edition = "2024"++[features]+contacts = [+ "dep:ente-contacts",+ "dep:serde",+ "dep:serde-wasm-bindgen",+ "dep:wasm-bindgen-futures",+]++[dependencies]+ente-contacts = { workspace = true, optional = true }+ente-core.workspace = true+js-sys.workspace = true+serde = { workspace = true, optional = true }+serde-wasm-bindgen = { workspace = true, optional = true }+thiserror.workspace = true+wasm-bindgen.workspace = true+wasm-bindgen-futures = { workspace = true, optional = true }diff --git a/rust/bindings/wasm/contacts/src/lib.rs b/rust/bindings/wasm/lib/src/contacts.rssimilarity index 99%rename from rust/bindings/wasm/contacts/src/lib.rsrename to rust/bindings/wasm/lib/src/contacts.rsindex 51c8eaa881..b70b9ae721 100644--- a/rust/bindings/wasm/contacts/src/lib.rs+++ b/rust/bindings/wasm/lib/src/contacts.rs@@ -1,9 +1,10 @@use ente_contacts::WrappedRootContactKey;-use ente_wasm_core::Session;use serde::{Serialize, Serializer};use serde_wasm_bindgen as swb;use wasm_bindgen::prelude::*;+use crate::session::Session;+#[derive(Debug, thiserror::Error)]pub enum Error {#[error(transparent)]diff --git a/rust/bindings/wasm/lib/src/lib.rs b/rust/bindings/wasm/lib/src/lib.rsnew file mode 100644index 0000000000..377f032eb4--- /dev/null+++ b/rust/bindings/wasm/lib/src/lib.rs@@ -0,0 +1,3 @@+#[cfg(feature = "contacts")]+pub mod contacts;+pub mod session;diff --git a/rust/bindings/wasm/core/src/lib.rs b/rust/bindings/wasm/lib/src/session.rssimilarity index 100%rename from rust/bindings/wasm/core/src/lib.rsrename to rust/bindings/wasm/lib/src/session.rsdiff --git a/rust/bindings/wasm/locker/Cargo.toml b/rust/bindings/wasm/locker/Cargo.tomlindex 3403638076..1b70f7a2b6 100644--- a/rust/bindings/wasm/locker/Cargo.toml+++ b/rust/bindings/wasm/locker/Cargo.toml@@ -6,6 +6,5 @@ edition = "2024"crate-type = ["cdylib"][dependencies]-ente-wasm-contacts.workspace = true-ente-wasm-core.workspace = true+ente-wasm-lib = { workspace = true, features = ["contacts"] }ente-wasm-log.workspace = truediff --git a/rust/bindings/wasm/locker/src/lib.rs b/rust/bindings/wasm/locker/src/lib.rsindex e1f5565a08..49bcbd3c6c 100644--- a/rust/bindings/wasm/locker/src/lib.rs+++ b/rust/bindings/wasm/locker/src/lib.rs@@ -1,3 +1,2 @@-pub use ente_wasm_contacts::{contacts_get_diff, contacts_get_profile_picture};-pub use ente_wasm_core::{Session, open_session};+use ente_wasm_lib as _;use ente_wasm_log as _;diff --git a/rust/bindings/wasm/photos/Cargo.toml b/rust/bindings/wasm/photos/Cargo.tomlindex 97a7609160..599de55625 100644--- a/rust/bindings/wasm/photos/Cargo.toml+++ b/rust/bindings/wasm/photos/Cargo.toml@@ -6,6 +6,5 @@ edition = "2024"crate-type = ["cdylib"][dependencies]-ente-wasm-contacts.workspace = true-ente-wasm-core.workspace = true+ente-wasm-lib = { workspace = true, features = ["contacts"] }ente-wasm-log.workspace = truediff --git a/rust/bindings/wasm/photos/src/lib.rs b/rust/bindings/wasm/photos/src/lib.rsindex e1f5565a08..49bcbd3c6c 100644--- a/rust/bindings/wasm/photos/src/lib.rs+++ b/rust/bindings/wasm/photos/src/lib.rs@@ -1,3 +1,2 @@-pub use ente_wasm_contacts::{contacts_get_diff, contacts_get_profile_picture};-pub use ente_wasm_core::{Session, open_session};+use ente_wasm_lib as _;use ente_wasm_log as _;