56 lines
1.8 KiB
JavaScript
56 lines
1.8 KiB
JavaScript
export function subjectName(subject = "") {
|
|
const commonName = /(?:^|,)CN=([^,]+)/.exec(subject)?.[1];
|
|
return commonName ?? (subject || "Unnamed certificate");
|
|
}
|
|
|
|
export function verdictCopy(result, hasUserDecision) {
|
|
if (hasUserDecision) {
|
|
return result.verdict.trusted
|
|
? {
|
|
eyebrow: "Local decision",
|
|
title: "You trust this connection",
|
|
detail: "The decision is limited to the displayed host and port in this simulation.",
|
|
}
|
|
: {
|
|
eyebrow: "Local decision",
|
|
title: "You do not trust this connection",
|
|
detail: "The connection remains blocked by your explicit decision.",
|
|
};
|
|
}
|
|
|
|
if (result.facts.validation === "success") {
|
|
return {
|
|
eyebrow: "Firefox validation",
|
|
title: "The conventional certificate path is valid",
|
|
detail: "Trust plugins may still add evidence, warnings, or a stricter local verdict.",
|
|
};
|
|
}
|
|
|
|
return {
|
|
eyebrow: "Decision required",
|
|
title: "Firefox could not verify this identity",
|
|
detail: "Review the broken path and attributed plugin findings before deciding.",
|
|
};
|
|
}
|
|
|
|
export function chainRows(facts) {
|
|
const chain = facts.constructedChain.length
|
|
? facts.constructedChain
|
|
: facts.presentedChain;
|
|
const failureAtEnd = facts.validation === "failure";
|
|
|
|
return chain.map((certificate, index) => ({
|
|
...certificate,
|
|
name: subjectName(certificate.subject),
|
|
role:
|
|
index === 0 ? "Leaf certificate" : index === chain.length - 1 ? "Root candidate" : "Intermediate CA",
|
|
edge:
|
|
index === chain.length - 1
|
|
? failureAtEnd
|
|
? "Not anchored in current Firefox trust"
|
|
: "Trusted by current Firefox policy"
|
|
: "Signature links to next issuer",
|
|
failed: index === chain.length - 1 && failureAtEnd,
|
|
}));
|
|
}
|