From cc2c30b0efc0729c8b14c2705f80ad8ed4f51df0 Mon Sep 17 00:00:00 2001 From: Chili Palmer Date: Fri, 14 Aug 2026 17:53:48 +0200 Subject: [PATCH] Allow locked iPhone Git actions (#51) --- apple/Generated/ironstorage_apple.swift | 30 ++++++++++++++++++++++--- apple/Generated/ironstorage_appleFFI.h | 2 +- apple/Sources/App/IronStorageApp.swift | 14 ------------ crates/apple/src/lib.rs | 17 +++++++++----- crates/storage/src/mobile_home.rs | 13 +++++++---- 5 files changed, 49 insertions(+), 27 deletions(-) diff --git a/apple/Generated/ironstorage_apple.swift b/apple/Generated/ironstorage_apple.swift index e83ee62..c62b742 100644 --- a/apple/Generated/ironstorage_apple.swift +++ b/apple/Generated/ironstorage_apple.swift @@ -6519,6 +6519,30 @@ fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer { } } +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +fileprivate struct FfiConverterOptionTypeMobileAuthentication: FfiConverterRustBuffer { + typealias SwiftType = MobileAuthentication? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeMobileAuthentication.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeMobileAuthentication.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + #if swift(>=5.8) @_documentation(visibility: private) #endif @@ -7020,11 +7044,11 @@ public func mobileAuthentication()throws -> MobileAuthentication { ) }) } -public func mobileHomeOperation(authentication: MobileAuthentication) -> MobileHomeOperation { +public func mobileHomeOperation(authentication: MobileAuthentication?) -> MobileHomeOperation { return try! FfiConverterTypeMobileHomeOperation_lift(try! rustCall() { uniffiCallStatus in uniffi_ironstorage_apple_fn_func_mobile_home_operation( - FfiConverterTypeMobileAuthentication_lower(authentication),uniffiCallStatus + FfiConverterOptionTypeMobileAuthentication.lower(authentication),uniffiCallStatus ) }) } @@ -7125,7 +7149,7 @@ private let initializationResult: InitializationResult = { if (uniffi_ironstorage_apple_checksum_func_mobile_authentication() != 38258) { return InitializationResult.apiChecksumMismatch } - if (uniffi_ironstorage_apple_checksum_func_mobile_home_operation() != 64540) { + if (uniffi_ironstorage_apple_checksum_func_mobile_home_operation() != 26980) { return InitializationResult.apiChecksumMismatch } if (uniffi_ironstorage_apple_checksum_func_mobile_key_transfer() != 57389) { diff --git a/apple/Generated/ironstorage_appleFFI.h b/apple/Generated/ironstorage_appleFFI.h index 8e37efb..991e215 100644 --- a/apple/Generated/ironstorage_appleFFI.h +++ b/apple/Generated/ironstorage_appleFFI.h @@ -561,7 +561,7 @@ uint64_t uniffi_ironstorage_apple_fn_func_mobile_authentication(RustCallStatus * #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IRONSTORAGE_APPLE_FN_FUNC_MOBILE_HOME_OPERATION #define UNIFFI_FFIDEF_UNIFFI_IRONSTORAGE_APPLE_FN_FUNC_MOBILE_HOME_OPERATION -uint64_t uniffi_ironstorage_apple_fn_func_mobile_home_operation(uint64_t authentication, RustCallStatus *_Nonnull out_status +uint64_t uniffi_ironstorage_apple_fn_func_mobile_home_operation(RustBuffer authentication, RustCallStatus *_Nonnull out_status ); #endif #ifndef UNIFFI_FFIDEF_UNIFFI_IRONSTORAGE_APPLE_FN_FUNC_MOBILE_KEY_TRANSFER diff --git a/apple/Sources/App/IronStorageApp.swift b/apple/Sources/App/IronStorageApp.swift index 7d0d1fb..8ea3ea4 100644 --- a/apple/Sources/App/IronStorageApp.swift +++ b/apple/Sources/App/IronStorageApp.swift @@ -592,10 +592,6 @@ private final class ShellViewController: UITableViewController, MobileTabRoot { guard homePage == nil, homeTask == nil, !isHomeWorking else { return } homeGeneration += 1 let current = homeGeneration - guard let authentication else { - showHomeFailure(.unavailable) - return - } let operation = mobileHomeOperation(authentication: authentication) homeOperation = operation isHomeWorking = true @@ -621,10 +617,6 @@ private final class ShellViewController: UITableViewController, MobileTabRoot { private func runHome(_ request: HomeRequest) { guard page.state == .ready, shellTab == .home, !isHomeWorking else { return } - guard let authentication else { - showHomeFailure(.unavailable) - return - } cancelHomeWork() homeGeneration += 1 let current = homeGeneration @@ -5421,12 +5413,6 @@ private struct HomeFailure: Error, Sendable { detail: "IronStorage could not load the storage-provided Home page." ) - static let unavailable = HomeFailure( - kind: .configuration, - title: "Home Is Unavailable", - detail: "Complete password-store setup before using Git actions." - ) - private init(kind: MobileHomeErrorKind, title: String, detail: String) { self.kind = kind self.title = title diff --git a/crates/apple/src/lib.rs b/crates/apple/src/lib.rs index ddb6dbc..df26a03 100644 --- a/crates/apple/src/lib.rs +++ b/crates/apple/src/lib.rs @@ -1912,12 +1912,12 @@ pub fn set_selected_mobile_tab(tab: MobileTab) -> Result<(), MobilePreferenceErr #[uniffi::export] pub fn mobile_home_operation( - authentication: Arc, + authentication: Option>, ) -> Arc { Arc::new(MobileHomeOperation { - operation: mobile_home::MobileHomeOperation::new(Arc::clone( - &authentication.authentication, - )), + operation: mobile_home::MobileHomeOperation::new( + authentication.map(|authentication| Arc::clone(&authentication.authentication)), + ), }) } @@ -1991,7 +1991,7 @@ pub fn replace_configured_mobile_application_token( #[cfg(test)] mod tests { use super::{ - MobileHomeActionKind, MobileOnboardingErrorKind, MobileOnboardingFfiError, + MobileHomeActionKind, MobileHomePhase, MobileOnboardingErrorKind, MobileOnboardingFfiError, MobileShellState, MobileTab, StorageHomeActionKind, }; @@ -2042,4 +2042,11 @@ mod tests { MobileHomeActionKind::Push ); } + + #[test] + fn home_bridge_does_not_require_entry_authentication() { + let operation = super::mobile_home_operation(None); + assert_eq!(operation.progress().phase, MobileHomePhase::Validating); + operation.cancel(); + } } diff --git a/crates/storage/src/mobile_home.rs b/crates/storage/src/mobile_home.rs index fe3a07f..dc984b1 100644 --- a/crates/storage/src/mobile_home.rs +++ b/crates/storage/src/mobile_home.rs @@ -313,14 +313,14 @@ impl MobileHomeProgress { } pub struct MobileHomeOperation { - authentication: Arc, + authentication: Option>, control: GitOperationControl, phase: Arc>, action: Mutex>, } impl MobileHomeOperation { - pub fn new(authentication: Arc) -> Self { + pub fn new(authentication: Option>) -> Self { let phase = Arc::new(Mutex::new(MobileHomePhase::Validating)); let observed = Arc::clone(&phase); Self { @@ -413,8 +413,13 @@ impl MobileHomeOperation { } let reservation = self .authentication - .reserve_repository_operation(repository_operation(action)) - .map_err(MobileHomeError::from_reservation)?; + .as_ref() + .map(|authentication| { + authentication + .reserve_repository_operation(repository_operation(action)) + .map_err(MobileHomeError::from_reservation) + }) + .transpose()?; let result = operation(); drop(reservation); result