spec-3nweb-server 1.7.1 → 1.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/build/3nstorage/3nstorage-app.d.ts +4 -1
  2. package/build/3nstorage/3nstorage-app.js +18 -9
  3. package/build/3nstorage/owner.d.ts +3 -2
  4. package/build/3nstorage/owner.js +39 -32
  5. package/build/3nstorage/resources/sessions.js +2 -1
  6. package/build/3nstorage/resources/store.d.ts +5 -5
  7. package/build/3nstorage/resources/store.js +3 -12
  8. package/build/3nstorage/resources/users.d.ts +6 -6
  9. package/build/3nstorage/resources/users.js +13 -16
  10. package/build/3nstorage/shared.d.ts +2 -6
  11. package/build/3nstorage/shared.js +5 -9
  12. package/build/asmail/asmail-app.d.ts +1 -1
  13. package/build/asmail/asmail-app.js +3 -3
  14. package/build/asmail/config.d.ts +2 -6
  15. package/build/asmail/config.js +20 -12
  16. package/build/asmail/delivery.d.ts +2 -6
  17. package/build/asmail/delivery.js +0 -6
  18. package/build/asmail/resources/delivery-sessions.js +1 -2
  19. package/build/asmail/resources/inbox.d.ts +17 -26
  20. package/build/asmail/resources/inbox.js +15 -59
  21. package/build/asmail/resources/recipients.d.ts +28 -10
  22. package/build/asmail/resources/recipients.js +62 -22
  23. package/build/asmail/retrieval.d.ts +2 -2
  24. package/build/asmail/retrieval.js +11 -18
  25. package/build/config/signup.d.ts +1 -1
  26. package/build/config/signup.js +1 -1
  27. package/build/lib-common/assert.js +2 -1
  28. package/build/lib-common/buffer-utils.js +2 -1
  29. package/build/lib-common/byte-streaming/common.js +11 -11
  30. package/build/lib-common/bytes-equal.js +2 -1
  31. package/build/lib-common/exceptions/error.js +2 -1
  32. package/build/lib-common/exceptions/file.js +2 -1
  33. package/build/lib-common/exceptions/http.js +2 -1
  34. package/build/lib-common/ipc/generic-ipc.js +14 -14
  35. package/build/lib-common/ipc/ws-ipc.js +2 -1
  36. package/build/lib-common/json-equal.js +2 -1
  37. package/build/lib-common/json-utils.js +2 -1
  38. package/build/lib-common/jwkeys.js +2 -1
  39. package/build/lib-common/map-of-sets.js +2 -1
  40. package/build/lib-common/mid-sigs-NaCl-Ed.js +2 -1
  41. package/build/lib-common/objs-on-disk/file-layout.js +2 -1
  42. package/build/lib-common/objs-on-disk/obj-file.js +2 -1
  43. package/build/lib-common/objs-on-disk/v1-obj-file-format.js +2 -1
  44. package/build/lib-common/processes.js +2 -1
  45. package/build/lib-common/random-node.js +2 -1
  46. package/build/lib-common/service-api/3nstorage/owner.d.ts +1 -3
  47. package/build/lib-common/service-api/3nstorage/owner.js +2 -4
  48. package/build/lib-common/service-api/asmail/config.d.ts +1 -3
  49. package/build/lib-common/service-api/asmail/config.js +4 -5
  50. package/build/lib-common/service-api/asmail/delivery.js +2 -1
  51. package/build/lib-common/service-api/asmail/retrieval.d.ts +1 -3
  52. package/build/lib-common/service-api/asmail/retrieval.js +3 -4
  53. package/build/lib-common/service-api/ipc-api.js +2 -1
  54. package/build/lib-common/service-api/locker.d.ts +17 -0
  55. package/build/lib-common/service-api/locker.js +31 -0
  56. package/build/lib-common/service-api/mailer-id/login.js +2 -1
  57. package/build/lib-common/service-api/mailer-id/provisioning.d.ts +3 -4
  58. package/build/lib-common/service-api/mailer-id/provisioning.js +3 -12
  59. package/build/lib-common/service-api/pub-key-login.js +2 -1
  60. package/build/lib-common/service-api/web-socket-base.js +2 -1
  61. package/build/lib-common/session-encryptor.js +2 -1
  62. package/build/lib-common/time-window-cache.js +2 -1
  63. package/build/lib-server/mid-access.d.ts +5 -0
  64. package/build/lib-server/mid-access.js +28 -0
  65. package/build/lib-server/middleware/body-parsers.d.ts +7 -7
  66. package/build/lib-server/middleware/body-parsers.js +14 -14
  67. package/build/lib-server/pkl-access.d.ts +4 -0
  68. package/build/lib-server/pkl-access.js +28 -0
  69. package/build/lib-server/resources/dns.js +2 -1
  70. package/build/lib-server/resources/mailerid-authorizer.js +5 -6
  71. package/build/lib-server/resources/server-data-folders.d.ts +1 -0
  72. package/build/lib-server/resources/server-data-folders.js +9 -4
  73. package/build/{mailerId/resources/compute-login-dhshared-key.js → lib-server/resources/server-key-for-pkl-challenge.js} +5 -5
  74. package/build/lib-server/resources/sessions.js +7 -7
  75. package/build/lib-server/resources/user-files.d.ts +3 -3
  76. package/build/lib-server/resources/user-files.js +4 -2
  77. package/build/lib-server/routes/sessions/close.js +2 -1
  78. package/build/lib-server/web-sockets/app.js +2 -3
  79. package/build/lib-server/web-sockets/server-events.js +1 -2
  80. package/build/lib.d.ts +1 -1
  81. package/build/lib.js +2 -2
  82. package/build/locker/locker-app.d.ts +3 -0
  83. package/build/locker/locker-app.js +41 -0
  84. package/build/locker/resources/lockers.d.ts +0 -0
  85. package/build/{lib-common/binding.js → locker/resources/lockers.js} +3 -10
  86. package/build/locker/resources/sessions.d.ts +9 -0
  87. package/build/locker/resources/sessions.js +33 -0
  88. package/build/locker/routes/create-locker.d.ts +4 -0
  89. package/build/locker/routes/create-locker.js +37 -0
  90. package/build/mailerId/mailerId-app.d.ts +1 -1
  91. package/build/mailerId/mailerId-app.js +12 -11
  92. package/build/mailerId/routes/certify.js +2 -1
  93. package/build/main.js +1 -1
  94. package/build/mock/dns.js +3 -4
  95. package/build/mock/mock-as-child-proc.js +2 -2
  96. package/build/mock/node-child-ipc.js +2 -1
  97. package/build/mock/run-in-proc.js +2 -2
  98. package/build/mock/tls-options.js +2 -1
  99. package/build/services.d.ts +2 -1
  100. package/build/services.js +22 -11
  101. package/build/{admin → signup}/resources/users.js +3 -4
  102. package/build/{admin/admin-app.d.ts → signup/signup-app.d.ts} +1 -1
  103. package/build/{admin/admin-app.js → signup/signup-app.js} +6 -16
  104. package/package.json +1 -1
  105. package/build/lib-common/binding.d.ts +0 -1
  106. /package/build/{mailerId/resources/compute-login-dhshared-key.d.ts → lib-server/resources/server-key-for-pkl-challenge.d.ts} +0 -0
  107. /package/build/{admin → signup}/resources/users.d.ts +0 -0
  108. /package/build/{admin → signup}/routes/add.d.ts +0 -0
  109. /package/build/{admin → signup}/routes/add.js +0 -0
  110. /package/build/{admin → signup}/routes/get-available-addresses.d.ts +0 -0
  111. /package/build/{admin → signup}/routes/get-available-addresses.js +0 -0
  112. /package/build/{admin → signup}/routes/get-available-domains.d.ts +0 -0
  113. /package/build/{admin → signup}/routes/get-available-domains.js +0 -0
  114. /package/build/{admin → signup}/signup-tokens.d.ts +0 -0
  115. /package/build/{admin → signup}/signup-tokens.js +0 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2017, 2019 - 2020 3NSoft Inc.
