spec-3nweb-server 1.7.0 → 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 (144) 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.d.ts +2 -2
  6. package/build/3nstorage/resources/sessions.js +2 -1
  7. package/build/3nstorage/resources/store.d.ts +6 -6
  8. package/build/3nstorage/resources/store.js +3 -12
  9. package/build/3nstorage/resources/users.d.ts +16 -16
  10. package/build/3nstorage/resources/users.js +13 -16
  11. package/build/3nstorage/shared.d.ts +2 -6
  12. package/build/3nstorage/shared.js +5 -9
  13. package/build/asmail/asmail-app.d.ts +1 -1
  14. package/build/asmail/asmail-app.js +3 -3
  15. package/build/asmail/config.d.ts +2 -6
  16. package/build/asmail/config.js +20 -12
  17. package/build/asmail/delivery.d.ts +2 -6
  18. package/build/asmail/delivery.js +0 -6
  19. package/build/asmail/resources/delivery-sessions.d.ts +3 -3
  20. package/build/asmail/resources/delivery-sessions.js +1 -2
  21. package/build/asmail/resources/inbox.d.ts +26 -35
  22. package/build/asmail/resources/inbox.js +15 -59
  23. package/build/asmail/resources/recipients.d.ts +39 -21
  24. package/build/asmail/resources/recipients.js +62 -22
  25. package/build/asmail/resources/sessions.d.ts +2 -2
  26. package/build/asmail/retrieval.d.ts +2 -2
  27. package/build/asmail/retrieval.js +11 -18
  28. package/build/asmail/routes/delivery/sender-authorization.d.ts +1 -1
  29. package/build/asmail/routes/delivery/start-session.d.ts +1 -1
  30. package/build/config/letsencrypt.d.ts +1 -1
  31. package/build/config/signup.d.ts +1 -1
  32. package/build/config/signup.js +2 -1
  33. package/build/lib-common/assert.js +2 -1
  34. package/build/lib-common/buffer-utils.js +2 -1
  35. package/build/lib-common/byte-streaming/common.d.ts +2 -2
  36. package/build/lib-common/byte-streaming/common.js +16 -16
  37. package/build/lib-common/bytes-equal.js +2 -1
  38. package/build/lib-common/exceptions/error.js +2 -1
  39. package/build/lib-common/exceptions/file.d.ts +1 -1
  40. package/build/lib-common/exceptions/file.js +2 -1
  41. package/build/lib-common/exceptions/http.js +2 -1
  42. package/build/lib-common/ipc/generic-ipc.d.ts +7 -7
  43. package/build/lib-common/ipc/generic-ipc.js +20 -20
  44. package/build/lib-common/ipc/ws-ipc.js +2 -1
  45. package/build/lib-common/json-equal.js +2 -1
  46. package/build/lib-common/json-utils.js +2 -1
  47. package/build/lib-common/jwkeys.js +2 -1
  48. package/build/lib-common/map-of-sets.js +2 -1
  49. package/build/lib-common/mid-sigs-NaCl-Ed.js +2 -1
  50. package/build/lib-common/objs-on-disk/file-layout.d.ts +4 -4
  51. package/build/lib-common/objs-on-disk/file-layout.js +2 -1
  52. package/build/lib-common/objs-on-disk/obj-file.js +2 -1
  53. package/build/lib-common/objs-on-disk/utils.d.ts +3 -3
  54. package/build/lib-common/objs-on-disk/v1-obj-file-format.js +2 -1
  55. package/build/lib-common/processes.d.ts +1 -1
  56. package/build/lib-common/processes.js +2 -1
  57. package/build/lib-common/random-node.js +2 -1
  58. package/build/lib-common/service-api/3nstorage/owner.d.ts +1 -3
  59. package/build/lib-common/service-api/3nstorage/owner.js +2 -4
  60. package/build/lib-common/service-api/asmail/config.d.ts +1 -3
  61. package/build/lib-common/service-api/asmail/config.js +4 -5
  62. package/build/lib-common/service-api/asmail/delivery.js +2 -1
  63. package/build/lib-common/service-api/asmail/retrieval.d.ts +1 -3
  64. package/build/lib-common/service-api/asmail/retrieval.js +3 -4
  65. package/build/lib-common/service-api/ipc-api.d.ts +6 -6
  66. package/build/lib-common/service-api/ipc-api.js +2 -1
  67. package/build/lib-common/service-api/locker.d.ts +17 -0
  68. package/build/lib-common/service-api/locker.js +31 -0
  69. package/build/lib-common/service-api/mailer-id/login.js +2 -1
  70. package/build/lib-common/service-api/mailer-id/provisioning.d.ts +3 -4
  71. package/build/lib-common/service-api/mailer-id/provisioning.js +3 -12
  72. package/build/lib-common/service-api/pub-key-login.js +2 -1
  73. package/build/lib-common/service-api/web-socket-base.d.ts +1 -1
  74. package/build/lib-common/service-api/web-socket-base.js +2 -1
  75. package/build/lib-common/session-encryptor.js +2 -1
  76. package/build/lib-common/time-window-cache.js +2 -1
  77. package/build/lib-server/mid-access.d.ts +5 -0
  78. package/build/lib-server/mid-access.js +28 -0
  79. package/build/lib-server/middleware/body-parsers.d.ts +7 -7
  80. package/build/lib-server/middleware/body-parsers.js +14 -14
  81. package/build/lib-server/middleware/error-handler.d.ts +1 -1
  82. package/build/lib-server/pkl-access.d.ts +4 -0
  83. package/build/lib-server/pkl-access.js +28 -0
  84. package/build/lib-server/resources/dns.d.ts +1 -1
  85. package/build/lib-server/resources/dns.js +2 -1
  86. package/build/lib-server/resources/mailerid-authorizer.js +5 -6
  87. package/build/lib-server/resources/server-data-folders.d.ts +1 -0
  88. package/build/lib-server/resources/server-data-folders.js +9 -4
  89. package/build/{mailerId/resources/compute-login-dhshared-key.js → lib-server/resources/server-key-for-pkl-challenge.js} +5 -5
  90. package/build/lib-server/resources/sessions.d.ts +2 -2
  91. package/build/lib-server/resources/sessions.js +7 -7
  92. package/build/lib-server/resources/user-files.d.ts +4 -4
  93. package/build/lib-server/resources/user-files.js +4 -2
  94. package/build/lib-server/routes/pub-key-login/start-exchange.d.ts +4 -4
  95. package/build/lib-server/routes/sessions/close.js +2 -1
  96. package/build/lib-server/routes/sessions/mid-auth.d.ts +1 -1
  97. package/build/lib-server/routes/sessions/start.d.ts +4 -4
  98. package/build/lib-server/web-sockets/app.d.ts +1 -1
  99. package/build/lib-server/web-sockets/app.js +8 -9
  100. package/build/lib-server/web-sockets/server-events.d.ts +1 -1
  101. package/build/lib-server/web-sockets/server-events.js +1 -2
  102. package/build/lib.d.ts +1 -2
  103. package/build/lib.js +2 -5
  104. package/build/locker/locker-app.d.ts +3 -0
  105. package/build/locker/locker-app.js +41 -0
  106. package/build/locker/resources/lockers.d.ts +0 -0
  107. package/build/{lib-common/binding.js → locker/resources/lockers.js} +3 -10
  108. package/build/locker/resources/sessions.d.ts +9 -0
  109. package/build/locker/resources/sessions.js +33 -0
  110. package/build/locker/routes/create-locker.d.ts +4 -0
  111. package/build/locker/routes/create-locker.js +37 -0
  112. package/build/mailerId/mailerId-app.d.ts +1 -1
  113. package/build/mailerId/mailerId-app.js +12 -11
  114. package/build/mailerId/resources/certifier.d.ts +1 -1
  115. package/build/mailerId/resources/sessions.d.ts +1 -1
  116. package/build/mailerId/routes/certify.js +2 -1
  117. package/build/main.js +1 -1
  118. package/build/mock/dns.js +3 -4
  119. package/build/mock/mock-as-child-proc.js +2 -2
  120. package/build/mock/node-child-ipc.d.ts +2 -2
  121. package/build/mock/node-child-ipc.js +2 -1
  122. package/build/mock/run-in-proc.js +2 -2
  123. package/build/mock/tls-options.js +2 -1
  124. package/build/services.d.ts +2 -1
  125. package/build/services.js +22 -11
  126. package/build/{admin → signup}/resources/users.d.ts +3 -3
  127. package/build/{admin → signup}/resources/users.js +3 -4
  128. package/build/{admin/admin-app.d.ts → signup/signup-app.d.ts} +1 -1
  129. package/build/{admin/admin-app.js → signup/signup-app.js} +6 -16
  130. package/build/{admin → signup}/signup-tokens.d.ts +1 -1
  131. package/package.json +3 -3
  132. package/build/config/from-env.d.ts +0 -9
  133. package/build/config/from-env.js +0 -117
  134. package/build/lib-common/binding.d.ts +0 -1
  135. package/build/run.d.ts +0 -1
  136. package/build/run.js +0 -45
  137. /package/build/{mailerId/resources/compute-login-dhshared-key.d.ts → lib-server/resources/server-key-for-pkl-challenge.d.ts} +0 -0
  138. /package/build/{admin → signup}/routes/add.d.ts +0 -0
  139. /package/build/{admin → signup}/routes/add.js +0 -0
  140. /package/build/{admin → signup}/routes/get-available-addresses.d.ts +0 -0
  141. /package/build/{admin → signup}/routes/get-available-addresses.js +0 -0
  142. /package/build/{admin → signup}/routes/get-available-domains.d.ts +0 -0
  143. /package/build/{admin → signup}/routes/get-available-domains.js +0 -0
  144. /package/build/{admin → signup}/signup-tokens.js +0 -0
