198 lines
9.3 KiB
Java
198 lines
9.3 KiB
Java
package com.discord.utilities.captcha;
|
|
|
|
import android.app.Activity;
|
|
import android.os.Bundle;
|
|
import b.i.a.f.e.h.a;
|
|
import b.i.a.f.h.o.l;
|
|
import b.j.a.f.a;
|
|
import b.j.a.f.c;
|
|
import com.discord.R;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.captcha.CaptchaHelper;
|
|
import com.google.android.gms.common.GoogleApiAvailability;
|
|
import com.google.android.gms.safetynet.SafetyNetClient;
|
|
import com.hcaptcha.sdk.HCaptcha$1;
|
|
import com.hcaptcha.sdk.HCaptchaConfig;
|
|
import com.hcaptcha.sdk.HCaptchaError;
|
|
import com.hcaptcha.sdk.HCaptchaException;
|
|
import com.hcaptcha.sdk.HCaptchaSize;
|
|
import com.hcaptcha.sdk.HCaptchaTheme;
|
|
import com.hcaptcha.sdk.HCaptchaTokenResponse;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import java.util.Locale;
|
|
import java.util.Objects;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import rx.Emitter;
|
|
import rx.functions.Action1;
|
|
/* compiled from: CaptchaHelper.kt */
|
|
public final class CaptchaHelper$tryShowCaptcha$1<T> implements Action1<Emitter<String>> {
|
|
public final /* synthetic */ CaptchaHelper.CaptchaRequest $captchaRequest;
|
|
|
|
/* compiled from: CaptchaHelper.kt */
|
|
/* renamed from: com.discord.utilities.captcha.CaptchaHelper$tryShowCaptcha$1$1 reason: invalid class name */
|
|
public static final class AnonymousClass1<TResult> implements c<HCaptchaTokenResponse> {
|
|
public final /* synthetic */ Emitter $emitter;
|
|
|
|
public AnonymousClass1(Emitter emitter) {
|
|
this.$emitter = emitter;
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: rx.Emitter */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public final void onSuccess(HCaptchaTokenResponse hCaptchaTokenResponse) {
|
|
Emitter emitter = this.$emitter;
|
|
m.checkNotNullExpressionValue(hCaptchaTokenResponse, "hCaptchaTokenResponse");
|
|
emitter.onNext(hCaptchaTokenResponse.a);
|
|
this.$emitter.onCompleted();
|
|
}
|
|
}
|
|
|
|
/* compiled from: CaptchaHelper.kt */
|
|
/* renamed from: com.discord.utilities.captcha.CaptchaHelper$tryShowCaptcha$1$2 reason: invalid class name */
|
|
public static final class AnonymousClass2 implements a {
|
|
public final /* synthetic */ Emitter $emitter;
|
|
public final /* synthetic */ Function1 $errorHandler;
|
|
|
|
public AnonymousClass2(Emitter emitter, Function1 function1) {
|
|
this.$emitter = emitter;
|
|
this.$errorHandler = function1;
|
|
}
|
|
|
|
@Override // b.j.a.f.a
|
|
public final void onFailure(HCaptchaException hCaptchaException) {
|
|
m.checkNotNullExpressionValue(hCaptchaException, "hCaptchaException");
|
|
if (hCaptchaException.a() == HCaptchaError.CHALLENGE_CLOSED) {
|
|
this.$emitter.onCompleted();
|
|
return;
|
|
}
|
|
String name = hCaptchaException.a().name();
|
|
Locale locale = Locale.ROOT;
|
|
m.checkNotNullExpressionValue(locale, "Locale.ROOT");
|
|
Objects.requireNonNull(name, "null cannot be cast to non-null type java.lang.String");
|
|
String lowerCase = name.toLowerCase(locale);
|
|
m.checkNotNullExpressionValue(lowerCase, "(this as java.lang.String).toLowerCase(locale)");
|
|
this.$errorHandler.invoke(new CaptchaHelper.Failure(R.string.captcha_failed, lowerCase));
|
|
}
|
|
}
|
|
|
|
/* compiled from: CaptchaHelper.kt */
|
|
/* renamed from: com.discord.utilities.captcha.CaptchaHelper$tryShowCaptcha$1$3 reason: invalid class name */
|
|
public static final class AnonymousClass3 extends o implements Function0<Unit> {
|
|
public final /* synthetic */ Activity $activity;
|
|
public final /* synthetic */ Emitter $emitter;
|
|
public final /* synthetic */ Function1 $errorHandler;
|
|
|
|
/* compiled from: CaptchaHelper.kt */
|
|
/* renamed from: com.discord.utilities.captcha.CaptchaHelper$tryShowCaptcha$1$3$1 reason: invalid class name */
|
|
public static final class AnonymousClass1 extends o implements Function1<String, Unit> {
|
|
public final /* synthetic */ AnonymousClass3 this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public AnonymousClass1(AnonymousClass3 r1) {
|
|
super(1);
|
|
this.this$0 = r1;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public /* bridge */ /* synthetic */ Unit invoke(String str) {
|
|
invoke(str);
|
|
return Unit.a;
|
|
}
|
|
|
|
public final void invoke(String str) {
|
|
m.checkNotNullParameter(str, "token");
|
|
this.this$0.$emitter.onNext(str);
|
|
this.this$0.$emitter.onCompleted();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public AnonymousClass3(Activity activity, Emitter emitter, Function1 function1) {
|
|
super(0);
|
|
this.$activity = activity;
|
|
this.$emitter = emitter;
|
|
this.$errorHandler = function1;
|
|
}
|
|
|
|
@Override // kotlin.jvm.functions.Function0
|
|
/* renamed from: invoke */
|
|
public final void mo1invoke() {
|
|
CaptchaHelper captchaHelper = CaptchaHelper.INSTANCE;
|
|
Activity activity = this.$activity;
|
|
a.g<l> gVar = b.i.a.f.k.a.a;
|
|
SafetyNetClient safetyNetClient = new SafetyNetClient(activity);
|
|
m.checkNotNullExpressionValue(safetyNetClient, "SafetyNet\n … .getClient(activity)");
|
|
CaptchaHelper.access$showCaptcha(captchaHelper, safetyNetClient, new AnonymousClass1(this), this.$errorHandler);
|
|
}
|
|
}
|
|
|
|
public CaptchaHelper$tryShowCaptcha$1(CaptchaHelper.CaptchaRequest captchaRequest) {
|
|
this.$captchaRequest = captchaRequest;
|
|
}
|
|
|
|
public final void call(Emitter<String> emitter) {
|
|
CaptchaHelper$tryShowCaptcha$1$errorHandler$1 captchaHelper$tryShowCaptcha$1$errorHandler$1 = new CaptchaHelper$tryShowCaptcha$1$errorHandler$1(emitter);
|
|
CaptchaHelper.CaptchaRequest captchaRequest = this.$captchaRequest;
|
|
if (captchaRequest instanceof CaptchaHelper.CaptchaRequest.HCaptcha) {
|
|
Activity activity = ((CaptchaHelper.CaptchaRequest.HCaptcha) captchaRequest).getActivity();
|
|
HCaptchaConfig.a builder = HCaptchaConfig.builder();
|
|
String siteKey = ((CaptchaHelper.CaptchaRequest.HCaptcha) this.$captchaRequest).getSiteKey();
|
|
Objects.requireNonNull(builder);
|
|
Objects.requireNonNull(siteKey, "siteKey is marked non-null but is null");
|
|
builder.a = siteKey;
|
|
builder.n = StoreStream.Companion.getUserSettingsSystem().getLocale();
|
|
builder.m = true;
|
|
Boolean bool = builder.c;
|
|
if (!builder.f3101b) {
|
|
bool = HCaptchaConfig.access$000();
|
|
}
|
|
Boolean bool2 = builder.e;
|
|
if (!builder.d) {
|
|
bool2 = HCaptchaConfig.access$100();
|
|
}
|
|
String str = builder.h;
|
|
if (!builder.g) {
|
|
str = HCaptchaConfig.access$200();
|
|
}
|
|
String str2 = builder.n;
|
|
if (!builder.m) {
|
|
str2 = HCaptchaConfig.access$300();
|
|
}
|
|
HCaptchaSize hCaptchaSize = builder.p;
|
|
if (!builder.o) {
|
|
hCaptchaSize = HCaptchaConfig.access$400();
|
|
}
|
|
HCaptchaTheme hCaptchaTheme = builder.r;
|
|
if (!builder.q) {
|
|
hCaptchaTheme = HCaptchaConfig.access$500();
|
|
}
|
|
HCaptchaConfig hCaptchaConfig = new HCaptchaConfig(builder.a, bool, bool2, builder.f, str, builder.i, builder.j, builder.k, builder.l, str2, hCaptchaSize, hCaptchaTheme);
|
|
b.j.a.a aVar = new b.j.a.a(activity);
|
|
HCaptcha$1 hCaptcha$1 = new HCaptcha$1(aVar);
|
|
String str3 = b.j.a.c.j;
|
|
Bundle bundle = new Bundle();
|
|
bundle.putSerializable("hCaptchaConfig", hCaptchaConfig);
|
|
bundle.putParcelable("hCaptchaDialogListener", hCaptcha$1);
|
|
b.j.a.c cVar = new b.j.a.c();
|
|
cVar.setArguments(bundle);
|
|
cVar.show(aVar.e, b.j.a.c.j);
|
|
aVar.c.add(new AnonymousClass1(emitter));
|
|
aVar.a();
|
|
aVar.d.add(new AnonymousClass2(emitter, captchaHelper$tryShowCaptcha$1$errorHandler$1));
|
|
aVar.a();
|
|
} else if (captchaRequest instanceof CaptchaHelper.CaptchaRequest.ReCaptcha) {
|
|
Activity activity2 = ((CaptchaHelper.CaptchaRequest.ReCaptcha) captchaRequest).getActivity();
|
|
CaptchaHelper captchaHelper = CaptchaHelper.INSTANCE;
|
|
Object obj = GoogleApiAvailability.c;
|
|
GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.d;
|
|
m.checkNotNullExpressionValue(googleApiAvailability, "GoogleApiAvailability\n .getInstance()");
|
|
CaptchaHelper.access$ensurePlayServicesAvailable(captchaHelper, googleApiAvailability, activity2, new AnonymousClass3(activity2, emitter, captchaHelper$tryShowCaptcha$1$errorHandler$1), captchaHelper$tryShowCaptcha$1$errorHandler$1);
|
|
}
|
|
}
|
|
}
|