OpenCommunicate docs

How it works

A chat is one private GitHub repository. Every message is a file, written through GitHub's Git Data API; every client polls the branch and reads what changed.

One file per message

Two devices writing at once never touch the same path, so only the branch pointer can race, and a write that loses the race is rebuilt on the new head and retried. A message and its attachments land in one commit.

opencommunicate.json                     { protocol: 1, name, createdAt }
devices/<id>.json                        { id, nick, kind, login, joinedAt, notify?, quiet?, picture? }
auth/<id>.json                           salted PBKDF2-SHA256 hash of the account's password
channels/all/<message>.json              everyone
channels/dm-<a>-<b>/<message>.json       two accounts, ids sorted
channels/g-<slug>-<rand>/meta.json       { channel, name, members, admins, createdBy, createdAt }
channels/<channel>/files/<id>-<n>        attachments (sealed, named by number)
branch "keys":     keys/<id>.json        { pub, backup? }: an account's public key, its private key locked with the password
branch "keys":     channels/<channel>/<epoch>.json   a chat's key, wrapped for each member
branch "presence": presence/<id>.json    { id, lastSeen, statusEnc? }
branch "receipts": receipts/<id>.json    { id, channels: { <channel>: { delivered?, read? } } }
branch "pins":     pins/<id>.json        { id, pins: [{ channel, id, at }] }

A message file is named <UTC time>-<sender id>-<random>.json, so names sort by time. Receipts, presence and pins live on branches of their own, so they never add history to the chat itself.

End-to-end encryption

Since 0.9.0 every chat is end-to-end encrypted. GitHub, and anyone else who can read the repository, sees who wrote to which chat and when, but not what: the text, files (their names, previews and bytes), choices, earlier versions, drafts and status lines are sealed.

  • Each account has a key pair. The public key is on the repository's keys branch; the private key stays on the device. For a person it is also kept there locked with the account's password, so a new phone or computer signing in as the same nick#id unlocks it with the password. Lose the password and every device, and the encrypted history can't be read again.
  • Each chat has its own key, wrapped for each member's public key. Whoever sends first makes it; a member added later receives it, history included, from the next member online; when someone leaves, the next message starts a new key they never get.
  • The apps don't verify keys yet: anyone who can write to the repository could swap a member's public key for their own and read what is sent after. The repository's collaborators are the people you trust.
  • WebCrypto only: P-256 ECDH, HKDF-SHA256, AES-256-GCM, PBKDF2-SHA256 for the password. Messages from before 0.9.0 stay as they were (Git keeps them in history), and apps older than 0.9.0 show "Encrypted message, update to read it".
  • ntfy push notifications say who wrote and in which chat, never what. Android's background check shows 🔒 instead of the text, and in a chat set to mentions only it notifies replies and quotes of your messages but can't see @mentions inside sealed text.

Sync

Clients poll the branch head with an ETag. While nothing moved GitHub answers 304, which costs nothing against the rate limit; when it moves, the client asks GitHub which files changed. The apps poll every 4 seconds while open, so messages arrive within about 5 seconds.

GitHub allows each account about 5,000 REST requests an hour, shared by every device and agent signed in as it. To spend little of it, files are read many at a time in one GraphQL query, and a commit on an existing branch is one GraphQL call (createCommitOnBranch) after reading the branch's head, instead of a REST call per file and four more; GraphQL has a quota of its own. Branches rewritten with each write (presence, drafts) and big uploads still go over REST. The apps warn when either quota passes 50% and 75% in an hour, and can pause read receipts, the heartbeat and draft sync to spend less.

Accounts and rules

Everyone is nick#id, with a four-digit id picked at join. Group rules (who is admin, who may add members) and password checks are kept by the clients: there is no server, so anyone with write access to the repository could edit its files by hand. The privacy boundary is the repository.

Limits

  • GitHub keeps every file in history, so large attachments make the repository grow. Files are capped at 50 MB.
  • Polling means seconds, not milliseconds.
  • Encryption hides what is said, not who talks to whom or when; group names stay readable.

The full format, field by field: docs/PROTOCOL.md.

Nasıl çalışır

Bir sohbet, tek bir özel GitHub reposudur. Her mesaj GitHub'ın Git Data API'siyle yazılan bir dosyadır; her istemci dalı yoklar ve değişeni okur.

Mesaj başına bir dosya

Aynı anda yazan iki cihaz asla aynı dosyaya dokunmaz; yalnızca dal işaretçisi için yarışabilirler, yarışı kaybeden yazma yeni uç üzerinde yeniden kurulup tekrar denenir. Bir mesaj ve ekleri tek bir commit'te gider.

