manageos 1.0.1 → 1.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/dist/audio.d.ts +38 -0
- package/dist/audio.d.ts.map +1 -0
- package/dist/audio.js +178 -0
- package/dist/audio.js.map +1 -0
- package/dist/clipboard.d.ts +16 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +56 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/encryption.d.ts +16 -0
- package/dist/encryption.d.ts.map +1 -0
- package/dist/encryption.js +53 -0
- package/dist/encryption.js.map +1 -0
- package/dist/filesystem.d.ts +2 -0
- package/dist/filesystem.d.ts.map +1 -1
- package/dist/filesystem.js +40 -15
- package/dist/filesystem.js.map +1 -1
- package/dist/firewall.d.ts +39 -0
- package/dist/firewall.d.ts.map +1 -0
- package/dist/firewall.js +116 -0
- package/dist/firewall.js.map +1 -0
- package/dist/index.d.ts +22 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -11
- package/dist/index.js.map +1 -1
- package/dist/network.d.ts +82 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +355 -0
- package/dist/network.js.map +1 -0
- package/dist/notification.d.ts +81 -0
- package/dist/notification.d.ts.map +1 -0
- package/dist/notification.js +146 -0
- package/dist/notification.js.map +1 -0
- package/dist/power.d.ts +18 -0
- package/dist/power.d.ts.map +1 -0
- package/dist/power.js +65 -0
- package/dist/power.js.map +1 -0
- package/dist/regedit.js +38 -2
- package/dist/regedit.js.map +1 -1
- package/dist/screen.d.ts +11 -0
- package/dist/screen.d.ts.map +1 -0
- package/dist/screen.js +13 -0
- package/dist/screen.js.map +1 -0
- package/dist/services.d.ts +60 -0
- package/dist/services.d.ts.map +1 -0
- package/dist/services.js +322 -0
- package/dist/services.js.map +1 -0
- package/dist/systeminfo.js +21 -15
- package/dist/systeminfo.js.map +1 -1
- package/dist/taskmgr.js +11 -8
- package/dist/taskmgr.js.map +1 -1
- package/dist/uac.d.ts +28 -0
- package/dist/uac.d.ts.map +1 -0
- package/dist/uac.js +69 -0
- package/dist/uac.js.map +1 -0
- package/dist/{usermanager.d.ts → users.d.ts} +2 -2
- package/dist/users.d.ts.map +1 -0
- package/dist/{usermanager.js → users.js} +7 -4
- package/dist/users.js.map +1 -0
- package/package.json +11 -1
- package/dist/usermanager.d.ts.map +0 -1
- package/dist/usermanager.js.map +0 -1
package/dist/firewall.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const child_process_1 = require("child_process");
|
|
4
|
+
class Async {
|
|
5
|
+
static runCommand(cmd) {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
(0, child_process_1.exec)(`powershell -Command "${cmd}"`, (error) => {
|
|
8
|
+
if (error)
|
|
9
|
+
reject(error);
|
|
10
|
+
else
|
|
11
|
+
resolve();
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
static async addRule(rule) {
|
|
16
|
+
try {
|
|
17
|
+
const parts = [
|
|
18
|
+
`-DisplayName "${rule.name}"`,
|
|
19
|
+
`-Direction ${rule.direction || "Inbound"}`,
|
|
20
|
+
`-Action ${rule.action || "Allow"}`,
|
|
21
|
+
];
|
|
22
|
+
if (rule.protocol)
|
|
23
|
+
parts.push(`-Protocol ${rule.protocol}`);
|
|
24
|
+
if (rule.localPort)
|
|
25
|
+
parts.push(`-LocalPort ${rule.localPort}`);
|
|
26
|
+
if (rule.remoteAddress)
|
|
27
|
+
parts.push(`-RemoteAddress ${rule.remoteAddress}`);
|
|
28
|
+
const cmd = `New-NetFirewallRule ${parts.join(" ")}`;
|
|
29
|
+
await this.runCommand(cmd);
|
|
30
|
+
return { success: true };
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return { success: false, error: error.message };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
static async removeRule(name) {
|
|
37
|
+
try {
|
|
38
|
+
const cmd = `Remove-NetFirewallRule -DisplayName "${name}"`;
|
|
39
|
+
await this.runCommand(cmd);
|
|
40
|
+
return { success: true };
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return { success: false, error: error.message };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
static async listRules() {
|
|
47
|
+
return new Promise((resolve) => {
|
|
48
|
+
(0, child_process_1.exec)(`powershell -Command "Get-NetFirewallRule | Select-Object -ExpandProperty DisplayName"`, { encoding: "utf-8" }, (error, stdout) => {
|
|
49
|
+
if (error) {
|
|
50
|
+
resolve({ success: false, error: error.message });
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const rules = stdout
|
|
54
|
+
.split("\n")
|
|
55
|
+
.map((line) => line.trim())
|
|
56
|
+
.filter((line) => line);
|
|
57
|
+
resolve({ success: true, rules });
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
class Sync {
|
|
63
|
+
static runCommand(cmd) {
|
|
64
|
+
(0, child_process_1.execSync)(`powershell -Command "${cmd}"`, { stdio: "ignore" });
|
|
65
|
+
}
|
|
66
|
+
static addRule(rule) {
|
|
67
|
+
try {
|
|
68
|
+
const parts = [
|
|
69
|
+
`-DisplayName "${rule.name}"`,
|
|
70
|
+
`-Direction ${rule.direction || "Inbound"}`,
|
|
71
|
+
`-Action ${rule.action || "Allow"}`,
|
|
72
|
+
];
|
|
73
|
+
if (rule.protocol)
|
|
74
|
+
parts.push(`-Protocol ${rule.protocol}`);
|
|
75
|
+
if (rule.localPort)
|
|
76
|
+
parts.push(`-LocalPort ${rule.localPort}`);
|
|
77
|
+
if (rule.remoteAddress)
|
|
78
|
+
parts.push(`-RemoteAddress ${rule.remoteAddress}`);
|
|
79
|
+
const cmd = `New-NetFirewallRule ${parts.join(" ")}`;
|
|
80
|
+
this.runCommand(cmd);
|
|
81
|
+
return { success: true };
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return { success: false, error: error.message };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
static removeRule(name) {
|
|
88
|
+
try {
|
|
89
|
+
const cmd = `Remove-NetFirewallRule -DisplayName "${name}"`;
|
|
90
|
+
this.runCommand(cmd);
|
|
91
|
+
return { success: true };
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return { success: false, error: error.message };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
static listRules() {
|
|
98
|
+
try {
|
|
99
|
+
const output = (0, child_process_1.execSync)(`powershell -Command "Get-NetFirewallRule | Select-Object -ExpandProperty DisplayName"`, { encoding: "utf-8" });
|
|
100
|
+
const rules = output
|
|
101
|
+
.split("\n")
|
|
102
|
+
.map((line) => line.trim())
|
|
103
|
+
.filter((line) => line);
|
|
104
|
+
return { success: true, rules };
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
return { success: false, error: error.message };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
class Firewall {
|
|
112
|
+
static Sync = Sync;
|
|
113
|
+
static Async = Async;
|
|
114
|
+
}
|
|
115
|
+
exports.default = Firewall;
|
|
116
|
+
//# sourceMappingURL=firewall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firewall.js","sourceRoot":"","sources":["../src/firewall.ts"],"names":[],"mappings":";;AAAA,iDAA+C;AAsB/C,MAAM,KAAK;IACD,MAAM,CAAC,UAAU,CAAC,GAAW;QACnC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAA,oBAAI,EAAC,wBAAwB,GAAG,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE;gBAC7C,IAAI,KAAK;oBAAE,MAAM,CAAC,KAAK,CAAC,CAAC;;oBACpB,OAAO,EAAE,CAAC;YACjB,CAAC,CAAC,CAA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EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;YAC1B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAClC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QAClD,CAAC;IACH,CAAC;CACF;AAED,MAAqB,QAAQ;IACpB,MAAM,CAAU,IAAI,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC;;AAFvC,2BAGC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,12 +2,32 @@ import Regedit from "./regedit";
|
|
|
2
2
|
import Taskmgr from "./taskmgr";
|
|
3
3
|
import FileSystem from "./filesystem";
|
|
4
4
|
import SystemInfo from "./systeminfo";
|
|
5
|
-
import
|
|
5
|
+
import Users from "./users";
|
|
6
|
+
import Network from "./network";
|
|
7
|
+
import Clipboard from "./clipboard";
|
|
8
|
+
import Audio from "./audio";
|
|
9
|
+
import Notification from "./notification";
|
|
10
|
+
import Screen from "./screen";
|
|
11
|
+
import Power from "./power";
|
|
12
|
+
import Services from "./services";
|
|
13
|
+
import Firewall from "./firewall";
|
|
14
|
+
import UAC from "./uac";
|
|
15
|
+
import Encryption from "./encryption";
|
|
6
16
|
export default class ManageOS {
|
|
7
17
|
static readonly Regedit: typeof Regedit;
|
|
8
18
|
static readonly Taskmgr: typeof Taskmgr;
|
|
9
19
|
static readonly FileSystem: typeof FileSystem;
|
|
10
20
|
static readonly SystemInfo: typeof SystemInfo;
|
|
11
|
-
static readonly
|
|
21
|
+
static readonly Users: typeof Users;
|
|
22
|
+
static readonly Network: typeof Network;
|
|
23
|
+
static readonly Clipboard: typeof Clipboard;
|
|
24
|
+
static readonly Audio: typeof Audio;
|
|
25
|
+
static readonly Notification: typeof Notification;
|
|
26
|
+
static readonly Screen: typeof Screen;
|
|
27
|
+
static readonly Power: typeof Power;
|
|
28
|
+
static readonly Services: typeof Services;
|
|
29
|
+
static readonly Firewall: typeof Firewall;
|
|
30
|
+
static readonly UAC: typeof UAC;
|
|
31
|
+
static readonly Encryption: typeof Encryption;
|
|
12
32
|
}
|
|
13
33
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,WAAW,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,MAAM,CAAC,QAAQ,CAAC,OAAO,iBAAW;IAClC,MAAM,CAAC,QAAQ,CAAC,OAAO,iBAAW;IAClC,MAAM,CAAC,QAAQ,CAAC,UAAU,oBAAc;IACxC,MAAM,CAAC,QAAQ,CAAC,UAAU,oBAAc;IACxC,MAAM,CAAC,QAAQ,CAAC,KAAK,eAAS;IAC9B,MAAM,CAAC,QAAQ,CAAC,OAAO,iBAAW;IAClC,MAAM,CAAC,QAAQ,CAAC,SAAS,mBAAa;IACtC,MAAM,CAAC,QAAQ,CAAC,KAAK,eAAS;IAC9B,MAAM,CAAC,QAAQ,CAAC,YAAY,sBAAgB;IAC5C,MAAM,CAAC,QAAQ,CAAC,MAAM,gBAAU;IAChC,MAAM,CAAC,QAAQ,CAAC,KAAK,eAAS;IAC9B,MAAM,CAAC,QAAQ,CAAC,QAAQ,kBAAY;IACpC,MAAM,CAAC,QAAQ,CAAC,QAAQ,kBAAY;IACpC,MAAM,CAAC,QAAQ,CAAC,GAAG,aAAO;IAC1B,MAAM,CAAC,QAAQ,CAAC,UAAU,oBAAc;CACzC"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const regedit_1 = __importDefault(require("./regedit"));
|
|
7
|
+
const taskmgr_1 = __importDefault(require("./taskmgr"));
|
|
8
|
+
const filesystem_1 = __importDefault(require("./filesystem"));
|
|
9
|
+
const systeminfo_1 = __importDefault(require("./systeminfo"));
|
|
10
|
+
const users_1 = __importDefault(require("./users"));
|
|
11
|
+
const network_1 = __importDefault(require("./network"));
|
|
12
|
+
const clipboard_1 = __importDefault(require("./clipboard"));
|
|
13
|
+
const audio_1 = __importDefault(require("./audio"));
|
|
14
|
+
const notification_1 = __importDefault(require("./notification"));
|
|
15
|
+
const screen_1 = __importDefault(require("./screen"));
|
|
16
|
+
const power_1 = __importDefault(require("./power"));
|
|
17
|
+
const services_1 = __importDefault(require("./services"));
|
|
18
|
+
const firewall_1 = __importDefault(require("./firewall"));
|
|
19
|
+
const uac_1 = __importDefault(require("./uac"));
|
|
20
|
+
const encryption_1 = __importDefault(require("./encryption"));
|
|
21
|
+
class ManageOS {
|
|
22
|
+
static Regedit = regedit_1.default;
|
|
23
|
+
static Taskmgr = taskmgr_1.default;
|
|
24
|
+
static FileSystem = filesystem_1.default;
|
|
25
|
+
static SystemInfo = systeminfo_1.default;
|
|
26
|
+
static Users = users_1.default;
|
|
27
|
+
static Network = network_1.default;
|
|
28
|
+
static Clipboard = clipboard_1.default;
|
|
29
|
+
static Audio = audio_1.default;
|
|
30
|
+
static Notification = notification_1.default;
|
|
31
|
+
static Screen = screen_1.default;
|
|
32
|
+
static Power = power_1.default;
|
|
33
|
+
static Services = services_1.default;
|
|
34
|
+
static Firewall = firewall_1.default;
|
|
35
|
+
static UAC = uac_1.default;
|
|
36
|
+
static Encryption = encryption_1.default;
|
|
12
37
|
}
|
|
38
|
+
exports.default = ManageOS;
|
|
13
39
|
//# 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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAAgC;AAChC,wDAAgC;AAChC,8DAAsC;AACtC,8DAAsC;AACtC,oDAA4B;AAC5B,wDAAgC;AAChC,4DAAoC;AACpC,oDAA4B;AAC5B,kEAA0C;AAC1C,sDAA8B;AAC9B,oDAA4B;AAC5B,0DAAkC;AAClC,0DAAkC;AAClC,gDAAwB;AACxB,8DAAsC;AAEtC,MAAqB,QAAQ;IAC3B,MAAM,CAAU,OAAO,GAAG,iBAAO,CAAC;IAClC,MAAM,CAAU,OAAO,GAAG,iBAAO,CAAC;IAClC,MAAM,CAAU,UAAU,GAAG,oBAAU,CAAC;IACxC,MAAM,CAAU,UAAU,GAAG,oBAAU,CAAC;IACxC,MAAM,CAAU,KAAK,GAAG,eAAK,CAAC;IAC9B,MAAM,CAAU,OAAO,GAAG,iBAAO,CAAC;IAClC,MAAM,CAAU,SAAS,GAAG,mBAAS,CAAC;IACtC,MAAM,CAAU,KAAK,GAAG,eAAK,CAAC;IAC9B,MAAM,CAAU,YAAY,GAAG,sBAAY,CAAC;IAC5C,MAAM,CAAU,MAAM,GAAG,gBAAM,CAAC;IAChC,MAAM,CAAU,KAAK,GAAG,eAAK,CAAC;IAC9B,MAAM,CAAU,QAAQ,GAAG,kBAAQ,CAAC;IACpC,MAAM,CAAU,QAAQ,GAAG,kBAAQ,CAAC;IACpC,MAAM,CAAU,GAAG,GAAG,aAAG,CAAC;IAC1B,MAAM,CAAU,UAAU,GAAG,oBAAU,CAAC;;AAf1C,2BAgBC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
type WifiConnectResult = {
|
|
2
|
+
success: boolean;
|
|
3
|
+
error?: string;
|
|
4
|
+
};
|
|
5
|
+
type PingResult = {
|
|
6
|
+
host: string;
|
|
7
|
+
alive: boolean;
|
|
8
|
+
time: number | null;
|
|
9
|
+
numeric_host: string | null;
|
|
10
|
+
details: object | null;
|
|
11
|
+
error?: string;
|
|
12
|
+
};
|
|
13
|
+
type PingCallback = (result: PingResult) => void;
|
|
14
|
+
type WifiProfile = {
|
|
15
|
+
name: string | null;
|
|
16
|
+
ssid: string | null;
|
|
17
|
+
networkType: string | null;
|
|
18
|
+
radioType: string | null;
|
|
19
|
+
authentication: string | null;
|
|
20
|
+
cipher: string | null;
|
|
21
|
+
keyContent: string | null;
|
|
22
|
+
raw: Record<string, string | number | boolean>;
|
|
23
|
+
} | null;
|
|
24
|
+
type BSSID = {
|
|
25
|
+
bssid: string;
|
|
26
|
+
signal?: string;
|
|
27
|
+
radioType?: string;
|
|
28
|
+
channel?: string;
|
|
29
|
+
basicRatesMbps?: string;
|
|
30
|
+
otherRatesMbps?: string;
|
|
31
|
+
[key: string]: string | undefined;
|
|
32
|
+
};
|
|
33
|
+
type WifiNetwork = {
|
|
34
|
+
interfaceName?: string;
|
|
35
|
+
ssid?: string;
|
|
36
|
+
networkType?: string;
|
|
37
|
+
authentication?: string;
|
|
38
|
+
encryption?: string;
|
|
39
|
+
bssids: BSSID[];
|
|
40
|
+
};
|
|
41
|
+
type NetworkInterface = {
|
|
42
|
+
name: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
physicalAddress?: string;
|
|
45
|
+
dHCPEnabled?: string;
|
|
46
|
+
autoconfigurationEnabled?: string;
|
|
47
|
+
linkLocalIPv6Address?: string;
|
|
48
|
+
iPv4Address?: string;
|
|
49
|
+
subnetMask?: string;
|
|
50
|
+
defaultGateway?: string;
|
|
51
|
+
dHCPServer?: string;
|
|
52
|
+
dHCPv6IAID?: string;
|
|
53
|
+
dHCPv6ClientDUID?: string;
|
|
54
|
+
dNSServers?: string | string[];
|
|
55
|
+
leaseObtained?: string;
|
|
56
|
+
leaseExpires?: string;
|
|
57
|
+
mediaState?: string;
|
|
58
|
+
connectionSpecificDNSSuffix?: string;
|
|
59
|
+
netBIOSOverTcpip?: string;
|
|
60
|
+
};
|
|
61
|
+
declare class Sync {
|
|
62
|
+
static connectWifi(profileName: string, interfaceName?: string): WifiConnectResult;
|
|
63
|
+
static disconnectWifi(): boolean;
|
|
64
|
+
static wifiProfile(ssid: string): WifiProfile;
|
|
65
|
+
static interfaces(): NetworkInterface[];
|
|
66
|
+
static ping(hosts: string | string[], callback: PingCallback): PingResult[];
|
|
67
|
+
static wifiNetworks(): WifiNetwork[];
|
|
68
|
+
}
|
|
69
|
+
declare class Async {
|
|
70
|
+
static connectWifi(profileName: string, interfaceName?: string): Promise<WifiConnectResult>;
|
|
71
|
+
static disconnectWifi(): Promise<boolean>;
|
|
72
|
+
static wifiProfile(ssid: string): Promise<WifiProfile>;
|
|
73
|
+
static interfaces(): Promise<NetworkInterface[]>;
|
|
74
|
+
static ping(hosts: string | string[], callback?: PingCallback): Promise<PingResult[]>;
|
|
75
|
+
static wifiNetworks(): Promise<WifiNetwork[]>;
|
|
76
|
+
}
|
|
77
|
+
export default class Network {
|
|
78
|
+
static readonly sync: typeof Sync;
|
|
79
|
+
static readonly async: typeof Async;
|
|
80
|
+
}
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=network.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../src/network.ts"],"names":[],"mappings":"AAIA,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,YAAY,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;AAEjD,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,GA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
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const ping_1 = __importDefault(require("ping"));
|
|
8
|
+
const deasync_1 = __importDefault(require("deasync"));
|
|
9
|
+
function parseWifiProfile(output) {
|
|
10
|
+
const lines = output
|
|
11
|
+
.split(/\r?\n/)
|
|
12
|
+
.map((l) => l.trim())
|
|
13
|
+
.filter(Boolean);
|
|
14
|
+
const result = {};
|
|
15
|
+
function normalizeValue(value) {
|
|
16
|
+
const v = value.toLowerCase();
|
|
17
|
+
if (["yes", "present", "enabled"].includes(v))
|
|
18
|
+
return true;
|
|
19
|
+
if (["no", "not present", "disabled"].includes(v))
|
|
20
|
+
return false;
|
|
21
|
+
if (!isNaN(Number(value)))
|
|
22
|
+
return Number(value);
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
for (const line of lines) {
|
|
26
|
+
const match = line.match(/^(.+?)\s*:\s*(.*)$/);
|
|
27
|
+
if (match) {
|
|
28
|
+
const key = match[1]
|
|
29
|
+
.trim()
|
|
30
|
+
.replace(/\s+/g, " ")
|
|
31
|
+
.replace(/[- ]+([a-zA-Z0-9])/g, (_, c) => c.toUpperCase())
|
|
32
|
+
.replace(/^([A-Z])/, (m) => m.toLowerCase());
|
|
33
|
+
const value = match[2].trim().replace(/^"|"$/g, "");
|
|
34
|
+
result[key] = normalizeValue(value);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
name: result.name ?? null,
|
|
39
|
+
ssid: result.ssidName ?? result.sSIDName ?? null,
|
|
40
|
+
networkType: result.networkType ?? null,
|
|
41
|
+
radioType: result.radioType ?? null,
|
|
42
|
+
authentication: result.authentication ?? null,
|
|
43
|
+
cipher: result.cipher ?? null,
|
|
44
|
+
keyContent: result.keyContent ?? null,
|
|
45
|
+
raw: result,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function parsePingOutput(output) {
|
|
49
|
+
const lines = output
|
|
50
|
+
.split(/\r?\n/)
|
|
51
|
+
.map((line) => line.trim())
|
|
52
|
+
.filter((line) => line);
|
|
53
|
+
let stats = {};
|
|
54
|
+
for (let line of lines) {
|
|
55
|
+
if (line.toLowerCase().startsWith("packets:")) {
|
|
56
|
+
const match = line.match(/Sent\s*=\s*(\d+),\s*Received\s*=\s*(\d+),\s*Lost\s*=\s*(\d+)/i);
|
|
57
|
+
if (match) {
|
|
58
|
+
stats.packets = {
|
|
59
|
+
sent: Number(match[1]),
|
|
60
|
+
received: Number(match[2]),
|
|
61
|
+
lost: Number(match[3]),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (line.toLowerCase().startsWith("minimum =")) {
|
|
66
|
+
const match = line.match(/Minimum\s*=\s*(\d+)ms,\s*Maximum\s*=\s*(\d+)ms,\s*Average\s*=\s*(\d+)ms/i);
|
|
67
|
+
if (match) {
|
|
68
|
+
stats.times = {
|
|
69
|
+
min: Number(match[1]),
|
|
70
|
+
max: Number(match[2]),
|
|
71
|
+
avg: Number(match[3]),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return stats;
|
|
77
|
+
}
|
|
78
|
+
function convertPingResultToJson(res) {
|
|
79
|
+
if (!res || !res.alive) {
|
|
80
|
+
return {
|
|
81
|
+
host: res?.host || null,
|
|
82
|
+
alive: false,
|
|
83
|
+
time: null,
|
|
84
|
+
numeric_host: res?.numeric_host || null,
|
|
85
|
+
details: null,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const stats = parsePingOutput(res.output);
|
|
89
|
+
return {
|
|
90
|
+
host: res.host,
|
|
91
|
+
alive: res.alive,
|
|
92
|
+
time: Number(res.time) || null,
|
|
93
|
+
numeric_host: res.numeric_host,
|
|
94
|
+
details: stats,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function parseWifiNetworks(output) {
|
|
98
|
+
const lines = output.split(/\r?\n/);
|
|
99
|
+
const networks = [];
|
|
100
|
+
let currentNetwork = null;
|
|
101
|
+
let currentBSSID = null;
|
|
102
|
+
const trimKey = (key) => key
|
|
103
|
+
.replace(/\.+/g, "")
|
|
104
|
+
.replace(/\s+/g, " ")
|
|
105
|
+
.trim()
|
|
106
|
+
.replace(/[- ]+([a-zA-Z0-9])/g, (_, chr) => chr.toUpperCase())
|
|
107
|
+
.replace(/^([A-Z])/, (m) => m.toLowerCase());
|
|
108
|
+
for (let line of lines) {
|
|
109
|
+
line = line.trim();
|
|
110
|
+
if (!line)
|
|
111
|
+
continue;
|
|
112
|
+
const ssidMatch = line.match(/^SSID\s+\d+\s+:\s+(.*)$/i);
|
|
113
|
+
if (ssidMatch) {
|
|
114
|
+
if (currentNetwork)
|
|
115
|
+
networks.push(currentNetwork);
|
|
116
|
+
currentNetwork = { ssid: ssidMatch[1], bssids: [] };
|
|
117
|
+
currentBSSID = null;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const interfaceMatch = line.match(/^Interface name\s+:\s+(.*)$/i);
|
|
121
|
+
if (interfaceMatch) {
|
|
122
|
+
if (currentNetwork)
|
|
123
|
+
networks.push(currentNetwork);
|
|
124
|
+
currentNetwork = { interfaceName: interfaceMatch[1], bssids: [] };
|
|
125
|
+
currentBSSID = null;
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const bssidMatch = line.match(/^BSSID\s+\d+\s+:\s+(.*)$/i);
|
|
129
|
+
if (bssidMatch && currentNetwork) {
|
|
130
|
+
currentBSSID = { bssid: bssidMatch[1] };
|
|
131
|
+
currentNetwork.bssids.push(currentBSSID);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const kvMatch = line.match(/^(.+?)\s+:\s+(.*)$/);
|
|
135
|
+
if (kvMatch) {
|
|
136
|
+
const key = trimKey(kvMatch[1]);
|
|
137
|
+
const value = kvMatch[2].trim();
|
|
138
|
+
if (currentBSSID) {
|
|
139
|
+
currentBSSID[key] = value;
|
|
140
|
+
}
|
|
141
|
+
else if (currentNetwork) {
|
|
142
|
+
currentNetwork[key] = value;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (currentNetwork)
|
|
147
|
+
networks.push(currentNetwork);
|
|
148
|
+
return networks;
|
|
149
|
+
}
|
|
150
|
+
function toCamelCase(str) {
|
|
151
|
+
return str
|
|
152
|
+
.replace(/\.+/g, "")
|
|
153
|
+
.replace(/\s+/g, " ")
|
|
154
|
+
.trim()
|
|
155
|
+
.replace(/[- ]+([a-zA-Z0-9])/g, (_, chr) => chr.toUpperCase())
|
|
156
|
+
.replace(/^([A-Z])/, (m) => m.toLowerCase());
|
|
157
|
+
}
|
|
158
|
+
function parseIpconfig(output) {
|
|
159
|
+
const lines = output.split(/\r?\n/);
|
|
160
|
+
const adapters = [];
|
|
161
|
+
let currentAdapter = null;
|
|
162
|
+
for (let line of lines) {
|
|
163
|
+
line = line.trim();
|
|
164
|
+
if (!line)
|
|
165
|
+
continue;
|
|
166
|
+
if (/adapter/i.test(line)) {
|
|
167
|
+
if (currentAdapter)
|
|
168
|
+
adapters.push(currentAdapter);
|
|
169
|
+
currentAdapter = { name: line.replace(":", "") };
|
|
170
|
+
}
|
|
171
|
+
else if (currentAdapter) {
|
|
172
|
+
const match = line.match(/^(.+?)\s*:\s*(.*)$/);
|
|
173
|
+
if (match) {
|
|
174
|
+
const key = toCamelCase(match[1]);
|
|
175
|
+
const value = match[2].trim();
|
|
176
|
+
if (currentAdapter[key]) {
|
|
177
|
+
if (Array.isArray(currentAdapter[key])) {
|
|
178
|
+
currentAdapter[key].push(value);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
currentAdapter[key] = [currentAdapter[key], value];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
currentAdapter[key] = value;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (currentAdapter)
|
|
191
|
+
adapters.push(currentAdapter);
|
|
192
|
+
return adapters;
|
|
193
|
+
}
|
|
194
|
+
class Sync {
|
|
195
|
+
static connectWifi(profileName, interfaceName = "Wi‑Fi") {
|
|
196
|
+
try {
|
|
197
|
+
(0, child_process_1.execSync)(`netsh wlan connect name="${profileName}" interface="${interfaceName}"`, { stdio: "ignore" });
|
|
198
|
+
return { success: true };
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
return { success: false, error: err.message };
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
static disconnectWifi() {
|
|
205
|
+
try {
|
|
206
|
+
(0, child_process_1.execSync)(`netsh wlan disconnect`, { stdio: "ignore" });
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
catch (err) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
static wifiProfile(ssid) {
|
|
214
|
+
try {
|
|
215
|
+
const stdout = (0, child_process_1.execSync)(`netsh wlan show profile name="${ssid}" key=clear`, { encoding: "utf8" });
|
|
216
|
+
return parseWifiProfile(stdout);
|
|
217
|
+
}
|
|
218
|
+
catch (err) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
static interfaces() {
|
|
223
|
+
try {
|
|
224
|
+
const raw = (0, child_process_1.execSync)("ipconfig /all", {
|
|
225
|
+
encoding: "utf8",
|
|
226
|
+
});
|
|
227
|
+
return parseIpconfig(raw);
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
return [];
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
static ping(hosts, callback) {
|
|
234
|
+
const hostList = Array.isArray(hosts) ? hosts : [hosts];
|
|
235
|
+
const results = [];
|
|
236
|
+
hostList.forEach((host) => {
|
|
237
|
+
let result = null;
|
|
238
|
+
let done = false;
|
|
239
|
+
ping_1.default.promise
|
|
240
|
+
.probe(host, { timeout: 5 })
|
|
241
|
+
.then((res) => {
|
|
242
|
+
result = res;
|
|
243
|
+
done = true;
|
|
244
|
+
})
|
|
245
|
+
.catch(() => {
|
|
246
|
+
result = {
|
|
247
|
+
host,
|
|
248
|
+
alive: false,
|
|
249
|
+
time: null,
|
|
250
|
+
output: "",
|
|
251
|
+
numeric_host: null,
|
|
252
|
+
error: "Ping failed",
|
|
253
|
+
};
|
|
254
|
+
done = true;
|
|
255
|
+
});
|
|
256
|
+
while (!done) {
|
|
257
|
+
deasync_1.default.sleep(100);
|
|
258
|
+
}
|
|
259
|
+
const jsonResult = convertPingResultToJson(result);
|
|
260
|
+
callback(jsonResult);
|
|
261
|
+
results.push(jsonResult);
|
|
262
|
+
});
|
|
263
|
+
return results;
|
|
264
|
+
}
|
|
265
|
+
static wifiNetworks() {
|
|
266
|
+
try {
|
|
267
|
+
const raw = (0, child_process_1.execSync)("netsh wlan show networks mode=bssid", {
|
|
268
|
+
encoding: "utf8",
|
|
269
|
+
});
|
|
270
|
+
return parseWifiNetworks(raw);
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
return [];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
class Async {
|
|
278
|
+
static connectWifi(profileName, interfaceName = "Wi‑Fi") {
|
|
279
|
+
return new Promise((resolve) => {
|
|
280
|
+
(0, child_process_1.exec)(`netsh wlan connect name="${profileName}" interface="${interfaceName}"`, { encoding: "utf8" }, (err) => {
|
|
281
|
+
if (err) {
|
|
282
|
+
return resolve({ success: false, error: err.message });
|
|
283
|
+
}
|
|
284
|
+
resolve({ success: true });
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
static disconnectWifi() {
|
|
289
|
+
return new Promise((resolve) => {
|
|
290
|
+
(0, child_process_1.exec)(`netsh wlan disconnect`, { encoding: "utf8" }, (err) => {
|
|
291
|
+
resolve(!err);
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
static async wifiProfile(ssid) {
|
|
296
|
+
return new Promise((resolve) => {
|
|
297
|
+
(0, child_process_1.exec)(`netsh wlan show profile name="${ssid}" key=clear`, { encoding: "utf8" }, (err, stdout) => {
|
|
298
|
+
if (err) {
|
|
299
|
+
return resolve(null);
|
|
300
|
+
}
|
|
301
|
+
resolve(parseWifiProfile(stdout));
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
static interfaces() {
|
|
306
|
+
return new Promise((resolve, reject) => {
|
|
307
|
+
(0, child_process_1.exec)("ipconfig /all", (err, stdout) => {
|
|
308
|
+
if (err)
|
|
309
|
+
return reject(err);
|
|
310
|
+
resolve(parseIpconfig(stdout));
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
static async ping(hosts, callback) {
|
|
315
|
+
const hostList = Array.isArray(hosts) ? hosts : [hosts];
|
|
316
|
+
const results = await Promise.all(hostList.map(async (host) => {
|
|
317
|
+
try {
|
|
318
|
+
const res = await ping_1.default.promise.probe(host, { timeout: 5 });
|
|
319
|
+
const jsonResult = convertPingResultToJson(res);
|
|
320
|
+
if (callback)
|
|
321
|
+
callback(jsonResult);
|
|
322
|
+
return jsonResult;
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
const failed = {
|
|
326
|
+
host,
|
|
327
|
+
alive: false,
|
|
328
|
+
time: null,
|
|
329
|
+
numeric_host: null,
|
|
330
|
+
details: null,
|
|
331
|
+
error: "Ping failed",
|
|
332
|
+
};
|
|
333
|
+
if (callback)
|
|
334
|
+
callback(failed);
|
|
335
|
+
return failed;
|
|
336
|
+
}
|
|
337
|
+
}));
|
|
338
|
+
return results;
|
|
339
|
+
}
|
|
340
|
+
static wifiNetworks() {
|
|
341
|
+
return new Promise((resolve, reject) => {
|
|
342
|
+
(0, child_process_1.exec)("netsh wlan show networks mode=bssid", (err, stdout) => {
|
|
343
|
+
if (err)
|
|
344
|
+
return reject(err);
|
|
345
|
+
resolve(parseWifiNetworks(stdout));
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
class Network {
|
|
351
|
+
static sync = Sync;
|
|
352
|
+
static async = Async;
|
|
353
|
+
}
|
|
354
|
+
exports.default = Network;
|
|
355
|
+
//# sourceMappingURL=network.js.map
|