spec-3nweb-server 1.3.8 → 1.5.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 +28 -28
  3. package/build/3nstorage/resources/store.d.ts +2 -9
  4. package/build/3nstorage/resources/store.js +76 -73
  5. package/build/3nstorage/resources/users.d.ts +4 -2
  6. package/build/3nstorage/resources/users.js +8 -4
  7. package/build/3nstorage/routes/owner/archive-obj-version.d.ts +2 -2
  8. package/build/3nstorage/routes/owner/archive-obj-version.js +36 -31
  9. package/build/3nstorage/routes/owner/cancel-trans.js +1 -1
  10. package/build/3nstorage/routes/owner/delete-obj.d.ts +3 -2
  11. package/build/3nstorage/routes/owner/delete-obj.js +42 -7
  12. package/build/3nstorage/routes/owner/get-archived-obj-ver.js +10 -6
  13. package/build/3nstorage/routes/owner/get-current-obj.js +2 -2
  14. package/build/3nstorage/routes/owner/list-obj-archive.js +28 -31
  15. package/build/3nstorage/routes/owner/param-getter.js +3 -2
  16. package/build/3nstorage/routes/owner/param-setter.js +3 -2
  17. package/build/3nstorage/routes/owner/put-current-obj.js +12 -10
  18. package/build/3nstorage/routes/owner/session-params.js +4 -3
  19. package/build/admin/admin-app.js +5 -5
  20. package/build/admin/resources/users.js +42 -42
  21. package/build/admin/routes/add.js +3 -3
  22. package/build/admin/signup-tokens.js +8 -8
  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/async-fs-node.d.ts +2 -0
  49. package/build/lib-common/async-fs-node.js +13 -13
  50. package/build/lib-common/byte-streaming/common.js +9 -9
  51. package/build/lib-common/canonical-address.js +1 -1
  52. package/build/lib-common/ipc/generic-ipc.js +12 -12
  53. package/build/lib-common/ipc/ws-ipc.js +2 -2
  54. package/build/lib-common/mid-sigs-NaCl-Ed.js +14 -14
  55. package/build/lib-common/objs-on-disk/file-layout.js +10 -10
  56. package/build/lib-common/objs-on-disk/obj-file.js +11 -11
  57. package/build/lib-common/objs-on-disk/utils.d.ts +1 -0
  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 +24 -18
  62. package/build/lib-common/service-api/3nstorage/owner.js +31 -26
  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.d.ts +1 -0
  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 +13 -10
