spec-3nweb-server 1.7.1 → 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 (115) 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.js +2 -1
  6. package/build/3nstorage/resources/store.d.ts +5 -5
  7. package/build/3nstorage/resources/store.js +3 -12
  8. package/build/3nstorage/resources/users.d.ts +6 -6
  9. package/build/3nstorage/resources/users.js +13 -16
  10. package/build/3nstorage/shared.d.ts +2 -6
  11. package/build/3nstorage/shared.js +5 -9
  12. package/build/asmail/asmail-app.d.ts +1 -1
  13. package/build/asmail/asmail-app.js +3 -3
  14. package/build/asmail/config.d.ts +2 -6
  15. package/build/asmail/config.js +20 -12
  16. package/build/asmail/delivery.d.ts +2 -6
  17. package/build/asmail/delivery.js +0 -6
  18. package/build/asmail/resources/delivery-sessions.js +1 -2
  19. package/build/asmail/resources/inbox.d.ts +17 -26
  20. package/build/asmail/resources/inbox.js +15 -59
  21. package/build/asmail/resources/recipients.d.ts +28 -10
  22. package/build/asmail/resources/recipients.js +62 -22
  23. package/build/asmail/retrieval.d.ts +2 -2
  24. package/build/asmail/retrieval.js +11 -18
  25. package/build/config/signup.d.ts +1 -1
  26. package/build/config/signup.js +1 -1
  27. package/build/lib-common/assert.js +2 -1
  28. package/build/lib-common/buffer-utils.js +2 -1
  29. package/build/lib-common/byte-streaming/common.js +11 -11
  30. package/build/lib-common/bytes-equal.js +2 -1
  31. package/build/lib-common/exceptions/error.js +2 -1
  32. package/build/lib-common/exceptions/file.js +2 -1
  33. package/build/lib-common/exceptions/http.js +2 -1
  34. package/build/lib-common/ipc/generic-ipc.js +14 -14
  35. package/build/lib-common/ipc/ws-ipc.js +2 -1
  36. package/build/lib-common/json-equal.js +2 -1
  37. package/build/lib-common/json-utils.js +2 -1
  38. package/build/lib-common/jwkeys.js +2 -1
  39. package/build/lib-common/map-of-sets.js +2 -1
  40. package/build/lib-common/mid-sigs-NaCl-Ed.js +2 -1
  41. package/build/lib-common/objs-on-disk/file-layout.js +2 -1
  42. package/build/lib-common/objs-on-disk/obj-file.js +2 -1
  43. package/build/lib-common/objs-on-disk/v1-obj-file-format.js +2 -1
  44. package/build/lib-common/processes.js +2 -1
  45. package/build/lib-common/random-node.js +2 -1
  46. package/build/lib-common/service-api/3nstorage/owner.d.ts +1 -3
  47. package/build/lib-common/service-api/3nstorage/owner.js +2 -4
  48. package/build/lib-common/service-api/asmail/config.d.ts +1 -3
  49. package/build/lib-common/service-api/asmail/config.js +4 -5
  50. package/build/lib-common/service-api/asmail/delivery.js +2 -1
  51. package/build/lib-common/service-api/asmail/retrieval.d.ts +1 -3
  52. package/build/lib-common/service-api/asmail/retrieval.js +3 -4
  53. package/build/lib-common/service-api/ipc-api.js +2 -1
  54. package/build/lib-common/service-api/locker.d.ts +17 -0
  55. package/build/lib-common/service-api/locker.js +31 -0
  56. package/build/lib-common/service-api/mailer-id/login.js +2 -1
  57. package/build/lib-common/service-api/mailer-id/provisioning.d.ts +3 -4
  58. package/build/lib-common/service-api/mailer-id/provisioning.js +3 -12
  59. package/build/lib-common/service-api/pub-key-login.js +2 -1
  60. package/build/lib-common/service-api/web-socket-base.js +2 -1
  61. package/build/lib-common/session-encryptor.js +2 -1
  62. package/build/lib-common/time-window-cache.js +2 -1
  63. package/build/lib-server/mid-access.d.ts +5 -0
  64. package/build/lib-server/mid-access.js +28 -0
  65. package/build/lib-server/middleware/body-parsers.d.ts +7 -7
  66. package/build/lib-server/middleware/body-parsers.js +14 -14
  67. package/build/lib-server/pkl-access.d.ts +4 -0
  68. package/build/lib-server/pkl-access.js +28 -0
  69. package/build/lib-server/resources/dns.js +2 -1
  70. package/build/lib-server/resources/mailerid-authorizer.js +5 -6
  71. package/build/lib-server/resources/server-data-folders.d.ts +1 -0
  72. package/build/lib-server/resources/server-data-folders.js +9 -4
  73. package/build/{mailerId/resources/compute-login-dhshared-key.js → lib-server/resources/server-key-for-pkl-challenge.js} +5 -5
  74. package/build/lib-server/resources/sessions.js +7 -7
  75. package/build/lib-server/resources/user-files.d.ts +3 -3
  76. package/build/lib-server/resources/user-files.js +4 -2
  77. package/build/lib-server/routes/sessions/close.js +2 -1
  78. package/build/lib-server/web-sockets/app.js +2 -3
  79. package/build/lib-server/web-sockets/server-events.js +1 -2
  80. package/build/lib.d.ts +1 -1
  81. package/build/lib.js +2 -2
  82. package/build/locker/locker-app.d.ts +3 -0
  83. package/build/locker/locker-app.js +41 -0
  84. package/build/locker/resources/lockers.d.ts +0 -0
  85. package/build/{lib-common/binding.js → locker/resources/lockers.js} +3 -10
  86. package/build/locker/resources/sessions.d.ts +9 -0
  87. package/build/locker/resources/sessions.js +33 -0
  88. package/build/locker/routes/create-locker.d.ts +4 -0
  89. package/build/locker/routes/create-locker.js +37 -0
  90. package/build/mailerId/mailerId-app.d.ts +1 -1
  91. package/build/mailerId/mailerId-app.js +12 -11
  92. package/build/mailerId/routes/certify.js +2 -1
  93. package/build/main.js +1 -1
  94. package/build/mock/dns.js +3 -4
  95. package/build/mock/mock-as-child-proc.js +2 -2
  96. package/build/mock/node-child-ipc.js +2 -1
  97. package/build/mock/run-in-proc.js +2 -2
  98. package/build/mock/tls-options.js +2 -1
  99. package/build/services.d.ts +2 -1
  100. package/build/services.js +22 -11
  101. package/build/{admin → signup}/resources/users.js +3 -4
  102. package/build/{admin/admin-app.d.ts → signup/signup-app.d.ts} +1 -1
  103. package/build/{admin/admin-app.js → signup/signup-app.js} +6 -16
  104. package/package.json +1 -1
  105. package/build/lib-common/binding.d.ts +0 -1
  106. /package/build/{mailerId/resources/compute-login-dhshared-key.d.ts → lib-server/resources/server-key-for-pkl-challenge.d.ts} +0 -0
  107. /package/build/{admin → signup}/resources/users.d.ts +0 -0
  108. /package/build/{admin → signup}/routes/add.d.ts +0 -0
  109. /package/build/{admin → signup}/routes/add.js +0 -0
  110. /package/build/{admin → signup}/routes/get-available-addresses.d.ts +0 -0
  111. /package/build/{admin → signup}/routes/get-available-addresses.js +0 -0
  112. /package/build/{admin → signup}/routes/get-available-domains.d.ts +0 -0
  113. /package/build/{admin → signup}/routes/get-available-domains.js +0 -0
  114. /package/build/{admin → signup}/signup-tokens.d.ts +0 -0
  115. /package/build/{admin → signup}/signup-tokens.js +0 -0
