Skip to content

Commit d8cea93

Browse files
committed
feat(Auth): Remove options from API's (#3075)
* feat(Auth): Remove options from API's that are not needed * removing options from setupTOTP API
1 parent a33e46a commit d8cea93

File tree

14 files changed

+33
-167
lines changed

14 files changed

+33
-167
lines changed

Amplify/Categories/Auth/AuthCategory+ClientBehavior.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,8 @@ extension AuthCategory: AuthCategoryBehavior {
7575
try await plugin.confirmResetPassword(for: username, with: newPassword, confirmationCode: confirmationCode, options: options)
7676
}
7777

78-
public func setUpTOTP(
79-
options: SetUpTOTPRequest.Options? = nil
80-
) async throws -> TOTPSetupDetails {
81-
try await plugin.setUpTOTP(options: options)
78+
public func setUpTOTP() async throws -> TOTPSetupDetails {
79+
try await plugin.setUpTOTP()
8280
}
8381

8482
public func verifyTOTPSetup(

Amplify/Categories/Auth/AuthCategoryBehavior.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,7 @@ public protocol AuthCategoryBehavior: AuthCategoryUserBehavior, AuthCategoryDevi
130130
/// Calling this method will initiate TOTP setup process and returns a shared secret that can be used to generate QR code.
131131
/// The setup details also contains a URI generator helper that can be used to retireve a TOTP Setup URI.
132132
///
133-
/// - Parameters:
134-
/// - options: Parameters specific to plugin behavior
135-
func setUpTOTP(
136-
options: SetUpTOTPRequest.Options?
137-
) async throws -> TOTPSetupDetails
133+
func setUpTOTP() async throws -> TOTPSetupDetails
138134

139135
/// Verifies TOTP Setup
140136
///

Amplify/Categories/Auth/Request/SetUpTOTPRequest.swift

Lines changed: 0 additions & 34 deletions
This file was deleted.

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPlugin+PluginSpecificAPI.swift

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,20 @@ public extension AWSCognitoAuthPlugin {
3333
try await task.value
3434
}
3535

36-
func fetchMFAPreference(
37-
options: FetchMFAPreferenceRequest.Options? = nil
38-
) async throws -> UserMFAPreference {
39-
let options = options ?? FetchMFAPreferenceRequest.Options()
40-
let request = FetchMFAPreferenceRequest(options: options)
36+
func fetchMFAPreference() async throws -> UserMFAPreference {
4137
let task = FetchMFAPreferenceTask(
42-
request,
4338
authStateMachine: authStateMachine,
4439
userPoolFactory: authEnvironment.cognitoUserPoolFactory)
4540
return try await task.value
4641
}
4742

4843
func updateMFAPreference(
4944
sms: MFAPreference?,
50-
totp: MFAPreference?,
51-
options: UpdateMFAPreferenceRequest.Options? = nil
45+
totp: MFAPreference?
5246
) async throws {
53-
let options = options ?? UpdateMFAPreferenceRequest.Options()
54-
let request = UpdateMFAPreferenceRequest(
55-
options: options,
56-
smsPreference: sms,
57-
totpPreference: totp)
5847
let task = UpdateMFAPreferenceTask(
59-
request,
48+
smsPreference: sms,
49+
totpPreference: totp,
6050
authStateMachine: authStateMachine,
6151
userPoolFactory: authEnvironment.cognitoUserPoolFactory)
6252
return try await task.value

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPluginBehavior.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,15 @@ protocol AWSCognitoAuthPluginBehavior: AuthCategoryPlugin {
4040

4141
/// Fetches users MFA preferences
4242
///
43-
/// - Parameters:
44-
/// - options: Parameters specific to plugin behavior.
45-
func fetchMFAPreference(
46-
options: FetchMFAPreferenceRequest.Options?
47-
) async throws -> UserMFAPreference
43+
func fetchMFAPreference() async throws -> UserMFAPreference
4844

4945
/// Updates users MFA preferences
5046
///
5147
/// - Parameters:
5248
/// - sms: The preference that needs to be updated for SMS
5349
/// - totp: The preference that needs to be updated for TOTP
54-
/// - options: Parameters specific to plugin behavior.
5550
func updateMFAPreference(
5651
sms: MFAPreference?,
57-
totp: MFAPreference?,
58-
options: UpdateMFAPreferenceRequest.Options?
52+
totp: MFAPreference?
5953
) async throws
6054
}

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/ClientBehavior/AWSCognitoAuthPlugin+ClientBehavior.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,8 @@ extension AWSCognitoAuthPlugin: AuthCategoryBehavior {
167167
}
168168
}
169169

170-
public func setUpTOTP(
171-
options: SetUpTOTPRequest.Options?
172-
) async throws -> TOTPSetupDetails {
173-
let options = options ?? SetUpTOTPRequest.Options()
174-
let request = SetUpTOTPRequest(options: options)
170+
public func setUpTOTP() async throws -> TOTPSetupDetails {
175171
let task = SetUpTOTPTask(
176-
request,
177172
authStateMachine: authStateMachine,
178173
userPoolFactory: authEnvironment.cognitoUserPoolFactory)
179174
return try await taskQueue.sync {

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Request/FetchMFAPreferenceRequest.swift

Lines changed: 0 additions & 30 deletions
This file was deleted.

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Request/UpdateMFAPreferenceRequest.swift

Lines changed: 0 additions & 38 deletions
This file was deleted.

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/FetchMFAPreferenceTask.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import AWSPluginsCore
1111
import ClientRuntime
1212
import AWSCognitoIdentityProvider
1313

14-
protocol AuthFetchMFAPreferenceTask: AmplifyAuthTask where Request == FetchMFAPreferenceRequest,
14+
protocol AuthFetchMFAPreferenceTask: AmplifyAuthTask where Request == Void,
1515
Success == UserMFAPreference,
1616
Failure == AuthError {}
1717

@@ -24,7 +24,6 @@ class FetchMFAPreferenceTask: AuthFetchMFAPreferenceTask, DefaultLogger {
2424

2525
typealias CognitoUserPoolFactory = () throws -> CognitoUserPoolBehavior
2626

27-
private let request: FetchMFAPreferenceRequest
2827
private let authStateMachine: AuthStateMachine
2928
private let userPoolFactory: CognitoUserPoolFactory
3029
private let taskHelper: AWSAuthTaskHelper
@@ -33,10 +32,8 @@ class FetchMFAPreferenceTask: AuthFetchMFAPreferenceTask, DefaultLogger {
3332
HubPayload.EventName.Auth.fetchMFAPreferenceAPI
3433
}
3534

36-
init(_ request: FetchMFAPreferenceRequest,
37-
authStateMachine: AuthStateMachine,
35+
init(authStateMachine: AuthStateMachine,
3836
userPoolFactory: @escaping CognitoUserPoolFactory) {
39-
self.request = request
4037
self.authStateMachine = authStateMachine
4138
self.userPoolFactory = userPoolFactory
4239
self.taskHelper = AWSAuthTaskHelper(authStateMachine: authStateMachine)

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/Protocols/AuthSetUpTOTPTask.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99
import Amplify
1010

11-
protocol AuthSetUpTOTPTask: AmplifyAuthTask where Request == SetUpTOTPRequest, Success == TOTPSetupDetails, Failure == AuthError {}
11+
protocol AuthSetUpTOTPTask: AmplifyAuthTask where Request == Void, Success == TOTPSetupDetails, Failure == AuthError {}
1212

1313
public extension HubPayload.EventName.Auth {
1414

0 commit comments

Comments
 (0)