Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
598 changes: 540 additions & 58 deletions auth0/src/main/java/com/auth0/android/myaccount/MyAccountAPIClient.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.auth0.android.myaccount

public enum class PhoneAuthenticationMethodType(public val value: String) {
Comment thread
pmathew92 marked this conversation as resolved.
SMS("sms"),
VOICE("voice")
}
165 changes: 165 additions & 0 deletions auth0/src/main/java/com/auth0/android/result/AuthenticationMethod.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
package com.auth0.android.result

import com.google.gson.JsonDeserializationContext
import com.google.gson.JsonDeserializer
import com.google.gson.JsonElement
import com.google.gson.annotations.JsonAdapter
import com.google.gson.annotations.SerializedName
import java.lang.reflect.Type

public data class AuthenticationMethods(
@SerializedName("authentication_methods")
public val authenticationMethods: List<AuthenticationMethod>
)

@JsonAdapter(AuthenticationMethod.Deserializer::class)
public sealed class AuthenticationMethod {
public abstract val id: String
public abstract val type: String
public abstract val createdAt: String
public abstract val usage: List<String>

internal class Deserializer : JsonDeserializer<AuthenticationMethod> {
override fun deserialize(
json: JsonElement,
typeOfT: Type,
context: JsonDeserializationContext
): AuthenticationMethod? {
val jsonObject = json.asJsonObject
val type = jsonObject.get("type")?.asString
val targetClass = when (type) {
"password" -> PasswordAuthenticationMethod::class.java
"passkey" -> PasskeyAuthenticationMethod::class.java
"recovery-code" -> RecoveryCodeAuthenticationMethod::class.java
"push-notification" -> PushNotificationAuthenticationMethod::class.java
"totp" -> TotpAuthenticationMethod::class.java
"webauthn-platform" -> WebAuthnPlatformAuthenticationMethod::class.java
"webauthn-roaming" -> WebAuthnRoamingAuthenticationMethod::class.java
"phone" -> PhoneAuthenticationMethod::class.java
"email" -> EmailAuthenticationMethod::class.java
else -> null
}
return context.deserialize(jsonObject, targetClass)
}
}
Comment on lines +26 to +44

Check notice

Code scanning / CodeQL

Unused classes and interfaces Note

Unused class: Deserializer is not referenced within this codebase. If not used as an external API it should be removed.

Copilot Autofix

AI 8 months ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

}

public data class PasswordAuthenticationMethod(
@SerializedName("id") override val id: String,
@SerializedName("type") override val type: String,
@SerializedName("created_at") override val createdAt: String,
@SerializedName("usage") override val usage: List<String>,
@SerializedName("identity_user_id")
public val identityUserId: String?,
@SerializedName("last_password_reset")
public val lastPasswordReset: String?
) : AuthenticationMethod()

public data class PasskeyAuthenticationMethod(
@SerializedName("id") override val id: String,
@SerializedName("type") override val type: String,
@SerializedName("created_at") override val createdAt: String,
@SerializedName("usage") override val usage: List<String>,
@SerializedName("credential_backed_up")
public val credentialBackedUp: Boolean?,
@SerializedName("credential_device_type")
public val credentialDeviceType: String?,
@SerializedName("identity_user_id")
public val identityUserId: String?,
@SerializedName("key_id")
public val keyId: String?,
@SerializedName("public_key")
public val publicKey: String?,
@SerializedName("transports")
public val transports: List<String>?,
@SerializedName("user_agent")
public val userAgent: String?,
@SerializedName("user_handle")
public val userHandle: String?
) : AuthenticationMethod()

public sealed class MfaAuthenticationMethod : AuthenticationMethod() {
public abstract val confirmed: Boolean?
}

public data class RecoveryCodeAuthenticationMethod(
@SerializedName("id") override val id: String,
@SerializedName("type") override val type: String,
@SerializedName("created_at") override val createdAt: String,
@SerializedName("usage") override val usage: List<String>,
@SerializedName("confirmed") override val confirmed: Boolean?
) : MfaAuthenticationMethod()

public data class PushNotificationAuthenticationMethod(
@SerializedName("id") override val id: String,
@SerializedName("type") override val type: String,
@SerializedName("created_at") override val createdAt: String,
@SerializedName("usage") override val usage: List<String>,
@SerializedName("confirmed") override val confirmed: Boolean?,
@SerializedName("name")
public val name: String?
) : MfaAuthenticationMethod()

