@wireapp/core 32.0.8 → 32.1.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/package.json
CHANGED
|
@@ -14,6 +14,7 @@ export declare class MLSService {
|
|
|
14
14
|
addUsersToExistingConversation(groupId: Uint8Array, invitee: Invitee[]): Promise<import("@wireapp/api-client/src/conversation").PostMlsMessageResponse | null>;
|
|
15
15
|
configureMLSCallbacks({ groupIdFromConversationId, ...coreCryptoCallbacks }: MLSCallbacks): void;
|
|
16
16
|
getKeyPackagesPayload(qualifiedUsers: QualifiedUsers[]): Promise<Invitee[]>;
|
|
17
|
+
getEpoch(groupId: Uint8Array): Promise<number>;
|
|
17
18
|
newProposal(proposalType: ProposalType, args: ProposalArgs | AddProposalArgs | RemoveProposalArgs): Promise<import("@wireapp/core-crypto").ProposalBundle>;
|
|
18
19
|
newExternalProposal(externalProposalType: ExternalProposalType, args: ExternalProposalArgs | ExternalRemoveProposalArgs): Promise<Uint8Array>;
|
|
19
20
|
processWelcomeMessage(welcomeMessage: Uint8Array): Promise<ConversationId>;
|
|
@@ -112,6 +112,9 @@ class MLSService {
|
|
|
112
112
|
}, []);
|
|
113
113
|
return coreCryptoKeyPackagesPayload;
|
|
114
114
|
}
|
|
115
|
+
getEpoch(groupId) {
|
|
116
|
+
return this.getCoreCryptoClient().conversationEpoch(groupId);
|
|
117
|
+
}
|
|
115
118
|
async newProposal(proposalType, args) {
|
|
116
119
|
return this.getCoreCryptoClient().newProposal(proposalType, args);
|
|
117
120
|
}
|
|
@@ -62,6 +62,13 @@ export declare class NotificationService extends EventEmitter {
|
|
|
62
62
|
private isOutdatedEvent;
|
|
63
63
|
handleNotification(notification: Notification, source: PayloadBundleSource, dryRun?: boolean): AsyncGenerator<HandledEventPayload>;
|
|
64
64
|
private cleanupPayloadBundle;
|
|
65
|
+
/**
|
|
66
|
+
* Will process one event
|
|
67
|
+
* @param event The backend event to process
|
|
68
|
+
* @param source The source of the event (websocket or notication stream)
|
|
69
|
+
* @param dryRun Will not try to decrypt if true
|
|
70
|
+
* @return the decrypted payload and the raw event. Returns `undefined` when the payload is a coreCrypto-only system message
|
|
71
|
+
*/
|
|
65
72
|
private handleEvent;
|
|
66
73
|
/**
|
|
67
74
|
* ## MLS only ##
|
|
@@ -198,7 +198,9 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
198
198
|
}
|
|
199
199
|
try {
|
|
200
200
|
const data = yield __await(this.handleEvent(event, source, dryRun));
|
|
201
|
-
|
|
201
|
+
if (typeof data !== 'undefined') {
|
|
202
|
+
yield yield __await(Object.assign(Object.assign({}, data), { mappedEvent: data.mappedEvent ? this.cleanupPayloadBundle(data.mappedEvent) : undefined }));
|
|
203
|
+
}
|
|
202
204
|
}
|
|
203
205
|
catch (error) {
|
|
204
206
|
this.logger.error(`There was an error with notification ID "${notification.id}": ${error.message}`, error);
|
|
@@ -234,6 +236,13 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
234
236
|
return payload;
|
|
235
237
|
}
|
|
236
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Will process one event
|
|
241
|
+
* @param event The backend event to process
|
|
242
|
+
* @param source The source of the event (websocket or notication stream)
|
|
243
|
+
* @param dryRun Will not try to decrypt if true
|
|
244
|
+
* @return the decrypted payload and the raw event. Returns `undefined` when the payload is a coreCrypto-only system message
|
|
245
|
+
*/
|
|
237
246
|
async handleEvent(event, source, dryRun = false) {
|
|
238
247
|
var _a, _b;
|
|
239
248
|
switch (event.type) {
|
|
@@ -251,8 +260,8 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
251
260
|
const encryptedData = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
|
|
252
261
|
const groupId = await this.getGroupIdFromConversationId((_a = event.qualified_conversation) !== null && _a !== void 0 ? _a : { id: event.conversation, domain: '' });
|
|
253
262
|
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
254
|
-
// Check if the message includes proposals
|
|
255
263
|
const { proposals, commitDelay, message } = await this.mlsService.decryptMessage(groupIdBytes, encryptedData);
|
|
264
|
+
// Check if the message includes proposals
|
|
256
265
|
if (typeof commitDelay === 'number' || proposals.length > 0) {
|
|
257
266
|
// we are dealing with a proposal, add a task to process this proposal later on
|
|
258
267
|
// Those proposals are stored inside of coreCrypto and will be handled after a timeout
|
|
@@ -262,10 +271,12 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
262
271
|
eventTime: event.time,
|
|
263
272
|
});
|
|
264
273
|
// This is not a text message, there is nothing more to do
|
|
265
|
-
return
|
|
274
|
+
return undefined;
|
|
266
275
|
}
|
|
267
276
|
if (!message) {
|
|
268
|
-
|
|
277
|
+
const newEpoch = await this.mlsService.getEpoch(groupIdBytes);
|
|
278
|
+
this.logger.log(`Received commit message for group "${groupId}". New epoch is "${newEpoch}"`);
|
|
279
|
+
return undefined;
|
|
269
280
|
}
|
|
270
281
|
const decryptedData = protocol_messaging_1.GenericMessage.decode(message);
|
|
271
282
|
/**
|