import { useCallback, useEffect, useState } from 'react' import { useMe } from './me' import { useShowModal } from './modal' import useVault, { useVaultConfigurator, useVaultMigration } from './use-vault' import { Button, InputGroup } from 'react-bootstrap' import { Form, Input, PasswordInput, SubmitButton } from './form' import bip39Words from '@/lib/bip39-words' import Info from './info' import CancelButton from './cancel-button' import * as yup from 'yup' import { deviceSyncSchema } from '@/lib/validate' import RefreshIcon from '@/svgs/refresh-line.svg' import { useApolloClient } from '@apollo/client' export default function DeviceSync () { const { me } = useMe() const apollo = useApolloClient() const [value, setVaultKey, clearVault, disconnectVault] = useVaultConfigurator() const showModal = useShowModal() const enabled = !!me?.privates?.vaultKeyHash const connected = !!value?.key const migrate = useVaultMigration() const [debugValue, setDebugValue, clearValue] = useVault(me, 'debug') const manage = useCallback(async () => { if (enabled && connected) { showModal((onClose) => (
Sensitive data (like wallet credentials) is now securely synced between all connected devices.
Disconnect to prevent this device from syncing data or to reset your passphrase.
This will delete all encrypted data on the server and disconnect all devices.
You will need to enter a new passphrase on this and all other devices to sync data again.
Device sync uses end-to-end encryption to securely synchronize your data across devices.
Your sensitive data remains private and inaccessible to our servers while being synced across all your connected devices using only a passphrase.
If you have lost your passphrase or wish to erase all encrypted data from the server, you can reset the device sync data and start over.
This action cannot be undone.
{!enabled ? 'Enable secure sync of sensitive data (like wallet credentials) between your devices. You’ll need to enter this passphrase on each device you want to connect.' : 'Enter the passphrase from device sync to access your encrypted sensitive data (like wallet credentials) on the server.'}