From b3c3aa2f330f12f9f6e88f4ffa31075666bd91f8 Mon Sep 17 00:00:00 2001 From: qaz741wsd856 Date: Sun, 30 Nov 2025 09:38:50 +0000 Subject: [PATCH] feat: add devices handler with stub implementation --- src/handlers/devices.rs | 18 ++++++++++++++++++ src/handlers/mod.rs | 1 + src/router.rs | 4 +++- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/handlers/devices.rs diff --git a/src/handlers/devices.rs b/src/handlers/devices.rs new file mode 100644 index 0000000..63a5920 --- /dev/null +++ b/src/handlers/devices.rs @@ -0,0 +1,18 @@ +use axum::Json; +use serde_json::{json, Value}; + +/// GET /devices +/// +/// Returns an empty list of devices. +/// Device tracking is not implemented in this minimal Bitwarden-compatible server. +/// This does not affect authentication since we use stateless JWT tokens. +/// Clients will show "No devices currently logged in" in the device management settings. +#[worker::send] +pub async fn get_devices() -> Json { + Json(json!({ + "data": [], + "continuationToken": null, + "object": "list" + })) +} + diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index b9a2e76..e3a52fe 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -1,6 +1,7 @@ pub mod accounts; pub mod ciphers; pub mod config; +pub mod devices; pub mod emergency_access; pub mod folders; pub mod identity; diff --git a/src/router.rs b/src/router.rs index 61fa516..1f95bf9 100644 --- a/src/router.rs +++ b/src/router.rs @@ -5,7 +5,7 @@ use axum::{ use std::sync::Arc; use worker::Env; -use crate::handlers::{accounts, ciphers, config, emergency_access, folders, identity, import, sync, webauth}; +use crate::handlers::{accounts, ciphers, config, devices, emergency_access, folders, identity, import, sync, webauth}; pub fn api_router(env: Env) -> Router { let app_state = Arc::new(env); @@ -78,6 +78,8 @@ pub fn api_router(env: Env) -> Router { "/api/emergency-access/granted", get(emergency_access::get_granted_access), ) + // Devices (stub - returns empty list, device tracking not implemented) + .route("/api/devices", get(devices::get_devices)) // WebAuthn (stub - prevents 404 errors, passkeys not supported) .route( "/api/webauthn",