@wireapp/core 42.19.0 → 42.19.2

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 (36) hide show
  1. package/lib/Account.d.ts +7 -3
  2. package/lib/Account.d.ts.map +1 -1
  3. package/lib/Account.js +15 -6
  4. package/lib/conversation/ConversationService/ConversationService.d.ts +3 -2
  5. package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
  6. package/lib/conversation/ConversationService/ConversationService.js +3 -2
  7. package/lib/conversation/ConversationService/ConversationService.test.js +2 -1
  8. package/lib/conversation/SubconversationService/SubconversationService.d.ts +71 -0
  9. package/lib/conversation/SubconversationService/SubconversationService.d.ts.map +1 -0
  10. package/lib/conversation/SubconversationService/SubconversationService.js +221 -0
  11. package/lib/conversation/SubconversationService/SubconversationService.test.d.ts +2 -0
  12. package/lib/conversation/SubconversationService/SubconversationService.test.d.ts.map +1 -0
  13. package/lib/conversation/SubconversationService/SubconversationService.test.js +374 -0
  14. package/lib/conversation/SubconversationService/subconversationUtil.d.ts +4 -0
  15. package/lib/conversation/SubconversationService/subconversationUtil.d.ts.map +1 -0
  16. package/lib/conversation/SubconversationService/subconversationUtil.js +25 -0
  17. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts +4 -1
  18. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
  19. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +2 -2
  20. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.js +8 -8
  21. package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +2 -36
  22. package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
  23. package/lib/messagingProtocols/mls/MLSService/MLSService.js +8 -94
  24. package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +5 -4
  25. package/lib/messagingProtocols/mls/types.d.ts +2 -3
  26. package/lib/messagingProtocols/mls/types.d.ts.map +1 -1
  27. package/lib/storage/CoreDB.d.ts +10 -0
  28. package/lib/storage/CoreDB.d.ts.map +1 -1
  29. package/lib/storage/CoreDB.js +3 -1
  30. package/package.json +3 -3
  31. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.d.ts +0 -13
  32. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.d.ts.map +0 -1
  33. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.js +0 -67
  34. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.d.ts +0 -2
  35. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.d.ts.map +0 -1
  36. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.js +0 -72
@@ -33,15 +33,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
35
  exports.MLSService = exports.optionalToUint8Array = void 0;
36
- const conversation_1 = require("@wireapp/api-client/lib/conversation");
37
36
  const http_1 = require("@wireapp/api-client/lib/http");
38
- const TimeUtil_1 = require("@wireapp/commons/lib/util/TimeUtil");
39
37
  const bazinga64_1 = require("bazinga64");
40
38
  const logdown_1 = __importDefault(require("logdown"));
41
39
  const commons_1 = require("@wireapp/commons");
42
40
  const core_crypto_1 = require("@wireapp/core-crypto");
43
41
  const CoreCryptoMLSError_1 = require("./CoreCryptoMLSError");
44
- const subconversationGroupIdStore_1 = require("./stores/subconversationGroupIdStore/subconversationGroupIdStore");
45
42
  const messageSender_1 = require("../../../conversation/message/messageSender");
46
43
  const fullyQualifiedClientIdUtils_1 = require("../../../util/fullyQualifiedClientIdUtils");
47
44
  const numberToHex_1 = require("../../../util/numberToHex");
