447 lines
17 KiB
Java
447 lines
17 KiB
Java
package com.discord.utilities.captcha;
|
|
|
|
import android.app.Activity;
|
|
import android.text.TextUtils;
|
|
import androidx.appcompat.widget.ActivityChooserModel;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import b.d.b.a.a;
|
|
import b.i.a.f.e.h.c;
|
|
import b.i.a.f.e.h.j.d;
|
|
import b.i.a.f.e.k.k;
|
|
import b.i.a.f.e.k.s;
|
|
import b.i.a.f.e.k.v;
|
|
import b.i.a.f.h.o.i;
|
|
import b.i.a.f.h.o.j;
|
|
import b.i.a.f.n.c0;
|
|
import b.i.a.f.n.g;
|
|
import com.discord.R;
|
|
import com.discord.app.AppActivity;
|
|
import com.discord.widgets.notice.WidgetNoticeDialog;
|
|
import com.google.android.gms.common.GoogleApiAvailability;
|
|
import com.google.android.gms.safetynet.SafetyNetApi;
|
|
import com.google.android.gms.safetynet.SafetyNetClient;
|
|
import com.google.android.gms.tasks.Task;
|
|
import com.google.android.gms.tasks.TaskCompletionSource;
|
|
import d0.z.d.m;
|
|
import java.util.Objects;
|
|
import java.util.concurrent.Executor;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Emitter;
|
|
import rx.Observable;
|
|
/* compiled from: CaptchaHelper.kt */
|
|
public final class CaptchaHelper {
|
|
public static final String CAPTCHA_KEY = "captcha_key";
|
|
private static final String FAILED_CAPTCHA_EXPIRED = "expired";
|
|
private static final String FAILED_DEVICE_UNSUPPORTED = "unsupported_device";
|
|
private static final String FAILED_MISSING_DEPS = "missing_dependencies";
|
|
public static final CaptchaHelper INSTANCE = new CaptchaHelper();
|
|
private static final String RECAPTCHA_SITE_KEY = "6Lff5jIUAAAAAImNXvYYPv2VW2En3Dexy4oX2o4s";
|
|
private static String captchaRqtoken;
|
|
private static String captchaToken;
|
|
|
|
/* compiled from: CaptchaHelper.kt */
|
|
public static final class CaptchaPayload {
|
|
private final String captchaKey;
|
|
private final String captchaRqtoken;
|
|
|
|
public CaptchaPayload(String str, String str2) {
|
|
m.checkNotNullParameter(str, "captchaKey");
|
|
this.captchaKey = str;
|
|
this.captchaRqtoken = str2;
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ CaptchaPayload(String str, String str2, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(str, (i & 2) != 0 ? null : str2);
|
|
}
|
|
|
|
public static /* synthetic */ CaptchaPayload copy$default(CaptchaPayload captchaPayload, String str, String str2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
str = captchaPayload.captchaKey;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
str2 = captchaPayload.captchaRqtoken;
|
|
}
|
|
return captchaPayload.copy(str, str2);
|
|
}
|
|
|
|
public final String component1() {
|
|
return this.captchaKey;
|
|
}
|
|
|
|
public final String component2() {
|
|
return this.captchaRqtoken;
|
|
}
|
|
|
|
public final CaptchaPayload copy(String str, String str2) {
|
|
m.checkNotNullParameter(str, "captchaKey");
|
|
return new CaptchaPayload(str, str2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof CaptchaPayload)) {
|
|
return false;
|
|
}
|
|
CaptchaPayload captchaPayload = (CaptchaPayload) obj;
|
|
return m.areEqual(this.captchaKey, captchaPayload.captchaKey) && m.areEqual(this.captchaRqtoken, captchaPayload.captchaRqtoken);
|
|
}
|
|
|
|
public final String getCaptchaKey() {
|
|
return this.captchaKey;
|
|
}
|
|
|
|
public final String getCaptchaRqtoken() {
|
|
return this.captchaRqtoken;
|
|
}
|
|
|
|
public int hashCode() {
|
|
String str = this.captchaKey;
|
|
int i = 0;
|
|
int hashCode = (str != null ? str.hashCode() : 0) * 31;
|
|
String str2 = this.captchaRqtoken;
|
|
if (str2 != null) {
|
|
i = str2.hashCode();
|
|
}
|
|
return hashCode + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder R = a.R("CaptchaPayload(captchaKey=");
|
|
R.append(this.captchaKey);
|
|
R.append(", captchaRqtoken=");
|
|
return a.H(R, this.captchaRqtoken, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: CaptchaHelper.kt */
|
|
public static abstract class CaptchaRequest {
|
|
|
|
/* compiled from: CaptchaHelper.kt */
|
|
public static final class HCaptcha extends CaptchaRequest {
|
|
private final Activity activity;
|
|
private final String rqdata;
|
|
private final String siteKey;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public HCaptcha(String str, Activity activity, String str2) {
|
|
super(null);
|
|
m.checkNotNullParameter(str, "siteKey");
|
|
m.checkNotNullParameter(activity, ActivityChooserModel.ATTRIBUTE_ACTIVITY);
|
|
this.siteKey = str;
|
|
this.activity = activity;
|
|
this.rqdata = str2;
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ HCaptcha(String str, Activity activity, String str2, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(str, activity, (i & 4) != 0 ? null : str2);
|
|
}
|
|
|
|
public static /* synthetic */ HCaptcha copy$default(HCaptcha hCaptcha, String str, Activity activity, String str2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
str = hCaptcha.siteKey;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
activity = hCaptcha.activity;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
str2 = hCaptcha.rqdata;
|
|
}
|
|
return hCaptcha.copy(str, activity, str2);
|
|
}
|
|
|
|
public final String component1() {
|
|
return this.siteKey;
|
|
}
|
|
|
|
public final Activity component2() {
|
|
return this.activity;
|
|
}
|
|
|
|
public final String component3() {
|
|
return this.rqdata;
|
|
}
|
|
|
|
public final HCaptcha copy(String str, Activity activity, String str2) {
|
|
m.checkNotNullParameter(str, "siteKey");
|
|
m.checkNotNullParameter(activity, ActivityChooserModel.ATTRIBUTE_ACTIVITY);
|
|
return new HCaptcha(str, activity, str2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof HCaptcha)) {
|
|
return false;
|
|
}
|
|
HCaptcha hCaptcha = (HCaptcha) obj;
|
|
return m.areEqual(this.siteKey, hCaptcha.siteKey) && m.areEqual(this.activity, hCaptcha.activity) && m.areEqual(this.rqdata, hCaptcha.rqdata);
|
|
}
|
|
|
|
public final Activity getActivity() {
|
|
return this.activity;
|
|
}
|
|
|
|
public final String getRqdata() {
|
|
return this.rqdata;
|
|
}
|
|
|
|
public final String getSiteKey() {
|
|
return this.siteKey;
|
|
}
|
|
|
|
public int hashCode() {
|
|
String str = this.siteKey;
|
|
int i = 0;
|
|
int hashCode = (str != null ? str.hashCode() : 0) * 31;
|
|
Activity activity = this.activity;
|
|
int hashCode2 = (hashCode + (activity != null ? activity.hashCode() : 0)) * 31;
|
|
String str2 = this.rqdata;
|
|
if (str2 != null) {
|
|
i = str2.hashCode();
|
|
}
|
|
return hashCode2 + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder R = a.R("HCaptcha(siteKey=");
|
|
R.append(this.siteKey);
|
|
R.append(", activity=");
|
|
R.append(this.activity);
|
|
R.append(", rqdata=");
|
|
return a.H(R, this.rqdata, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: CaptchaHelper.kt */
|
|
public static final class ReCaptcha extends CaptchaRequest {
|
|
private final Activity activity;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public ReCaptcha(Activity activity) {
|
|
super(null);
|
|
m.checkNotNullParameter(activity, ActivityChooserModel.ATTRIBUTE_ACTIVITY);
|
|
this.activity = activity;
|
|
}
|
|
|
|
public static /* synthetic */ ReCaptcha copy$default(ReCaptcha reCaptcha, Activity activity, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
activity = reCaptcha.activity;
|
|
}
|
|
return reCaptcha.copy(activity);
|
|
}
|
|
|
|
public final Activity component1() {
|
|
return this.activity;
|
|
}
|
|
|
|
public final ReCaptcha copy(Activity activity) {
|
|
m.checkNotNullParameter(activity, ActivityChooserModel.ATTRIBUTE_ACTIVITY);
|
|
return new ReCaptcha(activity);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof ReCaptcha) && m.areEqual(this.activity, ((ReCaptcha) obj).activity);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final Activity getActivity() {
|
|
return this.activity;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Activity activity = this.activity;
|
|
if (activity != null) {
|
|
return activity.hashCode();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder R = a.R("ReCaptcha(activity=");
|
|
R.append(this.activity);
|
|
R.append(")");
|
|
return R.toString();
|
|
}
|
|
}
|
|
|
|
private CaptchaRequest() {
|
|
}
|
|
|
|
public /* synthetic */ CaptchaRequest(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: CaptchaHelper.kt */
|
|
public static final class Failure extends Throwable {
|
|
private final int errorStringId;
|
|
private final String reasonCode;
|
|
|
|
public Failure(int i, String str) {
|
|
m.checkNotNullParameter(str, "reasonCode");
|
|
this.errorStringId = i;
|
|
this.reasonCode = str;
|
|
}
|
|
|
|
public static /* synthetic */ Failure copy$default(Failure failure, int i, String str, int i2, Object obj) {
|
|
if ((i2 & 1) != 0) {
|
|
i = failure.errorStringId;
|
|
}
|
|
if ((i2 & 2) != 0) {
|
|
str = failure.reasonCode;
|
|
}
|
|
return failure.copy(i, str);
|
|
}
|
|
|
|
public final int component1() {
|
|
return this.errorStringId;
|
|
}
|
|
|
|
public final String component2() {
|
|
return this.reasonCode;
|
|
}
|
|
|
|
public final Failure copy(int i, String str) {
|
|
m.checkNotNullParameter(str, "reasonCode");
|
|
return new Failure(i, str);
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Failure)) {
|
|
return false;
|
|
}
|
|
Failure failure = (Failure) obj;
|
|
return this.errorStringId == failure.errorStringId && m.areEqual(this.reasonCode, failure.reasonCode);
|
|
}
|
|
|
|
public final int getErrorStringId() {
|
|
return this.errorStringId;
|
|
}
|
|
|
|
public final String getReasonCode() {
|
|
return this.reasonCode;
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public int hashCode() {
|
|
int i = this.errorStringId * 31;
|
|
String str = this.reasonCode;
|
|
return i + (str != null ? str.hashCode() : 0);
|
|
}
|
|
|
|
@Override // java.lang.Throwable, java.lang.Object
|
|
public String toString() {
|
|
StringBuilder R = a.R("Failure(errorStringId=");
|
|
R.append(this.errorStringId);
|
|
R.append(", reasonCode=");
|
|
return a.H(R, this.reasonCode, ")");
|
|
}
|
|
}
|
|
|
|
private CaptchaHelper() {
|
|
}
|
|
|
|
public static final /* synthetic */ void access$ensurePlayServicesAvailable(CaptchaHelper captchaHelper, GoogleApiAvailability googleApiAvailability, Activity activity, Function0 function0, Function1 function1) {
|
|
captchaHelper.ensurePlayServicesAvailable(googleApiAvailability, activity, function0, function1);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$showCaptcha(CaptchaHelper captchaHelper, SafetyNetClient safetyNetClient, Function1 function1, Function1 function12) {
|
|
captchaHelper.showCaptcha(safetyNetClient, function1, function12);
|
|
}
|
|
|
|
private final void ensurePlayServicesAvailable(GoogleApiAvailability googleApiAvailability, Activity activity, Function0<Unit> function0, Function1<? super Failure, Unit> function1) {
|
|
int c = googleApiAvailability.c(activity);
|
|
if (c != 0 && googleApiAvailability.d(c)) {
|
|
Task<Void> e = googleApiAvailability.e(activity);
|
|
CaptchaHelper$ensurePlayServicesAvailable$1 captchaHelper$ensurePlayServicesAvailable$1 = new CaptchaHelper$ensurePlayServicesAvailable$1(function0);
|
|
c0 c0Var = (c0) e;
|
|
Objects.requireNonNull(c0Var);
|
|
Executor executor = g.a;
|
|
c0Var.g(executor, captchaHelper$ensurePlayServicesAvailable$1);
|
|
c0Var.e(executor, new CaptchaHelper$ensurePlayServicesAvailable$2(function1));
|
|
m.checkNotNullExpressionValue(c0Var, "makeGooglePlayServicesAv…ISSING_DEPS))\n }");
|
|
} else if (c == 0) {
|
|
function0.mo1invoke();
|
|
} else {
|
|
function1.invoke(new Failure(R.string.captcha_failed_unsupported, FAILED_DEVICE_UNSUPPORTED));
|
|
}
|
|
}
|
|
|
|
private final void showCaptcha(SafetyNetClient safetyNetClient, Function1<? super String, Unit> function1, Function1<? super Failure, Unit> function12) {
|
|
Objects.requireNonNull(safetyNetClient);
|
|
SafetyNetApi safetyNetApi = b.i.a.f.k.a.d;
|
|
c cVar = safetyNetClient.g;
|
|
Objects.requireNonNull((i) safetyNetApi);
|
|
if (!TextUtils.isEmpty(RECAPTCHA_SITE_KEY)) {
|
|
d a = cVar.a(new j(cVar, RECAPTCHA_SITE_KEY));
|
|
v vVar = new v(new SafetyNetApi.RecaptchaTokenResponse());
|
|
k.b bVar = k.a;
|
|
TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
|
|
a.c(new s(a, taskCompletionSource, vVar, bVar));
|
|
c0<TResult> c0Var = taskCompletionSource.a;
|
|
CaptchaHelper$showCaptcha$1 captchaHelper$showCaptcha$1 = new CaptchaHelper$showCaptcha$1(function1);
|
|
Objects.requireNonNull(c0Var);
|
|
Executor executor = g.a;
|
|
c0Var.g(executor, captchaHelper$showCaptcha$1);
|
|
c0Var.e(executor, new CaptchaHelper$showCaptcha$2(function12));
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("Null or empty site key in verifyWithRecaptcha");
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.utilities.captcha.CaptchaHelper */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ void showCaptchaHelpDialog$default(CaptchaHelper captchaHelper, AppActivity appActivity, Function0 function0, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
function0 = null;
|
|
}
|
|
captchaHelper.showCaptchaHelpDialog(appActivity, function0);
|
|
}
|
|
|
|
public final String getCaptchaRqtoken() {
|
|
return captchaRqtoken;
|
|
}
|
|
|
|
public final String getCaptchaToken() {
|
|
return captchaToken;
|
|
}
|
|
|
|
public final void setCaptchaRqtoken(String str) {
|
|
captchaRqtoken = str;
|
|
}
|
|
|
|
public final void setCaptchaToken(String str) {
|
|
captchaToken = str;
|
|
}
|
|
|
|
public final void showCaptchaHelpDialog(AppActivity appActivity, Function0<Unit> function0) {
|
|
FragmentManager supportFragmentManager;
|
|
if (appActivity != null && (supportFragmentManager = appActivity.getSupportFragmentManager()) != null) {
|
|
WidgetNoticeDialog.Builder negativeButton$default = WidgetNoticeDialog.Builder.setNegativeButton$default(new WidgetNoticeDialog.Builder(appActivity).setTitle(R.string.captcha_problems).setMessage(R.string.captcha_problems_info).setPositiveButton(R.string.captcha_open_browser, new CaptchaHelper$showCaptchaHelpDialog$$inlined$let$lambda$1(appActivity, function0)), (int) R.string.cancel, (Function1) null, 2, (Object) null);
|
|
m.checkNotNullExpressionValue(supportFragmentManager, "it");
|
|
negativeButton$default.show(supportFragmentManager);
|
|
}
|
|
}
|
|
|
|
public final Observable<String> tryShowCaptcha(CaptchaRequest captchaRequest) {
|
|
m.checkNotNullParameter(captchaRequest, "captchaRequest");
|
|
Observable<String> n = Observable.n(new CaptchaHelper$tryShowCaptcha$1(captchaRequest), Emitter.BackpressureMode.BUFFER);
|
|
m.checkNotNullExpressionValue(n, "Observable.create({ emit….BackpressureMode.BUFFER)");
|
|
return n;
|
|
}
|
|
}
|