Skip to content

#171 Document the registration + first-message key-exchange sequence … - #251

Merged
codebestia merged 1 commit into
codebestia:mainfrom
madisonsc52-del:#171-Document-the-registration-+-first-message-key-exchange-sequence-FIX
Jun 28, 2026
Merged

#171 Document the registration + first-message key-exchange sequence …#251
codebestia merged 1 commit into
codebestia:mainfrom
madisonsc52-del:#171-Document-the-registration-+-first-message-key-exchange-sequence-FIX

Conversation

@madisonsc52-del

Copy link
Copy Markdown
Contributor

Description

Adds backend E2EE onboarding documentation at apps/backend/docs/e2ee-onboarding.md, covering the happy path, offline-recipient path, and prekey-exhausted path. The doc records the exact JSON request/response shapes and ordering guarantees for the currently implemented onboarding endpoints, and it is linked from apps/backend/IMPLEMENTATION_DOCS.md.

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Other

Findings

After reviewing the backend codebase, I found that the currently implemented E2EE-related flow includes:

  • POST /auth/challenge
    • creates and returns a sign-in message plus nonce
  • POST /auth/verify
    • verifies the wallet signature
    • resolves or creates the user
    • resolves or registers the device using identityPublicKey
    • returns a JWT containing deviceId
  • POST /devices/:id/prekeys
    • validates device ownership
    • verifies signed prekey signature
    • uploads/replaces the signed prekey
    • uploads one-time prekeys subject to the 200 key cap
  • GET /devices
    • lists the caller's devices

I also found that the repo does not currently implement backend endpoints for:

  • recipient bundle fetch
  • atomic one-time prekey consumption/reservation
  • explicit server-side session establishment
  • encrypted envelope submission/delivery flow

Exact issue identified

The issue was a missing backend sequence document for E2EE onboarding.

Specifically, the codebase lacked:

  • apps/backend/docs/e2ee-onboarding.md
  • a link to that doc from IMPLEMENTATION_DOCS.md

Fix features

I fixed the issue by adding documentation that:

  • covers the happy path
  • covers the offline-recipient path
  • covers the prekey-exhausted path
  • includes exact JSON shapes for the implemented endpoints
  • documents the ordering guarantees clients should rely on
  • clearly distinguishes between:
    • currently implemented backend behavior
    • intended future flow for first-DM bundle/session/envelope handling

Files created

  • apps/backend/docs/e2ee-onboarding.md
  • apps/backend/IMPLEMENTATION_DOCS.md

The documentation issue is resolved without changing backend runtime logic.

Checklist

  • I have read the contributing guidelines
  • I have tested my changes locally
  • My code follows the project's coding standards

If you want a stricter version reflecting the environment limitation, I can also phrase the checklist to note that local test execution could not be completed because pnpm/vitest were unavailable in the workspace.

CLOSE #171

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@madisonsc52-del Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@codebestia codebestia left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Thank you for your contribution.

@codebestia
codebestia merged commit bd24c33 into codebestia:main Jun 28, 2026
2 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.

Document the registration + first-message key-exchange sequence

2 participants