// Vip Identity Card // Purpose: Defines the Vip Identity Card module and the local helpers/components used in this file. // Scope: Keeps behavior unchanged while isolating this concern into a clear, single-responsibility unit. import { useState } from 'react'; import CardFrame from '../CardFrame/index.jsx'; import { fieldClass, flowWrapClass, innerFlowClass, maskKey } from './constants.js'; export default function VipIdentityCard({ currentStoredKey, applyIdentityKey, onMessage, fullWidth = false }) { const [restoreFlowStep, setRestoreFlowStep] = useState(0); const [restoreKeyInput, setRestoreKeyInput] = useState(''); const [working, setWorking] = useState(false); const beginRestoreFlow = () => { setRestoreFlowStep(1); setRestoreKeyInput(''); onMessage?.(''); }; const cancelRestoreFlow = () => { setRestoreFlowStep(0); setRestoreKeyInput(''); }; const handleRestoreSubmit = async (event) => { event.preventDefault(); if (restoreFlowStep < 2) return; setWorking(true); onMessage?.(''); try { await applyIdentityKey(restoreKeyInput); setRestoreFlowStep(0); setRestoreKeyInput(''); onMessage?.('Identity key restored.'); } catch (err) { onMessage?.(err.message || 'Failed to restore key.'); } finally { setWorking(false); } }; const wrapClass = fullWidth ? 'w-full' : flowWrapClass; return (

Current: {maskKey(currentStoredKey) || 'not set yet'}

{restoreFlowStep === 0 ? (
) : null} {restoreFlowStep === 1 ? (

Restoring your key should only be done when needed. Use this to move your identity to another browser.

) : null} {restoreFlowStep === 2 ? (
setRestoreKeyInput(event.target.value.toLowerCase())} placeholder="Paste key to restore" />
) : null}
); }