Implement Rust-owned adaptive Android password navigation (#96)
This commit is contained in:
1 parent
36e5f55283
commit
8c9341f214
26 files changed
+1553
-16
No files matched your search
@@ -5,6 +5,8 @@
|
||||
|
||||
mod private_storage;
|
||||
pub use private_storage::*;
|
||||
mod password_navigation;
|
||||
pub use password_navigation::*;
|
||||
|
||||
use std::{
|
||||
error::Error,
|
||||
@@ -1747,6 +1749,27 @@ impl MobileAuthentication {
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn navigation_entry(
|
||||
&self,
|
||||
directory: String,
|
||||
row_id: String,
|
||||
revision: String,
|
||||
passphrase: Option<String>,
|
||||
unix_seconds: u64,
|
||||
) -> Result<MobileEntryPresentation, MobileAuthenticationFfiError> {
|
||||
self.authentication
|
||||
.navigation_entry(
|
||||
&directory,
|
||||
&row_id,
|
||||
&revision,
|
||||
passphrase
|
||||
.map(|value| ironstorage::repository::SecretBytes::new(value.into_bytes())),
|
||||
unix_seconds,
|
||||
)
|
||||
.map(Into::into)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn entry_page(
|
||||
&self,
|
||||
path: String,
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
//! Mechanical exports for revision-checked private-store navigation.
|
||||
use crate::{MobileIcon, MobilePasswordFfiError, MobilePasswordRow, MobilePrivateRuntime};
|
||||
use ironstorage::mobile_passwords::navigation::{NavigationRow, PasswordNavigation};
|
||||
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
pub struct MobileNavigationRow {
|
||||
pub row: MobilePasswordRow,
|
||||
pub revision: String,
|
||||
}
|
||||
impl From<NavigationRow> for MobileNavigationRow {
|
||||
fn from(value: NavigationRow) -> Self {
|
||||
let row = value.row;
|
||||
Self {
|
||||
revision: value.revision,
|
||||
row: MobilePasswordRow {
|
||||
id: row.id().into(),
|
||||
path: row.path().into(),
|
||||
title: row.title().into(),
|
||||
detail: row.detail().into(),
|
||||
icon: MobileIcon::from(row.icon()),
|
||||
kind: row.kind().into(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
pub struct MobilePasswordNavigation {
|
||||
pub path: String,
|
||||
pub title: String,
|
||||
pub parent: Option<String>,
|
||||
pub revision: String,
|
||||
pub rows: Vec<MobileNavigationRow>,
|
||||
pub selected: Option<MobileNavigationRow>,
|
||||
pub stale: bool,
|
||||
}
|
||||
impl From<PasswordNavigation> for MobilePasswordNavigation {
|
||||
fn from(value: PasswordNavigation) -> Self {
|
||||
Self {
|
||||
path: value.path,
|
||||
title: value.title,
|
||||
parent: value.parent,
|
||||
revision: value.revision,
|
||||
rows: value.rows.into_iter().map(Into::into).collect(),
|
||||
selected: value.selected.map(Into::into),
|
||||
stale: value.stale,
|
||||
}
|
||||
}
|
||||
}
|
||||
#[uniffi::export]
|
||||
impl MobilePrivateRuntime {
|
||||
pub fn password_navigation(
|
||||
&self,
|
||||
path: String,
|
||||
selected: Option<String>,
|
||||
revision: Option<String>,
|
||||
activate: bool,
|
||||
) -> Result<MobilePasswordNavigation, MobilePasswordFfiError> {
|
||||
ironstorage::mobile_passwords::navigation::navigate(
|
||||
&self.storage,
|
||||
&path,
|
||||
selected.as_deref(),
|
||||
revision.as_deref(),
|
||||
activate,
|
||||
)
|
||||
.map(Into::into)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user