Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auth): Added the api shells for signin and confirmsignin for passwordless #2638

Merged
merged 18 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import com.amplifyframework.auth.AWSCognitoAuthMetadataType
import com.amplifyframework.auth.AuthCodeDeliveryDetails
import com.amplifyframework.auth.AuthDevice
import com.amplifyframework.auth.AuthException
import com.amplifyframework.auth.AuthPasswordlessDeliveryDestination
import com.amplifyframework.auth.AuthPasswordlessFlow
import com.amplifyframework.auth.AuthPlugin
import com.amplifyframework.auth.AuthProvider
import com.amplifyframework.auth.AuthSession
Expand All @@ -42,6 +44,8 @@ import com.amplifyframework.auth.options.AuthConfirmResetPasswordOptions
import com.amplifyframework.auth.options.AuthConfirmSignInOptions
import com.amplifyframework.auth.options.AuthConfirmSignUpOptions
import com.amplifyframework.auth.options.AuthFetchSessionOptions
import com.amplifyframework.auth.options.AuthMagicLinkOptions
import com.amplifyframework.auth.options.AuthOTPOptions
import com.amplifyframework.auth.options.AuthResendSignUpCodeOptions
import com.amplifyframework.auth.options.AuthResendUserAttributeConfirmationCodeOptions
import com.amplifyframework.auth.options.AuthResetPasswordOptions
Expand Down Expand Up @@ -202,6 +206,62 @@ class AWSCognitoAuthPlugin : AuthPlugin<AWSCognitoAuthService>() {
)
}

override fun signInWithMagicLink(
username: String,
flow: AuthPasswordlessFlow,
redirectURL: String,
options: AuthMagicLinkOptions,
onSuccess: Consumer<AuthSignInResult>,
onError: Consumer<AuthException>
) {
TODO("Not yet implemented")
}

override fun confirmSignInWithMagicLink(
challengeResponse: String,
options: AuthConfirmSignInOptions,
onSuccess: Consumer<AuthSignInResult>,
onError: Consumer<AuthException>
) {
TODO("Not yet implemented")
}

override fun confirmSignInWithMagicLink(
challengeResponse: String,
onSuccess: Consumer<AuthSignInResult>,
gpanshu marked this conversation as resolved.
Show resolved Hide resolved
onError: Consumer<AuthException>
) {
TODO("Not yet implemented")
}

override fun signInWithOTP(
username: String,
flow: AuthPasswordlessFlow,
destination: AuthPasswordlessDeliveryDestination,
options: AuthOTPOptions,
onSuccess: Consumer<AuthSignInResult>,
onError: Consumer<AuthException>
) {
TODO("Not yet implemented")
}

override fun confirmSignInWithOTP(
challengeResponse: String,
options: AuthConfirmSignInOptions,
onSuccess: Consumer<AuthSignInResult>,
onError: Consumer<AuthException>
) {
TODO("Not yet implemented")
}

override fun confirmSignInWithOTP(
challengeResponse: String,
onSuccess: Consumer<AuthSignInResult>,
onError: Consumer<AuthException>
) {
TODO("Not yet implemented")
}

