Cache TOTP discovery and report progress (#74)
This commit is contained in:
@@ -609,6 +609,8 @@ public protocol MobileAuthenticationProtocol: AnyObject, Sendable {
|
||||
|
||||
func beginEntryEditor(path: String) throws -> MobileEntryEditorSession
|
||||
|
||||
func cachedTotpPage() throws -> MobileTotpPage?
|
||||
|
||||
func cancel() throws
|
||||
|
||||
func copyEntryField(path: String, field: UInt64) throws -> MobileEntryCopy
|
||||
@@ -647,7 +649,7 @@ public protocol MobileAuthenticationProtocol: AnyObject, Sendable {
|
||||
|
||||
func totpDetail(path: String, unixSeconds: UInt64) throws -> MobileTotpDetail
|
||||
|
||||
func totpPage() throws -> MobileTotpPage
|
||||
func totpPage(operation: MobileTotpOperation) throws -> MobileTotpPage
|
||||
|
||||
func touchUserActivity() throws
|
||||
|
||||
@@ -746,6 +748,15 @@ open func beginEntryEditor(path: String)throws -> MobileEntryEditorSession {
|
||||
})
|
||||
}
|
||||
|
||||
open func cachedTotpPage()throws -> MobileTotpPage? {
|
||||
return try FfiConverterOptionTypeMobileTotpPage.lift(try rustCallWithError(FfiConverterTypeMobileAuthenticationFfiError_lift) {
|
||||
uniffiCallStatus in
|
||||
uniffi_ironstorage_apple_fn_method_mobileauthentication_cached_totp_page(
|
||||
self.uniffiCloneHandle(),uniffiCallStatus
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
open func cancel()throws {try rustCallWithError(FfiConverterTypeMobileAuthenticationFfiError_lift) {
|
||||
uniffiCallStatus in
|
||||
uniffi_ironstorage_apple_fn_method_mobileauthentication_cancel(
|
||||
@@ -945,11 +956,12 @@ open func totpDetail(path: String, unixSeconds: UInt64)throws -> MobileTotpDeta
|
||||
})
|
||||
}
|
||||
|
||||
open func totpPage()throws -> MobileTotpPage {
|
||||
open func totpPage(operation: MobileTotpOperation)throws -> MobileTotpPage {
|
||||
return try FfiConverterTypeMobileTotpPage_lift(try rustCallWithError(FfiConverterTypeMobileAuthenticationFfiError_lift) {
|
||||
uniffiCallStatus in
|
||||
uniffi_ironstorage_apple_fn_method_mobileauthentication_totp_page(
|
||||
self.uniffiCloneHandle(),uniffiCallStatus
|
||||
self.uniffiCloneHandle(),
|
||||
FfiConverterTypeMobileTotpOperation_lower(operation),uniffiCallStatus
|
||||
)
|
||||
})
|
||||
}
|
||||
@@ -1637,6 +1649,133 @@ public func FfiConverterTypeMobileOnboardingOperation_lower(_ value: MobileOnboa
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public protocol MobileTotpOperationProtocol: AnyObject, Sendable {
|
||||
|
||||
func cancel()
|
||||
|
||||
func progress() -> MobileTotpDiscoveryProgress
|
||||
|
||||
}
|
||||
open class MobileTotpOperation: MobileTotpOperationProtocol, @unchecked Sendable {
|
||||
fileprivate let handle: UInt64
|
||||
|
||||
/// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly.
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public struct NoHandle {
|
||||
public init() {}
|
||||
}
|
||||
|
||||
// TODO: We'd like this to be `private` but for Swifty reasons,
|
||||
// we can't implement `FfiConverter` without making this `required` and we can't
|
||||
// make it `required` without making it `public`.
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
required public init(unsafeFromHandle handle: UInt64) {
|
||||
self.handle = handle
|
||||
}
|
||||
|
||||
// This constructor can be used to instantiate a fake object.
|
||||
// - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
|
||||
//
|
||||
// - Warning:
|
||||
// Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash.
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public init(noHandle: NoHandle) {
|
||||
self.handle = 0
|
||||
}
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public func uniffiCloneHandle() -> UInt64 {
|
||||
return try! rustCall { uniffi_ironstorage_apple_fn_clone_mobiletotpoperation(self.handle, $0) }
|
||||
}
|
||||
// No primary constructor declared for this class.
|
||||
|
||||
deinit {
|
||||
if handle == 0 {
|
||||
// Mock objects have handle=0 don't try to free them
|
||||
return
|
||||
}
|
||||
|
||||
try! rustCall { uniffi_ironstorage_apple_fn_free_mobiletotpoperation(handle, $0) }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
open func cancel() {try! rustCall() {
|
||||
uniffiCallStatus in
|
||||
uniffi_ironstorage_apple_fn_method_mobiletotpoperation_cancel(
|
||||
self.uniffiCloneHandle(),uniffiCallStatus
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
open func progress() -> MobileTotpDiscoveryProgress {
|
||||
return try! FfiConverterTypeMobileTotpDiscoveryProgress_lift(try! rustCall() {
|
||||
uniffiCallStatus in
|
||||
uniffi_ironstorage_apple_fn_method_mobiletotpoperation_progress(
|
||||
self.uniffiCloneHandle(),uniffiCallStatus
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public struct FfiConverterTypeMobileTotpOperation: FfiConverter {
|
||||
typealias FfiType = UInt64
|
||||
typealias SwiftType = MobileTotpOperation
|
||||
|
||||
public static func lift(_ handle: UInt64) throws -> MobileTotpOperation {
|
||||
return MobileTotpOperation(unsafeFromHandle: handle)
|
||||
}
|
||||
|
||||
public static func lower(_ value: MobileTotpOperation) -> UInt64 {
|
||||
return value.uniffiCloneHandle()
|
||||
}
|
||||
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MobileTotpOperation {
|
||||
let handle: UInt64 = try readInt(&buf)
|
||||
return try lift(handle)
|
||||
}
|
||||
|
||||
public static func write(_ value: MobileTotpOperation, into buf: inout [UInt8]) {
|
||||
writeInt(&buf, lower(value))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public func FfiConverterTypeMobileTotpOperation_lift(_ handle: UInt64) throws -> MobileTotpOperation {
|
||||
return try FfiConverterTypeMobileTotpOperation.lift(handle)
|
||||
}
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public func FfiConverterTypeMobileTotpOperation_lower(_ value: MobileTotpOperation) -> UInt64 {
|
||||
return FfiConverterTypeMobileTotpOperation.lower(value)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public struct MobileAuthenticationState: Equatable, Hashable {
|
||||
public var unlocked: Bool
|
||||
public var biometricUnlockEnabled: Bool
|
||||
@@ -3713,16 +3852,88 @@ public func FfiConverterTypeMobileTotpDetail_lower(_ value: MobileTotpDetail) ->
|
||||
}
|
||||
|
||||
|
||||
public struct MobileTotpDiscoveryProgress: Equatable, Hashable {
|
||||
public var phase: MobileTotpDiscoveryPhase
|
||||
public var total: UInt32
|
||||
public var inspected: UInt32
|
||||
public var cacheHits: UInt32
|
||||
public var matches: UInt32
|
||||
public var unavailable: UInt32
|
||||
|
||||
// Default memberwise initializers are never public by default, so we
|
||||
// declare one manually.
|
||||
public init(phase: MobileTotpDiscoveryPhase, total: UInt32, inspected: UInt32, cacheHits: UInt32, matches: UInt32, unavailable: UInt32) {
|
||||
self.phase = phase
|
||||
self.total = total
|
||||
self.inspected = inspected
|
||||
self.cacheHits = cacheHits
|
||||
self.matches = matches
|
||||
self.unavailable = unavailable
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#if compiler(>=6)
|
||||
extension MobileTotpDiscoveryProgress: Sendable {}
|
||||
#endif
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public struct FfiConverterTypeMobileTotpDiscoveryProgress: FfiConverterRustBuffer {
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MobileTotpDiscoveryProgress {
|
||||
return
|
||||
try MobileTotpDiscoveryProgress(
|
||||
phase: FfiConverterTypeMobileTotpDiscoveryPhase.read(from: &buf),
|
||||
total: FfiConverterUInt32.read(from: &buf),
|
||||
inspected: FfiConverterUInt32.read(from: &buf),
|
||||
cacheHits: FfiConverterUInt32.read(from: &buf),
|
||||
matches: FfiConverterUInt32.read(from: &buf),
|
||||
unavailable: FfiConverterUInt32.read(from: &buf)
|
||||
)
|
||||
}
|
||||
|
||||
public static func write(_ value: MobileTotpDiscoveryProgress, into buf: inout [UInt8]) {
|
||||
FfiConverterTypeMobileTotpDiscoveryPhase.write(value.phase, into: &buf)
|
||||
FfiConverterUInt32.write(value.total, into: &buf)
|
||||
FfiConverterUInt32.write(value.inspected, into: &buf)
|
||||
FfiConverterUInt32.write(value.cacheHits, into: &buf)
|
||||
FfiConverterUInt32.write(value.matches, into: &buf)
|
||||
FfiConverterUInt32.write(value.unavailable, into: &buf)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public func FfiConverterTypeMobileTotpDiscoveryProgress_lift(_ buf: RustBuffer) throws -> MobileTotpDiscoveryProgress {
|
||||
return try FfiConverterTypeMobileTotpDiscoveryProgress.lift(buf)
|
||||
}
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public func FfiConverterTypeMobileTotpDiscoveryProgress_lower(_ value: MobileTotpDiscoveryProgress) -> RustBuffer {
|
||||
return FfiConverterTypeMobileTotpDiscoveryProgress.lower(value)
|
||||
}
|
||||
|
||||
|
||||
public struct MobileTotpPage: Equatable, Hashable {
|
||||
public var rows: [MobileTotpRow]
|
||||
public var unavailableEntries: UInt32
|
||||
public var cacheNotice: String?
|
||||
public var watch: MobileWatchSnapshotStatus
|
||||
|
||||
// Default memberwise initializers are never public by default, so we
|
||||
// declare one manually.
|
||||
public init(rows: [MobileTotpRow], unavailableEntries: UInt32, watch: MobileWatchSnapshotStatus) {
|
||||
public init(rows: [MobileTotpRow], unavailableEntries: UInt32, cacheNotice: String?, watch: MobileWatchSnapshotStatus) {
|
||||
self.rows = rows
|
||||
self.unavailableEntries = unavailableEntries
|
||||
self.cacheNotice = cacheNotice
|
||||
self.watch = watch
|
||||
}
|
||||
|
||||
@@ -3744,6 +3955,7 @@ public struct FfiConverterTypeMobileTotpPage: FfiConverterRustBuffer {
|
||||
try MobileTotpPage(
|
||||
rows: FfiConverterSequenceTypeMobileTotpRow.read(from: &buf),
|
||||
unavailableEntries: FfiConverterUInt32.read(from: &buf),
|
||||
cacheNotice: FfiConverterOptionString.read(from: &buf),
|
||||
watch: FfiConverterTypeMobileWatchSnapshotStatus.read(from: &buf)
|
||||
)
|
||||
}
|
||||
@@ -3751,6 +3963,7 @@ public struct FfiConverterTypeMobileTotpPage: FfiConverterRustBuffer {
|
||||
public static func write(_ value: MobileTotpPage, into buf: inout [UInt8]) {
|
||||
FfiConverterSequenceTypeMobileTotpRow.write(value.rows, into: &buf)
|
||||
FfiConverterUInt32.write(value.unavailableEntries, into: &buf)
|
||||
FfiConverterOptionString.write(value.cacheNotice, into: &buf)
|
||||
FfiConverterTypeMobileWatchSnapshotStatus.write(value.watch, into: &buf)
|
||||
}
|
||||
}
|
||||
@@ -5747,6 +5960,93 @@ public func FfiConverterTypeMobileTab_lower(_ value: MobileTab) -> RustBuffer {
|
||||
|
||||
|
||||
|
||||
public enum MobileTotpDiscoveryPhase: Equatable, Hashable {
|
||||
|
||||
case preparing
|
||||
case inspecting
|
||||
case saving
|
||||
case complete
|
||||
case cancelled
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#if compiler(>=6)
|
||||
extension MobileTotpDiscoveryPhase: Sendable {}
|
||||
#endif
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public struct FfiConverterTypeMobileTotpDiscoveryPhase: FfiConverterRustBuffer {
|
||||
typealias SwiftType = MobileTotpDiscoveryPhase
|
||||
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MobileTotpDiscoveryPhase {
|
||||
let variant: Int32 = try readInt(&buf)
|
||||
switch variant {
|
||||
|
||||
case 1: return .preparing
|
||||
|
||||
case 2: return .inspecting
|
||||
|
||||
case 3: return .saving
|
||||
|
||||
case 4: return .complete
|
||||
|
||||
case 5: return .cancelled
|
||||
|
||||
default: throw UniffiInternalError.unexpectedEnumCase
|
||||
}
|
||||
}
|
||||
|
||||
public static func write(_ value: MobileTotpDiscoveryPhase, into buf: inout [UInt8]) {
|
||||
switch value {
|
||||
|
||||
|
||||
case .preparing:
|
||||
writeInt(&buf, Int32(1))
|
||||
|
||||
|
||||
case .inspecting:
|
||||
writeInt(&buf, Int32(2))
|
||||
|
||||
|
||||
case .saving:
|
||||
writeInt(&buf, Int32(3))
|
||||
|
||||
|
||||
case .complete:
|
||||
writeInt(&buf, Int32(4))
|
||||
|
||||
|
||||
case .cancelled:
|
||||
writeInt(&buf, Int32(5))
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public func FfiConverterTypeMobileTotpDiscoveryPhase_lift(_ buf: RustBuffer) throws -> MobileTotpDiscoveryPhase {
|
||||
return try FfiConverterTypeMobileTotpDiscoveryPhase.lift(buf)
|
||||
}
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public func FfiConverterTypeMobileTotpDiscoveryPhase_lower(_ value: MobileTotpDiscoveryPhase) -> RustBuffer {
|
||||
return FfiConverterTypeMobileTotpDiscoveryPhase.lower(value)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public enum MobileWatchSnapshotState: Equatable, Hashable {
|
||||
|
||||
case unavailable
|
||||
@@ -5931,6 +6231,30 @@ fileprivate struct FfiConverterOptionTypeMobileKeyTransferKey: FfiConverterRustB
|
||||
}
|
||||
}
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
fileprivate struct FfiConverterOptionTypeMobileTotpPage: FfiConverterRustBuffer {
|
||||
typealias SwiftType = MobileTotpPage?
|
||||
|
||||
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
||||
guard let value = value else {
|
||||
writeInt(&buf, Int8(0))
|
||||
return
|
||||
}
|
||||
writeInt(&buf, Int8(1))
|
||||
FfiConverterTypeMobileTotpPage.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 FfiConverterTypeMobileTotpPage.read(from: &buf)
|
||||
default: throw UniffiInternalError.unexpectedOptionalTag
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
@@ -6343,6 +6667,13 @@ public func mobileShellFixture(state: MobileShellState) -> MobileShell {
|
||||
)
|
||||
})
|
||||
}
|
||||
public func mobileTotpOperation() -> MobileTotpOperation {
|
||||
return try! FfiConverterTypeMobileTotpOperation_lift(try! rustCall() {
|
||||
uniffiCallStatus in
|
||||
uniffi_ironstorage_apple_fn_func_mobile_totp_operation(uniffiCallStatus
|
||||
)
|
||||
})
|
||||
}
|
||||
public func productName() -> String {
|
||||
return try! FfiConverterString.lift(try! rustCall() {
|
||||
uniffiCallStatus in
|
||||
@@ -6405,6 +6736,9 @@ private let initializationResult: InitializationResult = {
|
||||
if (uniffi_ironstorage_apple_checksum_func_mobile_shell_fixture() != 1649) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_ironstorage_apple_checksum_func_mobile_totp_operation() != 22350) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_ironstorage_apple_checksum_func_product_name() != 43533) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
@@ -6423,6 +6757,9 @@ private let initializationResult: InitializationResult = {
|
||||
if (uniffi_ironstorage_apple_checksum_method_mobileauthentication_begin_entry_editor() != 63281) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_ironstorage_apple_checksum_method_mobileauthentication_cached_totp_page() != 36629) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_ironstorage_apple_checksum_method_mobileauthentication_cancel() != 6512) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
@@ -6480,7 +6817,7 @@ private let initializationResult: InitializationResult = {
|
||||
if (uniffi_ironstorage_apple_checksum_method_mobileauthentication_totp_detail() != 42762) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_ironstorage_apple_checksum_method_mobileauthentication_totp_page() != 18529) {
|
||||
if (uniffi_ironstorage_apple_checksum_method_mobileauthentication_totp_page() != 15475) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_ironstorage_apple_checksum_method_mobileauthentication_touch_user_activity() != 18402) {
|
||||
@@ -6540,6 +6877,12 @@ private let initializationResult: InitializationResult = {
|
||||
if (uniffi_ironstorage_apple_checksum_method_mobileonboardingoperation_setup() != 3525) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_ironstorage_apple_checksum_method_mobiletotpoperation_cancel() != 30179) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_ironstorage_apple_checksum_method_mobiletotpoperation_progress() != 54435) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
|
||||
return InitializationResult.ok
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user