core-3nweb-client-lib 0.49.3 → 0.49.4

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,6 +154,11 @@ 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: ${{
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.`}`);
157
162
  // save msg, in case delivery should be restarted
158
163
  const msgFS = await this.makeFSForNewMsg(id);
159
164
  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);
@@ -128,7 +128,11 @@ class Msg {
128
128
  await this.msgFS.writeJSONFile(MAIN_OBJ_FILE_NAME, main, { create: true, exclusive: true });
129
129
  await this.msgFS.writeJSONFile(PROGRESS_INFO_FILE_NAME, this.progress, { create: true, exclusive: true });
130
130
  if (this.attachments) {
131
- await this.attachments.linkIn(this.msgFS);
131
+ console.log(`Linking attachments ...`);
132
+ await this.attachments.linkIn(this.msgFS)
133
+ .then(
134
+ // DEBUG log
135
+ () => console.log(` .... msg attachments linked while delivery`), err => console.error(`linking attachments error:`, err));
132
136
  }
133
137
  }
134
138
  notifyOfChangesInProgress(saveProgress, saveWIPs) {
@@ -189,6 +193,8 @@ class Msg {
189
193
  msg.setSection('Cc', this.msgToSend.carbonCopy);
190
194
  msg.setSection('To', this.msgToSend.recipients);
191
195
  if (this.attachments) {
196
+ // DEBUG log
197
+ console.log(`setting attachment on messages packer`);
192
198
  await msg.setAttachments(this.attachments);
193
199
  }
194
200
  return msg;
@@ -164,6 +164,8 @@ class WIP {
164
164
  async getRecipientKeyAndEncrypt() {
165
165
  const recipient = this.sender.recipient;
166
166
  const introPKeyFromServer = await this.getIntroKeyIfRecipientIsUnknown(recipient);
167
+ // DEBUG log
168
+ console.log(`\n wip.getRecipientKeyAndEncrypt()`);
167
169
  this.packer = await this.msg.msgPacker();
168
170
  // get crypto parts for encrypting this message
169
171
  const { currentPair, encryptor, msgCount } = await this.msg.r.correspondents.generateKeysToSend(recipient, introPKeyFromServer);
@@ -191,7 +193,7 @@ class WIP {
191
193
  this.packer.setNextSendingParams(nextSendingParams);
192
194
  }
193
195
  // pack the message
194
- this.state.pack = await this.packer.pack();
196
+ this.state.pack = this.packer.pack();
195
197
  // initialize uploads info
196
198
  this.state.objUploads = new Array(this.state.pack.meta.objIds.length);
197
199
  this.state.objUploads.fill(null);
@@ -129,6 +129,6 @@ export declare class MsgPacker {
129
129
  getNewSrcForObj(objId: string, cryptor: AsyncSBoxCryptor): Promise<ObjSource>;
130
130
  getRestartedSrcForObj(objId: string, header: Uint8Array, offset: number, cryptor: AsyncSBoxCryptor): Promise<ObjSource>;
131
131
  private getSrcForNonMainObj;
132
- pack(): Promise<PackJSON>;
132
+ pack(): PackJSON;
133
133
  }
134
134
  export {};
@@ -238,9 +238,7 @@ class MsgPacker {
238
238
  if (this.meta) {
239
239
  throw new Error("Message metadata has already been set.");
240
240
  }
241
- this.meta = {
242
- pid: pid,
243
- };
241
+ this.meta = { pid };
244
242
  this.main['Flow Params'].msgCount = msgCount;
245
243
  Object.freeze(this.meta);
246
244
  }
@@ -333,6 +331,8 @@ class MsgPacker {
333
331
  if (this.hasAttachments) {
334
332
  this.main['Attachments'] = attachments;
335
333
  }
334
+ // DEBUG log
335
+ console.log(` message packer allObjs has ${this.allObjs.size} items`);
336
336
  }
337
337
  throwupOnMissingParts() {
338
338
  if (!this.meta) {
@@ -341,8 +341,7 @@ class MsgPacker {
341
341
  if (!this.wasBodySet) {
342
342
  throw new Error("Message Body is not set.");
343
343
  }
344
- if (this.meta.senderPKey &&
345
- !this.main['Flow Params'].introCerts) {
344
+ if (this.meta.senderPKey && !this.main['Flow Params'].introCerts) {
346
345
  throw new Error("Sender's key certification is missing.");
347
346
  }
348
347
  }
@@ -365,16 +364,14 @@ class MsgPacker {
365
364
  if (this.attachmentsCont) {
366
365
  const fName = path.path[0];
367
366
  if (path.path.length === 1) {
368
- const file = (this.attachmentsCont.files ?
369
- this.attachmentsCont.files[fName] : undefined);
367
+ const file = (this.attachmentsCont.files ? this.attachmentsCont.files[fName] : undefined);
370
368
  if (!file) {
371
369
  throw new Error(`File ${fName} is not found in attachments.`);
372
370
  }
373
371
  return file.getByteSource();
374
372
  }
375
373
  else {
376
- const fs = (this.attachmentsCont.folders ?
377
- this.attachmentsCont.folders[fName] : undefined);
374
+ const fs = (this.attachmentsCont.folders ? this.attachmentsCont.folders[fName] : undefined);
378
375
  if (!fs) {
379
376
  throw new Error(`Folder ${fName} is not found in attachments.`);
380
377
  }
@@ -440,7 +437,7 @@ class MsgPacker {
440
437
  }
441
438
  return src;
442
439
  }
443
- async pack() {
440
+ pack() {
444
441
  if (this.readyPack) {
445
442
  return this.readyPack;
446
443
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.49.3",
3
+ "version": "0.49.4",
4
4
  "description": "3NWeb client core library, embeddable into different environments",
5
5
  "main": "build/lib-index.js",
6
6
  "types": "build/lib-index.d.ts",