@regulaforensics/cordova-plugin-document-reader-api 7.4.590-rc → 7.5.19-rc

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.
@@ -1,5 +1,5 @@
1
1
  //
2
- // JSONConstructor.java
2
+ // JSONConstructor.kt
3
3
  // DocumentReader
4
4
  //
5
5
  // Created by Pavel Masiuk on 21.09.2023.
@@ -46,6 +46,7 @@ import com.regula.documentreader.api.params.rfid.TccParams
46
46
  import com.regula.documentreader.api.params.rfid.authorization.PAAttribute
47
47
  import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer
48
48
  import com.regula.documentreader.api.params.rfid.authorization.TAChallenge
49
+ import com.regula.documentreader.api.params.rfid.dg.DTCDataGroup
49
50
  import com.regula.documentreader.api.params.rfid.dg.EDLDataGroups
50
51
  import com.regula.documentreader.api.params.rfid.dg.EIDDataGroups
51
52
  import com.regula.documentreader.api.params.rfid.dg.EPassportDataGroups
@@ -243,6 +244,17 @@ fun generateDocReaderConfig(temp: DocReaderConfig?): JSONObject? {
243
244
  return result
244
245
  }
245
246
 
247
+ fun bleDeviceConfigFromJSON(input: JSONObject): BleDeviceConfig {
248
+ var result = BleDeviceConfig(bluetooth)
249
+
250
+ if (input.has("customDb")) result = BleDeviceConfig(bluetooth, byteArrayFromBase64(input.getString("customDb")))
251
+ if (input.has("licenseUpdate")) result.setLicenseUpdate(input.getBoolean("licenseUpdate"))
252
+ if (input.has("delayedNNLoad")) result.isDelayedNNLoad = input.getBoolean("delayedNNLoad")
253
+ if (input.has("blackList")) result.blackList = input.getJSONObject("blackList")
254
+
255
+ return result
256
+ }
257
+
246
258
  fun scannerConfigFromJSON(input: JSONObject): ScannerConfig {
247
259
  val builder = if (input.has("scenario")) ScannerConfig.Builder(input.getString("scenario"))
248
260
  else ScannerConfig.Builder(onlineProcessingConfigFromJSON(input.getJSONObject("onlineProcessingConfig"))!!)
@@ -274,6 +286,7 @@ fun recognizeConfigFromJSON(input: JSONObject): RecognizeConfig {
274
286
  else RecognizeConfig.Builder(onlineProcessingConfigFromJSON(input.getJSONObject("onlineProcessingConfig"))!!)
275
287
 
276
288
  if (input.has("oneShotIdentification")) builder.setOneShotIdentification(input.getBoolean("oneShotIdentification"))
289
+ if (input.has("dtc")) builder.setDTC(byteArrayFromBase64(input.getString("dtc"))!!)
277
290
  if (input.has("livePortrait")) builder.setLivePortrait(bitmapFromBase64(input.getString("livePortrait"))!!)
278
291
  if (input.has("extPortrait")) builder.setExtPortrait(bitmapFromBase64(input.getString("extPortrait"))!!)
279
292
  if (input.has("image")) builder.setBitmap(bitmapFromBase64(input.getString("image"))!!)
@@ -302,6 +315,7 @@ fun generateRecognizeConfig(temp: RecognizeConfig?): JSONObject? {
302
315
  result.put("scenario", input.scenario)
303
316
  result.put("onlineProcessingConfig", generateOnlineProcessingConfig(input.onlineProcessingConfig))
304
317
  result.put("oneShotIdentification", input.oneShotIdentification)
318
+ result.put("dtc", generateByteArray(input.dtc))
305
319
  result.put("livePortrait", bitmapToBase64(input.livePortrait))
306
320
  result.put("extPortrait", bitmapToBase64(input.extPortrait))
307
321
  result.put("image", bitmapToBase64(input.bitmap))
@@ -325,6 +339,7 @@ fun backendProcessingConfigFromJSON(temp: JSONObject?): BackendProcessingConfig?
325
339
  val result = BackendProcessingConfig(input.getString("url"))
326
340
  if (input.has("httpHeaders")) result.httpHeaders = stringMapFromJson(input.getJSONObject("httpHeaders"))
327
341
  if (input.has("rfidServerSideChipVerification")) result.rfidServerSideChipVerification = input.getBoolean("rfidServerSideChipVerification")
342
+ if (input.has("timeoutConnection")) result.timeoutConnection = input.getDouble("timeoutConnection")
328
343
 
329
344
  return result
330
345
  }
@@ -337,6 +352,7 @@ fun generateBackendProcessingConfig(temp: BackendProcessingConfig?): JSONObject?
337
352
  result.put("url", input.url)
338
353
  result.put("httpHeaders", generateStringMap(input.httpHeaders))
339
354
  result.put("rfidServerSideChipVerification", input.rfidServerSideChipVerification)
355
+ result.put("timeoutConnection", input.timeoutConnection)
340
356
 
341
357
  return result
342
358
  }
@@ -508,6 +524,14 @@ fun eIDDataGroupsFromJSON(input: JSONObject): EIDDataGroups {
508
524
 
509
525
  fun generateEIDDataGroups(input: EIDDataGroups): JSONObject = getDataGroups(input)
510
526
 
527
+ fun dtcDataGroupsFromJSON(input: JSONObject): DTCDataGroup {
528
+ val result = DTCDataGroup()
529
+ setDataGroups(result, input)
530
+ return result
531
+ }
532
+
533
+ fun generateDTCDataGroups(input: DTCDataGroup): JSONObject = getDataGroups(input)
534
+
511
535
  fun rfidScenarioFromJSON(input: JSONObject): RfidScenario {
512
536
  val result = RfidScenario()
513
537
  setRfidScenario(result, input)
@@ -573,18 +597,6 @@ fun generateTypeface(temp: Typeface?, size: Int? = null): JSONObject? {
573
597
  return result
574
598
  }
575
599
 
576
- fun bleDeviceConfigFromJSON(input: JSONObject): BleDeviceConfig {
577
- val bleWrapper = bleManager
578
- var result = BleDeviceConfig(bleWrapper)
579
-
580
- if (input.has("customDb")) result = BleDeviceConfig(bleWrapper!!, byteArrayFromBase64(input.getString("customDb")))
581
- if (input.has("licenseUpdate")) result.setLicenseUpdate(input.getBoolean("licenseUpdate"))
582
- if (input.has("delayedNNLoad")) result.isDelayedNNLoad = input.getBoolean("delayedNNLoad")
583
- if (input.has("blackList")) result.blackList = input.getJSONObject("blackList")
584
-
585
- return result
586
- }
587
-
588
600
  fun imageInputDataFromJSON(temp: JSONObject?): ImageInputData? {
589
601
  if (temp == null || !temp.has("image")) return null
590
602
  val input: JSONObject = temp
@@ -2168,6 +2180,7 @@ fun documentReaderResultsFromJSON(temp: JSONObject?): DocumentReaderResults? {
2168
2180
  result.documentType = listFromJSON(input.optJSONArray("documentType"), ::documentReaderDocumentTypeFromJSON)!!
2169
2181
  result.status = documentReaderResultsStatusFromJSON(input.optJSONObject("status"))!!
2170
2182
  result.vdsncData = vdsncDataFromJSON(input.optJSONObject("vdsncData")!!)
2183
+ result.dtcData = input.getString("dtcData")
2171
2184
  result.transactionInfo = transactionInfoFromJSON(input.optJSONObject("transactionInfo"))
2172
2185
 
2173
2186
  return result
@@ -2196,6 +2209,7 @@ fun generateDocumentReaderResults(temp: DocumentReaderResults?, context: Context
2196
2209
  result.put("documentType", generateList(input.documentType, ::generateDocumentReaderDocumentType))
2197
2210
  result.put("status", generateDocumentReaderResultsStatus(input.status))
2198
2211
  result.put("vdsncData", generateVDSNCData(input.vdsncData))
2212
+ result.put("dtcData", input.dtcData)
2199
2213
  result.put("transactionInfo", generateTransactionInfo(input.transactionInfo))
2200
2214
 
2201
2215
  return result
@@ -1,5 +1,5 @@
1
1
  //
2
- // Utils.java
2
+ // Utils.kt
3
3
  // DocumentReader
4
4
  //
5
5
  // Created by Pavel Masiuk on 21.09.2023.
@@ -225,7 +225,12 @@ fun CustomizationFont.setFont(editor: ParamsCustomization.CustomizationEditor, v
225
225
  }
226
226
 
227
227
  internal object Convert {
228
- fun byteArrayFromBase64(base64: String?) = base64?.let { Base64.decode(it, Base64.NO_WRAP) }
228
+ fun byteArrayFromBase64(base64: String?): ByteArray? {
229
+ var str = base64 ?: return null
230
+ if (str.startsWith("data")) str = str.substring(str.indexOf(",") + 1)
231
+ return Base64.decode(str, Base64.NO_WRAP)
232
+ }
233
+
229
234
  fun generateByteArray(array: ByteArray?) = array?.let { Base64.encodeToString(it, Base64.NO_WRAP) }
230
235
 
231
236
  fun bitmapFromBase64(base64: String?) = base64?.let {
@@ -1,5 +1,3 @@
1
- apply plugin: 'kotlin-android'
2
-
3
1
  android {
4
2
  compileSdk 34
5
3
 
@@ -16,7 +14,7 @@ repositories {
16
14
 
17
15
  dependencies {
18
16
  //noinspection GradleDependency
19
- implementation ('com.regula.documentreader:api:7.4.10108'){
17
+ implementation ('com.regula.documentreader:api:7.5.10417'){
20
18
  transitive = true
21
19
  }
22
20
  }
@@ -68,10 +68,6 @@
68
68
  if([options valueForKey:@"zoomFactor"] != nil)
69
69
  functionality.zoomFactor = [[options valueForKey:@"zoomFactor"] floatValue];
70
70
 
71
- // JSONObject
72
- if([options valueForKey:@"onlineProcessingConfiguration"] != nil)
73
- functionality.onlineProcessingConfig = [RGLWJSONConstructor onlineProcessingConfigFromJson:[options valueForKey:@"onlineProcessingConfiguration"]];
74
-
75
71
  // Custom
76
72
  // in android - cameraSize
77
73
  if([options valueForKey:@"videoSessionPreset"] != nil)
@@ -116,9 +112,6 @@
116
112
  // Float
117
113
  result[@"zoomFactor"] = [NSNumber numberWithFloat:functionality.zoomFactor];
118
114
 
119
- // JSONObject
120
- result[@"onlineProcessingConfiguration"] = [RGLWJSONConstructor generateOnlineProcessingConfig:functionality.onlineProcessingConfig];
121
-
122
115
  // Custom
123
116
  // in android - cameraSize
124
117
  result[@"videoSessionPreset"] = [self generateCaptureSessionPreset:functionality.videoSessionPreset];
@@ -180,6 +173,7 @@
180
173
  processParams.disablePerforationOCR = [options valueForKey:@"disablePerforationOCR"];
181
174
  if([options valueForKey:@"respectImageQuality"] != nil)
182
175
  processParams.respectImageQuality = [options valueForKey:@"respectImageQuality"];
176
+ if (options[@"strictImageQuality"]) processParams.strictImageQuality = options[@"strictImageQuality"];
183
177
  if([options valueForKey:@"splitNames"] != nil)
184
178
  processParams.splitNames = [options valueForKey:@"splitNames"];
185
179
  if([options valueForKey:@"doDetectCan"] != nil)
@@ -191,6 +185,9 @@
191
185
  if([options valueForKey:@"checkHologram"] != nil)
192
186
  processParams.checkHologram = [options valueForKey:@"checkHologram"];
193
187
  if (options[@"generateNumericCodes"]) processParams.generateNumericCodes = options[@"generateNumericCodes"];
188
+ if (options[@"strictBarcodeDigitalSignatureCheck"]) processParams.strictBarcodeDigitalSignatureCheck = options[@"strictBarcodeDigitalSignatureCheck"];
189
+ if (options[@"selectLongestNames"]) processParams.selectLongestNames = options[@"selectLongestNames"];
190
+ if (options[@"generateDTCVC"]) processParams.generateDTCVC = options[@"generateDTCVC"];
194
191
 
195
192
  // Int
196
193
  if([options valueForKey:@"measureSystem"] != nil)
@@ -308,12 +305,16 @@
308
305
  result[@"shouldReturnPackageForReprocess"] = processParams.shouldReturnPackageForReprocess;
309
306
  result[@"disablePerforationOCR"] = processParams.disablePerforationOCR;
310
307
  result[@"respectImageQuality"] = processParams.respectImageQuality;
308
+ result[@"strictImageQuality"] = processParams.strictImageQuality;
311
309
  result[@"splitNames"] = processParams.splitNames;
312
310
  result[@"doDetectCan"] = processParams.doDetectCan;
313
311
  result[@"useFaceApi"] = processParams.useFaceApi;
314
312
  result[@"useAuthenticityCheck"] = processParams.useAuthenticityCheck;
315
313
  result[@"checkHologram"] = processParams.checkHologram;
316
314
  result[@"generateNumericCodes"] = processParams.generateNumericCodes;
315
+ result[@"strictBarcodeDigitalSignatureCheck"] = processParams.strictBarcodeDigitalSignatureCheck;
316
+ result[@"selectLongestNames"] = processParams.selectLongestNames;
317
+ result[@"generateDTCVC"] = processParams.generateDTCVC;
317
318
 
318
319
  // Int
319
320
  result[@"measureSystem"] = [NSNumber numberWithInteger:processParams.measureSystem];
@@ -390,6 +391,8 @@
390
391
  customization.cameraFrameShapeType = [[options valueForKey:@"cameraFrameShapeType"] integerValue];
391
392
  if([options valueForKey:@"cameraFrameOffsetWidth"] != nil)
392
393
  customization.cameraFrameOffsetWidth = [[options valueForKey:@"cameraFrameOffsetWidth"] floatValue];
394
+ if(options[@"nextPageAnimationStartDelay"]) customization.nextPageAnimationStartDelay = [options[@"nextPageAnimationStartDelay"] floatValue];
395
+ if(options[@"nextPageAnimationEndDelay"]) customization.nextPageAnimationEndDelay = [options[@"nextPageAnimationEndDelay"] floatValue];
393
396
 
394
397
  // String
395
398
  if([options valueForKey:@"status"] != nil)
@@ -418,6 +421,8 @@
418
421
  customization.statusBackgroundColor = [self colorWithInt:[options valueForKey:@"statusBackgroundColor"]];
419
422
  if([options valueForKey:@"cameraPreviewBackgroundColor"] != nil)
420
423
  customization.cameraPreviewBackgroundColor = [self colorWithInt:[options valueForKey:@"cameraPreviewBackgroundColor"]];
424
+ if([options valueForKey:@"backgroundMaskColor"] != nil)
425
+ customization.backgroundMaskColor = [self colorWithInt:[options valueForKey:@"backgroundMaskColor"]];
421
426
 
422
427
  // Float
423
428
  if([options valueForKey:@"statusPositionMultiplier"] != nil)
@@ -516,6 +521,8 @@
516
521
  result[@"cameraFrameLineLength"] = [NSNumber numberWithFloat:customization.cameraFrameLineLength];
517
522
  result[@"cameraFrameShapeType"] = [NSNumber numberWithFloat:customization.cameraFrameShapeType];
518
523
  result[@"cameraFrameOffsetWidth"] = [NSNumber numberWithFloat:customization.cameraFrameOffsetWidth];
524
+ result[@"nextPageAnimationStartDelay"] = [NSNumber numberWithFloat:customization.nextPageAnimationStartDelay];
525
+ result[@"nextPageAnimationEndDelay"] = [NSNumber numberWithFloat:customization.nextPageAnimationEndDelay];
519
526
 
520
527
  // String
521
528
  result[@"status"] = customization.status;
@@ -532,6 +539,7 @@
532
539
  result[@"activityIndicatorColor"] = [self intWithColor:customization.activityIndicatorColor];
533
540
  result[@"statusBackgroundColor"] = [self intWithColor:customization.statusBackgroundColor];
534
541
  result[@"cameraPreviewBackgroundColor"] = [self intWithColor:customization.cameraPreviewBackgroundColor];
542
+ result[@"backgroundMaskColor"] = [self intWithColor:customization.backgroundMaskColor];
535
543
 
536
544
  // Float
537
545
  result[@"statusPositionMultiplier"] = [NSNumber numberWithFloat:customization.statusPositionMultiplier];
@@ -652,6 +660,8 @@
652
660
  rfidScenario.autoSettings = [[options valueForKey:@"autoSettings"] boolValue];
653
661
  if([options valueForKey:@"proceedReadingAlways"] != nil)
654
662
  rfidScenario.proceedReadingAlways = [[options valueForKey:@"proceedReadingAlways"] boolValue];
663
+ if(options[@"readDTC"]) rfidScenario.readDTC = [options[@"readDTC"] boolValue];
664
+ if(options[@"mrzStrictCheck"]) rfidScenario.mrzStrictCheck = options[@"mrzStrictCheck"];
655
665
 
656
666
  // Int
657
667
  if([options valueForKey:@"signManagementAction"] != nil)
@@ -686,6 +696,7 @@
686
696
  rfidScenario.eSignPINDefault = [options valueForKey:@"eSignPINDefault"];
687
697
  if([options valueForKey:@"eSignPINNewValue"] != nil)
688
698
  rfidScenario.eSignPINNewValue = [options valueForKey:@"eSignPINNewValue"];
699
+ if(options[@"cardAccess"]) rfidScenario.cardAccess = options[@"cardAccess"];
689
700
 
690
701
  // DataGroup
691
702
  if([options valueForKey:@"ePassportDataGroups"] != nil)
@@ -694,6 +705,7 @@
694
705
  [self setDataGroups :rfidScenario.eIDDataGroups dict:[options valueForKey:@"eIDDataGroups"]];
695
706
  if([options valueForKey:@"eDLDataGroups"] != nil)
696
707
  [self setDataGroups :rfidScenario.eDLDataGroups dict:[options valueForKey:@"eDLDataGroups"]];
708
+ if(options[@"dtcDataGroups"]) [self setDataGroups :rfidScenario.DTCDataGroups dict:options[@"dtcDataGroups"]];
697
709
  }
698
710
 
699
711
  +(NSDictionary*)getRfidScenario:(RGLRFIDScenario*)rfidScenario {
@@ -734,6 +746,8 @@
734
746
  result[@"applyAmendments"] = [NSNumber numberWithBool:rfidScenario.applyAmendments];
735
747
  result[@"autoSettings"] = [NSNumber numberWithBool:rfidScenario.autoSettings];
736
748
  result[@"proceedReadingAlways"] = [NSNumber numberWithBool:rfidScenario.proceedReadingAlways];
749
+ result[@"readDTC"] = [NSNumber numberWithBool:rfidScenario.readDTC];
750
+ result[@"mrzStrictCheck"] = rfidScenario.mrzStrictCheck;
737
751
 
738
752
  // Int
739
753
  result[@"signManagementAction"] = [NSNumber numberWithInteger:rfidScenario.signManagementAction];
@@ -753,11 +767,13 @@
753
767
  result[@"mrz"] = rfidScenario.mrz;
754
768
  result[@"eSignPINDefault"] = rfidScenario.eSignPINDefault;
755
769
  result[@"eSignPINNewValue"] = rfidScenario.eSignPINNewValue;
770
+ result[@"cardAccess"] = rfidScenario.cardAccess;
756
771
 
757
772
  // DataGroup
758
773
  result[@"eDLDataGroups"] = [self getDataGroups:rfidScenario.eDLDataGroups];
759
774
  result[@"ePassportDataGroups"] = [self getDataGroups:rfidScenario.ePassportDataGroups];
760
775
  result[@"eIDDataGroups"] = [self getDataGroups:rfidScenario.eIDDataGroups];
776
+ result[@"dtcDataGroups"] = [self getDataGroups:rfidScenario.DTCDataGroups];
761
777
 
762
778
  return result;
763
779
  }
@@ -819,6 +835,17 @@
819
835
  if([dict valueForKey:@"DG21"] != nil)
820
836
  ((RGLeIDDataGroup*)dataGroup).dG21 = [[dict valueForKey:@"DG21"] boolValue];
821
837
  }
838
+
839
+ // DTCDataGroups: 1-18 & 22-24
840
+ if ([dataGroup class] == [RGLDTCDataGroup class]) {
841
+ if(dict[@"DG15"]) ((RGLDTCDataGroup*)dataGroup).dG15 = [dict[@"DG15"] boolValue];
842
+ if(dict[@"DG16"]) ((RGLDTCDataGroup*)dataGroup).dG16 = [dict[@"DG16"] boolValue];
843
+ if(dict[@"DG17"]) ((RGLDTCDataGroup*)dataGroup).dG17 = [dict[@"DG17"] boolValue];
844
+ if(dict[@"DG18"]) ((RGLDTCDataGroup*)dataGroup).dG18 = [dict[@"DG18"] boolValue];
845
+ if(dict[@"DG22"]) ((RGLDTCDataGroup*)dataGroup).dG22 = [dict[@"DG22"] boolValue];
846
+ if(dict[@"DG23"]) ((RGLDTCDataGroup*)dataGroup).dG23 = [dict[@"DG23"] boolValue];
847
+ if(dict[@"DG24"]) ((RGLDTCDataGroup*)dataGroup).dG24 = [dict[@"DG24"] boolValue];
848
+ }
822
849
  }
823
850
 
824
851
  +(NSDictionary *)getDataGroups:(RGLDataGroup*)dataGroup {
@@ -857,6 +884,17 @@
857
884
  result[@"DG21"] = [NSNumber numberWithBool:((RGLeIDDataGroup*)dataGroup).dG21];
858
885
  }
859
886
 
887
+ // DTCDataGroups: 1-18 & 22-24
888
+ if ([dataGroup class] == [RGLDTCDataGroup class]) {
889
+ result[@"DG15"] = [NSNumber numberWithBool:((RGLDTCDataGroup*)dataGroup).dG15];
890
+ result[@"DG16"] = [NSNumber numberWithBool:((RGLDTCDataGroup*)dataGroup).dG16];
891
+ result[@"DG17"] = [NSNumber numberWithBool:((RGLDTCDataGroup*)dataGroup).dG17];
892
+ result[@"DG18"] = [NSNumber numberWithBool:((RGLDTCDataGroup*)dataGroup).dG18];
893
+ result[@"DG22"] = [NSNumber numberWithBool:((RGLDTCDataGroup*)dataGroup).dG22];
894
+ result[@"DG23"] = [NSNumber numberWithBool:((RGLDTCDataGroup*)dataGroup).dG23];
895
+ result[@"DG24"] = [NSNumber numberWithBool:((RGLDTCDataGroup*)dataGroup).dG24];
896
+ }
897
+
860
898
  return result;
861
899
  }
862
900
 
@@ -2,6 +2,7 @@
2
2
  #import <Foundation/Foundation.h>
3
3
  #import "RGLWJSONConstructor.h"
4
4
  #import "RGLWConfig.h"
5
+ #import <CoreBluetooth/CoreBluetooth.h>
5
6
  #import <DocumentReader/DocumentReader.h>
6
7
 
7
8
  @class DocReader;
@@ -13,7 +14,9 @@ typedef void (^RGLWRFIDSignatureCallback)(NSData * _Nonnull signature);
13
14
  @interface RGLWDocumentReader : CDVPlugin<RGLRecordScanningProcessDelegate,
14
15
  RGLDocReaderRFIDDelegate,
15
16
  RGLCustomizationActionDelegate,
16
- RGLDocReaderDatabaseFetchDelegate>
17
+ RGLDocReaderDatabaseFetchDelegate,
18
+ RGLBluetoothDelegate,
19
+ CBCentralManagerDelegate>
17
20
 
18
21
  @property (class) CDVInvokedUrlCommand* _Nullable command;
19
22
  @property NSNumber* _Nonnull doRequestPACertificates;
@@ -39,10 +39,6 @@ static RGLWEventSender sendEvent = ^(NSString* event, id data) {
39
39
  [self getDocumentReaderIsReady :successCallback :errorCallback];
40
40
  else if([action isEqualToString:@"getDocumentReaderStatus"])
41
41
  [self getDocumentReaderStatus :successCallback :errorCallback];
42
- else if([action isEqualToString:@"isAuthenticatorAvailableForUse"])
43
- [self isAuthenticatorAvailableForUse :successCallback :errorCallback];
44
- else if([action isEqualToString:@"isBlePermissionsGranted"])
45
- [self isBlePermissionsGranted :successCallback :errorCallback];
46
42
  else if([action isEqualToString:@"getRfidSessionStatus"])
47
43
  [self getRfidSessionStatus :successCallback :errorCallback];
48
44
  else if([action isEqualToString:@"setRfidSessionStatus"])
@@ -121,8 +117,8 @@ static RGLWEventSender sendEvent = ^(NSString* event, id data) {
121
117
  [self clearPKDCertificates :successCallback :errorCallback];
122
118
  else if([action isEqualToString:@"startNewSession"])
123
119
  [self startNewSession :successCallback :errorCallback];
124
- else if([action isEqualToString:@"startBluetoothService"])
125
- [self startBluetoothService :successCallback :errorCallback];
120
+ else if([action isEqualToString:@"connectBluetoothDevice"])
121
+ [self connectBluetoothDevice :[args objectAtIndex:0] :successCallback :errorCallback];
126
122
  else if([action isEqualToString:@"setLocalizationDictionary"])
127
123
  [self setLocalizationDictionary :[args objectAtIndex:0] :successCallback :errorCallback];
128
124
  else if([action isEqualToString:@"getLicense"])
@@ -131,6 +127,10 @@ static RGLWEventSender sendEvent = ^(NSString* event, id data) {
131
127
  [self getAvailableScenarios :successCallback :errorCallback];
132
128
  else if([action isEqualToString:@"getIsRFIDAvailableForUse"])
133
129
  [self getIsRFIDAvailableForUse :successCallback :errorCallback];
130
+ else if([action isEqualToString:@"isAuthenticatorRFIDAvailableForUse"])
131
+ [self isAuthenticatorRFIDAvailableForUse :successCallback :errorCallback];
132
+ else if([action isEqualToString:@"isAuthenticatorAvailableForUse"])
133
+ [self isAuthenticatorAvailableForUse :successCallback :errorCallback];
134
134
  else if([action isEqualToString:@"getDocReaderVersion"])
135
135
  [self getDocReaderVersion :successCallback :errorCallback];
136
136
  else if([action isEqualToString:@"getDocReaderDocumentsDatabase"])
@@ -171,6 +171,8 @@ static RGLWEventSender sendEvent = ^(NSString* event, id data) {
171
171
  [self encryptedContainers :[args objectAtIndex:0] :successCallback :errorCallback];
172
172
  else if([action isEqualToString:@"finalizePackage"])
173
173
  [self finalizePackage :successCallback :errorCallback];
174
+ else if([action isEqualToString:@"endBackendTransaction"])
175
+ [self endBackendTransaction :successCallback :errorCallback];
174
176
  else if([action isEqualToString:@"getTranslation"])
175
177
  [self getTranslation :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
176
178
  else
@@ -188,10 +190,6 @@ NSString* RGLWPaCertificateCompletionEvent = @"pa_certificate_completion";
188
190
  NSString* RGLWTaCertificateCompletionEvent = @"ta_certificate_completion";
189
191
  NSString* RGLWTaSignatureCompletionEvent = @"ta_signature_completion";
190
192
 
191
- NSString* RGLWBleOnServiceConnectedEvent = @"bleOnServiceConnectedEvent";
192
- NSString* RGLWBleOnServiceDisconnectedEvent = @"bleOnServiceDisconnectedEvent";
193
- NSString* RGLWBleOnDeviceReadyEvent = @"bleOnDeviceReadyEvent";
194
-
195
193
  NSString* RGLWVideoEncoderCompletionEvent = @"video_encoder_completion";
196
194
  NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
197
195
 
@@ -203,14 +201,6 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
203
201
  successCallback(RGLDocReader.shared.documentReaderStatus);
204
202
  }
205
203
 
206
- - (void) isAuthenticatorAvailableForUse:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
207
- successCallback(RGLDocReader.shared.isAuthenticatorAvailableForUse ? @YES : @NO);
208
- }
209
-
210
- - (void) isBlePermissionsGranted:(RGLWCallback)successCallback :(RGLWCallback)errorCallback {
211
- errorCallback(@"isBlePermissionsGranted() is an android-only method");
212
- }
213
-
214
204
  - (void) getRfidSessionStatus:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
215
205
  successCallback(RGLDocReader.shared.rfidSessionStatus);
216
206
  }
@@ -290,7 +280,7 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
290
280
  }
291
281
 
292
282
  - (void) initializeReaderWithBleDeviceConfig:(NSDictionary*)config :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
293
- errorCallback(@"initializeReaderWithBleDeviceConfig() is an android-only method");
283
+ [RGLDocReader.shared initializeReaderWithConfig:[RGLWJSONConstructor bleDeviceConfigFromJson:config :bluetooth] completion:[self getInitCompletion :successCallback :errorCallback]];
294
284
  }
295
285
 
296
286
  - (void) deinitializeReader:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
@@ -434,8 +424,55 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
434
424
  successCallback(@"");
435
425
  }
436
426
 
437
- - (void) startBluetoothService:(RGLWCallback)successCallback :(RGLWCallback)errorCallback {
438
- errorCallback(@"startBluetoothService() is an android-only method");
427
+ RGLBluetooth* bluetooth;
428
+ CBCentralManager* centralManager;
429
+ RGLWCallback savedCallbackForBluetoothResult;
430
+
431
+ - (void) connectBluetoothDevice:(NSString*)deviceName :(RGLWCallback)successCallback :(RGLWCallback)errorCallback {
432
+ // register callback for user's answer to bluetooth permission
433
+ centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
434
+
435
+ // return if already connected
436
+ if (bluetooth && bluetooth.state == RGLBluetoothConnectionStateConnected) return;
437
+
438
+ // start searching devices
439
+ if (!bluetooth) {
440
+ bluetooth = [RGLBluetooth new];
441
+ bluetooth.delegate = self;
442
+ }
443
+ savedCallbackForBluetoothResult = successCallback;
444
+ [bluetooth connectWithDeviceName:deviceName];
445
+ }
446
+
447
+ // CBCentralManagerDelegate
448
+ - (void)centralManagerDidUpdateState:(CBCentralManager *)central {
449
+ if (central.state != CBManagerStatePoweredOn && savedCallbackForBluetoothResult)
450
+ [self bluetoothDeviceConnectionFailed];
451
+ }
452
+
453
+ // RGLBluetoothDelegate
454
+ - (void)didChangeConnectionState:(RGLBluetooth *)bluetooth state:(RGLBluetoothConnectionState)state {
455
+ if (state == RGLBluetoothConnectionStateNone && savedCallbackForBluetoothResult)
456
+ [self bluetoothDeviceConnectionFailed];
457
+
458
+ // set searching timeout
459
+ if (state == RGLBluetoothConnectionStateSearching)
460
+ [self performSelector:NSSelectorFromString(@"bluetoothDeviceConnectionFailed") withObject:nil afterDelay:7.0];
461
+
462
+ if (state == RGLBluetoothConnectionStateConnected) {
463
+ savedCallbackForBluetoothResult(@YES);
464
+ savedCallbackForBluetoothResult = nil;
465
+ [NSObject cancelPreviousPerformRequestsWithTarget:self selector:NSSelectorFromString(@"bluetoothDeviceConnectionFailed") object:nil];
466
+ }
467
+ }
468
+
469
+ - (void) bluetoothDeviceConnectionFailed {
470
+ if (savedCallbackForBluetoothResult) {
471
+ savedCallbackForBluetoothResult(@NO);
472
+ savedCallbackForBluetoothResult = nil;
473
+ }
474
+ [bluetooth stopSearchDevices];
475
+ [bluetooth disconnect];
439
476
  }
440
477
 
441
478
  - (void) setLocalizationDictionary:(NSDictionary*)dictionary :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
@@ -466,6 +503,14 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
466
503
  successCallback([RGLWJSONConstructor generateDocReaderVersion:RGLDocReader.shared.version]);
467
504
  }
468
505
 
506
+ - (void) isAuthenticatorRFIDAvailableForUse:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
507
+ successCallback(RGLDocReader.shared.isAuthenticatorRFIDAvailableForUse ? @YES : @NO);
508
+ }
509
+
510
+ - (void) isAuthenticatorAvailableForUse:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
511
+ successCallback(RGLDocReader.shared.isAuthenticatorAvailableForUse ? @YES : @NO);
512
+ }
513
+
469
514
  - (void) getDocReaderDocumentsDatabase:(RGLWCallback)successCallback :(RGLWCallback)errorCallback {
470
515
  if(RGLDocReader.shared.version != nil)
471
516
  successCallback([RGLWJSONConstructor dictToString:[RGLWJSONConstructor generateDocReaderDocumentsDatabase:RGLDocReader.shared.version.database]]);
@@ -579,6 +624,11 @@ NSString* RGLWOnCustomButtonTappedEvent = @"onCustomButtonTappedEvent";
579
624
  }];
580
625
  }
581
626
 
627
+ - (void) endBackendTransaction:(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
628
+ [RGLDocReader.shared endBackendTransaction];
629
+ successCallback(@"");
630
+ }
631
+
582
632
  - (void) getTranslation:(NSString*)className :(NSNumber*)value :(RGLWCallback)successCallback :(RGLWCallback)errorCallback{
583
633
  if([className isEqualToString:@"RFIDErrorCodes"])
584
634
  successCallback(RGLRFIDErrorCodesGetStringValue([value intValue]));
@@ -30,6 +30,7 @@
30
30
 
31
31
  +(RGLConfig* _Nullable)configFromJson:(NSDictionary* _Nullable)input;
32
32
  +(NSDictionary* _Nullable)generateConfig:(RGLConfig* _Nullable)input;
33
+ +(RGLBleConfig* _Nullable)bleDeviceConfigFromJson:(NSDictionary* _Nullable)input :(RGLBluetooth* _Nonnull)bluetooth;
33
34
  +(RGLOnlineProcessingConfig* _Nullable)onlineProcessingConfigFromJson:(NSDictionary* _Nullable)input;
34
35
  +(NSDictionary* _Nullable)generateOnlineProcessingConfig:(RGLOnlineProcessingConfig* _Nullable)input;
35
36
  +(RGLImageInput* _Nullable)imageInputFromJson:(NSDictionary* _Nullable)input;
@@ -62,6 +63,8 @@
62
63
  +(NSDictionary* _Nullable)generateEPassportDataGroups:(RGLePassportDataGroup* _Nullable)input;
63
64
  +(RGLeIDDataGroup* _Nullable)eIDDataGroupsFromJson:(NSDictionary* _Nullable)input;
64
65
  +(NSDictionary* _Nullable)generateEIDDataGroups:(RGLeIDDataGroup* _Nullable)input;
66
+ +(RGLeIDDataGroup* _Nullable)dtcDataGroupsFromJson:(NSDictionary* _Nullable)input;
67
+ +(NSDictionary* _Nullable)generateRGLDTCDataGroups:(RGLeIDDataGroup* _Nullable)input;
65
68
  +(RGLRFIDScenario* _Nullable)rfidScenarioFromJson:(NSDictionary* _Nullable)input;
66
69
  +(NSDictionary* _Nullable)generateRFIDScenario:(RGLRFIDScenario* _Nullable)input;
67
70
  +(RGLCustomization* _Nullable)customizationFromJson:(NSDictionary* _Nullable)input;
@@ -23,6 +23,7 @@
23
23
 
24
24
  +(NSData*)base64Decode:(NSString*)input {
25
25
  if(input == nil) return nil;
26
+ if ([input hasPrefix:@"data"]) input = [input substringFromIndex:[input rangeOfString:@","].location + 1];
26
27
  return [[NSData alloc] initWithBase64EncodedString:input options:0];
27
28
  }
28
29
 
@@ -166,6 +167,17 @@
166
167
  return result;
167
168
  }
168
169
 
170
+ +(RGLBleConfig*)bleDeviceConfigFromJson:(NSDictionary*)input :(RGLBluetooth*)bluetooth {
171
+ if (!input) return nil;
172
+ RGLBleConfig *config = [[RGLBleConfig alloc] initWithBluetooth:bluetooth];
173
+
174
+ if (input[@"databasePath"]) config.databasePath = [[NSBundle mainBundle] pathForResource:input[@"databasePath"] ofType:nil];
175
+ if (input[@"licenseUpdate"]) config.licenseUpdateCheck = [input[@"licenseUpdate"] boolValue];
176
+ if (input[@"delayedNNLoad"]) config.delayedNNLoadEnabled = [input[@"delayedNNLoad"] boolValue];
177
+
178
+ return config;
179
+ }
180
+
169
181
  +(RGLScannerConfig*)scannerConfigFromJson:(NSDictionary*)input {
170
182
  RGLScannerConfig *config = [RGLScannerConfig alloc];
171
183
  if (input[@"scenario"]) config = [config initWithScenario:input[@"scenario"]];
@@ -216,7 +228,8 @@
216
228
  if (input[@"scenario"]) config.scenario = input[@"scenario"];
217
229
  if (input[@"livePortrait"]) config.livePortrait = [self imageWithBase64:input[@"livePortrait"]];
218
230
  if (input[@"extPortrait"]) config.extPortrait = [self imageWithBase64:input[@"extPortrait"]];
219
- if (input[@"oneShotIdentification"]) config.oneShotIdentification = input[@"oneShotIdentification"];
231
+ if (input[@"oneShotIdentification"]) config.oneShotIdentification = input[@"oneShotIdentification"];
232
+ if (input[@"dtc"]) config.dtc = [RGLWJSONConstructor base64Decode:input[@"dtc"]];
220
233
 
221
234
  return config;
222
235
  }
@@ -230,6 +243,7 @@
230
243
  result[@"livePortrait"] = [self base64WithImage: input.livePortrait];
231
244
  result[@"extPortrait"] = [self base64WithImage: input.extPortrait];
232
245
  result[@"oneShotIdentification"] = @(input.oneShotIdentification);
246
+ result[@"dtc"] = [self base64Encode: input.dtc];
233
247
  result[@"image"] = [self base64WithImage: input.image];
234
248
  result[@"data"] = [self base64Encode: input.imageData];
235
249
  if(input.images != nil) {
@@ -258,6 +272,7 @@
258
272
  result.httpHeaders = [input valueForKey:@"httpHeaders"];
259
273
  if([input valueForKey:@"rfidServerSideChipVerification"] != nil)
260
274
  result.rfidServerSideChipVerification = [input valueForKey:@"rfidServerSideChipVerification"];
275
+ if (input[@"timeoutConnection"]) result.timeoutConnection = input[@"timeoutConnection"];
261
276
 
262
277
  return result;
263
278
  }
@@ -269,6 +284,7 @@
269
284
  result[@"url"] = input.url;
270
285
  result[@"httpHeaders"] = input.httpHeaders;
271
286
  result[@"rfidServerSideChipVerification"] = input.rfidServerSideChipVerification;
287
+ result[@"timeoutConnection"] = input.timeoutConnection;
272
288
 
273
289
  return result;
274
290
  }
@@ -333,6 +349,16 @@
333
349
  return [RGLWConfig getDataGroups:input];
334
350
  }
