fix: repair the SMS 2FA flow (active 412 challenge and -22979/-22981 throttling) - #9
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes edge cases in the Apple SMS 2FA flow by correctly handling “active SMS challenge” (HTTP 412) and SMS throttling service errors (-22979/-22981), while avoiding a hard-coded trusted phone number ID by requiring selection from the retrieved trusted numbers.
Changes:
- Add strict classification for SMS send responses to treat HTTP 412 as an already-active SMS challenge when the response matches expected
hsa2+ selected number + unlocked 6-digit code constraints. - Preserve and route throttling service errors
-22979/-22981to SMS code entry (NeedsSMS2FAVerification(id)) without losing the selected number or triggering a resend. - Add contract-style unit tests for SMS send response classification and run
cargo test -p isideloadin CI.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| isideload/src/auth/apple_account.rs | Improves SMS 2FA send error handling/classification, preserves selected phone number across throttling, adds tests, and removes hard-coded trusted number selection. |
| .github/workflows/build.yml | Adds CI coverage for isideload tests to catch regressions in the auth flow. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| info!( | ||
| "The most recently attempted 2FA Method failed, please try a different method." | ||
| ); |
…throttling) - Classify a 412 response carrying an active SMS challenge instead of aborting, so the user can enter the code that was already sent. - Map -22979/-22981 (throttling) to NeedsSMS2FAVerification(id), keeping the selected number and last_error, without triggering another send. - Keep -28248 mapped to NeedsUnknown2FA (choose another method). - Stop hardcoding phone number ID 1: load the trusted phone numbers. - Add the sms_send_response_tests contract tests and a cargo test CI step.
e0a5f07 to
f560857
Compare
The 2FA bridge only handled SubmitCode; isideload also requires SendSms, SendToDevices, ResendCode and Abort. - Tauri backend: a typed async request_two_factor_response exchanging TwoFactorCallbackParams/Response over the 2fa-required/2fa-response events, with a timeout and a clean Abort path. - UI: trusted-method and trusted-number pickers, resend code, send to devices, last_error display, and associated styles. - EN/FR locales for the new strings. - Parsing tests for all TwoFactorCallbackResponse variants. Depends on nab138/isideload#9 (the isideload-side 2FA logic).
|
Tested this end-to-end on Linux and can confirm it fixes the 412 SMS 2FA failure. Setup: built iloader v2.3.1 from source with isideload pointed at this branch (commit f560857), together with the matching frontend changes from nab138/iloader#607. Account state: Apple ID with SMS 2FA whose trusted phone number is flagged non-FTEU ( Before: iloader surfaced "SMS 2FA code submission failed with http status 412 Precondition Failed" and never showed the code input. After: the 412 is classified as an active challenge, the app proceeds straight to the SMS code entry screen, and submitting the code that arrived on the phone completes the login successfully. Caveat found during testing: for accounts where the previous 2FA attempt was marked failed, the flow lands in the |
|
Thanks for the thorough end-to-end testing @nfrhnh! Great to hear it resolves the 412 SMS 2FA flow. Your caveat about For maintainers (@nab138): once isideload#9 is merged, I can immediately update |
|
See my comment in nab138/iloader#607 |
Problem
The SMS 2FA flow fails (reported in nab138/iloader#319):
send_sms_2fatreats every non-2xx response withoutserviceErrorsas fatal. Two cases were mishandled:mode: sms, trusted number, no lockout flags), but the request aborted instead of moving on to code entry.-22979/-22981("Too many verification codes…") — routed toNeedsUnknown2FA, which loses the selected phone number and forbidsSubmitCode/ResendCode. Yet-22979explicitly says "Enter the last code you received": a code was already sent and stays valid.In addition, the phone number ID was hardcoded to
1instead of loading the trusted phone numbers.Fix
classify_sms_send_response): checksmode,authenticationType: hsa2, matching phone-number id, code length 6, and no lockout flags →SmsSendOutcome::ActiveChallenge(proceeds to verification).-22979/-22981→NeedsSMS2FAVerification(id)withlast_error, keeping the selected number and without triggering another send.-28248→ kept asNeedsUnknown2FA(choose another method).1.Tests
sms_send_response_tests(10 contract tests: active challenge, wrong number, malformed response, lockout flags, preserved service errors).cargo test -p isideloadto CI.cargo test -p isideload: 10/10 passing.Real-world verification
Tested end-to-end with iloader (v2.3.1 + this isideload): at
-22979, the UI shows the code-entry field with the selected number kept; a code generated from a trusted device completes the login. ✅Fixes nab138/iloader#319