@wireapp/core 41.2.4 → 41.3.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.
- package/lib/Account.d.ts +1 -2
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +14 -10
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.js +4 -3
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.test.js +4 -4
- package/package.json +2 -2
package/lib/Account.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ import { ConnectionService } from './connection/';
|
|
|
10
10
|
import { AssetService, ConversationService } from './conversation/';
|
|
11
11
|
import { GiphyService } from './giphy/';
|
|
12
12
|
import { LinkPreviewService } from './linkPreview';
|
|
13
|
-
import { MLSService } from './messagingProtocols/mls';
|
|
14
13
|
import { MLSCallbacks, CryptoProtocolConfig } from './messagingProtocols/mls/types';
|
|
15
14
|
import { NewClient, ProteusService } from './messagingProtocols/proteus';
|
|
16
15
|
import { HandledEventPayload, NotificationService, NotificationSource } from './notification/';
|
|
@@ -70,8 +69,8 @@ export declare class Account extends TypedEventEmitter<Events> {
|
|
|
70
69
|
private db?;
|
|
71
70
|
private readonly nbPrekeys;
|
|
72
71
|
private readonly cryptoProtocolConfig?;
|
|
72
|
+
private protectedServices?;
|
|
73
73
|
service?: {
|
|
74
|
-
mls?: MLSService;
|
|
75
74
|
proteus: ProteusService;
|
|
76
75
|
account: AccountService;
|
|
77
76
|
asset: AssetService;
|
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,EACV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAuB,UAAU,EAAE,gBAAgB,EAAC,MAAM,iCAAiC,CAA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EtF;;WAEG;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;IA2FnB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,kBAAkB;YAIZ,UAAU;CAqBzB"}
|
package/lib/Account.js
CHANGED
|
@@ -172,6 +172,7 @@ class Account extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
172
172
|
* Will register a new client for the current user
|
|
173
173
|
*/
|
|
174
174
|
async registerClient(loginData, clientInfo = coreDefaultClient, entropyData) {
|
|
175
|
+
var _a, _b;
|
|
175
176
|
if (!this.service || !this.apiClient.context || !this.storeEngine) {
|
|
176
177
|
throw new Error('Services are not set or context not initialized.');
|
|
177
178
|
}
|
|
@@ -179,16 +180,17 @@ class Account extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
179
180
|
await this.initServices(this.apiClient.context);
|
|
180
181
|
const initialPreKeys = await this.service.proteus.createClient(entropyData);
|
|
181
182
|
const client = await this.service.client.register(loginData, clientInfo, initialPreKeys);
|
|
182
|
-
if (this.
|
|
183
|
+
if ((_a = this.protectedServices) === null || _a === void 0 ? void 0 : _a.mls) {
|
|
183
184
|
const { userId, domain = '' } = this.apiClient.context;
|
|
184
|
-
await this.
|
|
185
|
+
await this.protectedServices.mls.createClient({ id: userId, domain }, client.id);
|
|
185
186
|
}
|
|
186
|
-
this.logger.info(`Created new client {mls: ${!!this.
|
|
187
|
+
this.logger.info(`Created new client {mls: ${!!((_b = this.protectedServices) === null || _b === void 0 ? void 0 : _b.mls)}, id: ${client.id}}`);
|
|
187
188
|
await this.service.notification.initializeNotificationStream();
|
|
188
189
|
await this.service.client.synchronizeClients(client.id);
|
|
189
190
|
return this.initClient(client);
|
|
190
191
|
}
|
|
191
192
|
async initClient(client) {
|
|
193
|
+
var _a;
|
|
192
194
|
if (!this.service || !this.apiClient.context || !this.storeEngine) {
|
|
193
195
|
throw new Error('Services are not set.');
|
|
194
196
|
}
|
|
@@ -200,18 +202,18 @@ class Account extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
200
202
|
// Call /access endpoint with client_id after client initialisation
|
|
201
203
|
await this.apiClient.transport.http.associateClientWithSession(validClient.id);
|
|
202
204
|
await this.service.proteus.initClient(this.storeEngine, this.apiClient.context);
|
|
203
|
-
if (this.
|
|
205
|
+
if ((_a = this.protectedServices) === null || _a === void 0 ? void 0 : _a.mls) {
|
|
204
206
|
const { userId, domain = '' } = this.apiClient.context;
|
|
205
207
|
if (!client) {
|
|
206
208
|
// If the client has been passed to the method, it means it also has been initialized
|
|
207
|
-
await this.
|
|
209
|
+
await this.protectedServices.mls.initClient({ id: userId, domain }, validClient.id);
|
|
208
210
|
}
|
|
209
211
|
// initialize schedulers for pending mls proposals once client is initialized
|
|
210
|
-
await this.
|
|
212
|
+
await this.protectedServices.mls.checkExistingPendingProposals();
|
|
211
213
|
// initialize scheduler for syncing key packages with backend
|
|
212
|
-
this.
|
|
214
|
+
this.protectedServices.mls.checkForKeyPackagesBackendSync();
|
|
213
215
|
// leave stale conference subconversations (e.g after a crash)
|
|
214
|
-
await this.
|
|
216
|
+
await this.protectedServices.mls.leaveStaleConferenceSubconversations();
|
|
215
217
|
}
|
|
216
218
|
return validClient;
|
|
217
219
|
}
|
|
@@ -248,7 +250,7 @@ class Account extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
248
250
|
*/
|
|
249
251
|
configureMLSCallbacks(mlsCallbacks) {
|
|
250
252
|
var _a, _b;
|
|
251
|
-
(_b = (_a = this.
|
|
253
|
+
(_b = (_a = this.protectedServices) === null || _a === void 0 ? void 0 : _a.mls) === null || _b === void 0 ? void 0 : _b.configureMLSCallbacks(mlsCallbacks);
|
|
252
254
|
}
|
|
253
255
|
async initServices(context) {
|
|
254
256
|
var _a, _b;
|
|
@@ -276,8 +278,10 @@ class Account extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
276
278
|
const teamService = new team_1.TeamService(this.apiClient);
|
|
277
279
|
const broadcastService = new broadcast_1.BroadcastService(this.apiClient, proteusService);
|
|
278
280
|
const userService = new user_1.UserService(this.apiClient);
|
|
279
|
-
this.
|
|
281
|
+
this.protectedServices = {
|
|
280
282
|
mls: mlsService,
|
|
283
|
+
};
|
|
284
|
+
this.service = {
|
|
281
285
|
proteus: proteusService,
|
|
282
286
|
account: accountService,
|
|
283
287
|
asset: assetService,
|
|
@@ -34,11 +34,12 @@ const isCryptoboxError = (error) => {
|
|
|
34
34
|
return 'code' in error;
|
|
35
35
|
};
|
|
36
36
|
const generateDecryptionError = (senderInfo, error) => {
|
|
37
|
+
var _a;
|
|
37
38
|
const { clientId, userId } = senderInfo;
|
|
38
39
|
const sender = `${userId.id} (${clientId})`;
|
|
39
|
-
const coreCryptoCode = isCoreCryptoError(error)
|
|
40
|
-
const cryptoboxCode = isCryptoboxError(error)
|
|
41
|
-
const code = coreCryptoCode
|
|
40
|
+
const coreCryptoCode = isCoreCryptoError(error) ? error.proteusErrorCode : null;
|
|
41
|
+
const cryptoboxCode = isCryptoboxError(error) ? error.code : null;
|
|
42
|
+
const code = (_a = coreCryptoCode !== null && coreCryptoCode !== void 0 ? coreCryptoCode : cryptoboxCode) !== null && _a !== void 0 ? _a : exports.ProteusErrors.Unknown;
|
|
42
43
|
const message = `Decryption error from ${sender} (${error.message})`;
|
|
43
44
|
return new DecryptionError_1.DecryptionError(message, code);
|
|
44
45
|
};
|
|
@@ -22,15 +22,15 @@ const DecryptionErrorGenerator_1 = require("./DecryptionErrorGenerator");
|
|
|
22
22
|
const DecryptionError_1 = require("../../../../errors/DecryptionError");
|
|
23
23
|
const basePayload = { userId: { id: 'user1', domain: 'domain' }, clientId: 'client1' };
|
|
24
24
|
describe('generateDecryptionError', () => {
|
|
25
|
-
it('handles coreCrypto error',
|
|
26
|
-
const coreCryptoError = { proteusErrorCode
|
|
25
|
+
it.each([Math.floor(Math.random() * 100), 0])('handles coreCrypto error', proteusErrorCode => {
|
|
26
|
+
const coreCryptoError = { proteusErrorCode, message: 'decryption error' };
|
|
27
27
|
const error = (0, DecryptionErrorGenerator_1.generateDecryptionError)(basePayload, coreCryptoError);
|
|
28
28
|
expect(error).toBeInstanceOf(DecryptionError_1.DecryptionError);
|
|
29
29
|
expect(error.message).toBe(`Decryption error from user1 (client1) (${coreCryptoError.message})`);
|
|
30
30
|
expect(error.code).toBe(coreCryptoError.proteusErrorCode);
|
|
31
31
|
});
|
|
32
|
-
it('handles cryptobox error',
|
|
33
|
-
const coreCryptoError = { code
|
|
32
|
+
it.each([Math.floor(Math.random() * 100), 0])('handles cryptobox error', code => {
|
|
33
|
+
const coreCryptoError = { code, message: 'decryption error' };
|
|
34
34
|
const error = (0, DecryptionErrorGenerator_1.generateDecryptionError)(basePayload, coreCryptoError);
|
|
35
35
|
expect(error).toBeInstanceOf(DecryptionError_1.DecryptionError);
|
|
36
36
|
expect(error.message).toBe(`Decryption error from user1 (client1) (${coreCryptoError.message})`);
|
package/package.json
CHANGED