spec-3nweb-server 1.3.8 → 1.5.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/build/3nstorage/3nstorage-app.js +4 -4
- package/build/3nstorage/owner.js +28 -28
- package/build/3nstorage/resources/store.d.ts +2 -9
- package/build/3nstorage/resources/store.js +76 -73
- package/build/3nstorage/resources/users.d.ts +4 -2
- package/build/3nstorage/resources/users.js +8 -4
- package/build/3nstorage/routes/owner/archive-obj-version.d.ts +2 -2
- package/build/3nstorage/routes/owner/archive-obj-version.js +36 -31
- package/build/3nstorage/routes/owner/cancel-trans.js +1 -1
- package/build/3nstorage/routes/owner/delete-obj.d.ts +3 -2
- package/build/3nstorage/routes/owner/delete-obj.js +42 -7
- package/build/3nstorage/routes/owner/get-archived-obj-ver.js +10 -6
- package/build/3nstorage/routes/owner/get-current-obj.js +2 -2
- package/build/3nstorage/routes/owner/list-obj-archive.js +28 -31
- package/build/3nstorage/routes/owner/param-getter.js +3 -2
- package/build/3nstorage/routes/owner/param-setter.js +3 -2
- package/build/3nstorage/routes/owner/put-current-obj.js +12 -10
- package/build/3nstorage/routes/owner/session-params.js +4 -3
- package/build/admin/admin-app.js +5 -5
- package/build/admin/resources/users.js +42 -42
- package/build/admin/routes/add.js +3 -3
- package/build/admin/signup-tokens.js +8 -8
- package/build/asmail/asmail-app.js +7 -7
- package/build/asmail/config.js +9 -8
- package/build/asmail/delivery.js +10 -9
- package/build/asmail/resources/delivery-sessions.js +4 -3
- package/build/asmail/resources/inbox.d.ts +1 -1
- package/build/asmail/resources/inbox.js +22 -22
- package/build/asmail/resources/recipients.d.ts +2 -1
- package/build/asmail/resources/recipients.js +4 -4
- package/build/asmail/resources/sessions.js +2 -1
- package/build/asmail/retrieval.js +13 -8
- package/build/asmail/routes/config/param-getter.js +3 -2
- package/build/asmail/routes/config/param-setter.js +3 -2
- package/build/asmail/routes/delivery/finalize-delivery.js +3 -2
- package/build/asmail/routes/delivery/pre-flight.js +5 -4
- package/build/asmail/routes/delivery/provide-recipient-pubkey.js +3 -2
- package/build/asmail/routes/delivery/put-metadata.js +3 -2
- package/build/asmail/routes/delivery/put-obj.js +4 -4
- package/build/asmail/routes/delivery/restart-session.js +4 -3
- package/build/asmail/routes/delivery/sender-authorization.d.ts +1 -3
- package/build/asmail/routes/delivery/sender-authorization.js +3 -2
- package/build/asmail/routes/delivery/start-session.js +5 -4
- package/build/asmail/routes/retrieval/get-message-meta.js +3 -2
- package/build/asmail/routes/retrieval/get-message-obj.js +4 -3
- package/build/asmail/routes/retrieval/list-messages.js +3 -2
- package/build/asmail/routes/retrieval/remove-message.js +3 -2
- package/build/lib-common/async-fs-node.d.ts +2 -0
- package/build/lib-common/async-fs-node.js +13 -13
- package/build/lib-common/byte-streaming/common.js +9 -9
- package/build/lib-common/canonical-address.js +1 -1
- package/build/lib-common/ipc/generic-ipc.js +12 -12
- package/build/lib-common/ipc/ws-ipc.js +2 -2
- package/build/lib-common/mid-sigs-NaCl-Ed.js +14 -14
- package/build/lib-common/objs-on-disk/file-layout.js +10 -10
- package/build/lib-common/objs-on-disk/obj-file.js +11 -11
- package/build/lib-common/objs-on-disk/utils.d.ts +1 -0
- package/build/lib-common/objs-on-disk/utils.js +3 -3
- package/build/lib-common/processes.js +1 -1
- package/build/lib-common/random-node.js +7 -7
- package/build/lib-common/service-api/3nstorage/owner.d.ts +24 -18
- package/build/lib-common/service-api/3nstorage/owner.js +31 -26
- package/build/lib-common/service-api/asmail/delivery.js +2 -2
- package/build/lib-common/service-api/asmail/retrieval.js +1 -1
- package/build/lib-server/conf-util.js +2 -1
- package/build/lib-server/middleware/body-parsers.js +16 -16
- package/build/lib-server/middleware/error-handler.js +1 -1
- package/build/lib-server/resources/mailerid-authorizer.js +3 -3
- package/build/lib-server/resources/mem-backed-sessions-factory.js +3 -3
- package/build/lib-server/resources/server-data-folders.js +23 -23
- package/build/lib-server/resources/sessions.js +5 -5
- package/build/lib-server/resources/user-files.js +8 -8
- package/build/lib-server/routes/pub-key-login/complete-exchange.js +4 -3
- package/build/lib-server/routes/pub-key-login/start-exchange.js +7 -6
- package/build/lib-server/routes/sessions/mid-auth.js +6 -5
- package/build/lib-server/routes/sessions/start.js +4 -3
- package/build/lib-server/web-sockets/app.d.ts +1 -0
- package/build/lib-server/web-sockets/app.js +6 -5
- package/build/lib-server/web-sockets/server-events.js +5 -4
- package/build/mailerId/mailerId-app.js +7 -7
- package/build/mailerId/resources/certifier.d.ts +4 -6
- package/build/mailerId/resources/certifier.js +8 -7
- package/build/mailerId/resources/compute-login-dhshared-key.js +2 -1
- package/build/mailerId/resources/sessions.js +2 -1
- package/build/mailerId/resources/users.js +4 -4
- package/build/mailerId/routes/certify.js +1 -1
- package/build/main.js +10 -10
- package/build/mock/dns.js +1 -1
- package/build/mock/mock-as-child-proc.js +10 -10
- package/build/mock/node-child-ipc.js +2 -2
- package/build/mock/run-in-proc.js +7 -7
- package/build/run-config.js +10 -10
- package/build/run.js +4 -4
- package/build/services.js +5 -5
- package/package.json +13 -10
|
@@ -22,16 +22,16 @@ const canonical_address_1 = require("../../lib-common/canonical-address");
|
|
|
22
22
|
const path_1 = require("path");
|
|
23
23
|
const fs_1 = require("fs");
|
|
24
24
|
function addressToFName(address) {
|
|
25
|
-
return canonicalAddressToFName(canonical_address_1.toCanonicalAddress(address));
|
|
25
|
+
return canonicalAddressToFName((0, canonical_address_1.toCanonicalAddress)(address));
|
|
26
26
|
}
|
|
27
27
|
exports.addressToFName = addressToFName;
|
|
28
28
|
function canonicalAddressToFName(canonicalAddress) {
|
|
29
29
|
return buffer_utils_1.base64urlSafe.pack(buffer_utils_1.utf8.pack(canonicalAddress));
|
|
30
30
|
}
|
|
31
31
|
function treeInRootFolder(rootFolder) {
|
|
32
|
-
const defaults = path_1.join(rootFolder, 'defaults');
|
|
32
|
+
const defaults = (0, path_1.join)(rootFolder, 'defaults');
|
|
33
33
|
return {
|
|
34
|
-
users: { path: path_1.join(rootFolder, 'users') },
|
|
34
|
+
users: { path: (0, path_1.join)(rootFolder, 'users') },
|
|
35
35
|
defaults: {
|
|
36
36
|
path: defaults,
|
|
37
37
|
},
|
|
@@ -40,51 +40,51 @@ function treeInRootFolder(rootFolder) {
|
|
|
40
40
|
}
|
|
41
41
|
exports.treeInRootFolder = treeInRootFolder;
|
|
42
42
|
function tokensInRootFolder(rootFolder) {
|
|
43
|
-
return path_1.join(rootFolder, 'tokens');
|
|
43
|
+
return (0, path_1.join)(rootFolder, 'tokens');
|
|
44
44
|
}
|
|
45
45
|
exports.tokensInRootFolder = tokensInRootFolder;
|
|
46
46
|
function userDataInRootFolder(root, userId) {
|
|
47
|
-
return path_1.join(root, 'users', addressToFName(userId));
|
|
47
|
+
return (0, path_1.join)(root, 'users', addressToFName(userId));
|
|
48
48
|
}
|
|
49
49
|
exports.userDataInRootFolder = userDataInRootFolder;
|
|
50
50
|
function treeInDefaultsFolder(defaults) {
|
|
51
|
-
const mail = path_1.join(defaults, 'mail');
|
|
52
|
-
const mailParams = path_1.join(mail, 'params');
|
|
53
|
-
const store = path_1.join(defaults, 'store');
|
|
51
|
+
const mail = (0, path_1.join)(defaults, 'mail');
|
|
52
|
+
const mailParams = (0, path_1.join)(mail, 'params');
|
|
53
|
+
const store = (0, path_1.join)(defaults, 'store');
|
|
54
54
|
return {
|
|
55
|
-
info: { path: path_1.join(defaults, 'info') },
|
|
55
|
+
info: { path: (0, path_1.join)(defaults, 'info') },
|
|
56
56
|
mail: {
|
|
57
57
|
path: mail,
|
|
58
58
|
params: {
|
|
59
59
|
path: mailParams,
|
|
60
|
-
anonymous: { path: path_1.join(mailParams, 'anonymous') },
|
|
61
|
-
authenticated: { path: path_1.join(mailParams, 'authenticated') }
|
|
60
|
+
anonymous: { path: (0, path_1.join)(mailParams, 'anonymous') },
|
|
61
|
+
authenticated: { path: (0, path_1.join)(mailParams, 'authenticated') }
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
store: {
|
|
65
65
|
path: store,
|
|
66
|
-
params: { path: path_1.join(store, 'params') }
|
|
66
|
+
params: { path: (0, path_1.join)(store, 'params') }
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
exports.treeInDefaultsFolder = treeInDefaultsFolder;
|
|
71
71
|
function treeInUserFolder(userFoder) {
|
|
72
|
-
const mail = path_1.join(userFoder, 'mail');
|
|
73
|
-
const store = path_1.join(userFoder, 'store');
|
|
72
|
+
const mail = (0, path_1.join)(userFoder, 'mail');
|
|
73
|
+
const store = (0, path_1.join)(userFoder, 'store');
|
|
74
74
|
return {
|
|
75
|
-
info: { path: path_1.join(userFoder, 'info') },
|
|
75
|
+
info: { path: (0, path_1.join)(userFoder, 'info') },
|
|
76
76
|
mail: {
|
|
77
77
|
path: mail,
|
|
78
|
-
delivery: { path: path_1.join(mail, 'delivery') },
|
|
79
|
-
messages: { path: path_1.join(mail, 'messages') },
|
|
80
|
-
params: { path: path_1.join(mail, 'params') }
|
|
78
|
+
delivery: { path: (0, path_1.join)(mail, 'delivery') },
|
|
79
|
+
messages: { path: (0, path_1.join)(mail, 'messages') },
|
|
80
|
+
params: { path: (0, path_1.join)(mail, 'params') }
|
|
81
81
|
},
|
|
82
82
|
store: {
|
|
83
83
|
path: store,
|
|
84
|
-
params: { path: path_1.join(store, 'params') },
|
|
85
|
-
root: { path: path_1.join(store, 'root') },
|
|
86
|
-
objects: { path: path_1.join(store, 'objects') },
|
|
87
|
-
transactions: { path: path_1.join(store, 'transactions') }
|
|
84
|
+
params: { path: (0, path_1.join)(store, 'params') },
|
|
85
|
+
root: { path: (0, path_1.join)(store, 'root') },
|
|
86
|
+
objects: { path: (0, path_1.join)(store, 'objects') },
|
|
87
|
+
transactions: { path: (0, path_1.join)(store, 'transactions') }
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
90
|
}
|
|
@@ -103,7 +103,7 @@ exports.createFolderTree = createFolderTree;
|
|
|
103
103
|
function createFolderTreeSync(structure) {
|
|
104
104
|
for (const [key, def] of Object.entries(structure)) {
|
|
105
105
|
if (key === 'path') {
|
|
106
|
-
fs_1.mkdirSync(def, { recursive: true });
|
|
106
|
+
(0, fs_1.mkdirSync)(def, { recursive: true });
|
|
107
107
|
}
|
|
108
108
|
else {
|
|
109
109
|
createFolderTreeSync(def);
|
|
@@ -171,11 +171,11 @@ Object.freeze(BaseSessionFactory.prototype);
|
|
|
171
171
|
Object.freeze(BaseSessionFactory);
|
|
172
172
|
function wrapFactory(impl) {
|
|
173
173
|
const wrap = {
|
|
174
|
-
checkSession: binding_1.bind(impl, impl.checkSession),
|
|
175
|
-
ensureAuthorizedSession: binding_1.bind(impl, impl.ensureAuthorizedSession),
|
|
176
|
-
ensureOpenedSession: binding_1.bind(impl, impl.ensureOpenedSession),
|
|
177
|
-
ensureAuthorizedSessionForSocketStart: binding_1.bind(impl, impl.ensureAuthorizedSessionForSocketStart),
|
|
178
|
-
generate: binding_1.bind(impl, impl.generate)
|
|
174
|
+
checkSession: (0, binding_1.bind)(impl, impl.checkSession),
|
|
175
|
+
ensureAuthorizedSession: (0, binding_1.bind)(impl, impl.ensureAuthorizedSession),
|
|
176
|
+
ensureOpenedSession: (0, binding_1.bind)(impl, impl.ensureOpenedSession),
|
|
177
|
+
ensureAuthorizedSessionForSocketStart: (0, binding_1.bind)(impl, impl.ensureAuthorizedSessionForSocketStart),
|
|
178
|
+
generate: (0, binding_1.bind)(impl, impl.generate)
|
|
179
179
|
};
|
|
180
180
|
return wrap;
|
|
181
181
|
}
|
|
@@ -35,7 +35,7 @@ async function readJsonFile(path) {
|
|
|
35
35
|
return JSON.parse(buf.toString('utf8'));
|
|
36
36
|
}
|
|
37
37
|
function addressToFName(address) {
|
|
38
|
-
return buffer_utils_1.base64urlSafe.pack(buffer_utils_1.utf8.pack(canonical_address_1.toCanonicalAddress(address)));
|
|
38
|
+
return buffer_utils_1.base64urlSafe.pack(buffer_utils_1.utf8.pack((0, canonical_address_1.toCanonicalAddress)(address)));
|
|
39
39
|
}
|
|
40
40
|
exports.addressToFName = addressToFName;
|
|
41
41
|
class UserFiles {
|
|
@@ -43,10 +43,10 @@ class UserFiles {
|
|
|
43
43
|
this.userId = userId;
|
|
44
44
|
this.path = path;
|
|
45
45
|
this.fileWritingBufferSize = (writeBufferSize ?
|
|
46
|
-
conf_util_1.stringToNumOfBytes(writeBufferSize) :
|
|
46
|
+
(0, conf_util_1.stringToNumOfBytes)(writeBufferSize) :
|
|
47
47
|
DEFAULT_FILE_WRITE_BUFFER_SIZE);
|
|
48
48
|
this.fileReadingBufferSize = (readBufferSize ?
|
|
49
|
-
conf_util_1.stringToNumOfBytes(readBufferSize) :
|
|
49
|
+
(0, conf_util_1.stringToNumOfBytes)(readBufferSize) :
|
|
50
50
|
DEFAULT_FILE_READ_BUFFER_SIZE);
|
|
51
51
|
}
|
|
52
52
|
async ensureUserExistsOnDisk() {
|
|
@@ -64,23 +64,23 @@ class UserFiles {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
commonInfoFolder() {
|
|
67
|
-
return path_1.join(this.path, '..', 'info');
|
|
67
|
+
return (0, path_1.join)(this.path, '..', 'info');
|
|
68
68
|
}
|
|
69
69
|
getSpaceQuota() {
|
|
70
|
-
return readJsonFile(path_1.join(this.commonInfoFolder(), 'quota'));
|
|
70
|
+
return readJsonFile((0, path_1.join)(this.commonInfoFolder(), 'quota'));
|
|
71
71
|
}
|
|
72
72
|
getParam(paramFileName) {
|
|
73
|
-
return readJsonFile(path_1.join(this.path, 'params', paramFileName));
|
|
73
|
+
return readJsonFile((0, path_1.join)(this.path, 'params', paramFileName));
|
|
74
74
|
}
|
|
75
75
|
setParam(paramFileName, param) {
|
|
76
|
-
return fs.writeFile(path_1.join(this.path, 'params', paramFileName), JSON.stringify(param), { encoding: 'utf8', flag: 'w' });
|
|
76
|
+
return fs.writeFile((0, path_1.join)(this.path, 'params', paramFileName), JSON.stringify(param), { encoding: 'utf8', flag: 'w' });
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
exports.UserFiles = UserFiles;
|
|
80
80
|
Object.freeze(UserFiles.prototype);
|
|
81
81
|
Object.freeze(UserFiles);
|
|
82
82
|
async function pipeBytes(src, sink) {
|
|
83
|
-
const deferred = processes_1.defer();
|
|
83
|
+
const deferred = (0, processes_1.defer)();
|
|
84
84
|
src.pipe(sink, { end: false });
|
|
85
85
|
src.on('error', (err) => {
|
|
86
86
|
deferred.reject(err);
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
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/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.completePKLogin = void 0;
|
|
19
20
|
const ecma_nacl_1 = require("ecma-nacl");
|
|
@@ -33,11 +34,11 @@ function completePKLogin() {
|
|
|
33
34
|
const c = new Uint8Array(req.body);
|
|
34
35
|
const decryptedKey = session.params.encryptor.open(c);
|
|
35
36
|
const key = session.params.sessionKey;
|
|
36
|
-
if (!ecma_nacl_1.compareVectors(decryptedKey, key)) {
|
|
37
|
+
if (!(0, ecma_nacl_1.compareVectors)(decryptedKey, key)) {
|
|
37
38
|
throw new Error();
|
|
38
39
|
}
|
|
39
40
|
session.isAuthorized = true;
|
|
40
|
-
res.status(pub_key_login_1.complete.SC.ok).send(buffer_utils_1.toBuffer(session.params.serverVerificationBytes));
|
|
41
|
+
res.status(pub_key_login_1.complete.SC.ok).send((0, buffer_utils_1.toBuffer)(session.params.serverVerificationBytes));
|
|
41
42
|
}
|
|
42
43
|
catch (err) {
|
|
43
44
|
session.close();
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
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/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.startPKLogin = void 0;
|
|
19
20
|
const ecma_nacl_1 = require("ecma-nacl");
|
|
@@ -27,7 +28,7 @@ const NONCE_LENGTH = ecma_nacl_1.secret_box.NONCE_LENGTH;
|
|
|
27
28
|
const KEY_LENGTH = ecma_nacl_1.secret_box.KEY_LENGTH;
|
|
28
29
|
const POLY_LENGTH = ecma_nacl_1.secret_box.POLY_LENGTH;
|
|
29
30
|
function addEncryptorToSession(session, sessionKey, nonce) {
|
|
30
|
-
const encryptor = session_encryptor_1.makeSessionEncryptor(sessionKey, nonce);
|
|
31
|
+
const encryptor = (0, session_encryptor_1.makeSessionEncryptor)(sessionKey, nonce);
|
|
31
32
|
session.params.encryptor = encryptor;
|
|
32
33
|
session.addCleanUp(() => {
|
|
33
34
|
encryptor.destroy();
|
|
@@ -46,8 +47,8 @@ function startPKLogin(findUserParamsAndKeyFunc, sessionGenFunc, computeDHSharedK
|
|
|
46
47
|
if ('function' !== typeof computeDHSharedKeyFunc) {
|
|
47
48
|
throw new TypeError("Given argument 'computeDHSharedKeyFunc' must be function, but is not.");
|
|
48
49
|
}
|
|
49
|
-
return async
|
|
50
|
-
const userId = canonical_address_1.checkAndTransformAddress(req.body.userId);
|
|
50
|
+
return async (req, res, next) => {
|
|
51
|
+
const userId = (0, canonical_address_1.checkAndTransformAddress)(req.body.userId);
|
|
51
52
|
const kid = req.body.kid;
|
|
52
53
|
let session = req.session;
|
|
53
54
|
// missing userId makes a bad request
|
|
@@ -85,8 +86,8 @@ function startPKLogin(findUserParamsAndKeyFunc, sessionGenFunc, computeDHSharedK
|
|
|
85
86
|
session.params.userId = userId;
|
|
86
87
|
}
|
|
87
88
|
// get random bytes for session key and nonce
|
|
88
|
-
const nonce = await random_node_1.bytes(NONCE_LENGTH);
|
|
89
|
-
const sessionKey = await random_node_1.bytes(KEY_LENGTH);
|
|
89
|
+
const nonce = await (0, random_node_1.bytes)(NONCE_LENGTH);
|
|
90
|
+
const sessionKey = await (0, random_node_1.bytes)(KEY_LENGTH);
|
|
90
91
|
// compute DH-shared key for encrypting a challenge
|
|
91
92
|
const compRes = computeDHSharedKeyFunc(userParamsAndKey.pkey);
|
|
92
93
|
const dhsharedKey = compRes.dhsharedKey;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
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/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.midLogin = void 0;
|
|
19
20
|
const jwkeys_1 = require("../../../lib-common/jwkeys");
|
|
@@ -28,16 +29,16 @@ function midLogin(relyingPartyDomain, midAuthorizingFunc) {
|
|
|
28
29
|
if ('function' !== typeof midAuthorizingFunc) {
|
|
29
30
|
throw new TypeError("Given argument 'midAuthorizingFunc' must be function, but is not.");
|
|
30
31
|
}
|
|
31
|
-
return async
|
|
32
|
+
return async (req, res, next) => {
|
|
32
33
|
if (req.session.isAuthorized) {
|
|
33
34
|
res.status(login_1.ERR_SC.duplicate).send("This protocol request has already been served.");
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
37
|
const rb = req.body;
|
|
37
38
|
const sessionId = req.session.id;
|
|
38
|
-
if (!jwkeys_1.isLikeSignedMailerIdAssertion(rb.assertion) ||
|
|
39
|
-
!jwkeys_1.isLikeSignedKeyCert(rb.userCert) ||
|
|
40
|
-
!jwkeys_1.isLikeSignedKeyCert(rb.provCert)) {
|
|
39
|
+
if (!(0, jwkeys_1.isLikeSignedMailerIdAssertion)(rb.assertion) ||
|
|
40
|
+
!(0, jwkeys_1.isLikeSignedKeyCert)(rb.userCert) ||
|
|
41
|
+
!(0, jwkeys_1.isLikeSignedKeyCert)(rb.provCert)) {
|
|
41
42
|
res.sendStatus(login_1.ERR_SC.malformed);
|
|
42
43
|
req.session.close();
|
|
43
44
|
return;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
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/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.startSession = void 0;
|
|
19
20
|
const login_1 = require("../../../lib-common/service-api/mailer-id/login");
|
|
@@ -53,9 +54,9 @@ function startSession(userExistsFunc, sessionGenFunc, redirectFunc) {
|
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
|
-
return async
|
|
57
|
+
return async (req, res, next) => {
|
|
57
58
|
const session = req.session;
|
|
58
|
-
const userId = canonical_address_1.checkAndTransformAddress(req.body.userId);
|
|
59
|
+
const userId = (0, canonical_address_1.checkAndTransformAddress)(req.body.userId);
|
|
59
60
|
if (!userId) {
|
|
60
61
|
res.status(login_1.ERR_SC.malformed).json({
|
|
61
62
|
error: "User id is either malformed, or missing."
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
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/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.AppWithWSs = exports.UserSockets = void 0;
|
|
19
20
|
const http = require("http");
|
|
@@ -56,9 +57,9 @@ class UserSocketsServer {
|
|
|
56
57
|
server,
|
|
57
58
|
clientTracking: true,
|
|
58
59
|
maxPayload: MAX_MSG_PAYLOAD,
|
|
59
|
-
verifyClient: binding_1.bind(this, this.verifyClient)
|
|
60
|
+
verifyClient: (0, binding_1.bind)(this, this.verifyClient)
|
|
60
61
|
})
|
|
61
|
-
.on('connection', binding_1.bind(this, this.handleConnection)) // bad @types
|
|
62
|
+
.on('connection', (0, binding_1.bind)(this, this.handleConnection)) // bad @types
|
|
62
63
|
.on('error', (err) => { console.error(err); });
|
|
63
64
|
}
|
|
64
65
|
disconnect() {
|
|
@@ -73,7 +74,7 @@ class UserSocketsServer {
|
|
|
73
74
|
this.socksByPath.clear();
|
|
74
75
|
}
|
|
75
76
|
verifyClient(info, cb) {
|
|
76
|
-
const path = url_1.parse(info.req.url).path;
|
|
77
|
+
const path = (0, url_1.parse)(info.req.url).path;
|
|
77
78
|
const socks = this.socksByPath.get(path);
|
|
78
79
|
if (!socks) {
|
|
79
80
|
cb(false, 405, `WebSocket upgrade is not provided on ${path}`);
|
|
@@ -89,7 +90,7 @@ class UserSocketsServer {
|
|
|
89
90
|
}
|
|
90
91
|
handleConnection(client, req) {
|
|
91
92
|
const userId = req.session.params.userId;
|
|
92
|
-
const path = url_1.parse(req.url).path;
|
|
93
|
+
const path = (0, url_1.parse)(req.url).path;
|
|
93
94
|
const socks = this.socksByPath.get(path);
|
|
94
95
|
if (!socks) {
|
|
95
96
|
client.close();
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
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/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.ServerEvents = void 0;
|
|
19
20
|
const ws_ipc_1 = require("../../lib-common/ipc/ws-ipc");
|
|
@@ -27,8 +28,8 @@ class ServerEvents {
|
|
|
27
28
|
Object.seal(this);
|
|
28
29
|
}
|
|
29
30
|
attachIPC(userId, ws) {
|
|
30
|
-
const comm = ws_ipc_1.makeJsonCommPoint(ws);
|
|
31
|
-
const ipc = ws_ipc_1.makeEventfulServer(this.ipcChannel, comm);
|
|
31
|
+
const comm = (0, ws_ipc_1.makeJsonCommPoint)(ws);
|
|
32
|
+
const ipc = (0, ws_ipc_1.makeEventfulServer)(this.ipcChannel, comm);
|
|
32
33
|
for (const channel of this.eventChannels) {
|
|
33
34
|
ipc.addEventGroup(channel, async () => { });
|
|
34
35
|
}
|
|
@@ -48,7 +49,7 @@ class ServerEvents {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
get eventsSink() {
|
|
51
|
-
return binding_1.bind(this, this.sendEvent);
|
|
52
|
+
return (0, binding_1.bind)(this, this.sendEvent);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
exports.ServerEvents = ServerEvents;
|
|
@@ -38,16 +38,16 @@ function provisioningApp(sessions, users, certifier, computeDHSharedKey) {
|
|
|
38
38
|
const app = express();
|
|
39
39
|
app.disable('etag');
|
|
40
40
|
// MailerId certificate provisioning routes
|
|
41
|
-
app.post('/' + api.pkl.START_URL_END, sessions.checkSession(), body_parsers_1.json('1kb'), start_exchange_1.startPKLogin(users.getUserParamsAndKey, sessions.generate, computeDHSharedKey));
|
|
42
|
-
app.post('/' + api.pkl.COMPL_URL_END, sessions.ensureOpenedSession(), body_parsers_1.binary('1kb'), complete_exchange_1.completePKLogin());
|
|
43
|
-
app.post('/' + api.certify.URL_END, sessions.ensureAuthorizedSession(), body_parsers_1.binary('16kb'), certify_1.certify(certifier.certify));
|
|
41
|
+
app.post('/' + api.pkl.START_URL_END, sessions.checkSession(), (0, body_parsers_1.json)('1kb'), (0, start_exchange_1.startPKLogin)(users.getUserParamsAndKey, sessions.generate, computeDHSharedKey));
|
|
42
|
+
app.post('/' + api.pkl.COMPL_URL_END, sessions.ensureOpenedSession(), (0, body_parsers_1.binary)('1kb'), (0, complete_exchange_1.completePKLogin)());
|
|
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
46
|
function makeApp(rootFolder, domain, certFile) {
|
|
47
47
|
const app = express();
|
|
48
|
-
const certProvisSessions = sessions_1.makeSessionFactory(2 * 60);
|
|
49
|
-
const users = users_1.makeFactory(rootFolder);
|
|
50
|
-
const certifier = certifier_1.makeSingleProcCertifier(domain, certFile);
|
|
48
|
+
const certProvisSessions = (0, sessions_1.makeSessionFactory)(2 * 60);
|
|
49
|
+
const users = (0, users_1.makeFactory)(rootFolder);
|
|
50
|
+
const certifier = (0, certifier_1.makeSingleProcCertifier)(domain, certFile);
|
|
51
51
|
app.use(PROVISIONING_PATH, provisioningApp(certProvisSessions, users, certifier, compute_login_dhshared_key_1.calcNaClBoxSharedKey));
|
|
52
52
|
// MailerId display of service parameters, as per protocol
|
|
53
53
|
app.get('/', (req, res) => {
|
|
@@ -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(error_handler_1.makeErrHandler());
|
|
65
|
+
app.use((0, error_handler_1.makeErrHandler)());
|
|
66
66
|
return app;
|
|
67
67
|
}
|
|
68
68
|
exports.makeApp = makeApp;
|
|
@@ -6,12 +6,10 @@ export interface RootCerts {
|
|
|
6
6
|
current: SignedLoad;
|
|
7
7
|
previous: SignedLoad[];
|
|
8
8
|
}
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
}
|
|
9
|
+
export declare type ICertify = (userPKey: JsonKey, address: string, validFor?: number) => {
|
|
10
|
+
userCert: SignedLoad;
|
|
11
|
+
provCert: SignedLoad;
|
|
12
|
+
};
|
|
15
13
|
export interface Certifier {
|
|
16
14
|
certify: ICertify;
|
|
17
15
|
getRootCert(): SignedLoad;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
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/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.makeSingleProcCertifier = exports.MAX_USER_CERT_VALIDITY = exports.PROVIDER_CERT_VALIDITY = exports.ROOT_CERT_VALIDITY = void 0;
|
|
19
20
|
const ecma_nacl_1 = require("ecma-nacl");
|
|
@@ -28,7 +29,7 @@ exports.MAX_USER_CERT_VALIDITY = 24 * 60 * 60;
|
|
|
28
29
|
function loadOrGenerateRootCert(domain, path) {
|
|
29
30
|
let certsAndKey;
|
|
30
31
|
try {
|
|
31
|
-
certsAndKey = JSON.parse(fs_1.readFileSync(path, { encoding: 'utf8', flag: 'r' }));
|
|
32
|
+
certsAndKey = JSON.parse((0, fs_1.readFileSync)(path, { encoding: 'utf8', flag: 'r' }));
|
|
32
33
|
}
|
|
33
34
|
catch (err) {
|
|
34
35
|
if (err.code === file_1.Code.notFound) {
|
|
@@ -38,13 +39,13 @@ function loadOrGenerateRootCert(domain, path) {
|
|
|
38
39
|
throw err;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
|
-
const certDomain = jwkeys_1.getKeyCert(certsAndKey.certs.current).issuer;
|
|
42
|
+
const certDomain = (0, jwkeys_1.getKeyCert)(certsAndKey.certs.current).issuer;
|
|
42
43
|
if (certDomain !== domain) {
|
|
43
44
|
throw new Error('Give domain ' + domain +
|
|
44
45
|
' does not equal domain in certificates file: ' + certDomain);
|
|
45
46
|
}
|
|
46
47
|
try {
|
|
47
|
-
const pkeyBytes = ecma_nacl_1.signing.extract_pkey(jwkeys_1.keyFromJson(certsAndKey.skey, mid_sigs_NaCl_Ed_1.KEY_USE.ROOT, ecma_nacl_1.signing.JWK_ALG_NAME, ecma_nacl_1.signing.SECRET_KEY_LENGTH).k);
|
|
48
|
+
const pkeyBytes = ecma_nacl_1.signing.extract_pkey((0, jwkeys_1.keyFromJson)(certsAndKey.skey, mid_sigs_NaCl_Ed_1.KEY_USE.ROOT, ecma_nacl_1.signing.JWK_ALG_NAME, ecma_nacl_1.signing.SECRET_KEY_LENGTH).k);
|
|
48
49
|
const rootPKey = {
|
|
49
50
|
k: pkeyBytes,
|
|
50
51
|
kid: certsAndKey.skey.kid,
|
|
@@ -70,7 +71,7 @@ function createFirstCert(domain, path, log) {
|
|
|
70
71
|
previous: []
|
|
71
72
|
}
|
|
72
73
|
};
|
|
73
|
-
fs_1.writeFileSync(path, JSON.stringify(toSave), { encoding: 'utf8', flag: 'wx' });
|
|
74
|
+
(0, fs_1.writeFileSync)(path, JSON.stringify(toSave), { encoding: 'utf8', flag: 'wx' });
|
|
74
75
|
return toSave;
|
|
75
76
|
}
|
|
76
77
|
function updateCert(domain, path, certs, log) {
|
|
@@ -85,7 +86,7 @@ function updateCert(domain, path, certs, log) {
|
|
|
85
86
|
previous: [certs.current].concat(certs.previous)
|
|
86
87
|
}
|
|
87
88
|
};
|
|
88
|
-
fs_1.writeFileSync(path, JSON.stringify(toSave), { encoding: 'utf8', flag: 'w' });
|
|
89
|
+
(0, fs_1.writeFileSync)(path, JSON.stringify(toSave), { encoding: 'utf8', flag: 'w' });
|
|
89
90
|
return toSave;
|
|
90
91
|
}
|
|
91
92
|
const UPDATE_PERIOD = 8 * 60 * 60;
|
|
@@ -112,7 +113,7 @@ function makeSingleProcCertifier(domain, certsPath) {
|
|
|
112
113
|
provCert = provider.cert;
|
|
113
114
|
Object.freeze(provCert);
|
|
114
115
|
certifier = mid_sigs_NaCl_Ed_1.idProvider.makeIdProviderCertifier(domain, exports.MAX_USER_CERT_VALIDITY, provider.skey);
|
|
115
|
-
updateTime = (jwkeys_1.getKeyCert(provCert).expiresAt - 2 * UPDATE_PERIOD) * 1000;
|
|
116
|
+
updateTime = ((0, jwkeys_1.getKeyCert)(provCert).expiresAt - 2 * UPDATE_PERIOD) * 1000;
|
|
116
117
|
}
|
|
117
118
|
updateCertifier();
|
|
118
119
|
const timer = setInterval(updateCertifier, UPDATE_PERIOD * 1000);
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
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/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.calcNaClBoxSharedKey = void 0;
|
|
19
20
|
/**
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
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/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.makeSessionFactory = void 0;
|
|
19
20
|
const mem_backed_sessions_factory_1 = require("../../lib-server/resources/mem-backed-sessions-factory");
|
|
@@ -27,9 +27,9 @@ const path_1 = require("path");
|
|
|
27
27
|
const server_data_folders_1 = require("../../lib-server/resources/server-data-folders");
|
|
28
28
|
async function getUser(rootFolder, userId) {
|
|
29
29
|
try {
|
|
30
|
-
const userFolder = server_data_folders_1.userDataInRootFolder(rootFolder, userId);
|
|
31
|
-
const midParamsPath = path_1.join(userFolder, 'info', 'mid-params');
|
|
32
|
-
const str = await async_fs_node_1.readFile(midParamsPath, { encoding: 'utf8' });
|
|
30
|
+
const userFolder = (0, server_data_folders_1.userDataInRootFolder)(rootFolder, userId);
|
|
31
|
+
const midParamsPath = (0, path_1.join)(userFolder, 'info', 'mid-params');
|
|
32
|
+
const str = await (0, async_fs_node_1.readFile)(midParamsPath, { encoding: 'utf8' });
|
|
33
33
|
return JSON.parse(str);
|
|
34
34
|
}
|
|
35
35
|
catch (exc) {
|
|
@@ -41,7 +41,7 @@ async function getUser(rootFolder, userId) {
|
|
|
41
41
|
}
|
|
42
42
|
const MID_KEY_USE = 'login-pub-key';
|
|
43
43
|
function extractPKeyBytes(pkey) {
|
|
44
|
-
return jwkeys_1.keyFromJson(pkey, MID_KEY_USE, ecma_nacl_1.box.JWK_ALG_NAME, ecma_nacl_1.box.KEY_LENGTH).k;
|
|
44
|
+
return (0, jwkeys_1.keyFromJson)(pkey, MID_KEY_USE, ecma_nacl_1.box.JWK_ALG_NAME, ecma_nacl_1.box.KEY_LENGTH).k;
|
|
45
45
|
}
|
|
46
46
|
function makeFactory(rootFolder) {
|
|
47
47
|
const factory = {
|
|
@@ -51,7 +51,7 @@ function certify(certifyingFunc) {
|
|
|
51
51
|
res.status(provisioning_1.certify.SC.malformed).send('Missing or incorrectly formatted payload.');
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
res.status(provisioning_1.certify.SC.ok).send(buffer_utils_1.toBuffer(encryptor.pack(buffer_utils_1.utf8.pack(JSON.stringify(signedCerts)))));
|
|
54
|
+
res.status(provisioning_1.certify.SC.ok).send((0, buffer_utils_1.toBuffer)(encryptor.pack(buffer_utils_1.utf8.pack(JSON.stringify(signedCerts)))));
|
|
55
55
|
session.close();
|
|
56
56
|
};
|
|
57
57
|
}
|
package/build/main.js
CHANGED
|
@@ -30,7 +30,7 @@ if (!confFile) {
|
|
|
30
30
|
console.error(`Configuration file is not given. It should be the first script argument.`);
|
|
31
31
|
process.exit(-1);
|
|
32
32
|
}
|
|
33
|
-
const conf = JSON.parse(fs_1.readFileSync(confFile, 'utf8'));
|
|
33
|
+
const conf = JSON.parse((0, fs_1.readFileSync)(confFile, 'utf8'));
|
|
34
34
|
const noop = () => { };
|
|
35
35
|
(async () => {
|
|
36
36
|
if (!conf.servicesConnect) {
|
|
@@ -39,14 +39,14 @@ const noop = () => { };
|
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
try {
|
|
42
|
-
const prevPidStr = await async_fs_node_1.readFile(PID_FILE, { encoding: 'utf8' });
|
|
42
|
+
const prevPidStr = await (0, async_fs_node_1.readFile)(PID_FILE, { encoding: 'utf8' });
|
|
43
43
|
const prevPid = Number.parseInt(prevPidStr);
|
|
44
44
|
if (!Number.isNaN(prevPid)) {
|
|
45
|
-
child_process_1.execSync(`kill -SIGTERM ${prevPid}`);
|
|
46
|
-
while (!!child_process_1.execSync(`ps ${prevPid} | grep ${prevPid}`)) {
|
|
47
|
-
await processes_1.sleep(1000);
|
|
45
|
+
(0, child_process_1.execSync)(`kill -SIGTERM ${prevPid}`);
|
|
46
|
+
while (!!(0, child_process_1.execSync)(`ps ${prevPid} | grep ${prevPid}`)) {
|
|
47
|
+
await (0, processes_1.sleep)(1000);
|
|
48
48
|
}
|
|
49
|
-
await async_fs_node_1.unlink(PID_FILE).catch(noop);
|
|
49
|
+
await (0, async_fs_node_1.unlink)(PID_FILE).catch(noop);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
catch (err) {
|
|
@@ -61,16 +61,16 @@ const noop = () => { };
|
|
|
61
61
|
}
|
|
62
62
|
app.stop().then(err => console.log(err));
|
|
63
63
|
app = undefined;
|
|
64
|
-
async_fs_node_1.unlink(PID_FILE).catch(noop);
|
|
64
|
+
(0, async_fs_node_1.unlink)(PID_FILE).catch(noop);
|
|
65
65
|
}
|
|
66
66
|
try {
|
|
67
67
|
app = new app_1.AppWithWSs();
|
|
68
|
-
app.use(services_1.servicesApp(conf));
|
|
69
|
-
app.use(services_1.adminApp(conf));
|
|
68
|
+
app.use((0, services_1.servicesApp)(conf));
|
|
69
|
+
app.use((0, services_1.adminApp)(conf));
|
|
70
70
|
const { hostname, port, sslOpts } = conf.servicesConnect;
|
|
71
71
|
await app.start(sslOpts, port, hostname);
|
|
72
72
|
console.log(`Started 3NWeb server at address "${hostname}", port ${port}, ${sslOpts ? 'via TLS' : 'without TLS, and requiring TLS reverse proxy infront.'}`);
|
|
73
|
-
fs_1.writeFileSync(PID_FILE, `${process.pid}`);
|
|
73
|
+
(0, fs_1.writeFileSync)(PID_FILE, `${process.pid}`);
|
|
74
74
|
process.on('SIGINT', stopProcess);
|
|
75
75
|
process.on('SIGTERM', stopProcess);
|
|
76
76
|
}
|
package/build/mock/dns.js
CHANGED
|
@@ -56,7 +56,7 @@ class DNSMock {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
// node's definition incorrectly describes callback argument
|
|
59
|
-
this.resolveTxt = binding_1.bind(this, this.mockResolve);
|
|
59
|
+
this.resolveTxt = (0, binding_1.bind)(this, this.mockResolve);
|
|
60
60
|
Object.freeze(this);
|
|
61
61
|
}
|
|
62
62
|
mockResolve(domain, callback) {
|