taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit c7511e51416acba5fbc16bfb9264bb675e4d0695
parent b0265357733b2cfcb245508297bbb5c317e478ec
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 31 Oct 2026 11:21:48 +0100

support both spellings of the x-taler-bank wire_type

Diffstat:
Mpackages/libeufin-bank-webui/src/pages/OperationState/views.tsx | 3++-
Mpackages/libeufin-bank-webui/src/pages/PaytoWireTransferForm.tsx | 12+++++++-----
Mpackages/libeufin-bank-webui/src/pages/admin/AccountForm.tsx | 6++----
Mpackages/libeufin-bank-webui/src/utils.ts | 17+++++++++++++++++
4 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/packages/libeufin-bank-webui/src/pages/OperationState/views.tsx b/packages/libeufin-bank-webui/src/pages/OperationState/views.tsx @@ -59,6 +59,7 @@ import { WithdrawalProgress } from "../WithdrawalProgress.js"; import { validateWithdrawalAmount } from "../withdrawal-amount.js"; import { maximumWithdrawalAmount } from "../withdrawal-amount.js"; import { IntAmounts } from "../regional/CreateCashout.js"; +import { paytoTypeOfWireType } from "../../utils.js"; export function accountWithdrawalMaximum( account: TalerCorebankApi.AccountData, @@ -266,7 +267,7 @@ export function NeedConfirmationView({ : undefined; const expectsTalerBank = - config.wire_type === "X_TALER_BANK" || config.wire_type === "x-taler-bank"; + paytoTypeOfWireType(config.wire_type) === "x-taler-bank"; const supportedAccount = expectsTalerBank ? details.account.targetType === PaytoType.TalerBank : details.account.targetType === PaytoType.IBAN; diff --git a/packages/libeufin-bank-webui/src/pages/PaytoWireTransferForm.tsx b/packages/libeufin-bank-webui/src/pages/PaytoWireTransferForm.tsx @@ -44,7 +44,12 @@ import { useState } from "preact/hooks"; import { useBankChallengeHandlerContext } from "../context/challenge.js"; import { OperationError } from "../components/OperationError.js"; import { LoggedIn, useSessionState } from "../hooks/session.js"; -import { undefinedIfEmpty, validateIBAN, validateTalerBank } from "../utils.js"; +import { + paytoTypeOfWireType, + undefinedIfEmpty, + validateIBAN, + validateTalerBank, +} from "../utils.js"; import { IntAmountJson, IntAmounts } from "./regional/CreateCashout.js"; export interface Props { @@ -106,10 +111,7 @@ export function PaytoWireTransferForm({ const { showError } = useNotificationContext(); const mfa = useBankChallengeHandlerContext(); - const paytoType = - config.wire_type === "X_TALER_BANK" - ? ("x-taler-bank" as const) - : ("iban" as const); + const paytoType = paytoTypeOfWireType(config.wire_type); const errorsWire = undefinedIfEmpty({ account: !account diff --git a/packages/libeufin-bank-webui/src/pages/admin/AccountForm.tsx b/packages/libeufin-bank-webui/src/pages/admin/AccountForm.tsx @@ -36,6 +36,7 @@ import { useSessionState } from "../../hooks/session.js"; import { ErrorMessageMappingFor, TanChannel, + paytoTypeOfWireType, undefinedIfEmpty, validateIBAN, validateTalerBank, @@ -140,10 +141,7 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({ ErrorMessageMappingFor<typeof defaultValue> | undefined >(undefined); - const paytoType = - config.wire_type === "X_TALER_BANK" - ? ("x-taler-bank" as const) - : ("iban" as const); + const paytoType = paytoTypeOfWireType(config.wire_type); const cashoutPaytoType: typeof paytoType = "iban" as const; const defaultValue: AccountFormData = { diff --git a/packages/libeufin-bank-webui/src/utils.ts b/packages/libeufin-bank-webui/src/utils.ts @@ -34,6 +34,23 @@ export function getIbanFromPayto(url: string): string { return iban; } +/** + * Payto target type the bank's `wire_type` selects. + * + * The Corebank API documents `wire_type` as the payto target type, so the + * values are `"iban"` and `"x-taler-bank"`; the Kotlin implementation used to + * answer `"X_TALER_BANK"` instead, and some deployments still do. Accept both + * spellings and fall back to IBAN, which is what the API says a missing + * `wire_type` means. + */ +export function paytoTypeOfWireType( + wireType: string | undefined, +): "iban" | "x-taler-bank" { + return wireType === "X_TALER_BANK" || wireType === "x-taler-bank" + ? "x-taler-bank" + : "iban"; +} + export function undefinedIfEmpty<T extends object>(obj: T): T | undefined { return Object.keys(obj).some( (k) => (obj as Record<string, T>)[k] !== undefined,