Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions BuildTools/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BuildTools/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let package = Package(
name: "BuildTools",
platforms: [.macOS(.v10_11)],
dependencies: [
.package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.49.4"),
.package(url: "https://github.com/nicklockwood/SwiftFormat", .exact("0.49.5")),
],
targets: [.target(name: "BuildTools", path: "")]
)
10 changes: 9 additions & 1 deletion FlowCrypt.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
5133B6702716320F00C95463 /* ContactKeyDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5133B66F2716320F00C95463 /* ContactKeyDetailViewController.swift */; };
5133B6722716321F00C95463 /* ContactKeyDetailDecorator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5133B6712716321F00C95463 /* ContactKeyDetailDecorator.swift */; };
5133B6742716E5EA00C95463 /* LabelCellNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5133B6732716E5EA00C95463 /* LabelCellNode.swift */; };
5137CB1427F8E0A900AEF895 /* EnterpriseServerApiHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5137CB1327F8E0A900AEF895 /* EnterpriseServerApiHelper.swift */; };
514C34DB276CE19C00FCAB79 /* ComposeMessageContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514C34DA276CE19C00FCAB79 /* ComposeMessageContext.swift */; };
514C34DD276CE1C000FCAB79 /* ComposeMessageRecipient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514C34DC276CE1C000FCAB79 /* ComposeMessageRecipient.swift */; };
514C34DF276CE20700FCAB79 /* ComposeMessageService+State.swift in Sources */ = {isa = PBXBuildFile; fileRef = 514C34DE276CE20700FCAB79 /* ComposeMessageService+State.swift */; };
Expand All @@ -93,6 +94,7 @@
51B0C774272AB61000124663 /* StringTestExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51B0C773272AB61000124663 /* StringTestExtension.swift */; };
51B4AE51271444580001F33B /* PubKeyRealmObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51B4AE50271444580001F33B /* PubKeyRealmObject.swift */; };
51B4AE5327144E590001F33B /* PubKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51B4AE5227144E590001F33B /* PubKey.swift */; };
51B7421B27F318D300E702C8 /* XCTestCaseExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51B7421A27F318D300E702C8 /* XCTestCaseExtension.swift */; };
51B9EE6F27567B520080B2D5 /* MessageRecipientsNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51B9EE6E27567B520080B2D5 /* MessageRecipientsNode.swift */; };
51C0C1EF271982A1000C9738 /* MailCore in Frameworks */ = {isa = PBXBuildFile; productRef = 51C0C1EE271982A1000C9738 /* MailCore */; };
51DA5BD62721AB07001C4359 /* PubKeyState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51DA5BD52721AB07001C4359 /* PubKeyState.swift */; };
Expand Down Expand Up @@ -516,6 +518,7 @@
5133B66F2716320F00C95463 /* ContactKeyDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactKeyDetailViewController.swift; sourceTree = "<group>"; };
5133B6712716321F00C95463 /* ContactKeyDetailDecorator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactKeyDetailDecorator.swift; sourceTree = "<group>"; };
5133B6732716E5EA00C95463 /* LabelCellNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelCellNode.swift; sourceTree = "<group>"; };
5137CB1327F8E0A900AEF895 /* EnterpriseServerApiHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnterpriseServerApiHelper.swift; sourceTree = "<group>"; };
514C34DA276CE19C00FCAB79 /* ComposeMessageContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeMessageContext.swift; sourceTree = "<group>"; };
514C34DC276CE1C000FCAB79 /* ComposeMessageRecipient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeMessageRecipient.swift; sourceTree = "<group>"; };
514C34DE276CE20700FCAB79 /* ComposeMessageService+State.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ComposeMessageService+State.swift"; sourceTree = "<group>"; };
Expand All @@ -536,6 +539,7 @@
51B0C773272AB61000124663 /* StringTestExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringTestExtension.swift; sourceTree = "<group>"; };
51B4AE50271444580001F33B /* PubKeyRealmObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PubKeyRealmObject.swift; sourceTree = "<group>"; };
51B4AE5227144E590001F33B /* PubKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PubKey.swift; sourceTree = "<group>"; };
51B7421A27F318D300E702C8 /* XCTestCaseExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XCTestCaseExtension.swift; sourceTree = "<group>"; };
51B9EE6E27567B520080B2D5 /* MessageRecipientsNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageRecipientsNode.swift; sourceTree = "<group>"; };
51DA5BD52721AB07001C4359 /* PubKeyState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PubKeyState.swift; sourceTree = "<group>"; };
51DA5BD92722C82E001C4359 /* RecipientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecipientTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1080,6 +1084,7 @@
isa = PBXGroup;
children = (
51B0C773272AB61000124663 /* StringTestExtension.swift */,
51B7421A27F318D300E702C8 /* XCTestCaseExtension.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -1684,6 +1689,7 @@
children = (
32DCAC9C0512037018F434A1 /* BackendApi.swift */,
21C7DF08266C0D8F00C44800 /* EnterpriseServerApi.swift */,
5137CB1327F8E0A900AEF895 /* EnterpriseServerApiHelper.swift */,
517C2E312779F91300FECF32 /* Models */,
);
path = "Account Server Services";
Expand Down Expand Up @@ -2531,7 +2537,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cd BuildTools\nSDKROOT=(xcrun --sdk macosx --show-sdk-path)\n#swift package update \n#Uncomment this line temporarily to update the version used to the latest matching your BuildTools/Package.swift file\nswift run -c release swiftformat \"$SRCROOT\" --exclude appium,fastlane,Pods,vendor\n";
shellScript = "cd BuildTools\nSDKROOT=(xcrun --sdk macosx --show-sdk-path)\n# swift package update\n#Uncomment this line temporarily to update the version used to the latest matching your BuildTools/Package.swift file\nswift run -c release swiftformat \"$SRCROOT\" --exclude appium,fastlane,Pods,vendor\n";
};
E531C3B50A9C90454C72F878 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -2591,6 +2597,7 @@
A36108E9273C7A2E00A90E34 /* MockError.swift in Sources */,
2C03CC16275BB53400887EEB /* EnterpriseServerApiTests.swift in Sources */,
9F7E8EC6269877E70021C07F /* KeyInfoTests.swift in Sources */,
51B7421B27F318D300E702C8 /* XCTestCaseExtension.swift in Sources */,
9F5F504326FA6C7500294FA2 /* EnterpriseServerApiMock.swift in Sources */,
51DA5BDA2722C82E001C4359 /* RecipientTests.swift in Sources */,
9FC41171268118A7004C0A69 /* PassPhraseStorageTests.swift in Sources */,
Expand Down Expand Up @@ -2805,6 +2812,7 @@
9F2AC5B1267BDED100F6149B /* GmailSearchExpressionGenerator.swift in Sources */,
040FDF1227EDFC5C00CB936A /* IdTokenUtils.swift in Sources */,
9F953E09238310D500AEB98B /* KeyMethods.swift in Sources */,
5137CB1427F8E0A900AEF895 /* EnterpriseServerApiHelper.swift in Sources */,
9F92EE72236F165E009BE0D7 /* EncryptedStorage.swift in Sources */,
32DCA00224982EDA88D69C6E /* AppErr.swift in Sources */,
9F6EE17B2598F9FA0059BA51 /* Gmail+Backup.swift in Sources */,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions FlowCrypt/App/AppContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,25 @@ class AppContext {
let userAccountService: SessionServiceType
let keyService: KeyServiceType
let passPhraseService: PassPhraseServiceType
let clientConfigurationService: ClientConfigurationServiceType

init(
encryptedStorage: EncryptedStorageType,
session: SessionType?,
userAccountService: SessionServiceType,
keyService: KeyServiceType,
passPhraseService: PassPhraseServiceType,
clientConfigurationService: ClientConfigurationServiceType,
globalRouter: GlobalRouterType
) {
self.encryptedStorage = encryptedStorage
self.session = session
self.userAccountService = userAccountService
self.keyService = keyService
self.passPhraseService = passPhraseService
self.clientConfigurationService = clientConfigurationService
self.globalRouter = globalRouter
}

@MainActor
static func setUpAppContext(globalRouter: GlobalRouterType) throws -> AppContext {
static func setup(globalRouter: GlobalRouterType) throws -> AppContext {
let keyChainService = KeyChainService()
let encryptedStorage = EncryptedStorage(
storageEncryptionKey: try keyChainService.getStorageEncryptionKey()
Expand All @@ -49,11 +46,6 @@ class AppContext {
storage: encryptedStorage,
passPhraseService: passPhraseService
)
let clientConfigurationService = ClientConfigurationService(
local: LocalClientConfiguration(
encryptedStorage: encryptedStorage
)
)
return AppContext(
encryptedStorage: encryptedStorage,
session: nil, // will be set later. But would be nice to already set here, if available
Expand All @@ -66,19 +58,17 @@ class AppContext {
),
keyService: keyService,
passPhraseService: passPhraseService,
clientConfigurationService: clientConfigurationService,
globalRouter: globalRouter
)
}

func withSession(session: SessionType?, authType: AuthType, user: User) -> AppContextWithUser {
return AppContextWithUser(
func with(session: SessionType?, authType: AuthType, user: User) async throws -> AppContextWithUser {
return try await AppContextWithUser(
encryptedStorage: encryptedStorage,
session: session,
userAccountService: userAccountService,
keyService: keyService,
passPhraseService: passPhraseService,
clientConfigurationService: clientConfigurationService,
globalRouter: globalRouter,
authType: authType,
user: user
Expand Down Expand Up @@ -131,28 +121,38 @@ class AppContextWithUser: AppContext {
let user: User
let userId: UserId

let enterpriseServer: EnterpriseServerApiType
let clientConfigurationService: ClientConfigurationServiceType

init(
encryptedStorage: EncryptedStorageType,
session: SessionType?,
userAccountService: SessionServiceType,
keyService: KeyServiceType,
passPhraseService: PassPhraseServiceType,
clientConfigurationService: ClientConfigurationServiceType,
globalRouter: GlobalRouterType,
authType: AuthType,
user: User
) {
) async throws {
self.authType = authType
self.user = user
self.userId = UserId(email: user.email, name: user.name)
self.enterpriseServer = try await EnterpriseServerApi(email: user.email)
self.clientConfigurationService = ClientConfigurationService(
server: enterpriseServer,
local: LocalClientConfiguration(
encryptedStorage: encryptedStorage
)
)

_ = try await self.clientConfigurationService.fetch(for: user)

super.init(
encryptedStorage: encryptedStorage,
session: session,
userAccountService: userAccountService,
keyService: keyService,
passPhraseService: passPhraseService,
clientConfigurationService: clientConfigurationService,
globalRouter: globalRouter
)
}
Expand Down
6 changes: 5 additions & 1 deletion FlowCrypt/Controllers/Compose/ComposeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,16 @@ final class ComposeViewController: TableNodeViewController {
encryptedStorage: appContext.encryptedStorage,
messageGateway: appContext.getRequiredMailProvider().messageSender,
passPhraseService: appContext.passPhraseService,
enterpriseServer: appContext.enterpriseServer,
sender: appContext.user.email
)
self.filesManager = filesManager
self.photosManager = photosManager
self.keyMethods = keyMethods
self.pubLookup = PubLookup(clientConfiguration: clientConfiguration, localContactsProvider: self.localContactsProvider)
self.pubLookup = PubLookup(
clientConfiguration: clientConfiguration,
localContactsProvider: self.localContactsProvider
)
self.router = appContext.globalRouter
self.contextToSend.subject = input.subject
self.contextToSend.attachments = input.attachments
Expand Down
10 changes: 6 additions & 4 deletions FlowCrypt/Controllers/Setup/SetupBackupsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,12 @@ extension SetupBackupsViewController {
}

func handleBackButtonTap() {
do {
try appContext.globalRouter.signOut(appContext: appContext)
} catch {
showAlert(message: error.localizedDescription)
Task {
do {
try await appContext.globalRouter.signOut(appContext: appContext)
} catch {
showAlert(message: error.localizedDescription)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ class SetupCreatePassphraseAbstractViewController: TableNodeViewController, Pass
}

func handleBackButtonTap() {
do {
try appContext.globalRouter.signOut(appContext: self.appContext)
} catch {
showAlert(message: error.localizedDescription)
Task {
do {
try await appContext.globalRouter.signOut(appContext: self.appContext)
} catch {
showAlert(message: error.localizedDescription)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final class SetupGenerateKeyViewController: SetupCreatePassphraseAbstractViewCon

try await submitKeyToAttester(user: appContext.user, publicKey: encryptedPrv.key.public)
try await appContext.getBackupService().backupToInbox(keys: [encryptedPrv.key], for: appContext.userId)
try await putKeypairsInEncryptedStorage(encryptedPrv: encryptedPrv, storageMethod: storageMethod, passPhrase: passPhrase)
try putKeypairsInEncryptedStorage(encryptedPrv: encryptedPrv, storageMethod: storageMethod, passPhrase: passPhrase)

if storageMethod == .memory {
let passPhrase = PassPhrase(
Expand Down
10 changes: 6 additions & 4 deletions FlowCrypt/Controllers/Setup/SetupInitialViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,12 @@ extension SetupInitialViewController {
}

private func signOut() {
do {
try appContext.globalRouter.signOut(appContext: appContext)
} catch {
showAlert(message: error.localizedDescription)
Task {
do {
try await appContext.globalRouter.signOut(appContext: appContext)
} catch {
showAlert(message: error.localizedDescription)
}
}
}

Expand Down
20 changes: 12 additions & 8 deletions FlowCrypt/Controllers/SideMenu/Menu/MyMenuViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,12 @@ extension MyMenuViewController {
return
}

do {
try appContext.globalRouter.switchActive(user: account, appContext: appContext)
} catch {
showAlert(message: error.localizedDescription)
Task {
do {
try await appContext.globalRouter.switchActive(user: account, appContext: appContext)
} catch {
showAlert(message: error.localizedDescription)
}
}
}
}
Expand Down Expand Up @@ -309,10 +311,12 @@ extension MyMenuViewController {
showAlert(message: error.localizedDescription)
}
case .logOut:
do {
try appContext.globalRouter.signOut(appContext: appContext)
} catch {
showAlert(message: error.localizedDescription)
Task {
do {
try await appContext.globalRouter.signOut(appContext: appContext)
} catch {
showAlert(message: error.localizedDescription)
}
}
}
}
Expand Down
Loading