core-3nweb-client-lib 0.49.6 → 0.49.8

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.
Files changed (87) hide show
  1. package/build/api-defs/asmail.d.ts +1 -0
  2. package/build/api-defs/files.d.ts +11 -5
  3. package/build/core/asmail/delivery/common.d.ts +8 -28
  4. package/build/core/asmail/delivery/common.js +1 -47
  5. package/build/core/asmail/delivery/index.js +3 -3
  6. package/build/core/asmail/delivery/per-recipient-wip.js +3 -2
  7. package/build/core/asmail/inbox/index.d.ts +8 -32
  8. package/build/core/asmail/inbox/index.js +120 -170
  9. package/build/core/asmail/inbox/msg-indexing/dataset/v0/sql-db-v-none.d.ts +11 -0
  10. package/build/{lib-client/xsp-fs/util/for-arrays.js → core/asmail/inbox/msg-indexing/dataset/v0/sql-db-v-none.js} +7 -13
  11. package/build/core/asmail/inbox/msg-indexing/dataset/v1/logs.d.ts +33 -0
  12. package/build/core/asmail/inbox/msg-indexing/dataset/v1/logs.js +72 -0
  13. package/build/core/asmail/inbox/msg-indexing/dataset/v1/sql-db.d.ts +28 -0
  14. package/build/core/asmail/inbox/msg-indexing/dataset/v1/sql-db.js +477 -0
  15. package/build/core/asmail/inbox/msg-indexing/index.d.ts +12 -26
  16. package/build/core/asmail/inbox/msg-indexing/index.js +47 -68
  17. package/build/core/asmail/inbox/msg-on-disk.d.ts +0 -5
  18. package/build/core/asmail/inbox/msg-on-disk.js +2 -24
  19. package/build/core/asmail/index.js +8 -7
  20. package/build/core/asmail/msg/common.d.ts +0 -1
  21. package/build/core/asmail/msg/common.js +1 -1
  22. package/build/core/index.js +7 -4
  23. package/build/core/keyring/common.d.ts +1 -0
  24. package/build/core/keyring/common.js +2 -1
  25. package/build/core/keyring/index.d.ts +7 -44
  26. package/build/core/keyring/index.js +88 -222
  27. package/build/core/keyring/introductory-keys/published-intro-key.d.ts +17 -0
  28. package/build/core/keyring/introductory-keys/published-intro-key.js +190 -0
  29. package/build/core/keyring/peer-keys/dataset/v1/json-files.d.ts +105 -0
  30. package/build/core/keyring/peer-keys/dataset/v1/json-files.js +89 -0
  31. package/build/core/keyring/peer-keys/dataset/v2/logs.d.ts +43 -0
  32. package/build/core/keyring/peer-keys/dataset/v2/logs.js +116 -0
  33. package/build/core/keyring/peer-keys/dataset/v2/peer-keys-db.d.ts +73 -0
  34. package/build/core/keyring/peer-keys/dataset/v2/peer-keys-db.js +543 -0
  35. package/build/core/keyring/peer-keys/index.d.ts +24 -0
  36. package/build/core/keyring/peer-keys/index.js +208 -0
  37. package/build/core/storage/synced/obj-files.js +10 -3
  38. package/build/core/storage/synced/obj-status.d.ts +1 -1
  39. package/build/core/storage/synced/obj-status.js +8 -2
  40. package/build/core/storage/synced/storage.d.ts +4 -4
  41. package/build/core/storage/system-folders/apps-data.d.ts +0 -1
  42. package/build/core/storage/system-folders/apps-data.js +2 -6
  43. package/build/lib-client/asmail/recipient.d.ts +1 -0
  44. package/build/lib-client/asmail/recipient.js +11 -0
  45. package/build/lib-client/fs-utils/fs-sync-utils.d.ts +1 -1
  46. package/build/lib-client/fs-utils/fs-sync-utils.js +70 -13
  47. package/build/lib-client/xsp-fs/folder-node.js +13 -3
  48. package/build/lib-client/xsp-fs/fs.js +3 -1
  49. package/build/lib-client/xsp-fs/node-in-fs.d.ts +1 -0
  50. package/build/lib-client/xsp-fs/node-in-fs.js +7 -2
  51. package/build/lib-client/xsp-fs/node-persistence.js +1 -3
  52. package/build/lib-client/xsp-fs/xsp-payload-v2.js +1 -2
  53. package/build/lib-common/dataset-sync/per-device-json-array-logs.d.ts +58 -0
  54. package/build/lib-common/dataset-sync/per-device-json-array-logs.js +432 -0
  55. package/build/lib-common/dataset-sync/single-file.d.ts +10 -0
  56. package/build/lib-common/dataset-sync/single-file.js +77 -0
  57. package/build/lib-common/number-line.d.ts +10 -0
  58. package/build/lib-common/number-line.js +66 -0
  59. package/build/lib-common/objs-on-disk/obj-version-file.d.ts +1 -1
  60. package/build/lib-common/objs-on-disk/obj-version-file.js +3 -3
  61. package/build/lib-common/rng-def.d.ts +1 -0
  62. package/build/lib-common/rng-def.js +8 -0
  63. package/build/lib-sqlite-on-3nstorage/for-sqlite.d.ts +38 -0
  64. package/build/lib-sqlite-on-3nstorage/for-sqlite.js +162 -0
  65. package/build/lib-sqlite-on-3nstorage/index.d.ts +18 -5
  66. package/build/lib-sqlite-on-3nstorage/index.js +49 -26
  67. package/build/tests/caps-api/file-sink-checks/splice.js +72 -1
  68. package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.js +27 -1
  69. package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.js +12 -3
  70. package/build/tests/computer.3nweb.core/inbox/msg-indexing.js +16 -12
  71. package/build/tests/computer.3nweb.core/keyrings.js +113 -28
  72. package/build/tests/jasmine.js +2 -2
  73. package/build/tests/units/number-line.js +9 -9
  74. package/package.json +2 -1
  75. package/build/core/asmail/inbox/msg-indexing/logs-n-entries.d.ts +0 -52
  76. package/build/core/asmail/inbox/msg-indexing/logs-n-entries.js +0 -333
  77. package/build/core/asmail/inbox/msg-indexing/sql-indexing.d.ts +0 -4
  78. package/build/core/asmail/inbox/msg-indexing/sql-indexing.js +0 -319
  79. package/build/core/keyring/correspondent-keys.d.ts +0 -149
  80. package/build/core/keyring/correspondent-keys.js +0 -403
  81. package/build/core/keyring/id-to-email-map.d.ts +0 -38
  82. package/build/core/keyring/id-to-email-map.js +0 -105
  83. package/build/core/keyring/keyring-storage.d.ts +0 -9
  84. package/build/core/keyring/keyring-storage.js +0 -54
  85. package/build/core/keyring/published-intro-key.d.ts +0 -45
  86. package/build/core/keyring/published-intro-key.js +0 -200
  87. package/build/lib-client/xsp-fs/util/for-arrays.d.ts +0 -1
