CertificateMonitor
A TLS certificate monitor - a table of hosts with issuer, expiry date and a days-left badge that turns amber at 30 days and red at 7 or when expired, soonest first, with check again, renew and stop monitoring.
Code
import { CertificateMonitor, type CertificateRecord } from "@fadymondy/nasaq/web";declare const certificates: CertificateRecord[];declare const api: { add(host: string): Promise<void>; recheck(id: string): Promise<void> };export const Certs = () => ( <CertificateMonitor certificates={certificates} onAdd={(h) => api.add(h)} onRecheck={(id) => api.recheck(id)} />);Security · beta
Live examples and controls: CertificateMonitor in the lab.
Install
npx shadcn@latest add https://docs.nasaqui.com/r/cert-monitor.jsonWatch certificates so none lapses unnoticed. Each host shows its issuer, expiry date, whether it renews automatically and a days-left badge: green above 30 days, amber at 30 or fewer, red at 7 or fewer or already expired, and neutral when the check failed. The list is sorted with the soonest expiry first. Row actions: check again, renew now (for certificates that do not renew automatically) and stop monitoring (with a confirm). Add a host from the toolbar. It has no backend: your callbacks act and you pass the updated certificates back. Change the thresholds with thresholds; override the clock with now in tests and stories.
When to use
- A security or hosting page that lists certificates.
DaysLeftBadgebeside a domain elsewhere.
When not to use
- Issuing certificates or CSRs.
- Domain verification: use
DomainsManager.
Import
import { CertificateMonitor } from "@fadymondy/nasaq/web";
// inside this monorepo: "@nasaq/web"Quick start
import { CertificateMonitor, type CertificateRecord } from "@fadymondy/nasaq/web";
declare const certificates: CertificateRecord[];
declare const api: { add(host: string): Promise<void>; recheck(id: string): Promise<void> };
export const Certs = () => (
<CertificateMonitor certificates={certificates} onAdd={(h) => api.add(h)} onRecheck={(id) => api.recheck(id)} />
);Anatomy
CertificateMonitor data-slot="certificate-monitor"
├─ header title, "N monitored, M need attention" Badge
├─ toolbar search, add host form
├─ DataTable host, issuer, expires, auto renew, DaysLeftBadge; row menu: Check again, Renew now, Stop monitoring
└─ AlertDialog stop monitoring confirm
DaysLeftBadge data-slot="days-left-badge" data-status = valid | expiring | critical | expired | errorAPI
CertificateMonitor: every Card prop except children, plus:
| Prop | Type | Default | Description |
|---|---|---|---|
certificates | readonly CertificateRecord[] | required | { id, host, issuer?, validTo?, autoRenew?, error? }. error marks a failed check. |
thresholds | { warnDays, criticalDays } | { 30, 7 } | At or below warnDays is amber; at or below criticalDays is red. |
now | Date | number | now | Override the clock. |
loading | boolean | false | Skeleton state. |
onAdd | (host) => Promise<void | { error? }> | Shows the add form. | |
onRecheck, onRenew, onRemove | (id) => Promise<...> | Each shows its row action. Renew only shows for manual certificates. | |
labels | Partial<CertMonitorLabels> | Override any string. |
DaysLeftBadge: days, host, thresholds.
Helpers (pure, tested): certDaysLeft(validTo, now), certStatus, certTone, byExpiry, summarizeCerts, isValidCertHost.
Examples
Custom thresholds
import { DaysLeftBadge } from "@fadymondy/nasaq/web";
export const Badge = () => <DaysLeftBadge days={20} thresholds={{ warnDays: 14, criticalDays: 3 }} />; // still greenAccessibility
- The badge always says how many days (or that it expired): never colour alone. It also has an
aria-labelwith the host. - Rows have a button for the menu, not only right-click. Errors show in an
Alert.
RTL & i18n
- English and Arabic strings follow the Nasaq locale. Hostnames stay left to right; dates use Latin digits.
Styling & tokens
- Built on
DataTable,Card,Badge,AlertDialogand--nq-*tokens. Target[data-slot="certificate-monitor"].
Do / Don't
- Do alert well before 30 days for certificates that renew by hand.
- Do show a failed check as its own state instead of hiding the row.
- Don't count days from a stale
now: leave it unset in production. - Don't remove a host without the confirm.
Related
Lab
https://docs.nasaqui.com/?path=/docs/components-security-certificate-monitor--docs
AuditLog
The audit log table. Filter by actor, action, entity, channel (web, API or MCP) and dates, open a row for the field-level before and after, and set how long entries are kept.
DataPrivacy
Your data rights. Request a copy of your data and follow it until it is ready to download, delete the account with a grace period, and the public page that cancels a scheduled deletion.