rusmes-jmap
JMAP (JSON Meta Application Protocol) server for RusMES, targeting RFC 8620 (JMAP Core) and RFC 8621 (JMAP Mail) compliance.
Status
Alpha. All core JMAP methods are implemented and tested. Bearer token authentication is wired to the real AuthBackend. Email threading (RFC 5256), email import, and email parse are fully operational.
Architecture
JMAP uses HTTP/JSON instead of a text-based protocol:
JmapServer (axum)
|-- GET /.well-known/jmap -> Session resource
|-- POST /jmap -> API endpoint (method calls)
|-- GET /download/:acct/:blob -> Blob download
|-- POST /upload/:acct -> Blob upload
'-- GET /eventsource -> Push notifications (SSE)
Implemented JMAP Methods
Core (RFC 8620)
- Session endpoint (
/.well-known/jmap) with capabilities - Request validation (
using,methodCallsstructure) - Error responses (
unknownMethod,invalidArguments,unknownCapability,limit, etc.) - Account discovery
- Account permission enforcement (per RFC 8620 §3.3
forbiddenon account mismatch)
Email Methods (RFC 8621)
Email/get,Email/set(create / update / destroy),Email/queryEmail/changes,Email/copyEmail/import— import raw RFC 5322 messages into a mailboxEmail/parse— parse a blob as an RFC 5322 message without storing itEmailSubmission/set,EmailSubmission/get,EmailSubmission/query,EmailSubmission/changes
Mailbox Methods
Mailbox/get,Mailbox/set,Mailbox/query,Mailbox/changes
Other Methods
Thread/get,Thread/changesSearchSnippet/getIdentity/get,Identity/set(create / update / destroy)VacationResponse/get,VacationResponse/set
Email Conversion Correctness
EmailConversionContext<'_>: content-addressed blob IDs (compute_blob_idvia SHA-256), RFC 8621 keywords ($seen,$flagged,$answered,$draft,$deleted), realreceived_at,mailbox_ids,thread_id— no placeholder values inEmail/getresponses
Threading
- RFC 5256 thread ID assignment via References-chain algorithm
Authentication
- Bearer token authentication — wired to real
AuthBackend(token introspection) - HTTP Basic authentication — delegated to
AuthBackend::authenticate Principal { account_id, scopes }attached to request extensions for downstream enforcement
Blob & Push
- Blob download endpoint (
/download/:account/:blob/:name) - Blob upload endpoint (
/upload/:account) - EventSource (Server-Sent Events) with broadcast channel
Modules
| Module | Description |
|---|---|
api |
JmapServer — axum router and endpoint handlers |
auth |
Bearer / Basic credential extraction and AuthBackend delegation |
types |
JmapRequest, JmapResponse, JmapMethod, Principal |
methods |
Method dispatch and per-method handlers |
Key Types
Dependencies
rusmes-proto- mail typesrusmes-storage- mailbox and message storagerusmes-auth- authenticationaxum/hyper- HTTP serverserde/serde_json- JSON serializationtokio- async runtime
Tests