taler-typescript-core

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

commit 8afb4942915e80569e18bd179f5e7e27f133d4c1
parent 47fcbd02c29e18f607f055e9ca24c7394e5f333b
Author: Florian Dold <florian@dold.me>
Date:   Thu,  9 Jul 2026 20:36:52 +0200

remove deprecated merchant API parameters

...plus some other internal deprecation removals as a drive-by change.

Diffstat:
Mpackages/taler-harness/src/harness/environments.ts | 18+++++++++++++-----
Mpackages/taler-harness/src/harness/tops.ts | 15++++++++++-----
Mpackages/taler-harness/src/index.ts | 44++++++++++++++++++++++++++++++++------------
Mpackages/taler-harness/src/integrationtests/test-merchant-kyc-auth-multi.ts | 16+++++++++++-----
Mpackages/taler-harness/src/integrationtests/test-merchant-payto-reuse.ts | 9++++++---
Mpackages/taler-harness/src/integrationtests/test-tops-aml-basic.ts | 16+++++++++++-----
Mpackages/taler-harness/src/integrationtests/test-tops-aml-custom-addr-postal.ts | 23++++++++++++++++-------
Mpackages/taler-harness/src/integrationtests/test-tops-aml-custom-addr-sms.ts | 23++++++++++++++++-------
Mpackages/taler-merchant-webui/src/hooks/instance.ts | 5+----
Mpackages/taler-merchant-webui/src/hooks/order.ts | 2+-
Mpackages/taler-util/src/http-client/bank-core.ts | 16----------------
Mpackages/taler-util/src/http-client/merchant.ts | 23++---------------------
Mpackages/taler-util/src/types-taler-exchange.ts | 65-----------------------------------------------------------------
Mpackages/taler-util/src/types-taler-merchant.ts | 54++++++------------------------------------------------
14 files changed, 125 insertions(+), 204 deletions(-)

