Add cloud_project_number to updateApplicationVerificationRequired.

This commit is contained in:
levlam 2024-06-29 17:14:02 +03:00
parent 9c4a509b99
commit db61f74b62
2 changed files with 24 additions and 6 deletions

View File

@ -177,7 +177,7 @@ authorizationStateClosed = AuthorizationState;
//@description Device verification must be performed with the SafetyNet Attestation API @nonce Nonce to pass to the SafetyNet Attestation API
firebaseDeviceVerificationParametersSafetyNet nonce:bytes = FirebaseDeviceVerificationParameters;
//@description Device verification must be performed with the Play Integrity API
//@description Device verification must be performed with the classic Play Integrity verification (https://developer.android.com/google/play/integrity/classic)
//@nonce Base64url-encoded nonce to pass to the Play Integrity API
//@cloud_project_number Cloud project number to pass to the Play Integrity API
firebaseDeviceVerificationParametersPlayIntegrity nonce:string cloud_project_number:int64 = FirebaseDeviceVerificationParameters;
@ -7362,9 +7362,10 @@ updateFileRemovedFromDownloads file_id:int32 counts:downloadedFileCounts = Updat
//@description A request can't be completed unless application verification is performed; for official mobile applications only.
//-The method setApplicationVerificationToken must be called once the verification is completed or failed
//@verification_id Unique identifier for the verification process
//@nonce Unique nonce for the classic Play Integrity verification (https://developer.android.com/google/play/integrity/classic) for Android,
//@nonce Unique base64url-encoded nonce for the classic Play Integrity verification (https://developer.android.com/google/play/integrity/classic) for Android,
//-or a unique string to compare with verify_nonce field from a push notification for iOS
updateApplicationVerificationRequired verification_id:int53 nonce:string = Update;
//@cloud_project_number Cloud project number to pass to the Play Integrity API on Android
updateApplicationVerificationRequired verification_id:int53 nonce:string cloud_project_number:int64 = Update;
//@description New call was created or information about a call was updated @call New data about a call
updateCall call:call = Update;

View File

@ -12,6 +12,7 @@
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/base64.h"
#include "td/utils/common.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
@ -24,7 +25,22 @@ void NetQueryVerifier::verify(NetQueryPtr query, string nonce) {
CHECK(query->is_ready());
CHECK(query->is_error());
if (!check_utf8(nonce)) {
int64 cloud_project_number = 0;
auto status = [&] {
if (!check_utf8(nonce)) {
return Status::Error(400, "Invalid encoding");
}
#if TD_ANDROID
string cloud_project_number_str;
std::tie(cloud_project_number_str, nonce) = split(nonce, '_');
TRY_RESULT_ASSIGN(cloud_project_number, to_integer_safe<int64>(cloud_project_number_str));
TRY_RESULT_ASSIGN(nonce, hex_decode(nonce));
nonce = base64url_encode(nonce);
#endif
return Status::OK();
}();
if (status.is_error()) {
LOG(ERROR) << "Receive " << status;
query->set_error(Status::Error(400, "Invalid verification nonce"));
G()->net_query_dispatcher().dispatch(std::move(query));
return;
@ -33,8 +49,9 @@ void NetQueryVerifier::verify(NetQueryPtr query, string nonce) {
auto query_id = next_query_id_++;
queries_.emplace(query_id, std::make_pair(std::move(query), nonce));
send_closure(G()->td(), &Td::send_update,
td_api::make_object<td_api::updateApplicationVerificationRequired>(query_id, nonce));
send_closure(
G()->td(), &Td::send_update,
td_api::make_object<td_api::updateApplicationVerificationRequired>(query_id, nonce, cloud_project_number));
}
void NetQueryVerifier::set_verification_token(int64 query_id, string &&token, Promise<Unit> &&promise) {