@wireapp/core 38.4.2 → 38.4.3
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 +2 -3
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +37 -32
- package/lib/messagingProtocols/mls/MLSService/MLSService.types.d.ts +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper.d.ts +5 -2
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper.js +14 -4
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.d.ts +15 -5
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.js +42 -8
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts +7 -3
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.d.ts +6 -2
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.js +10 -7
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts +4 -5
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.js +7 -5
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.js +2 -2
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts +0 -2
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +4 -4
- package/package.json +4 -4
package/lib/Account.d.ts
CHANGED
|
@@ -71,7 +71,6 @@ export declare class Account<T = any> extends EventEmitter {
|
|
|
71
71
|
private secretsDb?;
|
|
72
72
|
private readonly nbPrekeys;
|
|
73
73
|
private readonly cryptoProtocolConfig?;
|
|
74
|
-
private coreCryptoClient?;
|
|
75
74
|
service?: {
|
|
76
75
|
mls?: MLSService;
|
|
77
76
|
proteus: ProteusService;
|
|
@@ -139,7 +138,8 @@ export declare class Account<T = any> extends EventEmitter {
|
|
|
139
138
|
* @returns The local existing client or undefined if the client does not exist or is not valid (non existing on backend)
|
|
140
139
|
*/
|
|
141
140
|
initClient(client?: RegisteredClient): Promise<RegisteredClient | undefined>;
|
|
142
|
-
private
|
|
141
|
+
private generateSecretKey;
|
|
142
|
+
private buildCryptoClient;
|
|
143
143
|
/**
|
|
144
144
|
* In order to be able to send MLS messages, the core needs a few information from the consumer.
|
|
145
145
|
* Namely:
|
|
@@ -195,7 +195,6 @@ export declare class Account<T = any> extends EventEmitter {
|
|
|
195
195
|
dryRun?: boolean;
|
|
196
196
|
}): () => void;
|
|
197
197
|
private generateDbName;
|
|
198
|
-
private generateSecretsDbName;
|
|
199
198
|
private generateCoreDbName;
|
|
200
199
|
private initEngine;
|
|
201
200
|
}
|
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,CAAC;
|
|
1
|
+
{"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../src/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AAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;YAiC3E,iBAAiB;YAkBjB,iBAAiB;IAyB/B;;;;;;OAMG;IACH,qBAAqB,CAAC,YAAY,EAAE,YAAY;IAInC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAgE1D,OAAO,CAAC,YAAY;IAKpB;;;OAGG;IACU,MAAM,CAAC,SAAS,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;YAShD,IAAI;IAQlB;;;;;;OAMG;IACI,MAAM,CAAC,EACZ,OAAkB,EAClB,wBAAmC,EACnC,4BAAuC,EACvC,qBAAgC,EAChC,MAAc,GACf,GAAE;QACD;;;;WAIG;QACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;QAE7E;;WAEG;QACH,4BAA4B,CAAC,EAAE,CAAC,EAAC,IAAI,EAAE,KAAK,EAAC,EAAE;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAC,KAAK,IAAI,CAAC;QAEtF;;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
|
@@ -34,12 +34,9 @@ const client_1 = require("@wireapp/api-client/lib/client/");
|
|
|
34
34
|
const event_1 = require("@wireapp/api-client/lib/event");
|
|
35
35
|
const tcp_1 = require("@wireapp/api-client/lib/tcp/");
|
|
36
36
|
const ReconnectingWebsocket_1 = require("@wireapp/api-client/lib/tcp/ReconnectingWebsocket");
|
|
37
|
-
const bazinga64_1 = require("bazinga64");
|
|
38
37
|
const logdown_1 = __importDefault(require("logdown"));
|
|
39
38
|
const events_1 = require("events");
|
|
40
39
|
const api_client_1 = require("@wireapp/api-client");
|
|
41
|
-
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
42
|
-
const cryptobox_1 = require("@wireapp/cryptobox");
|
|
43
40
|
const store_engine_1 = require("@wireapp/store-engine");
|
|
44
41
|
const account_1 = require("./account/");
|
|
45
42
|
const auth_2 = require("./auth/");
|
|
@@ -52,6 +49,7 @@ const giphy_1 = require("./giphy/");
|
|
|
52
49
|
const linkPreview_1 = require("./linkPreview");
|
|
53
50
|
const mls_1 = require("./messagingProtocols/mls");
|
|
54
51
|
const proteus_1 = require("./messagingProtocols/proteus");
|
|
52
|
+
const CryptoClient_1 = require("./messagingProtocols/proteus/ProteusService/CryptoClient");
|
|
55
53
|
const notification_1 = require("./notification/");
|
|
56
54
|
const self_1 = require("./self/");
|
|
57
55
|
const CoreDB_1 = require("./storage/CoreDB");
|
|
@@ -217,10 +215,10 @@ class Account extends events_1.EventEmitter {
|
|
|
217
215
|
}
|
|
218
216
|
return validClient;
|
|
219
217
|
}
|
|
220
|
-
async
|
|
218
|
+
async generateSecretKey(baseDbName) {
|
|
221
219
|
var _a, _b;
|
|
222
220
|
const coreCryptoKeyId = 'corecrypto-key';
|
|
223
|
-
const dbName =
|
|
221
|
+
const dbName = `secrets-${baseDbName}`;
|
|
224
222
|
const systemCrypto = (_a = this.cryptoProtocolConfig) === null || _a === void 0 ? void 0 : _a.systemCrypto;
|
|
225
223
|
this.secretsDb = systemCrypto
|
|
226
224
|
? await (0, encryptedStore_1.createCustomEncryptedStore)(dbName, systemCrypto)
|
|
@@ -230,8 +228,29 @@ class Account extends events_1.EventEmitter {
|
|
|
230
228
|
key = crypto.getRandomValues(new Uint8Array(16));
|
|
231
229
|
await this.secretsDb.saveSecretValue(coreCryptoKeyId, key);
|
|
232
230
|
}
|
|
233
|
-
|
|
234
|
-
|
|
231
|
+
await ((_b = this.secretsDb) === null || _b === void 0 ? void 0 : _b.close());
|
|
232
|
+
return key;
|
|
233
|
+
}
|
|
234
|
+
async buildCryptoClient(context, storeEngine, db, enableMLS) {
|
|
235
|
+
var _a, _b;
|
|
236
|
+
const clientType = enableMLS || !!((_a = this.cryptoProtocolConfig) === null || _a === void 0 ? void 0 : _a.useCoreCrypto)
|
|
237
|
+
? CryptoClient_1.CryptoClientType.CORE_CRYPTO
|
|
238
|
+
: CryptoClient_1.CryptoClientType.CRYPTOBOX;
|
|
239
|
+
let key = Uint8Array.from([]);
|
|
240
|
+
if (clientType === CryptoClient_1.CryptoClientType.CORE_CRYPTO) {
|
|
241
|
+
key = await this.generateSecretKey(storeEngine.storeName);
|
|
242
|
+
}
|
|
243
|
+
return (0, CryptoClient_1.buildCryptoClient)(clientType, db, {
|
|
244
|
+
storeEngine,
|
|
245
|
+
secretKey: key,
|
|
246
|
+
nbPrekeys: this.nbPrekeys,
|
|
247
|
+
coreCryptoWasmFilePath: (_b = this.cryptoProtocolConfig) === null || _b === void 0 ? void 0 : _b.coreCrypoWasmFilePath,
|
|
248
|
+
onNewPrekeys: async (prekeys) => {
|
|
249
|
+
this.logger.debug(`Received '${prekeys.length}' new PreKeys.`);
|
|
250
|
+
await this.apiClient.api.client.putClient(context.clientId, { prekeys });
|
|
251
|
+
this.logger.debug(`Successfully uploaded '${prekeys.length}' PreKeys.`);
|
|
252
|
+
},
|
|
253
|
+
});
|
|
235
254
|
}
|
|
236
255
|
/**
|
|
237
256
|
* In order to be able to send MLS messages, the core needs a few information from the consumer.
|
|
@@ -245,30 +264,22 @@ class Account extends events_1.EventEmitter {
|
|
|
245
264
|
(_b = (_a = this.service) === null || _a === void 0 ? void 0 : _a.mls) === null || _b === void 0 ? void 0 : _b.configureMLSCallbacks(mlsCallbacks);
|
|
246
265
|
}
|
|
247
266
|
async initServices(context) {
|
|
248
|
-
var _a, _b
|
|
249
|
-
const enableMLS = this.backendFeatures.supportsMLS && ((_a = this.cryptoProtocolConfig) === null || _a === void 0 ? void 0 : _a.mls);
|
|
250
|
-
this.coreCryptoClient =
|
|
251
|
-
enableMLS || ((_b = this.cryptoProtocolConfig) === null || _b === void 0 ? void 0 : _b.useCoreCrypto) ? await this.initCoreCrypto(context) : undefined;
|
|
267
|
+
var _a, _b;
|
|
268
|
+
const enableMLS = this.backendFeatures.supportsMLS && !!((_a = this.cryptoProtocolConfig) === null || _a === void 0 ? void 0 : _a.mls);
|
|
252
269
|
this.storeEngine = await this.initEngine(context);
|
|
253
270
|
this.db = await (0, CoreDB_1.openDB)(this.generateCoreDbName(context));
|
|
254
271
|
const accountService = new account_1.AccountService(this.apiClient);
|
|
255
272
|
const assetService = new conversation_1.AssetService(this.apiClient);
|
|
256
|
-
const
|
|
257
|
-
|
|
273
|
+
const cryptoClientDef = await this.buildCryptoClient(context, this.storeEngine, this.db, enableMLS);
|
|
274
|
+
const [clientType, cryptoClient] = cryptoClientDef;
|
|
275
|
+
const mlsService = clientType === CryptoClient_1.CryptoClientType.CORE_CRYPTO && enableMLS
|
|
276
|
+
? new mls_1.MLSService(this.apiClient, cryptoClient.getNativeClient(), Object.assign(Object.assign({}, (_b = this.cryptoProtocolConfig) === null || _b === void 0 ? void 0 : _b.mls), { nbKeyPackages: this.nbPrekeys }))
|
|
258
277
|
: undefined;
|
|
259
|
-
const
|
|
260
|
-
? this.coreCryptoClient
|
|
261
|
-
: new cryptobox_1.Cryptobox(this.storeEngine, this.nbPrekeys);
|
|
262
|
-
const proteusService = new proteus_1.ProteusService(this.apiClient, proteusCryptoClient, this.db, {
|
|
278
|
+
const proteusService = new proteus_1.ProteusService(this.apiClient, cryptoClient, {
|
|
263
279
|
// We can use qualified ids to send messages as long as the backend supports federated endpoints
|
|
264
280
|
useQualifiedIds: this.backendFeatures.federationEndpoints,
|
|
265
281
|
onNewClient: payload => this.emit(EVENTS.NEW_SESSION, payload),
|
|
266
282
|
nbPrekeys: this.nbPrekeys,
|
|
267
|
-
onNewPrekeys: async (prekeys) => {
|
|
268
|
-
this.logger.debug(`Received '${prekeys.length}' new PreKeys.`);
|
|
269
|
-
await this.apiClient.api.client.putClient(context.clientId, { prekeys });
|
|
270
|
-
this.logger.debug(`Successfully uploaded '${prekeys.length}' PreKeys.`);
|
|
271
|
-
},
|
|
272
283
|
});
|
|
273
284
|
const clientService = new client_2.ClientService(this.apiClient, proteusService, this.storeEngine);
|
|
274
285
|
const connectionService = new connection_1.ConnectionService(this.apiClient);
|
|
@@ -309,9 +320,8 @@ class Account extends events_1.EventEmitter {
|
|
|
309
320
|
* @param clearData if set to `true` will completely wipe any database that was created by the Account
|
|
310
321
|
*/
|
|
311
322
|
async logout(clearData = false) {
|
|
312
|
-
var _a
|
|
323
|
+
var _a;
|
|
313
324
|
(_a = this.db) === null || _a === void 0 ? void 0 : _a.close();
|
|
314
|
-
await ((_b = this.secretsDb) === null || _b === void 0 ? void 0 : _b.close());
|
|
315
325
|
if (clearData) {
|
|
316
326
|
await this.wipe();
|
|
317
327
|
}
|
|
@@ -319,11 +329,9 @@ class Account extends events_1.EventEmitter {
|
|
|
319
329
|
this.resetContext();
|
|
320
330
|
}
|
|
321
331
|
async wipe() {
|
|
322
|
-
var _a;
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
await ((_a = this.secretsDb) === null || _a === void 0 ? void 0 : _a.wipe());
|
|
332
|
+
var _a, _b;
|
|
333
|
+
await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.proteus.wipe());
|
|
334
|
+
await ((_b = this.secretsDb) === null || _b === void 0 ? void 0 : _b.wipe());
|
|
327
335
|
if (this.db) {
|
|
328
336
|
await (0, CoreDB_1.deleteDB)(this.db);
|
|
329
337
|
}
|
|
@@ -432,9 +440,6 @@ class Account extends events_1.EventEmitter {
|
|
|
432
440
|
const clientType = context.clientType === client_1.ClientType.NONE ? '' : `@${context.clientType}`;
|
|
433
441
|
return `wire@${this.apiClient.config.urls.name}@${context.userId}${clientType}`;
|
|
434
442
|
}
|
|
435
|
-
generateSecretsDbName(context) {
|
|
436
|
-
return `secrets-${this.generateDbName(context)}`;
|
|
437
|
-
}
|
|
438
443
|
generateCoreDbName(context) {
|
|
439
444
|
return `core-${this.generateDbName(context)}`;
|
|
440
445
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommitBundle } from '@wireapp/core-crypto
|
|
1
|
+
import type { CommitBundle } from '@wireapp/core-crypto';
|
|
2
2
|
export interface UploadCommitOptions {
|
|
3
3
|
/**
|
|
4
4
|
* If uploading the commit fails and we endup in a scenario where a retrial is possible, then this callback will be called to re-generate a new commit bundle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MLSService.types.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAC,MAAM
|
|
1
|
+
{"version":3,"file":"MLSService.types.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.types.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;IAErD;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,6BAA6B,EAAE,MAAM,CAAC;IACtC,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { PreKey } from '@wireapp/api-client/lib/auth';
|
|
2
2
|
import { CoreCrypto } from '@wireapp/core-crypto';
|
|
3
|
+
import type { CRUDEngine } from '@wireapp/store-engine';
|
|
3
4
|
import { CryptoClient } from './CryptoClient.types';
|
|
4
5
|
import { CoreDatabase } from '../../../../storage/CoreDB';
|
|
5
6
|
type Config = {
|
|
6
7
|
nbPrekeys: number;
|
|
7
8
|
onNewPrekeys: (prekeys: PreKey[]) => void;
|
|
8
9
|
};
|
|
10
|
+
export declare function buildClient(storeEngine: CRUDEngine, secretKey: Uint8Array, coreCryptoWasmFilePath: string, db: CoreDatabase, { nbPrekeys, onNewPrekeys }: Config): Promise<CoreCryptoWrapper>;
|
|
9
11
|
export declare class CoreCryptoWrapper implements CryptoClient {
|
|
10
12
|
private readonly coreCrypto;
|
|
11
13
|
private readonly prekeyTracker;
|
|
12
14
|
constructor(coreCrypto: CoreCrypto, db: CoreDatabase, config: Config);
|
|
15
|
+
getNativeClient(): CoreCrypto;
|
|
13
16
|
encrypt(sessions: string[], plainText: Uint8Array): Promise<Map<string, Uint8Array>>;
|
|
14
17
|
decrypt(sessionId: string, message: Uint8Array): Promise<Uint8Array>;
|
|
15
18
|
init(): Promise<void>;
|
|
@@ -33,8 +36,8 @@ export declare class CoreCryptoWrapper implements CryptoClient {
|
|
|
33
36
|
key: string;
|
|
34
37
|
}>;
|
|
35
38
|
debugBreakSession(sessionId: string): Promise<void>;
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
migrateFromCryptobox(dbName: string): Promise<void>;
|
|
40
|
+
wipe(): Promise<void>;
|
|
38
41
|
}
|
|
39
42
|
export {};
|
|
40
43
|
//# sourceMappingURL=CoreCryptoWrapper.d.ts.map
|
package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreCryptoWrapper.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAGpD,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAA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AAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;IAK/D,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IAIvD,aAAa,CAAC,SAAS,EAAE,MAAM;IAI/B,WAAW,CAAC,SAAS,EAAE,MAAM;IAI7B,aAAa,CAAC,SAAS,EAAE,MAAM;IAI/B,aAAa;IAIP,SAAS,CAAC,EAAE,EAAE,MAAM;;;;IAKpB,iBAAiB,CAAC,SAAS,EAAE,MAAM;IAUnC,oBAAoB,CAAC,MAAM,EAAE,MAAM;IAInC,IAAI;CAGX"}
|
|
@@ -18,15 +18,25 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.CoreCryptoWrapper = void 0;
|
|
21
|
+
exports.CoreCryptoWrapper = exports.buildClient = void 0;
|
|
22
22
|
const bazinga64_1 = require("bazinga64");
|
|
23
|
+
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
23
24
|
const CryptoClient_types_1 = require("./CryptoClient.types");
|
|
24
25
|
const PrekeysTracker_1 = require("./PrekeysTracker");
|
|
26
|
+
async function buildClient(storeEngine, secretKey, coreCryptoWasmFilePath, db, { nbPrekeys, onNewPrekeys }) {
|
|
27
|
+
const coreCrypto = await core_crypto_1.CoreCrypto.deferredInit(`corecrypto-${storeEngine.storeName}`, bazinga64_1.Encoder.toBase64(secretKey).asString, undefined, // We pass a placeholder entropy data. It will be set later on by calling `reseedRng`
|
|
28
|
+
coreCryptoWasmFilePath);
|
|
29
|
+
return new CoreCryptoWrapper(coreCrypto, db, { nbPrekeys, onNewPrekeys });
|
|
30
|
+
}
|
|
31
|
+
exports.buildClient = buildClient;
|
|
25
32
|
class CoreCryptoWrapper {
|
|
26
33
|
constructor(coreCrypto, db, config) {
|
|
27
34
|
this.coreCrypto = coreCrypto;
|
|
28
35
|
this.prekeyTracker = new PrekeysTracker_1.PrekeyTracker(this, db, config);
|
|
29
36
|
}
|
|
37
|
+
getNativeClient() {
|
|
38
|
+
return this.coreCrypto;
|
|
39
|
+
}
|
|
30
40
|
encrypt(sessions, plainText) {
|
|
31
41
|
return this.coreCrypto.proteusEncryptBatched(sessions, plainText);
|
|
32
42
|
}
|
|
@@ -88,11 +98,11 @@ class CoreCryptoWrapper {
|
|
|
88
98
|
];
|
|
89
99
|
await this.coreCrypto.proteusSessionFromPrekey(sessionId, Uint8Array.from(fakePrekey));
|
|
90
100
|
}
|
|
91
|
-
async
|
|
101
|
+
async migrateFromCryptobox(dbName) {
|
|
92
102
|
return this.coreCrypto.proteusCryptoboxMigrate(dbName);
|
|
93
103
|
}
|
|
94
|
-
|
|
95
|
-
return
|
|
104
|
+
async wipe() {
|
|
105
|
+
return this.coreCrypto.wipe();
|
|
96
106
|
}
|
|
97
107
|
}
|
|
98
108
|
exports.CoreCryptoWrapper = CoreCryptoWrapper;
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { PreKey } from '@wireapp/api-client/lib/auth';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import type { CRUDEngine } from '@wireapp/store-engine';
|
|
3
|
+
import type { CoreCryptoWrapper } from './CoreCryptoWrapper';
|
|
4
|
+
import type { CryptoboxWrapper } from './CryptoboxWrapper';
|
|
5
5
|
import { CoreDatabase } from '../../../../storage/CoreDB';
|
|
6
|
-
|
|
6
|
+
export declare enum CryptoClientType {
|
|
7
|
+
CORE_CRYPTO = 0,
|
|
8
|
+
CRYPTOBOX = 1
|
|
9
|
+
}
|
|
10
|
+
export type CryptoClientDef = [CryptoClientType.CRYPTOBOX, CryptoboxWrapper] | [CryptoClientType.CORE_CRYPTO, CoreCryptoWrapper];
|
|
11
|
+
type WrapConfig = {
|
|
7
12
|
nbPrekeys: number;
|
|
8
13
|
onNewPrekeys: (prekeys: PreKey[]) => void;
|
|
9
14
|
};
|
|
10
|
-
|
|
15
|
+
type InitConfig = WrapConfig & {
|
|
16
|
+
storeEngine: CRUDEngine;
|
|
17
|
+
secretKey: Uint8Array;
|
|
18
|
+
coreCryptoWasmFilePath?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function buildCryptoClient(clientType: CryptoClientType, db: CoreDatabase, { storeEngine, nbPrekeys, secretKey, coreCryptoWasmFilePath, onNewPrekeys }: InitConfig): Promise<CryptoClientDef>;
|
|
11
21
|
export {};
|
|
12
22
|
//# sourceMappingURL=CryptoClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoClient.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAEpD,OAAO,EAAC,UAAU,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"CryptoClient.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAEpD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEtD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAC;AAExD,oBAAY,gBAAgB;IAC1B,WAAW,IAAA;IACX,SAAS,IAAA;CACV;AAED,MAAM,MAAM,eAAe,GACvB,CAAC,gBAAgB,CAAC,SAAS,EAAE,gBAAgB,CAAC,GAC9C,CAAC,gBAAgB,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;AAEtD,KAAK,UAAU,GAAG;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,KAAK,UAAU,GAAG,UAAU,GAAG;IAC7B,WAAW,EAAE,UAAU,CAAC;IACxB,SAAS,EAAE,UAAU,CAAC;IACtB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,gBAAgB,EAC5B,EAAE,EAAE,YAAY,EAChB,EAAC,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,sBAAsB,EAAE,YAAY,EAAC,EAAE,UAAU,GACpF,OAAO,CAAC,eAAe,CAAC,CAa1B"}
|
|
@@ -17,13 +17,47 @@
|
|
|
17
17
|
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
}) : (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
}));
|
|
31
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
32
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
33
|
+
}) : function(o, v) {
|
|
34
|
+
o["default"] = v;
|
|
35
|
+
});
|
|
36
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
20
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
44
|
+
exports.buildCryptoClient = exports.CryptoClientType = void 0;
|
|
45
|
+
var CryptoClientType;
|
|
46
|
+
(function (CryptoClientType) {
|
|
47
|
+
CryptoClientType[CryptoClientType["CORE_CRYPTO"] = 0] = "CORE_CRYPTO";
|
|
48
|
+
CryptoClientType[CryptoClientType["CRYPTOBOX"] = 1] = "CRYPTOBOX";
|
|
49
|
+
})(CryptoClientType = exports.CryptoClientType || (exports.CryptoClientType = {}));
|
|
50
|
+
async function buildCryptoClient(clientType, db, { storeEngine, nbPrekeys, secretKey, coreCryptoWasmFilePath, onNewPrekeys }) {
|
|
51
|
+
if (clientType === CryptoClientType.CORE_CRYPTO) {
|
|
52
|
+
const { buildClient } = await Promise.resolve().then(() => __importStar(require('./CoreCryptoWrapper')));
|
|
53
|
+
const client = await buildClient(storeEngine, secretKey, coreCryptoWasmFilePath !== null && coreCryptoWasmFilePath !== void 0 ? coreCryptoWasmFilePath : '', db, {
|
|
54
|
+
nbPrekeys,
|
|
55
|
+
onNewPrekeys,
|
|
56
|
+
});
|
|
57
|
+
return [CryptoClientType.CORE_CRYPTO, client];
|
|
58
|
+
}
|
|
59
|
+
const { buildClient } = await Promise.resolve().then(() => __importStar(require('./CryptoboxWrapper')));
|
|
60
|
+
const client = await buildClient(storeEngine, { nbPrekeys, onNewPrekeys });
|
|
61
|
+
return [CryptoClientType.CRYPTOBOX, client];
|
|
28
62
|
}
|
|
29
|
-
exports.
|
|
63
|
+
exports.buildCryptoClient = buildCryptoClient;
|
|
@@ -4,7 +4,8 @@ export type InitialPrekeys = {
|
|
|
4
4
|
prekeys: PreKey[];
|
|
5
5
|
lastPrekey: PreKey;
|
|
6
6
|
};
|
|
7
|
-
export interface CryptoClient {
|
|
7
|
+
export interface CryptoClient<T = unknown> {
|
|
8
|
+
getNativeClient(): T;
|
|
8
9
|
encrypt(sessions: string[], plainText: Uint8Array): Promise<Map<string, Uint8Array>>;
|
|
9
10
|
decrypt(sessionId: string, message: Uint8Array): Promise<Uint8Array>;
|
|
10
11
|
/**
|
|
@@ -25,7 +26,10 @@ export interface CryptoClient {
|
|
|
25
26
|
deleteSession(sessionId: string): Promise<void>;
|
|
26
27
|
newPrekey(id: number): Promise<PreKey>;
|
|
27
28
|
debugBreakSession(sessionId: string): void;
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Will migrate the database from a different client type
|
|
31
|
+
*/
|
|
32
|
+
migrateFromCryptobox?(dbName: string): Promise<void>;
|
|
33
|
+
wipe(): Promise<void>;
|
|
30
34
|
}
|
|
31
35
|
//# sourceMappingURL=CryptoClient.types.d.ts.map
|
package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoClient.types.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAEpD,eAAO,MAAM,cAAc,QAAQ,CAAC;AACpC,MAAM,MAAM,cAAc,GAAG;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC,CAAC;AAErE,MAAM,WAAW,YAAY;
|
|
1
|
+
{"version":3,"file":"CryptoClient.types.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAEpD,eAAO,MAAM,cAAc,QAAQ,CAAC;AACpC,MAAM,MAAM,cAAc,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IACvC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C;;OAEG;IACH,oBAAoB,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { PreKey } from '@wireapp/api-client/lib/auth';
|
|
2
2
|
import { Cryptobox } from '@wireapp/cryptobox';
|
|
3
|
+
import { CRUDEngine } from '@wireapp/store-engine';
|
|
3
4
|
import { CryptoClient } from './CryptoClient.types';
|
|
4
5
|
type Config = {
|
|
5
6
|
onNewPrekeys: (prekeys: PreKey[]) => void;
|
|
6
7
|
};
|
|
8
|
+
export declare function buildClient(storeEngine: CRUDEngine, config: Config & {
|
|
9
|
+
nbPrekeys: number;
|
|
10
|
+
}): CryptoboxWrapper;
|
|
7
11
|
export declare class CryptoboxWrapper implements CryptoClient {
|
|
8
12
|
private readonly cryptobox;
|
|
9
13
|
constructor(cryptobox: Cryptobox, config: Config);
|
|
14
|
+
getNativeClient(): Cryptobox;
|
|
10
15
|
encrypt(sessions: string[], plainText: Uint8Array): Promise<Map<string, Uint8Array>>;
|
|
11
16
|
decrypt(sessionId: string, message: Uint8Array): Promise<Uint8Array>;
|
|
12
17
|
init(): Promise<void>;
|
|
@@ -33,8 +38,7 @@ export declare class CryptoboxWrapper implements CryptoClient {
|
|
|
33
38
|
key: string;
|
|
34
39
|
}>;
|
|
35
40
|
debugBreakSession(sessionId: string): Promise<void>;
|
|
36
|
-
|
|
37
|
-
get isCoreCrypto(): boolean;
|
|
41
|
+
wipe(): Promise<void>;
|
|
38
42
|
}
|
|
39
43
|
export {};
|
|
40
44
|
//# sourceMappingURL=CryptoboxWrapper.d.ts.map
|
package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CryptoboxWrapper.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAEpD,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"CryptoboxWrapper.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAEpD,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAC,YAAY,EAAiB,MAAM,sBAAsB,CAAC;AAElE,KAAK,MAAM,GAAG;IACZ,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,wBAAgB,WAAW,CAAC,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG;IAAC,SAAS,EAAE,MAAM,CAAA;CAAC,oBAGxF;AACD,qBAAa,gBAAiB,YAAW,YAAY;IACvC,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM;IAOjE,eAAe;IAIT,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU;IASvD,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;IAIxC,IAAI;IAIJ,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU;;;;;;;;;;IAkB/C,cAAc;IAId,oBAAoB,CAAC,SAAS,EAAE,MAAM;IAK5C,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;IAInD,aAAa;IAIb,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU;IAIvD,aAAa,CAAC,SAAS,EAAE,MAAM;IAQ/B,WAAW;IAIX,aAAa,CAAC,SAAS,EAAE,MAAM;IAI/B,SAAS,CAAC,EAAE,EAAE,MAAM;;;;IAKpB,iBAAiB,CAAC,SAAS,EAAE,MAAM;IAOnC,IAAI;CACX"}
|
|
@@ -18,9 +18,14 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.CryptoboxWrapper = void 0;
|
|
21
|
+
exports.CryptoboxWrapper = exports.buildClient = void 0;
|
|
22
22
|
const cryptobox_1 = require("@wireapp/cryptobox");
|
|
23
23
|
const CryptoClient_types_1 = require("./CryptoClient.types");
|
|
24
|
+
function buildClient(storeEngine, config) {
|
|
25
|
+
const cryptobox = new cryptobox_1.Cryptobox(storeEngine, config.nbPrekeys);
|
|
26
|
+
return new CryptoboxWrapper(cryptobox, { onNewPrekeys: () => { } });
|
|
27
|
+
}
|
|
28
|
+
exports.buildClient = buildClient;
|
|
24
29
|
class CryptoboxWrapper {
|
|
25
30
|
constructor(cryptobox, config) {
|
|
26
31
|
this.cryptobox = cryptobox;
|
|
@@ -29,6 +34,9 @@ class CryptoboxWrapper {
|
|
|
29
34
|
config.onNewPrekeys(serializedPreKeys);
|
|
30
35
|
});
|
|
31
36
|
}
|
|
37
|
+
getNativeClient() {
|
|
38
|
+
return this.cryptobox;
|
|
39
|
+
}
|
|
32
40
|
async encrypt(sessions, plainText) {
|
|
33
41
|
const encryptedPayloads = [];
|
|
34
42
|
for (const sessionId of sessions) {
|
|
@@ -98,11 +106,6 @@ class CryptoboxWrapper {
|
|
|
98
106
|
session.session.session_states = {};
|
|
99
107
|
this.cryptobox['cachedSessions'].set(sessionId, session);
|
|
100
108
|
}
|
|
101
|
-
async
|
|
102
|
-
// No migration needed for cryptobox
|
|
103
|
-
}
|
|
104
|
-
get isCoreCrypto() {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
109
|
+
async wipe() { }
|
|
107
110
|
}
|
|
108
111
|
exports.CryptoboxWrapper = CryptoboxWrapper;
|
|
@@ -2,21 +2,19 @@ import type { APIClient } from '@wireapp/api-client/lib/APIClient';
|
|
|
2
2
|
import type { PreKey, Context } from '@wireapp/api-client/lib/auth';
|
|
3
3
|
import type { Conversation, OTRRecipients, QualifiedOTRRecipients, QualifiedUserClients, UserClients } from '@wireapp/api-client/lib/conversation';
|
|
4
4
|
import type { QualifiedId, QualifiedUserPreKeyBundleMap, UserPreKeyBundleMap } from '@wireapp/api-client/lib/user';
|
|
5
|
-
import { CoreCrypto } from '@wireapp/core-crypto';
|
|
6
|
-
import { Cryptobox } from '@wireapp/cryptobox';
|
|
7
5
|
import { CRUDEngine } from '@wireapp/store-engine';
|
|
6
|
+
import { CryptoClient } from './CryptoClient';
|
|
8
7
|
import type { AddUsersToProteusConversationParams, CreateProteusConversationParams, ProteusServiceConfig, SendProteusMessageParams } from './ProteusService.types';
|
|
9
8
|
import { SendResult } from '../../../conversation';
|
|
10
|
-
import { CoreDatabase } from '../../../storage/CoreDB';
|
|
11
9
|
import type { EventHandlerResult } from '../../common.types';
|
|
12
10
|
import { EventHandlerParams } from '../EventHandler';
|
|
13
11
|
export declare class ProteusService {
|
|
14
12
|
private readonly apiClient;
|
|
13
|
+
private readonly cryptoClient;
|
|
15
14
|
private readonly config;
|
|
16
15
|
private readonly messageService;
|
|
17
16
|
private readonly logger;
|
|
18
|
-
|
|
19
|
-
constructor(apiClient: APIClient, cryptoClient: CoreCrypto | Cryptobox, db: CoreDatabase, config: ProteusServiceConfig);
|
|
17
|
+
constructor(apiClient: APIClient, cryptoClient: CryptoClient, config: ProteusServiceConfig);
|
|
20
18
|
handleEvent(params: Pick<EventHandlerParams, 'event' | 'source' | 'dryRun'>): EventHandlerResult;
|
|
21
19
|
initClient(storeEngine: CRUDEngine, context: Context): Promise<void>;
|
|
22
20
|
createClient(entropy?: Uint8Array): Promise<import("./CryptoClient").InitialPrekeys>;
|
|
@@ -40,5 +38,6 @@ export declare class ProteusService {
|
|
|
40
38
|
encrypt(plainText: Uint8Array, recipients: UserPreKeyBundleMap | UserClients, domain?: string): Promise<OTRRecipients<Uint8Array>>;
|
|
41
39
|
deleteSession(userId: QualifiedId, clientId: string): Promise<void>;
|
|
42
40
|
encryptQualified(plainText: Uint8Array, preKeyBundles: QualifiedUserPreKeyBundleMap | QualifiedUserClients): Promise<QualifiedOTRRecipients>;
|
|
41
|
+
wipe(): Promise<void>;
|
|
43
42
|
}
|
|
44
43
|
//# sourceMappingURL=ProteusService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProteusService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EACV,YAAY,EAEZ,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACZ,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAC,WAAW,EAAE,4BAA4B,EAAE,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"ProteusService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EACV,YAAY,EAEZ,aAAa,EACb,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACZ,MAAM,sCA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,CAAC,EAAE,MAAM;IAQ3E,kBAAkB,CAAC,EAC9B,gBAAgB,EAChB,YAAY,GACb,EAAE,+BAA+B,GAAG,OAAO,CAAC,YAAY,CAAC;IAiB7C,sBAAsB,CAAC,EAAC,cAAc,EAAE,gBAAgB,EAAC,EAAE,mCAAmC;IAI9F,WAAW,CAAC,EACvB,OAAO,EACP,cAAc,EACd,cAAc,EACd,UAAU,EACV,UAAU,EACV,OAAO,EACP,gBAAgB,GACjB,EAAE,wBAAwB,GAAG,OAAO,CAAC,UAAU,CAAC;YA2CnC,OAAO;IAuBR,OAAO,CAClB,SAAS,EAAE,UAAU,EACrB,UAAU,EAAE,mBAAmB,GAAG,WAAW,EAC7C,MAAM,GAAE,MAAW,GAClB,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAc9B,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM;IAS7C,gBAAgB,CAC3B,SAAS,EAAE,UAAU,EACrB,aAAa,EAAE,4BAA4B,GAAG,oBAAoB,GACjE,OAAO,CAAC,sBAAsB,CAAC;IAWlC,IAAI;CAGL"}
|
|
@@ -24,7 +24,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
24
24
|
exports.ProteusService = void 0;
|
|
25
25
|
const logdown_1 = __importDefault(require("logdown"));
|
|
26
26
|
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
27
|
-
const CryptoClient_1 = require("./CryptoClient");
|
|
28
27
|
const cryptoMigrationStateStore_1 = require("./cryptoMigrationStateStore");
|
|
29
28
|
const DecryptionErrorGenerator_1 = require("./DecryptionErrorGenerator");
|
|
30
29
|
const sessionIdMigrator_1 = require("./sessionIdMigrator");
|
|
@@ -35,12 +34,12 @@ const getGenericMessageParams_1 = require("../Utility/getGenericMessageParams");
|
|
|
35
34
|
const isClearFromMismatch_1 = require("../Utility/isClearFromMismatch");
|
|
36
35
|
const SessionHandler_1 = require("../Utility/SessionHandler");
|
|
37
36
|
class ProteusService {
|
|
38
|
-
constructor(apiClient, cryptoClient,
|
|
37
|
+
constructor(apiClient, cryptoClient, config) {
|
|
39
38
|
this.apiClient = apiClient;
|
|
39
|
+
this.cryptoClient = cryptoClient;
|
|
40
40
|
this.config = config;
|
|
41
41
|
this.logger = (0, logdown_1.default)('@wireapp/core/ProteusService');
|
|
42
42
|
this.messageService = new MessageService_1.MessageService(this.apiClient, this);
|
|
43
|
-
this.cryptoClient = (0, CryptoClient_1.wrapCryptoClient)(cryptoClient, db, config);
|
|
44
43
|
}
|
|
45
44
|
async handleEvent(params) {
|
|
46
45
|
const handledEvent = await (0, EventHandler_1.handleBackendEvent)(Object.assign(Object.assign({}, params), { decryptMessage: (payload, userId, clientId) => this.decrypt(payload, userId, clientId) }));
|
|
@@ -65,10 +64,10 @@ class ProteusService {
|
|
|
65
64
|
this.logger.info(`Successfully migrated session ids to qualified ids.`);
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
|
-
if (!cryptoMigrationStateStore_1.cryptoMigrationStore.coreCrypto.isReady(dbName) && this.cryptoClient.
|
|
67
|
+
if (!cryptoMigrationStateStore_1.cryptoMigrationStore.coreCrypto.isReady(dbName) && this.cryptoClient.migrateFromCryptobox) {
|
|
69
68
|
this.logger.info(`Migrating data from cryptobox store (${dbName}) to corecrypto.`);
|
|
70
69
|
try {
|
|
71
|
-
await this.cryptoClient.
|
|
70
|
+
await this.cryptoClient.migrateFromCryptobox(dbName);
|
|
72
71
|
cryptoMigrationStateStore_1.cryptoMigrationStore.coreCrypto.markAsReady(dbName);
|
|
73
72
|
this.logger.info(`Successfully migrated from cryptobox store (${dbName}) to corecrypto.`);
|
|
74
73
|
}
|
|
@@ -200,5 +199,8 @@ class ProteusService {
|
|
|
200
199
|
}
|
|
201
200
|
return qualifiedOTRRecipients;
|
|
202
201
|
}
|
|
202
|
+
wipe() {
|
|
203
|
+
return this.cryptoClient.wipe();
|
|
204
|
+
}
|
|
203
205
|
}
|
|
204
206
|
exports.ProteusService = ProteusService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProteusService.mocks.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.mocks.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ProteusService.mocks.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.mocks.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAIhD,eAAO,MAAM,mBAAmB;eAEQ,SAAS;gBAAc,UAAU;GAgBxE,CAAC"}
|
|
@@ -22,6 +22,7 @@ exports.buildProteusService = void 0;
|
|
|
22
22
|
const client_1 = require("@wireapp/api-client/lib/client");
|
|
23
23
|
const api_client_1 = require("@wireapp/api-client");
|
|
24
24
|
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
25
|
+
const CoreCryptoWrapper_1 = require("./CryptoClient/CoreCryptoWrapper");
|
|
25
26
|
const ProteusService_1 = require("./ProteusService");
|
|
26
27
|
const PayloadHelper_1 = require("../../../test/PayloadHelper");
|
|
27
28
|
const buildProteusService = async (federated = false) => {
|
|
@@ -32,9 +33,8 @@ const buildProteusService = async (federated = false) => {
|
|
|
32
33
|
clientId: (0, PayloadHelper_1.getUUID)(),
|
|
33
34
|
};
|
|
34
35
|
const coreCrypto = await core_crypto_1.CoreCrypto.deferredInit('store-name', 'key');
|
|
35
|
-
const proteusService = new ProteusService_1.ProteusService(apiClient, coreCrypto, {}, {
|
|
36
|
+
const proteusService = new ProteusService_1.ProteusService(apiClient, new CoreCryptoWrapper_1.CoreCryptoWrapper(coreCrypto, {}, {}), {
|
|
36
37
|
nbPrekeys: 0,
|
|
37
|
-
onNewPrekeys: jest.fn(),
|
|
38
38
|
useQualifiedIds: federated,
|
|
39
39
|
});
|
|
40
40
|
return [proteusService, { apiClient, coreCrypto }];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PreKey } from '@wireapp/api-client/lib/auth';
|
|
2
1
|
import { UserClients, QualifiedUserClients, ClientMismatch, MessageSendingStatus, ConversationProtocol, NewConversation } from '@wireapp/api-client/lib/conversation';
|
|
3
2
|
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
4
3
|
import { AddUsersParams, MessageSendingOptions, SendCommonParams } from '../../../conversation';
|
|
@@ -10,7 +9,6 @@ export type ProteusServiceConfig = {
|
|
|
10
9
|
useQualifiedIds: boolean;
|
|
11
10
|
onNewClient?: (client: NewClient) => void;
|
|
12
11
|
nbPrekeys: number;
|
|
13
|
-
onNewPrekeys: (prekeys: PreKey[]) => void;
|
|
14
12
|
};
|
|
15
13
|
export type SendProteusMessageParams = SendCommonParams & MessageSendingOptions & {
|
|
16
14
|
conversationId: QualifiedId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProteusService.types.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.types.ts"],"names":[],"mappings":"AAmBA,OAAO,
|
|
1
|
+
{"version":3,"file":"ProteusService.types.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EAChB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAC,cAAc,EAAE,qBAAqB,EAAE,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAE9F,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,WAAW,CAAC;CACrB;AACD,MAAM,MAAM,oBAAoB,GAAG;IACjC,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,GACrD,qBAAqB,GAAG;IACtB,cAAc,EAAE,WAAW,CAAC;IAE5B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,GAAG,WAAW,GAAG,oBAAoB,CAAC;IACxE,gBAAgB,CAAC,EAAE,CACjB,MAAM,EAAE,cAAc,GAAG,oBAAoB,EAC7C,OAAO,EAAE,OAAO,KACb,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,QAAQ,EAAE,oBAAoB,CAAC,OAAO,CAAC;CACxC,CAAC;AAEJ,MAAM,MAAM,+BAA+B,GAAG;IAC5C,gBAAgB,EAAE,eAAe,GAAG,MAAM,CAAC;IAC3C,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC"}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
const SessionHandler_1 = require("./SessionHandler");
|
|
22
|
-
const
|
|
22
|
+
const CoreCryptoWrapper_1 = require("../../ProteusService/CryptoClient/CoreCryptoWrapper");
|
|
23
23
|
const ProteusService_mocks_1 = require("../../ProteusService/ProteusService.mocks");
|
|
24
24
|
describe('SessionHandler', () => {
|
|
25
25
|
describe('constructSessionId', () => {
|
|
@@ -69,7 +69,7 @@ describe('SessionHandler', () => {
|
|
|
69
69
|
const { apiClient, coreCrypto } = (await (0, ProteusService_mocks_1.buildProteusService)())[1];
|
|
70
70
|
jest.spyOn(coreCrypto, 'proteusSessionExists').mockResolvedValue(true);
|
|
71
71
|
const sessionFromPrekeySpy = jest.spyOn(coreCrypto, 'proteusSessionFromPrekey');
|
|
72
|
-
await (0, SessionHandler_1.initSession)({ userId: { id: 'user1', domain: 'domain' }, clientId: 'client1' }, { apiClient, cryptoClient:
|
|
72
|
+
await (0, SessionHandler_1.initSession)({ userId: { id: 'user1', domain: 'domain' }, clientId: 'client1' }, { apiClient, cryptoClient: new CoreCryptoWrapper_1.CoreCryptoWrapper(coreCrypto, {}, {}) });
|
|
73
73
|
expect(sessionFromPrekeySpy).not.toHaveBeenCalled();
|
|
74
74
|
});
|
|
75
75
|
it('creates the session if it does not already exist', async () => {
|
|
@@ -88,7 +88,7 @@ describe('SessionHandler', () => {
|
|
|
88
88
|
useQualifiedIds: true,
|
|
89
89
|
});
|
|
90
90
|
const sessionFromPrekeySpy = jest.spyOn(coreCrypto, 'proteusSessionFromPrekey');
|
|
91
|
-
await (0, SessionHandler_1.initSession)({ userId: { id: 'user1', domain: 'domain' }, clientId: 'client1' }, { apiClient, cryptoClient:
|
|
91
|
+
await (0, SessionHandler_1.initSession)({ userId: { id: 'user1', domain: 'domain' }, clientId: 'client1' }, { apiClient, cryptoClient: new CoreCryptoWrapper_1.CoreCryptoWrapper(coreCrypto, {}, {}) });
|
|
92
92
|
expect(sessionFromPrekeySpy).toHaveBeenCalledWith(sessionId, expect.any(Object));
|
|
93
93
|
});
|
|
94
94
|
});
|
|
@@ -129,7 +129,7 @@ describe('SessionHandler', () => {
|
|
|
129
129
|
const sessions = await (0, SessionHandler_1.initSessions)({
|
|
130
130
|
recipients: Object.assign(Object.assign({}, existingUserClients), missingUserClients),
|
|
131
131
|
apiClient,
|
|
132
|
-
cryptoClient:
|
|
132
|
+
cryptoClient: new CoreCryptoWrapper_1.CoreCryptoWrapper(coreCrypto, {}, {}),
|
|
133
133
|
});
|
|
134
134
|
expect(sessionFromPrekeySpy).toHaveBeenCalledTimes(3);
|
|
135
135
|
expect(sessions).toHaveLength(6);
|
package/package.json
CHANGED
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@wireapp/api-client": "^22.14.
|
|
14
|
+
"@wireapp/api-client": "^22.14.3",
|
|
15
15
|
"@wireapp/commons": "^5.0.4",
|
|
16
16
|
"@wireapp/core-crypto": "0.6.0-rc.3",
|
|
17
17
|
"@wireapp/cryptobox": "12.8.0",
|
|
18
18
|
"@wireapp/promise-queue": "^2.1.1",
|
|
19
|
-
"@wireapp/protocol-messaging": "1.
|
|
19
|
+
"@wireapp/protocol-messaging": "1.44.0",
|
|
20
20
|
"@wireapp/store-engine": "5.0.3",
|
|
21
21
|
"@wireapp/store-engine-dexie": "^2.0.4",
|
|
22
22
|
"axios": "1.2.2",
|
|
@@ -60,6 +60,6 @@
|
|
|
60
60
|
"test:coverage": "jest --coverage",
|
|
61
61
|
"watch": "tsc --watch"
|
|
62
62
|
},
|
|
63
|
-
"version": "38.4.
|
|
64
|
-
"gitHead": "
|
|
63
|
+
"version": "38.4.3",
|
|
64
|
+
"gitHead": "191f5e4228b8ddddb246f3a248dc3245b837bdb7"
|
|
65
65
|
}
|