aboutsummaryrefslogtreecommitdiff
path: root/src/include/anastasis_json.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/anastasis_json.h')
-rw-r--r--src/include/anastasis_json.h410
1 files changed, 0 insertions, 410 deletions
diff --git a/src/include/anastasis_json.h b/src/include/anastasis_json.h
deleted file mode 100644
index d2523a2..0000000
--- a/src/include/anastasis_json.h
+++ /dev/null
@@ -1,410 +0,0 @@
1/*
2 This file is part of Anastasis
3 Copyright (C) 2020 Taler Systems SA
4
5 Anastasis is free software; you can redistribute it and/or modify it under the
6 terms of the GNU Lesser General Public License as published by the Free Software
7 Foundation; either version 3, or (at your option) any later version.
8
9 Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along with
14 Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/>
15*/
16/**
17 * @file include/anastasis_json.h
18 * @brief anastasis de-/serialization api
19 * @author Christian Grothoff
20 * @author Dominik Meister
21 * @author Dennis Neufeld
22 */
23#ifndef ANASTASIS_JSON_H
24#define ANASTASIS_JSON_H
25
26#include <jansson.h>
27#include <gnunet/gnunet_util_lib.h>
28#include "anastasis_error_codes.h"
29
30/**
31 * Enumeration of possible backup process status.
32 */
33enum ANASTASIS_BackupStatus
34{
35 ANASTASIS_BS_INITIAL,
36 ANASTASIS_BS_SELECT_CONTINENT,
37 ANASTASIS_BS_SELECT_COUNTRY,
38 ANASTASIS_BS_ENTER_USER_ATTRIBUTES,
39 ANASTASIS_BS_ADD_AUTHENTICATION_METHOD,
40 ANASTASIS_BS_ADD_POLICY,
41 ANASTASIS_BS_PAY
42};
43
44/**
45 * Enumeration of possible recovery process status.
46 */
47enum ANASTASIS_RecoveryStatus
48{
49 ANASTASIS_RS_INITIAL,
50 ANASTASIS_RS_SELECT_CONTINENT,
51 ANASTASIS_RS_SELECT_COUNTRY,
52 ANASTASIS_RS_ENTER_USER_ATTRIBUTES,
53 ANASTASIS_RS_SOLVE_CHALLENGE
54};
55
56// A state for the backup process.
57struct ANASTASIS_BackupState
58{
59 enum ANASTASIS_BackupStatus status;
60
61 union
62 {
63
64 struct
65 {
66 // empty!
67 } select_continent;
68
69 struct
70 {
71 const char *continent;
72 } select_country;
73
74 struct
75 {
76 const char *continent;
77 const char *country;
78 const char *currency; // derived or per manual override!
79 json_t *user_attributes;
80 } enter_attributes;
81
82 struct
83 {
84 const char *continent;
85 const char *country;
86 const char *currency;
87 json_t *user_attributes;
88
89 struct AuthenticationDetails
90 {
91 enum AuthenticationMethod
92 {
93 SMS,
94 VIDEO,
95 SECQUEST,
96 EMAIL,
97 SNAILMAIL
98 };
99 char *provider_url;
100 union Truth
101 {
102
103 struct
104 {
105 char *phone_number;
106 } sms;
107
108 struct
109 {
110 char *question;
111 char *answer; // FIXME: Reasonable to store answer in clear text here?
112 } secquest;
113
114 struct
115 {
116 char *mailaddress;
117 } email;
118
119 struct
120 {
121 char *full_name;
122 char *street; // street name + number
123 char *postal_code;
124 char *city;
125 char *country;
126 } snailmail;
127
128 struct
129 {
130 char *path_to_picture;
131 } video;
132 } truth;
133 }*ad; // array
134 size_t ad_length;
135 } add_authentication;
136 struct
137 {
138 const char *continent;
139 const char *country;
140 const char *currency;
141 json_t *user_attributes;
142
143 struct AuthenticationDetails
144 {
145 enum AuthenticationMethod
146 {
147 SMS,
148 VIDEO,
149 SECQUEST,
150 EMAIL,
151 SNAILMAIL
152 };
153 char *provider_url;
154 union Truth
155 {
156
157 struct
158 {
159 char *phone_number;
160 } sms;
161
162 struct
163 {
164 char *question;
165 char *answer; // FIXME: Reasonable to store answer in clear text here?
166 } secquest;
167
168 struct
169 {
170 char *mailaddress;
171 } email;
172
173 struct
174 {
175 char *full_name;
176 char *street; // street name + number
177 char *postal_code;
178 char *city;
179 char *country;
180 } snailmail;
181
182 struct
183 {
184 char *path_to_picture;
185 } video;
186 } truth;
187 }*ad; // array
188 size_t ad_length;
189
190 struct PolicyDetails
191 {
192 struct AuthenticationDetails *ad; // array
193 }*pd; // array
194 size_t pd_length;
195 } add_policy;
196 // FIXME: add_payment
197 } details;
198};
199
200
201// A state for the recovery process.
202struct ANASTASIS_RecoveryState
203{
204 enum ANASTASIS_RecoveryStatus status;
205
206 struct
207 {
208 // empty!
209 } select_continent;
210
211 struct
212 {
213 const char *continent;
214 } select_country;
215
216 struct
217 {
218 const char *continent;
219 const char *country;
220 const char *currency; // derived or per manual override!
221 json_t *user_attributes;
222 } enter_attributes;
223
224 struct
225 {
226 const char *continent;
227 const char *country;
228 const char *currency;
229 json_t *user_attributes;
230
231 struct ChallengeDetails
232 {
233 enum AuthenticationMethod
234 {
235 SMS,
236 VIDEO,
237 SECQUEST,
238 EMAIL,
239 SNAILMAIL
240 };
241 char *provider_url;
242 union Challenge
243 {
244
245 struct
246 {
247 char *phone_number;
248 char *code;
249 } sms;
250
251 struct
252 {
253 char *question;
254 char *answer; // FIXME: Reasonable to store answer in clear text here?
255 } secquest;
256
257 struct
258 {
259 char *mailaddress;
260 char *code;
261 } email;
262
263 struct
264 {
265 char *full_name;
266 char *street; // street name + number
267 char *postal_code;
268 char *city;
269 char *country;
270 char *code;
271 } snailmail;
272
273 struct
274 {
275 char *path_to_picture;
276 char *code;
277 } video;
278 } truth;
279 }*cd; // array
280 size_t cd_length;
281 } solve_challenge;
282};
283
284/**
285 * Definition of actions on ANASTASIS_BackupState.
286 */
287struct ANASTASIS_BackupAction
288{
289 enum action
290 {
291 ANASTASIS_BA_GET_SELECT_CONTINENT,
292 ANASTASIS_BA_GET_SELECT_COUNTRY,
293 ANASTASIS_BA_GET_ENTER_USER_ATTRIBUTES,
294 ANASTASIS_BA_GET_ADD_AUTHENTICATION_METHOD,
295 ANASTASIS_BA_GET_ADD_POLICY,
296 ANASTASIS_BA_GET_PAY,
297 ANASTASIS_BA_SET_SELECT_CONTINENT,
298 ANASTASIS_BA_SET_SELECT_COUNTRY,
299 ANASTASIS_BA_SET_ENTER_USER_ATTRIBUTES,
300 ANASTASIS_BA_SET_ADD_AUTHENTICATION_METHOD,
301 ANASTASIS_BA_SET_ADD_POLICY,
302 ANASTASIS_BA_SET_PAY
303 };
304};
305
306/**
307 * Definition of actions on ANASTASIS_RecoveryState.
308 */
309struct ANASTASIS_RecoveryAction
310{
311 enum action
312 {
313 ANASTASIS_RS_GET_SELECT_CONTINENT,
314 ANASTASIS_RS_GET_SELECT_COUNTRY,
315 ANASTASIS_RS_GET_ENTER_USER_ATTRIBUTES,
316 ANASTASIS_RS_GET_SOLVE_CHALLENGE,
317 ANASTASIS_RS_SET_SELECT_CONTINENT,
318 ANASTASIS_RS_SET_SELECT_COUNTRY,
319 ANASTASIS_RS_SET_ENTER_USER_ATTRIBUTES,
320 ANASTASIS_RS_SET_SOLVE_CHALLENGE
321 };
322};
323
324
325/**
326 * Signature of the callback bassed to #ANASTASIS_apply_anastasis_backup_action
327 * for asynchronous actions on a #ANASTASIS_BackupState.
328 *
329 * @param cls closure
330 * @param new_bs the new #ANASTASIS_BackupState
331 * @param error error code
332 */
333typedef void
334(*ANASTASIS_BackupApplyActionCallback)(
335 void *cls,
336 const struct ANASTASIS_BackupState *new_bs,
337 enum TALER_ErrorCode error);
338
339
340/**
341 * Signature of the callback bassed to #ANASTASIS_apply_anastasis_recovery_action
342 * for asynchronous actions on a #ANASTASIS_RecoveryState.
343 *
344 * @param cls closure
345 * @param new_bs the new #ANASTASIS_RecoveryState
346 * @param error error code
347 */
348typedef void
349(*ANASTASIS_RecoveryApplyActionCallback)(
350 void *cls,
351 const struct ANASTASIS_RecoveryState *new_rs,
352 enum TALER_ErrorCode error);
353
354
355/**
356 * Returns an initial ANASTASIS_BackupState.
357 *
358 * @return initial ANASTASIS_BackupState
359 */
360struct ANASTASIS_BackupState *
361ANASTASIS_get_initial_backup_state ();
362
363
364/**
365 * Returns an initial ANASTASIS_RecoveryState.
366 *
367 * @return initial ANASTASIS_RecoveryState
368 */
369struct ANASTASIS_RecoveryState *
370ANASTASIS_get_initial_recovery_state ();
371
372
373/**
374 * Operates on a backup state depending on given #ANASTASIS_BackupState
375 * and #ANASTASIS_BackupAction. The new #ANASTASIS_BackupState is returned
376 * by a callback function.
377 * This function can do network access to talk to anastasis service providers.
378 *
379 * @param ctx url context for the event loop
380 * @param bs the previous *ANASTASIS_BackupState
381 * @param ba the action to do on #ANASTASIS_BackupState
382 * @param cb callback function to call with the action
383 */
384void
385ANASTASIS_apply_anastasis_backup_action (
386 struct GNUNET_CURL_Context *ctx,
387 struct ANASTASIS_BackupState *bs,
388 struct ANASTASIS_BackupAction *ba,
389 ANASTASIS_BackupApplyActionCallback cb);
390
391
392/**
393 * Operates on a recovery state depending on given #ANASTASIS_RecoveryState
394 * and #ANASTASIS_RecoveryAction. The new #ANASTASIS_RecoveryState is returned
395 * by a callback function.
396 * This function can do network access to talk to anastasis service providers.
397 *
398 * @param ctx url context for the event loop
399 * @param bs the previous *ANASTASIS_RecoveryState
400 * @param ba the action to do on #ANASTASIS_RecoveryState
401 * @param cb callback function to call with the action
402 */
403void
404ANASTASIS_apply_anastasis_recovery_action (
405 struct GNUNET_CURL_Context *ctx,
406 struct ANASTASIS_RecoveryState *rs,
407 struct ANASTASIS_RecoveryAction *ra,
408 ANASTASIS_RecoveryApplyActionCallback cb);
409
410#endif /* _ANASTASIS_JSON_H */