Skip to content

Commit

Permalink
Added allowNewEnroll on SmartSelfie, Biometric, DocV and EnhancedDocV (
Browse files Browse the repository at this point in the history
…#285)

* added allowNewEnroll on SmartSelfie, Biometric, DocV and EnhancedDocV

* updated CHANGELOG.md

* removed hardcoded user id

* added TODO

* fixed broken tests
  • Loading branch information
jumaallan authored Dec 26, 2023
1 parent 520af73 commit 89033d9
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Unreleased

## 10.0.3

## 10.0.2

### Added
- Added `allowNewEnroll` on SmartSelfie, BiometricKYC, DocV and EnhancedDocV

## 10.0.1

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class OrchestratedDocumentVerificationScreenTest {
jobType = JobType.DocumentVerification,
userId = randomUserId(),
jobId = randomUserId(),
allowNewEnroll = false,
countryCode = "254",
documentType = "NATIONAL_ID",
captureBothSides = false,
Expand All @@ -48,6 +49,7 @@ class OrchestratedDocumentVerificationScreenTest {
jobType = JobType.DocumentVerification,
userId = randomUserId(),
jobId = randomUserId(),
allowNewEnroll = false,
countryCode = "254",
documentType = "NATIONAL_ID",
captureBothSides = false,
Expand Down
11 changes: 11 additions & 0 deletions lib/src/main/java/com/smileidentity/compose/SmileIDExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import java.net.URL
* @param jobId The job ID to associate with the SmartSelfie™ Enrollment. Most often, this
* will correspond to a unique Job ID within your own system. If not provided, a random job ID
* will be generated.
* @param allowNewEnroll Allows a partner to enroll the same user id again
* @param allowAgentMode Whether to allow Agent Mode or not. If allowed, a switch will be
* displayed allowing toggling between the back camera and front camera. If not allowed, only the
* front camera will be used.
Expand All @@ -63,6 +64,7 @@ fun SmileID.SmartSelfieEnrollment(
modifier: Modifier = Modifier,
userId: String = rememberSaveable { randomUserId() },
jobId: String = rememberSaveable { randomJobId() },
allowNewEnroll: Boolean = false,
allowAgentMode: Boolean = false,
showAttribution: Boolean = true,
showInstructions: Boolean = true,
Expand All @@ -76,6 +78,7 @@ fun SmileID.SmartSelfieEnrollment(
modifier = modifier,
userId = userId,
jobId = jobId,
allowNewEnroll = allowNewEnroll,
isEnroll = true,
allowAgentMode = allowAgentMode,
showAttribution = showAttribution,
Expand Down Expand Up @@ -114,6 +117,7 @@ fun SmileID.SmartSelfieAuthentication(
userId: String,
modifier: Modifier = Modifier,
jobId: String = rememberSaveable { randomJobId() },
allowNewEnroll: Boolean = false,
allowAgentMode: Boolean = false,
showAttribution: Boolean = true,
showInstructions: Boolean = true,
Expand All @@ -127,6 +131,7 @@ fun SmileID.SmartSelfieAuthentication(
modifier = modifier,
userId = userId,
jobId = jobId,
allowNewEnroll = allowNewEnroll,
isEnroll = false,
allowAgentMode = allowAgentMode,
showAttribution = showAttribution,
Expand Down Expand Up @@ -181,6 +186,7 @@ fun SmileID.DocumentVerification(
bypassSelfieCaptureWithFile: File? = null,
userId: String = rememberSaveable { randomUserId() },
jobId: String = rememberSaveable { randomJobId() },
allowNewEnroll: Boolean = false,
showAttribution: Boolean = true,
allowAgentMode: Boolean = false,
allowGalleryUpload: Boolean = false,
Expand Down Expand Up @@ -208,6 +214,7 @@ fun SmileID.DocumentVerification(
jobType = JobType.DocumentVerification,
userId = userId,
jobId = jobId,
allowNewEnroll = allowNewEnroll,
countryCode = countryCode,
documentType = documentType,
captureBothSides = captureBothSides,
Expand Down Expand Up @@ -262,6 +269,7 @@ fun SmileID.EnhancedDocumentVerificationScreen(
idAspectRatio: Float? = null,
userId: String = rememberSaveable { randomUserId() },
jobId: String = rememberSaveable { randomJobId() },
allowNewEnroll: Boolean = false,
showAttribution: Boolean = true,
allowAgentMode: Boolean = false,
allowGalleryUpload: Boolean = false,
Expand Down Expand Up @@ -289,6 +297,7 @@ fun SmileID.EnhancedDocumentVerificationScreen(
jobType = JobType.EnhancedDocumentVerification,
userId = userId,
jobId = jobId,
allowNewEnroll = allowNewEnroll,
countryCode = countryCode,
documentType = documentType,
captureBothSides = captureBothSides,
Expand Down Expand Up @@ -330,6 +339,7 @@ fun SmileID.BiometricKYC(
modifier: Modifier = Modifier,
userId: String = rememberSaveable { randomUserId() },
jobId: String = rememberSaveable { randomJobId() },
allowNewEnroll: Boolean = false,
allowAgentMode: Boolean = false,
showAttribution: Boolean = true,
showInstructions: Boolean = true,
Expand All @@ -344,6 +354,7 @@ fun SmileID.BiometricKYC(
idInfo = idInfo,
userId = userId,
jobId = jobId,
allowNewEnroll = allowNewEnroll,
allowAgentMode = allowAgentMode,
showAttribution = showAttribution,
showInstructions = showInstructions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fun OrchestratedBiometricKYCScreen(
modifier: Modifier = Modifier,
userId: String = rememberSaveable { randomUserId() },
jobId: String = rememberSaveable { randomJobId() },
allowNewEnroll: Boolean = false,
allowAgentMode: Boolean = false,
showAttribution: Boolean = true,
showInstructions: Boolean = true,
Expand All @@ -43,6 +44,7 @@ fun OrchestratedBiometricKYCScreen(
idInfo = idInfo,
userId = userId,
jobId = jobId,
allowNewEnroll = allowNewEnroll,
extraPartnerParams = extraPartnerParams,
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ internal fun OrchestratedSelfieCaptureScreen(
modifier: Modifier = Modifier,
userId: String = rememberSaveable { randomUserId() },
jobId: String = rememberSaveable { randomJobId() },
allowNewEnroll: Boolean = false,
isEnroll: Boolean = true,
allowAgentMode: Boolean = false,
skipApiSubmission: Boolean = false,
Expand All @@ -52,6 +53,7 @@ internal fun OrchestratedSelfieCaptureScreen(
isEnroll = isEnroll,
userId = userId,
jobId = jobId,
allowNewEnroll = allowNewEnroll,
skipApiSubmission = skipApiSubmission,
extraPartnerParams = extraPartnerParams,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,20 @@ import com.ujizin.camposer.state.rememberImageAnalyzer
internal fun SelfieCaptureScreen(
userId: String = rememberSaveable { randomUserId() },
jobId: String = rememberSaveable { randomJobId() },
allowNewEnroll: Boolean = false,
isEnroll: Boolean = true,
allowAgentMode: Boolean = true,
skipApiSubmission: Boolean = false,
viewModel: SelfieViewModel = viewModel(
factory = viewModelFactory { SelfieViewModel(isEnroll, userId, jobId, skipApiSubmission) },
factory = viewModelFactory {
SelfieViewModel(
isEnroll = isEnroll,
userId = userId,
jobId = jobId,
allowNewEnroll = allowNewEnroll,
skipApiSubmission = skipApiSubmission,
)
},
),
) {
val uiState = viewModel.uiState.collectAsStateWithLifecycle().value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class BiometricKYCFragment : Fragment() {
@DrawableRes partnerIcon: Int,
userId: String = randomUserId(),
jobId: String = randomJobId(),
allowNewEnroll: Boolean = false,
allowAgentMode: Boolean = false,
showAttribution: Boolean = true,
showInstructions: Boolean = true,
Expand All @@ -84,6 +85,7 @@ class BiometricKYCFragment : Fragment() {
this.idInfo = idInfo
this.userId = userId
this.jobId = jobId
this.allowNewEnroll = allowNewEnroll
this.allowAgentMode = allowAgentMode
this.showAttribution = showAttribution
this.showInstructions = showInstructions
Expand All @@ -109,6 +111,7 @@ class BiometricKYCFragment : Fragment() {
idInfo = args.idInfo,
userId = args.userId,
jobId = args.jobId,
allowNewEnroll = args.allowNewEnroll,
allowAgentMode = args.allowAgentMode,
showAttribution = args.showAttribution,
showInstructions = args.showInstructions,
Expand Down Expand Up @@ -136,6 +139,11 @@ private var Bundle.jobId: String
get() = getString(KEY_JOB_ID)!!
set(value) = putString(KEY_JOB_ID, value)

private const val KEY_ALLOW_NEW_ENROLL = "allowNewEnroll"
private var Bundle.allowNewEnroll: Boolean
get() = getBoolean(KEY_ALLOW_NEW_ENROLL)
set(value) = putBoolean(KEY_ALLOW_NEW_ENROLL, value)

private const val KEY_SHOW_ATTRIBUTION = "showAttribution"
private var Bundle.showAttribution: Boolean
get() = getBoolean(KEY_SHOW_ATTRIBUTION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class DocumentVerificationFragment : Fragment() {
documentType: String? = null,
userId: String = randomUserId(),
jobId: String = randomJobId(),
allowNewEnroll: Boolean = false,
showAttribution: Boolean = true,
allowAgentMode: Boolean = false,
allowGalleryUpload: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class EnhancedDocumentVerificationFragment : Fragment() {
documentType: String? = null,
userId: String = randomUserId(),
jobId: String = randomJobId(),
allowNewEnroll: Boolean = false,
showAttribution: Boolean = true,
allowAgentMode: Boolean = false,
allowGalleryUpload: Boolean = false,
Expand All @@ -81,6 +82,7 @@ class EnhancedDocumentVerificationFragment : Fragment() {
arguments = Bundle().apply {
this.userId = userId
this.jobId = jobId
this.allowNewEnroll = allowNewEnroll
this.showAttribution = showAttribution
this.allowAgentMode = allowAgentMode
this.allowGalleryUpload = allowGalleryUpload
Expand Down Expand Up @@ -113,6 +115,7 @@ class EnhancedDocumentVerificationFragment : Fragment() {
documentType = args.documentType,
userId = args.userId,
jobId = args.jobId,
allowNewEnroll = args.allowNewEnroll,
showAttribution = args.showAttribution,
allowAgentMode = args.allowAgentMode,
allowGalleryUpload = args.allowGalleryUpload,
Expand All @@ -137,6 +140,11 @@ private var Bundle.jobId: String
get() = getString(KEY_JOB_ID)!!
set(value) = putString(KEY_JOB_ID, value)

private const val KEY_ALLOW_NEW_ENROLL = "allowNewEnroll"
private var Bundle.allowNewEnroll: Boolean
get() = getBoolean(KEY_ALLOW_NEW_ENROLL)
set(value) = putBoolean(KEY_ALLOW_NEW_ENROLL, value)

private const val KEY_SHOW_ATTRIBUTION = "showAttribution"
private var Bundle.showAttribution: Boolean
get() = getBoolean(KEY_SHOW_ATTRIBUTION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class SmartSelfieAuthenticationFragment : Fragment() {
fun newInstance(
userId: String = randomUserId(),
jobId: String = randomJobId(),
allowNewEnroll: Boolean = false,
allowAgentMode: Boolean = false,
showAttribution: Boolean = true,
showInstructions: Boolean = true,
Expand All @@ -88,6 +89,7 @@ class SmartSelfieAuthenticationFragment : Fragment() {
arguments = Bundle().apply {
this.userId = userId
this.jobId = jobId
this.allowNewEnroll = allowNewEnroll
this.allowAgentMode = allowAgentMode
this.showAttribution = showAttribution
this.showInstructions = showInstructions
Expand All @@ -112,6 +114,7 @@ class SmartSelfieAuthenticationFragment : Fragment() {
SmileID.SmartSelfieAuthentication(
userId = args.userId,
jobId = args.jobId,
allowNewEnroll = args.allowNewEnroll,
allowAgentMode = args.allowAgentMode,
showAttribution = args.showAttribution,
showInstructions = args.showInstructions,
Expand Down Expand Up @@ -139,6 +142,11 @@ private var Bundle.jobId: String
get() = getString(KEY_JOB_ID)!!
set(value) = putString(KEY_JOB_ID, value)

private const val KEY_ALLOW_NEW_ENROLL = "allowNewEnroll"
private var Bundle.allowNewEnroll: Boolean
get() = getBoolean(KEY_ALLOW_NEW_ENROLL)
set(value) = putBoolean(KEY_ALLOW_NEW_ENROLL, value)

private const val KEY_SHOW_ATTRIBUTION = "showAttribution"
private var Bundle.showAttribution: Boolean
get() = getBoolean(KEY_SHOW_ATTRIBUTION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class SmartSelfieEnrollmentFragment : Fragment() {
fun newInstance(
userId: String = randomUserId(),
jobId: String = randomJobId(),
allowNewEnroll: Boolean = false,
allowAgentMode: Boolean = false,
showAttribution: Boolean = true,
showInstructions: Boolean = true,
Expand All @@ -90,6 +91,7 @@ class SmartSelfieEnrollmentFragment : Fragment() {
arguments = Bundle().apply {
this.userId = userId
this.jobId = jobId
this.allowNewEnroll = allowNewEnroll
this.allowAgentMode = allowAgentMode
this.showAttribution = showAttribution
this.showInstructions = showInstructions
Expand All @@ -114,6 +116,7 @@ class SmartSelfieEnrollmentFragment : Fragment() {
SmileID.SmartSelfieEnrollment(
userId = args.userId,
jobId = args.jobId,
allowNewEnroll = args.allowNewEnroll,
allowAgentMode = args.allowAgentMode,
showAttribution = args.showAttribution,
showInstructions = args.showInstructions,
Expand Down Expand Up @@ -141,6 +144,11 @@ private var Bundle.jobId: String
get() = getString(KEY_JOB_ID)!!
set(value) = putString(KEY_JOB_ID, value)

private const val KEY_ALLOW_NEW_ENROLL = "allowNewEnroll"
private var Bundle.allowNewEnroll: Boolean
get() = getBoolean(KEY_ALLOW_NEW_ENROLL)
set(value) = putBoolean(KEY_ALLOW_NEW_ENROLL, value)

private const val KEY_SHOW_ATTRIBUTION = "showAttribution"
private var Bundle.showAttribution: Boolean
get() = getBoolean(KEY_SHOW_ATTRIBUTION)
Expand Down
2 changes: 2 additions & 0 deletions lib/src/main/java/com/smileidentity/models/PrepUpload.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ data class PrepUploadRequest(
@Json(name = "partner_params") val partnerParams: PartnerParams,
// Callback URL *must* be defined either within your Partner Portal or here
@Json(name = "callback_url") val callbackUrl: String? = SmileID.callbackUrl,
// TODO - Michael will change this to a boolean
@Json(name = "allow_new_enroll") val allowNewEnroll: String,
@Json(name = "smile_client_id") val partnerId: String = SmileID.config.partnerId,
@Json(name = "source_sdk") val sourceSdk: String = "android",
@Json(name = "source_sdk_version") val sourceSdkVersion: String = BuildConfig.VERSION_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class BiometricKycViewModel(
private val idInfo: IdInfo,
private val userId: String,
private val jobId: String,
private val allowNewEnroll: Boolean,
private val extraPartnerParams: ImmutableMap<String, String> = persistentMapOf(),
) : ViewModel() {
private val _uiState = MutableStateFlow(BiometricKycUiState())
Expand Down Expand Up @@ -66,6 +67,8 @@ class BiometricKycViewModel(

val prepUploadRequest = PrepUploadRequest(
partnerParams = authResponse.partnerParams.copy(extras = extraPartnerParams),
// TODO : Michael will change this to boolean
allowNewEnroll = allowNewEnroll.toString(),
signature = authResponse.signature,
timestamp = authResponse.timestamp,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class SelfieViewModel(
private val isEnroll: Boolean,
private val userId: String,
private val jobId: String,
private val allowNewEnroll: Boolean,
private val skipApiSubmission: Boolean,
private val extraPartnerParams: ImmutableMap<String, String> = persistentMapOf(),
) : ViewModel() {
Expand Down Expand Up @@ -278,6 +279,8 @@ class SelfieViewModel(

val prepUploadRequest = PrepUploadRequest(
partnerParams = authResponse.partnerParams.copy(extras = extraPartnerParams),
// TODO : Michael will change this to boolean
allowNewEnroll = allowNewEnroll.toString(),
signature = authResponse.signature,
timestamp = authResponse.timestamp,
)
Expand Down
Loading

0 comments on commit 89033d9

Please sign in to comment.