-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathUserSession.swift
291 lines (186 loc) · 8.9 KB
/
UserSession.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
//
// Wire
// Copyright (C) 2025 Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
import Foundation
import LocalAuthentication
import WireAnalytics
import WireDataModel
/// An abstraction of the user session for use in the presentation
/// layer.
public protocol UserSession: AnyObject {
// MARK: - Mixed properties and methods
// swiftlint:disable:next todo_requires_jira_link
// TODO: structure mixed methods and properties in sections
var userProfile: UserProfile { get }
/// The current session lock, if any.
var lock: SessionLock? { get }
/// Whether the session needs to be unlocked by the user
/// via passcode or biometric authentication.
var isLocked: Bool { get }
/// Whether the screen curtain is required.
///
/// The screen curtain hides the contents of the app while it is
/// not active, such as when it is in the task switcher.
var requiresScreenCurtain: Bool { get }
/// Whether the app lock on.
var isAppLockActive: Bool { get set }
/// Whether the app lock feature is availble to the user.
var isAppLockAvailable: Bool { get }
/// Whether the app lock is mandatorily active.
var isAppLockForced: Bool { get }
/// The maximum number of seconds allowed in the background before the
/// authentication is required.
var appLockTimeout: UInt { get }
/// Whether a custom passcode has been set.
var isCustomAppLockPasscodeSet: Bool { get }
/// Whether a custom passcode (rather a device passcode) should be used.
var requireCustomAppLockPasscode: Bool { get }
/// Whether the user should be notified of the app lock being disabled.
var shouldNotifyUserOfDisabledAppLock: Bool { get }
/// Whether the user needs to be informed about configuration changes.
var needsToNotifyUserOfAppLockConfiguration: Bool { get set }
/// This property will be set or cleared depending on the user giving or removing consent for analytics tracking.
var analyticsEventTracker: AnalyticsEventTracker? { get }
/// Unlocks the database.
func unlockDatabase() throws
/// Open the app lock.
func openAppLock() throws
/// Authenticate with device owner credentials (biometrics or passcode).
///
/// - Parameters:
/// - passcodePreference: Used to determine which type of passcode is used.
/// - description: The message to dispaly in the authentication UI.
/// - callback: Invoked with the authentication result.
func evaluateAppLockAuthentication(
passcodePreference: AppLockPasscodePreference,
description: String,
callback: @escaping (AppLockAuthenticationResult) -> Void
)
/// Authenticate with a custom passcode.
///
/// - Parameter customPasscode: The user inputted passcode.
/// - Returns: The authentication result, which should be either `granted` or `denied`.
func evaluateAuthentication(customPasscode: String) -> AppLockAuthenticationResult
/// Delete the app lock passcode if it exists.
func deleteAppLockPasscode() throws
var conversationDirectory: ConversationDirectoryType { get }
/// The user who is logged into this session.
///
/// This can only be used on the main thread.
var selfUser: any UserType { get }
var selfUserLegalHoldSubject: any SelfUserLegalHoldable { get }
var editableSelfUser: any UserType & EditableUserType { get }
func perform(_ changes: @escaping () -> Void)
func enqueue(_ changes: @escaping () -> Void)
func enqueue(
_ changes: @escaping () -> Void,
completionHandler: (() -> Void)?
)
// swiftlint:disable todo_requires_jira_link
// TODO: rename to "shouldHideNotificationContent"
var isNotificationContentHidden: Bool { get set }
// TODO: rename to "isEncryptionAtRestEnabled"
// swiftlint:enable todo_requires_jira_link
var encryptMessagesAtRest: Bool { get }
func setEncryptionAtRest(enabled: Bool, skipMigration: Bool) throws
func addUserObserver(
_ observer: UserObserving,
for user: UserType
) -> NSObjectProtocol?
func addUserObserver(
_ observer: UserObserving
) -> NSObjectProtocol
func addMessageObserver(
_ observer: ZMMessageObserver,
for message: ZMConversationMessage
) -> NSObjectProtocol
func addConferenceCallingUnavailableObserver(
_ observer: ConferenceCallingUnavailableObserver
) -> Any
func addConferenceCallStateObserver(
_ observer: WireCallCenterCallStateObserver
) -> Any
func addConferenceCallErrorObserver(
_ observer: WireCallCenterCallErrorObserver
) -> Any
func addConversationListObserver(
_ observer: ZMConversationListObserver,
for list: ConversationList
) -> NSObjectProtocol
func conversationList() -> ConversationList
func pendingConnectionConversationsInUserSession() -> ConversationList
func archivedConversationsInUserSession() -> ConversationList
var ringingCallConversation: ZMConversation? { get }
var maxAudioMessageLength: TimeInterval { get }
var maxUploadFileSize: UInt64 { get }
func acknowledgeFeatureChange(for feature: Feature.Name)
func classification(
users: [UserType],
conversationDomain: String?
) -> SecurityClassification?
var maxVideoLength: TimeInterval { get }
func proxiedRequest(
path: String,
method: ZMTransportRequestMethod,
type: ProxiedRequestType,
callback: ProxyRequestCallback?
) -> ProxyRequest
func cancelProxiedRequest(_ request: ProxyRequest)
var networkState: NetworkState { get }
var selfUserClient: UserClient? { get }
var e2eiFeature: Feature.E2EI { get }
var mlsFeature: Feature.MLS { get }
func fetchAllClients()
func createTeamOneOnOne(
with user: UserType,
completion: @escaping (Swift.Result<ZMConversation, CreateTeamOneOnOneConversationError>) -> Void
)
// MARK: MLS
var mlsGroupVerification: (any MLSGroupVerificationProtocol)? { get }
// MARK: Notifications
/// Provides a unique context to bind notifications this user session.
var notificationContext: any NotificationContext { get }
// MARK: Context provider
var contextProvider: any ContextProvider { get }
// MARK: Use Cases
var getUserClientFingerprint: GetUserClientFingerprintUseCaseProtocol { get }
var isUserE2EICertifiedUseCase: IsUserE2EICertifiedUseCaseProtocol { get }
var isSelfUserE2EICertifiedUseCase: IsSelfUserE2EICertifiedUseCaseProtocol { get }
var getIsE2eIdentityEnabled: GetIsE2EIdentityEnabledUseCaseProtocol { get }
var getE2eIdentityCertificates: GetE2eIdentityCertificatesUseCaseProtocol { get }
var enrollE2EICertificate: EnrollE2EICertificateUseCaseProtocol { get }
var checkOneOnOneConversationIsReady: CheckOneOnOneConversationIsReadyUseCaseProtocol { get }
var lastE2EIUpdateDateRepository: LastE2EIdentityUpdateDateRepositoryInterface? { get }
func makeGetMLSFeatureUseCase() -> GetMLSFeatureUseCaseProtocol
func makeConversationSecureGuestLinkUseCase() -> CreateConversationGuestLinkUseCaseProtocol
func makeSetConversationGuestsAndServicesUseCase() -> SetAllowGuestAndServicesUseCaseProtocol
func makeAppendTextMessageUseCase() -> any AppendTextMessageUseCaseProtocol
func makeAppendImageMessageUseCase() -> any AppendImageMessageUseCaseProtocol
func makeAppendKnockMessageUseCase() -> any AppendKnockMessageUseCaseProtocol
func makeAppendLocationMessageUseCase() -> any AppendLocationMessagekUseCaseProtocol
func makeAppendFileMessageUseCase() -> any AppendFileMessageUseCaseProtocol
func makeToggleMessageReactionUseCase() -> any ToggleMessageReactionUseCaseProtocol
func makeCallQualitySurveyUseCase() -> any SubmitCallQualitySurveyUseCaseProtocol
func makeConversationFolderSelectionUseCase() -> UpdateConversationFolderUseCase
func makeConversationFolderCreationUseCase() -> CreateConversationFolderUseCase
func makeSearchUsersUseCase() -> SearchUsersUseCaseProtocol
func fetchSelfConversationMLSGroupID() async -> MLSGroupID?
func e2eIdentityUpdateCertificateUpdateStatus() -> E2EIdentityCertificateUpdateStatusUseCaseProtocol?
// MARK: - Dependency Injection
/// Cache for search users.
var searchUsersCache: SearchUsersCache { get }
}