@wireapp/core 46.1.0-hotfix-1.5 → 46.1.0-hotfix-1.7
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/README.md +1 -1
- package/lib/Account.d.ts +8 -5
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +141 -321
- package/lib/Account.test.js +9 -9
- package/lib/conversation/AssetService/AssetService.test.js +3 -3
- package/lib/conversation/ConversationService/ConversationService.d.ts +1 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +11 -5
- package/lib/conversation/ConversationService/ConversationService.test.js +6 -9
- package/lib/conversation/SubconversationService/SubconversationService.d.ts +1 -1
- package/lib/conversation/SubconversationService/SubconversationService.d.ts.map +1 -1
- package/lib/conversation/SubconversationService/SubconversationService.js +3 -1
- package/lib/conversation/SubconversationService/SubconversationService.test.js +6 -5
- package/lib/conversation/message/MessageBuilder.js +2 -2
- package/lib/conversation/message/MessageService.test.js +3 -3
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/AcmeService.d.ts +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/schema.d.ts +2 -2
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.js +8 -31
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.js +56 -4
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts +2 -2
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.js +3 -6
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.d.ts +4 -2
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.js +24 -2
- package/lib/messagingProtocols/mls/E2EIdentityService/Steps/OidcChallenge.d.ts +1 -1
- package/lib/messagingProtocols/mls/MLSService/ClientMLSError.d.ts +8 -0
- package/lib/messagingProtocols/mls/MLSService/ClientMLSError.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/MLSService/{MLSService.guards.js → ClientMLSError.js} +12 -7
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +45 -11
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +92 -42
- package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +109 -10
- package/lib/messagingProtocols/mls/MLSService/MLSService.types.d.ts +1 -15
- package/lib/messagingProtocols/mls/MLSService/MLSService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/index.d.ts +1 -0
- package/lib/messagingProtocols/mls/MLSService/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/index.js +1 -0
- package/lib/messagingProtocols/mls/types.d.ts +0 -3
- package/lib/messagingProtocols/mls/types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.js +0 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts +7 -4
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts +1 -1
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts.map +1 -1
- package/lib/test/PayloadHelper.js +2 -2
- package/package.json +3 -3
- package/lib/messagingProtocols/mls/MLSService/MLSService.guards.d.ts +0 -4
- package/lib/messagingProtocols/mls/MLSService/MLSService.guards.d.ts.map +0 -1
package/lib/Account.test.js
CHANGED
|
@@ -53,7 +53,7 @@ const ReconnectingWebsocket_1 = require("@wireapp/api-client/lib/tcp/Reconnectin
|
|
|
53
53
|
const http_status_codes_1 = require("http-status-codes");
|
|
54
54
|
const jest_websocket_mock_1 = require("jest-websocket-mock");
|
|
55
55
|
const nock_1 = __importStar(require("nock"));
|
|
56
|
-
const
|
|
56
|
+
const uuid_1 = require("uuid");
|
|
57
57
|
const api_client_1 = require("@wireapp/api-client");
|
|
58
58
|
const commons_1 = require("@wireapp/commons");
|
|
59
59
|
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
@@ -68,7 +68,7 @@ const MOCK_BACKEND = {
|
|
|
68
68
|
async function createAccount() {
|
|
69
69
|
const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
|
|
70
70
|
const account = new Account_1.Account(apiClient);
|
|
71
|
-
await account
|
|
71
|
+
await account['initServices']({
|
|
72
72
|
clientType: client_1.ClientType.TEMPORARY,
|
|
73
73
|
userId: '',
|
|
74
74
|
});
|
|
@@ -173,7 +173,7 @@ describe('Account', () => {
|
|
|
173
173
|
describe('"init"', () => {
|
|
174
174
|
it('initializes the Protocol buffers', async () => {
|
|
175
175
|
const account = new Account_1.Account();
|
|
176
|
-
await account
|
|
176
|
+
await account['initServices']({ clientType: client_1.ClientType.TEMPORARY, userId: '' });
|
|
177
177
|
expect(account.service.conversation).toBeDefined();
|
|
178
178
|
const message = protocol_messaging_1.GenericMessage.create({
|
|
179
179
|
messageId: '2d7cb6d8-118f-11e8-b642-0ed5f89f718b',
|
|
@@ -186,7 +186,7 @@ describe('Account', () => {
|
|
|
186
186
|
it('logs in with correct credentials', async () => {
|
|
187
187
|
const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
|
|
188
188
|
const account = new Account_1.Account(apiClient);
|
|
189
|
-
await account
|
|
189
|
+
await account['initServices']({ clientType: client_1.ClientType.TEMPORARY, userId: '' });
|
|
190
190
|
const { clientType, userId } = await account.login({
|
|
191
191
|
clientType: client_1.ClientType.TEMPORARY,
|
|
192
192
|
email: 'hello@example.com',
|
|
@@ -199,7 +199,7 @@ describe('Account', () => {
|
|
|
199
199
|
const apiClient = new api_client_1.APIClient({ urls: MOCK_BACKEND });
|
|
200
200
|
const account = new Account_1.Account(apiClient);
|
|
201
201
|
let backendError;
|
|
202
|
-
await account
|
|
202
|
+
await account['initServices']({ clientType: client_1.ClientType.TEMPORARY, userId: '' });
|
|
203
203
|
try {
|
|
204
204
|
await account.login({
|
|
205
205
|
clientType: client_1.ClientType.TEMPORARY,
|
|
@@ -249,7 +249,7 @@ describe('Account', () => {
|
|
|
249
249
|
let dependencies;
|
|
250
250
|
const mockNotifications = (size) => {
|
|
251
251
|
const notifications = Array.from(new Array(size)).map(() => ({
|
|
252
|
-
id: (0,
|
|
252
|
+
id: (0, uuid_1.v4)(),
|
|
253
253
|
payload: [{}],
|
|
254
254
|
}));
|
|
255
255
|
jest.spyOn(dependencies.apiClient.api.notification, 'getAllNotifications').mockResolvedValue({ notifications });
|
|
@@ -347,7 +347,7 @@ describe('Account', () => {
|
|
|
347
347
|
expect(onEvent).toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.NOTIFICATION_STREAM);
|
|
348
348
|
expect(onEvent).not.toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.WEBSOCKET);
|
|
349
349
|
onEvent.mockReset();
|
|
350
|
-
server.send(JSON.stringify({ id: (0,
|
|
350
|
+
server.send(JSON.stringify({ id: (0, uuid_1.v4)(), payload: [{}] }));
|
|
351
351
|
await waitFor(() => expect(onEvent).toHaveBeenCalledTimes(1));
|
|
352
352
|
expect(onEvent).not.toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.NOTIFICATION_STREAM);
|
|
353
353
|
expect(onEvent).toHaveBeenCalledWith(expect.any(Object), notification_2.NotificationSource.WEBSOCKET);
|
|
@@ -371,7 +371,7 @@ describe('Account', () => {
|
|
|
371
371
|
case Account_1.ConnectionState.PROCESSING_NOTIFICATIONS:
|
|
372
372
|
// sending a message as soon as the notificaiton stream starts to process
|
|
373
373
|
// This message should only be forwarded once the notification stream is fully processed
|
|
374
|
-
server.send(JSON.stringify({ id: (0,
|
|
374
|
+
server.send(JSON.stringify({ id: (0, uuid_1.v4)(), payload: [{}] }));
|
|
375
375
|
break;
|
|
376
376
|
case Account_1.ConnectionState.LIVE:
|
|
377
377
|
expect(onNotificationStreamProgress).toHaveBeenCalledTimes(nbNotifications);
|
|
@@ -406,7 +406,7 @@ describe('Account', () => {
|
|
|
406
406
|
case Account_1.ConnectionState.PROCESSING_NOTIFICATIONS:
|
|
407
407
|
// sending a message as soon as the notificaiton stream starts to process
|
|
408
408
|
// This message should only be forwarded once the notification stream is fully processed
|
|
409
|
-
server.send(JSON.stringify({ id: (0,
|
|
409
|
+
server.send(JSON.stringify({ id: (0, uuid_1.v4)(), payload: [{}] }));
|
|
410
410
|
break;
|
|
411
411
|
case Account_1.ConnectionState.LIVE:
|
|
412
412
|
reject(new Error());
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
const
|
|
21
|
+
const uuid_1 = require("uuid");
|
|
22
22
|
const api_client_1 = require("@wireapp/api-client");
|
|
23
23
|
const AssetService_1 = require("./AssetService");
|
|
24
24
|
describe('AssetService', () => {
|
|
@@ -27,8 +27,8 @@ describe('AssetService', () => {
|
|
|
27
27
|
const apiClient = new api_client_1.APIClient();
|
|
28
28
|
const assetService = new AssetService_1.AssetService(apiClient);
|
|
29
29
|
const assetServerData = {
|
|
30
|
-
key: `3-2-${(0,
|
|
31
|
-
token: (0,
|
|
30
|
+
key: `3-2-${(0, uuid_1.v4)()}`,
|
|
31
|
+
token: (0, uuid_1.v4)(),
|
|
32
32
|
expires: '',
|
|
33
33
|
};
|
|
34
34
|
jest.spyOn(apiClient.api.asset, 'postAsset').mockReturnValue({
|
|
@@ -135,7 +135,7 @@ export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
|
135
135
|
* Get a MLS 1:1-conversation with a given user.
|
|
136
136
|
* @param userId - qualified user id
|
|
137
137
|
*/
|
|
138
|
-
getMLS1to1Conversation(userId: QualifiedId): Promise<
|
|
138
|
+
getMLS1to1Conversation(userId: QualifiedId): Promise<import("@wireapp/api-client/lib/conversation").MLS1to1Conversation>;
|
|
139
139
|
/**
|
|
140
140
|
* Will try registering mls 1:1 conversation adding the other user.
|
|
141
141
|
* If it fails and the conversation is already established, it will try joining via external commit instead.
|
|
@@ -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,EACtB,eAAe,EACf,kBAAkB,
|
|
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,EACtB,eAAe,EACf,kBAAkB,EAGnB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,YAAY,EAIZ,4BAA4B,EAE7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAIvD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAEL,cAAc,EAEd,6BAA6B,EAC7B,oBAAoB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5B,UAAU,EAAE,WAAW,CAAC;QACxB,cAAc,EAAE,WAAW,EAAE,CAAC;KAC/B,GAAG,OAAO,CAAC,IAAI,CAAC;YA4BH,wBAAwB;YAsBxB,gCAAgC;YAyBhC,4BAA4B;YA0B5B,wBAAwB;YAIxB,yBAAyB;IAKvC;;;;OAIG;IACU,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAoB3E"}
|
|
@@ -75,7 +75,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
75
75
|
// Before trying to register a group, check if the group is already established o backend.
|
|
76
76
|
// If remote epoch is higher than 0, it means that the group was already established.
|
|
77
77
|
// It's possible that we've already received a welcome message.
|
|
78
|
-
const mlsConversation = await this.getMLS1to1Conversation(otherUserId);
|
|
78
|
+
const { conversation: mlsConversation, public_keys } = await this.getMLS1to1Conversation(otherUserId);
|
|
79
79
|
if (mlsConversation.epoch > 0) {
|
|
80
80
|
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) is already established on backend, checking the local epoch...`);
|
|
81
81
|
const isMLSGroupEstablishedLocally = await this.isMLSGroupEstablishedLocally(groupId);
|
|
@@ -88,15 +88,17 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
88
88
|
// We try joining via external commit.
|
|
89
89
|
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) is not yet established locally, joining via external commit...`);
|
|
90
90
|
await this.joinByExternalCommit(mlsConversation.qualified_id);
|
|
91
|
-
|
|
91
|
+
const { conversation: updatedMLSConversation } = await this.getMLS1to1Conversation(otherUserId);
|
|
92
|
+
return updatedMLSConversation;
|
|
92
93
|
}
|
|
93
94
|
// If group is not established on backend,
|
|
94
95
|
// we wipe the it locally (in case it exsits in the local store) and try to register it.
|
|
95
96
|
await this.mlsService.wipeConversation(groupId);
|
|
96
97
|
try {
|
|
97
|
-
await this.mlsService.
|
|
98
|
+
await this.mlsService.register1to1Conversation(groupId, otherUserId, selfUser, public_keys === null || public_keys === void 0 ? void 0 : public_keys.removal);
|
|
98
99
|
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) established successfully.`);
|
|
99
|
-
|
|
100
|
+
const { conversation: updatedMLSConversation } = await this.getMLS1to1Conversation(otherUserId);
|
|
101
|
+
return updatedMLSConversation;
|
|
100
102
|
}
|
|
101
103
|
catch (error) {
|
|
102
104
|
this.logger.info(`Could not register MLS group with id ${groupId}: `, error);
|
|
@@ -414,7 +416,11 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
414
416
|
* @param userId - qualified user id
|
|
415
417
|
*/
|
|
416
418
|
async getMLS1to1Conversation(userId) {
|
|
417
|
-
|
|
419
|
+
const conversation = await this.apiClient.api.conversation.getMLS1to1Conversation(userId);
|
|
420
|
+
if ((0, conversation_1.isMLS1to1Conversation)(conversation)) {
|
|
421
|
+
return conversation;
|
|
422
|
+
}
|
|
423
|
+
return { conversation };
|
|
418
424
|
}
|
|
419
425
|
/**
|
|
420
426
|
* Will try to register mls group by sending an empty commit to establish it.
|
|
@@ -107,6 +107,7 @@ describe('ConversationService', () => {
|
|
|
107
107
|
getEpoch: () => Promise.resolve(),
|
|
108
108
|
joinByExternalCommit: jest.fn(),
|
|
109
109
|
registerConversation: jest.fn(),
|
|
110
|
+
register1to1Conversation: jest.fn(),
|
|
110
111
|
wipeConversation: jest.fn(),
|
|
111
112
|
handleMLSMessageAddEvent: jest.fn(),
|
|
112
113
|
conversationExists: jest.fn(),
|
|
@@ -328,10 +329,8 @@ describe('ConversationService', () => {
|
|
|
328
329
|
jest.spyOn(mlsService, 'wipeConversation');
|
|
329
330
|
const establishedConversation = await conversationService.establishMLS1to1Conversation(mockGroupId, selfUser, otherUserId);
|
|
330
331
|
expect(mlsService.wipeConversation).toHaveBeenCalledWith(mockGroupId);
|
|
331
|
-
expect(mlsService.
|
|
332
|
-
expect(mlsService.
|
|
333
|
-
creator: selfUser,
|
|
334
|
-
});
|
|
332
|
+
expect(mlsService.register1to1Conversation).toHaveBeenCalledTimes(1);
|
|
333
|
+
expect(mlsService.register1to1Conversation).toHaveBeenCalledWith(mockGroupId, otherUserId, selfUser, undefined);
|
|
335
334
|
expect(conversationService.joinByExternalCommit).not.toHaveBeenCalled();
|
|
336
335
|
expect(establishedConversation.epoch).toEqual(updatedEpoch);
|
|
337
336
|
});
|
|
@@ -363,14 +362,12 @@ describe('ConversationService', () => {
|
|
|
363
362
|
epoch: updatedEpoch,
|
|
364
363
|
group_id: mockGroupId,
|
|
365
364
|
});
|
|
366
|
-
jest.spyOn(mlsService, '
|
|
365
|
+
jest.spyOn(mlsService, 'register1to1Conversation').mockRejectedValueOnce(undefined);
|
|
367
366
|
jest.spyOn(mlsService, 'wipeConversation');
|
|
368
367
|
const establishedConversation = await conversationService.establishMLS1to1Conversation(mockGroupId, selfUser, otherUserId);
|
|
369
368
|
expect(mlsService.wipeConversation).toHaveBeenCalledWith(mockGroupId);
|
|
370
|
-
expect(mlsService.
|
|
371
|
-
expect(mlsService.
|
|
372
|
-
creator: selfUser,
|
|
373
|
-
});
|
|
369
|
+
expect(mlsService.register1to1Conversation).toHaveBeenCalledTimes(2);
|
|
370
|
+
expect(mlsService.register1to1Conversation).toHaveBeenCalledWith(mockGroupId, otherUserId, selfUser, undefined);
|
|
374
371
|
expect(conversationService.joinByExternalCommit).not.toHaveBeenCalled();
|
|
375
372
|
expect(establishedConversation.epoch).toEqual(updatedEpoch);
|
|
376
373
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubconversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/SubconversationService/SubconversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,kBAAkB,EAAkB,MAAM,sCAAsC,CAAC;AACzF,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAInD,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAGlD,KAAK,MAAM,GAAG;IACZ,wBAAwB,EAAE;QAAC,cAAc,EAAE,WAAW,CAAA;KAAC,CAAC;CACzD,CAAC;AAEF,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"SubconversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/SubconversationService/SubconversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,kBAAkB,EAAkB,MAAM,sCAAsC,CAAC;AACzF,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAInD,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAGlD,KAAK,MAAM,GAAG;IACZ,wBAAwB,EAAE;QAAC,cAAc,EAAE,WAAW,CAAA;KAAC,CAAC;CACzD,CAAC;AAEF,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;CACrB;AAID,qBAAa,sBAAuB,SAAQ,iBAAiB,CAAC,MAAM,CAAC;IAIjE,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAL/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmD;gBAGvD,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,WAAW,CAAC,wBAAY;IAK3C,IAAI,UAAU,IAAI,UAAU,CAK3B;IAED;;;;;;OAM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iCAAiC,sBACnB,kBAAkB,KACpC,QACD;QACE,oBAAoB,EAAE,WAAW,CAAC;QAClC,iBAAiB,EAAE,kBAAkB,CAAC;QACtC,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CACJ,CAOC;IAEK,0BAA0B,yBACT,WAAW,qBACd,kBAAkB,WAC5B,MAAM,qBAOf;IAEK,2BAA2B,yBACV,WAAW,qBACd,kBAAkB,mBAMrC;CACH"}
|
|
@@ -213,7 +213,9 @@ class SubconversationService extends commons_1.TypedEventEmitter {
|
|
|
213
213
|
const isSubconversationMember = subconversationMemberIds.some(({ userId, clientId, domain }) => (0, fullyQualifiedClientIdUtils_1.constructFullyQualifiedClientId)(userId, clientId, domain) ===
|
|
214
214
|
(0, fullyQualifiedClientIdUtils_1.constructFullyQualifiedClientId)(parentMember.userId, parentMember.clientId, parentMember.domain));
|
|
215
215
|
return {
|
|
216
|
-
userid:
|
|
216
|
+
userid: this.apiClient.backendFeatures.isFederated
|
|
217
|
+
? `${parentMember.userId}@${parentMember.domain}`
|
|
218
|
+
: parentMember.userId,
|
|
217
219
|
clientid: parentMember.clientId,
|
|
218
220
|
in_subconv: isSubconversationMember,
|
|
219
221
|
};
|
|
@@ -35,8 +35,9 @@ const getSubconversationResponse = ({ epoch, epochTimestamp, parentConversationI
|
|
|
35
35
|
epoch_timestamp: epochTimestamp,
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
const buildSubconversationService = async () => {
|
|
38
|
+
const buildSubconversationService = async (isFederated = false) => {
|
|
39
39
|
const apiClient = new api_client_1.APIClient({ urls: api_client_1.APIClient.BACKEND.STAGING });
|
|
40
|
+
apiClient.backendFeatures.isFederated = isFederated;
|
|
40
41
|
const mlsService = {
|
|
41
42
|
conversationExists: jest.fn(),
|
|
42
43
|
wipeConversation: jest.fn(),
|
|
@@ -253,8 +254,8 @@ describe('SubconversationService', () => {
|
|
|
253
254
|
const response = await subconversationService.getSubconversationEpochInfo(parentConversationId, parentConversationGroupId);
|
|
254
255
|
expect(response).toEqual(null);
|
|
255
256
|
});
|
|
256
|
-
it('returns epoch info and advances epoch number', async () => {
|
|
257
|
-
const [subconversationService, { mlsService }] = await buildSubconversationService();
|
|
257
|
+
it.each([true, false])('returns epoch info and advances epoch number', async (isFederated) => {
|
|
258
|
+
const [subconversationService, { mlsService }] = await buildSubconversationService(isFederated);
|
|
258
259
|
const parentConversationId = { id: 'parentConversationId', domain: 'domain' };
|
|
259
260
|
const parentConversationGroupId = 'parentConversationGroupId';
|
|
260
261
|
const subconversationGroupId = 'subconversationGroupId';
|
|
@@ -280,8 +281,8 @@ describe('SubconversationService', () => {
|
|
|
280
281
|
epoch: mockedEpoch,
|
|
281
282
|
keyLength: 32,
|
|
282
283
|
members: [
|
|
283
|
-
{ clientid: 'clientId1', in_subconv: true, userid: 'userId1@domain' },
|
|
284
|
-
{ clientid: 'clientId2', in_subconv: false, userid: 'userId2@domain' },
|
|
284
|
+
{ clientid: 'clientId1', in_subconv: true, userid: isFederated ? 'userId1@domain' : 'userId1' },
|
|
285
|
+
{ clientid: 'clientId2', in_subconv: false, userid: isFederated ? 'userId2@domain' : 'userId2' },
|
|
285
286
|
],
|
|
286
287
|
secretKey: mockedSecretKey,
|
|
287
288
|
};
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.wrapInEphemeral = exports.buildTextMessage = exports.buildHideMessage = exports.buildDeleteMessage = exports.buildCallMessage = exports.buildSessionResetMessage = exports.buildReactionMessage = exports.buildPingMessage = exports.buildLocationMessage = exports.buildImageMessage = exports.buildClearedMessage = exports.buildDataTransferMessage = exports.buildLastReadMessage = exports.buildFileAbortMessage = exports.buildFileMetaDataMessage = exports.buildFileDataMessage = exports.buildEditedTextMessage = exports.buildConfirmationMessage = exports.buildCompositeMessage = exports.buildButtonActionConfirmationMessage = exports.buildButtonActionMessage = exports.createId = void 0;
|
|
22
|
-
const
|
|
22
|
+
const uuid_1 = require("uuid");
|
|
23
23
|
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
24
24
|
const AssetTransferState_1 = require("../AssetTransferState");
|
|
25
25
|
const GenericMessageType_1 = require("../GenericMessageType");
|
|
26
26
|
const MessageToProtoMapper_1 = require("../message/MessageToProtoMapper");
|
|
27
27
|
function createId() {
|
|
28
|
-
return (0,
|
|
28
|
+
return (0, uuid_1.v4)();
|
|
29
29
|
}
|
|
30
30
|
exports.createId = createId;
|
|
31
31
|
function buildButtonActionMessage(payloadBundle) {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
const http_status_codes_1 = require("http-status-codes");
|
|
22
|
-
const
|
|
22
|
+
const uuid_1 = require("uuid");
|
|
23
23
|
const api_client_1 = require("@wireapp/api-client");
|
|
24
24
|
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
25
25
|
const MessageService_1 = require("./MessageService");
|
|
@@ -33,12 +33,12 @@ const baseMessageSendingStatus = {
|
|
|
33
33
|
time: new Date().toISOString(),
|
|
34
34
|
};
|
|
35
35
|
const user1 = {
|
|
36
|
-
id: (0,
|
|
36
|
+
id: (0, uuid_1.v4)(),
|
|
37
37
|
domain: '1.wire.test',
|
|
38
38
|
clients: ['client1.1', 'client1.2', 'client1.3', 'client1.4'],
|
|
39
39
|
};
|
|
40
40
|
const user2 = {
|
|
41
|
-
id: (0,
|
|
41
|
+
id: (0, uuid_1.v4)(),
|
|
42
42
|
domain: '2.wire.test',
|
|
43
43
|
clients: ['client2.1', 'client2.2', 'client2.3', 'client2.4'],
|
|
44
44
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export * as cryptography from './cryptography/';
|
|
|
6
6
|
export * as util from './util';
|
|
7
7
|
export * as MessageBuilder from './conversation/message/MessageBuilder';
|
|
8
8
|
export * as errors from './errors';
|
|
9
|
+
export { Ciphersuite } from '@wireapp/core-crypto';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAC,MAAM,WAAW,CAAC;AAC1E,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,cAAc,MAAM,uCAAuC,CAAC;AACxE,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAC,MAAM,WAAW,CAAC;AAC1E,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,cAAc,MAAM,uCAAuC,CAAC;AACxE,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -41,7 +41,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
41
41
|
return result;
|
|
42
42
|
};
|
|
43
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.errors = exports.MessageBuilder = exports.util = exports.cryptography = exports.CoreError = exports.conversation = exports.auth = exports.ConnectionState = exports.Account = void 0;
|
|
44
|
+
exports.Ciphersuite = exports.errors = exports.MessageBuilder = exports.util = exports.cryptography = exports.CoreError = exports.conversation = exports.auth = exports.ConnectionState = exports.Account = void 0;
|
|
45
45
|
var Account_1 = require("./Account");
|
|
46
46
|
Object.defineProperty(exports, "Account", { enumerable: true, get: function () { return Account_1.Account; } });
|
|
47
47
|
Object.defineProperty(exports, "ConnectionState", { enumerable: true, get: function () { return Account_1.ConnectionState; } });
|
|
@@ -53,3 +53,5 @@ exports.cryptography = __importStar(require("./cryptography/"));
|
|
|
53
53
|
exports.util = __importStar(require("./util"));
|
|
54
54
|
exports.MessageBuilder = __importStar(require("./conversation/message/MessageBuilder"));
|
|
55
55
|
exports.errors = __importStar(require("./errors"));
|
|
56
|
+
var core_crypto_1 = require("@wireapp/core-crypto");
|
|
57
|
+
Object.defineProperty(exports, "Ciphersuite", { enumerable: true, get: function () { return core_crypto_1.Ciphersuite; } });
|
package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/AcmeService.d.ts
CHANGED
|
@@ -64,11 +64,11 @@ export declare class AcmeService {
|
|
|
64
64
|
target: string;
|
|
65
65
|
status: string;
|
|
66
66
|
token: string;
|
|
67
|
-
validated?: string | undefined;
|
|
68
67
|
error?: {
|
|
69
68
|
type: string;
|
|
70
69
|
detail: string;
|
|
71
70
|
} | undefined;
|
|
71
|
+
validated?: string | undefined;
|
|
72
72
|
}>>;
|
|
73
73
|
checkStatusOfOrder(url: string, payload: Uint8Array): Promise<PostJoseRequestReturnValue<{
|
|
74
74
|
id: string;
|
|
@@ -207,22 +207,22 @@ export declare const OidcChallengeResponseSchema: z.ZodObject<{
|
|
|
207
207
|
target: string;
|
|
208
208
|
status: string;
|
|
209
209
|
token: string;
|
|
210
|
-
validated?: string | undefined;
|
|
211
210
|
error?: {
|
|
212
211
|
type: string;
|
|
213
212
|
detail: string;
|
|
214
213
|
} | undefined;
|
|
214
|
+
validated?: string | undefined;
|
|
215
215
|
}, {
|
|
216
216
|
type: string;
|
|
217
217
|
url: string;
|
|
218
218
|
target: string;
|
|
219
219
|
status: string;
|
|
220
220
|
token: string;
|
|
221
|
-
validated?: string | undefined;
|
|
222
221
|
error?: {
|
|
223
222
|
type: string;
|
|
224
223
|
detail: string;
|
|
225
224
|
} | undefined;
|
|
225
|
+
validated?: string | undefined;
|
|
226
226
|
}>;
|
|
227
227
|
export type OidcChallengeResponseData = z.infer<typeof OidcChallengeResponseSchema>;
|
|
228
228
|
export declare const CheckStatusOfOrderResponseSchema: z.ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"E2EIServiceExternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,UAAU,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAiB,MAAM,sBAAsB,CAAC;AAMnH,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"E2EIServiceExternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,UAAU,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAiB,MAAM,sBAAsB,CAAC;AAMnH,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EA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C,GAAG,SAAS,CAAC;IAsBxD,kBAAkB,CAC7B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,WAAW,EAAE,GACrB,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,cAAc,EAAE,CAAC,GAAG,SAAS,CAAC;IAyDxD,oBAAoB,CAC/B,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC1C,OAAO,CAAC,cAAc,EAAE,CAAC;IAiBf,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;YAKvC,4BAA4B;IAO1C;;;;;OAKG;IACU,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW5D,OAAO,KAAK,WAAW,GAKtB;YAEa,+BAA+B;IAK7C;;;;;;;;;;;;OAYG;YACW,0BAA0B;IA2BxC,OAAO,CAAC,4BAA4B;YAStB,+BAA+B;YAQ/B,uBAAuB;YAKvB,0BAA0B;YAI1B,4BAA4B;YAO5B,WAAW;YAkBX,8BAA8B;CAM7C"}
|
|
@@ -27,25 +27,8 @@ const Connection_1 = require("./Connection");
|
|
|
27
27
|
const Helper_1 = require("./Helper");
|
|
28
28
|
const E2EIStorage_1 = require("./Storage/E2EIStorage");
|
|
29
29
|
const fullyQualifiedClientIdUtils_1 = require("../../../util/fullyQualifiedClientIdUtils");
|
|
30
|
-
const LocalStorageStore_1 = require("../../../util/LocalStorageStore");
|
|
31
30
|
const LowPrecisionTaskScheduler_1 = require("../../../util/LowPrecisionTaskScheduler");
|
|
32
31
|
const qualifiedIdUtil_1 = require("../../../util/qualifiedIdUtil");
|
|
33
|
-
// TODO coreCrypto types are wrong here. They return a string (the key of the enum) instead of the enum value
|
|
34
|
-
function fixDeviceStatus(value) {
|
|
35
|
-
const fixedValue = core_crypto_1.DeviceStatus[value];
|
|
36
|
-
if (!fixedValue) {
|
|
37
|
-
throw new Error(`Invalid device status: ${value}`);
|
|
38
|
-
}
|
|
39
|
-
return fixedValue;
|
|
40
|
-
}
|
|
41
|
-
// TODO coreCrypto types are wrong here. They return a string (the key of the enum) instead of the enum value
|
|
42
|
-
function fixConversationState(value) {
|
|
43
|
-
const fixedValue = core_crypto_1.E2eiConversationState[value];
|
|
44
|
-
if (!fixedValue) {
|
|
45
|
-
throw new Error(`Invalid conversation status: ${value}`);
|
|
46
|
-
}
|
|
47
|
-
return fixedValue;
|
|
48
|
-
}
|
|
49
32
|
// This export is meant to be accessible from the outside (e.g the Webapp / UI)
|
|
50
33
|
class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
51
34
|
constructor(coreCryptoClient, coreDatabase, recurringTaskScheduler, clientService, mlsService) {
|
|
@@ -56,7 +39,6 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
56
39
|
this.clientService = clientService;
|
|
57
40
|
this.mlsService = mlsService;
|
|
58
41
|
this.enrollmentStorage = (0, E2EIStorage_1.createE2EIEnrollmentStorage)(coreDatabase);
|
|
59
|
-
mlsService.on('newCrlDistributionPoints', distributionPoints => this.handleNewCrlDistributionPoints(distributionPoints));
|
|
60
42
|
}
|
|
61
43
|
// If we have a handle in the local storage, we are in the enrollment process (this handle is saved before oauth redirect)
|
|
62
44
|
async isEnrollmentInProgress() {
|
|
@@ -67,11 +49,10 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
67
49
|
return this.enrollmentStorage.deletePendingEnrollmentData();
|
|
68
50
|
}
|
|
69
51
|
async getConversationState(conversationId) {
|
|
70
|
-
|
|
71
|
-
return fixConversationState(state);
|
|
52
|
+
return this.coreCryptoClient.e2eiConversationState(conversationId);
|
|
72
53
|
}
|
|
73
54
|
isE2EIEnabled() {
|
|
74
|
-
return this.coreCryptoClient.e2eiIsEnabled(this.mlsService.config.
|
|
55
|
+
return this.coreCryptoClient.e2eiIsEnabled(this.mlsService.config.defaultCiphersuite);
|
|
75
56
|
}
|
|
76
57
|
async getAllGroupUsersIdentities(groupId) {
|
|
77
58
|
const conversationExists = await this.mlsService.conversationExists(groupId);
|
|
@@ -102,7 +83,7 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
102
83
|
.map(fullyQualifiedId => (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(fullyQualifiedId));
|
|
103
84
|
const mappedUserIdentities = new Map();
|
|
104
85
|
for (const userId of userIds) {
|
|
105
|
-
const identities = (userIdentities.get(userId.id) || []).map(identity => (Object.assign(Object.assign({}, identity), {
|
|
86
|
+
const identities = (userIdentities.get(userId.id) || []).map(identity => (Object.assign(Object.assign({}, identity), { deviceId: (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(identity.clientId).client, qualifiedUserId: userId })));
|
|
106
87
|
const basicMLSDevices = allUsersMLSDevices
|
|
107
88
|
.filter(({ user }) => user === userId.id)
|
|
108
89
|
// filtering devices that have a valid identity
|
|
@@ -117,14 +98,11 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
117
98
|
async getDevicesIdentities(groupId, userClientsMap) {
|
|
118
99
|
const clientIds = Object.entries(userClientsMap).map(([clientId, userId]) => (0, Helper_1.getE2EIClientId)(clientId, userId.id, userId.domain).asBytes);
|
|
119
100
|
const deviceIdentities = await this.coreCryptoClient.getDeviceIdentities(bazinga64_1.Decoder.fromBase64(groupId).asBytes, clientIds);
|
|
120
|
-
return deviceIdentities.map(identity => (Object.assign(Object.assign({}, identity), { deviceId: (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(identity.clientId).client, qualifiedUserId: userClientsMap[identity.clientId] })));
|
|
101
|
+
return deviceIdentities.map(identity => (Object.assign(Object.assign({}, identity), { deviceId: (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(identity.clientId).client, credentialType: identity.credentialType, qualifiedUserId: userClientsMap[identity.clientId] })));
|
|
121
102
|
}
|
|
122
103
|
async isFreshMLSSelfClient() {
|
|
123
104
|
const client = await this.clientService.loadClient();
|
|
124
|
-
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
|
-
return !(0, Helper_1.isMLSDevice)(client);
|
|
105
|
+
return !client || !this.mlsService.isInitializedMLSClient(client);
|
|
128
106
|
}
|
|
129
107
|
async registerLocalCertificateRoot(acmeService) {
|
|
130
108
|
const localCertificateRoot = await acmeService.getLocalCertificateRoot();
|
|
@@ -139,6 +117,7 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
139
117
|
*/
|
|
140
118
|
async initialize(discoveryUrl) {
|
|
141
119
|
this._acmeService = new Connection_1.AcmeService(discoveryUrl);
|
|
120
|
+
this.mlsService.on('newCrlDistributionPoints', distributionPoints => this.handleNewCrlDistributionPoints(distributionPoints));
|
|
142
121
|
await this.registerServerCertificates();
|
|
143
122
|
await this.initialiseCrlDistributionTimers();
|
|
144
123
|
}
|
|
@@ -166,12 +145,10 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
166
145
|
* Both must be registered before the first enrollment.
|
|
167
146
|
*/
|
|
168
147
|
async registerServerCertificates() {
|
|
169
|
-
const
|
|
170
|
-
const store = (0, LocalStorageStore_1.LocalStorageStore)(this.coreDatabase.name);
|
|
148
|
+
const isRootRegistered = await this.coreCryptoClient.e2eiIsPKIEnvSetup();
|
|
171
149
|
// Register root certificate if not already registered
|
|
172
|
-
if (!
|
|
150
|
+
if (!isRootRegistered) {
|
|
173
151
|
await this.registerLocalCertificateRoot(this.acmeService);
|
|
174
|
-
store.add(ROOT_CA_KEY, 'true');
|
|
175
152
|
}
|
|
176
153
|
// Register intermediate certificate and update it every 24 hours
|
|
177
154
|
const INTERMEDIATE_CA_KEY = 'update-intermediate-certificates';
|
|
@@ -17,19 +17,28 @@
|
|
|
17
17
|
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
20
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
const TimeUtil_1 = require("@wireapp/commons/lib/util/TimeUtil");
|
|
25
|
+
const axios_1 = __importDefault(require("axios"));
|
|
26
|
+
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
21
27
|
const E2EIServiceExternal_1 = require("./E2EIServiceExternal");
|
|
22
28
|
const CoreDB_1 = require("../../../storage/CoreDB");
|
|
23
29
|
const PayloadHelper_1 = require("../../../test/PayloadHelper");
|
|
24
30
|
const qualifiedIdUtil_1 = require("../../../util/qualifiedIdUtil");
|
|
25
31
|
const RecurringTaskScheduler_1 = require("../../../util/RecurringTaskScheduler");
|
|
26
|
-
async function buildE2EIService() {
|
|
32
|
+
async function buildE2EIService(dbName = 'core-test-db') {
|
|
27
33
|
const coreCrypto = {
|
|
28
34
|
getUserIdentities: jest.fn(),
|
|
29
35
|
getClientIds: jest.fn().mockResolvedValue([]),
|
|
36
|
+
e2eiIsPKIEnvSetup: jest.fn(),
|
|
37
|
+
e2eiRegisterAcmeCA: jest.fn(),
|
|
38
|
+
e2eiRegisterIntermediateCA: jest.fn(),
|
|
30
39
|
};
|
|
31
40
|
const clientService = {};
|
|
32
|
-
const mockedDb = await (0, CoreDB_1.openDB)(
|
|
41
|
+
const mockedDb = await (0, CoreDB_1.openDB)(dbName);
|
|
33
42
|
const mockedMLSService = {
|
|
34
43
|
on: jest.fn(),
|
|
35
44
|
getClientIds: jest.fn(),
|
|
@@ -39,12 +48,12 @@ async function buildE2EIService() {
|
|
|
39
48
|
delete: key => mockedDb.delete('recurringTasks', key),
|
|
40
49
|
get: async (key) => { var _a; return (_a = (await mockedDb.get('recurringTasks', key))) === null || _a === void 0 ? void 0 : _a.firingDate; },
|
|
41
50
|
set: async (key, timestamp) => {
|
|
42
|
-
await mockedDb.put('recurringTasks', { key, firingDate: timestamp });
|
|
51
|
+
await mockedDb.put('recurringTasks', { key, firingDate: timestamp }, key);
|
|
43
52
|
},
|
|
44
53
|
});
|
|
45
54
|
return [
|
|
46
55
|
new E2EIServiceExternal_1.E2EIServiceExternal(coreCrypto, mockedDb, recurringTaskScheduler, clientService, mockedMLSService),
|
|
47
|
-
{ coreCrypto, mlsService: mockedMLSService },
|
|
56
|
+
{ coreCrypto, mlsService: mockedMLSService, recurringTaskScheduler },
|
|
48
57
|
];
|
|
49
58
|
}
|
|
50
59
|
function generateCoreCryptoIdentity({ userId, status = 'Valid', deviceId = (0, PayloadHelper_1.getUUID)(), }) {
|
|
@@ -56,6 +65,7 @@ function generateCoreCryptoIdentity({ userId, status = 'Valid', deviceId = (0, P
|
|
|
56
65
|
certificate: '-----BEGIN CERTIFICATE-----\nMIICRTCCAeqgAwIBAgIQcpcbKbgHLM5qoB7xgxm6BTAKBggqhkjOPQQDAjAuMSww\nKgYDVQQDEyNlbG5hLndpcmUubGluayBFMkVJIEludGVybWVkaWF0ZSBDQTAeFw0y\nMzExMjIxMTIwMDVaFw0yMzExMjQxMTIwMDVaMDIxFzAVBgNVBAoTDmVsbmEud2ly\nZS5saW5rMRcwFQYDVQQDEw5BZHJpYW4gV2Vpc3MgMjAqMAUGAytlcAMhAMwP5B9X\nwanLL7JUmHEc1SJYAvHUvMnL1MS/D4CK3JaMo4IBEzCCAQ8wDgYDVR0PAQH/BAQD\nAgeAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAdBgNVHQ4EFgQUrIPC\nem20zAl1ybZqXm2LkvD2U1swHwYDVR0jBBgwFoAU5bQTjX1Ps09suTYe4tzXUKgl\nN9YwdwYDVR0RBHAwboYpaW06d2lyZWFwcD0lNDBhZHJpYW5fd2lyZTJAZWxuYS53\naXJlLmxpbmuGQWltOndpcmVhcHA9U0tIRHNFc09TODJUcldUSE5Fc1ZOQS9lYjll\nMDM4NjE4MzllOWRhQGVsbmEud2lyZS5saW5rMCUGDCsGAQQBgqRkxihAAQQVMBMC\nAQYEDGRlZmF1bHR0ZWFtcwQAMAoGCCqGSM49BAMCA0kAMEYCIQCQQHVAd6wjp2A+\nVvKIXu4oVlCMZkAUATU5bXY4njvapwIhAO8rION7Mz5rSjixJsdEL8E+HHsNvCax\ndjrSL0FL9SM6\n-----END CERTIFICATE-----\n',
|
|
57
66
|
status,
|
|
58
67
|
thumbprint: 'mNyAo88vAF5s7v0UWBNxlQKxP3dfT91A-4PbuzEA5uQ',
|
|
68
|
+
credentialType: core_crypto_1.CredentialType.X509,
|
|
59
69
|
};
|
|
60
70
|
}
|
|
61
71
|
const groupId = 'AAEAAhJrE+8TbFFUqiagedTYDUMAZWxuYS53aXJlLmxpbms=';
|
|
@@ -155,4 +165,46 @@ describe('E2EIServiceExternal', () => {
|
|
|
155
165
|
expect(userIdentities === null || userIdentities === void 0 ? void 0 : userIdentities.get((0, qualifiedIdUtil_1.stringifyQualifiedId)({ id: user2.userId, domain: user2.domain }))).toHaveLength(1);
|
|
156
166
|
});
|
|
157
167
|
});
|
|
168
|
+
describe('initialize', () => {
|
|
169
|
+
const axiosMock = axios_1.default;
|
|
170
|
+
axiosMock.get = jest.fn();
|
|
171
|
+
axiosMock.get.mockImplementation(async (url) => {
|
|
172
|
+
if (url === `${mockDiscoveryUrl}/roots.pem`) {
|
|
173
|
+
return { data: mockedRootCA };
|
|
174
|
+
}
|
|
175
|
+
if (url === `${mockDiscoveryUrl}/federation`) {
|
|
176
|
+
return { data: { crts: federatedCerts } };
|
|
177
|
+
}
|
|
178
|
+
return { data: null };
|
|
179
|
+
});
|
|
180
|
+
axios_1.default.create = jest.fn(() => axiosMock);
|
|
181
|
+
const mockDiscoveryUrl = 'https://some.crl.discovery.url';
|
|
182
|
+
const mockedRootCA = 'cert';
|
|
183
|
+
const federatedCerts = ['federatedCert1', 'federatedCert2'];
|
|
184
|
+
afterEach(() => {
|
|
185
|
+
jest.clearAllMocks();
|
|
186
|
+
jest.useRealTimers();
|
|
187
|
+
});
|
|
188
|
+
it('registers the server certificates and shedules a timer to refresh intermediate certs every', async () => {
|
|
189
|
+
jest.useFakeTimers();
|
|
190
|
+
const [service, { coreCrypto }] = await buildE2EIService('mockedDB1');
|
|
191
|
+
jest.spyOn(coreCrypto, 'e2eiIsPKIEnvSetup').mockResolvedValueOnce(false);
|
|
192
|
+
await service.initialize('https://some.crl.discovery.url');
|
|
193
|
+
expect(coreCrypto.e2eiRegisterAcmeCA).toHaveBeenCalledWith(mockedRootCA);
|
|
194
|
+
expect(coreCrypto.e2eiRegisterIntermediateCA).toHaveBeenCalledWith(federatedCerts[0]);
|
|
195
|
+
expect(coreCrypto.e2eiRegisterIntermediateCA).toHaveBeenCalledWith(federatedCerts[1]);
|
|
196
|
+
expect(coreCrypto.e2eiRegisterIntermediateCA).toHaveBeenCalledTimes(2);
|
|
197
|
+
await jest.advanceTimersByTimeAsync(TimeUtil_1.TimeInMillis.DAY);
|
|
198
|
+
await jest.runAllTimersAsync();
|
|
199
|
+
expect(coreCrypto.e2eiRegisterIntermediateCA).toHaveBeenCalledTimes(4);
|
|
200
|
+
});
|
|
201
|
+
it('does not register the root cert if it was already registered', async () => {
|
|
202
|
+
jest.useFakeTimers();
|
|
203
|
+
const [service, { coreCrypto }] = await buildE2EIService('mockedDB2');
|
|
204
|
+
jest.spyOn(coreCrypto, 'e2eiIsPKIEnvSetup').mockResolvedValueOnce(true);
|
|
205
|
+
await service.initialize('https://some.crl.discovery.url');
|
|
206
|
+
expect(coreCrypto.e2eiRegisterAcmeCA).not.toHaveBeenCalled();
|
|
207
|
+
expect(coreCrypto.e2eiRegisterIntermediateCA).toHaveBeenCalledTimes(2);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
158
210
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIClient } from '@wireapp/api-client';
|
|
2
|
-
import { CoreCrypto } from './E2EIService.types';
|
|
2
|
+
import { Ciphersuite, CoreCrypto } from './E2EIService.types';
|
|
3
3
|
import { InitialData } from './Storage/E2EIStorage.schema';
|
|
4
4
|
import { CoreDatabase } from '../../../storage/CoreDB';
|
|
5
5
|
export type getTokenCallback = (challengesData?: {
|
|
@@ -24,7 +24,7 @@ export declare class E2EIServiceInternal {
|
|
|
24
24
|
* @param getOAuthToken function called when the process needs an oauth token
|
|
25
25
|
* @param refresh should the process refresh the current certificate or get a new one
|
|
26
26
|
*/
|
|
27
|
-
generateCertificate(getOAuthToken: getTokenCallback, refresh: boolean): Promise<import("@wireapp/core-crypto").RotateBundle>;
|
|
27
|
+
generateCertificate(getOAuthToken: getTokenCallback, refresh: boolean, ciphersuite: Ciphersuite): Promise<import("@wireapp/core-crypto").RotateBundle>;
|
|
28
28
|
private continueCertificateGeneration;
|
|
29
29
|
private initIdentity;
|
|
30
30
|
private getDirectory;
|