systemquery/src/lib/io/hostuuid.mjs

18 lines
454 B
JavaScript
Raw Normal View History

2022-01-08 21:55:18 +00:00
"use strict";
import systeminfo from 'systeminformation';
import hash from '../crypto/hash.mjs';
/**
* Returns what (should) be a reproducible UUID for each host that it runs on.
* @return {string}
*/
export default async function() {
let serial = (await systeminfo.system()).serial;
let uuid = await systeminfo.uuid();
return hash("sha256", "base64",
`${serial}@${uuid.os}@${uuid.hardware}@${uuid.macs.join("#")}`
).replace(/[+/=]/g, "");
}