π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add Rust bridge to Auth
Neeraj Gupta43d70b62ccac
diff --git a/.github/workflows/auth-build.yml b/.github/workflows/auth-build.ymlindex 641ff21ef1..0a8f6b1793 100644--- a/.github/workflows/auth-build.yml+++ b/.github/workflows/auth-build.yml@@ -122,6 +122,9 @@ jobs:- run: flutter pub get --enforce-lockfile+ - run: cargo codegen frb auth+ working-directory: rust+- name: Prepare whatsnewrun: |mkdir -p whatsnew@@ -242,6 +245,9 @@ jobs:- run: flutter pub get --enforce-lockfile+ - run: cargo codegen frb auth+ working-directory: rust+- name: Create artifacts directoryrun: mkdir artifacts@@ -399,6 +405,9 @@ jobs:- run: flutter pub get --enforce-lockfile+ - run: cargo codegen frb auth+ working-directory: rust+- name: Create artifacts directoryrun: mkdir artifacts@@ -584,6 +593,9 @@ jobs:- run: flutter pub get --enforce-lockfile+ - run: cargo codegen frb auth+ working-directory: rust+- name: Install code signing dependenciesrun: |set -euo pipefail@@ -727,6 +739,9 @@ jobs:- run: flutter pub get --enforce-lockfile+ - run: cargo codegen frb auth+ working-directory: rust+- name: Install iOS podsrun: pod install --deploymentworking-directory: mobile/apps/auth/iosdiff --git a/.github/workflows/mobile-lint.yml b/.github/workflows/mobile-lint.ymlindex e01c8347bb..8bb68aa240 100644--- a/.github/workflows/mobile-lint.yml+++ b/.github/workflows/mobile-lint.yml@@ -74,6 +74,9 @@ jobs:- run: cargo codegen frbworking-directory: rust+ - run: cargo clippy -p ente-auth-frb --features flutter --all-targets --locked+ working-directory: rust+- run: cargo clippy -p ente-photos-frb --features flutter --all-targets --lockedworking-directory: rustdiff --git a/.github/workflows/warm-caches.yml b/.github/workflows/warm-caches.ymlindex 7b1105e4c7..94cb3ff459 100644--- a/.github/workflows/warm-caches.yml+++ b/.github/workflows/warm-caches.yml@@ -156,6 +156,8 @@ jobs:- run: cargo codegen frb+ - run: cargo clippy -p ente-auth-frb --features flutter --all-targets --locked+- run: cargo clippy -p ente-photos-frb --features flutter --all-targets --locked- run: cargo clippy -p ente-locker-frb --features flutter --all-targets --lockeddiff --git a/mobile/apps/auth/analysis_options.yaml b/mobile/apps/auth/analysis_options.yamlindex e8b138eb9a..b029bee88c 100644--- a/mobile/apps/auth/analysis_options.yaml+++ b/mobile/apps/auth/analysis_options.yaml@@ -46,6 +46,7 @@ analyzer:use_build_context_synchronously: errorexclude:+ - lib/src/rust/**- thirdparty/**- flutter/**- build/**diff --git a/mobile/apps/auth/flutter_rust_bridge.yaml b/mobile/apps/auth/flutter_rust_bridge.yamlnew file mode 100644index 0000000000..005b044421--- /dev/null+++ b/mobile/apps/auth/flutter_rust_bridge.yaml@@ -0,0 +1,9 @@+rust_input: crate::api, ente-frb-lib+rust_root: ../../../rust/bindings/frb/auth/+dart_output: lib/src/rust+dart_entrypoint_class_name: EnteAuthRust++dart_preamble: |+ // ignore_for_file: require_trailing_commas++web: falsediff --git a/mobile/apps/auth/ios/Podfile.lock b/mobile/apps/auth/ios/Podfile.lockindex 3895c71486..6cdf9e8462 100644--- a/mobile/apps/auth/ios/Podfile.lock+++ b/mobile/apps/auth/ios/Podfile.lock@@ -38,6 +38,8 @@ PODS:- DKPhotoGallery/Resource (0.0.19):- SDWebImage- SwiftyGif+ - ente_auth_frb (0.0.1):+ - Flutter- ente_mail (0.0.1):- Flutter- ente_qr (0.0.1):@@ -126,6 +128,7 @@ DEPENDENCIES:- backup_exclusion (from `.symlinks/plugins/backup_exclusion/ios`)- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)+ - ente_auth_frb (from `.symlinks/plugins/ente_auth_frb/ios`)- ente_mail (from `.symlinks/plugins/ente_mail/ios`)- ente_qr (from `.symlinks/plugins/ente_qr/ios`)- ente_qr_scanner (from `.symlinks/plugins/ente_qr_scanner/ios`)@@ -169,6 +172,8 @@ EXTERNAL SOURCES::path: ".symlinks/plugins/connectivity_plus/ios"device_info_plus::path: ".symlinks/plugins/device_info_plus/ios"+ ente_auth_frb:+ :path: ".symlinks/plugins/ente_auth_frb/ios"ente_mail::path: ".symlinks/plugins/ente_mail/ios"ente_qr:@@ -225,6 +230,7 @@ SPEC CHECKSUMS:device_info_plus: 21fcca2080fbcd348be798aa36c3e5ed849eefbeDKImagePickerController: 946cec48c7873164274ecc4624d19e3da4c1ef3cDKPhotoGallery: b3834fecb755ee09a593d7c9e389d8b5d6deed60+ ente_auth_frb: 2f9fe254c3faed407bda0b0fbb89d810a291411eente_mail: f0569c7ea17e8324ef28f36a93c49fa1f3de724fente_qr: 86beaf5d2644705db9b565b32dd8b82c05fb36afente_qr_scanner: 91ee1a2245149fb91f00b5b688285a7c94bb9caadiff --git a/mobile/apps/auth/lib/core/configuration.dart b/mobile/apps/auth/lib/core/configuration.dartindex 500fa85bc9..9e9dccaaf3 100644--- a/mobile/apps/auth/lib/core/configuration.dart+++ b/mobile/apps/auth/lib/core/configuration.dart@@ -2,6 +2,7 @@ import 'dart:async';import 'dart:typed_data';import 'package:ente_account_deletion/account_deletion.dart';+import 'package:ente_auth/services/authenticated_session.dart';import 'package:ente_base/models/database.dart';import 'package:ente_configuration/base_configuration.dart';import 'package:ente_crypto_api/ente_crypto_api.dart';@@ -85,6 +86,7 @@ class Configuration extends BaseConfiguration@overrideFuture<void> logout({bool autoLogout = false}) async {+ clearAuthenticatedSession();_authSecretKey = null;await super.logout();}diff --git a/mobile/apps/auth/lib/main.dart b/mobile/apps/auth/lib/main.dartindex 825df03b28..299b76ff1a 100644--- a/mobile/apps/auth/lib/main.dart+++ b/mobile/apps/auth/lib/main.dart@@ -16,6 +16,7 @@ import 'package:ente_auth/services/notification_service.dart';import 'package:ente_auth/services/preference_service.dart';import 'package:ente_auth/services/update_service.dart';import 'package:ente_auth/services/window_listener_service.dart';+import 'package:ente_auth/src/rust/frb_generated.dart';import 'package:ente_auth/store/authenticator_db.dart';import 'package:ente_auth/store/code_display_store.dart';import 'package:ente_auth/store/code_store.dart';@@ -142,7 +143,7 @@ Future<void> _runInForeground() async {return await _runWithLogs(() async {_logger.info("Starting app in foreground");try {- await _init(false, via: 'mainMethod');+ await _init();} catch (e, s) {_logger.severe("Failed to init", e, s);rethrow;@@ -198,9 +199,10 @@ void _registerWindowsProtocol() {}}-Future<void> _init(bool bool, {String? via}) async {+Future<void> _init() async {_registerWindowsProtocol();await CryptoUtil.init();+ await EnteAuthRust.init();await PreferenceService.instance.init();await CodeStore.instance.init();diff --git a/mobile/apps/auth/lib/services/authenticated_session.dart b/mobile/apps/auth/lib/services/authenticated_session.dartnew file mode 100644index 0000000000..b1ea0e540e--- /dev/null+++ b/mobile/apps/auth/lib/services/authenticated_session.dart@@ -0,0 +1,63 @@+import 'dart:io';++import 'package:ente_auth/core/configuration.dart';+import 'package:ente_auth/src/rust/third_party/ente_frb_lib/session.dart';+import 'package:ente_network/network.dart';++Session? _session;+String? _sessionKey;++Session authenticatedSession() {+ final config = Configuration.instance;+ final authToken = config.getToken();+ final userId = config.getUserID();+ if (authToken == null || userId == null || !config.hasConfiguredAccount()) {+ throw StateError('Authenticated session is not available');+ }+ final baseUrl = config.getHttpEndpoint();+ final key = '$baseUrl|$userId';+ final current = _session;+ if (current != null && _sessionKey == key) {+ current.updateAuthToken(authToken: authToken);+ return current;+ }++ final keyAttributes = config.getKeyAttributes();+ if (keyAttributes == null) {+ throw StateError('Authenticated session is not available');+ }+ final encryptedRecoveryKey = keyAttributes.recoveryKeyEncryptedWithMasterKey;+ final recoveryKeyNonce = keyAttributes.recoveryKeyDecryptionNonce;+ if (encryptedRecoveryKey.isEmpty || recoveryKeyNonce.isEmpty) {+ throw StateError('Recovery key is not available');+ }+ final headers = Network.instance.enteDio.options.headers;+ final opened = openSession(+ input: OpenSessionInput(+ baseUrl: baseUrl,+ authToken: authToken,+ userId: userId,+ masterKey: config.getKey()!,+ keyAttributes: SessionKeyAttributes(+ publicKey: keyAttributes.publicKey,+ encryptedSecretKey: keyAttributes.encryptedSecretKey,+ secretKeyDecryptionNonce: keyAttributes.secretKeyDecryptionNonce,+ recoveryKeyEncryptedWithMasterKey: encryptedRecoveryKey,+ recoveryKeyDecryptionNonce: recoveryKeyNonce,+ ),+ userAgent: headers[HttpHeaders.userAgentHeader] as String,+ clientPackage: headers['X-Client-Package'] as String,+ clientVersion: headers['X-Client-Version'] as String,+ ),+ );+ clearAuthenticatedSession();+ _session = opened;+ _sessionKey = key;+ return opened;+}++void clearAuthenticatedSession() {+ _session?.dispose();+ _session = null;+ _sessionKey = null;+}diff --git a/mobile/apps/auth/linux/flutter/generated_plugins.cmake b/mobile/apps/auth/linux/flutter/generated_plugins.cmakeindex 20d25bcbf3..f623581af6 100644--- a/mobile/apps/auth/linux/flutter/generated_plugins.cmake+++ b/mobile/apps/auth/linux/flutter/generated_plugins.cmake@@ -17,6 +17,7 @@ list(APPEND FLUTTER_PLUGIN_LIST)list(APPEND FLUTTER_FFI_PLUGIN_LIST+ ente_auth_frbjni)diff --git a/mobile/apps/auth/macos/Podfile.lock b/mobile/apps/auth/macos/Podfile.lockindex 57683cb323..c67515c8c6 100644--- a/mobile/apps/auth/macos/Podfile.lock+++ b/mobile/apps/auth/macos/Podfile.lock@@ -5,6 +5,8 @@ PODS:- FlutterMacOS- device_info_plus (0.0.1):- FlutterMacOS+ - ente_auth_frb (0.0.1):+ - FlutterMacOS- ente_qr (0.0.1):- FlutterMacOS- file_picker (0.0.1):@@ -77,6 +79,7 @@ DEPENDENCIES:- app_links (from `Flutter/ephemeral/.symlinks/plugins/app_links/macos`)- connectivity_plus (from `Flutter/ephemeral/.symlinks/plugins/connectivity_plus/macos`)- device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`)+ - ente_auth_frb (from `Flutter/ephemeral/.symlinks/plugins/ente_auth_frb/macos`)- ente_qr (from `Flutter/ephemeral/.symlinks/plugins/ente_qr/macos`)- file_picker (from `Flutter/ephemeral/.symlinks/plugins/file_picker/macos`)- file_saver (from `Flutter/ephemeral/.symlinks/plugins/file_saver/macos`)@@ -109,6 +112,8 @@ EXTERNAL SOURCES::path: Flutter/ephemeral/.symlinks/plugins/connectivity_plus/macosdevice_info_plus::path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos+ ente_auth_frb:+ :path: Flutter/ephemeral/.symlinks/plugins/ente_auth_frb/macosente_qr::path: Flutter/ephemeral/.symlinks/plugins/ente_qr/macosfile_picker:@@ -152,12 +157,13 @@ SPEC CHECKSUMS:app_links: 05a6ec2341985eb05e9f97dc63f5837c39895c3fconnectivity_plus: 4adf20a405e25b42b9c9f87feff8f4b6fde18a4edevice_info_plus: 4fb280989f669696856f8b129e4a5e3cd6c48f76+ ente_auth_frb: efe63d2f900a2971444739de331bf3b90c721cd9ente_qr: 679dcacb6a07788ee2e79d29485b07064cdec78dfile_picker: 7584aae6fa07a041af2b36a2655122d42f578c1afile_saver: e35bd97de451dde55ff8c38862ed7ad0f3418d0fflutter_local_notifications: 4bf37a31afde695b56091b4ae3e4d9c7a7e6cda0flutter_secure_storage_macos: 7f45e30f838cf2659862a4e4e3ee1c347c2b3b54- FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1+ FlutterMacOS: c232990155153907050900a2e175c7773903ba4elocal_auth_darwin: c3ee6cce0a8d56be34c8ccb66ba31f7f180aaebbpackage_info_plus: f0052d280d17aa382b932f399edf32507174e870scoped_dir_access: 6d48cfa2b5c90bf9ec7b8f43cf9fd55b3da431b3@@ -174,6 +180,6 @@ SPEC CHECKSUMS:url_launcher_macos: f87a979182d112f911de6820aefddaf56ee9fbfdwindow_manager: b729e31d38fb04905235df9ea896128991cad99e-PODFILE CHECKSUM: 6ff827273ace187339fc5d3684072a26ad85c298+PODFILE CHECKSUM: 65859659d1046735c510d67fc704df4253ab399cCOCOAPODS: 1.17.0diff --git a/mobile/apps/auth/pubspec.yaml b/mobile/apps/auth/pubspec.yamlindex 6cb11b4fa9..7b1e8a580b 100644--- a/mobile/apps/auth/pubspec.yaml+++ b/mobile/apps/auth/pubspec.yaml@@ -29,6 +29,8 @@ dependencies:path: ../../packages/account_deletionente_accounts:path: ../../packages/accounts+ ente_auth_frb:+ path: rust_builderente_base:path: ../../packages/baseente_components:@@ -78,6 +80,7 @@ dependencies:flutter_localizations:sdk: flutterflutter_native_splash: 2.4.7+ flutter_rust_bridge: 2.13.0# Version 9.2.4 leaves lock-screen keys behind after an app reinstall.# Upgrade only after this is fixed or with a migration.# https://github.com/juliansteenbakker/flutter_secure_storage/issues/870#issuecomment-2777447937@@ -86,6 +89,7 @@ dependencies:flutter_staggered_grid_view: 0.7.0flutter_svg: 2.3.0fluttertoast: 8.2.14+ freezed_annotation: 3.1.0gradient_borders: 1.0.1http: 1.6.0hugeicons: 1.1.7@@ -138,9 +142,11 @@ dependencies:xdg_directories: 1.1.0dev_dependencies:+ build_runner: 2.13.1flutter_lints: 6.0.0flutter_test:sdk: flutter+ freezed: 3.2.3qr: 3.0.2shared_preferences_platform_interface: 2.4.2diff --git a/mobile/apps/auth/rust_builder/android/build.gradle b/mobile/apps/auth/rust_builder/android/build.gradlenew file mode 100644index 0000000000..1bdbd15110--- /dev/null+++ b/mobile/apps/auth/rust_builder/android/build.gradle@@ -0,0 +1,20 @@+plugins {+ id 'com.android.library'+}++group 'com.flutter_rust_bridge.ente_auth_frb'+version '1.0'++android {+ namespace 'com.flutter_rust_bridge.ente_auth_frb'++ defaultConfig {+ minSdkVersion 19+ }+}++apply from: "../../../../cargokit/gradle/plugin.gradle"+cargokit {+ manifestDir = "../../../../../rust/bindings/frb/auth"+ libname = "ente_auth_frb"+}diff --git a/mobile/apps/auth/rust_builder/android/settings.gradle b/mobile/apps/auth/rust_builder/android/settings.gradlenew file mode 100644index 0000000000..4412c9cd65--- /dev/null+++ b/mobile/apps/auth/rust_builder/android/settings.gradle@@ -0,0 +1 @@+rootProject.name = 'ente_auth_frb'diff --git a/mobile/apps/auth/rust_builder/android/src/main/AndroidManifest.xml b/mobile/apps/auth/rust_builder/android/src/main/AndroidManifest.xmlnew file mode 100644index 0000000000..ccd531e893--- /dev/null+++ b/mobile/apps/auth/rust_builder/android/src/main/AndroidManifest.xml@@ -0,0 +1,3 @@+<manifest xmlns:android="http://schemas.android.com/apk/res/android"+ package="com.flutter_rust_bridge.ente_auth_frb">+</manifest>diff --git a/mobile/apps/auth/rust_builder/ios/Classes/dummy_file.c b/mobile/apps/auth/rust_builder/ios/Classes/dummy_file.cnew file mode 100644index 0000000000..fe10e0cd59--- /dev/null+++ b/mobile/apps/auth/rust_builder/ios/Classes/dummy_file.c@@ -0,0 +1 @@+// CocoaPods requires a source file to create the framework.diff --git a/mobile/apps/auth/rust_builder/ios/ente_auth_frb.podspec b/mobile/apps/auth/rust_builder/ios/ente_auth_frb.podspecnew file mode 100644index 0000000000..d0ece97a6a--- /dev/null+++ b/mobile/apps/auth/rust_builder/ios/ente_auth_frb.podspec@@ -0,0 +1,24 @@+Pod::Spec.new do |s|+ s.name = 'ente_auth_frb'+ s.version = '0.0.1'+ s.summary = 'Rust bindings for Ente Auth.'+ s.homepage = 'https://ente.io/auth'+ s.license = { :type => 'AGPL-3.0' }+ s.author = 'Ente'+ s.source = { :path => '.' }+ s.source_files = 'Classes/**/*'+ s.dependency 'Flutter'+ s.platform = :ios, '15.0'++ s.script_phase = {+ :name => 'Build Rust library',+ :script => 'sh "$(cd -P "$PODS_TARGET_SRCROOT" && pwd)/../../../../cargokit/build_pod.sh" ../../../../../rust/bindings/frb/auth ente_auth_frb',+ :execution_position => :before_compile,+ :input_files => ['${BUILT_PRODUCTS_DIR}/cargokit_phony'],+ :output_files => ['${BUILT_PRODUCTS_DIR}/libente_auth_frb.a'],+ }+ s.pod_target_xcconfig = {+ 'DEFINES_MODULE' => 'YES',+ 'OTHER_LDFLAGS' => '-force_load ${BUILT_PRODUCTS_DIR}/libente_auth_frb.a -lc++',+ }+enddiff --git a/mobile/apps/auth/rust_builder/linux/CMakeLists.txt b/mobile/apps/auth/rust_builder/linux/CMakeLists.txtnew file mode 100644index 0000000000..5b8a84ba8a--- /dev/null+++ b/mobile/apps/auth/rust_builder/linux/CMakeLists.txt@@ -0,0 +1,12 @@+cmake_minimum_required(VERSION 3.10)++set(PROJECT_NAME "ente_auth_frb")+project(${PROJECT_NAME} LANGUAGES CXX)++include("../../../../cargokit/cmake/cargokit.cmake")+apply_cargokit(${PROJECT_NAME} ../../../../../rust/bindings/frb/auth ente_auth_frb "")++set(ente_auth_frb_bundled_libraries+ "${${PROJECT_NAME}_cargokit_lib}"+ PARENT_SCOPE+)diff --git a/mobile/apps/auth/rust_builder/macos/Classes/dummy_file.c b/mobile/apps/auth/rust_builder/macos/Classes/dummy_file.cnew file mode 100644index 0000000000..fe10e0cd59--- /dev/null+++ b/mobile/apps/auth/rust_builder/macos/Classes/dummy_file.c@@ -0,0 +1 @@+// CocoaPods requires a source file to create the framework.diff --git a/mobile/apps/auth/rust_builder/macos/ente_auth_frb.podspec b/mobile/apps/auth/rust_builder/macos/ente_auth_frb.podspecnew file mode 100644index 0000000000..63111bad74--- /dev/null+++ b/mobile/apps/auth/rust_builder/macos/ente_auth_frb.podspec@@ -0,0 +1,24 @@+Pod::Spec.new do |s|+ s.name = 'ente_auth_frb'+ s.version = '0.0.1'+ s.summary = 'Rust bindings for Ente Auth.'+ s.homepage = 'https://ente.io/auth'+ s.license = { :type => 'AGPL-3.0' }+ s.author = 'Ente'+ s.source = { :path => '.' }+ s.source_files = 'Classes/**/*'+ s.dependency 'FlutterMacOS'+ s.platform = :osx, '12.0'++ s.script_phase = {+ :name => 'Build Rust library',+ :script => 'sh "$(cd -P "$PODS_TARGET_SRCROOT" && pwd)/../../../../cargokit/build_pod.sh" ../../../../../rust/bindings/frb/auth ente_auth_frb',+ :execution_position => :before_compile,+ :input_files => ['${BUILT_PRODUCTS_DIR}/cargokit_phony'],+ :output_files => ['${BUILT_PRODUCTS_DIR}/libente_auth_frb.a'],+ }+ s.pod_target_xcconfig = {+ 'DEFINES_MODULE' => 'YES',+ 'OTHER_LDFLAGS' => '-force_load ${BUILT_PRODUCTS_DIR}/libente_auth_frb.a -lc++',+ }+enddiff --git a/mobile/apps/auth/rust_builder/pubspec.yaml b/mobile/apps/auth/rust_builder/pubspec.yamlnew file mode 100644index 0000000000..ca9f9247c8--- /dev/null+++ b/mobile/apps/auth/rust_builder/pubspec.yaml@@ -0,0 +1,26 @@+name: ente_auth_frb+description: Rust bindings for Ente Auth.+version: 0.0.1+publish_to: none++environment:+ sdk: ">=3.10.0 <4.0.0"+ flutter: ">=3.3.0"++dependencies:+ flutter:+ sdk: flutter++flutter:+ plugin:+ platforms:+ android:+ ffiPlugin: true+ ios:+ ffiPlugin: true+ linux:+ ffiPlugin: true+ macos:+ ffiPlugin: true+ windows:+ ffiPlugin: truediff --git a/mobile/apps/auth/rust_builder/windows/CMakeLists.txt b/mobile/apps/auth/rust_builder/windows/CMakeLists.txtnew file mode 100644index 0000000000..b11e68a1e1--- /dev/null+++ b/mobile/apps/auth/rust_builder/windows/CMakeLists.txt@@ -0,0 +1,12 @@+cmake_minimum_required(VERSION 3.14)++set(PROJECT_NAME "ente_auth_frb")+project(${PROJECT_NAME} LANGUAGES CXX)++include("../../../../cargokit/cmake/cargokit.cmake")+apply_cargokit(${PROJECT_NAME} ../../../../../../../../../rust/bindings/frb/auth ente_auth_frb "")++set(ente_auth_frb_bundled_libraries+ "${${PROJECT_NAME}_cargokit_lib}"+ PARENT_SCOPE+)diff --git a/mobile/apps/auth/windows/flutter/generated_plugins.cmake b/mobile/apps/auth/windows/flutter/generated_plugins.cmakeindex d91d40bf51..2b466682ba 100644--- a/mobile/apps/auth/windows/flutter/generated_plugins.cmake+++ b/mobile/apps/auth/windows/flutter/generated_plugins.cmake@@ -19,6 +19,7 @@ list(APPEND FLUTTER_PLUGIN_LIST)list(APPEND FLUTTER_FFI_PLUGIN_LIST+ ente_auth_frbflutter_local_notifications_windowsjni)diff --git a/mobile/apps/auth/windows/signing/allowed-pe-files.txt b/mobile/apps/auth/windows/signing/allowed-pe-files.txtindex 61d8e3819b..6c4380a310 100644--- a/mobile/apps/auth/windows/signing/allowed-pe-files.txt+++ b/mobile/apps/auth/windows/signing/allowed-pe-files.txt@@ -2,6 +2,7 @@ app_links_plugin.dllauth.execonnectivity_plus_plugin.dlldartjni.dll+ente_auth_frb.dllfile_saver_plugin.dllflutter_local_notifications_windows.dllflutter_secure_storage_windows_plugin.dlldiff --git a/mobile/pubspec.lock b/mobile/pubspec.lockindex b71e99c9b7..96b2baab8b 100644--- a/mobile/pubspec.lock+++ b/mobile/pubspec.lock@@ -570,6 +570,13 @@ packages:url: "https://pub.dev"source: hostedversion: "5.0.3"+ ente_auth_frb:+ dependency: transitive+ description:+ path: "apps/auth/rust_builder"+ relative: true+ source: path+ version: "0.0.1"ente_crypto_dart:dependency: transitivedescription:diff --git a/rust/Cargo.lock b/rust/Cargo.lockindex 20f13fb72d..7c239dc583 100644--- a/rust/Cargo.lock+++ b/rust/Cargo.lock@@ -2482,6 +2482,14 @@ dependencies = ["zeroize",]+[[package]]+name = "ente-auth-frb"+version = "0.0.0"+dependencies = [+ "ente-frb-lib",+ "flutter_rust_bridge",+]+[[package]]name = "ente-auth-wasm"version = "0.0.0"diff --git a/rust/Cargo.toml b/rust/Cargo.tomlindex 39eb130f0c..6dabd998ea 100644--- a/rust/Cargo.toml+++ b/rust/Cargo.toml@@ -3,6 +3,7 @@ resolver = "2"members = ["apps/cli","apps/ensu/src-tauri",+ "bindings/frb/auth","bindings/frb/lib","bindings/frb/locker","bindings/frb/log",diff --git a/rust/bindings/frb/auth/Cargo.toml b/rust/bindings/frb/auth/Cargo.tomlnew file mode 100644index 0000000000..197a61118e--- /dev/null+++ b/rust/bindings/frb/auth/Cargo.toml@@ -0,0 +1,17 @@+[package]+name = "ente-auth-frb"+edition.workspace = true++[lib]+crate-type = ["cdylib", "staticlib"]++[dependencies]+ente-frb-lib.workspace = true+flutter_rust_bridge.workspace = true++[lints]+workspace = true++[features]+default = []+flutter = []diff --git a/rust/bindings/frb/auth/cargokit.yaml b/rust/bindings/frb/auth/cargokit.yamlnew file mode 100644index 0000000000..56a90aa824--- /dev/null+++ b/rust/bindings/frb/auth/cargokit.yaml@@ -0,0 +1,7 @@+cargo:+ debug:+ extra_flags: ["--features", "flutter"]+ profile:+ extra_flags: ["--features", "flutter"]+ release:+ extra_flags: ["--features", "flutter"]diff --git a/rust/bindings/frb/auth/src/api/init.rs b/rust/bindings/frb/auth/src/api/init.rsnew file mode 100644index 0000000000..1606ea581d--- /dev/null+++ b/rust/bindings/frb/auth/src/api/init.rs@@ -0,0 +1,4 @@+#[flutter_rust_bridge::frb(init)]+pub fn init_app() {+ flutter_rust_bridge::setup_default_user_utils();+}diff --git a/rust/bindings/frb/auth/src/api/mod.rs b/rust/bindings/frb/auth/src/api/mod.rsnew file mode 100644index 0000000000..43763f10a4--- /dev/null+++ b/rust/bindings/frb/auth/src/api/mod.rs@@ -0,0 +1 @@+pub mod init;diff --git a/rust/bindings/frb/auth/src/lib.rs b/rust/bindings/frb/auth/src/lib.rsnew file mode 100644index 0000000000..f2425a0527--- /dev/null+++ b/rust/bindings/frb/auth/src/lib.rs@@ -0,0 +1,12 @@+pub mod api;++#[cfg(feature = "flutter")]+#[expect(+ unsafe_code,+ clippy::allow_attributes,+ clippy::allow_attributes_without_reason,+ clippy::unwrap_used,+ reason = "Flutter Rust Bridge generates unsafe bindings, unwrap calls and allow attributes without reasons"+)]+#[rustfmt::skip]+mod frb_generated;diff --git a/rust/checks/lint-exceptions/suppressions.json b/rust/checks/lint-exceptions/suppressions.jsonindex c9add6495a..efef732c6e 100644--- a/rust/checks/lint-exceptions/suppressions.json+++ b/rust/checks/lint-exceptions/suppressions.json@@ -1,5 +1,11 @@{"rust/apps/ensu/src-tauri/src/logging.rs": ["clippy::expect_used"],+ "rust/bindings/frb/auth/src/lib.rs": [+ "clippy::allow_attributes",+ "clippy::allow_attributes_without_reason",+ "clippy::unwrap_used",+ "unsafe_code"+ ],"rust/bindings/frb/locker/src/lib.rs": ["clippy::allow_attributes","clippy::allow_attributes_without_reason",diff --git a/rust/tools/codegen/src/main.rs b/rust/tools/codegen/src/main.rsindex 03875dc3d1..227ec905bb 100644--- a/rust/tools/codegen/src/main.rs+++ b/rust/tools/codegen/src/main.rs@@ -30,6 +30,7 @@ enum NativeTarget {#[derive(Clone, Copy)]enum FrbTarget {All,+ Auth,Photos,Locker,}@@ -59,6 +60,7 @@ fn run() -> Result<(), DynError> {Some("frb") => {let target = match args.next().as_deref() {None => FrbTarget::All,+ Some("auth") => FrbTarget::Auth,Some("photos") => FrbTarget::Photos,Some("locker") => FrbTarget::Locker,_ => return Err(usage_error()),@@ -79,7 +81,7 @@ fn run() -> Result<(), DynError> {}fn usage_error() -> DynError {- "usage: cargo codegen <native [ensu|cast]|frb [photos|locker]|napi>".into()+ "usage: cargo codegen <native [ensu|cast]|frb [auth|photos|locker]|napi>".into()}fn generate_native(target: NativeTarget) -> Result<(), DynError> {@@ -166,7 +168,8 @@ fn generate_frb(target: FrbTarget) -> Result<(), DynError> {.ok_or("failed to resolve repo root from rust/tools/codegen")?;let apps: &[&str] = match target {- FrbTarget::All => &["photos", "locker"],+ FrbTarget::All => &["auth", "photos", "locker"],+ FrbTarget::Auth => &["auth"],FrbTarget::Photos => &["photos"],FrbTarget::Locker => &["locker"],};@@ -180,6 +183,9 @@ fn generate_frb(target: FrbTarget) -> Result<(), DynError> {fs::remove_dir_all(&generated_dir)?;}generate_frb_package(&package_dir)?;+ if *app == "auth" {+ continue;+ }for name in ["contacts", "legacy"] {let types_path = package_dir.join("lib/src/rust/third_party/ente_frb_lib")@@ -359,11 +365,16 @@ fn format_frb_bindings(target: FrbTarget) -> Result<(), DynError> {match target {FrbTarget::All => {command+ .arg("-p")+ .arg("ente-auth-frb").arg("-p").arg("ente-photos-frb").arg("-p").arg("ente-locker-frb");}+ FrbTarget::Auth => {+ command.arg("-p").arg("ente-auth-frb");+ }FrbTarget::Photos => {command.arg("-p").arg("ente-photos-frb");}