CLEMA protocol

Security Considerations

  1. TLS Required: All connections must use WSS (WebSocket Secure)
  2. Passwords: CLEMA accounts have none: they sign in by phone and keep tokens. A transport account password is stored in whatever form its adapter must verify against, and is never usable as a CLEMA credential
  3. Connection Timeout: Connections that send nothing for 120 seconds are closed
  4. File Authorization: Stored files require message visibility; direct transfer tokens are random, single-use capabilities backed by bearer and role checks
  5. Conversation Authorization: Membership and role checks are performed server-side in the same transaction as every mutation
  6. Invitation Bounds: Invitation tokens are cryptographically random, optionally user-bound, expire, have a usage limit and can be revoked
  7. Moderation Hierarchy: Ban and restriction targets are checked against current roles in the same transaction as the mutation
  8. Atomic Slow Mode: The last successful post and the new message are checked and written under one database transaction
  9. Privacy Enforcement: Blocks and inbound message/invitation policies are checked inside the mutation transaction; profile, presence, search and avatar reads apply the same relationship rules
  10. Phone Verification: Codes are random, stored only as digests, valid for 5 minutes, single-use and bound to one purpose, with five attempts each. A code proves only that the number received it: a number its carrier has given to someone else signs them in to the account it is still bound to
  11. Phone Privacy: A number is shown to its owner alone. An address book finds accounts only for numbers its uploader already has, within the owner's phone_discovery setting and a daily limit per account; uploaded books are kept only to find people who join later
  12. Push Privacy: Pushes carry identifiers, names and the first 100 characters of a message — what a fallback notification needs — and nothing more passes through the push provider. Registrations end with their session
  13. QR Sign-In: Codes are random, stored only as digests, valid for 60 seconds, single-use and bound to the waiting connection. Only a session that proved the number approves one, after the user has seen the waiting client's description and address