Files
decolua--9router/open-sse/shared/machineId.js
T
wehub-resource-sync 05fcd08057
Deploy GitBook to 9router.github.io / build-deploy (push) Failing after 2s
chore: import upstream snapshot with attribution
2026-07-13 12:21:01 +08:00

20 lines
506 B
JavaScript

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);
}