@qore-id/react-native-qoreid-sdk 1.1.4 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/android/build.gradle +98 -61
- package/android/gradle.properties +5 -9
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/qoreidsdk/QoreidSdkModule.kt +160 -142
- package/android/src/main/java/com/qoreidsdk/QoreidSdkPackage.kt +27 -12
- package/android/src/newarch/QoreidSdkSpec.kt +7 -0
- package/android/src/oldarch/QoreidSdkSpec.kt +11 -0
- package/ios/QoreidSdk.swift +15 -6
- package/lib/commonjs/NativeQoreidSdk.js +9 -0
- package/lib/commonjs/NativeQoreidSdk.js.map +1 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/qoreIdSdk.js +16 -3
- package/lib/commonjs/qoreIdSdk.js.map +1 -1
- package/lib/commonjs/types.d.js.map +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/NativeQoreidSdk.mjs +3 -0
- package/lib/module/NativeQoreidSdk.mjs.map +1 -0
- package/lib/module/index.mjs +3 -0
- package/lib/module/index.mjs.map +1 -0
- package/lib/module/{qoreIdSdk.js → qoreIdSdk.mjs} +17 -4
- package/lib/module/qoreIdSdk.mjs.map +1 -0
- package/lib/module/types.d.mjs +2 -0
- package/lib/module/{types.d.js.map → types.d.mjs.map} +1 -1
- package/lib/module/{utils.js → utils.mjs} +1 -1
- package/lib/module/{utils.js.map → utils.mjs.map} +1 -1
- package/lib/typescript/src/NativeQoreidSdk.d.ts +7 -0
- package/lib/typescript/src/NativeQoreidSdk.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/{qoreIdSdk.d.ts → src/qoreIdSdk.d.ts} +1 -1
- package/lib/typescript/src/qoreIdSdk.d.ts.map +1 -0
- package/lib/typescript/src/utils.d.ts.map +1 -0
- package/package.json +65 -39
- package/qore-id-react-native-qoreid-sdk.podspec +24 -16
- package/src/NativeQoreidSdk.ts +8 -0
- package/src/qoreIdSdk.tsx +25 -1
- package/android/src/main/java/com/qoreidsdk/QoreIdJSData.kt +0 -50
- package/lib/module/index.js +0 -3
- package/lib/module/index.js.map +0 -1
- package/lib/module/qoreIdSdk.js.map +0 -1
- package/lib/module/types.d.js +0 -2
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/qoreIdSdk.d.ts.map +0 -1
- package/lib/typescript/utils.d.ts.map +0 -1
- /package/lib/typescript/{index.d.ts → src/index.d.ts} +0 -0
- /package/lib/typescript/{utils.d.ts → src/utils.d.ts} +0 -0
package/README.md
CHANGED
package/android/build.gradle
CHANGED
|
@@ -1,98 +1,135 @@
|
|
|
1
1
|
buildscript {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
repositories {
|
|
5
|
-
google()
|
|
6
|
-
mavenCentral()
|
|
7
|
-
}
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["QoreidRnUpgrade_kotlinVersion"]
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
repositories {
|
|
6
|
+
google()
|
|
7
|
+
mavenCentral()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
dependencies {
|
|
11
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
12
|
+
// noinspection DifferentKotlinGradleVersion
|
|
13
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def reactNativeArchitectures() {
|
|
18
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
19
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
def isNewArchitectureEnabled() {
|
|
17
|
-
|
|
23
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
apply plugin: "com.android.library"
|
|
21
27
|
apply plugin: "kotlin-android"
|
|
22
|
-
apply plugin: "maven-publish"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
|
|
26
28
|
|
|
27
29
|
if (isNewArchitectureEnabled()) {
|
|
28
|
-
|
|
30
|
+
apply plugin: "com.facebook.react"
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
def getExtOrDefault(name) {
|
|
32
|
-
|
|
34
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["QoreidSdk_" + name]
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
def getExtOrIntegerDefault(name) {
|
|
36
|
-
|
|
38
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["QoreidSdk_" + name]).toInteger()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
def supportsNamespace() {
|
|
42
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
43
|
+
def major = parsed[0].toInteger()
|
|
44
|
+
def minor = parsed[1].toInteger()
|
|
45
|
+
|
|
46
|
+
// Namespace support was added in 7.3.0
|
|
47
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
android {
|
|
40
|
-
|
|
51
|
+
if (supportsNamespace()) {
|
|
52
|
+
namespace "com.qoreidsdk"
|
|
53
|
+
|
|
41
54
|
sourceSets {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
defaultConfig {
|
|
48
|
-
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
49
|
-
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
50
|
-
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
51
|
-
buildConfigField "String", "s", "\"react_native_android_sdk\""
|
|
52
|
-
multiDexEnabled true
|
|
53
|
-
}
|
|
54
|
-
buildTypes {
|
|
55
|
-
release {
|
|
56
|
-
minifyEnabled false
|
|
57
|
-
}
|
|
58
|
-
debug {
|
|
59
|
-
gradle.properties['isReleaseBuild'] = false
|
|
60
|
-
}
|
|
55
|
+
main {
|
|
56
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
57
|
+
}
|
|
61
58
|
}
|
|
59
|
+
}
|
|
62
60
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
62
|
+
|
|
63
|
+
defaultConfig {
|
|
64
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
65
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
66
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
67
|
+
buildConfigField "String", "s", "\"react_native_android_sdk\""
|
|
68
|
+
multiDexEnabled true
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
buildFeatures {
|
|
72
|
+
buildConfig true
|
|
73
|
+
}
|
|
66
74
|
|
|
75
|
+
buildTypes {
|
|
76
|
+
release {
|
|
77
|
+
minifyEnabled false
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
lintOptions {
|
|
82
|
+
disable "GradleCompatible"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
compileOptions {
|
|
86
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
87
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
sourceSets {
|
|
91
|
+
main {
|
|
92
|
+
if (isNewArchitectureEnabled()) {
|
|
93
|
+
java.srcDirs += [
|
|
94
|
+
"src/newarch",
|
|
95
|
+
// This is needed to build Kotlin project with NewArch enabled
|
|
96
|
+
"${project.buildDir}/generated/source/codegen/java"
|
|
97
|
+
]
|
|
98
|
+
} else {
|
|
99
|
+
java.srcDirs += ["src/oldarch"]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
67
103
|
}
|
|
68
104
|
|
|
69
105
|
repositories {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
mavenLocal()
|
|
73
|
-
maven { url "https://repo.qoreid.com/repository/maven-releases/" }
|
|
74
|
-
maven { url 'https://jitpack.io' }
|
|
106
|
+
mavenCentral()
|
|
107
|
+
google()
|
|
75
108
|
}
|
|
76
109
|
|
|
77
110
|
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
78
111
|
|
|
112
|
+
repositories {
|
|
113
|
+
mavenCentral()
|
|
114
|
+
google()
|
|
115
|
+
mavenLocal()
|
|
116
|
+
maven { url "https://repo.qoreid.com/repository/maven-releases/" }
|
|
117
|
+
maven { url 'https://jitpack.io' }
|
|
118
|
+
}
|
|
79
119
|
|
|
80
120
|
dependencies {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
88
|
-
|
|
121
|
+
implementation 'com.qoreid:qoreid-sdk:1.2.0'
|
|
122
|
+
// For < 0.71, this will be from the local maven repo
|
|
123
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
124
|
+
//noinspection GradleDynamicVersion
|
|
125
|
+
implementation "com.facebook.react:react-native:+"
|
|
126
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
89
127
|
}
|
|
90
128
|
|
|
91
|
-
|
|
92
129
|
if (isNewArchitectureEnabled()) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
130
|
+
react {
|
|
131
|
+
jsRootDir = file("../src/")
|
|
132
|
+
libraryName = "QoreidSdk"
|
|
133
|
+
codegenJavaPackageName = "com.qoreidsdk"
|
|
134
|
+
}
|
|
98
135
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
android.useAndroidX=true
|
|
7
|
-
android.enableJetifier=true
|
|
8
|
-
isReleaseBuild=true
|
|
9
|
-
|
|
1
|
+
QoreidRnUpgrade_kotlinVersion=1.7.0
|
|
2
|
+
QoreidRnUpgrade_minSdkVersion=21
|
|
3
|
+
QoreidRnUpgrade_targetSdkVersion=31
|
|
4
|
+
QoreidRnUpgrade_compileSdkVersion=31
|
|
5
|
+
QoreidRnUpgrade_ndkversion=21.4.7075529
|
|
@@ -4,8 +4,16 @@ import android.app.Activity
|
|
|
4
4
|
import android.content.Intent
|
|
5
5
|
import android.os.Build
|
|
6
6
|
import android.util.Log
|
|
7
|
-
import
|
|
7
|
+
import androidx.annotation.RequiresApi
|
|
8
|
+
import com.facebook.react.bridge.Arguments
|
|
9
|
+
import com.facebook.react.bridge.BaseActivityEventListener
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
|
+
import com.facebook.react.bridge.ReactMethod
|
|
12
|
+
import com.facebook.react.bridge.Promise
|
|
13
|
+
import com.facebook.react.bridge.ReadableMap
|
|
14
|
+
import com.facebook.react.bridge.WritableMap
|
|
8
15
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
16
|
+
import com.qoreid.sdk.core.OnFlowRequestIdCallback
|
|
9
17
|
import com.qoreid.sdk.core.QoreIDParams
|
|
10
18
|
import com.qoreid.sdk.core.QoreIDSdk
|
|
11
19
|
import com.qoreid.sdk.core.QoreIDSdk.QORE_ID_RESULT_CODE
|
|
@@ -15,153 +23,163 @@ import com.qoreid.sdk.core.models.ApplicantData
|
|
|
15
23
|
import com.qoreid.sdk.core.models.ErrorResult
|
|
16
24
|
import com.qoreid.sdk.core.models.QoreIDResult
|
|
17
25
|
import com.qoreid.sdk.core.models.SuccessResult
|
|
18
|
-
import java.util.HashMap
|
|
19
|
-
|
|
20
|
-
class QoreidSdkModule(val reactContext: ReactApplicationContext) :
|
|
21
|
-
ReactContextBaseJavaModule(reactContext) {
|
|
22
|
-
private var qoreIdResult: QoreIDResult? = null
|
|
23
|
-
|
|
24
|
-
private val activityEventListener =
|
|
25
|
-
object : BaseActivityEventListener() {
|
|
26
|
-
override fun onActivityResult(
|
|
27
|
-
activity: Activity?,
|
|
28
|
-
requestCode: Int,
|
|
29
|
-
resultCode: Int,
|
|
30
|
-
intent: Intent?
|
|
31
|
-
) {
|
|
32
|
-
|
|
33
|
-
if (resultCode == QORE_ID_RESULT_CODE && intent != null) {
|
|
34
|
-
qoreIdResult =
|
|
35
|
-
if (Build.VERSION.SDK_INT < 33) {
|
|
36
|
-
intent.extras?.getSerializable(QORE_ID_RESULT_EXTRA_KEY) as
|
|
37
|
-
QoreIDResult
|
|
38
|
-
} else {
|
|
39
|
-
intent.extras?.getSerializable(
|
|
40
|
-
QORE_ID_RESULT_EXTRA_KEY,
|
|
41
|
-
QoreIDResult::class.java
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
processQoreIDResult(reactContext, qoreIdResult!!)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
init {
|
|
50
|
-
reactContext.addActivityEventListener(activityEventListener)
|
|
51
|
-
QoreIDSdk.Callbacks.onFlowRequestId {
|
|
52
|
-
Log.i("QORE_ID", it.toString())
|
|
53
|
-
|
|
54
|
-
val event =
|
|
55
|
-
Arguments.createMap().apply {
|
|
56
|
-
putString("data", it.toString())
|
|
57
|
-
putString("message", "QOREID SDK INITIALIZED")
|
|
58
|
-
putString("event", "SESSION_RESULT")
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
sendEvent(reactContext, "onResult", event)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
override fun getName(): String {
|
|
66
|
-
return NAME
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
@ReactMethod
|
|
70
|
-
fun launchQoreidSdk(readableData: ReadableMap) {
|
|
71
|
-
val data = readableData.toHashMap()
|
|
72
26
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
)
|
|
99
|
-
val flowId = config?.get("flowId") as? Double
|
|
100
|
-
|
|
101
|
-
val qoreIDParams =
|
|
102
|
-
if (flowId?.toLong() != 0L) {
|
|
103
|
-
QoreIDParams()
|
|
104
|
-
.clientId(config?.get("clientId") as String)
|
|
105
|
-
.customerReference(config?.get("customerReference") as String)
|
|
106
|
-
.inputData(applicantData, addressData)
|
|
107
|
-
.ocrAcceptedDocuments(data?.get("acceptedDocuments") as List<String>)
|
|
108
|
-
.workflow(flowId!!.toLong())
|
|
109
|
-
// .workflowDefaultIdentity(config?.get("defaultIdType") as
|
|
110
|
-
// String)
|
|
111
|
-
} else {
|
|
112
|
-
QoreIDParams()
|
|
113
|
-
.clientId(config?.get("clientId") as String)
|
|
114
|
-
.customerReference(config?.get("customerReference") as String)
|
|
115
|
-
.inputData(applicantData, addressData)
|
|
116
|
-
.ocrAcceptedDocuments(data?.get("acceptedDocuments") as List<String>)
|
|
117
|
-
.collection(config?.get("productCode") as String)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
QoreIDSdk.s(BuildConfig.s)
|
|
121
|
-
QoreIDSdk.params(qoreIDParams)
|
|
122
|
-
QoreIDSdk.launch(requireNotNull(currentActivity))
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
fun processQoreIDResult(context: ReactContext, qoreIdResult: QoreIDResult) {
|
|
126
|
-
when (qoreIdResult) {
|
|
127
|
-
is ErrorResult -> {
|
|
128
|
-
// Handle error.
|
|
129
|
-
val event =
|
|
130
|
-
Arguments.createMap().apply {
|
|
131
|
-
putString("code", qoreIdResult.code.toString())
|
|
132
|
-
putString("data", qoreIdResult.data.toString())
|
|
133
|
-
putString("message", qoreIdResult.message)
|
|
134
|
-
putString("event", "ERROR_RESULT")
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
sendEvent(context, "onResult", event)
|
|
138
|
-
}
|
|
139
|
-
is SuccessResult -> {
|
|
140
|
-
// Handle success.
|
|
141
|
-
val event =
|
|
142
|
-
Arguments.createMap().apply {
|
|
143
|
-
putString("data", qoreIdResult.data.toString())
|
|
144
|
-
putString("message", qoreIdResult.message)
|
|
145
|
-
putString("event", "SUCCESS_RESULT")
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
sendEvent(context, "onResult", event)
|
|
27
|
+
class QoreidSdkModule internal constructor(context: ReactApplicationContext) :
|
|
28
|
+
QoreidSdkSpec(context) {
|
|
29
|
+
|
|
30
|
+
private var qoreIdResult: QoreIDResult? = null
|
|
31
|
+
|
|
32
|
+
private val activityEventListener =
|
|
33
|
+
object : BaseActivityEventListener() {
|
|
34
|
+
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
|
35
|
+
override fun onActivityResult(
|
|
36
|
+
activity: Activity?,
|
|
37
|
+
requestCode: Int,
|
|
38
|
+
resultCode: Int,
|
|
39
|
+
intent: Intent?
|
|
40
|
+
) {
|
|
41
|
+
|
|
42
|
+
if (resultCode == QORE_ID_RESULT_CODE && intent != null) {
|
|
43
|
+
qoreIdResult =
|
|
44
|
+
if (Build.VERSION.SDK_INT < 33) {
|
|
45
|
+
intent.extras?.getSerializable(QORE_ID_RESULT_EXTRA_KEY) as
|
|
46
|
+
QoreIDResult
|
|
47
|
+
} else {
|
|
48
|
+
intent.extras?.getSerializable(
|
|
49
|
+
QORE_ID_RESULT_EXTRA_KEY,
|
|
50
|
+
QoreIDResult::class.java
|
|
51
|
+
)
|
|
149
52
|
}
|
|
53
|
+
processQoreIDResult(context, qoreIdResult!!)
|
|
150
54
|
}
|
|
55
|
+
}
|
|
151
56
|
}
|
|
152
57
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
58
|
+
override fun getName(): String {
|
|
59
|
+
return NAME
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
init {
|
|
63
|
+
context.addActivityEventListener(activityEventListener)
|
|
64
|
+
|
|
65
|
+
QoreIDSdk.Callbacks.onFlowRequestId(object : OnFlowRequestIdCallback {
|
|
66
|
+
override fun onValue(flowRequestId: Long) {
|
|
67
|
+
Log.i("QORE_ID", flowRequestId.toString())
|
|
68
|
+
val event =
|
|
69
|
+
Arguments.createMap().apply {
|
|
70
|
+
putString("data", flowRequestId.toString())
|
|
71
|
+
putString("message", "QOREID SDK INITIALIZED")
|
|
72
|
+
putString("event", "SESSION_RESULT")
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
sendEvent(context, "onResult", event)
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@ReactMethod
|
|
81
|
+
override fun launchQoreidSdk(readableData: ReadableMap) {
|
|
82
|
+
val data = readableData.toHashMap()
|
|
83
|
+
|
|
84
|
+
if (currentActivity == null) {
|
|
85
|
+
Log.e("Error", "No current activity")
|
|
86
|
+
return
|
|
157
87
|
}
|
|
158
88
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
89
|
+
val config = data?.get("config") as? HashMap<*, *>
|
|
90
|
+
val apD = data?.get("applicantData") as? HashMap<*, *>
|
|
91
|
+
val applicantData =
|
|
92
|
+
ApplicantData(
|
|
93
|
+
apD?.get("firstName") as String,
|
|
94
|
+
apD?.get("lastName") as String,
|
|
95
|
+
apD?.get("phoneNumber") as String?,
|
|
96
|
+
apD?.get("middleName") as String?,
|
|
97
|
+
apD?.get("dob") as String?,
|
|
98
|
+
apD?.get("email") as String?,
|
|
99
|
+
apD?.get("gender") as String?
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
val adD = data?.get("addressData") as? HashMap<*, *>
|
|
103
|
+
val addressData =
|
|
104
|
+
AddressData(
|
|
105
|
+
adD?.get("address") as String?,
|
|
106
|
+
adD?.get("city") as String?,
|
|
107
|
+
adD?.get("lga") as String?,
|
|
108
|
+
adD?.get("state") as String?,
|
|
109
|
+
)
|
|
110
|
+
val flowId = config?.get("flowId") as? Double
|
|
111
|
+
|
|
112
|
+
val qoreIDParams =
|
|
113
|
+
if (flowId?.toLong() != 0L) {
|
|
114
|
+
QoreIDParams()
|
|
115
|
+
.clientId(config?.get("clientId") as String)
|
|
116
|
+
.customerReference(config?.get("customerReference") as String)
|
|
117
|
+
.inputData(applicantData, addressData)
|
|
118
|
+
.ocrAcceptedDocuments(data?.get("acceptedDocuments") as List<String>)
|
|
119
|
+
.workflow(flowId!!.toLong())
|
|
120
|
+
.workflowDefaultIdentity(
|
|
121
|
+
config?.get("defaultIdType") as
|
|
122
|
+
String
|
|
123
|
+
)
|
|
124
|
+
} else {
|
|
125
|
+
QoreIDParams()
|
|
126
|
+
.clientId(config?.get("clientId") as String)
|
|
127
|
+
.customerReference(config?.get("customerReference") as String)
|
|
128
|
+
.inputData(applicantData, addressData)
|
|
129
|
+
.ocrAcceptedDocuments(data?.get("acceptedDocuments") as List<String>)
|
|
130
|
+
.collection(config?.get("productCode") as String)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
QoreIDSdk.s(BuildConfig.s)
|
|
134
|
+
QoreIDSdk.params(qoreIDParams)
|
|
135
|
+
QoreIDSdk.launch(requireNotNull(currentActivity))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
fun processQoreIDResult(context: ReactApplicationContext, qoreIdResult: QoreIDResult) {
|
|
139
|
+
when (qoreIdResult) {
|
|
140
|
+
is ErrorResult -> {
|
|
141
|
+
// Handle error.
|
|
142
|
+
val event =
|
|
143
|
+
Arguments.createMap().apply {
|
|
144
|
+
putString("code", qoreIdResult.code.toString())
|
|
145
|
+
putString("data", qoreIdResult.data.toString())
|
|
146
|
+
putString("message", qoreIdResult.message)
|
|
147
|
+
putString("event", "ERROR_RESULT")
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
sendEvent(context, "onResult", event)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
is SuccessResult -> {
|
|
154
|
+
// Handle success.
|
|
155
|
+
val event =
|
|
156
|
+
Arguments.createMap().apply {
|
|
157
|
+
putString("data", qoreIdResult.data.toString())
|
|
158
|
+
putString("message", qoreIdResult.message)
|
|
159
|
+
putString("event", "SUCCESS_RESULT")
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
sendEvent(context, "onResult", event)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private fun sendEvent(
|
|
168
|
+
reactContext: ReactApplicationContext,
|
|
169
|
+
eventName: String,
|
|
170
|
+
params: WritableMap?
|
|
171
|
+
) {
|
|
172
|
+
reactContext
|
|
173
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
174
|
+
.emit(eventName, params)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
companion object {
|
|
178
|
+
const val NAME = "QoreidSdk"
|
|
179
|
+
|
|
180
|
+
@JvmStatic
|
|
181
|
+
fun initialize(activity: Activity) {
|
|
182
|
+
QoreIDSdk.initialize(activity)
|
|
166
183
|
}
|
|
184
|
+
}
|
|
167
185
|
}
|
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
package com.qoreidsdk
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import com.facebook.react.ReactPackage
|
|
6
|
-
import com.facebook.react.bridge.NativeModule
|
|
3
|
+
import com.facebook.react.TurboReactPackage
|
|
7
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
|
-
import com.facebook.react.
|
|
9
|
-
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
|
+
import java.util.HashMap
|
|
10
9
|
|
|
11
|
-
class QoreidSdkPackage :
|
|
12
|
-
override fun
|
|
13
|
-
return
|
|
10
|
+
class QoreidSdkPackage : TurboReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == QoreidSdkModule.NAME) {
|
|
13
|
+
QoreidSdkModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
override fun
|
|
17
|
-
return
|
|
19
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
+
return ReactModuleInfoProvider {
|
|
21
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
+
val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
23
|
+
moduleInfos[QoreidSdkModule.NAME] = ReactModuleInfo(
|
|
24
|
+
QoreidSdkModule.NAME,
|
|
25
|
+
QoreidSdkModule.NAME,
|
|
26
|
+
false, // canOverrideExistingModule
|
|
27
|
+
false, // needsEagerInit
|
|
28
|
+
true, // hasConstants
|
|
29
|
+
false, // isCxxModule
|
|
30
|
+
isTurboModule // isTurboModule
|
|
31
|
+
)
|
|
32
|
+
moduleInfos
|
|
33
|
+
}
|
|
18
34
|
}
|
|
19
|
-
|
|
20
35
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
package com.qoreidsdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
|
+
import com.facebook.react.bridge.Promise
|
|
6
|
+
import com.facebook.react.bridge.ReadableMap
|
|
7
|
+
|
|
8
|
+
abstract class QoreidSdkSpec internal constructor(context: ReactApplicationContext) :
|
|
9
|
+
ReactContextBaseJavaModule(context) {
|
|
10
|
+
abstract fun launchQoreidSdk(readableData: ReadableMap)
|
|
11
|
+
}
|
package/ios/QoreidSdk.swift
CHANGED
|
@@ -75,7 +75,7 @@ class QoreidSdk: RCTEventEmitter {
|
|
|
75
75
|
vc.onQoreIdResult = { [weak self] result in
|
|
76
76
|
self?.onQoreIdResultReceived(result: result)
|
|
77
77
|
}
|
|
78
|
-
self.controller()
|
|
78
|
+
self.controller()?.pushViewController(vc, animated: false)
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -84,10 +84,10 @@ class QoreidSdk: RCTEventEmitter {
|
|
|
84
84
|
if let result = result {
|
|
85
85
|
if let errorResult = result as? ErrorResult {
|
|
86
86
|
self.sendEvent(withName: "onResult", body:["code": String(describing: errorResult.code), "data": self.parseData(errorResult.data), "message": errorResult.message, "event": "ERROR_RESULT"])
|
|
87
|
-
self.controller()
|
|
87
|
+
self.controller()?.popViewController(animated: false)
|
|
88
88
|
} else if let successResult = result as? SuccessResult {
|
|
89
89
|
self.sendEvent(withName: "onResult", body:["data": self.parseData( successResult.data), "message": successResult.message!, "event": "SUCCESS_RESULT"])
|
|
90
|
-
self.controller()
|
|
90
|
+
self.controller()?.popViewController(animated: false)
|
|
91
91
|
} else if let pendingResult = result as? PendingResult {
|
|
92
92
|
self.sendEvent(withName: "onResult", body:["data": pendingResult.data?.verification?.id! ?? 0, "message": pendingResult.message!, "event": "SESSION_RESULT"])
|
|
93
93
|
}
|
|
@@ -130,9 +130,18 @@ class QoreidSdk: RCTEventEmitter {
|
|
|
130
130
|
return false
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
private func controller() -> UINavigationController {
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
private func controller() -> UINavigationController? {
|
|
134
|
+
if #available(iOS 13.0, *) {
|
|
135
|
+
// iOS 13 and later
|
|
136
|
+
let scenes = UIApplication.shared.connectedScenes
|
|
137
|
+
let windowScene = scenes.first { $0.activationState == .foregroundActive } as? UIWindowScene
|
|
138
|
+
let window = windowScene?.windows.first { $0.isKeyWindow }
|
|
139
|
+
return (window?.rootViewController as? UINavigationController)
|
|
140
|
+
} else {
|
|
141
|
+
// iOS 12 and earlier
|
|
142
|
+
let window = UIApplication.shared.keyWindow
|
|
143
|
+
return (window?.rootViewController as! UINavigationController)
|
|
144
|
+
}
|
|
136
145
|
}
|
|
137
146
|
}
|
|
138
147
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('QoreidSdk');
|
|
9
|
+
//# sourceMappingURL=NativeQoreidSdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeQoreidSdk.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAMpCC,gCAAmB,CAACC,YAAY,CAAO,WAAW,CAAC","ignoreList":[]}
|