12
]);
13
14
>
function validateMacAddress(candidate: string): boolean {
macAddress.ts
15
>
const tempCandidate = candidate.replace(/\-/g, ':').toLowerCase();
16
>
return !invalidMacAddresses.has(tempCandidate);
17
>
}
18
19
export function getMac(): string {
21
>
for (const name in ifaces) {
22
>
const networkInterface = ifaces[name];
23
>
if (networkInterface) {
24
>
for (const { mac } of networkInterface) {
25
>
if (validateMacAddress(mac)) {
26
>
return mac;
27
>
}
28
>
}
29
>
}
30
>
}
31
32
throw new Error('Unable to retrieve mac address (unexpected format)');