core-3nweb-client-lib 0.34.2 → 0.35.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) 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 +54 -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 +64 -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 +197 -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 +5 -1
  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/cryptor-wasm.js +1 -1
  83. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  84. package/build/lib-client/cryptor/in-proc-js.js +1 -1
  85. package/build/lib-client/cryptor/in-proc-wasm.js +1 -1
  86. package/build/lib-client/fs-utils/fs-sync-utils.js +1 -1
  87. package/build/lib-client/key-derivation.d.ts +2 -1
  88. package/build/lib-client/objs-on-disk/obj-folders.d.ts +1 -1
  89. package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +1 -1
  90. package/build/lib-client/request-utils.js +4 -2
  91. package/build/lib-client/service-locator.d.ts +2 -1
  92. package/build/lib-client/user-with-mid-session.d.ts +6 -5
  93. package/build/lib-client/user-with-mid-session.js +4 -4
  94. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/attrs.js +3 -3
  95. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/common.d.ts +2 -2
  96. package/build/lib-client/{3nstorage → xsp-fs}/exceptions.d.ts +1 -1
  97. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/file-node.d.ts +1 -1
  98. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/file-node.js +4 -4
  99. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/file.d.ts +1 -1
  100. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/file.js +5 -5
  101. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/folder-node-serialization.js +3 -3
  102. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/folder-node.d.ts +1 -1
  103. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/folder-node.js +9 -9
  104. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/fs.d.ts +1 -1
  105. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/fs.js +6 -6
  106. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/link-node.d.ts +1 -1
  107. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/link-node.js +2 -2
  108. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/node-in-fs.js +6 -6
  109. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/node-persistence.js +4 -4
  110. package/build/lib-client/{3nstorage → xsp-fs}/util/file-based-json.d.ts +10 -4
  111. package/build/lib-client/{3nstorage → xsp-fs}/util/file-based-json.js +33 -15
  112. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/xsp-payload-v1.js +3 -3
  113. package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/xsp-payload-v2.js +5 -5
  114. package/build/lib-common/jwkeys.d.ts +6 -106
  115. package/build/lib-common/mid-sigs-NaCl-Ed.d.ts +4 -1
  116. package/build/lib-common/service-api/asmail/config.d.ts +9 -30
  117. package/build/lib-common/service-api/asmail/config.js +6 -2
  118. package/build/lib-common/service-api/asmail/delivery.d.ts +5 -12
  119. package/build/lib-common/service-api/asmail/delivery.js +3 -0
  120. package/build/lib-common/service-api/mailer-id/login.d.ts +3 -6
  121. package/build/lib-common/service-api/mailer-id/provisioning.d.ts +6 -7
  122. package/build/lib-common/service-api/mailer-id/provisioning.js +3 -0
  123. package/build/lib-common/user-admin-api/signup.d.ts +2 -1
  124. package/build/raw-3nweb-clients.d.ts +1 -1
  125. package/build/raw-3nweb-clients.js +2 -2
  126. package/package.json +3 -3
  127. package/build/core/asmail/config/common.d.ts +0 -24
  128. package/build/core/asmail/config/common.js +0 -87
  129. package/build/core/asmail/config/index.d.ts +0 -47
  130. package/build/core/asmail/config/index.js +0 -69
  131. package/build/core/asmail/config/invitations-anon.d.ts +0 -13
  132. package/build/core/asmail/config/invitations-anon.js +0 -99
  133. package/build/core/asmail/config/published-intro-key.d.ts +0 -17
  134. package/build/core/asmail/config/published-intro-key.js +0 -104
  135. package/build/core/asmail/keyring/index.d.ts +0 -36
  136. /package/build/core/{asmail/keyring → keyring}/id-to-email-map.d.ts +0 -0
  137. /package/build/core/{asmail/keyring → keyring}/id-to-email-map.js +0 -0
  138. /package/build/core/{asmail/keyring → keyring}/keyring-storage.d.ts +0 -0
  139. /package/build/lib-client/{cryptor-work-labels.d.ts → cryptor/cryptor-work-labels.d.ts} +0 -0
  140. /package/build/lib-client/{cryptor-work-labels.js → cryptor/cryptor-work-labels.js} +0 -0
  141. /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/attrs.d.ts +0 -0
  142. /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/common.js +0 -0
  143. /package/build/lib-client/{3nstorage → xsp-fs}/exceptions.js +0 -0
  144. /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/folder-node-serialization.d.ts +0 -0
  145. /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/node-in-fs.d.ts +0 -0
  146. /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/node-persistence.d.ts +0 -0
  147. /package/build/lib-client/{3nstorage → xsp-fs}/util/for-arrays.d.ts +0 -0
  148. /package/build/lib-client/{3nstorage → xsp-fs}/util/for-arrays.js +0 -0
  149. /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/xsp-payload-v1.d.ts +0 -0
  150. /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/xsp-payload-v2.d.ts +0 -0
@@ -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);
@@ -1,36 +0,0 @@
1
- import { IdToEmailMap } from './id-to-email-map';
2
- import { MsgKeyRole } from './common';
3
- import { AsyncSBoxCryptor } from 'xsp-files';
4
- import { ConfigOfASMailServer } from '../config/index';
5
- import { ResourcesForSending } from '../delivery/common';
6
- import { ResourcesForReceiving } from '../inbox';
7
- export { KEY_USE, MsgKeyRole } from './common';
8
- export interface MsgKeyInfo {
9
- correspondent: string;
10
- key?: Uint8Array;
11
- /**
12
- * This is a current status of the key in this keyring.
13
- */
14
- keyStatus: MsgKeyRole;
15
- /**
16
- * Length of a key pack, in a main object's header start.
17
- * This length depends on algorithms, hence we cannot hard-wire it, but must
18
- * pass it this way, setting it according to key's nature.
19
- */
20
- msgKeyPackLen: number;
21
- }
22
- type WritableFS = web3n.files.WritableFS;
23
- type SendingResources = ResourcesForSending['correspondents'];
24
- type ReceptionResources = ResourcesForReceiving['correspondents'];
25
- export interface KeyRing {
26
- needIntroKeyFor: SendingResources['needIntroKeyFor'];
27
- generateKeysToSend: SendingResources['generateKeysToSend'];
28
- nextCrypto: SendingResources['nextCrypto'];
29
- decrypt: ReceptionResources['msgDecryptor'];
30
- close(): Promise<void>;
31
- }
32
- export declare function makeAndKeyRing(cryptor: AsyncSBoxCryptor, fs: WritableFS, publishedKeys: ConfigOfASMailServer['publishedKeys']): Promise<KeyRing>;
33
- export interface KeyPairsStorage {
34
- pairIdToEmailMap: IdToEmailMap;
35
- saveChanges: () => void;
36
- }