import { defineTrustPlugin, exactCertificateScope, } from "../sdk/plugin-api.js"; export default defineTrustPlugin({ manifest: { manifestVersion: 1, trustApiVersion: "0.1", id: "community.village.strict-example", name: "Village strict example", version: "1.0.0", supportedModes: ["advisor", "decision-authority"], capabilities: { interactiveUi: true }, }, hooks: { collectEvidence({ facts }) { if (facts.hostname !== "library.village") return undefined; return { entries: [ { kind: "evidence", code: "known-community-certificate", message: "The configured community recognizes this certificate.", }, ], }; }, async onTlsFailure({ facts, journal, ui }) { const trusted = await ui.requestDecision({ title: "Unknown village authority", summary: "Firefox does not recognize this authority. The community recognizes the exact certificate.", proposedScope: exactCertificateScope(facts), evidenceEntryIds: journal.entries.map((entry) => entry.id), }); if (trusted === undefined) return undefined; const common = { scope: exactCertificateScope(facts), lifetime: { kind: "session" } as const, reasonEntryIds: journal.entries.map((entry) => entry.id), }; return trusted ? { ...common, trusted: true, overriddenErrors: [...facts.errors] } : { ...common, trusted: false, overriddenErrors: [] }; }, }, });