import {
ArrowLeftIcon,
CheckIcon,
CircleIcon,
CopyIcon,
DownloadIcon,
KeyRoundIcon,
Loader2Icon,
TriangleAlertIcon,
UserPlusIcon,
XIcon,
} from 'lucide-react';
import { useRef, useState } from 'react';
import { Button } from '#/components/atoms/button.jsx';
import { Heading } from '#/components/atoms/heading.jsx';
import { Notice } from '#/components/atoms/notice.jsx';
import { Panel } from '#/components/atoms/panel.jsx';
import { ErrorNotice } from '#/components/molecules/error-notice.jsx';
import { TextField } from '#/components/molecules/text-field.jsx';
import { isRateLimitError } from '#/lib/atproto.js';
import { MIGRATION_STEPS, runMigration } from '#/lib/migrate.js';
import { generateRecoveryKey } from '#/lib/rotationKey.js';
/**
* First-run wizard, served by the server on an empty PDS. Two ways in: mint a
* brand-new account, or migrate an existing one here from another PDS.
*/
export function OnboardPage({ hostname }) {
const [choice, setChoice] = useState(
/** @type {null|'create'|'migrate'} */ (null),
);
return (
);
}
function StepIcon({ status }) {
if (status === 'done')
return ;
if (status === 'warn')
return ;
if (status === 'error')
return ;
if (status === 'active')
return ;
return ;
}
function CodePrompt({ kind, onSubmit, blocked }) {
return (
);
}
/**
* Shows a freshly minted recovery key's private half for the user to save. In
* `reminder` mode (post-migration) it's informational; otherwise it carries the
* "I've saved this" checkbox that unblocks the identity move.
*/
function RecoveryKeyCard({ privateKeyHex, saved, onSavedChange, reminder }) {
const [copied, setCopied] = useState(false);
const copy = async () => {
try {
await navigator.clipboard.writeText(privateKeyHex);
setCopied(true);
setTimeout(() => setCopied(false), 1500);
} catch {
// Clipboard can be unavailable (permissions/insecure context); the key is
// still selectable in the box.
}
};
return (
Your recovery key
Save this private key somewhere safe (a password manager). It's the only
way to recover your identity if this server is ever lost, and it{' '}
won't be shown again.