commit cf8bda5b97d46c0649a3ce2305321b8e57450a9c
parent 455e012f2fee752f057cc32d67e8ab7b869bac27
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 4 May 2025 20:28:02 +0200
add logic to clear postal address check after its completion
Diffstat:
6 files changed, 219 insertions(+), 29 deletions(-)
diff --git a/contrib/bump-taler-version.sh b/contrib/bump-taler-version.sh
@@ -0,0 +1,57 @@
+#!/usr/bin/env bash
+set -eu
+
+if [ $# != 1 ]; then
+ >&2 echo "Illegal number of arguments"
+ >&2 echo "Usage: $0 <version>"
+ exit -1
+fi
+
+VERSION="$1"
+DATE="$(date -R)"
+GIT_USER="$(git config user.name)"
+GIT_EMAIL="$(git config user.email)"
+
+function updated {
+ local FILE=$1
+ if [[ $(grep "${VERSION}" "${FILE}") ]]; then
+ echo "${FILE} already in ${VERSION}"
+ return -1
+ fi
+}
+
+# update configure.ac
+function configure_ac {
+ updated configure.ac || return 0
+
+ sed -i "/AC_INIT/s/,\\[\\(.*\\)\\],/,[${VERSION}],/" configure.ac
+ echo "configure.ac ${VERSION}"
+}
+
+# update debian/changelog
+function debian_changelog {
+ updated debian/changelog || return 0
+
+ cat <<EOF > ./debian/changelog.tmp
+taler-exchange (${VERSION}) unstable; urgency=low
+
+ * Release ${VERSION}.
+
+ -- ${GIT_USER} <${GIT_EMAIL}> ${DATE}
+
+EOF
+ cat ./debian/changelog >> ./debian/changelog.tmp
+ mv ./debian/changelog.tmp ./debian/changelog
+ echo "debian/changelog ${VERSION}"
+}
+
+function doc_doxygen_taler_doxy {
+ updated doc/doxygen/taler.doxy || return 0
+
+ sed -i "/PROJECT_NUMBER/s/= \(.*\)/= ${VERSION}/" doc/doxygen/taler.doxy
+ echo "doc/doxygen/taler.doxy ${VERSION}"
+}
+
+configure_ac
+debian_changelog
+doc_doxygen_taler_doxy
diff --git a/src/kyclogic/Makefile.am b/src/kyclogic/Makefile.am
@@ -19,6 +19,7 @@ bin_SCRIPTS = \
taler-exchange-helper-measure-challenger-email-context-check \
taler-exchange-helper-measure-challenger-postal-context-check \
taler-exchange-helper-measure-challenger-sms-context-check \
+ taler-exchange-helper-measure-clear-continue \
taler-exchange-helper-measure-defaults-but-investigate \
taler-exchange-helper-measure-freeze \
taler-exchange-helper-measure-inform-investigate \
diff --git a/src/kyclogic/taler-exchange-helper-measure-challenger-email-context-check b/src/kyclogic/taler-exchange-helper-measure-challenger-email-context-check
@@ -63,7 +63,7 @@ do
exit 0
;;
v)
- echo "$0 v0.0.0"
+ echo "$0 v0.0.1"
exit 0
;;
V)
@@ -98,16 +98,22 @@ ADDRESS=$(jq -n \
CURRENT_RULES=$(echo "$INPUTS" | jq '.current_rules // null')
# Get context values.
EXPIRATION_TIME=$(echo "$INPUTS" | jq '.context.expiration_time // .current_rules.expiration_time // null')
-# Preserve successor measure.
-SUCCESSOR_MEASURE=$(echo "$INPUTS" | jq '.current_rules.successor_measure // null')
-# Preserve successor measure.
-PROG_NAME=$(echo "$INPUTS" | jq '.context.prog_name // "inform-investigate"')
+# Get successor measure from current rules, if any (still applies if this new measure expires)
+CSUCCESSOR_MEASURE=$(echo "$INPUTS" | jq '.current_rules.successor_measure // null')
+# Context for AML program EXEC_NAME, if any.
+NEXT_CONTEXT=$(echo "$INPUTS" | jq '.context.next_context // null')
+# Get successor program from context
+EXEC_NAME=$(echo "$INPUTS" | jq '.context.exec_name // "taler-exchange-helper-measure-inform-investigate"')
-# Define custom measure for address validation
+# Define custom measure for address validation.
+# We always first run a program to clear the address validation measure,
+# and then run whatever program we were given from the context (if any).
+# If none was given in the context, we run 'inform-investigate'.
CUSTOM_AMEASURES=$(jq -n \
--argjson address "$ADDRESS" \
- --argjson prog "$PROG_NAME" \
- '{"custom-email-investigation":{"context":{"initial_address":$address},"check_name":"email-registration","prog_name":$prog}}')
+ --argjson en "$EXEC_NAME" \
+ --argjson nc "$NEXT_CONTEXT" \
+ '{"custom-email-investigation":{"context":{"initial_address":$address,"exec_name":$en,"next_context":$nc,"clear_measure":"custom-email-investigation"},"check_name":"email-registration","prog_name":"taler-exchange-helper-measure-clear-continue"}}')
# Finally, output the new rules.
# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlOutcome
@@ -115,7 +121,7 @@ CUSTOM_AMEASURES=$(jq -n \
jq -n \
--argjson et "$EXPIRATION_TIME" \
- --argjson sm "$SUCCESSOR_MEASURE" \
+ --argjson sm "$CSUCCESSOR_MEASURE" \
--argjson nm '"custom-email-investigation"' \
--argjson cma "$CUSTOM_AMEASURES" \
--argjson nr "$CURRENT_RULES" \
diff --git a/src/kyclogic/taler-exchange-helper-measure-challenger-postal-context-check b/src/kyclogic/taler-exchange-helper-measure-challenger-postal-context-check
@@ -65,7 +65,7 @@ do
exit 0
;;
v)
- echo "$0 v0.0.0"
+ echo "$0 v0.0.1"
exit 0
;;
V)
@@ -100,20 +100,26 @@ ADDRESS=$(jq -n \
--argjson address_country "$ADDRESS_COUNTRY" \
'{"CONTACT_NAME":$contact_name,"ADDRESS_LINES":$address_lines,"ADDRESS_COUNTRY":$address_country,"read_only":true}')
-# Get current rules.
+# Get current rules
CURRENT_RULES=$(echo "$INPUTS" | jq '.current_rules // null')
-# Get context values.
+# Get context values
EXPIRATION_TIME=$(echo "$INPUTS" | jq '.context.expiration_time // .current_rules.expiration_time // null')
-# Preserve successor measure.
-SUCCESSOR_MEASURE=$(echo "$INPUTS" | jq '.current_rules.successor_measure // null')
-# Preserve successor measure.
-PROG_NAME=$(echo "$INPUTS" | jq '.context.prog_name // "inform-investigate"')
+# Get successor measure from current rules, if any (still applies if this new measure expires)
+CSUCCESSOR_MEASURE=$(echo "$INPUTS" | jq '.current_rules.successor_measure // null')
+# Context for AML program EXEC_NAME, if any.
+NEXT_CONTEXT=$(echo "$INPUTS" | jq '.context.next_context // null')
+# Get successor program from context
+EXEC_NAME=$(echo "$INPUTS" | jq '.context.exec_name // "taler-exchange-helper-measure-inform-investigate"')
-# Define custom measure for address validation
+# Define custom measure for address validation.
+# We always first run a program to clear the address validation measure,
+# and then run whatever program we were given from the context (if any).
+# If none was given in the context, we run 'inform-investigate'.
CUSTOM_AMEASURES=$(jq -n \
--argjson address "$ADDRESS" \
- --argjson prog "$PROG_NAME" \
- '{"custom-address-investigation":{"context":{"initial_address":$address},"check_name":"postal-registration","prog_name":$prog}}')
+ --argjson en "$EXEC_NAME" \
+ --argjson nc "$NEXT_CONTEXT" \
+ '{"custom-address-investigation":{"context":{"initial_address":$address,"exec_name":$en,"next_context":$nc,"clear_measure":"custom-address-investigation"},"check_name":"postal-registration","prog_name":"taler-exchange-helper-measure-clear-continue"}}')
# Finally, output the new rules.
# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlOutcome
@@ -121,7 +127,7 @@ CUSTOM_AMEASURES=$(jq -n \
jq -n \
--argjson et "$EXPIRATION_TIME" \
- --argjson sm "$SUCCESSOR_MEASURE" \
+ --argjson sm "$CSUCCESSOR_MEASURE" \
--argjson nm '"custom-address-investigation"' \
--argjson cma "$CUSTOM_AMEASURES" \
--argjson nr "$CURRENT_RULES" \
diff --git a/src/kyclogic/taler-exchange-helper-measure-challenger-sms-context-check b/src/kyclogic/taler-exchange-helper-measure-challenger-sms-context-check
@@ -63,7 +63,7 @@ do
exit 0
;;
v)
- echo "$0 v0.0.0"
+ echo "$0 v0.0.1"
exit 0
;;
V)
@@ -96,18 +96,27 @@ ADDRESS=$(jq -n \
# 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')
-# Preserve successor measure.
-SUCCESSOR_MEASURE=$(echo "$INPUTS" | jq '.current_rules.successor_measure // null')
-# Preserve successor measure.
-PROG_NAME=$(echo "$INPUTS" | jq '.context.prog_name // "inform-investigate"')
-# Define custom measure for address validation
+# Get successor measure from current rules, if any (still applies if this new measure expires)
+CSUCCESSOR_MEASURE=$(echo "$INPUTS" | jq '.current_rules.successor_measure // null')
+# Context for AML program EXEC_NAME, if any.
+NEXT_CONTEXT=$(echo "$INPUTS" | jq '.context.next_context // null')
+# Get successor program from context
+EXEC_NAME=$(echo "$INPUTS" | jq '.context.exec_name // "taler-exchange-helper-measure-inform-investigate"')
+
+
+# Define custom measure for SMS/phone validation.
+# We always first run a program to clear the address validation measure,
+# and then run whatever program we were given from the context (if any).
+# If none was given in the context, we run 'inform-investigate'.
CUSTOM_AMEASURES=$(jq -n \
--argjson address "$ADDRESS" \
- --argjson prog "$PROG_NAME" \
- '{"custom-phone-investigation":{"context":{"initial_address":$address},"check_name":"sms-registration","prog_name":$prog}}')
+ --argjson en "$EXEC_NAME" \
+ --argjson nc "$NEXT_CONTEXT" \
+ '{"custom-phone-investigation":{"context":{"initial_address":$address,"exec_name":$en,"next_context":$nc,"clear_measure":"custom-phone-investigation"},"check_name":"sms-registration","prog_name":"taler-exchange-helper-measure-clear-continue"}}')
# Finally, output the new rules.
# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlOutcome
@@ -115,7 +124,7 @@ CUSTOM_AMEASURES=$(jq -n \
jq -n \
--argjson et "$EXPIRATION_TIME" \
- --argjson sm "$SUCCESSOR_MEASURE" \
+ --argjson sm "$CSUCCESSOR_MEASURE" \
--argjson nm '"custom-phone-investigation"' \
--argjson cma "$CUSTOM_AMEASURES" \
--argjson nr "$CURRENT_RULES" \
diff --git a/src/kyclogic/taler-exchange-helper-measure-clear-continue b/src/kyclogic/taler-exchange-helper-measure-clear-continue
@@ -0,0 +1,111 @@
+#!/bin/bash
+#
+# This file is part of TALER
+# Copyright (C) 2024, 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)
+ exit 0
+ ;;
+ c)
+ # shellcheck disable=SC2034
+ CONF="$OPTARG"
+ ;;
+ h)
+ echo "This is a KYC measure program that clears a measure from the rule set and continues with another AML program, all controlled via the context."
+ 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 "context"
+ echo "current_rules"
+ exit 0
+ ;;
+ r)
+ # Context for AML program to run next
+ echo "next_context"
+ # Binary name of AML program to run next
+ echo "exec_name"
+ # Which measure to clear?
+ echo "clear_measure"
+ exit 0
+ ;;
+ v)
+ echo "$0 v0.0.0"
+ 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,"context":.context}')
+
+# Get current rules.
+CURRENT_RULES=$(echo "$INPUTS" | jq '.current_rules // null')
+# Get context values.
+NEXT_CONTEXT=$(echo "$INPUTS" | jq '.context.next_context')
+EXEC_NAME=$(echo "$INPUTS" | jq '.context.exec_name')
+CLEAR_MEASURE=$(echo "$INPUTS" | jq '.context.clear_measure // null')
+
+# Remove matching measure from current rules.
+NEW_RULES=$(echo "$CURRENT_RULES" | jq '(.rules[] |= if (.measures[0]=="'"${CLEAR_MEASURE}"'") then del(.) else . end)')
+
+echo "Passing new rules ${NEW_RULES} to ${EXEC_NAME}." 1>&2
+
+# Finally, pass the new rules as input to the AML program '$EXEC_NAME'.
+jq -n \
+ --argjson nc "$NEXT_CONTEXT" \
+ --argjson nr "$NEW_RULES" \
+ '{"current_rules":$nr,"context":$nc}' \
+ | exec "${EXEC_NAME}"