core-3nweb-client-lib 0.34.2 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/build/api-defs/asmail.d.ts +70 -5
  2. package/build/api-defs/common-caps.d.ts +3 -0
  3. package/build/api-defs/keys.d.ts +154 -0
  4. package/build/api-defs/mailerid.d.ts +8 -0
  5. package/build/api-defs/web3n.d.ts +1 -0
  6. package/build/core/asmail/asmail-cap-ipc.js +20 -1
  7. package/build/core/asmail/config.d.ts +16 -0
  8. package/build/core/asmail/config.js +43 -0
  9. package/build/core/asmail/delivery/common.d.ts +2 -2
  10. package/build/core/asmail/delivery/common.js +2 -1
  11. package/build/core/asmail/delivery/index.d.ts +2 -1
  12. package/build/core/asmail/delivery/index.js +4 -1
  13. package/build/core/asmail/delivery/per-recipient-wip.js +1 -1
  14. package/build/core/asmail/inbox/attachments/fs.d.ts +1 -1
  15. package/build/core/asmail/inbox/attachments/fs.js +2 -2
  16. package/build/core/asmail/inbox/index.d.ts +6 -6
  17. package/build/core/asmail/inbox/index.js +1 -1
  18. package/build/core/asmail/inbox/msg-indexing/index.d.ts +1 -1
  19. package/build/core/asmail/inbox/msg-indexing/logs-n-entries.d.ts +1 -1
  20. package/build/core/asmail/index.d.ts +4 -4
  21. package/build/core/asmail/index.js +11 -22
  22. package/build/core/asmail/key-verification.d.ts +5 -4
  23. package/build/core/asmail/key-verification.js +2 -1
  24. package/build/core/asmail/msg/common.d.ts +5 -4
  25. package/build/core/asmail/msg/opener.d.ts +4 -4
  26. package/build/core/asmail/msg/opener.js +1 -1
  27. package/build/core/asmail/msg/packer.d.ts +3 -3
  28. package/build/core/asmail/msg/packer.js +2 -2
  29. package/build/core/asmail/sending-params/index.d.ts +7 -6
  30. package/build/core/asmail/sending-params/index.js +21 -12
  31. package/build/core/asmail/sending-params/invitations-anon.d.ts +35 -0
  32. package/build/core/asmail/sending-params/invitations-anon.js +164 -0
  33. package/build/core/asmail/sending-params/own-params.d.ts +10 -19
  34. package/build/core/asmail/sending-params/own-params.js +27 -20
  35. package/build/core/asmail/sending-params/params-from-others.d.ts +7 -11
  36. package/build/core/asmail/sending-params/params-from-others.js +32 -23
  37. package/build/core/id-manager/index.d.ts +1 -1
  38. package/build/core/id-manager/key-storage.d.ts +1 -1
  39. package/build/core/index.d.ts +3 -0
  40. package/build/core/index.js +39 -11
  41. package/build/core/{asmail/keyring → keyring}/common.d.ts +3 -1
  42. package/build/core/{asmail/keyring → keyring}/common.js +2 -2
  43. package/build/core/{asmail/keyring → keyring}/correspondent-keys.d.ts +5 -3
  44. package/build/core/{asmail/keyring → keyring}/correspondent-keys.js +5 -5
  45. package/build/core/keyring/index.d.ts +72 -0
  46. package/build/core/{asmail/keyring → keyring}/index.js +68 -59
  47. package/build/core/{asmail/keyring → keyring}/keyring-storage.js +1 -1
  48. package/build/core/keyring/keyrings-cap-ipc.d.ts +5 -0
  49. package/build/core/keyring/keyrings-cap-ipc.js +50 -0
  50. package/build/core/keyring/published-intro-key.d.ts +43 -0
  51. package/build/core/keyring/published-intro-key.js +176 -0
  52. package/build/core/startup/sign-up.d.ts +1 -1
  53. package/build/core/storage/common/constants.d.ts +4 -0
  54. package/build/core/storage/common/constants.js +24 -0
  55. package/build/core/storage/common/obj-info-file.js +1 -1
  56. package/build/core/storage/index.d.ts +7 -1
  57. package/build/core/storage/index.js +33 -3
  58. package/build/core/storage/local/obj-files.d.ts +1 -1
  59. package/build/core/storage/local/obj-status.d.ts +1 -1
  60. package/build/core/storage/local/obj-status.js +1 -1
  61. package/build/core/storage/local/storage.d.ts +1 -1
  62. package/build/core/storage/local/storage.js +2 -2
  63. package/build/core/storage/synced/downloader.d.ts +2 -2
  64. package/build/core/storage/synced/obj-files.d.ts +3 -3
  65. package/build/core/storage/synced/obj-files.js +1 -1
  66. package/build/core/storage/synced/obj-status.d.ts +1 -1
  67. package/build/core/storage/synced/obj-status.js +1 -1
  68. package/build/core/storage/synced/remote-events.d.ts +2 -2
  69. package/build/core/storage/synced/storage.d.ts +2 -2
  70. package/build/core/storage/synced/storage.js +5 -5
  71. package/build/core/storage/synced/upload-header-file.d.ts +1 -1
  72. package/build/core/storage/synced/upsyncer.d.ts +1 -1
  73. package/build/core/storage/synced/upsyncer.js +1 -1
  74. package/build/core-ipc/common-caps.js +4 -0
  75. package/build/lib-client/3nstorage/{service.d.ts → storage-owner.d.ts} +1 -4
  76. package/build/lib-client/3nstorage/{service.js → storage-owner.js} +21 -25
  77. package/build/lib-client/asmail/recipient.d.ts +0 -3
  78. package/build/lib-client/asmail/recipient.js +19 -17
  79. package/build/lib-client/asmail/service-config.d.ts +9 -5
  80. package/build/lib-client/asmail/service-config.js +42 -17
  81. package/build/lib-client/cryptor/cryptor-in-worker.js +1 -1
  82. package/build/lib-client/cryptor/in-proc-js.js +1 -1
  83. package/build/lib-client/cryptor/in-proc-wasm.js +1 -1
  84. package/build/lib-client/fs-utils/fs-sync-utils.js +1 -1
  85. package/build/lib-client/key-derivation.d.ts +2 -1
  86. package/build/lib-client/objs-on-disk/obj-folders.d.ts +1 -1
  87. package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +1 -1
  88. package/build/lib-client/request-utils.js +4 -2
  89. package/build/lib-client/service-locator.d.ts +2 -1
  90. package/build/lib-client/user-with-mid-session.d.ts +6 -5
  91. package/build/lib-client/user-with-mid-session.js +4 -4
  92. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/attrs.js +3 -3
  93. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/common.d.ts +2 -2
  94. package/build/lib-client/{3nstorage → xsp-fs}/exceptions.d.ts +1 -1
  95. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/file-node.d.ts +1 -1
  96. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/file-node.js +4 -4
  97. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/file.d.ts +1 -1
  98. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/file.js +5 -5
  99. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/folder-node-serialization.js +3 -3
  100. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/folder-node.d.ts +1 -1
  101. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/folder-node.js +9 -9
  102. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/fs.d.ts +1 -1
  103. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/fs.js +6 -6
  104. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/link-node.d.ts +1 -1
  105. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/link-node.js +2 -2
  106. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/node-in-fs.js +6 -6
  107. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/node-persistence.js +4 -4
  108. package/build/lib-client/{3nstorage → xsp-fs}/util/file-based-json.d.ts +10 -4
  109. package/build/lib-client/{3nstorage → xsp-fs}/util/file-based-json.js +33 -15
  110. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/xsp-payload-v1.js +3 -3
  111. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/xsp-payload-v2.js +5 -5
  112. package/build/lib-common/jwkeys.d.ts +6 -106
  113. package/build/lib-common/mid-sigs-NaCl-Ed.d.ts +4 -1
  114. package/build/lib-common/service-api/asmail/config.d.ts +9 -30
  115. package/build/lib-common/service-api/asmail/config.js +4 -1
  116. package/build/lib-common/service-api/asmail/delivery.d.ts +5 -12
  117. package/build/lib-common/service-api/asmail/delivery.js +3 -0
  118. package/build/lib-common/service-api/mailer-id/login.d.ts +3 -6
  119. package/build/lib-common/service-api/mailer-id/provisioning.d.ts +6 -7
  120. package/build/lib-common/service-api/mailer-id/provisioning.js +3 -0
  121. package/build/lib-common/user-admin-api/signup.d.ts +2 -1
  122. package/build/raw-3nweb-clients.d.ts +1 -1
  123. package/build/raw-3nweb-clients.js +2 -2
  124. package/package.json +2 -2
  125. package/build/core/asmail/config/common.d.ts +0 -24
  126. package/build/core/asmail/config/common.js +0 -87
  127. package/build/core/asmail/config/index.d.ts +0 -47
  128. package/build/core/asmail/config/index.js +0 -69
  129. package/build/core/asmail/config/invitations-anon.d.ts +0 -13
  130. package/build/core/asmail/config/invitations-anon.js +0 -99
  131. package/build/core/asmail/config/published-intro-key.d.ts +0 -17
  132. package/build/core/asmail/config/published-intro-key.js +0 -104
  133. package/build/core/asmail/keyring/index.d.ts +0 -36
  134. /package/build/core/{asmail/keyring → keyring}/id-to-email-map.d.ts +0 -0
  135. /package/build/core/{asmail/keyring → keyring}/id-to-email-map.js +0 -0
  136. /package/build/core/{asmail/keyring → keyring}/keyring-storage.d.ts +0 -0
  137. /package/build/lib-client/{cryptor-work-labels.d.ts → cryptor/cryptor-work-labels.d.ts} +0 -0
  138. /package/build/lib-client/{cryptor-work-labels.js → cryptor/cryptor-work-labels.js} +0 -0
  139. /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/attrs.d.ts +0 -0
  140. /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/common.js +0 -0
  141. /package/build/lib-client/{3nstorage → xsp-fs}/exceptions.js +0 -0
  142. /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/folder-node-serialization.d.ts +0 -0
  143. /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/node-in-fs.d.ts +0 -0
  144. /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/node-persistence.d.ts +0 -0
  145. /package/build/lib-client/{3nstorage → xsp-fs}/util/for-arrays.d.ts +0 -0
  146. /package/build/lib-client/{3nstorage → xsp-fs}/util/for-arrays.js +0 -0
  147. /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/xsp-payload-v1.d.ts +0 -0
  148. /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/xsp-payload-v2.d.ts +0 -0