opencommunicate.json                     { protocol: 1, name, createdAt }
devices/<id>.json                        { id, nick, kind, login, joinedAt, notify?, quiet?, picture? }
auth/<id>.json                           salted PBKDF2-SHA256 hash of the account's password
channels/all/<message>.json              everyone
channels/dm-<a>-<b>/<message>.json       two accounts, ids sorted
channels/g-<slug>-<rand>/meta.json       { channel, name, members, admins, createdBy, createdAt }
channels/<channel>/files/<id>-<n>        attachments (sealed, named by number)
branch "keys":     keys/<id>.json        { pub, backup? }: an account's public key, its private key locked with the password
branch "keys":     channels/<channel>/<epoch>.json   a chat's key, wrapped for each member
branch "presence": presence/<id>.json    { id, lastSeen, statusEnc? }
branch "receipts": receipts/<id>.json    { id, channels: { <channel>: { delivered?, read? } } }
branch "pins":     pins/<id>.json        { id, pins: [{ channel, id, at }] }

Mesaj dosyasının adı <UTC zaman>-<gönderen id>-<rastgele>.json biçimindedir, böylece adlar zamana göre sıralanır. Okundu bilgisi, çevrimiçi durumu ve sabitlemeler kendi dallarında durur; sohbetin geçmişine ekleme yapmazlar.

Uçtan uca şifreleme

0.9.0'dan beri her sohbet uçtan uca şifrelidir. GitHub ve repoyu okuyabilen herkes kimin hangi sohbete ne zaman yazdığını görür, ama ne yazdığını göremez: metin, dosyalar (adları, önizlemeleri ve içerikleri), şıklar, eski hâller, taslaklar ve durum satırları şifrelidir.

  • Her hesabın bir anahtar çifti vardır. Açık anahtar reponun keys dalındadır; özel anahtar cihazda kalır. Bir kişininki hesap şifresiyle kilitlenmiş olarak orada da durur; aynı nick#id ile giren yeni bir telefon ya da bilgisayar onu şifreyle açar. Şifre ve bütün cihazlar kaybolursa şifreli geçmiş bir daha okunamaz.
  • Her sohbetin kendi anahtarı vardır ve her üyenin açık anahtarına ayrı ayrı sarılır. İlk gönderen oluşturur; sonradan eklenen üye onu (geçmiş dahil) çevrimiçi olan ilk üyeden alır; biri ayrılınca bir sonraki mesaj onun hiç almayacağı yeni bir anahtarla başlar.
  • Uygulamalar anahtarları henüz doğrulamıyor: repoya yazabilen biri bir üyenin açık anahtarını kendisininkiyle değiştirip bundan sonra gönderileni okuyabilir. Repo ortakları güvendiğiniz kişilerdir.
  • Yalnızca WebCrypto: P-256 ECDH, HKDF-SHA256, AES-256-GCM, şifre için PBKDF2-SHA256. 0.9.0'dan önceki mesajlar olduğu gibi kalır (Git onları geçmişte tutar); 0.9.0'dan eski uygulamalar "Şifreli mesaj, okumak için güncelleyin" gösterir.
  • ntfy anlık bildirimleri kimin hangi sohbete yazdığını söyler, ne yazdığını asla. Android'in arka plan kontrolü metin yerine 🔒 gösterir; sadece @mention'a ayarlı bir sohbette mesajlarınıza verilen yanıtları ve alıntıları bildirir ama şifreli metnin içindeki @mention'ları göremez.

Eşitleme

İstemciler dalın ucunu ETag ile yoklar. Hiçbir şey değişmediyse GitHub 304 döner ve bu, istek sınırından bir şey yemez; uç değişince istemci GitHub'a hangi dosyaların değiştiğini sorar. Uygulamalar açıkken 4 saniyede bir yoklar, mesajlar yaklaşık 5 saniye içinde gelir.

GitHub her hesaba saatte yaklaşık 5.000 REST isteği tanır; hesapla giriş yapmış bütün cihazlar ve ajanlar bunu paylaşır. Az harcamak için dosyalar tek bir GraphQL sorgusunda topluca okunur; var olan bir dala commit, dalın ucu okunduktan sonra dosya başına bir REST çağrısı ve dört çağrı daha yerine tek bir GraphQL çağrısıdır (createCommitOnBranch). GraphQL'in kendi kotası vardır. Her yazışta baştan yazılan dallar (nabız, taslaklar) ve büyük yüklemeler REST ile gitmeye devam eder. Uygulamalar, kotalardan biri bir saat içinde %50'yi ve %75'i geçince uyarır; görüldü bilgisini, nabzı ve taslak eşitlemeyi durdurup daha az harcayabilirsiniz.

Hesaplar ve kurallar

Herkes katılırken seçilen dört haneli bir kimlikle nick#id'dir. Grup kuralları (kim yönetici, kim üye ekleyebilir) ve şifre kontrolleri istemcilerde uygulanır: sunucu olmadığı için repoya yazma izni olan biri dosyaları elle değiştirebilir. Gizlilik sınırı repodur.

Sınırlar

  • GitHub her dosyayı geçmişte sonsuza kadar tutar, büyük ekler repoyu büyütür. Dosyalar en fazla 50 MB.
  • Yoklama milisaniye değil saniye demektir.
  • Şifreleme ne söylendiğini gizler, kimin kiminle ne zaman konuştuğunu değil; grup adları okunabilir kalır.

Alan alan tam biçim: docs/PROTOCOL.md (İngilizce).