accurascan_kyc 1.3.0 → 1.3.2

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.
@@ -23,7 +23,7 @@ Pod::Spec.new do |s|
23
23
  s.static_framework = true
24
24
  # s.dependency "AccuraKYC","4.0.2"
25
25
  # s.dependency "AccuraKYC","4.0.4"
26
- s.dependency 'AccuraKYC_Sim', '4.0.9'
26
+ s.dependency 'AccuraKYC', '4.1.1-KYC'
27
27
  # Don't install the dependencies when we run `pod install` in the old architecture.
28
28
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
29
29
  s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
@@ -100,11 +100,11 @@ dependencies {
100
100
  implementation 'androidx.appcompat:appcompat:1.6.0'
101
101
  implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
102
102
  // Update OCR
103
- implementation 'com.github.accurascan:AccuraOCR:6.1.3'
103
+ implementation 'com.github.accurascan:AccuraOCR:6.1.6'
104
104
  // FaceMatch has no issue
105
105
  implementation 'com.github.accurascan:AccuraFaceMatch:3.2.5'
106
106
  // Update Liveness
107
- implementation 'com.github.accurascan:Liveness-Android:3.3.1.1'
107
+ implementation 'com.github.accurascan:Liveness-Android:3.4.1'
108
108
  implementation 'com.squareup.picasso:picasso:2.71828'
109
109
  }
110
110
 
@@ -121,6 +121,23 @@ public class AccurascanKycModule extends ReactContextBaseJavaModule {
121
121
  return "file://"+file.getAbsolutePath();
122
122
  }
123
123
 
124
+ // Conversion Method from JSONObject to Map<String, String>
125
+ public static Map<String, String> jsonToMap(JSONObject jsonObj) {
126
+ Map<String, String> map = new HashMap<>();
127
+ Iterator<String> keys = jsonObj.keys();
128
+
129
+ while (keys.hasNext()) {
130
+ String key = keys.next();
131
+ try {
132
+ map.put(key, jsonObj.getString(key));
133
+ } catch (JSONException e) {
134
+ e.printStackTrace();
135
+ }
136
+ }
137
+
138
+ return map;
139
+ }
140
+
124
141
  // Example method
125
142
  // See https://reactnative.dev/docs/native-modules-android
126
143
  @ReactMethod
@@ -416,6 +433,29 @@ public class AccurascanKycModule extends ReactContextBaseJavaModule {
416
433
  recogEngine.setBlurPercentage(getCurrentActivity(), 62);
417
434
  }
418
435
 
436
+ if (accuraConfigs.has("setIsDocEnable")){
437
+ OcrActivity.isDocLiveness = accuraConfigs.getBoolean("setIsDocEnable");
438
+ };
439
+ if (accuraConfigs.has("setDocUrl")){
440
+ OcrActivity.DocumentLivenessUrl = accuraConfigs.getString("setDocUrl");
441
+ };
442
+ if (accuraConfigs.has("setProgressMessage")){
443
+ OcrActivity.setProgressMessage = accuraConfigs.getString("setProgressMessage");
444
+ };
445
+ if (accuraConfigs.has("setHideProgressDialogue")){
446
+ OcrActivity.setHideProgressDialogue = accuraConfigs.getBoolean("setHideProgressDialogue");
447
+ };
448
+ if (accuraConfigs.has("setHeader")) {
449
+ JSONObject jsonHeader = accuraConfigs.optJSONObject("setHeader");
450
+ if (jsonHeader != null) {
451
+ OcrActivity.DocHeader = jsonToMap(jsonHeader);
452
+ }
453
+ }
454
+ if (accuraConfigs.has("setApiTimer")){
455
+ OcrActivity.setApiTimer = accuraConfigs.getInt("setApiTimer");
456
+ };
457
+
458
+
419
459
  // recogEngine.isCheckPhotoCopy(getCurrentActivity(),accuraConfigs.getBoolean("isCheckPhotoCopy"));
420
460
  result.invoke(null, "Configs setup sucessfully");
421
461
  return true;
@@ -2,6 +2,7 @@ package com.accurascankyc;
2
2
 
3
3
  import android.app.Activity;
4
4
  import android.app.Dialog;
5
+ import android.app.ProgressDialog;
5
6
  import android.content.Intent;
6
7
  import android.content.pm.ActivityInfo;
7
8
  import android.content.res.Resources;
@@ -56,7 +57,9 @@ import java.io.OutputStream;
56
57
  import java.lang.ref.WeakReference;
57
58
  import java.security.cert.CertificateException;
