@wireapp/core 46.1.0-hotfix-1.1 → 46.1.0-hotfix-1.5
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/LICENSE +674 -0
- package/lib/Account.d.ts +5 -8
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +321 -141
- 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 +5 -11
- package/lib/conversation/ConversationService/ConversationService.test.js +9 -6
- 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 +1 -3
- package/lib/conversation/SubconversationService/SubconversationService.test.js +5 -6
- package/lib/conversation/message/MessageBuilder.js +2 -2
- package/lib/conversation/message/MessageService.test.js +3 -3
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -3
- 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 +31 -8
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.js +4 -56
- 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 +6 -3
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.d.ts +2 -4
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.js +2 -24
- package/lib/messagingProtocols/mls/E2EIdentityService/Steps/OidcChallenge.d.ts +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +11 -45
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.guards.d.ts +4 -0
- package/lib/messagingProtocols/mls/MLSService/MLSService.guards.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/MLSService/{ClientMLSError.js → MLSService.guards.js} +7 -12
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +42 -92
- package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +10 -109
- package/lib/messagingProtocols/mls/MLSService/MLSService.types.d.ts +15 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/index.d.ts +0 -1
- package/lib/messagingProtocols/mls/MLSService/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/index.js +0 -1
- package/lib/messagingProtocols/mls/types.d.ts +3 -0
- 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 +1 -0
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts +4 -7
- 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 +8 -8
- package/lib/messagingProtocols/mls/MLSService/ClientMLSError.d.ts +0 -8
- package/lib/messagingProtocols/mls/MLSService/ClientMLSError.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 uuidjs_1 = require("uuidjs");
|
|
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, uuidjs_1.genV4)().toString(),
|
|
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, uuidjs_1.genV4)().toString(), 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, uuidjs_1.genV4)().toString(), 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, uuidjs_1.genV4)().toString(), 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 uuidjs_1 = require("uuidjs");
|
|
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, uuidjs_1.genV4)().toString()}`,
|
|
31
|
+
token: (0, uuidjs_1.genV4)().toString(),
|
|
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<MLSConversation>;
|
|
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,EAEnB,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,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c,EAAE,WAAW,CAAC;QAC5B,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
|
|
78
|
+
const mlsConversation = 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,17 +88,15 @@ 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
|
-
|
|
92
|
-
return updatedMLSConversation;
|
|
91
|
+
return this.getMLS1to1Conversation(otherUserId);
|
|
93
92
|
}
|
|
94
93
|
// If group is not established on backend,
|
|
95
94
|
// we wipe the it locally (in case it exsits in the local store) and try to register it.
|
|
96
95
|
await this.mlsService.wipeConversation(groupId);
|
|
97
96
|
try {
|
|
98
|
-
await this.mlsService.
|
|
97
|
+
await this.mlsService.registerConversation(groupId, [otherUserId, selfUser.user], { creator: selfUser });
|
|
99
98
|
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) established successfully.`);
|
|
100
|
-
|
|
101
|
-
return updatedMLSConversation;
|
|
99
|
+
return this.getMLS1to1Conversation(otherUserId);
|
|
102
100
|
}
|
|
103
101
|
catch (error) {
|
|
104
102
|
this.logger.info(`Could not register MLS group with id ${groupId}: `, error);
|
|
@@ -416,11 +414,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
416
414
|
* @param userId - qualified user id
|
|
417
415
|
*/
|
|
418
416
|
async getMLS1to1Conversation(userId) {
|
|
419
|
-
|
|
420
|
-
if ((0, conversation_1.isMLS1to1Conversation)(conversation)) {
|
|
421
|
-
return conversation;
|
|
422
|
-
}
|
|
423
|
-
return { conversation };
|
|
417
|
+
return this.apiClient.api.conversation.getMLS1to1Conversation(userId);
|
|
424
418
|
}
|
|
425
419
|
/**
|
|
426
420
|
* Will try to register mls group by sending an empty commit to establish it.
|
|
@@ -107,7 +107,6 @@ describe('ConversationService', () => {
|
|
|
107
107
|
getEpoch: () => Promise.resolve(),
|
|
108
108
|
joinByExternalCommit: jest.fn(),
|
|
109
109
|
registerConversation: jest.fn(),
|
|
110
|
-
register1to1Conversation: jest.fn(),
|
|
111
110
|
wipeConversation: jest.fn(),
|
|
112
111
|
handleMLSMessageAddEvent: jest.fn(),
|
|
113
112
|
conversationExists: jest.fn(),
|
|
@@ -329,8 +328,10 @@ describe('ConversationService', () => {
|
|
|
329
328
|
jest.spyOn(mlsService, 'wipeConversation');
|
|
330
329
|
const establishedConversation = await conversationService.establishMLS1to1Conversation(mockGroupId, selfUser, otherUserId);
|
|
331
330
|
expect(mlsService.wipeConversation).toHaveBeenCalledWith(mockGroupId);
|
|
332
|
-
expect(mlsService.
|
|
333
|
-
expect(mlsService.
|
|
331
|
+
expect(mlsService.registerConversation).toHaveBeenCalledTimes(1);
|
|
332
|
+
expect(mlsService.registerConversation).toHaveBeenCalledWith(mockGroupId, [otherUserId, selfUser.user], {
|
|
333
|
+
creator: selfUser,
|
|
334
|
+
});
|
|
334
335
|
expect(conversationService.joinByExternalCommit).not.toHaveBeenCalled();
|
|
335
336
|
expect(establishedConversation.epoch).toEqual(updatedEpoch);
|
|
336
337
|
});
|
|
@@ -362,12 +363,14 @@ describe('ConversationService', () => {
|
|
|
362
363
|
epoch: updatedEpoch,
|
|
363
364
|
group_id: mockGroupId,
|
|
364
365
|
});
|
|
365
|
-
jest.spyOn(mlsService, '
|
|
366
|
+
jest.spyOn(mlsService, 'registerConversation').mockRejectedValueOnce(undefined);
|
|
366
367
|
jest.spyOn(mlsService, 'wipeConversation');
|
|
367
368
|
const establishedConversation = await conversationService.establishMLS1to1Conversation(mockGroupId, selfUser, otherUserId);
|
|
368
369
|
expect(mlsService.wipeConversation).toHaveBeenCalledWith(mockGroupId);
|
|
369
|
-
expect(mlsService.
|
|
370
|
-
expect(mlsService.
|
|
370
|
+
expect(mlsService.registerConversation).toHaveBeenCalledTimes(2);
|
|
371
|
+
expect(mlsService.registerConversation).toHaveBeenCalledWith(mockGroupId, [otherUserId, selfUser.user], {
|
|
372
|
+
creator: selfUser,
|
|
373
|
+
});
|
|
371
374
|
expect(conversationService.joinByExternalCommit).not.toHaveBeenCalled();
|
|
372
375
|
expect(establishedConversation.epoch).toEqual(updatedEpoch);
|
|
373
376
|
});
|
|
@@ -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,MAAM,CAAC;
|
|
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,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;IAC9B,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;;;;;;OAMG;IACU,6BAA6B,CACxC,cAAc,EAAE,WAAW,EAC3B,OAAO,EAAE,MAAM,EACf,WAAW,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K,0BAA0B,yBACT,WAAW,qBACd,kBAAkB,WAC5B,MAAM,qBAOf;IAEK,2BAA2B,yBACV,WAAW,qBACd,kBAAkB,mBAMrC;CACH"}
|
|
@@ -213,9 +213,7 @@ 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:
|
|
217
|
-
? `${parentMember.userId}@${parentMember.domain}`
|
|
218
|
-
: parentMember.userId,
|
|
216
|
+
userid: `${parentMember.userId}@${parentMember.domain}`,
|
|
219
217
|
clientid: parentMember.clientId,
|
|
220
218
|
in_subconv: isSubconversationMember,
|
|
221
219
|
};
|
|
@@ -35,9 +35,8 @@ const getSubconversationResponse = ({ epoch, epochTimestamp, parentConversationI
|
|
|
35
35
|
epoch_timestamp: epochTimestamp,
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
const buildSubconversationService = async (
|
|
38
|
+
const buildSubconversationService = async () => {
|
|
39
39
|
const apiClient = new api_client_1.APIClient({ urls: api_client_1.APIClient.BACKEND.STAGING });
|
|
40
|
-
apiClient.backendFeatures.isFederated = isFederated;
|
|
41
40
|
const mlsService = {
|
|
42
41
|
conversationExists: jest.fn(),
|
|
43
42
|
wipeConversation: jest.fn(),
|
|
@@ -254,8 +253,8 @@ describe('SubconversationService', () => {
|
|
|
254
253
|
const response = await subconversationService.getSubconversationEpochInfo(parentConversationId, parentConversationGroupId);
|
|
255
254
|
expect(response).toEqual(null);
|
|
256
255
|
});
|
|
257
|
-
it
|
|
258
|
-
const [subconversationService, { mlsService }] = await buildSubconversationService(
|
|
256
|
+
it('returns epoch info and advances epoch number', async () => {
|
|
257
|
+
const [subconversationService, { mlsService }] = await buildSubconversationService();
|
|
259
258
|
const parentConversationId = { id: 'parentConversationId', domain: 'domain' };
|
|
260
259
|
const parentConversationGroupId = 'parentConversationGroupId';
|
|
261
260
|
const subconversationGroupId = 'subconversationGroupId';
|
|
@@ -281,8 +280,8 @@ describe('SubconversationService', () => {
|
|
|
281
280
|
epoch: mockedEpoch,
|
|
282
281
|
keyLength: 32,
|
|
283
282
|
members: [
|
|
284
|
-
{ clientid: 'clientId1', in_subconv: true, userid:
|
|
285
|
-
{ clientid: 'clientId2', in_subconv: false, userid:
|
|
283
|
+
{ clientid: 'clientId1', in_subconv: true, userid: 'userId1@domain' },
|
|
284
|
+
{ clientid: 'clientId2', in_subconv: false, userid: 'userId2@domain' },
|
|
286
285
|
],
|
|
287
286
|
secretKey: mockedSecretKey,
|
|
288
287
|
};
|
|
@@ -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 uuidjs_1 = require("uuidjs");
|
|
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, uuidjs_1.genV4)().toString();
|
|
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 uuidjs_1 = require("uuidjs");
|
|
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, uuidjs_1.genV4)().toString(),
|
|
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, uuidjs_1.genV4)().toString(),
|
|
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,5 +6,4 @@ 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';
|
|
10
9
|
//# 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"}
|
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.
|
|
44
|
+
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,5 +53,3 @@ 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;
|
|
67
68
|
error?: {
|
|
68
69
|
type: string;
|
|
69
70
|
detail: string;
|
|
70
71
|
} | 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;
|
|
210
211
|
error?: {
|
|
211
212
|
type: string;
|
|
212
213
|
detail: string;
|
|
213
214
|
} | 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;
|
|
221
222
|
error?: {
|
|
222
223
|
type: string;
|
|
223
224
|
detail: string;
|
|
224
225
|
} | 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,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAIrD,OAAO,EAAC,sBAAsB,EAAuB,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG;IACnE,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,WAAW,CAAC;CA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AKG;IACU,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM5D,OAAO,KAAK,WAAW,GAKtB;YAEa,+BAA+B;IAK7C;;;;;;;;;;;;OAYG;YACW,0BAA0B;IA6BxC,OAAO,CAAC,4BAA4B;YAStB,+BAA+B;YAQ/B,uBAAuB;YAKvB,0BAA0B;YAI1B,4BAA4B;YAO5B,WAAW;YAkBX,8BAA8B;CAM7C"}
|
|
@@ -27,8 +27,25 @@ 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");
|
|
30
31
|
const LowPrecisionTaskScheduler_1 = require("../../../util/LowPrecisionTaskScheduler");
|
|
31
32
|
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
|
+
}
|
|
32
49
|
// This export is meant to be accessible from the outside (e.g the Webapp / UI)
|
|
33
50
|
class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
34
51
|
constructor(coreCryptoClient, coreDatabase, recurringTaskScheduler, clientService, mlsService) {
|
|
@@ -39,6 +56,7 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
39
56
|
this.clientService = clientService;
|
|
40
57
|
this.mlsService = mlsService;
|
|
41
58
|
this.enrollmentStorage = (0, E2EIStorage_1.createE2EIEnrollmentStorage)(coreDatabase);
|
|
59
|
+
mlsService.on('newCrlDistributionPoints', distributionPoints => this.handleNewCrlDistributionPoints(distributionPoints));
|
|
42
60
|
}
|
|
43
61
|
// If we have a handle in the local storage, we are in the enrollment process (this handle is saved before oauth redirect)
|
|
44
62
|
async isEnrollmentInProgress() {
|
|
@@ -49,10 +67,11 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
49
67
|
return this.enrollmentStorage.deletePendingEnrollmentData();
|
|
50
68
|
}
|
|
51
69
|
async getConversationState(conversationId) {
|
|
52
|
-
|
|
70
|
+
const state = await this.coreCryptoClient.e2eiConversationState(conversationId);
|
|
71
|
+
return fixConversationState(state);
|
|
53
72
|
}
|
|
54
73
|
isE2EIEnabled() {
|
|
55
|
-
return this.coreCryptoClient.e2eiIsEnabled(this.mlsService.config.
|
|
74
|
+
return this.coreCryptoClient.e2eiIsEnabled(this.mlsService.config.cipherSuite);
|
|
56
75
|
}
|
|
57
76
|
async getAllGroupUsersIdentities(groupId) {
|
|
58
77
|
const conversationExists = await this.mlsService.conversationExists(groupId);
|
|
@@ -83,7 +102,7 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
83
102
|
.map(fullyQualifiedId => (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(fullyQualifiedId));
|
|
84
103
|
const mappedUserIdentities = new Map();
|
|
85
104
|
for (const userId of userIds) {
|
|
86
|
-
const identities = (userIdentities.get(userId.id) || []).map(identity => (Object.assign(Object.assign({}, identity), { deviceId: (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(identity.clientId).client, qualifiedUserId: userId })));
|
|
105
|
+
const identities = (userIdentities.get(userId.id) || []).map(identity => (Object.assign(Object.assign({}, identity), { status: fixDeviceStatus(identity.status), deviceId: (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(identity.clientId).client, qualifiedUserId: userId })));
|
|
87
106
|
const basicMLSDevices = allUsersMLSDevices
|
|
88
107
|
.filter(({ user }) => user === userId.id)
|
|
89
108
|
// filtering devices that have a valid identity
|
|
@@ -98,11 +117,14 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
98
117
|
async getDevicesIdentities(groupId, userClientsMap) {
|
|
99
118
|
const clientIds = Object.entries(userClientsMap).map(([clientId, userId]) => (0, Helper_1.getE2EIClientId)(clientId, userId.id, userId.domain).asBytes);
|
|
100
119
|
const deviceIdentities = await this.coreCryptoClient.getDeviceIdentities(bazinga64_1.Decoder.fromBase64(groupId).asBytes, clientIds);
|
|
101
|
-
return deviceIdentities.map(identity => (Object.assign(Object.assign({}, identity), { deviceId: (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(identity.clientId).client,
|
|
120
|
+
return deviceIdentities.map(identity => (Object.assign(Object.assign({}, identity), { deviceId: (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(identity.clientId).client, qualifiedUserId: userClientsMap[identity.clientId] })));
|
|
102
121
|
}
|
|
103
122
|
async isFreshMLSSelfClient() {
|
|
104
123
|
const client = await this.clientService.loadClient();
|
|
105
|
-
|
|
124
|
+
if (!client) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
return !(0, Helper_1.isMLSDevice)(client);
|
|
106
128
|
}
|
|
107
129
|
async registerLocalCertificateRoot(acmeService) {
|
|
108
130
|
const localCertificateRoot = await acmeService.getLocalCertificateRoot();
|
|
@@ -117,7 +139,6 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
117
139
|
*/
|
|
118
140
|
async initialize(discoveryUrl) {
|
|
119
141
|
this._acmeService = new Connection_1.AcmeService(discoveryUrl);
|
|
120
|
-
this.mlsService.on('newCrlDistributionPoints', distributionPoints => this.handleNewCrlDistributionPoints(distributionPoints));
|
|
121
142
|
await this.registerServerCertificates();
|
|
122
143
|
await this.initialiseCrlDistributionTimers();
|
|
123
144
|
}
|
|
@@ -145,10 +166,12 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
145
166
|
* Both must be registered before the first enrollment.
|
|
146
167
|
*/
|
|
147
168
|
async registerServerCertificates() {
|
|
148
|
-
const
|
|
169
|
+
const ROOT_CA_KEY = 'e2ei_root-registered';
|
|
170
|
+
const store = (0, LocalStorageStore_1.LocalStorageStore)(this.coreDatabase.name);
|
|
149
171
|
// Register root certificate if not already registered
|
|
150
|
-
if (!
|
|
172
|
+
if (!store.has(ROOT_CA_KEY)) {
|
|
151
173
|
await this.registerLocalCertificateRoot(this.acmeService);
|
|
174
|
+
store.add(ROOT_CA_KEY, 'true');
|
|
152
175
|
}
|
|
153
176
|
// Register intermediate certificate and update it every 24 hours
|
|
154
177
|
const INTERMEDIATE_CA_KEY = 'update-intermediate-certificates';
|
|
@@ -17,28 +17,19 @@
|
|
|
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
|
-
};
|
|
23
20
|
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");
|
|
27
21
|
const E2EIServiceExternal_1 = require("./E2EIServiceExternal");
|
|
28
22
|
const CoreDB_1 = require("../../../storage/CoreDB");
|
|
29
23
|
const PayloadHelper_1 = require("../../../test/PayloadHelper");
|
|
30
24
|
const qualifiedIdUtil_1 = require("../../../util/qualifiedIdUtil");
|
|
31
25
|
const RecurringTaskScheduler_1 = require("../../../util/RecurringTaskScheduler");
|
|
32
|
-
async function buildE2EIService(
|
|
26
|
+
async function buildE2EIService() {
|
|
33
27
|
const coreCrypto = {
|
|
34
28
|
getUserIdentities: jest.fn(),
|
|
35
29
|
getClientIds: jest.fn().mockResolvedValue([]),
|
|
36
|
-
e2eiIsPKIEnvSetup: jest.fn(),
|
|
37
|
-
e2eiRegisterAcmeCA: jest.fn(),
|
|
38
|
-
e2eiRegisterIntermediateCA: jest.fn(),
|
|
39
30
|
};
|
|
40
31
|
const clientService = {};
|
|
41
|
-
const mockedDb = await (0, CoreDB_1.openDB)(
|
|
32
|
+
const mockedDb = await (0, CoreDB_1.openDB)('core-test-db');
|
|
42
33
|
const mockedMLSService = {
|
|
43
34
|
on: jest.fn(),
|
|
44
35
|
getClientIds: jest.fn(),
|
|
@@ -48,12 +39,12 @@ async function buildE2EIService(dbName = 'core-test-db') {
|
|
|
48
39
|
delete: key => mockedDb.delete('recurringTasks', key),
|
|
49
40
|
get: async (key) => { var _a; return (_a = (await mockedDb.get('recurringTasks', key))) === null || _a === void 0 ? void 0 : _a.firingDate; },
|
|
50
41
|
set: async (key, timestamp) => {
|
|
51
|
-
await mockedDb.put('recurringTasks', { key, firingDate: timestamp }
|
|
42
|
+
await mockedDb.put('recurringTasks', { key, firingDate: timestamp });
|
|
52
43
|
},
|
|
53
44
|
});
|
|
54
45
|
return [
|
|
55
46
|
new E2EIServiceExternal_1.E2EIServiceExternal(coreCrypto, mockedDb, recurringTaskScheduler, clientService, mockedMLSService),
|
|
56
|
-
{ coreCrypto, mlsService: mockedMLSService
|
|
47
|
+
{ coreCrypto, mlsService: mockedMLSService },
|
|
57
48
|
];
|
|
58
49
|
}
|
|
59
50
|
function generateCoreCryptoIdentity({ userId, status = 'Valid', deviceId = (0, PayloadHelper_1.getUUID)(), }) {
|
|
@@ -65,7 +56,6 @@ function generateCoreCryptoIdentity({ userId, status = 'Valid', deviceId = (0, P
|
|
|
65
56
|
certificate: '-----BEGIN CERTIFICATE-----\nMIICRTCCAeqgAwIBAgIQcpcbKbgHLM5qoB7xgxm6BTAKBggqhkjOPQQDAjAuMSww\nKgYDVQQDEyNlbG5hLndpcmUubGluayBFMkVJIEludGVybWVkaWF0ZSBDQTAeFw0y\nMzExMjIxMTIwMDVaFw0yMzExMjQxMTIwMDVaMDIxFzAVBgNVBAoTDmVsbmEud2ly\nZS5saW5rMRcwFQYDVQQDEw5BZHJpYW4gV2Vpc3MgMjAqMAUGAytlcAMhAMwP5B9X\nwanLL7JUmHEc1SJYAvHUvMnL1MS/D4CK3JaMo4IBEzCCAQ8wDgYDVR0PAQH/BAQD\nAgeAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAdBgNVHQ4EFgQUrIPC\nem20zAl1ybZqXm2LkvD2U1swHwYDVR0jBBgwFoAU5bQTjX1Ps09suTYe4tzXUKgl\nN9YwdwYDVR0RBHAwboYpaW06d2lyZWFwcD0lNDBhZHJpYW5fd2lyZTJAZWxuYS53\naXJlLmxpbmuGQWltOndpcmVhcHA9U0tIRHNFc09TODJUcldUSE5Fc1ZOQS9lYjll\nMDM4NjE4MzllOWRhQGVsbmEud2lyZS5saW5rMCUGDCsGAQQBgqRkxihAAQQVMBMC\nAQYEDGRlZmF1bHR0ZWFtcwQAMAoGCCqGSM49BAMCA0kAMEYCIQCQQHVAd6wjp2A+\nVvKIXu4oVlCMZkAUATU5bXY4njvapwIhAO8rION7Mz5rSjixJsdEL8E+HHsNvCax\ndjrSL0FL9SM6\n-----END CERTIFICATE-----\n',
|
|
66
57
|
status,
|
|
67
58
|
thumbprint: 'mNyAo88vAF5s7v0UWBNxlQKxP3dfT91A-4PbuzEA5uQ',
|
|
68
|
-
credentialType: core_crypto_1.CredentialType.X509,
|
|
69
59
|
};
|
|
70
60
|
}
|
|
71
61
|
const groupId = 'AAEAAhJrE+8TbFFUqiagedTYDUMAZWxuYS53aXJlLmxpbms=';
|
|
@@ -165,46 +155,4 @@ describe('E2EIServiceExternal', () => {
|
|
|
165
155
|
expect(userIdentities === null || userIdentities === void 0 ? void 0 : userIdentities.get((0, qualifiedIdUtil_1.stringifyQualifiedId)({ id: user2.userId, domain: user2.domain }))).toHaveLength(1);
|
|
166
156
|
});
|
|
167
157
|
});
|
|
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
|
-
});
|
|
210
158
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIClient } from '@wireapp/api-client';
|
|
2
|
-
import {
|
|
2
|
+
import { 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
|
|
27
|
+
generateCertificate(getOAuthToken: getTokenCallback, refresh: boolean): Promise<import("@wireapp/core-crypto").RotateBundle>;
|
|
28
28
|
private continueCertificateGeneration;
|
|
29
29
|
private initIdentity;
|
|
30
30
|
private getDirectory;
|