commit 3f43b2e948125e0e20a48195df8db2a666b689a1
parent 4e83739451cc56b514ab56e426627b151a2fb1c6
Author: Florian Dold <florian@dold.me>
Date: Mon, 5 May 2025 21:36:50 +0200
move challenger converter helpers into exchange
Diffstat:
5 files changed, 114 insertions(+), 0 deletions(-)
diff --git a/debian/taler-exchange.install b/debian/taler-exchange.install
@@ -19,6 +19,9 @@ usr/bin/taler-exchange-kyc-oauth2-challenger.sh
usr/bin/taler-exchange-kyc-oauth2-nda.sh
usr/bin/taler-exchange-kyc-oauth2-test-converter.sh
usr/bin/taler-exchange-kyc-persona-converter.sh
+usr/bin/taler-exchange-kyc-challenger-sms-converter
+usr/bin/taler-exchange-kyc-challenger-email-converter
+usr/bin/taler-exchange-kyc-challenger-postal-converter
usr/bin/taler-exchange-kyc-tester
usr/bin/taler-exchange-kyc-trigger
usr/bin/taler-exchange-router
diff --git a/src/kyclogic/Makefile.am b/src/kyclogic/Makefile.am
@@ -38,6 +38,9 @@ bin_SCRIPTS = \
taler-exchange-kyc-kycaid-converter.sh \
taler-exchange-kyc-persona-converter.sh \
taler-exchange-kyc-oauth2-test-converter.sh \
+ taler-exchange-kyc-challenger-email-converter \
+ taler-exchange-kyc-challenger-postal-converter \
+ taler-exchange-kyc-challenger-sms-converter \
taler-exchange-kyc-oauth2-challenger.sh \
taler-exchange-kyc-oauth2-nda.sh
diff --git a/src/kyclogic/taler-exchange-kyc-challenger-email-converter b/src/kyclogic/taler-exchange-kyc-challenger-email-converter
@@ -0,0 +1,35 @@
+#!/bin/bash
+# This file is in the public domain.
+#
+# Challenger's /info returns the 'id' as a Number, but the
+# exchange oauth2 plugin expects it as a String.
+# Additionally, we need to check that we got the expected
+# "email" address type (and otherwise exit with failure),
+# and finally move the .address.phone value to
+# the "CONTACT_PHONE" field.
+#
+# Uses JQ to convert!
+exec jq 'if .address_type!="email" then halt_error(4) else (. | .id?) |= (. | tostring) | .FORM_ID="challenger-email" | .FORM_VERSION=0 | .CONTACT_EMAIL=.address.email | del(.address) | del(.address_type) end'
+
+# Example input:
+# {
+# "id": 1,
+# "address": {
+# "email": "me@example.com"
+# },
+# "address_type": "phone",
+# "expires": {
+# "t_s": 1775590216
+# }
+# }
+#
+# Example output:
+#
+# {
+# "id": "1",
+# "expires": {
+# "t_s": 1775590216
+# }
+# "CONTACT_EMAIL": "me@example.com"
+# }
+#
diff --git a/src/kyclogic/taler-exchange-kyc-challenger-postal-converter b/src/kyclogic/taler-exchange-kyc-challenger-postal-converter
@@ -0,0 +1,38 @@
+#!/bin/bash
+# This file is in the public domain.
+#
+# Challenger's /info returns the 'id' as a Number, but the
+# exchange oauth2 plugin expects it as a String.
+# Additionally, we need to check that we got the expected
+# "postal" address type (and otherwise exit with failure),
+# and finally move the .address values to
+# the "ADDRESS_*" fields.
+#
+# Uses JQ to convert!
+exec jq 'if .address_type!="postal" and .address_type !="postal-ch" then halt_error(4) else (. | .id?) |= (. | tostring) | .FORM_ID="challenger-postal" | .FORM_VERSION=0 | .CONTACT_NAME=.address.CONTACT_NAME | .ADDRESS_LINES=.address.ADDRESS_LINES | if .address_type=="postal" then .ADDRESS_COUNTRY=.address.ADDRESS_COUNTRY else .ADDRESS_COUNTRY="CH" end | del(.address) | del(.address_type) end'
+
+# Example input:
+# {
+# "id": 1,
+# "address": {
+# "CONTACT_NAME": "Richard Stallman",
+# "ADDRESS_LINES": "Bundesgasse 1\n1234 Bern"
+# },
+# "address_type": "postal-ch",
+# "expires": {
+# "t_s": 1775590216
+# }
+# }
+#
+# Example output:
+#
+# {
+# "id": "1",
+# "expires": {
+# "t_s": 1775590216
+# }
+# "CONTACT_NAME": "Richard Stallman"
+# "ADDRESS_LIENS": "Bundesgasse 1\n1234 Bern"
+# "ADDRESS_COUNTRY": "CH"
+# }
+#
diff --git a/src/kyclogic/taler-exchange-kyc-challenger-sms-converter b/src/kyclogic/taler-exchange-kyc-challenger-sms-converter
@@ -0,0 +1,35 @@
+#!/bin/bash
+# This file is in the public domain.
+#
+# Challenger's /info returns the 'id' as a Number, but the
+# exchange oauth2 plugin expects it as a String.
+# Additionally, we need to check that we got the expected
+# "phone" address type (and otherwise exit with failure),
+# and finally move the .address.CONTACT_PHONE value to
+# the "CONTACT_PHONE" field.
+#
+# Uses JQ to convert!
+exec jq 'if .address_type!="phone" then halt_error(4) else (. | .id?) |= (. | tostring) | .CONTACT_PHONE=.address.CONTACT_PHONE | .FORM_ID="challenger-sms" | .FORM_VERSION=0 | del(.address) | del(.address_type) end'
+
+# Example input:
+# {
+# "id": 1,
+# "address": {
+# "CONTACT_PHONE": "+4112345678"
+# },
+# "address_type": "phone",
+# "expires": {
+# "t_s": 1775590216
+# }
+# }
+#
+# Example output:
+#
+# {
+# "id": "1",
+# "expires": {
+# "t_s": 1775590216
+# }
+# "CONTACT_PHONE": "+4112345678"
+# }
+#