@@ -12,8 +12,6 @@ import com.auth0.android.request.internal.ResponseUtils.isNetworkError
1212import com.auth0.android.result.Challenge
1313import com.auth0.android.result.Credentials
1414import com.auth0.android.result.DatabaseUser
15- import com.auth0.android.result.PasskeyChallengeResponse
16- import com.auth0.android.result.PasskeyRegistrationResponse
1715import com.auth0.android.result.UserProfile
1816import com.google.gson.Gson
1917import okhttp3.HttpUrl.Companion.toHttpUrl
@@ -153,102 +151,6 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
153151 return loginWithToken(parameters)
154152 }
155153
156-
157- /* *
158- * Log in a user using passkeys.
159- * This should be called after the client has received the Passkey challenge and Auth-session from the server .
160- * Requires the client to have the **Passkey** Grant Type enabled. See [Client Grant Types](https://auth0.com/docs/clients/client-grant-types)
161- * to learn how to enable it.
162- *
163- * @param authSession the auth session received from the server as part of the public challenge request.
164- * @param authResponse the public key credential response to be sent to the server
165- * @param parameters additional parameters to be sent as part of the request
166- * @return a request to configure and start that will yield [Credentials]
167- */
168- internal fun signinWithPasskey (
169- authSession : String ,
170- authResponse : PublicKeyCredentialResponse ,
171- parameters : Map <String , String >
172- ): AuthenticationRequest {
173- val params = ParameterBuilder .newBuilder().apply {
174- setGrantType(ParameterBuilder .GRANT_TYPE_PASSKEY )
175- set(AUTH_SESSION_KEY , authSession)
176- addAll(parameters)
177- }.asDictionary()
178-
179- return loginWithToken(params)
180- .addParameter(
181- AUTH_RESPONSE_KEY ,
182- Gson ().toJsonTree(authResponse)
183- ) as AuthenticationRequest
184- }
185-
186-
187- /* *
188- * Register a user and returns a challenge.
189- * Requires the client to have the **Passkey** Grant Type enabled. See [Client Grant Types](https://auth0.com/docs/clients/client-grant-types)
190- * to learn how to enable it.
191- *
192- * @param userMetadata user information of the client
193- * @param parameters additional parameter to be sent as part of the request
194- * @return a request to configure and start that will yield [PasskeyRegistrationResponse]
195- */
196- internal fun signupWithPasskey (
197- userMetadata : UserMetadataRequest ,
198- parameters : Map <String , String >,
199- ): Request <PasskeyRegistrationResponse , AuthenticationException > {
200- val user = Gson ().toJsonTree(userMetadata)
201- val url = auth0.getDomainUrl().toHttpUrl().newBuilder()
202- .addPathSegment(PASSKEY_PATH )
203- .addPathSegment(REGISTER_PATH )
204- .build()
205-
206- val params = ParameterBuilder .newBuilder().apply {
207- setClientId(clientId)
208- parameters[ParameterBuilder .REALM_KEY ]?.let {
209- setRealm(it)
210- }
211- }.asDictionary()
212-
213- val passkeyRegistrationAdapter: JsonAdapter <PasskeyRegistrationResponse > = GsonAdapter (
214- PasskeyRegistrationResponse ::class .java, gson
215- )
216- val post = factory.post(url.toString(), passkeyRegistrationAdapter)
217- .addParameters(params) as BaseRequest <PasskeyRegistrationResponse , AuthenticationException >
218- post.addParameter(USER_PROFILE_KEY , user)
219- return post
220- }
221-
222-
223- /* *
224- * Request for a challenge to initiate a passkey login flow
225- * Requires the client to have the **Passkey** Grant Type enabled. See [Client Grant Types](https://auth0.com/docs/clients/client-grant-types)
226- * to learn how to enable it.
227- *
228- * @param realm An optional connection name
229- * @return a request to configure and start that will yield [PasskeyChallengeResponse]
230- */
231- internal fun passkeyChallenge (
232- realm : String?
233- ): Request <PasskeyChallengeResponse , AuthenticationException > {
234- val url = auth0.getDomainUrl().toHttpUrl().newBuilder()
235- .addPathSegment(PASSKEY_PATH )
236- .addPathSegment(CHALLENGE_PATH )
237- .build()
238-
239- val parameters = ParameterBuilder .newBuilder().apply {
240- setClientId(clientId)
241- realm?.let { setRealm(it) }
242- }.asDictionary()
243-
244- val passkeyChallengeAdapter: JsonAdapter <PasskeyChallengeResponse > = GsonAdapter (
245- PasskeyChallengeResponse ::class .java, gson
246- )
247-
248- return factory.post(url.toString(), passkeyChallengeAdapter)
249- .addParameters(parameters)
250- }
251-
252154 /* *
253155 * Log in a user using an Out Of Band authentication code after they have received the 'mfa_required' error.
254156 * The MFA token tells the server the username or email, password, and realm values sent on the first request.
@@ -793,7 +695,8 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
793695 val parameters = ParameterBuilder .newBuilder()
794696 .setClientId(clientId)
795697 .setGrantType(ParameterBuilder .GRANT_TYPE_AUTHORIZATION_CODE )
796- .set(OAUTH_CODE_KEY , authorizationCode).set(REDIRECT_URI_KEY , redirectUri)
698+ .set(OAUTH_CODE_KEY , authorizationCode)
699+ .set(REDIRECT_URI_KEY , redirectUri)
797700 .set(" code_verifier" , codeVerifier)
798701 .asDictionary()
799702 val url = auth0.getDomainUrl().toHttpUrl().newBuilder()
@@ -833,26 +736,26 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
833736 .addPathSegment(OAUTH_PATH )
834737 .addPathSegment(TOKEN_PATH )
835738 .build()
836- val requestParameters =
837- ParameterBuilder .newBuilder()
838- .setClientId(clientId)
839- .addAll(parameters)
840- .asDictionary()
739+ val requestParameters = ParameterBuilder .newBuilder()
740+ .setClientId(clientId)
741+ .addAll(parameters)
742+ .asDictionary()
841743 val credentialsAdapter: JsonAdapter <Credentials > = GsonAdapter (
842744 Credentials ::class .java, gson
843745 )
844746 val request = BaseAuthenticationRequest (
845- factory.post(url.toString(), credentialsAdapter), clientId, baseURL
747+ factory.post(url.toString(), credentialsAdapter),
748+ clientId,
749+ baseURL
846750 )
847751 request.addParameters(requestParameters)
848752 return request
849753 }
850754
851755 private fun profileRequest (): Request <UserProfile , AuthenticationException > {
852- val url =
853- auth0.getDomainUrl().toHttpUrl().newBuilder()
854- .addPathSegment(USER_INFO_PATH )
855- .build()
756+ val url = auth0.getDomainUrl().toHttpUrl().newBuilder()
757+ .addPathSegment(USER_INFO_PATH )
758+ .build()
856759 val userProfileAdapter: JsonAdapter <UserProfile > = GsonAdapter (
857760 UserProfile ::class .java, gson
858761 )
@@ -879,9 +782,6 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
879782 private const val SUBJECT_TOKEN_KEY = " subject_token"
880783 private const val SUBJECT_TOKEN_TYPE_KEY = " subject_token_type"
881784 private const val USER_METADATA_KEY = " user_metadata"
882- private const val AUTH_SESSION_KEY = " auth_session"
883- private const val AUTH_RESPONSE_KEY = " authn_response"
884- private const val USER_PROFILE_KEY = " user_profile"
885785 private const val SIGN_UP_PATH = " signup"
886786 private const val DB_CONNECTIONS_PATH = " dbconnections"
887787 private const val CHANGE_PASSWORD_PATH = " change_password"
@@ -893,23 +793,24 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
893793 private const val REVOKE_PATH = " revoke"
894794 private const val MFA_PATH = " mfa"
895795 private const val CHALLENGE_PATH = " challenge"
896- private const val PASSKEY_PATH = " passkey"
897- private const val REGISTER_PATH = " register"
898796 private const val HEADER_AUTHORIZATION = " Authorization"
899797 private const val WELL_KNOWN_PATH = " .well-known"
900798 private const val JWKS_FILE_PATH = " jwks.json"
901799 private fun createErrorAdapter (): ErrorAdapter <AuthenticationException > {
902800 val mapAdapter = forMap(GsonProvider .gson)
903801 return object : ErrorAdapter <AuthenticationException > {
904802 override fun fromRawResponse (
905- statusCode : Int , bodyText : String , headers : Map <String , List <String >>
803+ statusCode : Int ,
804+ bodyText : String ,
805+ headers : Map <String , List <String >>
906806 ): AuthenticationException {
907807 return AuthenticationException (bodyText, statusCode)
908808 }
909809
910810 @Throws(IOException ::class )
911811 override fun fromJsonResponse (
912- statusCode : Int , reader : Reader
812+ statusCode : Int ,
813+ reader : Reader
913814 ): AuthenticationException {
914815 val values = mapAdapter.fromJson(reader)
915816 return AuthenticationException (values, statusCode)
@@ -918,11 +819,13 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
918819 override fun fromException (cause : Throwable ): AuthenticationException {
919820 if (isNetworkError(cause)) {
920821 return AuthenticationException (
921- " Failed to execute the network request" , NetworkErrorException (cause)
822+ " Failed to execute the network request" ,
823+ NetworkErrorException (cause)
922824 )
923825 }
924826 return AuthenticationException (
925- " Something went wrong" , Auth0Exception (" Something went wrong" , cause)
827+ " Something went wrong" ,
828+ Auth0Exception (" Something went wrong" , cause)
926829 )
927830 }
928831 }
0 commit comments