From cef4b965b9f51a28a213c944e02551fd9f610e8d Mon Sep 17 00:00:00 2001 From: Jordan Haven Date: Mon, 7 Oct 2024 12:13:04 -0400 Subject: [PATCH 1/2] Add missing B2B OAuth providers --- .../sdk/b2b/network/models/B2BResponseData.kt | 61 ++++++++++++++++++- .../stytch/sdk/b2b/network/models/Enums.kt | 15 ++++- .../java/com/stytch/sdk/b2b/oauth/OAuth.kt | 15 +++++ .../com/stytch/sdk/b2b/oauth/OAuthImpl.kt | 3 + 4 files changed, 89 insertions(+), 5 deletions(-) diff --git a/source/sdk/src/main/java/com/stytch/sdk/b2b/network/models/B2BResponseData.kt b/source/sdk/src/main/java/com/stytch/sdk/b2b/network/models/B2BResponseData.kt index e1aaf3697..2a32431c8 100644 --- a/source/sdk/src/main/java/com/stytch/sdk/b2b/network/models/B2BResponseData.kt +++ b/source/sdk/src/main/java/com/stytch/sdk/b2b/network/models/B2BResponseData.kt @@ -4,7 +4,6 @@ import android.os.Parcelable import androidx.annotation.Keep import com.squareup.moshi.Json import com.squareup.moshi.JsonClass -import com.stytch.sdk.common.network.models.AuthenticationFactor import com.stytch.sdk.common.network.models.CommonAuthenticationData import com.stytch.sdk.common.network.models.IBasicData import kotlinx.parcelize.Parcelize @@ -134,7 +133,7 @@ public data class B2BSessionData( @Json(name = "expires_at") val expiresAt: String, @Json(name = "authentication_factors") - val authenticationFactors: List, + val authenticationFactors: List, @Json(name = "custom_claims") val customClaims: @RawValue Map?, val roles: List, @@ -1206,3 +1205,61 @@ public data class B2BSCIMRotateCancelResponseData( val connection: SCIMConnection, ) : IBasicData, Parcelable + +@Keep +@JsonClass(generateAdapter = true) +@Parcelize +public data class B2BAuthenticationFactor( + @Json(name = "delivery_method") + val deliveryMethod: String, + val type: String, + @Json(name = "last_authenticated_at") + val lastAuthenticatedAt: String, + @Json(name = "email_factor") + val emailFactor: EmailFactor?, + @Json(name = "phone_number_factor") + val phoneFactor: PhoneFactor?, + @Json(name = "google_oauth_factor") + val googleOAuthFactor: OAuthFactor?, + @Json(name = "microsoft_oauth_factor") + val microsoftOAuthFactor: OAuthFactor?, + @Json(name = "github_oauth_factor") + val githubOAuthFactor: OAuthFactor?, + @Json(name = "hubspot_oauth_factor") + val hubspotOAuthFactor: OAuthFactor?, + @Json(name = "slack_oauth_factor") + val slackOAuthFactor: OAuthFactor?, +) : Parcelable { + @Keep + @JsonClass(generateAdapter = true) + @Parcelize + public data class EmailFactor( + @Json(name = "email_id") + val emailId: String, + @Json(name = "email_address") + val emailAddress: String, + ) : Parcelable + + @Keep + @JsonClass(generateAdapter = true) + @Parcelize + public data class PhoneFactor( + @Json(name = "phone_id") + val phoneId: String, + @Json(name = "phone_number") + val phoneNumber: String, + ) : Parcelable + + @Keep + @JsonClass(generateAdapter = true) + @Parcelize + public data class OAuthFactor( + val id: String, + @Json(name = "email_id") + val emailId: String? = null, + @Json(name = "provider_subject") + val providerSubject: String, + @Json(name = "provider_tenant_id") + val providerTenantId: String? = null, + ) : Parcelable +} diff --git a/source/sdk/src/main/java/com/stytch/sdk/b2b/network/models/Enums.kt b/source/sdk/src/main/java/com/stytch/sdk/b2b/network/models/Enums.kt index 761f13358..7ece2526e 100644 --- a/source/sdk/src/main/java/com/stytch/sdk/b2b/network/models/Enums.kt +++ b/source/sdk/src/main/java/com/stytch/sdk/b2b/network/models/Enums.kt @@ -42,16 +42,23 @@ public enum class MfaPolicy { } @JsonClass(generateAdapter = false) -public enum class AllowedAuthMethods(override val jsonName: String) : IEnumValue { +public enum class AllowedAuthMethods( + override val jsonName: String, +) : IEnumValue { SSO("sso"), MAGIC_LINK("magic_link"), PASSWORD("password"), GOOGLE_OAUTH("google_oauth"), MICROSOFT_OAUTH("microsoft_oauth"), + HUBSPOT_OAUTH("hubspot_oauth"), + GITHUB_OAUTH("github_oauth"), + SLACK_OAUTH("slack_oauth"), } @JsonClass(generateAdapter = false) -public enum class MfaMethod(override val jsonName: String) : IEnumValue { +public enum class MfaMethod( + override val jsonName: String, +) : IEnumValue { SMS("sms_otp"), TOTP("totp"), } @@ -63,7 +70,9 @@ public enum class SearchOperator { } @JsonClass(generateAdapter = false) -public enum class SetMFAEnrollment(override val jsonName: String) : IEnumValue { +public enum class SetMFAEnrollment( + override val jsonName: String, +) : IEnumValue { ENROLL("enroll"), UNENROLL("unenroll"), } diff --git a/source/sdk/src/main/java/com/stytch/sdk/b2b/oauth/OAuth.kt b/source/sdk/src/main/java/com/stytch/sdk/b2b/oauth/OAuth.kt index fdc4f030f..6155b8d06 100644 --- a/source/sdk/src/main/java/com/stytch/sdk/b2b/oauth/OAuth.kt +++ b/source/sdk/src/main/java/com/stytch/sdk/b2b/oauth/OAuth.kt @@ -145,6 +145,21 @@ public interface OAuth { */ public val microsoft: Provider + /** + * Exposes an instance of the HubSpot OAuth implementation + */ + public val hubspot: Provider + + /** + * Exposes an instance of the Slack OAuth implementation + */ + public val slack: Provider + + /** + * Exposes an instance of the GitHub OAuth implementation + */ + public val github: Provider + /** * Exposes an instance of the Discovery OAuth implementation */ diff --git a/source/sdk/src/main/java/com/stytch/sdk/b2b/oauth/OAuthImpl.kt b/source/sdk/src/main/java/com/stytch/sdk/b2b/oauth/OAuthImpl.kt index b65b8d07d..63aa16dee 100644 --- a/source/sdk/src/main/java/com/stytch/sdk/b2b/oauth/OAuthImpl.kt +++ b/source/sdk/src/main/java/com/stytch/sdk/b2b/oauth/OAuthImpl.kt @@ -30,6 +30,9 @@ internal class OAuthImpl( ) : OAuth { override val google: OAuth.Provider = ProviderImpl("google") override val microsoft: OAuth.Provider = ProviderImpl("microsoft") + override val hubspot: OAuth.Provider = ProviderImpl("hubspot") + override val slack: OAuth.Provider = ProviderImpl("slack") + override val github: OAuth.Provider = ProviderImpl("github") override val discovery: OAuth.Discovery = DiscoveryImpl() override suspend fun authenticate(parameters: OAuth.AuthenticateParameters): OAuthAuthenticateResponse { From 248f5e2f3140e60de5ae63193598888558e0f432 Mon Sep 17 00:00:00 2001 From: Jordan Haven Date: Mon, 7 Oct 2024 12:13:57 -0400 Subject: [PATCH 2/2] Bump version --- source/sdk/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/sdk/build.gradle b/source/sdk/build.gradle index 55c27497c..b9e291334 100644 --- a/source/sdk/build.gradle +++ b/source/sdk/build.gradle @@ -10,7 +10,7 @@ plugins { ext { PUBLISH_GROUP_ID = 'com.stytch.sdk' - PUBLISH_VERSION = '0.27.1' + PUBLISH_VERSION = '0.28.0' PUBLISH_ARTIFACT_ID = 'sdk' }