@wireapp/core 38.15.2 → 39.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +1 -3
- package/lib/broadcast/BroadcastService.d.ts +2 -2
- package/lib/broadcast/BroadcastService.d.ts.map +1 -1
- package/lib/broadcast/BroadcastService.js +5 -12
- package/lib/client/ClientDatabaseRepository.d.ts +5 -5
- package/lib/client/ClientDatabaseRepository.d.ts.map +1 -1
- package/lib/client/ClientDatabaseRepository.js +9 -16
- package/lib/client/ClientService.d.ts.map +1 -1
- package/lib/client/ClientService.js +2 -2
- 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/ConversationService/ConversationService.d.ts +1 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.test.js +1 -1
- package/lib/conversation/ConversationService/ConversationService.types.d.ts +2 -6
- package/lib/conversation/ConversationService/ConversationService.types.d.ts.map +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/message/MessageService.d.ts +5 -31
- package/lib/conversation/message/MessageService.d.ts.map +1 -1
- package/lib/conversation/message/MessageService.js +9 -151
- package/lib/conversation/message/MessageService.test.js +107 -156
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts +7 -11
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.js +16 -35
- 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 +1 -2
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.test.js +55 -94
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts +5 -8
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/Recipients.d.ts +4 -10
- package/lib/messagingProtocols/proteus/Utility/Recipients.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/Recipients.js +2 -13
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts +8 -11
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.js +54 -75
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +26 -33
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts +5 -14
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.js +3 -35
- package/lib/user/UserService.d.ts +1 -16
- package/lib/user/UserService.d.ts.map +1 -1
- package/lib/user/UserService.js +1 -43
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
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,
|
|
4
|
-
import type { QualifiedId, QualifiedUserPreKeyBundleMap
|
|
3
|
+
import type { Conversation, QualifiedOTRRecipients, QualifiedUserClients } from '@wireapp/api-client/lib/conversation';
|
|
4
|
+
import type { QualifiedId, QualifiedUserPreKeyBundleMap } 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';
|
|
@@ -10,9 +10,9 @@ import type { EventHandlerResult } from '../../common.types';
|
|
|
10
10
|
import { EventHandlerParams } from '../EventHandler';
|
|
11
11
|
type EncryptionResult = {
|
|
12
12
|
/** the encrypted payloads for the clients that have a valid sessions */
|
|
13
|
-
payloads:
|
|
13
|
+
payloads: QualifiedOTRRecipients;
|
|
14
14
|
/** user-client that do not have prekeys on backend (deleted clients) */
|
|
15
|
-
unknowns?:
|
|
15
|
+
unknowns?: QualifiedUserClients;
|
|
16
16
|
};
|
|
17
17
|
export declare class ProteusService {
|
|
18
18
|
private readonly apiClient;
|
|
@@ -28,7 +28,7 @@ export declare class ProteusService {
|
|
|
28
28
|
* Get the fingerprint of the local client.
|
|
29
29
|
*/
|
|
30
30
|
getLocalFingerprint(): Promise<string>;
|
|
31
|
-
constructSessionId(userId:
|
|
31
|
+
constructSessionId(userId: QualifiedId, clientId: string): string;
|
|
32
32
|
/**
|
|
33
33
|
* Get the fingerprint of a remote client
|
|
34
34
|
* @param userId ID of user
|
|
@@ -39,14 +39,10 @@ export declare class ProteusService {
|
|
|
39
39
|
getRemoteFingerprint(userId: QualifiedId, clientId: string, prekey?: PreKey): Promise<string>;
|
|
40
40
|
createConversation({ conversationData, otherUserIds, }: CreateProteusConversationParams): Promise<Conversation>;
|
|
41
41
|
addUsersToConversation({ conversationId, qualifiedUserIds }: AddUsersToProteusConversationParams): Promise<import("@wireapp/api-client/lib/event").ConversationMemberJoinEvent>;
|
|
42
|
-
sendMessage({ userIds,
|
|
42
|
+
sendMessage({ userIds, conversationId, nativePush, targetMode, payload, onClientMismatch, }: SendProteusMessageParams): Promise<SendResult>;
|
|
43
43
|
private decrypt;
|
|
44
|
-
encrypt(plainText: Uint8Array, recipients: UserPreKeyBundleMap | UserClients, domain?: string): Promise<EncryptionResult>;
|
|
45
44
|
deleteSession(userId: QualifiedId, clientId: string): Promise<void>;
|
|
46
|
-
|
|
47
|
-
payloads: QualifiedOTRRecipients;
|
|
48
|
-
unknowns?: QualifiedUserClients;
|
|
49
|
-
}>;
|
|
45
|
+
encrypt(plainText: Uint8Array, recipients: QualifiedUserPreKeyBundleMap | QualifiedUserClients): Promise<EncryptionResult>;
|
|
50
46
|
wipe(storeEngine?: CRUDEngine): Promise<void>;
|
|
51
47
|
}
|
|
52
48
|
export {};
|
|
@@ -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,
|
|
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,EACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAC,WAAW,EAAE,4BAA4B,EAAC,MAAM,8BAA8B,CAAC;AAI5F,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,KAAK,gBAAgB,GAAG;IACtB,wEAAwE;IACxE,QAAQ,EAAE,sBAAsB,CAAC;IACjC,wEAAwE;IACxE,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC,CAAC;AACF,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;IAyB1D,YAAY,CAAC,OAAO,CAAC,EAAE,UAAU;IAIxC;;OAEG;IACI,mBAAmB;IAInB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIxE;;;;;;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,UAAU,EACV,UAAU,EACV,OAAO,EACP,gBAAgB,GACjB,EAAE,wBAAwB,GAAG,OAAO,CAAC,UAAU,CAAC;YA0CnC,OAAO;IAuBd,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM;IAQ7C,OAAO,CAClB,SAAS,EAAE,UAAU,EACrB,UAAU,EAAE,4BAA4B,GAAG,oBAAoB,GAC9D,OAAO,CAAC,gBAAgB,CAAC;IAgBtB,IAAI,CAAC,WAAW,CAAC,EAAE,UAAU;CAMpC"}
|
|
@@ -56,7 +56,7 @@ class ProteusService {
|
|
|
56
56
|
}
|
|
57
57
|
async initClient(storeEngine, context) {
|
|
58
58
|
const dbName = storeEngine.storeName;
|
|
59
|
-
if (context.domain
|
|
59
|
+
if (context.domain) {
|
|
60
60
|
// We want sessions to be fully qualified from now on
|
|
61
61
|
if (!cryptoMigrationStateStore_1.cryptoMigrationStore.qualifiedSessions.isReady(dbName)) {
|
|
62
62
|
this.logger.info(`Migrating existing session ids to qualified ids.`);
|
|
@@ -87,8 +87,8 @@ class ProteusService {
|
|
|
87
87
|
getLocalFingerprint() {
|
|
88
88
|
return this.cryptoClient.getFingerprint();
|
|
89
89
|
}
|
|
90
|
-
constructSessionId(userId, clientId
|
|
91
|
-
return (0, SessionHandler_1.constructSessionId)({ clientId, userId
|
|
90
|
+
constructSessionId(userId, clientId) {
|
|
91
|
+
return (0, SessionHandler_1.constructSessionId)({ clientId, userId });
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* Get the fingerprint of a remote client
|
|
@@ -119,25 +119,20 @@ class ProteusService {
|
|
|
119
119
|
async addUsersToConversation({ conversationId, qualifiedUserIds }) {
|
|
120
120
|
return this.apiClient.api.conversation.postMembers(conversationId, qualifiedUserIds);
|
|
121
121
|
}
|
|
122
|
-
async sendMessage({ userIds,
|
|
122
|
+
async sendMessage({ userIds, conversationId, nativePush, targetMode, payload, onClientMismatch, }) {
|
|
123
123
|
const messageParams = await (0, getGenericMessageParams_1.getGenericMessageParams)({
|
|
124
124
|
apiClient: this.apiClient,
|
|
125
125
|
sendingClientId: this.apiClient.validatedClientId,
|
|
126
126
|
conversationId,
|
|
127
127
|
genericMessage: payload,
|
|
128
|
-
useQualifiedIds: this.config.useQualifiedIds,
|
|
129
128
|
options: {
|
|
130
129
|
userIds,
|
|
131
|
-
sendAsProtobuf,
|
|
132
130
|
nativePush,
|
|
133
131
|
targetMode,
|
|
134
|
-
onClientMismatch,
|
|
135
132
|
},
|
|
136
133
|
});
|
|
137
|
-
const {
|
|
138
|
-
const response =
|
|
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) }));
|
|
134
|
+
const { sendingClientId, recipients, plainText, options } = messageParams;
|
|
135
|
+
const response = await this.messageService.sendMessage(sendingClientId, recipients, plainText, Object.assign(Object.assign({}, options), { onClientMismatch: mismatch => onClientMismatch === null || onClientMismatch === void 0 ? void 0 : onClientMismatch(mismatch, false) }));
|
|
141
136
|
if (!response.canceled) {
|
|
142
137
|
if (!(0, isClearFromMismatch_1.isClearFromMismatch)(response)) {
|
|
143
138
|
// We warn the consumer that there is a mismatch that did not prevent message sending
|
|
@@ -178,38 +173,24 @@ class ProteusService {
|
|
|
178
173
|
throw (0, DecryptionErrorGenerator_1.generateDecryptionError)({ userId, clientId }, error);
|
|
179
174
|
}
|
|
180
175
|
}
|
|
181
|
-
async encrypt(plainText, recipients, domain = '') {
|
|
182
|
-
const { sessions, unknowns } = 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 { payloads: (0, SessionHandler_1.buildEncryptedPayloads)(payload), unknowns };
|
|
191
|
-
}
|
|
192
176
|
deleteSession(userId, clientId) {
|
|
193
177
|
return (0, SessionHandler_1.deleteSession)({
|
|
194
178
|
userId,
|
|
195
179
|
clientId,
|
|
196
|
-
useQualifiedIds: this.config.useQualifiedIds,
|
|
197
180
|
cryptoClient: this.cryptoClient,
|
|
198
181
|
});
|
|
199
182
|
}
|
|
200
|
-
async
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
}
|
|
183
|
+
async encrypt(plainText, recipients) {
|
|
184
|
+
const { sessions, unknowns } = await (0, SessionHandler_1.initSessions)({
|
|
185
|
+
recipients,
|
|
186
|
+
apiClient: this.apiClient,
|
|
187
|
+
cryptoClient: this.cryptoClient,
|
|
188
|
+
logger: this.logger,
|
|
189
|
+
});
|
|
190
|
+
const payloads = await this.cryptoClient.encrypt(sessions, plainText);
|
|
210
191
|
return {
|
|
211
|
-
payloads:
|
|
212
|
-
unknowns
|
|
192
|
+
payloads: (0, SessionHandler_1.buildEncryptedPayloads)(payloads),
|
|
193
|
+
unknowns,
|
|
213
194
|
};
|
|
214
195
|
}
|
|
215
196
|
async wipe(storeEngine) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIClient } from '@wireapp/api-client';
|
|
2
2
|
import { CryptoClient } from './CryptoClient';
|
|
3
3
|
import { ProteusService } from './ProteusService';
|
|
4
|
-
export declare const buildProteusService: (
|
|
4
|
+
export declare const buildProteusService: () => Promise<[ProteusService, {
|
|
5
5
|
apiClient: APIClient;
|
|
6
6
|
cryptoClient: CryptoClient;
|
|
7
7
|
}]>;
|
|
@@ -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;AAE9C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAIhD,eAAO,MAAM,mBAAmB;
|
|
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;AAE9C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAIhD,eAAO,MAAM,mBAAmB;eACD,SAAS;kBAAgB,YAAY;GAgBnE,CAAC"}
|
|
@@ -24,7 +24,7 @@ const api_client_1 = require("@wireapp/api-client");
|
|
|
24
24
|
const CoreCryptoWrapper_1 = require("./CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper");
|
|
25
25
|
const ProteusService_1 = require("./ProteusService");
|
|
26
26
|
const PayloadHelper_1 = require("../../../test/PayloadHelper");
|
|
27
|
-
const buildProteusService = async (
|
|
27
|
+
const buildProteusService = async () => {
|
|
28
28
|
const apiClient = new api_client_1.APIClient({ urls: api_client_1.APIClient.BACKEND.STAGING });
|
|
29
29
|
apiClient.context = {
|
|
30
30
|
clientType: client_1.ClientType.NONE,
|
|
@@ -34,7 +34,6 @@ const buildProteusService = async (federated = false) => {
|
|
|
34
34
|
const cryptoClient = new CoreCryptoWrapper_1.CoreCryptoWrapper({}, {}, {});
|
|
35
35
|
const proteusService = new ProteusService_1.ProteusService(apiClient, cryptoClient, {
|
|
36
36
|
nbPrekeys: 0,
|
|
37
|
-
useQualifiedIds: federated,
|
|
38
37
|
});
|
|
39
38
|
return [proteusService, { apiClient, cryptoClient }];
|
|
40
39
|
};
|
|
@@ -64,11 +64,11 @@ jest.mock('./CryptoClient/CoreCryptoWrapper/PrekeysTracker', () => {
|
|
|
64
64
|
});
|
|
65
65
|
jest.mock('../Utility/Recipients', () => (Object.assign(Object.assign({}, jest.requireActual('../Utility/Recipients')), { getRecipientsForConversation: jest.fn(), getQualifiedRecipientsForConversation: jest.fn() })));
|
|
66
66
|
const MockedRecipients = Recipients;
|
|
67
|
-
const prepareDataForEncryption = async (
|
|
68
|
-
const [proteusService, { cryptoClient, apiClient }] = await (0, ProteusService_mocks_1.buildProteusService)(
|
|
67
|
+
const prepareDataForEncryption = async () => {
|
|
68
|
+
const [proteusService, { cryptoClient, apiClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
|
|
69
69
|
const domain = 'staging.zinfra.io';
|
|
70
70
|
//user 1
|
|
71
|
-
const firstUserId = 'bc0c99f1-49a5-4ad2-889a-62885af37088';
|
|
71
|
+
const firstUserId = { id: 'bc0c99f1-49a5-4ad2-889a-62885af37088', domain };
|
|
72
72
|
//user 1 clients
|
|
73
73
|
const firstClientId = 'be67218b77d02d30';
|
|
74
74
|
const secondClientId = 'ae87218e77d02d30';
|
|
@@ -76,25 +76,19 @@ const prepareDataForEncryption = async (useQualifiedIds = true) => {
|
|
|
76
76
|
const firstClientSessionId = (0, SessionHandler_1.constructSessionId)({
|
|
77
77
|
userId: firstUserId,
|
|
78
78
|
clientId: firstClientId,
|
|
79
|
-
useQualifiedIds,
|
|
80
|
-
domain: useQualifiedIds ? domain : undefined,
|
|
81
79
|
});
|
|
82
80
|
const firstClientSession2Id = (0, SessionHandler_1.constructSessionId)({
|
|
83
81
|
userId: firstUserId,
|
|
84
82
|
clientId: secondClientId,
|
|
85
|
-
useQualifiedIds,
|
|
86
|
-
domain: useQualifiedIds ? domain : undefined,
|
|
87
83
|
});
|
|
88
84
|
//user 2
|
|
89
|
-
const secondUserId = 'cd0c88f1-49a5-4ar2-889a-62885af37069';
|
|
85
|
+
const secondUserId = { id: 'cd0c88f1-49a5-4ar2-889a-62885af37069', domain };
|
|
90
86
|
//user 2 client
|
|
91
87
|
const thirdClientId = 'ce67218b77d02d69';
|
|
92
88
|
//user 2 sessions
|
|
93
89
|
const secondClientSessionId = (0, SessionHandler_1.constructSessionId)({
|
|
94
90
|
userId: secondUserId,
|
|
95
91
|
clientId: thirdClientId,
|
|
96
|
-
useQualifiedIds,
|
|
97
|
-
domain: useQualifiedIds ? domain : undefined,
|
|
98
92
|
});
|
|
99
93
|
//message sent by a user
|
|
100
94
|
const message = 'Hello';
|
|
@@ -134,7 +128,7 @@ describe('ProteusService', () => {
|
|
|
134
128
|
const expectedFingerprint = 'fingerprint-client1';
|
|
135
129
|
const userId = { id: 'user1', domain: 'domain.com' };
|
|
136
130
|
const clientId = 'client1';
|
|
137
|
-
jest.spyOn(apiClient.api.user, '
|
|
131
|
+
jest.spyOn(apiClient.api.user, 'postMultiPreKeyBundles').mockResolvedValue({
|
|
138
132
|
[userId.domain]: {
|
|
139
133
|
[userId.id]: {
|
|
140
134
|
[clientId]: {
|
|
@@ -154,7 +148,7 @@ describe('ProteusService', () => {
|
|
|
154
148
|
it('create a session from given prekey if session does not exists', async () => {
|
|
155
149
|
const [proteusService, { apiClient, cryptoClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
|
|
156
150
|
const expectedFingerprint = 'fingerprint-client1';
|
|
157
|
-
const getPrekeysSpy = jest.spyOn(apiClient.api.user, '
|
|
151
|
+
const getPrekeysSpy = jest.spyOn(apiClient.api.user, 'postMultiPreKeyBundles');
|
|
158
152
|
jest.spyOn(cryptoClient, 'getRemoteFingerprint').mockResolvedValue(expectedFingerprint);
|
|
159
153
|
const saveSessionSpy = jest.spyOn(cryptoClient, 'sessionFromPrekey').mockResolvedValue(undefined);
|
|
160
154
|
jest.spyOn(cryptoClient, 'saveSession').mockResolvedValue(undefined);
|
|
@@ -220,58 +214,11 @@ describe('ProteusService', () => {
|
|
|
220
214
|
});
|
|
221
215
|
});
|
|
222
216
|
describe('"encrypt"', () => {
|
|
223
|
-
it('returns encrypted payload', async () => {
|
|
224
|
-
const { services, data: { firstUser, encryptedMessageBuffer, messageBuffer }, } = await prepareDataForEncryption(false);
|
|
225
|
-
const userClients = {
|
|
226
|
-
[firstUser.id]: [firstUser.clients.first, firstUser.clients.second],
|
|
227
|
-
};
|
|
228
|
-
const encryptedPayload = new Map([
|
|
229
|
-
[firstUser.sessions.first, encryptedMessageBuffer],
|
|
230
|
-
[firstUser.sessions.second, encryptedMessageBuffer],
|
|
231
|
-
]);
|
|
232
|
-
jest.spyOn(services.cryptoClient, 'sessionExists').mockResolvedValue(true);
|
|
233
|
-
jest.spyOn(services.cryptoClient, 'encrypt').mockImplementationOnce(() => Promise.resolve(encryptedPayload));
|
|
234
|
-
const { payloads } = await services.proteusService.encrypt(messageBuffer, userClients);
|
|
235
|
-
expect(services.cryptoClient.encrypt).toHaveBeenCalledWith([firstUser.sessions.first, firstUser.sessions.second], messageBuffer);
|
|
236
|
-
expect(payloads).toEqual({
|
|
237
|
-
[firstUser.id]: {
|
|
238
|
-
[firstUser.clients.first]: encryptedMessageBuffer,
|
|
239
|
-
[firstUser.clients.second]: encryptedMessageBuffer,
|
|
240
|
-
},
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
it('returns encrypted payload for multiple users', async () => {
|
|
244
|
-
const { services, data: { firstUser, secondUser, encryptedMessageBuffer, messageBuffer }, } = await prepareDataForEncryption(false);
|
|
245
|
-
const userClients = {
|
|
246
|
-
[firstUser.id]: [firstUser.clients.first, firstUser.clients.second],
|
|
247
|
-
[secondUser.id]: [secondUser.clients.first],
|
|
248
|
-
};
|
|
249
|
-
const encryptedPayload = new Map([
|
|
250
|
-
[firstUser.sessions.first, encryptedMessageBuffer],
|
|
251
|
-
[firstUser.sessions.second, encryptedMessageBuffer],
|
|
252
|
-
[secondUser.sessions.first, encryptedMessageBuffer],
|
|
253
|
-
]);
|
|
254
|
-
jest.spyOn(services.cryptoClient, 'sessionExists').mockResolvedValue(true);
|
|
255
|
-
jest.spyOn(services.cryptoClient, 'encrypt').mockResolvedValueOnce(encryptedPayload);
|
|
256
|
-
const { payloads } = await services.proteusService.encrypt(messageBuffer, userClients);
|
|
257
|
-
expect(services.cryptoClient.encrypt).toHaveBeenCalledWith([firstUser.sessions.first, firstUser.sessions.second, secondUser.sessions.first], messageBuffer);
|
|
258
|
-
expect(payloads).toEqual({
|
|
259
|
-
[firstUser.id]: {
|
|
260
|
-
[firstUser.clients.first]: encryptedMessageBuffer,
|
|
261
|
-
[firstUser.clients.second]: encryptedMessageBuffer,
|
|
262
|
-
},
|
|
263
|
-
[secondUser.id]: {
|
|
264
|
-
[secondUser.clients.first]: encryptedMessageBuffer,
|
|
265
|
-
},
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
describe('"encryptQualified"', () => {
|
|
270
217
|
it('returns encrypted payload', async () => {
|
|
271
218
|
const { services, data: { firstUser, encryptedMessageBuffer, messageBuffer, domain }, } = await prepareDataForEncryption();
|
|
272
219
|
const userClients = {
|
|
273
220
|
[domain]: {
|
|
274
|
-
[firstUser.id]: [firstUser.clients.first, firstUser.clients.second],
|
|
221
|
+
[firstUser.id.id]: [firstUser.clients.first, firstUser.clients.second],
|
|
275
222
|
},
|
|
276
223
|
};
|
|
277
224
|
const encryptedPayload = new Map([
|
|
@@ -280,12 +227,11 @@ describe('ProteusService', () => {
|
|
|
280
227
|
]);
|
|
281
228
|
jest.spyOn(services.cryptoClient, 'sessionExists').mockResolvedValue(true);
|
|
282
229
|
jest.spyOn(services.cryptoClient, 'encrypt').mockResolvedValueOnce(encryptedPayload);
|
|
283
|
-
const { payloads } = await services.proteusService.
|
|
284
|
-
// console.log({encrypted, missing});
|
|
230
|
+
const { payloads } = await services.proteusService.encrypt(messageBuffer, userClients);
|
|
285
231
|
expect(services.cryptoClient.encrypt).toHaveBeenCalledWith([firstUser.sessions.first, firstUser.sessions.second], messageBuffer);
|
|
286
232
|
expect(payloads).toEqual({
|
|
287
233
|
[domain]: {
|
|
288
|
-
[firstUser.id]: {
|
|
234
|
+
[firstUser.id.id]: {
|
|
289
235
|
[firstUser.clients.first]: encryptedMessageBuffer,
|
|
290
236
|
[firstUser.clients.second]: encryptedMessageBuffer,
|
|
291
237
|
},
|
|
@@ -296,8 +242,8 @@ describe('ProteusService', () => {
|
|
|
296
242
|
const { services, data: { firstUser, secondUser, encryptedMessageBuffer, messageBuffer, domain }, } = await prepareDataForEncryption();
|
|
297
243
|
const userClients = {
|
|
298
244
|
[domain]: {
|
|
299
|
-
[firstUser.id]: [firstUser.clients.first, firstUser.clients.second],
|
|
300
|
-
[secondUser.id]: [secondUser.clients.first],
|
|
245
|
+
[firstUser.id.id]: [firstUser.clients.first, firstUser.clients.second],
|
|
246
|
+
[secondUser.id.id]: [secondUser.clients.first],
|
|
301
247
|
},
|
|
302
248
|
};
|
|
303
249
|
const encryptedPayload = new Map([
|
|
@@ -307,15 +253,15 @@ describe('ProteusService', () => {
|
|
|
307
253
|
]);
|
|
308
254
|
jest.spyOn(services.cryptoClient, 'sessionExists').mockResolvedValue(true);
|
|
309
255
|
jest.spyOn(services.cryptoClient, 'encrypt').mockResolvedValueOnce(encryptedPayload);
|
|
310
|
-
const { payloads } = await services.proteusService.
|
|
256
|
+
const { payloads } = await services.proteusService.encrypt(messageBuffer, userClients);
|
|
311
257
|
expect(services.cryptoClient.encrypt).toHaveBeenCalledWith([firstUser.sessions.first, firstUser.sessions.second, secondUser.sessions.first], messageBuffer);
|
|
312
258
|
expect(payloads).toEqual({
|
|
313
259
|
[domain]: {
|
|
314
|
-
[firstUser.id]: {
|
|
260
|
+
[firstUser.id.id]: {
|
|
315
261
|
[firstUser.clients.first]: encryptedMessageBuffer,
|
|
316
262
|
[firstUser.clients.second]: encryptedMessageBuffer,
|
|
317
263
|
},
|
|
318
|
-
[secondUser.id]: {
|
|
264
|
+
[secondUser.id.id]: {
|
|
319
265
|
[secondUser.clients.first]: encryptedMessageBuffer,
|
|
320
266
|
},
|
|
321
267
|
},
|
|
@@ -325,8 +271,8 @@ describe('ProteusService', () => {
|
|
|
325
271
|
const { services, data: { firstUser, secondUser, encryptedMessageBuffer, messageBuffer, domain }, } = await prepareDataForEncryption();
|
|
326
272
|
const userClients = {
|
|
327
273
|
[domain]: {
|
|
328
|
-
[firstUser.id]: [firstUser.clients.first, firstUser.clients.second],
|
|
329
|
-
[secondUser.id]: [secondUser.clients.first],
|
|
274
|
+
[firstUser.id.id]: [firstUser.clients.first, firstUser.clients.second],
|
|
275
|
+
[secondUser.id.id]: [secondUser.clients.first],
|
|
330
276
|
},
|
|
331
277
|
};
|
|
332
278
|
const encryptedPayload = new Map([
|
|
@@ -334,16 +280,16 @@ describe('ProteusService', () => {
|
|
|
334
280
|
[firstUser.sessions.second, encryptedMessageBuffer],
|
|
335
281
|
[secondUser.sessions.first, encryptedMessageBuffer],
|
|
336
282
|
]);
|
|
337
|
-
jest.spyOn(services.apiClient.api.user, '
|
|
283
|
+
jest.spyOn(services.apiClient.api.user, 'postMultiPreKeyBundles').mockResolvedValue({
|
|
338
284
|
[domain]: {
|
|
339
|
-
[firstUser.id]: {
|
|
285
|
+
[firstUser.id.id]: {
|
|
340
286
|
[firstUser.clients.first]: null,
|
|
341
287
|
[firstUser.clients.second]: {
|
|
342
288
|
id: 123,
|
|
343
289
|
key: 'pQABARhIAqEAWCCaJpFa9c626ORmjj1aV6OnOYgmTjfoiE3ynOfNfGAOmgOhAKEAWCD60VMzRrLfO+1GSjgyhnVp2N7L58DM+eeJhZJi1tBLfQT2',
|
|
344
290
|
},
|
|
345
291
|
},
|
|
346
|
-
[secondUser.id]: {
|
|
292
|
+
[secondUser.id.id]: {
|
|
347
293
|
[secondUser.clients.first]: {
|
|
348
294
|
id: 123,
|
|
349
295
|
key: 'pQABARhIAqEAWCCaJpFa9c626ORmjj1aV6OnOYgmTjfoiE3ynOfNfGAOmgOhAKEAWCD60VMzRrLfO+1GSjgyhnVp2N7L58DM+eeJhZJi1tBLfQT2',
|
|
@@ -355,20 +301,20 @@ describe('ProteusService', () => {
|
|
|
355
301
|
jest.spyOn(services.cryptoClient, 'encrypt').mockResolvedValueOnce(encryptedPayload);
|
|
356
302
|
jest.spyOn(services.cryptoClient, 'sessionFromPrekey').mockResolvedValue();
|
|
357
303
|
jest.spyOn(services.cryptoClient, 'saveSession').mockResolvedValue();
|
|
358
|
-
const { payloads, unknowns } = await services.proteusService.
|
|
304
|
+
const { payloads, unknowns } = await services.proteusService.encrypt(messageBuffer, userClients);
|
|
359
305
|
expect(services.cryptoClient.encrypt).toHaveBeenCalledWith([firstUser.sessions.second, secondUser.sessions.first], messageBuffer);
|
|
360
306
|
expect(unknowns).toEqual({
|
|
361
307
|
[domain]: {
|
|
362
|
-
[firstUser.id]: [firstUser.clients.first],
|
|
308
|
+
[firstUser.id.id]: [firstUser.clients.first],
|
|
363
309
|
},
|
|
364
310
|
});
|
|
365
311
|
expect(payloads).toEqual({
|
|
366
312
|
[domain]: {
|
|
367
|
-
[firstUser.id]: {
|
|
313
|
+
[firstUser.id.id]: {
|
|
368
314
|
[firstUser.clients.first]: encryptedMessageBuffer,
|
|
369
315
|
[firstUser.clients.second]: encryptedMessageBuffer,
|
|
370
316
|
},
|
|
371
|
-
[secondUser.id]: {
|
|
317
|
+
[secondUser.id.id]: {
|
|
372
318
|
[secondUser.clients.first]: encryptedMessageBuffer,
|
|
373
319
|
},
|
|
374
320
|
},
|
|
@@ -398,7 +344,13 @@ describe('ProteusService', () => {
|
|
|
398
344
|
expect(errorMessage).toContain('no userIds are given');
|
|
399
345
|
}
|
|
400
346
|
});
|
|
401
|
-
[
|
|
347
|
+
[
|
|
348
|
+
{ domain: { user1: ['client1'], user2: ['client11', 'client12'] } },
|
|
349
|
+
[
|
|
350
|
+
{ domain: 'domain', id: 'user1' },
|
|
351
|
+
{ domain: 'domain', id: 'user2' },
|
|
352
|
+
],
|
|
353
|
+
].forEach(recipients => {
|
|
402
354
|
it(`forwards the list of users to report (${JSON.stringify(recipients)})`, async () => {
|
|
403
355
|
const [proteusService] = await (0, ProteusService_mocks_1.buildProteusService)();
|
|
404
356
|
MockedRecipients.getRecipientsForConversation.mockResolvedValue({});
|
|
@@ -410,7 +362,12 @@ describe('ProteusService', () => {
|
|
|
410
362
|
userIds: recipients,
|
|
411
363
|
conversationId: { id: 'conv1', domain: '' },
|
|
412
364
|
});
|
|
413
|
-
expect(proteusService['messageService'].sendMessage).toHaveBeenCalledWith(expect.any(String), expect.any(Object), expect.any(Uint8Array), expect.objectContaining({
|
|
365
|
+
expect(proteusService['messageService'].sendMessage).toHaveBeenCalledWith(expect.any(String), expect.any(Object), expect.any(Uint8Array), expect.objectContaining({
|
|
366
|
+
reportMissing: [
|
|
367
|
+
{ domain: 'domain', id: 'user1' },
|
|
368
|
+
{ domain: 'domain', id: 'user2' },
|
|
369
|
+
],
|
|
370
|
+
}));
|
|
414
371
|
});
|
|
415
372
|
});
|
|
416
373
|
[
|
|
@@ -422,9 +379,9 @@ describe('ProteusService', () => {
|
|
|
422
379
|
],
|
|
423
380
|
].forEach(recipients => {
|
|
424
381
|
it(`forwards the list of users to report for federated message (${JSON.stringify(recipients)})`, async () => {
|
|
425
|
-
const [proteusService] = await (0, ProteusService_mocks_1.buildProteusService)(
|
|
426
|
-
MockedRecipients.
|
|
427
|
-
jest.spyOn(proteusService['messageService'], '
|
|
382
|
+
const [proteusService] = await (0, ProteusService_mocks_1.buildProteusService)();
|
|
383
|
+
MockedRecipients.getRecipientsForConversation.mockResolvedValue({});
|
|
384
|
+
jest.spyOn(proteusService['messageService'], 'sendMessage').mockResolvedValue({});
|
|
428
385
|
await proteusService.sendMessage({
|
|
429
386
|
protocol: conversation_1.ConversationProtocol.PROTEUS,
|
|
430
387
|
conversationId: { id: 'conv1', domain: 'domain1' },
|
|
@@ -432,7 +389,7 @@ describe('ProteusService', () => {
|
|
|
432
389
|
targetMode: conversation_2.MessageTargetMode.USERS,
|
|
433
390
|
userIds: recipients,
|
|
434
391
|
});
|
|
435
|
-
expect(proteusService['messageService'].
|
|
392
|
+
expect(proteusService['messageService'].sendMessage).toHaveBeenCalledWith(expect.any(String), expect.any(Object), expect.any(Uint8Array), expect.objectContaining({
|
|
436
393
|
reportMissing: [
|
|
437
394
|
{ id: 'user1', domain: 'domain1' },
|
|
438
395
|
{ id: 'user2', domain: 'domain1' },
|
|
@@ -441,9 +398,15 @@ describe('ProteusService', () => {
|
|
|
441
398
|
}));
|
|
442
399
|
});
|
|
443
400
|
});
|
|
444
|
-
[
|
|
401
|
+
[
|
|
402
|
+
{ domain: { user1: ['client1'], user2: ['client11', 'client12'] } },
|
|
403
|
+
[
|
|
404
|
+
{ domain: 'domain', id: 'user1' },
|
|
405
|
+
{ domain: 'domain', id: 'user2' },
|
|
406
|
+
],
|
|
407
|
+
].forEach(recipients => {
|
|
445
408
|
it(`ignores all missing user/client pair if targetMode is USER_CLIENTS`, async () => {
|
|
446
|
-
const [proteusService] = await (0, ProteusService_mocks_1.buildProteusService)(
|
|
409
|
+
const [proteusService] = await (0, ProteusService_mocks_1.buildProteusService)();
|
|
447
410
|
MockedRecipients.getRecipientsForConversation.mockReturnValue(Promise.resolve({}));
|
|
448
411
|
jest.spyOn(proteusService['messageService'], 'sendMessage').mockReturnValue(Promise.resolve({}));
|
|
449
412
|
await proteusService.sendMessage({
|
|
@@ -465,11 +428,9 @@ describe('ProteusService', () => {
|
|
|
465
428
|
],
|
|
466
429
|
].forEach(recipients => {
|
|
467
430
|
it(`ignores all missing user/client pair if targetMode is USER_CLIENTS on federated env`, async () => {
|
|
468
|
-
const [proteusService] = await (0, ProteusService_mocks_1.buildProteusService)(
|
|
469
|
-
MockedRecipients.
|
|
470
|
-
jest
|
|
471
|
-
.spyOn(proteusService['messageService'], 'sendFederatedMessage')
|
|
472
|
-
.mockReturnValue(Promise.resolve({}));
|
|
431
|
+
const [proteusService] = await (0, ProteusService_mocks_1.buildProteusService)();
|
|
432
|
+
MockedRecipients.getRecipientsForConversation.mockResolvedValue({});
|
|
433
|
+
jest.spyOn(proteusService['messageService'], 'sendMessage').mockReturnValue(Promise.resolve({}));
|
|
473
434
|
await proteusService.sendMessage({
|
|
474
435
|
protocol: conversation_1.ConversationProtocol.PROTEUS,
|
|
475
436
|
conversationId: { id: 'conv1', domain: 'domain1' },
|
|
@@ -477,19 +438,19 @@ describe('ProteusService', () => {
|
|
|
477
438
|
targetMode: conversation_2.MessageTargetMode.USERS_CLIENTS,
|
|
478
439
|
userIds: recipients,
|
|
479
440
|
});
|
|
480
|
-
expect(proteusService['messageService'].
|
|
441
|
+
expect(proteusService['messageService'].sendMessage).toHaveBeenCalledWith(expect.any(String), expect.any(Object), expect.any(Uint8Array), expect.objectContaining({
|
|
481
442
|
reportMissing: false,
|
|
482
443
|
}));
|
|
483
444
|
});
|
|
484
445
|
});
|
|
485
446
|
it(`returns the recipients that could not receive the message`, async () => {
|
|
486
|
-
const [proteusService] = await (0, ProteusService_mocks_1.buildProteusService)(
|
|
447
|
+
const [proteusService] = await (0, ProteusService_mocks_1.buildProteusService)();
|
|
487
448
|
const recipients = {
|
|
488
449
|
domain1: { user1: ['client1'], user2: ['client11', 'client12'] },
|
|
489
450
|
domain2: { user3: ['client3'] },
|
|
490
451
|
};
|
|
491
|
-
MockedRecipients.
|
|
492
|
-
jest.spyOn(proteusService['messageService'], '
|
|
452
|
+
MockedRecipients.getRecipientsForConversation.mockResolvedValue({});
|
|
453
|
+
jest.spyOn(proteusService['messageService'], 'sendMessage').mockResolvedValue({
|
|
493
454
|
missing: {},
|
|
494
455
|
redundant: {},
|
|
495
456
|
failed_to_send: { domain2: recipients.domain2 },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QualifiedUserClients, ClientMismatch, MessageSendingStatus, ConversationProtocol, NewConversation } from '@wireapp/api-client/lib/conversation';
|
|
2
2
|
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
3
3
|
import { AddUsersParams, MessageSendingOptions, SendCommonParams } from '../../../conversation';
|
|
4
4
|
export interface NewClient {
|
|
@@ -6,20 +6,17 @@ export interface NewClient {
|
|
|
6
6
|
userId: QualifiedId;
|
|
7
7
|
}
|
|
8
8
|
export type ProteusServiceConfig = {
|
|
9
|
-
useQualifiedIds: boolean;
|
|
10
9
|
onNewClient?: (client: NewClient) => void;
|
|
11
10
|
nbPrekeys: number;
|
|
12
11
|
};
|
|
13
12
|
export type SendProteusMessageParams = SendCommonParams & MessageSendingOptions & {
|
|
14
13
|
conversationId: QualifiedId;
|
|
15
14
|
/**
|
|
16
|
-
* Can be either a QualifiedId[]
|
|
17
|
-
* When given a QualifiedId[]
|
|
18
|
-
* When given a QualifiedUserClients
|
|
19
|
-
* When given a QualifiedId[] or QualifiedUserClients the method will send the message through the federated API endpoint
|
|
20
|
-
* When given a string[] or UserClients the method will send the message through the old API endpoint
|
|
15
|
+
* Can be either a QualifiedId[] or QualfiedUserClients. The type has some effect on the behavior of the method. (Needed only for Proteus)
|
|
16
|
+
* When given a QualifiedId[] the method will fetch the freshest list of devices for those users (since they are not given by the consumer). As a consequence no ClientMismatch error will trigger and we will ignore missing clients when sending
|
|
17
|
+
* When given a QualifiedUserClients the method will only send to the clients listed in the userIds. This could lead to ClientMismatch (since the given list of devices might not be the freshest one and new clients could have been created)
|
|
21
18
|
*/
|
|
22
|
-
userIds?:
|
|
19
|
+
userIds?: QualifiedId[] | QualifiedUserClients;
|
|
23
20
|
onClientMismatch?: (status: ClientMismatch | MessageSendingStatus, wasSent: boolean) => void | boolean | Promise<boolean>;
|
|
24
21
|
protocol: ConversationProtocol.PROTEUS;
|
|
25
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProteusService.types.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"ProteusService.types.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,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,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;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,oBAAoB,CAAC;IAC/C,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"}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import { APIClient } from '@wireapp/api-client/lib/APIClient';
|
|
2
|
-
import { QualifiedUserClients
|
|
3
|
-
import { QualifiedId, QualifiedUserPreKeyBundleMap
|
|
2
|
+
import { QualifiedUserClients } from '@wireapp/api-client/lib/conversation';
|
|
3
|
+
import { QualifiedId, QualifiedUserPreKeyBundleMap } from '@wireapp/api-client/lib/user';
|
|
4
4
|
interface GetRecipientsForConversationQualifiedParams {
|
|
5
5
|
apiClient: APIClient;
|
|
6
6
|
conversationId: QualifiedId;
|
|
7
7
|
userIds?: QualifiedId[] | QualifiedUserClients;
|
|
8
8
|
}
|
|
9
|
-
declare const
|
|
10
|
-
|
|
11
|
-
apiClient: APIClient;
|
|
12
|
-
conversationId: QualifiedId;
|
|
13
|
-
userIds?: string[] | UserClients;
|
|
14
|
-
}
|
|
15
|
-
declare const getRecipientsForConversation: ({ apiClient, conversationId, userIds, }: GetRecipientsForConversationParams) => Promise<UserClients | UserPreKeyBundleMap>;
|
|
16
|
-
export { getQualifiedRecipientsForConversation, getRecipientsForConversation };
|
|
9
|
+
declare const getRecipientsForConversation: ({ apiClient, conversationId, userIds, }: GetRecipientsForConversationQualifiedParams) => Promise<QualifiedUserClients | QualifiedUserPreKeyBundleMap>;
|
|
10
|
+
export { getRecipientsForConversation };
|
|
17
11
|
//# sourceMappingURL=Recipients.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Recipients.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/Utility/Recipients.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"Recipients.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/Utility/Recipients.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAC,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAC,WAAW,EAAE,4BAA4B,EAAC,MAAM,8BAA8B,CAAC;AAOvF,UAAU,2CAA2C;IACnD,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,WAAW,CAAC;IAC5B,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,oBAAoB,CAAC;CAChD;AAED,QAAA,MAAM,4BAA4B,4CAI/B,2CAA2C,KAAG,QAAQ,oBAAoB,GAAG,4BAA4B,CAO3G,CAAC;AAEF,OAAO,EAAC,4BAA4B,EAAC,CAAC"}
|
|
@@ -18,26 +18,15 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.getRecipientsForConversation =
|
|
21
|
+
exports.getRecipientsForConversation = void 0;
|
|
22
22
|
const PreKeyBundle_1 = require("./PreKeyBundle/PreKeyBundle");
|
|
23
23
|
const getConversationQualifiedMembers_1 = require("../../../conversation/ConversationService/Utility/getConversationQualifiedMembers");
|
|
24
24
|
const util_1 = require("../../../util");
|
|
25
|
-
const
|
|
25
|
+
const getRecipientsForConversation = async ({ apiClient, conversationId, userIds, }) => {
|
|
26
26
|
if ((0, util_1.isQualifiedUserClients)(userIds)) {
|
|
27
27
|
return userIds;
|
|
28
28
|
}
|
|
29
29
|
const recipientIds = userIds || (await (0, getConversationQualifiedMembers_1.getConversationQualifiedMembers)({ apiClient: apiClient, conversationId }));
|
|
30
30
|
return (0, PreKeyBundle_1.getQualifiedPreKeyBundle)({ apiClient, userIds: recipientIds });
|
|
31
31
|
};
|
|
32
|
-
exports.getQualifiedRecipientsForConversation = getQualifiedRecipientsForConversation;
|
|
33
|
-
const getRecipientsForConversation = async ({ apiClient, conversationId, userIds, }) => {
|
|
34
|
-
if ((0, util_1.isUserClients)(userIds)) {
|
|
35
|
-
return userIds;
|
|
36
|
-
}
|
|
37
|
-
return (0, PreKeyBundle_1.getPreKeyBundleMap)({
|
|
38
|
-
apiClient: apiClient,
|
|
39
|
-
conversationId,
|
|
40
|
-
userIds,
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
32
|
exports.getRecipientsForConversation = getRecipientsForConversation;
|