Skip to content

Commit

Permalink
6.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins committed Apr 18, 2022
1 parent 302a85e commit 03020ec
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 22 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This repository contains the source code of the Document Reader API, and the sam
```bash
$ cd example
$ npm install
$ npx jetify
$ cordova prepare
```

Expand Down
1 change: 1 addition & 0 deletions example/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<preference name="AndroidXEnabled" value="true" />
<allow-intent href="market:*" />
<config-file parent="/*" target="AndroidManifest.xml">
<uses-permission android:name="android.permission.NFC" />
Expand Down
7 changes: 4 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
"cordova-android": "^9.0.0",
"cordova-ios": "^6.1.1",
"cordova-plugin-add-swift-support": "^2.0.2",
"@regulaforensics/cordova-plugin-document-reader-api": "^6.2.2",
"@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "^6.2.1",
"@regulaforensics/cordova-plugin-document-reader-api": "^6.3.0",
"@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "^6.3.0",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-image-picker": "^1.1.3",
"cordova-plugin-android-permissions": "1.1.0",
"cordova-plugin-advanced-http": "3.2.1"
"cordova-plugin-advanced-http": "3.2.1",
"jetifier": "^2.0.0"
},
"cordova": {
"plugins": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@regulaforensics/cordova-plugin-document-reader-api",
"version": "6.2.2",
"version": "6.3.0",
"description": "Cordova plugin for reading and validation of identification documents (API framework)",
"cordova": {
"id": "@regulaforensics/cordova-plugin-document-reader-api",
Expand Down
4 changes: 2 additions & 2 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-document-reader-api" version="6.2.2"
<plugin id="cordova-plugin-document-reader-api" version="6.3.0"
xmlns="http://apache.org/cordova/ns/plugins/1.0">
<name>DocumentReaderApi</name>
<description>Cordova plugin Document reader api</description>
Expand All @@ -25,7 +25,7 @@
<podspec>
<config/>
<pods>
<pod name="DocumentReader" spec="~> 6.2.2441" />
<pod name="DocumentReader" spec="~> 6.3.2494" />
</pods>
</podspec>
</platform>
Expand Down
23 changes: 16 additions & 7 deletions src/android/DocumentReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.regula.documentreader.api.completions.IRfidPKDCertificateCompletion;
import com.regula.documentreader.api.completions.IRfidReaderRequest;
import com.regula.documentreader.api.completions.IRfidTASignatureCompletion;
import com.regula.documentreader.api.completions.ITccParamsCompletion;
import com.regula.documentreader.api.enums.DocReaderAction;
import com.regula.documentreader.api.errors.DocumentReaderException;
import com.regula.documentreader.api.internal.core.CoreScenarioUtil;
Expand Down Expand Up @@ -325,8 +326,8 @@ public void error(String s) {
case "parseCoreResults":
parseCoreResults(callback, args(0));
break;
case "initializeReaderWithDatabasePath":
initializeReaderWithDatabasePath(callback, args(0), args(1));
case "setTCCParams":
setTCCParams(callback, args(0));
break;
case "initializeReaderWithDatabase":
initializeReaderWithDatabase(callback, args(0), args(1));
Expand Down Expand Up @@ -439,6 +440,10 @@ private void getDatabaseDocumentsNumber(Callback callback) {
callback.success(Instance().version.database.documentsNumber);
}

private void setTCCParams(Callback callback, final JSONObject params) {
Instance().setTccParams(JSONConstructor.TCCParamsFromJSON(params), getTCCParamsCompletion(callback));
}

private void deinitializeReader(Callback callback) {
Instance().deinitializeReader();
callback.success();
Expand Down Expand Up @@ -700,11 +705,6 @@ private void recognizeImageWithCameraMode(Callback callback, String base64, bool
callback.error("recognizeImageWithCameraMode() is an ios-only method");
}

@SuppressWarnings("unused")
private void initializeReaderWithDatabasePath(Callback callback, Object license, String path) {
callback.error("initializeReaderWithDatabasePath() is an ios-only method");
}

@SuppressWarnings("unused")
private void setRfidSessionStatus(Callback callback, String s) {
callback.error("setRfidSessionStatus() is an ios-only method");
Expand Down Expand Up @@ -752,6 +752,15 @@ private IDocumentReaderInitCompletion getInitCompletion(Callback callback) {
};
}

private ITccParamsCompletion getTCCParamsCompletion(Callback callback) {
return (success, error) -> {
if (success)
callback.success("success");
else
callback.error("failed: " + error.getMessage());
};
}

private IRfidReaderRequest getIRfidReaderRequest() {
return new IRfidReaderRequest() {
@Override
Expand Down
20 changes: 20 additions & 0 deletions src/android/JSONConstructor.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.regula.documentreader.api.errors.DocumentReaderException;
import com.regula.documentreader.api.internal.core.CoreDetailedScenario;
import com.regula.documentreader.api.params.FaceMetaData;
import com.regula.documentreader.api.params.rfid.TccParams;
import com.regula.documentreader.api.params.rfid.authorization.PAAttribute;
import com.regula.documentreader.api.params.rfid.authorization.PAResourcesIssuer;
import com.regula.documentreader.api.params.rfid.authorization.TAChallenge;
Expand Down Expand Up @@ -340,6 +341,25 @@ static DocumentReaderNotification DocumentReaderNotificationFromJSON(JSONObject
return result;
}

static TccParams TCCParamsFromJSON(JSONObject input) {
TccParams result = new TccParams();
try {
if (input.has("serviceUrlTA"))
result.setServiceUrlTA(input.getString("serviceUrlTA"));
if (input.has("serviceUrlPA"))
result.setServiceUrlPA(input.getString("serviceUrlPA"));
if (input.has("pfxCertUrl"))
result.setPfxCertUrl(input.getString("pfxCertUrl"));
if (input.has("pfxPassPhrase"))
result.setPfxPassPhrase(input.getString("pfxPassPhrase"));
if (input.has("pfxCert"))
result.setPfxCert(Base64.decode(input.getString("pfxCert"), Base64.DEFAULT));
} catch (JSONException e) {
e.printStackTrace();
}
return result;
}

static Throwable ThrowableFromJSON(JSONObject jsonObject) {
return new Throwable();
}
Expand Down
12 changes: 12 additions & 0 deletions src/android/RegulaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ private static void setCustomization(ParamsCustomization customization, JSONObje
editor.setToolbarSize(BigDecimal.valueOf(opts.getDouble("toolbarSize")).floatValue());
if (opts.has("statusBackgroundColor"))
editor.setStatusBackgroundColor(opts.getString("statusBackgroundColor"));
if (opts.has("hologramAnimationImage"))
editor.setHologramAnimationImage(drawableFromBase64(opts.getString("hologramAnimationImage"), context));
if (opts.has("hologramAnimationPositionMultiplier"))
editor.setHologramAnimationPositionMultiplier((float) opts.getDouble("hologramAnimationPositionMultiplier"));
if (opts.has("hologramAnimationImageMatrix"))
editor.setHologramAnimationImageMatrix(matrixFromFloatArray(floatArrayFromJson(opts.getJSONArray("hologramAnimationImageMatrix"))));
if (opts.has("hologramAnimationImageScaleType"))
editor.setHologramAnimationImageScaleType(ScaleType.valueOf(opts.getString("hologramAnimationImageScaleType")));

editor.applyImmediately(context);
}
Expand Down Expand Up @@ -423,6 +431,10 @@ private static JSONObject getCustomization(ParamsCustomization customization) th
object.put("changeFrameButtonCollapseImage", bitmapToBase64String(bitmapFromDrawable(customization.getChangeFrameCollapseButtonDrawable())));
object.put("toolbarSize", customization.getToolbarSize());
object.put("statusBackgroundColor", customization.getStatusBackgroundColor());
object.put("hologramAnimationImage", bitmapToBase64String(bitmapFromDrawable(customization.getHologramAnimationImage())));
object.put("hologramAnimationPositionMultiplier", customization.getHologramAnimationPositionMultiplier());
object.put("hologramAnimationImageMatrix", customization.getHologramAnimationImageMatrix());
object.put("hologramAnimationImageScaleType", customization.getHologramAnimationImageScaleType());

return object;
}
Expand Down
2 changes: 1 addition & 1 deletion src/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repositories {
}

dependencies {
implementation ('com.regula.documentreader:api:6.2.6779'){
implementation ('com.regula.documentreader:api:6.3.6939'){
transitive = true
}
}
21 changes: 15 additions & 6 deletions src/ios/RGLDocumentReader.m
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ - (void) exec:(CDVInvokedUrlCommand*)command {
[self provideTASignature :[args objectAtIndex:0] :successCallback :errorCallback];
else if([action isEqualToString:@"parseCoreResults"])
[self parseCoreResults :[args objectAtIndex:0] :successCallback :errorCallback];
else if([action isEqualToString:@"initializeReaderWithDatabasePath"])
[self initializeReaderWithDatabasePath :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
else if([action isEqualToString:@"setTCCParams"])
[self setTCCParams :[args objectAtIndex:0] :successCallback :errorCallback];
else if([action isEqualToString:@"initializeReaderWithDatabase"])
[self initializeReaderWithDatabase :[args objectAtIndex:0] :[args objectAtIndex:1] :successCallback :errorCallback];
else if([action isEqualToString:@"recognizeImageFrame"])
Expand Down Expand Up @@ -324,10 +324,6 @@ - (void) startRFIDReader:(Callback)successCallback :(Callback)errorCallback{
});
}

- (void) initializeReaderWithDatabasePath:(NSString*)licenseString :(NSString*)databasePath :(Callback)successCallback :(Callback)errorCallback{
[RGLDocReader.shared initializeReaderWithConfig:[RGLConfig configWithLicenseData:[[NSData alloc] initWithBase64EncodedString:licenseString options:0] licenseUpdateCheck:true databasePath:databasePath delayedNNLoadEnabled:false] completion:[self getInitCompletion :successCallback :errorCallback]];
}

- (void) prepareDatabase:(NSString*)dbID :(Callback)successCallback :(Callback)errorCallback{
[RGLDocReader.shared prepareDatabase:dbID progressHandler:[self getProgressHandler :successCallback :errorCallback] completion:[self getPrepareCompletion :successCallback :errorCallback]];
}
Expand Down Expand Up @@ -510,6 +506,10 @@ - (void) getDocumentReaderStatus:(Callback)successCallback :(Callback)errorCallb
[self result:RGLDocReader.shared.documentReaderStatus :successCallback];
}

- (void) setTCCParams:(NSDictionary*)params :(Callback)successCallback :(Callback)errorCallback{
[RGLDocReader.shared setTCCParams:[RGLWJSONConstructor RGLTCCParamsFromJson:params] completion:[self getTCCParamsCompletion:successCallback :errorCallback]];
}

- (void) getRfidSessionStatus:(Callback)successCallback :(Callback)errorCallback{
[self result:RGLDocReader.shared.rfidSessionStatus :successCallback];
}
Expand Down Expand Up @@ -636,4 +636,13 @@ -(RGLDocumentReaderPrepareCompletion _Nonnull)getPrepareCompletion:(Callback)suc
};
}

-(void (^_Nullable)(BOOL success, NSError * _Nullable error))getTCCParamsCompletion:(Callback)successCallback :(Callback)errorCallback{
return ^(BOOL success, NSError * _Nullable error) {
if (success)
[self result:@"success" :successCallback];
else
[self result:[NSString stringWithFormat:@"%@/%@", @"failed: ", error.description] :errorCallback];
};
}

@end
1 change: 1 addition & 0 deletions src/ios/RGLWJSONConstructor.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
+(NSMutableDictionary* _Nonnull)generateRfidNotificationCompletionWithError:(NSInteger)notification : (NSInteger)value;
+(NSMutableDictionary* _Nonnull)generateNSDictionary:(NSDictionary<NSNumber*, NSNumber*>* _Nullable)input;
+(RGLPKDCertificate* _Nullable)RGLPKDCertificateFromJson:(NSDictionary* _Nullable) dict;
+(RGLTCCParams* _Nonnull)RGLTCCParamsFromJson:(NSDictionary* _Nonnull)input;
+(NSInteger)generateDocReaderAction:(RGLDocReaderAction)action;
+(NSInteger)generateRFIDCompleteAction:(RGLRFIDCompleteAction)action;
+(NSInteger)generateRFIDNotificationAction:(RGLRFIDNotificationAction)action;
Expand Down
12 changes: 11 additions & 1 deletion src/ios/RGLWJSONConstructor.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ +(RGLPKDCertificate*)RGLPKDCertificateFromJson:(NSDictionary*)input {
return [[RGLPKDCertificate alloc] initWithBinaryData:binaryData resourceType:type privateKey:privateKey];
}

+(RGLTCCParams*)RGLTCCParamsFromJson:(NSDictionary*)input {
NSString* serviceTAURLString = [input valueForKey:@"serviceUrlTA"];
NSString* servicePAURLString = [input valueForKey:@"serviceUrlPA"];
NSString* pfxCertURLString = [input valueForKey:@"pfxCertUrl"];
NSString* pfxPassPhrase = [input valueForKey:@"pfxPassPhrase"];
NSData* pfxCertData = [input objectForKey:@"pfxCert"] != nil ? [[NSData alloc] initWithBase64EncodedString:[input objectForKey:@"pfxCert"] options:0] : nil;

return [[RGLTCCParams alloc] initWithServiceTAURLString:serviceTAURLString servicePAURLString:servicePAURLString pfxCertURLString:pfxCertURLString pfxCertData: pfxCertData pfxPassPhrase:pfxPassPhrase];
}

+(NSMutableDictionary*)generateCGPoint:(CGPoint)input {
NSMutableDictionary *result = [NSMutableDictionary new];

Expand Down Expand Up @@ -390,7 +400,7 @@ +(NSMutableDictionary* _Nonnull)generateRGLImageQuality:(RGLImageQuality* _Nulla
NSMutableDictionary *result = [NSMutableDictionary new];
if(input == nil) return result;

result[@"type"] = @(input.type);
result[@"type"] = input.type;
result[@"result"] = @(input.result);
result[@"featureType"] = @(input.featureType);
result[@"boundRects"] = [self generateNSArrayCGRect:input.boundRects];
Expand Down
16 changes: 16 additions & 0 deletions src/ios/RegulaConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ +(RGLImageQA*)ImageQAFromJson:(NSDictionary*)dict {
image.colornessCheck = [dict valueForKey:@"colornessCheck"];
if([dict valueForKey:@"moireCheck"] != nil)
image.moireCheck = [dict valueForKey:@"moireCheck"];
if([dict valueForKey:@"expectedPass"] != nil){
NSMutableArray<RGLImageQualityCheckType> *expectedPass = [NSMutableArray new];
for(NSString* str in [dict valueForKey:@"expectedPass"])
[expectedPass addObject:str];
image.expectedPass = expectedPass;
}

return image;
}
Expand All @@ -313,6 +319,7 @@ +(NSDictionary*)ImageQAToJson:(RGLImageQA*)input {
result[@"glaresCheck"] = input.glaresCheck;
result[@"colornessCheck"] = input.colornessCheck;
result[@"moireCheck"] = input.moireCheck;
result[@"expectedPass"] = input.expectedPass;

return result;
}
Expand Down Expand Up @@ -537,6 +544,12 @@ +(void)setCustomization:(NSDictionary*)options :(RGLCustomization*)customization
customization.toolbarSize = [[options valueForKey:@"toolbarSize"] floatValue];
if([options valueForKey:@"statusBackgroundColor"] != nil)
customization.statusBackgroundColor = [self getUIColorObjectFromHexString:[options valueForKey:@"statusBackgroundColor"] alpha:1];
if([options valueForKey:@"hologramAnimationImageContentMode"] != nil)
customization.hologramAnimationImageContentMode = [self UIViewContentModeWithNSInteger:[[options valueForKey:@"hologramAnimationImageContentMode"] integerValue]];
if([options valueForKey:@"hologramAnimationPositionMultiplier"] != nil)
customization.hologramAnimationPositionMultiplier = [[options valueForKey:@"hologramAnimationPositionMultiplier"] floatValue];
if([options valueForKey:@"hologramAnimationImage"] != nil)
customization.hologramAnimationImage = [self imageFromBase64:[options valueForKey:@"hologramAnimationImage"]];
}

+(void)setFunctionality:(NSDictionary*)options :(RGLFunctionality*)functionality {
Expand Down Expand Up @@ -740,6 +753,9 @@ +(NSMutableDictionary *)getCustomization:(RGLCustomization*)customization {
result[@"cameraFramePortraitAspectRatio"] = [NSNumber numberWithFloat:customization.cameraFramePortraitAspectRatio];
result[@"cameraFrameLandscapeAspectRatio"] = [NSNumber numberWithFloat:customization.cameraFrameLandscapeAspectRatio];
result[@"toolbarSize"] = [NSNumber numberWithFloat:customization.toolbarSize];
result[@"hologramAnimationImageContentMode"] = [NSNumber numberWithInteger:[self NSIntegerWithUIViewContentMode:customization.hologramAnimationImageContentMode]];
result[@"hologramAnimationPositionMultiplier"] = [NSNumber numberWithFloat:customization.hologramAnimationPositionMultiplier];
result[@"hologramAnimationImage"] = [UIImageJPEGRepresentation(customization.hologramAnimationImage, 1.0) base64EncodedStringWithOptions:0];
if(customization.customLabelStatus != nil)
result[@"customLabelStatus"] = customization.customLabelStatus.string;
if(customization.activityIndicatorColor != nil)
Expand Down
3 changes: 2 additions & 1 deletion www/DocumentReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,7 @@ const eImageQualityCheckType = {
IQC_BOUNDS: 5,
IQC_SCREEN_CAPTURE: 6,
IQC_PORTRAIT: 7,
IQC_HANDWRITTEN: 8,
}

const eLDS_ParsingErrorCodes = {
Expand Down Expand Up @@ -6081,7 +6082,7 @@ DocumentReader.providePACertificates = (certificates, successCallback, errorCall
DocumentReader.provideTACertificates = (certificates, successCallback, errorCallback) => cordova.exec(successCallback, errorCallback, "DocumentReader", "exec", ["provideTACertificates", certificates])
DocumentReader.provideTASignature = (certificates, successCallback, errorCallback) => cordova.exec(successCallback, errorCallback, "DocumentReader", "exec", ["provideTASignature", certificates])
DocumentReader.parseCoreResults = (json, successCallback, errorCallback) => cordova.exec(successCallback, errorCallback, "DocumentReader", "exec", ["parseCoreResults", json])
DocumentReader.initializeReaderWithDatabasePath = (license, path, successCallback, errorCallback) => cordova.exec(successCallback, errorCallback, "DocumentReader", "exec", ["initializeReaderWithDatabasePath", license, path])
DocumentReader.setTCCParams = (params, successCallback, errorCallback) => cordova.exec(successCallback, errorCallback, "DocumentReader", "exec", ["setTCCParams", params])
DocumentReader.initializeReaderWithDatabase = (license, db, successCallback, errorCallback) => cordova.exec(successCallback, errorCallback, "DocumentReader", "exec", ["initializeReaderWithDatabase", license, db])
DocumentReader.recognizeImageFrame = (image, params, successCallback, errorCallback) => cordova.exec(successCallback, errorCallback, "DocumentReader", "exec", ["recognizeImageFrame", image, params])
DocumentReader.recognizeImageWithOpts = (image, options, successCallback, errorCallback) => cordova.exec(successCallback, errorCallback, "DocumentReader", "exec", ["recognizeImageWithOpts", image, options])
Expand Down

0 comments on commit 03020ec

Please sign in to comment.