aiservermanager 0.1.1
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 +31 -0
- package/backend/dist/di/container.js +80 -0
- package/backend/dist/di/container.js.map +1 -0
- package/backend/dist/di/types.js +18 -0
- package/backend/dist/di/types.js.map +1 -0
- package/backend/dist/files/validatePassword.ps1 +10 -0
- package/backend/dist/files/wmiGpuQuery.ps1 +15 -0
- package/backend/dist/helpers/ExecTools.js +101 -0
- package/backend/dist/helpers/ExecTools.js.map +1 -0
- package/backend/dist/index.js +51 -0
- package/backend/dist/index.js.map +1 -0
- package/backend/dist/middleware/authMiddleware.js +32 -0
- package/backend/dist/middleware/authMiddleware.js.map +1 -0
- package/backend/dist/models/GpuInfo.js +3 -0
- package/backend/dist/models/GpuInfo.js.map +1 -0
- package/backend/dist/models/ServiceConfig.js +46 -0
- package/backend/dist/models/ServiceConfig.js.map +1 -0
- package/backend/dist/models/ServiceStatus.js +3 -0
- package/backend/dist/models/ServiceStatus.js.map +1 -0
- package/backend/dist/routes/authRoutes.js +46 -0
- package/backend/dist/routes/authRoutes.js.map +1 -0
- package/backend/dist/routes/gpuRoutes.js +35 -0
- package/backend/dist/routes/gpuRoutes.js.map +1 -0
- package/backend/dist/routes/serviceRoutes.js +206 -0
- package/backend/dist/routes/serviceRoutes.js.map +1 -0
- package/backend/dist/routes/systemRoutes.js +64 -0
- package/backend/dist/routes/systemRoutes.js.map +1 -0
- package/backend/dist/services/auth/linuxPasswordVerifier.js +74 -0
- package/backend/dist/services/auth/linuxPasswordVerifier.js.map +1 -0
- package/backend/dist/services/auth/passwordVerifier.js +3 -0
- package/backend/dist/services/auth/passwordVerifier.js.map +1 -0
- package/backend/dist/services/auth/windowsPasswordVerifier.js +73 -0
- package/backend/dist/services/auth/windowsPasswordVerifier.js.map +1 -0
- package/backend/dist/services/authService.js +240 -0
- package/backend/dist/services/authService.js.map +1 -0
- package/backend/dist/services/configManager.js +96 -0
- package/backend/dist/services/configManager.js.map +1 -0
- package/backend/dist/services/controllers/systemctlController.js +287 -0
- package/backend/dist/services/controllers/systemctlController.js.map +1 -0
- package/backend/dist/services/controllers/windowsServiceController.js +201 -0
- package/backend/dist/services/controllers/windowsServiceController.js.map +1 -0
- package/backend/dist/services/detectors/amdLinuxDetector.js +127 -0
- package/backend/dist/services/detectors/amdLinuxDetector.js.map +1 -0
- package/backend/dist/services/detectors/gpuDetector.js +3 -0
- package/backend/dist/services/detectors/gpuDetector.js.map +1 -0
- package/backend/dist/services/detectors/nvidiaSmiDetector.js +67 -0
- package/backend/dist/services/detectors/nvidiaSmiDetector.js.map +1 -0
- package/backend/dist/services/detectors/wmiDetector.js +125 -0
- package/backend/dist/services/detectors/wmiDetector.js.map +1 -0
- package/backend/dist/services/enrichers/gpuEnricher.js +3 -0
- package/backend/dist/services/enrichers/gpuEnricher.js.map +1 -0
- package/backend/dist/services/enrichers/lspciEnricher.js +92 -0
- package/backend/dist/services/enrichers/lspciEnricher.js.map +1 -0
- package/backend/dist/services/enrichers/vulkanEnricher.js +57 -0
- package/backend/dist/services/enrichers/vulkanEnricher.js.map +1 -0
- package/backend/dist/services/gpuService.js +108 -0
- package/backend/dist/services/gpuService.js.map +1 -0
- package/backend/dist/services/helpers/gpuDedup.js +46 -0
- package/backend/dist/services/helpers/gpuDedup.js.map +1 -0
- package/backend/dist/services/helpers/gpuEngineNames.js +22 -0
- package/backend/dist/services/helpers/gpuEngineNames.js.map +1 -0
- package/backend/dist/services/llamaAutocompleteService.js +277 -0
- package/backend/dist/services/llamaAutocompleteService.js.map +1 -0
- package/backend/dist/services/managedServicesController.js +72 -0
- package/backend/dist/services/managedServicesController.js.map +1 -0
- package/backend/dist/services/managedServicesManager.js +91 -0
- package/backend/dist/services/managedServicesManager.js.map +1 -0
- package/backend/dist/services/probes/amdLinuxUsageProbe.js +109 -0
- package/backend/dist/services/probes/amdLinuxUsageProbe.js.map +1 -0
- package/backend/dist/services/probes/gpuUsageProbe.js +3 -0
- package/backend/dist/services/probes/gpuUsageProbe.js.map +1 -0
- package/backend/dist/services/probes/nvidiaSmiUsageProbe.js +67 -0
- package/backend/dist/services/probes/nvidiaSmiUsageProbe.js.map +1 -0
- package/backend/dist/services/providers/systemInfoLinuxProvider.js +188 -0
- package/backend/dist/services/providers/systemInfoLinuxProvider.js.map +1 -0
- package/backend/dist/services/providers/systemInfoWindowsProvider.js +101 -0
- package/backend/dist/services/providers/systemInfoWindowsProvider.js.map +1 -0
- package/backend/dist/services/serviceConfigController.js +116 -0
- package/backend/dist/services/serviceConfigController.js.map +1 -0
- package/backend/dist/services/serviceController.js +3 -0
- package/backend/dist/services/serviceController.js.map +1 -0
- package/backend/dist/services/serviceManager.js +157 -0
- package/backend/dist/services/serviceManager.js.map +1 -0
- package/backend/dist/services/systemInfoProvider.js +3 -0
- package/backend/dist/services/systemInfoProvider.js.map +1 -0
- package/backend/dist/services/systemService.js +42 -0
- package/backend/dist/services/systemService.js.map +1 -0
- package/backend/public/browser/chunk-34LU6STA.js +1 -0
- package/backend/public/browser/chunk-JGNPKRLU.js +4 -0
- package/backend/public/browser/favicon.svg +11 -0
- package/backend/public/browser/index.html +15 -0
- package/backend/public/browser/main-MUMQYBNS.js +5579 -0
- package/backend/public/browser/polyfills-5CFQRCPP.js +2 -0
- package/backend/public/browser/styles-QBUDNRKH.css +1 -0
- package/bin/aiservermanager.js +2 -0
- package/package.json +45 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = serviceRoutes;
|
|
4
|
+
const express_1 = require("express");
|
|
5
|
+
const types_1 = require("../di/types");
|
|
6
|
+
function serviceRoutes(container) {
|
|
7
|
+
const router = (0, express_1.Router)();
|
|
8
|
+
/** Get status of all managed services. */
|
|
9
|
+
router.get("/", async (_req, res) => {
|
|
10
|
+
try {
|
|
11
|
+
const sm = container.get(types_1.SERVICE_MANAGER);
|
|
12
|
+
const statusList = await sm.getStatusList();
|
|
13
|
+
res.json(statusList);
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
res.status(500).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
/** Perform an action on a named service: { name: "llama", action: "start" } */
|
|
20
|
+
router.post("/control", async (req, res) => {
|
|
21
|
+
try {
|
|
22
|
+
const { name, action } = req.body;
|
|
23
|
+
if (!name || !action) {
|
|
24
|
+
return res.status(400).json({ error: "Both 'name' and 'action' are required" });
|
|
25
|
+
}
|
|
26
|
+
if (!["start", "stop", "enable", "disable"].includes(action)) {
|
|
27
|
+
return res.status(400).json({ error: `Invalid action: ${action}` });
|
|
28
|
+
}
|
|
29
|
+
const sm = container.get(types_1.SERVICE_MANAGER);
|
|
30
|
+
const result = await sm.performAction(name, action);
|
|
31
|
+
res.json(result);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
const status = err.message.startsWith("Unknown service") ? 404 : 500;
|
|
35
|
+
res.status(status).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
/** List all user-created service configs. */
|
|
39
|
+
router.get("/config", (_req, res) => {
|
|
40
|
+
try {
|
|
41
|
+
const scc = container.get(types_1.SERVICE_CONFIG_CONTROLLER);
|
|
42
|
+
res.json(scc.listConfigs());
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
res.status(500).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
/** Get a single service config by name. */
|
|
49
|
+
router.get("/config/:name", (req, res) => {
|
|
50
|
+
try {
|
|
51
|
+
const name = Array.isArray(req.params.name) ? req.params.name[0] : req.params.name;
|
|
52
|
+
const scc = container.get(types_1.SERVICE_CONFIG_CONTROLLER);
|
|
53
|
+
const cfg = scc.getConfig(name);
|
|
54
|
+
if (!cfg) {
|
|
55
|
+
return res.status(404).json({ error: `Config "${name}" not found` });
|
|
56
|
+
}
|
|
57
|
+
res.json(cfg);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
res.status(500).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
/** Create or update a service config. */
|
|
64
|
+
router.post("/config", async (req, res) => {
|
|
65
|
+
try {
|
|
66
|
+
const body = req.body;
|
|
67
|
+
if (!body.name || !body.command) {
|
|
68
|
+
return res.status(400).json({ error: "Both 'name' and 'command' are required" });
|
|
69
|
+
}
|
|
70
|
+
const cfg = {
|
|
71
|
+
name: body.name,
|
|
72
|
+
type: body.type,
|
|
73
|
+
command: body.command,
|
|
74
|
+
flags: body.flags ?? [],
|
|
75
|
+
};
|
|
76
|
+
const scc = container.get(types_1.SERVICE_CONFIG_CONTROLLER);
|
|
77
|
+
const result = await scc.createOrUpdate(cfg);
|
|
78
|
+
if (!result.ok) {
|
|
79
|
+
return res.status(400).json({ error: result.error });
|
|
80
|
+
}
|
|
81
|
+
res.status(201).json(result.config);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
res.status(500).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
/** Delete a service config and its systemd unit. */
|
|
88
|
+
router.delete("/config/:name", async (req, res) => {
|
|
89
|
+
try {
|
|
90
|
+
const name = Array.isArray(req.params.name) ? req.params.name[0] : req.params.name;
|
|
91
|
+
const scc = container.get(types_1.SERVICE_CONFIG_CONTROLLER);
|
|
92
|
+
const result = await scc.deleteService(name);
|
|
93
|
+
if (!result.ok) {
|
|
94
|
+
return res.status(404).json({ error: result.error });
|
|
95
|
+
}
|
|
96
|
+
res.json({ ok: true });
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
res.status(500).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
/** List all installed services on the system (excludes custom). */
|
|
103
|
+
router.get("/managed/available", async (_req, res) => {
|
|
104
|
+
try {
|
|
105
|
+
const msc = container.get(types_1.MANAGED_SERVICES_CONTROLLER);
|
|
106
|
+
const available = await msc.listAvailable();
|
|
107
|
+
res.json(available);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
res.status(500).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
/** List the user-selected managed service names. */
|
|
114
|
+
router.get("/managed", (_req, res) => {
|
|
115
|
+
try {
|
|
116
|
+
const msc = container.get(types_1.MANAGED_SERVICES_CONTROLLER);
|
|
117
|
+
res.json(msc.listManaged());
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
res.status(500).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
/** Add a service to the managed list: { name: "docker" } */
|
|
124
|
+
router.post("/managed", async (req, res) => {
|
|
125
|
+
try {
|
|
126
|
+
const { name } = req.body;
|
|
127
|
+
if (!name || typeof name !== "string") {
|
|
128
|
+
return res.status(400).json({ error: "'name' is required" });
|
|
129
|
+
}
|
|
130
|
+
const msc = container.get(types_1.MANAGED_SERVICES_CONTROLLER);
|
|
131
|
+
const result = msc.addManaged(name);
|
|
132
|
+
if (!result.ok) {
|
|
133
|
+
return res.status(409).json({ error: result.error });
|
|
134
|
+
}
|
|
135
|
+
res.status(201).json({ ok: true });
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
res.status(500).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
/** Remove a service from the managed list: { name: "docker" } */
|
|
142
|
+
router.delete("/managed", async (req, res) => {
|
|
143
|
+
try {
|
|
144
|
+
const { name } = req.body;
|
|
145
|
+
if (!name || typeof name !== "string") {
|
|
146
|
+
return res.status(400).json({ error: "'name' is required" });
|
|
147
|
+
}
|
|
148
|
+
const msc = container.get(types_1.MANAGED_SERVICES_CONTROLLER);
|
|
149
|
+
const result = msc.removeManaged(name);
|
|
150
|
+
if (!result.ok) {
|
|
151
|
+
return res.status(404).json({ error: result.error });
|
|
152
|
+
}
|
|
153
|
+
res.json({ ok: true });
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
res.status(500).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
/** Llama autocomplete suggestions: GET /llama/autocomplete?type=binary&query=xxx&binary=/path/to/llama-server */
|
|
160
|
+
router.get("/llama/autocomplete", async (req, res) => {
|
|
161
|
+
try {
|
|
162
|
+
const type = req.query.type;
|
|
163
|
+
const query = req.query.query ?? "";
|
|
164
|
+
const binary = req.query.binary ?? "";
|
|
165
|
+
const validTypes = ["binary", "model", "mmproj", "apikey", "host", "device", "path"];
|
|
166
|
+
if (!type || !validTypes.includes(type)) {
|
|
167
|
+
return res.status(400).json({ error: `Invalid type. Must be one of: ${validTypes.join(", ")}` });
|
|
168
|
+
}
|
|
169
|
+
const acas = container.get(types_1.LLAMA_AUTOCOMPLETE_SERVICE);
|
|
170
|
+
// Pass all existing configs for cross-service suggestions
|
|
171
|
+
const scc = container.get(types_1.SERVICE_CONFIG_CONTROLLER);
|
|
172
|
+
const allConfigs = scc.listConfigs();
|
|
173
|
+
// Wire GPU service for device suggestions (lazy, avoids circular dep)
|
|
174
|
+
try {
|
|
175
|
+
const gpuService = container.get(types_1.GPU_SERVICE);
|
|
176
|
+
acas.setGpuService(gpuService);
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
// GPU service not available — device suggestions will be empty
|
|
180
|
+
}
|
|
181
|
+
const suggestions = await acas.getSuggestions(type, query, allConfigs, binary);
|
|
182
|
+
res.json(suggestions);
|
|
183
|
+
}
|
|
184
|
+
catch (err) {
|
|
185
|
+
res.status(500).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
/** Get recent journal lines for a service: GET /journal/:name?lines=100 */
|
|
189
|
+
router.get("/journal/:name", async (req, res) => {
|
|
190
|
+
try {
|
|
191
|
+
const name = Array.isArray(req.params.name) ? req.params.name[0] : req.params.name;
|
|
192
|
+
const lines = parseInt(req.query.lines, 10) || 100;
|
|
193
|
+
const sm = container.get(types_1.SERVICE_MANAGER);
|
|
194
|
+
const result = await sm.getJournal(name, lines);
|
|
195
|
+
if ("error" in result) {
|
|
196
|
+
return res.status(404).json(result);
|
|
197
|
+
}
|
|
198
|
+
res.json(result);
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
res.status(500).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
return router;
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=serviceRoutes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceRoutes.js","sourceRoot":"","sources":["../../src/routes/serviceRoutes.ts"],"names":[],"mappings":";;AAiBA,gCA+NC;AAhPD,qCAAoD;AAEpD,uCAMqB;AASrB,SAAwB,aAAa,CAAC,SAAoB;IACxD,MAAM,MAAM,GAAG,IAAA,gBAAM,GAAE,CAAC;IAExB,0CAA0C;IAC1C,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAClC,IAAI,CAAC;YACH,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,CAAiB,uBAAe,CAAC,CAAC;YAC1D,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC,aAAa,EAAE,CAAC;YAC5C,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACvB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,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C,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;YACnF,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,KAAe,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;YAE7D,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,CAAiB,uBAAe,CAAC,CAAC;YAC1D,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAEhD,IAAI,OAAO,IAAI,MAAM,EAAE,CAAC;gBACtB,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACtC,CAAC;YAED,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;QACxF,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = systemRoutes;
|
|
4
|
+
const express_1 = require("express");
|
|
5
|
+
const ExecTools_1 = require("../helpers/ExecTools");
|
|
6
|
+
const types_1 = require("../di/types");
|
|
7
|
+
function systemRoutes(container) {
|
|
8
|
+
const router = (0, express_1.Router)();
|
|
9
|
+
/** Get system information via platform-aware provider. */
|
|
10
|
+
router.get("/info", async (_req, res) => {
|
|
11
|
+
try {
|
|
12
|
+
const providers = container.getAll(types_1.SYSTEM_INFO_PROVIDER);
|
|
13
|
+
let provider = null;
|
|
14
|
+
for (const p of providers) {
|
|
15
|
+
if (await p.isAvailable()) {
|
|
16
|
+
provider = p;
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (!provider) {
|
|
21
|
+
res.status(501).json({ error: "System info is not available on this platform" });
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
res.json(await provider.getSystemInfo());
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
res.status(500).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
/** Reboot the server. */
|
|
31
|
+
router.post("/reboot", async (_req, res) => {
|
|
32
|
+
try {
|
|
33
|
+
const cmd = process.platform === "win32" ? "shutdown /r /t 0" : "sudo reboot";
|
|
34
|
+
const result = await ExecTools_1.ExecTools.safeExec(cmd);
|
|
35
|
+
if (result.stderr) {
|
|
36
|
+
res.status(500).json({ error: result.stderr });
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
res.json({ status: "reboot initiated" });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
res.status(500).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
/** Shutdown the server. */
|
|
47
|
+
router.post("/shutdown", async (_req, res) => {
|
|
48
|
+
try {
|
|
49
|
+
const cmd = process.platform === "win32" ? "shutdown /s /t 0" : "sudo poweroff";
|
|
50
|
+
const result = await ExecTools_1.ExecTools.safeExec(cmd);
|
|
51
|
+
if (result.stderr) {
|
|
52
|
+
res.status(500).json({ error: result.stderr });
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
res.json({ status: "shutdown initiated" });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
res.status(500).json({ error: err instanceof Error ? err.message : "Unknown error" });
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return router;
|
|
63
|
+
}
|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AC;YACjD,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;QACxF,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.LinuxPasswordVerifier = void 0;
|
|
43
|
+
const os = __importStar(require("os"));
|
|
44
|
+
const inversify_1 = require("inversify");
|
|
45
|
+
/**
|
|
46
|
+
* Verify password through PAM using the 'login' service.
|
|
47
|
+
* Uses the same authentication stack as system login.
|
|
48
|
+
*/
|
|
49
|
+
let LinuxPasswordVerifier = class LinuxPasswordVerifier {
|
|
50
|
+
username = os.userInfo().username;
|
|
51
|
+
async verify(password) {
|
|
52
|
+
const pam = require("authenticate-pam");
|
|
53
|
+
if (!pam) {
|
|
54
|
+
console.warn("[LinuxPasswordVerifier] PAM not available on this platform");
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return new Promise((resolve) => {
|
|
58
|
+
pam.authenticate(this.username, password, (err, _userInfo) => {
|
|
59
|
+
if (err) {
|
|
60
|
+
console.error(`[LinuxPasswordVerifier] PAM auth failed for ${this.username}: ${err.message}`);
|
|
61
|
+
resolve(false);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
console.log(`[LinuxPasswordVerifier] PAM auth successful for ${this.username}`);
|
|
65
|
+
resolve(true);
|
|
66
|
+
}, { serviceName: "login" });
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
exports.LinuxPasswordVerifier = LinuxPasswordVerifier;
|
|
71
|
+
exports.LinuxPasswordVerifier = LinuxPasswordVerifier = __decorate([
|
|
72
|
+
(0, inversify_1.injectable)()
|
|
73
|
+
], LinuxPasswordVerifier);
|
|
74
|
+
//# sourceMappingURL=linuxPasswordVerifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linuxPasswordVerifier.js","sourceRoot":"","sources":["../../../src/services/auth/linuxPasswordVerifier.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,yCAAuC;AAYvC;;;GAGG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACf,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC;IAEnD,KAAK,CAAC,MAAM,CAAC,QAAgB;QAC3B,MAAM,GAAG,GAAc,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAEnD,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAC;YAC3E,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,GAAG,CAAC,YAAY,CACd,IAAI,CAAC,QAAQ,EACb,QAAQ,EACR,CAAC,GAAiB,EAAE,SAAkB,EAAE,EAAE;gBACxC,IAAI,GAAG,EAAE,CAAC;oBACR,OAAO,CAAC,KAAK,CAAC,+CAA+C,IAAI,CAAC,QAAQ,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;oBAC9F,OAAO,CAAC,KAAK,CAAC,CAAC;oBACf,OAAO;gBACT,CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,mDAAmD,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAChF,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,EACD,EAAE,WAAW,EAAE,OAAO,EAAE,CACzB,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA3BY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,sBAAU,GAAE;GACA,qBAAqB,CA2BjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passwordVerifier.js","sourceRoot":"","sources":["../../../src/services/auth/passwordVerifier.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.WindowsPasswordVerifier = void 0;
|
|
43
|
+
const os = __importStar(require("os"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const inversify_1 = require("inversify");
|
|
46
|
+
const ExecTools_1 = require("../../helpers/ExecTools");
|
|
47
|
+
/**
|
|
48
|
+
* Verify password against the local Windows SAM via .NET PrincipalContext.
|
|
49
|
+
* Password is passed through an environment variable to avoid shell escaping.
|
|
50
|
+
*/
|
|
51
|
+
let WindowsPasswordVerifier = class WindowsPasswordVerifier {
|
|
52
|
+
username = os.userInfo().username;
|
|
53
|
+
scriptPath = path.resolve(__dirname, "../../files/validatePassword.ps1");
|
|
54
|
+
async verify(password) {
|
|
55
|
+
const result = await ExecTools_1.ExecTools.safeExecPs1(this.scriptPath, {
|
|
56
|
+
timeout: 10_000,
|
|
57
|
+
env: { SM_PASSWORD: password, USERNAME: this.username },
|
|
58
|
+
});
|
|
59
|
+
const ok = result.stdout.trim() === "OK";
|
|
60
|
+
if (ok) {
|
|
61
|
+
console.log(`[WindowsPasswordVerifier] auth successful for ${this.username}`);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
console.error(`[WindowsPasswordVerifier] auth failed for ${this.username}${result.stderr ? ": " + result.stderr.trim() : ""}`);
|
|
65
|
+
}
|
|
66
|
+
return ok;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.WindowsPasswordVerifier = WindowsPasswordVerifier;
|
|
70
|
+
exports.WindowsPasswordVerifier = WindowsPasswordVerifier = __decorate([
|
|
71
|
+
(0, inversify_1.injectable)()
|
|
72
|
+
], WindowsPasswordVerifier);
|
|
73
|
+
//# sourceMappingURL=windowsPasswordVerifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"windowsPasswordVerifier.js","sourceRoot":"","sources":["../../../src/services/auth/windowsPasswordVerifier.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,yCAAuC;AACvC,uDAAoD;AAGpD;;;GAGG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IACjB,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC;IAClC,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,kCAAkC,CAAC,CAAC;IAE1F,KAAK,CAAC,MAAM,CAAC,QAAgB;QAC3B,MAAM,MAAM,GAAG,MAAM,qBAAS,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE;YAC1D,OAAO,EAAE,MAAM;YACf,GAAG,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;SACxD,CAAC,CAAC;QAEH,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,IAAI,CAAC;QACzC,IAAI,EAAE,EAAE,CAAC;YACP,OAAO,CAAC,GAAG,CAAC,iDAAiD,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAChF,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CACX,6CAA6C,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAChH,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAA;AApBY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,GAAE;GACA,uBAAuB,CAoBnC"}
|