Add additive KDBX importer

This commit is contained in:
2026-08-11 09:04:48 +02:00
parent f84f7247d2
commit bf75465642
23 changed files with 1959 additions and 82 deletions

View File

@@ -27,6 +27,7 @@ use crate::{
GitOperationControl, GitProgressPhase, GitRepository, GitSnapshot, PullOutcome,
PushOutcome, ReqwestGitTransport,
},
kdbx::{KdbxImportOutcome, KdbxImportRequest, KdbxImporter},
mutation::{MutationOutcome, TreeMutator},
otp::{OtpAlgorithm, OtpCodeValidity, OtpInput, OtpKind, OtpService, OtpUri},
presentation::{ClipboardTimeout, QrMatrix},
@@ -55,6 +56,7 @@ pub enum DesktopErrorKind {
EntryExists,
Mutation,
Otp,
Import,
}
#[derive(Debug)]
@@ -545,6 +547,27 @@ impl DesktopStorage {
.map_err(|error| DesktopError::new(DesktopErrorKind::Read, error))
}
pub fn import_kdbx_active(
&self,
handle: &NativeAuthenticationHandle,
request: &KdbxImportRequest,
password: SecretBytes,
) -> Result<(KdbxImportOutcome, TreeModel), DesktopError> {
handle
.ensure_active()
.map_err(|error| DesktopError::new(DesktopErrorKind::Authentication, error))?;
let repository = self.repository()?;
let keys = self.keys()?;
let mut provider = handle.clone();
let outcome = KdbxImporter::new(&repository, keys)
.import(request, password, &mut provider, GitIdentity::ironstorage())
.map_err(|error| DesktopError::new(DesktopErrorKind::Import, error))?;
let tree = VaultReader::new(&repository, keys)
.list(&DirectoryPath::root())
.map_err(|error| DesktopError::new(DesktopErrorKind::Read, error))?;
Ok((outcome, tree))
}
pub fn otp_code_active(
&self,
handle: &NativeAuthenticationHandle,