spec-3nweb-server 1.7.0 → 1.7.5

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.
Files changed (144) hide show
  1. package/build/3nstorage/3nstorage-app.d.ts +4 -1
  2. package/build/3nstorage/3nstorage-app.js +18 -9
  3. package/build/3nstorage/owner.d.ts +3 -2
  4. package/build/3nstorage/owner.js +39 -32
  5. package/build/3nstorage/resources/sessions.d.ts +2 -2
  6. package/build/3nstorage/resources/sessions.js +2 -1
  7. package/build/3nstorage/resources/store.d.ts +6 -6
  8. package/build/3nstorage/resources/store.js +3 -12
  9. package/build/3nstorage/resources/users.d.ts +16 -16
  10. package/build/3nstorage/resources/users.js +13 -16
  11. package/build/3nstorage/shared.d.ts +2 -6
  12. package/build/3nstorage/shared.js +5 -9
  13. package/build/asmail/asmail-app.d.ts +1 -1
  14. package/build/asmail/asmail-app.js +3 -3
  15. package/build/asmail/config.d.ts +2 -6
  16. package/build/asmail/config.js +20 -12
  17. package/build/asmail/delivery.d.ts +2 -6
  18. package/build/asmail/delivery.js +0 -6
  19. package/build/asmail/resources/delivery-sessions.d.ts +3 -3
  20. package/build/asmail/resources/delivery-sessions.js +1 -2
  21. package/build/asmail/resources/inbox.d.ts +26 -35
  22. package/build/asmail/resources/inbox.js +15 -59
  23. package/build/asmail/resources/recipients.d.ts +39 -21
  24. package/build/asmail/resources/recipients.js +62 -22
  25. package/build/asmail/resources/sessions.d.ts +2 -2
  26. package/build/asmail/retrieval.d.ts +2 -2
  27. package/build/asmail/retrieval.js +11 -18
  28. package/build/asmail/routes/delivery/sender-authorization.d.ts +1 -1
  29. package/build/asmail/routes/delivery/start-session.d.ts +1 -1
  30. package/build/config/letsencrypt.d.ts +1 -1
  31. package/build/config/signup.d.ts +1 -1
  32. package/build/config/signup.js +2 -1
  33. package/build/lib-common/assert.js +2 -1
  34. package/build/lib-common/buffer-utils.js +2 -1
  35. package/build/lib-common/byte-streaming/common.d.ts +2 -2
  36. package/build/lib-common/byte-streaming/common.js +16 -16
  37. package/build/lib-common/bytes-equal.js +2 -1
  38. package/build/lib-common/exceptions/error.js +2 -1
  39. package/build/lib-common/exceptions/file.d.ts +1 -1
  40. package/build/lib-common/exceptions/file.js +2 -1
  41. package/build/lib-common/exceptions/http.js +2 -1
  42. package/build/lib-common/ipc/generic-ipc.d.ts +7 -7
  43. package/build/lib-common/ipc/generic-ipc.js +20 -20
  44. package/build/lib-common/ipc/ws-ipc.js +2 -1
  45. package/build/lib-common/json-equal.js +2 -1
  46. package/build/lib-common/json-utils.js +2 -1
  47. package/build/lib-common/jwkeys.js +2 -1
  48. package/build/lib-common/map-of-sets.js +2 -1
  49. package/build/lib-common/mid-sigs-NaCl-Ed.js +2 -1
  50. package/build/lib-common/objs-on-disk/file-layout.d.ts +4 -4
  51. package/build/lib-common/objs-on-disk/file-layout.js +2 -1
  52. package/build/lib-common/objs-on-disk/obj-file.js +2 -1
  53. package/build/lib-common/objs-on-disk/utils.d.ts +3 -3
  54. package/build/lib-common/objs-on-disk/v1-obj-file-format.js +2 -1
  55. package/build/lib-common/processes.d.ts +1 -1
  56. package/build/lib-common/processes.js +2 -1
  57. package/build/lib-common/random-node.js +2 -1
  58. package/build/lib-common/service-api/3nstorage/owner.d.ts +1 -3
  59. package/build/lib-common/service-api/3nstorage/owner.js +2 -4
  60. package/build/lib-common/service-api/asmail/config.d.ts +1 -3
  61. package/build/lib-common/service-api/asmail/config.js +4 -5
  62. package/build/lib-common/service-api/asmail/delivery.js +2 -1
  63. package/build/lib-common/service-api/asmail/retrieval.d.ts +1 -3
  64. package/build/lib-common/service-api/asmail/retrieval.js +3 -4
  65. package/build/lib-common/service-api/ipc-api.d.ts +6 -6
  66. package/build/lib-common/service-api/ipc-api.js +2 -1
  67. package/build/lib-common/service-api/locker.d.ts +17 -0
  68. package/build/lib-common/service-api/locker.js +31 -0
  69. package/build/lib-common/service-api/mailer-id/login.js +2 -1
  70. package/build/lib-common/service-api/mailer-id/provisioning.d.ts +3 -4
  71. package/build/lib-common/service-api/mailer-id/provisioning.js +3 -12
  72. package/build/lib-common/service-api/pub-key-login.js +2 -1
  73. package/build/lib-common/service-api/web-socket-base.d.ts +1 -1
  74. package/build/lib-common/service-api/web-socket-base.js +2 -1
  75. package/build/lib-common/session-encryptor.js +2 -1
  76. package/build/lib-common/time-window-cache.js +2 -1
  77. package/build/lib-server/mid-access.d.ts +5 -0
  78. package/build/lib-server/mid-access.js +28 -0
  79. package/build/lib-server/middleware/body-parsers.d.ts +7 -7
  80. package/build/lib-server/middleware/body-parsers.js +14 -14
  81. package/build/lib-server/middleware/error-handler.d.ts +1 -1
  82. package/build/lib-server/pkl-access.d.ts +4 -0
  83. package/build/lib-server/pkl-access.js +28 -0
  84. package/build/lib-server/resources/dns.d.ts +1 -1
  85. package/build/lib-server/resources/dns.js +2 -1
  86. package/build/lib-server/resources/mailerid-authorizer.js +5 -6
  87. package/build/lib-server/resources/server-data-folders.d.ts +1 -0
  88. package/build/lib-server/resources/server-data-folders.js +9 -4
  89. package/build/{mailerId/resources/compute-login-dhshared-key.js → lib-server/resources/server-key-for-pkl-challenge.js} +5 -5
  90. package/build/lib-server/resources/sessions.d.ts +2 -2
  91. package/build/lib-server/resources/sessions.js +7 -7
  92. package/build/lib-server/resources/user-files.d.ts +4 -4
  93. package/build/lib-server/resources/user-files.js +4 -2
  94. package/build/lib-server/routes/pub-key-login/start-exchange.d.ts +4 -4
  95. package/build/lib-server/routes/sessions/close.js +2 -1
  96. package/build/lib-server/routes/sessions/mid-auth.d.ts +1 -1
  97. package/build/lib-server/routes/sessions/start.d.ts +4 -4
  98. package/build/lib-server/web-sockets/app.d.ts +1 -1
  99. package/build/lib-server/web-sockets/app.js +8 -9
  100. package/build/lib-server/web-sockets/server-events.d.ts +1 -1
  101. package/build/lib-server/web-sockets/server-events.js +1 -2
  102. package/build/lib.d.ts +1 -2
  103. package/build/lib.js +2 -5
  104. package/build/locker/locker-app.d.ts +3 -0
  105. package/build/locker/locker-app.js +41 -0
  106. package/build/locker/resources/lockers.d.ts +0 -0
  107. package/build/{lib-common/binding.js → locker/resources/lockers.js} +3 -10
  108. package/build/locker/resources/sessions.d.ts +9 -0
  109. package/build/locker/resources/sessions.js +33 -0
  110. package/build/locker/routes/create-locker.d.ts +4 -0
  111. package/build/locker/routes/create-locker.js +37 -0
  112. package/build/mailerId/mailerId-app.d.ts +1 -1
  113. package/build/mailerId/mailerId-app.js +12 -11
  114. package/build/mailerId/resources/certifier.d.ts +1 -1
  115. package/build/mailerId/resources/sessions.d.ts +1 -1
  116. package/build/mailerId/routes/certify.js +2 -1
  117. package/build/main.js +1 -1
  118. package/build/mock/dns.js +3 -4
  119. package/build/mock/mock-as-child-proc.js +2 -2
  120. package/build/mock/node-child-ipc.d.ts +2 -2
  121. package/build/mock/node-child-ipc.js +2 -1
  122. package/build/mock/run-in-proc.js +2 -2
  123. package/build/mock/tls-options.js +2 -1
  124. package/build/services.d.ts +2 -1
  125. package/build/services.js +22 -11
  126. package/build/{admin → signup}/resources/users.d.ts +3 -3
  127. package/build/{admin → signup}/resources/users.js +3 -4
  128. package/build/{admin/admin-app.d.ts → signup/signup-app.d.ts} +1 -1
  129. package/build/{admin/admin-app.js → signup/signup-app.js} +6 -16
  130. package/build/{admin → signup}/signup-tokens.d.ts +1 -1
  131. package/package.json +3 -3
  132. package/build/config/from-env.d.ts +0 -9
  133. package/build/config/from-env.js +0 -117
  134. package/build/lib-common/binding.d.ts +0 -1
  135. package/build/run.d.ts +0 -1
  136. package/build/run.js +0 -45
  137. /package/build/{mailerId/resources/compute-login-dhshared-key.d.ts → lib-server/resources/server-key-for-pkl-challenge.d.ts} +0 -0
  138. /package/build/{admin → signup}/routes/add.d.ts +0 -0
  139. /package/build/{admin → signup}/routes/add.js +0 -0
  140. /package/build/{admin → signup}/routes/get-available-addresses.d.ts +0 -0
  141. /package/build/{admin → signup}/routes/get-available-addresses.js +0 -0
  142. /package/build/{admin → signup}/routes/get-available-domains.d.ts +0 -0
  143. /package/build/{admin → signup}/routes/get-available-domains.js +0 -0
  144. /package/build/{admin → signup}/signup-tokens.js +0 -0
