@finos_sdk/sdk-ekyc 1.2.8 → 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/README.md +6 -6
- package/android/build.gradle +1 -1
- package/android/src/main/java/finos/sdk/ekyc/EKYCModule.kt +220 -119
- package/dist/EKYCModule.d.ts +9 -8
- package/dist/EKYCModule.js +89 -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 +20 -16
- package/dist/src/modules/FinosEKYCModule.js +49 -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 +89 -86
- package/src/modules/FinosESignModule.ts +117 -266
- package/src/modules/README.md +21 -2
- package/src/types/ekycLivenessType.ts +16 -2
- package/dist/finos_sdk-sdk-ekyc-1.2.8.tgz +0 -0
|
@@ -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
|
|
@@ -105,6 +107,19 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
|
|
110
|
+
@ReactMethod
|
|
111
|
+
fun setTransactionId(transactionId: String, promise: Promise) {
|
|
112
|
+
Log.d(TAG, "▶️ setTransactionId() called with: $transactionId")
|
|
113
|
+
try {
|
|
114
|
+
SdkEkyc.setTransactionId(transactionId)
|
|
115
|
+
Log.d(TAG, "✅ setTransactionId() success")
|
|
116
|
+
promise.resolve(true)
|
|
117
|
+
} catch (e: Exception) {
|
|
118
|
+
Log.e(TAG, "❌ setTransactionId() failed: ${e.message}", e)
|
|
119
|
+
promise.reject("SET_TRANSACTION_ID_ERROR", "Failed to set transaction ID: ${e.message}")
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
108
123
|
@ReactMethod
|
|
109
124
|
fun startNfcScan(
|
|
110
125
|
appKey: String,
|
|
@@ -317,10 +332,14 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
317
332
|
fun startLiveness(
|
|
318
333
|
appKey: String,
|
|
319
334
|
selfieImage: String,
|
|
320
|
-
usingRandomAction: Boolean,
|
|
321
335
|
transactionId: String,
|
|
322
|
-
isStraight: Boolean,
|
|
323
336
|
switchFrontCamera: Boolean?,
|
|
337
|
+
useActiveLiveness: Boolean?,
|
|
338
|
+
autoCapture: Boolean?,
|
|
339
|
+
isShowCameraFont: Boolean?,
|
|
340
|
+
customActionsArray: ReadableArray?,
|
|
341
|
+
activeActionCount: Int?,
|
|
342
|
+
forceCaptureTimeout: Double?,
|
|
324
343
|
promise: Promise
|
|
325
344
|
) {
|
|
326
345
|
Log.d(TAG, "▶️ startLiveness() called")
|
|
@@ -337,13 +356,38 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
337
356
|
return
|
|
338
357
|
}
|
|
339
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
|
+
|
|
340
376
|
val livenessConfig =
|
|
341
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(),
|
|
342
389
|
selfieImage = imageFile,
|
|
343
|
-
|
|
344
|
-
isStraight = isStraight,
|
|
345
|
-
transactionId = transactionId,
|
|
346
|
-
isShowCameraFont = switchFrontCamera ?: false
|
|
390
|
+
transactionId = transactionId
|
|
347
391
|
)
|
|
348
392
|
val ekycConfig =
|
|
349
393
|
EKYCConfigSDK(
|
|
@@ -952,8 +996,8 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
952
996
|
// ==================== eSign Methods ====================
|
|
953
997
|
|
|
954
998
|
@ReactMethod
|
|
955
|
-
fun initializeESign(promise: Promise) {
|
|
956
|
-
Log.d(TAG, "▶️ initializeESign() called")
|
|
999
|
+
fun initializeESign(finosToken: String?, promise: Promise) {
|
|
1000
|
+
Log.d(TAG, "▶️ initializeESign() called with token: ${finosToken?.take(10)}...")
|
|
957
1001
|
try {
|
|
958
1002
|
val currentActivity = reactApplicationContext.currentActivity
|
|
959
1003
|
if (currentActivity == null) {
|
|
@@ -964,6 +1008,7 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
964
1008
|
|
|
965
1009
|
SdkeSign.initializeESign(
|
|
966
1010
|
context = currentActivity,
|
|
1011
|
+
finosToken = finosToken,
|
|
967
1012
|
callbackSuccess = { code, message ->
|
|
968
1013
|
Log.d(TAG, "✅ initializeESign() success")
|
|
969
1014
|
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
@@ -977,11 +1022,11 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
977
1022
|
Log.e(TAG, "❌ initializeESign() failed - Event: $event, Message: ${error.message}")
|
|
978
1023
|
val errorMap = Arguments.createMap().apply {
|
|
979
1024
|
putString("event", event.name.toString())
|
|
980
|
-
putString("message", error.message)
|
|
981
|
-
putString("code", error.code)
|
|
1025
|
+
putString("message", error.message ?: "")
|
|
1026
|
+
putString("code", error.code.toString())
|
|
982
1027
|
}
|
|
983
1028
|
sendEvent("onESignError", errorMap)
|
|
984
|
-
promise.reject(event.name.toString(), error.message)
|
|
1029
|
+
promise.reject(event.name.toString(), error.message ?: "Unknown Error")
|
|
985
1030
|
}
|
|
986
1031
|
)
|
|
987
1032
|
} catch (e: Exception) {
|
|
@@ -990,6 +1035,35 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
990
1035
|
}
|
|
991
1036
|
}
|
|
992
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
|
+
|
|
993
1067
|
@ReactMethod
|
|
994
1068
|
fun openSessionId(
|
|
995
1069
|
accessToken: String?,
|
|
@@ -1029,11 +1103,11 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1029
1103
|
Log.e(TAG, "❌ openSessionId() failed - Event: $event, Message: ${error.message}")
|
|
1030
1104
|
val errorMap = Arguments.createMap().apply {
|
|
1031
1105
|
putString("event", event.name.toString())
|
|
1032
|
-
putString("message", error.message)
|
|
1033
|
-
putString("code", error.code)
|
|
1106
|
+
putString("message", error.message ?: "")
|
|
1107
|
+
putString("code", error.code.toString())
|
|
1034
1108
|
}
|
|
1035
1109
|
sendEvent("onESignError", errorMap)
|
|
1036
|
-
promise.reject(event.name.toString(), error.message)
|
|
1110
|
+
promise.reject(event.name.toString(), error.message ?: "Unknown Error")
|
|
1037
1111
|
}
|
|
1038
1112
|
)
|
|
1039
1113
|
} else if (userEsignModelJson != null && privateKeyFilePath != null) {
|
|
@@ -1069,11 +1143,11 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1069
1143
|
Log.e(TAG, "❌ openSessionId() failed - Event: $event, Message: ${error.message}")
|
|
1070
1144
|
val errorMap = Arguments.createMap().apply {
|
|
1071
1145
|
putString("event", event.name.toString())
|
|
1072
|
-
putString("message", error.message)
|
|
1073
|
-
putString("code", error.code)
|
|
1146
|
+
putString("message", error.message ?: "")
|
|
1147
|
+
putString("code", error.code.toString())
|
|
1074
1148
|
}
|
|
1075
1149
|
sendEvent("onESignError", errorMap)
|
|
1076
|
-
promise.reject(event.name.toString(), error.message)
|
|
1150
|
+
promise.reject(event.name.toString(), error.message ?: "Unknown Error")
|
|
1077
1151
|
}
|
|
1078
1152
|
)
|
|
1079
1153
|
} else {
|
|
@@ -1120,11 +1194,11 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1120
1194
|
Log.e(TAG, "❌ registerDevice() failed - Event: $event, Message: ${error.message}")
|
|
1121
1195
|
val errorMap = Arguments.createMap().apply {
|
|
1122
1196
|
putString("event", event.name.toString())
|
|
1123
|
-
putString("message", error.message)
|
|
1124
|
-
putString("code", error.code)
|
|
1197
|
+
putString("message", error.message ?: "")
|
|
1198
|
+
putString("code", error.code.toString())
|
|
1125
1199
|
}
|
|
1126
1200
|
sendEvent("onESignError", errorMap)
|
|
1127
|
-
promise.reject(event.name.toString(), error.message)
|
|
1201
|
+
promise.reject(event.name.toString(), error.message ?: "Unknown Error")
|
|
1128
1202
|
}
|
|
1129
1203
|
)
|
|
1130
1204
|
} catch (e: Exception) {
|
|
@@ -1143,7 +1217,6 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1143
1217
|
try {
|
|
1144
1218
|
val currentActivity = reactApplicationContext.currentActivity
|
|
1145
1219
|
if (currentActivity == null) {
|
|
1146
|
-
Log.e(TAG, "❌ listCerts() failed: Activity not available")
|
|
1147
1220
|
promise.reject("NO_ACTIVITY", "Activity not available")
|
|
1148
1221
|
return
|
|
1149
1222
|
}
|
|
@@ -1153,7 +1226,7 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1153
1226
|
pageNumber = pageNumber,
|
|
1154
1227
|
pageSize = pageSize,
|
|
1155
1228
|
callbackSuccess = { certs ->
|
|
1156
|
-
|
|
1229
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1157
1230
|
val (eventMap, promiseMap) = createSeparateMapsWithArray(
|
|
1158
1231
|
arrayBuilder = { array: WritableArray ->
|
|
1159
1232
|
certs.forEach { cert ->
|
|
@@ -1172,18 +1245,17 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1172
1245
|
promise.resolve(promiseMap)
|
|
1173
1246
|
},
|
|
1174
1247
|
callbackError = { event, error ->
|
|
1175
|
-
|
|
1248
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1176
1249
|
val errorMap = Arguments.createMap().apply {
|
|
1177
1250
|
putString("event", event.name.toString())
|
|
1178
|
-
putString("message", error.message)
|
|
1179
|
-
putString("code", error.code)
|
|
1251
|
+
putString("message", error.message ?: "")
|
|
1252
|
+
putString("code", error.code.toString())
|
|
1180
1253
|
}
|
|
1181
1254
|
sendEvent("onESignError", errorMap)
|
|
1182
|
-
promise.reject(event.name.toString(), error.message)
|
|
1255
|
+
promise.reject(event.name.toString(), error.message ?: "Unknown Error")
|
|
1183
1256
|
}
|
|
1184
1257
|
)
|
|
1185
1258
|
} catch (e: Exception) {
|
|
1186
|
-
Log.e(TAG, "❌ listCerts() exception: ${e.message}", e)
|
|
1187
1259
|
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1188
1260
|
}
|
|
1189
1261
|
}
|
|
@@ -1194,10 +1266,22 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1194
1266
|
promise: Promise
|
|
1195
1267
|
) {
|
|
1196
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
|
+
|
|
1197
1282
|
try {
|
|
1198
1283
|
val currentActivity = reactApplicationContext.currentActivity
|
|
1199
1284
|
if (currentActivity == null) {
|
|
1200
|
-
Log.e(TAG, "❌ verifyCert() failed: Activity not available")
|
|
1201
1285
|
promise.reject("NO_ACTIVITY", "Activity not available")
|
|
1202
1286
|
return
|
|
1203
1287
|
}
|
|
@@ -1206,7 +1290,7 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1206
1290
|
context = currentActivity,
|
|
1207
1291
|
serial = serial,
|
|
1208
1292
|
callbackSuccess = { code, message ->
|
|
1209
|
-
|
|
1293
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1210
1294
|
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
1211
1295
|
map.putString("code", code.toString())
|
|
1212
1296
|
map.putString("message", message)
|
|
@@ -1215,18 +1299,19 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1215
1299
|
promise.resolve(promiseMap)
|
|
1216
1300
|
},
|
|
1217
1301
|
callbackError = { event, error ->
|
|
1218
|
-
|
|
1302
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1303
|
+
val errorMessage = error.message ?: ""
|
|
1304
|
+
val errorCode = error.code.toString()
|
|
1219
1305
|
val errorMap = Arguments.createMap().apply {
|
|
1220
1306
|
putString("event", event.name.toString())
|
|
1221
|
-
putString("message",
|
|
1222
|
-
putString("code",
|
|
1307
|
+
putString("message", errorMessage)
|
|
1308
|
+
putString("code", errorCode)
|
|
1223
1309
|
}
|
|
1224
1310
|
sendEvent("onESignError", errorMap)
|
|
1225
|
-
promise.reject(event.name.toString(),
|
|
1311
|
+
promise.reject(event.name.toString(), errorMessage)
|
|
1226
1312
|
}
|
|
1227
1313
|
)
|
|
1228
1314
|
} catch (e: Exception) {
|
|
1229
|
-
Log.e(TAG, "❌ verifyCert() exception: ${e.message}", e)
|
|
1230
1315
|
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1231
1316
|
}
|
|
1232
1317
|
}
|
|
@@ -1241,7 +1326,6 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1241
1326
|
try {
|
|
1242
1327
|
val currentActivity = reactApplicationContext.currentActivity
|
|
1243
1328
|
if (currentActivity == null) {
|
|
1244
|
-
Log.e(TAG, "❌ listSignRequest() failed: Activity not available")
|
|
1245
1329
|
promise.reject("NO_ACTIVITY", "Activity not available")
|
|
1246
1330
|
return
|
|
1247
1331
|
}
|
|
@@ -1251,14 +1335,16 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1251
1335
|
pageNumber = pageNumber,
|
|
1252
1336
|
pageSize = pageSize,
|
|
1253
1337
|
callbackSuccess = { requests ->
|
|
1254
|
-
|
|
1338
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1255
1339
|
val (eventMap, promiseMap) = createSeparateMapsWithArray(
|
|
1256
1340
|
arrayBuilder = { array: WritableArray ->
|
|
1257
1341
|
requests.forEach { request ->
|
|
1258
1342
|
val requestMap = Arguments.createMap().apply {
|
|
1259
1343
|
putString("requestId", request.requestId)
|
|
1260
|
-
putString("
|
|
1261
|
-
putString("
|
|
1344
|
+
putString("authId", request.authId ?: "")
|
|
1345
|
+
putString("authData", request.authData ?: "")
|
|
1346
|
+
putString("status", request.authId ?: "")
|
|
1347
|
+
putString("documentName", request.authData ?: "")
|
|
1262
1348
|
}
|
|
1263
1349
|
array.pushMap(requestMap)
|
|
1264
1350
|
}
|
|
@@ -1269,18 +1355,17 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1269
1355
|
promise.resolve(promiseMap)
|
|
1270
1356
|
},
|
|
1271
1357
|
callbackError = { event, error ->
|
|
1272
|
-
|
|
1358
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1273
1359
|
val errorMap = Arguments.createMap().apply {
|
|
1274
1360
|
putString("event", event.name.toString())
|
|
1275
|
-
putString("message", error.message)
|
|
1276
|
-
putString("code", error.code)
|
|
1361
|
+
putString("message", error.message ?: "")
|
|
1362
|
+
putString("code", error.code.toString())
|
|
1277
1363
|
}
|
|
1278
1364
|
sendEvent("onESignError", errorMap)
|
|
1279
|
-
promise.reject(event.name.toString(), error.message)
|
|
1365
|
+
promise.reject(event.name.toString(), error.message ?: "Unknown Error")
|
|
1280
1366
|
}
|
|
1281
1367
|
)
|
|
1282
1368
|
} catch (e: Exception) {
|
|
1283
|
-
Log.e(TAG, "❌ listSignRequest() exception: ${e.message}", e)
|
|
1284
1369
|
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1285
1370
|
}
|
|
1286
1371
|
}
|
|
@@ -1295,6 +1380,8 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1295
1380
|
promise: Promise
|
|
1296
1381
|
) {
|
|
1297
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)}...")
|
|
1298
1385
|
try {
|
|
1299
1386
|
val currentActivity = reactApplicationContext.currentActivity
|
|
1300
1387
|
if (currentActivity == null) {
|
|
@@ -1303,6 +1390,7 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1303
1390
|
return
|
|
1304
1391
|
}
|
|
1305
1392
|
|
|
1393
|
+
Log.d(TAG, " 🔄 Calling SdkeSign.confirmSign()")
|
|
1306
1394
|
SdkeSign.confirmSign(
|
|
1307
1395
|
context = currentActivity,
|
|
1308
1396
|
signRequestId = signRequestId,
|
|
@@ -1311,7 +1399,8 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1311
1399
|
authData = authData ?: "",
|
|
1312
1400
|
confirm = confirm,
|
|
1313
1401
|
callbackSuccess = { code, message ->
|
|
1314
|
-
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ý
|
|
1315
1404
|
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
1316
1405
|
map.putString("code", code.toString())
|
|
1317
1406
|
map.putString("message", message)
|
|
@@ -1320,69 +1409,47 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1320
1409
|
promise.resolve(promiseMap)
|
|
1321
1410
|
},
|
|
1322
1411
|
callbackError = { event, error ->
|
|
1323
|
-
|
|
1324
|
-
val
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
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)
|
|
1328
1435
|
}
|
|
1329
|
-
sendEvent("onESignError", errorMap)
|
|
1330
|
-
promise.reject(event.name.toString(), error.message)
|
|
1331
1436
|
}
|
|
1332
1437
|
)
|
|
1333
1438
|
} catch (e: Exception) {
|
|
1334
|
-
Log.e(TAG, "❌ confirmSign() exception: ${e.message}", e)
|
|
1335
1439
|
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1336
1440
|
}
|
|
1337
1441
|
}
|
|
1338
1442
|
|
|
1339
|
-
|
|
1340
|
-
fun authenticate(
|
|
1341
|
-
username: String,
|
|
1342
|
-
password: String,
|
|
1343
|
-
promise: Promise
|
|
1344
|
-
) {
|
|
1345
|
-
Log.d(TAG, "▶️ authenticate() called")
|
|
1346
|
-
try {
|
|
1347
|
-
SdkeSign.authenticate(
|
|
1348
|
-
username = username,
|
|
1349
|
-
password = password,
|
|
1350
|
-
callbackSuccess = { token, userId ->
|
|
1351
|
-
Log.d(TAG, "✅ authenticate() success")
|
|
1352
|
-
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
1353
|
-
map.putString("token", token)
|
|
1354
|
-
map.putString("userId", userId.toString())
|
|
1355
|
-
}
|
|
1356
|
-
sendEvent("onESignAuthenticateSuccess", eventMap)
|
|
1357
|
-
promise.resolve(promiseMap)
|
|
1358
|
-
},
|
|
1359
|
-
callbackError = { event, error ->
|
|
1360
|
-
Log.e(TAG, "❌ authenticate() failed - Event: $event, Message: ${error.message}")
|
|
1361
|
-
val errorMap = Arguments.createMap().apply {
|
|
1362
|
-
putString("event", event.name.toString())
|
|
1363
|
-
putString("message", error.message)
|
|
1364
|
-
putString("code", error.code)
|
|
1365
|
-
}
|
|
1366
|
-
sendEvent("onESignError", errorMap)
|
|
1367
|
-
promise.reject(event.name.toString(), error.message)
|
|
1368
|
-
}
|
|
1369
|
-
)
|
|
1370
|
-
} catch (e: Exception) {
|
|
1371
|
-
Log.e(TAG, "❌ authenticate() exception: ${e.message}", e)
|
|
1372
|
-
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1443
|
+
|
|
1375
1444
|
|
|
1376
1445
|
@ReactMethod
|
|
1377
1446
|
fun registerRemoteSigning(
|
|
1378
|
-
accessToken: String,
|
|
1379
1447
|
requestJson: String,
|
|
1380
1448
|
promise: Promise
|
|
1381
1449
|
) {
|
|
1382
1450
|
Log.d(TAG, "▶️ registerRemoteSigning() called")
|
|
1383
1451
|
try {
|
|
1384
1452
|
SdkeSign.registerRemoteSigning(
|
|
1385
|
-
accessToken = accessToken,
|
|
1386
1453
|
requestJson = requestJson,
|
|
1387
1454
|
callbackSuccess = { rawResponse ->
|
|
1388
1455
|
Log.d(TAG, "✅ registerRemoteSigning() success")
|
|
@@ -1393,14 +1460,28 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1393
1460
|
promise.resolve(promiseMap)
|
|
1394
1461
|
},
|
|
1395
1462
|
callbackError = { event, error ->
|
|
1396
|
-
|
|
1397
|
-
val
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
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)
|
|
1401
1484
|
}
|
|
1402
|
-
sendEvent("onESignError", errorMap)
|
|
1403
|
-
promise.reject(event.name.toString(), error.message)
|
|
1404
1485
|
}
|
|
1405
1486
|
)
|
|
1406
1487
|
} catch (e: Exception) {
|
|
@@ -1411,17 +1492,15 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1411
1492
|
|
|
1412
1493
|
@ReactMethod
|
|
1413
1494
|
fun signPdf(
|
|
1414
|
-
accessToken: String,
|
|
1415
1495
|
requestJson: String,
|
|
1416
1496
|
promise: Promise
|
|
1417
1497
|
) {
|
|
1418
1498
|
Log.d(TAG, "▶️ signPdf() called")
|
|
1419
1499
|
try {
|
|
1420
1500
|
SdkeSign.signPdf(
|
|
1421
|
-
accessToken = accessToken,
|
|
1422
1501
|
requestJson = requestJson,
|
|
1423
1502
|
callbackSuccess = { rawResponse ->
|
|
1424
|
-
|
|
1503
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1425
1504
|
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
1426
1505
|
map.putString("response", rawResponse)
|
|
1427
1506
|
}
|
|
@@ -1429,35 +1508,45 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1429
1508
|
promise.resolve(promiseMap)
|
|
1430
1509
|
},
|
|
1431
1510
|
callbackError = { event, error ->
|
|
1432
|
-
|
|
1433
|
-
val
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
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)
|
|
1437
1531
|
}
|
|
1438
|
-
sendEvent("onESignError", errorMap)
|
|
1439
|
-
promise.reject(event.name.toString(), error.message)
|
|
1440
1532
|
}
|
|
1441
1533
|
)
|
|
1442
1534
|
} catch (e: Exception) {
|
|
1443
|
-
Log.e(TAG, "❌ signPdf() exception: ${e.message}", e)
|
|
1444
1535
|
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1445
1536
|
}
|
|
1446
1537
|
}
|
|
1447
1538
|
|
|
1448
1539
|
@ReactMethod
|
|
1449
1540
|
fun sendConfirmationDocument(
|
|
1450
|
-
accessToken: String,
|
|
1451
1541
|
requestJson: String,
|
|
1452
1542
|
promise: Promise
|
|
1453
1543
|
) {
|
|
1454
1544
|
Log.d(TAG, "▶️ sendConfirmationDocument() called")
|
|
1455
1545
|
try {
|
|
1456
1546
|
SdkeSign.sendConfirmationDocument(
|
|
1457
|
-
accessToken = accessToken,
|
|
1458
1547
|
requestJson = requestJson,
|
|
1459
1548
|
callbackSuccess = { rawResponse ->
|
|
1460
|
-
|
|
1549
|
+
// Bắn raw data lên - để EKYCModule.ts xử lý
|
|
1461
1550
|
val (eventMap, promiseMap) = createSeparateMaps { map ->
|
|
1462
1551
|
map.putString("response", rawResponse)
|
|
1463
1552
|
}
|
|
@@ -1465,18 +1554,30 @@ class EKYCModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMo
|
|
|
1465
1554
|
promise.resolve(promiseMap)
|
|
1466
1555
|
},
|
|
1467
1556
|
callbackError = { event, error ->
|
|
1468
|
-
|
|
1469
|
-
val
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
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)
|
|
1473
1577
|
}
|
|
1474
|
-
sendEvent("onESignError", errorMap)
|
|
1475
|
-
promise.reject(event.name.toString(), error.message)
|
|
1476
1578
|
}
|
|
1477
1579
|
)
|
|
1478
1580
|
} catch (e: Exception) {
|
|
1479
|
-
Log.e(TAG, "❌ sendConfirmationDocument() exception: ${e.message}", e)
|
|
1480
1581
|
promise.reject("ESIGN_EXCEPTION", e.message, e)
|
|
1481
1582
|
}
|
|
1482
1583
|
}
|