190 lines
9 KiB
Java
190 lines
9 KiB
Java
package com.discord.utilities.captcha;
|
|
|
|
import android.app.Activity;
|
|
import android.os.Bundle;
|
|
import c.i.a.f.e.h.a;
|
|
import c.i.a.f.h.o.l;
|
|
import c.j.a.f.a;
|
|
import c.j.a.f.c;
|
|
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) {
|
|
this.$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 // c.j.a.f.a
|
|
public final void onFailure(HCaptchaException hCaptchaException) {
|
|
HCaptchaError hCaptchaError = hCaptchaException.hCaptchaError;
|
|
if (hCaptchaError == HCaptchaError.CHALLENGE_CLOSED) {
|
|
this.$emitter.onCompleted();
|
|
return;
|
|
}
|
|
String name = hCaptchaError.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(2131887192, 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 = c.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.l = StoreStream.Companion.getUserSettingsSystem().getLocale();
|
|
builder.k = true;
|
|
Boolean bool = builder.f2374c;
|
|
if (!builder.b) {
|
|
bool = HCaptchaConfig.access$000();
|
|
}
|
|
String str = builder.f;
|
|
if (!builder.e) {
|
|
str = HCaptchaConfig.access$100();
|
|
}
|
|
String str2 = builder.l;
|
|
if (!builder.k) {
|
|
str2 = HCaptchaConfig.access$200();
|
|
}
|
|
HCaptchaSize hCaptchaSize = builder.n;
|
|
if (!builder.m) {
|
|
hCaptchaSize = HCaptchaConfig.access$300();
|
|
}
|
|
HCaptchaTheme hCaptchaTheme = builder.p;
|
|
if (!builder.o) {
|
|
hCaptchaTheme = HCaptchaConfig.access$400();
|
|
}
|
|
HCaptchaConfig hCaptchaConfig = new HCaptchaConfig(builder.a, bool, builder.d, str, builder.g, builder.h, builder.i, builder.j, str2, hCaptchaSize, hCaptchaTheme);
|
|
c.j.a.a aVar = new c.j.a.a(activity);
|
|
HCaptcha$1 hCaptcha$1 = new HCaptcha$1(aVar);
|
|
String str3 = c.j.a.c.i;
|
|
Bundle bundle = new Bundle();
|
|
bundle.putSerializable("hCaptchaConfig", hCaptchaConfig);
|
|
bundle.putParcelable("hCaptchaDialogListener", hCaptcha$1);
|
|
c.j.a.c cVar = new c.j.a.c();
|
|
cVar.setArguments(bundle);
|
|
cVar.show(aVar.e, c.j.a.c.i);
|
|
aVar.f1448c.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.f2285c;
|
|
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);
|
|
}
|
|
}
|
|
}
|