@wireapp/core 39.1.0 → 39.1.1
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/broadcast/BroadcastService.js +1 -1
- package/lib/conversation/message/MessageService.js +2 -2
- package/lib/conversation/message/UserClientsUtil.d.ts +14 -10
- package/lib/conversation/message/UserClientsUtil.d.ts.map +1 -1
- package/lib/conversation/message/UserClientsUtil.js +21 -11
- package/lib/conversation/message/UserClientsUtils.test.js +5 -9
- package/lib/messagingProtocols/proteus/Utility/Recipients.d.ts +2 -2
- package/lib/messagingProtocols/proteus/Utility/Recipients.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/Recipients.js +10 -2
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.js +1 -1
- package/package.json +2 -2
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.d.ts +0 -19
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.d.ts.map +0 -1
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.js +0 -63
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.d.ts +0 -2
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.d.ts.map +0 -1
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.js +0 -66
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.d.ts +0 -2
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.d.ts.map +0 -1
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.js +0 -35
|
@@ -33,7 +33,7 @@ class BroadcastService {
|
|
|
33
33
|
const plainTextArray = protocol_messaging_1.GenericMessage.encode(genericMessage).finish();
|
|
34
34
|
const send = () => {
|
|
35
35
|
return this.messageService.sendMessage(this.apiClient.validatedClientId, recipients, plainTextArray, {
|
|
36
|
-
reportMissing: (0, UserClientsUtil_1.
|
|
36
|
+
reportMissing: (0, UserClientsUtil_1.flattenUserMap)(recipients).map(({ userId }) => userId),
|
|
37
37
|
onClientMismatch,
|
|
38
38
|
});
|
|
39
39
|
};
|
|
@@ -127,12 +127,12 @@ class MessageService {
|
|
|
127
127
|
* @return resolves with a new message payload that can be sent
|
|
128
128
|
*/
|
|
129
129
|
async reencryptAfterMismatch(mismatch, recipients, plainText) {
|
|
130
|
-
const deleted = (0, UserClientsUtil_1.
|
|
130
|
+
const deleted = (0, UserClientsUtil_1.flattenUserMap)(mismatch.deleted);
|
|
131
131
|
// remove deleted clients to the recipients
|
|
132
132
|
deleted.forEach(({ userId, data }) => data.forEach(clientId => delete recipients[userId.domain][userId.id][clientId]));
|
|
133
133
|
if (Object.keys(mismatch.missing).length) {
|
|
134
134
|
const { payloads } = await this.proteusService.encrypt(plainText, mismatch.missing);
|
|
135
|
-
const reEncryptedPayloads = (0, UserClientsUtil_1.
|
|
135
|
+
const reEncryptedPayloads = (0, UserClientsUtil_1.flattenUserMap)(payloads);
|
|
136
136
|
reEncryptedPayloads.forEach(({ data, userId }) => {
|
|
137
137
|
var _a;
|
|
138
138
|
const domainRecipients = (_a = recipients[userId.domain]) !== null && _a !== void 0 ? _a : {};
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
2
|
-
type
|
|
2
|
+
type UserMap<T> = {
|
|
3
3
|
[userId: string]: T;
|
|
4
4
|
};
|
|
5
|
-
type
|
|
6
|
-
[domain: string]:
|
|
5
|
+
type QualifiedUserMap<T> = {
|
|
6
|
+
[domain: string]: UserMap<T>;
|
|
7
7
|
};
|
|
8
|
-
export declare function flattenUserClients<T>(userClients: UserClientsContainer<T>, domain?: string): {
|
|
9
|
-
data: T;
|
|
10
|
-
userId: QualifiedId;
|
|
11
|
-
}[];
|
|
12
8
|
/**
|
|
13
|
-
* Will flatten a container of users=>
|
|
9
|
+
* Will flatten a container of domain=>users=>anything infos to an array
|
|
14
10
|
*
|
|
15
|
-
* @param
|
|
11
|
+
* @param userMap The qualified UserMap to flatten
|
|
16
12
|
* @return An array containing the qualified user Ids and the clients info
|
|
17
13
|
*/
|
|
18
|
-
export declare function
|
|
14
|
+
export declare function flattenUserMap<T = unknown>(userMap: QualifiedUserMap<T>): {
|
|
19
15
|
data: T;
|
|
20
16
|
userId: QualifiedId;
|
|
21
17
|
}[];
|
|
18
|
+
/**
|
|
19
|
+
* Will convert a list of qualified users to a UserMap
|
|
20
|
+
* @param users the list of users to convert
|
|
21
|
+
*/
|
|
22
|
+
export declare function nestUsersList<T = unknown>(users: {
|
|
23
|
+
data: T;
|
|
24
|
+
userId: QualifiedId;
|
|
25
|
+
}[]): QualifiedUserMap<T>;
|
|
22
26
|
export {};
|
|
23
27
|
//# sourceMappingURL=UserClientsUtil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserClientsUtil.d.ts","sourceRoot":"","sources":["../../../src/conversation/message/UserClientsUtil.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,KAAK,
|
|
1
|
+
{"version":3,"file":"UserClientsUtil.d.ts","sourceRoot":"","sources":["../../../src/conversation/message/UserClientsUtil.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,KAAK,OAAO,CAAC,CAAC,IAAI;IAAC,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAA;CAAC,CAAC;AACxC,KAAK,gBAAgB,CAAC,CAAC,IAAI;IAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;CAAC,CAAC;AAE1D;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAC,EAAE,CAI1G;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAC,EAAE,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAQvG"}
|
|
@@ -18,20 +18,30 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.
|
|
22
|
-
function flattenUserClients(userClients, domain = '') {
|
|
23
|
-
return Object.entries(userClients).map(([id, data]) => ({ data, userId: { domain, id } }));
|
|
24
|
-
}
|
|
25
|
-
exports.flattenUserClients = flattenUserClients;
|
|
21
|
+
exports.nestUsersList = exports.flattenUserMap = void 0;
|
|
26
22
|
/**
|
|
27
|
-
* Will flatten a container of users=>
|
|
23
|
+
* Will flatten a container of domain=>users=>anything infos to an array
|
|
28
24
|
*
|
|
29
|
-
* @param
|
|
25
|
+
* @param userMap The qualified UserMap to flatten
|
|
30
26
|
* @return An array containing the qualified user Ids and the clients info
|
|
31
27
|
*/
|
|
32
|
-
function
|
|
33
|
-
return Object.entries(
|
|
34
|
-
return [...ids, ...
|
|
28
|
+
function flattenUserMap(userMap) {
|
|
29
|
+
return Object.entries(userMap).reduce((ids, [domain, userClients]) => {
|
|
30
|
+
return [...ids, ...Object.entries(userClients).map(([id, data]) => ({ data, userId: { domain, id } }))];
|
|
35
31
|
}, []);
|
|
36
32
|
}
|
|
37
|
-
exports.
|
|
33
|
+
exports.flattenUserMap = flattenUserMap;
|
|
34
|
+
/**
|
|
35
|
+
* Will convert a list of qualified users to a UserMap
|
|
36
|
+
* @param users the list of users to convert
|
|
37
|
+
*/
|
|
38
|
+
function nestUsersList(users) {
|
|
39
|
+
return users.reduce((users, { data, userId: { domain, id } }) => {
|
|
40
|
+
if (!users[domain]) {
|
|
41
|
+
users[domain] = {};
|
|
42
|
+
}
|
|
43
|
+
users[domain][id] = data;
|
|
44
|
+
return users;
|
|
45
|
+
}, {});
|
|
46
|
+
}
|
|
47
|
+
exports.nestUsersList = nestUsersList;
|
|
@@ -27,15 +27,11 @@ describe('userClientsUtils', () => {
|
|
|
27
27
|
{ data: ['client11'], userId: { domain: 'domain1', id: 'user2' } },
|
|
28
28
|
{ data: ['client1', 'client2'], userId: { domain: 'domain2', id: 'user3' } },
|
|
29
29
|
];
|
|
30
|
-
expect((0, UserClientsUtil_1.
|
|
30
|
+
expect((0, UserClientsUtil_1.flattenUserMap)(payload)).toEqual(expected);
|
|
31
31
|
});
|
|
32
|
-
it('
|
|
33
|
-
const payload = { user1: ['client1'], user2: ['client11'], user3: ['client1', 'client2'] };
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
{ data: ['client11'], userId: { domain: '', id: 'user2' } },
|
|
37
|
-
{ data: ['client1', 'client2'], userId: { domain: '', id: 'user3' } },
|
|
38
|
-
];
|
|
39
|
-
expect((0, UserClientsUtil_1.flattenUserClients)(payload)).toEqual(expected);
|
|
32
|
+
it('nest and flatten are inverse operations', () => {
|
|
33
|
+
const payload = { domain1: { user1: ['client1'], user2: ['client11'] }, domain2: { user3: ['client1', 'client2'] } };
|
|
34
|
+
const result = (0, UserClientsUtil_1.nestUsersList)((0, UserClientsUtil_1.flattenUserMap)(payload));
|
|
35
|
+
expect(result).toEqual(payload);
|
|
40
36
|
});
|
|
41
37
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { APIClient } from '@wireapp/api-client/lib/APIClient';
|
|
2
2
|
import { QualifiedUserClients } from '@wireapp/api-client/lib/conversation';
|
|
3
|
-
import { QualifiedId
|
|
3
|
+
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
4
4
|
interface GetRecipientsForConversationQualifiedParams {
|
|
5
5
|
apiClient: APIClient;
|
|
6
6
|
conversationId: QualifiedId;
|
|
7
7
|
userIds?: QualifiedId[] | QualifiedUserClients;
|
|
8
8
|
}
|
|
9
|
-
declare const getRecipientsForConversation: ({ apiClient, conversationId, userIds, }: GetRecipientsForConversationQualifiedParams) => Promise<QualifiedUserClients
|
|
9
|
+
declare const getRecipientsForConversation: ({ apiClient, conversationId, userIds, }: GetRecipientsForConversationQualifiedParams) => Promise<QualifiedUserClients>;
|
|
10
10
|
export { getRecipientsForConversation };
|
|
11
11
|
//# sourceMappingURL=Recipients.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Recipients.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/Utility/Recipients.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"Recipients.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/Utility/Recipients.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAE5D,OAAO,EAAC,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAczD,UAAU,2CAA2C;IACnD,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,WAAW,CAAC;IAC5B,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,oBAAoB,CAAC;CAChD;AAED,QAAA,MAAM,4BAA4B,4CAI/B,2CAA2C,KAAG,QAAQ,oBAAoB,CAQ5E,CAAC;AAEF,OAAO,EAAC,4BAA4B,EAAC,CAAC"}
|
|
@@ -19,14 +19,22 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.getRecipientsForConversation = void 0;
|
|
22
|
-
const PreKeyBundle_1 = require("./PreKeyBundle/PreKeyBundle");
|
|
23
22
|
const getConversationQualifiedMembers_1 = require("../../../conversation/ConversationService/Utility/getConversationQualifiedMembers");
|
|
23
|
+
const UserClientsUtil_1 = require("../../../conversation/message/UserClientsUtil");
|
|
24
24
|
const util_1 = require("../../../util");
|
|
25
|
+
function toQualifiedUserClients(publicClients) {
|
|
26
|
+
const userList = (0, UserClientsUtil_1.flattenUserMap)(publicClients).map(({ userId, data: clientInfo }) => ({
|
|
27
|
+
userId,
|
|
28
|
+
data: clientInfo.map(client => client.id),
|
|
29
|
+
}));
|
|
30
|
+
return (0, UserClientsUtil_1.nestUsersList)(userList);
|
|
31
|
+
}
|
|
25
32
|
const getRecipientsForConversation = async ({ apiClient, conversationId, userIds, }) => {
|
|
26
33
|
if ((0, util_1.isQualifiedUserClients)(userIds)) {
|
|
27
34
|
return userIds;
|
|
28
35
|
}
|
|
29
36
|
const recipientIds = userIds || (await (0, getConversationQualifiedMembers_1.getConversationQualifiedMembers)({ apiClient: apiClient, conversationId }));
|
|
30
|
-
|
|
37
|
+
const allClients = await apiClient.api.user.postListClients({ qualified_users: recipientIds });
|
|
38
|
+
return toQualifiedUserClients(allClients.qualified_user_map);
|
|
31
39
|
};
|
|
32
40
|
exports.getRecipientsForConversation = getRecipientsForConversation;
|
|
@@ -78,7 +78,7 @@ const initSessions = async ({ recipients, apiClient, cryptoClient, logger, }) =>
|
|
|
78
78
|
const missingClients = {};
|
|
79
79
|
const missingClientsWithPrekeys = {};
|
|
80
80
|
const existingSessions = [];
|
|
81
|
-
const users = (0, UserClientsUtil_1.
|
|
81
|
+
const users = (0, UserClientsUtil_1.flattenUserMap)(recipients);
|
|
82
82
|
for (const user of users) {
|
|
83
83
|
const { userId, data } = user;
|
|
84
84
|
const clients = Array.isArray(data) ? data : Object.keys(data);
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { APIClient } from '@wireapp/api-client/lib/APIClient';
|
|
2
|
-
import { QualifiedUserClients, UserClients } from '@wireapp/api-client/lib/conversation';
|
|
3
|
-
import { QualifiedId, QualifiedUserPreKeyBundleMap, UserPreKeyBundleMap } from '@wireapp/api-client/lib/user';
|
|
4
|
-
declare const preKeyBundleToUserClients: (users: UserPreKeyBundleMap) => UserClients;
|
|
5
|
-
/**
|
|
6
|
-
* Will generate a prekey bundle for specific users.
|
|
7
|
-
* If a QualifiedId array is given the bundle will contain all the clients from those users fetched from the server.
|
|
8
|
-
* If a QualifiedUserClients is provided then only the clients in the payload will be targeted (which could generate a ClientMismatch when sending messages)
|
|
9
|
-
*
|
|
10
|
-
* @param {QualifiedId[]|QualifiedUserClients} userIds - Targeted users.
|
|
11
|
-
* @returns {Promise<QualifiedUserPreKeyBundleMap}
|
|
12
|
-
*/
|
|
13
|
-
interface GetQualifiedPreKeyBundleMapParams {
|
|
14
|
-
apiClient: APIClient;
|
|
15
|
-
userIds?: QualifiedId[] | QualifiedUserClients;
|
|
16
|
-
}
|
|
17
|
-
declare const getQualifiedPreKeyBundle: ({ apiClient, userIds, }: GetQualifiedPreKeyBundleMapParams) => Promise<QualifiedUserPreKeyBundleMap>;
|
|
18
|
-
export { getQualifiedPreKeyBundle, preKeyBundleToUserClients };
|
|
19
|
-
//# sourceMappingURL=PreKeyBundle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PreKeyBundle.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAC,oBAAoB,EAAE,WAAW,EAAC,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAC,WAAW,EAAE,4BAA4B,EAAE,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AAI5G,QAAA,MAAM,yBAAyB,UAAW,mBAAmB,KAAG,WAK/D,CAAC;AAEF;;;;;;;GAOG;AACH,UAAU,iCAAiC;IACzC,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,oBAAoB,CAAC;CAChD;AACD,QAAA,MAAM,wBAAwB,4BAG3B,iCAAiC,KAAG,QAAQ,4BAA4B,CAoC1E,CAAC;AAEF,OAAO,EAAC,wBAAwB,EAAE,yBAAyB,EAAC,CAAC"}
|
|
@@ -1,63 +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.preKeyBundleToUserClients = exports.getQualifiedPreKeyBundle = void 0;
|
|
22
|
-
const util_1 = require("../../../../util");
|
|
23
|
-
const preKeyBundleToUserClients = (users) => {
|
|
24
|
-
return Object.entries(users).reduce((acc, [userId, clientsObj]) => {
|
|
25
|
-
acc[userId] = Object.keys(clientsObj);
|
|
26
|
-
return acc;
|
|
27
|
-
}, {});
|
|
28
|
-
};
|
|
29
|
-
exports.preKeyBundleToUserClients = preKeyBundleToUserClients;
|
|
30
|
-
const getQualifiedPreKeyBundle = async ({ apiClient, userIds, }) => {
|
|
31
|
-
let targets = [];
|
|
32
|
-
if (userIds) {
|
|
33
|
-
if ((0, util_1.isQualifiedIdArray)(userIds)) {
|
|
34
|
-
targets = userIds.map(id => ({ id }));
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
targets = Object.entries(userIds).reduce((accumulator, [domain, userClients]) => {
|
|
38
|
-
for (const userId in userClients) {
|
|
39
|
-
accumulator.push({ id: { id: userId, domain }, clients: userClients[userId] });
|
|
40
|
-
}
|
|
41
|
-
return accumulator;
|
|
42
|
-
}, []);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const preKeys = await Promise.all(targets.map(async ({ id: userId, clients }) => {
|
|
46
|
-
const prekeyBundle = await apiClient.api.user.getUserPreKeys(userId);
|
|
47
|
-
// We filter the clients that should not receive the message (if a QualifiedUserClients was given as parameter)
|
|
48
|
-
const userClients = clients
|
|
49
|
-
? prekeyBundle.clients.filter(client => clients.includes(client.client))
|
|
50
|
-
: prekeyBundle.clients;
|
|
51
|
-
return { user: userId, clients: userClients };
|
|
52
|
-
}));
|
|
53
|
-
return preKeys.reduce((bundleMap, qualifiedPrekey) => {
|
|
54
|
-
var _a, _b, _c;
|
|
55
|
-
bundleMap[_a = qualifiedPrekey.user.domain] || (bundleMap[_a] = {});
|
|
56
|
-
for (const client of qualifiedPrekey.clients) {
|
|
57
|
-
(_b = bundleMap[qualifiedPrekey.user.domain])[_c = qualifiedPrekey.user.id] || (_b[_c] = {});
|
|
58
|
-
bundleMap[qualifiedPrekey.user.domain][qualifiedPrekey.user.id][client.client] = client.prekey;
|
|
59
|
-
}
|
|
60
|
-
return bundleMap;
|
|
61
|
-
}, {});
|
|
62
|
-
};
|
|
63
|
-
exports.getQualifiedPreKeyBundle = getQualifiedPreKeyBundle;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PreKeyBundle.test.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,66 +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 PreKeyBundle_1 = require("./PreKeyBundle");
|
|
22
|
-
const firstUser = {
|
|
23
|
-
id: 'bc0c99f1-49a5-4ad2-889a-62885af37088',
|
|
24
|
-
clients: { first: 'be67218b77d02d30', second: 'ae87218e77d02d30' },
|
|
25
|
-
};
|
|
26
|
-
const secondUser = {
|
|
27
|
-
id: 'bc0c99ff-ffa5-ffd2-ff9a-6ff85af3ff88',
|
|
28
|
-
clients: { first: 'kk67218b77d02d30', second: 'kk87218e77d02d30' },
|
|
29
|
-
};
|
|
30
|
-
const validPreKey = {
|
|
31
|
-
id: 1337,
|
|
32
|
-
key: 'pQABARn//wKhAFggJ1Fbpg5l6wnzKOJE+vXpRnkqUYhIvVnR5lNXEbO2o/0DoQChAFggHxZvgvtDktY/vqBcpjjo6rQnXvcNQhfwmy8AJQJKlD0E9g==',
|
|
33
|
-
};
|
|
34
|
-
describe('PrekeyHandler', () => {
|
|
35
|
-
describe('preKeyBundleToUserClients', () => {
|
|
36
|
-
it('maps preKeyBundle to userClients', () => {
|
|
37
|
-
const input = {
|
|
38
|
-
[firstUser.id]: { [firstUser.clients.first]: validPreKey },
|
|
39
|
-
};
|
|
40
|
-
const output = {
|
|
41
|
-
[firstUser.id]: [firstUser.clients.first],
|
|
42
|
-
};
|
|
43
|
-
expect((0, PreKeyBundle_1.preKeyBundleToUserClients)(input)).toEqual(output);
|
|
44
|
-
});
|
|
45
|
-
it('maps preKeyBundle to userClients (multiple clients)', () => {
|
|
46
|
-
const input = {
|
|
47
|
-
[firstUser.id]: { [firstUser.clients.first]: validPreKey, [firstUser.clients.second]: validPreKey },
|
|
48
|
-
};
|
|
49
|
-
const output = {
|
|
50
|
-
[firstUser.id]: [firstUser.clients.first, firstUser.clients.second],
|
|
51
|
-
};
|
|
52
|
-
expect((0, PreKeyBundle_1.preKeyBundleToUserClients)(input)).toEqual(output);
|
|
53
|
-
});
|
|
54
|
-
it('maps preKeyBundle to userClients (multiple users)', () => {
|
|
55
|
-
const input = {
|
|
56
|
-
[firstUser.id]: { [firstUser.clients.first]: validPreKey, [firstUser.clients.second]: validPreKey },
|
|
57
|
-
[secondUser.id]: { [secondUser.clients.first]: validPreKey, [secondUser.clients.second]: validPreKey },
|
|
58
|
-
};
|
|
59
|
-
const output = {
|
|
60
|
-
[firstUser.id]: [firstUser.clients.first, firstUser.clients.second],
|
|
61
|
-
[secondUser.id]: [secondUser.clients.first, secondUser.clients.second],
|
|
62
|
-
};
|
|
63
|
-
expect((0, PreKeyBundle_1.preKeyBundleToUserClients)(input)).toEqual(output);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/Utility/PreKeyBundle/index.ts"],"names":[],"mappings":"AAmBA,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,35 +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("./PreKeyBundle"), exports);
|