import React from 'react'; import { X, Lock, Copy, Send, Ban } from '../icons'; import { useToast } from './Toasts/useToast'; export interface CredentialEntry { id: number; attacker_ip: string; decky_name: string; service: string; principal: string | null; secret_kind: string; secret_sha256: string; secret_b64: string | null; secret_printable: string | null; outcome: string | null; fields: any; first_seen: string; last_seen: string; attempt_count: number; } interface Props { cred: CredentialEntry; onClose: () => void; onSelectAttacker: (ip: string) => void; } const CredentialsInspector: React.FC = ({ cred, onClose, onSelectAttacker }) => { const { push } = useToast(); const isPlain = cred.secret_kind === 'plaintext'; const copy = async (text: string, label: string) => { try { await navigator.clipboard.writeText(text); push({ text: `${label} COPIED`, tone: 'matrix', icon: 'copy' }); } catch { push({ text: 'CLIPBOARD BLOCKED', tone: 'alert', icon: 'alert-triangle' }); } }; const copyJson = () => copy(JSON.stringify(cred, null, 2), 'JSON'); const stubMisp = () => push({ text: 'MISP NOT CONFIGURED', tone: 'violet', icon: 'info' }); const stubBlocklist = () => push({ text: 'BLOCKLIST NOT WIRED', tone: 'violet', icon: 'info' }); return (
{ if (e.target === e.currentTarget) onClose(); }} >

CREDENTIAL #{cred.id}

SECRET KIND
{cred.secret_kind.toUpperCase()}
OUTCOME
{cred.outcome ? {cred.outcome.toUpperCase()} : }
DECKY
{cred.decky_name}
SERVICE
{cred.service}
PRINCIPAL
{cred.principal ?? }
ATTACKER
onSelectAttacker(cred.attacker_ip)} > {cred.attacker_ip}
ATTEMPTS
{cred.attempt_count}
FIRST SEEN
{new Date(cred.first_seen).toLocaleString()}
LAST SEEN
{new Date(cred.last_seen).toLocaleString()}
{isPlain ? 'PLAINTEXT SECRET' : 'OBSERVED RESPONSE'}
              printable:{' '}
              {cred.secret_printable ?? '—'}{'\n'}
              b64:{' '}
              {cred.secret_b64 ?? '—'}
            
SECRET SHA-256
{cred.secret_sha256}
{cred.fields && Object.keys(cred.fields || {}).length > 0 && (
SERVICE FIELDS
{JSON.stringify(cred.fields, null, 2)}
)}
EXPORT
); }; export default CredentialsInspector;