@wireapp/core 40.5.1 → 40.5.2-1
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 +7 -9
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +35 -32
- package/lib/CoreError.js +1 -1
- package/lib/broadcast/BroadcastService.d.ts +11 -2
- package/lib/broadcast/BroadcastService.d.ts.map +1 -1
- package/lib/broadcast/BroadcastService.js +39 -5
- package/lib/client/ClientDatabaseRepository.d.ts +5 -5
- package/lib/client/ClientDatabaseRepository.d.ts.map +1 -1
- package/lib/client/ClientDatabaseRepository.js +17 -10
- package/lib/client/ClientService.d.ts +1 -5
- package/lib/client/ClientService.d.ts.map +1 -1
- package/lib/client/ClientService.js +9 -11
- package/lib/connection/ConnectionService.d.ts +2 -2
- package/lib/connection/ConnectionService.d.ts.map +1 -1
- package/lib/connection/ConnectionService.js +2 -2
- package/lib/conversation/AssetTransferState.js +1 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts +5 -12
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +11 -26
- package/lib/conversation/ConversationService/ConversationService.test.js +1 -1
- package/lib/conversation/ConversationService/ConversationService.types.d.ts +11 -12
- package/lib/conversation/ConversationService/ConversationService.types.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.types.js +1 -1
- package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts +1 -1
- package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts.map +1 -1
- package/lib/conversation/GenericMessageType.js +1 -1
- package/lib/conversation/ReactionType.d.ts +4 -1
- package/lib/conversation/ReactionType.d.ts.map +1 -1
- package/lib/conversation/ReactionType.js +6 -0
- package/lib/conversation/message/Message.types.js +1 -1
- package/lib/conversation/message/MessageBuilder.d.ts +1 -1
- package/lib/conversation/message/MessageBuilder.d.ts.map +1 -1
- package/lib/conversation/message/MessageBuilder.js +2 -2
- package/lib/conversation/message/MessageService.d.ts +31 -6
- package/lib/conversation/message/MessageService.d.ts.map +1 -1
- package/lib/conversation/message/MessageService.js +162 -19
- package/lib/conversation/message/MessageService.test.js +141 -151
- package/lib/conversation/message/PayloadBundle.js +1 -1
- package/lib/conversation/message/UserClientsUtil.d.ts +10 -14
- package/lib/conversation/message/UserClientsUtil.d.ts.map +1 -1
- package/lib/conversation/message/UserClientsUtil.js +11 -21
- package/lib/conversation/message/UserClientsUtils.test.js +9 -5
- package/lib/messagingProtocols/mls/EventHandler/EventHandler.d.ts +1 -1
- package/lib/messagingProtocols/mls/EventHandler/EventHandler.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts +1 -1
- 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/welcomeMessage/welcomeMessage.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.js +0 -2
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js +1 -3
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +8 -19
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +37 -79
- package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +0 -9
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/index.d.ts +2 -0
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/index.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/index.js +35 -0
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.d.ts +11 -0
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.js +50 -0
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.test.d.ts +2 -0
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.test.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.test.js +39 -0
- package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.d.ts +4 -0
- package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.js +35 -0
- package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.test.d.ts +2 -0
- package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.test.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.test.js +35 -0
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts +5 -10
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.js +11 -33
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.d.ts +3 -2
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.js +9 -8
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.d.ts +9 -4
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.js +24 -10
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.test.js +10 -2
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.d.ts +2 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.js +3 -3
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts +2 -2
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.d.ts +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.js +2 -2
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts +7 -14
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.js +35 -31
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.js +3 -2
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.test.js +89 -109
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts +9 -6
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.d.ts +25 -0
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.d.ts.map +1 -0
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.js +93 -0
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.d.ts +2 -0
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.d.ts.map +1 -0
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.js +66 -0
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.d.ts +2 -0
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.d.ts.map +1 -0
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.js +35 -0
- package/lib/messagingProtocols/proteus/Utility/Recipients.d.ts +10 -4
- package/lib/messagingProtocols/proteus/Utility/Recipients.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/Recipients.js +16 -16
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts +10 -15
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.js +92 -80
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +54 -70
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts +14 -5
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.js +35 -3
- package/lib/messagingProtocols/proteus/Utility/isClearFromMismatch.d.ts +2 -2
- package/lib/messagingProtocols/proteus/Utility/isClearFromMismatch.d.ts.map +1 -1
- package/lib/notification/NotificationDatabaseRepository.js +1 -1
- package/lib/notification/Notifications.types.js +1 -1
- package/lib/user/UserService.d.ts +17 -6
- package/lib/user/UserService.d.ts.map +1 -1
- package/lib/user/UserService.js +47 -2
- package/lib/util/TaskScheduler/TaskScheduler.d.ts +1 -4
- package/lib/util/TaskScheduler/TaskScheduler.d.ts.map +1 -1
- package/lib/util/TaskScheduler/TaskScheduler.js +3 -24
- package/lib/util/TypePredicateUtil.d.ts +1 -0
- package/lib/util/TypePredicateUtil.d.ts.map +1 -1
- package/lib/util/TypePredicateUtil.js +2 -1
- package/package.json +8 -8
- package/LICENSE +0 -674
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.d.ts +0 -13
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.js +0 -67
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.d.ts +0 -2
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.js +0 -72
- package/lib/util/TaskScheduler/TaskScheduler.store.d.ts +0 -7
- package/lib/util/TaskScheduler/TaskScheduler.store.d.ts.map +0 -1
- package/lib/util/TaskScheduler/TaskScheduler.store.js +0 -34
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PreKey } from '@wireapp/api-client/lib/auth';
|
|
2
2
|
import { CoreCrypto } from '@wireapp/core-crypto';
|
|
3
3
|
import type { CRUDEngine } from '@wireapp/store-engine';
|
|
4
|
+
import { CoreDatabase } from '../../../../../storage/CoreDB';
|
|
4
5
|
import { SecretCrypto } from '../../../../mls/types';
|
|
5
6
|
import { CryptoClient } from '../CryptoClient.types';
|
|
6
7
|
type Config = {
|
|
@@ -11,16 +12,16 @@ type Config = {
|
|
|
11
12
|
type ClientConfig = Config & {
|
|
12
13
|
onWipe: () => Promise<void>;
|
|
13
14
|
};
|
|
14
|
-
export declare function buildClient(storeEngine: CRUDEngine, coreCryptoWasmFilePath: string, { systemCrypto, nbPrekeys, onNewPrekeys }: Config): Promise<CoreCryptoWrapper>;
|
|
15
|
+
export declare function buildClient(storeEngine: CRUDEngine, coreCryptoWasmFilePath: string, db: CoreDatabase, { systemCrypto, nbPrekeys, onNewPrekeys }: Config): Promise<CoreCryptoWrapper>;
|
|
15
16
|
export declare class CoreCryptoWrapper implements CryptoClient {
|
|
16
17
|
private readonly coreCrypto;
|
|
17
18
|
private readonly config;
|
|
18
19
|
private readonly prekeyTracker;
|
|
19
|
-
constructor(coreCrypto: CoreCrypto, config: ClientConfig);
|
|
20
|
+
constructor(coreCrypto: CoreCrypto, db: CoreDatabase, config: ClientConfig);
|
|
20
21
|
getNativeClient(): CoreCrypto;
|
|
21
22
|
encrypt(sessions: string[], plainText: Uint8Array): Promise<Map<string, Uint8Array>>;
|
|
22
23
|
decrypt(sessionId: string, message: Uint8Array): Promise<Uint8Array>;
|
|
23
|
-
init(
|
|
24
|
+
init(): Promise<void>;
|
|
24
25
|
create(nbPrekeys: number, entropy?: Uint8Array): Promise<{
|
|
25
26
|
prekeys: PreKey[];
|
|
26
27
|
lastPrekey: {
|
|
@@ -36,19 +37,13 @@ export declare class CoreCryptoWrapper implements CryptoClient {
|
|
|
36
37
|
saveSession(sessionId: string): Promise<void>;
|
|
37
38
|
deleteSession(sessionId: string): Promise<void>;
|
|
38
39
|
consumePrekey(): Promise<void>;
|
|
39
|
-
newPrekey(): Promise<{
|
|
40
|
+
newPrekey(id: number): Promise<{
|
|
40
41
|
id: number;
|
|
41
42
|
key: string;
|
|
42
43
|
}>;
|
|
43
44
|
debugBreakSession(sessionId: string): Promise<void>;
|
|
44
45
|
debugResetIdentity(): Promise<void>;
|
|
45
46
|
migrateFromCryptobox(dbName: string): Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
* Will call the callback once corecrypto is ready.
|
|
48
|
-
* @param callback - Function to be called once corecrypto is ready.
|
|
49
|
-
* @see https://github.com/wireapp/wire-web-packages/pull/4972
|
|
50
|
-
*/
|
|
51
|
-
private onReady;
|
|
52
47
|
wipe(): Promise<void>;
|
|
53
48
|
}
|
|
54
49
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreCryptoWrapper.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAIpD,OAAO,
|
|
1
|
+
{"version":3,"file":"CoreCryptoWrapper.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAIpD,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAKtD,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAEnD,KAAK,MAAM,GAAG;IACZ,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,KAAK,YAAY,GAAG,MAAM,GAAG;IAC3B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B,CAAC;AAEF,wBAAsB,WAAW,CAC/B,WAAW,EAAE,UAAU,EACvB,sBAAsB,EAAE,MAAM,EAC9B,EAAE,EAAE,YAAY,EAChB,EAAC,YAAY,EAAE,SAAS,EAAE,YAAY,EAAC,EAAE,MAAM,GAC9C,OAAO,CAAC,iBAAiB,CAAC,CA4B5B;AAED,qBAAa,iBAAkB,YAAW,YAAY;IAGxC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAAgC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAF9F,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;gBAEjB,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAmB,MAAM,EAAE,YAAY;IAI5G,eAAe;IAIf,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU;IAIjD,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;IAI9C,IAAI;IAIE,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU;;;;;;;IAsBpD,cAAc;IAId,oBAAoB,CAAC,SAAS,EAAE,MAAM;IAIhC,kBAAkB,CAAC,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,kBAAkB;IAIlB,oBAAoB,CAAC,MAAM,EAAE,MAAM;IAInC,IAAI;CAIX"}
|
|
@@ -24,7 +24,7 @@ const idb_1 = require("idb");
|
|
|
24
24
|
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
25
25
|
const PrekeysTracker_1 = require("./PrekeysTracker");
|
|
26
26
|
const secretKeyGenerator_1 = require("./secretKeyGenerator");
|
|
27
|
-
async function buildClient(storeEngine, coreCryptoWasmFilePath, { systemCrypto, nbPrekeys, onNewPrekeys }) {
|
|
27
|
+
async function buildClient(storeEngine, coreCryptoWasmFilePath, db, { systemCrypto, nbPrekeys, onNewPrekeys }) {
|
|
28
28
|
let key;
|
|
29
29
|
const coreCryptoDbName = `corecrypto-${storeEngine.storeName}`;
|
|
30
30
|
const secretKeysDbName = `secrets-${storeEngine.storeName}`;
|
|
@@ -52,16 +52,15 @@ async function buildClient(storeEngine, coreCryptoWasmFilePath, { systemCrypto,
|
|
|
52
52
|
databaseName: coreCryptoDbName,
|
|
53
53
|
key: bazinga64_1.Encoder.toBase64(key.key).asString,
|
|
54
54
|
wasmFilePath: coreCryptoWasmFilePath,
|
|
55
|
-
ciphersuites: [core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519],
|
|
56
55
|
});
|
|
57
|
-
return new CoreCryptoWrapper(coreCrypto, { nbPrekeys, onNewPrekeys, onWipe: key.deleteKey });
|
|
56
|
+
return new CoreCryptoWrapper(coreCrypto, db, { nbPrekeys, onNewPrekeys, onWipe: key.deleteKey });
|
|
58
57
|
}
|
|
59
58
|
exports.buildClient = buildClient;
|
|
60
59
|
class CoreCryptoWrapper {
|
|
61
|
-
constructor(coreCrypto, config) {
|
|
60
|
+
constructor(coreCrypto, db, config) {
|
|
62
61
|
this.coreCrypto = coreCrypto;
|
|
63
62
|
this.config = config;
|
|
64
|
-
this.prekeyTracker = new PrekeysTracker_1.PrekeyTracker(this, config);
|
|
63
|
+
this.prekeyTracker = new PrekeysTracker_1.PrekeyTracker(this, db, config);
|
|
65
64
|
}
|
|
66
65
|
getNativeClient() {
|
|
67
66
|
return this.coreCrypto;
|
|
@@ -72,10 +71,7 @@ class CoreCryptoWrapper {
|
|
|
72
71
|
decrypt(sessionId, message) {
|
|
73
72
|
return this.coreCrypto.proteusDecrypt(sessionId, message);
|
|
74
73
|
}
|
|
75
|
-
init(
|
|
76
|
-
if (nbInitialPrekeys) {
|
|
77
|
-
this.prekeyTracker.setInitialState(nbInitialPrekeys);
|
|
78
|
-
}
|
|
74
|
+
init() {
|
|
79
75
|
return this.coreCrypto.proteusInit();
|
|
80
76
|
}
|
|
81
77
|
async create(nbPrekeys, entropy) {
|
|
@@ -85,8 +81,9 @@ class CoreCryptoWrapper {
|
|
|
85
81
|
await this.init();
|
|
86
82
|
const prekeys = [];
|
|
87
83
|
for (let id = 0; id < nbPrekeys; id++) {
|
|
88
|
-
prekeys.push(await this.newPrekey());
|
|
84
|
+
prekeys.push(await this.newPrekey(id));
|
|
89
85
|
}
|
|
86
|
+
await this.prekeyTracker.setInitialState(prekeys.length);
|
|
90
87
|
const lastPrekeyBytes = await this.coreCrypto.proteusLastResortPrekey();
|
|
91
88
|
const lastPrekey = bazinga64_1.Encoder.toBase64(lastPrekeyBytes).asString;
|
|
92
89
|
const lastPrekeyId = core_crypto_1.CoreCrypto.proteusLastResortPrekeyId();
|
|
@@ -120,9 +117,9 @@ class CoreCryptoWrapper {
|
|
|
120
117
|
consumePrekey() {
|
|
121
118
|
return this.prekeyTracker.consumePrekey();
|
|
122
119
|
}
|
|
123
|
-
async newPrekey() {
|
|
124
|
-
const
|
|
125
|
-
return { id, key: bazinga64_1.Encoder.toBase64(
|
|
120
|
+
async newPrekey(id) {
|
|
121
|
+
const key = await this.coreCrypto.proteusNewPrekey(id);
|
|
122
|
+
return { id, key: bazinga64_1.Encoder.toBase64(key).asString };
|
|
126
123
|
}
|
|
127
124
|
async debugBreakSession(sessionId) {
|
|
128
125
|
const fakePrekey = [
|
|
@@ -139,28 +136,9 @@ class CoreCryptoWrapper {
|
|
|
139
136
|
async migrateFromCryptobox(dbName) {
|
|
140
137
|
return this.coreCrypto.proteusCryptoboxMigrate(dbName);
|
|
141
138
|
}
|
|
142
|
-
/**
|
|
143
|
-
* Will call the callback once corecrypto is ready.
|
|
144
|
-
* @param callback - Function to be called once corecrypto is ready.
|
|
145
|
-
* @see https://github.com/wireapp/wire-web-packages/pull/4972
|
|
146
|
-
*/
|
|
147
|
-
onReady(callback) {
|
|
148
|
-
if (!this.coreCrypto.isLocked()) {
|
|
149
|
-
return callback();
|
|
150
|
-
}
|
|
151
|
-
return new Promise(resolve => {
|
|
152
|
-
const intervalId = setInterval(async () => {
|
|
153
|
-
if (!this.coreCrypto.isLocked()) {
|
|
154
|
-
clearInterval(intervalId);
|
|
155
|
-
await callback();
|
|
156
|
-
return resolve();
|
|
157
|
-
}
|
|
158
|
-
}, 100);
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
139
|
async wipe() {
|
|
162
140
|
await this.config.onWipe();
|
|
163
|
-
|
|
141
|
+
return this.coreCrypto.wipe();
|
|
164
142
|
}
|
|
165
143
|
}
|
|
166
144
|
exports.CoreCryptoWrapper = CoreCryptoWrapper;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PreKey } from '@wireapp/api-client/lib/auth';
|
|
2
2
|
import { CryptoClient } from '../..';
|
|
3
|
+
import type { CoreDatabase } from '../../../../../../storage/CoreDB';
|
|
3
4
|
type CoreCryptoPrekeyGenerator = Pick<CryptoClient, 'newPrekey'>;
|
|
4
5
|
interface PrekeysGeneratorConfig {
|
|
5
6
|
/**
|
|
@@ -16,10 +17,10 @@ export declare class PrekeyTracker {
|
|
|
16
17
|
private readonly generator;
|
|
17
18
|
private config;
|
|
18
19
|
private prekeyState;
|
|
19
|
-
constructor(generator: CoreCryptoPrekeyGenerator, config: PrekeysGeneratorConfig);
|
|
20
|
+
constructor(generator: CoreCryptoPrekeyGenerator, db: CoreDatabase, config: PrekeysGeneratorConfig);
|
|
20
21
|
private generatePrekeys;
|
|
21
|
-
setInitialState(nbPrekeys: number): number;
|
|
22
22
|
consumePrekey(): Promise<void>;
|
|
23
|
+
setInitialState(nbInitialPrekeys: number): Promise<void>;
|
|
23
24
|
private numberOfMissingPrekeys;
|
|
24
25
|
}
|
|
25
26
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrekeysTracker.d.ts","sourceRoot":"","sources":["../../../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAIpD,OAAO,EAAC,YAAY,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PrekeysTracker.d.ts","sourceRoot":"","sources":["../../../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAIpD,OAAO,EAAC,YAAY,EAAC,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kCAAkC,CAAC;AAEnE,KAAK,yBAAyB,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;AAEjE,UAAU,sBAAsB;IAC9B;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC3C;AAED,qBAAa,aAAa;IAItB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAE1B,OAAO,CAAC,MAAM;IALhB,OAAO,CAAC,WAAW,CAAsB;gBAGtB,SAAS,EAAE,yBAAyB,EACrD,EAAE,EAAE,YAAY,EACR,MAAM,EAAE,sBAAsB;YAK1B,eAAe;IASvB,aAAa;IAUb,eAAe,CAAC,gBAAgB,EAAE,MAAM;IAI9C,OAAO,CAAC,sBAAsB;CAK/B"}
|
|
@@ -21,23 +21,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
exports.PrekeyTracker = void 0;
|
|
22
22
|
const PrekeysTracker_store_1 = require("./PrekeysTracker.store");
|
|
23
23
|
class PrekeyTracker {
|
|
24
|
-
constructor(generator, config) {
|
|
24
|
+
constructor(generator, db, config) {
|
|
25
25
|
this.generator = generator;
|
|
26
26
|
this.config = config;
|
|
27
|
-
this.prekeyState = new PrekeysTracker_store_1.PrekeysTrackerStore();
|
|
27
|
+
this.prekeyState = new PrekeysTracker_store_1.PrekeysTrackerStore(db);
|
|
28
28
|
}
|
|
29
29
|
async generatePrekeys(nb) {
|
|
30
30
|
const prekeys = [];
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const ids = await this.prekeyState.createIds(nb);
|
|
32
|
+
for (const id of ids) {
|
|
33
|
+
prekeys.push(await this.generator.newPrekey(id));
|
|
33
34
|
}
|
|
34
35
|
return prekeys;
|
|
35
36
|
}
|
|
36
|
-
setInitialState(nbPrekeys) {
|
|
37
|
-
return this.prekeyState.addPrekeys(nbPrekeys);
|
|
38
|
-
}
|
|
39
37
|
async consumePrekey() {
|
|
40
|
-
const nbPrekeys = this.prekeyState.consumePrekey();
|
|
38
|
+
const nbPrekeys = await this.prekeyState.consumePrekey();
|
|
41
39
|
const missingPrekeys = this.numberOfMissingPrekeys(nbPrekeys);
|
|
42
40
|
if (missingPrekeys > 0) {
|
|
43
41
|
// when the number of local prekeys hit less than a quarter of what it should be, we refill the stock
|
|
@@ -45,6 +43,9 @@ class PrekeyTracker {
|
|
|
45
43
|
this.config.onNewPrekeys(newPrekeys);
|
|
46
44
|
}
|
|
47
45
|
}
|
|
46
|
+
async setInitialState(nbInitialPrekeys) {
|
|
47
|
+
await this.prekeyState.createIds(nbInitialPrekeys);
|
|
48
|
+
}
|
|
48
49
|
numberOfMissingPrekeys(currentNumberOfPrekeys) {
|
|
49
50
|
const threshold = Math.ceil(this.config.nbPrekeys / 2);
|
|
50
51
|
const hasHitThreshold = currentNumberOfPrekeys <= threshold;
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import { CoreDatabase } from '../../../../../../storage/CoreDB';
|
|
1
2
|
export declare class PrekeysTrackerStore {
|
|
2
|
-
private
|
|
3
|
+
private readonly db;
|
|
4
|
+
constructor(db: CoreDatabase);
|
|
5
|
+
private getState;
|
|
6
|
+
private saveState;
|
|
3
7
|
/**
|
|
4
8
|
* Will mark one prekey as consumed and decrease the total number of prekeys of 1
|
|
5
9
|
* @returns the number of valid prekeys that are left
|
|
6
10
|
*/
|
|
7
|
-
consumePrekey(): number
|
|
11
|
+
consumePrekey(): Promise<number>;
|
|
12
|
+
getNumberOfPrekeys(): Promise<number>;
|
|
8
13
|
/**
|
|
9
|
-
*
|
|
14
|
+
* will generate nbIds ids that can be used to store prekeys
|
|
10
15
|
* @param nbIds the number of ids to generate
|
|
11
16
|
*/
|
|
12
|
-
|
|
17
|
+
createIds(nbIds: number): Promise<number[]>;
|
|
13
18
|
}
|
|
14
19
|
//# sourceMappingURL=PrekeysTracker.store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrekeysTracker.store.d.ts","sourceRoot":"","sources":["../../../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrekeysTracker.store.d.ts","sourceRoot":"","sources":["../../../../../../../src/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAC,MAAM,kCAAkC,CAAC;AAQ9D,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,YAAY;YAE/B,QAAQ;YAIR,SAAS;IAIvB;;;OAGG;IACG,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAOhC,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAK3C;;;OAGG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAMlD"}
|
|
@@ -19,26 +19,40 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.PrekeysTrackerStore = void 0;
|
|
22
|
-
|
|
22
|
+
const STATE_PRIMARY_KEY = 'prekeys_state';
|
|
23
23
|
class PrekeysTrackerStore {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
constructor(db) {
|
|
25
|
+
this.db = db;
|
|
26
|
+
}
|
|
27
|
+
async getState() {
|
|
28
|
+
var _a;
|
|
29
|
+
return (_a = (await this.db.get('prekeys', STATE_PRIMARY_KEY))) !== null && _a !== void 0 ? _a : { nbPrekeys: 0, highestId: 0 };
|
|
30
|
+
}
|
|
31
|
+
async saveState(state) {
|
|
32
|
+
await this.db.put('prekeys', state, STATE_PRIMARY_KEY);
|
|
28
33
|
}
|
|
29
34
|
/**
|
|
30
35
|
* Will mark one prekey as consumed and decrease the total number of prekeys of 1
|
|
31
36
|
* @returns the number of valid prekeys that are left
|
|
32
37
|
*/
|
|
33
|
-
consumePrekey() {
|
|
34
|
-
|
|
38
|
+
async consumePrekey() {
|
|
39
|
+
const currentState = await this.getState();
|
|
40
|
+
const newState = Object.assign(Object.assign({}, currentState), { nbPrekeys: currentState.nbPrekeys - 1 });
|
|
41
|
+
await this.saveState(newState);
|
|
42
|
+
return newState.nbPrekeys;
|
|
43
|
+
}
|
|
44
|
+
async getNumberOfPrekeys() {
|
|
45
|
+
const currentState = await this.getState();
|
|
46
|
+
return currentState.nbPrekeys;
|
|
35
47
|
}
|
|
36
48
|
/**
|
|
37
|
-
*
|
|
49
|
+
* will generate nbIds ids that can be used to store prekeys
|
|
38
50
|
* @param nbIds the number of ids to generate
|
|
39
51
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
52
|
+
async createIds(nbIds) {
|
|
53
|
+
const currentState = await this.getState();
|
|
54
|
+
this.saveState({ nbPrekeys: currentState.highestId + nbIds, highestId: currentState.highestId + nbIds });
|
|
55
|
+
return Array.from(new Array(nbIds)).map((_, i) => currentState.highestId + 1 + i);
|
|
42
56
|
}
|
|
43
57
|
}
|
|
44
58
|
exports.PrekeysTrackerStore = PrekeysTrackerStore;
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
const PrekeysTracker_1 = require("./PrekeysTracker");
|
|
22
|
+
const CoreDB_1 = require("../../../../../../storage/CoreDB");
|
|
22
23
|
describe('PrekeysGenerator', () => {
|
|
24
|
+
let db;
|
|
23
25
|
const baseConfig = {
|
|
24
26
|
nbPrekeys: 10,
|
|
25
27
|
onNewPrekeys: jest.fn(),
|
|
@@ -27,9 +29,15 @@ describe('PrekeysGenerator', () => {
|
|
|
27
29
|
const mockPrekeyTracker = {
|
|
28
30
|
newPrekey: jest.fn().mockResolvedValue(Uint8Array.from([])),
|
|
29
31
|
};
|
|
32
|
+
beforeEach(async () => {
|
|
33
|
+
db = await (0, CoreDB_1.openDB)('test');
|
|
34
|
+
});
|
|
35
|
+
afterEach(async () => {
|
|
36
|
+
await db.clear('prekeys');
|
|
37
|
+
});
|
|
30
38
|
it('triggers the threshold callback when number of prekeys hits the limit', async () => {
|
|
31
|
-
const prekeyTracker = new PrekeysTracker_1.PrekeyTracker(mockPrekeyTracker, baseConfig);
|
|
32
|
-
prekeyTracker.setInitialState(baseConfig.nbPrekeys);
|
|
39
|
+
const prekeyTracker = new PrekeysTracker_1.PrekeyTracker(mockPrekeyTracker, db, baseConfig);
|
|
40
|
+
await prekeyTracker.setInitialState(baseConfig.nbPrekeys);
|
|
33
41
|
expect(baseConfig.onNewPrekeys).not.toHaveBeenCalled();
|
|
34
42
|
await prekeyTracker.consumePrekey();
|
|
35
43
|
await prekeyTracker.consumePrekey();
|
|
@@ -2,6 +2,7 @@ import { PreKey } from '@wireapp/api-client/lib/auth';
|
|
|
2
2
|
import type { CRUDEngine } from '@wireapp/store-engine';
|
|
3
3
|
import type { CoreCryptoWrapper } from './CoreCryptoWrapper/CoreCryptoWrapper';
|
|
4
4
|
import type { CryptoboxWrapper } from './CryptoboxWrapper';
|
|
5
|
+
import { CoreDatabase } from '../../../../storage/CoreDB';
|
|
5
6
|
import { SecretCrypto } from '../../../mls/types';
|
|
6
7
|
export declare enum CryptoClientType {
|
|
7
8
|
CORE_CRYPTO = 0,
|
|
@@ -17,6 +18,6 @@ type InitConfig = WrapConfig & {
|
|
|
17
18
|
systemCrypto?: SecretCrypto;
|
|
18
19
|
coreCryptoWasmFilePath?: string;
|
|
19
20
|
};
|
|
20
|
-
export declare function buildCryptoClient(clientType: CryptoClientType, { storeEngine, nbPrekeys, systemCrypto, coreCryptoWasmFilePath, onNewPrekeys }: InitConfig): Promise<CryptoClientDef>;
|
|
21
|
+
export declare function buildCryptoClient(clientType: CryptoClientType, db: CoreDatabase, { storeEngine, nbPrekeys, systemCrypto, coreCryptoWasmFilePath, onNewPrekeys }: InitConfig): Promise<CryptoClientDef>;
|
|
21
22
|
export {};
|
|
22
23
|
//# 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,KAAK,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEtD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,uCAAuC,CAAC;AAC7E,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,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,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,gBAAgB,EAC5B,EAAC,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,sBAAsB,EAAE,YAAY,EAAC,EAAE,UAAU,GACvF,OAAO,CAAC,eAAe,CAAC,CAc1B"}
|
|
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,uCAAuC,CAAC;AAC7E,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,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,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,gBAAgB,EAC5B,EAAE,EAAE,YAAY,EAChB,EAAC,WAAW,EAAE,SAAS,EAAE,YAAY,EAAE,sBAAsB,EAAE,YAAY,EAAC,EAAE,UAAU,GACvF,OAAO,CAAC,eAAe,CAAC,CAc1B"}
|
|
@@ -46,11 +46,11 @@ var CryptoClientType;
|
|
|
46
46
|
(function (CryptoClientType) {
|
|
47
47
|
CryptoClientType[CryptoClientType["CORE_CRYPTO"] = 0] = "CORE_CRYPTO";
|
|
48
48
|
CryptoClientType[CryptoClientType["CRYPTOBOX"] = 1] = "CRYPTOBOX";
|
|
49
|
-
})(CryptoClientType
|
|
50
|
-
async function buildCryptoClient(clientType, { storeEngine, nbPrekeys, systemCrypto, coreCryptoWasmFilePath, onNewPrekeys }) {
|
|
49
|
+
})(CryptoClientType = exports.CryptoClientType || (exports.CryptoClientType = {}));
|
|
50
|
+
async function buildCryptoClient(clientType, db, { storeEngine, nbPrekeys, systemCrypto, coreCryptoWasmFilePath, onNewPrekeys }) {
|
|
51
51
|
if (clientType === CryptoClientType.CORE_CRYPTO) {
|
|
52
52
|
const { buildClient } = await Promise.resolve().then(() => __importStar(require('./CoreCryptoWrapper')));
|
|
53
|
-
const client = await buildClient(storeEngine, coreCryptoWasmFilePath !== null && coreCryptoWasmFilePath !== void 0 ? coreCryptoWasmFilePath : '', {
|
|
53
|
+
const client = await buildClient(storeEngine, coreCryptoWasmFilePath !== null && coreCryptoWasmFilePath !== void 0 ? coreCryptoWasmFilePath : '', db, {
|
|
54
54
|
systemCrypto,
|
|
55
55
|
nbPrekeys,
|
|
56
56
|
onNewPrekeys,
|
|
@@ -10,7 +10,7 @@ export interface CryptoClient<T = unknown> {
|
|
|
10
10
|
/**
|
|
11
11
|
* Will init an already existing client. The client should already exist in the database. If the client doesn't exist, it needs to be created using the `create` method.
|
|
12
12
|
*/
|
|
13
|
-
init(
|
|
13
|
+
init(): Promise<void>;
|
|
14
14
|
/**
|
|
15
15
|
* Will create a new client and store it in the database
|
|
16
16
|
*/
|
|
@@ -23,7 +23,7 @@ export interface CryptoClient<T = unknown> {
|
|
|
23
23
|
saveSession(sessionId: string): Promise<void>;
|
|
24
24
|
consumePrekey: () => Promise<void>;
|
|
25
25
|
deleteSession(sessionId: string): Promise<void>;
|
|
26
|
-
newPrekey(): Promise<PreKey>;
|
|
26
|
+
newPrekey(id: number): Promise<PreKey>;
|
|
27
27
|
debugBreakSession(sessionId: string): void;
|
|
28
28
|
debugResetIdentity(): Promise<void>;
|
|
29
29
|
/**
|
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,MAAM,MAAM,cAAc,GAAG;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC,CAAC;AAErE,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC,eAAe,IAAI,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACrF,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAErE;;OAEG;IACH,IAAI,
|
|
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,MAAM,MAAM,cAAc,GAAG;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC,CAAC;AAErE,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,OAAO;IACvC,eAAe,IAAI,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACrF,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAErE;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtB;;OAEG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACzE,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzD,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAChF,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACnD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvC,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC;;OAEG;IACH,oBAAoB,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB"}
|
|
@@ -33,7 +33,7 @@ export declare class CryptoboxWrapper implements CryptoClient {
|
|
|
33
33
|
sessionExists(sessionId: string): Promise<boolean>;
|
|
34
34
|
saveSession(): Promise<void>;
|
|
35
35
|
deleteSession(sessionId: string): Promise<void>;
|
|
36
|
-
newPrekey(): Promise<{
|
|
36
|
+
newPrekey(id: number): Promise<{
|
|
37
37
|
id: number;
|
|
38
38
|
key: string;
|
|
39
39
|
}>;
|
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;AAE7C,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAElD,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;AAED,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;;;;
|
|
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;AAE7C,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAElD,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;AAED,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,kBAAkB;IAIlB,IAAI;CACX"}
|
|
@@ -97,9 +97,9 @@ class CryptoboxWrapper {
|
|
|
97
97
|
async deleteSession(sessionId) {
|
|
98
98
|
await this.cryptobox.session_delete(sessionId);
|
|
99
99
|
}
|
|
100
|
-
async newPrekey() {
|
|
100
|
+
async newPrekey(id) {
|
|
101
101
|
// CryptoBox is generating prekeys internally
|
|
102
|
-
return { id
|
|
102
|
+
return { id, key: '' };
|
|
103
103
|
}
|
|
104
104
|
async debugBreakSession(sessionId) {
|
|
105
105
|
const session = await this.cryptobox.session_load(sessionId);
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import type { APIClient } from '@wireapp/api-client/lib/APIClient';
|
|
2
2
|
import type { PreKey, Context } from '@wireapp/api-client/lib/auth';
|
|
3
|
-
import type { Conversation, QualifiedOTRRecipients, QualifiedUserClients } from '@wireapp/api-client/lib/conversation';
|
|
4
|
-
import type { QualifiedId, QualifiedUserPreKeyBundleMap } from '@wireapp/api-client/lib/user';
|
|
3
|
+
import type { Conversation, OTRRecipients, QualifiedOTRRecipients, QualifiedUserClients, UserClients } from '@wireapp/api-client/lib/conversation';
|
|
4
|
+
import type { QualifiedId, QualifiedUserPreKeyBundleMap, UserPreKeyBundleMap } from '@wireapp/api-client/lib/user';
|
|
5
5
|
import { CRUDEngine } from '@wireapp/store-engine';
|
|
6
6
|
import { CryptoClient } from './CryptoClient';
|
|
7
7
|
import type { AddUsersToProteusConversationParams, CreateProteusConversationParams, ProteusServiceConfig, SendProteusMessageParams } from './ProteusService.types';
|
|
8
8
|
import { SendResult } from '../../../conversation';
|
|
9
9
|
import type { EventHandlerResult } from '../../common.types';
|
|
10
10
|
import { EventHandlerParams } from '../EventHandler';
|
|
11
|
-
export type EncryptionResult = {
|
|
12
|
-
/** the encrypted payloads for the clients that have a valid sessions */
|
|
13
|
-
payloads: QualifiedOTRRecipients;
|
|
14
|
-
/** user-client that do not have prekeys on backend (deleted clients) */
|
|
15
|
-
unknowns?: QualifiedUserClients;
|
|
16
|
-
/** users for whom we could retrieve a prekey and, thus, for which we could not encrypt the message */
|
|
17
|
-
failed?: QualifiedId[];
|
|
18
|
-
};
|
|
19
11
|
export declare class ProteusService {
|
|
20
12
|
private readonly apiClient;
|
|
21
13
|
private readonly cryptoClient;
|
|
@@ -30,7 +22,7 @@ export declare class ProteusService {
|
|
|
30
22
|
* Get the fingerprint of the local client.
|
|
31
23
|
*/
|
|
32
24
|
getLocalFingerprint(): Promise<string>;
|
|
33
|
-
constructSessionId(userId: QualifiedId, clientId: string): string;
|
|
25
|
+
constructSessionId(userId: string | QualifiedId, clientId: string, domain?: string): string;
|
|
34
26
|
/**
|
|
35
27
|
* Get the fingerprint of a remote client
|
|
36
28
|
* @param userId ID of user
|
|
@@ -40,11 +32,12 @@ export declare class ProteusService {
|
|
|
40
32
|
*/
|
|
41
33
|
getRemoteFingerprint(userId: QualifiedId, clientId: string, prekey?: PreKey): Promise<string>;
|
|
42
34
|
createConversation({ conversationData, otherUserIds, }: CreateProteusConversationParams): Promise<Conversation>;
|
|
43
|
-
addUsersToConversation({ conversationId,
|
|
44
|
-
sendMessage({ userIds, conversationId, nativePush, targetMode, payload, onClientMismatch, }: SendProteusMessageParams): Promise<SendResult>;
|
|
35
|
+
addUsersToConversation({ conversationId, qualifiedUserIds }: AddUsersToProteusConversationParams): Promise<import("@wireapp/api-client/lib/event").ConversationMemberJoinEvent>;
|
|
36
|
+
sendMessage({ userIds, sendAsProtobuf, conversationId, nativePush, targetMode, payload, onClientMismatch, }: SendProteusMessageParams): Promise<SendResult>;
|
|
45
37
|
private decrypt;
|
|
38
|
+
encrypt(plainText: Uint8Array, recipients: UserPreKeyBundleMap | UserClients, domain?: string): Promise<OTRRecipients<Uint8Array>>;
|
|
46
39
|
deleteSession(userId: QualifiedId, clientId: string): Promise<void>;
|
|
47
|
-
|
|
40
|
+
encryptQualified(plainText: Uint8Array, preKeyBundles: QualifiedUserPreKeyBundleMap | QualifiedUserClients): Promise<QualifiedOTRRecipients>;
|
|
48
41
|
wipe(storeEngine?: CRUDEngine): Promise<void>;
|
|
49
42
|
}
|
|
50
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,sBAAsB,EACtB,oBAAoB,
|
|
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;AAIjH,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAI5C,OAAO,KAAK,EACV,mCAAmC,EACnC,+BAA+B,EAC/B,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAA0C,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAE1F,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAC,kBAAkB,EAAqB,MAAM,iBAAiB,CAAC;AAWvE,qBAAa,cAAc;IAKvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM;IANzB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;gBAG/C,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,oBAAoB;IAKlC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC,GAAG,kBAAkB;IAiBhG,UAAU,CAAC,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO;IA0B1D,YAAY,CAAC,OAAO,CAAC,EAAE,UAAU;IAIxC;;OAEG;IACI,mBAAmB;IAInB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IAIlG;;;;;;OAMG;IACU,oBAAoB,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,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;YAmDnC,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;IAW5B,IAAI,CAAC,WAAW,CAAC,EAAE,UAAU;CAMpC"}
|
|
@@ -55,9 +55,8 @@ class ProteusService {
|
|
|
55
55
|
return handledEvent;
|
|
56
56
|
}
|
|
57
57
|
async initClient(storeEngine, context) {
|
|
58
|
-
var _a;
|
|
59
58
|
const dbName = storeEngine.storeName;
|
|
60
|
-
if (context.domain) {
|
|
59
|
+
if (context.domain && this.config.useQualifiedIds) {
|
|
61
60
|
// We want sessions to be fully qualified from now on
|
|
62
61
|
if (!cryptoMigrationStateStore_1.cryptoMigrationStore.qualifiedSessions.isReady(dbName)) {
|
|
63
62
|
this.logger.info(`Migrating existing session ids to qualified ids.`);
|
|
@@ -77,9 +76,7 @@ class ProteusService {
|
|
|
77
76
|
this.logger.error('Client was not able to perform DB migration: ', error);
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
|
-
|
|
81
|
-
const totalUsableBackedPrekeys = backendPrekeys.length - 1; // we remove the last resort prekey from the total number of available prekeys
|
|
82
|
-
return this.cryptoClient.init(totalUsableBackedPrekeys);
|
|
79
|
+
return this.cryptoClient.init();
|
|
83
80
|
}
|
|
84
81
|
createClient(entropy) {
|
|
85
82
|
return this.cryptoClient.create(this.config.nbPrekeys, entropy);
|
|
@@ -90,8 +87,8 @@ class ProteusService {
|
|
|
90
87
|
getLocalFingerprint() {
|
|
91
88
|
return this.cryptoClient.getFingerprint();
|
|
92
89
|
}
|
|
93
|
-
constructSessionId(userId, clientId) {
|
|
94
|
-
return (0, SessionHandler_1.constructSessionId)({ clientId, userId });
|
|
90
|
+
constructSessionId(userId, clientId, domain) {
|
|
91
|
+
return (0, SessionHandler_1.constructSessionId)({ clientId, userId, domain, useQualifiedIds: this.config.useQualifiedIds });
|
|
95
92
|
}
|
|
96
93
|
/**
|
|
97
94
|
* Get the fingerprint of a remote client
|
|
@@ -119,24 +116,28 @@ class ProteusService {
|
|
|
119
116
|
}
|
|
120
117
|
return this.apiClient.api.conversation.postConversation(payload);
|
|
121
118
|
}
|
|
122
|
-
async addUsersToConversation({ conversationId,
|
|
123
|
-
return this.apiClient.api.conversation.postMembers(conversationId,
|
|
119
|
+
async addUsersToConversation({ conversationId, qualifiedUserIds }) {
|
|
120
|
+
return this.apiClient.api.conversation.postMembers(conversationId, qualifiedUserIds);
|
|
124
121
|
}
|
|
125
|
-
async sendMessage({ userIds, conversationId, nativePush, targetMode, payload, onClientMismatch, }) {
|
|
126
|
-
var _a;
|
|
122
|
+
async sendMessage({ userIds, sendAsProtobuf, conversationId, nativePush, targetMode, payload, onClientMismatch, }) {
|
|
127
123
|
const messageParams = await (0, getGenericMessageParams_1.getGenericMessageParams)({
|
|
128
124
|
apiClient: this.apiClient,
|
|
129
125
|
sendingClientId: this.apiClient.validatedClientId,
|
|
130
126
|
conversationId,
|
|
131
127
|
genericMessage: payload,
|
|
128
|
+
useQualifiedIds: this.config.useQualifiedIds,
|
|
132
129
|
options: {
|
|
133
130
|
userIds,
|
|
131
|
+
sendAsProtobuf,
|
|
134
132
|
nativePush,
|
|
135
133
|
targetMode,
|
|
134
|
+
onClientMismatch,
|
|
136
135
|
},
|
|
137
136
|
});
|
|
138
|
-
const { sendingClientId, recipients, plainText, options } = messageParams;
|
|
139
|
-
const response =
|
|
137
|
+
const { federated, sendingClientId, recipients, plainText, options } = messageParams;
|
|
138
|
+
const response = federated
|
|
139
|
+
? await this.messageService.sendFederatedMessage(sendingClientId, recipients, plainText, Object.assign(Object.assign({}, options), { onClientMismatch: mismatch => onClientMismatch === null || onClientMismatch === void 0 ? void 0 : onClientMismatch(mismatch, false) }))
|
|
140
|
+
: await this.messageService.sendMessage(sendingClientId, recipients, plainText, Object.assign(Object.assign({}, options), { sendAsProtobuf, onClientMismatch: mismatch => onClientMismatch === null || onClientMismatch === void 0 ? void 0 : onClientMismatch(mismatch, false) }));
|
|
140
141
|
if (!response.canceled) {
|
|
141
142
|
if (!(0, isClearFromMismatch_1.isClearFromMismatch)(response)) {
|
|
142
143
|
// We warn the consumer that there is a mismatch that did not prevent message sending
|
|
@@ -145,11 +146,8 @@ class ProteusService {
|
|
|
145
146
|
this.logger.log(`Successfully sent Proteus message to conversation '${conversationId.id}'`);
|
|
146
147
|
}
|
|
147
148
|
const sendingState = response.canceled ? conversation_1.MessageSendingState.CANCELED : conversation_1.MessageSendingState.OUTGOING_SENT;
|
|
148
|
-
const failedToSend = response
|
|
149
|
-
?
|
|
150
|
-
queued: response.failed_to_send,
|
|
151
|
-
failed: response.failed,
|
|
152
|
-
}
|
|
149
|
+
const failedToSend = 'failed_to_send' in response && Object.keys(response.failed_to_send).length > 0
|
|
150
|
+
? response.failed_to_send
|
|
153
151
|
: undefined;
|
|
154
152
|
return {
|
|
155
153
|
id: payload.messageId,
|
|
@@ -180,26 +178,32 @@ class ProteusService {
|
|
|
180
178
|
throw (0, DecryptionErrorGenerator_1.generateDecryptionError)({ userId, clientId }, error);
|
|
181
179
|
}
|
|
182
180
|
}
|
|
181
|
+
async encrypt(plainText, recipients, domain = '') {
|
|
182
|
+
const sessions = await (0, SessionHandler_1.initSessions)({
|
|
183
|
+
recipients,
|
|
184
|
+
domain,
|
|
185
|
+
apiClient: this.apiClient,
|
|
186
|
+
cryptoClient: this.cryptoClient,
|
|
187
|
+
logger: this.logger,
|
|
188
|
+
});
|
|
189
|
+
const payload = await this.cryptoClient.encrypt(sessions, plainText);
|
|
190
|
+
return (0, SessionHandler_1.buildEncryptedPayloads)(payload);
|
|
191
|
+
}
|
|
183
192
|
deleteSession(userId, clientId) {
|
|
184
193
|
return (0, SessionHandler_1.deleteSession)({
|
|
185
194
|
userId,
|
|
186
195
|
clientId,
|
|
196
|
+
useQualifiedIds: this.config.useQualifiedIds,
|
|
187
197
|
cryptoClient: this.cryptoClient,
|
|
188
198
|
});
|
|
189
199
|
}
|
|
190
|
-
async
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const payloads = await this.cryptoClient.encrypt(sessions, plainText);
|
|
198
|
-
return {
|
|
199
|
-
payloads: (0, SessionHandler_1.buildEncryptedPayloads)(payloads),
|
|
200
|
-
unknowns,
|
|
201
|
-
failed,
|
|
202
|
-
};
|
|
200
|
+
async encryptQualified(plainText, preKeyBundles) {
|
|
201
|
+
const qualifiedOTRRecipients = {};
|
|
202
|
+
for (const [domain, preKeyBundleMap] of Object.entries(preKeyBundles)) {
|
|
203
|
+
const result = await this.encrypt(plainText, preKeyBundleMap, domain);
|
|
204
|
+
qualifiedOTRRecipients[domain] = result;
|
|
205
|
+
}
|
|
206
|
+
return qualifiedOTRRecipients;
|
|
203
207
|
}
|
|
204
208
|
async wipe(storeEngine) {
|
|
205
209
|
if (storeEngine) {
|