import { AlertTriangleIcon } from "lucide-react"; import React from "react"; import { toast } from "sonner"; import Loading from "src/components/Loading"; import PasswordInput from "src/components/password/PasswordInput"; import SettingsHeader from "src/components/SettingsHeader"; import { Alert, AlertDescription, AlertTitle } from "src/components/ui/alert"; import { LoadingButton } from "src/components/ui/custom/loading-button"; import { Label } from "src/components/ui/label"; import { useInfo } from "src/hooks/useInfo"; import { request } from "src/utils/request"; export function AutoUnlock() { const { data: info, mutate: refetchInfo } = useInfo(); const [unlockPassword, setUnlockPassword] = React.useState(""); const [loading, setLoading] = React.useState(false); const onSubmit = async (e: React.FormEvent) => { e.preventDefault(); try { setLoading(true); await request("/api/auto-unlock", { method: "PATCH", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ unlockPassword, }), }); await refetchInfo(); setUnlockPassword(""); toast( `Successfully ${unlockPassword ? "enabled" : "disabled"} auto-unlock` ); } catch (error) { toast("Auto Unlock change failed", { description: (error as Error).message, }); } finally { setLoading(false); } }; if (!info) { return ; } if (!info.autoUnlockPasswordSupported) { return

Your Hub does not support this feature.

; } return ( <>

In some situations it can be impractical to manually unlock the wallet every time Alby Hub is started. In those cases you can save the unlock password in plaintext so that Alby Hub can auto-unlock itself.

Attention Everyone who has access to the machine running this hub could read that password and take your funds. Use this only in a secure environment. {!info.autoUnlockPasswordEnabled && ( <>
Enable Auto Unlock
)} {info.autoUnlockPasswordEnabled && ( <>
Disable Auto Unlock
)}
); }