Skip to content
This repository was archived by the owner on Oct 15, 2026. It is now read-only.

Encrypted .raftbundle session sharing - #11

Merged
kevinraymond merged 5 commits into
mainfrom
claude/encrypted-session-export-Cm8vE
Apr 27, 2026
Merged

kevinraymond merged 5 commits into
mainfrom
claude/encrypted-session-export-Cm8vE

Conversation

@kevinraymond

Copy link
Copy Markdown
Member

Summary

  • Adds an "Encrypt & share" action on each saved session that produces a passphrase + downloadable .raftbundle file. Recipient drops the file into the import panel, enters the passphrase out-of-band, and picks which tabs to bring in.
  • Reuses the existing PBKDF2 (600k) + AES-256-GCM primitives from cloudSync/encryption.ts. File-shaped envelope: { v: 1, salt, iv, ct, iterations }. Zero servers, zero accounts, no auto-encryption — the user explicitly opts in per export.
  • Passphrase dialog shows the passphrase once, warns to share it through a different channel than the file, and has separate Copy / Download buttons on purpose.

Trust surface

  • Safety test (tests/safety/encrypted-bundle.test.ts) asserts export + import make zero fetch / XMLHttpRequest / WebSocket calls.
  • Round-trip test exports a 50-tab + 3-groups-per-window session and asserts the restored Session is bit-for-bit toEqual to the original.
  • Wrong passphrase surfaces a clean "Incorrect passphrase or corrupted bundle" error; malformed envelopes are rejected before any key derivation.
  • Envelope test pins the iteration count at 600,000 and confirms fresh salt+IV per export.

Files

  • src/shared/importExport/bundle.ts — exportBundle, importBundle, envelope helpers, generateBundlePassphrase (6 words + 4 digits).
  • src/shared/importExport/parsers/raftbundle.ts — async parser entry returning the standard ImportResult.
  • src/shared/importExport/{index,types,validators}.ts — register the new format and route bundles past the auto-detect importer.
  • src/options/components/ImportExportPanel.tsx — per-session export action, passphrase modal, decrypt + tab-picker import flow. Also fixes a pre-existing double-fire on the Choose File button.
  • tests/safety/encrypted-bundle.test.ts — 14 tests covering the above.

Test plan

  • pnpm typecheck clean
  • pnpm lint clean
  • pnpm test --run (759 / 759 passing)
  • Manual: export a session, copy passphrase, download bundle, re-import in the same profile with a new ID, confirm tab-picker selects subset correctly
  • Manual: wrong passphrase produces inline error, dialog stays open
  • Manual: dropping a .raftbundle renamed to .json still routes through the passphrase prompt (envelope sniff)

Non-goals

  • No cloud-shareable links (would require a server).
  • No auto-encryption — explicit user action only.

https://claude.ai/code/session_01Kv2npptMMD2BV3y7dxjp1X


Generated by Claude Code

claude added 4 commits April 27, 2026 09:02
Lets users export a saved session as an end-to-end-encrypted file with a
one-time passphrase, then re-import on another machine. Reuses the
PBKDF2 (600k) + AES-256-GCM primitives from cloud sync, file-shaped
envelope { v, salt, iv, ct, iterations }.

Trust surface: passphrase + bundle travel out-of-band, both halves are
needed to read it. The new safety suite asserts the export/import path
makes zero network calls and round-trips a 50-tab session bit-for-bit.
The <span role="button"> click was bubbling up to the wrapping <label>,
which natively forwards activation to the contained file input — so the
picker opened once from the explicit onClick and once from the label.
The label-wrapped span was producing two click activations on the
underlying file input: one from the explicit onClick and one from the
label's native click-forwarding. stopPropagation didn't reliably suppress
the second activation. A plain button + ref.click() has a single source
of truth and behaves predictably.
Comment thread src/shared/importExport/bundle.ts Fixed
@codecov-commenter

codecov-commenter commented Apr 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/shared/importExport/bundle.ts 87.14% 9 Missing ⚠️
src/shared/importExport/validators.ts 28.57% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

CodeQL flagged the previous `crypto.getRandomValues() % N` pattern: when
the 32-bit range isn't an exact multiple of N, low buckets are slightly
more likely. unbiasedRandomInt rejects draws in the unfair top slice so
the modulo is uniform. Rejection rate is < 1 in ~36M for our inputs.
@kevinraymond
kevinraymond merged commit 65521b9 into main Apr 27, 2026
7 checks passed
@kevinraymond
kevinraymond deleted the claude/encrypted-session-export-Cm8vE branch April 27, 2026 12:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants