taldir

Directory service to resolve wallet mailboxes by messenger addresses
Log | Files | Refs | Submodules | README | LICENSE

taldir-validate-phone (841B)


      1 #!/bin/bash
      2 # This file is in the public domain.
      3 set -eu
      4 
      5 # Check shared secrets
      6 if [ -x "$TELESIGN_AUTH_TOKEN" ]
      7 then
      8     echo "TELESIGN_AUTH_TOKEN not sent in environment"
      9     exit 1
     10 fi
     11 
     12 USER_MAIL=$1
     13 CODE=$2
     14 LINK=$(taldir-cli -l -a $1 -t phone -c $2)
     15 
     16 TOPIC=$3
     17 
     18 MESSAGE=$(echo -e $4)
     19 
     20 TMPFILE=$(mktemp /tmp/sms-loggingXXXXXX)
     21 STATUS=$(curl --request POST \
     22      --url https://rest-api.telesign.com/v1/messaging \
     23      --header "authorization: Basic $TELESIGN_AUTH_TOKEN" \
     24      --header 'content-type: application/x-www-form-urlencoded' \
     25      --data account_livecycle_event=transact \
     26      --data "message=$MESSAGE" \
     27      --data message_type=OTP \
     28      --data "phone_number=$1" \
     29      -w "%{http_code}" -s -o $TMPFILE)
     30 case $STATUS in
     31     200|203|250|290|291|295)
     32         exit 0;
     33         ;;
     34     *)
     35         exit 1;
     36         ;;
     37 esac
     38 exit 1