core-3nweb-client-lib 0.49.5 → 0.49.6
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.
|
@@ -154,11 +154,6 @@ class Delivery {
|
|
|
154
154
|
}
|
|
155
155
|
const attachments = common_1.Attachments.fromMsg(msgToSend);
|
|
156
156
|
const localMeta = opts === null || opts === void 0 ? void 0 : opts.localMeta;
|
|
157
|
-
// DEBUG log
|
|
158
|
-
console.log(`\n adding message ${msgToSend.attachments ? `with attachments: ${JSON.stringify({
|
|
159
|
-
files: msgToSend.attachments.files ? Object.keys(msgToSend.attachments.files).length : 0,
|
|
160
|
-
folders: msgToSend.attachments.folders ? Object.keys(msgToSend.attachments.folders).length : 0
|
|
161
|
-
})}` : `without attachments in outgoing msg object.`}`);
|
|
162
157
|
// save msg, in case delivery should be restarted
|
|
163
158
|
const msgFS = await this.makeFSForNewMsg(id);
|
|
164
159
|
const msg = await msg_1.Msg.forNew(id, msgFS, msgToSend, sender, recipients, this.r, attachments, localMeta, opts === null || opts === void 0 ? void 0 : opts.retryRecipient);
|
|
@@ -127,11 +127,7 @@ class Msg {
|
|
|
127
127
|
await this.msgFS.writeJSONFile(MAIN_OBJ_FILE_NAME, main, { create: true, exclusive: true });
|
|
128
128
|
await this.msgFS.writeJSONFile(PROGRESS_INFO_FILE_NAME, this.progress, { create: true, exclusive: true });
|
|
129
129
|
if (this.attachments) {
|
|
130
|
-
|
|
131
|
-
await this.attachments.linkIn(this.msgFS)
|
|
132
|
-
.then(
|
|
133
|
-
// DEBUG log
|
|
134
|
-
() => console.log(` .... msg attachments linked while delivery`), err => console.error(`linking attachments error:`, err));
|
|
130
|
+
await this.attachments.linkIn(this.msgFS);
|
|
135
131
|
}
|
|
136
132
|
}
|
|
137
133
|
notifyOfChangesInProgress(saveProgress, saveWIPs) {
|
|
@@ -192,8 +188,6 @@ class Msg {
|
|
|
192
188
|
msg.setSection('Cc', this.msgToSend.carbonCopy);
|
|
193
189
|
msg.setSection('To', this.msgToSend.recipients);
|
|
194
190
|
if (this.attachments) {
|
|
195
|
-
// DEBUG log
|
|
196
|
-
console.log(`setting attachment on messages packer`);
|
|
197
191
|
await msg.setAttachments(this.attachments);
|
|
198
192
|
}
|
|
199
193
|
return msg;
|
|
@@ -80,7 +80,6 @@ class WIP {
|
|
|
80
80
|
* or if this wip is done, undefined is returned.
|
|
81
81
|
*/
|
|
82
82
|
startNext() {
|
|
83
|
-
var _a, _b;
|
|
84
83
|
let proc = this.proc.latestTaskAtThisMoment();
|
|
85
84
|
if (proc) {
|
|
86
85
|
return;
|
|
@@ -102,13 +101,9 @@ class WIP {
|
|
|
102
101
|
proc = this.proc.addStarted(this.sendObjs());
|
|
103
102
|
}
|
|
104
103
|
else if (stage === "cancel") {
|
|
105
|
-
// DEBUG log
|
|
106
|
-
console.log(` canceled sending msgId: ${(_a = this.state.session) === null || _a === void 0 ? void 0 : _a.msgId}`);
|
|
107
104
|
return;
|
|
108
105
|
}
|
|
109
106
|
else if (stage === undefined) {
|
|
110
|
-
// DEBUG log
|
|
111
|
-
console.log(` done sending msgId: ${(_b = this.state.session) === null || _b === void 0 ? void 0 : _b.msgId}`);
|
|
112
107
|
return;
|
|
113
108
|
}
|
|
114
109
|
else {
|
|
@@ -164,8 +159,6 @@ class WIP {
|
|
|
164
159
|
async getRecipientKeyAndEncrypt() {
|
|
165
160
|
const recipient = this.sender.recipient;
|
|
166
161
|
const introPKeyFromServer = await this.getIntroKeyIfRecipientIsUnknown(recipient);
|
|
167
|
-
// DEBUG log
|
|
168
|
-
console.log(`\n wip.getRecipientKeyAndEncrypt()`);
|
|
169
162
|
this.packer = await this.msg.msgPacker();
|
|
170
163
|
// get crypto parts for encrypting this message
|
|
171
164
|
const { currentPair, encryptor, msgCount } = await this.msg.r.correspondents.generateKeysToSend(recipient, introPKeyFromServer);
|
|
@@ -262,8 +255,6 @@ class WIP {
|
|
|
262
255
|
throw new Error(`Message pack is not set.`);
|
|
263
256
|
}
|
|
264
257
|
this.state.session = await this.sender.sendMetadata(this.state.pack.meta);
|
|
265
|
-
// DEBUG log
|
|
266
|
-
console.log(`\n wip.sendMeta() returned with\n msgId: ${this.state.session.msgId}\n meta.objIds sent to server:`, this.state.pack.meta.objIds);
|
|
267
258
|
this.msg.progress.recipients[this.state.recipient].idOnDelivery = this.state.session.msgId;
|
|
268
259
|
if (this.state.stage !== "cancel") {
|
|
269
260
|
this.state.stage = "5-send-objs";
|
|
@@ -317,9 +308,6 @@ class WIP {
|
|
|
317
308
|
return { objId, upload, src };
|
|
318
309
|
}
|
|
319
310
|
async completeDelivery() {
|
|
320
|
-
var _a;
|
|
321
|
-
// DEBUG log
|
|
322
|
-
console.log(` wip.completeDelivery() msg ${!!((_a = this.state.session) === null || _a === void 0 ? void 0 : _a.msgId)}`);
|
|
323
311
|
await this.sender.completeDelivery();
|
|
324
312
|
this.updateInfo(0, true);
|
|
325
313
|
this.state.stage = undefined;
|
|
@@ -339,17 +327,12 @@ class WIP {
|
|
|
339
327
|
* completes sending, when no more sending is left.
|
|
340
328
|
*/
|
|
341
329
|
async sendObjs() {
|
|
342
|
-
var _a, _b, _c;
|
|
343
|
-
// DEBUG log
|
|
344
|
-
console.log(` wip.sendObjs(), msgId: ${(_a = this.state.session) === null || _a === void 0 ? void 0 : _a.msgId}, p 0, \n !!this.sender is ${!!this.sender}\n this.currentObj is ${(_b = this.currentObj) === null || _b === void 0 ? void 0 : _b.objId}`);
|
|
345
330
|
if (!this.sender) {
|
|
346
331
|
this.sender = await sender_1.MailSender.resume(this.msg.r.makeNet(), this.state.recipient, this.state.session);
|
|
347
332
|
}
|
|
348
333
|
// ensure there is an object to send, or complete delivery
|
|
349
334
|
if (!this.currentObj) {
|
|
350
335
|
this.currentObj = await this.getObjToSend();
|
|
351
|
-
// DEBUG log
|
|
352
|
-
console.log(` ... this.getObjToSend() sets currentObj to be ${(_c = this.currentObj) === null || _c === void 0 ? void 0 : _c.objId}`);
|
|
353
336
|
if (!this.currentObj) {
|
|
354
337
|
return this.completeDelivery();
|
|
355
338
|
}
|
|
@@ -377,8 +360,6 @@ class WIP {
|
|
|
377
360
|
* @param obj is a message object to send
|
|
378
361
|
*/
|
|
379
362
|
async firstObjSendingRequest(obj) {
|
|
380
|
-
// DEBUG log
|
|
381
|
-
console.log(` wip.firstObjSendingRequest() ${obj.objId}`);
|
|
382
363
|
// read from source
|
|
383
364
|
const header = await obj.src.readHeader();
|
|
384
365
|
const { size, isEndless } = await obj.src.segSrc.getSize();
|
|
@@ -410,8 +391,6 @@ class WIP {
|
|
|
410
391
|
obj.upload.header = buffer_utils_1.base64.pack(header);
|
|
411
392
|
}
|
|
412
393
|
this.updateInfo(header.length + segsChunk.length);
|
|
413
|
-
// DEBUG log
|
|
414
|
-
console.log(` ... ${obj.objId} 1st/single obj request send, isObjDone is ${isObjDone}`);
|
|
415
394
|
return isObjDone;
|
|
416
395
|
}
|
|
417
396
|
/**
|
|
@@ -421,16 +400,12 @@ class WIP {
|
|
|
421
400
|
* @param obj is a message object to send
|
|
422
401
|
*/
|
|
423
402
|
async followingObjSendingRequest(obj) {
|
|
424
|
-
// DEBUG log
|
|
425
|
-
console.log(` wip.followingObjSendingRequest() ${obj.objId}`);
|
|
426
403
|
// read from source
|
|
427
404
|
const segsSize = obj.upload.expectedSegsSize;
|
|
428
405
|
const chunk = await obj.src.segSrc.readNext(this.sender.maxChunkSize);
|
|
429
406
|
// return early, when there are no bytes
|
|
430
407
|
if (!chunk) {
|
|
431
408
|
await this.sender.sendObj(obj.objId, EMPTY_BYTE_ARR, undefined, { ofs: obj.upload.segsOffset, last: true });
|
|
432
|
-
// DEBUG log
|
|
433
|
-
console.log(` ... ${obj.objId} 2nd/following obj request has no more chunk to send, and completed sending obj`);
|
|
434
409
|
return true;
|
|
435
410
|
}
|
|
436
411
|
// check for an overrun
|
|
@@ -450,8 +425,6 @@ class WIP {
|
|
|
450
425
|
await this.sender.sendObj(obj.objId, chunk, undefined, opts);
|
|
451
426
|
obj.upload.segsOffset += chunk.length;
|
|
452
427
|
this.updateInfo(chunk.length);
|
|
453
|
-
// DEBUG log
|
|
454
|
-
console.log(` ... ${obj.objId} 2nd/following obj request sent ${chunk.length} bytes, isObjDone is ${isObjDone}`);
|
|
455
428
|
return isObjDone;
|
|
456
429
|
}
|
|
457
430
|
}
|
|
@@ -153,7 +153,7 @@ class MsgPacker {
|
|
|
153
153
|
const fPath = appendedPath(fsPath, fName);
|
|
154
154
|
if (entry.isFile) {
|
|
155
155
|
await fs.readonlyFile(fName);
|
|
156
|
-
this.addFileInto(folder, fName, fPath);
|
|
156
|
+
await this.addFileInto(folder, fName, fPath);
|
|
157
157
|
}
|
|
158
158
|
else if (entry.isFolder) {
|
|
159
159
|
const f = await fs.readonlySubRoot(fName);
|
|
@@ -331,8 +331,6 @@ class MsgPacker {
|
|
|
331
331
|
if (this.hasAttachments) {
|
|
332
332
|
this.main['Attachments'] = attachments;
|
|
333
333
|
}
|
|
334
|
-
// DEBUG log
|
|
335
|
-
console.log(` message packer allObjs has ${this.allObjs.size} items`);
|
|
336
334
|
}
|
|
337
335
|
throwupOnMissingParts() {
|
|
338
336
|
if (!this.meta) {
|