spec-3nweb-server 1.7.13 → 1.8.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 +3 -3
- package/build/asmail/asmail-app.js +3 -3
- package/build/asmail/resources/inbox.d.ts +3 -1
- package/build/asmail/resources/inbox.js +23 -2
- package/build/asmail/resources/recipients.d.ts +1 -1
- package/build/asmail/resources/recipients.js +2 -2
- package/build/asmail/retrieval.js +2 -2
- package/build/asmail/routes/retrieval/list-messages.js +19 -1
- package/build/{config/cli → cli}/index.js +1 -1
- package/build/config/letsencrypt.js +5 -3
- package/build/lib-common/service-api/3nstorage/root-route.d.ts +5 -0
- package/build/lib-common/service-api/3nstorage/root-route.js +18 -0
- package/build/lib-common/service-api/asmail/retrieval.d.ts +10 -3
- package/build/lib-common/service-api/asmail/retrieval.js +14 -5
- package/build/lib-common/service-api/asmail/root-route.d.ts +5 -0
- package/build/lib-common/service-api/asmail/root-route.js +18 -0
- package/build/lib-common/service-api/mailer-id/root-route.d.ts +6 -0
- package/build/lib-common/service-api/mailer-id/root-route.js +18 -0
- package/build/lib-server/resources/mailerid-authorizer.d.ts +6 -1
- package/build/lib-server/resources/mailerid-authorizer.js +6 -5
- package/build/lib-server/routes/sessions/mid-auth.js +3 -3
- package/build/mailerId/mailerId-app.d.ts +5 -1
- package/build/mailerId/mailerId-app.js +9 -3
- package/build/main.js +1 -1
- package/build/services.d.ts +2 -0
- package/build/services.js +10 -4
- package/package.json +1 -1
- /package/build/{config/cli → cli}/index.d.ts +0 -0
- /package/build/{config/cli → cli}/run-cmd.d.ts +0 -0
- /package/build/{config/cli → cli}/run-cmd.js +0 -0
- /package/build/{config/cli → cli}/show-sample-config.d.ts +0 -0
- /package/build/{config/cli → cli}/show-sample-config.js +0 -0
- /package/build/{config/cli → cli}/signup-cmd.d.ts +0 -0
- /package/build/{config/cli → cli}/signup-cmd.js +0 -0
- /package/build/{config/cli → cli}/user-cmd.d.ts +0 -0
- /package/build/{config/cli → cli}/user-cmd.js +0 -0
- /package/build/{config/cli → cli}/utils.d.ts +0 -0
- /package/build/{config/cli → cli}/utils.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2016, 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2016, 2020, 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
|
|
@@ -35,8 +35,8 @@ function setupStaticStorageEntryRoute(app) {
|
|
|
35
35
|
path = path + '/';
|
|
36
36
|
}
|
|
37
37
|
const json = {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
owner: path + PATHS.owner.substring(1),
|
|
39
|
+
shared: path + PATHS.shared.substring(1)
|
|
40
40
|
};
|
|
41
41
|
// the following implicitly sets content type application/json
|
|
42
42
|
res.status(200).json(json);
|
|
@@ -38,9 +38,9 @@ function setupStaticEntryRoute(app) {
|
|
|
38
38
|
path = path + '/';
|
|
39
39
|
}
|
|
40
40
|
const json = {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
delivery: path + PATHS.delivery.substring(1),
|
|
42
|
+
retrieval: path + PATHS.retrieval.substring(1),
|
|
43
|
+
config: path + PATHS.config.substring(1)
|
|
44
44
|
};
|
|
45
45
|
// the following implicitly sets content type application/json
|
|
46
46
|
res.status(200).json(json);
|
|
@@ -75,9 +75,11 @@ export declare class Inbox extends UserFiles<InboxParams> {
|
|
|
75
75
|
completeMsgDelivery(msgId: string): Promise<void>;
|
|
76
76
|
private areAllMsgObjsComplete;
|
|
77
77
|
/**
|
|
78
|
+
* @param fromTS
|
|
79
|
+
* @param toTS
|
|
78
80
|
* @return a promise, resolvable to a list of available message ids.
|
|
79
81
|
*/
|
|
80
|
-
getMsgIds(): Promise<retrievalApi.listMsgs.Reply>;
|
|
82
|
+
getMsgIds(fromTS: number | undefined, toTS: number | undefined): Promise<retrievalApi.listMsgs.Reply>;
|
|
81
83
|
/**
|
|
82
84
|
* This method returns parameters of an incomplete message, identified
|
|
83
85
|
* by a given id.
|
|
@@ -237,10 +237,31 @@ class Inbox extends user_files_1.UserFiles {
|
|
|
237
237
|
return true;
|
|
238
238
|
}
|
|
239
239
|
/**
|
|
240
|
+
* @param fromTS
|
|
241
|
+
* @param toTS
|
|
240
242
|
* @return a promise, resolvable to a list of available message ids.
|
|
241
243
|
*/
|
|
242
|
-
getMsgIds() {
|
|
243
|
-
|
|
244
|
+
async getMsgIds(fromTS, toTS) {
|
|
245
|
+
// XXX this isn't efficient, and needs sqlite-powered index
|
|
246
|
+
const lst = await fs.readdir(this.metas.readyMsgsFolder);
|
|
247
|
+
if ((fromTS === undefined) && (toTS === undefined)) {
|
|
248
|
+
return lst;
|
|
249
|
+
}
|
|
250
|
+
const filteredLst = [];
|
|
251
|
+
for (const msgId of lst) {
|
|
252
|
+
try {
|
|
253
|
+
const { deliveryStart } = await this.metas.get(msgId, true);
|
|
254
|
+
if (fromTS && (deliveryStart < fromTS)) {
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (toTS && (toTS < deliveryStart)) {
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
filteredLst.push(msgId);
|
|
261
|
+
}
|
|
262
|
+
catch (exc) { }
|
|
263
|
+
}
|
|
264
|
+
return filteredLst;
|
|
244
265
|
}
|
|
245
266
|
/**
|
|
246
267
|
* This method returns parameters of an incomplete message, identified
|
|
@@ -79,7 +79,7 @@ export interface MsgRetrieval {
|
|
|
79
79
|
* This returns a promise, resolvable to array with ids of available
|
|
80
80
|
* messages. Rejected promise may have a string error code from SC.
|
|
81
81
|
*/
|
|
82
|
-
getMsgIds: (userId: string) => Promise<retrievalApi.listMsgs.Reply>;
|
|
82
|
+
getMsgIds: (userId: string, fromTS: number | undefined, toTS: number | undefined) => Promise<retrievalApi.listMsgs.Reply>;
|
|
83
83
|
/**
|
|
84
84
|
* This returns a promise, resolvable to message meta.
|
|
85
85
|
* Rejected promise may have a string error code from SC.
|
|
@@ -284,9 +284,9 @@ function makeRecipients(rootFolder, writeBufferSize, readBufferSize) {
|
|
|
284
284
|
Object.freeze(delivery);
|
|
285
285
|
const retrieval = {
|
|
286
286
|
exists: config.exists,
|
|
287
|
-
getMsgIds: async (userId) => {
|
|
287
|
+
getMsgIds: async (userId, fromTS, toTS) => {
|
|
288
288
|
const inbox = await getInbox(userId);
|
|
289
|
-
return inbox.getMsgIds();
|
|
289
|
+
return inbox.getMsgIds(fromTS, toTS);
|
|
290
290
|
},
|
|
291
291
|
getMsgMeta: async (userId, msgId) => {
|
|
292
292
|
const inbox = await getInbox(userId);
|
|
@@ -46,11 +46,11 @@ function setWSPart(app, sessions, recipients) {
|
|
|
46
46
|
function setHttpPart(app, domain, sessions, recipients, midAuthorizer) {
|
|
47
47
|
app.disable('etag');
|
|
48
48
|
// Login
|
|
49
|
-
(0, mid_access_1.addMailerIdLoginRoutes)(app, domain, '/' + api.midLogin.
|
|
49
|
+
(0, mid_access_1.addMailerIdLoginRoutes)(app, domain, '/' + api.midLogin.MID_URL_PART, sessions, recipients.exists, midAuthorizer);
|
|
50
50
|
// *** Require authorized session for everything below ***
|
|
51
51
|
app.use(sessions.ensureAuthorizedSession());
|
|
52
52
|
app.post('/' + api.closeSession.URL_END, (0, body_parsers_1.emptyBody)(), (0, close_1.closeSession)());
|
|
53
|
-
app.get('/' + api.listMsgs.
|
|
53
|
+
app.get('/' + api.listMsgs.EXPRESS_URL_END, (0, list_messages_1.listMsgIds)(recipients.getMsgIds));
|
|
54
54
|
app.get('/' + api.msgMetadata.EXPRESS_URL_END, (0, get_message_meta_1.getMsgMeta)(recipients.getMsgMeta));
|
|
55
55
|
app.delete('/' + api.rmMsg.EXPRESS_URL_END, (0, remove_message_1.deleteMsg)(recipients.deleteMsg));
|
|
56
56
|
app.get('/' + api.msgObj.EXPRESS_URL_END, (0, get_message_obj_1.getMsgObj)(recipients.getObj));
|
|
@@ -22,8 +22,14 @@ const retrieval_1 = require("../../../lib-common/service-api/asmail/retrieval");
|
|
|
22
22
|
function listMsgIds(listMsgIdsFunc) {
|
|
23
23
|
return async (req, res, next) => {
|
|
24
24
|
const userId = req.session.params.userId;
|
|
25
|
+
const opts = extractQueryOptions(req);
|
|
26
|
+
if (!opts) {
|
|
27
|
+
res.status(retrieval_1.ERR_SC.malformed).send("Bad query parameters");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
25
30
|
try {
|
|
26
|
-
const
|
|
31
|
+
const { from, to } = opts;
|
|
32
|
+
const msgIds = await listMsgIdsFunc(userId, from, to);
|
|
27
33
|
res.status(retrieval_1.listMsgs.SC.ok).json(msgIds);
|
|
28
34
|
}
|
|
29
35
|
catch (err) {
|
|
@@ -41,4 +47,16 @@ function listMsgIds(listMsgIdsFunc) {
|
|
|
41
47
|
};
|
|
42
48
|
}
|
|
43
49
|
exports.listMsgIds = listMsgIds;
|
|
50
|
+
function extractQueryOptions(req) {
|
|
51
|
+
const query = req.query;
|
|
52
|
+
const from = (query.from ? parseInt(query.from) : undefined);
|
|
53
|
+
if ((from !== undefined) && (isNaN(from) || (from <= 0))) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const to = (query.to ? parseInt(query.to) : undefined);
|
|
57
|
+
if ((to !== undefined) && (isNaN(to) || (to <= 0))) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
return { from, to };
|
|
61
|
+
}
|
|
44
62
|
Object.freeze(exports);
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.parseProcessArgv = void 0;
|
|
20
|
-
const default_confs_1 = require("../default-confs");
|
|
20
|
+
const default_confs_1 = require("../config/default-confs");
|
|
21
21
|
const run_cmd_1 = require("./run-cmd");
|
|
22
22
|
const show_sample_config_1 = require("./show-sample-config");
|
|
23
23
|
const signup_cmd_1 = require("./signup-cmd");
|
|
@@ -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,13 +19,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.sslOptsFromConfig = void 0;
|
|
20
20
|
const fs_1 = require("fs");
|
|
21
21
|
const path_1 = require("path");
|
|
22
|
+
const LETSENCRYPT_CERT_FILE = 'fullchain.pem';
|
|
23
|
+
const LETSENCRYPT_KEY_FILE = 'privkey.pem';
|
|
22
24
|
function sslOptsFromConfig(letsencrypt, sslOpts, skipReloadOnCertsChange) {
|
|
23
25
|
if (!sslOpts) {
|
|
24
26
|
sslOpts = {};
|
|
25
27
|
}
|
|
26
28
|
if (letsencrypt) {
|
|
27
|
-
sslOpts.cert = (0, fs_1.readFileSync)((0, path_1.join)(letsencrypt,
|
|
28
|
-
sslOpts.key = (0, fs_1.readFileSync)((0, path_1.join)(letsencrypt,
|
|
29
|
+
sslOpts.cert = (0, fs_1.readFileSync)((0, path_1.join)(letsencrypt, LETSENCRYPT_CERT_FILE));
|
|
30
|
+
sslOpts.key = (0, fs_1.readFileSync)((0, path_1.join)(letsencrypt, LETSENCRYPT_KEY_FILE));
|
|
29
31
|
if (skipReloadOnCertsChange) {
|
|
30
32
|
return { sslOpts };
|
|
31
33
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 });
|
|
@@ -12,13 +12,20 @@ export declare const ERR_SC: {
|
|
|
12
12
|
server: number;
|
|
13
13
|
};
|
|
14
14
|
export declare namespace midLogin {
|
|
15
|
-
const
|
|
15
|
+
const MID_URL_PART = "login/mailerid/";
|
|
16
|
+
const START_URL_END: string;
|
|
17
|
+
const AUTH_URL_END: string;
|
|
16
18
|
}
|
|
17
19
|
export declare namespace closeSession {
|
|
18
20
|
const URL_END = "close-session";
|
|
19
21
|
}
|
|
22
|
+
export interface ListMsgsOpts {
|
|
23
|
+
from?: number;
|
|
24
|
+
to?: number;
|
|
25
|
+
}
|
|
20
26
|
export declare namespace listMsgs {
|
|
21
|
-
const
|
|
27
|
+
const EXPRESS_URL_END = "msg/ids";
|
|
28
|
+
function genUrlEnd(opts?: ListMsgsOpts): string;
|
|
22
29
|
interface Reply extends Array<string> {
|
|
23
30
|
}
|
|
24
31
|
const SC: {
|
|
@@ -35,7 +42,7 @@ export declare namespace rmMsg {
|
|
|
35
42
|
}
|
|
36
43
|
export interface ObjSize {
|
|
37
44
|
header: number;
|
|
38
|
-
segments: number;
|
|
45
|
+
segments: number | undefined;
|
|
39
46
|
}
|
|
40
47
|
export interface ObjStatus {
|
|
41
48
|
completed?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015, 2017 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015, 2017, 2019, 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
|
|
@@ -13,8 +13,7 @@
|
|
|
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/>.
|
|
17
|
-
*/
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
18
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
18
|
exports.msgMainObjRecieved = exports.msgRecievedCompletely = exports.wsEventChannel = exports.msgObj = exports.sanitizedMeta = exports.msgMetadata = exports.rmMsg = exports.listMsgs = exports.closeSession = exports.midLogin = exports.ERR_SC = exports.HTTP_HEADER = exports.BIN_TYPE = void 0;
|
|
20
19
|
/**
|
|
@@ -38,7 +37,9 @@ exports.ERR_SC = {
|
|
|
38
37
|
Object.freeze(exports.ERR_SC);
|
|
39
38
|
var midLogin;
|
|
40
39
|
(function (midLogin) {
|
|
41
|
-
midLogin.
|
|
40
|
+
midLogin.MID_URL_PART = 'login/mailerid/';
|
|
41
|
+
midLogin.START_URL_END = midLogin.MID_URL_PART + midApi.startSession.URL_END;
|
|
42
|
+
midLogin.AUTH_URL_END = midLogin.MID_URL_PART + midApi.authSession.URL_END;
|
|
42
43
|
})(midLogin = exports.midLogin || (exports.midLogin = {}));
|
|
43
44
|
Object.freeze(midLogin);
|
|
44
45
|
var closeSession;
|
|
@@ -48,7 +49,12 @@ var closeSession;
|
|
|
48
49
|
Object.freeze(closeSession);
|
|
49
50
|
var listMsgs;
|
|
50
51
|
(function (listMsgs) {
|
|
51
|
-
listMsgs.
|
|
52
|
+
listMsgs.EXPRESS_URL_END = 'msg/ids';
|
|
53
|
+
function genUrlEnd(opts) {
|
|
54
|
+
let optStr = (opts ? '?' + (0, querystring_1.stringify)(opts) : '');
|
|
55
|
+
return `msg/ids${optStr}`;
|
|
56
|
+
}
|
|
57
|
+
listMsgs.genUrlEnd = genUrlEnd;
|
|
52
58
|
listMsgs.SC = {
|
|
53
59
|
ok: 200,
|
|
54
60
|
};
|
|
@@ -144,4 +150,7 @@ var msgMainObjRecieved;
|
|
|
144
150
|
msgMainObjRecieved.EVENT_NAME = 'msg-main-obj-received';
|
|
145
151
|
})(msgMainObjRecieved = exports.msgMainObjRecieved || (exports.msgMainObjRecieved = {}));
|
|
146
152
|
Object.freeze(msgMainObjRecieved);
|
|
153
|
+
// XXX add event about message removal
|
|
154
|
+
// it is useful in multi-device case, pass implicit implicit signal that will
|
|
155
|
+
// have context-specific meaning.
|
|
147
156
|
Object.freeze(exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
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 });
|
|
@@ -0,0 +1,18 @@
|
|
|
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 });
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
import { SignedLoad } from '../../lib-common/jwkeys';
|
|
1
2
|
import { MidAuthorizer } from '../routes/sessions/mid-auth';
|
|
2
|
-
export declare function validator(): MidAuthorizer;
|
|
3
|
+
export declare function validator(ownMidService: OwnMidService | undefined): MidAuthorizer;
|
|
4
|
+
export interface OwnMidService {
|
|
5
|
+
domain: string;
|
|
6
|
+
getRoot: () => SignedLoad;
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2016, 2019 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2016, 2019, 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
|
|
@@ -62,11 +62,11 @@ function getRootCert(serviceURL) {
|
|
|
62
62
|
}
|
|
63
63
|
// TODO need to add caching of certs using domain->(kid->cert)
|
|
64
64
|
// (this will speed things up)
|
|
65
|
-
function validator() {
|
|
66
|
-
return (rpDomain, sessionId, userId, assertion, userCert, provCert) => validate(rpDomain, sessionId, userId, assertion, userCert, provCert);
|
|
65
|
+
function validator(ownMidService) {
|
|
66
|
+
return (rpDomain, sessionId, userId, assertion, userCert, provCert) => validate(rpDomain, sessionId, userId, assertion, userCert, provCert, ownMidService);
|
|
67
67
|
}
|
|
68
68
|
exports.validator = validator;
|
|
69
|
-
async function validate(rpDomain, sessionId, userId, assertion, userCert, provCert) {
|
|
69
|
+
async function validate(rpDomain, sessionId, userId, assertion, userCert, provCert, ownMidService) {
|
|
70
70
|
const validAt = Date.now() / 1000;
|
|
71
71
|
try {
|
|
72
72
|
// check that certificate is for the user
|
|
@@ -83,7 +83,8 @@ async function validate(rpDomain, sessionId, userId, assertion, userCert, provCe
|
|
|
83
83
|
return false;
|
|
84
84
|
}
|
|
85
85
|
// get root certificate and check the whole chain
|
|
86
|
-
const rootCert =
|
|
86
|
+
const rootCert = ((ownMidService && (issuer === ownMidService.domain)) ?
|
|
87
|
+
ownMidService.getRoot() : await getRootCert(serviceURL));
|
|
87
88
|
const assertInfo = mid.relyingParty.verifyAssertion(assertion, { user: userCert, prov: provCert, root: rootCert }, issuer, validAt);
|
|
88
89
|
if ((assertInfo.relyingPartyDomain === rpDomain)
|
|
89
90
|
&& (assertInfo.sessionId === sessionId)) {
|
|
@@ -36,9 +36,9 @@ function midLogin(relyingPartyDomain, midAuthorizingFunc) {
|
|
|
36
36
|
}
|
|
37
37
|
const rb = req.body;
|
|
38
38
|
const sessionId = req.session.id;
|
|
39
|
-
if (!(0, jwkeys_1.isLikeSignedMailerIdAssertion)(rb.assertion)
|
|
40
|
-
!(0, jwkeys_1.isLikeSignedKeyCert)(rb.userCert)
|
|
41
|
-
!(0, 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)) {
|
|
42
42
|
res.sendStatus(login_1.ERR_SC.malformed);
|
|
43
43
|
req.session.close();
|
|
44
44
|
return;
|
|
@@ -4,4 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import * as express from 'express';
|
|
6
6
|
import { ErrLogger } from '../lib-server/middleware/error-handler';
|
|
7
|
-
|
|
7
|
+
import { OwnMidService } from '../lib-server/resources/mailerid-authorizer';
|
|
8
|
+
export declare function makeMailerIdApp(rootFolder: string, domain: string, certFile: string, errLogger?: ErrLogger): {
|
|
9
|
+
app: express.Express;
|
|
10
|
+
ownService: OwnMidService;
|
|
11
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2016, 2020, 2024 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2016, 2020, 2024 - 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
|
|
@@ -59,12 +59,18 @@ function makeMailerIdApp(rootFolder, domain, certFile, errLogger) {
|
|
|
59
59
|
const json = {
|
|
60
60
|
"current-cert": certifier.getRootCert(),
|
|
61
61
|
"previous-certs": certifier.getPrevCerts(),
|
|
62
|
-
|
|
62
|
+
provisioning: path + PROVISIONING_PATH.substring(1)
|
|
63
63
|
};
|
|
64
64
|
res.status(200).json(json); // content type application/json
|
|
65
65
|
});
|
|
66
66
|
app.use((0, error_handler_1.makeErrHandler)(errLogger));
|
|
67
|
-
return
|
|
67
|
+
return {
|
|
68
|
+
app,
|
|
69
|
+
ownService: {
|
|
70
|
+
domain,
|
|
71
|
+
getRoot: () => certifier.getRootCert()
|
|
72
|
+
}
|
|
73
|
+
};
|
|
68
74
|
}
|
|
69
75
|
exports.makeMailerIdApp = makeMailerIdApp;
|
|
70
76
|
Object.freeze(exports);
|
package/build/main.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
const cli_1 = require("./
|
|
20
|
+
const cli_1 = require("./cli");
|
|
21
21
|
const from_yaml_1 = require("./config/from-yaml");
|
|
22
22
|
const letsencrypt_1 = require("./config/letsencrypt");
|
|
23
23
|
const lib_1 = require("./lib");
|
package/build/services.d.ts
CHANGED
package/build/services.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2017, 2020, 2024 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2017, 2020, 2024 - 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
|
|
@@ -26,16 +26,22 @@ const signup_app_1 = require("./signup/signup-app");
|
|
|
26
26
|
const error_handler_1 = require("./lib-server/middleware/error-handler");
|
|
27
27
|
const locker_app_1 = require("./locker/locker-app");
|
|
28
28
|
function servicesApp(conf, errLogger, logSetup) {
|
|
29
|
+
var _a;
|
|
29
30
|
if (!conf.enabledServices || (typeof conf.enabledServices !== 'object')) {
|
|
30
31
|
throw new Error('Missing enabled-services sections in confs.');
|
|
31
32
|
}
|
|
32
33
|
const app = new app_1.AppWithWSs();
|
|
33
|
-
|
|
34
|
+
let midAuthorizer; // share, allowing for caching of certs
|
|
34
35
|
if (conf.enabledServices.mailerId) {
|
|
35
|
-
app
|
|
36
|
+
const { app: midApp, ownService } = (0, mailerId_app_1.makeMailerIdApp)(conf.rootFolder, conf.domain, conf.mailerId.certs, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('MailerId') : errLogger);
|
|
37
|
+
app.http.use('/mailerid', midApp);
|
|
36
38
|
if (logSetup === 'console') {
|
|
37
39
|
console.log(`Enabled MailerId service with provider domain ${conf.domain}`);
|
|
38
40
|
}
|
|
41
|
+
midAuthorizer = (0, mailerid_authorizer_1.validator)(ownService);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
midAuthorizer = (0, mailerid_authorizer_1.validator)(undefined);
|
|
39
45
|
}
|
|
40
46
|
if (conf.enabledServices.asmail) {
|
|
41
47
|
app.use('/asmail', (0, asmail_app_1.makeASMailApp)(conf.rootFolder, conf.domain, midAuthorizer, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('ASMail') : errLogger));
|
|
@@ -49,7 +55,7 @@ function servicesApp(conf, errLogger, logSetup) {
|
|
|
49
55
|
console.log(`Enabled 3NStorage service with provider domain ${conf.domain}`);
|
|
50
56
|
}
|
|
51
57
|
}
|
|
52
|
-
if (conf.
|
|
58
|
+
if ((_a = conf.auxiliaryServices) === null || _a === void 0 ? void 0 : _a.locker) {
|
|
53
59
|
app.use('/locker', (0, locker_app_1.makeLockerApp)(conf.rootFolder, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('Locker') : errLogger));
|
|
54
60
|
if (logSetup === 'console') {
|
|
55
61
|
console.log(`Enabled Locker service`);
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|