@idnow/react-idcheckio 8.1.8 → 9.0.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 +2 -2
- package/android/build.gradle +8 -2
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/android/gradle.properties +2 -2
- package/android/src/main/java/com/idnowreactidcheckio/{IdnowReactIdcheckioModule.kt → IDCheckIOBridgeModule.kt} +24 -28
- package/android/src/main/java/com/idnowreactidcheckio/IdnowReactIdcheckioActivity.kt +17 -15
- package/android/src/main/java/com/idnowreactidcheckio/IdnowReactIdcheckioPackage.kt +1 -1
- package/android/src/main/java/com/idnowreactidcheckio/bean/ExtractionReact.kt +4 -4
- package/android/src/main/java/com/idnowreactidcheckio/bean/IntegrityCheckReact.kt +2 -2
- package/android/src/main/java/com/idnowreactidcheckio/bean/OnlineContextEnum.kt +9 -0
- package/android/src/main/java/com/idnowreactidcheckio/utils/Mapper.kt +17 -52
- package/app.plugin.js +19 -0
- package/idnow-react-idcheckio.podspec +5 -24
- package/ios/IDCheckIOBridgeModule.m +29 -0
- package/ios/IDCheckIOBridgeModule.swift +106 -0
- package/ios/Utils/Mapper.swift +18 -38
- package/package.json +8 -4
- package/plugins/addSPMDependency.js +119 -0
- package/plugins/copyNativeFiles.js +135 -0
- package/release-public.sh +2 -2
- package/src/index.d.ts +6 -30
- package/src/index.js +50 -48
- package/android/src/main/java/com/idnowreactidcheckio/bean/Theme.kt +0 -29
- package/android/src/main/java/com/idnowreactidcheckio/bean/ThemeEnum.kt +0 -13
- package/ios/IdnowReactIdcheckio-Bridging-Header.h +0 -2
- package/ios/IdnowReactIdcheckio.mm +0 -29
- package/ios/IdnowReactIdcheckio.swift +0 -131
- package/ios/Models/ThemeEnum.swift +0 -20
- package/ios/Models/ThemeReact.swift +0 -32
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ You will have access to four methods to communicate with the sdk.
|
|
|
53
53
|
* @returns {@link IDCheckioResult}
|
|
54
54
|
* @throws An error of type {@link IDCheckioError} if the capture fails.
|
|
55
55
|
*/
|
|
56
|
-
export function
|
|
56
|
+
export function startSession(onlineContext: IDCheckioOnlineContext | null, parameters: IDCheckioParams, theme: IDCheckTheme | null): Promise<IDCheckioResult>;
|
|
57
57
|
```
|
|
58
58
|
### Preload
|
|
59
59
|
The `preload` is completely optional and will preload the embedded model of the sdk, this way the `activate` will be faster afterwards.
|
|
@@ -124,7 +124,7 @@ const [onlineContext, setOnlineContext] = useState<IDCheckioOnlineContext | null
|
|
|
124
124
|
const startCapture = async () => {
|
|
125
125
|
let theme = new IDCheckTheme({});
|
|
126
126
|
let params = new IDCheckioParamsBuilder().build();
|
|
127
|
-
|
|
127
|
+
startSession(onlineContext, params).then(
|
|
128
128
|
(result) => {
|
|
129
129
|
setOnlineContext(result.onlineContext);
|
|
130
130
|
Alert.alert('Success', 'Capture ended successfully.');
|
package/android/build.gradle
CHANGED
|
@@ -8,7 +8,7 @@ buildscript {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
dependencies {
|
|
11
|
-
classpath "com.android.tools.build:gradle:8.
|
|
11
|
+
classpath "com.android.tools.build:gradle:8.10.1"
|
|
12
12
|
// noinspection DifferentKotlinGradleVersion
|
|
13
13
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
14
|
}
|
|
@@ -48,6 +48,8 @@ def supportsNamespace() {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
android {
|
|
51
|
+
ndkVersion getExtOrDefault("ndkversion")
|
|
52
|
+
|
|
51
53
|
if (supportsNamespace()) {
|
|
52
54
|
namespace "com.idnowreactidcheckio"
|
|
53
55
|
|
|
@@ -93,13 +95,17 @@ repositories {
|
|
|
93
95
|
|
|
94
96
|
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
95
97
|
|
|
98
|
+
configurations.all {
|
|
99
|
+
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-compose-compiler-plugin-embeddable'
|
|
100
|
+
}
|
|
101
|
+
|
|
96
102
|
dependencies {
|
|
97
103
|
// For < 0.71, this will be from the local maven repo
|
|
98
104
|
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
99
105
|
//noinspection GradleDynamicVersion
|
|
100
106
|
implementation "com.facebook.react:react-native:+"
|
|
101
107
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
102
|
-
implementation('com.ariadnext.android.idcheckio:sdk:
|
|
108
|
+
implementation('com.ariadnext.android.idcheckio:sdk:9.0.3@aar') {
|
|
103
109
|
transitive = true
|
|
104
110
|
}
|
|
105
111
|
implementation 'androidx.appcompat:appcompat:1.7.0'
|
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
IdnowReactIdcheckio_kotlinVersion=2.0
|
|
1
|
+
IdnowReactIdcheckio_kotlinVersion=2.2.0
|
|
2
2
|
IdnowReactIdcheckio_minSdkVersion=21
|
|
3
3
|
IdnowReactIdcheckio_targetSdkVersion=35
|
|
4
4
|
IdnowReactIdcheckio_compileSdkVersion=35
|
|
5
|
-
IdnowReactIdcheckio_ndkversion=27.
|
|
5
|
+
IdnowReactIdcheckio_ndkversion=27.1.12297006
|
|
@@ -2,33 +2,31 @@ package com.idnowreactidcheckio
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.content.Intent
|
|
5
|
-
import com.ariadnext.idcheckio.
|
|
6
|
-
import com.ariadnext.idcheckio.
|
|
7
|
-
import com.ariadnext.idcheckio.
|
|
8
|
-
import com.ariadnext.idcheckio.
|
|
9
|
-
import com.ariadnext.idcheckio.
|
|
10
|
-
import com.ariadnext.idcheckio.
|
|
11
|
-
import com.ariadnext.idcheckio.
|
|
12
|
-
import com.ariadnext.idcheckio.
|
|
13
|
-
import com.ariadnext.idcheckio.
|
|
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
|
|
5
|
+
import com.ariadnext.idcheckio.domain.utils.extension.toJson
|
|
6
|
+
import com.ariadnext.idcheckio.external.Idcheckio
|
|
7
|
+
import com.ariadnext.idcheckio.external.error.ErrorMsg
|
|
8
|
+
import com.ariadnext.idcheckio.external.error.IdcheckioError
|
|
9
|
+
import com.ariadnext.idcheckio.external.error.IdcheckioErrorCause
|
|
10
|
+
import com.ariadnext.idcheckio.external.error.toErrorMsg
|
|
11
|
+
import com.ariadnext.idcheckio.external.result.activation.IdcheckioCallback
|
|
12
|
+
import com.ariadnext.idcheckio.external.result.onboarding.OnboardingResultCallback
|
|
13
|
+
import com.ariadnext.idcheckio.external.result.online.IdcheckioResult
|
|
17
14
|
import com.facebook.react.bridge.BaseActivityEventListener
|
|
18
15
|
import com.facebook.react.bridge.Promise
|
|
19
16
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
20
17
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
21
18
|
import com.facebook.react.bridge.ReactMethod
|
|
22
19
|
import com.facebook.react.bridge.ReadableMap
|
|
23
|
-
import com.idnowreactidcheckio.utils.Extension.filterNotNullValues
|
|
24
20
|
import com.idnowreactidcheckio.utils.Mapper
|
|
25
21
|
|
|
26
|
-
class
|
|
22
|
+
class IDCheckIOBridgeModule(private val reactContext: ReactApplicationContext) :
|
|
27
23
|
ReactContextBaseJavaModule(reactContext), IdcheckioCallback, OnboardingResultCallback {
|
|
28
24
|
/** Name of the module */
|
|
29
|
-
private val name = "
|
|
25
|
+
private val name = "IDCheckIOBridgeModule"
|
|
26
|
+
|
|
30
27
|
/*** Flag to retrieve activity result*/
|
|
31
28
|
private val startRequest = 9537152
|
|
29
|
+
|
|
32
30
|
/*** Keep the promise as we will need to send a response after the async call are done.*/
|
|
33
31
|
private var promise: Promise? = null
|
|
34
32
|
|
|
@@ -36,9 +34,9 @@ class IdnowReactIdcheckioModule(private val reactContext: ReactApplicationContex
|
|
|
36
34
|
reactContext.addActivityEventListener(object : BaseActivityEventListener() {
|
|
37
35
|
override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?) {
|
|
38
36
|
if (requestCode != startRequest) return
|
|
39
|
-
if(resultCode == Activity.RESULT_OK) {
|
|
37
|
+
if (resultCode == Activity.RESULT_OK) {
|
|
40
38
|
promise?.resolve(data?.extras?.getSerializable(Mapper.idcheckioResult) ?: IdcheckioResult())
|
|
41
|
-
} else if(resultCode == Activity.RESULT_CANCELED) {
|
|
39
|
+
} else if (resultCode == Activity.RESULT_CANCELED) {
|
|
42
40
|
promise?.reject(name, data?.extras?.getString(Mapper.errorMsg) ?: IdcheckioError.INTERNAL_ERROR.toErrorMsg().toJson())
|
|
43
41
|
}
|
|
44
42
|
}
|
|
@@ -52,7 +50,7 @@ class IdnowReactIdcheckioModule(private val reactContext: ReactApplicationContex
|
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
@ReactMethod
|
|
55
|
-
fun activate(token: String, extractData: Boolean, promise: Promise){
|
|
53
|
+
fun activate(token: String, extractData: Boolean, promise: Promise) {
|
|
56
54
|
this.promise = promise
|
|
57
55
|
Idcheckio.activate(token, reactContext, this, extractData)
|
|
58
56
|
}
|
|
@@ -71,12 +69,9 @@ class IdnowReactIdcheckioModule(private val reactContext: ReactApplicationContex
|
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
@ReactMethod
|
|
74
|
-
fun startOnboarding(folderUid: String,
|
|
72
|
+
fun startOnboarding(folderUid: String, promise: Promise) {
|
|
75
73
|
this.promise = promise
|
|
76
|
-
|
|
77
|
-
Mapper.getOnboardingCustomizationFromReadableMap(reactContext, theme.toHashMap().filterNotNullValues { it?.toString() })
|
|
78
|
-
} ?: OnboardingCustomization()
|
|
79
|
-
reactContext.currentActivity?.let { Idcheckio.startOnboarding(it, folderUid, this, onboardingCustomization) }
|
|
74
|
+
reactContext.currentActivity?.let { Idcheckio.startOnboarding(it, folderUid, this) }
|
|
80
75
|
}
|
|
81
76
|
|
|
82
77
|
/**
|
|
@@ -91,8 +86,8 @@ class IdnowReactIdcheckioModule(private val reactContext: ReactApplicationContex
|
|
|
91
86
|
}
|
|
92
87
|
|
|
93
88
|
@ReactMethod
|
|
94
|
-
fun
|
|
95
|
-
val activity = currentActivity ?: run {
|
|
89
|
+
fun startSession(onlineContext: ReadableMap?, params: ReadableMap, promise: Promise) {
|
|
90
|
+
val activity = reactContext.currentActivity ?: run {
|
|
96
91
|
promise.reject(name, noContextError())
|
|
97
92
|
return
|
|
98
93
|
}
|
|
@@ -100,14 +95,15 @@ class IdnowReactIdcheckioModule(private val reactContext: ReactApplicationContex
|
|
|
100
95
|
val intent = Intent(activity, IdnowReactIdcheckioActivity::class.java).apply {
|
|
101
96
|
putExtra(Mapper.params, params.toHashMap())
|
|
102
97
|
onlineContext?.let { putExtra(Mapper.onlineContext, it.toHashMap().toString()) }
|
|
103
|
-
theme?.let { putExtra(Mapper.theme, it.toHashMap()) }
|
|
104
98
|
}
|
|
105
99
|
activity.startActivityForResult(intent, startRequest)
|
|
106
100
|
}
|
|
107
101
|
|
|
108
102
|
/** Return a json ErrorMsg with the no context error. */
|
|
109
|
-
private fun noContextError() = ErrorMsg(
|
|
110
|
-
|
|
103
|
+
private fun noContextError() = ErrorMsg(
|
|
104
|
+
cause = IdcheckioErrorCause.DEVICE_ERROR, details = IdcheckioError.CONTEXT_LOST.name,
|
|
105
|
+
message = "Fail to find a usable activity to start the sdk."
|
|
106
|
+
).toJson()
|
|
111
107
|
|
|
112
108
|
override fun getName(): String {
|
|
113
109
|
return name
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
package com.idnowreactidcheckio
|
|
2
2
|
|
|
3
|
-
import android.R.attr
|
|
4
3
|
import android.annotation.SuppressLint
|
|
5
4
|
import android.content.Intent
|
|
6
5
|
import android.os.Bundle
|
|
7
6
|
import android.view.Window
|
|
7
|
+
import androidx.fragment.app.Fragment
|
|
8
8
|
import androidx.fragment.app.FragmentActivity
|
|
9
|
-
import com.ariadnext.idcheckio.
|
|
10
|
-
import com.ariadnext.idcheckio.
|
|
11
|
-
import com.ariadnext.idcheckio.
|
|
12
|
-
import com.ariadnext.idcheckio.
|
|
13
|
-
import com.ariadnext.idcheckio.
|
|
14
|
-
import com.ariadnext.idcheckio.
|
|
15
|
-
import com.ariadnext.idcheckio.
|
|
16
|
-
import com.ariadnext.idcheckio.
|
|
17
|
-
import com.idnowreactidcheckio.utils.Extension.filterNotNullValues
|
|
9
|
+
import com.ariadnext.idcheckio.domain.utils.extension.toJson
|
|
10
|
+
import com.ariadnext.idcheckio.external.error.ErrorMsg
|
|
11
|
+
import com.ariadnext.idcheckio.external.error.IdcheckioError
|
|
12
|
+
import com.ariadnext.idcheckio.external.error.toErrorMsg
|
|
13
|
+
import com.ariadnext.idcheckio.external.params.OnlineContext
|
|
14
|
+
import com.ariadnext.idcheckio.external.result.online.IdcheckioInteraction
|
|
15
|
+
import com.ariadnext.idcheckio.external.result.online.IdcheckioInteractionInterface
|
|
16
|
+
import com.ariadnext.idcheckio.external.result.online.IdcheckioResult
|
|
18
17
|
import com.idnowreactidcheckio.utils.Mapper
|
|
19
18
|
|
|
20
19
|
|
|
@@ -27,15 +26,15 @@ class IdnowReactIdcheckioActivity : FragmentActivity(), IdcheckioInteractionInte
|
|
|
27
26
|
setContentView(R.layout.activity_idnow_react_idcheckio)
|
|
28
27
|
val params = intent.extras?.getSerializable(Mapper.params) as? HashMap<String, Any?>
|
|
29
28
|
val onlineContext = intent.extras?.getString(Mapper.onlineContext)
|
|
30
|
-
val theme = intent.extras?.getSerializable(Mapper.theme) as? HashMap<String, Any?> ?: HashMap()
|
|
31
29
|
|
|
32
30
|
Mapper.getIdcheckioViewFromParams(params)
|
|
33
|
-
.
|
|
31
|
+
.also { builder ->
|
|
32
|
+
onlineContext?.let { json -> OnlineContext.createFrom(json) }?.let { builder.onlineContext(it) }
|
|
33
|
+
}
|
|
34
34
|
.listener(this)
|
|
35
35
|
.build()
|
|
36
36
|
.also {
|
|
37
|
-
supportFragmentManager.beginTransaction().replace(R.id.idnow_react_idcheckio_container, it).commit()
|
|
38
|
-
it.startOnline(onlineContext?.let { json -> OnlineContext.Companion.createFrom(json) })
|
|
37
|
+
supportFragmentManager.beginTransaction().replace(R.id.idnow_react_idcheckio_container, it as Fragment).commit()
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
|
|
@@ -54,6 +53,7 @@ class IdnowReactIdcheckioActivity : FragmentActivity(), IdcheckioInteractionInte
|
|
|
54
53
|
}
|
|
55
54
|
finish()
|
|
56
55
|
}
|
|
56
|
+
|
|
57
57
|
IdcheckioInteraction.ERROR -> {
|
|
58
58
|
Intent().apply {
|
|
59
59
|
putExtra(Mapper.errorMsg, (data as ErrorMsg).toJson())
|
|
@@ -61,7 +61,9 @@ class IdnowReactIdcheckioActivity : FragmentActivity(), IdcheckioInteractionInte
|
|
|
61
61
|
}
|
|
62
62
|
finish()
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
|
|
65
|
+
else -> { /* Do nothing */
|
|
66
|
+
}
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
}
|
|
@@ -8,7 +8,7 @@ import com.facebook.react.uimanager.ViewManager
|
|
|
8
8
|
|
|
9
9
|
class IdnowReactIdcheckioPackage : ReactPackage {
|
|
10
10
|
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
-
return listOf(
|
|
11
|
+
return listOf(IDCheckIOBridgeModule(reactContext))
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
package com.idnowreactidcheckio.bean
|
|
2
2
|
|
|
3
|
-
import com.ariadnext.idcheckio.
|
|
4
|
-
import com.ariadnext.idcheckio.
|
|
5
|
-
import com.ariadnext.idcheckio.
|
|
3
|
+
import com.ariadnext.idcheckio.external.params.DataRequirement
|
|
4
|
+
import com.ariadnext.idcheckio.external.params.Extraction
|
|
5
|
+
import com.ariadnext.idcheckio.external.params.FaceDetection
|
|
6
6
|
|
|
7
7
|
internal data class ExtractionReact(
|
|
8
8
|
var codeline: DataRequirement? = null,
|
|
9
|
-
var face: FaceDetection? = null
|
|
9
|
+
var face: FaceDetection? = null,
|
|
10
10
|
) {
|
|
11
11
|
/**
|
|
12
12
|
* Map to an [Extraction] used by the sdk.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
package com.idnowreactidcheckio.bean
|
|
2
2
|
|
|
3
|
-
import com.ariadnext.idcheckio.
|
|
3
|
+
import com.ariadnext.idcheckio.external.params.IntegrityCheck
|
|
4
4
|
|
|
5
5
|
internal data class IntegrityCheckReact(
|
|
6
6
|
var readEmrtd: Boolean? = null,
|
|
7
|
-
var docLiveness: Boolean? = null
|
|
7
|
+
var docLiveness: Boolean? = null,
|
|
8
8
|
) {
|
|
9
9
|
/**
|
|
10
10
|
* Map to an [IntegrityCheck] used by the sdk.
|
|
@@ -2,75 +2,40 @@ package com.idnowreactidcheckio.utils
|
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.content.Context
|
|
5
|
-
import com.ariadnext.idcheckio.
|
|
6
|
-
import com.ariadnext.idcheckio.
|
|
7
|
-
import com.ariadnext.idcheckio.
|
|
8
|
-
import com.ariadnext.idcheckio.
|
|
9
|
-
import com.ariadnext.idcheckio.
|
|
10
|
-
import com.ariadnext.idcheckio.
|
|
11
|
-
import com.ariadnext.idcheckio.
|
|
12
|
-
import com.ariadnext.idcheckio.
|
|
13
|
-
import com.ariadnext.idcheckio.
|
|
14
|
-
import com.ariadnext.idcheckio.
|
|
15
|
-
import com.ariadnext.idcheckio.
|
|
16
|
-
import com.ariadnext.idcheckio.
|
|
17
|
-
import com.ariadnext.idcheckio.
|
|
18
|
-
import com.ariadnext.idcheckio.sdk.component.IdcheckioView
|
|
19
|
-
import com.ariadnext.idcheckio.sdk.interfaces.cis.CISType
|
|
20
|
-
import com.facebook.react.bridge.ReactContext
|
|
5
|
+
import com.ariadnext.idcheckio.external.IdcheckioView
|
|
6
|
+
import com.ariadnext.idcheckio.external.params.CISType
|
|
7
|
+
import com.ariadnext.idcheckio.external.params.CaptureMode
|
|
8
|
+
import com.ariadnext.idcheckio.external.params.ConfirmationType
|
|
9
|
+
import com.ariadnext.idcheckio.external.params.DataRequirement
|
|
10
|
+
import com.ariadnext.idcheckio.external.params.DocumentType
|
|
11
|
+
import com.ariadnext.idcheckio.external.params.Extraction
|
|
12
|
+
import com.ariadnext.idcheckio.external.params.FaceDetection
|
|
13
|
+
import com.ariadnext.idcheckio.external.params.FileSize
|
|
14
|
+
import com.ariadnext.idcheckio.external.params.IntegrityCheck
|
|
15
|
+
import com.ariadnext.idcheckio.external.params.Language
|
|
16
|
+
import com.ariadnext.idcheckio.external.params.OnlineConfig
|
|
17
|
+
import com.ariadnext.idcheckio.external.params.Orientation
|
|
21
18
|
import com.idnowreactidcheckio.bean.ExtractionEnum
|
|
22
19
|
import com.idnowreactidcheckio.bean.ExtractionReact
|
|
23
20
|
import com.idnowreactidcheckio.bean.IntegrityCheckEnum
|
|
24
21
|
import com.idnowreactidcheckio.bean.IntegrityCheckReact
|
|
25
22
|
import com.idnowreactidcheckio.bean.OnlineConfigEnum
|
|
26
23
|
import com.idnowreactidcheckio.bean.ParamsEnum
|
|
27
|
-
import com.idnowreactidcheckio.bean.Theme
|
|
28
|
-
import com.idnowreactidcheckio.bean.ThemeEnum
|
|
29
24
|
import com.idnowreactidcheckio.utils.Extension.filterNotNullValues
|
|
30
25
|
|
|
31
26
|
internal object Mapper {
|
|
32
27
|
/** Key to send/retrieve params on a Bundle */
|
|
33
28
|
const val params = "params"
|
|
34
|
-
|
|
35
|
-
const val theme = "theme"
|
|
29
|
+
|
|
36
30
|
/** Key to send/retrieve online context on a Bundle */
|
|
37
31
|
const val onlineContext = "onlineContext"
|
|
32
|
+
|
|
38
33
|
/** Key to send/retrieve result on a Bundle */
|
|
39
34
|
const val idcheckioResult = "idcheckioResult"
|
|
35
|
+
|
|
40
36
|
/** Key to send/retrieve error on a Bundle */
|
|
41
37
|
const val errorMsg = "errorMsg"
|
|
42
38
|
|
|
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
39
|
@SuppressLint("DiscouragedApi") // Suppressed as it is the only way for us to do this.
|
|
75
40
|
/**
|
|
76
41
|
* Retrieve a resource for any package by it's identifier name.
|
|
@@ -78,7 +43,7 @@ internal object Mapper {
|
|
|
78
43
|
* @param identifier name of a resources.
|
|
79
44
|
* @return the resources if found or null if not.
|
|
80
45
|
*/
|
|
81
|
-
private fun getResFromName(cont: Context, identifier: String): Int?{
|
|
46
|
+
private fun getResFromName(cont: Context, identifier: String): Int? {
|
|
82
47
|
return cont.resources.getIdentifier(identifier, "color", cont.packageName).takeIf { it != 0 }
|
|
83
48
|
}
|
|
84
49
|
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const { withPlugins } = require('@expo/config-plugins');
|
|
2
|
+
const addSPMDependency = require('./plugins/addSPMDependency');
|
|
3
|
+
const copyNativeFiles = require('./plugins/copyNativeFiles');
|
|
4
|
+
|
|
5
|
+
const withIDCheckIO = (config, options = {}) => {
|
|
6
|
+
const {
|
|
7
|
+
version = '9.0.3',
|
|
8
|
+
repositoryUrl = 'https://git-externe.rennes.ariadnext.com/idcheckio/idcheckiosdk-release-ios',
|
|
9
|
+
repoName = 'idcheckiosdk-release-ios',
|
|
10
|
+
productName = 'IDCheckIOSDK',
|
|
11
|
+
} = options;
|
|
12
|
+
|
|
13
|
+
return withPlugins(config, [
|
|
14
|
+
[addSPMDependency, { version, repositoryUrl, repoName, productName }],
|
|
15
|
+
copyNativeFiles,
|
|
16
|
+
]);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = withIDCheckIO;
|
|
@@ -13,31 +13,12 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
|
|
14
14
|
s.platform = :ios, "12.0"
|
|
15
15
|
s.source = { :path => "." }
|
|
16
|
-
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
17
16
|
s.swift_version = "5.7"
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
# Swift/Objective-C compatibility
|
|
19
|
+
s.pod_target_xcconfig = {
|
|
20
|
+
"DEFINES_MODULE" => "YES",
|
|
21
|
+
}
|
|
20
22
|
|
|
21
|
-
|
|
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
|
|
23
|
+
s.source_files = ""
|
|
43
24
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
|
|
3
|
+
@interface RCT_EXTERN_MODULE(IDCheckIOBridgeModule, NSObject)
|
|
4
|
+
|
|
5
|
+
RCT_EXTERN_METHOD(
|
|
6
|
+
preload:(BOOL)extractData
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
RCT_EXTERN_METHOD(
|
|
10
|
+
activate: (NSString *)token
|
|
11
|
+
extractData: (BOOL) extractData
|
|
12
|
+
resolver: (RCTPromiseResolveBlock) resolve
|
|
13
|
+
rejecter: (RCTPromiseRejectBlock)reject
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
RCT_EXTERN_METHOD(
|
|
17
|
+
startOnboarding: (NSString *)folderUid
|
|
18
|
+
resolver: (RCTPromiseResolveBlock) resolve
|
|
19
|
+
rejecter: (RCTPromiseRejectBlock)reject
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
RCT_EXTERN_METHOD(
|
|
23
|
+
startSession: (NSDictionary *)onlineContext
|
|
24
|
+
params: (NSDictionary *)params
|
|
25
|
+
resolver: (RCTPromiseResolveBlock) resolve
|
|
26
|
+
rejecter: (RCTPromiseRejectBlock)reject
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
@end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import IDCheckIOSDK
|
|
3
|
+
import React
|
|
4
|
+
|
|
5
|
+
@objc(IDCheckIOBridgeModule)
|
|
6
|
+
class IDCheckIOBridgeModule: NSObject {
|
|
7
|
+
let tag = "IDnowReactIDCheckIO"
|
|
8
|
+
|
|
9
|
+
@objc
|
|
10
|
+
func preload(_ extractData: Bool) {
|
|
11
|
+
Task(priority: .userInitiated) { @MainActor in
|
|
12
|
+
Idcheckio.preload(extractData: extractData)
|
|
13
|
+
Idcheckio.framework = .reactNative
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@objc
|
|
18
|
+
func activate(
|
|
19
|
+
_ token: String,
|
|
20
|
+
extractData: Bool,
|
|
21
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
22
|
+
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
23
|
+
) {
|
|
24
|
+
Task(priority: .userInitiated) { @MainActor in
|
|
25
|
+
do {
|
|
26
|
+
try await Idcheckio.activate(withToken: token, extractData: extractData)
|
|
27
|
+
print("[\(self.tag))] Initialization ended successfully !")
|
|
28
|
+
resolve(true)
|
|
29
|
+
} catch {
|
|
30
|
+
print("[\(self.tag))] Error occured on activation : \(error.localizedDescription)")
|
|
31
|
+
let jsonError = self.getErrorJson(error)
|
|
32
|
+
reject(self.tag, jsonError, error)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@objc
|
|
38
|
+
func startOnboarding(
|
|
39
|
+
_ folderUid: String,
|
|
40
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
41
|
+
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
42
|
+
) {
|
|
43
|
+
Task(priority: .userInitiated) { @MainActor in
|
|
44
|
+
do {
|
|
45
|
+
try await Idcheckio.startOnboarding(with: folderUid)
|
|
46
|
+
print("[\(self.tag))] Onboarding ended successfully")
|
|
47
|
+
resolve(true)
|
|
48
|
+
} catch {
|
|
49
|
+
print("[\(self.tag))] Error occured : \(error)")
|
|
50
|
+
let jsonError = self.getErrorJson(error)
|
|
51
|
+
reject(self.tag, jsonError, error)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@objc
|
|
57
|
+
func startSession(
|
|
58
|
+
_ onlineContext: [String: Any]?,
|
|
59
|
+
params: [String: Any],
|
|
60
|
+
resolver resolve: @escaping RCTPromiseResolveBlock,
|
|
61
|
+
rejecter reject: @escaping RCTPromiseRejectBlock
|
|
62
|
+
) {
|
|
63
|
+
Task(priority: .userInitiated) { @MainActor in
|
|
64
|
+
let (sdkParams, sdkExtraParams) = Mapper.getIdcheckioParams(map: params)
|
|
65
|
+
let onlineContextJson = Mapper.dictionaryToJSONString(onlineContext ?? [:]) ?? ""
|
|
66
|
+
let onlineContextValue = OnlineContext.from(json: onlineContextJson)
|
|
67
|
+
do {
|
|
68
|
+
let idcheckioResult = try await Idcheckio.startSession(
|
|
69
|
+
onlineContext: onlineContextValue,
|
|
70
|
+
sdkParams: sdkParams,
|
|
71
|
+
sdkExtraParams: sdkExtraParams)
|
|
72
|
+
if let resultValue = idcheckioResult {
|
|
73
|
+
print("[\(self.tag))] Session ended successfully")
|
|
74
|
+
// Manage success
|
|
75
|
+
resolve(self.resultToJSON(resultValue))
|
|
76
|
+
} else {
|
|
77
|
+
print("[\(self.tag))] Session ended with empty result")
|
|
78
|
+
resolve("{}")
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
} catch {
|
|
82
|
+
print("[\(self.tag))] Error occured: \(error))")
|
|
83
|
+
let jsonError = self.getErrorJson(error)
|
|
84
|
+
reject(self.tag, jsonError, error)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// MARK: - Privates functions
|
|
90
|
+
private func resultToJSON(_ result: IdcheckioResult) -> String {
|
|
91
|
+
if let jsonData = try? JSONEncoder().encode(result) {
|
|
92
|
+
return String(data: jsonData, encoding: .utf8) ?? ""
|
|
93
|
+
} else {
|
|
94
|
+
return "{}"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private func getErrorJson(_ error: Error) -> String {
|
|
99
|
+
if let jsonData = try? JSONEncoder().encode(error as! IdcheckioError) {
|
|
100
|
+
return String(data: jsonData, encoding: .utf8) ?? ""
|
|
101
|
+
} else {
|
|
102
|
+
return
|
|
103
|
+
"{\"message\":\"Internal error.\",\"details\":\"INTERNAL_ERROR\",\"cause\":\"INTERNAL_ERROR\"}"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|