Add authenticationCodeTypeFirebaseIos.

This commit is contained in:
levlam 2023-01-19 15:12:55 +03:00
parent f0e4a4cdc8
commit 1d9f2d6de9
4 changed files with 20 additions and 4 deletions

View File

@ -50,11 +50,17 @@ authenticationCodeTypeMissedCall phone_number_prefix:string length:int32 = Authe
//@length Length of the code
authenticationCodeTypeFragment url:string length:int32 = AuthenticationCodeType;
//@description An authentication code is delivered via Firebase Authentication
//@description An authentication code is delivered via Firebase Authentication to the official Android app
//@nonce Nonce to pass to the SafetyNet Attestation API
//@length Length of the code
authenticationCodeTypeFirebaseAndroid nonce:bytes length:int32 = AuthenticationCodeType;
//@description An authentication code is delivered via Firebase Authentication to the official iOS app
//@receipt Receipt of successful applikation token validation to compare with receipt from push notification
//@push_timeout Time after the next authentication method is supposed to be used if verification push notification isn't received, in seconds
//@length Length of the code
authenticationCodeTypeFirebaseIos receipt:string push_timeout:int32 length:int32 = AuthenticationCodeType;
//@description Information about the authentication code that was sent
//@phone_number A phone number that is being authenticated

View File

@ -164,6 +164,10 @@ SendCodeHelper::AuthenticationCodeInfo SendCodeHelper::get_sent_authentication_c
return AuthenticationCodeInfo{AuthenticationCodeInfo::Type::FirebaseAndroid, code_type->length_,
code_type->nonce_.as_slice().str()};
}
if ((code_type->flags_ & telegram_api::auth_sentCodeTypeFirebaseSms::RECEIPT_MASK) != 0) {
return AuthenticationCodeInfo{AuthenticationCodeInfo::Type::FirebaseIos, code_type->length_,
std::move(code_type->receipt_), code_type->push_timeout_};
}
return AuthenticationCodeInfo{AuthenticationCodeInfo::Type::Sms, code_type->length_, ""};
}
case telegram_api::auth_sentCodeTypeEmailCode::ID:
@ -196,6 +200,9 @@ td_api::object_ptr<td_api::AuthenticationCodeType> SendCodeHelper::get_authentic
case AuthenticationCodeInfo::Type::FirebaseAndroid:
return td_api::make_object<td_api::authenticationCodeTypeFirebaseAndroid>(authentication_code_info.pattern,
authentication_code_info.length);
case AuthenticationCodeInfo::Type::FirebaseIos:
return td_api::make_object<td_api::authenticationCodeTypeFirebaseIos>(
authentication_code_info.pattern, authentication_code_info.push_timeout, authentication_code_info.length);
default:
UNREACHABLE();
return nullptr;

View File

@ -57,14 +57,15 @@ class SendCodeHelper {
private:
struct AuthenticationCodeInfo {
enum class Type : int32 { None, Message, Sms, Call, FlashCall, MissedCall, Fragment, FirebaseAndroid };
enum class Type : int32 { None, Message, Sms, Call, FlashCall, MissedCall, Fragment, FirebaseAndroid, FirebaseIos };
Type type = Type::None;
int32 length = 0;
int32 push_timeout = 0;
string pattern;
AuthenticationCodeInfo() = default;
AuthenticationCodeInfo(Type type, int length, string pattern)
: type(type), length(length), pattern(std::move(pattern)) {
AuthenticationCodeInfo(Type type, int32 length, string pattern, int32 push_timeout = 0)
: type(type), length(length), push_timeout(push_timeout), pattern(std::move(pattern)) {
}
template <class StorerT>

View File

@ -18,6 +18,7 @@ void SendCodeHelper::AuthenticationCodeInfo::store(StorerT &storer) const {
using td::store;
store(type, storer);
store(length, storer);
store(push_timeout, storer);
store(pattern, storer);
}
@ -26,6 +27,7 @@ void SendCodeHelper::AuthenticationCodeInfo::parse(ParserT &parser) {
using td::parse;
parse(type, parser);
parse(length, parser);
parse(push_timeout, parser);
parse(pattern, parser);
}