@opsimathically/nodenetproccalld 0.0.2 → 0.0.3
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 +51 -5
- package/dist/index.d.mts +136 -1
- package/dist/index.d.ts +136 -1
- package/dist/index.js +875 -137
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +870 -137
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/config/api_keys.config.json5 +0 -21
- package/config/server.config.json5 +0 -79
package/dist/index.mjs
CHANGED
|
@@ -101,7 +101,7 @@ var _ApiKeyAuthorizer = class _ApiKeyAuthorizer {
|
|
|
101
101
|
__name(_ApiKeyAuthorizer, "ApiKeyAuthorizer");
|
|
102
102
|
var ApiKeyAuthorizer = _ApiKeyAuthorizer;
|
|
103
103
|
|
|
104
|
-
// src/classes/
|
|
104
|
+
// src/classes/clienttlspackageconfigfileloader/ClientTlsPackageConfigFileLoader.class.ts
|
|
105
105
|
import fs from "fs";
|
|
106
106
|
import path from "path";
|
|
107
107
|
|
|
@@ -1212,8 +1212,408 @@ var JSON5 = {
|
|
|
1212
1212
|
var lib = JSON5;
|
|
1213
1213
|
var dist_default = lib;
|
|
1214
1214
|
|
|
1215
|
-
// src/classes/
|
|
1215
|
+
// src/classes/clienttlspackageconfigfileloader/ClientTlsPackageConfigFileLoader.class.ts
|
|
1216
1216
|
import { z } from "zod";
|
|
1217
|
+
var client_tls_package_config_schema = z.object({
|
|
1218
|
+
ca_key_file: z.string().min(1),
|
|
1219
|
+
ca_cert_file: z.string().min(1),
|
|
1220
|
+
output_dir: z.string().min(1).optional(),
|
|
1221
|
+
overwrite: z.boolean().optional(),
|
|
1222
|
+
default_valid_days: z.number().int().positive().optional(),
|
|
1223
|
+
clients: z.array(z.object({
|
|
1224
|
+
client_name: z.string().min(1),
|
|
1225
|
+
common_name: z.string().min(1).optional(),
|
|
1226
|
+
uri_san: z.string().min(1).optional(),
|
|
1227
|
+
package_name: z.string().min(1).optional(),
|
|
1228
|
+
valid_days: z.number().int().positive().optional()
|
|
1229
|
+
}).strict()).min(1)
|
|
1230
|
+
}).strict();
|
|
1231
|
+
function ParseJson5File(params) {
|
|
1232
|
+
const absolute_file_path = path.resolve(process.cwd(), params.file_path);
|
|
1233
|
+
let file_content;
|
|
1234
|
+
try {
|
|
1235
|
+
file_content = fs.readFileSync(absolute_file_path, "utf8");
|
|
1236
|
+
} catch (error) {
|
|
1237
|
+
const error_message = error instanceof Error ? error.message : String(error);
|
|
1238
|
+
throw new Error(`Unable to read client TLS package config file "${absolute_file_path}": ${error_message}`);
|
|
1239
|
+
}
|
|
1240
|
+
try {
|
|
1241
|
+
return dist_default.parse(file_content);
|
|
1242
|
+
} catch (error) {
|
|
1243
|
+
const error_message = error instanceof Error ? error.message : String(error);
|
|
1244
|
+
throw new Error(`Invalid JSON5 in client TLS package config "${absolute_file_path}": ${error_message}`);
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
__name(ParseJson5File, "ParseJson5File");
|
|
1248
|
+
function BuildZodErrorMessage(params) {
|
|
1249
|
+
const lines = params.error.issues.map((issue) => {
|
|
1250
|
+
const issue_path = issue.path.length > 0 ? issue.path.join(".") : "<root>";
|
|
1251
|
+
return `${issue_path}: ${issue.message}`;
|
|
1252
|
+
});
|
|
1253
|
+
return `Invalid client TLS package config file.
|
|
1254
|
+
${lines.join("\n")}`;
|
|
1255
|
+
}
|
|
1256
|
+
__name(BuildZodErrorMessage, "BuildZodErrorMessage");
|
|
1257
|
+
function ResolvePath(params) {
|
|
1258
|
+
if (path.isAbsolute(params.file_path)) {
|
|
1259
|
+
return params.file_path;
|
|
1260
|
+
}
|
|
1261
|
+
return path.resolve(params.base_dir, params.file_path);
|
|
1262
|
+
}
|
|
1263
|
+
__name(ResolvePath, "ResolvePath");
|
|
1264
|
+
function BuildUriSanFromCommonName(params) {
|
|
1265
|
+
const normalized_common_name = params.common_name.replace(/[^a-zA-Z0-9_.-]/g, "_").toLowerCase();
|
|
1266
|
+
return `spiffe://nodenetproccalld/${normalized_common_name}`;
|
|
1267
|
+
}
|
|
1268
|
+
__name(BuildUriSanFromCommonName, "BuildUriSanFromCommonName");
|
|
1269
|
+
var _ClientTlsPackageConfigFileLoader = class _ClientTlsPackageConfigFileLoader {
|
|
1270
|
+
loadClientTlsPackageOptions(params) {
|
|
1271
|
+
const absolute_config_file_path = path.resolve(process.cwd(), params.client_tls_package_generation_options.config_file_path);
|
|
1272
|
+
const config_dir = path.dirname(absolute_config_file_path);
|
|
1273
|
+
const config_raw = ParseJson5File({
|
|
1274
|
+
file_path: absolute_config_file_path
|
|
1275
|
+
});
|
|
1276
|
+
const parse_result = client_tls_package_config_schema.safeParse(config_raw);
|
|
1277
|
+
if (!parse_result.success) {
|
|
1278
|
+
throw new Error(BuildZodErrorMessage({
|
|
1279
|
+
error: parse_result.error
|
|
1280
|
+
}));
|
|
1281
|
+
}
|
|
1282
|
+
const config_from_file = parse_result.data;
|
|
1283
|
+
const output_dir = ResolvePath({
|
|
1284
|
+
file_path: config_from_file.output_dir ?? "./client_certs",
|
|
1285
|
+
base_dir: config_dir
|
|
1286
|
+
});
|
|
1287
|
+
const overwrite = config_from_file.overwrite ?? false;
|
|
1288
|
+
const default_valid_days = config_from_file.default_valid_days ?? 36500;
|
|
1289
|
+
const clients = this.buildRuntimeClients({
|
|
1290
|
+
clients: config_from_file.clients,
|
|
1291
|
+
default_valid_days
|
|
1292
|
+
});
|
|
1293
|
+
this.assertUniqueClientNames({
|
|
1294
|
+
clients
|
|
1295
|
+
});
|
|
1296
|
+
this.assertUniquePackageNames({
|
|
1297
|
+
clients
|
|
1298
|
+
});
|
|
1299
|
+
return {
|
|
1300
|
+
ca_key_file: ResolvePath({
|
|
1301
|
+
file_path: config_from_file.ca_key_file,
|
|
1302
|
+
base_dir: config_dir
|
|
1303
|
+
}),
|
|
1304
|
+
ca_cert_file: ResolvePath({
|
|
1305
|
+
file_path: config_from_file.ca_cert_file,
|
|
1306
|
+
base_dir: config_dir
|
|
1307
|
+
}),
|
|
1308
|
+
output_dir,
|
|
1309
|
+
overwrite,
|
|
1310
|
+
default_valid_days,
|
|
1311
|
+
clients
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
buildRuntimeClients(params) {
|
|
1315
|
+
return params.clients.map((client_definition) => {
|
|
1316
|
+
const common_name = client_definition.common_name ?? client_definition.client_name;
|
|
1317
|
+
const client_uri_san = client_definition.uri_san ?? BuildUriSanFromCommonName({
|
|
1318
|
+
common_name
|
|
1319
|
+
});
|
|
1320
|
+
const package_name = client_definition.package_name ?? client_definition.client_name;
|
|
1321
|
+
const valid_days = client_definition.valid_days ?? params.default_valid_days;
|
|
1322
|
+
return {
|
|
1323
|
+
client_name: client_definition.client_name,
|
|
1324
|
+
common_name,
|
|
1325
|
+
uri_san: client_uri_san,
|
|
1326
|
+
package_name,
|
|
1327
|
+
valid_days
|
|
1328
|
+
};
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
assertUniqueClientNames(params) {
|
|
1332
|
+
const seen_client_names = /* @__PURE__ */ new Set();
|
|
1333
|
+
for (const client of params.clients) {
|
|
1334
|
+
if (seen_client_names.has(client.client_name)) {
|
|
1335
|
+
throw new Error(`Duplicate client_name "${client.client_name}" in client TLS package config file.`);
|
|
1336
|
+
}
|
|
1337
|
+
seen_client_names.add(client.client_name);
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
assertUniquePackageNames(params) {
|
|
1341
|
+
const seen_package_names = /* @__PURE__ */ new Set();
|
|
1342
|
+
for (const client of params.clients) {
|
|
1343
|
+
if (seen_package_names.has(client.package_name)) {
|
|
1344
|
+
throw new Error(`Duplicate package_name "${client.package_name}" in client TLS package config file.`);
|
|
1345
|
+
}
|
|
1346
|
+
seen_package_names.add(client.package_name);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1350
|
+
__name(_ClientTlsPackageConfigFileLoader, "ClientTlsPackageConfigFileLoader");
|
|
1351
|
+
var ClientTlsPackageConfigFileLoader = _ClientTlsPackageConfigFileLoader;
|
|
1352
|
+
|
|
1353
|
+
// src/classes/clienttlspackagegenerator/ClientTlsPackageGenerator.class.ts
|
|
1354
|
+
import { execFileSync } from "child_process";
|
|
1355
|
+
import fs2 from "fs";
|
|
1356
|
+
import path2 from "path";
|
|
1357
|
+
function WriteTextFile(params) {
|
|
1358
|
+
fs2.writeFileSync(params.file_path, params.content, "utf8");
|
|
1359
|
+
}
|
|
1360
|
+
__name(WriteTextFile, "WriteTextFile");
|
|
1361
|
+
function EnsureReadableFile(params) {
|
|
1362
|
+
if (!fs2.existsSync(params.file_path)) {
|
|
1363
|
+
throw new Error(`${params.label} does not exist: ${params.file_path}`);
|
|
1364
|
+
}
|
|
1365
|
+
const stat_result = fs2.statSync(params.file_path);
|
|
1366
|
+
if (!stat_result.isFile()) {
|
|
1367
|
+
throw new Error(`${params.label} is not a file: ${params.file_path}`);
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
__name(EnsureReadableFile, "EnsureReadableFile");
|
|
1371
|
+
var _ClientTlsPackageGenerator = class _ClientTlsPackageGenerator {
|
|
1372
|
+
generateClientTlsPackages(params) {
|
|
1373
|
+
this.assertOpenSslAvailable();
|
|
1374
|
+
this.assertTarAvailable();
|
|
1375
|
+
this.assertCaFiles({
|
|
1376
|
+
runtime_options: params.runtime_options
|
|
1377
|
+
});
|
|
1378
|
+
fs2.mkdirSync(params.runtime_options.output_dir, {
|
|
1379
|
+
recursive: true
|
|
1380
|
+
});
|
|
1381
|
+
const ca_serial_path = path2.join(params.runtime_options.output_dir, "client_ca.cert.srl");
|
|
1382
|
+
if (params.runtime_options.overwrite) {
|
|
1383
|
+
fs2.rmSync(ca_serial_path, {
|
|
1384
|
+
force: true
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
const generated_packages = [];
|
|
1388
|
+
for (const client_definition of params.runtime_options.clients) {
|
|
1389
|
+
const client_files = this.buildClientFileMap({
|
|
1390
|
+
output_dir: params.runtime_options.output_dir,
|
|
1391
|
+
client_name: client_definition.client_name,
|
|
1392
|
+
package_name: client_definition.package_name
|
|
1393
|
+
});
|
|
1394
|
+
this.prepareClientOutput({
|
|
1395
|
+
client_files,
|
|
1396
|
+
overwrite: params.runtime_options.overwrite
|
|
1397
|
+
});
|
|
1398
|
+
try {
|
|
1399
|
+
this.generateClientCertificate({
|
|
1400
|
+
client_files,
|
|
1401
|
+
ca_key_file: params.runtime_options.ca_key_file,
|
|
1402
|
+
ca_cert_file: params.runtime_options.ca_cert_file,
|
|
1403
|
+
ca_serial_path,
|
|
1404
|
+
common_name: client_definition.common_name,
|
|
1405
|
+
uri_san: client_definition.uri_san,
|
|
1406
|
+
valid_days: client_definition.valid_days
|
|
1407
|
+
});
|
|
1408
|
+
fs2.rmSync(client_files.client_csr_path, {
|
|
1409
|
+
force: true
|
|
1410
|
+
});
|
|
1411
|
+
fs2.rmSync(client_files.client_ext_path, {
|
|
1412
|
+
force: true
|
|
1413
|
+
});
|
|
1414
|
+
fs2.copyFileSync(params.runtime_options.ca_cert_file, client_files.ca_cert_copy_path);
|
|
1415
|
+
this.writeClientReadme({
|
|
1416
|
+
client_files,
|
|
1417
|
+
client_name: client_definition.client_name
|
|
1418
|
+
});
|
|
1419
|
+
this.createTarPackage({
|
|
1420
|
+
client_files
|
|
1421
|
+
});
|
|
1422
|
+
generated_packages.push({
|
|
1423
|
+
client_name: client_definition.client_name,
|
|
1424
|
+
package_path: client_files.package_path,
|
|
1425
|
+
directory_path: client_files.client_dir,
|
|
1426
|
+
client_cert_path: client_files.client_cert_path,
|
|
1427
|
+
client_key_path: client_files.client_key_path,
|
|
1428
|
+
ca_cert_path: client_files.ca_cert_copy_path
|
|
1429
|
+
});
|
|
1430
|
+
} finally {
|
|
1431
|
+
fs2.rmSync(client_files.client_csr_path, {
|
|
1432
|
+
force: true
|
|
1433
|
+
});
|
|
1434
|
+
fs2.rmSync(client_files.client_ext_path, {
|
|
1435
|
+
force: true
|
|
1436
|
+
});
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
fs2.rmSync(ca_serial_path, {
|
|
1440
|
+
force: true
|
|
1441
|
+
});
|
|
1442
|
+
return {
|
|
1443
|
+
output_dir: params.runtime_options.output_dir,
|
|
1444
|
+
packages: generated_packages
|
|
1445
|
+
};
|
|
1446
|
+
}
|
|
1447
|
+
assertOpenSslAvailable() {
|
|
1448
|
+
try {
|
|
1449
|
+
execFileSync("openssl", [
|
|
1450
|
+
"version"
|
|
1451
|
+
], {
|
|
1452
|
+
stdio: "ignore"
|
|
1453
|
+
});
|
|
1454
|
+
} catch {
|
|
1455
|
+
throw new Error("openssl command is required but was not found. Please install openssl and retry.");
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
assertTarAvailable() {
|
|
1459
|
+
try {
|
|
1460
|
+
execFileSync("tar", [
|
|
1461
|
+
"--version"
|
|
1462
|
+
], {
|
|
1463
|
+
stdio: "ignore"
|
|
1464
|
+
});
|
|
1465
|
+
} catch {
|
|
1466
|
+
throw new Error("tar command is required but was not found. Please install tar and retry.");
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
assertCaFiles(params) {
|
|
1470
|
+
EnsureReadableFile({
|
|
1471
|
+
file_path: params.runtime_options.ca_key_file,
|
|
1472
|
+
label: "ca_key_file"
|
|
1473
|
+
});
|
|
1474
|
+
EnsureReadableFile({
|
|
1475
|
+
file_path: params.runtime_options.ca_cert_file,
|
|
1476
|
+
label: "ca_cert_file"
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1479
|
+
buildClientFileMap(params) {
|
|
1480
|
+
const client_dir = path2.join(params.output_dir, params.client_name);
|
|
1481
|
+
return {
|
|
1482
|
+
client_dir,
|
|
1483
|
+
client_key_path: path2.join(client_dir, "client.key.pem"),
|
|
1484
|
+
client_csr_path: path2.join(client_dir, "client.csr.pem"),
|
|
1485
|
+
client_cert_path: path2.join(client_dir, "client.cert.pem"),
|
|
1486
|
+
client_ext_path: path2.join(client_dir, "client.ext"),
|
|
1487
|
+
package_path: path2.join(params.output_dir, `${params.package_name}.tar.gz`),
|
|
1488
|
+
ca_cert_copy_path: path2.join(client_dir, "ca.cert.pem")
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
prepareClientOutput(params) {
|
|
1492
|
+
if (!params.overwrite) {
|
|
1493
|
+
if (fs2.existsSync(params.client_files.client_dir)) {
|
|
1494
|
+
throw new Error(`Refusing to overwrite existing client directory "${params.client_files.client_dir}". Set overwrite=true in client TLS package config.`);
|
|
1495
|
+
}
|
|
1496
|
+
if (fs2.existsSync(params.client_files.package_path)) {
|
|
1497
|
+
throw new Error(`Refusing to overwrite existing client package "${params.client_files.package_path}". Set overwrite=true in client TLS package config.`);
|
|
1498
|
+
}
|
|
1499
|
+
} else {
|
|
1500
|
+
fs2.rmSync(params.client_files.client_dir, {
|
|
1501
|
+
recursive: true,
|
|
1502
|
+
force: true
|
|
1503
|
+
});
|
|
1504
|
+
fs2.rmSync(params.client_files.package_path, {
|
|
1505
|
+
force: true
|
|
1506
|
+
});
|
|
1507
|
+
}
|
|
1508
|
+
fs2.mkdirSync(params.client_files.client_dir, {
|
|
1509
|
+
recursive: true
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
generateClientCertificate(params) {
|
|
1513
|
+
WriteTextFile({
|
|
1514
|
+
file_path: params.client_files.client_ext_path,
|
|
1515
|
+
content: [
|
|
1516
|
+
"extendedKeyUsage=clientAuth",
|
|
1517
|
+
"keyUsage=digitalSignature,keyEncipherment",
|
|
1518
|
+
`subjectAltName=URI:${params.uri_san}`
|
|
1519
|
+
].join("\n")
|
|
1520
|
+
});
|
|
1521
|
+
this.runOpenSslCommand({
|
|
1522
|
+
args: [
|
|
1523
|
+
"req",
|
|
1524
|
+
"-new",
|
|
1525
|
+
"-newkey",
|
|
1526
|
+
"rsa:4096",
|
|
1527
|
+
"-sha256",
|
|
1528
|
+
"-nodes",
|
|
1529
|
+
"-keyout",
|
|
1530
|
+
params.client_files.client_key_path,
|
|
1531
|
+
"-out",
|
|
1532
|
+
params.client_files.client_csr_path,
|
|
1533
|
+
"-subj",
|
|
1534
|
+
`/CN=${params.common_name}`
|
|
1535
|
+
]
|
|
1536
|
+
});
|
|
1537
|
+
const ca_sign_args = [
|
|
1538
|
+
"x509",
|
|
1539
|
+
"-req",
|
|
1540
|
+
"-in",
|
|
1541
|
+
params.client_files.client_csr_path,
|
|
1542
|
+
"-CA",
|
|
1543
|
+
params.ca_cert_file,
|
|
1544
|
+
"-CAkey",
|
|
1545
|
+
params.ca_key_file,
|
|
1546
|
+
"-CAserial",
|
|
1547
|
+
params.ca_serial_path,
|
|
1548
|
+
"-out",
|
|
1549
|
+
params.client_files.client_cert_path,
|
|
1550
|
+
"-days",
|
|
1551
|
+
String(params.valid_days),
|
|
1552
|
+
"-sha256",
|
|
1553
|
+
"-extfile",
|
|
1554
|
+
params.client_files.client_ext_path
|
|
1555
|
+
];
|
|
1556
|
+
if (!fs2.existsSync(params.ca_serial_path)) {
|
|
1557
|
+
const with_create_serial = [
|
|
1558
|
+
...ca_sign_args
|
|
1559
|
+
];
|
|
1560
|
+
with_create_serial.splice(10, 0, "-CAcreateserial");
|
|
1561
|
+
this.runOpenSslCommand({
|
|
1562
|
+
args: with_create_serial
|
|
1563
|
+
});
|
|
1564
|
+
} else {
|
|
1565
|
+
this.runOpenSslCommand({
|
|
1566
|
+
args: ca_sign_args
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1569
|
+
fs2.chmodSync(params.client_files.client_key_path, 384);
|
|
1570
|
+
fs2.chmodSync(params.client_files.client_cert_path, 420);
|
|
1571
|
+
fs2.chmodSync(params.client_files.client_ext_path, 384);
|
|
1572
|
+
fs2.chmodSync(params.client_files.client_csr_path, 384);
|
|
1573
|
+
}
|
|
1574
|
+
writeClientReadme(params) {
|
|
1575
|
+
const readme_content = [
|
|
1576
|
+
`Client TLS bundle for: ${params.client_name}`,
|
|
1577
|
+
"",
|
|
1578
|
+
"Files:",
|
|
1579
|
+
"- client.key.pem",
|
|
1580
|
+
"- client.cert.pem",
|
|
1581
|
+
"- ca.cert.pem",
|
|
1582
|
+
"",
|
|
1583
|
+
"Use these with NetworkProcedureCallClient tls_mtls fields."
|
|
1584
|
+
].join("\n");
|
|
1585
|
+
WriteTextFile({
|
|
1586
|
+
file_path: path2.join(params.client_files.client_dir, "README.txt"),
|
|
1587
|
+
content: `${readme_content}
|
|
1588
|
+
`
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
createTarPackage(params) {
|
|
1592
|
+
execFileSync("tar", [
|
|
1593
|
+
"-C",
|
|
1594
|
+
params.client_files.client_dir,
|
|
1595
|
+
"-czf",
|
|
1596
|
+
params.client_files.package_path,
|
|
1597
|
+
"."
|
|
1598
|
+
], {
|
|
1599
|
+
stdio: "ignore"
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
runOpenSslCommand(params) {
|
|
1603
|
+
execFileSync("openssl", params.args, {
|
|
1604
|
+
stdio: "ignore"
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
__name(_ClientTlsPackageGenerator, "ClientTlsPackageGenerator");
|
|
1609
|
+
var ClientTlsPackageGenerator = _ClientTlsPackageGenerator;
|
|
1610
|
+
|
|
1611
|
+
// src/classes/configfileloader/ConfigFileLoader.class.ts
|
|
1612
|
+
import fs3 from "fs";
|
|
1613
|
+
import path3 from "path";
|
|
1614
|
+
|
|
1615
|
+
// src/classes/configvalidator/ConfigValidator.class.ts
|
|
1616
|
+
import { z as z2 } from "zod";
|
|
1217
1617
|
var privilege_name_list = [
|
|
1218
1618
|
"invoke_functions",
|
|
1219
1619
|
"define_functions",
|
|
@@ -1229,104 +1629,104 @@ var tls_min_version_list = [
|
|
|
1229
1629
|
"TLSv1.2",
|
|
1230
1630
|
"TLSv1.3"
|
|
1231
1631
|
];
|
|
1232
|
-
var worker_runtime_options_schema =
|
|
1233
|
-
call_timeout_ms:
|
|
1234
|
-
control_timeout_ms:
|
|
1235
|
-
start_timeout_ms:
|
|
1236
|
-
stop_timeout_ms:
|
|
1237
|
-
restart_on_failure:
|
|
1238
|
-
max_restarts_per_worker:
|
|
1239
|
-
max_pending_calls_per_worker:
|
|
1240
|
-
restart_base_delay_ms:
|
|
1241
|
-
restart_max_delay_ms:
|
|
1242
|
-
restart_jitter_ms:
|
|
1632
|
+
var worker_runtime_options_schema = z2.object({
|
|
1633
|
+
call_timeout_ms: z2.number().int().positive().optional(),
|
|
1634
|
+
control_timeout_ms: z2.number().int().positive().optional(),
|
|
1635
|
+
start_timeout_ms: z2.number().int().positive().optional(),
|
|
1636
|
+
stop_timeout_ms: z2.number().int().positive().optional(),
|
|
1637
|
+
restart_on_failure: z2.boolean().optional(),
|
|
1638
|
+
max_restarts_per_worker: z2.number().int().nonnegative().optional(),
|
|
1639
|
+
max_pending_calls_per_worker: z2.number().int().positive().optional(),
|
|
1640
|
+
restart_base_delay_ms: z2.number().int().positive().optional(),
|
|
1641
|
+
restart_max_delay_ms: z2.number().int().positive().optional(),
|
|
1642
|
+
restart_jitter_ms: z2.number().int().nonnegative().optional()
|
|
1243
1643
|
}).strict();
|
|
1244
|
-
var rate_limiter_schema =
|
|
1245
|
-
enabled:
|
|
1246
|
-
tokens_per_interval:
|
|
1247
|
-
interval_ms:
|
|
1248
|
-
burst_tokens:
|
|
1249
|
-
disconnect_on_limit:
|
|
1644
|
+
var rate_limiter_schema = z2.object({
|
|
1645
|
+
enabled: z2.boolean().optional(),
|
|
1646
|
+
tokens_per_interval: z2.number().int().positive().optional(),
|
|
1647
|
+
interval_ms: z2.number().int().positive().optional(),
|
|
1648
|
+
burst_tokens: z2.number().int().positive().optional(),
|
|
1649
|
+
disconnect_on_limit: z2.boolean().optional()
|
|
1250
1650
|
}).strict();
|
|
1251
|
-
var abuse_controls_schema =
|
|
1252
|
-
connection_controls:
|
|
1253
|
-
max_concurrent_sockets:
|
|
1254
|
-
max_concurrent_handshakes:
|
|
1255
|
-
max_unauthenticated_sessions:
|
|
1256
|
-
global_connection_window_ms:
|
|
1257
|
-
global_max_new_connections_per_window:
|
|
1258
|
-
per_ip_max_new_connections_per_window:
|
|
1259
|
-
tls_handshake_timeout_ms:
|
|
1260
|
-
auth_message_timeout_ms:
|
|
1261
|
-
max_pre_auth_frame_bytes:
|
|
1262
|
-
max_post_auth_frame_bytes:
|
|
1651
|
+
var abuse_controls_schema = z2.object({
|
|
1652
|
+
connection_controls: z2.object({
|
|
1653
|
+
max_concurrent_sockets: z2.number().int().positive().optional(),
|
|
1654
|
+
max_concurrent_handshakes: z2.number().int().positive().optional(),
|
|
1655
|
+
max_unauthenticated_sessions: z2.number().int().positive().optional(),
|
|
1656
|
+
global_connection_window_ms: z2.number().int().positive().optional(),
|
|
1657
|
+
global_max_new_connections_per_window: z2.number().int().positive().optional(),
|
|
1658
|
+
per_ip_max_new_connections_per_window: z2.number().int().positive().optional(),
|
|
1659
|
+
tls_handshake_timeout_ms: z2.number().int().positive().optional(),
|
|
1660
|
+
auth_message_timeout_ms: z2.number().int().positive().optional(),
|
|
1661
|
+
max_pre_auth_frame_bytes: z2.number().int().positive().optional(),
|
|
1662
|
+
max_post_auth_frame_bytes: z2.number().int().positive().optional()
|
|
1263
1663
|
}).strict().optional(),
|
|
1264
|
-
auth_controls:
|
|
1265
|
-
pending_auth_window_ms:
|
|
1266
|
-
max_pending_auth_attempts_per_ip_per_window:
|
|
1267
|
-
failed_auth_window_ms:
|
|
1268
|
-
max_failed_auth_per_ip_per_window:
|
|
1269
|
-
max_failed_auth_per_api_key_per_window:
|
|
1270
|
-
block_duration_ms:
|
|
1271
|
-
enable_blocklist:
|
|
1664
|
+
auth_controls: z2.object({
|
|
1665
|
+
pending_auth_window_ms: z2.number().int().positive().optional(),
|
|
1666
|
+
max_pending_auth_attempts_per_ip_per_window: z2.number().int().positive().optional(),
|
|
1667
|
+
failed_auth_window_ms: z2.number().int().positive().optional(),
|
|
1668
|
+
max_failed_auth_per_ip_per_window: z2.number().int().positive().optional(),
|
|
1669
|
+
max_failed_auth_per_api_key_per_window: z2.number().int().positive().optional(),
|
|
1670
|
+
block_duration_ms: z2.number().int().positive().optional(),
|
|
1671
|
+
enable_blocklist: z2.boolean().optional()
|
|
1272
1672
|
}).strict().optional(),
|
|
1273
|
-
request_controls:
|
|
1274
|
-
max_in_flight_requests_per_connection:
|
|
1673
|
+
request_controls: z2.object({
|
|
1674
|
+
max_in_flight_requests_per_connection: z2.number().int().positive().optional(),
|
|
1275
1675
|
per_connection: rate_limiter_schema.optional(),
|
|
1276
1676
|
per_api_key: rate_limiter_schema.optional(),
|
|
1277
1677
|
per_ip: rate_limiter_schema.optional()
|
|
1278
1678
|
}).strict().optional(),
|
|
1279
|
-
observability:
|
|
1280
|
-
enable_console_log:
|
|
1679
|
+
observability: z2.object({
|
|
1680
|
+
enable_console_log: z2.boolean().optional()
|
|
1281
1681
|
}).strict().optional()
|
|
1282
1682
|
}).strict();
|
|
1283
|
-
var daemon_server_config_schema =
|
|
1284
|
-
information:
|
|
1285
|
-
server_name:
|
|
1683
|
+
var daemon_server_config_schema = z2.object({
|
|
1684
|
+
information: z2.object({
|
|
1685
|
+
server_name: z2.string().min(1)
|
|
1286
1686
|
}).strict(),
|
|
1287
|
-
network:
|
|
1288
|
-
bind_addr:
|
|
1289
|
-
tcp_listen_port:
|
|
1687
|
+
network: z2.object({
|
|
1688
|
+
bind_addr: z2.string().min(1),
|
|
1689
|
+
tcp_listen_port: z2.number().int().positive().max(65535)
|
|
1290
1690
|
}).strict(),
|
|
1291
|
-
tls_mtls:
|
|
1292
|
-
key_file:
|
|
1293
|
-
cert_file:
|
|
1294
|
-
ca_file:
|
|
1295
|
-
crl_file:
|
|
1296
|
-
min_version:
|
|
1297
|
-
cipher_suites:
|
|
1298
|
-
handshake_timeout_ms:
|
|
1299
|
-
request_timeout_ms:
|
|
1300
|
-
max_frame_bytes:
|
|
1691
|
+
tls_mtls: z2.object({
|
|
1692
|
+
key_file: z2.string().min(1),
|
|
1693
|
+
cert_file: z2.string().min(1),
|
|
1694
|
+
ca_file: z2.string().min(1),
|
|
1695
|
+
crl_file: z2.string().min(1).optional(),
|
|
1696
|
+
min_version: z2.enum(tls_min_version_list).optional(),
|
|
1697
|
+
cipher_suites: z2.string().min(1).optional(),
|
|
1698
|
+
handshake_timeout_ms: z2.number().int().positive().optional(),
|
|
1699
|
+
request_timeout_ms: z2.number().int().positive().optional(),
|
|
1700
|
+
max_frame_bytes: z2.number().int().positive().optional()
|
|
1301
1701
|
}).strict(),
|
|
1302
|
-
workerprocedurecall:
|
|
1303
|
-
count:
|
|
1702
|
+
workerprocedurecall: z2.object({
|
|
1703
|
+
count: z2.number().int().positive(),
|
|
1304
1704
|
constructor_options: worker_runtime_options_schema.optional(),
|
|
1305
1705
|
start_options: worker_runtime_options_schema.optional()
|
|
1306
1706
|
}).strict(),
|
|
1307
1707
|
abuse_controls: abuse_controls_schema.optional(),
|
|
1308
|
-
observability:
|
|
1309
|
-
enable_console_log:
|
|
1310
|
-
log_worker_events:
|
|
1311
|
-
metrics_log_interval_ms:
|
|
1708
|
+
observability: z2.object({
|
|
1709
|
+
enable_console_log: z2.boolean().optional(),
|
|
1710
|
+
log_worker_events: z2.boolean().optional(),
|
|
1711
|
+
metrics_log_interval_ms: z2.number().int().positive().optional()
|
|
1312
1712
|
}).strict().optional()
|
|
1313
1713
|
}).strict();
|
|
1314
|
-
var daemon_api_key_config_schema =
|
|
1315
|
-
api_keys:
|
|
1316
|
-
key_id:
|
|
1317
|
-
api_key:
|
|
1318
|
-
privileges:
|
|
1319
|
-
enabled:
|
|
1320
|
-
identity_constraints:
|
|
1321
|
-
remote_address_regex:
|
|
1322
|
-
tls_peer_subject_regex:
|
|
1323
|
-
tls_peer_san_regex:
|
|
1324
|
-
tls_peer_fingerprint256_regex:
|
|
1325
|
-
tls_peer_serial_number_regex:
|
|
1714
|
+
var daemon_api_key_config_schema = z2.object({
|
|
1715
|
+
api_keys: z2.array(z2.object({
|
|
1716
|
+
key_id: z2.string().min(1),
|
|
1717
|
+
api_key: z2.string().min(1),
|
|
1718
|
+
privileges: z2.array(z2.enum(privilege_name_list)).min(1),
|
|
1719
|
+
enabled: z2.boolean().optional(),
|
|
1720
|
+
identity_constraints: z2.object({
|
|
1721
|
+
remote_address_regex: z2.string().min(1).optional(),
|
|
1722
|
+
tls_peer_subject_regex: z2.string().min(1).optional(),
|
|
1723
|
+
tls_peer_san_regex: z2.string().min(1).optional(),
|
|
1724
|
+
tls_peer_fingerprint256_regex: z2.string().min(1).optional(),
|
|
1725
|
+
tls_peer_serial_number_regex: z2.string().min(1).optional()
|
|
1326
1726
|
}).strict().optional()
|
|
1327
1727
|
}).strict()).min(1)
|
|
1328
1728
|
}).strict();
|
|
1329
|
-
function
|
|
1729
|
+
function BuildZodErrorMessage2(params) {
|
|
1330
1730
|
const message_lines = params.error.issues.map((issue) => {
|
|
1331
1731
|
const issue_path = issue.path.length > 0 ? issue.path.join(".") : "<root>";
|
|
1332
1732
|
return `${issue_path}: ${issue.message}`;
|
|
@@ -1334,7 +1734,7 @@ function BuildZodErrorMessage(params) {
|
|
|
1334
1734
|
return `${params.prefix}
|
|
1335
1735
|
${message_lines.join("\n")}`;
|
|
1336
1736
|
}
|
|
1337
|
-
__name(
|
|
1737
|
+
__name(BuildZodErrorMessage2, "BuildZodErrorMessage");
|
|
1338
1738
|
function CompileRegex(params) {
|
|
1339
1739
|
try {
|
|
1340
1740
|
return new RegExp(params.source);
|
|
@@ -1348,7 +1748,7 @@ var _ConfigValidator = class _ConfigValidator {
|
|
|
1348
1748
|
validateServerConfig(params) {
|
|
1349
1749
|
const parse_result = daemon_server_config_schema.safeParse(params.server_config_raw);
|
|
1350
1750
|
if (!parse_result.success) {
|
|
1351
|
-
throw new Error(
|
|
1751
|
+
throw new Error(BuildZodErrorMessage2({
|
|
1352
1752
|
prefix: "Invalid server config.",
|
|
1353
1753
|
error: parse_result.error
|
|
1354
1754
|
}));
|
|
@@ -1358,7 +1758,7 @@ var _ConfigValidator = class _ConfigValidator {
|
|
|
1358
1758
|
validateApiKeysConfig(params) {
|
|
1359
1759
|
const parse_result = daemon_api_key_config_schema.safeParse(params.api_keys_config_raw);
|
|
1360
1760
|
if (!parse_result.success) {
|
|
1361
|
-
throw new Error(
|
|
1761
|
+
throw new Error(BuildZodErrorMessage2({
|
|
1362
1762
|
prefix: "Invalid api-keys config.",
|
|
1363
1763
|
error: parse_result.error
|
|
1364
1764
|
}));
|
|
@@ -1451,20 +1851,20 @@ var ConfigValidator = _ConfigValidator;
|
|
|
1451
1851
|
// src/classes/configfileloader/ConfigFileLoader.class.ts
|
|
1452
1852
|
function ReadUtf8File(params) {
|
|
1453
1853
|
try {
|
|
1454
|
-
return
|
|
1854
|
+
return fs3.readFileSync(params.file_path, "utf8");
|
|
1455
1855
|
} catch (error) {
|
|
1456
1856
|
const error_message = error instanceof Error ? error.message : String(error);
|
|
1457
1857
|
throw new Error(`Unable to read file "${params.file_path}": ${error_message}`);
|
|
1458
1858
|
}
|
|
1459
1859
|
}
|
|
1460
1860
|
__name(ReadUtf8File, "ReadUtf8File");
|
|
1461
|
-
function
|
|
1462
|
-
if (
|
|
1861
|
+
function ResolvePath2(params) {
|
|
1862
|
+
if (path3.isAbsolute(params.file_path)) {
|
|
1463
1863
|
return params.file_path;
|
|
1464
1864
|
}
|
|
1465
|
-
return
|
|
1865
|
+
return path3.resolve(params.base_dir, params.file_path);
|
|
1466
1866
|
}
|
|
1467
|
-
__name(
|
|
1867
|
+
__name(ResolvePath2, "ResolvePath");
|
|
1468
1868
|
function ParseJson5(params) {
|
|
1469
1869
|
try {
|
|
1470
1870
|
return dist_default.parse(params.content);
|
|
@@ -1480,11 +1880,11 @@ var _ConfigFileLoader = class _ConfigFileLoader {
|
|
|
1480
1880
|
this.config_validator = params?.config_validator ?? new ConfigValidator();
|
|
1481
1881
|
}
|
|
1482
1882
|
loadDaemonConfig(params) {
|
|
1483
|
-
const server_config_path =
|
|
1883
|
+
const server_config_path = ResolvePath2({
|
|
1484
1884
|
file_path: params.config_paths.server_config_path,
|
|
1485
1885
|
base_dir: process.cwd()
|
|
1486
1886
|
});
|
|
1487
|
-
const api_keys_config_path =
|
|
1887
|
+
const api_keys_config_path = ResolvePath2({
|
|
1488
1888
|
file_path: params.config_paths.api_keys_config_path,
|
|
1489
1889
|
base_dir: process.cwd()
|
|
1490
1890
|
});
|
|
@@ -1502,7 +1902,7 @@ var _ConfigFileLoader = class _ConfigFileLoader {
|
|
|
1502
1902
|
});
|
|
1503
1903
|
const runtime_tls_mtls = this.resolveTlsMaterial({
|
|
1504
1904
|
tls_file_config: server_config.tls_mtls,
|
|
1505
|
-
config_file_dir:
|
|
1905
|
+
config_file_dir: path3.dirname(server_config_path)
|
|
1506
1906
|
});
|
|
1507
1907
|
const runtime_api_keys = this.config_validator.toRuntimeApiKeysConfig({
|
|
1508
1908
|
api_keys_config
|
|
@@ -1560,7 +1960,7 @@ var _ConfigFileLoader = class _ConfigFileLoader {
|
|
|
1560
1960
|
};
|
|
1561
1961
|
}
|
|
1562
1962
|
readPemFile(params) {
|
|
1563
|
-
const absolute_file_path =
|
|
1963
|
+
const absolute_file_path = ResolvePath2({
|
|
1564
1964
|
file_path: params.pem_path,
|
|
1565
1965
|
base_dir: params.config_file_dir
|
|
1566
1966
|
});
|
|
@@ -1581,11 +1981,13 @@ var ConfigFileLoader = _ConfigFileLoader;
|
|
|
1581
1981
|
var default_server_config_path = "./config/server.config.json5";
|
|
1582
1982
|
var default_api_keys_config_path = "./config/api_keys.config.json5";
|
|
1583
1983
|
var default_config_output_dir = "./config";
|
|
1984
|
+
var default_tls_config_file_path = "./config/tls_generation.config.json5";
|
|
1985
|
+
var default_client_tls_config_file_path = "./config/client_tls_packages.config.json5";
|
|
1584
1986
|
var default_tls_output_dir = "./config/certs";
|
|
1585
1987
|
var default_ca_common_name = "nodenetproccalld-local-ca";
|
|
1586
1988
|
var default_server_common_name = "localhost";
|
|
1587
1989
|
var default_client_common_name = "nodenetproccalld-client";
|
|
1588
|
-
var default_tls_valid_days =
|
|
1990
|
+
var default_tls_valid_days = 36500;
|
|
1589
1991
|
var _DaemonCli = class _DaemonCli {
|
|
1590
1992
|
parseOptions() {
|
|
1591
1993
|
const options = {
|
|
@@ -1597,14 +1999,36 @@ var _DaemonCli = class _DaemonCli {
|
|
|
1597
1999
|
output_dir: default_config_output_dir,
|
|
1598
2000
|
overwrite: false
|
|
1599
2001
|
},
|
|
2002
|
+
default_tls_config_generation: {
|
|
2003
|
+
enabled: false,
|
|
2004
|
+
output_file_path: default_tls_config_file_path,
|
|
2005
|
+
overwrite: false
|
|
2006
|
+
},
|
|
2007
|
+
default_client_tls_config_generation: {
|
|
2008
|
+
enabled: false,
|
|
2009
|
+
output_file_path: default_client_tls_config_file_path,
|
|
2010
|
+
overwrite: false
|
|
2011
|
+
},
|
|
1600
2012
|
tls_generation: {
|
|
1601
2013
|
enabled: false,
|
|
2014
|
+
config_file_path: void 0,
|
|
1602
2015
|
output_dir: default_tls_output_dir,
|
|
1603
2016
|
overwrite: false,
|
|
1604
2017
|
ca_common_name: default_ca_common_name,
|
|
1605
2018
|
server_common_name: default_server_common_name,
|
|
1606
2019
|
client_common_name: default_client_common_name,
|
|
2020
|
+
server_dns_sans: [
|
|
2021
|
+
"localhost"
|
|
2022
|
+
],
|
|
2023
|
+
server_ip_sans: [
|
|
2024
|
+
"127.0.0.1"
|
|
2025
|
+
],
|
|
2026
|
+
client_uri_san: void 0,
|
|
1607
2027
|
valid_days: default_tls_valid_days
|
|
2028
|
+
},
|
|
2029
|
+
client_tls_package_generation: {
|
|
2030
|
+
enabled: false,
|
|
2031
|
+
config_file_path: default_client_tls_config_file_path
|
|
1608
2032
|
}
|
|
1609
2033
|
};
|
|
1610
2034
|
const argv = process.argv.slice(2);
|
|
@@ -1653,6 +2077,62 @@ var _DaemonCli = class _DaemonCli {
|
|
|
1653
2077
|
options.tls_generation.enabled = true;
|
|
1654
2078
|
continue;
|
|
1655
2079
|
}
|
|
2080
|
+
if (token2 === "--tls-generation-config") {
|
|
2081
|
+
const next_value = argv[index + 1];
|
|
2082
|
+
if (!next_value) {
|
|
2083
|
+
throw new Error("Missing value for --tls-generation-config");
|
|
2084
|
+
}
|
|
2085
|
+
options.tls_generation.config_file_path = next_value;
|
|
2086
|
+
index += 1;
|
|
2087
|
+
continue;
|
|
2088
|
+
}
|
|
2089
|
+
if (token2 === "--generate-default-tls-config") {
|
|
2090
|
+
options.default_tls_config_generation.enabled = true;
|
|
2091
|
+
continue;
|
|
2092
|
+
}
|
|
2093
|
+
if (token2 === "--default-tls-config-file") {
|
|
2094
|
+
const next_value = argv[index + 1];
|
|
2095
|
+
if (!next_value) {
|
|
2096
|
+
throw new Error("Missing value for --default-tls-config-file");
|
|
2097
|
+
}
|
|
2098
|
+
options.default_tls_config_generation.output_file_path = next_value;
|
|
2099
|
+
index += 1;
|
|
2100
|
+
continue;
|
|
2101
|
+
}
|
|
2102
|
+
if (token2 === "--default-tls-config-overwrite") {
|
|
2103
|
+
options.default_tls_config_generation.overwrite = true;
|
|
2104
|
+
continue;
|
|
2105
|
+
}
|
|
2106
|
+
if (token2 === "--generate-default-client-tls-config") {
|
|
2107
|
+
options.default_client_tls_config_generation.enabled = true;
|
|
2108
|
+
continue;
|
|
2109
|
+
}
|
|
2110
|
+
if (token2 === "--default-client-tls-config-file") {
|
|
2111
|
+
const next_value = argv[index + 1];
|
|
2112
|
+
if (!next_value) {
|
|
2113
|
+
throw new Error("Missing value for --default-client-tls-config-file");
|
|
2114
|
+
}
|
|
2115
|
+
options.default_client_tls_config_generation.output_file_path = next_value;
|
|
2116
|
+
index += 1;
|
|
2117
|
+
continue;
|
|
2118
|
+
}
|
|
2119
|
+
if (token2 === "--default-client-tls-config-overwrite") {
|
|
2120
|
+
options.default_client_tls_config_generation.overwrite = true;
|
|
2121
|
+
continue;
|
|
2122
|
+
}
|
|
2123
|
+
if (token2 === "--generate-client-tls-packages") {
|
|
2124
|
+
options.client_tls_package_generation.enabled = true;
|
|
2125
|
+
continue;
|
|
2126
|
+
}
|
|
2127
|
+
if (token2 === "--client-tls-generation-config") {
|
|
2128
|
+
const next_value = argv[index + 1];
|
|
2129
|
+
if (!next_value) {
|
|
2130
|
+
throw new Error("Missing value for --client-tls-generation-config");
|
|
2131
|
+
}
|
|
2132
|
+
options.client_tls_package_generation.config_file_path = next_value;
|
|
2133
|
+
index += 1;
|
|
2134
|
+
continue;
|
|
2135
|
+
}
|
|
1656
2136
|
if (token2 === "--tls-output-dir") {
|
|
1657
2137
|
const next_value = argv[index + 1];
|
|
1658
2138
|
if (!next_value) {
|
|
@@ -1727,7 +2207,28 @@ var _DaemonCli = class _DaemonCli {
|
|
|
1727
2207
|
" Output directory for server/api-key config files.",
|
|
1728
2208
|
" Default: ./config",
|
|
1729
2209
|
" --default-config-overwrite Overwrite existing default config files.",
|
|
2210
|
+
" --generate-default-tls-config",
|
|
2211
|
+
" Generate a default TLS-generation JSON5 config and exit.",
|
|
2212
|
+
" --default-tls-config-file <path>",
|
|
2213
|
+
" Output path for default TLS-generation config.",
|
|
2214
|
+
" Default: ./config/tls_generation.config.json5",
|
|
2215
|
+
" --default-tls-config-overwrite",
|
|
2216
|
+
" Overwrite existing TLS-generation config file.",
|
|
2217
|
+
" --generate-default-client-tls-config",
|
|
2218
|
+
" Generate a default client TLS package JSON5 config and exit.",
|
|
2219
|
+
" --default-client-tls-config-file <path>",
|
|
2220
|
+
" Output path for default client TLS package config.",
|
|
2221
|
+
" Default: ./config/client_tls_packages.config.json5",
|
|
2222
|
+
" --default-client-tls-config-overwrite",
|
|
2223
|
+
" Overwrite existing client TLS package config file.",
|
|
1730
2224
|
" --generate-tls-material Generate CA/server/client TLS material and exit.",
|
|
2225
|
+
" --tls-generation-config <path>",
|
|
2226
|
+
" Load TLS-generation options from JSON5 file.",
|
|
2227
|
+
" --generate-client-tls-packages",
|
|
2228
|
+
" Generate client cert/key packages from JSON5 config.",
|
|
2229
|
+
" --client-tls-generation-config <path>",
|
|
2230
|
+
" Path to client TLS package generation JSON5 config.",
|
|
2231
|
+
" Default: ./config/client_tls_packages.config.json5",
|
|
1731
2232
|
" --tls-output-dir <path> Output directory for generated TLS files.",
|
|
1732
2233
|
" Default: ./config/certs",
|
|
1733
2234
|
" --tls-overwrite Overwrite existing TLS files in output dir.",
|
|
@@ -1738,7 +2239,7 @@ var _DaemonCli = class _DaemonCli {
|
|
|
1738
2239
|
" --tls-client-cn <value> Client certificate common name.",
|
|
1739
2240
|
" Default: nodenetproccalld-client",
|
|
1740
2241
|
" --tls-valid-days <number> Certificate validity in days.",
|
|
1741
|
-
" Default:
|
|
2242
|
+
" Default: 36500",
|
|
1742
2243
|
" -h, --help Show this help message."
|
|
1743
2244
|
].join("\n");
|
|
1744
2245
|
console.log(help_text);
|
|
@@ -2068,9 +2569,61 @@ var _DaemonProcess = class _DaemonProcess {
|
|
|
2068
2569
|
__name(_DaemonProcess, "DaemonProcess");
|
|
2069
2570
|
var DaemonProcess = _DaemonProcess;
|
|
2070
2571
|
|
|
2572
|
+
// src/classes/defaultclienttlsgenerationconfiggenerator/DefaultClientTlsGenerationConfigGenerator.class.ts
|
|
2573
|
+
import fs4 from "fs";
|
|
2574
|
+
import path4 from "path";
|
|
2575
|
+
var default_client_tls_generation_config_template = `{
|
|
2576
|
+
// Existing CA files used to sign client certificates.
|
|
2577
|
+
// Paths are resolved relative to this config file.
|
|
2578
|
+
ca_key_file: './certs/ca.key.pem',
|
|
2579
|
+
ca_cert_file: './certs/ca.cert.pem',
|
|
2580
|
+
|
|
2581
|
+
// Where client cert bundles will be written.
|
|
2582
|
+
output_dir: './client_certs',
|
|
2583
|
+
|
|
2584
|
+
// Set true to replace existing client bundles.
|
|
2585
|
+
overwrite: false,
|
|
2586
|
+
|
|
2587
|
+
// Default validity period for generated client certs.
|
|
2588
|
+
default_valid_days: 36500,
|
|
2589
|
+
|
|
2590
|
+
clients: [
|
|
2591
|
+
{
|
|
2592
|
+
client_name: 'your_client_name_here',
|
|
2593
|
+
common_name: 'your_client_name_here',
|
|
2594
|
+
uri_san: 'spiffe://nodenetproccalld/your_client_name_here',
|
|
2595
|
+
package_name: 'your_client_name_here_bundle'
|
|
2596
|
+
},
|
|
2597
|
+
{
|
|
2598
|
+
client_name: 'localhost',
|
|
2599
|
+
common_name: 'localhost',
|
|
2600
|
+
uri_san: 'spiffe://nodenetproccalld/localhost',
|
|
2601
|
+
package_name: 'localhost_bundle'
|
|
2602
|
+
}
|
|
2603
|
+
]
|
|
2604
|
+
}
|
|
2605
|
+
`;
|
|
2606
|
+
var _DefaultClientTlsGenerationConfigGenerator = class _DefaultClientTlsGenerationConfigGenerator {
|
|
2607
|
+
generateDefaultClientTlsGenerationConfig(params) {
|
|
2608
|
+
const output_file_path = path4.resolve(process.cwd(), params.default_client_tls_config_generation_options.output_file_path);
|
|
2609
|
+
if (!params.default_client_tls_config_generation_options.overwrite && fs4.existsSync(output_file_path)) {
|
|
2610
|
+
throw new Error(`Refusing to overwrite existing client TLS config "${output_file_path}". Use --default-client-tls-config-overwrite to replace it.`);
|
|
2611
|
+
}
|
|
2612
|
+
fs4.mkdirSync(path4.dirname(output_file_path), {
|
|
2613
|
+
recursive: true
|
|
2614
|
+
});
|
|
2615
|
+
fs4.writeFileSync(output_file_path, default_client_tls_generation_config_template, "utf8");
|
|
2616
|
+
return {
|
|
2617
|
+
output_file_path
|
|
2618
|
+
};
|
|
2619
|
+
}
|
|
2620
|
+
};
|
|
2621
|
+
__name(_DefaultClientTlsGenerationConfigGenerator, "DefaultClientTlsGenerationConfigGenerator");
|
|
2622
|
+
var DefaultClientTlsGenerationConfigGenerator = _DefaultClientTlsGenerationConfigGenerator;
|
|
2623
|
+
|
|
2071
2624
|
// src/classes/defaultconfiggenerator/DefaultConfigGenerator.class.ts
|
|
2072
|
-
import
|
|
2073
|
-
import
|
|
2625
|
+
import fs5 from "fs";
|
|
2626
|
+
import path5 from "path";
|
|
2074
2627
|
var default_server_config_template = `{
|
|
2075
2628
|
// Friendly name that clients can use in their own config maps.
|
|
2076
2629
|
information: {
|
|
@@ -2174,28 +2727,28 @@ var default_api_keys_config_template = `{
|
|
|
2174
2727
|
}
|
|
2175
2728
|
`;
|
|
2176
2729
|
function EnsureParentDirectory(params) {
|
|
2177
|
-
|
|
2730
|
+
fs5.mkdirSync(path5.dirname(params.file_path), {
|
|
2178
2731
|
recursive: true
|
|
2179
2732
|
});
|
|
2180
2733
|
}
|
|
2181
2734
|
__name(EnsureParentDirectory, "EnsureParentDirectory");
|
|
2182
2735
|
function WriteFileIfAllowed(params) {
|
|
2183
|
-
if (!params.overwrite &&
|
|
2736
|
+
if (!params.overwrite && fs5.existsSync(params.file_path)) {
|
|
2184
2737
|
throw new Error(`Refusing to overwrite existing config "${params.file_path}". Use --default-config-overwrite to replace it.`);
|
|
2185
2738
|
}
|
|
2186
2739
|
EnsureParentDirectory({
|
|
2187
2740
|
file_path: params.file_path
|
|
2188
2741
|
});
|
|
2189
|
-
|
|
2742
|
+
fs5.writeFileSync(params.file_path, params.content, "utf8");
|
|
2190
2743
|
}
|
|
2191
2744
|
__name(WriteFileIfAllowed, "WriteFileIfAllowed");
|
|
2192
2745
|
var _DefaultConfigGenerator = class _DefaultConfigGenerator {
|
|
2193
2746
|
generateDefaultConfig(params) {
|
|
2194
2747
|
const options = params.default_config_generation_options;
|
|
2195
|
-
const output_dir =
|
|
2196
|
-
const server_config_path =
|
|
2197
|
-
const api_keys_config_path =
|
|
2198
|
-
|
|
2748
|
+
const output_dir = path5.resolve(process.cwd(), options.output_dir);
|
|
2749
|
+
const server_config_path = path5.join(output_dir, "server.config.json5");
|
|
2750
|
+
const api_keys_config_path = path5.join(output_dir, "api_keys.config.json5");
|
|
2751
|
+
fs5.mkdirSync(output_dir, {
|
|
2199
2752
|
recursive: true
|
|
2200
2753
|
});
|
|
2201
2754
|
WriteFileIfAllowed({
|
|
@@ -2218,10 +2771,117 @@ var _DefaultConfigGenerator = class _DefaultConfigGenerator {
|
|
|
2218
2771
|
__name(_DefaultConfigGenerator, "DefaultConfigGenerator");
|
|
2219
2772
|
var DefaultConfigGenerator = _DefaultConfigGenerator;
|
|
2220
2773
|
|
|
2774
|
+
// src/classes/defaulttlsgenerationconfiggenerator/DefaultTlsGenerationConfigGenerator.class.ts
|
|
2775
|
+
import fs6 from "fs";
|
|
2776
|
+
import path6 from "path";
|
|
2777
|
+
var default_tls_generation_config_template = `{
|
|
2778
|
+
// Where generated CA/server/client cert + key files should be written.
|
|
2779
|
+
output_dir: './config/certs',
|
|
2780
|
+
|
|
2781
|
+
// Set true to replace existing files in output_dir.
|
|
2782
|
+
overwrite: false,
|
|
2783
|
+
|
|
2784
|
+
// X.509 subject common names.
|
|
2785
|
+
ca_common_name: 'nodenetproccalld-local-ca',
|
|
2786
|
+
server_common_name: 'your_server_name_here',
|
|
2787
|
+
client_common_name: 'nodenetproccalld-client',
|
|
2788
|
+
|
|
2789
|
+
// Server certificate SAN entries used by hostname validation.
|
|
2790
|
+
// Add the DNS names and IPs clients will actually connect to.
|
|
2791
|
+
server_dns_sans: ['your_server_name_here', 'localhost'],
|
|
2792
|
+
server_ip_sans: ['127.0.0.1'],
|
|
2793
|
+
|
|
2794
|
+
// Optional explicit client URI SAN; when omitted, generator derives one from client_common_name.
|
|
2795
|
+
// client_uri_san: 'spiffe://nodenetproccalld/client',
|
|
2796
|
+
|
|
2797
|
+
// Certificate validity period.
|
|
2798
|
+
valid_days: 36500
|
|
2799
|
+
}
|
|
2800
|
+
`;
|
|
2801
|
+
var _DefaultTlsGenerationConfigGenerator = class _DefaultTlsGenerationConfigGenerator {
|
|
2802
|
+
generateDefaultTlsGenerationConfig(params) {
|
|
2803
|
+
const output_file_path = path6.resolve(process.cwd(), params.default_tls_config_generation_options.output_file_path);
|
|
2804
|
+
if (!params.default_tls_config_generation_options.overwrite && fs6.existsSync(output_file_path)) {
|
|
2805
|
+
throw new Error(`Refusing to overwrite existing TLS generation config "${output_file_path}". Use --default-tls-config-overwrite to replace it.`);
|
|
2806
|
+
}
|
|
2807
|
+
fs6.mkdirSync(path6.dirname(output_file_path), {
|
|
2808
|
+
recursive: true
|
|
2809
|
+
});
|
|
2810
|
+
fs6.writeFileSync(output_file_path, default_tls_generation_config_template, "utf8");
|
|
2811
|
+
return {
|
|
2812
|
+
output_file_path
|
|
2813
|
+
};
|
|
2814
|
+
}
|
|
2815
|
+
};
|
|
2816
|
+
__name(_DefaultTlsGenerationConfigGenerator, "DefaultTlsGenerationConfigGenerator");
|
|
2817
|
+
var DefaultTlsGenerationConfigGenerator = _DefaultTlsGenerationConfigGenerator;
|
|
2818
|
+
|
|
2819
|
+
// src/classes/tlsgenerationconfigfileloader/TlsGenerationConfigFileLoader.class.ts
|
|
2820
|
+
import fs7 from "fs";
|
|
2821
|
+
import path7 from "path";
|
|
2822
|
+
import { z as z3 } from "zod";
|
|
2823
|
+
var tls_generation_config_schema = z3.object({
|
|
2824
|
+
output_dir: z3.string().min(1).optional(),
|
|
2825
|
+
overwrite: z3.boolean().optional(),
|
|
2826
|
+
ca_common_name: z3.string().min(1).optional(),
|
|
2827
|
+
server_common_name: z3.string().min(1).optional(),
|
|
2828
|
+
client_common_name: z3.string().min(1).optional(),
|
|
2829
|
+
server_dns_sans: z3.array(z3.string().min(1)).optional(),
|
|
2830
|
+
server_ip_sans: z3.array(z3.string().min(1)).optional(),
|
|
2831
|
+
client_uri_san: z3.string().min(1).optional(),
|
|
2832
|
+
valid_days: z3.number().int().positive().optional()
|
|
2833
|
+
}).strict();
|
|
2834
|
+
function ParseJson5File2(params) {
|
|
2835
|
+
const absolute_file_path = path7.resolve(process.cwd(), params.file_path);
|
|
2836
|
+
let file_content;
|
|
2837
|
+
try {
|
|
2838
|
+
file_content = fs7.readFileSync(absolute_file_path, "utf8");
|
|
2839
|
+
} catch (error) {
|
|
2840
|
+
const error_message = error instanceof Error ? error.message : String(error);
|
|
2841
|
+
throw new Error(`Unable to read TLS generation config file "${absolute_file_path}": ${error_message}`);
|
|
2842
|
+
}
|
|
2843
|
+
try {
|
|
2844
|
+
return dist_default.parse(file_content);
|
|
2845
|
+
} catch (error) {
|
|
2846
|
+
const error_message = error instanceof Error ? error.message : String(error);
|
|
2847
|
+
throw new Error(`Invalid JSON5 in TLS generation config "${absolute_file_path}": ${error_message}`);
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
__name(ParseJson5File2, "ParseJson5File");
|
|
2851
|
+
function BuildZodErrorMessage3(params) {
|
|
2852
|
+
const lines = params.error.issues.map((issue) => {
|
|
2853
|
+
const issue_path = issue.path.length > 0 ? issue.path.join(".") : "<root>";
|
|
2854
|
+
return `${issue_path}: ${issue.message}`;
|
|
2855
|
+
});
|
|
2856
|
+
return `Invalid TLS generation config file.
|
|
2857
|
+
${lines.join("\n")}`;
|
|
2858
|
+
}
|
|
2859
|
+
__name(BuildZodErrorMessage3, "BuildZodErrorMessage");
|
|
2860
|
+
var _TlsGenerationConfigFileLoader = class _TlsGenerationConfigFileLoader {
|
|
2861
|
+
loadTlsGenerationOptions(params) {
|
|
2862
|
+
const config_raw = ParseJson5File2({
|
|
2863
|
+
file_path: params.config_file_path
|
|
2864
|
+
});
|
|
2865
|
+
const parse_result = tls_generation_config_schema.safeParse(config_raw);
|
|
2866
|
+
if (!parse_result.success) {
|
|
2867
|
+
throw new Error(BuildZodErrorMessage3({
|
|
2868
|
+
error: parse_result.error
|
|
2869
|
+
}));
|
|
2870
|
+
}
|
|
2871
|
+
const config_from_file = parse_result.data;
|
|
2872
|
+
return {
|
|
2873
|
+
...params.fallback_options,
|
|
2874
|
+
...config_from_file
|
|
2875
|
+
};
|
|
2876
|
+
}
|
|
2877
|
+
};
|
|
2878
|
+
__name(_TlsGenerationConfigFileLoader, "TlsGenerationConfigFileLoader");
|
|
2879
|
+
var TlsGenerationConfigFileLoader = _TlsGenerationConfigFileLoader;
|
|
2880
|
+
|
|
2221
2881
|
// src/classes/tlsmaterialgenerator/TlsMaterialGenerator.class.ts
|
|
2222
|
-
import { execFileSync } from "child_process";
|
|
2223
|
-
import
|
|
2224
|
-
import
|
|
2882
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
2883
|
+
import fs8 from "fs";
|
|
2884
|
+
import path8 from "path";
|
|
2225
2885
|
function EnsurePositiveInteger(params) {
|
|
2226
2886
|
if (!Number.isInteger(params.value) || params.value <= 0) {
|
|
2227
2887
|
throw new Error(`${params.label} must be a positive integer.`);
|
|
@@ -2229,15 +2889,35 @@ function EnsurePositiveInteger(params) {
|
|
|
2229
2889
|
}
|
|
2230
2890
|
__name(EnsurePositiveInteger, "EnsurePositiveInteger");
|
|
2231
2891
|
function MakeDirRecursive(params) {
|
|
2232
|
-
|
|
2892
|
+
fs8.mkdirSync(params.dir_path, {
|
|
2233
2893
|
recursive: true
|
|
2234
2894
|
});
|
|
2235
2895
|
}
|
|
2236
2896
|
__name(MakeDirRecursive, "MakeDirRecursive");
|
|
2237
|
-
function
|
|
2238
|
-
|
|
2897
|
+
function WriteTextFile2(params) {
|
|
2898
|
+
fs8.writeFileSync(params.file_path, params.content, "utf8");
|
|
2239
2899
|
}
|
|
2240
|
-
__name(
|
|
2900
|
+
__name(WriteTextFile2, "WriteTextFile");
|
|
2901
|
+
function BuildServerSubjectAltNameLine(params) {
|
|
2902
|
+
const san_entries = [];
|
|
2903
|
+
for (const dns_name of params.server_dns_sans) {
|
|
2904
|
+
if (dns_name.trim().length === 0) {
|
|
2905
|
+
continue;
|
|
2906
|
+
}
|
|
2907
|
+
san_entries.push(`DNS:${dns_name.trim()}`);
|
|
2908
|
+
}
|
|
2909
|
+
for (const ip_addr of params.server_ip_sans) {
|
|
2910
|
+
if (ip_addr.trim().length === 0) {
|
|
2911
|
+
continue;
|
|
2912
|
+
}
|
|
2913
|
+
san_entries.push(`IP:${ip_addr.trim()}`);
|
|
2914
|
+
}
|
|
2915
|
+
if (san_entries.length === 0) {
|
|
2916
|
+
throw new Error("TLS generation requires at least one SAN entry. Provide server_dns_sans or server_ip_sans.");
|
|
2917
|
+
}
|
|
2918
|
+
return `subjectAltName=${san_entries.join(",")}`;
|
|
2919
|
+
}
|
|
2920
|
+
__name(BuildServerSubjectAltNameLine, "BuildServerSubjectAltNameLine");
|
|
2241
2921
|
var _TlsMaterialGenerator = class _TlsMaterialGenerator {
|
|
2242
2922
|
generateTlsMaterial(params) {
|
|
2243
2923
|
const options = params.tls_generation_options;
|
|
@@ -2245,7 +2925,7 @@ var _TlsMaterialGenerator = class _TlsMaterialGenerator {
|
|
|
2245
2925
|
value: options.valid_days,
|
|
2246
2926
|
label: "tls_generation.valid_days"
|
|
2247
2927
|
});
|
|
2248
|
-
const output_dir =
|
|
2928
|
+
const output_dir = path8.resolve(process.cwd(), options.output_dir);
|
|
2249
2929
|
MakeDirRecursive({
|
|
2250
2930
|
dir_path: output_dir
|
|
2251
2931
|
});
|
|
@@ -2266,12 +2946,15 @@ var _TlsMaterialGenerator = class _TlsMaterialGenerator {
|
|
|
2266
2946
|
this.generateServerCertificate({
|
|
2267
2947
|
tls_files,
|
|
2268
2948
|
valid_days: options.valid_days,
|
|
2269
|
-
server_common_name: options.server_common_name
|
|
2949
|
+
server_common_name: options.server_common_name,
|
|
2950
|
+
server_dns_sans: options.server_dns_sans,
|
|
2951
|
+
server_ip_sans: options.server_ip_sans
|
|
2270
2952
|
});
|
|
2271
2953
|
this.generateClientCertificate({
|
|
2272
2954
|
tls_files,
|
|
2273
2955
|
valid_days: options.valid_days,
|
|
2274
|
-
client_common_name: options.client_common_name
|
|
2956
|
+
client_common_name: options.client_common_name,
|
|
2957
|
+
client_uri_san: options.client_uri_san
|
|
2275
2958
|
});
|
|
2276
2959
|
this.cleanupIntermediateFiles({
|
|
2277
2960
|
tls_files
|
|
@@ -2293,7 +2976,7 @@ var _TlsMaterialGenerator = class _TlsMaterialGenerator {
|
|
|
2293
2976
|
}
|
|
2294
2977
|
assertOpenSslAvailable() {
|
|
2295
2978
|
try {
|
|
2296
|
-
|
|
2979
|
+
execFileSync2("openssl", [
|
|
2297
2980
|
"version"
|
|
2298
2981
|
], {
|
|
2299
2982
|
stdio: "ignore"
|
|
@@ -2304,17 +2987,17 @@ var _TlsMaterialGenerator = class _TlsMaterialGenerator {
|
|
|
2304
2987
|
}
|
|
2305
2988
|
buildTlsFileMap(params) {
|
|
2306
2989
|
return {
|
|
2307
|
-
ca_key_path:
|
|
2308
|
-
ca_cert_path:
|
|
2309
|
-
server_key_path:
|
|
2310
|
-
server_csr_path:
|
|
2311
|
-
server_cert_path:
|
|
2312
|
-
server_ext_path:
|
|
2313
|
-
client_key_path:
|
|
2314
|
-
client_csr_path:
|
|
2315
|
-
client_cert_path:
|
|
2316
|
-
client_ext_path:
|
|
2317
|
-
ca_serial_path:
|
|
2990
|
+
ca_key_path: path8.join(params.output_dir, "ca.key.pem"),
|
|
2991
|
+
ca_cert_path: path8.join(params.output_dir, "ca.cert.pem"),
|
|
2992
|
+
server_key_path: path8.join(params.output_dir, "server.key.pem"),
|
|
2993
|
+
server_csr_path: path8.join(params.output_dir, "server.csr.pem"),
|
|
2994
|
+
server_cert_path: path8.join(params.output_dir, "server.cert.pem"),
|
|
2995
|
+
server_ext_path: path8.join(params.output_dir, "server.ext"),
|
|
2996
|
+
client_key_path: path8.join(params.output_dir, "client.key.pem"),
|
|
2997
|
+
client_csr_path: path8.join(params.output_dir, "client.csr.pem"),
|
|
2998
|
+
client_cert_path: path8.join(params.output_dir, "client.cert.pem"),
|
|
2999
|
+
client_ext_path: path8.join(params.output_dir, "client.ext"),
|
|
3000
|
+
ca_serial_path: path8.join(params.output_dir, "ca.cert.srl")
|
|
2318
3001
|
};
|
|
2319
3002
|
}
|
|
2320
3003
|
assertTargetFilesAreWritable(params) {
|
|
@@ -2328,18 +3011,18 @@ var _TlsMaterialGenerator = class _TlsMaterialGenerator {
|
|
|
2328
3011
|
];
|
|
2329
3012
|
if (!params.overwrite) {
|
|
2330
3013
|
for (const target_path of target_paths) {
|
|
2331
|
-
if (
|
|
3014
|
+
if (fs8.existsSync(target_path)) {
|
|
2332
3015
|
throw new Error(`Refusing to overwrite existing file "${target_path}". Use --tls-overwrite to replace existing material.`);
|
|
2333
3016
|
}
|
|
2334
3017
|
}
|
|
2335
3018
|
return;
|
|
2336
3019
|
}
|
|
2337
3020
|
for (const target_path of target_paths) {
|
|
2338
|
-
|
|
3021
|
+
fs8.rmSync(target_path, {
|
|
2339
3022
|
force: true
|
|
2340
3023
|
});
|
|
2341
3024
|
}
|
|
2342
|
-
|
|
3025
|
+
fs8.rmSync(params.tls_files.ca_serial_path, {
|
|
2343
3026
|
force: true
|
|
2344
3027
|
});
|
|
2345
3028
|
}
|
|
@@ -2364,10 +3047,13 @@ var _TlsMaterialGenerator = class _TlsMaterialGenerator {
|
|
|
2364
3047
|
});
|
|
2365
3048
|
}
|
|
2366
3049
|
generateServerCertificate(params) {
|
|
2367
|
-
|
|
3050
|
+
WriteTextFile2({
|
|
2368
3051
|
file_path: params.tls_files.server_ext_path,
|
|
2369
3052
|
content: [
|
|
2370
|
-
|
|
3053
|
+
BuildServerSubjectAltNameLine({
|
|
3054
|
+
server_dns_sans: params.server_dns_sans,
|
|
3055
|
+
server_ip_sans: params.server_ip_sans
|
|
3056
|
+
}),
|
|
2371
3057
|
"extendedKeyUsage=serverAuth",
|
|
2372
3058
|
"keyUsage=digitalSignature,keyEncipherment"
|
|
2373
3059
|
].join("\n")
|
|
@@ -2412,8 +3098,8 @@ var _TlsMaterialGenerator = class _TlsMaterialGenerator {
|
|
|
2412
3098
|
});
|
|
2413
3099
|
}
|
|
2414
3100
|
generateClientCertificate(params) {
|
|
2415
|
-
const client_uri = `spiffe://nodenetproccalld/${params.client_common_name.replace(/[^a-zA-Z0-9_.-]/g, "_").toLowerCase()}`;
|
|
2416
|
-
|
|
3101
|
+
const client_uri = params.client_uri_san ?? `spiffe://nodenetproccalld/${params.client_common_name.replace(/[^a-zA-Z0-9_.-]/g, "_").toLowerCase()}`;
|
|
3102
|
+
WriteTextFile2({
|
|
2417
3103
|
file_path: params.tls_files.client_ext_path,
|
|
2418
3104
|
content: [
|
|
2419
3105
|
"extendedKeyUsage=clientAuth",
|
|
@@ -2460,24 +3146,24 @@ var _TlsMaterialGenerator = class _TlsMaterialGenerator {
|
|
|
2460
3146
|
});
|
|
2461
3147
|
}
|
|
2462
3148
|
cleanupIntermediateFiles(params) {
|
|
2463
|
-
|
|
3149
|
+
fs8.rmSync(params.tls_files.server_csr_path, {
|
|
2464
3150
|
force: true
|
|
2465
3151
|
});
|
|
2466
|
-
|
|
3152
|
+
fs8.rmSync(params.tls_files.client_csr_path, {
|
|
2467
3153
|
force: true
|
|
2468
3154
|
});
|
|
2469
|
-
|
|
3155
|
+
fs8.rmSync(params.tls_files.server_ext_path, {
|
|
2470
3156
|
force: true
|
|
2471
3157
|
});
|
|
2472
|
-
|
|
3158
|
+
fs8.rmSync(params.tls_files.client_ext_path, {
|
|
2473
3159
|
force: true
|
|
2474
3160
|
});
|
|
2475
|
-
|
|
3161
|
+
fs8.rmSync(params.tls_files.ca_serial_path, {
|
|
2476
3162
|
force: true
|
|
2477
3163
|
});
|
|
2478
3164
|
}
|
|
2479
3165
|
runOpenSslCommand(params) {
|
|
2480
|
-
|
|
3166
|
+
execFileSync2("openssl", params.args, {
|
|
2481
3167
|
stdio: "ignore"
|
|
2482
3168
|
});
|
|
2483
3169
|
}
|
|
@@ -2510,10 +3196,36 @@ async function StartDaemonFromCli() {
|
|
|
2510
3196
|
console.log(`API keys config: ${generated_default_config.api_keys_config_path}`);
|
|
2511
3197
|
return;
|
|
2512
3198
|
}
|
|
3199
|
+
if (cli_options.default_tls_config_generation.enabled) {
|
|
3200
|
+
const default_tls_generation_config_generator = new DefaultTlsGenerationConfigGenerator();
|
|
3201
|
+
const generated_default_tls_config = default_tls_generation_config_generator.generateDefaultTlsGenerationConfig({
|
|
3202
|
+
default_tls_config_generation_options: cli_options.default_tls_config_generation
|
|
3203
|
+
});
|
|
3204
|
+
console.log("Default TLS-generation config generated successfully.");
|
|
3205
|
+
console.log(`TLS-generation config: ${generated_default_tls_config.output_file_path}`);
|
|
3206
|
+
return;
|
|
3207
|
+
}
|
|
3208
|
+
if (cli_options.default_client_tls_config_generation.enabled) {
|
|
3209
|
+
const default_client_tls_config_generator = new DefaultClientTlsGenerationConfigGenerator();
|
|
3210
|
+
const generated_default_client_tls_config = default_client_tls_config_generator.generateDefaultClientTlsGenerationConfig({
|
|
3211
|
+
default_client_tls_config_generation_options: cli_options.default_client_tls_config_generation
|
|
3212
|
+
});
|
|
3213
|
+
console.log("Default client TLS package config generated successfully.");
|
|
3214
|
+
console.log(`Client TLS package config: ${generated_default_client_tls_config.output_file_path}`);
|
|
3215
|
+
return;
|
|
3216
|
+
}
|
|
2513
3217
|
if (cli_options.tls_generation.enabled) {
|
|
3218
|
+
let tls_generation_options = cli_options.tls_generation;
|
|
3219
|
+
if (cli_options.tls_generation.config_file_path) {
|
|
3220
|
+
const tls_generation_config_file_loader = new TlsGenerationConfigFileLoader();
|
|
3221
|
+
tls_generation_options = tls_generation_config_file_loader.loadTlsGenerationOptions({
|
|
3222
|
+
config_file_path: cli_options.tls_generation.config_file_path,
|
|
3223
|
+
fallback_options: tls_generation_options
|
|
3224
|
+
});
|
|
3225
|
+
}
|
|
2514
3226
|
const tls_material_generator = new TlsMaterialGenerator();
|
|
2515
3227
|
const generated_tls_material = tls_material_generator.generateTlsMaterial({
|
|
2516
|
-
tls_generation_options
|
|
3228
|
+
tls_generation_options
|
|
2517
3229
|
});
|
|
2518
3230
|
console.log("TLS material generated successfully.");
|
|
2519
3231
|
console.log(`Output directory: ${generated_tls_material.output_dir}`);
|
|
@@ -2526,6 +3238,22 @@ async function StartDaemonFromCli() {
|
|
|
2526
3238
|
console.log("If using default config, set tls_mtls key_file/cert_file/ca_file in config/server.config.json5 to these files.");
|
|
2527
3239
|
return;
|
|
2528
3240
|
}
|
|
3241
|
+
if (cli_options.client_tls_package_generation.enabled) {
|
|
3242
|
+
const client_tls_package_config_file_loader = new ClientTlsPackageConfigFileLoader();
|
|
3243
|
+
const runtime_options = client_tls_package_config_file_loader.loadClientTlsPackageOptions({
|
|
3244
|
+
client_tls_package_generation_options: cli_options.client_tls_package_generation
|
|
3245
|
+
});
|
|
3246
|
+
const client_tls_package_generator = new ClientTlsPackageGenerator();
|
|
3247
|
+
const generated_client_tls_packages = client_tls_package_generator.generateClientTlsPackages({
|
|
3248
|
+
runtime_options
|
|
3249
|
+
});
|
|
3250
|
+
console.log("Client TLS packages generated successfully.");
|
|
3251
|
+
console.log(`Output directory: ${generated_client_tls_packages.output_dir}`);
|
|
3252
|
+
for (const generated_package of generated_client_tls_packages.packages) {
|
|
3253
|
+
console.log(`Client ${generated_package.client_name}: ${generated_package.package_path}`);
|
|
3254
|
+
}
|
|
3255
|
+
return;
|
|
3256
|
+
}
|
|
2529
3257
|
const daemon_process = new DaemonProcess({
|
|
2530
3258
|
config_paths: {
|
|
2531
3259
|
server_config_path: cli_options.server_config_path,
|
|
@@ -2544,12 +3272,17 @@ if (__require.main === module) {
|
|
|
2544
3272
|
}
|
|
2545
3273
|
export {
|
|
2546
3274
|
ApiKeyAuthorizer,
|
|
3275
|
+
ClientTlsPackageConfigFileLoader,
|
|
3276
|
+
ClientTlsPackageGenerator,
|
|
2547
3277
|
ConfigFileLoader,
|
|
2548
3278
|
ConfigValidator,
|
|
2549
3279
|
DaemonCli,
|
|
2550
3280
|
DaemonProcess,
|
|
3281
|
+
DefaultClientTlsGenerationConfigGenerator,
|
|
2551
3282
|
DefaultConfigGenerator,
|
|
3283
|
+
DefaultTlsGenerationConfigGenerator,
|
|
2552
3284
|
NetworkProcedureCallDaemon,
|
|
3285
|
+
TlsGenerationConfigFileLoader,
|
|
2553
3286
|
TlsMaterialGenerator
|
|
2554
3287
|
};
|
|
2555
3288
|
//# sourceMappingURL=index.mjs.map
|