Skip to content

Commit f55a2f8

Browse files
Update Authentication.swift
Signed-off-by: Mr3242-Scripter <dastan20211@gmail.com>
1 parent f112e99 commit f55a2f8

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

‎Sources/DeveloperPortal/Authentication.swift‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,25 @@ public extension DeveloperPortal {
219219
verificationHandler: verificationHandler,
220220
codeAlreadySent: pushedCode
221221
)
222+
// SideInstaller: after 2FA, login again. Refresh client-info + client time
223+
// so the post-code GrandSlam request isn't refused with HTTP 503.
224+
var post2FAAnisette = anisetteData
225+
let advertised = post2FAAnisette.clientInfo
226+
if advertised.contains("10.12") || advertised.isEmpty || advertised.contains("Android") {
227+
post2FAAnisette.clientInfo = "<MacBookPro18,3> <macOS;26.6;25F84> <com.apple.AuthKit/1 (com.apple.akd/1.0)>"
228+
post2FAAnisette.userAgent = "AuthKit/1 (Macintosh; OS X 26.6) (com.apple.akd/1.0)"
229+
}
230+
// Fresh client time (ISO8601) — stale time contributes to 503 refusals
231+
let formatter = ISO8601DateFormatter()
232+
formatter.formatOptions = [.withInternetDateTime]
233+
post2FAAnisette.clientTime = formatter.string(from: Date())
234+
// Brief pause so Apple accepts the verified session before re-login
235+
try await Task.sleep(nanoseconds: 1_500_000_000)
222236
return try await PushedCodeState.$handled.withValue(PushedCodeState.handled || pushedCode) {
223237
try await authenticate(
224238
appleID: unsanitizedAppleID,
225239
password: password,
226-
anisetteData: anisetteData,
240+
anisetteData: post2FAAnisette,
227241
xcodeVersion: xcodeVersion,
228242
machinePassword: machinePassword,
229243
accountRepairHandler: accountRepairHandler,
@@ -373,7 +387,7 @@ public extension DeveloperPortal {
373387
}
374388

375389
// SideInstaller: retry HTTP 429 / 503 with spaced backoff
376-
let retryDelays: [UInt64] = [2_000_000_000, 5_000_000_000] // 2s, 5s
390+
let retryDelays: [UInt64] = [2_000_000_000, 5_000_000_000, 10_000_000_000, 15_000_000_000] // 2s, 5s, 10s, 15s — SideInstaller-style 503 backoff
377391
var data = Data()
378392
var response: URLResponse = URLResponse(url: Constants.URLs.grandSlamAuth, mimeType: nil, expectedContentLength: 0, textEncodingName: nil)
379393
var statusCode = 0
@@ -403,7 +417,7 @@ public extension DeveloperPortal {
403417
let rawStr = String(data: data, encoding: .utf8) ?? data.hexEncodedString()
404418
debugLog("[SideSign] GrandSlam still HTTP \(statusCode) after retries: \(rawStr.prefix(200))")
405419
throw ServerError.badServerResponse(
406-
reason: "Apple sign-in refused the request (HTTP \(statusCode)). Try a Windows anisette server and sign in again.",
420+
reason: "Apple returned HTTP \(statusCode) after 2FA (temporary refuse). Wait a minute, Reset adi.pb, use jkcoxson/Mac anisette, and try again.",
407421
jsonPayload: rawStr
408422
)
409423
}

0 commit comments

Comments
 (0)