native-machine-id 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,11 +23,11 @@ npx native-machine-id --raw
23
23
  import { getMachineId } from 'native-machine-id';
24
24
 
25
25
  // Get the machine ID, hashed with SHA-256
26
- const hashedId = getMachineID();
26
+ const hashedId = getMachineId();
27
27
  console.log('Hashed Machine ID:', hashedId);
28
28
 
29
29
  // Get the raw machine ID (should not be exposed in untrusted environments)
30
- const rawId = getMachineID({ raw: true });
30
+ const rawId = getMachineId({ raw: true });
31
31
  console.log('Original Machine ID:', rawId);
32
32
 
33
33
  // Or synchronously
@@ -37,7 +37,7 @@ const id = getMachineIdSync();
37
37
 
38
38
  ## Supported Platforms
39
39
 
40
- - **macOS**: Uses the `IOPlatformUUID` from the `IOKit` framework (Supported on macOS 12.0 and later).
40
+ - **macOS**: Uses the `IOPlatformUUID` from the `IOKit` framework.
41
41
  - **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`.
42
42
  - **Windows**: Uses the `MachineGuid` from the `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography` registry.
43
43
 
package/binding.gyp CHANGED
@@ -10,7 +10,7 @@
10
10
  'xcode_settings': {
11
11
  'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
12
12
  'CLANG_CXX_LIBRARY': 'libc++',
13
- 'MACOSX_DEPLOYMENT_TARGET': '12.0',
13
+ 'MACOSX_DEPLOYMENT_TARGET': '10.7',
14
14
  },
15
15
  'msvs_settings': {
16
16
  'VCCLCompilerTool': { 'ExceptionHandling': 1 },
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA2BA,MAAM,MAAM,mBAAmB,GAAG;IAEhC,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAMF,wBAAsB,YAAY,CAAC,EACjC,GAAW,GACZ,GAAE,mBAAwB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAQxD;AAMD,wBAAgB,gBAAgB,CAAC,EAAE,GAAW,EAAE,GAAE,mBAAwB,GACtE,MAAM,GACN,SAAS,CAQZ"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAoDA,MAAM,MAAM,mBAAmB,GAAG;IAEhC,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAMF,wBAAsB,YAAY,CAAC,EACjC,GAAW,GACZ,GAAE,mBAAwB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAQxD;AAMD,wBAAgB,gBAAgB,CAAC,EAAE,GAAW,EAAE,GAAE,mBAAwB,GACtE,MAAM,GACN,SAAS,CAQZ"}
package/dist/index.js CHANGED
@@ -3,11 +3,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getMachineIdSync = exports.getMachineId = void 0;
6
+ exports.getMachineId = getMachineId;
7
+ exports.getMachineIdSync = getMachineIdSync;
7
8
  const bindings_1 = __importDefault(require("bindings"));
8
9
  const crypto_1 = require("crypto");
9
10
  const util_1 = require("util");
10
- const binding = (0, bindings_1.default)('native_machine_id');
11
+ const getBindings = () => {
12
+ const tries = [
13
+ () => (0, bindings_1.default)('native_machine_id'),
14
+ () => require('../build/Release/native_machine_id.node'),
15
+ () => require('../build/Debug/native_machine_id.node'),
16
+ ];
17
+ for (const tryBinding of tries) {
18
+ try {
19
+ return tryBinding();
20
+ }
21
+ catch (error) {
22
+ }
23
+ }
24
+ throw new Error('Unable to load native machine ID bindings. Please ensure the module is built correctly.');
25
+ };
26
+ const binding = getBindings();
11
27
  function getMachineIdFromBindingSync() {
12
28
  try {
13
29
  return binding.getMachineIdSync() || undefined;
@@ -32,7 +48,6 @@ async function getMachineId({ raw = false, } = {}) {
32
48
  }
33
49
  return (0, crypto_1.createHash)('sha256').update(machineId).digest('hex');
34
50
  }
35
- exports.getMachineId = getMachineId;
36
51
  function getMachineIdSync({ raw = false } = {}) {
37
52
  const machineId = getMachineIdFromBindingSync();
38
53
  if (!machineId || raw === true) {
@@ -40,5 +55,4 @@ function getMachineIdSync({ raw = false } = {}) {
40
55
  }
41
56
  return (0, crypto_1.createHash)('sha256').update(machineId).digest('hex');
42
57
  }
43
- exports.getMachineIdSync = getMachineIdSync;
44
58
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAgC;AAChC,mCAAoC;AACpC,+BAAiC;AAEjC,MAAM,OAAO,GAAG,IAAA,kBAAQ,EAAC,mBAAmB,CAAC,CAAC;AAE9C,SAAS,2BAA2B;IAClC,IAAI;QACF,OAAO,OAAO,CAAC,gBAAgB,EAAE,IAAI,SAAS,CAAC;KAChD;IAAC,MAAM;QAEN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED,KAAK,UAAU,4BAA4B;IACzC,IAAI;QACF,MAAM,QAAQ,GACZ,CAAC,MAAM,IAAA,gBAAS,EAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC,IAAI,SAAS,CAAC;QAE9D,OAAO,QAAQ,CAAC;KACjB;IAAC,MAAM;QAEN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAWM,KAAK,UAAU,YAAY,CAAC,EACjC,GAAG,GAAG,KAAK,MACY,EAAE;IACzB,MAAM,SAAS,GAAG,MAAM,4BAA4B,EAAE,CAAC;IAEvD,IAAI,CAAC,SAAS,IAAI,GAAG,KAAK,IAAI,EAAE;QAC9B,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,M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CAAC;AAED,KAAK,UAAU,4BAA4B;IACzC,IAAI,CAAC;QACH,MAAM,QAAQ,GACZ,CAAC,MAAM,IAAA,gBAAS,EAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC,IAAI,SAAS,CAAC;QAE9D,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,MAAM,CAAC;QAEP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAWM,KAAK,UAAU,YAAY,CAAC,EACjC,GAAG,GAAG,KAAK,MACY,EAAE;IACzB,MAAM,SAAS,GAAG,MAAM,4BAA4B,EAAE,CAAC;IAEvD,IAAI,CAAC,SAAS,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAMD,SAAgB,gBAAgB,CAAC,EAAE,GAAG,GAAG,KAAK,KAA0B,EAAE;IAGxE,MAAM,SAAS,GAAG,2BAA2B,EAAE,CAAC;IAEhD,IAAI,CAAC,SAAS,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-machine-id",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Native retrieval of a unique desktop machine ID without admin privileges or child processes. Faster and more reliable alternative to node-machine-id.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,6 +8,7 @@
8
8
  "compile": "tsc -p tsconfig.json && node-gyp rebuild && gen-esm-wrapper . ./dist/.esm-wrapper.mjs",
9
9
  "bootstrap": "npm run compile",
10
10
  "pretest": "npm run compile",
11
+ "install": "prebuild-install --runtime napi || node-gyp rebuild",
11
12
  "test": "mocha",
12
13
  "test-cov": "nyc -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test",
13
14
  "test-ci": "npm run test-cov",
@@ -20,12 +21,14 @@
20
21
  "gypfile": true,
21
22
  "dependencies": {
22
23
  "bindings": "^1.5.0",
23
- "node-addon-api": "^8.0.0"
24
+ "node-addon-api": "^8.0.0",
25
+ "node-loader": "^2.1.0"
24
26
  },
25
27
  "license": "Apache-2.0",
26
28
  "exports": {
27
29
  "require": "./dist/index.js",
28
- "import": "./dist/.esm-wrapper.mjs"
30
+ "import": "./dist/.esm-wrapper.mjs",
31
+ "types": "./dist/index.d.ts"
29
32
  },
30
33
  "homepage": "https://github.com/mongodb-js/devtools-shared",
31
34
  "repository": {
@@ -47,17 +50,18 @@
47
50
  "@mongodb-js/mocha-config-devtools": "^1.0.5",
48
51
  "@mongodb-js/prettier-config-devtools": "^1.0.2",
49
52
  "@mongodb-js/tsconfig-devtools": "^1.0.3",
53
+ "@types/bindings": "^1.5.5",
50
54
  "@types/chai": "^4.2.21",
51
55
  "@types/mocha": "^9.1.1",
52
- "@types/sinon-chai": "^3.2.5",
53
56
  "@types/node": "^17.0.35",
57
+ "@types/sinon-chai": "^3.2.5",
58
+ "chai": "^4.5.0",
54
59
  "eslint": "^7.25.0",
55
60
  "gen-esm-wrapper": "^1.1.1",
56
61
  "mocha": "^8.4.0",
57
- "chai": "^4.5.0",
58
62
  "node-machine-id": "^1.1.12",
59
- "typescript": "^5.0.4",
60
- "ts-node": "^10.9.2"
63
+ "ts-node": "^10.9.2",
64
+ "typescript": "^5.0.4"
61
65
  },
62
66
  "keywords": [
63
67
  "machine id",