Public dry run dryrun-20b59dc46b72
Source commit: 20b59dc46b72103c2f8a516c692b5cc3d54fab19 Public tree identity: sha256:aaa5ac7b58b2a0d23c6b11e5f76324bf3839ca1f62653a83deb736932adcfbd9
This commit is contained in:
commit
2bef715211
221 changed files with 79792 additions and 0 deletions
43
scripts/coordinator-wire.js
Normal file
43
scripts/coordinator-wire.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
let requestId = 0;
|
||||
|
||||
function coordinatorWireRequest(payload, prefix = "acceptance") {
|
||||
if (payload && payload.type === "coordinator_request") return payload;
|
||||
if (!payload || typeof payload.type !== "string" || !payload.type.trim()) {
|
||||
throw new Error("coordinator payload must have a non-empty type");
|
||||
}
|
||||
requestId += 1;
|
||||
return {
|
||||
type: "coordinator_request",
|
||||
protocol_version: 1,
|
||||
request_id: `${prefix}-${process.pid}-${requestId}`,
|
||||
operation: payload.type,
|
||||
authentication: authenticationMetadata(payload),
|
||||
payload,
|
||||
};
|
||||
}
|
||||
|
||||
function authenticationMetadata(payload) {
|
||||
if (payload.type === "authenticated") {
|
||||
return {
|
||||
kind: "cli_session",
|
||||
session: true,
|
||||
request_operation: payload.request?.type || "unknown",
|
||||
};
|
||||
}
|
||||
if (payload.type === "signed_node" || payload.node_signature) {
|
||||
return { kind: "node_signature", node: payload.node || null };
|
||||
}
|
||||
if (payload.agent_signature) {
|
||||
return {
|
||||
kind: "agent_signature",
|
||||
agent: payload.actor_agent || null,
|
||||
fingerprint: payload.agent_public_key_fingerprint || null,
|
||||
};
|
||||
}
|
||||
if (payload.admin_token) {
|
||||
return { kind: "admin_credential" };
|
||||
}
|
||||
return { kind: "none" };
|
||||
}
|
||||
|
||||
module.exports = { coordinatorWireRequest };
|
||||
Loading…
Add table
Add a link
Reference in a new issue