taler-typescript-core

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

commit 0fa2bc2f8f9506f80af58054d377065502bd83d1
parent 26d77ac3430d169010cb76b33ef324ec22ddfc46
Author: Florian Dold <florian@dold.me>
Date:   Sat, 18 Jul 2026 19:33:16 +0200

remove deprecated payto functions and types

Diffstat:
Mpackages/taler-merchant-webui/src/components/form/InputPaytoForm.tsx | 7++-----
Mpackages/taler-util/src/payto.ts | 282-------------------------------------------------------------------------------
Mpackages/taler-wallet-webextension/src/wallet/DestinationSelection/index.ts | 1-
3 files changed, 2 insertions(+), 288 deletions(-)

diff --git a/packages/taler-merchant-webui/src/components/form/InputPaytoForm.tsx b/packages/taler-merchant-webui/src/components/form/InputPaytoForm.tsx @@ -20,7 +20,6 @@ */ import { InternationalizationAPI, - PaytoUri, TranslatedString, Paytos, Result, @@ -41,7 +40,6 @@ const TALER_SCREEN_ID = 11; export interface Props<T> extends InputProps<T> {} -// type Entity = PaytoUriGeneric // https://datatracker.ietf.org/doc/html/rfc8905 type Entity = { // iban, bitcoin, x-taler-bank. it defined the format @@ -296,14 +294,13 @@ export function InputPaytoForm<T>({ const pto = hasErrors || !value.target ? undefined - : ({ + : { targetType: value.target, targetPath: value.path2 ? `${path1WithSlash}${value.path2}` : (path1WithSlash ?? ""), params: value.params ?? {}, - isKnown: false as const, - } as PaytoUri); + }; const str = !pto ? undefined diff --git a/packages/taler-util/src/payto.ts b/packages/taler-util/src/payto.ts @@ -29,9 +29,6 @@ import { } from "./taler-crypto.js"; import { URLSearchParams } from "./url.js"; -/** - * @deprecated use NormalizedPayto or FullPayto - */ export type PaytoString = string; const PAYTO_PREFIX = "payto://"; @@ -872,19 +869,6 @@ export function codecNormalizedForPaytoString(): Codec<Paytos.NormalizedPaytoStr } /** - * @deprecated use Paytos namespace - */ -export type PaytoUri = - | PaytoUriUnknown - | PaytoUriIBAN - | PaytoUriTaler - | PaytoUriCyclos - | PaytoUriTalerHttp - | PaytoUriTalerBank - | PaytoUriEthereum - | PaytoUriBitcoin; - -/** * @deprecated use codecForNormalizedPAyto or codecForFullPayto * @returns */ @@ -905,90 +889,6 @@ export function codecForPaytoString(): Codec<PaytoString> { }, }; } -/** - * @deprecated use Paytos namespace - */ -export interface PaytoUriGeneric { - targetType: PaytoType | string; - targetPath: string; - params: { [name: string]: string }; -} - -/** - * @deprecated use Paytos namespace - */ -export interface PaytoUriUnknown extends PaytoUriGeneric { - isKnown: false; -} - -/** - * @deprecated use Paytos namespace - */ -export interface PaytoUriIBAN extends PaytoUriGeneric { - isKnown: true; - targetType: "iban"; - iban: string; - bic?: string; -} - -/** - * @deprecated use Paytos namespace - */ -export interface PaytoUriTaler extends PaytoUriGeneric { - isKnown: true; - targetType: "taler-reserve"; - exchange: string; - reservePub: string; -} - -/** - * @deprecated use Paytos namespace - */ -export interface PaytoUriTalerHttp extends PaytoUriGeneric { - isKnown: true; - targetType: "taler-reserve-http"; - exchange: string; - reservePub: string; -} - -/** - * @deprecated use Paytos namespace - */ -export interface PaytoUriTalerBank extends PaytoUriGeneric { - isKnown: true; - targetType: "x-taler-bank"; - host: string; - account: string; -} - -/** - * @deprecated use Paytos namespace - */ -export interface PaytoUriBitcoin extends PaytoUriGeneric { - isKnown: true; - targetType: "bitcoin"; - address: string; - segwitAddrs: Array<string>; -} - -/** - * @deprecated use Paytos namespace - */ -export interface PaytoUriEthereum extends PaytoUriGeneric { - isKnown: true; - targetType: "ethereum"; - address: string; -} - -/** - * @deprecated use Paytos namespace - */ -export interface PaytoUriCyclos extends PaytoUriGeneric { - isKnown: true; - targetType: "cyclos"; - host: string; - account: string; -} export interface WellKnownPaytoParams { amount?: AmountString; @@ -1038,185 +938,3 @@ function createSearchParams(paramList: [string, string][]): string { .map(([key, value]) => `${rfc3986(key)}=${rfc3986(value)}`) .join("&"); } - -/** - * Serialize a PaytoURI into a valid payto:// string - * @deprecated use paytos namespace - * - * @param p - * @returns - */ -export function stringifyPaytoUri(p: PaytoUri): PaytoString { - const url = new URL(`${PAYTO_PREFIX}${p.targetType}/${p.targetPath}`); - const paramList = !p.params ? [] : Object.entries(p.params); - url.search = createSearchParams(paramList); - return url.href as PaytoString; -} - -/** - * Parse a valid payto:// uri into a PaytoUri object - * RFC 8905 - * @deprecated use new Payto namespace functions - * - * @param s - * @returns - */ -export function parsePaytoUri(s: string): PaytoUri | undefined { - if (!s.startsWith(PAYTO_PREFIX)) { - return undefined; - } - - const [acct, search] = s.slice(PAYTO_PREFIX.length).split("?"); - - const firstSlashPos = acct.indexOf("/"); - - if (firstSlashPos === -1) { - return undefined; - } - - const targetType = acct.slice(0, firstSlashPos) as PaytoType; - const targetPath = acct.slice(firstSlashPos + 1); - - const params: { [k: string]: string } = {}; - - const searchParams = new URLSearchParams(search || ""); - - searchParams.forEach((v, k) => { - // URLSearchParams already decodes uri components - params[k] = v; //decodeURIComponent(v); - }); - - switch (targetType) { - case "iban": { - const parts = targetPath.split("/"); - let iban: string | undefined = undefined; - let bic: string | undefined = undefined; - if (parts.length === 1) { - iban = parts[0].toUpperCase(); - } - if (parts.length === 2) { - bic = parts[0]; - iban = parts[1].toUpperCase(); - } else { - iban = targetPath.toUpperCase(); - } - return { - isKnown: true, - targetPath, - targetType, - params, - iban, - bic, - }; - } - case "bitcoin": { - const msg = /\b([A-Z0-9]{52})\b/.exec(params["message"]); - const reserve = !msg ? params["subject"] : msg[0]; - const pubRes = !reserve ? undefined : Paytos.parseReservePub(reserve); - const addr = - !pubRes || !Result.isOk(pubRes) - ? undefined - : generateFakeSegwitAddress(pubRes.value, targetPath); - const segwitAddrs = !addr || !Result.isOk(addr) ? [] : addr.value; - - const result: PaytoUriBitcoin = { - isKnown: true, - targetPath, - targetType, - address: targetPath, - params, - segwitAddrs, - }; - - return result; - } - case "x-taler-bank": { - const parts = targetPath.split("/"); - const host = parts[0]; - const account = parts[parts.length - 1]; - return { - targetPath, - targetType, - params, - isKnown: true, - host, - account, - }; - } - case "cyclos": { - const parts = targetPath.split("/"); - const host = parts[0]; - const account = parts[parts.length - 1]; - const result: PaytoUriCyclos = { - isKnown: true, - targetPath, - targetType, - host, - account, - params, - }; - - return result; - } - case "taler-reserve": { - const parts = targetPath.split("/"); - const exchange = parts[0]; - const reservePub = parts[1]; - return { - targetPath, - targetType, - params, - isKnown: true, - exchange, - reservePub, - }; - } - case "ethereum": { - const result: PaytoUriEthereum = { - isKnown: true, - targetPath, - targetType, - address: targetPath, - params, - }; - return result; - } - default: { - return { - targetPath, - targetType, - params, - isKnown: false, - }; - } - } -} - -/** - * @deprecated do not use this, create a payto object and use stringify - * - * @param exchangeBaseUrl - * @param reservePub - * @returns - */ -export function talerPaytoFromExchangeReserve( - exchangeBaseUrl: string, - reservePub: string, -): string { - const url = new URL(exchangeBaseUrl); - let proto: string; - if (url.protocol === "http:") { - proto = "taler-reserve-http"; - } else if (url.protocol === "https:") { - proto = "taler-reserve"; - } else { - throw Error(`unsupported exchange base URL protocol (${url.protocol})`); - } - - let path = url.pathname; - if (!path.endsWith("/")) { - path = path + "/"; - } - - return `payto://${proto}/${url.host}${url.pathname}${reservePub}`; -} diff --git a/packages/taler-wallet-webextension/src/wallet/DestinationSelection/index.ts b/packages/taler-wallet-webextension/src/wallet/DestinationSelection/index.ts @@ -16,7 +16,6 @@ import { WalletBankAccountInfo, - PaytoUri, ScopeInfo, PaytoString, } from "@gnu-taler/taler-util";