From e9c90749f36464d1c8f2b4336621213439e41c25 Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 10:27:37 +0200 Subject: [PATCH 01/19] feat: add a native device ID library --- package-lock.json | 434 +++++++++++++++++++++++++- packages/machine-id/.gitignore | 25 ++ packages/machine-id/LICENSE | 192 ++++++++++++ packages/machine-id/README.md | 63 ++++ packages/machine-id/bin/machine-id.js | 3 + packages/machine-id/binding.cc | 69 ++++ packages/machine-id/binding.gyp | 29 ++ packages/machine-id/index.d.ts | 7 + packages/machine-id/index.js | 3 + packages/machine-id/package.json | 47 +++ packages/machine-id/test/index.js | 34 ++ 11 files changed, 900 insertions(+), 6 deletions(-) create mode 100644 packages/machine-id/.gitignore create mode 100644 packages/machine-id/LICENSE create mode 100644 packages/machine-id/README.md create mode 100644 packages/machine-id/bin/machine-id.js create mode 100644 packages/machine-id/binding.cc create mode 100644 packages/machine-id/binding.gyp create mode 100644 packages/machine-id/index.d.ts create mode 100644 packages/machine-id/index.js create mode 100644 packages/machine-id/package.json create mode 100644 packages/machine-id/test/index.js diff --git a/package-lock.json b/package-lock.json index 8425fea3..d3faa90b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10087,7 +10087,6 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "devOptional": true, "dependencies": { "file-uri-to-path": "1.0.0" } @@ -14339,8 +14338,7 @@ "node_modules/file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "devOptional": true + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" }, "node_modules/filelist": { "version": "1.0.4", @@ -19406,6 +19404,10 @@ "lz-string": "bin/bin.js" } }, + "node_modules/machine-id": { + "resolved": "packages/machine-id", + "link": true + }, "node_modules/macos-export-certificate-and-key": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/macos-export-certificate-and-key/-/macos-export-certificate-and-key-1.2.2.tgz", @@ -21198,6 +21200,13 @@ "string-width": "^1.0.2 || 2 || 3 || 4" } }, + "node_modules/node-machine-id": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/node-machine-id/-/node-machine-id-1.1.12.tgz", + "integrity": "sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ==", + "dev": true, + "license": "MIT" + }, "node_modules/node-preload": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", @@ -28124,6 +28133,247 @@ "node": ">=14.17" } }, + "packages/machine-id": { + "version": "1.0.0", + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "bindings": "^1.5.0", + "node-addon-api": "^8.0.0" + }, + "devDependencies": { + "gen-esm-wrapper": "^1.1.1", + "mocha": "^10.4.0", + "node-machine-id": "^1.1.12" + } + }, + "packages/machine-id/node_modules/ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "packages/machine-id/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "packages/machine-id/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "packages/machine-id/node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "packages/machine-id/node_modules/diff": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "packages/machine-id/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "packages/machine-id/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "packages/machine-id/node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/machine-id/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "packages/machine-id/node_modules/mocha": { + "version": "10.8.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz", + "integrity": "sha512-VZlYo/WE8t1tstuRmqgeyBgCbJc/lEdopaa+axcKzTBJ+UIdlAB9XnmvTCAH4pwR4ElNInaedhEBmZD8iCSVEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", + "chokidar": "^3.5.3", + "debug": "^4.3.5", + "diff": "^5.2.0", + "escape-string-regexp": "^4.0.0", + "find-up": "^5.0.0", + "glob": "^8.1.0", + "he": "^1.2.0", + "js-yaml": "^4.1.0", + "log-symbols": "^4.1.0", + "minimatch": "^5.1.6", + "ms": "^2.1.3", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", + "supports-color": "^8.1.1", + "workerpool": "^6.5.1", + "yargs": "^16.2.0", + "yargs-parser": "^20.2.9", + "yargs-unparser": "^2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + } + }, + "packages/machine-id/node_modules/node-addon-api": { + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.3.1.tgz", + "integrity": "sha512-lytcDEdxKjGJPTLEfW4mYMigRezMlyJY8W4wxJK8zE533Jlb8L8dRuObJFWg2P+AuOIxoCgKF+2Oq4d4Zd0OUA==", + "license": "MIT", + "engines": { + "node": "^18 || ^20 || >= 21" + } + }, + "packages/machine-id/node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "packages/machine-id/node_modules/serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "packages/machine-id/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "packages/machine-id/node_modules/workerpool": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", + "dev": true, + "license": "Apache-2.0" + }, + "packages/machine-id/node_modules/yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, "packages/mongodb-cloud-info": { "version": "2.1.7", "license": "Apache-2.0", @@ -38487,7 +38737,6 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "devOptional": true, "requires": { "file-uri-to-path": "1.0.0" } @@ -41626,8 +41875,7 @@ "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "devOptional": true + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" }, "filelist": { "version": "1.0.4", @@ -45380,6 +45628,174 @@ "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", "dev": true }, + "machine-id": { + "version": "file:packages/machine-id", + "requires": { + "bindings": "^1.5.0", + "gen-esm-wrapper": "^1.1.1", + "mocha": "^10.4.0", + "node-addon-api": "^8.0.0", + "node-machine-id": "^1.1.12" + }, + "dependencies": { + "ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "dev": true + }, + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + } + }, + "diff": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", + "dev": true + }, + "glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + } + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "requires": { + "argparse": "^2.0.1" + } + }, + "log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "requires": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + } + }, + "minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "mocha": { + "version": "10.8.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz", + "integrity": "sha512-VZlYo/WE8t1tstuRmqgeyBgCbJc/lEdopaa+axcKzTBJ+UIdlAB9XnmvTCAH4pwR4ElNInaedhEBmZD8iCSVEg==", + "dev": true, + "requires": { + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", + "chokidar": "^3.5.3", + "debug": "^4.3.5", + "diff": "^5.2.0", + "escape-string-regexp": "^4.0.0", + "find-up": "^5.0.0", + "glob": "^8.1.0", + "he": "^1.2.0", + "js-yaml": "^4.1.0", + "log-symbols": "^4.1.0", + "minimatch": "^5.1.6", + "ms": "^2.1.3", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", + "supports-color": "^8.1.1", + "workerpool": "^6.5.1", + "yargs": "^16.2.0", + "yargs-parser": "^20.2.9", + "yargs-unparser": "^2.0.0" + } + }, + "node-addon-api": { + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.3.1.tgz", + "integrity": "sha512-lytcDEdxKjGJPTLEfW4mYMigRezMlyJY8W4wxJK8zE533Jlb8L8dRuObJFWg2P+AuOIxoCgKF+2Oq4d4Zd0OUA==" + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, + "serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "workerpool": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", + "dev": true + }, + "yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true + } + } + }, "macos-export-certificate-and-key": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/macos-export-certificate-and-key/-/macos-export-certificate-and-key-1.2.2.tgz", @@ -46944,6 +47360,12 @@ "integrity": "sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==", "dev": true }, + "node-machine-id": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/node-machine-id/-/node-machine-id-1.1.12.tgz", + "integrity": "sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ==", + "dev": true + }, "node-preload": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", diff --git a/packages/machine-id/.gitignore b/packages/machine-id/.gitignore new file mode 100644 index 00000000..e3c4e1eb --- /dev/null +++ b/packages/machine-id/.gitignore @@ -0,0 +1,25 @@ +.DS_Store +.lock-wscript +.idea/ +.vscode/ +*.iml +.nvmrc +.nyc_output +*.swp +lerna-debug.log +lib-cov +npm-debug.log +.idea/ +coverage/ +dist/ +node_modules/ +.lock-wscript +.cache/ +expansions.yaml +tmp/expansions.yaml +.evergreen/mongodb +tmp/ +.esm-wrapper.mjs +package-lock.json +build/ +crash.log \ No newline at end of file diff --git a/packages/machine-id/LICENSE b/packages/machine-id/LICENSE new file mode 100644 index 00000000..7502810f --- /dev/null +++ b/packages/machine-id/LICENSE @@ -0,0 +1,192 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2024 MongoDB Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/packages/machine-id/README.md b/packages/machine-id/README.md new file mode 100644 index 00000000..ec6a0630 --- /dev/null +++ b/packages/machine-id/README.md @@ -0,0 +1,63 @@ +# @mongodb-js/machine-id + +[![npm](https://img.shields.io/npm/v/@mongodb-js/machine-id.svg)](https://www.npmjs.com/package/@mongodb-js/machine-id) + +A native Node.js module to retrieve the unique machine ID across different operating systems. + +## Installation + +``` +npm install @mongodb-js/machine-id +``` + +Or use it directly in the CLI + +``` +npx @mongodb-js/machine-id +``` + +## Usage + +### As a module + +```javascript +const getMachineID = require('@mongodb-js/machine-id'); + +// Get the machine ID +const id = getMachineID(); +console.log('Machine ID:', id); +``` + +### As a CLI + +After installing globally, run: + +``` +machine-id +``` + +This will print the machine ID to the console. + +## Supported Platforms + +- **macOS**: Retrieves the IOPlatformUUID using the IOKit framework +- **Linux**: Support for Linux planned in future releases +- **Windows**: Support for Windows planned in future releases + +## Implementation Details + +The module uses native OS-specific APIs to retrieve the machine ID: + +- On macOS, it uses the IOKit framework to access the IOPlatformUUID, which uniquely identifies the machine. + +## Comparison with node-machine-id + +This module provides similar functionality to [node-machine-id](https://www.npmjs.com/package/node-machine-id), but with: + +- Simplified API focused on getting the raw machine ID +- Direct native access to system APIs without shell commands +- Optimized for use in MongoDB tools + +## License + +Apache-2.0 diff --git a/packages/machine-id/bin/machine-id.js b/packages/machine-id/bin/machine-id.js new file mode 100644 index 00000000..7e98456c --- /dev/null +++ b/packages/machine-id/bin/machine-id.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node +const getMachineID = require(".."); +console.log(getMachineID() || "Machine ID not available on this platform"); diff --git a/packages/machine-id/binding.cc b/packages/machine-id/binding.cc new file mode 100644 index 00000000..ae35cc94 --- /dev/null +++ b/packages/machine-id/binding.cc @@ -0,0 +1,69 @@ +#include +#include + +#ifdef __APPLE__ +#include +#include +#endif + +using namespace Napi; + +namespace +{ + +#ifdef __APPLE__ + // Get macOS machine ID using IOKit framework directly + std::string getMachineId() + { + std::string uuid; + io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMainPortDefault, "IOService:/"); + + if (ioRegistryRoot == MACH_PORT_NULL) + { + return ""; + } + + CFStringRef uuidKey = CFSTR("IOPlatformUUID"); + CFTypeRef uuidProperty = IORegistryEntryCreateCFProperty(ioRegistryRoot, uuidKey, kCFAllocatorDefault, 0); + + if (uuidProperty) + { + char buffer[128]; + if (CFStringGetCString((CFStringRef)uuidProperty, buffer, sizeof(buffer), kCFStringEncodingUTF8)) + { + uuid = buffer; + } + CFRelease(uuidProperty); + } + + IOObjectRelease(ioRegistryRoot); + return uuid; + } +#endif + + // Function to get the machine ID + Value GetMachineId(const CallbackInfo &args) + { + Env env = args.Env(); + +#ifdef __APPLE__ + std::string id = getMachineId(); + if (!id.empty()) + { + return String::New(env, id); + } +#endif + + // If we couldn't get a machine ID or platform not supported + return env.Undefined(); + } + +} + +static Object InitModule(Env env, Object exports) +{ + exports["getMachineId"] = Function::New(env, GetMachineId); + return exports; +} + +NODE_API_MODULE(machine_id, InitModule) diff --git a/packages/machine-id/binding.gyp b/packages/machine-id/binding.gyp new file mode 100644 index 00000000..8d530ceb --- /dev/null +++ b/packages/machine-id/binding.gyp @@ -0,0 +1,29 @@ +{ + 'targets': [{ + 'target_name': 'machine_id', + 'sources': [ 'binding.cc' ], + 'include_dirs': ["", + "gypfile": true, + "dependencies": { + "bindings": "^1.5.0", + "node-addon-api": "^8.0.0" + }, + "license": "Apache-2.0", + "exports": { + "require": "./index.js", + "import": "./.esm-wrapper.mjs" + }, + "homepage": "https://github.com/mongodb-js/devtools-shared", + "repository": { + "type": "git", + "url": "https://github.com/mongodb-js/devtools-shared.git" + }, + "bugs": "https://jira.mongodb.org/projects/COMPASS/issues", + "typings": "index.d.ts", + "files": [ + "binding.cc", + "binding.gyp", + "index.d.ts", + "index.js", + "bin/machine-id.js", + "LICENSE", + ".esm-wrapper.mjs" + ], + "bin": { + "machine-id": "bin/machine-id.js" + }, + "devDependencies": { + "gen-esm-wrapper": "^1.1.1", + "mocha": "^10.4.0", + "node-machine-id": "^1.1.12" + } +} diff --git a/packages/machine-id/test/index.js b/packages/machine-id/test/index.js new file mode 100644 index 00000000..524785f0 --- /dev/null +++ b/packages/machine-id/test/index.js @@ -0,0 +1,34 @@ +"use strict"; +const assert = require("assert"); +const getMachineId = require(".."); +const { machineId, machineIdSync } = require("node-machine-id"); + +describe("machine-id", function () { + this.timeout(5000); + + it("returns a non-empty machine ID", function () { + const id = getMachineId(); + assert.strictEqual(typeof id, "string"); + assert.ok(id.length > 0, "Machine ID should not be empty"); + }); + + it("returns a valid UUID format", function () { + const id = getMachineId(); + // UUID format: 8-4-4-4-12 hex digits + const uuidRegex = + /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; + assert.ok(uuidRegex.test(id), `Expected UUID format, got: ${id}`); + }); + + it("compares with node-machine-id", function () { + const ourId = getMachineId(); + // Machine ID from node-machine-id may be lowercase + const nodeId = machineIdSync(true).toUpperCase(); + + console.log("Our machine ID:", ourId); + console.log("node-machine-id:", nodeId); + + assert.ok(ourId, "Our implementation should return a machine ID"); + assert.ok(nodeId, "node-machine-id should return a machine ID"); + }); +}); From ca4b94473ce62d85138a684be4ded28e6b659baf Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 11:19:11 +0200 Subject: [PATCH 02/19] test: add tests --- package-lock.json | 985 ++++++++++++++++++++----- packages/machine-id/.eslintrc.js | 8 + packages/machine-id/.mocharc.js | 1 + packages/machine-id/package.json | 43 +- packages/machine-id/src/bindings.d.ts | 4 + packages/machine-id/src/index.spec.ts | 57 ++ packages/machine-id/src/index.ts | 19 + packages/machine-id/test/index.js | 34 - packages/machine-id/tsconfig-lint.json | 5 + packages/machine-id/tsconfig.json | 8 + 10 files changed, 941 insertions(+), 223 deletions(-) create mode 100644 packages/machine-id/.eslintrc.js create mode 100644 packages/machine-id/.mocharc.js create mode 100644 packages/machine-id/src/bindings.d.ts create mode 100644 packages/machine-id/src/index.spec.ts create mode 100644 packages/machine-id/src/index.ts delete mode 100644 packages/machine-id/test/index.js create mode 100644 packages/machine-id/tsconfig-lint.json create mode 100644 packages/machine-id/tsconfig.json diff --git a/package-lock.json b/package-lock.json index d3faa90b..492a7c9e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2327,6 +2327,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@eslint/js": { + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", + "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/@gar/promisify": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", @@ -2346,6 +2356,20 @@ "node": ">=10.10.0" } }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@humanwhocodes/object-schema": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", @@ -6998,6 +7022,10 @@ "resolved": "packages/get-os-info", "link": true }, + "node_modules/@mongodb-js/machine-id": { + "resolved": "packages/machine-id", + "link": true + }, "node_modules/@mongodb-js/mocha-config-devtools": { "resolved": "configs/mocha-config-devtools", "link": true @@ -8945,6 +8973,13 @@ "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", "dev": true }, + "node_modules/@ungap/structured-clone": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz", + "integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==", + "dev": true, + "license": "ISC" + }, "node_modules/@vue/compiler-core": { "version": "3.5.13", "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.13.tgz", @@ -16876,6 +16911,16 @@ "node": ">=8" } }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/is-plain-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", @@ -19404,10 +19449,6 @@ "lz-string": "bin/bin.js" } }, - "node_modules/machine-id": { - "resolved": "packages/machine-id", - "link": true - }, "node_modules/macos-export-certificate-and-key": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/macos-export-certificate-and-key/-/macos-export-certificate-and-key-1.2.2.tgz", @@ -28134,6 +28175,7 @@ } }, "packages/machine-id": { + "name": "@mongodb-js/machine-id", "version": "1.0.0", "hasInstallScript": true, "license": "Apache-2.0", @@ -28141,10 +28183,143 @@ "bindings": "^1.5.0", "node-addon-api": "^8.0.0" }, + "bin": { + "machine-id": "lib/bin/machine-id.js" + }, "devDependencies": { + "@mongodb-js/eslint-config-devtools": "0.9.11", + "@mongodb-js/mocha-config-devtools": "^1.0.5", + "@mongodb-js/prettier-config-devtools": "^1.0.2", + "@mongodb-js/tsconfig-devtools": "^1.0.3", + "@types/chai": "^4.2.21", + "@types/mocha": "^9.1.1", + "@types/node": "^20.10.0", + "@types/sinon-chai": "^3.2.5", + "chai": "^4.5.0", + "eslint": "^8.0.0", "gen-esm-wrapper": "^1.1.1", "mocha": "^10.4.0", - "node-machine-id": "^1.1.12" + "node-machine-id": "^1.1.12", + "typescript": "^5.0.0" + } + }, + "packages/machine-id/node_modules/@eslint/eslintrc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.6.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "packages/machine-id/node_modules/@eslint/eslintrc/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "packages/machine-id/node_modules/@eslint/eslintrc/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "packages/machine-id/node_modules/@humanwhocodes/config-array": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", + "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", + "deprecated": "Use @eslint/config-array instead", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanwhocodes/object-schema": "^2.0.3", + "debug": "^4.3.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "packages/machine-id/node_modules/@humanwhocodes/config-array/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "packages/machine-id/node_modules/@humanwhocodes/config-array/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "packages/machine-id/node_modules/@humanwhocodes/object-schema": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "deprecated": "Use @eslint/object-schema instead", + "dev": true, + "license": "BSD-3-Clause" + }, + "packages/machine-id/node_modules/@types/node": { + "version": "20.17.30", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.30.tgz", + "integrity": "sha512-7zf4YyHA+jvBNfVrk2Gtvs6x7E8V+YDW05bNfG2XkWDJfYRXrTiP/DsB2zSYTaHX0bGIujTBQdMVAhb+j7mwpg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.19.2" + } + }, + "packages/machine-id/node_modules/acorn": { + "version": "8.14.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", + "integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" } }, "packages/machine-id/node_modules/ansi-colors": { @@ -28209,6 +28384,158 @@ "node": ">=0.3.1" } }, + "packages/machine-id/node_modules/eslint": { + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", + "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", + "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.1", + "@humanwhocodes/config-array": "^0.13.0", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "packages/machine-id/node_modules/eslint-scope": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "packages/machine-id/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "packages/machine-id/node_modules/eslint/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "packages/machine-id/node_modules/eslint/node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "packages/machine-id/node_modules/eslint/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "packages/machine-id/node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "packages/machine-id/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, "packages/machine-id/node_modules/glob": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", @@ -28230,6 +28557,22 @@ "url": "https://github.com/sponsors/isaacs" } }, + "packages/machine-id/node_modules/globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "packages/machine-id/node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -28357,6 +28700,40 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, + "packages/machine-id/node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/machine-id/node_modules/typescript": { + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "packages/machine-id/node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "dev": true, + "license": "MIT" + }, "packages/machine-id/node_modules/workerpool": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", @@ -31411,6 +31788,12 @@ } } }, + "@eslint/js": { + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", + "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", + "dev": true + }, "@gar/promisify": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", @@ -31427,6 +31810,12 @@ "minimatch": "^3.0.4" } }, + "@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true + }, "@humanwhocodes/object-schema": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", @@ -35588,6 +35977,412 @@ } } }, + "@mongodb-js/machine-id": { + "version": "file:packages/machine-id", + "requires": { + "@mongodb-js/eslint-config-devtools": "0.9.11", + "@mongodb-js/mocha-config-devtools": "^1.0.5", + "@mongodb-js/prettier-config-devtools": "^1.0.2", + "@mongodb-js/tsconfig-devtools": "^1.0.3", + "@types/chai": "^4.2.21", + "@types/mocha": "^9.1.1", + "@types/node": "^20.10.0", + "@types/sinon-chai": "^3.2.5", + "bindings": "^1.5.0", + "chai": "^4.5.0", + "eslint": "^8.0.0", + "gen-esm-wrapper": "^1.1.1", + "mocha": "^10.4.0", + "node-addon-api": "^8.0.0", + "node-machine-id": "^1.1.12", + "typescript": "^5.0.0" + }, + "dependencies": { + "@eslint/eslintrc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "dev": true, + "requires": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.6.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "dependencies": { + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } + } + }, + "@humanwhocodes/config-array": { + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", + "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", + "dev": true, + "requires": { + "@humanwhocodes/object-schema": "^2.0.3", + "debug": "^4.3.1", + "minimatch": "^3.0.5" + }, + "dependencies": { + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } + } + }, + "@humanwhocodes/object-schema": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "dev": true + }, + "@types/node": { + "version": "20.17.30", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.30.tgz", + "integrity": "sha512-7zf4YyHA+jvBNfVrk2Gtvs6x7E8V+YDW05bNfG2XkWDJfYRXrTiP/DsB2zSYTaHX0bGIujTBQdMVAhb+j7mwpg==", + "dev": true, + "requires": { + "undici-types": "~6.19.2" + } + }, + "acorn": { + "version": "8.14.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", + "integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==", + "dev": true + }, + "ansi-colors": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", + "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", + "dev": true + }, + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + } + }, + "diff": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", + "dev": true + }, + "eslint": { + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", + "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.1", + "@humanwhocodes/config-array": "^0.13.0", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "dependencies": { + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "requires": { + "is-glob": "^4.0.3" + } + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } + } + }, + "eslint-scope": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + } + }, + "eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true + }, + "espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "requires": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + } + }, + "estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true + }, + "glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + } + }, + "globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" + } + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "requires": { + "argparse": "^2.0.1" + } + }, + "log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "requires": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + } + }, + "minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "mocha": { + "version": "10.8.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz", + "integrity": "sha512-VZlYo/WE8t1tstuRmqgeyBgCbJc/lEdopaa+axcKzTBJ+UIdlAB9XnmvTCAH4pwR4ElNInaedhEBmZD8iCSVEg==", + "dev": true, + "requires": { + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", + "chokidar": "^3.5.3", + "debug": "^4.3.5", + "diff": "^5.2.0", + "escape-string-regexp": "^4.0.0", + "find-up": "^5.0.0", + "glob": "^8.1.0", + "he": "^1.2.0", + "js-yaml": "^4.1.0", + "log-symbols": "^4.1.0", + "minimatch": "^5.1.6", + "ms": "^2.1.3", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", + "supports-color": "^8.1.1", + "workerpool": "^6.5.1", + "yargs": "^16.2.0", + "yargs-parser": "^20.2.9", + "yargs-unparser": "^2.0.0" + } + }, + "node-addon-api": { + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.3.1.tgz", + "integrity": "sha512-lytcDEdxKjGJPTLEfW4mYMigRezMlyJY8W4wxJK8zE533Jlb8L8dRuObJFWg2P+AuOIxoCgKF+2Oq4d4Zd0OUA==" + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "requires": { + "picomatch": "^2.2.1" + } + }, + "serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true + }, + "typescript": { + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", + "dev": true + }, + "undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "dev": true + }, + "workerpool": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", + "dev": true + }, + "yargs-parser": { + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", + "dev": true + } + } + }, "@mongodb-js/mocha-config-devtools": { "version": "file:configs/mocha-config-devtools", "requires": { @@ -37844,6 +38639,12 @@ "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", "dev": true }, + "@ungap/structured-clone": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz", + "integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==", + "dev": true + }, "@vue/compiler-core": { "version": "3.5.13", "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.13.tgz", @@ -43715,6 +44516,12 @@ "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", "dev": true }, + "is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true + }, "is-plain-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", @@ -45628,174 +46435,6 @@ "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", "dev": true }, - "machine-id": { - "version": "file:packages/machine-id", - "requires": { - "bindings": "^1.5.0", - "gen-esm-wrapper": "^1.1.1", - "mocha": "^10.4.0", - "node-addon-api": "^8.0.0", - "node-machine-id": "^1.1.12" - }, - "dependencies": { - "ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", - "dev": true - }, - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0" - } - }, - "chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", - "dev": true, - "requires": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "fsevents": "~2.3.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - } - }, - "diff": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", - "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", - "dev": true - }, - "glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - } - }, - "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "requires": { - "argparse": "^2.0.1" - } - }, - "log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "requires": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - } - }, - "minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dev": true, - "requires": { - "brace-expansion": "^2.0.1" - } - }, - "mocha": { - "version": "10.8.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz", - "integrity": "sha512-VZlYo/WE8t1tstuRmqgeyBgCbJc/lEdopaa+axcKzTBJ+UIdlAB9XnmvTCAH4pwR4ElNInaedhEBmZD8iCSVEg==", - "dev": true, - "requires": { - "ansi-colors": "^4.1.3", - "browser-stdout": "^1.3.1", - "chokidar": "^3.5.3", - "debug": "^4.3.5", - "diff": "^5.2.0", - "escape-string-regexp": "^4.0.0", - "find-up": "^5.0.0", - "glob": "^8.1.0", - "he": "^1.2.0", - "js-yaml": "^4.1.0", - "log-symbols": "^4.1.0", - "minimatch": "^5.1.6", - "ms": "^2.1.3", - "serialize-javascript": "^6.0.2", - "strip-json-comments": "^3.1.1", - "supports-color": "^8.1.1", - "workerpool": "^6.5.1", - "yargs": "^16.2.0", - "yargs-parser": "^20.2.9", - "yargs-unparser": "^2.0.0" - } - }, - "node-addon-api": { - "version": "8.3.1", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.3.1.tgz", - "integrity": "sha512-lytcDEdxKjGJPTLEfW4mYMigRezMlyJY8W4wxJK8zE533Jlb8L8dRuObJFWg2P+AuOIxoCgKF+2Oq4d4Zd0OUA==" - }, - "readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "requires": { - "picomatch": "^2.2.1" - } - }, - "serialize-javascript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", - "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", - "dev": true, - "requires": { - "randombytes": "^2.1.0" - } - }, - "supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "workerpool": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", - "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", - "dev": true - }, - "yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "dev": true - } - } - }, "macos-export-certificate-and-key": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/macos-export-certificate-and-key/-/macos-export-certificate-and-key-1.2.2.tgz", diff --git a/packages/machine-id/.eslintrc.js b/packages/machine-id/.eslintrc.js new file mode 100644 index 00000000..70d48211 --- /dev/null +++ b/packages/machine-id/.eslintrc.js @@ -0,0 +1,8 @@ +module.exports = { + root: true, + extends: ["@mongodb-js/eslint-config-devtools"], + parserOptions: { + tsconfigRootDir: __dirname, + project: ["./tsconfig-lint.json"], + }, +}; diff --git a/packages/machine-id/.mocharc.js b/packages/machine-id/.mocharc.js new file mode 100644 index 00000000..64afeb1f --- /dev/null +++ b/packages/machine-id/.mocharc.js @@ -0,0 +1 @@ +module.exports = require('@mongodb-js/mocha-config-devtools'); diff --git a/packages/machine-id/package.json b/packages/machine-id/package.json index 6b788251..c9a09a0c 100644 --- a/packages/machine-id/package.json +++ b/packages/machine-id/package.json @@ -2,12 +2,16 @@ "name": "@mongodb-js/machine-id", "version": "1.0.0", "description": "Cross-platform native module to retrieve machine/device identifiers", - "main": "index.js", + "main": "lib/index.js", + "types": "lib/index.d.ts", "scripts": { - "pretest": "npm run build", + "compile": "tsc -p tsconfig.json && node-gyp rebuild && gen-esm-wrapper . ./dist/.esm-wrapper.mjs", + "bootstrap": "npm run compile", + "pretest": "npm run compile", "test": "mocha", - "prepack": "npm run build", - "build": "node-gyp rebuild && gen-esm-wrapper . ./.esm-wrapper.mjs" + "lint": "eslint \"**/*.{js,ts}\"", + "check": "npm run lint && npm run test", + "prepublishOnly": "npm run compile" }, "author": "Compass Team ", "gypfile": true, @@ -17,8 +21,8 @@ }, "license": "Apache-2.0", "exports": { - "require": "./index.js", - "import": "./.esm-wrapper.mjs" + "require": "./lib/index.js", + "import": "./lib/.esm-wrapper.mjs" }, "homepage": "https://github.com/mongodb-js/devtools-shared", "repository": { @@ -26,22 +30,29 @@ "url": "https://github.com/mongodb-js/devtools-shared.git" }, "bugs": "https://jira.mongodb.org/projects/COMPASS/issues", - "typings": "index.d.ts", + "bin": { + "machine-id": "lib/bin/machine-id.js" + }, "files": [ "binding.cc", "binding.gyp", - "index.d.ts", - "index.js", - "bin/machine-id.js", - "LICENSE", - ".esm-wrapper.mjs" + "lib", + "LICENSE" ], - "bin": { - "machine-id": "bin/machine-id.js" - }, "devDependencies": { + "@mongodb-js/eslint-config-devtools": "0.9.11", + "@mongodb-js/mocha-config-devtools": "^1.0.5", + "@mongodb-js/prettier-config-devtools": "^1.0.2", + "@mongodb-js/tsconfig-devtools": "^1.0.3", + "@types/chai": "^4.2.21", + "@types/mocha": "^9.1.1", + "@types/sinon-chai": "^3.2.5", + "@types/node": "^20.10.0", + "eslint": "^8.0.0", "gen-esm-wrapper": "^1.1.1", "mocha": "^10.4.0", - "node-machine-id": "^1.1.12" + "chai": "^4.5.0", + "node-machine-id": "^1.1.12", + "typescript": "^5.0.0" } } diff --git a/packages/machine-id/src/bindings.d.ts b/packages/machine-id/src/bindings.d.ts new file mode 100644 index 00000000..77a93b1c --- /dev/null +++ b/packages/machine-id/src/bindings.d.ts @@ -0,0 +1,4 @@ +declare module 'bindings' { + function bindings(filename: string): any; + export = bindings; +} \ No newline at end of file diff --git a/packages/machine-id/src/index.spec.ts b/packages/machine-id/src/index.spec.ts new file mode 100644 index 00000000..62ddbe5e --- /dev/null +++ b/packages/machine-id/src/index.spec.ts @@ -0,0 +1,57 @@ +import { getMachineId } from "."; +import { machineIdSync as otherMachineId } from "node-machine-id"; +import { expect } from "chai"; +import { createHash } from "crypto"; + +describe("machine-id", function () { + this.timeout(5_000); + + describe("without hashing", function () { + let id: string; + + beforeEach(function () { + id = getMachineId(true); + }); + + it("returns a valid UUID format machine ID", function () { + // UUID format: 8-4-4-4-12 hex digits + const uuidRegex = + /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; + + expect(uuidRegex.test(id)); + }); + + it("is consistent with node-machine-id", function () { + const nodeId = otherMachineId(true); + + // node-machine-id returns a lowercase ID + expect(id.toLowerCase()).to.equal(nodeId); + }); + + it("can reproduce the hashed node-machine-id value", function () { + const nodeId = otherMachineId(); + + // Compare the lowercase workaround for consistency with node-machine-id + const hashedId = createHash("sha256") + .update(id.toLowerCase()) + .digest("hex"); + + expect(hashedId).to.equal(nodeId); + }); + }); + + describe("with hashing", function () { + let id: string; + + beforeEach(function () { + id = getMachineId(); + }); + + it("returns a valid SHA256 hash format machine ID", function () { + // SHA256 hash format: 64 hex digits + const hashRegex = /^[0-9a-f]{64}$/i; + + expect(hashRegex.test(id)); + }); + }); +}); diff --git a/packages/machine-id/src/index.ts b/packages/machine-id/src/index.ts new file mode 100644 index 00000000..c9382b29 --- /dev/null +++ b/packages/machine-id/src/index.ts @@ -0,0 +1,19 @@ +import bindings from "bindings"; +import { createHash } from "crypto"; + +const binding = bindings("machine_id"); + +/** + * Get the machine ID for the current system + * @param skipHash - If true, the machine ID will not be hashed with SHA256. + * @returns The machine ID (UUID) or undefined if not available + */ +export function getMachineId(skipHash = false): string { + const machineId: string = binding.getMachineId() as string; + + if (skipHash === true) { + return machineId; + } + + return createHash("sha256").update(machineId).digest("hex"); +} diff --git a/packages/machine-id/test/index.js b/packages/machine-id/test/index.js deleted file mode 100644 index 524785f0..00000000 --- a/packages/machine-id/test/index.js +++ /dev/null @@ -1,34 +0,0 @@ -"use strict"; -const assert = require("assert"); -const getMachineId = require(".."); -const { machineId, machineIdSync } = require("node-machine-id"); - -describe("machine-id", function () { - this.timeout(5000); - - it("returns a non-empty machine ID", function () { - const id = getMachineId(); - assert.strictEqual(typeof id, "string"); - assert.ok(id.length > 0, "Machine ID should not be empty"); - }); - - it("returns a valid UUID format", function () { - const id = getMachineId(); - // UUID format: 8-4-4-4-12 hex digits - const uuidRegex = - /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; - assert.ok(uuidRegex.test(id), `Expected UUID format, got: ${id}`); - }); - - it("compares with node-machine-id", function () { - const ourId = getMachineId(); - // Machine ID from node-machine-id may be lowercase - const nodeId = machineIdSync(true).toUpperCase(); - - console.log("Our machine ID:", ourId); - console.log("node-machine-id:", nodeId); - - assert.ok(ourId, "Our implementation should return a machine ID"); - assert.ok(nodeId, "node-machine-id should return a machine ID"); - }); -}); diff --git a/packages/machine-id/tsconfig-lint.json b/packages/machine-id/tsconfig-lint.json new file mode 100644 index 00000000..6bdef84f --- /dev/null +++ b/packages/machine-id/tsconfig-lint.json @@ -0,0 +1,5 @@ +{ + "extends": "./tsconfig.json", + "include": ["**/*"], + "exclude": ["node_modules", "dist"] +} diff --git a/packages/machine-id/tsconfig.json b/packages/machine-id/tsconfig.json new file mode 100644 index 00000000..836d247a --- /dev/null +++ b/packages/machine-id/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "@mongodb-js/tsconfig-devtools/tsconfig.common.json", + "compilerOptions": { + "outDir": "dist" + }, + "include": ["src/**/*"], + "exclude": ["./src/**/*.spec.*"] +} From 337bd121a54c1d9c5586de61daa1862cef3f804f Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 11:24:09 +0200 Subject: [PATCH 03/19] fix: update binding code to include linux --- packages/machine-id/binding.cc | 57 +++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/packages/machine-id/binding.cc b/packages/machine-id/binding.cc index ae35cc94..d4c1e3f0 100644 --- a/packages/machine-id/binding.cc +++ b/packages/machine-id/binding.cc @@ -4,6 +4,9 @@ #ifdef __APPLE__ #include #include +#elif defined(__linux__) +#include +#include #endif using namespace Napi; @@ -12,7 +15,7 @@ namespace { #ifdef __APPLE__ - // Get macOS machine ID using IOKit framework directly + // Get macOS machine Id using IOKit framework directly std::string getMachineId() { std::string uuid; @@ -39,14 +42,60 @@ namespace IOObjectRelease(ioRegistryRoot); return uuid; } +#elif defined(__linux__) + // Linux machine Id paths + const char *DBUS_PATH = "/var/lib/dbus/machine-id"; + const char *DBUS_PATH_ETC = "/etc/machine-id"; + + // Trim whitespace and newlines from a string + std::string trim(const std::string &str) + { + std::string result = str; + result.erase(result.find_last_not_of(" \n\r\t") + 1); + result.erase(0, result.find_first_not_of(" \n\r\t")); + return result; + } + + // Read file contents + std::string readFile(const char *path) + { + std::ifstream file(path); + std::string content; + + if (file.is_open()) + { + std::string line; + if (std::getline(file, line)) + { + content = line; + } + file.close(); + } + + return content; + } + + // Get Linux machine Id by reading from system files + std::string getMachineId() + { + std::string id = readFile(DBUS_PATH); + + // Try fallback path if the first path fails + if (id.empty()) + { + id = readFile(DBUS_PATH_ETC); + } + + return trim(id); + } #endif - // Function to get the machine ID + // Function to get the machine Id Value GetMachineId(const CallbackInfo &args) { Env env = args.Env(); -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__linux__) std::string id = getMachineId(); if (!id.empty()) { @@ -54,7 +103,7 @@ namespace } #endif - // If we couldn't get a machine ID or platform not supported + // If we couldn't get a machine Id or platform not supported return env.Undefined(); } From 766ed9f0d5fc05c3571aa178ec1a7ed269e2effc Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 11:26:20 +0200 Subject: [PATCH 04/19] fix: handle undefined and add linux --- packages/machine-id/src/index.spec.ts | 4 ++-- packages/machine-id/src/index.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/machine-id/src/index.spec.ts b/packages/machine-id/src/index.spec.ts index 62ddbe5e..c1bae588 100644 --- a/packages/machine-id/src/index.spec.ts +++ b/packages/machine-id/src/index.spec.ts @@ -10,7 +10,7 @@ describe("machine-id", function () { let id: string; beforeEach(function () { - id = getMachineId(true); + id = getMachineId(true) || ""; }); it("returns a valid UUID format machine ID", function () { @@ -44,7 +44,7 @@ describe("machine-id", function () { let id: string; beforeEach(function () { - id = getMachineId(); + id = getMachineId() || ""; }); it("returns a valid SHA256 hash format machine ID", function () { diff --git a/packages/machine-id/src/index.ts b/packages/machine-id/src/index.ts index c9382b29..988a85fc 100644 --- a/packages/machine-id/src/index.ts +++ b/packages/machine-id/src/index.ts @@ -8,8 +8,12 @@ const binding = bindings("machine_id"); * @param skipHash - If true, the machine ID will not be hashed with SHA256. * @returns The machine ID (UUID) or undefined if not available */ -export function getMachineId(skipHash = false): string { - const machineId: string = binding.getMachineId() as string; +export function getMachineId(skipHash = false): string | undefined { + const machineId: string | undefined = binding.getMachineId(); + + if (!machineId) { + return undefined; + } if (skipHash === true) { return machineId; From 0374c632e6a46bc797a775be1cc94f6850b49e4a Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 11:44:19 +0200 Subject: [PATCH 05/19] feat: add windows, use different argument, and update docs --- packages/machine-id/README.md | 8 ++-- packages/machine-id/binding.cc | 53 ++++++++++++++++++++++++--- packages/machine-id/src/index.spec.ts | 2 +- packages/machine-id/src/index.ts | 12 ++++-- 4 files changed, 62 insertions(+), 13 deletions(-) diff --git a/packages/machine-id/README.md b/packages/machine-id/README.md index ec6a0630..b92d134b 100644 --- a/packages/machine-id/README.md +++ b/packages/machine-id/README.md @@ -21,11 +21,13 @@ npx @mongodb-js/machine-id ### As a module ```javascript -const getMachineID = require('@mongodb-js/machine-id'); +import { getMachineID } from '@mongodb-js/machine-id'; // Get the machine ID -const id = getMachineID(); -console.log('Machine ID:', id); +const hashedId = getMachineID(); +console.log('SHA-256 Hashed Machine ID:', id); +const id = getMachineID({ raw: true }); +console.log('Original Machine ID:', id); ``` ### As a CLI diff --git a/packages/machine-id/binding.cc b/packages/machine-id/binding.cc index d4c1e3f0..94842c8c 100644 --- a/packages/machine-id/binding.cc +++ b/packages/machine-id/binding.cc @@ -7,6 +7,8 @@ #elif defined(__linux__) #include #include +#elif defined(_WIN32) +#include #endif using namespace Napi; @@ -15,7 +17,7 @@ namespace { #ifdef __APPLE__ - // Get macOS machine Id using IOKit framework directly + // Get macOS machine ID using IOKit framework directly std::string getMachineId() { std::string uuid; @@ -43,7 +45,7 @@ namespace return uuid; } #elif defined(__linux__) - // Linux machine Id paths + // Linux machine ID paths const char *DBUS_PATH = "/var/lib/dbus/machine-id"; const char *DBUS_PATH_ETC = "/etc/machine-id"; @@ -75,7 +77,7 @@ namespace return content; } - // Get Linux machine Id by reading from system files + // Get Linux machine ID by reading from system files std::string getMachineId() { std::string id = readFile(DBUS_PATH); @@ -88,14 +90,53 @@ namespace return trim(id); } +#elif defined(_WIN32) + // Get Windows machine ID from registry + std::string getMachineId() + { + std::string machineGuid; + HKEY hKey; + LONG result = RegOpenKeyExA( + HKEY_LOCAL_MACHINE, + "SOFTWARE\\Microsoft\\Cryptography", + 0, + KEY_QUERY_VALUE | KEY_WOW64_64KEY, + &hKey); + + if (result != ERROR_SUCCESS) + { + return ""; + } + + char value[128]; + DWORD valueSize = sizeof(value); + DWORD valueType; + + result = RegQueryValueExA( + hKey, + "MachineGuid", + NULL, + &valueType, + reinterpret_cast(value), + &valueSize); + + RegCloseKey(hKey); + + if (result == ERROR_SUCCESS && valueType == REG_SZ) + { + machineGuid = value; + } + + return machineGuid; + } #endif - // Function to get the machine Id + // Function to get the machine ID Value GetMachineId(const CallbackInfo &args) { Env env = args.Env(); -#if defined(__APPLE__) || defined(__linux__) +#if defined(__APPLE__) || defined(__linux__) || defined(_WIN32) std::string id = getMachineId(); if (!id.empty()) { @@ -103,7 +144,7 @@ namespace } #endif - // If we couldn't get a machine Id or platform not supported + // If we couldn't get a machine ID or platform not supported return env.Undefined(); } diff --git a/packages/machine-id/src/index.spec.ts b/packages/machine-id/src/index.spec.ts index c1bae588..497c92ca 100644 --- a/packages/machine-id/src/index.spec.ts +++ b/packages/machine-id/src/index.spec.ts @@ -10,7 +10,7 @@ describe("machine-id", function () { let id: string; beforeEach(function () { - id = getMachineId(true) || ""; + id = getMachineId({ raw: true }) || ""; }); it("returns a valid UUID format machine ID", function () { diff --git a/packages/machine-id/src/index.ts b/packages/machine-id/src/index.ts index 988a85fc..13e80919 100644 --- a/packages/machine-id/src/index.ts +++ b/packages/machine-id/src/index.ts @@ -3,19 +3,25 @@ import { createHash } from "crypto"; const binding = bindings("machine_id"); +export type GetMachineIdOptions = { + /** If true, the machine ID will not be hashed with SHA256. */ + raw?: boolean; +}; + /** * Get the machine ID for the current system - * @param skipHash - If true, the machine ID will not be hashed with SHA256. * @returns The machine ID (UUID) or undefined if not available */ -export function getMachineId(skipHash = false): string | undefined { +export function getMachineId({ raw = false }: GetMachineIdOptions = {}): + | string + | undefined { const machineId: string | undefined = binding.getMachineId(); if (!machineId) { return undefined; } - if (skipHash === true) { + if (raw === true) { return machineId; } From cace6b381fedce60be90d7cda9967892b3fd3752 Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 11:56:11 +0200 Subject: [PATCH 06/19] fix: issues with lint --- packages/machine-id/.eslintignore | 1 + packages/machine-id/.eslintrc.js | 4 ++-- packages/machine-id/.prettierignore | 2 ++ packages/machine-id/.prettierrc.json | 1 + packages/machine-id/bin/machine-id.js | 5 +++-- packages/machine-id/index.d.ts | 7 ------- packages/machine-id/index.js | 3 --- packages/machine-id/package.json | 2 +- packages/machine-id/src/bindings.d.ts | 6 ++++-- packages/machine-id/src/index.spec.ts | 30 +++++++++++++-------------- packages/machine-id/src/index.ts | 8 +++---- 11 files changed, 33 insertions(+), 36 deletions(-) create mode 100644 packages/machine-id/.eslintignore create mode 100644 packages/machine-id/.prettierignore create mode 100644 packages/machine-id/.prettierrc.json delete mode 100644 packages/machine-id/index.d.ts delete mode 100644 packages/machine-id/index.js diff --git a/packages/machine-id/.eslintignore b/packages/machine-id/.eslintignore new file mode 100644 index 00000000..1521c8b7 --- /dev/null +++ b/packages/machine-id/.eslintignore @@ -0,0 +1 @@ +dist diff --git a/packages/machine-id/.eslintrc.js b/packages/machine-id/.eslintrc.js index 70d48211..83296d73 100644 --- a/packages/machine-id/.eslintrc.js +++ b/packages/machine-id/.eslintrc.js @@ -1,8 +1,8 @@ module.exports = { root: true, - extends: ["@mongodb-js/eslint-config-devtools"], + extends: ['@mongodb-js/eslint-config-devtools'], parserOptions: { tsconfigRootDir: __dirname, - project: ["./tsconfig-lint.json"], + project: ['./tsconfig-lint.json'], }, }; diff --git a/packages/machine-id/.prettierignore b/packages/machine-id/.prettierignore new file mode 100644 index 00000000..009af543 --- /dev/null +++ b/packages/machine-id/.prettierignore @@ -0,0 +1,2 @@ +dist +coverage diff --git a/packages/machine-id/.prettierrc.json b/packages/machine-id/.prettierrc.json new file mode 100644 index 00000000..dfae21d0 --- /dev/null +++ b/packages/machine-id/.prettierrc.json @@ -0,0 +1 @@ +"@mongodb-js/prettier-config-devtools" diff --git a/packages/machine-id/bin/machine-id.js b/packages/machine-id/bin/machine-id.js index 7e98456c..314c61c3 100644 --- a/packages/machine-id/bin/machine-id.js +++ b/packages/machine-id/bin/machine-id.js @@ -1,3 +1,4 @@ #!/usr/bin/env node -const getMachineID = require(".."); -console.log(getMachineID() || "Machine ID not available on this platform"); +const getMachineID = require('..'); +// eslint-disable-next-line no-console +console.log(getMachineID() || 'Machine ID not available on this platform'); diff --git a/packages/machine-id/index.d.ts b/packages/machine-id/index.d.ts deleted file mode 100644 index 20e3c473..00000000 --- a/packages/machine-id/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Get the machine ID for the current system - * @returns The machine ID (UUID) or undefined if not available - */ -declare function getMachineId(): string | undefined; - -export = getMachineId; diff --git a/packages/machine-id/index.js b/packages/machine-id/index.js deleted file mode 100644 index f42b0fe6..00000000 --- a/packages/machine-id/index.js +++ /dev/null @@ -1,3 +0,0 @@ -const binding = require("bindings")("machine_id"); - -module.exports = binding.getMachineId; diff --git a/packages/machine-id/package.json b/packages/machine-id/package.json index c9a09a0c..459d8359 100644 --- a/packages/machine-id/package.json +++ b/packages/machine-id/package.json @@ -9,7 +9,7 @@ "bootstrap": "npm run compile", "pretest": "npm run compile", "test": "mocha", - "lint": "eslint \"**/*.{js,ts}\"", + "lint": "eslint . && prettier --check .", "check": "npm run lint && npm run test", "prepublishOnly": "npm run compile" }, diff --git a/packages/machine-id/src/bindings.d.ts b/packages/machine-id/src/bindings.d.ts index 77a93b1c..53d8fa66 100644 --- a/packages/machine-id/src/bindings.d.ts +++ b/packages/machine-id/src/bindings.d.ts @@ -1,4 +1,6 @@ declare module 'bindings' { - function bindings(filename: string): any; + function bindings(filename: string): { + getMachineId: () => string | undefined; + }; export = bindings; -} \ No newline at end of file +} diff --git a/packages/machine-id/src/index.spec.ts b/packages/machine-id/src/index.spec.ts index 497c92ca..92a6e29c 100644 --- a/packages/machine-id/src/index.spec.ts +++ b/packages/machine-id/src/index.spec.ts @@ -1,19 +1,19 @@ -import { getMachineId } from "."; -import { machineIdSync as otherMachineId } from "node-machine-id"; -import { expect } from "chai"; -import { createHash } from "crypto"; +import { getMachineId } from '.'; +import { machineIdSync as otherMachineId } from 'node-machine-id'; +import { expect } from 'chai'; +import { createHash } from 'crypto'; -describe("machine-id", function () { +describe('machine-id', function () { this.timeout(5_000); - describe("without hashing", function () { + describe('without hashing', function () { let id: string; beforeEach(function () { - id = getMachineId({ raw: true }) || ""; + id = getMachineId({ raw: true }) || ''; }); - it("returns a valid UUID format machine ID", function () { + it('returns a valid UUID format machine ID', function () { // UUID format: 8-4-4-4-12 hex digits const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; @@ -21,33 +21,33 @@ describe("machine-id", function () { expect(uuidRegex.test(id)); }); - it("is consistent with node-machine-id", function () { + it('is consistent with node-machine-id', function () { const nodeId = otherMachineId(true); // node-machine-id returns a lowercase ID expect(id.toLowerCase()).to.equal(nodeId); }); - it("can reproduce the hashed node-machine-id value", function () { + it('can reproduce the hashed node-machine-id value', function () { const nodeId = otherMachineId(); // Compare the lowercase workaround for consistency with node-machine-id - const hashedId = createHash("sha256") + const hashedId = createHash('sha256') .update(id.toLowerCase()) - .digest("hex"); + .digest('hex'); expect(hashedId).to.equal(nodeId); }); }); - describe("with hashing", function () { + describe('with hashing', function () { let id: string; beforeEach(function () { - id = getMachineId() || ""; + id = getMachineId() || ''; }); - it("returns a valid SHA256 hash format machine ID", function () { + it('returns a valid SHA256 hash format machine ID', function () { // SHA256 hash format: 64 hex digits const hashRegex = /^[0-9a-f]{64}$/i; diff --git a/packages/machine-id/src/index.ts b/packages/machine-id/src/index.ts index 13e80919..66fd9b79 100644 --- a/packages/machine-id/src/index.ts +++ b/packages/machine-id/src/index.ts @@ -1,7 +1,7 @@ -import bindings from "bindings"; -import { createHash } from "crypto"; +import bindings from 'bindings'; +import { createHash } from 'crypto'; -const binding = bindings("machine_id"); +const binding = bindings('machine_id'); export type GetMachineIdOptions = { /** If true, the machine ID will not be hashed with SHA256. */ @@ -25,5 +25,5 @@ export function getMachineId({ raw = false }: GetMachineIdOptions = {}): return machineId; } - return createHash("sha256").update(machineId).digest("hex"); + return createHash('sha256').update(machineId).digest('hex'); } From cfd326facf7682e16a9841181a3943084c5f19e0 Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 11:59:37 +0200 Subject: [PATCH 07/19] fix: use dist for main file --- packages/machine-id/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/machine-id/package.json b/packages/machine-id/package.json index 459d8359..be197d8c 100644 --- a/packages/machine-id/package.json +++ b/packages/machine-id/package.json @@ -2,8 +2,8 @@ "name": "@mongodb-js/machine-id", "version": "1.0.0", "description": "Cross-platform native module to retrieve machine/device identifiers", - "main": "lib/index.js", - "types": "lib/index.d.ts", + "main": "dist/index.js", + "types": "dist/index.d.ts", "scripts": { "compile": "tsc -p tsconfig.json && node-gyp rebuild && gen-esm-wrapper . ./dist/.esm-wrapper.mjs", "bootstrap": "npm run compile", @@ -21,8 +21,8 @@ }, "license": "Apache-2.0", "exports": { - "require": "./lib/index.js", - "import": "./lib/.esm-wrapper.mjs" + "require": "./dist/index.js", + "import": "./dist/.esm-wrapper.mjs" }, "homepage": "https://github.com/mongodb-js/devtools-shared", "repository": { From af4ce9cf63a4be6f0c483fb60aa4d16052e0fb9d Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 12:09:39 +0200 Subject: [PATCH 08/19] fix: depcheck --- packages/machine-id/package.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/machine-id/package.json b/packages/machine-id/package.json index be197d8c..7bc70675 100644 --- a/packages/machine-id/package.json +++ b/packages/machine-id/package.json @@ -9,6 +9,7 @@ "bootstrap": "npm run compile", "pretest": "npm run compile", "test": "mocha", + "test-ci": "npm run test", "lint": "eslint . && prettier --check .", "check": "npm run lint && npm run test", "prepublishOnly": "npm run compile" @@ -47,12 +48,12 @@ "@types/chai": "^4.2.21", "@types/mocha": "^9.1.1", "@types/sinon-chai": "^3.2.5", - "@types/node": "^20.10.0", - "eslint": "^8.0.0", + "@types/node": "^17.0.35", + "eslint": "^7.25.0", "gen-esm-wrapper": "^1.1.1", - "mocha": "^10.4.0", + "mocha": "^8.4.0", "chai": "^4.5.0", "node-machine-id": "^1.1.12", - "typescript": "^5.0.0" + "typescript": "^5.0.4" } } From 118ee937dc9017c53cbfbbe3de7319d6e16d422e Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 12:10:47 +0200 Subject: [PATCH 09/19] fix build divergence --- package-lock.json | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 492a7c9e..8139328a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28193,14 +28193,14 @@ "@mongodb-js/tsconfig-devtools": "^1.0.3", "@types/chai": "^4.2.21", "@types/mocha": "^9.1.1", - "@types/node": "^20.10.0", + "@types/node": "^17.0.35", "@types/sinon-chai": "^3.2.5", "chai": "^4.5.0", - "eslint": "^8.0.0", + "eslint": "^7.25.0", "gen-esm-wrapper": "^1.1.1", - "mocha": "^10.4.0", + "mocha": "^8.4.0", "node-machine-id": "^1.1.12", - "typescript": "^5.0.0" + "typescript": "^5.0.4" } }, "packages/machine-id/node_modules/@eslint/eslintrc": { @@ -35986,16 +35986,16 @@ "@mongodb-js/tsconfig-devtools": "^1.0.3", "@types/chai": "^4.2.21", "@types/mocha": "^9.1.1", - "@types/node": "^20.10.0", + "@types/node": "^17.0.35", "@types/sinon-chai": "^3.2.5", "bindings": "^1.5.0", "chai": "^4.5.0", - "eslint": "^8.0.0", + "eslint": "^7.25.0", "gen-esm-wrapper": "^1.1.1", - "mocha": "^10.4.0", + "mocha": "^8.4.0", "node-addon-api": "^8.0.0", "node-machine-id": "^1.1.12", - "typescript": "^5.0.0" + "typescript": "^5.0.4" }, "dependencies": { "@eslint/eslintrc": { @@ -36075,8 +36075,7 @@ "dev": true }, "@types/node": { - "version": "20.17.30", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.30.tgz", + "version": "https://registry.npmjs.org/@types/node/-/node-20.17.30.tgz", "integrity": "sha512-7zf4YyHA+jvBNfVrk2Gtvs6x7E8V+YDW05bNfG2XkWDJfYRXrTiP/DsB2zSYTaHX0bGIujTBQdMVAhb+j7mwpg==", "dev": true, "requires": { @@ -36133,8 +36132,7 @@ "dev": true }, "eslint": { - "version": "8.57.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", + "version": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", "dev": true, "requires": { @@ -36292,8 +36290,7 @@ } }, "mocha": { - "version": "10.8.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz", + "version": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz", "integrity": "sha512-VZlYo/WE8t1tstuRmqgeyBgCbJc/lEdopaa+axcKzTBJ+UIdlAB9XnmvTCAH4pwR4ElNInaedhEBmZD8iCSVEg==", "dev": true, "requires": { From 11099027e0ad32c4422db2c990a8304ece91f651 Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 12:40:45 +0200 Subject: [PATCH 10/19] fix: better documentation --- packages/machine-id/README.md | 39 ++++++++++++++++----------- packages/machine-id/binding.cc | 2 +- packages/machine-id/src/bindings.d.ts | 2 +- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/packages/machine-id/README.md b/packages/machine-id/README.md index b92d134b..95f9491d 100644 --- a/packages/machine-id/README.md +++ b/packages/machine-id/README.md @@ -1,8 +1,6 @@ # @mongodb-js/machine-id -[![npm](https://img.shields.io/npm/v/@mongodb-js/machine-id.svg)](https://www.npmjs.com/package/@mongodb-js/machine-id) - -A native Node.js module to retrieve the unique machine ID across different operating systems. +> Cross-platform module to retrieve unique machine IDs across desktop operating systems without admin privileges or child processes. ## Installation @@ -16,6 +14,7 @@ Or use it directly in the CLI npx @mongodb-js/machine-id ``` + ## Usage ### As a module @@ -40,25 +39,35 @@ machine-id This will print the machine ID to the console. -## Supported Platforms +## Comparison with `node-machine-id` +This module provides similar functionality to [node-machine-id](https://www.npmjs.com/package/node-machine-id), but **using native access to system APIs without the need for child processes**. + +If you were previously using `node-machine-id`, you can use the following mapping to get a result that uses the same hashing transformation. This helps create more consistent results as before but it is not guaranteed to be the same for all cases. +```ts +import { createHash } from 'crypto'; +import { getMachineId } from '@mongodb-js/machine-id'; -- **macOS**: Retrieves the IOPlatformUUID using the IOKit framework -- **Linux**: Support for Linux planned in future releases -- **Windows**: Support for Windows planned in future releases +function machineIdSync(original: boolean): string | undefined { + const rawMachineId = getMachineId({ raw: true }).toLowerCase(); -## Implementation Details + if (original) { + return rawMachineId; + } -The module uses native OS-specific APIs to retrieve the machine ID: + return createHash("sha256") + .update(rawMachineId) + .digest("hex"); +} -- On macOS, it uses the IOKit framework to access the IOPlatformUUID, which uniquely identifies the machine. +``` + +## Supported Platforms -## Comparison with node-machine-id +- **macOS**: Uses the `IOPlatformUUID` from the `IOKit` framework (Supported on macOS 12.0 and later). +- **Linux**: Uses the `/etc/machine-id` file to retrieve the machine ID. If this file does not exist, it falls back to `/var/lib/dbus/machine-id`. +- **Windows**: Uses the `MachineGuid` from the `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography` registry. -This module provides similar functionality to [node-machine-id](https://www.npmjs.com/package/node-machine-id), but with: -- Simplified API focused on getting the raw machine ID -- Direct native access to system APIs without shell commands -- Optimized for use in MongoDB tools ## License diff --git a/packages/machine-id/binding.cc b/packages/machine-id/binding.cc index 94842c8c..823730c5 100644 --- a/packages/machine-id/binding.cc +++ b/packages/machine-id/binding.cc @@ -144,7 +144,7 @@ namespace } #endif - // If we couldn't get a machine ID or platform not supported + // If we couldn't get a machine ID or platform not supported, return undefined. return env.Undefined(); } diff --git a/packages/machine-id/src/bindings.d.ts b/packages/machine-id/src/bindings.d.ts index 53d8fa66..4b639513 100644 --- a/packages/machine-id/src/bindings.d.ts +++ b/packages/machine-id/src/bindings.d.ts @@ -1,5 +1,5 @@ declare module 'bindings' { - function bindings(filename: string): { + function bindings(filename: 'machine_id'): { getMachineId: () => string | undefined; }; export = bindings; From eb8853a68ec4d6980f53ce31c761fb06a0061ab4 Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 12:43:17 +0200 Subject: [PATCH 11/19] fix: stricter file operations --- packages/machine-id/binding.cc | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/packages/machine-id/binding.cc b/packages/machine-id/binding.cc index 823730c5..6346ad68 100644 --- a/packages/machine-id/binding.cc +++ b/packages/machine-id/binding.cc @@ -52,6 +52,11 @@ namespace // Trim whitespace and newlines from a string std::string trim(const std::string &str) { + if (str.empty()) + { + return str; + } + std::string result = str; result.erase(result.find_last_not_of(" \n\r\t") + 1); result.erase(0, result.find_first_not_of(" \n\r\t")); @@ -61,20 +66,26 @@ namespace // Read file contents std::string readFile(const char *path) { - std::ifstream file(path); - std::string content; - - if (file.is_open()) + try { - std::string line; - if (std::getline(file, line)) + std::ifstream file(path); + std::string content; + + if (file.is_open()) { - content = line; + std::string line; + if (std::getline(file, line)) + { + content = line; + } + file.close(); } - file.close(); + return content; + } + catch (const std::exception &) + { + return ""; } - - return content; } // Get Linux machine ID by reading from system files From c6ca2389e566f9b05bda72ea4b2f936d67ef3d76 Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 13:42:19 +0200 Subject: [PATCH 12/19] test: add performance tests --- packages/machine-id/README.md | 20 ++-- packages/machine-id/package.json | 3 +- packages/machine-id/scripts/benchmark.ts | 111 +++++++++++++++++++++++ packages/machine-id/src/index.spec.ts | 86 ++++++++++++++++++ packages/machine-id/tsconfig.json | 2 +- 5 files changed, 208 insertions(+), 14 deletions(-) create mode 100644 packages/machine-id/scripts/benchmark.ts diff --git a/packages/machine-id/README.md b/packages/machine-id/README.md index 95f9491d..c373a11d 100644 --- a/packages/machine-id/README.md +++ b/packages/machine-id/README.md @@ -14,7 +14,6 @@ Or use it directly in the CLI npx @mongodb-js/machine-id ``` - ## Usage ### As a module @@ -40,34 +39,31 @@ machine-id This will print the machine ID to the console. ## Comparison with `node-machine-id` + This module provides similar functionality to [node-machine-id](https://www.npmjs.com/package/node-machine-id), but **using native access to system APIs without the need for child processes**. If you were previously using `node-machine-id`, you can use the following mapping to get a result that uses the same hashing transformation. This helps create more consistent results as before but it is not guaranteed to be the same for all cases. + ```ts import { createHash } from 'crypto'; import { getMachineId } from '@mongodb-js/machine-id'; function machineIdSync(original: boolean): string | undefined { - const rawMachineId = getMachineId({ raw: true }).toLowerCase(); + const rawMachineId = getMachineId({ raw: true }).toLowerCase(); - if (original) { - return rawMachineId; - } + if (original) { + return rawMachineId; + } - return createHash("sha256") - .update(rawMachineId) - .digest("hex"); + return createHash('sha256').update(rawMachineId).digest('hex'); } - ``` ## Supported Platforms - **macOS**: Uses the `IOPlatformUUID` from the `IOKit` framework (Supported on macOS 12.0 and later). - **Linux**: Uses the `/etc/machine-id` file to retrieve the machine ID. If this file does not exist, it falls back to `/var/lib/dbus/machine-id`. -- **Windows**: Uses the `MachineGuid` from the `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography` registry. - - +- **Windows**: Uses the `MachineGuid` from the `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography` registry. ## License diff --git a/packages/machine-id/package.json b/packages/machine-id/package.json index 7bc70675..f701e88b 100644 --- a/packages/machine-id/package.json +++ b/packages/machine-id/package.json @@ -12,7 +12,8 @@ "test-ci": "npm run test", "lint": "eslint . && prettier --check .", "check": "npm run lint && npm run test", - "prepublishOnly": "npm run compile" + "prepublishOnly": "npm run compile", + "benchmark": "ts-node scripts/benchmark.ts" }, "author": "Compass Team ", "gypfile": true, diff --git a/packages/machine-id/scripts/benchmark.ts b/packages/machine-id/scripts/benchmark.ts new file mode 100644 index 00000000..aa62458e --- /dev/null +++ b/packages/machine-id/scripts/benchmark.ts @@ -0,0 +1,111 @@ +#!/usr/bin/env node +/* eslint-disable no-console */ +/** + * Performance comparison script for machine-id vs node-machine-id + * + * This script measures and compares the performance of @mongodb-js/machine-id + * against the node-machine-id package. + */ + +import { getMachineId } from '../dist/index.js'; +import { machineIdSync } from 'node-machine-id'; + +// Configuration +const ITERATIONS = 100; +const WARMUP_ITERATIONS = 10; + +// Utility to format time +function formatTime(ms: number): string { + if (ms < 1) { + return `${(ms * 1000).toFixed(2)}µs`; + } + return `${ms.toFixed(2)}ms`; +} + +// Utility to format comparison +function formatComparison(time1: number, time2: number): string { + if (time1 < time2) { + return `${(time2 / time1).toFixed(2)}x faster`; + } else { + return `${(time1 / time2).toFixed(2)}x slower`; + } +} + +function runBenchmark() { + console.log('========================================'); + console.log('Machine ID Performance Benchmark'); + console.log('========================================'); + console.log(`Platform: ${process.platform}`); + console.log(`Node.js version: ${process.version}`); + console.log(`Test iterations: ${ITERATIONS}`); + console.log('----------------------------------------'); + + // Warm-up + console.log('Warming up...'); + for (let i = 0; i < WARMUP_ITERATIONS; i++) { + getMachineId({ raw: true }); + machineIdSync(true); + } + + // Test raw mode (no hashing) + console.log('\nRaw machine ID retrieval:'); + + const startOursRaw = process.hrtime.bigint(); + for (let i = 0; i < ITERATIONS; i++) { + getMachineId({ raw: true }); + } + const endOursRaw = process.hrtime.bigint(); + const ourTimeRaw = Number(endOursRaw - startOursRaw) / 1_000_000; // ms + + // node-machine-id + const startOtherRaw = process.hrtime.bigint(); + for (let i = 0; i < ITERATIONS; i++) { + machineIdSync(true); + } + const endOtherRaw = process.hrtime.bigint(); + const otherTimeRaw = Number(endOtherRaw - startOtherRaw) / 1_000_000; // ms + + console.log( + `@mongodb-js/machine-id: ${formatTime(ourTimeRaw)} total, ${formatTime(ourTimeRaw / ITERATIONS)} per call`, + ); + console.log( + `node-machine-id: ${formatTime(otherTimeRaw)} total, ${formatTime(otherTimeRaw / ITERATIONS)} per call`, + ); + console.log( + `Comparison: @mongodb-js/machine-id is ${formatComparison(ourTimeRaw, otherTimeRaw)}`, + ); + + // Test hashed mode + console.log('\nHashed machine ID:'); + + // @mongodb-js/machine-id + const startOursHashed = process.hrtime.bigint(); + for (let i = 0; i < ITERATIONS; i++) { + getMachineId(); + } + const endOursHashed = process.hrtime.bigint(); + const ourTimeHashed = Number(endOursHashed - startOursHashed) / 1_000_000; // ms + + // node-machine-id + const startOtherHashed = process.hrtime.bigint(); + for (let i = 0; i < ITERATIONS; i++) { + machineIdSync(); + } + const endOtherHashed = process.hrtime.bigint(); + const otherTimeHashed = Number(endOtherHashed - startOtherHashed) / 1_000_000; // ms + + console.log( + `@mongodb-js/machine-id: ${formatTime(ourTimeHashed)} total, ${formatTime(ourTimeHashed / ITERATIONS)} per call`, + ); + console.log( + `node-machine-id: ${formatTime(otherTimeHashed)} total, ${formatTime(otherTimeHashed / ITERATIONS)} per call`, + ); + console.log( + `Comparison: @mongodb-js/machine-id is ${formatComparison(ourTimeHashed, otherTimeHashed)}`, + ); + + console.log('\n========================================'); +} + +// Run the benchmark +runBenchmark(); diff --git a/packages/machine-id/src/index.spec.ts b/packages/machine-id/src/index.spec.ts index 92a6e29c..f8a1470a 100644 --- a/packages/machine-id/src/index.spec.ts +++ b/packages/machine-id/src/index.spec.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import { getMachineId } from '.'; import { machineIdSync as otherMachineId } from 'node-machine-id'; import { expect } from 'chai'; @@ -54,4 +55,89 @@ describe('machine-id', function () { expect(hashRegex.test(id)); }); }); + + describe('performance comparison', function () { + // Increase timeout for performance tests + this.timeout(100_000); + + it('performs faster than node-machine-id (raw)', function () { + const iterations = 1000; + + // Warm-up run to account for initial load time + getMachineId({ raw: true }); + otherMachineId(true); + + // Test implementation + const startOurs = process.hrtime.bigint(); + for (let i = 0; i < iterations; i++) { + getMachineId({ raw: true }); + } + const endOurs = process.hrtime.bigint(); + const ourTime = Number(endOurs - startOurs) / 1_000_000; // Convert to ms + + // Test node-machine-id + const startOther = process.hrtime.bigint(); + for (let i = 0; i < iterations; i++) { + otherMachineId(true); + } + const endOther = process.hrtime.bigint(); + const otherTime = Number(endOther - startOther) / 1_000_000; // Convert to ms + + console.log( + `Performance comparison (raw mode, ${iterations} iterations):`, + ); + console.log( + `- Our implementation: ${ourTime.toFixed(4)}ms (${(ourTime / iterations).toFixed(4)}ms per call)`, + ); + console.log( + `- node-machine-id: ${otherTime.toFixed(4)}ms (${(otherTime / iterations).toFixed(4)}ms per call)`, + ); + console.log( + `- Difference: ${ourTime < otherTime ? 'Ours is ' + (otherTime / ourTime).toFixed(2) + 'x faster' : 'node-machine-id is ' + (ourTime / otherTime).toFixed(2) + 'x faster'}`, + ); + + // We expect our native implementation to be faster + // but don't fail the test if it's not, just report the measurements + }); + + it('performs faster than node-machine-id (hashed)', function () { + const iterations = 1000; + + // Warm-up run + getMachineId(); + otherMachineId(); + + // Test our implementation + const startOurs = process.hrtime.bigint(); + for (let i = 0; i < iterations; i++) { + getMachineId(); + } + const endOurs = process.hrtime.bigint(); + const ourTime = Number(endOurs - startOurs) / 1_000_000; // Convert to ms + + // Test node-machine-id + const startOther = process.hrtime.bigint(); + for (let i = 0; i < iterations; i++) { + otherMachineId(); + } + const endOther = process.hrtime.bigint(); + const otherTime = Number(endOther - startOther) / 1_000_000; // Convert to ms + + console.log( + `Performance comparison (hashed mode, ${iterations} iterations):`, + ); + console.log( + `- Our implementation: ${ourTime.toFixed(4)}ms (${(ourTime / iterations).toFixed(4)}ms per call)`, + ); + console.log( + `- node-machine-id: ${otherTime.toFixed(4)}ms (${(otherTime / iterations).toFixed(4)}ms per call)`, + ); + console.log( + `- Difference: ${ourTime < otherTime ? 'Ours is ' + (otherTime / ourTime).toFixed(2) + 'x faster' : 'node-machine-id is ' + (ourTime / otherTime).toFixed(2) + 'x faster'}`, + ); + + // We expect our native implementation to be faster + // but don't fail the test if it's not, just report the measurements + }); + }); }); diff --git a/packages/machine-id/tsconfig.json b/packages/machine-id/tsconfig.json index 836d247a..a2af0408 100644 --- a/packages/machine-id/tsconfig.json +++ b/packages/machine-id/tsconfig.json @@ -4,5 +4,5 @@ "outDir": "dist" }, "include": ["src/**/*"], - "exclude": ["./src/**/*.spec.*"] + "exclude": ["./src/**/*.spec.*", "scripts/benchmark.ts"] } From b98496b5c1543df572da86b1a5a784a2ffd7062a Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 14:41:04 +0200 Subject: [PATCH 13/19] refactor: move performance tests to a script --- package-lock.json | 4 +- packages/machine-id/README.md | 47 +++++++------ packages/machine-id/bin/machine-id.js | 4 -- packages/machine-id/package.json | 9 +-- packages/machine-id/scripts/benchmark.ts | 16 ++--- packages/machine-id/src/bin/machine-id.ts | 12 ++++ packages/machine-id/src/index.spec.ts | 85 ----------------------- 7 files changed, 50 insertions(+), 127 deletions(-) delete mode 100644 packages/machine-id/bin/machine-id.js create mode 100644 packages/machine-id/src/bin/machine-id.ts diff --git a/package-lock.json b/package-lock.json index 8139328a..555fc09a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28184,7 +28184,7 @@ "node-addon-api": "^8.0.0" }, "bin": { - "machine-id": "lib/bin/machine-id.js" + "machine-id": "dist/bin/machine-id.js" }, "devDependencies": { "@mongodb-js/eslint-config-devtools": "0.9.11", @@ -28200,6 +28200,7 @@ "gen-esm-wrapper": "^1.1.1", "mocha": "^8.4.0", "node-machine-id": "^1.1.12", + "ts-node": "^10.9.2", "typescript": "^5.0.4" } }, @@ -35995,6 +35996,7 @@ "mocha": "^8.4.0", "node-addon-api": "^8.0.0", "node-machine-id": "^1.1.12", + "ts-node": "^10.9.2", "typescript": "^5.0.4" }, "dependencies": { diff --git a/packages/machine-id/README.md b/packages/machine-id/README.md index c373a11d..201c4a42 100644 --- a/packages/machine-id/README.md +++ b/packages/machine-id/README.md @@ -1,6 +1,6 @@ # @mongodb-js/machine-id -> Cross-platform module to retrieve unique machine IDs across desktop operating systems without admin privileges or child processes. +> Native implementation for retrieving unique machine ID without admin privileges or child processes for desktop platforms. Faster and more reliable alternative to node-machine-id. ## Installation @@ -28,21 +28,36 @@ const id = getMachineID({ raw: true }); console.log('Original Machine ID:', id); ``` -### As a CLI -After installing globally, run: - -``` -machine-id -``` +## Supported Platforms -This will print the machine ID to the console. +- **macOS**: Uses the `IOPlatformUUID` from the `IOKit` framework (Supported on macOS 12.0 and later). +- **Linux**: Uses the `/var/lib/dbus/machine-id` file to retrieve the machine ID. If this file does not exist, it falls back to `/etc/machine-id`. +- **Windows**: Uses the `MachineGuid` from the `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography` registry. ## Comparison with `node-machine-id` -This module provides similar functionality to [node-machine-id](https://www.npmjs.com/package/node-machine-id), but **using native access to system APIs without the need for child processes**. +This module provides similar functionality to [node-machine-id](https://www.npmjs.com/package/node-machine-id), but **using native access to system APIs without the need for child processes**, making it much faster and reliable. + +Here's a table of performance comparisons between the two libraries, based on the average runtime from 1000 iterations of the `getMachineId` and `machineIdSync` functions, from `scripts/benchmark.ts`: + +| Test | node-machine-id | @mongodb-js/machine-id | Improvement | +| ----------- | --------------- | ---------------------- | ----------- | +| **Mac** | +| Raw | 10.71ms | 0.0072ms | 1494x | +| Hashed | 12.42ms | 0.0176ms | 707x | +| **Linux** | +| Raw | 3.26ms | 0.0059ms | 557x | +| Hashed | 3.25ms | 0.0088ms | 368x | +| **Windows** | +| Raw | 45.36ms* | 0.0122ms | 3704x | +| Hashed | 28.66ms* | 0.0272ms | 1053x | -If you were previously using `node-machine-id`, you can use the following mapping to get a result that uses the same hashing transformation. This helps create more consistent results as before but it is not guaranteed to be the same for all cases. +\* - Windows tests may be inaccurate due to potential caching. + + +### Migrating from `node-machine-id` +If you were previously using `node-machine-id`, you can use the following mapping to get a result with the following hashing transformation. This is not guaranteed always to 1:1 match the output of `node-machine-id` for all cases. For example on Linux, it falls back to `/etc/machine-id` if `/var/lib/dbus/machine-id` is not available. ```ts import { createHash } from 'crypto'; @@ -51,20 +66,10 @@ import { getMachineId } from '@mongodb-js/machine-id'; function machineIdSync(original: boolean): string | undefined { const rawMachineId = getMachineId({ raw: true }).toLowerCase(); - if (original) { - return rawMachineId; - } - - return createHash('sha256').update(rawMachineId).digest('hex'); + return original ? rawMachineId : createHash('sha256').update(rawMachineId).digest('hex'); } ``` -## Supported Platforms - -- **macOS**: Uses the `IOPlatformUUID` from the `IOKit` framework (Supported on macOS 12.0 and later). -- **Linux**: Uses the `/etc/machine-id` file to retrieve the machine ID. If this file does not exist, it falls back to `/var/lib/dbus/machine-id`. -- **Windows**: Uses the `MachineGuid` from the `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography` registry. - ## License Apache-2.0 diff --git a/packages/machine-id/bin/machine-id.js b/packages/machine-id/bin/machine-id.js deleted file mode 100644 index 314c61c3..00000000 --- a/packages/machine-id/bin/machine-id.js +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env node -const getMachineID = require('..'); -// eslint-disable-next-line no-console -console.log(getMachineID() || 'Machine ID not available on this platform'); diff --git a/packages/machine-id/package.json b/packages/machine-id/package.json index f701e88b..818af748 100644 --- a/packages/machine-id/package.json +++ b/packages/machine-id/package.json @@ -1,7 +1,7 @@ { "name": "@mongodb-js/machine-id", "version": "1.0.0", - "description": "Cross-platform native module to retrieve machine/device identifiers", + "description": "Native implementation for retrieving unique machine ID without admin privileges or child processes for desktop platforms. Faster and more reliable alternative to node-machine-id.", "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { @@ -33,12 +33,12 @@ }, "bugs": "https://jira.mongodb.org/projects/COMPASS/issues", "bin": { - "machine-id": "lib/bin/machine-id.js" + "machine-id": "dist/bin/machine-id.js" }, "files": [ "binding.cc", "binding.gyp", - "lib", + "dist", "LICENSE" ], "devDependencies": { @@ -55,6 +55,7 @@ "mocha": "^8.4.0", "chai": "^4.5.0", "node-machine-id": "^1.1.12", - "typescript": "^5.0.4" + "typescript": "^5.0.4", + "ts-node": "^10.9.2" } } diff --git a/packages/machine-id/scripts/benchmark.ts b/packages/machine-id/scripts/benchmark.ts index aa62458e..2af90a63 100644 --- a/packages/machine-id/scripts/benchmark.ts +++ b/packages/machine-id/scripts/benchmark.ts @@ -12,7 +12,6 @@ import { machineIdSync } from 'node-machine-id'; // Configuration const ITERATIONS = 100; -const WARMUP_ITERATIONS = 10; // Utility to format time function formatTime(ms: number): string { @@ -40,15 +39,8 @@ function runBenchmark() { console.log(`Test iterations: ${ITERATIONS}`); console.log('----------------------------------------'); - // Warm-up - console.log('Warming up...'); - for (let i = 0; i < WARMUP_ITERATIONS; i++) { - getMachineId({ raw: true }); - machineIdSync(true); - } - // Test raw mode (no hashing) - console.log('\nRaw machine ID retrieval:'); + console.log('Raw:'); const startOursRaw = process.hrtime.bigint(); for (let i = 0; i < ITERATIONS; i++) { @@ -75,8 +67,10 @@ function runBenchmark() { `Comparison: @mongodb-js/machine-id is ${formatComparison(ourTimeRaw, otherTimeRaw)}`, ); + console.log('----------------------------------------'); + // Test hashed mode - console.log('\nHashed machine ID:'); + console.log('Hashed:'); // @mongodb-js/machine-id const startOursHashed = process.hrtime.bigint(); @@ -103,8 +97,6 @@ function runBenchmark() { console.log( `Comparison: @mongodb-js/machine-id is ${formatComparison(ourTimeHashed, otherTimeHashed)}`, ); - - console.log('\n========================================'); } // Run the benchmark diff --git a/packages/machine-id/src/bin/machine-id.ts b/packages/machine-id/src/bin/machine-id.ts new file mode 100644 index 00000000..5ab027e4 --- /dev/null +++ b/packages/machine-id/src/bin/machine-id.ts @@ -0,0 +1,12 @@ +#!/usr/bin/env node +import { getMachineId } from '..'; + +// Check if --raw flag is provided +const rawFlag = process.argv.includes('--raw'); + +// Get the machine ID, passing the raw option if requested +const id = + getMachineId({ raw: rawFlag }) || 'Machine ID not available on this platform'; + +// eslint-disable-next-line no-console +console.log(id); diff --git a/packages/machine-id/src/index.spec.ts b/packages/machine-id/src/index.spec.ts index f8a1470a..560818d0 100644 --- a/packages/machine-id/src/index.spec.ts +++ b/packages/machine-id/src/index.spec.ts @@ -55,89 +55,4 @@ describe('machine-id', function () { expect(hashRegex.test(id)); }); }); - - describe('performance comparison', function () { - // Increase timeout for performance tests - this.timeout(100_000); - - it('performs faster than node-machine-id (raw)', function () { - const iterations = 1000; - - // Warm-up run to account for initial load time - getMachineId({ raw: true }); - otherMachineId(true); - - // Test implementation - const startOurs = process.hrtime.bigint(); - for (let i = 0; i < iterations; i++) { - getMachineId({ raw: true }); - } - const endOurs = process.hrtime.bigint(); - const ourTime = Number(endOurs - startOurs) / 1_000_000; // Convert to ms - - // Test node-machine-id - const startOther = process.hrtime.bigint(); - for (let i = 0; i < iterations; i++) { - otherMachineId(true); - } - const endOther = process.hrtime.bigint(); - const otherTime = Number(endOther - startOther) / 1_000_000; // Convert to ms - - console.log( - `Performance comparison (raw mode, ${iterations} iterations):`, - ); - console.log( - `- Our implementation: ${ourTime.toFixed(4)}ms (${(ourTime / iterations).toFixed(4)}ms per call)`, - ); - console.log( - `- node-machine-id: ${otherTime.toFixed(4)}ms (${(otherTime / iterations).toFixed(4)}ms per call)`, - ); - console.log( - `- Difference: ${ourTime < otherTime ? 'Ours is ' + (otherTime / ourTime).toFixed(2) + 'x faster' : 'node-machine-id is ' + (ourTime / otherTime).toFixed(2) + 'x faster'}`, - ); - - // We expect our native implementation to be faster - // but don't fail the test if it's not, just report the measurements - }); - - it('performs faster than node-machine-id (hashed)', function () { - const iterations = 1000; - - // Warm-up run - getMachineId(); - otherMachineId(); - - // Test our implementation - const startOurs = process.hrtime.bigint(); - for (let i = 0; i < iterations; i++) { - getMachineId(); - } - const endOurs = process.hrtime.bigint(); - const ourTime = Number(endOurs - startOurs) / 1_000_000; // Convert to ms - - // Test node-machine-id - const startOther = process.hrtime.bigint(); - for (let i = 0; i < iterations; i++) { - otherMachineId(); - } - const endOther = process.hrtime.bigint(); - const otherTime = Number(endOther - startOther) / 1_000_000; // Convert to ms - - console.log( - `Performance comparison (hashed mode, ${iterations} iterations):`, - ); - console.log( - `- Our implementation: ${ourTime.toFixed(4)}ms (${(ourTime / iterations).toFixed(4)}ms per call)`, - ); - console.log( - `- node-machine-id: ${otherTime.toFixed(4)}ms (${(otherTime / iterations).toFixed(4)}ms per call)`, - ); - console.log( - `- Difference: ${ourTime < otherTime ? 'Ours is ' + (otherTime / ourTime).toFixed(2) + 'x faster' : 'node-machine-id is ' + (ourTime / otherTime).toFixed(2) + 'x faster'}`, - ); - - // We expect our native implementation to be faster - // but don't fail the test if it's not, just report the measurements - }); - }); }); From 931af288ddc71dcc4f15b845f38df49b258f74bb Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 14:41:14 +0200 Subject: [PATCH 14/19] fix: remove package-lock redundancies --- package-lock.json | 959 ---------------------------------------------- 1 file changed, 959 deletions(-) diff --git a/package-lock.json b/package-lock.json index 555fc09a..fb66f12d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2327,16 +2327,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@eslint/js": { - "version": "8.57.1", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", - "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, "node_modules/@gar/promisify": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", @@ -2356,20 +2346,6 @@ "node": ">=10.10.0" } }, - "node_modules/@humanwhocodes/module-importer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", - "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=12.22" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } - }, "node_modules/@humanwhocodes/object-schema": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", @@ -8973,13 +8949,6 @@ "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", "dev": true }, - "node_modules/@ungap/structured-clone": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz", - "integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==", - "dev": true, - "license": "ISC" - }, "node_modules/@vue/compiler-core": { "version": "3.5.13", "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.13.tgz", @@ -16911,16 +16880,6 @@ "node": ">=8" } }, - "node_modules/is-path-inside": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", - "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/is-plain-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", @@ -28204,455 +28163,6 @@ "typescript": "^5.0.4" } }, - "packages/machine-id/node_modules/@eslint/eslintrc": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", - "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^9.6.0", - "globals": "^13.19.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "packages/machine-id/node_modules/@eslint/eslintrc/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "packages/machine-id/node_modules/@eslint/eslintrc/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "packages/machine-id/node_modules/@humanwhocodes/config-array": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", - "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", - "deprecated": "Use @eslint/config-array instead", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@humanwhocodes/object-schema": "^2.0.3", - "debug": "^4.3.1", - "minimatch": "^3.0.5" - }, - "engines": { - "node": ">=10.10.0" - } - }, - "packages/machine-id/node_modules/@humanwhocodes/config-array/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "packages/machine-id/node_modules/@humanwhocodes/config-array/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "packages/machine-id/node_modules/@humanwhocodes/object-schema": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", - "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", - "deprecated": "Use @eslint/object-schema instead", - "dev": true, - "license": "BSD-3-Clause" - }, - "packages/machine-id/node_modules/@types/node": { - "version": "20.17.30", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.30.tgz", - "integrity": "sha512-7zf4YyHA+jvBNfVrk2Gtvs6x7E8V+YDW05bNfG2XkWDJfYRXrTiP/DsB2zSYTaHX0bGIujTBQdMVAhb+j7mwpg==", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": "~6.19.2" - } - }, - "packages/machine-id/node_modules/acorn": { - "version": "8.14.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", - "integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==", - "dev": true, - "license": "MIT", - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "packages/machine-id/node_modules/ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "packages/machine-id/node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true, - "license": "Python-2.0" - }, - "packages/machine-id/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "packages/machine-id/node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", - "dev": true, - "license": "MIT", - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, - "packages/machine-id/node_modules/diff": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", - "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, - "packages/machine-id/node_modules/eslint": { - "version": "8.57.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", - "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", - "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", - "dev": true, - "license": "MIT", - "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.4", - "@eslint/js": "8.57.1", - "@humanwhocodes/config-array": "^0.13.0", - "@humanwhocodes/module-importer": "^1.0.1", - "@nodelib/fs.walk": "^1.2.8", - "@ungap/structured-clone": "^1.2.0", - "ajv": "^6.12.4", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.3.2", - "doctrine": "^3.0.0", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.2.2", - "eslint-visitor-keys": "^3.4.3", - "espree": "^9.6.1", - "esquery": "^1.4.2", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "globals": "^13.19.0", - "graphemer": "^1.4.0", - "ignore": "^5.2.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "js-yaml": "^4.1.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", - "natural-compare": "^1.4.0", - "optionator": "^0.9.3", - "strip-ansi": "^6.0.1", - "text-table": "^0.2.0" - }, - "bin": { - "eslint": "bin/eslint.js" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "packages/machine-id/node_modules/eslint-scope": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", - "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "packages/machine-id/node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "packages/machine-id/node_modules/eslint/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "packages/machine-id/node_modules/eslint/node_modules/glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", - "dev": true, - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.3" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "packages/machine-id/node_modules/eslint/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "packages/machine-id/node_modules/espree": { - "version": "9.6.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", - "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", - "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "acorn": "^8.9.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.4.1" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "packages/machine-id/node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=4.0" - } - }, - "packages/machine-id/node_modules/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "dev": true, - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "packages/machine-id/node_modules/globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "packages/machine-id/node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "packages/machine-id/node_modules/log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "license": "MIT", - "dependencies": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "packages/machine-id/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "packages/machine-id/node_modules/mocha": { - "version": "10.8.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz", - "integrity": "sha512-VZlYo/WE8t1tstuRmqgeyBgCbJc/lEdopaa+axcKzTBJ+UIdlAB9XnmvTCAH4pwR4ElNInaedhEBmZD8iCSVEg==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-colors": "^4.1.3", - "browser-stdout": "^1.3.1", - "chokidar": "^3.5.3", - "debug": "^4.3.5", - "diff": "^5.2.0", - "escape-string-regexp": "^4.0.0", - "find-up": "^5.0.0", - "glob": "^8.1.0", - "he": "^1.2.0", - "js-yaml": "^4.1.0", - "log-symbols": "^4.1.0", - "minimatch": "^5.1.6", - "ms": "^2.1.3", - "serialize-javascript": "^6.0.2", - "strip-json-comments": "^3.1.1", - "supports-color": "^8.1.1", - "workerpool": "^6.5.1", - "yargs": "^16.2.0", - "yargs-parser": "^20.2.9", - "yargs-unparser": "^2.0.0" - }, - "bin": { - "_mocha": "bin/_mocha", - "mocha": "bin/mocha.js" - }, - "engines": { - "node": ">= 14.0.0" - } - }, "packages/machine-id/node_modules/node-addon-api": { "version": "8.3.1", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.3.1.tgz", @@ -28662,58 +28172,6 @@ "node": "^18 || ^20 || >= 21" } }, - "packages/machine-id/node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "license": "MIT", - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, - "packages/machine-id/node_modules/serialize-javascript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", - "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "randombytes": "^2.1.0" - } - }, - "packages/machine-id/node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" - } - }, - "packages/machine-id/node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true, - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "packages/machine-id/node_modules/typescript": { "version": "5.8.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", @@ -28728,30 +28186,6 @@ "node": ">=14.17" } }, - "packages/machine-id/node_modules/undici-types": { - "version": "6.19.8", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", - "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", - "dev": true, - "license": "MIT" - }, - "packages/machine-id/node_modules/workerpool": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", - "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", - "dev": true, - "license": "Apache-2.0" - }, - "packages/machine-id/node_modules/yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=10" - } - }, "packages/mongodb-cloud-info": { "version": "2.1.7", "license": "Apache-2.0", @@ -31789,12 +31223,6 @@ } } }, - "@eslint/js": { - "version": "8.57.1", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", - "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", - "dev": true - }, "@gar/promisify": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", @@ -31811,12 +31239,6 @@ "minimatch": "^3.0.4" } }, - "@humanwhocodes/module-importer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", - "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", - "dev": true - }, "@humanwhocodes/object-schema": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", @@ -36000,385 +35422,16 @@ "typescript": "^5.0.4" }, "dependencies": { - "@eslint/eslintrc": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", - "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", - "dev": true, - "requires": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^9.6.0", - "globals": "^13.19.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", - "strip-json-comments": "^3.1.1" - }, - "dependencies": { - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - } - } - }, - "@humanwhocodes/config-array": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", - "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", - "dev": true, - "requires": { - "@humanwhocodes/object-schema": "^2.0.3", - "debug": "^4.3.1", - "minimatch": "^3.0.5" - }, - "dependencies": { - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - } - } - }, - "@humanwhocodes/object-schema": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", - "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", - "dev": true - }, - "@types/node": { - "version": "https://registry.npmjs.org/@types/node/-/node-20.17.30.tgz", - "integrity": "sha512-7zf4YyHA+jvBNfVrk2Gtvs6x7E8V+YDW05bNfG2XkWDJfYRXrTiP/DsB2zSYTaHX0bGIujTBQdMVAhb+j7mwpg==", - "dev": true, - "requires": { - "undici-types": "~6.19.2" - } - }, - "acorn": { - "version": "8.14.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz", - "integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==", - "dev": true - }, - "ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", - "dev": true - }, - "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0" - } - }, - "chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", - "dev": true, - "requires": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "fsevents": "~2.3.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - } - }, - "diff": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", - "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", - "dev": true - }, - "eslint": { - "version": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", - "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", - "dev": true, - "requires": { - "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.4", - "@eslint/js": "8.57.1", - "@humanwhocodes/config-array": "^0.13.0", - "@humanwhocodes/module-importer": "^1.0.1", - "@nodelib/fs.walk": "^1.2.8", - "@ungap/structured-clone": "^1.2.0", - "ajv": "^6.12.4", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.3.2", - "doctrine": "^3.0.0", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.2.2", - "eslint-visitor-keys": "^3.4.3", - "espree": "^9.6.1", - "esquery": "^1.4.2", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "globals": "^13.19.0", - "graphemer": "^1.4.0", - "ignore": "^5.2.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "js-yaml": "^4.1.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", - "natural-compare": "^1.4.0", - "optionator": "^0.9.3", - "strip-ansi": "^6.0.1", - "text-table": "^0.2.0" - }, - "dependencies": { - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", - "dev": true, - "requires": { - "is-glob": "^4.0.3" - } - }, - "minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - } - } - }, - "eslint-scope": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", - "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", - "dev": true, - "requires": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - } - }, - "eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true - }, - "espree": { - "version": "9.6.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", - "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", - "dev": true, - "requires": { - "acorn": "^8.9.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.4.1" - } - }, - "estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true - }, - "glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - } - }, - "globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, - "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "requires": { - "argparse": "^2.0.1" - } - }, - "log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "requires": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - } - }, - "minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dev": true, - "requires": { - "brace-expansion": "^2.0.1" - } - }, - "mocha": { - "version": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz", - "integrity": "sha512-VZlYo/WE8t1tstuRmqgeyBgCbJc/lEdopaa+axcKzTBJ+UIdlAB9XnmvTCAH4pwR4ElNInaedhEBmZD8iCSVEg==", - "dev": true, - "requires": { - "ansi-colors": "^4.1.3", - "browser-stdout": "^1.3.1", - "chokidar": "^3.5.3", - "debug": "^4.3.5", - "diff": "^5.2.0", - "escape-string-regexp": "^4.0.0", - "find-up": "^5.0.0", - "glob": "^8.1.0", - "he": "^1.2.0", - "js-yaml": "^4.1.0", - "log-symbols": "^4.1.0", - "minimatch": "^5.1.6", - "ms": "^2.1.3", - "serialize-javascript": "^6.0.2", - "strip-json-comments": "^3.1.1", - "supports-color": "^8.1.1", - "workerpool": "^6.5.1", - "yargs": "^16.2.0", - "yargs-parser": "^20.2.9", - "yargs-unparser": "^2.0.0" - } - }, "node-addon-api": { "version": "8.3.1", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.3.1.tgz", "integrity": "sha512-lytcDEdxKjGJPTLEfW4mYMigRezMlyJY8W4wxJK8zE533Jlb8L8dRuObJFWg2P+AuOIxoCgKF+2Oq4d4Zd0OUA==" }, - "readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "requires": { - "picomatch": "^2.2.1" - } - }, - "serialize-javascript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", - "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", - "dev": true, - "requires": { - "randombytes": "^2.1.0" - } - }, - "supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true - }, "typescript": { "version": "5.8.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "dev": true - }, - "undici-types": { - "version": "6.19.8", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", - "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", - "dev": true - }, - "workerpool": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", - "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", - "dev": true - }, - "yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "dev": true } } }, @@ -38638,12 +37691,6 @@ "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", "dev": true }, - "@ungap/structured-clone": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz", - "integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==", - "dev": true - }, "@vue/compiler-core": { "version": "3.5.13", "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.13.tgz", @@ -44515,12 +43562,6 @@ "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", "dev": true }, - "is-path-inside": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", - "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", - "dev": true - }, "is-plain-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", From 723f5c3e9b4d813ec5b75e90cc6b4e719c377800 Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 14:48:54 +0200 Subject: [PATCH 15/19] docs: add credits --- packages/machine-id/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/machine-id/README.md b/packages/machine-id/README.md index 201c4a42..4e487da1 100644 --- a/packages/machine-id/README.md +++ b/packages/machine-id/README.md @@ -70,6 +70,9 @@ function machineIdSync(original: boolean): string | undefined { } ``` +## Credits +Influenced by the work from [denisbrodbeck/machineid](https://github.com/denisbrodbeck/machineid) and [automation-stack/node-machine-id](https://github.com/automation-stack/node-machine-id). + ## License Apache-2.0 From fb333125a8f2ea11110d5fa1ca805b9421d13c58 Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 15:13:33 +0200 Subject: [PATCH 16/19] feat: add testing coverage and corner case tests --- packages/machine-id/README.md | 22 ++++++------ packages/machine-id/package.json | 3 +- packages/machine-id/src/bin/machine-id.ts | 7 +--- packages/machine-id/src/index.spec.ts | 44 ++++++++++++++++++++++- packages/machine-id/src/index.ts | 9 ++++- 5 files changed, 66 insertions(+), 19 deletions(-) diff --git a/packages/machine-id/README.md b/packages/machine-id/README.md index 4e487da1..5fea92c6 100644 --- a/packages/machine-id/README.md +++ b/packages/machine-id/README.md @@ -28,7 +28,6 @@ const id = getMachineID({ raw: true }); console.log('Original Machine ID:', id); ``` - ## Supported Platforms - **macOS**: Uses the `IOPlatformUUID` from the `IOKit` framework (Supported on macOS 12.0 and later). @@ -44,19 +43,19 @@ Here's a table of performance comparisons between the two libraries, based on th | Test | node-machine-id | @mongodb-js/machine-id | Improvement | | ----------- | --------------- | ---------------------- | ----------- | | **Mac** | -| Raw | 10.71ms | 0.0072ms | 1494x | -| Hashed | 12.42ms | 0.0176ms | 707x | +| Raw | 10.71ms | 0.0072ms | 1494x | +| Hashed | 12.42ms | 0.0176ms | 707x | | **Linux** | -| Raw | 3.26ms | 0.0059ms | 557x | -| Hashed | 3.25ms | 0.0088ms | 368x | +| Raw | 3.26ms | 0.0059ms | 557x | +| Hashed | 3.25ms | 0.0088ms | 368x | | **Windows** | -| Raw | 45.36ms* | 0.0122ms | 3704x | -| Hashed | 28.66ms* | 0.0272ms | 1053x | - -\* - Windows tests may be inaccurate due to potential caching. +| Raw | 45.36ms\* | 0.0122ms | 3704x | +| Hashed | 28.66ms\* | 0.0272ms | 1053x | +\* - Windows tests may be inaccurate due to potential caching. ### Migrating from `node-machine-id` + If you were previously using `node-machine-id`, you can use the following mapping to get a result with the following hashing transformation. This is not guaranteed always to 1:1 match the output of `node-machine-id` for all cases. For example on Linux, it falls back to `/etc/machine-id` if `/var/lib/dbus/machine-id` is not available. ```ts @@ -66,11 +65,14 @@ import { getMachineId } from '@mongodb-js/machine-id'; function machineIdSync(original: boolean): string | undefined { const rawMachineId = getMachineId({ raw: true }).toLowerCase(); - return original ? rawMachineId : createHash('sha256').update(rawMachineId).digest('hex'); + return original + ? rawMachineId + : createHash('sha256').update(rawMachineId).digest('hex'); } ``` ## Credits + Influenced by the work from [denisbrodbeck/machineid](https://github.com/denisbrodbeck/machineid) and [automation-stack/node-machine-id](https://github.com/automation-stack/node-machine-id). ## License diff --git a/packages/machine-id/package.json b/packages/machine-id/package.json index 818af748..748fce7f 100644 --- a/packages/machine-id/package.json +++ b/packages/machine-id/package.json @@ -9,7 +9,8 @@ "bootstrap": "npm run compile", "pretest": "npm run compile", "test": "mocha", - "test-ci": "npm run test", + "test-cov": "nyc -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test", + "test-ci": "npm run test-cov", "lint": "eslint . && prettier --check .", "check": "npm run lint && npm run test", "prepublishOnly": "npm run compile", diff --git a/packages/machine-id/src/bin/machine-id.ts b/packages/machine-id/src/bin/machine-id.ts index 5ab027e4..580fde6e 100644 --- a/packages/machine-id/src/bin/machine-id.ts +++ b/packages/machine-id/src/bin/machine-id.ts @@ -1,12 +1,7 @@ #!/usr/bin/env node import { getMachineId } from '..'; -// Check if --raw flag is provided -const rawFlag = process.argv.includes('--raw'); - -// Get the machine ID, passing the raw option if requested -const id = - getMachineId({ raw: rawFlag }) || 'Machine ID not available on this platform'; +const id = getMachineId({ raw: process.argv.includes('--raw') }) || ''; // eslint-disable-next-line no-console console.log(id); diff --git a/packages/machine-id/src/index.spec.ts b/packages/machine-id/src/index.spec.ts index 560818d0..0b173ff5 100644 --- a/packages/machine-id/src/index.spec.ts +++ b/packages/machine-id/src/index.spec.ts @@ -1,8 +1,13 @@ /* eslint-disable no-console */ import { getMachineId } from '.'; import { machineIdSync as otherMachineId } from 'node-machine-id'; -import { expect } from 'chai'; +import chai, { expect } from 'chai'; import { createHash } from 'crypto'; +import sinonChai from 'sinon-chai'; +import sinon from 'sinon'; +import bindings from 'bindings'; + +chai.use(sinonChai); describe('machine-id', function () { this.timeout(5_000); @@ -53,6 +58,43 @@ describe('machine-id', function () { const hashRegex = /^[0-9a-f]{64}$/i; expect(hashRegex.test(id)); + + expect(id).equals( + createHash('sha256') + .update(getMachineId({ raw: true }) || '') + .digest('hex'), + ); + }); + }); + + describe('edge cases', function () { + afterEach(function () { + sinon.restore(); + }); + + describe('returns undefined', function () { + it('if something goes wrong with the binding function', function () { + sinon + .stub(bindings('machine_id'), 'getMachineId') + .throws(new Error('Binding error')); + + expect(getMachineId({ raw: true })).to.be.undefined; + expect(getMachineId()).to.be.undefined; + }); + + it('if the binding function returns an empty string', function () { + sinon.stub(bindings('machine_id'), 'getMachineId').returns(''); + + expect(getMachineId({ raw: true })).to.be.undefined; + expect(getMachineId()).to.be.undefined; + }); + + it('if the binding function returns undefined', function () { + sinon.stub(bindings('machine_id'), 'getMachineId').returns(undefined); + + expect(getMachineId({ raw: true })).to.be.undefined; + expect(getMachineId()).to.be.undefined; + }); }); }); }); diff --git a/packages/machine-id/src/index.ts b/packages/machine-id/src/index.ts index 66fd9b79..e722e5e6 100644 --- a/packages/machine-id/src/index.ts +++ b/packages/machine-id/src/index.ts @@ -15,7 +15,14 @@ export type GetMachineIdOptions = { export function getMachineId({ raw = false }: GetMachineIdOptions = {}): | string | undefined { - const machineId: string | undefined = binding.getMachineId(); + let machineId: string | undefined; + + try { + machineId = binding.getMachineId(); + } catch { + // If the binding fails, we can assume the machine ID is not available. + return undefined; + } if (!machineId) { return undefined; From 98d5c1f7a8d71f702254630764c1a489e6a22a03 Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 16:13:09 +0200 Subject: [PATCH 17/19] refactor: fixes from feedback --- packages/machine-id/src/index.spec.ts | 18 +++++++++++------- packages/machine-id/src/index.ts | 24 +++++++++++------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/packages/machine-id/src/index.spec.ts b/packages/machine-id/src/index.spec.ts index 0b173ff5..f18d5425 100644 --- a/packages/machine-id/src/index.spec.ts +++ b/packages/machine-id/src/index.spec.ts @@ -6,6 +6,7 @@ import { createHash } from 'crypto'; import sinonChai from 'sinon-chai'; import sinon from 'sinon'; import bindings from 'bindings'; +import assert from 'assert'; chai.use(sinonChai); @@ -16,7 +17,9 @@ describe('machine-id', function () { let id: string; beforeEach(function () { - id = getMachineId({ raw: true }) || ''; + const deviceId = getMachineId(); + assert(deviceId); + id = deviceId; }); it('returns a valid UUID format machine ID', function () { @@ -50,7 +53,9 @@ describe('machine-id', function () { let id: string; beforeEach(function () { - id = getMachineId() || ''; + const deviceId = getMachineId(); + assert(deviceId); + id = deviceId; }); it('returns a valid SHA256 hash format machine ID', function () { @@ -59,11 +64,10 @@ describe('machine-id', function () { expect(hashRegex.test(id)); - expect(id).equals( - createHash('sha256') - .update(getMachineId({ raw: true }) || '') - .digest('hex'), - ); + const hashId = getMachineId({ raw: true }); + assert(hashId); + + expect(id).equals(createHash('sha256').update(hashId).digest('hex')); }); }); diff --git a/packages/machine-id/src/index.ts b/packages/machine-id/src/index.ts index e722e5e6..336cdf4e 100644 --- a/packages/machine-id/src/index.ts +++ b/packages/machine-id/src/index.ts @@ -8,6 +8,15 @@ export type GetMachineIdOptions = { raw?: boolean; }; +function getMachineIdFromBinding(): string | undefined { + try { + return binding.getMachineId() || undefined; + } catch { + // If the binding fails, we can assume the machine ID is not available. + return undefined; + } +} + /** * Get the machine ID for the current system * @returns The machine ID (UUID) or undefined if not available @@ -15,20 +24,9 @@ export type GetMachineIdOptions = { export function getMachineId({ raw = false }: GetMachineIdOptions = {}): | string | undefined { - let machineId: string | undefined; - - try { - machineId = binding.getMachineId(); - } catch { - // If the binding fails, we can assume the machine ID is not available. - return undefined; - } - - if (!machineId) { - return undefined; - } + const machineId: string | undefined = getMachineIdFromBinding(); - if (raw === true) { + if (!machineId || raw === true) { return machineId; } From 657c3b7677c834a36fa06d22b415caf1c2f8991e Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 14 Apr 2025 16:49:08 +0200 Subject: [PATCH 18/19] fix: handle string::npos case in a cleaner way and fix test --- packages/machine-id/binding.cc | 7 +++++-- packages/machine-id/src/index.spec.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/machine-id/binding.cc b/packages/machine-id/binding.cc index 6346ad68..56fae20a 100644 --- a/packages/machine-id/binding.cc +++ b/packages/machine-id/binding.cc @@ -56,9 +56,12 @@ namespace { return str; } - std::string result = str; - result.erase(result.find_last_not_of(" \n\r\t") + 1); + size_t from_right = result.find_last_not_of(" \n\r\t"); + if (from_right != std::string::npos) + { + result.erase(from_right + 1); + } result.erase(0, result.find_first_not_of(" \n\r\t")); return result; } diff --git a/packages/machine-id/src/index.spec.ts b/packages/machine-id/src/index.spec.ts index f18d5425..27647e2f 100644 --- a/packages/machine-id/src/index.spec.ts +++ b/packages/machine-id/src/index.spec.ts @@ -17,7 +17,7 @@ describe('machine-id', function () { let id: string; beforeEach(function () { - const deviceId = getMachineId(); + const deviceId = getMachineId({ raw: true }); assert(deviceId); id = deviceId; }); From 60cc9ce526cb55bf40ef8c295cd07db6cd88b89d Mon Sep 17 00:00:00 2001 From: gagik Date: Tue, 15 Apr 2025 13:20:43 +0200 Subject: [PATCH 19/19] fix: stricter native implementation and type fix from PR feedback --- packages/machine-id/binding.cc | 41 ++++++++++++++++++++------------ packages/machine-id/src/index.ts | 2 +- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/packages/machine-id/binding.cc b/packages/machine-id/binding.cc index 56fae20a..efb39da3 100644 --- a/packages/machine-id/binding.cc +++ b/packages/machine-id/binding.cc @@ -18,7 +18,7 @@ namespace #ifdef __APPLE__ // Get macOS machine ID using IOKit framework directly - std::string getMachineId() + std::string getMachineId() noexcept { std::string uuid; io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMainPortDefault, "IOService:/"); @@ -34,10 +34,14 @@ namespace if (uuidProperty) { char buffer[128]; - if (CFStringGetCString((CFStringRef)uuidProperty, buffer, sizeof(buffer), kCFStringEncodingUTF8)) + if (!CFStringGetCString((CFStringRef)uuidProperty, buffer, sizeof(buffer), kCFStringEncodingUTF8)) { - uuid = buffer; + CFRelease(uuidProperty); + IOObjectRelease(ioRegistryRoot); + return ""; } + + uuid = buffer; CFRelease(uuidProperty); } @@ -77,10 +81,12 @@ namespace if (file.is_open()) { std::string line; - if (std::getline(file, line)) + + if (!file.fail() && std::getline(file, line)) { content = line; } + file.close(); } return content; @@ -94,21 +100,21 @@ namespace // Get Linux machine ID by reading from system files std::string getMachineId() { - std::string id = readFile(DBUS_PATH); + std::string uuid = readFile(DBUS_PATH); // Try fallback path if the first path fails - if (id.empty()) + if (uuid.empty()) { - id = readFile(DBUS_PATH_ETC); + uuid = readFile(DBUS_PATH_ETC); } - return trim(id); + return trim(uuid); } #elif defined(_WIN32) // Get Windows machine ID from registry std::string getMachineId() { - std::string machineGuid; + std::string uuid; HKEY hKey; LONG result = RegOpenKeyExA( HKEY_LOCAL_MACHINE, @@ -122,7 +128,7 @@ namespace return ""; } - char value[128]; + char value[128] = {0}; DWORD valueSize = sizeof(value); DWORD valueType; @@ -134,14 +140,19 @@ namespace reinterpret_cast(value), &valueSize); - RegCloseKey(hKey); - - if (result == ERROR_SUCCESS && valueType == REG_SZ) + if (result == ERROR_SUCCESS && valueType == REG_SZ && valueSize > 0) + { + // Create string with explicit length based on returned valueSize + uuid = std::string(value, valueSize - (value[valueSize - 1] == '\0' ? 1 : 0)); + } + else { - machineGuid = value; + RegCloseKey(hKey); + return ""; } - return machineGuid; + RegCloseKey(hKey); + return uuid; } #endif diff --git a/packages/machine-id/src/index.ts b/packages/machine-id/src/index.ts index 336cdf4e..85fb24a1 100644 --- a/packages/machine-id/src/index.ts +++ b/packages/machine-id/src/index.ts @@ -24,7 +24,7 @@ function getMachineIdFromBinding(): string | undefined { export function getMachineId({ raw = false }: GetMachineIdOptions = {}): | string | undefined { - const machineId: string | undefined = getMachineIdFromBinding(); + const machineId = getMachineIdFromBinding(); if (!machineId || raw === true) { return machineId;