@wireapp/core 43.2.0 → 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/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.js +4 -1
- 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.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +47 -36
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"E2EIServiceExternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/m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"}
|
|
@@ -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;
|
|
@@ -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,
|
|
@@ -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,MAA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e7D;;;;;;;OAOG;IACU,sBAAsB,CAAC,EAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAC,EAAE,4BAA4B;YAWnF,4BAA4B;YAU5B,0BAA0B;IAKxC,OAAO,CAAC,6BAA6B;IAIrC;;;;;OAKG;IACU,sBAAsB,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
|
|
@@ -68,43 +69,45 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
68
69
|
this.logger = (0, logdown_1.default)('@wireapp/core/MLSService');
|
|
69
70
|
this.textEncoder = new TextEncoder();
|
|
70
71
|
this.textDecoder = new TextDecoder();
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
await this.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
catch (error) {
|
|
90
|
-
if (isExternalCommit) {
|
|
91
|
-
await this.coreCryptoClient.clearPendingGroupFromExternalCommit(groupId);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
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;
|
|
95
90
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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;
|
|
104
108
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
108
111
|
/**
|
|
109
112
|
* Will try to register mls group and send an empty commit to establish it.
|
|
110
113
|
*
|
|
@@ -491,6 +494,7 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
491
494
|
return this.apiClient.api.client.uploadMLSKeyPackages(clientId, keyPackages.map(keyPackage => btoa(bazinga64_1.Converter.arrayBufferViewToBaselineString(keyPackage))));
|
|
492
495
|
}
|
|
493
496
|
async wipeConversation(groupId) {
|
|
497
|
+
(0, messageAdd_1.deleteMLSMessagesQueue)(groupId);
|
|
494
498
|
await this.cancelKeyMaterialRenewal(groupId);
|
|
495
499
|
await this.cancelPendingProposalsTask(groupId);
|
|
496
500
|
const doesConversationExist = await this.conversationExists(groupId);
|
|
@@ -586,7 +590,14 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
586
590
|
return clientIds;
|
|
587
591
|
}
|
|
588
592
|
async handleMLSMessageAddEvent(event, groupIdFromConversationId) {
|
|
589
|
-
|
|
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 }));
|
|
590
601
|
}
|
|
591
602
|
async handleMLSWelcomeMessageEvent(event, clientId) {
|
|
592
603
|
// Every time we've received a welcome message, it means that our key package was consumed,
|
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
|
}
|