@regulaforensics/react-native-document-reader-api 5.7.0 → 6.1.0
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 +2 -2
- package/RNDocumentReaderApi.podspec +2 -2
- package/android/build.gradle +4 -6
- package/android/src/main/java/com/regula/documentreader/Helpers.java +8 -3
- package/android/src/main/java/com/regula/documentreader/JSONConstructor.java +110 -10
- package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderModule.java +58 -26
- package/android/src/main/java/com/regula/documentreader/RegulaConfig.java +72 -9
- package/example/.editorconfig +3 -0
- package/example/.flowconfig +4 -13
- package/example/.gitattributes +3 -1
- package/example/.prettierrc.js +1 -0
- package/example/App.js +30 -18
- package/example/android/app/BUCK +55 -0
- package/example/android/app/build.gradle +35 -17
- package/example/android/app/debug.keystore +0 -0
- package/example/android/app/src/debug/AndroidManifest.xml +6 -1
- package/example/android/app/src/main/AndroidManifest.xml +21 -22
- package/example/android/app/src/main/assets/index.android.bundle +636 -0
- package/example/android/app/src/main/java/com/regula/dr/fullrfid/MainApplication.java +1 -2
- package/example/android/app/src/main/res/drawable-mdpi/images_id.png +0 -0
- package/example/android/app/src/main/res/drawable-mdpi/images_portrait.png +0 -0
- package/example/android/app/src/main/res/drawable-mdpi/node_modules_reactnativecheckbox_img_ic_check_box.png +0 -0
- package/example/android/app/src/main/res/drawable-mdpi/node_modules_reactnativecheckbox_img_ic_check_box_outline_blank.png +0 -0
- package/example/android/app/src/main/res/drawable-mdpi/node_modules_reactnativecheckbox_img_ic_indeterminate_check_box.png +0 -0
- package/example/android/app/src/main/res/drawable-xhdpi/node_modules_reactnativecheckbox_img_ic_check_box.png +0 -0
- package/example/android/app/src/main/res/drawable-xhdpi/node_modules_reactnativecheckbox_img_ic_check_box_outline_blank.png +0 -0
- package/example/android/app/src/main/res/drawable-xxhdpi/node_modules_reactnativecheckbox_img_ic_check_box.png +0 -0
- package/example/android/app/src/main/res/drawable-xxhdpi/node_modules_reactnativecheckbox_img_ic_check_box_outline_blank.png +0 -0
- package/example/android/build.gradle +12 -6
- package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/example/android/gradle.properties +2 -1
- package/example/android/gradlew +14 -17
- package/example/android/gradlew.bat +7 -18
- package/example/android/settings.gradle +0 -2
- package/example/ios/DocumentReader/AppDelegate.m +7 -3
- package/example/ios/DocumentReader/Info.plist +8 -10
- package/example/ios/DocumentReader/LaunchScreen.storyboard +47 -0
- package/example/ios/DocumentReader.xcodeproj/project.pbxproj +257 -96
- package/example/ios/DocumentReader.xcodeproj/xcshareddata/xcschemes/DocumentReader.xcscheme +1 -1
- package/example/ios/DocumentReaderTests/DocumentReaderTests.m +65 -0
- package/example/ios/DocumentReaderTests/Info.plist +24 -0
- package/example/ios/Podfile +13 -4
- package/example/metro.config.js +1 -1
- package/example/package.json +17 -18
- package/index.d.ts +724 -514
- package/index.js +672 -510
- package/ios/RGLWJSONConstructor.h +6 -0
- package/ios/RGLWJSONConstructor.m +92 -0
- package/ios/RNRegulaDocumentReader.m +28 -8
- package/ios/RegulaConfig.h +2 -0
- package/ios/RegulaConfig.m +119 -31
- package/package.json +1 -1
- package/example/ios/DocumentReader.xcodeproj/xcshareddata/xcschemes/DocumentReader-tvOS.xcscheme +0 -88
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ $ pod install
|
|
|
34
34
|
5. iOS:
|
|
35
35
|
* Copy the `regula.license` file to the `example/ios/DocumentReader` folder.
|
|
36
36
|
* Change the Bundle Identifier to the one you have specified during the registration at [licensing.regulaforensics.com](https://licensing.regulaforensics.com).
|
|
37
|
-
* Run `react-native run-ios` inside `example` folder - this is just one way to run the app. You can also run it directly from within Xcode.
|
|
37
|
+
* Run `npx react-native run-ios` inside `example` folder - this is just one way to run the app. You can also run it directly from within Xcode.
|
|
38
38
|
|
|
39
39
|
### Troubleshooting license issues
|
|
40
40
|
If you have issues with license verification when running the application, please verify that next is true:
|
|
@@ -46,7 +46,7 @@ If you have issues with license verification when running the application, pleas
|
|
|
46
46
|
6. You placed the `license` into the correct folder as described [here](#how-to-build-demo-application).
|
|
47
47
|
|
|
48
48
|
## Documentation
|
|
49
|
-
You can find documentation on API [here](https://docs.regulaforensics.com/react-native).
|
|
49
|
+
You can find documentation on API [here](https://docs.regulaforensics.com/develop/doc-reader-sdk/mobile/react-native).
|
|
50
50
|
|
|
51
51
|
## Additional information
|
|
52
52
|
If you have any technical questions, feel free to [contact](mailto:react.support@regulaforensics.com) us or create issue [here](https://github.com/regulaforensics/react-native-document-reader/issues).
|
|
@@ -12,8 +12,8 @@ Pod::Spec.new do |s|
|
|
|
12
12
|
s.homepage = 'https://regulaforensics.com'
|
|
13
13
|
|
|
14
14
|
s.source = { :http => 'file:' + __dir__ }
|
|
15
|
-
s.ios.deployment_target = '
|
|
15
|
+
s.ios.deployment_target = '11.0'
|
|
16
16
|
s.source_files = "ios/*.{h,m}"
|
|
17
|
-
s.dependency 'DocumentReader', '
|
|
17
|
+
s.dependency 'DocumentReader', '6.1.2358'
|
|
18
18
|
s.dependency 'React'
|
|
19
19
|
end
|
package/android/build.gradle
CHANGED
|
@@ -16,7 +16,7 @@ android {
|
|
|
16
16
|
buildToolsVersion "30.0.0"
|
|
17
17
|
|
|
18
18
|
defaultConfig {
|
|
19
|
-
minSdkVersion
|
|
19
|
+
minSdkVersion 21
|
|
20
20
|
targetSdkVersion 30
|
|
21
21
|
versionCode 1
|
|
22
22
|
versionName "1.0"
|
|
@@ -37,12 +37,10 @@ repositories {
|
|
|
37
37
|
rootProject.allprojects {
|
|
38
38
|
repositories {
|
|
39
39
|
maven {
|
|
40
|
-
url "
|
|
41
|
-
allowInsecureProtocol true
|
|
40
|
+
url "https://maven.regulaforensics.com/RegulaDocumentReader"
|
|
42
41
|
}
|
|
43
42
|
maven {
|
|
44
|
-
url "
|
|
45
|
-
allowInsecureProtocol true
|
|
43
|
+
url "https://maven.regulaforensics.com/RegulaDocumentReader/Beta"
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
}
|
|
@@ -51,7 +49,7 @@ dependencies {
|
|
|
51
49
|
//noinspection GradleDynamicVersion
|
|
52
50
|
implementation 'com.facebook.react:react-native:+'
|
|
53
51
|
//noinspection GradleDependency
|
|
54
|
-
implementation('com.regula.documentreader:api:
|
|
52
|
+
implementation('com.regula.documentreader:api:6.1.6564') {
|
|
55
53
|
transitive = true
|
|
56
54
|
}
|
|
57
55
|
}
|
|
@@ -24,9 +24,7 @@ import java.util.List;
|
|
|
24
24
|
class Helpers {
|
|
25
25
|
static Bitmap bitmapFromBase64(String base64) {
|
|
26
26
|
byte[] decodedString = Base64.decode(base64, Base64.DEFAULT);
|
|
27
|
-
|
|
28
|
-
options.inPreferredConfig = Bitmap.Config.RGB_565;
|
|
29
|
-
Bitmap result = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length, options);
|
|
27
|
+
Bitmap result = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
|
|
30
28
|
int sizeMultiplier = result.getByteCount() / 5000000;
|
|
31
29
|
if (result.getByteCount() > 5000000)
|
|
32
30
|
result = Bitmap.createScaledBitmap(result, result.getWidth() / (int) Math.sqrt(sizeMultiplier), result.getHeight() / (int) Math.sqrt(sizeMultiplier), false);
|
|
@@ -136,4 +134,11 @@ class Helpers {
|
|
|
136
134
|
result.add(jsonArray.optString(i));
|
|
137
135
|
return result;
|
|
138
136
|
}
|
|
137
|
+
|
|
138
|
+
static String[] stringArrayFromJson(JSONArray jsonArray) {
|
|
139
|
+
String[] result = new String[jsonArray.length()];
|
|
140
|
+
for (int i = 0; i < jsonArray.length(); i++)
|
|
141
|
+
result[i] = jsonArray.optString(i);
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
139
144
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
package com.regula.documentreader;
|
|
2
2
|
|
|
3
|
+
import static com.regula.documentreader.api.completions.IRfidNotificationCompletion.RFID_EXTRA_ERROR_CODE;
|
|
4
|
+
|
|
3
5
|
import android.content.Context;
|
|
4
6
|
import android.graphics.Bitmap;
|
|
5
7
|
import android.graphics.BitmapFactory;
|
|
6
8
|
import android.graphics.Rect;
|
|
9
|
+
import android.os.Bundle;
|
|
7
10
|
import android.util.Base64;
|
|
8
11
|
|
|
9
12
|
import com.regula.documentreader.api.enums.DocReaderAction;
|
|
@@ -11,11 +14,13 @@ import com.regula.documentreader.api.enums.PDF417Info;
|
|
|
11
14
|
import com.regula.documentreader.api.enums.eGraphicFieldType;
|
|
12
15
|
import com.regula.documentreader.api.enums.eRPRM_Lights;
|
|
13
16
|
import com.regula.documentreader.api.errors.DocumentReaderException;
|
|
17
|
+
import com.regula.documentreader.api.internal.core.CoreDetailedScenario;
|
|
14
18
|
import com.regula.documentreader.api.params.FaceMetaData;
|
|
15
19
|
import com.regula.documentreader.api.params.rfid.authorization.PAAttribute;
|
|
16
20
|
import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer;
|
|
17
21
|
import com.regula.documentreader.api.params.rfid.authorization.TAChallenge;
|
|
18
22
|
import com.regula.documentreader.api.results.Bounds;
|
|
23
|
+
import com.regula.documentreader.api.results.BytesData;
|
|
19
24
|
import com.regula.documentreader.api.results.Coordinate;
|
|
20
25
|
import com.regula.documentreader.api.results.DocReaderFieldRect;
|
|
21
26
|
import com.regula.documentreader.api.results.DocumentReaderBarcodeField;
|
|
@@ -25,14 +30,15 @@ import com.regula.documentreader.api.results.DocumentReaderGraphicField;
|
|
|
25
30
|
import com.regula.documentreader.api.results.DocumentReaderGraphicResult;
|
|
26
31
|
import com.regula.documentreader.api.results.DocumentReaderNotification;
|
|
27
32
|
import com.regula.documentreader.api.results.DocumentReaderResults;
|
|
33
|
+
import com.regula.documentreader.api.results.DocumentReaderResultsStatus;
|
|
28
34
|
import com.regula.documentreader.api.results.DocumentReaderScenario;
|
|
29
|
-
import com.regula.documentreader.api.results.DocumentReaderScenarioFull;
|
|
30
35
|
import com.regula.documentreader.api.results.DocumentReaderTextField;
|
|
31
36
|
import com.regula.documentreader.api.results.DocumentReaderTextResult;
|
|
32
37
|
import com.regula.documentreader.api.results.DocumentReaderValue;
|
|
33
38
|
import com.regula.documentreader.api.results.ElementPosition;
|
|
34
39
|
import com.regula.documentreader.api.results.ImageQuality;
|
|
35
40
|
import com.regula.documentreader.api.results.ImageQualityGroup;
|
|
41
|
+
import com.regula.documentreader.api.results.VDSNCData;
|
|
36
42
|
import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityCheck;
|
|
37
43
|
import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityElement;
|
|
38
44
|
import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityResult;
|
|
@@ -294,6 +300,18 @@ class JSONConstructor {
|
|
|
294
300
|
return result;
|
|
295
301
|
}
|
|
296
302
|
|
|
303
|
+
static JSONObject generateRfidNotificationCompletion(int notification, Bundle value) {
|
|
304
|
+
JSONObject result = new JSONObject();
|
|
305
|
+
try {
|
|
306
|
+
result.put("notification", notification);
|
|
307
|
+
if(value != null)
|
|
308
|
+
result.put("value", value.get(RFID_EXTRA_ERROR_CODE));
|
|
309
|
+
} catch (JSONException ignored) {
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return result;
|
|
313
|
+
}
|
|
314
|
+
|
|
297
315
|
static JSONObject generatePACertificateCompletion(byte[] serialNumber, PAResourcesIssuer issuer) {
|
|
298
316
|
JSONObject result = new JSONObject();
|
|
299
317
|
try {
|
|
@@ -335,8 +353,6 @@ class JSONConstructor {
|
|
|
335
353
|
JSONObject result = new JSONObject();
|
|
336
354
|
if (input == null) return result;
|
|
337
355
|
try {
|
|
338
|
-
result.put("uvTorch", input.uvTorch);
|
|
339
|
-
result.put("seriesProcessMode", input.seriesProcessMode);
|
|
340
356
|
result.put("name", input.name);
|
|
341
357
|
result.put("caption", input.caption);
|
|
342
358
|
result.put("description", input.description);
|
|
@@ -346,7 +362,7 @@ class JSONConstructor {
|
|
|
346
362
|
return result;
|
|
347
363
|
}
|
|
348
364
|
|
|
349
|
-
static JSONObject
|
|
365
|
+
static JSONObject generateCoreDetailedScenario(CoreDetailedScenario input) {
|
|
350
366
|
JSONObject result = new JSONObject();
|
|
351
367
|
if (input == null) return result;
|
|
352
368
|
try {
|
|
@@ -1039,6 +1055,92 @@ class JSONConstructor {
|
|
|
1039
1055
|
return result;
|
|
1040
1056
|
}
|
|
1041
1057
|
|
|
1058
|
+
static JSONObject generateDocumentReaderResultsStatus(DocumentReaderResultsStatus input) {
|
|
1059
|
+
JSONObject result = new JSONObject();
|
|
1060
|
+
if (input == null) return result;
|
|
1061
|
+
try {
|
|
1062
|
+
result.put("overallStatus", input.getOverallStatus());
|
|
1063
|
+
result.put("optical", input.getOptical());
|
|
1064
|
+
result.put("detailsOptical", generateDetailsOptical(input.getDetailsOptical()));
|
|
1065
|
+
result.put("rfid", input.getRfid());
|
|
1066
|
+
result.put("detailsRFID", generateDetailsRFID(input.getDetailsRFID()));
|
|
1067
|
+
result.put("portrait", input.getPortrait());
|
|
1068
|
+
result.put("stopList", input.getStopList());
|
|
1069
|
+
} catch (JSONException e) {
|
|
1070
|
+
e.printStackTrace();
|
|
1071
|
+
}
|
|
1072
|
+
return result;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
static JSONObject generateDetailsOptical(DocumentReaderResultsStatus.DetailsOptical input) {
|
|
1076
|
+
JSONObject result = new JSONObject();
|
|
1077
|
+
if (input == null) return result;
|
|
1078
|
+
try {
|
|
1079
|
+
result.put("overallStatus", input.getOverallStatus());
|
|
1080
|
+
result.put("mrz", input.getMrz());
|
|
1081
|
+
result.put("text", input.getText());
|
|
1082
|
+
result.put("docType", input.getDocType());
|
|
1083
|
+
result.put("security", input.getSecurity());
|
|
1084
|
+
result.put("imageQA", input.getImageQA());
|
|
1085
|
+
result.put("expiry", input.getExpiry());
|
|
1086
|
+
result.put("vds", input.getVds());
|
|
1087
|
+
result.put("pagesCount", input.getPagesCount());
|
|
1088
|
+
} catch (JSONException e) {
|
|
1089
|
+
e.printStackTrace();
|
|
1090
|
+
}
|
|
1091
|
+
return result;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
static JSONObject generateDetailsRFID(DocumentReaderResultsStatus.DetailsRFID input) {
|
|
1095
|
+
JSONObject result = new JSONObject();
|
|
1096
|
+
if (input == null) return result;
|
|
1097
|
+
try {
|
|
1098
|
+
result.put("pa", input.getPA());
|
|
1099
|
+
result.put("ca", input.getCA());
|
|
1100
|
+
result.put("aa", input.getAA());
|
|
1101
|
+
result.put("ta", input.getTA());
|
|
1102
|
+
result.put("bac", input.getBAC());
|
|
1103
|
+
result.put("pace", input.getPACE());
|
|
1104
|
+
result.put("overallStatus", input.getOverallStatus());
|
|
1105
|
+
} catch (JSONException e) {
|
|
1106
|
+
e.printStackTrace();
|
|
1107
|
+
}
|
|
1108
|
+
return result;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
static JSONObject generateVDSNCData(VDSNCData input) {
|
|
1112
|
+
JSONObject result = new JSONObject();
|
|
1113
|
+
if (input == null) return result;
|
|
1114
|
+
try {
|
|
1115
|
+
result.put("type", input.getType());
|
|
1116
|
+
result.put("version", input.getVersion());
|
|
1117
|
+
result.put("issuingCountry", input.getIssuingCountry());
|
|
1118
|
+
result.put("message", input.getMessage());
|
|
1119
|
+
result.put("signatureAlgorithm", input.getSignatureAlg());
|
|
1120
|
+
result.put("signature", generateBytesData(input.getSignature()));
|
|
1121
|
+
result.put("certificate", generateBytesData(input.getCertificate()));
|
|
1122
|
+
result.put("certificateChain", generateList(input.getCertificateChain(), JSONConstructor::generateCertificateChain));
|
|
1123
|
+
result.put("notifications", generateLongArray(input.getNotifications()));
|
|
1124
|
+
} catch (JSONException e) {
|
|
1125
|
+
e.printStackTrace();
|
|
1126
|
+
}
|
|
1127
|
+
return result;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
static JSONObject generateBytesData(BytesData input) {
|
|
1131
|
+
JSONObject result = new JSONObject();
|
|
1132
|
+
if (input == null) return result;
|
|
1133
|
+
try {
|
|
1134
|
+
result.put("data", input.getData());
|
|
1135
|
+
result.put("length", input.getLength());
|
|
1136
|
+
result.put("status", input.getStatus());
|
|
1137
|
+
result.put("type", input.getType());
|
|
1138
|
+
} catch (JSONException e) {
|
|
1139
|
+
e.printStackTrace();
|
|
1140
|
+
}
|
|
1141
|
+
return result;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1042
1144
|
static JSONObject generateDocumentReaderResults(DocumentReaderResults input, Context context) {
|
|
1043
1145
|
JSONObject result = new JSONObject();
|
|
1044
1146
|
if (input == null) return result;
|
|
@@ -1063,6 +1165,8 @@ class JSONConstructor {
|
|
|
1063
1165
|
result.put("authenticityResult", generateDocumentReaderAuthenticityResult(input.authenticityResult, context));
|
|
1064
1166
|
result.put("barcodeResult", generateDocumentReaderBarcodeResult(input.barcodeResult));
|
|
1065
1167
|
result.put("documentType", generateList(input.documentType, JSONConstructor::generateDocumentReaderDocumentType));
|
|
1168
|
+
result.put("status", generateDocumentReaderResultsStatus(input.status));
|
|
1169
|
+
result.put("vdsncData", generateVDSNCData(input.vdsncData));
|
|
1066
1170
|
} catch (JSONException e) {
|
|
1067
1171
|
e.printStackTrace();
|
|
1068
1172
|
}
|
|
@@ -1074,10 +1178,6 @@ class JSONConstructor {
|
|
|
1074
1178
|
static DocumentReaderScenario DocumentReaderScenarioFromJSON(JSONObject input) {
|
|
1075
1179
|
try {
|
|
1076
1180
|
DocumentReaderScenario result = new DocumentReaderScenario();
|
|
1077
|
-
if (input.has("uvTorch"))
|
|
1078
|
-
result.uvTorch = input.getBoolean("uvTorch");
|
|
1079
|
-
if (input.has("seriesProcessMode"))
|
|
1080
|
-
result.seriesProcessMode = input.getBoolean("seriesProcessMode");
|
|
1081
1181
|
if (input.has("name"))
|
|
1082
1182
|
result.name = input.getString("name");
|
|
1083
1183
|
if (input.has("caption"))
|
|
@@ -1091,9 +1191,9 @@ class JSONConstructor {
|
|
|
1091
1191
|
return null;
|
|
1092
1192
|
}
|
|
1093
1193
|
|
|
1094
|
-
static
|
|
1194
|
+
static CoreDetailedScenario CoreDetailedScenarioFromJSON(JSONObject input) {
|
|
1095
1195
|
try {
|
|
1096
|
-
|
|
1196
|
+
CoreDetailedScenario result = new CoreDetailedScenario();
|
|
1097
1197
|
if (input.has("uvTorch"))
|
|
1098
1198
|
result.uvTorch = input.getBoolean("uvTorch");
|
|
1099
1199
|
if (input.has("frameOrientation"))
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.regula.documentreader;
|
|
2
2
|
|
|
3
|
+
import android.annotation.SuppressLint;
|
|
3
4
|
import android.app.Activity;
|
|
4
5
|
import android.app.PendingIntent;
|
|
5
6
|
import android.content.Context;
|
|
@@ -8,6 +9,7 @@ import android.content.IntentFilter;
|
|
|
8
9
|
import android.graphics.Bitmap;
|
|
9
10
|
import android.nfc.NfcAdapter;
|
|
10
11
|
import android.nfc.tech.IsoDep;
|
|
12
|
+
import android.os.Bundle;
|
|
11
13
|
import android.util.Base64;
|
|
12
14
|
|
|
13
15
|
import com.facebook.react.bridge.ActivityEventListener;
|
|
@@ -23,28 +25,34 @@ import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
|
23
25
|
import com.regula.documentreader.api.completions.IDocumentReaderCompletion;
|
|
24
26
|
import com.regula.documentreader.api.completions.IDocumentReaderInitCompletion;
|
|
25
27
|
import com.regula.documentreader.api.completions.IDocumentReaderPrepareCompletion;
|
|
26
|
-
import com.regula.documentreader.api.completions.IRfidNotificationCompletion;
|
|
27
28
|
import com.regula.documentreader.api.completions.IRfidPKDCertificateCompletion;
|
|
28
29
|
import com.regula.documentreader.api.completions.IRfidReaderRequest;
|
|
29
30
|
import com.regula.documentreader.api.completions.IRfidTASignatureCompletion;
|
|
30
31
|
import com.regula.documentreader.api.enums.DocReaderAction;
|
|
31
32
|
import com.regula.documentreader.api.errors.DocumentReaderException;
|
|
33
|
+
import com.regula.documentreader.api.internal.core.CoreScenarioUtil;
|
|
34
|
+
import com.regula.documentreader.api.params.DocReaderConfig;
|
|
32
35
|
import com.regula.documentreader.api.params.ImageInputParam;
|
|
33
36
|
import com.regula.documentreader.api.params.rfid.PKDCertificate;
|
|
34
37
|
import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer;
|
|
35
38
|
import com.regula.documentreader.api.params.rfid.authorization.TAChallenge;
|
|
36
39
|
import com.regula.documentreader.api.results.DocumentReaderResults;
|
|
40
|
+
import com.regula.documentreader.api.parser.DocReaderResultsJsonParser;
|
|
37
41
|
|
|
38
42
|
import org.json.JSONArray;
|
|
39
43
|
import org.json.JSONException;
|
|
40
44
|
import org.json.JSONObject;
|
|
41
45
|
|
|
42
46
|
import java.io.File;
|
|
47
|
+
import java.io.IOException;
|
|
48
|
+
import java.io.InputStream;
|
|
43
49
|
import java.util.ArrayList;
|
|
44
50
|
import java.util.List;
|
|
45
51
|
|
|
46
52
|
import static com.regula.documentreader.api.DocumentReader.Instance;
|
|
47
53
|
|
|
54
|
+
import androidx.annotation.NonNull;
|
|
55
|
+
|
|
48
56
|
@SuppressWarnings({"ConstantConditions", "RedundantSuppression"})
|
|
49
57
|
public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule implements ActivityEventListener, LifecycleEventListener {
|
|
50
58
|
private final static String prepareDatabaseProgressChangeEvent = "prepareDatabaseProgressChangeEvent";
|
|
@@ -132,8 +140,8 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
132
140
|
send(videoEncoderCompletionEvent, JSONConstructor.generateVideoEncoderCompletion(sessionId, file).toString());
|
|
133
141
|
}
|
|
134
142
|
|
|
135
|
-
private void sendIRfidNotificationCompletion(int notification) {
|
|
136
|
-
send(rfidNotificationCompletionEvent, notification
|
|
143
|
+
private void sendIRfidNotificationCompletion(int notification, Bundle value) {
|
|
144
|
+
send(rfidNotificationCompletionEvent, JSONConstructor.generateRfidNotificationCompletion(notification, value).toString());
|
|
137
145
|
}
|
|
138
146
|
|
|
139
147
|
private void sendPACertificateCompletion(byte[] serialNumber, PAResourcesIssuer issuer) {
|
|
@@ -181,6 +189,9 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
181
189
|
};
|
|
182
190
|
try {
|
|
183
191
|
switch (action) {
|
|
192
|
+
case "initializeReaderAutomatically":
|
|
193
|
+
initializeReaderAutomatically(callback);
|
|
194
|
+
break;
|
|
184
195
|
case "getAPIVersion":
|
|
185
196
|
getAPIVersion(callback);
|
|
186
197
|
break;
|
|
@@ -337,6 +348,9 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
337
348
|
case "provideTASignature":
|
|
338
349
|
provideTASignature(callback, args(0));
|
|
339
350
|
break;
|
|
351
|
+
case "parseCoreResults":
|
|
352
|
+
parseCoreResults(callback, args(0));
|
|
353
|
+
break;
|
|
340
354
|
case "initializeReaderWithDatabasePath":
|
|
341
355
|
initializeReaderWithDatabasePath(callback, args(0), args(1));
|
|
342
356
|
break;
|
|
@@ -376,6 +390,7 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
376
390
|
};
|
|
377
391
|
Intent intent = new Intent(activity.getApplicationContext(), activity.getClass());
|
|
378
392
|
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
393
|
+
@SuppressLint("UnspecifiedImmutableFlag")
|
|
379
394
|
PendingIntent pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, intent, 0);
|
|
380
395
|
NfcAdapter.getDefaultAdapter(getActivity()).enableForegroundDispatch(activity, pendingIntent, filters, techList);
|
|
381
396
|
}
|
|
@@ -387,10 +402,32 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
387
402
|
backgroundRFIDEnabled = false;
|
|
388
403
|
}
|
|
389
404
|
|
|
405
|
+
private void initializeReaderAutomatically(Callback callback) {
|
|
406
|
+
if (!Instance().isReady())
|
|
407
|
+
try {
|
|
408
|
+
InputStream is = getContext().getAssets().open("regula.license");
|
|
409
|
+
byte[] license = new byte[is.available()];
|
|
410
|
+
//noinspection ResultOfMethodCallIgnored
|
|
411
|
+
is.read(license);
|
|
412
|
+
Instance().initializeReader(getContext(), new DocReaderConfig(license), getInitCompletion(callback));
|
|
413
|
+
is.close();
|
|
414
|
+
} catch (IOException e) {
|
|
415
|
+
e.printStackTrace();
|
|
416
|
+
callback.error("problem reading license(see logs)");
|
|
417
|
+
}
|
|
418
|
+
else
|
|
419
|
+
callback.success("already initialized");
|
|
420
|
+
}
|
|
421
|
+
|
|
390
422
|
private void getAvailableScenarios(Callback callback) throws JSONException {
|
|
391
423
|
callback.success(JSONConstructor.generateList(Instance().availableScenarios, JSONConstructor::generateDocumentReaderScenario).toString());
|
|
392
424
|
}
|
|
393
425
|
|
|
426
|
+
private void parseCoreResults(Callback callback, String json) {
|
|
427
|
+
DocumentReaderResults results = (DocumentReaderResults) DocReaderResultsJsonParser.parseCoreResults(json).get("docReaderResults");
|
|
428
|
+
callback.success(JSONConstructor.generateDocumentReaderResults(results, getContext()).toString());
|
|
429
|
+
}
|
|
430
|
+
|
|
394
431
|
private void getAPIVersion(Callback callback) {
|
|
395
432
|
callback.success(Instance().version.api);
|
|
396
433
|
}
|
|
@@ -445,11 +482,11 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
445
482
|
}
|
|
446
483
|
|
|
447
484
|
private void selectedScenario(Callback callback) {
|
|
448
|
-
callback.success(JSONConstructor.
|
|
485
|
+
callback.success(JSONConstructor.generateCoreDetailedScenario(CoreScenarioUtil.getScenario(Instance().processParams().getScenario())).toString());
|
|
449
486
|
}
|
|
450
487
|
|
|
451
488
|
private void getScenario(Callback callback, String scenario) {
|
|
452
|
-
callback.success(JSONConstructor.
|
|
489
|
+
callback.success(JSONConstructor.generateCoreDetailedScenario(CoreScenarioUtil.getScenario(scenario)).toString());
|
|
453
490
|
}
|
|
454
491
|
|
|
455
492
|
private void getLicenseExpiryDate(Callback callback) {
|
|
@@ -471,11 +508,11 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
471
508
|
}
|
|
472
509
|
|
|
473
510
|
private void getDocumentReaderIsReady(Callback callback) {
|
|
474
|
-
callback.success(Instance().
|
|
511
|
+
callback.success(Instance().isReady());
|
|
475
512
|
}
|
|
476
513
|
|
|
477
514
|
private void getDocumentReaderStatus(Callback callback) {
|
|
478
|
-
callback.success(Instance().
|
|
515
|
+
callback.success(Instance().isReady());
|
|
479
516
|
}
|
|
480
517
|
|
|
481
518
|
private void isRFIDAvailableForUse(Callback callback) {
|
|
@@ -483,15 +520,15 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
483
520
|
}
|
|
484
521
|
|
|
485
522
|
private void initializeReader(Callback callback, Object license) {
|
|
486
|
-
if (!Instance().
|
|
487
|
-
Instance().initializeReader(getContext(), Base64.decode(license.toString(), Base64.DEFAULT), getInitCompletion(callback));
|
|
523
|
+
if (!Instance().isReady())
|
|
524
|
+
Instance().initializeReader(getContext(), new DocReaderConfig(Base64.decode(license.toString(), Base64.DEFAULT)), getInitCompletion(callback));
|
|
488
525
|
else
|
|
489
526
|
callback.success("already initialized");
|
|
490
527
|
}
|
|
491
528
|
|
|
492
529
|
private void initializeReaderWithDatabase(Callback callback, Object license, Object db) {
|
|
493
|
-
if (!Instance().
|
|
494
|
-
Instance().initializeReader(getContext(), Base64.decode(license.toString(), Base64.DEFAULT), Base64.decode(db.toString(), Base64.DEFAULT), getInitCompletion(callback));
|
|
530
|
+
if (!Instance().isReady())
|
|
531
|
+
Instance().initializeReader(getContext(), new DocReaderConfig(Base64.decode(license.toString(), Base64.DEFAULT), Base64.decode(db.toString(), Base64.DEFAULT)), getInitCompletion(callback));
|
|
495
532
|
else
|
|
496
533
|
callback.success("already initialized");
|
|
497
534
|
}
|
|
@@ -593,11 +630,11 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
593
630
|
private void startRFIDReader(@SuppressWarnings("unused") Callback callback) {
|
|
594
631
|
stopBackgroundRFID();
|
|
595
632
|
IRfidReaderRequest delegate = null;
|
|
596
|
-
if(rfidDelegate == RFIDDelegate.NO_PA)
|
|
633
|
+
if (rfidDelegate == RFIDDelegate.NO_PA)
|
|
597
634
|
delegate = getIRfidReaderRequestNoPA();
|
|
598
|
-
if(rfidDelegate == RFIDDelegate.FULL)
|
|
635
|
+
if (rfidDelegate == RFIDDelegate.FULL)
|
|
599
636
|
delegate = getIRfidReaderRequest();
|
|
600
|
-
Instance().startRFIDReader(getContext(), getCompletion(), delegate,
|
|
637
|
+
Instance().startRFIDReader(getContext(), getCompletion(), delegate, this::sendIRfidNotificationCompletion);
|
|
601
638
|
}
|
|
602
639
|
|
|
603
640
|
private void stopRFIDReader(Callback callback) {
|
|
@@ -705,7 +742,7 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
705
742
|
private IDocumentReaderCompletion getCompletion() {
|
|
706
743
|
return (action, results, error) -> {
|
|
707
744
|
sendCompletion(action, results, error);
|
|
708
|
-
if (action == DocReaderAction.ERROR || action == DocReaderAction.CANCEL || (action == DocReaderAction.COMPLETE && results.rfidResult == 1))
|
|
745
|
+
if (action == DocReaderAction.ERROR || action == DocReaderAction.CANCEL || (action == DocReaderAction.COMPLETE && results != null && results.rfidResult == 1))
|
|
709
746
|
stopBackgroundRFID();
|
|
710
747
|
};
|
|
711
748
|
}
|
|
@@ -743,20 +780,20 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
743
780
|
private IRfidReaderRequest getIRfidReaderRequest() {
|
|
744
781
|
return new IRfidReaderRequest() {
|
|
745
782
|
@Override
|
|
746
|
-
public void onRequestPACertificates(byte[] serialNumber, PAResourcesIssuer issuer, IRfidPKDCertificateCompletion completion) {
|
|
783
|
+
public void onRequestPACertificates(byte[] serialNumber, PAResourcesIssuer issuer, @NonNull IRfidPKDCertificateCompletion completion) {
|
|
747
784
|
paCertificateCompletion = completion;
|
|
748
785
|
completion.onCertificatesReceived(new PKDCertificate[0]);
|
|
749
786
|
sendPACertificateCompletion(serialNumber, issuer);
|
|
750
787
|
}
|
|
751
788
|
|
|
752
789
|
@Override
|
|
753
|
-
public void onRequestTACertificates(String keyCAR, IRfidPKDCertificateCompletion completion) {
|
|
790
|
+
public void onRequestTACertificates(String keyCAR, @NonNull IRfidPKDCertificateCompletion completion) {
|
|
754
791
|
taCertificateCompletion = completion;
|
|
755
792
|
sendTACertificateCompletion(keyCAR);
|
|
756
793
|
}
|
|
757
794
|
|
|
758
795
|
@Override
|
|
759
|
-
public void onRequestTASignature(TAChallenge challenge, IRfidTASignatureCompletion completion) {
|
|
796
|
+
public void onRequestTASignature(TAChallenge challenge, @NonNull IRfidTASignatureCompletion completion) {
|
|
760
797
|
taSignatureCompletion = completion;
|
|
761
798
|
sendTASignatureCompletion(challenge);
|
|
762
799
|
}
|
|
@@ -766,19 +803,19 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
766
803
|
private IRfidReaderRequest getIRfidReaderRequestNoPA() {
|
|
767
804
|
return new IRfidReaderRequest() {
|
|
768
805
|
@Override
|
|
769
|
-
public void onRequestPACertificates(byte[] serialNumber, PAResourcesIssuer issuer, IRfidPKDCertificateCompletion completion) {
|
|
806
|
+
public void onRequestPACertificates(byte[] serialNumber, PAResourcesIssuer issuer, @NonNull IRfidPKDCertificateCompletion completion) {
|
|
770
807
|
paCertificateCompletion = null;
|
|
771
808
|
completion.onCertificatesReceived(new PKDCertificate[0]);
|
|
772
809
|
}
|
|
773
810
|
|
|
774
811
|
@Override
|
|
775
|
-
public void onRequestTACertificates(String keyCAR, IRfidPKDCertificateCompletion completion) {
|
|
812
|
+
public void onRequestTACertificates(String keyCAR, @NonNull IRfidPKDCertificateCompletion completion) {
|
|
776
813
|
taCertificateCompletion = completion;
|
|
777
814
|
sendTACertificateCompletion(keyCAR);
|
|
778
815
|
}
|
|
779
816
|
|
|
780
817
|
@Override
|
|
781
|
-
public void onRequestTASignature(TAChallenge challenge, IRfidTASignatureCompletion completion) {
|
|
818
|
+
public void onRequestTASignature(TAChallenge challenge, @NonNull IRfidTASignatureCompletion completion) {
|
|
782
819
|
taSignatureCompletion = completion;
|
|
783
820
|
sendTASignatureCompletion(challenge);
|
|
784
821
|
}
|
|
@@ -792,9 +829,4 @@ public class RNRegulaDocumentReaderModule extends ReactContextBaseJavaModule imp
|
|
|
792
829
|
public static final int NO_PA = 1;
|
|
793
830
|
public static final int FULL = 2;
|
|
794
831
|
}
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
private IRfidNotificationCompletion getIRfidNotificationCompletion() {
|
|
798
|
-
return (notificationType, value) -> sendIRfidNotificationCompletion(notificationType);
|
|
799
|
-
}
|
|
800
832
|
}
|