taler-docs

Documentation for GNU Taler components, APIs and protocols
Log | Files | Refs | README | LICENSE

taler-kyc-manual.rst (55412B)


      1 ..
      2   This file is part of GNU TALER.
      3 
      4   Copyright (C) 2014-2025 Taler Systems SA
      5 
      6   TALER is free software; you can redistribute it and/or modify it under the
      7   terms of the GNU Affero General Public License as published by the Free Software
      8   Foundation; either version 3.0, or (at your option) any later version.
      9 
     10   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     11   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     12   A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.
     13 
     14   You should have received a copy of the GNU Affero General Public License along with
     15   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     16 
     17   @author Christian Grothoff
     18   @author Florian Dold
     19 
     20 .. _KycOperatorManual:
     21 
     22 Exchange KYC/AML Operator Manual
     23 ################################
     24 
     25 Introduction
     26 ============
     27 
     28 About GNU Taler
     29 ---------------
     30 
     31 .. include:: frags/about-taler.rst
     32 
     33 
     34 About this manual
     35 -----------------
     36 
     37 This chapter describes how to setup certain compliance aspects of a GNU Taler
     38 exchange. Users that just want to set up an exchange as an experiment without
     39 legal or regulatory requirements can safely skip this chapter.
     40 
     41 This manual targets compliance experts working with system administrators and
     42 developers to configure legitimization (KYC/KYB) and anti-money laundering
     43 (AML) processes for a GNU Taler exchange.  Expertise in all three domains is
     44 required, as Taler's KYC and AML processes are highly configurable and
     45 programmable.
     46 
     47 
     48 
     49 Legal conditions for using the service
     50 --------------------------------------
     51 
     52 .. include:: frags/legal.rst
     53 
     54 
     55 Know-Your-Customer Setup
     56 ========================
     57 
     58 To legally operate, Taler exchange operators may have to comply with KYC
     59 regulation that requires financial institutions to identify parties involved
     60 in transactions at certain points.
     61 
     62 Taler permits an exchange to require know-your-customer (KYC) or
     63 know-your-business (KYB) data under the following circumstances:
     64 
     65 * Customer withdraws money over a threshold
     66 * Wallet receives (via refunds) money resulting in a balance over a threshold
     67 * Wallet receives money via P2P payments over a threshold
     68 * Merchant receives money over a threshold
     69 * Merchant deposits digital cash over a threshold (**planned feature, bug 9040**)
     70 * Reserve is "opened" for invoicing (**planned feature**)
     71 
     72 Any of the above requests can trigger the KYC process,
     73 which can be illustrated as follows:
     74 
     75 .. image:: images/kyc-process.png
     76 
     77 At the end of the KYC process, the wallet re-tries the
     78 original request, and assuming KYC was successful, the
     79 request should then succeed.
     80 
     81 
     82 KYC Terminology
     83 ---------------
     84 
     85 * **Attributes**: Attributes are used to represent KYC data obtained about
     86   an account holder. Attributes include passport images, address data,
     87   business registration documents, and indeed arbitrary forms filed by
     88   AML staff or the customer themselves.  Attribute data is considered
     89   sensitive private information and is thus stored encrypted within the
     90   exchange database.
     91 
     92 * **Check**: A check establishes a particular attribute of a user, such as
     93   their name based on an ID document and lifeness, mailing address, phone
     94   number, taxpayer identity, etc.  Checks may be given *context* (such as
     95   whether a customer is an individual or a business) to run correctly. Checks
     96   can also be AML staff inserting information for plausibilization.  Checks
     97   result in *attributes* about the account's owner which are given to an
     98   external AML *program* together with the *context* to determine an *outcome*.
     99   KYC checks are always specified with a fallback *measure* to be taken if
    100   the check fails.
    101 
    102 * **Condition**: A condition specifies when KYC is required. Conditions
    103   include the *type of operation*, a threshold amount (e.g. above EUR:1000)
    104   and possibly a time period (e.g. over the last month).
    105 
    106 * **Configuration**: The configuration determines the *legitimization rules*,
    107   and specifies which providers offer which *checks*.
    108 
    109 * **Context**: Context is information provided as input into a *check* and
    110   *program* to customize their execution. The context is initially set by the
    111   *measure* (possibly including data from the *trigger*).  Naturally, the
    112   *program* may use its `AmlProgramInput` which includes *context* and
    113   *attribute* data to compute an update *context* for the next set of
    114   *measures* that it specifies in the `LegitimizationRuleSet` as part
    115   of the `AmlOutcome`.  Thus, *context* is something that typically
    116   evolves as the *account* undergoes *measures*.  Context is lost if
    117   an account transitions to default *legitimization rules* due to
    118   *expiration*.
    119 
    120 * **Decision**: AML decisions are these as taken by AML officers (humans). AML
    121   outcomes are the results of AML programs (code). Legitimization outcomes (DB
    122   table) can arise from either.
    123 
    124 * **Display priority**: Every rule has a *display priority*. If a second
    125   *rule* is *triggered* before the *outcome* of a *rule* could be determined,
    126   the *rule* with the larger *display priority* becomes the requirement that
    127   the account owner has to satisfy (and that thus will be displayed by the
    128   KYC SPA).
    129 
    130 * **Expiration**: Except for the default rules, any set of KYC rules is
    131   subject to *expiration*. This can be because *attributes* become outdated or
    132   because sanctions have a time limit. The expiration time thus determines
    133   when a new *measure* is triggered in the absence of a transaction crossing
    134   thresholds in the current set of *legitimization rules*.
    135 
    136 * **Legitimization rules**: The *legitimization rules* determine under which
    137   *conditions* which *measures* will be taken. A `LegitimizationRuleSet`
    138   always also includes an *expiration* time period for (custom, non-default)
    139   *legitimization rules* after which a fallback measure* will automatically
    140   apply.  Legitimization rules may be *exposed* to the client (for example,
    141   to allow a wallet to stay below hard withdraw thresholds) or could be secret.
    142 
    143 * **Logic**: Logic refers to a specific bit of code (realized as an exchange
    144   plugin) that enables the interaction with a specific *provider*.  Logic
    145   typically requires *configuration* for access control (such as an
    146   authorization token) and possibly the endpoint of the specific *provider*
    147   implementing the respective API.
    148 
    149 * **Measure**: Describes the possible outgoing edges from one state in the
    150   state machine (including how to show the current state). Each edge is given
    151   some *context* and a *check* to be performed as well as an AML *program*
    152   which determines the *outcome*.  We generally distinguish between
    153   "original" measures (defined globally in the exchange configuration) and
    154   "custom" measures (defined specifically for an account by AML staff).
    155   Additionally, only *original* measures that have a *check* of type
    156   "SKIP" and that require no inputs can be used as *FALLBACK* measures.
    157 
    158 * **Outcome**: An `AmlOutcome` describes the account state that an account
    159   ends up in due to either an AML staff action or an AML *program* doing some
    160   computation over the attributes resulting from a *check*.  Outcomes can be
    161   that certain types of transactions are "verboten", that the account is (or
    162   remains) under investigation by AML staff, that the account is given certain
    163   properties, and/or that certain events are to be logged. Outcomes also
    164   include a new set of *legitimization rules* to apply (and an *expiration*
    165   time at which point a successor *measure* will be automatically taken).
    166 
    167 * **Provider**: A provider performs a specific set of *checks* at a certain
    168   *cost*. Interaction with a provider is performed by provider-specific
    169   *logic*.
    170 
    171 * **Program**: An AML helper *program* is given *context* about the current
    172   state of an account and the attribute data from a *check* to compute the
    173   *outcome*.  For example, a *program* may look at the "PEP" field of a KYC
    174   check and decide if the outcome is to put the account into ``normal`` or
    175   ``held-for-manual-review`` state.  AML programs are always specified
    176   with a fallback *measure* to be taken if the program fails.
    177 
    178 * **Trigger**: A specific transaction that satisfies a **Condition**.
    179 
    180 * **Type of operation**: The operation type determines which Taler-specific
    181   operation has triggered the KYC requirement. We support five types of
    182   operation: withdraw (by customer), deposit (by merchant),
    183   aggregate transfer (to merchant), P2P receive (by wallet) and
    184   (high) wallet balance.
    185 
    186 
    187 Configuration of possible KYC/AML providers
    188 -------------------------------------------
    189 
    190 The KYC configuration determines the *legitimization rules*, and specifies
    191 which providers offer which *checks*.
    192 
    193 The configuration specifies a set of providers, one per configuration
    194 section. The names of the configuration sections must begin with
    195 ``kyc-proider-`` followed by an arbitrary ``$PROVIDER_ID``:
    196 
    197 .. code-block:: ini
    198   :caption: /etc/taler-exchange/conf.d/exchange-kyc-providers.conf
    199 
    200   [kyc-provider-$PROVIDER_ID]
    201 
    202   # Which plugin is responsible for this provider?
    203   # Choices include "oauth2", "kycaid" and "persona".
    204   LOGIC = oauth2
    205 
    206   # Plus additional logic-specific options, e.g.:
    207   AUTHORIZATION_TOKEN = superdupersecret
    208 
    209   # Other logic-specific internal options (example):
    210   FORM_ID = business_legi_form
    211 
    212 
    213 OAuth 2.0 specifics
    214 ^^^^^^^^^^^^^^^^^^^
    215 
    216 In terms of configuration, the OAuth 2.0 logic requires the respective client
    217 credentials to be configured apriori to enable access to the legitimization
    218 service.  The OAuth 2.0 configuration options are:
    219 
    220 .. code-block:: ini
    221   :caption: /etc/taler-exchange/conf.d/exchange-oauth2.conf
    222 
    223   [kyc-provider-example-oauth2]
    224   LOGIC = oauth2
    225   # (generic options omitted)
    226   # How long is the KYC check valid?
    227   KYC_OAUTH2_VALIDITY = forever
    228 
    229   # URL to which we redirect the user for the login process
    230   KYC_OAUTH2_AUTHORIZE_URL = "http://kyc.example.com/authorize"
    231   # URL where we POST the user's authentication information
    232   KYC_OAUTH2_TOKEN_URL = "http://kyc.example.com/token"
    233   # URL of the user info access point.
    234   KYC_OAUTH2_INFO_URL = "http://kyc.example.com/info"
    235 
    236   # Where does the client get redirected upon completion?
    237   KYC_OAUTH2_POST_URL = "http://example.com/thank-you"
    238 
    239   # For authentication to the OAuth2.0 service
    240   KYC_OAUTH2_CLIENT_ID = testcase
    241   KYC_OAUTH2_CLIENT_SECRET = password
    242 
    243   # Mustach template that converts OAuth2.0 data about the user
    244   # into GNU Taler standardized attribute data.
    245   KYC_OAUTH2_CONVERTER_HELPER = taler-exchange-kyc-oauth2-challenger.sh
    246 
    247 The converter helper is expected to be customized to the selected OAuth2.0
    248 service: different services may return different details about the user or
    249 business, hence there cannot be a universal converter for all purposes. The
    250 default shell script uses the ``jq`` tool to convert the JSON returned by the
    251 service into the KYC attributes (also in JSON) expected by the exchange.  The
    252 script will need to be adjusted based on the attributes collected by the
    253 specific backend.
    254 
    255 The converter reads the JSON returned by the info endpoint from its standard
    256 input and writes the attributes to its standard output: a JSON object with
    257 the ID of the user at the provider in ``id`` and the name of the form in
    258 ``FORM_ID`` (see `CustomerKycAttributes`).  A provider that collects several
    259 forms in one KYC process, such as Beekeeper, may instead have its converter
    260 output a non-empty array of such objects, one *attribute set* per form; only
    261 the first object needs ``id``.  The exchange then stores each set as a
    262 record of its own, all in one transaction and with the same collection
    263 time, and numbers them in the order of the array (the *form index*, from
    264 0).  The first set is the *primary* one: it becomes the current attributes
    265 of the account, which AML programs get as ``attributes``.  AML programs
    266 find the other sets in ``kyc_history``, and AML officers see each set as an
    267 entry of its own.  With age restriction, the birthday of the account's
    268 reserves is taken from the ``DATE_OF_BIRTH`` of the first set (as for a
    269 single set, which clears the birthday if it has none), and from any further
    270 set that has one.  Only the OAuth 2.0 logic accepts such an array.
    271 
    272 The Challenger service for address validation supports OAuth2.0, but does not
    273 have a static AUTHORIZE_URL. Instead, the AUTHORIZE_URL must be enabled by the client
    274 using a special authenticated request to the Challenger's ``/setup`` endpoint.
    275 The exchange supports this by appending ``#setup`` to the AUTHORIZE_URL (note
    276 that fragments are illegal in OAuth2.0 URLs).  Be careful to quote the URL,
    277 as ``#`` is otherwise interpreted as the beginning of a comment by the
    278 configuration file syntax.
    279 
    280 .. code-block:: ini
    281   :caption: /etc/taler-exchange/conf.d/exchange-challenger-oauth2.conf
    282 
    283   [kyc-provider-challenger-oauth2]
    284   LOGIC = oauth2
    285   KYC_OAUTH2_AUTHORIZE_URL = "http://challenger.example.com/authorize/#setup"
    286   KYC_OAUTH2_TOKEN_URL = "http://challenger.example.com/token"
    287   KYC_OAUTH2_INFO_URL = "http://challenger.example.com/info"
    288 
    289 When using OAuth 2.0, the *CLIENT REDIRECT URI* must be set to the
    290 ``/kyc-proof/$PROVIDER_SECTION`` endpoint. For example, given the
    291 configuration above and an exchange running on the host
    292 ``exchange.example.com``, the redirect URI would be
    293 ``https://exchange.example.com/kyc-proof/kyc-provider-challenger-oauth2/``.
    294 
    295 Using the OAuth 2.0 logic with the ``/setup`` endpoint it is possible to
    296 pass Challenger the address to validate via the **context** of the KYC check.
    297 To do so, the *address type* specific address data must be provided in a
    298 field ``initial_address`` of the **context** object.
    299 
    300 
    301 Persona specifics
    302 ^^^^^^^^^^^^^^^^^
    303 
    304 We use the hosted flow. The Persona endpoints return a ``request-id``, which
    305 we log for diagnosis.
    306 
    307 Persona should be configured to use the ``/kyc-webhook/`` endpoint of the
    308 exchange to notify the exchange about the completion of KYC processes.  The
    309 webhook is authenticated using a shared secret, which should be in the
    310 configuration.  To use the Persona webhook, you must set the webhook URL in
    311 the Persona service to ``$EXCHANGE_BASE_URL/kyc-webhook/$SECTION_NAME/`` where
    312 ``$SECTION_NAME`` is the name of the configuration section.  You should also
    313 extract the authentication token for the webhook and put it into the
    314 configuration as shown above.
    315 
    316 
    317 .. code-block:: ini
    318   :caption: /etc/taler-exchange/conf.d/exchange-persona.conf
    319 
    320   [kyclogic-persona]
    321   # Webhook authorization token. Global for all uses
    322   # of the persona provider!
    323   WEBHOOK_AUTH_TOKEN = wbhsec_698b5a19-c790-47f6-b396-deb572ec82f9
    324 
    325   [kyc-provider-example-persona]
    326   LOGIC = persona
    327   # (generic options omitted)
    328 
    329   # How long is the KYC check valid?
    330   KYC_PERSONA_VALIDITY = 365d
    331 
    332   # Which subdomain is used for our API?
    333   KYC_PERSONA_SUBDOMAIN = taler
    334 
    335   # Authentication token to use.
    336   KYC_PERSONA_AUTH_TOKEN = persona_sandbox_42XXXX
    337 
    338   # Form to use.
    339   KYC_PERSONA_TEMPLATE_ID = itempl_Uj6Xxxxx
    340 
    341   # Where do we redirect to after KYC finished successfully.
    342   KYC_PERSONA_POST_URL = "https://taler.net/kyc-done"
    343 
    344   # Salt to give to requests for idempotency.
    345   # Optional.
    346   # KYC_PERSONA_SALT = salt
    347 
    348   # Helper to convert JSON with KYC data returned by Persona into GNU Taler
    349   # internal format. Should probably always be set to some variant of
    350   # "taler-exchange-kyc-persona-converter.sh".
    351   KYC_PERSONA_CONVERTER_HELPER = "taler-exchange-kyc-persona-converter.sh"
    352 
    353 The converter helper is expected to be customized to the
    354 selected template: different templates may return different details
    355 about the user or business, hence there cannot be a universal converter
    356 for all purposes. The default shell script uses the ``jq`` tool to
    357 convert the JSON returned by Persona into the KYC attributes (also
    358 in JSON) expected by the exchange.  The script will need to be adjusted
    359 based on the attributes collected by the specific template.
    360 
    361 
    362 KYC AID specifics
    363 ^^^^^^^^^^^^^^^^^
    364 
    365 We use the hosted flow.
    366 
    367 KYCAID must be configured to use the ``/kyc-webhook/$SECTION_NAME/`` endpoint
    368 of the exchange to notify the exchange about the completion of KYC processes.
    369 
    370 .. code-block:: ini
    371   :caption: /etc/taler-exchange/conf.d/exchange-kycaid.conf
    372 
    373   [kyc-provider-example-kycaid]
    374   LOGIC = kycaid
    375   # (generic options omitted)
    376 
    377   # How long is the KYC check valid?
    378   KYC_KYCAID_VALIDITY = 365d
    379 
    380   # Authentication token to use.
    381   KYC_KYCAID_AUTH_TOKEN = XXX
    382 
    383   # Form to use.
    384   KYC_KYCAID_FORM_ID = XXX
    385 
    386   # URL to go to after the process is complete.
    387   KYC_KYCAID_POST_URL = "https://taler.net/kyc-done"
    388 
    389   # Script to convert the KYCAID data into the Taler format.
    390   KYC_KYCAID_CONVERTER_HELPER = taler-exchange-kyc-kycaid-converter.sh
    391 
    392 
    393 The converter helper is expected to be customized to the selected template:
    394 different templates may return different details about the user or business,
    395 hence there cannot be a universal converter for all purposes. The default
    396 shell script uses the ``jq`` tool to convert the JSON returned by Persona into
    397 the KYC attributes (also in JSON) expected by the exchange.  The script will
    398 need to be adjusted based on the attributes collected by the specific
    399 template.
    400 
    401 
    402 Configuration of possible KYC/AML checks
    403 ----------------------------------------
    404 
    405 The configuration specifies a set of possible KYC checks offered by external
    406 providers, one per configuration section.  The names of the configuration
    407 sections must begin with ``kyc-check-`` followed by an arbitrary
    408 ``$CHECK_NAME``.
    409 
    410 .. code-block:: ini
    411 
    412   [kyc-check-$CHECK_NAME]
    413 
    414   # Which type of check is this? Also determines
    415   # the SPA form to show to the user for this check.
    416   #
    417   # INFO: wait for staff or contact staff out-of band
    418   #          (only information shown, no SPA action)
    419   # FORM: SPA should show an inline (HTML) form
    420   # LINK: SPA may start external KYC process or upload
    421   #
    422   TYPE = INFO|LINK|FORM
    423 
    424   # Optional. Set to YES to allow this check be
    425   # done voluntarily by a client (they may then
    426   # still have to pay for it). Used to offer the
    427   # SPA to display checks even if they are
    428   # not required. Default is NO.
    429   # Since **vATTEST**.
    430   VOLUNTARY = YES/NO
    431 
    432   # Provider id, present only if type is LINK.
    433   # Refers to a ``kyc-provider-$PROVIDER_ID`` section.
    434   PROVIDER_ID = id
    435 
    436   # Name of the SPA form, if type is FORM
    437   # "INFO" and "LINK" are reserved and must not be used.
    438   # The exchange server and the SPA must agree on a list
    439   # of supported forms and the resulting attributes.
    440   #
    441   # The SPA should include a JSON resource file
    442   # "forms.json" mapping form names to arrays of
    443   # attribute names each form provides.
    444   FORM_NAME = name
    445 
    446   # Descriptions to use in the SPA to display the check.
    447   DESCRIPTION = "Upload your passport picture"
    448   DESCRIPTION_I18N = "{"en":"Upload scan of your passport"}"
    449 
    450   # ';'-separated list of fields that the CONTEXT must
    451   # provide as inputs to this check. For example,
    452   # for a FORM of type CHOICE, this might state
    453   # ``choices: string[];``. The type after the ":"
    454   # is for now purely for documentation and is
    455   # not checked. However, it may be shown to AML staff
    456   # when they configure measures.
    457   REQUIRES = requirement;
    458 
    459   # Description of the outputs provided by the check.
    460   # Basically, the check's output is expected to
    461   # provide the following fields as attribute inputs into
    462   # a subsequent AML program.
    463   # INFO never has any outputs.
    464   OUTPUTS = "business_name street city country registration"
    465 
    466   # **original** measure to take if the check fails
    467   # (for any reason, e.g. provider or form fail to
    468   # satisfy constraints or provider signals user error)
    469   # Usually should point to a measure that requests
    470   # AML staff to investigate.  The fallback measure
    471   # context always includes the reasons for the
    472   # failure.  Fallback measures MUST be *original*
    473   # measures and MUST use a check of
    474   # type "SKIP" and MUST NOT require any inputs.
    475   FALLBACK = MEASURE_NAME
    476 
    477 The list of possible FORM names is fixed in the SPA
    478 for a particular exchange release.
    479 
    480 The "check_name" value "skip" is reserved and must not be defined. It can be
    481 used in measures where the AML program must be run immediately without any
    482 input.
    483 
    484 The outcome of *any* check is stored encrypted in the ``kyc_attributes``
    485 table.  It MUST include an ``expiration_time``.  A KYC process that returned
    486 several attribute sets (see the OAuth 2.0 converter above) stores one row
    487 per set, with its position in the column ``form_index``; each set of a
    488 process is stored only once.
    489 
    490 The INFO Type
    491 ^^^^^^^^^^^^^
    492 
    493 When using KYC checks of type "INFO", the KYC-SPA
    494 will simply show the given DESCRIPTION (or translations
    495 from DESCRIPTION_I18N) to the user.
    496 
    497 
    498 The FORM Type
    499 ^^^^^^^^^^^^^
    500 
    501 When using KYC checks of type "FORM", the KYC-SPA
    502 will show different forms based on "FORM_NAME" while
    503 also showing the user the text from DESCRIPTION
    504 as instructions.
    505 
    506 Some of the forms may be further parameterized via
    507 the context in which the form is executed.
    508 
    509 .. note::
    510 
    511   For build-in forms, it should in the future not be
    512   necessary to specify the context requirements via
    513   REQUIRES as the KYC SPA should inform the exchange
    514   about the requirements of each form automatically.
    515   However, this is not yet implemented, see #9187.
    516 
    517 When forms are submitted, the exchange converts the form data into key-value
    518 pairs where the key is the form field name and the value depends on
    519 the key.  The different keys are defined in the
    520 ``gnu-taler-form-attributes`` GANA registry.
    521 The respective AML program can then evaluate the data from the form
    522 submission from ``attributes``.
    523 
    524 
    525 The LINK Type
    526 ^^^^^^^^^^^^^
    527 
    528 When using KYC checks of type "LINK", the KYC-SPA will show a link that allows
    529 the user to begin the KYC process at an external provider under the given
    530 DESCRIPTION.
    531 
    532 The external providers are expected to yield KYC attributes in the form of
    533 key-value pairs where the list of keys is defined in the GANA
    534 ``gnu-taler-kyc-attributes`` registry, which also defines the format of each
    535 attribute.  External providers may not directly yield attributes using the
    536 correct encodings, thus converter helper programs are typically used to convert
    537 external attribute data into the standardized format.
    538 
    539 
    540 Configuration of legitimization rules
    541 -------------------------------------
    542 
    543 The configuration also must specify a set of legitimization rules, one per
    544 configuration section. Each rule specifies the condition and the measure the
    545 condition triggers:
    546 
    547 .. code-block:: ini
    548 
    549   [kyc-rule-$RULE_NAME]
    550 
    551   # Operation that triggers this rule.
    552   # Must be one of AGGREGATE, BALANCE, CLOSE, DEPOSIT, MERGE,
    553   # REFUND, TRANSACTION or WITHDRAW
    554   OPERATION_TYPE = WITHDRAW
    555 
    556   # Space-separated list of next measures to be performed.
    557   # The SPA should display *all* of these measures to the user.
    558   # (They have a choice of either which ones, or in
    559   # which order they are to be performed.)
    560   # A special measure name "verboten" is used if the
    561   # specified threshold may never be crossed
    562   # (under this set of rules).
    563   NEXT_MEASURES = SWISSNESS KYB
    564 
    565   # "YES" if all NEXT_MEASURES will eventually need
    566   # to be satisfied, "NO" if the user has a choice between
    567   # them. Not actually enforced by the exchange, but
    568   # primarily used to inform the user whether this is
    569   # an "and" or "or". YES for "and".
    570   IS_AND_COMBINATOR = YES
    571 
    572   # YES if the rule (specifically, operation type,
    573   # threshold, timeframe) and the general nature of
    574   # the next measure (verboten or approval required)
    575   # should be exposed to the client.
    576   # Defaults to NO if not set.
    577   EXPOSED = YES
    578 
    579   # Threshold amount above which the rule is
    580   # triggered.  The total must be exceeded in the given
    581   # timeframe.
    582   THRESHOLD = KUDOS:100
    583 
    584   # Timeframe over which the amount to be compared to
    585   # the THRESHOLD is calculated.
    586   # Ignored for WALLET-BALANCE.  Can be 'forever'.
    587   TIMEFRAME = 30 days
    588 
    589   # Set to YES to enable the rule (default is NO)
    590   ENABLED = NO
    591 
    592 The operation types of KYC rules refer to the following scenarios:
    593 
    594 * **AGGREGATION**: Triggered when an exchange is about to do a
    595   wire transfer to a merchant. Such wire transfers typically have
    596   aggregated multiple smaller deposits, and thus enforcing KYC rules
    597   at aggregation time is more efficient than checking individual
    598   deposits. Plus, checking at the aggregation level is likely to
    599   render structuring inherently ineffective.
    600   Enforced by the exchange.
    601 
    602 * **BALANCE**: Triggered whenever the balance of a wallet is increased.
    603   Can only be used with a timeframe of zero, as this is about the absolute
    604   amount that can be stored at any time in a compliant wallet.
    605   Enforced by the wallet.
    606 
    607 * **CLOSE**: Triggered when a reserve is closed (explicitly by a wallet
    608   or implicitly by timeout). Use with caution, as this may prevent
    609   an exchange from returning funds that were not withdrawn to users.
    610   Enforced by the exchange.
    611   (Note: This rule is so far not used in production
    612   anywhere, thus likely not tested well yet.)
    613 
    614 * **DEPOSIT**: Sets a limit on the amount that can be deposited by
    615   a merchant into their bank account.  Can be used with a timeframe
    616   of zero to effectively set another transaction limit that additionally
    617   only applies to deposits (and not P2P payments), or with a non-zero
    618   timeframe to limit the amount a merchant can deposit over time.
    619   Usually used with a limit of zero to enforce merchant onboarding
    620   prior to first payment processing.  Inefficient to enforce limits
    621   later, usually for merchants that have been onboarded **AGGREGATION**
    622   limits should be set instead.
    623   Enforced by the exchange.
    624 
    625 * **MERGE**: Triggered when a user received digital cash from another
    626   wallet.
    627   Enforced by the exchange.
    628 
    629 * **REFUND**: Limit on the amount that can be refunded per
    630   transaction by a compliant merchant to a compliant wallet.
    631   Can only be used with a timeframe of zero, as this is about
    632   the amount that can be funded on an individual purchase.
    633   Enforced both wallet-side and merchant-side (enforcement by
    634   the exchange could be implemented in the future, but is
    635   tricky as the exchange sees refunds per coin and not per
    636   purchase).
    637 
    638 * **TRANSACTION**: Refers to all transactions of a wallet where digital
    639   cash is spent. Can be used with a timeframe of zero to set a transaction
    640   limit, or with a non-zero timeframe to limit the spending rate over time.
    641   Applies to spending money both in P2P and merchant transactions.
    642   Enforced by wallets and merchants.
    643 
    644 * **WITHDRAW**: Triggered when a user withdraws digital cash from their
    645   bank account.  Enforced by the exchange.
    646 
    647 
    648 Configuration of AML programs
    649 -----------------------------
    650 
    651 AML decision processes are automatically executed under certain configurable
    652 conditions.  Basically, any AML program that is run can flag an account for
    653 investigation by setting the respective flag in the `AmlOutcome`. Once this
    654 happens, the respective account will be highlighted to AML staff. The AML
    655 program can also limit the operations of the account by setting arbitrary
    656 thresholds for the various operations (including freezing the account by
    657 setting the thresholds to zero). AML staff investigating the account can then
    658 request further documentation or set new rules, including new thresholds.
    659 
    660 AML programs can base their decisions on arbitrary attributes created by the
    661 KYC check (such as the user being a politically exposed person).
    662 
    663 AML programs will be given the KYC attributes in JSON format on standard
    664 input, and must output the `AmlOutcome`. If AML programs fail (return non-zero
    665 status codes), a FALLBACK measure is automatically triggered.  FALLBACK
    666 measures MUST be *original* measures and MUST have a check of type "SKIP"
    667 and MUST NOT require any inputs.
    668 
    669 AML programs are listed in the configuration file, one program per section:
    670 
    671 .. code-block:: ini
    672 
    673   [aml-program-$PROG_NAME]
    674 
    675   # Program to run.
    676   COMMAND = taler-helper-aml-pep
    677 
    678   # Human-readable description of what this
    679   # AML helper program will do. Used to show
    680   # to the AML staff.
    681   DESCRIPTION = "check if the customer is a PEP"
    682 
    683   # True if this AML program is enabled (and thus can be
    684   # used in measures and exposed to AML staff).
    685   # Optional, default is NO.
    686   ENABLED = YES
    687 
    688   # **original** measure to take if COMMAND fails
    689   # Usually points to a measure that asks AML staff
    690   # to contact the systems administrator. The fallback measure
    691   # context always includes the reasons for the
    692   # failure.  FALLBACK measures MUST be *original*
    693   # measures with a check type of "SKIP" without any required
    694   # inputs.
    695   FALLBACK = MEASURE_NAME
    696 
    697 Implementing your own AML programs
    698 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    699 
    700 When implementing an AML program, developers must
    701 ensure to provide four main execution paths:
    702 
    703 * Generate a list of *required* context field names
    704   for the helper (introspection!) when given the "-r"
    705   command-line switch. The output should use the same
    706   syntax as the REQUIRES clause of ``[kyc-check-]``
    707   configuration sections, except that new lines
    708   MUST be used to separate fields instead of ";".
    709 * Generate a list of *required* inputs fields
    710   for the helper (introspection!) when given the "-i"
    711   command-line switch.  The input fields are named
    712   after the respective fields of the `AmlProgramInput`,
    713   thus "attributes", "aml_history", "context", "kyc_history",
    714   "default_rules" and "current_rules" are valid strings
    715   to return. Additionally, for the histories, it is
    716   possible to specify "\*_history[$NUMBER]" where
    717   "$NUMBER" is the number of entries to return, with
    718   positive numbers counting from the start of the
    719   history and negative numbers from the end of the
    720   history. Thus, "aml_history[-1]" will cause only
    721   the last AML history entry to be included.
    722 * Generate a list of *required* attribute names
    723   for the helper (introspection!) when given the "-a"
    724   command-line switch. The output should use the same
    725   list of names as the ATTRIBUTES in the
    726   ``[kyc-provider-]`` configuration section
    727   (but may also include FORM field names).
    728 * Process an input JSON object of type
    729   `AmlProgramInput` into a JSON object of
    730   type `AmlOutcome`.
    731   This is the default behavior if no command-line switches
    732   are provided.
    733 
    734 AML programs will be given the exchange's configuration filename with the "-c
    735 FILENAME" command-line option.  They may or may not use the configuration file
    736 as they see fit. AML programs should support the canonical "-h" (help) and
    737 "-v" (version) command-line options to display a help text and their version
    738 number respectively.  AML programs may be given the "-V" option to put them
    739 into verbose mode, suggesting that they should log additional information to
    740 standard error.
    741 
    742 If the AML program fails (exits with a failure code or does not provide
    743 well-formed JSON output) the AML/KYC process continues with the FALLBACK
    744 measure. This should usually be one that asks AML staff to contact the systems
    745 administrator.
    746 
    747 .. ts:def:: AmlProgramInput
    748 
    749   interface AmlProgramInput {
    750 
    751     // JSON object that was provided as
    752     // part of the *measure*.  This JSON object is
    753     // provided under "context" in the main JSON object
    754     // input to the AML program.  This "context" should
    755     // satify both the REQUIRES clause of the respective
    756     // check and the output of "-r" from the
    757     // AML program's command-line option.
    758     context?: Object;
    759 
    760     // JSON object that captures the
    761     // output of a ``[kyc-provider-]`` or (HTML) FORM.
    762     // In the case of KYC data provided by providers,
    763     // the keys in the JSON object will be the attribute
    764     // names and the values must be strings representing
    765     // the data. In the case of file uploads, the data
    766     // MUST be base64-encoded or be an external upload.
    767     // If the provider returned several attribute sets,
    768     // these are the first (primary) one; the others are
    769     // in ``kyc_history``.
    770     // Attributes are only provided if the AML program
    771     // specifies "attributes" for its input requirements.
    772     attributes?: Object;
    773 
    774     // JSON array with the results of historic
    775     // AML desisions about the account.
    776     //
    777     // AML history is only provided if the AML program
    778     // specifies "aml_history" for its input requirements.
    779     aml_history?: AmlHistoryEntry[];
    780 
    781     // JSON array with the results of historic
    782     // KYC data about the account, newest first, one entry
    783     // per attribute set.  The sets of a KYC process that
    784     // returned several are consecutive entries, in the
    785     // order the provider returned them.
    786     //
    787     // KYC history is only provided if the AML program
    788     // specifies "kyc_history" for its input requirements.
    789     kyc_history?: KycHistoryEntry[];
    790 
    791     // Default KYC rules of the exchange (exposed and not exposed).
    792     //
    793     // Default KYC rules are only provided if the AML program
    794     // specifies "default_rules" for its input requirements.
    795     default_rules?: LegitimizationRuleSet;
    796 
    797     // Current KYC rules the exchange applies for this user.
    798     // (exposed and not exposed).
    799     //
    800     // Current KYC rules are only provided if the AML program
    801     // specifies "current_rules" for its input requirements.
    802     current_rules?: LegitimizationRuleSet;
    803 
    804   }
    805 
    806 .. ts:def:: AmlHistoryEntry
    807 
    808   interface AmlHistoryEntry {
    809     // When was the AML decision taken.
    810     decision_time : Timestamp;
    811 
    812     // What was the justification given for the decision.
    813     justification : string;
    814 
    815     // Public key of the AML officer taking the decision.
    816     decider_pub : AmlOfficerPublicKeyP;
    817 
    818     // Properties associated with the account by the decision.
    819     properties : Object;
    820 
    821     // New set of legitimization rules that was put in place.
    822     new_rules : LegitimizationRuleSet;
    823 
    824     // True if the account was flagged for (further)
    825     // investigation.
    826     to_investigate : boolean;
    827 
    828     // True if this is the currently active decision.
    829     is_active : boolean;
    830   }
    831 
    832 .. ts:def:: KycHistoryEntry
    833 
    834   interface KycHistoryEntry {
    835     // Name of the provider
    836     // which was used to collect the attributes. NULL if they were
    837     // just uploaded via a form by the account owner.
    838     provider_name?: string;
    839 
    840     // True if the KYC process completed.
    841     finished: boolean;
    842 
    843     // Numeric `error code <error-codes>`, if the
    844     // KYC process did not succeed; 0 on success.
    845     code: number;
    846 
    847     // Human-readable description of ``code``. Optional.
    848     hint?: string;
    849 
    850     // Optional detail given when the KYC process failed.
    851     error_message?: string;
    852 
    853     // Identifier of the user at the KYC provider. Optional.
    854     provider_user_id?: string;
    855 
    856     // Identifier of the KYC process at the KYC provider. Optional.
    857     provider_legitimization_id? :string;
    858 
    859     // The collected KYC data.
    860     // NULL if the attribute data could not
    861     // be decrypted or was not yet collected.
    862     attributes?: Object;
    863 
    864     // Time when the KYC data was collected
    865     collection_time: Timestamp;
    866 
    867     // Time when the KYC data will expire.
    868     expiration_time: Timestamp;
    869   }
    870 
    871 .. ts:def:: AmlOutcome
    872 
    873   interface AmlOutcome {
    874 
    875     // Should the client's account be investigated
    876     // by AML staff?
    877     // Defaults to false.
    878     to_investigate?: boolean;
    879 
    880     // Free-form properties about the account.
    881     // Can be used to store properties such as PEP,
    882     // risk category, type of business, hits on
    883     // sanctions lists, etc.
    884     properties?: AccountProperties;
    885 
    886     // Types of events to add to the KYC events table.
    887     // (for statistics).
    888     events?: string[];
    889 
    890     // Space-separated list of measures to trigger
    891     // immediately on the account.
    892     // Prefixed with a "+" to indicate that the
    893     // measures should be ANDed.
    894     // Should typically be used to give the user some
    895     // information or request additional information.
    896     //
    897     // MUST NOT contain an instant measure.
    898     // AML programs may be chained directly via
    899     // exec / fork+exec, but the exchange does not
    900     // support chaining.
    901     new_measures?: string;
    902 
    903     // KYC rules to apply.  Note that this
    904     // overrides *all* of the default rules
    905     // until the ``expiration_time`` and specifies
    906     // the successor measure to apply after the
    907     // expiration time.
    908     new_rules: LegitimizationRuleSet;
    909 
    910   }
    911 
    912 If the AML program fails (exits with a failure code or
    913 does not provide well-formed JSON output) the AML/KYC
    914 process continues with the FALLBACK measure. This should
    915 usually be one that asks AML staff to contact the
    916 systems administrator.
    917 
    918 
    919 
    920 Configuration of measures
    921 -------------------------
    922 
    923 Finally, the configuration specifies a set of
    924 **original** *measures* one per configuration section:
    925 
    926 .. code-block:: ini
    927 
    928   [kyc-measure-$MEASURE_NAME]
    929 
    930   # Possible check for this measure.  Optional.
    931   # If not given (or set to "SKIP"), PROGRAM should
    932   # be run immediately (on an empty set of attributes).
    933   CHECK_NAME = IB_FORM
    934 
    935   # Context for the check. The context can be
    936   # just an empty JSON object if there is none.
    937   CONTEXT = {"choices":["individual","business"]}
    938 
    939   # Program name to run on the context and check data to
    940   # determine the outcome and next measure.
    941   # Refers to a ``[aml-program-$PROG_NAME]`` section name.
    942   PROGRAM = taler-aml-program
    943 
    944 If ``CHECK_NAME`` is set to "SKIP" (or is not provided at all), the AML
    945 ``PROGRAM`` is to be run immediately.  This is useful if no client-interaction
    946 is required to arrive at a decision.
    947 
    948 .. note::
    949 
    950   The list of *measures* in the configuration is not complete: AML staff may
    951   freely define new measures dynamically, usually by selecting checks, an AML
    952   program, and providing context.  The measures specified in the configuration
    953   are called the *original measures* and only those can be used as FALLBACK
    954   measures.
    955 
    956 
    957 
    958 AML Configuration
    959 =================
    960 
    961 The AML configuration steps are used to add or remove keys of exchange
    962 operator staff that are responsible for anti-money laundering (AML)
    963 compliance.  These AML officers are shown suspicious transactions and are
    964 granted access to the KYC data of an exchange. They can then investigate the
    965 transaction and decide on new rules for the respective user. They may request
    966 additional KYC data from the consumer, can change the thresholds up to which
    967 amounts transactions are allowed, and associate properties with the account
    968 that AML programs (and AML officers) may interpret for arbitrary future
    969 actions.
    970 
    971 
    972 AML Officer Setup
    973 -----------------
    974 
    975 To begin the AML setup, AML staff should launch the GNU Taler exchange AML SPA
    976 Web interface by going to the ``/aml-spa/`` endpoint of the exchange. This is
    977 generally a public endpoint, but of course an operator may restrict access via
    978 the reverse proxy. The SPA will generate a public-private key pair and store
    979 it in the local storage of the browser.  The public key will be displayed and
    980 **must** be securely transmitted to the offline system for approval.  Using the
    981 offline system, one can then configure which staff has access to the AML
    982 operations:
    983 
    984 .. code-block:: shell-session
    985 
    986   [root@exchange-offline]# taler-exchange-offline \
    987      aml-enable "$PUBLIC_KEY" "Legal Name" rw > aml.json
    988   [root@exchange-online]# taler-exchange-offline \
    989      upload < aml.json
    990 
    991 The above commands would add an AML officer with the given "Legal Name" with
    992 read-write (rw) access to the AML officer database.  Using "ro" instead of
    993 "rw" would grant read-only access to the data, leaving out the ability to
    994 actually make AML decisions.  Once AML access has been granted, the AML
    995 officer can use the SPA to review cases and (with "rw" access) take AML
    996 decisions.
    997 
    998 Access rights can be revoked at any time using:
    999 
   1000 .. code-block:: shell-session
   1001 
   1002   [root@exchange-offline]# taler-exchange-offline \
   1003      aml-disable $PUBLIC_KEY "Legal Name" > aml-off.json
   1004   [root@exchange-online]# taler-exchange-offline \
   1005      upload < aml-off.json
   1006 
   1007 
   1008 AML Forms
   1009 ---------
   1010 
   1011 AML forms are defined by the :ref:`dynamic forms design document <dd54dynamicforms>`.
   1012 The shipped implementation with the exchange is installed in
   1013 
   1014 .. code-block:: shell-session
   1015 
   1016   ${INSTALL_PREFIX}/share/taler-exchange/spa/forms.js
   1017 
   1018 
   1019 The variable ``form`` contains the list of all forms available. For
   1020 every entry in the list the next properties are expected to be present:
   1021 
   1022 ``label``: used in the UI as the name of the form
   1023 
   1024 ``id``: identification name, this will be saved in the exchange database
   1025 along with the values to correctly render the form again.
   1026 It should be simple, short and without any character outside numbers,
   1027 letters and underscore.
   1028 
   1029 ``version``: when editing a form, instead of just replacing fields
   1030 it will be better to create a new form with the same id and new version.
   1031 That way old forms in the database will use the old definition of the form.
   1032 It should be a number.
   1033 
   1034 ``impl`` : a function that returns the design and behavior of form.
   1035 See DD 54 dynamic forms.
   1036 
   1037 .. attention::
   1038 
   1039   do not remove a form from the list if it has been used. Otherwise you
   1040   won't be able to see the information saved in the exchange database.
   1041 
   1042 To add a new one you can simply copy and paste one element, and edit it.
   1043 
   1044 It is much easier to download ``@gnu-taler/aml-backoffice-ui`` source
   1045 from ``https://git.taler.net/wallet-core.git/``, compile and copy the file
   1046 from the ``dist/prod``.
   1047 
   1048 
   1049 .. _sanctions:
   1050 
   1051 Sanction list checking
   1052 ======================
   1053 
   1054 The **taler-exchange-sanctionlist** service can be used to automatically check
   1055 KYC records against sanction lists.  The service is not run by default but
   1056 must be explicitly enabled. It can run in incremental mode, processing
   1057 incoming KYC records immediately when new data is submitted. When a new
   1058 sanction list is released, use the "--reset" option to re-process all existing
   1059 records, checking them again against the latest list.  To only reset the
   1060 position but keep checking in the background, add "--norun". Finally, to run
   1061 the tool manually and exit immediately once all existing KYC records have been
   1062 processed (and not wait for new records to eventually be submitted from new
   1063 customers), use "--test".
   1064 
   1065 The tool operates by decrypting all of the KYC attributes from the exchange
   1066 database and passes them to a helper program which must then determine
   1067 
   1068 * which sanction list record matches best,
   1069 * how well that sanction list record matches, and
   1070 * how certain the tool is that the match is accurate.
   1071 
   1072 Based on this assessment by the helper program, **taler-exchange-sanctionlist**
   1073 will then either
   1074 
   1075 * freeze the account and flag it for investigation (likely match),
   1076 * only flag the account for investigation (possible match), or
   1077 * allow the account to continue as normal (no match)
   1078 
   1079 To avoid the same account being flagged repeatedly for investigation
   1080 due to a false-positive match with the sanction list, AML staff can
   1081 mark an account with the "SANCTION_LIST_SUPPRESS: true"
   1082 property, in which case hits on the sanction list are ignored.
   1083 
   1084 Robocop
   1085 -------
   1086 
   1087 Robocop is an implementation of a sanction list helper that can be used to
   1088 match KYC records against sanction lists. It consists of a generic matching
   1089 tool that computes the editing distance between a provided KYC record and each
   1090 sanction list entry. The sanction list entries must be provided in a file that
   1091 contains a JSON array with all sanction list entries where each entry is a
   1092 JSON object with fields matching the KYC attributes from the GANA registry,
   1093 plus a special field "ssid" that identifies the sanction list entry. Each
   1094 regular attribute field must be mapped to an array of strings where each
   1095 string is a possible spelling for values of this field, for example to allow
   1096 aliases to be given for names.
   1097 
   1098 Given such a sanction list, Robocop finds the best match for
   1099 each KYC record read from standard input (one record per line)
   1100 and outputs the match quality, confidence and the "ssid" of the
   1101 best match in the format expected by **taler-exchange-sanctionlist**.
   1102 
   1103 Robocop additionally includes Python script to convert the Swiss
   1104 sanction list (provided in XML) to its internal JSON format, and
   1105 a shell script to optimize the resulting JSON data by removing
   1106 empty fields.
   1107 
   1108 
   1109 .. _ExchangeTemplateCustomization:
   1110 
   1111 KYC Process Template Customization
   1112 ==================================
   1113 
   1114 The Exchange comes with various HTML templates that are shown to guide users
   1115 through the KYC process. The Exchange uses `C implementation of mustache
   1116 <https://gitlab.com/jobol/mustach>`__ as the templating engine.  This section
   1117 describes the various templates.  In general, the templates must be installed
   1118 to the ``share/taler-exchange/templates/`` directory. The file names must be
   1119 of the form ``$NAME.$LANG.must`` where ``$NAME`` is the name of the template
   1120 and ``$LANG`` is the 2-letter language code of the template. English templates
   1121 must exist and will be used as a fallback.  If the browser (user-agent) has
   1122 provided language preferences in the HTTP header and the respective language
   1123 exists, the correct language will be automatically served.
   1124 
   1125 The following subsections give details about each of the templates. Most
   1126 subsection titles are the ``$NAME`` of the respective template.
   1127 
   1128 
   1129 Generic Errors Templates
   1130 ------------------------
   1131 
   1132 A number of templates are used for generic errors. These are:
   1133 
   1134 * kyc-proof-already-done (KYC process already completed)
   1135 * kyc-bad-request (400 Bad Request)
   1136 * kyc-proof-endpoint-unknown (404 Not Found for KYC logic)
   1137 * kyc-proof-internal-error (500 Internal Server Error)
   1138 * kyc-proof-target-unknown (404 Not Found for KYC operation)
   1139 
   1140 All of these templates are instantiated using the following information:
   1141 
   1142 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1143   error compactly for reporting to developers
   1144 
   1145 * hint: String; human-readable Taler error code, should be shown for the
   1146   user to understand the error
   1147 
   1148 * message: String; optional, extended human-readable text provided to elaborate
   1149   on the error, should be shown to provide additional context
   1150 
   1151 
   1152 kycaid-invalid-request
   1153 ----------------------
   1154 
   1155 The KYCaid plugin does not support requests to the
   1156 ``/kyc-proof/`` endpoint (HTTP 400 bad request).
   1157 
   1158 This template is instantiated using the following information:
   1159 
   1160 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1161   error compactly for reporting to developers
   1162 
   1163 * hint: String; human-readable Taler error code, should be shown for the
   1164   user to understand the error
   1165 
   1166 * error: String; error code from the server
   1167 
   1168 * error_details: String; optional error description from the server
   1169 
   1170 * error_uri: optional URI with further details about the error from the server
   1171 
   1172 
   1173 
   1174 oauth2-authentication-failure
   1175 -----------------------------
   1176 
   1177 The OAuth2 server said that the request was not
   1178 properly authenticated (HTTP 403 Forbidden).
   1179 
   1180 
   1181 This template is instantiated using the following information:
   1182 
   1183 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1184   error compactly for reporting to developers
   1185 
   1186 * hint: String; human-readable Taler error code, should be shown for the
   1187   user to understand the error
   1188 
   1189 
   1190 oauth2-authorization-failure
   1191 ----------------------------
   1192 
   1193 The OAuth2 server refused to return the KYC data because the authorization
   1194 code provided was invalid (HTTP 403 Forbidden).
   1195 
   1196 This template is instantiated using the following information:
   1197 
   1198 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1199   error compactly for reporting to developers
   1200 
   1201 * hint: String; human-readable Taler error code, should be shown for the
   1202   user to understand the error
   1203 
   1204 * error: String; error code from the server
   1205 
   1206 * error_message: String; error message from the server
   1207 
   1208 
   1209 oauth2-authorization-failure-malformed
   1210 --------------------------------------
   1211 
   1212 The server refused the authorization, but then provided
   1213 a malformed response (HTTP 502 Bad Gateway).
   1214 
   1215 This template is instantiated using the following information:
   1216 
   1217 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1218   error compactly for reporting to developers
   1219 
   1220 * hint: string; human-readable Taler error code, should be shown for the
   1221   user to understand the error
   1222 
   1223 * debug: boolean; true if we are running in debug mode and are allowed to return HTML with potentially sensitive information
   1224 
   1225 * server_response: Object; could be NULL; this includes the (malformed) OAuth2 server response, it should be shown to the user if "debug" is true
   1226 
   1227 
   1228 oauth2-bad-request
   1229 ------------------
   1230 
   1231 The client made an invalid request (HTTP 400 Bad Request).
   1232 
   1233 This template is instantiated using the following information:
   1234 
   1235 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1236   error compactly for reporting to developers
   1237 
   1238 * hint: String; human-readable Taler error code, should be shown for the
   1239   user to understand the error
   1240 
   1241 * message: String; additional error message elaborating on what was bad about the request
   1242 
   1243 
   1244 oauth2-conversion-failure
   1245 -------------------------
   1246 
   1247 Converting the KYC data into the exchange's internal
   1248 format failed (HTTP 502 Bad Gateway).
   1249 
   1250 This template is instantiated using the following information:
   1251 
   1252 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1253   error compactly for reporting to developers
   1254 
   1255 * hint: string; human-readable Taler error code, should be shown for the
   1256   user to understand the error
   1257 
   1258 * debug: boolean; true if we are running in debug mode and are allowed to return HTML with potentially sensitive information
   1259 
   1260 * converter: String; name of the conversion command that failed which was used by the Exchange
   1261 
   1262 * attributes: Object; attributes returned by the conversion command, often NULL (after all, conversion failed)
   1263 
   1264 * message: error message elaborating on the conversion failure
   1265 
   1266 
   1267 oauth2-provider-failure
   1268 -----------------------
   1269 
   1270 We did not get an acceptable response from the OAuth2
   1271 provider (HTTP 502 Bad Gateway).
   1272 
   1273 This template is instantiated using the following information:
   1274 
   1275 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1276   error compactly for reporting to developers
   1277 
   1278 * hint: String; human-readable Taler error code, should be shown for the
   1279   user to understand the error
   1280 
   1281 * message: String; could be NULL; text elaborating on the details of the failure
   1282 
   1283 
   1284 oauth2-state-invalid
   1285 --------------------
   1286 
   1287 The ``state`` of the request to the ``/kyc-proof/`` endpoint was not the one
   1288 the exchange issued for the KYC process currently running for the account,
   1289 so the request was ignored (HTTP 403 Forbidden).
   1290 
   1291 This template is instantiated using the following information:
   1292 
   1293 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1294   error compactly for reporting to developers
   1295 
   1296 * hint: String; human-readable Taler error code, should be shown for the
   1297   user to understand the error
   1298 
   1299 * message: String; additional error message elaborating on what was wrong
   1300 
   1301 
   1302 persona-exchange-unauthorized
   1303 -----------------------------
   1304 
   1305 The Persona server refused our request (HTTP 403 Forbidden from Persona, returned as a HTTP 502 Bad Gateway).
   1306 
   1307 This template is instantiated using the following information:
   1308 
   1309 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1310   error compactly for reporting to developers
   1311 
   1312 * hint: String; human-readable Taler error code, should be shown for the
   1313   user to understand the error
   1314 
   1315 * data: Object; data returned from Persona service, optional
   1316 
   1317 * persona_http_status: Integer; HTTP status code returned by Persona
   1318 
   1319 
   1320 persona-load-failure
   1321 --------------------
   1322 
   1323 The Persona server refused our request (HTTP 429 Too Many Requests from Persona, returned as a HTTP 503 Service Unavailable).
   1324 
   1325 This template is instantiated using the following information:
   1326 
   1327 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1328   error compactly for reporting to developers
   1329 
   1330 * hint: String; human-readable Taler error code, should be shown for the
   1331   user to understand the error
   1332 
   1333 * data: Object; data returned from Persona service, optional
   1334 
   1335 * persona_http_status: Integer; HTTP status code returned by Persona
   1336 
   1337 
   1338 persona-exchange-unpaid
   1339 -----------------------
   1340 
   1341 The Persona server refused our request (HTTP 402 Payment Required from Persona, returned as a HTTP 503 Service Unavailable).
   1342 
   1343 This template is instantiated using the following information:
   1344 
   1345 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1346   error compactly for reporting to developers
   1347 
   1348 * hint: String; human-readable Taler error code, should be shown for the
   1349   user to understand the error
   1350 
   1351 * data: Object; data returned from Persona service, optional
   1352 
   1353 * persona_http_status: Integer; HTTP status code returned by Persona
   1354 
   1355 
   1356 
   1357 persona-logic-failure
   1358 ---------------------
   1359 
   1360 The Persona server refused our request (HTTP 400, 403, 409, 422 from Persona, returned as a HTTP 502 Bad Gateway).
   1361 
   1362 This template is instantiated using the following information:
   1363 
   1364 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1365   error compactly for reporting to developers
   1366 
   1367 * hint: String; human-readable Taler error code, should be shown for the
   1368   user to understand the error
   1369 
   1370 * data: Object; data returned from Persona service, optional
   1371 
   1372 * persona_http_status: Integer; HTTP status code returned by Persona
   1373 
   1374 
   1375 persona-invalid-response
   1376 ------------------------
   1377 
   1378 The Persona server refused our request in an
   1379 unexpected way; returned as a HTTP 502 Bad Gateway.
   1380 
   1381 This template is instantiated using the following information:
   1382 
   1383 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1384   error compactly for reporting to developers
   1385 
   1386 * hint: string; human-readable Taler error code, should be shown for the
   1387   user to understand the error
   1388 
   1389 * debug: boolean; true if we are running in debug mode and are allowed to return HTML with potentially sensitive information
   1390 
   1391 * server_response: Object; could be NULL; this includes the (malformed) OAuth2 server response, it should be shown to the user if "debug" is true
   1392 
   1393 
   1394 persona-network-timeout
   1395 -----------------------
   1396 
   1397 The Persona server refused our request (HTTP 408 from Persona, returned as a HTTP 504 Gateway Timeout).
   1398 
   1399 This template is instantiated using the following information:
   1400 
   1401 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1402   error compactly for reporting to developers
   1403 
   1404 * hint: String; human-readable Taler error code, should be shown for the
   1405   user to understand the error
   1406 
   1407 * data: Object; data returned from Persona service, optional
   1408 
   1409 * persona_http_status: Integer; HTTP status code returned by Persona
   1410 
   1411 
   1412 persona-kyc-failed
   1413 ------------------
   1414 
   1415 The Persona server indicated a problem with the KYC process, saying it was not completed.
   1416 
   1417 This template is instantiated using the following information:
   1418 
   1419 * persona_inquiry_id: String; internal ID of the inquiry within Persona, useful for further diagnostics by staff
   1420 
   1421 * data: Object; could be NULL; this includes the server response, it contains extensive diagnostics, see Persona documentation on their ``/api/v1/inquiries/$ID``.
   1422 
   1423 * persona_http_status: Integer; HTTP status code returned by Persona
   1424 
   1425 persona-provider-failure
   1426 ------------------------
   1427 
   1428 The Persona server refused our request (HTTP 500 from Persona, returned as a HTTP 502 Bad Gateway).
   1429 
   1430 This template is instantiated using the following information:
   1431 
   1432 * ec: Integer; numeric Taler error code, should be shown to indicate the
   1433   error compactly for reporting to developers
   1434 
   1435 * hint: String; human-readable Taler error code, should be shown for the
   1436   user to understand the error
   1437 
   1438 * data: Object; data returned from Persona service, optional
   1439 
   1440 * persona_http_status: Integer; HTTP status code returned by Persona