// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #pragma once #include "td/telegram/net/NetQuery.h" #include "td/telegram/SecureValue.h" #include "td/telegram/UserId.h" #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" #include "td/actor/actor.h" #include "td/actor/PromiseFuture.h" #include "td/utils/Container.h" #include "td/utils/Status.h" #include #include namespace td { class Td; using TdApiSecureValue = td_api::object_ptr; using TdApiAllSecureValues = td_api::object_ptr; using TdApiAuthorizationForm = td_api::object_ptr; class SecureManager : public NetQueryCallback { public: explicit SecureManager(ActorShared<> parent); void get_secure_value(std::string password, SecureValueType type, Promise promise); void get_all_secure_values(std::string password, Promise promise); void set_secure_value(string password, SecureValue secure_value, Promise promise); void delete_secure_value(SecureValueType type, Promise promise); void set_secure_value_errors(Td *td, tl_object_ptr input_user, vector> errors, Promise promise); void get_passport_authorization_form(string password, UserId bot_user_id, string scope, string public_key, string payload, Promise promise); void send_passport_authorization_form(string password, int32 authorization_form_id, std::vector types, Promise<> promise); private: ActorShared<> parent_; int32 refcnt_{1}; std::map> set_secure_value_queries_; struct AuthorizationForm { UserId bot_user_id; string scope; string public_key; string payload; bool is_selfie_required; bool is_received; }; std::map authorization_forms_; int32 authorization_form_id_{0}; void hangup() override; void hangup_shared() override; void dec_refcnt(); void do_get_secure_value(std::string password, SecureValueType type, Promise promise); void on_delete_secure_value(SecureValueType type, Promise promise, Result result); void on_get_passport_authorization_form(int32 authorization_form_id, Promise promise, Result r_authorization_form); void do_send_passport_authorization_form(int32 authorization_form_id, vector credentials, Promise<> promise); void on_result(NetQueryPtr query) override; Container> container_; void send_with_promise(NetQueryPtr query, Promise promise); }; } // namespace td