native-machine-id 0.0.1 → 0.0.2
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 +8 -6
- package/binding.cc +1 -1
- package/binding.gyp +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +20 -2
package/README.md
CHANGED
|
@@ -22,11 +22,13 @@ npx native-machine-id --raw
|
|
|
22
22
|
```javascript
|
|
23
23
|
import { getMachineId } from 'native-machine-id';
|
|
24
24
|
|
|
25
|
-
// Get the machine ID
|
|
26
|
-
const hashedId =
|
|
27
|
-
console.log('
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
// Get the machine ID, hashed with SHA-256
|
|
26
|
+
const hashedId = getMachineID();
|
|
27
|
+
console.log('Hashed Machine ID:', hashedId);
|
|
28
|
+
|
|
29
|
+
// Get the raw machine ID (should not be exposed in untrusted environments)
|
|
30
|
+
const rawId = getMachineID({ raw: true });
|
|
31
|
+
console.log('Original Machine ID:', rawId);
|
|
30
32
|
|
|
31
33
|
// Or synchronously
|
|
32
34
|
import { getMachineIdSync } from 'native-machine-id';
|
|
@@ -41,7 +43,7 @@ const id = getMachineIdSync();
|
|
|
41
43
|
|
|
42
44
|
## Comparison with `node-machine-id`
|
|
43
45
|
|
|
44
|
-
This module provides similar functionality to [node-machine-id](https://www.npmjs.com/package/node-machine-id)
|
|
46
|
+
This module provides similar functionality to [node-machine-id](https://www.npmjs.com/package/node-machine-id) while **using native access to system APIs without the need for child processes**, making it much faster and reliable.
|
|
45
47
|
|
|
46
48
|
Here's a table of performance comparisons between the two libraries, based on the average runtime from 1000 iterations of the `getMachineIdSync` and `machineIdSync` functions, from `scripts/benchmark.ts`:
|
|
47
49
|
|
package/binding.cc
CHANGED
package/binding.gyp
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.getMachineIdSync = exports.getMachineId = void 0;
|
|
|
7
7
|
const bindings_1 = __importDefault(require("bindings"));
|
|
8
8
|
const crypto_1 = require("crypto");
|
|
9
9
|
const util_1 = require("util");
|
|
10
|
-
const binding = (0, bindings_1.default)('
|
|
10
|
+
const binding = (0, bindings_1.default)('native_machine_id');
|
|
11
11
|
function getMachineIdFromBindingSync() {
|
|
12
12
|
try {
|
|
13
13
|
return binding.getMachineIdSync() || undefined;
|
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,
|
|
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,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAVD,oCAUC;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;QAC9B,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAVD,4CAUC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "native-machine-id",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
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",
|
|
@@ -58,5 +58,23 @@
|
|
|
58
58
|
"node-machine-id": "^1.1.12",
|
|
59
59
|
"typescript": "^5.0.4",
|
|
60
60
|
"ts-node": "^10.9.2"
|
|
61
|
-
}
|
|
61
|
+
},
|
|
62
|
+
"keywords": [
|
|
63
|
+
"machine id",
|
|
64
|
+
"node machine id",
|
|
65
|
+
"device identifier",
|
|
66
|
+
"node id",
|
|
67
|
+
"unique identifier",
|
|
68
|
+
"device id",
|
|
69
|
+
"machine identifier",
|
|
70
|
+
"unique id",
|
|
71
|
+
"platform id",
|
|
72
|
+
"electron id",
|
|
73
|
+
"node-machine-id",
|
|
74
|
+
"uuid",
|
|
75
|
+
"restrictions",
|
|
76
|
+
"native",
|
|
77
|
+
"telemetry",
|
|
78
|
+
"telemetry id"
|
|
79
|
+
]
|
|
62
80
|
}
|