diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/Options/AWSAuthConfirmSignInOptions.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/Options/AWSAuthConfirmSignInOptions.swift index ce54b5a908..fed4400ba6 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/Options/AWSAuthConfirmSignInOptions.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/Options/AWSAuthConfirmSignInOptions.swift @@ -11,6 +11,7 @@ public struct AWSAuthConfirmSignInOptions { /// User attributes to be passed in when confirming a sign with NEW_PASSWORD_REQUIRED challenge public let userAttributes: [AuthUserAttribute]? + /// A map of custom key-value pairs that you can provide as input for any custom workflows that this action triggers. public let metadata: [String: String]? /// Device name that would be provided to Cognito when setting up TOTP diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/Options/AWSAuthConfirmSignInWithMagicLinkOptions.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/Options/AWSAuthConfirmSignInWithMagicLinkOptions.swift new file mode 100644 index 0000000000..51705be725 --- /dev/null +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/Options/AWSAuthConfirmSignInWithMagicLinkOptions.swift @@ -0,0 +1,17 @@ +// +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// +import Amplify + +public struct AWSAuthConfirmSignInWithMagicLinkOptions { + + /// A map of custom key-value pairs that you can provide as input for any custom workflows that this action triggers. + public let metadata: [String: String]? + + public init(metadata: [String: String]? = nil) { + self.metadata = metadata + } +} diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/Options/AWSAuthConfirmSignInWithOTPOptions.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/Options/AWSAuthConfirmSignInWithOTPOptions.swift new file mode 100644 index 0000000000..bb959945b6 --- /dev/null +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/Options/AWSAuthConfirmSignInWithOTPOptions.swift @@ -0,0 +1,17 @@ +// +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// +import Amplify + +public struct AWSAuthConfirmSignInWithOTPOptions { + + /// A map of custom key-value pairs that you can provide as input for any custom workflows that this action triggers. + public let metadata: [String: String]? + + public init(metadata: [String: String]? = nil) { + self.metadata = metadata + } +} diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignInWithOTPTask.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignInWithOTPTask.swift index ee4e820abf..ca425c6e85 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignInWithOTPTask.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignInWithOTPTask.swift @@ -98,7 +98,7 @@ class AWSAuthConfirmSignInWithOTPTask: AuthConfirmSignInWithOTPTask, DefaultLogg private func createConfirmSignInEventData() -> ConfirmSignInEventData { var passwordlessMetadata = confirmSignInRequestMetadata.toDictionary() - if let customerMetadata = (request.options.pluginOptions as? AWSAuthConfirmSignInOptions)?.metadata { + if let customerMetadata = (request.options.pluginOptions as? AWSAuthConfirmSignInWithOTPOptions)?.metadata { passwordlessMetadata.merge(customerMetadata, uniquingKeysWith: { passwordlessMetadata, customerMetadata in // Ideally key collision won't happen, because passwordless has been namespaced // if for some reason collision still happens, diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/AWSAuthConfirmSignInWithOTPTaskTests.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/AWSAuthConfirmSignInWithOTPTaskTests.swift index 5f2022a511..70bd752ee3 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/AWSAuthConfirmSignInWithOTPTaskTests.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/ClientBehaviorTests/SignIn/AWSAuthConfirmSignInWithOTPTaskTests.swift @@ -60,7 +60,8 @@ class AWSAuthConfirmSignInWithOTPTaskTests: BasePluginTest { }) do { - let confirmSignInOptions = AWSAuthConfirmSignInOptions(metadata: customerMetadata) + let confirmSignInOptions = AWSAuthConfirmSignInWithOTPOptions( + metadata: customerMetadata) let option = AuthConfirmSignInWithOTPRequest.Options(pluginOptions: confirmSignInOptions) let confirmSignInResult = try await plugin.confirmSignInWithOTP( challengeResponse: "code",