@wireapp/core 38.8.1 → 38.8.3
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/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +1 -2
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +8 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +14 -9
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts +2 -2
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.js +3 -4
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.test.js +54 -94
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.js +15 -15
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +50 -42
- package/lib/util/fullyQualifiedClientIdUtils.d.ts +1 -1
- package/lib/util/fullyQualifiedClientIdUtils.d.ts.map +1 -1
- package/lib/util/fullyQualifiedClientIdUtils.js +1 -2
- package/lib/util/fullyQualifiedClientIdUtils.test.js +3 -4
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationService/ConversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAEL,YAAY,EACZ,2BAA2B,EAC3B,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,WAAW,EAGX,mBAAmB,EACpB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAC,4BAA4B,EAAC,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAC,G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AI,CAAC;IAMhB;;;;OAIG;IAEH;;;OAGG;IACU,qBAAqB,CAAC,gBAAgB,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC;YAmC/E,cAAc;IAqBf,yBAAyB,CAAC,EACrC,gBAAgB,EAChB,OAAO,EACP,cAAc,GACf,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAcvC,8BAA8B,CAAC,EAC1C,OAAO,EACP,cAAc,EACd,gBAAgB,GACjB,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ConversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationService/ConversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAEL,YAAY,EACZ,2BAA2B,EAC3B,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,WAAW,EAGX,mBAAmB,EACpB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAC,4BAA4B,EAAC,MAAM,+BAA+B,CAAC;AAC3E,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,EAAC,cAAc,EAAE,aAAa,EAAE,oBAAoB,EAAE,UAAU,EAAC,MAAM,6BAA6B,CAAC;AAE5G,OAAO,EAAC,YAAY,EAAuB,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAEzF,OAAO,EAAC,UAAU,EAAuB,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAkC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AACjG,OAAO,EACL,mCAAmC,EACnC,wBAAwB,EACzB,MAAM,sEAAsE,CAAC;AAG9E,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AAItC,qBAAa,mBAAmB;IAM5B,OAAO,CAAC,QAAQ,CAAC,SAA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;IAI5C,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAIlD,YAAY;IAYb,mBAAmB;CA2BjC"}
|
|
@@ -250,10 +250,9 @@ class ConversationService {
|
|
|
250
250
|
};
|
|
251
251
|
}
|
|
252
252
|
async removeUsersFromMLSConversation({ groupId, conversationId, qualifiedUserIds, }) {
|
|
253
|
-
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
254
253
|
const clientsToRemove = await this.apiClient.api.user.postListClients({ qualified_users: qualifiedUserIds });
|
|
255
254
|
const fullyQualifiedClientIds = (0, fullyQualifiedClientIdUtils_1.mapQualifiedUserClientIdsToFullyQualifiedClientIds)(clientsToRemove.qualified_user_map);
|
|
256
|
-
const messageResponse = await this.mlsService.removeClientsFromConversation(
|
|
255
|
+
const messageResponse = await this.mlsService.removeClientsFromConversation(groupId, fullyQualifiedClientIds);
|
|
257
256
|
//key material gets updated after removing a user from the group, so we can reset last key update time value in the store
|
|
258
257
|
this.mlsService.resetKeyMaterialRenewal(groupId);
|
|
259
258
|
const conversation = await this.getConversation(conversationId);
|
|
@@ -28,6 +28,8 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
28
28
|
logger: logdown.Logger;
|
|
29
29
|
config: MLSServiceConfig;
|
|
30
30
|
groupIdFromConversationId?: MLSCallbacks['groupIdFromConversationId'];
|
|
31
|
+
private readonly textEncoder;
|
|
32
|
+
private readonly textDecoder;
|
|
31
33
|
constructor(apiClient: APIClient, coreCryptoClient: CoreCrypto, { keyingMaterialUpdateThreshold, nbKeyPackages, }: Partial<MLSServiceConfig>);
|
|
32
34
|
initClient(userId: QualifiedId, clientId: string): Promise<void>;
|
|
33
35
|
createClient(userId: QualifiedId, clientId: string): Promise<void>;
|
|
@@ -74,7 +76,12 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
74
76
|
user: QualifiedId;
|
|
75
77
|
client?: string;
|
|
76
78
|
}): Promise<PostMlsMessageResponse | null | undefined>;
|
|
77
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Will send a removal commit for given clients
|
|
81
|
+
* @param groupId groupId of the conversation
|
|
82
|
+
* @param clientIds the list of **qualified** ids of the clients we want to remove from the group
|
|
83
|
+
*/
|
|
84
|
+
removeClientsFromConversation(groupId: string, clientIds: string[]): Promise<PostMlsMessageResponse | null>;
|
|
78
85
|
private commitProposals;
|
|
79
86
|
conversationExists(groupId: string): Promise<boolean>;
|
|
80
87
|
clientValidKeypackagesCount(): Promise<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MLSService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,sBAAsB,EAAqB,MAAM,sCAAsC,CAAC;AAChG,OAAO,EAAC,eAAe,EAAC,MAAM,sDAAsD,CAAC;AACrF,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EACL,eAAe,EAGf,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAC,gBAAgB,EAAsB,MAAM,oBAAoB,CAAC;AAKzE,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAKrD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAqB,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAC,4BAA4B,EAAE,4BAA4B,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;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AC,MAAM,CAAC;IAI9C,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAI9E;;;;OAIG;YACW,gBAAgB;IAgB9B,OAAO,CAAC,sCAAsC;IAI9C;;;OAGG;IACI,uBAAuB,CAAC,OAAO,EAAE,MAAM;IAK9C;;;OAGG;IACI,0BAA0B,CAAC,OAAO,EAAE,MAAM;IAUjD;;;OAGG;IACI,0BAA0B;IASjC;;;OAGG;IACI,8BAA8B;YAQvB,eAAe;IAmB7B;;;;;OAKG;YACW,mBAAmB;YAMnB,oBAAoB;IAOrB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhD,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,YAAY,CAAC,GAAG,kBAAkB;IAO5F;;;;;OAKG;IACU,4BAA4B,CACvC,uBAAuB,EAAE,WAAW,EACpC,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,MAAM,CAAC;IAYlB;;;;;;;OAOG;IACU,sBAAsB,CAAC,EAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAC,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"}
|
|
@@ -65,15 +65,16 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
65
65
|
this.apiClient = apiClient;
|
|
66
66
|
this.coreCryptoClient = coreCryptoClient;
|
|
67
67
|
this.logger = (0, logdown_1.default)('@wireapp/core/MLSService');
|
|
68
|
+
this.textEncoder = new TextEncoder();
|
|
69
|
+
this.textDecoder = new TextDecoder();
|
|
68
70
|
this.config = {
|
|
69
71
|
keyingMaterialUpdateThreshold,
|
|
70
72
|
nbKeyPackages,
|
|
71
73
|
};
|
|
72
74
|
}
|
|
73
75
|
async initClient(userId, clientId) {
|
|
74
|
-
const encoder = new TextEncoder();
|
|
75
76
|
const qualifiedClientId = (0, fullyQualifiedClientIdUtils_1.constructFullyQualifiedClientId)(userId.id, clientId, userId.domain);
|
|
76
|
-
await this.coreCryptoClient.mlsInit(
|
|
77
|
+
await this.coreCryptoClient.mlsInit(this.textEncoder.encode(qualifiedClientId));
|
|
77
78
|
}
|
|
78
79
|
async createClient(userId, clientId) {
|
|
79
80
|
await this.initClient(userId, clientId);
|
|
@@ -123,10 +124,9 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
123
124
|
configureMLSCallbacks(_a) {
|
|
124
125
|
var { groupIdFromConversationId } = _a, coreCryptoCallbacks = __rest(_a, ["groupIdFromConversationId"]);
|
|
125
126
|
this.coreCryptoClient.registerCallbacks(Object.assign(Object.assign({}, coreCryptoCallbacks), { clientIsExistingGroupUser: (client, otherClients) => {
|
|
126
|
-
const
|
|
127
|
-
const { user } = (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(decoder.decode(client));
|
|
127
|
+
const { user } = (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(this.textDecoder.decode(client));
|
|
128
128
|
return otherClients.some(client => {
|
|
129
|
-
const { user: otherUser } = (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(
|
|
129
|
+
const { user: otherUser } = (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(this.textDecoder.decode(client));
|
|
130
130
|
return otherUser.toLowerCase() === user.toLowerCase();
|
|
131
131
|
});
|
|
132
132
|
} }));
|
|
@@ -284,8 +284,14 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
284
284
|
this.scheduleKeyMaterialRenewal(groupId);
|
|
285
285
|
return response;
|
|
286
286
|
}
|
|
287
|
-
|
|
288
|
-
|
|
287
|
+
/**
|
|
288
|
+
* Will send a removal commit for given clients
|
|
289
|
+
* @param groupId groupId of the conversation
|
|
290
|
+
* @param clientIds the list of **qualified** ids of the clients we want to remove from the group
|
|
291
|
+
*/
|
|
292
|
+
removeClientsFromConversation(groupId, clientIds) {
|
|
293
|
+
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
294
|
+
return this.processCommitAction(groupIdBytes, () => this.coreCryptoClient.removeClientsFromConversation(groupIdBytes, clientIds.map(id => this.textEncoder.encode(id))));
|
|
289
295
|
}
|
|
290
296
|
async commitProposals(groupId) {
|
|
291
297
|
const commitBundle = await this.coreCryptoClient.commitPendingProposals(groupId);
|
|
@@ -493,10 +499,9 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
493
499
|
*/
|
|
494
500
|
async getClientIds(groupId) {
|
|
495
501
|
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
496
|
-
const decoder = new TextDecoder();
|
|
497
502
|
const rawClientIds = await this.coreCryptoClient.getClientIds(groupIdBytes);
|
|
498
503
|
const clientIds = rawClientIds.map(id => {
|
|
499
|
-
const { user, client, domain } = (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(
|
|
504
|
+
const { user, client, domain } = (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(this.textDecoder.decode(id));
|
|
500
505
|
return { userId: user, clientId: client, domain };
|
|
501
506
|
});
|
|
502
507
|
return clientIds;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { APIClient } from '@wireapp/api-client';
|
|
2
|
-
import {
|
|
2
|
+
import { CryptoClient } from './CryptoClient';
|
|
3
3
|
import { ProteusService } from './ProteusService';
|
|
4
4
|
export declare const buildProteusService: (federated?: boolean) => Promise<[ProteusService, {
|
|
5
5
|
apiClient: APIClient;
|
|
6
|
-
|
|
6
|
+
cryptoClient: CryptoClient;
|
|
7
7
|
}]>;
|
|
8
8
|
//# sourceMappingURL=ProteusService.mocks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProteusService.mocks.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.mocks.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"ProteusService.mocks.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.mocks.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAIhD,eAAO,MAAM,mBAAmB;eAEQ,SAAS;kBAAgB,YAAY;GAgB5E,CAAC"}
|
|
@@ -21,7 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
exports.buildProteusService = void 0;
|
|
22
22
|
const client_1 = require("@wireapp/api-client/lib/client");
|
|
23
23
|
const api_client_1 = require("@wireapp/api-client");
|
|
24
|
-
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
25
24
|
const CoreCryptoWrapper_1 = require("./CryptoClient/CoreCryptoWrapper");
|
|
26
25
|
const ProteusService_1 = require("./ProteusService");
|
|
27
26
|
const PayloadHelper_1 = require("../../../test/PayloadHelper");
|
|
@@ -32,11 +31,11 @@ const buildProteusService = async (federated = false) => {
|
|
|
32
31
|
userId: (0, PayloadHelper_1.getUUID)(),
|
|
33
32
|
clientId: (0, PayloadHelper_1.getUUID)(),
|
|
34
33
|
};
|
|
35
|
-
const
|
|
36
|
-
const proteusService = new ProteusService_1.ProteusService(apiClient,
|
|
34
|
+
const cryptoClient = new CoreCryptoWrapper_1.CoreCryptoWrapper({}, {}, {});
|
|
35
|
+
const proteusService = new ProteusService_1.ProteusService(apiClient, cryptoClient, {
|
|
37
36
|
nbPrekeys: 0,
|
|
38
37
|
useQualifiedIds: federated,
|
|
39
38
|
});
|
|
40
|
-
return [proteusService, { apiClient,
|
|
39
|
+
return [proteusService, { apiClient, cryptoClient }];
|
|
41
40
|
};
|
|
42
41
|
exports.buildProteusService = buildProteusService;
|
|
@@ -65,7 +65,7 @@ jest.mock('./CryptoClient/PrekeysTracker', () => {
|
|
|
65
65
|
jest.mock('../Utility/Recipients', () => (Object.assign(Object.assign({}, jest.requireActual('../Utility/Recipients')), { getRecipientsForConversation: jest.fn(), getQualifiedRecipientsForConversation: jest.fn() })));
|
|
66
66
|
const MockedRecipients = Recipients;
|
|
67
67
|
const prepareDataForEncryption = async (useQualifiedIds = true) => {
|
|
68
|
-
const [proteusService, {
|
|
68
|
+
const [proteusService, { cryptoClient, apiClient }] = await (0, ProteusService_mocks_1.buildProteusService)(useQualifiedIds);
|
|
69
69
|
const domain = 'staging.zinfra.io';
|
|
70
70
|
//user 1
|
|
71
71
|
const firstUserId = 'bc0c99f1-49a5-4ad2-889a-62885af37088';
|
|
@@ -88,7 +88,7 @@ const prepareDataForEncryption = async (useQualifiedIds = true) => {
|
|
|
88
88
|
//user 2
|
|
89
89
|
const secondUserId = 'cd0c88f1-49a5-4ar2-889a-62885af37069';
|
|
90
90
|
//user 2 client
|
|
91
|
-
const thirdClientId = '
|
|
91
|
+
const thirdClientId = 'ce67218b77d02d69';
|
|
92
92
|
//user 2 sessions
|
|
93
93
|
const secondClientSessionId = (0, SessionHandler_1.constructSessionId)({
|
|
94
94
|
userId: secondUserId,
|
|
@@ -107,7 +107,7 @@ const prepareDataForEncryption = async (useQualifiedIds = true) => {
|
|
|
107
107
|
key: 'pQABARn//wKhAFggJ1Fbpg5l6wnzKOJE+vXpRnkqUYhIvVnR5lNXEbO2o/0DoQChAFggHxZvgvtDktY/vqBcpjjo6rQnXvcNQhfwmy8AJQJKlD0E9g==',
|
|
108
108
|
};
|
|
109
109
|
return {
|
|
110
|
-
services: { proteusService, apiClient,
|
|
110
|
+
services: { proteusService, apiClient, cryptoClient },
|
|
111
111
|
data: {
|
|
112
112
|
firstUser: {
|
|
113
113
|
id: firstUserId,
|
|
@@ -130,29 +130,35 @@ const prepareDataForEncryption = async (useQualifiedIds = true) => {
|
|
|
130
130
|
describe('ProteusService', () => {
|
|
131
131
|
describe('getRemoteFingerprint', () => {
|
|
132
132
|
it('create a session if session does not exists', async () => {
|
|
133
|
-
const [proteusService, { apiClient,
|
|
133
|
+
const [proteusService, { apiClient, cryptoClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
|
|
134
134
|
const expectedFingerprint = 'fingerprint-client1';
|
|
135
|
-
const getPrekeyMock = jest.spyOn(apiClient.api.user, 'getClientPreKey').mockResolvedValue({
|
|
136
|
-
client: 'client1',
|
|
137
|
-
prekey: {
|
|
138
|
-
id: 123,
|
|
139
|
-
key: 'pQABARhIAqEAWCCaJpFa9c626ORmjj1aV6OnOYgmTjfoiE3ynOfNfGAOmgOhAKEAWCD60VMzRrLfO+1GSjgyhnVp2N7L58DM+eeJhZJi1tBLfQT2',
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
jest.spyOn(coreCrypto, 'proteusFingerprintRemote').mockResolvedValue(expectedFingerprint);
|
|
143
|
-
jest.spyOn(coreCrypto, 'proteusSessionExists').mockResolvedValue(false);
|
|
144
135
|
const userId = { id: 'user1', domain: 'domain.com' };
|
|
145
136
|
const clientId = 'client1';
|
|
137
|
+
jest.spyOn(apiClient.api.user, 'postQualifiedMultiPreKeyBundles').mockResolvedValue({
|
|
138
|
+
[userId.domain]: {
|
|
139
|
+
[userId.id]: {
|
|
140
|
+
[clientId]: {
|
|
141
|
+
id: 123,
|
|
142
|
+
key: 'pQABARhIAqEAWCCaJpFa9c626ORmjj1aV6OnOYgmTjfoiE3ynOfNfGAOmgOhAKEAWCD60VMzRrLfO+1GSjgyhnVp2N7L58DM+eeJhZJi1tBLfQT2',
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
jest.spyOn(cryptoClient, 'getRemoteFingerprint').mockResolvedValue(expectedFingerprint);
|
|
148
|
+
jest.spyOn(cryptoClient, 'sessionFromPrekey').mockResolvedValue(undefined);
|
|
149
|
+
jest.spyOn(cryptoClient, 'saveSession').mockResolvedValue(undefined);
|
|
150
|
+
jest.spyOn(cryptoClient, 'sessionExists').mockResolvedValue(false);
|
|
146
151
|
const result = await proteusService.getRemoteFingerprint(userId, clientId);
|
|
147
|
-
expect(getPrekeyMock).toHaveBeenCalledWith(userId, clientId);
|
|
148
152
|
expect(result).toBe(expectedFingerprint);
|
|
149
153
|
});
|
|
150
154
|
it('create a session from given prekey if session does not exists', async () => {
|
|
151
|
-
const [proteusService, { apiClient,
|
|
155
|
+
const [proteusService, { apiClient, cryptoClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
|
|
152
156
|
const expectedFingerprint = 'fingerprint-client1';
|
|
153
157
|
const getPrekeyMock = jest.spyOn(apiClient.api.user, 'getClientPreKey');
|
|
154
|
-
jest.spyOn(
|
|
155
|
-
jest.spyOn(
|
|
158
|
+
jest.spyOn(cryptoClient, 'getRemoteFingerprint').mockResolvedValue(expectedFingerprint);
|
|
159
|
+
jest.spyOn(cryptoClient, 'sessionFromPrekey').mockResolvedValue(undefined);
|
|
160
|
+
jest.spyOn(cryptoClient, 'saveSession').mockResolvedValue(undefined);
|
|
161
|
+
jest.spyOn(cryptoClient, 'sessionExists').mockResolvedValue(false);
|
|
156
162
|
const userId = { id: 'user1', domain: 'domain.com' };
|
|
157
163
|
const clientId = 'client1';
|
|
158
164
|
const result = await proteusService.getRemoteFingerprint(userId, clientId, {
|
|
@@ -163,12 +169,12 @@ describe('ProteusService', () => {
|
|
|
163
169
|
expect(result).toBe(expectedFingerprint);
|
|
164
170
|
});
|
|
165
171
|
it('returns the fingerprint from existing session', async () => {
|
|
166
|
-
const [proteusService, { apiClient,
|
|
172
|
+
const [proteusService, { apiClient, cryptoClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
|
|
167
173
|
const expectedFingerprint = 'fingerprint-client1';
|
|
168
174
|
const getPrekeyMock = jest.spyOn(apiClient.api.user, 'getClientPreKey');
|
|
169
|
-
const sessionFromPrekeyMock = jest.spyOn(
|
|
170
|
-
jest.spyOn(
|
|
171
|
-
jest.spyOn(
|
|
175
|
+
const sessionFromPrekeyMock = jest.spyOn(cryptoClient, 'sessionFromPrekey');
|
|
176
|
+
jest.spyOn(cryptoClient, 'getRemoteFingerprint').mockResolvedValue(expectedFingerprint);
|
|
177
|
+
jest.spyOn(cryptoClient, 'sessionExists').mockResolvedValue(true);
|
|
172
178
|
const userId = { id: 'user1', domain: 'domain.com' };
|
|
173
179
|
const clientId = 'client1';
|
|
174
180
|
const result = await proteusService.getRemoteFingerprint(userId, clientId);
|
|
@@ -188,9 +194,10 @@ describe('ProteusService', () => {
|
|
|
188
194
|
};
|
|
189
195
|
const decryptedMessage = {};
|
|
190
196
|
it('decrypts incoming proteus encrypted events when session already exists', async () => {
|
|
191
|
-
const [proteusService, {
|
|
192
|
-
jest.spyOn(
|
|
193
|
-
const createSessionSpy = jest.spyOn(
|
|
197
|
+
const [proteusService, { cryptoClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
|
|
198
|
+
jest.spyOn(cryptoClient, 'sessionExists').mockResolvedValue(true);
|
|
199
|
+
const createSessionSpy = jest.spyOn(cryptoClient, 'sessionFromMessage');
|
|
200
|
+
jest.spyOn(cryptoClient, 'decrypt').mockResolvedValue(new Uint8Array());
|
|
194
201
|
jest.spyOn(protocol_messaging_1.GenericMessage, 'decode').mockReturnValue(decryptedMessage);
|
|
195
202
|
const result = await proteusService.handleEvent(eventPayload);
|
|
196
203
|
expect(result).toBeDefined();
|
|
@@ -198,10 +205,11 @@ describe('ProteusService', () => {
|
|
|
198
205
|
expect(result === null || result === void 0 ? void 0 : result.decryptedData).toBe(decryptedMessage);
|
|
199
206
|
});
|
|
200
207
|
it('decrypts incoming proteus encrypted and creates session if not already existing', async () => {
|
|
201
|
-
const [proteusService, {
|
|
202
|
-
jest.spyOn(
|
|
203
|
-
|
|
204
|
-
const
|
|
208
|
+
const [proteusService, { cryptoClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
|
|
209
|
+
jest.spyOn(cryptoClient, 'sessionExists').mockResolvedValue(false);
|
|
210
|
+
jest.spyOn(cryptoClient, 'saveSession').mockResolvedValue(undefined);
|
|
211
|
+
const createSessionSpy = jest.spyOn(cryptoClient, 'sessionFromMessage').mockResolvedValue(new Uint8Array());
|
|
212
|
+
const decryptSpy = jest.spyOn(cryptoClient, 'decrypt');
|
|
205
213
|
jest.spyOn(protocol_messaging_1.GenericMessage, 'decode').mockReturnValue(decryptedMessage);
|
|
206
214
|
const result = await proteusService.handleEvent(eventPayload);
|
|
207
215
|
expect(result).toBeDefined();
|
|
@@ -212,28 +220,18 @@ describe('ProteusService', () => {
|
|
|
212
220
|
});
|
|
213
221
|
describe('"encrypt"', () => {
|
|
214
222
|
it('returns encrypted payload', async () => {
|
|
215
|
-
const { services, data: { firstUser,
|
|
223
|
+
const { services, data: { firstUser, encryptedMessageBuffer, messageBuffer }, } = await prepareDataForEncryption(false);
|
|
216
224
|
const userClients = {
|
|
217
225
|
[firstUser.id]: [firstUser.clients.first, firstUser.clients.second],
|
|
218
226
|
};
|
|
219
|
-
const preKeyBundleMap = {
|
|
220
|
-
[firstUser.id]: {
|
|
221
|
-
[firstUser.clients.first]: validPreKey,
|
|
222
|
-
[firstUser.clients.second]: validPreKey,
|
|
223
|
-
},
|
|
224
|
-
};
|
|
225
227
|
const encryptedPayload = new Map([
|
|
226
228
|
[firstUser.sessions.first, encryptedMessageBuffer],
|
|
227
229
|
[firstUser.sessions.second, encryptedMessageBuffer],
|
|
228
230
|
]);
|
|
229
|
-
jest
|
|
230
|
-
|
|
231
|
-
.mockImplementationOnce(() => Promise.resolve(preKeyBundleMap));
|
|
232
|
-
jest
|
|
233
|
-
.spyOn(services.coreCryptoClient, 'proteusEncryptBatched')
|
|
234
|
-
.mockImplementationOnce(() => Promise.resolve(encryptedPayload));
|
|
231
|
+
jest.spyOn(services.cryptoClient, 'sessionExists').mockResolvedValue(true);
|
|
232
|
+
jest.spyOn(services.cryptoClient, 'encrypt').mockImplementationOnce(() => Promise.resolve(encryptedPayload));
|
|
235
233
|
const encrypted = await services.proteusService.encrypt(messageBuffer, userClients);
|
|
236
|
-
expect(services.
|
|
234
|
+
expect(services.cryptoClient.encrypt).toHaveBeenCalledWith([firstUser.sessions.first, firstUser.sessions.second], messageBuffer);
|
|
237
235
|
expect(encrypted).toEqual({
|
|
238
236
|
[firstUser.id]: {
|
|
239
237
|
[firstUser.clients.first]: encryptedMessageBuffer,
|
|
@@ -242,33 +240,20 @@ describe('ProteusService', () => {
|
|
|
242
240
|
});
|
|
243
241
|
});
|
|
244
242
|
it('returns encrypted payload for multiple users', async () => {
|
|
245
|
-
const { services, data: { firstUser, secondUser,
|
|
243
|
+
const { services, data: { firstUser, secondUser, encryptedMessageBuffer, messageBuffer }, } = await prepareDataForEncryption(false);
|
|
246
244
|
const userClients = {
|
|
247
245
|
[firstUser.id]: [firstUser.clients.first, firstUser.clients.second],
|
|
248
246
|
[secondUser.id]: [secondUser.clients.first],
|
|
249
247
|
};
|
|
250
|
-
const preKeyBundleMap = {
|
|
251
|
-
[firstUser.id]: {
|
|
252
|
-
[firstUser.clients.first]: validPreKey,
|
|
253
|
-
[firstUser.clients.second]: null,
|
|
254
|
-
},
|
|
255
|
-
[secondUser.id]: {
|
|
256
|
-
[secondUser.clients.first]: validPreKey,
|
|
257
|
-
},
|
|
258
|
-
};
|
|
259
248
|
const encryptedPayload = new Map([
|
|
260
249
|
[firstUser.sessions.first, encryptedMessageBuffer],
|
|
261
250
|
[firstUser.sessions.second, encryptedMessageBuffer],
|
|
262
251
|
[secondUser.sessions.first, encryptedMessageBuffer],
|
|
263
252
|
]);
|
|
264
|
-
jest
|
|
265
|
-
|
|
266
|
-
.mockImplementationOnce(() => Promise.resolve(preKeyBundleMap));
|
|
267
|
-
jest
|
|
268
|
-
.spyOn(services.coreCryptoClient, 'proteusEncryptBatched')
|
|
269
|
-
.mockImplementationOnce(() => Promise.resolve(encryptedPayload));
|
|
253
|
+
jest.spyOn(services.cryptoClient, 'sessionExists').mockResolvedValue(true);
|
|
254
|
+
jest.spyOn(services.cryptoClient, 'encrypt').mockResolvedValueOnce(encryptedPayload);
|
|
270
255
|
const encrypted = await services.proteusService.encrypt(messageBuffer, userClients);
|
|
271
|
-
expect(services.
|
|
256
|
+
expect(services.cryptoClient.encrypt).toHaveBeenCalledWith([firstUser.sessions.first, firstUser.sessions.second, secondUser.sessions.first], messageBuffer);
|
|
272
257
|
expect(encrypted).toEqual({
|
|
273
258
|
[firstUser.id]: {
|
|
274
259
|
[firstUser.clients.first]: encryptedMessageBuffer,
|
|
@@ -282,33 +267,21 @@ describe('ProteusService', () => {
|
|
|
282
267
|
});
|
|
283
268
|
describe('"encryptQualified"', () => {
|
|
284
269
|
it('returns encrypted payload', async () => {
|
|
285
|
-
const { services, data: { firstUser,
|
|
270
|
+
const { services, data: { firstUser, encryptedMessageBuffer, messageBuffer, domain }, } = await prepareDataForEncryption();
|
|
286
271
|
const userClients = {
|
|
287
272
|
[domain]: {
|
|
288
273
|
[firstUser.id]: [firstUser.clients.first, firstUser.clients.second],
|
|
289
274
|
},
|
|
290
275
|
};
|
|
291
|
-
const preKeyBundleMap = {
|
|
292
|
-
[domain]: {
|
|
293
|
-
[firstUser.id]: {
|
|
294
|
-
[firstUser.clients.first]: validPreKey,
|
|
295
|
-
[firstUser.clients.second]: validPreKey,
|
|
296
|
-
},
|
|
297
|
-
},
|
|
298
|
-
};
|
|
299
276
|
const encryptedPayload = new Map([
|
|
300
277
|
[firstUser.sessions.first, encryptedMessageBuffer],
|
|
301
278
|
[firstUser.sessions.second, encryptedMessageBuffer],
|
|
302
279
|
]);
|
|
303
|
-
jest
|
|
304
|
-
|
|
305
|
-
.mockImplementationOnce(() => Promise.resolve(preKeyBundleMap));
|
|
306
|
-
jest
|
|
307
|
-
.spyOn(services.coreCryptoClient, 'proteusEncryptBatched')
|
|
308
|
-
.mockImplementationOnce(() => Promise.resolve(encryptedPayload));
|
|
280
|
+
jest.spyOn(services.cryptoClient, 'sessionExists').mockResolvedValue(true);
|
|
281
|
+
jest.spyOn(services.cryptoClient, 'encrypt').mockResolvedValueOnce(encryptedPayload);
|
|
309
282
|
const encrypted = await services.proteusService.encryptQualified(messageBuffer, userClients);
|
|
310
283
|
// console.log({encrypted, missing});
|
|
311
|
-
expect(services.
|
|
284
|
+
expect(services.cryptoClient.encrypt).toHaveBeenCalledWith([firstUser.sessions.first, firstUser.sessions.second], messageBuffer);
|
|
312
285
|
expect(encrypted).toEqual({
|
|
313
286
|
[domain]: {
|
|
314
287
|
[firstUser.id]: {
|
|
@@ -319,40 +292,27 @@ describe('ProteusService', () => {
|
|
|
319
292
|
});
|
|
320
293
|
});
|
|
321
294
|
it('returns missing clients and encrypted payload for multiple users', async () => {
|
|
322
|
-
const { services, data: { firstUser, secondUser,
|
|
295
|
+
const { services, data: { firstUser, secondUser, encryptedMessageBuffer, messageBuffer, domain }, } = await prepareDataForEncryption();
|
|
323
296
|
const userClients = {
|
|
324
297
|
[domain]: {
|
|
325
298
|
[firstUser.id]: [firstUser.clients.first, firstUser.clients.second],
|
|
326
299
|
[secondUser.id]: [secondUser.clients.first],
|
|
327
300
|
},
|
|
328
301
|
};
|
|
329
|
-
const preKeyBundleMap = {
|
|
330
|
-
[domain]: {
|
|
331
|
-
[firstUser.id]: {
|
|
332
|
-
[firstUser.clients.first]: validPreKey,
|
|
333
|
-
[firstUser.clients.second]: null,
|
|
334
|
-
},
|
|
335
|
-
[secondUser.id]: {
|
|
336
|
-
[secondUser.clients.first]: validPreKey,
|
|
337
|
-
},
|
|
338
|
-
},
|
|
339
|
-
};
|
|
340
302
|
const encryptedPayload = new Map([
|
|
341
303
|
[firstUser.sessions.first, encryptedMessageBuffer],
|
|
304
|
+
[firstUser.sessions.second, encryptedMessageBuffer],
|
|
342
305
|
[secondUser.sessions.first, encryptedMessageBuffer],
|
|
343
306
|
]);
|
|
344
|
-
jest
|
|
345
|
-
|
|
346
|
-
.mockImplementationOnce(() => Promise.resolve(preKeyBundleMap));
|
|
347
|
-
jest
|
|
348
|
-
.spyOn(services.coreCryptoClient, 'proteusEncryptBatched')
|
|
349
|
-
.mockImplementationOnce(() => Promise.resolve(encryptedPayload));
|
|
307
|
+
jest.spyOn(services.cryptoClient, 'sessionExists').mockResolvedValue(true);
|
|
308
|
+
jest.spyOn(services.cryptoClient, 'encrypt').mockResolvedValueOnce(encryptedPayload);
|
|
350
309
|
const encrypted = await services.proteusService.encryptQualified(messageBuffer, userClients);
|
|
351
|
-
expect(services.
|
|
310
|
+
expect(services.cryptoClient.encrypt).toHaveBeenCalledWith([firstUser.sessions.first, firstUser.sessions.second, secondUser.sessions.first], messageBuffer);
|
|
352
311
|
expect(encrypted).toEqual({
|
|
353
312
|
[domain]: {
|
|
354
313
|
[firstUser.id]: {
|
|
355
314
|
[firstUser.clients.first]: encryptedMessageBuffer,
|
|
315
|
+
[firstUser.clients.second]: encryptedMessageBuffer,
|
|
356
316
|
},
|
|
357
317
|
[secondUser.id]: {
|
|
358
318
|
[secondUser.clients.first]: encryptedMessageBuffer,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionHandler.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAC,WAAW,EAAC,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AAE9E,OAAO,EAAC,MAAM,EAAC,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAK9C,OAAO,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAE/D,UAAU,wBAAwB;IAChC,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,kBAAkB,kDAAiD,wBAAwB,KAAG,MAKnG,CAAC;
|
|
1
|
+
{"version":3,"file":"SessionHandler.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAC,WAAW,EAAC,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AAE9E,OAAO,EAAC,MAAM,EAAC,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAK9C,OAAO,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAE/D,UAAU,wBAAwB;IAChC,MAAM,EAAE,MAAM,GAAG,WAAW,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,kBAAkB,kDAAiD,wBAAwB,KAAG,MAKnG,CAAC;AAuFF;;;GAGG;AACH,QAAA,MAAM,WAAW;YAC6B,WAAW;cAAY,MAAM;;;eAClC,SAAS;kBAAgB,YAAY;MAC3E,QAAQ,MAAM,CAmBhB,CAAC;AAyBF,UAAU,wCAAwC;IAChD,UAAU,EAAE,WAAW,GAAG,mBAAmB,CAAC;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,QAAA,MAAM,YAAY,6DAMf,wCAAwC,KAAG,QAAQ,MAAM,EAAE,CAgC7D,CAAC;AAEF,UAAU,mBAAmB;IAC3B,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;CAC1B;AACD,iBAAe,aAAa,CAAC,MAAM,EAAE,mBAAmB,iBAGvD;AA+CD,KAAK,iBAAiB,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9D;;GAEG;AACH,QAAA,MAAM,sBAAsB,uDAO3B,CAAC;AAEF,OAAO,EAAC,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAC,CAAC"}
|
|
@@ -43,13 +43,6 @@ const parseSessionId = (sessionId) => {
|
|
|
43
43
|
}
|
|
44
44
|
return match.groups;
|
|
45
45
|
};
|
|
46
|
-
const createSession = async ({ sessionId, initialPrekey, cryptoClient, apiClient, }) => {
|
|
47
|
-
const { userId, clientId, domain } = parseSessionId(sessionId);
|
|
48
|
-
const prekey = initialPrekey !== null && initialPrekey !== void 0 ? initialPrekey : (await apiClient.api.user.getClientPreKey({ id: userId, domain: domain !== null && domain !== void 0 ? domain : '' }, clientId)).prekey;
|
|
49
|
-
const prekeyBuffer = bazinga64_1.Decoder.fromBase64(prekey.key).asBytes;
|
|
50
|
-
await cryptoClient.sessionFromPrekey(sessionId, prekeyBuffer);
|
|
51
|
-
await cryptoClient.saveSession(sessionId);
|
|
52
|
-
};
|
|
53
46
|
const createLegacySessions = async ({ userClients, apiClient, cryptoClient, logger, }) => {
|
|
54
47
|
const preKeyBundleMap = await apiClient.api.user.postMultiPreKeyBundles(userClients);
|
|
55
48
|
const sessions = await createSessionsFromPreKeys({
|
|
@@ -87,15 +80,22 @@ const createQualifiedSessions = async ({ userClientMap, domain, apiClient, crypt
|
|
|
87
80
|
const initSession = async ({ userId, clientId, initialPrekey }, { cryptoClient, apiClient }) => {
|
|
88
81
|
const sessionId = constructSessionId({ userId, clientId, useQualifiedIds: !!userId.domain });
|
|
89
82
|
const sessionExists = await cryptoClient.sessionExists(sessionId);
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
83
|
+
if (sessionExists) {
|
|
84
|
+
return sessionId;
|
|
85
|
+
}
|
|
86
|
+
if (initialPrekey) {
|
|
87
|
+
const prekeyBuffer = bazinga64_1.Decoder.fromBase64(initialPrekey.key).asBytes;
|
|
88
|
+
await cryptoClient.sessionFromPrekey(sessionId, prekeyBuffer);
|
|
89
|
+
await cryptoClient.saveSession(sessionId);
|
|
90
|
+
return sessionId;
|
|
97
91
|
}
|
|
98
|
-
|
|
92
|
+
const sessions = await initSessions({
|
|
93
|
+
recipients: { [userId.id]: [clientId] },
|
|
94
|
+
domain: userId.domain,
|
|
95
|
+
apiClient,
|
|
96
|
+
cryptoClient,
|
|
97
|
+
});
|
|
98
|
+
return sessions[0];
|
|
99
99
|
};
|
|
100
100
|
exports.initSession = initSession;
|
|
101
101
|
/**
|
|
@@ -18,10 +18,28 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
const api_client_1 = require("@wireapp/api-client");
|
|
21
22
|
const SessionHandler_1 = require("./SessionHandler");
|
|
22
|
-
|
|
23
|
-
const
|
|
23
|
+
function generatePrekeys(userId, clientIds) {
|
|
24
|
+
const clients = clientIds.reduce((prekeys, clientId, index) => {
|
|
25
|
+
return Object.assign(Object.assign({}, prekeys), { [clientId]: {
|
|
26
|
+
id: index,
|
|
27
|
+
key: 'pQABARn//wKhAFggJ1Fbpg5l6wnzKOJE+vXpRnkqUYhIvVnR5lNXEbO2o/0DoQChAFggHxZvgvtDktY/vqBcpjjo6rQnXvcNQhfwmy8AJQJKlD0E9g==',
|
|
28
|
+
} });
|
|
29
|
+
}, {});
|
|
30
|
+
return {
|
|
31
|
+
[userId.id]: Object.assign({}, clients),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
24
34
|
describe('SessionHandler', () => {
|
|
35
|
+
const cryptoClient = {
|
|
36
|
+
sessionFromMessage: jest.fn(),
|
|
37
|
+
sessionFromPrekey: jest.fn(),
|
|
38
|
+
sessionExists: jest.fn(),
|
|
39
|
+
saveSession: jest.fn(),
|
|
40
|
+
deleteSession: jest.fn(),
|
|
41
|
+
};
|
|
42
|
+
const apiClient = new api_client_1.APIClient({ urls: api_client_1.APIClient.BACKEND.STAGING });
|
|
25
43
|
describe('constructSessionId', () => {
|
|
26
44
|
describe('constructs a session ID', () => {
|
|
27
45
|
it('without a domain', () => {
|
|
@@ -66,35 +84,42 @@ describe('SessionHandler', () => {
|
|
|
66
84
|
});
|
|
67
85
|
describe('initSession', () => {
|
|
68
86
|
it('only returns sessions that already exists', async () => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
await (0, SessionHandler_1.initSession)({ userId: { id: 'user1', domain: 'domain' }, clientId: 'client1' }, { apiClient, cryptoClient: new CoreCryptoWrapper_1.CoreCryptoWrapper(coreCrypto, {}, {}) });
|
|
73
|
-
expect(sessionFromPrekeySpy).not.toHaveBeenCalled();
|
|
87
|
+
jest.spyOn(cryptoClient, 'sessionExists').mockResolvedValue(true);
|
|
88
|
+
await (0, SessionHandler_1.initSession)({ userId: { id: 'user1', domain: 'domain' }, clientId: 'client1' }, { apiClient, cryptoClient });
|
|
89
|
+
expect(cryptoClient.sessionFromPrekey).not.toHaveBeenCalled();
|
|
74
90
|
});
|
|
75
91
|
it('creates the session if it does not already exist', async () => {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
jest.spyOn(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
92
|
+
const userId = { id: 'user1', domain: 'domain' };
|
|
93
|
+
const clientId = 'client1';
|
|
94
|
+
jest.spyOn(cryptoClient, 'sessionExists').mockResolvedValue(false);
|
|
95
|
+
jest
|
|
96
|
+
.spyOn(apiClient.api.user, 'postQualifiedMultiPreKeyBundles')
|
|
97
|
+
.mockResolvedValue({ domain: generatePrekeys(userId, [clientId]) });
|
|
98
|
+
const sessionId = (0, SessionHandler_1.constructSessionId)({
|
|
99
|
+
userId,
|
|
100
|
+
clientId,
|
|
101
|
+
useQualifiedIds: true,
|
|
84
102
|
});
|
|
103
|
+
await (0, SessionHandler_1.initSession)({ userId, clientId }, { apiClient, cryptoClient });
|
|
104
|
+
expect(cryptoClient.sessionFromPrekey).toHaveBeenCalledWith(sessionId, expect.any(Object));
|
|
105
|
+
});
|
|
106
|
+
it('indicates the consumer if a session could not be created', async () => {
|
|
107
|
+
const userId = { id: 'user1', domain: 'domain' };
|
|
108
|
+
const clientId = 'client1';
|
|
109
|
+
jest
|
|
110
|
+
.spyOn(apiClient.api.user, 'postQualifiedMultiPreKeyBundles')
|
|
111
|
+
.mockResolvedValue({ domain: generatePrekeys(userId, [clientId]) });
|
|
85
112
|
const sessionId = (0, SessionHandler_1.constructSessionId)({
|
|
86
|
-
userId
|
|
87
|
-
clientId
|
|
113
|
+
userId,
|
|
114
|
+
clientId,
|
|
88
115
|
useQualifiedIds: true,
|
|
89
116
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
expect(sessionFromPrekeySpy).toHaveBeenCalledWith(sessionId, expect.any(Object));
|
|
117
|
+
await (0, SessionHandler_1.initSession)({ userId, clientId }, { apiClient, cryptoClient });
|
|
118
|
+
expect(cryptoClient.sessionFromPrekey).toHaveBeenCalledWith(sessionId, expect.any(Object));
|
|
93
119
|
});
|
|
94
120
|
});
|
|
95
121
|
describe('initSessions', () => {
|
|
96
122
|
it('creates new sessions only for sessions that are missing', async () => {
|
|
97
|
-
const { apiClient, coreCrypto } = (await (0, ProteusService_mocks_1.buildProteusService)())[1];
|
|
98
123
|
const existingUserClients = {
|
|
99
124
|
'existing-user1': ['client1'],
|
|
100
125
|
'existing-user2': ['client1', 'client2'],
|
|
@@ -104,32 +129,15 @@ describe('SessionHandler', () => {
|
|
|
104
129
|
'missing-user2': ['client1', 'client2'],
|
|
105
130
|
};
|
|
106
131
|
jest.spyOn(apiClient.api.user, 'postQualifiedMultiPreKeyBundles').mockResolvedValue({});
|
|
107
|
-
jest.spyOn(apiClient.api.user, 'postMultiPreKeyBundles').mockResolvedValue({
|
|
108
|
-
'missing-user1': {
|
|
109
|
-
client1: {
|
|
110
|
-
id: 1,
|
|
111
|
-
key: 'pQABARn//wKhAFggJ1Fbpg5l6wnzKOJE+vXpRnkqUYhIvVnR5lNXEbO2o/0DoQChAFggHxZvgvtDktY/vqBcpjjo6rQnXvcNQhfwmy8AJQJKlD0E9g==',
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
'missing-user2': {
|
|
115
|
-
client1: {
|
|
116
|
-
id: 1,
|
|
117
|
-
key: 'pQABARn//wKhAFggJ1Fbpg5l6wnzKOJE+vXpRnkqUYhIvVnR5lNXEbO2o/0DoQChAFggHxZvgvtDktY/vqBcpjjo6rQnXvcNQhfwmy8AJQJKlD0E9g==',
|
|
118
|
-
},
|
|
119
|
-
client2: {
|
|
120
|
-
id: 1,
|
|
121
|
-
key: 'pQABARn//wKhAFggJ1Fbpg5l6wnzKOJE+vXpRnkqUYhIvVnR5lNXEbO2o/0DoQChAFggHxZvgvtDktY/vqBcpjjo6rQnXvcNQhfwmy8AJQJKlD0E9g==',
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
});
|
|
132
|
+
jest.spyOn(apiClient.api.user, 'postMultiPreKeyBundles').mockResolvedValue(Object.assign(Object.assign({}, generatePrekeys({ id: 'missing-user1', domain: '' }, ['client1'])), generatePrekeys({ id: 'missing-user2', domain: '' }, ['client1', 'client2'])));
|
|
125
133
|
jest
|
|
126
|
-
.spyOn(
|
|
134
|
+
.spyOn(cryptoClient, 'sessionExists')
|
|
127
135
|
.mockImplementation(sessionId => Promise.resolve(sessionId.includes('missing')));
|
|
128
|
-
const sessionFromPrekeySpy = jest.spyOn(
|
|
136
|
+
const sessionFromPrekeySpy = jest.spyOn(cryptoClient, 'sessionFromPrekey');
|
|
129
137
|
const sessions = await (0, SessionHandler_1.initSessions)({
|
|
130
138
|
recipients: Object.assign(Object.assign({}, existingUserClients), missingUserClients),
|
|
131
139
|
apiClient,
|
|
132
|
-
cryptoClient
|
|
140
|
+
cryptoClient,
|
|
133
141
|
});
|
|
134
142
|
expect(sessionFromPrekeySpy).toHaveBeenCalledTimes(3);
|
|
135
143
|
expect(sessions).toHaveLength(6);
|
|
@@ -9,6 +9,6 @@ export declare const parseFullQualifiedClientId: (qualifiedId: string) => {
|
|
|
9
9
|
client: ClientId;
|
|
10
10
|
domain: Domain;
|
|
11
11
|
};
|
|
12
|
-
export declare const mapQualifiedUserClientIdsToFullyQualifiedClientIds: (qualifiedUserMap: QualifiedUserClientMap) =>
|
|
12
|
+
export declare const mapQualifiedUserClientIdsToFullyQualifiedClientIds: (qualifiedUserMap: QualifiedUserClientMap) => `${string}:${string}@${string}`[];
|
|
13
13
|
export {};
|
|
14
14
|
//# sourceMappingURL=fullyQualifiedClientIdUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fullyQualifiedClientIdUtils.d.ts","sourceRoot":"","sources":["../../src/util/fullyQualifiedClientIdUtils.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAC;AAEtE,KAAK,MAAM,GAAG,MAAM,CAAC;AACrB,KAAK,QAAQ,GAAG,MAAM,CAAC;AACvB,KAAK,MAAM,GAAG,MAAM,CAAC;AACrB,MAAM,MAAM,kBAAkB,GAAG,GAAG,MAAM,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;AAEnE,eAAO,MAAM,+BAA+B,WAClC,MAAM,YACJ,QAAQ,UACV,MAAM,KACb,kBAAuD,CAAC;AAE3D,eAAO,MAAM,0BAA0B,gBAAiB,MAAM;UAAU,MAAM;YAAU,QAAQ;YAAU,MAAM;CAO/G,CAAC;AAEF,eAAO,MAAM,kDAAkD,qBAAsB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"fullyQualifiedClientIdUtils.d.ts","sourceRoot":"","sources":["../../src/util/fullyQualifiedClientIdUtils.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAC;AAEtE,KAAK,MAAM,GAAG,MAAM,CAAC;AACrB,KAAK,QAAQ,GAAG,MAAM,CAAC;AACvB,KAAK,MAAM,GAAG,MAAM,CAAC;AACrB,MAAM,MAAM,kBAAkB,GAAG,GAAG,MAAM,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;AAEnE,eAAO,MAAM,+BAA+B,WAClC,MAAM,YACJ,QAAQ,UACV,MAAM,KACb,kBAAuD,CAAC;AAE3D,eAAO,MAAM,0BAA0B,gBAAiB,MAAM;UAAU,MAAM;YAAU,QAAQ;YAAU,MAAM;CAO/G,CAAC;AAEF,eAAO,MAAM,kDAAkD,qBAAsB,sBAAsB,sCAO1G,CAAC"}
|
|
@@ -32,10 +32,9 @@ const parseFullQualifiedClientId = (qualifiedId) => {
|
|
|
32
32
|
};
|
|
33
33
|
exports.parseFullQualifiedClientId = parseFullQualifiedClientId;
|
|
34
34
|
const mapQualifiedUserClientIdsToFullyQualifiedClientIds = (qualifiedUserMap) => {
|
|
35
|
-
const encoder = new TextEncoder();
|
|
36
35
|
return Object.entries(qualifiedUserMap).flatMap(([domain, users]) => {
|
|
37
36
|
const clients = Object.entries(users);
|
|
38
|
-
return clients.flatMap(([userId, clients]) => clients.map(client =>
|
|
37
|
+
return clients.flatMap(([userId, clients]) => clients.map(client => (0, exports.constructFullyQualifiedClientId)(userId, client.id, domain)));
|
|
39
38
|
});
|
|
40
39
|
};
|
|
41
40
|
exports.mapQualifiedUserClientIdsToFullyQualifiedClientIds = mapQualifiedUserClientIdsToFullyQualifiedClientIds;
|
|
@@ -36,7 +36,6 @@ var MOCKED_CLIENT_IDS;
|
|
|
36
36
|
MOCKED_CLIENT_IDS["CLIENT2"] = "4130002c222";
|
|
37
37
|
MOCKED_CLIENT_IDS["CLIENT3"] = "4130002c223";
|
|
38
38
|
})(MOCKED_CLIENT_IDS || (MOCKED_CLIENT_IDS = {}));
|
|
39
|
-
const encoder = new TextEncoder();
|
|
40
39
|
describe('constructFullyQualifiedClientId', () => {
|
|
41
40
|
it('construct fullyQualifiedClientId client id', () => {
|
|
42
41
|
expect((0, fullyQualifiedClientIdUtils_1.constructFullyQualifiedClientId)(MOCKED_USER_IDS.USER1, MOCKED_CLIENT_IDS.CLIENT1, MOCKED_DOMAINS.DOMAIN1)).toEqual(`${MOCKED_USER_IDS.USER1}:${MOCKED_CLIENT_IDS.CLIENT1}@${MOCKED_DOMAINS.DOMAIN1}`);
|
|
@@ -67,7 +66,7 @@ describe('mapQualifiedUserClientIdsToFullyQualifiedClientIds', () => {
|
|
|
67
66
|
],
|
|
68
67
|
},
|
|
69
68
|
};
|
|
70
|
-
const expectedResult = [`${MOCKED_USER_IDS.USER1}:${MOCKED_CLIENT_IDS.CLIENT1}@${MOCKED_DOMAINS.DOMAIN1}`]
|
|
69
|
+
const expectedResult = [`${MOCKED_USER_IDS.USER1}:${MOCKED_CLIENT_IDS.CLIENT1}@${MOCKED_DOMAINS.DOMAIN1}`];
|
|
71
70
|
const result = (0, fullyQualifiedClientIdUtils_1.mapQualifiedUserClientIdsToFullyQualifiedClientIds)(qualified_user_map3);
|
|
72
71
|
expect(result).toEqual(expectedResult);
|
|
73
72
|
});
|
|
@@ -98,7 +97,7 @@ describe('mapQualifiedUserClientIdsToFullyQualifiedClientIds', () => {
|
|
|
98
97
|
`${MOCKED_USER_IDS.USER1}:${MOCKED_CLIENT_IDS.CLIENT1}@${MOCKED_DOMAINS.DOMAIN1}`,
|
|
99
98
|
`${MOCKED_USER_IDS.USER1}:${MOCKED_CLIENT_IDS.CLIENT2}@${MOCKED_DOMAINS.DOMAIN2}`,
|
|
100
99
|
`${MOCKED_USER_IDS.USER1}:${MOCKED_CLIENT_IDS.CLIENT3}@${MOCKED_DOMAINS.DOMAIN2}`,
|
|
101
|
-
]
|
|
100
|
+
];
|
|
102
101
|
const result = (0, fullyQualifiedClientIdUtils_1.mapQualifiedUserClientIdsToFullyQualifiedClientIds)(qualified_user_map3);
|
|
103
102
|
expect(result).toEqual(expectedResult);
|
|
104
103
|
});
|
|
@@ -143,7 +142,7 @@ describe('mapQualifiedUserClientIdsToFullyQualifiedClientIds', () => {
|
|
|
143
142
|
`${MOCKED_USER_IDS.USER1}:${MOCKED_CLIENT_IDS.CLIENT2}@${MOCKED_DOMAINS.DOMAIN2}`,
|
|
144
143
|
`${MOCKED_USER_IDS.USER1}:${MOCKED_CLIENT_IDS.CLIENT3}@${MOCKED_DOMAINS.DOMAIN2}`,
|
|
145
144
|
`${MOCKED_USER_IDS.USER2}:${MOCKED_CLIENT_IDS.CLIENT2}@${MOCKED_DOMAINS.DOMAIN2}`,
|
|
146
|
-
]
|
|
145
|
+
];
|
|
147
146
|
const result = (0, fullyQualifiedClientIdUtils_1.mapQualifiedUserClientIdsToFullyQualifiedClientIds)(qualified_user_map3);
|
|
148
147
|
expect(result).toEqual(expectedResult);
|
|
149
148
|
});
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@wireapp/api-client": "^22.15.
|
|
14
|
+
"@wireapp/api-client": "^22.15.1",
|
|
15
15
|
"@wireapp/commons": "^5.0.4",
|
|
16
16
|
"@wireapp/core-crypto": "0.6.0-rc.3",
|
|
17
17
|
"@wireapp/cryptobox": "12.8.0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@wireapp/protocol-messaging": "1.44.0",
|
|
20
20
|
"@wireapp/store-engine": "5.0.3",
|
|
21
21
|
"@wireapp/store-engine-dexie": "^2.0.5",
|
|
22
|
-
"axios": "1.
|
|
22
|
+
"axios": "1.3.0",
|
|
23
23
|
"bazinga64": "6.0.3",
|
|
24
24
|
"hash.js": "1.1.7",
|
|
25
25
|
"http-status-codes": "2.2.0",
|
|
@@ -60,6 +60,6 @@
|
|
|
60
60
|
"test:coverage": "jest --coverage",
|
|
61
61
|
"watch": "tsc --watch"
|
|
62
62
|
},
|
|
63
|
-
"version": "38.8.
|
|
64
|
-
"gitHead": "
|
|
63
|
+
"version": "38.8.3",
|
|
64
|
+
"gitHead": "b37fb8e63a6d258cf0aed3be478fc5411f9bd6fe"
|
|
65
65
|
}
|