override fun confirmSignUp(
username: String,
confirmationCode: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import com.amplifyframework.auth.AuthChannelEventName
import com.amplifyframework.auth.AuthCodeDeliveryDetails
import com.amplifyframework.auth.AuthDevice
import com.amplifyframework.auth.AuthException
import com.amplifyframework.auth.AuthPasswordlessDeliveryDestination
import com.amplifyframework.auth.AuthPasswordlessFlow
import com.amplifyframework.auth.AuthProvider
import com.amplifyframework.auth.AuthSession
import com.amplifyframework.auth.AuthUser
Expand Down Expand Up @@ -103,6 +105,8 @@ import com.amplifyframework.auth.options.AuthConfirmResetPasswordOptions
import com.amplifyframework.auth.options.AuthConfirmSignInOptions
import com.amplifyframework.auth.options.AuthConfirmSignUpOptions
import com.amplifyframework.auth.options.AuthFetchSessionOptions
import com.amplifyframework.auth.options.AuthMagicLinkOptions
import com.amplifyframework.auth.options.AuthOTPOptions
import com.amplifyframework.auth.options.AuthResendSignUpCodeOptions
import com.amplifyframework.auth.options.AuthResendUserAttributeConfirmationCodeOptions
import com.amplifyframework.auth.options.AuthResetPasswordOptions
Expand Down Expand Up @@ -347,6 +351,62 @@ internal class RealAWSCognitoAuthPlugin(
confirmSignUp(username, confirmationCode, AuthConfirmSignUpOptions.defaults(), onSuccess, onError)
}

override fun signInWithMagicLink(
username: String,
flow: AuthPasswordlessFlow,
redirectURL: String,
options: AuthMagicLinkOptions,
onSuccess: Consumer<AuthSignInResult>,
onError: Consumer<AuthException>
) {
TODO("Not yet implemented")
}

override fun confirmSignInWithMagicLink(
challengeResponse: String,
options: AuthConfirmSignInOptions,
onSuccess: Consumer<AuthSignInResult>,
onError: Consumer<AuthException>
) {
TODO("Not yet implemented")
}

override fun confirmSignInWithMagicLink(
challengeResponse: String,
onSuccess: Consumer<AuthSignInResult>,
onError: Consumer<AuthException>
gpanshu marked this conversation as resolved.
Show resolved Hide resolved
) {
TODO("Not yet implemented")
}

override fun signInWithOTP(
username: String,
flow: AuthPasswordlessFlow,
destination: AuthPasswordlessDeliveryDestination,
options: AuthOTPOptions,
onSuccess: Consumer<AuthSignInResult>,
onError: Consumer<AuthException>
) {
TODO("Not yet implemented")
}

override fun confirmSignInWithOTP(
challengeResponse: String,
options: AuthConfirmSignInOptions,
onSuccess: Consumer<AuthSignInResult>,
onError: Consumer<AuthException>
) {
TODO("Not yet implemented")
}

override fun confirmSignInWithOTP(
challengeResponse: String,
onSuccess: Consumer<AuthSignInResult>,
onError: Consumer<AuthException>
) {
TODO("Not yet implemented")
}

override fun confirmSignUp(
username: String,
confirmationCode: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

package com.amplifyframework.auth.cognito.options

import com.amplifyframework.auth.options.AuthMagicLinkOptions

/**
* Cognito extension of passwordless Magic Link options to add the platform specific fields.
*/
data class AWSCognitoAuthWithMagicLinkOptions
/**
* Advanced options for signing up using Passwordless.
* @param userMetadata user attributes to be sent to the service such as information about the user
* @param clientMetadata Additional custom attributes to be sent to the service such as information about the client
*/
internal constructor(
/**
* Get additional custom attributes to be sent to the service such a Fs information about the client.
gpanshu marked this conversation as resolved.
Show resolved Hide resolved
* @return a map of additional custom attributes to be sent to the service such as information about the client
*/
val clientMetadata: Map<String, String>?,
gpanshu marked this conversation as resolved.
Show resolved Hide resolved
/**
* Get user attributes to be sent to the service such as information about the user
* @return user attributes to be sent to the service such as information about the user
*/
val userMetadata: Map<String, String>?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no reason for this to be null when its impossible for builder to pass null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

) : AuthMagicLinkOptions() {

companion object {
/**
* Get a builder object.
* @return a builder object.
*/
@JvmStatic
fun builder(): CognitoBuilder {
return CognitoBuilder()
}

inline operator fun invoke(block: CognitoBuilder.() -> Unit) = CognitoBuilder().apply(block).build()
}

/**
* The builder for this class.
*/
class CognitoBuilder : Builder<CognitoBuilder?>() {
private var clientMetadata: Map<String, String> = mapOf()
private var userMetadata: Map<String, String> = mapOf()
/**
* Gets the type of builder to support proper flow with this being an extended class.
* @return the type of builder to support proper flow with this being an extended class.
*/
override fun getThis(): CognitoBuilder {
return this
}
/**
* A map of additional custom attributes to be sent to the service such as information about the client.
* @param clientMetadata A map of additional custom attributes to be sent to the service such as information
* about the client.
* @return the instance of the builder.
*/
fun clientMetadata(clientMetadata: Map<String, String>) = apply { this.clientMetadata = clientMetadata }

/**
* A map of user attributes to be sent to the service such as information about the user.
* @param userMetadata A map of user attributes to be sent to the service such as information
* about the user
* @return the instance of the builder.
*/
fun userMetadata(userMetadata: Map<String, String>) = apply { this.userMetadata = userMetadata }

/**
* Build the object.
* @return a new instance of AWSCognitoAuthMagicLinkOptions.
*/
override fun build() = AWSCognitoAuthWithMagicLinkOptions(clientMetadata, userMetadata)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

package com.amplifyframework.auth.cognito.options

import com.amplifyframework.auth.options.AuthOTPOptions

/**
* Cognito extension of passwordless OTP options to add the platform specific fields.
*/
data class AWSCognitoAuthWithOTPOptions
/**
* Advanced options for signing up using Passwordless.
* @param clientMetadata Additional custom attributes to be sent to the service such as information about the client
gpanshu marked this conversation as resolved.
Show resolved Hide resolved
* @param userMetadata User attributes to be sent to the service such as information about the user
*/
internal constructor(

/**
* Get additional custom attributes to be sent to the service such as information about the client.
* @return a map of additional custom attributes to be sent to the service such as information about the client
*/
val clientMetadata: Map<String, String>?,
gpanshu marked this conversation as resolved.
Show resolved Hide resolved
/**
* Get user attributes to be sent to the service such as information about the user
* @return a map of user attributes to be sent to the service such as information about the user
*/
val userMetadata: Map<String, String>?
) : AuthOTPOptions() {

companion object {
/**
* Get a builder object.
* @return a builder object.
*/
@JvmStatic
fun builder(): CognitoBuilder {
return CognitoBuilder()
}

inline operator fun invoke(block: CognitoBuilder.() -> Unit) = CognitoBuilder().apply(block).build()
}

/**
* The builder for this class.
*/
class CognitoBuilder : Builder<CognitoBuilder?>() {
private var clientMetadata: Map<String, String> = mapOf()
private var userMetadata: Map<String, String> = mapOf()
/**
* Gets the type of builder to support proper flow with this being an extended class.
* @return the type of builder to support proper flow with this being an extended class.
*/
override fun getThis(): CognitoBuilder {
return this
}

/**
* A map of additional custom attributes to be sent to the service such as information about the client.
* @param clientMetadata A map of additional custom attributes to be sent to the service such as information
* about the client.
* @return the instance of the builder.
*/
fun clientMetadata(clientMetadata: Map<String, String>) = apply { this.clientMetadata = clientMetadata }

/**
* A map of user attributes to be sent to the service such as information about the user.
* @param userMetadata A map of user attributes to be sent to the service such as information
* about the user
* @return the instance of the builder.
*/
fun userMetadata(userMetadata: Map<String, String>) = apply { this.userMetadata = userMetadata }

/**
* Build the object.
* @return a new instance of AWSCognitoAuthOTPOptions.
*/
override fun build() = AWSCognitoAuthWithOTPOptions(clientMetadata, userMetadata)
}
}
Loading