/** * Segmented OTP / one-time-code fill for the DEBUG browser (2026-10). * * Real OTP widgets are N sibling inputs (usually `maxlength="1"`, * `inputmode="numeric"`, sometimes `autocomplete="new-password"`) plus a * sensor that auto-submits when the last digit lands. Typing the whole code * into ONE cell therefore fails `TYPE_NOT_VERIFIED`, and retrying without * clearing appends into populated cells until the site rate-limits the run * ("Too many invalid OTP attempts"). * * `fillOtp` detects the group by SHAPE (N visible single-char inputs, never * by autocomplete alone), clears every cell and verifies empty, types one * digit per cell with real key events, re-reads values after each insert, * and only submits when the widget did NOT auto-submit itself. */ import { type CdpPage } from './cdp'; export interface OtpGroupInfo { /** Number of digit cells in the group. */ length: number; /** Tag names of the cells (diagnostics only). */ tags: string[]; /** True when the cells sit inside a dialog/modal. */ modal: boolean; } export interface FillOtpOptions { /** The code digits (non-digit chars are stripped). */ code: string; /** Expected length; when set and mismatched the call is refused loudly. */ digits?: number; /** * Submit behaviour. `auto` (default) clicks submit only when the widget * did NOT navigate/auto-submit after the last digit. `always` clicks, * `never` leaves the form for the site sensor or a later step. */ submit?: 'auto' | 'always' | 'never'; } export interface FillOtpResult { ok: boolean; filled: number; expected: number; /** The per-cell values observed after filling (lengths only downstream). */ values: string[]; autoSubmitted: boolean; submitted: boolean; modal: boolean; visibleError?: string; error?: string; detail?: string; } export declare function detectOtpGroup(page: CdpPage): Promise<(OtpGroupInfo & { values: string[]; }) | null>; /** * Fill a segmented OTP widget digit-by-digit. * * Never types into a populated cell: every cell is cleared and verified * empty first. After the last digit the page gets a short settle window so * an auto-submit sensor (navigation / loading state) can fire before the * caller decides whether to click submit itself. */ export declare function fillOtpGroup(page: CdpPage, opts: FillOtpOptions): Promise;