package/build/lib.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export { AppWithWSs } from './lib-server/web-sockets/app';
2
- export { Configurations, servicesApp, adminApp } from './services';
3
- export { getConfsFromEnv, getBindParamsFromEnv } from './config/from-env';
2
+ export { Configurations, servicesApp, accountsApp } from './services';
4
3
  export { addSingleUserSignup } from './config/signup';
5
4
  export import errors = require('./lib-server/middleware/error-handler');
6
5
  export * as mock from './mock/run-in-proc';
package/build/lib.js CHANGED
@@ -16,15 +16,12 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.mock = exports.addSingleUserSignup = exports.getBindParamsFromEnv = exports.getConfsFromEnv = exports.adminApp = exports.servicesApp = exports.AppWithWSs = void 0;
19
+ exports.mock = exports.addSingleUserSignup = exports.accountsApp = exports.servicesApp = exports.AppWithWSs = void 0;
20
20
  var app_1 = require("./lib-server/web-sockets/app");
21
21
  Object.defineProperty(exports, "AppWithWSs", { enumerable: true, get: function () { return app_1.AppWithWSs; } });
22
22
  var services_1 = require("./services");
23
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; } });
24
+ Object.defineProperty(exports, "accountsApp", { enumerable: true, get: function () { return services_1.accountsApp; } });
28
25
  var signup_1 = require("./config/signup");
