commit 0dc422e0dfe70dac15b5923b264a71eb93de26cc
parent 6e9a98b056705a7bc31321af085f92ae022a2516
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 30 Mar 2025 15:15:49 +0200
fix issues with challenger send script
Diffstat:
2 files changed, 9 insertions(+), 85 deletions(-)
diff --git a/src/challenger/challenger-send-post.sh b/src/challenger/challenger-send-post.sh
@@ -8,36 +8,13 @@ set -eu
# ORG_ID=
# . pingen-secrets
-ENDPOINT="https://api.v2.pingen.com"
+ENDPOINT="https://api.pingen.com"
LOGS="$PWD/authorization-post.log"
MESSAGE=$(cat -)
-DATE=$(date +%F)
ADDR="$1"
NAME=$(echo "$ADDR" | jq -r .full_name)
STREET=$(echo "$ADDR" | jq -r .street)
-
-LNUMBER=$(echo $STREET | awk '{print $NF}')
-FNUMBER=$(echo $STREET | awk '{print $1}')
-case "$LNUMBER"
-in
- ''|*[!0-9]*)
- case "$FNUMBER"
- in
- ''|*[!0-9]*)
- NUMBER=0
- ;;
- *)
- NUMBER="$FNUMBER"
- ;;
- esac
- ;;
- *)
- NUMBER="$LNUMBER"
- ;;
-esac
-
-
CITY=$(echo "$ADDR" | jq -r .city)
POSTCODE=$(echo "$ADDR" | jq -r .postcode)
COUNTRY=$(echo "$ADDR" | jq -r .country)
@@ -48,25 +25,26 @@ cat - | sed -e "s/%NAME%/$NAME/g" \
-e "s/%STREET%/$STREET/g" \
-e "s/%POSTCODE%/$POSTCODE/g" \
-e "s/%CITY%/$CITY/g" \
- -e "s/%COUNTRY%/$COUNTRY/g" \
- -e "s/%MESSAGE%/$MESSAGE/g" > input.tex <<EOF
+ -e "s/%COUNTRY%/$COUNTRY/g" > input.tex <<EOF
\NeedsTeXFormat{LaTeX2e}
\documentclass[fontsize=11pt,a4paper]{scrlttr2}
\makeatletter
\KOMAoptions{foldmarks=off}
\makeatother
\setkomavar{subject}{Address validation}
-\setkomavar{signature}{Taler Systems SA}
+\setkomavar{signature}{Taler Operations AG, c/o Berner Fachhochschule, H\"oheweg 80, 2502 Biel/Bienne}
\date{\today}
\begin{document}
\begin{letter}{\ \ %NAME% \\\\ \ \ %STREET% \\\\ \ \ %POSTCODE% %CITY% \\\\ \ \ %COUNTRY% }
\opening{To whom it may concern,}
-%MESSAGE%
+EOF
+echo "$MESSAGE" >> input.tex
+cat - >> input.tex <<EOF
\closing{Best regards}
\end{letter}
\end{document}
EOF
-pdflatex input.tex > /dev/null 2> /dev/null
+pdflatex input.tex > "$MYDIR/pdflatex.out" 2> "$MYDIR/pdflatex.err"
REPLY=$(curl \
-s \
@@ -78,7 +56,7 @@ REPLY=$(curl \
--data-urlencode "scope=letter" \
https://identity.pingen.com/auth/access-tokens)
-ACCESS_TOKEN=$(echo $REPLY | jq -r .access_token)
+ACCESS_TOKEN=$(echo "$REPLY" | jq -r .access_token)
REPLY=$(curl -s \
-X GET "$ENDPOINT/file-upload" \
@@ -92,35 +70,6 @@ curl -s \
-T input.pdf \
"$UPLOAD_URL"
-
-RECIPIENT="$(jq -n '
- {
- name: $NAME,
- street: $STREET,
- number: $NUMBER,
- city: $CITY,
- zip: $POSTCODE,
- country: $COUNTRY,
- }' \
- --arg NAME "$NAME" \
- --arg STREET "$STREET" \
- --arg NUMBER "$NUMBER" \
- --arg CITY "$CITY" \
- --arg POSTCODE "$POSTCODE" \
- --arg COUNTRY "$COUNTRY" \
- )"
-
-SENDER="$(jq -n '
- {
- name: "Taler Systems SA",
- street: "Rue de Mondorf",
- number: "7",
- zip: "5421",
- city: "Erpeldange",
- country: "LU"
- }'
- )"
-
REQUEST="$(jq -n '
{ data: {
type: "letters",
@@ -135,8 +84,6 @@ REQUEST="$(jq -n '
print_spectrum: "grayscale"
} }
}' \
- --argjson RECIPIENT "$RECIPIENT" \
- --argjson SENDER "$SENDER" \
--arg UPLOAD_URL "$UPLOAD_URL" \
--arg URL_SIG "$URL_SIG" \
)"
@@ -159,30 +106,6 @@ case "$STATUS" in
exit 1;
;;
esac
-LETTER_ID=$(cat $MYDIR/final-reply.txt | jq -r .data.id)
-REPLY="$MYDIR/delete-reply.txt"
-STATUS=409
-sleep 1;
-while test "$STATUS" = 409;
-do
- STATUS=$(curl -s --request DELETE \
- --url "$ENDPOINT/organisations/$ORG_ID/letters/$LETTER_ID" \
- --header "Authorization: Bearer $ACCESS_TOKEN" \
- -o "$REPLY" \
- -w "%{http_code}" -s)
- case "$STATUS" in
- 204)
- cat "$REPLY" >> "$LOGS"
- ;;
- 409)
- # Happens, likely still in processing...
- ;;
- *)
- echo "Failed to delete letter: $STATUS" >> "$LOGS"
- ;;
- esac
-done
rm -r "$MYDIR"
-
exit 0
diff --git a/src/challenger/default-challenge-message.txt b/src/challenger/default-challenge-message.txt
@@ -0,0 +1 @@
+Please enter the PIN {{pin}} at {{challenger_url}} to verify your address.