mirror of
https://github.com/xtool-org/xtool.git
synced 2026-11-21 02:41:46 +03:00
Support static GSA endpoints
This commit is contained in:
@@ -174,7 +174,7 @@ public final class ADIDataProvider: AnisetteDataProvider {
|
||||
cpim: Data
|
||||
) async throws -> (routingInfo: UInt64, provisioningInfo: Data) {
|
||||
let resp: EndProvisioningResponse = try await sendRequest(
|
||||
endpoint: \.midFinishProvisioning,
|
||||
endpoint: .lookup(\.midFinishProvisioning),
|
||||
request: EndProvisioningRequest(cpim: cpim.base64EncodedString())
|
||||
)
|
||||
|
||||
@@ -192,7 +192,7 @@ public final class ADIDataProvider: AnisetteDataProvider {
|
||||
|
||||
private func provision() async throws -> (routingInfo: UInt64, provisioningInfo: Data) {
|
||||
let resp: StartProvisioningResponse = try await sendRequest(
|
||||
endpoint: \.midStartProvisioning,
|
||||
endpoint: .lookup(\.midStartProvisioning),
|
||||
request: StartProvisioningRequest()
|
||||
)
|
||||
guard let spim = Data(base64Encoded: resp.spim) else { throw ADIError.badStartResponse }
|
||||
|
||||
@@ -17,4 +17,7 @@ struct GrandSlamEndpoints: Decodable {
|
||||
let midFinishProvisioning: String
|
||||
}
|
||||
|
||||
typealias GrandSlamEndpoint = KeyPath<GrandSlamEndpoints, String>
|
||||
enum GrandSlamEndpoint {
|
||||
case lookup(KeyPath<GrandSlamEndpoints, String>)
|
||||
case url(URL)
|
||||
}
|
||||
|
||||
@@ -58,8 +58,13 @@ class GrandSlamLookupManager {
|
||||
}
|
||||
|
||||
func fetchURL(forEndpoint endpoint: GrandSlamEndpoint) async throws -> URL {
|
||||
let endpoints = try await fetchEndpoints()
|
||||
return URL(string: endpoints[keyPath: endpoint])!
|
||||
switch endpoint {
|
||||
case .lookup(let keyPath):
|
||||
let endpoints = try await fetchEndpoints()
|
||||
return URL(string: endpoints[keyPath: keyPath])!
|
||||
case .url(let url):
|
||||
return url
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ struct GrandSlamTrustedDeviceRequest: GrandSlamTwoFactorRequest {
|
||||
static func decode(data: Data) throws {}
|
||||
}
|
||||
|
||||
static let endpoint: GrandSlamEndpoint = \.trustedDeviceSecondaryAuth
|
||||
static let endpoint: GrandSlamEndpoint = .lookup(\.trustedDeviceSecondaryAuth)
|
||||
|
||||
let loginData: GrandSlamLoginData
|
||||
}
|
||||
@@ -25,7 +25,7 @@ struct GrandSlamSecondaryAuthRequest: GrandSlamTwoFactorRequest {
|
||||
}
|
||||
}
|
||||
|
||||
static let endpoint: GrandSlamEndpoint = \.secondaryAuth
|
||||
static let endpoint: GrandSlamEndpoint = .lookup(\.secondaryAuth)
|
||||
|
||||
let loginData: GrandSlamLoginData
|
||||
}
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ struct GrandSlamValidateRequest: GrandSlamTwoFactorRequest {
|
||||
static func decode(data: Data) throws {}
|
||||
}
|
||||
|
||||
static let endpoint: GrandSlamEndpoint = \.validateCode
|
||||
static let endpoint: GrandSlamEndpoint = .lookup(\.validateCode)
|
||||
|
||||
let loginData: GrandSlamLoginData
|
||||
let verificationCode: String
|
||||
|
||||
@@ -67,7 +67,7 @@ protocol GrandSlamOperationRequest: GrandSlamRequest
|
||||
|
||||
extension GrandSlamOperationRequest {
|
||||
|
||||
static var endpoint: GrandSlamEndpoint { \.gsService }
|
||||
static var endpoint: GrandSlamEndpoint { .lookup(\.gsService) }
|
||||
|
||||
func configure(request: inout HTTPRequest, deviceInfo: DeviceInfo, anisetteData: AnisetteData) {
|
||||
request.headers["Accept"] = "*/*"
|
||||
|
||||
Reference in New Issue
Block a user