Phone Verification Controller
Sequences PhoneNumberVerificationHandler calls and exposes the result as a single observable PhoneVerificationState.
This is where the rules that are easy to get wrong live:
only a number with PhoneNumberValue.isValid can start verification;
a request in flight blocks a second one, so double-tapping "Send code" sends one SMS;
resend is refused until the handler's cooldown elapses;
editing the number invalidates any verification already obtained — see onPhoneNumberChanged.
The controller is UI-framework-agnostic apart from holding its state in a Compose mutableStateOf; it contains no composables and can be driven from a ViewModel just as easily. Every method is suspend and does its work on the caller's dispatcher — nothing here blocks the main thread, and no coroutine is launched internally, so cancellation is the caller's to control.
Constructors
Functions
True when phoneNumber is the number that was successfully verified.
Tells the controller the field's number changed.
Starts verification for phoneNumber.
Seconds remaining before a resend is allowed; 0 when it is allowed now.
Re-sends the code for the active challenge.
Submits code against the active challenge.