spec-3nweb-server 1.3.6 → 1.4.1

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 (94) 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 +4 -3
  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.js +3 -3
  70. package/build/lib-server/resources/server-data-folders.js +23 -23
  71. package/build/lib-server/resources/sessions.js +5 -5
  72. package/build/lib-server/resources/user-files.js +8 -8
  73. package/build/lib-server/routes/pub-key-login/complete-exchange.js +4 -3
  74. package/build/lib-server/routes/pub-key-login/start-exchange.js +7 -6
  75. package/build/lib-server/routes/sessions/mid-auth.js +6 -5
  76. package/build/lib-server/routes/sessions/start.js +4 -3
  77. package/build/lib-server/web-sockets/app.js +6 -5
  78. package/build/lib-server/web-sockets/server-events.js +5 -4
  79. package/build/mailerId/mailerId-app.js +7 -7
  80. package/build/mailerId/resources/certifier.d.ts +4 -6
  81. package/build/mailerId/resources/certifier.js +8 -7
  82. package/build/mailerId/resources/compute-login-dhshared-key.js +2 -1
  83. package/build/mailerId/resources/sessions.js +2 -1
  84. package/build/mailerId/resources/users.js +4 -4
  85. package/build/mailerId/routes/certify.js +1 -1
  86. package/build/main.js +10 -10
  87. package/build/mock/dns.js +1 -1
  88. package/build/mock/mock-as-child-proc.js +10 -10
  89. package/build/mock/node-child-ipc.js +2 -2
  90. package/build/mock/run-in-proc.js +7 -7
  91. package/build/run-config.js +10 -10
  92. package/build/run.js +4 -4
  93. package/build/services.js +5 -5
  94. package/package.json +9 -6
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2017, 2019 3NSoft Inc.
3
+ Copyright (C) 2015 - 2017, 2019, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -13,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.objRemoved = exports.objChanged = exports.wsEventChannel = exports.archiveRoot = exports.archiveObj = exports.cancelRootTransaction = exports.cancelTransaction = exports.addDiffSectionTo = exports.sanitizedDiff = exports.archivedRootVersion = exports.archivedObjVersion = exports.currentRootObj = exports.currentObj = exports.keyDerivParams = exports.PARAM_SC = exports.sessionParams = exports.closeSession = exports.midLogin = exports.BIN_TYPE = exports.HTTP_HEADER = exports.ERR_SC = void 0;
19
20
  /**
@@ -75,15 +76,15 @@ var currentObj;
75
76
  (function (currentObj) {
76
77
  currentObj.EXPRESS_URL_END = 'obj/:objId/current';
77
78
  function getReqUrlEnd(objId, opts) {
78
- return `obj/${objId}/current${opts ? `?${querystring_1.stringify(opts)}` : ''}`;
79
+ return `obj/${objId}/current${opts ? `?${(0, querystring_1.stringify)(opts)}` : ''}`;
79
80
  }
80
81
  currentObj.getReqUrlEnd = getReqUrlEnd;
81
82
  function firstPutReqUrlEnd(objId, opts) {
82
- return `obj/${objId}/current?${querystring_1.stringify(opts)}`;
83
+ return `obj/${objId}/current?${(0, querystring_1.stringify)(opts)}`;
83
84
  }
84
85
  currentObj.firstPutReqUrlEnd = firstPutReqUrlEnd;
85
86
  function secondPutReqUrlEnd(objId, opts) {
86
- return `obj/${objId}/current?${querystring_1.stringify(opts)}`;
87
+ return `obj/${objId}/current?${(0, querystring_1.stringify)(opts)}`;
87
88
  }
88
89
  currentObj.secondPutReqUrlEnd = secondPutReqUrlEnd;
89
90
  currentObj.SC = {
@@ -105,15 +106,15 @@ var currentRootObj;
105
106
  (function (currentRootObj) {
106
107
  currentRootObj.EXPRESS_URL_END = 'root/current';
107
108
  function getReqUrlEnd(opts) {
108
- return `root/current${opts ? `?${querystring_1.stringify(opts)}` : ''}`;
109
+ return `root/current${opts ? `?${(0, querystring_1.stringify)(opts)}` : ''}`;
109
110
  }
110
111
  currentRootObj.getReqUrlEnd = getReqUrlEnd;
111
112
  function firstPutReqUrlEnd(opts) {
112
- return `root/current?${querystring_1.stringify(opts)}`;
113
+ return `root/current?${(0, querystring_1.stringify)(opts)}`;
113
114
  }
114
115
  currentRootObj.firstPutReqUrlEnd = firstPutReqUrlEnd;
115
116
  function secondPutReqUrlEnd(opts) {
116
- return `root/current?${querystring_1.stringify(opts)}`;
117
+ return `root/current?${(0, querystring_1.stringify)(opts)}`;
117
118
  }
118
119
  currentRootObj.secondPutReqUrlEnd = secondPutReqUrlEnd;
119
120
  currentRootObj.SC = currentObj.SC;
@@ -126,7 +127,7 @@ var archivedObjVersion;
126
127
  if (opts) {
127
128
  opts.ver = version;
128
129
  }
129
- const query = (opts ? `?${querystring_1.stringify(opts)}` : '');
130
+ const query = (opts ? `?${(0, querystring_1.stringify)(opts)}` : '');
130
131
  return `/obj/${objId}/archived${query}`;
131
132
  }
132
133
  archivedObjVersion.getReqUrlEnd = getReqUrlEnd;
@@ -146,7 +147,7 @@ var archivedRootVersion;
146
147
  if (opts) {
147
148
  opts.ver = version;
148
149
  }
149
- const query = (opts ? `?${querystring_1.stringify(opts)}` : '');
150
+ const query = (opts ? `?${(0, querystring_1.stringify)(opts)}` : '');
150
151
  return `root/archived${query}`;
151
152
  }
152
153
  archivedRootVersion.getReqUrlEnd = getReqUrlEnd;
@@ -97,11 +97,11 @@ var msgObj;
97
97
  (function (msgObj) {
98
98
  msgObj.EXPRESS_URL_END = 'msg/obj/:objId';
99
99
  function firstPutReqUrlEnd(objId, opts) {
100
- return `msg/obj/${objId}?${querystring_1.stringify(opts)}`;
100
+ return `msg/obj/${objId}?${(0, querystring_1.stringify)(opts)}`;
101
101
  }
102
102
  msgObj.firstPutReqUrlEnd = firstPutReqUrlEnd;
103
103
  function secondPutReqUrlEnd(objId, opts) {
104
- return `msg/obj/${objId}?${querystring_1.stringify(opts)}`;
104
+ return `msg/obj/${objId}?${(0, querystring_1.stringify)(opts)}`;
105
105
  }
106
106
  msgObj.secondPutReqUrlEnd = secondPutReqUrlEnd;
107
107
  msgObj.SC = {
@@ -114,7 +114,7 @@ var msgObj;
114
114
  (function (msgObj) {
115
115
  msgObj.EXPRESS_URL_END = 'msg/:msgId/obj/:objId';
116
116
  function genUrlEnd(msgId, objId, opts) {
117
- let optStr = (opts ? '?' + querystring_1.stringify(opts) : '');
117
+ let optStr = (opts ? '?' + (0, querystring_1.stringify)(opts) : '');
118
118
  return `msg/${msgId}/obj/${objId}${optStr}`;
119
119
  }
120
120
  msgObj.genUrlEnd = genUrlEnd;
@@ -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.stringToNumOfBytes = void 0;
19
20
  const mapAmountEndings = {
@@ -50,10 +50,10 @@ function emptyBody() {
50
50
  // get and check Content-Length
51
51
  const contentLength = parseInt(req.get(HTTP_HEADER.contentLength), 10);
52
52
  if (isNaN(contentLength)) {
53
- return next(error_handler_1.makeErr(411, "Content-Length header is required with proper number."));
53
+ return next((0, error_handler_1.makeErr)(411, "Content-Length header is required with proper number."));
54
54
  }
55
55
  if (contentLength !== 0) {
56
- return next(error_handler_1.makeErr(413, "Request body is too long."));
56
+ return next((0, error_handler_1.makeErr)(413, "Request body is too long."));
57
57
  }
58
58
  next();
59
59
  };
@@ -73,22 +73,22 @@ async function parseBinaryBodyWithExpectedSize(req, expectedLen) {
73
73
  }
74
74
  // check type
75
75
  if (!req.is(TYPES.bin)) {
76
- throw error_handler_1.makeErr(415, `Content-Type must be ${TYPES.bin} for this call.`);
76
+ throw (0, error_handler_1.makeErr)(415, `Content-Type must be ${TYPES.bin} for this call.`);
77
77
  }
78
78
  // check length declared in header
79
79
  const contentLength = parseInt(req.get(HTTP_HEADER.contentLength), 10);
80
80
  if (isNaN(contentLength)) {
81
- throw error_handler_1.makeErr(411, "Content-Length header is required with proper number.");
81
+ throw (0, error_handler_1.makeErr)(411, "Content-Length header is required with proper number.");
82
82
  }
83
83
  if (contentLength !== expectedLen) {
84
- throw error_handler_1.makeErr(400, "Unexpected number of bytes.");
84
+ throw (0, error_handler_1.makeErr)(400, "Unexpected number of bytes.");
85
85
  }
86
86
  }
87
87
  catch (err) {
88
88
  attachByteDrainToRequest(req);
89
89
  throw err;
90
90
  }
91
- const deffered = processes_1.defer();
91
+ const deffered = (0, processes_1.defer)();
92
92
  const bytes = new common_1.BytesFIFOBuffer();
93
93
  // collect body bytes
94
94
  let erred = false;
@@ -101,7 +101,7 @@ async function parseBinaryBodyWithExpectedSize(req, expectedLen) {
101
101
  }
102
102
  else {
103
103
  erred = true;
104
- deffered.reject(error_handler_1.makeErr(400, "Request body is longer than expected."));
104
+ deffered.reject((0, error_handler_1.makeErr)(400, "Request body is longer than expected."));
105
105
  }
106
106
  });
107
107
  req.on('end', () => {
@@ -112,14 +112,14 @@ async function parseBinaryBodyWithExpectedSize(req, expectedLen) {
112
112
  deffered.resolve(bytes.getBytes(undefined));
113
113
  }
114
114
  else {
115
- deffered.reject(error_handler_1.makeErr(400, "Request body is shorter than expected."));
115
+ deffered.reject((0, error_handler_1.makeErr)(400, "Request body is shorter than expected."));
116
116
  }
117
117
  });
118
118
  return deffered.promise;
119
119
  }
120
120
  exports.parseBinaryBodyWithExpectedSize = parseBinaryBodyWithExpectedSize;
121
121
  function byteCollector(maxSize, contentType, parser) {
122
- const maxSizeNum = conf_util_1.stringToNumOfBytes(maxSize);
122
+ const maxSizeNum = (0, conf_util_1.stringToNumOfBytes)(maxSize);
123
123
  if ('string' !== typeof contentType) {
124
124
  throw new Error("Given 'contentType' argument must be a string.");
125
125
  }
@@ -127,19 +127,19 @@ function byteCollector(maxSize, contentType, parser) {
127
127
  // check Content-Type
128
128
  if (!req.is(contentType)) {
129
129
  attachByteDrainToRequest(req);
130
- return next(error_handler_1.makeErr(415, "Content-Type must be " +
130
+ return next((0, error_handler_1.makeErr)(415, "Content-Type must be " +
131
131
  contentType + " for this call."));
132
132
  }
133
133
  // get and check Content-Length
134
134
  const contentLength = parseInt(req.get(HTTP_HEADER.contentLength), 10);
135
135
  if (isNaN(contentLength)) {
136
136
  attachByteDrainToRequest(req);
137
- return next(error_handler_1.makeErr(411, "Content-Length header is required with proper number."));
137
+ return next((0, error_handler_1.makeErr)(411, "Content-Length header is required with proper number."));
138
138
  }
139
139
  // enforce agreed limit on request size
140
140
  if (contentLength > maxSizeNum) {
141
141
  attachByteDrainToRequest(req);
142
- return next(error_handler_1.makeErr(413, "Request body is too long."));
142
+ return next((0, error_handler_1.makeErr)(413, "Request body is too long."));
143
143
  }
144
144
  // XXX we may use fifo here, postponing byte copying till moment, when
145
145
  // everything is downloaded
@@ -160,7 +160,7 @@ function byteCollector(maxSize, contentType, parser) {
160
160
  else {
161
161
  erred = true;
162
162
  req.body = null;
163
- next(error_handler_1.makeErr(413, "Request body is too long."));
163
+ next((0, error_handler_1.makeErr)(413, "Request body is too long."));
164
164
  }
165
165
  });
166
166
  req.on('end', () => {
@@ -201,11 +201,11 @@ function json(maxSize, allowNonObject) {
201
201
  req.body = JSON.parse(bodyAsStr);
202
202
  }
203
203
  catch (err) {
204
- return next(error_handler_1.makeErr(400, "Request body cannot be interpreted as JSON."));
204
+ return next((0, error_handler_1.makeErr)(400, "Request body cannot be interpreted as JSON."));
205
205
  }
206
206
  if (!allowNonObject &&
207
207
  (!req.body || (typeof req.body !== 'object'))) {
208
- return next(error_handler_1.makeErr(400, "Request body is not a JSON object."));
208
+ return next((0, error_handler_1.makeErr)(400, "Request body is not a JSON object."));
209
209
  }
210
210
  next();
211
211
  });
@@ -223,7 +223,7 @@ function textPlain(maxSize) {
223
223
  req.body = req.body.toString('utf8');
224
224
  }
225
225
  catch (err) {
226
- return next(error_handler_1.makeErr(400, "Request body cannot be interpreted as plain utf8 text."));
226
+ return next((0, error_handler_1.makeErr)(400, "Request body cannot be interpreted as plain utf8 text."));
227
227
  }
228
228
  next();
229
229
  });
@@ -27,7 +27,7 @@ const error_1 = require("../../lib-common/exceptions/error");
27
27
  * @param cause
28
28
  */