@@ -5,15 +5,15 @@ import * as configApi from '../../lib-common/service-api/asmail/config';
5
5
  import * as retrievalApi from '../../lib-common/service-api/asmail/retrieval';
6
6
  import { UserFiles, ObjReader } from '../../lib-server/resources/user-files';
7
7
  export { ObjPipe, ObjReader } from '../../lib-server/resources/user-files';
8
- declare type AnonSenderPolicy = configApi.p.anonSenderPolicy.Policy;
9
- export declare type AuthSenderPolicy = configApi.p.authSenderPolicy.Policy;
10
- declare type Whitelist = configApi.p.authSenderWhitelist.List;
11
- declare type Blacklist = configApi.p.authSenderBlacklist.List;
12
- declare type AuthSenderInvites = configApi.p.authSenderInvites.List;
13
- declare type AnonSenderInvites = configApi.p.anonSenderInvites.List;
14
- declare type MsgMeta = retrievalApi.MsgMeta;
15
- export declare type MsgEvents = retrievalApi.msgMainObjRecieved.Event | retrievalApi.msgRecievedCompletely.Event;
16
- export declare type MailEventsSink = (userId: string, channel: string, event: MsgEvents) => void;
8
+ type AnonSenderPolicy = configApi.p.anonSenderPolicy.Policy;
9
+ export type AuthSenderPolicy = configApi.p.authSenderPolicy.Policy;
10
+ type Whitelist = configApi.p.authSenderWhitelist.List;
11
+ type Blacklist = configApi.p.authSenderBlacklist.List;
12
+ type AuthSenderInvites = configApi.p.authSenderInvites.List;
13
+ type AnonSenderInvites = configApi.p.anonSenderInvites.List;
14
+ type MsgMeta = retrievalApi.MsgMeta;
15
+ export type MsgEvents = retrievalApi.msgMainObjRecieved.Event | retrievalApi.msgRecievedCompletely.Event;
16
+ export type MailEventsSink = (userId: string, channel: string, event: MsgEvents) => void;
17
17
  export declare const SC: {
18
18
  OBJ_EXIST: string;
19
19
  USER_UNKNOWN: string;
@@ -22,7 +22,16 @@ export declare const SC: {
22
22
  WRONG_OBJ_STATE: string;
23
23
  OBJ_FILE_INCOMPLETE: string;
24
24
  };
25
- export declare class Inbox extends UserFiles {
25
+ export interface InboxParams {
26
+ "pubkey": deliveryApi.initPubKey.Reply;
27
+ "anonymous/policy": AnonSenderPolicy;
28
+ "anonymous/invites": AnonSenderInvites;
29
+ "authenticated/policy": AuthSenderPolicy;
30
+ "authenticated/blacklist": Blacklist;
31
+ "authenticated/whitelist": Whitelist;
32
+ "authenticated/invites": AuthSenderInvites;
33
+ }
34
+ export declare class Inbox extends UserFiles<InboxParams> {
26
35
  private metas;
27
36
  private objFiles;
28
37
  private mailEventsSink;
@@ -97,35 +106,17 @@ export declare class Inbox extends UserFiles {
97
106
  */
98
107
  getObj(msgId: string, objId: string, header: boolean, segsOfs: number, segsLimit: number | undefined): Promise<ObjReader>;
99
108
  /**
100
- * @param inbox
101
109
  * @param initKeyCerts
102
110
  * @param setDefault when it is true, sets default values -- null --
103
111
  * in place of an object with certs.
104
112
  * @return a promise, resolvable to true, when certs are set, or
105
113
  * resolvable to false, when given certs do not pass sanitization.
106
114
  */
107
- static setPubKey(inbox: Inbox, initKeyCerts: deliveryApi.initPubKey.Reply, setDefault: boolean): Promise<boolean>;
108
- /**
109
- * @return a promise, either resolvable to object with certificates,
110
- * or resolvable to null (default), if key certs were not set by the user.
111
- */
112
- static getPubKey(inbox: Inbox): Promise<deliveryApi.initPubKey.Reply>;
113
- static getAnonSenderPolicy(inbox: Inbox): Promise<AnonSenderPolicy>;
114
- static setAnonSenderPolicy(inbox: Inbox, policy: AnonSenderPolicy, setDefault: boolean): Promise<boolean>;
115
- getAnonSenderPolicy(): Promise<AnonSenderPolicy>;
116
- static getAnonSenderInvites(inbox: Inbox): Promise<AnonSenderInvites>;
117
- static setAnonSenderInvites(inbox: Inbox, invites: AnonSenderInvites, setDefault: boolean): Promise<boolean>;
118
- getAnonSenderInvites(): Promise<AnonSenderInvites>;
119
- static getAuthSenderPolicy(inbox: Inbox): Promise<AuthSenderPolicy>;
120
- static setAuthSenderPolicy(inbox: Inbox, policy: AuthSenderPolicy, setDefault: boolean): Promise<boolean>;
121
- getAuthSenderPolicy(): Promise<AuthSenderPolicy>;
122
- static getAuthSenderBlacklist(inbox: Inbox): Promise<Blacklist>;
123
- static setAuthSenderBlacklist(inbox: Inbox, list: Blacklist, setDefault: boolean): Promise<boolean>;
124
- getAuthSenderBlacklist(): Promise<Blacklist>;
125
- static getAuthSenderWhitelist(inbox: Inbox): Promise<Whitelist>;
126
- static setAuthSenderWhitelist(inbox: Inbox, list: Whitelist, setDefault: boolean): Promise<boolean>;
127
- getAuthSenderWhitelist(): Promise<Whitelist>;
128
- static getAuthSenderInvites(inbox: Inbox): Promise<AuthSenderInvites>;
129
- static setAuthSenderInvites(inbox: Inbox, invites: AuthSenderInvites, setDefault: boolean): Promise<boolean>;
130
- getAuthSenderInvites(): Promise<AuthSenderInvites>;
115
+ setPubKey(initKeyCerts: deliveryApi.initPubKey.Reply, setDefault: boolean): Promise<boolean>;
116
+ setAnonSenderPolicy(policy: AnonSenderPolicy, setDefault: boolean): Promise<boolean>;
117
+ setAnonSenderInvites(invites: AnonSenderInvites, setDefault: boolean): Promise<boolean>;
118
+ setAuthSenderPolicy(policy: AuthSenderPolicy, setDefault: boolean): Promise<boolean>;
119
+ setAuthSenderBlacklist(list: Blacklist, setDefault: boolean): Promise<boolean>;
120
+ setAuthSenderWhitelist(list: Whitelist, setDefault: boolean): Promise<boolean>;
121
+ setAuthSenderInvites(invites: AuthSenderInvites, setDefault: boolean): Promise<boolean>;
131
122
  }
@@ -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";
@@ -10,7 +9,7 @@ export declare const BIN_TYPE = "application/octet-stream";
10
9
  * This checks existence of a given user, returning a promise, resolvable
11
10
  * either to true, when given user id is known, or to false, when it is not.
12
11
  */
13
- export declare type UserExists = (userId: string) => Promise<boolean>;
12
+ export type UserExists = (userId: string) => Promise<boolean>;
14
13
  /**
15
14
  * This tells what is an allowable maximum message size for a given recipient,
16
15
  * for a given sender and/or under a given invitation token.
@@ -20,46 +19,46 @@ export declare type UserExists = (userId: string) => Promise<boolean>;
20
19
  * (3) -1 (less than zero), if mail cannot be accepted due to full mail
21
20
  * box.
22
21
  */
23
- export declare type AllowedMaxMsgSize = (recipient: string, sender: string | undefined, invitation: string | undefined) => Promise<number>;
22
+ export type AllowedMaxMsgSize = (recipient: string, sender: string | undefined, invitation: string | undefined) => Promise<number>;
24
23
  /**
25
24
  * This allocates storage for a message returning a promise, resolvable to
26
25
  * (1) message id, when a folder for new message has been created,
27
26
  * (2) undefined, if recipient is unknown.
28
27
  */
29
- export declare type SetMsgStorage = (recipient: string, msgMeta: deliveryApi.msgMeta.Request, authSender: string | undefined, invite: string | undefined, maxMsgLength: number) => Promise<string>;
28
+ export type SetMsgStorage = (recipient: string, msgMeta: deliveryApi.msgMeta.Request, authSender: string | undefined, invite: string | undefined, maxMsgLength: number) => Promise<string>;
30
29
  /**
31
30
  * This saves object's bytes, returning a promise, resolvable when saving
32
31
  * is OK, otherwise, promise rejects with string error code from SC.
33
32
  */
34
- export declare type SaveObj = (recipient: string, msgId: string, objId: string, fstReq: deliveryApi.PutObjFirstQueryOpts | undefined, sndReq: deliveryApi.PutObjSecondQueryOpts | undefined, bytesLen: number, bytes: Readable) => Promise<void>;
33
+ export type SaveObj = (recipient: string, msgId: string, objId: string, fstReq: deliveryApi.PutObjFirstQueryOpts | undefined, sndReq: deliveryApi.PutObjSecondQueryOpts | undefined, bytesLen: number, bytes: Readable) => Promise<void>;
35
34
  /**
36
35
  * This finalizes delivery of a message, returning a promise.
37
36
  * Rejected promise may have a string error code from SC.
38
37
  */
39
- export declare type FinalizeDelivery = (recipient: string, msgId: string) => Promise<void>;
38
+ export type FinalizeDelivery = (recipient: string, msgId: string) => Promise<void>;
40
39
  /**
41
40
  * This returns a promise, resolvable to array with ids of available messages.
42
41
  * Rejected promise may have a string error code from SC.
43
42
  */
44
- export declare type GetMsgIds = (userId: string) => Promise<retrievalApi.listMsgs.Reply>;
43
+ export type GetMsgIds = (userId: string) => Promise<retrievalApi.listMsgs.Reply>;
45
44
  /**
46
45
  * This returns a promise, resolvable to message meta.
47
46
  * Rejected promise may have a string error code from SC.
48
47
  */
49
- export declare type GetMsgMeta = (userId: string, msgId: string) => Promise<retrievalApi.MsgMeta>;
48
+ export type GetMsgMeta = (userId: string, msgId: string) => Promise<retrievalApi.MsgMeta>;
50
49
  /**
51
50
  * This deletes a message returning a promise, resolvable when message is
52
51
  * removed.
53
52
  * Rejected promise may have a string error code from SC.
54
53
  */
55
- export declare type DeleteMsg = (userId: string, msgId: string) => Promise<void>;
54
+ export type DeleteMsg = (userId: string, msgId: string) => Promise<void>;
56
55
  /**
57
56
  * This returns parameter of a message that is still in delivery, identified
58
57
  * by given recipient and message id. If message is unknown, or if it has
59
58
  * already been delivered, error code is thrown.
60
59
  * Rejected promise may have a string error code from SC.
61
60
  */
62
- export declare type IncompleteMsgDeliveryParams = (recipient: string, msgId: string) => Promise<{
61
+ export type IncompleteMsgDeliveryParams = (recipient: string, msgId: string) => Promise<{
63
62
  maxMsgLength: number;
64
63
  currentMsgLength: number;
65
64
  }>;
@@ -67,14 +66,24 @@ export declare type IncompleteMsgDeliveryParams = (recipient: string, msgId: str
67
66
  * This returns a promise, resolvable to readable stream of object bytes.
68
67
  * Rejected promise may be passing string error code from SC.
69
68
  */
70
- export declare type GetObj = (userId: string, msgId: string, objId: string, header: boolean, segsOffset: number, segsLimit: number | undefined) => Promise<ObjReader>;
71
- declare type GetParam<T> = (userId: string) => Promise<T>;
72
- declare type SetParam<T> = (userId: string, param: T) => Promise<boolean>;
73
- export declare type GetPubKey = GetParam<configApi.p.initPubKey.Certs>;
74
- export declare type SetPubKey = SetParam<configApi.p.initPubKey.Certs>;
75
- export declare type GetAnonSenderInvites = GetParam<configApi.p.anonSenderInvites.List>;
76
- export declare type SetAnonSenderInvites = SetParam<configApi.p.anonSenderInvites.List>;
77
- export declare type EventsSink = MailEventsSink;
69
+ export type GetObj = (userId: string, msgId: string, objId: string, header: boolean, segsOffset: number, segsLimit: number | undefined) => Promise<ObjReader>;
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'>;
86
+ export type EventsSink = MailEventsSink;
78
87
  export interface Factory {
79
88
  exists: UserExists;
80
89
  allowedMaxMsgSize: AllowedMaxMsgSize;
@@ -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 declare 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,6 +1,6 @@
1
1
  import { Request as Req, SessionParams, Factory } from '../../lib-server/resources/sessions';
2
- export declare type SessionsFactory = Factory<SessionParams>;
3
- export declare type Request = Req<SessionParams>;
2
+ export type SessionsFactory = Factory<SessionParams>;
3
+ export type Request = Req<SessionParams>;
4
4
  /**
5
5
  * This returns factory, that works properly in a single process application,
6
6
  * clearing up sessions that past given timeout.
@@ -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,6 +1,6 @@
1
1
  import { RequestHandler } from 'express';
2
2
  import { SignedLoad } from '../../../lib-common/jwkeys';
3
- export declare type IMidAuthorizer = (rpDomain: string, sessionId: string, userId: string, mailerIdAssertion: SignedLoad, userCert: SignedLoad, provCert: SignedLoad) => Promise<boolean>;
3
+ export type IMidAuthorizer = (rpDomain: string, sessionId: string, userId: string, mailerIdAssertion: SignedLoad, userCert: SignedLoad, provCert: SignedLoad) => Promise<boolean>;
4
4
  /**
5
5
  * This creates an authorize-sender route handler.
6
6
  * @param relyingPartyDomain at which this service operates, as seen by client
@@ -1,7 +1,7 @@
1
1
  import { RequestHandler } from 'express';
2
2
  import { GenerateSession } from '../../resources/delivery-sessions';
3
3
  import { AllowedMaxMsgSize } from '../../resources/recipients';
4
- export declare type Redirect = (userId: string) => Promise<string>;
4
+ export type Redirect = (userId: string) => Promise<string>;
5
5
  /**
6
6
  * This creates a start-session route handler.
7
7
  * @param allowedMsgSizeFunc is a function returning promises, that may resolve to
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { ServerOptions } from "https";
3
- export declare type CertsUpdateListener = (newOpts: ServerOptions, originalOpts: ServerOptions) => Promise<void>;
3
+ export type CertsUpdateListener = (newOpts: ServerOptions, originalOpts: ServerOptions) => Promise<void>;
4
4
  export declare function sslOptsFromConfig(letsencrypt: string | undefined, sslOpts: ServerOptions | undefined, skipReloadOnCertsChange: boolean | undefined): {
5
5
  sslOpts: ServerOptions;
6
6
  onCertsUpdate?: (listener: CertsUpdateListener) => (() => void);
@@ -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");
@@ -129,4 +129,5 @@ async function readAllSignupTokens(rootFolder) {
129
129
  return { multiUserTokens, singleUserTokens };
130
130
  }
131
131
  exports.readAllSignupTokens = readAllSignupTokens;
132
+ // XXX external qrencode command can be used to display QR code
132
133
  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.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);