core-3nweb-client-lib 0.34.1 → 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.
- package/build/api-defs/asmail.d.ts +70 -5
- package/build/api-defs/common-caps.d.ts +3 -0
- package/build/api-defs/keys.d.ts +154 -0
- package/build/api-defs/mailerid.d.ts +8 -0
- package/build/api-defs/web3n.d.ts +1 -0
- package/build/core/asmail/asmail-cap-ipc.js +20 -1
- package/build/core/asmail/config.d.ts +16 -0
- package/build/core/asmail/config.js +43 -0
- package/build/core/asmail/delivery/common.d.ts +2 -2
- package/build/core/asmail/delivery/common.js +2 -1
- package/build/core/asmail/delivery/index.d.ts +2 -1
- package/build/core/asmail/delivery/index.js +4 -1
- package/build/core/asmail/delivery/per-recipient-wip.js +1 -1
- package/build/core/asmail/inbox/attachments/fs.d.ts +1 -1
- package/build/core/asmail/inbox/attachments/fs.js +2 -2
- package/build/core/asmail/inbox/index.d.ts +6 -6
- package/build/core/asmail/inbox/index.js +1 -1
- package/build/core/asmail/inbox/msg-indexing/index.d.ts +1 -1
- package/build/core/asmail/inbox/msg-indexing/logs-n-entries.d.ts +1 -1
- package/build/core/asmail/index.d.ts +4 -4
- package/build/core/asmail/index.js +11 -22
- package/build/core/asmail/key-verification.d.ts +5 -4
- package/build/core/asmail/key-verification.js +20 -10
- package/build/core/asmail/msg/common.d.ts +5 -4
- package/build/core/asmail/msg/opener.d.ts +4 -4
- package/build/core/asmail/msg/opener.js +1 -1
- package/build/core/asmail/msg/packer.d.ts +3 -3
- package/build/core/asmail/msg/packer.js +2 -2
- package/build/core/asmail/sending-params/index.d.ts +7 -6
- package/build/core/asmail/sending-params/index.js +21 -12
- package/build/core/asmail/sending-params/invitations-anon.d.ts +35 -0
- package/build/core/asmail/sending-params/invitations-anon.js +164 -0
- package/build/core/asmail/sending-params/own-params.d.ts +10 -19
- package/build/core/asmail/sending-params/own-params.js +27 -20
- package/build/core/asmail/sending-params/params-from-others.d.ts +7 -11
- package/build/core/asmail/sending-params/params-from-others.js +32 -23
- package/build/core/id-manager/index.d.ts +1 -1
- package/build/core/id-manager/key-storage.d.ts +1 -1
- package/build/core/index.d.ts +3 -0
- package/build/core/index.js +39 -11
- package/build/core/{asmail/keyring → keyring}/common.d.ts +3 -1
- package/build/core/{asmail/keyring → keyring}/common.js +2 -2
- package/build/core/{asmail/keyring → keyring}/correspondent-keys.d.ts +5 -3
- package/build/core/{asmail/keyring → keyring}/correspondent-keys.js +5 -5
- package/build/core/keyring/index.d.ts +72 -0
- package/build/core/{asmail/keyring → keyring}/index.js +68 -59
- package/build/core/{asmail/keyring → keyring}/keyring-storage.js +1 -1
- package/build/core/keyring/keyrings-cap-ipc.d.ts +5 -0
- package/build/core/keyring/keyrings-cap-ipc.js +50 -0
- package/build/core/keyring/published-intro-key.d.ts +43 -0
- package/build/core/keyring/published-intro-key.js +176 -0
- package/build/core/startup/sign-up.d.ts +1 -1
- package/build/core/storage/common/constants.d.ts +4 -0
- package/build/core/storage/common/constants.js +24 -0
- package/build/core/storage/common/obj-info-file.js +1 -1
- package/build/core/storage/index.d.ts +7 -1
- package/build/core/storage/index.js +33 -3
- package/build/core/storage/local/obj-files.d.ts +1 -1
- package/build/core/storage/local/obj-status.d.ts +1 -1
- package/build/core/storage/local/obj-status.js +1 -1
- package/build/core/storage/local/storage.d.ts +1 -1
- package/build/core/storage/local/storage.js +2 -2
- package/build/core/storage/synced/downloader.d.ts +2 -2
- package/build/core/storage/synced/obj-files.d.ts +3 -3
- package/build/core/storage/synced/obj-files.js +1 -1
- package/build/core/storage/synced/obj-status.d.ts +1 -1
- package/build/core/storage/synced/obj-status.js +1 -1
- package/build/core/storage/synced/remote-events.d.ts +2 -2
- package/build/core/storage/synced/storage.d.ts +2 -2
- package/build/core/storage/synced/storage.js +5 -5
- package/build/core/storage/synced/upload-header-file.d.ts +1 -1
- package/build/core/storage/synced/upsyncer.d.ts +1 -1
- package/build/core/storage/synced/upsyncer.js +1 -1
- package/build/core-ipc/common-caps.js +4 -0
- package/build/lib-client/3nstorage/{service.d.ts → storage-owner.d.ts} +1 -4
- package/build/lib-client/3nstorage/{service.js → storage-owner.js} +21 -25
- package/build/lib-client/asmail/recipient.d.ts +0 -3
- package/build/lib-client/asmail/recipient.js +19 -17
- package/build/lib-client/asmail/service-config.d.ts +9 -5
- package/build/lib-client/asmail/service-config.js +42 -17
- package/build/lib-client/cryptor/cryptor-in-worker.js +1 -1
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/cryptor/in-proc-js.js +1 -1
- package/build/lib-client/cryptor/in-proc-wasm.js +1 -1
- package/build/lib-client/fs-utils/fs-sync-utils.js +1 -1
- package/build/lib-client/key-derivation.d.ts +2 -1
- package/build/lib-client/objs-on-disk/obj-folders.d.ts +1 -1
- package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +1 -1
- package/build/lib-client/request-utils.js +4 -2
- package/build/lib-client/service-locator.d.ts +2 -1
- package/build/lib-client/user-with-mid-session.d.ts +6 -5
- package/build/lib-client/user-with-mid-session.js +4 -4
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/attrs.js +3 -3
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/common.d.ts +2 -2
- package/build/lib-client/{3nstorage → xsp-fs}/exceptions.d.ts +1 -1
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/file-node.d.ts +1 -1
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/file-node.js +4 -4
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/file.d.ts +1 -1
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/file.js +5 -5
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/folder-node-serialization.js +3 -3
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/folder-node.d.ts +1 -1
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/folder-node.js +9 -9
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/fs.d.ts +1 -1
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/fs.js +6 -6
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/link-node.d.ts +1 -1
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/link-node.js +2 -2
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/node-in-fs.js +6 -6
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/node-persistence.js +4 -4
- package/build/lib-client/{3nstorage → xsp-fs}/util/file-based-json.d.ts +10 -4
- package/build/lib-client/{3nstorage → xsp-fs}/util/file-based-json.js +33 -15
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/xsp-payload-v1.js +3 -3
- package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/xsp-payload-v2.js +5 -5
- package/build/lib-common/jwkeys.d.ts +6 -106
- package/build/lib-common/jwkeys.js +4 -6
- package/build/lib-common/mid-sigs-NaCl-Ed.d.ts +4 -1
- package/build/lib-common/service-api/asmail/config.d.ts +9 -30
- package/build/lib-common/service-api/asmail/config.js +4 -1
- package/build/lib-common/service-api/asmail/delivery.d.ts +5 -12
- package/build/lib-common/service-api/asmail/delivery.js +3 -0
- package/build/lib-common/service-api/mailer-id/login.d.ts +3 -6
- package/build/lib-common/service-api/mailer-id/provisioning.d.ts +6 -7
- package/build/lib-common/service-api/mailer-id/provisioning.js +3 -0
- package/build/lib-common/user-admin-api/signup.d.ts +2 -1
- package/build/raw-3nweb-clients.d.ts +1 -1
- package/build/raw-3nweb-clients.js +2 -2
- package/package.json +2 -2
- package/build/core/asmail/config/common.d.ts +0 -24
- package/build/core/asmail/config/common.js +0 -87
- package/build/core/asmail/config/index.d.ts +0 -47
- package/build/core/asmail/config/index.js +0 -69
- package/build/core/asmail/config/invitations-anon.d.ts +0 -13
- package/build/core/asmail/config/invitations-anon.js +0 -99
- package/build/core/asmail/config/published-intro-key.d.ts +0 -17
- package/build/core/asmail/config/published-intro-key.js +0 -104
- package/build/core/asmail/keyring/index.d.ts +0 -36
- /package/build/core/{asmail/keyring → keyring}/id-to-email-map.d.ts +0 -0
- /package/build/core/{asmail/keyring → keyring}/id-to-email-map.js +0 -0
- /package/build/core/{asmail/keyring → keyring}/keyring-storage.d.ts +0 -0
- /package/build/lib-client/{cryptor-work-labels.d.ts → cryptor/cryptor-work-labels.d.ts} +0 -0
- /package/build/lib-client/{cryptor-work-labels.js → cryptor/cryptor-work-labels.js} +0 -0
- /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/attrs.d.ts +0 -0
- /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/common.js +0 -0
- /package/build/lib-client/{3nstorage → xsp-fs}/exceptions.js +0 -0
- /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/folder-node-serialization.d.ts +0 -0
- /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/node-in-fs.d.ts +0 -0
- /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/node-persistence.d.ts +0 -0
- /package/build/lib-client/{3nstorage → xsp-fs}/util/for-arrays.d.ts +0 -0
- /package/build/lib-client/{3nstorage → xsp-fs}/util/for-arrays.js +0 -0
- /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/xsp-payload-v1.d.ts +0 -0
- /package/build/lib-client/{3nstorage/xsp-fs → xsp-fs}/xsp-payload-v2.d.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2017 - 2018 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2017 - 2018, 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
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.OwnSendingParams = void 0;
|
|
19
|
-
const file_based_json_1 = require("../../../lib-client/
|
|
20
|
-
const synced_1 = require("../../../lib-common/processes/synced");
|
|
20
|
+
const file_based_json_1 = require("../../../lib-client/xsp-fs/util/file-based-json");
|
|
21
21
|
const json_utils_1 = require("../../../lib-common/json-utils");
|
|
22
22
|
const DEFAULT_INVITE_LABEL = 'Default';
|
|
23
23
|
const DEFAULT_INVITE_MAX_MSG_SIZE = 1024 * 1024 * 1024;
|
|
@@ -27,13 +27,11 @@ const DEFAULT_INVITE_MAX_MSG_SIZE = 1024 * 1024 * 1024;
|
|
|
27
27
|
* invitation tokens, and this class uses config service to register tokens on
|
|
28
28
|
* a server.
|
|
29
29
|
*/
|
|
30
|
-
class OwnSendingParams
|
|
30
|
+
class OwnSendingParams {
|
|
31
31
|
constructor(anonInvites) {
|
|
32
|
-
super();
|
|
33
32
|
this.anonInvites = anonInvites;
|
|
34
33
|
this.params = new Map();
|
|
35
34
|
this.defaultParams = undefined;
|
|
36
|
-
this.changesProc = new synced_1.SingleProc();
|
|
37
35
|
this.getFor = async (address) => {
|
|
38
36
|
let p = this.params.get(address);
|
|
39
37
|
if (p) {
|
|
@@ -55,11 +53,11 @@ class OwnSendingParams extends file_based_json_1.JsonFileProc {
|
|
|
55
53
|
};
|
|
56
54
|
p.suggested.timestamp = Date.now();
|
|
57
55
|
this.params.set(p.address, p);
|
|
58
|
-
await this.
|
|
56
|
+
await this.fileProc.order.startOrChain(() => this.persist());
|
|
59
57
|
return p.suggested;
|
|
60
58
|
};
|
|
61
59
|
this.setAsInUse = async (address, invite) => {
|
|
62
|
-
await this.
|
|
60
|
+
await this.fileProc.order.startOrChain(async () => {
|
|
63
61
|
const p = this.params.get(address);
|
|
64
62
|
if (!p || !p.suggested) {
|
|
65
63
|
return;
|
|
@@ -72,17 +70,20 @@ class OwnSendingParams extends file_based_json_1.JsonFileProc {
|
|
|
72
70
|
await this.persist();
|
|
73
71
|
});
|
|
74
72
|
};
|
|
73
|
+
this.fileProc = new file_based_json_1.JsonFileProc(this.onFileEvent.bind(this));
|
|
75
74
|
Object.seal(this);
|
|
76
75
|
}
|
|
77
|
-
async
|
|
78
|
-
|
|
79
|
-
await
|
|
80
|
-
|
|
81
|
-
|
|
76
|
+
static async makeAndInit(file, anonInvites) {
|
|
77
|
+
const ownParams = new OwnSendingParams(anonInvites);
|
|
78
|
+
await ownParams.fileProc.start(file, () => ownParams.toFileJSON());
|
|
79
|
+
await ownParams.absorbChangesFromFile();
|
|
80
|
+
if (!ownParams.defaultParams) {
|
|
81
|
+
await ownParams.setDefaultParams();
|
|
82
82
|
}
|
|
83
|
+
return ownParams;
|
|
83
84
|
}
|
|
84
85
|
async setDefaultParams() {
|
|
85
|
-
await this.
|
|
86
|
+
await this.fileProc.order.startOrChain(async () => {
|
|
86
87
|
const invites = this.anonInvites.getAll();
|
|
87
88
|
const defaultInvite = invites.get(DEFAULT_INVITE_LABEL);
|
|
88
89
|
if (defaultInvite) {
|
|
@@ -101,15 +102,17 @@ class OwnSendingParams extends file_based_json_1.JsonFileProc {
|
|
|
101
102
|
await this.persist();
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
toFileJSON() {
|
|
106
|
+
return {
|
|
106
107
|
default: this.defaultParams,
|
|
107
108
|
senderSpecific: Array.from(this.params.values())
|
|
108
109
|
};
|
|
109
|
-
|
|
110
|
+
}
|
|
111
|
+
async persist() {
|
|
112
|
+
await this.fileProc.save(this.toFileJSON(), false);
|
|
110
113
|
}
|
|
111
114
|
async absorbChangesFromFile() {
|
|
112
|
-
const { json } = await this.get();
|
|
115
|
+
const { json } = await this.fileProc.get(false);
|
|
113
116
|
// we may add checks to json data
|
|
114
117
|
this.params.clear();
|
|
115
118
|
json.senderSpecific.forEach(p => this.params.set(p.address, p));
|
|
@@ -125,7 +128,11 @@ class OwnSendingParams extends file_based_json_1.JsonFileProc {
|
|
|
125
128
|
if (ev.type !== 'file-change') {
|
|
126
129
|
return;
|
|
127
130
|
}
|
|
128
|
-
await this.
|
|
131
|
+
await this.fileProc.order.startOrChain(() => this.absorbChangesFromFile());
|
|
132
|
+
}
|
|
133
|
+
async close() {
|
|
134
|
+
await this.anonInvites.close();
|
|
135
|
+
await this.fileProc.close();
|
|
129
136
|
}
|
|
130
137
|
}
|
|
131
138
|
exports.OwnSendingParams = OwnSendingParams;
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import { JsonFileProc } from '../../../lib-client/3nstorage/util/file-based-json';
|
|
2
|
-
import { SendingParams } from '../msg/common';
|
|
3
1
|
import { SendingParamsHolder } from '../sending-params';
|
|
4
2
|
export { SendingParams } from '../msg/common';
|
|
5
3
|
type ExposedFuncs = SendingParamsHolder['otherSides'];
|
|
6
4
|
type WritableFile = web3n.files.WritableFile;
|
|
7
5
|
type FileEvent = web3n.files.FileEvent;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
private
|
|
14
|
-
constructor();
|
|
15
|
-
start(file: WritableFile): Promise<void>;
|
|
16
|
-
private absorbChangesFromFile;
|
|
6
|
+
export declare class ParamsFromOthers {
|
|
7
|
+
private readonly params;
|
|
8
|
+
private readonly fileProc;
|
|
9
|
+
private constructor();
|
|
10
|
+
static makeAndInit(file: WritableFile): Promise<ParamsFromOthers>;
|
|
11
|
+
private absorbRemoteChanges;
|
|
17
12
|
protected onFileEvent(ev: FileEvent): Promise<void>;
|
|
18
13
|
getFor: ExposedFuncs['get'];
|
|
19
14
|
setFor: ExposedFuncs['set'];
|
|
20
15
|
private persist;
|
|
16
|
+
close(): Promise<void>;
|
|
21
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2017 - 2018 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2017 - 2018, 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
|
|
@@ -13,16 +13,14 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.ParamsFromOthers = void 0;
|
|
19
|
-
const file_based_json_1 = require("../../../lib-client/
|
|
20
|
-
|
|
21
|
-
class ParamsFromOthers extends file_based_json_1.JsonFileProc {
|
|
20
|
+
const file_based_json_1 = require("../../../lib-client/xsp-fs/util/file-based-json");
|
|
21
|
+
class ParamsFromOthers {
|
|
22
22
|
constructor() {
|
|
23
|
-
super();
|
|
24
23
|
this.params = new Map();
|
|
25
|
-
this.changesProc = new synced_1.SingleProc();
|
|
26
24
|
this.getFor = (address) => {
|
|
27
25
|
const p = this.params.get(address);
|
|
28
26
|
if (!p) {
|
|
@@ -31,7 +29,7 @@ class ParamsFromOthers extends file_based_json_1.JsonFileProc {
|
|
|
31
29
|
return copyParams(p);
|
|
32
30
|
};
|
|
33
31
|
this.setFor = (address, params) => {
|
|
34
|
-
return this.
|
|
32
|
+
return this.fileProc.order.startOrChain(async () => {
|
|
35
33
|
const existing = this.params.get(address);
|
|
36
34
|
if (existing && (existing.timestamp >= params.timestamp)) {
|
|
37
35
|
return;
|
|
@@ -42,33 +40,44 @@ class ParamsFromOthers extends file_based_json_1.JsonFileProc {
|
|
|
42
40
|
await this.persist();
|
|
43
41
|
});
|
|
44
42
|
};
|
|
43
|
+
this.fileProc = new file_based_json_1.JsonFileProc(this.onFileEvent.bind(this));
|
|
45
44
|
Object.seal(this);
|
|
46
45
|
}
|
|
47
|
-
async
|
|
48
|
-
|
|
49
|
-
await
|
|
46
|
+
static async makeAndInit(file) {
|
|
47
|
+
const paramsFromOthers = new ParamsFromOthers();
|
|
48
|
+
await paramsFromOthers.fileProc.start(file, []);
|
|
49
|
+
await paramsFromOthers.absorbRemoteChanges();
|
|
50
|
+
return paramsFromOthers;
|
|
50
51
|
}
|
|
51
|
-
async
|
|
52
|
-
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
async absorbRemoteChanges() {
|
|
53
|
+
// XXX
|
|
54
|
+
// - check for changes: what is needed here from fileProc, and what is
|
|
55
|
+
// generic in absorbing remote changes to refactor it into JsonFileProc
|
|
56
|
+
// - absorb and sync, if needed: what can be in JsonFileProc
|
|
57
|
+
// Code from pre-v.sync:
|
|
58
|
+
// const { json } = await this.fileProc.get();
|
|
59
|
+
// this.setFromJSON(json);
|
|
56
60
|
}
|
|
57
61
|
async onFileEvent(ev) {
|
|
58
62
|
if (ev.src === 'local') {
|
|
59
63
|
return;
|
|
60
64
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
switch (ev.type) {
|
|
66
|
+
case 'file-change':
|
|
67
|
+
await this.fileProc.order.startOrChain(() => this.absorbRemoteChanges());
|
|
68
|
+
break;
|
|
69
|
+
case 'removed':
|
|
70
|
+
throw new Error(`Unexpected removal of file with invites info`);
|
|
71
|
+
default:
|
|
72
|
+
return;
|
|
66
73
|
}
|
|
67
|
-
await this.changesProc.startOrChain(() => this.absorbChangesFromFile());
|
|
68
74
|
}
|
|
69
75
|
async persist() {
|
|
70
76
|
const json = Array.from(this.params.values());
|
|
71
|
-
await this.save(json);
|
|
77
|
+
await this.fileProc.save(json, false);
|
|
78
|
+
}
|
|
79
|
+
async close() {
|
|
80
|
+
await this.fileProc.close();
|
|
72
81
|
}
|
|
73
82
|
}
|
|
74
83
|
exports.ParamsFromOthers = ParamsFromOthers;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { user as mid } from '../../lib-common/mid-sigs-NaCl-Ed';
|
|
2
|
-
import { JsonKey } from '../../lib-common/jwkeys';
|
|
3
2
|
import { GenerateKey } from '../startup/sign-in';
|
|
4
3
|
import { LogError, LogWarning } from '../../lib-client/logging/log-to-file';
|
|
5
4
|
import { NetClient } from '../../lib-client/request-utils';
|
|
6
5
|
import { ServiceLocator } from '../../lib-client/service-locator';
|
|
6
|
+
type JsonKey = web3n.keys.JsonKey;
|
|
7
7
|
type WritableFS = web3n.files.WritableFS;
|
|
8
8
|
/**
|
|
9
9
|
* This function completes provisioning process, returning a promise, resolvable
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LogError, LogWarning } from "../../lib-client/logging/log-to-file";
|
|
2
|
-
import { JsonKey } from "../../lib-common/jwkeys";
|
|
3
2
|
type WritableFS = web3n.files.WritableFS;
|
|
3
|
+
type JsonKey = web3n.keys.JsonKey;
|
|
4
4
|
export interface LoginKeysJSON {
|
|
5
5
|
address: string;
|
|
6
6
|
keys: JsonKey[];
|
package/build/core/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare class Core {
|
|
|
18
18
|
private cryptor;
|
|
19
19
|
private storages;
|
|
20
20
|
private asmail;
|
|
21
|
+
private keyrings;
|
|
21
22
|
private idManager;
|
|
22
23
|
private isInitialized;
|
|
23
24
|
private closingProc;
|
|
@@ -36,11 +37,13 @@ export declare class Core {
|
|
|
36
37
|
};
|
|
37
38
|
private makeStorageCAP;
|
|
38
39
|
private makeMailCAP;
|
|
40
|
+
private makeKeyringsCAP;
|
|
39
41
|
private makeLogCAP;
|
|
40
42
|
private makeMailerIdCAP;
|
|
41
43
|
private closeBroadcast;
|
|
42
44
|
close$: import("rxjs").Observable<void>;
|
|
43
45
|
close(): Promise<void>;
|
|
46
|
+
private performDataMigrationsAtInit;
|
|
44
47
|
private initCore;
|
|
45
48
|
getStorages(): FactoryOfFSs;
|
|
46
49
|
}
|
package/build/core/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2022 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2022, 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
|
|
@@ -28,8 +28,9 @@ const rxjs_1 = require("rxjs");
|
|
|
28
28
|
const log_to_file_1 = require("../lib-client/logging/log-to-file");
|
|
29
29
|
const operators_1 = require("rxjs/operators");
|
|
30
30
|
const app_files_1 = require("./app-files");
|
|
31
|
-
const
|
|
32
|
-
const
|
|
31
|
+
const keyring_1 = require("./keyring");
|
|
32
|
+
const constants_1 = require("./storage/common/constants");
|
|
33
|
+
const config_1 = require("./asmail/config");
|
|
33
34
|
class Core {
|
|
34
35
|
constructor(makeNet, makeResolver, makeCryptor, appDirs, logger, signUpUrl) {
|
|
35
36
|
this.makeNet = makeNet;
|
|
@@ -58,7 +59,7 @@ class Core {
|
|
|
58
59
|
throw new Error(`Stores failed to initialize`);
|
|
59
60
|
}
|
|
60
61
|
// 3) give id manager fs, in which it will record labeled key(s)
|
|
61
|
-
await setupManagerStorage(await this.storages.makeSyncedFSForApp(MAILERID_APP_NAME), [u.midSKey.labeled]);
|
|
62
|
+
await setupManagerStorage(await this.storages.makeSyncedFSForApp(constants_1.MAILERID_APP_NAME), [u.midSKey.labeled]);
|
|
62
63
|
return idManager;
|
|
63
64
|
};
|
|
64
65
|
this.initForExistingUserWithoutCache = async (address) => {
|
|
@@ -80,7 +81,7 @@ class Core {
|
|
|
80
81
|
return;
|
|
81
82
|
}
|
|
82
83
|
// 4) complete initialization of id manager
|
|
83
|
-
await setupManagerStorage(await this.storages.makeSyncedFSForApp(MAILERID_APP_NAME));
|
|
84
|
+
await setupManagerStorage(await this.storages.makeSyncedFSForApp(constants_1.MAILERID_APP_NAME));
|
|
84
85
|
return idManager;
|
|
85
86
|
};
|
|
86
87
|
};
|
|
@@ -89,7 +90,7 @@ class Core {
|
|
|
89
90
|
if (!completeStorageInit) {
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
|
-
const idManager = await id_manager_1.IdManager.initFromCachedStore(address, await this.storages.makeSyncedFSForApp(MAILERID_APP_NAME), this.makeResolver('mailerid'), () => this.makeNet(), this.logger.logError, this.logger.logWarning);
|
|
93
|
+
const idManager = await id_manager_1.IdManager.initFromCachedStore(address, await this.storages.makeSyncedFSForApp(constants_1.MAILERID_APP_NAME), this.makeResolver('mailerid'), () => this.makeNet(), this.logger.logError, this.logger.logWarning);
|
|
93
94
|
if (!idManager) {
|
|
94
95
|
return;
|
|
95
96
|
}
|
|
@@ -100,6 +101,7 @@ class Core {
|
|
|
100
101
|
this.close$ = this.closeBroadcast.asObservable();
|
|
101
102
|
this.cryptor = makeCryptor(this.logger.logError, this.logger.logWarning);
|
|
102
103
|
this.storages = new storage_1.Storages(this.cryptor.cryptor.sbox, this.appDirs.storagePathFor);
|
|
104
|
+
this.keyrings = new keyring_1.Keyrings(this.cryptor.cryptor.sbox);
|
|
103
105
|
this.asmail = new asmail_1.ASMail(this.cryptor.cryptor.sbox, this.makeNet, this.appDirs.inboxPathFor, this.logger);
|
|
104
106
|
Object.seal(this);
|
|
105
107
|
}
|
|
@@ -133,7 +135,8 @@ class Core {
|
|
|
133
135
|
const mail = this.makeMailCAP(requestedCAPs);
|
|
134
136
|
const log = this.makeLogCAP(appDomain, requestedCAPs);
|
|
135
137
|
const mailerid = this.makeMailerIdCAP(requestedCAPs);
|
|
136
|
-
const
|
|
138
|
+
const keyrings = this.makeKeyringsCAP(requestedCAPs);
|
|
139
|
+
const caps = { mail, log, mailerid, storage, keyrings };
|
|
137
140
|
return { caps, close };
|
|
138
141
|
}
|
|
139
142
|
;
|
|
@@ -156,6 +159,15 @@ class Core {
|
|
|
156
159
|
return undefined;
|
|
157
160
|
}
|
|
158
161
|
}
|
|
162
|
+
makeKeyringsCAP(requestedCAPs) {
|
|
163
|
+
if (requestedCAPs.keyrings
|
|
164
|
+
&& (requestedCAPs.keyrings === 'all')) {
|
|
165
|
+
return this.keyrings.makeKeyringsCAP();
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
159
171
|
makeLogCAP(appDomain, requestedCAPs) {
|
|
160
172
|
if (requestedCAPs.logToPlatform === true) {
|
|
161
173
|
return (type, msg, e) => this.logger.appLog(type, appDomain, msg, e);
|
|
@@ -177,8 +189,11 @@ class Core {
|
|
|
177
189
|
this.closingProc = (async () => {
|
|
178
190
|
if (this.isInitialized) {
|
|
179
191
|
await this.asmail.close();
|
|
192
|
+
await this.keyrings.close();
|
|
180
193
|
await this.storages.close();
|
|
181
194
|
this.asmail = undefined;
|
|
195
|
+
this.keyrings = undefined;
|
|
196
|
+
this.idManager = undefined;
|
|
182
197
|
this.storages = undefined;
|
|
183
198
|
}
|
|
184
199
|
await this.cryptor.close();
|
|
@@ -188,12 +203,25 @@ class Core {
|
|
|
188
203
|
}
|
|
189
204
|
await this.closingProc;
|
|
190
205
|
}
|
|
206
|
+
async performDataMigrationsAtInit() {
|
|
207
|
+
await this.storages.migrateCoreAppDataOnFirstRun('synced', `${constants_1.ASMAIL_APP_NAME}/keyring`, constants_1.KEYRINGS_APP_NAME);
|
|
208
|
+
await this.storages.migrateCoreAppDataOnFirstRun('synced', `${constants_1.ASMAIL_APP_NAME}/config/introductory-key.json`, `${constants_1.KEYRINGS_APP_NAME}/introductory-keys/published-on-server.json`);
|
|
209
|
+
await this.storages.migrateCoreAppDataOnFirstRun('synced', `${constants_1.ASMAIL_APP_NAME}/config/anonymous/invites.json`, `${constants_1.ASMAIL_APP_NAME}/sending-params/anonymous-invites.json`);
|
|
210
|
+
}
|
|
191
211
|
async initCore(idManager) {
|
|
192
212
|
try {
|
|
193
213
|
this.idManager = idManager;
|
|
194
|
-
const
|
|
195
|
-
const
|
|
196
|
-
|
|
214
|
+
const address = this.idManager.getId();
|
|
215
|
+
const getSigner = this.idManager.getSigner;
|
|
216
|
+
const asmailServerConfig = new config_1.ConfigOfASMailServer(address, getSigner, this.makeResolver('asmail'), this.makeNet());
|
|
217
|
+
// XXX This should be removed, at some point, as there will be no more
|
|
218
|
+
// users with very old data folders.
|
|
219
|
+
await this.performDataMigrationsAtInit();
|
|
220
|
+
const keyringsSyncedFS = await this.storages.makeSyncedFSForApp(constants_1.KEYRINGS_APP_NAME);
|
|
221
|
+
await this.keyrings.init(keyringsSyncedFS, this.idManager.getSigner, asmailServerConfig.makeParamSetterAndGetter('init-pub-key'));
|
|
222
|
+
const inboxSyncedFS = await this.storages.makeSyncedFSForApp(constants_1.ASMAIL_APP_NAME);
|
|
223
|
+
const inboxLocalFS = await this.storages.makeLocalFSForApp(constants_1.ASMAIL_APP_NAME);
|
|
224
|
+
await this.asmail.init(this.idManager.getId(), this.idManager.getSigner, inboxSyncedFS, inboxLocalFS, this.storages.storageGetterForASMail(), this.makeResolver, asmailServerConfig, this.keyrings.forASMail());
|
|
197
225
|
this.isInitialized = true;
|
|
198
226
|
return this.idManager.getId();
|
|
199
227
|
}
|
|
@@ -289,7 +317,7 @@ function severalDomainsAppFSChecker(appFSs) {
|
|
|
289
317
|
}
|
|
290
318
|
const allFSs = () => 'w';
|
|
291
319
|
function fsChecker(setting) {
|
|
292
|
-
return
|
|
320
|
+
return type => {
|
|
293
321
|
const s = setting.find(s => (s.type === type));
|
|
294
322
|
if (!s) {
|
|
295
323
|
return false;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
type JsonKey = web3n.keys.JsonKey;
|
|
2
|
+
type JsonKeyShort = web3n.keys.JsonKeyShort;
|
|
2
3
|
export type MsgKeyRole = 'suggested' | 'in_use' | 'old' | 'published_intro' | 'prev_published_intro' | 'introductory';
|
|
3
4
|
export declare const KID_LENGTH = 16;
|
|
4
5
|
export declare const PID_LENGTH = 2;
|
|
@@ -59,3 +60,4 @@ export declare function extractKeyBytes(key: JsonKeyShort): Uint8Array;
|
|
|
59
60
|
* @param alg
|
|
60
61
|
*/
|
|
61
62
|
export declare function msgKeyPackSizeFor(alg: string): number;
|
|
63
|
+
export {};
|
|
@@ -27,8 +27,8 @@ exports.msgKeyPackSizeFor = msgKeyPackSizeFor;
|
|
|
27
27
|
* This file contains common functions used by parts of a keyring.
|
|
28
28
|
*/
|
|
29
29
|
const ecma_nacl_1 = require("ecma-nacl");
|
|
30
|
-
const buffer_utils_1 = require("
|
|
31
|
-
const random_node_1 = require("
|
|
30
|
+
const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
31
|
+
const random_node_1 = require("../../lib-common/random-node");
|
|
32
32
|
exports.KID_LENGTH = 16;
|
|
33
33
|
exports.PID_LENGTH = 2;
|
|
34
34
|
exports.KEY_USE = {
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
* This file contains functionality, used inside keyring.
|
|
3
3
|
*/
|
|
4
4
|
import { JWKeyPair, MsgKeyRole, ASMailKeyPair } from './common';
|
|
5
|
-
import {
|
|
6
|
-
import { SuggestedNextKeyPair } from '../msg/opener';
|
|
5
|
+
import { SuggestedNextKeyPair } from '../asmail/msg/opener';
|
|
7
6
|
import { KeyPairsStorage } from './index';
|
|
8
|
-
import { Decryptor } from '
|
|
7
|
+
import { Decryptor } from '../../lib-common/async-cryptor-wrap';
|
|
9
8
|
import { AsyncSBoxCryptor } from 'xsp-files';
|
|
9
|
+
type JsonKey = web3n.keys.JsonKey;
|
|
10
|
+
type JsonKeyShort = web3n.keys.JsonKeyShort;
|
|
10
11
|
export interface ReceptionPair {
|
|
11
12
|
pids: string[];
|
|
12
13
|
recipientKey: JWKeyPair;
|
|
@@ -142,3 +143,4 @@ export declare class CorrespondentKeys {
|
|
|
142
143
|
msgCount: number;
|
|
143
144
|
}>;
|
|
144
145
|
}
|
|
146
|
+
export {};
|
|
@@ -22,12 +22,12 @@ exports.msgMasterDecryptor = msgMasterDecryptor;
|
|
|
22
22
|
* This file contains functionality, used inside keyring.
|
|
23
23
|
*/
|
|
24
24
|
const common_1 = require("./common");
|
|
25
|
-
const random = require("
|
|
25
|
+
const random = require("../../lib-common/random-node");
|
|
26
26
|
const ecma_nacl_1 = require("ecma-nacl");
|
|
27
|
-
const buffer_utils_1 = require("
|
|
28
|
-
const error_1 = require("
|
|
29
|
-
const async_cryptor_wrap_1 = require("
|
|
30
|
-
const cryptor_work_labels_1 = require("
|
|
27
|
+
const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
28
|
+
const error_1 = require("../../lib-common/exceptions/error");
|
|
29
|
+
const async_cryptor_wrap_1 = require("../../lib-common/async-cryptor-wrap");
|
|
30
|
+
const cryptor_work_labels_1 = require("../../lib-client/cryptor/cryptor-work-labels");
|
|
31
31
|
function generatePids() {
|
|
32
32
|
const pids = [];
|
|
33
33
|
for (let i = 0; i < 5; i += 1) {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { IdToEmailMap } from './id-to-email-map';
|
|
2
|
+
import { MsgKeyRole } from './common';
|
|
3
|
+
import { AsyncSBoxCryptor } from 'xsp-files';
|
|
4
|
+
import { ResourcesForSending } from '../asmail/delivery/common';
|
|
5
|
+
import { ResourcesForReceiving } from '../asmail/inbox';
|
|
6
|
+
import { GetSigner } from '../id-manager';
|
|
7
|
+
import { ParamOnServer } from '../../lib-client/asmail/service-config';
|
|
8
|
+
export { KEY_USE, MsgKeyRole } from './common';
|
|
9
|
+
export interface MsgKeyInfo {
|
|
10
|
+
correspondent: string;
|
|
11
|
+
key?: Uint8Array;
|
|
12
|
+
/**
|
|
13
|
+
* This is a current status of the key in this keyring.
|
|
14
|
+
*/
|
|
15
|
+
keyStatus: MsgKeyRole;
|
|
16
|
+
/**
|
|
17
|
+
* Length of a key pack, in a main object's header start.
|
|
18
|
+
* This length depends on algorithms, hence we cannot hard-wire it, but must
|
|
19
|
+
* pass it this way, setting it according to key's nature.
|
|
20
|
+
*/
|
|
21
|
+
msgKeyPackLen: number;
|
|
22
|
+
}
|
|
23
|
+
type WritableFS = web3n.files.WritableFS;
|
|
24
|
+
type Service = web3n.keys.Keyrings;
|
|
25
|
+
type SendingResources = ResourcesForSending['correspondents'];
|
|
26
|
+
type ReceptionResources = ResourcesForReceiving['correspondents'];
|
|
27
|
+
export interface KeyringForASMail {
|
|
28
|
+
needIntroKeyFor: SendingResources['needIntroKeyFor'];
|
|
29
|
+
generateKeysToSend: SendingResources['generateKeysToSend'];
|
|
30
|
+
nextCrypto: SendingResources['nextCrypto'];
|
|
31
|
+
decrypt: ReceptionResources['msgDecryptor'];
|
|
32
|
+
close(): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export interface KeyPairsStorage {
|
|
35
|
+
pairIdToEmailMap: IdToEmailMap;
|
|
36
|
+
saveChanges: () => void;
|
|
37
|
+
}
|
|
38
|
+
export declare class Keyrings {
|
|
39
|
+
private readonly cryptor;
|
|
40
|
+
/**
|
|
41
|
+
* This is a map from correspondents' canonical addresses to key objects.
|
|
42
|
+
*/
|
|
43
|
+
private readonly corrKeys;
|
|
44
|
+
readonly pairIdToEmailMap: IdToEmailMap;
|
|
45
|
+
private readonly workLabel;
|
|
46
|
+
private storage;
|
|
47
|
+
private publishedKeys;
|
|
48
|
+
constructor(cryptor: AsyncSBoxCryptor);
|
|
49
|
+
private readonly asKeyPairsStorage;
|
|
50
|
+
private addCorrespondent;
|
|
51
|
+
init(fs: WritableFS, getSigner: GetSigner, pkeyOnServer: ParamOnServer<'init-pub-key'>): Promise<void>;
|
|
52
|
+
forASMail(): KeyringForASMail;
|
|
53
|
+
private saveChanges;
|
|
54
|
+
private needIntroKeyFor;
|
|
55
|
+
private generateKeysToSend;
|
|
56
|
+
private nextCrypto;
|
|
57
|
+
private decryptMsgKeyWithIntroPair;
|
|
58
|
+
private findEstablishedReceptionPairs;
|
|
59
|
+
private decryptMsgKeyWithEstablishedPair;
|
|
60
|
+
/**
|
|
61
|
+
* This method updates message counts and a timestamp in a given reception
|
|
62
|
+
* pair.
|
|
63
|
+
* @param rp is a sending pair, in which changes should be done. Note this
|
|
64
|
+
* must be a shared structure at this point, not a copy of a pair.
|
|
65
|
+
* @param msgCount is a message count that should be added to the pair.
|
|
66
|
+
*/
|
|
67
|
+
private updateReceivedMsgCountIn;
|
|
68
|
+
private absorbSuggestedNextKeyPair;
|
|
69
|
+
private decrypt;
|
|
70
|
+
close(): Promise<void>;
|
|
71
|
+
makeKeyringsCAP(): Service;
|
|
72
|
+
}
|