45 lines
1.9 KiB
Rust
45 lines
1.9 KiB
Rust
// file: crates/ksp-app-wallet-desk/src/wallet_security.rs
|
|
// version: 3
|
|
|
|
//! VIEW/OWNER credential and strong VIEW security contracts for Wallet Desk.
|
|
|
|
use ts_rs::TS; // rust-rules: trait-import
|
|
|
|
/// Safe VIEW security status returned after one OWNER-authorized strong VIEW administration operation.
|
|
#[derive(serde::Serialize, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export, export_to = "../frontend/ts/bindings/ksp_app_wallet_desk/wallet_security/WalletViewSecurityStatusDto.ts")]
|
|
pub(crate) struct WalletViewSecurityStatusDto {
|
|
/// Capability that performed the strong VIEW administration operation.
|
|
pub(crate) capability: String,
|
|
/// Number of effective Config-owned Wallet password candidates without names or values.
|
|
pub(crate) configured_secret_candidate_count: usize,
|
|
/// Whether the current Wallet state exposes a VIEW slot after the operation.
|
|
pub(crate) view_enabled: bool,
|
|
/// Root-scoped Wallet identifier.
|
|
pub(crate) wallet_id: String,
|
|
}
|
|
|
|
/// Builds the safe strong VIEW administration status from an authorized OWNER projection.
|
|
pub(crate) fn view_security_status_from_authorized(wallet: &crate::WalletAuthorizedDto) -> WalletViewSecurityStatusDto {
|
|
return WalletViewSecurityStatusDto {
|
|
capability: wallet.capability.clone(),
|
|
configured_secret_candidate_count: wallet.configured_secret_candidate_count,
|
|
view_enabled: wallet.view_enabled,
|
|
wallet_id: wallet.wallet_id.clone(),
|
|
};
|
|
}
|
|
|
|
/// New credential moved frontend -> Rust for one explicit Wallet password rotation.
|
|
#[derive(serde::Deserialize, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export, export_to = "../frontend/ts/bindings/ksp_app_wallet_desk/wallet_security/WalletPasswordRotationRequestDto.ts")]
|
|
pub(crate) struct WalletPasswordRotationRequestDto {
|
|
/// New password transported only for the explicit rotation call.
|
|
pub(crate) password: String,
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "../unit_tests/wallet_security.rs"]
|
|
mod tests;
|