212 lines
12 KiB
Rust
212 lines
12 KiB
Rust
// file: crates/ksp-app-wallet-desk/src/lib.rs
|
|
// version: 8
|
|
|
|
//! Tauri desktop application shell for KSP Wallet management and inspection.
|
|
|
|
#![forbid(unsafe_code)]
|
|
#![deny(unreachable_pub)]
|
|
#![warn(missing_docs)]
|
|
|
|
mod app_state;
|
|
mod bootstrap;
|
|
mod constants;
|
|
mod dto_common;
|
|
mod errors;
|
|
mod frontend_logging;
|
|
mod logging_runtime;
|
|
mod splash;
|
|
mod tauri;
|
|
mod transport_runtime;
|
|
mod tw_main;
|
|
mod tw_splash;
|
|
mod wallet_balance;
|
|
mod wallet_config;
|
|
mod wallet_import;
|
|
mod wallet_inventory;
|
|
mod wallet_secrets;
|
|
mod wallet_session;
|
|
|
|
/// Runs the KSP wallet desktop application.
|
|
pub use self::tauri::run;
|
|
|
|
/// Shared Wallet Desk application state managed by Tauri.
|
|
pub(crate) use self::app_state::AppState;
|
|
/// Crate-internal Logging startup state shared by the application state.
|
|
pub(crate) use self::bootstrap::LoggingStartup;
|
|
/// Builds the Config management facade from the common KSP CLI bootstrap contract.
|
|
pub(crate) use self::bootstrap::config_management;
|
|
/// Initializes the Logging runtime from Config, with the same bounded fallback policy as Config Desk.
|
|
pub(crate) use self::bootstrap::initialize_logging;
|
|
/// Loads the concrete Wallet Desk Config composite.
|
|
pub(crate) use self::bootstrap::load_wallet_desk_composite;
|
|
/// Resolves and validates one required standard-document component from the Wallet Desk composite.
|
|
pub(crate) use self::bootstrap::required_composite_component_profile;
|
|
/// Composite-local identifier for the Logging standard document.
|
|
pub(crate) use self::constants::COMPOSITE_COMPONENT_ID_LOGGING;
|
|
/// Composite-local identifier for the HTTP Transport standard document.
|
|
pub(crate) use self::constants::COMPOSITE_COMPONENT_ID_TRANSPORT;
|
|
/// Composite-local identifier for the Wallet standard document.
|
|
pub(crate) use self::constants::COMPOSITE_COMPONENT_ID_WALLET;
|
|
/// Structured domain used while bootstrapping Config and Logging.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_BOOTSTRAP;
|
|
/// Structured domain used by technical frontend events.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_FRONTEND;
|
|
/// Structured domain used by the Wallet Desk shell.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_SHELL;
|
|
/// Structured domain used by Wallet Desk HTTP Transport and balance operations.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_TRANSPORT;
|
|
/// Structured domain used while preparing Wallet filesystem roots.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_WALLET_CONFIG;
|
|
/// Structured domain used by native-picker Wallet transfer import operations.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_WALLET_IMPORT;
|
|
/// Structured domain used while enumerating and inspecting locked Wallet files.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_WALLET_INVENTORY;
|
|
/// Structured domain used by Config-owned Wallet password candidate operations.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_WALLET_SECRET;
|
|
/// Structured domain used by durable Wallet session, creation and unlock operations.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_WALLET_SESSION;
|
|
/// Structured domain used by Tauri window lifecycle operations.
|
|
pub(crate) use self::constants::TRACING_DOMAIN_WINDOWS;
|
|
/// Owning target for backend events emitted by Wallet Desk.
|
|
pub(crate) use self::constants::TRACING_TARGET;
|
|
/// Owning target for generic frontend events emitted through the KSP bridge.
|
|
pub(crate) use self::constants::TRACING_TARGET_FRONTEND;
|
|
/// Owning target for main-window frontend events.
|
|
pub(crate) use self::constants::TRACING_TARGET_FRONTEND_MAIN;
|
|
/// Owning target for splash-window frontend events.
|
|
pub(crate) use self::constants::TRACING_TARGET_FRONTEND_SPLASH;
|
|
/// Native Wallet filename suffix accepted by inventory operations.
|
|
pub(crate) use self::constants::WALLET_FILE_SUFFIX;
|
|
/// Safe command error projection exposed to Tauri commands.
|
|
pub(crate) use self::dto_common::CommandErrorDto;
|
|
/// Initial application/runtime snapshot exposed to the Wallet Desk shell.
|
|
pub(crate) use self::dto_common::RuntimeStatusDto;
|
|
/// Shared Wallet Desk application state is internally inconsistent.
|
|
pub(crate) use self::errors::ERROR_CODE_APP_STATE_INVALID;
|
|
/// Shared Wallet Desk runtime state cannot be locked safely.
|
|
pub(crate) use self::errors::ERROR_CODE_APP_STATE_LOCK_FAILED;
|
|
/// The Wallet Desk Config composite is missing or misroutes one required standard component.
|
|
pub(crate) use self::errors::ERROR_CODE_CONFIG_COMPOSITE_INVALID;
|
|
/// Frontend logging requested an unsupported level.
|
|
pub(crate) use self::errors::ERROR_CODE_FRONTEND_LOG_LEVEL_INVALID;
|
|
/// Frontend logging requested a target outside the application whitelist.
|
|
pub(crate) use self::errors::ERROR_CODE_FRONTEND_LOG_TARGET_INVALID;
|
|
/// Wallet Desk could not install the managed Logging runtime or its safe fallback.
|
|
pub(crate) use self::errors::ERROR_CODE_LOGGING_BOOTSTRAP_FAILED;
|
|
/// Splash readiness was invoked from a window other than the splash window.
|
|
pub(crate) use self::errors::ERROR_CODE_SPLASH_ORIGIN_INVALID;
|
|
/// A KSP desk splash environment duration is malformed or exceeds its safety bound.
|
|
pub(crate) use self::errors::ERROR_CODE_SPLASH_SETTING_INVALID;
|
|
/// Tauri runtime assembly or execution failed.
|
|
pub(crate) use self::errors::ERROR_CODE_TAURI_RUNTIME_FAILED;
|
|
/// A required Tauri window is missing from the configured application runtime.
|
|
pub(crate) use self::errors::ERROR_CODE_TAURI_WINDOW_MISSING;
|
|
/// A Tauri window show/focus/destroy/event operation failed.
|
|
pub(crate) use self::errors::ERROR_CODE_TAURI_WINDOW_OPERATION_FAILED;
|
|
/// Wallet balance access requires an authorized VIEW or OWNER session.
|
|
pub(crate) use self::errors::ERROR_CODE_WALLET_AUTHORIZATION_REQUIRED;
|
|
/// The configured Wallet root or effective profile directory resolves to an unsupported filesystem object.
|
|
pub(crate) use self::errors::ERROR_CODE_WALLET_DIRECTORY_INVALID;
|
|
/// Wallet Desk could not inspect or create the configured Wallet directory tree.
|
|
pub(crate) use self::errors::ERROR_CODE_WALLET_DIRECTORY_PREPARE_FAILED;
|
|
/// Native-picker transfer source is invalid or cannot be staged.
|
|
pub(crate) use self::errors::ERROR_CODE_WALLET_IMPORT_SOURCE_INVALID;
|
|
/// Wallet import has no staged native-picker source.
|
|
pub(crate) use self::errors::ERROR_CODE_WALLET_IMPORT_SOURCE_MISSING;
|
|
/// Wallet inventory filesystem operation failed.
|
|
pub(crate) use self::errors::ERROR_CODE_WALLET_INVENTORY_FAILED;
|
|
/// No effective Config-owned Wallet password candidate is available.
|
|
pub(crate) use self::errors::ERROR_CODE_WALLET_SECRET_CANDIDATES_MISSING;
|
|
/// Wallet selection identifier is invalid or no longer eligible.
|
|
pub(crate) use self::errors::ERROR_CODE_WALLET_SELECTION_INVALID;
|
|
/// Wallet session lifecycle operation is incompatible with the current state.
|
|
pub(crate) use self::errors::ERROR_CODE_WALLET_SESSION_INVALID;
|
|
/// Selected Wallet does not expose an enabled VIEW capability.
|
|
pub(crate) use self::errors::ERROR_CODE_WALLET_VIEW_DISABLED;
|
|
/// Log payload sent by Wallet Desk frontend scripts.
|
|
pub(crate) use self::frontend_logging::FrontendLogPayloadDto;
|
|
/// Emits one validated frontend event through the KSP Logging facade.
|
|
pub(crate) use self::frontend_logging::emit_frontend_log_event;
|
|
/// Creates the stable runtime identity for this Wallet Desk process launch.
|
|
pub(crate) use self::logging_runtime::launch_identity;
|
|
/// Command emitted by Rust to the splash frontend.
|
|
pub(crate) use self::splash::SplashOrderDto;
|
|
/// Runtime timings used by the common desk splash lifecycle.
|
|
pub(crate) use self::splash::SplashSettings;
|
|
/// Safe and executable Transport runtime retained by the application state.
|
|
pub(crate) use self::transport_runtime::TransportRuntime;
|
|
/// Resolves the composite-selected Transport profile and builds the executable HTTP pool.
|
|
pub(crate) use self::transport_runtime::initialize_transport;
|
|
/// Resolves the required main window or returns a typed error.
|
|
pub(crate) use self::tw_main::require_main_window;
|
|
/// Shows and focuses the main Wallet Desk window.
|
|
pub(crate) use self::tw_main::show_main_window;
|
|
/// Resolves the required splash window or returns a typed error.
|
|
pub(crate) use self::tw_splash::require_splash_window;
|
|
/// Starts the one-shot splash lifecycle after the splash frontend reports readiness.
|
|
pub(crate) use self::tw_splash::splash_frontend_ready_service;
|
|
/// Safe balance snapshot for the currently authorized Wallet.
|
|
pub(crate) use self::wallet_balance::WalletBalanceDto;
|
|
/// Formats exact lamports as a decimal SOL string without floating point.
|
|
pub(crate) use self::wallet_balance::format_lamports_as_sol;
|
|
/// Resolved Wallet Config and directory preparation status captured during application bootstrap.
|
|
pub(crate) use self::wallet_config::WalletConfigStartup;
|
|
/// Resolves the composite-selected Wallet Config and prepares its application-owned directory tree.
|
|
pub(crate) use self::wallet_config::initialize_wallet_config;
|
|
/// Rust-only staged import source containing bounded zeroizing transfer bytes.
|
|
pub(crate) use self::wallet_import::PendingWalletImport;
|
|
/// Import request whose new native Wallet credentials move frontend -> Rust only.
|
|
pub(crate) use self::wallet_import::WalletImportRequestDto;
|
|
/// Native picker request containing only the expected transfer format.
|
|
pub(crate) use self::wallet_import::WalletImportSourceRequestDto;
|
|
/// Safe transfer format DTO used by the import picker.
|
|
pub(crate) use self::wallet_import::WalletTransferFormatDto;
|
|
/// Safe inspection projection for one staged external transfer source.
|
|
pub(crate) use self::wallet_import::WalletTransferInspectionDto;
|
|
/// Loads and validates one native-picker import source into bounded zeroizing Rust memory.
|
|
pub(crate) use self::wallet_import::stage_wallet_import_source;
|
|
/// Safe locked Wallet projection returned after selection.
|
|
pub(crate) use self::wallet_inventory::LockedWalletDto;
|
|
/// Locked inspection outcome exposed by Wallet inventory rows in crate unit tests.
|
|
#[cfg(test)]
|
|
pub(crate) use self::wallet_inventory::WalletInspectionStatusDto;
|
|
/// Safe Wallet inventory row projection.
|
|
pub(crate) use self::wallet_inventory::WalletInventoryEntryDto;
|
|
/// Visual lock/error state exposed by Wallet inventory rows in crate unit tests.
|
|
#[cfg(test)]
|
|
pub(crate) use self::wallet_inventory::WalletInventoryStateDto;
|
|
/// Request DTO used for one root-scoped Wallet selection.
|
|
pub(crate) use self::wallet_inventory::WalletSelectionRequestDto;
|
|
/// Enumerates native Wallet files under the effective Config-managed root.
|
|
pub(crate) use self::wallet_inventory::list_wallet_inventory;
|
|
/// Builds a validated destination path for one new root-scoped Wallet.
|
|
pub(crate) use self::wallet_inventory::new_wallet_destination;
|
|
/// Re-resolves one locked Wallet into Rust-only path state plus safe DTO.
|
|
pub(crate) use self::wallet_inventory::resolve_locked_wallet;
|
|
/// Re-inspects one root-scoped Wallet selection in crate unit tests.
|
|
#[cfg(test)]
|
|
pub(crate) use self::wallet_inventory::select_locked_wallet;
|
|
/// Discovers Config-owned Wallet password candidates without exposing their names or values.
|
|
pub(crate) use self::wallet_secrets::discover_wallet_secret_candidates;
|
|
/// Returns the configured Wallet password candidate count without exposing their names or values.
|
|
pub(crate) use self::wallet_secrets::wallet_secret_candidate_count;
|
|
/// Authorized OWNER projection exposed only after successful creation.
|
|
pub(crate) use self::wallet_session::WalletAuthorizedDto;
|
|
/// Create request whose password strings move frontend -> Rust only.
|
|
pub(crate) use self::wallet_session::WalletCreateRequestDto;
|
|
/// Durable backend Wallet session retaining full paths and handles only in Rust.
|
|
pub(crate) use self::wallet_session::WalletSession;
|
|
/// Minimal safe projection of the durable Wallet session.
|
|
pub(crate) use self::wallet_session::WalletSessionDto;
|
|
/// Safe state code for the durable Wallet session in crate unit tests.
|
|
#[cfg(test)]
|
|
pub(crate) use self::wallet_session::WalletSessionStateDto;
|
|
/// Capability targeted by one explicit unlock operation.
|
|
pub(crate) use self::wallet_session::WalletUnlockCapability;
|
|
/// Manual unlock request whose password moves frontend -> Rust only.
|
|
pub(crate) use self::wallet_session::WalletUnlockRequestDto;
|
|
/// Builds an authorized OWNER DTO from a Rust-only Wallet handle.
|
|
pub(crate) use self::wallet_session::owner_projection;
|
|
/// Builds an authorized VIEW DTO from a Rust-only Wallet handle.
|
|
pub(crate) use self::wallet_session::view_projection;
|