-- Federation between Sonda servers (see internal/federation). Off until an admin turns it on; the key pair is made then. -- The private key stays in this table and is never returned by the API. CREATE TABLE federation_settings ( id INTEGER PRIMARY KEY CHECK (id = 1), -- one row enabled INTEGER NOT NULL DEFAULT 0, name TEXT NOT NULL DEFAULT '', -- shown to friends; '' = the host name address TEXT NOT NULL DEFAULT '', -- where friends reach this server public_key TEXT NOT NULL DEFAULT '', -- Ed25519, base64url; '' until first enabled private_key TEXT NOT NULL DEFAULT '', updated_at INTEGER NOT NULL DEFAULT 0 -- unix seconds ); -- Single-use invites. Only the SHA-256 of the code is kept. CREATE TABLE federation_invites ( id INTEGER PRIMARY KEY, code_hash TEXT NOT NULL UNIQUE, created_at INTEGER NOT NULL, expires_at INTEGER NOT NULL, used_at INTEGER ); -- The other servers. state: incoming (they used my invite, I have not approved), outgoing (I used theirs, they have -- not approved), active. CREATE TABLE federation_friends ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, address TEXT NOT NULL, public_key TEXT NOT NULL UNIQUE, state TEXT NOT NULL CHECK (state IN ('incoming', 'outgoing', 'active')), created_at INTEGER NOT NULL, approved_at INTEGER );