@regulaforensics/react-native-document-reader-api 6.3.0 → 6.5.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.
@@ -12,6 +12,8 @@
12
12
  +(NSMutableDictionary* _Nonnull)generateNSDictionary:(NSDictionary<NSNumber*, NSNumber*>* _Nullable)input;
13
13
  +(RGLPKDCertificate* _Nullable)RGLPKDCertificateFromJson:(NSDictionary* _Nullable) dict;
14
14
  +(RGLTCCParams* _Nonnull)RGLTCCParamsFromJson:(NSDictionary* _Nonnull)input;
15
+ +(RGLConfig* _Nullable)RGLConfigFromJson:(NSDictionary* _Nonnull)input;
16
+ +(RGLImageInput* _Nonnull)RGLImageInputFromJson:(NSDictionary* _Nonnull)input;
15
17
  +(NSInteger)generateDocReaderAction:(RGLDocReaderAction)action;
16
18
  +(NSInteger)generateRFIDCompleteAction:(RGLRFIDCompleteAction)action;
17
19
  +(NSInteger)generateRFIDNotificationAction:(RGLRFIDNotificationAction)action;
@@ -35,6 +35,42 @@
35
35
  return [[RGLTCCParams alloc] initWithServiceTAURLString:serviceTAURLString servicePAURLString:servicePAURLString pfxCertURLString:pfxCertURLString pfxCertData: pfxCertData pfxPassPhrase:pfxPassPhrase];
36
36
  }
37
37
 
38
+ +(RGLConfig*)RGLConfigFromJson:(NSDictionary*)input {
39
+ NSData* license;
40
+ if([input valueForKey:@"license"] != nil)
41
+ license = [[NSData alloc] initWithBase64EncodedString:[input valueForKey:@"license"] options:0];
42
+ else return nil;
43
+
44
+ RGLConfig *config = [[RGLConfig alloc] initWithLicenseData:license];
45
+
46
+ if([input valueForKey:@"databasePath"] != nil){
47
+ config.databasePath = [[input valueForKey:@"databasePath"] stringValue];
48
+ }
49
+ if([input valueForKey:@"licenseUpdate"] != nil){
50
+ config.licenseUpdateCheck = [[input valueForKey:@"licenseUpdate"] boolValue];
51
+ }
52
+ if([input valueForKey:@"delayedNNLoad"] != nil){
53
+ config.delayedNNLoadEnabled = [[input valueForKey:@"delayedNNLoad"] boolValue];
54
+ }
55
+
56
+ return config;
57
+ }
58
+
59
+
60
+ +(RGLImageInput*)RGLImageInputFromJson:(NSDictionary*)input {
61
+ NSInteger pageIndex = 0;
62
+ if([input valueForKey:@"pageIndex"] != nil)
63
+ pageIndex = [[input valueForKey:@"pageIndex"] integerValue];
64
+ NSInteger light = 6;
65
+ if([input valueForKey:@"light"] != nil)
66
+ pageIndex = [[input valueForKey:@"light"] integerValue];
67
+ if([input valueForKey:@"bitmap"] != nil){
68
+ UIImage* image = [UIImage imageWithData:[[NSData alloc]initWithBase64EncodedString:[input valueForKey:@"bitmap"] options:NSDataBase64DecodingIgnoreUnknownCharacters]];
69
+ return [[RGLImageInput alloc] initWithImage:image light:light pageIndex:pageIndex];
70
+ }
71
+ return nil;
72
+ }
73
+
38
74
  +(NSMutableDictionary*)generateCGPoint:(CGPoint)input {
39
75
  NSMutableDictionary *result = [NSMutableDictionary new];
40
76
 
@@ -107,6 +143,9 @@
107
143
  case RGLDocReaderActionError:
108
144
  result = 3;
109
145
  break;
146
+ case RGLDocReaderActionProcessTimeout:
147
+ result = 10;
148
+ break;
110
149
  default:
111
150
  break;
112
151
  }
@@ -118,7 +157,7 @@
118
157
  NSInteger result = 0;
