@wireapp/core 46.24.0 → 46.24.2
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
package/lib/Account.d.ts
CHANGED
|
@@ -12,11 +12,10 @@ 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';
|
|
16
15
|
import { InitClientOptions, MLSService } from './messagingProtocols/mls';
|
|
17
16
|
import { E2EIServiceExternal } from './messagingProtocols/mls/E2EIdentityService';
|
|
18
|
-
import {
|
|
19
|
-
import { CoreCallbacks, SecretCrypto } from './messagingProtocols/mls/types';
|
|
17
|
+
import { getTokenCallback } from './messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal';
|
|
18
|
+
import { CoreCallbacks, CoreCryptoConfig, SecretCrypto } from './messagingProtocols/mls/types';
|
|
20
19
|
import { NewClient, ProteusService } from './messagingProtocols/proteus';
|
|
21
20
|
import { HandledEventPayload, NotificationService, NotificationSource } from './notification/';
|
|
22
21
|
import { SelfService } from './self/';
|
|
@@ -39,7 +38,6 @@ interface AccountOptions {
|
|
|
39
38
|
/** Used to store info in the database (will create a inMemory engine if returns undefined) */
|
|
40
39
|
createStore?: CreateStoreFn;
|
|
41
40
|
systemCrypto?: SecretCrypto;
|
|
42
|
-
coreCryptoConfig?: CoreCryptoConfig;
|
|
43
41
|
/** Number of prekeys to generate when creating a new device (defaults to 2)
|
|
44
42
|
* Prekeys are Diffie-Hellmann public keys which allow offline initiation of a secure Proteus session between two devices.
|
|
45
43
|
* Having a high value will:
|
|
@@ -50,6 +48,10 @@ interface AccountOptions {
|
|
|
50
48
|
* - 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
|
|
51
49
|
*/
|
|
52
50
|
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;
|
|
53
55
|
}
|
|
54
56
|
type InitOptions = {
|
|
55
57
|
/** cookie used to identify the current user. Will use the browser cookie if not defined */
|
|
@@ -69,6 +71,7 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
69
71
|
private options;
|
|
70
72
|
private readonly apiClient;
|
|
71
73
|
private readonly logger;
|
|
74
|
+
private readonly coreCryptoConfig?;
|
|
72
75
|
/** this is the client the consumer is currently using. Will be set as soon as `initClient` is called and will be rest upon logout */
|
|
73
76
|
private currentClient?;
|
|
74
77
|
private storeEngine?;
|
|
@@ -114,7 +117,7 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
114
117
|
*/
|
|
115
118
|
useAPIVersion(min: number, max: number, allowDev?: boolean): Promise<BackendFeatures>;
|
|
116
119
|
private persistCookie;
|
|
117
|
-
enrollE2EI({ displayName, handle, teamId, discoveryUrl, getOAuthToken,
|
|
120
|
+
enrollE2EI({ displayName, handle, teamId, discoveryUrl, getOAuthToken, certificateTtl, }: {
|
|
118
121
|
/** display name of the user (should match the identity provider) */
|
|
119
122
|
displayName: string;
|
|
120
123
|
/** handle of the user (should match the identity provider) */
|
|
@@ -124,8 +127,6 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
124
127
|
discoveryUrl: string;
|
|
125
128
|
/** function called to get the oauth token */
|
|
126
129
|
getOAuthToken: getTokenCallback;
|
|
127
|
-
/** function called to get all conversations */
|
|
128
|
-
getAllConversations: getAllConversationsCallback;
|
|
129
130
|
/** number of seconds the certificate should be valid (default 90 days) */
|
|
130
131
|
certificateTtl?: number;
|
|
131
132
|
}): 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,EAAC,MAAM,iCAAiC,CAAC;AAEnG,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAC;AAUxD,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,qBA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AO,CAAC,uBAAuB;YAIjB,UAAU;IAuBxB,OAAO,CAAC,yBAAyB,CAS/B;IAEW,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;CAmBtD"}
|
package/lib/Account.js
CHANGED
|
@@ -104,6 +104,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
104
104
|
options;
|
|
105
105
|
apiClient;
|
|
106
106
|
logger;
|
|
107
|
+
coreCryptoConfig;
|
|
107
108
|
/** this is the client the consumer is currently using. Will be set as soon as `initClient` is called and will be rest upon logout */
|
|
108
109
|
currentClient;
|
|
109
110
|
storeEngine;
|
|
@@ -117,11 +118,12 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
117
118
|
* @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
|
|
118
119
|
* @param accountOptions
|
|
119
120
|
*/
|
|
120
|
-
constructor(apiClient = new api_client_1.APIClient(), options = { nbPrekeys: 100
|
|
121
|
+
constructor(apiClient = new api_client_1.APIClient(), options = { nbPrekeys: 100 }) {
|
|
121
122
|
super();
|
|
122
123
|
this.options = options;
|
|
123
124
|
this.apiClient = apiClient;
|
|
124
125
|
this.backendFeatures = this.apiClient.backendFeatures;
|
|
126
|
+
this.coreCryptoConfig = options.coreCryptoConfig;
|
|
125
127
|
this.recurringTaskScheduler = new RecurringTaskScheduler_1.RecurringTaskScheduler({
|
|
126
128
|
get: async (key) => {
|
|
127
129
|
const task = await this.db?.get('recurringTasks', key);
|
|
@@ -167,7 +169,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
167
169
|
const entity = { expiration: cookie.expiration, zuid: cookie.zuid };
|
|
168
170
|
return storeEngine.updateOrCreate(auth_1.AUTH_TABLE_NAME, auth_1.AUTH_COOKIE_KEY, entity);
|
|
169
171
|
}
|
|
170
|
-
async enrollE2EI({ displayName, handle, teamId, discoveryUrl, getOAuthToken,
|
|
172
|
+
async enrollE2EI({ displayName, handle, teamId, discoveryUrl, getOAuthToken, certificateTtl = 90 * (TimeUtil_1.TimeInMillis.DAY / 1000), }) {
|
|
171
173
|
const context = this.apiClient.context;
|
|
172
174
|
const domain = context?.domain ?? '';
|
|
173
175
|
if (!this.currentClient) {
|
|
@@ -183,7 +185,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
183
185
|
teamId,
|
|
184
186
|
id: this.userId,
|
|
185
187
|
};
|
|
186
|
-
return this.service.mls.enrollE2EI(discoveryUrl, user, this.currentClient, this.options.nbPrekeys, certificateTtl, getOAuthToken
|
|
188
|
+
return this.service.mls.enrollE2EI(discoveryUrl, user, this.currentClient, this.options.nbPrekeys, certificateTtl, getOAuthToken);
|
|
187
189
|
}
|
|
188
190
|
get clientId() {
|
|
189
191
|
return this.apiClient.validatedClientId;
|
|
@@ -258,7 +260,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
258
260
|
this.apiClient.context.clientId = client.id;
|
|
259
261
|
// Call /access endpoint with client_id after client initialisation
|
|
260
262
|
await this.apiClient.transport.http.associateClientWithSession(client.id);
|
|
261
|
-
await this.service.proteus.initClient(this.apiClient.context);
|
|
263
|
+
await this.service.proteus.initClient(this.storeEngine, this.apiClient.context);
|
|
262
264
|
if ((await this.isMLSActiveForClient()) && this.service.mls && mlsConfig) {
|
|
263
265
|
const { userId, domain = '' } = this.apiClient.context;
|
|
264
266
|
await this.service.mls.initClient({ id: userId, domain }, client, mlsConfig);
|
|
@@ -281,12 +283,14 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
281
283
|
this.logger.debug(`Successfully uploaded '${prekeys.length}' PreKeys.`);
|
|
282
284
|
},
|
|
283
285
|
};
|
|
284
|
-
|
|
286
|
+
const coreCryptoConfig = this.coreCryptoConfig;
|
|
287
|
+
if (coreCryptoConfig) {
|
|
285
288
|
const { buildClient } = await Promise.resolve().then(() => __importStar(require('./messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper')));
|
|
286
289
|
const client = await buildClient(storeEngine, {
|
|
287
290
|
...baseConfig,
|
|
288
|
-
|
|
289
|
-
|
|
291
|
+
...coreCryptoConfig,
|
|
292
|
+
generateSecretKey: keyId => (0, secretKeyGenerator_1.generateSecretKey)({ keyId, keySize: 16, secretsDb: encryptedStore }),
|
|
293
|
+
});
|
|
290
294
|
return [CryptoClient_1.CryptoClientType.CORE_CRYPTO, client];
|
|
291
295
|
}
|
|
292
296
|
const { buildClient } = await Promise.resolve().then(() => __importStar(require('./messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper')));
|
|
@@ -319,7 +323,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
319
323
|
const proteusService = new proteus_1.ProteusService(this.apiClient, cryptoClient, {
|
|
320
324
|
onNewClient: payload => this.emit(EVENTS.NEW_SESSION, payload),
|
|
321
325
|
nbPrekeys: this.options.nbPrekeys,
|
|
322
|
-
}
|
|
326
|
+
});
|
|
323
327
|
const clientService = new client_2.ClientService(this.apiClient, proteusService, this.storeEngine);
|
|
324
328
|
if (clientType === CryptoClient_1.CryptoClientType.CORE_CRYPTO && (await this.apiClient.supportsMLS())) {
|
|
325
329
|
mlsService = new mls_1.MLSService(this.apiClient, cryptoClient.getNativeClient(), this.db, this.recurringTaskScheduler);
|
|
@@ -384,9 +388,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
384
388
|
* Will delete the identity and history of the current user
|
|
385
389
|
*/
|
|
386
390
|
async wipeAllData() {
|
|
387
|
-
|
|
388
|
-
await (0, identityClearer_1.deleteIdentity)(this.storeEngine, false);
|
|
389
|
-
}
|
|
391
|
+
await this.service?.proteus.wipe(this.storeEngine);
|
|
390
392
|
if (this.db) {
|
|
391
393
|
await (0, CoreDB_1.deleteDB)(this.db);
|
|
392
394
|
}
|
|
@@ -397,6 +399,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
397
399
|
* Will keep the history intact
|
|
398
400
|
*/
|
|
399
401
|
async wipeCryptoData() {
|
|
402
|
+
await this.service?.proteus.wipe();
|
|
400
403
|
if (this.storeEngine) {
|
|
401
404
|
await (0, identityClearer_1.deleteIdentity)(this.storeEngine, true);
|
|
402
405
|
}
|
|
@@ -531,21 +534,20 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
531
534
|
return this.service?.subconversation.getSubconversationGroupId(conversationId, subconversationId);
|
|
532
535
|
};
|
|
533
536
|
async isMLSActiveForClient() {
|
|
534
|
-
//
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
}
|
|
538
|
-
// Check if the MLS service is initialized
|
|
539
|
-
if (this.service?.mls === undefined) {
|
|
537
|
+
// MLS service is initialized
|
|
538
|
+
const isMLSServiceInitialized = this.service?.mls !== undefined;
|
|
539
|
+
if (!isMLSServiceInitialized) {
|
|
540
540
|
return false;
|
|
541
541
|
}
|
|
542
|
-
//
|
|
543
|
-
|
|
542
|
+
// Backend Supports MLS trough removal keys
|
|
543
|
+
const isMLSSupported = await this.apiClient.supportsMLS();
|
|
544
|
+
if (!isMLSSupported) {
|
|
544
545
|
return false;
|
|
545
546
|
}
|
|
546
|
-
//
|
|
547
|
+
// MLS is enabled for the public via feature flag
|
|
547
548
|
const commonConfig = (await this.service?.team.getCommonFeatureConfig()) ?? {};
|
|
548
|
-
|
|
549
|
+
const isMLSForTeamEnabled = commonConfig[team_1.FEATURE_KEY.MLS]?.status === team_1.FeatureStatus.ENABLED;
|
|
550
|
+
return isMLSSupported && isMLSForTeamEnabled && isMLSServiceInitialized;
|
|
549
551
|
}
|
|
550
552
|
}
|
|
551
553
|
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(this.storeEngine);
|
|
109
109
|
if (shouldDeleteWholeDatabase) {
|
|
110
110
|
await this.storeEngine.clearTables();
|
|
111
111
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, RemoteConversations, MLSConversation, SUBCONVERSATION_ID } from '@wireapp/api-client/lib/conversation';
|
|
1
|
+
import { Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, RemoteConversations, PostMlsMessageResponse, 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, MLSCreateConversationResponse, SendMlsMessageParams, SendResult } from './ConversationService.types';
|
|
8
8
|
import { MessageTimer, RemoveUsersParams } from '../../conversation/';
|
|
9
|
-
import { MLSService
|
|
9
|
+
import { MLSService } 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,10 +16,6 @@ type Events = {
|
|
|
16
16
|
MLSConversationRecovered: {
|
|
17
17
|
conversationId: QualifiedId;
|
|
18
18
|
};
|
|
19
|
-
[MLSServiceEvents.MLS_EVENT_DISTRIBUTED]: {
|
|
20
|
-
events: any;
|
|
21
|
-
time: string;
|
|
22
|
-
};
|
|
23
19
|
};
|
|
24
20
|
export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
25
21
|
private readonly apiClient;
|
|
@@ -50,7 +46,7 @@ export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
|
50
46
|
* @param conversationData Payload object for group creation
|
|
51
47
|
* @returns Resolves when the conversation was created
|
|
52
48
|
*/
|
|
53
|
-
createProteusConversation(conversationData: NewConversation): Promise<BaseCreateConversationResponse>;
|
|
49
|
+
createProteusConversation(conversationData: NewConversation): Promise<import("./ConversationService.types").BaseCreateConversationResponse>;
|
|
54
50
|
getConversation(conversationId: QualifiedId): Promise<Conversation>;
|
|
55
51
|
getMLSSelfConversation(): Promise<MLSConversation>;
|
|
56
52
|
getConversations(conversationIds?: QualifiedId[]): Promise<RemoteConversations>;
|
|
@@ -90,7 +86,7 @@ export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
|
90
86
|
* Will create a conversation on backend and register it to CoreCrypto once created
|
|
91
87
|
* @param conversationData
|
|
92
88
|
*/
|
|
93
|
-
createMLSConversation(conversationData: NewConversation, selfUserId: QualifiedId, selfClientId: string): Promise<
|
|
89
|
+
createMLSConversation(conversationData: NewConversation, selfUserId: QualifiedId, selfClientId: string): Promise<MLSCreateConversationResponse>;
|
|
94
90
|
private sendMLSMessage;
|
|
95
91
|
/**
|
|
96
92
|
* Will add users to existing MLS group by claiming their key packages and passing them to CoreCrypto.addClientsToConversation
|
|
@@ -99,9 +95,9 @@ export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
|
99
95
|
* @param groupId Id of the group to which we want to add users
|
|
100
96
|
* @param conversationId Id of the conversation to which we want to add users
|
|
101
97
|
*/
|
|
102
|
-
addUsersToMLSConversation({ qualifiedUsers, groupId, conversationId, }: Required<AddUsersParams>): Promise<
|
|
103
|
-
removeUsersFromMLSConversation({ groupId, conversationId, qualifiedUserIds, }: RemoveUsersParams): Promise<
|
|
104
|
-
joinByExternalCommit(conversationId: QualifiedId): Promise<
|
|
98
|
+
addUsersToMLSConversation({ qualifiedUsers, groupId, conversationId, }: Required<AddUsersParams>): Promise<MLSCreateConversationResponse>;
|
|
99
|
+
removeUsersFromMLSConversation({ groupId, conversationId, qualifiedUserIds, }: RemoveUsersParams): Promise<MLSCreateConversationResponse>;
|
|
100
|
+
joinByExternalCommit(conversationId: QualifiedId): Promise<PostMlsMessageResponse>;
|
|
105
101
|
/**
|
|
106
102
|
* Will check if mls group exists locally.
|
|
107
103
|
* @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,EACnB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAGnB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,YAAY,EAIZ,4BAA4B,EAE7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAGvD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAa,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAG/D,OAAO,EAEL,cAAc,EAEd,6BAA6B,EAC7B,oBAAoB,EACpB,UAAU,EACX,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAC,YAAY,EAAuB,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAC;AAMxD,OAAO,EAAkC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AACjG,OAAO,EACL,mCAAmC,EACnC,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AAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAoB3E"}
|
|
@@ -27,7 +27,6 @@ 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");
|
|
31
30
|
const conversationRejoinQueue_1 = require("../../messagingProtocols/mls/conversationRejoinQueue");
|
|
32
31
|
const CoreCryptoMLSError_1 = require("../../messagingProtocols/mls/MLSService/CoreCryptoMLSError");
|
|
33
32
|
const proteus_1 = require("../../messagingProtocols/proteus");
|
|
@@ -52,11 +51,6 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
52
51
|
this.subconversationService = subconversationService;
|
|
53
52
|
this._mlsService = _mlsService;
|
|
54
53
|
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
|
-
}
|
|
60
54
|
}
|
|
61
55
|
get mlsService() {
|
|
62
56
|
if (!this._mlsService) {
|
|
@@ -203,7 +197,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
203
197
|
if (!groupId) {
|
|
204
198
|
throw new Error('No group_id found in response which is required for creating MLS conversations.');
|
|
205
199
|
}
|
|
206
|
-
const failures = await this.mlsService.registerConversation(groupId, qualifiedUsers.concat(selfUserId), {
|
|
200
|
+
const { events, failures } = await this.mlsService.registerConversation(groupId, qualifiedUsers.concat(selfUserId), {
|
|
207
201
|
creator: {
|
|
208
202
|
user: selfUserId,
|
|
209
203
|
client: selfClientId,
|
|
@@ -212,6 +206,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
212
206
|
// We fetch the fresh version of the conversation created on backend with the newly added users
|
|
213
207
|
const conversation = await this.apiClient.api.conversation.getConversation(qualifiedId);
|
|
214
208
|
return {
|
|
209
|
+
events,
|
|
215
210
|
conversation,
|
|
216
211
|
failedToAdd: failures,
|
|
217
212
|
};
|
|
@@ -261,22 +256,29 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
261
256
|
async addUsersToMLSConversation({ qualifiedUsers, groupId, conversationId, }) {
|
|
262
257
|
const exisitingClientIdsInGroup = await this.mlsService.getClientIdsInGroup(groupId);
|
|
263
258
|
const { keyPackages, failures: keysClaimingFailures } = await this.mlsService.getKeyPackagesPayload(qualifiedUsers, exisitingClientIdsInGroup);
|
|
264
|
-
|
|
259
|
+
const { events, failures } = keyPackages.length > 0
|
|
260
|
+
? await this.mlsService.addUsersToExistingConversation(groupId, keyPackages)
|
|
261
|
+
: { events: [], failures: [] };
|
|
265
262
|
const conversation = await this.getConversation(conversationId);
|
|
266
263
|
//We store the info when user was added (and key material was created), so we will know when to renew it
|
|
267
264
|
await this.mlsService.resetKeyMaterialRenewal(groupId);
|
|
268
265
|
return {
|
|
266
|
+
events,
|
|
269
267
|
conversation,
|
|
270
|
-
failedToAdd: keysClaimingFailures,
|
|
268
|
+
failedToAdd: [...keysClaimingFailures, ...failures],
|
|
271
269
|
};
|
|
272
270
|
}
|
|
273
271
|
async removeUsersFromMLSConversation({ groupId, conversationId, qualifiedUserIds, }) {
|
|
274
272
|
const clientsToRemove = await this.apiClient.api.user.postListClients({ qualified_users: qualifiedUserIds });
|
|
275
273
|
const fullyQualifiedClientIds = (0, fullyQualifiedClientIdUtils_1.mapQualifiedUserClientIdsToFullyQualifiedClientIds)(clientsToRemove.qualified_user_map);
|
|
276
|
-
await this.mlsService.removeClientsFromConversation(groupId, fullyQualifiedClientIds);
|
|
274
|
+
const messageResponse = await this.mlsService.removeClientsFromConversation(groupId, fullyQualifiedClientIds);
|
|
277
275
|
//key material gets updated after removing a user from the group, so we can reset last key update time value in the store
|
|
278
276
|
await this.mlsService.resetKeyMaterialRenewal(groupId);
|
|
279
|
-
|
|
277
|
+
const conversation = await this.getConversation(conversationId);
|
|
278
|
+
return {
|
|
279
|
+
events: messageResponse.events,
|
|
280
|
+
conversation,
|
|
281
|
+
};
|
|
280
282
|
}
|
|
281
283
|
async joinByExternalCommit(conversationId) {
|
|
282
284
|
return this.mlsService.joinByExternalCommit(() => this.apiClient.api.conversation.getGroupInfo(conversationId));
|
|
@@ -113,7 +113,6 @@ describe('ConversationService', () => {
|
|
|
113
113
|
clientId: PayloadHelper.getUUID(),
|
|
114
114
|
};
|
|
115
115
|
const mockedMLSService = {
|
|
116
|
-
on: jest.fn(),
|
|
117
116
|
encryptMessage: () => { },
|
|
118
117
|
commitPendingProposals: () => Promise.resolve(),
|
|
119
118
|
getEpoch: () => Promise.resolve(),
|
|
@@ -312,7 +311,7 @@ describe('ConversationService', () => {
|
|
|
312
311
|
group_id: mockGroupId,
|
|
313
312
|
});
|
|
314
313
|
jest.spyOn(mlsService, 'isConversationEstablished').mockResolvedValueOnce(false);
|
|
315
|
-
jest.spyOn(mlsService, 'joinByExternalCommit');
|
|
314
|
+
jest.spyOn(mlsService, 'joinByExternalCommit').mockResolvedValueOnce({ events: [], time: '' });
|
|
316
315
|
const establishedConversation = await conversationService.establishMLS1to1Conversation(mockGroupId, selfUser, otherUserId);
|
|
317
316
|
expect(mlsService.registerConversation).not.toHaveBeenCalled();
|
|
318
317
|
expect(conversationService.joinByExternalCommit).toHaveBeenCalledWith(mockConversationId);
|
|
@@ -520,7 +519,8 @@ describe('ConversationService', () => {
|
|
|
520
519
|
epoch: 1,
|
|
521
520
|
group_id: mockGroupId,
|
|
522
521
|
});
|
|
523
|
-
|
|
522
|
+
const mlsMessage = { events: [], time: '', failures: [] };
|
|
523
|
+
jest.spyOn(mlsService, 'addUsersToExistingConversation').mockResolvedValueOnce(mlsMessage);
|
|
524
524
|
await conversationService.addUsersToMLSConversation({
|
|
525
525
|
qualifiedUsers,
|
|
526
526
|
groupId: mockGroupId,
|
|
@@ -542,6 +542,11 @@ 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
|
+
};
|
|
545
550
|
jest.spyOn(apiClient.api.user, 'getUserSupportedProtocols').mockImplementation(id => {
|
|
546
551
|
if (id === otherUsersToAdd[2]) {
|
|
547
552
|
return Promise.resolve([conversation_1.ConversationProtocol.PROTEUS]);
|
|
@@ -558,13 +563,14 @@ describe('ConversationService', () => {
|
|
|
558
563
|
epoch: 1,
|
|
559
564
|
group_id: mockGroupId,
|
|
560
565
|
});
|
|
561
|
-
|
|
566
|
+
const mlsMessage = { events: [], time: '', failures: [addUsersFailure] };
|
|
567
|
+
jest.spyOn(mlsService, 'addUsersToExistingConversation').mockResolvedValueOnce(mlsMessage);
|
|
562
568
|
const { failedToAdd } = await conversationService.addUsersToMLSConversation({
|
|
563
569
|
qualifiedUsers,
|
|
564
570
|
groupId: mockGroupId,
|
|
565
571
|
conversationId: mockConversationId,
|
|
566
572
|
});
|
|
567
|
-
expect(failedToAdd).toEqual([keysClaimingFailure]);
|
|
573
|
+
expect(failedToAdd).toEqual([keysClaimingFailure, addUsersFailure]);
|
|
568
574
|
});
|
|
569
575
|
});
|
|
570
576
|
describe('tryEstablishingMLSGroup', () => {
|
|
@@ -1,12 +1,3 @@
|
|
|
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
|
-
}
|
|
12
3
|
//# 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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E2eiEnrollment, Ciphersuite, CoreCrypto, WireIdentity, E2eiConversationState, DeviceStatus, CredentialType } from '@wireapp/core-crypto';
|
|
1
|
+
import { E2eiEnrollment, Ciphersuite, CoreCrypto, RotateBundle, 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, DeviceStatus, WireIdentity, E2eiConversationState, CredentialType };
|
|
11
|
+
export { E2eiEnrollment, Ciphersuite, CoreCrypto, RotateBundle, 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,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,
|
|
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,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,EACL,cAAc,EACd,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,qBAAqB,EACrB,cAAc,GACf,CAAC;AAEF,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,12 +18,11 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.CredentialType = exports.E2eiConversationState = exports.
|
|
21
|
+
exports.CredentialType = exports.E2eiConversationState = 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; } });
|
|
27
26
|
Object.defineProperty(exports, "E2eiConversationState", { enumerable: true, get: function () { return core_crypto_1.E2eiConversationState; } });
|
|
28
27
|
Object.defineProperty(exports, "DeviceStatus", { enumerable: true, get: function () { return core_crypto_1.DeviceStatus; } });
|
|
29
28
|
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,EA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AA+B;IAK7C;;;;;;;;;;;;OAYG;YACW,0BAA0B;IA2BxC,OAAO,CAAC,4BAA4B;YAStB,+BAA+B;YAQ/B,uBAAuB;YAKvB,0BAA0B;YAI1B,4BAA4B;YAO5B,WAAW;YAkBX,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.
|
|
60
|
+
return this.coreCryptoClient.e2eiConversationState(conversationId);
|
|
61
61
|
}
|
|
62
62
|
isE2EIEnabled() {
|
|
63
63
|
return this.coreCryptoClient.e2eiIsEnabled(this.mlsService.config.defaultCiphersuite);
|
|
@@ -115,7 +115,6 @@ 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,
|
|
119
118
|
}));
|
|
120
119
|
mappedUserIdentities.set((0, qualifiedIdUtil_1.stringifyQualifiedId)(userId), [...identities, ...basicMLSDevices]);
|
|
121
120
|
}
|
|
@@ -138,7 +137,7 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
138
137
|
}
|
|
139
138
|
async registerLocalCertificateRoot(acmeService) {
|
|
140
139
|
const localCertificateRoot = await acmeService.getLocalCertificateRoot();
|
|
141
|
-
await this.coreCryptoClient.
|
|
140
|
+
await this.coreCryptoClient.e2eiRegisterAcmeCA(localCertificateRoot);
|
|
142
141
|
return localCertificateRoot;
|
|
143
142
|
}
|
|
144
143
|
/**
|
|
@@ -161,7 +160,7 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
161
160
|
}
|
|
162
161
|
async registerCrossSignedCertificates(acmeService) {
|
|
163
162
|
const certificates = await acmeService.getFederationCrossSignedCertificates();
|
|
164
|
-
await Promise.all(certificates.map(cert => this.coreCryptoClient.
|
|
163
|
+
await Promise.all(certificates.map(cert => this.coreCryptoClient.e2eiRegisterIntermediateCA(cert)));
|
|
165
164
|
}
|
|
166
165
|
/**
|
|
167
166
|
* This function is used to register different server certificates in CoreCrypto.
|
|
@@ -177,7 +176,7 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
177
176
|
* Both must be registered before the first enrollment.
|
|
178
177
|
*/
|
|
179
178
|
async registerServerCertificates() {
|
|
180
|
-
const isRootRegistered = await this.coreCryptoClient.
|
|
179
|
+
const isRootRegistered = await this.coreCryptoClient.e2eiIsPKIEnvSetup();
|
|
181
180
|
// Register root certificate if not already registered
|
|
182
181
|
if (!isRootRegistered) {
|
|
183
182
|
await this.registerLocalCertificateRoot(this.acmeService);
|
|
@@ -223,7 +222,7 @@ class E2EIServiceExternal extends commons_1.TypedEventEmitter {
|
|
|
223
222
|
await this.validateCrl(distributionPointUrl, crl, () => this.emit('crlChanged', { domain }));
|
|
224
223
|
}
|
|
225
224
|
async validateCrl(url, crl, onDirty) {
|
|
226
|
-
const { expiration: expirationTimestampSeconds, dirty } = await this.coreCryptoClient.
|
|
225
|
+
const { expiration: expirationTimestampSeconds, dirty } = await this.coreCryptoClient.e2eiRegisterCRL(url, crl);
|
|
227
226
|
const expirationTimestamp = expirationTimestampSeconds && expirationTimestampSeconds * TimeUtil_1.TimeInMillis.SECOND;
|
|
228
227
|
await this.cancelCrlDistributionTimer(url);
|
|
229
228
|
//set a new timer that will execute a task once the CRL is expired
|
|
@@ -30,17 +30,12 @@ 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 transactionContext = {
|
|
34
|
-
e2eiIsPKIEnvSetup: jest.fn(),
|
|
35
|
-
e2eiRegisterAcmeCA: jest.fn(),
|
|
36
|
-
e2eiRegisterIntermediateCA: jest.fn(),
|
|
37
|
-
};
|
|
38
33
|
const coreCrypto = {
|
|
39
34
|
getUserIdentities: jest.fn(),
|
|
40
35
|
getClientIds: jest.fn().mockResolvedValue([]),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
e2eiIsPKIEnvSetup: jest.fn(),
|
|
37
|
+
e2eiRegisterAcmeCA: jest.fn(),
|
|
38
|
+
e2eiRegisterIntermediateCA: jest.fn(),
|
|
44
39
|
};
|
|
45
40
|
const clientService = {};
|
|
46
41
|
const mockedDb = await (0, CoreDB_1.openDB)(dbName);
|
|
@@ -58,7 +53,7 @@ async function buildE2EIService(dbName = 'core-test-db') {
|
|
|
58
53
|
});
|
|
59
54
|
return [
|
|
60
55
|
new E2EIServiceExternal_1.E2EIServiceExternal(coreCrypto, mockedDb, recurringTaskScheduler, clientService, mockedMLSService),
|
|
61
|
-
{ coreCrypto, mlsService: mockedMLSService, recurringTaskScheduler
|
|
56
|
+
{ coreCrypto, mlsService: mockedMLSService, recurringTaskScheduler },
|
|
62
57
|
];
|
|
63
58
|
}
|
|
64
59
|
function generateCoreCryptoIdentity({ userId, status = 'Valid', deviceId = (0, PayloadHelper_1.getUUID)(), }) {
|
|
@@ -192,24 +187,24 @@ describe('E2EIServiceExternal', () => {
|
|
|
192
187
|
});
|
|
193
188
|
it('registers the server certificates and shedules a timer to refresh intermediate certs every', async () => {
|
|
194
189
|
jest.useFakeTimers();
|
|
195
|
-
const [service, {
|
|
196
|
-
jest.spyOn(
|
|
190
|
+
const [service, { coreCrypto }] = await buildE2EIService('mockedDB1');
|
|
191
|
+
jest.spyOn(coreCrypto, 'e2eiIsPKIEnvSetup').mockResolvedValueOnce(false);
|
|
197
192
|
await service.initialize('https://some.crl.discovery.url');
|
|
198
|
-
expect(
|
|
199
|
-
expect(
|
|
200
|
-
expect(
|
|
201
|
-
expect(
|
|
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);
|
|
202
197
|
await jest.advanceTimersByTimeAsync(TimeUtil_1.TimeInMillis.DAY);
|
|
203
198
|
await jest.runAllTimersAsync();
|
|
204
|
-
expect(
|
|
199
|
+
expect(coreCrypto.e2eiRegisterIntermediateCA).toHaveBeenCalledTimes(4);
|
|
205
200
|
});
|
|
206
201
|
it('does not register the root cert if it was already registered', async () => {
|
|
207
202
|
jest.useFakeTimers();
|
|
208
|
-
const [service, {
|
|
209
|
-
jest.spyOn(
|
|
203
|
+
const [service, { coreCrypto }] = await buildE2EIService('mockedDB2');
|
|
204
|
+
jest.spyOn(coreCrypto, 'e2eiIsPKIEnvSetup').mockResolvedValueOnce(true);
|
|
210
205
|
await service.initialize('https://some.crl.discovery.url');
|
|
211
|
-
expect(
|
|
212
|
-
expect(
|
|
206
|
+
expect(coreCrypto.e2eiRegisterAcmeCA).not.toHaveBeenCalled();
|
|
207
|
+
expect(coreCrypto.e2eiRegisterIntermediateCA).toHaveBeenCalledTimes(2);
|
|
213
208
|
});
|
|
214
209
|
});
|
|
215
210
|
});
|