2025-05-09 21:52:46 +00:00
|
|
|
import type { Port80Handler } from '../../http/port80/port80-handler.js';
|
2025-05-09 17:00:27 +00:00
|
|
|
import { Port80HandlerEvents } from '../models/common-types.js';
|
|
|
|
import type { ICertificateData, ICertificateFailure, ICertificateExpiring } from '../models/common-types.js';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Subscribers callback definitions for Port80Handler events
|
|
|
|
*/
|
|
|
|
export interface Port80HandlerSubscribers {
|
|
|
|
onCertificateIssued?: (data: ICertificateData) => void;
|
|
|
|
onCertificateRenewed?: (data: ICertificateData) => void;
|
|
|
|
onCertificateFailed?: (data: ICertificateFailure) => void;
|
|
|
|
onCertificateExpiring?: (data: ICertificateExpiring) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Subscribes to Port80Handler events based on provided callbacks
|
|
|
|
*/
|
|
|
|
export function subscribeToPort80Handler(
|
|
|
|
handler: Port80Handler,
|
|
|
|
subscribers: Port80HandlerSubscribers
|
|
|
|
): void {
|
|
|
|
if (subscribers.onCertificateIssued) {
|
|
|
|
handler.on(Port80HandlerEvents.CERTIFICATE_ISSUED, subscribers.onCertificateIssued);
|
|
|
|
}
|
|
|
|
if (subscribers.onCertificateRenewed) {
|
|
|
|
handler.on(Port80HandlerEvents.CERTIFICATE_RENEWED, subscribers.onCertificateRenewed);
|
|
|
|
}
|
|
|
|
if (subscribers.onCertificateFailed) {
|
|
|
|
handler.on(Port80HandlerEvents.CERTIFICATE_FAILED, subscribers.onCertificateFailed);
|
|
|
|
}
|
|
|
|
if (subscribers.onCertificateExpiring) {
|
|
|
|
handler.on(Port80HandlerEvents.CERTIFICATE_EXPIRING, subscribers.onCertificateExpiring);
|
|
|
|
}
|
|
|
|
}
|