@@ -1,8 +1,5 @@
1
- /**
2
- * This defines interfaces for mail delivery requests.
3
- */
4
- import * as jwk from '../../jwkeys';
5
- import * as config from './config';
1
+ type MailerIdAssertion = web3n.keys.MailerIdAssertion;
2
+ type PKeyCertChain = web3n.keys.PKeyCertChain;
6
3
  export declare const HTTP_HEADER: {
7
4
  contentType: string;
8
5
  contentLength: string;
@@ -77,11 +74,7 @@ export declare namespace sessionRestart {
77
74
  }
78
75
  export declare namespace authSender {
79
76
  const URL_END = "authorize-sender";
80
- interface Request {
81
- assertion: jwk.SignedLoad;
82
- userCert: jwk.SignedLoad;
83
- provCert: jwk.SignedLoad;
84
- }
77
+ type Request = MailerIdAssertion;
85
78
  const SC: {
86
79
  ok: number;
87
80
  authFailed: number;
@@ -89,8 +82,7 @@ export declare namespace authSender {
89
82
  }
90
83
  export declare namespace initPubKey {
91
84
  const URL_END = "init-pub-key";
92
- interface Reply extends config.p.initPubKey.Certs {
93
- }
85
+ type Reply = PKeyCertChain;
94
86
  const SC: {
95
87
  ok: number;
96
88
  pkeyNotRegistered: number;
@@ -156,3 +148,4 @@ export declare namespace completion {
156
148
  export interface ErrorReply {
157
149
  error: string;
158
150
  }
151
+ export {};
@@ -16,6 +16,9 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>. */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.completion = exports.msgObj = exports.msgMeta = exports.initPubKey = exports.authSender = exports.sessionRestart = exports.sessionStart = exports.preFlight = exports.ERR_SC = exports.HTTP_HEADER = void 0;
19
+ /**
20
+ * This defines interfaces for mail delivery requests.
21
+ */
19
22
  const querystring_1 = require("querystring");
20
23
  exports.HTTP_HEADER = {
21
24
  contentType: 'Content-Type',
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This defines request interfaces for mailerId-based login.
3
3
  */
4
- import * as jwk from '../../jwkeys';
4
+ type MailerIdAssertion = web3n.keys.MailerIdAssertion;
5
5
  export declare const ERR_SC: {
6
6
  duplicate: number;
7
7
  malformed: number;
@@ -28,11 +28,7 @@ export declare namespace startSession {
28
28
  export declare namespace authSession {
29
29
  const URL_END = "authorize-session";
30
30
  const method = "POST";
31
- interface Request {
32
- assertion: jwk.SignedLoad;
33
- userCert: jwk.SignedLoad;
34
- provCert: jwk.SignedLoad;
35
- }
31
+ type Request = MailerIdAssertion;
36
32
  const SC: {
37
33
  authFailed: number;
38
34
  ok: number;
@@ -41,3 +37,4 @@ export declare namespace authSession {
41
37
  export interface ErrorReply {
42
38
  error: string;
43
39
  }
40
+ export {};
@@ -1,7 +1,5 @@
1
- /**
2
- * This defines request interfaces for MailerId certificate provisioning.
3
- */
4
- import * as jwk from '../../jwkeys';
1
+ type SignedLoad = web3n.keys.SignedLoad;
2
+ type JsonKey = web3n.keys.JsonKey;
5
3
  export declare namespace pkl {
6
4
  const START_URL_END = "start-login-exchange";
7
5
  const COMPL_URL_END = "complete-login-exchange";
@@ -10,12 +8,12 @@ export declare namespace certify {
10
8
  const URL_END = "certify";
11
9
  const method = "POST";
12
10
  interface Request {
13
- pkey: jwk.JsonKey;
11
+ pkey: JsonKey;
14
12
  duration: number;
15
13
  }
16
14
  interface Reply {
17
- userCert: jwk.SignedLoad;
18
- provCert: jwk.SignedLoad;
15
+ userCert: SignedLoad;
16
+ provCert: SignedLoad;
19
17
  }
20
18
  const SC: {
21
19
  cryptoVerifFail: number;
@@ -23,3 +21,4 @@ export declare namespace certify {
23
21
  ok: number;
24
22
  };
25
23
  }
24
+ export {};
@@ -17,6 +17,9 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.certify = exports.pkl = void 0;
20
+ /**
21
+ * This defines request interfaces for MailerId certificate provisioning.
22
+ */
20
23
  const pklApi = require("../pub-key-login");
21
24
  var pkl;
22
25
  (function (pkl) {
@@ -2,7 +2,7 @@
2
2
  * This defines interface for signup to 3NWeb services, but it is not part of
3
3
  * 3NWeb utility protocols, like ASMail.
4
4
  */
5
- import { JsonKey } from '../jwkeys';
5
+ type JsonKey = web3n.keys.JsonKey;
6
6
  export declare const ERR_SC: {
7
7
  duplicate: number;
8
8
  malformed: number;
@@ -68,3 +68,4 @@ export declare namespace isActivated {
68
68
  export interface ErrorReply {
69
69
  error: string;
70
70
  }
71
+ export {};
@@ -1,4 +1,4 @@
1
- import { StorageOwner as StorageOwnerClient } from './lib-client/3nstorage/service';
1
+ import { StorageOwner as StorageOwnerClient } from './lib-client/3nstorage/storage-owner';
2
2
  import { MailRecipient as MailRecipientClient } from './lib-client/asmail/recipient';
3
3
  import { MailSender as MailSenderClient } from './lib-client/asmail/sender';
4
4
  import { MailerIdProvisioner as MailerIdProvisionerClient } from './lib-client/mailer-id/provisioner';
@@ -18,13 +18,13 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.serviceLocationFuncs = exports.MailerIdProvisioner = exports.signupFuncs = exports.MailSender = exports.MailRecipient = exports.StorageOwner = void 0;
20
20
  exports.getLibVersion = getLibVersion;
21
- const service_1 = require("./lib-client/3nstorage/service");
21
+ const storage_owner_1 = require("./lib-client/3nstorage/storage-owner");
22
22
  const recipient_1 = require("./lib-client/asmail/recipient");
23
23
  const sender_1 = require("./lib-client/asmail/sender");
24
24
  const provisioner_1 = require("./lib-client/mailer-id/provisioner");
25
25
  const signupClientFuncs = require("./lib-client/3nweb-signup");
26
26
  const srvLocFuncs = require("./lib-client/service-locator");
27
- exports.StorageOwner = service_1.StorageOwner;
27
+ exports.StorageOwner = storage_owner_1.StorageOwner;
28
28
  exports.MailRecipient = recipient_1.MailRecipient;
29
29
  exports.MailSender = sender_1.MailSender;
30
30
  exports.signupFuncs = signupClientFuncs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.34.2",
3
+ "version": "0.35.0",
4
4
  "description": "3NWeb client core library, embeddable into different environments",
5
5
  "main": "build/lib-index.js",
6
6
  "types": "build/lib-index.d.ts",
@@ -42,7 +42,7 @@
42
42
  "jasmine": "^3.9.0",
43
43
  "protobufjs-cli": "^1.0.2",
44
44
  "spec-3nweb-server": "^1.7.0",
45
- "tsuml2": "^0.6.1",
45
+ "tsuml2": "^0.17.1",
46
46
  "typescript": "^5.5.3"
47
47
  }
48
48
  }
@@ -1,24 +0,0 @@
1
- import { MailConfigurator } from '../../../lib-client/asmail/service-config';
2
- import { JsonFileProc } from '../../../lib-client/3nstorage/util/file-based-json';
3
- type WritableFile = web3n.files.WritableFile;
4
- type FileEvent = web3n.files.FileEvent;
5
- export declare abstract class ParamOnFileAndServer<TF, TS> extends JsonFileProc<TF> {
6
- private paramPath;
7
- private serviceConf;
8
- private changesProc;
9
- constructor(paramPath: string, serviceConf: MailConfigurator);
10
- start(file: WritableFile): Promise<void>;
11
- private absorbChangesFromFile;
12
- private syncServiceSetting;
13
- protected onFileEvent(ev: FileEvent): Promise<void>;
14
- /**
15
- * This function updates values on ASMail configuration server.
16
- * It also saves data to file, returning file's new version.
17
- */
18
- protected save(): Promise<number>;
19
- protected abstract setFromJSON(json: TF): void;
20
- protected abstract toFileJSON(): TF;
21
- protected abstract toServiceJSON(): TS;
22
- protected abstract initStruct(): Promise<void>;
23
- }
24
- export {};
@@ -1,87 +0,0 @@
1
- "use strict";
2
- /*
3
- Copyright (C) 2017 - 2018 3NSoft Inc.
4
-
5
- This program is free software: you can redistribute it and/or modify it under
6
- the terms of the GNU General Public License as published by the Free Software
7
- Foundation, either version 3 of the License, or (at your option) any later
8
- version.
9
-
10
- This program is distributed in the hope that it will be useful, but
11
- WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
- See the GNU General Public License for more details.
14
-
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/>. */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.ParamOnFileAndServer = void 0;
19
- const json_utils_1 = require("../../../lib-common/json-utils");
20
- const file_based_json_1 = require("../../../lib-client/3nstorage/util/file-based-json");
21
- const synced_1 = require("../../../lib-common/processes/synced");
22
- class ParamOnFileAndServer extends file_based_json_1.JsonFileProc {
23
- constructor(paramPath, serviceConf) {
24
- super();
25
- this.paramPath = paramPath;
26
- this.serviceConf = serviceConf;
27
- // XXX This should be done in a transactional style, with set on server
28
- // first. FolderNode with its base class is an example of transactional
29
- // mechanism implementation.
30
- this.changesProc = new synced_1.SingleProc();
31
- }
32
- async start(file) {
33
- await super.start(file, async () => {
34
- await this.initStruct();
35
- return this.toFileJSON();
36
- });
37
- await this.absorbChangesFromFile();
38
- await this.syncServiceSetting();
39
- }
40
- async absorbChangesFromFile() {
41
- const { json } = await this.get();
42
- this.setFromJSON(json);
43
- }
44
- async syncServiceSetting() {
45
- // XXX we may have the following bug here:
46
- // Device with older version of param gets to this point, and sets older
47
- // value.
48
- // To protect aginst this case, absorbing from file must ensure highest
49
- // synced version is read.
50
- const infoOnServer = await this.serviceConf.getParam(this.paramPath)
51
- .catch((exc) => {
52
- if (exc.type === 'http-connect') {
53
- return;
54
- }
55
- throw exc;
56
- });
57
- const currentVal = this.toServiceJSON();
58
- if (!(0, json_utils_1.deepEqual)(infoOnServer, currentVal)) {
59
- await this.serviceConf.setParam(this.paramPath, currentVal);
60
- }
61
- }
62
- async onFileEvent(ev) {
63
- if (ev.src === 'local') {
64
- return;
65
- }
66
- if (ev.type === 'removed') {
67
- throw new Error(`Unexpected removal of file with parameter ${this.paramPath}`);
68
- }
69
- if (ev.type !== 'file-change') {
70
- return;
71
- }
72
- await this.changesProc.startOrChain(() => this.absorbChangesFromFile());
73
- }
74
- /**
75
- * This function updates values on ASMail configuration server.
76
- * It also saves data to file, returning file's new version.
77
- */
78
- save() {
79
- return this.changesProc.startOrChain(async () => {
80
- await this.serviceConf.setParam(this.paramPath, this.toServiceJSON());
81
- const version = await super.save(this.toFileJSON());
82
- return version;
83
- });
84
- }
85
- }
86
- exports.ParamOnFileAndServer = ParamOnFileAndServer;
87
- Object.freeze(exports);
@@ -1,47 +0,0 @@
1
- import { ServiceLocator } from '../../../lib-client/service-locator';
2
- import { GetSigner } from '../../id-manager';
3
- import { MsgKeyRole } from '../keyring';
4
- import { JWKeyPair } from '../keyring/common';
5
- import { NetClient } from '../../../lib-client/request-utils';
6
- type WritableFS = web3n.files.WritableFS;
7
- /**
8
- * Instance of this class updates and checks setting of ASMail server.
9
- */
10
- export declare class ConfigOfASMailServer {
11
- private anonInvites;
12
- private publishedIntroKeys;
13
- anonSenderInvites: {
14
- getAll: () => Map<string, {
15
- invite: string;
16
- msgMaxSize: number;
17
- }>;
18
- create: (label: string, msgMaxSize: number) => Promise<string>;
19
- setMsgMaxSize: (label: string, msgMaxSize: number) => Promise<void>;
20
- };
21
- publishedKeys: {
22
- /**
23
- * This generates a new NaCl's box key pair, as a new introductory
24
- * published key.
25
- */
26
- update: () => Promise<void>;
27
- /**
28
- * This looks for a published key with a given key id. If it is found, an
29
- * object is returned with following fields:
30
- * - pair is JWK key pair;
31
- * - role of a found key pair;
32
- * - replacedAt field is present for a previously published key pair,
33
- * telling, in milliseconds, when this key was superseded a newer one.
34
- * Undefined is returned, when a key is not found.
35
- * @param kid
36
- * @return if key is found, object with following fields is returned:
37
- */
38
- find: (kid: string) => {
39
- role: MsgKeyRole;
40
- pair: JWKeyPair;
41
- replacedAt?: number;
42
- } | undefined;
43
- };
44
- private constructor();
45
- static makeAndStart(address: string, getSigner: GetSigner, resolver: ServiceLocator, net: NetClient, fs: WritableFS): Promise<ConfigOfASMailServer>;
46
- }
47
- export {};
@@ -1,69 +0,0 @@
1
- "use strict";
2
- /*
3
- Copyright (C) 2015 - 2018, 2021 3NSoft Inc.
4
-
5
- This program is free software: you can redistribute it and/or modify it under
6
- the terms of the GNU General Public License as published by the Free Software
7
- Foundation, either version 3 of the License, or (at your option) any later
8
- version.
9
-
10
- This program is distributed in the hope that it will be useful, but
11
- WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
- See the GNU General Public License for more details.
14
-
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/>.
17
- */
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.ConfigOfASMailServer = void 0;
20
- const service_config_1 = require("../../../lib-client/asmail/service-config");
21
- const file_1 = require("../../../lib-common/exceptions/file");
22
- const error_1 = require("../../../lib-common/exceptions/error");
23
- const invitations_anon_1 = require("./invitations-anon");
24
- const published_intro_key_1 = require("./published-intro-key");
25
- const ANON_SENDER_INVITES_FILE = 'anonymous/invites.json';
26
- const INTRO_KEY_FILE = 'introductory-key.json';
27
- /**
28
- * Instance of this class updates and checks setting of ASMail server.
29
- */
30
- class ConfigOfASMailServer {
31
- constructor(address, getSigner, resolver, net) {
32
- const serviceConf = new service_config_1.MailConfigurator(address, getSigner, () => resolver(serviceConf.userId), net);
33
- this.anonInvites = (0, invitations_anon_1.makeInvites)(serviceConf);
34
- this.publishedIntroKeys = (0, published_intro_key_1.makePublishedIntroKey)(getSigner, serviceConf);
35
- this.anonSenderInvites = {
36
- getAll: this.anonInvites.getAll,
37
- create: this.anonInvites.create,
38
- setMsgMaxSize: this.anonInvites.setMsgMaxSize
39
- };
40
- Object.freeze(this.anonSenderInvites);
41
- this.publishedKeys = {
42
- update: this.publishedIntroKeys.update,
43
- find: this.publishedIntroKeys.find
44
- };
45
- Object.freeze(this.publishedKeys);
46
- Object.freeze(this);
47
- }
48
- static async makeAndStart(address, getSigner, resolver, net, fs) {
49
- try {
50
- (0, file_1.ensureCorrectFS)(fs, 'synced', true);
51
- const conf = new ConfigOfASMailServer(address, getSigner, resolver, net);
52
- await Promise.all([
53
- fs.writableFile(ANON_SENDER_INVITES_FILE)
54
- .then(f => conf.anonInvites.start(f)),
55
- fs.writableFile(INTRO_KEY_FILE)
56
- .then(f => conf.publishedIntroKeys.start(f)),
57
- ]);
58
- await fs.close();
59
- return conf;
60
- }
61
- catch (err) {
62
- throw (0, error_1.errWithCause)(err, 'Failed to initialize ConfigOfASMailServer');
63
- }
64
- }
65
- }
66
- exports.ConfigOfASMailServer = ConfigOfASMailServer;
67
- Object.freeze(ConfigOfASMailServer.prototype);
68
- Object.freeze(ConfigOfASMailServer);
69
- Object.freeze(exports);
@@ -1,13 +0,0 @@
1
- import { MailConfigurator } from '../../../lib-client/asmail/service-config';
2
- type WritableFile = web3n.files.WritableFile;
3
- export interface Invites {
4
- getAll: () => Map<string, {
5
- invite: string;
6
- msgMaxSize: number;
7
- }>;
8
- create: (label: string, msgMaxSize: number) => Promise<string>;
9
- setMsgMaxSize: (label: string, msgMaxSize: number) => Promise<void>;
10
- start: (file: WritableFile) => Promise<void>;
11
- }
12
- export declare function makeInvites(serviceConf: MailConfigurator): Invites;
13
- export {};
@@ -1,99 +0,0 @@
1
- "use strict";
2
- /*
3
- Copyright (C) 2015 - 2018 3NSoft Inc.
4
-
5
- This program is free software: you can redistribute it and/or modify it under
6
- the terms of the GNU General Public License as published by the Free Software
7
- Foundation, either version 3 of the License, or (at your option) any later
8
- version.
9
-
10
- This program is distributed in the hope that it will be useful, but
11
- WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
- See the GNU General Public License for more details.
14
-
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/>. */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.makeInvites = makeInvites;
19
- const random = require("../../../lib-common/random-node");
20
- const api = require("../../../lib-common/service-api/asmail/config");
21
- const common_1 = require("./common");
22
- const INVITE_TOKEN_LEN = 40;
23
- function makeInvites(serviceConf) {
24
- const invites = new InvitesData(serviceConf);
25
- return {
26
- create: invites.create.bind(invites),
27
- getAll: invites.getAll.bind(invites),
28
- setMsgMaxSize: invites.setMsgMaxSize.bind(invites),
29
- start: invites.start.bind(invites)
30
- };
31
- }
32
- class InvitesData extends common_1.ParamOnFileAndServer {
33
- constructor(serviceConf) {
34
- super(api.p.anonSenderInvites.URL_END, serviceConf);
35
- this.invites = {};
36
- Object.seal(this);
37
- }
38
- async initStruct() { }
39
- setFromJSON(json) {
40
- this.invites = json.invites;
41
- }
42
- toFileJSON() {
43
- return {
44
- invites: this.invites
45
- };
46
- }
47
- toServiceJSON() {
48
- const serverJSON = {};
49
- Object.entries(this.invites)
50
- .forEach(([invite, params]) => {
51
- serverJSON[invite] = params.msgMaxSize;
52
- });
53
- return serverJSON;
54
- }
55
- getAll() {
56
- const byLabel = new Map();
57
- Object.entries(this.invites)
58
- .forEach(([invite, params]) => {
59
- byLabel.set(params.label, { invite, msgMaxSize: params.msgMaxSize });
60
- });
61
- return byLabel;
62
- }
63
- ;
64
- async create(label, msgMaxSize) {
65
- const existingInvite = this.findByLabel(label);
66
- if (existingInvite) {
67
- throw new Error(`Anonymous sender invite already exists with label ${label}`);
68
- }
69
- const invite = await this.generateNewRandomInvite();
70
- this.invites[invite] = { label, msgMaxSize };
71
- await this.save();
72
- return invite;
73
- }
74
- ;
75
- async generateNewRandomInvite() {
76
- let invite;
77
- do {
78
- invite = await random.stringOfB64Chars(INVITE_TOKEN_LEN);
79
- } while (this.invites[invite]);
80
- return invite;
81
- }
82
- findByLabel(label) {
83
- const found = Object.entries(this.invites)
84
- .find(([_, params]) => (params.label === label));
85
- return (found ? found[0] : undefined);
86
- }
87
- async setMsgMaxSize(label, msgMaxSize) {
88
- const invite = this.findByLabel(label);
89
- if (!invite) {
90
- throw new Error(`There is no anonymous sender invite with label ${label}`);
91
- }
92
- this.invites[invite].msgMaxSize = msgMaxSize;
93
- await this.save();
94
- }
95
- ;
96
- }
97
- Object.freeze(InvitesData.prototype);
98
- Object.freeze(InvitesData);
99
- Object.freeze(exports);
@@ -1,17 +0,0 @@
1
- import { MailConfigurator } from '../../../lib-client/asmail/service-config';
2
- import * as api from '../../../lib-common/service-api/asmail/config';
3
- import { GetSigner } from '../../id-manager';
4
- import { JWKeyPair, MsgKeyRole } from '../keyring/common';
5
- type WritableFile = web3n.files.WritableFile;
6
- export type Certs = api.p.initPubKey.Certs;
7
- export interface PublishedIntroKey {
8
- update: () => Promise<void>;
9
- find: (kid: string) => {
10
- role: MsgKeyRole;
11
- pair: JWKeyPair;
12
- replacedAt?: number;
13
- } | undefined;
14
- start: (file: WritableFile) => Promise<void>;
15
- }
16
- export declare function makePublishedIntroKey(getSigner: GetSigner, serviceConf: MailConfigurator): PublishedIntroKey;
17
- export {};
@@ -1,104 +0,0 @@
1
- "use strict";
2
- /*
3
- Copyright (C) 2015 - 2018 3NSoft Inc.
4
-
5
- This program is free software: you can redistribute it and/or modify it under
6
- the terms of the GNU General Public License as published by the Free Software
7
- Foundation, either version 3 of the License, or (at your option) any later
8
- version.
9
-
10
- This program is distributed in the hope that it will be useful, but
11
- WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
- See the GNU General Public License for more details.
14
-
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/>. */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.makePublishedIntroKey = makePublishedIntroKey;
19
- const api = require("../../../lib-common/service-api/asmail/config");
20
- const common_1 = require("../keyring/common");
21
- const common_2 = require("./common");
22
- const INTRO_KEY_VALIDITY = 31 * 24 * 60 * 60;
23
- function makePublishedIntroKey(getSigner, serviceConf) {
24
- const published = new PublishedKey(getSigner, serviceConf);
25
- return {
26
- find: published.find.bind(published),
27
- update: published.update.bind(published),
28
- start: published.start.bind(published)
29
- };
30
- }
31
- class PublishedKey extends common_2.ParamOnFileAndServer {
32
- constructor(getSigner, serviceConf) {
33
- super(api.p.initPubKey.URL_END, serviceConf);
34
- this.getSigner = getSigner;
35
- this.published = undefined;
36
- Object.seal(this);
37
- }
38
- async initStruct() {
39
- const newPair = await this.makeNewIntroKey();
40
- this.published = {
41
- current: {
42
- keyPair: newPair.pair,
43
- certs: newPair.certs
44
- }
45
- };
46
- }
47
- setFromJSON(json) {
48
- this.published = json;
49
- }
50
- toFileJSON() {
51
- return this.published;
52
- }
53
- toServiceJSON() {
54
- return this.published.current.certs;
55
- }
56
- async makeNewIntroKey() {
57
- const signer = await this.getSigner();
58
- const pair = await (0, common_1.generateKeyPair)();
59
- const certs = {
60
- pkeyCert: signer.certifyPublicKey(pair.pkey, INTRO_KEY_VALIDITY),
61
- userCert: signer.userCert,
62
- provCert: signer.providerCert
63
- };
64
- pair.createdAt = Date.now();
65
- return { pair, certs };
66
- }
67
- async update() {
68
- const newKey = await this.makeNewIntroKey();
69
- if (this.published.current) {
70
- this.published.current.keyPair.retiredAt = newKey.pair.createdAt;
71
- this.published.previous = this.published.current.keyPair;
72
- }
73
- this.published.current = {
74
- keyPair: newKey.pair,
75
- certs: newKey.certs
76
- };
77
- await this.save();
78
- }
79
- ;
80
- find(kid) {
81
- // check current key
82
- if (this.published.current
83
- && (this.published.current.keyPair.skey.kid === kid)) {
84
- return {
85
- role: 'published_intro',
86
- pair: this.published.current.keyPair
87
- };
88
- }
89
- // check previous key
90
- if (this.published.previous
91
- && (this.published.previous.skey.kid === kid)) {
92
- return {
93
- role: 'prev_published_intro',
94
- pair: this.published.previous,
95
- replacedAt: this.published.previous.retiredAt
96
- };
97
- }
98
- // if nothing found, explicitly return undefined
99
- return;
100
- }
101
- }
102
- Object.freeze(PublishedKey.prototype);
103
- Object.freeze(PublishedKey);
104
- Object.freeze(exports);