aboutsummaryrefslogtreecommitdiff
path: root/src/kyclogic
diff options
context:
space:
mode:
Diffstat (limited to 'src/kyclogic')
-rw-r--r--src/kyclogic/Makefile.am4
-rw-r--r--src/kyclogic/taler-exchange-helper-measure-defaults-but-investigate94
-rwxr-xr-xsrc/kyclogic/taler-exchange-helper-measure-freeze11
-rwxr-xr-xsrc/kyclogic/taler-exchange-helper-measure-none78
-rw-r--r--src/kyclogic/taler-exchange-helper-measure-preserve-but-investigate94
-rw-r--r--src/kyclogic/taler-exchange-helper-measure-preserve-set-expiration106
-rwxr-xr-xsrc/kyclogic/taler-exchange-helper-measure-test-form2
-rwxr-xr-xsrc/kyclogic/taler-exchange-helper-measure-test-oauth10
-rw-r--r--src/kyclogic/taler-exchange-helper-measure-update-from-context112
9 files changed, 469 insertions, 42 deletions
diff --git a/src/kyclogic/Makefile.am b/src/kyclogic/Makefile.am
index 89f15c8bc..626051e65 100644
--- a/src/kyclogic/Makefile.am
+++ b/src/kyclogic/Makefile.am
@@ -20,6 +20,10 @@ bin_SCRIPTS = \
taler-exchange-helper-measure-test-oauth \
taler-exchange-helper-measure-none \
taler-exchange-helper-measure-freeze \
+ taler-exchange-helper-measure-defaults-but-investigate \
+ taler-exchange-helper-measure-preserve-but-investigate \
+ taler-exchange-helper-measure-preserve-set-expiration \
+ taler-exchange-helper-measure-update-from-context \
taler-exchange-kyc-kycaid-converter.sh \
taler-exchange-kyc-persona-converter.sh \
taler-exchange-kyc-oauth2-test-converter.sh \
diff --git a/src/kyclogic/taler-exchange-helper-measure-defaults-but-investigate b/src/kyclogic/taler-exchange-helper-measure-defaults-but-investigate
new file mode 100644
index 000000000..5f9138795
--- /dev/null
+++ b/src/kyclogic/taler-exchange-helper-measure-defaults-but-investigate
@@ -0,0 +1,94 @@
+#!/bin/bash
+#
+# This file is part of TALER
+# Copyright (C) 2024 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)
+ # No attributes are required.
+ exit 0
+ ;;
+ c)
+ # shellcheck disable=SC2034
+ CONF="$OPTARG"
+ ;;
+ h)
+ echo "This is a KYC measure program that applies default rules to an account, but flags it for manual investigation."
+ 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'
+ ;;
+ i)
+ # Need default rules.
+ echo "default_rules"
+ exit 0
+ ;;
+ r)
+ # No context is required.
+ 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
+DEFAULT_RULES=$(jq '.default_rules')
+
+# Finally, output the new rules.
+# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlOutcome
+# for the required output format.
+
+echo "$DEFAULT_RULES" \
+ | jq '.+{"to_investigate": true}'
diff --git a/src/kyclogic/taler-exchange-helper-measure-freeze b/src/kyclogic/taler-exchange-helper-measure-freeze
index 4609493cd..b81334b71 100755
--- a/src/kyclogic/taler-exchange-helper-measure-freeze
+++ b/src/kyclogic/taler-exchange-helper-measure-freeze
@@ -30,7 +30,7 @@ function exit_fail() {
CONF="$HOME/.config/taler-exchange.conf"
VERBOSE=0
-while getopts 'ac:hrvV' OPTION;
+while getopts 'ac:hirvV' OPTION;
do
case "$OPTION" in
a)
@@ -48,10 +48,15 @@ do
# 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'
;;
+ i)
+ # No inputs are required
+ exit 0
+ ;;
r)
# No context is required.
exit 0
@@ -75,14 +80,14 @@ then
fi
-# See https://docs.taler.net/taler-exchange-manual.html#tsref-type-AmlProgramInput
+# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlProgramInput
# for the full JSON with possible inputs.
# New rules apply for 30 days.
EXPIRATION=$((3600 * 30 + $(date +%s)))
# Finally, output the new rules.
-# See https://docs.taler.net/taler-exchange-manual.html#tsref-type-AmlOutcome
+# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlOutcome
# for the required output format.
jq -n \
diff --git a/src/kyclogic/taler-exchange-helper-measure-none b/src/kyclogic/taler-exchange-helper-measure-none
index 16f4d3dc0..ebea68bb4 100755
--- a/src/kyclogic/taler-exchange-helper-measure-none
+++ b/src/kyclogic/taler-exchange-helper-measure-none
@@ -32,42 +32,48 @@ function exit_fail() {
CONF="$HOME/.config/taler-exchange.conf"
VERBOSE=0
-while getopts 'ac:hrvV' OPTION; do
- case "$OPTION" in
- a)
- # No attributes are required.
- exit 0
- ;;
- c)
- # shellcheck disable=SC2034
- CONF="$OPTARG"
- ;;
- h)
- echo "This is a KYC measure program that freezes the account and flags it for manual investigation. This is the ultimate fallback measure."
- echo 'Supported options:'
- echo ' -a -- show required attributes'
- # shellcheck disable=SC2016
- echo ' -c $CONF -- set configuration'
- echo ' -h -- print this help'
- echo ' -r -- show required context'
- echo ' -v -- show version'
- echo ' -V -- be verbose'
- ;;
- r)
- # No context is required.
- exit 0
- ;;
- v)
- echo "$0 v0.0.0"
- exit 0
- ;;
- V)
- VERBOSE=1
- ;;
- ?)
- exit_fail "Unrecognized command line option"
- ;;
- esac
+while getopts 'ac:hirvV' OPTION;
+do
+ case "$OPTION" in
+ a)
+ # No attributes are required.
+ exit 0
+ ;;
+ c)
+ # shellcheck disable=SC2034
+ CONF="$OPTARG"
+ ;;
+ h)
+ echo "This is a KYC measure program that freezes the account and flags it for manual investigation. This is the ultimate fallback measure."
+ 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'
+ ;;
+ i)
+ # No inputs are required
+ exit 0
+ ;;
+ r)
+ # No context is required.
+ 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
diff --git a/src/kyclogic/taler-exchange-helper-measure-preserve-but-investigate b/src/kyclogic/taler-exchange-helper-measure-preserve-but-investigate
new file mode 100644
index 000000000..901337cd7
--- /dev/null
+++ b/src/kyclogic/taler-exchange-helper-measure-preserve-but-investigate
@@ -0,0 +1,94 @@
+#!/bin/bash
+#
+# This file is part of TALER
+# Copyright (C) 2024 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)
+ # No attributes are required.
+ exit 0
+ ;;
+ c)
+ # shellcheck disable=SC2034
+ CONF="$OPTARG"
+ ;;
+ h)
+ echo "This is a KYC measure program that preserves the current rules of an account, but flags it for manual investigation."
+ 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'
+ ;;
+ i)
+ # Need current rules.
+ echo "current_rules"
+ exit 0
+ ;;
+ r)
+ # No context is required.
+ 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
+CURRENT_RULES=$(jq '.current_rules')
+
+# Finally, output the new rules.
+# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlOutcome
+# for the required output format.
+
+echo "$CURRENT_RULES" \
+ | jq '.+{"to_investigate": true}'
diff --git a/src/kyclogic/taler-exchange-helper-measure-preserve-set-expiration b/src/kyclogic/taler-exchange-helper-measure-preserve-set-expiration
new file mode 100644
index 000000000..ba09d5489
--- /dev/null
+++ b/src/kyclogic/taler-exchange-helper-measure-preserve-set-expiration
@@ -0,0 +1,106 @@
+#!/bin/bash
+#
+# This file is part of TALER
+# Copyright (C) 2024 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)
+ # No attributes are required.
+ exit 0
+ ;;
+ c)
+ # shellcheck disable=SC2034
+ CONF="$OPTARG"
+ ;;
+ h)
+ echo "This is a KYC measure program that preserves the current rules of an account, but sets expiration rules based on 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'
+ ;;
+ i)
+ # Need context and current_rules.
+ echo "context"
+ echo "current_rules"
+ exit 0
+ ;;
+ r)
+ # Need expiration time and successor measure.
+ echo "expiration_time"
+ echo "successor_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,"context":.context}')
+
+# Get context values.
+EXPIRATION_TIME=$(echo "$INPUTS" | jq '.context.expiration_time // null')
+SUCCESSOR_MEASURE=$(echo "$INPUTS" | jq '.context.successor_measure // null')
+
+# Finally, output the new rules.
+# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlOutcome
+# for the required output format.
+
+echo "$INPUTS" \
+ | jq \
+ --jsonarg et "$EXPIRATION_TIME" \
+ --jsonarg sm "$SUCCESSOR_MEASURE" \
+ '.current_rules+{"new_rules":(.new_rules+{"expiration_time":$et,"successor_measure":$sm})}|del(..|nulls)'
+
+exit 0
diff --git a/src/kyclogic/taler-exchange-helper-measure-test-form b/src/kyclogic/taler-exchange-helper-measure-test-form
index 72f72258d..ab418ca2e 100755
--- a/src/kyclogic/taler-exchange-helper-measure-test-form
+++ b/src/kyclogic/taler-exchange-helper-measure-test-form
@@ -96,7 +96,7 @@ echo "$J" >> /dev/null
EXPIRATION=$((3600 * 30 + $(date +%s)))
# Read currency from the config
-CURRENCY=$(taler-config -c $CONF -s taler -o currency)
+CURRENCY=$(taler-exchange-config -c "$CONF" -s exchange -o currency)
# Finally, output the new rules.
# See https://docs.taler.net/taler-exchange-manual.html#tsref-type-AmlOutcome
diff --git a/src/kyclogic/taler-exchange-helper-measure-test-oauth b/src/kyclogic/taler-exchange-helper-measure-test-oauth
index 4c833d6e2..92835e36f 100755
--- a/src/kyclogic/taler-exchange-helper-measure-test-oauth
+++ b/src/kyclogic/taler-exchange-helper-measure-test-oauth
@@ -28,7 +28,7 @@ function exit_fail() {
CONF="$HOME/.config/taler-exchange.conf"
VERBOSE=0
-while getopts 'ac:hrvV' OPTION;
+while getopts 'ac:hirvV' OPTION;
do
case "$OPTION" in
a)
@@ -49,10 +49,16 @@ do
# 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'
;;
+ i)
+ # Only attribute inputs are required
+ echo "attributes"
+ exit 0
+ ;;
r)
# No context is required.
exit 0
@@ -88,7 +94,7 @@ J=$(echo "$A" | jq -r 'def get($k):
# Here we could use those values...
echo "$J" >> /dev/null
-# See https://docs.taler.net/taler-exchange-manual.html#tsref-type-AmlProgramInput
+# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlProgramInput
# for the full JSON with possible inputs.
# New rules apply for 30 days.
diff --git a/src/kyclogic/taler-exchange-helper-measure-update-from-context b/src/kyclogic/taler-exchange-helper-measure-update-from-context
new file mode 100644
index 000000000..bdd7ecfcf
--- /dev/null
+++ b/src/kyclogic/taler-exchange-helper-measure-update-from-context
@@ -0,0 +1,112 @@
+#!/bin/bash
+#
+# This file is part of TALER
+# Copyright (C) 2024 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)
+ # No attributes are required.
+ exit 0
+ ;;
+ c)
+ # shellcheck disable=SC2034
+ CONF="$OPTARG"
+ ;;
+ h)
+ echo "This is a KYC measure program that updates the current rules of an account based on values given in 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'
+ ;;
+ i)
+ # Need context and current_rules.
+ echo "context"
+ echo "current_rules"
+ exit 0
+ ;;
+ r)
+ # Need new_rules, custom_measures, expiration time and successor measure.
+ echo "new_rules"
+ echo "custom_measures"
+ echo "expiration_time"
+ echo "successor_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 '{"context":.context,"current_rules":.current_rules}')
+
+# Get context values.
+EXPIRATION_TIME=$(echo "$INPUTS" | jq '.context.expiration_time // .current_rules.expiration_time // null')
+SUCCESSOR_MEASURE=$(echo "$INPUTS" | jq '.context.successor_measure // .current_rules.successor_measure // null')
+CUSTOM_MEASURES=$(echo "$INPUTS" | jq '.context.custom_measures // null')
+NEW_RULES=$(echo "$INPUTS" | jq '.context.new_rules // null')
+
+# Finally, output the new rules.
+# See https://docs.taler.net/taler-kyc-manual.html#tsref-type-AmlOutcome
+# for the required output format.
+
+echo "$INPUTS" \
+ | jq \
+ --jsonarg et "$EXPIRATION_TIME" \
+ --jsonarg sm "$SUCCESSOR_MEASURE" \
+ --jsonarg cm "$CUSTOM_MEASURES" \
+ --jsonarg nr "$NEW_RULES" \
+ '.current_rules+{"new_rules":(.current_rules.new_rules+{"expiration_time":$et,"successor_measure":$sm,"rules":(.current_rules.new_rules.rules+$nr),"custom_measures":(.current_rules.custom_measures+$cm)})}|del(..|nulls)'
+
+exit 0