core-3nweb-client-lib 0.41.1 → 0.41.3

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.
@@ -27,7 +27,8 @@ function userIdToFolderName(userId) {
27
27
  return buffer_utils_1.base64urlSafe.pack(buffer_utils_1.utf8.pack(userId));
28
28
  }
29
29
  function folderNameToUserId(folderName) {
30
- return buffer_utils_1.utf8.open(buffer_utils_1.base64urlSafe.open(folderName));
30
+ const str = buffer_utils_1.utf8.open(buffer_utils_1.base64urlSafe.open(folderName));
31
+ return (str.includes('@') ? str : undefined);
31
32
  }
32
33
  exports.UTIL_DIR = 'util';
33
34
  const INBOX_DIR = 'inbox';
@@ -70,7 +71,10 @@ function appDirs(appDir) {
70
71
  continue;
71
72
  }
72
73
  try {
73
- users.push(folderNameToUserId(entry.name));
74
+ const userId = folderNameToUserId(entry.name);
75
+ if (userId) {
76
+ users.push(userId);
77
+ }
74
78
  }
75
79
  catch (e) {
76
80
  continue;
@@ -96,9 +96,11 @@ class CorrespondentKeys {
96
96
  */
97
97
  mapAllKeysIntoRing() {
98
98
  // index key pairs
99
- const pairs = [this.keys.receptionPairs.suggested,
99
+ const pairs = [
100
+ this.keys.receptionPairs.suggested,
100
101
  this.keys.receptionPairs.inUse,
101
- this.keys.receptionPairs.old];
102
+ this.keys.receptionPairs.old
103
+ ];
102
104
  const email = this.correspondent;
103
105
  pairs.forEach(pair => {
104
106
  if (!pair) {
@@ -156,7 +158,7 @@ class CorrespondentKeys {
156
158
  return false;
157
159
  }
158
160
  const now = Date.now();
159
- if ((this.keys.sendingPair.sentMsgs.lastTS + MIN_PERIOD_FOR_PAIR) < now) {
161
+ if ((this.keys.sendingPair.timestamp + MIN_PERIOD_FOR_PAIR) > now) {
160
162
  return false;
161
163
  }
162
164
  return true;
@@ -173,6 +175,7 @@ class CorrespondentKeys {
173
175
  }
174
176
  const mp = this.keys.receptionPairs.inUse;
175
177
  this.keys.receptionPairs.inUse = this.keys.receptionPairs.suggested;
178
+ this.keys.receptionPairs.suggested = null;
176
179
  if (mp) {
177
180
  const dp = this.keys.receptionPairs.old;
178
181
  this.keys.receptionPairs.old = mp;
@@ -225,7 +228,7 @@ class CorrespondentKeys {
225
228
  && (existingPair.senderKey.pkey.kid === pair.senderKid)) {
226
229
  return;
227
230
  }
228
- if (existingPair.timestamp < pair.timestamp) {
231
+ if (existingPair.timestamp > pair.timestamp) {
229
232
  return;
230
233
  }
231
234
  }