@smile_identity/react-native 10.2.4 → 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/build.gradle +2 -1
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/smileidentity/react/Mapper.kt +7 -2
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBiometricKYCViewManager.kt +10 -3
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDDocumentVerificationViewManager.kt +1 -1
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDEnhancedDocumentVerificationViewManager.kt +13 -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/SmileIDBiometricKYCView.kt +2 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerificationView.kt +2 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDEnhancedDocumentVerificationView.kt +2 -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 +19 -0
- package/ios/Utils/SmileIDDictExt.swift +242 -216
- package/ios/Utils/SmileIDUtils.swift +9 -0
- package/ios/View/SmileIDBiometricKYCView.swift +4 -2
- package/ios/View/SmileIDConsentView.swift +1 -1
- package/ios/View/SmileIDDocumentCaptureView.swift +2 -2
- package/ios/View/SmileIDDocumentVerificationView.swift +2 -1
- package/ios/View/SmileIDEnhancedDocumentVerificationView.swift +3 -1
- package/ios/View/SmileIDSmartSelfieAuthEnhancedView.swift +35 -34
- package/ios/View/SmileIDSmartSelfieAuthView.swift +3 -1
- package/ios/View/SmileIDSmartSelfieCaptureView.swift +28 -34
- package/ios/View/SmileIDSmartSelfieEnrollmentEnhancedView.swift +2 -1
- package/ios/View/SmileIDSmartSelfieEnrollmentView.swift +1 -1
- package/ios/ViewManagers/SmileIDBaseViewManager.swift +1 -1
- package/ios/ViewManagers/SmileIDBiometricKYCViewManager.swift +35 -24
- package/ios/ViewManagers/SmileIDDocumentVerificationViewManager.swift +1 -0
- package/ios/ViewManagers/SmileIDEnhancedDocumentVerificationViewManager.swift +52 -40
- 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 -22
- package/lib/commonjs/SmileIDBiometricKYCView.js +2 -11
- package/lib/commonjs/SmileIDBiometricKYCView.js.map +1 -1
- package/lib/commonjs/SmileIDEnhancedDocumentVerificationView.js +2 -11
- package/lib/commonjs/SmileIDEnhancedDocumentVerificationView.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js +33 -2
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/SmileIDBiometricKYCView.js +2 -11
- package/lib/module/SmileIDBiometricKYCView.js.map +1 -1
- package/lib/module/SmileIDEnhancedDocumentVerificationView.js +2 -11
- package/lib/module/SmileIDEnhancedDocumentVerificationView.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +31 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/SmileIDBiometricKYCView.d.ts.map +1 -1
- package/lib/typescript/SmileIDEnhancedDocumentVerificationView.d.ts +2 -2
- package/lib/typescript/SmileIDEnhancedDocumentVerificationView.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +19 -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/SmileIDBiometricKYCView.tsx +2 -9
- package/src/SmileIDEnhancedDocumentVerificationView.tsx +6 -16
- package/src/index.tsx +2 -0
- package/src/types.ts +66 -4
package/android/build.gradle
CHANGED
|
@@ -30,7 +30,7 @@ def kotlinVersion = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("
|
|
|
30
30
|
|
|
31
31
|
apply plugin: "com.android.library"
|
|
32
32
|
apply plugin: "kotlin-android"
|
|
33
|
-
apply plugin: 'kotlin-kapt'
|
|
33
|
+
//apply plugin: 'kotlin-kapt'
|
|
34
34
|
apply plugin: "org.jlleitschuh.gradle.ktlint"
|
|
35
35
|
apply plugin: "org.jetbrains.kotlin.plugin.serialization"
|
|
36
36
|
if (kotlinVersion?.startsWith("2")) {
|
|
@@ -90,6 +90,7 @@ android {
|
|
|
90
90
|
|
|
91
91
|
kotlinOptions {
|
|
92
92
|
jvmTarget = JavaVersion.VERSION_17.toString()
|
|
93
|
+
freeCompilerArgs += ['-Xskip-metadata-version-check']
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
lintOptions {
|
|
@@ -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
|
}
|
|
@@ -165,7 +170,7 @@ fun ReadableMap.toConsentInfo(): ConsentInformation {
|
|
|
165
170
|
},
|
|
166
171
|
personalDetailsConsentGranted = getBoolOrDefault("personalDetailsConsentGranted", false),
|
|
167
172
|
contactInfoConsentGranted = getBoolOrDefault("contactInfoConsentGranted", false),
|
|
168
|
-
documentInfoConsentGranted = getBoolOrDefault("
|
|
173
|
+
documentInfoConsentGranted = getBoolOrDefault("documentInfoConsentGranted", false)
|
|
169
174
|
)
|
|
170
175
|
}
|
|
171
176
|
|
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")
|
|
@@ -38,6 +44,7 @@ class SmileIDBiometricKYCViewManager(
|
|
|
38
44
|
view.showAttribution = it.getBoolOrDefault("showAttribution", true)
|
|
39
45
|
view.showInstructions = it.getBoolOrDefault("showInstructions", true)
|
|
40
46
|
view.allowNewEnroll = it.getBoolOrDefault("allowNewEnroll", false)
|
|
47
|
+
view.useStrictMode = it.getBoolOrDefault("useStrictMode", false)
|
|
41
48
|
}
|
|
42
49
|
}
|
|
43
50
|
|
|
@@ -40,7 +40,7 @@ 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.
|
|
43
|
+
view.useStrictMode = it.getBoolOrDefault("useStrictMode", false)
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -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,7 @@ 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.
|
|
57
|
+
view.useStrictMode = it.getBoolOrDefault("useStrictMode", false)
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
|
|
@@ -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
|
|
|
@@ -17,6 +17,7 @@ import com.smileidentity.util.randomUserId
|
|
|
17
17
|
class SmileIDBiometricKYCView(context: ReactApplicationContext) : SmileIDView(context) {
|
|
18
18
|
var idInfo: IdInfo? = null
|
|
19
19
|
var consentInformation: ConsentInformation? = null
|
|
20
|
+
var useStrictMode: Boolean? = false
|
|
20
21
|
|
|
21
22
|
override fun renderContent() {
|
|
22
23
|
idInfo ?: run {
|
|
@@ -41,6 +42,7 @@ class SmileIDBiometricKYCView(context: ReactApplicationContext) : SmileIDView(co
|
|
|
41
42
|
showInstructions = showInstructions,
|
|
42
43
|
extraPartnerParams = extraPartnerParams,
|
|
43
44
|
consentInformation = consentInformation!!,
|
|
45
|
+
useStrictMode = useStrictMode ?: false,
|
|
44
46
|
) { res ->
|
|
45
47
|
when (res) {
|
|
46
48
|
is SmileIDResult.Success -> {
|
package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerificationView.kt
CHANGED
|
@@ -20,6 +20,7 @@ class SmileIDDocumentVerificationView(context: ReactApplicationContext) : SmileI
|
|
|
20
20
|
var bypassSelfieCaptureWithFilePath: String? = null
|
|
21
21
|
var documentType: String? = null
|
|
22
22
|
var idAspectRatio: Float? = null
|
|
23
|
+
var useStrictMode: Boolean? = false
|
|
23
24
|
|
|
24
25
|
override fun renderContent() {
|
|
25
26
|
countryCode ?: run {
|
|
@@ -48,6 +49,7 @@ class SmileIDDocumentVerificationView(context: ReactApplicationContext) : SmileI
|
|
|
48
49
|
allowNewEnroll = allowNewEnroll ?: false,
|
|
49
50
|
bypassSelfieCaptureWithFile = bypassSelfieCaptureWithFile,
|
|
50
51
|
extraPartnerParams = extraPartnerParams,
|
|
52
|
+
useStrictMode = useStrictMode ?: false,
|
|
51
53
|
) { res ->
|
|
52
54
|
when (res) {
|
|
53
55
|
is SmileIDResult.Success -> {
|
|
@@ -21,6 +21,7 @@ class SmileIDEnhancedDocumentVerificationView(context: ReactApplicationContext)
|
|
|
21
21
|
var documentType: String? = null
|
|
22
22
|
var idAspectRatio: Float? = null
|
|
23
23
|
var consentInformation: ConsentInformation? = null
|
|
24
|
+
var useStrictMode: Boolean? = false
|
|
24
25
|
|
|
25
26
|
override fun renderContent() {
|
|
26
27
|
countryCode ?: run {
|
|
@@ -51,6 +52,7 @@ class SmileIDEnhancedDocumentVerificationView(context: ReactApplicationContext)
|
|
|
51
52
|
captureBothSides = captureBothSides,
|
|
52
53
|
extraPartnerParams = extraPartnerParams,
|
|
53
54
|
consentInformation = consentInformation!!,
|
|
55
|
+
useStrictMode = useStrictMode ?: false,
|
|
54
56
|
) { res ->
|
|
55
57
|
when (res) {
|
|
56
58
|
is SmileIDResult.Success -> {
|
|
@@ -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
|
}
|