@smile_identity/react-native 10.2.1 → 10.2.3
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/README.md +4 -28
- package/android/build.gradle +12 -6
- package/android/gradle.properties +4 -3
- package/android/src/main/java/com/smileidentity/react/Mapper.kt +2 -3
- package/android/src/main/java/com/smileidentity/react/SmileIdModule.kt +37 -39
- package/android/src/main/java/com/smileidentity/react/SmileIdPackage.kt +4 -0
- package/android/src/main/java/com/smileidentity/react/results/BiometricKycCaptureResult.kt +9 -0
- package/android/src/main/java/com/smileidentity/react/results/SmartSelfieCaptureResult.kt +3 -2
- package/android/src/main/java/com/smileidentity/react/utils/BiometricKycCaptureResultAdapter.kt +69 -0
- package/android/src/main/java/com/smileidentity/react/utils/SelfieCaptureResultAdapter.kt +0 -2
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieAuthenticationEnhancedViewManager.kt +64 -0
- package/android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieEnrollmentEnhancedViewManager.kt +64 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDBiometricKYCView.kt +7 -7
- package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentCaptureView.kt +9 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerificationView.kt +2 -4
- package/android/src/main/java/com/smileidentity/react/views/SmileIDEnhancedDocumentVerificationView.kt +3 -5
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthenticationEnhancedView.kt +61 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthenticationView.kt +0 -2
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollmentEnhancedView.kt +60 -0
- package/android/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollmentView.kt +0 -2
- package/android/src/oldarch/SmileIdSpec.kt +3 -12
- package/ios/RNSmileID.mm +6 -3
- package/ios/RNSmileID.swift +470 -477
- package/ios/View/SmileIDSmartSelfieAuthEnhancedView.swift +44 -0
- package/ios/View/SmileIDSmartSelfieAuthView.swift +2 -3
- package/ios/View/SmileIDSmartSelfieCaptureView.swift +2 -2
- package/ios/View/SmileIDSmartSelfieEnrollmentEnhancedView.swift +44 -0
- package/ios/ViewManagers/SmileIDSmartSelfieAuthenticationEnhancedViewManager.m +7 -0
- package/ios/ViewManagers/SmileIDSmartSelfieAuthenticationEnhancedViewManager.swift +25 -0
- package/ios/ViewManagers/SmileIDSmartSelfieEnrollmentEnhancedViewManager.m +7 -0
- package/ios/ViewManagers/SmileIDSmartSelfieEnrollmentEnhancedViewManager.swift +25 -0
- package/lib/commonjs/NativeSmileId.js.map +1 -1
- package/lib/commonjs/SmileIDDocumentCaptureView.js.map +1 -1
- package/lib/commonjs/SmileIDSmartSelfieAuthenticationEnhancedView.js +40 -0
- package/lib/commonjs/SmileIDSmartSelfieAuthenticationEnhancedView.js.map +1 -0
- package/lib/commonjs/SmileIDSmartSelfieEnrollmentEnhancedView.js +40 -0
- package/lib/commonjs/SmileIDSmartSelfieEnrollmentEnhancedView.js.map +1 -0
- package/lib/commonjs/index.js +26 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/NativeSmileId.js.map +1 -1
- package/lib/module/SmileIDDocumentCaptureView.js.map +1 -1
- package/lib/module/SmileIDSmartSelfieAuthenticationEnhancedView.js +30 -0
- package/lib/module/SmileIDSmartSelfieAuthenticationEnhancedView.js.map +1 -0
- package/lib/module/SmileIDSmartSelfieEnrollmentEnhancedView.js +30 -0
- package/lib/module/SmileIDSmartSelfieEnrollmentEnhancedView.js.map +1 -0
- package/lib/module/index.js +10 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/NativeSmileId.d.ts +6 -4
- package/lib/typescript/NativeSmileId.d.ts.map +1 -1
- package/lib/typescript/SmileIDDocumentCaptureView.d.ts +2 -2
- package/lib/typescript/SmileIDDocumentCaptureView.d.ts.map +1 -1
- package/lib/typescript/SmileIDSmartSelfieAuthenticationEnhancedView.d.ts +8 -0
- package/lib/typescript/SmileIDSmartSelfieAuthenticationEnhancedView.d.ts.map +1 -0
- package/lib/typescript/SmileIDSmartSelfieEnrollmentEnhancedView.d.ts +8 -0
- package/lib/typescript/SmileIDSmartSelfieEnrollmentEnhancedView.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +12 -6
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +2 -0
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/react-native-smile-id.podspec +1 -1
- package/src/NativeSmileId.ts +10 -14
- package/src/SmileIDDocumentCaptureView.tsx +4 -4
- package/src/SmileIDSmartSelfieAuthenticationEnhancedView.tsx +47 -0
- package/src/SmileIDSmartSelfieEnrollmentEnhancedView.tsx +47 -0
- package/src/index.tsx +21 -2
- package/src/types.ts +8 -0
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Please see [CHANGELOG.md](CHANGELOG.md) or [Releases](https://github.com/smileid
|
|
|
20
20
|
|
|
21
21
|
## Getting Started
|
|
22
22
|
|
|
23
|
-
Full documentation is available at [Smile ID Documentation](https://docs.usesmileid.com/integration-options/mobile)
|
|
23
|
+
Full documentation is available at [Smile ID Documentation]((https://docs.usesmileid.com/integration-options/mobile/getting-started))
|
|
24
24
|
|
|
25
25
|
### 0. Requirements
|
|
26
26
|
|
|
@@ -44,36 +44,12 @@ Add the dependency to your `package.json`:
|
|
|
44
44
|
}
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
### 2. Smile Config
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
### 2. Initialization
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
There are multiple ways to initialize the SDK. See [Initialization](https://docs.usesmileid.com/integration-options/mobile/getting-started) and choose the best option
|
|
51
|
+
for your integration
|
|
52
52
|
|
|
53
|
-
#### iOS
|
|
54
|
-
|
|
55
|
-
Drag the `smile_config.json` into your project's file inspector and ensure that the file is added to your app's target. Confirm that it is by checking the Copy Bundle Resources drop down in the Build Phases tab as shown below.
|
|
56
|
-
|
|
57
|
-
### 3. Initialization
|
|
58
|
-
|
|
59
|
-
Initialize the Smile ID SDK in your app's entry file (normally `index.tsx`) by calling `initialize`:
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
import { initialize } from 'rn-smile-id';
|
|
63
|
-
import React, { useEffect } from 'react';
|
|
64
|
-
|
|
65
|
-
const App = () => {
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
initialize().then(() => console.log('Smile ID Initialized'));
|
|
68
|
-
}, []);
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
// ...rest of your component
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export default App;
|
|
76
|
-
```
|
|
77
53
|
|
|
78
54
|
## Getting Help
|
|
79
55
|
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,6 @@ import com.android.Version
|
|
|
3
3
|
buildscript {
|
|
4
4
|
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
5
5
|
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["SmileId_kotlinVersion"]
|
|
6
|
-
def smile_id_sdk_version = rootProject.ext.has("androidVersion") ? rootProject.ext.get("androidVersion") : project.properties["SmileId_androidVersion"]
|
|
7
6
|
|
|
8
7
|
repositories {
|
|
9
8
|
google()
|
|
@@ -14,7 +13,9 @@ buildscript {
|
|
|
14
13
|
dependencies {
|
|
15
14
|
classpath "com.android.tools.build:gradle:8.3.2"
|
|
16
15
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
17
|
-
|
|
16
|
+
if (kotlinVersion?.startsWith("2")) {
|
|
17
|
+
classpath "org.jetbrains.kotlin:compose-compiler-gradle-plugin:$kotlin_version"
|
|
18
|
+
}
|
|
18
19
|
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
|
19
20
|
classpath "org.jlleitschuh.gradle:ktlint-gradle:12.1.1"
|
|
20
21
|
}
|
|
@@ -25,12 +26,16 @@ def reactNativeArchitectures() {
|
|
|
25
26
|
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
def kotlinVersion = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["SmileId_kotlinVersion"]
|
|
30
|
+
|
|
28
31
|
apply plugin: "com.android.library"
|
|
29
32
|
apply plugin: "kotlin-android"
|
|
30
33
|
apply plugin: 'kotlin-kapt'
|
|
31
34
|
apply plugin: "org.jlleitschuh.gradle.ktlint"
|
|
32
35
|
apply plugin: "org.jetbrains.kotlin.plugin.serialization"
|
|
33
|
-
|
|
36
|
+
if (kotlinVersion?.startsWith("2")) {
|
|
37
|
+
apply plugin: "org.jetbrains.kotlin.plugin.compose"
|
|
38
|
+
}
|
|
34
39
|
|
|
35
40
|
def getExtOrDefault(name) {
|
|
36
41
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["SmileId_" + name]
|
|
@@ -71,6 +76,7 @@ android {
|
|
|
71
76
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
72
77
|
|
|
73
78
|
}
|
|
79
|
+
|
|
74
80
|
buildTypes {
|
|
75
81
|
release {
|
|
76
82
|
minifyEnabled false
|
|
@@ -91,7 +97,7 @@ android {
|
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
composeOptions {
|
|
94
|
-
kotlinCompilerExtensionVersion rootProject.ext.has("kotlinCompilerExtensionVersion") ? rootProject.ext.get("kotlinCompilerExtensionVersion") :
|
|
100
|
+
kotlinCompilerExtensionVersion rootProject.ext.has("kotlinCompilerExtensionVersion") ? rootProject.ext.get("kotlinCompilerExtensionVersion") : project.properties["SmileId_kotlinCompilerExtensionVersion"]
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
compileOptions {
|
|
@@ -112,8 +118,8 @@ repositories {
|
|
|
112
118
|
gradlePluginPortal()
|
|
113
119
|
}
|
|
114
120
|
|
|
115
|
-
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") :
|
|
116
|
-
def smile_id_sdk_version =
|
|
121
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["SmileId_kotlinVersion"]
|
|
122
|
+
def smile_id_sdk_version = project.properties["SmileId_androidVersion"]
|
|
117
123
|
|
|
118
124
|
dependencies {
|
|
119
125
|
implementation "com.facebook.react:react-native:0.72"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
SmileId_kotlinVersion=2.0.0
|
|
2
2
|
SmileId_minSdkVersion=21
|
|
3
|
-
SmileId_targetSdkVersion=
|
|
4
|
-
SmileId_compileSdkVersion=
|
|
3
|
+
SmileId_targetSdkVersion=35
|
|
4
|
+
SmileId_compileSdkVersion=35
|
|
5
5
|
SmileId_ndkversion=21.4.7075529
|
|
6
|
-
SmileId_androidVersion=10.
|
|
6
|
+
SmileId_androidVersion=10.4.2
|
|
7
|
+
SmileId_kotlinCompilerExtensionVersion=1.5.11
|
|
@@ -3,7 +3,6 @@ package com.smileidentity.react
|
|
|
3
3
|
import com.facebook.react.bridge.ReadableMap
|
|
4
4
|
import com.smileidentity.models.AuthenticationRequest
|
|
5
5
|
import com.smileidentity.models.Config
|
|
6
|
-
import com.smileidentity.models.ConsentInfo
|
|
7
6
|
import com.smileidentity.models.EnhancedKycRequest
|
|
8
7
|
import com.smileidentity.models.IdInfo
|
|
9
8
|
import com.smileidentity.models.ImageType
|
|
@@ -31,10 +30,10 @@ fun ReadableMap.toConfig(): Config {
|
|
|
31
30
|
authToken = getStringOrDefault("authToken") ?: run {
|
|
32
31
|
throw IllegalArgumentException("authToken is required")
|
|
33
32
|
},
|
|
34
|
-
|
|
33
|
+
prodLambdaUrl = getStringOrDefault("prodLambdaUrl") ?: run {
|
|
35
34
|
throw IllegalArgumentException("prodBaseUrl is required")
|
|
36
35
|
},
|
|
37
|
-
|
|
36
|
+
testLambdaUrl = getStringOrDefault("testLambdaUrl") ?: run {
|
|
38
37
|
throw IllegalArgumentException("sandboxBaseUrl is required")
|
|
39
38
|
},
|
|
40
39
|
)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package com.smileidentity.react
|
|
2
2
|
|
|
3
|
-
import android.util.Log
|
|
4
3
|
import com.facebook.react.bridge.Arguments
|
|
5
4
|
import com.facebook.react.bridge.Promise
|
|
6
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
@@ -15,7 +14,6 @@ import com.smileidentity.models.BiometricKycJobStatusResponse
|
|
|
15
14
|
import com.smileidentity.models.DocumentVerificationJobStatusResponse
|
|
16
15
|
import com.smileidentity.models.EnhancedDocumentVerificationJobStatusResponse
|
|
17
16
|
import com.smileidentity.models.EnhancedKycAsyncResponse
|
|
18
|
-
import com.smileidentity.models.EnhancedKycRequest
|
|
19
17
|
import com.smileidentity.models.EnhancedKycResponse
|
|
20
18
|
import com.smileidentity.models.PrepUploadResponse
|
|
21
19
|
import com.smileidentity.models.ProductsConfigResponse
|
|
@@ -27,18 +25,15 @@ import com.smileidentity.networking.pollDocumentVerificationJobStatus
|
|
|
27
25
|
import com.smileidentity.networking.pollEnhancedDocumentVerificationJobStatus
|
|
28
26
|
import com.smileidentity.networking.pollSmartSelfieJobStatus
|
|
29
27
|
import com.smileidentity.react.utils.getIntOrDefault
|
|
30
|
-
import com.smileidentity.react.utils.getStringOrDefault
|
|
31
|
-
import com.smileidentity.results.SmartSelfieResult
|
|
32
|
-
import java.net.URL
|
|
33
28
|
import kotlinx.coroutines.CoroutineExceptionHandler
|
|
34
29
|
import kotlinx.coroutines.CoroutineScope
|
|
35
30
|
import kotlinx.coroutines.Dispatchers
|
|
36
31
|
import kotlinx.coroutines.flow.Flow
|
|
37
32
|
import kotlinx.coroutines.flow.last
|
|
38
33
|
import kotlinx.coroutines.flow.map
|
|
39
|
-
import kotlinx.coroutines.flow.single
|
|
40
34
|
import kotlinx.coroutines.launch
|
|
41
35
|
import kotlinx.coroutines.withContext
|
|
36
|
+
import java.net.URL
|
|
42
37
|
import kotlin.time.Duration
|
|
43
38
|
import kotlin.time.Duration.Companion.milliseconds
|
|
44
39
|
|
|
@@ -49,45 +44,48 @@ class SmileIdModule internal constructor(
|
|
|
49
44
|
override fun getName(): String = NAME
|
|
50
45
|
|
|
51
46
|
@ReactMethod
|
|
52
|
-
override fun
|
|
53
|
-
apiKey: String,
|
|
54
|
-
config: ReadableMap,
|
|
55
|
-
useSandBox: Boolean,
|
|
56
|
-
enableCrashReporting: Boolean,
|
|
57
|
-
promise: Promise
|
|
58
|
-
) {
|
|
59
|
-
SmileID.initialize(
|
|
60
|
-
context = reactApplicationContext,
|
|
61
|
-
apiKey = apiKey,
|
|
62
|
-
config = config.toConfig(),
|
|
63
|
-
useSandbox = useSandBox,
|
|
64
|
-
enableCrashReporting = enableCrashReporting
|
|
65
|
-
)
|
|
66
|
-
promise.resolve(null)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
@ReactMethod
|
|
70
|
-
override fun initializeWithConfig(
|
|
71
|
-
config: ReadableMap,
|
|
47
|
+
override fun initialize(
|
|
72
48
|
useSandBox: Boolean,
|
|
73
49
|
enableCrashReporting: Boolean,
|
|
50
|
+
config: ReadableMap?,
|
|
51
|
+
apiKey: String?,
|
|
74
52
|
promise: Promise
|
|
75
53
|
) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
54
|
+
try {
|
|
55
|
+
when {
|
|
56
|
+
// Case 1: Initialize with API key and config
|
|
57
|
+
apiKey != null && config != null -> {
|
|
58
|
+
SmileID.initialize(
|
|
59
|
+
context = reactApplicationContext,
|
|
60
|
+
apiKey = apiKey,
|
|
61
|
+
config = config.toConfig(),
|
|
62
|
+
useSandbox = useSandBox,
|
|
63
|
+
enableCrashReporting = enableCrashReporting
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
// Case 2: Initialize with just config
|
|
67
|
+
config != null -> {
|
|
68
|
+
SmileID.initialize(
|
|
69
|
+
context = reactApplicationContext,
|
|
70
|
+
config = config.toConfig(),
|
|
71
|
+
useSandbox = useSandBox,
|
|
72
|
+
enableCrashReporting = enableCrashReporting
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
// Case 3: Basic initialization
|
|
76
|
+
else -> {
|
|
77
|
+
SmileID.initialize(
|
|
78
|
+
context = reactApplicationContext,
|
|
79
|
+
useSandbox = useSandBox
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
promise.resolve(null)
|
|
84
|
+
} catch (e: Exception) {
|
|
85
|
+
promise.reject("INITIALIZE_ERROR", e.message, e)
|
|
86
|
+
}
|
|
83
87
|
}
|
|
84
88
|
|
|
85
|
-
@ReactMethod
|
|
86
|
-
override fun initialize(useSandBox: Boolean, promise: Promise) {
|
|
87
|
-
SmileID.initialize(context = reactApplicationContext, useSandbox = useSandBox)
|
|
88
|
-
promise.resolve(null)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
89
|
@ReactMethod
|
|
92
90
|
override fun setCallbackUrl(callbackUrl: String, promise: Promise) {
|
|
93
91
|
SmileID.setCallbackUrl(callbackUrl = URL(callbackUrl))
|
|
@@ -12,8 +12,10 @@ import com.smileidentity.react.viewmanagers.SmileIDDocumentCaptureViewManager
|
|
|
12
12
|
import com.smileidentity.react.viewmanagers.SmileIDDocumentVerificationViewManager
|
|
13
13
|
import com.smileidentity.react.viewmanagers.SmileIDEnhancedDocumentVerificationViewManager
|
|
14
14
|
import com.smileidentity.react.viewmanagers.SmileIDSmartSelfieAuthenticationViewManager
|
|
15
|
+
import com.smileidentity.react.viewmanagers.SmileIDSmartSelfieAuthenticationEnhancedViewManager
|
|
15
16
|
import com.smileidentity.react.viewmanagers.SmileIDSmartSelfieCaptureViewManager
|
|
16
17
|
import com.smileidentity.react.viewmanagers.SmileIDSmartSelfieEnrollmentViewManager
|
|
18
|
+
import com.smileidentity.react.viewmanagers.SmileIDSmartSelfieEnrollmentEnhancedViewManager
|
|
17
19
|
import com.smileidentity.react.views.SmileIDDocumentCaptureView
|
|
18
20
|
|
|
19
21
|
class SmileIdPackage : TurboReactPackage() {
|
|
@@ -24,6 +26,8 @@ class SmileIdPackage : TurboReactPackage() {
|
|
|
24
26
|
SmileIDDocumentCaptureViewManager(reactContext),
|
|
25
27
|
SmileIDSmartSelfieEnrollmentViewManager(reactContext),
|
|
26
28
|
SmileIDSmartSelfieAuthenticationViewManager(reactContext),
|
|
29
|
+
SmileIDSmartSelfieEnrollmentEnhancedViewManager(reactContext),
|
|
30
|
+
SmileIDSmartSelfieAuthenticationEnhancedViewManager(reactContext),
|
|
27
31
|
SmileIDDocumentVerificationViewManager(reactContext),
|
|
28
32
|
SmileIDEnhancedDocumentVerificationViewManager(reactContext),
|
|
29
33
|
SmileIDConsentViewManager(reactContext),
|
|
@@ -2,10 +2,11 @@ package com.smileidentity.react.results
|
|
|
2
2
|
|
|
3
3
|
import com.smileidentity.models.v2.SmartSelfieResponse
|
|
4
4
|
import java.io.File
|
|
5
|
+
import com.squareup.moshi.JsonClass
|
|
5
6
|
|
|
7
|
+
@JsonClass(generateAdapter = true)
|
|
6
8
|
data class SmartSelfieCaptureResult(
|
|
7
9
|
val selfieFile: File? = null,
|
|
8
10
|
val livenessFiles: List<File>? = null,
|
|
9
|
-
val apiResponse: SmartSelfieResponse? = null
|
|
10
|
-
val didSubmitBiometricKycJob: Boolean? = null
|
|
11
|
+
val apiResponse: SmartSelfieResponse? = null
|
|
11
12
|
)
|
package/android/src/main/java/com/smileidentity/react/utils/BiometricKycCaptureResultAdapter.kt
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
package com.smileidentity.react.utils
|
|
2
|
+
|
|
3
|
+
import com.smileidentity.SmileID
|
|
4
|
+
import com.smileidentity.react.results.BiometricKycCaptureResult
|
|
5
|
+
import com.squareup.moshi.FromJson
|
|
6
|
+
import com.squareup.moshi.JsonAdapter
|
|
7
|
+
import com.squareup.moshi.JsonAdapter.Factory
|
|
8
|
+
import com.squareup.moshi.JsonReader
|
|
9
|
+
import com.squareup.moshi.JsonWriter
|
|
10
|
+
import com.squareup.moshi.ToJson
|
|
11
|
+
import java.io.File
|
|
12
|
+
|
|
13
|
+
class BiometricKycCaptureResultAdapter : JsonAdapter<BiometricKycCaptureResult>() {
|
|
14
|
+
|
|
15
|
+
@FromJson
|
|
16
|
+
override fun fromJson(reader: JsonReader): BiometricKycCaptureResult {
|
|
17
|
+
reader.beginObject()
|
|
18
|
+
var selfieFile: File? = null
|
|
19
|
+
var livenessFiles: List<File>? = null
|
|
20
|
+
var didSubmitBiometricKycJob: Boolean? = null
|
|
21
|
+
|
|
22
|
+
while (reader.hasNext()) {
|
|
23
|
+
when (reader.nextName()) {
|
|
24
|
+
"selfieFile" -> selfieFile = reader.nextString()?.let { File(it) }
|
|
25
|
+
"livenessFiles" -> {
|
|
26
|
+
// Assuming livenessFiles is an array of file paths in the JSON
|
|
27
|
+
val files = mutableListOf<File>()
|
|
28
|
+
reader.beginArray()
|
|
29
|
+
while (reader.hasNext()) {
|
|
30
|
+
reader.nextString()?.let { files.add(File(it)) }
|
|
31
|
+
}
|
|
32
|
+
reader.endArray()
|
|
33
|
+
livenessFiles = files
|
|
34
|
+
}
|
|
35
|
+
"didSubmitBiometricKycJob" -> didSubmitBiometricKycJob = reader.nextBoolean()
|
|
36
|
+
else -> reader.skipValue()
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
reader.endObject()
|
|
41
|
+
return BiometricKycCaptureResult(
|
|
42
|
+
selfieFile = selfieFile,
|
|
43
|
+
livenessFiles = livenessFiles,
|
|
44
|
+
didSubmitBiometricKycJob = didSubmitBiometricKycJob
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@ToJson
|
|
49
|
+
override fun toJson(writer: JsonWriter, value: BiometricKycCaptureResult?) {
|
|
50
|
+
if (value == null) {
|
|
51
|
+
writer.nullValue()
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
writer.beginObject()
|
|
55
|
+
writer.name("selfieFile").value(value.selfieFile?.absolutePath)
|
|
56
|
+
|
|
57
|
+
writer.name("livenessFiles")
|
|
58
|
+
writer.beginArray()
|
|
59
|
+
value.livenessFiles?.forEach { writer.value(it.absolutePath) }
|
|
60
|
+
writer.endArray()
|
|
61
|
+
|
|
62
|
+
writer.name("didSubmitBiometricKycJob").value(value.didSubmitBiometricKycJob)
|
|
63
|
+
writer.endObject()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
companion object {
|
|
67
|
+
val FACTORY = Factory { type, annotations, moshi -> if (type == BiometricKycCaptureResult::class.java) BiometricKycCaptureResultAdapter() else null }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -33,10 +33,8 @@ class SelfieCaptureResultAdapter : JsonAdapter<SmartSelfieCaptureResult>() {
|
|
|
33
33
|
reader.endArray()
|
|
34
34
|
livenessFiles = files
|
|
35
35
|
}
|
|
36
|
-
|
|
37
36
|
"apiResponse" -> apiResponse =
|
|
38
37
|
SmileID.moshi.adapter(SmartSelfieResponse::class.java).fromJson(reader)
|
|
39
|
-
|
|
40
38
|
else -> reader.skipValue()
|
|
41
39
|
}
|
|
42
40
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
package com.smileidentity.react.viewmanagers
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.bridge.ReadableArray
|
|
5
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
6
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
7
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
8
|
+
import com.smileidentity.react.utils.getBoolOrDefault
|
|
9
|
+
import com.smileidentity.react.utils.getImmutableMapOrDefault
|
|
10
|
+
import com.smileidentity.react.utils.getStringOrDefault
|
|
11
|
+
import com.smileidentity.react.views.SmileIDSmartSelfieAuthenticationEnhancedView
|
|
12
|
+
|
|
13
|
+
@ReactModule(name = SmileIDSmartSelfieAuthenticationEnhancedViewManager.NAME)
|
|
14
|
+
class SmileIDSmartSelfieAuthenticationEnhancedViewManager(
|
|
15
|
+
private val reactApplicationContext: ReactApplicationContext
|
|
16
|
+
) : SimpleViewManager<SmileIDSmartSelfieAuthenticationEnhancedView>() {
|
|
17
|
+
|
|
18
|
+
override fun getName(): String = NAME
|
|
19
|
+
|
|
20
|
+
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
|
|
21
|
+
return mapOf(
|
|
22
|
+
"onSmileResult" to mapOf(
|
|
23
|
+
"phasedRegistrationNames" to mapOf(
|
|
24
|
+
"bubbled" to "onResult"
|
|
25
|
+
)
|
|
26
|
+
)
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun getCommandsMap(): Map<String, Int> {
|
|
31
|
+
return mapOf("setParams" to COMMAND_SET_PARAMS)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun receiveCommand(
|
|
35
|
+
view: SmileIDSmartSelfieAuthenticationEnhancedView,
|
|
36
|
+
commandId: String?,
|
|
37
|
+
args: ReadableArray?
|
|
38
|
+
) {
|
|
39
|
+
super.receiveCommand(view, commandId, args)
|
|
40
|
+
when (commandId?.toInt()) {
|
|
41
|
+
COMMAND_SET_PARAMS -> {
|
|
42
|
+
// Extract params from args and apply to view
|
|
43
|
+
val params = args?.getMap(0)
|
|
44
|
+
params?.let {
|
|
45
|
+
view.extraPartnerParams = params.getImmutableMapOrDefault("extraPartnerParams")
|
|
46
|
+
view.userId = params.getStringOrDefault("userId")
|
|
47
|
+
view.showAttribution = params.getBoolOrDefault("showAttribution", true)
|
|
48
|
+
view.showInstructions = params.getBoolOrDefault("showInstructions", true)
|
|
49
|
+
view.allowNewEnroll = params.getBoolOrDefault("allowNewEnroll", false)
|
|
50
|
+
view.renderContent()
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
override fun createViewInstance(p0: ThemedReactContext): SmileIDSmartSelfieAuthenticationEnhancedView {
|
|
57
|
+
return SmileIDSmartSelfieAuthenticationEnhancedView(reactApplicationContext)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
companion object {
|
|
61
|
+
const val NAME = "SmileIDSmartSelfieAuthenticationEnhancedView"
|
|
62
|
+
const val COMMAND_SET_PARAMS = 2
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
package com.smileidentity.react.viewmanagers
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.bridge.ReadableArray
|
|
5
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
6
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
7
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
8
|
+
import com.smileidentity.react.utils.getBoolOrDefault
|
|
9
|
+
import com.smileidentity.react.utils.getImmutableMapOrDefault
|
|
10
|
+
import com.smileidentity.react.utils.getStringOrDefault
|
|
11
|
+
import com.smileidentity.react.views.SmileIDSmartSelfieEnrollmentEnhancedView
|
|
12
|
+
|
|
13
|
+
@ReactModule(name = SmileIDSmartSelfieEnrollmentEnhancedViewManager.NAME)
|
|
14
|
+
class SmileIDSmartSelfieEnrollmentEnhancedViewManager(
|
|
15
|
+
private val reactApplicationContext: ReactApplicationContext
|
|
16
|
+
) : SimpleViewManager<SmileIDSmartSelfieEnrollmentEnhancedView>() {
|
|
17
|
+
|
|
18
|
+
override fun getName(): String = NAME
|
|
19
|
+
|
|
20
|
+
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
|
|
21
|
+
return mapOf(
|
|
22
|
+
"onSmileResult" to mapOf(
|
|
23
|
+
"phasedRegistrationNames" to mapOf(
|
|
24
|
+
"bubbled" to "onResult"
|
|
25
|
+
)
|
|
26
|
+
)
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun getCommandsMap(): Map<String, Int> {
|
|
31
|
+
return mapOf("setParams" to COMMAND_SET_PARAMS)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun receiveCommand(
|
|
35
|
+
view: SmileIDSmartSelfieEnrollmentEnhancedView,
|
|
36
|
+
commandId: String?,
|
|
37
|
+
args: ReadableArray?
|
|
38
|
+
) {
|
|
39
|
+
super.receiveCommand(view, commandId, args)
|
|
40
|
+
when (commandId?.toInt()) {
|
|
41
|
+
COMMAND_SET_PARAMS -> {
|
|
42
|
+
// Extract params from args and apply to view
|
|
43
|
+
val params = args?.getMap(0)
|
|
44
|
+
params?.let {
|
|
45
|
+
view.extraPartnerParams = params.getImmutableMapOrDefault("extraPartnerParams")
|
|
46
|
+
view.userId = params.getStringOrDefault("userId")
|
|
47
|
+
view.showAttribution = params.getBoolOrDefault("showAttribution", true)
|
|
48
|
+
view.showInstructions = params.getBoolOrDefault("showInstructions", true)
|
|
49
|
+
view.allowNewEnroll = params.getBoolOrDefault("allowNewEnroll", false)
|
|
50
|
+
view.renderContent()
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
override fun createViewInstance(p0: ThemedReactContext): SmileIDSmartSelfieEnrollmentEnhancedView {
|
|
57
|
+
return SmileIDSmartSelfieEnrollmentEnhancedView(reactApplicationContext)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
companion object {
|
|
61
|
+
const val NAME = "SmileIDSmartSelfieEnrollmentEnhancedView"
|
|
62
|
+
const val COMMAND_SET_PARAMS = 1
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -7,8 +7,8 @@ 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.react.results.
|
|
11
|
-
import com.smileidentity.react.utils.
|
|
10
|
+
import com.smileidentity.react.results.BiometricKycCaptureResult
|
|
11
|
+
import com.smileidentity.react.utils.BiometricKycCaptureResultAdapter
|
|
12
12
|
import com.smileidentity.results.SmileIDResult
|
|
13
13
|
import com.smileidentity.util.randomJobId
|
|
14
14
|
import com.smileidentity.util.randomUserId
|
|
@@ -31,14 +31,14 @@ class SmileIDBiometricKYCView(context: ReactApplicationContext) : SmileIDView(co
|
|
|
31
31
|
jobId = jobId ?: rememberSaveable { randomJobId() },
|
|
32
32
|
allowAgentMode = allowAgentMode ?: false,
|
|
33
33
|
allowNewEnroll = allowNewEnroll ?: false,
|
|
34
|
-
showAttribution = showAttribution
|
|
35
|
-
showInstructions = showInstructions
|
|
34
|
+
showAttribution = showAttribution,
|
|
35
|
+
showInstructions = showInstructions,
|
|
36
36
|
extraPartnerParams = extraPartnerParams,
|
|
37
37
|
) { res ->
|
|
38
38
|
when (res) {
|
|
39
39
|
is SmileIDResult.Success -> {
|
|
40
40
|
val result =
|
|
41
|
-
|
|
41
|
+
BiometricKycCaptureResult(
|
|
42
42
|
selfieFile = res.data.selfieFile,
|
|
43
43
|
livenessFiles = res.data.livenessFiles,
|
|
44
44
|
didSubmitBiometricKycJob = res.data.didSubmitBiometricKycJob,
|
|
@@ -46,12 +46,12 @@ class SmileIDBiometricKYCView(context: ReactApplicationContext) : SmileIDView(co
|
|
|
46
46
|
val newMoshi =
|
|
47
47
|
SmileID.moshi
|
|
48
48
|
.newBuilder()
|
|
49
|
-
.add(
|
|
49
|
+
.add(BiometricKycCaptureResultAdapter.FACTORY)
|
|
50
50
|
.build()
|
|
51
51
|
val json =
|
|
52
52
|
try {
|
|
53
53
|
newMoshi
|
|
54
|
-
.adapter(
|
|
54
|
+
.adapter(BiometricKycCaptureResult::class.java)
|
|
55
55
|
.toJson(result)
|
|
56
56
|
} catch (e: Exception) {
|
|
57
57
|
emitFailure(e)
|
|
@@ -65,10 +65,19 @@ class SmileIDDocumentCaptureView(context: ReactApplicationContext) : SmileIDView
|
|
|
65
65
|
DocumentCaptureScreen(
|
|
66
66
|
jobId = jobId,
|
|
67
67
|
side = if (front) DocumentCaptureSide.Front else DocumentCaptureSide.Back,
|
|
68
|
+
showInstructions = showInstructions,
|
|
69
|
+
showAttribution = showAttribution,
|
|
70
|
+
allowGallerySelection = allowGalleryUpload,
|
|
71
|
+
showConfirmation = showConfirmation,
|
|
72
|
+
showSkipButton = false,
|
|
73
|
+
instructionsHeroImage = hero,
|
|
74
|
+
instructionsTitleText = stringResource(instructionTitle),
|
|
75
|
+
instructionsSubtitleText = stringResource(instructionSubTitle),
|
|
68
76
|
captureTitleText = stringResource(captureTitleText),
|
|
69
77
|
knownIdAspectRatio = idAspectRatio,
|
|
70
78
|
onConfirm = { file -> handleConfirmation(file) },
|
|
71
79
|
onError = { throwable -> emitFailure(throwable) },
|
|
80
|
+
onSkip = { }
|
|
72
81
|
)
|
|
73
82
|
}
|
|
74
83
|
|
package/android/src/main/java/com/smileidentity/react/views/SmileIDDocumentVerificationView.kt
CHANGED
|
@@ -11,7 +11,6 @@ import com.smileidentity.react.utils.DocumentCaptureResultAdapter
|
|
|
11
11
|
import com.smileidentity.results.SmileIDResult
|
|
12
12
|
import com.smileidentity.util.randomJobId
|
|
13
13
|
import com.smileidentity.util.randomUserId
|
|
14
|
-
import kotlinx.collections.immutable.toImmutableMap
|
|
15
14
|
import java.io.File
|
|
16
15
|
|
|
17
16
|
class SmileIDDocumentVerificationView(context: ReactApplicationContext) : SmileIDView(context) {
|
|
@@ -41,13 +40,12 @@ class SmileIDDocumentVerificationView(context: ReactApplicationContext) : SmileI
|
|
|
41
40
|
countryCode = countryCode!!,
|
|
42
41
|
documentType = documentType,
|
|
43
42
|
idAspectRatio = idAspectRatio,
|
|
44
|
-
showAttribution = showAttribution
|
|
43
|
+
showAttribution = showAttribution,
|
|
45
44
|
allowAgentMode = allowAgentMode ?: false,
|
|
46
|
-
showInstructions = showInstructions
|
|
45
|
+
showInstructions = showInstructions,
|
|
47
46
|
allowGalleryUpload = allowGalleryUpload,
|
|
48
47
|
captureBothSides = captureBothSides,
|
|
49
48
|
allowNewEnroll = allowNewEnroll ?: false,
|
|
50
|
-
skipApiSubmission = skipApiSubmission,
|
|
51
49
|
bypassSelfieCaptureWithFile = bypassSelfieCaptureWithFile,
|
|
52
50
|
extraPartnerParams = extraPartnerParams,
|
|
53
51
|
) { res ->
|
|
@@ -11,7 +11,6 @@ import com.smileidentity.react.utils.DocumentCaptureResultAdapter
|
|
|
11
11
|
import com.smileidentity.results.SmileIDResult
|
|
12
12
|
import com.smileidentity.util.randomJobId
|
|
13
13
|
import com.smileidentity.util.randomUserId
|
|
14
|
-
import kotlinx.collections.immutable.toImmutableMap
|
|
15
14
|
|
|
16
15
|
class SmileIDEnhancedDocumentVerificationView(context: ReactApplicationContext) :
|
|
17
16
|
SmileIDView(context) {
|
|
@@ -24,7 +23,7 @@ class SmileIDEnhancedDocumentVerificationView(context: ReactApplicationContext)
|
|
|
24
23
|
override fun renderContent() {
|
|
25
24
|
countryCode ?: run {
|
|
26
25
|
emitFailure(IllegalArgumentException("countryCode is required for DocumentVerification"))
|
|
27
|
-
return
|
|
26
|
+
return
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
composeView.apply {
|
|
@@ -37,13 +36,12 @@ class SmileIDEnhancedDocumentVerificationView(context: ReactApplicationContext)
|
|
|
37
36
|
countryCode = countryCode!!,
|
|
38
37
|
documentType = documentType,
|
|
39
38
|
idAspectRatio = idAspectRatio,
|
|
40
|
-
showAttribution = showAttribution
|
|
39
|
+
showAttribution = showAttribution,
|
|
41
40
|
allowAgentMode = allowAgentMode ?: false,
|
|
42
|
-
showInstructions = showInstructions
|
|
41
|
+
showInstructions = showInstructions,
|
|
43
42
|
allowNewEnroll = allowNewEnroll ?: false,
|
|
44
43
|
allowGalleryUpload = allowGalleryUpload,
|
|
45
44
|
captureBothSides = captureBothSides,
|
|
46
|
-
skipApiSubmission = skipApiSubmission,
|
|
47
45
|
extraPartnerParams = extraPartnerParams,
|
|
48
46
|
) { res ->
|
|
49
47
|
when (res) {
|