feat(backup,cli): add AES-256-GCM .gcoord.enc backup, verify, restore CLI and API

This commit is contained in:
tyuXX 2026-11-27 14:23:22 +00:00
parent 413053182b
commit fbc1eb94e0
7 changed files with 1155 additions and 19 deletions

View file

@ -243,6 +243,35 @@ export class KnownHostsService {
.all() as KnownHostRecord[];
}
replaceAllKnownHosts(
records: Array<
Pick<KnownHostRecord, 'hostPort' | 'algorithm' | 'fingerprint'> &
Partial<Pick<KnownHostRecord, 'trustedAt' | 'updatedAt'>>
>,
): void {
const now = Date.now();
const tx = this.db.transaction(() => {
this.db.prepare('DELETE FROM known_hosts').run();
const ins = this.db.prepare(
`INSERT INTO known_hosts (host_port, algorithm, fingerprint, trusted_at, updated_at)
VALUES (?, ?, ?, ?, ?)`,
);
for (const r of records) {
ins.run(
r.hostPort,
r.algorithm,
r.fingerprint,
r.trustedAt ?? now,
r.updatedAt ?? now,
);
}
});
tx();
this.pendingTofu.clear();
this.pendingMismatches.clear();
this.emitChange();
}
deleteKnownHost(hostPort: string): boolean {
const res = this.db
.prepare('DELETE FROM known_hosts WHERE host_port = ?')