@@ -22,14 +22,14 @@ exports.calcNaClBoxSharedKey = void 0;
22
22
  */
23
23
  const ecma_nacl_1 = require("ecma-nacl");
24
24
  const random = require("../../lib-common/random-node");
25
- // XXX update the key from time-to-time
26
- const testLoginSecretKey = random.bytesSync(32);
27
- const testLoginPublicKey = ecma_nacl_1.box.generate_pubkey(testLoginSecretKey);
25
+ // XXX update the key from time-to-time, and this must be single instance
26
+ const skeyForPKLChallenge = random.bytesSync(32);
27
+ const pkeyForPKLChallenge = ecma_nacl_1.box.generate_pubkey(skeyForPKLChallenge);
28
28
  function calcNaClBoxSharedKey(userPubKey) {
29
- const dhsharedKey = ecma_nacl_1.box.calc_dhshared_key(userPubKey, testLoginSecretKey);
29
+ const dhsharedKey = ecma_nacl_1.box.calc_dhshared_key(userPubKey, skeyForPKLChallenge);
30
30
  return {
31
31
  dhsharedKey: dhsharedKey,
32
- serverPubKey: testLoginPublicKey
32
+ serverPubKey: pkeyForPKLChallenge
33
33
  };
34
34
  }
35
35
  exports.calcNaClBoxSharedKey = calcNaClBoxSharedKey;
@@ -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.wrapFactory = exports.BaseSessionFactory = exports.SESSION_ID_HEADER = void 0;
19
- const binding_1 = require("../../lib-common/binding");
20
20
  // Constant custom header
21
21
  exports.SESSION_ID_HEADER = "X-Session-Id";
22
22
  const LOW_CASED_SESSION_ID_HEADER = exports.SESSION_ID_HEADER.toLowerCase();
@@ -171,11 +171,11 @@ Object.freeze(BaseSessionFactory.prototype);
171
171
  Object.freeze(BaseSessionFactory);
172
172
  function wrapFactory(impl) {
173
173
  const wrap = {
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)
174
+ checkSession: impl.checkSession.bind(impl),
175
+ ensureAuthorizedSession: impl.ensureAuthorizedSession.bind(impl),
176
+ ensureOpenedSession: impl.ensureOpenedSession.bind(impl),
177
+ ensureAuthorizedSessionForSocketStart: impl.ensureAuthorizedSessionForSocketStart.bind(impl),
178
+ generate: impl.generate.bind(impl)
179
179
  };
