@regulaforensics/react-native-document-reader-api 6.7.0 → 6.7.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.
@@ -63,6 +63,8 @@ class Helpers {
63
63
  }
64
64
 
65
65
  static String bitmapToBase64String(Bitmap bitmap) {
66
+ if(bitmap == null) return null;
67
+
66
68
  ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
67
69
  bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
68
70
  byte[] byteArray = byteArrayOutputStream.toByteArray();
@@ -149,6 +149,14 @@ class JSONConstructor {
149
149
  return result;
150
150
  }
151
151
 
152
+ static int[] intArrayFromJSON(JSONArray input) throws JSONException {
153
+ int[] result = new int[input.length()];
154
+ for (int i = 0; i < input.length(); i++)
155
+ result[i] = input.getInt(i);
156
+
157
+ return result;
158
+ }
159
+
152
160
  static JSONArray generateByteArray(byte[] array) throws JSONException {
153
161
  JSONArray result = new JSONArray();
154
162
  if (array == null) return result;
@@ -186,18 +194,18 @@ class JSONConstructor {
186
194
  try {
187
195
  result.put("action", action);
188
196
  switch (action) {
189
- case DocReaderAction.PROCESS:
190
- case DocReaderAction.PROCESS_WHITE_UV_IMAGES:
191
- break;
192
- case DocReaderAction.NOTIFICATION:
193
- result.put("results", generateDocumentReaderResultsNotification(results));
194
- break;
195
197
  case DocReaderAction.COMPLETE:
196
198
  case DocReaderAction.MORE_PAGES_AVAILABLE:
197
199
  case DocReaderAction.CANCEL:
198
200
  case DocReaderAction.ERROR:
201
+ case DocReaderAction.TIMEOUT:
199
202
  result.put("results", generateDocumentReaderResults(results, context));
200
203
  break;
204
+ case DocReaderAction.NOTIFICATION:
205
+ result.put("results", generateDocumentReaderResultsNotification(results));
206
+ break;
207
+ default:
208
+ break;
201
209
  }
202
210
  if (error != null)
203
211
  result.put("error", generateDocumentReaderException(error));
@@ -470,6 +478,8 @@ class JSONConstructor {
470
478
  result.put("values", generateList(input.values, JSONConstructor::generateDocumentReaderValue, context));
471
479
  result.put("comparisonList", generateList(input.comparisonList, JSONConstructor::generateDocumentReaderComparison));
472
480
  result.put("validityList", generateList(input.validityList, JSONConstructor::generateDocumentReaderValidity));
481
+ result.put("comparisonStatus", input.comparisonStatus);
482
+ result.put("validityStatus", input.validityStatus);
473
483
  } catch (JSONException e) {
474
484
  e.printStackTrace();
475
485
  }
@@ -581,9 +591,11 @@ class JSONConstructor {
581
591
  JSONObject result = new JSONObject();
582
592
  if (input == null) return null;
583
593
  try {
584
- result.put("code", input.getNotificationCode());
585
- result.put("attachment", input.getDataFileType());
586
- result.put("value", input.getProgress());
594
+ result.put("code", input.code);
595
+ result.put("value", input.value);
596
+ result.put("notificationCode", input.getNotificationCode());
597
+ result.put("dataFileType", input.getDataFileType());
598
+ result.put("progress", input.getProgress());
587
599
  } catch (JSONException e) {
588
600
  e.printStackTrace();
589
601
  }
@@ -1150,7 +1162,9 @@ class JSONConstructor {
1150
1162
  JSONObject result = new JSONObject();
1151
1163
  if (input == null) return null;
1152
1164
  try {
1165
+ result.put("videoCaptureSessionId", input.videoCaptureSessionId);
1153
1166
  result.put("chipPage", input.chipPage);
1167
+ result.put("irElapsedTime", input.irElapsedTime);
1154
1168
  result.put("processingFinishedStatus", input.processingFinishedStatus);
1155
1169
  result.put("elapsedTime", input.elapsedTime);
1156
1170
  result.put("elapsedTimeRFID", input.elapsedTimeRFID);
@@ -1168,6 +1182,7 @@ class JSONConstructor {
1168
1182
  result.put("rfidSessionData", generateRFIDSessionData(input.rfidSessionData));
1169
1183
  result.put("authenticityResult", generateDocumentReaderAuthenticityResult(input.authenticityResult, context));
1170
1184
  result.put("barcodeResult", generateDocumentReaderBarcodeResult(input.barcodeResult));
1185
+ result.put("ppmIn", input.ppmIn);
1171
1186
  result.put("documentType", generateList(input.documentType, JSONConstructor::generateDocumentReaderDocumentType));
1172
1187
  result.put("status", generateDocumentReaderResultsStatus(input.status));
1173
1188
  result.put("vdsncData", generateVDSNCData(input.vdsncData));
@@ -9,6 +9,7 @@ import android.content.IntentFilter;
9
9
  import android.graphics.Bitmap;
10
10
  import android.nfc.NfcAdapter;
11
11
  import android.nfc.tech.IsoDep;
12
+ import android.os.Build;
12
13
  import android.os.Bundle;
13
14
  import android.util.Base64;
14
15
 
@@ -40,7 +41,9 @@ import com.regula.documentreader.api.internal.params.ImageInputParam;
40
41
  import com.regula.documentreader.api.params.rfid.PKDCertificate;
41
42
  import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer;
42
43
  import com.regula.documentreader.api.params.rfid.authorization.TAChallenge;
44
+ import com.regula.documentreader.api.results.DocumentReaderGraphicField;
43
45
  import com.regula.documentreader.api.results.DocumentReaderResults;
46
+ import com.regula.documentreader.api.results.DocumentReaderTextField;
44
47
  import com.regula.documentreader.api.internal.parser.DocReaderResultsJsonParser;
45
48
 
46
49
  import org.json.JSONArray;
@@ -127,7 +130,17 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
127
130
  public void onHostDestroy() {
128
131
  }
129
132
 
133
+ @SuppressWarnings({"WrapperTypeMayBePrimitive", "unchecked"})
130
134
  private <T> T args(int index) throws JSONException {
135
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
136
+ // Rewrite it according to react native documentation!!!
137
+ // the is no int or double in js so all ints are sent as double by default
138
+ Object value = data.get(index);
139
+ if (value instanceof Double)
140
+ if ((Double) value % 1 == 0) {
141
+ Integer intValue = ((Double) value).intValue();
142
+ return (T) intValue;
143
+ }
131
144
  //noinspection unchecked
132
145
  return (T) data.get(index);
133
146
  }
@@ -414,6 +427,57 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
414
427
  case "recognizeImagesWithImageInputs":
415
428
  recognizeImagesWithImageInputs(callback, args(0));
416
429
  break;
430
+ case "textFieldValueByType":
431
+ textFieldValueByType(callback, args(0), args(1));
432
+ break;
433
+ case "textFieldValueByTypeLcid":
434
+ textFieldValueByTypeLcid(callback, args(0), args(1), args(2));
435
+ break;
436
+ case "textFieldValueByTypeSource":
437
+ textFieldValueByTypeSource(callback, args(0), args(1), args(2));
438
+ break;
439
+ case "textFieldValueByTypeLcidSource":
440
+ textFieldValueByTypeLcidSource(callback, args(0), args(1), args(2), args(3));
441
+ break;
442
+ case "textFieldValueByTypeSourceOriginal":
443
+ textFieldValueByTypeSourceOriginal(callback, args(0), args(1), args(2), args(3));
444
+ break;
445
+ case "textFieldValueByTypeLcidSourceOriginal":
446
+ textFieldValueByTypeLcidSourceOriginal(callback, args(0), args(1), args(2), args(3), args(4));
447
+ break;
448
+ case "textFieldByType":
449
+ textFieldByType(callback, args(0), args(1));
450
+ break;
451
+ case "textFieldByTypeLcid":
452
+ textFieldByTypeLcid(callback, args(0), args(1), args(2));
453
+ break;
454
+ case "graphicFieldByTypeSource":
455
+ graphicFieldByTypeSource(callback, args(0), args(1), args(2));
456
+ break;
457
+ case "graphicFieldByTypeSourcePageIndex":
458
+ graphicFieldByTypeSourcePageIndex(callback, args(0), args(1), args(2), args(3));
459
+ break;
460
+ case "graphicFieldByTypeSourcePageIndexLight":
461
+ graphicFieldByTypeSourcePageIndexLight(callback, args(0), args(1), args(2), args(3), args(4));
462
+ break;
463
+ case "graphicFieldImageByType":
464
+ graphicFieldImageByType(callback, args(0), args(1));
465
+ break;
466
+ case "graphicFieldImageByTypeSource":
467
+ graphicFieldImageByTypeSource(callback, args(0), args(1), args(2));
468
+ break;
469
+ case "graphicFieldImageByTypeSourcePageIndex":
470
+ graphicFieldImageByTypeSourcePageIndex(callback, args(0), args(1), args(2), args(3));
471
+ break;
472
+ case "graphicFieldImageByTypeSourcePageIndexLight":
473
+ graphicFieldImageByTypeSourcePageIndexLight(callback, args(0), args(1), args(2), args(3), args(4));
474
+ break;
475
+ case "containers":
476
+ containers(callback, args(0), args(1));
477
+ break;
478
+ case "encryptedContainers":
479
+ encryptedContainers(callback, args(0));
480
+ break;
417
481
  }
418
482
  } catch (Exception e) {
419
483
  e.printStackTrace();
@@ -430,8 +494,10 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
430
494
  };
431
495
  Intent intent = new Intent(activity.getApplicationContext(), activity.getClass());
432
496
  intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
433
- @SuppressLint("UnspecifiedImmutableFlag")
434
- PendingIntent pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, intent, 0);
497
+ int flags = 0;
498
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
499
+ flags = PendingIntent.FLAG_IMMUTABLE;
500
+ PendingIntent pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, intent, flags);
435
501
  NfcAdapter.getDefaultAdapter(getActivity()).enableForegroundDispatch(activity, pendingIntent, filters, techList);
436
502
  }
437
503
 
@@ -482,6 +548,7 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
482
548
  callback.success();
483
549
  }
484
550
 
551
+ @SuppressLint("MissingPermission")
485
552
  private void initializeReaderBleDeviceConfig(Callback callback) {
486
553
  if (BluetoothUtil.Companion.getBleManager() == null) callback.error("bleManager is null");
487
554
  if (!Instance().isReady())
@@ -794,15 +861,126 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
794
861
  callback.success();
795
862
  }
796
863
 
797
- private void setCameraSessionIsPaused(Callback callback, @SuppressWarnings("unused") boolean ignored) {
798
- callback.error("setCameraSessionIsPaused() is an ios-only method");
799
- }
800
-
801
864
  private void setRfidDelegate(Callback callback, int delegate) {
802
865
  rfidDelegate = delegate;
803
866
  callback.success();
804
867
  }
805
868
 
869
+ private void textFieldValueByType(Callback callback, String raw, int fieldType) {
870
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
871
+ callback.success(results.getTextFieldValueByType(fieldType));
872
+ }
873
+
874
+ private void textFieldValueByTypeLcid(Callback callback, String raw, int fieldType, int lcid) {
875
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
876
+ callback.success(results.getTextFieldValueByType(fieldType, lcid));
877
+ }
878
+
879
+ private void textFieldValueByTypeSource(Callback callback, String raw, int fieldType, int source) {
880
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
881
+ callback.success(results.getTextFieldValueByTypeAndSource(fieldType, source));
882
+ }
883
+
884
+ private void textFieldValueByTypeLcidSource(Callback callback, String raw, int fieldType, int lcid, int source) {
885
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
886
+ callback.success(results.getTextFieldValueByType(fieldType, lcid, source));
887
+ }
888
+
889
+ private void textFieldValueByTypeSourceOriginal(Callback callback, String raw, int fieldType, int source, boolean original) {
890
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
891
+ callback.success(results.getTextFieldValueByTypeAndSource(fieldType, source, original));
892
+ }
893
+
894
+ private void textFieldValueByTypeLcidSourceOriginal(Callback callback, String raw, int fieldType, int lcid, int source, boolean original) {
895
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
896
+ callback.success(results.getTextFieldValueByType(fieldType, lcid, source, original));
897
+ }
898
+
899
+ private void textFieldByType(Callback callback, String raw, int fieldType) {
900
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
901
+ DocumentReaderTextField result = results.getTextFieldByType(fieldType);
902
+ if (result == null)
903
+ callback.success(null);
904
+ else
905
+ callback.success(JSONConstructor.generateDocumentReaderTextField(result, getContext()).toString());
906
+ }
907
+
908
+ private void textFieldByTypeLcid(Callback callback, String raw, int fieldType, int lcid) {
909
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
910
+ DocumentReaderTextField result = results.getTextFieldByType(fieldType, lcid);
911
+ if (result == null)
912
+ callback.success(null);
913
+ else
914
+ callback.success(JSONConstructor.generateDocumentReaderTextField(result, getContext()).toString());
915
+ }
916
+
917
+ private void graphicFieldByTypeSource(Callback callback, String raw, int fieldType, int source) {
918
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
919
+ DocumentReaderGraphicField result = results.getGraphicFieldByType(fieldType, source);
920
+ if (result == null)
921
+ callback.success(null);
922
+ else
923
+ callback.success(JSONConstructor.generateDocumentReaderGraphicField(result, getContext()).toString());
924
+ }
925
+
926
+ private void graphicFieldByTypeSourcePageIndex(Callback callback, String raw, int fieldType, int source, int pageIndex) {
927
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
928
+ DocumentReaderGraphicField result = results.getGraphicFieldByType(fieldType, source, pageIndex);
929
+ if (result == null)
930
+ callback.success(null);
931
+ else
932
+ callback.success(JSONConstructor.generateDocumentReaderGraphicField(result, getContext()).toString());
933
+ }
934
+
935
+ private void graphicFieldByTypeSourcePageIndexLight(Callback callback, String raw, int fieldType, int source, int pageIndex, int light) {
936
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
937
+ DocumentReaderGraphicField result = results.getGraphicFieldByType(fieldType, source, pageIndex, light);
938
+ if (result == null)
939
+ callback.success(null);
940
+ else
941
+ callback.success(JSONConstructor.generateDocumentReaderGraphicField(result, getContext()).toString());
942
+ }
943
+
944
+ private void graphicFieldImageByType(Callback callback, String raw, int fieldType) {
945
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
946
+ callback.success(Helpers.bitmapToBase64String(results.getGraphicFieldImageByType(fieldType)));
947
+ }
948
+
949
+ private void graphicFieldImageByTypeSource(Callback callback, String raw, int fieldType, int source) {
950
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
951
+ callback.success(Helpers.bitmapToBase64String(results.getGraphicFieldImageByType(fieldType, source)));
952
+ }
953
+
954
+ private void graphicFieldImageByTypeSourcePageIndex(Callback callback, String raw, int fieldType, int source, int pageIndex) {
955
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
956
+ callback.success(Helpers.bitmapToBase64String(results.getGraphicFieldImageByType(fieldType, source, pageIndex)));
957
+ }
958
+
959
+ private void graphicFieldImageByTypeSourcePageIndexLight(Callback callback, String raw, int fieldType, int source, int pageIndex, int light) {
960
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
961
+ callback.success(Helpers.bitmapToBase64String(results.getGraphicFieldImageByType(fieldType, source, pageIndex, light)));
962
+ }
963
+
964
+ @SuppressLint("WrongConstant")
965
+ private void containers(Callback callback, String raw, JSONArray resultType) {
966
+ try {
967
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
968
+ callback.success(results.getContainers(JSONConstructor.intArrayFromJSON(resultType)));
969
+ } catch (JSONException e) {
970
+ e.printStackTrace();
971
+ callback.error(e.toString());
972
+ }
973
+ }
974
+
975
+ private void encryptedContainers(Callback callback, String raw) {
976
+ DocumentReaderResults results = DocumentReaderResults.fromRawResults(raw);
977
+ callback.success(results.getEncryptedContainers());
978
+ }
979
+
980
+ private void setCameraSessionIsPaused(Callback callback, @SuppressWarnings("unused") boolean ignored) {
981
+ callback.error("setCameraSessionIsPaused() is an ios-only method");
982
+ }
983
+
806
984
  private void getCameraSessionIsPaused(Callback callback) {
807
985
  callback.error("getCameraSessionIsPaused() is an ios-only method");
808
986
  }
@@ -227,6 +227,8 @@ class RegulaConfig {
227
227
  processParams.respectImageQuality = opts.getBoolean("respectImageQuality");
228
228
  if (opts.has("splitNames"))
229
229
  processParams.splitNames = opts.getBoolean("splitNames");
230
+ if (opts.has("convertCase"))
231
+ processParams.convertCase = opts.getInt("convertCase");
230
232
  }
231
233
 
232
234
  private static void setCustomization(ParamsCustomization customization, JSONObject opts, Context context) throws JSONException {
@@ -516,6 +518,7 @@ class RegulaConfig {
516
518
  object.put("documentGroupFilter", generateIntArray(processParams.documentGroupFilter));
517
519
  object.put("respectImageQuality", processParams.respectImageQuality);
518
520
  object.put("splitNames", processParams.splitNames);
521
+ object.put("convertCase", processParams.convertCase);
519
522
 
520
523
  return object;
521
524
  }
package/example/App.js CHANGED
@@ -138,8 +138,6 @@ export default class App extends Component {
138
138
  this.handleResults(completion.results)
139
139
  if (completion.action === Enum.DocReaderAction.TIMEOUT)
140
140
  this.handleResults(completion.results)
141
- if (completion.action === Enum.DocReaderAction.CANCEL || completion.action === Enum.DocReaderAction.ERROR)
142
- isReadingRfid = false
143
141
  }
144
142
 
145
143
  showRfidUI() {
@@ -159,7 +157,7 @@ export default class App extends Component {
159
157
 
160
158
  updateRfidUI(results) {
161
159
  if (results.code === Enum.eRFID_NotificationCodes.RFID_NOTIFICATION_PCSC_READING_DATAGROUP)
162
- this.setState({ rfidDescription: Enum.eRFID_DataFile_Type.getTranslation(results.number) })
160
+ this.setState({ rfidDescription: Enum.eRFID_DataFile_Type.getTranslation(results.dataFileType) })
163
161
  this.setState({ rfidUIHeader: "Reading RFID", rfidUIHeaderColor: "black", rfidProgress: results.value / 100 })
164
162
  if (Platform.OS === 'ios')
165
163
  DocumentReader.setRfidSessionStatus(this.state.rfidDescription + "\n" + results.value + "%", e => { }, e => { })
@@ -171,11 +169,20 @@ export default class App extends Component {
171
169
 
172
170
  displayResults(results) {
173
171
  if(results == null) return
174
- this.setState({ fullName: results.getTextFieldValueByType({ fieldType: Enum.eVisualFieldType.FT_SURNAME_AND_GIVEN_NAMES }) })
175
- if (results.getGraphicFieldImageByType({ fieldType: Enum.eGraphicFieldType.GF_DOCUMENT_IMAGE }) != null)
176
- this.setState({ docFront: { uri: "data:image/png;base64," + results.getGraphicFieldImageByType({ fieldType: Enum.eGraphicFieldType.GF_DOCUMENT_IMAGE }) } })
177
- if (results.getGraphicFieldImageByType({ fieldType: Enum.eGraphicFieldType.GF_PORTRAIT }) != null)
178
- this.setState({ portrait: { uri: "data:image/png;base64," + results.getGraphicFieldImageByType({ fieldType: Enum.eGraphicFieldType.GF_PORTRAIT }) } })
172
+
173
+ results.textFieldValueByType(Enum.eVisualFieldType.FT_SURNAME_AND_GIVEN_NAMES, (value) => {
174
+ this.setState({ fullName: value })
175
+ }, error => console.log(error))
176
+
177
+ results.graphicFieldImageByType(Enum.eGraphicFieldType.GF_DOCUMENT_IMAGE, (value) => {
178
+ if(value != null && value != "")
179
+ this.setState({ docFront: { uri: "data:image/png;base64," + value } })
180
+ }, error => console.log(error))
181
+
182
+ results.graphicFieldImageByType(Enum.eGraphicFieldType.GF_PORTRAIT, (value) => {
183
+ if(value != null && value != "")
184
+ this.setState({ portrait: { uri: "data:image/png;base64," + value } })
185
+ }, error => console.log(error))
179
186
  }
180
187
 
181
188
  customRFID() {
@@ -491,7 +491,6 @@
491
491
  CLANG_ENABLE_MODULES = YES;
492
492
  CODE_SIGN_ENTITLEMENTS = DocumentReader/DocumentReader.entitlements;
493
493
  CURRENT_PROJECT_VERSION = 1;
494
- DEVELOPMENT_TEAM = "";
495
494
  ENABLE_BITCODE = NO;
496
495
  INFOPLIST_FILE = DocumentReader/Info.plist;
497
496
  LD_RUNPATH_SEARCH_PATHS = (
@@ -519,7 +518,6 @@
519
518
  CLANG_ENABLE_MODULES = YES;
520
519
  CODE_SIGN_ENTITLEMENTS = DocumentReader/DocumentReader.entitlements;
521
520
  CURRENT_PROJECT_VERSION = 1;
522
- DEVELOPMENT_TEAM = "";
523
521
  INFOPLIST_FILE = DocumentReader/Info.plist;
524
522
  LD_RUNPATH_SEARCH_PATHS = (
525
523
  "$(inherited)",
@@ -1,6 +1,5 @@
1
1
  const path = require('path');
2
2
  const folders = [
3
- "../",
4
3
  path.resolve(path.join(__dirname, './node_modules'))
5
4
  ];
6
5
  module.exports = {
@@ -10,7 +10,7 @@
10
10
  "lint": "eslint ."
11
11
  },
12
12
  "dependencies": {
13
- "@regulaforensics/react-native-document-reader-api": "6.7.0",
13
+ "@regulaforensics/react-native-document-reader-api": "6.7.2",
14
14
  "@regulaforensics/react-native-document-reader-core-fullrfid": "6.7.0",
15
15
  "react": "17.0.2",
16
16
  "react-native": "^0.67.0",