@@ -150,6 +147,12 @@ class MLSService extends commons_1.TypedEventEmitter {
150
147
  async initClient(userId, client) {
151
148
  const qualifiedClientId = (0, fullyQualifiedClientIdUtils_1.constructFullyQualifiedClientId)(userId.id, client.id, userId.domain);
152
149
  await this.coreCryptoClient.mlsInit(this.textEncoder.encode(qualifiedClientId), [this.config.defaultCiphersuite], this.config.nbKeyPackages);
150
+ await this.coreCryptoClient.registerCallbacks({
151
+ // All authorization/membership rules are enforced on backend
152
+ clientIsExistingGroupUser: async () => true,
153
+ authorize: async () => true,
154
+ userAuthorize: async () => true,
155
+ });
153
156
  // We need to make sure keypackages and public key are uploaded to the backend
154
157
  await this.uploadMLSPublicKeys(client);
155
158
  await this.verifyRemoteMLSKeyPackagesAmount(client.id);
@@ -168,14 +171,6 @@ class MLSService extends commons_1.TypedEventEmitter {
168
171
  }
169
172
  return this.processCommitAction(groupIdBytes, () => this.coreCryptoClient.addClientsToConversation(groupIdBytes, invitee));
170
173
  }
171
- configureMLSCallbacks(_a) {
172
- var { groupIdFromConversationId } = _a, coreCryptoCallbacks = __rest(_a, ["groupIdFromConversationId"]);
173
- void this.coreCryptoClient.registerCallbacks(Object.assign(Object.assign({}, coreCryptoCallbacks), { clientIsExistingGroupUser: (_groupId, _client, _otherClients) => {
174
- // All authorization/membership rules are enforced on backend
175
- return Promise.resolve(true);
176
- } }));
177
- this.groupIdFromConversationId = groupIdFromConversationId;
178
- }
179
174
  async getKeyPackagesPayload(qualifiedUsers) {
180
175
  /**
181
176
  * @note We need to fetch key packages for all the users
@@ -239,74 +234,6 @@ class MLSService extends commons_1.TypedEventEmitter {
239
234
  }
240
235
  return mlsResponse;
241
236
  }
242
- async getConferenceSubconversation(conversationId) {
243
- return this.apiClient.api.conversation.getSubconversation(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
244
- }
245
- async deleteConferenceSubconversation(conversationId, data) {
246
- return this.apiClient.api.conversation.deleteSubconversation(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE, data);
247
- }
248
- /**
249
- * Will leave conference subconversation if it's known by client and established.
250
- *
251
- * @param conversationId Id of the parent conversation which subconversation we want to leave
252
- */
253
- async leaveConferenceSubconversation(conversationId) {
254
- const subconversationGroupId = subconversationGroupIdStore_1.subconversationGroupIdStore.getGroupId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
255
- if (!subconversationGroupId) {
256
- return;
257
- }
258
- const isSubconversationEstablished = await this.conversationExists(subconversationGroupId);
259
- if (!isSubconversationEstablished) {
260
- // if the subconversation was known by a client but is not established anymore, we can remove it from the store
261
- return subconversationGroupIdStore_1.subconversationGroupIdStore.removeGroupId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
262
- }
263
- try {
264
- await this.apiClient.api.conversation.deleteSubconversationSelf(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
265
- }
266
- catch (error) {
267
- this.logger.error(`Failed to leave conference subconversation:`, error);
268
- }
269
- await this.wipeConversation(subconversationGroupId);
270
- // once we've left the subconversation, we can remove it from the store
271
- subconversationGroupIdStore_1.subconversationGroupIdStore.removeGroupId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
272
- }
273
- async leaveStaleConferenceSubconversations() {
274
- const conversationIds = subconversationGroupIdStore_1.subconversationGroupIdStore.getAllGroupIdsBySubconversationId(conversation_1.SUBCONVERSATION_ID.CONFERENCE);
275
- for (const { parentConversationId } of conversationIds) {
276
- await this.leaveConferenceSubconversation(parentConversationId);
277
- }
278
- }
279
- /**
280
- * Will join or register an mls subconversation for conference calls.
281
- * Will return the secret key derived from the subconversation
282
- *
283
- * @param conversationId Id of the parent conversation in which the call should happen
284
- */
285
- async joinConferenceSubconversation(conversationId) {
286
- const subconversation = await this.getConferenceSubconversation(conversationId);
287
- if (subconversation.epoch === 0) {
288
- // if subconversation is not yet established, create it
289
- await this.registerConversation(subconversation.group_id, []);
290
- }
291
- else {
292
- const epochUpdateTime = new Date(subconversation.epoch_timestamp).getTime();
293
- const epochAge = new Date().getTime() - epochUpdateTime;
294
- if (epochAge > TimeUtil_1.TimeInMillis.DAY) {
295
- // if subconversation does exist, but it's older than 24h, delete and re-join
296
- await this.deleteConferenceSubconversation(conversationId, {
297
- groupId: subconversation.group_id,
298
- epoch: subconversation.epoch,
299
- });
300
- await this.wipeConversation(subconversation.group_id);
301
- return this.joinConferenceSubconversation(conversationId);
302
- }
303
- await this.joinByExternalCommit(() => this.apiClient.api.conversation.getSubconversationGroupInfo(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE));
304
- }
305
- const epoch = Number(await this.getEpoch(subconversation.group_id));
306
- // We store the mapping between the subconversation and the parent conversation
307
- subconversationGroupIdStore_1.subconversationGroupIdStore.storeGroupId(conversationId, subconversation.subconv_id, subconversation.group_id);
308
- return { groupId: subconversation.group_id, epoch };
309
- }
310
237
  async exportSecretKey(groupId, keyLength) {
311
238
  const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
312
239
  const key = await this.coreCryptoClient.exportSecretKey(groupIdBytes, keyLength);
@@ -565,19 +492,6 @@ class MLSService extends commons_1.TypedEventEmitter {
565
492
  const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
566
493
  return this.coreCryptoClient.wipeConversation(groupIdBytes);
567
494
  }
568
- /**
569
- * If there is a matching conversationId => groupId pair in the database,
570
- * we can find the groupId and return it as a string
571
- *
572
- * @param conversationQualifiedId
573
- */
574
- async getGroupIdFromConversationId(conversationQualifiedId, subconversationId) {
575
- var _a;
576
- const groupId = subconversationId
577
- ? subconversationGroupIdStore_1.subconversationGroupIdStore.getGroupId(conversationQualifiedId, subconversationId)
578
- : await ((_a = this.groupIdFromConversationId) === null || _a === void 0 ? void 0 : _a.call(this, conversationQualifiedId));
579
- return groupId;
580
- }
581
495
  /**
582
496
  * If there are pending proposals, we need to either process them,
583
497
  * or save them in the database for later processing
@@ -662,8 +576,8 @@ class MLSService extends commons_1.TypedEventEmitter {
662
576
  });
663
577
  return clientIds;
664
578
  }
665
- async handleMLSMessageAddEvent(event) {
666
- return (0, events_1.handleMLSMessageAdd)({ event, mlsService: this });
579
+ async handleMLSMessageAddEvent(event, groupIdFromConversationId) {
580
+ return (0, events_1.handleMLSMessageAdd)({ event, mlsService: this, groupIdFromConversationId });
667
581
  }
668
582
  async handleMLSWelcomeMessageEvent(event, clientId) {
669
583
  // Every time we've received a welcome message, it means that our key package was consumed,
@@ -46,6 +46,7 @@ const createMLSService = async () => {
46
46
  decryptMessage: jest.fn(),
47
47
  conversationEpoch: jest.fn(),
48
48
  commitPendingProposals: jest.fn(),
49
+ registerCallbacks: jest.fn(),
49
50
  };
50
51
  const mockedDb = await (0, CoreDB_1.openDB)('core-test-db');
51
52
  const recurringTaskScheduler = new RecurringTaskScheduler_1.RecurringTaskScheduler({
@@ -196,7 +197,7 @@ describe('MLSService', () => {
196
197
  const [mlsService, { coreCrypto: mockCoreCrypto }] = await createMLSService();
197
198
  const mockGroupId = 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm3OQFc=';
198
199
  const mockedNewEpoch = 3;
199
- jest.spyOn(mlsService, 'getGroupIdFromConversationId').mockResolvedValueOnce(mockGroupId);
200
+ const getGroupIdFromConversationId = () => Promise.resolve(mockGroupId);
200
201
  const mockedDecryptoedMessage = {
201
202
  hasEpochChanged: true,
202
203
  isActive: false,
@@ -213,7 +214,7 @@ describe('MLSService', () => {
213
214
  from: '',
214
215
  time: '',
215
216
  };
216
- await mlsService.handleMLSMessageAddEvent(mockedMLSWelcomeEvent);
217
+ await mlsService.handleMLSMessageAddEvent(mockedMLSWelcomeEvent, getGroupIdFromConversationId);
217
218
  expect(mockCoreCrypto.decryptMessage).toHaveBeenCalled();
218
219
  expect(mlsService.emit).toHaveBeenCalledWith('newEpoch', { epoch: mockedNewEpoch, groupId: mockGroupId });
219
220
  });
@@ -223,7 +224,7 @@ describe('MLSService', () => {
223
224
  const mockGroupId = 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm3OQFc=';
224
225
  const mockedNewEpoch = 3;
225
226
  const commitDelay = 1000;
226
- jest.spyOn(mlsService, 'getGroupIdFromConversationId').mockResolvedValueOnce(mockGroupId);
227
+ const getGroupIdFromConversationId = () => Promise.resolve(mockGroupId);
227
228
  const mockedDecryptoedMessage = {
228
229
  hasEpochChanged: true,
229
230
  isActive: false,
@@ -241,7 +242,7 @@ describe('MLSService', () => {
241
242
  from: '',
242
243
  time: new Date().toISOString(),
243
244
  };
244
- await mlsService.handleMLSMessageAddEvent(mockedMLSWelcomeEvent);
245
+ await mlsService.handleMLSMessageAddEvent(mockedMLSWelcomeEvent, getGroupIdFromConversationId);
245
246
  expect(mockCoreCrypto.commitPendingProposals).not.toHaveBeenCalled();
246
247
  jest.advanceTimersByTime(commitDelay);
247
248
  expect(mockCoreCrypto.decryptMessage).toHaveBeenCalled();
@@ -1,5 +1,4 @@
1
1
  import { QualifiedId } from '@wireapp/api-client/lib/user';
2
- import { CoreCryptoCallbacks } from '@wireapp/core-crypto';
3
2
  import { MLSServiceConfig } from './MLSService/MLSService.types';
4
3
  export type ClientId = string;
5
4
  export type SecretCrypto = {
@@ -11,12 +10,12 @@ export type SecretCrypto = {
11
10
  decrypt: (payload: Uint8Array) => Promise<string>;
12
11
  version: 1;
13
12
  };
14
- export interface MLSCallbacks extends Pick<CoreCryptoCallbacks, 'authorize' | 'userAuthorize'> {
13
+ export interface CoreCallbacks {
15
14
  /**
16
15
  * Should return a groupId corresponding to the conversation ID given
17
16
  * Used for the core to know what core-crypto conversation we are dealing with when receiving events
18
17
  * @param conversationId
19
- * @returns the bytes of the groupId corresponding to the conversation ID
18
+ * @returns the groupId corresponding to the conversation ID
20
19
  */
21
20
  groupIdFromConversationId: (conversationId: QualifiedId) => Promise<string | undefined>;
22
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/messagingProtocols/mls/types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,OA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,CAAC,EAAE,YAAY,CAAC;IAE5B,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAE9B,uEAAuE;IACvE,GAAG,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEhC,oKAAoK;IACpK,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
@@ -1,3 +1,5 @@
1
+ import { SUBCONVERSATION_ID } from '@wireapp/api-client/lib/conversation';
2
+ import { QualifiedId } from '@wireapp/api-client/lib/user';
1
3
  import { DBSchema, IDBPDatabase } from 'idb';
2
4
  interface CoreDBSchema extends DBSchema {
3
5
  prekeys: {
@@ -28,6 +30,14 @@ interface CoreDBSchema extends DBSchema {
28
30
  domain: string;
29
31
  };
30
32
  };
33
+ subconversations: {
34
+ key: string;
35
+ value: {
36
+ parentConversationId: QualifiedId;
37
+ subconversationId: SUBCONVERSATION_ID;
38
+ groupId: string;
39
+ };
40
+ };
31
41
  }
32
42
  export type CoreDatabase = IDBPDatabase<CoreDBSchema>;
33
43
  export declare function openDB(dbName: string): Promise<CoreDatabase>;
@@ -1 +1 @@
1
- {"version":3,"file":"CoreDB.d.ts","sourceRoot":"","sources":["../../src/storage/CoreDB.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,QAAQ,EAA2B,YAAY,EAAsB,MAAM,KAAK,CAAC;AAGzF,UAAU,YAAa,SAAQ,QAAQ;IACrC,OAAO,EAAE;QACP,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE;YAAC,SAAS,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAC,CAAC;KAC/C,CAAC;IACF,gBAAgB,EAAE;QAChB,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAC,CAAC;KAC9C,CAAC;IACF,cAAc,EAAE;QACd,GAAG,EAAE,MA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ACF,qBAAqB,EAAE;QACrB,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE;YAAC,EAAE,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAC,CAAC;KACrC,CAAC;IACF,gBAAgB,EAAE;QAChB,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE;YAAC,oBAAoB,EAAE,WAAW,CAAC;YAAC,iBAAiB,EAAE,kBAAkB,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAC,CAAC;KACpG,CAAC;CACH;AAED,MAAM,MAAM,YAAY,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAEtD,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAmBlE;AAED,wBAAsB,QAAQ,CAAC,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9D"}
@@ -20,7 +20,7 @@
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.deleteDB = exports.openDB = void 0;
22
22
  const idb_1 = require("idb");
23
- const VERSION = 4;
23
+ const VERSION = 5;
24
24
  async function openDB(dbName) {
25
25
  const db = await (0, idb_1.openDB)(dbName, VERSION, {
26
26
  upgrade: (db, oldVersion) => {
@@ -34,6 +34,8 @@ async function openDB(dbName) {
34
34
  db.createObjectStore('recurringTasks');
35
35
  case 3:
36
36
  db.createObjectStore('conversationBlacklist');
37
+ case 4:
38
+ db.createObjectStore('subconversations');
37
39
  }
38
40
  },
39
41
  });
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
12
12
  },
13
13
  "dependencies": {
14
- "@wireapp/api-client": "^26.5.0",
14
+ "@wireapp/api-client": "^26.5.1",
15
15
  "@wireapp/commons": "^5.2.2",
16
16
  "@wireapp/core-crypto": "1.0.0-rc.16",
17
17
  "@wireapp/cryptobox": "12.8.0",
@@ -61,6 +61,6 @@
61
61
  "test:coverage": "jest --coverage",
62
62
  "watch": "tsc --watch"
63
63
  },
64
- "version": "42.19.0",
65
- "gitHead": "5ecc27e935400844c53aa6164210cb4f9846a1dd"
64
+ "version": "42.19.2",
65
+ "gitHead": "96506c0e52f08f30c956c8b6a067d1e9e3e1abd2"
66
66
  }
@@ -1,13 +0,0 @@
1
- import { SUBCONVERSATION_ID } from '@wireapp/api-client/lib/conversation';
2
- import { QualifiedId } from '@wireapp/api-client/lib/user';
3
- export declare const subconversationGroupIdStore: {
4
- storeGroupId: (parentConversationId: QualifiedId, subconversationId: SUBCONVERSATION_ID, subconversationGroupId: string) => void;
5
- getGroupId: (parentConversationId: QualifiedId, subconversationId: SUBCONVERSATION_ID) => string | undefined;
6
- removeGroupId: (parentConversationId: QualifiedId, subconversationId: SUBCONVERSATION_ID) => void;
7
- getAllGroupIdsBySubconversationId: (subconversationIdQuery: SUBCONVERSATION_ID) => {
8
- subconversationGroupId: string;
9
- parentConversationId: QualifiedId;
10
- subconversationId: SUBCONVERSATION_ID;
11
- }[];
12
- };
13
- //# sourceMappingURL=subconversationGroupIdStore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subconversationGroupIdStore.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAgEzD,eAAO,MAAM,2BAA2B;yCA3BhB,WAAW,qBACd,kBAAkB,0BACb,MAAM;uCAMU,WAAW,qBAAqB,kBAAkB;0CAc/C,WAAW,qBAAqB,kBAAkB;gEAT5B,kBAAkB;;8BArC3D,WAAW;2BAAqB,kBAAkB;;CAwD3E,CAAC"}
@@ -1,67 +0,0 @@
1
- "use strict";
2
- /*
3
- * Wire
4
- * Copyright (C) 2023 Wire Swiss GmbH
5
- *
6
- * This program is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see http://www.gnu.org/licenses/.
18
- *
19
- */
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.subconversationGroupIdStore = void 0;
22
- const storageKey = 'subconversationGroupIdStore';
23
- const generateSubconversationStoreKey = (parentConversationId, subconversationId) => {
24
- return `${parentConversationId.id}@${parentConversationId.domain}:${subconversationId}`;
25
- };
26
- const parseSubconversationStoreKey = (subconversationStoreKey) => {
27
- const [parentConversationId, subconversationId] = subconversationStoreKey.split(':');
28
- const [id, domain] = parentConversationId.split('@');
29
- return { parentConversationId: { domain, id }, subconversationId };
30
- };
31
- const getCurrentMap = () => {
32
- const storedEntry = localStorage.getItem(storageKey);
33
- return storedEntry ? new Map(JSON.parse(storedEntry)) : new Map();
34
- };
35
- const addItemToMap = (subconversationId, subgroupId) => {
36
- const currentMap = getCurrentMap();
37
- currentMap.set(subconversationId, subgroupId);
38
- localStorage.setItem(storageKey, JSON.stringify(Array.from(currentMap.entries())));
39
- };
40
- const removeItemFromMap = (subconversationId) => {
41
- const currentMap = getCurrentMap();
42
- currentMap.delete(subconversationId);
43
- localStorage.setItem(storageKey, JSON.stringify(Array.from(currentMap.entries())));
44
- };
45
- const storeGroupId = (parentConversationId, subconversationId, subconversationGroupId) => {
46
- const subconversationStoreKey = generateSubconversationStoreKey(parentConversationId, subconversationId);
47
- addItemToMap(subconversationStoreKey, subconversationGroupId);
48
- };
49
- const getGroupId = (parentConversationId, subconversationId) => {
50
- const subconversationStoreKey = generateSubconversationStoreKey(parentConversationId, subconversationId);
51
- return getCurrentMap().get(subconversationStoreKey);
52
- };
53
- const getAllGroupIdsBySubconversationId = (subconversationIdQuery) => {
54
- return Array.from(getCurrentMap().entries())
55
- .map(([subconversationId, subconversationGroupId]) => (Object.assign(Object.assign({}, parseSubconversationStoreKey(subconversationId)), { subconversationGroupId })))
56
- .filter(({ subconversationId }) => subconversationId === subconversationIdQuery);
57
- };
58
- const removeGroupId = (parentConversationId, subconversationId) => {
59
- const subconversationStoreKey = generateSubconversationStoreKey(parentConversationId, subconversationId);
60
- return removeItemFromMap(subconversationStoreKey);
61
- };
62
- exports.subconversationGroupIdStore = {
63
- storeGroupId,
64
- getGroupId,
65
- removeGroupId,
66
- getAllGroupIdsBySubconversationId,
67
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=subconversationGroupIdStore.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subconversationGroupIdStore.test.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.ts"],"names":[],"mappings":""}
@@ -1,72 +0,0 @@
1
- "use strict";
2
- /*
3
- * Wire
4
- * Copyright (C) 2018 Wire Swiss GmbH
5
- *
6
- * This program is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see http://www.gnu.org/licenses/.
18
- *
19
- */
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- const conversation_1 = require("@wireapp/api-client/lib/conversation");
22
- const subconversationGroupIdStore_1 = require("./subconversationGroupIdStore");
23
- describe('subconversationGroupIdMapper', () => {
24
- it('returns empty groupId if conversation is not known', () => {
25
- const groupId = subconversationGroupIdStore_1.subconversationGroupIdStore.getGroupId({ domain: 'example.com', id: '123' }, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
26
- expect(groupId).toBeUndefined();
27
- });
28
- it('returns the stored groupId', () => {
29
- const conversationId = { domain: 'example.com', id: '123' };
30
- const subconversation = conversation_1.SUBCONVERSATION_ID.CONFERENCE;
31
- const groupId = 'groupID';
32
- subconversationGroupIdStore_1.subconversationGroupIdStore.storeGroupId(conversationId, subconversation, groupId);
33
- const result = subconversationGroupIdStore_1.subconversationGroupIdStore.getGroupId(conversationId, subconversation);
34
- expect(result).toBe(groupId);
35
- });
36
- it('removes groupId from the store', () => {
37
- const conversationId = { domain: 'example.com', id: '123' };
38
- const subconversation = conversation_1.SUBCONVERSATION_ID.CONFERENCE;
39
- const groupId = 'groupID';
40
- subconversationGroupIdStore_1.subconversationGroupIdStore.storeGroupId(conversationId, subconversation, groupId);
41
- expect(subconversationGroupIdStore_1.subconversationGroupIdStore.getGroupId(conversationId, subconversation)).toEqual(groupId);
42
- subconversationGroupIdStore_1.subconversationGroupIdStore.removeGroupId(conversationId, subconversation);
43
- expect(subconversationGroupIdStore_1.subconversationGroupIdStore.getGroupId(conversationId, subconversation)).toBeUndefined();
44
- });
45
- it('retrieves all entries from the store by subconversation id', () => {
46
- const conversationId = { domain: 'example.com', id: '123' };
47
- const subconversation = conversation_1.SUBCONVERSATION_ID.CONFERENCE;
48
- const groupId = 'groupID';
49
- const conversationId2 = { domain: 'example2.com', id: '1234' };
50
- const subconversation2 = conversation_1.SUBCONVERSATION_ID.CONFERENCE;
51
- const groupId2 = 'groupID2';
52
- const conversationId3 = { domain: 'example3.com', id: '12345' };
53
- const subconversation3 = 'none';
54
- const groupId3 = 'groupID3';
55
- subconversationGroupIdStore_1.subconversationGroupIdStore.storeGroupId(conversationId, subconversation, groupId);
56
- subconversationGroupIdStore_1.subconversationGroupIdStore.storeGroupId(conversationId2, subconversation2, groupId2);
57
- subconversationGroupIdStore_1.subconversationGroupIdStore.storeGroupId(conversationId3, subconversation3, groupId3);
58
- const result = subconversationGroupIdStore_1.subconversationGroupIdStore.getAllGroupIdsBySubconversationId(conversation_1.SUBCONVERSATION_ID.CONFERENCE);
59
- expect(result).toEqual([
60
- {
61
- parentConversationId: conversationId,
62
- subconversationId: subconversation,
63
- subconversationGroupId: groupId,
64
- },
65
- {
66
- parentConversationId: conversationId2,
67
- subconversationId: subconversation2,
68
- subconversationGroupId: groupId2,
69
- },
70
- ]);
71
- });
72
- });