119
158
  switch (input) {
120
159
  case RGLRFIDCompleteActionComplete:
121
- result = 10;
160
+ result = 999;
122
161
  break;
123
162
  case RGLRFIDCompleteActionError:
124
163
  result = 3;
@@ -136,6 +175,29 @@
136
175
  return result;
137
176
  }
138
177
 
178
+ +(NSNumber*)generateRGLImageQualityCheckType:(RGLImageQualityCheckType)value {
179
+ if(value == RGLImageQualityCheckTypeImageGlares)
180
+ return @0;
181
+ else if(value == RGLImageQualityCheckTypeImageFocus)
182
+ return @1;
183
+ else if(value == RGLImageQualityCheckTypeImageResolution)
184
+ return @2;
185
+ else if(value == RGLImageQualityCheckTypeImageColorness)
186
+ return @3;
187
+ else if(value == RGLImageQualityCheckTypeImagePerspective)
188
+ return @4;
189
+ else if(value == RGLImageQualityCheckTypeImageBounds)
190
+ return @5;
191
+ else if(value == RGLImageQualityCheckTypeScreenCapture)
192
+ return @6;
193
+ else if(value == RGLImageQualityCheckTypePortrait)
194
+ return @7;
195
+ else if(value == RGLImageQualityCheckTypeHandwritten)
196
+ return @8;
197
+ else
198
+ return @0;
199
+ }
200
+
139
201
  +(NSInteger)generateRFIDNotificationAction:(RGLRFIDNotificationAction)input {
140
202
  return 5;
141
203
  }
@@ -155,6 +217,9 @@
155
217
  case 3:
156
218
  result[@"results"] = [self generateRGLDocumentReaderResults:results];
157
219
  break;
220
+ case 10:
221
+ result[@"results"] = [self generateRGLDocumentReaderResults:results];
222
+ break;
158
223
  case 5:
159
224
  result[@"results"] = [self generateResultsWithNotification:[self generateRGLRFIDNotify:notify]];
160
225
  break;
@@ -164,7 +229,7 @@
164
229
  case 8:
165
230
  result[@"results"] = [self generateRGLDocumentReaderResults:results];
166
231
  break;
167
- case 10:
232
+ case 999:
168
233
  result[@"results"] = [self generateResultsWithRFID :results :1];
169
234
  action = 1;
170
235
  break;
@@ -251,11 +316,9 @@
251
316
  [array addObject:[self generateRGLImageQualityGroup:item]];
252
317
  result[@"imageQuality"] = array;
253
318
  }
254
- result[@"overallResult"] = @(input.overallResult);
255
319
  result[@"authenticityResult"] = [self generateRGLDocumentReaderAuthenticityResult:input.authenticityResults];
256
320
  result[@"rfidSessionData"] = [self generateRGLRFIDSessionData:input.rfidSessionData];
257
321
  result[@"chipPage"] = @(input.chipPage);
258
- result[@"resolutionType"] = @(input.resolutionType);
259
322
  result[@"barcodeResult"] = [self generateRGLDocumentReaderBarcodeResult:input.barcodeResult];
260
323
  result[@"processingFinishedStatus"] = @(input.processingFinishedStatus);
261
324
  result[@"morePagesAvailable"] = @(input.morePagesAvailable);
@@ -400,7 +463,7 @@
400
463
  NSMutableDictionary *result = [NSMutableDictionary new];
401
464
  if(input == nil) return result;
402
465
 
403
- result[@"type"] = input.type;
466
+ result[@"type"] = [self generateRGLImageQualityCheckType:input.type];
404
467
  result[@"result"] = @(input.result);
405
468
  result[@"featureType"] = @(input.featureType);
406
469
  result[@"boundRects"] = [self generateNSArrayCGRect:input.boundRects];
@@ -571,7 +634,6 @@
571
634
  result[@"status"] = @(input.status);
572
635
  result[@"extLeSupport"] = @(input.extLeSupport);
573
636
  result[@"processTime"] = @(input.processTime);