public data class TotpAuthenticationMethod(
@SerializedName("id") override val id: String,
@SerializedName("type") override val type: String,
@SerializedName("created_at") override val createdAt: String,
@SerializedName("usage") override val usage: List<String>,
@SerializedName("confirmed") override val confirmed: Boolean?,
@SerializedName("name")
public val name: String?
) : MfaAuthenticationMethod()

public sealed class WebAuthnAuthenticationMethod : MfaAuthenticationMethod() {
public abstract val name: String?
public abstract val keyId: String?
public abstract val publicKey: String?
}

public data class WebAuthnPlatformAuthenticationMethod(
@SerializedName("id") override val id: String,
@SerializedName("type") override val type: String,
@SerializedName("created_at") override val createdAt: String,
@SerializedName("usage") override val usage: List<String>,
@SerializedName("confirmed") override val confirmed: Boolean?,
@SerializedName("name") override val name: String?,
@SerializedName("key_id") override val keyId: String?,
@SerializedName("public_key") override val publicKey: String?
) : WebAuthnAuthenticationMethod()

public data class WebAuthnRoamingAuthenticationMethod(
@SerializedName("id") override val id: String,
@SerializedName("type") override val type: String,
@SerializedName("created_at") override val createdAt: String,
@SerializedName("usage") override val usage: List<String>,
@SerializedName("confirmed") override val confirmed: Boolean?,
@SerializedName("name") override val name: String?,
@SerializedName("key_id") override val keyId: String?,
@SerializedName("public_key") override val publicKey: String?
) : WebAuthnAuthenticationMethod()

public data class PhoneAuthenticationMethod(
@SerializedName("id") override val id: String,
@SerializedName("type") override val type: String,
@SerializedName("created_at") override val createdAt: String,
@SerializedName("usage") override val usage: List<String>,
@SerializedName("confirmed") override val confirmed: Boolean?,
@SerializedName("name")
public val name: String?,
@SerializedName("phone_number")
public val phoneNumber: String?,
@SerializedName("preferred_authentication_method")
public val preferredAuthenticationMethod: String?
) : MfaAuthenticationMethod()

public data class EmailAuthenticationMethod(
@SerializedName("id") override val id: String,
@SerializedName("type") override val type: String,
@SerializedName("created_at") override val createdAt: String,
@SerializedName("usage") override val usage: List<String>,
@SerializedName("confirmed") override val confirmed: Boolean?,
@SerializedName("name")
public val name: String?,
@SerializedName("email")
public val email: String?
) : MfaAuthenticationMethod()
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.auth0.android.result

import com.google.gson.JsonDeserializationContext
import com.google.gson.JsonDeserializer
import com.google.gson.JsonElement
import com.google.gson.annotations.JsonAdapter
import com.google.gson.annotations.SerializedName
import java.lang.reflect.Type

@JsonAdapter(EnrollmentChallenge.Deserializer::class)
public sealed class EnrollmentChallenge {
public abstract val id: String?
public abstract val authSession: String

internal class Deserializer : JsonDeserializer<EnrollmentChallenge> {
override fun deserialize(
json: JsonElement,
typeOfT: Type,
context: JsonDeserializationContext
): EnrollmentChallenge? {
val jsonObject = json.asJsonObject
val targetClass = when {
jsonObject.has("barcode_uri") -> TotpEnrollmentChallenge::class.java
jsonObject.has("recovery_code") -> RecoveryCodeEnrollmentChallenge::class.java
jsonObject.has("authn_params_public_key") -> PasskeyEnrollmentChallenge::class.java
else -> MfaEnrollmentChallenge::class.java
Comment thread
pmathew92 marked this conversation as resolved.
}
return context.deserialize(jsonObject, targetClass)
}
}
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Dismissed
}

public data class MfaEnrollmentChallenge(
@SerializedName("id")
override val id: String,
@SerializedName("auth_session")
override val authSession: String
) : EnrollmentChallenge()

public data class TotpEnrollmentChallenge(
@SerializedName("id")
override val id: String,
@SerializedName("auth_session")
override val authSession: String,
@SerializedName("barcode_uri")
public val barcodeUri: String,
@SerializedName("manual_input_code")
public val manualInputCode: String?
) : EnrollmentChallenge()

