{"_id":"@1n/machine-id","name":"@1n/machine-id","dist-tags":{"latest":"1.1.0"},"versions":{"1.1.0":{"name":"@1n/machine-id","version":"1.1.0","description":"Cross-platform unique machine (desktop) id discovery","type":"module","main":"lib/index.js","module":"lib/index.js","types":"lib/index.d.ts","publishConfig":{"registry":"https://registry.npmjs.org/","access":"public"},"license":"MIT","_id":"@1n/machine-id@1.1.0","gitHead":"48a6e8fc79c473639e8538da896706323948c9b6","_nodeVersion":"23.10.0","_npmVersion":"11.2.0","dist":{"integrity":"sha512-Z0tJIHAY0eERb6GIpfS+WSmkQ8lB/5tneH7h/33xDJTjIKLOCWqrAmnb9Z4ntD8TyV3n+yjkXY4JKN4CNGQ5Ag==","shasum":"e8e9e94dd6ba6d95f0122b14ed1b5bad69334a7b","tarball":"https://registry.npmjs.org/@1n/machine-id/-/machine-id-1.1.0.tgz","fileCount":4,"unpackedSize":5164,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCQ5KlbmAp+vgcQmAj7cbXITwD+wbTvE2J5p9nNTqJB9QIhAJ0zNKPaOb0M8B/OPif4LjXmW/KAHfLuieOn7ZbdmH4q"}]},"_npmUser":{"name":"scriptpower","email":"scriptpower@qq.com"},"directories":{},"maintainers":[{"name":"scriptpower","email":"scriptpower@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/machine-id_1.1.0_1742446902177_0.24778076810597183"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-20T05:01:42.027Z","1.1.0":"2025-03-20T05:01:42.362Z","modified":"2025-03-20T05:01:42.732Z"},"maintainers":[{"name":"scriptpower","email":"scriptpower@qq.com"}],"description":"Cross-platform unique machine (desktop) id discovery","license":"MIT","readme":"# @1n/machine-id\n\n> Cross-platform unique machine (desktop) id discovery.\n\n## Use cases\n\n- Software restrictions\n- Installation tracking\n\n## Features\n\n- Hardware independent\n- Unique within the OS installation\n- No elevated rights required\n- No external dependencies and does not require any native bindings\n- Cross-platform (OSx, Win, Linux)\n\n## How it works\n\nModule based on OS native UUID/GUID which used for internal needs.\n\nAll others approaches requires elevated rights or much depends on hardware components, but this approach summarize the methods of selecting the most reliable unique identifier\n\n- **Win32/64** uses key `MachineGuid` in registry `HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography` **(can be changed by administrator but with unpredictable consequences)**\n\n> It is generated during OS installation and won't change unless you make another OS\n> updates or reinstall. Depending on the OS version it may contain the network adapter\n> MAC address embedded (plus some other numbers, including random), or a pseudorandom number.\n\n- **OSx** uses `IOPlatformUUID` (the same Hardware UUID) `ioreg -rd1 -c IOPlatformExpertDevice`\n\n> Value from I/O Kit registry in IOPlatformExpertDevice class\n\n- **Linux** uses `/var/lib/dbus/machine-id` **(can be changed by `root` but with unpredictable consequences)**\n[http://man7.org/linux/man-pages/man5/machine-id.5.html](http://man7.org/linux/man-pages/man5/machine-id.5.html)\n\n> The /var/lib/dbus/machine-id file contains the unique machine ID of the local\n> system that is set during installation. The machine ID is a single\n> newline-terminated, hexadecimal, 32-character, lowercase machine ID\n> string. When decoded from hexadecimal, this corresponds with a\n> 16-byte/128-bit string.\n>\n> The machine ID is usually generated from a random source during\n> system installation and stays constant for all subsequent boots.\n> Optionally, for stateless systems, it is generated during runtime at\n> early boot if it is found to be empty.\n>\n> The machine ID does not change based on user configuration or when\n> hardware is replaced.\n\n## Installation\n\n```bash\nnpm install @1n/machine-id\n```\n\n## Usage\n\n### machineId( original? )\n\n- **original** `<Boolean>`, If `true` return original value of machine id, otherwise return hashed value (sha-256), default: `false`\n\n### machineIdSync( original? )\n\n- synchronous version of `machineId`\n\n```js\nimport { machineId, machineIdSync } from '@1n/machine-id';\n\n// Asynchronous call with async/await or Promise\n\nasync function getMachineId() {\n    let id = await machineId();\n    ...\n}\n\nmachineId().then((id) => {\n    ...\n})\n\n// Synchronous call\n\nlet id = machineIdSync()\n// id = c24b0fe51856497eebb6a2bfcd120247aac0d6334d670bb92e09a00ce8169365\nlet id = machineIdSync(true)\n// id = 98912984-c4e9-5ceb-8000-03882a0485e4\n```\n","readmeFilename":"README.md","_rev":"1-e3b2dc1c35baa97ea05e4d7c8e0a59e8"}