fix ssl-checker type
This commit is contained in:
1 parent
2884ab524d
commit
cb5316e6f5
2 files changed
+27
-3
No files matched your search
@@ -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<string, unknown>) => Promise<SslCertificate>;
|
||||
import sslChecker, { SSLDetails } from "ssl-checker";
|
||||
type SSLCheckerType = typeof sslChecker;
|
||||
|
||||
const fetchMonitorCertificate = async (checker: SslChecker, monitor: Monitor): Promise<SslCertificate> => {
|
||||
const fetchMonitorCertificate = async (checker: SSLCheckerType, monitor: Monitor): Promise<SSLDetails> => {
|
||||
const monitorUrl = new URL(monitor.url);
|
||||
const hostname = monitorUrl.hostname;
|
||||
const cert = await checker(hostname);
|
||||
|
||||
Vendored
+24
@@ -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<SSLDetails>;
|
||||
|
||||
// Change 'export default' to 'export =' to allow it to be callable
|
||||
export = sslChecker;
|
||||
}
|
||||
Reference in new issue
Block a user