@@ -12,8 +12,8 @@ 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
15+ import com.auth0.android.result.PasskeyChallenge
16+ import com.auth0.android.result.PasskeyRegistrationChallenge
1717import com.auth0.android.result.UserProfile
1818import com.google.gson.Gson
1919import okhttp3.HttpUrl.Companion.toHttpUrl
@@ -155,25 +155,39 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
155155
156156
157157 /* *
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 .
158+ * Sign-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+ * The default scope used is 'openid profile email'.
161+ *
160162 * Requires the client to have the **Passkey** Grant Type enabled. See [Client Grant Types](https://auth0.com/docs/clients/client-grant-types)
161163 * to learn how to enable it.
162164 *
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
165+ * Example usage:
166+ *
167+ * ```
168+ * client.signinWithPasskey("{authSession}", "{authResponse}","{realm}")
169+ * .validateClaims() //mandatory
170+ * .addParameter("scope","scope")
171+ * .start(object: Callback<Credentials, AuthenticationException> {
172+ * override fun onFailure(error: AuthenticationException) { }
173+ * override fun onSuccess(result: Credentials) { }
174+ * })
175+ * ```
176+ *
177+ * @param authSession the auth session received from the server as part of the public key challenge request.
178+ * @param authResponse the public key credential authentication response
179+ * @param realm the default connection to use
166180 * @return a request to configure and start that will yield [Credentials]
167181 */
168- internal fun signinWithPasskey (
182+ public fun signinWithPasskey (
169183 authSession : String ,
170- authResponse : PublicKeyCredentialResponse ,
171- parameters : Map < String , String >
184+ authResponse : PublicKeyCredentials ,
185+ realm : String
172186 ): AuthenticationRequest {
173187 val params = ParameterBuilder .newBuilder().apply {
174188 setGrantType(ParameterBuilder .GRANT_TYPE_PASSKEY )
175189 set(AUTH_SESSION_KEY , authSession)
176- addAll(parameters )
190+ setRealm(realm )
177191 }.asDictionary()
178192
179193 return loginWithToken(params)
@@ -185,64 +199,86 @@ public class AuthenticationAPIClient @VisibleForTesting(otherwise = VisibleForTe
185199
186200
187201 /* *
188- * Register a user and returns a challenge.
202+ * Sign-up a user and returns a challenge for private and public key generation.
203+ * The default scope used is 'openid profile email'.
189204 * Requires the client to have the **Passkey** Grant Type enabled. See [Client Grant Types](https://auth0.com/docs/clients/client-grant-types)
190205 * to learn how to enable it.
191206 *
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]
207+ * Example usage:
208+ *
209+ *
210+ * ```
211+ * client.signupWithPasskey("{userData}","{realm}")
212+ * .addParameter("scope","scope")
213+ * .start(object: Callback<PasskeyRegistration, AuthenticationException> {
214+ * override fun onSuccess(result: PasskeyRegistration) { }
215+ * override fun onFailure(error: AuthenticationException) { }
216+ * })
217+ * ```
218+ *
219+ * @param userData user information of the client
220+ * @param realm default connection to use
221+ * @return a request to configure and start that will yield [PasskeyRegistrationChallenge]
195222 */
196- internal fun signupWithPasskey (
197- userMetadata : UserMetadataRequest ,
198- parameters : Map < String , String >,
199- ): Request <PasskeyRegistrationResponse , AuthenticationException > {
200- val user = Gson ().toJsonTree(userMetadata )
223+ public fun signupWithPasskey (
224+ userData : UserData ,
225+ realm : String
226+ ): Request <PasskeyRegistrationChallenge , AuthenticationException > {
227+ val user = Gson ().toJsonTree(userData )
201228 val url = auth0.getDomainUrl().toHttpUrl().newBuilder()
202229 .addPathSegment(PASSKEY_PATH )
203230 .addPathSegment(REGISTER_PATH )
204231 .build()
205232
206233 val params = ParameterBuilder .newBuilder().apply {
207234 setClientId(clientId)
208- parameters[ParameterBuilder .REALM_KEY ]?.let {
209- setRealm(it)
210- }
235+ setRealm(realm)
211236 }.asDictionary()
212237
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 >
238+ val passkeyRegistrationChallengeAdapter: JsonAdapter <PasskeyRegistrationChallenge > =
239+ GsonAdapter (
240+ PasskeyRegistrationChallenge ::class .java, gson
241+ )
242+ val post = factory.post(url.toString(), passkeyRegistrationChallengeAdapter)
243+ .addParameters(params) as BaseRequest <PasskeyRegistrationChallenge , AuthenticationException >
218244 post.addParameter(USER_PROFILE_KEY , user)
219245 return post
220246 }
221247
222248
223249 /* *
224- * Request for a challenge to initiate a passkey login flow
250+ * Request for a challenge to initiate passkey login flow
225251 * Requires the client to have the **Passkey** Grant Type enabled. See [Client Grant Types](https://auth0.com/docs/clients/client-grant-types)
226252 * to learn how to enable it.
227253 *
228- * @param realm An optional connection name
229- * @return a request to configure and start that will yield [PasskeyChallengeResponse]
254+ * Example usage:
255+ *
256+ * ```
257+ * client.passkeyChallenge("{realm}")
258+ * .start(object: Callback<PasskeyChallenge, AuthenticationException> {
259+ * override fun onSuccess(result: PasskeyChallenge) { }
260+ * override fun onFailure(error: AuthenticationException) { }
261+ * })
262+ * ```
263+ *
264+ * @param realm A default connection name
265+ * @return a request to configure and start that will yield [PasskeyChallenge]
230266 */
231- internal fun passkeyChallenge (
232- realm : String?
233- ): Request <PasskeyChallengeResponse , AuthenticationException > {
267+ public fun passkeyChallenge (
268+ realm : String
269+ ): Request <PasskeyChallenge , AuthenticationException > {
234270 val url = auth0.getDomainUrl().toHttpUrl().newBuilder()
235271 .addPathSegment(PASSKEY_PATH )
236272 .addPathSegment(CHALLENGE_PATH )
237273 .build()
238274
239275 val parameters = ParameterBuilder .newBuilder().apply {
240276 setClientId(clientId)
241- realm?. let { setRealm(it) }
277+ setRealm(realm)
242278 }.asDictionary()
243279
244- val passkeyChallengeAdapter: JsonAdapter <PasskeyChallengeResponse > = GsonAdapter (
245- PasskeyChallengeResponse ::class .java, gson
280+ val passkeyChallengeAdapter: JsonAdapter <PasskeyChallenge > = GsonAdapter (
281+ PasskeyChallenge ::class .java, gson
246282 )
247283
248284 return factory.post(url.toString(), passkeyChallengeAdapter)
0 commit comments