anastasis

Credential backup and recovery protocol and service
Log | Files | Refs | Submodules | README | LICENSE

commit b9a9d2f6101b5211987861f56cd6e35331f96faa
parent cf4b6ebd6de3370da4b16d2f1ef19a2a3d3d0b12
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat,  5 Mar 2022 21:46:47 +0100

introduce 'display_hint' in state machine, make feedback states more expressive

Diffstat:
Msrc/reducer/anastasis_api_recovery_redux.c | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 60 insertions(+), 10 deletions(-)

diff --git a/src/reducer/anastasis_api_recovery_redux.c b/src/reducer/anastasis_api_recovery_redux.c @@ -539,8 +539,10 @@ start_feedback_cb ( instructions = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("state", - "hint"), - GNUNET_JSON_pack_string ("hint", + "code-in-file"), + GNUNET_JSON_pack_string ("filename", + csr->details.tan_filename), + GNUNET_JSON_pack_string ("display_hint", csr->details.tan_filename), GNUNET_JSON_pack_uint64 ("http_status", (json_int_t) csr->http_status)); @@ -562,8 +564,10 @@ start_feedback_cb ( instructions = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("state", - "hint"), - GNUNET_JSON_pack_string ("hint", + "send-to-address"), + GNUNET_JSON_pack_string ("address_hint", + csr->details.tan_address_hint), + GNUNET_JSON_pack_string ("display_hint", csr->details.tan_address_hint), GNUNET_JSON_pack_uint64 ("http_status", (json_int_t) csr->http_status)); @@ -585,12 +589,14 @@ start_feedback_cb ( pay = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("state", - "payment"), + "taler-payment"), GNUNET_JSON_pack_string ( "taler_pay_uri", csr->details.payment_required.taler_pay_uri), GNUNET_JSON_pack_string ("provider", cd->provider_url), + GNUNET_JSON_pack_string ("display_hint", + csr->details.payment_required.taler_pay_uri), GNUNET_JSON_pack_data_auto ( "payment_secret", &csr->details.payment_required.payment_secret)); @@ -626,6 +632,9 @@ start_feedback_cb ( err = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("state", "server-failure"), + GNUNET_JSON_pack_string ( + "display_hint", + _ ("The Anastasis provider experienced a failure")), GNUNET_JSON_pack_uint64 ("http_status", csr->http_status), GNUNET_JSON_pack_uint64 ("error_code", @@ -651,6 +660,9 @@ start_feedback_cb ( "truth-unknown"), GNUNET_JSON_pack_uint64 ("http_status", csr->http_status), + GNUNET_JSON_pack_string ( + "display_hint", + _ ("The provider does not have the requested information")), GNUNET_JSON_pack_uint64 ("error_code", TALER_EC_ANASTASIS_TRUTH_UNKNOWN)); GNUNET_assert (0 == @@ -669,6 +681,7 @@ start_feedback_cb ( { json_t *reply; json_t *c; + char *hint; c = find_challenge_in_cs (sctx->state, &cd->uuid); @@ -693,6 +706,13 @@ start_feedback_cb ( "answer-pin", json_integer ( csr->details.bank_transfer_required.answer_code))); + GNUNET_asprintf (&hint, + _ ("Wire %s to %s (%s) with subject %s\n"), + TALER_amount2s ( + &csr->details.bank_transfer_required.amount), + csr->details.bank_transfer_required.target_iban, + csr->details.bank_transfer_required.target_business_name, + csr->details.bank_transfer_required.wire_transfer_subject); reply = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("state", "iban-instructions"), @@ -700,6 +720,9 @@ start_feedback_cb ( "target_iban", csr->details.bank_transfer_required.target_iban), GNUNET_JSON_pack_string ( + "display_hint", + hint), + GNUNET_JSON_pack_string ( "target_business_name", csr->details.bank_transfer_required.target_business_name), GNUNET_JSON_pack_string ( @@ -708,6 +731,7 @@ start_feedback_cb ( TALER_JSON_pack_amount ( "challenge_amount", &csr->details.bank_transfer_required.amount)); + GNUNET_free (hint); GNUNET_assert (0 == json_object_set_new (feedback, uuid, @@ -816,6 +840,8 @@ answer_feedback_cb ( instructions = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("status", "incorrect-answer"), + GNUNET_JSON_pack_string ("display_hint", + _ ("The provided answer was incorrect")), GNUNET_JSON_pack_uint64 ("error_code", csr->ec), GNUNET_JSON_pack_uint64 ("http_status", @@ -838,10 +864,13 @@ answer_feedback_cb ( pay = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("state", - "payment-required"), - GNUNET_JSON_pack_string ("taler_pay_uri", - csr->details.payment_required. - taler_pay_uri), + "taler-payment"), + GNUNET_JSON_pack_string ( + "taler_pay_uri", + csr->details.payment_required.taler_pay_uri), + GNUNET_JSON_pack_string ( + "display_hint", + csr->details.payment_required.taler_pay_uri), GNUNET_JSON_pack_string ("provider", cd->provider_url), GNUNET_JSON_pack_data_auto ( @@ -879,6 +908,9 @@ answer_feedback_cb ( err = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("state", "server-failure"), + GNUNET_JSON_pack_string ( + "display_hint", + _ ("The Anastasis provider experienced a failure")), GNUNET_JSON_pack_uint64 ("http_status", csr->http_status), GNUNET_JSON_pack_uint64 ("error_code", @@ -902,6 +934,10 @@ answer_feedback_cb ( err = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("state", "truth-unknown"), + GNUNET_JSON_pack_uint64 ("http_status", + csr->http_status), + GNUNET_JSON_pack_string ("display_hint", + TALER_ErrorCode_get_hint (csr->ec)), GNUNET_JSON_pack_uint64 ("error_code", TALER_EC_ANASTASIS_TRUTH_UNKNOWN)); GNUNET_assert (0 == @@ -919,11 +955,22 @@ answer_feedback_cb ( case ANASTASIS_CHALLENGE_ANSWER_STATUS_RATE_LIMIT_EXCEEDED: { json_t *err; - + char *hint; + + GNUNET_asprintf ( + &hint, + _ ("exceeded limit of %llu attempts in %s"), + (unsigned long long) csr->details.rate_limit_exceeded.request_limit, + GNUNET_TIME_relative2s ( + csr->details.rate_limit_exceeded.request_frequency, + true)); err = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ( "state", "rate-limit-exceeded"), + GNUNET_JSON_pack_string ( + "display_hint", + hint), GNUNET_JSON_pack_uint64 ( "request_limit", csr->details.rate_limit_exceeded.request_limit), @@ -933,6 +980,7 @@ answer_feedback_cb ( GNUNET_JSON_pack_uint64 ( "error_code", TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED)); + GNUNET_free (hint); GNUNET_assert (0 == json_object_set_new (feedback, uuid, @@ -953,6 +1001,8 @@ answer_feedback_cb ( err = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ("state", "authentication-timeout"), + GNUNET_JSON_pack_string ("display_hint", + _ ("Challenge not yet satisfied")), GNUNET_JSON_pack_uint64 ("error_code", TALER_EC_ANASTASIS_TRUTH_AUTH_TIMEOUT)); GNUNET_assert (0 ==