spec-3nweb-server 1.6.4 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/build/3nstorage/resources/sessions.d.ts +2 -2
- package/build/3nstorage/resources/store.d.ts +1 -1
- package/build/3nstorage/resources/users.d.ts +15 -15
- package/build/admin/admin-app.d.ts +1 -1
- package/build/admin/admin-app.js +4 -1
- package/build/admin/resources/users.d.ts +3 -3
- package/build/admin/signup-tokens.d.ts +1 -1
- package/build/asmail/resources/delivery-sessions.d.ts +3 -3
- package/build/asmail/resources/inbox.d.ts +9 -9
- package/build/asmail/resources/recipients.d.ts +18 -18
- package/build/asmail/resources/sessions.d.ts +2 -2
- package/build/asmail/routes/delivery/sender-authorization.d.ts +1 -1
- package/build/asmail/routes/delivery/start-session.d.ts +1 -1
- package/build/config/cli/index.d.ts +9 -0
- package/build/config/cli/index.js +68 -0
- package/build/config/cli/run-cmd.d.ts +10 -0
- package/build/config/cli/run-cmd.js +69 -0
- package/build/config/cli/signup-cmd.d.ts +17 -0
- package/build/config/cli/signup-cmd.js +194 -0
- package/build/config/cli/user-cmd.d.ts +9 -0
- package/build/config/cli/user-cmd.js +55 -0
- package/build/config/cli/utils.d.ts +45 -0
- package/build/config/cli/utils.js +52 -0
- package/build/config/from-yaml.d.ts +2 -0
- package/build/config/from-yaml.js +28 -0
- package/build/config/letsencrypt.d.ts +7 -0
- package/build/config/letsencrypt.js +62 -0
- package/build/config/signup.d.ts +15 -0
- package/build/config/signup.js +133 -0
- package/build/lib-common/byte-streaming/common.d.ts +2 -2
- package/build/lib-common/byte-streaming/common.js +5 -5
- package/build/lib-common/exceptions/file.d.ts +1 -1
- package/build/lib-common/ipc/generic-ipc.d.ts +7 -7
- package/build/lib-common/ipc/generic-ipc.js +6 -6
- package/build/lib-common/objs-on-disk/file-layout.d.ts +4 -4
- package/build/lib-common/objs-on-disk/utils.d.ts +3 -3
- package/build/lib-common/processes.d.ts +1 -1
- package/build/lib-common/service-api/ipc-api.d.ts +6 -6
- package/build/lib-common/service-api/web-socket-base.d.ts +1 -1
- package/build/lib-server/middleware/error-handler.d.ts +1 -1
- package/build/lib-server/resources/dns.d.ts +1 -1
- package/build/lib-server/resources/dns.js +48 -10
- package/build/lib-server/resources/sessions.d.ts +2 -2
- package/build/lib-server/resources/user-files.d.ts +1 -1
- package/build/lib-server/routes/pub-key-login/start-exchange.d.ts +4 -4
- package/build/lib-server/routes/sessions/mid-auth.d.ts +1 -1
- package/build/lib-server/routes/sessions/start.d.ts +4 -4
- package/build/lib-server/web-sockets/app.d.ts +1 -1
- package/build/lib-server/web-sockets/app.js +6 -6
- package/build/lib-server/web-sockets/server-events.d.ts +1 -1
- package/build/lib.d.ts +1 -1
- package/build/lib.js +3 -5
- package/build/mailerId/resources/certifier.d.ts +1 -1
- package/build/mailerId/resources/sessions.d.ts +1 -1
- package/build/main.js +196 -45
- package/build/mock/node-child-ipc.d.ts +2 -2
- package/build/mock/run-in-proc.js +6 -3
- package/build/services.d.ts +4 -2
- package/build/services.js +15 -6
- package/package.json +16 -3
- package/postinstall.js +25 -0
- package/build/run-config.d.ts +0 -10
- package/build/run-config.js +0 -146
- package/build/run.d.ts +0 -1
- package/build/run.js +0 -45
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2020, 2023 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -37,8 +37,11 @@ function setTestCertsAndDNS(domains, thisSrvLoc) {
|
|
|
37
37
|
for (const domain of domains) {
|
|
38
38
|
dnsRecs[domain] = [
|
|
39
39
|
['asmail', '=', `${thisSrvLoc}/asmail`],
|
|
40
|
-
[
|
|
41
|
-
|
|
40
|
+
[
|
|
41
|
+
'mailerid=', `${thisSrvLoc}/mailerid`,
|
|
42
|
+
`3nstorage=${thisSrvLoc}/3nstorage`
|
|
43
|
+
] // two 3NWeb records in one DNS TXT record
|
|
44
|
+
// XXX add other life-like records
|
|
42
45
|
];
|
|
43
46
|
}
|
|
44
47
|
const dnsMock = new dns_1.DNSMock(dnsRecs);
|
package/build/services.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface Configurations {
|
|
|
12
12
|
hostname?: string;
|
|
13
13
|
port: number;
|
|
14
14
|
sslOpts?: https.ServerOptions;
|
|
15
|
+
letsencrypt?: string;
|
|
16
|
+
skipReloadOnCertsChange?: boolean;
|
|
15
17
|
};
|
|
16
18
|
rootFolder: string;
|
|
17
19
|
domain: string;
|
|
@@ -22,5 +24,5 @@ export interface Configurations {
|
|
|
22
24
|
noTokenFile?: string;
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
|
-
export declare function servicesApp(conf: Configurations, errLogger?: ErrLogger | 'console'): AppWithWSs;
|
|
26
|
-
export declare function adminApp(conf: Configurations, errLogger?: ErrLogger | 'console'): AppWithWSs;
|
|
27
|
+
export declare function servicesApp(conf: Configurations, errLogger?: ErrLogger | 'console', logSetup?: 'console'): AppWithWSs;
|
|
28
|
+
export declare function adminApp(conf: Configurations, errLogger?: ErrLogger | 'console', logSetup?: 'console'): AppWithWSs;
|
package/build/services.js
CHANGED
|
@@ -24,29 +24,38 @@ const asmail_app_1 = require("./asmail/asmail-app");
|
|
|
24
24
|
const _3nstorage_app_1 = require("./3nstorage/3nstorage-app");
|
|
25
25
|
const admin_app_1 = require("./admin/admin-app");
|
|
26
26
|
const error_handler_1 = require("./lib-server/middleware/error-handler");
|
|
27
|
-
function servicesApp(conf, errLogger) {
|
|
27
|
+
function servicesApp(conf, errLogger, logSetup) {
|
|
28
28
|
if (!conf.enabledServices || (typeof conf.enabledServices !== 'object')) {
|
|
29
29
|
throw new Error('Missing enabled-services sections in confs.');
|
|
30
30
|
}
|
|
31
31
|
const app = new app_1.AppWithWSs();
|
|
32
32
|
const midAuthorizer = (0, mailerid_authorizer_1.validator)(); // share, allowing for caching of certs
|
|
33
33
|
if (conf.enabledServices.mailerId) {
|
|
34
|
-
app.http.use('/mailerid', (0, mailerId_app_1.makeApp)(conf.rootFolder, conf.domain, conf.mailerId.certs, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('
|
|
34
|
+
app.http.use('/mailerid', (0, mailerId_app_1.makeApp)(conf.rootFolder, conf.domain, conf.mailerId.certs, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('MailerId') : errLogger));
|
|
35
|
+
if (logSetup === 'console') {
|
|
36
|
+
console.log(`Enabled MailerId service with provider domain ${conf.domain}`);
|
|
37
|
+
}
|
|
35
38
|
}
|
|
36
39
|
if (conf.enabledServices.asmail) {
|
|
37
|
-
app.use('/asmail', (0, asmail_app_1.makeApp)(conf.rootFolder, conf.domain, midAuthorizer, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('
|
|
40
|
+
app.use('/asmail', (0, asmail_app_1.makeApp)(conf.rootFolder, conf.domain, midAuthorizer, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('ASMail') : errLogger));
|
|
41
|
+
if (logSetup === 'console') {
|
|
42
|
+
console.log(`Enabled ASMail service with provider domain ${conf.domain}`);
|
|
43
|
+
}
|
|
38
44
|
}
|
|
39
45
|
if (conf.enabledServices.storage) {
|
|
40
|
-
app.use('/3nstorage', (0, _3nstorage_app_1.makeApp)(conf.rootFolder, conf.domain, midAuthorizer, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('
|
|
46
|
+
app.use('/3nstorage', (0, _3nstorage_app_1.makeApp)(conf.rootFolder, conf.domain, midAuthorizer, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('3NStorage') : errLogger));
|
|
47
|
+
if (logSetup === 'console') {
|
|
48
|
+
console.log(`Enabled 3NStorage service with provider domain ${conf.domain}`);
|
|
49
|
+
}
|
|
41
50
|
}
|
|
42
51
|
return app;
|
|
43
52
|
}
|
|
44
53
|
exports.servicesApp = servicesApp;
|
|
45
|
-
function adminApp(conf, errLogger) {
|
|
54
|
+
function adminApp(conf, errLogger, logSetup) {
|
|
46
55
|
if (errLogger === 'console') {
|
|
47
56
|
errLogger = (0, error_handler_1.makeErrLoggerToConsole)('3NWeb server admin');
|
|
48
57
|
}
|
|
49
|
-
return new app_1.AppWithWSs((0, admin_app_1.makeApp)(conf, errLogger));
|
|
58
|
+
return new app_1.AppWithWSs((0, admin_app_1.makeApp)(conf, errLogger, logSetup));
|
|
50
59
|
}
|
|
51
60
|
exports.adminApp = adminApp;
|
|
52
61
|
Object.freeze(exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spec-3nweb-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "3NWeb spec server.",
|
|
5
5
|
"main": "build/lib.js",
|
|
6
6
|
"types": "build/lib.d.ts",
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
"test": "node build/tests/jasmine.js",
|
|
10
10
|
"clear-for-packing": "npm prune --production && bash -c \"rm -rf build/mock build/tests 'node_modules/ecma-nacl/c sources'\"",
|
|
11
11
|
"clear-for-packing-mock": "npm prune --production && bash -c \"rm -rf build/tests 'node_modules/ecma-nacl/c sources'\"",
|
|
12
|
-
"pack
|
|
12
|
+
"pack": "pkg --config package.json build/main.js",
|
|
13
|
+
"pack-deb": "npm run pack && bash packing/create-deb.sh",
|
|
14
|
+
"postinstall": "node -e \"try{require('./postinstall')}catch(e){}\""
|
|
13
15
|
},
|
|
14
16
|
"repository": {
|
|
15
17
|
"type": "git",
|
|
@@ -29,8 +31,12 @@
|
|
|
29
31
|
},
|
|
30
32
|
"license": "GPL-3.0",
|
|
31
33
|
"dependencies": {
|
|
34
|
+
"command-line-args": "^5.2.1",
|
|
35
|
+
"command-line-usage": "^7.0.1",
|
|
32
36
|
"ecma-nacl": "^2.4.0",
|
|
33
|
-
"express": "^4.
|
|
37
|
+
"express": "^4.19.2",
|
|
38
|
+
"js-yaml": "^4.1.0",
|
|
39
|
+
"prompts": "^2.4.2",
|
|
34
40
|
"punycode": "^2.1.1",
|
|
35
41
|
"ws": "^7.4.6",
|
|
36
42
|
"xsp-files": "^2.0.0"
|
|
@@ -41,9 +47,16 @@
|
|
|
41
47
|
"@types/node": "^16.11.7",
|
|
42
48
|
"@types/ws": "^4.0.0",
|
|
43
49
|
"jasmine": "^3.9.0",
|
|
50
|
+
"pkg": "^5.8.1",
|
|
44
51
|
"rxjs": "^5.3.0",
|
|
45
52
|
"typescript": "^4.7.4",
|
|
46
53
|
"xhr2": "^0.1.3"
|
|
47
54
|
},
|
|
55
|
+
"pkg": {
|
|
56
|
+
"targets": [
|
|
57
|
+
"node18-linux-x64"
|
|
58
|
+
],
|
|
59
|
+
"outputPath": "dist"
|
|
60
|
+
},
|
|
48
61
|
"readmeFilename": "README.md"
|
|
49
62
|
}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
function is(it) {
|
|
3
|
+
return !!it && it !== '0' && it !== 'false';
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const env = process.env;
|
|
7
|
+
|
|
8
|
+
const ADBLOCK = is(env.ADBLOCK);
|
|
9
|
+
const SILENT = ['silent', 'error', 'warn'].includes(env.npm_config_loglevel) ;
|
|
10
|
+
const COLOR = is(env.npm_config_color);
|
|
11
|
+
|
|
12
|
+
const BANNER = `\u001B[96mThank you for using spec-server (\u001B[94m https://github.com/3nsoft/spec-server.git \u001B[96m) of 3NWeb uitlity services. This server is developed together with defining 3NWeb protocols by PrivacySafe\u001B[0m
|
|
13
|
+
|
|
14
|
+
\u001B[96mThe project needs your help! Please consider supporting PrivacySafe on Open Collective: \u001B[0m
|
|
15
|
+
\u001B[96m>\u001B[94m https://opencollective.com/privacysafe \u001B[0m
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
function isBannerRequired() {
|
|
19
|
+
if (ADBLOCK || SILENT) { return false; }
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (isBannerRequired()) {
|
|
24
|
+
console.log(COLOR ? BANNER : BANNER.replace(/\u001B\[\d+m/g, ''));
|
|
25
|
+
}
|
package/build/run-config.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Configurations } from "./services";
|
|
3
|
-
import { ServerOptions } from "https";
|
|
4
|
-
export declare function getConfsFromEnv(): Configurations;
|
|
5
|
-
export declare function getBindParamsFromEnv(): {
|
|
6
|
-
address?: string;
|
|
7
|
-
port: number;
|
|
8
|
-
sslOpts?: ServerOptions;
|
|
9
|
-
};
|
|
10
|
-
export declare function addSingleUserSignup(rootFolder: string, userId: string): Promise<string>;
|
package/build/run-config.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (C) 2019 - 2020 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.addSingleUserSignup = exports.getBindParamsFromEnv = exports.getConfsFromEnv = void 0;
|
|
20
|
-
const async_fs_node_1 = require("./lib-common/async-fs-node");
|
|
21
|
-
const path_1 = require("path");
|
|
22
|
-
const fs_1 = require("fs");
|
|
23
|
-
const signup_tokens_1 = require("./admin/signup-tokens");
|
|
24
|
-
const server_data_folders_1 = require("./lib-server/resources/server-data-folders");
|
|
25
|
-
const DOMAIN_VAR = 'W3N_DOMAIN';
|
|
26
|
-
const DATA_DIR_VAR = 'W3N_DATA_DIR';
|
|
27
|
-
const NO_TOKENS_FILE = 'NO_TOKENS_FILE';
|
|
28
|
-
const CERTS_FILE_VAR = 'W3N_MID_CERTS_FILE';
|
|
29
|
-
const ADDRESS_VAR = 'W3N_SERICE_ADDRESS';
|
|
30
|
-
const PORT_VAR = 'W3N_SERICE_PORT';
|
|
31
|
-
const TLS_KEY_VAR = 'W3N_SERICE_TLS_KEY';
|
|
32
|
-
const TLS_CERT_VAR = 'W3N_SERICE_TLS_CERT';
|
|
33
|
-
const TLS_PFX_VAR = 'W3N_SERICE_TLS_PFX';
|
|
34
|
-
const DEFAULT_PORT = 8080;
|
|
35
|
-
function makeConf(domain, rootFolder, midCertsFile, noTokenFile) {
|
|
36
|
-
return {
|
|
37
|
-
enabledServices: {
|
|
38
|
-
asmail: true,
|
|
39
|
-
storage: true,
|
|
40
|
-
mailerId: true
|
|
41
|
-
},
|
|
42
|
-
rootFolder,
|
|
43
|
-
domain,
|
|
44
|
-
mailerId: {
|
|
45
|
-
certs: midCertsFile
|
|
46
|
-
},
|
|
47
|
-
signup: {
|
|
48
|
-
noTokenFile
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function getConfsFromEnv() {
|
|
53
|
-
const domain = process.env[DOMAIN_VAR];
|
|
54
|
-
if (!domain) {
|
|
55
|
-
throw new Error(`Environment variable ${DOMAIN_VAR} is not set with domain name, for which 3NWeb processes are served.`);
|
|
56
|
-
}
|
|
57
|
-
let dataDir = process.env[DATA_DIR_VAR];
|
|
58
|
-
if (!dataDir) {
|
|
59
|
-
dataDir = '/var/local/3nweb';
|
|
60
|
-
}
|
|
61
|
-
// Make data folders
|
|
62
|
-
ensureFolderPresence(dataDir, true);
|
|
63
|
-
dataDir = (0, fs_1.realpathSync)(dataDir);
|
|
64
|
-
let midCerts = process.env[CERTS_FILE_VAR];
|
|
65
|
-
if (!midCerts) {
|
|
66
|
-
midCerts = (0, path_1.join)(dataDir, 'mid-certs.json');
|
|
67
|
-
}
|
|
68
|
-
const noTokenFile = process.env[NO_TOKENS_FILE];
|
|
69
|
-
return makeConf(domain, dataDir, midCerts, noTokenFile);
|
|
70
|
-
}
|
|
71
|
-
exports.getConfsFromEnv = getConfsFromEnv;
|
|
72
|
-
function ensureFolderPresence(path, doLog) {
|
|
73
|
-
if ((0, async_fs_node_1.existsFolderSync)(path)) {
|
|
74
|
-
if (doLog) {
|
|
75
|
-
console.log(`Using existing data folder ${path}`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
(0, fs_1.mkdirSync)(path);
|
|
80
|
-
if (doLog) {
|
|
81
|
-
console.log(`Created ${(0, fs_1.realpathSync)(path)}`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function getBindParamsFromEnv() {
|
|
86
|
-
const address = process.env[ADDRESS_VAR];
|
|
87
|
-
const portStr = process.env[PORT_VAR];
|
|
88
|
-
let port;
|
|
89
|
-
if (portStr) {
|
|
90
|
-
port = Number.parseInt(portStr);
|
|
91
|
-
if (!Number.isInteger(port)) {
|
|
92
|
-
port = DEFAULT_PORT;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
port = DEFAULT_PORT;
|
|
97
|
-
}
|
|
98
|
-
const sslOpts = getTLSParamsFromEnv();
|
|
99
|
-
return { address, port, sslOpts };
|
|
100
|
-
}
|
|
101
|
-
exports.getBindParamsFromEnv = getBindParamsFromEnv;
|
|
102
|
-
function getTLSParamsFromEnv() {
|
|
103
|
-
const pfx = process.env[TLS_PFX_VAR];
|
|
104
|
-
if (pfx) {
|
|
105
|
-
return { pfx };
|
|
106
|
-
}
|
|
107
|
-
const cert = process.env[TLS_CERT_VAR];
|
|
108
|
-
const key = process.env[TLS_KEY_VAR];
|
|
109
|
-
if (cert && key) {
|
|
110
|
-
return { cert, key };
|
|
111
|
-
}
|
|
112
|
-
else if (!cert && !key) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
throw new Error(`Both ${TLS_CERT_VAR} and ${TLS_KEY_VAR} environment parameters should be present, but one is missing.`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
async function addSingleUserSignup(rootFolder, userId) {
|
|
120
|
-
const token = await (0, signup_tokens_1.generateToken)();
|
|
121
|
-
const ctx = (0, signup_tokens_1.makeSingleUserSignupCtx)(token, userId);
|
|
122
|
-
const fPath = (0, signup_tokens_1.tokenPath)(rootFolder, token);
|
|
123
|
-
try {
|
|
124
|
-
await (0, async_fs_node_1.writeFile)(fPath, JSON.stringify(ctx), { encoding: 'utf8', flag: 'wx' });
|
|
125
|
-
return token;
|
|
126
|
-
}
|
|
127
|
-
catch (exc) {
|
|
128
|
-
if (exc.alreadyExists) {
|
|
129
|
-
return addSingleUserSignup(rootFolder, userId);
|
|
130
|
-
}
|
|
131
|
-
else if (exc.notFound) {
|
|
132
|
-
await (0, async_fs_node_1.mkdir)((0, server_data_folders_1.tokensInRootFolder)(rootFolder))
|
|
133
|
-
.catch((exc) => {
|
|
134
|
-
if (!exc.alreadyExists) {
|
|
135
|
-
throw exc;
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
return addSingleUserSignup(rootFolder, userId);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
throw exc;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
exports.addSingleUserSignup = addSingleUserSignup;
|
|
146
|
-
Object.freeze(exports);
|
package/build/run.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/build/run.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (C) 2015 - 2019 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
|
-
const lib_1 = require("./lib");
|
|
20
|
-
(async () => {
|
|
21
|
-
let app = undefined;
|
|
22
|
-
async function stopProcess() {
|
|
23
|
-
if (!app) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
app.stop().then(err => console.log(err));
|
|
27
|
-
app = undefined;
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
const conf = (0, lib_1.getConfsFromEnv)();
|
|
31
|
-
app = new lib_1.AppWithWSs();
|
|
32
|
-
app.use((0, lib_1.servicesApp)(conf));
|
|
33
|
-
app.use((0, lib_1.adminApp)(conf));
|
|
34
|
-
const { address, port, sslOpts } = (0, lib_1.getBindParamsFromEnv)();
|
|
35
|
-
await app.start(sslOpts, port, address);
|
|
36
|
-
console.log(`Started 3NWeb server at address ${address}, port ${port}, ${sslOpts ? 'via TLS' : 'without TLS, and requiring TLS reverse proxy infront.'}`);
|
|
37
|
-
process.on('SIGINT', stopProcess);
|
|
38
|
-
process.on('SIGTERM', stopProcess);
|
|
39
|
-
}
|
|
40
|
-
catch (err) {
|
|
41
|
-
stopProcess();
|
|
42
|
-
console.error(err);
|
|
43
|
-
process.exit(-500);
|
|
44
|
-
}
|
|
45
|
-
})();
|