From cb5316e6f568ad615f96364f2554715e59816292 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Wed, 11 Mar 2026 10:48:12 -0700 Subject: [PATCH] fix ssl-checker type --- server/src/controllers/controllerUtils.ts | 6 +++--- server/src/types/ssl-checker.d.ts | 24 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 server/src/types/ssl-checker.d.ts diff --git a/server/src/controllers/controllerUtils.ts b/server/src/controllers/controllerUtils.ts index 173790cda..f8447fd59 100755 --- a/server/src/controllers/controllerUtils.ts +++ b/server/src/controllers/controllerUtils.ts @@ -1,9 +1,9 @@ import { AppError } from "@/utils/AppError.js"; import { Monitor, type MonitorType, MonitorTypes, UserRole } from "@/types/index.js"; -type SslCertificate = { valid: boolean; validFrom: string; validTo: string; daysRemaining: number; validFor?: string[] }; -type SslChecker = (host: string, options?: Record) => Promise; +import sslChecker, { SSLDetails } from "ssl-checker"; +type SSLCheckerType = typeof sslChecker; -const fetchMonitorCertificate = async (checker: SslChecker, monitor: Monitor): Promise => { +const fetchMonitorCertificate = async (checker: SSLCheckerType, monitor: Monitor): Promise => { const monitorUrl = new URL(monitor.url); const hostname = monitorUrl.hostname; const cert = await checker(hostname); diff --git a/server/src/types/ssl-checker.d.ts b/server/src/types/ssl-checker.d.ts new file mode 100644 index 000000000..bcbc39858 --- /dev/null +++ b/server/src/types/ssl-checker.d.ts @@ -0,0 +1,24 @@ +declare module "ssl-checker" { + import { Agent } from "https"; + + export interface SSLDetails { + daysRemaining: number; + valid: boolean; + validFrom: string; + validTo: string; + validFor: string[]; + } + + export interface SSLOptions { + method?: "GET" | "HEAD"; + port?: number; + agent?: Agent; + rejectUnauthorized?: boolean; + validateSubjectAltName?: boolean; + } + + function sslChecker(hostname: string, options?: SSLOptions): Promise; + + // Change 'export default' to 'export =' to allow it to be callable + export = sslChecker; +}