Skip to content

feat(e2ee): ask the browser to keep the storage that holds device keys - #56

Merged
Yoshiofthewire merged 1 commit into
mainfrom
feat/persistent-storage
Nov 25, 2026
Merged

Yoshiofthewire merged 1 commit into
mainfrom
feat/persistent-storage

Conversation

@Yoshiofthewire

Copy link
Copy Markdown
Member

In one line: KyMessages now asks the browser not to clear the storage that holds this device's encryption keys and room sessions.

What changed

  • Once a device's encryption store is open, KyMessages asks for persistent storage. It doesn't ask if the site already has it. This happens at sign-in, when the chat starts the device.
  • With persistent storage, the browser no longer clears the device on its own to free disk space. In Safari it may also survive the 7-day cleanup of sites that haven't been visited; WebKit only says "might". Without this, a cleared store loses the device and the room keys it received, so older encrypted history can become unreadable in this browser.
  • Firefox shows a permission prompt. Chromium and Safari decide silently. If the browser says no, nothing changes.
  • Sign-out still deletes every crypto store, exactly as before. Only the browser's own clean-up is affected.
  • Security is unchanged: the store was already on disk in IndexedDB, sealed under a non-extractable key. This only stops the browser deleting it unasked.

Review this: web/src/chat/e2ee.ts openStore: the request runs only for a device starting up, and it never blocks start-up. The sign-out and reset paths that also open the store don't ask. web/src/persist.ts: it doesn't ask again once storage is persistent, and it swallows errors.
Checked:

  • npm test: 214 passed, including 3 new keepStorage cases.
  • npm run build with Node 26.13.1. Only the main JS chunk changed, and the committed web/dist matches the build.
  • New browser test in e2ee-store-signout.spec.mjs, run in every project: 18 of 18 passed across Chromium (4 projects) and Firefox (2), alongside the two existing store tests.
  • The new test fails on main's bundle in Chromium and Firefox (Received: false).
  • go build -o .browser/server ./cmd/server, go vet ./web/....

Not checked: Safari, and the Firefox prompt's look by hand.
Decided for you: we ask when the device starts, which is at sign-in, not on page load, so the Firefox prompt appears right after signing in.
You need to: nothing.

Detail

This is part of a suite-wide change. KyNotes (Busnes-app/KyNotes-server#206) and KyIdentity (Busnes-app/KyIdentity-server#306) get the same request. Other Ky apps keep only preferences or service-worker caches, which can be rebuilt, so they don't need it.

keepStorage calls persisted() before persist(), so a browser that already keeps the storage is never asked again. persist() only exists in page context, and the device starts there. web/AGENTS.md and web/browser/AGENTS.md describe the new behaviour and test.

🤖 Generated with Claude Code

Once a device's encryption store is open, KyMessages asks for
persistent storage, so the browser does not clear the device's keys
and room sessions on its own to free space or after days without a
visit. Firefox asks the user; Chromium and Safari decide silently.
A refusal changes nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yoshiofthewire

Copy link
Copy Markdown
Member Author

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪

🧪 PR contains tests

⚡ No major issues detected


⚠️ Review coverage: The following files were not included in this review because of the token budget:

  • web/dist/assets/index-CmR13YJO.js

Advisory only: this comment never gates the pull request.
gpt-6.1-sol using pr-agent on behalf of Yoshi

@Yoshiofthewire

Copy link
Copy Markdown
Member Author

Security review - cleared

Detail withheld: this repository is public, and posting an unfixed finding here would be public disclosure. The full report was posted to the hand-off board at https://myslop.urlxl.us/f/pr-reviewer-busnes-app-kymessages-native-56, where it is readable by the operator and expires seven days after the last post.

Review input was truncated; omitted changes were not reviewed.


gpt-6.1-sol using security-audit on behalf of Yoshi

@Yoshiofthewire

Copy link
Copy Markdown
Member Author

Autonomous review - 1/1 personas cleared

  • security: cleared

Merging remains a human decision; this bot never approves.


gpt-6.1-sol using security-audit on behalf of Yoshi

@Yoshiofthewire
Yoshiofthewire merged commit 9202576 into main Nov 25, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant