systeminformation 6.0.0-beta.6 → 6.0.0-beta.8

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
@@ -49,6 +49,8 @@ in a browser.
49
49
  - `npu()` - detected NPUs / AI accelerators (experimental)
50
50
  - `software()` - installed software / applications
51
51
  - `npm()` - globally installed npm packages
52
+ - `fans()` - detected fans with rpm and pwm
53
+ - `serialPorts()` - detected serial / COM ports
52
54
 
53
55
  ### Extended Windows support
54
56
 
@@ -163,7 +165,7 @@ implementations can be tree-shaken away.
163
165
 
164
166
  - complete rewrite in TypeScript with typed declarations for every function
165
167
  - modular imports: load the whole library, a single operating system, or a single function
166
- - new functions: `camera()`, `keyboard()`, `mouse()`, `thunderbolt()`, `pci()`, `npu()`, `software()`, `npm()`
168
+ - new functions: `camera()`, `keyboard()`, `mouse()`, `thunderbolt()`, `pci()`, `npu()`, `software()`, `npm()`, `fans()`, `serialPorts()`
167
169
  - extended Windows support: `disksIO()`, `fsStats()`, `fsOpenFiles()`, `thunderbolt()`
168
170
  - `time()` and `version()` are now asynchronous - all functions are async (async/await preferred, promises as alternative)
169
171
  - callbacks are no longer supported
@@ -616,6 +618,15 @@ On Windows, `si.displays()` reports physical monitors: in duplicate/mirror mode
616
618
  | | [0].maxPower | X | | | | | max power |
617
619
  | | [0].default | X | | X | X | | is default printer |
618
620
  | | [0].serialNumber | | | X | | | serial number |
621
+ | si.serialPorts() | [{...}] | X | | X | X | | detected serial / COM ports |
622
+ | | [0].device | X | | X | X | | device path (COMx on Windows) |
623
+ | | [0].name | X | | X | X | | product / friendly name |
624
+ | | [0].manufacturer | X | | X | X | | manufacturer |
625
+ | | [0].serialNumber | X | | X | X | | serial number (USB only) |
626
+ | | [0].vendorId | X | | X | X | | vendor id (hex) |
627
+ | | [0].productId | X | | X | X | | product id (hex) |
628
+ | | [0].pnpId | X | | | X | | stable id (by-id / DeviceID) |
629
+ | | [0].type | X | | X | X | | usb, onboard, pci, bluetooth |
619
630
 
620
631
  #### 11. Devices
621
632
 
@@ -1017,6 +1028,10 @@ and - as soon as the package exposes them - the fan speeds in `fans()`.
1017
1028
 
1018
1029
  Windows itself does not expose actual fan speeds: `Win32_Fan` only reports that a fan exists, its `DesiredSpeed` is the *requested* speed and is left empty by virtually every mainboard. Real values are read from a running [LibreHardwareMonitor](https://github.com/LibreHardwareMonitor/LibreHardwareMonitor) or OpenHardwareMonitor, which publish their sensors in an own WMI namespace. Without one of these tools running, `fans()` returns an empty array or entries without `rpm`.
1019
1030
 
1031
+ #### Serial Ports
1032
+
1033
+ `serialPorts()` only *enumerates* ports - opening one (baud rate, termios, RTS toggling) needs a native binding and is out of scope for this zero-dependency library. Two things worth knowing: on Linux a port shows up in the list even when your user is not in the `dialout` / `uucp` group, so listing can succeed while opening fails; on Windows the `COMx` number is reassigned per USB port, so `pnpId` is the only stable key. RS-232 and RS-485 cannot be told apart by enumeration - an RS-485 transceiver looks like an ordinary UART to the operating system - so no such information is reported.
1034
+
1020
1035
  #### Windows Temperature, Battery, ...
1021
1036
 
1022
1037
  `get-WmiObject` - which is used to determine temperature and battery sometimes needs to be run with admin
@@ -18,7 +18,7 @@ const networkStatsSingle = async (iface) => {
18
18
  let rx_errors = 0;
19
19
  let tx_dropped = 0;
20
20
  let tx_errors = 0;
21
- const { stdout } = await (0, exec_1.execSave)(`netstat -ibndI ${iface}`);
21
+ const stdout = await (0, exec_1.execSecure)('netstat', ['-ibndI', iface]);
22
22
  if (stdout) {
23
23
  const lines = stdout.split('\n');
24
24
  for (let i = 1; i < lines.length; i++) {
@@ -1,6 +1,7 @@
1
- import type { AudioData, BaseboardData, BatteryObject, BiosData, ChassisData, CpuCacheData, CpuObject, CpuTemperatureObject, DisksIoData, DisplayData, FsBlockDevicesData, FsOpenFilesData, FsStatsData, InetChecksiteData, MemData, NetworkInterfacesData, NetworkStatsData, NpuData, OsData, PciData, ProcessesData, SystemData, UsbData, UuidData } from './types';
1
+ import type { AudioData, BaseboardData, BatteryObject, BiosData, ChassisData, CpuCacheData, CpuObject, CpuTemperatureObject, DisksIoData, DisplayData, FsBlockDevicesData, FsOpenFilesData, FsStatsData, InetChecksiteData, MemData, NetworkInterfacesData, NetworkStatsData, NpuData, OsData, PciData, ProcessesData, SerialPortData, SystemData, UsbData, UuidData } from './types';
2
2
  export declare const initBatteryResult: BatteryObject;
3
3
  export declare const initAudioResult: AudioData;
4
+ export declare const initSerialPortResult: SerialPortData;
4
5
  export declare const initUsbResult: UsbData;
5
6
  export declare const initCpuResult: CpuObject;
6
7
  export declare const initCpuCacheResult: CpuCacheData;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initNetworkSpeed = exports.initPciData = exports.initNpuData = exports.initNetworkInterface = exports.initProcesses = exports.initDisplay = exports.initDiskIo = exports.initFsStats = exports.initFsBlockDevice = exports.initFsOpenFiles = exports.initSystem = exports.initBios = exports.initBaseboard = exports.initChassis = exports.initUUID = exports.initOsInfo = exports.initMemData = exports.initCheckSite = exports.initCpuTemperature = exports.initCpuCacheResult = exports.initCpuResult = exports.initUsbResult = exports.initAudioResult = exports.initBatteryResult = void 0;
3
+ exports.initNetworkSpeed = exports.initPciData = exports.initNpuData = exports.initNetworkInterface = exports.initProcesses = exports.initDisplay = exports.initDiskIo = exports.initFsStats = exports.initFsBlockDevice = exports.initFsOpenFiles = exports.initSystem = exports.initBios = exports.initBaseboard = exports.initChassis = exports.initUUID = exports.initOsInfo = exports.initMemData = exports.initCheckSite = exports.initCpuTemperature = exports.initCpuCacheResult = exports.initCpuResult = exports.initUsbResult = exports.initSerialPortResult = exports.initAudioResult = exports.initBatteryResult = void 0;
4
4
  const node_os_1 = require("node:os");
5
5
  const acceleration_1 = require("./acceleration");
6
6
  const const_1 = require("./const");
@@ -34,6 +34,16 @@ exports.initAudioResult = {
34
34
  out: null,
35
35
  status: ''
36
36
  };
37
+ exports.initSerialPortResult = {
38
+ device: '',
39
+ name: null,
40
+ manufacturer: null,
41
+ serialNumber: null,
42
+ vendorId: null,
43
+ productId: null,
44
+ pnpId: null,
45
+ type: 'unknown'
46
+ };
37
47
  exports.initUsbResult = {
38
48
  id: null,
39
49
  bus: null,
@@ -4,7 +4,6 @@ exports.mergeControllerNvidia = exports.nvidiaDevices = exports.nvidiaSmi = expo
4
4
  const promises_1 = require("fs/promises");
5
5
  const const_1 = require("./const");
6
6
  const exec_1 = require("./exec");
7
- const security_1 = require("./security");
8
7
  let _nvidiaSmiPath = null;
9
8
  const getNvidiaSmi = async () => {
10
9
  if (_nvidiaSmiPath !== null) {
@@ -49,11 +48,9 @@ const nvidiaSmi = async () => {
49
48
  const nvidiaSmiExe = await (0, exports.getNvidiaSmi)();
50
49
  if (nvidiaSmiExe) {
51
50
  const nvidiaSmiOpts = '--query-gpu=driver_version,pci.sub_device_id,name,pci.bus_id,fan.speed,memory.total,memory.used,memory.free,utilization.gpu,utilization.memory,temperature.gpu,temperature.memory,power.draw,power.limit,clocks.gr,clocks.mem --format=csv,noheader,nounits';
52
- const cmd = `${nvidiaSmiExe} ${nvidiaSmiOpts}`;
53
51
  try {
54
- const sanitized = (0, security_1.sanitizeShellString)(cmd) + (const_1.LINUX ? ' 2>/dev/null' : '') + (const_1.WINDOWS ? ' 2> nul' : '');
55
- const { stdout } = await (0, exec_1.exec)(sanitized, const_1.execOptsWin);
56
- return stdout;
52
+ const { stdout } = await (0, exec_1.execFile)(nvidiaSmiExe, nvidiaSmiOpts.split(' '), const_1.execOptsWin);
53
+ return String(stdout);
57
54
  }
58
55
  catch { }
59
56
  }
@@ -328,6 +328,17 @@ export type FanData = {
328
328
  pwm: number | null;
329
329
  source: string;
330
330
  };
331
+ export type SerialPortType = 'usb' | 'onboard' | 'pci' | 'bluetooth' | 'virtual' | 'unknown';
332
+ export type SerialPortData = {
333
+ device: string;
334
+ name: string | null;
335
+ manufacturer: string | null;
336
+ serialNumber: string | null;
337
+ vendorId: string | null;
338
+ productId: string | null;
339
+ pnpId: string | null;
340
+ type: SerialPortType;
341
+ };
331
342
  export type CurrentLoadData = {
332
343
  avgLoad: number;
333
344
  currentLoad: number;
@@ -12,6 +12,13 @@ const diskLayout = async () => {
12
12
  let stdout = '';
13
13
  let cmd = '';
14
14
  let cmdFullSmart = '';
15
+ const addSmartCmds = (bsdName) => {
16
+ if (typeof bsdName !== 'string' || !/^disk\d+(s\d+)*$/.test(bsdName)) {
17
+ return;
18
+ }
19
+ cmd += `printf "\n${bsdName}|"; diskutil info /dev/${bsdName} | grep SMART;`;
20
+ cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${bsdName};`;
21
+ };
15
22
  try {
16
23
  ({ stdout } = await (0, exec_1.exec)(`system_profiler SPSerialATADataType SPNVMeDataType SPUSBDataType SPStorageDataType -xml`, { maxBuffer: const_1.MAX_BUFFER_SIZE }));
17
24
  const data = (0, darwin_1.plistParser)(stdout, false);
@@ -44,8 +51,7 @@ const diskLayout = async () => {
44
51
  temperature: null,
45
52
  bsdName: disk.bsd_name
46
53
  });
47
- cmd += 'printf "\n' + disk.bsd_name + '|"; diskutil info /dev/' + disk.bsd_name + ' | grep SMART;';
48
- cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${disk.bsd_name};`;
54
+ addSmartCmds(disk.bsd_name);
49
55
  });
50
56
  }
51
57
  });
@@ -74,8 +80,7 @@ const diskLayout = async () => {
74
80
  temperature: null,
75
81
  bsdName: disk.bsd_name
76
82
  });
77
- cmd += 'printf "\n' + disk.bsd_name + '|"; diskutil info /dev/' + disk.bsd_name + ' | grep SMART;';
78
- cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${disk.bsd_name};`;
83
+ addSmartCmds(disk.bsd_name);
79
84
  });
80
85
  }
81
86
  });
@@ -106,8 +111,7 @@ const diskLayout = async () => {
106
111
  temperature: null,
107
112
  bsdName: media.bsd_name
108
113
  });
109
- cmd += 'printf "\n' + media.bsd_name + '|"; diskutil info /dev/' + media.bsd_name + ' | grep SMART;';
110
- cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${disk.bsd_name};`;
114
+ addSmartCmds(media.bsd_name);
111
115
  }
112
116
  else if (disk?._items.length) {
113
117
  disk._items.forEach((subdisk) => {
@@ -46,6 +46,7 @@ export { software } from './software';
46
46
  export { system } from './system';
47
47
  export { thunderbolt } from './thunderbolt';
48
48
  export { time } from '../time';
49
+ export { serialPorts } from './serial-ports';
49
50
  export { usb } from './usb';
50
51
  export { users } from './users';
51
52
  export { uuid } from './uuid';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shell = exports.services = exports.processLoad = exports.processes = exports.printer = exports.pci = exports.osInfo = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
4
- exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.time = exports.thunderbolt = exports.system = exports.software = void 0;
4
+ exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.time = exports.thunderbolt = exports.system = exports.software = void 0;
5
5
  var audio_1 = require("./audio");
6
6
  Object.defineProperty(exports, "audio", { enumerable: true, get: function () { return audio_1.audio; } });
7
7
  var baseboard_1 = require("./baseboard");
@@ -104,6 +104,8 @@ var thunderbolt_1 = require("./thunderbolt");
104
104
  Object.defineProperty(exports, "thunderbolt", { enumerable: true, get: function () { return thunderbolt_1.thunderbolt; } });
105
105
  var time_1 = require("../time");
106
106
  Object.defineProperty(exports, "time", { enumerable: true, get: function () { return time_1.time; } });
107
+ var serial_ports_1 = require("./serial-ports");
108
+ Object.defineProperty(exports, "serialPorts", { enumerable: true, get: function () { return serial_ports_1.serialPorts; } });
107
109
  var usb_1 = require("./usb");
108
110
  Object.defineProperty(exports, "usb", { enumerable: true, get: function () { return usb_1.usb; } });
109
111
  var users_1 = require("./users");
@@ -19,11 +19,11 @@ const networkStatsSingle = async (iface) => {
19
19
  let rx_errors = 0;
20
20
  let tx_dropped = 0;
21
21
  let tx_errors = 0;
22
- let stdout = '';
23
- ({ stdout } = await (0, exec_1.execSave)(`ifconfig ${iface} | grep "status"`));
24
- operstate = (stdout.split(':')[1] || '').trim().toLowerCase();
22
+ let stdout = await (0, exec_1.execSecure)('ifconfig', [iface]);
23
+ const statusLine = stdout.split('\n').find((l) => l.includes('status')) || '';
24
+ operstate = (statusLine.split(':')[1] || '').trim().toLowerCase();
25
25
  operstate = operstate === 'active' ? 'up' : operstate === 'inactive' ? 'down' : 'unknown';
26
- ({ stdout } = await (0, exec_1.execSave)(`netstat -bdnI ${iface}`));
26
+ stdout = await (0, exec_1.execSecure)('netstat', ['-bdnI', iface]);
27
27
  if (stdout) {
28
28
  const lines = stdout.toString().split('\n');
29
29
  if (lines.length > 1 && lines[1].trim() !== '') {
@@ -0,0 +1,2 @@
1
+ import type { SerialPortData } from '../common/types';
2
+ export declare const serialPorts: () => Promise<SerialPortData[]>;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serialPorts = void 0;
4
+ const promises_1 = require("fs/promises");
5
+ const common_1 = require("../common");
6
+ const defaults_1 = require("../common/defaults");
7
+ const exec_1 = require("../common/exec");
8
+ const toHex4 = (value) => {
9
+ const num = Number.parseInt(value, 10);
10
+ return Number.isNaN(num) ? null : num.toString(16).padStart(4, '0');
11
+ };
12
+ const parseUsbPorts = (stdout) => {
13
+ const ports = new Map();
14
+ let usb = {};
15
+ for (const raw of stdout.split('\n')) {
16
+ const line = raw.replace(/\|/g, '').trim();
17
+ if (line.startsWith('+-o')) {
18
+ if (line.includes('class IOUSBHostDevice')) {
19
+ usb = {};
20
+ }
21
+ continue;
22
+ }
23
+ const entry = /^"([^"]+)" = (.+)$/.exec(line);
24
+ if (!entry) {
25
+ continue;
26
+ }
27
+ const key = entry[1];
28
+ const value = (entry[2] || '').replace(/^"|"$/g, '').trim();
29
+ switch (key) {
30
+ case 'idVendor':
31
+ usb.vendorId = toHex4(value);
32
+ break;
33
+ case 'idProduct':
34
+ usb.productId = toHex4(value);
35
+ break;
36
+ case 'USB Vendor Name':
37
+ usb.manufacturer = value || null;
38
+ break;
39
+ case 'USB Product Name':
40
+ usb.name = value || null;
41
+ break;
42
+ case 'USB Serial Number':
43
+ usb.serialNumber = value || null;
44
+ break;
45
+ case 'IOCalloutDevice':
46
+ ports.set(value, { ...usb });
47
+ break;
48
+ default:
49
+ break;
50
+ }
51
+ }
52
+ return ports;
53
+ };
54
+ const calloutDevices = (stdout) => {
55
+ const devices = new Set();
56
+ const regex = /"IOCalloutDevice" = "([^"]+)"/g;
57
+ let match = regex.exec(stdout);
58
+ while (match) {
59
+ if (match[1]) {
60
+ devices.add(match[1]);
61
+ }
62
+ match = regex.exec(stdout);
63
+ }
64
+ return devices;
65
+ };
66
+ const serialPorts = async () => {
67
+ await (0, common_1.nextTick)();
68
+ const result = [];
69
+ let devices = [];
70
+ try {
71
+ devices = (await (0, promises_1.readdir)('/dev')).filter((device) => device.startsWith('cu.'));
72
+ }
73
+ catch {
74
+ return result;
75
+ }
76
+ const [usbTree, bluetoothTree] = await Promise.all([(0, exec_1.execSave)('ioreg -r -c IOUSBHostDevice -l -w0'), (0, exec_1.execSave)('ioreg -r -c IOBluetoothDevice -l -w0')]);
77
+ const usbPorts = parseUsbPorts(usbTree.stdout);
78
+ const bluetoothPorts = calloutDevices(bluetoothTree.stdout);
79
+ for (const device of devices.sort()) {
80
+ const path = `/dev/${device}`;
81
+ const usb = usbPorts.get(path);
82
+ const name = device.substring(3);
83
+ result.push({
84
+ ...(0, common_1.cloneObj)(defaults_1.initSerialPortResult),
85
+ ...usb,
86
+ device: path,
87
+ name: usb?.name || name,
88
+ type: usb ? 'usb' : bluetoothPorts.has(path) ? 'bluetooth' : 'unknown'
89
+ });
90
+ }
91
+ return result;
92
+ };
93
+ exports.serialPorts = serialPorts;
@@ -16,6 +16,7 @@ export declare const getStaticData: () => Promise<{
16
16
  audio: import("./common/types").AudioData[] | null;
17
17
  bluetooth: import("./common/types").BluetoothObject[] | null;
18
18
  usb: import("./common/types").UsbData[] | null;
19
+ serialPorts: import("./common/types").SerialPortData[] | null;
19
20
  printer: import("./common/types").PrinterData[] | null;
20
21
  camera: import("./common/types").Camera[] | null;
21
22
  keyboard: import("./common/types").Keyboard[] | null;
@@ -100,6 +101,7 @@ export declare const getAllData: (srv?: string, iface?: string) => Promise<{
100
101
  audio: import("./common/types").AudioData[] | null;
101
102
  bluetooth: import("./common/types").BluetoothObject[] | null;
102
103
  usb: import("./common/types").UsbData[] | null;
104
+ serialPorts: import("./common/types").SerialPortData[] | null;
103
105
  printer: import("./common/types").PrinterData[] | null;
104
106
  camera: import("./common/types").Camera[] | null;
105
107
  keyboard: import("./common/types").Keyboard[] | null;
package/dist/get-data.js CHANGED
@@ -38,7 +38,7 @@ const common_1 = require("./common");
38
38
  const si = __importStar(require("./index"));
39
39
  const getStaticData = async () => {
40
40
  await (0, common_1.nextTick)();
41
- const [version, system, bios, baseboard, chassis, os, uuid, versions, cpu, cpuFlags, gpu, displays, net, memLayout, diskLayout, audio, bluetooth, usb, printer, camera, keyboard, mouse, pci, thunderbolt, npu, wifiInterfaces, software] = await Promise.all([
41
+ const [version, system, bios, baseboard, chassis, os, uuid, versions, cpu, cpuFlags, gpu, displays, net, memLayout, diskLayout, audio, bluetooth, usb, serialPorts, printer, camera, keyboard, mouse, pci, thunderbolt, npu, wifiInterfaces, software] = await Promise.all([
42
42
  si.version(),
43
43
  si.system(),
44
44
  si.bios(),
@@ -57,6 +57,7 @@ const getStaticData = async () => {
57
57
  si.audio(),
58
58
  si.bluetoothDevices(),
59
59
  si.usb(),
60
+ si.serialPorts(),
60
61
  si.printer(),
61
62
  si.camera(),
62
63
  si.keyboard(),
@@ -85,6 +86,7 @@ const getStaticData = async () => {
85
86
  audio,
86
87
  bluetooth,
87
88
  usb,
89
+ serialPorts,
88
90
  printer,
89
91
  camera,
90
92
  keyboard,
package/dist/index.d.ts CHANGED
@@ -44,6 +44,7 @@ export { pci } from './pci';
44
44
  export { printer } from './printer';
45
45
  export { processes } from './processes';
46
46
  export { processLoad } from './process-load';
47
+ export { serialPorts } from './serial-ports';
47
48
  export { services } from './services';
48
49
  export { shell } from './shell';
49
50
  export { software } from './software';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.osInfo = exports.observe = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetPublicIp = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.getAllData = exports.getDynamicData = exports.getStaticData = exports.get = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
4
- exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.time = exports.thunderbolt = exports.system = exports.software = exports.shell = exports.services = exports.processLoad = exports.processes = exports.printer = exports.pci = void 0;
4
+ exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.time = exports.thunderbolt = exports.system = exports.software = exports.shell = exports.services = exports.serialPorts = exports.processLoad = exports.processes = exports.printer = exports.pci = void 0;
5
5
  var audio_1 = require("./audio");
6
6
  Object.defineProperty(exports, "audio", { enumerable: true, get: function () { return audio_1.audio; } });
7
7
  var baseboard_1 = require("./baseboard");
@@ -102,6 +102,8 @@ var processes_1 = require("./processes");
102
102
  Object.defineProperty(exports, "processes", { enumerable: true, get: function () { return processes_1.processes; } });
103
103
  var process_load_1 = require("./process-load");
104
104
  Object.defineProperty(exports, "processLoad", { enumerable: true, get: function () { return process_load_1.processLoad; } });
105
+ var serial_ports_1 = require("./serial-ports");
106
+ Object.defineProperty(exports, "serialPorts", { enumerable: true, get: function () { return serial_ports_1.serialPorts; } });
105
107
  var services_1 = require("./services");
106
108
  Object.defineProperty(exports, "services", { enumerable: true, get: function () { return services_1.services; } });
107
109
  var shell_1 = require("./shell");
@@ -46,6 +46,7 @@ export { software } from './software';
46
46
  export { system } from './system';
47
47
  export { thunderbolt } from './thunderbolt';
48
48
  export { time } from '../time';
49
+ export { serialPorts } from './serial-ports';
49
50
  export { usb } from './usb';
50
51
  export { users } from './users';
51
52
  export { uuid } from './uuid';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shell = exports.services = exports.processLoad = exports.processes = exports.printer = exports.pci = exports.osInfo = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
4
- exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.time = exports.thunderbolt = exports.system = exports.software = void 0;
4
+ exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.time = exports.thunderbolt = exports.system = exports.software = void 0;
5
5
  var audio_1 = require("./audio");
6
6
  Object.defineProperty(exports, "audio", { enumerable: true, get: function () { return audio_1.audio; } });
7
7
  var baseboard_1 = require("./baseboard");
@@ -104,6 +104,8 @@ var thunderbolt_1 = require("./thunderbolt");
104
104
  Object.defineProperty(exports, "thunderbolt", { enumerable: true, get: function () { return thunderbolt_1.thunderbolt; } });
105
105
  var time_1 = require("../time");
106
106
  Object.defineProperty(exports, "time", { enumerable: true, get: function () { return time_1.time; } });
107
+ var serial_ports_1 = require("./serial-ports");
108
+ Object.defineProperty(exports, "serialPorts", { enumerable: true, get: function () { return serial_ports_1.serialPorts; } });
107
109
  var usb_1 = require("./usb");
108
110
  Object.defineProperty(exports, "usb", { enumerable: true, get: function () { return usb_1.usb; } });
109
111
  var users_1 = require("./users");
@@ -267,7 +267,7 @@ const networkInterfaces = async (defaultString = '', rescan = true) => {
267
267
  ip6subnet = ip6linksubnet;
268
268
  }
269
269
  const ifaceDevName = dev.split(':')[0].trim();
270
- const ifaceSanitized = (0, security_1.sanitizeString)(ifaceDevName);
270
+ const ifaceSanitized = (0, security_1.sanitizeString)(ifaceDevName, true);
271
271
  const cmd = `echo -n "addr_assign_type: "; cat /sys/class/net/${ifaceSanitized}/addr_assign_type 2>/dev/null; echo;
272
272
  echo -n "address: "; cat /sys/class/net/${ifaceSanitized}/address 2>/dev/null; echo;
273
273
  echo -n "addr_len: "; cat /sys/class/net/${ifaceSanitized}/addr_len 2>/dev/null; echo;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.networkStats = void 0;
4
4
  const files_1 = require("../common/files");
5
- const exec_1 = require("../common/exec");
6
5
  const common_1 = require("../common");
7
6
  const security_1 = require("../common/security");
8
7
  const defaults_1 = require("../common/defaults");
@@ -13,40 +12,13 @@ const networkStatsSingle = async (iface) => {
13
12
  await (0, common_1.nextTick)();
14
13
  const defaults = { ...defaults_1.initNetworkSpeed, iface };
15
14
  if (!_network[iface] || (_network[iface] && !_network[iface].ms) || (_network[iface] && _network[iface].ms && Date.now() - _network[iface].ms >= 500)) {
16
- if (await (0, files_1.fileExists)('/sys/class/net/' + iface)) {
17
- const cmd = 'cat /sys/class/net/' +
18
- iface +
19
- '/operstate; ' +
20
- 'cat /sys/class/net/' +
21
- iface +
22
- '/statistics/rx_bytes; ' +
23
- 'cat /sys/class/net/' +
24
- iface +
25
- '/statistics/tx_bytes; ' +
26
- 'cat /sys/class/net/' +
27
- iface +
28
- '/statistics/rx_dropped; ' +
29
- 'cat /sys/class/net/' +
30
- iface +
31
- '/statistics/rx_errors; ' +
32
- 'cat /sys/class/net/' +
33
- iface +
34
- '/statistics/tx_dropped; ' +
35
- 'cat /sys/class/net/' +
36
- iface +
37
- '/statistics/tx_errors; ';
38
- const { stdout } = await (0, exec_1.execSave)(cmd);
39
- if (stdout) {
40
- const lines = stdout.split('\n');
41
- const operstate = lines[0].trim();
42
- const rx_bytes = (0, common_1.toInt)(lines[1]);
43
- const tx_bytes = (0, common_1.toInt)(lines[2]);
44
- const rx_dropped = (0, common_1.toInt)(lines[3]);
45
- const rx_errors = (0, common_1.toInt)(lines[4]);
46
- const tx_dropped = (0, common_1.toInt)(lines[5]);
47
- const tx_errors = (0, common_1.toInt)(lines[6]);
48
- return (0, network_1.calcNetworkSpeed)(iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate, _network);
49
- }
15
+ const dir = '/sys/class/net/' + iface;
16
+ if (/^[\w.:@-]+$/.test(iface) && (await (0, files_1.fileExists)(dir))) {
17
+ const [operstate, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors] = await Promise.all([
18
+ (0, files_1.readSysfs)(dir + '/operstate'),
19
+ ...['rx_bytes', 'tx_bytes', 'rx_dropped', 'rx_errors', 'tx_dropped', 'tx_errors'].map(async (f) => (0, common_1.toInt)(await (0, files_1.readSysfs)(dir + '/statistics/' + f)))
20
+ ]);
21
+ return (0, network_1.calcNetworkSpeed)(iface, rx_bytes, tx_bytes, rx_dropped, rx_errors, tx_dropped, tx_errors, operstate, _network);
50
22
  }
51
23
  return defaults;
52
24
  }
@@ -0,0 +1,2 @@
1
+ import type { SerialPortData } from '../common/types';
2
+ export declare const serialPorts: (sysPath?: string, byIdPath?: string) => Promise<SerialPortData[]>;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serialPorts = void 0;
4
+ const promises_1 = require("fs/promises");
5
+ const path_1 = require("path");
6
+ const common_1 = require("../common");
7
+ const defaults_1 = require("../common/defaults");
8
+ const files_1 = require("../common/files");
9
+ const busType = (subsystem, name) => {
10
+ switch (subsystem) {
11
+ case 'usb':
12
+ case 'usb-serial':
13
+ return 'usb';
14
+ case 'pnp':
15
+ case 'amba':
16
+ case 'platform':
17
+ case 'of_serial':
18
+ return 'onboard';
19
+ case 'pci':
20
+ return 'pci';
21
+ case 'bluetooth':
22
+ return 'bluetooth';
23
+ default:
24
+ return name.startsWith('rfcomm') ? 'bluetooth' : 'unknown';
25
+ }
26
+ };
27
+ const usbDevicePath = async (devicePath) => {
28
+ let current = devicePath;
29
+ for (let depth = 0; depth < 6; depth++) {
30
+ if (await (0, files_1.fileExists)(`${current}/idVendor`)) {
31
+ return current;
32
+ }
33
+ const parent = (0, path_1.dirname)(current);
34
+ if (parent === current) {
35
+ return '';
36
+ }
37
+ current = parent;
38
+ }
39
+ return '';
40
+ };
41
+ const stableIds = async (path) => {
42
+ const map = {};
43
+ try {
44
+ for (const entry of await (0, promises_1.readdir)(path)) {
45
+ try {
46
+ map[(0, path_1.basename)(await (0, promises_1.readlink)(`${path}/${entry}`))] = entry;
47
+ }
48
+ catch { }
49
+ }
50
+ }
51
+ catch { }
52
+ return map;
53
+ };
54
+ const serialPorts = async (sysPath = '/sys/class/tty', byIdPath = '/dev/serial/by-id') => {
55
+ await (0, common_1.nextTick)();
56
+ const result = [];
57
+ let names = [];
58
+ try {
59
+ names = await (0, promises_1.readdir)(sysPath);
60
+ }
61
+ catch {
62
+ return result;
63
+ }
64
+ const byId = await stableIds(byIdPath);
65
+ for (const name of names.sort()) {
66
+ let devicePath = '';
67
+ try {
68
+ devicePath = await (0, promises_1.realpath)(`${sysPath}/${name}/device`);
69
+ }
70
+ catch {
71
+ continue;
72
+ }
73
+ if ((await (0, files_1.readSysfs)(`${sysPath}/${name}/type`)) === '0') {
74
+ continue;
75
+ }
76
+ let subsystem = '';
77
+ try {
78
+ subsystem = (0, path_1.basename)(await (0, promises_1.realpath)(`${devicePath}/subsystem`));
79
+ }
80
+ catch { }
81
+ const port = {
82
+ ...(0, common_1.cloneObj)(defaults_1.initSerialPortResult),
83
+ device: `/dev/${name}`,
84
+ name,
85
+ type: busType(subsystem, name),
86
+ pnpId: byId[name] || null
87
+ };
88
+ const usbPath = await usbDevicePath(devicePath);
89
+ if (usbPath) {
90
+ port.type = 'usb';
91
+ port.vendorId = (await (0, files_1.readSysfs)(`${usbPath}/idVendor`)).toLowerCase() || null;
92
+ port.productId = (await (0, files_1.readSysfs)(`${usbPath}/idProduct`)).toLowerCase() || null;
93
+ port.manufacturer = (await (0, files_1.readSysfs)(`${usbPath}/manufacturer`)) || null;
94
+ port.serialNumber = (await (0, files_1.readSysfs)(`${usbPath}/serial`)) || null;
95
+ port.name = (await (0, files_1.readSysfs)(`${usbPath}/product`)) || name;
96
+ }
97
+ result.push(port);
98
+ }
99
+ return result;
100
+ };
101
+ exports.serialPorts = serialPorts;
@@ -0,0 +1 @@
1
+ export declare const serialPorts: () => Promise<import("./common/types").SerialPortData[] | null>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serialPorts = void 0;
4
+ const const_1 = require("./common/const");
5
+ const serialPorts = async () => {
6
+ switch (true) {
7
+ case const_1.LINUX || const_1.ANDROID:
8
+ return (await import('./linux/serial-ports.js')).serialPorts();
9
+ case const_1.DARWIN:
10
+ return (await import('./darwin/serial-ports.js')).serialPorts();
11
+ case const_1.WINDOWS:
12
+ return (await import('./windows/serial-ports.js')).serialPorts();
13
+ default:
14
+ return null;
15
+ }
16
+ };
17
+ exports.serialPorts = serialPorts;
package/dist/versions.js CHANGED
@@ -414,90 +414,45 @@ const versions = async (apps) => {
414
414
  });
415
415
  }
416
416
  if (Object.keys(appsObj.versions).includes('postgresql')) {
417
- if (const_1.LINUX) {
418
- (0, exec_1.exec)('locate bin/postgres')
419
- .then((res) => {
420
- const postgresqlBin = res.stdout.split('\n').sort();
421
- if (postgresqlBin.length) {
422
- (0, exec_1.exec)(postgresqlBin[postgresqlBin.length - 1] + ' -V')
423
- .then((res) => {
424
- if (res.stdout) {
425
- const postgresql = res.stdout.split('\n')[0].split(' ') || [];
426
- appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
417
+ if (const_1.WINDOWS) {
418
+ windows_1.ps.exec('Get-CimInstance Win32_Service | select caption | fl')
419
+ .then((stdout) => {
420
+ const serviceSections = (stdout ? stdout.toString() : '').split(/\n\s*\n/);
421
+ serviceSections.forEach((item) => {
422
+ const lines = item.trim().split('\r\n');
423
+ const srvCaption = (0, common_1.getValue)(lines, 'caption', ':', true).toLowerCase();
424
+ if (srvCaption.indexOf('postgresql') > -1) {
425
+ const parts = srvCaption.split(' server ');
426
+ if (parts.length > 1) {
427
+ appsObj.versions.postgresql = parts[1];
427
428
  }
428
- functionProcessed();
429
- })
430
- .catch(() => {
431
- functionProcessed();
432
- });
433
- }
434
- else {
435
- functionProcessed();
436
- }
429
+ }
430
+ });
431
+ functionProcessed();
437
432
  })
438
433
  .catch(() => {
439
- (0, exec_1.exec)('psql -V')
440
- .then((res) => {
441
- const postgresql = res.stdout.split('\n')[0].split(' ') || [];
442
- appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
443
- appsObj.versions.postgresql = appsObj.versions.postgresql.split('-')[0];
444
- functionProcessed();
445
- })
446
- .catch(() => {
447
- functionProcessed();
448
- });
434
+ functionProcessed();
449
435
  });
450
436
  }
451
437
  else {
452
- if (const_1.WINDOWS) {
453
- windows_1.ps.exec('Get-CimInstance Win32_Service | select caption | fl')
454
- .then((stdout) => {
455
- const serviceSections = (stdout ? stdout.toString() : '').split(/\n\s*\n/);
456
- serviceSections.forEach((item) => {
457
- const lines = item.trim().split('\r\n');
458
- const srvCaption = (0, common_1.getValue)(lines, 'caption', ':', true).toLowerCase();
459
- if (srvCaption.indexOf('postgresql') > -1) {
460
- const parts = srvCaption.split(' server ');
461
- if (parts.length > 1) {
462
- appsObj.versions.postgresql = parts[1];
463
- }
464
- }
465
- });
466
- functionProcessed();
467
- })
468
- .catch(() => {
469
- functionProcessed();
470
- });
471
- }
472
- else {
473
- (0, exec_1.exec)('postgres -V')
474
- .then((res) => {
475
- if (res.stdout) {
476
- const postgresql = res.stdout.split('\n')[0].split(' ') || [];
477
- appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
478
- if (appsObj.versions.postgresql.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
479
- appsObj.versions.postgresql = postgresql[postgresql.length - 2];
480
- }
438
+ const parsePostgres = (stdout) => {
439
+ const postgresql = stdout.split('\n')[0].split(' ') || [];
440
+ let version = postgresql.length ? postgresql[postgresql.length - 1] : '';
441
+ if (version.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
442
+ version = postgresql[postgresql.length - 2];
443
+ }
444
+ return version.split('-')[0];
445
+ };
446
+ (async () => {
447
+ for (const cmd of ['postgres -V', 'pg_config --version', 'psql -V']) {
448
+ const { stdout } = await (0, exec_1.execSave)(cmd);
449
+ if (stdout) {
450
+ appsObj.versions.postgresql = parsePostgres(stdout);
451
+ break;
481
452
  }
482
- functionProcessed();
483
- })
484
- .catch(() => {
485
- (0, exec_1.exec)('pg_config --version 2> /dev/null')
486
- .then((res) => {
487
- if (res.stdout) {
488
- const postgresql = res.stdout.toString().split('\n')[0].split(' ') || [];
489
- appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
490
- if (appsObj.versions.postgresql.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
491
- appsObj.versions.postgresql = postgresql[postgresql.length - 2];
492
- }
493
- }
494
- })
495
- .catch(() => { })
496
- .finally(() => {
497
- functionProcessed();
498
- });
499
- });
500
- }
453
+ }
454
+ functionProcessed();
455
+ })();
501
456
  }
502
457
  }
503
458
  if (Object.keys(appsObj.versions).includes('perl')) {
@@ -99,6 +99,9 @@ const diskLayout = async () => {
99
99
  const smartDev = JSON.parse(stdout.trim());
100
100
  if (smartDev?.devices && smartDev.devices.length > 0) {
101
101
  for (const dev of smartDev.devices) {
102
+ if (!/^[\w/.,:\\-]+$/.test(String(dev.name || ''))) {
103
+ continue;
104
+ }
102
105
  try {
103
106
  const { stdout: smartOut } = await (0, exec_1.execSave)(`smartctl -j -a ${dev.name}`, const_1.execOptsWin);
104
107
  const smartData = JSON.parse(smartOut);
@@ -49,6 +49,7 @@ export { shell } from './shell';
49
49
  export { software } from './software';
50
50
  export { system } from './system';
51
51
  export { thunderbolt } from './thunderbolt';
52
+ export { serialPorts } from './serial-ports';
52
53
  export { usb } from './usb';
53
54
  export { users } from './users';
54
55
  export { uuid } from './uuid';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.printer = exports.pci = exports.osInfo = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetLatency = exports.gpu = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.displays = exports.disksIO = exports.diskLayout = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = exports.vboxInfo = exports.versions = exports.version = exports.time = exports.inetChecksite = exports.dockerVolumes = exports.dockerInfo = exports.dockerImages = exports.dockerContainerStats = exports.dockerContainers = exports.dockerContainerProcesses = exports.dockerAll = exports.fullLoad = exports.cpuCurrentSpeed = exports.currentLoad = void 0;
4
- exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.uuid = exports.users = exports.usb = exports.thunderbolt = exports.system = exports.software = exports.shell = exports.services = exports.processes = exports.processLoad = void 0;
4
+ exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.thunderbolt = exports.system = exports.software = exports.shell = exports.services = exports.processes = exports.processLoad = void 0;
5
5
  var cpu_current_load_1 = require("../cpu-current-load");
6
6
  Object.defineProperty(exports, "currentLoad", { enumerable: true, get: function () { return cpu_current_load_1.currentLoad; } });
7
7
  var cpu_current_speed_1 = require("../cpu-current-speed");
@@ -110,6 +110,8 @@ var system_1 = require("./system");
110
110
  Object.defineProperty(exports, "system", { enumerable: true, get: function () { return system_1.system; } });
111
111
  var thunderbolt_1 = require("./thunderbolt");
112
112
  Object.defineProperty(exports, "thunderbolt", { enumerable: true, get: function () { return thunderbolt_1.thunderbolt; } });
113
+ var serial_ports_1 = require("./serial-ports");
114
+ Object.defineProperty(exports, "serialPorts", { enumerable: true, get: function () { return serial_ports_1.serialPorts; } });
113
115
  var usb_1 = require("./usb");
114
116
  Object.defineProperty(exports, "usb", { enumerable: true, get: function () { return usb_1.usb; } });
115
117
  var users_1 = require("./users");
@@ -149,8 +149,8 @@ const getWindowsWiredProfilesInformation = async () => {
149
149
  };
150
150
  const getWindowsWirelessIfaceSSID = async (interfaceName) => {
151
151
  try {
152
- const { stdout } = await (0, exec_1.exec)(`netsh wlan show interface name="${interfaceName}" | findstr "SSID"`, const_1.execOptsWin);
153
- const SSID = stdout.split('\r\n')[0];
152
+ const { stdout } = await (0, exec_1.execFile)('netsh', ['wlan', 'show', 'interface', `name=${(0, security_1.sanitizeString)(interfaceName)}`], const_1.execOptsWin);
153
+ const SSID = String(stdout).split('\r\n').find((l) => l.includes('SSID')) || '';
154
154
  const parseSSID = (SSID.split(':').pop() || '').trim();
155
155
  return parseSSID;
156
156
  }
@@ -197,11 +197,10 @@ const getWindowsIEEE8021x = async (connectionType, iface, interfaces) => {
197
197
  let i8021xState = '';
198
198
  let i8021xProtocol = '';
199
199
  try {
200
- const SSID = await getWindowsWirelessIfaceSSID((0, security_1.sanitizeString)(iface));
200
+ const SSID = await getWindowsWirelessIfaceSSID(iface);
201
201
  if (SSID !== 'Unknown') {
202
- const ifaceSanitized = (0, security_1.sanitizeString)(SSID);
203
- const { stdout } = await (0, exec_1.exec)(`netsh wlan show profiles "${ifaceSanitized}"`, const_1.execOptsWin);
204
- const profiles = stdout.split('\r\n');
202
+ const { stdout } = await (0, exec_1.execFile)('netsh', ['wlan', 'show', 'profiles', (0, security_1.sanitizeString)(SSID)], const_1.execOptsWin);
203
+ const profiles = String(stdout).split('\r\n');
205
204
  i8021xState = (profiles.find((l) => l.indexOf('802.1X') >= 0) || '').trim();
206
205
  i8021xProtocol = (profiles.find((l) => l.indexOf('EAP') >= 0) || '').trim();
207
206
  }
@@ -0,0 +1,3 @@
1
+ import type { SerialPortData } from '../common/types';
2
+ export declare const parseSerialPorts: (devices: any[]) => SerialPortData[];
3
+ export declare const serialPorts: () => Promise<SerialPortData[]>;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serialPorts = exports.parseSerialPorts = void 0;
4
+ const common_1 = require("../common");
5
+ const defaults_1 = require("../common/defaults");
6
+ const windows_1 = require("../common/windows");
7
+ const matchId = (deviceId, key) => {
8
+ const match = new RegExp(`${key}_([0-9A-Fa-f]{4})`).exec(deviceId);
9
+ return match?.[1] ? match[1].toLowerCase() : null;
10
+ };
11
+ const parseSerial = (deviceId) => {
12
+ const ftdi = /PID_[0-9A-Fa-f]{4}\+([^+\\]+)/.exec(deviceId);
13
+ if (ftdi?.[1]) {
14
+ return ftdi[1];
15
+ }
16
+ const last = deviceId.split('\\').pop() || '';
17
+ return last && !last.includes('&') ? last : null;
18
+ };
19
+ const parseType = (deviceId) => {
20
+ const id = deviceId.toUpperCase();
21
+ if (id.startsWith('USB\\') || id.startsWith('FTDIBUS\\')) {
22
+ return 'usb';
23
+ }
24
+ if (id.startsWith('BTHENUM') || id.startsWith('BTHLE')) {
25
+ return 'bluetooth';
26
+ }
27
+ if (id.startsWith('PCI\\')) {
28
+ return 'pci';
29
+ }
30
+ if (id.startsWith('ACPI\\')) {
31
+ return 'onboard';
32
+ }
33
+ if (id.startsWith('ROOT\\') || id.startsWith('SW\\') || id.startsWith('UMB\\')) {
34
+ return 'virtual';
35
+ }
36
+ return 'unknown';
37
+ };
38
+ const parseSerialPorts = (devices) => {
39
+ const result = [];
40
+ for (const device of devices) {
41
+ const name = (device.Name || '').trim();
42
+ const port = /\((COM\d+)\)/.exec(name);
43
+ if (!port?.[1]) {
44
+ continue;
45
+ }
46
+ const deviceId = device.DeviceID || device.PNPDeviceID || '';
47
+ const type = parseType(deviceId);
48
+ result.push({
49
+ ...(0, common_1.cloneObj)(defaults_1.initSerialPortResult),
50
+ device: port[1],
51
+ name: name.replace(/\s*\(COM\d+\)\s*$/, '') || port[1],
52
+ manufacturer: (device.Manufacturer || '').trim() || null,
53
+ serialNumber: type === 'usb' ? parseSerial(deviceId) : null,
54
+ vendorId: matchId(deviceId, 'VID'),
55
+ productId: matchId(deviceId, 'PID'),
56
+ pnpId: deviceId || null,
57
+ type
58
+ });
59
+ }
60
+ return result;
61
+ };
62
+ exports.parseSerialPorts = parseSerialPorts;
63
+ const serialPorts = async () => {
64
+ await (0, common_1.nextTick)();
65
+ try {
66
+ const result = await windows_1.ps.exec(`@(Get-CimInstance Win32_PnPEntity -Filter "Name LIKE '%(COM%'" | Select-Object Name,DeviceID,Manufacturer) | ConvertTo-Json -Depth 3`);
67
+ return (0, exports.parseSerialPorts)((0, windows_1.psArray)(result));
68
+ }
69
+ catch {
70
+ return [];
71
+ }
72
+ };
73
+ exports.serialPorts = serialPorts;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "6.0.0-beta.6",
3
+ "version": "6.0.0-beta.8",
4
4
  "description": "Advanced, lightweight system and OS information library",
5
5
  "license": "MIT",
6
6
  "author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",