import { getIdentity } from '../auth/auth.ic';
import { internetIdentityAuth } from '../../utils/identity.utils';
import { uploadWorker } from '../../workers/sync.ic.worker';
export const sync = async ({ syncData, clean }) => {
  const identity = getIdentity();
  if (!identity) {
    throw new Error('No internet identity to sync data');
  }
  const internetIdentity = await internetIdentityAuth();
  await uploadWorker({
    internetIdentity,
    syncData,
    host: `${window.location}`
  });
  await clean(syncData);
};
