spec-3nweb-server 1.3.5 → 1.4.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.
Files changed (95) hide show
  1. package/build/3nstorage/3nstorage-app.js +4 -4
  2. package/build/3nstorage/owner.js +21 -21
  3. package/build/3nstorage/resources/store.js +25 -24
  4. package/build/3nstorage/resources/users.js +2 -2
  5. package/build/3nstorage/routes/owner/archive-obj-version.d.ts +2 -2
  6. package/build/3nstorage/routes/owner/archive-obj-version.js +3 -2
  7. package/build/3nstorage/routes/owner/cancel-trans.js +1 -1
  8. package/build/3nstorage/routes/owner/delete-obj.js +1 -1
  9. package/build/3nstorage/routes/owner/get-archived-obj-ver.js +2 -2
  10. package/build/3nstorage/routes/owner/get-current-obj.js +2 -2
  11. package/build/3nstorage/routes/owner/list-obj-archive.js +3 -2
  12. package/build/3nstorage/routes/owner/param-getter.js +3 -2
  13. package/build/3nstorage/routes/owner/param-setter.js +3 -2
  14. package/build/3nstorage/routes/owner/put-current-obj.js +12 -10
  15. package/build/3nstorage/routes/owner/session-params.js +4 -3
  16. package/build/admin/admin-app.js +7 -5
  17. package/build/admin/resources/users.d.ts +10 -4
  18. package/build/admin/resources/users.js +90 -37
  19. package/build/admin/routes/add.js +3 -3
  20. package/build/admin/routes/get-available-domains.d.ts +3 -0
  21. package/build/admin/routes/get-available-domains.js +38 -0
  22. package/build/admin/signup-tokens.js +11 -11
  23. package/build/asmail/asmail-app.js +7 -7
  24. package/build/asmail/config.js +9 -8
  25. package/build/asmail/delivery.js +10 -9
  26. package/build/asmail/resources/delivery-sessions.js +5 -4
  27. package/build/asmail/resources/inbox.d.ts +1 -1
  28. package/build/asmail/resources/inbox.js +22 -22
  29. package/build/asmail/resources/recipients.d.ts +2 -1
  30. package/build/asmail/resources/recipients.js +4 -4
  31. package/build/asmail/resources/sessions.js +2 -1
  32. package/build/asmail/retrieval.js +13 -8
  33. package/build/asmail/routes/config/param-getter.js +3 -2
  34. package/build/asmail/routes/config/param-setter.js +3 -2
  35. package/build/asmail/routes/delivery/finalize-delivery.js +3 -2
  36. package/build/asmail/routes/delivery/pre-flight.js +5 -4
  37. package/build/asmail/routes/delivery/provide-recipient-pubkey.js +3 -2
  38. package/build/asmail/routes/delivery/put-metadata.js +3 -2
  39. package/build/asmail/routes/delivery/put-obj.js +4 -4
  40. package/build/asmail/routes/delivery/restart-session.js +4 -3
  41. package/build/asmail/routes/delivery/sender-authorization.d.ts +1 -3
  42. package/build/asmail/routes/delivery/sender-authorization.js +3 -2
  43. package/build/asmail/routes/delivery/start-session.js +5 -4
  44. package/build/asmail/routes/retrieval/get-message-meta.js +3 -2
  45. package/build/asmail/routes/retrieval/get-message-obj.js +4 -3
  46. package/build/asmail/routes/retrieval/list-messages.js +3 -2
  47. package/build/asmail/routes/retrieval/remove-message.js +3 -2
  48. package/build/lib-common/admin-api/signup.d.ts +9 -0
  49. package/build/lib-common/admin-api/signup.js +11 -2
  50. package/build/lib-common/async-fs-node.js +13 -13
  51. package/build/lib-common/byte-streaming/common.js +9 -9
  52. package/build/lib-common/canonical-address.js +1 -1
  53. package/build/lib-common/ipc/generic-ipc.js +12 -12
  54. package/build/lib-common/ipc/ws-ipc.js +2 -2
  55. package/build/lib-common/mid-sigs-NaCl-Ed.js +14 -14
  56. package/build/lib-common/objs-on-disk/file-layout.js +10 -10
  57. package/build/lib-common/objs-on-disk/obj-file.js +11 -11
  58. package/build/lib-common/objs-on-disk/utils.js +3 -3
  59. package/build/lib-common/processes.js +1 -1
  60. package/build/lib-common/random-node.js +7 -7
  61. package/build/lib-common/service-api/3nstorage/owner.d.ts +5 -4
  62. package/build/lib-common/service-api/3nstorage/owner.js +11 -10
  63. package/build/lib-common/service-api/asmail/delivery.js +2 -2
  64. package/build/lib-common/service-api/asmail/retrieval.js +1 -1
  65. package/build/lib-server/conf-util.js +2 -1
  66. package/build/lib-server/middleware/body-parsers.js +16 -16
  67. package/build/lib-server/middleware/error-handler.js +1 -1
  68. package/build/lib-server/resources/mailerid-authorizer.js +3 -3
  69. package/build/lib-server/resources/mem-backed-sessions-factory.d.ts +1 -1
  70. package/build/lib-server/resources/mem-backed-sessions-factory.js +35 -10
  71. package/build/lib-server/resources/server-data-folders.js +23 -23
  72. package/build/lib-server/resources/sessions.js +5 -5
  73. package/build/lib-server/resources/user-files.js +8 -8
  74. package/build/lib-server/routes/pub-key-login/complete-exchange.js +4 -3
  75. package/build/lib-server/routes/pub-key-login/start-exchange.js +7 -6
  76. package/build/lib-server/routes/sessions/mid-auth.js +6 -5
  77. package/build/lib-server/routes/sessions/start.js +4 -3
  78. package/build/lib-server/web-sockets/app.js +6 -5
  79. package/build/lib-server/web-sockets/server-events.js +5 -4
  80. package/build/mailerId/mailerId-app.js +7 -7
  81. package/build/mailerId/resources/certifier.d.ts +4 -6
  82. package/build/mailerId/resources/certifier.js +8 -7
  83. package/build/mailerId/resources/compute-login-dhshared-key.js +2 -1
  84. package/build/mailerId/resources/sessions.js +2 -1
  85. package/build/mailerId/resources/users.js +4 -4
  86. package/build/mailerId/routes/certify.js +1 -1
  87. package/build/main.js +10 -10
  88. package/build/mock/dns.js +1 -1
  89. package/build/mock/mock-as-child-proc.js +10 -10
  90. package/build/mock/node-child-ipc.js +2 -2
  91. package/build/mock/run-in-proc.js +7 -7
  92. package/build/run-config.js +10 -10
  93. package/build/run.js +4 -4
  94. package/build/services.js +5 -5
  95. package/package.json +7 -4
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.startSession = void 0;
19
20
  const login_1 = require("../../../lib-common/service-api/mailer-id/login");
