Skip to content

Commit ace0465

Browse files
committed
Return post-login data from login/pin login auth handlers
1 parent 9f2388f commit ace0465

8 files changed

+19
-17
lines changed

src/ga_auth_handlers.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ namespace sdk {
341341
m_ca_addrs[subaccount].emplace_back(blinded_addr);
342342
}
343343
} else {
344-
m_session.login(m_mnemonic, m_password);
344+
m_result = m_session.login(m_mnemonic, m_password);
345345
}
346346

347347
// fall-through down to check for/upload confidential addresses requests
@@ -397,7 +397,8 @@ namespace sdk {
397397
}
398398

399399
// Log in and set up the session
400-
m_session.authenticate(args.at("signature"), "GA", m_master_xpub_bip32, std::string(), m_hw_device);
400+
m_result = m_session.authenticate(
401+
args.at("signature"), "GA", m_master_xpub_bip32, std::string(), m_hw_device);
401402

402403
// Ask the caller for the xpubs for each subaccount
403404
std::vector<nlohmann::json> paths;
@@ -451,7 +452,7 @@ namespace sdk {
451452

452453
auth_handler::state_type login_with_pin_call::call_impl()
453454
{
454-
m_session.login_with_pin(m_pin, m_pin_data);
455+
m_result = m_session.login_with_pin(m_pin, m_pin_data);
455456

456457
if (m_session.is_liquid()) {
457458
// when logged in with pin, the wallet software signer is available, thus the session is able to obtain

src/ga_rust.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ namespace sdk {
154154
}
155155

156156
std::string ga_rust::get_challenge(const std::string& address) { throw std::runtime_error("not implemented"); }
157-
void ga_rust::authenticate(const std::string& sig_der_hex, const std::string& path_hex,
157+
nlohmann::json ga_rust::authenticate(const std::string& sig_der_hex, const std::string& path_hex,
158158
const std::string& root_xpub_bip32, const std::string& device_id, const nlohmann::json& hw_device)
159159
{
160+
// FIXME: return post-login data
160161
throw std::runtime_error("not implemented");
161162
}
162163
void ga_rust::register_subaccount_xpubs(const std::vector<std::string>& bip32_xpubs)

src/ga_rust.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ namespace sdk {
7777
const std::string& gait_path_hex, bool supports_csv);
7878

7979
std::string get_challenge(const std::string& address);
80-
void authenticate(const std::string& sig_der_hex, const std::string& path_hex,
80+
nlohmann::json authenticate(const std::string& sig_der_hex, const std::string& path_hex,
8181
const std::string& root_xpub_bip32, const std::string& device_id, const nlohmann::json& hw_device);
8282
void register_subaccount_xpubs(const std::vector<std::string>& bip32_xpubs);
8383
nlohmann::json login(const std::string& mnemonic, const std::string& password);

src/ga_session.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,14 +1611,14 @@ namespace sdk {
16111611
wamp_call(locker, "login.set_appearance", appearance.get());
16121612
}
16131613

1614-
void ga_session::authenticate(const std::string& sig_der_hex, const std::string& path_hex,
1614+
nlohmann::json ga_session::authenticate(const std::string& sig_der_hex, const std::string& path_hex,
16151615
const std::string& root_xpub_bip32, const std::string& device_id, const nlohmann::json& hw_device)
16161616
{
16171617
locker_t locker(m_mutex);
1618-
authenticate(locker, sig_der_hex, path_hex, root_xpub_bip32, device_id, hw_device);
1618+
return authenticate(locker, sig_der_hex, path_hex, root_xpub_bip32, device_id, hw_device);
16191619
}
16201620

1621-
void ga_session::authenticate(ga_session::locker_t& locker, const std::string& sig_der_hex,
1621+
nlohmann::json ga_session::authenticate(ga_session::locker_t& locker, const std::string& sig_der_hex,
16221622
const std::string& path_hex, const std::string& root_xpub_bip32, const std::string& device_id,
16231623
const nlohmann::json& hw_device)
16241624
{
@@ -1747,6 +1747,7 @@ namespace sdk {
17471747
locker.unlock();
17481748
on_new_block(nlohmann::json(
17491749
{ { "block_height", block_height }, { "block_hash", block_hash }, { "diverged_count", 0 } }));
1750+
return get_post_login_data();
17501751
}
17511752

17521753
void ga_session::load_client_blob(ga_session::locker_t& locker, bool encache)
@@ -1870,9 +1871,8 @@ namespace sdk {
18701871
const auto hexder_path = sign_challenge(locker, challenge);
18711872
m_mnemonic = mnemonic;
18721873

1873-
authenticate(
1874+
return authenticate(
18741875
locker, hexder_path.first, hexder_path.second, std::string(), std::string(), nlohmann::json::object());
1875-
return get_post_login_data();
18761876
}
18771877

18781878
nlohmann::json ga_session::get_settings()

src/ga_session.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace sdk {
7272
const std::string& gait_path_hex, bool supports_csv);
7373

7474
std::string get_challenge(const std::string& address);
75-
void authenticate(const std::string& sig_der_hex, const std::string& path_hex,
75+
nlohmann::json authenticate(const std::string& sig_der_hex, const std::string& path_hex,
7676
const std::string& root_xpub_bip32, const std::string& device_id,
7777
const nlohmann::json& hw_device = nlohmann::json::object());
7878

@@ -244,7 +244,7 @@ namespace sdk {
244244
void register_user(locker_t& locker, const std::string& master_pub_key_hex,
245245
const std::string& master_chain_code_hex, const std::string& gait_path_hex, bool supports_csv);
246246

247-
void authenticate(locker_t& locker, const std::string& sig_der_hex, const std::string& path_hex,
247+
nlohmann::json authenticate(locker_t& locker, const std::string& sig_der_hex, const std::string& path_hex,
248248
const std::string& root_xpub_bip32, const std::string& device_id, const nlohmann::json& hw_device);
249249
nlohmann::json login(locker_t& locker, const std::string& mnemonic);
250250
void set_notification_handler(locker_t& locker, GA_notification_handler handler, void* context);

src/session.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,12 @@ namespace sdk {
332332
});
333333
}
334334

335-
void session::authenticate(const std::string& sig_der_hex, const std::string& path_hex,
335+
nlohmann::json session::authenticate(const std::string& sig_der_hex, const std::string& path_hex,
336336
const std::string& root_xpub_bip32, const std::string& device_id, const nlohmann::json& hw_device)
337337
{
338-
exception_wrapper([&] {
338+
return exception_wrapper([&] {
339339
auto p = get_nonnull_impl();
340-
p->authenticate(sig_der_hex, path_hex, root_xpub_bip32, device_id, hw_device);
340+
return p->authenticate(sig_der_hex, path_hex, root_xpub_bip32, device_id, hw_device);
341341
});
342342
}
343343

src/session.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace sdk {
5656
const std::string& gait_path_hex, bool supports_csv);
5757

5858
std::string get_challenge(const std::string& address);
59-
void authenticate(const std::string& sig_der_hex, const std::string& path_hex,
59+
nlohmann::json authenticate(const std::string& sig_der_hex, const std::string& path_hex,
6060
const std::string& root_xpub_bip32, const std::string& device_id, const nlohmann::json& hw_device);
6161
void register_subaccount_xpubs(const std::vector<std::string>& bip32_xpubs);
6262
nlohmann::json login(const std::string& mnemonic, const std::string& password);

src/session_common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace sdk {
5757
= 0;
5858

5959
virtual std::string get_challenge(const std::string& address) = 0;
60-
virtual void authenticate(const std::string& sig_der_hex, const std::string& path_hex,
60+
virtual nlohmann::json authenticate(const std::string& sig_der_hex, const std::string& path_hex,
6161
const std::string& root_xpub_bip32, const std::string& device_id, const nlohmann::json& hw_device)
6262
= 0;
6363
virtual void register_subaccount_xpubs(const std::vector<std::string>& bip32_xpubs) = 0;

0 commit comments

Comments
 (0)