@smile_identity/react-native 10.1.12 → 10.2.1
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 +12 -6
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/smileidentity/react/results/DocumentCaptureResult.kt +12 -0
- package/android/src/main/java/com/smileidentity/react/results/SmartSelfieCaptureResult.kt +11 -0
- package/android/src/main/java/com/smileidentity/react/utils/DocumentCaptureResultAdapter.kt +46 -2
- package/android/src/main/java/com/smileidentity/react/utils/ReactUtils.kt +19 -0
- package/android/src/main/java/com/smileidentity/react/utils/SelfieCaptureResultAdapter.kt +28 -17
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBiometricKYCViewManager.kt +2 -2
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDConsentViewManager.kt +2 -3
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDDocumentVerificationViewManager.kt +3 -3
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDEnhancedDocumentVerificationViewManager.kt +3 -3
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieAuthenticationViewManager.kt +3 -3
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieEnrollmentViewManager.kt +3 -3
- package/android/src/main/java/com/smileidentity/react/views/SmileIDBiometricKYCView.kt +27 -17
- package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentCaptureView.kt +1 -17
- package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerificationView.kt +30 -16
- package/android/src/main/java/com/smileidentity/react/views/SmileIDEnhancedDocumentVerificationView.kt +30 -16
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthenticationView.kt +30 -20
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieCaptureView.kt +1 -5
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollmentView.kt +31 -21
- package/android/src/main/java/com/smileidentity/react/views/SmileIDView.kt +5 -3
- package/ios/Utils/FileUtils.swift +24 -0
- package/ios/View/SmileIDBiometricKYCView.swift +54 -51
- package/ios/View/SmileIDDocumentVerificationView.swift +51 -47
- package/ios/View/SmileIDEnhancedDocumentVerificationView.swift +50 -47
- package/ios/View/SmileIDSmartSelfieAuthView.swift +36 -33
- package/ios/View/SmileIDSmartSelfieCaptureView.swift +4 -41
- package/ios/View/SmileIDSmartSelfieEnrollmentView.swift +36 -33
- package/ios/ViewManagers/SmileIDDocumentVerificationViewManager.swift +40 -39
- package/ios/ViewManagers/SmileIDEnhancedDocumentVerificationViewManager.swift +40 -39
- package/ios/ViewManagers/SmileIDSmartSelfieAuthenticationViewManager.swift +20 -19
- package/ios/ViewManagers/SmileIDSmartSelfieEnrollmentViewManager.swift +20 -19
- package/ios/ViewModels/SmileIDProductModel.swift +1 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/types.d.ts +9 -2
- 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 +16 -2
|
@@ -6,12 +6,12 @@ import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
|
|
|
6
6
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
7
|
import com.smileidentity.SmileID
|
|
8
8
|
import com.smileidentity.compose.EnhancedDocumentVerificationScreen
|
|
9
|
-
import com.smileidentity.results.
|
|
9
|
+
import com.smileidentity.react.results.DocumentCaptureResult
|
|
10
|
+
import com.smileidentity.react.utils.DocumentCaptureResultAdapter
|
|
10
11
|
import com.smileidentity.results.SmileIDResult
|
|
11
12
|
import com.smileidentity.util.randomJobId
|
|
12
13
|
import com.smileidentity.util.randomUserId
|
|
13
14
|
import kotlinx.collections.immutable.toImmutableMap
|
|
14
|
-
import timber.log.Timber
|
|
15
15
|
|
|
16
16
|
class SmileIDEnhancedDocumentVerificationView(context: ReactApplicationContext) :
|
|
17
17
|
SmileIDView(context) {
|
|
@@ -43,25 +43,39 @@ class SmileIDEnhancedDocumentVerificationView(context: ReactApplicationContext)
|
|
|
43
43
|
allowNewEnroll = allowNewEnroll ?: false,
|
|
44
44
|
allowGalleryUpload = allowGalleryUpload,
|
|
45
45
|
captureBothSides = captureBothSides,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
skipApiSubmission = skipApiSubmission,
|
|
47
|
+
extraPartnerParams = extraPartnerParams,
|
|
48
|
+
) { res ->
|
|
49
|
+
when (res) {
|
|
49
50
|
is SmileIDResult.Success -> {
|
|
50
|
-
val
|
|
51
|
+
val result =
|
|
52
|
+
DocumentCaptureResult(
|
|
53
|
+
selfieFile = res.data.selfieFile,
|
|
54
|
+
documentFrontFile = res.data.documentFrontFile,
|
|
55
|
+
livenessFiles = res.data.livenessFiles,
|
|
56
|
+
documentBackFile = res.data.documentBackFile,
|
|
57
|
+
didSubmitEnhancedDocVJob = res.data.didSubmitEnhancedDocVJob,
|
|
58
|
+
)
|
|
59
|
+
val newMoshi =
|
|
51
60
|
SmileID.moshi
|
|
52
|
-
.
|
|
53
|
-
.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
.newBuilder()
|
|
62
|
+
.add(DocumentCaptureResultAdapter.FACTORY)
|
|
63
|
+
.build()
|
|
64
|
+
val json =
|
|
65
|
+
try {
|
|
66
|
+
newMoshi
|
|
67
|
+
.adapter(DocumentCaptureResult::class.java)
|
|
68
|
+
.toJson(result)
|
|
69
|
+
} catch (e: Exception) {
|
|
70
|
+
emitFailure(e)
|
|
71
|
+
return@EnhancedDocumentVerificationScreen
|
|
72
|
+
}
|
|
73
|
+
json?.let { js ->
|
|
74
|
+
emitSuccess(js)
|
|
57
75
|
}
|
|
58
|
-
emitSuccess(json)
|
|
59
76
|
}
|
|
60
77
|
|
|
61
|
-
is SmileIDResult.Error ->
|
|
62
|
-
result.throwable.printStackTrace()
|
|
63
|
-
emitFailure(result.throwable)
|
|
64
|
-
}
|
|
78
|
+
is SmileIDResult.Error -> emitFailure(res.throwable)
|
|
65
79
|
}
|
|
66
80
|
}
|
|
67
81
|
}
|
package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthenticationView.kt
CHANGED
|
@@ -6,12 +6,11 @@ import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
|
|
|
6
6
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
7
|
import com.smileidentity.SmileID
|
|
8
8
|
import com.smileidentity.compose.SmartSelfieAuthentication
|
|
9
|
-
import com.smileidentity.results.
|
|
9
|
+
import com.smileidentity.react.results.SmartSelfieCaptureResult
|
|
10
|
+
import com.smileidentity.react.utils.SelfieCaptureResultAdapter
|
|
10
11
|
import com.smileidentity.results.SmileIDResult
|
|
11
|
-
import com.smileidentity.util.randomJobId
|
|
12
12
|
import com.smileidentity.util.randomUserId
|
|
13
13
|
import kotlinx.collections.immutable.toImmutableMap
|
|
14
|
-
import timber.log.Timber
|
|
15
14
|
|
|
16
15
|
class SmileIDSmartSelfieAuthenticationView(context: ReactApplicationContext) :
|
|
17
16
|
SmileIDView(context) {
|
|
@@ -23,30 +22,41 @@ class SmileIDSmartSelfieAuthenticationView(context: ReactApplicationContext) :
|
|
|
23
22
|
CompositionLocalProvider(LocalViewModelStoreOwner provides customViewModelStoreOwner) {
|
|
24
23
|
SmileID.SmartSelfieAuthentication(
|
|
25
24
|
userId = userId ?: rememberSaveable { randomUserId() },
|
|
26
|
-
jobId = jobId ?: rememberSaveable { randomJobId() },
|
|
27
25
|
allowAgentMode = allowAgentMode ?: false,
|
|
28
26
|
allowNewEnroll = allowNewEnroll ?: false,
|
|
29
|
-
showAttribution = showAttribution
|
|
30
|
-
showInstructions = showInstructions
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
showAttribution = showAttribution,
|
|
28
|
+
showInstructions = showInstructions,
|
|
29
|
+
skipApiSubmission = skipApiSubmission,
|
|
30
|
+
extraPartnerParams = extraPartnerParams,
|
|
31
|
+
) { res ->
|
|
32
|
+
when (res) {
|
|
34
33
|
is SmileIDResult.Success -> {
|
|
35
|
-
val
|
|
34
|
+
val result =
|
|
35
|
+
SmartSelfieCaptureResult(
|
|
36
|
+
selfieFile = res.data.selfieFile,
|
|
37
|
+
livenessFiles = res.data.livenessFiles,
|
|
38
|
+
apiResponse = res.data.apiResponse,
|
|
39
|
+
)
|
|
40
|
+
val newMoshi =
|
|
36
41
|
SmileID.moshi
|
|
37
|
-
.
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
.newBuilder()
|
|
43
|
+
.add(SelfieCaptureResultAdapter.FACTORY)
|
|
44
|
+
.build()
|
|
45
|
+
val json =
|
|
46
|
+
try {
|
|
47
|
+
newMoshi
|
|
48
|
+
.adapter(SmartSelfieCaptureResult::class.java)
|
|
49
|
+
.toJson(result)
|
|
50
|
+
} catch (e: Exception) {
|
|
51
|
+
emitFailure(e)
|
|
52
|
+
return@SmartSelfieAuthentication
|
|
53
|
+
}
|
|
54
|
+
json?.let { js ->
|
|
55
|
+
emitSuccess(js)
|
|
42
56
|
}
|
|
43
|
-
emitSuccess(json)
|
|
44
57
|
}
|
|
45
58
|
|
|
46
|
-
is SmileIDResult.Error ->
|
|
47
|
-
result.throwable.printStackTrace()
|
|
48
|
-
emitFailure(result.throwable)
|
|
49
|
-
}
|
|
59
|
+
is SmileIDResult.Error -> emitFailure(res.throwable)
|
|
50
60
|
}
|
|
51
61
|
}
|
|
52
62
|
}
|
package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieCaptureView.kt
CHANGED
|
@@ -37,6 +37,7 @@ import com.smileidentity.compose.selfie.SmartSelfieInstructionsScreen
|
|
|
37
37
|
import com.smileidentity.compose.theme.colorScheme
|
|
38
38
|
import com.smileidentity.compose.theme.typography
|
|
39
39
|
import com.smileidentity.models.v2.Metadata
|
|
40
|
+
import com.smileidentity.react.results.SmartSelfieCaptureResult
|
|
40
41
|
import com.smileidentity.react.utils.SelfieCaptureResultAdapter
|
|
41
42
|
import com.smileidentity.results.SmileIDResult
|
|
42
43
|
import com.smileidentity.util.randomJobId
|
|
@@ -44,12 +45,7 @@ import com.smileidentity.util.randomUserId
|
|
|
44
45
|
import com.smileidentity.viewmodel.SelfieUiState
|
|
45
46
|
import com.smileidentity.viewmodel.SelfieViewModel
|
|
46
47
|
import com.smileidentity.viewmodel.viewModelFactory
|
|
47
|
-
import java.io.File
|
|
48
48
|
|
|
49
|
-
data class SmartSelfieCaptureResult(
|
|
50
|
-
val selfieFile: File? = null,
|
|
51
|
-
val livenessFiles: List<File >? = null
|
|
52
|
-
)
|
|
53
49
|
|
|
54
50
|
@OptIn(SmileIDOptIn::class)
|
|
55
51
|
class SmileIDSmartSelfieCaptureView(context: ReactApplicationContext) : SmileIDView(context) {
|
package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollmentView.kt
CHANGED
|
@@ -6,46 +6,56 @@ import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
|
|
|
6
6
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
7
|
import com.smileidentity.SmileID
|
|
8
8
|
import com.smileidentity.compose.SmartSelfieEnrollment
|
|
9
|
-
import com.smileidentity.results.
|
|
9
|
+
import com.smileidentity.react.results.SmartSelfieCaptureResult
|
|
10
|
+
import com.smileidentity.react.utils.SelfieCaptureResultAdapter
|
|
10
11
|
import com.smileidentity.results.SmileIDResult
|
|
11
|
-
import com.smileidentity.util.randomJobId
|
|
12
12
|
import com.smileidentity.util.randomUserId
|
|
13
13
|
import kotlinx.collections.immutable.toImmutableMap
|
|
14
|
-
import timber.log.Timber
|
|
15
14
|
|
|
16
15
|
class SmileIDSmartSelfieEnrollmentView(context: ReactApplicationContext) : SmileIDView(context) {
|
|
17
16
|
|
|
18
17
|
override fun renderContent() {
|
|
19
18
|
composeView.apply {
|
|
20
|
-
val customViewModelStoreOwner = CustomViewModelStoreOwner()
|
|
21
19
|
setContent {
|
|
20
|
+
val customViewModelStoreOwner = CustomViewModelStoreOwner()
|
|
22
21
|
CompositionLocalProvider(LocalViewModelStoreOwner provides customViewModelStoreOwner) {
|
|
23
22
|
SmileID.SmartSelfieEnrollment(
|
|
24
23
|
userId = userId ?: rememberSaveable { randomUserId() },
|
|
25
|
-
jobId = jobId ?: rememberSaveable { randomJobId() },
|
|
26
24
|
allowAgentMode = allowAgentMode ?: false,
|
|
27
25
|
allowNewEnroll = allowNewEnroll ?: false,
|
|
28
|
-
showAttribution = showAttribution
|
|
29
|
-
showInstructions = showInstructions
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
showAttribution = showAttribution,
|
|
27
|
+
showInstructions = showInstructions,
|
|
28
|
+
skipApiSubmission = skipApiSubmission,
|
|
29
|
+
extraPartnerParams = extraPartnerParams,
|
|
30
|
+
) { res ->
|
|
31
|
+
when (res) {
|
|
33
32
|
is SmileIDResult.Success -> {
|
|
34
|
-
val
|
|
33
|
+
val result =
|
|
34
|
+
SmartSelfieCaptureResult(
|
|
35
|
+
selfieFile = res.data.selfieFile,
|
|
36
|
+
livenessFiles = res.data.livenessFiles,
|
|
37
|
+
apiResponse = res.data.apiResponse,
|
|
38
|
+
)
|
|
39
|
+
val newMoshi =
|
|
35
40
|
SmileID.moshi
|
|
36
|
-
.
|
|
37
|
-
.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
.newBuilder()
|
|
42
|
+
.add(SelfieCaptureResultAdapter.FACTORY)
|
|
43
|
+
.build()
|
|
44
|
+
val json =
|
|
45
|
+
try {
|
|
46
|
+
newMoshi
|
|
47
|
+
.adapter(SmartSelfieCaptureResult::class.java)
|
|
48
|
+
.toJson(result)
|
|
49
|
+
} catch (e: Exception) {
|
|
50
|
+
emitFailure(e)
|
|
51
|
+
return@SmartSelfieEnrollment
|
|
52
|
+
}
|
|
53
|
+
json?.let { js ->
|
|
54
|
+
emitSuccess(js)
|
|
41
55
|
}
|
|
42
|
-
emitSuccess(json)
|
|
43
56
|
}
|
|
44
57
|
|
|
45
|
-
is SmileIDResult.Error ->
|
|
46
|
-
result.throwable.printStackTrace()
|
|
47
|
-
emitFailure(result.throwable)
|
|
48
|
-
}
|
|
58
|
+
is SmileIDResult.Error -> emitFailure(res.throwable)
|
|
49
59
|
}
|
|
50
60
|
}
|
|
51
61
|
}
|
|
@@ -11,9 +11,9 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
11
11
|
import com.facebook.react.bridge.ReactContext
|
|
12
12
|
import com.facebook.react.bridge.WritableMap
|
|
13
13
|
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
14
|
-
import com.smileidentity.SmileID
|
|
15
14
|
import com.smileidentity.models.JobType
|
|
16
|
-
import
|
|
15
|
+
import kotlinx.collections.immutable.ImmutableMap
|
|
16
|
+
import kotlinx.collections.immutable.persistentMapOf
|
|
17
17
|
import timber.log.Timber
|
|
18
18
|
|
|
19
19
|
@SuppressLint("CheckResult")
|
|
@@ -25,8 +25,9 @@ abstract class SmileIDView(context: ReactApplicationContext) : LinearLayout(cont
|
|
|
25
25
|
var allowAgentMode: Boolean? = false
|
|
26
26
|
var allowNewEnroll: Boolean? = false
|
|
27
27
|
var showInstructions: Boolean = true
|
|
28
|
+
var skipApiSubmission: Boolean = false
|
|
28
29
|
var showAttribution: Boolean = true
|
|
29
|
-
var extraPartnerParams:
|
|
30
|
+
var extraPartnerParams: ImmutableMap<String, String> = persistentMapOf()
|
|
30
31
|
private var eventEmitter: RCTEventEmitter
|
|
31
32
|
private var productThrowable: Throwable? = null
|
|
32
33
|
|
|
@@ -112,3 +113,4 @@ abstract class SmileIDView(context: ReactApplicationContext) : LinearLayout(cont
|
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
}
|
|
116
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
protocol SmileIDFileUtilsProtocol {
|
|
2
|
+
var fileManager: FileManager { get set }
|
|
3
|
+
func getFilePath(fileName: String) -> String?
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
extension SmileIDFileUtilsProtocol {
|
|
7
|
+
func getSmileIDDirectory() -> String? {
|
|
8
|
+
guard let documentsDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first else {
|
|
9
|
+
print("Unable to access documents directory")
|
|
10
|
+
return nil
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let smileIDDirectory = documentsDirectory.appendingPathComponent("SmileID")
|
|
14
|
+
return smileIDDirectory.absoluteURL.absoluteString
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
func getFilePath(fileName: String) -> String? {
|
|
18
|
+
guard let smileIDDirectory = getSmileIDDirectory() else {
|
|
19
|
+
return nil
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (smileIDDirectory as NSString).appendingPathComponent(fileName)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -2,59 +2,62 @@ import Foundation
|
|
|
2
2
|
import SmileID
|
|
3
3
|
import SwiftUI
|
|
4
4
|
|
|
5
|
-
struct SmileIDBiometricKYCView: View {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
5
|
+
struct SmileIDBiometricKYCView: View ,SmileIDFileUtilsProtocol {
|
|
6
|
+
var fileManager: FileManager = Foundation.FileManager.default
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var body: some View{
|
|
9
|
+
NavigationView {
|
|
10
|
+
if let idInfo = product.idInfo {
|
|
11
|
+
SmileID.biometricKycScreen(
|
|
12
|
+
idInfo: idInfo, // already validated in the SmileIDBiometricKYCViewManager
|
|
13
|
+
userId: product.userId ?? generateUserId(),
|
|
14
|
+
jobId: product.jobId ?? generateJobId(),
|
|
15
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
16
|
+
allowAgentMode: product.allowAgentMode,
|
|
17
|
+
showAttribution: product.showAttribution,
|
|
18
|
+
showInstructions: product.showInstructions,
|
|
19
|
+
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
20
|
+
delegate: self
|
|
21
|
+
)
|
|
22
|
+
} else {
|
|
23
|
+
// This exists for debugging purposes and will show in extreme cases
|
|
24
|
+
// when the params were not set NB: setParams in the viewmanager will always
|
|
25
|
+
// return an error if the required data is missing
|
|
26
|
+
Text("An error has occured")
|
|
27
|
+
}
|
|
28
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
29
|
+
}
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
extension SmileIDBiometricKYCView: BiometricKycResultDelegate {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
func didSucceed(
|
|
48
|
-
selfieImage _: URL,
|
|
49
|
-
livenessImages _: [URL],
|
|
50
|
-
jobStatusResponse: BiometricKycJobStatusResponse
|
|
51
|
-
) {
|
|
52
|
-
let encoder = JSONEncoder()
|
|
53
|
-
let jsonData = try! encoder.encode(jobStatusResponse)
|
|
54
|
-
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
func didError(error: Error) {
|
|
58
|
-
product.onResult?(["error": error.localizedDescription])
|
|
33
|
+
func didSucceed(selfieImage: URL, livenessImages: [URL], didSubmitBiometricJob: Bool) {
|
|
34
|
+
|
|
35
|
+
let params: [String: Any] = [
|
|
36
|
+
"selfieFile": getFilePath(fileName: selfieImage.absoluteString),
|
|
37
|
+
"livenessFiles": livenessImages.map {
|
|
38
|
+
getFilePath(fileName: $0.absoluteString)
|
|
39
|
+
},
|
|
40
|
+
"didSubmitBiometricKycJob": didSubmitBiometricJob,
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
|
|
44
|
+
product.onResult?(["error": SmileIDError.unknown("SmileIDBiometricKYCView encoding error")])
|
|
45
|
+
return
|
|
59
46
|
}
|
|
47
|
+
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
func didSucceed(
|
|
51
|
+
selfieImage _: URL,
|
|
52
|
+
livenessImages _: [URL],
|
|
53
|
+
jobStatusResponse: BiometricKycJobStatusResponse
|
|
54
|
+
) {
|
|
55
|
+
let encoder = JSONEncoder()
|
|
56
|
+
let jsonData = try! encoder.encode(jobStatusResponse)
|
|
57
|
+
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
func didError(error: Error) {
|
|
61
|
+
product.onResult?(["error": error.localizedDescription])
|
|
62
|
+
}
|
|
60
63
|
}
|
|
@@ -2,56 +2,60 @@ import Foundation
|
|
|
2
2
|
import SmileID
|
|
3
3
|
import SwiftUI
|
|
4
4
|
|
|
5
|
-
struct SmileIDDocumentVerificationView: View {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
5
|
+
struct SmileIDDocumentVerificationView: View ,SmileIDFileUtilsProtocol {
|
|
6
|
+
var fileManager: FileManager = Foundation.FileManager.default
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var body : some View {
|
|
9
|
+
AnyView(NavigationView {
|
|
10
|
+
if let countryCode = product.countryCode {
|
|
11
|
+
SmileID.documentVerificationScreen(
|
|
12
|
+
userId: product.userId ?? generateUserId(),
|
|
13
|
+
jobId: product.jobId ?? generateJobId(),
|
|
14
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
15
|
+
countryCode: countryCode, // already validated in SmileIDDocumentVerificationViewManager
|
|
16
|
+
documentType: product.documentType,
|
|
17
|
+
idAspectRatio: product.idAspectRatio,
|
|
18
|
+
bypassSelfieCaptureWithFile: product.bypassSelfieCaptureWithFilePath,
|
|
19
|
+
captureBothSides: product.captureBothSides,
|
|
20
|
+
allowAgentMode: product.allowAgentMode,
|
|
21
|
+
allowGalleryUpload: product.allowGalleryUpload,
|
|
22
|
+
showInstructions: product.showInstructions,
|
|
23
|
+
showAttribution: product.showAttribution,
|
|
24
|
+
skipApiSubmission: product.skipApiSubmission,
|
|
25
|
+
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
26
|
+
delegate: self
|
|
27
|
+
)
|
|
28
|
+
} else {
|
|
29
|
+
// This exists for debugging purposes and will show in extreme cases
|
|
30
|
+
// when the params were not set NB: setParams in the viewmanager will always
|
|
31
|
+
// return an error if the required data is missing
|
|
32
|
+
Text("An error has occured")
|
|
33
|
+
}
|
|
34
|
+
}.navigationViewStyle(StackNavigationViewStyle()))
|
|
35
|
+
}
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
extension SmileIDDocumentVerificationView: DocumentVerificationResultDelegate {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
|
|
48
|
-
product.onResult?(["error": SmileIDError.unknown("SmileIDDocumentVerificationView encoding error")])
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
39
|
+
func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, didSubmitDocumentVerificationJob: Bool) {
|
|
40
|
+
|
|
41
|
+
var params: [String: Any] = [
|
|
42
|
+
"selfieFile": getFilePath(fileName: selfie.absoluteString),
|
|
43
|
+
"documentFrontFile": getFilePath(fileName: documentFrontImage.absoluteString),
|
|
44
|
+
"didSubmitDocumentVerificationJob": didSubmitDocumentVerificationJob
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
if let documentBackImage = documentBackImage {
|
|
48
|
+
params["documentBackFile"] = getFilePath(fileName: documentBackImage.absoluteString)
|
|
52
49
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
|
|
51
|
+
guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
|
|
52
|
+
product.onResult?(["error": SmileIDError.unknown("SmileIDDocumentVerificationView encoding error")])
|
|
53
|
+
return
|
|
56
54
|
}
|
|
55
|
+
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
func didError(error: Error) {
|
|
59
|
+
product.onResult?(["error": error.localizedDescription])
|
|
60
|
+
}
|
|
57
61
|
}
|
|
@@ -2,56 +2,59 @@ import Foundation
|
|
|
2
2
|
import SmileID
|
|
3
3
|
import SwiftUI
|
|
4
4
|
|
|
5
|
-
struct SmileIDEnhancedDocumentVerificationView: View {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
5
|
+
struct SmileIDEnhancedDocumentVerificationView: View,SmileIDFileUtilsProtocol {
|
|
6
|
+
var fileManager: FileManager = Foundation.FileManager.default
|
|
7
|
+
@ObservedObject var product : SmileIDProductModel
|
|
8
|
+
var body: some View {
|
|
9
|
+
NavigationView {
|
|
10
|
+
if let countryCode = product.countryCode {
|
|
11
|
+
SmileID.enhancedDocumentVerificationScreen(
|
|
12
|
+
userId: product.userId ?? generateUserId(),
|
|
13
|
+
jobId: product.jobId ?? generateJobId(),
|
|
14
|
+
allowNewEnroll: product.allowNewEnroll,
|
|
15
|
+
countryCode: countryCode, // already validated in the view manager
|
|
16
|
+
documentType: product.documentType,
|
|
17
|
+
idAspectRatio: product.idAspectRatio,
|
|
18
|
+
bypassSelfieCaptureWithFile: product.bypassSelfieCaptureWithFilePath,
|
|
19
|
+
captureBothSides: product.captureBothSides,
|
|
20
|
+
allowAgentMode: product.allowAgentMode,
|
|
21
|
+
allowGalleryUpload: product.allowGalleryUpload,
|
|
22
|
+
showInstructions: product.showInstructions,
|
|
23
|
+
skipApiSubmission: product.skipApiSubmission,
|
|
24
|
+
showAttribution: product.showAttribution,
|
|
25
|
+
extraPartnerParams: product.extraPartnerParams as [String: String],
|
|
26
|
+
delegate: self
|
|
27
|
+
)
|
|
28
|
+
} else {
|
|
29
|
+
// This exists for debugging purposes and will show in extreme cases
|
|
30
|
+
// when the params were not set NB: setParams in the viewmanager will always
|
|
31
|
+
// return an error if the required data is missing
|
|
32
|
+
Text("An error has occured")
|
|
33
|
+
}
|
|
34
|
+
}.navigationViewStyle(StackNavigationViewStyle())
|
|
35
|
+
}
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
extension SmileIDEnhancedDocumentVerificationView: EnhancedDocumentVerificationResultDelegate {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
|
|
48
|
-
product.onResult?(["error": SmileIDError.unknown("SmileIDEnhancedDocumentVerificationView encoding error")])
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
39
|
+
func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, didSubmitEnhancedDocVJob: Bool) {
|
|
40
|
+
var params: [String: Any] = [
|
|
41
|
+
"selfieFile": getFilePath(fileName: selfie.absoluteString),
|
|
42
|
+
"documentFrontFile": getFilePath(fileName: documentFrontImage.absoluteString),
|
|
43
|
+
"didSubmitEnhancedDocVJob": didSubmitEnhancedDocVJob
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
if let documentBackImage = documentBackImage {
|
|
47
|
+
params["documentBackFile"] = getFilePath(fileName: documentBackImage.absoluteString)
|
|
52
48
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
|
|
50
|
+
guard let jsonData = try? JSONSerialization.data(withJSONObject: params.toJSONCompatibleDictionary(), options: .prettyPrinted) else {
|
|
51
|
+
product.onResult?(["error": SmileIDError.unknown("SmileIDEnhancedDocumentVerificationView encoding error")])
|
|
52
|
+
return
|
|
56
53
|
}
|
|
54
|
+
product.onResult?(["result": String(data: jsonData, encoding: .utf8)!])
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
func didError(error: Error) {
|
|
58
|
+
product.onResult?(["error": error.localizedDescription])
|
|
59
|
+
}
|
|
57
60
|
}
|