Some cleanup
- Commit
cb68c0619ed5b5513e8852f826ebd7fdb5dd22ff- Author
- Kabir Oberai <[email protected]>
- When
- 2024-12-07 05:40 UTC (1 year ago)
- Parents
36ee4bc
Diff
Sources/Supersign/Integration/SuperchargeInstaller.swift
diff --git a/Sources/Supersign/Integration/SuperchargeInstaller.swift b/Sources/Supersign/Integration/SuperchargeInstaller.swiftindex 22015c2..8c79e1d 100644--- a/Sources/Supersign/Integration/SuperchargeInstaller.swift+++ b/Sources/Supersign/Integration/SuperchargeInstaller.swift@@ -18,7 +18,6 @@ extension LockdownClient { public protocol IntegratedInstallerDelegate: AnyObject, Sendable { - func fetchCode() async -> String? func fetchTeam(fromTeams teams: [DeveloperServicesTeam]) async -> DeveloperServicesTeam? func setPresentedMessage(_ message: IntegratedInstaller.Message?)@@ -82,15 +81,10 @@ public actor IntegratedInstaller { case unlockDevice } - public enum Credentials: Sendable {- case password(String)- case token(DeveloperServicesLoginToken)- }- let udid: String let lookupMode: LookupMode let appleID: String- let credentials: Credentials+ let token: DeveloperServicesLoginToken let configureDevice: Bool let storage: KeyValueStorage public weak var delegate: IntegratedInstallerDelegate?@@ -150,7 +144,7 @@ public actor IntegratedInstaller { udid: String, lookupMode: LookupMode, appleID: String,- credentials: Credentials,+ token: DeveloperServicesLoginToken, configureDevice: Bool, storage: KeyValueStorage, delegate: IntegratedInstallerDelegate@@ -158,7 +152,7 @@ public actor IntegratedInstaller { self.udid = udid self.lookupMode = lookupMode self.appleID = appleID- self.credentials = credentials+ self.token = token self.configureDevice = configureDevice self.storage = storage self.delegate = delegate@@ -436,22 +430,6 @@ public actor IntegratedInstaller { try await updateStage(to: "Logging in") let anisetteProvider = try ADIDataProvider.adiProvider(deviceInfo: deviceInfo, storage: storage)- let token: DeveloperServicesLoginToken- switch credentials {- case .password(let password):- let newToken = try await DeveloperServicesLoginManager(- deviceInfo: deviceInfo,- anisetteProvider: anisetteProvider- ).logIn(- withUsername: self.appleID,- password: password,- twoFactorDelegate: self- )- try await self.updateProgress(to: 1/2)- token = newToken- case .token(let existingToken):- token = existingToken- } return try await self.install( deviceInfo: deviceInfo, provisioningData: anisetteProvider.provisioningData(),@@ -499,13 +477,4 @@ public actor IntegratedInstaller { } -extension IntegratedInstaller: TwoFactorAuthDelegate {- public func fetchCode() async -> String? {- guard let delegate = delegate else {- return nil- }- return await delegate.fetchCode()- }-}- #endif
Sources/SupersignCLISupport/DevCommand.swift
diff --git a/Sources/SupersignCLISupport/DevCommand.swift b/Sources/SupersignCLISupport/DevCommand.swiftindex 8fc40bb..9f9730b 100644--- a/Sources/SupersignCLISupport/DevCommand.swift+++ b/Sources/SupersignCLISupport/DevCommand.swift@@ -59,9 +59,6 @@ struct DevCommand: AsyncParsableCommand { let token = try AuthToken.saved() - let username = token.appleID- let credentials: IntegratedInstaller.Credentials = .token(token.dsToken)- let client = try await connectionOptions.client() print("Installing to device: \(client.deviceName) (udid: \(client.udid))") @@ -69,8 +66,8 @@ struct DevCommand: AsyncParsableCommand { let installer = IntegratedInstaller( udid: client.udid, lookupMode: .only(client.connectionType),- appleID: username,- credentials: credentials,+ appleID: token.appleID,+ token: token.dsToken, configureDevice: false, storage: SupersignCLI.config.storage, delegate: installDelegate
Sources/SupersignCLISupport/InstallCommand.swift
diff --git a/Sources/SupersignCLISupport/InstallCommand.swift b/Sources/SupersignCLISupport/InstallCommand.swiftindex e4e3cc5..3383fa6 100644--- a/Sources/SupersignCLISupport/InstallCommand.swift+++ b/Sources/SupersignCLISupport/InstallCommand.swift@@ -23,9 +23,6 @@ struct InstallCommand: AsyncParsableCommand { func run() async throws { let token = try AuthToken.saved() - let username = token.appleID- let credentials: IntegratedInstaller.Credentials = .token(token.dsToken)- let client = try await connectionOptions.client() print("Installing to device: \(client.deviceName) (udid: \(client.udid))")@@ -34,8 +31,8 @@ struct InstallCommand: AsyncParsableCommand { let installer = IntegratedInstaller( udid: client.udid, lookupMode: .only(client.connectionType),- appleID: username,- credentials: credentials,+ appleID: token.appleID,+ token: token.dsToken, configureDevice: false, storage: SupersignCLI.config.storage, delegate: installDelegate
Sources/SupersignCLISupport/SuperchargeCommand.swift
diff --git a/Sources/SupersignCLISupport/SuperchargeCommand.swift b/Sources/SupersignCLISupport/SuperchargeCommand.swiftindex 80f0460..3343348 100644--- a/Sources/SupersignCLISupport/SuperchargeCommand.swift+++ b/Sources/SupersignCLISupport/SuperchargeCommand.swift@@ -16,8 +16,6 @@ struct InstallSuperchargeCommand: AsyncParsableCommand { } let auth = try AuthToken.saved()- let username = auth.appleID- let credentials: IntegratedInstaller.Credentials = .token(auth.dsToken) let client = try await ConnectionOptions(udid: udid, search: .usb).client() @@ -27,8 +25,8 @@ struct InstallSuperchargeCommand: AsyncParsableCommand { let installer = IntegratedInstaller( udid: client.udid, lookupMode: .only(.usb),- appleID: username,- credentials: credentials,+ appleID: auth.appleID,+ token: auth.dsToken, configureDevice: true, storage: SupersignCLI.config.storage, delegate: installDelegate
Sources/SupersignCLISupport/SupersignCLIDelegate.swift
diff --git a/Sources/SupersignCLISupport/SupersignCLIDelegate.swift b/Sources/SupersignCLISupport/SupersignCLIDelegate.swiftindex ef1ea67..3174734 100644--- a/Sources/SupersignCLISupport/SupersignCLIDelegate.swift+++ b/Sources/SupersignCLISupport/SupersignCLIDelegate.swift@@ -2,17 +2,13 @@ import Foundation import Supersign import ConcurrencyExtras -private func _fetchCode() async -> String? {- Console.prompt("Code: ")-}- final class SupersignCLIAuthDelegate: TwoFactorAuthDelegate { func fetchCode() async -> String? {- await _fetchCode()+ Console.prompt("Code: ") } } -actor SupersignCLIDelegate: IntegratedInstallerDelegate, TwoFactorAuthDelegate {+actor SupersignCLIDelegate: IntegratedInstallerDelegate { public enum Error: Swift.Error { case decompressionFailed case compressionFailed@@ -25,10 +21,6 @@ actor SupersignCLIDelegate: IntegratedInstallerDelegate, TwoFactorAuthDelegate { private let updateTask = LockIsolated<Task<Void, Never>?>(nil) - func fetchCode() async -> String? {- await _fetchCode()- }- func fetchTeam(fromTeams teams: [DeveloperServicesTeam]) async -> DeveloperServicesTeam? { if let preferredTeam = preferredTeam { // Fails if a team with the requested ID isn't found.@@ -111,18 +103,11 @@ actor SupersignCLIDelegate: IntegratedInstallerDelegate, TwoFactorAuthDelegate { } } - private static let expiryFormatter: DateFormatter = {- let formatter = DateFormatter()- formatter.dateStyle = .medium- formatter.timeStyle = .short- return formatter- }()- func confirmRevocation(of certificates: [DeveloperServicesCertificate]) async -> Bool { print("\nThe following certificates must be revoked:") print( certificates.map {- "- \($0.attributes.name) (expires \(Self.expiryFormatter.string(from: $0.attributes.expiry)))"+ "- \($0.attributes.name) (expires \($0.attributes.expiry.formatted(date: .abbreviated, time: .shortened)))" }.joined(separator: "\n") ) return await Task.detached { Console.confirm("Continue?") }.value