Chunked checksum verification and IndexedDB durability ensuring zero corrupted payloads even across intermittent satellite links.
export type SyncStatus = 'queued' | 'uploading' | 'synced' | 'retrying';
export interface SyncTask<TPayload = unknown> {
id: string;
checksumSha256: string;
attempts: number;
status: SyncStatus;
payload: TPayload;
}
export async function processQueueItem<T>(
task: SyncTask<T>,
uploadFn: (item: SyncTask<T>) => Promise<void>
): Promise<SyncStatus> {
try {
await uploadFn({ ...task, status: 'uploading' });
return 'synced';
} catch {
const delayMs = Math.min(30000, 1000 * Math.pow(2, task.attempts));
await new Promise((res) => setTimeout(res, delayMs));
return 'retrying';
}
}