@finos_sdk/sdk-ekyc 1.2.9 → 1.3.1
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/build.gradle +1 -1
- package/android/src/main/java/finos/sdk/ekyc/EKYCModule.kt +207 -119
- package/dist/EKYCModule.d.ts +8 -8
- package/dist/EKYCModule.js +76 -40
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/package.json +1 -1
- package/dist/src/modules/FinosEKYCModule.d.ts +15 -16
- package/dist/src/modules/FinosEKYCModule.js +32 -43
- package/dist/src/modules/FinosESignModule.d.ts +21 -16
- package/dist/src/modules/FinosESignModule.js +73 -218
- package/dist/src/types/ekycLivenessType.d.ts +11 -2
- package/dist/src/types/ekycLivenessType.js +7 -0
- package/package.json +2 -2
- package/src/modules/FinosEKYCModule.ts +72 -87
- package/src/modules/FinosESignModule.ts +117 -266
- package/src/modules/README.md +21 -2
- package/src/types/ekycLivenessType.ts +16 -2
package/android/build.gradle
CHANGED
|
@@ -65,7 +65,7 @@ dependencies {
|
|
|
65
65
|
implementation 'com.facebook.react:react-android'
|
|
66
66
|
|
|
67
67
|
// Finos eKYC SDK dependencies from GitHub Packages Maven repository
|
|
68
|
-
def sdkVersion = "1.
|
|
68
|
+
def sdkVersion = "1.3.1"
|
|
69
69
|
implementation("finos.sdk.ekyc:ekyc:$sdkVersion")
|
|
70
70
|
implementation("finos.sdk.ekyc:ekycui:$sdkVersion")
|
|
71
71
|
implementation("finos.sdk.ekyc:nfc:$sdkVersion")
|
|
@@ -8,6 +8,7 @@ import com.facebook.react.bridge.Promise
|
|
|
8
8
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
9
|
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
10
10
|
import com.facebook.react.bridge.ReactMethod
|
|
11
|
+
import com.facebook.react.bridge.ReadableArray
|
|
11
12
|
import com.facebook.react.bridge.WritableArray
|
|
12
13
|
import com.facebook.react.bridge.WritableMap
|
|
13
14
|
import com.facebook.react.module.annotations.ReactModule
|
|
@@ -15,6 +16,7 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
|
15
16
|
import finos.sdk.c06.SdkEkycC06
|
|
16
17
|
import finos.sdk.core.define.EKYCEvent
|
|
17
18
|
import finos.sdk.core.define.SDKType
|
|
19
|
+
import finos.sdk.core.define.SDKFaceDetectStatus
|
|
18
20
|
import finos.sdk.core.model.response.SDKEkycResult
|
|
19
21
|
import finos.sdk.core.model.sdk.config.AppKeyConfig
|
|
20
22
|
import finos.sdk.core.model.sdk.config.C06Config
|
|
@@ -330,10 +332,14 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
330
332
|
fun startLiveness(
|
|
331
333
|
appKey: String,
|
|
332
334
|
selfieImage: String,
|
|
333
|
-
usingRandomAction: Boolean,
|
|
334
335
|
transactionId: String,
|
|
335
|
-
isStraight: Boolean,
|
|
336
336
|
switchFrontCamera: Boolean?,
|
|
337
|
+
useActiveLiveness: Boolean?,
|
|
338
|
+
autoCapture: Boolean?,
|
|
339
|
+
isShowCameraFont: Boolean?,
|
|
340
|
+
customActionsArray: ReadableArray?,
|
|
341
|
+
activeActionCount: Int?,
|
|
342
|
+
forceCaptureTimeout: Double?,
|
|
337
343
|
promise: Promise
|
|
338
344
|
) {
|
|
339
345
|
Log.d(TAG, "▶️ startLiveness() called")
|
|
@@ -350,13 +356,38 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
350
356
|
return
|
|
351
357
|
}
|
|
352
358
|
|
|
359
|
+
// Parse customActions from ReadableArray
|
|
360
|
+
val customActions: List<SDKFaceDetectStatus>? = if (customActionsArray != null && customActionsArray.size() > 0) {
|
|
361
|
+
val actions = mutableListOf<SDKFaceDetectStatus>()
|
|
362
|
+
for (i in 0 until customActionsArray.size()) {
|
|
363
|
+
val actionString = customActionsArray.getString(i)
|
|
364
|
+
when (actionString) {
|
|
365
|
+
"LEFT" -> actions.add(SDKFaceDetectStatus.LEFT)
|
|
366
|
+
"RIGHT" -> actions.add(SDKFaceDetectStatus.RIGHT)
|
|
367
|
+
"STRAIGHT" -> actions.add(SDKFaceDetectStatus.STRAIGHT)
|
|
368
|
+
else -> Log.w(TAG, "Unknown action: $actionString")
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (actions.isNotEmpty()) actions else null
|
|
372
|
+
} else {
|
|
373
|
+
null
|
|
374
|
+
}
|
|
375
|
+
|
|
353
376
|
val livenessConfig =
|
|
354
377
|
LivenessConfig(
|
|
378
|
+
isActiveLiveness = useActiveLiveness ?: false,
|
|
379
|
+
autoCapture = autoCapture ?: true,
|
|
380
|
+
isShowCameraFont = isShowCameraFont ?: (switchFrontCamera ?: true),
|
|
381
|
+
// Custom actions từ checkboxes (nếu có chọn)
|
|
382
|
+
// Nếu có actions được chọn → sử dụng customActions
|
|
383
|
+
// Nếu không có actions nào được chọn → sử dụng random actions với activeActionCount
|
|
384
|
+
customActions = customActions,
|
|
385
|
+
// Number of random actions (1-10), only used when customActions = null
|
|
386
|
+
// activeActionCount = 2 → 2 random actions + STRAIGHT
|
|
387
|
+
activeActionCount = activeActionCount ?: 2,
|
|
388
|
+
forceCaptureTimeout = (forceCaptureTimeout ?: 0.0).toLong(),
|
|
355
389
|
selfieImage = imageFile,
|
|
356
|
-
|
|
357
|
-
isStraight = isStraight,
|
|
358
|
-
transactionId = transactionId,
|
|
359
|
-
isShowCameraFont = switchFrontCamera ?: false
|
|
390
|
+
transactionId = transactionId
|
|
360
391
|
)
|
|
361
392
|
val ekycConfig =
|
|
362
393
|
EKYCConfigSDK(
|
|
@@ -965,8 +996,8 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
965
996
|
// ==================== eSign Methods ====================
|
|
966
997
|
|
|
967
998
|
@ReactMethod
|
|
968
|
-
fun initializeESign(promise: Promise) {
|
|
969
|
-
Log.d(TAG, "▶️ initializeESign() called")
|
|
999
|
+
fun initializeESign(finosToken: String?, promise: Promise) {
|
|
1000
|
+
Log.d(TAG, "▶️ initializeESign() called with token: ${finosToken?.take(10)}...")
|
|
970
1001
|
try {
|
|
971
1002
|
val currentActivity = reactApplicationContext.currentActivity
|
|
972
1003
|
if (currentActivity == null) {
|
|
@@ -977,6 +1008,7 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
977
1008
|
|
|
978
1009
|
SdkeSign.initializeESign(
|
|
979
1010
|
context = currentActivity,
|
|
1011
|
+
finosToken = finosToken,
|
|
980
1012
|
callbackSuccess = { code, message ->
|
|
981
1013
|
Log.d(TAG, "✅ initializeESign() success")
|
|
982
1014
|
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
@@ -990,11 +1022,11 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
990
1022
|
Log.e(TAG, "❌ initializeESign() failed - Event: $event, Message: ${error.message}")
|
|
991
1023
|
val errorMap = Arguments.createMap().apply {
|
|
992
1024
|
putString("event", event.name.toString())
|
|
993
|
-
putString("message", error.message)
|
|
994
|
-
putString("code", error.code)
|
|
1025
|
+
putString("message", error.message ?: "")
|
|
1026
|
+
putString("code", error.code.toString())
|
|
995
1027
|
}
|
|
996
1028
|
sendEvent("onESignError", errorMap)
|
|
997
|
-
promise.reject(event.name.toString(), error.message)
|
|
1029
|
+
promise.reject(event.name.toString(), error.message ?: "Unknown Error")
|
|
998
1030
|
}
|
|
999
1031
|
)
|
|
1000
1032
|
} catch (e: Exception) {
|
|
@@ -1003,6 +1035,35 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1003
1035
|
}
|
|
1004
1036
|
}
|
|
1005
1037
|
|
|
1038
|
+
@ReactMethod
|
|
1039
|
+
fun getSdkToken(
|
|
1040
|
+
identity: String,
|
|
1041
|
+
name: String,
|
|
1042
|
+
deviceId: String,
|
|
1043
|
+
promise: Promise
|
|
1044
|
+
) {
|
|
1045
|
+
Log.d(TAG, "▶️ getSdkToken() called")
|
|
1046
|
+
try {
|
|
1047
|
+
SdkeSign.getSdkToken(
|
|
1048
|
+
cccd = identity, // Map identity param to cccd
|
|
1049
|
+
name = name,
|
|
1050
|
+
deviceId = deviceId,
|
|
1051
|
+
callbackSuccess = { token ->
|
|
1052
|
+
Log.d(TAG, "✅ getSdkToken() success")
|
|
1053
|
+
promise.resolve(token)
|
|
1054
|
+
},
|
|
1055
|
+
callbackError = { error ->
|
|
1056
|
+
Log.e(TAG, "❌ getSdkToken() failed: $error")
|
|
1057
|
+
// error might be String or Object, toString() covers both
|
|
1058
|
+
promise.reject("GET_SDK_TOKEN_ERROR", error.toString())
|
|
1059
|
+
}
|
|
1060
|
+
)
|
|
1061
|
+
} catch (e: Exception) {
|
|
1062
|
+
Log.e(TAG, "❌ getSdkToken() exception: ${e.message}", e)
|
|
1063
|
+
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1006
1067
|
@ReactMethod
|
|
1007
1068
|
fun openSessionId(
|
|
1008
1069
|
accessToken: String?,
|
|
@@ -1042,11 +1103,11 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1042
1103
|
Log.e(TAG, "❌ openSessionId() failed - Event: $event, Message: ${error.message}")
|
|
1043
1104
|
val errorMap = Arguments.createMap().apply {
|
|
1044
1105
|
putString("event", event.name.toString())
|
|
1045
|
-
putString("message", error.message)
|
|
1046
|
-
putString("code", error.code)
|
|
1106
|
+
putString("message", error.message ?: "")
|
|
1107
|
+
putString("code", error.code.toString())
|
|
1047
1108
|
}
|
|
1048
1109
|
sendEvent("onESignError", errorMap)
|
|
1049
|
-
promise.reject(event.name.toString(), error.message)
|
|
1110
|
+
promise.reject(event.name.toString(), error.message ?: "Unknown Error")
|
|
1050
1111
|
}
|
|
1051
1112
|
)
|
|
1052
1113
|
} else if (userEsignModelJson != null && privateKeyFilePath != null) {
|
|
@@ -1082,11 +1143,11 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1082
1143
|
Log.e(TAG, "❌ openSessionId() failed - Event: $event, Message: ${error.message}")
|
|
1083
1144
|
val errorMap = Arguments.createMap().apply {
|
|
1084
1145
|
putString("event", event.name.toString())
|
|
1085
|
-
putString("message", error.message)
|
|
1086
|
-
putString("code", error.code)
|
|
1146
|
+
putString("message", error.message ?: "")
|
|
1147
|
+
putString("code", error.code.toString())
|
|
1087
1148
|
}
|
|
1088
1149
|
sendEvent("onESignError", errorMap)
|
|
1089
|
-
promise.reject(event.name.toString(), error.message)
|
|
1150
|
+
promise.reject(event.name.toString(), error.message ?: "Unknown Error")
|
|
1090
1151
|
}
|
|
1091
1152
|
)
|
|
1092
1153
|
} else {
|
|
@@ -1133,11 +1194,11 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1133
1194
|
Log.e(TAG, "❌ registerDevice() failed - Event: $event, Message: ${error.message}")
|
|
1134
1195
|
val errorMap = Arguments.createMap().apply {
|
|
1135
1196
|
putString("event", event.name.toString())
|
|
1136
|
-
putString("message", error.message)
|
|
1137
|
-
putString("code", error.code)
|
|
1197
|
+
putString("message", error.message ?: "")
|
|
1198
|
+
putString("code", error.code.toString())
|
|
1138
1199
|
}
|
|
1139
1200
|
sendEvent("onESignError", errorMap)
|
|
1140
|
-
promise.reject(event.name.toString(), error.message)
|
|
1201
|
+
promise.reject(event.name.toString(), error.message ?: "Unknown Error")
|
|
1141
1202
|
}
|
|
1142
1203
|
)
|
|
1143
1204
|
} catch (e: Exception) {
|
|
@@ -1156,7 +1217,6 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1156
1217
|
try {
|
|
1157
1218
|
val currentActivity = reactApplicationContext.currentActivity
|
|
1158
1219
|
if (currentActivity == null) {
|
|
1159
|
-
Log.e(TAG, "❌ listCerts() failed: Activity not available")
|
|
1160
1220
|
promise.reject("NO_ACTIVITY", "Activity not available")
|
|
1161
1221
|
return
|
|
1162
1222
|
}
|
|
@@ -1166,7 +1226,7 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1166
1226
|
pageNumber = pageNumber,
|
|
1167
1227
|
pageSize = pageSize,
|
|
1168
1228
|
callbackSuccess = { certs ->
|
|
1169
|
-
|
|
1229
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1170
1230
|
val (eventMap, promiseMap) = createSeparateMapsWithArray(
|
|
1171
1231
|
arrayBuilder = { array: WritableArray ->
|
|
1172
1232
|
certs.forEach { cert ->
|
|
@@ -1185,18 +1245,17 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1185
1245
|
promise.resolve(promiseMap)
|
|
1186
1246
|
},
|
|
1187
1247
|
callbackError = { event, error ->
|
|
1188
|
-
|
|
1248
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1189
1249
|
val errorMap = Arguments.createMap().apply {
|
|
1190
1250
|
putString("event", event.name.toString())
|
|
1191
|
-
putString("message", error.message)
|
|
1192
|
-
putString("code", error.code)
|
|
1251
|
+
putString("message", error.message ?: "")
|
|
1252
|
+
putString("code", error.code.toString())
|
|
1193
1253
|
}
|
|
1194
1254
|
sendEvent("onESignError", errorMap)
|
|
1195
|
-
promise.reject(event.name.toString(), error.message)
|
|
1255
|
+
promise.reject(event.name.toString(), error.message ?: "Unknown Error")
|
|
1196
1256
|
}
|
|
1197
1257
|
)
|
|
1198
1258
|
} catch (e: Exception) {
|
|
1199
|
-
Log.e(TAG, "❌ listCerts() exception: ${e.message}", e)
|
|
1200
1259
|
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1201
1260
|
}
|
|
1202
1261
|
}
|
|
@@ -1207,10 +1266,22 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1207
1266
|
promise: Promise
|
|
1208
1267
|
) {
|
|
1209
1268
|
Log.d(TAG, "▶️ verifyCert() called")
|
|
1269
|
+
|
|
1270
|
+
if (serial.isBlank()) {
|
|
1271
|
+
val errorMsg = "Certificate serial không được để trống"
|
|
1272
|
+
val errorMap = Arguments.createMap().apply {
|
|
1273
|
+
putString("event", "SDK_START_ERROR")
|
|
1274
|
+
putString("message", errorMsg)
|
|
1275
|
+
putString("code", "INVALID_SERIAL")
|
|
1276
|
+
}
|
|
1277
|
+
sendEvent("onESignError", errorMap)
|
|
1278
|
+
promise.reject("INVALID_SERIAL", errorMsg)
|
|
1279
|
+
return
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1210
1282
|
try {
|
|
1211
1283
|
val currentActivity = reactApplicationContext.currentActivity
|
|
1212
1284
|
if (currentActivity == null) {
|
|
1213
|
-
Log.e(TAG, "❌ verifyCert() failed: Activity not available")
|
|
1214
1285
|
promise.reject("NO_ACTIVITY", "Activity not available")
|
|
1215
1286
|
return
|
|
1216
1287
|
}
|
|
@@ -1219,7 +1290,7 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1219
1290
|
context = currentActivity,
|
|
1220
1291
|
serial = serial,
|
|
1221
1292
|
callbackSuccess = { code, message ->
|
|
1222
|
-
|
|
1293
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1223
1294
|
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
1224
1295
|
map.putString("code", code.toString())
|
|
1225
1296
|
map.putString("message", message)
|
|
@@ -1228,18 +1299,19 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1228
1299
|
promise.resolve(promiseMap)
|
|
1229
1300
|
},
|
|
1230
1301
|
callbackError = { event, error ->
|
|
1231
|
-
|
|
1302
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1303
|
+
val errorMessage = error.message ?: ""
|
|
1304
|
+
val errorCode = error.code.toString()
|
|
1232
1305
|
val errorMap = Arguments.createMap().apply {
|
|
1233
1306
|
putString("event", event.name.toString())
|
|
1234
|
-
putString("message",
|
|
1235
|
-
putString("code",
|
|
1307
|
+
putString("message", errorMessage)
|
|
1308
|
+
putString("code", errorCode)
|
|
1236
1309
|
}
|
|
1237
1310
|
sendEvent("onESignError", errorMap)
|
|
1238
|
-
promise.reject(event.name.toString(),
|
|
1311
|
+
promise.reject(event.name.toString(), errorMessage)
|
|
1239
1312
|
}
|
|
1240
1313
|
)
|
|
1241
1314
|
} catch (e: Exception) {
|
|
1242
|
-
Log.e(TAG, "❌ verifyCert() exception: ${e.message}", e)
|
|
1243
1315
|
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1244
1316
|
}
|
|
1245
1317
|
}
|
|
@@ -1254,7 +1326,6 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1254
1326
|
try {
|
|
1255
1327
|
val currentActivity = reactApplicationContext.currentActivity
|
|
1256
1328
|
if (currentActivity == null) {
|
|
1257
|
-
Log.e(TAG, "❌ listSignRequest() failed: Activity not available")
|
|
1258
1329
|
promise.reject("NO_ACTIVITY", "Activity not available")
|
|
1259
1330
|
return
|
|
1260
1331
|
}
|
|
@@ -1264,14 +1335,16 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1264
1335
|
pageNumber = pageNumber,
|
|
1265
1336
|
pageSize = pageSize,
|
|
1266
1337
|
callbackSuccess = { requests ->
|
|
1267
|
-
|
|
1338
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1268
1339
|
val (eventMap, promiseMap) = createSeparateMapsWithArray(
|
|
1269
1340
|
arrayBuilder = { array: WritableArray ->
|
|
1270
1341
|
requests.forEach { request ->
|
|
1271
1342
|
val requestMap = Arguments.createMap().apply {
|
|
1272
1343
|
putString("requestId", request.requestId)
|
|
1273
|
-
putString("
|
|
1274
|
-
putString("
|
|
1344
|
+
putString("authId", request.authId ?: "")
|
|
1345
|
+
putString("authData", request.authData ?: "")
|
|
1346
|
+
putString("status", request.authId ?: "")
|
|
1347
|
+
putString("documentName", request.authData ?: "")
|
|
1275
1348
|
}
|
|
1276
1349
|
array.pushMap(requestMap)
|
|
1277
1350
|
}
|
|
@@ -1282,18 +1355,17 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1282
1355
|
promise.resolve(promiseMap)
|
|
1283
1356
|
},
|
|
1284
1357
|
callbackError = { event, error ->
|
|
1285
|
-
|
|
1358
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1286
1359
|
val errorMap = Arguments.createMap().apply {
|
|
1287
1360
|
putString("event", event.name.toString())
|
|
1288
|
-
putString("message", error.message)
|
|
1289
|
-
putString("code", error.code)
|
|
1361
|
+
putString("message", error.message ?: "")
|
|
1362
|
+
putString("code", error.code.toString())
|
|
1290
1363
|
}
|
|
1291
1364
|
sendEvent("onESignError", errorMap)
|
|
1292
|
-
promise.reject(event.name.toString(), error.message)
|
|
1365
|
+
promise.reject(event.name.toString(), error.message ?: "Unknown Error")
|
|
1293
1366
|
}
|
|
1294
1367
|
)
|
|
1295
1368
|
} catch (e: Exception) {
|
|
1296
|
-
Log.e(TAG, "❌ listSignRequest() exception: ${e.message}", e)
|
|
1297
1369
|
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1298
1370
|
}
|
|
1299
1371
|
}
|
|
@@ -1308,6 +1380,8 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1308
1380
|
promise: Promise
|
|
1309
1381
|
) {
|
|
1310
1382
|
Log.d(TAG, "▶️ confirmSign() called")
|
|
1383
|
+
Log.d(TAG, " 📋 Request params - signRequestId: $signRequestId, confirm: $confirm")
|
|
1384
|
+
Log.d(TAG, " 📋 Auth params - authId: ${authId?.take(20)}..., authData: ${authData?.take(20)}...")
|
|
1311
1385
|
try {
|
|
1312
1386
|
val currentActivity = reactApplicationContext.currentActivity
|
|
1313
1387
|
if (currentActivity == null) {
|
|
@@ -1316,6 +1390,7 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1316
1390
|
return
|
|
1317
1391
|
}
|
|
1318
1392
|
|
|
1393
|
+
Log.d(TAG, " 🔄 Calling SdkeSign.confirmSign()")
|
|
1319
1394
|
SdkeSign.confirmSign(
|
|
1320
1395
|
context = currentActivity,
|
|
1321
1396
|
signRequestId = signRequestId,
|
|
@@ -1324,7 +1399,8 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1324
1399
|
authData = authData ?: "",
|
|
1325
1400
|
confirm = confirm,
|
|
1326
1401
|
callbackSuccess = { code, message ->
|
|
1327
|
-
Log.d(TAG, "✅ confirmSign() success")
|
|
1402
|
+
Log.d(TAG, "✅ confirmSign() success - Code: $code, Message: $message")
|
|
1403
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1328
1404
|
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
1329
1405
|
map.putString("code", code.toString())
|
|
1330
1406
|
map.putString("message", message)
|
|
@@ -1333,69 +1409,47 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1333
1409
|
promise.resolve(promiseMap)
|
|
1334
1410
|
},
|
|
1335
1411
|
callbackError = { event, error ->
|
|
1336
|
-
|
|
1337
|
-
val
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1412
|
+
val errorMessage = error.message ?: ""
|
|
1413
|
+
val errorCode = error.code.toString()
|
|
1414
|
+
|
|
1415
|
+
Log.d(TAG, "🔍 confirmSign() error callback - Message: '$errorMessage', Code: '$errorCode'")
|
|
1416
|
+
|
|
1417
|
+
// Check if message contains "thành công" or code == "0" -> treat as success
|
|
1418
|
+
if (errorMessage.contains("thành công", ignoreCase = true) || errorCode == "0") {
|
|
1419
|
+
Log.d(TAG, "✅ confirmSign() success (async operation) - Message: $errorMessage")
|
|
1420
|
+
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
1421
|
+
map.putString("code", "200")
|
|
1422
|
+
map.putString("message", errorMessage)
|
|
1423
|
+
}
|
|
1424
|
+
sendEvent("onESignConfirmSignSuccess", eventMap)
|
|
1425
|
+
promise.resolve(promiseMap)
|
|
1426
|
+
} else {
|
|
1427
|
+
Log.e(TAG, "❌ confirmSign() failed - Event: $event, Message: $errorMessage, Code: $errorCode")
|
|
1428
|
+
val errorMap = Arguments.createMap().apply {
|
|
1429
|
+
putString("event", event.name.toString())
|
|
1430
|
+
putString("message", errorMessage)
|
|
1431
|
+
putString("code", errorCode)
|
|
1432
|
+
}
|
|
1433
|
+
sendEvent("onESignError", errorMap)
|
|
1434
|
+
promise.reject(event.name.toString(), errorMessage)
|
|
1341
1435
|
}
|
|
1342
|
-
sendEvent("onESignError", errorMap)
|
|
1343
|
-
promise.reject(event.name.toString(), error.message)
|
|
1344
1436
|
}
|
|
1345
1437
|
)
|
|
1346
1438
|
} catch (e: Exception) {
|
|
1347
|
-
Log.e(TAG, "❌ confirmSign() exception: ${e.message}", e)
|
|
1348
1439
|
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1349
1440
|
}
|
|
1350
1441
|
}
|
|
1351
1442
|
|
|
1352
|
-
|
|
1353
|
-
fun authenticate(
|
|
1354
|
-
username: String,
|
|
1355
|
-
password: String,
|
|
1356
|
-
promise: Promise
|
|
1357
|
-
) {
|
|
1358
|
-
Log.d(TAG, "▶️ authenticate() called")
|
|
1359
|
-
try {
|
|
1360
|
-
SdkeSign.authenticate(
|
|
1361
|
-
username = username,
|
|
1362
|
-
password = password,
|
|
1363
|
-
callbackSuccess = { token, userId ->
|
|
1364
|
-
Log.d(TAG, "✅ authenticate() success")
|
|
1365
|
-
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
1366
|
-
map.putString("token", token)
|
|
1367
|
-
map.putString("userId", userId.toString())
|
|
1368
|
-
}
|
|
1369
|
-
sendEvent("onESignAuthenticateSuccess", eventMap)
|
|
1370
|
-
promise.resolve(promiseMap)
|
|
1371
|
-
},
|
|
1372
|
-
callbackError = { event, error ->
|
|
1373
|
-
Log.e(TAG, "❌ authenticate() failed - Event: $event, Message: ${error.message}")
|
|
1374
|
-
val errorMap = Arguments.createMap().apply {
|
|
1375
|
-
putString("event", event.name.toString())
|
|
1376
|
-
putString("message", error.message)
|
|
1377
|
-
putString("code", error.code)
|
|
1378
|
-
}
|
|
1379
|
-
sendEvent("onESignError", errorMap)
|
|
1380
|
-
promise.reject(event.name.toString(), error.message)
|
|
1381
|
-
}
|
|
1382
|
-
)
|
|
1383
|
-
} catch (e: Exception) {
|
|
1384
|
-
Log.e(TAG, "❌ authenticate() exception: ${e.message}", e)
|
|
1385
|
-
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1443
|
+
|
|
1388
1444
|
|
|
1389
1445
|
@ReactMethod
|
|
1390
1446
|
fun registerRemoteSigning(
|
|
1391
|
-
accessToken: String,
|
|
1392
1447
|
requestJson: String,
|
|
1393
1448
|
promise: Promise
|
|
1394
1449
|
) {
|
|
1395
1450
|
Log.d(TAG, "▶️ registerRemoteSigning() called")
|
|
1396
1451
|
try {
|
|
1397
1452
|
SdkeSign.registerRemoteSigning(
|
|
1398
|
-
accessToken = accessToken,
|
|
1399
1453
|
requestJson = requestJson,
|
|
1400
1454
|
callbackSuccess = { rawResponse ->
|
|
1401
1455
|
Log.d(TAG, "✅ registerRemoteSigning() success")
|
|
@@ -1406,14 +1460,28 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1406
1460
|
promise.resolve(promiseMap)
|
|
1407
1461
|
},
|
|
1408
1462
|
callbackError = { event, error ->
|
|
1409
|
-
|
|
1410
|
-
val
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1463
|
+
val errorMessage = error.message ?: ""
|
|
1464
|
+
val errorCode = error.code.toString()
|
|
1465
|
+
|
|
1466
|
+
// Check if message contains "thành công" or code == "0" -> treat as success
|
|
1467
|
+
if (errorMessage.contains("thành công", ignoreCase = true) || errorCode == "0") {
|
|
1468
|
+
Log.d(TAG, "✅ registerRemoteSigning() success (async operation) - Message: $errorMessage")
|
|
1469
|
+
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
1470
|
+
map.putString("response", "{\"status\":1,\"msg\":\"$errorMessage\"}")
|
|
1471
|
+
map.putString("message", errorMessage)
|
|
1472
|
+
}
|
|
1473
|
+
sendEvent("onESignRegisterRemoteSigningSuccess", eventMap)
|
|
1474
|
+
promise.resolve(promiseMap)
|
|
1475
|
+
} else {
|
|
1476
|
+
Log.e(TAG, "❌ registerRemoteSigning() failed - Event: $event, Message: $errorMessage")
|
|
1477
|
+
val errorMap = Arguments.createMap().apply {
|
|
1478
|
+
putString("event", event.name.toString())
|
|
1479
|
+
putString("message", errorMessage)
|
|
1480
|
+
putString("code", errorCode)
|
|
1481
|
+
}
|
|
1482
|
+
sendEvent("onESignError", errorMap)
|
|
1483
|
+
promise.reject(event.name.toString(), errorMessage)
|
|
1414
1484
|
}
|
|
1415
|
-
sendEvent("onESignError", errorMap)
|
|
1416
|
-
promise.reject(event.name.toString(), error.message)
|
|
1417
1485
|
}
|
|
1418
1486
|
)
|
|
1419
1487
|
} catch (e: Exception) {
|
|
@@ -1424,17 +1492,15 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1424
1492
|
|
|
1425
1493
|
@ReactMethod
|
|
1426
1494
|
fun signPdf(
|
|
1427
|
-
accessToken: String,
|
|
1428
1495
|
requestJson: String,
|
|
1429
1496
|
promise: Promise
|
|
1430
1497
|
) {
|
|
1431
1498
|
Log.d(TAG, "▶️ signPdf() called")
|
|
1432
1499
|
try {
|
|
1433
1500
|
SdkeSign.signPdf(
|
|
1434
|
-
accessToken = accessToken,
|
|
1435
1501
|
requestJson = requestJson,
|
|
1436
1502
|
callbackSuccess = { rawResponse ->
|
|
1437
|
-
|
|
1503
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1438
1504
|
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
1439
1505
|
map.putString("response", rawResponse)
|
|
1440
1506
|
}
|
|
@@ -1442,35 +1508,45 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1442
1508
|
promise.resolve(promiseMap)
|
|
1443
1509
|
},
|
|
1444
1510
|
callbackError = { event, error ->
|
|
1445
|
-
|
|
1446
|
-
val
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1511
|
+
val errorMessage = error.message ?: ""
|
|
1512
|
+
val errorCode = error.code.toString()
|
|
1513
|
+
|
|
1514
|
+
// Check if message contains "thành công" or code == "0" -> treat as success
|
|
1515
|
+
if (errorMessage.contains("thành công", ignoreCase = true) || errorCode == "0") {
|
|
1516
|
+
Log.d(TAG, "✅ signPdf() success (async operation) - Message: $errorMessage")
|
|
1517
|
+
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
1518
|
+
map.putString("response", "{\"status\":1,\"msg\":\"$errorMessage\"}")
|
|
1519
|
+
map.putString("message", errorMessage)
|
|
1520
|
+
}
|
|
1521
|
+
sendEvent("onESignSignPdfSuccess", eventMap)
|
|
1522
|
+
promise.resolve(promiseMap)
|
|
1523
|
+
} else {
|
|
1524
|
+
val errorMap = Arguments.createMap().apply {
|
|
1525
|
+
putString("event", event.name.toString())
|
|
1526
|
+
putString("message", errorMessage)
|
|
1527
|
+
putString("code", errorCode)
|
|
1528
|
+
}
|
|
1529
|
+
sendEvent("onESignError", errorMap)
|
|
1530
|
+
promise.reject(event.name.toString(), errorMessage)
|
|
1450
1531
|
}
|
|
1451
|
-
sendEvent("onESignError", errorMap)
|
|
1452
|
-
promise.reject(event.name.toString(), error.message)
|
|
1453
1532
|
}
|
|
1454
1533
|
)
|
|
1455
1534
|
} catch (e: Exception) {
|
|
1456
|
-
Log.e(TAG, "❌ signPdf() exception: ${e.message}", e)
|
|
1457
1535
|
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1458
1536
|
}
|
|
1459
1537
|
}
|
|
1460
1538
|
|
|
1461
1539
|
@ReactMethod
|
|
1462
1540
|
fun sendConfirmationDocument(
|
|
1463
|
-
accessToken: String,
|
|
1464
1541
|
requestJson: String,
|
|
1465
1542
|
promise: Promise
|
|
1466
1543
|
) {
|
|
1467
1544
|
Log.d(TAG, "▶️ sendConfirmationDocument() called")
|
|
1468
1545
|
try {
|
|
1469
1546
|
SdkeSign.sendConfirmationDocument(
|
|
1470
|
-
accessToken = accessToken,
|
|
1471
1547
|
requestJson = requestJson,
|
|
1472
1548
|
callbackSuccess = { rawResponse ->
|
|
1473
|
-
|
|
1549
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1474
1550
|
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
1475
1551
|
map.putString("response", rawResponse)
|
|
1476
1552
|
}
|
|
@@ -1478,18 +1554,30 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1478
1554
|
promise.resolve(promiseMap)
|
|
1479
1555
|
},
|
|
1480
1556
|
callbackError = { event, error ->
|
|
1481
|
-
|
|
1482
|
-
val
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1557
|
+
val errorMessage = error.message ?: ""
|
|
1558
|
+
val errorCode = error.code.toString()
|
|
1559
|
+
|
|
1560
|
+
// Check if message contains "thành công" or code == "0" -> treat as success
|
|
1561
|
+
if (errorMessage.contains("thành công", ignoreCase = true) || errorCode == "0") {
|
|
1562
|
+
Log.d(TAG, "✅ sendConfirmationDocument() success (async operation) - Message: $errorMessage")
|
|
1563
|
+
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
1564
|
+
map.putString("response", "{\"status\":1,\"msg\":\"$errorMessage\"}")
|
|
1565
|
+
map.putString("message", errorMessage)
|
|
1566
|
+
}
|
|
1567
|
+
sendEvent("onESignSendConfirmationDocumentSuccess", eventMap)
|
|
1568
|
+
promise.resolve(promiseMap)
|
|
1569
|
+
} else {
|
|
1570
|
+
val errorMap = Arguments.createMap().apply {
|
|
1571
|
+
putString("event", event.name.toString())
|
|
1572
|
+
putString("message", errorMessage)
|
|
1573
|
+
putString("code", errorCode)
|
|
1574
|
+
}
|
|
1575
|
+
sendEvent("onESignError", errorMap)
|
|
1576
|
+
promise.reject(event.name.toString(), errorMessage)
|
|
1486
1577
|
}
|
|
1487
|
-
sendEvent("onESignError", errorMap)
|
|
1488
|
-
promise.reject(event.name.toString(), error.message)
|
|
1489
1578
|
}
|
|
1490
1579
|
)
|
|
1491
1580
|
} catch (e: Exception) {
|
|
1492
|
-
Log.e(TAG, "❌ sendConfirmationDocument() exception: ${e.message}", e)
|
|
1493
1581
|
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1494
1582
|
}
|
|
1495
1583
|
}
|