diff --git a/src-tauri/src/fido/hid.rs b/src-tauri/src/fido/hid.rs index 847c07c..68e8c21 100644 --- a/src-tauri/src/fido/hid.rs +++ b/src-tauri/src/fido/hid.rs @@ -16,6 +16,9 @@ const CTAPHID_KEEPALIVE: u8 = 0xBB; pub struct HidTransport { device: hidapi::HidDevice, cid: u32, + pub vid: u16, + pub pid: u16, + pub product_name: String, } impl HidTransport { @@ -41,6 +44,13 @@ impl HidTransport { info.product_id() ); + let vid = info.vendor_id(); + let pid = info.product_id(); + let product_name = info + .product_string() + .unwrap_or("Unknown FIDO Device") + .to_string(); + let device = info.open_device(&api).map_err(|e| { log::error!("Failed to open HID device: {}", e); e @@ -53,7 +63,13 @@ impl HidTransport { })?; log::info!("HID Transport established successfully. CID: 0x{:08X}", cid); - Ok(Self { device, cid }) + Ok(Self { + device, + cid, + vid, + pid, + product_name, + }) } fn init_channel(device: &hidapi::HidDevice) -> Result { diff --git a/src-tauri/src/fido/mod.rs b/src-tauri/src/fido/mod.rs index 4c062f0..1e10359 100644 --- a/src-tauri/src/fido/mod.rs +++ b/src-tauri/src/fido/mod.rs @@ -37,7 +37,11 @@ pub(crate) fn get_fido_info() -> Result { max_msg_size: info.max_msg_size, pin_protocols: info.pin_uv_auth_protocols, min_pin_length: info.min_pin_length, - firmware_version: format!("0x{:X}", info.firmware_version), + firmware_version: format!( + "{}.{}", + (info.firmware_version >> 8) & 0xFF, + info.firmware_version & 0xFF + ), }) } @@ -188,7 +192,7 @@ pub fn read_device_details() -> Result { m.get(&Value::Integer(0x0E)) .and_then(|v| { if let Value::Integer(i) = v { - Some(format!("0x{:X}", i)) + Some(format!("{}.{}", (i >> 8) & 0xFF, i & 0xFF)) } else { None } @@ -292,7 +296,13 @@ pub fn read_device_details() -> Result { Vec::new() }); - let mut config = AppConfig::default(); + let mut config = AppConfig { + vid: format!("{:04X}", transport.vid), + pid: format!("{:04X}", transport.pid), + product_name: transport.product_name.clone(), + ..Default::default() + }; + if let Ok(Value::Map(m)) = from_slice(&phy_res) { log::debug!("Parsed Physical Config map successfully"); // These keys might need adjustment based on exact firmware response structure @@ -311,7 +321,7 @@ pub fn read_device_details() -> Result { Ok(FullDeviceStatus { info: DeviceInfo { - serial: aaguid_str, // Using AAGUID as serial since unique serial isn't available + serial: "?".to_string(), // Serial number is not available through fido. Previous code was using AAGUID as serial but it is too long to display in place of serial it is already displayed somewhere else. flash_used: used / 1024, flash_total: total / 1024, firmware_version: fw_version, @@ -319,5 +329,6 @@ pub fn read_device_details() -> Result { config, secure_boot: false, secure_lock: false, + method: "FIDO".to_string(), }) } diff --git a/src-tauri/src/io.rs b/src-tauri/src/io.rs index 555f68a..8dc3d6b 100644 --- a/src-tauri/src/io.rs +++ b/src-tauri/src/io.rs @@ -3,8 +3,13 @@ use crate::{error::PFError, fido, rescue, types::*}; #[tauri::command] pub fn read_device_details() -> Result { - rescue::read_device_details() - // fido::read_device_details() + match rescue::read_device_details() { + Ok(status) => Ok(status), + Err(e) => { + log::warn!("Rescue method failed: {}. Falling back to FIDO...", e); + fido::read_device_details() + } + } } #[tauri::command] diff --git a/src-tauri/src/rescue/mod.rs b/src-tauri/src/rescue/mod.rs index abcb736..6a1b682 100644 --- a/src-tauri/src/rescue/mod.rs +++ b/src-tauri/src/rescue/mod.rs @@ -235,6 +235,7 @@ pub fn read_device_details() -> Result { config, secure_boot: sb_enabled, secure_lock: sb_locked, + method: "Rescue".to_string(), }) } diff --git a/src-tauri/src/types.rs b/src-tauri/src/types.rs index 64dbf9c..1ca3228 100644 --- a/src-tauri/src/types.rs +++ b/src-tauri/src/types.rs @@ -55,6 +55,7 @@ pub struct FullDeviceStatus { pub config: AppConfig, pub secure_boot: bool, pub secure_lock: bool, + pub method: String, } // Fido stuff: diff --git a/src/lib/device/manager.svelte.ts b/src/lib/device/manager.svelte.ts index 1a4d0d2..0d359af 100644 --- a/src/lib/device/manager.svelte.ts +++ b/src/lib/device/manager.svelte.ts @@ -16,6 +16,7 @@ class DeviceManager { connected = $state(false); fidoInfo: FidoInfo | null = $state(null); error: string | null = $state(null); + method: string = $state(""); credentials: StoredCredential[] = $state([]); unlocked = $state(false); @@ -60,6 +61,8 @@ class DeviceManager { confirmed: false, }; + this.method = status.method; + const fido = await invoke("get_fido_info"); this.fidoInfo = fido; diff --git a/src/lib/device/types.svelte.ts b/src/lib/device/types.svelte.ts index e505443..11124a5 100644 --- a/src/lib/device/types.svelte.ts +++ b/src/lib/device/types.svelte.ts @@ -38,6 +38,7 @@ export interface FullDeviceStatus { config: DeviceConfig; secureBoot: boolean; secureLock: boolean; + method: string; } export interface SecurityState { diff --git a/src/lib/views/homeView.svelte b/src/lib/views/homeView.svelte index eadc75d..b7df1bf 100644 --- a/src/lib/views/homeView.svelte +++ b/src/lib/views/homeView.svelte @@ -7,14 +7,24 @@ import { device } from "$lib/device/manager.svelte"; - import { Cpu, Lock, LockOpen, Microchip, ShieldCheck, TriangleAlert, Shield } from "@lucide/svelte"; + import { + Cpu, + Lock, + LockOpen, + Microchip, + ShieldCheck, + TriangleAlert, + Shield, + } from "@lucide/svelte"; import NoDeviceStatus from "$lib/components/device/NoDeviceStatus.svelte";

Device Overview

-

Quick view of your device status and specifications.

+

+ Quick view of your device status and specifications. +

{#if !device.connected} @@ -36,16 +46,24 @@

Firmware Version

-

v{device.info.firmwareVersion}

+

+ v{device.info.firmwareVersion} +

VID:PID

-

{device.config.vid}:{device.config.pid}

+

+ {device.config.vid}:{device.config.pid} +

Product Name

{device.config.productName}

+
+

Connection Method

+ {device.method} +
@@ -57,7 +75,10 @@ {device.info.flashUsed} / {device.info.flashTotal} KB - + @@ -74,7 +95,9 @@

FIDO Version

-

{device.fidoInfo.versions[0] || "N/A"}

+

+ {device.fidoInfo.versions[0] || "N/A"} +

PIN Set

@@ -98,10 +121,14 @@

AAGUID

-

{device.fidoInfo.aaguid}

+

+ {device.fidoInfo.aaguid} +

{:else} -

FIDO information not available

+

+ FIDO information not available +

{/if} @@ -128,7 +155,9 @@
LED Dimmable - + {device.config.ledDimmable ? "Yes" : "No"}
@@ -157,7 +186,9 @@ {:else} {/if} - + {device.security.secureBoot ? "Secure Boot" : "Development"}
@@ -170,7 +201,9 @@
Secure Lock - + {device.security.confirmed ? "Acknowledged" : "Pending"}