[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: work on recovery reducer (WiP)
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: work on recovery reducer (WiP) |
Date: |
Sun, 21 Feb 2021 13:09:58 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new 0a5af71 work on recovery reducer (WiP)
0a5af71 is described below
commit 0a5af71e9489bb1c113596b15dfaf2c1c386a9d6
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Feb 21 13:09:55 2021 +0100
work on recovery reducer (WiP)
---
src/include/anastasis.h | 2 +-
src/reducer/anastasis_api_recovery_redux.c | 795 +++++++++++++----------------
2 files changed, 350 insertions(+), 447 deletions(-)
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 2ec97b5..6e71220 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -226,7 +226,7 @@ struct ANASTASIS_ChallengeStartResponse
* Defines a callback for the response status for a challenge start
* operation.
*
- * @param cls handle to the request
+ * @param cls closure
* @param csr response details
*/
typedef void
diff --git a/src/reducer/anastasis_api_recovery_redux.c
b/src/reducer/anastasis_api_recovery_redux.c
index 33aa46f..2757f57 100644
--- a/src/reducer/anastasis_api_recovery_redux.c
+++ b/src/reducer/anastasis_api_recovery_redux.c
@@ -1,6 +1,6 @@
/*
This file is part of Anastasis
- Copyright (C) 2020 Taler Systems SA
+ Copyright (C) 2020, 2021 Taler Systems SA
Anastasis is free software; you can redistribute it and/or modify it under
the
terms of the GNU Lesser General Public License as published by the Free
Software
@@ -94,244 +94,6 @@ ANASTASIS_recovery_start (const struct
GNUNET_CONFIGURATION_Handle *cfg)
}
-//////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////
-
-/**
- * State for a "challenge answer" CMD.
- */
-struct ChallengeState
-{
- /**
- * Reference to the challenge we are solving
- */
- struct ANASTASIS_Challenge *c;
-
- /**
- * Expected status code.
- */
- unsigned int http_status;
-
- /**
- * Answer to the challenge we are solving
- */
- const char *answer;
-
- /**
- * Index of the challenge we are solving
- */
- unsigned int challenge_index;
-
- /**
- * 0 for no plugin needed 1 for plugin needed to authenticate
- */
- unsigned int mode;
-
- /**
- * Handle for an challenge answer operation
- */
- struct ANASTASIS_ChallengeAnswerOperation *cao;
-
- /**
- * Function to call after challenge answer.
- */
- ANASTASIS_ActionCallback cb;
-
- /**
- * Closure for action callback #cb.
- */
- void *cb_cls;
-
- /**
- * Current state
- */
- json_t *state;
-
- /**
- * Payment order ID we got back, if any. Otherwise NULL.
- */
- char *payment_order_id;
-
- /**
- * Payment order ID we are to provide in the request, may be NULL.
- */
- struct ANASTASIS_PaymentSecretP payment_order_req;
-
- /**
- * True if @e payment_order_req is initialized.
- */
- bool payment_order_set;
-
- /**
- * code we read in the file generated by the plugin
- */
- char *code;
-};
-
-
-#if GRAVEYARD
-
-// static
-void
-challenge_payment_cb (void *cls,
- const char *taler_pay_url,
- const char *server_url,
- unsigned int http_status)
-{
- const char *m;
- json_t *recovery_information;
- json_t *challenges;
- json_t *challenge;
- struct ChallengeState *cs = cls;
-
- if (http_status != MHD_HTTP_PAYMENT_REQUIRED)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u/%d to in %s:%u\n",
- cs->http_status,
- http_status,
- __FILE__,
- __LINE__);
- ANASTASIS_redux_fail_ (cs->cb,
- cs->cb_cls,
- TALER_EC_ANASTASIS_REDUCER_BACKEND_FAILURE,
- "Unexpected response code!");
- return;
- }
-
- if (0 != strncmp (taler_pay_url,
- "taler://pay/http",
- strlen ("taler://pay/http")))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Did not find `%s' in `%s'\n",
- "/-/-/",
- taler_pay_url);
- ANASTASIS_redux_fail_ (cs->cb,
- cs->cb_cls,
- TALER_EC_INVALID, // FIXME: Error code
- "Invalid pay uri!");
- return;
- }
- m = strstr (taler_pay_url, "/-/-/");
- if (NULL == m)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Did not find `%s' in `%s'\n",
- "/-/-/",
- taler_pay_url);
- ANASTASIS_redux_fail_ (cs->cb,
- cs->cb_cls,
- TALER_EC_INVALID, // FIXME: Error code
- "Invalid pay uri!");
-
- /* NOTE: The above is a simplifying assumption for the
- test-logic, hitting this code merely means that
- the assumptions for the test (i.e. no instance) are
- not satisfied, it is not inherently the case that
- the above token must appear in the payment request!
-
- So if you hit this, you might just want to modify
- the code here to handle this better! */
- return;
- }
- cs->payment_order_id = GNUNET_strdup (&m[strlen ("/-/-/")]);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "At %s:%d Order ID from Anastasis service is %s\n",
- __FILE__, __LINE__,
- cs->payment_order_id);
-
- set_state (cs->state,
- ANASTASIS_RECOVERY_STATE_CHALLENGE_PAYING);
-
- recovery_information = json_object_get (cs->state,
- "recovery_information");
- GNUNET_assert (json_is_object (recovery_information));
- challenges = json_object_get (recovery_information,
- "challenges");
- GNUNET_assert (json_is_array (challenges));
- challenge =
- json_array_get (challenges,
- cs->challenge_index);
- GNUNET_assert (0 == json_object_set (challenge,
- "pay_uri",
- json_string (taler_pay_url)));
- GNUNET_assert (0 == json_object_set (challenge,
- "order_id",
- json_string (cs->payment_order_id)));
-
- cs->cb (cs->cb_cls,
- TALER_EC_NONE,
- cs->state);
- cs->cb = NULL;
-}
-
-
-// static
-void
-challenge_start_cb (void *cls,
- const char *response_string,
- unsigned int http_status_code)
-{
- json_t *recovery_information;
- json_t *challenges;
- const struct ANASTASIS_ChallengeDetails *ci;
- struct ChallengeState *cs = cls;
-
- if (http_status_code != MHD_HTTP_OK)
- {
- ANASTASIS_redux_fail_ (cs->cb,
- cs->cb_cls,
- TALER_EC_ANASTASIS_REDUCER_BACKEND_FAILURE,
- "Unexpected response code!");
-
- return;
- }
- else
- {
- set_state (cs->state,
- ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING);
- }
- ci = ANASTASIS_challenge_get_details (cs->c);
- GNUNET_assert (NULL != ci);
- recovery_information = json_object_get (cs->state,
- "recovery_information");
- GNUNET_assert (json_is_object (recovery_information));
- challenges = json_object_get (recovery_information,
- "challenges");
- GNUNET_assert (json_is_array (challenges));
-#if FIXME
- // overwrite challenge -- but only what we need here for the UI + nonce!
- json_t *challenge;
- // WTF?
- challenge =
- json_array_get (challenges,
- cs->challenge_index);
- challenge = ANASTASIS_challenge_information_to_json (ci);
- GNUNET_free (ci);
- GNUNET_assert (0 == json_array_set_new (challenges,
- cs->challenge_index,
- challenge));
-#endif
- cs->cb (cs->cb_cls,
- TALER_EC_NONE,
- cs->state);
- cs->cb = NULL;
-}
-
-
-#endif
-// end of graveyard
-//////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////
-
-
/**
* Context for a "select_challenge" operation.
*/
@@ -418,6 +180,179 @@ core_secret_cb (void *cls,
sctx->cb (sctx->cb_cls,
TALER_EC_NONE,
sctx->state);
+ sctx_free (sctx);
+}
+
+
+/**
+ * Defines a callback for the response status for a challenge start
+ * operation.
+ *
+ * @param cls a `struct SelectChallengeContext *`
+ * @param csr response details
+ */
+static void
+answer_feedback_cb (
+ void *cls,
+ const struct ANASTASIS_ChallengeStartResponse *csr)
+{
+ struct SelectChallengeContext *sctx = cls;
+ const struct ANASTASIS_ChallengeDetails *cd;
+ char uuid[sizeof (cd->uuid) * 2];
+ char *end;
+ json_t *feedback;
+
+ cd = ANASTASIS_challenge_get_details (csr->challenge);
+ end = GNUNET_STRINGS_data_to_string (&cd->uuid,
+ sizeof (cd->uuid),
+ uuid,
+ sizeof (uuid));
+ GNUNET_assert (NULL != end);
+ *end = '\0';
+ feedback = json_object_get (sctx->state,
+ "challenge_feedback");
+ if (NULL == feedback)
+ {
+ feedback = json_object ();
+ GNUNET_assert (0 ==
+ json_object_set_new (sctx->state,
+ "challenge_feedback",
+ feedback));
+ }
+ switch (csr->cs)
+ {
+ case ANASTASIS_CHALLENGE_STATUS_SOLVED:
+#if FIXME
+ mark_challenge_solved (sctx,
+ csr->challenge);
+ // => TRICKY: secret recovery success MAY will be reported AFTER
+ // answer feedback, so need to be prepared for that!
+ // => scheduling task to continue async should suffice!
+#endif
+ return;
+ case ANASTASIS_CHALLENGE_STATUS_INSTRUCTIONS:
+ {
+ json_t *instructions;
+
+ instructions = json_pack ("{s:s, s:s, s:I}",
+ "state",
+ "instructions",
+ "instructions",
+ csr->details.open_challenge.instructions,
+ "http_status",
+ (json_int_t) csr->details.open_challenge.
+ http_status);
+ GNUNET_assert (NULL != instructions);
+ GNUNET_assert (0 ==
+ json_object_set_new (feedback,
+ uuid,
+ instructions));
+ }
+ set_state (sctx->state,
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING);
+ sctx->cb (sctx->cb_cls,
+ TALER_EC_NONE,
+ sctx->state);
+ sctx_free (sctx);
+ return;
+ case ANASTASIS_CHALLENGE_STATUS_REDIRECT_FOR_AUTHENTICATION:
+ {
+ json_t *redir;
+
+ redir = json_pack ("{s:s, s:s}",
+ "state",
+ "redirect",
+ "redirect_url",
+ csr->details.redirect_url);
+ GNUNET_assert (NULL != redir);
+ GNUNET_assert (0 ==
+ json_object_set_new (feedback,
+ uuid,
+ redir));
+ }
+ set_state (sctx->state,
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING);
+ sctx->cb (sctx->cb_cls,
+ TALER_EC_NONE,
+ sctx->state);
+ sctx_free (sctx);
+ return;
+ case ANASTASIS_CHALLENGE_STATUS_PAYMENT_REQUIRED:
+ {
+ json_t *pay;
+
+ pay = json_pack ("{s:s, s:s, s:o}",
+ "state",
+ "payment",
+ "taler_pay_uri",
+ csr->details.payment_required.taler_pay_uri,
+ "payment_secret",
+ GNUNET_JSON_from_data_auto (
+ &csr->details.payment_required.payment_secret));
+ GNUNET_assert (NULL != pay);
+ GNUNET_assert (0 ==
+ json_object_set_new (feedback,
+ uuid,
+ pay));
+ }
+ set_state (sctx->state,
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_PAYING);
+ sctx->cb (sctx->cb_cls,
+ TALER_EC_NONE,
+ sctx->state);
+ sctx_free (sctx);
+ return;
+ case ANASTASIS_CHALLENGE_STATUS_SERVER_FAILURE:
+ {
+ json_t *err;
+
+ err = json_pack ("{s:s, s:I, s:I}",
+ "state",
+ "server-failure",
+ "http_status",
+ (json_int_t) csr->details.server_failure.http_status,
+ "error_code",
+ (json_int_t) csr->details.server_failure.ec);
+ GNUNET_assert (NULL != err);
+ GNUNET_assert (0 ==
+ json_object_set_new (feedback,
+ uuid,
+ err));
+ }
+ set_state (sctx->state,
+ ANASTASIS_GENERIC_STATE_ERROR);
+ sctx->cb (sctx->cb_cls,
+ TALER_EC_NONE,
+ sctx->state);
+ sctx_free (sctx);
+ return;
+ case ANASTASIS_CHALLENGE_STATUS_TRUTH_UNKNOWN:
+ {
+ json_t *err;
+
+ err = json_pack ("{s:s}",
+ "state",
+ "truth-unknown");
+ GNUNET_assert (NULL != err);
+ GNUNET_assert (0 ==
+ json_object_set_new (feedback,
+ uuid,
+ err));
+ }
+ set_state (sctx->state,
+ ANASTASIS_GENERIC_STATE_ERROR);
+ sctx->cb (sctx->cb_cls,
+ TALER_EC_NONE,
+ sctx->state);
+ sctx_free (sctx);
+ return;
+ }
+ GNUNET_break (0);
+ ANASTASIS_redux_fail_ (sctx->cb,
+ sctx->cb_cls,
+ TALER_EC_INVALID,
+ NULL);
+ sctx_free (sctx);
}
@@ -433,27 +368,171 @@ core_secret_cb (void *cls,
* @param ri recovery information struct which contains the policies
*/
static void
-select_challenge_cb (void *cls,
- const struct ANASTASIS_RecoveryInformation *ri)
+run_challenge_cb (void *cls,
+ const struct ANASTASIS_RecoveryInformation *ri)
{
struct SelectChallengeContext *sctx = cls;
+ const struct ANASTASIS_PaymentSecretP *psp = NULL;
+ struct ANASTASIS_PaymentSecretP ps;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_fixed_auto ("payment_secret",
+ &ps),
+ GNUNET_JSON_spec_end ()
+ };
- // FIXME:
- // - find challenge by sctx->uuid in ri (if not found, error)
- // - if secure question, find answer in sctx->args and answer it
- // - if answer is provided, try to answer it
- // - if no answer is provided, start challenge without answer
- // => given answer feedback, report that back to user via state update
- // => TRICKY: secret recovery success MAY will be reported AFTER
- // answer feedback, so need to be prepared for that!
+ if (NULL == ri)
+ {
+ GNUNET_break (0);
+ ANASTASIS_redux_fail_ (sctx->cb,
+ sctx->cb_cls,
+ TALER_EC_INVALID,
+ NULL);
+ sctx_free (sctx);
+ return;
+ }
+
+ /* Check if we got a payment_secret */
+ if (NULL != json_object_get (sctx->args,
+ "payment_secret"))
+ {
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (sctx->args,
+ spec,
+ NULL, NULL))
+ {
+ ANASTASIS_redux_fail_ (sctx->cb,
+ sctx->cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
+ "'payment_secret' malformed");
+ sctx_free (sctx);
+ return;
+ }
+ psp = &ps;
+ }
+
+ for (unsigned int i = 0; i<ri->cs_len; i++)
+ {
+ struct ANASTASIS_Challenge *ci = ri->cs[i];
+ const struct ANASTASIS_ChallengeDetails *cd;
+ int ret;
+
+ cd = ANASTASIS_challenge_get_details (ci);
+ if (0 ==
+ GNUNET_memcmp (&sctx->uuid,
+ &cd->uuid))
+ {
+ if (0 == strcmp ("question",
+ cd->method))
+ {
+ /* security question, answer must be a string */
+ json_t *janswer = json_object_get (sctx->args,
+ "answer");
+ const char *answer = json_string_value (janswer);
+
+ if (NULL == answer)
+ {
+ ANASTASIS_redux_fail_ (sctx->cb,
+ sctx->cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
+ "'answer' missing");
+ sctx_free (sctx);
+ return;
+ }
+ ret = ANASTASIS_challenge_answer (ci,
+ psp,
+ answer,
+ &answer_feedback_cb,
+ sctx);
+ }
+ else
+ {
+ /* Check if we got a PIN or a HASH */
+ json_t *pin = json_object_get (sctx->args,
+ "pin");
+ json_t *hash = json_object_get (sctx->args,
+ "hash");
+ if (json_is_integer (pin))
+ {
+ uint64_t ianswer = json_integer_value (pin);
+
+ ret = ANASTASIS_challenge_answer2 (ci,
+ psp,
+ ianswer,
+ &answer_feedback_cb,
+ sctx);
+ }
+ else if (NULL != hash)
+ {
+ struct GNUNET_HashCode hashed_answer;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_fixed_auto ("hash",
+ &hashed_answer),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (sctx->args,
+ spec,
+ NULL, NULL))
+ {
+ ANASTASIS_redux_fail_ (sctx->cb,
+ sctx->cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
+ "'answer' malformed");
+ sctx_free (sctx);
+ return;
+ }
+ ret = ANASTASIS_challenge_start (ci,
+ psp,
+ &hashed_answer,
+ &answer_feedback_cb,
+ sctx);
+ }
+ else
+ {
+ /* no answer provided */
+ ret = ANASTASIS_challenge_start (ci,
+ psp,
+ NULL, /* no answer */
+ &answer_feedback_cb,
+ sctx);
+ }
+ }
+ if (GNUNET_OK != ret)
+ {
+ ANASTASIS_redux_fail_ (sctx->cb,
+ sctx->cb_cls,
+ TALER_EC_INVALID,
+ NULL);
+ sctx_free (sctx);
+ return;
+ }
+ return; /* await answer feedback */
+ }
+ }
+ ANASTASIS_redux_fail_ (sctx->cb,
+ sctx->cb_cls,
+ TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
+ "'uuid' not in list of challenges");
+ sctx_free (sctx);
}
+/**
+ * The user selected a challenge to be solved. Begin the solving
+ * process.
+ *
+ * @param[in] state we are in
+ * @param arguments our arguments with the solution
+ * @param cb functiont o call with the new state
+ * @param cb_cls closure for @a cb
+ * @return handle to cancel challenge selection step
+ */
static struct ANASTASIS_ReduxAction *
-select_challenge (json_t *state,
- const json_t *arguments,
- ANASTASIS_ActionCallback cb,
- void *cb_cls)
+run_challenge (json_t *state,
+ const json_t *arguments,
+ ANASTASIS_ActionCallback cb,
+ void *cb_cls)
{
struct SelectChallengeContext *sctx
= GNUNET_new (struct SelectChallengeContext);
@@ -499,7 +578,7 @@ select_challenge (json_t *state,
sctx->args = json_incref ((json_t*) arguments);
sctx->r = ANASTASIS_recovery_deserialize (ANASTASIS_REDUX_ctx_,
rd,
- &select_challenge_cb,
+ &run_challenge_cb,
sctx,
&core_secret_cb,
sctx);
@@ -520,190 +599,25 @@ select_challenge (json_t *state,
}
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-// 2nd graveyard...
-
-
-static struct ANASTASIS_ReduxAction *
-pay_challenge (json_t *state,
- const json_t *arguments,
- ANASTASIS_ActionCallback cb,
- void *cb_cls)
-{
- // FIXME: implement
- if (NULL == arguments)
- {
- ANASTASIS_redux_fail_ (cb,
- cb_cls,
- TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
- "pay_challenge");
- return NULL;
- }
-
- cb (cb_cls,
- TALER_EC_NONE,
- state);
- return NULL;
-}
-
-
-static bool
-check_policy_fulfilled (json_t *state)
-{
- size_t p_index;
- json_t *recovery_information;
- json_t *challenges;
- json_t *policy;
- json_t *policies;
-
- recovery_information = json_object_get (state,
- "recovery_information");
- GNUNET_assert (json_is_object (recovery_information));
- policies = json_object_get (recovery_information,
- "policies");
- GNUNET_assert (json_is_array (policies));
- challenges = json_object_get (recovery_information,
- "challenges");
- GNUNET_assert (json_is_array (challenges));
-
- json_array_foreach (policies, p_index, policy)
- {
- size_t c_index;
- json_t *challenge_index;
- bool fulfilled = true;
-
- GNUNET_assert (json_is_array (policy));
- json_array_foreach (policy, c_index, challenge_index)
- {
- json_t *challenge = json_array_get (challenges,
- json_integer_value (
- challenge_index));
- unsigned int solved =
- json_integer_value (json_object_get (challenge,
- "solved"));
- if (solved == 0)
- {
- fulfilled = false;
- break;
- }
- }
- if (fulfilled)
- return true;
- }
- return false;
-}
-
-
-// static
-void
-challenge_answer_cb (void *af_cls,
- unsigned int http_status_code,
- enum TALER_ErrorCode ec)
-{
- struct ChallengeState *cs = af_cls;
- if (http_status_code != MHD_HTTP_OK)
- {
- ANASTASIS_redux_fail_ (cs->cb,
- cs->cb_cls,
- ec,
- "Unexpected response code!");
- return;
- }
- if (check_policy_fulfilled (cs->state))
- {
- // struct RecoverSecretState *rss
- // = GNUNET_new (struct RecoverSecretState);
- // FIXME: implement -> call recovery begin again
- set_state (cs->state,
- ANASTASIS_RECOVERY_STATE_RECOVERY_FINISHED);
- }
-}
-
-
-static struct ANASTASIS_ReduxAction *
-solve_challenge (json_t *state,
- const json_t *arguments,
- ANASTASIS_ActionCallback cb,
- void *cb_cls)
-{
- if (NULL == arguments)
- {
- ANASTASIS_redux_fail_ (cb,
- cb_cls,
- TALER_EC_ANASTASIS_REDUCER_INPUT_INVALID,
- "solve_challenge");
- return NULL;
- }
- json_t *recovery_information;
- json_t *challenges;
- struct ChallengeState *cs = GNUNET_new (struct ChallengeState);
-
- cs->cb = cb;
- cs->cb_cls = cb_cls;
- cs->state = state;
- cs->challenge_index =
- (unsigned int) json_integer_value (
- json_object_get (arguments,
- "challenge_index"));
- recovery_information = json_object_get (state,
- "recovery_information");
- GNUNET_assert (json_is_object (recovery_information));
- challenges = json_object_get (recovery_information,
- "challenges");
- GNUNET_assert (json_is_array (challenges));
-#if 0
- json_t *challenge;
- const char *method;
- struct ANASTASIS_Challenge *c;
-
- // FIXME: get challenge from recovery operation; deduplicate with code above!
- challenge =
- json_array_get (challenges,
- cs->challenge_index);
- // FIXME: c->recovery not initialized, will be deref'ed later!
- c = ANASTASIS_json_to_challenge (challenge);
-
- method = json_string_value (
- json_object_get (challenge,
- "method"));
- if (0 == strcmp (method, "question"))
- {
- cs->mode = 0;
- cs->answer = json_string_value (
- json_object_get (arguments,
- "answer"));
- }
- else
- {
- cs->mode = 1;
- cs->answer = json_string_value (
- json_object_get (arguments,
- "code"));
- }
-
- cs->cao = ANASTASIS_challenge_answer (c,
- cs->answer,
- &challenge_answer_cb,
- cs);
-#endif
- cb (cb_cls,
- TALER_EC_NONE,
- state);
- return NULL;
-}
-
-
+/**
+ * The user pressed "back" during challenge solving.
+ * Transition back to selecting another challenge.
+ *
+ * @param[in] state we are in
+ * @param arguments our arguments (unused)
+ * @param cb functiont o call with the new state
+ * @param cb_cls closure for @a cb
+ * @return NULL (synchronous operation)
+ */
static struct ANASTASIS_ReduxAction *
back_challenge_solving (json_t *state,
const json_t *arguments,
ANASTASIS_ActionCallback cb,
void *cb_cls)
{
- // FIXME: implement
+ (void) arguments;
+ set_state (state,
+ ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING);
cb (cb_cls,
TALER_EC_NONE,
state);
@@ -711,17 +625,6 @@ back_challenge_solving (json_t *state,
}
-// End of 2nd graveyard...
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-
-
/**
* Signature of callback function that implements a state transition.
*
@@ -765,7 +668,7 @@ ANASTASIS_recovery_action_ (json_t *state,
{
ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING,
"select_challenge",
- &select_challenge
+ &run_challenge
},
{
ANASTASIS_RECOVERY_STATE_CHALLENGE_SELECTING,
@@ -775,7 +678,7 @@ ANASTASIS_recovery_action_ (json_t *state,
{
ANASTASIS_RECOVERY_STATE_CHALLENGE_PAYING,
"pay",
- &pay_challenge
+ &run_challenge
},
{
ANASTASIS_RECOVERY_STATE_CHALLENGE_PAYING,
@@ -785,7 +688,7 @@ ANASTASIS_recovery_action_ (json_t *state,
{
ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING,
"solve_challenge",
- &solve_challenge
+ &run_challenge
},
{
ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-anastasis] branch master updated: work on recovery reducer (WiP),
gnunet <=