Skip to content

Commit 1d9f2d6

Browse files
committed
Add authenticationCodeTypeFirebaseIos.
1 parent f0e4a4c commit 1d9f2d6

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

td/generate/scheme/td_api.tl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,17 @@ authenticationCodeTypeMissedCall phone_number_prefix:string length:int32 = Authe
5050
//@length Length of the code
5151
authenticationCodeTypeFragment url:string length:int32 = AuthenticationCodeType;
5252

53-
//@description An authentication code is delivered via Firebase Authentication
53+
//@description An authentication code is delivered via Firebase Authentication to the official Android app
5454
//@nonce Nonce to pass to the SafetyNet Attestation API
5555
//@length Length of the code
5656
authenticationCodeTypeFirebaseAndroid nonce:bytes length:int32 = AuthenticationCodeType;
5757

58+
//@description An authentication code is delivered via Firebase Authentication to the official iOS app
59+
//@receipt Receipt of successful applikation token validation to compare with receipt from push notification
60+
//@push_timeout Time after the next authentication method is supposed to be used if verification push notification isn't received, in seconds
61+
//@length Length of the code
62+
authenticationCodeTypeFirebaseIos receipt:string push_timeout:int32 length:int32 = AuthenticationCodeType;
63+
5864

5965
//@description Information about the authentication code that was sent
6066
//@phone_number A phone number that is being authenticated

td/telegram/SendCodeHelper.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ SendCodeHelper::AuthenticationCodeInfo SendCodeHelper::get_sent_authentication_c
164164
return AuthenticationCodeInfo{AuthenticationCodeInfo::Type::FirebaseAndroid, code_type->length_,
165165
code_type->nonce_.as_slice().str()};
166166
}
167+
if ((code_type->flags_ & telegram_api::auth_sentCodeTypeFirebaseSms::RECEIPT_MASK) != 0) {
168+
return AuthenticationCodeInfo{AuthenticationCodeInfo::Type::FirebaseIos, code_type->length_,
169+
std::move(code_type->receipt_), code_type->push_timeout_};
170+
}
167171
return AuthenticationCodeInfo{AuthenticationCodeInfo::Type::Sms, code_type->length_, ""};
168172
}
169173
case telegram_api::auth_sentCodeTypeEmailCode::ID:
@@ -196,6 +200,9 @@ td_api::object_ptr<td_api::AuthenticationCodeType> SendCodeHelper::get_authentic
196200
case AuthenticationCodeInfo::Type::FirebaseAndroid:
197201
return td_api::make_object<td_api::authenticationCodeTypeFirebaseAndroid>(authentication_code_info.pattern,
198202
authentication_code_info.length);
203+
case AuthenticationCodeInfo::Type::FirebaseIos:
204+
return td_api::make_object<td_api::authenticationCodeTypeFirebaseIos>(
205+
authentication_code_info.pattern, authentication_code_info.push_timeout, authentication_code_info.length);
199206
default:
200207
UNREACHABLE();
201208
return nullptr;

td/telegram/SendCodeHelper.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ class SendCodeHelper {
5757

5858
private:
5959
struct AuthenticationCodeInfo {
60-
enum class Type : int32 { None, Message, Sms, Call, FlashCall, MissedCall, Fragment, FirebaseAndroid };
60+
enum class Type : int32 { None, Message, Sms, Call, FlashCall, MissedCall, Fragment, FirebaseAndroid, FirebaseIos };
6161
Type type = Type::None;
6262
int32 length = 0;
63+
int32 push_timeout = 0;
6364
string pattern;
6465

6566
AuthenticationCodeInfo() = default;
66-
AuthenticationCodeInfo(Type type, int length, string pattern)
67-
: type(type), length(length), pattern(std::move(pattern)) {
67+
AuthenticationCodeInfo(Type type, int32 length, string pattern, int32 push_timeout = 0)
68+
: type(type), length(length), push_timeout(push_timeout), pattern(std::move(pattern)) {
6869
}
6970

7071
template <class StorerT>

td/telegram/SendCodeHelper.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ void SendCodeHelper::AuthenticationCodeInfo::store(StorerT &storer) const {
1818
using td::store;
1919
store(type, storer);
2020
store(length, storer);
21+
store(push_timeout, storer);
2122
store(pattern, storer);
2223
}
2324

@@ -26,6 +27,7 @@ void SendCodeHelper::AuthenticationCodeInfo::parse(ParserT &parser) {
2627
using td::parse;
2728
parse(type, parser);
2829
parse(length, parser);
30+
parse(push_timeout, parser);
2931
parse(pattern, parser);
3032
}
3133

0 commit comments

Comments
 (0)