public data class RecoveryCodeEnrollmentChallenge(
@SerializedName("id")
override val id: String,
@SerializedName("auth_session")
override val authSession: String,
@SerializedName("recovery_code")
public val recoveryCode: String
) : EnrollmentChallenge()
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.auth0.android.result

import com.google.gson.annotations.SerializedName

/**
* Represents the payload for an enrollment request.
* This is a sealed class to handle different types of enrollment payloads.
*/
public sealed class EnrollmentPayload(
@SerializedName("type")
public open val type: String
)

public data class PasskeyEnrollmentPayload(
@SerializedName("connection")
public val connection: String?,
@SerializedName("identity_user_id")
public val identityUserId: String?
) : EnrollmentPayload("passkey")

public data class WebAuthnPlatformEnrollmentPayload(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can be a normal class ?

public class WebAuthnPlatformEnrollmentPayload() : EnrollmentPayload("webauthn-roaming") 

This way you don't have to add an empty placeholder for the data class

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

maintain consistency within the EnrollmentPayload sealed class hierarchy.

Copy link
Copy Markdown
Contributor

@pmathew92 pmathew92 Sep 4, 2025

Choose a reason for hiding this comment

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

normal class can also be part of sealed class ?

private val placeholder: String? = null
) : EnrollmentPayload("webauthn-platform")

public data class WebAuthnRoamingEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("webauthn-roaming")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

aintain consistency within the EnrollmentPayload sealed class hierarchy.


public data class TotpEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("totp")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

aintain consistency within the EnrollmentPayload sealed class hierarchy.


public data class PushNotificationEnrollmentPayload(
private val placeholder: String? = null
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

aintain consistency within the EnrollmentPayload sealed class hierarchy.

) : EnrollmentPayload("push-notification")

public data class RecoveryCodeEnrollmentPayload(
private val placeholder: String? = null
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

aintain consistency within the EnrollmentPayload sealed class hierarchy.

) : EnrollmentPayload("recovery-code")
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

Using placeholder parameters in data classes is not a good practice. Consider using object declarations for payload types that don't need additional properties, or remove these placeholder fields entirely.

Suggested change
) : EnrollmentPayload("recovery-code")
public object WebAuthnPlatformEnrollmentPayload : EnrollmentPayload("webauthn-platform")
public object WebAuthnRoamingEnrollmentPayload : EnrollmentPayload("webauthn-roaming")
public object TotpEnrollmentPayload : EnrollmentPayload("totp")
public object PushNotificationEnrollmentPayload : EnrollmentPayload("push-notification")
public object RecoveryCodeEnrollmentPayload : EnrollmentPayload("recovery-code")

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

Using placeholder parameters in data classes is not a good practice. Consider using object declarations for payload types that don't need additional properties, or remove these placeholder fields entirely.

Suggested change
) : EnrollmentPayload("recovery-code")
public object WebAuthnPlatformEnrollmentPayload : EnrollmentPayload("webauthn-platform")
public object WebAuthnRoamingEnrollmentPayload : EnrollmentPayload("webauthn-roaming")
public object TotpEnrollmentPayload : EnrollmentPayload("totp")
public object PushNotificationEnrollmentPayload : EnrollmentPayload("push-notification")
public object RecoveryCodeEnrollmentPayload : EnrollmentPayload("recovery-code")

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

Using placeholder parameters in data classes is not a good practice. Consider using object declarations for payload types that don't need additional properties, or remove these placeholder fields entirely.

Suggested change
) : EnrollmentPayload("recovery-code")
public object WebAuthnPlatformEnrollmentPayload : EnrollmentPayload("webauthn-platform")
public object WebAuthnRoamingEnrollmentPayload : EnrollmentPayload("webauthn-roaming")
public object TotpEnrollmentPayload : EnrollmentPayload("totp")
public object PushNotificationEnrollmentPayload : EnrollmentPayload("push-notification")
public object RecoveryCodeEnrollmentPayload : EnrollmentPayload("recovery-code")

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

Using placeholder parameters in data classes is not a good practice. Consider using object declarations for payload types that don't need additional properties, or remove these placeholder fields entirely.

