@wireapp/core 17.31.0 → 17.31.4
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/CHANGELOG.md +35 -0
- package/package.json +9 -9
- package/src/main/Account.js.map +0 -1
- package/src/main/Account.test.browser.js +0 -114
- package/src/main/Account.test.node.d.ts +0 -1
- package/src/main/Account.test.node.js +0 -214
- package/src/main/Account.test.node.js.map +0 -1
- package/src/main/Account.test.node.ts +0 -236
- package/src/main/Account.ts +0 -401
- package/src/main/CoreError.js.map +0 -1
- package/src/main/CoreError.ts +0 -30
- package/src/main/auth/LoginSanitizer.js.map +0 -1
- package/src/main/auth/LoginSanitizer.test.node.d.ts +0 -1
- package/src/main/auth/LoginSanitizer.test.node.js +0 -56
- package/src/main/auth/LoginSanitizer.test.node.js.map +0 -1
- package/src/main/auth/LoginSanitizer.test.node.ts +0 -68
- package/src/main/auth/LoginSanitizer.ts +0 -44
- package/src/main/auth/index.js.map +0 -1
- package/src/main/auth/index.ts +0 -20
- package/src/main/broadcast/AvailabilityType.js.map +0 -1
- package/src/main/broadcast/AvailabilityType.ts +0 -22
- package/src/main/broadcast/BroadcastService.js.map +0 -1
- package/src/main/broadcast/BroadcastService.ts +0 -66
- package/src/main/broadcast/index.js.map +0 -1
- package/src/main/broadcast/index.ts +0 -21
- package/src/main/client/ClientBackendRepository.js.map +0 -1
- package/src/main/client/ClientBackendRepository.ts +0 -33
- package/src/main/client/ClientDatabaseRepository.js.map +0 -1
- package/src/main/client/ClientDatabaseRepository.ts +0 -130
- package/src/main/client/ClientInfo.js.map +0 -1
- package/src/main/client/ClientInfo.ts +0 -28
- package/src/main/client/ClientService.js.map +0 -1
- package/src/main/client/ClientService.ts +0 -116
- package/src/main/client/index.js.map +0 -1
- package/src/main/client/index.ts +0 -23
- package/src/main/connection/ConnectionService.js.map +0 -1
- package/src/main/connection/ConnectionService.ts +0 -49
- package/src/main/connection/index.js.map +0 -1
- package/src/main/connection/index.ts +0 -20
- package/src/main/conversation/AbortReason.js.map +0 -1
- package/src/main/conversation/AbortReason.ts +0 -22
- package/src/main/conversation/AssetService.js.map +0 -1
- package/src/main/conversation/AssetService.test.node.d.ts +0 -1
- package/src/main/conversation/AssetService.test.node.js +0 -61
- package/src/main/conversation/AssetService.test.node.js.map +0 -1
- package/src/main/conversation/AssetService.test.node.ts +0 -65
- package/src/main/conversation/AssetService.ts +0 -60
- package/src/main/conversation/AssetTransferState.js.map +0 -1
- package/src/main/conversation/AssetTransferState.ts +0 -23
- package/src/main/conversation/ClientActionType.js.map +0 -1
- package/src/main/conversation/ClientActionType.ts +0 -20
- package/src/main/conversation/ConversationMapper.js.map +0 -1
- package/src/main/conversation/ConversationMapper.test.node.d.ts +0 -1
- package/src/main/conversation/ConversationMapper.test.node.js +0 -111
- package/src/main/conversation/ConversationMapper.test.node.js.map +0 -1
- package/src/main/conversation/ConversationMapper.test.node.ts +0 -154
- package/src/main/conversation/ConversationMapper.ts +0 -56
- package/src/main/conversation/ConversationService.js.map +0 -1
- package/src/main/conversation/ConversationService.test.node.d.ts +0 -1
- package/src/main/conversation/ConversationService.test.node.js +0 -344
- package/src/main/conversation/ConversationService.test.node.js.map +0 -1
- package/src/main/conversation/ConversationService.test.node.ts +0 -416
- package/src/main/conversation/ConversationService.ts +0 -1024
- package/src/main/conversation/GenericMessageType.js.map +0 -1
- package/src/main/conversation/GenericMessageType.ts +0 -44
- package/src/main/conversation/MessageTimer.js.map +0 -1
- package/src/main/conversation/MessageTimer.test.node.d.ts +0 -1
- package/src/main/conversation/MessageTimer.test.node.js +0 -88
- package/src/main/conversation/MessageTimer.test.node.js.map +0 -1
- package/src/main/conversation/MessageTimer.test.node.ts +0 -103
- package/src/main/conversation/MessageTimer.ts +0 -56
- package/src/main/conversation/ReactionType.js.map +0 -1
- package/src/main/conversation/ReactionType.ts +0 -23
- package/src/main/conversation/content/AssetContent.js.map +0 -1
- package/src/main/conversation/content/AssetContent.ts +0 -71
- package/src/main/conversation/content/ButtonActionConfirmationContent.js.map +0 -1
- package/src/main/conversation/content/ButtonActionConfirmationContent.ts +0 -21
- package/src/main/conversation/content/ButtonActionContent.js.map +0 -1
- package/src/main/conversation/content/ButtonActionContent.ts +0 -21
- package/src/main/conversation/content/CallingContent.js.map +0 -1
- package/src/main/conversation/content/CallingContent.ts +0 -20
- package/src/main/conversation/content/ClearedContent.js.map +0 -1
- package/src/main/conversation/content/ClearedContent.ts +0 -21
- package/src/main/conversation/content/ClientActionContent.js.map +0 -1
- package/src/main/conversation/content/ClientActionContent.ts +0 -22
- package/src/main/conversation/content/ClientAddContent.js.map +0 -1
- package/src/main/conversation/content/ClientAddContent.ts +0 -24
- package/src/main/conversation/content/ClientRemoveContent.js.map +0 -1
- package/src/main/conversation/content/ClientRemoveContent.ts +0 -25
- package/src/main/conversation/content/CompositeContent.js.map +0 -1
- package/src/main/conversation/content/CompositeContent.ts +0 -21
- package/src/main/conversation/content/ConfirmationContent.js.map +0 -1
- package/src/main/conversation/content/ConfirmationContent.ts +0 -21
- package/src/main/conversation/content/ContentType.js.map +0 -1
- package/src/main/conversation/content/ContentType.ts +0 -112
- package/src/main/conversation/content/ConversationContent.js.map +0 -1
- package/src/main/conversation/content/ConversationContent.ts +0 -71
- package/src/main/conversation/content/DeletedContent.js.map +0 -1
- package/src/main/conversation/content/DeletedContent.ts +0 -21
- package/src/main/conversation/content/EditedTextContent.js.map +0 -1
- package/src/main/conversation/content/EditedTextContent.ts +0 -31
- package/src/main/conversation/content/FileContent.js.map +0 -1
- package/src/main/conversation/content/FileContent.ts +0 -32
- package/src/main/conversation/content/HiddenContent.js.map +0 -1
- package/src/main/conversation/content/HiddenContent.ts +0 -21
- package/src/main/conversation/content/ImageContent.js.map +0 -1
- package/src/main/conversation/content/ImageContent.ts +0 -25
- package/src/main/conversation/content/KnockContent.js.map +0 -1
- package/src/main/conversation/content/KnockContent.ts +0 -21
- package/src/main/conversation/content/LinkPreviewContent.js.map +0 -1
- package/src/main/conversation/content/LinkPreviewContent.ts +0 -32
- package/src/main/conversation/content/LocationContent.js.map +0 -1
- package/src/main/conversation/content/LocationContent.ts +0 -29
- package/src/main/conversation/content/MentionContent.js.map +0 -1
- package/src/main/conversation/content/MentionContent.ts +0 -21
- package/src/main/conversation/content/QuoteContent.js.map +0 -1
- package/src/main/conversation/content/QuoteContent.ts +0 -29
- package/src/main/conversation/content/ReactionContent.js.map +0 -1
- package/src/main/conversation/content/ReactionContent.ts +0 -27
- package/src/main/conversation/content/TextContent.js.map +0 -1
- package/src/main/conversation/content/TextContent.ts +0 -29
- package/src/main/conversation/content/TweetContent.js.map +0 -1
- package/src/main/conversation/content/TweetContent.ts +0 -21
- package/src/main/conversation/content/index.js.map +0 -1
- package/src/main/conversation/content/index.ts +0 -49
- package/src/main/conversation/index.js.map +0 -1
- package/src/main/conversation/index.ts +0 -28
- package/src/main/conversation/message/CompositeContentBuilder.js.map +0 -1
- package/src/main/conversation/message/CompositeContentBuilder.ts +0 -60
- package/src/main/conversation/message/Message.js.map +0 -1
- package/src/main/conversation/message/Message.ts +0 -24
- package/src/main/conversation/message/MessageBuilder.js.map +0 -1
- package/src/main/conversation/message/MessageBuilder.test.browser.js +0 -27
- package/src/main/conversation/message/MessageBuilder.ts +0 -488
- package/src/main/conversation/message/MessageService.js.map +0 -1
- package/src/main/conversation/message/MessageService.test.node.d.ts +0 -1
- package/src/main/conversation/message/MessageService.test.node.js +0 -308
- package/src/main/conversation/message/MessageService.test.node.js.map +0 -1
- package/src/main/conversation/message/MessageService.test.node.ts +0 -398
- package/src/main/conversation/message/MessageService.ts +0 -383
- package/src/main/conversation/message/MessageToProtoMapper.js.map +0 -1
- package/src/main/conversation/message/MessageToProtoMapper.ts +0 -114
- package/src/main/conversation/message/OtrMessage.js.map +0 -1
- package/src/main/conversation/message/OtrMessage.ts +0 -160
- package/src/main/conversation/message/PayloadBundle.js.map +0 -1
- package/src/main/conversation/message/PayloadBundle.ts +0 -101
- package/src/main/conversation/message/TeamMessage.js.map +0 -1
- package/src/main/conversation/message/TeamMessage.ts +0 -72
- package/src/main/conversation/message/TextContentBuilder.js.map +0 -1
- package/src/main/conversation/message/TextContentBuilder.ts +0 -88
- package/src/main/conversation/message/UserClientsUtil.js.map +0 -1
- package/src/main/conversation/message/UserClientsUtil.ts +0 -44
- package/src/main/conversation/message/UserClientsUtils.test.node.d.ts +0 -1
- package/src/main/conversation/message/UserClientsUtils.test.node.js +0 -42
- package/src/main/conversation/message/UserClientsUtils.test.node.js.map +0 -1
- package/src/main/conversation/message/UserClientsUtils.test.node.ts +0 -44
- package/src/main/conversation/message/UserMessage.js.map +0 -1
- package/src/main/conversation/message/UserMessage.ts +0 -95
- package/src/main/cryptography/AssetCryptography.browser.js.map +0 -1
- package/src/main/cryptography/AssetCryptography.browser.ts +0 -76
- package/src/main/cryptography/AssetCryptography.node.js.map +0 -1
- package/src/main/cryptography/AssetCryptography.node.ts +0 -85
- package/src/main/cryptography/CryptographyDatabaseRepository.js.map +0 -1
- package/src/main/cryptography/CryptographyDatabaseRepository.ts +0 -44
- package/src/main/cryptography/CryptographyService.js.map +0 -1
- package/src/main/cryptography/CryptographyService.test.browser.js +0 -195
- package/src/main/cryptography/CryptographyService.test.node.d.ts +0 -1
- package/src/main/cryptography/CryptographyService.test.node.js +0 -228
- package/src/main/cryptography/CryptographyService.test.node.js.map +0 -1
- package/src/main/cryptography/CryptographyService.test.node.ts +0 -246
- package/src/main/cryptography/CryptographyService.ts +0 -246
- package/src/main/cryptography/EncryptedAsset.js.map +0 -1
- package/src/main/cryptography/EncryptedAsset.ts +0 -30
- package/src/main/cryptography/GenericMessageMapper.js.map +0 -1
- package/src/main/cryptography/GenericMessageMapper.ts +0 -274
- package/src/main/cryptography/MessageHashService.js.map +0 -1
- package/src/main/cryptography/MessageHashService.test.browser.js +0 -176
- package/src/main/cryptography/MessageHashService.test.node.d.ts +0 -1
- package/src/main/cryptography/MessageHashService.test.node.js +0 -138
- package/src/main/cryptography/MessageHashService.test.node.js.map +0 -1
- package/src/main/cryptography/MessageHashService.test.node.ts +0 -176
- package/src/main/cryptography/MessageHashService.ts +0 -109
- package/src/main/cryptography/SessionPayloadBundle.js.map +0 -1
- package/src/main/cryptography/SessionPayloadBundle.ts +0 -23
- package/src/main/cryptography/index.js.map +0 -1
- package/src/main/cryptography/index.ts +0 -23
- package/src/main/giphy/GiphyService.js.map +0 -1
- package/src/main/giphy/GiphyService.ts +0 -37
- package/src/main/giphy/index.js.map +0 -1
- package/src/main/giphy/index.ts +0 -20
- package/src/main/index.js.map +0 -1
- package/src/main/index.test.browser.js +0 -22
- package/src/main/index.ts +0 -34
- package/src/main/notification/NotificationBackendRepository.js.map +0 -1
- package/src/main/notification/NotificationBackendRepository.ts +0 -33
- package/src/main/notification/NotificationDatabaseRepository.js.map +0 -1
- package/src/main/notification/NotificationDatabaseRepository.ts +0 -74
- package/src/main/notification/NotificationService.js.map +0 -1
- package/src/main/notification/NotificationService.test.browser.js +0 -179
- package/src/main/notification/NotificationService.test.node.d.ts +0 -1
- package/src/main/notification/NotificationService.test.node.js +0 -99
- package/src/main/notification/NotificationService.test.node.js.map +0 -1
- package/src/main/notification/NotificationService.test.node.ts +0 -124
- package/src/main/notification/NotificationService.ts +0 -260
- package/src/main/notification/index.js.map +0 -1
- package/src/main/notification/index.ts +0 -20
- package/src/main/self/SelfService.js.map +0 -1
- package/src/main/self/SelfService.ts +0 -59
- package/src/main/self/index.js.map +0 -1
- package/src/main/self/index.ts +0 -20
- package/src/main/team/TeamService.js.map +0 -1
- package/src/main/team/TeamService.ts +0 -68
- package/src/main/team/index.js.map +0 -1
- package/src/main/team/index.ts +0 -20
- package/src/main/test/CryptographyHelper.js.map +0 -1
- package/src/main/test/CryptographyHelper.ts +0 -57
- package/src/main/test/PayloadHelper.js.map +0 -1
- package/src/main/test/PayloadHelper.ts +0 -60
- package/src/main/user/UserMapper.js.map +0 -1
- package/src/main/user/UserMapper.test.node.d.ts +0 -1
- package/src/main/user/UserMapper.test.node.js +0 -55
- package/src/main/user/UserMapper.test.node.js.map +0 -1
- package/src/main/user/UserMapper.test.node.ts +0 -63
- package/src/main/user/UserMapper.ts +0 -92
- package/src/main/user/UserService.js.map +0 -1
- package/src/main/user/UserService.test.node.js +0 -141
- package/src/main/user/UserService.ts +0 -98
- package/src/main/user/index.js.map +0 -1
- package/src/main/user/index.ts +0 -20
- package/src/main/util/TypePredicateUtil.js.map +0 -1
- package/src/main/util/TypePredicateUtil.test.node.d.ts +0 -1
- package/src/main/util/TypePredicateUtil.test.node.js +0 -42
- package/src/main/util/TypePredicateUtil.test.node.js.map +0 -1
- package/src/main/util/TypePredicateUtil.test.node.ts +0 -44
- package/src/main/util/TypePredicateUtil.ts +0 -52
- package/src/main/util/index.js.map +0 -1
- package/src/main/util/index.ts +0 -20
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2020 Wire Swiss GmbH
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import {StatusCodes as HTTP_STATUS} from 'http-status-codes';
|
|
21
|
-
import {AxiosError} from 'axios';
|
|
22
|
-
import {proteus as ProtobufOTR} from '@wireapp/protocol-messaging/web/otr';
|
|
23
|
-
import Long from 'long';
|
|
24
|
-
import {uuidToBytes} from '@wireapp/commons/src/main/util/StringUtil';
|
|
25
|
-
import {APIClient} from '@wireapp/api-client';
|
|
26
|
-
import {
|
|
27
|
-
ClientMismatch,
|
|
28
|
-
MessageSendingStatus,
|
|
29
|
-
NewOTRMessage,
|
|
30
|
-
OTRRecipients,
|
|
31
|
-
QualifiedOTRRecipients,
|
|
32
|
-
QualifiedUserClients,
|
|
33
|
-
UserClients,
|
|
34
|
-
} from '@wireapp/api-client/src/conversation';
|
|
35
|
-
import {Encoder} from 'bazinga64';
|
|
36
|
-
|
|
37
|
-
import {encryptAsset} from '../../cryptography/AssetCryptography.node';
|
|
38
|
-
import {CryptographyService} from '../../cryptography';
|
|
39
|
-
import {QualifiedId, QualifiedUserPreKeyBundleMap, UserPreKeyBundleMap} from '@wireapp/api-client/src/user';
|
|
40
|
-
import {MessageBuilder} from './MessageBuilder';
|
|
41
|
-
import {GenericMessage} from '@wireapp/protocol-messaging';
|
|
42
|
-
import {GenericMessageType} from '..';
|
|
43
|
-
import {flattenUserClients, flattenQualifiedUserClients} from './UserClientsUtil';
|
|
44
|
-
import {isQualifiedIdArray, isStringArray} from '../../util';
|
|
45
|
-
|
|
46
|
-
type ClientMismatchError = AxiosError<ClientMismatch | MessageSendingStatus>;
|
|
47
|
-
|
|
48
|
-
export class MessageService {
|
|
49
|
-
constructor(private readonly apiClient: APIClient, private readonly cryptographyService: CryptographyService) {}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Sends a message to a non-federated backend.
|
|
53
|
-
*
|
|
54
|
-
* @param sendingClientId The clientId of the current user
|
|
55
|
-
* @param recipients The list of recipients to send the message to
|
|
56
|
-
* @param plainText The plainText data to send
|
|
57
|
-
* @param options.conversationId? the conversation to send the message to. Will broadcast if not set
|
|
58
|
-
* @param options.reportMissing? trigger a mismatch error when there are missing recipients in the payload
|
|
59
|
-
* @param options.sendAsProtobuf?
|
|
60
|
-
* @param options.onClientMismatch? Called when a mismatch happens on the server
|
|
61
|
-
* @return the ClientMismatch status returned by the backend
|
|
62
|
-
*/
|
|
63
|
-
public async sendMessage(
|
|
64
|
-
sendingClientId: string,
|
|
65
|
-
recipients: UserClients | UserPreKeyBundleMap,
|
|
66
|
-
plainText: Uint8Array,
|
|
67
|
-
options: {
|
|
68
|
-
conversationId?: string;
|
|
69
|
-
reportMissing?: boolean | string[];
|
|
70
|
-
sendAsProtobuf?: boolean;
|
|
71
|
-
nativePush?: boolean;
|
|
72
|
-
onClientMismatch?: (mismatch: ClientMismatch) => void | boolean | Promise<boolean>;
|
|
73
|
-
} = {},
|
|
74
|
-
): Promise<ClientMismatch & {errored?: boolean}> {
|
|
75
|
-
let plainTextPayload = plainText;
|
|
76
|
-
let cipherText: Uint8Array;
|
|
77
|
-
if (this.shouldSendAsExternal(plainText, recipients)) {
|
|
78
|
-
const externalPayload = await this.generateExternalPayload(plainText);
|
|
79
|
-
plainTextPayload = externalPayload.text;
|
|
80
|
-
cipherText = externalPayload.cipherText;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const encryptedPayload = await this.cryptographyService.encrypt(plainTextPayload, recipients);
|
|
84
|
-
const send = (payload: OTRRecipients<Uint8Array>) => {
|
|
85
|
-
return options.sendAsProtobuf
|
|
86
|
-
? this.sendOTRProtobufMessage(sendingClientId, payload, {...options, assetData: cipherText})
|
|
87
|
-
: this.sendOTRMessage(sendingClientId, payload, {...options, assetData: cipherText});
|
|
88
|
-
};
|
|
89
|
-
try {
|
|
90
|
-
return await send(encryptedPayload);
|
|
91
|
-
} catch (error) {
|
|
92
|
-
if (!this.isClientMismatchError(error)) {
|
|
93
|
-
throw error;
|
|
94
|
-
}
|
|
95
|
-
const mismatch = error.response!.data as ClientMismatch;
|
|
96
|
-
const shouldStopSending = options.onClientMismatch && (await options.onClientMismatch(mismatch)) === false;
|
|
97
|
-
if (shouldStopSending) {
|
|
98
|
-
return {...mismatch, errored: true};
|
|
99
|
-
}
|
|
100
|
-
const reEncryptedMessage = await this.reencryptAfterMismatch(mismatch, encryptedPayload, plainText);
|
|
101
|
-
return send(reEncryptedMessage);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Sends a message to a federated backend.
|
|
107
|
-
*
|
|
108
|
-
* @param sendingClientId The clientId of the current user
|
|
109
|
-
* @param recipients The list of recipients to send the message to
|
|
110
|
-
* @param plainText The plainText data to send
|
|
111
|
-
* @param options.conversationId? the conversation to send the message to. Will broadcast if not set
|
|
112
|
-
* @param options.reportMissing? trigger a mismatch error when there are missing recipients in the payload
|
|
113
|
-
* @param options.sendAsProtobuf?
|
|
114
|
-
* @param options.onClientMismatch? Called when a mismatch happens on the server
|
|
115
|
-
* @return the MessageSendingStatus returned by the backend
|
|
116
|
-
*/
|
|
117
|
-
public async sendFederatedMessage(
|
|
118
|
-
sendingClientId: string,
|
|
119
|
-
recipients: QualifiedUserClients | QualifiedUserPreKeyBundleMap,
|
|
120
|
-
plainText: Uint8Array,
|
|
121
|
-
options: {
|
|
122
|
-
assetData?: Uint8Array;
|
|
123
|
-
conversationId?: QualifiedId;
|
|
124
|
-
reportMissing?: boolean | QualifiedId[];
|
|
125
|
-
nativePush?: boolean;
|
|
126
|
-
onClientMismatch?: (mismatch: MessageSendingStatus) => void | boolean | Promise<boolean>;
|
|
127
|
-
},
|
|
128
|
-
): Promise<MessageSendingStatus & {errored?: boolean}> {
|
|
129
|
-
const send = (payload: QualifiedOTRRecipients) => {
|
|
130
|
-
return this.sendFederatedOtrMessage(sendingClientId, payload, options);
|
|
131
|
-
};
|
|
132
|
-
const encryptedPayload = await this.cryptographyService.encryptQualified(plainText, recipients);
|
|
133
|
-
try {
|
|
134
|
-
return await send(encryptedPayload);
|
|
135
|
-
} catch (error) {
|
|
136
|
-
if (!this.isClientMismatchError(error)) {
|
|
137
|
-
throw error;
|
|
138
|
-
}
|
|
139
|
-
const mismatch = error.response!.data as MessageSendingStatus;
|
|
140
|
-
const shouldStopSending = options.onClientMismatch && (await options.onClientMismatch(mismatch)) === false;
|
|
141
|
-
if (shouldStopSending) {
|
|
142
|
-
return {...mismatch, errored: true};
|
|
143
|
-
}
|
|
144
|
-
const reEncryptedPayload = await this.reencryptAfterFederatedMismatch(mismatch, encryptedPayload, plainText);
|
|
145
|
-
return send(reEncryptedPayload);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
private async sendFederatedOtrMessage(
|
|
150
|
-
sendingClientId: string,
|
|
151
|
-
recipients: QualifiedOTRRecipients,
|
|
152
|
-
options: {
|
|
153
|
-
assetData?: Uint8Array;
|
|
154
|
-
conversationId?: QualifiedId;
|
|
155
|
-
reportMissing?: boolean | QualifiedId[];
|
|
156
|
-
nativePush?: boolean;
|
|
157
|
-
},
|
|
158
|
-
): Promise<MessageSendingStatus> {
|
|
159
|
-
const qualifiedUserEntries = Object.entries(recipients).map<ProtobufOTR.IQualifiedUserEntry>(
|
|
160
|
-
([domain, otrRecipients]) => {
|
|
161
|
-
const userEntries = Object.entries(otrRecipients).map<ProtobufOTR.IUserEntry>(([userId, otrClientMap]) => {
|
|
162
|
-
const clientEntries = Object.entries(otrClientMap).map<ProtobufOTR.IClientEntry>(([clientId, payload]) => {
|
|
163
|
-
return {
|
|
164
|
-
client: {
|
|
165
|
-
client: Long.fromString(clientId, 16),
|
|
166
|
-
},
|
|
167
|
-
text: payload,
|
|
168
|
-
};
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
user: {
|
|
173
|
-
uuid: uuidToBytes(userId),
|
|
174
|
-
},
|
|
175
|
-
clients: clientEntries,
|
|
176
|
-
};
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
return {domain, entries: userEntries};
|
|
180
|
-
},
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
const protoMessage = ProtobufOTR.QualifiedNewOtrMessage.create({
|
|
184
|
-
recipients: qualifiedUserEntries,
|
|
185
|
-
sender: {
|
|
186
|
-
client: Long.fromString(sendingClientId, 16),
|
|
187
|
-
},
|
|
188
|
-
nativePush: options.nativePush,
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
if (options.assetData) {
|
|
192
|
-
protoMessage.blob = options.assetData;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (options.reportMissing) {
|
|
196
|
-
if (isQualifiedIdArray(options.reportMissing)) {
|
|
197
|
-
protoMessage.reportOnly = {userIds: options.reportMissing};
|
|
198
|
-
} else {
|
|
199
|
-
protoMessage.reportAll = true;
|
|
200
|
-
}
|
|
201
|
-
} else {
|
|
202
|
-
protoMessage.ignoreAll = true;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (!options.conversationId) {
|
|
206
|
-
//TODO implement federated broadcast sending
|
|
207
|
-
throw new Error('Unimplemented federated broadcast');
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const {id, domain} = options.conversationId;
|
|
211
|
-
|
|
212
|
-
return this.apiClient.conversation.api.postOTRMessageV2(id, domain, protoMessage);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
private async sendOTRMessage(
|
|
216
|
-
sendingClientId: string,
|
|
217
|
-
recipients: OTRRecipients<Uint8Array>,
|
|
218
|
-
options: {
|
|
219
|
-
conversationId?: string;
|
|
220
|
-
assetData?: Uint8Array;
|
|
221
|
-
reportMissing?: boolean | string[];
|
|
222
|
-
nativePush?: boolean;
|
|
223
|
-
},
|
|
224
|
-
): Promise<ClientMismatch> {
|
|
225
|
-
const message: NewOTRMessage<string> = {
|
|
226
|
-
data: options.assetData ? Encoder.toBase64(options.assetData).asString : undefined,
|
|
227
|
-
recipients: CryptographyService.convertArrayRecipientsToBase64(recipients),
|
|
228
|
-
sender: sendingClientId,
|
|
229
|
-
native_push: options.nativePush,
|
|
230
|
-
};
|
|
231
|
-
|
|
232
|
-
let ignoreMissing;
|
|
233
|
-
if (isStringArray(options.reportMissing)) {
|
|
234
|
-
message.report_missing = options.reportMissing;
|
|
235
|
-
} else {
|
|
236
|
-
// By default we want ignore missing to be false (and have mismatch errors in case some clients are missing)
|
|
237
|
-
ignoreMissing = typeof options.reportMissing === 'boolean' ? !options.reportMissing : false;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return !options.conversationId
|
|
241
|
-
? this.apiClient.broadcast.api.postBroadcastMessage(sendingClientId, message, ignoreMissing)
|
|
242
|
-
: this.apiClient.conversation.api.postOTRMessage(sendingClientId, options.conversationId, message, ignoreMissing);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
private async generateExternalPayload(plainText: Uint8Array): Promise<{text: Uint8Array; cipherText: Uint8Array}> {
|
|
246
|
-
const asset = await encryptAsset({plainText});
|
|
247
|
-
const {cipherText, keyBytes, sha256} = asset;
|
|
248
|
-
const messageId = MessageBuilder.createId();
|
|
249
|
-
|
|
250
|
-
const externalMessage = {
|
|
251
|
-
otrKey: new Uint8Array(keyBytes),
|
|
252
|
-
sha256: new Uint8Array(sha256),
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
const genericMessage = GenericMessage.create({
|
|
256
|
-
[GenericMessageType.EXTERNAL]: externalMessage,
|
|
257
|
-
messageId,
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
return {text: GenericMessage.encode(genericMessage).finish(), cipherText};
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
private shouldSendAsExternal(plainText: Uint8Array, preKeyBundles: UserPreKeyBundleMap | UserClients): boolean {
|
|
264
|
-
const EXTERNAL_MESSAGE_THRESHOLD_BYTES = 200 * 1024;
|
|
265
|
-
|
|
266
|
-
let clientCount = 0;
|
|
267
|
-
for (const user in preKeyBundles) {
|
|
268
|
-
clientCount += Object.keys(preKeyBundles[user]).length;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const messageInBytes = new Uint8Array(plainText).length;
|
|
272
|
-
const estimatedPayloadInBytes = clientCount * messageInBytes;
|
|
273
|
-
|
|
274
|
-
return estimatedPayloadInBytes > EXTERNAL_MESSAGE_THRESHOLD_BYTES;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
private isClientMismatchError(error: any): error is ClientMismatchError {
|
|
278
|
-
return error.response?.status === HTTP_STATUS.PRECONDITION_FAILED;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
private async reencryptAfterMismatch(
|
|
282
|
-
mismatch: ClientMismatch,
|
|
283
|
-
recipients: OTRRecipients<Uint8Array>,
|
|
284
|
-
plainText: Uint8Array,
|
|
285
|
-
): Promise<OTRRecipients<Uint8Array>> {
|
|
286
|
-
const deleted = flattenUserClients(mismatch.deleted);
|
|
287
|
-
const missing = flattenUserClients(mismatch.missing);
|
|
288
|
-
// remove deleted clients to the recipients
|
|
289
|
-
deleted.forEach(({userId, data}) => data.forEach(clientId => delete recipients[userId.id][clientId]));
|
|
290
|
-
if (missing.length) {
|
|
291
|
-
const missingPreKeyBundles = await this.apiClient.user.api.postMultiPreKeyBundles(mismatch.missing);
|
|
292
|
-
const reEncrypted = await this.cryptographyService.encrypt(plainText, missingPreKeyBundles);
|
|
293
|
-
const reEncryptedPayloads = flattenUserClients<{[client: string]: Uint8Array}>(reEncrypted);
|
|
294
|
-
// add missing clients to the recipients
|
|
295
|
-
reEncryptedPayloads.forEach(({data, userId}) => (recipients[userId.id] = {...recipients[userId.id], ...data}));
|
|
296
|
-
}
|
|
297
|
-
return recipients;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Will re-encrypt a message when there were some missing clients in the initial send (typically when the server replies with a client mismatch error)
|
|
302
|
-
*
|
|
303
|
-
* @param {ProtobufOTR.QualifiedNewOtrMessage} messageData The initial message that was sent
|
|
304
|
-
* @param {MessageSendingStatus} messageSendingStatus Info about the missing/deleted clients
|
|
305
|
-
* @param {Uint8Array} plainText The text that should be encrypted for the missing clients
|
|
306
|
-
* @return resolves with a new message payload that can be sent
|
|
307
|
-
*/
|
|
308
|
-
private async reencryptAfterFederatedMismatch(
|
|
309
|
-
mismatch: MessageSendingStatus,
|
|
310
|
-
recipients: QualifiedOTRRecipients,
|
|
311
|
-
plainText: Uint8Array,
|
|
312
|
-
): Promise<QualifiedOTRRecipients> {
|
|
313
|
-
const deleted = flattenQualifiedUserClients(mismatch.deleted);
|
|
314
|
-
const missing = flattenQualifiedUserClients(mismatch.missing);
|
|
315
|
-
// remove deleted clients to the recipients
|
|
316
|
-
deleted.forEach(({userId, data}) =>
|
|
317
|
-
data.forEach(clientId => delete recipients[userId.domain][userId.id][clientId]),
|
|
318
|
-
);
|
|
319
|
-
|
|
320
|
-
if (Object.keys(missing).length) {
|
|
321
|
-
const missingPreKeyBundles = await this.apiClient.user.api.postQualifiedMultiPreKeyBundles(mismatch.missing);
|
|
322
|
-
const reEncrypted = await this.cryptographyService.encryptQualified(plainText, missingPreKeyBundles);
|
|
323
|
-
const reEncryptedPayloads = flattenQualifiedUserClients<{[client: string]: Uint8Array}>(reEncrypted);
|
|
324
|
-
reEncryptedPayloads.forEach(
|
|
325
|
-
({data, userId}) => (recipients[userId.domain][userId.id] = {...recipients[userId.domain][userId.id], ...data}),
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
return recipients;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
private async sendOTRProtobufMessage(
|
|
332
|
-
sendingClientId: string,
|
|
333
|
-
recipients: OTRRecipients<Uint8Array>,
|
|
334
|
-
options: {conversationId?: string; assetData?: Uint8Array; reportMissing?: boolean | string[]},
|
|
335
|
-
): Promise<ClientMismatch> {
|
|
336
|
-
const userEntries: ProtobufOTR.IUserEntry[] = Object.entries(recipients).map(([userId, otrClientMap]) => {
|
|
337
|
-
const clients: ProtobufOTR.IClientEntry[] = Object.entries(otrClientMap).map(([clientId, payload]) => {
|
|
338
|
-
return {
|
|
339
|
-
client: {
|
|
340
|
-
client: Long.fromString(clientId, 16),
|
|
341
|
-
},
|
|
342
|
-
text: payload,
|
|
343
|
-
};
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
return {
|
|
347
|
-
clients,
|
|
348
|
-
user: {
|
|
349
|
-
uuid: uuidToBytes(userId),
|
|
350
|
-
},
|
|
351
|
-
};
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
const protoMessage = ProtobufOTR.NewOtrMessage.create({
|
|
355
|
-
recipients: userEntries,
|
|
356
|
-
sender: {
|
|
357
|
-
client: Long.fromString(sendingClientId, 16),
|
|
358
|
-
},
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
let ignoreMissing;
|
|
362
|
-
if (isStringArray(options.reportMissing)) {
|
|
363
|
-
const encoder = new TextEncoder();
|
|
364
|
-
protoMessage.reportMissing = options.reportMissing.map(userId => ({uuid: encoder.encode(userId)}));
|
|
365
|
-
} else {
|
|
366
|
-
// By default we want ignore missing to be false (and have mismatch errors in case some clients are missing)
|
|
367
|
-
ignoreMissing = typeof options.reportMissing === 'boolean' ? !options.reportMissing : false;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
if (options.assetData) {
|
|
371
|
-
protoMessage.blob = options.assetData;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
return !options.conversationId
|
|
375
|
-
? this.apiClient.broadcast.api.postBroadcastProtobufMessage(sendingClientId, protoMessage, ignoreMissing)
|
|
376
|
-
: this.apiClient.conversation.api.postOTRProtobufMessage(
|
|
377
|
-
sendingClientId,
|
|
378
|
-
options.conversationId,
|
|
379
|
-
protoMessage,
|
|
380
|
-
ignoreMissing,
|
|
381
|
-
);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessageToProtoMapper.js","sourceRoot":"","sources":["MessageToProtoMapper.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2020 Wire Swiss GmbH
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import {Article, Asset, LinkPreview, Mention, Quote, Text, Tweet} from '@wireapp/protocol-messaging';
|
|
21
|
-
|
|
22
|
-
import type {LinkPreviewUploadedContent} from '../content';
|
|
23
|
-
import {GenericMessageType} from '../GenericMessageType';
|
|
24
|
-
import type {EditedTextMessage, TextMessage} from './OtrMessage';
|
|
25
|
-
|
|
26
|
-
export class MessageToProtoMapper {
|
|
27
|
-
static mapLinkPreviews(linkPreviews: LinkPreviewUploadedContent[]): LinkPreview[] {
|
|
28
|
-
const builtLinkPreviews = [];
|
|
29
|
-
|
|
30
|
-
for (const linkPreview of linkPreviews) {
|
|
31
|
-
const linkPreviewMessage = LinkPreview.create({
|
|
32
|
-
permanentUrl: linkPreview.permanentUrl,
|
|
33
|
-
summary: linkPreview.summary,
|
|
34
|
-
title: linkPreview.title,
|
|
35
|
-
url: linkPreview.url,
|
|
36
|
-
urlOffset: linkPreview.urlOffset,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
if (linkPreview.tweet) {
|
|
40
|
-
linkPreviewMessage.tweet = Tweet.create({
|
|
41
|
-
author: linkPreview.tweet.author,
|
|
42
|
-
username: linkPreview.tweet.username,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (linkPreview.imageUploaded) {
|
|
47
|
-
const {asset, image} = linkPreview.imageUploaded;
|
|
48
|
-
|
|
49
|
-
const imageMetadata = Asset.ImageMetaData.create({
|
|
50
|
-
height: image.height,
|
|
51
|
-
width: image.width,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const original = Asset.Original.create({
|
|
55
|
-
[GenericMessageType.IMAGE]: imageMetadata,
|
|
56
|
-
mimeType: image.type,
|
|
57
|
-
size: image.data.length,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const remoteData = Asset.RemoteData.create({
|
|
61
|
-
assetId: asset.key,
|
|
62
|
-
assetToken: asset.token,
|
|
63
|
-
otrKey: asset.keyBytes,
|
|
64
|
-
sha256: asset.sha256,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const assetMessage = Asset.create({
|
|
68
|
-
original,
|
|
69
|
-
uploaded: remoteData,
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
linkPreviewMessage.image = assetMessage;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
linkPreviewMessage.article = Article.create({
|
|
76
|
-
image: linkPreviewMessage.image,
|
|
77
|
-
permanentUrl: linkPreviewMessage.permanentUrl,
|
|
78
|
-
summary: linkPreviewMessage.summary,
|
|
79
|
-
title: linkPreviewMessage.title,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
builtLinkPreviews.push(linkPreviewMessage);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return builtLinkPreviews;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
static mapText(payloadBundle: TextMessage | EditedTextMessage): Text {
|
|
89
|
-
const {expectsReadConfirmation, legalHoldStatus, linkPreviews, mentions, quote, text} = payloadBundle.content;
|
|
90
|
-
|
|
91
|
-
const textMessage = Text.create({
|
|
92
|
-
content: text,
|
|
93
|
-
expectsReadConfirmation,
|
|
94
|
-
legalHoldStatus,
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
if (linkPreviews?.length) {
|
|
98
|
-
textMessage.linkPreview = MessageToProtoMapper.mapLinkPreviews(linkPreviews);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (mentions?.length) {
|
|
102
|
-
textMessage.mentions = mentions.map(mention => Mention.create(mention));
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (quote) {
|
|
106
|
-
textMessage.quote = Quote.create({
|
|
107
|
-
quotedMessageId: quote.quotedMessageId,
|
|
108
|
-
quotedMessageSha256: quote.quotedMessageSha256,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return textMessage;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OtrMessage.js","sourceRoot":"","sources":["OtrMessage.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG"}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2018 Wire Swiss GmbH
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import type {
|
|
21
|
-
AssetContent,
|
|
22
|
-
ButtonActionContent,
|
|
23
|
-
ButtonActionConfirmationContent,
|
|
24
|
-
CallingContent,
|
|
25
|
-
ClearedContent,
|
|
26
|
-
ClientActionContent,
|
|
27
|
-
CompositeContent,
|
|
28
|
-
ConfirmationContent,
|
|
29
|
-
DeletedContent,
|
|
30
|
-
EditedTextContent,
|
|
31
|
-
FileAssetAbortContent,
|
|
32
|
-
FileAssetContent,
|
|
33
|
-
FileAssetMetaDataContent,
|
|
34
|
-
HiddenContent,
|
|
35
|
-
ImageAssetContent,
|
|
36
|
-
KnockContent,
|
|
37
|
-
LocationContent,
|
|
38
|
-
ReactionContent,
|
|
39
|
-
TextContent,
|
|
40
|
-
} from '../content';
|
|
41
|
-
import type {BasePayloadBundle, PayloadBundleType} from './PayloadBundle';
|
|
42
|
-
|
|
43
|
-
export interface TextMessage extends BasePayloadBundle {
|
|
44
|
-
content: TextContent;
|
|
45
|
-
type: PayloadBundleType.TEXT;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface ButtonActionMessage extends BasePayloadBundle {
|
|
49
|
-
content: ButtonActionContent;
|
|
50
|
-
type: PayloadBundleType.BUTTON_ACTION;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface ButtonActionConfirmationMessage extends BasePayloadBundle {
|
|
54
|
-
content: ButtonActionConfirmationContent;
|
|
55
|
-
type: PayloadBundleType.BUTTON_ACTION_CONFIRMATION;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface CallMessage extends BasePayloadBundle {
|
|
59
|
-
content: CallingContent;
|
|
60
|
-
type: PayloadBundleType.CALL;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface CompositeMessage extends BasePayloadBundle {
|
|
64
|
-
content: CompositeContent;
|
|
65
|
-
type: PayloadBundleType.COMPOSITE;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface EditedTextMessage extends BasePayloadBundle {
|
|
69
|
-
content: EditedTextContent;
|
|
70
|
-
type: PayloadBundleType.MESSAGE_EDIT;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface FileAssetMessage extends BasePayloadBundle {
|
|
74
|
-
content: FileAssetContent;
|
|
75
|
-
type: PayloadBundleType.ASSET;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface FileAssetMetaDataMessage extends BasePayloadBundle {
|
|
79
|
-
content: FileAssetMetaDataContent;
|
|
80
|
-
type: PayloadBundleType.ASSET_META;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface FileAssetAbortMessage extends BasePayloadBundle {
|
|
84
|
-
content: FileAssetAbortContent;
|
|
85
|
-
type: PayloadBundleType.ASSET_ABORT;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// TODO Merge ImageAssetMessageOutgoing & ImageAssetMessage
|
|
89
|
-
export interface ImageAssetMessageOutgoing extends BasePayloadBundle {
|
|
90
|
-
content: ImageAssetContent;
|
|
91
|
-
type: PayloadBundleType.ASSET_IMAGE;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export interface ImageAssetMessage extends BasePayloadBundle {
|
|
95
|
-
content: AssetContent;
|
|
96
|
-
type: PayloadBundleType.ASSET_IMAGE;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface LocationMessage extends BasePayloadBundle {
|
|
100
|
-
content: LocationContent;
|
|
101
|
-
type: PayloadBundleType.LOCATION;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export interface ReactionMessage extends BasePayloadBundle {
|
|
105
|
-
content: ReactionContent;
|
|
106
|
-
type: PayloadBundleType.REACTION;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface ConfirmationMessage extends BasePayloadBundle {
|
|
110
|
-
content: ConfirmationContent;
|
|
111
|
-
type: PayloadBundleType.CONFIRMATION;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export interface PingMessage extends BasePayloadBundle {
|
|
115
|
-
content: KnockContent;
|
|
116
|
-
type: PayloadBundleType.PING;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export interface ResetSessionMessage extends BasePayloadBundle {
|
|
120
|
-
content: ClientActionContent;
|
|
121
|
-
type: PayloadBundleType.CLIENT_ACTION;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export interface ClearConversationMessage extends BasePayloadBundle {
|
|
125
|
-
content: ClearedContent;
|
|
126
|
-
type: PayloadBundleType.CONVERSATION_CLEAR;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export interface HideMessage extends BasePayloadBundle {
|
|
130
|
-
content: HiddenContent;
|
|
131
|
-
type: PayloadBundleType.MESSAGE_HIDE;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export interface DeleteMessage extends BasePayloadBundle {
|
|
135
|
-
content: DeletedContent;
|
|
136
|
-
type: PayloadBundleType.MESSAGE_DELETE;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export type OtrMessage =
|
|
140
|
-
| ButtonActionMessage
|
|
141
|
-
| ButtonActionConfirmationMessage
|
|
142
|
-
| CallMessage
|
|
143
|
-
| ClearConversationMessage
|
|
144
|
-
| CompositeMessage
|
|
145
|
-
| ConfirmationMessage
|
|
146
|
-
| DeleteMessage
|
|
147
|
-
| EditedTextMessage
|
|
148
|
-
| FileAssetAbortMessage
|
|
149
|
-
| FileAssetMessage
|
|
150
|
-
| FileAssetMetaDataMessage
|
|
151
|
-
| HideMessage
|
|
152
|
-
| ImageAssetMessage
|
|
153
|
-
| ImageAssetMessageOutgoing
|
|
154
|
-
| LocationMessage
|
|
155
|
-
| PingMessage
|
|
156
|
-
| ReactionMessage
|
|
157
|
-
| ResetSessionMessage
|
|
158
|
-
| TextMessage;
|
|
159
|
-
|
|
160
|
-
export type QuotableMessage = EditedTextMessage | ImageAssetMessage | LocationMessage | TextMessage;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PayloadBundle.js","sourceRoot":"","sources":["PayloadBundle.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAUH,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC7B,0DAAmC,CAAA;IACnC,sFAA+D,CAAA;IAC/D,kEAA2C,CAAA;AAC7C,CAAC,EAJW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAI9B;AAED,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,8DAAwC,CAAA;IACxC,wEAAkD,CAAA;IAClD,4EAAsD,CAAA;IACtD,gEAA0C,CAAA;AAC5C,CAAC,EALW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAK7B;AAmBD,IAAY,iBA2CX;AA3CD,WAAY,iBAAiB;IAC3B,sDAAiC,CAAA;IACjC,kEAA6C,CAAA;IAC7C,kEAA6C,CAAA;IAC7C,gEAA2C,CAAA;IAC3C,sEAAiD,CAAA;IACjD,gGAA2E,CAAA;IAC3E,oDAA+B,CAAA;IAC/B,sEAAiD,CAAA;IACjD,gEAA2C,CAAA;IAC3C,sEAAiD,CAAA;IACjD,8DAAyC,CAAA;IACzC,oEAA+C,CAAA;IAC/C,gFAA2D,CAAA;IAC3D,gFAA2D,CAAA;IAC3D,kFAA6D,CAAA;IAC7D,4DAAuC,CAAA;IACvC,kEAA6C,CAAA;IAC7C,wEAAmD,CAAA;IACnD,oEAA+C,CAAA;IAC/C,oEAA+C,CAAA;IAC/C,oDAA+B,CAAA;IAC/B,4DAAuC,CAAA;IACvC,4FAAuE,CAAA;IACvE,4FAAuE,CAAA;IACvE,kEAA6C,CAAA;IAC7C,4EAAuD,CAAA;IACvD,8EAAyD,CAAA;IACzD,kEAA6C,CAAA;IAC7C,oDAA+B,CAAA;IAC/B,oEAA+C,CAAA;IAC/C,wDAAmC,CAAA;IACnC,0DAAqC,CAAA;IACrC,sEAAiD,CAAA;IACjD,0EAAqD,CAAA;IACrD,gFAA2D,CAAA;IAC3D,0EAAqD,CAAA;IACrD,kEAA6C,CAAA;IAC7C,0FAAqE,CAAA;IACrE,wFAAmE,CAAA;IACnE,0FAAqE,CAAA;IACrE,kFAA6D,CAAA;IAC7D,kEAA6C,CAAA;AAC/C,CAAC,EA3CW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QA2C5B"}
|