180
180
  return wrap;
181
181
  }
@@ -3,7 +3,7 @@ export declare const SC: {
3
3
  USER_UNKNOWN: string;
4
4
  };
5
5
  export declare function addressToFName(address: string): string;
6
- export declare abstract class UserFiles {
6
+ export declare abstract class UserFiles<ParamTypes extends object> {
7
7
  readonly userId: string;
8
8
  readonly path: string;
9
9
  protected readonly fileWritingBufferSize: number;
@@ -12,8 +12,8 @@ export declare abstract class UserFiles {
12
12
  ensureUserExistsOnDisk(): Promise<void>;
13
13
  private commonInfoFolder;
14
14
  getSpaceQuota(): Promise<number>;
15
- getParam<T>(paramFileName: string): Promise<T>;
16
- setParam<T>(paramFileName: string, param: T): Promise<void>;
15
+ getParam<P extends keyof ParamTypes>(paramFileName: P): Promise<ParamTypes[P]>;
16
+ protected setParam<P extends keyof ParamTypes>(paramFileName: P, param: ParamTypes[P]): Promise<void>;
17
17
  }
18
18
  export type ObjPipe = (outStream: NodeJS.WritableStream) => Promise<void>;
19
19
  export interface ObjReader {
@@ -70,10 +70,12 @@ class UserFiles {
70
70
  return readJsonFile((0, path_1.join)(this.commonInfoFolder(), 'quota'));
71
71
  }
72
72
  getParam(paramFileName) {
73
- return readJsonFile((0, path_1.join)(this.path, 'params', paramFileName));
73
+ const filePath = (0, path_1.join)(this.path, 'params', paramFileName);
74
+ return readJsonFile(filePath);
74
75
  }
75
76
  setParam(paramFileName, param) {
76
- return fs.writeFile((0, path_1.join)(this.path, 'params', paramFileName), JSON.stringify(param), { encoding: 'utf8', flag: 'w' });
77
+ const filePath = (0, path_1.join)(this.path, 'params', paramFileName);
78
+ return fs.writeFile(filePath, JSON.stringify(param), { encoding: 'utf8', flag: 'w' });
77
79
  }
78
80
  }
79
81
  exports.UserFiles = UserFiles;
@@ -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.closeSession = void 0;
19
20
  function closeSession() {
@@ -21,7 +21,6 @@ const http = require("http");
21
21
  const https = require("https");
22
22
  const express = require("express");
23
23
  const WebSocket = require("ws");
24
- const binding_1 = require("../../lib-common/binding");
25
24
  const map_of_sets_1 = require("../../lib-common/map-of-sets");
26
25
  const url_1 = require("url");
27
26
  const MAX_MSG_PAYLOAD = 4 * 1024;
@@ -57,9 +56,9 @@ class UserSocketsServer {
57
56
  server,
58
57
  clientTracking: true,
59
58
  maxPayload: MAX_MSG_PAYLOAD,
60
- verifyClient: (0, binding_1.bind)(this, this.verifyClient)
59
+ verifyClient: this.verifyClient.bind(this)
61
60
  })
62
- .on('connection', (0, binding_1.bind)(this, this.handleConnection)) // bad @types
61
+ .on('connection', this.handleConnection.bind(this))
63
62
  .on('error', (err) => { console.error(err); });
64
63
  }
65
64
  disconnect() {
@@ -18,7 +18,6 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.ServerEvents = void 0;
20
20
  const ws_ipc_1 = require("../../lib-common/ipc/ws-ipc");
21
- const binding_1 = require("../../lib-common/binding");
22
21
  class ServerEvents {
23
22
  constructor(ipcChannel, eventChannels, getSocket) {
24
23
  this.ipcChannel = ipcChannel;
@@ -49,7 +48,7 @@ class ServerEvents {
49
48
  }
50
49
  }
51
50
  get eventsSink() {
52
- return (0, binding_1.bind)(this, this.sendEvent);
51
+ return this.sendEvent.bind(this);
53
52
  }
54
53
  }
55
54
  exports.ServerEvents = ServerEvents;
package/build/lib.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AppWithWSs } from './lib-server/web-sockets/app';
2
- export { Configurations, servicesApp, adminApp } from './services';
2
+ export { Configurations, servicesApp, accountsApp } from './services';
3
3
  export { addSingleUserSignup } from './config/signup';
4
4
  export import errors = require('./lib-server/middleware/error-handler');
5
5
  export * as mock from './mock/run-in-proc';
package/build/lib.js CHANGED
@@ -16,12 +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.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; } });
24
+ Object.defineProperty(exports, "accountsApp", { enumerable: true, get: function () { return services_1.accountsApp; } });
25
25
  var signup_1 = require("./config/signup");
26
26
  Object.defineProperty(exports, "addSingleUserSignup", { enumerable: true, get: function () { return signup_1.addSingleUserSignup; } });
27
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);
@@ -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);
@@ -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);
@@ -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;