@wireapp/core 46.24.1 → 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 +5 -5
- package/lib/test/StoreHelper.d.ts +0 -2
- package/lib/test/StoreHelper.d.ts.map +0 -1
- package/lib/test/StoreHelper.js +0 -27
|
@@ -6,9 +6,6 @@ export type getTokenCallback = (challengesData?: {
|
|
|
6
6
|
challenge: any;
|
|
7
7
|
keyAuth: string;
|
|
8
8
|
}) => Promise<string | undefined>;
|
|
9
|
-
export type getAllConversationsCallback = () => Promise<{
|
|
10
|
-
group_id: string;
|
|
11
|
-
}[]>;
|
|
12
9
|
export declare class E2EIServiceInternal {
|
|
13
10
|
private readonly coreCryptoClient;
|
|
14
11
|
private readonly apiClient;
|
|
@@ -27,10 +24,7 @@ export declare class E2EIServiceInternal {
|
|
|
27
24
|
* @param getOAuthToken function called when the process needs an oauth token
|
|
28
25
|
* @param refresh should the process refresh the current certificate or get a new one
|
|
29
26
|
*/
|
|
30
|
-
generateCertificate(getOAuthToken: getTokenCallback, refresh: boolean,
|
|
31
|
-
newCrlDistributionPoints: import("@wireapp/core-crypto").NewCrlDistributionPoints;
|
|
32
|
-
keyPackages: Uint8Array[];
|
|
33
|
-
}>;
|
|
27
|
+
generateCertificate(getOAuthToken: getTokenCallback, refresh: boolean, ciphersuite: Ciphersuite): Promise<import("@wireapp/core-crypto").RotateBundle>;
|
|
34
28
|
private continueCertificateGeneration;
|
|
35
29
|
private initIdentity;
|
|
36
30
|
private getDirectory;
|
|
@@ -48,8 +42,8 @@ export declare class E2EIServiceInternal {
|
|
|
48
42
|
* Stores the received certificate data in local storage for later use
|
|
49
43
|
*
|
|
50
44
|
* @param oAuthIdToken
|
|
51
|
-
* @returns
|
|
45
|
+
* @returns RotateBundle
|
|
52
46
|
*/
|
|
53
|
-
private
|
|
47
|
+
private getRotateBundle;
|
|
54
48
|
}
|
|
55
49
|
//# sourceMappingURL=E2EIServiceInternal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"E2EIServiceInternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAI9C,OAAO,EAAgB,WAAW,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"E2EIServiceInternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.ts"],"names":[],"m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 0;
|
|
22
22
|
const commons_1 = require("@wireapp/commons");
|
|
23
23
|
const AcmeServer_1 = require("./Connection/AcmeServer");
|
|
24
|
-
const E2EIService_types_1 = require("./E2EIService.types");
|
|
25
24
|
const Helper_1 = require("./Helper");
|
|
26
25
|
const Account_1 = require("./Steps/Account");
|
|
27
26
|
const Authorization_1 = require("./Steps/Authorization");
|
|
@@ -56,7 +55,7 @@ class E2EIServiceInternal {
|
|
|
56
55
|
* @param getOAuthToken function called when the process needs an oauth token
|
|
57
56
|
* @param refresh should the process refresh the current certificate or get a new one
|
|
58
57
|
*/
|
|
59
|
-
async generateCertificate(getOAuthToken, refresh,
|
|
58
|
+
async generateCertificate(getOAuthToken, refresh, ciphersuite) {
|
|
60
59
|
const stashedEnrollmentData = await this.enrollmentStorage.getPendingEnrollmentData();
|
|
61
60
|
if (stashedEnrollmentData) {
|
|
62
61
|
// In case we have stashed data, we continue the enrollment flow (we are coming back from a redirect)
|
|
@@ -64,7 +63,7 @@ class E2EIServiceInternal {
|
|
|
64
63
|
if (!oAuthToken) {
|
|
65
64
|
throw new Error('No OAuthToken received for in progress enrollment process');
|
|
66
65
|
}
|
|
67
|
-
return this.continueCertificateGeneration(oAuthToken, stashedEnrollmentData
|
|
66
|
+
return this.continueCertificateGeneration(oAuthToken, stashedEnrollmentData);
|
|
68
67
|
}
|
|
69
68
|
// We first get the challenges needed to validate the user identity
|
|
70
69
|
const identity = await this.initIdentity(refresh, ciphersuite);
|
|
@@ -72,7 +71,7 @@ class E2EIServiceInternal {
|
|
|
72
71
|
const { keyauth, oidcChallenge } = enrollmentChallenges.authorization;
|
|
73
72
|
const challengeData = { challenge: oidcChallenge, keyAuth: keyauth };
|
|
74
73
|
// store auth data for continuing the flow later on (in case we are redirected to the identity provider)
|
|
75
|
-
const handle = await this.coreCryptoClient.
|
|
74
|
+
const handle = await this.coreCryptoClient.e2eiEnrollmentStash(identity);
|
|
76
75
|
const enrollmentData = {
|
|
77
76
|
handle,
|
|
78
77
|
...enrollmentChallenges,
|
|
@@ -83,19 +82,19 @@ class E2EIServiceInternal {
|
|
|
83
82
|
if (!oAuthToken) {
|
|
84
83
|
throw new Error('No OAuthToken received for in initial enrollment process');
|
|
85
84
|
}
|
|
86
|
-
return this.continueCertificateGeneration(oAuthToken, enrollmentData
|
|
85
|
+
return this.continueCertificateGeneration(oAuthToken, enrollmentData);
|
|
87
86
|
}
|
|
88
|
-
async continueCertificateGeneration(oAuthToken, enrollmentData
|
|
87
|
+
async continueCertificateGeneration(oAuthToken, enrollmentData) {
|
|
89
88
|
const handle = enrollmentData.handle;
|
|
90
|
-
const identity = await this.coreCryptoClient.
|
|
91
|
-
return this.
|
|
89
|
+
const identity = await this.coreCryptoClient.e2eiEnrollmentStashPop(handle);
|
|
90
|
+
return this.getRotateBundle(identity, oAuthToken, enrollmentData);
|
|
92
91
|
}
|
|
93
92
|
// ############ Internal Functions ############
|
|
94
93
|
async initIdentity(hasActiveCertificate, ciphersuite) {
|
|
95
94
|
const { user } = this.initialData;
|
|
96
95
|
return hasActiveCertificate
|
|
97
|
-
? this.coreCryptoClient.
|
|
98
|
-
: this.coreCryptoClient.
|
|
96
|
+
? this.coreCryptoClient.e2eiNewRotateEnrollment(this.certificateTtl, ciphersuite, user.displayName, user.handle, user.teamId)
|
|
97
|
+
: this.coreCryptoClient.e2eiNewActivationEnrollment(user.displayName, user.handle, this.certificateTtl, ciphersuite, user.teamId);
|
|
99
98
|
}
|
|
100
99
|
async getDirectory(identity, connection) {
|
|
101
100
|
const directory = await connection.getDirectory();
|
|
@@ -159,9 +158,9 @@ class E2EIServiceInternal {
|
|
|
159
158
|
* Stores the received certificate data in local storage for later use
|
|
160
159
|
*
|
|
161
160
|
* @param oAuthIdToken
|
|
162
|
-
* @returns
|
|
161
|
+
* @returns RotateBundle
|
|
163
162
|
*/
|
|
164
|
-
async
|
|
163
|
+
async getRotateBundle(identity, oAuthIdToken, enrollmentData) {
|
|
165
164
|
// Step 7: Do OIDC client challenge
|
|
166
165
|
const oidcData = await (0, OidcChallenge_1.doWireOidcChallenge)({
|
|
167
166
|
oAuthIdToken,
|
|
@@ -211,24 +210,7 @@ class E2EIServiceInternal {
|
|
|
211
210
|
throw new Error('Error while trying to continue OAuth flow. No certificate received');
|
|
212
211
|
}
|
|
213
212
|
// Step 10: Initialize MLS with the certificate
|
|
214
|
-
return this.coreCryptoClient.
|
|
215
|
-
const conversations = await getAllConversations();
|
|
216
|
-
const newCrlDistributionPoints = await cx.saveX509Credential(identity, certificate);
|
|
217
|
-
for (const conversation of conversations) {
|
|
218
|
-
if (Boolean(conversation.group_id?.length)) {
|
|
219
|
-
const idAsBytes = new TextEncoder().encode(conversation.group_id);
|
|
220
|
-
await cx.e2eiRotate(idAsBytes);
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
this.logger.error('No group id found in conversation');
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
const keyPackages = await cx.clientKeypackages(cipherSuite, E2EIService_types_1.CredentialType.X509, this.keyPackagesAmount);
|
|
227
|
-
return {
|
|
228
|
-
newCrlDistributionPoints,
|
|
229
|
-
keyPackages,
|
|
230
|
-
};
|
|
231
|
-
});
|
|
213
|
+
return this.coreCryptoClient.e2eiRotateAll(identity, certificate, this.keyPackagesAmount);
|
|
232
214
|
}
|
|
233
215
|
}
|
|
234
216
|
exports.E2EIServiceInternal = E2EIServiceInternal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageAdd.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,8BAA8B,EAAC,MAAM,+BAA+B,CAAC;AAK7E,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,UAAU,EAAyC,MAAM,gCAAgC,CAAC;AAElG,UAAU,yBAAyB;IACjC,KAAK,EAAE,8BAA8B,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,eAAO,MAAM,mBAAmB,oCAI7B,yBAAyB,KAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"messageAdd.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,8BAA8B,EAAC,MAAM,+BAA+B,CAAC;AAK7E,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,UAAU,EAAyC,MAAM,gCAAgC,CAAC;AAElG,UAAU,yBAAyB;IACjC,KAAK,EAAE,8BAA8B,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,eAAO,MAAM,mBAAmB,oCAI7B,yBAAyB,KAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAoChE,CAAC"}
|
|
@@ -25,19 +25,14 @@ const MLSService_1 = require("../../../MLSService/MLSService");
|
|
|
25
25
|
const handleMLSMessageAdd = async ({ event, groupId, mlsService, }) => {
|
|
26
26
|
const encryptedData = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
|
|
27
27
|
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
28
|
-
const
|
|
29
|
-
if (!decryptedMessage) {
|
|
30
|
-
// If the message is not decrypted, we return null
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
const { message, commitDelay, hasEpochChanged, senderClientId: encodedSenderClientId } = decryptedMessage;
|
|
28
|
+
const { proposals, commitDelay, message, senderClientId: encodedSenderClientId, hasEpochChanged, } = await mlsService.decryptMessage(groupIdBytes, encryptedData);
|
|
34
29
|
if (encodedSenderClientId) {
|
|
35
30
|
const decoder = new TextDecoder();
|
|
36
31
|
const senderClientId = decoder.decode((0, MLSService_1.optionalToUint8Array)(encodedSenderClientId));
|
|
37
32
|
event.senderClientId = senderClientId;
|
|
38
33
|
}
|
|
39
34
|
// Check if the message includes proposals
|
|
40
|
-
if (typeof commitDelay === 'number') {
|
|
35
|
+
if (typeof commitDelay === 'number' || proposals.length > 0) {
|
|
41
36
|
// we are dealing with a proposal, add a task to process this proposal later on
|
|
42
37
|
// Those proposals are stored inside of coreCrypto and will be handled after a timeout
|
|
43
38
|
await mlsService.handlePendingProposals({
|
|
@@ -45,11 +45,45 @@ const createMockedMessage = () => {
|
|
|
45
45
|
})).finish();
|
|
46
46
|
};
|
|
47
47
|
describe('handleMLSMessageAdd', () => {
|
|
48
|
+
it('does not handle pending proposals if message does not contain proposals', async () => {
|
|
49
|
+
const event = createMLSMessageAddEventMock({ id: 'conversationId', domain: 'staging.zinfra.io' });
|
|
50
|
+
const mockGroupId = 'AAEAAH87aajaQ011i+rNLmwpy0sAZGl5YS53aXJlLmxpbms=';
|
|
51
|
+
const message = createMockedMessage();
|
|
52
|
+
jest.spyOn(mockedMLSService, 'decryptMessage').mockResolvedValueOnce({
|
|
53
|
+
proposals: [],
|
|
54
|
+
commitDelay: undefined,
|
|
55
|
+
message,
|
|
56
|
+
hasEpochChanged: false,
|
|
57
|
+
isActive: true,
|
|
58
|
+
});
|
|
59
|
+
await (0, messageAdd_1.handleMLSMessageAdd)({ event, mlsService: mockedMLSService, groupId: mockGroupId });
|
|
60
|
+
expect(mockedMLSService.handlePendingProposals).not.toHaveBeenCalled();
|
|
61
|
+
});
|
|
62
|
+
it('handles pending proposals if message includes proposals', async () => {
|
|
63
|
+
const event = createMLSMessageAddEventMock({ id: 'conversationId', domain: 'staging.zinfra.io' });
|
|
64
|
+
const mockGroupId = 'AAEAAH87aajaQ011i+rNLmwpy0sAZGl5YS53aXJlLmxpbms=';
|
|
65
|
+
const message = createMockedMessage();
|
|
66
|
+
jest.spyOn(mockedMLSService, 'decryptMessage').mockResolvedValueOnce({
|
|
67
|
+
proposals: [{ proposal: new Uint8Array(), proposalRef: new Uint8Array(), crlNewDistributionPoints: [] }],
|
|
68
|
+
commitDelay: 2000,
|
|
69
|
+
crlNewDistributionPoints: [],
|
|
70
|
+
message,
|
|
71
|
+
hasEpochChanged: false,
|
|
72
|
+
isActive: true,
|
|
73
|
+
});
|
|
74
|
+
await (0, messageAdd_1.handleMLSMessageAdd)({ event, mlsService: mockedMLSService, groupId: mockGroupId });
|
|
75
|
+
expect(mockedMLSService.handlePendingProposals).toHaveBeenCalledWith({
|
|
76
|
+
groupId: mockGroupId,
|
|
77
|
+
delayInMs: 2000,
|
|
78
|
+
eventTime: event.time,
|
|
79
|
+
});
|
|
80
|
+
});
|
|
48
81
|
it('emits "newEpoch" event if incoming message has advanced epoch number', async () => {
|
|
49
82
|
const event = createMLSMessageAddEventMock({ id: 'conversationId', domain: 'staging.zinfra.io' });
|
|
50
83
|
const mockGroupId = 'AAEAAH87aajaQ011i+rNLmwpy0sAZGl5YS53aXJlLmxpbms=';
|
|
51
84
|
const message = createMockedMessage();
|
|
52
85
|
jest.spyOn(mockedMLSService, 'decryptMessage').mockResolvedValueOnce({
|
|
86
|
+
proposals: [],
|
|
53
87
|
message,
|
|
54
88
|
hasEpochChanged: true,
|
|
55
89
|
isActive: true,
|
package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
const event_1 = require("@wireapp/api-client/lib/event");
|
|
22
22
|
const welcomeMessage_1 = require("./welcomeMessage");
|
|
23
|
-
const
|
|
23
|
+
const __1 = require("../../..");
|
|
24
24
|
jest.mock('bazinga64', () => ({
|
|
25
25
|
...jest.requireActual('bazinga64'),
|
|
26
26
|
Decoder: {
|
|
@@ -62,7 +62,7 @@ describe('MLS welcomeMessage eventHandler', () => {
|
|
|
62
62
|
it('emits new epoch event after processing a welcome message', async () => {
|
|
63
63
|
jest.spyOn(mockParams.mlsService, 'getEpoch').mockResolvedValue(1);
|
|
64
64
|
await (0, welcomeMessage_1.handleMLSWelcomeMessage)(mockParams);
|
|
65
|
-
expect(mockParams.mlsService.emit).toHaveBeenCalledWith(
|
|
65
|
+
expect(mockParams.mlsService.emit).toHaveBeenCalledWith(__1.MLSServiceEvents.NEW_EPOCH, {
|
|
66
66
|
groupId: 'conversationId',
|
|
67
67
|
epoch: 1,
|
|
68
68
|
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { MLSPublicKeyRecord, RegisteredClient } from '@wireapp/api-client/lib/client';
|
|
2
|
-
import { SUBCONVERSATION_ID } from '@wireapp/api-client/lib/conversation';
|
|
2
|
+
import { PostMlsMessageResponse, SUBCONVERSATION_ID } from '@wireapp/api-client/lib/conversation';
|
|
3
3
|
import { ConversationMLSMessageAddEvent, ConversationMLSWelcomeEvent } from '@wireapp/api-client/lib/event';
|
|
4
4
|
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
5
5
|
import { APIClient } from '@wireapp/api-client';
|
|
6
6
|
import { TypedEventEmitter } from '@wireapp/commons';
|
|
7
|
-
import { Ciphersuite, ConversationId, CoreCrypto, DecryptedMessage } from '@wireapp/core-crypto';
|
|
7
|
+
import { AddProposalArgs, Ciphersuite, ConversationId, CoreCrypto, DecryptedMessage, ProposalArgs, ProposalType, RemoveProposalArgs } from '@wireapp/core-crypto';
|
|
8
8
|
import { AddUsersFailure, KeyPackageClaimUser } from '../../../conversation';
|
|
9
9
|
import { CoreDatabase } from '../../../storage/CoreDB';
|
|
10
10
|
import { RecurringTaskScheduler } from '../../../util/RecurringTaskScheduler';
|
|
11
11
|
import { User } from '../E2EIdentityService';
|
|
12
|
-
import {
|
|
12
|
+
import { getTokenCallback } from '../E2EIdentityService/E2EIServiceInternal';
|
|
13
13
|
import { ClientId, HandlePendingProposalsParams } from '../types';
|
|
14
14
|
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
15
15
|
interface MLSConfig {
|
|
@@ -33,8 +33,7 @@ export declare const optionalToUint8Array: (array: Uint8Array | []) => Uint8Arra
|
|
|
33
33
|
export declare enum MLSServiceEvents {
|
|
34
34
|
NEW_EPOCH = "newEpoch",
|
|
35
35
|
MLS_CLIENT_MISMATCH = "mlsClientMismatch",
|
|
36
|
-
NEW_CRL_DISTRIBUTION_POINTS = "newCrlDistributionPoints"
|
|
37
|
-
MLS_EVENT_DISTRIBUTED = "mlsEventDistributed"
|
|
36
|
+
NEW_CRL_DISTRIBUTION_POINTS = "newCrlDistributionPoints"
|
|
38
37
|
}
|
|
39
38
|
type Events = {
|
|
40
39
|
[MLSServiceEvents.NEW_EPOCH]: {
|
|
@@ -43,10 +42,6 @@ type Events = {
|
|
|
43
42
|
};
|
|
44
43
|
[MLSServiceEvents.NEW_CRL_DISTRIBUTION_POINTS]: string[];
|
|
45
44
|
[MLSServiceEvents.MLS_CLIENT_MISMATCH]: void;
|
|
46
|
-
[MLSServiceEvents.MLS_EVENT_DISTRIBUTED]: {
|
|
47
|
-
events: any;
|
|
48
|
-
time: string;
|
|
49
|
-
};
|
|
50
45
|
};
|
|
51
46
|
export declare class MLSService extends TypedEventEmitter<Events> {
|
|
52
47
|
private readonly apiClient;
|
|
@@ -57,6 +52,7 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
57
52
|
private _config?;
|
|
58
53
|
private readonly textEncoder;
|
|
59
54
|
private readonly textDecoder;
|
|
55
|
+
private readonly conflictBackoffQueue;
|
|
60
56
|
constructor(apiClient: APIClient, coreCryptoClient: CoreCrypto, coreDatabase: CoreDatabase, recurringTaskScheduler: RecurringTaskScheduler);
|
|
61
57
|
/**
|
|
62
58
|
* return true if the MLS service if configured and ready to be used
|
|
@@ -77,6 +73,7 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
77
73
|
*/
|
|
78
74
|
isInitializedMLSClient: (client: RegisteredClient) => boolean;
|
|
79
75
|
private getCredentialType;
|
|
76
|
+
private uploadCommitBundle;
|
|
80
77
|
private readonly _uploadCommitBundle;
|
|
81
78
|
/**
|
|
82
79
|
* Will add users to an existing MLS group and send a commit bundle to backend.
|
|
@@ -85,7 +82,9 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
85
82
|
* @param groupId - the group id of the MLS group
|
|
86
83
|
* @param keyPackages - the list of keys of clients to add to the MLS group
|
|
87
84
|
*/
|
|
88
|
-
addUsersToExistingConversation(groupId: string, keyPackages: Uint8Array[]): Promise<
|
|
85
|
+
addUsersToExistingConversation(groupId: string, keyPackages: Uint8Array[]): Promise<PostMlsMessageResponse & {
|
|
86
|
+
failures: AddUsersFailure[];
|
|
87
|
+
}>;
|
|
89
88
|
/**
|
|
90
89
|
* Will return a list of client ids which are already in the group at core crypto level
|
|
91
90
|
*
|
|
@@ -98,12 +97,24 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
98
97
|
failures: AddUsersFailure[];
|
|
99
98
|
}>;
|
|
100
99
|
getEpoch(groupId: string | Uint8Array): Promise<number>;
|
|
101
|
-
|
|
100
|
+
newProposal(proposalType: ProposalType, args: ProposalArgs | AddProposalArgs | RemoveProposalArgs): Promise<import("@wireapp/core-crypto").ProposalBundle>;
|
|
101
|
+
joinByExternalCommit(getGroupInfo: () => Promise<Uint8Array>): Promise<PostMlsMessageResponse>;
|
|
102
102
|
exportSecretKey(groupId: string, keyLength: number): Promise<string>;
|
|
103
103
|
private dispatchNewCrlDistributionPoints;
|
|
104
104
|
processWelcomeMessage(welcomeMessage: Uint8Array): Promise<ConversationId>;
|
|
105
|
-
decryptMessage(conversationId: ConversationId, payload: Uint8Array): Promise<DecryptedMessage
|
|
105
|
+
decryptMessage(conversationId: ConversationId, payload: Uint8Array): Promise<DecryptedMessage>;
|
|
106
106
|
encryptMessage(conversationId: ConversationId, message: Uint8Array): Promise<Uint8Array>;
|
|
107
|
+
/**
|
|
108
|
+
* Will wrap a coreCrypto call that generates a CommitBundle and do all the necessary work so that commitbundle is handled the right way.
|
|
109
|
+
* It does:
|
|
110
|
+
* - commit the pending proposal
|
|
111
|
+
* - then generates the commitBundle with the given function
|
|
112
|
+
* - uploads the commitBundle to backend
|
|
113
|
+
* - warns coreCrypto that the commit was successfully processed
|
|
114
|
+
* @param groupId
|
|
115
|
+
* @param generateCommit The function that will generate a coreCrypto CommitBundle
|
|
116
|
+
*/
|
|
117
|
+
private processCommitAction;
|
|
107
118
|
private updateKeyingMaterial;
|
|
108
119
|
/**
|
|
109
120
|
* Will create an empty conversation inside of coreCrypto.
|
|
@@ -124,7 +135,9 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
124
135
|
client?: string;
|
|
125
136
|
};
|
|
126
137
|
parentGroupId?: string;
|
|
127
|
-
}): Promise<
|
|
138
|
+
}): Promise<PostMlsMessageResponse & {
|
|
139
|
+
failures: AddUsersFailure[];
|
|
140
|
+
}>;
|
|
128
141
|
/**
|
|
129
142
|
* Will create a 1:1 conversation inside of coreCrypto, try claiming key packages for user and (if succesfull) add them to the MLS group.
|
|
130
143
|
* @param groupId the id of the group to create inside of coreCrypto
|
|
@@ -134,7 +147,9 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
134
147
|
register1to1Conversation(groupId: string, userId: QualifiedId, selfUser: {
|
|
135
148
|
user: QualifiedId;
|
|
136
149
|
client: string;
|
|
137
|
-
}, removalKeyFor1to1Signature?: MLSPublicKeyRecord): Promise<
|
|
150
|
+
}, removalKeyFor1to1Signature?: MLSPublicKeyRecord): Promise<PostMlsMessageResponse & {
|
|
151
|
+
failures: AddUsersFailure[];
|
|
152
|
+
}>;
|
|
138
153
|
/**
|
|
139
154
|
* Will try to register mls group and send an empty commit to establish it.
|
|
140
155
|
*
|
|
@@ -147,7 +162,7 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
147
162
|
* @param groupId groupId of the conversation
|
|
148
163
|
* @param clientIds the list of **qualified** ids of the clients we want to remove from the group
|
|
149
164
|
*/
|
|
150
|
-
removeClientsFromConversation(groupId: string, clientIds: ClientId[]): Promise<
|
|
165
|
+
removeClientsFromConversation(groupId: string, clientIds: ClientId[]): Promise<PostMlsMessageResponse>;
|
|
151
166
|
/**
|
|
152
167
|
* Will check if mls group exists in corecrypto.
|
|
153
168
|
* @param groupId groupId of the conversation
|
|
@@ -258,7 +273,7 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
258
273
|
* @param oAuthIdToken The OAuth id token if the user is already authenticated
|
|
259
274
|
* @returns AcmeChallenge if the user is not authenticated, true if the user is authenticated
|
|
260
275
|
*/
|
|
261
|
-
enrollE2EI(discoveryUrl: string, user: User, client: RegisteredClient, nbPrekeys: number, certificateTtl: number, getOAuthToken: getTokenCallback
|
|
276
|
+
enrollE2EI(discoveryUrl: string, user: User, client: RegisteredClient, nbPrekeys: number, certificateTtl: number, getOAuthToken: getTokenCallback): Promise<void>;
|
|
262
277
|
}
|
|
263
278
|
export {};
|
|
264
279
|
//# sourceMappingURL=MLSService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MLSService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAqB,kBAAkB,EAAE,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AAC7G,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"MLSService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAqB,kBAAkB,EAAE,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AAC7G,OAAO,EAAC,sBAAsB,EAAE,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAChG,OAAO,EAAC,8BAA8B,EAAE,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAE1G,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,SAAS,EA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