Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | 1x 1x 18x 18x 18x 18x 9x 9x 9x 9x 9x 9x 18x 12x 110x | "use client";
import { useEffect, useState } from "react";
import { Fingerprint, Loader2 } from "lucide-react";
import { fetchApi } from "@/lib/api";
import { useSpeStatus } from "@/components/spe/use-spe-status";
import { type SpeAuditEvent } from "@/lib/spe";
import { AttestationCard } from "./_components/AttestationCard";
import { AttestationExplainer } from "./_components/AttestationExplainer";
import { useT } from "@/lib/i18n/translate";
const ENVIRONMENT_LABELS: Record<string, string> = {
azure: "Azure",
local: "Local stack",
static: "Static demo",
};
/**
* /admin/attestation (#774): the attestation evidence behind each SPE's
* label, from /api/admin/spe, with the SPE's last events from the audit
* chain (/api/admin/audit?type=spe).
*/
export default function AdminAttestationPage() {
const t = useT("admin");
const { data, loading, error, watch } = useSpeStatus();
const [events, setEvents] = useState<SpeAuditEvent[]>([]);
useEffect(() => {
let cancelled = false;
fetchApi("/api/admin/audit?type=spe&limit=50")
.then((r) => (r.ok ? r.json() : null))
.then((d: { speEvents?: SpeAuditEvent[] } | null) => {
if (!cancelled && Array.isArray(d?.speEvents)) setEvents(d.speEvents);
})
.catch(() => {});
return () => {
cancelled = true;
};
}, []);
return (
<div className="min-h-screen bg-(--bg)">
<main className="px-8 py-10 max-w-6xl mx-auto space-y-8">
<div className="flex flex-col md:flex-row md:items-end justify-between gap-4">
<div>
<h1 className="page-header flex items-center gap-3">
<Fingerprint
size={28}
className="text-(--layer5-text)"
aria-hidden="true"
/>
{t("SPE attestation")}
</h1>
<p className="text-(--text-secondary) text-lg mt-1">
{t(
"What proves each secure processing environment · EHDS Art. 73",
)}
</p>
</div>
{data && (
<span className="text-xs font-semibold px-2.5 py-1 rounded-full bg-(--surface-2) text-(--text-secondary) self-start md:self-auto">
{t(ENVIRONMENT_LABELS[data.environment] ?? data.environment)}
</span>
)}
</div>
<AttestationExplainer />
{loading ? (
<p className="flex items-center gap-2 text-sm text-(--text-secondary)">
<Loader2 size={14} className="animate-spin" aria-hidden="true" />
{t("Loading attestation evidence…")}
</p>
) : !data ? (
<p className="text-sm text-(--text-secondary)">
{t("Secure processing environments unavailable")}
{error ? `: ${error}` : ""}
</p>
) : (
<>
{data.fallback && (
<p
role="note"
className="text-xs text-(--warning-text) bg-(--warning)/10 border border-(--warning)/30 rounded-lg px-3 py-2"
>
{data.fallback.reason}.{" "}
{t("No attestation is known for any SPE.")}
</p>
)}
{data.spes.length === 0 ? (
<p className="text-sm text-(--text-secondary)">
{t("No SPE reported")}
</p>
) : (
data.spes.map((spe) => (
<AttestationCard
key={spe.id}
spe={spe}
trustee={data.trustee}
residualTrust={data.residualTrust}
events={events.filter((e) => e.speId === spe.id)}
power={data.power}
onPowerChange={watch}
/>
))
)}
</>
)}
</main>
</div>
);
}
|