core-3nweb-client-lib 0.27.4 → 0.27.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.
- package/build/api-defs/files.d.ts +40 -10
- package/build/core/asmail/delivery/per-recipient-wip.js +2 -2
- package/build/core/asmail/inbox/inbox-events.js +10 -5
- package/build/core/asmail/inbox/index.d.ts +3 -2
- package/build/core/asmail/inbox/index.js +14 -10
- package/build/core/asmail/inbox/msg-indexing.d.ts +17 -64
- package/build/core/asmail/inbox/msg-indexing.js +440 -311
- package/build/core/asmail/inbox/msg-on-disk.js +2 -1
- package/build/core/asmail/index.js +3 -2
- package/build/core/asmail/keyring/correspondent-keys.js +3 -1
- package/build/core/asmail/keyring/index.d.ts +1 -4
- package/build/core/asmail/keyring/index.js +6 -6
- package/build/core/asmail/msg/opener.js +4 -3
- package/build/core/asmail/msg/packer.d.ts +1 -0
- package/build/core/asmail/msg/packer.js +8 -4
- package/build/core/index.js +2 -3
- package/build/core/storage/local/obj-files.js +2 -1
- package/build/core/storage/synced/storage.js +3 -2
- package/build/core/storage/synced/upload-header-file.js +4 -2
- package/build/core/storage/synced/upsyncer.js +3 -5
- package/build/ipc-via-protobuf/asmail-cap.js +14 -15
- package/build/ipc-via-protobuf/bytes.js +42 -18
- package/build/ipc-via-protobuf/file.js +43 -39
- package/build/ipc-via-protobuf/fs.js +72 -67
- package/build/ipc-via-protobuf/mailerid.js +2 -2
- package/build/ipc-via-protobuf/protobuf-msg.d.ts +1 -0
- package/build/ipc-via-protobuf/protobuf-msg.js +5 -1
- package/build/ipc-via-protobuf/startup-cap.js +8 -8
- package/build/ipc-via-protobuf/storage-cap.js +4 -4
- package/build/lib-client/3nstorage/xsp-fs/common.js +2 -0
- package/build/lib-client/3nstorage/xsp-fs/file-node.js +0 -17
- package/build/lib-client/3nstorage/xsp-fs/file.d.ts +1 -1
- package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +1 -1
- package/build/lib-client/3nstorage/xsp-fs/folder-node.js +13 -7
- package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +1 -1
- package/build/lib-client/3nstorage/xsp-fs/fs.js +1 -1
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +2 -2
- package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +7 -3
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +1 -0
- package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +7 -5
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +3 -4
- package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +20 -15
- package/build/lib-client/cryptor/cryptor-in-worker.js +37 -47
- 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 +15 -12
- package/build/lib-client/cryptor/in-proc-wasm.js +11 -8
- package/build/lib-client/cryptor/serialization-for-wasm.d.ts +36 -0
- package/build/lib-client/cryptor/serialization-for-wasm.js +58 -0
- package/build/lib-client/cryptor-work-labels.d.ts +26 -0
- package/build/lib-client/cryptor-work-labels.js +152 -0
- package/build/lib-client/fs-sync-utils.d.ts +7 -1
- package/build/lib-client/fs-sync-utils.js +18 -7
- package/build/lib-client/local-files/dev-file-src.d.ts +2 -1
- package/build/lib-client/local-files/dev-file-src.js +5 -1
- package/build/lib-client/local-files/device-fs.js +2 -1
- package/build/lib-client/objs-on-disk/obj-on-disk.js +5 -1
- package/build/lib-client/request-utils.js +14 -14
- package/build/lib-common/async-cryptor-wrap.d.ts +9 -9
- package/build/lib-common/async-cryptor-wrap.js +13 -13
- package/build/lib-common/byte-streaming/pipe.d.ts +1 -1
- package/build/lib-common/byte-streaming/pipe.js +3 -3
- package/build/lib-common/byte-streaming/wrapping.js +4 -2
- package/build/lib-common/json-utils.js +0 -3
- package/build/lib-common/processes/synced.js +0 -184
- package/build/lib-sqlite-on-3nstorage/index.d.ts +32 -0
- package/build/lib-sqlite-on-3nstorage/index.js +117 -0
- package/build/lib-sqlite-on-3nstorage/sqljs.d.ts +279 -0
- package/build/lib-sqlite-on-3nstorage/sqljs.js +223 -0
- package/build/protos/asmail.proto.js +3748 -1121
- package/build/protos/bytes.proto.js +731 -204
- package/build/protos/common.proto.js +192 -44
- package/build/protos/cryptor.proto.js +184 -61
- package/build/protos/file.proto.js +1336 -324
- package/build/protos/fs.proto.js +3099 -846
- package/build/protos/ipc.proto.js +244 -61
- package/build/protos/logger.proto.js +219 -53
- package/build/protos/mailerid.proto.js +230 -50
- package/build/protos/startup.proto.js +341 -77
- package/build/protos/storage.proto.js +276 -62
- package/package.json +8 -7
- package/protos/bytes.proto +13 -4
- package/protos/file.proto +4 -1
- package/protos/fs.proto +4 -1
|
@@ -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.MsgOnDisk = void 0;
|
|
19
20
|
const fs = require("../../../lib-common/async-fs-node");
|
|
@@ -99,8 +99,8 @@ class ASMail {
|
|
|
99
99
|
}
|
|
100
100
|
async setupInbox(syncedFS, getSigner, getStorages, makeResolver) {
|
|
101
101
|
const cachePath = this.inboxPathForUser(this.address);
|
|
102
|
-
const
|
|
103
|
-
this.inbox = await inbox_1.InboxOnServer.makeAndStart(cachePath,
|
|
102
|
+
const inboxSyncedFS = await (0, fs_sync_utils_1.getOrMakeAndUploadFolderIn)(syncedFS, INBOX_DATA_FOLDER);
|
|
103
|
+
this.inbox = await inbox_1.InboxOnServer.makeAndStart(cachePath, inboxSyncedFS, {
|
|
104
104
|
address: this.address,
|
|
105
105
|
cryptor: this.cryptor,
|
|
106
106
|
getSigner,
|
|
@@ -126,6 +126,7 @@ class ASMail {
|
|
|
126
126
|
}
|
|
127
127
|
;
|
|
128
128
|
async close() {
|
|
129
|
+
await this.inbox.close();
|
|
129
130
|
await this.keyring.close();
|
|
130
131
|
}
|
|
131
132
|
}
|
|
@@ -26,6 +26,7 @@ const ecma_nacl_1 = require("ecma-nacl");
|
|
|
26
26
|
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
27
27
|
const error_1 = require("../../../lib-common/exceptions/error");
|
|
28
28
|
const async_cryptor_wrap_1 = require("../../../lib-common/async-cryptor-wrap");
|
|
29
|
+
const cryptor_work_labels_1 = require("../../../lib-client/cryptor-work-labels");
|
|
29
30
|
function generatePids() {
|
|
30
31
|
const pids = [];
|
|
31
32
|
for (let i = 0; i < 5; i += 1) {
|
|
@@ -35,7 +36,8 @@ function generatePids() {
|
|
|
35
36
|
}
|
|
36
37
|
function msgMasterDecryptor(cryptor, skey, pkey) {
|
|
37
38
|
const msgMasterKey = calcMsgMasterKey(skey, pkey);
|
|
38
|
-
const
|
|
39
|
+
const workLabel = cryptor_work_labels_1.cryptoWorkLabels.makeRandom('asmail');
|
|
40
|
+
const masterDecr = (0, async_cryptor_wrap_1.makeDecryptor)(cryptor, workLabel, msgMasterKey);
|
|
39
41
|
msgMasterKey.fill(0);
|
|
40
42
|
return masterDecr;
|
|
41
43
|
}
|
|
@@ -7,10 +7,7 @@ import { ResourcesForReceiving } from '../inbox';
|
|
|
7
7
|
export { KEY_USE, MsgKeyRole } from './common';
|
|
8
8
|
export interface MsgKeyInfo {
|
|
9
9
|
correspondent: string;
|
|
10
|
-
|
|
11
|
-
* This is a base64 form of key's byte array.
|
|
12
|
-
*/
|
|
13
|
-
key?: string;
|
|
10
|
+
key?: Uint8Array;
|
|
14
11
|
/**
|
|
15
12
|
* This is a current status of the key in this keyring.
|
|
16
13
|
*/
|
|
@@ -28,6 +28,7 @@ const canonical_address_1 = require("../../../lib-common/canonical-address");
|
|
|
28
28
|
const common_2 = require("../delivery/common");
|
|
29
29
|
const keyring_storage_1 = require("./keyring-storage");
|
|
30
30
|
const assert_1 = require("../../../lib-common/assert");
|
|
31
|
+
const cryptor_work_labels_1 = require("../../../lib-client/cryptor-work-labels");
|
|
31
32
|
var common_3 = require("./common");
|
|
32
33
|
Object.defineProperty(exports, "KEY_USE", { enumerable: true, get: function () { return common_3.KEY_USE; } });
|
|
33
34
|
function makeAndKeyRing(cryptor, fs, publishedKeys) {
|
|
@@ -43,6 +44,7 @@ class KRing {
|
|
|
43
44
|
*/
|
|
44
45
|
this.corrKeys = new Map();
|
|
45
46
|
this.pairIdToEmailMap = new id_to_email_map_1.IdToEmailMap();
|
|
47
|
+
this.workLabel = cryptor_work_labels_1.cryptoWorkLabels.makeRandom('asmail');
|
|
46
48
|
this.storage = undefined;
|
|
47
49
|
this.asKeyPairsStorage = {
|
|
48
50
|
pairIdToEmailMap: this.pairIdToEmailMap,
|
|
@@ -64,7 +66,7 @@ class KRing {
|
|
|
64
66
|
const { msgMasterKey, currentPair, msgCount } = await ck.getSendingPair(introPKeyFromServer);
|
|
65
67
|
// prepare message encryptor
|
|
66
68
|
const nextNonce = await random.bytes(xsp_files_1.NONCE_LENGTH);
|
|
67
|
-
const encryptor = (0, async_cryptor_wrap_1.makeEncryptor)(this.cryptor, msgMasterKey, nextNonce);
|
|
69
|
+
const encryptor = (0, async_cryptor_wrap_1.makeEncryptor)(this.cryptor, this.workLabel, msgMasterKey, nextNonce);
|
|
68
70
|
msgMasterKey.fill(0);
|
|
69
71
|
return { encryptor, currentPair, msgCount };
|
|
70
72
|
};
|
|
@@ -148,10 +150,9 @@ class KRing {
|
|
|
148
150
|
const info = {
|
|
149
151
|
correspondent: undefined,
|
|
150
152
|
keyStatus: recipKey.role,
|
|
151
|
-
key:
|
|
153
|
+
key: mainObjFileKey,
|
|
152
154
|
msgKeyPackLen
|
|
153
155
|
};
|
|
154
|
-
mainObjFileKey.fill(0);
|
|
155
156
|
return info;
|
|
156
157
|
}
|
|
157
158
|
catch (err) {
|
|
@@ -195,7 +196,7 @@ class KRing {
|
|
|
195
196
|
const h = await getMainObjHeader();
|
|
196
197
|
for (const { correspondent, pair, role } of pairs) {
|
|
197
198
|
const masterKey = buffer_utils_1.base64.open(pair.msgMasterKey);
|
|
198
|
-
const masterDecr = (0, async_cryptor_wrap_1.makeDecryptor)(this.cryptor, masterKey);
|
|
199
|
+
const masterDecr = (0, async_cryptor_wrap_1.makeDecryptor)(this.cryptor, this.workLabel, masterKey);
|
|
199
200
|
masterKey.fill(0);
|
|
200
201
|
try {
|
|
201
202
|
const msgKeyPackLen = msgKeyPackLenForPair(pair);
|
|
@@ -206,10 +207,9 @@ class KRing {
|
|
|
206
207
|
const keyInfo = {
|
|
207
208
|
correspondent: correspondent,
|
|
208
209
|
keyStatus: role,
|
|
209
|
-
key:
|
|
210
|
+
key: mainObjFileKey,
|
|
210
211
|
msgKeyPackLen
|
|
211
212
|
};
|
|
212
|
-
mainObjFileKey.fill(0);
|
|
213
213
|
// set pair as in use
|
|
214
214
|
if (keyInfo.keyStatus === 'suggested') {
|
|
215
215
|
const corrKeys = this.corrKeys.get(keyInfo.correspondent);
|
|
@@ -20,6 +20,7 @@ exports.openMsg = exports.OpenedMsg = void 0;
|
|
|
20
20
|
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
21
21
|
const error_1 = require("../../../lib-common/exceptions/error");
|
|
22
22
|
const xsp_files_1 = require("xsp-files");
|
|
23
|
+
const cryptor_work_labels_1 = require("../../../lib-client/cryptor-work-labels");
|
|
23
24
|
class OpenedMsg {
|
|
24
25
|
constructor(msgId, main) {
|
|
25
26
|
this.msgId = msgId;
|
|
@@ -77,9 +78,9 @@ Object.freeze(OpenedMsg);
|
|
|
77
78
|
async function openMsg(msgId, mainObjId, mainObj, headerOfs, fKey, cryptor) {
|
|
78
79
|
try {
|
|
79
80
|
const header = await mainObj.readHeader();
|
|
80
|
-
const segReader = await (0, xsp_files_1.makeSegmentsReader)(fKey, (0, xsp_files_1.idToHeaderNonce)(mainObjId), 0, header.subarray(headerOfs), cryptor);
|
|
81
|
-
const byteSrc =
|
|
82
|
-
const bytes = await byteSrc.
|
|
81
|
+
const segReader = await (0, xsp_files_1.makeSegmentsReader)(fKey, (0, xsp_files_1.idToHeaderNonce)(mainObjId), 0, header.subarray(headerOfs), cryptor, cryptor_work_labels_1.cryptoWorkLabels.makeFor('asmail', msgId));
|
|
82
|
+
const byteSrc = (0, xsp_files_1.makeDecryptedByteSource)(mainObj.segSrc, segReader);
|
|
83
|
+
const bytes = await byteSrc.readNext(undefined);
|
|
83
84
|
if (!bytes) {
|
|
84
85
|
throw new Error(`End of bytes is reached too soon`);
|
|
85
86
|
}
|
|
@@ -52,6 +52,7 @@ export declare class MsgPacker {
|
|
|
52
52
|
private hasAttachments;
|
|
53
53
|
private attachmentsFS;
|
|
54
54
|
private attachmentsCont;
|
|
55
|
+
private workLabel;
|
|
55
56
|
private constructor();
|
|
56
57
|
static empty(segSizeIn256bs: number): MsgPacker;
|
|
57
58
|
static fromPack(p: PackJSON, segSizeIn256bs: number, att: undefined | {
|
|
@@ -24,6 +24,7 @@ const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
|
24
24
|
const folder_node_serialization_1 = require("../../../lib-client/3nstorage/xsp-fs/folder-node-serialization");
|
|
25
25
|
const json_utils_1 = require("../../../lib-common/json-utils");
|
|
26
26
|
const attachments_container_1 = require("./attachments-container");
|
|
27
|
+
const cryptor_work_labels_1 = require("../../../lib-client/cryptor-work-labels");
|
|
27
28
|
function turnKeysToB64(obj) {
|
|
28
29
|
obj.key = buffer_utils_1.base64.pack(obj.key);
|
|
29
30
|
if (!obj.folder) {
|
|
@@ -88,6 +89,7 @@ class MsgPacker {
|
|
|
88
89
|
'From': undefined
|
|
89
90
|
};
|
|
90
91
|
this.mainObjId = this.addJsonObj(this.main);
|
|
92
|
+
this.workLabel = cryptor_work_labels_1.cryptoWorkLabels.makeFor('asmail', this.mainObjId);
|
|
91
93
|
Object.seal(this);
|
|
92
94
|
}
|
|
93
95
|
static empty(segSizeIn256bs) {
|
|
@@ -97,6 +99,7 @@ class MsgPacker {
|
|
|
97
99
|
const packer = new MsgPacker(segSizeIn256bs);
|
|
98
100
|
packer.readyPack = p;
|
|
99
101
|
packer.mainObjId = p.meta.objIds[0];
|
|
102
|
+
packer.workLabel = cryptor_work_labels_1.cryptoWorkLabels.makeFor('asmail', packer.mainObjId);
|
|
100
103
|
Object.values((0, json_utils_1.copy)(p.objs))
|
|
101
104
|
.forEach(obj => {
|
|
102
105
|
packer.allObjs.set(obj.id, obj);
|
|
@@ -347,7 +350,7 @@ class MsgPacker {
|
|
|
347
350
|
}
|
|
348
351
|
const msgKeyPack = await msgKeyEnc.pack(obj.key);
|
|
349
352
|
const bytes = buffer_utils_1.utf8.pack(JSON.stringify(obj.json));
|
|
350
|
-
const segWriter = await (0, xsp_files_1.makeSegmentsWriter)(obj.key, (0, xsp_files_1.idToHeaderNonce)(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs, payloadFormat: 1 }, random.bytes, cryptor);
|
|
353
|
+
const segWriter = await (0, xsp_files_1.makeSegmentsWriter)(obj.key, (0, xsp_files_1.idToHeaderNonce)(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs, payloadFormat: 1 }, random.bytes, cryptor, this.workLabel);
|
|
351
354
|
// make source that inserts message key pack into header
|
|
352
355
|
return makeMainObjSrc(msgKeyPack, bytes, segWriter);
|
|
353
356
|
}
|
|
@@ -410,10 +413,10 @@ class MsgPacker {
|
|
|
410
413
|
// make object segments writer
|
|
411
414
|
let segWriter;
|
|
412
415
|
if (header) {
|
|
413
|
-
segWriter = await (0, xsp_files_1.makeSegmentsWriter)(obj.key, (0, xsp_files_1.idToHeaderNonce)(obj.id), 0, { type: 'restart', header }, random.bytes, cryptor);
|
|
416
|
+
segWriter = await (0, xsp_files_1.makeSegmentsWriter)(obj.key, (0, xsp_files_1.idToHeaderNonce)(obj.id), 0, { type: 'restart', header }, random.bytes, cryptor, this.workLabel);
|
|
414
417
|
}
|
|
415
418
|
else {
|
|
416
|
-
segWriter = await (0, xsp_files_1.makeSegmentsWriter)(obj.key, (0, xsp_files_1.idToHeaderNonce)(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs, payloadFormat: 1 }, random.bytes, cryptor);
|
|
419
|
+
segWriter = await (0, xsp_files_1.makeSegmentsWriter)(obj.key, (0, xsp_files_1.idToHeaderNonce)(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs, payloadFormat: 1 }, random.bytes, cryptor, this.workLabel);
|
|
417
420
|
}
|
|
418
421
|
// make object source
|
|
419
422
|
let src;
|
|
@@ -492,7 +495,8 @@ function fileSrcToByteSrc(fileSrc) {
|
|
|
492
495
|
size: await fileSrc.getSize()
|
|
493
496
|
};
|
|
494
497
|
},
|
|
495
|
-
|
|
498
|
+
readNext: fileSrc.readNext,
|
|
499
|
+
readAt: fileSrc.readAt,
|
|
496
500
|
seek: fileSrc.seek
|
|
497
501
|
};
|
|
498
502
|
}
|
package/build/core/index.js
CHANGED
|
@@ -120,9 +120,8 @@ class Core {
|
|
|
120
120
|
const initFromSignUp$ = signUp.newUser$
|
|
121
121
|
.pipe((0, operators_1.mergeMap)(this.initForNewUser, 1));
|
|
122
122
|
const initFromSignIn$ = signIn.existingUser$;
|
|
123
|
-
const coreInit = (0, rxjs_1.merge)(initFromSignIn$, initFromSignUp$)
|
|
124
|
-
.pipe((0, operators_1.take)(1), (0, operators_1.mergeMap)(idManager => this.initCore(idManager), 1))
|
|
125
|
-
.toPromise();
|
|
123
|
+
const coreInit = (0, rxjs_1.lastValueFrom)((0, rxjs_1.merge)(initFromSignIn$, initFromSignUp$)
|
|
124
|
+
.pipe((0, operators_1.take)(1), (0, operators_1.mergeMap)(idManager => this.initCore(idManager), 1)));
|
|
126
125
|
return { coreInit, capsForStartup };
|
|
127
126
|
}
|
|
128
127
|
;
|
|
@@ -24,6 +24,7 @@ const path_1 = require("path");
|
|
|
24
24
|
const obj_files_gc_1 = require("./obj-files-gc");
|
|
25
25
|
const obj_status_1 = require("./obj-status");
|
|
26
26
|
const timed_cache_1 = require("../../../lib-common/timed-cache");
|
|
27
|
+
const rxjs_1 = require("rxjs");
|
|
27
28
|
class ObjFiles {
|
|
28
29
|
constructor(folders, logError) {
|
|
29
30
|
this.folders = folders;
|
|
@@ -140,7 +141,7 @@ class LocalObj {
|
|
|
140
141
|
const fPath = this.path(version);
|
|
141
142
|
const { obj, write$ } = await obj_on_disk_1.ObjOnDisk.createFileForWriteOfNewVersion(this.objId, version, fPath, encSub, undefined, this.objSegsGetterFromDisk);
|
|
142
143
|
try {
|
|
143
|
-
await
|
|
144
|
+
await (0, rxjs_1.lastValueFrom)(write$);
|
|
144
145
|
}
|
|
145
146
|
catch (err) {
|
|
146
147
|
if (this.verObjs.get(version) === obj) {
|
|
@@ -26,6 +26,7 @@ const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
|
26
26
|
const xsp_files_1 = require("xsp-files");
|
|
27
27
|
const remote_events_1 = require("./remote-events");
|
|
28
28
|
const upsyncer_1 = require("./upsyncer");
|
|
29
|
+
const rxjs_1 = require("rxjs");
|
|
29
30
|
const utils_for_observables_1 = require("../../../lib-common/utils-for-observables");
|
|
30
31
|
class SyncedStore {
|
|
31
32
|
constructor(files, remoteStorage, getStorages, cryptor, logError) {
|
|
@@ -216,12 +217,12 @@ class SyncedStore {
|
|
|
216
217
|
throw (0, exceptions_1.makeObjExistsExc)(objId);
|
|
217
218
|
}
|
|
218
219
|
const { fileWrite$ } = await this.files.saveFirstVersion(objId, encSub);
|
|
219
|
-
await
|
|
220
|
+
await (0, rxjs_1.lastValueFrom)(fileWrite$);
|
|
220
221
|
}
|
|
221
222
|
else {
|
|
222
223
|
const obj = await this.getObjOrThrow(objId);
|
|
223
224
|
const { fileWrite$ } = await obj.saveNewVersion(version, encSub);
|
|
224
|
-
await
|
|
225
|
+
await (0, rxjs_1.lastValueFrom)(fileWrite$);
|
|
225
226
|
}
|
|
226
227
|
}
|
|
227
228
|
async removeObj(objId) {
|
|
@@ -25,12 +25,14 @@ const assert_1 = require("../../../lib-common/assert");
|
|
|
25
25
|
exports.UPLOAD_HEADER_FILE_NAME_EXT = 'upload';
|
|
26
26
|
async function saveUploadHeaderFile(objFolder, headers) {
|
|
27
27
|
const bytes = packUploadHeaderChange(headers);
|
|
28
|
-
|
|
28
|
+
const upFile = uploadHeaderFilePath(objFolder, headers.uploadVersion);
|
|
29
|
+
await (0, async_fs_node_1.writeFile)(upFile, bytes);
|
|
29
30
|
}
|
|
30
31
|
exports.saveUploadHeaderFile = saveUploadHeaderFile;
|
|
31
32
|
async function readUploadHeaderFromFile(objFolder, uploadVersion) {
|
|
32
33
|
try {
|
|
33
|
-
const
|
|
34
|
+
const upFile = uploadHeaderFilePath(objFolder, uploadVersion);
|
|
35
|
+
const bytes = await (0, async_fs_node_1.readFile)(upFile);
|
|
34
36
|
return unpackUploadHeaderChange(bytes);
|
|
35
37
|
}
|
|
36
38
|
catch (exc) {
|
|
@@ -161,8 +161,7 @@ class UploadTask {
|
|
|
161
161
|
const header = await this.headerToUpload();
|
|
162
162
|
let segs = undefined;
|
|
163
163
|
if (segsToUpload > 0) {
|
|
164
|
-
await this.src.segSrc.
|
|
165
|
-
segs = await this.src.segSrc.read(segsToUpload);
|
|
164
|
+
segs = await this.src.segSrc.readAt(upload.segsOfs, segsToUpload);
|
|
166
165
|
}
|
|
167
166
|
(0, assert_1.assert)(!!segs && (segs.length === segsToUpload));
|
|
168
167
|
const ver = this.info.uploadVersion;
|
|
@@ -210,8 +209,7 @@ class UploadTask {
|
|
|
210
209
|
}
|
|
211
210
|
async continueOrderedUpload(upload) {
|
|
212
211
|
const segsToUpload = Math.min(upload.segsLeft, this.maxUploadChunk());
|
|
213
|
-
await this.src.segSrc.
|
|
214
|
-
const segs = await this.src.segSrc.read(segsToUpload);
|
|
212
|
+
const segs = await this.src.segSrc.readAt(upload.segsOfs, segsToUpload);
|
|
215
213
|
(0, assert_1.assert)(!!segs && (segs.length === segsToUpload));
|
|
216
214
|
const ofs = upload.segsOfs;
|
|
217
215
|
const trans = upload.transactionId;
|
|
@@ -230,7 +228,7 @@ class UploadTask {
|
|
|
230
228
|
const segInfo = upload.newSegsLeft[0];
|
|
231
229
|
(0, assert_1.assert)(!!segInfo);
|
|
232
230
|
const len = Math.min(maxSegs, segInfo.len);
|
|
233
|
-
const segs = await this.src.segSrc.
|
|
231
|
+
const segs = await this.src.segSrc.readAt(segInfo.thisVerOfs, len);
|
|
234
232
|
(0, assert_1.assert)(!!segs && (segs.length === len));
|
|
235
233
|
if (segInfo.len > len) {
|
|
236
234
|
upload.newSegsLeft.splice(1, 0, {
|
|
@@ -49,9 +49,8 @@ function exposeASMailCAP(cap, expServices) {
|
|
|
49
49
|
}
|
|
50
50
|
exports.exposeASMailCAP = exposeASMailCAP;
|
|
51
51
|
function makeASMailCaller(caller, objPath) {
|
|
52
|
-
const delivPath =
|
|
53
|
-
const inboxPath =
|
|
54
|
-
const connectPath = objPath.concat('connect');
|
|
52
|
+
const delivPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'delivery');
|
|
53
|
+
const inboxPath = (0, protobuf_msg_1.methodPathFor)(objPath, 'inbox');
|
|
55
54
|
return {
|
|
56
55
|
getUserId: getUserId.makeCaller(caller, objPath),
|
|
57
56
|
delivery: {
|
|
@@ -83,7 +82,7 @@ var getUserId;
|
|
|
83
82
|
}
|
|
84
83
|
getUserId.wrapService = wrapService;
|
|
85
84
|
function makeCaller(caller, objPath) {
|
|
86
|
-
const path =
|
|
85
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'getUserId');
|
|
87
86
|
return () => caller.startPromiseCall(path, undefined)
|
|
88
87
|
.then(buf => {
|
|
89
88
|
if (!buf) {
|
|
@@ -116,7 +115,7 @@ var inboxListMsgs;
|
|
|
116
115
|
}
|
|
117
116
|
inboxListMsgs.wrapService = wrapService;
|
|
118
117
|
function makeCaller(caller, objPath) {
|
|
119
|
-
const path =
|
|
118
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'listMsgs');
|
|
120
119
|
return fromTS => {
|
|
121
120
|
const req = (fromTS ? { fromTS: (0, protobuf_msg_1.toVal)(fromTS) } : {});
|
|
122
121
|
return caller
|
|
@@ -139,7 +138,7 @@ var removeMsg;
|
|
|
139
138
|
}
|
|
140
139
|
removeMsg.wrapService = wrapService;
|
|
141
140
|
function makeCaller(caller, objPath) {
|
|
142
|
-
const path =
|
|
141
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'removeMsg');
|
|
143
142
|
return async (msgId) => {
|
|
144
143
|
await caller.startPromiseCall(path, requestType.pack({ msgId }));
|
|
145
144
|
};
|
|
@@ -160,7 +159,7 @@ var getMsg;
|
|
|
160
159
|
}
|
|
161
160
|
getMsg.wrapService = wrapService;
|
|
162
161
|
function makeCaller(caller, objPath) {
|
|
163
|
-
const path =
|
|
162
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'getMsg');
|
|
164
163
|
return msgId => caller
|
|
165
164
|
.startPromiseCall(path, requestType.pack({ msgId }))
|
|
166
165
|
.then(buf => unpackIncomingMessage(buf, caller));
|
|
@@ -220,7 +219,7 @@ var inboxSubscribe;
|
|
|
220
219
|
}
|
|
221
220
|
inboxSubscribe.wrapService = wrapService;
|
|
222
221
|
function makeCaller(caller, objPath) {
|
|
223
|
-
const path =
|
|
222
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'subscribe');
|
|
224
223
|
return (event, obs) => {
|
|
225
224
|
const s = new rxjs_1.Subject();
|
|
226
225
|
const unsub = caller.startObservableCall(path, requestType.pack({ event }), s);
|
|
@@ -246,7 +245,7 @@ var preFlight;
|
|
|
246
245
|
}
|
|
247
246
|
preFlight.wrapService = wrapService;
|
|
248
247
|
function makeCaller(caller, objPath) {
|
|
249
|
-
const path =
|
|
248
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'preFlight');
|
|
250
249
|
return toAddress => caller
|
|
251
250
|
.startPromiseCall(path, requestType.pack({ toAddress }))
|
|
252
251
|
.then(protobuf_msg_1.unpackInt);
|
|
@@ -341,7 +340,7 @@ var addMsg;
|
|
|
341
340
|
}
|
|
342
341
|
addMsg.wrapService = wrapService;
|
|
343
342
|
function makeCaller(caller, objPath) {
|
|
344
|
-
const path =
|
|
343
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'addMsg');
|
|
345
344
|
return async (recipients, msg, id, opts) => {
|
|
346
345
|
const req = { id, msg: packMsg(msg, caller), recipients };
|
|
347
346
|
if (opts) {
|
|
@@ -369,7 +368,7 @@ var delivListMsgs;
|
|
|
369
368
|
}
|
|
370
369
|
delivListMsgs.wrapService = wrapService;
|
|
371
370
|
function makeCaller(caller, objPath) {
|
|
372
|
-
const path =
|
|
371
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'listMsgs');
|
|
373
372
|
return () => caller
|
|
374
373
|
.startPromiseCall(path, undefined)
|
|
375
374
|
.then(buf => {
|
|
@@ -438,7 +437,7 @@ var currentState;
|
|
|
438
437
|
}
|
|
439
438
|
currentState.wrapService = wrapService;
|
|
440
439
|
function makeCaller(caller, objPath) {
|
|
441
|
-
const path =
|
|
440
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'currentState');
|
|
442
441
|
return id => caller
|
|
443
442
|
.startPromiseCall(path, requestType.pack({ id }))
|
|
444
443
|
.then(buf => {
|
|
@@ -463,7 +462,7 @@ var rmMsg;
|
|
|
463
462
|
}
|
|
464
463
|
rmMsg.wrapService = wrapService;
|
|
465
464
|
function makeCaller(caller, objPath) {
|
|
466
|
-
const path =
|
|
465
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'rmMsg');
|
|
467
466
|
return (id, cancelSending) => caller
|
|
468
467
|
.startPromiseCall(path, requestType.pack({
|
|
469
468
|
id, cancelSending: (0, protobuf_msg_1.toOptVal)(cancelSending)
|
|
@@ -488,7 +487,7 @@ var observeAllDeliveries;
|
|
|
488
487
|
}
|
|
489
488
|
observeAllDeliveries.wrapService = wrapService;
|
|
490
489
|
function makeCaller(caller, objPath) {
|
|
491
|
-
const path =
|
|
490
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'observeAllDeliveries');
|
|
492
491
|
return obs => {
|
|
493
492
|
const s = new rxjs_1.Subject();
|
|
494
493
|
const unsub = caller.startObservableCall(path, undefined, s);
|
|
@@ -520,7 +519,7 @@ var observeDelivery;
|
|
|
520
519
|
}
|
|
521
520
|
observeDelivery.wrapService = wrapService;
|
|
522
521
|
function makeCaller(caller, objPath) {
|
|
523
|
-
const path =
|
|
522
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'observeDelivery');
|
|
524
523
|
return (id, obs) => {
|
|
525
524
|
const s = new rxjs_1.Subject();
|
|
526
525
|
const unsub = caller.startObservableCall(path, requestType.pack({ id }), s);
|
|
@@ -53,7 +53,8 @@ function makeSrcCaller(caller, ref) {
|
|
|
53
53
|
const src = {
|
|
54
54
|
getPosition: srcGetPosition.makeCaller(caller, objPath),
|
|
55
55
|
getSize: srcGetSize.makeCaller(caller, objPath),
|
|
56
|
-
|
|
56
|
+
readNext: srcReadNext.makeCaller(caller, objPath),
|
|
57
|
+
readAt: srcReadAt.makeCaller(caller, objPath),
|
|
57
58
|
seek: srcSeek.makeCaller(caller, objPath)
|
|
58
59
|
};
|
|
59
60
|
caller.registerClientDrop(src, ref);
|
|
@@ -64,7 +65,8 @@ function exposeSrcService(src, expServices) {
|
|
|
64
65
|
const wrap = {
|
|
65
66
|
getPosition: srcGetPosition.wrapService(src.getPosition),
|
|
66
67
|
getSize: srcGetSize.wrapService(src.getSize),
|
|
67
|
-
|
|
68
|
+
readNext: srcReadNext.wrapService(src.readNext),
|
|
69
|
+
readAt: srcReadAt.wrapService(src.readAt),
|
|
68
70
|
seek: srcSeek.wrapService(src.seek)
|
|
69
71
|
};
|
|
70
72
|
const ref = expServices.exposeDroppableService('FileByteSource', wrap, src);
|
|
@@ -82,7 +84,7 @@ var sinkGetSize;
|
|
|
82
84
|
}
|
|
83
85
|
sinkGetSize.wrapService = wrapService;
|
|
84
86
|
function makeCaller(caller, objPath) {
|
|
85
|
-
const path =
|
|
87
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'getSize');
|
|
86
88
|
return () => caller
|
|
87
89
|
.startPromiseCall(path, undefined)
|
|
88
90
|
.then(protobuf_msg_1.unpackInt);
|
|
@@ -102,7 +104,7 @@ var sinkSplice;
|
|
|
102
104
|
}
|
|
103
105
|
sinkSplice.wrapService = wrapService;
|
|
104
106
|
function makeCaller(caller, objPath) {
|
|
105
|
-
const path =
|
|
107
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'splice');
|
|
106
108
|
return async (pos, del, bytes) => {
|
|
107
109
|
await caller
|
|
108
110
|
.startPromiseCall(path, requestType.pack({
|
|
@@ -125,7 +127,7 @@ var sinkTruncate;
|
|
|
125
127
|
}
|
|
126
128
|
sinkTruncate.wrapService = wrapService;
|
|
127
129
|
function makeCaller(caller, objPath) {
|
|
128
|
-
const path =
|
|
130
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'truncate');
|
|
129
131
|
return async (size) => {
|
|
130
132
|
await caller
|
|
131
133
|
.startPromiseCall(path, requestType.pack({ size }));
|
|
@@ -160,7 +162,7 @@ var sinkShowLayout;
|
|
|
160
162
|
}
|
|
161
163
|
sinkShowLayout.wrapService = wrapService;
|
|
162
164
|
function makeCaller(caller, objPath) {
|
|
163
|
-
const path =
|
|
165
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'showLayout');
|
|
164
166
|
return () => caller
|
|
165
167
|
.startPromiseCall(path, undefined)
|
|
166
168
|
.then(buf => unpackLayout(replyType.unpack(buf)));
|
|
@@ -180,7 +182,7 @@ var sinkDone;
|
|
|
180
182
|
}
|
|
181
183
|
sinkDone.wrapService = wrapService;
|
|
182
184
|
function makeCaller(caller, objPath) {
|
|
183
|
-
const path =
|
|
185
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'done');
|
|
184
186
|
return async (err) => {
|
|
185
187
|
const req = (err ? { err: (0, protobuf_msg_1.errToMsg)(err) } : {});
|
|
186
188
|
await caller
|
|
@@ -201,7 +203,7 @@ var srcGetSize;
|
|
|
201
203
|
}
|
|
202
204
|
srcGetSize.wrapService = wrapService;
|
|
203
205
|
function makeCaller(caller, objPath) {
|
|
204
|
-
const path =
|
|
206
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'getSize');
|
|
205
207
|
return () => caller
|
|
206
208
|
.startPromiseCall(path, undefined)
|
|
207
209
|
.then(protobuf_msg_1.unpackInt);
|
|
@@ -220,7 +222,7 @@ var srcGetPosition;
|
|
|
220
222
|
}
|
|
221
223
|
srcGetPosition.wrapService = wrapService;
|
|
222
224
|
function makeCaller(caller, objPath) {
|
|
223
|
-
const path =
|
|
225
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'getPosition');
|
|
224
226
|
return () => caller
|
|
225
227
|
.startPromiseCall(path, undefined)
|
|
226
228
|
.then(protobuf_msg_1.unpackInt);
|
|
@@ -228,9 +230,9 @@ var srcGetPosition;
|
|
|
228
230
|
srcGetPosition.makeCaller = makeCaller;
|
|
229
231
|
})(srcGetPosition || (srcGetPosition = {}));
|
|
230
232
|
Object.freeze(srcGetPosition);
|
|
231
|
-
var
|
|
232
|
-
(function (
|
|
233
|
-
const requestType = protobuf_type_1.ProtoType.for(bytes_proto_1.bytes.
|
|
233
|
+
var srcReadNext;
|
|
234
|
+
(function (srcReadNext) {
|
|
235
|
+
const requestType = protobuf_type_1.ProtoType.for(bytes_proto_1.bytes.ReadNextRequestBody);
|
|
234
236
|
const replyType = protobuf_type_1.ProtoType.for(bytes_proto_1.bytes.ReadReplyBody);
|
|
235
237
|
function wrapService(fn) {
|
|
236
238
|
return buf => {
|
|
@@ -240,16 +242,38 @@ var srcRead;
|
|
|
240
242
|
return { promise };
|
|
241
243
|
};
|
|
242
244
|
}
|
|
243
|
-
|
|
245
|
+
srcReadNext.wrapService = wrapService;
|
|
244
246
|
function makeCaller(caller, objPath) {
|
|
245
|
-
const path =
|
|
247
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'readNext');
|
|
246
248
|
return len => caller
|
|
247
249
|
.startPromiseCall(path, requestType.pack({ len: (0, protobuf_msg_1.toOptVal)(len) }))
|
|
248
250
|
.then(buf => (0, protobuf_msg_1.valOfOpt)(replyType.unpack(buf).bytes));
|
|
249
251
|
}
|
|
250
|
-
|
|
251
|
-
})(
|
|
252
|
-
Object.freeze(
|
|
252
|
+
srcReadNext.makeCaller = makeCaller;
|
|
253
|
+
})(srcReadNext || (srcReadNext = {}));
|
|
254
|
+
Object.freeze(srcReadNext);
|
|
255
|
+
var srcReadAt;
|
|
256
|
+
(function (srcReadAt) {
|
|
257
|
+
const requestType = protobuf_type_1.ProtoType.for(bytes_proto_1.bytes.ReadAtRequestBody);
|
|
258
|
+
const replyType = protobuf_type_1.ProtoType.for(bytes_proto_1.bytes.ReadReplyBody);
|
|
259
|
+
function wrapService(fn) {
|
|
260
|
+
return buf => {
|
|
261
|
+
const { pos, len } = requestType.unpack(buf);
|
|
262
|
+
const promise = fn((0, protobuf_msg_1.fixInt)(pos), (0, protobuf_msg_1.valOfOptInt)(len))
|
|
263
|
+
.then(bytes => replyType.pack({ bytes: (0, protobuf_msg_1.toOptVal)(bytes) }));
|
|
264
|
+
return { promise };
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
srcReadAt.wrapService = wrapService;
|
|
268
|
+
function makeCaller(caller, objPath) {
|
|
269
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'readAt');
|
|
270
|
+
return (pos, len) => caller
|
|
271
|
+
.startPromiseCall(path, requestType.pack({ pos, len: (0, protobuf_msg_1.toOptVal)(len) }))
|
|
272
|
+
.then(buf => (0, protobuf_msg_1.valOfOpt)(replyType.unpack(buf).bytes));
|
|
273
|
+
}
|
|
274
|
+
srcReadAt.makeCaller = makeCaller;
|
|
275
|
+
})(srcReadAt || (srcReadAt = {}));
|
|
276
|
+
Object.freeze(srcReadAt);
|
|
253
277
|
var srcSeek;
|
|
254
278
|
(function (srcSeek) {
|
|
255
279
|
const requestType = protobuf_type_1.ProtoType.for(bytes_proto_1.bytes.SeekRequestBody);
|
|
@@ -262,7 +286,7 @@ var srcSeek;
|
|
|
262
286
|
}
|
|
263
287
|
srcSeek.wrapService = wrapService;
|
|
264
288
|
function makeCaller(caller, objPath) {
|
|
265
|
-
const path =
|
|
289
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'seek');
|
|
266
290
|
return async (offset) => {
|
|
267
291
|
await caller
|
|
268
292
|
.startPromiseCall(path, requestType.pack({ offset }));
|