Full Toolkit for Next-Level Domain Analysis
Refactor certs page 🧹
Felix Wotschofsky3bc55cd72601
diff --git a/app/lookup/[domain]/certs/page.tsx b/app/lookup/[domain]/certs/page.tsxindex dbb7420..b6d2e90 100644--- a/app/lookup/[domain]/certs/page.tsx+++ b/app/lookup/[domain]/certs/page.tsx@@ -11,7 +11,19 @@ import {import DomainLink from '@/components/DomainLink';-const lookupCerts = async (domain: string) => {+type CertsData = {+ issuer_ca_id: number;+ issuer_name: string;+ common_name: string;+ name_value: string;+ id: number;+ entry_timestamp: string;+ not_before: string;+ not_after: string;+ serial_number: string;+}[];++const lookupCerts = async (domain: string): Promise<CertsData> => {const response = await fetch('https://crt.sh?' +new URLSearchParams({@@ -24,27 +36,7 @@ const lookupCerts = async (domain: string) => {throw new Error('Failed to fetch certs');}- const data = (await response.json()) as {- issuer_ca_id: number;- issuer_name: string;- common_name: string;- name_value: string;- id: number;- entry_timestamp: string;- not_before: string;- not_after: string;- serial_number: string;- }[];-- return data.map((c) => ({- id: c.id,- loggedAt: c.entry_timestamp,- notBefore: c.not_before,- notAfter: c.not_after,- commonName: c.common_name,- matchingIdentities: c.name_value,- issuerName: c.issuer_name,- }));+ return await response.json();};type CertsResultsPageProps = {@@ -85,22 +77,22 @@ const CertsResultsPage: FC<CertsResultsPageProps> = async ({<TableBody>{certs.map((cert) => (<TableRow key={cert.id}>- <TableCell className="pl-0">{cert.loggedAt}</TableCell>- <TableCell>{cert.notBefore}</TableCell>- <TableCell>{cert.notAfter}</TableCell>+ <TableCell className="pl-0">{cert.entry_timestamp}</TableCell>+ <TableCell>{cert.not_before}</TableCell>+ <TableCell>{cert.not_after}</TableCell><TableCell>- <DomainLink domain={cert.commonName} />+ <DomainLink domain={cert.common_name} /></TableCell><TableCell>- {cert.matchingIdentities.split(/\n/g).map((value, index) => (+ {cert.name_value.split(/\n/g).map((value, index) => (<>{index !== 0 && <br />}<DomainLink domain={value} /></>))}</TableCell>- <TableCell className="pr-0">{cert.issuerName}</TableCell>+ <TableCell className="pr-0">{cert.issuer_name}</TableCell></TableRow>))}</TableBody>