{"id":13547545,"url":"https://github.com/automation-stack/node-machine-id","last_synced_at":"2025-05-14T16:01:47.914Z","repository":{"id":39420077,"uuid":"63163136","full_name":"automation-stack/node-machine-id","owner":"automation-stack","description":"Unique machine (desktop) id (no admin privileges required)","archived":false,"fork":false,"pushed_at":"2024-08-27T20:03:58.000Z","size":66,"stargazers_count":581,"open_issues_count":26,"forks_count":61,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-29T17:43:23.833Z","etag":null,"topics":["electron","id","machine-id","node"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/automation-stack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-12T14:07:22.000Z","updated_at":"2024-10-29T09:06:26.000Z","dependencies_parsed_at":"2024-11-11T10:04:43.367Z","dependency_job_id":"8c1dc6a6-cb55-44fb-825c-be16807e6f27","html_url":"https://github.com/automation-stack/node-machine-id","commit_stats":{"total_commits":57,"total_committers":11,"mean_commits":5.181818181818182,"dds":0.2807017543859649,"last_synced_commit":"f580f9f20668582e9087d92cea2511c972f2e6aa"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/automation-stack%2Fnode-machine-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/automation-stack%2Fnode-machine-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/automation-stack%2Fnode-machine-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/automation-stack%2Fnode-machine-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/automation-stack","download_url":"https://codeload.github.com/automation-stack/node-machine-id/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154994,"owners_count":21056542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electron","id","machine-id","node"],"created_at":"2024-08-01T12:00:57.762Z","updated_at":"2025-04-10T03:48:49.706Z","avatar_url":"https://github.com/automation-stack.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"**Cross-platform unique machine (desktop) id discovery**\n\n\n## Use cases\n- Software restrictions\n- Installation tracking\n\n## Features\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\n**All 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\n```HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography``` **(can be changed by administrator but with unpredictable consequences)**\n\u003e   It is generated during OS installation and won't change unless you make another OS\n\u003e   updates or reinstall. Depending on the OS version it may contain the network adapter\n\u003e   MAC address embedded (plus some other numbers, including random), or a pseudorandom number.\n\n- **OSx** uses ```IOPlatformUUID``` (the same Hardware UUID)\n``` ioreg -rd1 -c IOPlatformExpertDevice ```\n\u003e   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)**\nhttp://man7.org/linux/man-pages/man5/machine-id.5.html\n\u003e   The /var/lib/dbus/machine-id file contains the unique machine ID of the local\n\u003e   system that is set during installation. The machine ID is a single\n\u003e   newline-terminated, hexadecimal, 32-character, lowercase machine ID\n\u003e   string. When decoded from hexadecimal, this corresponds with a\n\u003e   16-byte/128-bit string.\n\u003e\n\u003e   The machine ID is usually generated from a random source during\n\u003e   system installation and stays constant for all subsequent boots.\n\u003e   Optionally, for stateless systems, it is generated during runtime at\n\u003e   early boot if it is found to be empty.\n\u003e\n\u003e   The machine ID does not change based on user configuration or when\n\u003e   hardware is replaced.\n\n\n## Installation\n```\nnpm install node-machine-id\n```\n\n## Usage\n### Function: machineId(original)\n- **original** ```\u003cBoolean\u003e```, If ```true``` return original value of machine id, otherwise return hashed value (sha-256), default: ```false```\n\n### Function: machineIdSync(original);\n- syncronous version of ```machineId```\n\n```js\nimport {machineId, machineIdSync} from 'node-machine-id';\n\n// Asyncronous call with async/await or Promise\n\nasync function getMachineId() {\n    let id = await machineId();\n    ...\n}\n\nmachineId().then((id) =\u003e {\n    ...\n})\n\n// Syncronous call\n\nlet id = machineIdSync()\n// id = c24b0fe51856497eebb6a2bfcd120247aac0d6334d670bb92e09a00ce8169365\nlet id = machineIdSync(true)\n// id = 98912984-c4e9-5ceb-8000-03882a0485e4\n```\n### Caveats\n\n- Image-based environments have usually the same `machine-id`\n\u003e As a workaround you can generate new machine-ids for each instance (or container) with `dbus-uuidgen` and changed them in the respective \u003e files: `/etc/machine-id` and `/var/lib/dbus/machine-id`. Thanks [@stefanhuber](https://github.com/stefanhuber)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautomation-stack%2Fnode-machine-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fautomation-stack%2Fnode-machine-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautomation-stack%2Fnode-machine-id/lists"}