-
Notifications
You must be signed in to change notification settings - Fork 165
SDK-6103 Added support for My Account API. #847
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
Changes from all commits
c8243e3
58ebd47
c0703ad
a702900
13da6ba
c42e67f
eddddc0
25b4e13
6ae1fe1
93c507b
5a71404
db02f71
bb3adc3
4689ff3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.auth0.android.myaccount | ||
|
|
||
| /** | ||
| * Represents the preferred method for phone-based multi-factor authentication, either "sms" or "voice". | ||
| * This is used when enrolling a new phone factor or updating an existing one. | ||
| */ | ||
| public enum class PhoneAuthenticationMethodType(public val value: String) { | ||
| SMS("sms"), | ||
| VOICE("voice") | ||
| } | ||
| 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) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| 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 | ||
pmathew92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| return context.deserialize(jsonObject, targetClass) | ||
| } | ||
| } | ||
github-advanced-security[bot] marked this conversation as resolved.
Dismissed
Show dismissed
Hide 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,41 @@ | ||
| 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 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") | ||
|
|
||
| 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") |
| 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 | ||||||||||||||||||
|
|
||||||||||||||||||
|
||||||||||||||||||
| /** | |
| * 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. | |
| */ |
| 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.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,11 @@ | ||
| package com.auth0.android.result | ||
|
|
||
| import com.google.gson.annotations.SerializedName | ||
|
|
||
| /** | ||
| * Represents the challenge data required for enrolling a passkey. | ||
| * A passkey enrollment challenge, combining the authentication method ID from the response headers | ||
| * with the challenge details from the response body. | ||
| */ | ||
| public data class PasskeyEnrollmentChallenge( | ||
| val authenticationMethodId: String, | ||
| @SerializedName("auth_session") | ||
| val authSession: String, | ||
| @SerializedName("authn_params_public_key") | ||
| val authParamsPublicKey: AuthnParamsPublicKey | ||
| ) | ||
| public val authenticationMethodId: String, | ||
| public val authSession: String, | ||
| public val authParamsPublicKey: AuthnParamsPublicKey | ||
pmathew92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
| 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 | ||
|
|
||
| /** | ||
| * Represents the payload for a verification request, such as providing an OTP code. | ||
| */ | ||
| public data class VerifyOtpPayload( | ||
| @SerializedName("otp_code") | ||
| public val otpCode: String | ||
| ) |
Uh oh!
There was an error while loading. Please reload this page.