Skip to content

Commit

Permalink
Fail active liveness after timeout (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanshg authored Jun 18, 2024
1 parent bf4116c commit d2038e3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
12 changes: 12 additions & 0 deletions lib/src/main/java/com/smileidentity/models/v2/FailureReason.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.smileidentity.models.v2

import android.os.Parcelable
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import kotlinx.parcelize.Parcelize

@Parcelize
@JsonClass(generateAdapter = true)
data class FailureReason(
@Json(name = "mobile_active_liveness_timed_out") val activeLivenessTimedOut: Boolean? = null,
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.smileidentity.models.SubmitBvnTotpRequest
import com.smileidentity.models.SubmitBvnTotpResponse
import com.smileidentity.models.UploadRequest
import com.smileidentity.models.ValidDocumentsResponse
import com.smileidentity.models.v2.FailureReason
import com.smileidentity.models.v2.Metadata
import com.smileidentity.models.v2.SmartSelfieResponse
import java.io.File
Expand Down Expand Up @@ -86,6 +87,7 @@ interface SmileIDService {
@Part("user_id") userId: String? = null,
@Part("partner_params")
partnerParams: Map<@JvmSuppressWildcards String, @JvmSuppressWildcards String>? = null,
@Part("failure_reason") failureReason: FailureReason? = null,
@Part("callback_url") callbackUrl: String? = SmileID.callbackUrl.ifBlank { null },
@Part("sandbox_result") sandboxResult: Int? = null,
@Part("allow_new_enroll") allowNewEnroll: Boolean? = null,
Expand All @@ -110,6 +112,7 @@ interface SmileIDService {
@Part livenessImages: List<@JvmSuppressWildcards MultipartBody.Part>,
@Part("partner_params")
partnerParams: Map<@JvmSuppressWildcards String, @JvmSuppressWildcards String>? = null,
@Part("failure_reason") failureReason: FailureReason? = null,
@Part("callback_url") callbackUrl: String? = SmileID.callbackUrl.ifBlank { null },
@Part("sandbox_result") sandboxResult: Int? = null,
@Part("metadata") metadata: Metadata? = Metadata.default(),
Expand Down Expand Up @@ -230,6 +233,7 @@ suspend fun SmileIDService.doSmartSelfieEnrollment(
livenessImages: List<File>,
userId: String? = null,
partnerParams: Map<String, String>? = null,
failureReason: FailureReason? = null,
callbackUrl: String? = SmileID.callbackUrl.ifBlank { null },
sandboxResult: Int? = null,
allowNewEnroll: Boolean? = null,
Expand All @@ -239,6 +243,7 @@ suspend fun SmileIDService.doSmartSelfieEnrollment(
livenessImages = livenessImages.asFormDataParts("liveness_images", "image/jpeg"),
userId = userId,
partnerParams = partnerParams,
failureReason = failureReason,
callbackUrl = callbackUrl,
sandboxResult = sandboxResult,
allowNewEnroll = allowNewEnroll,
Expand All @@ -262,6 +267,7 @@ suspend fun SmileIDService.doSmartSelfieAuthentication(
selfieImage: File,
livenessImages: List<File>,
partnerParams: Map<String, String>? = null,
failureReason: FailureReason? = null,
callbackUrl: String? = SmileID.callbackUrl.ifBlank { null },
sandboxResult: Int? = null,
metadata: Metadata? = Metadata.default(),
Expand All @@ -270,6 +276,7 @@ suspend fun SmileIDService.doSmartSelfieAuthentication(
selfieImage = selfieImage.asFormDataPart("selfie_image", "image/jpeg"),
livenessImages = livenessImages.asFormDataParts("liveness_images", "image/jpeg"),
partnerParams = partnerParams,
failureReason = failureReason,
callbackUrl = callbackUrl,
sandboxResult = sandboxResult,
metadata = metadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.smileidentity.R
import com.smileidentity.SmileID
import com.smileidentity.SmileIDCrashReporting
import com.smileidentity.ml.SelfieQualityModel
import com.smileidentity.models.v2.FailureReason
import com.smileidentity.models.v2.SmartSelfieResponse
import com.smileidentity.networking.doSmartSelfieAuthentication
import com.smileidentity.networking.doSmartSelfieEnrollment
Expand Down Expand Up @@ -555,6 +556,7 @@ class SmartSelfieV2ViewModel(
livenessImages = livenessFiles,
allowNewEnroll = allowNewEnroll,
partnerParams = extraPartnerParams,
failureReason = FailureReason(activeLivenessTimedOut = forcedFailureTimerExpired),
metadata = null,
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class MainScreenViewModel : ViewModel() {
partnerId = SmileID.config.partnerId,
isProduction = uiState.value.isProduction,
job = Job(
jobType = SmartSelfieAuthentication,
jobType = SmartSelfieEnrollment,
timestamp = response.createdAt,
userId = response.userId,
jobId = response.jobId,
Expand All @@ -349,7 +349,7 @@ class MainScreenViewModel : ViewModel() {
}
} else if (result is SmileIDResult.Error) {
val th = result.throwable
val message = "SmartSelfie Authentication error: ${th.message}"
val message = "SmartSelfie Enrollment error: ${th.message}"
Timber.e(th, message)
_uiState.update { it.copy(snackbarMessage = message) }
}
Expand Down

0 comments on commit d2038e3

Please sign in to comment.