Initialize Browsec architecture and TrustLab
This commit is contained in:
commit
a1e56c1d09
14 files changed
+1500
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import { unknownLocalAuthority } from "../fixtures/tls.js";
|
||||
import { TrustRunner } from "../src/index.js";
|
||||
|
||||
const villagePlugin = {
|
||||
manifest: {
|
||||
id: "community.village.trust",
|
||||
name: "Village community trust",
|
||||
role: "decision-authority",
|
||||
},
|
||||
collectEvidence({ facts }) {
|
||||
if (facts.hostname !== "library.village") return;
|
||||
return {
|
||||
entries: [
|
||||
{
|
||||
kind: "evidence",
|
||||
code: "known-community-key",
|
||||
message: "The community has previously observed this certificate.",
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
decide({ facts, journal }) {
|
||||
const known = journal.entries.some(
|
||||
(entry) => entry.code === "known-community-key",
|
||||
);
|
||||
if (!known) return;
|
||||
return {
|
||||
trusted: true,
|
||||
scope: { hostname: facts.hostname, port: facts.port },
|
||||
reasonEntryIds: journal.entries
|
||||
.filter((entry) => entry.code === "known-community-key")
|
||||
.map((entry) => entry.id),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
const result = await new TrustRunner({ plugins: [villagePlugin] }).evaluate(
|
||||
unknownLocalAuthority,
|
||||
);
|
||||
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
|
||||
Reference in new issue
Block a user