@wireapp/core 30.12.0 → 31.0.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 +28 -22
- package/src/main/Account.d.ts +11 -3
- package/src/main/Account.js +11 -0
- package/src/main/CoreError.d.ts +1 -1
- package/src/main/account/AccountService.d.ts +2 -2
- package/src/main/account/AccountService.ts +2 -2
- package/src/main/auth/LoginSanitizer.d.ts +1 -1
- package/src/main/broadcast/AvailabilityType.d.ts +1 -1
- package/src/main/broadcast/BroadcastService.d.ts +3 -3
- package/src/main/client/ClientBackendRepository.d.ts +2 -2
- package/src/main/client/ClientDatabaseRepository.d.ts +3 -3
- package/src/main/client/ClientInfo.d.ts +1 -1
- package/src/main/client/ClientService.d.ts +4 -4
- package/src/main/connection/ConnectionService.d.ts +1 -1
- package/src/main/conversation/AbortReason.d.ts +1 -1
- package/src/main/conversation/AssetService/AssetService.d.ts +4 -4
- package/src/main/conversation/ConversationService/ConversationService.d.ts +9 -28
- package/src/main/conversation/ConversationService/ConversationService.js +4 -312
- package/src/main/conversation/ConversationService/ConversationService.types.d.ts +2 -0
- package/src/main/conversation/ConversationService/messageGenerator.d.ts +9 -0
- package/src/main/conversation/ConversationService/messageGenerator.js +301 -0
- package/src/main/conversation/message/CompositeContentBuilder.d.ts +1 -1
- package/src/main/conversation/message/Message.d.ts +3 -3
- package/src/main/conversation/message/MessageBuilder.d.ts +6 -2
- package/src/main/conversation/message/MessageBuilder.js +3 -0
- package/src/main/conversation/message/MessageToProtoMapper.d.ts +2 -2
- package/src/main/conversation/message/OtrMessage.d.ts +2 -2
- package/src/main/conversation/message/PayloadBundle.d.ts +3 -3
- package/src/main/conversation/message/TeamMessage.d.ts +2 -2
- package/src/main/conversation/message/TextContentBuilder.d.ts +1 -1
- package/src/main/conversation/message/UserMessage.d.ts +2 -2
- package/src/main/cryptography/AssetCryptography/index.d.ts +1 -1
- package/src/main/cryptography/CryptographyDatabaseRepository.d.ts +1 -1
- package/src/main/cryptography/CryptographyService.d.ts +7 -7
- package/src/main/cryptography/GenericMessageMapper.d.ts +1 -1
- package/src/main/giphy/GiphyService.d.ts +2 -2
- package/src/main/mls/MLSService/MLSService.d.ts +5 -3
- package/src/main/mls/MLSService/MLSService.js +35 -10
- package/src/main/mls/types.d.ts +11 -0
- package/src/main/notification/NotificationBackendRepository.d.ts +2 -2
- package/src/main/notification/NotificationDatabaseRepository.d.ts +4 -7
- package/src/main/notification/NotificationDatabaseRepository.js +0 -10
- package/src/main/notification/NotificationService.d.ts +6 -17
- package/src/main/notification/NotificationService.js +15 -27
- package/src/main/notification/types.d.ts +0 -4
- package/src/main/self/SelfService.d.ts +2 -2
- package/src/main/team/TeamService.d.ts +2 -2
- package/src/main/test/CryptographyHelper.d.ts +1 -1
- package/src/main/user/UserService.d.ts +3 -3
- package/src/main/util/TypePredicateUtil.d.ts +2 -2
- package/src/main/util/{mapQualifiedUserClientIdsToFullyQualifiedClientIds.d.ts → fullyQualifiedClientIdUtils.d.ts} +5 -0
- package/src/main/util/{mapQualifiedUserClientIdsToFullyQualifiedClientIds.js → fullyQualifiedClientIdUtils.js} +12 -2
- package/CHANGELOG.md +0 -12408
|
@@ -63,16 +63,6 @@ class NotificationDatabaseRepository {
|
|
|
63
63
|
});
|
|
64
64
|
return lastNotification.id;
|
|
65
65
|
}
|
|
66
|
-
generateCompoundGroupIdPrimaryKey({ conversationId, conversationDomain, }) {
|
|
67
|
-
return `${conversationId}@${conversationDomain}`;
|
|
68
|
-
}
|
|
69
|
-
async addCompoundGroupId(params) {
|
|
70
|
-
await this.storeEngine.updateOrCreate(STORES.GROUP_IDS, this.generateCompoundGroupIdPrimaryKey(params), params.groupId);
|
|
71
|
-
return params;
|
|
72
|
-
}
|
|
73
|
-
async getCompoundGroupId(params) {
|
|
74
|
-
return this.storeEngine.read(STORES.GROUP_IDS, this.generateCompoundGroupIdPrimaryKey(params));
|
|
75
|
-
}
|
|
76
66
|
/**
|
|
77
67
|
* ## MLS only ##
|
|
78
68
|
* Store groupIds with pending proposals and a delay in the DB until the proposals get committed.
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
2
|
+
import { APIClient } from '@wireapp/api-client';
|
|
3
3
|
import * as Events from '@wireapp/api-client/src/event';
|
|
4
|
-
import
|
|
4
|
+
import { Notification } from '@wireapp/api-client/src/notification/';
|
|
5
5
|
import { CRUDEngine } from '@wireapp/store-engine';
|
|
6
6
|
import { EventEmitter } from 'events';
|
|
7
7
|
import { PayloadBundle, PayloadBundleSource } from '../conversation';
|
|
8
8
|
import { NotificationError } from '../CoreError';
|
|
9
|
-
import
|
|
9
|
+
import { CryptographyService } from '../cryptography';
|
|
10
10
|
import { GenericMessage } from '@wireapp/protocol-messaging';
|
|
11
11
|
import { AbortHandler } from '@wireapp/api-client/src/tcp';
|
|
12
|
-
import { QualifiedId } from '@wireapp/api-client/src/user';
|
|
13
|
-
import { Conversation } from '@wireapp/api-client/src/conversation';
|
|
14
12
|
import { CommitPendingProposalsParams, LastKeyMaterialUpdateParams } from './types';
|
|
15
|
-
import
|
|
13
|
+
import { MLSService } from '../mls';
|
|
16
14
|
export declare type HandledEventPayload = {
|
|
17
15
|
event: Events.BackendEvent;
|
|
18
16
|
mappedEvent?: PayloadBundle;
|
|
@@ -61,23 +59,14 @@ export declare class NotificationService extends EventEmitter {
|
|
|
61
59
|
handleNotification(notification: Notification, source: PayloadBundleSource, dryRun?: boolean): AsyncGenerator<HandledEventPayload>;
|
|
62
60
|
private cleanupPayloadBundle;
|
|
63
61
|
private handleEvent;
|
|
64
|
-
/**
|
|
65
|
-
* ## MLS only ##
|
|
66
|
-
* If there is a groupId in the conversation, we need to store the conversationId => groupId pair
|
|
67
|
-
* in order to find the groupId when decrypting messages
|
|
68
|
-
* This is a bit hacky but since mls messages do not embed the groupId we need to keep a mapping of those
|
|
69
|
-
*
|
|
70
|
-
* @param conversation conversation with group_id
|
|
71
|
-
*/
|
|
72
|
-
saveConversationGroupId(conversation: Conversation): Promise<void>;
|
|
73
62
|
/**
|
|
74
63
|
* ## MLS only ##
|
|
75
64
|
* If there is a matching conversationId => groupId pair in the database,
|
|
76
|
-
* we can find the groupId and return it as a
|
|
65
|
+
* we can find the groupId and return it as a string
|
|
77
66
|
*
|
|
78
67
|
* @param conversationQualifiedId
|
|
79
68
|
*/
|
|
80
|
-
|
|
69
|
+
private getGroupIdFromConversationId;
|
|
81
70
|
/**
|
|
82
71
|
* ## MLS only ##
|
|
83
72
|
* If there are pending proposals, we need to either process them,
|
|
@@ -229,20 +229,25 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
229
229
|
const groupIdStr = bazinga64_1.Encoder.toBase64(newGroupId).asString;
|
|
230
230
|
// The groupId can then be sent back to the consumer
|
|
231
231
|
return {
|
|
232
|
-
event,
|
|
232
|
+
event: Object.assign(Object.assign({}, event), { data: groupIdStr }),
|
|
233
233
|
mappedEvent: ConversationMapper_1.ConversationMapper.mapConversationEvent(Object.assign(Object.assign({}, event), { data: groupIdStr }), source),
|
|
234
234
|
};
|
|
235
235
|
case Events.CONVERSATION_EVENT.MLS_MESSAGE_ADD:
|
|
236
236
|
const encryptedData = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
|
|
237
|
-
const groupId = await this.
|
|
237
|
+
const groupId = await this.getGroupIdFromConversationId((_a = event.qualified_conversation) !== null && _a !== void 0 ? _a : { id: event.conversation, domain: '' });
|
|
238
|
+
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
238
239
|
// Check if the message includes proposals
|
|
239
|
-
const { proposals, commitDelay, message } = await this.mlsService.decryptMessage(
|
|
240
|
-
if (proposals.length > 0) {
|
|
240
|
+
const { proposals, commitDelay, message } = await this.mlsService.decryptMessage(groupIdBytes, encryptedData);
|
|
241
|
+
if (typeof commitDelay === 'number' || proposals.length > 0) {
|
|
242
|
+
// we are dealing with a proposal, add a task to process this proposal later on
|
|
243
|
+
// Those proposals are stored inside of coreCrypto and will be handled after a timeout
|
|
241
244
|
await this.handlePendingProposals({
|
|
242
|
-
groupId
|
|
245
|
+
groupId,
|
|
243
246
|
delayInMs: commitDelay !== null && commitDelay !== void 0 ? commitDelay : 0,
|
|
244
247
|
eventTime: event.time,
|
|
245
248
|
});
|
|
249
|
+
// This is not a text message, there is nothing more to do
|
|
250
|
+
return { event };
|
|
246
251
|
}
|
|
247
252
|
if (!message) {
|
|
248
253
|
throw new Error(`MLS message received from ${source} was empty`);
|
|
@@ -280,7 +285,6 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
280
285
|
if (!conversation) {
|
|
281
286
|
throw new Error('no conv');
|
|
282
287
|
}
|
|
283
|
-
await this.saveConversationGroupId(conversation);
|
|
284
288
|
case Events.CONVERSATION_EVENT.MESSAGE_TIMER_UPDATE:
|
|
285
289
|
case Events.CONVERSATION_EVENT.RENAME:
|
|
286
290
|
case Events.CONVERSATION_EVENT.TYPING: {
|
|
@@ -298,37 +302,21 @@ class NotificationService extends events_1.EventEmitter {
|
|
|
298
302
|
}
|
|
299
303
|
return { event };
|
|
300
304
|
}
|
|
301
|
-
/**
|
|
302
|
-
* ## MLS only ##
|
|
303
|
-
* If there is a groupId in the conversation, we need to store the conversationId => groupId pair
|
|
304
|
-
* in order to find the groupId when decrypting messages
|
|
305
|
-
* This is a bit hacky but since mls messages do not embed the groupId we need to keep a mapping of those
|
|
306
|
-
*
|
|
307
|
-
* @param conversation conversation with group_id
|
|
308
|
-
*/
|
|
309
|
-
async saveConversationGroupId(conversation) {
|
|
310
|
-
if (conversation.group_id) {
|
|
311
|
-
const { group_id: groupId, qualified_id: { id: conversationId, domain: conversationDomain }, } = conversation;
|
|
312
|
-
await this.database.addCompoundGroupId({ conversationDomain, conversationId, groupId });
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
305
|
/**
|
|
316
306
|
* ## MLS only ##
|
|
317
307
|
* If there is a matching conversationId => groupId pair in the database,
|
|
318
|
-
* we can find the groupId and return it as a
|
|
308
|
+
* we can find the groupId and return it as a string
|
|
319
309
|
*
|
|
320
310
|
* @param conversationQualifiedId
|
|
321
311
|
*/
|
|
322
|
-
async
|
|
312
|
+
async getGroupIdFromConversationId(conversationQualifiedId) {
|
|
313
|
+
var _a, _b;
|
|
323
314
|
const { id: conversationId, domain: conversationDomain } = conversationQualifiedId;
|
|
324
|
-
const groupId = await this.
|
|
325
|
-
conversationId,
|
|
326
|
-
conversationDomain,
|
|
327
|
-
});
|
|
315
|
+
const groupId = await ((_b = (_a = this.mlsService).groupIdFromConversationId) === null || _b === void 0 ? void 0 : _b.call(_a, conversationQualifiedId));
|
|
328
316
|
if (!groupId) {
|
|
329
317
|
throw new Error(`Could not find a group_id for conversation ${conversationId}@${conversationDomain}`);
|
|
330
318
|
}
|
|
331
|
-
return
|
|
319
|
+
return groupId;
|
|
332
320
|
}
|
|
333
321
|
/**
|
|
334
322
|
* ## MLS only ##
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
export declare type CommonMLS = {
|
|
2
2
|
groupId: string;
|
|
3
3
|
};
|
|
4
|
-
export declare type CompoundGroupIdParams = {
|
|
5
|
-
conversationId: string;
|
|
6
|
-
conversationDomain: string;
|
|
7
|
-
} & CommonMLS;
|
|
8
4
|
export declare type HandlePendingProposalsParams = {
|
|
9
5
|
delayInMs: number;
|
|
10
6
|
eventTime: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { APIClient } from '@wireapp/api-client';
|
|
2
|
+
import { Self } from '@wireapp/api-client/src/self/';
|
|
3
3
|
export declare class SelfService {
|
|
4
4
|
private readonly apiClient;
|
|
5
5
|
constructor(apiClient: APIClient);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { APIClient } from '@wireapp/api-client';
|
|
2
|
+
import { MemberData, Members, NewTeamData, TeamChunkData, TeamData, UpdateTeamData } from '@wireapp/api-client/src/team/';
|
|
3
3
|
export declare class TeamService {
|
|
4
4
|
private readonly apiClient;
|
|
5
5
|
constructor(apiClient: APIClient);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { keys } from '@wireapp/proteus';
|
|
2
|
-
import
|
|
2
|
+
import { CryptographyService } from '../cryptography';
|
|
3
3
|
export declare function createEncodedCipherText(receiver: keys.IdentityKeyPair, preKey: keys.PreKey, text: string): Promise<string>;
|
|
4
4
|
export declare function getPlainText(cryptographyService: CryptographyService, encodedPreKeyMessage: string, sessionId?: string): Promise<string | void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { APIClient } from '@wireapp/api-client';
|
|
2
|
+
import { QualifiedId, User } from '@wireapp/api-client/src/user/';
|
|
3
|
+
import { AvailabilityType, BroadcastService } from '../broadcast/';
|
|
4
4
|
import { ConnectionService } from '../connection';
|
|
5
5
|
import { ConversationService } from '../conversation';
|
|
6
6
|
export declare class UserService {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { QualifiedUserClients, UserClients } from '@wireapp/api-client/src/conversation/';
|
|
2
|
+
import { QualifiedId } from '@wireapp/api-client/src/user/';
|
|
3
3
|
export declare function isStringArray(obj: any): obj is string[];
|
|
4
4
|
export declare function isQualifiedId(obj: any): obj is QualifiedId;
|
|
5
5
|
export declare function isQualifiedIdArray(obj: any): obj is QualifiedId[];
|
|
@@ -4,5 +4,10 @@ declare type ClientId = string;
|
|
|
4
4
|
declare type Domain = string;
|
|
5
5
|
export declare type ClientIdStringType = `${UserId}:${ClientId}@${Domain}`;
|
|
6
6
|
export declare const constructFullyQualifiedClientId: (userId: UserId, clientId: ClientId, domain: Domain) => ClientIdStringType;
|
|
7
|
+
export declare const parseFullQualifiedClientId: (qualifiedId: string) => {
|
|
8
|
+
user: UserId;
|
|
9
|
+
client: ClientId;
|
|
10
|
+
domain: Domain;
|
|
11
|
+
};
|
|
7
12
|
export declare const mapQualifiedUserClientIdsToFullyQualifiedClientIds: (qualifiedUserMap: QualifiedUserClientMap) => Uint8Array[];
|
|
8
13
|
export {};
|
|
@@ -18,9 +18,19 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.mapQualifiedUserClientIdsToFullyQualifiedClientIds = exports.constructFullyQualifiedClientId = void 0;
|
|
21
|
+
exports.mapQualifiedUserClientIdsToFullyQualifiedClientIds = exports.parseFullQualifiedClientId = exports.constructFullyQualifiedClientId = void 0;
|
|
22
22
|
const constructFullyQualifiedClientId = (userId, clientId, domain) => `${userId}:${clientId}@${domain}`;
|
|
23
23
|
exports.constructFullyQualifiedClientId = constructFullyQualifiedClientId;
|
|
24
|
+
const parseFullQualifiedClientId = (qualifiedId) => {
|
|
25
|
+
var _a;
|
|
26
|
+
const regexp = /([a-zA-Z0-9\-]+):([a-zA-Z0-9\-]+)@([a-zA-Z0-9\-.]+)/;
|
|
27
|
+
const [, user, client, domain] = (_a = qualifiedId.match(regexp)) !== null && _a !== void 0 ? _a : [];
|
|
28
|
+
if (!user || !client || !domain) {
|
|
29
|
+
throw new Error(`given client fully qualified ID is corrupted (${qualifiedId})`);
|
|
30
|
+
}
|
|
31
|
+
return { user, client, domain };
|
|
32
|
+
};
|
|
33
|
+
exports.parseFullQualifiedClientId = parseFullQualifiedClientId;
|
|
24
34
|
const mapQualifiedUserClientIdsToFullyQualifiedClientIds = (qualifiedUserMap) => {
|
|
25
35
|
const encoder = new TextEncoder();
|
|
26
36
|
return Object.entries(qualifiedUserMap).flatMap(([domain, users]) => {
|
|
@@ -29,4 +39,4 @@ const mapQualifiedUserClientIdsToFullyQualifiedClientIds = (qualifiedUserMap) =>
|
|
|
29
39
|
});
|
|
30
40
|
};
|
|
31
41
|
exports.mapQualifiedUserClientIdsToFullyQualifiedClientIds = mapQualifiedUserClientIdsToFullyQualifiedClientIds;
|
|
32
|
-
//# sourceMappingURL=
|
|
42
|
+
//# sourceMappingURL=fullyQualifiedClientIdUtils.js.map
|