Files
Dhruv Sharma 400d013465 feat(remote): per-device tokens and one-time pairing codes (#8081)
* fix(httpd): count failed remote logins per IPv6 /64

The lockout keyed on the exact source address, so a client holding an IPv6
/64 could rotate addresses and never hit the 5-failure limit.

* fix(httpd): cap the retired password hash list

Each password rotation appended to the retired list and nothing removed
entries. Keep the 8 most recent.

* fix(cli): hide the pairing password in remote-host status

status printed the password on every call, so it ended up in agent
transcripts and logs. It now needs --show-password. enable still prints it
for the installer, which parses that output.

* fix(desktop): encrypt saved remote host passwords

remotes.json held every host password in plaintext, so any process running
as the user, including agents AO starts, could read a credential that opens
a shell on each host. Passwords are now sealed with safeStorage and an
existing file is rewritten on launch. A password this launch cannot decrypt
is kept as is. Without a protected keychain (Linux basic_text) they stay
plaintext as before.

* fix(desktop): keep account host tokens out of the renderer

The renderer fetched every account host token from AO Cloud and passed it
to main, so script running in the renderer could read credentials that open
a shell on each linked host. Main now syncs and links account hosts itself
(remotes:syncAccountHosts, remotes:linkAccountHost), and the Cloud proxy
strips tokens from /me/hosts responses sent to the renderer and refuses that
path on its binary and stream channels.

* fix(e2e): use the renamed account host IPCs in the fake bridge

The fake bridge still stubbed remotes.importAccountHost, pruneAccountHosts
and issueAccountToken, which no longer exist.

* docs(skills): describe remote-host status --show-password

Three skill docs still said status prints the pairing password and told
agents to filter it with grep.

* fix(desktop): keep a saved password that cannot be decrypted during account sync

A host whose encrypted password could not be decrypted read back with an
empty password, so account sync replaced it with the account token and
dropped the encrypted value. Sync now changes only the label and address of
such an entry. An encrypted account token is marked as one, so a host the
account no longer lists is still removed when its token cannot be decrypted.

* fix(desktop): keep AO Cloud requests out of the remote hosts queue

Account host sync and linking called AO Cloud inside the queue that orders
list, connect, add and disconnect, with no time limit, so a Cloud that never
answered blocked every saved host. The directory read now runs before the
queue with a 10 second limit, and the registration PUT runs after it with no
limit, since making a tunnel can take more than a minute. A Cloud failure
rejects as an expected IPC error. Of two overlapping syncs, the older
listing is not applied over the newer one.

* feat(remote): give each paired device its own token

Every hand-paired device shared one pairing password that never expired,
so one device could not be revoked without re-pairing all of them.

A device now exchanges a one-time pairing code (10 minutes, single use), or
the password it already holds, at POST /api/v1/remote-host/devices for its
own token. The remote listener accepts device tokens, tells a removed
device that it was removed, and can refuse the pairing password
(require-device-credentials). Removing a device revokes its token and
closes its connections. The device list merges devices with push
registrations and shows the account's shared token as one row. Regenerate
also removes every device token.

* feat(cli): pair, list and revoke remote host devices

Adds ao remote-host pair, devices, devices revoke and
require-device-credentials. enable prints a one-time pairing code instead
of the pairing password, and status says when the password is off.

* feat(install): print a one-time pairing code for pairing by hand

The code is made when the pairing details are printed, so its 10 minutes
start there. A release without `ao remote-host pair` still prints the
password.

* docs(remote): describe pairing codes and device management

The Grok bot setup now exchanges a pairing code for its own token instead
of saving the pairing password.

* fix(remote): remove push registrations when every device is revoked

Rotating the pairing password revoked every device token but kept the phones' push registrations. They stayed in the device list as pairing-password devices and kept receiving notifications.

* fix(cli): print the password on enable only when the daemon has no pairing codes

enable printed the long-lived password whenever making a pairing code failed. It now does so only on 404 or 501 from the pairing-code route, and returns any other failure or an empty code as an error.

* fix(remote): revoke devices only after the new password is saved

Devices were revoked before the listener started and the state was saved, so a rotation that failed kept the old password but had already removed every device token and push registration. Revoking now follows the save and also closes the revoked devices' connections.

* fix(remote): move an unreadable device registry aside

A read error other than a missing file returned an empty registry at the same path, so the next write replaced the real file. It is now moved to .bad first, as a damaged file already is.

* test(remote): skip the device registry mode check on Windows

Windows does not report 0600, and the other mobilebridge tests already skip this check there.

* fix(remote): refuse device registry writes when a damaged file stays in place

A damaged or unreadable registry is moved to .bad before an empty one is used. If that rename failed, the next write still replaced the file. The registry now refuses every write in that case.

* test(remote): check that regenerate closes a device's open connection

* refactor(desktop): pick the device row icon with isPhone

The icon and the phone count in New Chat used the same platform check written twice.

* chore(remote): cut comments that restate the code

Exported symbols keep a one-line doc comment, as revive requires. Other comments stay only where they say why.
2026-11-11 14:46:56 +05:30
..