Skip to content

fix(mobile): preserve NATS routing fields after decryption - #600

Merged
huichen merged 1 commit into
mainfrom
claude/remote-e2ee-diagnostics
Sep 13, 2026
Merged

huichen merged 1 commit into
mainfrom
claude/remote-e2ee-diagnostics

Conversation

@huichen

@huichen huichen commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

Root cause

The E2EE receive path spread a NATS MsgImpl into a plain object after decryption. MsgImpl.subject is a prototype getter, so { ...message, data }` drops it. Presence only reads data and keeps working, but catalog/event/transfer handlers read subject and throw, causing the client to mark the generation unhealthy and reconnect. RPC refresh can still show new sessions, explaining the misleading yellow-but-receiving behavior.

Live diagnosis

  • Read-only WSS observer joined the local Desktop's existing broker pairing without changing its identity or stealing queue deliveries; no message bodies or credentials were logged.
  • Broker round trips stayed approximately 11-16ms while the phone repeatedly performed secure_open, often around the 20-second catalog refresh cadence.
  • An actual received MsgImpl had a string subject; its spread copy had undefined subject and reproduced the exact slice TypeError.
  • Installed Desktop is 0.0.2-476b90e8 (already E2EE v2). This patch requires only a mobile update.

Fix and regression

  • Explicitly forward subject and decrypted data, with the consumer type narrowed to those fields.
  • Return only decrypted data from secure RPC rather than falsely advertising a spread MsgImpl as a full Msg.
  • Exercise real SDK MsgImpl and QueuedIteratorImpl with actual Noise/AEAD, repeated presence/catalog/event pushes and file download delivery. The new test fails before the fix and passes afterward.

Checks

Mobile typecheck, ESLint and all 74 suites / 933 tests passed. Phone installation of the newly built APK remains the final real-device verification.

@huichen
huichen enabled auto-merge (squash) September 13, 2026 15:23
@huichen
huichen merged commit 317e67c into main Sep 13, 2026
12 checks passed
@huichen
huichen deleted the claude/remote-e2ee-diagnostics branch September 13, 2026 15:25
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