@wireapp/core 41.2.2 → 41.2.4
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.js +1 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts +6 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +22 -0
- package/lib/conversation/ConversationService/ConversationService.types.d.ts +1 -2
- package/lib/conversation/ConversationService/ConversationService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts +7 -7
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +4 -6
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.js +79 -12
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.d.ts +7 -7
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.js +3 -6
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js +2 -16
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +0 -3
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +0 -11
- package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.d.ts +8 -8
- package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.js +11 -12
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts +5 -4
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.js +9 -13
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.test.js +9 -10
- package/lib/notification/NotificationService.d.ts +3 -6
- package/lib/notification/NotificationService.d.ts.map +1 -1
- package/lib/notification/NotificationService.js +11 -30
- package/lib/notification/NotificationService.test.js +5 -6
- package/package.json +2 -2
- package/lib/messagingProtocols/mls/EventHandler/EventHandler.d.ts +0 -5
- package/lib/messagingProtocols/mls/EventHandler/EventHandler.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/EventHandler/EventHandler.js +0 -32
- package/lib/messagingProtocols/mls/EventHandler/EventHandler.types.d.ts +0 -11
- package/lib/messagingProtocols/mls/EventHandler/EventHandler.types.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/EventHandler/EventHandler.types.js +0 -20
- package/lib/messagingProtocols/mls/EventHandler/index.d.ts +0 -3
- package/lib/messagingProtocols/mls/EventHandler/index.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/EventHandler/index.js +0 -36
- package/lib/messagingProtocols/proteus/EventHandler/EventHandler.d.ts +0 -5
- package/lib/messagingProtocols/proteus/EventHandler/EventHandler.d.ts.map +0 -1
- package/lib/messagingProtocols/proteus/EventHandler/EventHandler.js +0 -29
- package/lib/messagingProtocols/proteus/EventHandler/EventHandler.types.d.ts +0 -11
- package/lib/messagingProtocols/proteus/EventHandler/EventHandler.types.d.ts.map +0 -1
- package/lib/messagingProtocols/proteus/EventHandler/EventHandler.types.js +0 -20
- package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.test.d.ts +0 -2
- package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.test.d.ts.map +0 -1
- package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.test.js +0 -38
- package/lib/messagingProtocols/proteus/EventHandler/index.d.ts +0 -3
- package/lib/messagingProtocols/proteus/EventHandler/index.d.ts.map +0 -1
- package/lib/messagingProtocols/proteus/EventHandler/index.js +0 -36
package/lib/Account.js
CHANGED
|
@@ -270,8 +270,8 @@ class Account extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
270
270
|
const connectionService = new connection_1.ConnectionService(this.apiClient);
|
|
271
271
|
const giphyService = new giphy_1.GiphyService(this.apiClient);
|
|
272
272
|
const linkPreviewService = new linkPreview_1.LinkPreviewService(assetService);
|
|
273
|
-
const notificationService = new notification_1.NotificationService(this.apiClient, proteusService, this.storeEngine, mlsService);
|
|
274
273
|
const conversationService = new conversation_1.ConversationService(this.apiClient, proteusService, mlsService);
|
|
274
|
+
const notificationService = new notification_1.NotificationService(this.apiClient, this.storeEngine, conversationService);
|
|
275
275
|
const selfService = new self_1.SelfService(this.apiClient);
|
|
276
276
|
const teamService = new team_1.TeamService(this.apiClient);
|
|
277
277
|
const broadcastService = new broadcast_1.BroadcastService(this.apiClient, proteusService);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, RemoteConversations, PostMlsMessageResponse } from '@wireapp/api-client/lib/conversation';
|
|
2
|
-
import { ConversationMemberLeaveEvent } from '@wireapp/api-client/lib/event';
|
|
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';
|
|
5
5
|
import { APIClient } from '@wireapp/api-client';
|
|
@@ -8,6 +8,7 @@ import { MessageTimer, RemoveUsersParams } from '../../conversation/';
|
|
|
8
8
|
import { MLSService } from '../../messagingProtocols/mls';
|
|
9
9
|
import { ProteusService } from '../../messagingProtocols/proteus';
|
|
10
10
|
import { AddUsersToProteusConversationParams, SendProteusMessageParams } from '../../messagingProtocols/proteus/ProteusService/ProteusService.types';
|
|
11
|
+
import { HandledEventPayload } from '../../notification';
|
|
11
12
|
import { RemoteData } from '../content';
|
|
12
13
|
export declare class ConversationService {
|
|
13
14
|
private readonly apiClient;
|
|
@@ -100,5 +101,9 @@ export declare class ConversationService {
|
|
|
100
101
|
user: QualifiedId;
|
|
101
102
|
client: string;
|
|
102
103
|
}, otherUserId: QualifiedId) => Promise<void>;
|
|
104
|
+
private handleMLSMessageAddEvent;
|
|
105
|
+
private handleMLSWelcomeMessageEvent;
|
|
106
|
+
private handleOtrMessageAddEvent;
|
|
107
|
+
handleEvent(event: BackendEvent): Promise<HandledEventPayload | undefined>;
|
|
103
108
|
}
|
|
104
109
|
//# sourceMappingURL=ConversationService.d.ts.map
|
|
@@ -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,EACvB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,
|
|
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,EACvB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,YAAY,EAIZ,4BAA4B,EAE7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAIvD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAI9C,OAAO,EAEL,cAAc,EACd,6BAA6B,EAC7B,oBAAoB,EACpB,UAAU,EACX,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAC,YAAY,EAAuB,iBAAiB,EAAC,MAAM,qBAAqB,CAAC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AAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAmBvD,4BAA4B,CAAC,OAAO,EAAE,MAAM;IAI5C,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAIlD,YAAY;IAYb,mBAAmB;IA4BhC;;;;;;;OAOG;IACH,SAAgB,4BAA4B,YACjC,MAAM,YACL;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,eAChC,WAAW,KACvB,QAAQ,IAAI,CAAC,CA0Bd;YAEY,wBAAwB;YAIxB,4BAA4B;YAI5B,wBAAwB;IAIzB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;CAYxF"}
|
|
@@ -24,6 +24,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
24
24
|
exports.ConversationService = void 0;
|
|
25
25
|
const conversation_1 = require("@wireapp/api-client/lib/conversation");
|
|
26
26
|
const data_1 = require("@wireapp/api-client/lib/conversation/data");
|
|
27
|
+
const event_1 = require("@wireapp/api-client/lib/event");
|
|
27
28
|
const bazinga64_1 = require("bazinga64");
|
|
28
29
|
const logdown_1 = __importDefault(require("logdown"));
|
|
29
30
|
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
@@ -32,6 +33,7 @@ const ConversationService_types_1 = require("./ConversationService.types");
|
|
|
32
33
|
const conversation_2 = require("../../conversation/");
|
|
33
34
|
const AssetCryptography_1 = require("../../cryptography/AssetCryptography");
|
|
34
35
|
const mls_1 = require("../../messagingProtocols/mls");
|
|
36
|
+
const events_1 = require("../../messagingProtocols/mls/EventHandler/events");
|
|
35
37
|
const proteus_1 = require("../../messagingProtocols/proteus");
|
|
36
38
|
const util_1 = require("../../util");
|
|
37
39
|
const fullyQualifiedClientIdUtils_1 = require("../../util/fullyQualifiedClientIdUtils");
|
|
@@ -338,5 +340,25 @@ class ConversationService {
|
|
|
338
340
|
}
|
|
339
341
|
}
|
|
340
342
|
}
|
|
343
|
+
async handleMLSMessageAddEvent(event) {
|
|
344
|
+
return (0, events_1.handleMLSMessageAdd)({ event, mlsService: this.mlsService });
|
|
345
|
+
}
|
|
346
|
+
async handleMLSWelcomeMessageEvent(event) {
|
|
347
|
+
return (0, events_1.handleMLSWelcomeMessage)({ event, mlsService: this.mlsService });
|
|
348
|
+
}
|
|
349
|
+
async handleOtrMessageAddEvent(event) {
|
|
350
|
+
return this.proteusService.handleOtrMessageAddEvent(event);
|
|
351
|
+
}
|
|
352
|
+
async handleEvent(event) {
|
|
353
|
+
switch (event.type) {
|
|
354
|
+
case event_1.CONVERSATION_EVENT.MLS_MESSAGE_ADD:
|
|
355
|
+
return this.handleMLSMessageAddEvent(event);
|
|
356
|
+
case event_1.CONVERSATION_EVENT.MLS_WELCOME_MESSAGE:
|
|
357
|
+
return this.handleMLSWelcomeMessageEvent(event);
|
|
358
|
+
case event_1.CONVERSATION_EVENT.OTR_MESSAGE_ADD:
|
|
359
|
+
return this.handleOtrMessageAddEvent(event);
|
|
360
|
+
}
|
|
361
|
+
return undefined;
|
|
362
|
+
}
|
|
341
363
|
}
|
|
342
364
|
exports.ConversationService = ConversationService;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { QualifiedUserClients, ConversationProtocol, MessageSendingStatus, Conversation } from '@wireapp/api-client/lib/conversation';
|
|
2
|
-
import { ConversationEvent } from '@wireapp/api-client/lib/event';
|
|
3
|
-
import { ConversationMemberJoinEvent } from '@wireapp/api-client/lib/event';
|
|
2
|
+
import { ConversationEvent, ConversationMemberJoinEvent } from '@wireapp/api-client/lib/event';
|
|
4
3
|
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
5
4
|
import { GenericMessage } from '@wireapp/protocol-messaging';
|
|
6
5
|
import { MessageSendingState } from '..';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationService.types.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationService/ConversationService.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACb,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"ConversationService.types.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationService/ConversationService.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACb,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAE,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAC,mBAAmB,EAAC,MAAM,IAAI,CAAC;AAEvC,oBAAY,iBAAiB;IAC3B,IAAI,IAAA;IACJ,KAAK,IAAA;IACL,aAAa,IAAA;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,oBAAoB,CAAC;IAE/C,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,gBAAgB,CAAC,EAAE,uBAAuB,CAAC,kBAAkB,CAAC,CAAC;IAE/D;;;;;OAKG;IACH,UAAU,CAAC,EAAE,iBAAiB,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB;IACtC;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1G;AAED;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,oBAAoB,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,MA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jC,EAAE,EAAE,MAAM,CAAC;IACX,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,2FAA2F;IAC3F,KAAK,EAAE,mBAAmB,CAAC;IAC3B,4MAA4M;IAC5M,YAAY,CAAC,EAAE;QACb,gIAAgI;QAChI,MAAM,CAAC,EAAE,oBAAoB,GAAG,WAAW,EAAE,CAAC;QAC9C,oJAAoJ;QACpJ,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;KACxB,CAAC;CACH,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
interface HandleMLSMessageAddParams extends EventHandlerParams {
|
|
1
|
+
import { ConversationMLSMessageAddEvent } from '@wireapp/api-client/lib/event';
|
|
2
|
+
import { HandledEventPayload } from '../../../../../notification';
|
|
3
|
+
import { MLSService } from '../../../MLSService/MLSService';
|
|
4
|
+
interface HandleMLSMessageAddParams {
|
|
6
5
|
event: ConversationMLSMessageAddEvent;
|
|
6
|
+
mlsService: MLSService;
|
|
7
7
|
}
|
|
8
|
-
declare const handleMLSMessageAdd: ({ mlsService,
|
|
9
|
-
export {
|
|
8
|
+
export declare const handleMLSMessageAdd: ({ event, mlsService, }: HandleMLSMessageAddParams) => Promise<HandledEventPayload | undefined>;
|
|
9
|
+
export {};
|
|
10
10
|
//# 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,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,eAAO,MAAM,mBAAmB,2BAG7B,yBAAyB,KAAG,QAAQ,mBAAmB,GAAG,SAAS,CA+CrE,CAAC"}
|
|
@@ -18,14 +18,11 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.handleMLSMessageAdd =
|
|
22
|
-
const event_1 = require("@wireapp/api-client/lib/event");
|
|
21
|
+
exports.handleMLSMessageAdd = void 0;
|
|
23
22
|
const bazinga64_1 = require("bazinga64");
|
|
24
23
|
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
25
24
|
const MLSService_1 = require("../../../MLSService/MLSService");
|
|
26
|
-
const
|
|
27
|
-
exports.isMLSMessageAddEvent = isMLSMessageAddEvent;
|
|
28
|
-
const handleMLSMessageAdd = async ({ mlsService, event }, onEpochChanged) => {
|
|
25
|
+
const handleMLSMessageAdd = async ({ event, mlsService, }) => {
|
|
29
26
|
var _a;
|
|
30
27
|
const encryptedData = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
|
|
31
28
|
const qualifiedConversationId = (_a = event.qualified_conversation) !== null && _a !== void 0 ? _a : { id: event.conversation, domain: '' };
|
|
@@ -52,7 +49,8 @@ const handleMLSMessageAdd = async ({ mlsService, event }, onEpochChanged) => {
|
|
|
52
49
|
});
|
|
53
50
|
}
|
|
54
51
|
if (hasEpochChanged) {
|
|
55
|
-
await
|
|
52
|
+
const newEpoch = await mlsService.getEpoch(groupId);
|
|
53
|
+
mlsService.emit('newEpoch', { groupId, epoch: newEpoch });
|
|
56
54
|
}
|
|
57
55
|
return message ? { event, decryptedData: protocol_messaging_1.GenericMessage.decode(message) } : undefined;
|
|
58
56
|
};
|
|
@@ -19,20 +19,87 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
const event_1 = require("@wireapp/api-client/lib/event");
|
|
22
|
+
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
22
23
|
const messageAdd_1 = require("./messageAdd");
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
const mockedMLSService = {
|
|
25
|
+
getGroupIdFromConversationId: jest.fn(),
|
|
26
|
+
decryptMessage: jest.fn(),
|
|
27
|
+
handlePendingProposals: jest.fn(),
|
|
28
|
+
getEpoch: jest.fn(),
|
|
29
|
+
emit: jest.fn(),
|
|
30
|
+
};
|
|
31
|
+
const createMLSMessageAddEventMock = (conversationId) => ({
|
|
32
|
+
data: '',
|
|
33
|
+
conversation: conversationId.id,
|
|
34
|
+
qualified_conversation: conversationId,
|
|
35
|
+
from: '',
|
|
36
|
+
senderClientId: '',
|
|
37
|
+
type: event_1.CONVERSATION_EVENT.MLS_MESSAGE_ADD,
|
|
38
|
+
time: '2023-08-21T06:47:43.387Z',
|
|
39
|
+
});
|
|
40
|
+
const createMockedMessage = () => {
|
|
41
|
+
return protocol_messaging_1.GenericMessage.encode(protocol_messaging_1.GenericMessage.create({
|
|
42
|
+
messageId: '2d7cb6d8-118f-11e8-b642-0ed5f89f718b',
|
|
43
|
+
text: protocol_messaging_1.Text.create({ content: 'Hello, World!' }),
|
|
44
|
+
})).finish();
|
|
45
|
+
};
|
|
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
|
+
jest.spyOn(mockedMLSService, 'getGroupIdFromConversationId').mockResolvedValueOnce(undefined);
|
|
50
|
+
await expect((0, messageAdd_1.handleMLSMessageAdd)({ event, mlsService: mockedMLSService })).rejects.toThrow();
|
|
51
|
+
});
|
|
52
|
+
it('does not handle pending proposals if message does not contain proposals', async () => {
|
|
53
|
+
const event = createMLSMessageAddEventMock({ id: 'conversationId', domain: 'staging.zinfra.io' });
|
|
54
|
+
const mockGroupId = 'AAEAAH87aajaQ011i+rNLmwpy0sAZGl5YS53aXJlLmxpbms=';
|
|
55
|
+
jest.spyOn(mockedMLSService, 'getGroupIdFromConversationId').mockResolvedValueOnce(mockGroupId);
|
|
56
|
+
const message = createMockedMessage();
|
|
57
|
+
jest.spyOn(mockedMLSService, 'decryptMessage').mockResolvedValueOnce({
|
|
58
|
+
proposals: [],
|
|
59
|
+
commitDelay: undefined,
|
|
60
|
+
message,
|
|
61
|
+
hasEpochChanged: false,
|
|
62
|
+
isActive: true,
|
|
63
|
+
});
|
|
64
|
+
await (0, messageAdd_1.handleMLSMessageAdd)({ event, mlsService: mockedMLSService });
|
|
65
|
+
expect(mockedMLSService.handlePendingProposals).not.toHaveBeenCalled();
|
|
66
|
+
});
|
|
67
|
+
it('handles pending proposals if message includes proposals', async () => {
|
|
68
|
+
const event = createMLSMessageAddEventMock({ id: 'conversationId', domain: 'staging.zinfra.io' });
|
|
69
|
+
const mockGroupId = 'AAEAAH87aajaQ011i+rNLmwpy0sAZGl5YS53aXJlLmxpbms=';
|
|
70
|
+
jest.spyOn(mockedMLSService, 'getGroupIdFromConversationId').mockResolvedValueOnce(mockGroupId);
|
|
71
|
+
const message = createMockedMessage();
|
|
72
|
+
jest.spyOn(mockedMLSService, 'decryptMessage').mockResolvedValueOnce({
|
|
73
|
+
proposals: [{ proposal: new Uint8Array(), proposalRef: new Uint8Array() }],
|
|
74
|
+
commitDelay: 2000,
|
|
75
|
+
message,
|
|
76
|
+
hasEpochChanged: false,
|
|
77
|
+
isActive: true,
|
|
78
|
+
});
|
|
79
|
+
await (0, messageAdd_1.handleMLSMessageAdd)({ event, mlsService: mockedMLSService });
|
|
80
|
+
expect(mockedMLSService.handlePendingProposals).toHaveBeenCalledWith({
|
|
81
|
+
groupId: mockGroupId,
|
|
82
|
+
delayInMs: 2000,
|
|
83
|
+
eventTime: event.time,
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
it('emits "newEpoch" event if incoming message has advanced epoch number', async () => {
|
|
87
|
+
const event = createMLSMessageAddEventMock({ id: 'conversationId', domain: 'staging.zinfra.io' });
|
|
88
|
+
const mockGroupId = 'AAEAAH87aajaQ011i+rNLmwpy0sAZGl5YS53aXJlLmxpbms=';
|
|
89
|
+
jest.spyOn(mockedMLSService, 'getGroupIdFromConversationId').mockResolvedValueOnce(mockGroupId);
|
|
90
|
+
const message = createMockedMessage();
|
|
91
|
+
jest.spyOn(mockedMLSService, 'decryptMessage').mockResolvedValueOnce({
|
|
92
|
+
proposals: [],
|
|
93
|
+
message,
|
|
94
|
+
hasEpochChanged: true,
|
|
95
|
+
isActive: true,
|
|
30
96
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
97
|
+
const mockedNewEpoch = 5;
|
|
98
|
+
jest.spyOn(mockedMLSService, 'getEpoch').mockResolvedValueOnce(mockedNewEpoch);
|
|
99
|
+
await (0, messageAdd_1.handleMLSMessageAdd)({ event, mlsService: mockedMLSService });
|
|
100
|
+
expect(mockedMLSService.emit).toHaveBeenCalledWith('newEpoch', {
|
|
101
|
+
groupId: mockGroupId,
|
|
102
|
+
epoch: mockedNewEpoch,
|
|
36
103
|
});
|
|
37
104
|
});
|
|
38
105
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
interface HandleWelcomeMessageParams extends EventHandlerParams {
|
|
1
|
+
import { ConversationMLSWelcomeEvent } from '@wireapp/api-client/lib/event';
|
|
2
|
+
import { HandledEventPayload } from '../../../../../notification';
|
|
3
|
+
import { MLSService } from '../../../MLSService';
|
|
4
|
+
interface HandleWelcomeMessageParams {
|
|
6
5
|
event: ConversationMLSWelcomeEvent;
|
|
6
|
+
mlsService: MLSService;
|
|
7
7
|
}
|
|
8
|
-
declare const
|
|
9
|
-
export {
|
|
8
|
+
export declare const handleMLSWelcomeMessage: ({ mlsService, event, }: HandleWelcomeMessageParams) => Promise<HandledEventPayload>;
|
|
9
|
+
export {};
|
|
10
10
|
//# sourceMappingURL=welcomeMessage.d.ts.map
|
package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"welcomeMessage.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"welcomeMessage.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAG1E,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAC;AAE/C,UAAU,0BAA0B;IAClC,KAAK,EAAE,2BAA2B,CAAC;IACnC,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,eAAO,MAAM,uBAAuB,2BAGjC,0BAA0B,KAAG,QAAQ,mBAAmB,CAa1D,CAAC"}
|
|
@@ -18,12 +18,9 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.
|
|
22
|
-
const event_1 = require("@wireapp/api-client/lib/event");
|
|
21
|
+
exports.handleMLSWelcomeMessage = void 0;
|
|
23
22
|
const bazinga64_1 = require("bazinga64");
|
|
24
|
-
const
|
|
25
|
-
exports.isWelcomeMessageEvent = isWelcomeMessageEvent;
|
|
26
|
-
const handleWelcomeMessage = async ({ mlsService, event }) => {
|
|
23
|
+
const handleMLSWelcomeMessage = async ({ mlsService, event, }) => {
|
|
27
24
|
const data = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
|
|
28
25
|
// We extract the groupId from the welcome message and let coreCrypto store this group
|
|
29
26
|
const newGroupId = await mlsService.processWelcomeMessage(data);
|
|
@@ -35,4 +32,4 @@ const handleWelcomeMessage = async ({ mlsService, event }) => {
|
|
|
35
32
|
event: Object.assign(Object.assign({}, event), { data: groupIdStr }),
|
|
36
33
|
};
|
|
37
34
|
};
|
|
38
|
-
exports.
|
|
35
|
+
exports.handleMLSWelcomeMessage = handleMLSWelcomeMessage;
|
package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js
CHANGED
|
@@ -41,28 +41,14 @@ const mockParams = {
|
|
|
41
41
|
dryRun: false,
|
|
42
42
|
};
|
|
43
43
|
describe('MLS welcomeMessage eventHandler', () => {
|
|
44
|
-
describe('isWelcomeMessageEvent', () => {
|
|
45
|
-
it('returns true for a welcome message event', () => {
|
|
46
|
-
const event = {
|
|
47
|
-
type: event_1.CONVERSATION_EVENT.MLS_WELCOME_MESSAGE,
|
|
48
|
-
};
|
|
49
|
-
expect((0, welcomeMessage_1.isWelcomeMessageEvent)(event)).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
it('returns false for a non-welcome message event', () => {
|
|
52
|
-
const event = {
|
|
53
|
-
type: event_1.CONVERSATION_EVENT.MEMBER_JOIN,
|
|
54
|
-
};
|
|
55
|
-
expect((0, welcomeMessage_1.isWelcomeMessageEvent)(event)).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
44
|
describe('handleWelcomeMessage', () => {
|
|
59
45
|
it('calls processWelcomeMessage and schedules periodic key material updates', async () => {
|
|
60
|
-
await (0, welcomeMessage_1.
|
|
46
|
+
await (0, welcomeMessage_1.handleMLSWelcomeMessage)(mockParams);
|
|
61
47
|
expect(mockParams.mlsService.processWelcomeMessage).toHaveBeenCalled();
|
|
62
48
|
expect(mockParams.mlsService.scheduleKeyMaterialRenewal).toHaveBeenCalled();
|
|
63
49
|
});
|
|
64
50
|
it('returns a eventHandlerResult', async () => {
|
|
65
|
-
const eventHandlerResult = await (0, welcomeMessage_1.
|
|
51
|
+
const eventHandlerResult = await (0, welcomeMessage_1.handleMLSWelcomeMessage)(mockParams);
|
|
66
52
|
expect(eventHandlerResult).toBeDefined();
|
|
67
53
|
expect(eventHandlerResult.event).toEqual({ data: 'conversationId', type: 'conversation.mls-welcome' });
|
|
68
54
|
});
|
|
@@ -7,8 +7,6 @@ import { AddProposalArgs, ConversationId, CoreCrypto, DecryptedMessage, External
|
|
|
7
7
|
import { MLSServiceConfig } from './MLSService.types';
|
|
8
8
|
import { KeyPackageClaimUser } from '../../../conversation';
|
|
9
9
|
import { TypedEventEmitter } from '../../../util/TypedEventEmitter';
|
|
10
|
-
import { EventHandlerResult } from '../../common.types';
|
|
11
|
-
import { EventHandlerParams } from '../EventHandler';
|
|
12
10
|
import { CommitPendingProposalsParams, HandlePendingProposalsParams, MLSCallbacks } from '../types';
|
|
13
11
|
export declare const optionalToUint8Array: (array: Uint8Array | []) => Uint8Array;
|
|
14
12
|
export interface SubconversationEpochInfoMember {
|
|
@@ -155,7 +153,6 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
155
153
|
private uploadMLSPublicKeys;
|
|
156
154
|
private uploadMLSKeyPackages;
|
|
157
155
|
wipeConversation(groupId: string): Promise<void>;
|
|
158
|
-
handleEvent(params: Omit<EventHandlerParams, 'mlsService'>): EventHandlerResult;
|
|
159
156
|
/**
|
|
160
157
|
* If there is a matching conversationId => groupId pair in the database,
|
|
161
158
|
* we can find the groupId and return it as a string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MLSService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.ts"],"names":[],"mappings":"AA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C,EAAE,4BAA4B;IAoBjG;;;;;OAKG;IACU,sBAAsB,CAAC,EAAC,OAAO,EAAE,UAAkB,EAAC,EAAE,4BAA4B;IAa/F;;;;OAIG;IACU,6BAA6B;IAiB1C;;;;OAIG;IACU,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;CAW1G"}
|
|
@@ -47,7 +47,6 @@ const fullyQualifiedClientIdUtils_1 = require("../../../util/fullyQualifiedClien
|
|
|
47
47
|
const RecurringTaskScheduler_1 = require("../../../util/RecurringTaskScheduler");
|
|
48
48
|
const TaskScheduler_1 = require("../../../util/TaskScheduler");
|
|
49
49
|
const TypedEventEmitter_1 = require("../../../util/TypedEventEmitter");
|
|
50
|
-
const EventHandler_1 = require("../EventHandler");
|
|
51
50
|
//@todo: this function is temporary, we wait for the update from core-crypto side
|
|
52
51
|
//they are returning regular array instead of Uint8Array for commit and welcome messages
|
|
53
52
|
const optionalToUint8Array = (array) => {
|
|
@@ -485,16 +484,6 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
485
484
|
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
486
485
|
return this.coreCryptoClient.wipeConversation(groupIdBytes);
|
|
487
486
|
}
|
|
488
|
-
async handleEvent(params) {
|
|
489
|
-
return (0, EventHandler_1.handleBackendEvent)(Object.assign(Object.assign({}, params), { mlsService: this }), async (groupId) => {
|
|
490
|
-
const conversationExists = await this.conversationExists(groupId);
|
|
491
|
-
if (!conversationExists) {
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
const newEpoch = await this.getEpoch(groupId);
|
|
495
|
-
this.emit('newEpoch', { groupId, epoch: newEpoch });
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
487
|
/**
|
|
499
488
|
* If there is a matching conversationId => groupId pair in the database,
|
|
500
489
|
* we can find the groupId and return it as a string
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
type HandleOtrMessageAddParams = Omit<EventHandlerParams, 'event'> & {
|
|
1
|
+
import { ConversationOtrMessageAddEvent } from '@wireapp/api-client/lib/event';
|
|
2
|
+
import { HandledEventPayload } from '../../../../../notification';
|
|
3
|
+
import { ProteusService } from '../../../ProteusService';
|
|
4
|
+
interface HandleOtrMessageAddParams {
|
|
6
5
|
event: ConversationOtrMessageAddEvent;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export {
|
|
6
|
+
proteusService: ProteusService;
|
|
7
|
+
}
|
|
8
|
+
export declare const handleOtrMessageAdd: ({ event, proteusService, }: HandleOtrMessageAddParams) => Promise<HandledEventPayload>;
|
|
9
|
+
export {};
|
|
10
10
|
//# sourceMappingURL=otrMessageAdd.d.ts.map
|
package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otrMessageAdd.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"otrMessageAdd.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,8BAA8B,EAAC,MAAM,+BAA+B,CAAC;AAO7E,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAEvD,UAAU,yBAAyB;IACjC,KAAK,EAAE,8BAA8B,CAAC;IACtC,cAAc,EAAE,cAAc,CAAC;CAChC;AAED,eAAO,MAAM,mBAAmB,+BAG7B,yBAAyB,KAAG,QAAQ,mBAAmB,CA6BzD,CAAC"}
|
|
@@ -18,27 +18,26 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.handleOtrMessageAdd =
|
|
22
|
-
const event_1 = require("@wireapp/api-client/lib/event");
|
|
21
|
+
exports.handleOtrMessageAdd = void 0;
|
|
23
22
|
const bazinga64_1 = require("bazinga64");
|
|
24
23
|
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
24
|
+
const conversation_1 = require("../../../../../conversation");
|
|
25
25
|
const DecryptionError_1 = require("../../../../../errors/DecryptionError");
|
|
26
|
-
const
|
|
27
|
-
exports.isOtrMessageAddEvent = isOtrMessageAddEvent;
|
|
28
|
-
const handleOtrMessageAdd = async ({ decryptMessage, event, dryRun = false, }) => {
|
|
29
|
-
if (dryRun) {
|
|
30
|
-
// In case of a dry run, we do not want to decrypt messages
|
|
31
|
-
// We just return the raw event to the caller
|
|
32
|
-
return { event };
|
|
33
|
-
}
|
|
26
|
+
const handleOtrMessageAdd = async ({ event, proteusService, }) => {
|
|
34
27
|
try {
|
|
35
28
|
const { from, qualified_from, data: { sender: clientId, text: encodedCiphertext }, } = event;
|
|
36
29
|
const userId = qualified_from || { id: from, domain: '' };
|
|
37
30
|
const messageBytes = bazinga64_1.Decoder.fromBase64(encodedCiphertext).asBytes;
|
|
38
|
-
const decryptedData = await
|
|
31
|
+
const decryptedData = await proteusService.decrypt(messageBytes, userId, clientId);
|
|
32
|
+
const decodedData = protocol_messaging_1.GenericMessage.decode(decryptedData);
|
|
33
|
+
const isSessionReset = decodedData[conversation_1.GenericMessageType.CLIENT_ACTION] === protocol_messaging_1.ClientAction.RESET_SESSION;
|
|
34
|
+
if (isSessionReset) {
|
|
35
|
+
// If a session reset message was received, we need to count a consumed prekey (because the sender has created a new session from a new prekey)
|
|
36
|
+
await proteusService.consumePrekey();
|
|
37
|
+
}
|
|
39
38
|
return {
|
|
40
39
|
event,
|
|
41
|
-
decryptedData:
|
|
40
|
+
decryptedData: decodedData,
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
43
|
catch (error) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { APIClient } from '@wireapp/api-client/lib/APIClient';
|
|
2
2
|
import type { PreKey, Context } from '@wireapp/api-client/lib/auth';
|
|
3
3
|
import { NewConversation, QualifiedOTRRecipients, QualifiedUserClients } from '@wireapp/api-client/lib/conversation';
|
|
4
|
+
import type { ConversationOtrMessageAddEvent } from '@wireapp/api-client/lib/event';
|
|
4
5
|
import type { QualifiedId, QualifiedUserPreKeyBundleMap } from '@wireapp/api-client/lib/user';
|
|
5
6
|
import { CRUDEngine } from '@wireapp/store-engine';
|
|
6
7
|
import { CryptoClient } from './CryptoClient';
|
|
7
8
|
import type { AddUsersToProteusConversationParams, ProteusServiceConfig, SendProteusMessageParams } from './ProteusService.types';
|
|
8
9
|
import { ProteusCreateConversationResponse, SendResult, ProteusAddUsersResponse } from '../../../conversation';
|
|
9
|
-
import
|
|
10
|
-
import { EventHandlerParams } from '../EventHandler';
|
|
10
|
+
import { HandledEventPayload } from '../../../notification';
|
|
11
11
|
export type EncryptionResult = {
|
|
12
12
|
/** the encrypted payloads for the clients that have a valid sessions */
|
|
13
13
|
payloads: QualifiedOTRRecipients;
|
|
@@ -23,7 +23,7 @@ export declare class ProteusService {
|
|
|
23
23
|
private readonly messageService;
|
|
24
24
|
private readonly logger;
|
|
25
25
|
constructor(apiClient: APIClient, cryptoClient: CryptoClient, config: ProteusServiceConfig);
|
|
26
|
-
|
|
26
|
+
handleOtrMessageAddEvent(event: ConversationOtrMessageAddEvent): Promise<HandledEventPayload>;
|
|
27
27
|
initClient(storeEngine: CRUDEngine, context: Context): Promise<void>;
|
|
28
28
|
createClient(entropy?: Uint8Array): Promise<import("./CryptoClient").InitialPrekeys>;
|
|
29
29
|
/**
|
|
@@ -46,7 +46,8 @@ export declare class ProteusService {
|
|
|
46
46
|
*/
|
|
47
47
|
addUsersToConversation({ conversationId, qualifiedUsers, }: AddUsersToProteusConversationParams): Promise<ProteusAddUsersResponse>;
|
|
48
48
|
sendMessage({ userIds, conversationId, nativePush, targetMode, payload, onClientMismatch, }: SendProteusMessageParams): Promise<SendResult>;
|
|
49
|
-
|
|
49
|
+
decrypt(encryptedText: Uint8Array, userId: QualifiedId, clientId: string): Promise<Uint8Array>;
|
|
50
|
+
consumePrekey(): Promise<void>;
|
|
50
51
|
deleteSession(userId: QualifiedId, clientId: string): Promise<void>;
|
|
51
52
|
encrypt(plainText: Uint8Array, recipients: QualifiedUserPreKeyBundleMap | QualifiedUserClients): Promise<EncryptionResult>;
|
|
52
53
|
wipe(storeEngine?: CRUDEngine): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProteusService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAGL,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAC,WAAW,EAAE,4BAA4B,EAAC,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"ProteusService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAGL,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,K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M;IAIxE;;;;;;OAMG;IACU,oBAAoB,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAQ3E,kBAAkB,CAAC,gBAAgB,EAAE,eAAe,GAAG,OAAO,CAAC,iCAAiC,CAAC;IAwC9G;;;OAGG;IACU,sBAAsB,CAAC,EAClC,cAAc,EACd,cAAc,GACf,EAAE,mCAAmC,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAqC5D,WAAW,CAAC,EACvB,OAAO,EACP,cAAc,EACd,UAAU,EACV,UAAU,EACV,OAAO,EACP,gBAAgB,GACjB,EAAE,wBAAwB,GAAG,OAAO,CAAC,UAAU,CAAC;IA6CpC,OAAO,CAAC,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM;IAuB9E,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM;IAQ7C,OAAO,CAClB,SAAS,EAAE,UAAU,EACrB,UAAU,EAAE,4BAA4B,GAAG,oBAAoB,GAC9D,OAAO,CAAC,gBAAgB,CAAC;IAiBtB,IAAI,CAAC,WAAW,CAAC,EAAE,UAAU;CAMpC"}
|
|
@@ -24,7 +24,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
24
24
|
exports.ProteusService = void 0;
|
|
25
25
|
const conversation_1 = require("@wireapp/api-client/lib/conversation");
|
|
26
26
|
const logdown_1 = __importDefault(require("logdown"));
|
|
27
|
-
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
28
27
|
const cryptoMigrationStateStore_1 = require("./cryptoMigrationStateStore");
|
|
29
28
|
const DecryptionErrorGenerator_1 = require("./DecryptionErrorGenerator");
|
|
30
29
|
const identityClearer_1 = require("./identityClearer");
|
|
@@ -33,7 +32,7 @@ const userDomainFilters_1 = require("./userDomainFilters");
|
|
|
33
32
|
const conversation_2 = require("../../../conversation");
|
|
34
33
|
const MessageService_1 = require("../../../conversation/message/MessageService");
|
|
35
34
|
const errors_1 = require("../../../errors");
|
|
36
|
-
const
|
|
35
|
+
const events_1 = require("../EventHandler/events");
|
|
37
36
|
const getGenericMessageParams_1 = require("../Utility/getGenericMessageParams");
|
|
38
37
|
const isClearFromMismatch_1 = require("../Utility/isClearFromMismatch");
|
|
39
38
|
const SessionHandler_1 = require("../Utility/SessionHandler");
|
|
@@ -45,17 +44,11 @@ class ProteusService {
|
|
|
45
44
|
this.logger = (0, logdown_1.default)('@wireapp/core/ProteusService');
|
|
46
45
|
this.messageService = new MessageService_1.MessageService(this.apiClient, this);
|
|
47
46
|
}
|
|
48
|
-
async
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.logger.debug('A session was reset from a remote device');
|
|
54
|
-
// If a session reset message was received, we need to count a consumed prekey (because the sender has created a new session from a new prekey)
|
|
55
|
-
await this.cryptoClient.consumePrekey();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return handledEvent;
|
|
47
|
+
async handleOtrMessageAddEvent(event) {
|
|
48
|
+
return (0, events_1.handleOtrMessageAdd)({
|
|
49
|
+
event,
|
|
50
|
+
proteusService: this,
|
|
51
|
+
});
|
|
59
52
|
}
|
|
60
53
|
async initClient(storeEngine, context) {
|
|
61
54
|
var _a;
|
|
@@ -236,6 +229,9 @@ class ProteusService {
|
|
|
236
229
|
throw (0, DecryptionErrorGenerator_1.generateDecryptionError)({ userId, clientId }, error);
|
|
237
230
|
}
|
|
238
231
|
}
|
|
232
|
+
consumePrekey() {
|
|
233
|
+
return this.cryptoClient.consumePrekey();
|
|
234
|
+
}
|
|
239
235
|
deleteSession(userId, clientId) {
|
|
240
236
|
return (0, SessionHandler_1.deleteSession)({
|
|
241
237
|
userId,
|
|
@@ -48,7 +48,6 @@ const conversation_2 = require("../../../conversation");
|
|
|
48
48
|
const MessageBuilder_1 = require("../../../conversation/message/MessageBuilder");
|
|
49
49
|
const ProteusService_mocks_1 = require("./ProteusService.mocks");
|
|
50
50
|
const SessionHandler_1 = require("../Utility/SessionHandler");
|
|
51
|
-
const notification_1 = require("../../../notification");
|
|
52
51
|
const event_1 = require("@wireapp/api-client/lib/event");
|
|
53
52
|
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
54
53
|
const errors_1 = require("../../../errors");
|
|
@@ -188,14 +187,14 @@ describe('ProteusService', () => {
|
|
|
188
187
|
expect(result).toBe(expectedFingerprint);
|
|
189
188
|
});
|
|
190
189
|
});
|
|
191
|
-
describe('
|
|
190
|
+
describe('handleOtrMessageAddEvent', () => {
|
|
192
191
|
const eventPayload = {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
192
|
+
type: event_1.CONVERSATION_EVENT.OTR_MESSAGE_ADD,
|
|
193
|
+
qualified_from: (0, testUtils_1.generateQualifiedId)('domain'),
|
|
194
|
+
data: { sender: 'client1', text: '', recipient: '' },
|
|
195
|
+
conversation: '',
|
|
196
|
+
from: '',
|
|
197
|
+
time: '',
|
|
199
198
|
};
|
|
200
199
|
const decryptedMessage = {};
|
|
201
200
|
it('decrypts incoming proteus encrypted events when session already exists', async () => {
|
|
@@ -204,7 +203,7 @@ describe('ProteusService', () => {
|
|
|
204
203
|
const createSessionSpy = jest.spyOn(cryptoClient, 'sessionFromMessage');
|
|
205
204
|
jest.spyOn(cryptoClient, 'decrypt').mockResolvedValue(new Uint8Array());
|
|
206
205
|
jest.spyOn(protocol_messaging_1.GenericMessage, 'decode').mockReturnValue(decryptedMessage);
|
|
207
|
-
const result = await proteusService.
|
|
206
|
+
const result = await proteusService.handleOtrMessageAddEvent(eventPayload);
|
|
208
207
|
expect(result).toBeDefined();
|
|
209
208
|
expect(createSessionSpy).not.toHaveBeenCalled();
|
|
210
209
|
expect(result === null || result === void 0 ? void 0 : result.decryptedData).toBe(decryptedMessage);
|
|
@@ -216,7 +215,7 @@ describe('ProteusService', () => {
|
|
|
216
215
|
const createSessionSpy = jest.spyOn(cryptoClient, 'sessionFromMessage').mockResolvedValue(new Uint8Array());
|
|
217
216
|
const decryptSpy = jest.spyOn(cryptoClient, 'decrypt');
|
|
218
217
|
jest.spyOn(protocol_messaging_1.GenericMessage, 'decode').mockReturnValue(decryptedMessage);
|
|
219
|
-
const result = await proteusService.
|
|
218
|
+
const result = await proteusService.handleOtrMessageAddEvent(eventPayload);
|
|
220
219
|
expect(result).toBeDefined();
|
|
221
220
|
expect(createSessionSpy).toHaveBeenCalled();
|
|
222
221
|
expect(decryptSpy).not.toHaveBeenCalled();
|
|
@@ -5,10 +5,9 @@ import { APIClient } from '@wireapp/api-client';
|
|
|
5
5
|
import { GenericMessage } from '@wireapp/protocol-messaging';
|
|
6
6
|
import { CRUDEngine } from '@wireapp/store-engine';
|
|
7
7
|
import { NotificationSource } from './Notifications.types';
|
|
8
|
+
import { ConversationService } from '../conversation';
|
|
8
9
|
import { NotificationError } from '../CoreError';
|
|
9
10
|
import { DecryptionError } from '../errors/DecryptionError';
|
|
10
|
-
import { MLSService } from '../messagingProtocols/mls';
|
|
11
|
-
import { ProteusService } from '../messagingProtocols/proteus';
|
|
12
11
|
import { TypedEventEmitter } from '../util/TypedEventEmitter';
|
|
13
12
|
export type HandledEventPayload = {
|
|
14
13
|
/** the raw event received from backend */
|
|
@@ -29,14 +28,13 @@ type Events = {
|
|
|
29
28
|
[TOPIC.NOTIFICATION_ERROR]: NotificationError;
|
|
30
29
|
};
|
|
31
30
|
export declare class NotificationService extends TypedEventEmitter<Events> {
|
|
32
|
-
private readonly
|
|
33
|
-
private readonly mlsService?;
|
|
31
|
+
private readonly conversationService;
|
|
34
32
|
private readonly apiClient;
|
|
35
33
|
private readonly backend;
|
|
36
34
|
private readonly database;
|
|
37
35
|
private readonly logger;
|
|
38
36
|
static readonly TOPIC: typeof TOPIC;
|
|
39
|
-
constructor(apiClient: APIClient,
|
|
37
|
+
constructor(apiClient: APIClient, storeEngine: CRUDEngine, conversationService: ConversationService);
|
|
40
38
|
private getAllNotifications;
|
|
41
39
|
/** Should only be called with a completely new client. */
|
|
42
40
|
initializeNotificationStream(): Promise<string>;
|
|
@@ -62,7 +60,6 @@ export declare class NotificationService extends TypedEventEmitter<Events> {
|
|
|
62
60
|
/**
|
|
63
61
|
* Will process one event
|
|
64
62
|
* @param event The backend event to process
|
|
65
|
-
* @param source The source of the event (websocket or notication stream)
|
|
66
63
|
* @param dryRun Will not try to decrypt if true
|
|
67
64
|
* @return the decrypted payload and the raw event. Returns `undefined` when the payload is a coreCrypto-only system message
|
|
68
65
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationService.d.ts","sourceRoot":"","sources":["../../src/notification/NotificationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"NotificationService.d.ts","sourceRoot":"","sources":["../../src/notification/NotificationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,YAAY,EAAC,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAC,YAAY,EAAC,MAAM,6BAA6B,CAAC;AAGzD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAC,UAAU,EAA4B,MAAM,uBAAuB,CAAC;AAI5E,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAY,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAE5D,MAAM,MAAM,mBAAmB,GAAG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,MAAM,KAAK,IAAI,EACvD,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAC;IAoC3D;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;IAYT,kBAAkB,CAC9B,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,kBAAkB,EAC1B,MAAM,GAAE,OAAe,GACtB,cAAc,CAAC,mBAAmB,CAAC;IAmCtC;;;;;OAKG;YACW,WAAW;CAc1B"}
|
|
@@ -34,7 +34,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
34
34
|
};
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.NotificationService = void 0;
|
|
37
|
-
const event_1 = require("@wireapp/api-client/lib/event");
|
|
38
37
|
const logdown_1 = __importDefault(require("logdown"));
|
|
39
38
|
const store_engine_1 = require("@wireapp/store-engine");
|
|
40
39
|
const NotificationBackendRepository_1 = require("./NotificationBackendRepository");
|
|
@@ -47,10 +46,9 @@ var TOPIC;
|
|
|
47
46
|
TOPIC["NOTIFICATION_ERROR"] = "NotificationService.TOPIC.NOTIFICATION_ERROR";
|
|
48
47
|
})(TOPIC || (TOPIC = {}));
|
|
49
48
|
class NotificationService extends TypedEventEmitter_1.TypedEventEmitter {
|
|
50
|
-
constructor(apiClient,
|
|
49
|
+
constructor(apiClient, storeEngine, conversationService) {
|
|
51
50
|
super();
|
|
52
|
-
this.
|
|
53
|
-
this.mlsService = mlsService;
|
|
51
|
+
this.conversationService = conversationService;
|
|
54
52
|
this.logger = (0, logdown_1.default)('@wireapp/core/NotificationService', {
|
|
55
53
|
logger: console,
|
|
56
54
|
markdown: false,
|
|
@@ -163,7 +161,7 @@ class NotificationService extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
163
161
|
continue;
|
|
164
162
|
}
|
|
165
163
|
try {
|
|
166
|
-
const data = yield __await(this.handleEvent(event,
|
|
164
|
+
const data = yield __await(this.handleEvent(event, dryRun));
|
|
167
165
|
if (typeof data !== 'undefined') {
|
|
168
166
|
yield yield __await(data);
|
|
169
167
|
}
|
|
@@ -187,35 +185,18 @@ class NotificationService extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
187
185
|
/**
|
|
188
186
|
* Will process one event
|
|
189
187
|
* @param event The backend event to process
|
|
190
|
-
* @param source The source of the event (websocket or notication stream)
|
|
191
188
|
* @param dryRun Will not try to decrypt if true
|
|
192
189
|
* @return the decrypted payload and the raw event. Returns `undefined` when the payload is a coreCrypto-only system message
|
|
193
190
|
*/
|
|
194
|
-
async handleEvent(event,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return mlsResult;
|
|
191
|
+
async handleEvent(event, dryRun = false) {
|
|
192
|
+
if (dryRun) {
|
|
193
|
+
// In case of a dry run, we do not want to decrypt messages
|
|
194
|
+
// We just return the raw event to the caller
|
|
195
|
+
return { event };
|
|
200
196
|
}
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
dryRun,
|
|
205
|
-
});
|
|
206
|
-
if (proteusResult) {
|
|
207
|
-
return proteusResult;
|
|
208
|
-
}
|
|
209
|
-
// Fallback to other events
|
|
210
|
-
switch (event.type) {
|
|
211
|
-
// Meta events
|
|
212
|
-
case event_1.CONVERSATION_EVENT.MEMBER_JOIN:
|
|
213
|
-
// As of today (07/07/2022) the backend sends `WELCOME` message to the user's own conversation (not the actual conversation that the welcome should be part of)
|
|
214
|
-
// So in order to map conversation Ids and groupId together, we need to first fetch the conversation and get the groupId linked to it.
|
|
215
|
-
const conversation = await this.apiClient.api.conversation.getConversation((_b = event.qualified_conversation) !== null && _b !== void 0 ? _b : { id: event.conversation, domain: '' });
|
|
216
|
-
if (!conversation) {
|
|
217
|
-
throw new Error('no conv');
|
|
218
|
-
}
|
|
197
|
+
const conversationEventResult = await this.conversationService.handleEvent(event);
|
|
198
|
+
if (conversationEventResult) {
|
|
199
|
+
return conversationEventResult;
|
|
219
200
|
}
|
|
220
201
|
return { event };
|
|
221
202
|
}
|
|
@@ -27,15 +27,14 @@ const MOCK_BACKEND = {
|
|
|
27
27
|
rest: `https://${BASE_URL}`,
|
|
28
28
|
ws: `wss://${BASE_URL}`,
|
|
29
29
|
};
|
|
30
|
-
const
|
|
31
|
-
const mockedProteusService = {};
|
|
30
|
+
const mockedConversationService = {};
|
|
32
31
|
describe('NotificationService', () => {
|
|
33
32
|
describe('handleEvent', () => {
|
|
34
33
|
it('propagates errors to the outer calling function', async () => {
|
|
35
34
|
const storeEngine = new store_engine_1.MemoryEngine();
|
|
36
35
|
await storeEngine.init('NotificationService.test');
|
|
37
36
|
const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
|
|
38
|
-
const notificationService = new _1.NotificationService(apiClient,
|
|
37
|
+
const notificationService = new _1.NotificationService(apiClient, storeEngine, mockedConversationService);
|
|
39
38
|
jest.spyOn(notificationService, 'handleEvent').mockImplementation(() => {
|
|
40
39
|
throw new Error('Test error');
|
|
41
40
|
});
|
|
@@ -58,7 +57,7 @@ describe('NotificationService', () => {
|
|
|
58
57
|
const storeEngine = new store_engine_1.MemoryEngine();
|
|
59
58
|
await storeEngine.init('NotificationService.test');
|
|
60
59
|
const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
|
|
61
|
-
const notificationService = new _1.NotificationService(apiClient,
|
|
60
|
+
const notificationService = new _1.NotificationService(apiClient, storeEngine, mockedConversationService);
|
|
62
61
|
jest.spyOn(notificationService, 'handleEvent').mockReturnValue({});
|
|
63
62
|
const spySetLastNotificationId = jest
|
|
64
63
|
.spyOn(notificationService, 'setLastNotificationId')
|
|
@@ -76,7 +75,7 @@ describe('NotificationService', () => {
|
|
|
76
75
|
const storeEngine = new store_engine_1.MemoryEngine();
|
|
77
76
|
await storeEngine.init('NotificationService.test');
|
|
78
77
|
const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
|
|
79
|
-
const notificationService = new _1.NotificationService(apiClient,
|
|
78
|
+
const notificationService = new _1.NotificationService(apiClient, storeEngine, mockedConversationService);
|
|
80
79
|
jest.spyOn(notificationService, 'handleEvent').mockReturnValue({});
|
|
81
80
|
const spySetLastNotificationId = jest
|
|
82
81
|
.spyOn(notificationService, 'setLastNotificationId')
|
|
@@ -94,7 +93,7 @@ describe('NotificationService', () => {
|
|
|
94
93
|
const storeEngine = new store_engine_1.MemoryEngine();
|
|
95
94
|
await storeEngine.init('NotificationService.test');
|
|
96
95
|
const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
|
|
97
|
-
const notificationService = new _1.NotificationService(apiClient,
|
|
96
|
+
const notificationService = new _1.NotificationService(apiClient, storeEngine, mockedConversationService);
|
|
98
97
|
notificationService.on(_1.NotificationService.TOPIC.NOTIFICATION_ERROR, notificationError => {
|
|
99
98
|
expect(notificationError.error.message).toBe('Test error');
|
|
100
99
|
expect(spySetLastNotificationId).toHaveBeenCalledTimes(0);
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { EventHandlerParams } from './EventHandler.types';
|
|
2
|
-
import { EventHandlerResult } from '../../common.types';
|
|
3
|
-
declare const handleBackendEvent: (params: EventHandlerParams, onEpochChanged: (groupId: string) => Promise<void>) => EventHandlerResult;
|
|
4
|
-
export { handleBackendEvent };
|
|
5
|
-
//# sourceMappingURL=EventHandler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventHandler.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/EventHandler/EventHandler.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAEtD,QAAA,MAAM,kBAAkB,WACd,kBAAkB,4BACA,MAAM,KAAK,QAAQ,IAAI,CAAC,uBASnD,CAAC;AAEF,OAAO,EAAC,kBAAkB,EAAC,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Wire
|
|
4
|
-
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
-
*
|
|
6
|
-
* This program is free software: you can redistribute it and/or modify
|
|
7
|
-
* it under the terms of the GNU General Public License as published by
|
|
8
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
-
* (at your option) any later version.
|
|
10
|
-
*
|
|
11
|
-
* This program is distributed in the hope that it will be useful,
|
|
12
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
-
* GNU General Public License for more details.
|
|
15
|
-
*
|
|
16
|
-
* You should have received a copy of the GNU General Public License
|
|
17
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.handleBackendEvent = void 0;
|
|
22
|
-
const events_1 = require("./events");
|
|
23
|
-
const handleBackendEvent = async (params, onEpochChanged) => {
|
|
24
|
-
const { event } = params;
|
|
25
|
-
if ((0, events_1.isWelcomeMessageEvent)(event)) {
|
|
26
|
-
return (0, events_1.handleWelcomeMessage)(Object.assign(Object.assign({}, params), { event }));
|
|
27
|
-
}
|
|
28
|
-
if ((0, events_1.isMLSMessageAddEvent)(event)) {
|
|
29
|
-
return (0, events_1.handleMLSMessageAdd)(Object.assign(Object.assign({}, params), { event }), onEpochChanged);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
exports.handleBackendEvent = handleBackendEvent;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BackendEvent } from '@wireapp/api-client/lib/event';
|
|
2
|
-
import { NotificationSource } from '../../../notification';
|
|
3
|
-
import { MLSService } from '../MLSService/MLSService';
|
|
4
|
-
export { BackendEvent };
|
|
5
|
-
export type EventHandlerParams = {
|
|
6
|
-
mlsService: MLSService;
|
|
7
|
-
event: BackendEvent;
|
|
8
|
-
source: NotificationSource;
|
|
9
|
-
dryRun?: boolean;
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=EventHandler.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventHandler.types.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/EventHandler/EventHandler.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAC,YAAY,EAAC,CAAC;AAEtB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Wire
|
|
4
|
-
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
-
*
|
|
6
|
-
* This program is free software: you can redistribute it and/or modify
|
|
7
|
-
* it under the terms of the GNU General Public License as published by
|
|
8
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
-
* (at your option) any later version.
|
|
10
|
-
*
|
|
11
|
-
* This program is distributed in the hope that it will be useful,
|
|
12
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
-
* GNU General Public License for more details.
|
|
15
|
-
*
|
|
16
|
-
* You should have received a copy of the GNU General Public License
|
|
17
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/EventHandler/index.ts"],"names":[],"mappings":"AAmBA,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Wire
|
|
4
|
-
* Copyright (C) 2022 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("./EventHandler.types"), exports);
|
|
36
|
-
__exportStar(require("./EventHandler"), exports);
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { EventHandlerParams } from './EventHandler.types';
|
|
2
|
-
import { EventHandlerResult } from '../../common.types';
|
|
3
|
-
declare const handleBackendEvent: (params: EventHandlerParams) => EventHandlerResult;
|
|
4
|
-
export { handleBackendEvent };
|
|
5
|
-
//# sourceMappingURL=EventHandler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventHandler.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/EventHandler/EventHandler.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAEtD,QAAA,MAAM,kBAAkB,WAAkB,kBAAkB,uBAK3D,CAAC;AAEF,OAAO,EAAC,kBAAkB,EAAC,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Wire
|
|
4
|
-
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
-
*
|
|
6
|
-
* This program is free software: you can redistribute it and/or modify
|
|
7
|
-
* it under the terms of the GNU General Public License as published by
|
|
8
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
-
* (at your option) any later version.
|
|
10
|
-
*
|
|
11
|
-
* This program is distributed in the hope that it will be useful,
|
|
12
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
-
* GNU General Public License for more details.
|
|
15
|
-
*
|
|
16
|
-
* You should have received a copy of the GNU General Public License
|
|
17
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.handleBackendEvent = void 0;
|
|
22
|
-
const events_1 = require("./events");
|
|
23
|
-
const handleBackendEvent = async (params) => {
|
|
24
|
-
const { event } = params;
|
|
25
|
-
if ((0, events_1.isOtrMessageAddEvent)(event)) {
|
|
26
|
-
return (0, events_1.handleOtrMessageAdd)(Object.assign(Object.assign({}, params), { event }));
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
exports.handleBackendEvent = handleBackendEvent;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BackendEvent } from '@wireapp/api-client/lib/event';
|
|
2
|
-
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
3
|
-
import { NotificationSource } from '../../../notification';
|
|
4
|
-
export { BackendEvent };
|
|
5
|
-
export type EventHandlerParams = {
|
|
6
|
-
dryRun?: boolean;
|
|
7
|
-
event: BackendEvent;
|
|
8
|
-
source: NotificationSource;
|
|
9
|
-
decryptMessage: (encryptedPayload: Uint8Array, userId: QualifiedId, clientId: string) => Promise<Uint8Array>;
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=EventHandler.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventHandler.types.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/EventHandler/EventHandler.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAC,YAAY,EAAC,CAAC;AAEtB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,cAAc,EAAE,CAAC,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CAC9G,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Wire
|
|
4
|
-
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
-
*
|
|
6
|
-
* This program is free software: you can redistribute it and/or modify
|
|
7
|
-
* it under the terms of the GNU General Public License as published by
|
|
8
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
-
* (at your option) any later version.
|
|
10
|
-
*
|
|
11
|
-
* This program is distributed in the hope that it will be useful,
|
|
12
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
-
* GNU General Public License for more details.
|
|
15
|
-
*
|
|
16
|
-
* You should have received a copy of the GNU General Public License
|
|
17
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.test.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"otrMessageAdd.test.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.test.ts"],"names":[],"mappings":""}
|
package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.test.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Wire
|
|
4
|
-
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
-
*
|
|
6
|
-
* This program is free software: you can redistribute it and/or modify
|
|
7
|
-
* it under the terms of the GNU General Public License as published by
|
|
8
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
-
* (at your option) any later version.
|
|
10
|
-
*
|
|
11
|
-
* This program is distributed in the hope that it will be useful,
|
|
12
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
-
* GNU General Public License for more details.
|
|
15
|
-
*
|
|
16
|
-
* You should have received a copy of the GNU General Public License
|
|
17
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
const event_1 = require("@wireapp/api-client/lib/event");
|
|
22
|
-
const _1 = require(".");
|
|
23
|
-
describe('MLS messageAdd eventHandler', () => {
|
|
24
|
-
describe('isMessageAdd', () => {
|
|
25
|
-
it('returns true for a messageAdd event', () => {
|
|
26
|
-
const event = {
|
|
27
|
-
type: event_1.CONVERSATION_EVENT.OTR_MESSAGE_ADD,
|
|
28
|
-
};
|
|
29
|
-
expect((0, _1.isOtrMessageAddEvent)(event)).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
it('returns false for a non-messageAdd event', () => {
|
|
32
|
-
const event = {
|
|
33
|
-
type: event_1.CONVERSATION_EVENT.MEMBER_JOIN,
|
|
34
|
-
};
|
|
35
|
-
expect((0, _1.isOtrMessageAddEvent)(event)).toBe(false);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/EventHandler/index.ts"],"names":[],"mappings":"AAmBA,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Wire
|
|
4
|
-
* Copyright (C) 2022 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("./EventHandler.types"), exports);
|
|
36
|
-
__exportStar(require("./EventHandler"), exports);
|