390 lines
9.9 KiB
Smali
390 lines
9.9 KiB
Smali
.class public final Lcom/discord/utilities/auth/AuthUtils;
|
|
.super Ljava/lang/Object;
|
|
.source "AuthUtils.kt"
|
|
|
|
|
|
# static fields
|
|
.field public static final AUTHY_PACKAGE:Ljava/lang/String; = "com.authy.authy"
|
|
|
|
.field public static final GOOGLE_AUTHENTICATOR_PACKAGE:Ljava/lang/String; = "com.google.android.apps.authenticator2"
|
|
|
|
.field public static final INSTANCE:Lcom/discord/utilities/auth/AuthUtils;
|
|
|
|
.field public static final MAX_PASSWORD_LENGTH:I = 0x80
|
|
|
|
.field public static final MIN_PASSWORD_LENGTH:I = 0x6
|
|
|
|
.field public static final URL_AUTHY:Ljava/lang/String; = "https://play.google.com/store/apps/details?id=com.authy.authy"
|
|
|
|
.field public static final URL_GOOGLE_AUTHENTICATOR:Ljava/lang/String; = "https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2"
|
|
|
|
.field public static final URL_PLAY_STORE:Ljava/lang/String; = "https://play.google.com/store/apps/details"
|
|
|
|
|
|
# direct methods
|
|
.method public static constructor <clinit>()V
|
|
.locals 1
|
|
|
|
new-instance v0, Lcom/discord/utilities/auth/AuthUtils;
|
|
|
|
invoke-direct {v0}, Lcom/discord/utilities/auth/AuthUtils;-><init>()V
|
|
|
|
sput-object v0, Lcom/discord/utilities/auth/AuthUtils;->INSTANCE:Lcom/discord/utilities/auth/AuthUtils;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public constructor <init>()V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static final synthetic access$isValidEmail(Lcom/discord/utilities/auth/AuthUtils;Ljava/lang/String;)Z
|
|
.locals 0
|
|
|
|
invoke-direct {p0, p1}, Lcom/discord/utilities/auth/AuthUtils;->isValidEmail(Ljava/lang/String;)Z
|
|
|
|
move-result p0
|
|
|
|
return p0
|
|
.end method
|
|
|
|
.method private final isValidEmail(Ljava/lang/String;)Z
|
|
.locals 3
|
|
|
|
invoke-interface {p1}, Ljava/lang/CharSequence;->length()I
|
|
|
|
move-result v0
|
|
|
|
const/4 v1, 0x1
|
|
|
|
const/4 v2, 0x0
|
|
|
|
if-lez v0, :cond_0
|
|
|
|
const/4 v0, 0x1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
const/4 v0, 0x0
|
|
|
|
:goto_0
|
|
if-eqz v0, :cond_1
|
|
|
|
sget-object v0, Landroid/util/Patterns;->EMAIL_ADDRESS:Ljava/util/regex/Pattern;
|
|
|
|
invoke-virtual {v0, p1}, Ljava/util/regex/Pattern;->matcher(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {p1}, Ljava/util/regex/Matcher;->matches()Z
|
|
|
|
move-result p1
|
|
|
|
if-eqz p1, :cond_1
|
|
|
|
goto :goto_1
|
|
|
|
:cond_1
|
|
const/4 v1, 0x0
|
|
|
|
:goto_1
|
|
return v1
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public final createDiscriminatorInputValidator(II)Lcom/discord/utilities/view/validators/InputValidator;
|
|
.locals 1
|
|
.param p1 # I
|
|
.annotation build Landroidx/annotation/StringRes;
|
|
.end annotation
|
|
.end param
|
|
.param p2 # I
|
|
.annotation build Landroidx/annotation/StringRes;
|
|
.end annotation
|
|
.end param
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(II)",
|
|
"Lcom/discord/utilities/view/validators/InputValidator<",
|
|
"Lcom/google/android/material/textfield/TextInputLayout;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
|
|
new-instance v0, Lcom/discord/utilities/auth/AuthUtils$createDiscriminatorInputValidator$1;
|
|
|
|
invoke-direct {v0, p1, p2}, Lcom/discord/utilities/auth/AuthUtils$createDiscriminatorInputValidator$1;-><init>(II)V
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public final createEmailInputValidator(I)Lcom/discord/utilities/view/validators/BasicTextInputValidator;
|
|
.locals 2
|
|
.param p1 # I
|
|
.annotation build Landroidx/annotation/StringRes;
|
|
.end annotation
|
|
.end param
|
|
|
|
new-instance v0, Lcom/discord/utilities/view/validators/BasicTextInputValidator;
|
|
|
|
sget-object v1, Lcom/discord/utilities/auth/AuthUtils$createEmailInputValidator$1;->INSTANCE:Lcom/discord/utilities/auth/AuthUtils$createEmailInputValidator$1;
|
|
|
|
invoke-direct {v0, p1, v1}, Lcom/discord/utilities/view/validators/BasicTextInputValidator;-><init>(ILkotlin/jvm/functions/Function1;)V
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public final createPasswordInputValidator(I)Lcom/discord/utilities/view/validators/BasicTextInputValidator;
|
|
.locals 2
|
|
.param p1 # I
|
|
.annotation build Landroidx/annotation/StringRes;
|
|
.end annotation
|
|
.end param
|
|
|
|
new-instance v0, Lcom/discord/utilities/view/validators/BasicTextInputValidator;
|
|
|
|
sget-object v1, Lcom/discord/utilities/auth/AuthUtils$createPasswordInputValidator$1;->INSTANCE:Lcom/discord/utilities/auth/AuthUtils$createPasswordInputValidator$1;
|
|
|
|
invoke-direct {v0, p1, v1}, Lcom/discord/utilities/view/validators/BasicTextInputValidator;-><init>(ILkotlin/jvm/functions/Function1;)V
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public final encodeTotpSecret(Ljava/lang/String;)Ljava/lang/String;
|
|
.locals 4
|
|
.annotation build Landroid/annotation/SuppressLint;
|
|
value = {
|
|
"DefaultLocale"
|
|
}
|
|
.end annotation
|
|
|
|
const-string v0, "secret"
|
|
|
|
invoke-static {p1, v0}, Lc0/n/c/j;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
const-string v0, " "
|
|
|
|
const-string v1, ""
|
|
|
|
const/4 v2, 0x0
|
|
|
|
const/4 v3, 0x4
|
|
|
|
invoke-static {p1, v0, v1, v2, v3}, Lc0/t/k;->replace$default(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZI)Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {p1}, Ljava/lang/String;->toUpperCase()Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
const-string v0, "(this as java.lang.String).toUpperCase()"
|
|
|
|
invoke-static {p1, v0}, Lc0/n/c/j;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
invoke-static {p1}, Lc0/t/p;->trim(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-virtual {p1}, Ljava/lang/Object;->toString()Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
return-object p1
|
|
.end method
|
|
|
|
.method public final generateNewTotpKey()Ljava/lang/String;
|
|
.locals 5
|
|
.annotation build Landroid/annotation/SuppressLint;
|
|
value = {
|
|
"DefaultLocale"
|
|
}
|
|
.end annotation
|
|
|
|
invoke-static {}, Lcom/discord/utilities/time/ClockFactory;->get()Lcom/discord/utilities/time/Clock;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-interface {v0}, Lcom/discord/utilities/time/Clock;->currentTimeMillis()J
|
|
|
|
move-result-wide v0
|
|
|
|
new-instance v2, Lc0/p/d;
|
|
|
|
long-to-int v3, v0
|
|
|
|
const/16 v4, 0x20
|
|
|
|
shr-long/2addr v0, v4
|
|
|
|
long-to-int v1, v0
|
|
|
|
invoke-direct {v2, v3, v1}, Lc0/p/d;-><init>(II)V
|
|
|
|
const/16 v0, 0xa
|
|
|
|
new-array v0, v0, [B
|
|
|
|
invoke-virtual {v2, v0}, Lc0/p/c;->nextBytes([B)[B
|
|
|
|
move-result-object v0
|
|
|
|
invoke-static {v0}, Lcom/discord/utilities/string/StringUtilsKt;->encodeToBase32String([B)Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
const-string/jumbo v1, "utf-8"
|
|
|
|
invoke-static {v0, v1}, Ljava/net/URLEncoder;->encode(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "URLEncoder\n .enco\u2026oBase32String(), \"utf-8\")"
|
|
|
|
invoke-static {v0, v1}, Lc0/n/c/j;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
const-string v1, "="
|
|
|
|
const-string v2, ""
|
|
|
|
const/4 v3, 0x0
|
|
|
|
const/4 v4, 0x4
|
|
|
|
invoke-static {v0, v1, v2, v3, v4}, Lc0/t/k;->replace$default(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZI)Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "(this as java.lang.String).toLowerCase()"
|
|
|
|
invoke-static {v0, v1}, Lc0/n/c/j;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
invoke-static {v0}, Lc0/t/p;->trim(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {v0}, Ljava/lang/Object;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
new-instance v1, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v1, v0}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
|
|
|
|
const/4 v0, 0x3
|
|
|
|
new-array v0, v0, [Ljava/lang/Integer;
|
|
|
|
const/16 v2, 0xc
|
|
|
|
invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
|
|
|
|
move-result-object v2
|
|
|
|
aput-object v2, v0, v3
|
|
|
|
const/4 v2, 0x1
|
|
|
|
const/16 v3, 0x8
|
|
|
|
invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
|
|
|
|
move-result-object v3
|
|
|
|
aput-object v3, v0, v2
|
|
|
|
const/4 v2, 0x2
|
|
|
|
invoke-static {v4}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
|
|
|
|
move-result-object v3
|
|
|
|
aput-object v3, v0, v2
|
|
|
|
invoke-static {v0}, Lf/h/a/f/f/n/f;->listOf([Ljava/lang/Object;)Ljava/util/List;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-interface {v0}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object v0
|
|
|
|
:goto_0
|
|
invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v2
|
|
|
|
if-eqz v2, :cond_0
|
|
|
|
invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v2
|
|
|
|
check-cast v2, Ljava/lang/Number;
|
|
|
|
invoke-virtual {v2}, Ljava/lang/Number;->intValue()I
|
|
|
|
move-result v2
|
|
|
|
const-string v3, " "
|
|
|
|
invoke-virtual {v1, v2, v3}, Ljava/lang/StringBuilder;->insert(ILjava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "builder.toString()"
|
|
|
|
invoke-static {v0, v1}, Lc0/n/c/j;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public final isValidPasswordLength(Ljava/lang/String;)Z
|
|
.locals 1
|
|
|
|
const-string v0, "password"
|
|
|
|
invoke-static {p1, v0}, Lc0/n/c/j;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
invoke-virtual {p1}, Ljava/lang/String;->length()I
|
|
|
|
move-result p1
|
|
|
|
const/4 v0, 0x6
|
|
|
|
if-le v0, p1, :cond_0
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
const/16 v0, 0x80
|
|
|
|
if-lt v0, p1, :cond_1
|
|
|
|
const/4 p1, 0x1
|
|
|
|
goto :goto_1
|
|
|
|
:cond_1
|
|
:goto_0
|
|
const/4 p1, 0x0
|
|
|
|
:goto_1
|
|
return p1
|
|
.end method
|