sync: overhaul sync system — device pairing, server_sequence, auto-sync, dashboards

BREAKING: replace legacy API keys with device tokens via pairing flow.
- Server: /api/client/pair, revoke, me endpoints; server_sequence + tombstones + idempotency
- Desktop client: PairDevice, GetMe, RevokeCurrent; auto-sync loop every 60s
- Config: device_token stored in separate file (0600), not config.yml
- Client DB: last_pull_seq migration for incremental pull
- Frontend (Svelte): settings modal with connect/disconnect/interval
- User dashboard (/dashboard): device list with status, revoke with password
- Admin dashboard (/admin/dashboard): devices table from /admin/api/devices
- CLI (cmd/verstak): updated for ServerSequence/GetState changes
- Fix: autoSyncLoop falls back to SQLite sync_state for server URL
- Fix: SyncSetInterval preserves server_url/device_id from SQLite
This commit is contained in:
2026-06-02 02:26:05 +08:00
parent 7fe02fc8df
commit 87c8dfcbea
15 changed files with 1002 additions and 253 deletions
@@ -0,0 +1,6 @@
package storage
// migration011 — add last_pull_seq to sync_state.
const migration011 = `
ALTER TABLE sync_state ADD COLUMN last_pull_seq INTEGER NOT NULL DEFAULT 0;
`
+9 -8
View File
@@ -57,16 +57,17 @@ CREATE TABLE IF NOT EXISTS _schema_ver (
`
var migrationFiles = map[int]string{
1: migration001,
2: migration002,
3: migration003,
4: migration004,
5: migration005,
6: migration006,
1: migration001,
2: migration002,
3: migration003,
4: migration004,
5: migration005,
6: migration006,
// 7: migration007 (FTS5) — created lazily by search.Rebuild()
8: migration008,
9: migration009,
8: migration008,
9: migration009,
10: migration010,
11: migration011,
}
func (db *DB) runInitialSchema() error {