@wireapp/core 46.24.1 → 46.24.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/Account.d.ts +8 -7
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +23 -21
- package/lib/client/ClientService.js +1 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts +8 -12
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +13 -11
- package/lib/conversation/ConversationService/ConversationService.test.js +11 -5
- package/lib/messagingProtocols/common.types.d.ts +0 -9
- package/lib/messagingProtocols/common.types.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIService.types.d.ts +2 -2
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIService.types.js +1 -2
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.js +5 -6
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.js +15 -20
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts +3 -9
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.js +12 -30
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +2 -7
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.js +34 -0
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js +2 -2
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +31 -16
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +171 -74
- package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +151 -93
- package/lib/messagingProtocols/mls/types.d.ts +8 -0
- package/lib/messagingProtocols/mls/types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts +13 -4
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.js +62 -79
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts +2 -0
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts +3 -5
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.js +14 -14
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.js +1 -3
- package/lib/messagingProtocols/proteus/ProteusService/WithMockedGenerics.test.js +0 -3
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +0 -3
- package/lib/secretStore/secretKeyGenerator.d.ts +0 -1
- package/lib/secretStore/secretKeyGenerator.d.ts.map +1 -1
- package/lib/secretStore/secretKeyGenerator.js +1 -3
- package/package.json +6 -6
- package/lib/test/StoreHelper.d.ts +0 -2
- package/lib/test/StoreHelper.d.ts.map +0 -1
- package/lib/test/StoreHelper.js +0 -27
|
@@ -67,34 +67,25 @@ const defaultMLSInitConfig = {
|
|
|
67
67
|
ciphersuites: [core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519],
|
|
68
68
|
defaultCiphersuite: core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519,
|
|
69
69
|
};
|
|
70
|
-
// Needs to be divisible by 4 to be a valid base64 string
|
|
71
|
-
const mockGroupId = 'Z3JvdXAtdGVzdC0x';
|
|
72
|
-
const mockedMLSWelcomeEventData = '';
|
|
73
70
|
const createMLSService = async () => {
|
|
74
71
|
const apiClient = new api_client_1.APIClient();
|
|
75
|
-
const
|
|
76
|
-
mlsInit: jest.fn(),
|
|
77
|
-
wipeConversation: jest.fn(),
|
|
78
|
-
clientKeypackages: jest.fn(),
|
|
72
|
+
const mockCoreCrypto = {
|
|
79
73
|
createConversation: jest.fn(),
|
|
80
|
-
clientValidKeypackagesCount: jest.fn(),
|
|
81
74
|
conversationExists: jest.fn(),
|
|
75
|
+
wipeConversation: jest.fn(),
|
|
76
|
+
clientValidKeypackagesCount: jest.fn(),
|
|
77
|
+
clientKeypackages: jest.fn(),
|
|
78
|
+
mlsInit: jest.fn(),
|
|
79
|
+
clientPublicKey: jest.fn(),
|
|
82
80
|
processWelcomeMessage: jest.fn(),
|
|
81
|
+
conversationEpoch: jest.fn(),
|
|
83
82
|
commitPendingProposals: jest.fn(),
|
|
84
|
-
|
|
85
|
-
updateKeyingMaterial: jest.fn(),
|
|
86
|
-
};
|
|
87
|
-
const mockCoreCrypto = {
|
|
88
|
-
transaction: jest.fn(fn => {
|
|
89
|
-
return fn(transactionContext);
|
|
90
|
-
}),
|
|
91
|
-
registerEpochObserver: jest.fn(),
|
|
92
|
-
provideTransport: jest.fn(),
|
|
93
|
-
version: jest.fn(),
|
|
94
|
-
conversationExists: jest.fn(),
|
|
83
|
+
registerCallbacks: jest.fn(),
|
|
95
84
|
e2eiIsEnabled: jest.fn(() => false),
|
|
96
|
-
|
|
97
|
-
|
|
85
|
+
clearPendingGroupFromExternalCommit: async () => { },
|
|
86
|
+
clearPendingCommit: async () => { },
|
|
87
|
+
commitAccepted: jest.fn(),
|
|
88
|
+
transaction: jest.fn(),
|
|
98
89
|
};
|
|
99
90
|
const mockedDb = await (0, CoreDB_1.openDB)('core-test-db');
|
|
100
91
|
const recurringTaskScheduler = new RecurringTaskScheduler_1.RecurringTaskScheduler({
|
|
@@ -106,11 +97,8 @@ const createMLSService = async () => {
|
|
|
106
97
|
});
|
|
107
98
|
const mlsService = new MLSService_1.MLSService(apiClient, mockCoreCrypto, mockedDb, recurringTaskScheduler);
|
|
108
99
|
mlsService['_config'] = { ...defaultMLSInitConfig, nbKeyPackages: 100, keyingMaterialUpdateThreshold: 1 };
|
|
109
|
-
return [mlsService, { apiClient, coreCrypto: mockCoreCrypto, recurringTaskScheduler
|
|
100
|
+
return [mlsService, { apiClient, coreCrypto: mockCoreCrypto, recurringTaskScheduler }];
|
|
110
101
|
};
|
|
111
|
-
afterAll(() => {
|
|
112
|
-
jest.clearAllTimers();
|
|
113
|
-
});
|
|
114
102
|
describe('MLSService', () => {
|
|
115
103
|
describe('registerConversation', () => {
|
|
116
104
|
let mlsService;
|
|
@@ -124,6 +112,12 @@ describe('MLSService', () => {
|
|
|
124
112
|
.mockResolvedValue({ removal: { ed25519: 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm3OQFc=' } });
|
|
125
113
|
jest.spyOn(apiClient.api.client, 'claimMLSKeyPackages').mockResolvedValue({ key_packages: [] });
|
|
126
114
|
jest.spyOn(mlsService, 'scheduleKeyMaterialRenewal').mockImplementation();
|
|
115
|
+
jest.spyOn(mlsService, 'processCommitAction').mockImplementation(() => ({
|
|
116
|
+
failed_to_send: [],
|
|
117
|
+
failed: [],
|
|
118
|
+
events: [],
|
|
119
|
+
time: '',
|
|
120
|
+
}));
|
|
127
121
|
jest.spyOn(mlsService, 'cancelKeyMaterialRenewal').mockImplementation();
|
|
128
122
|
});
|
|
129
123
|
it('creates a new mls conversation and avoid adding the selfUser', async () => {
|
|
@@ -151,10 +145,37 @@ describe('MLSService', () => {
|
|
|
151
145
|
keyPackages: [],
|
|
152
146
|
failures: [failure],
|
|
153
147
|
});
|
|
154
|
-
const failures = await mlsService.registerConversation(groupId, [...users, selfUser], { creator });
|
|
148
|
+
const { failures } = await mlsService.registerConversation(groupId, [...users, selfUser], { creator });
|
|
155
149
|
expect(failures).toEqual([failure]);
|
|
156
150
|
expect(mlsService.scheduleKeyMaterialRenewal).toHaveBeenCalledWith(groupId);
|
|
157
151
|
});
|
|
152
|
+
it("returns a list of failure reasons if it was not possible to upload users' keys", async () => {
|
|
153
|
+
const groupId = 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm3OQFc=';
|
|
154
|
+
const selfUser = createUserId();
|
|
155
|
+
const creator = { user: selfUser, client: 'client-1' };
|
|
156
|
+
const users = [createUserId(), createUserId()];
|
|
157
|
+
const failureKeysClaiming = {
|
|
158
|
+
reason: conversation_1.AddUsersFailureReasons.OFFLINE_FOR_TOO_LONG,
|
|
159
|
+
users: [users[0]],
|
|
160
|
+
};
|
|
161
|
+
const failureKeysUpload = {
|
|
162
|
+
reason: conversation_1.AddUsersFailureReasons.UNREACHABLE_BACKENDS,
|
|
163
|
+
users: [users[1]],
|
|
164
|
+
backends: [users[1].domain],
|
|
165
|
+
};
|
|
166
|
+
jest.spyOn(mlsService, 'getKeyPackagesPayload').mockResolvedValueOnce({
|
|
167
|
+
keyPackages: [new Uint8Array()],
|
|
168
|
+
failures: [failureKeysClaiming],
|
|
169
|
+
});
|
|
170
|
+
jest.spyOn(mlsService, 'addUsersToExistingConversation').mockResolvedValueOnce({
|
|
171
|
+
failures: [failureKeysUpload],
|
|
172
|
+
events: [],
|
|
173
|
+
time: '',
|
|
174
|
+
});
|
|
175
|
+
const { failures } = await mlsService.registerConversation(groupId, [...users, selfUser], { creator });
|
|
176
|
+
expect(failures).toEqual([failureKeysClaiming, failureKeysUpload]);
|
|
177
|
+
expect(mlsService.scheduleKeyMaterialRenewal).toHaveBeenCalledWith(groupId);
|
|
178
|
+
});
|
|
158
179
|
});
|
|
159
180
|
describe('getKeyPackagesPayload', () => {
|
|
160
181
|
it('succesfully claims keys for all users', async () => {
|
|
@@ -189,24 +210,24 @@ describe('MLSService', () => {
|
|
|
189
210
|
});
|
|
190
211
|
describe('isConversationEstablished', () => {
|
|
191
212
|
it('returns false if conversation does not exist locally', async () => {
|
|
192
|
-
const [mlsService
|
|
213
|
+
const [mlsService] = await createMLSService();
|
|
193
214
|
const groupId = 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm3OQFc=';
|
|
194
|
-
jest.spyOn(
|
|
215
|
+
jest.spyOn(mlsService, 'conversationExists').mockResolvedValueOnce(false);
|
|
195
216
|
const isEstablshed = await mlsService.isConversationEstablished(groupId);
|
|
196
217
|
expect(isEstablshed).toBe(false);
|
|
197
218
|
});
|
|
198
219
|
it('returns false if epoch number is 0', async () => {
|
|
199
|
-
const [mlsService
|
|
220
|
+
const [mlsService] = await createMLSService();
|
|
200
221
|
const groupId = 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm3OQFc=';
|
|
201
|
-
jest.spyOn(
|
|
222
|
+
jest.spyOn(mlsService, 'conversationExists').mockResolvedValueOnce(true);
|
|
202
223
|
jest.spyOn(mlsService, 'getEpoch').mockResolvedValueOnce(0);
|
|
203
224
|
const isEstablshed = await mlsService.isConversationEstablished(groupId);
|
|
204
225
|
expect(isEstablshed).toBe(false);
|
|
205
226
|
});
|
|
206
227
|
it.each([1, 2, 100])('returns false if epoch number is 1 or more', async (epoch) => {
|
|
207
|
-
const [mlsService
|
|
228
|
+
const [mlsService] = await createMLSService();
|
|
208
229
|
const groupId = 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm3OQFc=';
|
|
209
|
-
jest.spyOn(
|
|
230
|
+
jest.spyOn(mlsService, 'conversationExists').mockResolvedValueOnce(true);
|
|
210
231
|
jest.spyOn(mlsService, 'getEpoch').mockResolvedValueOnce(epoch);
|
|
211
232
|
const isEstablshed = await mlsService.isConversationEstablished(groupId);
|
|
212
233
|
expect(isEstablshed).toBe(true);
|
|
@@ -276,7 +297,7 @@ describe('MLSService', () => {
|
|
|
276
297
|
});
|
|
277
298
|
describe('initClient', () => {
|
|
278
299
|
it('uses the default config if config is not provided by the consumer', async () => {
|
|
279
|
-
const [mlsService, { apiClient, coreCrypto
|
|
300
|
+
const [mlsService, { apiClient, coreCrypto }] = await createMLSService();
|
|
280
301
|
const mockUserId = { id: 'user-1', domain: 'local.zinfra.io' };
|
|
281
302
|
const mockClientId = 'client-1';
|
|
282
303
|
const mockClient = { mls_public_keys: {}, id: mockClientId };
|
|
@@ -287,11 +308,11 @@ describe('MLSService', () => {
|
|
|
287
308
|
jest.spyOn(apiClient.api.client, 'getMLSKeyPackageCount').mockResolvedValueOnce(mlsService.config.nbKeyPackages);
|
|
288
309
|
const config = { ...defaultMLSInitConfig };
|
|
289
310
|
await mlsService.initClient(mockUserId, mockClient, config);
|
|
290
|
-
expect(
|
|
311
|
+
expect(coreCrypto.mlsInit).toHaveBeenCalledWith(expect.any(Uint8Array), [core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519], 100);
|
|
291
312
|
expect(mlsService.config.nbKeyPackages).toEqual(100);
|
|
292
313
|
});
|
|
293
314
|
it('uses the config provided by the consumer', async () => {
|
|
294
|
-
const [mlsService, { apiClient,
|
|
315
|
+
const [mlsService, { apiClient, coreCrypto }] = await createMLSService();
|
|
295
316
|
const mockUserId = { id: 'user-1', domain: 'local.zinfra.io' };
|
|
296
317
|
const mockClientId = 'client-1';
|
|
297
318
|
const mockClient = { mls_public_keys: {}, id: mockClientId };
|
|
@@ -302,11 +323,11 @@ describe('MLSService', () => {
|
|
|
302
323
|
jest.spyOn(apiClient.api.client, 'getMLSKeyPackageCount').mockResolvedValueOnce(mlsService.config.nbKeyPackages);
|
|
303
324
|
const config = { ...defaultMLSInitConfig, nbKeyPackages: 40, keyingMaterialUpdateThreshold: TimeUtil_1.TimeInMillis.DAY };
|
|
304
325
|
await mlsService.initClient(mockUserId, mockClient, config);
|
|
305
|
-
expect(
|
|
326
|
+
expect(coreCrypto.mlsInit).toHaveBeenCalledWith(expect.any(Uint8Array), [core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519], config.nbKeyPackages);
|
|
306
327
|
expect(mlsService.config).toEqual(config);
|
|
307
328
|
});
|
|
308
329
|
it('uses the default config value when provided with undefined by the consumer', async () => {
|
|
309
|
-
const [mlsService, { apiClient,
|
|
330
|
+
const [mlsService, { apiClient, coreCrypto }] = await createMLSService();
|
|
310
331
|
const mockUserId = { id: 'user-1', domain: 'local.zinfra.io' };
|
|
311
332
|
const mockClientId = 'client-1';
|
|
312
333
|
const mockClient = { mls_public_keys: {}, id: mockClientId };
|
|
@@ -321,11 +342,11 @@ describe('MLSService', () => {
|
|
|
321
342
|
keyingMaterialUpdateThreshold: TimeUtil_1.TimeInMillis.DAY,
|
|
322
343
|
};
|
|
323
344
|
await mlsService.initClient(mockUserId, mockClient, config);
|
|
324
|
-
expect(
|
|
345
|
+
expect(coreCrypto.mlsInit).toHaveBeenCalledWith(expect.any(Uint8Array), [core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519], 100);
|
|
325
346
|
expect(mlsService.config).toEqual({ ...config, nbKeyPackages: 100 });
|
|
326
347
|
});
|
|
327
348
|
it('uploads public key only if it was not yet defined on client entity', async () => {
|
|
328
|
-
const [mlsService, { apiClient,
|
|
349
|
+
const [mlsService, { apiClient, coreCrypto }] = await createMLSService();
|
|
329
350
|
const mockUserId = { id: 'user-1', domain: 'local.zinfra.io' };
|
|
330
351
|
const mockClientId = 'client-1';
|
|
331
352
|
const mockClient = { mls_public_keys: {}, id: mockClientId };
|
|
@@ -335,17 +356,17 @@ describe('MLSService', () => {
|
|
|
335
356
|
jest.spyOn(Helper, 'getMLSDeviceStatus').mockReturnValueOnce(Helper.MLSDeviceStatus.FRESH);
|
|
336
357
|
jest.spyOn(coreCrypto, 'clientPublicKey').mockResolvedValue(new Uint8Array());
|
|
337
358
|
await mlsService.initClient(mockUserId, mockClient, defaultMLSInitConfig);
|
|
338
|
-
expect(
|
|
359
|
+
expect(coreCrypto.mlsInit).toHaveBeenCalled();
|
|
339
360
|
expect(apiClient.api.client.putClient).toHaveBeenCalledWith(mockClientId, expect.anything());
|
|
340
361
|
});
|
|
341
362
|
it('uploads key packages if there are not enough keys on backend', async () => {
|
|
342
|
-
const [mlsService, { apiClient,
|
|
363
|
+
const [mlsService, { apiClient, coreCrypto }] = await createMLSService();
|
|
343
364
|
const mockUserId = { id: 'user-1', domain: 'local.zinfra.io' };
|
|
344
365
|
const mockClientId = 'client-1';
|
|
345
366
|
const mockClient = { mls_public_keys: { ed25519: 'key' }, id: mockClientId };
|
|
346
367
|
apiClient.context = { clientType: client_1.ClientType.PERMANENT, clientId: mockClientId, userId: '' };
|
|
347
368
|
const mockedClientKeyPackages = [new Uint8Array()];
|
|
348
|
-
jest.spyOn(
|
|
369
|
+
jest.spyOn(coreCrypto, 'clientKeypackages').mockResolvedValueOnce(mockedClientKeyPackages);
|
|
349
370
|
jest.spyOn(coreCrypto, 'clientPublicKey').mockResolvedValueOnce(new Uint8Array());
|
|
350
371
|
jest.spyOn(Helper, 'getMLSDeviceStatus').mockReturnValueOnce(Helper.MLSDeviceStatus.REGISTERED);
|
|
351
372
|
jest.spyOn(apiClient.api.client, 'uploadMLSKeyPackages').mockResolvedValueOnce(undefined);
|
|
@@ -353,11 +374,11 @@ describe('MLSService', () => {
|
|
|
353
374
|
.spyOn(apiClient.api.client, 'getMLSKeyPackageCount')
|
|
354
375
|
.mockResolvedValueOnce(mlsService['minRequiredKeyPackages'] - 1);
|
|
355
376
|
await mlsService.initClient(mockUserId, mockClient, defaultMLSInitConfig);
|
|
356
|
-
expect(
|
|
377
|
+
expect(coreCrypto.mlsInit).toHaveBeenCalled();
|
|
357
378
|
expect(apiClient.api.client.uploadMLSKeyPackages).toHaveBeenCalledWith(mockClientId, expect.anything());
|
|
358
379
|
});
|
|
359
380
|
it('does not upload public key or key packages if both are already uploaded', async () => {
|
|
360
|
-
const [mlsService, { apiClient,
|
|
381
|
+
const [mlsService, { apiClient, coreCrypto }] = await createMLSService();
|
|
361
382
|
const mockUserId = { id: 'user-1', domain: 'local.zinfra.io' };
|
|
362
383
|
const mockClientId = 'client-1';
|
|
363
384
|
const mockClient = { mls_public_keys: { ed25519: 'key' }, id: mockClientId };
|
|
@@ -368,67 +389,97 @@ describe('MLSService', () => {
|
|
|
368
389
|
jest.spyOn(apiClient.api.client, 'putClient');
|
|
369
390
|
jest.spyOn(coreCrypto, 'clientPublicKey').mockResolvedValueOnce(new Uint8Array());
|
|
370
391
|
await mlsService.initClient(mockUserId, mockClient, defaultMLSInitConfig);
|
|
371
|
-
expect(
|
|
392
|
+
expect(coreCrypto.mlsInit).toHaveBeenCalled();
|
|
372
393
|
expect(apiClient.api.client.uploadMLSKeyPackages).not.toHaveBeenCalled();
|
|
373
394
|
expect(apiClient.api.client.putClient).not.toHaveBeenCalled();
|
|
374
395
|
});
|
|
375
396
|
});
|
|
376
397
|
describe('wipeConversation', () => {
|
|
377
398
|
it('wipes a group and cancels its timers', async () => {
|
|
378
|
-
const [mlsService, {
|
|
399
|
+
const [mlsService, { coreCrypto, recurringTaskScheduler }] = await createMLSService();
|
|
379
400
|
const groupId = 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm4OQFc=';
|
|
380
|
-
|
|
381
|
-
transactionContext.wipeConversation = jest.fn().mockResolvedValue(undefined);
|
|
401
|
+
jest.spyOn(coreCrypto, 'conversationExists').mockResolvedValueOnce(true);
|
|
382
402
|
jest.spyOn(recurringTaskScheduler, 'cancelTask');
|
|
383
403
|
jest.spyOn(TaskScheduler_1.TaskScheduler, 'cancelTask');
|
|
384
404
|
await mlsService.wipeConversation(groupId);
|
|
385
405
|
expect(recurringTaskScheduler.cancelTask).toHaveBeenCalledWith(expect.stringContaining(groupId));
|
|
386
406
|
expect(TaskScheduler_1.TaskScheduler.cancelTask).toHaveBeenCalledWith(expect.stringContaining(groupId));
|
|
387
|
-
expect(
|
|
407
|
+
expect(coreCrypto.wipeConversation).toHaveBeenCalled();
|
|
388
408
|
});
|
|
389
409
|
it('does not try to wipe a group if it does not exist already', async () => {
|
|
390
|
-
const [mlsService, {
|
|
410
|
+
const [mlsService, { coreCrypto, recurringTaskScheduler }] = await createMLSService();
|
|
391
411
|
const groupId = 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm4OQFc=';
|
|
392
|
-
|
|
393
|
-
transactionContext.wipeConversation = jest.fn().mockResolvedValue(undefined);
|
|
412
|
+
jest.spyOn(coreCrypto, 'conversationExists').mockResolvedValueOnce(false);
|
|
394
413
|
jest.spyOn(recurringTaskScheduler, 'cancelTask');
|
|
395
414
|
jest.spyOn(TaskScheduler_1.TaskScheduler, 'cancelTask');
|
|
396
415
|
await mlsService.wipeConversation(groupId);
|
|
397
416
|
expect(recurringTaskScheduler.cancelTask).toHaveBeenCalledWith(expect.stringContaining(groupId));
|
|
398
417
|
expect(TaskScheduler_1.TaskScheduler.cancelTask).toHaveBeenCalledWith(expect.stringContaining(groupId));
|
|
399
|
-
expect(
|
|
418
|
+
expect(coreCrypto.wipeConversation).not.toHaveBeenCalled();
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
describe('commitPendingProposals', () => {
|
|
422
|
+
it('commits pending proposals and uploads received commit bundle to backend', async () => {
|
|
423
|
+
const [mlsService, { coreCrypto: mockCoreCrypto, apiClient }] = await createMLSService();
|
|
424
|
+
const mockGroupId = 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm3OQFc=';
|
|
425
|
+
jest.spyOn(mockCoreCrypto, 'commitPendingProposals').mockResolvedValueOnce({
|
|
426
|
+
commit: new Uint8Array(),
|
|
427
|
+
groupInfo: { payload: new Uint8Array() },
|
|
428
|
+
});
|
|
429
|
+
jest.spyOn(apiClient.api.conversation, 'postMlsCommitBundle').mockResolvedValueOnce({ events: [], time: '' });
|
|
430
|
+
await mlsService.commitPendingProposals(mockGroupId);
|
|
431
|
+
expect(mockCoreCrypto.commitPendingProposals).toHaveBeenCalled();
|
|
432
|
+
expect(apiClient.api.conversation.postMlsCommitBundle).toHaveBeenCalled();
|
|
433
|
+
});
|
|
434
|
+
it('clears pending commit and retries when failed committing pending proposals', async () => {
|
|
435
|
+
const [mlsService, { coreCrypto: mockCoreCrypto, apiClient }] = await createMLSService();
|
|
436
|
+
const mockGroupId = 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm3OQFc=';
|
|
437
|
+
jest.spyOn(mockCoreCrypto, 'commitPendingProposals').mockRejectedValueOnce(new Error('mocked error'));
|
|
438
|
+
jest.spyOn(mockCoreCrypto, 'commitPendingProposals').mockResolvedValueOnce({
|
|
439
|
+
commit: new Uint8Array(),
|
|
440
|
+
groupInfo: { payload: new Uint8Array() },
|
|
441
|
+
});
|
|
442
|
+
jest.spyOn(apiClient.api.conversation, 'postMlsCommitBundle').mockResolvedValueOnce({ events: [], time: '' });
|
|
443
|
+
jest.spyOn(mockCoreCrypto, 'clearPendingCommit');
|
|
444
|
+
jest.spyOn(mockCoreCrypto, 'clearPendingGroupFromExternalCommit');
|
|
445
|
+
await mlsService.commitPendingProposals(mockGroupId);
|
|
446
|
+
expect(mockCoreCrypto.clearPendingCommit).toHaveBeenCalledTimes(1);
|
|
447
|
+
expect(mockCoreCrypto.clearPendingGroupFromExternalCommit).toHaveBeenCalledTimes(1);
|
|
448
|
+
expect(mockCoreCrypto.commitPendingProposals).toHaveBeenCalledTimes(2);
|
|
449
|
+
expect(apiClient.api.conversation.postMlsCommitBundle).toHaveBeenCalledTimes(1);
|
|
400
450
|
});
|
|
401
451
|
});
|
|
402
452
|
describe('handleMLSMessageAddEvent', () => {
|
|
403
453
|
it('decrypts a message and emits new epoch event if epoch has changed', async () => {
|
|
404
|
-
const [mlsService, {
|
|
454
|
+
const [mlsService, { coreCrypto: mockCoreCrypto }] = await createMLSService();
|
|
405
455
|
const mockGroupId = 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm3OQFc=';
|
|
406
456
|
const mockedNewEpoch = 3;
|
|
407
457
|
const getGroupIdFromConversationId = () => Promise.resolve(mockGroupId);
|
|
408
458
|
const mockedDecryptoedMessage = {
|
|
409
459
|
hasEpochChanged: true,
|
|
410
460
|
isActive: false,
|
|
461
|
+
proposals: [],
|
|
411
462
|
};
|
|
412
|
-
jest.spyOn(
|
|
413
|
-
jest.spyOn(
|
|
463
|
+
jest.spyOn(mockCoreCrypto, 'transaction').mockResolvedValueOnce(mockedDecryptoedMessage);
|
|
464
|
+
jest.spyOn(mockCoreCrypto, 'conversationEpoch').mockResolvedValueOnce(mockedNewEpoch);
|
|
414
465
|
jest.spyOn(mlsService, 'emit').mockImplementation(jest.fn());
|
|
415
466
|
const mockedMLSWelcomeEvent = {
|
|
416
467
|
type: event_1.CONVERSATION_EVENT.MLS_MESSAGE_ADD,
|
|
417
468
|
senderClientId: '',
|
|
418
469
|
conversation: '',
|
|
419
|
-
data:
|
|
470
|
+
data: '',
|
|
420
471
|
from: '',
|
|
421
472
|
time: '',
|
|
422
473
|
};
|
|
423
474
|
await mlsService.handleMLSMessageAddEvent(mockedMLSWelcomeEvent, getGroupIdFromConversationId);
|
|
424
|
-
expect(
|
|
475
|
+
expect(mockCoreCrypto.transaction).toHaveBeenCalled();
|
|
425
476
|
expect(mlsService.emit).toHaveBeenCalledWith(MLSService_1.MLSServiceEvents.NEW_EPOCH, {
|
|
426
477
|
epoch: mockedNewEpoch,
|
|
427
478
|
groupId: mockGroupId,
|
|
428
479
|
});
|
|
429
480
|
});
|
|
430
481
|
it('handles pending propoals with a delay after decrypting a message', async () => {
|
|
431
|
-
const [mlsService, {
|
|
482
|
+
const [mlsService, { coreCrypto: mockCoreCrypto }] = await createMLSService();
|
|
432
483
|
jest.useFakeTimers();
|
|
433
484
|
const mockGroupId = 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm3OQFc=';
|
|
434
485
|
const mockedNewEpoch = 3;
|
|
@@ -437,117 +488,122 @@ describe('MLSService', () => {
|
|
|
437
488
|
const mockedDecryptoedMessage = {
|
|
438
489
|
hasEpochChanged: true,
|
|
439
490
|
isActive: false,
|
|
491
|
+
proposals: [],
|
|
440
492
|
commitDelay,
|
|
441
493
|
};
|
|
442
|
-
jest.spyOn(
|
|
443
|
-
jest.spyOn(
|
|
494
|
+
jest.spyOn(mockCoreCrypto, 'transaction').mockResolvedValueOnce(mockedDecryptoedMessage);
|
|
495
|
+
jest.spyOn(mockCoreCrypto, 'conversationEpoch').mockResolvedValueOnce(mockedNewEpoch);
|
|
444
496
|
jest.spyOn(mlsService, 'commitPendingProposals');
|
|
445
497
|
const mockedMLSWelcomeEvent = {
|
|
446
498
|
type: event_1.CONVERSATION_EVENT.MLS_MESSAGE_ADD,
|
|
447
499
|
senderClientId: '',
|
|
448
500
|
conversation: '',
|
|
449
|
-
data:
|
|
501
|
+
data: '',
|
|
450
502
|
from: '',
|
|
451
503
|
time: new Date().toISOString(),
|
|
452
504
|
};
|
|
453
505
|
await mlsService.handleMLSMessageAddEvent(mockedMLSWelcomeEvent, getGroupIdFromConversationId);
|
|
506
|
+
expect(mockCoreCrypto.commitPendingProposals).not.toHaveBeenCalled();
|
|
454
507
|
jest.advanceTimersByTime(commitDelay);
|
|
455
|
-
expect(
|
|
508
|
+
expect(mockCoreCrypto.transaction).toHaveBeenCalled();
|
|
509
|
+
expect(mockCoreCrypto.commitPendingProposals).toHaveBeenCalled();
|
|
456
510
|
});
|
|
457
511
|
});
|
|
458
512
|
describe('handleMLSWelcomeMessageEvent', () => {
|
|
459
513
|
it("before processing welcome it verifies that there's enough key packages locally", async () => {
|
|
460
|
-
const [mlsService, { apiClient,
|
|
514
|
+
const [mlsService, { apiClient, coreCrypto }] = await createMLSService();
|
|
461
515
|
const mockClientId = 'client-1';
|
|
462
516
|
const mockClient = { mls_public_keys: { ed25519: 'key' }, id: mockClientId };
|
|
463
517
|
apiClient.context = { clientType: client_1.ClientType.PERMANENT, clientId: mockClientId, userId: '' };
|
|
464
518
|
const mockedClientKeyPackages = [new Uint8Array()];
|
|
465
|
-
jest.spyOn(
|
|
519
|
+
jest.spyOn(coreCrypto, 'clientKeypackages').mockResolvedValueOnce(mockedClientKeyPackages);
|
|
466
520
|
const numberOfKeysBelowThreshold = mlsService['minRequiredKeyPackages'] - 1;
|
|
467
521
|
jest.spyOn(apiClient.api.client, 'getMLSKeyPackageCount').mockResolvedValueOnce(numberOfKeysBelowThreshold);
|
|
468
|
-
jest.spyOn(
|
|
522
|
+
jest.spyOn(coreCrypto, 'clientValidKeypackagesCount').mockResolvedValueOnce(numberOfKeysBelowThreshold);
|
|
469
523
|
jest.spyOn(apiClient.api.client, 'uploadMLSKeyPackages').mockResolvedValueOnce(undefined);
|
|
470
524
|
jest
|
|
471
|
-
.spyOn(
|
|
472
|
-
.
|
|
525
|
+
.spyOn(coreCrypto, 'processWelcomeMessage')
|
|
526
|
+
.mockResolvedValueOnce({ id: new Uint8Array(), crlNewDistributionPoints: [] });
|
|
473
527
|
jest.spyOn(mlsService, 'scheduleKeyMaterialRenewal').mockImplementation(jest.fn());
|
|
474
528
|
const mockedMLSWelcomeEvent = {
|
|
475
529
|
type: event_1.CONVERSATION_EVENT.MLS_WELCOME_MESSAGE,
|
|
476
530
|
conversation: '',
|
|
477
|
-
data:
|
|
531
|
+
data: '',
|
|
478
532
|
from: '',
|
|
479
533
|
time: '',
|
|
480
534
|
};
|
|
481
535
|
await mlsService.handleMLSWelcomeMessageEvent(mockedMLSWelcomeEvent, mockClient.id);
|
|
482
|
-
expect(
|
|
536
|
+
expect(coreCrypto.processWelcomeMessage).toHaveBeenCalled();
|
|
483
537
|
expect(apiClient.api.client.uploadMLSKeyPackages).toHaveBeenCalledWith(mockClientId, expect.anything());
|
|
484
538
|
});
|
|
485
539
|
it('before processing welcome it does not generate new keys if there is enough key packages locally', async () => {
|
|
486
|
-
const [mlsService, { apiClient,
|
|
540
|
+
const [mlsService, { apiClient, coreCrypto }] = await createMLSService();
|
|
487
541
|
const mockClientId = 'client-1';
|
|
488
542
|
const mockClient = { mls_public_keys: { ed25519: 'key' }, id: mockClientId };
|
|
489
543
|
apiClient.context = { clientType: client_1.ClientType.PERMANENT, clientId: mockClientId, userId: '' };
|
|
490
544
|
const mockedClientKeyPackages = [new Uint8Array()];
|
|
491
|
-
jest.spyOn(
|
|
545
|
+
jest.spyOn(coreCrypto, 'clientKeypackages').mockResolvedValueOnce(mockedClientKeyPackages);
|
|
492
546
|
const numberOfKeysAboveThreshold = mlsService['minRequiredKeyPackages'] + 1;
|
|
493
|
-
jest.spyOn(
|
|
547
|
+
jest.spyOn(coreCrypto, 'clientValidKeypackagesCount').mockResolvedValueOnce(numberOfKeysAboveThreshold);
|
|
494
548
|
jest.spyOn(apiClient.api.client, 'getMLSKeyPackageCount').mockResolvedValueOnce(numberOfKeysAboveThreshold);
|
|
495
549
|
jest.spyOn(apiClient.api.client, 'uploadMLSKeyPackages').mockResolvedValueOnce(undefined);
|
|
496
550
|
jest
|
|
497
|
-
.spyOn(
|
|
498
|
-
.
|
|
551
|
+
.spyOn(coreCrypto, 'processWelcomeMessage')
|
|
552
|
+
.mockResolvedValueOnce({ id: new Uint8Array(), crlNewDistributionPoints: [] });
|
|
499
553
|
jest.spyOn(mlsService, 'scheduleKeyMaterialRenewal').mockImplementation(jest.fn());
|
|
500
554
|
const mockedMLSWelcomeEvent = {
|
|
501
555
|
type: event_1.CONVERSATION_EVENT.MLS_WELCOME_MESSAGE,
|
|
502
556
|
conversation: '',
|
|
503
|
-
data:
|
|
557
|
+
data: '',
|
|
504
558
|
from: '',
|
|
505
559
|
time: '',
|
|
506
560
|
};
|
|
507
561
|
await mlsService.handleMLSWelcomeMessageEvent(mockedMLSWelcomeEvent, mockClient.id);
|
|
508
|
-
expect(
|
|
562
|
+
expect(coreCrypto.processWelcomeMessage).toHaveBeenCalled();
|
|
509
563
|
expect(apiClient.api.client.uploadMLSKeyPackages).not.toHaveBeenCalled();
|
|
510
564
|
});
|
|
511
565
|
it('before processing welcome it does not generate new keys if there is enough key packages uploaded to backend', async () => {
|
|
512
|
-
const [mlsService, { apiClient,
|
|
566
|
+
const [mlsService, { apiClient, coreCrypto }] = await createMLSService();
|
|
513
567
|
const mockClientId = 'client-1';
|
|
514
568
|
const mockClient = { mls_public_keys: { ed25519: 'key' }, id: mockClientId };
|
|
515
569
|
apiClient.context = { clientType: client_1.ClientType.PERMANENT, clientId: mockClientId, userId: '' };
|
|
516
570
|
const mockedClientKeyPackages = [new Uint8Array()];
|
|
517
|
-
jest.spyOn(
|
|
571
|
+
jest.spyOn(coreCrypto, 'clientKeypackages').mockResolvedValueOnce(mockedClientKeyPackages);
|
|
518
572
|
const numberOfKeysBelowThreshold = mlsService['minRequiredKeyPackages'] - 1;
|
|
519
573
|
const numberOfKeysAboveThreshold = mlsService['minRequiredKeyPackages'] + 1;
|
|
520
|
-
jest.spyOn(
|
|
574
|
+
jest.spyOn(coreCrypto, 'clientValidKeypackagesCount').mockResolvedValueOnce(numberOfKeysBelowThreshold);
|
|
521
575
|
jest.spyOn(apiClient.api.client, 'getMLSKeyPackageCount').mockResolvedValueOnce(numberOfKeysAboveThreshold);
|
|
522
576
|
jest.spyOn(apiClient.api.client, 'uploadMLSKeyPackages').mockResolvedValueOnce(undefined);
|
|
523
577
|
jest
|
|
524
|
-
.spyOn(
|
|
525
|
-
.
|
|
578
|
+
.spyOn(coreCrypto, 'processWelcomeMessage')
|
|
579
|
+
.mockResolvedValueOnce({ id: new Uint8Array(), crlNewDistributionPoints: [] });
|
|
526
580
|
jest.spyOn(mlsService, 'scheduleKeyMaterialRenewal').mockImplementation(jest.fn());
|
|
527
581
|
const mockedMLSWelcomeEvent = {
|
|
528
582
|
type: event_1.CONVERSATION_EVENT.MLS_WELCOME_MESSAGE,
|
|
529
583
|
conversation: '',
|
|
530
|
-
data:
|
|
584
|
+
data: '',
|
|
531
585
|
from: '',
|
|
532
586
|
time: '',
|
|
533
587
|
};
|
|
534
588
|
await mlsService.handleMLSWelcomeMessageEvent(mockedMLSWelcomeEvent, mockClient.id);
|
|
535
|
-
expect(
|
|
589
|
+
expect(coreCrypto.processWelcomeMessage).toHaveBeenCalled();
|
|
536
590
|
expect(apiClient.api.client.uploadMLSKeyPackages).not.toHaveBeenCalled();
|
|
537
591
|
});
|
|
538
592
|
});
|
|
539
593
|
describe('tryEstablishingMLSGroup', () => {
|
|
540
594
|
it('returns false if group did already exist locally', async () => {
|
|
541
|
-
const [mlsService
|
|
542
|
-
|
|
595
|
+
const [mlsService] = await createMLSService();
|
|
596
|
+
const mockGroupId = 'mock-group-id';
|
|
597
|
+
jest.spyOn(mlsService, 'conversationExists').mockResolvedValueOnce(true);
|
|
543
598
|
jest.spyOn(mlsService, 'registerConversation').mockImplementation(jest.fn());
|
|
544
599
|
const wasConversationEstablished = await mlsService.tryEstablishingMLSGroup(mockGroupId);
|
|
545
600
|
expect(mlsService.registerConversation).not.toHaveBeenCalled();
|
|
546
601
|
expect(wasConversationEstablished).toBe(false);
|
|
547
602
|
});
|
|
548
603
|
it('returns false if corecrypto has thrown an error when trying to register group locally', async () => {
|
|
549
|
-
const [mlsService
|
|
550
|
-
|
|
604
|
+
const [mlsService] = await createMLSService();
|
|
605
|
+
const mockGroupId = 'mock-group-id';
|
|
606
|
+
jest.spyOn(mlsService, 'conversationExists').mockResolvedValueOnce(false);
|
|
551
607
|
const conversationAlreadyExistsError = new Error();
|
|
552
608
|
conversationAlreadyExistsError.name = CoreCryptoMLSError_1.CORE_CRYPTO_ERROR_NAMES.MlsErrorConversationAlreadyExists;
|
|
553
609
|
jest.spyOn(mlsService, 'registerConversation').mockRejectedValueOnce(conversationAlreadyExistsError);
|
|
@@ -556,8 +612,9 @@ describe('MLSService', () => {
|
|
|
556
612
|
expect(wasConversationEstablished).toBe(false);
|
|
557
613
|
});
|
|
558
614
|
it('returns false and wipes group locally if any backend error was thrown', async () => {
|
|
559
|
-
const [mlsService
|
|
560
|
-
|
|
615
|
+
const [mlsService] = await createMLSService();
|
|
616
|
+
const mockGroupId = 'mock-group-id2';
|
|
617
|
+
jest.spyOn(mlsService, 'conversationExists').mockResolvedValueOnce(false);
|
|
561
618
|
jest
|
|
562
619
|
.spyOn(mlsService, 'registerConversation')
|
|
563
620
|
.mockRejectedValueOnce(new http_1.BackendError('', http_1.BackendErrorLabel.MLS_STALE_MESSAGE, http_1.StatusCode.CONFLICT));
|
|
@@ -568,9 +625,10 @@ describe('MLSService', () => {
|
|
|
568
625
|
expect(wasConversationEstablished).toBe(false);
|
|
569
626
|
});
|
|
570
627
|
it('returns true after MLS group was etablished successfully', async () => {
|
|
571
|
-
const [mlsService
|
|
572
|
-
|
|
573
|
-
jest.spyOn(mlsService, '
|
|
628
|
+
const [mlsService] = await createMLSService();
|
|
629
|
+
const mockGroupId = 'mock-group-id2';
|
|
630
|
+
jest.spyOn(mlsService, 'conversationExists').mockResolvedValueOnce(false);
|
|
631
|
+
jest.spyOn(mlsService, 'registerConversation').mockResolvedValueOnce({ events: [], time: '', failures: [] });
|
|
574
632
|
jest.spyOn(mlsService, 'wipeConversation').mockImplementation(jest.fn());
|
|
575
633
|
const wasConversationEstablished = await mlsService.tryEstablishingMLSGroup(mockGroupId);
|
|
576
634
|
expect(mlsService.registerConversation).toHaveBeenCalledWith(mockGroupId, []);
|
|
@@ -20,4 +20,12 @@ export type HandlePendingProposalsParams = {
|
|
|
20
20
|
delayInMs: number;
|
|
21
21
|
eventTime: string;
|
|
22
22
|
} & CommonMLS;
|
|
23
|
+
export interface CoreCryptoConfig {
|
|
24
|
+
/**
|
|
25
|
+
* path on the public server to the core crypto wasm file.
|
|
26
|
+
* This file will be downloaded lazily when corecrypto is needed.
|
|
27
|
+
* It, thus, needs to know where, on the server, the file can be found
|
|
28
|
+
*/
|
|
29
|
+
wasmFilePath: string;
|
|
30
|
+
}
|
|
23
31
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/messagingProtocols/mls/types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACpD,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACvD,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,yBAAyB,EAAE,CAAC,cAAc,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACzF;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/messagingProtocols/mls/types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACpD,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACvD,CAAC;AAEF,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,yBAAyB,EAAE,CAAC,cAAc,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACzF;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,SAAS,CAAC;AAEd,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -2,19 +2,20 @@ import { PreKey } from '@wireapp/api-client/lib/auth';
|
|
|
2
2
|
import { CoreCrypto } from '@wireapp/core-crypto';
|
|
3
3
|
import type { CRUDEngine } from '@wireapp/store-engine';
|
|
4
4
|
import { GeneratedKey } from '../../../../../secretStore/secretKeyGenerator';
|
|
5
|
-
import { CoreCryptoConfig } from '../../../../common.types';
|
|
6
5
|
import { CryptoClient } from '../CryptoClient.types';
|
|
7
6
|
type Config = {
|
|
8
|
-
generateSecretKey: (keyId: string
|
|
7
|
+
generateSecretKey: (keyId: string) => Promise<GeneratedKey>;
|
|
9
8
|
nbPrekeys: number;
|
|
10
9
|
onNewPrekeys: (prekeys: PreKey[]) => void;
|
|
10
|
+
wasmFilePath: string;
|
|
11
11
|
};
|
|
12
|
-
type ClientConfig = Omit<Config, 'generateSecretKey'> & {
|
|
12
|
+
type ClientConfig = Omit<Config, 'generateSecretKey' | 'wasmFilePath'> & {
|
|
13
13
|
onWipe: () => Promise<void>;
|
|
14
14
|
};
|
|
15
|
-
export declare function buildClient(storeEngine: CRUDEngine, { generateSecretKey, nbPrekeys, onNewPrekeys }: Config
|
|
15
|
+
export declare function buildClient(storeEngine: CRUDEngine, { wasmFilePath, generateSecretKey, nbPrekeys, onNewPrekeys }: Config): Promise<CoreCryptoWrapper>;
|
|
16
16
|
export declare class CoreCryptoWrapper implements CryptoClient {
|
|
17
17
|
private readonly coreCrypto;
|
|
18
|
+
private readonly config;
|
|
18
19
|
private readonly prekeyTracker;
|
|
19
20
|
readonly version: string;
|
|
20
21
|
constructor(coreCrypto: CoreCrypto, config: ClientConfig);
|
|
@@ -42,7 +43,15 @@ export declare class CoreCryptoWrapper implements CryptoClient {
|
|
|
42
43
|
key: string;
|
|
43
44
|
}>;
|
|
44
45
|
debugBreakSession(sessionId: string): Promise<void>;
|
|
46
|
+
debugResetIdentity(): Promise<void>;
|
|
45
47
|
migrateFromCryptobox(dbName: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Will call the callback once corecrypto is ready.
|
|
50
|
+
* @param callback - Function to be called once corecrypto is ready.
|
|
51
|
+
* @see https://github.com/wireapp/wire-web-packages/pull/4972
|
|
52
|
+
*/
|
|
53
|
+
private onReady;
|
|
54
|
+
wipe(): Promise<void>;
|
|
46
55
|
}
|
|
47
56
|
export {};
|
|
48
57
|
//# sourceMappingURL=CoreCryptoWrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreCryptoWrapper.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAKpD,OAAO,
|
|
1
|
+
{"version":3,"file":"CoreCryptoWrapper.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAKpD,OAAO,EAAC,UAAU,EAAgD,MAAM,sBAAsB,CAAC;AAC/F,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAItD,OAAO,EAAoB,YAAY,EAAC,MAAM,+CAA+C,CAAC;AAC9F,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAEnD,KAAK,MAAM,GAAG;IACZ,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,KAAK,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,mBAAmB,GAAG,cAAc,CAAC,GAAG;IACvE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B,CAAC;AAmBF,wBAAsB,WAAW,CAC/B,WAAW,EAAE,UAAU,EACvB,EAAC,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAC,EAAE,MAAM,GACjE,OAAO,CAAC,iBAAiB,CAAC,CAyB5B;AAED,qBAAa,iBAAkB,YAAW,YAAY;IAKlD,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IALzB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,SAAgB,OAAO,EAAE,MAAM,CAAC;gBAGb,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,YAAY;IAMvC,eAAe;IAIf,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU;IAIjD,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;IAI9C,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM;IAOxB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU;;;;;;;IAqBpD,cAAc;IAId,oBAAoB,CAAC,SAAS,EAAE,MAAM;IAIhC,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;IAK/D,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IAIvD,aAAa,CAAC,SAAS,EAAE,MAAM;IAI/B,WAAW,CAAC,SAAS,EAAE,MAAM;IAI7B,aAAa,CAAC,SAAS,EAAE,MAAM;IAI/B,aAAa;IAIP,SAAS;;;;IAKT,iBAAiB,CAAC,SAAS,EAAE,MAAM;IAUnC,kBAAkB;IAIlB,oBAAoB,CAAC,MAAM,EAAE,MAAM;IAIzC;;;;OAIG;IACH,OAAO,CAAC,OAAO;IAgBT,IAAI;CAIX"}
|