diff --git a/td/telegram/SecureManager.cpp b/td/telegram/SecureManager.cpp index 0fe63224..63c82fc9 100644 --- a/td/telegram/SecureManager.cpp +++ b/td/telegram/SecureManager.cpp @@ -627,6 +627,7 @@ class GetPassportAuthorizationForm : public NetQueryCallback { return on_error(r_result.move_as_error()); } authorization_form_ = r_result.move_as_ok(); + LOG(INFO) << "Receive " << to_string(authorization_form_); loop(); } diff --git a/td/telegram/SecureValue.cpp b/td/telegram/SecureValue.cpp index 04b7b517..ee0d2bd5 100644 --- a/td/telegram/SecureValue.cpp +++ b/td/telegram/SecureValue.cpp @@ -1329,8 +1329,9 @@ static Slice secure_value_type_as_slice(SecureValueType type) { } } -static auto credentials_as_jsonable(std::vector &credentials, Slice payload, bool with_selfie) { - return json_object([&credentials, &payload, with_selfie](auto &o) { +static auto credentials_as_jsonable(const std::vector &credentials, Slice payload, + bool with_selfie) { + return json_object([&credentials, payload, with_selfie](auto &o) { o("secure_data", json_object([&credentials, with_selfie](auto &o) { for (auto &c : credentials) { if (c.type == SecureValueType::PhoneNumber || c.type == SecureValueType::EmailAddress) { @@ -1360,7 +1361,7 @@ static auto credentials_as_jsonable(std::vector &credent }); } -Result get_encrypted_credentials(std::vector &credentials, +Result get_encrypted_credentials(const std::vector &credentials, Slice payload, bool with_selfie, Slice public_key) { auto encoded_credentials = json_encode(credentials_as_jsonable(credentials, payload, with_selfie)); diff --git a/td/telegram/SecureValue.h b/td/telegram/SecureValue.h index 6a13779c..865018d1 100644 --- a/td/telegram/SecureValue.h +++ b/td/telegram/SecureValue.h @@ -169,7 +169,7 @@ struct SecureValueCredentials { optional selfie; }; -Result get_encrypted_credentials(std::vector &credentials, +Result get_encrypted_credentials(const std::vector &credentials, Slice payload, bool with_selfie, Slice public_key); class SecureValue { diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index aff7be98..0ae74260 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -1139,7 +1139,7 @@ class CliClient final : public Actor { recovery_email_address = ""; } send_request(make_tl_object(password, new_password, new_hint, true, recovery_email_address)); - } else if (op == "gpaf" || op == "secureid") { + } else if (op == "gpafhttp") { string password; std::tie(password, args) = split(args); ChainBufferWriter writer; @@ -1160,6 +1160,32 @@ class CliClient final : public Actor { LOG(INFO) << "Callback URL:" << query.get_arg("callback_url"); send_request(make_tl_object(to_integer(bot_id), scope, public_key, 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(to_integer(bot_id), scope, public_key, + payload, password)); } else if (op == "spaf") { string password; string id;