diff --git a/packages/taler-harness/src/harness/environments.ts b/packages/taler-harness/src/harness/environments.ts @@ -515,7 +515,7 @@ export function createBrowser(t: GlobalTestState) { const firefoxOpts = new Firefox.Options(); firefoxOpts.addArguments("--headless"); if (process.env.BROWSER_BINARY) { - firefoxOpts.setBinary(process.env.BROWSER_BINARY) + firefoxOpts.setBinary(process.env.BROWSER_BINARY); } const driver = new Builder() .forBrowser(Browser.FIREFOX) @@ -531,7 +531,7 @@ export function createBrowser(t: GlobalTestState) { // chromeOpts.addArguments("--no-sandbox", "--headless","--no-startup-window"); chromeOpts.addArguments(`--incognito`); if (process.env.BROWSER_BINARY) { - chromeOpts.setBinaryPath(process.env.BROWSER_BINARY) + chromeOpts.setBinaryPath(process.env.BROWSER_BINARY); } const driver = new Builder() @@ -1722,9 +1722,17 @@ export async function registerHarnessBankTestUser( `Created test bank account ${username} with password ${password}`, ); const tokRes = succeedOrThrow( - await bankClient.createAccessTokenBasic(username, password, { - scope: "readwrite", - }), + await bankClient.createAccessToken( + username, + { + type: "basic", + username, + password, + }, + { + scope: "readwrite", + }, + ), ); return { password, diff --git a/packages/taler-harness/src/harness/tops.ts b/packages/taler-harness/src/harness/tops.ts @@ -28,7 +28,6 @@ import { hashNormalizedPaytoUri, j2s, KycRule, - KycStatusLongPollingReason, LimitOperationType, MerchantAccountKycRedirectsResponse, MerchantAccountKycStatus, @@ -903,8 +902,11 @@ export async function doTopsKycAuth( const kycStatus = await merchantClient.getCurrentInstanceKycStatus( merchantAdminAccessToken, { - reason: KycStatusLongPollingReason.AUTH_TRANSFER, - timeout: 30000, + longpoll: { + type: "state-exit", + status: MerchantAccountKycStatus.KYC_WIRE_REQUIRED, + timeout: 30000, + }, }, ); logger.info(`kyc status after transfer: ${j2s(kycStatus)}`); @@ -978,8 +980,11 @@ export async function doTopsAcceptTos( const kycStatus = await merchantClient.getCurrentInstanceKycStatus( merchantAdminAccessToken, { - reason: KycStatusLongPollingReason.AUTH_TRANSFER, - timeout: 30000, + longpoll: { + type: "state-enter", + status: MerchantAccountKycStatus.KYC_WIRE_REQUIRED, + timeout: 30000, + }, }, ); logger.info(`kyc status after accept-tos: ${j2s(kycStatus)}`); diff --git a/packages/taler-harness/src/index.ts b/packages/taler-harness/src/index.ts @@ -170,9 +170,17 @@ testingCli `Created test bank account ${username} with password ${password}`, ); const tokRes = succeedOrThrow( - await bank.createAccessTokenBasic(username, password, { - scope: "readwrite", - }), + await bank.createAccessToken( + username, + { + type: "basic", + password, + username, + }, + { + scope: "readwrite", + }, + ), ); const token = tokRes.access_token; const bankAuth = { username, token }; @@ -917,9 +925,13 @@ deploymentCli let bankAdminAuth: TokenAuth | undefined; if (bankAdminPassword) { - const resp = await bank.createAccessTokenBasic( + const resp = await bank.createAccessToken( "admin", - bankAdminPassword, + { + type: "basic", + password: bankAdminPassword, + username: "admin", + }, { scope: "readwrite", duration: { @@ -1127,13 +1139,21 @@ deploymentCli logger.info("random password: ", randomPassword); let token: AccessToken; { - const resp = await bank.createAccessTokenBasic(id, prevPassword, { - scope: "readwrite", - duration: Duration.toTalerProtocolDuration( - Duration.fromSpec({ minutes: 1 }), - ), - refreshable: false, - }); + const resp = await bank.createAccessToken( + id, + { + type: "basic", + password: prevPassword, + username: id, + }, + { + scope: "readwrite", + duration: Duration.toTalerProtocolDuration( + Duration.fromSpec({ minutes: 1 }), + ), + refreshable: false, + }, + ); if (resp.type === "fail") { if (resp.case === HttpStatusCode.Accepted) { console.error( diff --git a/packages/taler-harness/src/integrationtests/test-merchant-kyc-auth-multi.ts b/packages/taler-harness/src/integrationtests/test-merchant-kyc-auth-multi.ts @@ -23,8 +23,8 @@ import { encodeCrock, getRandomBytes, j2s, - KycStatusLongPollingReason, Logger, + MerchantAccountKycStatus, parsePaytoUriOrThrow, succeedOrThrow, TalerMerchantInstanceHttpClient, @@ -149,8 +149,11 @@ async function doAccountKycAuth( const kycStatus = await merchantClient.getCurrentInstanceKycStatus( merchantAccessToken, { - reason: KycStatusLongPollingReason.AUTH_TRANSFER, - timeout: 30000, + longpoll: { + type: "state-exit", + timeout: 30000, + status: MerchantAccountKycStatus.KYC_WIRE_REQUIRED, + }, }, ); logger.info(`kyc status after transfer: ${j2s(kycStatus)}`); @@ -254,8 +257,11 @@ export async function runMerchantKycAuthMultiTest(t: GlobalTestState) { const kycStatus = await merchantClient.getCurrentInstanceKycStatus( merchantAccessToken, { - reason: KycStatusLongPollingReason.AUTH_TRANSFER, - timeout: 30000, + longpoll: { + type: "state-exit", + status: MerchantAccountKycStatus.KYC_WIRE_REQUIRED, + timeout: 30000, + }, }, ); logger.info(`kyc status after transfer: ${j2s(kycStatus)}`); diff --git a/packages/taler-harness/src/integrationtests/test-merchant-payto-reuse.ts b/packages/taler-harness/src/integrationtests/test-merchant-payto-reuse.ts @@ -24,8 +24,8 @@ import { encodeCrock, getRandomBytes, j2s, - KycStatusLongPollingReason, Logger, + MerchantAccountKycStatus, parsePaytoUriOrThrow, PreparePayResultType, succeedOrThrow, @@ -155,8 +155,11 @@ async function doAccountKycAuth( const kycStatus = await merchantClient.getCurrentInstanceKycStatus( merchantAccessToken, { - reason: KycStatusLongPollingReason.AUTH_TRANSFER, - timeout: 30000, + longpoll: { + type: "state-exit", + status: MerchantAccountKycStatus.KYC_WIRE_REQUIRED, + timeout: 30000, + }, }, ); logger.info(`kyc status after transfer: ${j2s(kycStatus)}`); diff --git a/packages/taler-harness/src/integrationtests/test-tops-aml-basic.ts b/packages/taler-harness/src/integrationtests/test-tops-aml-basic.ts @@ -22,8 +22,8 @@ import { encodeCrock, hashNormalizedPaytoUri, j2s, - KycStatusLongPollingReason, Logger, + MerchantAccountKycStatus, parsePaytoUriOrThrow, succeedOrThrow, TalerExchangeHttpClient, @@ -112,8 +112,11 @@ export async function runTopsAmlBasicTest(t: GlobalTestState) { const kycStatus = await merchantClient.getCurrentInstanceKycStatus( merchantAdminAccessToken, { - reason: KycStatusLongPollingReason.AUTH_TRANSFER, // FIXME: deprecated - timeout: 30000, + longpoll: { + type: "state-exit", + status: MerchantAccountKycStatus.KYC_WIRE_REQUIRED, + timeout: 30000, + }, }, ); t.assertTrue(kycStatus.type === "ok"); @@ -170,8 +173,11 @@ export async function runTopsAmlBasicTest(t: GlobalTestState) { const kycStatus = await merchantClient.getCurrentInstanceKycStatus( merchantAdminAccessToken, { - reason: KycStatusLongPollingReason.AUTH_TRANSFER, // FIXME: deprecated - timeout: 30000, + longpoll: { + type: "state-enter", + status: MerchantAccountKycStatus.KYC_WIRE_REQUIRED, + timeout: 30000, + }, }, ); logger.info(`kyc status after accept-tos: ${j2s(kycStatus)}`); diff --git a/packages/taler-harness/src/integrationtests/test-tops-aml-custom-addr-postal.ts b/packages/taler-harness/src/integrationtests/test-tops-aml-custom-addr-postal.ts @@ -22,8 +22,8 @@ import { encodeCrock, hashNormalizedPaytoUri, j2s, - KycStatusLongPollingReason, Logger, + MerchantAccountKycStatus, parsePaytoUriOrThrow, succeedOrThrow, TalerExchangeHttpClient, @@ -64,8 +64,11 @@ export async function runTopsAmlCustomAddrPostalTest(t: GlobalTestState) { const kycStatus = await merchantClient.getCurrentInstanceKycStatus( merchantAdminAccessToken, { - reason: KycStatusLongPollingReason.AUTH_TRANSFER, // FIXME: deprecated - timeout: 30000, + longpoll: { + type: "state-enter", + status: MerchantAccountKycStatus.KYC_WIRE_REQUIRED, + timeout: 30000, + }, }, ); t.assertTrue(kycStatus.type === "ok"); @@ -102,8 +105,11 @@ export async function runTopsAmlCustomAddrPostalTest(t: GlobalTestState) { const kycStatus = await merchantClient.getCurrentInstanceKycStatus( merchantAdminAccessToken, { - reason: KycStatusLongPollingReason.AUTH_TRANSFER, // FIXME: deprecated - timeout: 30000, + longpoll: { + type: "state-exit", + status: MerchantAccountKycStatus.KYC_WIRE_REQUIRED, + timeout: 30000, + }, }, ); t.assertTrue(kycStatus.type === "ok"); @@ -164,8 +170,11 @@ export async function runTopsAmlCustomAddrPostalTest(t: GlobalTestState) { const kycStatus = await merchantClient.getCurrentInstanceKycStatus( merchantAdminAccessToken, { - reason: KycStatusLongPollingReason.AUTH_TRANSFER, // FIXME: deprecated - timeout: 30000, + longpoll: { + type: "state-enter", + status: MerchantAccountKycStatus.KYC_WIRE_REQUIRED, + timeout: 30000, + }, }, ); diff --git a/packages/taler-harness/src/integrationtests/test-tops-aml-custom-addr-sms.ts b/packages/taler-harness/src/integrationtests/test-tops-aml-custom-addr-sms.ts @@ -23,8 +23,8 @@ import { encodeCrock, hashNormalizedPaytoUri, j2s, - KycStatusLongPollingReason, Logger, + MerchantAccountKycStatus, OfficerId, OfficerSession, parsePaytoUriOrThrow, @@ -67,8 +67,11 @@ export async function runTopsAmlCustomAddrSmsTest(t: GlobalTestState) { const kycStatus = await merchantClient.getCurrentInstanceKycStatus( merchantAdminAccessToken, { - reason: KycStatusLongPollingReason.AUTH_TRANSFER, // FIXME: deprecated - timeout: 30000, + longpoll: { + type: "state-enter", + status: MerchantAccountKycStatus.KYC_WIRE_REQUIRED, + timeout: 30000, + }, }, ); t.assertTrue(kycStatus.type === "ok"); @@ -105,8 +108,11 @@ export async function runTopsAmlCustomAddrSmsTest(t: GlobalTestState) { const kycStatus = await merchantClient.getCurrentInstanceKycStatus( merchantAdminAccessToken, { - reason: KycStatusLongPollingReason.AUTH_TRANSFER, // FIXME: deprecated - timeout: 30000, + longpoll: { + type: "state-exit", + status: MerchantAccountKycStatus.KYC_WIRE_REQUIRED, + timeout: 30000, + }, }, ); t.assertTrue(kycStatus.type === "ok"); @@ -168,8 +174,11 @@ export async function runTopsAmlCustomAddrSmsTest(t: GlobalTestState) { const kycStatus = await merchantClient.getCurrentInstanceKycStatus( merchantAdminAccessToken, { - reason: KycStatusLongPollingReason.AUTH_TRANSFER, // FIXME: deprecated - timeout: 30000, + longpoll: { + type: "state-enter", + status: MerchantAccountKycStatus.KYC_WIRE_REQUIRED, + timeout: 30000, + }, }, ); logger.info(`kyc status after accept-tos: ${j2s(kycStatus)}`); diff --git a/packages/taler-merchant-webui/src/hooks/instance.ts b/packages/taler-merchant-webui/src/hooks/instance.ts @@ -16,7 +16,6 @@ import { AccessToken, - CurrencySpecification, getMerchantAccountKycStatusSimplified, MerchantAccountKycStatus, MerchantAccountKycStatusSimplified, @@ -30,8 +29,6 @@ import { useSessionContext } from "../context/session.js"; // Fix default import https://github.com/microsoft/TypeScript/issues/49189 import _useSWR, { mutate, SWRHook } from "swr"; -import { useEffect } from "preact/hooks"; -import { useState } from "preact/hooks"; const useSWR = _useSWR as unknown as SWRHook; export function revalidateInstanceDetails() { @@ -105,7 +102,7 @@ export function useInstanceKYCDetailsLongPolling() { etag: latestData.body.etag, timeout: LONG_POLL_DELAY, }, - ct, + cancellationToken: ct, }); await mutate(r, { revalidate: false }); return r; diff --git a/packages/taler-merchant-webui/src/hooks/order.ts b/packages/taler-merchant-webui/src/hooks/order.ts @@ -88,7 +88,7 @@ export function useOrderDetailsWithLongPoll(orderId: string) { etag: latestStatus.body.etag!, timeout: LONG_POLL_DELAY, }, - ct, + cancellationToken: ct, }); await mutate(r, { revalidate: false }); return r; diff --git a/packages/taler-util/src/http-client/bank-core.ts b/packages/taler-util/src/http-client/bank-core.ts @@ -210,22 +210,6 @@ export class TalerCoreBankHttpClient { } /** - * @deprecated use createAccessToken - * https://docs.taler.net/core/api-corebank.html#post--accounts-$USERNAME-token - */ - async createAccessTokenBasic( - username: string, - password: string, - body: TokenRequest, - ) { - return this.createAccessToken( - username, - { type: "basic", username, password }, - body, - ); - } - - /** * https://docs.taler.net/core/api-corebank.html#delete--accounts-$USERNAME-token */ async deleteAccessToken(user: string, token: AccessToken) { diff --git a/packages/taler-util/src/http-client/merchant.ts b/packages/taler-util/src/http-client/merchant.ts @@ -961,20 +961,12 @@ export class TalerMerchantInstanceHttpClient { assertUnreachable(params.longpoll); } url.searchParams.set("timeout_ms", String(params.longpoll.timeout)); - } else { - // backward compat, prefer longpoll - if (params.timeout) { - url.searchParams.set("timeout_ms", String(params.timeout)); - } - if (params.reason) { - url.searchParams.set("lpt", String(params.reason)); - } } if (token) { headers.Authorization = makeBearerTokenAuthHeader(token); } - const cancellationToken = params.ct ?? this.cancellationToken; + const cancellationToken = params.cancellationToken ?? this.cancellationToken; const resp = await this.httpLib.fetch(url.href, { method: "GET", headers, @@ -1854,26 +1846,18 @@ export class TalerMerchantInstanceHttpClient { if (params.sessionId) { url.searchParams.set("session_id", params.sessionId); } - if (params.timeout) { - url.searchParams.set("timeout_ms", String(params.timeout)); - } const headers: Record<string, string> = {}; if (params.longpoll) { url.searchParams.set("lp_not_etag", params.longpoll.etag); headers["If-none-match"] = `"${params.longpoll.etag}"`; url.searchParams.set("timeout_ms", String(params.longpoll.timeout)); - } else { - // backward compat, prefer longpoll - if (params.timeout) { - url.searchParams.set("timeout_ms", String(params.timeout)); - } } if (token) { headers.Authorization = makeBearerTokenAuthHeader(token); } - const cancellationToken = params.ct ?? this.cancellationToken; + const cancellationToken = params.cancellationToken ?? this.cancellationToken; const resp = await this.httpLib.fetch(url.href, { method: "GET", headers, @@ -3928,9 +3912,6 @@ export class TalerMerchantManagementHttpClient extends TalerMerchantInstanceHttp if (params.exchangeURL) { url.searchParams.set("exchange_url", params.exchangeURL); } - if (params.timeout) { - url.searchParams.set("timeout_ms", String(params.timeout)); - } const headers: Record<string, string> = {}; if (token) { diff --git a/packages/taler-util/src/types-taler-exchange.ts b/packages/taler-util/src/types-taler-exchange.ts @@ -1386,71 +1386,6 @@ export interface ExchangePurseDeposits { deposits: PurseDeposit[]; } -/** - * @deprecated batch deposit should be used. - */ -export interface ExchangeDepositRequest { - // Amount to be deposited, can be a fraction of the - // coin's total value. - contribution: AmountString; - - // The merchant's account details. - // In case of an auction policy, it refers to the seller. - merchant_payto_uri: string; - - // The salt is used to hide the payto_uri from customers - // when computing the h_wire of the merchant. - wire_salt: string; - - // SHA-512 hash of the contract of the merchant with the customer. Further - // details are never disclosed to the exchange. - h_contract_terms: HashCodeString; - - // Hash of denomination RSA key with which the coin is signed. - denom_pub_hash: HashCodeString; - - // Exchange's unblinded RSA signature of the coin. - ub_sig: UnblindedDenominationSignature; - - // Timestamp when the contract was finalized. - timestamp: TalerProtocolTimestamp; - - // Indicative time by which the exchange undertakes to transfer the funds to - // the merchant, in case of successful payment. A wire transfer deadline of 'never' - // is not allowed. - wire_transfer_deadline: TalerProtocolTimestamp; - - // EdDSA public key of the merchant, so that the client can identify the - // merchant for refund requests. - // - // THIS FIELD WILL BE DEPRECATED, once the refund mechanism becomes a - // policy via extension. - merchant_pub: EddsaPublicKeyString; - - // Date until which the merchant can issue a refund to the customer via the - // exchange, to be omitted if refunds are not allowed. - // - // THIS FIELD WILL BE DEPRECATED, once the refund mechanism becomes a - // policy via extension. - refund_deadline?: TalerProtocolTimestamp; - - // CAVEAT: THIS IS WORK IN PROGRESS - // (Optional) policy for the deposit. - // This might be a refund, auction or escrow policy. - // - // Note that support for policies is an optional feature of the exchange. - // Optional features are so called "extensions" in Taler. The exchange - // provides the list of supported extensions, including policies, in the - // ExtensionsManifestsResponse response to the /keys endpoint. - policy?: any; - - // Signature over TALER_DepositRequestPS, made by the customer with the - // coin's private key. - coin_sig: EddsaSignatureString; - - h_age_commitment?: string; -} - export type TrackTransaction = | ({ type: "accepted" } & TrackTransactionAccepted) | ({ type: "wired" } & TrackTransactionWired); diff --git a/packages/taler-util/src/types-taler-merchant.ts b/packages/taler-util/src/types-taler-merchant.ts @@ -1431,24 +1431,6 @@ export interface PaymentStatusRequestParams { allowRefundedForRepurchase?: boolean; } -/** - * @deprecated use KycLongPollingReason - */ -export enum KycStatusLongPollingReason { - /** - * Waiting for an account to receive the wire transfer - */ - AUTH_TRANSFER = 1, - /** - * Waiting for an account on aml investigation to be completed - */ - AML_INVESTIGATION = 2, - /** - * Waiting for an account to be ready to be used - */ - TO_BE_OK = 3, -} - export type KycLongPollingReason = | KycLongPollingReasonWaitForStateEnter | KycLongPollingReasonWaitForStateExit @@ -1480,40 +1462,24 @@ export interface GetKycStatusRequestParams { // the KYC status only for this wire account. // Otherwise, for all wire accounts. wireHash?: string; + // If specified, the KYC check should return // the KYC status only for the given exchange. // Otherwise, for all exchanges we interacted with. exchangeURL?: string; /** - * @deprecated use longpoll - * If specified, the merchant will wait up to - * timeout_ms milliseconds for the exchanges to - * confirm completion of the KYC process(es). - */ - timeout?: number; - - /** - * @deprecated use longpoll - * Specifies what status change we are long-polling for. - * Use 1 to wait for the KYC auth transfer (access token available), - * 2 to wait for an AML investigation to be done, - * and 3 to wait for the KYC status to be OK. If multiple accounts - * or exchanges match the query, any account reaching the TARGET - * state will cause the response to be returned. - */ - reason?: KycStatusLongPollingReason; - - /** * */ longpoll?: KycLongPollingReason; - ct?: CancellationToken; + cancellationToken?: CancellationToken; } + export type OrderDetailLongPollingReason = { etag: string; timeout: number; }; + export interface GetOtpDeviceRequestParams { // Timestamp in seconds to use when calculating // the current OTP code of the device. Since protocol v10. @@ -1522,20 +1488,12 @@ export interface GetOtpDeviceRequestParams { // code of the device. Since protocol v10. price?: AmountString; } + export interface GetOrderRequestParams { // Session ID that the payment must be bound to. // If not specified, the payment is not session-bound. sessionId?: string; - /** - * @deprecated use longpoll - * Timeout in milliseconds to wait for a payment if - * the answer would otherwise be negative (long polling). - */ - timeout?: number; - /** - * - */ longpoll?: OrderDetailLongPollingReason; // Since protocol v9 refunded orders are only returned @@ -1543,7 +1501,7 @@ export interface GetOrderRequestParams { // explicitly to “YES”. allowRefundedForRepurchase?: boolean; - ct?: CancellationToken; + cancellationToken?: CancellationToken; } export interface ListConfirmedWireTransferRequestParams { /**