File size: 1,074 Bytes
f778c12 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | // Prints the local node host device identity for pairing verification.
import {
loadDeviceIdentityIfPresent,
publicKeyRawBase64UrlFromPem,
} from "../../infra/device-identity.js";
import { defaultRuntime, writeRuntimeJson } from "../../runtime.js";
/**
* Read-only by design: the SSH-verified pairing probe calls this remotely and
* must never mint a fresh identity on a host that has not run the node host.
*/
export function runNodeIdentityShow(opts: { json?: boolean }) {
const identity = loadDeviceIdentityIfPresent();
if (!identity) {
defaultRuntime.error(
"no node device identity found (start the node host once with `openclaw node run` or `openclaw node install`)",
);
defaultRuntime.exit(1);
return;
}
const payload = {
deviceId: identity.deviceId,
publicKey: publicKeyRawBase64UrlFromPem(identity.publicKeyPem),
};
if (opts.json) {
writeRuntimeJson(defaultRuntime, payload, 0);
return;
}
defaultRuntime.log(`deviceId: ${payload.deviceId}`);
defaultRuntime.log(`publicKey: ${payload.publicKey}`);
}
|