More cleanup

This commit is contained in:
Kabir Oberai
2024-12-07 01:06:48 -05:00
Unverified
parent cb68c0619e
commit 0f1eac8a92
3 changed files with 28 additions and 55 deletions
@@ -68,6 +68,7 @@ public struct DeveloperServicesLoginManager: Sendable {
password: password,
twoFactorDelegate: twoFactorDelegate
).authenticate()
_ = twoFactorDelegate
return try await self.logIn(withLoginData: loginData)
}
-6
View File
@@ -1,6 +0,0 @@
framework module Supersign {
umbrella header "Supersign.h"
export *
module * { export * }
}
+27 -49
View File
@@ -11,50 +11,6 @@ extension DeviceInfo {
}
}
private extension AuthToken {
static func retrieve(
deviceInfo: DeviceInfo,
username: String?,
password: String?,
resetProvisioning: Bool = false
) async throws -> Self {
guard let username = username ?? Console.prompt("Apple ID: "), !username.isEmpty else {
throw Console.Error("A non-empty Apple ID is required.")
}
guard let password = password ?? Console.getPassword("Password: "), !password.isEmpty else {
throw Console.Error("A non-empty password is required.")
}
let provider = try ADIDataProvider.adiProvider(
deviceInfo: deviceInfo,
storage: SupersignCLI.config.storage
)
if resetProvisioning {
provider.resetProvisioning()
}
let authDelegate = SupersignCLIAuthDelegate()
let manager = try DeveloperServicesLoginManager(
deviceInfo: deviceInfo,
anisetteProvider: provider
)
let token = try await manager.logIn(
withUsername: username,
password: password,
twoFactorDelegate: authDelegate
)
_ = authDelegate
return AuthToken(appleID: username, dsToken: token)
}
static func retrieve(deviceInfo: DeviceInfo, account: String?) async throws -> Self {
if let account = account, let token = Self(string: account) {
return token
} else {
return try await retrieve(deviceInfo: deviceInfo, username: account, password: nil)
}
}
}
struct DSLoginCommand: AsyncParsableCommand {
static let configuration = CommandConfiguration(
commandName: "login",
@@ -70,12 +26,34 @@ struct DSLoginCommand: AsyncParsableCommand {
) var printToken = false
func run() async throws {
let fullToken = try await AuthToken.retrieve(
deviceInfo: .fetch(),
username: self.username,
password: self.password,
resetProvisioning: resetProvisioning
guard let username = username ?? Console.prompt("Apple ID: "), !username.isEmpty else {
throw Console.Error("A non-empty Apple ID is required.")
}
guard let password = password ?? Console.getPassword("Password: "), !password.isEmpty else {
throw Console.Error("A non-empty password is required.")
}
let deviceInfo = try DeviceInfo.fetch()
let provider = try ADIDataProvider.adiProvider(
deviceInfo: deviceInfo,
storage: SupersignCLI.config.storage
)
if resetProvisioning {
provider.resetProvisioning()
}
let authDelegate = SupersignCLIAuthDelegate()
let manager = try DeveloperServicesLoginManager(
deviceInfo: deviceInfo,
anisetteProvider: provider
)
let token = try await manager.logIn(
withUsername: username,
password: password,
twoFactorDelegate: authDelegate
)
let fullToken = AuthToken(appleID: username, dsToken: token)
if printToken {
guard let string = fullToken.string else {
throw Console.Error("Could not encode token.")