Sign the plugin registry and pin plugin files
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
27
tools/sign-registry.mjs
Normal file
27
tools/sign-registry.mjs
Normal file
@ -0,0 +1,27 @@
|
||||
// Run after changing any plugin: pins each file's SHA-256 in registry.json and
|
||||
// writes registry.json.sig. Exbyte Depot refuses a catalog with a bad signature.
|
||||
// Usage: node tools/sign-registry.mjs <ed25519-private-key.pem>
|
||||
import { createHash, createPrivateKey, sign } from "node:crypto";
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
|
||||
const root = new URL("../", import.meta.url);
|
||||
const keyPath = process.argv[2];
|
||||
if (!keyPath) {
|
||||
console.error("Usage: node tools/sign-registry.mjs <ed25519-private-key.pem>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const reg = JSON.parse(readFileSync(new URL("registry.json", root), "utf8"));
|
||||
for (const p of reg.plugins) {
|
||||
p.sha256 = {};
|
||||
for (const f of p.files) {
|
||||
p.sha256[f] = createHash("sha256").update(readFileSync(new URL(`plugins/${p.id}/${f}`, root))).digest("hex");
|
||||
}
|
||||
}
|
||||
reg.updated = new Date().toISOString().replace(/\.\d+Z$/, "Z");
|
||||
|
||||
const text = JSON.stringify(reg, null, 2) + "\n";
|
||||
writeFileSync(new URL("registry.json", root), text);
|
||||
const signature = sign(null, Buffer.from(text, "utf8"), createPrivateKey(readFileSync(keyPath)));
|
||||
writeFileSync(new URL("registry.json.sig", root), signature.toString("base64") + "\n");
|
||||
console.log(`Signed ${reg.plugins.length} plugin(s).`);
|
||||
Reference in New Issue
Block a user