正在查看: Oolka v2.4.42 应用的 RemoteDataSource.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Oolka v2.4.42 应用的 RemoteDataSource.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package co.hyperverge.hypersnapsdk.data.remote;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import co.hyperverge.hyperkyc.data.models.HyperKycConfig;
import co.hyperverge.hyperkyc.data.models.WorkflowAPIHeaders;
import co.hyperverge.hyperkyc.data.models.result.HyperKycStatus;
import co.hyperverge.hypersnapsdk.BuildConfig;
import co.hyperverge.hypersnapsdk.HyperSnapSDK;
import co.hyperverge.hypersnapsdk.analytics.mixpanel.Keys;
import co.hyperverge.hypersnapsdk.data.DataSource;
import co.hyperverge.hypersnapsdk.data.models.APIResponse;
import co.hyperverge.hypersnapsdk.helpers.FileHelper;
import co.hyperverge.hypersnapsdk.helpers.SDKInternalConfig;
import co.hyperverge.hypersnapsdk.helpers.SPHelper;
import co.hyperverge.hypersnapsdk.helpers.TimingUtils;
import co.hyperverge.hypersnapsdk.listeners.APICompletionCallback;
import co.hyperverge.hypersnapsdk.model.GestureResponse;
import co.hyperverge.hypersnapsdk.model.LivenessResponse;
import co.hyperverge.hypersnapsdk.objects.HVBaseConfig;
import co.hyperverge.hypersnapsdk.objects.HVDocConfig;
import co.hyperverge.hypersnapsdk.objects.HVError;
import co.hyperverge.hypersnapsdk.objects.HVResponse;
import co.hyperverge.hypersnapsdk.objects.HyperSnapParams;
import co.hyperverge.hypersnapsdk.objects.HyperSnapSDKConfig;
import co.hyperverge.hypersnapsdk.service.security.GKYCSignatureVerify;
import co.hyperverge.hypersnapsdk.utils.AppConstants;
import co.hyperverge.hypersnapsdk.utils.HVLogUtils;
import co.hyperverge.hypersnapsdk.utils.StringUtils;
import co.hyperverge.hypersnapsdk.utils.Utils;
import com.cashfree.pg.core.hidden.utils.Constants;
import com.google.gson.Gson;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import okhttp3.Headers;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import org.json.JSONException;
import org.json.JSONObject;
import retrofit2.b;
import retrofit2.c;
import retrofit2.w;
public class RemoteDataSource extends DataSource {
private static final String TAG = "co.hyperverge.hypersnapsdk.data.remote.RemoteDataSource";
private static RemoteDataSource instance;
public static class AnonymousClass12 {
static final int[] $SwitchMap$co$hyperverge$hypersnapsdk$objects$HyperSnapParams$FaceMatchMode;
static {
int[] iArr = new int[HyperSnapParams.FaceMatchMode.values().length];
$SwitchMap$co$hyperverge$hypersnapsdk$objects$HyperSnapParams$FaceMatchMode = iArr;
try {
iArr[HyperSnapParams.FaceMatchMode.FACE_FACE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$co$hyperverge$hypersnapsdk$objects$HyperSnapParams$FaceMatchMode[HyperSnapParams.FaceMatchMode.FACE_ID.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$co$hyperverge$hypersnapsdk$objects$HyperSnapParams$FaceMatchMode[HyperSnapParams.FaceMatchMode.FACE_IDFACESTRING.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$co$hyperverge$hypersnapsdk$objects$HyperSnapParams$FaceMatchMode[HyperSnapParams.FaceMatchMode.FACE_ID_FACE_STRING.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
}
}
public static boolean checkForDataLogging(JSONObject jSONObject) {
HVLogUtils.d(TAG, "checkForDataLogging() called with: parameters = [" + jSONObject + "]");
if (jSONObject == null || !jSONObject.has("dataLogging")) {
return false;
}
try {
return jSONObject.getString("dataLogging").equals("yes");
} catch (JSONException e) {
if (SDKInternalConfig.getInstance().getErrorMonitoringService() == null) {
return false;
}
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
return false;
}
}
public JSONObject convertMapToJson(Map<String, String> map) {
HVLogUtils.d(TAG, "convertMapToJson() called with: map = [" + map + "]");
try {
return new JSONObject(new Gson().toJson(map));
} catch (Exception unused) {
return new JSONObject();
}
}
private JSONObject createFaceMatchHeaders(JSONObject jSONObject) {
HVLogUtils.d(TAG, "createFaceMatchHeaders() called with: headers = [" + jSONObject + "]");
if (jSONObject == null) {
jSONObject = new JSONObject();
}
return addHeaderParams(jSONObject);
}
private JSONObject createFaceMatchParams(JSONObject jSONObject) {
HVLogUtils.d(TAG, "createFaceMatchParams() called with: parameters = [" + jSONObject + "]");
return jSONObject == null ? new JSONObject() : jSONObject;
}
public static RemoteDataSource getInstance() {
if (instance == null) {
instance = new RemoteDataSource();
}
return instance;
}
private boolean isAfrica(String str) {
HVLogUtils.d(TAG, "isAfrica() called with: endpoint = [" + str + "]");
return str.contains("zaf") || HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getHyperSnapRegion().equals(HyperSnapParams.Region.AFRICA);
}
private boolean isApac(String str) {
HVLogUtils.d(TAG, "isApac() called with: endpoint = [" + str + "]");
HyperSnapParams.Region hyperSnapRegion = HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getHyperSnapRegion();
return str.contains("apac") || hyperSnapRegion.equals(HyperSnapParams.Region.ASIA_PACIFIC) || hyperSnapRegion.equals(HyperSnapParams.Region.AsiaPacific);
}
private boolean isIndia(String str) {
HVLogUtils.d(TAG, "isIndia() called with: endpoint = [" + str + "]");
HyperSnapParams.Region hyperSnapRegion = HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getHyperSnapRegion();
return str.contains("ind") || hyperSnapRegion.equals(HyperSnapParams.Region.INDIA) || hyperSnapRegion.equals(HyperSnapParams.Region.India);
}
public boolean isSignatureVerfied(APIResponse aPIResponse, String str, JSONObject jSONObject, HashMap<String, String> hashMap, JSONObject jSONObject2, JSONObject jSONObject3, boolean z, List<Integer> list) {
HVLogUtils.d(TAG, "isSignatureVerfied() called with: apiResponse = [" + aPIResponse + "], uuid = [" + str + "], requestQuery = [" + jSONObject + "], tagFileUriMap = [" + hashMap + "], requestBody = [" + jSONObject2 + "], requestHeaders = [" + jSONObject3 + "], shouldUseApacSignatureCheck = [" + z + "], allowedStatusCodes = [" + list + "]");
if (list == null || list.isEmpty()) {
list = new HVBaseConfig().getAllowedStatusCodes();
}
HyperSnapSDKConfig hyperSnapSDKConfig = HyperSnapSDK.getInstance().getHyperSnapSDKConfig();
if (!hyperSnapSDKConfig.isShouldUseSignature() || !list.contains(aPIResponse.getStatusCode())) {
return true;
}
JSONObject responseBody = aPIResponse.getResponseBody();
if (responseBody == null) {
responseBody = aPIResponse.getErrorBody();
}
JSONObject responseHeaders = aPIResponse.getResponseHeaders();
boolean validateSignatureIfNeededAPAC = (!hyperSnapSDKConfig.isShouldUseSHA256Signature() || z) ? SignatureHelper.validateSignatureIfNeededAPAC(responseBody, responseHeaders, str) : SignatureHelper.validateSignatureIfNeeded(responseBody, responseHeaders, str);
if (validateSignatureIfNeededAPAC) {
return validateSignatureIfNeededAPAC;
}
try {
return GKYCSignatureVerify.builder().requestQuery(jSONObject).tagFileUriMap(hashMap).requestBody(jSONObject2).requestHeaders(jSONObject3).responseBody(responseBody).responseHeaders(responseHeaders).build().verify(responseHeaders.getString("X-HV-Signature"));
} catch (JSONException e) {
logError(e);
return validateSignatureIfNeededAPAC;
}
}
private boolean isValidFaceMatchInputs(Context context, String str, String str2, String str3, HyperSnapParams.FaceMatchMode faceMatchMode, APICompletionCallback aPICompletionCallback) {
String str4;
boolean z;
HVLogUtils.d(TAG, "isValidFaceMatchInputs() called with: context = [" + context + "], endpoint = [" + str + "], image1 = [" + str2 + "], image2 = [" + str3 + "], hyperSnapFaceMatchMode = [" + faceMatchMode + "], callback = [" + aPICompletionCallback + "]");
if (aPICompletionCallback == null) {
return false;
}
if (context == null) {
str4 = "Context object is null";
z = false;
} else {
str4 = "";
z = true;
}
if (StringUtils.isEmptyOrNull(str)) {
str4 = "Face match endpoint is empty";
z = false;
}
if (StringUtils.isEmptyOrNull(str2) || !new File(str2).exists()) {
str4 = "Face file path is invalid";
z = false;
}
int i = AnonymousClass12.$SwitchMap$co$hyperverge$hypersnapsdk$objects$HyperSnapParams$FaceMatchMode[faceMatchMode.ordinal()];
if (i != 1) {
if (i != 2) {
if ((i == 3 || i == 4) && StringUtils.isEmptyOrNull(str3)) {
str4 = "ID Face String is invalid";
z = false;
}
} else if (StringUtils.isEmptyOrNull(str3) || !new File(str3).exists()) {
str4 = "Document file path is invalid";
z = false;
}
} else if (StringUtils.isEmptyOrNull(str3) || !new File(str3).exists()) {
str4 = "Second face file path is invalid";
z = false;
}
if (z) {
return true;
}
aPICompletionCallback.onResult(new HVError(6, str4), null);
return false;
}
public void logError(Exception exc) {
HVLogUtils.d(TAG, "logError() called with: e = [" + exc + "]");
Utils.getErrorMessage(exc);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(exc);
}
}
@NonNull
private MultipartBody.Part prepareFilePart(Context context, String str, String str2) {
HVLogUtils.d(TAG, "prepareFilePart() called with: context = [" + context + "], partName = [" + str + "], filePath = [" + str2 + "]");
File file = new File(str2);
return MultipartBody.Part.createFormData(str, file.getName(), RequestBody.create(MediaType.parse(context.getContentResolver().getType(Uri.parse(str2))), file));
}
public void printLogs(Exception exc) {
try {
if (TextUtils.isEmpty(Utils.getErrorMessage(exc))) {
return;
}
Utils.getErrorMessage(exc);
} catch (Exception unused) {
}
}
public void setLivenessResponseForSummary(LivenessResponse livenessResponse, APIResponse aPIResponse) {
HVLogUtils.d(TAG, "setLivenessResponseForSummary() called with: livenessResponse = [" + livenessResponse + "], apiResponse = [" + aPIResponse + "]");
try {
JSONObject errorBody = aPIResponse.getErrorBody();
HVError error = getError(errorBody);
livenessResponse.setLivenessError(error.getErrorMessage());
livenessResponse.setErrorCode(error.getErrorCode());
if (errorBody.has("result") && errorBody.getJSONObject("result").has(AppConstants.SUMMARY)) {
livenessResponse.setResponse(errorBody);
}
livenessResponse.setRequestID(aPIResponse.getRequestID());
} catch (JSONException e) {
logError(e);
}
}
public HVResponse setSummaryDetails(HVResponse hVResponse, JSONObject jSONObject) {
HVLogUtils.d(TAG, "setSummaryDetails() called with: response = [" + hVResponse + "], resultObj = [" + jSONObject + "]");
try {
if (jSONObject.has("result")) {
JSONObject jSONObject2 = jSONObject.getJSONObject("result");
if (jSONObject2.has(AppConstants.SUMMARY)) {
JSONObject jSONObject3 = jSONObject2.getJSONObject(AppConstants.SUMMARY);
String string = jSONObject3.getString("action");
String str = AppConstants.RETAKE_DEFAULT_MESSAGE;
if (jSONObject3.has(AppConstants.RETAKE_MESSAGE)) {
str = jSONObject3.getString(AppConstants.RETAKE_MESSAGE);
}
hVResponse.setAction(string);
hVResponse.setRetakeMessage(str);
hVResponse.setApiResult(jSONObject);
}
}
} catch (Exception e) {
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
return hVResponse;
}
private boolean shouldSendQRCodeToOCREndpoint(String str) {
HVLogUtils.d(TAG, "shouldSendQRCodeToOCREndpoint() called with: ocrEndpoint = [" + str + "]");
return !StringUtils.isEmptyOrNull(str) && (str.contains("/v1.1/readNID") || str.contains("/v2/nationalID"));
}
private void updateAPIResponseWithRequestSignature(APIResponse aPIResponse, String str) {
HVLogUtils.d(TAG, "updateAPIResponseWithRequestSignature() called with: apiResponse = [" + aPIResponse + "], uuid = [" + str + "]");
if (!HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldUseSignature() || str == null) {
return;
}
try {
aPIResponse.setRequestSignature(str);
} catch (JSONException e) {
logError(e);
}
}
public JSONObject addHeaderParams(JSONObject jSONObject) {
HVLogUtils.d(TAG, "addHeaderParams() called with: header = [" + jSONObject + "]");
try {
if (jSONObject.has("transactionId") && jSONObject.getString("transactionId").equalsIgnoreCase("transactionId")) {
jSONObject.remove("transactionId");
}
} catch (Exception e) {
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
try {
if (!jSONObject.has(WorkflowAPIHeaders.SDK_VERSION)) {
jSONObject.put(WorkflowAPIHeaders.SDK_VERSION, BuildConfig.HYPERSNAP_VERSION_NAME);
}
jSONObject.put(WorkflowAPIHeaders.OS, "android");
jSONObject.put(WorkflowAPIHeaders.APP_VERSION, SDKInternalConfig.getInstance().getAppVersion());
jSONObject.put(WorkflowAPIHeaders.DEVICE, Build.MODEL);
jSONObject.put("device-brand", Build.BRAND);
jSONObject.put("device-manufacturer", Build.MANUFACTURER);
jSONObject.put("abi-arch", Build.CPU_ABI);
jSONObject.put("os-version", Build.VERSION.SDK_INT);
jSONObject.put("sensor-orientation", AppConstants.sensorOrientation);
if (!AppConstants.cameraLevel.isEmpty()) {
jSONObject.put("camera-level", AppConstants.cameraLevel + "-" + AppConstants.cameraType);
}
} catch (Exception e2) {
printLogs(e2);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e2);
}
}
return jSONObject;
}
public HVError getError(JSONObject jSONObject) {
HVLogUtils.d(TAG, "getError() called with: error = [" + jSONObject + "]");
new JSONObject();
HVError hVError = new HVError();
try {
String string = jSONObject.has(HyperKycStatus.ERROR) ? jSONObject.getString(HyperKycStatus.ERROR) : " ";
if (jSONObject.has("result")) {
JSONObject jSONObject2 = jSONObject.getJSONObject("result");
if (jSONObject2.has(HyperKycStatus.ERROR)) {
string = jSONObject2.getString(HyperKycStatus.ERROR);
}
} else if (jSONObject.has("message")) {
string = jSONObject.getString("message");
}
return new HVError(jSONObject.has(Keys.STATUS_CODE) ? jSONObject.getInt(Keys.STATUS_CODE) : 14, string);
} catch (JSONException e) {
printLogs(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() == null) {
return hVError;
}
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
return hVError;
}
}
public HVError getErrorFromException(Exception exc) {
HVLogUtils.d(TAG, "getErrorFromException() called with: e = [" + exc + "]");
Utils.getErrorMessage(exc);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(exc);
}
return new HVError(2, exc.getLocalizedMessage());
}
public HVError getErrorValidationAPI(JSONObject jSONObject) {
HVLogUtils.d(TAG, "getErrorValidationAPI() called with: error = [" + jSONObject + "]");
new JSONObject();
HVError hVError = new HVError();
try {
int i = jSONObject.getInt(Keys.STATUS_CODE);
JSONObject jSONObject2 = jSONObject.getJSONObject(HyperKycStatus.ERROR);
if (jSONObject2.has(AppConstants.RETAKE_ERROR_CODE)) {
i = jSONObject2.getInt(AppConstants.RETAKE_ERROR_CODE);
}
String string = jSONObject2.has("message") ? jSONObject2.getString("message") : "";
if (jSONObject2.has("path")) {
try {
string = string + ", path:" + jSONObject2.getJSONArray("path").toString();
} catch (Exception e) {
printLogs(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
}
return new HVError(i, string);
} catch (JSONException e2) {
printLogs(e2);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() == null) {
return hVError;
}
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e2);
return hVError;
}
}
@Override
public void getLivenessTextureScore(java.lang.String r22, java.lang.String r23, java.lang.String r24, java.util.List<java.lang.Integer> r25, final co.hyperverge.hypersnapsdk.objects.HVFaceConfig r26, final co.hyperverge.hypersnapsdk.data.DataSource.NetworkCallback r27) {
throw new UnsupportedOperationException("Method not decompiled: co.hyperverge.hypersnapsdk.data.remote.RemoteDataSource.getLivenessTextureScore(java.lang.String, java.lang.String, java.lang.String, java.util.List, co.hyperverge.hypersnapsdk.objects.HVFaceConfig, co.hyperverge.hypersnapsdk.data.DataSource$NetworkCallback):void");
}
public Map<String, RequestBody> getMapFromJson(JSONObject jSONObject) {
HVLogUtils.d(TAG, "getMapFromJson() called with: params = [" + jSONObject + "]");
Gson gson = new Gson();
HashMap hashMap = new HashMap();
HashMap hashMap2 = new HashMap();
if (jSONObject == null) {
return hashMap;
}
Map map = (Map) gson.fromJson(jSONObject.toString(), hashMap2.getClass());
for (String str : map.keySet()) {
hashMap.put(str, RequestBody.create(MediaType.parse("text/plain"), (String) map.get(str)));
}
return hashMap;
}
public String getReferenceId(JSONObject jSONObject) {
HVLogUtils.d(TAG, "getReferenceId() called with: headers = [" + jSONObject + "]");
if (jSONObject != null && jSONObject.has(Constants.REFERENCE_ID)) {
try {
return jSONObject.getString(Constants.REFERENCE_ID);
} catch (JSONException e) {
printLogs(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
}
}
return " ";
}
public String getRequestId(Headers headers) {
String str;
HVLogUtils.d(TAG, "getRequestId() called with: object = [" + headers + "]");
try {
str = headers.get(AppConstants.REQUEST_ID);
} catch (Exception e) {
printLogs(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() != null) {
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
}
str = " ";
}
if (str != null && !str.trim().isEmpty()) {
return str;
}
try {
return headers.get(AppConstants.HV_REQUEST_ID);
} catch (Exception e2) {
printLogs(e2);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() == null) {
return " ";
}
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e2);
return " ";
}
}
public b<ResponseBody> getResponseBodyForSingleImageRequest(Context context, String str, String str2, JSONObject jSONObject, JSONObject jSONObject2) {
HVLogUtils.d(TAG, "getResponseBodyForSingleImageRequest() called with: context = [" + context + "], endpoint = [" + str + "], imageUri = [" + str2 + "], parameters = [" + jSONObject + "], headers = [" + jSONObject2 + "]");
File file = new File(str2);
MultipartBody.Part createFormData = MultipartBody.Part.createFormData("selfie", file.getName(), RequestBody.create(MediaType.parse("image/jpeg"), file));
if (jSONObject2 == null) {
jSONObject2 = new JSONObject();
}
JSONObject addHeaderParams = addHeaderParams(jSONObject2);
Map<String, RequestBody> mapFromJson = getMapFromJson(jSONObject);
Map<String, String> hashMap = new HashMap<>();
if (addHeaderParams != null) {
hashMap = (Map) new Gson().fromJson(addHeaderParams.toString(), HashMap.class);
}
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken() == null || HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken().isEmpty()) {
hashMap.put(HyperKycConfig.APP_ID, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppId());
hashMap.put(HyperKycConfig.APP_KEY, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppKey());
} else {
hashMap.put(HyperKycConfig.AUTHORIZATION, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken());
}
return ApiClient.getService().singleImageUpload(str, hashMap, createFormData, mapFromJson);
}
public String getUUIDForImage(Context context, String str, JSONObject jSONObject) {
HVLogUtils.d(TAG, "getUUIDForImage() called with: context = [" + context + "], imageUri = [" + str + "], headers = [" + jSONObject + "]");
String uniqueIdentifierIfNeeded = SignatureHelper.getUniqueIdentifierIfNeeded(str, jSONObject);
try {
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldUseSignature() && uniqueIdentifierIfNeeded != null) {
jSONObject.put(AppConstants.PARAMS_UUID, uniqueIdentifierIfNeeded);
}
} catch (JSONException e) {
printLogs(e);
SDKInternalConfig.getInstance().getErrorMonitoringService(context).sendErrorMessage(e);
}
return uniqueIdentifierIfNeeded;
}
@Override
public void ipAddressToGeo(final APICompletionCallback aPICompletionCallback) {
HVLogUtils.d(TAG, "ipAddressToGeo() called with: callback = [" + aPICompletionCallback + "]");
HashMap hashMap = new HashMap();
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken() == null || HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken().isEmpty()) {
hashMap.put(HyperKycConfig.APP_ID, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppId());
hashMap.put(HyperKycConfig.APP_KEY, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppKey());
} else {
hashMap.put(HyperKycConfig.AUTHORIZATION, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken());
}
try {
if (!SPHelper.getTransactionID().trim().isEmpty() && !hashMap.containsKey("transactionId")) {
hashMap.put("transactionId", SPHelper.getTransactionID());
}
} catch (Exception e) {
Utils.getErrorMessage(e);
}
ApiClient.getService().ipAddressToGeo("https://hypersnapweb.hyperverge.co/api/proxy/geoIP/", hashMap).C0(new c<ResponseBody>() {
public void onFailure(@NonNull b<ResponseBody> bVar, @NonNull Throwable th) {
HVLogUtils.d(RemoteDataSource.TAG, "ipAddressToGeo(): onFailure() called with: call = [" + bVar + "], t = [" + th + "]");
String unused = RemoteDataSource.TAG;
Utils.getErrorMessage(th);
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(th);
aPICompletionCallback.onResult(new HVError(12, th.getLocalizedMessage()), null);
}
public void onResponse(@NonNull b<ResponseBody> bVar, @NonNull w<ResponseBody> wVar) {
HVLogUtils.d(RemoteDataSource.TAG, "ipAddressToGeo(): onResponse() called with: call = [" + bVar + "], response = [" + wVar + "]");
APIResponse aPIResponse = new APIResponse(wVar);
HVResponse hVResponse = new HVResponse();
hVResponse.setApiHeaders(aPIResponse.getResponseHeaders());
hVResponse.setStatusCode(aPIResponse.getStatusCode());
hVResponse.setStatusMessage(aPIResponse.getStatusMessage());
if (wVar.f()) {
try {
hVResponse.setApiResult(aPIResponse.getResponseBody());
aPICompletionCallback.onResult(null, hVResponse);
return;
} catch (Exception e2) {
String unused = RemoteDataSource.TAG;
Utils.getErrorMessage(e2);
aPICompletionCallback.onResult(RemoteDataSource.this.getErrorFromException(e2), hVResponse);
return;
}
}
try {
aPICompletionCallback.onResult(RemoteDataSource.this.getError(aPIResponse.getErrorBody()), hVResponse);
} catch (Exception e3) {
String unused2 = RemoteDataSource.TAG;
Utils.getErrorMessage(e3);
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e3);
aPICompletionCallback.onResult(RemoteDataSource.this.getErrorFromException(e3), hVResponse);
}
}
});
}
@Override
public void makeFaceAuthAPICall(final Context context, String str, String str2, JSONObject jSONObject, JSONObject jSONObject2, final List<Integer> list, final APICompletionCallback aPICompletionCallback) {
HVLogUtils.d(TAG, "makeFaceAuthAPICall() called with: context = [" + context + "], endpoint = [" + str + "], selfieImageURL = [" + str2 + "], parameters = [" + jSONObject + "], headers = [" + jSONObject2 + "], allowedStatusCodes = [" + list + "], callback = [" + aPICompletionCallback + "]");
final String uUIDForImage = getUUIDForImage(context, str2, jSONObject2);
getResponseBodyForSingleImageRequest(context, str, str2, jSONObject, jSONObject2).C0(new c<ResponseBody>() {
public void onFailure(b<ResponseBody> bVar, Throwable th) {
HVLogUtils.d(RemoteDataSource.TAG, "makeFaceAuthAPICall(): onFailure() called with: call = [" + bVar + "], throwable = [" + th + "]");
RemoteDataSource.this.processFailureResponse(context, th, aPICompletionCallback);
}
public void onResponse(b<ResponseBody> bVar, w<ResponseBody> wVar) {
HVLogUtils.d(RemoteDataSource.TAG, "makeFaceAuthAPICall(): onResponse() called with: call = [" + bVar + "], response = [" + wVar + "]");
RemoteDataSource.this.processResponse(context, wVar, uUIDForImage, list, aPICompletionCallback);
}
});
}
@Override
public void makeFaceDedupeAPICall(final Context context, String str, String str2, JSONObject jSONObject, JSONObject jSONObject2, final List<Integer> list, final APICompletionCallback aPICompletionCallback) {
HVLogUtils.d(TAG, "makeFaceDedupeAPICall() called with: context = [" + context + "], endpoint = [" + str + "], selfieImageURL = [" + str2 + "], parameters = [" + jSONObject + "], headers = [" + jSONObject2 + "], allowedStatusCodes = [" + list + "], callback = [" + aPICompletionCallback + "]");
final String uUIDForImage = getUUIDForImage(context, str2, jSONObject2);
getResponseBodyForSingleImageRequest(context, str, str2, jSONObject, jSONObject2).C0(new c<ResponseBody>() {
public void onFailure(b<ResponseBody> bVar, Throwable th) {
HVLogUtils.d(RemoteDataSource.TAG, "makeFaceDedupeAPICall(): onFailure() called with: call = [" + bVar + "], throwable = [" + th + "]");
RemoteDataSource.this.processFailureResponse(context, th, aPICompletionCallback);
}
public void onResponse(b<ResponseBody> bVar, w<ResponseBody> wVar) {
HVLogUtils.d(RemoteDataSource.TAG, "makeFaceDedupeAPICall() onResponse() called with: call = [" + bVar + "], response = [" + wVar + "]");
RemoteDataSource.this.processResponse(context, wVar, uUIDForImage, list, aPICompletionCallback);
}
});
}
@Override
public void makeFaceMatchCall(final android.content.Context r18, java.lang.String r19, java.lang.String r20, java.lang.String r21, final co.hyperverge.hypersnapsdk.objects.HyperSnapParams.FaceMatchMode r22, org.json.JSONObject r23, org.json.JSONObject r24, final java.util.List<java.lang.Integer> r25, final co.hyperverge.hypersnapsdk.listeners.APICompletionCallback r26) {
throw new UnsupportedOperationException("Method not decompiled: co.hyperverge.hypersnapsdk.data.remote.RemoteDataSource.makeFaceMatchCall(android.content.Context, java.lang.String, java.lang.String, java.lang.String, co.hyperverge.hypersnapsdk.objects.HyperSnapParams$FaceMatchMode, org.json.JSONObject, org.json.JSONObject, java.util.List, co.hyperverge.hypersnapsdk.listeners.APICompletionCallback):void");
}
@Override
public void makeOcrCall(final Context context, String str, final String str2, String str3, HVDocConfig hVDocConfig, final JSONObject jSONObject, JSONObject jSONObject2, final List<Integer> list, final APICompletionCallback aPICompletionCallback) {
String str4;
String str5;
MultipartBody.Part part;
String str6;
String str7;
b<ResponseBody> ocrCall;
HVLogUtils.d(TAG, "makeOcrCall() called with: context = [" + context + "], endpoint = [" + str + "], documentUri = [" + str2 + "], qrCodeCroppedImageUri = [" + str3 + "], hvDocConfig = [" + hVDocConfig + "], parameters = [" + jSONObject + "], headers = [" + jSONObject2 + "], allowedStatusCodes = [" + list + "], callback = [" + aPICompletionCallback + "]");
if (aPICompletionCallback == null) {
return;
}
if (context == null) {
aPICompletionCallback.onResult(new HVError(6, "Context object is null"), null);
return;
}
final HashMap hashMap = new HashMap();
if (str2 == null || str2.trim().isEmpty() || !new File(str2).exists()) {
aPICompletionCallback.onResult(new HVError(6, "Document file path is null"), null);
return;
}
File file = new File(str2);
if (str2.contains(".pdf")) {
str4 = "pdf";
hashMap.put("pdf", str2);
str5 = "application/pdf";
} else {
str4 = "image";
hashMap.put("image", str2);
str5 = "image/jpeg";
}
MultipartBody.Part createFormData = MultipartBody.Part.createFormData(str4, file.getName(), RequestBody.create(MediaType.parse(str5), file));
if (!StringUtils.isEmptyOrNull(str3)) {
hashMap.put("qrCroppedImage", str3);
}
if (hVDocConfig == null || !hVDocConfig.isShouldReadNIDQR() || StringUtils.isEmptyOrNull(str3)) {
part = null;
} else {
File file2 = new File(str3);
part = MultipartBody.Part.createFormData("qrCroppedImage", file2.getName(), RequestBody.create(MediaType.parse("image/jpeg"), file2));
}
JSONObject addHeaderParams = addHeaderParams(jSONObject2 == null ? new JSONObject() : jSONObject2);
String uniqueIdentifierIfNeeded = SignatureHelper.getUniqueIdentifierIfNeeded(str2, addHeaderParams);
try {
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldUseSHA256Signature() && uniqueIdentifierIfNeeded != null && !addHeaderParams.has(AppConstants.PARAMS_UUID)) {
addHeaderParams.put(AppConstants.PARAMS_UUID, uniqueIdentifierIfNeeded);
}
str6 = uniqueIdentifierIfNeeded;
} catch (JSONException e) {
str6 = uniqueIdentifierIfNeeded;
HVLogUtils.e(TAG, "makeOcrCall(): exception = [" + Utils.getErrorMessage(e) + "]", e);
Utils.getErrorMessage(e);
SDKInternalConfig.getInstance().getErrorMonitoringService(context).sendErrorMessage(e);
}
checkForDataLogging(jSONObject);
Map<String, RequestBody> mapFromJson = getMapFromJson(jSONObject);
Map<String, String> hashMap2 = new HashMap<>();
if (addHeaderParams != null) {
hashMap2 = (Map) new Gson().fromJson(addHeaderParams.toString(), HashMap.class);
}
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken() == null || HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken().isEmpty()) {
hashMap2.put(HyperKycConfig.APP_ID, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppId());
hashMap2.put(HyperKycConfig.APP_KEY, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppKey());
} else {
hashMap2.put(HyperKycConfig.AUTHORIZATION, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken());
}
if (hVDocConfig == null || !hVDocConfig.isShouldReadNIDQR() || !shouldSendQRCodeToOCREndpoint(str) || part == null) {
str7 = str6;
ocrCall = ApiClient.getService().ocrCall(str, hashMap2, createFormData, mapFromJson);
} else {
str7 = str6;
ocrCall = ApiClient.getService().ocrPlusQRCall(str, hashMap2, createFormData, part, mapFromJson);
}
getReferenceId(addHeaderParams);
final TimingUtils timingUtils = new TimingUtils();
final String str8 = str7;
final Map<String, String> map = hashMap2;
ocrCall.C0(new c<ResponseBody>() {
public void onFailure(b<ResponseBody> bVar, Throwable th) {
HVLogUtils.d(RemoteDataSource.TAG, "makeOcrCall(): onFailure() called with: call = [" + bVar + "], t = [" + th + "]");
String unused = RemoteDataSource.TAG;
Utils.getErrorMessage(th);
HVError hVError = th.getLocalizedMessage().contains("Certificate pinning") ? new HVError(15, "Secure connection could not be established.") : new HVError(12, th.getLocalizedMessage());
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logDocumentAPICallFailed(null, hVError);
}
aPICompletionCallback.onResult(hVError, null);
}
public void onResponse(b<ResponseBody> bVar, w<ResponseBody> wVar) {
String str9;
HVLogUtils.d(RemoteDataSource.TAG, "makeOcrCall(): onResponse() called with: call = [" + bVar + "], response = [" + wVar + "]");
APIResponse aPIResponse = new APIResponse(wVar);
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldUseSignature() && (str9 = str8) != null) {
try {
aPIResponse.setRequestSignature(str9);
} catch (JSONException e2) {
RemoteDataSource.this.logError(e2);
}
}
RemoteDataSource remoteDataSource = RemoteDataSource.this;
boolean isSignatureVerfied = remoteDataSource.isSignatureVerfied(aPIResponse, str8, null, hashMap, jSONObject, remoteDataSource.convertMapToJson(map), false, list);
HVError error = !isSignatureVerfied ? RemoteDataSource.this.getError(AppConstants.SIGNATURE_ERROR, 18) : null;
HVResponse hVResponse = new HVResponse();
hVResponse.setApiHeaders(aPIResponse.getResponseHeaders());
hVResponse.setStatusCode(aPIResponse.getStatusCode());
hVResponse.setStatusMessage(aPIResponse.getStatusMessage());
boolean isShouldReturnRawResponse = HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldReturnRawResponse();
JSONObject responseBody = aPIResponse.getResponseBody();
if (!wVar.f()) {
HVError hVError = new HVError();
if (isSignatureVerfied) {
if (aPIResponse.getErrorBody() != null) {
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldReturnRawResponse()) {
try {
aPIResponse.addHeader(AppConstants.RAW_RESPONSE, aPIResponse.getErrorBody().toString());
hVResponse.setApiHeaders(aPIResponse.getResponseHeaders());
} catch (JSONException e3) {
RemoteDataSource.this.logError(e3);
}
}
hVResponse = RemoteDataSource.this.setSummaryDetails(hVResponse, aPIResponse.getErrorBody());
error = RemoteDataSource.this.getError(aPIResponse.getErrorBody());
} else {
error = hVError;
}
}
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logDocumentAPICallFailed(null, error);
}
aPICompletionCallback.onResult(error, hVResponse);
return;
}
if (responseBody != null) {
if (isShouldReturnRawResponse) {
try {
aPIResponse.addRawResponseBody();
hVResponse.setApiHeaders(aPIResponse.getResponseHeaders());
} catch (JSONException e4) {
RemoteDataSource.this.logError(e4);
}
}
if (!isSignatureVerfied) {
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logDocumentAPICallFailed(null, error);
}
aPICompletionCallback.onResult(error, hVResponse);
} else {
hVResponse.setApiResult(responseBody);
HVResponse summaryDetails = RemoteDataSource.this.setSummaryDetails(hVResponse, responseBody);
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logDocumentAPIResponseReceived(summaryDetails, str2, timingUtils.getTimeDifferenceLong().longValue());
}
aPICompletionCallback.onResult(null, summaryDetails);
}
}
}
});
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logDocumentAPIPost(str, str2);
}
}
@Override
public void makeTextMatchAPICall(final Context context, final String str, JSONObject jSONObject, JSONObject jSONObject2, final List<Integer> list, final APICompletionCallback aPICompletionCallback) {
HVLogUtils.d(TAG, "makeTextMatchAPICall() called with: context = [" + context + "], endpoint = [" + str + "], parameters = [" + jSONObject + "], headers = [" + jSONObject2 + "], allowedStatusCodes = [" + list + "], callback = [" + aPICompletionCallback + "]");
if (aPICompletionCallback == null) {
return;
}
if (context == null) {
aPICompletionCallback.onResult(new HVError(6, "Context object is null"), null);
return;
}
if (jSONObject2 == null) {
jSONObject2 = new JSONObject();
}
if (jSONObject == null) {
jSONObject = new JSONObject();
}
final JSONObject jSONObject3 = jSONObject;
JSONObject addHeaderParams = addHeaderParams(jSONObject2);
final String uniqueIdentifierForReqIfNeeded = SignatureHelper.getUniqueIdentifierForReqIfNeeded(jSONObject3.toString());
Map<String, String> hashMap = new HashMap<>();
if (addHeaderParams != null) {
hashMap = (Map) new Gson().fromJson(addHeaderParams.toString(), HashMap.class);
}
final Map<String, String> map = hashMap;
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken() == null || HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken().isEmpty()) {
map.put(HyperKycConfig.APP_ID, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppId());
map.put(HyperKycConfig.APP_KEY, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppKey());
} else {
map.put(HyperKycConfig.AUTHORIZATION, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken());
}
b<ResponseBody> matchingAPI = ApiClient.getService().matchingAPI(str, map, RequestBody.create(MediaType.parse("application/json"), jSONObject3.toString()));
getReferenceId(addHeaderParams);
new TimingUtils();
matchingAPI.C0(new c<ResponseBody>() {
public void onFailure(b<ResponseBody> bVar, Throwable th) {
HVLogUtils.d(RemoteDataSource.TAG, "makeTextMatchAPICall(): onFailure() called with: call = [" + bVar + "], t = [" + th + "]");
String unused = RemoteDataSource.TAG;
Utils.getErrorMessage(th);
SDKInternalConfig.getInstance().getErrorMonitoringService(context).sendErrorMessage(th);
HVError hVError = th.getLocalizedMessage().contains("Certificate pinning") ? new HVError(15, "Secure connection could not be established.") : new HVError(12, th.getLocalizedMessage());
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logTextMatchAPICallFailed(hVError);
}
aPICompletionCallback.onResult(hVError, null);
}
public void onResponse(b<ResponseBody> bVar, w<ResponseBody> wVar) {
boolean isSignatureVerfied;
HVLogUtils.d(RemoteDataSource.TAG, "makeTextMatchAPICall(): onResponse() called with: call = [" + bVar + "], response = [" + wVar + "]");
APIResponse aPIResponse = new APIResponse(wVar);
HVResponse hVResponse = new HVResponse();
hVResponse.setApiHeaders(aPIResponse.getResponseHeaders());
hVResponse.setStatusCode(aPIResponse.getStatusCode());
hVResponse.setStatusMessage(aPIResponse.getStatusMessage());
if (str.contains("apac")) {
RemoteDataSource remoteDataSource = RemoteDataSource.this;
isSignatureVerfied = remoteDataSource.isSignatureVerfied(aPIResponse, uniqueIdentifierForReqIfNeeded, null, null, jSONObject3, remoteDataSource.convertMapToJson(map), true, list);
} else {
RemoteDataSource remoteDataSource2 = RemoteDataSource.this;
isSignatureVerfied = remoteDataSource2.isSignatureVerfied(aPIResponse, uniqueIdentifierForReqIfNeeded, null, null, jSONObject3, remoteDataSource2.convertMapToJson(map), false, list);
}
HVError error = !isSignatureVerfied ? RemoteDataSource.this.getError(AppConstants.SIGNATURE_ERROR, 18) : null;
JSONObject responseBody = aPIResponse.getResponseBody();
if (!wVar.f()) {
if (!isSignatureVerfied) {
aPICompletionCallback.onResult(error, hVResponse);
return;
} else {
if (aPIResponse.getErrorBody() != null) {
aPICompletionCallback.onResult(RemoteDataSource.this.getError(aPIResponse.getErrorBody()), hVResponse);
return;
}
return;
}
}
if (responseBody != null) {
if (!isSignatureVerfied) {
aPICompletionCallback.onResult(error, hVResponse);
} else {
hVResponse.setApiResult(responseBody);
aPICompletionCallback.onResult(null, hVResponse);
}
}
}
});
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logTextMatchAPIPost();
}
}
@Override
public void makeValidationAPICall(final Context context, String str, JSONObject jSONObject, JSONObject jSONObject2, JSONObject jSONObject3, JSONObject jSONObject4, Boolean bool, List<Integer> list, final APICompletionCallback aPICompletionCallback) {
HVLogUtils.d(TAG, "makeValidationAPICall() called with: context = [" + context + "], endpoint = [" + str + "], userInput = [" + jSONObject + "], ocrResultFront = [" + jSONObject2 + "], ocrResultBack = [" + jSONObject3 + "], qr = [" + jSONObject4 + "], checkDatabase = [" + bool + "], allowedStatusCodes = [" + list + "], callback = [" + aPICompletionCallback + "]");
if (aPICompletionCallback == null) {
return;
}
if (context == null) {
aPICompletionCallback.onResult(new HVError(6, "Context object is null"), null);
return;
}
HashMap hashMap = new HashMap();
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken() == null || HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken().isEmpty()) {
hashMap.put(HyperKycConfig.APP_ID, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppId());
hashMap.put(HyperKycConfig.APP_KEY, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppKey());
} else {
hashMap.put(HyperKycConfig.AUTHORIZATION, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken());
}
JSONObject jSONObject5 = new JSONObject();
if (jSONObject != null) {
try {
jSONObject5.put("userInput", jSONObject);
} catch (Exception e) {
printLogs(e);
SDKInternalConfig.getInstance().getErrorMonitoringService(context).sendErrorMessage(e);
}
}
if (jSONObject2 != null && jSONObject3 != null) {
jSONObject5.put("ocrResultFront", jSONObject2);
jSONObject5.put("ocrResultBack", jSONObject3);
}
if (jSONObject2 != null && jSONObject3 == null) {
jSONObject5.put("ocrResult", jSONObject2);
}
if (jSONObject4 != null) {
jSONObject5.put("qrResult", jSONObject4);
}
jSONObject5.put("checkDatabase", bool);
b<ResponseBody> validationAPICall = ApiClient.getService().validationAPICall(str, hashMap, RequestBody.create(MediaType.parse("application/json"), jSONObject5.toString()));
final TimingUtils timingUtils = new TimingUtils();
validationAPICall.C0(new c<ResponseBody>() {
public void onFailure(b<ResponseBody> bVar, Throwable th) {
HVLogUtils.d(RemoteDataSource.TAG, "makeValidationAPICall(): onFailure() called with: call = [" + bVar + "], t = [" + th + "]");
String unused = RemoteDataSource.TAG;
Utils.getErrorMessage(th);
SDKInternalConfig.getInstance().getErrorMonitoringService(context).sendErrorMessage(th);
HVError hVError = th.getLocalizedMessage().contains("Certificate pinning") ? new HVError(15, "Secure connection could not be established.") : new HVError(12, th.getLocalizedMessage());
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logValidationAPICallFailed(hVError);
}
aPICompletionCallback.onResult(hVError, null);
}
public void onResponse(b<ResponseBody> bVar, w<ResponseBody> wVar) {
HVLogUtils.d(RemoteDataSource.TAG, "makeValidationAPICall(): onResponse() called with: call = [" + bVar + "], response = [" + wVar + "]");
APIResponse aPIResponse = new APIResponse(wVar);
HVResponse hVResponse = new HVResponse();
hVResponse.setApiHeaders(aPIResponse.getResponseHeaders());
hVResponse.setStatusCode(aPIResponse.getStatusCode());
hVResponse.setStatusMessage(aPIResponse.getStatusMessage());
if (wVar.f()) {
try {
hVResponse.setApiResult(aPIResponse.getResponseBody());
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logValidationAPISuccess(aPIResponse.getRequestID(), timingUtils.getTimeDifferenceLong().longValue());
}
aPICompletionCallback.onResult(null, hVResponse);
return;
} catch (JSONException e2) {
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
try {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logValidationAPIFailed(e2.getLocalizedMessage(), wVar.b(), aPIResponse.getRequestID());
} catch (JSONException unused) {
RemoteDataSource.this.logError(e2);
}
}
aPICompletionCallback.onResult(RemoteDataSource.this.getErrorFromException(e2), hVResponse);
RemoteDataSource.this.printLogs(e2);
SDKInternalConfig.getInstance().getErrorMonitoringService(context).sendErrorMessage(e2);
return;
}
}
try {
HVError errorValidationAPI = RemoteDataSource.this.getErrorValidationAPI(aPIResponse.getErrorBody());
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logValidationAPIFailed(errorValidationAPI.getErrorMessage(), errorValidationAPI.getErrorCode(), aPIResponse.getRequestID());
}
aPICompletionCallback.onResult(errorValidationAPI, hVResponse);
} catch (JSONException e3) {
RemoteDataSource.this.printLogs(e3);
SDKInternalConfig.getInstance().getErrorMonitoringService(context).sendErrorMessage(e3);
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
try {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logValidationAPIFailed(e3.getLocalizedMessage(), wVar.b(), aPIResponse.getRequestID());
} catch (JSONException unused2) {
RemoteDataSource.this.logError(e3);
}
}
aPICompletionCallback.onResult(RemoteDataSource.this.getErrorFromException(e3), hVResponse);
}
}
});
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logValidationAPIPost();
}
}
@Override
public void makeVerifyDocAlignmentCall(final Context context, String str, String str2, JSONObject jSONObject, JSONObject jSONObject2, final List<Integer> list, final APICompletionCallback aPICompletionCallback) {
JSONObject jSONObject3 = jSONObject2;
HVLogUtils.d(TAG, "makeVerifyDocAlignmentCall() called with: context = [" + context + "], endpoint = [" + str + "], documentUri = [" + str2 + "], parameters = [" + jSONObject + "], headers = [" + jSONObject3 + "], allowedStatusCodes = [" + list + "], callback = [" + aPICompletionCallback + "]");
if (aPICompletionCallback == null) {
return;
}
if (context == null) {
aPICompletionCallback.onResult(new HVError(6, "Context object is null"), null);
return;
}
if (str2 == null || str2.trim().isEmpty() || !new File(str2).exists()) {
aPICompletionCallback.onResult(new HVError(6, "Document file path is invalid"), null);
return;
}
File file = new File(str2);
MultipartBody.Part createFormData = MultipartBody.Part.createFormData("image", file.getName(), RequestBody.create(MediaType.parse("image/jpeg"), file));
if (jSONObject3 == null) {
jSONObject3 = new JSONObject();
}
JSONObject addHeaderParams = addHeaderParams(jSONObject3);
final String uniqueIdentifierIfNeeded = SignatureHelper.getUniqueIdentifierIfNeeded(str2, addHeaderParams);
try {
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldUseSignature() && uniqueIdentifierIfNeeded != null) {
addHeaderParams.put(AppConstants.PARAMS_UUID, uniqueIdentifierIfNeeded);
}
} catch (JSONException e) {
printLogs(e);
SDKInternalConfig.getInstance().getErrorMonitoringService(context).sendErrorMessage(e);
}
final boolean checkForDataLogging = checkForDataLogging(jSONObject);
Map<String, RequestBody> mapFromJson = getMapFromJson(jSONObject);
Map<String, String> hashMap = new HashMap<>();
if (addHeaderParams != null) {
hashMap = (Map) new Gson().fromJson(addHeaderParams.toString(), HashMap.class);
}
final Map<String, String> map = hashMap;
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken() == null || HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken().isEmpty()) {
map.put(HyperKycConfig.APP_ID, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppId());
map.put(HyperKycConfig.APP_KEY, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppKey());
} else {
map.put(HyperKycConfig.AUTHORIZATION, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken());
}
b<ResponseBody> verifyAlignment = ApiClient.getService().verifyAlignment(str, map, createFormData, mapFromJson);
final String referenceId = getReferenceId(addHeaderParams);
final TimingUtils timingUtils = new TimingUtils();
verifyAlignment.C0(new c<ResponseBody>() {
public void onFailure(b<ResponseBody> bVar, Throwable th) {
HVLogUtils.d(RemoteDataSource.TAG, "makeVerifyDocAlignmentCall(): onFailure() called with: call = [" + bVar + "], t = [" + th + "]");
String unused = RemoteDataSource.TAG;
Utils.getErrorMessage(th);
SDKInternalConfig.getInstance().getErrorMonitoringService(context).sendErrorMessage(th);
HVError hVError = th.getLocalizedMessage().contains("Certificate pinning") ? new HVError(15, "Secure connection could not be established.") : new HVError(12, th.getLocalizedMessage());
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logVerifyAlignmentAPICallFailed(hVError);
}
aPICompletionCallback.onResult(hVError, null);
}
public void onResponse(b<ResponseBody> bVar, w<ResponseBody> wVar) {
String str3;
String str4;
HVLogUtils.d(RemoteDataSource.TAG, "makeVerifyDocAlignmentCall(): onResponse() called with: call = [" + bVar + "], response = [" + wVar + "]");
APIResponse aPIResponse = new APIResponse(wVar);
HVResponse hVResponse = new HVResponse();
JSONObject responseBody = aPIResponse.getResponseBody();
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldUseSignature() && (str4 = uniqueIdentifierIfNeeded) != null) {
try {
aPIResponse.setRequestSignature(str4);
} catch (JSONException e2) {
RemoteDataSource.this.logError(e2);
}
}
RemoteDataSource remoteDataSource = RemoteDataSource.this;
boolean isSignatureVerfied = remoteDataSource.isSignatureVerfied(aPIResponse, uniqueIdentifierIfNeeded, null, null, null, remoteDataSource.convertMapToJson(map), false, list);
HVError error = !isSignatureVerfied ? RemoteDataSource.this.getError(AppConstants.SIGNATURE_ERROR, 18) : null;
hVResponse.setApiHeaders(aPIResponse.getResponseHeaders());
hVResponse.setStatusCode(aPIResponse.getStatusCode());
hVResponse.setStatusMessage(aPIResponse.getStatusMessage());
try {
str3 = aPIResponse.getRequestID();
} catch (JSONException e3) {
RemoteDataSource.this.logError(e3);
str3 = null;
}
if (!wVar.f()) {
JSONObject errorBody = aPIResponse.getErrorBody();
HVError hVError = new HVError();
if (isSignatureVerfied) {
error = errorBody != null ? RemoteDataSource.this.getError(errorBody) : hVError;
}
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logVerifyAlignmentAPIFailed(checkForDataLogging, referenceId, error.getErrorMessage(), error.getErrorCode(), str3);
}
aPICompletionCallback.onResult(error, hVResponse);
return;
}
if (responseBody != null) {
if (!isSignatureVerfied) {
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logVerifyAlignmentAPIFailed(checkForDataLogging, referenceId, error.getErrorMessage(), error.getErrorCode(), str3);
}
aPICompletionCallback.onResult(error, hVResponse);
} else {
hVResponse.setApiResult(responseBody);
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logVerifyAlignmentAPISuccess(checkForDataLogging, referenceId, str3, timingUtils.getTimeDifferenceLong().longValue());
}
aPICompletionCallback.onResult(null, hVResponse);
}
}
}
});
if (SDKInternalConfig.getInstance().isShouldLogAnalyticsForThisUser()) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService(context).logVerifyAlignmentAPIPost();
}
}
@Override
public void postSensorDataFiles(final Context context, String str, File file) {
HVLogUtils.d(TAG, "postSensorDataFiles() called with: context = [" + context + "], endpoint = [" + str + "], sensorDataZipFile = [" + file + "]");
MultipartBody.Part createFormData = MultipartBody.Part.createFormData("sensorDataZipFile", file.getName(), RequestBody.create(MediaType.parse("application/zip"), file));
HashMap hashMap = new HashMap();
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken() == null || HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken().isEmpty()) {
hashMap.put(HyperKycConfig.APP_ID, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppId());
hashMap.put(HyperKycConfig.APP_KEY, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppKey());
} else {
hashMap.put(HyperKycConfig.AUTHORIZATION, HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAccessToken());
}
ApiClient.getSensorDataInterface().postSensorData(str, hashMap, createFormData).C0(new c<ResponseBody>() {
public void onFailure(b<ResponseBody> bVar, Throwable th) {
HVLogUtils.d(RemoteDataSource.TAG, "postSensorDataFiles(): onFailure() called with: call = [" + bVar + "], t = [" + th + "]");
String unused = RemoteDataSource.TAG;
StringBuilder sb = new StringBuilder();
sb.append("onFailure postSensorDataFiles : ");
sb.append(Utils.getErrorMessage(th));
FileHelper.delete(new File(context.getFilesDir(), "hv/sensorData"));
if (SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logSensorDataPostFailure(new HVError(2, Utils.getErrorMessage(th)));
}
}
public void onResponse(b<ResponseBody> bVar, w<ResponseBody> wVar) {
HVLogUtils.d(RemoteDataSource.TAG, "postSensorDataFiles(): onResponse() called with: call = [" + bVar + "], response = [" + wVar + "]");
FileHelper.delete(new File(context.getFilesDir(), "hv/sensorData"));
if (wVar.f()) {
if (SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logSensorDataPostSuccessful();
}
} else if (SDKInternalConfig.getInstance().getAnalyticsTrackerService() != null) {
SDKInternalConfig.getInstance().getAnalyticsTrackerService().logSensorDataPostFailure(new HVError(2, "response.isSuccessful() is false"));
}
}
});
}
public void processFailureResponse(Context context, Throwable th, APICompletionCallback aPICompletionCallback) {
HVLogUtils.d(TAG, "processFailureResponse() called with: context = [" + context + "], t = [" + th + "], callback = [" + aPICompletionCallback + "]");
SDKInternalConfig.getInstance().getErrorMonitoringService(context).sendErrorMessage(th);
aPICompletionCallback.onResult(th.getLocalizedMessage().contains("Certificate pinning") ? new HVError(15, "Secure connection could not be established.") : new HVError(12, th.getLocalizedMessage()), null);
}
public void processResponse(Context context, w<ResponseBody> wVar, String str, List<Integer> list, APICompletionCallback aPICompletionCallback) {
HVLogUtils.d(TAG, "processResponse() called with: context = [" + context + "], response = [" + wVar + "], uuid = [" + str + "], allowedStatusCodes = [" + list + "], callback = [" + aPICompletionCallback + "]");
APIResponse aPIResponse = new APIResponse(wVar);
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldUseSignature() && str != null) {
try {
aPIResponse.setRequestSignature(str);
} catch (JSONException e) {
logError(e);
}
}
boolean isSignatureVerfied = isSignatureVerfied(aPIResponse, str, null, null, null, null, false, list);
HVError error = !isSignatureVerfied ? getError(AppConstants.SIGNATURE_ERROR, 18) : null;
HVResponse hVResponse = new HVResponse();
hVResponse.setApiHeaders(aPIResponse.getResponseHeaders());
hVResponse.setStatusCode(aPIResponse.getStatusCode());
hVResponse.setStatusMessage(aPIResponse.getStatusMessage());
JSONObject responseBody = aPIResponse.getResponseBody();
if (!wVar.f()) {
if (!isSignatureVerfied) {
aPICompletionCallback.onResult(error, hVResponse);
return;
} else {
if (aPIResponse.getErrorBody() != null) {
aPICompletionCallback.onResult(getError(aPIResponse.getErrorBody()), hVResponse);
return;
}
return;
}
}
if (responseBody != null) {
if (!isSignatureVerfied) {
aPICompletionCallback.onResult(error, hVResponse);
} else {
hVResponse.setApiResult(responseBody);
aPICompletionCallback.onResult(null, hVResponse);
}
}
}
public JSONObject setCustomHeaders(Headers headers, String str) {
HVLogUtils.d(TAG, "setCustomHeaders() called with: headers = [" + headers + "], uuid = [" + str + "]");
JSONObject jSONObject = new JSONObject();
for (int i = 0; i < headers.size(); i++) {
try {
String name = headers.name(i);
String value = headers.value(i);
if (name.toLowerCase().startsWith("x-hv-")) {
jSONObject.put(name, value);
}
if (name.equalsIgnoreCase(Constants.X_REQUEST_ID)) {
jSONObject.put(AppConstants.HV_REQUEST_ID, value);
}
if (name.equalsIgnoreCase("x-response-signature")) {
jSONObject.put("X-HV-Response-Signature", value);
}
} catch (Exception e) {
printLogs(e);
if (SDKInternalConfig.getInstance().getErrorMonitoringService() == null) {
return null;
}
SDKInternalConfig.getInstance().getErrorMonitoringService().sendErrorMessage(e);
return null;
}
}
if (HyperSnapSDK.getInstance().getHyperSnapSDKConfig().isShouldUseSignature() && str != null) {
jSONObject.put("X-HV-Request-Signature", str);
}
return jSONObject;
}
@Override
public void verifyPair(String str, String str2, final DataSource.NetworkCallback networkCallback) {
HVLogUtils.d(TAG, "verifyPair() called with: imageFilePath1 = [" + str + "], imageFilePath2 = [" + str2 + "], callback = [" + networkCallback + "]");
File file = new File(str);
MultipartBody.Part createFormData = MultipartBody.Part.createFormData("image1", file.getName(), RequestBody.create(MediaType.parse("image/jpeg"), file));
File file2 = new File(str2);
ApiClient.getDocsService().verifyPair(SDKInternalConfig.getInstance().getVerifyPairUri(), HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppId(), HyperSnapSDK.getInstance().getHyperSnapSDKConfig().getAppKey(), createFormData, MultipartBody.Part.createFormData("image2", file2.getName(), RequestBody.create(MediaType.parse("image/jpeg"), file2)), RequestBody.create(MediaType.parse("text/plain"), "selfie")).C0(new c<GestureResponse>() {
public void onFailure(b<GestureResponse> bVar, Throwable th) {
HVLogUtils.d(RemoteDataSource.TAG, "verifyPair(): onFailure() called with: call = [" + bVar + "], t = [" + th + "]");
networkCallback.onFailure(12, th.getLocalizedMessage());
}
public void onResponse(b<GestureResponse> bVar, w<GestureResponse> wVar) {
HVLogUtils.d(RemoteDataSource.TAG, "verifyPair(): onResponse() called with: call = [" + bVar + "], response = [" + wVar + "]");
GestureResponse gestureResponse = (GestureResponse) wVar.a();
gestureResponse.setHttpStatusCode(Integer.valueOf(wVar.b()));
gestureResponse.setStatusMessage(wVar.g());
networkCallback.onSuccess(gestureResponse);
}
});
}
public HVError getError(String str, int i) {
HVLogUtils.d(TAG, "getError() called with: errorMessage = [" + str + "], errorCode = [" + i + "]");
return new HVError(i, str);
}
}