3
+ Copyright (C) 2015 - 2017, 2019 - 2020, 2025 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
@@ -329,14 +329,13 @@ class Inbox extends user_files_1.UserFiles {
329
329
  return reader;
330
330
  }
331
331
  /**
332
- * @param inbox
333
332
  * @param initKeyCerts
334
333
  * @param setDefault when it is true, sets default values -- null --
335
334
  * in place of an object with certs.
336
335
  * @return a promise, resolvable to true, when certs are set, or
337
336
  * resolvable to false, when given certs do not pass sanitization.
338
337
  */
339
- static async setPubKey(inbox, initKeyCerts, setDefault) {
338
+ async setPubKey(initKeyCerts, setDefault) {
340
339
  if (setDefault) {
341
340
  initKeyCerts = null;
342
341
  }
@@ -349,20 +348,10 @@ class Inbox extends user_files_1.UserFiles {
349
348
  return false;
350
349
  }
351
350
  }
352
- await inbox.setParam('pubkey', initKeyCerts);
351
+ await this.setParam('pubkey', initKeyCerts);
353
352
  return true;
354
353
  }
355
- /**
356
- * @return a promise, either resolvable to object with certificates,
357
- * or resolvable to null (default), if key certs were not set by the user.
358
- */
359
- static getPubKey(inbox) {
360
- return inbox.getParam('pubkey');
361
- }
362
- static getAnonSenderPolicy(inbox) {
363
- return inbox.getParam('anonymous/policy');
364
- }
365
- static async setAnonSenderPolicy(inbox, policy, setDefault) {
354
+ async setAnonSenderPolicy(policy, setDefault) {
366
355
  if (setDefault) {
367
356
  policy = {
368
357
  accept: true,
@@ -380,16 +369,10 @@ class Inbox extends user_files_1.UserFiles {
380
369
  false;
381
370
  }
382
371
  }
383
- await inbox.setParam('anonymous/policy', policy);
372
+ await this.setParam('anonymous/policy', policy);
384
373
  return true;
385
374
  }
386
- getAnonSenderPolicy() {
387
- return Inbox.getAnonSenderPolicy(this);
388
- }
389
- static getAnonSenderInvites(inbox) {
390
- return inbox.getParam('anonymous/invites');
391
- }
392
- static async setAnonSenderInvites(inbox, invites, setDefault) {
375
+ async setAnonSenderInvites(invites, setDefault) {
393
376
  if (setDefault) {
394
377
  invites = {};
395
378
  }
@@ -406,16 +389,10 @@ class Inbox extends user_files_1.UserFiles {
406
389
  }
407
390
  }
408
391
  }
409
- await inbox.setParam('anonymous/invites', invites);
392
+ await this.setParam('anonymous/invites', invites);
410
393
  return true;
411
394
  }
412
- getAnonSenderInvites() {
413
- return Inbox.getAnonSenderInvites(this);
414
- }
415
- static getAuthSenderPolicy(inbox) {
416
- return inbox.getParam('authenticated/policy');
417
- }
418
- static async setAuthSenderPolicy(inbox, policy, setDefault) {
395
+ async setAuthSenderPolicy(policy, setDefault) {
419
396
  if (setDefault) {
420
397
  policy = {
421
398
  acceptWithInvitesOnly: false,
@@ -435,16 +412,10 @@ class Inbox extends user_files_1.UserFiles {
435
412
  return false;
436
413
  }
437
414
  }
438
- await inbox.setParam('authenticated/policy', policy);
415
+ await this.setParam('authenticated/policy', policy);
439
416
  return true;
440
417
  }
441
- getAuthSenderPolicy() {
442
- return Inbox.getAuthSenderPolicy(this);
443
- }
444
- static getAuthSenderBlacklist(inbox) {
445
- return inbox.getParam('authenticated/blacklist');
446
- }
447
- static async setAuthSenderBlacklist(inbox, list, setDefault) {
418
+ async setAuthSenderBlacklist(list, setDefault) {
448
419
  if (setDefault) {
449
420
  list = {};
450
421
  }
@@ -454,16 +425,10 @@ class Inbox extends user_files_1.UserFiles {
454
425
  return false;
455
426
  }
456
427
  }
457
- await inbox.setParam('authenticated/blacklist', list);
428
+ await this.setParam('authenticated/blacklist', list);
458
429
  return true;
459
430
  }
460
- getAuthSenderBlacklist() {
461
- return Inbox.getAuthSenderBlacklist(this);
462
- }
463
- static getAuthSenderWhitelist(inbox) {
464
- return inbox.getParam('authenticated/whitelist');
465
- }
466
- static async setAuthSenderWhitelist(inbox, list, setDefault) {
431
+ async setAuthSenderWhitelist(list, setDefault) {
467
432
  if (setDefault) {
468
433
  list = {};
469
434
  }
@@ -480,16 +445,10 @@ class Inbox extends user_files_1.UserFiles {
480
445
  }
481
446
  }
482
447
  }
483
- await inbox.setParam('authenticated/whitelist', list);
448
+ await this.setParam('authenticated/whitelist', list);
484
449
  return true;
485
450
  }
486
- getAuthSenderWhitelist() {
487
- return Inbox.getAuthSenderWhitelist(this);
488
- }
489
- static getAuthSenderInvites(inbox) {
490
- return inbox.getParam('authenticated/invites');
491
- }
492
- static async setAuthSenderInvites(inbox, invites, setDefault) {
451
+ async setAuthSenderInvites(invites, setDefault) {
493
452
  if (setDefault) {
494
453
  invites = {};
495
454
  }
@@ -506,12 +465,9 @@ class Inbox extends user_files_1.UserFiles {
506
465
  }
507
466
  }
508
467
  }
509
- await inbox.setParam('authenticated/invites', invites);
468
+ await this.setParam('authenticated/invites', invites);
510
469
  return true;
511
470
  }
512
- getAuthSenderInvites() {
513
- return Inbox.getAuthSenderInvites(this);
514
- }
515
471
  }
