chore(agent): major version dependency bump (#4446)
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
nodePackages_latest.vls
|
||||
nodePackages_latest.prisma
|
||||
prisma-engines
|
||||
# Cargo
|
||||
cargo-edit
|
||||
];
|
||||
|
||||
# https://devenv.sh/basics/
|
||||
|
||||
@@ -11,24 +11,24 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@hoppscotch/ui": "^0.2.1",
|
||||
"@tauri-apps/api": ">=2.0.0-rc.0",
|
||||
"@tauri-apps/plugin-shell": ">=2.0.0-rc.0",
|
||||
"@tauri-apps/api": "^2.0.2",
|
||||
"@tauri-apps/plugin-shell": "^2.0.0",
|
||||
"@vueuse/core": "^11.1.0",
|
||||
"axios": "^1.7.7",
|
||||
"fp-ts": "^2.16.9",
|
||||
"vue": "^3.3.4"
|
||||
"vue": "3.3.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify-json/lucide": "^1.2.6",
|
||||
"@tauri-apps/cli": ">=2.0.0-rc.0",
|
||||
"@types/node": "^22.7.0",
|
||||
"@iconify-json/lucide": "^1.2.8",
|
||||
"@tauri-apps/cli": "^2.0.3",
|
||||
"@types/node": "^22.7.5",
|
||||
"@vitejs/plugin-vue": "^5.1.4",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"postcss": "^8.4.47",
|
||||
"tailwindcss": "^3.4.13",
|
||||
"typescript": "^5.2.2",
|
||||
"typescript": "^5.6.3",
|
||||
"unplugin-icons": "^0.19.3",
|
||||
"vite": "^5.4.7",
|
||||
"vue-tsc": "^2.0.22"
|
||||
"vite": "^5.4.8",
|
||||
"vue-tsc": "^2.1.6"
|
||||
}
|
||||
}
|
||||
|
||||
837
packages/hoppscotch-agent/src-tauri/Cargo.lock
generated
837
packages/hoppscotch-agent/src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -12,36 +12,36 @@ name = "hoppscotch_agent_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2.0.0-rc", features = [] }
|
||||
tauri-build = { version = "2.0.1", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2.0.0-rc.0", features = ["tray-icon", "image-png"] }
|
||||
tauri-plugin-shell = "2.0.0-rc"
|
||||
tauri-plugin-autostart = "2.0.0-rc"
|
||||
tauri = { version = "2.0.4", features = ["tray-icon", "image-png"] }
|
||||
tauri-plugin-shell = "2.0.1"
|
||||
tauri-plugin-autostart = "2.0.1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
tokio = { version = "1.40.0", features = ["full"] }
|
||||
dashmap = { version = "6.1.0", features = ["serde"] }
|
||||
axum = { version = "0.7.6" }
|
||||
axum = { version = "0.7.7" }
|
||||
axum-extra = { version = "0.9.4", features = ["typed-header"] }
|
||||
tower-http = { version = "0.6.1", features = ["cors"] }
|
||||
tokio-util = "0.7.12"
|
||||
uuid = { version = "1.10.0", features = [ "v4", "fast-rng" ] }
|
||||
uuid = { version = "1.11.0", features = [ "v4", "fast-rng" ] }
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
rand = "0.8.5"
|
||||
log = "0.4.22"
|
||||
env_logger = "0.11.5"
|
||||
curl = { version = "0.4.46", features = ["ntlm", "static-curl", "static-ssl"] }
|
||||
openssl = { version = "0.10.66", features = ["vendored"] }
|
||||
openssl-sys = { version = "0.9.103", features = ["vendored"] }
|
||||
curl = { version = "0.4.47", features = ["ntlm", "static-curl", "static-ssl"] }
|
||||
openssl = { version = "0.10.68", features = ["vendored"] }
|
||||
openssl-sys = { version = "0.9.104", features = ["vendored"] }
|
||||
url-escape = "0.1.1"
|
||||
thiserror = "1.0.64"
|
||||
tauri-plugin-store = "2.0.0-rc.3"
|
||||
tauri-plugin-store = "2.0.1"
|
||||
x25519-dalek = { version = "2.0.1", features = ["getrandom"] }
|
||||
base16 = "0.2.1"
|
||||
aes-gcm = { version = "0.10.3", features = ["aes"] }
|
||||
tauri-plugin-updater = "2.0.0-rc.3"
|
||||
tauri-plugin-dialog = "2.0.0-rc.7"
|
||||
tauri-plugin-updater = "2.0.2"
|
||||
tauri-plugin-dialog = "2.0.1"
|
||||
http = "1.1.0"
|
||||
lazy_static = "1.5.0"
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ pub enum AppError {
|
||||
RegistrationInsertError,
|
||||
#[error("Failed to save registrations to store")]
|
||||
RegistrationSaveError,
|
||||
#[error("Store error: {0}")]
|
||||
TauriPluginStore(#[from] tauri_plugin_store::Error),
|
||||
}
|
||||
|
||||
impl IntoResponse for AppError {
|
||||
|
||||
@@ -4,20 +4,20 @@ use chrono::{DateTime, Utc};
|
||||
use dashmap::DashMap;
|
||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||
use tauri_plugin_store::StoreBuilder;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use tokio::sync::RwLock;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
use crate::error::AppError;
|
||||
|
||||
/// Describes one registered app instance
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Registration {
|
||||
pub registered_at: DateTime<Utc>,
|
||||
pub registered_at: DateTime<Utc>,
|
||||
|
||||
/// base16 (lowercase) encoded shared secret that the client
|
||||
/// and agent established during registration that is used
|
||||
/// to encrypt traffic between them
|
||||
pub shared_secret_b16: String
|
||||
/// base16 (lowercase) encoded shared secret that the client
|
||||
/// and agent established during registration that is used
|
||||
/// to encrypt traffic between them
|
||||
pub shared_secret_b16: String,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@@ -30,28 +30,26 @@ pub struct AppState {
|
||||
|
||||
/// Registrations against the agent, the key is the auth
|
||||
/// token associated to the registration
|
||||
registrations: DashMap<String, Registration>
|
||||
registrations: DashMap<String, Registration>,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
|
||||
pub fn new(app_handle: tauri::AppHandle) -> Self {
|
||||
let mut store = StoreBuilder::new("app_data.bin")
|
||||
.build(app_handle);
|
||||
let store = StoreBuilder::new(&app_handle, "app_data.bin").build();
|
||||
|
||||
let _ = store.load();
|
||||
|
||||
// Try loading and parsing registrations from the store, if that failed,
|
||||
// load the default list
|
||||
let registrations = store.get("registrations")
|
||||
.and_then(|val| serde_json::from_value(val.clone()).ok())
|
||||
.unwrap_or_else(|| DashMap::new());
|
||||
|
||||
let registrations = store
|
||||
.get("registrations")
|
||||
.and_then(|val| serde_json::from_value(val.clone()).ok())
|
||||
.unwrap_or_else(|| DashMap::new());
|
||||
|
||||
Self {
|
||||
active_registration_code: RwLock::new(None),
|
||||
cancellation_tokens: DashMap::new(),
|
||||
registrations
|
||||
registrations,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,39 +58,41 @@ impl AppState {
|
||||
/// reference, you shouldn't do it for registrations as `update_registrations`
|
||||
/// performs save operation that needs to be done and should be used instead
|
||||
pub fn get_registrations(&self) -> &DashMap<String, Registration> {
|
||||
&self.registrations
|
||||
&self.registrations
|
||||
}
|
||||
|
||||
/// Provides you an opportunity to update the registrations list
|
||||
/// and also persists the data to the disk
|
||||
pub fn update_registrations(
|
||||
pub fn update_registrations(
|
||||
&self,
|
||||
app_handle: tauri::AppHandle,
|
||||
update_func: impl FnOnce(&DashMap<String, Registration>)
|
||||
update_func: impl FnOnce(&DashMap<String, Registration>),
|
||||
) -> Result<(), AppError> {
|
||||
update_func(&self.registrations);
|
||||
|
||||
let mut store = StoreBuilder::new("app_data.bin")
|
||||
.build(app_handle);
|
||||
let store = StoreBuilder::new(&app_handle, "app_data.bin").build();
|
||||
|
||||
let _ = store.load();
|
||||
let _ = store.load()?;
|
||||
|
||||
store.delete("registrations")
|
||||
.map_err(|_| AppError::RegistrationClearError)?;
|
||||
let _ = store
|
||||
.delete("registrations")
|
||||
.then_some(())
|
||||
.ok_or(AppError::RegistrationClearError)?;
|
||||
|
||||
store.insert("registrations".into(), serde_json::to_value(self.registrations.clone()).unwrap())
|
||||
.map_err(|_| AppError::RegistrationInsertError)?;
|
||||
let _ = store.set(
|
||||
"registrations",
|
||||
serde_json::to_value(self.registrations.clone()).unwrap(),
|
||||
);
|
||||
|
||||
store.save()
|
||||
.map_err(|_| AppError::RegistrationSaveError)?;
|
||||
store.save().map_err(|_| AppError::RegistrationSaveError)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn validate_registration(&self, registration: &str) -> bool {
|
||||
match *self.active_registration_code.read().await {
|
||||
Some(ref code) => code == registration,
|
||||
None => false
|
||||
Some(ref code) => code == registration,
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,50 +105,40 @@ impl AppState {
|
||||
}
|
||||
|
||||
pub fn validate_access(&self, auth_key: &str) -> bool {
|
||||
self.registrations.get(auth_key).is_some()
|
||||
self.registrations.get(auth_key).is_some()
|
||||
}
|
||||
|
||||
pub fn validate_access_and_get_data<T>(
|
||||
&self,
|
||||
auth_key: &str,
|
||||
nonce: &str,
|
||||
data: &Bytes
|
||||
&self,
|
||||
auth_key: &str,
|
||||
nonce: &str,
|
||||
data: &Bytes,
|
||||
) -> Option<T>
|
||||
where
|
||||
T : DeserializeOwned
|
||||
T: DeserializeOwned,
|
||||
{
|
||||
if let Some(registration) = self.registrations.get(auth_key) {
|
||||
let key: [u8; 32] = base16::decode(®istration.shared_secret_b16)
|
||||
.ok()?
|
||||
[0..32]
|
||||
.try_into()
|
||||
.ok()?;
|
||||
if let Some(registration) = self.registrations.get(auth_key) {
|
||||
let key: [u8; 32] = base16::decode(®istration.shared_secret_b16).ok()?[0..32]
|
||||
.try_into()
|
||||
.ok()?;
|
||||
|
||||
let nonce: [u8; 12] = base16::decode(nonce)
|
||||
.ok()?
|
||||
[0..12]
|
||||
.try_into()
|
||||
.ok()?;
|
||||
let nonce: [u8; 12] = base16::decode(nonce).ok()?[0..12].try_into().ok()?;
|
||||
|
||||
let cipher = Aes256Gcm::new(&key.into());
|
||||
let cipher = Aes256Gcm::new(&key.into());
|
||||
|
||||
let data = data
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect::<Vec<u8>>();
|
||||
let data = data.iter().cloned().collect::<Vec<u8>>();
|
||||
|
||||
let plain_data = cipher.decrypt(&nonce.into(), data.as_slice())
|
||||
.ok()?;
|
||||
let plain_data = cipher.decrypt(&nonce.into(), data.as_slice()).ok()?;
|
||||
|
||||
serde_json::from_reader(plain_data.as_slice())
|
||||
.ok()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
serde_json::from_reader(plain_data.as_slice()).ok()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_registration_info(&self, auth_key: &str) -> Option<Registration> {
|
||||
self.registrations.get(auth_key)
|
||||
.map(|reference| reference.value().clone())
|
||||
self.registrations
|
||||
.get(auth_key)
|
||||
.map(|reference| reference.value().clone())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +1,39 @@
|
||||
#[cfg(desktop)]
|
||||
pub async fn check_and_install_updates(app: tauri::AppHandle, updater: tauri_plugin_updater::Updater) {
|
||||
use tauri::Manager;
|
||||
use tauri_plugin_dialog::MessageDialogKind;
|
||||
use tauri_plugin_dialog::DialogExt;
|
||||
pub async fn check_and_install_updates(
|
||||
app: tauri::AppHandle,
|
||||
updater: tauri_plugin_updater::Updater,
|
||||
) {
|
||||
use tauri::Manager;
|
||||
use tauri_plugin_dialog::DialogExt;
|
||||
use tauri_plugin_dialog::MessageDialogButtons;
|
||||
use tauri_plugin_dialog::MessageDialogKind;
|
||||
|
||||
let update = updater.check().await;
|
||||
|
||||
let update = updater.check().await;
|
||||
if let Ok(Some(update)) = update {
|
||||
let do_update = app
|
||||
.dialog()
|
||||
.message(format!(
|
||||
"Update to {} is available!{}",
|
||||
update.version,
|
||||
update
|
||||
.body
|
||||
.clone()
|
||||
.map(|body| format!("\n\nRelease Notes: {}", body))
|
||||
.unwrap_or("".into())
|
||||
))
|
||||
.title("Update Available")
|
||||
.kind(MessageDialogKind::Info)
|
||||
.buttons(MessageDialogButtons::OkCancelCustom(
|
||||
"Update".to_string(),
|
||||
"Cancel".to_string(),
|
||||
))
|
||||
.blocking_show();
|
||||
|
||||
if let Ok(Some(update)) = update {
|
||||
let do_update = app.dialog()
|
||||
.message(
|
||||
format!(
|
||||
"Update to {} is available!{}",
|
||||
update.version,
|
||||
update.body
|
||||
.clone()
|
||||
.map(|body| format!("\n\nRelease Notes: {}", body))
|
||||
.unwrap_or("".into())
|
||||
)
|
||||
)
|
||||
.title("Update Available")
|
||||
.kind(MessageDialogKind::Info)
|
||||
.ok_button_label("Update")
|
||||
.cancel_button_label("Cancel")
|
||||
.blocking_show();
|
||||
if do_update {
|
||||
let _ = update.download_and_install(|_, _| {}, || {}).await;
|
||||
|
||||
if do_update {
|
||||
let _ = update.download_and_install(|_, _| {}, || {}).await;
|
||||
|
||||
tauri::process::restart(&app.env());
|
||||
}
|
||||
}
|
||||
tauri::process::restart(&app.env());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
838
pnpm-lock.yaml
generated
838
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user