58
59
  import java.util.Arrays;
60
+ import java.util.HashMap;
59
61
  import java.util.List;
62
+ import java.util.Map;
60
63
 
61
64
  import javax.net.ssl.HostnameVerifier;
62
65
  import javax.net.ssl.SSLContext;
@@ -90,6 +93,15 @@ public class OcrActivity extends SensorsActivity implements OcrCallback {
90
93
  private Bitmap frame;
91
94
  private static Activity appActivity = null;
92
95
 
96
+ public static String DocumentLivenessUrl = "";
97
+ public static String setProgressMessage = "API Loading...";
98
+ public static boolean isDocLiveness = false;
99
+ public static Map<String,String> DocHeader = new HashMap<>();
100
+ public static int setApiTimer = 60;
101
+ public static boolean setHideProgressDialogue = true;
102
+ private ProgressDialog pd;
103
+ private boolean isBacksideAvail = false;
104
+
93
105
  private static class MyHandler extends Handler {
94
106
 
95
107
  private final WeakReference<OcrActivity> mActivity;
@@ -224,6 +236,12 @@ public class OcrActivity extends SensorsActivity implements OcrCallback {
224
236
  cameraView.setMRZCountryCodeList("all");
225
237
  }
226
238
 
239
+ cameraView
240
+ .enableDocLiveness(isDocLiveness)
241
+ .setServerUrl(DocumentLivenessUrl)
242
+ .setMaxTimeLimitInSeconds(setApiTimer)
243
+ .addApiHeaders(DocHeader);
244
+
227
245
  cameraView.setRecogType(recogType)
228
246
  .setView(linearLayout) // To add camera view
229
247
  .setOcrCallback(this) // To get Update and Success Call back
@@ -599,7 +617,7 @@ public class OcrActivity extends SensorsActivity implements OcrCallback {
599
617
  backUri = null;
600
618
  recogResult = RecogResult.getRecogResult();
601
619
  if (recogResult != null) {
602
- mrzResult = setMRZData(recogResult);
620
+ // mrzResult = setMRZData(recogResult);
603
621
  if (recogResult.faceBitmap != null) {
604
622
  faceUri = AccurascanKycModule.getImageUri(recogResult.faceBitmap, "face", fileDir);
605
623
  }
@@ -611,6 +629,13 @@ public class OcrActivity extends SensorsActivity implements OcrCallback {
611
629
  }
612
630
  }
613
631
 
632
+ if (backUri != null){
633
+ isBacksideAvail = true;
634
+ }else{
635
+ isBacksideAvail = false;
636
+ }
637
+ mrzResult = setMRZData(recogResult);
638
+
614
639
  } else if (recogType == RecogType.BANKCARD) {
615
640
  faceUri = null;
616
641
  frontUri = null;
@@ -745,6 +770,13 @@ public class OcrActivity extends SensorsActivity implements OcrCallback {
745
770
  OcrData.MapData frontData = data.getFrontData();
746
771
  OcrData.MapData backData = data.getBackData();
747
772
  if (frontData != null) {
773
+ if(isDocLiveness){
774
+ try {
775
+ frontResult.put("Document Liveness", frontData.docLiveness);
776
+ } catch (JSONException e) {
777
+ e.printStackTrace(); // Handle the exception here (e.g., log the error or notify the user)
778
+ }
779
+ }
748
780
  List<OcrData.MapData.ScannedData> frontScanData = frontData.getOcr_data();
749
781
  for (int i = 0; i < frontScanData.size(); i++) {
750
782
  if (frontScanData.get(i).getKey() != null) {
@@ -769,6 +801,13 @@ public class OcrActivity extends SensorsActivity implements OcrCallback {
769
801
  }
770
802
  }
771
803
  if (backData != null) {
804
+ if(isDocLiveness){
805
+ try {
806
+ backResult.put("Document Liveness", backData.docLiveness);
807
+ } catch (JSONException e) {
808
+ e.printStackTrace(); // Handle the exception here (e.g., log the error or notify the user)
809
+ }
810
+ }
772
811
  List<OcrData.MapData.ScannedData> backScanData = backData.getOcr_data();
773
812
  for (int i = 0; i < backScanData.size(); i++) {
774
813
  if (backScanData.get(i).getKey() != null) {
@@ -1230,6 +1269,45 @@ public class OcrActivity extends SensorsActivity implements OcrCallback {
1230
1269
  }
1231
1270
  }
1232
1271
 
1272
+ @Override
1273
+ public void onAPIUpdate(int i, String s) {
1274
+ Runnable runnable = () -> {
1275
+ if (i == RecogEngine.ACCURA_API_DISPLAY_PROGRESS) {
1276
+ // Display your custom progress dialog
1277
+ if (pd == null) {
1278
+ pd = new ProgressDialog(OcrActivity.this);
1279
+ pd.setCancelable(false);
1280
+ pd.setCanceledOnTouchOutside(false);
1281
+ pd.setMessage(setProgressMessage);
1282
+ }
1283
+ try {
1284
+ // If setHideProgressDialogue is true, hide the progress dialog immediately
1285
+ if (setHideProgressDialogue) {
1286
+ if (pd.isShowing()) {
1287
+ pd.dismiss();
1288
+ }
1289
+ } else {
1290
+ // Otherwise, show or hide based on the value of `s`
1291
+ if (s.equals("Show") && !pd.isShowing()) {
1292
+ Message _message = new Message();
1293
+ _message.what = 1;
1294
+ _message.obj = "Please wait...";
1295
+ handler.sendMessage(_message);
1296
+ pd.show();
1297
+ } else if (s.equals("Hide") && pd.isShowing()) {
1298
+ pd.dismiss();
1299
+ }
1300
+ }
1301
+ } catch (Exception e) {
1302
+ e.printStackTrace();
1303
+ }
1304
+ } else if (i == RecogEngine.ACCURA_API_ERROR) {
1305
+ Toast.makeText(OcrActivity.this, "Api Error is" + s, Toast.LENGTH_LONG).show();
1306
+ }
1307
+ };
1308
+ runOnUiThread(runnable);
1309
+ }
1310
+
1233
1311
  /**
1234
1312
  * Set Barcode selection Dialog to Scan only selected barcode format
1235
1313
  * See {@link BarcodeFormat} to get All Barcode format
@@ -1285,6 +1363,15 @@ public class OcrActivity extends SensorsActivity implements OcrCallback {
1285
1363
  JSONObject frontResult = new JSONObject();
1286
1364
  try {
1287
1365
  frontResult.put("MRZ", recogResult.lines);
1366
+
1367
+ if(isDocLiveness && recogType == RecogType.MRZ){
1368
+ frontResult.put("Document Liveness Front", recogResult.docfrontliveness);
1369
+
1370
+ if(recogResult.docbackliveness != null && isBacksideAvail){
1371
+ frontResult.put("Document Liveness Back", recogResult.docbackliveness);
1372
+ }
1373
+ }
1374
+
1288
1375
  frontResult.put("Document Type", recogResult.docType);
1289
1376
  frontResult.put("First Name", recogResult.givenname);
1290
1377
  frontResult.put("First Name", recogResult.givenname);
@@ -407,15 +407,15 @@ public class OcrResultActivity extends Activity implements FaceCallback {
407
407
  }else {
408
408
  livenessCustomization.setLowLightTolerence(-1/*lowLightTolerence*/);
409
409
  }
410
- if (livenessConfig.has("setApiKey")){
411
- try {
412
- livenessCustomization.setApiKey(livenessConfig.getString("setApiKey"));
413
- } catch (JSONException e) {
414
- e.printStackTrace();
415
- }
416
- }else {
417
- livenessCustomization.setApiKey("");
418
- }
410
+ // if (livenessConfig.has("setApiKey")){
411
+ //// try {
412
+ //// livenessCustomization.setApiKey(livenessConfig.getString("setApiKey"));
413
+ //// } catch (JSONException e) {
414
+ //// e.printStackTrace();
415
+ //// }
416
+ //// }else {
417
+ //// livenessCustomization.setApiKey("");
418
+ //// }
419
419
  if (livenessConfig.has("setfeedbackDialogMessage")){
420
420
  try {
421
421
  livenessCustomization.feedbackDialogMessage = livenessConfig.getString("setfeedbackDialogMessage");
@@ -391,6 +391,44 @@ class AccurascanKyc: NSObject {
391
391
  }else{
392
392
  self.accuraCameraWrapper?.setCameraFacing(.CAMERA_FACING_BACK)
393
393
  }
394
+
395
+
396
+ if configs["setIsDocEnable"] != nil {
397
+ let val = (configs["setIsDocEnable"] as? Bool)!
398
+ self.accuraCameraWrapper?.isApiCallingEnable(val)
399
+ }else{
400
+ self.accuraCameraWrapper?.isApiCallingEnable(false)
401
+ }
402
+
403
+ if configs["setDocUrl"] != nil {
404
+ let val = (configs["setDocUrl"] as? String)!
405
+ self.accuraCameraWrapper?.apiurl(val)
406
+ }
407
+
408
+ if configs["setProgressMessage"] != nil {
409
+ let val = (configs["setProgressMessage"] as? String)
410
+ self.accuraCameraWrapper?.setProgressDialogue(val)
411
+ } else{
412
+ self.accuraCameraWrapper?.setProgressDialogue("API Calling...")
413
+ }
414
+
415
+ if configs["setHideProgressDialogue"] != nil {
416
+ let val = (configs["setHideProgressDialogue"] as? Bool)!
417
+ self.accuraCameraWrapper?.hideProgressDialogue(val)
418
+ }
419
+
420
+
421
+ if configs["setApiTimer"] != nil {
422
+ let val = (configs["setApiTimer"] as? Int32)!
423
+ self.accuraCameraWrapper?.apiTimer(Float(val))
424
+ }else{
425
+ self.accuraCameraWrapper?.apiTimer(100.0)
426
+ }
427
+
428
+ if configs["setHeader"] != nil {
429
+ let val = (configs["setHeader"] as? [String: String])!
430
+ self.accuraCameraWrapper?.apiheader((val))
431
+ }
394
432
  // if accuraconfigs["enableLogs"] != nil {
395
433
  // if accuraconfigs["enableLogs"] as? Int == 0 {
396
434
  // accuraCameraWrapper?.showLogFile(true)
@@ -317,7 +317,7 @@ class ViewController: UIViewController {
317
317
  shortTap.numberOfTouchesRequired = 1
318
318
  self.view.addGestureRecognizer(shortTap)
319
319
  } else if status == .denied {
320
- let alert = UIAlertController(title: "AccuraSdk", message: "It looks like your privacy settings are preventing us from accessing your camera.", preferredStyle: .alert)
320
+ let alert = UIAlertController(title: "Alert!", message: "It looks like your privacy settings are preventing us from accessing your camera.", preferredStyle: .alert)
321
321
  let yesButton = UIAlertAction(title: "OK", style: .default) { _ in
322
322
  if #available(iOS 10.0, *) {
323
323
  UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [:], completionHandler: nil)
@@ -326,7 +326,7 @@ class ViewController: UIViewController {
326
326
  }
327
327
  }
328
328
  alert.addAction(yesButton)
329
- self.present(alert, animated: true, completion: nil)
329
+ self.getTopMostViewController()?.present(alert, animated: true, completion: nil)
330
330
  } else if status == .restricted {
331
331
  } else if status == .notDetermined {
332
332
  AVCaptureDevice.requestAccess(for: .video) { granted in
@@ -485,6 +485,16 @@ class ViewController: UIViewController {
485
485
  self.dismiss(animated: true)
486
486
  }
487
487
 
488
+ func getTopMostViewController() -> UIViewController? {
489
+ var topMostViewController = UIApplication.shared.keyWindow?.rootViewController
490
+
491
+ while let presentedViewController = topMostViewController?.presentedViewController {
492
+ topMostViewController = presentedViewController
493
+ }
494
+
495
+ return topMostViewController
496
+ }
497
+
488
498
  @objc private func ChangedOrientation() {
489
499
  var width: CGFloat = 0.0
490
500
  var height: CGFloat = 0.0
@@ -1877,6 +1887,10 @@ class ViewController: UIViewController {
1877
1887
  }
1878
1888
 
1879
1889
  extension ViewController: VideoCameraWrapperDelegate {
1890
+
1891
+ func onAPIError(_ error: String!) {
1892
+ print(error ?? "")
1893
+ }
1880
1894
 
1881
1895
  func isBothSideAvailable(_ isBothAvailable: Bool) {
1882
1896
  isbothSideAvailable = isBothAvailable
@@ -2635,6 +2649,14 @@ extension ViewController: VideoCameraWrapperDelegate {
2635
2649
  mrzData["MRZ"] = line
2636
2650
 
2637
2651
  }
2652
+
2653
+ if let docLivenessFront = shareScanningListing["Document Liveness"] as? String {
2654
+ mrzData["Document Liveness Front"] = docLivenessFront
2655
+ }
2656
+ if let docLivenessBack = shareScanningListing["Document Back Liveness"] as? String {
2657
+ mrzData["Document Liveness Back"] = docLivenessBack
2658
+ }
2659
+
2638
2660
  if let givenname = shareScanningListing["givenname"] as? String {
2639
2661
  mrzData["First Name"] = givenname
2640
2662
  } else if let givenname = shareScanningListing["givenNames"] as? String {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "accurascan_kyc",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Accura Scan",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",