exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit e4e213d260733a1e557aa1a0f32880d63cef29af
parent 3f5793d9924515dfbd709c76b9286a77c3c16aa4
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 25 Feb 2025 21:33:46 +0100

add missing file

Diffstat:
Asrc/kyclogic/taler-exchange-helper-measure-tops-3rdparty-check | 145+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 145 insertions(+), 0 deletions(-)

diff --git a/src/kyclogic/taler-exchange-helper-measure-tops-3rdparty-check b/src/kyclogic/taler-exchange-helper-measure-tops-3rdparty-check @@ -0,0 +1,145 @@ +#!/bin/bash +# +# This file is part of TALER +# Copyright (C) 2025 Taler Systems SA +# +# TALER is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3, or (at your option) any later version. +# +# TALER is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/license> +# + +# Hard error reporting on. +set -eu + + +# Exit, with error message (hard failure) +function exit_fail() { + echo " FAIL: " "$@" >&2 + EXIT_STATUS=1 + exit "$EXIT_STATUS" +} + +CONF="$HOME/.config/taler-exchange.conf" +VERBOSE=0 + +while getopts 'ac:hirvV' OPTION; +do + case "$OPTION" in + a) + # Controlling entity 3rd person field is required. + echo "CONTROLLING_ENTITY_THIRD_PERSON" + exit 0 + ;; + c) + # shellcheck disable=SC2034 + CONF="$OPTARG" + ;; + h) + echo "This is a KYC measure program that determines the next VQF form to ask for (if any) based on the type of legal entity the customer claimed to be on the primary form." + echo 'Supported options:' + echo ' -a -- show required attributes' + # shellcheck disable=SC2016 + echo ' -c $CONF -- set configuration' + echo ' -h -- print this help' + echo ' -i -- show required inputs' + echo ' -r -- show required context' + echo ' -v -- show version' + echo ' -V -- be verbose' + exit 0 + ;; + i) + # Need context and current_rules. + echo "attributes" + echo "current_rules" + exit 0 + ;; + r) + # Nothing needed from context + exit 0 + ;; + v) + echo "$0 v0.0.1" + exit 0 + ;; + V) + VERBOSE=1 + ;; + ?) + exit_fail "Unrecognized command line option" + ;; + esac +done + +if [ 1 = "$VERBOSE" ] +then + echo "Running $0" 1>&2 +fi + +# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlProgramInput +# for the full JSON with possible inputs. + +# First, extract inputs we need +INPUTS=$(jq '{"current_rules":.current_rules,"attributes":.attributes}') + +# Get entity type +CONTROL3P=$(echo "$INPUTS" | jq '.attributes.CONTROLLING_ENTITY_THIRD_PERSON // null') +# Get current rules. +CURRENT_RULES=$(echo "$INPUTS" | jq '.current_rules // null') +# Get context values. +EXPIRATION_TIME=$(echo "$INPUTS" | jq '.context.expiration_time // .current_rules.expiration_time // null') + +FORM="error" + +case "$CONTROL3P" +in + "false") + FORM="none" + ;; + "true") + FORM="902.9" + ;; +esac + +# Check high-level case +case "$FORM" +in + "error") + # This should not happen, immediately trigger investigation and show error to the user. + echo "ERROR: Unexpected value for controlling entity is 3rd person '${CONTROL3P}'" 1>&2 + NEW_RULES=$(echo "$CURRENT_RULES" | jq '(.rules[] | select (.rule_name==\"kyc-rule-deposit-limit-zero\").measures=["form-info-internal-error"])') + INVESTIGATE="true" + ;; + "none") + # Immediately trigger address validation. + echo "$INPUTS" | taler-exchange-helper-measure-tops-address-check + exit $? + ;; + *) + # Proceed to FORM. + echo "Selected VQF form ${FORM}." 1&>2 + + # Force user to fill in $FORM + NEW_RULES=$(echo "$CURRENT_RULES" | jq "(.rules[] | select (.rule_name==\"kyc-rule-deposit-limit-zero\").measures=[\"form-${FORM}\"])") + INVESTIGATE="false" + ;; +esac + +# Finally, output the new rules. +# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlOutcome +# for the required output format. +jq \ + --argjson inv "$INVESTIGATE" \ + --argjson et "$EXPIRATION_TIME" \ + --argjson sm "$SUCCESSOR_MEASURE" \ + --argjson cm "$CUSTOM_MEASURES" \ + --argjson nr "$NEW_RULES" \ + '{"to_investigate":$inv,"new_rules":$nr+{"expiration_time":$et,"successor_measure":$sm,"custom_measures":($nr.custom_measures+$cm)}}|del(..|nulls)' + +exit 0