Fix passport credentials.

GitOrigin-RevId: d33a340286f13b2f8dede37c227f102794ebad8b
This commit is contained in:
levlam 2018-04-28 01:54:45 +03:00
parent 7d9003980f
commit 118cdd1530
4 changed files with 33 additions and 5 deletions

View File

@ -627,6 +627,7 @@ class GetPassportAuthorizationForm : public NetQueryCallback {
return on_error(r_result.move_as_error()); return on_error(r_result.move_as_error());
} }
authorization_form_ = r_result.move_as_ok(); authorization_form_ = r_result.move_as_ok();
LOG(INFO) << "Receive " << to_string(authorization_form_);
loop(); loop();
} }

View File

@ -1329,8 +1329,9 @@ static Slice secure_value_type_as_slice(SecureValueType type) {
} }
} }
static auto credentials_as_jsonable(std::vector<SecureValueCredentials> &credentials, Slice payload, bool with_selfie) { static auto credentials_as_jsonable(const std::vector<SecureValueCredentials> &credentials, Slice payload,
return json_object([&credentials, &payload, with_selfie](auto &o) { bool with_selfie) {
return json_object([&credentials, payload, with_selfie](auto &o) {
o("secure_data", json_object([&credentials, with_selfie](auto &o) { o("secure_data", json_object([&credentials, with_selfie](auto &o) {
for (auto &c : credentials) { for (auto &c : credentials) {
if (c.type == SecureValueType::PhoneNumber || c.type == SecureValueType::EmailAddress) { if (c.type == SecureValueType::PhoneNumber || c.type == SecureValueType::EmailAddress) {
@ -1360,7 +1361,7 @@ static auto credentials_as_jsonable(std::vector<SecureValueCredentials> &credent
}); });
} }
Result<EncryptedSecureCredentials> get_encrypted_credentials(std::vector<SecureValueCredentials> &credentials, Result<EncryptedSecureCredentials> get_encrypted_credentials(const std::vector<SecureValueCredentials> &credentials,
Slice payload, bool with_selfie, Slice public_key) { Slice payload, bool with_selfie, Slice public_key) {
auto encoded_credentials = json_encode<std::string>(credentials_as_jsonable(credentials, payload, with_selfie)); auto encoded_credentials = json_encode<std::string>(credentials_as_jsonable(credentials, payload, with_selfie));

View File

@ -169,7 +169,7 @@ struct SecureValueCredentials {
optional<SecureFileCredentials> selfie; optional<SecureFileCredentials> selfie;
}; };
Result<EncryptedSecureCredentials> get_encrypted_credentials(std::vector<SecureValueCredentials> &credentials, Result<EncryptedSecureCredentials> get_encrypted_credentials(const std::vector<SecureValueCredentials> &credentials,
Slice payload, bool with_selfie, Slice public_key); Slice payload, bool with_selfie, Slice public_key);
class SecureValue { class SecureValue {

View File

@ -1139,7 +1139,7 @@ class CliClient final : public Actor {
recovery_email_address = ""; recovery_email_address = "";
} }
send_request(make_tl_object<td_api::setPassword>(password, new_password, new_hint, true, recovery_email_address)); send_request(make_tl_object<td_api::setPassword>(password, new_password, new_hint, true, recovery_email_address));
} else if (op == "gpaf" || op == "secureid") { } else if (op == "gpafhttp") {
string password; string password;
std::tie(password, args) = split(args); std::tie(password, args) = split(args);
ChainBufferWriter writer; ChainBufferWriter writer;
@ -1160,6 +1160,32 @@ class CliClient final : public Actor {
LOG(INFO) << "Callback URL:" << query.get_arg("callback_url"); LOG(INFO) << "Callback URL:" << query.get_arg("callback_url");
send_request(make_tl_object<td_api::getPassportAuthorizationForm>(to_integer<int32>(bot_id), scope, public_key, send_request(make_tl_object<td_api::getPassportAuthorizationForm>(to_integer<int32>(bot_id), scope, public_key,
payload, password)); payload, password));
} else if (op == "gpaf") {
string password;
string bot_id;
string scope;
string public_key =
"-----BEGIN PUBLIC KEY-----\n"
"MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAzmgKr0fPP4rB/TsNEweC\n"
"hoG3ntUxuBTmHsFBW6CpABGdaTmKZSjAI/cTofhBgtRQIOdX0YRGHHHhwyLf49Wv\n"
"9l+XexbJOa0lTsJSNMj8Y/9sZbqUl5ur8ZOTM0sxbXC0XKexu1tM9YavH+Lbrobk\n"
"jt0+cmo/zEYZWNtLVihnR2IDv+7tSgiDoFWi/koAUdfJ1VMw+hReUaLg3vE9CmPK\n"
"tQiTy+NvmrYaBPb75I0Jz3Lrz1+mZSjLKO25iT84RIsxarBDd8iYh2avWkCmvtiR\n"
"Lcif8wLxi2QWC1rZoCA3Ip+Hg9J9vxHlzl6xT01WjUStMhfwrUW6QBpur7FJ+aKM\n"
"oaMoHieFNCG4qIkWVEHHSsUpLum4SYuEnyNH3tkjbrdldZanCvanGq+TZyX0buRt\n"
"4zk7FGcu8iulUkAP/o/WZM0HKinFN/vuzNVA8iqcO/BBhewhzpqmmTMnWmAO8WPP\n"
"DJMABRtXJnVuPh1CI5pValzomLJM4/YvnJGppzI1QiHHNA9JtxVmj2xf8jaXa1LJ\n"
"WUNJK+RvUWkRUxpWiKQQO9FAyTPLRtDQGN9eUeDR1U0jqRk/gNT8smHGN6I4H+NR\n"
"3X3/1lMfcm1dvk654ql8mxjCA54IpTPr/icUMc7cSzyIiQ7Tp9PZTl1gHh281ZWf\n"
"P7d2+fuJMlkjtM7oAwf+tI8CAwEAAQ==\n"
"-----END PUBLIC KEY-----";
string payload;
std::tie(password, args) = split(args);
std::tie(bot_id, args) = split(args);
std::tie(scope, payload) = split(args);
send_request(make_tl_object<td_api::getPassportAuthorizationForm>(to_integer<int32>(bot_id), scope, public_key,
payload, password));
} else if (op == "spaf") { } else if (op == "spaf") {
string password; string password;
string id; string id;