sync-types.ts

1.8 KB · raw

1export interface TrustedNetwork {2  ssid?: string;3  bssid?: string;4  isTailscale: boolean;5  addedAt: number;6}78export interface PairedDevice {9  deviceId: string;10  displayName: string;11  x25519PublicKey: string;12  pairedAt: number;13  lastSeenAt?: number;14  lastSyncAt?: number;15  lastKnownIp?: string;16}1718// A stripped-down device record propagated in SYNC_VAULT_SEND so every peer19// learns the full mesh without re-pairing. No IP — IPs are ephemeral and20// discovered fresh via subnet scan.21export interface SyncableDevice {22  publicKeyHex: string;23  deviceName: string;24  pairedAt: number;25}2627export type SyncMessage =28  | { type: 'SYNC_HELLO' }29  | { type: 'SYNC_VAULT_SEND'; blob: string; timestamp: number; license?: string; devices: SyncableDevice[] }30  | { type: 'SYNC_VAULT_ACK'; applied: boolean }31  | { type: 'SYNC_DONE' }32  | { type: 'SYNC_ERROR'; error: string };3334export type SyncStatus = "synced" | "syncing" | "no_peers" | "not_trusted" | "offline";3536/**37 * Pairing request received from a peer that needs user confirmation.38 *39 * The banner expires after 60 seconds (`expiresAt - receivedAt = 60_000`);40 * after that the popup hides the banner and the background drops the41 * request. The publicKeyHex is the peer's static X25519 identity — it42 * gets written to trusted devices on accept and discarded on reject.43 */44export interface IncomingPairingRequest {45  deviceName: string;46  publicKeyHex: string;47  receivedAt: number;48  expiresAt: number;49  /**50   * Connection id of the still-open pairing-only socket. The background's51   * RESPOND_INCOMING_PAIRING handler sends PAIR_ACCEPT or PAIR_REJECT over52   * this connection then disconnects. May be absent for synthetic test53   * injections that do not have a real connection behind them.54   */55  connectionId?: string;56}