Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.
Improve GrandSlam auth error messages
kabiroberai79335148b044
diff --git a/Supersign/GrandSlam/Operations/GrandSlamAuthenticateOperation.swift b/Supersign/GrandSlam/Operations/GrandSlamAuthenticateOperation.swiftindex 8236b4e..37849b6 100644--- a/Supersign/GrandSlam/Operations/GrandSlamAuthenticateOperation.swift+++ b/Supersign/GrandSlam/Operations/GrandSlamAuthenticateOperation.swift@@ -10,11 +10,26 @@ import Foundationclass GrandSlamAuthenticateOperation {- enum Error: Swift.Error {- case failedChallenge- case invalidSession- case invalidResponse+ enum Error: Swift.Error, LocalizedError {+ case internalErrorcase failedSecondaryAuth++ var errorDescription: String? {+ switch self {+ case .internalError:+ return NSLocalizedString(+ "apple_id_auth.error.internal",+ value: "An internal authentication error occurred.",+ comment: ""+ )+ case .failedSecondaryAuth:+ return NSLocalizedString(+ "apple_id_auth.error.failed_secondary_auth",+ value: "Could not complete 2-factor authentication.",+ comment: ""+ )+ }+ }}private struct Response: Decodable {@@ -84,10 +99,10 @@ class GrandSlamAuthenticateOperation {srpClient.add(string: "|")guard srpClient.verify(hamk: completeResponse.hamk) && srpClient.verify(negProto: completeResponse.negProto)- else { return completion(.failure(Error.invalidSession)) }+ else { return completion(.failure(Error.internalError)) }guard let rawLoginResponse = srpClient.decrypt(cbc: completeResponse.encryptedResponse) else {- return completion(.failure(Error.invalidResponse))+ return completion(.failure(Error.internalError))}let response: Response@@ -134,7 +149,7 @@ class GrandSlamAuthenticateOperation {serverPublicKey: initResponse.serverPublicKey,isS2K: isS2K)- guard let m1Data = mDataRaw else { return completion(.failure(Error.failedChallenge)) }+ guard let m1Data = mDataRaw else { return completion(.failure(Error.internalError)) }let completeRequest = GrandSlamAuthCompleteRequest(username: username, cookie: initResponse.cookie, m1Data: m1Datadiff --git a/Supersign/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swift b/Supersign/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swiftindex fd96921..bd4fb17 100644--- a/Supersign/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swift+++ b/Supersign/GrandSlam/Operations/GrandSlamTwoFactorAuthenticateOperation.swift@@ -69,10 +69,9 @@ class GrandSlamTwoFactorAuthenticateOperation {func perform(completion: @escaping (Result<(), Swift.Error>) -> Void) {switch mode {case .secondaryAuth:- // TODO: Does this always work?- // we *should* be calling performSecondaryAuth but that doesn't seem- // to actually trigger the 2fa prompt on trusted devices. Somehow- // using trustedDevice auth seems to work fine though+ // TODO: We *should* be calling performSecondaryAuth – it does+ // seem like performTrustedDeviceAuth sometimes works here but+ // other times re-authenticating continues to 409self.performTrustedDeviceAuth(completion: completion)case .trustedDeviceSecondaryAuth:self.performTrustedDeviceAuth(completion: completion)