516
472
  exports.Inbox = Inbox;
517
473
  Object.freeze(Inbox.prototype);
@@ -1,8 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { Readable } from 'stream';
3
- import { Inbox, ObjReader, MailEventsSink } from './inbox';
3
+ import { ObjReader, MailEventsSink, InboxParams } from './inbox';
4
4
  import * as deliveryApi from '../../lib-common/service-api/asmail/delivery';
5
- import * as configApi from '../../lib-common/service-api/asmail/config';
6
5
  import * as retrievalApi from '../../lib-common/service-api/asmail/retrieval';
7
6
  export { SC } from './inbox';
8
7
  export declare const BIN_TYPE = "application/octet-stream";
@@ -68,12 +67,22 @@ export type IncompleteMsgDeliveryParams = (recipient: string, msgId: string) =>
68
67
  * Rejected promise may be passing string error code from SC.
69
68
  */
70
69
  export type GetObj = (userId: string, msgId: string, objId: string, header: boolean, segsOffset: number, segsLimit: number | undefined) => Promise<ObjReader>;
71
- type GetParam<T> = (userId: string) => Promise<T>;
72
- type SetParam<T> = (userId: string, param: T) => Promise<boolean>;
73
- export type GetPubKey = GetParam<configApi.p.initPubKey.Certs>;
74
- export type SetPubKey = SetParam<configApi.p.initPubKey.Certs>;
75
- export type GetAnonSenderInvites = GetParam<configApi.p.anonSenderInvites.List>;
76
- export type SetAnonSenderInvites = SetParam<configApi.p.anonSenderInvites.List>;
70
+ type GetParam<P extends keyof InboxParams> = (userId: string) => Promise<InboxParams[P]>;
71
+ type SetParam<P extends keyof InboxParams> = (userId: string, param: InboxParams[P]) => Promise<boolean>;
72
+ export type GetPubKey = GetParam<'pubkey'>;
73
+ export type SetPubKey = SetParam<'pubkey'>;
74
+ export type GetAnonSenderPolicy = GetParam<'anonymous/policy'>;
75
+ export type SetAnonSenderPolicy = SetParam<'anonymous/policy'>;
76
+ export type GetAnonSenderInvites = GetParam<'anonymous/invites'>;
77
+ export type SetAnonSenderInvites = SetParam<'anonymous/invites'>;
78
+ export type GetAuthSenderPolicy = GetParam<'authenticated/policy'>;
79
+ export type SetAuthSenderPolicy = SetParam<'authenticated/policy'>;
80
+ export type GetAuthSenderInvites = GetParam<'authenticated/invites'>;
81
+ export type SetAuthSenderInvites = SetParam<'authenticated/invites'>;
82
+ export type GetAuthSenderBlacklist = GetParam<'authenticated/blacklist'>;
83
+ export type SetAuthSenderBlacklist = SetParam<'authenticated/blacklist'>;
84
+ export type GetAuthSenderWhitelist = GetParam<'authenticated/whitelist'>;
85
+ export type SetAuthSenderWhitelist = SetParam<'authenticated/whitelist'>;
77
86
  export type EventsSink = MailEventsSink;
