@wireapp/core 17.29.0 → 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 +41 -0
- package/package.json +8 -8
- package/src/main/conversation/ConversationMapper.js +2 -0
- package/src/main/conversation/ConversationService.d.ts +5 -2
- package/src/main/conversation/ConversationService.js +0 -2
- package/src/main/conversation/message/PayloadBundle.d.ts +3 -0
- package/src/main/cryptography/GenericMessageMapper.d.ts +0 -1
- package/src/main/cryptography/GenericMessageMapper.js +23 -158
- 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 -54
- 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 -1020
- 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 -98
- 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 -364
- 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
package/src/main/Account.ts
DELETED
|
@@ -1,401 +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 {AxiosError} from 'axios';
|
|
21
|
-
import {StatusCodes as HTTP_STATUS} from 'http-status-codes';
|
|
22
|
-
import {APIClient} from '@wireapp/api-client';
|
|
23
|
-
import type {RegisterData} from '@wireapp/api-client/src/auth';
|
|
24
|
-
import {AUTH_COOKIE_KEY, AUTH_TABLE_NAME, Context, Cookie, CookieStore, LoginData} from '@wireapp/api-client/src/auth/';
|
|
25
|
-
import {ClientType, RegisteredClient} from '@wireapp/api-client/src/client/';
|
|
26
|
-
import * as Events from '@wireapp/api-client/src/event';
|
|
27
|
-
import {WebSocketClient} from '@wireapp/api-client/src/tcp/';
|
|
28
|
-
import * as cryptobox from '@wireapp/cryptobox';
|
|
29
|
-
import {CRUDEngine, MemoryEngine, error as StoreEngineError} from '@wireapp/store-engine';
|
|
30
|
-
import {EventEmitter} from 'events';
|
|
31
|
-
import logdown from 'logdown';
|
|
32
|
-
|
|
33
|
-
import {LoginSanitizer} from './auth/';
|
|
34
|
-
import {BroadcastService} from './broadcast/';
|
|
35
|
-
import {ClientInfo, ClientService} from './client/';
|
|
36
|
-
import {ConnectionService} from './connection/';
|
|
37
|
-
import {
|
|
38
|
-
AssetService,
|
|
39
|
-
ConversationService,
|
|
40
|
-
PayloadBundle,
|
|
41
|
-
PayloadBundleSource,
|
|
42
|
-
PayloadBundleType,
|
|
43
|
-
} from './conversation/';
|
|
44
|
-
import * as OtrMessage from './conversation/message/OtrMessage';
|
|
45
|
-
import * as UserMessage from './conversation/message/UserMessage';
|
|
46
|
-
import type {CoreError, NotificationError} from './CoreError';
|
|
47
|
-
import {CryptographyService} from './cryptography/';
|
|
48
|
-
import {GiphyService} from './giphy/';
|
|
49
|
-
import {NotificationHandler, NotificationService} from './notification/';
|
|
50
|
-
import {SelfService} from './self/';
|
|
51
|
-
import {TeamService} from './team/';
|
|
52
|
-
import {UserService} from './user/';
|
|
53
|
-
import {AccountService} from './account/';
|
|
54
|
-
|
|
55
|
-
enum TOPIC {
|
|
56
|
-
ERROR = 'Account.TOPIC.ERROR',
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface Account {
|
|
60
|
-
on(
|
|
61
|
-
event: PayloadBundleType.ASSET,
|
|
62
|
-
listener: (payload: OtrMessage.FileAssetMessage | OtrMessage.ImageAssetMessage) => void,
|
|
63
|
-
): this;
|
|
64
|
-
on(event: PayloadBundleType.BUTTON_ACTION, listener: (payload: OtrMessage.ButtonActionMessage) => void): this;
|
|
65
|
-
on(event: PayloadBundleType.ASSET_ABORT, listener: (payload: OtrMessage.FileAssetAbortMessage) => void): this;
|
|
66
|
-
on(event: PayloadBundleType.ASSET_IMAGE, listener: (payload: OtrMessage.ImageAssetMessage) => void): this;
|
|
67
|
-
on(event: PayloadBundleType.ASSET_META, listener: (payload: OtrMessage.FileAssetMetaDataMessage) => void): this;
|
|
68
|
-
on(event: PayloadBundleType.CALL, listener: (payload: OtrMessage.CallMessage) => void): this;
|
|
69
|
-
on(event: PayloadBundleType.CLIENT_ACTION, listener: (payload: OtrMessage.ResetSessionMessage) => void): this;
|
|
70
|
-
on(event: PayloadBundleType.CLIENT_ADD, listener: (payload: UserMessage.UserClientAddMessage) => void): this;
|
|
71
|
-
on(event: PayloadBundleType.CLIENT_REMOVE, listener: (payload: UserMessage.UserClientRemoveMessage) => void): this;
|
|
72
|
-
on(event: PayloadBundleType.CONFIRMATION, listener: (payload: OtrMessage.ConfirmationMessage) => void): this;
|
|
73
|
-
on(event: PayloadBundleType.CONNECTION_REQUEST, listener: (payload: UserMessage.UserConnectionMessage) => void): this;
|
|
74
|
-
on(event: PayloadBundleType.USER_UPDATE, listener: (payload: UserMessage.UserUpdateMessage) => void): this;
|
|
75
|
-
on(
|
|
76
|
-
event: PayloadBundleType.CONVERSATION_CLEAR,
|
|
77
|
-
listener: (payload: OtrMessage.ClearConversationMessage) => void,
|
|
78
|
-
): this;
|
|
79
|
-
on(event: PayloadBundleType.CONVERSATION_RENAME, listener: (payload: Events.ConversationRenameEvent) => void): this;
|
|
80
|
-
on(event: PayloadBundleType.LOCATION, listener: (payload: OtrMessage.LocationMessage) => void): this;
|
|
81
|
-
on(event: PayloadBundleType.MEMBER_JOIN, listener: (payload: Events.TeamMemberJoinEvent) => void): this;
|
|
82
|
-
on(event: PayloadBundleType.MESSAGE_DELETE, listener: (payload: OtrMessage.DeleteMessage) => void): this;
|
|
83
|
-
on(event: PayloadBundleType.MESSAGE_EDIT, listener: (payload: OtrMessage.EditedTextMessage) => void): this;
|
|
84
|
-
on(event: PayloadBundleType.MESSAGE_HIDE, listener: (payload: OtrMessage.HideMessage) => void): this;
|
|
85
|
-
on(event: PayloadBundleType.PING, listener: (payload: OtrMessage.PingMessage) => void): this;
|
|
86
|
-
on(event: PayloadBundleType.REACTION, listener: (payload: OtrMessage.ReactionMessage) => void): this;
|
|
87
|
-
on(event: PayloadBundleType.TEXT, listener: (payload: OtrMessage.TextMessage) => void): this;
|
|
88
|
-
on(
|
|
89
|
-
event: PayloadBundleType.TIMER_UPDATE,
|
|
90
|
-
listener: (payload: Events.ConversationMessageTimerUpdateEvent) => void,
|
|
91
|
-
): this;
|
|
92
|
-
on(event: PayloadBundleType.TYPING, listener: (payload: Events.ConversationTypingEvent) => void): this;
|
|
93
|
-
on(event: PayloadBundleType.UNKNOWN, listener: (payload: any) => void): this;
|
|
94
|
-
on(event: TOPIC.ERROR, listener: (payload: CoreError) => void): this;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export type StoreEngineProvider = (storeName: string) => Promise<CRUDEngine>;
|
|
98
|
-
|
|
99
|
-
type AccountConfig = {
|
|
100
|
-
federationDomain?: string;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export class Account extends EventEmitter {
|
|
104
|
-
private readonly apiClient: APIClient;
|
|
105
|
-
private readonly logger: logdown.Logger;
|
|
106
|
-
private readonly storeEngineProvider: StoreEngineProvider;
|
|
107
|
-
private storeEngine?: CRUDEngine;
|
|
108
|
-
|
|
109
|
-
public static readonly TOPIC = TOPIC;
|
|
110
|
-
public service?: {
|
|
111
|
-
account: AccountService;
|
|
112
|
-
asset: AssetService;
|
|
113
|
-
broadcast: BroadcastService;
|
|
114
|
-
client: ClientService;
|
|
115
|
-
connection: ConnectionService;
|
|
116
|
-
conversation: ConversationService;
|
|
117
|
-
cryptography: CryptographyService;
|
|
118
|
-
giphy: GiphyService;
|
|
119
|
-
notification: NotificationService;
|
|
120
|
-
self: SelfService;
|
|
121
|
-
team: TeamService;
|
|
122
|
-
user: UserService;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* @param apiClient The apiClient instance to use in the core (will create a new new one if undefined)
|
|
127
|
-
* @param storeEngineProvider Used to store info in the database (will create a inMemory engine if undefined)
|
|
128
|
-
* @param config.federationDomain If using a federated backend this will set the default domain for qualified ids. Do not set if using a regular backend
|
|
129
|
-
*/
|
|
130
|
-
constructor(
|
|
131
|
-
apiClient: APIClient = new APIClient(),
|
|
132
|
-
storeEngineProvider?: StoreEngineProvider,
|
|
133
|
-
private readonly config?: AccountConfig,
|
|
134
|
-
) {
|
|
135
|
-
super();
|
|
136
|
-
this.apiClient = apiClient;
|
|
137
|
-
if (storeEngineProvider) {
|
|
138
|
-
this.storeEngineProvider = storeEngineProvider;
|
|
139
|
-
} else {
|
|
140
|
-
this.storeEngineProvider = async (storeName: string) => {
|
|
141
|
-
const engine = new MemoryEngine();
|
|
142
|
-
await engine.init(storeName);
|
|
143
|
-
return engine;
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
apiClient.on(APIClient.TOPIC.COOKIE_REFRESH, async (cookie?: Cookie) => {
|
|
148
|
-
if (cookie && this.storeEngine) {
|
|
149
|
-
try {
|
|
150
|
-
await this.persistCookie(this.storeEngine, cookie);
|
|
151
|
-
} catch (error) {
|
|
152
|
-
this.logger.error(`Failed to save cookie: ${(error as Error).message}`, error);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
this.logger = logdown('@wireapp/core/Account', {
|
|
158
|
-
logger: console,
|
|
159
|
-
markdown: false,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
private persistCookie(storeEngine: CRUDEngine, cookie: Cookie): Promise<string> {
|
|
164
|
-
const entity = {expiration: cookie.expiration, zuid: cookie.zuid};
|
|
165
|
-
return storeEngine.updateOrCreate(AUTH_TABLE_NAME, AUTH_COOKIE_KEY, entity);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
get clientId(): string {
|
|
169
|
-
return this.apiClient.validatedClientId;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
get userId(): string {
|
|
173
|
-
return this.apiClient.validatedUserId;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
public async register(registration: RegisterData, clientType: ClientType): Promise<Context> {
|
|
177
|
-
const context = await this.apiClient.register(registration, clientType);
|
|
178
|
-
const storeEngine = await this.initEngine(context);
|
|
179
|
-
await this.initServices(storeEngine);
|
|
180
|
-
return context;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
public async init(clientType: ClientType, cookie?: Cookie, initializedStoreEngine?: CRUDEngine): Promise<Context> {
|
|
184
|
-
const context = await this.apiClient.init(clientType, cookie);
|
|
185
|
-
if (initializedStoreEngine) {
|
|
186
|
-
this.storeEngine = initializedStoreEngine;
|
|
187
|
-
this.logger.log(`Initialized store with existing engine "${this.storeEngine.storeName}".`);
|
|
188
|
-
} else {
|
|
189
|
-
this.storeEngine = await this.initEngine(context);
|
|
190
|
-
}
|
|
191
|
-
await this.initServices(this.storeEngine);
|
|
192
|
-
if (initializedStoreEngine) {
|
|
193
|
-
await this.initClient({
|
|
194
|
-
clientType,
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
return context;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
public async initServices(storeEngine: CRUDEngine): Promise<void> {
|
|
201
|
-
const accountService = new AccountService(this.apiClient);
|
|
202
|
-
const assetService = new AssetService(this.apiClient);
|
|
203
|
-
const cryptographyService = new CryptographyService(this.apiClient, storeEngine, this.config);
|
|
204
|
-
|
|
205
|
-
const clientService = new ClientService(this.apiClient, storeEngine, cryptographyService);
|
|
206
|
-
const connectionService = new ConnectionService(this.apiClient);
|
|
207
|
-
const giphyService = new GiphyService(this.apiClient);
|
|
208
|
-
const conversationService = new ConversationService(this.apiClient, cryptographyService, assetService);
|
|
209
|
-
const notificationService = new NotificationService(this.apiClient, cryptographyService, storeEngine);
|
|
210
|
-
const selfService = new SelfService(this.apiClient);
|
|
211
|
-
const teamService = new TeamService(this.apiClient);
|
|
212
|
-
|
|
213
|
-
const broadcastService = new BroadcastService(this.apiClient, cryptographyService);
|
|
214
|
-
const userService = new UserService(this.apiClient, broadcastService, conversationService, connectionService);
|
|
215
|
-
|
|
216
|
-
this.service = {
|
|
217
|
-
account: accountService,
|
|
218
|
-
asset: assetService,
|
|
219
|
-
broadcast: broadcastService,
|
|
220
|
-
client: clientService,
|
|
221
|
-
connection: connectionService,
|
|
222
|
-
conversation: conversationService,
|
|
223
|
-
cryptography: cryptographyService,
|
|
224
|
-
giphy: giphyService,
|
|
225
|
-
notification: notificationService,
|
|
226
|
-
self: selfService,
|
|
227
|
-
team: teamService,
|
|
228
|
-
user: userService,
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
public async login(
|
|
233
|
-
loginData: LoginData,
|
|
234
|
-
initClient: boolean = true,
|
|
235
|
-
clientInfo?: ClientInfo,
|
|
236
|
-
initializedStoreEngine?: CRUDEngine,
|
|
237
|
-
): Promise<Context> {
|
|
238
|
-
this.resetContext();
|
|
239
|
-
LoginSanitizer.removeNonPrintableCharacters(loginData);
|
|
240
|
-
|
|
241
|
-
const context = await this.apiClient.login(loginData);
|
|
242
|
-
if (initializedStoreEngine) {
|
|
243
|
-
this.storeEngine = initializedStoreEngine;
|
|
244
|
-
this.logger.log(`Initialized store with existing engine "${this.storeEngine.storeName}".`);
|
|
245
|
-
} else {
|
|
246
|
-
this.storeEngine = await this.initEngine(context);
|
|
247
|
-
}
|
|
248
|
-
await this.initServices(this.storeEngine);
|
|
249
|
-
|
|
250
|
-
if (initClient) {
|
|
251
|
-
await this.initClient(loginData, clientInfo);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return context;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
public async initClient(
|
|
258
|
-
loginData: LoginData,
|
|
259
|
-
clientInfo?: ClientInfo,
|
|
260
|
-
): Promise<{isNewClient: boolean; localClient: RegisteredClient}> {
|
|
261
|
-
if (!this.service) {
|
|
262
|
-
throw new Error('Services are not set.');
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
try {
|
|
266
|
-
const localClient = await this.loadAndValidateLocalClient();
|
|
267
|
-
return {isNewClient: false, localClient};
|
|
268
|
-
} catch (error) {
|
|
269
|
-
// There was no client so we need to "create" and "register" a client
|
|
270
|
-
const notFoundInDatabase =
|
|
271
|
-
error instanceof cryptobox.error.CryptoboxError ||
|
|
272
|
-
(error as Error).constructor.name === 'CryptoboxError' ||
|
|
273
|
-
error instanceof StoreEngineError.RecordNotFoundError ||
|
|
274
|
-
(error as Error).constructor.name === StoreEngineError.RecordNotFoundError.name;
|
|
275
|
-
const notFoundOnBackend = (error as AxiosError).response?.status === HTTP_STATUS.NOT_FOUND;
|
|
276
|
-
|
|
277
|
-
if (notFoundInDatabase) {
|
|
278
|
-
this.logger.log(`Could not find valid client in database "${this.storeEngine?.storeName}".`);
|
|
279
|
-
return this.registerClient(loginData, clientInfo);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (notFoundOnBackend) {
|
|
283
|
-
this.logger.log('Could not find valid client on backend');
|
|
284
|
-
const client = await this.service!.client.getLocalClient();
|
|
285
|
-
const shouldDeleteWholeDatabase = client.type === ClientType.TEMPORARY;
|
|
286
|
-
if (shouldDeleteWholeDatabase) {
|
|
287
|
-
this.logger.log('Last client was temporary - Deleting database');
|
|
288
|
-
|
|
289
|
-
if (this.storeEngine) {
|
|
290
|
-
await this.storeEngine.clearTables();
|
|
291
|
-
}
|
|
292
|
-
const context = await this.apiClient.init(loginData.clientType);
|
|
293
|
-
await this.initEngine(context);
|
|
294
|
-
|
|
295
|
-
return this.registerClient(loginData, clientInfo);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
this.logger.log('Last client was permanent - Deleting cryptography stores');
|
|
299
|
-
await this.service!.cryptography.deleteCryptographyStores();
|
|
300
|
-
return this.registerClient(loginData, clientInfo);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
throw error;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
public async loadAndValidateLocalClient(): Promise<RegisteredClient> {
|
|
308
|
-
await this.service!.cryptography.initCryptobox();
|
|
309
|
-
|
|
310
|
-
const loadedClient = await this.service!.client.getLocalClient();
|
|
311
|
-
await this.apiClient.client.api.getClient(loadedClient.id);
|
|
312
|
-
this.apiClient.context!.clientId = loadedClient.id;
|
|
313
|
-
|
|
314
|
-
return loadedClient;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
private async registerClient(
|
|
318
|
-
loginData: LoginData,
|
|
319
|
-
clientInfo?: ClientInfo,
|
|
320
|
-
): Promise<{isNewClient: boolean; localClient: RegisteredClient}> {
|
|
321
|
-
if (!this.service) {
|
|
322
|
-
throw new Error('Services are not set.');
|
|
323
|
-
}
|
|
324
|
-
const registeredClient = await this.service.client.register(loginData, clientInfo);
|
|
325
|
-
this.apiClient.context!.clientId = registeredClient.id;
|
|
326
|
-
this.logger.log('Client is created');
|
|
327
|
-
|
|
328
|
-
await this.service!.notification.initializeNotificationStream();
|
|
329
|
-
await this.service!.client.synchronizeClients();
|
|
330
|
-
|
|
331
|
-
return {isNewClient: true, localClient: registeredClient};
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
private resetContext(): void {
|
|
335
|
-
delete this.apiClient.context;
|
|
336
|
-
delete this.service;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
public async logout(): Promise<void> {
|
|
340
|
-
await this.apiClient.logout();
|
|
341
|
-
this.resetContext();
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
public async listen(
|
|
345
|
-
notificationHandler: NotificationHandler = this.service!.notification.handleNotification,
|
|
346
|
-
): Promise<Account> {
|
|
347
|
-
if (!this.apiClient.context) {
|
|
348
|
-
throw new Error('Context is not set - please login first');
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
this.apiClient.transport.ws.removeAllListeners(WebSocketClient.TOPIC.ON_MESSAGE);
|
|
352
|
-
this.apiClient.transport.ws.on(WebSocketClient.TOPIC.ON_MESSAGE, notification => {
|
|
353
|
-
notificationHandler(notification, PayloadBundleSource.WEBSOCKET).catch(error => {
|
|
354
|
-
this.logger.error(`Failed to handle notification ID "${notification.id}": ${error.message}`, error);
|
|
355
|
-
});
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
this.service!.notification.removeAllListeners(NotificationService.TOPIC.NOTIFICATION_ERROR);
|
|
359
|
-
this.service!.notification.on(NotificationService.TOPIC.NOTIFICATION_ERROR, this.handleError);
|
|
360
|
-
|
|
361
|
-
for (const payloadType of Object.values(PayloadBundleType)) {
|
|
362
|
-
this.service!.notification.removeAllListeners(payloadType);
|
|
363
|
-
this.service!.notification.on(payloadType as any, this.handlePayload);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
const onBeforeConnect = async () => this.service!.notification.handleNotificationStream(notificationHandler);
|
|
367
|
-
await this.apiClient.connect(onBeforeConnect);
|
|
368
|
-
return this;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
private readonly handlePayload = async (payload: PayloadBundle): Promise<void> => {
|
|
372
|
-
switch (payload.type) {
|
|
373
|
-
case PayloadBundleType.TIMER_UPDATE: {
|
|
374
|
-
const {
|
|
375
|
-
data: {message_timer},
|
|
376
|
-
conversation,
|
|
377
|
-
} = payload as unknown as Events.ConversationMessageTimerUpdateEvent;
|
|
378
|
-
const expireAfterMillis = Number(message_timer);
|
|
379
|
-
this.service!.conversation.messageTimer.setConversationLevelTimer(conversation, expireAfterMillis);
|
|
380
|
-
break;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
this.emit(payload.type, payload);
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
private readonly handleError = (accountError: NotificationError): void => {
|
|
387
|
-
this.emit(Account.TOPIC.ERROR, accountError);
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
private async initEngine(context: Context): Promise<CRUDEngine> {
|
|
391
|
-
const clientType = context.clientType === ClientType.NONE ? '' : `@${context.clientType}`;
|
|
392
|
-
const dbName = `wire@${this.apiClient.config.urls.name}@${context.userId}${clientType}`;
|
|
393
|
-
this.logger.log(`Initialising store with name "${dbName}"...`);
|
|
394
|
-
this.storeEngine = await this.storeEngineProvider(dbName);
|
|
395
|
-
const cookie = CookieStore.getCookie();
|
|
396
|
-
if (cookie) {
|
|
397
|
-
await this.persistCookie(this.storeEngine, cookie);
|
|
398
|
-
}
|
|
399
|
-
return this.storeEngine;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CoreError.js","sourceRoot":"","sources":["CoreError.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAIH,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,gEAAmD,CAAA;AACrD,CAAC,EAFW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAEpB"}
|
package/src/main/CoreError.ts
DELETED
|
@@ -1,30 +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 {Notification} from '@wireapp/api-client/src/notification';
|
|
21
|
-
|
|
22
|
-
export enum CoreError {
|
|
23
|
-
NOTIFICATION_ERROR = 'CoreError.NOTIFICATION_ERROR',
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface NotificationError {
|
|
27
|
-
error: Error;
|
|
28
|
-
notification: Notification;
|
|
29
|
-
type: CoreError.NOTIFICATION_ERROR;
|
|
30
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LoginSanitizer.js","sourceRoot":"","sources":["LoginSanitizer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAIH,MAAa,cAAc;IACzB,gBAAe,CAAC;IAET,MAAM,CAAC,4BAA4B,CAAC,SAAoB;QAC7D,MAAM,sBAAsB,GAAG,MAAM,CAAC;QAEtC,IAAI,SAAS,CAAC,KAAK,EAAE;YACnB,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;SACvE;QAED,IAAI,SAAS,CAAC,MAAM,EAAE;YACpB,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;SACzE;QAED,IAAI,SAAS,CAAC,QAAQ,EAAE;YACtB,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;SACpD;QAED,IAAI,SAAS,CAAC,KAAK,EAAE;YACnB,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;SAClF;IACH,CAAC;CACF;AAtBD,wCAsBC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -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;
|