Rename payload to nonce.
GitOrigin-RevId: ac49a3c22307cf904c440b9b6ddb34feee38da1a
This commit is contained in:
parent
ac1472c938
commit
d464ba71b8
@ -3253,8 +3253,8 @@ resendEmailAddressVerificationCode = EmailAddressAuthenticationCodeInfo;
|
|||||||
checkEmailAddressVerificationCode code:string = Ok;
|
checkEmailAddressVerificationCode code:string = Ok;
|
||||||
|
|
||||||
|
|
||||||
//@description Returns a Telegram Passport authorization form for sharing data with a service @bot_user_id User identified of the service's bot @scope Telegram Passport element types requested by the service @public_key Service's public_key @payload Authorization form payload provided by the service @password Password of the current user
|
//@description Returns a Telegram Passport authorization form for sharing data with a service @bot_user_id User identified of the service's bot @scope Telegram Passport element types requested by the service @public_key Service's public_key @nonce Authorization form nonce provided by the service @password Password of the current user
|
||||||
getPassportAuthorizationForm bot_user_id:int32 scope:string public_key:string payload:string password:string = PassportAuthorizationForm;
|
getPassportAuthorizationForm bot_user_id:int32 scope:string public_key:string nonce:string password:string = PassportAuthorizationForm;
|
||||||
|
|
||||||
//@description Sends a Telegram Passport authorization form, effectively sharing data with the service @autorization_form_id Authorization form identifier @types Types of Telegram Passport elements chosen by user to complete the authorization form
|
//@description Sends a Telegram Passport authorization form, effectively sharing data with the service @autorization_form_id Authorization form identifier @types Types of Telegram Passport elements chosen by user to complete the authorization form
|
||||||
sendPassportAuthorizationForm autorization_form_id:int32 types:vector<PassportElementType> = Ok;
|
sendPassportAuthorizationForm autorization_form_id:int32 types:vector<PassportElementType> = Ok;
|
||||||
|
Binary file not shown.
@ -1032,7 +1032,7 @@ void SecureManager::set_secure_value_errors(Td *td, tl_object_ptr<telegram_api::
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SecureManager::get_passport_authorization_form(string password, UserId bot_user_id, string scope,
|
void SecureManager::get_passport_authorization_form(string password, UserId bot_user_id, string scope,
|
||||||
string public_key, string payload,
|
string public_key, string nonce,
|
||||||
Promise<TdApiAuthorizationForm> promise) {
|
Promise<TdApiAuthorizationForm> promise) {
|
||||||
refcnt_++;
|
refcnt_++;
|
||||||
auto authorization_form_id = ++max_authorization_form_id_;
|
auto authorization_form_id = ++max_authorization_form_id_;
|
||||||
@ -1040,7 +1040,7 @@ void SecureManager::get_passport_authorization_form(string password, UserId bot_
|
|||||||
form.bot_user_id = bot_user_id;
|
form.bot_user_id = bot_user_id;
|
||||||
form.scope = scope;
|
form.scope = scope;
|
||||||
form.public_key = public_key;
|
form.public_key = public_key;
|
||||||
form.payload = payload;
|
form.nonce = nonce;
|
||||||
form.is_received = false;
|
form.is_received = false;
|
||||||
auto new_promise = PromiseCreator::lambda(
|
auto new_promise = PromiseCreator::lambda(
|
||||||
[actor_id = actor_id(this), authorization_form_id, promise = std::move(promise)](
|
[actor_id = actor_id(this), authorization_form_id, promise = std::move(promise)](
|
||||||
@ -1113,7 +1113,9 @@ void SecureManager::send_passport_authorization_form(int32 authorization_form_id
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto r_encrypted_credentials = get_encrypted_credentials(credentials, it->second.payload, it->second.public_key);
|
auto r_encrypted_credentials =
|
||||||
|
get_encrypted_credentials(credentials, it->second.nonce, it->second.public_key,
|
||||||
|
it->second.scope[0] == '{' && it->second.scope.back() == '}');
|
||||||
if (r_encrypted_credentials.is_error()) {
|
if (r_encrypted_credentials.is_error()) {
|
||||||
return promise.set_error(r_encrypted_credentials.move_as_error());
|
return promise.set_error(r_encrypted_credentials.move_as_error());
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ class SecureManager : public NetQueryCallback {
|
|||||||
void on_get_secure_value(SecureValueWithCredentials value);
|
void on_get_secure_value(SecureValueWithCredentials value);
|
||||||
|
|
||||||
void get_passport_authorization_form(string password, UserId bot_user_id, string scope, string public_key,
|
void get_passport_authorization_form(string password, UserId bot_user_id, string scope, string public_key,
|
||||||
string payload, Promise<TdApiAuthorizationForm> promise);
|
string nonce, Promise<TdApiAuthorizationForm> promise);
|
||||||
void send_passport_authorization_form(int32 authorization_form_id, std::vector<SecureValueType> types,
|
void send_passport_authorization_form(int32 authorization_form_id, std::vector<SecureValueType> types,
|
||||||
Promise<> promise);
|
Promise<> promise);
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ class SecureManager : public NetQueryCallback {
|
|||||||
UserId bot_user_id;
|
UserId bot_user_id;
|
||||||
string scope;
|
string scope;
|
||||||
string public_key;
|
string public_key;
|
||||||
string payload;
|
string nonce;
|
||||||
bool is_received;
|
bool is_received;
|
||||||
std::map<SecureValueType, SuitableSecureValue> options;
|
std::map<SecureValueType, SuitableSecureValue> options;
|
||||||
};
|
};
|
||||||
|
@ -1425,8 +1425,9 @@ static Slice secure_value_type_as_slice(SecureValueType type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto credentials_as_jsonable(const std::vector<SecureValueCredentials> &credentials, Slice payload) {
|
static auto credentials_as_jsonable(const std::vector<SecureValueCredentials> &credentials, Slice nonce,
|
||||||
return json_object([&credentials, payload](auto &o) {
|
bool rename_payload_to_nonce) {
|
||||||
|
return json_object([&credentials, nonce, rename_payload_to_nonce](auto &o) {
|
||||||
o("secure_data", json_object([&credentials](auto &o) {
|
o("secure_data", json_object([&credentials](auto &o) {
|
||||||
for (auto &cred : credentials) {
|
for (auto &cred : credentials) {
|
||||||
if (cred.type == SecureValueType::PhoneNumber || cred.type == SecureValueType::EmailAddress) {
|
if (cred.type == SecureValueType::PhoneNumber || cred.type == SecureValueType::EmailAddress) {
|
||||||
@ -1455,13 +1456,15 @@ static auto credentials_as_jsonable(const std::vector<SecureValueCredentials> &c
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
o("payload", payload);
|
o(rename_payload_to_nonce ? "nonce" : "payload", nonce);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<EncryptedSecureCredentials> get_encrypted_credentials(const std::vector<SecureValueCredentials> &credentials,
|
Result<EncryptedSecureCredentials> get_encrypted_credentials(const std::vector<SecureValueCredentials> &credentials,
|
||||||
Slice payload, Slice public_key) {
|
Slice nonce, Slice public_key,
|
||||||
auto encoded_credentials = json_encode<std::string>(credentials_as_jsonable(credentials, payload));
|
bool rename_payload_to_nonce) {
|
||||||
|
auto encoded_credentials =
|
||||||
|
json_encode<std::string>(credentials_as_jsonable(credentials, nonce, rename_payload_to_nonce));
|
||||||
LOG(INFO) << "Created credentials " << encoded_credentials;
|
LOG(INFO) << "Created credentials " << encoded_credentials;
|
||||||
|
|
||||||
auto secret = secure_storage::Secret::create_new();
|
auto secret = secure_storage::Secret::create_new();
|
||||||
|
@ -195,7 +195,8 @@ struct SecureValueCredentials {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Result<EncryptedSecureCredentials> get_encrypted_credentials(const std::vector<SecureValueCredentials> &credentials,
|
Result<EncryptedSecureCredentials> get_encrypted_credentials(const std::vector<SecureValueCredentials> &credentials,
|
||||||
Slice payload, Slice public_key);
|
Slice nonce, Slice public_key,
|
||||||
|
bool rename_payload_to_nonce);
|
||||||
|
|
||||||
class SecureValue {
|
class SecureValue {
|
||||||
public:
|
public:
|
||||||
|
@ -6460,17 +6460,17 @@ void Td::on_request(uint64 id, td_api::getPassportAuthorizationForm &request) {
|
|||||||
CLEAN_INPUT_STRING(request.password_);
|
CLEAN_INPUT_STRING(request.password_);
|
||||||
CLEAN_INPUT_STRING(request.public_key_);
|
CLEAN_INPUT_STRING(request.public_key_);
|
||||||
CLEAN_INPUT_STRING(request.scope_);
|
CLEAN_INPUT_STRING(request.scope_);
|
||||||
CLEAN_INPUT_STRING(request.payload_);
|
CLEAN_INPUT_STRING(request.nonce_);
|
||||||
UserId bot_user_id(request.bot_user_id_);
|
UserId bot_user_id(request.bot_user_id_);
|
||||||
if (!bot_user_id.is_valid()) {
|
if (!bot_user_id.is_valid()) {
|
||||||
return send_error_raw(id, 400, "Bot user identifier invalid");
|
return send_error_raw(id, 400, "Bot user identifier invalid");
|
||||||
}
|
}
|
||||||
if (request.payload_.empty()) {
|
if (request.nonce_.empty()) {
|
||||||
return send_error_raw(id, 400, "Payload must be non-empty");
|
return send_error_raw(id, 400, "Nonce must be non-empty");
|
||||||
}
|
}
|
||||||
CREATE_REQUEST_PROMISE();
|
CREATE_REQUEST_PROMISE();
|
||||||
send_closure(secure_manager_, &SecureManager::get_passport_authorization_form, std::move(request.password_),
|
send_closure(secure_manager_, &SecureManager::get_passport_authorization_form, std::move(request.password_),
|
||||||
bot_user_id, std::move(request.scope_), std::move(request.public_key_), std::move(request.payload_),
|
bot_user_id, std::move(request.scope_), std::move(request.public_key_), std::move(request.nonce_),
|
||||||
std::move(promise));
|
std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user