335
351
 
352
+ +(RGLDTCDataGroup*)dtcDataGroupsFromJson:(NSDictionary*)input {
353
+ RGLDTCDataGroup *result = [RGLDTCDataGroup new];
354
+ [RGLWConfig setDataGroups :result dict:input];
355
+ return result;
356
+ }
357
+
358
+ +(NSDictionary*)generateRGLDTCDataGroups:(RGLDTCDataGroup*)input {
359
+ return [RGLWConfig getDataGroups:input];
360
+ }
361
+
336
362
  +(RGLRFIDScenario*)rfidScenarioFromJson:(NSDictionary*)input {
337
363
  RGLRFIDScenario *result = [RGLRFIDScenario new];
338
364
  [RGLWConfig setRfidScenario:input :result];
@@ -2220,7 +2246,7 @@
2220
2246
  [imageQuality addObject:[self imageQualityGroupFromJson:item]];
2221
2247
  }
2222
2248
 
2223
- return [[RGLDocumentReaderResults alloc]
2249
+ RGLDocumentReaderResults* result = [[RGLDocumentReaderResults alloc]
2224
2250
  initWithDocumentTypes:documentType
2225
2251
  textResult:[self documentReaderTextResultFromJson: [input valueForKey:@"textResult"]]
2226
2252
  graphicResult:[self documentReaderGraphicResultFromJson: [input valueForKey:@"graphicResult"]]
@@ -2240,6 +2266,10 @@
2240
2266
  elapsedTime:[[input valueForKey:@"elapsedTime"] integerValue]
2241
2267
  elapsedTimeRFID:[[input valueForKey:@"elapsedTimeRFID"] integerValue]
2242
2268
  transactionInfo:[self transactionInfoFromJson:[input valueForKey:@"transactionInfo"]]];
2269
+
2270
+ [result setValue:[RGLWJSONConstructor base64Decode:input[@"dtcData"]] forKey:@"dtcData"];
2271
+
2272
+ return result;
2243
2273
  }
2244
2274
 
2245
2275
  +(NSDictionary*)generateDocumentReaderResults:(RGLDocumentReaderResults*)input {
@@ -2289,6 +2319,7 @@
2289
2319
  result[@"rawResult"] = input.rawResult;
2290
2320
  result[@"status"] = [self generateDocumentReaderResultsStatus:input.status];
2291
2321
  result[@"vdsncData"] = [self generateVDSNCData:input.vdsncData];
2322
+ result[@"dtcData"] = [self base64Encode: input.dtcData];
2292
2323
  result[@"transactionInfo"] = [self generateTransactionInfo:input.transactionInfo];
2293
2324
 
2294
2325
  return result;