From bf7207fa7d2b082211ec03c95e605034e0da8df1 Mon Sep 17 00:00:00 2001 From: Wizou <11647984+wiz0u@users.noreply.github.com> Date: Sun, 5 Feb 2023 15:43:49 +0100 Subject: [PATCH] Support for Firebase SMS --- src/Client.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Client.cs b/src/Client.cs index b0c76b0..452a82d 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -1074,6 +1074,21 @@ namespace WTelegram else if (sentCodeBase is Auth_SentCode sentCode) { phone_code_hash = sentCode.phone_code_hash; + if (sentCode.type is Auth_SentCodeTypeFirebaseSms firebaseSms) + { + var token = await ConfigAsync("firebase:" + Convert.ToHexString(firebaseSms.nonce)); + int index = token?.IndexOf(':') ?? -1; + if (!(index > 0 && token[..index] switch + { + "safety_net_token" => await this.Auth_RequestFirebaseSms(phone_number, phone_code_hash, safety_net_token: token[(index + 1)..]), + "ios_push_secret" => await this.Auth_RequestFirebaseSms(phone_number, phone_code_hash, ios_push_secret: token[(index + 1)..]), + _ => false + })) + { + sentCodeBase = await this.Auth_ResendCode(phone_number, phone_code_hash); + goto resent; + } + } var timeout = DateTime.UtcNow + TimeSpan.FromSeconds(sentCode.timeout); Helpers.Log(3, $"A verification code has been sent via {sentCode.type.GetType().Name[17..]}"); RaiseUpdate(sentCode);