@@ -24,15 +24,15 @@ function addUser(addUserFunc) {
24
24
  return async function (req, res, next) {
25
25
  const { mailerId, storage, userId, signupToken } = req.body;
26
26
  if (('string' !== typeof userId)
27
- || !canonical_address_1.checkAndTransformAddress(userId)) {
27
+ || !(0, canonical_address_1.checkAndTransformAddress)(userId)) {
28
28
  res.status(signup_1.ERR_SC.malformed).send('Given user id is malformed.');
29
29
  return;
30
30
  }
31
- if (!users_1.validateUserMidParams(mailerId)) {
31
+ if (!(0, users_1.validateUserMidParams)(mailerId)) {
32
32
  res.status(signup_1.ERR_SC.malformed).send('MailerId parameters are malformed.');
33
33
  return;
34
34
  }
35
- if (!users_1.validateUserStorageParams(storage)) {
35
+ if (!(0, users_1.validateUserStorageParams)(storage)) {
36
36
  res.status(signup_1.ERR_SC.malformed).send('Storage parameters are malformed.');
37
37
  return;
38
38
  }
@@ -31,7 +31,7 @@ function canCreateUser(userId, ctx) {
31
31
  return false;
32
32
  }
33
33
  }
34
- const cAddr = canonical_address_1.toCanonicalAddress(userId);
34
+ const cAddr = (0, canonical_address_1.toCanonicalAddress)(userId);
35
35
  if (ctx.type === 'single-user') {
36
36
  return (cAddr === ctx.userId);
37
37
  }
@@ -52,7 +52,7 @@ function addressesForName(name, ctx) {
52
52
  }
53
53
  if (ctx.type === 'single-user') {
54
54
  const userId = `${name}${ctx.userId.substring(ctx.userId.indexOf('@'))}`;
55
- return ((canonical_address_1.toCanonicalAddress(userId) === ctx.userId) ?
55
+ return (((0, canonical_address_1.toCanonicalAddress)(userId) === ctx.userId) ?
56
56
  [userId] : []);
57
57
  }
58
58
  else if (ctx.type === 'multi-domain') {
@@ -67,7 +67,7 @@ function makeSingleUserSignupCtx(token, userId, validitySecs) {
67
67
  const ctx = {
68
68
  token,
69
69
  type: 'single-user',
70
- userId: canonical_address_1.toCanonicalAddress(userId)
70
+ userId: (0, canonical_address_1.toCanonicalAddress)(userId)
71
71
  };
72
72
  if (validitySecs) {
73
73
  ctx.validTill = Math.floor(Date.now() / 1000) + validitySecs;
@@ -76,11 +76,11 @@ function makeSingleUserSignupCtx(token, userId, validitySecs) {
76
76
  }
77
77
  exports.makeSingleUserSignupCtx = makeSingleUserSignupCtx;
78
78
  function makeMultiDomainSignupCtx(signupDomains, token, validitySecs) {
79
- assert_1.assert(Array.isArray(signupDomains));
79
+ (0, assert_1.assert)(Array.isArray(signupDomains));
80
80
  const ctx = {
81
81
  token,
82
82
  type: 'multi-domain',
83
- domains: signupDomains.map(d => canonical_address_1.toCanonicalAddress(d).substring(1))
83
+ domains: signupDomains.map(d => (0, canonical_address_1.toCanonicalAddress)(d).substring(1))
84
84
  };
85
85
  if (validitySecs) {
86
86
  ctx.validTill = Math.floor(Date.now() / 1000) + validitySecs;
@@ -91,7 +91,7 @@ exports.makeMultiDomainSignupCtx = makeMultiDomainSignupCtx;
91
91
  const TOKEN_BYTES_LEN = 30;
92
92
  const TOKEN_FILE_NAME_LEN = 10;
93
93
  async function generateToken() {
94
- const tokenBytes = await random_node_1.bytes(TOKEN_BYTES_LEN);
94
+ const tokenBytes = await (0, random_node_1.bytes)(TOKEN_BYTES_LEN);
95
95
  const token = buffer_utils_1.base64urlSafe.pack(tokenBytes);
96
96
  return token;
97
97
  }
@@ -111,13 +111,13 @@ function tokenFileName(token) {
111
111
  return token.substring(0, TOKEN_FILE_NAME_LEN);
112
112
  }
113
113
  function tokenPath(rootFolder, token) {
114
- return path_1.join(server_data_folders_1.tokensInRootFolder(rootFolder), tokenFileName(token));
114
+ return (0, path_1.join)((0, server_data_folders_1.tokensInRootFolder)(rootFolder), tokenFileName(token));
115
115
  }
116
116
  exports.tokenPath = tokenPath;
117
117
  function areTokensSame(t1, t2) {
118
118
  try {
119
119
  const t2Bytes = buffer_utils_1.base64urlSafe.open(t2);
120
- return ecma_nacl_1.compareVectors(t1, t2Bytes);
120
+ return (0, ecma_nacl_1.compareVectors)(t1, t2Bytes);
121
121
  }
122
122
  catch (err) {
123
123
  return false;
@@ -49,14 +49,14 @@ function setupStaticEntryRoute(app) {
49
49
  function makeApp(rootFolder, domain, midAuthorizer) {
50
50
  const app = new app_1.AppWithWSs();
51
51
  const mailDeliverySessions = delivery_sessions_1.DeliverySessions.make(5 * 60);
52
- const recipientsSessions = sessions_1.makeSessionFactory(10 * 60);
53
- const userSettingSessions = sessions_1.makeSessionFactory(10 * 60);
54
- const recipients = recipients_1.makeFactory(rootFolder);
52
+ const recipientsSessions = (0, sessions_1.makeSessionFactory)(10 * 60);
53
+ const userSettingSessions = (0, sessions_1.makeSessionFactory)(10 * 60);
54
+ const recipients = (0, recipients_1.makeFactory)(rootFolder);
55
55
  setupStaticEntryRoute(app.http);
56
- app.http.use(PATHS.delivery, delivery_1.makeApp(domain, mailDeliverySessions, recipients, midAuthorizer));
57
- app.use(PATHS.retrieval, retrieval_1.makeApp(domain, recipientsSessions, recipients, midAuthorizer));
58
- app.http.use(PATHS.config, config_1.makeApp(domain, userSettingSessions, recipients, midAuthorizer));
59
- app.http.use(error_handler_1.makeErrHandler((err, req) => {
56
+ app.http.use(PATHS.delivery, (0, delivery_1.makeApp)(domain, mailDeliverySessions, recipients, midAuthorizer));
57
+ app.use(PATHS.retrieval, (0, retrieval_1.makeApp)(domain, recipientsSessions, recipients, midAuthorizer));
58
+ app.http.use(PATHS.config, (0, config_1.makeApp)(domain, userSettingSessions, recipients, midAuthorizer));
59
+ app.http.use((0, error_handler_1.makeErrHandler)((err, req) => {
60
60
  if (typeof err.status !== 'number') {
61
61
  console.error(`\n --- Error occured in asmail, when handling ${req.method} request to ${req.originalUrl}`);
62
62
  console.error(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.makeApp = void 0;
19
20
  /**
@@ -33,17 +34,17 @@ const api = require("../lib-common/service-api/asmail/config");
33
34
  function makeApp(domain, sessions, recipients, midAuthorizer) {
34
35
  const app = express();
35
36
  app.disable('etag');
36
- app.post('/' + api.midLogin.START_URL_END, sessions.checkSession(), body_parsers_1.json('1kb'), start_1.startSession(recipients.exists, sessions.generate));
37
- app.post('/' + api.midLogin.AUTH_URL_END, sessions.ensureOpenedSession(), body_parsers_1.json('4kb'), mid_auth_1.midLogin(domain, midAuthorizer));
37
+ app.post('/' + api.midLogin.START_URL_END, sessions.checkSession(), (0, body_parsers_1.json)('1kb'), (0, start_1.startSession)(recipients.exists, sessions.generate));
38
+ app.post('/' + api.midLogin.AUTH_URL_END, sessions.ensureOpenedSession(), (0, body_parsers_1.json)('4kb'), (0, mid_auth_1.midLogin)(domain, midAuthorizer));
38
39
  // *** Require authorized session for everything below ***
39
40
  app.use(sessions.ensureAuthorizedSession());
40
- app.post('/' + api.closeSession.URL_END, body_parsers_1.emptyBody(), close_1.closeSession());
41
+ app.post('/' + api.closeSession.URL_END, (0, body_parsers_1.emptyBody)(), (0, close_1.closeSession)());
41
42
  app.route('/' + api.p.initPubKey.URL_END)
42
- .get(param_getter_1.getParam(recipients.getPubKey))
43
- .put(body_parsers_1.json('4kb', true), param_setter_1.setParam(recipients.setPubKey));
43
+ .get((0, param_getter_1.getParam)(recipients.getPubKey))
44
+ .put((0, body_parsers_1.json)('4kb', true), (0, param_setter_1.setParam)(recipients.setPubKey));
44
45
  app.route('/' + api.p.anonSenderInvites.URL_END)
45
- .get(param_getter_1.getParam(recipients.getAnonSenderInvites))
46
- .put(body_parsers_1.json('4kb', true), param_setter_1.setParam(recipients.setAnonSenderInvites));
46
+ .get((0, param_getter_1.getParam)(recipients.getAnonSenderInvites))
47
+ .put((0, body_parsers_1.json)('4kb', true), (0, param_setter_1.setParam)(recipients.setAnonSenderInvites));
47
48
  return app;
48
49
  }
49
50
  exports.makeApp = makeApp;
@@ -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.makeApp = void 0;
19
20
  /**
@@ -37,16 +38,16 @@ const MAX_CHUNK_SIZE = '0.5mb';
37
38
  function makeApp(domain, sessions, recipients, midAuthorizer) {
38
39
  const app = express();
39
40
  app.disable('etag');
40
- app.post('/' + api.sessionStart.URL_END, sessions.checkSession(), body_parsers_1.json('1kb'), start_session_1.startSession(recipients.allowedMaxMsgSize, sessions.generate));
41
- app.post('/' + api.preFlight.URL_END, sessions.checkSession(), body_parsers_1.json('1kb'), pre_flight_1.preFlight(recipients.allowedMaxMsgSize));
42
- app.post('/' + api.sessionRestart.URL_END, sessions.checkSession(), body_parsers_1.json('1kb'), restart_session_1.restartSession(sessions.generate, sessions.getSessionForMsg, recipients.incompleteMsgDeliveryParams, MAX_CHUNK_SIZE));
43
- app.post('/' + api.authSender.URL_END, sessions.ensureOpenedSession(), body_parsers_1.json('4kb'), sender_authorization_1.authorize(domain, midAuthorizer));
41
+ app.post('/' + api.sessionStart.URL_END, sessions.checkSession(), (0, body_parsers_1.json)('1kb'), (0, start_session_1.startSession)(recipients.allowedMaxMsgSize, sessions.generate));
42
+ app.post('/' + api.preFlight.URL_END, sessions.checkSession(), (0, body_parsers_1.json)('1kb'), (0, pre_flight_1.preFlight)(recipients.allowedMaxMsgSize));
43
+ app.post('/' + api.sessionRestart.URL_END, sessions.checkSession(), (0, body_parsers_1.json)('1kb'), (0, restart_session_1.restartSession)(sessions.generate, sessions.getSessionForMsg, recipients.incompleteMsgDeliveryParams, MAX_CHUNK_SIZE));
44
+ app.post('/' + api.authSender.URL_END, sessions.ensureOpenedSession(), (0, body_parsers_1.json)('4kb'), (0, sender_authorization_1.authorize)(domain, midAuthorizer));
44
45
  // *** Require authorized session for everything below ***
45
46
  app.use(sessions.ensureAuthorizedSession());
46
- app.get('/' + api.initPubKey.URL_END, provide_recipient_pubkey_1.getRecipientPubKey(recipients.getPubKey));
47
- app.put('/' + api.msgMeta.URL_END, body_parsers_1.json('16kb'), put_metadata_1.saveMetadata(recipients.setMsgStorage, MAX_CHUNK_SIZE));
48
- app.put('/' + api.msgObj.EXPRESS_URL_END, put_obj_1.saveMsgObj(recipients.saveObj, MAX_CHUNK_SIZE));
49
- app.post('/' + api.completion.URL_END, body_parsers_1.emptyBody(), finalize_delivery_1.finalizeDelivery(recipients.finalizeDelivery));
47
+ app.get('/' + api.initPubKey.URL_END, (0, provide_recipient_pubkey_1.getRecipientPubKey)(recipients.getPubKey));
48
+ app.put('/' + api.msgMeta.URL_END, (0, body_parsers_1.json)('16kb'), (0, put_metadata_1.saveMetadata)(recipients.setMsgStorage, MAX_CHUNK_SIZE));
49
+ app.put('/' + api.msgObj.EXPRESS_URL_END, (0, put_obj_1.saveMsgObj)(recipients.saveObj, MAX_CHUNK_SIZE));
50
+ app.post('/' + api.completion.URL_END, (0, body_parsers_1.emptyBody)(), (0, finalize_delivery_1.finalizeDelivery)(recipients.finalizeDelivery));
50
51
  return app;
51
52
  }
52
53
  exports.makeApp = makeApp;
@@ -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.DeliverySessions = void 0;
19
20
  /**
@@ -82,8 +83,8 @@ class DeliverySessions extends mem_backed_sessions_factory_1.InMemorySessions {
82
83
  */
83
84
  static make(timeout) {
84
85
  const factory = new DeliverySessions(timeout);
85
- const wrap = sessions_1.wrapFactory(factory);
86
- wrap.getSessionForMsg = binding_1.bind(factory, factory.getSessionForMsg);
86
+ const wrap = (0, sessions_1.wrapFactory)(factory);
87
+ wrap.getSessionForMsg = (0, binding_1.bind)(factory, factory.getSessionForMsg);
87
88
  return Object.freeze(wrap);
88
89
  }
89
90
  }
@@ -53,7 +53,7 @@ export declare class Inbox extends UserFiles {
53
53
  * @param completeMsg flag, true for complete messages, and false for
54
54
  * incomplete (in-delivery) messages.
55
55
  */
56
- getMsgMeta(msgId: string, completeMsg: any): Promise<MsgMeta>;
56
+ getMsgMeta(msgId: string, completeMsg: boolean): Promise<MsgMeta>;
57
57
  startSavingObj(msgId: string, objId: string, bytes: Readable, bytesLen: number, opts: deliveryApi.PutObjFirstQueryOpts): Promise<void>;
58
58
  continueSavingObj(msgId: string, objId: string, bytes: Readable, bytesLen: number, opts: deliveryApi.PutObjSecondQueryOpts): Promise<void>;
59
59
  /**
@@ -63,7 +63,7 @@ async function genMsgIdAndMakeFolder(delivPath, msgsFolder) {
63
63
  const msgId = await random.stringOfB64UrlSafeChars(MSG_ID_LEN);
64
64
  // make msg folder among deliveries
65
65
  try {
66
- await fs.mkdir(path_1.join(delivPath, msgId));
66
+ await fs.mkdir((0, path_1.join)(delivPath, msgId));
67
67
  }
68
68
  catch (exc) {
69
69
  if (exc.alreadyExists) {
@@ -75,8 +75,8 @@ async function genMsgIdAndMakeFolder(delivPath, msgsFolder) {
75
75
  }
76
76
  // ensure that msgId does not belong to any existing message
77
77
  try {
78
- await fs.stat(path_1.join(msgsFolder, msgId));
79
- await fs.rmdir(path_1.join(delivPath, msgId));
78
+ await fs.stat((0, path_1.join)(msgsFolder, msgId));
79
+ await fs.rmdir((0, path_1.join)(delivPath, msgId));
80
80
  return genMsgIdAndMakeFolder(delivPath, msgsFolder);
81
81
  }
82
82
  catch (exc) { }
@@ -85,13 +85,13 @@ async function genMsgIdAndMakeFolder(delivPath, msgsFolder) {
85
85
  class Inbox extends user_files_1.UserFiles {
86
86
  constructor(userId, path, mailEventsSink, writeBufferSize, readBufferSize) {
87
87
  super(userId, path, writeBufferSize, readBufferSize);
88
- this.metas = new MsgMetas(5 * 60 * 1000, path_1.join(this.path, 'delivery'), path_1.join(this.path, 'messages'));
88
+ this.metas = new MsgMetas(5 * 60 * 1000, (0, path_1.join)(this.path, 'delivery'), (0, path_1.join)(this.path, 'messages'));
89
89
  this.objFiles = new ObjFiles(5 * 60 * 1000, this.metas.deliveryFolder, this.metas.readyMsgsFolder);
90
90
  this.mailEventsSink = mailEventsSink;
91
91
  Object.freeze(this);
92
92
  }
93
93
  static async make(userFolder, userId, mailEventsSink, writeBufferSize, readBufferSize) {
94
- const path = path_1.join(userFolder, 'mail');
94
+ const path = (0, path_1.join)(userFolder, 'mail');
95
95
  const inbox = new Inbox(userId, path, mailEventsSink, writeBufferSize, readBufferSize);
96
96
  await inbox.ensureUserExistsOnDisk();
97
97
  return inbox;
@@ -153,8 +153,8 @@ class Inbox extends user_files_1.UserFiles {
153
153
  throw exports.SC.WRONG_OBJ_STATE;
154
154
  }
155
155
  const file = await this.objFiles.forNewFile(msgId, objId);
156
- const chunks = utils_1.chunksInOrderedStream(bytesLen, opts.header, 0);
157
- await utils_1.streamToObjFile(file, chunks, bytes, this.fileWritingBufferSize);
156
+ const chunks = (0, utils_1.chunksInOrderedStream)(bytesLen, opts.header, 0);
157
+ await (0, utils_1.streamToObjFile)(file, chunks, bytes, this.fileWritingBufferSize);
158
158
  // set obj status in meta
159
159
  meta.objs[objId] = {
160
160
  size: {
@@ -191,8 +191,8 @@ class Inbox extends user_files_1.UserFiles {
191
191
  }
192
192
  }
193
193
  const file = await this.objFiles.forExistingFile(msgId, objId, true);
194
- const chunks = utils_1.chunksInOrderedStream(bytesLen, undefined, opts.ofs);
195
- await utils_1.streamToObjFile(file, chunks, bytes, this.fileWritingBufferSize);
194
+ const chunks = (0, utils_1.chunksInOrderedStream)(bytesLen, undefined, opts.ofs);
195
+ await (0, utils_1.streamToObjFile)(file, chunks, bytes, this.fileWritingBufferSize);
196
196
  // update meta
197
197
  objStatus.size.segments += bytesLen;
198
198
  if (opts.last) {
@@ -221,8 +221,8 @@ class Inbox extends user_files_1.UserFiles {
221
221
  meta.deliveryCompletion = Date.now();
222
222
  await this.metas.set(msgId, meta);
223
223
  // move message folder to a place with completed messages
224
- const srcFolder = path_1.join(this.metas.deliveryFolder, msgId);
225
- const dstFolder = path_1.join(this.metas.readyMsgsFolder, msgId);
224
+ const srcFolder = (0, path_1.join)(this.metas.deliveryFolder, msgId);
225
+ const dstFolder = (0, path_1.join)(this.metas.readyMsgsFolder, msgId);
226
226
  await fs.rename(srcFolder, dstFolder);
227
227
  this.objFiles.changeToReadingPathsInMsg(msgId);
228
228
  // raise event about completion of receiving a message
@@ -267,7 +267,7 @@ class Inbox extends user_files_1.UserFiles {
267
267
  this.metas.uncache(msgId);
268
268
  this.objFiles.uncache(msgId);
269
269
  try {
270
- const msgPath = path_1.join(this.metas.readyMsgsFolder, msgId);
270
+ const msgPath = (0, path_1.join)(this.metas.readyMsgsFolder, msgId);
271
271
  const rmPath = `${msgPath}~remove`;
272
272
  await fs.rename(msgPath, rmPath);
273
273
  await fs.rmDirWithContent(rmPath);
@@ -315,14 +315,14 @@ class Inbox extends user_files_1.UserFiles {
315
315
  len: (segBytesToRead + headerLen),
316
316
  segsLen,
317
317
  headerLen,
318
- pipe: utils_1.makeNoBaseObjPipe(file, true, segsOfs, segBytesToRead)
318
+ pipe: (0, utils_1.makeNoBaseObjPipe)(file, true, segsOfs, segBytesToRead)
319
319
  };
320
320
  }
321
321
  else {
322
322
  reader = {
323
323
  len: segBytesToRead,
324
324
  segsLen,
325
- pipe: utils_1.makeNoBaseObjPipe(file, false, segsOfs, segBytesToRead)
325
+ pipe: (0, utils_1.makeNoBaseObjPipe)(file, false, segsOfs, segBytesToRead)
326
326
  };
327
327
  }
328
328
  Object.freeze(reader);
@@ -342,9 +342,9 @@ class Inbox extends user_files_1.UserFiles {
342
342
  }
343
343
  else {
344
344
  const isOK = (typeof initKeyCerts === 'object') && !!initKeyCerts &&
345
- jwkeys_1.isLikeSignedKeyCert(initKeyCerts.pkeyCert) &&
346
- jwkeys_1.isLikeSignedKeyCert(initKeyCerts.userCert) &&
347
- jwkeys_1.isLikeSignedKeyCert(initKeyCerts.provCert);
345
+ (0, jwkeys_1.isLikeSignedKeyCert)(initKeyCerts.pkeyCert) &&
346
+ (0, jwkeys_1.isLikeSignedKeyCert)(initKeyCerts.userCert) &&
347
+ (0, jwkeys_1.isLikeSignedKeyCert)(initKeyCerts.provCert);
348
348
  if (!isOK) {
349
349
  return false;
350
350
  }
@@ -565,10 +565,10 @@ class ObjFiles {
565
565
  return objFile;
566
566
  }
567
567
  objFileWritingPath(msgId, objId) {
568
- return path_1.join(this.deliveryFolder, msgId, objId);
568
+ return (0, path_1.join)(this.deliveryFolder, msgId, objId);
569
569
  }
570
570
  objFileReadingPath(msgId, objId) {
571
- return path_1.join(this.readyMsgsFolder, msgId, objId);
571
+ return (0, path_1.join)(this.readyMsgsFolder, msgId, objId);
572
572
  }
573
573
  changeToReadingPathsInMsg(msgId) {
574
574
  const msgObjs = this.cache.get(msgId);
@@ -608,7 +608,7 @@ class MsgMetas {
608
608
  return meta;
609
609
  }
610
610
  async fromFile(msgId, completeMsg) {
611
- const filePath = path_1.join((completeMsg ? this.readyMsgsFolder : this.deliveryFolder), msgId, META_FILE);
611
+ const filePath = (0, path_1.join)((completeMsg ? this.readyMsgsFolder : this.deliveryFolder), msgId, META_FILE);
612
612
  const str = await fs.readFile(filePath, { encoding: 'utf8', flag: 'r' })
613
613
  .catch((exc) => {
614
614
  if (exc.notFound) {
@@ -620,7 +620,7 @@ class MsgMetas {
620
620
  return JSON.parse(str);
621
621
  }
622
622
  catch (err) {
623
- throw error_1.errWithCause(err, `Can't parse content of message meta file`);
623
+ throw (0, error_1.errWithCause)(err, `Can't parse content of message meta file`);
624
624
  }
625
625
  }
626
626
  async set(msgId, meta) {
@@ -628,7 +628,7 @@ class MsgMetas {
628
628
  await this.saveToFile(msgId, meta);
629
629
  }
630
630
  async saveToFile(msgId, meta) {
631
- const filePath = path_1.join(this.deliveryFolder, msgId, META_FILE);
631
+ const filePath = (0, path_1.join)(this.deliveryFolder, msgId, META_FILE);
632
632
  await this.saveProcs.startOrChain(msgId, () => fs.writeFile(filePath, JSON.stringify(meta), { encoding: 'utf8', flag: 'w' }));
633
633
  }
634
634
  uncache(msgId) {
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { Readable } from 'stream';
3
- import { ObjReader, MailEventsSink } from './inbox';
3
+ import { Inbox, ObjReader, MailEventsSink } from './inbox';
4
4
  import * as deliveryApi from '../../lib-common/service-api/asmail/delivery';
5
5
  import * as configApi from '../../lib-common/service-api/asmail/config';
6
6
  import * as retrievalApi from '../../lib-common/service-api/asmail/retrieval';
@@ -92,4 +92,5 @@ export interface Factory {
92
92
  setAnonSenderInvites: SetAnonSenderInvites;
93
93
  setMailEventsSink(sink: EventsSink): void;
94
94
  }
95
+ export declare type StaticSetter<T> = (inbox: Inbox, param: T, setDefault: boolean) => Promise<boolean>;
95
96
  export declare function makeFactory(rootFolder: string, writeBufferSize?: string | number, readBufferSize?: string | number): Factory;
@@ -16,7 +16,7 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.makeFactory = exports.BIN_TYPE = void 0;
19
+ exports.makeFactory = exports.BIN_TYPE = exports.SC = void 0;
20
20
  const inbox_1 = require("./inbox");
21
21
  const server_data_folders_1 = require("../../lib-server/resources/server-data-folders");
22
22
  var inbox_2 = require("./inbox");
@@ -77,7 +77,7 @@ async function adaptToFreeSpaceLeft(inbox, msgSize) {
77
77
  }
78
78
  /**
79
79
  * @param inbox
80
- * @param invitation is a string invitation token, or null.
80
+ * @param invitation is a string invitation token, or undefined.
81
81
  * @returns a promise, resolvable to
82
82
  * (1) zero (0), if leaving mail is forbidden,
83
83
  * (2) greater than zero maximum message length, and
@@ -107,7 +107,7 @@ async function allowedMsgSizeForAnonSender(inbox, invitation) {
107
107
  /**
108
108
  * @param inbox
109
109
  * @param sender is sender string address
110
- * @param invitation is a string invitation token, or null.
110
+ * @param invitation is a string invitation token, or undefined.
111
111
  * @returns a promise, resolvable to
112
112
  * (1) zero (0), if leaving mail is forbidden,
113
113
  * (2) greater than zero maximum message length, and
@@ -163,7 +163,7 @@ function makeFactory(rootFolder, writeBufferSize, readBufferSize) {
163
163
  }
164
164
  }
165
165
  else {
166
- const userFolder = server_data_folders_1.userDataInRootFolder(rootFolder, userId);
166
+ const userFolder = (0, server_data_folders_1.userDataInRootFolder)(rootFolder, userId);
167
167
  inbox = await inbox_1.Inbox.make(userFolder, userId, mailEventsSink, writeBufferSize, readBufferSize);
168
168
  boxes.set(userId, inbox);
169
169
  return inbox;
@@ -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");
@@ -13,9 +13,14 @@
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.makeApp = void 0;
20
+ /**
21
+ * This module gives a function that creates a mountable, or app.use()-able,
22
+ * express ASMail application.
23
+ */
19
24
  // Internal libs
20
25
  const body_parsers_1 = require("../lib-server/middleware/body-parsers");
21
26
  const app_1 = require("../lib-server/web-sockets/app");
@@ -47,14 +52,14 @@ function setWSPart(app, sessions, recipients) {
47
52
  }
48
53
  function setHttpPart(app, domain, sessions, recipients, midAuthorizer) {
49
54
  app.http.disable('etag');
50
- app.http.post('/' + api.midLogin.START_URL_END, sessions.checkSession(), body_parsers_1.json('1kb'), start_1.startSession(recipients.exists, sessions.generate));
51
- app.http.post('/' + api.midLogin.AUTH_URL_END, sessions.ensureOpenedSession(), body_parsers_1.json('4kb'), mid_auth_1.midLogin(domain, midAuthorizer));
55
+ app.http.post('/' + api.midLogin.START_URL_END, sessions.checkSession(), (0, body_parsers_1.json)('1kb'), (0, start_1.startSession)(recipients.exists, sessions.generate));
56
+ app.http.post('/' + api.midLogin.AUTH_URL_END, sessions.ensureOpenedSession(), (0, body_parsers_1.json)('4kb'), (0, mid_auth_1.midLogin)(domain, midAuthorizer));
52
57
  // *** Require authorized session for everything below ***
53
58
  app.http.use(sessions.ensureAuthorizedSession());
54
- app.http.post('/' + api.closeSession.URL_END, body_parsers_1.emptyBody(), close_1.closeSession());
55
- app.http.get('/' + api.listMsgs.URL_END, list_messages_1.listMsgIds(recipients.getMsgIds));
56
- app.http.get('/' + api.msgMetadata.EXPRESS_URL_END, get_message_meta_1.getMsgMeta(recipients.getMsgMeta));
57
- app.http.delete('/' + api.rmMsg.EXPRESS_URL_END, remove_message_1.deleteMsg(recipients.deleteMsg));
58
- app.http.get('/' + api.msgObj.EXPRESS_URL_END, get_message_obj_1.getMsgObj(recipients.getObj));
59
+ app.http.post('/' + api.closeSession.URL_END, (0, body_parsers_1.emptyBody)(), (0, close_1.closeSession)());
60
+ app.http.get('/' + api.listMsgs.URL_END, (0, list_messages_1.listMsgIds)(recipients.getMsgIds));
61
+ app.http.get('/' + api.msgMetadata.EXPRESS_URL_END, (0, get_message_meta_1.getMsgMeta)(recipients.getMsgMeta));
62
+ app.http.delete('/' + api.rmMsg.EXPRESS_URL_END, (0, remove_message_1.deleteMsg)(recipients.deleteMsg));
63
+ app.http.get('/' + api.msgObj.EXPRESS_URL_END, (0, get_message_obj_1.getMsgObj)(recipients.getObj));
59
64
  }
60
65
  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.getParam = void 0;
19
20
  const recipients_1 = require("../../resources/recipients");
@@ -22,7 +23,7 @@ function getParam(paramGetter) {
22
23
  if ('function' !== typeof paramGetter) {
23
24
  throw new TypeError("Given argument 'paramGetter' must be function, but is not.");
24
25
  }
25
- return async function (req, res, next) {
26
+ return async (req, res, next) => {
26
27
  const session = req.session;
27
28
  const userId = session.params.userId;
28
29
  try {
@@ -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.setParam = void 0;
19
20
  const recipients_1 = require("../../resources/recipients");
@@ -22,7 +23,7 @@ function setParam(paramSetter) {
22
23
  if ('function' !== typeof paramSetter) {
23
24
  throw new TypeError("Given argument 'paramSetter' must be function, but is not.");
24
25
  }
25
- return async function (req, res, next) {
26
+ return async (req, res, next) => {
26
27
  const session = req.session;
27
28
  const userId = session.params.userId;
28
29
  const pValue = req.body;
@@ -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.finalizeDelivery = void 0;
19
20
  const recipients_1 = require("../../resources/recipients");
@@ -22,7 +23,7 @@ function finalizeDelivery(finDelivFunc) {
22
23
  if ('function' !== typeof finDelivFunc) {
23
24
  throw new TypeError("Given argument 'finDelivFunc' must be function, but is not.");
24
25
  }
25
- return async function (req, res, next) {
26
+ return async (req, res, next) => {
26
27
  const session = req.session;
27
28
  const recipient = session.params.recipient;
28
29
  const msgId = session.params.msgId;
@@ -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.preFlight = void 0;
19
20
  const recipients_1 = require("../../resources/recipients");
@@ -59,9 +60,9 @@ function preFlight(allowedMsgSizeFunc, redirectFunc) {
59
60
  throw new Error(`Unrecognized code ${msgSize} for message size limits.`);
60
61
  }
61
62
  }
62
- return async function (req, res, next) {
63
+ return async (req, res, next) => {
63
64
  const rb = req.body;
64
- const recipient = canonical_address_1.checkAndTransformAddress(rb.recipient);
65
+ const recipient = (0, canonical_address_1.checkAndTransformAddress)(rb.recipient);
65
66
  let sender = rb.sender;
66
67
  const invitation = rb.invitation;
67
68
  const session = req.session;
@@ -81,7 +82,7 @@ function preFlight(allowedMsgSizeFunc, redirectFunc) {
81
82
  }
82
83
  // if sender is given, we canonicalize the address
83
84
  if (sender) {
84
- sender = canonical_address_1.checkAndTransformAddress(sender);
85
+ sender = (0, canonical_address_1.checkAndTransformAddress)(sender);
85
86
  if (!sender) {
86
87
  res.status(delivery_1.ERR_SC.malformed).json({
87
88
  error: "Sender field is malformed"
@@ -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.getRecipientPubKey = void 0;
19
20
  const recipients_1 = require("../../resources/recipients");
@@ -27,7 +28,7 @@ function getRecipientPubKey(pkeyProvidingFunc) {
27
28
  if ('function' !== typeof pkeyProvidingFunc) {
28
29
  throw new TypeError("Given argument 'pkeyProvidingFunc' must be function, but is not.");
29
30
  }
30
- return async function (req, res, next) {
31
+ return async (req, res, next) => {
31
32
  const session = req.session;
32
33
  try {
33
34
  const certs = await pkeyProvidingFunc(session.params.recipient);
@@ -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.saveMetadata = void 0;
19
20
  const recipients_1 = require("../../resources/recipients");
@@ -48,7 +49,7 @@ function saveMetadata(setMsgStorageFunc, maxChunk) {
48
49
  "be function, but is not.");
49
50
  }
50
51
  const maxChunkSize = confUtil.stringToNumOfBytes(maxChunk);
51
- return async function (req, res, next) {
52
+ return async (req, res, next) => {
52
53
  const session = req.session;
53
54
  const msgMeta = req.body;
54
55
  const recipient = session.params.recipient;
@@ -26,9 +26,9 @@ function saveMsgObj(saveObjFunc, chunkLimit) {
26
26
  throw new TypeError("Given argument 'saveObjFunc' must be function, but is not.");
27
27
  }
28
28
  const maxChunkSize = confUtil.stringToNumOfBytes(chunkLimit);
29
- return async function (req, res, next) {
29
+ return async (req, res, next) => {
30
30
  if (!req.is(recipients_1.BIN_TYPE)) {
31
- body_parsers_1.attachByteDrainToRequest(req);
31
+ (0, body_parsers_1.attachByteDrainToRequest)(req);
32
32
  res.status(delivery_1.ERR_SC.wrongContentType).send(`Content-Type must be ${recipients_1.BIN_TYPE} for this call.`);
33
33
  return;
34
34
  }
@@ -43,7 +43,7 @@ function saveMsgObj(saveObjFunc, chunkLimit) {
43
43
  // get and check Content-Length, implicitly sending replies for bad length
44
44
  let len = getContentLenOrSendError(req, res, maxChunkSize);
45
45
  if (len === undefined) {
46
- body_parsers_1.attachByteDrainToRequest(req);
46
+ (0, body_parsers_1.attachByteDrainToRequest)(req);
47
47
  return;
48
48
  }
49
49
  // extract and check query parameters
@@ -149,7 +149,7 @@ function getContentLenOrSendError(req, res, maxChunkSize) {
149
149
  return;
150
150
  }
151
151
  function replyToMalformed(req, msg, res) {
152
- body_parsers_1.attachByteDrainToRequest(req);
152
+ (0, body_parsers_1.attachByteDrainToRequest)(req);
153
153
  res.status(delivery_1.ERR_SC.malformed).send(msg);
154
154
  }
155
155
  Object.freeze(exports);