574
- result[@"sessionDataStatus"] = [self generateRGLRFIDSessionDataStatus:input.sessionDataStatus];
575
637
 
576
638
  return result;
577
639
  }
@@ -170,6 +170,8 @@ RCT_EXPORT_METHOD(exec:(NSString*)moduleName:(NSString*)action:(NSArray*)args:(R
170
170
  [self startRFIDReader :successCallback :errorCallback];
171
171
  else if([action isEqualToString:@"stopRFIDReader"])
172
172
  [self stopRFIDReader :successCallback :errorCallback];
173
+ else if([action isEqualToString:@"stopRFIDReaderWithErrorMessage"])
174
+ [self stopRFIDReaderWithErrorMessage :[args objectAtIndex:0] :successCallback :errorCallback];
173
175
  else if([action isEqualToString:@"stopScanner"])
174
176
  [self stopScanner :successCallback :errorCallback];
175
177
  else if([action isEqualToString:@"deinitializeReader"])
@@ -226,6 +228,8 @@ RCT_EXPORT_METHOD(exec:(NSString*)moduleName:(NSString*)action:(NSArray*)args:(R
226
228
  [self prepareDatabase :[args objectAtIndex:0] :successCallback :errorCallback];
227
229
  else if([action isEqualToString:@"recognizeImage"])
228
230
  [self recognizeImage :[args objectAtIndex:0] :successCallback :errorCallback];
231
+ else if([action isEqualToString:@"recognizeData"])
232
+ [self recognizeData :[args objectAtIndex:0] :successCallback :errorCallback];
229
233
  else if([action isEqualToString:@"setRfidSessionStatus"])
230
234
  [self setRfidSessionStatus :[args objectAtIndex:0] :successCallback :errorCallback];
231
235
  else if([action isEqualToString:@"providePACertificates"])
@@ -238,20 +242,16 @@ RCT_EXPORT_METHOD(exec:(NSString*)moduleName:(NSString*)action:(NSArray*)args:(R
238
242
  [self parseCoreResults :[args objectAtIndex:0] :successCallback :errorCallback];
239
243
  else if([action isEqualToString:@"setTCCParams"])
240
244
  [self setTCCParams :[args objectAtIndex:0] :successCallback :errorCallback];
241
- else if([action isEqualToString:@"initializeReaderWithDatabase"])
242
- [self initializeReaderWithDatabase :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
243
- else if([action isEqualToString:@"recognizeImageFrame"])
244
- [self recognizeImageFrame :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
245
245
  else if([action isEqualToString:@"recognizeImageWithOpts"])
246
246
  [self recognizeImageWithOpts :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
247
247
  else if([action isEqualToString:@"recognizeVideoFrame"])
248
248
  [self recognizeVideoFrame :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
249
249
  else if([action isEqualToString:@"showScannerWithCameraIDAndOpts"])
250
250
  [self showScannerWithCameraIDAndOpts :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
251
- else if([action isEqualToString:@"recognizeImageWithImageInputParams"])
252
- [self recognizeImageWithImageInputParams :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
253
251
  else if([action isEqualToString:@"recognizeImageWithCameraMode"])
254
252
  [self recognizeImageWithCameraMode :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
253
+ else if([action isEqualToString:@"recognizeImagesWithImageInputs"])
254
+ [self recognizeImagesWithImageInputs :[args objectAtIndex:0] :successCallback :errorCallback];
255
255
  else
256
256
  [self result:[NSString stringWithFormat:@"%@/%@", @"method not implemented: ", action] :errorCallback];
257
257
  }
@@ -274,8 +274,10 @@ RCT_EXPORT_METHOD(exec:(NSString*)moduleName:(NSString*)action:(NSArray*)args:(R
274
274
  [self result:@"showScannerWithCameraID() is an android-only method" :errorCallback];
275
275
  }
276
276
 
277
- - (void) recognizeImageFrame:(NSString*)base64 :(NSDictionary*)opts :(Callback)successCallback :(Callback)errorCallback{
278
- [self result:@"recognizeImageFrame() is an android-only method" :errorCallback];
277
+ - (void) stopRFIDReaderWithErrorMessage:(NSMutableString*)message :(Callback)successCallback :(Callback)errorCallback{
278
+ [RGLDocReader.shared stopRFIDReaderWithErrorMessage:message completion:^() {
279
+ [self result:@"" :successCallback];
280
+ }];
279
281
  }
280
282
 
281
283
  - (void) recognizeImageWithOpts:(NSString*)base64 :(NSDictionary*)opts :(Callback)successCallback :(Callback)errorCallback{
@@ -290,20 +292,12 @@ RCT_EXPORT_METHOD(exec:(NSString*)moduleName:(NSString*)action:(NSArray*)args:(R
290
292
  [self result:@"showScannerWithCameraIDAndOpts() is an android-only method" :errorCallback];
291
293
  }
292
294
 
293
- - (void) recognizeImageWithImageInputParams:(NSString*)base64 :(NSDictionary*)params :(Callback)successCallback :(Callback)errorCallback{
294
- [self result:@"recognizeImageWithImageInputParams() is an android-only method" :errorCallback];
295
- }
296
-
297
295
  - (void) getLicenseMessage:(Callback)successCallback :(Callback)errorCallback{
298
296
  [self result:@"getLicenseMessage() is an android-only method" :successCallback];
299
297
  }
300
298
 
301
- - (void) initializeReaderWithDatabase:(NSString*)licenseString :(NSString*)databaseString :(Callback)successCallback :(Callback)errorCallback{
302
- [self result:@"initializeReaderWithDatabase() is an android-only method" :successCallback];
303
- }
304
-
305
- - (void) initializeReader:(NSString*)licenseString :(Callback)successCallback :(Callback)errorCallback{
306
- [RGLDocReader.shared initializeReaderWithConfig:[RGLConfig configWithLicenseData:[[NSData alloc] initWithBase64EncodedString:licenseString options:0]] completion:[self getInitCompletion :successCallback :errorCallback]];
299
+ - (void) initializeReader:(NSDictionary*)config :(Callback)successCallback :(Callback)errorCallback{
300
+ [RGLDocReader.shared initializeReaderWithConfig:[RGLWJSONConstructor RGLConfigFromJson:config] completion:[self getInitCompletion :successCallback :errorCallback]];
307
301
  }
308
302
 
309
303
  - (void) parseCoreResults:(NSString*)json :(Callback)successCallback :(Callback)errorCallback{
@@ -350,6 +344,10 @@ RCT_EXPORT_METHOD(exec:(NSString*)moduleName:(NSString*)action:(NSArray*)args:(R
350
344
  [self recognizeImageWith :base64 :false :successCallback :errorCallback];
351
345
  }
352
346
 
347
+ - (void) recognizeData:(NSString*)data :(Callback)successCallback :(Callback)errorCallback{
348
+ [RGLDocReader.shared recognizeData :[[NSData alloc] initWithBase64EncodedString:data options:0] completion:[self getCompletion]];
349
+ }
350
+
353
351
  - (void) recognizeImages:(NSArray*)input :(Callback)successCallback :(Callback)errorCallback{
354
352
  NSMutableArray<UIImage*>* images = [[NSMutableArray alloc] init];
355
353
  for(__strong NSMutableString* base64 in input)
@@ -359,6 +357,15 @@ RCT_EXPORT_METHOD(exec:(NSString*)moduleName:(NSString*)action:(NSArray*)args:(R
359
357
  });
360
358
  }
361
359
 
360
+ - (void) recognizeImagesWithImageInputs:(NSArray*)input :(Callback)successCallback :(Callback)errorCallback{
361
+ NSMutableArray<RGLImageInput*>* images = [[NSMutableArray alloc] init];
362
+ for(__strong NSDictionary* image in input)
363
+ [images addObject:[RGLWJSONConstructor RGLImageInputFromJson: image]];
364
+ dispatch_async(dispatch_get_main_queue(), ^{
365
+ [RGLDocReader.shared recognizeImagesWithImageInputs:images completion:[self getCompletion]];
366
+ });
367
+ }
368
+
362
369
  - (void) recognizeImageWithCameraMode:(NSMutableString*)base64 :(BOOL)cameraMode :(Callback)successCallback :(Callback)errorCallback{
363
370
  [self recognizeImageWith :base64 :cameraMode :successCallback :errorCallback];
364
371
  }
@@ -447,6 +447,37 @@
447
447
  return group;
448
448
  }
449
449
 
450
+ +(RGLOnlineProcessingConfig*)RGLOnlineProcessingConfigFromJSON:(NSDictionary*)dict {
451
+ if([dict valueForKey:@"mode"] == nil) return nil;
452
+
453
+ RGLOnlineProcessingConfig *result = [[RGLOnlineProcessingConfig alloc] initWithMode:[[dict valueForKey:@"mode"] integerValue]];
454
+
455
+ if([dict valueForKey:@"imageFormat"] != nil)
456
+ result.imageFormat = [[dict valueForKey:@"imageFormat"] integerValue];
457
+ if([dict valueForKey:@"url"] != nil)
458
+ result.serviceURL = [dict valueForKey:@"url"];
459
+ if([dict valueForKey:@"imageCompressionQuality"] != nil)
460
+ result.imageCompressionQuality = [[dict valueForKey:@"imageCompressionQuality"] floatValue];
461
+ if([dict valueForKey:@"processParams"] != nil) {
462
+ RGLProcessParams *params = [RGLProcessParams new];
463
+ [self setProcessParams:[dict valueForKey:@"processParams"] :params];
464
+ result.processParams = params;
465
+ }
466
+
467
+ return result;
468
+ }
469
+
470
+ +(RGLReprocParams*)RGLReprocParamsFromJSON:(NSDictionary*)dict {
471
+ RGLReprocParams *result = [RGLReprocParams new];
472
+
473
+ if([dict valueForKey:@"serviceUrl"] != nil)
474
+ result.serviceURL = [dict valueForKey:@"serviceUrl"];
475
+ if([dict valueForKey:@"failIfNoService"] != nil)
476
+ result.failIfNoService = [dict valueForKey:@"failIfNoService"];
477
+
478
+ return result;
479
+ }
480
+
450
481
  +(void)setCustomization:(NSDictionary*)options :(RGLCustomization*)customization {
451
482
  if([options valueForKey:@"cameraFrameBorderWidth"] != nil)
452
483
  customization.cameraFrameBorderWidth = [[options valueForKey:@"cameraFrameBorderWidth"] floatValue];
@@ -550,6 +581,8 @@
550
581
  customization.hologramAnimationPositionMultiplier = [[options valueForKey:@"hologramAnimationPositionMultiplier"] floatValue];
551
582
  if([options valueForKey:@"hologramAnimationImage"] != nil)
552
583
  customization.hologramAnimationImage = [self imageFromBase64:[options valueForKey:@"hologramAnimationImage"]];
584
+ if([options valueForKey:@"uiCustomizationLayer"] != nil)
585
+ customization.customUILayerJSON = [options valueForKey:@"uiCustomizationLayer"];
553
586
  }
554
587
 
555
588
  +(void)setFunctionality:(NSDictionary*)options :(RGLFunctionality*)functionality {
@@ -588,10 +621,6 @@
588
621
  functionality.singleResult = [[options valueForKey:@"singleResult"] boolValue];
589
622
  if([options valueForKey:@"cameraPosition"] != nil)
590
623
  functionality.cameraPosition = [self AVCaptureDevicePositionWithNSInteger:[[options valueForKey:@"cameraPosition"] integerValue]];
591
- if([options valueForKey:@"onlineMode"] != nil)
592
- functionality.onlineMode = [[options valueForKey:@"onlineMode"] boolValue];
593
- if([options valueForKey:@"serviceURL"] != nil)
594
- functionality.serviceURL = [[options valueForKey:@"serviceURL"] stringValue];
595
624
  if([options valueForKey:@"btDeviceName"] != nil)
596
625
  functionality.btDeviceName = [[options valueForKey:@"btDeviceName"] stringValue];
597
626
  if([options valueForKey:@"useAuthenticator"] != nil)
@@ -612,6 +641,8 @@
612
641
  functionality.recordScanningProcess = [[options valueForKey:@"recordScanningProcess"] boolValue];
613
642
  if([options valueForKey:@"manualMultipageMode"] != nil)
614
643
  functionality.manualMultipageMode = [[options valueForKey:@"manualMultipageMode"] boolValue];
644
+ if([options valueForKey:@"onlineProcessingConfiguration"] != nil)
645
+ functionality.onlineProcessingConfig = [self RGLOnlineProcessingConfigFromJSON:[options valueForKey:@"onlineProcessingConfiguration"]];;
615
646
  }
616
647
 
617
648
  +(void)setProcessParams:(NSDictionary*)options :(RGLProcessParams*)processParams {
@@ -755,6 +786,7 @@
755
786
  result[@"toolbarSize"] = [NSNumber numberWithFloat:customization.toolbarSize];
756
787
  result[@"hologramAnimationImageContentMode"] = [NSNumber numberWithInteger:[self NSIntegerWithUIViewContentMode:customization.hologramAnimationImageContentMode]];
757
788
  result[@"hologramAnimationPositionMultiplier"] = [NSNumber numberWithFloat:customization.hologramAnimationPositionMultiplier];
789
+ result[@"uiCustomizationLayer"] = customization.customUILayerJSON;
758
790
  result[@"hologramAnimationImage"] = [UIImageJPEGRepresentation(customization.hologramAnimationImage, 1.0) base64EncodedStringWithOptions:0];
759
791
  if(customization.customLabelStatus != nil)
760
792
  result[@"customLabelStatus"] = customization.customLabelStatus.string;
@@ -794,8 +826,6 @@
794
826
  result[@"videoSessionPreset"] = [NSNumber numberWithInteger:[self NSIntegerWithAVCaptureSessionPreset:functionality.videoSessionPreset]];
795
827
  result[@"videoCaptureMotionControl"] = [NSNumber numberWithBool:functionality.videoCaptureMotionControl];
796
828
  result[@"orientation"] = [NSNumber numberWithInteger:[self NSIntegerWithUIInterfaceOrientationMask:functionality.orientation]];
797
- result[@"onlineMode"] = [NSNumber numberWithBool:functionality.onlineMode];
798
- result[@"serviceURL"] = functionality.serviceURL;
799
829
  result[@"cameraPosition"] = [NSNumber numberWithInteger:[self NSIntegerWithAVCaptureDevicePosition:functionality.cameraPosition]];
800
830
  result[@"btDeviceName"] = functionality.btDeviceName;
801
831
  result[@"useAuthenticator"] = [NSNumber numberWithBool:functionality.isUseAuthenticator];
@@ -966,6 +996,10 @@
966
996
  rfidScenario.authorizedInstallCert = [[options valueForKey:@"authorizedInstallCert"] boolValue];
967
997
  if([options valueForKey:@"authorizedInstallQCert"] != nil)
968
998
  rfidScenario.authorizedInstallQCert = [[options valueForKey:@"authorizedInstallQCert"] boolValue];
999
+ if([options valueForKey:@"reprocessParams"] != nil)
1000
+ rfidScenario.reprocParams = [self RGLReprocParamsFromJSON: [options valueForKey:@"reprocessParams"]];
1001
+ if([options valueForKey:@"defaultReadingBufferSize"] != nil)
1002
+ rfidScenario.defaultReadingBufferSize = [[options valueForKey:@"defaultReadingBufferSize"] intValue];
969
1003
  }
970
1004
 
971
1005
  @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regulaforensics/react-native-document-reader-api",
3
- "version": "6.3.0",
3
+ "version": "6.5.0",
4
4
  "description": "React Native module for reading and validation of identification documents (API framework)",
5
5
  "main": "index.js",
6
6
  "scripts": {