44 const std::filesystem::path& path,
47 std::string archivePath,
48 const std::string& nameServer)
52 , archivePath_(
std::
move(archivePath))
63 std::string deviceName,
64 std::unique_ptr<AccountCredentials> credentials,
70 virtual std::vector<uint8_t>
getPasswordKey(
const std::string& )
override;
79 std::string_view scheme,
80 const std::string& password,
88 std::string_view scheme,
89 const std::string& password,
96 const std::string& password,
97 dht::crypto::Identity& device,
98 const dht::InfoHash&
id,
102 void onAuthReady(
const std::string& deviceId, std::shared_ptr<dhtnet::ChannelSocket> channel);
111 std::string accountId;
115 std::string deviceName;
116 std::unique_ptr<ArchiveAccountCredentials> credentials;
117 std::shared_ptr<LinkDeviceContext> linkDevCtx;
118 std::unique_ptr<AddDeviceContext> addDeviceCtx;
121 std::unique_ptr<asio::steady_timer> timeout;
122 bool canceled {
false};
125 struct DeviceAuthInfo;
126 std::shared_ptr<AuthContext> authCtx_;
128 void createAccount(AuthContext& ctx);
129 void migrateAccount(AuthContext& ctx);
131 std::pair<std::string, std::shared_ptr<dht::Value>> makeReceipt(
const dht::crypto::Identity&
id,
132 const dht::crypto::Certificate& device,
133 const std::string& ethAccount);
134 void updateArchive(AccountArchive&
content )
const;
135 void saveArchive(AccountArchive&
content, std::string_view scheme,
const std::string&
pwd);
136 AccountArchive readArchive(std::string_view scheme,
const std::string& password)
const;
137 static std::pair<std::vector<uint8_t>, dht::InfoHash> computeKeys(
const std::string& password,
138 const std::string&
pin,
140 bool updateCertificates(AccountArchive&
archive, dht::crypto::Identity& device);
141 static bool needsMigration(
const std::string& accountId,
const dht::crypto::Identity&
id);
143 void loadFromFile(AuthContext& ctx);
146 void startLoadArchiveFromDevice(
const std::shared_ptr<AuthContext>& ctx);
148 bool doAddDevice(std::string_view scheme,
149 const std::shared_ptr<AuthContext>& ctx,
150 std::shared_ptr<dhtnet::ChannelSocket> channel);
154 inline std::weak_ptr<ArchiveAccountManager> weak()
161 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.
ArchiveAccountManager(const std::string &accountId, const std::filesystem::path &path, OnExportConfig &&onExportConfig, OnSyncData &&onSyncData, std::string archivePath, const std::string &nameServer)