@wireapp/core 46.24.4 → 46.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Account.d.ts +7 -8
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +17 -23
- package/lib/client/ClientService.js +1 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts +12 -8
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +11 -13
- package/lib/conversation/ConversationService/ConversationService.test.js +5 -11
- package/lib/messagingProtocols/common.types.d.ts +9 -0
- 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 +2 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.js +6 -5
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.js +20 -15
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts +9 -3
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.js +30 -12
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +7 -2
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.js +0 -34
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js +2 -2
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +16 -31
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +74 -171
- package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +93 -151
- package/lib/messagingProtocols/mls/types.d.ts +0 -8
- package/lib/messagingProtocols/mls/types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts +4 -13
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.js +79 -62
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts +0 -2
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts +5 -3
- 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 +3 -1
- package/lib/messagingProtocols/proteus/ProteusService/WithMockedGenerics.test.js +3 -0
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +3 -0
- package/lib/secretStore/secretKeyGenerator.d.ts +1 -0
- package/lib/secretStore/secretKeyGenerator.d.ts.map +1 -1
- package/lib/secretStore/secretKeyGenerator.js +3 -1
- package/lib/team/TeamService.d.ts +5 -2
- package/lib/team/TeamService.d.ts.map +1 -1
- package/lib/team/TeamService.js +12 -2
- package/lib/test/StoreHelper.d.ts +2 -0
- package/lib/test/StoreHelper.d.ts.map +1 -0
- package/lib/test/StoreHelper.js +27 -0
- package/package.json +6 -6
package/lib/Account.d.ts
CHANGED
|
@@ -12,10 +12,11 @@ import { AssetService, ConversationService } from './conversation/';
|
|
|
12
12
|
import { SubconversationService } from './conversation/SubconversationService/SubconversationService';
|
|
13
13
|
import { GiphyService } from './giphy/';
|
|
14
14
|
import { LinkPreviewService } from './linkPreview';
|
|
15
|
+
import { CoreCryptoConfig } from './messagingProtocols/common.types';
|
|
15
16
|
import { InitClientOptions, MLSService } from './messagingProtocols/mls';
|
|
16
17
|
import { E2EIServiceExternal } from './messagingProtocols/mls/E2EIdentityService';
|
|
17
|
-
import { getTokenCallback } from './messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal';
|
|
18
|
-
import { CoreCallbacks,
|
|
18
|
+
import { getAllConversationsCallback, getTokenCallback } from './messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal';
|
|
19
|
+
import { CoreCallbacks, SecretCrypto } from './messagingProtocols/mls/types';
|
|
19
20
|
import { NewClient, ProteusService } from './messagingProtocols/proteus';
|
|
20
21
|
import { HandledEventPayload, NotificationService, NotificationSource } from './notification/';
|
|
21
22
|
import { SelfService } from './self/';
|
|
@@ -38,6 +39,7 @@ interface AccountOptions {
|
|
|
38
39
|
/** Used to store info in the database (will create a inMemory engine if returns undefined) */
|
|
39
40
|
createStore?: CreateStoreFn;
|
|
40
41
|
systemCrypto?: SecretCrypto;
|
|
42
|
+
coreCryptoConfig?: CoreCryptoConfig;
|
|
41
43
|
/** Number of prekeys to generate when creating a new device (defaults to 2)
|
|
42
44
|
* Prekeys are Diffie-Hellmann public keys which allow offline initiation of a secure Proteus session between two devices.
|
|
43
45
|
* Having a high value will:
|
|
@@ -48,10 +50,6 @@ interface AccountOptions {
|
|
|
48
50
|
* - make it likely that all prekeys get consumed while the device is offline and the last resort prekey will be used to create new session
|
|
49
51
|
*/
|
|
50
52
|
nbPrekeys: number;
|
|
51
|
-
/**
|
|
52
|
-
* Config for coreCrypto in case it supposed to be used. Will fallback to the old cryptobox logic if not provided
|
|
53
|
-
*/
|
|
54
|
-
coreCryptoConfig?: CoreCryptoConfig;
|
|
55
53
|
}
|
|
56
54
|
type InitOptions = {
|
|
57
55
|
/** cookie used to identify the current user. Will use the browser cookie if not defined */
|
|
@@ -71,7 +69,6 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
71
69
|
private options;
|
|
72
70
|
private readonly apiClient;
|
|
73
71
|
private readonly logger;
|
|
74
|
-
private readonly coreCryptoConfig?;
|
|
75
72
|
/** this is the client the consumer is currently using. Will be set as soon as `initClient` is called and will be rest upon logout */
|
|
76
73
|
private currentClient?;
|
|
77
74
|
private storeEngine?;
|
|
@@ -117,7 +114,7 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
117
114
|
*/
|
|
118
115
|
useAPIVersion(min: number, max: number, allowDev?: boolean): Promise<BackendFeatures>;
|
|
119
116
|
private persistCookie;
|
|
120
|
-
enrollE2EI({ displayName, handle, teamId, discoveryUrl, getOAuthToken, certificateTtl, }: {
|
|
117
|
+
enrollE2EI({ displayName, handle, teamId, discoveryUrl, getOAuthToken, getAllConversations, certificateTtl, }: {
|
|
121
118
|
/** display name of the user (should match the identity provider) */
|
|
122
119
|
displayName: string;
|
|
123
120
|
/** handle of the user (should match the identity provider) */
|
|
@@ -127,6 +124,8 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
127
124
|
discoveryUrl: string;
|
|
128
125
|
/** function called to get the oauth token */
|
|
129
126
|
getOAuthToken: getTokenCallback;
|
|
127
|
+
/** function called to get all conversations */
|
|
128
|
+
getAllConversations: getAllConversationsCallback;
|
|
130
129
|
/** number of seconds the certificate should be valid (default 90 days) */
|
|
131
130
|
certificateTtl?: number;
|
|
132
131
|
}): Promise<void>;
|
package/lib/Account.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../src/Account.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EAGZ,OAAO,EACP,MAAM,EAEN,SAAS,EAEV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAuB,UAAU,EAAE,gBAAgB,E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QACH,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;QAE5D;;;;;;WAMG;QACH,qBAAqB,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;QAEzD;;WAEG;QACH,MAAM,CAAC,EAAE,OAAO,CAAC;KACb,GAAG,MAAM,IAAI;IAiGnB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,uBAAuB;YAIjB,UAAU;IAuBxB,OAAO,CAAC,yBAAyB,CAS/B;IAEW,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;CAetD"}
|
package/lib/Account.js
CHANGED
|
@@ -104,7 +104,6 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
104
104
|
options;
|
|
105
105
|
apiClient;
|
|
106
106
|
logger;
|
|
107
|
-
coreCryptoConfig;
|
|
108
107
|
/** this is the client the consumer is currently using. Will be set as soon as `initClient` is called and will be rest upon logout */
|
|
109
108
|
currentClient;
|
|
110
109
|
storeEngine;
|
|
@@ -118,12 +117,11 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
118
117
|
* @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
|
|
119
118
|
* @param accountOptions
|
|
120
119
|
*/
|
|
121
|
-
constructor(apiClient = new api_client_1.APIClient(), options = { nbPrekeys: 100 }) {
|
|
120
|
+
constructor(apiClient = new api_client_1.APIClient(), options = { nbPrekeys: 100, coreCryptoConfig: { wasmFilePath: '', enabled: false } }) {
|
|
122
121
|
super();
|
|
123
122
|
this.options = options;
|
|
124
123
|
this.apiClient = apiClient;
|
|
125
124
|
this.backendFeatures = this.apiClient.backendFeatures;
|
|
126
|
-
this.coreCryptoConfig = options.coreCryptoConfig;
|
|
127
125
|
this.recurringTaskScheduler = new RecurringTaskScheduler_1.RecurringTaskScheduler({
|
|
128
126
|
get: async (key) => {
|
|
129
127
|
const task = await this.db?.get('recurringTasks', key);
|
|
@@ -169,7 +167,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
169
167
|
const entity = { expiration: cookie.expiration, zuid: cookie.zuid };
|
|
170
168
|
return storeEngine.updateOrCreate(auth_1.AUTH_TABLE_NAME, auth_1.AUTH_COOKIE_KEY, entity);
|
|
171
169
|
}
|
|
172
|
-
async enrollE2EI({ displayName, handle, teamId, discoveryUrl, getOAuthToken, certificateTtl = 90 * (TimeUtil_1.TimeInMillis.DAY / 1000), }) {
|
|
170
|
+
async enrollE2EI({ displayName, handle, teamId, discoveryUrl, getOAuthToken, getAllConversations, certificateTtl = 90 * (TimeUtil_1.TimeInMillis.DAY / 1000), }) {
|
|
173
171
|
const context = this.apiClient.context;
|
|
174
172
|
const domain = context?.domain ?? '';
|
|
175
173
|
if (!this.currentClient) {
|
|
@@ -185,7 +183,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
185
183
|
teamId,
|
|
186
184
|
id: this.userId,
|
|
187
185
|
};
|
|
188
|
-
return this.service.mls.enrollE2EI(discoveryUrl, user, this.currentClient, this.options.nbPrekeys, certificateTtl, getOAuthToken);
|
|
186
|
+
return this.service.mls.enrollE2EI(discoveryUrl, user, this.currentClient, this.options.nbPrekeys, certificateTtl, getOAuthToken, getAllConversations);
|
|
189
187
|
}
|
|
190
188
|
get clientId() {
|
|
191
189
|
return this.apiClient.validatedClientId;
|
|
@@ -260,7 +258,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
260
258
|
this.apiClient.context.clientId = client.id;
|
|
261
259
|
// Call /access endpoint with client_id after client initialisation
|
|
262
260
|
await this.apiClient.transport.http.associateClientWithSession(client.id);
|
|
263
|
-
await this.service.proteus.initClient(this.
|
|
261
|
+
await this.service.proteus.initClient(this.apiClient.context);
|
|
264
262
|
if ((await this.isMLSActiveForClient()) && this.service.mls && mlsConfig) {
|
|
265
263
|
const { userId, domain = '' } = this.apiClient.context;
|
|
266
264
|
await this.service.mls.initClient({ id: userId, domain }, client, mlsConfig);
|
|
@@ -283,14 +281,12 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
283
281
|
this.logger.debug(`Successfully uploaded '${prekeys.length}' PreKeys.`);
|
|
284
282
|
},
|
|
285
283
|
};
|
|
286
|
-
|
|
287
|
-
if (coreCryptoConfig) {
|
|
284
|
+
if (this.options.coreCryptoConfig?.enabled) {
|
|
288
285
|
const { buildClient } = await Promise.resolve().then(() => __importStar(require('./messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper')));
|
|
289
286
|
const client = await buildClient(storeEngine, {
|
|
290
287
|
...baseConfig,
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
});
|
|
288
|
+
generateSecretKey: (keyId, keySize) => (0, secretKeyGenerator_1.generateSecretKey)({ keyId, keySize, secretsDb: encryptedStore }),
|
|
289
|
+
}, this.options.coreCryptoConfig);
|
|
294
290
|
return [CryptoClient_1.CryptoClientType.CORE_CRYPTO, client];
|
|
295
291
|
}
|
|
296
292
|
const { buildClient } = await Promise.resolve().then(() => __importStar(require('./messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper')));
|
|
@@ -323,7 +319,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
323
319
|
const proteusService = new proteus_1.ProteusService(this.apiClient, cryptoClient, {
|
|
324
320
|
onNewClient: payload => this.emit(EVENTS.NEW_SESSION, payload),
|
|
325
321
|
nbPrekeys: this.options.nbPrekeys,
|
|
326
|
-
});
|
|
322
|
+
}, this.storeEngine);
|
|
327
323
|
const clientService = new client_2.ClientService(this.apiClient, proteusService, this.storeEngine);
|
|
328
324
|
if (clientType === CryptoClient_1.CryptoClientType.CORE_CRYPTO && (await this.apiClient.supportsMLS())) {
|
|
329
325
|
mlsService = new mls_1.MLSService(this.apiClient, cryptoClient.getNativeClient(), this.db, this.recurringTaskScheduler);
|
|
@@ -388,7 +384,9 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
388
384
|
* Will delete the identity and history of the current user
|
|
389
385
|
*/
|
|
390
386
|
async wipeAllData() {
|
|
391
|
-
|
|
387
|
+
if (this.storeEngine) {
|
|
388
|
+
await (0, identityClearer_1.deleteIdentity)(this.storeEngine, false);
|
|
389
|
+
}
|
|
392
390
|
if (this.db) {
|
|
393
391
|
await (0, CoreDB_1.deleteDB)(this.db);
|
|
394
392
|
}
|
|
@@ -399,7 +397,6 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
399
397
|
* Will keep the history intact
|
|
400
398
|
*/
|
|
401
399
|
async wipeCryptoData() {
|
|
402
|
-
await this.service?.proteus.wipe();
|
|
403
400
|
if (this.storeEngine) {
|
|
404
401
|
await (0, identityClearer_1.deleteIdentity)(this.storeEngine, true);
|
|
405
402
|
}
|
|
@@ -534,20 +531,17 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
534
531
|
return this.service?.subconversation.getSubconversationGroupId(conversationId, subconversationId);
|
|
535
532
|
};
|
|
536
533
|
async isMLSActiveForClient() {
|
|
537
|
-
//
|
|
538
|
-
|
|
539
|
-
if (!isMLSServiceInitialized) {
|
|
534
|
+
// Check for CoreCrypto library, it is required for MLS
|
|
535
|
+
if (!this.options.coreCryptoConfig?.enabled) {
|
|
540
536
|
return false;
|
|
541
537
|
}
|
|
542
|
-
//
|
|
543
|
-
|
|
544
|
-
if (!isMLSSupported) {
|
|
538
|
+
// Check if the backend supports MLS trough removal keys
|
|
539
|
+
if (!(await this.apiClient.supportsMLS())) {
|
|
545
540
|
return false;
|
|
546
541
|
}
|
|
547
|
-
// MLS is enabled for the public via feature flag
|
|
542
|
+
// Check if MLS is enabled for the public via backend feature flag
|
|
548
543
|
const commonConfig = (await this.service?.team.getCommonFeatureConfig()) ?? {};
|
|
549
|
-
|
|
550
|
-
return isMLSSupported && isMLSForTeamEnabled && isMLSServiceInitialized;
|
|
544
|
+
return commonConfig[team_1.FEATURE_KEY.MLS]?.status === team_1.FeatureStatus.ENABLED;
|
|
551
545
|
}
|
|
552
546
|
}
|
|
553
547
|
exports.Account = Account;
|
|
@@ -105,7 +105,7 @@ class ClientService {
|
|
|
105
105
|
const notFoundOnBackend = axios_1.default.isAxiosError(error) ? error.response?.status === http_status_codes_1.StatusCodes.NOT_FOUND : false;
|
|
106
106
|
if (notFoundOnBackend && this.storeEngine) {
|
|
107
107
|
const shouldDeleteWholeDatabase = loadedClient.type === client_1.ClientType.TEMPORARY;
|
|
108
|
-
await this.proteusService.wipe(
|
|
108
|
+
await this.proteusService.wipe();
|
|
109
109
|
if (shouldDeleteWholeDatabase) {
|
|
110
110
|
await this.storeEngine.clearTables();
|
|
111
111
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, RemoteConversations,
|
|
1
|
+
import { Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, RemoteConversations, MLSConversation, SUBCONVERSATION_ID } from '@wireapp/api-client/lib/conversation';
|
|
2
2
|
import { BackendEvent, ConversationMemberLeaveEvent } from '@wireapp/api-client/lib/event';
|
|
3
3
|
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
4
4
|
import { XOR } from '@wireapp/commons/lib/util/TypeUtil';
|
|
5
5
|
import { APIClient } from '@wireapp/api-client';
|
|
6
6
|
import { TypedEventEmitter } from '@wireapp/commons';
|
|
7
|
-
import { AddUsersParams,
|
|
7
|
+
import { AddUsersParams, BaseCreateConversationResponse, SendMlsMessageParams, SendResult } from './ConversationService.types';
|
|
8
8
|
import { MessageTimer, RemoveUsersParams } from '../../conversation/';
|
|
9
|
-
import { MLSService } from '../../messagingProtocols/mls';
|
|
9
|
+
import { MLSService, MLSServiceEvents } from '../../messagingProtocols/mls';
|
|
10
10
|
import { ProteusService } from '../../messagingProtocols/proteus';
|
|
11
11
|
import { AddUsersToProteusConversationParams, SendProteusMessageParams } from '../../messagingProtocols/proteus/ProteusService/ProteusService.types';
|
|
12
12
|
import { HandledEventResult } from '../../notification';
|
|
@@ -16,6 +16,10 @@ type Events = {
|
|
|
16
16
|
MLSConversationRecovered: {
|
|
17
17
|
conversationId: QualifiedId;
|
|
18
18
|
};
|
|
19
|
+
[MLSServiceEvents.MLS_EVENT_DISTRIBUTED]: {
|
|
20
|
+
events: any;
|
|
21
|
+
time: string;
|
|
22
|
+
};
|
|
19
23
|
};
|
|
20
24
|
export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
21
25
|
private readonly apiClient;
|
|
@@ -46,7 +50,7 @@ export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
|
46
50
|
* @param conversationData Payload object for group creation
|
|
47
51
|
* @returns Resolves when the conversation was created
|
|
48
52
|
*/
|
|
49
|
-
createProteusConversation(conversationData: NewConversation): Promise<
|
|
53
|
+
createProteusConversation(conversationData: NewConversation): Promise<BaseCreateConversationResponse>;
|
|
50
54
|
getConversation(conversationId: QualifiedId): Promise<Conversation>;
|
|
51
55
|
getMLSSelfConversation(): Promise<MLSConversation>;
|
|
52
56
|
getConversations(conversationIds?: QualifiedId[]): Promise<RemoteConversations>;
|
|
@@ -86,7 +90,7 @@ export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
|
86
90
|
* Will create a conversation on backend and register it to CoreCrypto once created
|
|
87
91
|
* @param conversationData
|
|
88
92
|
*/
|
|
89
|
-
createMLSConversation(conversationData: NewConversation, selfUserId: QualifiedId, selfClientId: string): Promise<
|
|
93
|
+
createMLSConversation(conversationData: NewConversation, selfUserId: QualifiedId, selfClientId: string): Promise<BaseCreateConversationResponse>;
|
|
90
94
|
private sendMLSMessage;
|
|
91
95
|
/**
|
|
92
96
|
* Will add users to existing MLS group by claiming their key packages and passing them to CoreCrypto.addClientsToConversation
|
|
@@ -95,9 +99,9 @@ export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
|
95
99
|
* @param groupId Id of the group to which we want to add users
|
|
96
100
|
* @param conversationId Id of the conversation to which we want to add users
|
|
97
101
|
*/
|
|
98
|
-
addUsersToMLSConversation({ qualifiedUsers, groupId, conversationId, }: Required<AddUsersParams>): Promise<
|
|
99
|
-
removeUsersFromMLSConversation({ groupId, conversationId, qualifiedUserIds, }: RemoveUsersParams): Promise<
|
|
100
|
-
joinByExternalCommit(conversationId: QualifiedId): Promise<
|
|
102
|
+
addUsersToMLSConversation({ qualifiedUsers, groupId, conversationId, }: Required<AddUsersParams>): Promise<BaseCreateConversationResponse>;
|
|
103
|
+
removeUsersFromMLSConversation({ groupId, conversationId, qualifiedUserIds, }: RemoveUsersParams): Promise<Conversation>;
|
|
104
|
+
joinByExternalCommit(conversationId: QualifiedId): Promise<void>;
|
|
101
105
|
/**
|
|
102
106
|
* Will check if mls group exists locally.
|
|
103
107
|
* @param groupId groupId of the conversation
|
|
@@ -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,
|
|
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,EAEnB,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;AAGvD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAa,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAG/D,OAAO,EACL,cAAc,EACd,8BAA8B,EAE9B,oBAAoB,EACpB,UAAU,EACX,MAAM,6BAA6B,CAAC;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,EACnC,OAAO,EACP,cAAc,EACd,UAAU,EACV,cAAc,GACf,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,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"}
|
|
@@ -27,6 +27,7 @@ const bazinga64_1 = require("bazinga64");
|
|
|
27
27
|
const commons_1 = require("@wireapp/commons");
|
|
28
28
|
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
29
29
|
const conversation_2 = require("../../conversation/");
|
|
30
|
+
const mls_1 = require("../../messagingProtocols/mls");
|
|
30
31
|
const conversationRejoinQueue_1 = require("../../messagingProtocols/mls/conversationRejoinQueue");
|
|
31
32
|
const CoreCryptoMLSError_1 = require("../../messagingProtocols/mls/MLSService/CoreCryptoMLSError");
|
|
32
33
|
const proteus_1 = require("../../messagingProtocols/proteus");
|
|
@@ -51,6 +52,11 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
51
52
|
this.subconversationService = subconversationService;
|
|
52
53
|
this._mlsService = _mlsService;
|
|
53
54
|
this.messageTimer = new conversation_2.MessageTimer();
|
|
55
|
+
if (this._mlsService) {
|
|
56
|
+
this.mlsService.on(mls_1.MLSServiceEvents.MLS_EVENT_DISTRIBUTED, data => {
|
|
57
|
+
this.emit(mls_1.MLSServiceEvents.MLS_EVENT_DISTRIBUTED, data);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
54
60
|
}
|
|
55
61
|
get mlsService() {
|
|
56
62
|
if (!this._mlsService) {
|
|
@@ -197,7 +203,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
197
203
|
if (!groupId) {
|
|
198
204
|
throw new Error('No group_id found in response which is required for creating MLS conversations.');
|
|
199
205
|
}
|
|
200
|
-
const
|
|
206
|
+
const failures = await this.mlsService.registerConversation(groupId, qualifiedUsers.concat(selfUserId), {
|
|
201
207
|
creator: {
|
|
202
208
|
user: selfUserId,
|
|
203
209
|
client: selfClientId,
|
|
@@ -206,7 +212,6 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
206
212
|
// We fetch the fresh version of the conversation created on backend with the newly added users
|
|
207
213
|
const conversation = await this.apiClient.api.conversation.getConversation(qualifiedId);
|
|
208
214
|
return {
|
|
209
|
-
events,
|
|
210
215
|
conversation,
|
|
211
216
|
failedToAdd: failures,
|
|
212
217
|
};
|
|
@@ -256,29 +261,22 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
256
261
|
async addUsersToMLSConversation({ qualifiedUsers, groupId, conversationId, }) {
|
|
257
262
|
const exisitingClientIdsInGroup = await this.mlsService.getClientIdsInGroup(groupId);
|
|
258
263
|
const { keyPackages, failures: keysClaimingFailures } = await this.mlsService.getKeyPackagesPayload(qualifiedUsers, exisitingClientIdsInGroup);
|
|
259
|
-
|
|
260
|
-
? await this.mlsService.addUsersToExistingConversation(groupId, keyPackages)
|
|
261
|
-
: { events: [], failures: [] };
|
|
264
|
+
await this.mlsService.addUsersToExistingConversation(groupId, keyPackages);
|
|
262
265
|
const conversation = await this.getConversation(conversationId);
|
|
263
266
|
//We store the info when user was added (and key material was created), so we will know when to renew it
|
|
264
267
|
await this.mlsService.resetKeyMaterialRenewal(groupId);
|
|
265
268
|
return {
|
|
266
|
-
events,
|
|
267
269
|
conversation,
|
|
268
|
-
failedToAdd:
|
|
270
|
+
failedToAdd: keysClaimingFailures,
|
|
269
271
|
};
|
|
270
272
|
}
|
|
271
273
|
async removeUsersFromMLSConversation({ groupId, conversationId, qualifiedUserIds, }) {
|
|
272
274
|
const clientsToRemove = await this.apiClient.api.user.postListClients({ qualified_users: qualifiedUserIds });
|
|
273
275
|
const fullyQualifiedClientIds = (0, fullyQualifiedClientIdUtils_1.mapQualifiedUserClientIdsToFullyQualifiedClientIds)(clientsToRemove.qualified_user_map);
|
|
274
|
-
|
|
276
|
+
await this.mlsService.removeClientsFromConversation(groupId, fullyQualifiedClientIds);
|
|
275
277
|
//key material gets updated after removing a user from the group, so we can reset last key update time value in the store
|
|
276
278
|
await this.mlsService.resetKeyMaterialRenewal(groupId);
|
|
277
|
-
|
|
278
|
-
return {
|
|
279
|
-
events: messageResponse.events,
|
|
280
|
-
conversation,
|
|
281
|
-
};
|
|
279
|
+
return await this.getConversation(conversationId);
|
|
282
280
|
}
|
|
283
281
|
async joinByExternalCommit(conversationId) {
|
|
284
282
|
return this.mlsService.joinByExternalCommit(() => this.apiClient.api.conversation.getGroupInfo(conversationId));
|
|
@@ -113,6 +113,7 @@ describe('ConversationService', () => {
|
|
|
113
113
|
clientId: PayloadHelper.getUUID(),
|
|
114
114
|
};
|
|
115
115
|
const mockedMLSService = {
|
|
116
|
+
on: jest.fn(),
|
|
116
117
|
encryptMessage: () => { },
|
|
117
118
|
commitPendingProposals: () => Promise.resolve(),
|
|
118
119
|
getEpoch: () => Promise.resolve(),
|
|
@@ -311,7 +312,7 @@ describe('ConversationService', () => {
|
|
|
311
312
|
group_id: mockGroupId,
|
|
312
313
|
});
|
|
313
314
|
jest.spyOn(mlsService, 'isConversationEstablished').mockResolvedValueOnce(false);
|
|
314
|
-
jest.spyOn(mlsService, 'joinByExternalCommit')
|
|
315
|
+
jest.spyOn(mlsService, 'joinByExternalCommit');
|
|
315
316
|
const establishedConversation = await conversationService.establishMLS1to1Conversation(mockGroupId, selfUser, otherUserId);
|
|
316
317
|
expect(mlsService.registerConversation).not.toHaveBeenCalled();
|
|
317
318
|
expect(conversationService.joinByExternalCommit).toHaveBeenCalledWith(mockConversationId);
|
|
@@ -519,8 +520,7 @@ describe('ConversationService', () => {
|
|
|
519
520
|
epoch: 1,
|
|
520
521
|
group_id: mockGroupId,
|
|
521
522
|
});
|
|
522
|
-
|
|
523
|
-
jest.spyOn(mlsService, 'addUsersToExistingConversation').mockResolvedValueOnce(mlsMessage);
|
|
523
|
+
jest.spyOn(mlsService, 'addUsersToExistingConversation');
|
|
524
524
|
await conversationService.addUsersToMLSConversation({
|
|
525
525
|
qualifiedUsers,
|
|
526
526
|
groupId: mockGroupId,
|
|
@@ -542,11 +542,6 @@ describe('ConversationService', () => {
|
|
|
542
542
|
reason: __1.AddUsersFailureReasons.OFFLINE_FOR_TOO_LONG,
|
|
543
543
|
users: [otherUsersToAdd[0]],
|
|
544
544
|
};
|
|
545
|
-
const addUsersFailure = {
|
|
546
|
-
reason: __1.AddUsersFailureReasons.UNREACHABLE_BACKENDS,
|
|
547
|
-
users: [otherUsersToAdd[1]],
|
|
548
|
-
backends: [otherUsersToAdd[1].domain],
|
|
549
|
-
};
|
|
550
545
|
jest.spyOn(apiClient.api.user, 'getUserSupportedProtocols').mockImplementation(id => {
|
|
551
546
|
if (id === otherUsersToAdd[2]) {
|
|
552
547
|
return Promise.resolve([conversation_1.ConversationProtocol.PROTEUS]);
|
|
@@ -563,14 +558,13 @@ describe('ConversationService', () => {
|
|
|
563
558
|
epoch: 1,
|
|
564
559
|
group_id: mockGroupId,
|
|
565
560
|
});
|
|
566
|
-
|
|
567
|
-
jest.spyOn(mlsService, 'addUsersToExistingConversation').mockResolvedValueOnce(mlsMessage);
|
|
561
|
+
jest.spyOn(mlsService, 'addUsersToExistingConversation');
|
|
568
562
|
const { failedToAdd } = await conversationService.addUsersToMLSConversation({
|
|
569
563
|
qualifiedUsers,
|
|
570
564
|
groupId: mockGroupId,
|
|
571
565
|
conversationId: mockConversationId,
|
|
572
566
|
});
|
|
573
|
-
expect(failedToAdd).toEqual([keysClaimingFailure
|
|
567
|
+
expect(failedToAdd).toEqual([keysClaimingFailure]);
|
|
574
568
|
});
|
|
575
569
|
});
|
|
576
570
|
describe('tryEstablishingMLSGroup', () => {
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import { HandledEventPayload } from '../notification';
|
|
2
2
|
export type EventHandlerResult = Promise<HandledEventPayload | void>;
|
|
3
|
+
export interface CoreCryptoConfig {
|
|
4
|
+
/**
|
|
5
|
+
* path on the public server to the core crypto wasm file.
|
|
6
|
+
* This file will be downloaded lazily when corecrypto is needed.
|
|
7
|
+
* It, thus, needs to know where, on the server, the file can be found
|
|
8
|
+
*/
|
|
9
|
+
wasmFilePath: string;
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
}
|
|
3
12
|
//# sourceMappingURL=common.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.types.d.ts","sourceRoot":"","sources":["../../src/messagingProtocols/common.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAEpD,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"common.types.d.ts","sourceRoot":"","sources":["../../src/messagingProtocols/common.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAEpD,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;AAErE,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;CAClB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E2eiEnrollment, Ciphersuite, CoreCrypto,
|
|
1
|
+
import { E2eiEnrollment, Ciphersuite, CoreCrypto, WireIdentity, E2eiConversationState, DeviceStatus, CredentialType } from '@wireapp/core-crypto';
|
|
2
2
|
/**
|
|
3
3
|
* Proxy types relevant to the E2EIService from CoreCrypto
|
|
4
4
|
*/
|
|
@@ -8,7 +8,7 @@ export type AcmeDirectory = OmitFree<Awaited<ReturnType<E2eiEnrollment['director
|
|
|
8
8
|
export type AcmeChallenge = OmitFree<NonNullable<NewAcmeAuthzOriginal['challenge']>>;
|
|
9
9
|
export type NewAcmeOrder = OmitFree<Awaited<ReturnType<E2eiEnrollment['newOrderResponse']>>>;
|
|
10
10
|
export type NewAcmeAuthz = Pick<Awaited<ReturnType<E2eiEnrollment['newAuthzResponse']>>, 'identifier' | 'keyauth' | 'challenge'>;
|
|
11
|
-
export { E2eiEnrollment, Ciphersuite, CoreCrypto,
|
|
11
|
+
export { E2eiEnrollment, Ciphersuite, CoreCrypto, DeviceStatus, WireIdentity, E2eiConversationState, CredentialType };
|
|
12
12
|
export type User = {
|
|
13
13
|
id: string;
|
|
14
14
|
domain: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"E2EIService.types.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIService.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,cAAc,EACd,WAAW,EACX,UAAU,EACV,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"E2EIService.types.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIService.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,cAAc,EACd,WAAW,EACX,UAAU,EACV,YAAY,EACZ,qBAAqB,EACrB,YAAY,EACZ,cAAc,EACf,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,KAAK,QAAQ,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACnC,KAAK,oBAAoB,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9F,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/F,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,WAAW,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AACrF,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7F,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,EACvD,YAAY,GAAG,SAAS,GAAG,WAAW,CACvC,CAAC;AACF,OAAO,EAAC,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAC,CAAC;AAEpH,MAAM,MAAM,IAAI,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC;AACjC,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAC3B,MAAM,MAAM,OAAO,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.CredentialType = exports.E2eiConversationState = exports.DeviceStatus = exports.CoreCrypto = exports.Ciphersuite = exports.E2eiEnrollment = void 0;
|
|
21
|
+
exports.CredentialType = exports.E2eiConversationState = exports.WireIdentity = exports.DeviceStatus = exports.CoreCrypto = exports.Ciphersuite = exports.E2eiEnrollment = void 0;
|
|
22
22
|
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
23
23
|
Object.defineProperty(exports, "E2eiEnrollment", { enumerable: true, get: function () { return core_crypto_1.E2eiEnrollment; } });
|
|
24
24
|
Object.defineProperty(exports, "Ciphersuite", { enumerable: true, get: function () { return core_crypto_1.Ciphersuite; } });
|
|
25
25
|
Object.defineProperty(exports, "CoreCrypto", { enumerable: true, get: function () { return core_crypto_1.CoreCrypto; } });
|
|
26
|
+
Object.defineProperty(exports, "WireIdentity", { enumerable: true, get: function () { return core_crypto_1.WireIdentity; } });
|
|
26
27
|
Object.defineProperty(exports, "E2eiConversationState", { enumerable: true, get: function () { return core_crypto_1.E2eiConversationState; } });
|
|
27
28
|
Object.defineProperty(exports, "DeviceStatus", { enumerable: true, get: function () { return core_crypto_1.DeviceStatus; } });
|
|
28
29
|
Object.defineProperty(exports, "CredentialType", { enumerable: true, get: function () { return core_crypto_1.CredentialType; } });
|
|
@@ -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;AAGrD,OAAO,EAAC,sBAAsB,EAAuB,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAC,UAAU,EAAmB,MAAM,eAAe,CAAC;AAE3D,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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oBAAoB,CAAC,cAAc,EAAE,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAItF,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;IAI3B,0BAA0B,CACrC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,cAAc,EAAE,CAAC,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;IA0DxD,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;IAO7C;;;;;;;;;;;;OAYG;YACW,0BAA0B;IA2BxC,OAAO,CAAC,4BAA4B;YAStB,+BAA+B;YAQ/B,uBAAuB;YAKvB,0BAA0B;YAI1B,4BAA4B;YAO5B,WAAW;YAoBX,8BAA8B;CAM7C"}
|
|
@@ -57,7 +57,7 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
57
57
|
return this.enrollmentStorage.deletePendingEnrollmentData();
|
|
58
58
|
}
|
|
59
59
|
async getConversationState(conversationId) {
|
|
60
|
-
return this.coreCryptoClient.e2eiConversationState(conversationId);
|
|
60
|
+
return this.coreCryptoClient.transaction(cx => cx.e2eiConversationState(conversationId));
|
|
61
61
|
}
|
|
62
62
|
isE2EIEnabled() {
|
|
63
63
|
return this.coreCryptoClient.e2eiIsEnabled(this.mlsService.config.defaultCiphersuite);
|
|
@@ -115,6 +115,7 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
115
115
|
clientId: id.client,
|
|
116
116
|
qualifiedUserId: userId,
|
|
117
117
|
credentialType: core_crypto_1.CredentialType.Basic,
|
|
118
|
+
x509Identity: undefined,
|
|
118
119
|
}));
|
|
119
120
|
mappedUserIdentities.set((0, qualifiedIdUtil_1.stringifyQualifiedId)(userId), [...identities, ...basicMLSDevices]);
|
|
120
121
|
}
|
|
@@ -137,7 +138,7 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
137
138
|
}
|
|
138
139
|
async registerLocalCertificateRoot(acmeService) {
|
|
139
140
|
const localCertificateRoot = await acmeService.getLocalCertificateRoot();
|
|
140
|
-
await this.coreCryptoClient.e2eiRegisterAcmeCA(localCertificateRoot);
|
|
141
|
+
await this.coreCryptoClient.transaction(cx => cx.e2eiRegisterAcmeCA(localCertificateRoot));
|
|
141
142
|
return localCertificateRoot;
|
|
142
143
|
}
|
|
143
144
|
/**
|
|
@@ -160,7 +161,7 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
160
161
|
}
|
|
161
162
|
async registerCrossSignedCertificates(acmeService) {
|
|
162
163
|
const certificates = await acmeService.getFederationCrossSignedCertificates();
|
|
163
|
-
await Promise.all(certificates.map(cert => this.coreCryptoClient.e2eiRegisterIntermediateCA(cert)));
|
|
164
|
+
await Promise.all(certificates.map(cert => this.coreCryptoClient.transaction(cx => cx.e2eiRegisterIntermediateCA(cert))));
|
|
164
165
|
}
|
|
165
166
|
/**
|
|
166
167
|
* This function is used to register different server certificates in CoreCrypto.
|
|
@@ -176,7 +177,7 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
176
177
|
* Both must be registered before the first enrollment.
|
|
177
178
|
*/
|
|
178
179
|
async registerServerCertificates() {
|
|
179
|
-
const isRootRegistered = await this.coreCryptoClient.e2eiIsPKIEnvSetup();
|
|
180
|
+
const isRootRegistered = await this.coreCryptoClient.transaction(cx => cx.e2eiIsPKIEnvSetup());
|
|
180
181
|
// Register root certificate if not already registered
|
|
181
182
|
if (!isRootRegistered) {
|
|
182
183
|
await this.registerLocalCertificateRoot(this.acmeService);
|
|
@@ -222,7 +223,7 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
222
223
|
await this.validateCrl(distributionPointUrl, crl, () => this.emit('crlChanged', { domain }));
|
|
223
224
|
}
|
|
224
225
|
async validateCrl(url, crl, onDirty) {
|
|
225
|
-
const { expiration: expirationTimestampSeconds, dirty } = await this.coreCryptoClient.e2eiRegisterCRL(url, crl);
|
|
226
|
+
const { expiration: expirationTimestampSeconds, dirty } = await this.coreCryptoClient.transaction(cx => cx.e2eiRegisterCRL(url, crl));
|
|
226
227
|
const expirationTimestamp = expirationTimestampSeconds && expirationTimestampSeconds * TimeUtil_1.TimeInMillis.SECOND;
|
|
227
228
|
await this.cancelCrlDistributionTimer(url);
|
|
228
229
|
//set a new timer that will execute a task once the CRL is expired
|
|
@@ -30,13 +30,18 @@ const PayloadHelper_1 = require("../../../test/PayloadHelper");
|
|
|
30
30
|
const qualifiedIdUtil_1 = require("../../../util/qualifiedIdUtil");
|
|
31
31
|
const RecurringTaskScheduler_1 = require("../../../util/RecurringTaskScheduler");
|
|
32
32
|
async function buildE2EIService(dbName = 'core-test-db') {
|
|
33
|
-
const
|
|
34
|
-
getUserIdentities: jest.fn(),
|
|
35
|
-
getClientIds: jest.fn().mockResolvedValue([]),
|
|
33
|
+
const transactionContext = {
|
|
36
34
|
e2eiIsPKIEnvSetup: jest.fn(),
|
|
37
35
|
e2eiRegisterAcmeCA: jest.fn(),
|
|
38
36
|
e2eiRegisterIntermediateCA: jest.fn(),
|
|
39
37
|
};
|
|
38
|
+
const coreCrypto = {
|
|
39
|
+
getUserIdentities: jest.fn(),
|
|
40
|
+
getClientIds: jest.fn().mockResolvedValue([]),
|
|
41
|
+
transaction: jest.fn(fn => {
|
|
42
|
+
return fn(transactionContext);
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
40
45
|
const clientService = {};
|
|
41
46
|
const mockedDb = await (0, CoreDB_1.openDB)(dbName);
|
|
42
47
|
const mockedMLSService = {
|
|
@@ -53,7 +58,7 @@ async function buildE2EIService(dbName = 'core-test-db') {
|
|
|
53
58
|
});
|
|
54
59
|
return [
|
|
55
60
|
new E2EIServiceExternal_1.E2EIServiceExternal(coreCrypto, mockedDb, recurringTaskScheduler, clientService, mockedMLSService),
|
|
56
|
-
{ coreCrypto, mlsService: mockedMLSService, recurringTaskScheduler },
|
|
61
|
+
{ coreCrypto, mlsService: mockedMLSService, recurringTaskScheduler, transactionContext },
|
|
57
62
|
];
|
|
58
63
|
}
|
|
59
64
|
function generateCoreCryptoIdentity({ userId, status = 'Valid', deviceId = (0, PayloadHelper_1.getUUID)(), }) {
|
|
@@ -187,24 +192,24 @@ describe('E2EIServiceExternal', () => {
|
|
|
187
192
|
});
|
|
188
193
|
it('registers the server certificates and shedules a timer to refresh intermediate certs every', async () => {
|
|
189
194
|
jest.useFakeTimers();
|
|
190
|
-
const [service, {
|
|
191
|
-
jest.spyOn(
|
|
195
|
+
const [service, { transactionContext }] = await buildE2EIService('mockedDB1');
|
|
196
|
+
jest.spyOn(transactionContext, 'e2eiIsPKIEnvSetup').mockResolvedValueOnce(false);
|
|
192
197
|
await service.initialize('https://some.crl.discovery.url');
|
|
193
|
-
expect(
|
|
194
|
-
expect(
|
|
195
|
-
expect(
|
|
196
|
-
expect(
|
|
198
|
+
expect(transactionContext.e2eiRegisterAcmeCA).toHaveBeenCalledWith(mockedRootCA);
|
|
199
|
+
expect(transactionContext.e2eiRegisterIntermediateCA).toHaveBeenCalledWith(federatedCerts[0]);
|
|
200
|
+
expect(transactionContext.e2eiRegisterIntermediateCA).toHaveBeenCalledWith(federatedCerts[1]);
|
|
201
|
+
expect(transactionContext.e2eiRegisterIntermediateCA).toHaveBeenCalledTimes(2);
|
|
197
202
|
await jest.advanceTimersByTimeAsync(TimeUtil_1.TimeInMillis.DAY);
|
|
198
203
|
await jest.runAllTimersAsync();
|
|
199
|
-
expect(
|
|
204
|
+
expect(transactionContext.e2eiRegisterIntermediateCA).toHaveBeenCalledTimes(4);
|
|
200
205
|
});
|
|
201
206
|
it('does not register the root cert if it was already registered', async () => {
|
|
202
207
|
jest.useFakeTimers();
|
|
203
|
-
const [service, {
|
|
204
|
-
jest.spyOn(
|
|
208
|
+
const [service, { transactionContext }] = await buildE2EIService('mockedDB2');
|
|
209
|
+
jest.spyOn(transactionContext, 'e2eiIsPKIEnvSetup').mockResolvedValueOnce(true);
|
|
205
210
|
await service.initialize('https://some.crl.discovery.url');
|
|
206
|
-
expect(
|
|
207
|
-
expect(
|
|
211
|
+
expect(transactionContext.e2eiRegisterAcmeCA).not.toHaveBeenCalled();
|
|
212
|
+
expect(transactionContext.e2eiRegisterIntermediateCA).toHaveBeenCalledTimes(2);
|
|
208
213
|
});
|
|
209
214
|
});
|
|
210
215
|
});
|