@regulaforensics/cordova-plugin-document-reader-api 5.5.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 +1 -1
- package/example/package.json +6 -4
- package/example/www/index.html +6 -1
- package/example/www/js/index.js +58 -4
- package/package.json +1 -1
- package/plugin.xml +4 -4
- package/src/android/DocumentReader.java +204 -9
- package/src/android/Helpers.java +16 -7
- package/src/android/JSONConstructor.java +691 -330
- package/src/android/RegulaConfig.java +78 -15
- package/src/android/build.gradle +11 -11
- package/src/ios/RGLDocumentReader.h +8 -3
- package/src/ios/RGLDocumentReader.m +152 -12
- package/src/ios/{JSONConstructor.h → RGLWJSONConstructor.h} +14 -3
- package/src/ios/{JSONConstructor.m → RGLWJSONConstructor.m} +149 -4
- package/src/ios/RegulaConfig.h +2 -0
- package/src/ios/RegulaConfig.m +126 -31
- package/www/DocumentReader.js +923 -576
|
@@ -5,6 +5,7 @@ import org.json.JSONObject;
|
|
|
5
5
|
import org.json.JSONException;
|
|
6
6
|
|
|
7
7
|
import com.regula.documentreader.api.DocumentReader;
|
|
8
|
+
import com.regula.documentreader.api.params.ImageQA;
|
|
8
9
|
import com.regula.documentreader.api.params.ParamsCustomization;
|
|
9
10
|
import com.regula.documentreader.api.params.Functionality;
|
|
10
11
|
import com.regula.documentreader.api.params.ProcessParam;
|
|
@@ -98,6 +99,10 @@ class RegulaConfig {
|
|
|
98
99
|
editor.setIsCameraTorchCheckDisabled(opts.getBoolean("isCameraTorchCheckDisabled"));
|
|
99
100
|
if (opts.has("recordScanningProcess"))
|
|
100
101
|
editor.setDoRecordProcessingVideo(opts.getBoolean("recordScanningProcess"));
|
|
102
|
+
if (opts.has("manualMultipageMode"))
|
|
103
|
+
editor.setManualMultipageMode(opts.getBoolean("manualMultipageMode"));
|
|
104
|
+
if (opts.has("exposure"))
|
|
105
|
+
editor.setExposure(BigDecimal.valueOf(opts.getDouble("exposure")).floatValue());
|
|
101
106
|
|
|
102
107
|
editor.apply();
|
|
103
108
|
}
|
|
@@ -163,6 +168,49 @@ class RegulaConfig {
|
|
|
163
168
|
processParams.checkHologram = opts.getBoolean("checkHologram");
|
|
164
169
|
if (opts.has("checkRequiredTextFields"))
|
|
165
170
|
processParams.checkRequiredTextFields = opts.getBoolean("checkRequiredTextFields");
|
|
171
|
+
if (opts.has("depersonalizeLog"))
|
|
172
|
+
processParams.depersonalizeLog = opts.getBoolean("depersonalizeLog");
|
|
173
|
+
if (opts.has("resultTypeOutput"))
|
|
174
|
+
processParams.resultTypeOutput = intArrayFromJson(opts.getJSONArray("resultTypeOutput"));
|
|
175
|
+
if (opts.has("generateDoublePageSpreadImage"))
|
|
176
|
+
processParams.generateDoublePageSpreadImage = opts.getBoolean("generateDoublePageSpreadImage");
|
|
177
|
+
if (opts.has("imageDpiOutMax"))
|
|
178
|
+
processParams.imageDpiOutMax = opts.getInt("imageDpiOutMax");
|
|
179
|
+
if (opts.has("alreadyCropped"))
|
|
180
|
+
processParams.alreadyCropped = opts.getBoolean("alreadyCropped");
|
|
181
|
+
if (opts.has("forceDocID"))
|
|
182
|
+
processParams.forceDocID = opts.getInt("forceDocID");
|
|
183
|
+
if (opts.has("matchTextFieldMask"))
|
|
184
|
+
processParams.matchTextFieldMask = opts.getBoolean("matchTextFieldMask");
|
|
185
|
+
if (opts.has("fastDocDetect"))
|
|
186
|
+
processParams.fastDocDetect = opts.getBoolean("fastDocDetect");
|
|
187
|
+
if (opts.has("updateOCRValidityByGlare"))
|
|
188
|
+
processParams.updateOCRValidityByGlare = opts.getBoolean("updateOCRValidityByGlare");
|
|
189
|
+
if (opts.has("imageQA")) {
|
|
190
|
+
ImageQA img = new ImageQA();
|
|
191
|
+
img.fromJson(opts.getJSONObject("imageQA"));
|
|
192
|
+
processParams.imageQA = img;
|
|
193
|
+
}
|
|
194
|
+
if (opts.has("forceDocFormat"))
|
|
195
|
+
processParams.forceDocFormat = opts.getInt("forceDocFormat");
|
|
196
|
+
if (opts.has("noGraphics"))
|
|
197
|
+
processParams.noGraphics = opts.getBoolean("noGraphics");
|
|
198
|
+
if (opts.has("documentAreaMin"))
|
|
199
|
+
processParams.documentAreaMin = opts.getDouble("documentAreaMin");
|
|
200
|
+
if (opts.has("multiDocOnImage"))
|
|
201
|
+
processParams.multiDocOnImage = opts.getBoolean("multiDocOnImage");
|
|
202
|
+
if (opts.has("shiftExpiryDate"))
|
|
203
|
+
processParams.shiftExpiryDate = opts.getInt("shiftExpiryDate");
|
|
204
|
+
if (opts.has("minimalHolderAge"))
|
|
205
|
+
processParams.minimalHolderAge = opts.getInt("minimalHolderAge");
|
|
206
|
+
if (opts.has("mrzFormatsFilter"))
|
|
207
|
+
processParams.mrzFormatsFilter = stringArrayFromJson(opts.getJSONArray("mrzFormatsFilter"));
|
|
208
|
+
if (opts.has("forceReadMrzBeforeLocate"))
|
|
209
|
+
processParams.forceReadMrzBeforeLocate = opts.getBoolean("forceReadMrzBeforeLocate");
|
|
210
|
+
if (opts.has("parseBarcodes"))
|
|
211
|
+
processParams.parseBarcodes = opts.getBoolean("parseBarcodes");
|
|
212
|
+
if (opts.has("shouldReturnPackageForReprocess"))
|
|
213
|
+
processParams.shouldReturnPackageForReprocess = opts.getBoolean("shouldReturnPackageForReprocess");
|
|
166
214
|
}
|
|
167
215
|
|
|
168
216
|
private static void setCustomization(ParamsCustomization customization, JSONObject opts, Context context) throws JSONException {
|
|
@@ -253,10 +301,6 @@ class RegulaConfig {
|
|
|
253
301
|
editor.setCameraFrameCornerRadius((float) opts.getDouble("cameraFrameCornerRadius"));
|
|
254
302
|
if (opts.has("cameraFrameLineCap"))
|
|
255
303
|
editor.setCameraFrameLineCap(Paint.Cap.values()[(opts.getInt("cameraFrameLineCap"))]);
|
|
256
|
-
if (opts.has("torchImageOnImage"))
|
|
257
|
-
editor.setTorchImageOn(drawableFromBase64(opts.getString("torchImageOnImage"), context));
|
|
258
|
-
if (opts.has("torchImageOffImage"))
|
|
259
|
-
editor.setTorchImageOff(drawableFromBase64(opts.getString("torchImageOffImage"), context));
|
|
260
304
|
if (opts.has("closeButtonImage"))
|
|
261
305
|
editor.setCloseButtonImage(drawableFromBase64(opts.getString("closeButtonImage"), context));
|
|
262
306
|
if (opts.has("captureButtonImage"))
|
|
@@ -277,8 +321,10 @@ class RegulaConfig {
|
|
|
277
321
|
editor.setChangeFrameCollapseButtonImage(drawableFromBase64(opts.getString("changeFrameButtonCollapseImage"), context));
|
|
278
322
|
if (opts.has("toolbarSize"))
|
|
279
323
|
editor.setToolbarSize(BigDecimal.valueOf(opts.getDouble("toolbarSize")).floatValue());
|
|
324
|
+
if (opts.has("statusBackgroundColor"))
|
|
325
|
+
editor.setStatusBackgroundColor(opts.getString("statusBackgroundColor"));
|
|
280
326
|
|
|
281
|
-
editor.
|
|
327
|
+
editor.applyImmediately(context);
|
|
282
328
|
}
|
|
283
329
|
|
|
284
330
|
private static JSONObject getFunctionality(Functionality functionality) throws JSONException {
|
|
@@ -315,6 +361,8 @@ class RegulaConfig {
|
|
|
315
361
|
object.put("zoomFactor", functionality.getZoomFactor());
|
|
316
362
|
object.put("isCameraTorchCheckDisabled", functionality.isCameraTorchCheckDisabled());
|
|
317
363
|
object.put("recordScanningProcess", functionality.doRecordProcessingVideo());
|
|
364
|
+
object.put("manualMultipageMode", functionality.isManualMultipageMode());
|
|
365
|
+
object.put("exposure", functionality.getExposure());
|
|
318
366
|
|
|
319
367
|
return object;
|
|
320
368
|
}
|
|
@@ -364,8 +412,6 @@ class RegulaConfig {
|
|
|
364
412
|
object.put("cameraFramePortraitAspectRatio", customization.getCameraFramePortraitAspectRatio());
|
|
365
413
|
object.put("cameraFrameCornerRadius", customization.getCameraFrameCornerRadius());
|
|
366
414
|
object.put("cameraFrameLineCap", customization.getCameraFrameLineCap().toString());
|
|
367
|
-
object.put("torchImageOnImage", bitmapToBase64String(bitmapFromDrawable(customization.getTorchImageOnDrawable())));
|
|
368
|
-
object.put("torchImageOffImage", bitmapToBase64String(bitmapFromDrawable(customization.getTorchImageOffDrawable())));
|
|
369
415
|
object.put("closeButtonImage", bitmapToBase64String(bitmapFromDrawable(customization.getCloseButtonDrawable())));
|
|
370
416
|
object.put("captureButtonImage", bitmapToBase64String(bitmapFromDrawable(customization.getCaptureButtonDrawable())));
|
|
371
417
|
object.put("changeFrameCollapseButtonImage", bitmapToBase64String(bitmapFromDrawable(customization.getChangeFrameCollapseButtonDrawable())));
|
|
@@ -376,12 +422,17 @@ class RegulaConfig {
|
|
|
376
422
|
object.put("changeFrameButtonExpandImage", bitmapToBase64String(bitmapFromDrawable(customization.getChangeFrameExpandButtonDrawable())));
|
|
377
423
|
object.put("changeFrameButtonCollapseImage", bitmapToBase64String(bitmapFromDrawable(customization.getChangeFrameCollapseButtonDrawable())));
|
|
378
424
|
object.put("toolbarSize", customization.getToolbarSize());
|
|
425
|
+
object.put("statusBackgroundColor", customization.getStatusBackgroundColor());
|
|
379
426
|
|
|
380
427
|
return object;
|
|
381
428
|
}
|
|
382
429
|
|
|
383
430
|
private static JSONObject getProcessParams(ProcessParam processParams) throws JSONException {
|
|
384
431
|
JSONObject object = new JSONObject();
|
|
432
|
+
object.put("documentIDList", processParams.documentIDList != null ? generateIntArray(processParams.documentIDList) : null);
|
|
433
|
+
object.put("barcodeTypes", processParams.doBarcodes != null ? generateArray(processParams.doBarcodes) : null);
|
|
434
|
+
object.put("fieldTypesFilter", processParams.fieldTypesFilter != null ? generateIntArray(processParams.fieldTypesFilter) : null);
|
|
435
|
+
object.put("faceMetaData", processParams.faceMetaData != null ? generateArray(processParams.faceMetaData, JSONConstructor::generateFaceMetaData) : null);
|
|
385
436
|
object.put("scenario", processParams.scenario);
|
|
386
437
|
object.put("measureSystem", processParams.measureSystem);
|
|
387
438
|
object.put("uvTorchEnabled", processParams.uvTorchEnabled);
|
|
@@ -409,14 +460,26 @@ class RegulaConfig {
|
|
|
409
460
|
object.put("returnCroppedBarcode", processParams.returnCroppedBarcode);
|
|
410
461
|
object.put("checkHologram", processParams.checkHologram);
|
|
411
462
|
object.put("checkRequiredTextFields", processParams.checkRequiredTextFields);
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
463
|
+
object.put("depersonalizeLog", processParams.depersonalizeLog);
|
|
464
|
+
object.put("resultTypeOutput", processParams.resultTypeOutput);
|
|
465
|
+
object.put("generateDoublePageSpreadImage", processParams.generateDoublePageSpreadImage);
|
|
466
|
+
object.put("imageDpiOutMax", processParams.imageDpiOutMax);
|
|
467
|
+
object.put("alreadyCropped", processParams.alreadyCropped);
|
|
468
|
+
object.put("forceDocID", processParams.forceDocID);
|
|
469
|
+
object.put("matchTextFieldMask", processParams.matchTextFieldMask);
|
|
470
|
+
object.put("fastDocDetect", processParams.fastDocDetect);
|
|
471
|
+
object.put("updateOCRValidityByGlare", processParams.updateOCRValidityByGlare);
|
|
472
|
+
object.put("imageQA", processParams.imageQA != null ? processParams.imageQA.toJsonObject() : null);
|
|
473
|
+
object.put("forceDocFormat", processParams.forceDocFormat);
|
|
474
|
+
object.put("noGraphics", processParams.noGraphics);
|
|
475
|
+
object.put("documentAreaMin", processParams.documentAreaMin);
|
|
476
|
+
object.put("multiDocOnImage", processParams.multiDocOnImage);
|
|
477
|
+
object.put("shiftExpiryDate", processParams.shiftExpiryDate);
|
|
478
|
+
object.put("minimalHolderAge", processParams.minimalHolderAge);
|
|
479
|
+
object.put("mrzFormatsFilter", processParams.mrzFormatsFilter != null ? generateArray(processParams.mrzFormatsFilter) : null);
|
|
480
|
+
object.put("forceReadMrzBeforeLocate", processParams.forceReadMrzBeforeLocate);
|
|
481
|
+
object.put("parseBarcodes", processParams.parseBarcodes);
|
|
482
|
+
object.put("shouldReturnPackageForReprocess", processParams.shouldReturnPackageForReprocess);
|
|
420
483
|
|
|
421
484
|
return object;
|
|
422
485
|
}
|
package/src/android/build.gradle
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
repositories {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
maven{
|
|
7
|
-
url "http://maven.regulaforensics.com/RegulaDocumentReader"
|
|
8
|
-
}
|
|
9
|
-
maven {
|
|
10
|
-
url "http://maven.regulaforensics.com/RegulaDocumentReader/Beta"
|
|
11
|
-
}
|
|
2
|
+
jcenter()
|
|
3
|
+
maven{
|
|
4
|
+
url "https://maven.google.com"
|
|
12
5
|
}
|
|
6
|
+
maven{
|
|
7
|
+
url "https://maven.regulaforensics.com/RegulaDocumentReader"
|
|
8
|
+
}
|
|
9
|
+
maven {
|
|
10
|
+
url "https://maven.regulaforensics.com/RegulaDocumentReader/Beta"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
13
|
|
|
14
14
|
dependencies {
|
|
15
|
-
implementation ('com.regula.documentreader:api:
|
|
15
|
+
implementation ('com.regula.documentreader:api:6.1.6564'){
|
|
16
16
|
transitive = true
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
#import <Cordova/CDVPlugin.h>
|
|
2
2
|
#import <Foundation/Foundation.h>
|
|
3
|
-
#import "
|
|
3
|
+
#import "RGLWJSONConstructor.h"
|
|
4
4
|
#import "RegulaConfig.h"
|
|
5
5
|
#import <DocumentReader/DocumentReader.h>
|
|
6
6
|
|
|
7
7
|
@class DocReader;
|
|
8
8
|
|
|
9
|
-
@interface RGLDocumentReader : CDVPlugin<RGLRecordScanningProcessDelegate>
|
|
9
|
+
@interface RGLDocumentReader : CDVPlugin<RGLRecordScanningProcessDelegate, RGLDocReaderRFIDDelegate>
|
|
10
10
|
|
|
11
11
|
@property (class) CDVInvokedUrlCommand* _Nullable command;
|
|
12
12
|
@property (class) NSNumber* _Nullable databasePercentageDownloaded;
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
- (void) sendEvent:(NSString*_Nullable)data :(NSString*_Nonnull)callbackId;
|
|
15
|
+
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@interface RFIDDelegateNoPA : NSObject<RGLDocReaderRFIDDelegate>
|
|
19
|
+
@end
|
|
@@ -2,6 +2,40 @@
|
|
|
2
2
|
#import "RGLDocumentReader.h"
|
|
3
3
|
@import DocumentReader;
|
|
4
4
|
|
|
5
|
+
RGLRFIDCertificatesCallback paCertificateCompletion;
|
|
6
|
+
RGLRFIDCertificatesCallback taCertificateCompletion;
|
|
7
|
+
typedef void (^RGLRFIDSignatureCallback)(NSData *signature);
|
|
8
|
+
RGLRFIDSignatureCallback taSignatureCompletion;
|
|
9
|
+
RFIDDelegateNoPA* rfidDelegateNoPA;
|
|
10
|
+
RGLDocumentReader* plugin;
|
|
11
|
+
NSString* rfidNotificationCompletionEvent = @"rfidNotificationCompletionEvent";
|
|
12
|
+
NSString* paCertificateCompletionEvent = @"paCertificateCompletionEvent";
|
|
13
|
+
NSString* taCertificateCompletionEvent = @"taCertificateCompletionEvent";
|
|
14
|
+
NSString* taSignatureCompletionEvent = @"taSignatureCompletionEvent";
|
|
15
|
+
|
|
16
|
+
@implementation RFIDDelegateNoPA
|
|
17
|
+
|
|
18
|
+
- (void)onRequestTACertificatesWithKey:(NSString *)keyCAR callback:(RGLRFIDCertificatesCallback)callback {
|
|
19
|
+
taCertificateCompletion = callback;
|
|
20
|
+
[plugin sendEvent:[NSString stringWithFormat:@"%@%@", taCertificateCompletionEvent, keyCAR] :RGLDocumentReader.command.callbackId];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
- (void)onRequestTASignatureWithChallenge:(RGLTAChallenge *)challenge callback:(void(^)(NSData *signature))callback {
|
|
24
|
+
taSignatureCompletion = callback;
|
|
25
|
+
[plugin sendEvent:[NSString stringWithFormat:@"%@%@", taSignatureCompletionEvent, [RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRGLTAChallenge:challenge]]] :RGLDocumentReader.command.callbackId];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
- (void)didChipConnected {
|
|
29
|
+
[plugin sendEvent:[NSString stringWithFormat:@"%@%@", rfidNotificationCompletionEvent, [RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRfidNotificationCompletion:1]]] :RGLDocumentReader.command.callbackId]; // int RFID_EVENT_CHIP_DETECTED = 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
- (void)didReceivedError:(RGLRFIDErrorCodes)errorCode {
|
|
33
|
+
[plugin sendEvent:[NSString stringWithFormat:@"%@%@", rfidNotificationCompletionEvent, [RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRfidNotificationCompletionWithError:2:errorCode]]] :RGLDocumentReader.command.callbackId]; // int RFID_EVENT_READING_ERROR = 2;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@end
|
|
37
|
+
|
|
38
|
+
|
|
5
39
|
@implementation RGLDocumentReader
|
|
6
40
|
|
|
7
41
|
static NSNumber* _databasePercentageDownloaded;
|
|
@@ -37,36 +71,60 @@ typedef void (^Callback)(NSString* response);
|
|
|
37
71
|
-(RGLDocumentReaderCompletion _Nonnull)getCompletion {
|
|
38
72
|
NSString* callbackId = RGLDocumentReader.command.callbackId;
|
|
39
73
|
return ^(RGLDocReaderAction action, RGLDocumentReaderResults * _Nullable results, NSError * _Nullable error) {
|
|
40
|
-
[self sendEvent:[
|
|
74
|
+
[self sendEvent:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateCompletion:[RGLWJSONConstructor generateDocReaderAction: action] :results :error :nil]] :callbackId];
|
|
41
75
|
};
|
|
42
76
|
}
|
|
43
77
|
|
|
44
78
|
-(RGLRFIDProcessCompletion _Nonnull)getRFIDCompletion {
|
|
45
79
|
NSString* callbackId = RGLDocumentReader.command.callbackId;
|
|
46
80
|
return ^(RGLRFIDCompleteAction action, RGLDocumentReaderResults * _Nullable results, NSError * _Nullable error, RGLRFIDErrorCodes errorCode) {
|
|
47
|
-
[self sendEvent:[
|
|
81
|
+
[self sendEvent:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateCompletion:[RGLWJSONConstructor generateRFIDCompleteAction: action] :results :error :nil]] :callbackId];
|
|
48
82
|
};
|
|
49
83
|
}
|
|
50
84
|
|
|
51
85
|
-(RGLRFIDNotificationCallback _Nonnull)getRFIDNotificationCallback {
|
|
52
86
|
NSString* callbackId = RGLDocumentReader.command.callbackId;
|
|
53
87
|
return ^(RGLRFIDNotificationAction notificationAction, RGLRFIDNotify* _Nullable notify) {
|
|
54
|
-
[self sendEvent:[
|
|
88
|
+
[self sendEvent:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateCompletion:[RGLWJSONConstructor generateRFIDNotificationAction:notificationAction] :nil :nil :notify]] :callbackId];
|
|
55
89
|
};
|
|
56
90
|
}
|
|
57
91
|
|
|
58
92
|
- (void)didFinishRecordingToFile:(NSURL *)fileURL {
|
|
59
93
|
NSString* callbackId = RGLDocumentReader.command.callbackId;
|
|
60
|
-
[self sendEvent:[
|
|
94
|
+
[self sendEvent:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateVideoEncoderCompletion:fileURL :nil]] :callbackId];
|
|
61
95
|
}
|
|
62
96
|
|
|
63
97
|
- (void)didFailWithError:(NSError *)error {
|
|
64
98
|
NSString* callbackId = RGLDocumentReader.command.callbackId;
|
|
65
|
-
[self sendEvent:[
|
|
99
|
+
[self sendEvent:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateVideoEncoderCompletion:nil :error]] :callbackId];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
- (void)onRequestPACertificatesWithSerial:(NSData *)serialNumber issuer:(RGLPAResourcesIssuer *)issuer callback:(RGLRFIDCertificatesCallback)callback {
|
|
103
|
+
paCertificateCompletion = callback;
|
|
104
|
+
[self sendEvent:[NSString stringWithFormat:@"%@%@", paCertificateCompletionEvent, [RGLWJSONConstructor dictToString:[RGLWJSONConstructor generatePACertificateCompletion:serialNumber :issuer]]] :RGLDocumentReader.command.callbackId];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
- (void)onRequestTACertificatesWithKey:(NSString *)keyCAR callback:(RGLRFIDCertificatesCallback)callback {
|
|
108
|
+
taCertificateCompletion = callback;
|
|
109
|
+
[self sendEvent:[NSString stringWithFormat:@"%@%@", taCertificateCompletionEvent, keyCAR] :RGLDocumentReader.command.callbackId];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
- (void)onRequestTASignatureWithChallenge:(RGLTAChallenge *)challenge callback:(void(^)(NSData *signature))callback {
|
|
113
|
+
taSignatureCompletion = callback;
|
|
114
|
+
[self sendEvent:[NSString stringWithFormat:@"%@%@", taSignatureCompletionEvent, [RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRGLTAChallenge:challenge]]] :RGLDocumentReader.command.callbackId];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
- (void)didChipConnected {
|
|
118
|
+
[plugin sendEvent:[NSString stringWithFormat:@"%@%@", rfidNotificationCompletionEvent, [RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRfidNotificationCompletion:1]]] :RGLDocumentReader.command.callbackId]; // int RFID_EVENT_CHIP_DETECTED = 1;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
- (void)didReceivedError:(RGLRFIDErrorCodes)errorCode {
|
|
122
|
+
[plugin sendEvent:[NSString stringWithFormat:@"%@%@", rfidNotificationCompletionEvent, [RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRfidNotificationCompletionWithError:2:errorCode]]] :RGLDocumentReader.command.callbackId]; // int RFID_EVENT_READING_ERROR = 2;
|
|
66
123
|
}
|
|
67
124
|
|
|
68
125
|
- (void) exec:(CDVInvokedUrlCommand*)command {
|
|
69
126
|
[RGLDocumentReader setCommand:command];
|
|
127
|
+
plugin = self;
|
|
70
128
|
NSMutableArray* args = [[NSMutableArray alloc] init];
|
|
71
129
|
NSString* action = [[command arguments] objectAtIndex:0];
|
|
72
130
|
for(int i = 1;i<[command arguments].count;i++)
|
|
@@ -78,7 +136,9 @@ typedef void (^Callback)(NSString* response);
|
|
|
78
136
|
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:response] callbackId:command.callbackId];
|
|
79
137
|
};
|
|
80
138
|
|
|
81
|
-
if([action isEqualToString:@"
|
|
139
|
+
if([action isEqualToString:@"initializeReaderAutomatically"])
|
|
140
|
+
[self initializeReaderAutomatically :successCallback :errorCallback];
|
|
141
|
+
else if([action isEqualToString:@"getAPIVersion"])
|
|
82
142
|
[self getAPIVersion :successCallback :errorCallback];
|
|
83
143
|
else if([action isEqualToString:@"getAvailableScenarios"])
|
|
84
144
|
[self getAvailableScenarios :successCallback :errorCallback];
|
|
@@ -148,6 +208,8 @@ typedef void (^Callback)(NSString* response);
|
|
|
148
208
|
[self readRFID :successCallback :errorCallback];
|
|
149
209
|
else if([action isEqualToString:@"getRfidSessionStatus"])
|
|
150
210
|
[self getRfidSessionStatus :successCallback :errorCallback];
|
|
211
|
+
else if([action isEqualToString:@"setRfidDelegate"])
|
|
212
|
+
[self setRfidDelegate :[args objectAtIndex:0] :successCallback :errorCallback];
|
|
151
213
|
else if([action isEqualToString:@"setEnableCoreLogs"])
|
|
152
214
|
[self setEnableCoreLogs :[args objectAtIndex:0] :successCallback :errorCallback];
|
|
153
215
|
else if([action isEqualToString:@"addPKDCertificates"])
|
|
@@ -174,8 +236,18 @@ typedef void (^Callback)(NSString* response);
|
|
|
174
236
|
[self recognizeImage :[args objectAtIndex:0] :successCallback :errorCallback];
|
|
175
237
|
else if([action isEqualToString:@"setRfidSessionStatus"])
|
|
176
238
|
[self setRfidSessionStatus :[args objectAtIndex:0] :successCallback :errorCallback];
|
|
239
|
+
else if([action isEqualToString:@"providePACertificates"])
|
|
240
|
+
[self providePACertificates :[args objectAtIndex:0] :successCallback :errorCallback];
|
|
241
|
+
else if([action isEqualToString:@"provideTACertificates"])
|
|
242
|
+
[self provideTACertificates :[args objectAtIndex:0] :successCallback :errorCallback];
|
|
243
|
+
else if([action isEqualToString:@"provideTASignature"])
|
|
244
|
+
[self provideTASignature :[args objectAtIndex:0] :successCallback :errorCallback];
|
|
245
|
+
else if([action isEqualToString:@"parseCoreResults"])
|
|
246
|
+
[self parseCoreResults :[args objectAtIndex:0] :successCallback :errorCallback];
|
|
177
247
|
else if([action isEqualToString:@"initializeReaderWithDatabasePath"])
|
|
178
248
|
[self initializeReaderWithDatabasePath :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
|
|
249
|
+
else if([action isEqualToString:@"initializeReaderWithDatabase"])
|
|
250
|
+
[self initializeReaderWithDatabase :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
|
|
179
251
|
else if([action isEqualToString:@"recognizeImageFrame"])
|
|
180
252
|
[self recognizeImageFrame :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
|
|
181
253
|
else if([action isEqualToString:@"recognizeImageWithOpts"])
|
|
@@ -192,6 +264,12 @@ typedef void (^Callback)(NSString* response);
|
|
|
192
264
|
[self result:[NSString stringWithFormat:@"%@/%@", @"method not implemented: ", action] :errorCallback];
|
|
193
265
|
}
|
|
194
266
|
|
|
267
|
+
- (void) initializeReaderAutomatically:(Callback)successCallback :(Callback)errorCallback{
|
|
268
|
+
NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"regula.license" ofType:nil];
|
|
269
|
+
NSData *licenseData = [NSData dataWithContentsOfFile:dataPath];
|
|
270
|
+
[RGLDocReader.shared initializeReaderWithConfig:[RGLConfig configWithLicenseData:licenseData] completion:[self getInitCompletion :successCallback :errorCallback]];
|
|
271
|
+
}
|
|
272
|
+
|
|
195
273
|
- (void) resetConfiguration:(Callback)successCallback :(Callback)errorCallback{
|
|
196
274
|
[self result:@"resetConfiguration() is an android-only method" :errorCallback];
|
|
197
275
|
}
|
|
@@ -228,8 +306,16 @@ typedef void (^Callback)(NSString* response);
|
|
|
228
306
|
[self result:@"getLicenseMessage() is an android-only method" :successCallback];
|
|
229
307
|
}
|
|
230
308
|
|
|
309
|
+
- (void) initializeReaderWithDatabase:(NSString*)licenseString :(NSString*)databaseString :(Callback)successCallback :(Callback)errorCallback{
|
|
310
|
+
[self result:@"initializeReaderWithDatabase() is an android-only method" :successCallback];
|
|
311
|
+
}
|
|
312
|
+
|
|
231
313
|
- (void) initializeReader:(NSString*)licenseString :(Callback)successCallback :(Callback)errorCallback{
|
|
232
|
-
[RGLDocReader.shared
|
|
314
|
+
[RGLDocReader.shared initializeReaderWithConfig:[RGLConfig configWithLicenseData:[[NSData alloc] initWithBase64EncodedString:licenseString options:0]] completion:[self getInitCompletion :successCallback :errorCallback]];
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
- (void) parseCoreResults:(NSString*)json :(Callback)successCallback :(Callback)errorCallback{
|
|
318
|
+
[self result:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRGLDocumentReaderResults:[RGLDocumentReaderResults initWithRawString: json]]] :successCallback];
|
|
233
319
|
}
|
|
234
320
|
|
|
235
321
|
- (void) startRFIDReader:(Callback)successCallback :(Callback)errorCallback{
|
|
@@ -239,7 +325,7 @@ typedef void (^Callback)(NSString* response);
|
|
|
239
325
|
}
|
|
240
326
|
|
|
241
327
|
- (void) initializeReaderWithDatabasePath:(NSString*)licenseString :(NSString*)databasePath :(Callback)successCallback :(Callback)errorCallback{
|
|
242
|
-
[RGLDocReader.shared
|
|
328
|
+
[RGLDocReader.shared initializeReaderWithConfig:[RGLConfig configWithLicenseData:[[NSData alloc] initWithBase64EncodedString:licenseString options:0] licenseUpdateCheck:true databasePath:databasePath delayedNNLoadEnabled:false] completion:[self getInitCompletion :successCallback :errorCallback]];
|
|
243
329
|
}
|
|
244
330
|
|
|
245
331
|
- (void) prepareDatabase:(NSString*)dbID :(Callback)successCallback :(Callback)errorCallback{
|
|
@@ -329,7 +415,7 @@ typedef void (^Callback)(NSString* response);
|
|
|
329
415
|
- (void) addPKDCertificates:(NSArray*)input :(Callback)successCallback :(Callback)errorCallback{
|
|
330
416
|
NSMutableArray *certificates = [[NSMutableArray alloc] init];
|
|
331
417
|
for(NSDictionary* certificateJSON in input)
|
|
332
|
-
[certificates addObject:[
|
|
418
|
+
[certificates addObject:[RGLWJSONConstructor RGLPKDCertificateFromJson:certificateJSON]];
|
|
333
419
|
[RGLDocReader.shared addPKDCertificates:certificates];
|
|
334
420
|
[self result:@"" :successCallback];
|
|
335
421
|
}
|
|
@@ -340,7 +426,7 @@ typedef void (^Callback)(NSString* response);
|
|
|
340
426
|
}
|
|
341
427
|
|
|
342
428
|
- (void) selectedScenario:(Callback)successCallback :(Callback)errorCallback{
|
|
343
|
-
[self result:[
|
|
429
|
+
[self result:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRGLScenario:RGLDocReader.shared.selectedScenario]] :successCallback];
|
|
344
430
|
}
|
|
345
431
|
|
|
346
432
|
- (void) stopScanner:(Callback)successCallback :(Callback)errorCallback{
|
|
@@ -462,7 +548,7 @@ typedef void (^Callback)(NSString* response);
|
|
|
462
548
|
BOOL success = false;
|
|
463
549
|
for(RGLScenario *scenario in RGLDocReader.shared.availableScenarios)
|
|
464
550
|
if([scenario.identifier isEqualToString:scenarioID]){
|
|
465
|
-
[self result:[
|
|
551
|
+
[self result:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRGLScenario:scenario]] :successCallback];
|
|
466
552
|
success = true;
|
|
467
553
|
break;
|
|
468
554
|
}
|
|
@@ -470,10 +556,64 @@ typedef void (^Callback)(NSString* response);
|
|
|
470
556
|
[self result:@"Scenario unavailable" :errorCallback];
|
|
471
557
|
}
|
|
472
558
|
|
|
559
|
+
- (void) providePACertificates:(NSArray*)input :(Callback)successCallback :(Callback)errorCallback{
|
|
560
|
+
if(paCertificateCompletion == nil){
|
|
561
|
+
[self result:@"paCertificateCompletion is nil" :errorCallback];
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
NSMutableArray *certificates = [[NSMutableArray alloc] init];
|
|
565
|
+
for(NSDictionary* certificateJSON in input)
|
|
566
|
+
[certificates addObject:[RGLWJSONConstructor RGLPKDCertificateFromJson:certificateJSON]];
|
|
567
|
+
paCertificateCompletion(certificates);
|
|
568
|
+
[self result:@"" :successCallback];
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
- (void) provideTACertificates:(NSArray*)input :(Callback)successCallback :(Callback)errorCallback{
|
|
572
|
+
if(taCertificateCompletion == nil){
|
|
573
|
+
[self result:@"taCertificateCompletion is nil" :errorCallback];
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
NSMutableArray *certificates = [[NSMutableArray alloc] init];
|
|
577
|
+
for(NSDictionary* certificateJSON in input)
|
|
578
|
+
[certificates addObject:[RGLWJSONConstructor RGLPKDCertificateFromJson:certificateJSON]];
|
|
579
|
+
taCertificateCompletion(certificates);
|
|
580
|
+
[self result:@"" :successCallback];
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
- (void) provideTASignature:(NSString*)input :(Callback)successCallback :(Callback)errorCallback{
|
|
584
|
+
if(taSignatureCompletion == nil){
|
|
585
|
+
[self result:@"taSignatureCompletion is nil" :errorCallback];
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
taSignatureCompletion([[NSData alloc] initWithBase64EncodedString:input options:0]);
|
|
589
|
+
[self result:@"" :successCallback];
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
- (void) setRfidDelegate:(NSNumber*)input :(Callback)successCallback :(Callback)errorCallback{
|
|
593
|
+
switch([input integerValue]){
|
|
594
|
+
case 0:
|
|
595
|
+
[RGLDocReader shared].rfidDelegate = nil;
|
|
596
|
+
break;
|
|
597
|
+
case 1:
|
|
598
|
+
if(rfidDelegateNoPA == nil)
|
|
599
|
+
rfidDelegateNoPA = [RFIDDelegateNoPA new];
|
|
600
|
+
[RGLDocReader shared].rfidDelegate = rfidDelegateNoPA;
|
|
601
|
+
break;
|
|
602
|
+
case 2:
|
|
603
|
+
[RGLDocReader shared].rfidDelegate = self;
|
|
604
|
+
break;
|
|
605
|
+
default:
|
|
606
|
+
[self result:@"wrong input" :errorCallback];
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
[self result:@"" :successCallback];
|
|
611
|
+
}
|
|
612
|
+
|
|
473
613
|
- (void) getAvailableScenarios:(Callback)successCallback :(Callback)errorCallback{
|
|
474
614
|
NSMutableArray *availableScenarios = [[NSMutableArray alloc] init];
|
|
475
615
|
for(RGLScenario *scenario in RGLDocReader.shared.availableScenarios)
|
|
476
|
-
[availableScenarios addObject:[
|
|
616
|
+
[availableScenarios addObject:[RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateRGLScenario:scenario]]];
|
|
477
617
|
[self result:[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:availableScenarios options:NSJSONWritingPrettyPrinted error:nil] encoding:NSUTF8StringEncoding] :successCallback];
|
|
478
618
|
}
|
|
479
619
|
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
#ifndef
|
|
2
|
-
#define
|
|
1
|
+
#ifndef RGLWJSONConstructor_h
|
|
2
|
+
#define RGLWJSONConstructor_h
|
|
3
3
|
|
|
4
4
|
#import <DocumentReader/DocumentReader.h>
|
|
5
5
|
@import CoreGraphics;
|
|
6
6
|
@import UIKit;
|
|
7
7
|
|
|
8
|
-
@interface
|
|
8
|
+
@interface RGLWJSONConstructor : NSObject
|
|
9
9
|
+(NSString* _Nonnull)dictToString:(NSMutableDictionary* _Nonnull)input;
|
|
10
|
+
+(NSMutableDictionary* _Nonnull)generateRfidNotificationCompletion:(NSInteger)notification;
|
|
11
|
+
+(NSMutableDictionary* _Nonnull)generateRfidNotificationCompletionWithError:(NSInteger)notification : (NSInteger)value;
|
|
10
12
|
+(NSMutableDictionary* _Nonnull)generateNSDictionary:(NSDictionary<NSNumber*, NSNumber*>* _Nullable)input;
|
|
11
13
|
+(RGLPKDCertificate* _Nullable)RGLPKDCertificateFromJson:(NSDictionary* _Nullable) dict;
|
|
12
14
|
+(NSInteger)generateDocReaderAction:(RGLDocReaderAction)action;
|
|
@@ -14,6 +16,8 @@
|
|
|
14
16
|
+(NSInteger)generateRFIDNotificationAction:(RGLRFIDNotificationAction)action;
|
|
15
17
|
+(NSMutableDictionary* _Nullable)generateCompletion:(NSInteger)action :(RGLDocumentReaderResults*_Nullable)results :(NSError*_Nullable)error :(RGLRFIDNotify*_Nullable)notify;
|
|
16
18
|
+(NSMutableDictionary* _Nonnull)generateVideoEncoderCompletion:(NSURL* _Nullable)input :(NSError* _Nullable)error;
|
|
19
|
+
+(NSString*_Nonnull)generateNSData:(NSData *_Nullable)input;
|
|
20
|
+
+(NSMutableDictionary* _Nonnull)generatePACertificateCompletion:(NSData *_Nullable)serialNumber :(RGLPAResourcesIssuer *_Nullable)issuer;
|
|
17
21
|
+(NSMutableDictionary* _Nonnull)generateRGLDocumentReaderResults:(RGLDocumentReaderResults* _Nullable)input;
|
|
18
22
|
+(NSMutableDictionary* _Nonnull)generateRGLPosition:(RGLPosition* _Nullable)input;
|
|
19
23
|
+(NSMutableDictionary* _Nonnull)generateRGLDocumentReaderBarcodeResult:(RGLDocumentReaderBarcodeResult* _Nullable)input;
|
|
@@ -49,6 +53,13 @@
|
|
|
49
53
|
+(NSMutableDictionary* _Nonnull)generateRGLCertificateChain:(RGLCertificateChain* _Nullable)input;
|
|
50
54
|
+(NSMutableDictionary* _Nonnull)generateRGLValidity:(RGLValidity* _Nullable)input;
|
|
51
55
|
+(NSMutableDictionary* _Nonnull)generateNSError:(NSError* _Nullable)input;
|
|
56
|
+
+(NSMutableDictionary* _Nonnull)generateRGLPAResourcesIssuer:(RGLPAResourcesIssuer* _Nullable)input;
|
|
57
|
+
+(NSMutableDictionary* _Nonnull)generateRGLPAAttribute:(RGLPAAttribute* _Nullable)input;
|
|
58
|
+
+(NSMutableDictionary* _Nonnull)generateRGLTAChallenge:(RGLTAChallenge* _Nullable)input;
|
|
59
|
+
+(NSMutableDictionary* _Nonnull)generateRGLDocumentReaderResultsStatus:(RGLDocumentReaderResultsStatus* _Nullable)input;
|
|
60
|
+
+(NSMutableDictionary* _Nonnull)generateRGLOpticalStatus:(RGLOpticalStatus* _Nullable)input;
|
|
61
|
+
+(NSMutableDictionary* _Nonnull)generateRGLVDSNCData:(RGLVDSNCData* _Nullable)input;
|
|
62
|
+
+(NSMutableDictionary* _Nonnull)generateRGLBytesData:(RGLBytesData* _Nullable)input;
|
|
52
63
|
+(NSMutableDictionary* _Nonnull)generateRGLRFIDNotify:(RGLRFIDNotify* _Nullable)input;
|
|
53
64
|
|
|
54
65
|
@end
|