Prepare Apple App Store distribution (#59)

This commit is contained in:
2026-08-16 17:55:59 +02:00
parent b50e47ab73
commit f894d43eb6
46 changed files with 20694 additions and 166 deletions

View File

@@ -4,6 +4,8 @@ description = "UniFFI boundary between IronStorage and its Apple frontends"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
publish = false
[lib]

View File

@@ -270,6 +270,7 @@ pub struct MobileHomeNotice {
#[derive(Clone, uniffi::Record)]
pub struct MobileHomePage {
pub remote_configured: bool,
pub freshness: MobileHomeFreshness,
pub refreshed_at: Option<i64>,
pub summaries: Vec<MobileHomeSummaryRow>,
@@ -283,6 +284,7 @@ pub struct MobileHomePage {
impl From<mobile_home::MobileHomePage> for MobileHomePage {
fn from(page: mobile_home::MobileHomePage) -> Self {
Self {
remote_configured: page.remote_configured(),
freshness: page.freshness().into(),
refreshed_at: page.refreshed_at(),
summaries: page
@@ -684,6 +686,7 @@ impl From<StorageWatchPreferenceState> for MobileWatchPreferenceState {
#[derive(Clone, uniffi::Record)]
pub struct MobilePreferences {
pub sync_configured: bool,
pub repository_title: String,
pub repository_url: String,
pub server_title: String,
@@ -702,6 +705,7 @@ pub struct MobilePreferences {
impl From<StorageMobilePreferences> for MobilePreferences {
fn from(preferences: StorageMobilePreferences) -> Self {
Self {
sync_configured: preferences.sync_configured(),
repository_title: preferences.repository_title().to_owned(),
repository_url: preferences.repository_url().to_owned(),
server_title: preferences.server_title().to_owned(),
@@ -1351,13 +1355,22 @@ pub struct MobileKeyTransferOutcome {
#[derive(Debug, uniffi::Error)]
pub enum MobileKeyTransferFfiError {
Failed { message: String },
Failed {
kind: MobileKeyTransferErrorKind,
message: String,
},
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, uniffi::Enum)]
pub enum MobileKeyTransferErrorKind {
ExistingKey,
Failed,
}
impl fmt::Display for MobileKeyTransferFfiError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Failed { message } => formatter.write_str(message),
Self::Failed { message, .. } => formatter.write_str(message),
}
}
}
@@ -1366,7 +1379,17 @@ impl Error for MobileKeyTransferFfiError {}
impl From<StorageKeyTransferError> for MobileKeyTransferFfiError {
fn from(error: StorageKeyTransferError) -> Self {
let kind = match &error {
StorageKeyTransferError::ExistingKey => MobileKeyTransferErrorKind::ExistingKey,
StorageKeyTransferError::LocalSetup(error)
if error.kind() == StorageOnboardingErrorKind::ExistingKey =>
{
MobileKeyTransferErrorKind::ExistingKey
}
_ => MobileKeyTransferErrorKind::Failed,
};
Self::Failed {
kind,
message: error.to_string(),
}
}
@@ -1440,6 +1463,7 @@ impl MobileKeyTransferImport {
self.importer
.lock()
.map_err(|_| MobileKeyTransferFfiError::Failed {
kind: MobileKeyTransferErrorKind::Failed,
message: "the key-transfer session is unavailable".to_owned(),
})?
.add_frame(ironstorage::repository::SecretBytes::new(
@@ -1453,17 +1477,20 @@ impl MobileKeyTransferImport {
&self,
passphrase: Option<String>,
make_default: bool,
overwrite: bool,
) -> Result<MobileKeyTransferOutcome, MobileKeyTransferFfiError> {
let outcome = self
.importer
.lock()
.map_err(|_| MobileKeyTransferFfiError::Failed {
kind: MobileKeyTransferErrorKind::Failed,
message: "the key-transfer session is unavailable".to_owned(),
})?
.import(
passphrase
.map(|value| ironstorage::repository::SecretBytes::new(value.into_bytes())),
make_default,
overwrite,
)?;
Ok(MobileKeyTransferOutcome {
title: outcome.title().to_owned(),
@@ -1830,6 +1857,16 @@ impl MobileAuthentication {
.map_err(Into::into)
}
pub fn create_directory(
&self,
parent: String,
name: String,
) -> Result<(), MobileAuthenticationFfiError> {
self.authentication
.create_directory(&parent, &name)
.map_err(Into::into)
}
pub fn entry_editor(
&self,
editor: u64,
@@ -1972,6 +2009,7 @@ pub enum MobileOnboardingErrorKind {
Authentication,
Repository,
ExistingClone,
ExistingKey,
Interrupted,
SecureStorage,
Configuration,
@@ -1986,6 +2024,7 @@ impl From<StorageOnboardingErrorKind> for MobileOnboardingErrorKind {
StorageOnboardingErrorKind::Authentication => Self::Authentication,
StorageOnboardingErrorKind::Repository => Self::Repository,
StorageOnboardingErrorKind::ExistingClone => Self::ExistingClone,
StorageOnboardingErrorKind::ExistingKey => Self::ExistingKey,
StorageOnboardingErrorKind::Interrupted => Self::Interrupted,
StorageOnboardingErrorKind::SecureStorage => Self::SecureStorage,
StorageOnboardingErrorKind::Configuration => Self::Configuration,
@@ -2060,6 +2099,43 @@ impl MobileOnboardingOperation {
})
}
pub fn connect_local_store(&self) -> Result<MobileOnboardingOutcome, MobileOnboardingFfiError> {
let outcome = self.operation.connect_local_store(&self.request)?;
Ok(MobileOnboardingOutcome {
title: outcome.title().to_owned(),
detail: outcome.detail().to_owned(),
})
}
pub fn cancel(&self) {
self.operation.cancel();
}
}
#[derive(uniffi::Object)]
pub struct MobileLocalOnboardingOperation {
operation: mobile_onboarding::MobileOnboardingOperation,
}
#[uniffi::export]
impl MobileLocalOnboardingOperation {
pub fn generate(
&self,
user_id: String,
passphrase: String,
replace_existing_key: bool,
) -> Result<MobileOnboardingOutcome, MobileOnboardingFfiError> {
let outcome = self.operation.setup_local_generated(
&user_id,
ironstorage::repository::SecretBytes::new(passphrase.into_bytes()),
replace_existing_key,
)?;
Ok(MobileOnboardingOutcome {
title: outcome.title().to_owned(),
detail: outcome.detail().to_owned(),
})
}
pub fn cancel(&self) {
self.operation.cancel();
}
@@ -2177,6 +2253,15 @@ pub fn mobile_key_transfer() -> Result<Arc<MobileKeyTransfer>, MobileKeyTransfer
}))
}
#[uniffi::export]
pub fn mobile_local_key_transfer_importer() -> Arc<MobileKeyTransferImport> {
Arc::new(MobileKeyTransferImport {
importer: Mutex::new(
ironstorage::mobile_key_transfer::MobileKeyTransferImport::local_setup(),
),
})
}
#[uniffi::export]
pub fn mobile_onboarding_operation(
server_url: String,
@@ -2195,6 +2280,13 @@ pub fn mobile_onboarding_operation(
}))
}
#[uniffi::export]
pub fn mobile_local_onboarding_operation() -> Arc<MobileLocalOnboardingOperation> {
Arc::new(MobileLocalOnboardingOperation {
operation: mobile_onboarding::MobileOnboardingOperation::default(),
})
}
#[uniffi::export]
pub fn replace_configured_mobile_application_token(
account: String,