29
26
  Object.defineProperty(exports, "addSingleUserSignup", { enumerable: true, get: function () { return signup_1.addSingleUserSignup; } });
30
27
  exports.errors = require("./lib-server/middleware/error-handler");
@@ -0,0 +1,3 @@
1
+ import { ErrLogger } from '../lib-server/middleware/error-handler';
2
+ import { AppWithWSs } from '../lib-server/web-sockets/app';
3
+ export declare function makeLockerApp(rootFolder: string, errLogger?: ErrLogger): AppWithWSs;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2024 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.makeLockerApp = void 0;
20
+ const body_parsers_1 = require("../lib-server/middleware/body-parsers");
21
+ const error_handler_1 = require("../lib-server/middleware/error-handler");
22
+ const app_1 = require("../lib-server/web-sockets/app");
23
+ const sessions_1 = require("./resources/sessions");
24
+ const _3nstorage_app_1 = require("../3nstorage/3nstorage-app");
25
+ const api = require("../lib-common/service-api/locker");
26
+ function addLockerSetupRoutes(app) {
27
+ app.put('/' + api.createLocker.URL_END, (0, body_parsers_1.json)('1kb'));
28
+ }
29
+ function makeLockerApp(rootFolder, errLogger) {
30
+ const ownersSessions = (0, sessions_1.makeSessionFactory)(20 * 60);
31
+ const sharingSessions = (0, sessions_1.makeSessionFactory)(20 * 60);
32
+ const app = new app_1.AppWithWSs();
33
+ app.http.disable('etag');
34
+ addLockerSetupRoutes(app.http);
35
+ const lockers = undefined;
36
+ app.use('/3nstorage', (0, _3nstorage_app_1.makeStorageAppForLocker)(lockers, ownersSessions, sharingSessions, errLogger));
37
+ app.http.use((0, error_handler_1.makeErrHandler)(errLogger));
38
+ return app;
39
+ }
40
+ exports.makeLockerApp = makeLockerApp;
41
+ Object.freeze(exports);
File without changes
@@ -1,6 +1,5 @@
1
- "use strict";
2
1
  /*
3
- Copyright (C) 2015 3NSoft Inc.
2
+ Copyright (C) 2024 3NSoft Inc.
4
3
 
5
4
  This program is free software: you can redistribute it and/or modify it under
6
5
  the terms of the GNU General Public License as published by the Free Software
@@ -13,11 +12,5 @@
13
12
  See the GNU General Public License for more details.
14
13
 
15
14
  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
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.bind = void 0;
19
- function bind(thisArg, func) {
20
- return func.bind(thisArg);
21
- }
22
- exports.bind = bind;
23
- Object.freeze(exports);
15
+ this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
@@ -0,0 +1,9 @@
1
+ import { Request as Req, SessionParams, Factory } from '../../lib-server/resources/sessions';
2
+ export type SessionsFactory = Factory<SessionParams>;
3
+ export type Request = Req<SessionParams>;
4
+ /**
5
+ * This returns factory, that works properly in a single process application,
6
+ * clearing up sessions that past given timeout.
7
+ * @param timeout is a session timeout in seconds
8
+ */
9
+ export declare function makeSessionFactory(timeout: number): SessionsFactory;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2017 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.makeSessionFactory = void 0;
20
+ const mem_backed_sessions_factory_1 = require("../../lib-server/resources/mem-backed-sessions-factory");
21
+ function makeSessionParams() {
22
+ return { userId: undefined };
23
+ }
24
+ /**
25
+ * This returns factory, that works properly in a single process application,
26
+ * clearing up sessions that past given timeout.
27
+ * @param timeout is a session timeout in seconds
28
+ */
29
+ function makeSessionFactory(timeout) {
30
+ return mem_backed_sessions_factory_1.InMemorySessions.factory(timeout, makeSessionParams);
31
+ }
32
+ exports.makeSessionFactory = makeSessionFactory;
33
+ Object.freeze(exports);
@@ -0,0 +1,4 @@
1
+ import { RequestHandler } from 'express';
2
+ import { createLocker as api } from '../../lib-common/service-api/locker';
3
+ export type LockerCreator = (token: string | undefined) => Promise<api.Reply>;
4
+ export declare function createLocker(createLocker: LockerCreator): RequestHandler;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2024 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.createLocker = void 0;
20
+ const locker_1 = require("../../lib-common/service-api/locker");
21
+ function createLocker(createLocker) {
22
+ if ('function' !== typeof createLocker) {
23
+ throw new TypeError("Given argument 'createLocker' must be function, but is not.");
24
+ }
25
+ return async (req, res, next) => {
26
+ const { token } = req.body;
27
+ try {
28
+ const lockerInfo = await createLocker(token);
29
+ res.status(locker_1.createLocker.SC.ok).json(lockerInfo);
30
+ }
31
+ catch (err) {
32
+ next(err);
33
+ }
34
+ };
35
+ }
36
+ exports.createLocker = createLocker;
37
+ Object.freeze(exports);
@@ -4,4 +4,4 @@
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;
7
+ export declare function makeMailerIdApp(rootFolder: string, domain: string, certFile: string, errLogger?: ErrLogger): express.Express;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2016, 2020 3NSoft Inc.
3
+ Copyright (C) 2015 - 2016, 2020, 2024 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,39 +16,40 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.makeApp = void 0;
19
+ exports.makeMailerIdApp = void 0;
20
20
  /**
21
21
  * This module gives a function that creates a mountable, or app.use()-able,
22
22
  * express MailerId application.
23
23
  */