Suggested change
) : EnrollmentPayload("recovery-code")
public object WebAuthnPlatformEnrollmentPayload : EnrollmentPayload("webauthn-platform")
public object WebAuthnRoamingEnrollmentPayload : EnrollmentPayload("webauthn-roaming")
public object TotpEnrollmentPayload : EnrollmentPayload("totp")
public object PushNotificationEnrollmentPayload : EnrollmentPayload("push-notification")
public object RecoveryCodeEnrollmentPayload : EnrollmentPayload("recovery-code")

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

Using placeholder parameters in data classes is not a good practice. Consider using object declarations for payload types that don't need additional properties, or remove these placeholder fields entirely.

Suggested change
) : EnrollmentPayload("recovery-code")
public object WebAuthnPlatformEnrollmentPayload : EnrollmentPayload("webauthn-platform")
public object WebAuthnRoamingEnrollmentPayload : EnrollmentPayload("webauthn-roaming")
public object TotpEnrollmentPayload : EnrollmentPayload("totp")
public object PushNotificationEnrollmentPayload : EnrollmentPayload("push-notification")
public object RecoveryCodeEnrollmentPayload : EnrollmentPayload("recovery-code")

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

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

[nitpick] Multiple classes use identical placeholder properties that serve no functional purpose. Consider using object declarations instead of data classes for payload types that don't require additional properties, or remove the placeholder entirely if not needed for serialization.

Suggested change
public data class WebAuthnPlatformEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("webauthn-platform")
public data class WebAuthnRoamingEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("webauthn-roaming")
public data class TotpEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("totp")
public data class PushNotificationEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("push-notification")
public data class RecoveryCodeEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("recovery-code")
public object WebAuthnPlatformEnrollmentPayload : EnrollmentPayload("webauthn-platform")
public object WebAuthnRoamingEnrollmentPayload : EnrollmentPayload("webauthn-roaming")
public object TotpEnrollmentPayload : EnrollmentPayload("totp")
public object PushNotificationEnrollmentPayload : EnrollmentPayload("push-notification")
public object RecoveryCodeEnrollmentPayload : EnrollmentPayload("recovery-code")

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

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

[nitpick] Multiple classes use identical placeholder properties that serve no functional purpose. Consider using object declarations instead of data classes for payload types that don't require additional properties, or remove the placeholder entirely if not needed for serialization.

Suggested change
public data class WebAuthnPlatformEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("webauthn-platform")
public data class WebAuthnRoamingEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("webauthn-roaming")
public data class TotpEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("totp")
public data class PushNotificationEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("push-notification")
public data class RecoveryCodeEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("recovery-code")
public object WebAuthnPlatformEnrollmentPayload : EnrollmentPayload("webauthn-platform")
public object WebAuthnRoamingEnrollmentPayload : EnrollmentPayload("webauthn-roaming")
public object TotpEnrollmentPayload : EnrollmentPayload("totp")
public object PushNotificationEnrollmentPayload : EnrollmentPayload("push-notification")
public object RecoveryCodeEnrollmentPayload : EnrollmentPayload("recovery-code")

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

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

[nitpick] Multiple classes use identical placeholder properties that serve no functional purpose. Consider using object declarations instead of data classes for payload types that don't require additional properties, or remove the placeholder entirely if not needed for serialization.

Suggested change
public data class WebAuthnPlatformEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("webauthn-platform")
public data class WebAuthnRoamingEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("webauthn-roaming")
public data class TotpEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("totp")
public data class PushNotificationEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("push-notification")
public data class RecoveryCodeEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("recovery-code")
public object WebAuthnPlatformEnrollmentPayload : EnrollmentPayload("webauthn-platform")
public object WebAuthnRoamingEnrollmentPayload : EnrollmentPayload("webauthn-roaming")
public object TotpEnrollmentPayload : EnrollmentPayload("totp")
public object PushNotificationEnrollmentPayload : EnrollmentPayload("push-notification")
public object RecoveryCodeEnrollmentPayload : EnrollmentPayload("recovery-code")

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

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

[nitpick] Multiple classes use identical placeholder properties that serve no functional purpose. Consider using object declarations instead of data classes for payload types that don't require additional properties, or remove the placeholder entirely if not needed for serialization.

