@smile_identity/react-native 10.2.5 → 10.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/smileidentity/react/Mapper.kt +6 -1
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBiometricKYCViewManager.kt +9 -3
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDDocumentVerificationViewManager.kt +0 -1
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDEnhancedDocumentVerificationViewManager.kt +12 -5
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieAuthenticationEnhancedViewManager.kt +1 -0
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieCaptureViewManager.kt +1 -0
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieEnrollmentEnhancedViewManager.kt +1 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSelfieView.kt +48 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthenticationEnhancedView.kt +5 -30
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthenticationView.kt +7 -32
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieCaptureView.kt +30 -189
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollmentEnhancedView.kt +5 -35
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollmentView.kt +7 -40
- package/ios/RNSmileID.swift +11 -4
- package/ios/Utils/SmileIDDictExt.swift +241 -230
- package/ios/View/SmileIDBiometricKYCView.swift +2 -2
- package/ios/View/SmileIDEnhancedDocumentVerificationView.swift +2 -2
- package/ios/View/SmileIDSmartSelfieAuthEnhancedView.swift +35 -34
- package/ios/View/SmileIDSmartSelfieAuthView.swift +2 -0
- package/ios/View/SmileIDSmartSelfieCaptureView.swift +27 -33
- package/ios/View/SmileIDSmartSelfieEnrollmentEnhancedView.swift +1 -0
- package/ios/ViewManagers/SmileIDBiometricKYCViewManager.swift +35 -30
- package/ios/ViewManagers/SmileIDEnhancedDocumentVerificationViewManager.swift +52 -47
- package/ios/ViewManagers/SmileIDSmartSelfieAuthenticationEnhancedViewManager.swift +7 -2
- package/ios/ViewManagers/SmileIDSmartSelfieCaptureViewManager.swift +1 -0
- package/ios/ViewManagers/SmileIDSmartSelfieEnrollmentEnhancedViewManager.swift +1 -0
- package/ios/ViewModels/SmileIDProductModel.swift +29 -24
- package/lib/commonjs/types.js +2 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/types.js +2 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/types.d.ts +5 -4
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/react-native-smile-id.podspec +1 -1
- package/src/types.ts +7 -4
|
@@ -153,7 +153,12 @@ fun ReadableMap.toEnhancedKycRequest(): EnhancedKycRequest {
|
|
|
153
153
|
throw IllegalArgumentException("signature is required")
|
|
154
154
|
},
|
|
155
155
|
consentInformation = getMapOrDefault("consentInformation", null)?.toConsentInfo() ?: run {
|
|
156
|
-
|
|
156
|
+
ConsentInformation(
|
|
157
|
+
consentGrantedDate = getCurrentIsoTimestamp(),
|
|
158
|
+
personalDetailsConsentGranted = false,
|
|
159
|
+
contactInfoConsentGranted = false,
|
|
160
|
+
documentInfoConsentGranted = false
|
|
161
|
+
)
|
|
157
162
|
},
|
|
158
163
|
)
|
|
159
164
|
}
|
package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBiometricKYCViewManager.kt
CHANGED
|
@@ -3,9 +3,11 @@ package com.smileidentity.react.viewmanagers
|
|
|
3
3
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
4
|
import com.facebook.react.bridge.ReadableMap
|
|
5
5
|
import com.facebook.react.module.annotations.ReactModule
|
|
6
|
+
import com.smileidentity.models.ConsentInformation
|
|
6
7
|
import com.smileidentity.react.toConsentInfo
|
|
7
8
|
import com.smileidentity.react.toIdInfo
|
|
8
9
|
import com.smileidentity.react.utils.getBoolOrDefault
|
|
10
|
+
import com.smileidentity.react.utils.getCurrentIsoTimestamp
|
|
9
11
|
import com.smileidentity.react.utils.getImmutableMapOrDefault
|
|
10
12
|
import com.smileidentity.react.utils.getMapOrDefault
|
|
11
13
|
import com.smileidentity.react.utils.getStringOrDefault
|
|
@@ -26,10 +28,14 @@ class SmileIDBiometricKYCViewManager(
|
|
|
26
28
|
args?.let {
|
|
27
29
|
val idInfoMap = it.getMap("idInfo")
|
|
28
30
|
?: return view.emitFailure(IllegalArgumentException("idInfo is required to run Biometric KYC"))
|
|
29
|
-
val consentInformationMap = it.getMap("consentInformation")
|
|
30
|
-
?: return view.emitFailure(IllegalArgumentException("consentInformation is required to run Biometric KYC"))
|
|
31
31
|
val idInfo = idInfoMap.toIdInfo()
|
|
32
|
-
view.consentInformation =
|
|
32
|
+
view.consentInformation = it.getMapOrDefault("consentInformation")?.toConsentInfo()
|
|
33
|
+
?: ConsentInformation(
|
|
34
|
+
consentGrantedDate = getCurrentIsoTimestamp(),
|
|
35
|
+
personalDetailsConsentGranted = false,
|
|
36
|
+
contactInfoConsentGranted = false,
|
|
37
|
+
documentInfoConsentGranted = false
|
|
38
|
+
)
|
|
33
39
|
view.extraPartnerParams = it.getImmutableMapOrDefault("extraPartnerParams")
|
|
34
40
|
view.userId = it.getStringOrDefault("userId")
|
|
35
41
|
view.jobId = it.getStringOrDefault("jobId")
|
|
@@ -40,7 +40,6 @@ class SmileIDDocumentVerificationViewManager(
|
|
|
40
40
|
view.documentType = it.getStringOrDefault("documentType", null)
|
|
41
41
|
view.idAspectRatio = it.getFloatOrDefault("idAspectRatio")
|
|
42
42
|
view.allowNewEnroll = it.getBoolOrDefault("allowNewEnroll", false)
|
|
43
|
-
view.skipApiSubmission = it.getBoolOrDefault("skipApiSubmission", false)
|
|
44
43
|
view.useStrictMode = it.getBoolOrDefault("useStrictMode", false)
|
|
45
44
|
}
|
|
46
45
|
}
|
|
@@ -6,9 +6,11 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
6
6
|
import com.facebook.react.module.annotations.ReactModule
|
|
7
7
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
8
8
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
9
|
+
import com.smileidentity.models.ConsentInformation
|
|
9
10
|
import com.smileidentity.react.toConsentInfo
|
|
10
11
|
import com.smileidentity.react.toIdInfo
|
|
11
12
|
import com.smileidentity.react.utils.getBoolOrDefault
|
|
13
|
+
import com.smileidentity.react.utils.getCurrentIsoTimestamp
|
|
12
14
|
import com.smileidentity.react.utils.getFloatOrDefault
|
|
13
15
|
import com.smileidentity.react.utils.getImmutableMapOrDefault
|
|
14
16
|
import com.smileidentity.react.utils.getMapOrDefault
|
|
@@ -30,10 +32,16 @@ class SmileIDEnhancedDocumentVerificationViewManager(
|
|
|
30
32
|
override fun applyArgs(view: SmileIDEnhancedDocumentVerificationView, args: ReadableMap?) {
|
|
31
33
|
args?.let {
|
|
32
34
|
val countryCode = it.getString("countryCode")
|
|
33
|
-
?: return view.emitFailure(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
view.consentInformation =
|
|
35
|
+
?: return view.emitFailure(
|
|
36
|
+
IllegalArgumentException("countryCode is required to run Enhanced Document Verification")
|
|
37
|
+
)
|
|
38
|
+
view.consentInformation = it.getMapOrDefault("consentInformation")?.toConsentInfo()
|
|
39
|
+
?: ConsentInformation(
|
|
40
|
+
consentGrantedDate = getCurrentIsoTimestamp(),
|
|
41
|
+
personalDetailsConsentGranted = false,
|
|
42
|
+
contactInfoConsentGranted = false,
|
|
43
|
+
documentInfoConsentGranted = false
|
|
44
|
+
)
|
|
37
45
|
view.extraPartnerParams = it.getImmutableMapOrDefault("extraPartnerParams")
|
|
38
46
|
view.userId = it.getStringOrDefault("userId")
|
|
39
47
|
view.jobId = it.getStringOrDefault("jobId")
|
|
@@ -46,7 +54,6 @@ class SmileIDEnhancedDocumentVerificationViewManager(
|
|
|
46
54
|
view.documentType = it.getStringOrDefault("documentType")
|
|
47
55
|
view.idAspectRatio = it.getFloatOrDefault("idAspectRatio")
|
|
48
56
|
view.allowNewEnroll = it.getBoolOrDefault("allowNewEnroll", false)
|
|
49
|
-
view.skipApiSubmission = it.getBoolOrDefault("skipApiSubmission", false)
|
|
50
57
|
view.useStrictMode = it.getBoolOrDefault("useStrictMode", false)
|
|
51
58
|
}
|
|
52
59
|
}
|
|
@@ -30,6 +30,7 @@ class SmileIDSmartSelfieAuthenticationEnhancedViewManager(
|
|
|
30
30
|
view.showAttribution = it.getBoolOrDefault("showAttribution", true)
|
|
31
31
|
view.showInstructions = it.getBoolOrDefault("showInstructions", true)
|
|
32
32
|
view.allowNewEnroll = it.getBoolOrDefault("allowNewEnroll", false)
|
|
33
|
+
view.skipApiSubmission = it.getBoolOrDefault("skipApiSubmission", false)
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -29,6 +29,7 @@ class SmileIDSmartSelfieCaptureViewManager(
|
|
|
29
29
|
view.allowAgentMode = it.getBoolOrDefault("allowAgentMode", false)
|
|
30
30
|
view.showAttribution = it.getBoolOrDefault("showAttribution", true)
|
|
31
31
|
view.showInstructions = it.getBoolOrDefault("showInstructions", true)
|
|
32
|
+
view.useStrictMode = it.getBoolOrDefault("useStrictMode", false)
|
|
32
33
|
view.showConfirmation =
|
|
33
34
|
it.getBoolOrDefault("showConfirmation", true)
|
|
34
35
|
}
|
|
@@ -30,6 +30,7 @@ class SmileIDSmartSelfieEnrollmentEnhancedViewManager(
|
|
|
30
30
|
view.showAttribution = it.getBoolOrDefault("showAttribution", true)
|
|
31
31
|
view.showInstructions = it.getBoolOrDefault("showInstructions", true)
|
|
32
32
|
view.allowNewEnroll = it.getBoolOrDefault("allowNewEnroll", false)
|
|
33
|
+
view.skipApiSubmission = it.getBoolOrDefault("skipApiSubmission", false)
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
package com.smileidentity.react.views
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import com.smileidentity.SmileID
|
|
6
|
+
import com.smileidentity.react.results.SmartSelfieCaptureResult
|
|
7
|
+
import com.smileidentity.react.utils.SelfieCaptureResultAdapter
|
|
8
|
+
import com.smileidentity.results.SmartSelfieResult
|
|
9
|
+
import com.smileidentity.results.SmileIDResult
|
|
10
|
+
|
|
11
|
+
@SuppressLint("CheckResult")
|
|
12
|
+
abstract class SmileIDSelfieView(currentContext: Context) : SmileIDView(currentContext) {
|
|
13
|
+
|
|
14
|
+
protected fun handleResultCallback(res: SmileIDResult<*>) {
|
|
15
|
+
when (res) {
|
|
16
|
+
is SmileIDResult.Success -> {
|
|
17
|
+
val data = res.data as? SmartSelfieResult ?: run {
|
|
18
|
+
emitFailure(Exception("Unexpected result type"))
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
val result = SmartSelfieCaptureResult(
|
|
22
|
+
selfieFile = data.selfieFile,
|
|
23
|
+
livenessFiles = data.livenessFiles,
|
|
24
|
+
apiResponse = data.apiResponse,
|
|
25
|
+
)
|
|
26
|
+
val newMoshi =
|
|
27
|
+
SmileID.moshi
|
|
28
|
+
.newBuilder()
|
|
29
|
+
.add(SelfieCaptureResultAdapter.FACTORY)
|
|
30
|
+
.build()
|
|
31
|
+
val json =
|
|
32
|
+
try {
|
|
33
|
+
newMoshi
|
|
34
|
+
.adapter(SmartSelfieCaptureResult::class.java)
|
|
35
|
+
.toJson(result)
|
|
36
|
+
} catch (e: Exception) {
|
|
37
|
+
emitFailure(e)
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
json?.let { js ->
|
|
41
|
+
emitSuccess(js)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
is SmileIDResult.Error -> emitFailure(res.throwable)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -8,11 +8,12 @@ import com.smileidentity.SmileID
|
|
|
8
8
|
import com.smileidentity.compose.SmartSelfieAuthenticationEnhanced
|
|
9
9
|
import com.smileidentity.react.results.SmartSelfieCaptureResult
|
|
10
10
|
import com.smileidentity.react.utils.SelfieCaptureResultAdapter
|
|
11
|
+
import com.smileidentity.results.SmartSelfieResult
|
|
11
12
|
import com.smileidentity.results.SmileIDResult
|
|
12
13
|
import com.smileidentity.util.randomUserId
|
|
13
14
|
|
|
14
15
|
class SmileIDSmartSelfieAuthenticationEnhancedView(context: ReactApplicationContext) :
|
|
15
|
-
|
|
16
|
+
SmileIDSelfieView(context) {
|
|
16
17
|
|
|
17
18
|
override fun renderContent() {
|
|
18
19
|
composeView.apply {
|
|
@@ -24,36 +25,10 @@ class SmileIDSmartSelfieAuthenticationEnhancedView(context: ReactApplicationCont
|
|
|
24
25
|
allowNewEnroll = allowNewEnroll ?: false,
|
|
25
26
|
showAttribution = showAttribution,
|
|
26
27
|
showInstructions = showInstructions,
|
|
28
|
+
skipApiSubmission = skipApiSubmission,
|
|
27
29
|
extraPartnerParams = extraPartnerParams,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
is SmileIDResult.Success -> {
|
|
31
|
-
val result =
|
|
32
|
-
SmartSelfieCaptureResult(
|
|
33
|
-
selfieFile = res.data.selfieFile,
|
|
34
|
-
livenessFiles = res.data.livenessFiles,
|
|
35
|
-
apiResponse = res.data.apiResponse,
|
|
36
|
-
)
|
|
37
|
-
val json =
|
|
38
|
-
try {
|
|
39
|
-
SmileID.moshi
|
|
40
|
-
.newBuilder()
|
|
41
|
-
.add(SelfieCaptureResultAdapter.FACTORY)
|
|
42
|
-
.build()
|
|
43
|
-
.adapter(SmartSelfieCaptureResult::class.java)
|
|
44
|
-
.toJson(result)
|
|
45
|
-
} catch (e: Exception) {
|
|
46
|
-
emitFailure(e)
|
|
47
|
-
return@SmartSelfieAuthenticationEnhanced
|
|
48
|
-
}
|
|
49
|
-
json?.let { response ->
|
|
50
|
-
emitSuccess(response)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
is SmileIDResult.Error -> emitFailure(res.throwable)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
30
|
+
onResult = { res -> handleResultCallback(res) },
|
|
31
|
+
)
|
|
57
32
|
}
|
|
58
33
|
}
|
|
59
34
|
}
|
package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthenticationView.kt
CHANGED
|
@@ -8,11 +8,13 @@ import com.smileidentity.SmileID
|
|
|
8
8
|
import com.smileidentity.compose.SmartSelfieAuthentication
|
|
9
9
|
import com.smileidentity.react.results.SmartSelfieCaptureResult
|
|
10
10
|
import com.smileidentity.react.utils.SelfieCaptureResultAdapter
|
|
11
|
+
import com.smileidentity.results.SmartSelfieResult
|
|
11
12
|
import com.smileidentity.results.SmileIDResult
|
|
13
|
+
import com.smileidentity.util.randomJobId
|
|
12
14
|
import com.smileidentity.util.randomUserId
|
|
13
15
|
|
|
14
16
|
class SmileIDSmartSelfieAuthenticationView(context: ReactApplicationContext) :
|
|
15
|
-
|
|
17
|
+
SmileIDSelfieView(context) {
|
|
16
18
|
|
|
17
19
|
override fun renderContent() {
|
|
18
20
|
composeView.apply {
|
|
@@ -21,42 +23,15 @@ class SmileIDSmartSelfieAuthenticationView(context: ReactApplicationContext) :
|
|
|
21
23
|
CompositionLocalProvider(LocalViewModelStoreOwner provides customViewModelStoreOwner) {
|
|
22
24
|
SmileID.SmartSelfieAuthentication(
|
|
23
25
|
userId = userId ?: rememberSaveable { randomUserId() },
|
|
26
|
+
jobId = jobId ?: rememberSaveable { randomJobId() },
|
|
24
27
|
allowAgentMode = allowAgentMode ?: false,
|
|
25
28
|
allowNewEnroll = allowNewEnroll ?: false,
|
|
26
29
|
showAttribution = showAttribution,
|
|
27
30
|
showInstructions = showInstructions,
|
|
31
|
+
skipApiSubmission = skipApiSubmission,
|
|
28
32
|
extraPartnerParams = extraPartnerParams,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
is SmileIDResult.Success -> {
|
|
32
|
-
val result =
|
|
33
|
-
SmartSelfieCaptureResult(
|
|
34
|
-
selfieFile = res.data.selfieFile,
|
|
35
|
-
livenessFiles = res.data.livenessFiles,
|
|
36
|
-
apiResponse = res.data.apiResponse,
|
|
37
|
-
)
|
|
38
|
-
val newMoshi =
|
|
39
|
-
SmileID.moshi
|
|
40
|
-
.newBuilder()
|
|
41
|
-
.add(SelfieCaptureResultAdapter.FACTORY)
|
|
42
|
-
.build()
|
|
43
|
-
val json =
|
|
44
|
-
try {
|
|
45
|
-
newMoshi
|
|
46
|
-
.adapter(SmartSelfieCaptureResult::class.java)
|
|
47
|
-
.toJson(result)
|
|
48
|
-
} catch (e: Exception) {
|
|
49
|
-
emitFailure(e)
|
|
50
|
-
return@SmartSelfieAuthentication
|
|
51
|
-
}
|
|
52
|
-
json?.let { js ->
|
|
53
|
-
emitSuccess(js)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
is SmileIDResult.Error -> emitFailure(res.throwable)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
33
|
+
onResult = { res -> handleResultCallback(res) },
|
|
34
|
+
)
|
|
60
35
|
}
|
|
61
36
|
}
|
|
62
37
|
}
|
package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieCaptureView.kt
CHANGED
|
@@ -1,222 +1,63 @@
|
|
|
1
1
|
package com.smileidentity.react.views
|
|
2
2
|
|
|
3
|
-
import android.graphics.BitmapFactory
|
|
4
|
-
import androidx.compose.foundation.background
|
|
5
|
-
import androidx.compose.foundation.layout.Box
|
|
6
|
-
import androidx.compose.foundation.layout.WindowInsets
|
|
7
|
-
import androidx.compose.foundation.layout.consumeWindowInsets
|
|
8
|
-
import androidx.compose.foundation.layout.fillMaxSize
|
|
9
|
-
import androidx.compose.foundation.layout.statusBars
|
|
10
|
-
import androidx.compose.foundation.layout.windowInsetsPadding
|
|
11
3
|
import androidx.compose.material3.MaterialTheme
|
|
12
4
|
import androidx.compose.material3.Surface
|
|
13
|
-
import androidx.compose.runtime.Composable
|
|
14
5
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
15
|
-
import androidx.compose.runtime.getValue
|
|
16
|
-
import androidx.compose.runtime.mutableStateOf
|
|
17
|
-
import androidx.compose.runtime.remember
|
|
18
|
-
import androidx.compose.runtime.saveable.rememberSaveable
|
|
19
|
-
import androidx.compose.runtime.setValue
|
|
20
|
-
import androidx.compose.runtime.toMutableStateList
|
|
21
|
-
import androidx.compose.ui.Modifier
|
|
22
|
-
import androidx.compose.ui.graphics.Color
|
|
23
|
-
import androidx.compose.ui.graphics.asImageBitmap
|
|
24
|
-
import androidx.compose.ui.graphics.painter.BitmapPainter
|
|
25
|
-
import androidx.compose.ui.res.stringResource
|
|
26
|
-
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
|
27
6
|
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
|
|
28
|
-
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
29
7
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
30
|
-
import com.smileidentity.R
|
|
31
8
|
import com.smileidentity.SmileID
|
|
32
9
|
import com.smileidentity.SmileIDOptIn
|
|
33
|
-
import com.smileidentity.compose.
|
|
34
|
-
import com.smileidentity.compose.
|
|
35
|
-
import com.smileidentity.compose.selfie.SelfieCaptureScreen
|
|
36
|
-
import com.smileidentity.compose.selfie.SmartSelfieInstructionsScreen
|
|
10
|
+
import com.smileidentity.compose.SmartSelfieEnrollment
|
|
11
|
+
import com.smileidentity.compose.SmartSelfieEnrollmentEnhanced
|
|
37
12
|
import com.smileidentity.compose.theme.colorScheme
|
|
38
13
|
import com.smileidentity.compose.theme.typography
|
|
39
|
-
import com.smileidentity.models.v2.Metadata
|
|
40
14
|
import com.smileidentity.react.results.SmartSelfieCaptureResult
|
|
41
15
|
import com.smileidentity.react.utils.SelfieCaptureResultAdapter
|
|
16
|
+
import com.smileidentity.results.SmartSelfieResult
|
|
42
17
|
import com.smileidentity.results.SmileIDResult
|
|
43
18
|
import com.smileidentity.util.randomJobId
|
|
44
19
|
import com.smileidentity.util.randomUserId
|
|
45
|
-
import com.smileidentity.viewmodel.SelfieUiState
|
|
46
|
-
import com.smileidentity.viewmodel.SelfieViewModel
|
|
47
|
-
import com.smileidentity.viewmodel.viewModelFactory
|
|
48
20
|
|
|
49
21
|
|
|
50
22
|
@OptIn(SmileIDOptIn::class)
|
|
51
|
-
class SmileIDSmartSelfieCaptureView(context: ReactApplicationContext) :
|
|
23
|
+
class SmileIDSmartSelfieCaptureView(context: ReactApplicationContext) : SmileIDSelfieView(context) {
|
|
52
24
|
var showConfirmation: Boolean = true
|
|
25
|
+
var useStrictMode: Boolean = false
|
|
53
26
|
|
|
54
27
|
override fun renderContent() {
|
|
55
28
|
composeView.apply {
|
|
56
29
|
val customViewModelStoreOwner = CustomViewModelStoreOwner()
|
|
57
30
|
setContent {
|
|
58
31
|
CompositionLocalProvider(LocalViewModelStoreOwner provides customViewModelStoreOwner) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)
|
|
84
|
-
val uiState = viewModel.uiState.collectAsStateWithLifecycle().value
|
|
85
|
-
var acknowledgedInstructions by rememberSaveable { mutableStateOf(false) }
|
|
86
|
-
CompositionLocalProvider(
|
|
87
|
-
LocalMetadata provides remember { Metadata.default().items.toMutableStateList() },
|
|
88
|
-
) {
|
|
89
|
-
MaterialTheme(colorScheme = SmileID.colorScheme, typography = SmileID.typography) {
|
|
90
|
-
Surface(content = {
|
|
91
|
-
when {
|
|
92
|
-
showInstructions && !acknowledgedInstructions -> SmartSelfieInstructionsScreen(
|
|
93
|
-
showAttribution = showAttribution,
|
|
94
|
-
) {
|
|
95
|
-
acknowledgedInstructions = true
|
|
96
|
-
}
|
|
97
|
-
uiState.processingState != null -> HandleProcessingState(viewModel)
|
|
98
|
-
uiState.selfieToConfirm != null ->
|
|
99
|
-
HandleSelfieConfirmation(
|
|
100
|
-
showConfirmation,
|
|
101
|
-
uiState,
|
|
102
|
-
viewModel,
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
else -> RenderSelfieCaptureScreen(userId, jobId, allowAgentMode ?: true, viewModel)
|
|
106
|
-
}
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
@Composable
|
|
113
|
-
private fun RenderSelfieCaptureScreen(
|
|
114
|
-
userId: String,
|
|
115
|
-
jobId: String,
|
|
116
|
-
allowAgentMode: Boolean,
|
|
117
|
-
viewModel: SelfieViewModel,
|
|
118
|
-
) {
|
|
119
|
-
Box(
|
|
120
|
-
modifier =
|
|
121
|
-
Modifier
|
|
122
|
-
.background(color = Color.White)
|
|
123
|
-
.windowInsetsPadding(WindowInsets.statusBars)
|
|
124
|
-
.consumeWindowInsets(WindowInsets.statusBars)
|
|
125
|
-
.fillMaxSize(),
|
|
126
|
-
) {
|
|
127
|
-
SelfieCaptureScreen(
|
|
128
|
-
userId = userId,
|
|
129
|
-
jobId = jobId,
|
|
130
|
-
allowAgentMode = allowAgentMode,
|
|
131
|
-
allowNewEnroll = false,
|
|
132
|
-
skipApiSubmission = true,
|
|
133
|
-
viewModel = viewModel,
|
|
134
|
-
)
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
@Composable
|
|
139
|
-
private fun HandleSelfieConfirmation(
|
|
140
|
-
showConfirmation: Boolean,
|
|
141
|
-
uiState: SelfieUiState,
|
|
142
|
-
viewModel: SelfieViewModel,
|
|
143
|
-
) {
|
|
144
|
-
if (showConfirmation) {
|
|
145
|
-
ImageCaptureConfirmationDialog(
|
|
146
|
-
titleText = stringResource(R.string.si_smart_selfie_confirmation_dialog_title),
|
|
147
|
-
subtitleText =
|
|
148
|
-
stringResource(
|
|
149
|
-
R.string.si_smart_selfie_confirmation_dialog_subtitle,
|
|
150
|
-
),
|
|
151
|
-
painter =
|
|
152
|
-
BitmapPainter(
|
|
153
|
-
BitmapFactory
|
|
154
|
-
.decodeFile(uiState.selfieToConfirm!!.absolutePath)
|
|
155
|
-
.asImageBitmap(),
|
|
156
|
-
),
|
|
157
|
-
confirmButtonText =
|
|
158
|
-
stringResource(
|
|
159
|
-
R.string.si_smart_selfie_confirmation_dialog_confirm_button,
|
|
160
|
-
),
|
|
161
|
-
onConfirm = {
|
|
162
|
-
viewModel.submitJob()
|
|
163
|
-
},
|
|
164
|
-
retakeButtonText =
|
|
165
|
-
stringResource(
|
|
166
|
-
R.string.si_smart_selfie_confirmation_dialog_retake_button,
|
|
167
|
-
),
|
|
168
|
-
onRetake = viewModel::onSelfieRejected,
|
|
169
|
-
scaleFactor = 1.25f,
|
|
170
|
-
)
|
|
171
|
-
} else {
|
|
172
|
-
viewModel.submitJob()
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
@Composable
|
|
177
|
-
private fun HandleProcessingState(viewModel: SelfieViewModel) {
|
|
178
|
-
try {
|
|
179
|
-
viewModel.onFinished { res ->
|
|
180
|
-
when (res) {
|
|
181
|
-
is SmileIDResult.Success -> {
|
|
182
|
-
res.data?.let { data ->
|
|
183
|
-
val result = SmartSelfieCaptureResult(
|
|
184
|
-
selfieFile = data.selfieFile,
|
|
185
|
-
livenessFiles = data.livenessFiles ?: emptyList()
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
try {
|
|
189
|
-
val newMoshi = SmileID.moshi
|
|
190
|
-
.newBuilder()
|
|
191
|
-
.add(SelfieCaptureResultAdapter.FACTORY)
|
|
192
|
-
.build()
|
|
193
|
-
|
|
194
|
-
newMoshi.adapter(SmartSelfieCaptureResult::class.java)
|
|
195
|
-
?.toJson(result)
|
|
196
|
-
?.let { js ->
|
|
197
|
-
emitSuccess(js)
|
|
198
|
-
} ?: run {
|
|
199
|
-
emitFailure(Exception("Failed to serialize result"))
|
|
200
|
-
}
|
|
201
|
-
} catch (e: Exception) {
|
|
202
|
-
emitFailure(e)
|
|
32
|
+
val userId = randomUserId()
|
|
33
|
+
val jobId = randomJobId()
|
|
34
|
+
MaterialTheme(colorScheme = SmileID.colorScheme, typography = SmileID.typography) {
|
|
35
|
+
Surface(content = {
|
|
36
|
+
if (useStrictMode) {
|
|
37
|
+
SmileID.SmartSelfieEnrollmentEnhanced(
|
|
38
|
+
userId = userId,
|
|
39
|
+
showAttribution = showAttribution,
|
|
40
|
+
showInstructions = showInstructions,
|
|
41
|
+
skipApiSubmission = true,
|
|
42
|
+
extraPartnerParams = extraPartnerParams,
|
|
43
|
+
onResult = { res -> handleResultCallback(res) },
|
|
44
|
+
)
|
|
45
|
+
} else {
|
|
46
|
+
SmileID.SmartSelfieEnrollment(
|
|
47
|
+
userId = userId,
|
|
48
|
+
jobId = jobId,
|
|
49
|
+
allowAgentMode = allowAgentMode ?: false,
|
|
50
|
+
showAttribution = showAttribution,
|
|
51
|
+
showInstructions = showInstructions,
|
|
52
|
+
skipApiSubmission = true,
|
|
53
|
+
extraPartnerParams = extraPartnerParams,
|
|
54
|
+
onResult = { res -> handleResultCallback(res) },
|
|
55
|
+
)
|
|
203
56
|
}
|
|
204
|
-
}
|
|
205
|
-
emitFailure(Exception("No data available in success result"))
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
is SmileIDResult.Error -> {
|
|
210
|
-
emitFailure(res.throwable ?: Exception("Unknown error occurred"))
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
else -> {
|
|
214
|
-
emitFailure(Exception("Unexpected result type"))
|
|
57
|
+
})
|
|
215
58
|
}
|
|
216
59
|
}
|
|
217
60
|
}
|
|
218
|
-
} catch (e: Exception) {
|
|
219
|
-
// emitFailure(e)
|
|
220
61
|
}
|
|
221
62
|
}
|
|
222
63
|
}
|
|
@@ -8,6 +8,7 @@ import com.smileidentity.SmileID
|
|
|
8
8
|
import com.smileidentity.compose.SmartSelfieEnrollmentEnhanced
|
|
9
9
|
import com.smileidentity.react.results.SmartSelfieCaptureResult
|
|
10
10
|
import com.smileidentity.react.utils.SelfieCaptureResultAdapter
|
|
11
|
+
import com.smileidentity.results.SmartSelfieResult
|
|
11
12
|
import com.smileidentity.results.SmileIDResult
|
|
12
13
|
import com.smileidentity.util.randomUserId
|
|
13
14
|
import kotlinx.coroutines.CoroutineScope
|
|
@@ -15,8 +16,7 @@ import kotlinx.coroutines.Dispatchers
|
|
|
15
16
|
import kotlinx.coroutines.Job
|
|
16
17
|
import kotlinx.coroutines.launch
|
|
17
18
|
|
|
18
|
-
class SmileIDSmartSelfieEnrollmentEnhancedView(context: ReactApplicationContext) :
|
|
19
|
-
private val viewScope = CoroutineScope(Dispatchers.Main + Job())
|
|
19
|
+
class SmileIDSmartSelfieEnrollmentEnhancedView(context: ReactApplicationContext) : SmileIDSelfieView(context) {
|
|
20
20
|
override fun renderContent() {
|
|
21
21
|
composeView.apply {
|
|
22
22
|
setContent {
|
|
@@ -27,40 +27,10 @@ class SmileIDSmartSelfieEnrollmentEnhancedView(context: ReactApplicationContext)
|
|
|
27
27
|
allowNewEnroll = allowNewEnroll ?: false,
|
|
28
28
|
showAttribution = showAttribution,
|
|
29
29
|
showInstructions = showInstructions,
|
|
30
|
+
skipApiSubmission = skipApiSubmission,
|
|
30
31
|
extraPartnerParams = extraPartnerParams,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
when (res) {
|
|
34
|
-
is SmileIDResult.Success -> {
|
|
35
|
-
val result =
|
|
36
|
-
SmartSelfieCaptureResult(
|
|
37
|
-
selfieFile = res.data.selfieFile,
|
|
38
|
-
livenessFiles = res.data.livenessFiles,
|
|
39
|
-
apiResponse = res.data.apiResponse,
|
|
40
|
-
)
|
|
41
|
-
val newMoshi =
|
|
42
|
-
SmileID.moshi
|
|
43
|
-
.newBuilder()
|
|
44
|
-
.add(SelfieCaptureResultAdapter.FACTORY)
|
|
45
|
-
.build()
|
|
46
|
-
val json =
|
|
47
|
-
try {
|
|
48
|
-
newMoshi
|
|
49
|
-
.adapter(SmartSelfieCaptureResult::class.java)
|
|
50
|
-
.toJson(result)
|
|
51
|
-
} catch (e: Exception) {
|
|
52
|
-
emitFailure(e)
|
|
53
|
-
return@launch
|
|
54
|
-
}
|
|
55
|
-
json?.let { js ->
|
|
56
|
-
emitSuccess(js)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
is SmileIDResult.Error -> emitFailure(res.throwable)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
32
|
+
onResult = { res -> handleResultCallback(res) },
|
|
33
|
+
)
|
|
64
34
|
}
|
|
65
35
|
}
|
|
66
36
|
}
|