24
24
  const express = require("express");
25
25
  const body_parsers_1 = require("../lib-server/middleware/body-parsers");
26
- const start_exchange_1 = require("../lib-server/routes/pub-key-login/start-exchange");
27
- const complete_exchange_1 = require("../lib-server/routes/pub-key-login/complete-exchange");
28
26
  const certify_1 = require("./routes/certify");
29
27
  const sessions_1 = require("./resources/sessions");
30
28
  const users_1 = require("./resources/users");
31
29
  const certifier_1 = require("./resources/certifier");
32
- const compute_login_dhshared_key_1 = require("./resources/compute-login-dhshared-key");
30
+ const server_key_for_pkl_challenge_1 = require("../lib-server/resources/server-key-for-pkl-challenge");
33
31
  const error_handler_1 = require("../lib-server/middleware/error-handler");
34
32
  const api = require("../lib-common/service-api/mailer-id/provisioning");
33
+ const pkl_access_1 = require("../lib-server/pkl-access");
35
34
  // Constant url parts of MailerId provisioning requests
36
35
  const PROVISIONING_PATH = '/prov/';
37
36
  function provisioningApp(sessions, users, certifier, computeDHSharedKey) {
38
37
  const app = express();
39
38
  app.disable('etag');
39
+ // Login
40
+ (0, pkl_access_1.addPKLLoginRoutes)(app, '/', users.getUserParamsAndKey, sessions, computeDHSharedKey);
41
+ // *** Require authorized session for everything below ***
42
+ app.use(sessions.ensureAuthorizedSession());
40
43
  // MailerId certificate provisioning routes
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
+ app.post('/' + api.certify.URL_END, (0, body_parsers_1.binary)('16kb'), (0, certify_1.certify)(certifier.certify));
44
45
  return app;
45
46
  }
