commit 06236f0d6a92fb11191c061277dfb604873a70ff parent 3b96a9805a59c33681484baeb5f8793362dd1669 Author: Florian Dold <florian@dold.me> Date: Mon, 6 Jul 2026 17:14:51 +0200 remove scripts, packaged separately in taler-challenger-helpers.git Diffstat:
| D | src/challenger/challenger-send-email | | | 4 | ---- |
| D | src/challenger/challenger-send-post | | | 908 | ------------------------------------------------------------------------------- |
| D | src/challenger/challenger-send-sms | | | 33 | --------------------------------- |
| D | src/challenger/challenger-send-sms-aspsms | | | 301 | ------------------------------------------------------------------------------- |
| D | src/challenger/challenger-send-sms-clicksend | | | 142 | ------------------------------------------------------------------------------- |
| D | src/challenger/challenger-send-sms-telesign | | | 160 | ------------------------------------------------------------------------------- |
| M | src/challenger/meson.build | | | 19 | ------------------- |
7 files changed, 0 insertions(+), 1567 deletions(-)
diff --git a/src/challenger/challenger-send-email b/src/challenger/challenger-send-email @@ -1,4 +0,0 @@ -#!/bin/sh -# This file is in the public domain. -EMAIL=$(echo "$1" | jq -r .CONTACT_EMAIL) -exec mail -s "KYC Challenger" -r noreply "$EMAIL" diff --git a/src/challenger/challenger-send-post b/src/challenger/challenger-send-post @@ -1,908 +0,0 @@ -#!/bin/bash -# This file is in the public domain. -set -eux - -# You need to provide these (set in environment). -# PINGEN_CLIENT_ID= -# PINGEN_CLIENT_SECRET= -# PINGEN_ORG_ID= -if [ -x "$PINGEN_CLIENT_ID" ] -then - echo "PINGEN_CLIENT_ID not sent in environment" - exit 1 -fi -if [ -x "$PINGEN_CLIENT_SECRET" ] -then - echo "PINGEN_CLIENT_SECRET not sent in environment" - exit 1 -fi -if [ -x "$PINGEN_ORG_ID" ] -then - echo "PINGEN_ORG_ID not sent in environment" - exit 1 -fi - -ENDPOINT="https://api.pingen.com" -LOGS="$HOME/authorization-post.log" -ERRORS="$HOME/authorization-post.err" - -MESSAGE=$(cat -) -ADDR="$1" -# We'll use "tr" to filter out anything that could be a problem in LaTeX. -# Name of business or individual, possibly with "Attn. $INDIVIDUAL_NAME" -CONTACT_NAME=$(echo "$ADDR" | jq -r .CONTACT_NAME | tr '|`~!"<>[]%_^#$&@\\{}' . ) -# Multi-line address -ADDRESS_LINES=$(echo "$ADDR" | jq -r .ADDRESS_LINES) -# This will just be the 2-letter country code -ADDRESS_COUNTRY=$(echo "$ADDR" | jq -r .ADDRESS_COUNTRY | tr '|`~!"<>[]%_^#$&@\\{}' . ) - -case "$ADDRESS_COUNTRY" -in - AF) - COUNTRY='Afghanistan' - ;; - AX) - COUNTRY='Åland Islands' - ;; - AL) - COUNTRY='Albania' - ;; - DZ) - COUNTRY='Algeria' - ;; - AS) - COUNTRY='American Samoa' - ;; - AD) - COUNTRY='Andorra' - ;; - AO) - COUNTRY='Angola' - ;; - AI) - COUNTRY='Anguilla' - ;; - AQ) - COUNTRY='Antarctica' - ;; - AG) - COUNTRY='Antigua \\\& Barbuda' - ;; - AR) - COUNTRY='Argentina' - ;; - AM) - COUNTRY='Armenia' - ;; - AW) - COUNTRY='Aruba' - ;; - AU) - COUNTRY='Australia' - ;; - AT) - COUNTRY='Austria' - ;; - AZ) - COUNTRY='Azerbaijan' - ;; - BS) - COUNTRY='Bahamas' - ;; - BH) - COUNTRY='Bahrain' - ;; - BD) - COUNTRY='Bangladesh' - ;; - BB) - COUNTRY='Barbados' - ;; - BY) - COUNTRY='Belarus' - ;; - BE) - COUNTRY='Belgium' - ;; - BZ) - COUNTRY='Belize' - ;; - BJ) - COUNTRY='Benin' - ;; - BM) - COUNTRY='Bermuda' - ;; - BT) - COUNTRY='Bhutan' - ;; - BO) - COUNTRY='Bolivia' - ;; - BA) - COUNTRY='Bosnia \\\& Herzegovina' - ;; - BW) - COUNTRY='Botswana' - ;; - BV) - COUNTRY='Bouvet Island' - ;; - BR) - COUNTRY='Brazil' - ;; - IO) - COUNTRY='British Indian Ocean Territory' - ;; - VG) - COUNTRY='British Virgin Islands' - ;; - BN) - COUNTRY='Brunei' - ;; - BG) - COUNTRY='Bulgaria' - ;; - BF) - COUNTRY='Burkina Faso' - ;; - BI) - COUNTRY='Burundi' - ;; - KH) - COUNTRY='Cambodia' - ;; - CM) - COUNTRY='Cameroon' - ;; - CA) - COUNTRY='Canada' - ;; - CV) - COUNTRY='Cape Verde' - ;; - BQ) - COUNTRY='Caribbean Netherlands' - ;; - KY) - COUNTRY='Cayman Islands' - ;; - CF) - COUNTRY='Central African Republic' - ;; - TD) - COUNTRY='Chad' - ;; - CL) - COUNTRY='Chile' - ;; - CN) - COUNTRY='China' - ;; - CX) - COUNTRY='Christmas Island' - ;; - CC) - COUNTRY='Cocos' - ;; - CO) - COUNTRY='Colombia' - ;; - KM) - COUNTRY='Comoros' - ;; - CG) - COUNTRY='Congo - Brazzaville' - ;; - CD) - COUNTRY='Congo - Kinshasa' - ;; - CK) - COUNTRY='Cook Islands' - ;; - CR) - COUNTRY='Costa Rica' - ;; - CI) -#shellcheck disable=SC1112 - COUNTRY='Côte d’Ivoire' - ;; - HR) - COUNTRY='Croatia' - ;; - CU) - COUNTRY='Cuba' - ;; - CW) - COUNTRY='Curaçao' - ;; - CY) - COUNTRY='Cyprus' - ;; - CZ) - COUNTRY='Czechia' - ;; - DK) - COUNTRY='Denmark' - ;; - DJ) - COUNTRY='Djibouti' - ;; - DM) - COUNTRY='Dominica' - ;; - DO) - COUNTRY='Dominican Republic' - ;; - EC) - COUNTRY='Ecuador' - ;; - EG) - COUNTRY='Egypt' - ;; - SV) - COUNTRY='El Salvador' - ;; - GQ) - COUNTRY='Equatorial Guinea' - ;; - ER) - COUNTRY='Eritrea' - ;; - EE) - COUNTRY='Estonia' - ;; - SZ) - COUNTRY='Eswatini' - ;; - ET) - COUNTRY='Ethiopia' - ;; - FK) - COUNTRY='Falkland Islands' - ;; - FO) - COUNTRY='Faroe Islands' - ;; - FJ) - COUNTRY='Fiji' - ;; - FI) - COUNTRY='Finland' - ;; - FR) - COUNTRY='France' - ;; - GF) - COUNTRY='French Guiana' - ;; - PF) - COUNTRY='French Polynesia' - ;; - TF) - COUNTRY='French Southern Territories' - ;; - GA) - COUNTRY='Gabon' - ;; - GM) - COUNTRY='Gambia' - ;; - GE) - COUNTRY='Georgia' - ;; - DE) - COUNTRY='Germany' - ;; - GH) - COUNTRY='Ghana' - ;; - GI) - COUNTRY='Gibraltar' - ;; - GR) - COUNTRY='Greece' - ;; - GL) - COUNTRY='Greenland' - ;; - GD) - COUNTRY='Grenada' - ;; - GP) - COUNTRY='Guadeloupe' - ;; - GU) - COUNTRY='Guam' - ;; - GT) - COUNTRY='Guatemala' - ;; - GG) - COUNTRY='Guernsey' - ;; - GN) - COUNTRY='Guinea' - ;; - GW) - COUNTRY='Guinea-Bissau' - ;; - GY) - COUNTRY='Guyana' - ;; - HT) - COUNTRY='Haiti' - ;; - HM) - COUNTRY='Heard \\\& McDonald Islands' - ;; - HN) - COUNTRY='Honduras' - ;; - HK) - COUNTRY='Hong Kong SAR China' - ;; - HU) - COUNTRY='Hungary' - ;; - IS) - COUNTRY='Iceland' - ;; - IN) - COUNTRY='India' - ;; - ID) - COUNTRY='Indonesia' - ;; - IR) - COUNTRY='Iran' - ;; - IQ) - COUNTRY='Iraq' - ;; - IE) - COUNTRY='Ireland' - ;; - IM) - COUNTRY='Isle of Man' - ;; - IL) - COUNTRY='Israel' - ;; - IT) - COUNTRY='Italy' - ;; - JM) - COUNTRY='Jamaica' - ;; - JP) - COUNTRY='Japan' - ;; - JE) - COUNTRY='Jersey' - ;; - JO) - COUNTRY='Jordan' - ;; - KZ) - COUNTRY='Kazakhstan' - ;; - KE) - COUNTRY='Kenya' - ;; - KI) - COUNTRY='Kiribati' - ;; - KW) - COUNTRY='Kuwait' - ;; - KG) - COUNTRY='Kyrgyzstan' - ;; - LA) - COUNTRY='Laos' - ;; - LV) - COUNTRY='Latvia' - ;; - LB) - COUNTRY='Lebanon' - ;; - LS) - COUNTRY='Lesotho' - ;; - LR) - COUNTRY='Liberia' - ;; - LY) - COUNTRY='Libya' - ;; - LI) - COUNTRY='Liechtenstein' - ;; - LT) - COUNTRY='Lithuania' - ;; - LU) - COUNTRY='Luxembourg' - ;; - MO) - COUNTRY='Macao SAR China' - ;; - MG) - COUNTRY='Madagascar' - ;; - MW) - COUNTRY='Malawi' - ;; - MY) - COUNTRY='Malaysia' - ;; - MV) - COUNTRY='Maldives' - ;; - ML) - COUNTRY='Mali' - ;; - MT) - COUNTRY='Malta' - ;; - MH) - COUNTRY='Marshall Islands' - ;; - MQ) - COUNTRY='Martinique' - ;; - MR) - COUNTRY='Mauritania' - ;; - MU) - COUNTRY='Mauritius' - ;; - YT) - COUNTRY='Mayotte' - ;; - MX) - COUNTRY='Mexico' - ;; - FM) - COUNTRY='Micronesia' - ;; - MD) - COUNTRY='Moldova' - ;; - MC) - COUNTRY='Monaco' - ;; - MN) - COUNTRY='Mongolia' - ;; - ME) - COUNTRY='Montenegro' - ;; - MS) - COUNTRY='Montserrat' - ;; - MA) - COUNTRY='Morocco' - ;; - MZ) - COUNTRY='Mozambique' - ;; - MM) - COUNTRY='Myanmar' - ;; - NA) - COUNTRY='Namibia' - ;; - NR) - COUNTRY='Nauru' - ;; - NP) - COUNTRY='Nepal' - ;; - NL) - COUNTRY='Netherlands' - ;; - NC) - COUNTRY='New Caledonia' - ;; - NZ) - COUNTRY='New Zealand' - ;; - NI) - COUNTRY='Nicaragua' - ;; - NE) - COUNTRY='Niger' - ;; - NG) - COUNTRY='Nigeria' - ;; - NU) - COUNTRY='Niue' - ;; - NF) - COUNTRY='Norfolk Island' - ;; - KP) - COUNTRY='North Korea' - ;; - MK) - COUNTRY='North Macedonia' - ;; - MP) - COUNTRY='Northern Mariana Islands' - ;; - NO) - COUNTRY='Norway' - ;; - OM) - COUNTRY='Oman' - ;; - PK) - COUNTRY='Pakistan' - ;; - PW) - COUNTRY='Palau' - ;; - PS) - COUNTRY='Palestinian Territories' - ;; - PA) - COUNTRY='Panama' - ;; - PG) - COUNTRY='Papua New Guinea' - ;; - PY) - COUNTRY='Paraguay' - ;; - PE) - COUNTRY='Peru' - ;; - PH) - COUNTRY='Philippines' - ;; - PN) - COUNTRY='Pitcairn Islands' - ;; - PL) - COUNTRY='Poland' - ;; - PT) - COUNTRY='Portugal' - ;; - PR) - COUNTRY='Puerto Rico' - ;; - QA) - COUNTRY='Qatar' - ;; - RE) - COUNTRY='Réunion' - ;; - RO) - COUNTRY='Romania' - ;; - RU) - COUNTRY='Russia' - ;; - RW) - COUNTRY='Rwanda' - ;; - WS) - COUNTRY='Samoa' - ;; - SM) - COUNTRY='San Marino' - ;; - ST) - COUNTRY='São Tomé \\\& Príncipe' - ;; - SA) - COUNTRY='Saudi Arabia' - ;; - SN) - COUNTRY='Senegal' - ;; - RS) - COUNTRY='Serbia' - ;; - SC) - COUNTRY='Seychelles' - ;; - SL) - COUNTRY='Sierra Leone' - ;; - SG) - COUNTRY='Singapore' - ;; - SX) - COUNTRY='Sint Maarten' - ;; - SK) - COUNTRY='Slovakia' - ;; - SI) - COUNTRY='Slovenia' - ;; - SB) - COUNTRY='Solomon Islands' - ;; - SO) - COUNTRY='Somalia' - ;; - ZA) - COUNTRY='South Africa' - ;; - GS) - COUNTRY='South Georgia \\\& South Sandwich Islands' - ;; - KR) - COUNTRY='South Korea' - ;; - SS) - COUNTRY='South Sudan' - ;; - ES) - COUNTRY='Spain' - ;; - LK) - COUNTRY='Sri Lanka' - ;; - BL) - COUNTRY='St. Barthélemy' - ;; - SH) - COUNTRY='St. Helena' - ;; - KN) - COUNTRY='St. Kitts \\\& Nevis' - ;; - LC) - COUNTRY='St. Lucia' - ;; - MF) - COUNTRY='St. Martin' - ;; - PM) - COUNTRY='St. Pierre \\\& Miquelon' - ;; - VC) - COUNTRY='St. Vincent \\\& Grenadines' - ;; - SD) - COUNTRY='Sudan' - ;; - SR) - COUNTRY='Suriname' - ;; - SJ) - COUNTRY='Svalbard \\\& Jan Mayen' - ;; - SE) - COUNTRY='Sweden' - ;; - CH) - COUNTRY='Switzerland' - ;; - SY) - COUNTRY='Syria' - ;; - TW) - COUNTRY='Taiwan' - ;; - TJ) - COUNTRY='Tajikistan' - ;; - TZ) - COUNTRY='Tanzania' - ;; - TH) - COUNTRY='Thailand' - ;; - TL) - COUNTRY='Timor-Leste' - ;; - TG) - COUNTRY='Togo' - ;; - TK) - COUNTRY='Tokelau' - ;; - TO) - COUNTRY='Tonga' - ;; - TT) - COUNTRY='Trinidad \\\& Tobago' - ;; - TN) - COUNTRY='Tunisia' - ;; - TR) - COUNTRY='Turkey' - ;; - TM) - COUNTRY='Turkmenistan' - ;; - TC) - COUNTRY='Turks \\\& Caicos Islands' - ;; - TV) - COUNTRY='Tuvalu' - ;; - UM) - COUNTRY='U.S. Outlying Islands' - ;; - VI) - COUNTRY='U.S. Virgin Islands' - ;; - UG) - COUNTRY='Uganda' - ;; - UA) - COUNTRY='Ukraine' - ;; - AE) - COUNTRY='United Arab Emirates' - ;; - GB) - COUNTRY='United Kingdom' - ;; - US) - COUNTRY='United States' - ;; - UY) - COUNTRY='Uruguay' - ;; - UZ) - COUNTRY='Uzbekistan' - ;; - VU) - COUNTRY='Vanuatu' - ;; - VA) - COUNTRY='Vatican City' - ;; - VE) - COUNTRY='Venezuela' - ;; - VN) - COUNTRY='Vietnam' - ;; - WF) - COUNTRY='Wallis \\\& Futuna' - ;; - EH) - COUNTRY='Western Sahara' - ;; - YE) - COUNTRY='Yemen' - ;; - ZM) - COUNTRY='Zambia' - ;; - ZW) - COUNTRY='Zimbabwe' - ;; - *) - echo "ERROR: Country code '${ADDRESS_COUNTRY}' not recognized" 1>&2 - COUNTRY="${ADDRESS_COUNTRY}" - ;; -esac - -# Convert new lines to " " for LaTeX. excluding trailing new-line -# at the end if present: -CONTACT_TEX=$(echo -n "${CONTACT_NAME%$'\n'}" | awk '{printf "%s ", $0}') -# Convert new lines to "\\" for LaTeX, and escape problematic characters, -# but leave "\\" intact. -ADDRESS_TEX=$(echo -n "${ADDRESS_LINES%$'\n'}" | awk '{printf "%s\\\\\\\\", $0}' | tr '|`~!"<>[]%_^#$&@{}' . | sed 's/\\\\/@@ESCAPED@@/g; s/\\./\./g; s/@@ESCAPED@@/\\\\/g') - - -MYDIR=$(mktemp -d /tmp/authorization-post-XXXXXX) -cd "$MYDIR" -sed -e "s|%NAME%|$CONTACT_TEX|g" \ - -e "s|%ADDRESS_TEX%|$ADDRESS_TEX|g" \ - -e "s/%COUNTRY%/$COUNTRY/g" > input.tex <<EOF -\NeedsTeXFormat{LaTeX2e} -\documentclass[fontsize=11pt,a4paper]{scrlttr2} -\makeatletter -\KOMAoptions{foldmarks=off} -\makeatother -\setplength{toaddrhpos}{3cm} -\setkomavar{subject}{Address validation} -\setkomavar{signature}{Taler Operations AG, c/o Berner Fachhochschule, H\"oheweg 80, 2502 Biel/Bienne} -\date{\today} -\begin{document} -\begin{letter}{%NAME%\\\\ %ADDRESS_TEX% %COUNTRY%} -\opening{To whom it may concern,} -EOF -echo "$MESSAGE" >> input.tex -cat - >> input.tex <<EOF -\closing{Best regards} -\end{letter} -\end{document} -EOF -pdflatex input.tex > "$MYDIR/pdflatex.out" 2> "$MYDIR/pdflatex.err" - -REPLY=$(curl \ - -s \ - -X POST \ - -H "Content-Type: application/x-www-form-urlencoded" \ - --data-urlencode "grant_type=client_credentials" \ - --data-urlencode "client_id=$PINGEN_CLIENT_ID" \ - --data-urlencode "client_secret=$PINGEN_CLIENT_SECRET" \ - --data-urlencode "scope=letter" \ - https://identity.pingen.com/auth/access-tokens) - -ACCESS_TOKEN=$(echo "$REPLY" | jq -r .access_token) - -REPLY=$(curl -s \ - -X GET "$ENDPOINT/file-upload" \ - -H "Authorization: Bearer $ACCESS_TOKEN") -ATTRS=$(echo "$REPLY" | jq .data.attributes) -UPLOAD_URL=$(echo "$ATTRS" | jq -r .url) -URL_SIG=$(echo "$ATTRS" | jq -r .url_signature) - -STATUS=$(curl -s \ - -X PUT \ - -T input.pdf \ - "$UPLOAD_URL" \ - -o "$MYDIR/upload-status.txt" \ - -w "%{http_code}" -s) - -case "$STATUS" in - 200) - ;; - 201) - ;; - 204) - ;; - *) - echo "Failed to upload letter: $STATUS" >> "$ERRORS" - cat "$MYDIR/upload-status.txt" >> "$ERRORS" - exit 1; - ;; -esac - - -REQUEST="$(jq -n ' - { data: { - type: "letters", - attributes: { - file_original_name: "input.pdf", - file_url: $UPLOAD_URL, - file_url_signature: $URL_SIG, - address_position: "left", - delivery_product: "cheap", - print_mode: "duplex", - auto_send: true, - print_spectrum: "grayscale" - } } - }' \ - --arg UPLOAD_URL "$UPLOAD_URL" \ - --arg URL_SIG "$URL_SIG" \ - )" - -STATUS=$(curl -s \ - --request POST \ - --url "$ENDPOINT/organisations/${PINGEN_ORG_ID}/letters" \ - --header "Content-Type: application/vnd.api+json" \ - --header "Authorization: Bearer $ACCESS_TOKEN" \ - -d "$REQUEST" \ - -o "$MYDIR/final-reply.txt" \ - -w "%{http_code}" -s) -case "$STATUS" in - 201) - cat "$MYDIR/final-reply.txt" >> "$LOGS" - ;; - *) - echo "Failed to add letter: $STATUS" >> "$ERRORS" - cat "$MYDIR/final-reply.txt" >> "$ERRORS" - exit 1; - ;; -esac - -rm -r "$MYDIR" -exit 0 diff --git a/src/challenger/challenger-send-sms b/src/challenger/challenger-send-sms @@ -1,33 +0,0 @@ -#!/bin/bash -# This file is in the public domain. -# Send an SMS -set -eu - -if [ $# -ne 1 ]; then - echo "Usage: $0 '{\"CONTACT_PHONE\":\"+41712345678\"}'" 1>&2 - exit 1 -fi - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -SCRIPT_NAME=$(basename "$0") -BASE="${SCRIPT_NAME}" - -PHONE_NUMBER=$(echo "$1" | jq -r .CONTACT_PHONE) -MESSAGE=$(cat -) - -# List of sub-scripts to try. -PROVIDERS="telesign clicksend aspsms" - -for PROVIDER in $PROVIDERS; do - SCRIPT_PATH="$SCRIPT_DIR/${BASE}-${PROVIDER}" - if [ -x "$SCRIPT_PATH" ]; then - if echo "$MESSAGE" | "$SCRIPT_PATH" "$PHONE_NUMBER"; then - exit 0 - else - echo "$PROVIDER failed to send to $PHONE_NUMBER." 1>&2 - fi - fi -done - -echo "All SMS providers failed to send to $PHONE_NUMBER." 1>&2 -exit 1 diff --git a/src/challenger/challenger-send-sms-aspsms b/src/challenger/challenger-send-sms-aspsms @@ -1,301 +0,0 @@ -#!/bin/bash -# This file is in the public domain. -# Send an SMS using ASPSMS API. -# -# Usage: -# echo "Hello world" | $0 +41791234567 -# -# Environment: -# ASPSMS_USERKEY -# ASPSMS_PASSWORD -# -# Exit codes: -# -# 0 SMS delivered -# -# 1 Usage/configuration error -# 2 Local/network/API communication failure -# 3 ASPSMS authentication failure -# 4 Invalid phone number -# 5 Recipient unavailable (phone off / no coverage / expired) -# 6 Mobile operator/provider failure -# 7 ASPSMS rejected request -# 8 Delivery timeout (status never became final) -# 9 Unknown failure -# - -set -euo pipefail - -# Check shared secrets -if [ -x "$ASPSMS_USERKEY" ] -then - echo "ASPSMS_USERKEY not set in environment" - exit 1 -fi - -if [ -x "$ASPSMS_PASSWORD" ] -then - echo "ASPSMS_PASSWORD not set in environment" - exit 1 -fi - - -API="https://webapi.aspsms.com" - -if [[ $# -ne 1 ]] -then - echo "Usage: $0 <PHONE_NUMBER>" >&2 - exit 1 -fi - -PHONE="$1" -MESSAGE="$(cat -)" - -if [[ -z "$MESSAGE" ]] -then - echo "Empty message" >&2 - exit 1 -fi - -TRANSREF="$(date +%s)-$$-$RANDOM" - -echo "T-REF: $TRANSREF" - -# -# Send SMS -# -SEND_JSON="$( -curl -fsS \ - --get \ - "$API/SendSimpleSMS" \ - --data-urlencode "Userkey=$ASPSMS_USERKEY" \ - --data-urlencode "Password=$ASPSMS_PASSWORD" \ - --data-urlencode "MSISDN=$PHONE" \ - --data-urlencode "MessageData=$MESSAGE" \ - --data-urlencode "TransactionReferenceNumber=$TRANSREF" -)" || { - echo "Communication with ASPSMS failed" >&2 - exit 2 -} - -ERROR_CODE=$(jq -r '.ErrorCode // empty' <<<"$SEND_JSON") -ERROR_DESC=$(jq -r '.ErrorDescription // empty' <<<"$SEND_JSON") - -#1 OK -#2 Connect failed. -#3 Authorization failed. -#4 Binary file not found. Please check the location. -#5 Not enough credits available. Please recharge your account to proceed. -#6 Time out error. -#7 Transmission error. Please try it again. -#8 Invalid UserKey. Please check the spelling of the UserKey. -#9 Invalid Password. -#10 Invalid originator. A maximum of 11 characters is allowed for alphanumeric originators. -#11 Invalid message date. Please verify the data. -#12 Invalid binary data. Please verify the data. -#13 Invalid binary file. Please check the file type. -#14 Invalid MCC. Please check the number. -#15 Invalid MNC. Please check the number. -#16 Invalid XSer. -#17 Invalid URL buffered message notification string. -#18 Invalid URL delivery notification string. -#19 Invalid URL non delivery notification string. -#20 Missing a recipient. Please specify at least one recipient. -#21 Missing binary data. Please specify some data. -#22 Invalid deferred delivery time. Please check the format. -#23 Missing transaction reference number. -#24 Service temporarely not available. -#25 User access denied. -#28 No Originator Restrictions. -#29 Originator Authorization Pending. -#30 Originator Not Authorized. -#31 Originator already authorized. -#32 No Notification Recipient Restrictions. -#33 Notification Recipient Authorization Pending. -#34 Notification Recipient Not Authorized. -#35 Notification Recipient Already Authorized. -#36 Security Token authorization pending. -#37 Security Token not authorized. -#38 Security Token not found. -#39 Security Token already authorized. - -case "$ERROR_CODE" in - 1) - ;; - 3|8|9) - echo "$ERROR_DESC" >&2 - exit 3 - ;; - 20|206) - echo "$ERROR_DESC" >&2 - exit 4 - ;; - 24) - echo "$ERROR_DESC" >&2 - exit 7 - ;; - "") - echo "Unexpected response:" >&2 - echo "$SEND_JSON" >&2 - exit 2 - ;; - *) - echo "$ERROR_DESC" >&2 - exit 7 - ;; -esac - -# -# Poll delivery status -# -# -# DeliveryStatus: -# -1 not yet known -# 0 delivered -# 1 buffered -# 2 failed -# -# Reason codes of interest: -# -# 000 unknown subscriber -# 101 unknown subscriber -# 103 Call Barred -# 107 absent subscriber -# 108 delivery failed (buffered / not delivered) -# 110 Protocol error -# 111 MS not qeuipment -# 105/113 SC congestion -# 118-126 network/provider failures -# 206 invalid destination address -# -# Full list: -# -#000 Unknown subscriber -#001 Service temporary not available -#002 Service temporary not available -#003 Service temporary not available -#004 Service temporary not available -#005 Service temporary not available -#006 Service temporary not available -#007 Service temporary not available -#008 Service temporary not available -#009 Illegal error code -#010 Network time-out -#100 Facility not supported -#101 Unknown subscriber -#102 Facility not provided -#103 Call barred -#104 Operation barred -#105 SC congestion -#106 Facility not supported -#107 Absent subscriber -#108 Delivery fail -#109 SC congestion -#110 Protocol error -#111 MS not equipped -#112 Unknown SC -#113 SC congestion -#114 Illegal MS -#115 MS not a subscriber -#116 Error in MS -#117 SMS lower layer not provisioned -#118 System fail -#119 PLMN system failure -#120 HLR system failure -#121 VLR system failure -#122 Previous VLR system failure -#123 Controlling MSC system failure -#124 VMSC system failure -#125 EIR system failure -#126 System failure -#127 Unexpected data value -#200 Error in address service centre -#201 Invalid absolute Validity Period -#202 Short message exceeds maximum -#203 Unable to Unpack GSM message -#204 Unable to convert to IA5 ALPHABET -#205 Invalid validity period format -#206 Invalid destination address -#207 Duplicate message submit -#208 Invalid message type indicator - -for ((i=0;i<60;i++)) -do - SEC=$(($i / 10)) - # Wait at least 100ms, then go up every second by 1 second - sleep ${SEC}.1 - echo "Fetching status..." - STATUS_JSON="$( - curl -fsS \ - --get \ - "$API/SendingStat03/Get" \ - --data-urlencode "Userkey=$ASPSMS_USERKEY" \ - --data-urlencode "Password=$ASPSMS_PASSWORD" \ - --data-urlencode "TransactionReferenceNumber=$TRANSREF" - )" || continue - - jq <<< "$STATUS_JSON" - # SendingStat03/Get returns an array of SMSMessagesWebAPI objects on - # success, or an ASPSMSServerResult object ({"ErrorCode":..}) on error / - # when no sendlog entry exists yet. Guard against indexing the object form, - # which would make jq error out and abort the script under `set -e`. - # In the message objects the delivery status is the field DST (0=delivered, - # 1=buffered, 2=failed, absent/-1=not yet known) and the reason is RSN. - DELIVERY=$(jq -r 'if type=="array" then (.[0].DST // empty) else empty end' <<<"$STATUS_JSON") - REASON=$(jq -r 'if type=="array" then (.[0].RSN // "") else "" end' <<<"$STATUS_JSON") - - case "$DELIVERY" in - - 0) - echo "Success!" >&2 - exit 0 - ;; - - 1) - continue - ;; - - 2) - echo "Failure: $REASON" - case "$REASON" in - - 206|000|101) - exit 4 - ;; - - 107|108) - exit 5 - ;; - - 105|113|118|119|120|121|122|123|124|125|126) - exit 6 - ;; - - *) - exit 9 - ;; - esac - ;; - - -1|"") - continue - ;; - - esac - -done - -exit 8 - -#| Exit | Meaning | -#| ---- | ----------------------------------------------------------------------------- | -#| 0 | SMS successfully delivered | -#| 1 | Usage or local configuration error | -#| 2 | Unable to contact ASPSMS/API/network error | -#| 3 | Authentication failure (invalid user key/password) | -#| 4 | Invalid or unknown recipient number | -#| 5 | Recipient unreachable (phone switched off, out of coverage, delivery expired) | -#| 6 | Mobile operator/network/provider failure | -#| 7 | ASPSMS rejected the request (temporary service issues, invalid request, etc.) | -#| 8 | Timed out waiting for a final delivery report | -#| 9 | Delivery failed for an unclassified reason | diff --git a/src/challenger/challenger-send-sms-clicksend b/src/challenger/challenger-send-sms-clicksend @@ -1,142 +0,0 @@ -#!/bin/bash -# This file is in the public domain. -# Send an SMS using ClickSend API - -set -eu - -# Check shared secrets -if [ -x "$CLICKSEND_USERNAME" ] -then - echo "CLICKSEND_USERNAME not set in environment" - exit 1 -fi -if [ -x "$CLICKSEND_API_KEY" ] -then - echo "CLICKSEND_API_KEY not set in environment" - exit 1 -fi - -if [ $# -ne 1 ] -then - echo "Usage: $0 <phone_number>" 1>&2 - exit 1 -fi - -PHONE_NUMBER="$1" -MESSAGE=$(cat -) - -TMPFILE=$(mktemp /tmp/clicksend-sms-logging-XXXXXX) - -RESPONSE=$(curl --silent --show-error --fail \ - --url https://rest.clicksend.com/v3/sms/send \ - --request POST \ - --header 'Content-Type: application/json' \ - --user "$CLICKSEND_USERNAME:$CLICKSEND_API_KEY" \ - --data "{ - \"messages\": [{ - \"source\": \"bash-script\", - \"to\": \"$PHONE_NUMBER\", - \"body\": \"$MESSAGE\" - }] - }") - -echo "$RESPONSE" > "$TMPFILE" - -RESPONSE_CODE=$(echo "$RESPONSE" | jq -r '.response_code') - -if [ "$RESPONSE_CODE" != "SUCCESS" ]; -then - echo "Clicksend: failed to send SMS to $PHONE_NUMBER, got response code $RESPONSE_CODE." 1>&2 - exit 2 -fi - -MESSAGE_ID=$(echo "$RESPONSE" | jq -r '.data.messages[0].message_id') - -if [ "$MESSAGE_ID" == "null" ]; -then - echo "Clicksend: failed to retrieve message ID for message to $PHONE_NUMBER." 1>&2 - echo "$RESPONSE" 1>&2 - exit 3 -fi - -MESSAGE_STATUS=$(echo "$RESPONSE" | jq -r '.data.messages[0].status') - -if [ "$MESSAGE_STATUS" == "SUCCESS" ]; -then - echo "Clicksend: message delivered successfully to $PHONE_NUMBER." 1>&2 - exit 0 -fi - -MAX_ITERATIONS=12 - -# Poll message status -echo "Polling message status (message_id: $MESSAGE_ID)..." 1>&2 -for N in $(seq 1 "$MAX_ITERATIONS") -do - STATUS_RESPONSE=$(curl --silent --show-error --fail \ - --url "https://rest.clicksend.com/v3/sms/receipts/$MESSAGE_ID" \ - --user "$CLICKSEND_USERNAME:$CLICKSEND_API_KEY") - - echo "$STATUS_RESPONSE" >> "$TMPFILE" - - RESPONSE_CODE=$(echo "$RESPONSE" | jq -r '.response_code') - - if [ "$RESPONSE_CODE" != "SUCCESS" ]; - then - echo "Clicksend: failed to get status for message to $PHONE_NUMBER, assuming failure." 1>&2 - echo "$RESPONSE" 1>&2 - exit 4 - fi - - STATUS_CODE=$(echo "$STATUS_RESPONSE" | jq -r '.data.status_code') - STATUS_TEXT=$(echo "$STATUS_RESPONSE" | jq -r '.data.status_text') - STATUS=$(echo "$STATUS_TEXT" | awk --field-separator ':' '{print $1}') - - case "$STATUS_CODE" in - "200") - case "$STATUS" in - "Success"|"Sent") - # Message sent to the network for delivery, wait a bit - sleep 1 - ;; - "Queued"|"Scheduled") - # queued for delivery, sleep a bit longer - sleep 10 - ;; - "WaitApproval") - # Human in the loop (strange), sleep even longer - sleep 120 - ;; - *) - # Unexpected status, keep trying - sleep 5 - ;; - esac - ;; - "201") - # Message delivered to the handset - echo "Clicksend: message delivered successfully to $PHONE_NUMBER." 1>&2 - exit 0 - ;; - "300") - # Temporary network error, clicksend will retry automatically, sleep a bit - sleep 20 - ;; - "301") - # Delivery failed - echo "Clicksend: message delivery to $PHONE_NUMBER failed: $DESCRIPTION" 1>&2 - exit 1 - ;; - "FAILED"|"INVALID_RECIPIENT") - echo "Clicksend: message delivery to $PHONE_NUMBER failed: $DESCRIPTION" 1>&2 - exit 6 - ;; - *) - echo "Clicksend: message delivery to $PHONE_NUMBER failed: $DESCRIPTION" 1>&2 - sleep 5 - ;; - esac -done - -echo "Clicksend: unclear message delivery status $STATUS_CODE ($DESCRIPTION) after $MAX_ITERATIONS iterations. Assuming failure." 1>&2 -exit 1 diff --git a/src/challenger/challenger-send-sms-telesign b/src/challenger/challenger-send-sms-telesign @@ -1,160 +0,0 @@ -#!/bin/bash -# This file is in the public domain. -# Send an SMS using Telesign API -set -eu - -# Check shared secrets -if [ -x "$TELESIGN_AUTH_TOKEN" ] -then - echo "TELESIGN_AUTH_TOKEN not set in environment" - exit 1 -fi - -if [ $# -ne 1 ]; -then - echo "Usage: $0 <phone_number>" 1>&2 - exit 1 -fi - -PHONE_NUMBER="$1" -MESSAGE=$(cat -) - -TMPFILE=$(mktemp /tmp/telesign-sms-logging-XXXXXX) - -RESPONSE=$(curl --silent --show-error --fail \ - --url https://rest-api.telesign.com/v1/messaging \ - --request POST \ - --header "Authorization: Basic $TELESIGN_AUTH_TOKEN" \ - --header "Content-Type: application/x-www-form-urlencoded" \ - --data account_livecycle_event=transact \ - --data "phone_number=$PHONE_NUMBER" \ - --data-urlencode "message=$MESSAGE" \ - --data "message_type=OTP") - -echo "$RESPONSE" > "$TMPFILE" -REFERENCE_ID=$(jq -r '.reference_id' "$TMPFILE") - -if [ "$REFERENCE_ID" == "null" ]; -then - echo "Telesign: failed to retrieve reference ID for message to $PHONE_NUMBER." 1>&2 - echo "$RESPONSE" 1>&2 - exit 1 -fi - -STATUS_CODE=$(echo "$RESPONSE" | jq -r '.status.code') - -case "$STATUS_CODE" in - "200") - # Delivered to headset. Should basically never happen here. - echo "Telesign: message delivered successfully to $PHONE_NUMBER." 1>&2 - exit 0 - ;; - "203"|"292"|"295") - # Delivered to gateway - sleep 2 - ;; - "207"|"211"|"220"|"221"|"222"|"231"|"237"|"238") - # Failure to deliver (hard) - echo "Telesign: could not deliver message to $PHONE_NUMBER: $STATUS_CODE" 1>&2 - exit 1 - ;; - "210") - # Temporary phone error - ;; - "250") - # Final status unknown - echo "Telesign: final status unknown for message to $PHONE_NUMBER, assuming success" 1>&2 - exit 0 - ;; - "290") - # Message in progress, go into loop below - sleep 2 - ;; - "502"|"503"|"504"|"505"|"506"|"507"|"508"|"509"|"510"|"511"|"512"|"513"|"514"|"515"|"517"|"520"|"521") - echo "Telesign: carrier problem ($STATUS_CODE) delivering to $PHONE_NUMBER" 1>&2 - exit 1 - ;; - "10000") - # Internal error at telesign... - echo "Telesign: internal error delivering to $PHONE_NUMBER" 1>&2 - echo "$RESPONSE" 1>&2 - exit 1 - ;; - "10019"|"10020") - # Rate limit exceeded. Treating as hard failure for now. - echo "Telesign: Rate limit exceeded ($STATUS_CODE) delivering to $PHONE_NUMBER" 1>&2 - echo "$RESPONSE" 1>&2 - exit 1 - ;; - *) - # Many possible status codes for failure... - echo "Telesign: Message delivery to $PHONE_NUMBER failed: $STATUS_CODE" 1>&2 - echo "$RESPONSE" 1&>2 - exit 1 - ;; -esac - -MAX_ITERATIONS=12 - -# Poll for message status -echo "Polling message status (reference_id: $REFERENCE_ID)..." 1>&2 -for N in $(seq 1 "$MAX_ITERATIONS") -do - STATUS_RESPONSE=$(curl --silent --show-error --fail \ - --url "https://rest-api.telesign.com/v1/messaging/$REFERENCE_ID" \ - --header "Authorization: Basic $TELESIGN_AUTH_TOKEN") - - echo "$STATUS_RESPONSE" >> "$TMPFILE" - - STATUS_CODE=$(echo "$STATUS_RESPONSE" | jq -r '.status.code') - DESCRIPTION=$(echo "$STATUS_RESPONSE" | jq -r '.status.description') - - case "$STATUS_CODE" in - "200") - # Delivered to headset. Great! - echo "Telesign: message delivered successfully to $PHONE_NUMBER." 1>&2 - exit 0 - ;; - "203"|"290"|"292"|"295") - # Delivered to gateway, wait a bit for an update - sleep 2 - ;; - "210") - # Temporary phone error - sleep 15 - ;; - "207"|"211"|"220"|"221"|"222"|"231"|"237"|"238") - # Failure to deliver (hard) - echo "Telesign: could not deliver message to $PHONE_NUMBER ($STATUS_CODE)" 1>&2 - exit 8 - ;; - "250") - # Final status unknown - echo "Telesign: final status for delivery to $PHONE_NUMBER unknown, assuming success" 1>&2 - exit 0 - ;; - "502"|"503"|"504"|"505"|"506"|"507"|"508"|"509"|"510"|"511"|"512"|"513"|"514"|"515"|"517"|"520"|"521") - echo "Telesign: carrier problem ($STATUS_CODE) for message to $PHONE_NUMBER" 1>&2 - exit 7 - ;; - "10000") - # Internal error at telesign... - echo "Telesign: internal error for message to $PHONE_NUMBER" 1>&2 - exit 9 - ;; - "10019"|"10020") - # Rate limit exceeded. Treating as hard failure for now. - echo "Telesign: rate limit exceeded for message to $PHONE_NUMBER" 1>&2 - exit 10 - ;; - *) - # Many possible status codes for failure... - echo "Telesign: message delivery to $PHONE_NUMBER failed: $STATUS_CODE" 1>&2 - echo "$RESPONSE" 1&>2 - exit 11 - ;; - esac -done - -echo "Telesign: unclear delivery status ${STATUS_CODE:-} (${DESCRIPTION:-}) for message to $PHONE_NUMBER after ${MAX_ITERATIONS:-} iterations. Assuming failure." 1>&2 -exit 12 diff --git a/src/challenger/meson.build b/src/challenger/meson.build @@ -7,25 +7,6 @@ dist_tmpldata_DATA = \ install_data('challenger.conf', install_dir: pkgcfgdir) -bin_SCRIPTS = [ - 'challenger-send-email', - 'challenger-send-post', - 'challenger-send-sms', - 'challenger-send-sms-aspsms', - 'challenger-send-sms-clicksend', - 'challenger-send-sms-telesign', -] - -foreach s : bin_SCRIPTS - configure_file( - input: s, - output: s, - install_dir: get_option('bindir'), - copy: true, - ) -endforeach - - check_SCRIPTS = [ 'test-challenger', 'test-challenger-pkce',