MCPcopy Create free account
hub / github.com/agentrpc/agentrpc / machineId

Function machineId

sdk-node/src/machine-id.ts:9–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7let cachedId: string | undefined;
8
9export const machineId = () => {
10 if (cachedId) {
11 return cachedId;
12 }
13
14 try {
15 const id = machineIdSync();
16 const hash = createHash("shake256", {
17 outputLength: 8,
18 })
19 .update(id)
20 .digest("hex");
21
22 cachedId = hash;
23
24 return hash;
25 } catch (e) {
26 log("Failed to get machine ID. Defaulting to random string.", { error: e });
27
28 const str = Math.random().toString(36).substring(8);
29 cachedId = str;
30
31 return str;
32 }
33};

Callers 1

constructorMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected