core-3nweb-client-lib 0.49.4 → 0.49.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.
@@ -155,10 +155,10 @@ class Delivery {
155
155
  const attachments = common_1.Attachments.fromMsg(msgToSend);
156
156
  const localMeta = opts === null || opts === void 0 ? void 0 : opts.localMeta;
157
157
  // DEBUG log
158
- console.log(`\n adding message ${msgToSend.attachments ? `with attachments: ${{
158
+ console.log(`\n adding message ${msgToSend.attachments ? `with attachments: ${JSON.stringify({
159
159
  files: msgToSend.attachments.files ? Object.keys(msgToSend.attachments.files).length : 0,
160
160
  folders: msgToSend.attachments.folders ? Object.keys(msgToSend.attachments.folders).length : 0
161
- }}` : `without attachments in outgoing msg object.`}`);
161
+ })}` : `without attachments in outgoing msg object.`}`);
162
162
  // save msg, in case delivery should be restarted
163
163
  const msgFS = await this.makeFSForNewMsg(id);
164
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);
@@ -65,7 +65,6 @@ class Msg {
65
65
  this.msgFS = msgFS;
66
66
  this.sendingProc = new synced_1.SingleProc();
67
67
  this.completionPromise = undefined;
68
- // private readonly progressSavingProc = new SingleProc();
69
68
  this.cancelled = false;
70
69
  this.sender = undefined;
71
70
  this.recipients = undefined;
@@ -4,6 +4,7 @@ import { FolderInJSON } from '../../../lib-client/xsp-fs/common';
4
4
  import { MsgEnvelope, SuggestedNextKeyPair, SendingParams } from './common';
5
5
  import { Encryptor } from '../../../lib-common/async-cryptor-wrap';
6
6
  import { AsyncRNG } from '../../../lib-common/rng-def';
7
+ import type { Attachments } from '../delivery/common';
7
8
  type FS = web3n.files.FS;
8
9
  type AttachmentsContainer = web3n.asmail.AttachmentsContainer;
9
10
  type PKeyCertChain = web3n.keys.PKeyCertChain;
@@ -119,10 +120,7 @@ export declare class MsgPacker {
119
120
  setNewKeyInfo(recipientKid: string, senderPKey: string, pkeyCerts: PKeyCertChain, msgCount: number): void;
120
121
  setNextCrypto(pair: SuggestedNextKeyPair): void;
121
122
  setNextSendingParams(params: SendingParams): void;
122
- setAttachments(att: {
123
- fs: FS | undefined;
124
- container: AttachmentsContainer | undefined;
125
- }): Promise<void>;
123
+ setAttachments({ fs, container }: Attachments): Promise<void>;
126
124
  private throwupOnMissingParts;
127
125
  getSrcForMainObj(msgKeyEnc: Encryptor, cryptor: AsyncSBoxCryptor): Promise<ObjSource>;
128
126
  private getFileByteSrc;
@@ -281,7 +281,7 @@ class MsgPacker {
281
281
  setNextSendingParams(params) {
282
282
  this.main['Flow Params'].nextSendingParams = params;
283
283
  }
284
- async setAttachments(att) {
284
+ async setAttachments({ fs, container }) {
285
285
  this.throwIfAlreadyPacked();
286
286
  if (this.hasAttachments) {
287
287
  throw new Error(`Attachments are already set.`);
@@ -290,29 +290,29 @@ class MsgPacker {
290
290
  const attachments = { nodes: {}, ctime: Date.now() };
291
291
  // populate attachments json
292
292
  const path = { start: 'attachments', path: [] };
293
- if (att.container && !(0, attachments_container_1.isContainerEmpty)(att.container)) {
294
- for (const f of (0, attachments_container_1.iterFilesIn)(att.container)) {
293
+ if (container && !(0, attachments_container_1.isContainerEmpty)(container)) {
294
+ for (const f of (0, attachments_container_1.iterFilesIn)(container)) {
295
295
  const filePath = appendedPath(path, f.fileName);
296
- this.addFileInto(attachments, f.fileName, filePath);
296
+ await this.addFileInto(attachments, f.fileName, filePath);
297
297
  }
298
- for (const f of (0, attachments_container_1.iterFoldersIn)(att.container)) {
298
+ for (const f of (0, attachments_container_1.iterFoldersIn)(container)) {
299
299
  const fsPath = appendedPath(path, f.folderName);
300
300
  await this.addFolderInto(attachments, f.folderName, f.folder, fsPath);
301
301
  }
302
- this.attachmentsCont = att.container;
302
+ this.attachmentsCont = container;
303
303
  this.hasAttachments = true;
304
304
  }
305
- else if (att.fs) {
306
- const list = await att.fs.listFolder('.');
305
+ else if (fs) {
306
+ const list = await fs.listFolder('.');
307
307
  if (list.length > 0) {
308
308
  for (const entry of list) {
309
309
  const fName = entry.name;
310
310
  const fPath = appendedPath(path, fName);
311
311
  if (entry.isFile) {
312
- this.addFileInto(attachments, fName, fPath);
312
+ await this.addFileInto(attachments, fName, fPath);
313
313
  }
314
314
  else if (entry.isFolder) {
315
- const f = await att.fs.readonlySubRoot(fName);
315
+ const f = await fs.readonlySubRoot(fName);
316
316
  await this.addFolderInto(attachments, fName, f, fPath);
317
317
  }
318
318
  else {
@@ -320,7 +320,7 @@ class MsgPacker {
320
320
  continue;
321
321
  }
322
322
  }
323
- this.attachmentsFS = att.fs;
323
+ this.attachmentsFS = fs;
324
324
  this.hasAttachments = true;
325
325
  }
326
326
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.49.4",
3
+ "version": "0.49.5",
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",