@opsimathically/nodenetproccalld 0.0.1 → 0.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/README.md +27 -7
- package/dist/index.d.mts +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +216 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +215 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,10 +64,30 @@ npm run build
|
|
|
64
64
|
npm run start
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
3. Generate
|
|
67
|
+
3. Generate default config files in `./config` (relative to where command is run):
|
|
68
68
|
|
|
69
69
|
```bash
|
|
70
|
-
|
|
70
|
+
nodenetproccalld --generate-default-config
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
By default this writes:
|
|
74
|
+
|
|
75
|
+
- `./config/server.config.json5`
|
|
76
|
+
- `./config/api_keys.config.json5`
|
|
77
|
+
|
|
78
|
+
Useful options:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
nodenetproccalld \
|
|
82
|
+
--generate-default-config \
|
|
83
|
+
--default-config-output-dir ./config \
|
|
84
|
+
--default-config-overwrite
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
4. Generate TLS material for fresh installs (CA/server/client):
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
nodenetproccalld --generate-tls-material
|
|
71
91
|
```
|
|
72
92
|
|
|
73
93
|
By default this writes:
|
|
@@ -82,7 +102,7 @@ By default this writes:
|
|
|
82
102
|
Useful options:
|
|
83
103
|
|
|
84
104
|
```bash
|
|
85
|
-
|
|
105
|
+
nodenetproccalld \
|
|
86
106
|
--generate-tls-material \
|
|
87
107
|
--tls-output-dir ./config/certs \
|
|
88
108
|
--tls-overwrite \
|
|
@@ -92,18 +112,18 @@ node dist/index.js \
|
|
|
92
112
|
--tls-valid-days 365
|
|
93
113
|
```
|
|
94
114
|
|
|
95
|
-
|
|
115
|
+
5. Start daemon with custom config paths:
|
|
96
116
|
|
|
97
117
|
```bash
|
|
98
|
-
|
|
118
|
+
nodenetproccalld \
|
|
99
119
|
--server-config /absolute/or/relative/server.config.json5 \
|
|
100
120
|
--api-keys-config /absolute/or/relative/api_keys.config.json5
|
|
101
121
|
```
|
|
102
122
|
|
|
103
|
-
|
|
123
|
+
6. CLI help:
|
|
104
124
|
|
|
105
125
|
```bash
|
|
106
|
-
|
|
126
|
+
nodenetproccalld --help
|
|
107
127
|
```
|
|
108
128
|
|
|
109
129
|
Installed package binaries:
|
package/dist/index.d.mts
CHANGED
|
@@ -101,6 +101,18 @@ type daemon_config_paths_t = {
|
|
|
101
101
|
api_keys_config_path: string;
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
+
type daemon_default_config_generation_options_t = {
|
|
105
|
+
enabled: boolean;
|
|
106
|
+
output_dir: string;
|
|
107
|
+
overwrite: boolean;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
type daemon_generated_default_config_t = {
|
|
111
|
+
output_dir: string;
|
|
112
|
+
server_config_path: string;
|
|
113
|
+
api_keys_config_path: string;
|
|
114
|
+
};
|
|
115
|
+
|
|
104
116
|
type daemon_tls_generation_options_t = {
|
|
105
117
|
enabled: boolean;
|
|
106
118
|
output_dir: string;
|
|
@@ -123,6 +135,7 @@ type daemon_generated_tls_material_t = {
|
|
|
123
135
|
|
|
124
136
|
type daemon_cli_options_t = daemon_config_paths_t & {
|
|
125
137
|
help: boolean;
|
|
138
|
+
default_config_generation: daemon_default_config_generation_options_t;
|
|
126
139
|
tls_generation: daemon_tls_generation_options_t;
|
|
127
140
|
};
|
|
128
141
|
|
|
@@ -191,6 +204,12 @@ declare class DaemonProcess {
|
|
|
191
204
|
private requestStop;
|
|
192
205
|
}
|
|
193
206
|
|
|
207
|
+
declare class DefaultConfigGenerator {
|
|
208
|
+
generateDefaultConfig(params: {
|
|
209
|
+
default_config_generation_options: daemon_default_config_generation_options_t;
|
|
210
|
+
}): daemon_generated_default_config_t;
|
|
211
|
+
}
|
|
212
|
+
|
|
194
213
|
type daemon_lifecycle_state_t = 'stopped' | 'starting' | 'running' | 'stopping';
|
|
195
214
|
type daemon_runtime_snapshot_t = {
|
|
196
215
|
lifecycle_state: daemon_lifecycle_state_t;
|
|
@@ -243,4 +262,4 @@ declare class TlsMaterialGenerator {
|
|
|
243
262
|
private getErrorMessage;
|
|
244
263
|
}
|
|
245
264
|
|
|
246
|
-
export { ApiKeyAuthorizer, ConfigFileLoader, ConfigValidator, DaemonCli, DaemonProcess, NetworkProcedureCallDaemon, TlsMaterialGenerator, type daemon_api_key_entry_t, type daemon_api_key_identity_constraints_t, type daemon_api_keys_config_file_t, type daemon_cli_options_t, type daemon_config_paths_t, type daemon_generated_tls_material_t, type daemon_observability_config_t, type daemon_runtime_api_key_entry_t, type daemon_runtime_config_t, type daemon_server_config_file_t, type daemon_tls_file_config_t, type daemon_tls_generation_options_t, type daemon_worker_config_t };
|
|
265
|
+
export { ApiKeyAuthorizer, ConfigFileLoader, ConfigValidator, DaemonCli, DaemonProcess, DefaultConfigGenerator, NetworkProcedureCallDaemon, TlsMaterialGenerator, type daemon_api_key_entry_t, type daemon_api_key_identity_constraints_t, type daemon_api_keys_config_file_t, type daemon_cli_options_t, type daemon_config_paths_t, type daemon_default_config_generation_options_t, type daemon_generated_default_config_t, type daemon_generated_tls_material_t, type daemon_observability_config_t, type daemon_runtime_api_key_entry_t, type daemon_runtime_config_t, type daemon_server_config_file_t, type daemon_tls_file_config_t, type daemon_tls_generation_options_t, type daemon_worker_config_t };
|
package/dist/index.d.ts
CHANGED
|
@@ -101,6 +101,18 @@ type daemon_config_paths_t = {
|
|
|
101
101
|
api_keys_config_path: string;
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
+
type daemon_default_config_generation_options_t = {
|
|
105
|
+
enabled: boolean;
|
|
106
|
+
output_dir: string;
|
|
107
|
+
overwrite: boolean;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
type daemon_generated_default_config_t = {
|
|
111
|
+
output_dir: string;
|
|
112
|
+
server_config_path: string;
|
|
113
|
+
api_keys_config_path: string;
|
|
114
|
+
};
|
|
115
|
+
|
|
104
116
|
type daemon_tls_generation_options_t = {
|
|
105
117
|
enabled: boolean;
|
|
106
118
|
output_dir: string;
|
|
@@ -123,6 +135,7 @@ type daemon_generated_tls_material_t = {
|
|
|
123
135
|
|
|
124
136
|
type daemon_cli_options_t = daemon_config_paths_t & {
|
|
125
137
|
help: boolean;
|
|
138
|
+
default_config_generation: daemon_default_config_generation_options_t;
|
|
126
139
|
tls_generation: daemon_tls_generation_options_t;
|
|
127
140
|
};
|
|
128
141
|
|
|
@@ -191,6 +204,12 @@ declare class DaemonProcess {
|
|
|
191
204
|
private requestStop;
|
|
192
205
|
}
|
|
193
206
|
|
|
207
|
+
declare class DefaultConfigGenerator {
|
|
208
|
+
generateDefaultConfig(params: {
|
|
209
|
+
default_config_generation_options: daemon_default_config_generation_options_t;
|
|
210
|
+
}): daemon_generated_default_config_t;
|
|
211
|
+
}
|
|
212
|
+
|
|
194
213
|
type daemon_lifecycle_state_t = 'stopped' | 'starting' | 'running' | 'stopping';
|
|
195
214
|
type daemon_runtime_snapshot_t = {
|
|
196
215
|
lifecycle_state: daemon_lifecycle_state_t;
|
|
@@ -243,4 +262,4 @@ declare class TlsMaterialGenerator {
|
|
|
243
262
|
private getErrorMessage;
|
|
244
263
|
}
|
|
245
264
|
|
|
246
|
-
export { ApiKeyAuthorizer, ConfigFileLoader, ConfigValidator, DaemonCli, DaemonProcess, NetworkProcedureCallDaemon, TlsMaterialGenerator, type daemon_api_key_entry_t, type daemon_api_key_identity_constraints_t, type daemon_api_keys_config_file_t, type daemon_cli_options_t, type daemon_config_paths_t, type daemon_generated_tls_material_t, type daemon_observability_config_t, type daemon_runtime_api_key_entry_t, type daemon_runtime_config_t, type daemon_server_config_file_t, type daemon_tls_file_config_t, type daemon_tls_generation_options_t, type daemon_worker_config_t };
|
|
265
|
+
export { ApiKeyAuthorizer, ConfigFileLoader, ConfigValidator, DaemonCli, DaemonProcess, DefaultConfigGenerator, NetworkProcedureCallDaemon, TlsMaterialGenerator, type daemon_api_key_entry_t, type daemon_api_key_identity_constraints_t, type daemon_api_keys_config_file_t, type daemon_cli_options_t, type daemon_config_paths_t, type daemon_default_config_generation_options_t, type daemon_generated_default_config_t, type daemon_generated_tls_material_t, type daemon_observability_config_t, type daemon_runtime_api_key_entry_t, type daemon_runtime_config_t, type daemon_server_config_file_t, type daemon_tls_file_config_t, type daemon_tls_generation_options_t, type daemon_worker_config_t };
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,7 @@ __export(index_exports, {
|
|
|
39
39
|
ConfigValidator: () => ConfigValidator,
|
|
40
40
|
DaemonCli: () => DaemonCli,
|
|
41
41
|
DaemonProcess: () => DaemonProcess,
|
|
42
|
+
DefaultConfigGenerator: () => DefaultConfigGenerator,
|
|
42
43
|
NetworkProcedureCallDaemon: () => NetworkProcedureCallDaemon,
|
|
43
44
|
TlsMaterialGenerator: () => TlsMaterialGenerator
|
|
44
45
|
});
|
|
@@ -1614,6 +1615,7 @@ var ConfigFileLoader = _ConfigFileLoader;
|
|
|
1614
1615
|
// src/classes/daemoncli/DaemonCli.class.ts
|
|
1615
1616
|
var default_server_config_path = "./config/server.config.json5";
|
|
1616
1617
|
var default_api_keys_config_path = "./config/api_keys.config.json5";
|
|
1618
|
+
var default_config_output_dir = "./config";
|
|
1617
1619
|
var default_tls_output_dir = "./config/certs";
|
|
1618
1620
|
var default_ca_common_name = "nodenetproccalld-local-ca";
|
|
1619
1621
|
var default_server_common_name = "localhost";
|
|
@@ -1625,6 +1627,11 @@ var _DaemonCli = class _DaemonCli {
|
|
|
1625
1627
|
server_config_path: default_server_config_path,
|
|
1626
1628
|
api_keys_config_path: default_api_keys_config_path,
|
|
1627
1629
|
help: false,
|
|
1630
|
+
default_config_generation: {
|
|
1631
|
+
enabled: false,
|
|
1632
|
+
output_dir: default_config_output_dir,
|
|
1633
|
+
overwrite: false
|
|
1634
|
+
},
|
|
1628
1635
|
tls_generation: {
|
|
1629
1636
|
enabled: false,
|
|
1630
1637
|
output_dir: default_tls_output_dir,
|
|
@@ -1660,6 +1667,23 @@ var _DaemonCli = class _DaemonCli {
|
|
|
1660
1667
|
index += 1;
|
|
1661
1668
|
continue;
|
|
1662
1669
|
}
|
|
1670
|
+
if (token2 === "--generate-default-config") {
|
|
1671
|
+
options.default_config_generation.enabled = true;
|
|
1672
|
+
continue;
|
|
1673
|
+
}
|
|
1674
|
+
if (token2 === "--default-config-output-dir") {
|
|
1675
|
+
const next_value = argv[index + 1];
|
|
1676
|
+
if (!next_value) {
|
|
1677
|
+
throw new Error("Missing value for --default-config-output-dir");
|
|
1678
|
+
}
|
|
1679
|
+
options.default_config_generation.output_dir = next_value;
|
|
1680
|
+
index += 1;
|
|
1681
|
+
continue;
|
|
1682
|
+
}
|
|
1683
|
+
if (token2 === "--default-config-overwrite") {
|
|
1684
|
+
options.default_config_generation.overwrite = true;
|
|
1685
|
+
continue;
|
|
1686
|
+
}
|
|
1663
1687
|
if (token2 === "--generate-tls-material") {
|
|
1664
1688
|
options.tls_generation.enabled = true;
|
|
1665
1689
|
continue;
|
|
@@ -1726,13 +1750,18 @@ var _DaemonCli = class _DaemonCli {
|
|
|
1726
1750
|
"nodenetproccalld",
|
|
1727
1751
|
"",
|
|
1728
1752
|
"Usage:",
|
|
1729
|
-
"
|
|
1753
|
+
" nodenetproccalld [options]",
|
|
1730
1754
|
"",
|
|
1731
1755
|
"Options:",
|
|
1732
1756
|
" --server-config <path> Path to server JSON5 config file.",
|
|
1733
1757
|
" Default: ./config/server.config.json5",
|
|
1734
1758
|
" --api-keys-config <path> Path to api keys JSON5 config file.",
|
|
1735
1759
|
" Default: ./config/api_keys.config.json5",
|
|
1760
|
+
" --generate-default-config Generate default JSON5 daemon config files and exit.",
|
|
1761
|
+
" --default-config-output-dir <path>",
|
|
1762
|
+
" Output directory for server/api-key config files.",
|
|
1763
|
+
" Default: ./config",
|
|
1764
|
+
" --default-config-overwrite Overwrite existing default config files.",
|
|
1736
1765
|
" --generate-tls-material Generate CA/server/client TLS material and exit.",
|
|
1737
1766
|
" --tls-output-dir <path> Output directory for generated TLS files.",
|
|
1738
1767
|
" Default: ./config/certs",
|
|
@@ -2074,10 +2103,160 @@ var _DaemonProcess = class _DaemonProcess {
|
|
|
2074
2103
|
__name(_DaemonProcess, "DaemonProcess");
|
|
2075
2104
|
var DaemonProcess = _DaemonProcess;
|
|
2076
2105
|
|
|
2077
|
-
// src/classes/
|
|
2078
|
-
var import_node_child_process = require("child_process");
|
|
2106
|
+
// src/classes/defaultconfiggenerator/DefaultConfigGenerator.class.ts
|
|
2079
2107
|
var import_node_fs2 = __toESM(require("fs"));
|
|
2080
2108
|
var import_node_path2 = __toESM(require("path"));
|
|
2109
|
+
var default_server_config_template = `{
|
|
2110
|
+
// Friendly name that clients can use in their own config maps.
|
|
2111
|
+
information: {
|
|
2112
|
+
server_name: 'daemon_server_1'
|
|
2113
|
+
},
|
|
2114
|
+
|
|
2115
|
+
// Bind target for tls.createServer.
|
|
2116
|
+
network: {
|
|
2117
|
+
bind_addr: '0.0.0.0',
|
|
2118
|
+
tcp_listen_port: 6767
|
|
2119
|
+
},
|
|
2120
|
+
|
|
2121
|
+
// PEM files are resolved relative to this config file unless absolute paths are used.
|
|
2122
|
+
tls_mtls: {
|
|
2123
|
+
key_file: './certs/server.key.pem',
|
|
2124
|
+
cert_file: './certs/server.cert.pem',
|
|
2125
|
+
ca_file: './certs/ca.cert.pem',
|
|
2126
|
+
// crl_file: './certs/ca.crl.pem',
|
|
2127
|
+
min_version: 'TLSv1.3',
|
|
2128
|
+
handshake_timeout_ms: 5000,
|
|
2129
|
+
request_timeout_ms: 15000,
|
|
2130
|
+
max_frame_bytes: 1048576
|
|
2131
|
+
},
|
|
2132
|
+
|
|
2133
|
+
workerprocedurecall: {
|
|
2134
|
+
count: 4,
|
|
2135
|
+
constructor_options: {
|
|
2136
|
+
call_timeout_ms: 30000,
|
|
2137
|
+
control_timeout_ms: 10000,
|
|
2138
|
+
restart_on_failure: true,
|
|
2139
|
+
max_restarts_per_worker: 6,
|
|
2140
|
+
max_pending_calls_per_worker: 500
|
|
2141
|
+
},
|
|
2142
|
+
start_options: {
|
|
2143
|
+
restart_base_delay_ms: 150,
|
|
2144
|
+
restart_max_delay_ms: 5000,
|
|
2145
|
+
restart_jitter_ms: 250
|
|
2146
|
+
}
|
|
2147
|
+
},
|
|
2148
|
+
|
|
2149
|
+
// Optional abuse controls from @opsimathically/networkprocedurecall.
|
|
2150
|
+
abuse_controls: {
|
|
2151
|
+
connection_controls: {
|
|
2152
|
+
max_concurrent_sockets: 1024,
|
|
2153
|
+
max_concurrent_handshakes: 256,
|
|
2154
|
+
max_unauthenticated_sessions: 256,
|
|
2155
|
+
per_ip_max_new_connections_per_window: 64,
|
|
2156
|
+
tls_handshake_timeout_ms: 5000,
|
|
2157
|
+
auth_message_timeout_ms: 5000
|
|
2158
|
+
},
|
|
2159
|
+
request_controls: {
|
|
2160
|
+
max_in_flight_requests_per_connection: 128,
|
|
2161
|
+
per_connection: {
|
|
2162
|
+
enabled: true,
|
|
2163
|
+
tokens_per_interval: 200,
|
|
2164
|
+
interval_ms: 1000,
|
|
2165
|
+
burst_tokens: 400
|
|
2166
|
+
},
|
|
2167
|
+
per_api_key: {
|
|
2168
|
+
enabled: true,
|
|
2169
|
+
tokens_per_interval: 1000,
|
|
2170
|
+
interval_ms: 1000,
|
|
2171
|
+
burst_tokens: 2000
|
|
2172
|
+
},
|
|
2173
|
+
per_ip: {
|
|
2174
|
+
enabled: true,
|
|
2175
|
+
tokens_per_interval: 500,
|
|
2176
|
+
interval_ms: 1000,
|
|
2177
|
+
burst_tokens: 1000
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
},
|
|
2181
|
+
|
|
2182
|
+
observability: {
|
|
2183
|
+
enable_console_log: true,
|
|
2184
|
+
log_worker_events: true,
|
|
2185
|
+
metrics_log_interval_ms: 30000
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
`;
|
|
2189
|
+
var default_api_keys_config_template = `{
|
|
2190
|
+
// API keys and privilege grants for auth_callback.
|
|
2191
|
+
api_keys: [
|
|
2192
|
+
{
|
|
2193
|
+
key_id: 'admin_key_1',
|
|
2194
|
+
api_key: 'replace_me_with_random_secret',
|
|
2195
|
+
privileges: ['all_privileges'],
|
|
2196
|
+
enabled: true,
|
|
2197
|
+
identity_constraints: {
|
|
2198
|
+
// Example: accept loopback clients only.
|
|
2199
|
+
remote_address_regex: '^(127\\\\.0\\\\.0\\\\.1|::1|::ffff:127\\\\.0\\\\.0\\\\.1)$'
|
|
2200
|
+
}
|
|
2201
|
+
},
|
|
2202
|
+
{
|
|
2203
|
+
key_id: 'invoke_only_key_1',
|
|
2204
|
+
api_key: 'replace_me_with_second_secret',
|
|
2205
|
+
privileges: ['invoke_functions'],
|
|
2206
|
+
enabled: false
|
|
2207
|
+
}
|
|
2208
|
+
]
|
|
2209
|
+
}
|
|
2210
|
+
`;
|
|
2211
|
+
function EnsureParentDirectory(params) {
|
|
2212
|
+
import_node_fs2.default.mkdirSync(import_node_path2.default.dirname(params.file_path), {
|
|
2213
|
+
recursive: true
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2216
|
+
__name(EnsureParentDirectory, "EnsureParentDirectory");
|
|
2217
|
+
function WriteFileIfAllowed(params) {
|
|
2218
|
+
if (!params.overwrite && import_node_fs2.default.existsSync(params.file_path)) {
|
|
2219
|
+
throw new Error(`Refusing to overwrite existing config "${params.file_path}". Use --default-config-overwrite to replace it.`);
|
|
2220
|
+
}
|
|
2221
|
+
EnsureParentDirectory({
|
|
2222
|
+
file_path: params.file_path
|
|
2223
|
+
});
|
|
2224
|
+
import_node_fs2.default.writeFileSync(params.file_path, params.content, "utf8");
|
|
2225
|
+
}
|
|
2226
|
+
__name(WriteFileIfAllowed, "WriteFileIfAllowed");
|
|
2227
|
+
var _DefaultConfigGenerator = class _DefaultConfigGenerator {
|
|
2228
|
+
generateDefaultConfig(params) {
|
|
2229
|
+
const options = params.default_config_generation_options;
|
|
2230
|
+
const output_dir = import_node_path2.default.resolve(process.cwd(), options.output_dir);
|
|
2231
|
+
const server_config_path = import_node_path2.default.join(output_dir, "server.config.json5");
|
|
2232
|
+
const api_keys_config_path = import_node_path2.default.join(output_dir, "api_keys.config.json5");
|
|
2233
|
+
import_node_fs2.default.mkdirSync(output_dir, {
|
|
2234
|
+
recursive: true
|
|
2235
|
+
});
|
|
2236
|
+
WriteFileIfAllowed({
|
|
2237
|
+
file_path: server_config_path,
|
|
2238
|
+
content: default_server_config_template,
|
|
2239
|
+
overwrite: options.overwrite
|
|
2240
|
+
});
|
|
2241
|
+
WriteFileIfAllowed({
|
|
2242
|
+
file_path: api_keys_config_path,
|
|
2243
|
+
content: default_api_keys_config_template,
|
|
2244
|
+
overwrite: options.overwrite
|
|
2245
|
+
});
|
|
2246
|
+
return {
|
|
2247
|
+
output_dir,
|
|
2248
|
+
server_config_path,
|
|
2249
|
+
api_keys_config_path
|
|
2250
|
+
};
|
|
2251
|
+
}
|
|
2252
|
+
};
|
|
2253
|
+
__name(_DefaultConfigGenerator, "DefaultConfigGenerator");
|
|
2254
|
+
var DefaultConfigGenerator = _DefaultConfigGenerator;
|
|
2255
|
+
|
|
2256
|
+
// src/classes/tlsmaterialgenerator/TlsMaterialGenerator.class.ts
|
|
2257
|
+
var import_node_child_process = require("child_process");
|
|
2258
|
+
var import_node_fs3 = __toESM(require("fs"));
|
|
2259
|
+
var import_node_path3 = __toESM(require("path"));
|
|
2081
2260
|
function EnsurePositiveInteger(params) {
|
|
2082
2261
|
if (!Number.isInteger(params.value) || params.value <= 0) {
|
|
2083
2262
|
throw new Error(`${params.label} must be a positive integer.`);
|
|
@@ -2085,13 +2264,13 @@ function EnsurePositiveInteger(params) {
|
|
|
2085
2264
|
}
|
|
2086
2265
|
__name(EnsurePositiveInteger, "EnsurePositiveInteger");
|
|
2087
2266
|
function MakeDirRecursive(params) {
|
|
2088
|
-
|
|
2267
|
+
import_node_fs3.default.mkdirSync(params.dir_path, {
|
|
2089
2268
|
recursive: true
|
|
2090
2269
|
});
|
|
2091
2270
|
}
|
|
2092
2271
|
__name(MakeDirRecursive, "MakeDirRecursive");
|
|
2093
2272
|
function WriteTextFile(params) {
|
|
2094
|
-
|
|
2273
|
+
import_node_fs3.default.writeFileSync(params.file_path, params.content, "utf8");
|
|
2095
2274
|
}
|
|
2096
2275
|
__name(WriteTextFile, "WriteTextFile");
|
|
2097
2276
|
var _TlsMaterialGenerator = class _TlsMaterialGenerator {
|
|
@@ -2101,7 +2280,7 @@ var _TlsMaterialGenerator = class _TlsMaterialGenerator {
|
|
|
2101
2280
|
value: options.valid_days,
|
|
2102
2281
|
label: "tls_generation.valid_days"
|
|
2103
2282
|
});
|
|
2104
|
-
const output_dir =
|
|
2283
|
+
const output_dir = import_node_path3.default.resolve(process.cwd(), options.output_dir);
|
|
2105
2284
|
MakeDirRecursive({
|
|
2106
2285
|
dir_path: output_dir
|
|
2107
2286
|
});
|
|
@@ -2160,17 +2339,17 @@ var _TlsMaterialGenerator = class _TlsMaterialGenerator {
|
|
|
2160
2339
|
}
|
|
2161
2340
|
buildTlsFileMap(params) {
|
|
2162
2341
|
return {
|
|
2163
|
-
ca_key_path:
|
|
2164
|
-
ca_cert_path:
|
|
2165
|
-
server_key_path:
|
|
2166
|
-
server_csr_path:
|
|
2167
|
-
server_cert_path:
|
|
2168
|
-
server_ext_path:
|
|
2169
|
-
client_key_path:
|
|
2170
|
-
client_csr_path:
|
|
2171
|
-
client_cert_path:
|
|
2172
|
-
client_ext_path:
|
|
2173
|
-
ca_serial_path:
|
|
2342
|
+
ca_key_path: import_node_path3.default.join(params.output_dir, "ca.key.pem"),
|
|
2343
|
+
ca_cert_path: import_node_path3.default.join(params.output_dir, "ca.cert.pem"),
|
|
2344
|
+
server_key_path: import_node_path3.default.join(params.output_dir, "server.key.pem"),
|
|
2345
|
+
server_csr_path: import_node_path3.default.join(params.output_dir, "server.csr.pem"),
|
|
2346
|
+
server_cert_path: import_node_path3.default.join(params.output_dir, "server.cert.pem"),
|
|
2347
|
+
server_ext_path: import_node_path3.default.join(params.output_dir, "server.ext"),
|
|
2348
|
+
client_key_path: import_node_path3.default.join(params.output_dir, "client.key.pem"),
|
|
2349
|
+
client_csr_path: import_node_path3.default.join(params.output_dir, "client.csr.pem"),
|
|
2350
|
+
client_cert_path: import_node_path3.default.join(params.output_dir, "client.cert.pem"),
|
|
2351
|
+
client_ext_path: import_node_path3.default.join(params.output_dir, "client.ext"),
|
|
2352
|
+
ca_serial_path: import_node_path3.default.join(params.output_dir, "ca.cert.srl")
|
|
2174
2353
|
};
|
|
2175
2354
|
}
|
|
2176
2355
|
assertTargetFilesAreWritable(params) {
|
|
@@ -2184,18 +2363,18 @@ var _TlsMaterialGenerator = class _TlsMaterialGenerator {
|
|
|
2184
2363
|
];
|
|
2185
2364
|
if (!params.overwrite) {
|
|
2186
2365
|
for (const target_path of target_paths) {
|
|
2187
|
-
if (
|
|
2366
|
+
if (import_node_fs3.default.existsSync(target_path)) {
|
|
2188
2367
|
throw new Error(`Refusing to overwrite existing file "${target_path}". Use --tls-overwrite to replace existing material.`);
|
|
2189
2368
|
}
|
|
2190
2369
|
}
|
|
2191
2370
|
return;
|
|
2192
2371
|
}
|
|
2193
2372
|
for (const target_path of target_paths) {
|
|
2194
|
-
|
|
2373
|
+
import_node_fs3.default.rmSync(target_path, {
|
|
2195
2374
|
force: true
|
|
2196
2375
|
});
|
|
2197
2376
|
}
|
|
2198
|
-
|
|
2377
|
+
import_node_fs3.default.rmSync(params.tls_files.ca_serial_path, {
|
|
2199
2378
|
force: true
|
|
2200
2379
|
});
|
|
2201
2380
|
}
|
|
@@ -2316,19 +2495,19 @@ var _TlsMaterialGenerator = class _TlsMaterialGenerator {
|
|
|
2316
2495
|
});
|
|
2317
2496
|
}
|
|
2318
2497
|
cleanupIntermediateFiles(params) {
|
|
2319
|
-
|
|
2498
|
+
import_node_fs3.default.rmSync(params.tls_files.server_csr_path, {
|
|
2320
2499
|
force: true
|
|
2321
2500
|
});
|
|
2322
|
-
|
|
2501
|
+
import_node_fs3.default.rmSync(params.tls_files.client_csr_path, {
|
|
2323
2502
|
force: true
|
|
2324
2503
|
});
|
|
2325
|
-
|
|
2504
|
+
import_node_fs3.default.rmSync(params.tls_files.server_ext_path, {
|
|
2326
2505
|
force: true
|
|
2327
2506
|
});
|
|
2328
|
-
|
|
2507
|
+
import_node_fs3.default.rmSync(params.tls_files.client_ext_path, {
|
|
2329
2508
|
force: true
|
|
2330
2509
|
});
|
|
2331
|
-
|
|
2510
|
+
import_node_fs3.default.rmSync(params.tls_files.ca_serial_path, {
|
|
2332
2511
|
force: true
|
|
2333
2512
|
});
|
|
2334
2513
|
}
|
|
@@ -2355,6 +2534,17 @@ async function StartDaemonFromCli() {
|
|
|
2355
2534
|
daemon_cli.printHelp();
|
|
2356
2535
|
return;
|
|
2357
2536
|
}
|
|
2537
|
+
if (cli_options.default_config_generation.enabled) {
|
|
2538
|
+
const default_config_generator = new DefaultConfigGenerator();
|
|
2539
|
+
const generated_default_config = default_config_generator.generateDefaultConfig({
|
|
2540
|
+
default_config_generation_options: cli_options.default_config_generation
|
|
2541
|
+
});
|
|
2542
|
+
console.log("Default config generated successfully.");
|
|
2543
|
+
console.log(`Output directory: ${generated_default_config.output_dir}`);
|
|
2544
|
+
console.log(`Server config: ${generated_default_config.server_config_path}`);
|
|
2545
|
+
console.log(`API keys config: ${generated_default_config.api_keys_config_path}`);
|
|
2546
|
+
return;
|
|
2547
|
+
}
|
|
2358
2548
|
if (cli_options.tls_generation.enabled) {
|
|
2359
2549
|
const tls_material_generator = new TlsMaterialGenerator();
|
|
2360
2550
|
const generated_tls_material = tls_material_generator.generateTlsMaterial({
|
|
@@ -2394,6 +2584,7 @@ if (require.main === module) {
|
|
|
2394
2584
|
ConfigValidator,
|
|
2395
2585
|
DaemonCli,
|
|
2396
2586
|
DaemonProcess,
|
|
2587
|
+
DefaultConfigGenerator,
|
|
2397
2588
|
NetworkProcedureCallDaemon,
|
|
2398
2589
|
TlsMaterialGenerator
|
|
2399
2590
|
});
|