@smile_identity/react-native 10.1.12 → 10.2.0
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/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/SelfieCaptureResultAdapter.kt +28 -17
- package/android/src/main/java/com/smileidentity/react/views/SmileIDBiometricKYCView.kt +26 -15
- package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentCaptureView.kt +1 -8
- package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerificationView.kt +28 -15
- package/android/src/main/java/com/smileidentity/react/views/SmileIDEnhancedDocumentVerificationView.kt +28 -15
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthenticationView.kt +26 -16
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieCaptureView.kt +1 -5
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollmentView.kt +26 -16
- package/ios/Utils/FileUtils.swift +24 -0
- package/ios/View/SmileIDBiometricKYCView.swift +54 -51
- package/ios/View/SmileIDDocumentVerificationView.swift +50 -47
- package/ios/View/SmileIDEnhancedDocumentVerificationView.swift +49 -47
- package/ios/View/SmileIDSmartSelfieAuthView.swift +35 -33
- package/ios/View/SmileIDSmartSelfieCaptureView.swift +4 -41
- package/ios/View/SmileIDSmartSelfieEnrollmentView.swift +35 -33
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/types.d.ts +4 -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 +10 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.smileidentity.react.results
|
|
2
|
+
|
|
3
|
+
import java.io.File
|
|
4
|
+
|
|
5
|
+
data class DocumentCaptureResult(
|
|
6
|
+
val selfieFile: File? = null,
|
|
7
|
+
val documentFrontFile: File? = null,
|
|
8
|
+
val livenessFiles: List<File>? = null,
|
|
9
|
+
val documentBackFile: File? = null,
|
|
10
|
+
val didSubmitDocumentVerificationJob: Boolean? = null,
|
|
11
|
+
val didSubmitEnhancedDocVJob: Boolean? = null
|
|
12
|
+
)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
package com.smileidentity.react.results
|
|
2
|
+
|
|
3
|
+
import com.smileidentity.models.v2.SmartSelfieResponse
|
|
4
|
+
import java.io.File
|
|
5
|
+
|
|
6
|
+
data class SmartSelfieCaptureResult(
|
|
7
|
+
val selfieFile: File? = null,
|
|
8
|
+
val livenessFiles: List<File>? = null,
|
|
9
|
+
val apiResponse: SmartSelfieResponse? = null,
|
|
10
|
+
val didSubmitBiometricKycJob: Boolean? = null
|
|
11
|
+
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
package com.smileidentity.react.utils
|
|
2
2
|
|
|
3
|
-
import com.smileidentity.react.
|
|
3
|
+
import com.smileidentity.react.results.DocumentCaptureResult
|
|
4
4
|
import com.squareup.moshi.FromJson
|
|
5
5
|
import com.squareup.moshi.JsonAdapter
|
|
6
6
|
import com.squareup.moshi.JsonReader
|
|
@@ -15,17 +15,44 @@ class DocumentCaptureResultAdapter : JsonAdapter<DocumentCaptureResult>() {
|
|
|
15
15
|
@FromJson
|
|
16
16
|
override fun fromJson(reader: JsonReader): DocumentCaptureResult {
|
|
17
17
|
reader.beginObject()
|
|
18
|
+
var selfieFile: File? = null
|
|
18
19
|
var frontFile: File? = null
|
|
19
20
|
var backFile: File? = null
|
|
21
|
+
var livenessFiles: MutableList<File>? = null
|
|
22
|
+
var didSubmitDocumentVerificationJob: Boolean? = null
|
|
23
|
+
var didSubmitEnhancedDocVJob: Boolean? = null
|
|
24
|
+
|
|
20
25
|
while (reader.hasNext()) {
|
|
21
26
|
when (reader.nextName()) {
|
|
27
|
+
"selfieFile" -> selfieFile = reader.nextString()?.let { File(it) }
|
|
22
28
|
"documentFrontFile" -> frontFile = reader.nextString()?.let { File(it) }
|
|
23
29
|
"documentBackFile" -> backFile = reader.nextString()?.let { File(it) }
|
|
30
|
+
"livenessFiles" -> {
|
|
31
|
+
livenessFiles = mutableListOf()
|
|
32
|
+
reader.beginArray()
|
|
33
|
+
while (reader.hasNext()) {
|
|
34
|
+
reader.nextString()?.let { livenessFiles.add(File(it)) }
|
|
35
|
+
}
|
|
36
|
+
reader.endArray()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
"didSubmitDocumentVerificationJob" -> didSubmitDocumentVerificationJob =
|
|
40
|
+
reader.nextBoolean()
|
|
41
|
+
|
|
42
|
+
"didSubmitEnhancedDocVJob" -> didSubmitEnhancedDocVJob = reader.nextBoolean()
|
|
24
43
|
else -> reader.skipValue()
|
|
25
44
|
}
|
|
26
45
|
}
|
|
27
46
|
reader.endObject()
|
|
28
|
-
|
|
47
|
+
|
|
48
|
+
return DocumentCaptureResult(
|
|
49
|
+
selfieFile = selfieFile,
|
|
50
|
+
documentFrontFile = frontFile,
|
|
51
|
+
documentBackFile = backFile,
|
|
52
|
+
livenessFiles = livenessFiles,
|
|
53
|
+
didSubmitDocumentVerificationJob = didSubmitDocumentVerificationJob,
|
|
54
|
+
didSubmitEnhancedDocVJob = didSubmitEnhancedDocVJob
|
|
55
|
+
)
|
|
29
56
|
}
|
|
30
57
|
|
|
31
58
|
@ToJson
|
|
@@ -34,9 +61,26 @@ class DocumentCaptureResultAdapter : JsonAdapter<DocumentCaptureResult>() {
|
|
|
34
61
|
writer.nullValue()
|
|
35
62
|
return
|
|
36
63
|
}
|
|
64
|
+
|
|
37
65
|
writer.beginObject()
|
|
66
|
+
writer.name("selfieFile").value(value.selfieFile?.absolutePath)
|
|
38
67
|
writer.name("documentFrontFile").value(value.documentFrontFile?.absolutePath)
|
|
39
68
|
writer.name("documentBackFile").value(value.documentBackFile?.absolutePath)
|
|
69
|
+
|
|
70
|
+
writer.name("livenessFiles")
|
|
71
|
+
if (value.livenessFiles == null) {
|
|
72
|
+
writer.nullValue()
|
|
73
|
+
} else {
|
|
74
|
+
writer.beginArray()
|
|
75
|
+
for (file in value.livenessFiles) {
|
|
76
|
+
writer.value(file.absolutePath)
|
|
77
|
+
}
|
|
78
|
+
writer.endArray()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
writer.name("didSubmitDocumentVerificationJob").value(value.didSubmitDocumentVerificationJob)
|
|
82
|
+
writer.name("didSubmitEnhancedDocVJob").value(value.didSubmitEnhancedDocVJob)
|
|
83
|
+
|
|
40
84
|
writer.endObject()
|
|
41
85
|
}
|
|
42
86
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
package com.smileidentity.react.utils
|
|
2
2
|
|
|
3
|
-
import com.smileidentity.
|
|
3
|
+
import com.smileidentity.SmileID
|
|
4
|
+
import com.smileidentity.models.v2.SmartSelfieResponse
|
|
5
|
+
import com.smileidentity.react.results.SmartSelfieCaptureResult
|
|
4
6
|
import com.squareup.moshi.FromJson
|
|
5
7
|
import com.squareup.moshi.JsonAdapter
|
|
8
|
+
import com.squareup.moshi.JsonAdapter.Factory
|
|
6
9
|
import com.squareup.moshi.JsonReader
|
|
7
10
|
import com.squareup.moshi.JsonWriter
|
|
8
|
-
import com.squareup.moshi.Moshi
|
|
9
11
|
import com.squareup.moshi.ToJson
|
|
10
12
|
import java.io.File
|
|
11
|
-
import java.lang.reflect.Type
|
|
12
13
|
|
|
13
14
|
class SelfieCaptureResultAdapter : JsonAdapter<SmartSelfieCaptureResult>() {
|
|
14
15
|
|
|
@@ -17,23 +18,35 @@ class SelfieCaptureResultAdapter : JsonAdapter<SmartSelfieCaptureResult>() {
|
|
|
17
18
|
reader.beginObject()
|
|
18
19
|
var selfieFile: File? = null
|
|
19
20
|
var livenessFiles: List<File>? = null
|
|
21
|
+
var apiResponse: SmartSelfieResponse? = null
|
|
22
|
+
|
|
20
23
|
while (reader.hasNext()) {
|
|
21
24
|
when (reader.nextName()) {
|
|
22
25
|
"selfieFile" -> selfieFile = reader.nextString()?.let { File(it) }
|
|
23
26
|
"livenessFiles" -> {
|
|
24
|
-
|
|
27
|
+
// Assuming livenessFiles is an array of file paths in the JSON
|
|
25
28
|
val files = mutableListOf<File>()
|
|
29
|
+
reader.beginArray()
|
|
26
30
|
while (reader.hasNext()) {
|
|
27
31
|
reader.nextString()?.let { files.add(File(it)) }
|
|
28
32
|
}
|
|
29
33
|
reader.endArray()
|
|
30
34
|
livenessFiles = files
|
|
31
35
|
}
|
|
36
|
+
|
|
37
|
+
"apiResponse" -> apiResponse =
|
|
38
|
+
SmileID.moshi.adapter(SmartSelfieResponse::class.java).fromJson(reader)
|
|
39
|
+
|
|
32
40
|
else -> reader.skipValue()
|
|
33
41
|
}
|
|
34
42
|
}
|
|
43
|
+
|
|
35
44
|
reader.endObject()
|
|
36
|
-
return SmartSelfieCaptureResult(
|
|
45
|
+
return SmartSelfieCaptureResult(
|
|
46
|
+
selfieFile = selfieFile,
|
|
47
|
+
livenessFiles = livenessFiles,
|
|
48
|
+
apiResponse = apiResponse
|
|
49
|
+
)
|
|
37
50
|
}
|
|
38
51
|
|
|
39
52
|
@ToJson
|
|
@@ -44,24 +57,22 @@ class SelfieCaptureResultAdapter : JsonAdapter<SmartSelfieCaptureResult>() {
|
|
|
44
57
|
}
|
|
45
58
|
writer.beginObject()
|
|
46
59
|
writer.name("selfieFile").value(value.selfieFile?.absolutePath)
|
|
60
|
+
|
|
47
61
|
writer.name("livenessFiles")
|
|
48
62
|
writer.beginArray()
|
|
49
|
-
value.livenessFiles?.forEach {
|
|
50
|
-
writer.value(file.absolutePath)
|
|
51
|
-
}
|
|
63
|
+
value.livenessFiles?.forEach { writer.value(it.absolutePath) }
|
|
52
64
|
writer.endArray()
|
|
65
|
+
|
|
66
|
+
writer.name("apiResponse")
|
|
67
|
+
if (value.apiResponse != null) {
|
|
68
|
+
SmileID.moshi.adapter(SmartSelfieResponse::class.java).toJson(writer, value.apiResponse)
|
|
69
|
+
} else {
|
|
70
|
+
writer.nullValue()
|
|
71
|
+
}
|
|
53
72
|
writer.endObject()
|
|
54
73
|
}
|
|
55
74
|
|
|
56
75
|
companion object {
|
|
57
|
-
val FACTORY =
|
|
58
|
-
override fun create(
|
|
59
|
-
type: Type,
|
|
60
|
-
annotations: Set<Annotation>,
|
|
61
|
-
moshi: Moshi
|
|
62
|
-
): JsonAdapter<*>? {
|
|
63
|
-
return if (type == SmartSelfieCaptureResult::class.java) SelfieCaptureResultAdapter() else null
|
|
64
|
-
}
|
|
65
|
-
}
|
|
76
|
+
val FACTORY = Factory { type, annotations, moshi -> if (type == SmartSelfieCaptureResult::class.java) SelfieCaptureResultAdapter() else null }
|
|
66
77
|
}
|
|
67
78
|
}
|
|
@@ -7,12 +7,12 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
7
7
|
import com.smileidentity.SmileID
|
|
8
8
|
import com.smileidentity.compose.BiometricKYC
|
|
9
9
|
import com.smileidentity.models.IdInfo
|
|
10
|
-
import com.smileidentity.results.
|
|
10
|
+
import com.smileidentity.react.results.SmartSelfieCaptureResult
|
|
11
|
+
import com.smileidentity.react.utils.SelfieCaptureResultAdapter
|
|
11
12
|
import com.smileidentity.results.SmileIDResult
|
|
12
13
|
import com.smileidentity.util.randomJobId
|
|
13
14
|
import com.smileidentity.util.randomUserId
|
|
14
15
|
import kotlinx.collections.immutable.toImmutableMap
|
|
15
|
-
import timber.log.Timber
|
|
16
16
|
|
|
17
17
|
class SmileIDBiometricKYCView(context: ReactApplicationContext) : SmileIDView(context) {
|
|
18
18
|
var idInfo: IdInfo? = null
|
|
@@ -35,24 +35,35 @@ class SmileIDBiometricKYCView(context: ReactApplicationContext) : SmileIDView(co
|
|
|
35
35
|
showAttribution = showAttribution ?: true,
|
|
36
36
|
showInstructions = showInstructions ?: true,
|
|
37
37
|
extraPartnerParams = (extraPartnerParams ?: mapOf()).toImmutableMap(),
|
|
38
|
-
) {
|
|
39
|
-
when (
|
|
38
|
+
) { res ->
|
|
39
|
+
when (res) {
|
|
40
40
|
is SmileIDResult.Success -> {
|
|
41
|
-
val
|
|
41
|
+
val result =
|
|
42
|
+
SmartSelfieCaptureResult(
|
|
43
|
+
selfieFile = res.data.selfieFile,
|
|
44
|
+
livenessFiles = res.data.livenessFiles,
|
|
45
|
+
didSubmitBiometricKycJob = res.data.didSubmitBiometricKycJob,
|
|
46
|
+
)
|
|
47
|
+
val newMoshi =
|
|
42
48
|
SmileID.moshi
|
|
43
|
-
.
|
|
44
|
-
.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
.newBuilder()
|
|
50
|
+
.add(SelfieCaptureResultAdapter.FACTORY)
|
|
51
|
+
.build()
|
|
52
|
+
val json =
|
|
53
|
+
try {
|
|
54
|
+
newMoshi
|
|
55
|
+
.adapter(SmartSelfieCaptureResult::class.java)
|
|
56
|
+
.toJson(result)
|
|
57
|
+
} catch (e: Exception) {
|
|
58
|
+
emitFailure(e)
|
|
59
|
+
return@BiometricKYC
|
|
60
|
+
}
|
|
61
|
+
json?.let { js ->
|
|
62
|
+
emitSuccess(js)
|
|
48
63
|
}
|
|
49
|
-
emitSuccess(json)
|
|
50
64
|
}
|
|
51
65
|
|
|
52
|
-
is SmileIDResult.Error ->
|
|
53
|
-
result.throwable.printStackTrace()
|
|
54
|
-
emitFailure(result.throwable)
|
|
55
|
-
}
|
|
66
|
+
is SmileIDResult.Error -> emitFailure(res.throwable)
|
|
56
67
|
}
|
|
57
68
|
}
|
|
58
69
|
}
|
|
@@ -17,22 +17,15 @@ import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner
|
|
|
17
17
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
18
18
|
import com.smileidentity.R
|
|
19
19
|
import com.smileidentity.SmileID
|
|
20
|
-
import com.smileidentity.SmileIDOptIn
|
|
21
20
|
import com.smileidentity.compose.document.DocumentCaptureScreen
|
|
22
21
|
import com.smileidentity.compose.document.DocumentCaptureSide
|
|
23
22
|
import com.smileidentity.compose.theme.colorScheme
|
|
23
|
+
import com.smileidentity.react.results.DocumentCaptureResult
|
|
24
24
|
import com.smileidentity.react.utils.DocumentCaptureResultAdapter
|
|
25
25
|
import com.smileidentity.util.randomJobId
|
|
26
|
-
import com.squareup.moshi.JsonClass
|
|
27
26
|
import timber.log.Timber
|
|
28
27
|
import java.io.File
|
|
29
28
|
|
|
30
|
-
data class DocumentCaptureResult(
|
|
31
|
-
val documentFrontFile: File? = null,
|
|
32
|
-
val documentBackFile: File? = null
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
@OptIn(SmileIDOptIn::class)
|
|
36
29
|
class SmileIDDocumentCaptureView(context: ReactApplicationContext) : SmileIDView(context) {
|
|
37
30
|
var showConfirmation: Boolean = true
|
|
38
31
|
var front: Boolean = true
|
package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerificationView.kt
CHANGED
|
@@ -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.DocumentVerification
|
|
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
|
import java.io.File
|
|
16
16
|
|
|
17
17
|
class SmileIDDocumentVerificationView(context: ReactApplicationContext) : SmileIDView(context) {
|
|
@@ -49,24 +49,37 @@ class SmileIDDocumentVerificationView(context: ReactApplicationContext) : SmileI
|
|
|
49
49
|
allowNewEnroll = allowNewEnroll ?: false,
|
|
50
50
|
bypassSelfieCaptureWithFile = bypassSelfieCaptureWithFile,
|
|
51
51
|
extraPartnerParams = (extraPartnerParams ?: mapOf()).toImmutableMap(),
|
|
52
|
-
) {
|
|
53
|
-
when (
|
|
52
|
+
) { res ->
|
|
53
|
+
when (res) {
|
|
54
54
|
is SmileIDResult.Success -> {
|
|
55
|
-
val
|
|
55
|
+
val result =
|
|
56
|
+
DocumentCaptureResult(
|
|
57
|
+
selfieFile = res.data.selfieFile,
|
|
58
|
+
documentFrontFile = res.data.documentFrontFile,
|
|
59
|
+
livenessFiles = res.data.livenessFiles,
|
|
60
|
+
documentBackFile = res.data.documentBackFile,
|
|
61
|
+
didSubmitDocumentVerificationJob = res.data.didSubmitDocumentVerificationJob,
|
|
62
|
+
)
|
|
63
|
+
val newMoshi =
|
|
56
64
|
SmileID.moshi
|
|
57
|
-
.
|
|
58
|
-
.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
.newBuilder()
|
|
66
|
+
.add(DocumentCaptureResultAdapter.FACTORY)
|
|
67
|
+
.build()
|
|
68
|
+
val json =
|
|
69
|
+
try {
|
|
70
|
+
newMoshi
|
|
71
|
+
.adapter(DocumentCaptureResult::class.java)
|
|
72
|
+
.toJson(result)
|
|
73
|
+
} catch (e: Exception) {
|
|
74
|
+
emitFailure(e)
|
|
75
|
+
return@DocumentVerification
|
|
76
|
+
}
|
|
77
|
+
json?.let { js ->
|
|
78
|
+
emitSuccess(js)
|
|
62
79
|
}
|
|
63
|
-
emitSuccess(json)
|
|
64
80
|
}
|
|
65
81
|
|
|
66
|
-
is SmileIDResult.Error ->
|
|
67
|
-
result.throwable.printStackTrace()
|
|
68
|
-
emitFailure(result.throwable)
|
|
69
|
-
}
|
|
82
|
+
is SmileIDResult.Error -> emitFailure(res.throwable)
|
|
70
83
|
}
|
|
71
84
|
}
|
|
72
85
|
}
|
|
@@ -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) {
|
|
@@ -44,24 +44,37 @@ class SmileIDEnhancedDocumentVerificationView(context: ReactApplicationContext)
|
|
|
44
44
|
allowGalleryUpload = allowGalleryUpload,
|
|
45
45
|
captureBothSides = captureBothSides,
|
|
46
46
|
extraPartnerParams = (extraPartnerParams ?: mapOf()).toImmutableMap(),
|
|
47
|
-
) {
|
|
48
|
-
when (
|
|
47
|
+
) { res ->
|
|
48
|
+
when (res) {
|
|
49
49
|
is SmileIDResult.Success -> {
|
|
50
|
-
val
|
|
50
|
+
val result =
|
|
51
|
+
DocumentCaptureResult(
|
|
52
|
+
selfieFile = res.data.selfieFile,
|
|
53
|
+
documentFrontFile = res.data.documentFrontFile,
|
|
54
|
+
livenessFiles = res.data.livenessFiles,
|
|
55
|
+
documentBackFile = res.data.documentBackFile,
|
|
56
|
+
didSubmitEnhancedDocVJob = res.data.didSubmitEnhancedDocVJob,
|
|
57
|
+
)
|
|
58
|
+
val newMoshi =
|
|
51
59
|
SmileID.moshi
|
|
52
|
-
.
|
|
53
|
-
.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
.newBuilder()
|
|
61
|
+
.add(DocumentCaptureResultAdapter.FACTORY)
|
|
62
|
+
.build()
|
|
63
|
+
val json =
|
|
64
|
+
try {
|
|
65
|
+
newMoshi
|
|
66
|
+
.adapter(DocumentCaptureResult::class.java)
|
|
67
|
+
.toJson(result)
|
|
68
|
+
} catch (e: Exception) {
|
|
69
|
+
emitFailure(e)
|
|
70
|
+
return@EnhancedDocumentVerificationScreen
|
|
71
|
+
}
|
|
72
|
+
json?.let { js ->
|
|
73
|
+
emitSuccess(js)
|
|
57
74
|
}
|
|
58
|
-
emitSuccess(json)
|
|
59
75
|
}
|
|
60
76
|
|
|
61
|
-
is SmileIDResult.Error ->
|
|
62
|
-
result.throwable.printStackTrace()
|
|
63
|
-
emitFailure(result.throwable)
|
|
64
|
-
}
|
|
77
|
+
is SmileIDResult.Error -> emitFailure(res.throwable)
|
|
65
78
|
}
|
|
66
79
|
}
|
|
67
80
|
}
|
package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthenticationView.kt
CHANGED
|
@@ -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.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
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 SmileIDSmartSelfieAuthenticationView(context: ReactApplicationContext) :
|
|
17
17
|
SmileIDView(context) {
|
|
@@ -23,30 +23,40 @@ class SmileIDSmartSelfieAuthenticationView(context: ReactApplicationContext) :
|
|
|
23
23
|
CompositionLocalProvider(LocalViewModelStoreOwner provides customViewModelStoreOwner) {
|
|
24
24
|
SmileID.SmartSelfieAuthentication(
|
|
25
25
|
userId = userId ?: rememberSaveable { randomUserId() },
|
|
26
|
-
jobId = jobId ?: rememberSaveable { randomJobId() },
|
|
27
26
|
allowAgentMode = allowAgentMode ?: false,
|
|
28
27
|
allowNewEnroll = allowNewEnroll ?: false,
|
|
29
28
|
showAttribution = showAttribution ?: true,
|
|
30
29
|
showInstructions = showInstructions ?: true,
|
|
31
30
|
extraPartnerParams = (extraPartnerParams ?: mapOf()).toImmutableMap(),
|
|
32
|
-
) {
|
|
33
|
-
when (
|
|
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,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.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
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 SmileIDSmartSelfieEnrollmentView(context: ReactApplicationContext) : SmileIDView(context) {
|
|
17
17
|
|
|
@@ -22,30 +22,40 @@ class SmileIDSmartSelfieEnrollmentView(context: ReactApplicationContext) : Smile
|
|
|
22
22
|
CompositionLocalProvider(LocalViewModelStoreOwner provides customViewModelStoreOwner) {
|
|
23
23
|
SmileID.SmartSelfieEnrollment(
|
|
24
24
|
userId = userId ?: rememberSaveable { randomUserId() },
|
|
25
|
-
jobId = jobId ?: rememberSaveable { randomJobId() },
|
|
26
25
|
allowAgentMode = allowAgentMode ?: false,
|
|
27
26
|
allowNewEnroll = allowNewEnroll ?: false,
|
|
28
27
|
showAttribution = showAttribution ?: true,
|
|
29
28
|
showInstructions = showInstructions ?: true,
|
|
30
29
|
extraPartnerParams = (extraPartnerParams ?: mapOf()).toImmutableMap(),
|
|
31
|
-
) {
|
|
32
|
-
when (
|
|
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
|
}
|
|
@@ -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
|
+
}
|