anastasis_service.h (23155B)
1 /* 2 This file is part of Anastasis 3 Copyright (C) 2019-2022 Anastasis SARL 4 5 Anastasis is free software; you can redistribute it and/or modify it under the 6 terms of the GNU 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.LIB. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file include/anastasis_service.h 18 * @brief C interface of libanastasisrest, a C library to use merchant's HTTP API 19 * @author Christian Grothoff 20 * @author Dennis Neufeld 21 * @author Dominik Meister 22 */ 23 #ifndef ANASTASIS_SERVICE_H 24 #define ANASTASIS_SERVICE_H 25 26 #include "anastasis_crypto_lib.h" 27 #include "anastasis_util_lib.h" 28 #include <gnunet/gnunet_curl_lib.h> 29 #include <jansson.h> 30 31 32 /** 33 * Anastasis authorization method configuration 34 */ 35 struct ANASTASIS_AuthorizationMethodConfig 36 { 37 /** 38 * Type of the method, i.e. "question". 39 */ 40 const char *type; 41 42 /** 43 * Fee charged for accessing key share using this method. 44 */ 45 struct TALER_Amount usage_fee; 46 }; 47 48 49 /** 50 * @brief Anastasis configuration data. 51 */ 52 struct ANASTASIS_Config 53 { 54 55 /** 56 * HTTP status returned. 57 */ 58 unsigned int http_status; 59 60 /** 61 * Taler-specific error code, #TALER_EC_NONE on success. 62 */ 63 enum TALER_ErrorCode ec; 64 65 /** 66 * Full response in JSON, if provided. 67 */ 68 const json_t *response; 69 70 /** 71 * Details depending on @e http_status. 72 */ 73 union 74 { 75 76 /** 77 * Details on #MHD_HTTP_OK. 78 */ 79 struct 80 { 81 82 /** 83 * Protocol version supported by the server. 84 */ 85 const char *version; 86 87 /** 88 * Business name of the anastasis provider. 89 */ 90 const char *business_name; 91 92 /** 93 * Array of authorization methods supported by the server. 94 */ 95 const struct ANASTASIS_AuthorizationMethodConfig *methods; 96 97 /** 98 * Length of the @e methods array. 99 */ 100 unsigned int methods_length; 101 102 /** 103 * Maximum size of an upload in megabytes. 104 */ 105 uint32_t storage_limit_in_megabytes; 106 107 /** 108 * Annual fee for an account / policy upload. 109 */ 110 struct TALER_Amount annual_fee; 111 112 /** 113 * Fee for a truth upload. 114 */ 115 struct TALER_Amount truth_upload_fee; 116 117 /** 118 * Maximum legal liability for data loss covered by the 119 * provider. 120 */ 121 struct TALER_Amount liability_limit; 122 123 /** 124 * Provider salt. 125 */ 126 struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt; 127 } ok; 128 129 } details; 130 131 }; 132 133 134 /** 135 * Function called with the result of a /config request. 136 * Note that an HTTP status of #MHD_HTTP_OK is no guarantee 137 * that @a acfg is non-NULL. @a acfg is non-NULL only if 138 * the server provided an acceptable response. 139 * 140 * @param cls closure 141 * @param acfg configuration obtained, NULL if we could not parse it 142 */ 143 typedef void 144 (*ANASTASIS_ConfigCallback)(void *cls, 145 const struct ANASTASIS_Config *acfg); 146 147 148 /** 149 * @brief A Config Operation Handle 150 */ 151 struct ANASTASIS_ConfigOperation; 152 153 154 /** 155 * Run a GET /config request against the Anastasis backend. 156 * 157 * @param ctx CURL context to use 158 * @param base_url base URL fo the Anastasis backend 159 * @param cb function to call with the results 160 * @param cb_cls closure for @a cb 161 * @return handle to cancel the operation 162 */ 163 struct ANASTASIS_ConfigOperation * 164 ANASTASIS_get_config (struct GNUNET_CURL_Context *ctx, 165 const char *base_url, 166 ANASTASIS_ConfigCallback cb, 167 void *cb_cls); 168 169 170 /** 171 * Cancel ongoing #ANASTASIS_get_config() request. 172 * 173 * @param co configuration request to cancel. 174 */ 175 void 176 ANASTASIS_config_cancel (struct ANASTASIS_ConfigOperation *co); 177 178 179 /****** POLICY API ******/ 180 181 182 /** 183 * Detailed meta data result. 184 */ 185 struct ANASTASIS_MetaDataEntry 186 { 187 188 /** 189 * Timestamp of the backup at the server. 190 */ 191 struct GNUNET_TIME_Timestamp server_time; 192 193 /** 194 * The encrypted meta data we downloaded. 195 */ 196 const void *meta_data; 197 198 /** 199 * Number of bytes in @e meta_data. 200 */ 201 size_t meta_data_size; 202 203 /** 204 * Policy version this @e meta_data is for. 205 */ 206 uint32_t version; 207 }; 208 209 210 /** 211 * Detailed results for meta data download. 212 */ 213 struct ANASTASIS_MetaDownloadDetails 214 { 215 216 /** 217 * HTTP status returned. 218 */ 219 unsigned int http_status; 220 221 /** 222 * Taler-specific error code, #TALER_EC_NONE on success. 223 */ 224 enum TALER_ErrorCode ec; 225 226 /** 227 * Full response in JSON, if provided. 228 */ 229 const json_t *response; 230 231 /** 232 * Details depending on @e http_status. 233 */ 234 union 235 { 236 237 /** 238 * Details on #MHD_HTTP_OK. 239 */ 240 struct 241 { 242 243 /** 244 * Version-sorted array of meta data we downloaded. 245 */ 246 const struct ANASTASIS_MetaDataEntry *metas; 247 248 /** 249 * Number of entries in @e metas. 250 */ 251 size_t metas_length; 252 253 } ok; 254 255 } details; 256 }; 257 258 259 /** 260 * Callback to process a GET /policy/$POL/meta request 261 * 262 * @param cls closure 263 * @param dd the response details 264 */ 265 typedef void 266 (*ANASTASIS_PolicyMetaLookupCallback) ( 267 void *cls, 268 const struct ANASTASIS_MetaDownloadDetails *dd); 269 270 271 /** 272 * Does a GET /policy/$POL/meta. 273 * 274 * @param ctx execution context 275 * @param backend_url base URL of the merchant backend 276 * @param anastasis_pub public key of the user's account 277 * @param max_version maximum version number to fetch 278 * @param cb callback which will work the response gotten from the backend 279 * @param cb_cls closure to pass to the callback 280 * @return handle for this operation, NULL upon errors 281 */ 282 struct ANASTASIS_PolicyMetaLookupOperation * 283 ANASTASIS_policy_meta_lookup ( 284 struct GNUNET_CURL_Context *ctx, 285 const char *backend_url, 286 const struct ANASTASIS_CRYPTO_AccountPublicKeyP *anastasis_pub, 287 uint32_t max_version, 288 ANASTASIS_PolicyMetaLookupCallback cb, 289 void *cb_cls); 290 291 292 /** 293 * Cancel a GET /policy/$POL/meta request. 294 * 295 * @param plo cancel the policy lookup operation 296 */ 297 void 298 ANASTASIS_policy_meta_lookup_cancel ( 299 struct ANASTASIS_PolicyMetaLookupOperation *plo); 300 301 302 /** 303 * Detailed results from the successful download. 304 */ 305 struct ANASTASIS_DownloadDetails 306 { 307 308 /** 309 * HTTP status returned. 310 */ 311 unsigned int http_status; 312 313 /** 314 * Taler-specific error code, #TALER_EC_NONE on success. 315 */ 316 enum TALER_ErrorCode ec; 317 318 /** 319 * Details depending on @e http_status. 320 */ 321 union 322 { 323 324 /** 325 * Details on #MHD_HTTP_OK. 326 */ 327 struct 328 { 329 330 /** 331 * Signature (already verified). 332 */ 333 struct ANASTASIS_AccountSignatureP sig; 334 335 /** 336 * Hash over @e policy and @e policy_size. 337 */ 338 struct GNUNET_HashCode curr_policy_hash; 339 340 /** 341 * The backup we downloaded. 342 */ 343 const void *policy; 344 345 /** 346 * Number of bytes in @e backup. 347 */ 348 size_t policy_size; 349 350 /** 351 * Policy version returned by the service. 352 */ 353 uint32_t version; 354 } ok; 355 356 } details; 357 358 }; 359 360 361 /** 362 * Handle for a GET /policy operation. 363 */ 364 struct ANASTASIS_PolicyLookupOperation; 365 366 367 /** 368 * Callback to process a GET /policy request 369 * 370 * @param cls closure 371 * @param dd the response details 372 */ 373 typedef void 374 (*ANASTASIS_PolicyLookupCallback) (void *cls, 375 const struct ANASTASIS_DownloadDetails *dd); 376 377 378 /** 379 * Does a GET /policy. 380 * 381 * @param ctx execution context 382 * @param backend_url base URL of the merchant backend 383 * @param anastasis_pub public key of the user's account 384 * @param cb callback which will work the response gotten from the backend 385 * @param cb_cls closure to pass to the callback 386 * @return handle for this operation, NULL upon errors 387 */ 388 struct ANASTASIS_PolicyLookupOperation * 389 ANASTASIS_policy_lookup ( 390 struct GNUNET_CURL_Context *ctx, 391 const char *backend_url, 392 const struct ANASTASIS_CRYPTO_AccountPublicKeyP *anastasis_pub, 393 ANASTASIS_PolicyLookupCallback cb, 394 void *cb_cls); 395 396 397 /** 398 * Does a GET /policy for a specific version. 399 * 400 * @param ctx execution context 401 * @param backend_url base URL of the merchant backend 402 * @param anastasis_pub public key of the user's account 403 * @param cb callback which will work the response gotten from the backend 404 * @param cb_cls closure to pass to the callback 405 * @param version version of the policy to be requested 406 * @return handle for this operation, NULL upon errors 407 */ 408 struct ANASTASIS_PolicyLookupOperation * 409 ANASTASIS_policy_lookup_version ( 410 struct GNUNET_CURL_Context *ctx, 411 const char *backend_url, 412 const struct ANASTASIS_CRYPTO_AccountPublicKeyP *anastasis_pub, 413 ANASTASIS_PolicyLookupCallback cb, 414 void *cb_cls, 415 unsigned int version); 416 417 418 /** 419 * Cancel a GET /policy request. 420 * 421 * @param plo cancel the policy lookup operation 422 */ 423 void 424 ANASTASIS_policy_lookup_cancel ( 425 struct ANASTASIS_PolicyLookupOperation *plo); 426 427 428 /** 429 * Handle for a POST /policy operation. 430 */ 431 struct ANASTASIS_PolicyStoreOperation; 432 433 434 /** 435 * High-level ways how an upload may conclude. 436 */ 437 enum ANASTASIS_UploadStatus 438 { 439 /** 440 * Backup was successfully made. 441 */ 442 ANASTASIS_US_SUCCESS = 0, 443 444 /** 445 * Account expired or payment was explicitly requested 446 * by the client. 447 */ 448 ANASTASIS_US_PAYMENT_REQUIRED, 449 450 /** 451 * HTTP interaction failed, see HTTP status. 452 */ 453 ANASTASIS_US_HTTP_ERROR, 454 455 /** 456 * We had an internal error (not sure this can happen, 457 * but reserved for HTTP 400 status codes). 458 */ 459 ANASTASIS_US_CLIENT_ERROR, 460 461 /** 462 * Server had an internal error. 463 */ 464 ANASTASIS_US_SERVER_ERROR, 465 466 /** 467 * Truth already exists. Not applicable for policy uploads. 468 */ 469 ANASTASIS_US_CONFLICTING_TRUTH 470 }; 471 472 473 /** 474 * Result of an upload. 475 */ 476 struct ANASTASIS_UploadDetails 477 { 478 /** 479 * High level status of the upload operation. Determines @e details. 480 */ 481 enum ANASTASIS_UploadStatus us; 482 483 /** 484 * HTTP status code. 485 */ 486 unsigned int http_status; 487 488 /** 489 * Taler error code. 490 */ 491 enum TALER_ErrorCode ec; 492 493 union 494 { 495 496 struct 497 { 498 /** 499 * Hash of the stored recovery data, returned if 500 * @e us is #ANASTASIS_US_SUCCESS. 501 */ 502 const struct GNUNET_HashCode *curr_backup_hash; 503 504 /** 505 * At what time is the provider set to forget this 506 * policy (because the account expires)? 507 */ 508 struct GNUNET_TIME_Timestamp policy_expiration; 509 510 /** 511 * Version number of the resulting policy. 512 */ 513 unsigned long long policy_version; 514 515 } success; 516 517 /** 518 * Details about required payment. 519 */ 520 struct 521 { 522 /** 523 * A taler://pay/-URI with a request to pay the annual fee for 524 * the service. Returned if @e us is #ANASTASIS_US_PAYMENT_REQUIRED. 525 */ 526 const char *payment_request; 527 528 /** 529 * The payment secret (aka order ID) extracted from the @e payment_request. 530 */ 531 struct ANASTASIS_PaymentSecretP ps; 532 } payment; 533 534 } details; 535 }; 536 537 538 /** 539 * Callback to process a POST /policy request 540 * 541 * @param cls closure 542 * @param up the decoded response body 543 */ 544 typedef void 545 (*ANASTASIS_PolicyStoreCallback) (void *cls, 546 const struct ANASTASIS_UploadDetails *up); 547 548 549 /** 550 * Store policies, does a POST /policy/$ACCOUNT_PUB 551 * 552 * @param ctx the CURL context used to connect to the backend 553 * @param backend_url backend's base URL, including final "/" 554 * @param anastasis_priv private key of the user's account 555 * @param recovery_data policy data to be stored 556 * @param recovery_data_size number of bytes in @a recovery_data 557 * @param recovery_meta_data policy meta data to be stored 558 * @param recovery_meta_data_size number of bytes in @a recovery_meta_data 559 * @param payment_years_requested for how many years would the client like the service to store the truth? 560 * @param payment_secret payment identifier of last payment 561 * @param payment_timeout how long to wait for the payment, use 562 * #GNUNET_TIME_UNIT_ZERO to let the server pick 563 * @param cb callback processing the response from /policy 564 * @param cb_cls closure for @a cb 565 * @return handle for the operation 566 */ 567 struct ANASTASIS_PolicyStoreOperation * 568 ANASTASIS_policy_store ( 569 struct GNUNET_CURL_Context *ctx, 570 const char *backend_url, 571 const struct ANASTASIS_CRYPTO_AccountPrivateKeyP *anastasis_priv, 572 const void *recovery_data, 573 size_t recovery_data_size, 574 const void *recovery_meta_data, 575 size_t recovery_meta_data_size, 576 uint32_t payment_years_requested, 577 const struct ANASTASIS_PaymentSecretP *payment_secret, 578 struct GNUNET_TIME_Relative payment_timeout, 579 ANASTASIS_PolicyStoreCallback cb, 580 void *cb_cls); 581 582 583 /** 584 * Cancel a POST /policy request. 585 * 586 * @param pso the policy store operation to cancel 587 */ 588 void 589 ANASTASIS_policy_store_cancel ( 590 struct ANASTASIS_PolicyStoreOperation *pso); 591 592 593 /****** TRUTH API ******/ 594 595 596 /** 597 * Handle for a POST /truth operation. 598 */ 599 struct ANASTASIS_TruthStoreOperation; 600 601 602 /** 603 * Callback to process a POST /truth request 604 * 605 * @param cls closure 606 * @param obj the response body 607 */ 608 typedef void 609 (*ANASTASIS_TruthStoreCallback) (void *cls, 610 const struct ANASTASIS_UploadDetails *up); 611 612 613 /** 614 * Store Truth, does a POST /truth/$UUID 615 * 616 * @param ctx the CURL context used to connect to the backend 617 * @param backend_url backend's base URL, including final "/" 618 * @param uuid unique identfication of the Truth Upload 619 * @param type type of the authorization method 620 * @param encrypted_keyshare key material to return to the client upon authorization 621 * @param truth_mime mime type of @e encrypted_truth (after decryption) 622 * @param encrypted_truth_size number of bytes in @e encrypted_truth 623 * @param encrypted_truth contains the @a type-specific authorization data 624 * @param payment_years_requested for how many years would the client like the service to store the truth? 625 * @param payment_timeout how long to wait for the payment, use 626 * #GNUNET_TIME_UNIT_ZERO to let the server pick 627 * @param cb callback processing the response from /truth 628 * @param cb_cls closure for cb 629 * @return handle for the operation 630 */ 631 struct ANASTASIS_TruthStoreOperation * 632 ANASTASIS_truth_store ( 633 struct GNUNET_CURL_Context *ctx, 634 const char *backend_url, 635 const struct ANASTASIS_CRYPTO_TruthUUIDP *uuid, 636 const char *type, 637 const struct ANASTASIS_CRYPTO_EncryptedKeyShareP *encrypted_keyshare, 638 const char *truth_mime, 639 size_t encrypted_truth_size, 640 const void *encrypted_truth, 641 uint32_t payment_years_requested, 642 struct GNUNET_TIME_Relative payment_timeout, 643 ANASTASIS_TruthStoreCallback cb, 644 void *cb_cls); 645 646 647 /** 648 * Cancel a POST /truth request. 649 * 650 * @param tso the truth store operation 651 */ 652 void 653 ANASTASIS_truth_store_cancel ( 654 struct ANASTASIS_TruthStoreOperation *tso); 655 656 657 /** 658 * Possible ways how to proceed with a challenge. 659 */ 660 enum ANASTASIS_ChallengeDetailType 661 { 662 663 /** 664 * A challenge TAN was written to a file. 665 * The name of the file is provided. 666 */ 667 ANASTASIS_CS_FILE_WRITTEN, 668 669 /** 670 * A challenge TAN was sent to the customer. 671 * A hint may be provided as to the address used. 672 */ 673 ANASTASIS_CS_TAN_SENT, 674 675 /** 676 * A challenge TAN was already recently sent to the customer. 677 * A hint may be provided as to the address used. 678 */ 679 ANASTASIS_CS_TAN_ALREADY_SENT, 680 681 /** 682 * The customer should wire funds to the bank 683 * account address provided. 684 */ 685 ANASTASIS_CS_WIRE_FUNDS 686 687 }; 688 689 690 /** 691 * This structure contains information about where to wire the funds 692 * to authenticate as well as a hint as to which bank account to send 693 * the funds from. 694 */ 695 struct ANASTASIS_WireFundsDetails 696 { 697 698 /** 699 * Answer code expected. 700 */ 701 uint64_t answer_code; 702 703 /** 704 * How much should be sent. 705 */ 706 struct TALER_Amount amount; 707 708 /** 709 * IBAN where to send the funds. 710 */ 711 const char *target_iban; 712 713 /** 714 * Name of the business receiving the funds. 715 */ 716 const char *target_business_name; 717 718 /** 719 * Wire transfer subject to use. 720 */ 721 const char *wire_transfer_subject; 722 723 }; 724 725 726 /** 727 * Information returned for a POST /truth/$TID/challenge request. 728 */ 729 struct ANASTASIS_TruthChallengeDetails 730 { 731 /** 732 * HTTP status returned by the server. 733 */ 734 unsigned int http_status; 735 736 /** 737 * Taler-specific error code, #TALER_EC_NONE on success. 738 */ 739 enum TALER_ErrorCode ec; 740 741 /** 742 * Full response in JSON, if provided. 743 */ 744 const json_t *response; 745 746 /** 747 * Details depending on @e http_status. 748 */ 749 union 750 { 751 752 /** 753 * Information for @e http_status of #MHD_HTTP_OK. 754 */ 755 struct 756 { 757 /** 758 * Meta-state about how the challenge was 759 * initiated and what is to be done next. 760 */ 761 enum ANASTASIS_ChallengeDetailType cs; 762 763 /** 764 * Details depending on @e cs. 765 */ 766 union 767 { 768 769 /** 770 * If @e cs is #ANASTASIS_CS_FILE_WRITTEN, this 771 * is the filename with the challenge code. 772 */ 773 const char *challenge_filename; 774 775 /** 776 * If @e cs is #ANASTASIS_CS_TAN_SENT, this 777 * is human-readable information as to where 778 * the TAN was sent. 779 */ 780 const char *tan_address_hint; 781 782 /** 783 * If @e cs is #ANASTASIS_CS_WIRE_FUNDS, this 784 * structure contains information about where 785 * to wire the funds to authenticate as well 786 * as a hint as to which bank account to send 787 * the funds from. 788 */ 789 struct ANASTASIS_WireFundsDetails wire_funds; 790 791 } details; 792 793 } success; 794 795 /** 796 * Information returne if @e http_status is #MHD_HTTP_PAYMENT_REQUIRED 797 */ 798 struct 799 { 800 /** 801 * A taler://pay/-URI with a request to pay the annual fee for 802 * the service. Returned if @e us is #ANASTASIS_US_PAYMENT_REQUIRED. 803 */ 804 const char *payment_request; 805 806 /** 807 * The payment secret (aka order ID) extracted from the @e payment_request. 808 */ 809 struct ANASTASIS_PaymentSecretP ps; 810 811 /** 812 * Data extracted from the payto:// URI. 813 */ 814 const struct TALER_MERCHANT_PayUriData *pd; 815 816 } payment_required; 817 818 } details; 819 820 }; 821 822 823 /** 824 * Handle for a POST /truth/$TID/challenge operation. 825 */ 826 struct ANASTASIS_TruthChallengeOperation; 827 828 829 /** 830 * Callback to process a POST /truth/$TID/challenge response. 831 * 832 * @param cls closure 833 * @param tcd details about the key share 834 */ 835 typedef void 836 (*ANASTASIS_TruthChallengeCallback) ( 837 void *cls, 838 const struct ANASTASIS_TruthChallengeDetails *tcd); 839 840 841 /** 842 * Makes a POST /truth/$TID/challenge request. 843 * 844 * @param ctx execution context 845 * @param backend_url base URL of the merchant backend 846 * @param truth_uuid identification of the Truth 847 * @param truth_key Key used to Decrypt the Truth on the Server 848 * @param payment_secret secret from the previously done payment NULL to trigger payment 849 * @param cb callback which will work the response gotten from the backend 850 * @param cb_cls closure to pass to the callback 851 * @return handle for this operation, NULL upon errors 852 */ 853 struct ANASTASIS_TruthChallengeOperation * 854 ANASTASIS_truth_challenge ( 855 struct GNUNET_CURL_Context *ctx, 856 const char *backend_url, 857 const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid, 858 const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key, 859 const struct ANASTASIS_PaymentSecretP *payment_secret, 860 ANASTASIS_TruthChallengeCallback cb, 861 void *cb_cls); 862 863 864 /** 865 * Cancel a POST /truth/$TID/challenge request. 866 * 867 * @param[in] tco operation to cancel 868 */ 869 void 870 ANASTASIS_truth_challenge_cancel ( 871 struct ANASTASIS_TruthChallengeOperation *tco); 872 873 874 /** 875 * Information returned for a POST /truth/$TID/solve request. 876 */ 877 struct ANASTASIS_TruthSolveReply 878 { 879 880 /** 881 * HTTP status returned by the server. 882 */ 883 unsigned int http_status; 884 885 /** 886 * Taler-specific error code, #TALER_EC_NONE on success. 887 */ 888 enum TALER_ErrorCode ec; 889 890 /** 891 * Details depending on @e http_status. 892 */ 893 union 894 { 895 896 /** 897 * Information returned if @e http_status is #MHD_HTTP_OK. 898 */ 899 struct 900 { 901 902 /** 903 * The encrypted key share. 904 */ 905 struct ANASTASIS_CRYPTO_EncryptedKeyShareP eks; 906 907 } success; 908 909 /** 910 * Information returne if @e http_status is #MHD_HTTP_PAYMENT_REQUIRED 911 */ 912 struct 913 { 914 /** 915 * A taler://pay/-URI with a request to pay the annual fee for 916 * the service. Returned if @e us is #ANASTASIS_US_PAYMENT_REQUIRED. 917 */ 918 const char *payment_request; 919 920 /** 921 * The payment secret (aka order ID) extracted from the @e payment_request. 922 */ 923 struct ANASTASIS_PaymentSecretP ps; 924 925 /** 926 * Data extracted from the payto:// URI. 927 */ 928 const struct TALER_MERCHANT_PayUriData *pd; 929 930 } payment_required; 931 932 /** 933 * Information returne if @e http_status is #MHD_HTTP_TOO_MANY_REQUESTS. 934 */ 935 struct 936 { 937 938 /** 939 * How many requests are allowed at most per @e request_frequency? 940 */ 941 uint32_t request_limit; 942 943 /** 944 * Frequency at which requests are allowed / new challenges are 945 * created. 946 */ 947 struct GNUNET_TIME_Relative request_frequency; 948 } too_many_requests; 949 950 } details; 951 952 }; 953 954 955 /** 956 * Handle for a POST /truth/$TID/solve operation. 957 */ 958 struct ANASTASIS_TruthSolveOperation; 959 960 961 /** 962 * Callback to process a POST /truth/$TID/solve response. 963 * 964 * @param cls closure 965 * @param kdd details about the key share 966 */ 967 typedef void 968 (*ANASTASIS_TruthSolveCallback) ( 969 void *cls, 970 const struct ANASTASIS_TruthSolveReply *trs); 971 972 973 /** 974 * Makes a POST /truth/$TID/solve request. 975 * 976 * @param ctx execution context 977 * @param backend_url base URL of the merchant backend 978 * @param truth_uuid identification of the Truth 979 * @param truth_key Key used to Decrypt the Truth on the Server 980 * @param payment_secret secret from the previously done payment NULL to trigger payment 981 * @param timeout how long to wait for the payment, use 982 * #GNUNET_TIME_UNIT_ZERO to let the server pick 983 * @param hashed_answer hashed answer to the challenge 984 * @param cb callback which will work the response gotten from the backend 985 * @param cb_cls closure to pass to the callback 986 * @return handle for this operation, NULL upon errors 987 */ 988 struct ANASTASIS_TruthSolveOperation * 989 ANASTASIS_truth_solve ( 990 struct GNUNET_CURL_Context *ctx, 991 const char *backend_url, 992 const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid, 993 const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key, 994 const struct ANASTASIS_PaymentSecretP *payment_secret, 995 struct GNUNET_TIME_Relative timeout, 996 const struct GNUNET_HashCode *hashed_answer, 997 ANASTASIS_TruthSolveCallback cb, 998 void *cb_cls); 999 1000 1001 /** 1002 * Cancel a POST /truth/$TID/solve request. 1003 * 1004 * @param[in] tso handle of the operation to cancel 1005 */ 1006 void 1007 ANASTASIS_truth_solve_cancel ( 1008 struct ANASTASIS_TruthSolveOperation *tso); 1009 1010 1011 #endif /* _ANASTASIS_SERVICE_H */