api9nin / open-sse /shared /machineId.js
github-actions[bot]
deploy from github actions 2026-06-18
c8ae75d
Raw
History Blame Contribute Delete
506 Bytes
import { machineIdSync } from "node-machine-id";
import crypto from "node:crypto";
let cachedRawId = null;
function loadRawMachineId() {
if (cachedRawId) return cachedRawId;
try {
cachedRawId = machineIdSync();
} catch {
cachedRawId = crypto.randomUUID();
}
return cachedRawId;
}
export async function getConsistentMachineId(salt = "endpoint-proxy-salt") {
const rawId = loadRawMachineId();
return crypto.createHash("sha256").update(rawId + salt).digest("hex").substring(0, 16);
}