Implement Android Home activity and HTTPS synchronization (#97)
This commit is contained in:
1 parent
8c9341f214
commit
5c933a99a3
29 files changed
+2008
-110
No files matched your search
@@ -4,6 +4,7 @@ use std::{
|
||||
collections::BTreeMap,
|
||||
error::Error,
|
||||
fmt,
|
||||
path::Path,
|
||||
sync::{Arc, Mutex},
|
||||
time::Duration,
|
||||
};
|
||||
@@ -79,7 +80,11 @@ impl MobileAuthenticationError {
|
||||
&self.detail
|
||||
}
|
||||
|
||||
fn new(kind: MobileAuthenticationErrorKind, title: &str, detail: impl Into<String>) -> Self {
|
||||
pub(crate) fn new(
|
||||
kind: MobileAuthenticationErrorKind,
|
||||
title: &str,
|
||||
detail: impl Into<String>,
|
||||
) -> Self {
|
||||
Self {
|
||||
kind,
|
||||
title: title.to_owned(),
|
||||
@@ -352,6 +357,32 @@ pub struct MobileAuthentication {
|
||||
}
|
||||
|
||||
impl MobileAuthentication {
|
||||
pub(crate) fn matches_configuration(
|
||||
&self,
|
||||
config: &Config,
|
||||
) -> Result<bool, MobileAuthenticationError> {
|
||||
let status = self.status()?;
|
||||
if self.config.source() != config.source()
|
||||
|| self.config.vault() != config.vault()
|
||||
|| self.config.key_material() != config.key_material()
|
||||
|| self.config.default_key() != config.default_key()
|
||||
|| self.config.git_remotes() != config.git_remotes()
|
||||
|| status.git_identity != *config.git_identity()
|
||||
|| status.authentication_timeout != config.authentication_timeout()
|
||||
|| status.biometric_unlock_enabled != config.biometric_unlock_enabled()
|
||||
{
|
||||
return Ok(false);
|
||||
}
|
||||
let current = Repository::open(config.vault()).map_err(entry_error)?;
|
||||
Ok(self
|
||||
.repository
|
||||
.navigation_revision(Path::new(""), false)
|
||||
.map_err(entry_error)?
|
||||
== current
|
||||
.navigation_revision(Path::new(""), false)
|
||||
.map_err(entry_error)?)
|
||||
}
|
||||
|
||||
pub fn load() -> Result<Self, MobileAuthenticationError> {
|
||||
let config = Config::load(None).map_err(|error| {
|
||||
MobileAuthenticationError::new(
|
||||
@@ -913,6 +944,7 @@ impl MobileAuthentication {
|
||||
&self,
|
||||
operation: &MobileTotpOperation,
|
||||
) -> Result<MobileTotpPage, MobileAuthenticationError> {
|
||||
self.ensure_repository_idle()?;
|
||||
self.ensure_active()?;
|
||||
let _discovery = self.totp_discovery.lock().map_err(|_| {
|
||||
entry_detail(
|
||||
@@ -946,6 +978,7 @@ impl MobileAuthentication {
|
||||
&self,
|
||||
query: &str,
|
||||
) -> Result<Option<MobileTotpPage>, MobileAuthenticationError> {
|
||||
self.ensure_repository_idle()?;
|
||||
let shared = self.status()?.watch_shared_totp_entries.clone();
|
||||
let cache_path = self.config.source().with_file_name("totp-catalog.toml");
|
||||
let mut page = MobileTotpService::new(&self.repository, &self.keys).search_cached_page(
|
||||
|
||||
Reference in new issue
Block a user