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.

Some cleanup

Kabir Oberaif6cee5de5e3c
diff --git a/Sources/Supersign/DeveloperServices/DeveloperServices+OpenAPI.swift b/Sources/Supersign/DeveloperServices/DeveloperServices+OpenAPI.swift
index 8a2c0b7..ad720ef 100644
--- a/Sources/Supersign/DeveloperServices/DeveloperServices+OpenAPI.swift
+++ b/Sources/Supersign/DeveloperServices/DeveloperServices+OpenAPI.swift
@@ -74,16 +74,16 @@ public struct DeveloperAPIXcodeAuthMiddleware: ClientMiddleware {
private static let queryEncoder = JSONEncoder()
public func intercept(
- _ request: HTTPTypes.HTTPRequest,
- body: OpenAPIRuntime.HTTPBody?,
+ _ request: HTTPRequest,
+ body: HTTPBody?,
baseURL: URL,
operationID: String,
next: @Sendable (
- _ request: HTTPTypes.HTTPRequest,
- _ body: OpenAPIRuntime.HTTPBody?,
+ _ request: HTTPRequest,
+ _ body: HTTPBody?,
_ baseURL: URL
- ) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?)
- ) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) {
+ ) async throws -> (HTTPResponse, HTTPBody?)
+ ) async throws -> (HTTPResponse, HTTPBody?) {
var request = request
let deviceInfo = try deviceInfoProvider.fetch()
@@ -203,16 +203,16 @@ public struct DeveloperAPIASCAuthMiddleware: ClientMiddleware {
}
public func intercept(
- _ request: HTTPTypes.HTTPRequest,
- body: OpenAPIRuntime.HTTPBody?,
+ _ request: HTTPRequest,
+ body: HTTPBody?,
baseURL: URL,
operationID: String,
next: @Sendable (
- _ request: HTTPTypes.HTTPRequest,
- _ body: OpenAPIRuntime.HTTPBody?,
+ _ request: HTTPRequest,
+ _ body: HTTPBody?,
_ baseURL: URL
- ) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?)
- ) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) {
+ ) async throws -> (HTTPResponse, HTTPBody?)
+ ) async throws -> (HTTPResponse, HTTPBody?) {
let jwt = try await generator.generate()
var request = request
request.headerFields[.authorization] = "Bearer \(jwt)"
diff --git a/Sources/Supersign/GrandSlam/Operations/GrandSlamAuthenticateOperation.swift b/Sources/Supersign/GrandSlam/Operations/GrandSlamAuthenticateOperation.swift
index 365d016..a92ef02 100644
--- a/Sources/Supersign/GrandSlam/Operations/GrandSlamAuthenticateOperation.swift
+++ b/Sources/Supersign/GrandSlam/Operations/GrandSlamAuthenticateOperation.swift
@@ -8,9 +8,8 @@
import Foundation
import Crypto
-import _CryptoExtras
-class GrandSlamAuthenticateOperation {
+struct GrandSlamAuthenticateOperation {
enum Error: Swift.Error, LocalizedError {
case internalError
@@ -51,18 +50,6 @@ class GrandSlamAuthenticateOperation {
let password: String
unowned let twoFactorDelegate: TwoFactorAuthDelegate
- init(
- client: GrandSlamClient,
- username: String,
- password: String,
- twoFactorDelegate: TwoFactorAuthDelegate
- ) {
- self.client = client
- self.username = username
- self.password = password
- self.twoFactorDelegate = twoFactorDelegate
- }
-
private func authenticateTwoFactor(
mode: GrandSlamAuthMode?,
loginData: GrandSlamLoginData
diff --git a/Sources/Supersign/GrandSlam/Operations/GrandSlamFetchAppTokensOperation.swift b/Sources/Supersign/GrandSlam/Operations/GrandSlamFetchAppTokensOperation.swift
index 763da71..ae2d5d8 100644
--- a/Sources/Supersign/GrandSlam/Operations/GrandSlamFetchAppTokensOperation.swift
+++ b/Sources/Supersign/GrandSlam/Operations/GrandSlamFetchAppTokensOperation.swift
@@ -17,7 +17,7 @@ extension AppTokenKey {
static let xcode = AppTokenKey("com.apple.gs.xcode.auth")
}
-class GrandSlamFetchAppTokensOperation {
+struct GrandSlamFetchAppTokensOperation {
enum Error: Swift.Error {
case invalidResponse
@@ -45,23 +45,17 @@ class GrandSlamFetchAppTokensOperation {
}
}
- private let decoder = PropertyListDecoder()
+ private static let decoder = PropertyListDecoder()
let client: GrandSlamClient
let apps: [AppTokenKey]
let loginData: GrandSlamLoginData
- init(client: GrandSlamClient, apps: [AppTokenKey], loginData: GrandSlamLoginData) {
- self.client = client
- self.apps = apps
- self.loginData = loginData
- }
-
private func handle(
response: GrandSlamAppTokensRequest.Decoder.Value
) async throws -> [AppTokenKey: Token] {
let decrypted = try AppTokens.decrypt(gcm: response.encryptedToken, withSK: loginData.sk)
- let pairs = try decoder
+ let pairs = try Self.decoder
.decode(Response.self, from: decrypted)
.tokens
.map { (AppTokenKey($0), $1) }
diff --git a/Sources/Supersign/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swift b/Sources/Supersign/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swift
index 2d4131d..6299c41 100644
--- a/Sources/Supersign/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swift
+++ b/Sources/Supersign/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swift
@@ -12,7 +12,7 @@ public protocol TwoFactorAuthDelegate: AnyObject, Sendable {
func fetchCode() async -> String?
}
-class GrandSlamTwoFactorAuthenticateOperation {
+struct GrandSlamTwoFactorAuthenticateOperation {
enum Error: Swift.Error {
case incorrectVerificationCode
@@ -23,17 +23,6 @@ class GrandSlamTwoFactorAuthenticateOperation {
let mode: GrandSlamAuthMode?
let loginData: GrandSlamLoginData
unowned let delegate: TwoFactorAuthDelegate
- init(
- client: GrandSlamClient,
- mode: GrandSlamAuthMode?,
- loginData: GrandSlamLoginData,
- delegate: TwoFactorAuthDelegate
- ) {
- self.client = client
- self.mode = mode
- self.loginData = loginData
- self.delegate = delegate
- }
private func performSMSAuth() async throws {
// TODO: parse phone number list from o=complete req?
diff --git a/Sources/Supersign/HTTPClientProtocol/HTTPClientProtocol.swift b/Sources/Supersign/HTTPClientProtocol/HTTPClientProtocol.swift
index 76aa7b0..2e90522 100644
--- a/Sources/Supersign/HTTPClientProtocol/HTTPClientProtocol.swift
+++ b/Sources/Supersign/HTTPClientProtocol/HTTPClientProtocol.swift
@@ -41,7 +41,7 @@ extension HTTPClientProtocol {
public func makeRequest(
_ request: HTTPRequest,
body: Data? = nil,
- onProgress: sending @isolated(any) (Double?) -> Void = { _ in }
+ onProgress: @isolated(any) (Double?) -> Void = { _ in }
) async throws -> (response: HTTPResponse, body: Data) {
await onProgress(0)
let (response, body) = try await send(request, body: body.map { HTTPBody($0) })
@@ -67,12 +67,12 @@ private struct UnimplementedHTTPClient: HTTPClientProtocol, ClientTransport {
public var asOpenAPITransport: ClientTransport { self }
func send(
- _ request: HTTPTypes.HTTPRequest,
- body: OpenAPIRuntime.HTTPBody?,
+ _ request: HTTPRequest,
+ body: HTTPBody?,
baseURL: URL,
operationID: String
- ) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) {
- let closure: (HTTPTypes.HTTPRequest, OpenAPIRuntime.HTTPBody?, URL, String) async throws -> (HTTPTypes.HTTPResponse, OpenAPIRuntime.HTTPBody?) = unimplemented()
+ ) async throws -> (HTTPResponse, HTTPBody?) {
+ let closure: (HTTPRequest, HTTPBody?, URL, String) async throws -> (HTTPResponse, HTTPBody?) = unimplemented()
return try await closure(request, body, baseURL, operationID)
}
diff --git a/Sources/Supersign/HTTPClientProtocol/URLSession+HTTP.swift b/Sources/Supersign/HTTPClientProtocol/URLSession+HTTP.swift
index 1663392..74527bf 100644
--- a/Sources/Supersign/HTTPClientProtocol/URLSession+HTTP.swift
+++ b/Sources/Supersign/HTTPClientProtocol/URLSession+HTTP.swift
@@ -18,7 +18,7 @@ extension HTTPClientDependencyKey: DependencyKey {
public static let liveValue: HTTPClientProtocol = Client()
}
-private final class Client: HTTPClientProtocol {
+private struct Client: HTTPClientProtocol {
final class ClientDelegate: NSObject, URLSessionWebSocketDelegate {
let webSocketCallbacks = LockIsolated<[
URLSessionWebSocketTask: @Sendable (URLSessionWebSocketTask.CloseCode?) -> Void
diff --git a/Sources/Supersign/Model/Mobileprovision.swift b/Sources/Supersign/Model/Mobileprovision.swift
index c68e9c4..803335f 100644
--- a/Sources/Supersign/Model/Mobileprovision.swift
+++ b/Sources/Supersign/Model/Mobileprovision.swift
@@ -9,7 +9,7 @@
import Foundation
import CSupersign
-public final class Mobileprovision: Decodable, @unchecked Sendable {
+public final class Mobileprovision: @unchecked Sendable {
public enum Error: Swift.Error {
case invalidProfile
@@ -39,24 +39,11 @@ public final class Mobileprovision: Decodable, @unchecked Sendable {
let raw: mobileprovision_t
- private static func mobileprovision(from data: Data) -> mobileprovision_t? {
- data.withUnsafeBytes {
+ public init(data: Data) throws {
+ guard let profile: mobileprovision_t = data.withUnsafeBytes({
guard let base = $0.baseAddress else { return nil }
return mobileprovision_create_from_data(base, $0.count)
- }
- }
-
- public init(data: Data) throws {
- guard let profile = Self.mobileprovision(from: data) else {
- throw Error.invalidProfile
- }
- self.raw = profile
- }
-
- public required init(from decoder: Decoder) throws {
- let container = try decoder.singleValueContainer()
- let data = try container.decode(Data.self)
- guard let profile = Self.mobileprovision(from: data) else {
+ }) else {
throw Error.invalidProfile
}
self.raw = profile