bitwarden_pm/debug.rs
1//! Dev-only debug-capability tree, rooted on [`PasswordManagerClient`].
2//!
3//! Mirrors the public client tree, but each node exposes only debug
4//! capabilities. A node hands back a handle authored in the crate that owns the
5//! state it reaches into, so that crate's internals stay reachable. Compiled
6//! only under the `debug-capabilities` feature.
7
8use bitwarden_core::Client;
9use bitwarden_state::debug::StateRegistryDebugExt as _;
10
11use crate::PasswordManagerClient;
12
13/// Root of the debug-capability tree. Routes to per-crate capability handles.
14#[bitwarden_ffi::wasm_object]
15pub struct DebugClient {
16 client: Client,
17}
18
19impl PasswordManagerClient {
20 /// Entry point for dev-only debug capabilities (bypass the public API).
21 pub fn debug(&self) -> DebugClient {
22 // The wasm and mobile bindings build a memory-backed registry that never
23 // runs the SDK-managed migrations, so their debug index would otherwise
24 // omit SDK-managed types (e.g. `Setting`). Registering here (idempotent)
25 // makes the browse cover them wherever the tree is reachable.
26 self.0
27 .internal
28 .state_registry()
29 .debug_register_migrations(&crate::migrations::get_sdk_managed_migrations());
30 DebugClient {
31 client: self.0.clone(),
32 }
33 }
34}
35
36#[bitwarden_ffi::wasm_export]
37impl DebugClient {
38 /// Persisted-state debug capabilities (browse the SDK's state registry).
39 /// Authored in `bitwarden-state`, where the registry lives.
40 pub fn state(&self) -> bitwarden_state::debug::StateDebug {
41 self.client.internal.state_registry().debug()
42 }
43}