import { createSignal, For, Show } from "solid-js"; import type { PasskeyEntry } from "../../shared/types"; import { detectBrowser } from "../../shared/browser"; interface PasskeyEntryProps { entry: PasskeyEntry | null; onDelete: () => void | Promise; } function formatDate(timestamp?: number): string { if (!timestamp) return "Never"; return new Date(timestamp).toLocaleDateString(); } function formatUsedCount(count?: number): string { const used = count ?? 0; return `used ${used} time${used === 1 ? "" : "s"}`; } function algorithmLabel(algorithm: -7 | -8): string { return algorithm === -8 ? "EdDSA (Ed25519)" : "ES256 (P-256)"; } function titleSizeClass(title: string): string { if (title.length >= 28) return "peach-entry-name--xxl"; if (title.length >= 20) return "peach-entry-name--xl"; if (title.length >= 14) return "peach-entry-name--lg"; return ""; } export function PasskeyEntryView(props: PasskeyEntryProps) { const [deleteConfirmPending, setDeleteConfirmPending] = createSignal(false); const currentBrowser = detectBrowser(); function crossBrowserMessage(entryBrowser: "chrome" | "firefox" | undefined): string | null { if (!entryBrowser) return null; if (currentBrowser === "unknown") return null; if (entryBrowser === currentBrowser) return null; const from = entryBrowser === "chrome" ? "Chrome" : "Firefox"; const to = currentBrowser === "chrome" ? "Chrome" : "Firefox"; return `This passkey was created on ${from}. To use it on ${to}, re-register it on this device.`; } return (
no passkey selected
}> {(entry) => ( <>

{entry().title}

setDeleteConfirmPending(true)} aria-label="Remove passkey" title="Remove passkey" > } >
remove?
{entry().rpId} passkey
username
{entry().userName}
display name
{entry().userDisplayName}
algorithm
{algorithmLabel(entry().algorithm)}
activity
{formatUsedCount(entry().signCount)} created {formatDate(entry().createdAt)} last used {formatDate(entry().lastUsedAt)}
0}>
{(tag) => {tag}}
{(msg) => (
{msg()}
)}
{entry().browser === "firefox" ? "This passkey is held by your platform authenticator. Peach stores only the metadata." : "The private key is stored encrypted in your Peach vault and is never shown in the UI."}
)} ); }