Implement Android TOTP cached discovery and search (#110)
This commit is contained in:
1 parent
0c8366d34f
commit
f4a6edbc68
18 files changed
+1070
-165
No files matched your search
@@ -1271,6 +1271,25 @@ pub struct MobileTotpDiscoveryProgress {
|
||||
pub unavailable: u32,
|
||||
}
|
||||
|
||||
impl From<ironstorage::mobile_totp::MobileTotpDiscoveryProgress> for MobileTotpDiscoveryProgress {
|
||||
fn from(progress: ironstorage::mobile_totp::MobileTotpDiscoveryProgress) -> Self {
|
||||
Self {
|
||||
phase: progress.phase().into(),
|
||||
total: progress.total(),
|
||||
inspected: progress.inspected(),
|
||||
cache_hits: progress.cache_hits(),
|
||||
matches: progress.matches(),
|
||||
unavailable: progress.unavailable(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
pub struct MobileTotpRefreshResult {
|
||||
pub progress: MobileTotpDiscoveryProgress,
|
||||
pub cache_notice: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(uniffi::Object)]
|
||||
pub struct MobileTotpOperation {
|
||||
operation: StorageTotpOperation,
|
||||
@@ -1279,15 +1298,7 @@ pub struct MobileTotpOperation {
|
||||
#[uniffi::export]
|
||||
impl MobileTotpOperation {
|
||||
pub fn progress(&self) -> MobileTotpDiscoveryProgress {
|
||||
let progress = self.operation.progress();
|
||||
MobileTotpDiscoveryProgress {
|
||||
phase: progress.phase().into(),
|
||||
total: progress.total(),
|
||||
inspected: progress.inspected(),
|
||||
cache_hits: progress.cache_hits(),
|
||||
matches: progress.matches(),
|
||||
unavailable: progress.unavailable(),
|
||||
}
|
||||
self.operation.progress().into()
|
||||
}
|
||||
|
||||
pub fn cancel(&self) {
|
||||
@@ -2369,6 +2380,36 @@ impl MobileAuthentication {
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn search_cached_totp_navigation(
|
||||
&self,
|
||||
query: String,
|
||||
operation: Arc<MobileTotpOperation>,
|
||||
) -> Result<Option<Vec<password_navigation::MobileNavigationRow>>, MobileAuthenticationFfiError>
|
||||
{
|
||||
self.authentication
|
||||
.search_cached_totp_navigation(&query, &operation.operation)
|
||||
.map(|rows| rows.map(|rows| rows.into_iter().map(Into::into).collect()))
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn refresh_totp_catalog(
|
||||
&self,
|
||||
operation: Arc<MobileTotpOperation>,
|
||||
passphrase: Option<String>,
|
||||
) -> Result<MobileTotpRefreshResult, MobileAuthenticationFfiError> {
|
||||
self.authentication
|
||||
.refresh_totp_catalog(
|
||||
&operation.operation,
|
||||
passphrase
|
||||
.map(|value| ironstorage::repository::SecretBytes::new(value.into_bytes())),
|
||||
)
|
||||
.map(|result| MobileTotpRefreshResult {
|
||||
progress: result.progress.into(),
|
||||
cache_notice: result.cache_notice,
|
||||
})
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn totp_detail(
|
||||
&self,
|
||||
path: String,
|
||||
|
||||
Reference in new issue
Block a user