native-machine-id 0.0.2 → 0.0.4

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.
Files changed (2) hide show
  1. package/binding.cc +8 -1
  2. package/package.json +1 -1
package/binding.cc CHANGED
@@ -4,6 +4,13 @@
4
4
  #ifdef __APPLE__
5
5
  #include <CoreFoundation/CoreFoundation.h>
6
6
  #include <IOKit/IOKitLib.h>
7
+ #include <AvailabilityMacros.h>
8
+ // kIOMainPortDefault is the replacement on macOS 12+ but is not available in older SDKs
9
+ #if (defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED >= 120000)
10
+ #define IO_PORT_DEFAULT kIOMainPortDefault
11
+ #else
12
+ #define IO_PORT_DEFAULT kIOMasterPortDefault
13
+ #endif
7
14
  #elif defined(__linux__)
8
15
  #include <fstream>
9
16
  #include <algorithm>
@@ -21,7 +28,7 @@ namespace
21
28
  std::string getMachineId() noexcept
22
29
  {
23
30
  std::string uuid;
24
- io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMainPortDefault, "IOService:/");
31
+ io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(IO_PORT_DEFAULT, "IOService:/");
25
32
 
26
33
  if (ioRegistryRoot == MACH_PORT_NULL)
27
34
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-machine-id",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
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",