43 const std::filesystem::path& path,
45 std::string archivePath,
46 const std::string& nameServer)
49 , archivePath_(
std::
move(archivePath))
60 std::string deviceName,
61 std::unique_ptr<AccountCredentials> credentials,
71 virtual std::vector<uint8_t>
getPasswordKey(
const std::string& )
override;
76 std::string_view auth_scheme,
82 std::string_view scheme,
83 const std::string& password,
86 std::string_view scheme,
87 const std::string& password);
91 const std::string& scheme);
95 std::string_view scheme,
96 const std::string& password,
104 const std::string& password,
105 dht::crypto::Identity& device,
106 const dht::InfoHash&
id,
110 void onAuthReady(
const std::string& deviceId, std::shared_ptr<dhtnet::ChannelSocket> channel);
120 std::string accountId;
124 std::string deviceName;
125 std::unique_ptr<ArchiveAccountCredentials> credentials;
126 std::unique_ptr<DhtLoadContext> dhtContext;
127 std::shared_ptr<LinkDeviceContext> linkDevCtx;
128 std::unique_ptr<AddDeviceContext> addDeviceCtx;
131 std::unique_ptr<asio::steady_timer> timeout;
132 bool canceled {
false};
134 struct DecodingContext;
136 struct DeviceAuthInfo;
137 std::shared_ptr<AuthContext> authCtx_;
139 void createAccount(AuthContext& ctx);
140 void migrateAccount(AuthContext& ctx);
142 std::pair<std::string, std::shared_ptr<dht::Value>> makeReceipt(
143 const dht::crypto::Identity&
id,
144 const dht::crypto::Certificate& device,
145 const std::string& ethAccount);
146 void updateArchive(AccountArchive&
content )
const;
147 void saveArchive(AccountArchive&
content, std::string_view scheme,
const std::string&
pwd);
148 AccountArchive readArchive(std::string_view scheme,
const std::string& password)
const;
149 static std::pair<std::vector<uint8_t>, dht::InfoHash> computeKeys(
const std::string& password,
150 const std::string&
pin,
152 bool updateCertificates(AccountArchive&
archive, dht::crypto::Identity& device);
153 static bool needsMigration(
const std::string& accountId,
const dht::crypto::Identity&
id);
155 void loadFromFile(AuthContext& ctx);
158 void startLoadArchiveFromDevice(
const std::shared_ptr<AuthContext>& ctx);
160 bool doAddDevice(std::string_view scheme,
161 const std::shared_ptr<AuthContext>& ctx,
162 const std::shared_ptr<dhtnet::ChannelSocket>& channel);
164 void loadFromDHT(
const std::shared_ptr<AuthContext>& ctx);
167 inline std::weak_ptr<ArchiveAccountManager> weak()
173 std::string archivePath_;
void initAuthentication(PrivateKey request, std::string deviceName, std::unique_ptr< AccountCredentials > credentials, AuthSuccessCallback onSuccess, AuthFailureCallback onFailure, const OnChangeCallback &onChange) override
bool setValidity(std::string_view scheme, const std::string &password, dht::crypto::Identity &device, const dht::InfoHash &id, int64_t validity)
Change the validity of a certificate.