Account access and session security
ZapFast links one or more WhatsApp accounts to the desktop and keeps each account's device session, message history, preferences, and cached media separate. It also protects the shared window with account privacy controls, safe external actions, and an optional app lock. See Application shell, Navigation and accessibility, and Settings and theming for the surrounding desktop experience.
Account model
An account is one linked WhatsApp number with its own live connection and local data. The application shell shows one active account at a time while the account switcher provides access to all linked numbers.
Linked accounts
The account switcher lists each linked number with its name, unread chat count, current selection, and notification state. An engineer can use it to change accounts, add another account, or mute notifications for one account without changing the others. Each account has its own archive, settings, backend connection, and folders.
References: src/account.rs• L1-5 src/account.rs• L21-36 src/…/accounts.rs• L89-129 src/…/accounts.rs• L133-173
Account removal
Account removal starts as an explicit user action from the account or login view. Unlinking tells WhatsApp to remove this computer, clears the account's live session state, and returns the account to a new-link state.
References: src/…/accounts.rs• L367-411 src/app.rs• L9958-9961 src/…/worker.rs• L4705-4746
Device linking
Device linking connects a local account slot to a WhatsApp account on a phone. The flow keeps the account in a linking state until WhatsApp confirms the pair and then changes to chat synchronization.
QR linking
The QR flow asks the user to open WhatsApp's Linked devices screen and scan the code shown by ZapFast. The code is refreshed when WhatsApp stops accepting the current set, so an expired code does not leave the user on a permanent waiting screen.
References: src/…/login.rs• L157-179 src/…/login.rs• L206-252 src/…/worker.rs• L4049-4055 src/…/worker.rs• L4078-4089
Phone-number linking
The phone-number flow is an alternative to scanning a QR code. The user enters a phone number with its country code, receives a short pairing code, and enters that code in WhatsApp's Linked devices flow.
References: src/…/login.rs• L241-250 src/…/login.rs• L254-315 src/app.rs• L9948-9956 src/…/worker.rs• L4056-4076 src/…/worker.rs• L8804-8827
Link lifecycle
The account moves through connection, linking, synchronization, disconnection, and logged-out states. A successful pair clears the temporary QR or pairing code and starts the connection; a phone-side unlink removes the local device session and requests a new link.
flowchart LR
A[Unlinked account] --> B[QR or phone pairing code]
B --> C[Phone confirms link]
C --> D[Connecting and syncing]
D --> E[Connected account]
E --> F[Disconnected]
F --> D
E --> G[Phone unlinks computer]
G --> A
References: src/…/login.rs• L84-179 src/…/worker.rs• L2398-2420 src/…/worker.rs• L4092-4107 src/…/worker.rs• L4711-4746
Privacy controls
Privacy controls describe what the linked WhatsApp account shares with other people. They are account-level values held by the phone, not ordinary desktop preferences, so ZapFast only enables editing after it has a current successful snapshot.
Account privacy
The Privacy section covers last seen, online status, profile photo, About, group adds, read receipts, and calls. ZapFast shows values such as Everyone, My contacts, Nobody, or Silence unknown callers when the phone reports them. Exclusion lists remain managed on the phone.
References: src/privacy.rs• L1-7 src/privacy.rs• L16-79 src/…/settings.rs• L575-665
Read and typing signals
Read receipts and typing status have local account switches, but their effect still depends on the account privacy state on WhatsApp. A failed privacy fetch leaves the last shown values in place and prevents edits until a later connection succeeds.
References: src/settings.rs• L449-455 src/settings.rs• L824-862 src/privacy.rs• L172-247 src/…/settings.rs• L575-628
App lock
The app lock protects the whole desktop window from someone using the same computer. It is a screen lock rather than a replacement for archive encryption: it hides the interface and requires a local password before private content is shown again.
Lock behavior
The user can set the lock in Privacy settings and choose one minute, fifteen minutes, or one hour of inactivity. The lock can also be requested at once. While locked, ZapFast draws only the lock screen, suppresses private accessibility content, withdraws existing notifications, stops active media work, and prevents hidden shortcuts from reaching chats.
References: src/settings.rs• L323-351 src/settings.rs• L531-535 src/…/settings.rs• L919-987 src/…/mod.rs• L48-59 src/app.rs• L10566-10619
Unlock and recovery
The password is checked against a stored verifier and is never stored as plain text. Repeated wrong attempts add a short delay. A forgotten password has no local bypass: the recovery path unlinks every account protected by the lock and releases the lock only after WhatsApp confirms the unlink.
References: src/app_lock.rs• L1-9 src/app_lock.rs• L17-32 src/app_lock.rs• L34-88 src/app_lock.rs• L456-467 src/…/lock.rs• L47-115 src/app.rs• L9979-9988
Protected requests
Notifications and links that arrive while the app is locked are held until unlock instead of exposing their target. After a successful unlock, ZapFast switches to the correct account and replays the last protected request for that type.
References: src/app_lock.rs• L223-252 src/app.rs• L10621-10660 src/app.rs• L10663-10680
Safety and local data
Account security also depends on what ZapFast stores locally and what it allows external applications to open. The data layout separates durable account state from replaceable cache data, while boundary checks reject unsafe desktop handlers.
Local data paths
The application uses separate configuration, state, cache, and runtime locations. The account index records linked accounts and the active account; each account directory holds the device session, local archive, account settings, and account-specific caches.
| Data | Purpose |
|---|---|
| config/accounts.json | Linked account order and active account |
state/accounts/<id>/session.db | Linked-device session; deleting it unlinks the account |
state/accounts/<id>/archive.db | Local message archive |
| state/…/settings.json | Settings for that account |
cache/accounts/<id>/ | Replaceable media, avatar, and sticker caches |
The real root directories come from the platform. The application creates them with private permissions where the platform supports them, and cache cleanup does not remove the device session.
References: src/paths.rs• L1-19 src/paths.rs• L37-49 src/paths.rs• L89-107 src/paths.rs• L232-270 src/paths.rs• L289-301
External action safety
Messages can contain links and downloaded files that cross from WhatsApp data into the desktop. ZapFast accepts only approved web or mail schemes for external links and only known document or media types for direct opening; other files are shown in their folder instead of being launched.
References: src/safety.rs• L45-67 src/safety.rs• L173-218
Notification privacy
Notifications follow both the account notification setting and the global choice to show message content. When content is disabled, or when the app is locked, the notification contains only “New message” so the desktop does not reveal chat text outside the window.
References: src/settings.rs• L479-487 src/…/settings.rs• L517-532 src/app.rs• L2553-2572
Change checklist
When these files or sections are changed, remember to consider these:
- Keep account creation, switching, login choices, unlinking, and per-account storage in sync when changing the account model.
- Keep QR refresh, phone-number pairing, link status, and logged-out cleanup aligned when changing device-link behavior.
- Keep phone privacy categories, allowed values, stale-data handling, and Settings controls aligned when changing privacy support.
- Keep the lock screen, notification redaction, deferred requests, inactivity timer, and forgotten-password unlink path aligned when changing app-lock behavior.
- Keep session files, archive files, write-ahead logs, keyring handling, and cache migration aligned when changing local data paths.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| WhatsApp exhausts the current QR references | The old code cannot link the computer | Request a fresh linking client and QR set |
| The phone unlinks the computer | The account loses its local device session and returns to linking | Show the logged-out state and request a new code |
| The archive key is missing or invalid | Local history cannot be opened | Offer retry for recoverable keyring errors; offer start-over only for a lost key |
| The app-lock password is forgotten | The private window cannot be unlocked | Require unlinking the protected accounts before recovery |
| A privacy fetch fails | Shown privacy values may be stale and cannot be edited | Keep the values visible but disable edits until a fresh fetch |
| A link or attachment uses an unsupported scheme or type | The desktop action is rejected | Allow only approved URL schemes and file extensions |
Key files
| File | Why to read it |
|---|---|
| src/account.rs | Defines the per-account runtime boundary and account-local state |
| src/…/accounts.rs | Shows how users switch, add, mute, and remove accounts |
| src/…/login.rs | Describes the QR, pairing-code, and link-status views |
| src/…/worker.rs | Connects pairing events and unlink cleanup to account state |
| src/privacy.rs | Defines the account privacy model and phone synchronization rules |
| src/app_lock.rs | Defines password verification, backoff, inactivity, and recovery state |
| src/…/lock.rs | Shows the locked-window and forgotten-password experience |
| src/paths.rs | Defines durable account data, session files, archives, and caches |
| src/safety.rs | Defines the boundary for external links and file opening |
| src/app.rs | Coordinates lock actions, deferred requests, notifications, and unlinking |