mirror of
https://github.com/xtool-org/xtool.git
synced 2026-11-18 13:31:38 +03:00
More cleanup
This commit is contained in:
@@ -68,6 +68,7 @@ public struct DeveloperServicesLoginManager: Sendable {
|
||||
password: password,
|
||||
twoFactorDelegate: twoFactorDelegate
|
||||
).authenticate()
|
||||
_ = twoFactorDelegate
|
||||
return try await self.logIn(withLoginData: loginData)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
framework module Supersign {
|
||||
umbrella header "Supersign.h"
|
||||
|
||||
export *
|
||||
module * { export * }
|
||||
}
|
||||
@@ -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.")
|
||||
|
||||
Reference in New Issue
Block a user