spec-3nweb-server 1.7.9 → 1.7.12
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 +16 -2
- package/build/asmail/resources/inbox.js +2 -2
- package/build/asmail/resources/recipients.js +16 -12
- package/build/config/cli/index.js +7 -8
- package/build/config/default-confs.d.ts +3 -0
- package/build/config/default-confs.js +22 -0
- package/build/config/from-yaml.js +5 -1
- package/build/lib-common/async-fs-node.d.ts +1 -0
- package/build/lib-common/buffer-utils.d.ts +1 -0
- package/build/lib-common/objs-on-disk/file-layout.d.ts +1 -0
- package/build/lib-common/objs-on-disk/v1-obj-file-format.d.ts +1 -0
- package/build/main.d.ts +1 -0
- package/build/main.js +7 -6
- package/build/signup/signup-tokens.d.ts +1 -0
- package/package.json +6 -9
package/README.md
CHANGED
|
@@ -7,9 +7,9 @@ Thus, we call it a spec server.
|
|
|
7
7
|
Main purpose of this server is to ensure that 3NWeb protocols are implementable, and to be a testbed for possible new features.
|
|
8
8
|
Secondary purpose of this server is to be packagable into a home-class server, i.e. server that can be run from a single machine.
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Build & Test
|
|
11
11
|
|
|
12
|
-
To use this repo, you need [Node.js](https://nodejs.org/)
|
|
12
|
+
To use this repo, you need [Node.js](https://nodejs.org/).
|
|
13
13
|
|
|
14
14
|
When in the project's folder, run
|
|
15
15
|
```
|
|
@@ -32,6 +32,20 @@ Config file is `src/tests/jasmine.ts`.
|
|
|
32
32
|
|
|
33
33
|
Please note, that support for running server on windows hasn't been introduced, yet.
|
|
34
34
|
|
|
35
|
+
## ASMail (Authenticated Secure Mail) protocol overview
|
|
36
|
+
|
|
37
|
+
```mermaid
|
|
38
|
+
flowchart LR
|
|
39
|
+
C@{ shape: hex, label: "customer#64;x.y.z" } -- anonymous <br> connection --> VS@{ shape: lin-cyl, label: "ASMail service for a.b.c" }
|
|
40
|
+
V@{ shape: hex, label: "vendor#64;a.b.c" } -- anonymous <br> connection --> CS@{ shape: lin-cyl, label: "ASMail service for x.y.z" }
|
|
41
|
+
subgraph cg[" "]
|
|
42
|
+
CS -- owner <br> connection --> C
|
|
43
|
+
end
|
|
44
|
+
subgraph vg[" "]
|
|
45
|
+
VS -- owner <br> connection --> V
|
|
46
|
+
end
|
|
47
|
+
```
|
|
48
|
+
|
|
35
49
|
# License
|
|
36
50
|
|
|
37
51
|
Code is provided here under GNU General Public License, version 3.
|
|
@@ -370,7 +370,7 @@ class Inbox extends user_files_1.UserFiles {
|
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
async setAuthSenderBlacklist(lst) {
|
|
373
|
-
if (
|
|
373
|
+
if (isValidBlacklist(lst)) {
|
|
374
374
|
await this.setParam('authenticated/blacklist', lst);
|
|
375
375
|
return true;
|
|
376
376
|
}
|
|
@@ -435,7 +435,7 @@ function isValidListWithMsgMaxSizes(lst) {
|
|
|
435
435
|
}
|
|
436
436
|
return true;
|
|
437
437
|
}
|
|
438
|
-
function
|
|
438
|
+
function isValidBlacklist(lst) {
|
|
439
439
|
return ('object' === typeof lst) && !!lst;
|
|
440
440
|
}
|
|
441
441
|
class ObjFiles {
|
|
@@ -86,22 +86,26 @@ async function adaptToFreeSpaceLeft(inbox, msgSize) {
|
|
|
86
86
|
*/
|
|
87
87
|
async function allowedMsgSizeForAnonSender(inbox, invitation) {
|
|
88
88
|
const policy = await inbox.getParam('anonymous/policy');
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (!invitation) {
|
|
89
|
+
if (policy.accept) {
|
|
90
|
+
// XXX this misses case when invite allows for bigger messages,
|
|
91
|
+
// while without invite messages are also allowed.
|
|
93
92
|
if (policy.acceptWithInvitesOnly) {
|
|
94
|
-
|
|
93
|
+
if (invitation) {
|
|
94
|
+
const invites = await inbox.getParam('anonymous/invites');
|
|
95
|
+
const sizeForInvite = invites[invitation];
|
|
96
|
+
return ((typeof sizeForInvite === 'number') ?
|
|
97
|
+
adaptToFreeSpaceLeft(inbox, sizeForInvite) : 0);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return await adaptToFreeSpaceLeft(inbox, policy.defaultMsgSize);
|
|
95
105
|
}
|
|
96
|
-
return await adaptToFreeSpaceLeft(inbox, policy.defaultMsgSize);
|
|
97
106
|
}
|
|
98
107
|
else {
|
|
99
|
-
|
|
100
|
-
const sizeForInvite = invites[invitation];
|
|
101
|
-
if (typeof sizeForInvite !== 'number') {
|
|
102
|
-
return 0;
|
|
103
|
-
}
|
|
104
|
-
return adaptToFreeSpaceLeft(inbox, sizeForInvite);
|
|
108
|
+
return 0;
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2023 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2023, 2025 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
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.parseProcessArgv = void 0;
|
|
20
|
-
const
|
|
20
|
+
const default_confs_1 = require("../default-confs");
|
|
21
21
|
const run_cmd_1 = require("./run-cmd");
|
|
22
22
|
const signup_cmd_1 = require("./signup-cmd");
|
|
23
23
|
const utils_1 = require("./utils");
|
|
@@ -46,22 +46,21 @@ function mainUsage(execName) {
|
|
|
46
46
|
}
|
|
47
47
|
function parseProcessArgv() {
|
|
48
48
|
const args = process.argv.slice(2);
|
|
49
|
-
const execName = (0, path_1.basename)(process.argv0);
|
|
50
49
|
if (args.length === 0) {
|
|
51
|
-
return (0, utils_1.toUsageDisplay)(0, mainUsage(
|
|
50
|
+
return (0, utils_1.toUsageDisplay)(0, mainUsage(default_confs_1.EXECUTABLE_NAME));
|
|
52
51
|
}
|
|
53
52
|
if (args[0] === run_cmd_1.runCmd.name) {
|
|
54
|
-
return (0, run_cmd_1.parseRunArgs)(args.slice(1),
|
|
53
|
+
return (0, run_cmd_1.parseRunArgs)(args.slice(1), default_confs_1.EXECUTABLE_NAME);
|
|
55
54
|
}
|
|
56
55
|
else if (args[0] === signup_cmd_1.signupCmd.name) {
|
|
57
|
-
return (0, signup_cmd_1.parseSignupArgs)(args.slice(1),
|
|
56
|
+
return (0, signup_cmd_1.parseSignupArgs)(args.slice(1), default_confs_1.EXECUTABLE_NAME);
|
|
58
57
|
}
|
|
59
58
|
else {
|
|
60
59
|
const opts = (0, utils_1.parseArgv)(args, [utils_1.helpOpt], { partial: true });
|
|
61
60
|
if (opts.help) {
|
|
62
|
-
return (0, utils_1.toUsageDisplay)(0, mainUsage(
|
|
61
|
+
return (0, utils_1.toUsageDisplay)(0, mainUsage(default_confs_1.EXECUTABLE_NAME));
|
|
63
62
|
}
|
|
64
|
-
return (0, utils_1.toUsageDisplay)(-1, (0, utils_1.toErrorUsage)(mainUsage(
|
|
63
|
+
return (0, utils_1.toUsageDisplay)(-1, (0, utils_1.toErrorUsage)(mainUsage(default_confs_1.EXECUTABLE_NAME), `Unknown command '${args[0]}'`));
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
exports.parseProcessArgv = parseProcessArgv;
|
|
@@ -0,0 +1,22 @@
|
|
|
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.DEFAULT_CONFIG_PATH = exports.DEFAULT_DATA_ROOT_PATH = exports.EXECUTABLE_NAME = void 0;
|
|
20
|
+
exports.EXECUTABLE_NAME = '3nweb';
|
|
21
|
+
exports.DEFAULT_DATA_ROOT_PATH = '/var/3nweb';
|
|
22
|
+
exports.DEFAULT_CONFIG_PATH = `/etc/3nweb/conf.yaml`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2023 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2023, 2025 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
|
|
@@ -19,9 +19,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.readYamlConfFile = void 0;
|
|
20
20
|
const fs_1 = require("fs");
|
|
21
21
|
const yaml = require("js-yaml");
|
|
22
|
+
const default_confs_1 = require("./default-confs");
|
|
22
23
|
function readYamlConfFile(path) {
|
|
23
24
|
const txt = (0, fs_1.readFileSync)(path, 'utf8');
|
|
24
25
|
const conf = yaml.load(txt);
|
|
26
|
+
if (conf.rootFolder) {
|
|
27
|
+
conf.rootFolder = default_confs_1.DEFAULT_DATA_ROOT_PATH;
|
|
28
|
+
}
|
|
25
29
|
return conf;
|
|
26
30
|
}
|
|
27
31
|
exports.readYamlConfFile = readYamlConfFile;
|
package/build/main.d.ts
CHANGED
package/build/main.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2016, 2019 3NSoft Inc.
|
|
4
|
+
Copyright (C) 2015 - 2016, 2019, 2025 3NSoft Inc.
|
|
4
5
|
|
|
5
6
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
7
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -21,6 +22,7 @@ const from_yaml_1 = require("./config/from-yaml");
|
|
|
21
22
|
const letsencrypt_1 = require("./config/letsencrypt");
|
|
22
23
|
const lib_1 = require("./lib");
|
|
23
24
|
const signup_1 = require("./config/signup");
|
|
25
|
+
const default_confs_1 = require("./config/default-confs");
|
|
24
26
|
async function run(conf) {
|
|
25
27
|
if (!conf.servicesConnect) {
|
|
26
28
|
console.error(`No connection settings found in ??.`);
|
|
@@ -112,12 +114,11 @@ function showUsage({ txtToDisplay, exitStatus }) {
|
|
|
112
114
|
process.exit(exitStatus);
|
|
113
115
|
}
|
|
114
116
|
function assembleConfig(configPath) {
|
|
115
|
-
if (configPath) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
else {
|
|
119
|
-
throw new Error(`Config path must be given`);
|
|
117
|
+
if (!configPath) {
|
|
118
|
+
configPath = default_confs_1.DEFAULT_CONFIG_PATH;
|
|
119
|
+
console.log(`Looking for configuration in default location: ${configPath}`);
|
|
120
120
|
}
|
|
121
|
+
return (0, from_yaml_1.readYamlConfFile)(configPath);
|
|
121
122
|
}
|
|
122
123
|
async function displaySignupInfo(conf) {
|
|
123
124
|
if (!conf.signup) {
|
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spec-3nweb-server",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.12",
|
|
4
4
|
"description": "3NWeb spec server.",
|
|
5
5
|
"main": "build/lib.js",
|
|
6
6
|
"types": "build/lib.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"3nweb": "build/main.js"
|
|
9
|
+
},
|
|
7
10
|
"scripts": {
|
|
8
11
|
"build": "tsc -p ts-code",
|
|
12
|
+
"server": "node build/main.js",
|
|
9
13
|
"test": "node build/tests/jasmine.js",
|
|
10
14
|
"clear-for-packing": "npm prune --production && bash -c \"rm -rf build/mock build/tests 'node_modules/ecma-nacl/c sources'\"",
|
|
11
15
|
"clear-for-packing-mock": "npm prune --production && bash -c \"rm -rf build/tests 'node_modules/ecma-nacl/c sources'\"",
|
|
12
|
-
"pack": "
|
|
16
|
+
"pack": "echo unimplemented",
|
|
13
17
|
"pack-deb": "npm run pack && bash packing/create-deb.sh",
|
|
14
18
|
"postinstall": "node -e \"try{require('./postinstall')}catch(e){}\""
|
|
15
19
|
},
|
|
@@ -47,16 +51,9 @@
|
|
|
47
51
|
"@types/node": "^16.11.7",
|
|
48
52
|
"@types/ws": "^4.0.0",
|
|
49
53
|
"jasmine": "^3.9.0",
|
|
50
|
-
"pkg": "^5.8.1",
|
|
51
54
|
"rxjs": "^5.3.0",
|
|
52
55
|
"typescript": "^4.7.4",
|
|
53
56
|
"xhr2": "^0.1.3"
|
|
54
57
|
},
|
|
55
|
-
"pkg": {
|
|
56
|
-
"targets": [
|
|
57
|
-
"node18-linux-x64"
|
|
58
|
-
],
|
|
59
|
-
"outputPath": "dist"
|
|
60
|
-
},
|
|
61
58
|
"readmeFilename": "README.md"
|
|
62
59
|
}
|