@@ -299,6 +299,7 @@ declare namespace web3n.asmail {
299
299
  objNotFound?: true;
300
300
  objId?: string;
301
301
  msgIsBroken?: true;
302
+ failToDecrypt?: true;
302
303
  }
303
304
 
304
305
  interface ASMailSendException extends RuntimeException {
@@ -314,7 +314,7 @@ declare namespace web3n.files {
314
314
  * sink with this error. When err is given, no errors will be thrown back
315
315
  * to this call.
316
316
  */
317
- done(err?: any, xattrChanges?: XAttrsChanges): Promise<void>;
317
+ done(err?: any): Promise<void>;
318
318
 
319
319
  }
320
320
 
@@ -1178,27 +1178,33 @@ declare namespace web3n.files {
1178
1178
  type RemoteEvent = RemoteVersionArchivalEvent | RemoteArchVerRemovalEvent |
1179
1179
  RemoteRemovalEvent | RemoteChangeEvent;
1180
1180
 
1181
+ /**
1182
+ * SyncStatus has fields that connect to item's parent, uploading, i.e. not just state of the item.
1183
+ * Hence, we pick only related fields.
1184
+ */
1185
+ type ItemSyncStatus = Pick<SyncStatus, 'state' | 'remote' | 'synced' | 'local'>;
1186
+
1181
1187
  interface RemoteVersionArchivalEvent extends FSEvent {
1182
1188
  type: 'remote-version-archival';
1183
1189
  archivedVersion: number;
1184
- syncStatus: SyncStatus;
1190
+ syncStatus: ItemSyncStatus;
1185
1191
  }
1186
1192
 
1187
1193
  interface RemoteArchVerRemovalEvent extends FSEvent {
1188
1194
  type: 'remote-arch-ver-removal';
1189
1195
  removedArchVer: number;
1190
- syncStatus: SyncStatus;
1196
+ syncStatus: ItemSyncStatus;
1191
1197
  }
1192
1198
 
1193
1199
  interface RemoteRemovalEvent extends FSEvent {
1194
1200
  type: 'remote-removal';
1195
- syncStatus: SyncStatus;
1201
+ syncStatus: ItemSyncStatus;
1196
1202
  }
1197
1203
 
1198
1204
  interface RemoteChangeEvent extends FSEvent {
1199
1205
  type: 'remote-change';
1200
1206
  newRemoteVersion: number;
1201
- syncStatus: SyncStatus;
1207
+ syncStatus: ItemSyncStatus;
1202
1208
  }
1203
1209
 
1204
1210
  type UploadEvent = UploadStartEvent | UploadProgressEvent | UploadDisconnectedEvent | UploadDoneEvent;
@@ -40,22 +40,17 @@ export interface ResourcesForSending {
40
40
  * @param address
41
41
  */
42
42
  needIntroKeyFor(address: string): boolean;
43
- /**
44
- * This function generates keys that are needed to send a message, i.e.
45
- * current crypto encryptor and identifiers to place in message's meta.
46
- * Returned object has following fields:
47
- * (a) encryptor - with encryptor, which should be used to pack message's
48
- * main part's key,
49
- * (b) currentPair - contains sendable form for current key pair.
50
- * (c) msgCount - message count for a current pair.
51
- * @param address
52
- * @param introPKeyFromServer is an optional recipient's key from a mail
53
- * server.
54
- */
55
- generateKeysToSend: (address: string, introPKeyFromServer?: JsonKey) => Promise<{
43
+ getEstablishedKeysToSendMsg: (address: string) => Promise<{
44
+ encryptor: Encryptor;
45
+ currentPair: ASMailKeyPair;
46
+ msgCount: number;
47
+ nextMsgCrypto?: SuggestedNextKeyPair;
48
+ }>;
49
+ generateIntroKeysToSendMsg: (address: string, introPKey: JsonKey) => Promise<{
56
50
  encryptor: Encryptor;
57
51
  currentPair: ASMailKeyPair;
58
52
  msgCount: number;
53
+ nextMsgCrypto?: SuggestedNextKeyPair;
59
54
  }>;
60
55
  /**
61
56
  * This function returns sending parameters that should be used now to
@@ -64,11 +59,6 @@ export interface ResourcesForSending {
64
59
  * @param address
65
60
  */
66
61
  paramsForSendingTo: (address: string) => SendingParams | undefined;
67
- /**
68
- * This function returns next key pair
69
- * @param address
70
- */
71
- nextCrypto: (address: string) => Promise<SuggestedNextKeyPair | undefined>;
72
62
  /**
73
63
  * This returns a new sending parameters that given address should use to
74
64
  * send messages back. Undefined is returned, if current parameters don't
@@ -89,14 +79,4 @@ export interface SavedMsgToSend {
89
79
  recipients: string[];
90
80
  retryOpts: DeliveryOptions['retryRecipient'];
91
81
  }
92
- /**
93
- * This is a utility function that adds a number into given number line
94
- * segments. Each segment is represented by an array, in which 0-th element is
95
- * the smallest number in the segment, while 1-st element is the largest.
96
- * Segments don't overlap and are ordered as they would on a number line:
97
- * segment with smaller numbers go first.
98
- * @param segments
99
- * @param n
100
- */
101
- export declare function addToNumberLineSegments(segments: number[][], n: number): void;
102
82
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2016 - 2017, 2020 3NSoft Inc.
3
+ Copyright (C) 2016 - 2017, 2020, 2026 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
@@ -18,7 +18,6 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.SEG_SIZE_IN_K_QUATS = exports.Attachments = void 0;
20
20
  exports.estimatePackedSizeOf = estimatePackedSizeOf;
21
- exports.addToNumberLineSegments = addToNumberLineSegments;
22
21
  const attachments_container_1 = require("../msg/attachments-container");
23
22
  const buffer_utils_1 = require("../../../lib-common/buffer-utils");
24
23
  const ATTACHMENTS_NAME = 'attachments';
@@ -139,49 +138,4 @@ function estimatePackedSizeOf(size) {
139
138
  }
140
139
  return 148 + numOfCompleteSegs * exports.SEG_SIZE_IN_K_QUATS * 256 + lastSegSize;
141
140
  }
142
- /**
143
- * This is a utility function that adds a number into given number line
144
- * segments. Each segment is represented by an array, in which 0-th element is
145
- * the smallest number in the segment, while 1-st element is the largest.
146
- * Segments don't overlap and are ordered as they would on a number line:
147
- * segment with smaller numbers go first.
148
- * @param segments
149
- * @param n
150
- */
151
- function addToNumberLineSegments(segments, n) {
152
- for (let i = (segments.length - 1); i >= 0; i -= 1) {
153
- const [low, high] = segments[i];
154
- if (high < n) {
155
- if ((high + 1) >= n) {
156
- // segment should be grown on a high side.
157
- // But now bigger segment won't merge with higher segment, cause if
158
- // it does, it would've merge from lower side of a higher segment.
159
- segments[i][1] = n;
160
- }
161
- else {
162
- // new segment should be added higher than this one
163
- segments.splice(i + 1, 0, [n, n]);
164
- }
165
- return;
166
- }
167
- if ((low <= n) && (n <= high)) {
168
- // do nothing as number falls into current segment
169
- return;
170
- }
171
- if (low <= (n + 1)) {
172
- // segment should be grown on a lower side
173
- segments[i][0] = n;
174
- if ((i - 1) >= 0) {
175
- // bigger segment may overlap with a lower one
176
- const lowerSeg = segments[i - 1];
177
- if ((lowerSeg[1] + 1) >= n) {
178
- lowerSeg[1] = high;
179
- segments.splice(i, 1);
180
- }
181
- }
182
- return;
183
- }
184
- }
185
- segments.unshift([n, n]);
186
- }
187
141
  Object.freeze(exports);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2016 - 2017, 2020 - 2023 3NSoft Inc.
3
+ Copyright (C) 2016 - 2017, 2020 - 2023, 2026 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,8 @@ const utils_for_observables_1 = require("../../../lib-common/utils-for-observabl
28
28
  const SMALL_MSG_SIZE = 1024 * 1024;
29
29
  const MSGS_FOLDER = 'msgs';
30
30
  function idToMsgFolder(id) {
31
- if (id.indexOf('/') > -1) {
32
- throw new Error(`Message id ${id} contains illegal character '/'.`);
31
+ if (id.includes('/') || id.includes('.')) {
32
+ throw new Error(`Message id ${id} contains illegal character(s).`);
33
33
  }
34
34
  return `${MSGS_FOLDER}/${id}`;
35
35
  }
@@ -161,7 +161,9 @@ class WIP {
161
161
  const introPKeyFromServer = await this.getIntroKeyIfRecipientIsUnknown(recipient);
162
162
  this.packer = await this.msg.msgPacker();
163
163
  // get crypto parts for encrypting this message
164
- const { currentPair, encryptor, msgCount } = await this.msg.r.correspondents.generateKeysToSend(recipient, introPKeyFromServer);
164
+ const { currentPair, encryptor, msgCount, nextMsgCrypto } = await (introPKeyFromServer ?
165
+ this.msg.r.correspondents.generateIntroKeysToSendMsg(recipient, introPKeyFromServer) :
166
+ this.msg.r.correspondents.getEstablishedKeysToSendMsg(recipient));
165
167
  // add crypto parameters to the message
166
168
  if (currentPair.pid) {
167
169
  this.packer.setEstablishedKeyPairInfo(currentPair.pid, msgCount);
@@ -176,7 +178,6 @@ class WIP {
176
178
  this.packer.setNewKeyInfo(currentPair.recipientKid, currentPair.senderPKey.k, pkCerts, msgCount);
177
179
  }
178
180
  // add next crypto parameters to the message
179
- const nextMsgCrypto = await this.msg.r.correspondents.nextCrypto(recipient);
180
181
  if (nextMsgCrypto) {
181
182
  this.packer.setNextCrypto(nextMsgCrypto);
182
183
  }
@@ -72,36 +72,12 @@ export interface ResourcesForReceiving {
72
72
  * messages have not been removed via direct action or due to expiry.
73
73
  * This object is also responsible for expiring messages on the server.
74
74
  */
75
- export declare class InboxOnServer {
76
- private readonly r;
77
- private readonly msgReceiver;
78
- private readonly storages;
79
- private readonly cryptor;
80
- private readonly random;
81
- private readonly downloader;
82
- private readonly cache;
83
- private readonly index;
84
- private readonly logError;
85
- private readonly inboxEvents;
86
- private readonly procs;
87
- private readonly recentlyOpenedMsgs;
88
- private constructor();
89
- static makeAndStart(cachePath: string, syncedFS: WritableFS, r: ResourcesForReceiving): Promise<InboxOnServer>;
90
- close(): Promise<void>;
91
- makeCAP(): InboxService;
92
- private removeMsg;
93
- private removeMsgFromServerAndCache;
94
- private msgFromDiskOrDownload;
95
- private startCachingAndAddKeyToIndex;
96
- private markOwnParams;
97
- private absorbSendingParams;
98
- private checkServerAuthIfPresent;
99
- private listMsgs;
100
- private listNewMsgs;
101
- private getMsg;
102
- private msgToUIForm;
103
- suspendNetworkActivity(): void;
104
- resumeNetworkActivity(): void;
105
- get connectivityEvent$(): import("rxjs").Observable<import("./inbox-events").InboxConnectionStatus>;
106
- }
75
+ export type InboxOnServer = Awaited<ReturnType<typeof makeInboxOnServer>>;
76
+ export declare function makeInboxOnServer(cachePath: string, syncedFS: WritableFS, localFS: WritableFS, r: ResourcesForReceiving): Promise<{
77
+ connectivityEvent$: import("rxjs").Observable<import("./inbox-events").InboxConnectionStatus>;
78
+ resumeNetworkActivity: () => void;
79
+ suspendNetworkActivity: () => void;
80
+ close: () => Promise<void>;
81
+ makeCAP: () => InboxService;
82
+ }>;
107
83
  export {};