@wireapp/core 42.5.0 → 42.6.0
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.
|
@@ -38,7 +38,7 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
38
38
|
private readonly textDecoder;
|
|
39
39
|
constructor(apiClient: APIClient, coreCryptoClient: CoreCrypto, { keyingMaterialUpdateThreshold, nbKeyPackages, defaultCiphersuite, defaultCredentialType, }: Partial<MLSServiceConfig>);
|
|
40
40
|
initClient(userId: QualifiedId, client: RegisteredClient): Promise<void>;
|
|
41
|
-
private uploadCommitBundle;
|
|
41
|
+
private readonly uploadCommitBundle;
|
|
42
42
|
/**
|
|
43
43
|
* Will add users to an existing MLS group and send a commit bundle to backend.
|
|
44
44
|
* Cannot be called with an empty array of keys.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MLSService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAqB,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAC,sBAAsB,EAAE,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAChG,OAAO,EAAC,eAAe,EAAC,MAAM,sDAAsD,CAAC;AACrF,OAAO,EAAC,8BAA8B,EAAE,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAE1G,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAGzD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EACL,eAAe,EAIf,cAAc,EACd,UAAU,EAEV,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,gBAAgB,EAAsB,MAAM,o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AK,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM;CAa/F"}
|
|
@@ -69,6 +69,43 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
69
69
|
this.logger = (0, logdown_1.default)('@wireapp/core/MLSService');
|
|
70
70
|
this.textEncoder = new TextEncoder();
|
|
71
71
|
this.textDecoder = new TextDecoder();
|
|
72
|
+
// We need to lock the websocket while commit bundle is being processed by backend,
|
|
73
|
+
// it's possible that we will be sent some mls messages before we receive the response from backend and accept a commit locally.
|
|
74
|
+
this.uploadCommitBundle = this.apiClient.withLockedWebSocket(async (groupId, commitBundle, { regenerateCommitBundle, isExternalCommit } = {}) => {
|
|
75
|
+
const { commit, groupInfo, welcome } = commitBundle;
|
|
76
|
+
const bundlePayload = new Uint8Array([...commit, ...groupInfo.payload, ...(welcome || [])]);
|
|
77
|
+
try {
|
|
78
|
+
const response = await this.apiClient.api.conversation.postMlsCommitBundle(bundlePayload);
|
|
79
|
+
if (isExternalCommit) {
|
|
80
|
+
await this.coreCryptoClient.mergePendingGroupFromExternalCommit(groupId);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
await this.coreCryptoClient.commitAccepted(groupId);
|
|
84
|
+
}
|
|
85
|
+
const newEpoch = await this.getEpoch(groupId);
|
|
86
|
+
const groupIdStr = bazinga64_1.Encoder.toBase64(groupId).asString;
|
|
87
|
+
this.emit('newEpoch', { epoch: newEpoch, groupId: groupIdStr });
|
|
88
|
+
return response;
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
if (isExternalCommit) {
|
|
92
|
+
await this.coreCryptoClient.clearPendingGroupFromExternalCommit(groupId);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
await this.coreCryptoClient.clearPendingCommit(groupId);
|
|
96
|
+
}
|
|
97
|
+
const shouldRetry = error instanceof http_1.BackendError && error.code === http_1.StatusCode.CONFLICT;
|
|
98
|
+
if (shouldRetry && regenerateCommitBundle) {
|
|
99
|
+
// in case of a 409, we want to retry to generate the commit and resend it
|
|
100
|
+
// could be that we are trying to upload a commit to a conversation that has a different epoch on backend
|
|
101
|
+
// in this case we will most likely receive a commit from backend that will increase our local epoch
|
|
102
|
+
this.logger.warn(`Uploading commitBundle failed. Will retry generating a new bundle`);
|
|
103
|
+
const updatedCommitBundle = await regenerateCommitBundle();
|
|
104
|
+
return this.uploadCommitBundle(groupId, updatedCommitBundle, { isExternalCommit });
|
|
105
|
+
}
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
72
109
|
this.config = {
|
|
73
110
|
keyingMaterialUpdateThreshold,
|
|
74
111
|
nbKeyPackages,
|
|
@@ -84,41 +121,6 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
84
121
|
await this.uploadMLSPublicKeys(client);
|
|
85
122
|
await this.verifyRemoteMLSKeyPackagesAmount(client.id);
|
|
86
123
|
}
|
|
87
|
-
async uploadCommitBundle(groupId, commitBundle, { regenerateCommitBundle, isExternalCommit } = {}) {
|
|
88
|
-
const { commit, groupInfo, welcome } = commitBundle;
|
|
89
|
-
const bundlePayload = new Uint8Array([...commit, ...groupInfo.payload, ...(welcome || [])]);
|
|
90
|
-
try {
|
|
91
|
-
const response = await this.apiClient.api.conversation.postMlsCommitBundle(bundlePayload);
|
|
92
|
-
if (isExternalCommit) {
|
|
93
|
-
await this.coreCryptoClient.mergePendingGroupFromExternalCommit(groupId);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
await this.coreCryptoClient.commitAccepted(groupId);
|
|
97
|
-
}
|
|
98
|
-
const newEpoch = await this.getEpoch(groupId);
|
|
99
|
-
const groupIdStr = bazinga64_1.Encoder.toBase64(groupId).asString;
|
|
100
|
-
this.emit('newEpoch', { epoch: newEpoch, groupId: groupIdStr });
|
|
101
|
-
return response;
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
if (isExternalCommit) {
|
|
105
|
-
await this.coreCryptoClient.clearPendingGroupFromExternalCommit(groupId);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
await this.coreCryptoClient.clearPendingCommit(groupId);
|
|
109
|
-
}
|
|
110
|
-
const shouldRetry = error instanceof http_1.BackendError && error.code === http_1.StatusCode.CONFLICT;
|
|
111
|
-
if (shouldRetry && regenerateCommitBundle) {
|
|
112
|
-
// in case of a 409, we want to retry to generate the commit and resend it
|
|
113
|
-
// could be that we are trying to upload a commit to a conversation that has a different epoch on backend
|
|
114
|
-
// in this case we will most likely receive a commit from backend that will increase our local epoch
|
|
115
|
-
this.logger.warn(`Uploading commitBundle failed. Will retry generating a new bundle`);
|
|
116
|
-
const updatedCommitBundle = await regenerateCommitBundle();
|
|
117
|
-
return this.uploadCommitBundle(groupId, updatedCommitBundle, { isExternalCommit });
|
|
118
|
-
}
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
124
|
/**
|
|
123
125
|
* Will add users to an existing MLS group and send a commit bundle to backend.
|
|
124
126
|
* Cannot be called with an empty array of keys.
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@wireapp/api-client": "^26.
|
|
14
|
+
"@wireapp/api-client": "^26.2.0",
|
|
15
15
|
"@wireapp/commons": "^5.1.3",
|
|
16
16
|
"@wireapp/core-crypto": "1.0.0-rc.12",
|
|
17
17
|
"@wireapp/cryptobox": "12.8.0",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"bazinga64": "^6.3.1",
|
|
24
24
|
"deepmerge-ts": "5.1.0",
|
|
25
25
|
"hash.js": "1.1.7",
|
|
26
|
-
"http-status-codes": "2.
|
|
26
|
+
"http-status-codes": "2.3.0",
|
|
27
27
|
"idb": "7.1.1",
|
|
28
28
|
"logdown": "3.3.1",
|
|
29
29
|
"long": "^5.2.0",
|
|
@@ -60,6 +60,6 @@
|
|
|
60
60
|
"test:coverage": "jest --coverage",
|
|
61
61
|
"watch": "tsc --watch"
|
|
62
62
|
},
|
|
63
|
-
"version": "42.
|
|
64
|
-
"gitHead": "
|
|
63
|
+
"version": "42.6.0",
|
|
64
|
+
"gitHead": "839ca7394c0fcb3ff4a87dfd121b2b6ac0d20b29"
|
|
65
65
|
}
|