idunn-rudp.cjs was 324 lines of which almost none were about Idunn. The transport moved to CultLib as cultnet-ts's signed-daemon-health module, beside the RUDP session it was already built on. What is left here is 65 lines: the three constants naming Idunn's wire contract, and the call shapes Odin's consumers already use. The constants are declared, not decided. Idunn defines them in docs/signed-daemon-health-authority.md, which until today did not state the connection id at all -- the value describing how to reach Idunn existed only in this consumer. Declaring two constants against a documented contract is not duplicated authority; duplicating 311 lines of transport across Odin and a future Hermodr repository would have been. The module also stops resolving CultLib by walking up three directories from its own location. It now honours CULTLIB_ROOT with that walk as a fallback, matching what hermodr-daemon.cjs already did. The old assumption held only while Odin sat beside CultLib, and Erycina broke on exactly that when it moved. The signed-health test now supplies IDUNN_HEALTH_CONTRACT to the publisher it builds by hand, and still asserts the literal wire values, so a change to the contract constants fails loudly rather than being absorbed. Verified: 22 tests pass across six files, including signature verification against the relocated implementation, and the syntax check is clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
67 lines
2 KiB
JavaScript
67 lines
2 KiB
JavaScript
"use strict";
|
|
|
|
const assert = require("node:assert/strict");
|
|
const crypto = require("node:crypto");
|
|
const test = require("node:test");
|
|
|
|
const {
|
|
IDUNN_HEALTH_CONTRACT,
|
|
signedHealthPayload,
|
|
signingMessage,
|
|
} = require("../src/odin/idunn-rudp.cjs");
|
|
|
|
test("Odin signs the complete canonical provider-health statement", () => {
|
|
const { privateKey, publicKey } = crypto.generateKeyPairSync("ed25519");
|
|
const publicDer = publicKey.export({ type: "spki", format: "der" });
|
|
const rawPublicKey = Buffer.from(publicDer.subarray(publicDer.length - 32));
|
|
const signerIdentityId = crypto
|
|
.createHash("sha256")
|
|
.update(Buffer.from("gamecult.provider-health.identity.v1\0"))
|
|
.update(rawPublicKey)
|
|
.digest("hex");
|
|
const publisher = {
|
|
daemonId: "yggdrasil-odin",
|
|
healthContract: "odin.cultnet-rudp-provider-health",
|
|
privateKey,
|
|
publisherIncarnationId: "24e0dc7f-6a92-4aa8-9f56-fb513d265e13",
|
|
publisherSequence: 0,
|
|
signerIdentityId,
|
|
sourceRuntimeId: "odin-yggdrasil",
|
|
contract: IDUNN_HEALTH_CONTRACT,
|
|
};
|
|
|
|
const signed = signedHealthPayload(
|
|
publisher,
|
|
{ state: "active", detail: "catalog current" },
|
|
"2026-08-21T12:34:56.789Z",
|
|
);
|
|
|
|
assert.equal(signed.statement[0], "idunn.signed_daemon_health.v1");
|
|
assert.equal(signed.statement[1], "yggdrasil-odin");
|
|
assert.equal(signed.statement[2], "odin.cultnet-rudp-provider-health");
|
|
assert.equal(signed.statement[3], "odin-yggdrasil");
|
|
assert.equal(signed.statement[8], 1);
|
|
assert.equal(signed.statement[9], 1787315696789);
|
|
assert.equal(signed.statement[15].byteLength, 64);
|
|
assert.equal(
|
|
crypto.verify(
|
|
null,
|
|
signingMessage(signed.unsignedPayload),
|
|
publicKey,
|
|
Buffer.from(signed.statement[15]),
|
|
),
|
|
true,
|
|
);
|
|
|
|
const tampered = Buffer.from(signed.unsignedPayload);
|
|
tampered[tampered.length - 1] ^= 1;
|
|
assert.equal(
|
|
crypto.verify(
|
|
null,
|
|
signingMessage(tampered),
|
|
publicKey,
|
|
Buffer.from(signed.statement[15]),
|
|
),
|
|
false,
|
|
);
|
|
});
|