diff --git a/new-ui/src/shared/components/WindowHeader/WindowHeader.tsx b/new-ui/src/shared/components/WindowHeader/WindowHeader.tsx index 25ff47939..4c477c2d3 100644 --- a/new-ui/src/shared/components/WindowHeader/WindowHeader.tsx +++ b/new-ui/src/shared/components/WindowHeader/WindowHeader.tsx @@ -1,8 +1,8 @@ import clsx from 'clsx'; import './style.scss'; import { useQuery } from '@tanstack/react-query'; -import { getVersion } from '@tauri-apps/api/app'; import { useId } from 'react'; +import { api } from '../../rust-api/api'; import { isPresent } from '../../utils/isPresent'; import { ConnectionWatcher } from './components/ConnectionWatcher/ConnectionsWatcher'; @@ -12,8 +12,8 @@ interface Props { export const WindowHeader = ({ variant }: Props) => { const { data: appVersion } = useQuery({ - queryFn: getVersion, - queryKey: ['app-version'], + queryFn: api.getClientBuildVersion, + queryKey: ['client-build-version'], }); const version = () => { diff --git a/new-ui/src/shared/rust-api/api.ts b/new-ui/src/shared/rust-api/api.ts index bb14ec542..f21f31457 100644 --- a/new-ui/src/shared/rust-api/api.ts +++ b/new-ui/src/shared/rust-api/api.ts @@ -120,6 +120,9 @@ const getPlatformHeader = (): Promise => invoke(TauriCommand.GetPlatform const getLatestAppVersion = (): Promise => invoke(TauriCommand.GetLatestAppVersion); +const getClientBuildVersion = (): Promise => + invoke(TauriCommand.GetClientBuildVersion); + const openLink = (link: string): Promise => invoke(TauriCommand.OpenLink, { link }); const startGlobalLogWatcher = (): Promise => @@ -367,6 +370,7 @@ export const api = { getProvisioningConfig, getPlatformHeader, getLatestAppVersion, + getClientBuildVersion, openLink, startGlobalLogWatcher, stopGlobalLogWatcher, diff --git a/new-ui/src/shared/rust-api/types.ts b/new-ui/src/shared/rust-api/types.ts index e496f8f32..2ccf9135f 100644 --- a/new-ui/src/shared/rust-api/types.ts +++ b/new-ui/src/shared/rust-api/types.ts @@ -144,6 +144,7 @@ export const TauriCommand = { GetProvisioningConfig: 'get_provisioning_config', GetPlatformHeader: 'get_platform_header', GetLatestAppVersion: 'get_latest_app_version', + GetClientBuildVersion: 'get_client_build_version', OpenLink: 'open_link', StartGlobalLogWatcher: 'start_global_logwatcher', StopGlobalLogWatcher: 'stop_global_logwatcher', diff --git a/src-tauri/enterprise/posture/src/inspector/mod.rs b/src-tauri/enterprise/posture/src/inspector/mod.rs index 015fcd48d..5cd0a2a2a 100644 --- a/src-tauri/enterprise/posture/src/inspector/mod.rs +++ b/src-tauri/enterprise/posture/src/inspector/mod.rs @@ -9,7 +9,7 @@ pub(crate) mod windows; use std::env::consts::OS; -use defguard_client_core::version::PKG_VERSION; +use defguard_client_core::version::{select_reported_app_version, PKG_VERSION}; use defguard_client_proto::defguard::enterprise::posture::v2::{ BoolCheck, DevicePostureData, Int32Check, StringCheck, UnavailableReason, }; @@ -140,7 +140,10 @@ fn security_update_age_days() -> Result { #[must_use] pub fn device_posture_data(disk_target: DiskEncryptionTarget) -> DevicePostureData { DevicePostureData { - defguard_client_version: PKG_VERSION.to_owned(), + defguard_client_version: select_reported_app_version( + PKG_VERSION, + option_env!("DEFGUARD_CLIENT_BUILD_VERSION"), + ), os_type: OS.to_string(), os_name: Some(StringCheck::from(os_name())), os_version: Some(StringCheck::from(os_version())), diff --git a/src-tauri/permissions/default.toml b/src-tauri/permissions/default.toml index 2f1d03058..610a1abaf 100644 --- a/src-tauri/permissions/default.toml +++ b/src-tauri/permissions/default.toml @@ -48,6 +48,7 @@ commands.allow = [ "update_tunnel", "delete_tunnel", "get_latest_app_version", + "get_client_build_version", "start_global_logwatcher", "stop_global_logwatcher", "command_get_app_config", diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index bb86f29c1..aa516e061 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -1409,16 +1409,21 @@ pub struct AppVersionInfo { const PRODUCT_NAME: &str = "defguard-client"; -fn reported_app_version(handle: &AppHandle) -> String { +fn reported_app_version(package_version: &str) -> String { defguard_client_core::version::select_reported_app_version( - &handle.package_info().version.to_string(), + package_version, option_env!("DEFGUARD_CLIENT_BUILD_VERSION"), ) } +#[tauri::command] +pub fn get_client_build_version() -> String { + reported_app_version(defguard_client_core::version::PKG_VERSION) +} + #[tauri::command(async)] pub async fn get_latest_app_version(handle: AppHandle) -> Result { - let app_version = reported_app_version(&handle); + let app_version = reported_app_version(&handle.package_info().version.to_string()); let operating_system = env::consts::OS; let mut request_data = HashMap::new(); diff --git a/src-tauri/src/gui.rs b/src-tauri/src/gui.rs index 382fdbbc8..f5c28fabb 100644 --- a/src-tauri/src/gui.rs +++ b/src-tauri/src/gui.rs @@ -187,6 +187,7 @@ pub fn run_app() { update_tunnel, delete_tunnel, get_latest_app_version, + get_client_build_version, start_global_logwatcher, stop_global_logwatcher, command_get_app_config,