From cf7c702f38bbcc7f3451d3c1446a89a4e782237e Mon Sep 17 00:00:00 2001 From: Krisjanis Gaidis Date: Tue, 22 Nov 2022 11:40:31 -0500 Subject: [PATCH] Financial Connections: renamed instances of AuthorizationSession to AuthSession. --- .../project.pbxproj | 12 ++-- .../FinancialConnectionsAPIClient.swift | 50 ++++++++--------- ... => FinancialConnectionsAuthSession.swift} | 2 +- .../FinancialConnectionsPartnerAccount.swift | 2 +- .../FinancialConnectionsSessionManifest.swift | 2 +- .../AccountPickerDataSource.swift | 24 ++++---- .../AccountPickerViewController.swift | 10 ++-- .../Source/Native/NativeFlowController.swift | 10 ++-- .../Source/Native/NativeFlowDataManager.swift | 6 +- .../PartnerAuth/PartnerAuthDataSource.swift | 16 +++--- .../PartnerAuthViewController.swift | 56 +++++++++---------- .../AccountFetcherTests.swift | 20 +++---- .../FinancialConnectionsSheetTests.swift | 20 +++---- .../SessionFetcherTests.swift | 20 +++---- 14 files changed, 125 insertions(+), 125 deletions(-) rename StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/{FinancialConnectionsAuthorizationSession.swift => FinancialConnectionsAuthSession.swift} (98%) diff --git a/StripeFinancialConnections/StripeFinancialConnections.xcodeproj/project.pbxproj b/StripeFinancialConnections/StripeFinancialConnections.xcodeproj/project.pbxproj index c61760dfe59..c426f9fc45a 100644 --- a/StripeFinancialConnections/StripeFinancialConnections.xcodeproj/project.pbxproj +++ b/StripeFinancialConnections/StripeFinancialConnections.xcodeproj/project.pbxproj @@ -140,16 +140,16 @@ 6ABF20382878786700C10295 /* UIFont+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6ABF20372878786700C10295 /* UIFont+Extensions.swift */; }; 6AC190E228E7449000417EC5 /* InstitutionSearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AC190E128E7449000417EC5 /* InstitutionSearchBar.swift */; }; 6AC190E428E752D000417EC5 /* cancel_circle@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6AC190E328E752D000417EC5 /* cancel_circle@3x.png */; }; - 6AD025C52926876B00C6CBF1 /* UIImage+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AD025C42926876B00C6CBF1 /* UIImage+Extensions.swift */; }; 6AD025C12925D71C00C6CBF1 /* HitTestStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AD025C02925D71C00C6CBF1 /* HitTestStackView.swift */; }; 6AD025C32925DA7500C6CBF1 /* HitTestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AD025C22925DA7500C6CBF1 /* HitTestView.swift */; }; + 6AD025C52926876B00C6CBF1 /* UIImage+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AD025C42926876B00C6CBF1 /* UIImage+Extensions.swift */; }; 6AD025C7292725EF00C6CBF1 /* ConsentBottomSheetModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AD025C6292725EF00C6CBF1 /* ConsentBottomSheetModel.swift */; }; 6AD025C92927EAC800C6CBF1 /* bullet@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6AD025C82927EAC800C6CBF1 /* bullet@3x.png */; }; 6AD025CB292BC89D00C6CBF1 /* BulletPointLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AD025CA292BC89D00C6CBF1 /* BulletPointLabelView.swift */; }; 6AD448B728C25F1F002CABB0 /* ResetFlowViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AD448B628C25F1F002CABB0 /* ResetFlowViewController.swift */; }; 6AD448B928C25F85002CABB0 /* ResetFlowDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AD448B828C25F85002CABB0 /* ResetFlowDataSource.swift */; }; 6AD5863E290AC9380088522B /* FinancialConnectionsPaymentMethodType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AD5863D290AC9380088522B /* FinancialConnectionsPaymentMethodType.swift */; }; - 6AD58640290AC9590088522B /* FinancialConnectionsAuthorizationSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AD5863F290AC9590088522B /* FinancialConnectionsAuthorizationSession.swift */; }; + 6AD58640290AC9590088522B /* FinancialConnectionsAuthSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AD5863F290AC9590088522B /* FinancialConnectionsAuthSession.swift */; }; 6AD58642290AC9FA0088522B /* FinancialConnectionsPartnerAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AD58641290AC9FA0088522B /* FinancialConnectionsPartnerAccount.swift */; }; 6AD58644290ACA200088522B /* FinancialConnectionsPaymentAccountResource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AD58643290ACA200088522B /* FinancialConnectionsPaymentAccountResource.swift */; }; 6AD58646290ACA580088522B /* FinancialConnectionsMixedOAuthParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AD58645290ACA580088522B /* FinancialConnectionsMixedOAuthParams.swift */; }; @@ -369,16 +369,16 @@ 6ABF20372878786700C10295 /* UIFont+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIFont+Extensions.swift"; sourceTree = ""; }; 6AC190E128E7449000417EC5 /* InstitutionSearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstitutionSearchBar.swift; sourceTree = ""; }; 6AC190E328E752D000417EC5 /* cancel_circle@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "cancel_circle@3x.png"; sourceTree = ""; }; - 6AD025C42926876B00C6CBF1 /* UIImage+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Extensions.swift"; sourceTree = ""; }; 6AD025C02925D71C00C6CBF1 /* HitTestStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HitTestStackView.swift; sourceTree = ""; }; 6AD025C22925DA7500C6CBF1 /* HitTestView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HitTestView.swift; sourceTree = ""; }; + 6AD025C42926876B00C6CBF1 /* UIImage+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Extensions.swift"; sourceTree = ""; }; 6AD025C6292725EF00C6CBF1 /* ConsentBottomSheetModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsentBottomSheetModel.swift; sourceTree = ""; }; 6AD025C82927EAC800C6CBF1 /* bullet@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "bullet@3x.png"; sourceTree = ""; }; 6AD025CA292BC89D00C6CBF1 /* BulletPointLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BulletPointLabelView.swift; sourceTree = ""; }; 6AD448B628C25F1F002CABB0 /* ResetFlowViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResetFlowViewController.swift; sourceTree = ""; }; 6AD448B828C25F85002CABB0 /* ResetFlowDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResetFlowDataSource.swift; sourceTree = ""; }; 6AD5863D290AC9380088522B /* FinancialConnectionsPaymentMethodType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinancialConnectionsPaymentMethodType.swift; sourceTree = ""; }; - 6AD5863F290AC9590088522B /* FinancialConnectionsAuthorizationSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinancialConnectionsAuthorizationSession.swift; sourceTree = ""; }; + 6AD5863F290AC9590088522B /* FinancialConnectionsAuthSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinancialConnectionsAuthSession.swift; sourceTree = ""; }; 6AD58641290AC9FA0088522B /* FinancialConnectionsPartnerAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinancialConnectionsPartnerAccount.swift; sourceTree = ""; }; 6AD58643290ACA200088522B /* FinancialConnectionsPaymentAccountResource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinancialConnectionsPaymentAccountResource.swift; sourceTree = ""; }; 6AD58645290ACA580088522B /* FinancialConnectionsMixedOAuthParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinancialConnectionsMixedOAuthParams.swift; sourceTree = ""; }; @@ -556,7 +556,7 @@ 3CAD99BA284E381100B163EB /* FinancialConnectionsInstitution.swift */, 6A370F312901CA2C00A6DB9B /* FinancialConnectionsSynchronize.swift */, 6AD5863D290AC9380088522B /* FinancialConnectionsPaymentMethodType.swift */, - 6AD5863F290AC9590088522B /* FinancialConnectionsAuthorizationSession.swift */, + 6AD5863F290AC9590088522B /* FinancialConnectionsAuthSession.swift */, 6AD58641290AC9FA0088522B /* FinancialConnectionsPartnerAccount.swift */, 6AD58643290ACA200088522B /* FinancialConnectionsPaymentAccountResource.swift */, 6AD58645290ACA580088522B /* FinancialConnectionsMixedOAuthParams.swift */, @@ -1096,7 +1096,7 @@ 6AE3F32F28EDF6B10079FD59 /* AuthFlowHelpers.swift in Sources */, 6AD025C32925DA7500C6CBF1 /* HitTestView.swift in Sources */, 3CE96D3627585F01006B7059 /* FinancialConnectionsSessionManifest.swift in Sources */, - 6AD58640290AC9590088522B /* FinancialConnectionsAuthorizationSession.swift in Sources */, + 6AD58640290AC9590088522B /* FinancialConnectionsAuthSession.swift in Sources */, 6A2318D028AE7EA700F2A7D8 /* RadioButtonView.swift in Sources */, 6ABE2D0A285B7BA20064B3A4 /* SFSafariViewController+Extensions.swift in Sources */, 6AD5863E290AC9380088522B /* FinancialConnectionsPaymentMethodType.swift in Sources */, diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/FinancialConnectionsAPIClient.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/FinancialConnectionsAPIClient.swift index 942a583c2fa..93628615ff9 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/FinancialConnectionsAPIClient.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/FinancialConnectionsAPIClient.swift @@ -23,25 +23,25 @@ protocol FinancialConnectionsAPIClient { func fetchInstitutions(clientSecret: String, query: String) -> Promise - func createAuthorizationSession(clientSecret: String, institutionId: String) -> Promise + func createAuthSession(clientSecret: String, institutionId: String) -> Promise - func cancelAuthSession(clientSecret: String, authSessionId: String) -> Promise + func cancelAuthSession(clientSecret: String, authSessionId: String) -> Promise func fetchAuthSessionOAuthResults(clientSecret: String, authSessionId: String) -> Future func authorizeAuthSession(clientSecret: String, authSessionId: String, - publicToken: String?) -> Promise + publicToken: String?) -> Promise func fetchAuthSessionAccounts( clientSecret: String, authSessionId: String, initialPollDelay: TimeInterval - ) -> Future + ) -> Future func selectAuthSessionAccounts(clientSecret: String, authSessionId: String, - selectedAccountIds: [String]) -> Promise + selectedAccountIds: [String]) -> Promise func markLinkingMoreAccounts(clientSecret: String) -> Promise @@ -134,7 +134,7 @@ extension STPAPIClient: FinancialConnectionsAPIClient { parameters: parameters) } - func createAuthorizationSession(clientSecret: String, institutionId: String) -> Promise { + func createAuthSession(clientSecret: String, institutionId: String) -> Promise { let body: [String:Any] = [ "client_secret": clientSecret, "institution": institutionId, @@ -142,15 +142,15 @@ extension STPAPIClient: FinancialConnectionsAPIClient { "use_abstract_flow": true, "return_url": "ios", ] - return self.post(resource: APIEndpointAuthorizationSessions, parameters: body) + return self.post(resource: APIEndpointAuthSessions, parameters: body) } - func cancelAuthSession(clientSecret: String, authSessionId: String) -> Promise { + func cancelAuthSession(clientSecret: String, authSessionId: String) -> Promise { let body = [ "client_secret": clientSecret, "id": authSessionId, ] - return self.post(resource: APIEndpointAuthorizationSessionsCancel, object: body) + return self.post(resource: APIEndpointAuthSessionsCancel, object: body) } func fetchAuthSessionOAuthResults(clientSecret: String, authSessionId: String) -> Future { @@ -163,7 +163,7 @@ extension STPAPIClient: FinancialConnectionsAPIClient { guard let self = self else { return Promise(error: FinancialConnectionsSheetError.unknown(debugDescription: "STPAPIClient deallocated.")) } - return self.post(resource: APIEndpointAuthorizationSessionsOAuthResults, object: body) + return self.post(resource: APIEndpointAuthSessionsOAuthResults, object: body) }, pollTimingOptions: APIPollingHelper.PollTimingOptions( initialPollDelay: 0, @@ -176,20 +176,20 @@ extension STPAPIClient: FinancialConnectionsAPIClient { func authorizeAuthSession(clientSecret: String, authSessionId: String, - publicToken: String? = nil) -> Promise { + publicToken: String? = nil) -> Promise { var body = [ "client_secret": clientSecret, "id": authSessionId, ] body["public_token"] = publicToken // not all integrations require public_token - return self.post(resource: APIEndpointAuthorizationSessionsAuthorized, object: body) + return self.post(resource: APIEndpointAuthSessionsAuthorized, object: body) } func fetchAuthSessionAccounts( clientSecret: String, authSessionId: String, initialPollDelay: TimeInterval - ) -> Future { + ) -> Future { let body = [ "client_secret": clientSecret, "id": authSessionId, @@ -199,9 +199,9 @@ extension STPAPIClient: FinancialConnectionsAPIClient { guard let self = self else { return Promise(error: FinancialConnectionsSheetError.unknown(debugDescription: "STPAPIClient deallocated.")) } - return self.post(resource: APIEndpointAuthorizationSessionsAccounts, object: body) + return self.post(resource: APIEndpointAuthSessionsAccounts, object: body) }, - pollTimingOptions: APIPollingHelper.PollTimingOptions( + pollTimingOptions: APIPollingHelper.PollTimingOptions( initialPollDelay: initialPollDelay ) ) @@ -210,13 +210,13 @@ extension STPAPIClient: FinancialConnectionsAPIClient { func selectAuthSessionAccounts(clientSecret: String, authSessionId: String, - selectedAccountIds: [String]) -> Promise { + selectedAccountIds: [String]) -> Promise { let body: [String: Any] = [ "client_secret": clientSecret, "id": authSessionId, "selected_accounts": selectedAccountIds, ] - return self.post(resource: APIEndpointAuthorizationSessionsSelectedAccounts, parameters: body) + return self.post(resource: APIEndpointAuthSessionsSelectedAccounts, parameters: body) } func markLinkingMoreAccounts(clientSecret: String) -> Promise { @@ -354,7 +354,7 @@ extension STPAPIClient: FinancialConnectionsAPIClient { ] body["key"] = publishableKey return self.post( - resource: APIEndpointAuthorizationSessionsEvents, + resource: APIEndpointAuthSessionsEvents, parameters: body ) } @@ -369,10 +369,10 @@ private let APIEndpointLinkMoreAccounts = "link_account_sessions/link_more_accou private let APIEndpointComplete = "link_account_sessions/complete" private let APIEndpointFeaturedInstitutions = "connections/featured_institutions" private let APIEndpointSearchInstitutions = "connections/institutions" -private let APIEndpointAuthorizationSessions = "connections/auth_sessions" -private let APIEndpointAuthorizationSessionsCancel = "connections/auth_sessions/cancel" -private let APIEndpointAuthorizationSessionsOAuthResults = "connections/auth_sessions/oauth_results" -private let APIEndpointAuthorizationSessionsAuthorized = "connections/auth_sessions/authorized" -private let APIEndpointAuthorizationSessionsAccounts = "connections/auth_sessions/accounts" -private let APIEndpointAuthorizationSessionsSelectedAccounts = "connections/auth_sessions/selected_accounts" -private let APIEndpointAuthorizationSessionsEvents = "connections/auth_sessions/events" +private let APIEndpointAuthSessions = "connections/auth_sessions" +private let APIEndpointAuthSessionsCancel = "connections/auth_sessions/cancel" +private let APIEndpointAuthSessionsOAuthResults = "connections/auth_sessions/oauth_results" +private let APIEndpointAuthSessionsAuthorized = "connections/auth_sessions/authorized" +private let APIEndpointAuthSessionsAccounts = "connections/auth_sessions/accounts" +private let APIEndpointAuthSessionsSelectedAccounts = "connections/auth_sessions/selected_accounts" +private let APIEndpointAuthSessionsEvents = "connections/auth_sessions/events" diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/FinancialConnectionsAuthorizationSession.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/FinancialConnectionsAuthSession.swift similarity index 98% rename from StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/FinancialConnectionsAuthorizationSession.swift rename to StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/FinancialConnectionsAuthSession.swift index 14ac5d4d618..6b698b33b76 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/FinancialConnectionsAuthorizationSession.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/FinancialConnectionsAuthSession.swift @@ -10,7 +10,7 @@ import Foundation import UIKit @_spi(STP) import StripeUICore -struct FinancialConnectionsAuthorizationSession: Decodable { +struct FinancialConnectionsAuthSession: Decodable { enum Flow: String, SafeEnumCodable, Equatable { case directWebview = "direct_webview" case finicityConnectV2Lite = "finicity_connect_v2_lite" diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/FinancialConnectionsPartnerAccount.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/FinancialConnectionsPartnerAccount.swift index 10fc5477e21..85a05c18db4 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/FinancialConnectionsPartnerAccount.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/FinancialConnectionsPartnerAccount.swift @@ -33,7 +33,7 @@ struct FinancialConnectionsDisabledPartnerAccount { let disableReason: String } -struct FinancialConnectionsAuthorizationSessionAccounts: Decodable { +struct FinancialConnectionsAuthSessionAccounts: Decodable { let data: [FinancialConnectionsPartnerAccount] let nextPane: FinancialConnectionsSessionManifest.NextPane } diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/FinancialConnectionsSessionManifest.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/FinancialConnectionsSessionManifest.swift index 0d92cbc8913..5622fc7abf7 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/FinancialConnectionsSessionManifest.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/API Bindings/Models/FinancialConnectionsSessionManifest.swift @@ -48,7 +48,7 @@ struct FinancialConnectionsSessionManifest: Decodable { // MARK: - Properties let accountholderIsLinkConsumer: Bool? - let activeAuthSession: FinancialConnectionsAuthorizationSession? + let activeAuthSession: FinancialConnectionsAuthSession? let activeInstitution: FinancialConnectionsInstitution? let allowManualEntry: Bool let businessName: String? diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/Native/AccountPicker/AccountPickerDataSource.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/Native/AccountPicker/AccountPickerDataSource.swift index 07cdff889bd..347eeab119a 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/Native/AccountPicker/AccountPickerDataSource.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/Native/AccountPicker/AccountPickerDataSource.swift @@ -19,21 +19,21 @@ protocol AccountPickerDataSource: AnyObject { var delegate: AccountPickerDataSourceDelegate? { get set } var manifest: FinancialConnectionsSessionManifest { get } - var authorizationSession: FinancialConnectionsAuthorizationSession { get } + var authSession: FinancialConnectionsAuthSession { get } var institution: FinancialConnectionsInstitution { get } var selectedAccounts: [FinancialConnectionsPartnerAccount] { get } var analyticsClient: FinancialConnectionsAnalyticsClient { get } - func pollAuthSessionAccounts() -> Future + func pollAuthSessionAccounts() -> Future func updateSelectedAccounts(_ selectedAccounts: [FinancialConnectionsPartnerAccount]) - func selectAuthSessionAccounts() -> Promise + func selectAuthSessionAccounts() -> Promise } final class AccountPickerDataSourceImplementation: AccountPickerDataSource { private let apiClient: FinancialConnectionsAPIClient private let clientSecret: String - let authorizationSession: FinancialConnectionsAuthorizationSession + let authSession: FinancialConnectionsAuthSession let manifest: FinancialConnectionsSessionManifest let institution: FinancialConnectionsInstitution let analyticsClient: FinancialConnectionsAnalyticsClient @@ -48,24 +48,24 @@ final class AccountPickerDataSourceImplementation: AccountPickerDataSource { init( apiClient: FinancialConnectionsAPIClient, clientSecret: String, - authorizationSession: FinancialConnectionsAuthorizationSession, + authSession: FinancialConnectionsAuthSession, manifest: FinancialConnectionsSessionManifest, institution: FinancialConnectionsInstitution, analyticsClient: FinancialConnectionsAnalyticsClient ) { self.apiClient = apiClient self.clientSecret = clientSecret - self.authorizationSession = authorizationSession + self.authSession = authSession self.manifest = manifest self.institution = institution self.analyticsClient = analyticsClient } - func pollAuthSessionAccounts() -> Future { + func pollAuthSessionAccounts() -> Future { return apiClient.fetchAuthSessionAccounts( clientSecret: clientSecret, - authSessionId: authorizationSession.id, - initialPollDelay: AuthSessionAccountsInitialPollDelay(forFlow: authorizationSession.flow) + authSessionId: authSession.id, + initialPollDelay: AuthSessionAccountsInitialPollDelay(forFlow: authSession.flow) ) } @@ -73,17 +73,17 @@ final class AccountPickerDataSourceImplementation: AccountPickerDataSource { self.selectedAccounts = selectedAccounts } - func selectAuthSessionAccounts() -> Promise { + func selectAuthSessionAccounts() -> Promise { return apiClient.selectAuthSessionAccounts( clientSecret: clientSecret, - authSessionId: authorizationSession.id, + authSessionId: authSession.id, selectedAccountIds: selectedAccounts.map({ $0.id }) ) } } private func AuthSessionAccountsInitialPollDelay( - forFlow flow: FinancialConnectionsAuthorizationSession.Flow? + forFlow flow: FinancialConnectionsAuthSession.Flow? ) -> TimeInterval { let defaultInitialPollDelay: TimeInterval = 1.75 guard let flow = flow else { diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/Native/AccountPicker/AccountPickerViewController.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/Native/AccountPicker/AccountPickerViewController.swift index 106ed6bb618..9e5b7db3d73 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/Native/AccountPicker/AccountPickerViewController.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/Native/AccountPicker/AccountPickerViewController.swift @@ -96,7 +96,7 @@ final class AccountPickerViewController: UIViewController { init(dataSource: AccountPickerDataSource) { self.dataSource = dataSource self.accountPickerType = dataSource.manifest.singleAccount ? .radioButton : .checkbox - self.institutionHasAccountPicker = (dataSource.authorizationSession.institutionSkipAccountSelection == true && dataSource.manifest.singleAccount && dataSource.authorizationSession.isOauth) + self.institutionHasAccountPicker = (dataSource.authSession.institutionSkipAccountSelection == true && dataSource.manifest.singleAccount && dataSource.authSession.isOauth) super.init(nibName: nil, bundle: nil) dataSource.delegate = self } @@ -138,7 +138,7 @@ final class AccountPickerViewController: UIViewController { eventName: "polling.accounts.success", parameters: [ "duration": Date().timeIntervalSince(pollingStartDate).milliseconds, - "authSessionId": self.dataSource.authorizationSession.id, + "authSessionId": self.dataSource.authSession.id, ] ) } @@ -154,14 +154,14 @@ final class AccountPickerViewController: UIViewController { debugDescription: "API returned an empty list of accounts" ) ) - } else if self.dataSource.authorizationSession.skipAccountSelection ?? false { + } else if self.dataSource.authSession.skipAccountSelection ?? false { self.delegate?.accountPickerViewController( self, didSelectAccounts: accounts ) } else if self.dataSource.manifest.singleAccount, - self.dataSource.authorizationSession.institutionSkipAccountSelection ?? false, + self.dataSource.authSession.institutionSkipAccountSelection ?? false, accounts.count == 1 { // the user saw an OAuth account selection screen and selected @@ -203,7 +203,7 @@ final class AccountPickerViewController: UIViewController { let errorView = AccountPickerNoAccountEligibleErrorView( institution: self.dataSource.institution, bussinessName: self.businessName, - institutionSkipAccountSelection: self.dataSource.authorizationSession.institutionSkipAccountSelection ?? false, + institutionSkipAccountSelection: self.dataSource.authSession.institutionSkipAccountSelection ?? false, numberOfIneligibleAccounts: numberOfIneligibleAccounts, paymentMethodType: self.dataSource.manifest.paymentMethodType ?? .usBankAccount, didSelectAnotherBank: self.didSelectAnotherBank, diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/Native/NativeFlowController.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/Native/NativeFlowController.swift index ce48c07340f..2dd09efe94e 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/Native/NativeFlowController.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/Native/NativeFlowController.swift @@ -337,9 +337,9 @@ extension NativeFlowController: PartnerAuthViewControllerDelegate { func partnerAuthViewController( _ viewController: PartnerAuthViewController, - didCompleteWithAuthSession authSession: FinancialConnectionsAuthorizationSession + didCompleteWithAuthSession authSession: FinancialConnectionsAuthSession ) { - dataManager.authorizationSession = authSession + dataManager.authSession = authSession let accountPickerViewController = CreatePaneViewController( pane: .accountPicker, @@ -544,11 +544,11 @@ private func CreatePaneViewController( let viewController: UIViewController? switch pane { case .accountPicker: - if let authorizationSession = dataManager.authorizationSession, let institution = dataManager.institution { + if let authSession = dataManager.authSession, let institution = dataManager.institution { let accountPickerDataSource = AccountPickerDataSourceImplementation( apiClient: dataManager.apiClient, clientSecret: dataManager.clientSecret, - authorizationSession: authorizationSession, + authSession: authSession, manifest: dataManager.manifest, institution: institution, analyticsClient: dataManager.analyticsClient @@ -569,7 +569,7 @@ private func CreatePaneViewController( institution: institution, linkedAccountId: linkedAccountId, analyticsClient: dataManager.analyticsClient, - authSessionId: dataManager.authorizationSession?.id + authSessionId: dataManager.authSession?.id ) let attachedLinkedPaymentAccountViewController = AttachLinkedPaymentAccountViewController( dataSource: dataSource diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/Native/NativeFlowDataManager.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/Native/NativeFlowDataManager.swift index a0d94b6f4c9..eb14db9e489 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/Native/NativeFlowDataManager.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/Native/NativeFlowDataManager.swift @@ -16,7 +16,7 @@ protocol NativeFlowDataManager: AnyObject { var analyticsClient: FinancialConnectionsAnalyticsClient { get } var institution: FinancialConnectionsInstitution? { get set } - var authorizationSession: FinancialConnectionsAuthorizationSession? { get set } + var authSession: FinancialConnectionsAuthSession? { get set } var linkedAccounts: [FinancialConnectionsPartnerAccount]? { get set } var terminalError: Error? { get set } var paymentAccountResource: FinancialConnectionsPaymentAccountResource? { get set } @@ -39,7 +39,7 @@ class NativeFlowAPIDataManager: NativeFlowDataManager { let analyticsClient: FinancialConnectionsAnalyticsClient var institution: FinancialConnectionsInstitution? - var authorizationSession: FinancialConnectionsAuthorizationSession? + var authSession: FinancialConnectionsAuthSession? var linkedAccounts: [FinancialConnectionsPartnerAccount]? var terminalError: Error? var paymentAccountResource: FinancialConnectionsPaymentAccountResource? @@ -65,7 +65,7 @@ class NativeFlowAPIDataManager: NativeFlowDataManager { } func resetState(withNewManifest newManifest: FinancialConnectionsSessionManifest) { - authorizationSession = nil + authSession = nil institution = nil paymentAccountResource = nil accountNumberLast4 = nil diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/Native/PartnerAuth/PartnerAuthDataSource.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/Native/PartnerAuth/PartnerAuthDataSource.swift index c1045d98adc..9e8aa262327 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/Native/PartnerAuth/PartnerAuthDataSource.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/Native/PartnerAuth/PartnerAuthDataSource.swift @@ -13,8 +13,8 @@ protocol PartnerAuthDataSource: AnyObject { var manifest: FinancialConnectionsSessionManifest { get } var analyticsClient: FinancialConnectionsAnalyticsClient { get } - func createAuthSession() -> Future - func authorizeAuthSession(_ authorizationSession: FinancialConnectionsAuthorizationSession) -> Future + func createAuthSession() -> Future + func authorizeAuthSession(_ authSession: FinancialConnectionsAuthSession) -> Future func cancelPendingAuthSessionIfNeeded() func recordAuthSessionEvent(eventName: String, authSessionId: String) } @@ -32,7 +32,7 @@ final class PartnerAuthDataSourceImplementation: PartnerAuthDataSource { // // in other words, a `pendingAuthSession` is up for being // cancelled unless the user successfully authorizes - private var pendingAuthSession: FinancialConnectionsAuthorizationSession? + private var pendingAuthSession: FinancialConnectionsAuthSession? init( institution: FinancialConnectionsInstitution, @@ -48,11 +48,11 @@ final class PartnerAuthDataSourceImplementation: PartnerAuthDataSource { self.analyticsClient = analyticsClient } - func createAuthSession() -> Future { - return apiClient.createAuthorizationSession( + func createAuthSession() -> Future { + return apiClient.createAuthSession( clientSecret: clientSecret, institutionId: institution.id - ).chained { [weak self] (authSession: FinancialConnectionsAuthorizationSession) in + ).chained { [weak self] (authSession: FinancialConnectionsAuthSession) in self?.pendingAuthSession = authSession return Promise(value: authSession) } @@ -69,14 +69,14 @@ final class PartnerAuthDataSourceImplementation: PartnerAuthDataSource { } } - private func cancelAuthSession(_ authSession: FinancialConnectionsAuthorizationSession) -> Future { + private func cancelAuthSession(_ authSession: FinancialConnectionsAuthSession) -> Future { return apiClient.cancelAuthSession( clientSecret: clientSecret, authSessionId: authSession.id ) } - func authorizeAuthSession(_ authSession: FinancialConnectionsAuthorizationSession) -> Future { + func authorizeAuthSession(_ authSession: FinancialConnectionsAuthSession) -> Future { return apiClient.fetchAuthSessionOAuthResults( clientSecret: clientSecret, authSessionId: authSession.id diff --git a/StripeFinancialConnections/StripeFinancialConnections/Source/Native/PartnerAuth/PartnerAuthViewController.swift b/StripeFinancialConnections/StripeFinancialConnections/Source/Native/PartnerAuth/PartnerAuthViewController.swift index 2ebaed26c7c..9c2d37ad90c 100644 --- a/StripeFinancialConnections/StripeFinancialConnections/Source/Native/PartnerAuth/PartnerAuthViewController.swift +++ b/StripeFinancialConnections/StripeFinancialConnections/Source/Native/PartnerAuth/PartnerAuthViewController.swift @@ -19,7 +19,7 @@ protocol PartnerAuthViewControllerDelegate: AnyObject { func partnerAuthViewController(_ viewController: PartnerAuthViewController, didReceiveTerminalError error: Error) func partnerAuthViewController( _ viewController: PartnerAuthViewController, - didCompleteWithAuthSession authSession: FinancialConnectionsAuthorizationSession + didCompleteWithAuthSession authSession: FinancialConnectionsAuthSession ) } @@ -71,35 +71,35 @@ final class PartnerAuthViewController: UIViewController { // order is important so be careful of moving self.showEstablishingConnectionLoadingView(false) switch result { - case .success(let authorizationSession): - self.createdAuthSession(authorizationSession) + case .success(let authSession): + self.createdAuthSession(authSession) case .failure(let error): self.showErrorView(error) } } } - private func createdAuthSession(_ authorizationSession: FinancialConnectionsAuthorizationSession) { + private func createdAuthSession(_ authSession: FinancialConnectionsAuthSession) { dataSource.recordAuthSessionEvent( eventName: "launched", - authSessionId: authorizationSession.id + authSessionId: authSession.id ) - if authorizationSession.isOauth { + if authSession.isOauth { let prepaneView = PrepaneView( institutionName: institution.name, institutionImageUrl: institution.icon?.default, - partner: (authorizationSession.showPartnerDisclosure ?? false) ? authorizationSession.flow?.toPartner() : nil, + partner: (authSession.showPartnerDisclosure ?? false) ? authSession.flow?.toPartner() : nil, isStripeDirect: dataSource.manifest.isStripeDirect ?? false, didSelectContinue: { [weak self] in - self?.openInstitutionAuthenticationWebView(authorizationSession: authorizationSession) + self?.openInstitutionAuthenticationWebView(authSession: authSession) } ) view.addAndPinSubview(prepaneView) dataSource.recordAuthSessionEvent( eventName: "loaded", - authSessionId: authorizationSession.id + authSessionId: authSession.id ) } else { // a legacy (non-oauth) institution will have a blank background @@ -111,7 +111,7 @@ final class PartnerAuthViewController: UIViewController { activityIndicator.startAnimating() view.addAndPinSubview(activityIndicator) - openInstitutionAuthenticationWebView(authorizationSession: authorizationSession) + openInstitutionAuthenticationWebView(authSession: authSession) } } @@ -228,8 +228,8 @@ final class PartnerAuthViewController: UIViewController { } } - private func openInstitutionAuthenticationWebView(authorizationSession: FinancialConnectionsAuthorizationSession) { - guard let urlString = authorizationSession.url, let url = URL(string: urlString) else { + private func openInstitutionAuthenticationWebView(authSession: FinancialConnectionsAuthSession) { + guard let urlString = authSession.url, let url = URL(string: urlString) else { assertionFailure("Expected to get a URL back from authorization session.") return } @@ -260,20 +260,20 @@ final class PartnerAuthViewController: UIViewController { if status == "success" { self.dataSource.recordAuthSessionEvent( eventName: "success", - authSessionId: authorizationSession.id + authSessionId: authSession.id ) - if authorizationSession.isOauth { + if authSession.isOauth { // for OAuth flows, we need to fetch OAuth results - self.authorizeAuthSession(authorizationSession) + self.authorizeAuthSession(authSession) } else { // for legacy flows (non-OAuth), we do not need to fetch OAuth results, or call authorize - self.delegate?.partnerAuthViewController(self, didCompleteWithAuthSession: authorizationSession) + self.delegate?.partnerAuthViewController(self, didCompleteWithAuthSession: authSession) } } else if status == "failure" { self.dataSource.recordAuthSessionEvent( eventName: "failure", - authSessionId: authorizationSession.id + authSessionId: authSession.id ) // cancel current auth session @@ -288,7 +288,7 @@ final class PartnerAuthViewController: UIViewController { } else { // assume `status == cancel` self.dataSource.recordAuthSessionEvent( eventName: "cancel", - authSessionId: authorizationSession.id + authSessionId: authSession.id ) // cancel current auth session @@ -308,17 +308,17 @@ final class PartnerAuthViewController: UIViewController { // the `error` may not always be set because of // a cancellation, but we still treat it as one if error != nil { - if authorizationSession.isOauth { + if authSession.isOauth { // on "manual cancels" (for OAuth) we log retry event: self.dataSource.recordAuthSessionEvent( eventName: "retry", - authSessionId: authorizationSession.id + authSessionId: authSession.id ) } else { // on "manual cancels" (for Legacy) we log cancel event: self.dataSource.recordAuthSessionEvent( eventName: "cancel", - authSessionId: authorizationSession.id + authSessionId: authSession.id ) } } @@ -336,7 +336,7 @@ final class PartnerAuthViewController: UIViewController { // cancel current auth session because something went wrong self.dataSource.cancelPendingAuthSessionIfNeeded() - if authorizationSession.isOauth { + if authSession.isOauth { // for OAuth institutions, we remain on the pre-pane, // but create a brand new auth session self.createAuthSession() @@ -374,24 +374,24 @@ final class PartnerAuthViewController: UIViewController { navigateBack() } else { // we successfully launched the secure web browser - if authorizationSession.isOauth { + if authSession.isOauth { dataSource.recordAuthSessionEvent( eventName: "oauth-launched", - authSessionId: authorizationSession.id + authSessionId: authSession.id ) } } } - private func authorizeAuthSession(_ authorizationSession: FinancialConnectionsAuthorizationSession) { + private func authorizeAuthSession(_ authSession: FinancialConnectionsAuthSession) { showEstablishingConnectionLoadingView(true) dataSource - .authorizeAuthSession(authorizationSession) + .authorizeAuthSession(authSession) .observe(on: .main) { [weak self] result in guard let self = self else { return } switch result { - case .success(let authorizationSession): - self.delegate?.partnerAuthViewController(self, didCompleteWithAuthSession: authorizationSession) + case .success(let authSession): + self.delegate?.partnerAuthViewController(self, didCompleteWithAuthSession: authSession) // hide the loading view after a delay to prevent // the screen from flashing _while_ the transition diff --git a/StripeFinancialConnections/StripeFinancialConnectionsTests/AccountFetcherTests.swift b/StripeFinancialConnections/StripeFinancialConnectionsTests/AccountFetcherTests.swift index 564d0c6b71b..af1d672a619 100644 --- a/StripeFinancialConnections/StripeFinancialConnectionsTests/AccountFetcherTests.swift +++ b/StripeFinancialConnections/StripeFinancialConnectionsTests/AccountFetcherTests.swift @@ -78,32 +78,32 @@ class PaginatedAPIClient: FinancialConnectionsAPIClient { return Promise() } - func createAuthorizationSession(clientSecret: String, institutionId: String) -> Promise { - return Promise() + func createAuthSession(clientSecret: String, institutionId: String) -> Promise { + return Promise() } - func cancelAuthSession(clientSecret: String, authSessionId: String) -> Promise { - return Promise() + func cancelAuthSession(clientSecret: String, authSessionId: String) -> Promise { + return Promise() } func fetchAuthSessionOAuthResults(clientSecret: String, authSessionId: String) -> Future { return Promise() } - func authorizeAuthSession(clientSecret: String, authSessionId: String, publicToken: String?) -> Promise { - return Promise() + func authorizeAuthSession(clientSecret: String, authSessionId: String, publicToken: String?) -> Promise { + return Promise() } func fetchAuthSessionAccounts( clientSecret: String, authSessionId: String, initialPollDelay: TimeInterval - ) -> Future { - return Promise() + ) -> Future { + return Promise() } - func selectAuthSessionAccounts(clientSecret: String, authSessionId: String, selectedAccountIds: [String]) -> Promise { - return Promise() + func selectAuthSessionAccounts(clientSecret: String, authSessionId: String, selectedAccountIds: [String]) -> Promise { + return Promise() } func markLinkingMoreAccounts(clientSecret: String) -> Promise { diff --git a/StripeFinancialConnections/StripeFinancialConnectionsTests/FinancialConnectionsSheetTests.swift b/StripeFinancialConnections/StripeFinancialConnectionsTests/FinancialConnectionsSheetTests.swift index 20695d995ba..2eb8b6675ae 100644 --- a/StripeFinancialConnections/StripeFinancialConnectionsTests/FinancialConnectionsSheetTests.swift +++ b/StripeFinancialConnections/StripeFinancialConnectionsTests/FinancialConnectionsSheetTests.swift @@ -35,32 +35,32 @@ class EmptyFinancialConnectionsAPIClient: FinancialConnectionsAPIClient { return Promise() } - func createAuthorizationSession(clientSecret: String, institutionId: String) -> Promise { - return Promise() + func createAuthSession(clientSecret: String, institutionId: String) -> Promise { + return Promise() } - func cancelAuthSession(clientSecret: String, authSessionId: String) -> Promise { - return Promise() + func cancelAuthSession(clientSecret: String, authSessionId: String) -> Promise { + return Promise() } func fetchAuthSessionOAuthResults(clientSecret: String, authSessionId: String) -> Future { return Promise() } - func authorizeAuthSession(clientSecret: String, authSessionId: String, publicToken: String?) -> Promise { - return Promise() + func authorizeAuthSession(clientSecret: String, authSessionId: String, publicToken: String?) -> Promise { + return Promise() } func fetchAuthSessionAccounts( clientSecret: String, authSessionId: String, initialPollDelay: TimeInterval - ) -> Future { - return Promise() + ) -> Future { + return Promise() } - func selectAuthSessionAccounts(clientSecret: String, authSessionId: String, selectedAccountIds: [String]) -> Promise { - return Promise() + func selectAuthSessionAccounts(clientSecret: String, authSessionId: String, selectedAccountIds: [String]) -> Promise { + return Promise() } func markLinkingMoreAccounts(clientSecret: String) -> Promise { diff --git a/StripeFinancialConnections/StripeFinancialConnectionsTests/SessionFetcherTests.swift b/StripeFinancialConnections/StripeFinancialConnectionsTests/SessionFetcherTests.swift index ab1a5970128..1b9698150a6 100644 --- a/StripeFinancialConnections/StripeFinancialConnectionsTests/SessionFetcherTests.swift +++ b/StripeFinancialConnections/StripeFinancialConnectionsTests/SessionFetcherTests.swift @@ -57,32 +57,32 @@ class NoMoreAccountSessionAPIClient: FinancialConnectionsAPIClient { return Promise() } - func createAuthorizationSession(clientSecret: String, institutionId: String) -> Promise { - return Promise() + func createAuthSession(clientSecret: String, institutionId: String) -> Promise { + return Promise() } - func cancelAuthSession(clientSecret: String, authSessionId: String) -> Promise { - return Promise() + func cancelAuthSession(clientSecret: String, authSessionId: String) -> Promise { + return Promise() } func fetchAuthSessionOAuthResults(clientSecret: String, authSessionId: String) -> Future { return Promise() } - func authorizeAuthSession(clientSecret: String, authSessionId: String, publicToken: String?) -> Promise { - return Promise() + func authorizeAuthSession(clientSecret: String, authSessionId: String, publicToken: String?) -> Promise { + return Promise() } func fetchAuthSessionAccounts( clientSecret: String, authSessionId: String, initialPollDelay: TimeInterval - ) -> Future { - return Promise() + ) -> Future { + return Promise() } - func selectAuthSessionAccounts(clientSecret: String, authSessionId: String, selectedAccountIds: [String]) -> Promise { - return Promise() + func selectAuthSessionAccounts(clientSecret: String, authSessionId: String, selectedAccountIds: [String]) -> Promise { + return Promise() } func markLinkingMoreAccounts(clientSecret: String) -> Promise {