@@ -53,9 +54,9 @@ function startSession(userExistsFunc, sessionGenFunc, redirectFunc) {
53
54
  });
54
55
  }
55
56
  }
56
- return async function (req, res, next) {
57
+ return async (req, res, next) => {
57
58
  const session = req.session;
58
- const userId = canonical_address_1.checkAndTransformAddress(req.body.userId);
59
+ const userId = (0, canonical_address_1.checkAndTransformAddress)(req.body.userId);
59
60
  if (!userId) {
60
61
  res.status(login_1.ERR_SC.malformed).json({
61
62
  error: "User id is either malformed, or missing."
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.AppWithWSs = exports.UserSockets = void 0;
19
20
  const http = require("http");
@@ -56,9 +57,9 @@ class UserSocketsServer {
56
57
  server,
57
58
  clientTracking: true,
58
59
  maxPayload: MAX_MSG_PAYLOAD,
59
- verifyClient: binding_1.bind(this, this.verifyClient)
60
+ verifyClient: (0, binding_1.bind)(this, this.verifyClient)
60
61
  })
61
- .on('connection', binding_1.bind(this, this.handleConnection)) // bad @types
62
+ .on('connection', (0, binding_1.bind)(this, this.handleConnection)) // bad @types
62
63
  .on('error', (err) => { console.error(err); });
63
64
  }
64
65
  disconnect() {
@@ -73,7 +74,7 @@ class UserSocketsServer {
73
74
  this.socksByPath.clear();
74
75
  }
75
76
  verifyClient(info, cb) {
76
- const path = url_1.parse(info.req.url).path;
77
+ const path = (0, url_1.parse)(info.req.url).path;
77
78
  const socks = this.socksByPath.get(path);
78
79
  if (!socks) {
79
80
  cb(false, 405, `WebSocket upgrade is not provided on ${path}`);
@@ -89,7 +90,7 @@ class UserSocketsServer {
89
90
  }
90
91
  handleConnection(client, req) {
91
92
  const userId = req.session.params.userId;
92
- const path = url_1.parse(req.url).path;
93
+ const path = (0, url_1.parse)(req.url).path;
93
94
  const socks = this.socksByPath.get(path);
94
95
  if (!socks) {
95
96
  client.close();
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.ServerEvents = void 0;
19
20
  const ws_ipc_1 = require("../../lib-common/ipc/ws-ipc");
@@ -27,8 +28,8 @@ class ServerEvents {
27
28
  Object.seal(this);
28
29
  }
29
30
  attachIPC(userId, ws) {
30
- const comm = ws_ipc_1.makeJsonCommPoint(ws);
31
- const ipc = ws_ipc_1.makeEventfulServer(this.ipcChannel, comm);
31
+ const comm = (0, ws_ipc_1.makeJsonCommPoint)(ws);
32
+ const ipc = (0, ws_ipc_1.makeEventfulServer)(this.ipcChannel, comm);
32
33
  for (const channel of this.eventChannels) {
33
34
  ipc.addEventGroup(channel, async () => { });
34
35
  }
@@ -48,7 +49,7 @@ class ServerEvents {
48
49
  }
49
50
  }
50
51
  get eventsSink() {
51
- return binding_1.bind(this, this.sendEvent);
52
+ return (0, binding_1.bind)(this, this.sendEvent);
52
53
  }
53
54
  }
54
55
  exports.ServerEvents = ServerEvents;
@@ -38,16 +38,16 @@ function provisioningApp(sessions, users, certifier, computeDHSharedKey) {
38
38
  const app = express();
39
39
  app.disable('etag');
40
40
  // MailerId certificate provisioning routes
41
- app.post('/' + api.pkl.START_URL_END, sessions.checkSession(), body_parsers_1.json('1kb'), start_exchange_1.startPKLogin(users.getUserParamsAndKey, sessions.generate, computeDHSharedKey));
42
- app.post('/' + api.pkl.COMPL_URL_END, sessions.ensureOpenedSession(), body_parsers_1.binary('1kb'), complete_exchange_1.completePKLogin());
43
- app.post('/' + api.certify.URL_END, sessions.ensureAuthorizedSession(), body_parsers_1.binary('16kb'), certify_1.certify(certifier.certify));
41
+ app.post('/' + api.pkl.START_URL_END, sessions.checkSession(), (0, body_parsers_1.json)('1kb'), (0, start_exchange_1.startPKLogin)(users.getUserParamsAndKey, sessions.generate, computeDHSharedKey));
42
+ app.post('/' + api.pkl.COMPL_URL_END, sessions.ensureOpenedSession(), (0, body_parsers_1.binary)('1kb'), (0, complete_exchange_1.completePKLogin)());
43
+ app.post('/' + api.certify.URL_END, sessions.ensureAuthorizedSession(), (0, body_parsers_1.binary)('16kb'), (0, certify_1.certify)(certifier.certify));
44
44
  return app;
45
45
  }
46
46
  function makeApp(rootFolder, domain, certFile) {
47
47
  const app = express();
48
- const certProvisSessions = sessions_1.makeSessionFactory(2 * 60);
49
- const users = users_1.makeFactory(rootFolder);
50
- const certifier = certifier_1.makeSingleProcCertifier(domain, certFile);
48
+ const certProvisSessions = (0, sessions_1.makeSessionFactory)(2 * 60);
49
+ const users = (0, users_1.makeFactory)(rootFolder);
50
+ const certifier = (0, certifier_1.makeSingleProcCertifier)(domain, certFile);
51
51
  app.use(PROVISIONING_PATH, provisioningApp(certProvisSessions, users, certifier, compute_login_dhshared_key_1.calcNaClBoxSharedKey));
52
52
  // MailerId display of service parameters, as per protocol
53
53
  app.get('/', (req, res) => {
@@ -62,7 +62,7 @@ function makeApp(rootFolder, domain, certFile) {
62
62
  };
63
63
  res.status(200).json(json); // content type application/json
64
64
  });
65
- app.use(error_handler_1.makeErrHandler());
65
+ app.use((0, error_handler_1.makeErrHandler)());
66
66
  return app;
67
67
  }
68
68
  exports.makeApp = makeApp;
@@ -6,12 +6,10 @@ export interface RootCerts {
6
6
  current: SignedLoad;
7
7
  previous: SignedLoad[];
8
8
  }
9
- export interface ICertify {
10
- (userPKey: JsonKey, address: string, validFor?: number): {
11
- userCert: SignedLoad;
12
- provCert: SignedLoad;
13
- };
14
- }
9
+ export declare type ICertify = (userPKey: JsonKey, address: string, validFor?: number) => {
10
+ userCert: SignedLoad;
11
+ provCert: SignedLoad;
12
+ };
15
13
  export interface Certifier {
16
14
  certify: ICertify;
17
15
  getRootCert(): SignedLoad;
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.makeSingleProcCertifier = exports.MAX_USER_CERT_VALIDITY = exports.PROVIDER_CERT_VALIDITY = exports.ROOT_CERT_VALIDITY = void 0;
19
20
  const ecma_nacl_1 = require("ecma-nacl");
@@ -28,7 +29,7 @@ exports.MAX_USER_CERT_VALIDITY = 24 * 60 * 60;
28
29
  function loadOrGenerateRootCert(domain, path) {
29
30
  let certsAndKey;
30
31
  try {
31
- certsAndKey = JSON.parse(fs_1.readFileSync(path, { encoding: 'utf8', flag: 'r' }));
32
+ certsAndKey = JSON.parse((0, fs_1.readFileSync)(path, { encoding: 'utf8', flag: 'r' }));
32
33
  }
33
34
  catch (err) {
34
35
  if (err.code === file_1.Code.notFound) {
@@ -38,13 +39,13 @@ function loadOrGenerateRootCert(domain, path) {
38
39
  throw err;
39
40
  }
40
41
  }
41
- const certDomain = jwkeys_1.getKeyCert(certsAndKey.certs.current).issuer;
42
+ const certDomain = (0, jwkeys_1.getKeyCert)(certsAndKey.certs.current).issuer;
42
43
  if (certDomain !== domain) {
43
44
  throw new Error('Give domain ' + domain +
44
45
  ' does not equal domain in certificates file: ' + certDomain);
45
46
  }
46
47
  try {
47
- const pkeyBytes = ecma_nacl_1.signing.extract_pkey(jwkeys_1.keyFromJson(certsAndKey.skey, mid_sigs_NaCl_Ed_1.KEY_USE.ROOT, ecma_nacl_1.signing.JWK_ALG_NAME, ecma_nacl_1.signing.SECRET_KEY_LENGTH).k);
48
+ const pkeyBytes = ecma_nacl_1.signing.extract_pkey((0, jwkeys_1.keyFromJson)(certsAndKey.skey, mid_sigs_NaCl_Ed_1.KEY_USE.ROOT, ecma_nacl_1.signing.JWK_ALG_NAME, ecma_nacl_1.signing.SECRET_KEY_LENGTH).k);
48
49
  const rootPKey = {
49
50
  k: pkeyBytes,
50
51
  kid: certsAndKey.skey.kid,
@@ -70,7 +71,7 @@ function createFirstCert(domain, path, log) {
70
71
  previous: []
71
72
  }
72
73
  };
73
- fs_1.writeFileSync(path, JSON.stringify(toSave), { encoding: 'utf8', flag: 'wx' });
74
+ (0, fs_1.writeFileSync)(path, JSON.stringify(toSave), { encoding: 'utf8', flag: 'wx' });
74
75
  return toSave;
75
76
  }
76
77
  function updateCert(domain, path, certs, log) {
@@ -85,7 +86,7 @@ function updateCert(domain, path, certs, log) {
85
86
  previous: [certs.current].concat(certs.previous)
86
87
  }
87
88
  };
88
- fs_1.writeFileSync(path, JSON.stringify(toSave), { encoding: 'utf8', flag: 'w' });
89
+ (0, fs_1.writeFileSync)(path, JSON.stringify(toSave), { encoding: 'utf8', flag: 'w' });
89
90
  return toSave;
90
91
  }
91
92
  const UPDATE_PERIOD = 8 * 60 * 60;
@@ -112,7 +113,7 @@ function makeSingleProcCertifier(domain, certsPath) {
112
113
  provCert = provider.cert;
113
114
  Object.freeze(provCert);
114
115
  certifier = mid_sigs_NaCl_Ed_1.idProvider.makeIdProviderCertifier(domain, exports.MAX_USER_CERT_VALIDITY, provider.skey);
115
- updateTime = (jwkeys_1.getKeyCert(provCert).expiresAt - 2 * UPDATE_PERIOD) * 1000;
116
+ updateTime = ((0, jwkeys_1.getKeyCert)(provCert).expiresAt - 2 * UPDATE_PERIOD) * 1000;
116
117
  }
117
118
  updateCertifier();
118
119
  const timer = setInterval(updateCertifier, UPDATE_PERIOD * 1000);
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.calcNaClBoxSharedKey = void 0;
19
20
  /**
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.makeSessionFactory = void 0;
19
20
  const mem_backed_sessions_factory_1 = require("../../lib-server/resources/mem-backed-sessions-factory");
@@ -27,9 +27,9 @@ const path_1 = require("path");
27
27
  const server_data_folders_1 = require("../../lib-server/resources/server-data-folders");
28
28
  async function getUser(rootFolder, userId) {
29
29
  try {
30
- const userFolder = server_data_folders_1.userDataInRootFolder(rootFolder, userId);
31
- const midParamsPath = path_1.join(userFolder, 'info', 'mid-params');
32
- const str = await async_fs_node_1.readFile(midParamsPath, { encoding: 'utf8' });
30
+ const userFolder = (0, server_data_folders_1.userDataInRootFolder)(rootFolder, userId);
31
+ const midParamsPath = (0, path_1.join)(userFolder, 'info', 'mid-params');
32
+ const str = await (0, async_fs_node_1.readFile)(midParamsPath, { encoding: 'utf8' });
33
33
  return JSON.parse(str);
34
34
  }
35
35
  catch (exc) {
@@ -41,7 +41,7 @@ async function getUser(rootFolder, userId) {
41
41
  }
42
42
  const MID_KEY_USE = 'login-pub-key';
43
43
  function extractPKeyBytes(pkey) {
44
- return jwkeys_1.keyFromJson(pkey, MID_KEY_USE, ecma_nacl_1.box.JWK_ALG_NAME, ecma_nacl_1.box.KEY_LENGTH).k;
44
+ return (0, jwkeys_1.keyFromJson)(pkey, MID_KEY_USE, ecma_nacl_1.box.JWK_ALG_NAME, ecma_nacl_1.box.KEY_LENGTH).k;
45
45
  }
46
46
  function makeFactory(rootFolder) {
47
47
  const factory = {
@@ -51,7 +51,7 @@ function certify(certifyingFunc) {
51
51
  res.status(provisioning_1.certify.SC.malformed).send('Missing or incorrectly formatted payload.');
52
52
  return;
53
53
  }
54
- res.status(provisioning_1.certify.SC.ok).send(buffer_utils_1.toBuffer(encryptor.pack(buffer_utils_1.utf8.pack(JSON.stringify(signedCerts)))));
54
+ res.status(provisioning_1.certify.SC.ok).send((0, buffer_utils_1.toBuffer)(encryptor.pack(buffer_utils_1.utf8.pack(JSON.stringify(signedCerts)))));
55
55
  session.close();
56
56
  };
57
57
  }
package/build/main.js CHANGED
@@ -30,7 +30,7 @@ if (!confFile) {
30
30
  console.error(`Configuration file is not given. It should be the first script argument.`);
31
31
  process.exit(-1);
32
32
  }
33
- const conf = JSON.parse(fs_1.readFileSync(confFile, 'utf8'));
33
+ const conf = JSON.parse((0, fs_1.readFileSync)(confFile, 'utf8'));
34
34
  const noop = () => { };
35
35
  (async () => {
36
36
  if (!conf.servicesConnect) {
@@ -39,14 +39,14 @@ const noop = () => { };
39
39
  return;
40
40
  }
41
41
  try {
42
- const prevPidStr = await async_fs_node_1.readFile(PID_FILE, { encoding: 'utf8' });
42
+ const prevPidStr = await (0, async_fs_node_1.readFile)(PID_FILE, { encoding: 'utf8' });
43
43
  const prevPid = Number.parseInt(prevPidStr);
44
44
  if (!Number.isNaN(prevPid)) {
45
- child_process_1.execSync(`kill -SIGTERM ${prevPid}`);
46
- while (!!child_process_1.execSync(`ps ${prevPid} | grep ${prevPid}`)) {
47
- await processes_1.sleep(1000);
45
+ (0, child_process_1.execSync)(`kill -SIGTERM ${prevPid}`);
46
+ while (!!(0, child_process_1.execSync)(`ps ${prevPid} | grep ${prevPid}`)) {
47
+ await (0, processes_1.sleep)(1000);
48
48
  }
49
- await async_fs_node_1.unlink(PID_FILE).catch(noop);
49
+ await (0, async_fs_node_1.unlink)(PID_FILE).catch(noop);
50
50
  }
51
51
  }
52
52
  catch (err) {
@@ -61,16 +61,16 @@ const noop = () => { };
61
61
  }
62
62
  app.stop().then(err => console.log(err));
63
63
  app = undefined;
64
- async_fs_node_1.unlink(PID_FILE).catch(noop);
64
+ (0, async_fs_node_1.unlink)(PID_FILE).catch(noop);
65
65
  }
66
66
  try {
67
67
  app = new app_1.AppWithWSs();
68
- app.use(services_1.servicesApp(conf));
69
- app.use(services_1.adminApp(conf));
68
+ app.use((0, services_1.servicesApp)(conf));
69
+ app.use((0, services_1.adminApp)(conf));
70
70
  const { hostname, port, sslOpts } = conf.servicesConnect;
71
71
  await app.start(sslOpts, port, hostname);
72
72
  console.log(`Started 3NWeb server at address "${hostname}", port ${port}, ${sslOpts ? 'via TLS' : 'without TLS, and requiring TLS reverse proxy infront.'}`);
73
- fs_1.writeFileSync(PID_FILE, `${process.pid}`);
73
+ (0, fs_1.writeFileSync)(PID_FILE, `${process.pid}`);
74
74
  process.on('SIGINT', stopProcess);
75
75
  process.on('SIGTERM', stopProcess);
76
76
  }
package/build/mock/dns.js CHANGED
@@ -56,7 +56,7 @@ class DNSMock {
56
56
  }
57
57
  }
58
58
  // node's definition incorrectly describes callback argument
59
- this.resolveTxt = binding_1.bind(this, this.mockResolve);
59
+ this.resolveTxt = (0, binding_1.bind)(this, this.mockResolve);
60
60
  Object.freeze(this);
61
61
  }
62
62
  mockResolve(domain, callback) {
@@ -27,9 +27,9 @@ const app_1 = require("../lib-server/web-sockets/app");
27
27
  const path_1 = require("path");
28
28
  const signup_tokens_1 = require("../admin/signup-tokens");
29
29
  const SERVER_MOCK_CHANNEL = 'server-mock';
30
- const parent = node_child_ipc_1.commToParent(SERVER_MOCK_CHANNEL);
30
+ const parent = (0, node_child_ipc_1.commToParent)(SERVER_MOCK_CHANNEL);
31
31
  const DEFAULT_SERVICE_PORT = 8088;
32
- const DEFAULT_DATA_FOLDER = path_1.join(__dirname, '/../../mock-data');
32
+ const DEFAULT_DATA_FOLDER = (0, path_1.join)(__dirname, '/../../mock-data');
33
33
  let dnsMock;
34
34
  let app;
35
35
  parent.addHandler('set-dns-mock', setDnsMock);
@@ -38,7 +38,7 @@ async function setDnsMock(env) {
38
38
  dns.resolveTxt = dnsMock.resolveTxt;
39
39
  }
40
40
  async function cleanDataFolder() {
41
- await async_fs_node_1.rmDirWithContent(DEFAULT_DATA_FOLDER).catch((exc) => {
41
+ await (0, async_fs_node_1.rmDirWithContent)(DEFAULT_DATA_FOLDER).catch((exc) => {
42
42
  if (!exc.notFound) {
43
43
  throw exc;
44
44
  }
@@ -50,7 +50,7 @@ async function start(env) {
50
50
  const servicePort = (env.req.port ? env.req.port : DEFAULT_SERVICE_PORT);
51
51
  const dataFolder = (env.req.dataFolder ?
52
52
  env.req.dataFolder : DEFAULT_DATA_FOLDER);
53
- const noTokensFilePath = path_1.join(dataFolder, 'no-tokens-signup.json');
53
+ const noTokensFilePath = (0, path_1.join)(dataFolder, 'no-tokens-signup.json');
54
54
  const conf = {
55
55
  rootFolder: dataFolder,
56
56
  domain: env.req.midServiceDomain,
@@ -63,19 +63,19 @@ async function start(env) {
63
63
  storage: true
64
64
  },
65
65
  mailerId: {
66
- certs: path_1.join(dataFolder, 'mid-certs.json')
66
+ certs: (0, path_1.join)(dataFolder, 'mid-certs.json')
67
67
  }
68
68
  };
69
69
  // prepare data folders
70
70
  await cleanDataFolder();
71
- await async_fs_node_1.mkdir(dataFolder);
71
+ await (0, async_fs_node_1.mkdir)(dataFolder);
72
72
  // write to-tokens signup file
73
- const noTokenCtx = signup_tokens_1.makeMultiDomainSignupCtx(env.req.signupDomains);
74
- await async_fs_node_1.writeFile(noTokensFilePath, JSON.stringify(noTokenCtx), { encoding: 'utf8' });
73
+ const noTokenCtx = (0, signup_tokens_1.makeMultiDomainSignupCtx)(env.req.signupDomains);
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(services_1.adminApp(conf));
78
- app.use(services_1.servicesApp(conf));
77
+ app.use((0, services_1.adminApp)(conf));
78
+ app.use((0, services_1.servicesApp)(conf));
79
79
  // start app
80
80
  await app.start(tls_options_1.sslOpts, servicePort);
81
81
  // set client https to trust the cert (MailerId checks need this)
@@ -34,7 +34,7 @@ function commToChild(channel, child) {
34
34
  child.send(env);
35
35
  }
36
36
  };
37
- return generic_ipc_1.makeRequestingClient(channel, rawDuplex);
37
+ return (0, generic_ipc_1.makeRequestingClient)(channel, rawDuplex);
38
38
  }
39
39
  exports.commToChild = commToChild;
40
40
  function commToParent(channel) {
@@ -57,7 +57,7 @@ function commToParent(channel) {
57
57
  process.send(env);
58
58
  }
59
59
  };
60
- return generic_ipc_1.makeRequestServer(channel, commPoint);
60
+ return (0, generic_ipc_1.makeRequestServer)(channel, commPoint);
61
61
  }
62
62
  exports.commToParent = commToParent;
63
63
  Object.freeze(exports);
@@ -47,7 +47,7 @@ function setTestCertsAndDNS(domains, thisSrvLoc) {
47
47
  }
48
48
  exports.setTestCertsAndDNS = setTestCertsAndDNS;
49
49
  async function startOn(srvDomain, dataDir, port, domains) {
50
- const noTokensFilePath = path_1.join(dataDir, 'no-tokens-signup.json');
50
+ const noTokensFilePath = (0, path_1.join)(dataDir, 'no-tokens-signup.json');
51
51
  const conf = {
52
52
  rootFolder: dataDir,
53
53
  domain: srvDomain,
@@ -60,7 +60,7 @@ async function startOn(srvDomain, dataDir, port, domains) {
60
60
  noTokenFile: noTokensFilePath
61
61
  },
62
62
  mailerId: {
63
- certs: path_1.join(dataDir, 'mid-certs.json')
63
+ certs: (0, path_1.join)(dataDir, 'mid-certs.json')
64
64
  },
65
65
  servicesConnect: {
66
66
  port,
@@ -68,22 +68,22 @@ async function startOn(srvDomain, dataDir, port, domains) {
68
68
  }
69
69
  };
70
70
  // prepare data folders
71
- await async_fs_node_1.mkdir(dataDir)
71
+ await (0, async_fs_node_1.mkdir)(dataDir)
72
72
  .catch((exc) => {
73
73
  if (!exc.alreadyExists) {
74
74
  throw exc;
75
75
  }
76
76
  });
77
77
  // write to-tokens signup file
78
- const noTokenCtx = signup_tokens_1.makeMultiDomainSignupCtx(domains.noTokenSignup);
79
- await async_fs_node_1.writeFile(noTokensFilePath, JSON.stringify(noTokenCtx), { encoding: 'utf8' });
78
+ const noTokenCtx = (0, signup_tokens_1.makeMultiDomainSignupCtx)(domains.noTokenSignup);
79
+ await (0, async_fs_node_1.writeFile)(noTokensFilePath, JSON.stringify(noTokenCtx), { encoding: 'utf8' });
80
80
  // certs and DNS
81
81
  const allDomains = domains.noTokenSignup.concat(domains.other);
82
82
  const dnsMock = setTestCertsAndDNS(allDomains, `${srvDomain}:${port}`);
83
83
  // setup services and start
84
84
  const app = new app_1.AppWithWSs();
85
- app.use(services_1.adminApp(conf));
86
- app.use(services_1.servicesApp(conf));
85
+ app.use((0, services_1.adminApp)(conf));
86
+ app.use((0, services_1.servicesApp)(conf));
87
87
  await app.start(conf.servicesConnect.sslOpts, conf.servicesConnect.port);
88
88
  return { dnsMock, stop: () => app.stop() };
89
89
  }
@@ -60,25 +60,25 @@ function getConfsFromEnv() {
60
60
  }
61
61
  // Make data folders
62
62
  ensureFolderPresence(dataDir, true);
63
- dataDir = fs_1.realpathSync(dataDir);
63
+ dataDir = (0, fs_1.realpathSync)(dataDir);
64
64
  let midCerts = process.env[CERTS_FILE_VAR];
65
65
  if (!midCerts) {
66
- midCerts = path_1.join(dataDir, 'mid-certs.json');
66
+ midCerts = (0, path_1.join)(dataDir, 'mid-certs.json');
67
67
  }
68
68
  const noTokenFile = process.env[NO_TOKENS_FILE];
69
69
  return makeConf(domain, dataDir, midCerts, noTokenFile);
70
70
  }
71
71
  exports.getConfsFromEnv = getConfsFromEnv;
72
72
  function ensureFolderPresence(path, doLog) {
73
- if (async_fs_node_1.existsFolderSync(path)) {
73
+ if ((0, async_fs_node_1.existsFolderSync)(path)) {
74
74
  if (doLog) {
75
75
  console.log(`Using existing data folder ${path}`);
76
76
  }
77
77
  }
78
78
  else {
79
- fs_1.mkdirSync(path);
79
+ (0, fs_1.mkdirSync)(path);
80
80
  if (doLog) {
81
- console.log(`Created ${fs_1.realpathSync(path)}`);
81
+ console.log(`Created ${(0, fs_1.realpathSync)(path)}`);
82
82
  }
83
83
  }
84
84
  }
@@ -117,11 +117,11 @@ function getTLSParamsFromEnv() {
117
117
  }
118
118
  }
119
119
  async function addSingleUserSignup(rootFolder, userId) {
120
- const token = await signup_tokens_1.generateToken();
121
- const ctx = signup_tokens_1.makeSingleUserSignupCtx(token, userId);
122
- const fPath = signup_tokens_1.tokenPath(rootFolder, token);
120
+ const token = await (0, signup_tokens_1.generateToken)();
121
+ const ctx = (0, signup_tokens_1.makeSingleUserSignupCtx)(token, userId);
122
+ const fPath = (0, signup_tokens_1.tokenPath)(rootFolder, token);
123
123
  try {
124
- await async_fs_node_1.writeFile(fPath, JSON.stringify(ctx), { encoding: 'utf8', flag: 'wx' });
124
+ await (0, async_fs_node_1.writeFile)(fPath, JSON.stringify(ctx), { encoding: 'utf8', flag: 'wx' });
125
125
  return token;
126
126
  }
127
127
  catch (exc) {
@@ -129,7 +129,7 @@ async function addSingleUserSignup(rootFolder, userId) {
129
129
  return addSingleUserSignup(rootFolder, userId);
130
130
  }
131
131
  else if (exc.notFound) {
132
- await async_fs_node_1.mkdir(server_data_folders_1.tokensInRootFolder(rootFolder))
132
+ await (0, async_fs_node_1.mkdir)((0, server_data_folders_1.tokensInRootFolder)(rootFolder))
133
133
  .catch((exc) => {
134
134
  if (!exc.alreadyExists) {
135
135
  throw exc;
package/build/run.js CHANGED
@@ -20,11 +20,11 @@ const app_1 = require("./lib-server/web-sockets/app");
20
20
  const run_config_1 = require("./run-config");
21
21
  (async () => {
22
22
  try {
23
- const conf = run_config_1.getConfsFromEnv();
23
+ const conf = (0, run_config_1.getConfsFromEnv)();
24
24
  const app = new app_1.AppWithWSs();
25
- app.use(services_1.servicesApp(conf));
26
- app.use(services_1.adminApp(conf));
27
- const { address, port, sslOpts } = run_config_1.getBindParamsFromEnv();
25
+ app.use((0, services_1.servicesApp)(conf));
26
+ app.use((0, services_1.adminApp)(conf));
27
+ const { address, port, sslOpts } = (0, run_config_1.getBindParamsFromEnv)();
28
28
  await app.start(sslOpts, port, address);
29
29
  console.log(`Started 3NWeb server at address ${address}, port ${port}, ${sslOpts ? 'via TLS' : 'without TLS, and requiring TLS reverse proxy infront.'}`);
30
30
  }
package/build/services.js CHANGED
@@ -28,21 +28,21 @@ function servicesApp(conf) {
28
28
  throw new Error('Missing enabled-services sections in confs.');
29
29
  }
30
30
  const app = new app_1.AppWithWSs();
31
- const midAuthorizer = mailerid_authorizer_1.validator(); // share, allowing for caching of certs
31
+ const midAuthorizer = (0, mailerid_authorizer_1.validator)(); // share, allowing for caching of certs
32
32
  if (conf.enabledServices.mailerId) {
33
- app.http.use('/mailerid', mailerId_app_1.makeApp(conf.rootFolder, conf.domain, conf.mailerId.certs));
33
+ app.http.use('/mailerid', (0, mailerId_app_1.makeApp)(conf.rootFolder, conf.domain, conf.mailerId.certs));
34
34
  }
35
35
  if (conf.enabledServices.asmail) {
36
- app.use('/asmail', asmail_app_1.makeApp(conf.rootFolder, conf.domain, midAuthorizer));
36
+ app.use('/asmail', (0, asmail_app_1.makeApp)(conf.rootFolder, conf.domain, midAuthorizer));
37
37
  }
38
38
  if (conf.enabledServices.storage) {
39
- app.use('/3nstorage', _3nstorage_app_1.makeApp(conf.rootFolder, conf.domain, midAuthorizer));
39
+ app.use('/3nstorage', (0, _3nstorage_app_1.makeApp)(conf.rootFolder, conf.domain, midAuthorizer));
40
40
  }
41
41
  return app;
42
42
  }
43
43
  exports.servicesApp = servicesApp;
44
44
  function adminApp(conf) {
45
- return new app_1.AppWithWSs(admin_app_1.makeApp(conf));
45
+ return new app_1.AppWithWSs((0, admin_app_1.makeApp)(conf));
46
46
  }
47
47
  exports.adminApp = adminApp;
48
48
  Object.freeze(exports);
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "spec-3nweb-server",
3
- "version": "1.3.5",
3
+ "version": "1.4.0",
4
4
  "description": "3NWeb spec server.",
5
5
  "main": "build/lib.js",
6
6
  "types": "build/lib.d.ts",
7
7
  "scripts": {
8
- "test": "tsc -p ts-code && node build/tests/jasmine.js",
9
- "build": "tsc -p ts-code"
8
+ "build": "tsc -p ts-code",
9
+ "test": "node build/tests/jasmine.js",
10
+ "clear-for-packing": "npm prune --production && bash -c \"rm -rf build/mock build/tests 'node_modules/ecma-nacl/c sources'\"",
11
+ "clear-for-packing-mock": "npm prune --production && bash -c \"rm -rf build/tests 'node_modules/ecma-nacl/c sources'\"",
12
+ "pack-deb": "npm run clear-for-packing && bash packing/deb/create-bin.sh"
10
13
  },
11
14
  "repository": {
12
15
  "type": "git",
@@ -39,7 +42,7 @@
39
42
  "@types/ws": "^4.0.0",
40
43
  "jasmine": "^2.5.3",
41
44
  "rxjs": "^5.3.0",
42
- "typescript": "^3.7.3",
45
+ "typescript": "^4.6.3",
43
46
  "xhr2": "^0.1.3"
44
47
  },
45
48
  "readmeFilename": "README.md"