Chrome and Firefox extension on the Rust client (async sessions over fetch) #20
Loading…
Reference in a new issue
No description provided.
Delete branch "board/983-8390a0"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Board #983. This adds the Chrome and Firefox extension (MV3), built on Plaintext's own Rust client compiled to WebAssembly. No crypto or sync logic is written in JavaScript.
How sync runs in the browser
client::Session's logic is now written once, asasyncmethods over a newAsyncTransporttrait. Every blockingTransportis also anAsyncTransport, and the existing blocking methods (login,sync,put_item, …) poll that future once. The CLI, the tests and #14'sffitherefore compile unchanged and exercise the same code. In the browser,wasm/implementsAsyncTransportwith onefetchfunction that refuses redirects, sends no cookies, and has a timeout and a size cap. DESIGN.md ("The browser extension") explains the choice and the three alternatives that were rejected.What's in it
AsyncTransport, with*_asyncversions of sign-in, resume, sync, keyring save and merge,put_itemand logout. The blocking methods are one-line wrappers over them.Session::restorereopens a session with no network, from the device's keyring copy.syncnow folds in a newer server keyring, as #14 also does.ureqandzip(with the importers) are left out of wasm builds, and the clock comes from JavaScript there.site::matches: eTLD+1 matching from a bundled Public Suffix List (tools/psl.pyrefreshes it), with exact-host matching and no https logins on http pages. Saved URLs are parsed the way browsers parse them: a scheme only at the start, a backslash ends the host, and only http(s) logins match.Item::exact_hostandItem::matches_page.crypto::seal_secret_key/open_secret_key, which seal the Secret Key under the password (Argon2id, random salt) so the browser can keep it.extensionfeature, on by default. The viewer build passes--no-default-featuresand comes out +223 bytes for the new item field.Accountexport: add, unlock, resume, restore offline, sync, list, fill, item, save offer and save, and the exact-host toggle (writable vaults only). Overlapping calls fail withbusy..wasmthrough the extension's ownnet.js.wasm/build.sh extensionbuilds the extension's WebAssembly.storage.session. Sealed vault and keyring copies live instorage.local, as the CLI keeps them, and the extension reopens from them with no network after the browser suspends it. One account failing doesn't affect the others. Auto-lock follows the idle time and ends the server sessions. Clipboard clearing goes through an offscreen document in Chrome and the event page in Firefox.formaction(including image buttons and buttons outside the form),<base>and non-web schemes, read through the prototypes;package.pybuilds both packages from one tree.TESTING.mdexplains how to install and what to try.Tests
cargo clippy --all-targets -D warningsandcargo testpass, including the 4 native bridge tests and the Node bridge test against a pkg built locally.web-ext lint, which reports 0 errors.extension/test/browsers/run.shpasses every check in Chrome for Testing 158 and Firefox 161 on the Mac, and in Chromium 155 and Firefox 158 on Nikita's Omarchy laptop (Arch Linux, run headless with throwaway profiles), against a fresh local server:formaction, an image button, a button outside the form,mailto:), or for a login framed by another site, while ajavascript:form still fills;Light and dark both pass. Screenshots are on board #983.
Review: three Opus rounds; every finding is fixed.
Test builds: no store and no pre-release, per Nikita.
plaintext-chrome-0.1.0-test.3.zipand the unsignedplaintext-firefox-0.1.0-test.3.xpiare in~/Downloads/plaintext-test/on the Mac and on the Omarchy laptop, next toTESTING.md.Not in this PR
TESTING.mdasks to check both by hand on Linux.🤖 Generated with Claude Code