@wireapp/core 42.19.1 → 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.
- package/lib/Account.d.ts +5 -3
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +12 -6
- package/lib/conversation/ConversationService/ConversationService.d.ts +3 -2
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +3 -2
- package/lib/conversation/ConversationService/ConversationService.test.js +2 -1
- package/lib/conversation/SubconversationService/SubconversationService.d.ts +14 -3
- package/lib/conversation/SubconversationService/SubconversationService.d.ts.map +1 -1
- package/lib/conversation/SubconversationService/SubconversationService.js +33 -19
- package/lib/conversation/SubconversationService/SubconversationService.test.js +37 -53
- package/lib/conversation/SubconversationService/subconversationUtil.d.ts +4 -0
- package/lib/conversation/SubconversationService/subconversationUtil.d.ts.map +1 -0
- package/lib/conversation/SubconversationService/subconversationUtil.js +25 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts +4 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +2 -2
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.js +8 -8
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +2 -11
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +8 -24
- package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +5 -4
- package/lib/messagingProtocols/mls/types.d.ts +2 -3
- package/lib/messagingProtocols/mls/types.d.ts.map +1 -1
- package/lib/storage/CoreDB.d.ts +10 -0
- package/lib/storage/CoreDB.d.ts.map +1 -1
- package/lib/storage/CoreDB.js +3 -1
- package/package.json +3 -3
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.d.ts +0 -13
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.js +0 -67
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.d.ts +0 -2
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.js +0 -72
package/lib/Account.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { GiphyService } from './giphy/';
|
|
|
14
14
|
import { LinkPreviewService } from './linkPreview';
|
|
15
15
|
import { MLSService } from './messagingProtocols/mls';
|
|
16
16
|
import { AcmeChallenge, E2EIServiceExternal } from './messagingProtocols/mls/E2EIdentityService';
|
|
17
|
-
import {
|
|
17
|
+
import { CoreCallbacks, CryptoProtocolConfig } from './messagingProtocols/mls/types';
|
|
18
18
|
import { NewClient, ProteusService } from './messagingProtocols/proteus';
|
|
19
19
|
import { HandledEventPayload, NotificationService, NotificationSource } from './notification/';
|
|
20
20
|
import { SelfService } from './self/';
|
|
@@ -74,6 +74,7 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
74
74
|
private readonly isMlsEnabled;
|
|
75
75
|
private storeEngine?;
|
|
76
76
|
private db?;
|
|
77
|
+
private coreCallbacks?;
|
|
77
78
|
service?: {
|
|
78
79
|
mls?: MLSService;
|
|
79
80
|
e2eIdentity?: E2EIServiceExternal;
|
|
@@ -153,9 +154,9 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
153
154
|
* Namely:
|
|
154
155
|
* - is the current user allowed to administrate a specific conversation
|
|
155
156
|
* - what is the groupId of a conversation
|
|
156
|
-
* @param
|
|
157
|
+
* @param coreCallbacks
|
|
157
158
|
*/
|
|
158
|
-
|
|
159
|
+
configureCoreCallbacks(coreCallbacks: CoreCallbacks): void;
|
|
159
160
|
initServices(context: Context): Promise<void>;
|
|
160
161
|
private resetContext;
|
|
161
162
|
/**
|
|
@@ -208,6 +209,7 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
208
209
|
private generateDbName;
|
|
209
210
|
private generateCoreDbName;
|
|
210
211
|
private initEngine;
|
|
212
|
+
private groupIdFromConversationId;
|
|
211
213
|
}
|
|
212
214
|
export {};
|
|
213
215
|
//# sourceMappingURL=Account.d.ts.map
|
package/lib/Account.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../src/Account.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EAGZ,OAAO,EACP,MAAM,EAEN,SAAS,EACV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAuB,UAAU,EAAE,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../src/Account.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EAGZ,OAAO,EACP,MAAM,EAEN,SAAS,EACV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAuB,UAAU,EAAE,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAEnG,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAC;AAQxD,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,UAAU,EAAe,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,WAAW,CAAC;AACpD,OAAO,EAAC,iBAA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G;IACH,sBAAsB,CAAC,aAAa,EAAE,aAAa;IAItC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAqE1D,OAAO,CAAC,YAAY;IAKpB;;;OAGG;IACU,MAAM,CAAC,SAAS,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAS9D;;OAEG;YACW,IAAI;IAOlB;;;;;;OAMG;IACI,MAAM,CAAC,EACZ,OAAkB,EAClB,wBAAmC,EACnC,4BAAuC,EACvC,qBAAgC,EAChC,MAAc,GACf,GAAE;QACD;;;;WAIG;QACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;QAE7E;;WAEG;QACH,4BAA4B,CAAC,EAAE,CAAC,EAAC,IAAI,EAAE,KAAK,EAAC,EAAE;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAC,KAAK,IAAI,CAAC;QAEtF;;WAEG;QACH,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;QAE5D;;;;;;WAMG;QACH,qBAAqB,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;QAEzD;;WAEG;QACH,MAAM,CAAC,EAAE,OAAO,CAAC;KACb,GAAG,MAAM,IAAI;IA2FnB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,kBAAkB;YAIZ,UAAU;IAsBxB,OAAO,CAAC,yBAAyB,CAS/B;CACH"}
|
package/lib/Account.js
CHANGED
|
@@ -90,6 +90,13 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
90
90
|
*/
|
|
91
91
|
constructor(apiClient = new api_client_1.APIClient(), { createStore = () => undefined, nbPrekeys = 100, cryptoProtocolConfig } = {}) {
|
|
92
92
|
super();
|
|
93
|
+
this.groupIdFromConversationId = async (conversationId, subconversationId) => {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
if (!subconversationId) {
|
|
96
|
+
return (_a = this.coreCallbacks) === null || _a === void 0 ? void 0 : _a.groupIdFromConversationId(conversationId);
|
|
97
|
+
}
|
|
98
|
+
return (_b = this.service) === null || _b === void 0 ? void 0 : _b.subconversation.getSubconversationGroupId(conversationId, subconversationId);
|
|
99
|
+
};
|
|
93
100
|
this.apiClient = apiClient;
|
|
94
101
|
this.backendFeatures = this.apiClient.backendFeatures;
|
|
95
102
|
this.cryptoProtocolConfig = cryptoProtocolConfig;
|
|
@@ -279,11 +286,10 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
279
286
|
* Namely:
|
|
280
287
|
* - is the current user allowed to administrate a specific conversation
|
|
281
288
|
* - what is the groupId of a conversation
|
|
282
|
-
* @param
|
|
289
|
+
* @param coreCallbacks
|
|
283
290
|
*/
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
(_b = (_a = this.service) === null || _a === void 0 ? void 0 : _a.mls) === null || _b === void 0 ? void 0 : _b.configureMLSCallbacks(mlsCallbacks);
|
|
291
|
+
configureCoreCallbacks(coreCallbacks) {
|
|
292
|
+
this.coreCallbacks = coreCallbacks;
|
|
287
293
|
}
|
|
288
294
|
async initServices(context) {
|
|
289
295
|
var _a;
|
|
@@ -306,8 +312,8 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
306
312
|
const connectionService = new connection_1.ConnectionService(this.apiClient);
|
|
307
313
|
const giphyService = new giphy_1.GiphyService(this.apiClient);
|
|
308
314
|
const linkPreviewService = new linkPreview_1.LinkPreviewService(assetService);
|
|
309
|
-
const conversationService = new conversation_1.ConversationService(this.apiClient, proteusService, this.db, mlsService);
|
|
310
|
-
const subconversationService = new SubconversationService_1.SubconversationService(this.apiClient, mlsService);
|
|
315
|
+
const conversationService = new conversation_1.ConversationService(this.apiClient, proteusService, this.db, this.groupIdFromConversationId, mlsService);
|
|
316
|
+
const subconversationService = new SubconversationService_1.SubconversationService(this.apiClient, this.db, mlsService);
|
|
311
317
|
const notificationService = new notification_1.NotificationService(this.apiClient, this.storeEngine, conversationService);
|
|
312
318
|
const selfService = new self_1.SelfService(this.apiClient);
|
|
313
319
|
const teamService = new team_1.TeamService(this.apiClient);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, RemoteConversations, PostMlsMessageResponse, MLSConversation } from '@wireapp/api-client/lib/conversation';
|
|
1
|
+
import { Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, RemoteConversations, PostMlsMessageResponse, MLSConversation, SUBCONVERSATION_ID } from '@wireapp/api-client/lib/conversation';
|
|
2
2
|
import { BackendEvent, ConversationMemberLeaveEvent } from '@wireapp/api-client/lib/event';
|
|
3
3
|
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
4
4
|
import { XOR } from '@wireapp/commons/lib/util/TypeUtil';
|
|
@@ -21,10 +21,11 @@ export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
|
21
21
|
private readonly apiClient;
|
|
22
22
|
private readonly proteusService;
|
|
23
23
|
private readonly coreDatabase;
|
|
24
|
+
private readonly groupIdFromConversationId;
|
|
24
25
|
private readonly _mlsService?;
|
|
25
26
|
readonly messageTimer: MessageTimer;
|
|
26
27
|
private readonly logger;
|
|
27
|
-
constructor(apiClient: APIClient, proteusService: ProteusService, coreDatabase: CoreDatabase, _mlsService?: MLSService | undefined);
|
|
28
|
+
constructor(apiClient: APIClient, proteusService: ProteusService, coreDatabase: CoreDatabase, groupIdFromConversationId: (conversationId: QualifiedId, subconversationId?: SUBCONVERSATION_ID) => Promise<string | undefined>, _mlsService?: MLSService | undefined);
|
|
28
29
|
get mlsService(): MLSService;
|
|
29
30
|
/**
|
|
30
31
|
* Get a fresh list from backend of clients for all the participants of the conversation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationService/ConversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,WAAW,EACX,eAAe,EACf,oBAAoB,EAEpB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,
|
|
1
|
+
{"version":3,"file":"ConversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationService/ConversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,WAAW,EACX,eAAe,EACf,oBAAoB,EAEpB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EACnB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,YAAY,EAIZ,4BAA4B,EAE7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAIvD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAInD,OAAO,EAEL,cAAc,EAEd,6BAA6B,EAC7B,oBAAoB,EACpB,UAAU,EACX,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAC,YAAY,EAAuB,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAEzF,OAAO,EAAC,UAAU,EAAuB,MAAM,8BAA8B,CAAC;AAE9E,OAAO,EAAkC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AACjG,OAAO,EACL,mCAAmC,EACnC,wBAAwB,EACzB,MAAM,sEAAsE,CAAC;AAC9E,OAAO,EAAsB,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAGlD,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AAGtC,KAAK,MAAM,GAAG;IACZ,wBAAwB,EAAE;QAAC,cAAc,EAAE,WAAW,CAAA;KAAC,CA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,EAC1C,OAAO,EACP,cAAc,EACd,gBAAgB,GACjB,EAAE,iBAAiB,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAoBhD,oBAAoB,CAAC,cAAc,EAAE,WAAW;IAI7D;;;;;OAKG;IACU,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAmBpE;;;OAGG;IACU,qBAAqB,CAAC,OAAO,EAAE,MAAM;IAIlD;;;;OAIG;IACU,4BAA4B,CAAC,OAAO,EAAE,MAAM;IAI5C,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAIlD,YAAY;IAYb,gCAAgC;IAa7C;;;;;OAKG;YACW,+BAA+B;IA6B7C;;;OAGG;IACG,sBAAsB,CAAC,MAAM,EAAE,WAAW;IAIhD;;;;;;;OAOG;IACH,SAAgB,4BAA4B,YACjC,MAAM,YACL;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,eAChC,WAAW,4BAEvB,QAAQ,eAAe,CAAC,CAoDzB;IAEF;;;;;;;;OAQG;IACU,uBAAuB,CAAC,EACnC,OAAO,EACP,cAAc,EACd,UAAU,EACV,cAAc,GACf,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,WAAW,CAAC;QAC5B,UAAU,EAAE,WAAW,CAAC;QACxB,cAAc,EAAE,WAAW,EAAE,CAAC;KAC/B,GAAG,OAAO,CAAC,IAAI,CAAC;YA4BH,wBAAwB;YAoBxB,uCAAuC;YAYvC,4BAA4B;YAI5B,wBAAwB;YAIxB,yBAAyB;IAKvC;;;;OAIG;IACU,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAoB3E"}
|
|
@@ -41,11 +41,12 @@ const util_1 = require("../../util");
|
|
|
41
41
|
const fullyQualifiedClientIdUtils_1 = require("../../util/fullyQualifiedClientIdUtils");
|
|
42
42
|
const messageSender_1 = require("../message/messageSender");
|
|
43
43
|
class ConversationService extends commons_1.TypedEventEmitter {
|
|
44
|
-
constructor(apiClient, proteusService, coreDatabase, _mlsService) {
|
|
44
|
+
constructor(apiClient, proteusService, coreDatabase, groupIdFromConversationId, _mlsService) {
|
|
45
45
|
super();
|
|
46
46
|
this.apiClient = apiClient;
|
|
47
47
|
this.proteusService = proteusService;
|
|
48
48
|
this.coreDatabase = coreDatabase;
|
|
49
|
+
this.groupIdFromConversationId = groupIdFromConversationId;
|
|
49
50
|
this._mlsService = _mlsService;
|
|
50
51
|
this.logger = (0, logdown_1.default)('@wireapp/core/ConversationService');
|
|
51
52
|
/**
|
|
@@ -453,7 +454,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
453
454
|
}
|
|
454
455
|
async handleMLSMessageAddEvent(event) {
|
|
455
456
|
try {
|
|
456
|
-
return await this.mlsService.handleMLSMessageAddEvent(event);
|
|
457
|
+
return await this.mlsService.handleMLSMessageAddEvent(event, this.groupIdFromConversationId);
|
|
457
458
|
}
|
|
458
459
|
catch (error) {
|
|
459
460
|
if ((0, CoreCryptoMLSError_1.isCoreCryptoMLSWrongEpochError)(error)) {
|
|
@@ -112,7 +112,8 @@ describe('ConversationService', () => {
|
|
|
112
112
|
resetKeyMaterialRenewal: jest.fn(),
|
|
113
113
|
};
|
|
114
114
|
const mockedDb = await (0, CoreDB_1.openDB)('core-test-db');
|
|
115
|
-
const
|
|
115
|
+
const groupIdFromConversationId = jest.fn();
|
|
116
|
+
const conversationService = new __1.ConversationService(client, mockedProteusService, mockedDb, groupIdFromConversationId, mockedMLSService);
|
|
116
117
|
jest.spyOn(conversationService, 'joinByExternalCommit');
|
|
117
118
|
jest.spyOn(conversationService, 'emit');
|
|
118
119
|
return [conversationService, { apiClient: client, mlsService: mockedMLSService }];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { SUBCONVERSATION_ID } from '@wireapp/api-client/lib/conversation';
|
|
1
2
|
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
2
3
|
import { APIClient } from '@wireapp/api-client';
|
|
3
4
|
import { TypedEventEmitter } from '@wireapp/commons';
|
|
4
5
|
import { MLSService } from '../../messagingProtocols/mls';
|
|
6
|
+
import { CoreDatabase } from '../../storage/CoreDB';
|
|
5
7
|
type Events = {
|
|
6
8
|
MLSConversationRecovered: {
|
|
7
9
|
conversationId: QualifiedId;
|
|
@@ -14,9 +16,10 @@ export interface SubconversationEpochInfoMember {
|
|
|
14
16
|
}
|
|
15
17
|
export declare class SubconversationService extends TypedEventEmitter<Events> {
|
|
16
18
|
private readonly apiClient;
|
|
19
|
+
private readonly coreDatabase;
|
|
17
20
|
private readonly _mlsService?;
|
|
18
21
|
private readonly logger;
|
|
19
|
-
constructor(apiClient: APIClient, _mlsService?: MLSService | undefined);
|
|
22
|
+
constructor(apiClient: APIClient, coreDatabase: CoreDatabase, _mlsService?: MLSService | undefined);
|
|
20
23
|
get mlsService(): MLSService;
|
|
21
24
|
/**
|
|
22
25
|
* Will join or register an mls subconversation for conference calls.
|
|
@@ -35,13 +38,13 @@ export declare class SubconversationService extends TypedEventEmitter<Events> {
|
|
|
35
38
|
*/
|
|
36
39
|
leaveConferenceSubconversation(conversationId: QualifiedId): Promise<void>;
|
|
37
40
|
leaveStaleConferenceSubconversations(): Promise<void>;
|
|
38
|
-
getSubconversationEpochInfo(
|
|
41
|
+
getSubconversationEpochInfo(parentConversationId: QualifiedId, parentConversationGroupId: string, shouldAdvanceEpoch?: boolean): Promise<{
|
|
39
42
|
members: SubconversationEpochInfoMember[];
|
|
40
43
|
epoch: number;
|
|
41
44
|
secretKey: string;
|
|
42
45
|
keyLength: number;
|
|
43
46
|
} | null>;
|
|
44
|
-
subscribeToEpochUpdates(
|
|
47
|
+
subscribeToEpochUpdates(parentConversationId: QualifiedId, parentConversationGroupId: string, findConversationByGroupId: (groupId: string) => QualifiedId | undefined, onEpochUpdate: (info: {
|
|
45
48
|
members: SubconversationEpochInfoMember[];
|
|
46
49
|
epoch: number;
|
|
47
50
|
secretKey: string;
|
|
@@ -55,6 +58,14 @@ export declare class SubconversationService extends TypedEventEmitter<Events> {
|
|
|
55
58
|
private getConferenceSubconversation;
|
|
56
59
|
private deleteConferenceSubconversation;
|
|
57
60
|
private generateSubconversationMembers;
|
|
61
|
+
getSubconversationGroupId: (parentConversationId: QualifiedId, subconversationId: SUBCONVERSATION_ID) => Promise<string | undefined>;
|
|
62
|
+
getAllGroupIdsBySubconversationId: (subconversationId: SUBCONVERSATION_ID) => Promise<{
|
|
63
|
+
parentConversationId: QualifiedId;
|
|
64
|
+
subconversationId: SUBCONVERSATION_ID;
|
|
65
|
+
groupId: string;
|
|
66
|
+
}[]>;
|
|
67
|
+
saveSubconversationGroupId: (parentConversationId: QualifiedId, subconversationId: SUBCONVERSATION_ID, groupId: string) => Promise<string>;
|
|
68
|
+
clearSubconversationGroupId: (parentConversationId: QualifiedId, subconversationId: SUBCONVERSATION_ID) => Promise<void>;
|
|
58
69
|
}
|
|
59
70
|
export {};
|
|
60
71
|
//# sourceMappingURL=SubconversationService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubconversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/SubconversationService/SubconversationService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SubconversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/SubconversationService/SubconversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,kBAAkB,EAAkB,MAAM,sCAAsC,CAAC;AACzF,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAInD,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAGlD,KAAK,MAAM,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AM,KAAK,WAAW,GAAG,SAAS,EACvE,aAAa,EAAE,CAAC,IAAI,EAAE;QACpB,OAAO,EAAE,8BAA8B,EAAE,CAAC;QAC1C,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;KACnB,KAAK,IAAI,GACT,OAAO,CAAC,MAAM,IAAI,CAAC;IA0CT,yCAAyC,CACpD,cAAc,EAAE,WAAW,EAC3B,cAAc,EAAE;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,GACpD,OAAO,CAAC,IAAI,CAAC;YAgCF,mCAAmC;YAMnC,4BAA4B;YAI5B,+BAA+B;YAO/B,8BAA8B;IAsBrC,yBAAyB,yBACR,WAAW,qBACd,kBAAkB,KACpC,QAAQ,MAAM,GAAG,SAAS,CAAC,CAO5B;IAEK,iCAAiC,sBACnB,kBAAkB;8BAGb,WAAW;2BACd,kBAAkB;iBAC5B,MAAM;SASjB;IAEK,0BAA0B,yBACT,WAAW,qBACd,kBAAkB,WAC5B,MAAM,qBAOf;IAEK,2BAA2B,yBACV,WAAW,qBACd,kBAAkB,mBAMrC;CACH"}
|
|
@@ -26,15 +26,31 @@ const conversation_1 = require("@wireapp/api-client/lib/conversation");
|
|
|
26
26
|
const TimeUtil_1 = require("@wireapp/commons/lib/util/TimeUtil");
|
|
27
27
|
const logdown_1 = __importDefault(require("logdown"));
|
|
28
28
|
const commons_1 = require("@wireapp/commons");
|
|
29
|
-
const
|
|
29
|
+
const subconversationUtil_1 = require("./subconversationUtil");
|
|
30
30
|
const fullyQualifiedClientIdUtils_1 = require("../../util/fullyQualifiedClientIdUtils");
|
|
31
31
|
const MLS_CONVERSATION_KEY_LENGTH = 32;
|
|
32
32
|
class SubconversationService extends commons_1.TypedEventEmitter {
|
|
33
|
-
constructor(apiClient, _mlsService) {
|
|
33
|
+
constructor(apiClient, coreDatabase, _mlsService) {
|
|
34
34
|
super();
|
|
35
35
|
this.apiClient = apiClient;
|
|
36
|
+
this.coreDatabase = coreDatabase;
|
|
36
37
|
this._mlsService = _mlsService;
|
|
37
38
|
this.logger = (0, logdown_1.default)('@wireapp/core/SubconversationService');
|
|
39
|
+
this.getSubconversationGroupId = async (parentConversationId, subconversationId) => {
|
|
40
|
+
const foundSubconversation = await this.coreDatabase.get('subconversations', (0, subconversationUtil_1.generateSubconversationStoreKey)(parentConversationId, subconversationId));
|
|
41
|
+
return foundSubconversation === null || foundSubconversation === void 0 ? void 0 : foundSubconversation.groupId;
|
|
42
|
+
};
|
|
43
|
+
this.getAllGroupIdsBySubconversationId = async (subconversationId) => {
|
|
44
|
+
const allSubconversations = await this.coreDatabase.getAll('subconversations');
|
|
45
|
+
const foundSubconversations = allSubconversations.filter(subconversation => subconversation.subconversationId === subconversationId);
|
|
46
|
+
return foundSubconversations;
|
|
47
|
+
};
|
|
48
|
+
this.saveSubconversationGroupId = async (parentConversationId, subconversationId, groupId) => {
|
|
49
|
+
return this.coreDatabase.put('subconversations', { parentConversationId, subconversationId, groupId }, (0, subconversationUtil_1.generateSubconversationStoreKey)(parentConversationId, subconversationId));
|
|
50
|
+
};
|
|
51
|
+
this.clearSubconversationGroupId = async (parentConversationId, subconversationId) => {
|
|
52
|
+
return this.coreDatabase.delete('subconversations', (0, subconversationUtil_1.generateSubconversationStoreKey)(parentConversationId, subconversationId));
|
|
53
|
+
};
|
|
38
54
|
}
|
|
39
55
|
get mlsService() {
|
|
40
56
|
if (!this._mlsService) {
|
|
@@ -75,7 +91,7 @@ class SubconversationService extends commons_1.TypedEventEmitter {
|
|
|
75
91
|
}
|
|
76
92
|
const epoch = Number(await this.mlsService.getEpoch(subconversationGroupId));
|
|
77
93
|
// We store the mapping between the subconversation and the parent conversation
|
|
78
|
-
|
|
94
|
+
await this.saveSubconversationGroupId(conversationId, subconversationId, subconversationGroupId);
|
|
79
95
|
return { groupId: subconversationGroupId, epoch };
|
|
80
96
|
}
|
|
81
97
|
catch (error) {
|
|
@@ -91,14 +107,14 @@ class SubconversationService extends commons_1.TypedEventEmitter {
|
|
|
91
107
|
* @param conversationId Id of the parent conversation which subconversation we want to leave
|
|
92
108
|
*/
|
|
93
109
|
async leaveConferenceSubconversation(conversationId) {
|
|
94
|
-
const subconversationGroupId =
|
|
110
|
+
const subconversationGroupId = await this.getSubconversationGroupId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
95
111
|
if (!subconversationGroupId) {
|
|
96
112
|
return;
|
|
97
113
|
}
|
|
98
114
|
const doesGroupExistLocally = await this.mlsService.conversationExists(subconversationGroupId);
|
|
99
115
|
if (!doesGroupExistLocally) {
|
|
100
116
|
// If the subconversation was known by a client but is does not exist locally, we can remove it from the store.
|
|
101
|
-
return
|
|
117
|
+
return this.clearSubconversationGroupId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
102
118
|
}
|
|
103
119
|
try {
|
|
104
120
|
await this.apiClient.api.conversation.deleteSubconversationSelf(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
@@ -108,20 +124,19 @@ class SubconversationService extends commons_1.TypedEventEmitter {
|
|
|
108
124
|
}
|
|
109
125
|
await this.mlsService.wipeConversation(subconversationGroupId);
|
|
110
126
|
// once we've left the subconversation, we can remove it from the store
|
|
111
|
-
|
|
127
|
+
await this.clearSubconversationGroupId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
112
128
|
}
|
|
113
129
|
async leaveStaleConferenceSubconversations() {
|
|
114
|
-
const conversationIds =
|
|
130
|
+
const conversationIds = await this.getAllGroupIdsBySubconversationId(conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
115
131
|
for (const { parentConversationId } of conversationIds) {
|
|
116
132
|
await this.leaveConferenceSubconversation(parentConversationId);
|
|
117
133
|
}
|
|
118
134
|
}
|
|
119
|
-
async getSubconversationEpochInfo(
|
|
120
|
-
const subconversationGroupId = await this.
|
|
121
|
-
const parentGroupId = await this.mlsService.getGroupIdFromConversationId(conversationId);
|
|
135
|
+
async getSubconversationEpochInfo(parentConversationId, parentConversationGroupId, shouldAdvanceEpoch = false) {
|
|
136
|
+
const subconversationGroupId = await this.getSubconversationGroupId(parentConversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
122
137
|
// this method should not be called if the subconversation (and its parent conversation) is not established
|
|
123
|
-
if (!subconversationGroupId
|
|
124
|
-
this.logger.error(`Could not obtain epoch info for conference subconversation of conversation ${JSON.stringify(
|
|
138
|
+
if (!subconversationGroupId) {
|
|
139
|
+
this.logger.error(`Could not obtain epoch info for conference subconversation of conversation ${JSON.stringify(parentConversationId)}: parent or subconversation group ID is missing`);
|
|
125
140
|
return null;
|
|
126
141
|
}
|
|
127
142
|
//we don't want to react to avs callbacks when conversation was not yet established
|
|
@@ -129,7 +144,7 @@ class SubconversationService extends commons_1.TypedEventEmitter {
|
|
|
129
144
|
if (!doesMLSGroupExist) {
|
|
130
145
|
return null;
|
|
131
146
|
}
|
|
132
|
-
const members = await this.generateSubconversationMembers(subconversationGroupId,
|
|
147
|
+
const members = await this.generateSubconversationMembers(subconversationGroupId, parentConversationGroupId);
|
|
133
148
|
if (shouldAdvanceEpoch) {
|
|
134
149
|
await this.mlsService.renewKeyMaterial(subconversationGroupId);
|
|
135
150
|
}
|
|
@@ -137,23 +152,22 @@ class SubconversationService extends commons_1.TypedEventEmitter {
|
|
|
137
152
|
const secretKey = await this.mlsService.exportSecretKey(subconversationGroupId, MLS_CONVERSATION_KEY_LENGTH);
|
|
138
153
|
return { members, epoch, keyLength: MLS_CONVERSATION_KEY_LENGTH, secretKey };
|
|
139
154
|
}
|
|
140
|
-
async subscribeToEpochUpdates(
|
|
141
|
-
const { epoch: initialEpoch, groupId: subconversationGroupId } = await this.joinConferenceSubconversation(
|
|
155
|
+
async subscribeToEpochUpdates(parentConversationId, parentConversationGroupId, findConversationByGroupId, onEpochUpdate) {
|
|
156
|
+
const { epoch: initialEpoch, groupId: subconversationGroupId } = await this.joinConferenceSubconversation(parentConversationId);
|
|
142
157
|
const forwardNewEpoch = async ({ groupId, epoch }) => {
|
|
143
|
-
var _a, _b;
|
|
144
158
|
if (groupId !== subconversationGroupId) {
|
|
145
159
|
// if the epoch update did not happen in the subconversation directly, check if it happened in the parent conversation
|
|
146
160
|
const parentConversationId = findConversationByGroupId(groupId);
|
|
147
161
|
if (!parentConversationId) {
|
|
148
162
|
return;
|
|
149
163
|
}
|
|
150
|
-
const foundSubconversationGroupId = await
|
|
164
|
+
const foundSubconversationGroupId = await this.getSubconversationGroupId(parentConversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
151
165
|
// if the conference subconversation of parent conversation is not known, ignore the epoch update
|
|
152
166
|
if (foundSubconversationGroupId !== subconversationGroupId) {
|
|
153
167
|
return;
|
|
154
168
|
}
|
|
155
169
|
}
|
|
156
|
-
const subconversationEpochInfo = await this.getSubconversationEpochInfo(
|
|
170
|
+
const subconversationEpochInfo = await this.getSubconversationEpochInfo(parentConversationId, parentConversationGroupId);
|
|
157
171
|
if (!subconversationEpochInfo) {
|
|
158
172
|
return;
|
|
159
173
|
}
|
|
@@ -164,7 +178,7 @@ class SubconversationService extends commons_1.TypedEventEmitter {
|
|
|
164
178
|
return () => this.mlsService.off('newEpoch', forwardNewEpoch);
|
|
165
179
|
}
|
|
166
180
|
async removeClientFromConferenceSubconversation(conversationId, clientToRemove) {
|
|
167
|
-
const subconversationGroupId = await this.
|
|
181
|
+
const subconversationGroupId = await this.getSubconversationGroupId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
168
182
|
if (!subconversationGroupId) {
|
|
169
183
|
return;
|
|
170
184
|
}
|