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
@@ -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);
@@ -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.restartSession = void 0;
19
20
  const recipients_1 = require("../../resources/recipients");
@@ -64,9 +65,9 @@ function restartSession(sessionGenFunc, sessionForMsgFunc, incompleteMsgFunc, ma
64
65
  maxChunkSize
65
66
  });
66
67
  }
67
- return async function (req, res, next) {
68
+ return async (req, res, next) => {
68
69
  const rb = req.body;
69
- const recipient = canonical_address_1.checkAndTransformAddress(rb.recipient);
70
+ const recipient = (0, canonical_address_1.checkAndTransformAddress)(rb.recipient);
70
71
  const msgId = rb.msgId;
71
72
  const session = req.session;
72
73
  // session is opened, and is even mentioned in a header
@@ -1,8 +1,6 @@
1
1
  import { RequestHandler } from 'express';
2
2
  import { SignedLoad } from '../../../lib-common/jwkeys';
3
- export interface IMidAuthorizer {
4
- (rpDomain: string, sessionId: string, userId: string, mailerIdAssertion: SignedLoad, userCert: SignedLoad, provCert: SignedLoad): Promise<boolean>;
5
- }
3
+ export declare type IMidAuthorizer = (rpDomain: string, sessionId: string, userId: string, mailerIdAssertion: SignedLoad, userCert: SignedLoad, provCert: SignedLoad) => Promise<boolean>;
6
4
  /**
7
5
  * This creates an authorize-sender route handler.
8
6
  * @param relyingPartyDomain at which this service operates, as seen by client
@@ -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.authorize = void 0;
19
20
  const delivery_1 = require("../../../lib-common/service-api/asmail/delivery");
@@ -28,7 +29,7 @@ function authorize(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(delivery_1.ERR_SC.duplicateReq).send("This protocol request has already been served.");
34
35
  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 recipients_1 = require("../../resources/recipients");
@@ -75,9 +76,9 @@ function startSession(allowedMsgSizeFunc, sessionGenFunc, redirectFunc) {
75
76
  throw new Error(`Unrecognized code ${msgSize} for message size limits.`);
76
77
  }
77
78
  }
78
- return async function (req, res, next) {
79
+ return async (req, res, next) => {
79
80
  const rb = req.body;
80
- const recipient = canonical_address_1.checkAndTransformAddress(rb.recipient);
81
+ const recipient = (0, canonical_address_1.checkAndTransformAddress)(rb.recipient);
81
82
  let sender = rb.sender;
82
83
  const invitation = rb.invitation;
83
84
  const session = req.session;
@@ -97,7 +98,7 @@ function startSession(allowedMsgSizeFunc, sessionGenFunc, redirectFunc) {
97
98
  }
98
99
  // if sender is given, we canonicalize the address
99
100
  if (sender) {
100
- sender = canonical_address_1.checkAndTransformAddress(sender);
101
+ sender = (0, canonical_address_1.checkAndTransformAddress)(sender);
101
102
  if (!sender) {
102
103
  res.status(delivery_1.ERR_SC.malformed).json({
103
104
  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.getMsgMeta = void 0;
19
20
  const recipients_1 = require("../../resources/recipients");
@@ -22,7 +23,7 @@ function getMsgMeta(getMsgMetaFunc) {
22
23
  if ('function' !== typeof getMsgMetaFunc) {
23
24
  throw new TypeError("Given argument 'getMsgMetaFunc' must be function, but is not.");
24
25
  }
25
- return async function (req, res, next) {
26
+ return async (req, res, next) => {
26
27
  const userId = req.session.params.userId;
27
28
  const msgId = req.params.msgId;
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.getMsgObj = void 0;
19
20
  const recipients_1 = require("../../resources/recipients");
@@ -44,7 +45,7 @@ function getMsgObj(getMsgObjFunc) {
44
45
  if ('function' !== typeof getMsgObjFunc) {
45
46
  throw new TypeError("Given argument 'getMsgObjFunc' must be function, but is not.");
46
47
  }
47
- return async function (req, res, next) {
48
+ return async (req, res, next) => {
48
49
  const userId = req.session.params.userId;
49
50
  const msgId = req.params.msgId;
50
51
  const objId = req.params.objId;
@@ -67,7 +68,7 @@ function getMsgObj(getMsgObjFunc) {
67
68
  await reader.pipe(res);
68
69
  }
69
70
  catch (err) {
70
- console.error(error_1.errWithCause(err, `Wasn't able to complete sending segments due to error in piping`));
71
+ console.error((0, error_1.errWithCause)(err, `Wasn't able to complete sending segments due to error in piping`));
71
72
  }
72
73
  finally {
73
74
  res.end();
@@ -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.listMsgIds = void 0;
19
20
  const recipients_1 = require("../../resources/recipients");
@@ -22,7 +23,7 @@ function listMsgIds(listMsgIdsFunc) {
22
23
  if ('function' !== typeof listMsgIdsFunc) {
23
24
  throw new TypeError("Given argument 'listMsgIdsFunc' must be function, but is not.");
24
25
  }
25
- return async function (req, res, next) {
26
+ return async (req, res, next) => {
26
27
  const userId = req.session.params.userId;
27
28
  try {
28
29
  const msgIds = await listMsgIdsFunc(userId);
@@ -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.deleteMsg = void 0;
19
20
  const recipients_1 = require("../../resources/recipients");
@@ -22,7 +23,7 @@ function deleteMsg(delMsgFunc) {
22
23
  if ('function' !== typeof delMsgFunc) {
23
24
  throw new TypeError("Given argument 'delMsgFunc' must be function, but is not.");
24
25
  }
25
- return async function (req, res, next) {
26
+ return async (req, res, next) => {
26
27
  const userId = req.session.params.userId;
27
28
  const msgId = req.params.msgId;
28
29
  try {
@@ -17,6 +17,15 @@ export declare namespace availableAddressesForName {
17
17
  ok: number;
18
18
  };
19
19
  }
20
+ export declare namespace availableDomains {
21
+ const URL_END = "available-domains";
22
+ interface Request {
23
+ signupToken?: string;
24
+ }
25
+ const SC: {
26
+ ok: number;
27
+ };
28
+ }
20
29
  export interface UserMidParams {
21
30
  defaultPKey: {
22
31
  pkey: JsonKey;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2016, 2020 3NSoft Inc.
3
+ Copyright (C) 2015 - 2016, 2020 - 2021 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -16,7 +16,7 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.isActivated = exports.addUser = exports.availableAddressesForName = exports.ERR_SC = void 0;
19
+ exports.isActivated = exports.addUser = exports.availableDomains = exports.availableAddressesForName = exports.ERR_SC = void 0;
20
20
  exports.ERR_SC = {
21
21
  duplicate: 475,
22
22
  malformed: 400
@@ -31,6 +31,15 @@ var availableAddressesForName;
31
31
  Object.freeze(availableAddressesForName.SC);
32
32
  })(availableAddressesForName = exports.availableAddressesForName || (exports.availableAddressesForName = {}));
33
33
  Object.freeze(availableAddressesForName);
34
+ var availableDomains;
35
+ (function (availableDomains) {
36
+ availableDomains.URL_END = 'available-domains';
37
+ availableDomains.SC = {
38
+ ok: 200
39
+ };
40
+ Object.freeze(availableDomains.SC);
41
+ })(availableDomains = exports.availableDomains || (exports.availableDomains = {}));
42
+ Object.freeze(availableDomains);
34
43
  var addUser;
35
44
  (function (addUser) {
36
45
  addUser.URL_END = 'add';