Suggested change
public data class WebAuthnPlatformEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("webauthn-platform")
public data class WebAuthnRoamingEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("webauthn-roaming")
public data class TotpEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("totp")
public data class PushNotificationEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("push-notification")
public data class RecoveryCodeEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("recovery-code")
public object WebAuthnPlatformEnrollmentPayload : EnrollmentPayload("webauthn-platform")
public object WebAuthnRoamingEnrollmentPayload : EnrollmentPayload("webauthn-roaming")
public object TotpEnrollmentPayload : EnrollmentPayload("totp")
public object PushNotificationEnrollmentPayload : EnrollmentPayload("push-notification")
public object RecoveryCodeEnrollmentPayload : EnrollmentPayload("recovery-code")

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

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

[nitpick] Multiple classes use identical placeholder properties that serve no functional purpose. Consider using object declarations instead of data classes for payload types that don't require additional properties, or remove the placeholder entirely if not needed for serialization.

Suggested change
public data class WebAuthnPlatformEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("webauthn-platform")
public data class WebAuthnRoamingEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("webauthn-roaming")
public data class TotpEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("totp")
public data class PushNotificationEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("push-notification")
public data class RecoveryCodeEnrollmentPayload(
private val placeholder: String? = null
) : EnrollmentPayload("recovery-code")
public object WebAuthnPlatformEnrollmentPayload : EnrollmentPayload("webauthn-platform")
public object WebAuthnRoamingEnrollmentPayload : EnrollmentPayload("webauthn-roaming")
public object TotpEnrollmentPayload : EnrollmentPayload("totp")
public object PushNotificationEnrollmentPayload : EnrollmentPayload("push-notification")
public object RecoveryCodeEnrollmentPayload : EnrollmentPayload("recovery-code")

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done


public data class EmailEnrollmentPayload(
@SerializedName("email")
public val email: String
) : EnrollmentPayload("email")

public data class PhoneEnrollmentPayload(
@SerializedName("phone_number")
public val phoneNumber: String,
@SerializedName("preferred_authentication_method")
public val preferredAuthenticationMethod: String
) : EnrollmentPayload("phone")
33 changes: 33 additions & 0 deletions auth0/src/main/java/com/auth0/android/result/ErrorResponse.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.auth0.android.result

import com.google.gson.annotations.SerializedName

/**
* Represents a standardized error response from the My Account API.
*/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

these are already defined in the MyAccountException class . What is the need to redefine this ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  1. ErrorResponse: This class is a pure Data Transfer Object (DTO). Its structure is a direct 1-to-1 mapping of the JSON error payload defined in the OpenAPI specification. It represents the raw error data from the server.
  2. MyAccountException: This is the actual exception class that our SDK uses to signal a failure to the developer. It consumes the data from the error response but also adds SDK-specific context, like the ability to wrap an underlying cause (e.g., a network error).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes I understand that. What I meant is ,the error you receive from the API is mapped to MyAccountException in the network layer. The above parameters are already defined in that class which the user can access . I also don't see any usage of this class also in the code. So delete it ,if not being used

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed [ErrorResponse.kt]

public data class ErrorResponse(
@SerializedName("type")
val type: String,
@SerializedName("status")
val status: Int,
@SerializedName("title")
val title: String,
@SerializedName("detail")
val detail: String,
@SerializedName("validation_errors")
val validationErrors: List<ValidationError>?
) {
/**
* Represents a specific validation error within an error response.
*/
public data class ValidationError(
@SerializedName("detail")
val detail: String,
@SerializedName("field")
val field: String?,
@SerializedName("pointer")
val pointer: String?,
@SerializedName("source")
val source: String?
)
}
10 changes: 10 additions & 0 deletions auth0/src/main/java/com/auth0/android/result/Factor.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.auth0.android.result

import com.google.gson.annotations.SerializedName

Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

The Factor class lacks documentation. Public data classes should have KDoc comments explaining their purpose and properties.

Suggested change
/**
* Represents a multi-factor authentication factor.
*
* @property type The type of factor (e.g., "totp", "sms", etc.).
* @property usage The usages supported by this factor (e.g., "authentication", "recovery"). May be null.
*/

Copilot uses AI. Check for mistakes.
public data class Factor(
@SerializedName("type")
public val type: String,
@SerializedName("usage")
public val usage: List<String>?
)
11 changes: 11 additions & 0 deletions auth0/src/main/java/com/auth0/android/result/Factors.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.auth0.android.result

import com.google.gson.annotations.SerializedName

/**
* A wrapper class for the list of factors returned by the API.
*/
public data class Factors(
@SerializedName("factors")
public val factors: List<Factor>
)

This file was deleted.

Loading