Documentation
¶
Overview ¶
Package wapair drives the WhatsApp Web QR pairing flow.
It is the WhatsApp counterpart to internal/devicecode: a small, UI-agnostic driver that both `forge channel whatsapp-login` and the init wizard's channel step use, so the pairing state machine lives in exactly one place.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QRDimensions ¶
QRDimensions reports the rows and columns RenderQR needs for code, so a caller can warn before drawing something the terminal will wrap into unscannable noise.
func RenderQR ¶
RenderQR writes code as a scannable QR block.
Half-block rendering keeps the code square in a terminal whose cells are taller than they are wide; a full-block render is stretched and many phones fail to lock onto it. QuietZone is 1 rather than qrterminal's default 4 — the standard 4-module margin costs 6 rows and 6 columns, which is the difference between fitting and not fitting in a typical 80x30 terminal. Phones scan reliably at 1 against a contrasting terminal background.
Types ¶
type Event ¶
type Event struct {
Kind EventKind
Code string // EventQR: the raw payload to encode
Timeout time.Duration // EventQR: how long until the next code
JID string // EventPaired: the linked account
Err error // EventError
}
Event is one step of the pairing flow.
type EventKind ¶
type EventKind int
EventKind discriminates the events a pairing session emits.
const ( // EventQR carries a new code to display. WhatsApp rotates codes every // ~20s, so several of these arrive before the user finishes scanning. EventQR EventKind = iota // EventScanned means the phone accepted the code and the post-pair // handshake is running. NOT yet usable — EventPaired is the completion. EventScanned // EventPaired means the scan succeeded and the session is persisted. EventPaired // EventError is terminal: the session cannot complete. EventError )
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is an in-flight pairing attempt. Close it when done — it holds an open socket and a SQLite handle.
func Start ¶
Start opens (creating if absent) the session store at sessionPath and begins a pairing attempt. Events are delivered on Events() until the channel closes.
The caller owns the returned Session and must Close it.
func (*Session) Events ¶
Events returns the pairing event stream. It closes when the flow reaches a terminal state.
func (*Session) SessionPath ¶
SessionPath is where the pairing is persisted.