@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,56 +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 client_1 = require("@wireapp/api-client/src/client");
|
|
22
|
-
const LoginSanitizer_1 = require("./LoginSanitizer");
|
|
23
|
-
describe('LoginSanitizer', () => {
|
|
24
|
-
describe('"removeNonPrintableCharacters"', () => {
|
|
25
|
-
it('sanitizes login data in-place', () => {
|
|
26
|
-
const loginData = {
|
|
27
|
-
clientType: client_1.ClientType.NONE,
|
|
28
|
-
email: 'me@wire.com\t',
|
|
29
|
-
password: '\r\nsecret',
|
|
30
|
-
};
|
|
31
|
-
LoginSanitizer_1.LoginSanitizer.removeNonPrintableCharacters(loginData);
|
|
32
|
-
expect(loginData.email).toBe('me@wire.com');
|
|
33
|
-
expect(loginData.password).toBe('\r\nsecret');
|
|
34
|
-
});
|
|
35
|
-
it('does not strip non-ASCII', () => {
|
|
36
|
-
const loginData = {
|
|
37
|
-
clientType: client_1.ClientType.NONE,
|
|
38
|
-
email: '😀中文¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨〈⟩〉◊♠♣♥♦"&<>ŒœŠšŸˆ˜–—‘’‚“”„†‡‰‹›€@wire.com',
|
|
39
|
-
password: ' 😀中文¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨〈⟩〉◊♠♣♥♦"&<>ŒœŠšŸˆ˜–—‘’‚“”„†‡‰‹›€',
|
|
40
|
-
};
|
|
41
|
-
LoginSanitizer_1.LoginSanitizer.removeNonPrintableCharacters(loginData);
|
|
42
|
-
expect(loginData.email).toBe('😀中文¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨〈⟩〉◊♠♣♥♦"&<>ŒœŠšŸˆ˜–—‘’‚“”„†‡‰‹›€@wire.com');
|
|
43
|
-
expect(loginData.password).toBe(' 😀中文¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨〈⟩〉◊♠♣♥♦"&<>ŒœŠšŸˆ˜–—‘’‚“”„†‡‰‹›€');
|
|
44
|
-
});
|
|
45
|
-
it('turns a given password into a string', () => {
|
|
46
|
-
const loginData = {
|
|
47
|
-
clientType: client_1.ClientType.NONE,
|
|
48
|
-
email: 'me@wire.com\t',
|
|
49
|
-
password: 1234567890,
|
|
50
|
-
};
|
|
51
|
-
LoginSanitizer_1.LoginSanitizer.removeNonPrintableCharacters(loginData);
|
|
52
|
-
expect(loginData.password).toEqual(jasmine.any(String));
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
//# sourceMappingURL=LoginSanitizer.test.node.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LoginSanitizer.test.node.js","sourceRoot":"","sources":["LoginSanitizer.test.node.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;AAGH,2DAA0D;AAE1D,qDAAgD;AAEhD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;QAC9C,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;YACvC,MAAM,SAAS,GAAc;gBAC3B,UAAU,EAAE,mBAAU,CAAC,IAAI;gBAC3B,KAAK,EAAE,eAAe;gBACtB,QAAQ,EAAE,YAAY;aACvB,CAAC;YAEF,+BAAc,CAAC,4BAA4B,CAAC,SAAS,CAAC,CAAC;YACvD,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC5C,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;YAClC,MAAM,SAAS,GAAc;gBAC3B,UAAU,EAAE,mBAAU,CAAC,IAAI;gBAC3B,KAAK,EACH,yQAAyQ;gBAC3Q,QAAQ,EACN,iQAAiQ;aACpQ,CAAC;YAEF,+BAAc,CAAC,4BAA4B,CAAC,SAAS,CAAC,CAAC;YACvD,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAC1B,yQAAyQ,CAC1Q,CAAC;YACF,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC7B,iQAAiQ,CAClQ,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YAC9C,MAAM,SAAS,GAAc;gBAC3B,UAAU,EAAE,mBAAU,CAAC,IAAI;gBAC3B,KAAK,EAAE,eAAe;gBACtB,QAAQ,EAAE,UAAU;aACrB,CAAC;YAEF,+BAAc,CAAC,4BAA4B,CAAC,SAAS,CAAC,CAAC;YACvD,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,68 +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 {LoginData} from '@wireapp/api-client/src/auth/';
|
|
21
|
-
import {ClientType} from '@wireapp/api-client/src/client';
|
|
22
|
-
|
|
23
|
-
import {LoginSanitizer} from './LoginSanitizer';
|
|
24
|
-
|
|
25
|
-
describe('LoginSanitizer', () => {
|
|
26
|
-
describe('"removeNonPrintableCharacters"', () => {
|
|
27
|
-
it('sanitizes login data in-place', () => {
|
|
28
|
-
const loginData: LoginData = {
|
|
29
|
-
clientType: ClientType.NONE,
|
|
30
|
-
email: 'me@wire.com\t',
|
|
31
|
-
password: '\r\nsecret',
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
LoginSanitizer.removeNonPrintableCharacters(loginData);
|
|
35
|
-
expect(loginData.email).toBe('me@wire.com');
|
|
36
|
-
expect(loginData.password).toBe('\r\nsecret');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('does not strip non-ASCII', () => {
|
|
40
|
-
const loginData: LoginData = {
|
|
41
|
-
clientType: ClientType.NONE,
|
|
42
|
-
email:
|
|
43
|
-
'😀中文¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨〈⟩〉◊♠♣♥♦"&<>ŒœŠšŸˆ˜–—‘’‚“”„†‡‰‹›€@wire.com',
|
|
44
|
-
password:
|
|
45
|
-
' 😀中文¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨〈⟩〉◊♠♣♥♦"&<>ŒœŠšŸˆ˜–—‘’‚“”„†‡‰‹›€',
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
LoginSanitizer.removeNonPrintableCharacters(loginData);
|
|
49
|
-
expect(loginData.email).toBe(
|
|
50
|
-
'😀中文¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨〈⟩〉◊♠♣♥♦"&<>ŒœŠšŸˆ˜–—‘’‚“”„†‡‰‹›€@wire.com',
|
|
51
|
-
);
|
|
52
|
-
expect(loginData.password).toBe(
|
|
53
|
-
' 😀中文¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋⟨〈⟩〉◊♠♣♥♦"&<>ŒœŠšŸˆ˜–—‘’‚“”„†‡‰‹›€',
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('turns a given password into a string', () => {
|
|
58
|
-
const loginData: LoginData = {
|
|
59
|
-
clientType: ClientType.NONE,
|
|
60
|
-
email: 'me@wire.com\t',
|
|
61
|
-
password: 1234567890,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
LoginSanitizer.removeNonPrintableCharacters(loginData);
|
|
65
|
-
expect(loginData.password).toEqual(jasmine.any(String));
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,44 +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 {LoginData} from '@wireapp/api-client/src/auth/';
|
|
21
|
-
|
|
22
|
-
export class LoginSanitizer {
|
|
23
|
-
constructor() {}
|
|
24
|
-
|
|
25
|
-
public static removeNonPrintableCharacters(loginData: LoginData): void {
|
|
26
|
-
const nonPrintableCharacters = /\s/gm;
|
|
27
|
-
|
|
28
|
-
if (loginData.email) {
|
|
29
|
-
loginData.email = loginData.email.replace(nonPrintableCharacters, '');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (loginData.handle) {
|
|
33
|
-
loginData.handle = loginData.handle.replace(nonPrintableCharacters, '');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (loginData.password) {
|
|
37
|
-
loginData.password = loginData.password.toString();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (loginData.phone) {
|
|
41
|
-
loginData.phone = loginData.phone.toString().replace(nonPrintableCharacters, '');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;AAEH,mDAAiC"}
|
package/src/main/auth/index.ts
DELETED
|
@@ -1,20 +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
|
-
export * from './LoginSanitizer';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AvailabilityType.js","sourceRoot":"","sources":["AvailabilityType.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG"}
|
|
@@ -1,22 +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 {Availability} from '@wireapp/protocol-messaging';
|
|
21
|
-
|
|
22
|
-
export type AvailabilityType = Availability.Type;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"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AAE,EAAE;YAC/D,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YAC5B,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;gBACnC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;aACvD;YACD,OAAO,SAAS,CAAC;QACnB,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;IAEM,KAAK,CAAC,uBAAuB,CAClC,cAA8B,EAC9B,aAAkC,EAClC,cAAwB;QAExB,MAAM,cAAc,GAAG,mCAAc,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,EAAE,CAAC;QACtE,OAAO,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE;YACtG,cAAc;SACf,CAAC,CAAC;IACL,CAAC;CACF;AAtCD,4CAsCC"}
|
|
@@ -1,66 +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 {APIClient} from '@wireapp/api-client';
|
|
21
|
-
import {ClientMismatch} from '@wireapp/api-client/src/conversation';
|
|
22
|
-
import type {UserPreKeyBundleMap} from '@wireapp/api-client/src/user/';
|
|
23
|
-
import {GenericMessage} from '@wireapp/protocol-messaging';
|
|
24
|
-
|
|
25
|
-
import {MessageService} from '../conversation/message/MessageService';
|
|
26
|
-
import type {CryptographyService} from '../cryptography/';
|
|
27
|
-
|
|
28
|
-
export class BroadcastService {
|
|
29
|
-
private readonly messageService: MessageService;
|
|
30
|
-
|
|
31
|
-
constructor(private readonly apiClient: APIClient, private readonly cryptographyService: CryptographyService) {
|
|
32
|
-
this.messageService = new MessageService(this.apiClient, this.cryptographyService);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public async getPreKeyBundlesFromTeam(teamId: string, skipOwnClients = false): Promise<UserPreKeyBundleMap> {
|
|
36
|
-
const {members: teamMembers} = await this.apiClient.teams.member.api.getAllMembers(teamId);
|
|
37
|
-
|
|
38
|
-
let members = teamMembers.map(member => ({id: member.user}));
|
|
39
|
-
|
|
40
|
-
if (skipOwnClients) {
|
|
41
|
-
const selfUser = await this.apiClient.self.api.getSelf();
|
|
42
|
-
members = members.filter(member => member.id !== selfUser.id);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const preKeys = await Promise.all(members.map(member => this.apiClient.user.api.getUserPreKeys(member.id)));
|
|
46
|
-
|
|
47
|
-
return preKeys.reduce<UserPreKeyBundleMap>((bundleMap, bundle) => {
|
|
48
|
-
bundleMap[bundle.user] = {};
|
|
49
|
-
for (const client of bundle.clients) {
|
|
50
|
-
bundleMap[bundle.user][client.client] = client.prekey;
|
|
51
|
-
}
|
|
52
|
-
return bundleMap;
|
|
53
|
-
}, {});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public async broadcastGenericMessage(
|
|
57
|
-
genericMessage: GenericMessage,
|
|
58
|
-
preKeyBundles: UserPreKeyBundleMap,
|
|
59
|
-
sendAsProtobuf?: boolean,
|
|
60
|
-
): Promise<ClientMismatch> {
|
|
61
|
-
const plainTextArray = GenericMessage.encode(genericMessage).finish();
|
|
62
|
-
return this.messageService.sendMessage(this.apiClient.validatedClientId, preKeyBundles, plainTextArray, {
|
|
63
|
-
sendAsProtobuf,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;AAEH,qDAAmC;AACnC,qDAAmC"}
|
|
@@ -1,21 +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
|
-
export * from './AvailabilityType';
|
|
21
|
-
export * from './BroadcastService';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClientBackendRepository.js","sourceRoot":"","sources":["ClientBackendRepository.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAKH,MAAa,uBAAuB;IAClC,YAA6B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAE9C,UAAU;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;IAChD,CAAC;IAEM,UAAU,CAAC,MAAiB;QACjC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;CACF;AAVD,0DAUC"}
|
|
@@ -1,33 +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 {APIClient} from '@wireapp/api-client';
|
|
21
|
-
import type {NewClient, RegisteredClient} from '@wireapp/api-client/src/client/';
|
|
22
|
-
|
|
23
|
-
export class ClientBackendRepository {
|
|
24
|
-
constructor(private readonly apiClient: APIClient) {}
|
|
25
|
-
|
|
26
|
-
public getClients(): Promise<RegisteredClient[]> {
|
|
27
|
-
return this.apiClient.client.api.getClients();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public postClient(client: NewClient): Promise<RegisteredClient> {
|
|
31
|
-
return this.apiClient.client.api.postClient(client);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClientDatabaseRepository.js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C,kCAAmB,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,EACjE,iBAAiB,CAClB,CAAC;QACF,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAEO,eAAe,CACrB,MAAc,EACd,MAAwB,EACxB,QAAiB,EACjB,MAAqB;QAErB,uCACK,MAAM,KACT,MAAM,EACN,IAAI,EAAE,EAAC,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,kCAAmB,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,EAAC,IAC7G;IACJ,CAAC;IAEO,oBAAoB,CAAC,MAAwB,EAAE,MAAqB;QAC1E,uCACK,MAAM,KACT,MAAM,EACN,IAAI,EAAE,EAAC,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,wBAAwB,CAAC,IAAI,CAAC,cAAc,EAAC,IACpF;IACJ,CAAC;;AAnGH,4DAoGC;AAnGwB,+BAAM,GAAG,cAAc,CAAC;AAEjC,6BAAI,GAAG;IACnB,cAAc,EAAE,gBAAgB;CACjC,CAAC"}
|
|
@@ -1,130 +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 {RegisteredClient} from '@wireapp/api-client/src/client/';
|
|
21
|
-
import type {CRUDEngine} from '@wireapp/store-engine';
|
|
22
|
-
|
|
23
|
-
import {CryptographyService} from '../cryptography/';
|
|
24
|
-
import type {MetaClient} from './ClientService';
|
|
25
|
-
|
|
26
|
-
export enum DatabaseStores {
|
|
27
|
-
CLIENTS = 'clients',
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export class ClientDatabaseRepository {
|
|
31
|
-
public static readonly STORES = DatabaseStores;
|
|
32
|
-
|
|
33
|
-
public static KEYS = {
|
|
34
|
-
LOCAL_IDENTITY: 'local_identity',
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
constructor(private readonly storeEngine: CRUDEngine) {}
|
|
38
|
-
|
|
39
|
-
public getLocalClient(): Promise<MetaClient> {
|
|
40
|
-
return this.getClient(ClientDatabaseRepository.KEYS.LOCAL_IDENTITY);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public getClient(sessionId: string): Promise<MetaClient> {
|
|
44
|
-
return this.storeEngine.read<MetaClient>(ClientDatabaseRepository.STORES.CLIENTS, sessionId);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public deleteLocalClient(): Promise<string> {
|
|
48
|
-
return this.storeEngine.delete(
|
|
49
|
-
ClientDatabaseRepository.STORES.CLIENTS,
|
|
50
|
-
ClientDatabaseRepository.KEYS.LOCAL_IDENTITY,
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public deleteClient(sessionId: string): Promise<string> {
|
|
55
|
-
return this.storeEngine.delete(ClientDatabaseRepository.STORES.CLIENTS, sessionId);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public createClientList(
|
|
59
|
-
userId: string,
|
|
60
|
-
clientList: RegisteredClient[],
|
|
61
|
-
domain: string | null,
|
|
62
|
-
): Promise<MetaClient[]> {
|
|
63
|
-
const createClientTasks: Promise<MetaClient>[] = [];
|
|
64
|
-
for (const client of clientList) {
|
|
65
|
-
createClientTasks.push(this.createClient(userId, client, domain));
|
|
66
|
-
}
|
|
67
|
-
return Promise.all(createClientTasks);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
public async createLocalClient(client: RegisteredClient, domain: string | null): Promise<MetaClient> {
|
|
71
|
-
const transformedClient = this.transformLocalClient(client, domain);
|
|
72
|
-
await this.storeEngine.create(
|
|
73
|
-
ClientDatabaseRepository.STORES.CLIENTS,
|
|
74
|
-
ClientDatabaseRepository.KEYS.LOCAL_IDENTITY,
|
|
75
|
-
transformedClient,
|
|
76
|
-
);
|
|
77
|
-
return transformedClient;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public async updateLocalClient(client: RegisteredClient, domain: string | null): Promise<MetaClient> {
|
|
81
|
-
const transformedClient = this.transformLocalClient(client, domain);
|
|
82
|
-
await this.storeEngine.update(
|
|
83
|
-
ClientDatabaseRepository.STORES.CLIENTS,
|
|
84
|
-
ClientDatabaseRepository.KEYS.LOCAL_IDENTITY,
|
|
85
|
-
transformedClient,
|
|
86
|
-
);
|
|
87
|
-
return transformedClient;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public async updateClient(userId: string, client: RegisteredClient, domain: string | null): Promise<MetaClient> {
|
|
91
|
-
const transformedClient = this.transformClient(userId, client, false, domain);
|
|
92
|
-
await this.storeEngine.update(
|
|
93
|
-
ClientDatabaseRepository.STORES.CLIENTS,
|
|
94
|
-
CryptographyService.constructSessionId(userId, client.id, domain),
|
|
95
|
-
transformedClient,
|
|
96
|
-
);
|
|
97
|
-
return transformedClient;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
public async createClient(userId: string, client: RegisteredClient, domain: string | null): Promise<MetaClient> {
|
|
101
|
-
const transformedClient = this.transformClient(userId, client, false, domain);
|
|
102
|
-
await this.storeEngine.create(
|
|
103
|
-
ClientDatabaseRepository.STORES.CLIENTS,
|
|
104
|
-
CryptographyService.constructSessionId(userId, client.id, domain),
|
|
105
|
-
transformedClient,
|
|
106
|
-
);
|
|
107
|
-
return transformedClient;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
private transformClient(
|
|
111
|
-
userId: string,
|
|
112
|
-
client: RegisteredClient,
|
|
113
|
-
verified: boolean,
|
|
114
|
-
domain: string | null,
|
|
115
|
-
): MetaClient {
|
|
116
|
-
return {
|
|
117
|
-
...client,
|
|
118
|
-
domain,
|
|
119
|
-
meta: {is_verified: verified, primary_key: CryptographyService.constructSessionId(userId, client.id, domain)},
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
private transformLocalClient(client: RegisteredClient, domain: string | null): MetaClient {
|
|
124
|
-
return {
|
|
125
|
-
...client,
|
|
126
|
-
domain,
|
|
127
|
-
meta: {is_verified: true, primary_key: ClientDatabaseRepository.KEYS.LOCAL_IDENTITY},
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClientInfo.js","sourceRoot":"","sources":["ClientInfo.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG"}
|
|
@@ -1,28 +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 {ClientClassification, Location} from '@wireapp/api-client/src/client/';
|
|
21
|
-
|
|
22
|
-
export interface ClientInfo {
|
|
23
|
-
classification: ClientClassification.DESKTOP | ClientClassification.PHONE | ClientClassification.TABLET;
|
|
24
|
-
cookieLabel: string;
|
|
25
|
-
label?: string;
|
|
26
|
-
location?: Location;
|
|
27
|
-
model: string;
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClientService.js","sourceRoot":"","sources":["ClientService.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAIH,4DAA8G;AAI9G,yBAAiF;AAUjF,MAAa,aAAa;IAIxB,YACmB,SAAoB,EACpB,WAAuB,EACvB,mBAAwC;QAFxC,cAAS,GAAT,SAAS,CAAW;QACpB,gBAAW,GAAX,WAAW,CAAY;QACvB,wBAAmB,GAAnB,mBAAmB,CAAqB;QAEzD,IAAI,CAAC,QAAQ,GAAG,IAAI,2BAAwB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC/D,IAAI,CAAC,OAAO,GAAG,IAAI,0BAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;IAEM,iBAAiB;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;IAC3C,CAAC;IAEM,UAAU;QACf,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;IACnC,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;IACxC,CAAC;IAEM,iBAAiB,CAAC,MAAwB,EAAE,MAAqB;QACtE,OAAO,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;IAEM,KAAK,CAAC,kBAAkB;QAC7B,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B,CAAC,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,gBAAgB,CAAC;YACjH,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,QAAQ,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;YACrE,OAAO,EAAE,iBAAiB;YAC1B,IAAI,EAAE,SAAS,CAAC,UAAU;SAC3B,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QACxD,MAAM,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC;QAC5E,MAAM,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,CAAC;QAE/C,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAhFD,sCAgFC"}
|
|
@@ -1,116 +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 {APIClient} from '@wireapp/api-client';
|
|
21
|
-
import type {LoginData, PreKey} from '@wireapp/api-client/src/auth/';
|
|
22
|
-
import {ClientClassification, ClientType, NewClient, RegisteredClient} from '@wireapp/api-client/src/client/';
|
|
23
|
-
import type {CRUDEngine} from '@wireapp/store-engine';
|
|
24
|
-
|
|
25
|
-
import type {CryptographyService} from '../cryptography/';
|
|
26
|
-
import {ClientInfo, ClientBackendRepository, ClientDatabaseRepository} from './';
|
|
27
|
-
|
|
28
|
-
export interface MetaClient extends RegisteredClient {
|
|
29
|
-
domain: string | null;
|
|
30
|
-
meta: {
|
|
31
|
-
is_verified?: boolean;
|
|
32
|
-
primary_key: string;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export class ClientService {
|
|
37
|
-
private readonly database: ClientDatabaseRepository;
|
|
38
|
-
private readonly backend: ClientBackendRepository;
|
|
39
|
-
|
|
40
|
-
constructor(
|
|
41
|
-
private readonly apiClient: APIClient,
|
|
42
|
-
private readonly storeEngine: CRUDEngine,
|
|
43
|
-
private readonly cryptographyService: CryptographyService,
|
|
44
|
-
) {
|
|
45
|
-
this.database = new ClientDatabaseRepository(this.storeEngine);
|
|
46
|
-
this.backend = new ClientBackendRepository(this.apiClient);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public deleteLocalClient(): Promise<string> {
|
|
50
|
-
return this.database.deleteLocalClient();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public getClients(): Promise<RegisteredClient[]> {
|
|
54
|
-
return this.backend.getClients();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public getLocalClient(): Promise<MetaClient> {
|
|
58
|
-
return this.database.getLocalClient();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
public createLocalClient(client: RegisteredClient, domain: string | null): Promise<MetaClient> {
|
|
62
|
-
return this.database.createLocalClient(client, domain);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public async synchronizeClients(): Promise<MetaClient[]> {
|
|
66
|
-
const registeredClients = await this.backend.getClients();
|
|
67
|
-
const filteredClients = registeredClients.filter(client => client.id !== this.apiClient.context!.clientId);
|
|
68
|
-
return this.database.createClientList(
|
|
69
|
-
this.apiClient.context!.userId,
|
|
70
|
-
filteredClients,
|
|
71
|
-
this.apiClient.context!.domain || null,
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// TODO: Split functionality into "create" and "register" client
|
|
76
|
-
public async register(
|
|
77
|
-
loginData: LoginData,
|
|
78
|
-
clientInfo: ClientInfo = {
|
|
79
|
-
classification: ClientClassification.DESKTOP,
|
|
80
|
-
cookieLabel: 'default',
|
|
81
|
-
model: '@wireapp/core',
|
|
82
|
-
},
|
|
83
|
-
): Promise<RegisteredClient> {
|
|
84
|
-
if (!this.apiClient.context) {
|
|
85
|
-
throw new Error('Context is not set.');
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (loginData.clientType === ClientType.NONE) {
|
|
89
|
-
throw new Error(`Can't register client of type "${ClientType.NONE}"`);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const serializedPreKeys: PreKey[] = await this.cryptographyService.createCryptobox();
|
|
93
|
-
|
|
94
|
-
if (!this.cryptographyService.cryptobox.lastResortPreKey) {
|
|
95
|
-
throw new Error('Cryptobox got initialized without a last resort PreKey.');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const newClient: NewClient = {
|
|
99
|
-
class: clientInfo.classification,
|
|
100
|
-
cookie: clientInfo.cookieLabel,
|
|
101
|
-
label: clientInfo.label,
|
|
102
|
-
lastkey: this.cryptographyService.cryptobox.serialize_prekey(this.cryptographyService.cryptobox.lastResortPreKey),
|
|
103
|
-
location: clientInfo.location,
|
|
104
|
-
model: clientInfo.model,
|
|
105
|
-
password: loginData.password ? String(loginData.password) : undefined,
|
|
106
|
-
prekeys: serializedPreKeys,
|
|
107
|
-
type: loginData.clientType,
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const client = await this.backend.postClient(newClient);
|
|
111
|
-
await this.createLocalClient(client, this.apiClient.context.domain || null);
|
|
112
|
-
await this.cryptographyService.initCryptobox();
|
|
113
|
-
|
|
114
|
-
return client;
|
|
115
|
-
}
|
|
116
|
-
}
|