46
- function makeApp(rootFolder, domain, certFile, errLogger) {
47
+ function makeMailerIdApp(rootFolder, domain, certFile, errLogger) {
47
48
  const app = express();
48
49
  const certProvisSessions = (0, sessions_1.makeSessionFactory)(2 * 60);
49
50
  const users = (0, users_1.makeFactory)(rootFolder);
50
51
  const certifier = (0, certifier_1.makeSingleProcCertifier)(domain, certFile);
51
- app.use(PROVISIONING_PATH, provisioningApp(certProvisSessions, users, certifier, compute_login_dhshared_key_1.calcNaClBoxSharedKey));
52
+ app.use(PROVISIONING_PATH, provisioningApp(certProvisSessions, users, certifier, server_key_for_pkl_challenge_1.calcNaClBoxSharedKey));
52
53
  // MailerId display of service parameters, as per protocol
53
54
  app.get('/', (req, res) => {
54
55
  let path = req.originalUrl;
@@ -65,5 +66,5 @@ function makeApp(rootFolder, domain, certFile, errLogger) {
65
66
  app.use((0, error_handler_1.makeErrHandler)(errLogger));
66
67
  return app;
67
68
  }
68
- exports.makeApp = makeApp;
69
+ exports.makeMailerIdApp = makeMailerIdApp;
69
70
  Object.freeze(exports);
@@ -6,7 +6,7 @@ export interface RootCerts {
6
6
  current: SignedLoad;
7
7
  previous: SignedLoad[];
8
8
  }
9
- export declare type ICertify = (userPKey: JsonKey, address: string, validFor?: number) => {
9
+ export type ICertify = (userPKey: JsonKey, address: string, validFor?: number) => {
10
10
  userCert: SignedLoad;
11
11
  provCert: SignedLoad;
12
12
  };
@@ -1,7 +1,7 @@
1
1
  import { Factory } from '../../lib-server/resources/sessions';
2
2
  import { SessionParams } from '../../lib-server/routes/pub-key-login/start-exchange';
3
3
  export { Request } from '../../lib-server/routes/pub-key-login/start-exchange';
4
- export declare type SessionsFactory = Factory<SessionParams>;
4
+ export type SessionsFactory = Factory<SessionParams>;
5
5
  /**
6
6
  * This returns factory, that works properly in a single process application,
7
7
  * clearing up sessions that past given timeout.
@@ -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.certify = void 0;
19
20
  const buffer_utils_1 = require("../../lib-common/buffer-utils");
package/build/main.js CHANGED
@@ -31,7 +31,7 @@ async function run(conf) {
31
31
  function createApp(conf) {
32
32
  const app = new lib_1.AppWithWSs();
33
33
  app.use((0, lib_1.servicesApp)(conf, 'console', 'console'));
34
- app.use((0, lib_1.adminApp)(conf, 'console', 'console'));
34
+ app.use((0, lib_1.accountsApp)(conf, 'console', 'console'));
35
35
  return app;
36
36
  }
37
37
  async function stopProcess() {
package/build/mock/dns.js CHANGED
@@ -13,10 +13,10 @@
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.DNSMock = void 0;
19
- const binding_1 = require("../lib-common/binding");
20
20
  const DNS_ERR_CODE = {
21
21
  NODATA: 'ENODATA',
22
22
  NOTFOUND: 'ENOTFOUND'
@@ -55,8 +55,7 @@ class DNSMock {
55
55
  this.domains.set(d, midUrlOrBulkRecs[d]);
56
56
  }
57
57
  }
58
- // node's definition incorrectly describes callback argument
59
- this.resolveTxt = (0, binding_1.bind)(this, this.mockResolve);
58
+ this.resolveTxt = this.mockResolve.bind(this);
60
59
  Object.freeze(this);
61
60
  }
62
61
  mockResolve(domain, callback) {
@@ -25,7 +25,7 @@ const https = require("https");
25
25
  const tls_options_1 = require("./tls-options");
26
26
  const app_1 = require("../lib-server/web-sockets/app");
27
27
  const path_1 = require("path");
28
- const signup_tokens_1 = require("../admin/signup-tokens");
28
+ const signup_tokens_1 = require("../signup/signup-tokens");
29
29
  const SERVER_MOCK_CHANNEL = 'server-mock';
30
30
  const parent = (0, node_child_ipc_1.commToParent)(SERVER_MOCK_CHANNEL);
31
31
  const DEFAULT_SERVICE_PORT = 8088;
@@ -74,7 +74,7 @@ async function start(env) {
74
74
  await (0, async_fs_node_1.writeFile)(noTokensFilePath, JSON.stringify(noTokenCtx), { encoding: 'utf8' });
75
75
  // setup app
76
76
  app = new app_1.AppWithWSs();
77
- app.use((0, services_1.adminApp)(conf));
77
+ app.use((0, services_1.accountsApp)(conf));
78
78
  app.use((0, services_1.servicesApp)(conf));
79
79
  // start app
80
80
  await app.start(tls_options_1.sslOpts, servicePort);
@@ -2,7 +2,7 @@
2
2
  import * as cProcs from 'child_process';
3
3
  import { RequestServer, RequestingClient } from '../lib-common/ipc/generic-ipc';
4
4
  export { RequestEnvelope, RequestHandler } from '../lib-common/ipc/generic-ipc';
5
- export declare type IPCToChild = RequestingClient;
6
- export declare type IPCToParent = RequestServer;
5
+ export type IPCToChild = RequestingClient;
6
+ export type IPCToParent = RequestServer;
7
7
  export declare function commToChild(channel: string, child: cProcs.ChildProcess): IPCToChild;
8
8
  export declare function commToParent(channel: string): IPCToParent;
@@ -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.commToParent = exports.commToChild = void 0;
19
20
  const generic_ipc_1 = require("../lib-common/ipc/generic-ipc");
@@ -25,7 +25,7 @@ const services_1 = require("../services");
25
25
  const dns = require("dns");
26
26
  const dns_1 = require("./dns");
27
27
  const path_1 = require("path");
28
- const signup_tokens_1 = require("../admin/signup-tokens");
28
+ const signup_tokens_1 = require("../signup/signup-tokens");
29
29
  function setTestCertsAndDNS(domains, thisSrvLoc) {
30
30
  if (thisSrvLoc.endsWith('/')) {
31
31
  throw new Error(`Location value shouldn't have trailing slash`);
@@ -85,7 +85,7 @@ async function startOn(srvDomain, dataDir, port, domains) {
85
85
  const dnsMock = setTestCertsAndDNS(allDomains, `${srvDomain}:${port}`);
86
86
  // setup services and start
87
87
  const app = new app_1.AppWithWSs();
88
- app.use((0, services_1.adminApp)(conf));
88
+ app.use((0, services_1.accountsApp)(conf));
89
89
  app.use((0, services_1.servicesApp)(conf));
90
90
  await app.start(conf.servicesConnect.sslOpts, conf.servicesConnect.port);
91
91
  return { dnsMock, stop: () => app.stop() };
@@ -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.sslOpts = void 0;
19
20
  exports.sslOpts = {
@@ -7,6 +7,7 @@ export interface Configurations {
7
7
  asmail?: boolean;
8
8
  storage?: boolean;
9
9
  mailerId?: boolean;
10
+ locker?: boolean;
10
11
  };
11
12
  servicesConnect?: {
12
13
  hostname?: string;
@@ -25,4 +26,4 @@ export interface Configurations {
25
26
  };
26
27
  }
27
28
  export declare function servicesApp(conf: Configurations, errLogger?: ErrLogger | 'console', logSetup?: 'console'): AppWithWSs;
28
- export declare function adminApp(conf: Configurations, errLogger?: ErrLogger | 'console', logSetup?: 'console'): AppWithWSs;
29
+ export declare function accountsApp(conf: Configurations, errLogger?: ErrLogger | 'console', logSetup?: 'console'): AppWithWSs;
package/build/services.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2017, 2020 3NSoft Inc.
3
+ Copyright (C) 2015 - 2017, 2020, 2024 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,14 +16,15 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.adminApp = exports.servicesApp = void 0;
19
+ exports.accountsApp = exports.servicesApp = void 0;
20
20
  const mailerid_authorizer_1 = require("./lib-server/resources/mailerid-authorizer");
21
21
  const app_1 = require("./lib-server/web-sockets/app");
22
22
  const mailerId_app_1 = require("./mailerId/mailerId-app");
23
23
  const asmail_app_1 = require("./asmail/asmail-app");
24
24
  const _3nstorage_app_1 = require("./3nstorage/3nstorage-app");
25
- const admin_app_1 = require("./admin/admin-app");
25
+ const signup_app_1 = require("./signup/signup-app");
26
26
  const error_handler_1 = require("./lib-server/middleware/error-handler");
27
+ const locker_app_1 = require("./locker/locker-app");
27
28
  function servicesApp(conf, errLogger, logSetup) {
28
29
  if (!conf.enabledServices || (typeof conf.enabledServices !== 'object')) {
29
30
  throw new Error('Missing enabled-services sections in confs.');
@@ -31,31 +32,41 @@ function servicesApp(conf, errLogger, logSetup) {
31
32
  const app = new app_1.AppWithWSs();
32
33
  const midAuthorizer = (0, mailerid_authorizer_1.validator)(); // share, allowing for caching of certs
33
34
  if (conf.enabledServices.mailerId) {
34
- app.http.use('/mailerid', (0, mailerId_app_1.makeApp)(conf.rootFolder, conf.domain, conf.mailerId.certs, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('MailerId') : errLogger));
35
+ app.http.use('/mailerid', (0, mailerId_app_1.makeMailerIdApp)(conf.rootFolder, conf.domain, conf.mailerId.certs, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('MailerId') : errLogger));
35
36
  if (logSetup === 'console') {
36
37
  console.log(`Enabled MailerId service with provider domain ${conf.domain}`);
37
38
  }
38
39
  }
39
40
  if (conf.enabledServices.asmail) {
40
- app.use('/asmail', (0, asmail_app_1.makeApp)(conf.rootFolder, conf.domain, midAuthorizer, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('ASMail') : errLogger));
41
+ app.use('/asmail', (0, asmail_app_1.makeASMailApp)(conf.rootFolder, conf.domain, midAuthorizer, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('ASMail') : errLogger));
41
42
  if (logSetup === 'console') {
42
43
  console.log(`Enabled ASMail service with provider domain ${conf.domain}`);
43
44
  }
44
45
  }
45
46
  if (conf.enabledServices.storage) {
46
- app.use('/3nstorage', (0, _3nstorage_app_1.makeApp)(conf.rootFolder, conf.domain, midAuthorizer, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('3NStorage') : errLogger));
47
+ app.use('/3nstorage', (0, _3nstorage_app_1.makeStorageApp)(conf.rootFolder, conf.domain, midAuthorizer, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('3NStorage') : errLogger));
47
48
  if (logSetup === 'console') {
48
49
  console.log(`Enabled 3NStorage service with provider domain ${conf.domain}`);
49
50
  }
50
51
  }
52
+ if (conf.enabledServices.locker) {
53
+ app.use('/locker', (0, locker_app_1.makeLockerApp)(conf.rootFolder, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('Locker') : errLogger));
54
+ if (logSetup === 'console') {
55
+ console.log(`Enabled Locker service`);
56
+ }
57
+ }
51
58
  return app;
52
59
  }
53
60
  exports.servicesApp = servicesApp;
54
- function adminApp(conf, errLogger, logSetup) {
55
- if (errLogger === 'console') {
56
- errLogger = (0, error_handler_1.makeErrLoggerToConsole)('3NWeb server admin');
61
+ function accountsApp(conf, errLogger, logSetup) {
62
+ const app = new app_1.AppWithWSs();
63
+ if (conf.signup) {
64
+ app.http.use('/signup', (0, signup_app_1.makeSignupApp)(conf, (errLogger === 'console') ? (0, error_handler_1.makeErrLoggerToConsole)('Signup') : errLogger));
65
+ if (logSetup === 'console') {
66
+ console.log(`Enabled signup service.`);
67
+ }
57
68
  }
58
- return new app_1.AppWithWSs((0, admin_app_1.makeApp)(conf, errLogger, logSetup));
69
+ return app;
59
70
  }
60
- exports.adminApp = adminApp;
71
+ exports.accountsApp = accountsApp;
61
72
  Object.freeze(exports);
@@ -13,7 +13,7 @@ export declare function validateUserStorageParams(params: UserStorageParams): bo
13
13
  * @return a promise, resolvable to available addresses for a given name.
14
14
  * If array is empty, there are no available addresses for a given name.
15
15
  */
16
- export declare type IAvailableDomains = (signupToken: string | undefined) => Promise<string[]>;
16
+ export type IAvailableDomains = (signupToken: string | undefined) => Promise<string[]>;
17
17
  /**
18
18
  * This returns a promise, resolvable to an array of addresses, that are
19
19
  * available for a given string. Array may be empty, when there are no
@@ -23,7 +23,7 @@ export declare type IAvailableDomains = (signupToken: string | undefined) => Pro
23
23
  * @return a promise, resolvable to available addresses for a given name.
24
24
  * If array is empty, there are no available addresses for a given name.
25
25
  */
26
- export declare type IAvailableAddressesForName = (name: string, signupToken: string | undefined) => Promise<string[]>;
26
+ export type IAvailableAddressesForName = (name: string, signupToken: string | undefined) => Promise<string[]>;
27
27
  /**
28
28
  * This creates a user, returning a promise, resolvable when a new account has
29
29
  * been created for a given user id.
@@ -35,7 +35,7 @@ export declare type IAvailableAddressesForName = (name: string, signupToken: str
35
35
  * @return a promise, resolvable, when user is added, and all parameters are
36
36
  * saved.
37
37
  */
38
- export declare type IAdd = (userId: string, midParams: UserMidParams, storeParams: any, signupToken: string | undefined) => Promise<void>;
38
+ export type IAdd = (userId: string, midParams: UserMidParams, storeParams: any, signupToken: string | undefined) => Promise<void>;
39
39
  export interface Factory {
40
40
  getAvailableDomains: IAvailableDomains;
41
41
  getAvailableAddresses: IAvailableAddressesForName;
@@ -25,7 +25,6 @@ const fs = require("../../lib-common/async-fs-node");
25
25
  const fs_1 = require("fs");
26
26
  const jwk = require("../../lib-common/jwkeys");
27
27
  const nacl = require("ecma-nacl");
28
- const binding_1 = require("../../lib-common/binding");
29
28
  const path_1 = require("path");
30
29
  const server_data_folders_1 = require("../../lib-server/resources/server-data-folders");
31
30
  const signup_tokens_1 = require("../signup-tokens");
@@ -357,9 +356,9 @@ class Users {
357
356
  }
358
357
  wrap() {
359
358
  const wrap = {
360
- getAvailableDomains: (0, binding_1.bind)(this, this.getAvailableDomains),
361
- getAvailableAddresses: (0, binding_1.bind)(this, this.getAvailableAddresses),
362
- add: (0, binding_1.bind)(this, this.add),
359
+ getAvailableDomains: this.getAvailableDomains.bind(this),
360
+ getAvailableAddresses: this.getAvailableAddresses.bind(this),
361
+ add: this.add.bind(this),
363
362
  };
364
363
  Object.freeze(wrap);
365
364
  return wrap;
@@ -1,4 +1,4 @@
1
1
  import * as express from 'express';
2
2
  import { ErrLogger } from '../lib-server/middleware/error-handler';
3
3
  import { Configurations } from '../services';
4
- export declare function makeApp(conf: Configurations, errLogger?: ErrLogger, logSetup?: 'console'): express.Express;
4
+ export declare function makeSignupApp(conf: Configurations, errLogger?: ErrLogger): express.Express;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2016, 2020 - 2021 3NSoft Inc.
3
+ Copyright (C) 2015 - 2016, 2020 - 2021, 2024 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.makeApp = void 0;
19
+ exports.makeSignupApp = void 0;
20
20
  const express = require("express");
21
21
  const body_parsers_1 = require("../lib-server/middleware/body-parsers");
22
22
  const error_handler_1 = require("../lib-server/middleware/error-handler");
@@ -25,26 +25,16 @@ const add_1 = require("./routes/add");
25
25
  const get_available_addresses_1 = require("./routes/get-available-addresses");
26
26
  const get_available_domains_1 = require("./routes/get-available-domains");
27
27
  const signupApi = require("../lib-common/admin-api/signup");
28
- function apiPart(users) {
28
+ function makeSignupApp(conf, errLogger) {
29
29
  const app = express();
30
30
  app.disable('etag');
31
+ const noTokenFile = (conf.signup ? conf.signup.noTokenFile : undefined);
32
+ const users = (0, users_1.makeFactory)(conf.rootFolder, noTokenFile);
31
33
  app.post('/' + signupApi.availableDomains.URL_END, (0, body_parsers_1.json)('1kb'), (0, get_available_domains_1.availableDomains)(users.getAvailableDomains));
32
34
  app.post('/' + signupApi.availableAddressesForName.URL_END, (0, body_parsers_1.json)('1kb'), (0, get_available_addresses_1.availableAddresses)(users.getAvailableAddresses));
33
35
  app.post('/' + signupApi.addUser.URL_END, (0, body_parsers_1.json)('4kb'), (0, add_1.addUser)(users.add));
34
- return app;
35
- }
36
- function makeApp(conf, errLogger, logSetup) {
37
- const app = express();
38
- const noTokenFile = (conf.signup ? conf.signup.noTokenFile : undefined);
39
- const users = (0, users_1.makeFactory)(conf.rootFolder, noTokenFile);
40
- if (conf.signup) {
41
- app.use('/signup', apiPart(users));
42
- if (logSetup === 'console') {
43
- console.log(`Enabled signup service.`);
44
- }
45
- }
46
36
  app.use((0, error_handler_1.makeErrHandler)(errLogger));
47
37
  return app;
48
38
  }
49
- exports.makeApp = makeApp;
39
+ exports.makeSignupApp = makeSignupApp;
50
40
  Object.freeze(exports);
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- export declare type SignupContext = SingleUserSignupCtx | MultiDomainSignupCtx;
2
+ export type SignupContext = SingleUserSignupCtx | MultiDomainSignupCtx;
3
3
  export interface SingleUserSignupCtx {
4
4
  token: string;
5
5
  type: 'single-user';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-3nweb-server",
3
- "version": "1.7.0",
3
+ "version": "1.7.5",
4
4
  "description": "3NWeb spec server.",
5
5
  "main": "build/lib.js",
6
6
  "types": "build/lib.d.ts",
@@ -10,7 +10,7 @@
10
10
  "clear-for-packing": "npm prune --production && bash -c \"rm -rf build/mock build/tests 'node_modules/ecma-nacl/c sources'\"",
11
11
  "clear-for-packing-mock": "npm prune --production && bash -c \"rm -rf build/tests 'node_modules/ecma-nacl/c sources'\"",
12
12
  "pack": "pkg --config package.json build/main.js",
13
- "pack-deb": "npm run pack && bash packing/deb/create-bin.sh",
13
+ "pack-deb": "npm run pack && bash packing/create-deb.sh",
14
14
  "postinstall": "node -e \"try{require('./postinstall')}catch(e){}\""
15
15
  },
16
16
  "repository": {
@@ -34,7 +34,7 @@
34
34
  "command-line-args": "^5.2.1",
35
35
  "command-line-usage": "^7.0.1",
36
36
  "ecma-nacl": "^2.4.0",
37
- "express": "^4.18.0",
37
+ "express": "^4.19.2",
38
38
  "js-yaml": "^4.1.0",
39
39
  "prompts": "^2.4.2",
40
40
  "punycode": "^2.1.1",