diff --git a/.github/workflows/android_ci.yaml.bak b/.github/workflows/android_ci.yaml.bak index 002255d159..a45ef67711 100644 --- a/.github/workflows/android_ci.yaml.bak +++ b/.github/workflows/android_ci.yaml.bak @@ -20,7 +20,7 @@ on: env: CARGO_TERM_COLOR: always FLUTTER_VERSION: "3.22.3" - RUST_TOOLCHAIN: "1.80.1" + RUST_TOOLCHAIN: "1.81.0" CARGO_MAKE_VERSION: "0.37.18" CLOUD_VERSION: 0.6.54-amd64 diff --git a/.github/workflows/flutter_ci.yaml b/.github/workflows/flutter_ci.yaml index 86d5b7ef30..42daeca881 100644 --- a/.github/workflows/flutter_ci.yaml +++ b/.github/workflows/flutter_ci.yaml @@ -26,7 +26,7 @@ on: env: CARGO_TERM_COLOR: always FLUTTER_VERSION: "3.22.2" - RUST_TOOLCHAIN: "1.80.1" + RUST_TOOLCHAIN: "1.81.0" CARGO_MAKE_VERSION: "0.37.18" CLOUD_VERSION: 0.6.54-amd64 @@ -40,7 +40,7 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest] + os: [ ubuntu-latest ] include: - os: ubuntu-latest flutter_profile: development-linux-x86_64 @@ -74,7 +74,7 @@ jobs: strategy: fail-fast: true matrix: - os: [windows-latest] + os: [ windows-latest ] include: - os: windows-latest flutter_profile: development-windows-x86 @@ -101,7 +101,7 @@ jobs: strategy: fail-fast: true matrix: - os: [macos-latest] + os: [ macos-latest ] include: - os: macos-latest flutter_profile: development-mac-x86_64 @@ -123,12 +123,12 @@ jobs: flutter_profile: ${{ matrix.flutter_profile }} unit_test: - needs: [prepare-linux] + needs: [ prepare-linux ] if: github.event.pull_request.draft != true strategy: fail-fast: false matrix: - os: [ubuntu-latest] + os: [ ubuntu-latest ] include: - os: ubuntu-latest flutter_profile: development-linux-x86_64 @@ -217,11 +217,11 @@ jobs: shell: bash cloud_integration_test: - needs: [prepare-linux] + needs: [ prepare-linux ] strategy: fail-fast: false matrix: - os: [ubuntu-latest] + os: [ ubuntu-latest ] include: - os: ubuntu-latest flutter_profile: development-linux-x86_64 @@ -340,13 +340,13 @@ jobs: shell: bash integration_test: - needs: [prepare-linux] + needs: [ prepare-linux ] if: github.event.pull_request.draft != true strategy: fail-fast: false matrix: - os: [ubuntu-latest] - test_number: [1, 2, 3, 4, 5, 6, 7, 8, 9] + os: [ ubuntu-latest ] + test_number: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] include: - os: ubuntu-latest target: "x86_64-unknown-linux-gnu" diff --git a/.github/workflows/ios_ci.yaml b/.github/workflows/ios_ci.yaml index 1cdc997180..bd71c77b3b 100644 --- a/.github/workflows/ios_ci.yaml +++ b/.github/workflows/ios_ci.yaml @@ -21,7 +21,7 @@ on: env: FLUTTER_VERSION: "3.22.3" - RUST_TOOLCHAIN: "1.80.1" + RUST_TOOLCHAIN: "1.81.0" concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 86ad99c6dc..91e6b99565 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: env: FLUTTER_VERSION: "3.22.0" - RUST_TOOLCHAIN: "1.80.1" + RUST_TOOLCHAIN: "1.81.0" jobs: create-release: @@ -232,10 +232,10 @@ jobs: matrix: job: - { - targets: "aarch64-apple-darwin,x86_64-apple-darwin", - os: macos-latest, - extra-build-args: "", - } + targets: "aarch64-apple-darwin,x86_64-apple-darwin", + os: macos-latest, + extra-build-args: "", + } steps: - name: Checkout source code uses: actions/checkout@v4 @@ -336,12 +336,12 @@ jobs: matrix: job: - { - arch: x86_64, - target: x86_64-unknown-linux-gnu, - os: ubuntu-20.04, - extra-build-args: "", - flutter_profile: production-linux-x86_64, - } + arch: x86_64, + target: x86_64-unknown-linux-gnu, + os: ubuntu-20.04, + extra-build-args: "", + flutter_profile: production-linux-x86_64, + } steps: - name: Checkout source code uses: actions/checkout@v4 diff --git a/.github/workflows/rust_ci.yaml b/.github/workflows/rust_ci.yaml index a67fd9d6ef..36c2e82064 100644 --- a/.github/workflows/rust_ci.yaml +++ b/.github/workflows/rust_ci.yaml @@ -19,7 +19,7 @@ on: env: CARGO_TERM_COLOR: always CLOUD_VERSION: 0.8.3-amd64 - RUST_TOOLCHAIN: "1.80.1" + RUST_TOOLCHAIN: "1.81.0" jobs: ubuntu-job: diff --git a/.github/workflows/rust_coverage.yml b/.github/workflows/rust_coverage.yml index 94a80aa95a..916f19d9fc 100644 --- a/.github/workflows/rust_coverage.yml +++ b/.github/workflows/rust_coverage.yml @@ -11,7 +11,7 @@ on: env: CARGO_TERM_COLOR: always FLUTTER_VERSION: "3.22.0" - RUST_TOOLCHAIN: "1.80.1" + RUST_TOOLCHAIN: "1.81.0" jobs: tests: diff --git a/.github/workflows/tauri2_ci.yaml b/.github/workflows/tauri2_ci.yaml index b4b9183d01..8ce4dac12b 100644 --- a/.github/workflows/tauri2_ci.yaml +++ b/.github/workflows/tauri2_ci.yaml @@ -12,7 +12,7 @@ on: env: NODE_VERSION: "18.16.0" PNPM_VERSION: "8.5.0" - RUST_TOOLCHAIN: "1.80.1" + RUST_TOOLCHAIN: "1.81.0" CARGO_MAKE_VERSION: "0.36.6" CI: true diff --git a/.github/workflows/tauri_ci.yaml b/.github/workflows/tauri_ci.yaml index 7d9c67e25a..fb2e874204 100644 --- a/.github/workflows/tauri_ci.yaml +++ b/.github/workflows/tauri_ci.yaml @@ -7,7 +7,7 @@ on: env: NODE_VERSION: "18.16.0" PNPM_VERSION: "8.5.0" - RUST_TOOLCHAIN: "1.80.1" + RUST_TOOLCHAIN: "1.81.0" concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -19,7 +19,7 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-20.04] + platform: [ ubuntu-20.04 ] runs-on: ${{ matrix.platform }} diff --git a/.github/workflows/tauri_release.yml b/.github/workflows/tauri_release.yml index 4612d5c3aa..e88af2190e 100644 --- a/.github/workflows/tauri_release.yml +++ b/.github/workflows/tauri_release.yml @@ -14,7 +14,7 @@ on: env: NODE_VERSION: "18.16.0" PNPM_VERSION: "8.5.0" - RUST_TOOLCHAIN: "1.80.1" + RUST_TOOLCHAIN: "1.81.0" jobs: publish-tauri: diff --git a/frontend/appflowy_flutter/macos/Podfile.lock b/frontend/appflowy_flutter/macos/Podfile.lock index d5ac7975b9..2d9b24cdaa 100644 --- a/frontend/appflowy_flutter/macos/Podfile.lock +++ b/frontend/appflowy_flutter/macos/Podfile.lock @@ -130,31 +130,31 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos SPEC CHECKSUMS: - app_links: 10e0a0ab602ffaf34d142cd4862f29d34b303b2a - appflowy_backend: 865496343de667fc8c600e04b9fd05234e130cf9 - bitsdojo_window_macos: 44e3b8fe3dd463820e0321f6256c5b1c16bb6a00 - connectivity_plus: 18d3c32514c886e046de60e9c13895109866c747 - desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898 - device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720 - file_selector_macos: 54fdab7caa3ac3fc43c9fac4d7d8d231277f8cf2 - flowy_infra_ui: 03301a39ad118771adbf051a664265c61c507f38 + app_links: 9028728e32c83a0831d9db8cf91c526d16cc5468 + appflowy_backend: 464aeb3e5c6966a41641a2111e5ead72ce2695f7 + bitsdojo_window_macos: 7959fb0ca65a3ccda30095c181ecb856fae48ea9 + connectivity_plus: e74b9f74717d2d99d45751750e266e55912baeb5 + desktop_drop: e0b672a7d84c0a6cbc378595e82cdb15f2970a43 + device_info_plus: a56e6e74dbbd2bb92f2da12c64ddd4f67a749041 + file_selector_macos: 585232b688707857504f9cb5f985a7c97fe4dd30 + flowy_infra_ui: 8760ff42a789de40bf5007a5f176b454722a341e FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 HotKey: e96d8a2ddbf4591131e2bb3f54e69554d90cdca6 - hotkey_manager: c32bf0bfe8f934b7bc17ab4ad5c4c142960b023c - irondash_engine_context: da62996ee25616d2f01bbeb85dc115d813359478 - local_notifier: e9506bc66fc70311e8bc7291fb70f743c081e4ff - package_info_plus: fa739dd842b393193c5ca93c26798dff6e3d0e0c - path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 + hotkey_manager: b443f35f4d772162937aa73fd8995e579f8ac4e2 + irondash_engine_context: 893c7d96d20ce361d7e996f39d360c4c2f9869ba + local_notifier: ebf072651e35ae5e47280ad52e2707375cb2ae4e + package_info_plus: a8a591e70e87ce97ce5d21b2594f69cea9e0312f + path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564 ReachabilitySwift: 7f151ff156cea1481a8411701195ac6a984f4979 - screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38 + screen_retriever: 4f97c103641aab8ce183fa5af3b87029df167936 Sentry: 1fe34e9c2cbba1e347623610d26db121dcb569f1 - sentry_flutter: a39c2a2d67d5e5b9cb0b94a4985c76dd5b3fc737 - share_plus: 36537c04ce0c3e3f5bd297ce4318b6d5ee5fd6cf - shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 - sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec - super_native_extensions: 85efee3a7495b46b04befcfc86ed12069264ebf3 - url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399 - window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 + sentry_flutter: e24b397f9a61fa5bbefd8279c3b2242ca86faa90 + share_plus: 11c7b7fa7020465584eca3ff6392c5bc1e399d6e + shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7 + sqflite: c35dad70033b8862124f8337cc994a809fcd9fa3 + super_native_extensions: c2795d6d9aedf4a79fae25cb6160b71b50549189 + url_launcher_macos: de10e46d8d8b9e3a7b8a133e8de92b104379f05e + window_manager: 1d01fa7ac65a6e6f83b965471b1a7fdd3f06166c PODFILE CHECKSUM: 0532f3f001ca3110b8be345d6491fff690e95823 diff --git a/frontend/appflowy_flutter/macos/Runner.xcodeproj/project.pbxproj b/frontend/appflowy_flutter/macos/Runner.xcodeproj/project.pbxproj index 1c3367e430..88c451bdd9 100644 --- a/frontend/appflowy_flutter/macos/Runner.xcodeproj/project.pbxproj +++ b/frontend/appflowy_flutter/macos/Runner.xcodeproj/project.pbxproj @@ -29,6 +29,7 @@ 706E045829F286F600B789F4 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 706E045729F286EC00B789F4 /* libc++.tbd */; }; D7360C6D6177708F7B2D3C9D /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CD81A6C7244B2318E0BA2E8 /* Pods_Runner.framework */; }; FB4E0E4F2CC9F3F900C57E87 /* libbz2.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = FB4E0E4E2CC9F3E900C57E87 /* libbz2.tbd */; }; + FB54062C2D22665000223D60 /* liblzma.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = FB54062B2D22664200223D60 /* liblzma.tbd */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -77,6 +78,7 @@ 7D41C30A3910C3A40B6085E3 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; FB4E0E4E2CC9F3E900C57E87 /* libbz2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libbz2.tbd; path = usr/lib/libbz2.tbd; sourceTree = SDKROOT; }; + FB54062B2D22664200223D60 /* liblzma.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = liblzma.tbd; path = usr/lib/liblzma.tbd; sourceTree = SDKROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -86,6 +88,7 @@ files = ( FB4E0E4F2CC9F3F900C57E87 /* libbz2.tbd in Frameworks */, 706E045829F286F600B789F4 /* libc++.tbd in Frameworks */, + FB54062C2D22665000223D60 /* liblzma.tbd in Frameworks */, D7360C6D6177708F7B2D3C9D /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -171,6 +174,7 @@ D73912EC22F37F3D000D13A0 /* Frameworks */ = { isa = PBXGroup; children = ( + FB54062B2D22664200223D60 /* liblzma.tbd */, FB4E0E4E2CC9F3E900C57E87 /* libbz2.tbd */, 706E045729F286EC00B789F4 /* libc++.tbd */, 1CD81A6C7244B2318E0BA2E8 /* Pods_Runner.framework */, diff --git a/frontend/appflowy_flutter/packages/appflowy_backend/lib/dispatch/dispatch.dart b/frontend/appflowy_flutter/packages/appflowy_backend/lib/dispatch/dispatch.dart index 552c6a268f..12fdd60ccf 100644 --- a/frontend/appflowy_flutter/packages/appflowy_backend/lib/dispatch/dispatch.dart +++ b/frontend/appflowy_flutter/packages/appflowy_backend/lib/dispatch/dispatch.dart @@ -24,8 +24,6 @@ import 'package:isolates/isolates.dart'; import 'package:isolates/ports.dart'; import 'package:protobuf/protobuf.dart'; -import '../protobuf/flowy-config/entities.pb.dart'; -import '../protobuf/flowy-config/event_map.pb.dart'; import '../protobuf/flowy-date/entities.pb.dart'; import '../protobuf/flowy-date/event_map.pb.dart'; @@ -35,7 +33,6 @@ part 'dart_event/flowy-folder/dart_event.dart'; part 'dart_event/flowy-user/dart_event.dart'; part 'dart_event/flowy-database2/dart_event.dart'; part 'dart_event/flowy-document/dart_event.dart'; -part 'dart_event/flowy-config/dart_event.dart'; part 'dart_event/flowy-date/dart_event.dart'; part 'dart_event/flowy-search/dart_event.dart'; part 'dart_event/flowy-ai/dart_event.dart'; diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lock index 87a5128960..c0df44a207 100644 --- a/frontend/appflowy_flutter/pubspec.lock +++ b/frontend/appflowy_flutter/pubspec.lock @@ -1989,18 +1989,18 @@ packages: dependency: "direct main" description: name: super_clipboard - sha256: cfeb142360fac67e0da1ca339accb892eb790c6528a218a008eef1709d96ed0f + sha256: "4a6ae6dfaa282ec1f2bff750976f535517ed8ca842d5deae13985eb11c00ac1f" url: "https://pub.dev" source: hosted - version: "0.8.22" + version: "0.8.24" super_native_extensions: dependency: transitive description: name: super_native_extensions - sha256: "6a7cfb7d212da7023b86fb99c736081e9c2cd982265d15dc5fe6381a32dbc875" + sha256: a433bba8186cd6b707560c42535bf284804665231c00bca86faf1aa4968b7637 url: "https://pub.dev" source: hosted - version: "0.8.22" + version: "0.8.24" sync_http: dependency: transitive description: diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yaml index 759c16e474..60ab502b2b 100644 --- a/frontend/appflowy_flutter/pubspec.yaml +++ b/frontend/appflowy_flutter/pubspec.yaml @@ -129,7 +129,7 @@ dependencies: sized_context: ^1.0.0+4 string_validator: ^1.0.0 styled_widget: ^0.4.1 - super_clipboard: ^0.8.4 + super_clipboard: ^0.8.24 synchronized: ^3.1.0+1 table_calendar: ^3.0.9 time: ^2.1.3 diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.toml b/frontend/appflowy_tauri/src-tauri/Cargo.toml index 196a93699a..f85e7c9151 100644 --- a/frontend/appflowy_tauri/src-tauri/Cargo.toml +++ b/frontend/appflowy_tauri/src-tauri/Cargo.toml @@ -19,7 +19,8 @@ tracing = "0.1.40" bytes = "1.5.0" serde = "1.0" serde_json = "1.0.108" -protobuf = { version = "2.28.0" } +protobuf.workspace = true + diesel = { version = "2.1.0", features = [ "sqlite", "chrono", @@ -78,7 +79,6 @@ lib-dispatch = { path = "../../rust-lib/lib-dispatch", features = [ ] } flowy-core = { path = "../../rust-lib/flowy-core", features = ["ts"] } flowy-user = { path = "../../rust-lib/flowy-user", features = ["tauri_ts"] } -flowy-config = { path = "../../rust-lib/flowy-config", features = ["tauri_ts"] } flowy-date = { path = "../../rust-lib/flowy-date", features = ["tauri_ts"] } flowy-ai = { path = "../../rust-lib/flowy-ai", features = ["tauri_ts"] } flowy-error = { path = "../../rust-lib/flowy-error", features = [ diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.toml b/frontend/appflowy_web_app/src-tauri/Cargo.toml index 56fa4bc799..90479b42d1 100644 --- a/frontend/appflowy_web_app/src-tauri/Cargo.toml +++ b/frontend/appflowy_web_app/src-tauri/Cargo.toml @@ -19,7 +19,7 @@ tracing = "0.1.40" bytes = "1.5.0" serde = "1.0" serde_json = "1.0.108" -protobuf = { version = "2.28.0" } +protobuf.workspace = true diesel = { version = "2.1.0", features = [ "sqlite", "chrono", @@ -77,7 +77,6 @@ lib-dispatch = { path = "../../rust-lib/lib-dispatch", features = [ ] } flowy-core = { path = "../../rust-lib/flowy-core", features = ["ts"] } flowy-user = { path = "../../rust-lib/flowy-user", features = ["tauri_ts"] } -flowy-config = { path = "../../rust-lib/flowy-config", features = ["tauri_ts"] } flowy-date = { path = "../../rust-lib/flowy-date", features = ["tauri_ts"] } flowy-error = { path = "../../rust-lib/flowy-error", features = [ "impl_from_sqlite", diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock index 54282cd279..34d76452a6 100644 --- a/frontend/rust-lib/Cargo.lock +++ b/frontend/rust-lib/Cargo.lock @@ -1393,7 +1393,7 @@ dependencies = [ "cssparser-macros", "dtoa-short", "itoa", - "phf 0.8.0", + "phf 0.11.2", "smallvec", ] @@ -1482,7 +1482,6 @@ dependencies = [ "collab-integrate", "crossbeam-utils", "flowy-codegen", - "flowy-config", "flowy-core", "flowy-date", "flowy-derive", @@ -1821,7 +1820,6 @@ dependencies = [ "flowy-database2", "flowy-document", "flowy-document-pub", - "flowy-encrypt", "flowy-folder", "flowy-folder-pub", "flowy-notification", @@ -2085,20 +2083,6 @@ dependencies = [ "walkdir", ] -[[package]] -name = "flowy-config" -version = "0.1.0" -dependencies = [ - "bytes", - "flowy-codegen", - "flowy-derive", - "flowy-error", - "flowy-sqlite", - "lib-dispatch", - "protobuf", - "strum_macros 0.21.1", -] - [[package]] name = "flowy-core" version = "0.1.0" @@ -2119,7 +2103,6 @@ dependencies = [ "diesel", "flowy-ai", "flowy-ai-pub", - "flowy-config", "flowy-database-pub", "flowy-database2", "flowy-date", @@ -2296,20 +2279,6 @@ dependencies = [ "lib-infra", ] -[[package]] -name = "flowy-encrypt" -version = "0.1.0" -dependencies = [ - "aes-gcm", - "anyhow", - "base64 0.21.5", - "getrandom 0.2.10", - "hmac", - "pbkdf2 0.12.2", - "rand 0.8.5", - "sha2", -] - [[package]] name = "flowy-error" version = "0.1.0" @@ -2483,7 +2452,6 @@ dependencies = [ "flowy-ai-pub", "flowy-database-pub", "flowy-document-pub", - "flowy-encrypt", "flowy-error", "flowy-folder-pub", "flowy-search-pub", @@ -2622,7 +2590,6 @@ dependencies = [ "fancy-regex 0.11.0", "flowy-codegen", "flowy-derive", - "flowy-encrypt", "flowy-error", "flowy-folder-pub", "flowy-notification", @@ -3675,10 +3642,12 @@ dependencies = [ name = "lib-infra" version = "0.1.0" dependencies = [ + "aes-gcm", "allo-isolate", "anyhow", "async-trait", "atomic_refcell", + "base64 0.22.1", "brotli", "bytes", "cfg-if", @@ -3686,9 +3655,12 @@ dependencies = [ "futures", "futures-core", "futures-util", + "hmac", "md5", + "pbkdf2 0.12.2", "pin-project", "rand 0.8.5", + "sha2", "tempfile", "tokio", "tracing", @@ -4504,7 +4476,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12" dependencies = [ - "phf_macros", + "phf_macros 0.8.0", "phf_shared 0.8.0", "proc-macro-hack", ] @@ -4524,6 +4496,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" dependencies = [ + "phf_macros 0.11.2", "phf_shared 0.11.2", ] @@ -4591,6 +4564,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "phf_macros" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +dependencies = [ + "phf_generator 0.11.2", + "phf_shared 0.11.2", + "proc-macro2", + "quote", + "syn 2.0.47", +] + [[package]] name = "phf_shared" version = "0.8.0" @@ -4908,53 +4894,60 @@ dependencies = [ [[package]] name = "protoc-bin-vendored" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "005ca8623e5633e298ad1f917d8be0a44bcf406bf3cde3b80e63003e49a3f27d" +checksum = "dd89a830d0eab2502c81a9b8226d446a52998bb78e5e33cb2637c0cdd6068d99" dependencies = [ "protoc-bin-vendored-linux-aarch_64", "protoc-bin-vendored-linux-ppcle_64", "protoc-bin-vendored-linux-x86_32", "protoc-bin-vendored-linux-x86_64", + "protoc-bin-vendored-macos-aarch_64", "protoc-bin-vendored-macos-x86_64", "protoc-bin-vendored-win32", ] [[package]] name = "protoc-bin-vendored-linux-aarch_64" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb9fc9cce84c8694b6ea01cc6296617b288b703719b725b8c9c65f7c5874435" +checksum = "f563627339f1653ea1453dfbcb4398a7369b768925eb14499457aeaa45afe22c" [[package]] name = "protoc-bin-vendored-linux-ppcle_64" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d2a07dcf7173a04d49974930ccbfb7fd4d74df30ecfc8762cf2f895a094516" +checksum = "5025c949a02cd3b60c02501dd0f348c16e8fff464f2a7f27db8a9732c608b746" [[package]] name = "protoc-bin-vendored-linux-x86_32" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54fef0b04fcacba64d1d80eed74a20356d96847da8497a59b0a0a436c9165b0" +checksum = "9c9500ce67d132c2f3b572504088712db715755eb9adf69d55641caa2cb68a07" [[package]] name = "protoc-bin-vendored-linux-x86_64" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8782f2ce7d43a9a5c74ea4936f001e9e8442205c244f7a3d4286bd4c37bc924" +checksum = "5462592380cefdc9f1f14635bcce70ba9c91c1c2464c7feb2ce564726614cc41" + +[[package]] +name = "protoc-bin-vendored-macos-aarch_64" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c637745681b68b4435484543667a37606c95ddacf15e917710801a0877506030" [[package]] name = "protoc-bin-vendored-macos-x86_64" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5de656c7ee83f08e0ae5b81792ccfdc1d04e7876b1d9a38e6876a9e09e02537" +checksum = "38943f3c90319d522f94a6dfd4a134ba5e36148b9506d2d9723a82ebc57c8b55" [[package]] name = "protoc-bin-vendored-win32" -version = "3.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9653c3ed92974e34c5a6e0a510864dab979760481714c172e0a34e437cb98804" +checksum = "7dc55d7dec32ecaf61e0bd90b3d2392d721a28b95cfd23c3e176eccefbeab2f2" [[package]] name = "protoc-rust" diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.toml index 1ddcb82c26..fd9b7ac1e9 100644 --- a/frontend/rust-lib/Cargo.toml +++ b/frontend/rust-lib/Cargo.toml @@ -18,8 +18,6 @@ members = [ "flowy-database-pub", "flowy-server", "flowy-server-pub", - "flowy-config", - "flowy-encrypt", "flowy-storage", "collab-integrate", "flowy-date", @@ -58,8 +56,6 @@ flowy-database2 = { path = "flowy-database2" } flowy-database-pub = { path = "flowy-database-pub" } flowy-server = { path = "flowy-server" } flowy-server-pub = { path = "flowy-server-pub" } -flowy-config = { path = "flowy-config" } -flowy-encrypt = { path = "flowy-encrypt" } flowy-storage = { path = "flowy-storage" } flowy-storage-pub = { path = "flowy-storage-pub" } flowy-search = { path = "flowy-search" } diff --git a/frontend/rust-lib/build-tool/flowy-codegen/Cargo.toml b/frontend/rust-lib/build-tool/flowy-codegen/Cargo.toml index 92a273ad04..27d36c310c 100644 --- a/frontend/rust-lib/build-tool/flowy-codegen/Cargo.toml +++ b/frontend/rust-lib/build-tool/flowy-codegen/Cargo.toml @@ -7,41 +7,42 @@ edition = "2021" [dependencies] log = "0.4.17" -serde = { workspace = true, features = ["derive"]} +serde = { workspace = true, features = ["derive"] } serde_json.workspace = true flowy-ast.workspace = true quote = "1.0" cmd_lib = { version = "1.3.0", optional = true } -protoc-rust = { version = "2", optional = true } +protoc-rust = { version = "2.28.0", optional = true } +#protobuf-codegen = { version = "3.7.1" } walkdir = { version = "2", optional = true } similar = { version = "1.3.0", optional = true } syn = { version = "1.0.109", features = ["extra-traits", "parsing", "derive", "full"] } fancy-regex = { version = "0.10.0", optional = true } lazy_static = { version = "1.4.0", optional = true } -tera = { version = "1.17.1", optional = true} +tera = { version = "1.17.1", optional = true } itertools = { version = "0.10", optional = true } phf = { version = "0.8.0", features = ["macros"], optional = true } -console = {version = "0.14.1", optional = true} -protoc-bin-vendored = { version = "3.0", optional = true } -toml = {version = "0.5.11", optional = true} +console = { version = "0.14.1", optional = true } +protoc-bin-vendored = { version = "3.1.0", optional = true } +toml = { version = "0.5.11", optional = true } [features] proto_gen = [ - "similar", - "fancy-regex", - "lazy_static", - "tera", - "itertools", - "phf", - "walkdir", - "console", - "toml", - "cmd_lib", - "protoc-rust", - "walkdir", - "protoc-bin-vendored", + "similar", + "fancy-regex", + "lazy_static", + "tera", + "itertools", + "phf", + "walkdir", + "console", + "toml", + "cmd_lib", + "protoc-rust", + "walkdir", + "protoc-bin-vendored", ] dart_event = ["walkdir", "tera", ] dart = ["proto_gen", "dart_event"] diff --git a/frontend/rust-lib/build-tool/flowy-codegen/src/protobuf_file/mod.rs b/frontend/rust-lib/build-tool/flowy-codegen/src/protobuf_file/mod.rs index 75b4b8eb4f..1ddb1bdeb0 100644 --- a/frontend/rust-lib/build-tool/flowy-codegen/src/protobuf_file/mod.rs +++ b/frontend/rust-lib/build-tool/flowy-codegen/src/protobuf_file/mod.rs @@ -12,8 +12,9 @@ use itertools::Itertools; use log::info; pub use proto_gen::*; pub use proto_info::*; +use std::fs; use std::fs::File; -use std::io::Write; +use std::io::{BufRead, BufReader, Write}; use std::path::{Path, PathBuf}; use std::process::Command; use walkdir::WalkDir; @@ -147,6 +148,38 @@ fn generate_rust_protobuf_files( .include(proto_file_output_path) .run() .expect("Running rust protoc failed."); + remove_box_pointers_lint_from_all_except_mod(protobuf_output_path); +} +fn remove_box_pointers_lint_from_all_except_mod(dir_path: &str) { + let dir = fs::read_dir(dir_path).expect("Failed to read directory"); + for entry in dir { + let entry = entry.expect("Failed to read directory entry"); + let path = entry.path(); + + // Skip directories and mod.rs + if path.is_file() { + if let Some(file_name) = path.file_name().and_then(|f| f.to_str()) { + if file_name != "mod.rs" { + remove_box_pointers_lint(&path); + } + } + } + } +} + +fn remove_box_pointers_lint(file_path: &Path) { + let file = File::open(file_path).expect("Failed to open file"); + let reader = BufReader::new(file); + let lines: Vec = reader + .lines() + .map_while(Result::ok) + .filter(|line| !line.contains("#![allow(box_pointers)]")) + .collect(); + + let mut file = File::create(file_path).expect("Failed to create file"); + for line in lines { + writeln!(file, "{}", line).expect("Failed to write line"); + } } #[cfg(feature = "ts")] diff --git a/frontend/rust-lib/dart-ffi/Cargo.toml b/frontend/rust-lib/dart-ffi/Cargo.toml index 91ed0d9bf6..8ad17c028f 100644 --- a/frontend/rust-lib/dart-ffi/Cargo.toml +++ b/frontend/rust-lib/dart-ffi/Cargo.toml @@ -36,7 +36,6 @@ flowy-core = { workspace = true } flowy-notification = { workspace = true, features = ["dart"] } flowy-document = { workspace = true, features = ["dart"] } -flowy-config = { workspace = true, features = ["dart"] } flowy-user = { workspace = true, features = ["dart"] } flowy-date = { workspace = true, features = ["dart"] } flowy-server = { workspace = true } diff --git a/frontend/rust-lib/event-integration-test/Cargo.toml b/frontend/rust-lib/event-integration-test/Cargo.toml index 33e4f4b184..392d82d858 100644 --- a/frontend/rust-lib/event-integration-test/Cargo.toml +++ b/frontend/rust-lib/event-integration-test/Cargo.toml @@ -15,7 +15,6 @@ flowy-database2 = { path = "../flowy-database2" } flowy-database-pub = { workspace = true } flowy-document = { path = "../flowy-document" } flowy-document-pub = { workspace = true } -flowy-encrypt = { workspace = true } flowy-ai = { workspace = true } lib-dispatch = { workspace = true } lib-infra = { workspace = true } diff --git a/frontend/rust-lib/flowy-config/Cargo.toml b/frontend/rust-lib/flowy-config/Cargo.toml deleted file mode 100644 index 821fcda2fc..0000000000 --- a/frontend/rust-lib/flowy-config/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "flowy-config" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -# workspace -flowy-sqlite = { workspace = true } -lib-dispatch = { workspace = true } -flowy-error = { workspace = true } - -flowy-derive.workspace = true -protobuf.workspace = true -bytes.workspace = true -strum_macros = "0.21" - -[build-dependencies] -flowy-codegen.workspace = true - -[features] -dart = ["flowy-codegen/dart"] -tauri_ts = ["flowy-codegen/ts"] diff --git a/frontend/rust-lib/flowy-config/Flowy.toml b/frontend/rust-lib/flowy-config/Flowy.toml deleted file mode 100644 index 0dbe74b3e3..0000000000 --- a/frontend/rust-lib/flowy-config/Flowy.toml +++ /dev/null @@ -1,3 +0,0 @@ -# Check out the FlowyConfig (located in flowy_toml.rs) for more details. -proto_input = ["src/event_map.rs", "src/entities.rs"] -event_files = ["src/event_map.rs"] \ No newline at end of file diff --git a/frontend/rust-lib/flowy-config/build.rs b/frontend/rust-lib/flowy-config/build.rs deleted file mode 100644 index e015eb2580..0000000000 --- a/frontend/rust-lib/flowy-config/build.rs +++ /dev/null @@ -1,23 +0,0 @@ -fn main() { - #[cfg(feature = "dart")] - { - flowy_codegen::protobuf_file::dart_gen(env!("CARGO_PKG_NAME")); - flowy_codegen::dart_event::gen(env!("CARGO_PKG_NAME")); - } - - #[cfg(feature = "tauri_ts")] - { - flowy_codegen::ts_event::gen(env!("CARGO_PKG_NAME"), flowy_codegen::Project::Tauri); - flowy_codegen::protobuf_file::ts_gen( - env!("CARGO_PKG_NAME"), - env!("CARGO_PKG_NAME"), - flowy_codegen::Project::Tauri, - ); - flowy_codegen::ts_event::gen(env!("CARGO_PKG_NAME"), flowy_codegen::Project::TauriApp); - flowy_codegen::protobuf_file::ts_gen( - env!("CARGO_PKG_NAME"), - env!("CARGO_PKG_NAME"), - flowy_codegen::Project::TauriApp, - ); - } -} diff --git a/frontend/rust-lib/flowy-config/src/entities.rs b/frontend/rust-lib/flowy-config/src/entities.rs deleted file mode 100644 index 931724d542..0000000000 --- a/frontend/rust-lib/flowy-config/src/entities.rs +++ /dev/null @@ -1,16 +0,0 @@ -use flowy_derive::ProtoBuf; - -#[derive(Default, ProtoBuf)] -pub struct KeyValuePB { - #[pb(index = 1)] - pub key: String, - - #[pb(index = 2, one_of)] - pub value: Option, -} - -#[derive(Default, ProtoBuf)] -pub struct KeyPB { - #[pb(index = 1)] - pub key: String, -} diff --git a/frontend/rust-lib/flowy-config/src/event_handler.rs b/frontend/rust-lib/flowy-config/src/event_handler.rs deleted file mode 100644 index 3bd97f8cb5..0000000000 --- a/frontend/rust-lib/flowy-config/src/event_handler.rs +++ /dev/null @@ -1,56 +0,0 @@ -use std::sync::Weak; - -use flowy_error::{FlowyError, FlowyResult}; -use flowy_sqlite::kv::KVStorePreferences; -use lib_dispatch::prelude::{data_result_ok, AFPluginData, AFPluginState, DataResult}; - -use crate::entities::{KeyPB, KeyValuePB}; - -pub(crate) async fn set_key_value_handler( - store_preferences: AFPluginState>, - data: AFPluginData, -) -> FlowyResult<()> { - let data = data.into_inner(); - - if let Some(store_preferences) = store_preferences.upgrade() { - match data.value { - None => store_preferences.remove(&data.key), - Some(value) => { - store_preferences.set_str(&data.key, value); - }, - } - } - - Ok(()) -} - -pub(crate) async fn get_key_value_handler( - store_preferences: AFPluginState>, - data: AFPluginData, -) -> DataResult { - match store_preferences.upgrade() { - None => Err(FlowyError::internal().with_context("The store preferences is already drop"))?, - Some(store_preferences) => { - let data = data.into_inner(); - let value = store_preferences.get_str(&data.key); - data_result_ok(KeyValuePB { - key: data.key, - value, - }) - }, - } -} - -pub(crate) async fn remove_key_value_handler( - store_preferences: AFPluginState>, - data: AFPluginData, -) -> FlowyResult<()> { - match store_preferences.upgrade() { - None => Err(FlowyError::internal().with_context("The store preferences is already drop"))?, - Some(store_preferences) => { - let data = data.into_inner(); - store_preferences.remove(&data.key); - Ok(()) - }, - } -} diff --git a/frontend/rust-lib/flowy-config/src/event_map.rs b/frontend/rust-lib/flowy-config/src/event_map.rs deleted file mode 100644 index 801dbdd75d..0000000000 --- a/frontend/rust-lib/flowy-config/src/event_map.rs +++ /dev/null @@ -1,31 +0,0 @@ -use std::sync::Weak; - -use strum_macros::Display; - -use flowy_derive::{Flowy_Event, ProtoBuf_Enum}; -use flowy_sqlite::kv::KVStorePreferences; -use lib_dispatch::prelude::AFPlugin; - -use crate::event_handler::*; - -pub fn init(store_preferences: Weak) -> AFPlugin { - AFPlugin::new() - .name(env!("CARGO_PKG_NAME")) - .state(store_preferences) - .event(ConfigEvent::SetKeyValue, set_key_value_handler) - .event(ConfigEvent::GetKeyValue, get_key_value_handler) - .event(ConfigEvent::RemoveKeyValue, remove_key_value_handler) -} - -#[derive(Debug, Clone, PartialEq, Eq, Hash, Display, ProtoBuf_Enum, Flowy_Event)] -#[event_err = "FlowyError"] -pub enum ConfigEvent { - #[event(input = "KeyValuePB")] - SetKeyValue = 0, - - #[event(input = "KeyPB", output = "KeyValuePB")] - GetKeyValue = 1, - - #[event(input = "KeyPB")] - RemoveKeyValue = 2, -} diff --git a/frontend/rust-lib/flowy-config/src/lib.rs b/frontend/rust-lib/flowy-config/src/lib.rs deleted file mode 100644 index e08a6c9ce6..0000000000 --- a/frontend/rust-lib/flowy-config/src/lib.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod entities; -mod event_handler; -pub mod event_map; -mod protobuf; diff --git a/frontend/rust-lib/flowy-core/Cargo.toml b/frontend/rust-lib/flowy-core/Cargo.toml index 09fd59d071..d1668524cb 100644 --- a/frontend/rust-lib/flowy-core/Cargo.toml +++ b/frontend/rust-lib/flowy-core/Cargo.toml @@ -20,7 +20,6 @@ flowy-document-pub = { workspace = true } flowy-error = { workspace = true } flowy-server = { workspace = true, features = ["enable_supabase"] } flowy-server-pub = { workspace = true } -flowy-config = { workspace = true } flowy-date = { workspace = true } collab-integrate = { workspace = true } flowy-search = { workspace = true } @@ -80,7 +79,6 @@ ts = [ "flowy-folder/tauri_ts", "flowy-search/tauri_ts", "flowy-database2/ts", - "flowy-config/tauri_ts", "flowy-ai/tauri_ts", "flowy-storage/tauri_ts", ] diff --git a/frontend/rust-lib/flowy-core/src/module.rs b/frontend/rust-lib/flowy-core/src/module.rs index 196fbce935..2e657bd9ca 100644 --- a/frontend/rust-lib/flowy-core/src/module.rs +++ b/frontend/rust-lib/flowy-core/src/module.rs @@ -18,15 +18,10 @@ pub fn make_plugins( ai_manager: Weak, file_storage_manager: Weak, ) -> Vec { - let store_preferences = user_session - .upgrade() - .map(|session| session.get_store_preferences()) - .unwrap(); let user_plugin = flowy_user::event_map::init(user_session); let folder_plugin = flowy_folder::event_map::init(folder_manager); let database_plugin = flowy_database2::event_map::init(database_manager); let document_plugin2 = flowy_document::event_map::init(document_manager2); - let config_plugin = flowy_config::event_map::init(store_preferences); let date_plugin = flowy_date::event_map::init(); let search_plugin = flowy_search::event_map::init(search_manager); let ai_plugin = flowy_ai::event_map::init(ai_manager); @@ -36,7 +31,6 @@ pub fn make_plugins( folder_plugin, database_plugin, document_plugin2, - config_plugin, date_plugin, search_plugin, ai_plugin, diff --git a/frontend/rust-lib/flowy-encrypt/Cargo.toml b/frontend/rust-lib/flowy-encrypt/Cargo.toml deleted file mode 100644 index 5ea42c60e2..0000000000 --- a/frontend/rust-lib/flowy-encrypt/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "flowy-encrypt" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["cdylib", "rlib"] - -[dependencies] -aes-gcm = "0.10.2" -rand = "0.8" -pbkdf2 = "0.12.2" -hmac = "0.12.1" -sha2 = "0.10.7" -anyhow.workspace = true -base64 = "0.21.2" - -[target.'cfg(target_arch = "wasm32")'.dependencies] -getrandom = { version = "0.2", features = ["js"]} \ No newline at end of file diff --git a/frontend/rust-lib/flowy-encrypt/src/lib.rs b/frontend/rust-lib/flowy-encrypt/src/lib.rs deleted file mode 100644 index a72d275af9..0000000000 --- a/frontend/rust-lib/flowy-encrypt/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub use encrypt::*; - -mod encrypt; diff --git a/frontend/rust-lib/flowy-server/Cargo.toml b/frontend/rust-lib/flowy-server/Cargo.toml index e5eb124fad..9e67081eb7 100644 --- a/frontend/rust-lib/flowy-server/Cargo.toml +++ b/frontend/rust-lib/flowy-server/Cargo.toml @@ -43,7 +43,6 @@ flowy-document-pub = { workspace = true } flowy-error = { workspace = true, features = ["impl_from_serde", "impl_from_reqwest", "impl_from_url", "impl_from_appflowy_cloud"] } flowy-server-pub = { workspace = true } flowy-search-pub = { workspace = true } -flowy-encrypt = { workspace = true } flowy-storage = { workspace = true } flowy-storage-pub = { workspace = true } flowy-ai-pub = { workspace = true } @@ -59,11 +58,11 @@ semver = "1.0.23" [dependencies.client-api] workspace = true features = [ - "collab-sync", - "test_util", - "enable_brotli", - # Uncomment the following line to enable verbose logging for sync - # "sync_verbose_log", + "collab-sync", + "test_util", + "enable_brotli", + # Uncomment the following line to enable verbose logging for sync + # "sync_verbose_log", ] [dev-dependencies] diff --git a/frontend/rust-lib/flowy-user/Cargo.toml b/frontend/rust-lib/flowy-user/Cargo.toml index 8eb7f06ee8..2a02043f38 100644 --- a/frontend/rust-lib/flowy-user/Cargo.toml +++ b/frontend/rust-lib/flowy-user/Cargo.toml @@ -8,10 +8,9 @@ edition = "2018" [dependencies] flowy-derive.workspace = true flowy-sqlite = { workspace = true } -flowy-encrypt = { workspace = true } flowy-error = { workspace = true, features = ["impl_from_dispatch_error", "impl_from_sqlite", "impl_from_collab_folder", "impl_from_collab_persistence", "impl_from_collab_document"] } flowy-folder-pub = { workspace = true } -lib-infra = { workspace = true } +lib-infra = { workspace = true, features = ["encryption"] } flowy-notification = { workspace = true } flowy-server-pub = { workspace = true } lib-dispatch = { workspace = true } diff --git a/frontend/rust-lib/flowy-user/src/services/cloud_config.rs b/frontend/rust-lib/flowy-user/src/services/cloud_config.rs index d4b4afc7a8..30f5725f9c 100644 --- a/frontend/rust-lib/flowy-user/src/services/cloud_config.rs +++ b/frontend/rust-lib/flowy-user/src/services/cloud_config.rs @@ -1,9 +1,9 @@ use std::sync::Arc; -use flowy_encrypt::generate_encryption_secret; use flowy_error::FlowyResult; use flowy_sqlite::kv::KVStorePreferences; use flowy_user_pub::cloud::UserCloudConfig; +use lib_infra::encryption::generate_encryption_secret; const CLOUD_CONFIG_KEY: &str = "af_user_cloud_config"; diff --git a/frontend/rust-lib/flowy-user/src/user_manager/manager_user_encryption.rs b/frontend/rust-lib/flowy-user/src/user_manager/manager_user_encryption.rs index 4288260899..2bfba3422e 100644 --- a/frontend/rust-lib/flowy-user/src/user_manager/manager_user_encryption.rs +++ b/frontend/rust-lib/flowy-user/src/user_manager/manager_user_encryption.rs @@ -1,13 +1,12 @@ use crate::entities::{AuthStateChangedPB, AuthStatePB}; +use crate::notification::send_auth_state_notification; +use crate::services::cloud_config::get_encrypt_secret; use crate::user_manager::UserManager; -use flowy_encrypt::{decrypt_text, encrypt_text}; use flowy_error::{ErrorCode, FlowyError, FlowyResult}; use flowy_user_pub::entities::{ EncryptionType, UpdateUserProfileParams, UserCredentials, UserProfile, }; - -use crate::notification::send_auth_state_notification; -use crate::services::cloud_config::get_encrypt_secret; +use lib_infra::encryption::{decrypt_text, encrypt_text}; impl UserManager { pub async fn set_encrypt_secret( diff --git a/frontend/rust-lib/lib-infra/Cargo.toml b/frontend/rust-lib/lib-infra/Cargo.toml index 7dc6f85bb3..12c805862b 100644 --- a/frontend/rust-lib/lib-infra/Cargo.toml +++ b/frontend/rust-lib/lib-infra/Cargo.toml @@ -26,6 +26,14 @@ futures = "0.3.30" cfg-if = "1.0.0" futures-util = "0.3.30" + +aes-gcm = { version = "0.10.2", optional = true } +rand = { version = "0.8.5", optional = true } +pbkdf2 = { version = "0.12.2", optional = true } +hmac = { version = "0.12.1", optional = true } +sha2 = { version = "0.10.7", optional = true } +base64 = { version = "0.22.1" } + [dev-dependencies] rand = "0.8.5" futures = "0.3.30" @@ -37,3 +45,4 @@ brotli = { version = "3.4.0", optional = true } [features] compression = ["brotli"] isolate_flutter = ["allo-isolate"] +encryption = ["aes-gcm", "rand", "pbkdf2", "hmac", "sha2"] \ No newline at end of file diff --git a/frontend/rust-lib/flowy-encrypt/src/encrypt.rs b/frontend/rust-lib/lib-infra/src/encryption/mod.rs similarity index 98% rename from frontend/rust-lib/flowy-encrypt/src/encrypt.rs rename to frontend/rust-lib/lib-infra/src/encryption/mod.rs index 88658858bb..6caabdc5cc 100644 --- a/frontend/rust-lib/flowy-encrypt/src/encrypt.rs +++ b/frontend/rust-lib/lib-infra/src/encryption/mod.rs @@ -46,7 +46,12 @@ pub fn encrypt_data>(data: T, combined_passphrase_salt: &str) -> .encrypt(GenericArray::from_slice(&nonce), data.as_ref()) .unwrap(); - Ok(nonce.into_iter().chain(ciphertext).collect()) + let result = nonce + .iter() + .copied() + .chain(ciphertext.iter().copied()) + .collect(); + Ok(result) } /// Decrypt a byte slice using AES-GCM. diff --git a/frontend/rust-lib/lib-infra/src/lib.rs b/frontend/rust-lib/lib-infra/src/lib.rs index 3b46e162fb..dc2ed5263c 100644 --- a/frontend/rust-lib/lib-infra/src/lib.rs +++ b/frontend/rust-lib/lib-infra/src/lib.rs @@ -19,6 +19,8 @@ if_wasm! { } } +#[cfg(feature = "encryption")] +pub mod encryption; #[cfg(feature = "isolate_flutter")] pub mod isolate_stream; pub mod priority_task; diff --git a/frontend/rust-lib/rust-toolchain.toml b/frontend/rust-lib/rust-toolchain.toml index 4d2dee853e..1de01fa45c 100644 --- a/frontend/rust-lib/rust-toolchain.toml +++ b/frontend/rust-lib/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.80.0" +channel = "1.81.0" diff --git a/frontend/scripts/docker-buildfiles/Dockerfile b/frontend/scripts/docker-buildfiles/Dockerfile index 19f7565953..960c1ba625 100644 --- a/frontend/scripts/docker-buildfiles/Dockerfile +++ b/frontend/scripts/docker-buildfiles/Dockerfile @@ -22,8 +22,8 @@ RUN sudo pacman -S --needed --noconfirm curl base-devel openssl clang cmake ninj RUN xdg-user-dirs-update RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y RUN source ~/.cargo/env && \ - rustup toolchain install 1.80.1 && \ - rustup default 1.80.1 + rustup toolchain install 1.81 && \ + rustup default 1.81 # Install Flutter RUN sudo pacman -S --noconfirm git tar gtk3 diff --git a/frontend/scripts/makefile/desktop.toml b/frontend/scripts/makefile/desktop.toml index f1f0aa0219..f972aa5cd4 100644 --- a/frontend/scripts/makefile/desktop.toml +++ b/frontend/scripts/makefile/desktop.toml @@ -1,4 +1,3 @@ - [tasks.env_check] dependencies = ["echo_env", "install_flutter_protobuf"] condition = { env_set = [ @@ -100,7 +99,7 @@ dependencies = ["set-app-version"] script = [ """ cd rust-lib/ - cargo build --profile ${CARGO_PROFILE} --${BUILD_FLAG} --package=dart-ffi --target ${RUST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}" + cargo build --profile ${CARGO_PROFILE} --package=dart-ffi --target ${RUST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}" cd ../ """, ] @@ -111,7 +110,7 @@ dependencies = ["set-app-version"] script = [ """ cd rust-lib/ - cargo build --profile ${CARGO_PROFILE} --${BUILD_FLAG} --package=dart-ffi --target ${RUST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}" + cargo build --profile ${CARGO_PROFILE} --package=dart-ffi --target ${RUST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}" cd ../ """, ] diff --git a/frontend/scripts/makefile/web.toml b/frontend/scripts/makefile/web.toml index d00dbaf8d1..52c09ea6bb 100644 --- a/frontend/scripts/makefile/web.toml +++ b/frontend/scripts/makefile/web.toml @@ -1,31 +1,31 @@ [tasks.wasm_build] script_runner = "bash" script = [ - """ - #!/usr/bin/env bash - BASE_DIR=$(pwd) - crates=("lib-dispatch" "flowy-encrypt" "lib-infra" "flowy-notification" "flowy-date" "flowy-error" "collab-integrate" "flowy-document") + """ + #!/usr/bin/env bash + BASE_DIR=$(pwd) + crates=("lib-dispatch" "lib-infra" "flowy-notification" "flowy-date" "flowy-error" "collab-integrate" "flowy-document") - # Iterate over each crate and build it - for crate in "${crates[@]}"; do - echo "🔥🔥🔥 Building $crate with wasm-pack..." - cd "$BASE_DIR/rust-lib/$crate" || { echo "Failed to enter directory $crate"; exit 1; } + # Iterate over each crate and build it + for crate in "${crates[@]}"; do + echo "🔥🔥🔥 Building $crate with wasm-pack..." + cd "$BASE_DIR/rust-lib/$crate" || { echo "Failed to enter directory $crate"; exit 1; } - wasm-pack build || { echo "Build failed for $crate"; exit 1; } - done - """ + wasm-pack build || { echo "Build failed for $crate"; exit 1; } + done + """ ] [tasks.web_clean] description = "Remove all the building artifacts" run_task = { name = [ - "rust_lib_clean", - "rm_macro_build_cache", - "rm_rust_generated_files", - "rm_web_generated_protobuf_files", - "rm_web_generated_event_files", - "rm_pkg", + "rust_lib_clean", + "rm_macro_build_cache", + "rm_rust_generated_files", + "rm_web_generated_protobuf_files", + "rm_web_generated_event_files", + "rm_pkg", ] } [tasks.rm_web_generated_protobuf_files]