spec-3nweb-server 1.7.12 → 1.7.13
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.
|
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.parseProcessArgv = void 0;
|
|
20
20
|
const default_confs_1 = require("../default-confs");
|
|
21
21
|
const run_cmd_1 = require("./run-cmd");
|
|
22
|
+
const show_sample_config_1 = require("./show-sample-config");
|
|
22
23
|
const signup_cmd_1 = require("./signup-cmd");
|
|
23
24
|
const utils_1 = require("./utils");
|
|
24
25
|
function mainUsage(execName) {
|
|
@@ -35,7 +36,8 @@ function mainUsage(execName) {
|
|
|
35
36
|
header: 'Available commands:',
|
|
36
37
|
content: [
|
|
37
38
|
run_cmd_1.runCmd,
|
|
38
|
-
signup_cmd_1.signupCmd
|
|
39
|
+
signup_cmd_1.signupCmd,
|
|
40
|
+
show_sample_config_1.showSampleConfigCmd
|
|
39
41
|
]
|
|
40
42
|
},
|
|
41
43
|
{
|
|
@@ -55,6 +57,11 @@ function parseProcessArgv() {
|
|
|
55
57
|
else if (args[0] === signup_cmd_1.signupCmd.name) {
|
|
56
58
|
return (0, signup_cmd_1.parseSignupArgs)(args.slice(1), default_confs_1.EXECUTABLE_NAME);
|
|
57
59
|
}
|
|
60
|
+
else if (args[0] === show_sample_config_1.showSampleConfigCmd.name) {
|
|
61
|
+
return { showSampleConfig: {
|
|
62
|
+
txtToDisplay: show_sample_config_1.sampleConfig, exitStatus: 0
|
|
63
|
+
} };
|
|
64
|
+
}
|
|
58
65
|
else {
|
|
59
66
|
const opts = (0, utils_1.parseArgv)(args, [utils_1.helpOpt], { partial: true });
|
|
60
67
|
if (opts.help) {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CommandDef } from "./utils";
|
|
2
|
+
export declare const showSampleConfigCmd: CommandDef<'show-sample-config'>;
|
|
3
|
+
export declare const sampleConfig = "\n# This is a sample configuration yaml file.\n# Uncomment and set required values.\n# Default path of this file is /etc/3nweb/conf.yaml\n\n# Uncomment to enable service\nenabledServices:\n # asmail: true\n # storage: true\n # mailerId: true\n\n# Data root folder. Set non-default value, if required.\n# rootFolder: /var/3nweb\n\n# Customize domain at which clients reach this server from an outside.\n# This value is used by users' MailerId-based login: assertion challenges\n# cryptographically imprint this domain to assure client that there is no\n# missuse.\ndomain: service-for.example.com\n\n# If MailerId provider service is enabled, this is its configuration\nmailerId:\n certs: /etc/3nweb/mailerid/certs\n\n# Customize servicesConnect before starting this server.\nservicesConnect:\n\n port: 7070\n # Hostname allows to restrict on which address service is listening for incoming connections\n # hostname: \"1.2.3.4\"\n\n # Uncomment path to Let's Encrypt folder, if it is used. This implicitly tells\n # server to HTTPS with given certificates.\n # letsencrypt: /etc/letsencrypt/live/service-for.example.com\n\n # By default HTTPS service reloads when certificates change. Skip, if required.\n # skipReloadOnCertsChange: false\n\n # Set TLS cert and key to do HTTPS. Use either this, or letsencrypt, but not both.\n # sslOpts: {\n # It is Node's https.ServerOptions. Follow https://nodejs.org/docs/latest/api/https.html\n # }\n\n# Configuration for signup service that creates new accounts on this server.\n# Comment out to disable signup service completely.\n# Note that signup cli commands should be used to create token, without which\n# signup doesn't happen, unless a no-token configuration file is provided.\nsignup: {\n # noTokenFile: /some/path/to/json\n}\n";
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2025 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.sampleConfig = exports.showSampleConfigCmd = void 0;
|
|
20
|
+
exports.showSampleConfigCmd = {
|
|
21
|
+
name: 'show-sample-config',
|
|
22
|
+
summary: 'prints out a template configuration yaml file with comments'
|
|
23
|
+
};
|
|
24
|
+
exports.sampleConfig = `
|
|
25
|
+
# This is a sample configuration yaml file.
|
|
26
|
+
# Uncomment and set required values.
|
|
27
|
+
# Default path of this file is /etc/3nweb/conf.yaml
|
|
28
|
+
|
|
29
|
+
# Uncomment to enable service
|
|
30
|
+
enabledServices:
|
|
31
|
+
# asmail: true
|
|
32
|
+
# storage: true
|
|
33
|
+
# mailerId: true
|
|
34
|
+
|
|
35
|
+
# Data root folder. Set non-default value, if required.
|
|
36
|
+
# rootFolder: /var/3nweb
|
|
37
|
+
|
|
38
|
+
# Customize domain at which clients reach this server from an outside.
|
|
39
|
+
# This value is used by users' MailerId-based login: assertion challenges
|
|
40
|
+
# cryptographically imprint this domain to assure client that there is no
|
|
41
|
+
# missuse.
|
|
42
|
+
domain: service-for.example.com
|
|
43
|
+
|
|
44
|
+
# If MailerId provider service is enabled, this is its configuration
|
|
45
|
+
mailerId:
|
|
46
|
+
certs: /etc/3nweb/mailerid/certs
|
|
47
|
+
|
|
48
|
+
# Customize servicesConnect before starting this server.
|
|
49
|
+
servicesConnect:
|
|
50
|
+
|
|
51
|
+
port: 7070
|
|
52
|
+
# Hostname allows to restrict on which address service is listening for incoming connections
|
|
53
|
+
# hostname: "1.2.3.4"
|
|
54
|
+
|
|
55
|
+
# Uncomment path to Let's Encrypt folder, if it is used. This implicitly tells
|
|
56
|
+
# server to HTTPS with given certificates.
|
|
57
|
+
# letsencrypt: /etc/letsencrypt/live/service-for.example.com
|
|
58
|
+
|
|
59
|
+
# By default HTTPS service reloads when certificates change. Skip, if required.
|
|
60
|
+
# skipReloadOnCertsChange: false
|
|
61
|
+
|
|
62
|
+
# Set TLS cert and key to do HTTPS. Use either this, or letsencrypt, but not both.
|
|
63
|
+
# sslOpts: {
|
|
64
|
+
# It is Node's https.ServerOptions. Follow https://nodejs.org/docs/latest/api/https.html
|
|
65
|
+
# }
|
|
66
|
+
|
|
67
|
+
# Configuration for signup service that creates new accounts on this server.
|
|
68
|
+
# Comment out to disable signup service completely.
|
|
69
|
+
# Note that signup cli commands should be used to create token, without which
|
|
70
|
+
# signup doesn't happen, unless a no-token configuration file is provided.
|
|
71
|
+
signup: {
|
|
72
|
+
# noTokenFile: /some/path/to/json
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
Object.freeze(exports);
|
package/build/main.js
CHANGED
|
@@ -23,9 +23,10 @@ const letsencrypt_1 = require("./config/letsencrypt");
|
|
|
23
23
|
const lib_1 = require("./lib");
|
|
24
24
|
const signup_1 = require("./config/signup");
|
|
25
25
|
const default_confs_1 = require("./config/default-confs");
|
|
26
|
+
const file_1 = require("./lib-common/exceptions/file");
|
|
26
27
|
async function run(conf) {
|
|
27
28
|
if (!conf.servicesConnect) {
|
|
28
|
-
console.error(
|
|
29
|
+
console.error(`❌ No connection settings found in configuration.`);
|
|
29
30
|
process.exit(-1);
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
@@ -41,7 +42,7 @@ async function run(conf) {
|
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
44
|
try {
|
|
44
|
-
console.log(
|
|
45
|
+
console.log(`🏁 Stopping app ...`);
|
|
45
46
|
await app.stop();
|
|
46
47
|
console.log(`app has stopped.`);
|
|
47
48
|
}
|
|
@@ -55,11 +56,11 @@ async function run(conf) {
|
|
|
55
56
|
}
|
|
56
57
|
async function startAppWithTLS(sslOpts, port, hostname) {
|
|
57
58
|
await app.start(sslOpts, port, hostname);
|
|
58
|
-
console.log(
|
|
59
|
+
console.log(`🚀 Started 3NWeb server on port ${port},${hostname ? ` hostname ${hostname},` : ''} with TLS.`);
|
|
59
60
|
}
|
|
60
61
|
async function startAppWithoutTLS(port, hostname) {
|
|
61
62
|
await app.start(undefined, port, hostname);
|
|
62
|
-
console.log(
|
|
63
|
+
console.log(`🚀 Started 3NWeb server on port ${port},${hostname ? ` hostname ${hostname},` : ''} without TLS, and requiring TLS reverse proxy infront.`);
|
|
63
64
|
}
|
|
64
65
|
try {
|
|
65
66
|
app = createApp(conf);
|
|
@@ -69,7 +70,7 @@ async function run(conf) {
|
|
|
69
70
|
await startAppWithTLS(tls.sslOpts, port, hostname);
|
|
70
71
|
if (!skipReloadOnCertsChange) {
|
|
71
72
|
tls.onCertsUpdate(async (newOpts, originalOpts) => {
|
|
72
|
-
console.log(
|
|
73
|
+
console.log(`🗘 Reloading server app server on TLS certificates change`);
|
|
73
74
|
try {
|
|
74
75
|
await stopProcess();
|
|
75
76
|
app = createApp(conf);
|
|
@@ -77,7 +78,7 @@ async function run(conf) {
|
|
|
77
78
|
}
|
|
78
79
|
catch (err) {
|
|
79
80
|
console.error(err);
|
|
80
|
-
console.log(
|
|
81
|
+
console.log(`⚠️ Failed to reload with new TLS certs. Attempting to load with original ones.`);
|
|
81
82
|
try {
|
|
82
83
|
await stopProcess();
|
|
83
84
|
app = createApp(conf);
|
|
@@ -118,7 +119,16 @@ function assembleConfig(configPath) {
|
|
|
118
119
|
configPath = default_confs_1.DEFAULT_CONFIG_PATH;
|
|
119
120
|
console.log(`Looking for configuration in default location: ${configPath}`);
|
|
120
121
|
}
|
|
121
|
-
|
|
122
|
+
try {
|
|
123
|
+
return (0, from_yaml_1.readYamlConfFile)(configPath);
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
if (err.code === file_1.Code.notFound) {
|
|
127
|
+
console.error(`❌ Configuration file ${configPath} is not found.`);
|
|
128
|
+
process.exit(-2);
|
|
129
|
+
}
|
|
130
|
+
throw err;
|
|
131
|
+
}
|
|
122
132
|
}
|
|
123
133
|
async function displaySignupInfo(conf) {
|
|
124
134
|
if (!conf.signup) {
|
|
@@ -223,12 +233,21 @@ else if (cmd.signupCmd) {
|
|
|
223
233
|
}
|
|
224
234
|
}
|
|
225
235
|
else {
|
|
226
|
-
|
|
236
|
+
showUsage({
|
|
237
|
+
txtToDisplay: `❌ No recognized subcommand given to signup module`,
|
|
238
|
+
exitStatus: -1
|
|
239
|
+
});
|
|
227
240
|
}
|
|
228
241
|
}
|
|
242
|
+
else if (cmd.showSampleConfig) {
|
|
243
|
+
showUsage(cmd.showSampleConfig);
|
|
244
|
+
}
|
|
229
245
|
else if (cmd.showUsage) {
|
|
230
246
|
showUsage(cmd.showUsage);
|
|
231
247
|
}
|
|
232
248
|
else {
|
|
233
|
-
|
|
249
|
+
showUsage({
|
|
250
|
+
txtToDisplay: `❌ No recognized command given`,
|
|
251
|
+
exitStatus: -1
|
|
252
|
+
});
|
|
234
253
|
}
|