Skip to content

Commit

Permalink
chore(release): set package.json to 1.0.2 [skip ci]
Browse files Browse the repository at this point in the history
## [1.0.2](v1.0.1...v1.0.2) (2022-01-06)

### Bug Fixes

* add missing build phase ([3cd9e20](3cd9e20))
  • Loading branch information
semantic-release-bot committed Jan 6, 2022
1 parent 3cd9e20 commit d03028e
Show file tree
Hide file tree
Showing 9 changed files with 673 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [1.0.2](https://github.com/onz-software/expo-combateafraude/compare/v1.0.1...v1.0.2) (2022-01-06)


### Bug Fixes

* add missing build phase ([3cd9e20](https://github.com/onz-software/expo-combateafraude/commit/3cd9e20951850f10881f95faa0b0d9866a4efa6a))

## [1.0.1](https://github.com/onz-software/expo-combateafraude/compare/v1.0.0...v1.0.1) (2022-01-06)


Expand Down
203 changes: 203 additions & 0 deletions build/android/CombateAFraudeModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
package [[PACKAGE]];

import android.app.Activity;
import android.content.Intent;

import com.combateafraude.documentdetector.input.CaptureMode;
import com.combateafraude.documentdetector.input.CaptureStage;
import com.combateafraude.faceauthenticator.FaceAuthenticatorActivity;
import com.combateafraude.faceauthenticator.input.FaceAuthenticator;
import com.combateafraude.faceauthenticator.output.FaceAuthenticatorResult;
import com.facebook.react.bridge.*;
import com.facebook.react.modules.core.DeviceEventManagerModule;

import org.jetbrains.annotations.NotNull;

import com.combateafraude.passivefaceliveness.input.PassiveFaceLiveness;
import com.combateafraude.passivefaceliveness.PassiveFaceLivenessActivity;
import com.combateafraude.passivefaceliveness.output.PassiveFaceLivenessResult;

import com.combateafraude.documentdetector.output.Capture;
import com.combateafraude.documentdetector.input.DocumentDetector;
import com.combateafraude.documentdetector.output.DocumentDetectorResult;
import com.combateafraude.documentdetector.input.Document;
import com.combateafraude.documentdetector.input.DocumentDetectorStep;
import com.combateafraude.documentdetector.DocumentDetectorActivity;

public class CombateAFraudeModule extends ReactContextBaseJavaModule {

private final int REQUEST_CODE_PASSIVE_FACE_LIVENESS = 50005;
private final int REQUEST_CODE_DOCUMENT_DETECTOR = 50006;
private final int REQUEST_CODE_FACE_AUTHENTICATOR = 50007;

CombateAFraudeModule(ReactApplicationContext reactContext) {
super(reactContext);
ActivityEventListener activityEventListener = new BaseActivityEventListener() {

@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent intent) {
try {
if (requestCode == REQUEST_CODE_PASSIVE_FACE_LIVENESS) {
if (intent == null) {
getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("PassiveFaceLiveness_Cancel", null);
return;
}

PassiveFaceLivenessResult passiveFaceLivenessResult = (PassiveFaceLivenessResult) intent.getSerializableExtra(PassiveFaceLivenessResult.PARAMETER_NAME);
if (passiveFaceLivenessResult.wasSuccessful()) {
WritableMap writableMap = new WritableNativeMap();

writableMap.putString("imagePath", passiveFaceLivenessResult.getImagePath());
writableMap.putString("imageUrl", passiveFaceLivenessResult.getImageUrl());
writableMap.putString("signedResponse", passiveFaceLivenessResult.getSignedResponse());
writableMap.putString("trackingId", passiveFaceLivenessResult.getTrackingId());

getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("PassiveFaceLiveness_Success", writableMap);
} else {
WritableMap writableMap = new WritableNativeMap();

writableMap.putString("message", passiveFaceLivenessResult.getSdkFailure().getMessage());
writableMap.putString("type", passiveFaceLivenessResult.getSdkFailure().getClass().getSimpleName());

getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("PassiveFaceLiveness_Error", writableMap);
}

} else if (requestCode == REQUEST_CODE_DOCUMENT_DETECTOR) {
if (intent == null) {
getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("DocumentDetector_Cancel", null);
return;
}

DocumentDetectorResult documentDetectorResult = (DocumentDetectorResult) intent.getSerializableExtra(DocumentDetectorResult.PARAMETER_NAME);
if (documentDetectorResult.wasSuccessful()) {
WritableMap writableMap = new WritableNativeMap();

WritableArray capturesArray = new WritableNativeArray();
for (Capture capture : documentDetectorResult.getCaptures()) {
WritableMap captureMap = new WritableNativeMap();

captureMap.putString("imagePath", capture.getImagePath());
captureMap.putString("imageUrl", capture.getImageUrl());
captureMap.putString("label", capture.getLabel());
captureMap.putDouble("quality", capture.getQuality() != null ? capture.getQuality() : 0.0);

capturesArray.pushMap(captureMap);
}
writableMap.putArray("captures", capturesArray);

writableMap.putString("type", documentDetectorResult.getType());
writableMap.putString("trackingId", documentDetectorResult.getTrackingId());
getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("DocumentDetector_Success", writableMap);
} else {
WritableMap writableMap = new WritableNativeMap();

writableMap.putString("message", documentDetectorResult.getSdkFailure().getMessage());
writableMap.putString("type", documentDetectorResult.getSdkFailure().getClass().getSimpleName());

getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("DocumentDetector_Error", writableMap);
}
} else if (requestCode == REQUEST_CODE_FACE_AUTHENTICATOR) {
if (intent == null) {
getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("FaceAuthenticator_Cancel", null);
return;
}

FaceAuthenticatorResult faceAuthenticatorResult = (FaceAuthenticatorResult) intent.getSerializableExtra(FaceAuthenticatorResult.PARAMETER_NAME);
if (faceAuthenticatorResult.wasSuccessful()) {
WritableMap writableMap = new WritableNativeMap();

writableMap.putBoolean("authenticated", faceAuthenticatorResult.isAuthenticated());
writableMap.putString("signedResponse", faceAuthenticatorResult.getSignedResponse());
writableMap.putString("trackingId", faceAuthenticatorResult.getTrackingId());
getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("FaceAuthenticator_Success", writableMap);
} else {
WritableMap writableMap = new WritableNativeMap();

writableMap.putString("message", faceAuthenticatorResult.getSdkFailure().getMessage());
writableMap.putString("type", faceAuthenticatorResult.getSdkFailure().getClass().getSimpleName());

getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("FaceAuthenticator_Error", writableMap);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
};

reactContext.addActivityEventListener(activityEventListener);
}

@NotNull
@Override
public String getName() {
return "CombateAFraude";
}

@ReactMethod
public void passiveFaceLiveness(String mobileToken) {
try {
PassiveFaceLiveness passiveFaceLiveness = new PassiveFaceLiveness.Builder(mobileToken)
.build();

Activity activity = getCurrentActivity();
Intent intent = new Intent(activity.getApplicationContext(), PassiveFaceLivenessActivity.class);
intent.putExtra(PassiveFaceLiveness.PARAMETER_NAME, passiveFaceLiveness);
activity.startActivityForResult(intent, REQUEST_CODE_PASSIVE_FACE_LIVENESS);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}

@ReactMethod
public void documentDetector(String mobileToken, String documentType) {
try {
DocumentDetector.Builder documentDetectorBuilder = new DocumentDetector.Builder(mobileToken);

if (documentType.equals("CNH")) {
documentDetectorBuilder.setDocumentSteps(new DocumentDetectorStep[]{
new DocumentDetectorStep(Document.CNH_FRONT),
new DocumentDetectorStep(Document.CNH_BACK)
});
} else if (documentType.equals("RG")) {
documentDetectorBuilder.setDocumentSteps(new DocumentDetectorStep[]{
new DocumentDetectorStep(Document.RG_FRONT),
new DocumentDetectorStep(Document.RG_BACK)
});
} else if (documentType.equals("RNE")) {
documentDetectorBuilder.setDocumentSteps(new DocumentDetectorStep[]{
new DocumentDetectorStep(Document.RNE_FRONT),
new DocumentDetectorStep(Document.RNE_BACK)
});
} else if (documentType.equals("CRLV")) {
documentDetectorBuilder.setDocumentSteps(new DocumentDetectorStep[]{
new DocumentDetectorStep(Document.CRLV)
});
}

Activity activity = getCurrentActivity();
Intent intent = new Intent(activity.getApplicationContext(), DocumentDetectorActivity.class);
intent.putExtra(DocumentDetector.PARAMETER_NAME, documentDetectorBuilder.build());
activity.startActivityForResult(intent, REQUEST_CODE_DOCUMENT_DETECTOR);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}

@ReactMethod
public void faceAuthenticator(String mobileToken, String CPF) {
try {
FaceAuthenticator faceAuthenticator = new FaceAuthenticator.Builder(mobileToken)
.setPeopleId(CPF)
.build();

Activity activity = getCurrentActivity();
Intent intent = new Intent(activity.getApplicationContext(), FaceAuthenticatorActivity.class);
intent.putExtra(FaceAuthenticator.PARAMETER_NAME, faceAuthenticator);
activity.startActivityForResult(intent, REQUEST_CODE_FACE_AUTHENTICATOR);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}

}
31 changes: 31 additions & 0 deletions build/android/CombateAFraudePackage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package [[PACKAGE]];

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class CombateAFraudePackage implements ReactPackage {

@NotNull
@Override
public List<ViewManager> createViewManagers(@NotNull ReactApplicationContext reactContext) {
return Collections.emptyList();
}

@NotNull
@Override
public List<NativeModule> createNativeModules(@NotNull ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();

modules.add(new CombateAFraudeModule(reactContext));

return modules;
}
}
3 changes: 3 additions & 0 deletions build/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { ConfigPlugin } from '@expo/config-plugins';
declare const mainPlugin: ConfigPlugin<void>;
export default mainPlugin;
Loading

0 comments on commit d03028e

Please sign in to comment.