spec-3nweb-server 1.6.3 → 1.7.0
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/3nstorage-app.d.ts +2 -1
- package/build/3nstorage/3nstorage-app.js +2 -7
- package/build/admin/admin-app.d.ts +2 -1
- package/build/admin/admin-app.js +5 -2
- package/build/asmail/asmail-app.d.ts +2 -1
- package/build/asmail/asmail-app.js +2 -7
- 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/{run-config.d.ts → config/from-env.d.ts} +1 -2
- package/build/{run-config.js → config/from-env.js} +2 -31
- 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 +132 -0
- package/build/lib-server/middleware/error-handler.d.ts +1 -0
- package/build/lib-server/middleware/error-handler.js +11 -2
- package/build/lib-server/resources/dns.js +48 -10
- package/build/lib.d.ts +6 -4
- package/build/lib.js +13 -4
- package/build/mailerId/mailerId-app.d.ts +2 -1
- package/build/mailerId/mailerId-app.js +2 -2
- package/build/main.js +199 -48
- package/build/mock/run-in-proc.js +6 -3
- package/build/run.js +19 -9
- package/build/services.d.ts +5 -2
- package/build/services.js +19 -6
- package/package.json +15 -2
- package/postinstall.js +25 -0
|
@@ -16,12 +16,10 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.
|
|
20
|
-
const async_fs_node_1 = require("
|
|
19
|
+
exports.getBindParamsFromEnv = exports.getConfsFromEnv = void 0;
|
|
20
|
+
const async_fs_node_1 = require("../lib-common/async-fs-node");
|
|
21
21
|
const path_1 = require("path");
|
|
22
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
23
|
const DOMAIN_VAR = 'W3N_DOMAIN';
|
|
26
24
|
const DATA_DIR_VAR = 'W3N_DATA_DIR';
|
|
27
25
|
const NO_TOKENS_FILE = 'NO_TOKENS_FILE';
|
|
@@ -116,31 +114,4 @@ function getTLSParamsFromEnv() {
|
|
|
116
114
|
throw new Error(`Both ${TLS_CERT_VAR} and ${TLS_KEY_VAR} environment parameters should be present, but one is missing.`);
|
|
117
115
|
}
|
|
118
116
|
}
|
|
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
117
|
Object.freeze(exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2023 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.readYamlConfFile = void 0;
|
|
20
|
+
const fs_1 = require("fs");
|
|
21
|
+
const yaml = require("js-yaml");
|
|
22
|
+
function readYamlConfFile(path) {
|
|
23
|
+
const txt = (0, fs_1.readFileSync)(path, 'utf8');
|
|
24
|
+
const conf = yaml.load(txt);
|
|
25
|
+
return conf;
|
|
26
|
+
}
|
|
27
|
+
exports.readYamlConfFile = readYamlConfFile;
|
|
28
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ServerOptions } from "https";
|
|
3
|
+
export declare type CertsUpdateListener = (newOpts: ServerOptions, originalOpts: ServerOptions) => Promise<void>;
|
|
4
|
+
export declare function sslOptsFromConfig(letsencrypt: string | undefined, sslOpts: ServerOptions | undefined, skipReloadOnCertsChange: boolean | undefined): {
|
|
5
|
+
sslOpts: ServerOptions;
|
|
6
|
+
onCertsUpdate?: (listener: CertsUpdateListener) => (() => void);
|
|
7
|
+
} | undefined;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2023 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.sslOptsFromConfig = void 0;
|
|
20
|
+
const fs_1 = require("fs");
|
|
21
|
+
const path_1 = require("path");
|
|
22
|
+
function sslOptsFromConfig(letsencrypt, sslOpts, skipReloadOnCertsChange) {
|
|
23
|
+
if (!sslOpts) {
|
|
24
|
+
sslOpts = {};
|
|
25
|
+
}
|
|
26
|
+
if (letsencrypt) {
|
|
27
|
+
sslOpts.cert = (0, fs_1.readFileSync)((0, path_1.join)(letsencrypt, 'fullchain.pem'));
|
|
28
|
+
sslOpts.key = (0, fs_1.readFileSync)((0, path_1.join)(letsencrypt, 'privkey.pem'));
|
|
29
|
+
if (skipReloadOnCertsChange) {
|
|
30
|
+
return { sslOpts };
|
|
31
|
+
}
|
|
32
|
+
const onCertsUpdate = makeCertsUpdatesWatch();
|
|
33
|
+
return { sslOpts, onCertsUpdate };
|
|
34
|
+
}
|
|
35
|
+
else if (sslOpts.cert && sslOpts.key) {
|
|
36
|
+
sslOpts.cert = (0, fs_1.readFileSync)(sslOpts.cert);
|
|
37
|
+
sslOpts.key = (0, fs_1.readFileSync)(sslOpts.key);
|
|
38
|
+
if (skipReloadOnCertsChange) {
|
|
39
|
+
return { sslOpts };
|
|
40
|
+
}
|
|
41
|
+
const onCertsUpdate = makeCertsUpdatesWatch();
|
|
42
|
+
return { sslOpts, onCertsUpdate };
|
|
43
|
+
}
|
|
44
|
+
else if ((!sslOpts.cert && sslOpts.key)
|
|
45
|
+
|| (sslOpts.cert && !sslOpts.key)) {
|
|
46
|
+
throw new Error(`servicesConnect.sslOpts section must have both key and cert fields pointing to respective files.`);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.sslOptsFromConfig = sslOptsFromConfig;
|
|
53
|
+
function makeCertsUpdatesWatch(
|
|
54
|
+
// XXX pass locations, or some fs watching object
|
|
55
|
+
) {
|
|
56
|
+
return listener => {
|
|
57
|
+
// XXX start watching a signal
|
|
58
|
+
const stopWatching = () => { };
|
|
59
|
+
return stopWatching;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { MultiDomainSignupCtx, SingleUserSignupCtx } from "../admin/signup-tokens";
|
|
2
|
+
export declare function addSingleUserSignup(rootFolder: string, userId: string): Promise<string>;
|
|
3
|
+
export declare function addMultiDomainSignup(rootFolder: string, domains: string[]): Promise<string>;
|
|
4
|
+
export declare function readNoTokensFile(noTokenFile: string): Promise<MultiDomainSignupCtx>;
|
|
5
|
+
export declare function readTokenFile(rootFolder: string, tokenId: string): Promise<SingleUserSignupCtx | MultiDomainSignupCtx | undefined>;
|
|
6
|
+
export declare function readAllSignupTokens(rootFolder: string): Promise<{
|
|
7
|
+
singleUserTokens: {
|
|
8
|
+
tokenId: string;
|
|
9
|
+
ctx: SingleUserSignupCtx;
|
|
10
|
+
}[];
|
|
11
|
+
multiUserTokens: {
|
|
12
|
+
tokenId: string;
|
|
13
|
+
ctx: MultiDomainSignupCtx;
|
|
14
|
+
}[];
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,132 @@
|
|
|
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.readAllSignupTokens = exports.readTokenFile = exports.readNoTokensFile = exports.addMultiDomainSignup = exports.addSingleUserSignup = void 0;
|
|
20
|
+
const async_fs_node_1 = require("../lib-common/async-fs-node");
|
|
21
|
+
const signup_tokens_1 = require("../admin/signup-tokens");
|
|
22
|
+
const server_data_folders_1 = require("../lib-server/resources/server-data-folders");
|
|
23
|
+
const error_1 = require("../lib-common/exceptions/error");
|
|
24
|
+
const path_1 = require("path");
|
|
25
|
+
async function addSingleUserSignup(rootFolder, userId) {
|
|
26
|
+
const token = await (0, signup_tokens_1.generateToken)();
|
|
27
|
+
const ctx = (0, signup_tokens_1.makeSingleUserSignupCtx)(token, userId);
|
|
28
|
+
const fPath = (0, signup_tokens_1.tokenPath)(rootFolder, token);
|
|
29
|
+
try {
|
|
30
|
+
await (0, async_fs_node_1.writeFile)(fPath, JSON.stringify(ctx), { encoding: 'utf8', flag: 'wx' });
|
|
31
|
+
return token;
|
|
32
|
+
}
|
|
33
|
+
catch (exc) {
|
|
34
|
+
if (exc.alreadyExists) {
|
|
35
|
+
return addSingleUserSignup(rootFolder, userId);
|
|
36
|
+
}
|
|
37
|
+
else if (exc.notFound) {
|
|
38
|
+
await (0, async_fs_node_1.mkdir)((0, server_data_folders_1.tokensInRootFolder)(rootFolder))
|
|
39
|
+
.catch((exc) => {
|
|
40
|
+
if (!exc.alreadyExists) {
|
|
41
|
+
throw exc;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return addSingleUserSignup(rootFolder, userId);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
throw exc;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.addSingleUserSignup = addSingleUserSignup;
|
|
52
|
+
async function addMultiDomainSignup(rootFolder, domains) {
|
|
53
|
+
const token = await (0, signup_tokens_1.generateToken)();
|
|
54
|
+
const ctx = (0, signup_tokens_1.makeMultiDomainSignupCtx)(domains, token);
|
|
55
|
+
const fPath = (0, signup_tokens_1.tokenPath)(rootFolder, token);
|
|
56
|
+
try {
|
|
57
|
+
await (0, async_fs_node_1.writeFile)(fPath, JSON.stringify(ctx), { encoding: 'utf8', flag: 'wx' });
|
|
58
|
+
return token;
|
|
59
|
+
}
|
|
60
|
+
catch (exc) {
|
|
61
|
+
if (exc.alreadyExists) {
|
|
62
|
+
return addMultiDomainSignup(rootFolder, domains);
|
|
63
|
+
}
|
|
64
|
+
else if (exc.notFound) {
|
|
65
|
+
await (0, async_fs_node_1.mkdir)((0, server_data_folders_1.tokensInRootFolder)(rootFolder))
|
|
66
|
+
.catch((exc) => {
|
|
67
|
+
if (!exc.alreadyExists) {
|
|
68
|
+
throw exc;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return addMultiDomainSignup(rootFolder, domains);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
throw exc;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.addMultiDomainSignup = addMultiDomainSignup;
|
|
79
|
+
async function readNoTokensFile(noTokenFile) {
|
|
80
|
+
try {
|
|
81
|
+
const str = await (0, async_fs_node_1.readFile)(noTokenFile, { encoding: 'utf8' });
|
|
82
|
+
return JSON.parse(str);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
throw (0, error_1.errWithCause)(err, `Fail to read "no tokens" signup context file ${noTokenFile}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.readNoTokensFile = readNoTokensFile;
|
|
89
|
+
async function readTokenFile(rootFolder, tokenId) {
|
|
90
|
+
try {
|
|
91
|
+
const fPath = (0, path_1.join)((0, server_data_folders_1.tokensInRootFolder)(rootFolder), tokenId);
|
|
92
|
+
const str = await (0, async_fs_node_1.readFile)(fPath, { encoding: 'utf8' });
|
|
93
|
+
const ctx = JSON.parse(str);
|
|
94
|
+
if (!ctx.token) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
else if (ctx.type === 'multi-domain') {
|
|
98
|
+
return (ctx.domains ? ctx : undefined);
|
|
99
|
+
}
|
|
100
|
+
else if (ctx.type === 'single-user') {
|
|
101
|
+
return (ctx.userId ? ctx : undefined);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
console.error(err);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.readTokenFile = readTokenFile;
|
|
113
|
+
async function readAllSignupTokens(rootFolder) {
|
|
114
|
+
const singleUserTokens = [];
|
|
115
|
+
const multiUserTokens = [];
|
|
116
|
+
const tokenIds = await (0, async_fs_node_1.readdir)((0, server_data_folders_1.tokensInRootFolder)(rootFolder));
|
|
117
|
+
for (const tokenId of tokenIds) {
|
|
118
|
+
const ctx = await readTokenFile(rootFolder, tokenId);
|
|
119
|
+
if (!ctx) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (ctx.type === 'multi-domain') {
|
|
123
|
+
multiUserTokens.push({ tokenId, ctx });
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
singleUserTokens.push({ tokenId, ctx });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return { multiUserTokens, singleUserTokens };
|
|
130
|
+
}
|
|
131
|
+
exports.readAllSignupTokens = readAllSignupTokens;
|
|
132
|
+
Object.freeze(exports);
|
|
@@ -13,3 +13,4 @@ export interface HttpError extends ErrorWithCause {
|
|
|
13
13
|
export declare function makeErr(code: number, msg: string, cause?: any): HttpError;
|
|
14
14
|
export declare type ErrLogger = (err: any, req: Request) => void;
|
|
15
15
|
export declare function makeErrHandler(log?: ErrLogger): ErrorRequestHandler;
|
|
16
|
+
export declare function makeErrLoggerToConsole(srvName: string): ErrLogger;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2016, 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2016, 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
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.makeErrHandler = exports.makeErr = void 0;
|
|
19
|
+
exports.makeErrLoggerToConsole = exports.makeErrHandler = exports.makeErr = void 0;
|
|
20
20
|
const http = require("http");
|
|
21
21
|
const error_1 = require("../../lib-common/exceptions/error");
|
|
22
22
|
/**
|
|
@@ -63,4 +63,13 @@ function makeErrHandler(log) {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
exports.makeErrHandler = makeErrHandler;
|
|
66
|
+
function makeErrLoggerToConsole(srvName) {
|
|
67
|
+
return (err, req) => {
|
|
68
|
+
if (typeof err.status !== 'number') {
|
|
69
|
+
console.error(`\n --- Error occured in ${srvName}, when handling ${req.method} request to ${req.originalUrl}`);
|
|
70
|
+
console.error(err);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
exports.makeErrLoggerToConsole = makeErrLoggerToConsole;
|
|
66
75
|
Object.freeze(exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2016 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2016, 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
|
|
@@ -39,19 +39,57 @@ Object.freeze(DNS_ERR_CODE);
|
|
|
39
39
|
*/
|
|
40
40
|
function extractPair(txtRecords, serviceLabel) {
|
|
41
41
|
for (const txtRecord of txtRecords) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
let joinedTXTstanzas = txtRecord.join('');
|
|
43
|
+
let record = getRecordAtStartOf(joinedTXTstanzas);
|
|
44
|
+
while (record) {
|
|
45
|
+
if (record.service === serviceLabel) {
|
|
46
|
+
const value = record.value.trim();
|
|
47
|
+
if (value.length > 0) {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (record.txtTail) {
|
|
52
|
+
record = getRecordAtStartOf(record.txtTail);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
return;
|
|
54
60
|
}
|
|
61
|
+
const recordsStarts = {
|
|
62
|
+
"3nstorage": '3nstorage=',
|
|
63
|
+
asmail: 'asmail=',
|
|
64
|
+
mailerid: 'mailerid='
|
|
65
|
+
};
|
|
66
|
+
function getRecordAtStartOf(txt) {
|
|
67
|
+
let service = undefined;
|
|
68
|
+
for (const [label, startSeq] of Object.entries(recordsStarts)) {
|
|
69
|
+
if (txt.startsWith(startSeq)) {
|
|
70
|
+
service = label;
|
|
71
|
+
txt = txt.substring(startSeq.length);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (!service) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
for (const delimiter of Object.values(recordsStarts)) {
|
|
79
|
+
const endPos = txt.indexOf(delimiter);
|
|
80
|
+
if (endPos >= 0) {
|
|
81
|
+
return {
|
|
82
|
+
service,
|
|
83
|
+
value: txt.substring(0, endPos),
|
|
84
|
+
txtTail: txt.substring(endPos)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
service,
|
|
90
|
+
value: txt
|
|
91
|
+
};
|
|
92
|
+
}
|
|
55
93
|
function resolveTxt(domain) {
|
|
56
94
|
return new Promise((resolve, reject) => {
|
|
57
95
|
// As of March 2017, docs for node say that texts given in a callback
|
package/build/lib.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export { AppWithWSs } from './lib-server/web-sockets/app';
|
|
2
|
+
export { Configurations, servicesApp, adminApp } from './services';
|
|
3
|
+
export { getConfsFromEnv, getBindParamsFromEnv } from './config/from-env';
|
|
4
|
+
export { addSingleUserSignup } from './config/signup';
|
|
5
|
+
export import errors = require('./lib-server/middleware/error-handler');
|
|
6
|
+
export * as mock from './mock/run-in-proc';
|
package/build/lib.js
CHANGED
|
@@ -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
|
|
@@ -16,8 +16,17 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.
|
|
20
|
-
|
|
21
|
-
exports
|
|
19
|
+
exports.mock = exports.addSingleUserSignup = exports.getBindParamsFromEnv = exports.getConfsFromEnv = exports.adminApp = exports.servicesApp = exports.AppWithWSs = void 0;
|
|
20
|
+
var app_1 = require("./lib-server/web-sockets/app");
|
|
21
|
+
Object.defineProperty(exports, "AppWithWSs", { enumerable: true, get: function () { return app_1.AppWithWSs; } });
|
|
22
|
+
var services_1 = require("./services");
|
|
23
|
+
Object.defineProperty(exports, "servicesApp", { enumerable: true, get: function () { return services_1.servicesApp; } });
|
|
24
|
+
Object.defineProperty(exports, "adminApp", { enumerable: true, get: function () { return services_1.adminApp; } });
|
|
25
|
+
var from_env_1 = require("./config/from-env");
|
|
26
|
+
Object.defineProperty(exports, "getConfsFromEnv", { enumerable: true, get: function () { return from_env_1.getConfsFromEnv; } });
|
|
27
|
+
Object.defineProperty(exports, "getBindParamsFromEnv", { enumerable: true, get: function () { return from_env_1.getBindParamsFromEnv; } });
|
|
28
|
+
var signup_1 = require("./config/signup");
|
|
29
|
+
Object.defineProperty(exports, "addSingleUserSignup", { enumerable: true, get: function () { return signup_1.addSingleUserSignup; } });
|
|
30
|
+
exports.errors = require("./lib-server/middleware/error-handler");
|
|
22
31
|
exports.mock = require("./mock/run-in-proc");
|
|
23
32
|
Object.freeze(exports);
|
|
@@ -3,4 +3,5 @@
|
|
|
3
3
|
* express MailerId application.
|
|
4
4
|
*/
|
|
5
5
|
import * as express from 'express';
|
|
6
|
-
|
|
6
|
+
import { ErrLogger } from '../lib-server/middleware/error-handler';
|
|
7
|
+
export declare function makeApp(rootFolder: string, domain: string, certFile: string, errLogger?: ErrLogger): express.Express;
|
|
@@ -43,7 +43,7 @@ function provisioningApp(sessions, users, certifier, computeDHSharedKey) {
|
|
|
43
43
|
app.post('/' + api.certify.URL_END, sessions.ensureAuthorizedSession(), (0, body_parsers_1.binary)('16kb'), (0, certify_1.certify)(certifier.certify));
|
|
44
44
|
return app;
|
|
45
45
|
}
|
|
46
|
-
function makeApp(rootFolder, domain, certFile) {
|
|
46
|
+
function makeApp(rootFolder, domain, certFile, errLogger) {
|
|
47
47
|
const app = express();
|
|
48
48
|
const certProvisSessions = (0, sessions_1.makeSessionFactory)(2 * 60);
|
|
49
49
|
const users = (0, users_1.makeFactory)(rootFolder);
|
|
@@ -62,7 +62,7 @@ function makeApp(rootFolder, domain, certFile) {
|
|
|
62
62
|
};
|
|
63
63
|
res.status(200).json(json); // content type application/json
|
|
64
64
|
});
|
|
65
|
-
app.use((0, error_handler_1.makeErrHandler)());
|
|
65
|
+
app.use((0, error_handler_1.makeErrHandler)(errLogger));
|
|
66
66
|
return app;
|
|
67
67
|
}
|
|
68
68
|
exports.makeApp = makeApp;
|