Skip to content

armgit / xtool

Public Imported from GitHub
0

Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.

more fixes

Kabir Oberai7a0b84584397
diff --git a/Supersign/Sources/Supersign/GrandSlam/Anisette/ADIDataProvider.swift b/Supersign/Sources/Supersign/GrandSlam/Anisette/ADIDataProvider.swift
index 4ee2561..f41f014 100644
--- a/Supersign/Sources/Supersign/GrandSlam/Anisette/ADIDataProvider.swift
+++ b/Supersign/Sources/Supersign/GrandSlam/Anisette/ADIDataProvider.swift
@@ -5,23 +5,35 @@ enum HashingError: Error {
case hashingFailed
}
-private extension String {
+private extension Data {
func sha256() throws -> [UInt8] {
- Array(SHA256.hash(data: Data(utf8)))
+ Array(SHA256.hash(data: self))
}
}
public protocol RawADIProvider {
- func startProvisioning(spim: Data) async throws -> (String, Data)
+ func clientInfo() async throws -> String
+ func startProvisioning(spim: Data, userID: UUID) async throws -> (RawADIProvisioningSession, Data)
+
+ func requestOTP(userID: UUID, routingInfo: inout UInt64, provisioningInfo: Data) async throws -> (machineID: Data, otp: Data)
+}
+
+extension RawADIProvider {
+ public func clientInfo() async throws -> String {
+ // Looks like Apple detects attempts to use a macOS client string on Windows :/
+ """
+ <PC> <Windows;6.2(0,0);9200> <com.apple.AuthKitWin/1 (com.apple.iCloud/7.21)>
+ """
+ }
+}
+
+public protocol RawADIProvisioningSession {
func endProvisioning(
- session: String,
routingInfo: UInt64,
ptm: Data,
tk: Data
) async throws -> Data
-
- func requestOTP(provisioningInfo: Data) async throws -> (machineID: Data, otp: Data)
}
// uses CoreADI APIs
@@ -40,8 +52,11 @@ public final class ADIDataProvider: AnisetteDataProvider {
private let httpClient: HTTPClientProtocol
private let lookupManager: GrandSlamLookupManager
+ private let localUserUID: UUID
private let localUserID: String
+ private var _clientInfo: String?
+
public init(
rawProvider: RawADIProvider,
deviceInfo: DeviceInfo,
@@ -55,18 +70,19 @@ public final class ADIDataProvider: AnisetteDataProvider {
self.httpClient = httpFactory.makeClient()
self.lookupManager = .init(deviceInfo: deviceInfo, httpFactory: httpFactory)
- if let localUserID = try storage.string(forKey: Self.localUserIDKey) {
- self.localUserID = localUserID
+ if let localUserUIDString = try storage.string(forKey: Self.localUserUIDKey),
+ let localUserUID = UUID(uuidString: localUserUIDString) {
+ self.localUserUID = localUserUID
} else {
- // localUserID = SHA256(local user UID)
- let localUserUID = UUID().uuidString
- let localUserID = try localUserUID.sha256().map { String(format: "%02X", $0) }.joined()
- try storage.setString(localUserID, forKey: Self.localUserIDKey)
- self.localUserID = localUserID
+ let localUserUID = UUID()
+ try storage.setString(localUserUID.uuidString, forKey: Self.localUserUIDKey)
+ self.localUserUID = localUserUID
}
+ // localUserID = SHA256(local user UID)
+ self.localUserID = try localUserUID.rawBytes.sha256().map { String(format: "%02X", $0) }.joined()
}
- private static let localUserIDKey = "SUPLocalUserID"
+ private static let localUserUIDKey = "SUPLocalUserUID"
private static let provisioningKey = "SUPProvisioningInfo"
private static let routingInfoKey = "SUPRoutingInfo"
@@ -106,6 +122,13 @@ public final class ADIDataProvider: AnisetteDataProvider {
return encoder
}()
+ private func clientInfo() async throws -> String {
+ if let _clientInfo { return _clientInfo }
+ let clientInfo = try await rawProvider.clientInfo()
+ self._clientInfo = clientInfo
+ return clientInfo
+ }
+
private func sendRequest<Request: Encodable, Response: Decodable>(
endpoint: GrandSlamEndpoint,
request: Request
@@ -126,11 +149,8 @@ public final class ADIDataProvider: AnisetteDataProvider {
)
request.headers["X-MMe-Country"] = Locale.current.regionCode
- // Looks like Apple detects attempts to use a macOS client string on Windows :/
- request.headers[DeviceInfo.clientInfoKey] = """
- <PC> <Windows;6.2(0,0);9200> <com.apple.AuthKitWin/1 (com.apple.iCloud/7.21)>
- """
- request.headers[DeviceInfo.deviceIDKey] = self.deviceInfo.deviceID
+ request.headers[DeviceInfo.clientInfoKey] = try await clientInfo()
+ request.headers[DeviceInfo.deviceIDKey] = self.localUserUID.uuidString
// request.headers[DeviceInfo.clientInfoKey] = self.deviceInfo.clientInfo.clientString
// self.deviceInfo.dictionary.forEach { request.headers[$0] = $1 }
@@ -143,7 +163,7 @@ public final class ADIDataProvider: AnisetteDataProvider {
}
private func endProvisioning(
- id: String,
+ session: RawADIProvisioningSession,
cpim: Data
) async throws -> (routingInfo: UInt64, provisioningInfo: Data) {
let resp: EndProvisioningResponse = try await sendRequest(
@@ -156,8 +176,8 @@ public final class ADIDataProvider: AnisetteDataProvider {
let tk = Data(base64Encoded: resp.tk)
else { throw ADIError.badEndResponse }
- let provisioningInfo = try await self.rawProvider.endProvisioning(
- session: id, routingInfo: rinfo, ptm: ptm, tk: tk
+ let provisioningInfo = try await session.endProvisioning(
+ routingInfo: rinfo, ptm: ptm, tk: tk
)
return (rinfo, provisioningInfo)
@@ -169,8 +189,8 @@ public final class ADIDataProvider: AnisetteDataProvider {
request: StartProvisioningRequest()
)
guard let spim = Data(base64Encoded: resp.spim) else { throw ADIError.badStartResponse }
- let (id, cpim) = try await rawProvider.startProvisioning(spim: spim)
- return try await endProvisioning(id: id, cpim: cpim)
+ let (session, cpim) = try await rawProvider.startProvisioning(spim: spim, userID: localUserUID)
+ return try await endProvisioning(session: session, cpim: cpim)
}
private func fetchAnisetteData(
@@ -178,14 +198,19 @@ public final class ADIDataProvider: AnisetteDataProvider {
provisioningInfo: Data
) async throws -> AnisetteData {
let requestTime = Date()
- let (mid, otp) = try await rawProvider.requestOTP(provisioningInfo: provisioningInfo)
+ var routingInfo = routingInfo
+ let (mid, otp) = try await rawProvider.requestOTP(userID: localUserUID, routingInfo: &routingInfo, provisioningInfo: provisioningInfo)
return AnisetteData(
clientTime: requestTime,
routingInfo: routingInfo,
machineID: mid.base64EncodedString(),
localUserID: self.localUserID,
- oneTimePassword: otp.base64EncodedString()
+ oneTimePassword: otp.base64EncodedString(),
+ deviceID: self.localUserUID.uuidString
)
+// let data = try await URLSession.shared.data(from: URL(string: "https://ani.sidestore.io")!).0
+// let otpVal = try (JSONSerialization.jsonObject(with: data) as! [String: Any])["X-Apple-I-MD"] as! String
+// return AnisetteData(clientTime: Date(), routingInfo: 17106176, machineID: "QPW9c1q+3xAr4CPt1NlFK9txkfno+vPTS6BCWPSCmHvk495CI+eFqt83/833IPU6aibCOMDBzZcD0W2I", localUserID: "B21B57ED6CB25584B80E97B8B28206B9C01EB23D32A18E69A701EDE84EC07B38", oneTimePassword: otpVal)
}
public func resetProvisioning() throws {
diff --git a/Supersign/Sources/Supersign/GrandSlam/Anisette/AnisetteData.swift b/Supersign/Sources/Supersign/GrandSlam/Anisette/AnisetteData.swift
index ee7bd26..6a31c61 100644
--- a/Supersign/Sources/Supersign/GrandSlam/Anisette/AnisetteData.swift
+++ b/Supersign/Sources/Supersign/GrandSlam/Anisette/AnisetteData.swift
@@ -49,16 +49,23 @@ public struct AnisetteData {
static let oneTimePasswordKey = "X-Apple-I-MD"
public let oneTimePassword: String
+ static let deviceIDKey = "X-Mme-Device-Id"
+ public var deviceID: String?
+
var dictionary: [String: String] {
- [
+ var dictionary = [
Self.localeKey: locale.identifier,
Self.timeZoneKey: timeZone.abbreviation() ?? "UTC",
Self.clientTimeKey: Self.dateFormatter.string(from: clientTime),
Self.routingInfoKey: "\(routingInfo)",
Self.machineIDKey: machineID,
Self.localUserIDKey: localUserID,
- Self.oneTimePasswordKey: oneTimePassword
+ Self.oneTimePasswordKey: oneTimePassword,
]
+ if let deviceID {
+ dictionary[Self.deviceIDKey] = deviceID
+ }
+ return dictionary
}
}
diff --git a/Supersign/Sources/Supersign/GrandSlam/Anisette/OmnisetteADIProvider.swift b/Supersign/Sources/Supersign/GrandSlam/Anisette/OmnisetteADIProvider.swift
new file mode 100644
index 0000000..98e5503
--- /dev/null
+++ b/Supersign/Sources/Supersign/GrandSlam/Anisette/OmnisetteADIProvider.swift
@@ -0,0 +1,192 @@
+import Foundation
+
+struct OmnisetteADIProvider: RawADIProvider {
+ // should implement v3 of https://github.com/SideStore/omnisette-server
+ // list: https://servers.sidestore.io/servers.json
+ // e.g. https://ani.sidestore.io
+ private let url: URL
+ init(url: URL = URL(string: "https://ani.sidestore.io")!) {
+ self.url = url
+ }
+
+ static let decoder: JSONDecoder = {
+ let decoder = JSONDecoder()
+ decoder.keyDecodingStrategy = .convertFromSnakeCase
+ decoder.dataDecodingStrategy = .base64
+ return decoder
+ }()
+
+ static let encoder: JSONEncoder = {
+ let encoder = JSONEncoder()
+ encoder.keyEncodingStrategy = .convertToSnakeCase
+ encoder.dataEncodingStrategy = .base64
+ return encoder
+ }()
+
+ func clientInfo() async throws -> String {
+ struct ClientInfo: Decodable {
+ let clientInfo: String
+ }
+ let (response, _) = try await URLSession.shared.data(from: url.appendingPathComponent("v3/client_info"))
+ let clientInfo = try Self.decoder.decode(ClientInfo.self, from: response)
+ return clientInfo.clientInfo
+ }
+
+ func startProvisioning(spim: Data, userID: UUID) async throws -> (RawADIProvisioningSession, Data) {
+ var url = url.appendingPathComponent("v3/provisioning_session")
+ var components = URLComponents(url: url, resolvingAgainstBaseURL: false)!
+ components.scheme = components.scheme == "http" ? "ws" : "wss"
+ url = components.url!
+ let task = URLSession.shared.webSocketTask(with: url)
+ task.resume()
+ let connection = OmnisetteProvisioningSession(task: task)
+ let cpim = try await connection.startProvisioning(spim: spim, userID: userID)
+ return (connection, cpim)
+ }
+
+ func requestOTP(
+ userID: UUID,
+ routingInfo: inout UInt64,
+ provisioningInfo: Data
+ ) async throws -> (machineID: Data, otp: Data) {
+ struct Request: Encodable {
+ let identifier: Data
+ let adiPb: Data
+ }
+
+ struct Response: Decodable {
+ var machineID: Data
+ var otp: Data
+ var rinfo: String
+
+ private enum CodingKeys: String, CodingKey {
+ case machineID = "X-Apple-I-MD-M"
+ case otp = "X-Apple-I-MD"
+ case rinfo = "X-Apple-I-MD-RINFO"
+ }
+ }
+
+ var request = URLRequest(url: url.appendingPathComponent("v3/get_headers"))
+ request.httpMethod = "POST"
+ request.httpBody = try Self.encoder.encode(Request(
+ identifier: userID.rawBytes,
+ adiPb: provisioningInfo
+ ))
+ request.setValue("application/json", forHTTPHeaderField: "Content-Type")
+ let (response, _) = try await URLSession.shared.data(for: request)
+ let decoded = try Self.decoder.decode(Response.self, from: response)
+ if let rinfo = UInt64(decoded.rinfo) {
+ routingInfo = rinfo
+ }
+ return (decoded.machineID, decoded.otp)
+ }
+}
+
+private final class OmnisetteProvisioningSession: RawADIProvisioningSession {
+ let task: URLSessionWebSocketTask
+
+ init(task: URLSessionWebSocketTask) {
+ self.task = task
+ }
+
+ deinit {
+ close()
+ }
+
+ private func close() {
+ task.cancel(with: .normalClosure, reason: nil)
+ }
+
+ func startProvisioning(
+ spim: Data,
+ userID: UUID
+ ) async throws -> Data {
+ do {
+ struct Response: Encodable {
+ let identifier: Data
+ }
+ try await receive("GiveIdentifier")
+ try await send(Response(identifier: userID.rawBytes))
+ }
+
+ do {
+ struct Response: Encodable {
+ let spim: Data
+ }
+ try await receive("GiveStartProvisioningData")
+ try await send(Response(spim: spim))
+ }
+
+ do {
+ struct Request: Decodable {
+ let cpim: Data
+ }
+ return try await receive("GiveEndProvisioningData", as: Request.self).cpim
+ }
+ }
+
+ func endProvisioning(routingInfo: UInt64, ptm: Data, tk: Data) async throws -> Data {
+ defer { close() }
+ do {
+ struct Response: Encodable {
+ let ptm: Data
+ let tk: Data
+ }
+ try await send(Response(ptm: ptm, tk: tk))
+ }
+
+ do {
+ struct Request: Decodable {
+ let adiPb: Data
+ }
+ return try await receive("ProvisioningSuccess", as: Request.self).adiPb
+ }
+ }
+
+ private struct Header: Decodable {
+ let result: String
+ }
+
+ @discardableResult
+ private func receive<T: Decodable>(_ message: String, as type: T.Type = EmptyResponse.self) async throws -> T {
+ let data = switch try await task.receive() {
+ case .data(let data): data
+ case .string(let text): Data(text.utf8)
+ @unknown default: Data()
+ }
+ let header = try OmnisetteADIProvider.decoder.decode(Header.self, from: data)
+ guard header.result == message else {
+ throw DecodingError.dataCorrupted(.init(
+ codingPath: [],
+ debugDescription: "Expected message '\(message)', got \(header.result)"
+ ))
+ }
+ return try OmnisetteADIProvider.decoder.decode(type, from: data)
+ }
+
+ private func send<T: Encodable>(_ message: T) async throws {
+ let encoded = try OmnisetteADIProvider.encoder.encode(message)
+ try await task.send(.string(String(decoding: encoded, as: UTF8.self)))
+ }
+}
+
+extension UUID {
+ var rawBytes: Data {
+ withUnsafeBytes(of: uuid) { Data($0) }
+ }
+}
+
+extension ADIDataProvider {
+ public static func omnisetteProvider(
+ deviceInfo: DeviceInfo,
+ storage: KeyValueStorage,
+ httpFactory: HTTPClientFactory = defaultHTTPClientFactory
+ ) throws -> ADIDataProvider {
+ return try ADIDataProvider(
+ rawProvider: OmnisetteADIProvider(),
+ deviceInfo: deviceInfo,
+ storage: storage,
+ httpFactory: httpFactory
+ )
+ }
+}
diff --git a/Supersign/Sources/Supersign/GrandSlam/Anisette/Supersette/SupersetteADIProvider.swift b/Supersign/Sources/Supersign/GrandSlam/Anisette/Supersette/SupersetteADIProvider.swift
index 49cf6c4..54d4b67 100644
--- a/Supersign/Sources/Supersign/GrandSlam/Anisette/Supersette/SupersetteADIProvider.swift
+++ b/Supersign/Sources/Supersign/GrandSlam/Anisette/Supersette/SupersetteADIProvider.swift
@@ -1,6 +1,15 @@
import Foundation
public class SupersetteADIProvider: RawADIProvider {
+ private struct ProvisioningSession: RawADIProvisioningSession {
+ let session: String
+ let provider: SupersetteADIProvider
+
+ func endProvisioning(routingInfo: UInt64, ptm: Data, tk: Data) async throws -> Data {
+ try await provider.endProvisioning(session: session, routingInfo: routingInfo, ptm: ptm, tk: tk)
+ }
+ }
+
private static let gateway = "http://kabir-winvm.local:3000/v1"
private static let encoder = JSONEncoder()
@@ -38,7 +47,7 @@ public class SupersetteADIProvider: RawADIProvider {
return try Self.decoder.decode(Response.self, from: data)
}
- public func startProvisioning(spim: Data) async throws -> (String, Data) {
+ public func startProvisioning(spim: Data, userID: UUID) async throws -> (RawADIProvisioningSession, Data) {
struct Request: Encodable {
let spim: Data
}
@@ -50,10 +59,11 @@ public class SupersetteADIProvider: RawADIProvider {
endpoint: "start-provisioning",
request: Request(spim: spim)
)
- return (resp.sessionID, resp.cpim)
+ let session = ProvisioningSession(session: resp.sessionID, provider: self)
+ return (session, resp.cpim)
}
- public func endProvisioning(
+ private func endProvisioning(
session: String,
routingInfo: UInt64,
ptm: Data,
@@ -75,7 +85,11 @@ public class SupersetteADIProvider: RawADIProvider {
return resp.provisioningInfo
}
- public func requestOTP(provisioningInfo: Data) async throws -> (machineID: Data, otp: Data) {
+ public func requestOTP(
+ userID: UUID,
+ routingInfo: inout UInt64,
+ provisioningInfo: Data
+ ) async throws -> (machineID: Data, otp: Data) {
struct Request: Encodable {
let provisioningInfo: Data
}
diff --git a/Supersign/Sources/Supersign/GrandSlam/Operations/GrandSlamAuthenticateOperation.swift b/Supersign/Sources/Supersign/GrandSlam/Operations/GrandSlamAuthenticateOperation.swift
index fa6e615..ea45e14 100644
--- a/Supersign/Sources/Supersign/GrandSlam/Operations/GrandSlamAuthenticateOperation.swift
+++ b/Supersign/Sources/Supersign/GrandSlam/Operations/GrandSlamAuthenticateOperation.swift
@@ -71,7 +71,7 @@ class GrandSlamAuthenticateOperation {
}
private func authenticateTwoFactor(
- mode: GrandSlamAuthMode,
+ mode: GrandSlamAuthMode?,
loginData: GrandSlamLoginData
) async throws -> GrandSlamLoginData {
guard !isSecondAttempt else { throw Error.failedSecondaryAuth }
@@ -105,10 +105,9 @@ class GrandSlamAuthenticateOperation {
let loginData = try decoder.decode(GrandSlamLoginData.self, from: rawLoginResponse)
- if response.statusCode == 409,
- let secondaryURL = response.url,
- let authMode = GrandSlamAuthMode(rawValue: secondaryURL) {
+ if response.statusCode == 409 {
// 2FA
+ let authMode = response.url.flatMap { GrandSlamAuthMode(rawValue: $0) }
return try await authenticateTwoFactor(
mode: authMode,
loginData: loginData
diff --git a/Supersign/Sources/Supersign/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swift b/Supersign/Sources/Supersign/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swift
index 12ac243..6862710 100644
--- a/Supersign/Sources/Supersign/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swift
+++ b/Supersign/Sources/Supersign/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swift
@@ -9,7 +9,7 @@
import Foundation
public protocol TwoFactorAuthDelegate: AnyObject {
- func fetchCode(completion: @escaping (String?) -> Void)
+ func fetchCode() async -> String?
}
class GrandSlamTwoFactorAuthenticateOperation {
@@ -20,12 +20,12 @@ class GrandSlamTwoFactorAuthenticateOperation {
}
let client: GrandSlamClient
- let mode: GrandSlamAuthMode
+ let mode: GrandSlamAuthMode?
let loginData: GrandSlamLoginData
unowned let delegate: TwoFactorAuthDelegate
init(
client: GrandSlamClient,
- mode: GrandSlamAuthMode,
+ mode: GrandSlamAuthMode?,
loginData: GrandSlamLoginData,
delegate: TwoFactorAuthDelegate
) {
@@ -37,16 +37,11 @@ class GrandSlamTwoFactorAuthenticateOperation {
private func performSecondaryAuth() async throws {
try await client.send(GrandSlamSecondaryAuthRequest(loginData: loginData))
- let code = await withCheckedContinuation { continuation in
- self.delegate.fetchCode {
- continuation.resume(returning: $0)
- }
- }
- try await self.validate(code: code)
+ try await validateCode()
}
- private func validate(code: String?) async throws {
- guard let code = code else { throw Error.userCancelled }
+ private func validateCode() async throws {
+ guard let code = await self.delegate.fetchCode() else { throw Error.userCancelled }
let request = GrandSlamValidateRequest(loginData: loginData, verificationCode: code)
do {
try await client.send(request)
@@ -58,12 +53,7 @@ class GrandSlamTwoFactorAuthenticateOperation {
private func performTrustedDeviceAuth() async throws {
let request = GrandSlamTrustedDeviceRequest(loginData: loginData)
try await client.send(request)
- let code = await withCheckedContinuation { continuation in
- self.delegate.fetchCode {
- continuation.resume(returning: $0)
- }
- }
- try await self.validate(code: code)
+ try await validateCode()
}
func perform() async throws {
@@ -75,6 +65,8 @@ class GrandSlamTwoFactorAuthenticateOperation {
try await self.performTrustedDeviceAuth()
case .trustedDeviceSecondaryAuth:
try await self.performTrustedDeviceAuth()
+ case nil: // means 2FA was automatically requested
+ try await validateCode()
}
}
diff --git a/Supersign/Sources/Supersign/GrandSlam/Requests/GrandSlamOperationRequest.swift b/Supersign/Sources/Supersign/GrandSlam/Requests/GrandSlamOperationRequest.swift
index 1e840ab..8a6bc77 100644
--- a/Supersign/Sources/Supersign/GrandSlam/Requests/GrandSlamOperationRequest.swift
+++ b/Supersign/Sources/Supersign/GrandSlam/Requests/GrandSlamOperationRequest.swift
@@ -72,6 +72,10 @@ extension GrandSlamOperationRequest {
func configure(request: inout HTTPRequest, deviceInfo: DeviceInfo, anisetteData: AnisetteData) {
request.headers["Accept"] = "*/*"
request.headers["User-Agent"] = deviceInfo.clientInfo.userAgent
+ // as of November 2024 it appears that using Mac clientInfo for auth causes
+ // secondaryAuth to fail in some cases. using PC instead causes GSA to immediately
+ // prompt for 2fa on o=complete, no secondaryAuth call needed.
+ request.headers[DeviceInfo.clientInfoKey] = "<PC> <Windows;6.2(0,0);9200> <com.apple.AuthKitWin/1 (com.apple.iCloud/7.21)>"
}
func method(deviceInfo: DeviceInfo, anisetteData: AnisetteData) -> GrandSlamMethod {
diff --git a/Supersign/Sources/Supersign/Integration/SuperchargeInstaller.swift b/Supersign/Sources/Supersign/Integration/SuperchargeInstaller.swift
index 642c861..5be923e 100644
--- a/Supersign/Sources/Supersign/Integration/SuperchargeInstaller.swift
+++ b/Supersign/Sources/Supersign/Integration/SuperchargeInstaller.swift
@@ -17,7 +17,7 @@ extension LockdownClient {
public protocol IntegratedInstallerDelegate: AnyObject {
- func fetchCode(completion: @escaping (String?) -> Void)
+ func fetchCode() async -> String?
func fetchTeam(fromTeams teams: [DeveloperServicesTeam], completion: @escaping (DeveloperServicesTeam?) -> Void)
func setPresentedMessage(_ message: IntegratedInstaller.Message?)
func installerDidUpdate(toStage stage: String, progress: Double?)
@@ -544,16 +544,11 @@ public final class IntegratedInstaller {
}
extension IntegratedInstaller: TwoFactorAuthDelegate {
- public func fetchCode(completion: @escaping (String?) -> Void) {
+ public func fetchCode() async -> String? {
guard let delegate = delegate else {
- self.installQueue.async { completion(nil) }
- return
- }
- delegate.fetchCode { code in
- self.installQueue.async {
- completion(code)
- }
+ return nil
}
+ return await delegate.fetchCode()
}
}
diff --git a/SupersignCLISupport/Sources/SupersignCLISupport/DSCommand.swift b/SupersignCLISupport/Sources/SupersignCLISupport/DSCommand.swift
index 91ee68d..62645da 100644
--- a/SupersignCLISupport/Sources/SupersignCLISupport/DSCommand.swift
+++ b/SupersignCLISupport/Sources/SupersignCLISupport/DSCommand.swift
@@ -25,11 +25,11 @@ private extension AuthToken {
throw Console.Error("A non-empty password is required.")
}
- let provider = SupersetteDataProvider(deviceInfo: deviceInfo)
-// let provider = try ADIDataProvider.supersetteProvider(
-// deviceInfo: deviceInfo,
-// storage: SupersignCLI.config.storage
-// )
+// let provider = SupersetteDataProvider(deviceInfo: deviceInfo)
+ let provider = try ADIDataProvider.omnisetteProvider(
+ deviceInfo: deviceInfo,
+ storage: SupersignCLI.config.storage
+ )
if resetProvisioning {
await provider.resetProvisioning()
}
@@ -90,10 +90,10 @@ struct DSTeamsListCommand: AsyncParsableCommand {
func run() async throws {
let deviceInfo = try DeviceInfo.fetch()
- let anisetteProvider = SupersetteDataProvider(deviceInfo: deviceInfo)
-// let anisetteProvider = try ADIDataProvider.supersetteProvider(
-// deviceInfo: deviceInfo, storage: SupersignCLI.config.storage
-// )
+// let anisetteProvider = SupersetteDataProvider(deviceInfo: deviceInfo)
+ let anisetteProvider = try ADIDataProvider.omnisetteProvider(
+ deviceInfo: deviceInfo, storage: SupersignCLI.config.storage
+ )
let token = try await AuthToken.retrieve(deviceInfo: deviceInfo, account: account)
let client = DeveloperServicesClient(
@@ -112,14 +112,13 @@ struct DSTeamsListCommand: AsyncParsableCommand {
}
struct DSAnisetteCommand: AsyncParsableCommand {
- private class Provider: RawADIProvider {
- func startProvisioning(spim: Data) -> (String, Data) {
+ private class Provider: RawADIProvider, RawADIProvisioningSession {
+ func startProvisioning(spim: Data, userID: UUID) -> (RawADIProvisioningSession, Data) {
print("spim: \(spim.base64EncodedString())")
- return ("", Data(base64Encoded: Console.prompt("cpim: ")!)!)
+ return (self, Data(base64Encoded: Console.prompt("cpim: ")!)!)
}
func endProvisioning(
- session: String,
routingInfo: UInt64,
ptm: Data,
tk: Data
@@ -132,7 +131,11 @@ struct DSAnisetteCommand: AsyncParsableCommand {
return Data(base64Encoded: Console.prompt("pinfo: ")!)!
}
- func requestOTP(provisioningInfo: Data) -> (machineID: Data, otp: Data) {
+ func requestOTP(
+ userID: UUID,
+ routingInfo: inout UInt64,
+ provisioningInfo: Data
+ ) -> (machineID: Data, otp: Data) {
print("otp; pinfo: \(provisioningInfo)")
return (Data(), Data())
}
diff --git a/SupersignCLISupport/Sources/SupersignCLISupport/SupersignCLIDelegate.swift b/SupersignCLISupport/Sources/SupersignCLISupport/SupersignCLIDelegate.swift
index b5ca601..f8af46b 100644
--- a/SupersignCLISupport/Sources/SupersignCLISupport/SupersignCLIDelegate.swift
+++ b/SupersignCLISupport/Sources/SupersignCLISupport/SupersignCLIDelegate.swift
@@ -1,13 +1,13 @@
import Foundation
import Supersign
-private func _fetchCode(completion: @escaping (String?) -> Void) {
- completion(Console.prompt("Code: "))
+private func _fetchCode() async -> String? {
+ Console.prompt("Code: ")
}
final class SupersignCLIAuthDelegate: TwoFactorAuthDelegate {
- func fetchCode(completion: @escaping (String?) -> Void) {
- _fetchCode(completion: completion)
+ func fetchCode() async -> String? {
+ await _fetchCode()
}
}
@@ -23,8 +23,8 @@ final class SupersignCLIDelegate: IntegratedInstallerDelegate, TwoFactorAuthDele
self.completion = completion
}
- func fetchCode(completion: @escaping (String?) -> Void) {
- _fetchCode(completion: completion)
+ func fetchCode() async -> String? {
+ await _fetchCode()
}
func fetchTeam(fromTeams teams: [DeveloperServicesTeam], completion: @escaping (DeveloperServicesTeam?) -> Void) {