@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.
- package/lib/Account.d.ts +7 -3
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +15 -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 +71 -0
- package/lib/conversation/SubconversationService/SubconversationService.d.ts.map +1 -0
- package/lib/conversation/SubconversationService/SubconversationService.js +221 -0
- package/lib/conversation/SubconversationService/SubconversationService.test.d.ts +2 -0
- package/lib/conversation/SubconversationService/SubconversationService.test.d.ts.map +1 -0
- package/lib/conversation/SubconversationService/SubconversationService.test.js +374 -0
- 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 -36
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +8 -94
- 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
|
@@ -9,11 +9,12 @@ import { BroadcastService } from './broadcast/';
|
|
|
9
9
|
import { ClientInfo, ClientService } from './client/';
|
|
10
10
|
import { ConnectionService } from './connection/';
|
|
11
11
|
import { AssetService, ConversationService } from './conversation/';
|
|
12
|
+
import { SubconversationService } from './conversation/SubconversationService/SubconversationService';
|
|
12
13
|
import { GiphyService } from './giphy/';
|
|
13
14
|
import { LinkPreviewService } from './linkPreview';
|
|
14
15
|
import { MLSService } from './messagingProtocols/mls';
|
|
15
16
|
import { AcmeChallenge, E2EIServiceExternal } from './messagingProtocols/mls/E2EIdentityService';
|
|
16
|
-
import {
|
|
17
|
+
import { CoreCallbacks, CryptoProtocolConfig } from './messagingProtocols/mls/types';
|
|
17
18
|
import { NewClient, ProteusService } from './messagingProtocols/proteus';
|
|
18
19
|
import { HandledEventPayload, NotificationService, NotificationSource } from './notification/';
|
|
19
20
|
import { SelfService } from './self/';
|
|
@@ -73,6 +74,7 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
73
74
|
private readonly isMlsEnabled;
|
|
74
75
|
private storeEngine?;
|
|
75
76
|
private db?;
|
|
77
|
+
private coreCallbacks?;
|
|
76
78
|
service?: {
|
|
77
79
|
mls?: MLSService;
|
|
78
80
|
e2eIdentity?: E2EIServiceExternal;
|
|
@@ -83,6 +85,7 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
83
85
|
client: ClientService;
|
|
84
86
|
connection: ConnectionService;
|
|
85
87
|
conversation: ConversationService;
|
|
88
|
+
subconversation: SubconversationService;
|
|
86
89
|
giphy: GiphyService;
|
|
87
90
|
linkPreview: LinkPreviewService;
|
|
88
91
|
notification: NotificationService;
|
|
@@ -151,9 +154,9 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
151
154
|
* Namely:
|
|
152
155
|
* - is the current user allowed to administrate a specific conversation
|
|
153
156
|
* - what is the groupId of a conversation
|
|
154
|
-
* @param
|
|
157
|
+
* @param coreCallbacks
|
|
155
158
|
*/
|
|
156
|
-
|
|
159
|
+
configureCoreCallbacks(coreCallbacks: CoreCallbacks): void;
|
|
157
160
|
initServices(context: Context): Promise<void>;
|
|
158
161
|
private resetContext;
|
|
159
162
|
/**
|
|
@@ -206,6 +209,7 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
206
209
|
private generateDbName;
|
|
207
210
|
private generateCoreDbName;
|
|
208
211
|
private initEngine;
|
|
212
|
+
private groupIdFromConversationId;
|
|
209
213
|
}
|
|
210
214
|
export {};
|
|
211
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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;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
|
@@ -45,6 +45,7 @@ const client_2 = require("./client/");
|
|
|
45
45
|
const connection_1 = require("./connection/");
|
|
46
46
|
const conversation_1 = require("./conversation/");
|
|
47
47
|
const messageSender_1 = require("./conversation/message/messageSender");
|
|
48
|
+
const SubconversationService_1 = require("./conversation/SubconversationService/SubconversationService");
|
|
48
49
|
const giphy_1 = require("./giphy/");
|
|
49
50
|
const linkPreview_1 = require("./linkPreview");
|
|
50
51
|
const mls_1 = require("./messagingProtocols/mls");
|
|
@@ -89,6 +90,13 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
89
90
|
*/
|
|
90
91
|
constructor(apiClient = new api_client_1.APIClient(), { createStore = () => undefined, nbPrekeys = 100, cryptoProtocolConfig } = {}) {
|
|
91
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
|
+
};
|
|
92
100
|
this.apiClient = apiClient;
|
|
93
101
|
this.backendFeatures = this.apiClient.backendFeatures;
|
|
94
102
|
this.cryptoProtocolConfig = cryptoProtocolConfig;
|
|
@@ -245,7 +253,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
245
253
|
// initialize scheduler for syncing key packages with backend
|
|
246
254
|
await this.service.mls.schedulePeriodicKeyPackagesBackendSync(validClient.id);
|
|
247
255
|
// leave stale conference subconversations (e.g after a crash)
|
|
248
|
-
await this.service.
|
|
256
|
+
await this.service.subconversation.leaveStaleConferenceSubconversations();
|
|
249
257
|
}
|
|
250
258
|
return validClient;
|
|
251
259
|
}
|
|
@@ -278,11 +286,10 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
278
286
|
* Namely:
|
|
279
287
|
* - is the current user allowed to administrate a specific conversation
|
|
280
288
|
* - what is the groupId of a conversation
|
|
281
|
-
* @param
|
|
289
|
+
* @param coreCallbacks
|
|
282
290
|
*/
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
(_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;
|
|
286
293
|
}
|
|
287
294
|
async initServices(context) {
|
|
288
295
|
var _a;
|
|
@@ -305,7 +312,8 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
305
312
|
const connectionService = new connection_1.ConnectionService(this.apiClient);
|
|
306
313
|
const giphyService = new giphy_1.GiphyService(this.apiClient);
|
|
307
314
|
const linkPreviewService = new linkPreview_1.LinkPreviewService(assetService);
|
|
308
|
-
const conversationService = new conversation_1.ConversationService(this.apiClient, proteusService, this.db, 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);
|
|
309
317
|
const notificationService = new notification_1.NotificationService(this.apiClient, this.storeEngine, conversationService);
|
|
310
318
|
const selfService = new self_1.SelfService(this.apiClient);
|
|
311
319
|
const teamService = new team_1.TeamService(this.apiClient);
|
|
@@ -321,6 +329,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
321
329
|
client: clientService,
|
|
322
330
|
connection: connectionService,
|
|
323
331
|
conversation: conversationService,
|
|
332
|
+
subconversation: subconversationService,
|
|
324
333
|
giphy: giphyService,
|
|
325
334
|
linkPreview: linkPreviewService,
|
|
326
335
|
notification: notificationService,
|
|
@@ -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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/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 }];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { SUBCONVERSATION_ID } from '@wireapp/api-client/lib/conversation';
|
|
2
|
+
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
3
|
+
import { APIClient } from '@wireapp/api-client';
|
|
4
|
+
import { TypedEventEmitter } from '@wireapp/commons';
|
|
5
|
+
import { MLSService } from '../../messagingProtocols/mls';
|
|
6
|
+
import { CoreDatabase } from '../../storage/CoreDB';
|
|
7
|
+
type Events = {
|
|
8
|
+
MLSConversationRecovered: {
|
|
9
|
+
conversationId: QualifiedId;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export interface SubconversationEpochInfoMember {
|
|
13
|
+
userid: `${string}@${string}`;
|
|
14
|
+
clientid: string;
|
|
15
|
+
in_subconv: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare class SubconversationService extends TypedEventEmitter<Events> {
|
|
18
|
+
private readonly apiClient;
|
|
19
|
+
private readonly coreDatabase;
|
|
20
|
+
private readonly _mlsService?;
|
|
21
|
+
private readonly logger;
|
|
22
|
+
constructor(apiClient: APIClient, coreDatabase: CoreDatabase, _mlsService?: MLSService | undefined);
|
|
23
|
+
get mlsService(): MLSService;
|
|
24
|
+
/**
|
|
25
|
+
* Will join or register an mls subconversation for conference calls.
|
|
26
|
+
* Will return the secret key derived from the subconversation
|
|
27
|
+
*
|
|
28
|
+
* @param conversationId Id of the parent conversation in which the call should happen
|
|
29
|
+
*/
|
|
30
|
+
joinConferenceSubconversation(conversationId: QualifiedId, shouldRetry?: boolean): Promise<{
|
|
31
|
+
groupId: string;
|
|
32
|
+
epoch: number;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Will leave conference subconversation if it's known by client and established.
|
|
36
|
+
*
|
|
37
|
+
* @param conversationId Id of the parent conversation which subconversation we want to leave
|
|
38
|
+
*/
|
|
39
|
+
leaveConferenceSubconversation(conversationId: QualifiedId): Promise<void>;
|
|
40
|
+
leaveStaleConferenceSubconversations(): Promise<void>;
|
|
41
|
+
getSubconversationEpochInfo(parentConversationId: QualifiedId, parentConversationGroupId: string, shouldAdvanceEpoch?: boolean): Promise<{
|
|
42
|
+
members: SubconversationEpochInfoMember[];
|
|
43
|
+
epoch: number;
|
|
44
|
+
secretKey: string;
|
|
45
|
+
keyLength: number;
|
|
46
|
+
} | null>;
|
|
47
|
+
subscribeToEpochUpdates(parentConversationId: QualifiedId, parentConversationGroupId: string, findConversationByGroupId: (groupId: string) => QualifiedId | undefined, onEpochUpdate: (info: {
|
|
48
|
+
members: SubconversationEpochInfoMember[];
|
|
49
|
+
epoch: number;
|
|
50
|
+
secretKey: string;
|
|
51
|
+
keyLength: number;
|
|
52
|
+
}) => void): Promise<() => void>;
|
|
53
|
+
removeClientFromConferenceSubconversation(conversationId: QualifiedId, clientToRemove: {
|
|
54
|
+
user: QualifiedId;
|
|
55
|
+
clientId: string;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
private joinSubconversationByExternalCommit;
|
|
58
|
+
private getConferenceSubconversation;
|
|
59
|
+
private deleteConferenceSubconversation;
|
|
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>;
|
|
69
|
+
}
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=SubconversationService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubconversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/SubconversationService/SubconversationService.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
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.SubconversationService = void 0;
|
|
25
|
+
const conversation_1 = require("@wireapp/api-client/lib/conversation");
|
|
26
|
+
const TimeUtil_1 = require("@wireapp/commons/lib/util/TimeUtil");
|
|
27
|
+
const logdown_1 = __importDefault(require("logdown"));
|
|
28
|
+
const commons_1 = require("@wireapp/commons");
|
|
29
|
+
const subconversationUtil_1 = require("./subconversationUtil");
|
|
30
|
+
const fullyQualifiedClientIdUtils_1 = require("../../util/fullyQualifiedClientIdUtils");
|
|
31
|
+
const MLS_CONVERSATION_KEY_LENGTH = 32;
|
|
32
|
+
class SubconversationService extends commons_1.TypedEventEmitter {
|
|
33
|
+
constructor(apiClient, coreDatabase, _mlsService) {
|
|
34
|
+
super();
|
|
35
|
+
this.apiClient = apiClient;
|
|
36
|
+
this.coreDatabase = coreDatabase;
|
|
37
|
+
this._mlsService = _mlsService;
|
|
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
|
+
};
|
|
54
|
+
}
|
|
55
|
+
get mlsService() {
|
|
56
|
+
if (!this._mlsService) {
|
|
57
|
+
throw new Error('MLSService was not initialised!');
|
|
58
|
+
}
|
|
59
|
+
return this._mlsService;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Will join or register an mls subconversation for conference calls.
|
|
63
|
+
* Will return the secret key derived from the subconversation
|
|
64
|
+
*
|
|
65
|
+
* @param conversationId Id of the parent conversation in which the call should happen
|
|
66
|
+
*/
|
|
67
|
+
async joinConferenceSubconversation(conversationId, shouldRetry = true) {
|
|
68
|
+
try {
|
|
69
|
+
const { group_id: subconversationGroupId, epoch: subconversationEpoch, epoch_timestamp: subconversationEpochTimestamp, subconv_id: subconversationId, } = await this.getConferenceSubconversation(conversationId);
|
|
70
|
+
if (subconversationEpoch === 0) {
|
|
71
|
+
const doesConversationExistsLocally = await this.mlsService.conversationExists(subconversationGroupId);
|
|
72
|
+
if (doesConversationExistsLocally) {
|
|
73
|
+
await this.mlsService.wipeConversation(subconversationGroupId);
|
|
74
|
+
}
|
|
75
|
+
// If subconversation is not yet established, create it and upload the commit bundle.
|
|
76
|
+
await this.mlsService.registerConversation(subconversationGroupId, []);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const epochUpdateTime = new Date(subconversationEpochTimestamp).getTime();
|
|
80
|
+
const epochAge = new Date().getTime() - epochUpdateTime;
|
|
81
|
+
if (epochAge > TimeUtil_1.TimeInMillis.DAY) {
|
|
82
|
+
// If subconversation does exist, but it's older than 24h, delete and re-join
|
|
83
|
+
await this.deleteConferenceSubconversation(conversationId, {
|
|
84
|
+
groupId: subconversationGroupId,
|
|
85
|
+
epoch: subconversationEpoch,
|
|
86
|
+
});
|
|
87
|
+
await this.mlsService.wipeConversation(subconversationGroupId);
|
|
88
|
+
return this.joinConferenceSubconversation(conversationId);
|
|
89
|
+
}
|
|
90
|
+
await this.joinSubconversationByExternalCommit(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
91
|
+
}
|
|
92
|
+
const epoch = Number(await this.mlsService.getEpoch(subconversationGroupId));
|
|
93
|
+
// We store the mapping between the subconversation and the parent conversation
|
|
94
|
+
await this.saveSubconversationGroupId(conversationId, subconversationId, subconversationGroupId);
|
|
95
|
+
return { groupId: subconversationGroupId, epoch };
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (shouldRetry) {
|
|
99
|
+
return this.joinConferenceSubconversation(conversationId, false);
|
|
100
|
+
}
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Will leave conference subconversation if it's known by client and established.
|
|
106
|
+
*
|
|
107
|
+
* @param conversationId Id of the parent conversation which subconversation we want to leave
|
|
108
|
+
*/
|
|
109
|
+
async leaveConferenceSubconversation(conversationId) {
|
|
110
|
+
const subconversationGroupId = await this.getSubconversationGroupId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
111
|
+
if (!subconversationGroupId) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const doesGroupExistLocally = await this.mlsService.conversationExists(subconversationGroupId);
|
|
115
|
+
if (!doesGroupExistLocally) {
|
|
116
|
+
// If the subconversation was known by a client but is does not exist locally, we can remove it from the store.
|
|
117
|
+
return this.clearSubconversationGroupId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
await this.apiClient.api.conversation.deleteSubconversationSelf(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
this.logger.error(`Failed to leave conference subconversation:`, error);
|
|
124
|
+
}
|
|
125
|
+
await this.mlsService.wipeConversation(subconversationGroupId);
|
|
126
|
+
// once we've left the subconversation, we can remove it from the store
|
|
127
|
+
await this.clearSubconversationGroupId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
128
|
+
}
|
|
129
|
+
async leaveStaleConferenceSubconversations() {
|
|
130
|
+
const conversationIds = await this.getAllGroupIdsBySubconversationId(conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
131
|
+
for (const { parentConversationId } of conversationIds) {
|
|
132
|
+
await this.leaveConferenceSubconversation(parentConversationId);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async getSubconversationEpochInfo(parentConversationId, parentConversationGroupId, shouldAdvanceEpoch = false) {
|
|
136
|
+
const subconversationGroupId = await this.getSubconversationGroupId(parentConversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
137
|
+
// this method should not be called if the subconversation (and its parent conversation) is not established
|
|
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`);
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
//we don't want to react to avs callbacks when conversation was not yet established
|
|
143
|
+
const doesMLSGroupExist = await this.mlsService.conversationExists(subconversationGroupId);
|
|
144
|
+
if (!doesMLSGroupExist) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const members = await this.generateSubconversationMembers(subconversationGroupId, parentConversationGroupId);
|
|
148
|
+
if (shouldAdvanceEpoch) {
|
|
149
|
+
await this.mlsService.renewKeyMaterial(subconversationGroupId);
|
|
150
|
+
}
|
|
151
|
+
const epoch = Number(await this.mlsService.getEpoch(subconversationGroupId));
|
|
152
|
+
const secretKey = await this.mlsService.exportSecretKey(subconversationGroupId, MLS_CONVERSATION_KEY_LENGTH);
|
|
153
|
+
return { members, epoch, keyLength: MLS_CONVERSATION_KEY_LENGTH, secretKey };
|
|
154
|
+
}
|
|
155
|
+
async subscribeToEpochUpdates(parentConversationId, parentConversationGroupId, findConversationByGroupId, onEpochUpdate) {
|
|
156
|
+
const { epoch: initialEpoch, groupId: subconversationGroupId } = await this.joinConferenceSubconversation(parentConversationId);
|
|
157
|
+
const forwardNewEpoch = async ({ groupId, epoch }) => {
|
|
158
|
+
if (groupId !== subconversationGroupId) {
|
|
159
|
+
// if the epoch update did not happen in the subconversation directly, check if it happened in the parent conversation
|
|
160
|
+
const parentConversationId = findConversationByGroupId(groupId);
|
|
161
|
+
if (!parentConversationId) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const foundSubconversationGroupId = await this.getSubconversationGroupId(parentConversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
165
|
+
// if the conference subconversation of parent conversation is not known, ignore the epoch update
|
|
166
|
+
if (foundSubconversationGroupId !== subconversationGroupId) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const subconversationEpochInfo = await this.getSubconversationEpochInfo(parentConversationId, parentConversationGroupId);
|
|
171
|
+
if (!subconversationEpochInfo) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
return onEpochUpdate(Object.assign(Object.assign({}, subconversationEpochInfo), { epoch: Number(epoch) }));
|
|
175
|
+
};
|
|
176
|
+
this.mlsService.on('newEpoch', forwardNewEpoch);
|
|
177
|
+
await forwardNewEpoch({ groupId: subconversationGroupId, epoch: initialEpoch });
|
|
178
|
+
return () => this.mlsService.off('newEpoch', forwardNewEpoch);
|
|
179
|
+
}
|
|
180
|
+
async removeClientFromConferenceSubconversation(conversationId, clientToRemove) {
|
|
181
|
+
const subconversationGroupId = await this.getSubconversationGroupId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
182
|
+
if (!subconversationGroupId) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const doesMLSGroupExist = await this.mlsService.conversationExists(subconversationGroupId);
|
|
186
|
+
if (!doesMLSGroupExist) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const { user: { id: userId, domain }, clientId, } = clientToRemove;
|
|
190
|
+
const clientToRemoveQualifiedId = (0, fullyQualifiedClientIdUtils_1.constructFullyQualifiedClientId)(userId, clientId, domain);
|
|
191
|
+
const subconversationMembers = await this.mlsService.getClientIds(subconversationGroupId);
|
|
192
|
+
const isSubconversationMember = subconversationMembers.some(({ userId, clientId, domain }) => (0, fullyQualifiedClientIdUtils_1.constructFullyQualifiedClientId)(userId, clientId, domain) === clientToRemoveQualifiedId);
|
|
193
|
+
if (!isSubconversationMember) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
return void this.mlsService.removeClientsFromConversation(subconversationGroupId, [clientToRemoveQualifiedId]);
|
|
197
|
+
}
|
|
198
|
+
async joinSubconversationByExternalCommit(conversationId, subconversation) {
|
|
199
|
+
await this.mlsService.joinByExternalCommit(() => this.apiClient.api.conversation.getSubconversationGroupInfo(conversationId, subconversation));
|
|
200
|
+
}
|
|
201
|
+
async getConferenceSubconversation(conversationId) {
|
|
202
|
+
return this.apiClient.api.conversation.getSubconversation(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
203
|
+
}
|
|
204
|
+
async deleteConferenceSubconversation(conversationId, data) {
|
|
205
|
+
return this.apiClient.api.conversation.deleteSubconversation(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE, data);
|
|
206
|
+
}
|
|
207
|
+
async generateSubconversationMembers(subconversationGroupId, parentGroupId) {
|
|
208
|
+
const subconversationMemberIds = await this.mlsService.getClientIds(subconversationGroupId);
|
|
209
|
+
const parentMemberIds = await this.mlsService.getClientIds(parentGroupId);
|
|
210
|
+
return parentMemberIds.map(parentMember => {
|
|
211
|
+
const isSubconversationMember = subconversationMemberIds.some(({ userId, clientId, domain }) => (0, fullyQualifiedClientIdUtils_1.constructFullyQualifiedClientId)(userId, clientId, domain) ===
|
|
212
|
+
(0, fullyQualifiedClientIdUtils_1.constructFullyQualifiedClientId)(parentMember.userId, parentMember.clientId, parentMember.domain));
|
|
213
|
+
return {
|
|
214
|
+
userid: `${parentMember.userId}@${parentMember.domain}`,
|
|
215
|
+
clientid: parentMember.clientId,
|
|
216
|
+
in_subconv: isSubconversationMember,
|
|
217
|
+
};
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
exports.SubconversationService = SubconversationService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubconversationService.test.d.ts","sourceRoot":"","sources":["../../../src/conversation/SubconversationService/SubconversationService.test.ts"],"names":[],"mappings":""}
|