diff --git a/Cargo.lock b/Cargo.lock index dde59a7..51319d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7352,6 +7352,7 @@ dependencies = [ "tauri-plugin-clipboard", "tauri-plugin-network", "tauri-plugin-store", + "tauri-plugin-stronghold", "tauri-plugin-upload", "tauri-winres", "thiserror 1.0.66", diff --git a/Cargo.toml b/Cargo.toml index d56e701..7c1008c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,4 +44,5 @@ openssl = "0.10.68" tower = { version = "0.4", features = ["util"] } tower-http = { version = "0.4.0", features = ["fs", "trace", "cors"] } rayon = "1.10.0" +tauri-plugin-stronghold = "2" tauri-plugin-upload = { git = "https://github.com/HuakunShen/tauri-plugins-workspace.git", branch = "kunkun", package = "tauri-plugin-upload" } diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 4909f1a..84b636d 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -56,7 +56,7 @@ uuid = "1.11.0" # tauri-plugin-devtools = "2.0.0" obfstr = { workspace = true } base64 = { workspace = true } -tauri-plugin-stronghold = "2" +tauri-plugin-stronghold = { workspace = true } [target."cfg(target_os = \"macos\")".dependencies] cocoa = "0.24.1" diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs index 83c1760..97d9728 100644 --- a/apps/desktop/src-tauri/src/lib.rs +++ b/apps/desktop/src-tauri/src/lib.rs @@ -197,7 +197,6 @@ pub fn run() { .setup(move |app| { setup::window::setup_window(app.handle()); setup::tray::create_tray(app.handle())?; - setup::stronghold::setup_stronghold(app.handle())?; #[cfg(all(not(target_os = "macos"), debug_assertions))] { app.deep_link().register("kunkun")?; @@ -245,7 +244,10 @@ pub fn run() { // setup::db::setup_db(app)?; let db_key = setup::keyring::setup_keyring(app.handle())?; let db_path = get_kunkun_db_path(app.app_handle())?; - app.manage(tauri_plugin_jarvis::commands::db::DBState::new(db_path.clone(), db_key.clone())?); + app.manage(tauri_plugin_jarvis::commands::db::DBState::new( + db_path.clone(), + db_key.clone(), + )?); tauri_plugin_jarvis::setup::db::setup_db(app.app_handle())?; /* ------------------------- Clipboard History Setup ------------------------ */ diff --git a/apps/desktop/src-tauri/src/setup/mod.rs b/apps/desktop/src-tauri/src/setup/mod.rs index 9d8aeda..a698331 100644 --- a/apps/desktop/src-tauri/src/setup/mod.rs +++ b/apps/desktop/src-tauri/src/setup/mod.rs @@ -1,6 +1,5 @@ pub mod clipboard; pub mod deeplink; pub mod keyring; -pub mod stronghold; pub mod tray; pub mod window; diff --git a/apps/desktop/src-tauri/src/setup/stronghold.rs b/apps/desktop/src-tauri/src/setup/stronghold.rs deleted file mode 100644 index 9fd27aa..0000000 --- a/apps/desktop/src-tauri/src/setup/stronghold.rs +++ /dev/null @@ -1,11 +0,0 @@ -use tauri::{AppHandle, Manager}; - -pub fn setup_stronghold(app: &AppHandle) -> tauri::Result<()> { - let salt_path = app - .path() - .app_local_data_dir() - .expect("could not resolve app local data path") - .join("salt.txt"); - app.plugin(tauri_plugin_stronghold::Builder::with_argon2(&salt_path).build())?; - Ok(()) -} diff --git a/packages/tauri-plugins/jarvis/Cargo.toml b/packages/tauri-plugins/jarvis/Cargo.toml index 3e49a99..6b0c387 100644 --- a/packages/tauri-plugins/jarvis/Cargo.toml +++ b/packages/tauri-plugins/jarvis/Cargo.toml @@ -15,6 +15,7 @@ serde_json = { workspace = true } thiserror = "1.0" applications = { workspace = true } anyhow = { workspace = true } +tauri-plugin-stronghold = { workspace = true } tar = "0.4.40" flate2 = "1.0.30" window-vibrancy = "0.5.0" diff --git a/packages/tauri-plugins/jarvis/src/lib.rs b/packages/tauri-plugins/jarvis/src/lib.rs index c869b26..1435931 100644 --- a/packages/tauri-plugins/jarvis/src/lib.rs +++ b/packages/tauri-plugins/jarvis/src/lib.rs @@ -54,7 +54,13 @@ impl JarvisState { /// Initializes the plugin. pub fn init() -> TauriPlugin { + let salt_path = app + .path() + .app_local_data_dir() + .expect("could not resolve app local data path") + .join("salt.txt"); Builder::new("jarvis") + .plugin(tauri_plugin_stronghold::Builder::with_argon2(&salt_path).build())? .invoke_handler(tauri::generate_handler![ /* ------------------------------ dev commands ------------------------------ */ commands::dev::open_devtools, @@ -180,6 +186,7 @@ pub fn init() -> TauriPlugin { .setup(move |app, api| { utils::setup::setup_app_path(app); utils::setup::setup_extension_storage(app); + utils::setup::setup_stronghold(app); // manage state so it is accessible by the commands app.manage(JarvisState::new()); diff --git a/packages/tauri-plugins/jarvis/src/utils/setup.rs b/packages/tauri-plugins/jarvis/src/utils/setup.rs index a19d51c..d7b6c10 100644 --- a/packages/tauri-plugins/jarvis/src/utils/setup.rs +++ b/packages/tauri-plugins/jarvis/src/utils/setup.rs @@ -45,3 +45,13 @@ pub fn setup_extension_storage(handle: &AppHandle) { std::fs::create_dir_all(&ext_dir).unwrap(); } } + +pub fn setup_stronghold(app: &AppHandle) -> tauri::Result<()> { + let salt_path = app + .path() + .app_local_data_dir() + .expect("could not resolve app local data path") + .join("salt.txt"); + app.plugin(tauri_plugin_stronghold::Builder::with_argon2(&salt_path).build())?; + Ok(()) +}