@finos_sdk/sdk-ekyc 0.0.36 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/AndroidManifest.xml +17 -0
- package/android/src/main/build.gradle +39 -0
- package/android/src/main/java/finos/sdk/ekyc/EKYCModule.kt +541 -0
- package/android/src/main/java/finos/sdk/ekyc/EKYCPackage.kt +38 -0
- package/dist/EKYCModule.d.ts +1 -1
- package/dist/EKYCModule.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
+
package="finos.sdk.ekyc">
|
|
3
|
+
|
|
4
|
+
<application/>
|
|
5
|
+
|
|
6
|
+
</manifest>
|
|
7
|
+
|
|
8
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
9
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
10
|
+
package="finos.sdk.ekyc">
|
|
11
|
+
|
|
12
|
+
<!-- Library manifest. No application/components are required here. -->
|
|
13
|
+
|
|
14
|
+
</manifest>
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
plugins {
|
|
2
|
+
id 'com.android.library'
|
|
3
|
+
id 'org.jetbrains.kotlin.android'
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
android {
|
|
7
|
+
namespace 'finos.sdk.ekyc'
|
|
8
|
+
compileSdk rootProject.ext.compileSdkVersion
|
|
9
|
+
|
|
10
|
+
defaultConfig {
|
|
11
|
+
minSdkVersion rootProject.ext.minSdkVersion
|
|
12
|
+
targetSdkVersion rootProject.ext.targetSdkVersion
|
|
13
|
+
consumerProguardFiles 'consumer-rules.pro'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
buildTypes {
|
|
17
|
+
release {
|
|
18
|
+
minifyEnabled false
|
|
19
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
dependencies {
|
|
25
|
+
implementation 'com.facebook.react:react-android'
|
|
26
|
+
implementation("finos.sdk.ekyc:ekyc:1.2.0")
|
|
27
|
+
implementation("finos.sdk.ekyc:ekycui:1.2.0")
|
|
28
|
+
implementation("finos.sdk.ekyc:nfc:1.2.0")
|
|
29
|
+
implementation("finos.sdk.ekyc:ocr:1.2.0")
|
|
30
|
+
implementation("finos.sdk.ekyc:liveness:1.2.0")
|
|
31
|
+
implementation("finos.sdk.ekyc:faceservice:1.2.0")
|
|
32
|
+
implementation("finos.sdk.ekyc:c06:1.2.0")
|
|
33
|
+
implementation("finos.sdk.ekyc:sdkcore:1.2.0")
|
|
34
|
+
implementation("finos.sdk.ekyc:sdkcorecamera:1.2.0")
|
|
35
|
+
implementation("finos.sdk.ekyc:sdkui:1.2.0")
|
|
36
|
+
implementation("finos.sdk.ekyc:qrcode:1.2.0")
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
// ... existing code ...
|
|
2
|
+
package finos.sdk.ekyc
|
|
3
|
+
|
|
4
|
+
// Reuse the same implementation as app module to expose RN bridge
|
|
5
|
+
// If needed, consider refactoring common code to a shared sourceSet
|
|
6
|
+
|
|
7
|
+
import android.R
|
|
8
|
+
import android.util.Base64
|
|
9
|
+
import android.util.Log
|
|
10
|
+
import com.facebook.react.bridge.Arguments
|
|
11
|
+
import com.facebook.react.bridge.Promise
|
|
12
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
13
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
14
|
+
import com.facebook.react.bridge.ReactMethod
|
|
15
|
+
import com.facebook.react.bridge.WritableMap
|
|
16
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
17
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
18
|
+
import finos.sdk.c06.SdkEkycC06
|
|
19
|
+
import finos.sdk.core.define.EKYCEvent
|
|
20
|
+
import finos.sdk.core.define.SDKType
|
|
21
|
+
import finos.sdk.core.model.response.SDKEkycResult
|
|
22
|
+
import finos.sdk.core.model.sdk.config.AppKeyConfig
|
|
23
|
+
import finos.sdk.core.model.sdk.config.C06Config
|
|
24
|
+
import finos.sdk.core.model.sdk.config.EKYCConfigSDK
|
|
25
|
+
import finos.sdk.core.model.sdk.config.FaceServiceConfig
|
|
26
|
+
import finos.sdk.core.model.sdk.config.LivenessConfig
|
|
27
|
+
import finos.sdk.core.model.sdk.config.NfcConfig
|
|
28
|
+
import finos.sdk.core.model.sdk.config.OcrConfig
|
|
29
|
+
import finos.sdk.core.model.sdk.config.OptionConfig
|
|
30
|
+
import finos.sdk.core.model.sdk.config.StyleConfig
|
|
31
|
+
import finos.sdk.core.define.AppIDType
|
|
32
|
+
import finos.sdk.ekyc.SdkEkyc
|
|
33
|
+
import finos.sdk.ekyc.ui.SdkEkycUI
|
|
34
|
+
import finos.sdk.faceservice.SdkEkycFaceService
|
|
35
|
+
import finos.sdk.liveness.SdkEkycLiveness
|
|
36
|
+
import finos.sdk.nfc.SdkEkycNfc
|
|
37
|
+
import finos.sdk.ocr.SdkEkycOcr
|
|
38
|
+
import java.io.File
|
|
39
|
+
import java.io.FileOutputStream
|
|
40
|
+
import java.util.Date
|
|
41
|
+
|
|
42
|
+
@ReactModule(name = EKYCModule.NAME)
|
|
43
|
+
class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
44
|
+
|
|
45
|
+
companion object {
|
|
46
|
+
const val NAME = "EKYCModule"
|
|
47
|
+
private const val TAG = "EKYCModule"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override fun getName(): String = NAME
|
|
51
|
+
|
|
52
|
+
private fun sendEvent(eventName: String, params: WritableMap?) {
|
|
53
|
+
reactApplicationContext
|
|
54
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
55
|
+
.emit(eventName, params)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@ReactMethod
|
|
59
|
+
fun initSdkEkyc(promise: Promise) {
|
|
60
|
+
try {
|
|
61
|
+
SdkEkyc.initSDKEkyc(reactApplicationContext) {
|
|
62
|
+
val params = Arguments.createMap().apply {
|
|
63
|
+
putString("status", "success")
|
|
64
|
+
putString("message", "SDK EKYC initialized successfully")
|
|
65
|
+
}
|
|
66
|
+
sendEvent("EKYCInitEvent", params)
|
|
67
|
+
promise.resolve(true)
|
|
68
|
+
}
|
|
69
|
+
} catch (e: Exception) {
|
|
70
|
+
promise.reject("INIT_ERROR", "Failed to initialize SDK EKYC: ${e.message}")
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// The rest of methods mirror the app module implementation
|
|
75
|
+
// startNfcScan, checkC06, startOcr, startLiveness, startFaceCompare, onResume, onPause, handleNewIntent, startEkycUI
|
|
76
|
+
// For brevity in this edit, reuse the same content as in app module `EKYCModule.kt`.
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
package finos.sdk.ekyc
|
|
80
|
+
|
|
81
|
+
import android.util.Base64
|
|
82
|
+
import android.util.Log
|
|
83
|
+
import com.facebook.react.bridge.Arguments
|
|
84
|
+
import com.facebook.react.bridge.Promise
|
|
85
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
86
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
87
|
+
import com.facebook.react.bridge.ReactMethod
|
|
88
|
+
import com.facebook.react.bridge.WritableMap
|
|
89
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
90
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
91
|
+
import finos.sdk.c06.SdkEkycC06
|
|
92
|
+
import finos.sdk.core.define.EKYCEvent
|
|
93
|
+
import finos.sdk.core.define.SDKType
|
|
94
|
+
import finos.sdk.core.model.response.SDKEkycResult
|
|
95
|
+
import finos.sdk.core.model.sdk.config.C06Config
|
|
96
|
+
import finos.sdk.core.model.sdk.config.EKYCConfigSDK
|
|
97
|
+
import finos.sdk.core.model.sdk.config.FaceServiceConfig
|
|
98
|
+
import finos.sdk.core.model.sdk.config.LivenessConfig
|
|
99
|
+
import finos.sdk.core.model.sdk.config.NfcConfig
|
|
100
|
+
import finos.sdk.core.model.sdk.config.OcrConfig
|
|
101
|
+
import finos.sdk.ekyc.SdkEkyc
|
|
102
|
+
import finos.sdk.faceservice.SdkEkycFaceService
|
|
103
|
+
import finos.sdk.liveness.SdkEkycLiveness
|
|
104
|
+
import finos.sdk.nfc.SdkEkycNfc
|
|
105
|
+
import finos.sdk.ocr.SdkEkycOcr
|
|
106
|
+
import java.io.File
|
|
107
|
+
import java.io.FileOutputStream
|
|
108
|
+
import java.util.Date
|
|
109
|
+
|
|
110
|
+
@ReactModule(name = EKYCModule.NAME)
|
|
111
|
+
class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
112
|
+
|
|
113
|
+
companion object {
|
|
114
|
+
const val NAME = "EKYCModule"
|
|
115
|
+
private const val TAG = "EKYCModule"
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
override fun getName(): String = NAME
|
|
119
|
+
|
|
120
|
+
private fun sendEvent(eventName: String, params: WritableMap?) {
|
|
121
|
+
reactApplicationContext
|
|
122
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
123
|
+
.emit(eventName, params)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@ReactMethod
|
|
127
|
+
fun initSdkEkyc(promise: Promise) {
|
|
128
|
+
try {
|
|
129
|
+
SdkEkyc.initSDKEkyc(reactApplicationContext) {
|
|
130
|
+
val params =
|
|
131
|
+
Arguments.createMap().apply {
|
|
132
|
+
putString("status", "success")
|
|
133
|
+
putString("message", "SDK EKYC initialized successfully")
|
|
134
|
+
}
|
|
135
|
+
sendEvent("EKYCInitEvent", params)
|
|
136
|
+
promise.resolve(true)
|
|
137
|
+
}
|
|
138
|
+
} catch (e: Exception) {
|
|
139
|
+
promise.reject("INIT_ERROR", "Failed to initialize SDK EKYC: ${e.message}")
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@ReactMethod
|
|
144
|
+
fun startNfcScan(
|
|
145
|
+
appKey: String,
|
|
146
|
+
documentNumber: String,
|
|
147
|
+
birthDate: String,
|
|
148
|
+
expireDate: String,
|
|
149
|
+
transactionId: String?,
|
|
150
|
+
facePathStorage: String?,
|
|
151
|
+
promise: Promise
|
|
152
|
+
) {
|
|
153
|
+
try {
|
|
154
|
+
Log.d(TAG, "startNfcScan:::0000")
|
|
155
|
+
val currentActivity = reactApplicationContext.currentActivity
|
|
156
|
+
if (currentActivity == null) {
|
|
157
|
+
promise.reject("NO_ACTIVITY", "Activity not available")
|
|
158
|
+
return
|
|
159
|
+
}
|
|
160
|
+
Log.d(TAG, "startNfcScan:::1111")
|
|
161
|
+
val nfcConfig = NfcConfig(
|
|
162
|
+
documentNumber = documentNumber,
|
|
163
|
+
birthDate = birthDate,
|
|
164
|
+
expireDate = expireDate,
|
|
165
|
+
facePathStorage = facePathStorage ?: "",
|
|
166
|
+
transactionId = transactionId ?: ""
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
val ekycConfig =
|
|
170
|
+
EKYCConfigSDK(appKey = appKey, sdkType = SDKType.NFC, nfcConfig = nfcConfig)
|
|
171
|
+
|
|
172
|
+
SdkEkycNfc.startEkyc(
|
|
173
|
+
activity = currentActivity,
|
|
174
|
+
ekycConfigSDK = ekycConfig,
|
|
175
|
+
callbackSuccess = { event, data ->
|
|
176
|
+
Log.d(TAG, "NFC Success - Event: $event, Data: $data")
|
|
177
|
+
|
|
178
|
+
when (event) {
|
|
179
|
+
EKYCEvent.SCAN_NFC_START -> {
|
|
180
|
+
val eventMap =
|
|
181
|
+
Arguments.createMap().apply {
|
|
182
|
+
putString("event", event.name)
|
|
183
|
+
putString("data", data.toString())
|
|
184
|
+
}
|
|
185
|
+
sendEvent("onNfcScanStart", eventMap)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
EKYCEvent.SCAN_NFC_SUCCESS -> {
|
|
189
|
+
val eventMap =
|
|
190
|
+
Arguments.createMap().apply {
|
|
191
|
+
putString("event", event.name)
|
|
192
|
+
putString("data", (data as SDKEkycResult).nfcResponse)
|
|
193
|
+
}
|
|
194
|
+
sendEvent("onNfcScanSuccess", eventMap)
|
|
195
|
+
val promiseMap =
|
|
196
|
+
Arguments.createMap().apply {
|
|
197
|
+
putString("event", event.name)
|
|
198
|
+
putString("data", (data as SDKEkycResult).nfcResponse)
|
|
199
|
+
}
|
|
200
|
+
promise.resolve(promiseMap)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
else -> {
|
|
204
|
+
val eventMap =
|
|
205
|
+
Arguments.createMap().apply {
|
|
206
|
+
putString("event", event.name)
|
|
207
|
+
putString("data", data.toString())
|
|
208
|
+
}
|
|
209
|
+
sendEvent("onNfcEvent", eventMap)
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
callbackError = { event, message ->
|
|
214
|
+
Log.e(TAG, "NFC Error - Event: $event, Message: $message")
|
|
215
|
+
|
|
216
|
+
val errorMap =
|
|
217
|
+
Arguments.createMap().apply {
|
|
218
|
+
putString("event", event.name)
|
|
219
|
+
putString("message", message ?: "Unknown error")
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
sendEvent("onNfcError", errorMap)
|
|
223
|
+
promise.reject(event.name, message ?: "Unknown NFC error")
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
Log.d(TAG, "startNfcScan:::222222")
|
|
227
|
+
} catch (e: Exception) {
|
|
228
|
+
Log.e(TAG, "Exception in startNfcScan: ${e.message}", e)
|
|
229
|
+
promise.reject("NFC_EXCEPTION", e.message, e)
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
@ReactMethod
|
|
234
|
+
fun checkC06(
|
|
235
|
+
appKey: String,
|
|
236
|
+
sod: String,
|
|
237
|
+
idCardNumber: String,
|
|
238
|
+
recentLocation: String,
|
|
239
|
+
transactionId: String?,
|
|
240
|
+
promise: Promise
|
|
241
|
+
) {
|
|
242
|
+
try {
|
|
243
|
+
val c06Config =
|
|
244
|
+
C06Config(
|
|
245
|
+
transactionId = transactionId ?: "",
|
|
246
|
+
sod = sod,
|
|
247
|
+
idCardNumber = idCardNumber,
|
|
248
|
+
recentLocation = recentLocation
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
val ekycConfig = EKYCConfigSDK(appKey = appKey, c06Config = c06Config)
|
|
252
|
+
|
|
253
|
+
SdkEkycC06.startEkyc(
|
|
254
|
+
ekycConfigSDK = ekycConfig,
|
|
255
|
+
callbackSuccess = { event, data ->
|
|
256
|
+
Log.d(TAG, "C06 Success - Event: $event, Data: $data")
|
|
257
|
+
|
|
258
|
+
val eventMap =
|
|
259
|
+
Arguments.createMap().apply {
|
|
260
|
+
putString("event", event.name)
|
|
261
|
+
putString("data", data.toString())
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
val promiseMap =
|
|
265
|
+
Arguments.createMap().apply {
|
|
266
|
+
putString("event", event.name)
|
|
267
|
+
putString("data", data.toString())
|
|
268
|
+
}
|
|
269
|
+
sendEvent("onC06Success", eventMap)
|
|
270
|
+
promise.resolve(promiseMap)
|
|
271
|
+
},
|
|
272
|
+
callbackError = { event, message ->
|
|
273
|
+
Log.e(TAG, "C06 Error - Event: $event, Message: $message")
|
|
274
|
+
|
|
275
|
+
val errorMap =
|
|
276
|
+
Arguments.createMap().apply {
|
|
277
|
+
putString("event", event.name)
|
|
278
|
+
putString("message", message ?: "Unknown error")
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
sendEvent("onC06Error", errorMap)
|
|
282
|
+
promise.reject(event.name, message ?: "Unknown C06 error")
|
|
283
|
+
}
|
|
284
|
+
)
|
|
285
|
+
} catch (e: Exception) {
|
|
286
|
+
Log.e(TAG, "Exception in checkC06: ${e.message}", e)
|
|
287
|
+
promise.reject("C06_EXCEPTION", e.message, e)
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
@ReactMethod
|
|
292
|
+
fun startOcr(
|
|
293
|
+
appKey: String,
|
|
294
|
+
idImage: String,
|
|
295
|
+
expectedDocumentSide: String,
|
|
296
|
+
transactionId: String,
|
|
297
|
+
promise: Promise
|
|
298
|
+
) {
|
|
299
|
+
try {
|
|
300
|
+
val currentActivity = reactApplicationContext.currentActivity
|
|
301
|
+
if (currentActivity == null) {
|
|
302
|
+
promise.reject("NO_ACTIVITY", "Activity not available")
|
|
303
|
+
return
|
|
304
|
+
}
|
|
305
|
+
val imageFile = File(idImage.replace("file://", ""))
|
|
306
|
+
if (!imageFile.exists()) {
|
|
307
|
+
promise.reject("FILE_NOT_FOUND", "Image file does not exist")
|
|
308
|
+
return
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
val ocrConfig =
|
|
312
|
+
OcrConfig(
|
|
313
|
+
idImage = imageFile,
|
|
314
|
+
expectedDocumentSide = expectedDocumentSide,
|
|
315
|
+
transactionId = transactionId
|
|
316
|
+
)
|
|
317
|
+
val ekycConfig =
|
|
318
|
+
EKYCConfigSDK(appKey = appKey, sdkType = SDKType.OCR, ocrConfig = ocrConfig)
|
|
319
|
+
SdkEkycOcr.startEkyc(
|
|
320
|
+
ekycConfigSDK = ekycConfig,
|
|
321
|
+
callbackSuccess = { event, data ->
|
|
322
|
+
Log.d(TAG, "OCR Success - Event: $event, Data: $data")
|
|
323
|
+
val resultMap =
|
|
324
|
+
Arguments.createMap().apply {
|
|
325
|
+
putString("event", event.name)
|
|
326
|
+
putString(
|
|
327
|
+
"data",
|
|
328
|
+
(data as SDKEkycResult).ocrResponse.toString()
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
sendEvent("onOcrSuccess", resultMap)
|
|
332
|
+
val promiseMap =
|
|
333
|
+
Arguments.createMap().apply {
|
|
334
|
+
putString("event", event.name)
|
|
335
|
+
putString(
|
|
336
|
+
"data",
|
|
337
|
+
(data as SDKEkycResult).ocrResponse.toString()
|
|
338
|
+
)
|
|
339
|
+
}
|
|
340
|
+
promise.resolve(promiseMap)
|
|
341
|
+
},
|
|
342
|
+
callbackError = { event, message ->
|
|
343
|
+
Log.e(TAG, "OCR Error - Event: $event, Message: $message")
|
|
344
|
+
val errorMap =
|
|
345
|
+
Arguments.createMap().apply {
|
|
346
|
+
putString("event", event.name)
|
|
347
|
+
putString("message", message ?: "Unknown error")
|
|
348
|
+
}
|
|
349
|
+
sendEvent("onOcrError", errorMap)
|
|
350
|
+
promise.reject(event.name, message ?: "Unknown OCR error")
|
|
351
|
+
}
|
|
352
|
+
)
|
|
353
|
+
} catch (e: Exception) {
|
|
354
|
+
Log.e(TAG, "Exception in startOcr: ${e.message}", e)
|
|
355
|
+
promise.reject("OCR_ERROR", e.message)
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
@ReactMethod
|
|
360
|
+
fun startLiveness(
|
|
361
|
+
appKey: String,
|
|
362
|
+
selfieImage: String,
|
|
363
|
+
usingRandomAction: Boolean,
|
|
364
|
+
transactionId: String,
|
|
365
|
+
isStraight: Boolean,
|
|
366
|
+
promise: Promise
|
|
367
|
+
) {
|
|
368
|
+
try {
|
|
369
|
+
val currentActivity = reactApplicationContext.currentActivity
|
|
370
|
+
if (currentActivity == null) {
|
|
371
|
+
promise.reject("NO_ACTIVITY", "Activity not available")
|
|
372
|
+
return
|
|
373
|
+
}
|
|
374
|
+
val imageFile = File(selfieImage.replace("file://", ""))
|
|
375
|
+
if (!imageFile.exists()) {
|
|
376
|
+
promise.reject("FILE_NOT_FOUND", "Image file does not exist")
|
|
377
|
+
return
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
val livenessConfig =
|
|
381
|
+
LivenessConfig(
|
|
382
|
+
selfieImage = imageFile,
|
|
383
|
+
usingRandomAction = usingRandomAction,
|
|
384
|
+
isStraight = isStraight,
|
|
385
|
+
transactionId = transactionId
|
|
386
|
+
)
|
|
387
|
+
val ekycConfig =
|
|
388
|
+
EKYCConfigSDK(
|
|
389
|
+
appKey = appKey,
|
|
390
|
+
sdkType = SDKType.LIVE_NESS,
|
|
391
|
+
livenessConfig = livenessConfig
|
|
392
|
+
)
|
|
393
|
+
SdkEkycLiveness.startEkyc(
|
|
394
|
+
ekycConfigSDK = ekycConfig,
|
|
395
|
+
callbackSuccess = { event, data ->
|
|
396
|
+
Log.d(TAG, "Liveness Success - Event: $event, Data: $data")
|
|
397
|
+
val resultMap =
|
|
398
|
+
Arguments.createMap().apply {
|
|
399
|
+
putString("event", event.name)
|
|
400
|
+
putString(
|
|
401
|
+
"data",
|
|
402
|
+
(data as SDKEkycResult).checkLivenessResponse.toString()
|
|
403
|
+
)
|
|
404
|
+
}
|
|
405
|
+
sendEvent("onLivenessSuccess", resultMap)
|
|
406
|
+
val promiseMap =
|
|
407
|
+
Arguments.createMap().apply {
|
|
408
|
+
putString("event", event.name)
|
|
409
|
+
putString(
|
|
410
|
+
"data",
|
|
411
|
+
(data as SDKEkycResult).checkLivenessResponse.toString()
|
|
412
|
+
)
|
|
413
|
+
}
|
|
414
|
+
promise.resolve(promiseMap)
|
|
415
|
+
},
|
|
416
|
+
callbackError = { event, message ->
|
|
417
|
+
Log.e(TAG, "Liveness Error - Event: $event, Message: $message")
|
|
418
|
+
val errorMap =
|
|
419
|
+
Arguments.createMap().apply {
|
|
420
|
+
putString("event", event.name)
|
|
421
|
+
putString("message", message ?: "Unknown error")
|
|
422
|
+
}
|
|
423
|
+
sendEvent("onLivenessError", errorMap)
|
|
424
|
+
promise.reject(event.name, message ?: "Unknown Liveness error")
|
|
425
|
+
}
|
|
426
|
+
)
|
|
427
|
+
} catch (e: Exception) {
|
|
428
|
+
Log.e(TAG, "Exception in startLiveness: ${e.message}", e)
|
|
429
|
+
promise.reject("LIVENESS_ERROR", e.message)
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
@ReactMethod
|
|
434
|
+
fun startFaceCompare(
|
|
435
|
+
appKey: String,
|
|
436
|
+
transactionId: String,
|
|
437
|
+
selfieImage: String,
|
|
438
|
+
idImage: String,
|
|
439
|
+
promise: Promise
|
|
440
|
+
) {
|
|
441
|
+
try {
|
|
442
|
+
val currentActivity = reactApplicationContext.currentActivity
|
|
443
|
+
if (currentActivity == null) {
|
|
444
|
+
promise.reject("NO_ACTIVITY", "Activity not available")
|
|
445
|
+
return
|
|
446
|
+
}
|
|
447
|
+
val imageFile = File(selfieImage.replace("file://", ""))
|
|
448
|
+
if (!imageFile.exists()) {
|
|
449
|
+
promise.reject("FILE_NOT_FOUND", "Image file does not exist")
|
|
450
|
+
return
|
|
451
|
+
}
|
|
452
|
+
val idImageFile = base64ToImageFile(idImage)
|
|
453
|
+
|
|
454
|
+
val faceServiceConfig =
|
|
455
|
+
FaceServiceConfig(
|
|
456
|
+
appKey = appKey,
|
|
457
|
+
transactionId = transactionId,
|
|
458
|
+
selfieImage = imageFile,
|
|
459
|
+
idImage = idImageFile
|
|
460
|
+
)
|
|
461
|
+
val ekycConfig = EKYCConfigSDK(faceServiceConfig = faceServiceConfig)
|
|
462
|
+
SdkEkycFaceService.startEkyc(
|
|
463
|
+
ekycConfigSDK = ekycConfig,
|
|
464
|
+
callbackSuccess = { event, data ->
|
|
465
|
+
Log.d(TAG, "Face Compare Success - Event: $event, Data: $data")
|
|
466
|
+
val resultMap =
|
|
467
|
+
Arguments.createMap().apply {
|
|
468
|
+
putString("event", event.name)
|
|
469
|
+
putString("data", data.toString())
|
|
470
|
+
}
|
|
471
|
+
sendEvent("onFaceCompareSuccess", resultMap)
|
|
472
|
+
val promiseMap =
|
|
473
|
+
Arguments.createMap().apply {
|
|
474
|
+
putString("event", event.name)
|
|
475
|
+
putString("data", data.toString())
|
|
476
|
+
}
|
|
477
|
+
promise.resolve(promiseMap)
|
|
478
|
+
},
|
|
479
|
+
callbackError = { event, message ->
|
|
480
|
+
Log.e(TAG, "FaceService Error - Event: $event, Message: $message")
|
|
481
|
+
val errorMap =
|
|
482
|
+
Arguments.createMap().apply {
|
|
483
|
+
putString("event", event.name)
|
|
484
|
+
putString("message", message ?: "Unknown error")
|
|
485
|
+
}
|
|
486
|
+
sendEvent("onFaceCompareError", errorMap)
|
|
487
|
+
promise.reject(event.name, message ?: "Unknown FaceService error")
|
|
488
|
+
}
|
|
489
|
+
)
|
|
490
|
+
} catch (e: Exception) {
|
|
491
|
+
Log.e(TAG, "Exception in startFaceCompare: ${e.message}", e)
|
|
492
|
+
promise.reject("FACE_COMPARE_ERROR", e.message)
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
@ReactMethod
|
|
497
|
+
fun onResume() {
|
|
498
|
+
reactApplicationContext.currentActivity?.let { activity ->
|
|
499
|
+
activity.runOnUiThread { SdkEkycNfc.onResumeNfc(activity) }
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
@ReactMethod
|
|
504
|
+
fun onPause() {
|
|
505
|
+
reactApplicationContext.currentActivity?.let { activity ->
|
|
506
|
+
activity.runOnUiThread { SdkEkycNfc.onPauseNfc(activity) }
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
@ReactMethod
|
|
511
|
+
fun handleNewIntent() {
|
|
512
|
+
reactApplicationContext.currentActivity?.let { activity ->
|
|
513
|
+
activity.runOnUiThread { SdkEkycNfc.onNewIntentNfc(activity.intent) }
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
private fun base64ToImageFile(base64Image: String): File {
|
|
518
|
+
try {
|
|
519
|
+
var processedBase64 = base64Image
|
|
520
|
+
if (base64Image.contains(",")) {
|
|
521
|
+
processedBase64 = base64Image.split(",")[1]
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
val bytes = Base64.decode(processedBase64, Base64.DEFAULT)
|
|
525
|
+
val timestamp = Date().time.toString()
|
|
526
|
+
val fileName = "image_$timestamp.jpg"
|
|
527
|
+
val directory = reactApplicationContext.cacheDir
|
|
528
|
+
val filePath = "${directory.path}/$fileName"
|
|
529
|
+
val imageFile = File(filePath)
|
|
530
|
+
FileOutputStream(imageFile).use { it.write(bytes) }
|
|
531
|
+
return imageFile
|
|
532
|
+
} catch (e: Exception) {
|
|
533
|
+
Log.e("LivenessFragment", "Error converting base64 to image file: ${e.message}", e)
|
|
534
|
+
val errorFile = File(reactApplicationContext.cacheDir, "error_image_${Date().time}.jpg")
|
|
535
|
+
errorFile.createNewFile()
|
|
536
|
+
return errorFile
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package finos.sdk.ekyc
|
|
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
|
+
class EKYCPackage : ReactPackage {
|
|
9
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
10
|
+
return listOf(EKYCModule(reactContext))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
14
|
+
return emptyList()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
package finos.sdk.ekyc
|
|
19
|
+
|
|
20
|
+
import com.facebook.react.ReactPackage
|
|
21
|
+
import com.facebook.react.bridge.NativeModule
|
|
22
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
23
|
+
import com.facebook.react.uimanager.ViewManager
|
|
24
|
+
|
|
25
|
+
class EKYCPackage : ReactPackage {
|
|
26
|
+
|
|
27
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
28
|
+
return listOf(EKYCModule(reactContext))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
override fun createViewManagers(
|
|
32
|
+
reactContext: ReactApplicationContext
|
|
33
|
+
): List<ViewManager<*, *>> {
|
|
34
|
+
return emptyList()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
package/dist/EKYCModule.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { C06Config } from './src/types/ekycC06Type';
|
|
|
5
5
|
import { OcrConfig } from './src/types/ekycOCRType';
|
|
6
6
|
import { LivenessConfig } from './src/types/ekycLivenessType';
|
|
7
7
|
import { FaceServiceConfig } from './src/types/ekycFaceType';
|
|
8
|
-
export declare const SDK_VERSION = "0.0.
|
|
8
|
+
export declare const SDK_VERSION = "0.0.36";
|
|
9
9
|
export declare const SDK_NAME = "@finos_sdk/sdk-ekyc";
|
|
10
10
|
declare class SDKeKYC {
|
|
11
11
|
private eventEmitter;
|
package/dist/EKYCModule.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SDKeKYC = exports.SDK_NAME = exports.SDK_VERSION = void 0;
|
|
4
4
|
const react_native_1 = require("react-native");
|
|
5
5
|
// Version information
|
|
6
|
-
exports.SDK_VERSION = '0.0.
|
|
6
|
+
exports.SDK_VERSION = '0.0.36';
|
|
7
7
|
exports.SDK_NAME = '@finos_sdk/sdk-ekyc';
|
|
8
8
|
const EKYCNativeModule = react_native_1.NativeModules.EKYCModule;
|
|
9
9
|
// Validate that the module is available
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finos_sdk/sdk-ekyc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"description": "React Native SDK for eKYC (electronic Know Your Customer) - Vietnamese CCCD NFC reading, OCR, Liveness detection, Face matching, and C06 residence verification",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|