core/steps/certificate.step.ts

core/steps/certificate.step.ts is a file in Bane's Lab Deploy. 16 lines of code and 3 definitions.

import { DANE_REMEDY, PROBE_DANE_PASSED, PROBE_FAILED, daneMismatch } from "#configuration/strings/deployment.strings";
import type { DaneReader, Journal } from "#types/deployment.types";
import { LINE_BREAK } from "#configuration/constants/deployment.constants";
import { readDane } from "#core/adapters/site.adapter";

export const probeCertificate = async function probeCertificate(
    journal: Journal,
    site: string,
    reader: DaneReader = readDane,
): Promise<void> {
    const keys = await reader(site);
    if (!keys.published.includes(keys.served)) {
        const finding = daneMismatch(keys.name, keys.served, keys.published);
        throw new Error([PROBE_FAILED, finding, DANE_REMEDY].join(LINE_BREAK));
    }
    journal.mark(PROBE_DANE_PASSED);
};