@idnow/react-idcheckio 7.2.0 → 8.0.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/.editorconfig +15 -0
- package/.gitattributes +2 -0
- package/README.md +236 -193
- package/android/build.gradle +95 -37
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +5 -4
- package/android/src/main/AndroidManifestNew.xml +9 -0
- package/android/src/main/java/com/idnowreactidcheckio/IdnowReactIdcheckioActivity.kt +67 -0
- package/android/src/main/java/com/idnowreactidcheckio/IdnowReactIdcheckioModule.kt +115 -0
- package/android/src/main/java/com/idnowreactidcheckio/IdnowReactIdcheckioPackage.kt +17 -0
- package/android/src/main/java/com/idnowreactidcheckio/bean/ExtractionEnum.kt +6 -0
- package/android/src/main/java/com/idnowreactidcheckio/bean/ExtractionReact.kt +20 -0
- package/android/src/main/java/com/idnowreactidcheckio/bean/IntegrityCheckEnum.kt +6 -0
- package/android/src/main/java/com/idnowreactidcheckio/bean/IntegrityCheckReact.kt +18 -0
- package/android/src/main/java/com/idnowreactidcheckio/bean/OnlineConfigEnum.kt +9 -0
- package/android/src/main/java/com/idnowreactidcheckio/bean/ParamsEnum.kt +19 -0
- package/android/src/main/java/com/idnowreactidcheckio/bean/Theme.kt +29 -0
- package/android/src/main/java/com/idnowreactidcheckio/bean/ThemeEnum.kt +13 -0
- package/android/src/main/java/com/idnowreactidcheckio/utils/Extension.kt +20 -0
- package/android/src/main/java/com/idnowreactidcheckio/utils/Mapper.kt +178 -0
- package/android/src/main/res/layout/activity_idnow_react_idcheckio.xml +9 -0
- package/idnow-react-idcheckio.podspec +43 -0
- package/ios/IdnowReactIdcheckio-Bridging-Header.h +2 -0
- package/ios/IdnowReactIdcheckio.mm +29 -0
- package/ios/IdnowReactIdcheckio.swift +131 -0
- package/ios/Models/ExtractionEnum.swift +13 -0
- package/ios/Models/ExtractionReact.swift +23 -0
- package/ios/Models/IntegrityCheckEnum.swift +13 -0
- package/ios/Models/IntegrityCheckReact.swift +24 -0
- package/ios/Models/OnlineConfigEnum.swift +16 -0
- package/ios/Models/ParamsEnum.swift +26 -0
- package/ios/Models/ThemeEnum.swift +20 -0
- package/ios/Models/ThemeReact.swift +32 -0
- package/ios/Utils/Mapper.swift +139 -0
- package/package.json +14 -11
- package/release-public.sh +4 -4
- package/src/index.d.ts +259 -0
- package/src/index.js +270 -0
- package/tsconfig.json +12 -0
- package/ReactIdcheckio.podspec +0 -15
- package/android/.project +0 -17
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
- package/android/src/main/java/com/ariadnext/idcheckio/IdcheckioActivity.java +0 -133
- package/android/src/main/java/com/ariadnext/idcheckio/IdcheckioConst.java +0 -39
- package/android/src/main/java/com/ariadnext/idcheckio/IdcheckioModule.java +0 -189
- package/android/src/main/java/com/ariadnext/idcheckio/IdcheckioPackage.java +0 -22
- package/android/src/main/java/com/ariadnext/idcheckio/ParameterUtils.java +0 -251
- package/idcheckio_params.js +0 -343
- package/index.js +0 -6
- package/ios/Idcheckio.h +0 -11
- package/ios/Idcheckio.m +0 -301
- package/ios/Idcheckio.xcodeproj/project.pbxproj +0 -340
- package/ios/Idcheckio.xcworkspace/contents.xcworkspacedata +0 -10
- package/ios/Idcheckio.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/IdcheckioKeys.h +0 -49
- package/ios/IdcheckioSdk+Utils.swift +0 -35
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
<?xml version=
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
2
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
-
|
|
3
|
+
package="com.idnowreactidcheckio">
|
|
4
4
|
<application>
|
|
5
|
-
<activity
|
|
5
|
+
<activity
|
|
6
|
+
android:name=".IdnowReactIdcheckioActivity"
|
|
6
7
|
android:screenOrientation="portrait"
|
|
7
|
-
android:configChanges="orientation|screenSize|uiMode"
|
|
8
|
+
android:configChanges="orientation|screenSize|uiMode"
|
|
8
9
|
android:exported="true"/>
|
|
9
10
|
</application>
|
|
10
11
|
</manifest>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
<application>
|
|
3
|
+
<activity
|
|
4
|
+
android:name=".IdnowReactIdcheckioActivity"
|
|
5
|
+
android:screenOrientation="portrait"
|
|
6
|
+
android:configChanges="orientation|screenSize|uiMode"
|
|
7
|
+
android:exported="true" />
|
|
8
|
+
</application>
|
|
9
|
+
</manifest>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
package com.idnowreactidcheckio
|
|
2
|
+
|
|
3
|
+
import android.R.attr
|
|
4
|
+
import android.annotation.SuppressLint
|
|
5
|
+
import android.content.Intent
|
|
6
|
+
import android.os.Bundle
|
|
7
|
+
import android.view.Window
|
|
8
|
+
import androidx.fragment.app.FragmentActivity
|
|
9
|
+
import com.ariadnext.idcheckio.sdk.bean.OnlineContext
|
|
10
|
+
import com.ariadnext.idcheckio.sdk.interfaces.ErrorMsg
|
|
11
|
+
import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioError
|
|
12
|
+
import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioInteraction
|
|
13
|
+
import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioInteractionInterface
|
|
14
|
+
import com.ariadnext.idcheckio.sdk.interfaces.result.IdcheckioResult
|
|
15
|
+
import com.ariadnext.idcheckio.sdk.interfaces.toErrorMsg
|
|
16
|
+
import com.ariadnext.idcheckio.sdk.utils.extension.toJson
|
|
17
|
+
import com.idnowreactidcheckio.utils.Extension.filterNotNullValues
|
|
18
|
+
import com.idnowreactidcheckio.utils.Mapper
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class IdnowReactIdcheckioActivity : FragmentActivity(), IdcheckioInteractionInterface {
|
|
22
|
+
|
|
23
|
+
@Suppress("UNCHECKED_CAST")
|
|
24
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
25
|
+
super.onCreate(savedInstanceState)
|
|
26
|
+
requestWindowFeature(Window.FEATURE_NO_TITLE)
|
|
27
|
+
setContentView(R.layout.activity_idnow_react_idcheckio)
|
|
28
|
+
val params = intent.extras?.getSerializable(Mapper.params) as? HashMap<String, Any?>
|
|
29
|
+
val onlineContext = intent.extras?.getString(Mapper.onlineContext)
|
|
30
|
+
val theme = intent.extras?.getSerializable(Mapper.theme) as? HashMap<String, Any?> ?: HashMap()
|
|
31
|
+
|
|
32
|
+
Mapper.getIdcheckioViewFromParams(params)
|
|
33
|
+
.dayNightTheme(Mapper.getDayNightThemeFromReadableMap(this, theme.filterNotNullValues { it?.toString() }))
|
|
34
|
+
.listener(this)
|
|
35
|
+
.build()
|
|
36
|
+
.also {
|
|
37
|
+
supportFragmentManager.beginTransaction().replace(R.id.idnow_react_idcheckio_container, it).commit()
|
|
38
|
+
it.startOnline(onlineContext?.let { json -> OnlineContext.Companion.createFrom(json) })
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@Deprecated("Still used in the sdk so we need to keep it that way.")
|
|
43
|
+
@SuppressLint("MissingSuperCall") // We don't need to call the super method as we will finish the activity.
|
|
44
|
+
override fun onBackPressed() {
|
|
45
|
+
onIdcheckioInteraction(IdcheckioInteraction.ERROR, IdcheckioError.CANCELLED_BY_USER.toErrorMsg(message = "Session cancelled by user."))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
override fun onIdcheckioInteraction(interaction: IdcheckioInteraction, data: Any?) {
|
|
49
|
+
when (interaction) {
|
|
50
|
+
IdcheckioInteraction.RESULT -> {
|
|
51
|
+
Intent().apply {
|
|
52
|
+
putExtra(Mapper.idcheckioResult, (data as IdcheckioResult).toJson())
|
|
53
|
+
setResult(RESULT_OK, this)
|
|
54
|
+
}
|
|
55
|
+
finish()
|
|
56
|
+
}
|
|
57
|
+
IdcheckioInteraction.ERROR -> {
|
|
58
|
+
Intent().apply {
|
|
59
|
+
putExtra(Mapper.errorMsg, (data as ErrorMsg).toJson())
|
|
60
|
+
setResult(RESULT_CANCELED, this)
|
|
61
|
+
}
|
|
62
|
+
finish()
|
|
63
|
+
}
|
|
64
|
+
else -> { /* Do nothing */ }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
package com.idnowreactidcheckio
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.content.Intent
|
|
5
|
+
import com.ariadnext.idcheckio.sdk.bean.OnboardingCustomization
|
|
6
|
+
import com.ariadnext.idcheckio.sdk.bean.OnlineContext
|
|
7
|
+
import com.ariadnext.idcheckio.sdk.component.Idcheckio
|
|
8
|
+
import com.ariadnext.idcheckio.sdk.interfaces.ErrorMsg
|
|
9
|
+
import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioCallback
|
|
10
|
+
import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioError
|
|
11
|
+
import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioErrorCause
|
|
12
|
+
import com.ariadnext.idcheckio.sdk.interfaces.result.IdcheckioResult
|
|
13
|
+
import com.ariadnext.idcheckio.sdk.interfaces.result.ips.OnboardingResultCallback
|
|
14
|
+
import com.ariadnext.idcheckio.sdk.interfaces.toErrorMsg
|
|
15
|
+
import com.ariadnext.idcheckio.sdk.utils.extension.getSerializable
|
|
16
|
+
import com.ariadnext.idcheckio.sdk.utils.extension.toJson
|
|
17
|
+
import com.facebook.react.bridge.BaseActivityEventListener
|
|
18
|
+
import com.facebook.react.bridge.Promise
|
|
19
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
20
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
21
|
+
import com.facebook.react.bridge.ReactMethod
|
|
22
|
+
import com.facebook.react.bridge.ReadableMap
|
|
23
|
+
import com.idnowreactidcheckio.utils.Extension.filterNotNullValues
|
|
24
|
+
import com.idnowreactidcheckio.utils.Mapper
|
|
25
|
+
|
|
26
|
+
class IdnowReactIdcheckioModule(private val reactContext: ReactApplicationContext) :
|
|
27
|
+
ReactContextBaseJavaModule(reactContext), IdcheckioCallback, OnboardingResultCallback {
|
|
28
|
+
/** Name of the module */
|
|
29
|
+
private val name = "IdnowReactIdcheckio"
|
|
30
|
+
/*** Flag to retrieve activity result*/
|
|
31
|
+
private val startRequest = 9537152
|
|
32
|
+
/*** Keep the promise as we will need to send a response after the async call are done.*/
|
|
33
|
+
private var promise: Promise? = null
|
|
34
|
+
|
|
35
|
+
init {
|
|
36
|
+
reactContext.addActivityEventListener(object : BaseActivityEventListener() {
|
|
37
|
+
override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?) {
|
|
38
|
+
if (requestCode != startRequest) return
|
|
39
|
+
if(resultCode == Activity.RESULT_OK) {
|
|
40
|
+
promise?.resolve(data?.extras?.getSerializable(Mapper.idcheckioResult) ?: IdcheckioResult())
|
|
41
|
+
} else if(resultCode == Activity.RESULT_CANCELED) {
|
|
42
|
+
promise?.reject(name, data?.extras?.getString(Mapper.errorMsg) ?: IdcheckioError.INTERNAL_ERROR.toErrorMsg().toJson())
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@ReactMethod
|
|
49
|
+
fun preload(extractData: Boolean) {
|
|
50
|
+
// No result expected, just launch the preload.
|
|
51
|
+
Idcheckio.preload(reactContext, extractData)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@ReactMethod
|
|
55
|
+
fun activate(token: String, extractData: Boolean, promise: Promise){
|
|
56
|
+
this.promise = promise
|
|
57
|
+
Idcheckio.activate(token, reactContext, this, extractData)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Activate callback.
|
|
62
|
+
*/
|
|
63
|
+
override fun onInitEnd(success: Boolean, error: ErrorMsg?) {
|
|
64
|
+
if (success) {
|
|
65
|
+
// Just send a success, no result needed.
|
|
66
|
+
promise?.resolve(null)
|
|
67
|
+
} else {
|
|
68
|
+
// On error send the ErrorMsg as Json.
|
|
69
|
+
promise?.reject(name, error?.toJson())
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@ReactMethod
|
|
74
|
+
fun startOnboarding(folderUid: String, theme: ReadableMap?, promise: Promise) {
|
|
75
|
+
this.promise = promise
|
|
76
|
+
val onboardingCustomization = theme?.let {
|
|
77
|
+
Mapper.getOnboardingCustomizationFromReadableMap(reactContext, theme.toHashMap().filterNotNullValues { it?.toString() })
|
|
78
|
+
} ?: OnboardingCustomization()
|
|
79
|
+
reactContext.currentActivity?.let { Idcheckio.startOnboarding(it, folderUid, this, onboardingCustomization) }
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Start onboarding callback.
|
|
84
|
+
*/
|
|
85
|
+
override fun onSessionFailure(errorMsg: ErrorMsg) {
|
|
86
|
+
promise?.reject(name, errorMsg.toJson())
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
override fun onSessionSuccess() {
|
|
90
|
+
promise?.resolve(null)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@ReactMethod
|
|
94
|
+
fun start(params: ReadableMap, onlineContext: ReadableMap?, theme: ReadableMap?, promise: Promise) {
|
|
95
|
+
val activity = currentActivity ?: run {
|
|
96
|
+
promise.reject(name, noContextError())
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
this.promise = promise
|
|
100
|
+
val intent = Intent(activity, IdnowReactIdcheckioActivity::class.java).apply {
|
|
101
|
+
putExtra(Mapper.params, params.toHashMap())
|
|
102
|
+
onlineContext?.let { putExtra(Mapper.onlineContext, it.toHashMap().toString()) }
|
|
103
|
+
theme?.let { putExtra(Mapper.theme, it.toHashMap()) }
|
|
104
|
+
}
|
|
105
|
+
activity.startActivityForResult(intent, startRequest)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Return a json ErrorMsg with the no context error. */
|
|
109
|
+
private fun noContextError() = ErrorMsg(cause = IdcheckioErrorCause.DEVICE_ERROR, details = IdcheckioError.CONTEXT_LOST.name,
|
|
110
|
+
message = "Fail to find a usable activity to start the sdk.").toJson()
|
|
111
|
+
|
|
112
|
+
override fun getName(): String {
|
|
113
|
+
return name
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.idnowreactidcheckio
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class IdnowReactIdcheckioPackage : ReactPackage {
|
|
10
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
+
return listOf(IdnowReactIdcheckioModule(reactContext))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
15
|
+
return emptyList()
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package com.idnowreactidcheckio.bean
|
|
2
|
+
|
|
3
|
+
import com.ariadnext.idcheckio.sdk.bean.DataRequirement
|
|
4
|
+
import com.ariadnext.idcheckio.sdk.bean.Extraction
|
|
5
|
+
import com.ariadnext.idcheckio.sdk.bean.FaceDetection
|
|
6
|
+
|
|
7
|
+
internal data class ExtractionReact(
|
|
8
|
+
var codeline: DataRequirement? = null,
|
|
9
|
+
var face: FaceDetection? = null
|
|
10
|
+
) {
|
|
11
|
+
/**
|
|
12
|
+
* Map to an [Extraction] used by the sdk.
|
|
13
|
+
*/
|
|
14
|
+
fun toExtraction(): Extraction {
|
|
15
|
+
return Extraction(
|
|
16
|
+
codeline = codeline ?: DataRequirement.DISABLED,
|
|
17
|
+
face = face ?: FaceDetection.DISABLED
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package com.idnowreactidcheckio.bean
|
|
2
|
+
|
|
3
|
+
import com.ariadnext.idcheckio.sdk.bean.IntegrityCheck
|
|
4
|
+
|
|
5
|
+
internal data class IntegrityCheckReact(
|
|
6
|
+
var readEmrtd: Boolean? = null,
|
|
7
|
+
var docLiveness: Boolean? = null
|
|
8
|
+
) {
|
|
9
|
+
/**
|
|
10
|
+
* Map to an [IntegrityCheck] used by the sdk.
|
|
11
|
+
*/
|
|
12
|
+
fun toIntegrityCheck(): IntegrityCheck {
|
|
13
|
+
return IntegrityCheck(
|
|
14
|
+
readEmrtd = readEmrtd ?: false,
|
|
15
|
+
docLiveness = docLiveness ?: false
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.idnowreactidcheckio.bean
|
|
2
|
+
|
|
3
|
+
enum class ParamsEnum {
|
|
4
|
+
docType,
|
|
5
|
+
confirmationType,
|
|
6
|
+
sideOneExtraction,
|
|
7
|
+
sideTwoExtraction,
|
|
8
|
+
useHd,
|
|
9
|
+
integrityCheck,
|
|
10
|
+
orientation,
|
|
11
|
+
onlineConfig,
|
|
12
|
+
language,
|
|
13
|
+
manualButtonTimer,
|
|
14
|
+
maxPictureFilesize,
|
|
15
|
+
adjustCrop,
|
|
16
|
+
confirmAbort,
|
|
17
|
+
captureMode,
|
|
18
|
+
overrideWordings
|
|
19
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.idnowreactidcheckio.bean
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.ColorRes
|
|
4
|
+
import com.ariadnext.idcheckio.sdk.bean.DayNightTheme
|
|
5
|
+
import com.ariadnext.idcheckio.sdk.R
|
|
6
|
+
|
|
7
|
+
internal data class Theme (
|
|
8
|
+
@ColorRes var foregroundColor: Int? = null,
|
|
9
|
+
@ColorRes var borderColor: Int? = null,
|
|
10
|
+
@ColorRes var backgroundColor: Int? = null,
|
|
11
|
+
@ColorRes var primaryColor: Int? = null,
|
|
12
|
+
@ColorRes var titleColor: Int? = null,
|
|
13
|
+
@ColorRes var textColor: Int? = null) {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Map a theme to a DayNightTheme
|
|
17
|
+
*/
|
|
18
|
+
fun toDayNightTheme(): DayNightTheme{
|
|
19
|
+
return DayNightTheme(
|
|
20
|
+
foregroundColor = foregroundColor ?: R.color.idcheckio_sdk_background_color,
|
|
21
|
+
borderColor = borderColor ?: R.color.idcheckio_sdk_border_color,
|
|
22
|
+
backgroundColor = backgroundColor ?: R.color.idcheckio_sdk_secondary_background_color,
|
|
23
|
+
primaryColor = primaryColor ?: R.color.idcheckio_sdk_primary_color,
|
|
24
|
+
textColor = textColor,
|
|
25
|
+
titleColor = titleColor
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package com.idnowreactidcheckio.bean
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Theme enum to simplify the mapping of a Theme Readable Map.
|
|
5
|
+
*/
|
|
6
|
+
internal enum class ThemeEnum(val jsonValue: String) {
|
|
7
|
+
PRIMARY_COLOR("primaryColor"),
|
|
8
|
+
BACKGROUND_COLOR("backgroundColor"),
|
|
9
|
+
FOREGROUND_COLOR("foregroundColor"),
|
|
10
|
+
BORDER_COLOR("borderColor"),
|
|
11
|
+
TEXT_COLOR("textColor"),
|
|
12
|
+
TITLE_COLOR("titleColor")
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
package com.idnowreactidcheckio.utils
|
|
2
|
+
|
|
3
|
+
internal object Extension {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Map all the value to a new type and remove all the nullable values from the map.
|
|
7
|
+
* [K] represents the type of the key.
|
|
8
|
+
* [V] represents the actual type of the value.
|
|
9
|
+
* [T] represents the new type of the value.
|
|
10
|
+
* @param lambda a lambda to transform a [V] object to a [T] object.
|
|
11
|
+
* @return a new map Map<K,T> without null values and with the new value type.
|
|
12
|
+
*/
|
|
13
|
+
fun <K,V,T> Map<K,V?>.filterNotNullValues(lambda: (V?) -> T?): Map<K, T> {
|
|
14
|
+
return LinkedHashMap<K, T>().apply {
|
|
15
|
+
for ((key, value) in this@filterNotNullValues) {
|
|
16
|
+
lambda(value)?.let { this[key] = it }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
package com.idnowreactidcheckio.utils
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.content.Context
|
|
5
|
+
import com.ariadnext.idcheckio.sdk.bean.CaptureMode
|
|
6
|
+
import com.ariadnext.idcheckio.sdk.bean.ConfirmationType
|
|
7
|
+
import com.ariadnext.idcheckio.sdk.bean.DataRequirement
|
|
8
|
+
import com.ariadnext.idcheckio.sdk.bean.DayNightTheme
|
|
9
|
+
import com.ariadnext.idcheckio.sdk.bean.DocumentType
|
|
10
|
+
import com.ariadnext.idcheckio.sdk.bean.Extraction
|
|
11
|
+
import com.ariadnext.idcheckio.sdk.bean.FaceDetection
|
|
12
|
+
import com.ariadnext.idcheckio.sdk.bean.FileSize
|
|
13
|
+
import com.ariadnext.idcheckio.sdk.bean.IntegrityCheck
|
|
14
|
+
import com.ariadnext.idcheckio.sdk.bean.Language
|
|
15
|
+
import com.ariadnext.idcheckio.sdk.bean.OnboardingCustomization
|
|
16
|
+
import com.ariadnext.idcheckio.sdk.bean.OnlineConfig
|
|
17
|
+
import com.ariadnext.idcheckio.sdk.bean.Orientation
|
|
18
|
+
import com.ariadnext.idcheckio.sdk.component.IdcheckioView
|
|
19
|
+
import com.ariadnext.idcheckio.sdk.interfaces.cis.CISType
|
|
20
|
+
import com.facebook.react.bridge.ReactContext
|
|
21
|
+
import com.idnowreactidcheckio.bean.ExtractionEnum
|
|
22
|
+
import com.idnowreactidcheckio.bean.ExtractionReact
|
|
23
|
+
import com.idnowreactidcheckio.bean.IntegrityCheckEnum
|
|
24
|
+
import com.idnowreactidcheckio.bean.IntegrityCheckReact
|
|
25
|
+
import com.idnowreactidcheckio.bean.OnlineConfigEnum
|
|
26
|
+
import com.idnowreactidcheckio.bean.ParamsEnum
|
|
27
|
+
import com.idnowreactidcheckio.bean.Theme
|
|
28
|
+
import com.idnowreactidcheckio.bean.ThemeEnum
|
|
29
|
+
import com.idnowreactidcheckio.utils.Extension.filterNotNullValues
|
|
30
|
+
|
|
31
|
+
internal object Mapper {
|
|
32
|
+
/** Key to send/retrieve params on a Bundle */
|
|
33
|
+
const val params = "params"
|
|
34
|
+
/** Key to send/retrieve theme on a Bundle */
|
|
35
|
+
const val theme = "theme"
|
|
36
|
+
/** Key to send/retrieve online context on a Bundle */
|
|
37
|
+
const val onlineContext = "onlineContext"
|
|
38
|
+
/** Key to send/retrieve result on a Bundle */
|
|
39
|
+
const val idcheckioResult = "idcheckioResult"
|
|
40
|
+
/** Key to send/retrieve error on a Bundle */
|
|
41
|
+
const val errorMsg = "errorMsg"
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Retrieve an [OnboardingCustomization] from a Map.
|
|
45
|
+
* @param cont the context to get the resources.
|
|
46
|
+
* @param map the map containing all the colors.
|
|
47
|
+
* @return the onboardingCustomization to apply.
|
|
48
|
+
*/
|
|
49
|
+
fun getOnboardingCustomizationFromReadableMap(cont: ReactContext, map: Map<String, String>): OnboardingCustomization {
|
|
50
|
+
return OnboardingCustomization(theme = getDayNightThemeFromReadableMap(cont.applicationContext, map))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Retrieve a [DayNightTheme] from a Map.
|
|
55
|
+
* @param cont the context to get the resources.
|
|
56
|
+
* @param map the map containing all the colors.
|
|
57
|
+
* @return the dayNightTheme to apply.
|
|
58
|
+
*/
|
|
59
|
+
fun getDayNightThemeFromReadableMap(cont: Context, map: Map<String, String>): DayNightTheme {
|
|
60
|
+
return Theme().apply {
|
|
61
|
+
map.entries.forEach {
|
|
62
|
+
when(it.key) {
|
|
63
|
+
ThemeEnum.PRIMARY_COLOR.jsonValue -> primaryColor = getResFromName(cont, it.value)
|
|
64
|
+
ThemeEnum.BACKGROUND_COLOR.jsonValue -> backgroundColor = getResFromName(cont, it.value)
|
|
65
|
+
ThemeEnum.FOREGROUND_COLOR.jsonValue -> foregroundColor = getResFromName(cont, it.value)
|
|
66
|
+
ThemeEnum.BORDER_COLOR.jsonValue -> borderColor = getResFromName(cont, it.value)
|
|
67
|
+
ThemeEnum.TEXT_COLOR.jsonValue -> textColor = getResFromName(cont, it.value)
|
|
68
|
+
ThemeEnum.TITLE_COLOR.jsonValue -> titleColor = getResFromName(cont, it.value)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}.toDayNightTheme()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@SuppressLint("DiscouragedApi") // Suppressed as it is the only way for us to do this.
|
|
75
|
+
/**
|
|
76
|
+
* Retrieve a resource for any package by it's identifier name.
|
|
77
|
+
* @param cont the context to get the resources.
|
|
78
|
+
* @param identifier name of a resources.
|
|
79
|
+
* @return the resources if found or null if not.
|
|
80
|
+
*/
|
|
81
|
+
private fun getResFromName(cont: Context, identifier: String): Int?{
|
|
82
|
+
return cont.resources.getIdentifier(identifier, "color", cont.packageName).takeIf { it != 0 }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Inline function that will help to extract data from a map when keys are values of a given enum.
|
|
87
|
+
* [E] is the enum of the keys (if a key is not part of the enum it is skipped).
|
|
88
|
+
* [R] is the object we want to create from this map. The lambda will be called on this object to simplify the completion of the fields.
|
|
89
|
+
* @param map the map containing all the value of our [R] objects.
|
|
90
|
+
* @param applyTo the resulting object to complete with all the values from the map.
|
|
91
|
+
* @param action the lambda that will be called on the [R] object to complete it.
|
|
92
|
+
* @return [R] completed with all the information from the map.
|
|
93
|
+
*/
|
|
94
|
+
private inline fun <reified E : Enum<E>, R> extractFromMap(map: Map<String, Any?>?, applyTo: R, action: R.(String, Any) -> Unit): R {
|
|
95
|
+
map?.filterNotNullValues { it }?.let { extract ->
|
|
96
|
+
extract.entries.forEach {
|
|
97
|
+
if (enumValues<E>().any { enumVal -> enumVal.name == it.key }) {
|
|
98
|
+
applyTo.action(it.key, it.value)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return applyTo
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Retrieve an [IdcheckioView.Builder] from a Map.
|
|
107
|
+
* @param map the map containing all the parameters.
|
|
108
|
+
* @return the builder completed.
|
|
109
|
+
*/
|
|
110
|
+
fun getIdcheckioViewFromParams(map: Map<String, Any?>?): IdcheckioView.Builder {
|
|
111
|
+
return extractFromMap<ParamsEnum, IdcheckioView.Builder>(map, IdcheckioView.Builder()) { key, value ->
|
|
112
|
+
// We need it as we are casting some Any to nullable Map.
|
|
113
|
+
@Suppress("UNCHECKED_CAST")
|
|
114
|
+
when (ParamsEnum.valueOf(key)) {
|
|
115
|
+
ParamsEnum.docType -> docType(DocumentType.valueOf(value.toString()))
|
|
116
|
+
ParamsEnum.confirmationType -> confirmType(ConfirmationType.valueOf(value.toString()))
|
|
117
|
+
ParamsEnum.sideOneExtraction -> sideOneExtraction(getExtraction(value as? Map<String, Any?>))
|
|
118
|
+
ParamsEnum.sideTwoExtraction -> sideTwoExtraction(getExtraction(value as? Map<String, Any?>))
|
|
119
|
+
ParamsEnum.useHd -> useHd(value.toString().toBoolean())
|
|
120
|
+
ParamsEnum.integrityCheck -> integrityCheck(getIntegrityCheck(value as? Map<String, Any?>))
|
|
121
|
+
ParamsEnum.orientation -> orientation(Orientation.valueOf(value.toString()))
|
|
122
|
+
ParamsEnum.onlineConfig -> onlineConfig(getOnlineConfig(value as? Map<String, Any?>))
|
|
123
|
+
ParamsEnum.language -> language(Language.valueOf(value.toString()))
|
|
124
|
+
ParamsEnum.manualButtonTimer -> manualButtonTimer(value.toString().toInt())
|
|
125
|
+
ParamsEnum.maxPictureFilesize -> maxPictureFilesize(FileSize.valueOf(value.toString()))
|
|
126
|
+
ParamsEnum.adjustCrop -> adjustCrop(value.toString().toBoolean())
|
|
127
|
+
ParamsEnum.confirmAbort -> confirmAbort(value.toString().toBoolean())
|
|
128
|
+
ParamsEnum.captureMode -> captureMode(CaptureMode.valueOf(value.toString()))
|
|
129
|
+
ParamsEnum.overrideWordings -> overrideWordings(value as Map<String, String>)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Retrieve an [Extraction] from a Map.
|
|
136
|
+
* @param map the map containing all the extraction values.
|
|
137
|
+
* @return the extraction completed.
|
|
138
|
+
*/
|
|
139
|
+
private fun getExtraction(map: Map<String, Any?>?): Extraction {
|
|
140
|
+
return extractFromMap<ExtractionEnum, ExtractionReact>(map, ExtractionReact()) { key, value ->
|
|
141
|
+
when (ExtractionEnum.valueOf(key)) {
|
|
142
|
+
ExtractionEnum.codeline -> codeline = DataRequirement.valueOf(value.toString())
|
|
143
|
+
ExtractionEnum.faceDetection -> face = FaceDetection.valueOf(value.toString())
|
|
144
|
+
}
|
|
145
|
+
}.toExtraction()
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Retrieve an [IntegrityCheck] from a Map.
|
|
150
|
+
* @param map the map containing all the integrity check values.
|
|
151
|
+
* @return the integrityCheck completed.
|
|
152
|
+
*/
|
|
153
|
+
private fun getIntegrityCheck(map: Map<String, Any?>?): IntegrityCheck {
|
|
154
|
+
return extractFromMap<IntegrityCheckEnum, IntegrityCheckReact>(map, IntegrityCheckReact()) { key, value ->
|
|
155
|
+
when (IntegrityCheckEnum.valueOf(key)) {
|
|
156
|
+
IntegrityCheckEnum.readEmrtd -> readEmrtd = value.toString().toBoolean()
|
|
157
|
+
IntegrityCheckEnum.docLiveness -> docLiveness = value.toString().toBoolean()
|
|
158
|
+
}
|
|
159
|
+
}.toIntegrityCheck()
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Retrieve an [OnlineConfig] from a Map.
|
|
164
|
+
* @param map the map containing all the online config values.
|
|
165
|
+
* @return the onlineConfig completed.
|
|
166
|
+
*/
|
|
167
|
+
private fun getOnlineConfig(map: Map<String, Any?>?): OnlineConfig {
|
|
168
|
+
return extractFromMap<OnlineConfigEnum, OnlineConfig>(map, OnlineConfig()) { key, value ->
|
|
169
|
+
when (OnlineConfigEnum.valueOf(key)) {
|
|
170
|
+
OnlineConfigEnum.isReferenceDocument -> isReferenceDocument = value.toString().toBoolean()
|
|
171
|
+
OnlineConfigEnum.cisType -> cisType = CISType.valueOf(value.toString())
|
|
172
|
+
OnlineConfigEnum.folderUid -> folderUid = value.toString()
|
|
173
|
+
OnlineConfigEnum.biometricConsent -> biometricConsent = value.toString().toBoolean()
|
|
174
|
+
OnlineConfigEnum.enableManualAnalysis -> enableManualAnalysis = value.toString().toBoolean()
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
3
|
+
xmlns:tools="http://schemas.android.com/tools"
|
|
4
|
+
android:id="@+id/idnow_react_idcheckio_container"
|
|
5
|
+
android:layout_width="match_parent"
|
|
6
|
+
android:layout_height="match_parent"
|
|
7
|
+
tools:context=".IdnowReactIdcheckioActivity">
|
|
8
|
+
|
|
9
|
+
</FrameLayout>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
folly_compiler_flags = "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32"
|
|
5
|
+
|
|
6
|
+
Pod::Spec.new do |s|
|
|
7
|
+
s.name = "idnow-react-idcheckio"
|
|
8
|
+
s.version = package["version"]
|
|
9
|
+
s.summary = package["description"]
|
|
10
|
+
s.homepage = package["homepage"]
|
|
11
|
+
s.license = package["license"]
|
|
12
|
+
s.authors = package["author"]
|
|
13
|
+
|
|
14
|
+
s.platform = :ios, "12.0"
|
|
15
|
+
s.source = { :path => "." }
|
|
16
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
17
|
+
s.swift_version = "5.7"
|
|
18
|
+
|
|
19
|
+
s.dependency "IDCheckIOSDK", "~> 8.0.0"
|
|
20
|
+
|
|
21
|
+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
22
|
+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
23
|
+
if respond_to?(:install_modules_dependencies, true)
|
|
24
|
+
install_modules_dependencies(s)
|
|
25
|
+
else
|
|
26
|
+
s.dependency "React-Core"
|
|
27
|
+
|
|
28
|
+
# Don't install the dependencies when we run `pod install` in the old architecture.
|
|
29
|
+
if ENV["RCT_NEW_ARCH_ENABLED"] == "1"
|
|
30
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
31
|
+
s.pod_target_xcconfig = {
|
|
32
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
33
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
34
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
|
|
35
|
+
}
|
|
36
|
+
s.dependency "React-Codegen"
|
|
37
|
+
s.dependency "RCT-Folly"
|
|
38
|
+
s.dependency "RCTRequired"
|
|
39
|
+
s.dependency "RCTTypeSafety"
|
|
40
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
|
|
3
|
+
@interface RCT_EXTERN_MODULE(IdnowReactIdcheckio, NSObject)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
RCT_EXTERN_METHOD(preload:(BOOL)extractData)
|
|
7
|
+
|
|
8
|
+
RCT_EXTERN_METHOD(activate:(NSString*)token
|
|
9
|
+
extractData:(BOOL)extractData
|
|
10
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
11
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
12
|
+
|
|
13
|
+
RCT_EXTERN_METHOD(start:(NSDictionary*)params
|
|
14
|
+
onlineContext:(NSDictionary*)onlineContext
|
|
15
|
+
theme:(NSDictionary*)theme
|
|
16
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
17
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
18
|
+
|
|
19
|
+
RCT_EXTERN_METHOD(startOnboarding:(NSString*)folderUid
|
|
20
|
+
theme:(NSDictionary*)theme
|
|
21
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
22
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
23
|
+
|
|
24
|
+
+ (BOOL)requiresMainQueueSetup
|
|
25
|
+
{
|
|
26
|
+
return NO;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@end
|