18 lines
638 B
JavaScript
18 lines
638 B
JavaScript
"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.
|
|
* @param {number} port The port number the agent will listen on. Optional - useful to disambiguating multiple agents running on the same machine for development purposes.
|
|
* @return {string}
|
|
*/
|
|
export default async function(port) {
|
|
let serial = (await systeminfo.system()).serial;
|
|
let uuid = await systeminfo.uuid();
|
|
return hash("sha256", "base64",
|
|
`${port}@${serial}@${uuid.os}@${uuid.hardware}@${uuid.macs.join("#")}`
|
|
).replace(/[+/=]/g, "");
|
|
}
|