@wireapp/core 43.1.4 → 43.3.0
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 +1 -2
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +6 -6
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.js +4 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.js +19 -7
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.d.ts +4 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.js +72 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/index.d.ts +2 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/index.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/index.js +35 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.d.ts +1 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.js +1 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts +2 -4
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +1 -8
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.js +3 -11
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +3 -2
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +52 -40
- package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +7 -1
- package/package.json +4 -4
package/lib/Account.d.ts
CHANGED
|
@@ -117,11 +117,10 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
117
117
|
useAPIVersion(min: number, max: number, allowDev?: boolean): Promise<BackendFeatures>;
|
|
118
118
|
private persistCookie;
|
|
119
119
|
private getE2EIStatus;
|
|
120
|
-
enrollE2EI({ displayName, handle, discoveryUrl,
|
|
120
|
+
enrollE2EI({ displayName, handle, discoveryUrl, oAuthIdToken, }: {
|
|
121
121
|
displayName: string;
|
|
122
122
|
handle: string;
|
|
123
123
|
discoveryUrl: string;
|
|
124
|
-
refreshActiveCertificate?: boolean;
|
|
125
124
|
oAuthIdToken?: string;
|
|
126
125
|
}): Promise<AcmeChallenge | boolean>;
|
|
127
126
|
get clientId(): string;
|
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,EAEV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAuB,UAAU,EAAE,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AAEnG,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAC;AASxD,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;AA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commons_1.TypedEventEmitter {
|
|
|
186
186
|
isFeatureEnabled: clientCanUseE2EI && teamCanUseE2EI,
|
|
187
187
|
};
|
|
188
188
|
}
|
|
189
|
-
async enrollE2EI({ displayName, handle, discoveryUrl,
|
|
189
|
+
async enrollE2EI({ displayName, handle, discoveryUrl, oAuthIdToken, }) {
|
|
190
190
|
var _a, _b, _c;
|
|
191
191
|
const context = this.apiClient.context;
|
|
192
192
|
const domain = (_a = context === null || context === void 0 ? void 0 : context.domain) !== null && _a !== void 0 ? _a : '';
|
|
@@ -203,7 +203,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
203
203
|
domain,
|
|
204
204
|
id: this.userId,
|
|
205
205
|
};
|
|
206
|
-
return this.service.mls.enrollE2EI(discoveryUrl, this.service.e2eIdentity, user, this.currentClient, this.nbPrekeys,
|
|
206
|
+
return this.service.mls.enrollE2EI(discoveryUrl, this.service.e2eIdentity, user, this.currentClient, this.nbPrekeys, oAuthIdToken);
|
|
207
207
|
}
|
|
208
208
|
get clientId() {
|
|
209
209
|
return this.apiClient.validatedClientId;
|
|
@@ -343,15 +343,15 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
343
343
|
const assetService = new conversation_1.AssetService(this.apiClient);
|
|
344
344
|
const [clientType, cryptoClient] = await this.buildCryptoClient(context, this.storeEngine);
|
|
345
345
|
let mlsService;
|
|
346
|
-
let
|
|
346
|
+
let e2eServiceExternal;
|
|
347
347
|
const proteusService = new proteus_1.ProteusService(this.apiClient, cryptoClient, {
|
|
348
348
|
onNewClient: payload => this.emit(EVENTS.NEW_SESSION, payload),
|
|
349
349
|
nbPrekeys: this.nbPrekeys,
|
|
350
350
|
});
|
|
351
351
|
const clientService = new client_2.ClientService(this.apiClient, proteusService, this.storeEngine);
|
|
352
352
|
if (clientType === CryptoClient_1.CryptoClientType.CORE_CRYPTO && (await this.isMlsEnabled())) {
|
|
353
|
-
|
|
354
|
-
mlsService = new mls_1.MLSService(this.apiClient, cryptoClient.getNativeClient(), this.db, this.recurringTaskScheduler, Object.assign({}, (_a = this.coreCryptoConfig) === null || _a === void 0 ? void 0 : _a.mls));
|
|
353
|
+
e2eServiceExternal = new E2EIdentityService_1.E2EIServiceExternal(cryptoClient.getNativeClient(), clientService);
|
|
354
|
+
mlsService = new mls_1.MLSService(this.apiClient, cryptoClient.getNativeClient(), this.db, this.recurringTaskScheduler, e2eServiceExternal, Object.assign({}, (_a = this.coreCryptoConfig) === null || _a === void 0 ? void 0 : _a.mls));
|
|
355
355
|
}
|
|
356
356
|
const connectionService = new connection_1.ConnectionService(this.apiClient);
|
|
357
357
|
const giphyService = new giphy_1.GiphyService(this.apiClient);
|
|
@@ -364,7 +364,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
364
364
|
const broadcastService = new broadcast_1.BroadcastService(this.apiClient, proteusService);
|
|
365
365
|
const userService = new user_1.UserService(this.apiClient);
|
|
366
366
|
this.service = {
|
|
367
|
-
e2eIdentity:
|
|
367
|
+
e2eIdentity: e2eServiceExternal,
|
|
368
368
|
mls: mlsService,
|
|
369
369
|
proteus: proteusService,
|
|
370
370
|
account: accountService,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"E2EIServiceExternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAKhH,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAG9C,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG;IAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAAC;AAG/G,qBAAa,mBAAmB;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;CAAC,CAAC;AAG/G,qBAAa,mBAAmB;IAI5B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAJhC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuD;gBAG3D,gBAAgB,EAAE,UAAU,EAC5B,aAAa,EAAE,aAAa;IAIxC,oBAAoB,IAAI,OAAO;IAK/B,kBAAkB,IAAI,MAAM,GAAG,SAAS;IAUxC,sBAAsB,IAAI,OAAO;IAIjC,gBAAgB,IAAI,IAAI;IAIxB,oBAAoB,CAAC,cAAc,EAAE,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIhF,aAAa,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAInD,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;IA6CnG,oBAAoB,CAC/B,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC1C,OAAO,CAAC,cAAc,EAAE,CAAC;IAef,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;CAOtD"}
|
|
@@ -91,7 +91,10 @@ class E2EIServiceExternal {
|
|
|
91
91
|
}
|
|
92
92
|
async isFreshMLSSelfClient() {
|
|
93
93
|
const client = await this.clientService.loadClient();
|
|
94
|
-
|
|
94
|
+
if (!client) {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
return typeof client.mls_public_keys.ed25519 !== 'string' || client.mls_public_keys.ed25519.length === 0;
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
exports.E2EIServiceExternal = E2EIServiceExternal;
|
|
@@ -11,7 +11,7 @@ declare class E2EIServiceInternal {
|
|
|
11
11
|
private isInitialized;
|
|
12
12
|
private constructor();
|
|
13
13
|
static getInstance(params?: InitParams): Promise<E2EIServiceInternal>;
|
|
14
|
-
startCertificateProcess(
|
|
14
|
+
startCertificateProcess(): Promise<AcmeChallenge | undefined>;
|
|
15
15
|
continueCertificateProcess(oAuthIdToken: string): Promise<RotateBundle | undefined>;
|
|
16
16
|
private initIdentity;
|
|
17
17
|
private exitWithError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"E2EIServiceInternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.ts"],"names":[],"mappings":"AAyBA,OAAO,EACL,aAAa,EAKb,UAAU,EACV,YAAY,EACb,MAAM,qBAAqB,CAAC;AAW7B,cAAM,mBAAmB;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuD;IAC9E,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAa;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAsB;IACzD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC;IACnC,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAClC,OAAO,CAAC,WAAW,CAAC,CAAc;IAClC,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO;WAea,WAAW,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAwBrE,uBAAuB
|
|
1
|
+
{"version":3,"file":"E2EIServiceInternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.ts"],"names":[],"mappings":"AAyBA,OAAO,EACL,aAAa,EAKb,UAAU,EACV,YAAY,EACb,MAAM,qBAAqB,CAAC;AAW7B,cAAM,mBAAmB;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuD;IAC9E,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAa;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAsB;IACzD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC;IACnC,OAAO,CAAC,QAAQ,CAAC,CAAiB;IAClC,OAAO,CAAC,WAAW,CAAC,CAAc;IAClC,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO;WAea,WAAW,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAwBrE,uBAAuB;IAYvB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;YAelF,YAAY;IA8B1B,OAAO,CAAC,aAAa;YAKP,IAAI;YAeJ,YAAY;YAeZ,eAAe;IAa7B;;;;;OAKG;YACW,gCAAgC;IAgD9C;;;;;;;OAOG;YACW,sCAAsC;IA2EpD;;;OAGG;YACW,iBAAiB;IA0B/B;;;;;;OAMG;YACW,iBAAiB;IAmB/B;;;;;OAKG;IACU,0BAA0B,CAAC,YAAY,EAAE,MAAM;CAkB7D;AAED,OAAO,EAAC,mBAAmB,EAAC,CAAC"}
|
|
@@ -63,12 +63,12 @@ class E2EIServiceInternal {
|
|
|
63
63
|
}
|
|
64
64
|
return E2EIServiceInternal.instance;
|
|
65
65
|
}
|
|
66
|
-
async startCertificateProcess(
|
|
66
|
+
async startCertificateProcess() {
|
|
67
67
|
// Step 0: Check if we have a handle in local storage
|
|
68
68
|
// If we don't have a handle, we need to start a new OAuth flow
|
|
69
69
|
try {
|
|
70
70
|
// Initialize the identity
|
|
71
|
-
await this.initIdentity(
|
|
71
|
+
await this.initIdentity();
|
|
72
72
|
return this.startNewOAuthFlow();
|
|
73
73
|
}
|
|
74
74
|
catch (error) {
|
|
@@ -89,13 +89,19 @@ class E2EIServiceInternal {
|
|
|
89
89
|
return undefined;
|
|
90
90
|
}
|
|
91
91
|
// ############ Internal Functions ############
|
|
92
|
-
async initIdentity(
|
|
92
|
+
async initIdentity() {
|
|
93
93
|
const { clientId, user } = E2EIStorage_1.E2EIStorage.get.initialData();
|
|
94
94
|
const e2eiClientId = (0, Helper_1.getE2EIClientId)(clientId, user.id, user.domain).asString;
|
|
95
95
|
const expiryDays = 2;
|
|
96
96
|
const ciphersuite = E2EIService_types_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519;
|
|
97
|
-
if (
|
|
98
|
-
|
|
97
|
+
if (this.e2eServiceExternal.hasActiveCertificate()) {
|
|
98
|
+
try {
|
|
99
|
+
this.identity = await this.coreCryptoClient.e2eiNewRotateEnrollment(e2eiClientId, expiryDays, ciphersuite, user.displayName, user.handle);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
this.logger.error('Error while trying to initIdentity e2eiNewRotateEnrollment', error);
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
99
105
|
}
|
|
100
106
|
else {
|
|
101
107
|
this.identity = await this.coreCryptoClient.e2eiNewActivationEnrollment(e2eiClientId, user.displayName, user.handle, expiryDays, ciphersuite);
|
|
@@ -260,7 +266,13 @@ class E2EIServiceInternal {
|
|
|
260
266
|
}
|
|
261
267
|
E2EIStorage_1.E2EIStorage.store.certificate(certificate);
|
|
262
268
|
// Step 10: Initialize MLS with the certificate
|
|
263
|
-
|
|
269
|
+
try {
|
|
270
|
+
return await this.coreCryptoClient.e2eiRotateAll(this.identity, certificate, this.keyPackagesAmount);
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
this.logger.error('Error while e2eiRotateAll', error);
|
|
274
|
+
throw error;
|
|
275
|
+
}
|
|
264
276
|
}
|
|
265
277
|
/**
|
|
266
278
|
* This function starts a new ACME enrollment flow for either a new client
|
|
@@ -322,7 +334,7 @@ class E2EIServiceInternal {
|
|
|
322
334
|
return this.exitWithError('Error while trying to continue OAuth flow. AcmeService is not initialized');
|
|
323
335
|
}
|
|
324
336
|
// We need to initialize the identity
|
|
325
|
-
await this.initIdentity(
|
|
337
|
+
await this.initIdentity();
|
|
326
338
|
await this.getAndStoreInitialEnrollmentData();
|
|
327
339
|
return await this.getRotateBundleAndStoreCertificateData(oAuthIdToken);
|
|
328
340
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const queueIncomingMLSMessage: <EventHandler extends (...args: any[]) => any>(groupId: string, handler: EventHandler) => Promise<ReturnType<EventHandler>>;
|
|
2
|
+
export declare const deleteMLSMessagesQueue: (groupId: string) => void;
|
|
3
|
+
export declare const withLockedMLSMessagesQueue: <T>(groupId: string, fn: () => Promise<T>) => Promise<T>;
|
|
4
|
+
//# sourceMappingURL=IncomingMesssagesQueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IncomingMesssagesQueue.d.ts","sourceRoot":"","sources":["../../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.ts"],"names":[],"mappings":"AA2CA,eAAO,MAAM,uBAAuB,kCAAyC,GAAG,EAAE,KAAK,GAAG,WAC/E,MAAM,6DAKhB,CAAC;AAEF,eAAO,MAAM,sBAAsB,YAAa,MAAM,SAErD,CAAC;AAcF,eAAO,MAAM,0BAA0B,eAAsB,MAAM,qCAUlE,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
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.withLockedMLSMessagesQueue = exports.deleteMLSMessagesQueue = exports.queueIncomingMLSMessage = void 0;
|
|
25
|
+
const logdown_1 = __importDefault(require("logdown"));
|
|
26
|
+
const promise_queue_1 = require("@wireapp/promise-queue");
|
|
27
|
+
const logger = (0, logdown_1.default)('@wireapp/core/MLSService/IncomingMessagesQueue');
|
|
28
|
+
// (groupId string -> queue) map
|
|
29
|
+
const queues = new Map();
|
|
30
|
+
const getQueue = (groupId) => {
|
|
31
|
+
const queue = queues.get(groupId);
|
|
32
|
+
if (queue) {
|
|
33
|
+
return queue;
|
|
34
|
+
}
|
|
35
|
+
const newConversationQueue = new promise_queue_1.PromiseQueue({
|
|
36
|
+
name: `mls-messages-queue-${groupId}`,
|
|
37
|
+
});
|
|
38
|
+
queues.set(groupId, newConversationQueue);
|
|
39
|
+
return newConversationQueue;
|
|
40
|
+
};
|
|
41
|
+
const queueIncomingMLSMessage = async (groupId, handler) => {
|
|
42
|
+
const conversationQueue = getQueue(groupId);
|
|
43
|
+
return conversationQueue.push(handler);
|
|
44
|
+
};
|
|
45
|
+
exports.queueIncomingMLSMessage = queueIncomingMLSMessage;
|
|
46
|
+
const deleteMLSMessagesQueue = (groupId) => {
|
|
47
|
+
queues.delete(groupId);
|
|
48
|
+
};
|
|
49
|
+
exports.deleteMLSMessagesQueue = deleteMLSMessagesQueue;
|
|
50
|
+
const lockMLSMessagesQueue = (groupId) => {
|
|
51
|
+
logger.info(`Locking incoming MLS messages queue for group ${groupId}`);
|
|
52
|
+
const conversationQueue = getQueue(groupId);
|
|
53
|
+
conversationQueue.pause(true);
|
|
54
|
+
};
|
|
55
|
+
const unlockMLSMessagesQueue = (groupId) => {
|
|
56
|
+
logger.info(`Unlocking incoming MLS messages queue for group ${groupId}`);
|
|
57
|
+
const conversationQueue = getQueue(groupId);
|
|
58
|
+
conversationQueue.pause(false);
|
|
59
|
+
};
|
|
60
|
+
const withLockedMLSMessagesQueue = async (groupId, fn) => {
|
|
61
|
+
lockMLSMessagesQueue(groupId);
|
|
62
|
+
try {
|
|
63
|
+
const result = await fn();
|
|
64
|
+
unlockMLSMessagesQueue(groupId);
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
unlockMLSMessagesQueue(groupId);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
exports.withLockedMLSMessagesQueue = withLockedMLSMessagesQueue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/index.ts"],"names":[],"mappings":"AAmBA,cAAc,0BAA0B,CAAC"}
|
package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
}) : (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
}));
|
|
31
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
32
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
__exportStar(require("./IncomingMesssagesQueue"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/index.ts"],"names":[],"mappings":"AAmBA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/index.ts"],"names":[],"mappings":"AAmBA,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { SUBCONVERSATION_ID } from '@wireapp/api-client/lib/conversation';
|
|
2
1
|
import { ConversationMLSMessageAddEvent } from '@wireapp/api-client/lib/event';
|
|
3
|
-
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
4
2
|
import { HandledEventPayload } from '../../../../../notification';
|
|
5
3
|
import { MLSService } from '../../../MLSService/MLSService';
|
|
6
4
|
interface HandleMLSMessageAddParams {
|
|
7
5
|
event: ConversationMLSMessageAddEvent;
|
|
6
|
+
groupId: string;
|
|
8
7
|
mlsService: MLSService;
|
|
9
|
-
groupIdFromConversationId: (conversationId: QualifiedId, subconversationId?: SUBCONVERSATION_ID) => Promise<string | undefined>;
|
|
10
8
|
}
|
|
11
|
-
export declare const handleMLSMessageAdd: ({ event,
|
|
9
|
+
export declare const handleMLSMessageAdd: ({ event, groupId, mlsService, }: HandleMLSMessageAddParams) => Promise<HandledEventPayload | null>;
|
|
12
10
|
export {};
|
|
13
11
|
//# sourceMappingURL=messageAdd.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageAdd.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"messageAdd.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,8BAA8B,EAAC,MAAM,+BAA+B,CAAC;AAK7E,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,UAAU,EAAuB,MAAM,gCAAgC,CAAC;AAEhF,UAAU,yBAAyB;IACjC,KAAK,EAAE,8BAA8B,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,eAAO,MAAM,mBAAmB,oCAI7B,yBAAyB,KAAG,QAAQ,mBAAmB,GAAG,IAAI,CAoChE,CAAC"}
|
|
@@ -22,15 +22,8 @@ exports.handleMLSMessageAdd = void 0;
|
|
|
22
22
|
const bazinga64_1 = require("bazinga64");
|
|
23
23
|
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
24
24
|
const MLSService_1 = require("../../../MLSService/MLSService");
|
|
25
|
-
const handleMLSMessageAdd = async ({ event,
|
|
26
|
-
var _a;
|
|
25
|
+
const handleMLSMessageAdd = async ({ event, groupId, mlsService, }) => {
|
|
27
26
|
const encryptedData = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
|
|
28
|
-
const qualifiedConversationId = (_a = event.qualified_conversation) !== null && _a !== void 0 ? _a : { id: event.conversation, domain: '' };
|
|
29
|
-
const groupId = await groupIdFromConversationId(qualifiedConversationId, event.subconv);
|
|
30
|
-
// We should not receive a message for a group the client is not aware of
|
|
31
|
-
if (!groupId) {
|
|
32
|
-
throw new Error(`Could not find a group_id for conversation ${qualifiedConversationId.id}@${qualifiedConversationId.domain}`);
|
|
33
|
-
}
|
|
34
27
|
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
35
28
|
const { proposals, commitDelay, message, senderClientId: encodedSenderClientId, hasEpochChanged, } = await mlsService.decryptMessage(groupIdBytes, encryptedData);
|
|
36
29
|
if (encodedSenderClientId) {
|
|
@@ -44,15 +44,9 @@ const createMockedMessage = () => {
|
|
|
44
44
|
})).finish();
|
|
45
45
|
};
|
|
46
46
|
describe('handleMLSMessageAdd', () => {
|
|
47
|
-
it('throws when received a message for a group that is not known by a client', async () => {
|
|
48
|
-
const event = createMLSMessageAddEventMock({ id: 'conversationId', domain: 'staging.zinfra.io' });
|
|
49
|
-
const groupIdFromConversationId = () => Promise.resolve(undefined);
|
|
50
|
-
await expect((0, messageAdd_1.handleMLSMessageAdd)({ event, mlsService: mockedMLSService, groupIdFromConversationId })).rejects.toThrow();
|
|
51
|
-
});
|
|
52
47
|
it('does not handle pending proposals if message does not contain proposals', async () => {
|
|
53
48
|
const event = createMLSMessageAddEventMock({ id: 'conversationId', domain: 'staging.zinfra.io' });
|
|
54
49
|
const mockGroupId = 'AAEAAH87aajaQ011i+rNLmwpy0sAZGl5YS53aXJlLmxpbms=';
|
|
55
|
-
const groupIdFromConversationId = () => Promise.resolve(mockGroupId);
|
|
56
50
|
const message = createMockedMessage();
|
|
57
51
|
jest.spyOn(mockedMLSService, 'decryptMessage').mockResolvedValueOnce({
|
|
58
52
|
proposals: [],
|
|
@@ -61,13 +55,12 @@ describe('handleMLSMessageAdd', () => {
|
|
|
61
55
|
hasEpochChanged: false,
|
|
62
56
|
isActive: true,
|
|
63
57
|
});
|
|
64
|
-
await (0, messageAdd_1.handleMLSMessageAdd)({ event, mlsService: mockedMLSService,
|
|
58
|
+
await (0, messageAdd_1.handleMLSMessageAdd)({ event, mlsService: mockedMLSService, groupId: mockGroupId });
|
|
65
59
|
expect(mockedMLSService.handlePendingProposals).not.toHaveBeenCalled();
|
|
66
60
|
});
|
|
67
61
|
it('handles pending proposals if message includes proposals', async () => {
|
|
68
62
|
const event = createMLSMessageAddEventMock({ id: 'conversationId', domain: 'staging.zinfra.io' });
|
|
69
63
|
const mockGroupId = 'AAEAAH87aajaQ011i+rNLmwpy0sAZGl5YS53aXJlLmxpbms=';
|
|
70
|
-
const groupIdFromConversationId = () => Promise.resolve(mockGroupId);
|
|
71
64
|
const message = createMockedMessage();
|
|
72
65
|
jest.spyOn(mockedMLSService, 'decryptMessage').mockResolvedValueOnce({
|
|
73
66
|
proposals: [{ proposal: new Uint8Array(), proposalRef: new Uint8Array() }],
|
|
@@ -76,7 +69,7 @@ describe('handleMLSMessageAdd', () => {
|
|
|
76
69
|
hasEpochChanged: false,
|
|
77
70
|
isActive: true,
|
|
78
71
|
});
|
|
79
|
-
await (0, messageAdd_1.handleMLSMessageAdd)({ event, mlsService: mockedMLSService,
|
|
72
|
+
await (0, messageAdd_1.handleMLSMessageAdd)({ event, mlsService: mockedMLSService, groupId: mockGroupId });
|
|
80
73
|
expect(mockedMLSService.handlePendingProposals).toHaveBeenCalledWith({
|
|
81
74
|
groupId: mockGroupId,
|
|
82
75
|
delayInMs: 2000,
|
|
@@ -86,7 +79,6 @@ describe('handleMLSMessageAdd', () => {
|
|
|
86
79
|
it('emits "newEpoch" event if incoming message has advanced epoch number', async () => {
|
|
87
80
|
const event = createMLSMessageAddEventMock({ id: 'conversationId', domain: 'staging.zinfra.io' });
|
|
88
81
|
const mockGroupId = 'AAEAAH87aajaQ011i+rNLmwpy0sAZGl5YS53aXJlLmxpbms=';
|
|
89
|
-
const groupIdFromConversationId = () => Promise.resolve(mockGroupId);
|
|
90
82
|
const message = createMockedMessage();
|
|
91
83
|
jest.spyOn(mockedMLSService, 'decryptMessage').mockResolvedValueOnce({
|
|
92
84
|
proposals: [],
|
|
@@ -96,7 +88,7 @@ describe('handleMLSMessageAdd', () => {
|
|
|
96
88
|
});
|
|
97
89
|
const mockedNewEpoch = 5;
|
|
98
90
|
jest.spyOn(mockedMLSService, 'getEpoch').mockResolvedValueOnce(mockedNewEpoch);
|
|
99
|
-
await (0, messageAdd_1.handleMLSMessageAdd)({ event, mlsService: mockedMLSService,
|
|
91
|
+
await (0, messageAdd_1.handleMLSMessageAdd)({ event, mlsService: mockedMLSService, groupId: mockGroupId });
|
|
100
92
|
expect(mockedMLSService.emit).toHaveBeenCalledWith('newEpoch', {
|
|
101
93
|
groupId: mockGroupId,
|
|
102
94
|
epoch: mockedNewEpoch,
|
|
@@ -30,11 +30,12 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
30
30
|
private readonly coreCryptoClient;
|
|
31
31
|
private readonly coreDatabase;
|
|
32
32
|
private readonly recurringTaskScheduler;
|
|
33
|
+
private readonly e2eServiceExternal;
|
|
33
34
|
logger: logdown.Logger;
|
|
34
35
|
config: LocalMLSServiceConfig;
|
|
35
36
|
private readonly textEncoder;
|
|
36
37
|
private readonly textDecoder;
|
|
37
|
-
constructor(apiClient: APIClient, coreCryptoClient: CoreCrypto, coreDatabase: CoreDatabase, recurringTaskScheduler: RecurringTaskScheduler, { keyingMaterialUpdateThreshold, nbKeyPackages, cipherSuite, }: Partial<MLSServiceConfig>);
|
|
38
|
+
constructor(apiClient: APIClient, coreCryptoClient: CoreCrypto, coreDatabase: CoreDatabase, recurringTaskScheduler: RecurringTaskScheduler, e2eServiceExternal: E2EIServiceExternal, { keyingMaterialUpdateThreshold, nbKeyPackages, cipherSuite, }: Partial<MLSServiceConfig>);
|
|
38
39
|
initClient(userId: QualifiedId, client: RegisteredClient, blockKeypackageUpload?: boolean): Promise<void>;
|
|
39
40
|
private getCredentialType;
|
|
40
41
|
private readonly uploadCommitBundle;
|
|
@@ -209,7 +210,7 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
209
210
|
* @param oAuthIdToken The OAuth id token if the user is already authenticated
|
|
210
211
|
* @returns AcmeChallenge if the user is not authenticated, true if the user is authenticated
|
|
211
212
|
*/
|
|
212
|
-
enrollE2EI(discoveryUrl: string, e2eiServiceExternal: E2EIServiceExternal, user: User, client: RegisteredClient, nbPrekeys: number,
|
|
213
|
+
enrollE2EI(discoveryUrl: string, e2eiServiceExternal: E2EIServiceExternal, user: User, client: RegisteredClient, nbPrekeys: number, oAuthIdToken?: string): Promise<AcmeChallenge | boolean>;
|
|
213
214
|
}
|
|
214
215
|
export {};
|
|
215
216
|
//# sourceMappingURL=MLSService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MLSService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAqB,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAC,sBAAsB,EAAE,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAChG,OAAO,EAAC,8BAA8B,EAAE,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAE1G,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9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AAsB,CAAC,EAAC,OAAO,EAAE,UAAkB,EAAC,EAAE,4BAA4B;IAY/F;;;;OAIG;IACU,+BAA+B;IAiB5C;;;;OAIG;IACU,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;IAY9F,wBAAwB,CACnC,KAAK,EAAE,8BAA8B,EACrC,yBAAyB,EAAE,CACzB,cAAc,EAAE,WAAW,EAC3B,iBAAiB,CAAC,EAAE,kBAAkB,KACnC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAgBrB,4BAA4B,CAAC,KAAK,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM;IAcjF,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE;IASjF;;;;;;;;OAQG;IACU,UAAU,CACrB,YAAY,EAAE,MAAM,EACpB,mBAAmB,EAAE,mBAAmB,EACxC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC;CA4DpC"}
|
|
@@ -45,6 +45,7 @@ const numberToHex_1 = require("../../../util/numberToHex");
|
|
|
45
45
|
const TaskScheduler_1 = require("../../../util/TaskScheduler");
|
|
46
46
|
const E2EIServiceInternal_1 = require("../E2EIdentityService/E2EIServiceInternal");
|
|
47
47
|
const events_1 = require("../EventHandler/events");
|
|
48
|
+
const messageAdd_1 = require("../EventHandler/events/messageAdd");
|
|
48
49
|
const MLSId_1 = require("../utils/MLSId");
|
|
49
50
|
//@todo: this function is temporary, we wait for the update from core-crypto side
|
|
50
51
|
//they are returning regular array instead of Uint8Array for commit and welcome messages
|
|
@@ -58,52 +59,55 @@ const defaultConfig = {
|
|
|
58
59
|
cipherSuite: core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519,
|
|
59
60
|
};
|
|
60
61
|
class MLSService extends commons_1.TypedEventEmitter {
|
|
61
|
-
constructor(apiClient, coreCryptoClient, coreDatabase, recurringTaskScheduler, { keyingMaterialUpdateThreshold = defaultConfig.keyingMaterialUpdateThreshold, nbKeyPackages = defaultConfig.nbKeyPackages, cipherSuite = defaultConfig.cipherSuite, }) {
|
|
62
|
+
constructor(apiClient, coreCryptoClient, coreDatabase, recurringTaskScheduler, e2eServiceExternal, { keyingMaterialUpdateThreshold = defaultConfig.keyingMaterialUpdateThreshold, nbKeyPackages = defaultConfig.nbKeyPackages, cipherSuite = defaultConfig.cipherSuite, }) {
|
|
62
63
|
super();
|
|
63
64
|
this.apiClient = apiClient;
|
|
64
65
|
this.coreCryptoClient = coreCryptoClient;
|
|
65
66
|
this.coreDatabase = coreDatabase;
|
|
66
67
|
this.recurringTaskScheduler = recurringTaskScheduler;
|
|
68
|
+
this.e2eServiceExternal = e2eServiceExternal;
|
|
67
69
|
this.logger = (0, logdown_1.default)('@wireapp/core/MLSService');
|
|
68
70
|
this.textEncoder = new TextEncoder();
|
|
69
71
|
this.textDecoder = new TextDecoder();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
await this.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
catch (error) {
|
|
89
|
-
if (isExternalCommit) {
|
|
90
|
-
await this.coreCryptoClient.clearPendingGroupFromExternalCommit(groupId);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
await this.coreCryptoClient.clearPendingCommit(groupId);
|
|
72
|
+
this.uploadCommitBundle = async (groupId, commitBundle, { regenerateCommitBundle, isExternalCommit } = {}) => {
|
|
73
|
+
const groupIdStr = bazinga64_1.Encoder.toBase64(groupId).asString;
|
|
74
|
+
// We need to lock the incoming mls messages queue while we are uploading the commit bundle
|
|
75
|
+
// it's possible that we will be sent some mls messages before we receive the response from backend and accept a commit locally.
|
|
76
|
+
return (0, messageAdd_1.withLockedMLSMessagesQueue)(groupIdStr, async () => {
|
|
77
|
+
const { commit, groupInfo, welcome } = commitBundle;
|
|
78
|
+
const bundlePayload = new Uint8Array([...commit, ...groupInfo.payload, ...(welcome || [])]);
|
|
79
|
+
try {
|
|
80
|
+
const response = await this.apiClient.api.conversation.postMlsCommitBundle(bundlePayload);
|
|
81
|
+
if (isExternalCommit) {
|
|
82
|
+
await this.coreCryptoClient.mergePendingGroupFromExternalCommit(groupId);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
await this.coreCryptoClient.commitAccepted(groupId);
|
|
86
|
+
}
|
|
87
|
+
const newEpoch = await this.getEpoch(groupId);
|
|
88
|
+
this.emit('newEpoch', { epoch: newEpoch, groupId: groupIdStr });
|
|
89
|
+
return response;
|
|
94
90
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (isExternalCommit) {
|
|
93
|
+
await this.coreCryptoClient.clearPendingGroupFromExternalCommit(groupId);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
await this.coreCryptoClient.clearPendingCommit(groupId);
|
|
97
|
+
}
|
|
98
|
+
const shouldRetry = error instanceof http_1.BackendError && error.code === http_1.StatusCode.CONFLICT;
|
|
99
|
+
if (shouldRetry && regenerateCommitBundle) {
|
|
100
|
+
// in case of a 409, we want to retry to generate the commit and resend it
|
|
101
|
+
// could be that we are trying to upload a commit to a conversation that has a different epoch on backend
|
|
102
|
+
// in this case we will most likely receive a commit from backend that will increase our local epoch
|
|
103
|
+
this.logger.warn(`Uploading commitBundle failed. Will retry generating a new bundle`);
|
|
104
|
+
const updatedCommitBundle = await regenerateCommitBundle();
|
|
105
|
+
return this.uploadCommitBundle(groupId, updatedCommitBundle, { isExternalCommit });
|
|
106
|
+
}
|
|
107
|
+
throw error;
|
|
103
108
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
107
111
|
/**
|
|
108
112
|
* Will try to register mls group and send an empty commit to establish it.
|
|
109
113
|
*
|
|
@@ -490,6 +494,7 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
490
494
|
return this.apiClient.api.client.uploadMLSKeyPackages(clientId, keyPackages.map(keyPackage => btoa(bazinga64_1.Converter.arrayBufferViewToBaselineString(keyPackage))));
|
|
491
495
|
}
|
|
492
496
|
async wipeConversation(groupId) {
|
|
497
|
+
(0, messageAdd_1.deleteMLSMessagesQueue)(groupId);
|
|
493
498
|
await this.cancelKeyMaterialRenewal(groupId);
|
|
494
499
|
await this.cancelPendingProposalsTask(groupId);
|
|
495
500
|
const doesConversationExist = await this.conversationExists(groupId);
|
|
@@ -585,7 +590,14 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
585
590
|
return clientIds;
|
|
586
591
|
}
|
|
587
592
|
async handleMLSMessageAddEvent(event, groupIdFromConversationId) {
|
|
588
|
-
|
|
593
|
+
var _a;
|
|
594
|
+
const qualifiedConversationId = (_a = event.qualified_conversation) !== null && _a !== void 0 ? _a : { id: event.conversation, domain: '' };
|
|
595
|
+
const groupId = await groupIdFromConversationId(qualifiedConversationId, event.subconv);
|
|
596
|
+
// We should not receive a message for a group the client is not aware of
|
|
597
|
+
if (!groupId) {
|
|
598
|
+
throw new Error(`Could not find a group_id for conversation ${qualifiedConversationId.id}@${qualifiedConversationId.domain}`);
|
|
599
|
+
}
|
|
600
|
+
return (0, messageAdd_1.queueIncomingMLSMessage)(groupId, () => (0, events_1.handleMLSMessageAdd)({ event, mlsService: this, groupId }));
|
|
589
601
|
}
|
|
590
602
|
async handleMLSWelcomeMessageEvent(event, clientId) {
|
|
591
603
|
// Every time we've received a welcome message, it means that our key package was consumed,
|
|
@@ -613,7 +625,7 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
613
625
|
* @param oAuthIdToken The OAuth id token if the user is already authenticated
|
|
614
626
|
* @returns AcmeChallenge if the user is not authenticated, true if the user is authenticated
|
|
615
627
|
*/
|
|
616
|
-
async enrollE2EI(discoveryUrl, e2eiServiceExternal, user, client, nbPrekeys,
|
|
628
|
+
async enrollE2EI(discoveryUrl, e2eiServiceExternal, user, client, nbPrekeys, oAuthIdToken) {
|
|
617
629
|
try {
|
|
618
630
|
const instance = await E2EIServiceInternal_1.E2EIServiceInternal.getInstance({
|
|
619
631
|
apiClient: this.apiClient,
|
|
@@ -626,7 +638,7 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
626
638
|
});
|
|
627
639
|
// If we don't have an OAuth id token, we need to start the certificate process with Oauth
|
|
628
640
|
if (!oAuthIdToken) {
|
|
629
|
-
const challengeData = await instance.startCertificateProcess(
|
|
641
|
+
const challengeData = await instance.startCertificateProcess();
|
|
630
642
|
if (challengeData) {
|
|
631
643
|
return challengeData;
|
|
632
644
|
}
|
|
@@ -635,7 +647,7 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
635
647
|
else {
|
|
636
648
|
let rotateBundle;
|
|
637
649
|
// If we are not refreshing the active certificate, we need to continue the certificate process with Oauth
|
|
638
|
-
if (!
|
|
650
|
+
if (!this.e2eServiceExternal.hasActiveCertificate()) {
|
|
639
651
|
rotateBundle = await instance.continueCertificateProcess(oAuthIdToken);
|
|
640
652
|
// If we are refreshing the active certificate, can start the refresh process
|
|
641
653
|
}
|
|
@@ -28,12 +28,18 @@ const MLSService_1 = require("./MLSService");
|
|
|
28
28
|
const CoreDB_1 = require("../../../storage/CoreDB");
|
|
29
29
|
const RecurringTaskScheduler_1 = require("../../../util/RecurringTaskScheduler");
|
|
30
30
|
const TaskScheduler_1 = require("../../../util/TaskScheduler");
|
|
31
|
+
const E2EIdentityService_1 = require("../E2EIdentityService");
|
|
31
32
|
jest.createMockFromModule('@wireapp/api-client');
|
|
32
33
|
function createUserId() {
|
|
33
34
|
return { id: (0, crypto_1.randomUUID)(), domain: '' };
|
|
34
35
|
}
|
|
36
|
+
const coreCrypto = {
|
|
37
|
+
getUserIdentities: jest.fn(),
|
|
38
|
+
};
|
|
39
|
+
const clientService = {};
|
|
35
40
|
const createMLSService = async () => {
|
|
36
41
|
const apiClient = new api_client_1.APIClient();
|
|
42
|
+
const e2eServiceExternal = new E2EIdentityService_1.E2EIServiceExternal(coreCrypto, clientService);
|
|
37
43
|
const mockCoreCrypto = {
|
|
38
44
|
createConversation: jest.fn(),
|
|
39
45
|
conversationExists: jest.fn(),
|
|
@@ -57,7 +63,7 @@ const createMLSService = async () => {
|
|
|
57
63
|
await mockedDb.put('recurringTasks', { key, firingDate: timestamp });
|
|
58
64
|
},
|
|
59
65
|
});
|
|
60
|
-
const mlsService = new MLSService_1.MLSService(apiClient, mockCoreCrypto, mockedDb, recurringTaskScheduler, {});
|
|
66
|
+
const mlsService = new MLSService_1.MLSService(apiClient, mockCoreCrypto, mockedDb, recurringTaskScheduler, e2eServiceExternal, {});
|
|
61
67
|
return [mlsService, { apiClient, coreCrypto: mockCoreCrypto, recurringTaskScheduler }];
|
|
62
68
|
};
|
|
63
69
|
describe('MLSService', () => {
|
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.
|
|
14
|
+
"@wireapp/api-client": "^26.8.0",
|
|
15
15
|
"@wireapp/commons": "^5.2.3",
|
|
16
16
|
"@wireapp/core-crypto": "1.0.0-rc.21",
|
|
17
17
|
"@wireapp/cryptobox": "12.8.0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@wireapp/protocol-messaging": "1.44.0",
|
|
20
20
|
"@wireapp/store-engine": "5.1.5",
|
|
21
21
|
"@wireapp/store-engine-dexie": "^2.1.7",
|
|
22
|
-
"axios": "1.6.
|
|
22
|
+
"axios": "1.6.3",
|
|
23
23
|
"bazinga64": "^6.3.4",
|
|
24
24
|
"deepmerge-ts": "5.1.0",
|
|
25
25
|
"hash.js": "1.1.7",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
"test:coverage": "jest --coverage",
|
|
62
62
|
"watch": "tsc --watch"
|
|
63
63
|
},
|
|
64
|
-
"version": "43.
|
|
65
|
-
"gitHead": "
|
|
64
|
+
"version": "43.3.0",
|
|
65
|
+
"gitHead": "20455a80f5a03d0abf698f348acfe5d92a3f36a0"
|
|
66
66
|
}
|