Skip to main content

Module api

Module api 

Source
Expand description

JMAP API server

This module implements the JMAP (JSON Meta Application Protocol) API server as defined in RFC 8620. It provides comprehensive request validation including:

  • Request structure validation (using, methodCalls)
  • Capability validation (ensuring declared capabilities are supported)
  • Method call validation (structure, limits, arguments)
  • Error responses per RFC 8620 Section 3.6:
    • unknownCapability: Capability not recognized
    • notRequest: Request doesn’t match JMAP structure
    • limit: Server limit exceeded (e.g., maxCallsInRequest)
    • unknownMethod: Method not recognized
    • invalidArguments: Invalid method arguments
    • Other error types for account/server issues

§Authentication

Real authentication is handled by crate::auth::require_auth which attaches a Principal to the request extensions. Construct the router via JmapServer::routes_with_auth in production. The legacy JmapServer::routes returns a router that rejects every request with 401 — the previous implementation that fabricated a hardcoded principal was a development-only fallback and has been removed.

For production deployments that include blob storage and EventSource push, use JmapServer::routes_with_auth_and_state which additionally mounts:

  • POST /upload/:account_id — blob upload (RFC 8620 §6.2)
  • GET /download/:account_id/:blob_id/:name — blob download (RFC 8620 §6.2)
  • GET /eventsource — Server-Sent Events push channel (RFC 8620 §7.3)

Structs§

JmapServer
JMAP server.

Functions§

account_id_for
Helper exposed for callers that need the canonical username → account-id mapping (kept here so external crates have a single entry point).