Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.
gsa: more SMS 2FA fixes (#416)
Kabir Oberai2186b7238308
diff --git a/Sources/XKit/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swift b/Sources/XKit/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swiftindex 6fc7079..5a41e02 100644--- a/Sources/XKit/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swift+++ b/Sources/XKit/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swift@@ -27,7 +27,7 @@ struct GrandSlamTwoFactorAuthenticateOperation {private func performSMSAuth() async throws {// TODO: parse phone number list from o=complete req?- let phoneNumberID = "1"+ let phoneNumberID = 1do {try await client.send(GrandSlamSMSAuthRequest(loginData: loginData, phoneNumberID: phoneNumberID))} catch let error as HTTPResponseError where error.status.code == 403 {@@ -40,7 +40,7 @@ struct GrandSlamTwoFactorAuthenticateOperation {try await validateCode(phoneNumberID: phoneNumberID)}- private func validateCode(phoneNumberID: String? = nil) async throws {+ private func validateCode(phoneNumberID: Int? = nil) async throws {guard let code = await self.delegate.fetchCode() else { throw Error.userCancelled }let request: any GrandSlamRequest = if let phoneNumberID {GrandSlamValidateSMSRequest(diff --git a/Sources/XKit/GrandSlam/Requests/Concrete/GrandSlamTrustedDeviceRequest.swift b/Sources/XKit/GrandSlam/Requests/Concrete/GrandSlamTrustedDeviceRequest.swiftindex 1cf55c4..628ba9f 100644--- a/Sources/XKit/GrandSlam/Requests/Concrete/GrandSlamTrustedDeviceRequest.swift+++ b/Sources/XKit/GrandSlam/Requests/Concrete/GrandSlamTrustedDeviceRequest.swift@@ -35,16 +35,22 @@ struct GrandSlamSMSAuthRequest: GrandSlamTwoFactorRequest {static func decode(data: Data) throws {}}- static let endpoint: GrandSlamEndpoint = .url(URL(string: "https://gsa.apple.com/auth/verify/phone/put?mode=sms")!)+ static let endpoint: GrandSlamEndpoint = .url(URL(string: "https://gsa.apple.com/auth/verify/phone")!)let loginData: GrandSlamLoginData- let phoneNumberID: String+ let phoneNumberID: Int++ var extraHeaders: [String: String] {+ [+ "Content-Type": "application/json",+ "Accept": "application/json",+ ]+ }func content(anisetteData: AnisetteData) -> GrandSlamRequestContent {- .post([- "serverInfo": [- "phoneNumber.id": phoneNumberID- ],- ])+ .put([+ "phoneNumber": ["id": phoneNumberID],+ "mode": "sms",+ ], type: .json)}}diff --git a/Sources/XKit/GrandSlam/Requests/Concrete/GrandSlamValidateRequest.swift b/Sources/XKit/GrandSlam/Requests/Concrete/GrandSlamValidateRequest.swiftindex 72a697a..b93c614 100644--- a/Sources/XKit/GrandSlam/Requests/Concrete/GrandSlamValidateRequest.swift+++ b/Sources/XKit/GrandSlam/Requests/Concrete/GrandSlamValidateRequest.swift@@ -29,20 +29,25 @@ struct GrandSlamValidateSMSRequest: GrandSlamTwoFactorRequest {}static let endpoint: GrandSlamEndpoint = .url(URL(- string: "https://gsa.apple.com/auth/verify/phone/securitycode?referrer=/auth/verify/phone/put"+ string: "https://gsa.apple.com/auth/verify/phone/securitycode")!)let loginData: GrandSlamLoginData- let phoneNumberID: String+ let phoneNumberID: Intlet verificationCode: String+ var extraHeaders: [String: String] {+ [+ "Content-Type": "application/json",+ "Accept": "application/json",+ ]+ }+func content(anisetteData: AnisetteData) -> GrandSlamRequestContent {.post([- "securityCode.code": verificationCode,- "serverInfo": [- "mode": "sms",- "phoneNumber.id": phoneNumberID- ]- ])+ "securityCode": ["code": verificationCode],+ "phoneNumber": ["id": phoneNumberID],+ "mode": "sms",+ ], type: .json)}}