78
87
  export interface Factory {
79
88
  exists: UserExists;
@@ -86,11 +95,20 @@ export interface Factory {
86
95
  deleteMsg: DeleteMsg;
87
96
  getObj: GetObj;
88
97
  incompleteMsgDeliveryParams: IncompleteMsgDeliveryParams;
98
+ setMailEventsSink(sink: EventsSink): void;
89
99
  getPubKey: GetPubKey;
90
100
  setPubKey: SetPubKey;
101
+ getAnonSenderPolicy: GetAnonSenderPolicy;
102
+ setAnonSenderPolicy: SetAnonSenderPolicy;
91
103
  getAnonSenderInvites: GetAnonSenderInvites;
92
104
  setAnonSenderInvites: SetAnonSenderInvites;
93
- setMailEventsSink(sink: EventsSink): void;
105
+ getAuthSenderPolicy: GetAuthSenderPolicy;
106
+ setAuthSenderPolicy: SetAuthSenderPolicy;
107
+ getAuthSenderInvites: GetAuthSenderInvites;
108
+ setAuthSenderInvites: SetAuthSenderInvites;
109
+ getAuthSenderBlacklist: GetAuthSenderBlacklist;
110
+ setAuthSenderBlacklist: SetAuthSenderBlacklist;
111
+ getAuthSenderWhitelist: GetAuthSenderWhitelist;
112
+ setAuthSenderWhitelist: SetAuthSenderWhitelist;
94
113
  }
95
- export type StaticSetter<T> = (inbox: Inbox, param: T, setDefault: boolean) => Promise<boolean>;
96
114
  export declare function makeFactory(rootFolder: string, writeBufferSize?: string | number, readBufferSize?: string | number): Factory;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2017, 2020 3NSoft Inc.
3
+ Copyright (C) 2015 - 2017, 2020, 2025 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
@@ -85,7 +85,7 @@ async function adaptToFreeSpaceLeft(inbox, msgSize) {
85
85
  * mail box.
86
86
  */
87
87
  async function allowedMsgSizeForAnonSender(inbox, invitation) {
88
- const policy = await inbox.getAnonSenderPolicy();
88
+ const policy = await inbox.getParam('anonymous/policy');
89
89
  if (!policy.accept) {
90
90
  return 0;
91
91
  }
@@ -96,7 +96,7 @@ async function allowedMsgSizeForAnonSender(inbox, invitation) {
96
96
  return await adaptToFreeSpaceLeft(inbox, policy.defaultMsgSize);
97
97
  }
98
98
  else {
99
- const invites = await inbox.getAnonSenderInvites();
99
+ const invites = await inbox.getParam('anonymous/invites');
100
100
  const sizeForInvite = invites[invitation];
101
101
  if (typeof sizeForInvite !== 'number') {
102
102
  return 0;
@@ -116,8 +116,8 @@ async function allowedMsgSizeForAnonSender(inbox, invitation) {
116
116
  */
117
117
  async function allowedMsgSizeForAuthSender(inbox, sender, invitation) {
118
118
  const results = await Promise.all([
119
- inbox.getAuthSenderPolicy(),
120
- inbox.getAuthSenderWhitelist()
119
+ inbox.getParam('authenticated/policy'),
120
+ inbox.getParam('authenticated/whitelist')
121
121
  ]);
122
122
  const policy = results[0];
123
123
  const sizeFromWL = findMatchIn(results[1], sender);
@@ -134,7 +134,7 @@ async function allowedMsgSizeForAuthSender(inbox, sender, invitation) {
134
134
  }
135
135
  // if needed, apply blacklist
136
136
  if (policy.applyBlackList) {
137
- const bList = await inbox.getAuthSenderBlacklist();
137
+ const bList = await inbox.getParam('authenticated/blacklist');
138
138
  if (typeof findMatchIn(bList, sender) === 'undefined') {
139
139
  return adaptToFreeSpaceLeft(inbox, policy.defaultMsgSize);
140
140
  }
@@ -169,18 +169,6 @@ function makeFactory(rootFolder, writeBufferSize, readBufferSize) {
169
169
  return inbox;
170
170
  }
171
171
  }
172
- function makeParamGetter(staticGetter) {
173
- return async (userId) => {
174
- const inbox = await getInbox(userId);
175
- return staticGetter(inbox);
176
- };
177
- }
178
- function makeParamSetter(staticSetter) {
179
- return async (userId, param, setDefault) => {
180
- const inbox = await getInbox(userId);
181
- return staticSetter(inbox, param, !!setDefault);
182
- };
183
- }
184
172
  const recipients = {
185
173
  exists: async (userId) => {
186
174
  try {
@@ -194,10 +182,62 @@ function makeFactory(rootFolder, writeBufferSize, readBufferSize) {
194
182
  return false;
195
183
  }
196
184
  },
197
- getPubKey: makeParamGetter(inbox_1.Inbox.getPubKey),
198
- setPubKey: makeParamSetter(inbox_1.Inbox.setPubKey),
199
- getAnonSenderInvites: makeParamGetter(inbox_1.Inbox.getAnonSenderInvites),
200
- setAnonSenderInvites: makeParamSetter(inbox_1.Inbox.setAnonSenderInvites),
185
+ getPubKey: async (recipient) => {
186
+ const inbox = await getInbox(recipient);
187
+ return inbox.getParam('pubkey');
188
+ },
189
+ setPubKey: async (userId, pkey) => {
190
+ const inbox = await getInbox(userId);
191
+ return inbox.setPubKey(pkey, false);
192
+ },
193
+ getAnonSenderPolicy: async (recipient) => {
194
+ const inbox = await getInbox(recipient);
195
+ return inbox.getParam('anonymous/policy');
196
+ },
197
+ setAnonSenderPolicy: async (userId, policy) => {
198
+ const inbox = await getInbox(userId);
199
+ return inbox.setAnonSenderPolicy(policy, false);
200
+ },
201
+ getAnonSenderInvites: async (recipient) => {
202
+ const inbox = await getInbox(recipient);
203
+ return inbox.getParam('anonymous/invites');
204
+ },
205
+ setAnonSenderInvites: async (userId, invites) => {
206
+ const inbox = await getInbox(userId);
207
+ return inbox.setAnonSenderInvites(invites, false);
208
+ },
209
+ getAuthSenderPolicy: async (recipient) => {
210
+ const inbox = await getInbox(recipient);
211
+ return inbox.getParam('authenticated/policy');
212
+ },
213
+ setAuthSenderPolicy: async (userId, policy) => {
214
+ const inbox = await getInbox(userId);
215
+ return inbox.setAuthSenderPolicy(policy, false);
216
+ },
217
+ getAuthSenderInvites: async (recipient) => {
218
+ const inbox = await getInbox(recipient);
219
+ return inbox.getParam('authenticated/invites');
220
+ },
221
+ setAuthSenderInvites: async (userId, invites) => {
222
+ const inbox = await getInbox(userId);
223
+ return inbox.setAnonSenderInvites(invites, false);
224
+ },
225
+ getAuthSenderBlacklist: async (recipient) => {
226
+ const inbox = await getInbox(recipient);
227
+ return inbox.getParam('authenticated/blacklist');
228
+ },
229
+ setAuthSenderBlacklist: async (userId, list) => {
230
+ const inbox = await getInbox(userId);
231
+ return inbox.setAuthSenderBlacklist(list, false);
232
+ },
233
+ getAuthSenderWhitelist: async (recipient) => {
234
+ const inbox = await getInbox(recipient);
235
+ return inbox.getParam('authenticated/whitelist');
236
+ },
237
+ setAuthSenderWhitelist: async (userId, list) => {
238
+ const inbox = await getInbox(userId);
239
+ return inbox.setAuthSenderWhitelist(list, false);
240
+ },
201
241
  allowedMaxMsgSize: async (recipient, sender, invitation) => {
202
242
  const inbox = await getInbox(recipient);
203
243
  // XXX move these two functions into inbox
@@ -1,5 +1,5 @@
1
1
  import { AppWithWSs } from '../lib-server/web-sockets/app';
2
2
  import { SessionsFactory } from './resources/sessions';
3
- import { Factory as recipFactory } from './resources/recipients';
3
+ import { Factory as RecipFactory } from './resources/recipients';
4
4
  import { MidAuthorizer } from '../lib-server/routes/sessions/mid-auth';
5
- export declare function makeApp(domain: string, sessions: SessionsFactory, recipients: recipFactory, midAuthorizer: MidAuthorizer): AppWithWSs;
5
+ export declare function makeApp(domain: string, sessions: SessionsFactory, recipients: RecipFactory, midAuthorizer: MidAuthorizer): AppWithWSs;
@@ -17,26 +17,19 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
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
- */
24
- // Internal libs
25
20
  const body_parsers_1 = require("../lib-server/middleware/body-parsers");
26
21
  const app_1 = require("../lib-server/web-sockets/app");
27
22
  const server_events_1 = require("../lib-server/web-sockets/server-events");
28
- // routes
29
- const mid_auth_1 = require("../lib-server/routes/sessions/mid-auth");
30
- const start_1 = require("../lib-server/routes/sessions/start");
31
23
  const close_1 = require("../lib-server/routes/sessions/close");
32
24
  const list_messages_1 = require("./routes/retrieval/list-messages");
33
25
  const get_message_meta_1 = require("./routes/retrieval/get-message-meta");
34
26
  const remove_message_1 = require("./routes/retrieval/remove-message");
35
27
  const get_message_obj_1 = require("./routes/retrieval/get-message-obj");
36
28
  const api = require("../lib-common/service-api/asmail/retrieval");
29
+ const mid_access_1 = require("../lib-server/mid-access");
37
30
  function makeApp(domain, sessions, recipients, midAuthorizer) {
38
31
  const app = new app_1.AppWithWSs();
39
- setHttpPart(app, domain, sessions, recipients, midAuthorizer);
32
+ setHttpPart(app.http, domain, sessions, recipients, midAuthorizer);
40
33
  setWSPart(app, sessions, recipients);
41
34
  return app;
42
35
  }
@@ -51,15 +44,15 @@ function setWSPart(app, sessions, recipients) {
51
44
  app.addWS(api.wsEventChannel.URL_END, sockets);
52
45
  }
53
46
  function setHttpPart(app, domain, sessions, recipients, midAuthorizer) {
54
- app.http.disable('etag');
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));
47
+ app.disable('etag');
48
+ // Login
49
+ (0, mid_access_1.addMailerIdLoginRoutes)(app, domain, '/' + api.midLogin.URL_PART, sessions, recipients.exists, midAuthorizer);
57
50
  // *** Require authorized session for everything below ***
58
- app.http.use(sessions.ensureAuthorizedSession());
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));
51
+ app.use(sessions.ensureAuthorizedSession());
52
+ app.post('/' + api.closeSession.URL_END, (0, body_parsers_1.emptyBody)(), (0, close_1.closeSession)());
53
+ app.get('/' + api.listMsgs.URL_END, (0, list_messages_1.listMsgIds)(recipients.getMsgIds));
54
+ app.get('/' + api.msgMetadata.EXPRESS_URL_END, (0, get_message_meta_1.getMsgMeta)(recipients.getMsgMeta));
55
+ app.delete('/' + api.rmMsg.EXPRESS_URL_END, (0, remove_message_1.deleteMsg)(recipients.deleteMsg));
56
+ app.get('/' + api.msgObj.EXPRESS_URL_END, (0, get_message_obj_1.getMsgObj)(recipients.getObj));
64
57
  }
65
58
  Object.freeze(exports);
@@ -1,4 +1,4 @@
1
- import { MultiDomainSignupCtx, SingleUserSignupCtx } from "../admin/signup-tokens";
1
+ import { MultiDomainSignupCtx, SingleUserSignupCtx } from "../signup/signup-tokens";
2
2
  export declare function addSingleUserSignup(rootFolder: string, userId: string): Promise<string>;
3
3
  export declare function addMultiDomainSignup(rootFolder: string, domains: string[]): Promise<string>;
4
4
  export declare function readNoTokensFile(noTokenFile: string): Promise<MultiDomainSignupCtx>;
@@ -18,7 +18,7 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.readAllSignupTokens = exports.readTokenFile = exports.readNoTokensFile = exports.addMultiDomainSignup = exports.addSingleUserSignup = void 0;
20
20
  const async_fs_node_1 = require("../lib-common/async-fs-node");
21
- const signup_tokens_1 = require("../admin/signup-tokens");
21
+ const signup_tokens_1 = require("../signup/signup-tokens");
22
22
  const server_data_folders_1 = require("../lib-server/resources/server-data-folders");
23
23
  const error_1 = require("../lib-common/exceptions/error");
24
24
  const path_1 = require("path");
@@ -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.assert = void 0;
19
20
  function assert(ok, errMsg) {
@@ -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.joinByteArrs = exports.utf8 = exports.base64urlSafe = exports.base64 = exports.bufFromJson = exports.toBuffer = exports.EMPTY_BUFFER = void 0;
19
20
  exports.EMPTY_BUFFER = Buffer.alloc(0);
@@ -13,18 +13,18 @@
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.sourceFromArray = exports.BytesFIFOBuffer = exports.wrapByteSinkImplementation = exports.wrapByteSourceImplementation = void 0;
19
- const binding_1 = require("../binding");
20
20
  function wrapByteSourceImplementation(src) {
21
21
  const wrap = {
22
- read: (0, binding_1.bind)(src, src.read),
23
- getSize: (0, binding_1.bind)(src, src.getSize)
22
+ read: src.read.bind(src),
23
+ getSize: src.getSize.bind(src)
24
24
  };
25
25
  if (src.seek) {
26
- wrap.seek = (0, binding_1.bind)(src, src.seek);
27
- wrap.getPosition = (0, binding_1.bind)(src, src.getPosition);
26
+ wrap.seek = src.seek.bind(src);
27
+ wrap.getPosition = src.getPosition.bind(src);
28
28
  }
29
29
  wrap.$_transferrable_type_id_$ = 'ByteSource';
30
30
  return wrap;
@@ -32,13 +32,13 @@ function wrapByteSourceImplementation(src) {
32
32
  exports.wrapByteSourceImplementation = wrapByteSourceImplementation;
33
33
  function wrapByteSinkImplementation(sink) {
34
34
  const wrap = {
35
- setSize: (0, binding_1.bind)(sink, sink.setSize),
36
- write: (0, binding_1.bind)(sink, sink.write),
37
- getSize: (0, binding_1.bind)(sink, sink.getSize)
35
+ setSize: sink.setSize.bind(sink),
36
+ write: sink.write.bind(sink),
37
+ getSize: sink.getSize.bind(sink)
38
38
  };
39
39
  if (sink.seek) {
40
- wrap.seek = (0, binding_1.bind)(sink, sink.seek);
41
- wrap.getPosition = (0, binding_1.bind)(sink, sink.getPosition);
40
+ wrap.seek = sink.seek.bind(sink);
41
+ wrap.getPosition = sink.getPosition.bind(sink);
42
42
  }
43
43
  wrap.$_transferrable_type_id_$ = 'ByteSink';
44
44
  return wrap;
@@ -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.bytesEqual = void 0;
19
20
  function bytesEqual(a, b) {
@@ -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.stringifyErr = exports.errWithCause = void 0;
19
20
  function errWithCause(cause, message) {
@@ -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.ensureCorrectFS = exports.maskPathInExc = exports.makeFileException = exports.Code = exports.fileExceptionType = void 0;
19
20
  exports.fileExceptionType = 'file';
@@ -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.makeHTTPException = exports.makeConnectionException = void 0;
19
20
  function makeConnectionException(url, method, msg, cause) {
@@ -13,11 +13,11 @@
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.SingleObserverWrap = exports.MultiObserverWrap = exports.makeSubscribingClient = exports.makeEventfulServer = exports.makeRequestServer = exports.makeRequestingClient = void 0;
19
20
  const ipc_api_1 = require("../service-api/ipc-api");
20
- const binding_1 = require("../binding");
21
21
  const map_of_sets_1 = require("../map-of-sets");
22
22
  const processes_1 = require("../processes");
23
23
  function toTransferrableError(e) {
@@ -159,8 +159,8 @@ class RequestingSide extends MessageHandler {
159
159
  wrap() {
160
160
  const w = {
161
161
  makeRequest: this.makeRequest.bind(this),
162
- close: (0, binding_1.bind)(this, this.close),
163
- on: (0, binding_1.bind)(this, this.on)
162
+ close: this.close.bind(this),
163
+ on: this.on.bind(this)
164
164
  };
165
165
  return Object.freeze(w);
166
166
  }
@@ -261,10 +261,10 @@ class ReplyingSide extends MessageHandler {
261
261
  }
262
262
  wrap() {
263
263
  const w = {
264
- addHandler: (0, binding_1.bind)(this, this.addHandler),
265
- notifyOfProgressOnRequest: (0, binding_1.bind)(this, this.notifyOfProgressOnRequest),
266
- close: (0, binding_1.bind)(this, this.close),
267
- on: (0, binding_1.bind)(this, this.on)
264
+ addHandler: this.addHandler.bind(this),
265
+ notifyOfProgressOnRequest: this.notifyOfProgressOnRequest.bind(this),
266
+ close: this.close.bind(this),
267
+ on: this.on.bind(this)
268
268
  };
269
269
  return Object.freeze(w);
270
270
  }
@@ -287,8 +287,8 @@ class EventsSendingSide extends ReplyingSide {
287
287
  super(channel, comm);
288
288
  this.subscriptionGroups = [];
289
289
  this.subscribedEvents = new Set();
290
- this.addHandler(ipc_api_1.events.subscribe.REQ_NAME, (0, binding_1.bind)(this, this.handleSubscribe));
291
- this.addHandler(ipc_api_1.events.unsubscribe.REQ_NAME, (0, binding_1.bind)(this, this.handleUnsubscribe));
290
+ this.addHandler(ipc_api_1.events.subscribe.REQ_NAME, this.handleSubscribe.bind(this));
291
+ this.addHandler(ipc_api_1.events.unsubscribe.REQ_NAME, this.handleUnsubscribe.bind(this));
292
292
  }
293
293
  findGroup(eventChannel) {
294
294
  for (const gr of this.subscriptionGroups) {
@@ -373,9 +373,9 @@ class EventsSendingSide extends ReplyingSide {
373
373
  notifyOfProgressOnRequest: reqServer.notifyOfProgressOnRequest,
374
374
  close: reqServer.close,
375
375
  on: reqServer.on,
376
- addEventGroup: (0, binding_1.bind)(this, this.addEventGroup),
377
- sendEvent: (0, binding_1.bind)(this, this.sendEvent),
378
- endEvent: (0, binding_1.bind)(this, this.endEvent)
376
+ addEventGroup: this.addEventGroup.bind(this),
377
+ sendEvent: this.sendEvent.bind(this),
378
+ endEvent: this.endEvent.bind(this)
379
379
  };
380
380
  return Object.freeze(w);
381
381
  }
@@ -536,7 +536,7 @@ class EventsReceivingSide extends RequestingSide {
536
536
  makeRequest: reqClient.makeRequest,
537
537
  close: reqClient.close,
538
538
  on: reqClient.on,
539
- subscribe: (0, binding_1.bind)(this, this.subscribe)
539
+ subscribe: this.subscribe.bind(this)
540
540
  };
541
541
  return Object.freeze(w);
542
542
  }
@@ -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.makeSubscriber = exports.makeJsonCommPoint = exports.makeEventfulServer = void 0;
19
20
  const generic_ipc_1 = require("./generic-ipc");
@@ -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.deepEqual = void 0;
19
20
  /**
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.applyChangesToJSON = exports.deepFind = exports.deepEqual = exports.copy = void 0;
19
20
  /**