@wireapp/core 17.31.1 → 17.31.2
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 +11 -0
- package/package.json +7 -7
- 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,274 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2019 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 {ConversationOtrMessageAddEvent} from '@wireapp/api-client/src/event/';
|
|
21
|
-
import logdown from 'logdown';
|
|
22
|
-
import {
|
|
23
|
-
GenericMessageType,
|
|
24
|
-
PayloadBundle,
|
|
25
|
-
PayloadBundleSource,
|
|
26
|
-
PayloadBundleState,
|
|
27
|
-
PayloadBundleType,
|
|
28
|
-
} from '../conversation';
|
|
29
|
-
import type {
|
|
30
|
-
AssetContent,
|
|
31
|
-
ClearedContent,
|
|
32
|
-
ConfirmationContent,
|
|
33
|
-
DeletedContent,
|
|
34
|
-
EditedTextContent,
|
|
35
|
-
HiddenContent,
|
|
36
|
-
KnockContent,
|
|
37
|
-
LocationContent,
|
|
38
|
-
ReactionContent,
|
|
39
|
-
TextContent,
|
|
40
|
-
} from '../conversation/content';
|
|
41
|
-
|
|
42
|
-
export class GenericMessageMapper {
|
|
43
|
-
private static readonly logger = logdown('@wireapp/core/cryptography/GenericMessageMapper', {
|
|
44
|
-
logger: console,
|
|
45
|
-
markdown: false,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// TODO: Turn "any" into a specific type (or collection of types) and make the return type more specific based on the
|
|
49
|
-
// "genericMessage" input parameter.
|
|
50
|
-
public static mapGenericMessage(
|
|
51
|
-
genericMessage: any,
|
|
52
|
-
event: ConversationOtrMessageAddEvent,
|
|
53
|
-
source: PayloadBundleSource,
|
|
54
|
-
): PayloadBundle {
|
|
55
|
-
const baseMessage: Omit<PayloadBundle, 'content' | 'type'> = {
|
|
56
|
-
conversation: event.conversation,
|
|
57
|
-
qualifiedConversation: event.qualified_conversation,
|
|
58
|
-
qualifiedFrom: event.qualified_from,
|
|
59
|
-
fromClientId: event.data.sender,
|
|
60
|
-
from: event.from,
|
|
61
|
-
state: PayloadBundleState.INCOMING,
|
|
62
|
-
timestamp: new Date(event.time).getTime(),
|
|
63
|
-
id: genericMessage.messageId,
|
|
64
|
-
messageTimer: 0,
|
|
65
|
-
source,
|
|
66
|
-
};
|
|
67
|
-
switch (genericMessage.content) {
|
|
68
|
-
case GenericMessageType.TEXT: {
|
|
69
|
-
const {
|
|
70
|
-
content: text,
|
|
71
|
-
expectsReadConfirmation,
|
|
72
|
-
legalHoldStatus,
|
|
73
|
-
linkPreview: linkPreviews,
|
|
74
|
-
mentions,
|
|
75
|
-
quote,
|
|
76
|
-
} = genericMessage[GenericMessageType.TEXT];
|
|
77
|
-
|
|
78
|
-
const content: TextContent = {expectsReadConfirmation, legalHoldStatus, text};
|
|
79
|
-
|
|
80
|
-
if (linkPreviews?.length) {
|
|
81
|
-
content.linkPreviews = linkPreviews;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (mentions?.length) {
|
|
85
|
-
content.mentions = mentions;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (quote) {
|
|
89
|
-
content.quote = quote;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (typeof legalHoldStatus !== 'undefined') {
|
|
93
|
-
content.legalHoldStatus = legalHoldStatus;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
...baseMessage,
|
|
98
|
-
content,
|
|
99
|
-
type: PayloadBundleType.TEXT,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
case GenericMessageType.BUTTON_ACTION: {
|
|
103
|
-
return {
|
|
104
|
-
...baseMessage,
|
|
105
|
-
content: genericMessage.buttonAction!,
|
|
106
|
-
type: PayloadBundleType.BUTTON_ACTION,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
case GenericMessageType.CALLING: {
|
|
110
|
-
return {
|
|
111
|
-
...baseMessage,
|
|
112
|
-
content: genericMessage.calling.content,
|
|
113
|
-
type: PayloadBundleType.CALL,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
case GenericMessageType.CONFIRMATION: {
|
|
117
|
-
const {firstMessageId, moreMessageIds, type} = genericMessage[GenericMessageType.CONFIRMATION];
|
|
118
|
-
|
|
119
|
-
const content: ConfirmationContent = {firstMessageId, moreMessageIds, type};
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
...baseMessage,
|
|
123
|
-
content,
|
|
124
|
-
type: PayloadBundleType.CONFIRMATION,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
case GenericMessageType.CLEARED: {
|
|
128
|
-
const content: ClearedContent = genericMessage[GenericMessageType.CLEARED];
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
...baseMessage,
|
|
132
|
-
content,
|
|
133
|
-
type: PayloadBundleType.CONVERSATION_CLEAR,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
case GenericMessageType.DELETED: {
|
|
137
|
-
const originalMessageId = genericMessage[GenericMessageType.DELETED].messageId;
|
|
138
|
-
|
|
139
|
-
const content: DeletedContent = {messageId: originalMessageId};
|
|
140
|
-
|
|
141
|
-
return {
|
|
142
|
-
...baseMessage,
|
|
143
|
-
content,
|
|
144
|
-
type: PayloadBundleType.MESSAGE_DELETE,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
case GenericMessageType.EDITED: {
|
|
148
|
-
const {
|
|
149
|
-
expectsReadConfirmation,
|
|
150
|
-
text: {
|
|
151
|
-
content: editedText,
|
|
152
|
-
legalHoldStatus,
|
|
153
|
-
linkPreview: editedLinkPreviews,
|
|
154
|
-
mentions: editedMentions,
|
|
155
|
-
quote: editedQuote,
|
|
156
|
-
},
|
|
157
|
-
replacingMessageId,
|
|
158
|
-
} = genericMessage[GenericMessageType.EDITED];
|
|
159
|
-
|
|
160
|
-
const content: EditedTextContent = {
|
|
161
|
-
expectsReadConfirmation,
|
|
162
|
-
legalHoldStatus,
|
|
163
|
-
originalMessageId: replacingMessageId,
|
|
164
|
-
text: editedText,
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
if (editedLinkPreviews?.length) {
|
|
168
|
-
content.linkPreviews = editedLinkPreviews;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (editedMentions?.length) {
|
|
172
|
-
content.mentions = editedMentions;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (editedQuote) {
|
|
176
|
-
content.quote = editedQuote;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return {
|
|
180
|
-
...baseMessage,
|
|
181
|
-
content,
|
|
182
|
-
type: PayloadBundleType.MESSAGE_EDIT,
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
case GenericMessageType.HIDDEN: {
|
|
186
|
-
const {conversationId, messageId} = genericMessage[GenericMessageType.HIDDEN];
|
|
187
|
-
|
|
188
|
-
const content: HiddenContent = {
|
|
189
|
-
conversationId,
|
|
190
|
-
messageId,
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
return {
|
|
194
|
-
...baseMessage,
|
|
195
|
-
content,
|
|
196
|
-
type: PayloadBundleType.MESSAGE_HIDE,
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
case GenericMessageType.KNOCK: {
|
|
200
|
-
const {expectsReadConfirmation, legalHoldStatus} = genericMessage[GenericMessageType.KNOCK];
|
|
201
|
-
const content: KnockContent = {expectsReadConfirmation, hotKnock: false, legalHoldStatus};
|
|
202
|
-
|
|
203
|
-
return {
|
|
204
|
-
...baseMessage,
|
|
205
|
-
content,
|
|
206
|
-
type: PayloadBundleType.PING,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
case GenericMessageType.LOCATION: {
|
|
210
|
-
const {expectsReadConfirmation, latitude, legalHoldStatus, longitude, name, zoom} =
|
|
211
|
-
genericMessage[GenericMessageType.LOCATION];
|
|
212
|
-
|
|
213
|
-
const content: LocationContent = {
|
|
214
|
-
expectsReadConfirmation,
|
|
215
|
-
latitude,
|
|
216
|
-
legalHoldStatus,
|
|
217
|
-
longitude,
|
|
218
|
-
name,
|
|
219
|
-
zoom,
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
return {
|
|
223
|
-
...baseMessage,
|
|
224
|
-
content,
|
|
225
|
-
type: PayloadBundleType.LOCATION,
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
case GenericMessageType.ASSET: {
|
|
229
|
-
const {expectsReadConfirmation, legalHoldStatus, notUploaded, original, preview, status, uploaded} =
|
|
230
|
-
genericMessage[GenericMessageType.ASSET];
|
|
231
|
-
const isImage = !!uploaded?.assetId && !!original?.image;
|
|
232
|
-
|
|
233
|
-
const content: AssetContent = {
|
|
234
|
-
abortReason: notUploaded,
|
|
235
|
-
expectsReadConfirmation,
|
|
236
|
-
legalHoldStatus,
|
|
237
|
-
original,
|
|
238
|
-
preview,
|
|
239
|
-
status,
|
|
240
|
-
uploaded,
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
return {
|
|
244
|
-
...baseMessage,
|
|
245
|
-
content,
|
|
246
|
-
type: isImage ? PayloadBundleType.ASSET_IMAGE : PayloadBundleType.ASSET,
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
case GenericMessageType.REACTION: {
|
|
250
|
-
const {emoji, legalHoldStatus, messageId} = genericMessage[GenericMessageType.REACTION];
|
|
251
|
-
|
|
252
|
-
const content: ReactionContent = {
|
|
253
|
-
legalHoldStatus,
|
|
254
|
-
originalMessageId: messageId,
|
|
255
|
-
type: emoji,
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
return {
|
|
259
|
-
...baseMessage,
|
|
260
|
-
content,
|
|
261
|
-
type: PayloadBundleType.REACTION,
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
default: {
|
|
265
|
-
this.logger.warn(`Unhandled event type "${genericMessage.content}": ${JSON.stringify(genericMessage)}`);
|
|
266
|
-
return {
|
|
267
|
-
...baseMessage,
|
|
268
|
-
content: genericMessage.content,
|
|
269
|
-
type: PayloadBundleType.UNKNOWN,
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MessageHashService.js","sourceRoot":"","sources":["MessageHashService.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8CAAgC;AAChC,gDAAwB;AAExB,qDAAqH;AAIrH,MAAa,kBAAkB;IAI7B,YAAY,cAAuC,EAAE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,CAAC,OAAO,CAAC,EAAE;YAC9C,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;SACrC;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,yBAAyB,OAAO,EAAE,CAAC,CAAC;SACrD;QAED,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,OAAO;QACL,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;CACF;AAlFD,gDAkFC"}
|
|
@@ -1,176 +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
|
-
//@ts-check
|
|
21
|
-
|
|
22
|
-
/* eslint-disable no-magic-numbers */
|
|
23
|
-
|
|
24
|
-
const {MessageHashService} = require('@wireapp/core/src/main/cryptography/');
|
|
25
|
-
|
|
26
|
-
describe('MessageHashService', () => {
|
|
27
|
-
describe('"getHash"', () => {
|
|
28
|
-
it('correctly identifies the message type.', () => {
|
|
29
|
-
const content = {
|
|
30
|
-
text: 'Hello!',
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const messageHashService = new MessageHashService(content);
|
|
34
|
-
|
|
35
|
-
spyOn(messageHashService, 'getTextBytes').and.callThrough();
|
|
36
|
-
spyOn(messageHashService, 'getLocationBytes').and.callThrough();
|
|
37
|
-
|
|
38
|
-
messageHashService.getHash();
|
|
39
|
-
|
|
40
|
-
expect(messageHashService.getTextBytes).toHaveBeenCalled();
|
|
41
|
-
expect(messageHashService.getLocationBytes).not.toHaveBeenCalled();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('correctly creates a timestamp bytes buffer.', () => {
|
|
45
|
-
const expectedHexValue = '000000005bcdcc09';
|
|
46
|
-
const content = {
|
|
47
|
-
text: 'Hello!',
|
|
48
|
-
};
|
|
49
|
-
const timestamp = 1540213769;
|
|
50
|
-
|
|
51
|
-
const messageHashService = new MessageHashService(content, timestamp);
|
|
52
|
-
const buffer = messageHashService.getTimestampBuffer(timestamp);
|
|
53
|
-
|
|
54
|
-
const hexValue = buffer.toString('hex');
|
|
55
|
-
expect(hexValue).toBe(expectedHexValue);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('correctly creates a markdown text bytes buffer.', () => {
|
|
59
|
-
const expectedHashValue = 'f25a925d55116800e66872d2a82d8292adf1d4177195703f976bc884d32b5c94';
|
|
60
|
-
|
|
61
|
-
const content = {
|
|
62
|
-
text: 'This has **markdown**',
|
|
63
|
-
};
|
|
64
|
-
const timestamp = 1540213965000;
|
|
65
|
-
|
|
66
|
-
const messageHashService = new MessageHashService(content, timestamp);
|
|
67
|
-
|
|
68
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
69
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('correctly creates an arabic text bytes buffer.', () => {
|
|
73
|
-
const expectedHashValue = '5830012f6f14c031bf21aded5b07af6e2d02d01074f137d106d4645e4dc539ca';
|
|
74
|
-
|
|
75
|
-
const content = {
|
|
76
|
-
text: 'بغداد',
|
|
77
|
-
};
|
|
78
|
-
const timestamp = 1540213965000;
|
|
79
|
-
|
|
80
|
-
const messageHashService = new MessageHashService(content, timestamp);
|
|
81
|
-
|
|
82
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
83
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('correctly creates an emoji text bytes buffer.', () => {
|
|
87
|
-
const expectedHashValue = '4f8ee55a8b71a7eb7447301d1bd0c8429971583b15a91594b45dee16f208afd5';
|
|
88
|
-
|
|
89
|
-
const content = {
|
|
90
|
-
text: 'Hello 👩💻👨👩👧!',
|
|
91
|
-
};
|
|
92
|
-
const timestamp = 1540213769000;
|
|
93
|
-
|
|
94
|
-
const messageHashService = new MessageHashService(content, timestamp);
|
|
95
|
-
|
|
96
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
97
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('correctly creates a link text bytes buffer.', () => {
|
|
101
|
-
const expectedHashValue = 'ef39934807203191c404ebb3acba0d33ec9dce669f9acec49710d520c365b657';
|
|
102
|
-
|
|
103
|
-
const content = {
|
|
104
|
-
text: 'https://www.youtube.com/watch?v=DLzxrzFCyOs',
|
|
105
|
-
};
|
|
106
|
-
const timestamp = 1540213769000;
|
|
107
|
-
|
|
108
|
-
const messageHashService = new MessageHashService(content, timestamp);
|
|
109
|
-
|
|
110
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
111
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('correctly creates a location bytes buffer.', () => {
|
|
115
|
-
const expectedHashValue = '56a5fa30081bc16688574fdfbbe96c2eee004d1fb37dc714eec6efb340192816';
|
|
116
|
-
|
|
117
|
-
const content = {
|
|
118
|
-
latitude: 52.5166667,
|
|
119
|
-
longitude: 13.4,
|
|
120
|
-
};
|
|
121
|
-
const timestamp = 1540213769000;
|
|
122
|
-
|
|
123
|
-
const messageHashService = new MessageHashService(content, timestamp);
|
|
124
|
-
|
|
125
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
126
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('correctly creates another location bytes buffer.', () => {
|
|
130
|
-
const expectedHashValue = '803b2698104f58772dbd715ec6ee5853d835df98a4736742b2a676b2217c9499';
|
|
131
|
-
|
|
132
|
-
const content = {
|
|
133
|
-
latitude: 51.509143,
|
|
134
|
-
longitude: -0.117277,
|
|
135
|
-
};
|
|
136
|
-
const timestamp = 1540213769000;
|
|
137
|
-
|
|
138
|
-
const messageHashService = new MessageHashService(content, timestamp);
|
|
139
|
-
|
|
140
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
141
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('correctly creates an asset bytes buffer.', () => {
|
|
145
|
-
const expectedHashValue = 'bf20de149847ae999775b3cc88e5ff0c0382e9fa67b9d382b1702920b8afa1de';
|
|
146
|
-
|
|
147
|
-
const content = {
|
|
148
|
-
uploaded: {
|
|
149
|
-
assetId: '3-2-1-38d4f5b9',
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
const timestamp = 1540213769000;
|
|
153
|
-
|
|
154
|
-
const messageHashService = new MessageHashService(content, timestamp);
|
|
155
|
-
|
|
156
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
157
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('correctly creates another asset bytes buffer.', () => {
|
|
161
|
-
const expectedHashValue = '2235f5b6c00d9b0917675399d0314c8401f0525457b00aa54a38998ab93b90d6';
|
|
162
|
-
|
|
163
|
-
const content = {
|
|
164
|
-
uploaded: {
|
|
165
|
-
assetId: '3-3-3-82a62735',
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
const timestamp = 1540213965000;
|
|
169
|
-
|
|
170
|
-
const messageHashService = new MessageHashService(content, timestamp);
|
|
171
|
-
|
|
172
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
173
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Wire
|
|
4
|
-
* Copyright (C) 2018 Wire Swiss GmbH
|
|
5
|
-
*
|
|
6
|
-
* This program is free software: you can redistribute it and/or modify
|
|
7
|
-
* it under the terms of the GNU General Public License as published by
|
|
8
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
-
* (at your option) any later version.
|
|
10
|
-
*
|
|
11
|
-
* This program is distributed in the hope that it will be useful,
|
|
12
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
-
* GNU General Public License for more details.
|
|
15
|
-
*
|
|
16
|
-
* You should have received a copy of the GNU General Public License
|
|
17
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
const MessageHashService_1 = require("./MessageHashService");
|
|
22
|
-
describe('MessageHashService', () => {
|
|
23
|
-
describe('"getHash"', () => {
|
|
24
|
-
it('correctly identifies the message type.', () => {
|
|
25
|
-
const content = {
|
|
26
|
-
text: 'Hello!',
|
|
27
|
-
};
|
|
28
|
-
const messageHashService = new MessageHashService_1.MessageHashService(content);
|
|
29
|
-
spyOn(messageHashService, 'getTextBytes').and.callThrough();
|
|
30
|
-
spyOn(messageHashService, 'getLocationBytes').and.callThrough();
|
|
31
|
-
messageHashService.getHash();
|
|
32
|
-
expect(messageHashService['getTextBytes']).toHaveBeenCalled();
|
|
33
|
-
expect(messageHashService['getLocationBytes']).not.toHaveBeenCalled();
|
|
34
|
-
});
|
|
35
|
-
it('correctly creates a timestamp bytes buffer.', () => {
|
|
36
|
-
const expectedHexValue = '000000005bcdcc09';
|
|
37
|
-
const content = {
|
|
38
|
-
text: 'Hello!',
|
|
39
|
-
};
|
|
40
|
-
const timestamp = 1540213769;
|
|
41
|
-
const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
|
|
42
|
-
const buffer = messageHashService['getTimestampBuffer'](timestamp);
|
|
43
|
-
const hexValue = buffer.toString('hex');
|
|
44
|
-
expect(hexValue).toBe(expectedHexValue);
|
|
45
|
-
});
|
|
46
|
-
it('correctly creates a markdown text bytes buffer.', () => {
|
|
47
|
-
const expectedHashValue = 'f25a925d55116800e66872d2a82d8292adf1d4177195703f976bc884d32b5c94';
|
|
48
|
-
const content = {
|
|
49
|
-
text: 'This has **markdown**',
|
|
50
|
-
};
|
|
51
|
-
const timestamp = 1540213965000;
|
|
52
|
-
const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
|
|
53
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
54
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
55
|
-
});
|
|
56
|
-
it('correctly creates an arabic text bytes buffer.', () => {
|
|
57
|
-
const expectedHashValue = '5830012f6f14c031bf21aded5b07af6e2d02d01074f137d106d4645e4dc539ca';
|
|
58
|
-
const content = {
|
|
59
|
-
text: 'بغداد',
|
|
60
|
-
};
|
|
61
|
-
const timestamp = 1540213965000;
|
|
62
|
-
const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
|
|
63
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
64
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
65
|
-
});
|
|
66
|
-
it('correctly creates an emoji text bytes buffer.', () => {
|
|
67
|
-
const expectedHashValue = '4f8ee55a8b71a7eb7447301d1bd0c8429971583b15a91594b45dee16f208afd5';
|
|
68
|
-
const content = {
|
|
69
|
-
text: 'Hello 👩💻👨👩👧!',
|
|
70
|
-
};
|
|
71
|
-
const timestamp = 1540213769000;
|
|
72
|
-
const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
|
|
73
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
74
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
75
|
-
});
|
|
76
|
-
it('correctly creates a link text bytes buffer.', () => {
|
|
77
|
-
const expectedHashValue = 'ef39934807203191c404ebb3acba0d33ec9dce669f9acec49710d520c365b657';
|
|
78
|
-
const content = {
|
|
79
|
-
text: 'https://www.youtube.com/watch?v=DLzxrzFCyOs',
|
|
80
|
-
};
|
|
81
|
-
const timestamp = 1540213769000;
|
|
82
|
-
const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
|
|
83
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
84
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
85
|
-
});
|
|
86
|
-
it('correctly creates a location bytes buffer.', () => {
|
|
87
|
-
const expectedHashValue = '56a5fa30081bc16688574fdfbbe96c2eee004d1fb37dc714eec6efb340192816';
|
|
88
|
-
const content = {
|
|
89
|
-
latitude: 52.5166667,
|
|
90
|
-
longitude: 13.4,
|
|
91
|
-
};
|
|
92
|
-
const timestamp = 1540213769000;
|
|
93
|
-
const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
|
|
94
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
95
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
96
|
-
});
|
|
97
|
-
it('correctly creates another location bytes buffer.', () => {
|
|
98
|
-
const expectedHashValue = '803b2698104f58772dbd715ec6ee5853d835df98a4736742b2a676b2217c9499';
|
|
99
|
-
const content = {
|
|
100
|
-
latitude: 51.509143,
|
|
101
|
-
longitude: -0.117277,
|
|
102
|
-
};
|
|
103
|
-
const timestamp = 1540213769000;
|
|
104
|
-
const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
|
|
105
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
106
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
107
|
-
});
|
|
108
|
-
it('correctly creates an asset bytes buffer.', () => {
|
|
109
|
-
const expectedHashValue = 'bf20de149847ae999775b3cc88e5ff0c0382e9fa67b9d382b1702920b8afa1de';
|
|
110
|
-
const content = {
|
|
111
|
-
uploaded: {
|
|
112
|
-
assetId: '3-2-1-38d4f5b9',
|
|
113
|
-
otrKey: new Uint8Array(),
|
|
114
|
-
sha256: new Uint8Array(),
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
const timestamp = 1540213769000;
|
|
118
|
-
const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
|
|
119
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
120
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
121
|
-
});
|
|
122
|
-
it('correctly creates another asset bytes buffer.', () => {
|
|
123
|
-
const expectedHashValue = '2235f5b6c00d9b0917675399d0314c8401f0525457b00aa54a38998ab93b90d6';
|
|
124
|
-
const content = {
|
|
125
|
-
uploaded: {
|
|
126
|
-
assetId: '3-3-3-82a62735',
|
|
127
|
-
otrKey: new Uint8Array(),
|
|
128
|
-
sha256: new Uint8Array(),
|
|
129
|
-
},
|
|
130
|
-
};
|
|
131
|
-
const timestamp = 1540213965000;
|
|
132
|
-
const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
|
|
133
|
-
const hashValue = messageHashService.getHash().toString('hex');
|
|
134
|
-
expect(hashValue).toBe(expectedHashValue);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
//# sourceMappingURL=MessageHashService.test.node.js.map
|
|
@@ -1 +0,0 @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