@@ -104,148 +104,6 @@ public final class SharingSession {
104104 return featureRepository. fetchFileSharing ( )
105105 }
106106
107- /// Initializes a new `SessionDirectory` to be used in an extension environment
108- /// - parameter databaseDirectory: The `NSURL` of the shared group container
109- /// - throws: `InitializationError.NeedsMigration` in case the local store needs to be
110- /// migrated, which is currently only supported in the main application or `InitializationError.LoggedOut` if
111- /// no user is currently logged in.
112- /// - returns: The initialized session object if no error is thrown
113-
114- @MainActor
115- public convenience init (
116- applicationGroupIdentifier: String ,
117- accountIdentifier: UUID ,
118- hostBundleIdentifier: String ,
119- environment: LegacyBackendEnvironment ,
120- appLockConfig: AppLockController . LegacyConfig ? ,
121- sharedUserDefaults: UserDefaults ,
122- minTLSVersion: String ? ,
123- currentBuildNumber: String ,
124- localDomain: String ? ,
125- isFederationEnabled: Bool
126- ) async throws {
127-
128- let sharedContainerURL = FileManager . sharedContainerDirectory ( for: applicationGroupIdentifier)
129-
130- let coreDataStack = CoreDataStack (
131- account: Account ( userName: " " , userIdentifier: accountIdentifier) ,
132- applicationContainer: sharedContainerURL,
133- localDomain: localDomain,
134- isFederationEnabled: isFederationEnabled
135- )
136-
137- guard coreDataStack. storesExists else {
138- throw InitializationError . missingSharedContainer
139- }
140-
141- guard !coreDataStack. needsMigration else {
142- throw InitializationError . needsMigration
143- }
144-
145- try await coreDataStack. load ( )
146-
147- // Don't cache the cookie because if the user logs out and back in again in the main app
148- // process, then the cached cookie will be invalid.
149- let cookieStorage = ZMPersistentCookieStorage (
150- forServerName: environment. backendURL. host!,
151- userIdentifier: accountIdentifier,
152- useCache: false
153- )
154-
155- let credentials = environment. proxy. flatMap { ProxyCredentials . retrieve ( for: $0) }
156-
157- let selfClientID = coreDataStack. syncContext. performAndWait {
158- ZMUser . selfUser ( in: coreDataStack. syncContext) . selfClient ( ) ? . remoteIdentifier
159- }
160-
161- let transportSession = ZMTransportSession (
162- environment: environment,
163- proxyUsername: credentials? . username,
164- proxyPassword: credentials? . password,
165- cookieStorage: cookieStorage,
166- reachability: environment. reachability,
167- initialAccessToken: nil ,
168- applicationGroupIdentifier: applicationGroupIdentifier,
169- applicationVersion: " 1.0.0 " ,
170- minTLSVersion: minTLSVersion,
171- selfClientID: selfClientID,
172- // This flag only concerns the push channel which isn't relevant
173- // in the sharing session.
174- isSyncV2Enabled: false
175- )
176-
177- let proxySettings : WireNetwork . ProxySettings ? = {
178- guard let proxy = environment. proxy else { return nil }
179-
180- if proxy. needsAuthentication {
181- guard
182- let proxyUsername = credentials? . username,
183- let proxyPassword = credentials? . password else {
184- fatalInternal ( " Proxy needs authentication but credentials are missing " )
185- return nil
186- }
187-
188- return . authenticated(
189- host: proxy. host,
190- port: proxy. port,
191- username: proxyUsername,
192- password: proxyPassword
193- )
194- } else {
195- return . unauthenticated( host: proxy. host, port: proxy. port)
196- }
197- } ( )
198-
199- let wireAPIBackendEnvironment = BackendEnvironment (
200- url: environment. backendURL,
201- webSocketURL: environment. backendWSURL,
202- blacklistURL: environment. blackListURL,
203- pinnedKeys: environment. trustData. map { trustData in
204- PinnedKey (
205- key: trustData. certificateKey,
206- rawKey: trustData. rawCertificateKey,
207- hosts: trustData. hosts. map { host in
208- switch host. rule {
209- case . equals:
210- . equals( host. value)
211- case . endsWith:
212- . endsWith( host. value)
213- }
214- }
215- )
216- } ,
217- proxySettings: proxySettings
218- )
219-
220- guard let apiVersion = BackendInfo . apiVersion,
221- let wireAPIVersion = WireNetwork . APIVersion ( rawValue: UInt ( apiVersion. rawValue) ) else {
222- fatal ( " cannot resolve api version " )
223-
224- }
225-
226- try await self . init (
227- accountIdentifier: accountIdentifier,
228- selfClientID: selfClientID!,
229- coreDataStack: coreDataStack,
230- transportSession: transportSession,
231- cachesDirectory: FileManager . default. cachesURLForAccount ( with: accountIdentifier, in: sharedContainerURL) ,
232- accountContainer: CoreDataStack . accountDataFolder (
233- accountIdentifier: accountIdentifier,
234- applicationContainer: sharedContainerURL
235- ) ,
236- appLockConfig: appLockConfig,
237- wireAPIBackendEnvironment: wireAPIBackendEnvironment,
238- minTLSVersion: . minVersionFrom( minTLSVersion) ,
239- apiVersion: wireAPIVersion,
240- sharedUserDefaults: sharedUserDefaults,
241- sharedContainerURL: URL ( " unused " ) !,
242- legacyEnvironment: environment,
243- proxyCredentials: credentials,
244- currentBuildNumber: currentBuildNumber,
245- localDomain: localDomain
246- )
247- }
248-
249107 @MainActor
250108 init (
251109 accountIdentifier: UUID ,
@@ -423,7 +281,7 @@ public final class SharingSession {
423281 }
424282
425283 let networkStack = NetworkStack (
426- backendEnvironment: BackendEnvironment2 ( legacyEnvironment) ,
284+ backendEnvironment: WireNetwork . BackendEnvironment ( legacyEnvironment) ,
427285 minTLSVersion: minTLSVersion,
428286 preferredAPIVersion: preferredAPIVersion,
429287 proxyCredentials: proxyCredentials
0 commit comments