Un server per la sincronizzazioneA server to sync through
Telefono e TV si sincronizzano attraverso un server che scegli tu: quello di dambox, pronto da usare, o uno tuo, che parla la piccola API HTTP descritta qui in OpenAPI 3.1. In entrambi i casi il server conserva solo dati cifrati sui dispositivi, e l'app ha bisogno solo del suo indirizzo.
Phone and TV sync through a server you choose: dambox's, ready to use, or one of your own that speaks the small HTTP API described here in OpenAPI 3.1. Either way the server only keeps data encrypted on the devices, and the app only needs its address.
Scegliere un server
Il server di dambox
Scrivi sync-divano.dambox.ch come Indirizzo del server su ogni dispositivo. Per ora è gratuito e non serve una chiave. Lo gestisce dambox; cosa conserva è nella privacy. Se un giorno le condizioni cambieranno, l'app lo annuncerà nella pagina Sincronizzazione, con una data.
Un server tuo
Va bene qualunque server che implementi l'API di questa pagina: vedi Cosa deve fare un server e il Riferimento API. Se accetta solo famiglie con una chiave (registration: secret), la chiave è quella da scrivere in Chiave del server.
Choosing a server
dambox's server
Enter sync-divano.dambox.ch as the Server address on every device. For now it's free and needs no key. It's run by dambox; what it keeps is in the privacy policy. If its terms ever change, the app will say so on the Sync page, with a date.
A server of your own
Any server that implements the API on this page works: see What a server must do and the API reference. If it only takes households with a key (registration: secret), that key goes in Server key.
Come funziona
- Uno spazio è l'insieme dei dispositivi di una famiglia. Ha una chiave che conoscono solo i suoi dispositivi e che il server non riceve mai.
- Il server conserva record
{id, rev, deleted, blob}per spazio.idè un'impronta calcolata con la chiave eblobè cifrato con AES-256-GCM: il server sa quanti record ci sono, quanto sono grandi (arrotondati) e quando cambiano, non cosa contengono. revè un contatore per spazio assegnato dal server. Le scritture sono compare-and-set surev: l'ordine del server fa fede e l'orologio dei dispositivi non conta.- Un nuovo dispositivo entra nello spazio con un abbinamento: mostra un codice QR, un dispositivo già presente lo inquadra, controlla l'impronta della chiave e gli passa la chiave dello spazio cifrata per lui. Il server la custodisce senza poterla aprire.
- Se non resta nessun dispositivo, si rientra con il kit di recupero: un codice QR, stampato o in PDF, con un segreto che il server non vede. Il server conserva un'impronta di ciò che lo prova e la chiave dello spazio cifrata con una chiave che solo il kit dà.
Un server malevolo può non rispondere o restituire dati vecchi, ma non può leggere né falsificare i record, né far entrare un suo dispositivo in uno spazio. Il formato dei record e la crittografia riguardano solo l'app: il server deve soltanto conservarli e restituirli in ordine.
How it works
- A space is the set of devices of one household. It has a key that only its devices know and that the server never receives.
- The server stores records
{id, rev, deleted, blob}per space.idis a keyed hash andblobis encrypted with AES-256-GCM: the server learns how many records there are, how big they are (rounded) and when they change, not what they contain. revis a per-space counter assigned by the server. Writes are compare-and-set onrev: the server's order is the truth and no device clock matters.- A new device joins a space by pairing: it shows a QR code, a device already in the space scans it, checks the key fingerprint and hands over the space key encrypted for it. The server holds it without being able to open it.
- When no device is left, the household gets back in with its recovery kit: a QR code, printed or as a PDF, holding a secret the server never sees. The server keeps a hash of what proves it, and the space key encrypted with a key only the kit gives.
A malicious server can refuse service or hand back stale data, but it cannot read or forge records, nor slip a device of its own into a space. The record format and the cryptography only concern the app: the server just stores records and hands them back in order.
Cosa deve fare un server
- Rispondere su HTTPS. Se sta dietro un proxy, il timeout di lettura del proxy deve superare la durata dei long-poll (
maxWaitSeconds). - Servire
GET /discoverysenza autenticazione: versioni del protocollo, regole di registrazione, limiti, funzioni e chi gestisce il server. Non sotto/.well-known, che alcuni hosting riservano a sé. - Salvare i record in una tabella
records(space_id, id, rev, deleted, blob)con chiave(space_id, id)e un indice su(space_id, rev), più un contatore per spazio. - Eseguire ogni push in una transazione: controllare ogni
baseRev, assegnarerev = ++contatorealle scritture applicate, restituire il record attuale per i conflitti. - Dimenticare i record cancellati dopo
tombstoneRetentionDays(almeno 30) e ricordare ilrevpiù alto eliminato: un pull consincepiù vecchio riceve 410cursor_expired. - Long-poll: svegliare i pull in attesa quando il contatore dello spazio cambia. Chi non può tenere aperte le richieste annuncia
maxWaitSeconds: 0e toglielongpolldafeatures: le modifiche arrivano allora fino a un minuto dopo, e così quello che un telefono manda a una TV con Guarda sulla TV. - Far scadere gli abbinamenti dopo 10 minuti; ogni codice si usa una volta sola.
- Kit di recupero (funzione
recovery): conservare l'impronta SHA-256 diauthewrappedcosì com'è, uno per spazio, il nuovo al posto del vecchio. Con un kit, revocare l'ultimo dispositivo non elimina lo spazio.POST /v1/recovercrea il dispositivo anche oltremaxDevicese risponde 404 allo stesso modo per uno spazio sconosciuto, senza kit o conauthsbagliata. - Conservare dei token solo l'impronta SHA-256 e non registrare mai i corpi delle richieste né i token.
- Limitare per IP
POST /v1/spaces,POST /v1/pairingsePOST /v1/recover. - Per un server privato, usare
registration: secret: chi crea uno spazio deve conoscere la chiave del server.
What a server must do
- Answer over HTTPS. Behind a proxy, the proxy's read timeout must be longer than the long-polls (
maxWaitSeconds). - Serve
GET /discoverywithout authentication: protocol versions, registration rules, limits, features and who runs the server. Not under/.well-known, which some hosts reserve for themselves. - Store records in a table
records(space_id, id, rev, deleted, blob)keyed on(space_id, id)with an index on(space_id, rev), plus a per-space counter. - Run each push in one transaction: check every
baseRev, assignrev = ++counterto the applied writes, return the current record for conflicts. - Forget deleted records after
tombstoneRetentionDays(at least 30) and remember the highest purgedrev: a pull with an oldersincegets 410cursor_expired. - Long-poll: wake waiting pulls when the space's counter moves. A server that can't hold requests open advertises
maxWaitSeconds: 0and dropslongpollfromfeatures: changes then take up to a minute to arrive, and so does what a phone sends a TV with Watch on TV. - Expire pairings after 10 minutes; each code is single use.
- Recovery kits (feature
recovery): keep a SHA-256 hash ofauthandwrappedas sent, one per space, the new one replacing the old. With a kit, revoking the last device doesn't delete the space.POST /v1/recovercreates the device even pastmaxDevicesand answers 404 alike for an unknown space, one without a kit or a wrongauth. - Keep only a SHA-256 hash of tokens and never log request bodies or tokens.
- Rate-limit
POST /v1/spaces,POST /v1/pairingsandPOST /v1/recoverper IP. - For a private server, use
registration: secret: whoever creates a space must know the server key.
Per esempio, il server di dambox risponde così aFor example, dambox's server answers GET https://sync-divano.dambox.ch/discovery:
{
"protocols": [1],
"registration": "open",
"features": ["longpoll", "recovery"],
"limits": {
"maxRecords": 20000, "maxBytes": 33554432, "maxBlobBytes": 16384,
"maxBatch": 500, "maxDevices": 10, "maxWaitSeconds": 30,
"tombstoneRetentionDays": 90, "inactiveSpaceDays": 365
},
"operator": {
"name": "Divano",
"privacyUrl": "https://divano.dambox.ch/privacy/",
"contact": "app+divano@dambox.ch"
}
}
Collegare l'app
- In Impostazioni › Sincronizzazione, prima di iniziare, scrivi l'indirizzo nel campo Indirizzo del server. Sulla TV puoi scriverlo dal telefono: inquadra il codice di Più comodo dal telefono (stessa rete Wi-Fi). Senza schema, Divano aggiunge
https://;http://è accettato solo per indirizzi della rete di casa (localhost,.local,.lan,.home.arpa, IP privati). - Con
registration: secret, scrivi in Chiave del server il segreto che hai configurato: serve solo per iniziare, sul primo dispositivo. - Usa lo stesso server su tutti i dispositivi: durante l'abbinamento l'app controlla che coincida.
Connecting the app
- In Settings › Sync, before you start, type the address in the Server address field. On a TV you can type it on your phone: scan the code under Easier from your phone (same Wi-Fi network). Without a scheme Divano adds
https://;http://is only accepted for home network addresses (localhost,.local,.lan,.home.arpa, private IPs). - With
registration: secret, enter the secret you configured in Server key: it's only needed to start, on the first device. - Use the same server on every device: pairing checks that they match.
Riferimento APIAPI reference
Generato da openapi.yaml, in inglese come la specifica. Corpi JSON, errori application/problem+json (RFC 9457), valori binari in base64url senza padding, orari in millisecondi Unix.
Generated from openapi.yaml. JSON bodies, application/problem+json errors (RFC 9457), binary values in base64url without padding, times in Unix milliseconds.