29
29
  function makeErr(code, msg, cause) {
30
- const err = error_1.errWithCause(cause, msg);
30
+ const err = (0, error_1.errWithCause)(cause, msg);
31
31
  err.status = code;
32
32
  return err;
33
33
  }
@@ -71,14 +71,14 @@ async function validate(rpDomain, sessionId, userId, assertion, userCert, provCe
71
71
  const validAt = Date.now() / 1000;
72
72
  try {
73
73
  // check that certificate is for the user
74
- const addressInCert = jwkeys_1.getPrincipalAddress(userCert);
74
+ const addressInCert = (0, jwkeys_1.getPrincipalAddress)(userCert);
75
75
  if (userId !== addressInCert) {
76
76
  return false;
77
77
  }
78
78
  // check that issuer is the one that provides MailerId service for
79
79
  // user's domain
80
- const issuer = jwkeys_1.getKeyCert(provCert).issuer;
81
- const serviceURL = await dns_1.get3NWebRecords(addressInCert, 'mailerid');
80
+ const issuer = (0, jwkeys_1.getKeyCert)(provCert).issuer;
81
+ const serviceURL = await (0, dns_1.get3NWebRecords)(addressInCert, 'mailerid');
82
82
  const domainInRecord = serviceURL.split('/')[0].split(':')[0];
83
83
  if (issuer !== domainInRecord) {
84
84
  return false;
@@ -51,7 +51,7 @@ class InMemorySessions extends sessions_1.BaseSessionFactory {
51
51
  async generate() {
52
52
  let newSessionId;
53
53
  do {
54
- newSessionId = buffer_utils_1.base64urlSafe.pack(await random_node_1.bytes(ID_BYTES_LEN));
54
+ newSessionId = buffer_utils_1.base64urlSafe.pack(await (0, random_node_1.bytes)(ID_BYTES_LEN));
55
55
  } while (this.sessions.has(strChunk(newSessionId)));
56
56
  const params = this.makeDefaultSessionParams(newSessionId);
57
57
  const session = this.makeSession(newSessionId, params);
@@ -87,7 +87,7 @@ class InMemorySessions extends sessions_1.BaseSessionFactory {
87
87
  static factory(timeout, makeDefaultSessionParams) {
88
88
  const factory = new InMemorySessions(timeout, makeDefaultSessionParams);
89
89
  Object.seal(factory);
90
- return Object.freeze(sessions_1.wrapFactory(factory));
90
+ return Object.freeze((0, sessions_1.wrapFactory)(factory));
91
91
  }
92
92
  }
93
93
  exports.InMemorySessions = InMemorySessions;
@@ -96,7 +96,7 @@ Object.freeze(InMemorySessions);
96
96
  function sameIdBytes(idStr, idBytes) {
97
97
  try {
98
98
  const bytes = buffer_utils_1.base64urlSafe.open(idStr);
99
- return ecma_nacl_1.compareVectors(bytes, idBytes);
99
+ return (0, ecma_nacl_1.compareVectors)(bytes, idBytes);
100
100
  }
101
101
  catch (err) {
102
102
  return false;
@@ -22,16 +22,16 @@ const canonical_address_1 = require("../../lib-common/canonical-address");
22
22
  const path_1 = require("path");
23
23
  const fs_1 = require("fs");
24
24
  function addressToFName(address) {
25
- return canonicalAddressToFName(canonical_address_1.toCanonicalAddress(address));
25
+ return canonicalAddressToFName((0, canonical_address_1.toCanonicalAddress)(address));
26
26
  }
27
27
  exports.addressToFName = addressToFName;
28
28
  function canonicalAddressToFName(canonicalAddress) {
29
29
  return buffer_utils_1.base64urlSafe.pack(buffer_utils_1.utf8.pack(canonicalAddress));
30
30
  }
31
31
  function treeInRootFolder(rootFolder) {
32
- const defaults = path_1.join(rootFolder, 'defaults');
32
+ const defaults = (0, path_1.join)(rootFolder, 'defaults');
33
33
  return {
34
- users: { path: path_1.join(rootFolder, 'users') },
34
+ users: { path: (0, path_1.join)(rootFolder, 'users') },
35
35
  defaults: {
36
36
  path: defaults,
37
37
  },
@@ -40,51 +40,51 @@ function treeInRootFolder(rootFolder) {
40
40
  }
41
41
  exports.treeInRootFolder = treeInRootFolder;
42
42
  function tokensInRootFolder(rootFolder) {
43
- return path_1.join(rootFolder, 'tokens');
43
+ return (0, path_1.join)(rootFolder, 'tokens');
44
44
  }
45
45
  exports.tokensInRootFolder = tokensInRootFolder;
46
46
  function userDataInRootFolder(root, userId) {
47
- return path_1.join(root, 'users', addressToFName(userId));
47
+ return (0, path_1.join)(root, 'users', addressToFName(userId));
48
48
  }
49
49
  exports.userDataInRootFolder = userDataInRootFolder;
50
50
  function treeInDefaultsFolder(defaults) {
51
- const mail = path_1.join(defaults, 'mail');
52
- const mailParams = path_1.join(mail, 'params');
53
- const store = path_1.join(defaults, 'store');
51
+ const mail = (0, path_1.join)(defaults, 'mail');
52
+ const mailParams = (0, path_1.join)(mail, 'params');
53
+ const store = (0, path_1.join)(defaults, 'store');
54
54
  return {
55
- info: { path: path_1.join(defaults, 'info') },
55
+ info: { path: (0, path_1.join)(defaults, 'info') },
56
56
  mail: {
57
57
  path: mail,
58
58
  params: {
59
59
  path: mailParams,
60
- anonymous: { path: path_1.join(mailParams, 'anonymous') },
61
- authenticated: { path: path_1.join(mailParams, 'authenticated') }
60
+ anonymous: { path: (0, path_1.join)(mailParams, 'anonymous') },
61
+ authenticated: { path: (0, path_1.join)(mailParams, 'authenticated') }
62
62
  }
63
63
  },
64
64
  store: {
65
65
  path: store,
66
- params: { path: path_1.join(store, 'params') }
66
+ params: { path: (0, path_1.join)(store, 'params') }
67
67
  }
68
68
  };
69
69
  }
70
70
  exports.treeInDefaultsFolder = treeInDefaultsFolder;
71
71
  function treeInUserFolder(userFoder) {
72
- const mail = path_1.join(userFoder, 'mail');
73
- const store = path_1.join(userFoder, 'store');
72
+ const mail = (0, path_1.join)(userFoder, 'mail');
73
+ const store = (0, path_1.join)(userFoder, 'store');
74
74
  return {
75
- info: { path: path_1.join(userFoder, 'info') },
75
+ info: { path: (0, path_1.join)(userFoder, 'info') },
76
76
  mail: {
77
77
  path: mail,
78
- delivery: { path: path_1.join(mail, 'delivery') },
79
- messages: { path: path_1.join(mail, 'messages') },
80
- params: { path: path_1.join(mail, 'params') }
78
+ delivery: { path: (0, path_1.join)(mail, 'delivery') },
79
+ messages: { path: (0, path_1.join)(mail, 'messages') },
80
+ params: { path: (0, path_1.join)(mail, 'params') }
81
81
  },
82
82
  store: {
83
83
  path: store,
84
- params: { path: path_1.join(store, 'params') },
85
- root: { path: path_1.join(store, 'root') },
86
- objects: { path: path_1.join(store, 'objects') },
87
- transactions: { path: path_1.join(store, 'transactions') }
84
+ params: { path: (0, path_1.join)(store, 'params') },
85
+ root: { path: (0, path_1.join)(store, 'root') },
86
+ objects: { path: (0, path_1.join)(store, 'objects') },
87
+ transactions: { path: (0, path_1.join)(store, 'transactions') }
88
88
  }
89
89
  };
90
90
  }
@@ -103,7 +103,7 @@ exports.createFolderTree = createFolderTree;
103
103
  function createFolderTreeSync(structure) {
104
104
  for (const [key, def] of Object.entries(structure)) {
105
105
  if (key === 'path') {
106
- fs_1.mkdirSync(def, { recursive: true });
106
+ (0, fs_1.mkdirSync)(def, { recursive: true });
107
107
  }
108
108
  else {
109
109
  createFolderTreeSync(def);
@@ -171,11 +171,11 @@ Object.freeze(BaseSessionFactory.prototype);
171
171
  Object.freeze(BaseSessionFactory);
172
172
  function wrapFactory(impl) {
173
173
  const wrap = {
174
- checkSession: binding_1.bind(impl, impl.checkSession),
175
- ensureAuthorizedSession: binding_1.bind(impl, impl.ensureAuthorizedSession),
176
- ensureOpenedSession: binding_1.bind(impl, impl.ensureOpenedSession),
177
- ensureAuthorizedSessionForSocketStart: binding_1.bind(impl, impl.ensureAuthorizedSessionForSocketStart),
178
- generate: binding_1.bind(impl, impl.generate)
174
+ checkSession: (0, binding_1.bind)(impl, impl.checkSession),
175
+ ensureAuthorizedSession: (0, binding_1.bind)(impl, impl.ensureAuthorizedSession),
176
+ ensureOpenedSession: (0, binding_1.bind)(impl, impl.ensureOpenedSession),
177
+ ensureAuthorizedSessionForSocketStart: (0, binding_1.bind)(impl, impl.ensureAuthorizedSessionForSocketStart),
178
+ generate: (0, binding_1.bind)(impl, impl.generate)
179
179
  };
180
180
  return wrap;
181
181
  }
@@ -35,7 +35,7 @@ async function readJsonFile(path) {
35
35
  return JSON.parse(buf.toString('utf8'));
36
36
  }
37
37
  function addressToFName(address) {
38
- return buffer_utils_1.base64urlSafe.pack(buffer_utils_1.utf8.pack(canonical_address_1.toCanonicalAddress(address)));
38
+ return buffer_utils_1.base64urlSafe.pack(buffer_utils_1.utf8.pack((0, canonical_address_1.toCanonicalAddress)(address)));
39
39
  }
40
40
  exports.addressToFName = addressToFName;
41
41
  class UserFiles {
@@ -43,10 +43,10 @@ class UserFiles {
43
43
  this.userId = userId;
44
44
  this.path = path;
45
45
  this.fileWritingBufferSize = (writeBufferSize ?
46
- conf_util_1.stringToNumOfBytes(writeBufferSize) :
46
+ (0, conf_util_1.stringToNumOfBytes)(writeBufferSize) :
47
47
  DEFAULT_FILE_WRITE_BUFFER_SIZE);
48
48
  this.fileReadingBufferSize = (readBufferSize ?
49
- conf_util_1.stringToNumOfBytes(readBufferSize) :
49
+ (0, conf_util_1.stringToNumOfBytes)(readBufferSize) :
50
50
  DEFAULT_FILE_READ_BUFFER_SIZE);
51
51
  }
52
52
  async ensureUserExistsOnDisk() {
@@ -64,23 +64,23 @@ class UserFiles {
64
64
  }
65
65
  }
66
66
  commonInfoFolder() {
67
- return path_1.join(this.path, '..', 'info');
67
+ return (0, path_1.join)(this.path, '..', 'info');
68
68
  }
69
69
  getSpaceQuota() {
70
- return readJsonFile(path_1.join(this.commonInfoFolder(), 'quota'));
70
+ return readJsonFile((0, path_1.join)(this.commonInfoFolder(), 'quota'));
71
71
  }
72
72
  getParam(paramFileName) {
73
- return readJsonFile(path_1.join(this.path, 'params', paramFileName));
73
+ return readJsonFile((0, path_1.join)(this.path, 'params', paramFileName));
74
74
  }
75
75
  setParam(paramFileName, param) {
76
- return fs.writeFile(path_1.join(this.path, 'params', paramFileName), JSON.stringify(param), { encoding: 'utf8', flag: 'w' });
76
+ return fs.writeFile((0, path_1.join)(this.path, 'params', paramFileName), JSON.stringify(param), { encoding: 'utf8', flag: 'w' });
77
77
  }
78
78
  }
79
79
  exports.UserFiles = UserFiles;
80
80
  Object.freeze(UserFiles.prototype);
81
81
  Object.freeze(UserFiles);
82
82
  async function pipeBytes(src, sink) {
83
- const deferred = processes_1.defer();
83
+ const deferred = (0, processes_1.defer)();
84
84
  src.pipe(sink, { end: false });
85
85
  src.on('error', (err) => {
86
86
  deferred.reject(err);
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.completePKLogin = void 0;
19
20
  const ecma_nacl_1 = require("ecma-nacl");
@@ -33,11 +34,11 @@ function completePKLogin() {
33
34
  const c = new Uint8Array(req.body);
34
35
  const decryptedKey = session.params.encryptor.open(c);
35
36
  const key = session.params.sessionKey;
36
- if (!ecma_nacl_1.compareVectors(decryptedKey, key)) {
37
+ if (!(0, ecma_nacl_1.compareVectors)(decryptedKey, key)) {
37
38
  throw new Error();
38
39
  }
39
40
  session.isAuthorized = true;
40
- res.status(pub_key_login_1.complete.SC.ok).send(buffer_utils_1.toBuffer(session.params.serverVerificationBytes));
41
+ res.status(pub_key_login_1.complete.SC.ok).send((0, buffer_utils_1.toBuffer)(session.params.serverVerificationBytes));
41
42
  }
42
43
  catch (err) {
43
44
  session.close();
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.startPKLogin = void 0;
19
20
  const ecma_nacl_1 = require("ecma-nacl");
@@ -27,7 +28,7 @@ const NONCE_LENGTH = ecma_nacl_1.secret_box.NONCE_LENGTH;
27
28
  const KEY_LENGTH = ecma_nacl_1.secret_box.KEY_LENGTH;
28
29
  const POLY_LENGTH = ecma_nacl_1.secret_box.POLY_LENGTH;
29
30
  function addEncryptorToSession(session, sessionKey, nonce) {
30
- const encryptor = session_encryptor_1.makeSessionEncryptor(sessionKey, nonce);
31
+ const encryptor = (0, session_encryptor_1.makeSessionEncryptor)(sessionKey, nonce);
31
32
  session.params.encryptor = encryptor;
32
33
  session.addCleanUp(() => {
33
34
  encryptor.destroy();
@@ -46,8 +47,8 @@ function startPKLogin(findUserParamsAndKeyFunc, sessionGenFunc, computeDHSharedK
46
47
  if ('function' !== typeof computeDHSharedKeyFunc) {
47
48
  throw new TypeError("Given argument 'computeDHSharedKeyFunc' must be function, but is not.");
48
49
  }
49
- return async function (req, res, next) {
50
- const userId = canonical_address_1.checkAndTransformAddress(req.body.userId);
50
+ return async (req, res, next) => {
51
+ const userId = (0, canonical_address_1.checkAndTransformAddress)(req.body.userId);
51
52
  const kid = req.body.kid;
52
53
  let session = req.session;
53
54
  // missing userId makes a bad request
@@ -85,8 +86,8 @@ function startPKLogin(findUserParamsAndKeyFunc, sessionGenFunc, computeDHSharedK
85
86
  session.params.userId = userId;
86
87
  }
87
88
  // get random bytes for session key and nonce
88
- const nonce = await random_node_1.bytes(NONCE_LENGTH);
89
- const sessionKey = await random_node_1.bytes(KEY_LENGTH);
89
+ const nonce = await (0, random_node_1.bytes)(NONCE_LENGTH);
90
+ const sessionKey = await (0, random_node_1.bytes)(KEY_LENGTH);
90
91
  // compute DH-shared key for encrypting a challenge
91
92
  const compRes = computeDHSharedKeyFunc(userParamsAndKey.pkey);
92
93
  const dhsharedKey = compRes.dhsharedKey;
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.midLogin = void 0;
19
20
  const jwkeys_1 = require("../../../lib-common/jwkeys");
@@ -28,16 +29,16 @@ function midLogin(relyingPartyDomain, midAuthorizingFunc) {
28
29
  if ('function' !== typeof midAuthorizingFunc) {
29
30
  throw new TypeError("Given argument 'midAuthorizingFunc' must be function, but is not.");
30
31
  }
31
- return async function (req, res, next) {
32
+ return async (req, res, next) => {
32
33
  if (req.session.isAuthorized) {
33
34
  res.status(login_1.ERR_SC.duplicate).send("This protocol request has already been served.");
34
35
  return;
35
36
  }
36
37
  const rb = req.body;
37
38
  const sessionId = req.session.id;
38
- if (!jwkeys_1.isLikeSignedMailerIdAssertion(rb.assertion) ||
39
- !jwkeys_1.isLikeSignedKeyCert(rb.userCert) ||
40
- !jwkeys_1.isLikeSignedKeyCert(rb.provCert)) {
39
+ if (!(0, jwkeys_1.isLikeSignedMailerIdAssertion)(rb.assertion) ||
40
+ !(0, jwkeys_1.isLikeSignedKeyCert)(rb.userCert) ||
41
+ !(0, jwkeys_1.isLikeSignedKeyCert)(rb.provCert)) {
41
42
  res.sendStatus(login_1.ERR_SC.malformed);
42
43
  req.session.close();
43
44
  return;
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.startSession = void 0;
19
20
  const login_1 = require("../../../lib-common/service-api/mailer-id/login");
@@ -53,9 +54,9 @@ function startSession(userExistsFunc, sessionGenFunc, redirectFunc) {
53
54
  });
54
55
  }
55
56
  }
56
- return async 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;