taler-typescript-core

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

commit 5c66655f9b95bf9628f18630d135439c88a82b88
parent c7ba2cdd8b68970633a89edb1017319caae229b0
Author: Sebastian <sebasjm@gmail.com>
Date:   Thu, 12 Jun 2025 11:47:39 -0300

fix #10031: spa now have a new list kyc-auth

Diffstat:
Mpackages/aml-backoffice-ui/src/hooks/transfers.ts | 62++++++++++++++++++++++++++++++++++++++++++++------------------
Mpackages/aml-backoffice-ui/src/pages/Transfers.tsx | 9++++++---
Mpackages/taler-util/src/http-client/exchange-client.ts | 70+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
3 files changed, 117 insertions(+), 24 deletions(-)

diff --git a/packages/aml-backoffice-ui/src/hooks/transfers.ts b/packages/aml-backoffice-ui/src/hooks/transfers.ts @@ -20,6 +20,7 @@ import { AmountJson, OfficerAccount, OperationOk, + PaytoHash, TalerExchangeResultByMethod2, TalerHttpError, } from "@gnu-taler/taler-util"; @@ -80,6 +81,7 @@ export function useTransferDebit() { ); } +type Direction = "credit" | "debit" | "kyc-auth"; /** * @param args * @returns @@ -87,7 +89,12 @@ export function useTransferDebit() { export function useTransferList({ direction, threshold, -}: { direction?: "credit" | "debit"; threshold?: AmountJson } = {}) { + account +}: { + direction?: "credit" | "debit" | "kyc-auth"; + threshold?: AmountJson; + account?: PaytoHash +} = {}) { const officer = useOfficer(); const session = officer.state === "ready" ? officer.account : undefined; const { @@ -95,28 +102,40 @@ export function useTransferList({ } = useExchangeApiContext(); const [offset, setOffset] = useState<string>(); - const isDebit = "debit" === direction; - async function fetcher([officer, offset, isDebit, threshold]: [ + async function fetcher([officer, offset, direction, threshold, account]: [ OfficerAccount, string, - boolean, + Direction, AmountJson | undefined, + PaytoHash | undefined ]) { - if (isDebit) { - return await api.getTransfersDebit(officer, { - order: "dec", - offset, - limit: PAGINATED_LIST_REQUEST, - threshold, - }); + switch (direction) { + case "credit": { + return await api.getTransfersCredit(officer, { + order: "dec", + offset, + limit: PAGINATED_LIST_REQUEST, + threshold, + }); + } + case "debit": { + return await api.getTransfersDebit(officer, { + order: "dec", + offset, + limit: PAGINATED_LIST_REQUEST, + threshold, + }); + } + case "kyc-auth": { + return await api.getTransfersKycAuth(officer, { + order: "dec", + offset, + limit: PAGINATED_LIST_REQUEST, + threshold, + }); + } } - return await api.getTransfersCredit(officer, { - order: "dec", - offset, - limit: PAGINATED_LIST_REQUEST, - threshold, - }); } const { data, error } = useSWR< @@ -125,7 +144,14 @@ export function useTransferList({ >( !session ? undefined - : [session, offset, isDebit, threshold, "getTransfersCredit"], + : [ + session, + offset, + direction ?? "debit", + threshold, + account, + "getTransfers", + ], fetcher, ); diff --git a/packages/aml-backoffice-ui/src/pages/Transfers.tsx b/packages/aml-backoffice-ui/src/pages/Transfers.tsx @@ -35,7 +35,7 @@ export function Transfers({ const { config } = useExchangeApiContext(); type FormType = { - direction: "credit" | "debit"; + direction: "credit" | "debit" | "kyc-auth"; threshold: AmountJson; }; const design: FormDesign = { @@ -54,6 +54,10 @@ export function Transfers({ label: i18n.str`Debit`, value: "debit", }, + { + label: i18n.str`KYC Auth`, + value: "kyc-auth", + }, ], }, { @@ -73,8 +77,7 @@ export function Transfers({ ); const direction = form.status.result.direction as - | "credit" - | "debit" + | FormType["direction"] | undefined; const threshold = form.status.result.threshold; diff --git a/packages/taler-util/src/http-client/exchange-client.ts b/packages/taler-util/src/http-client/exchange-client.ts @@ -46,6 +46,7 @@ import { LongPollParams, OfficerAccount, PaginationParams, + PaytoHash, codecForTalerCommonConfigResponse, } from "../types-taler-common.js"; import { @@ -1008,7 +1009,7 @@ export class TalerExchangeHttpClient { async getAmlDecisions( auth: OfficerAccount, params: PaginationParams & { - account?: string; + account?: PaytoHash; active?: boolean; investigation?: boolean; } = {}, @@ -1153,7 +1154,10 @@ export class TalerExchangeHttpClient { */ async getTransfersCredit( auth: OfficerAccount, - params: PaginationParams & { threshold?: AmountJson } = {}, + params: PaginationParams & { + threshold?: AmountJson; + account?: PaytoHash; + } = {}, ): Promise< | OperationOk<ExchangeTransferList> | OperationFail< @@ -1169,6 +1173,9 @@ export class TalerExchangeHttpClient { if (params.threshold) { url.searchParams.set("threshold", Amounts.stringify(params.threshold)); } + if (params.account) { + url.searchParams.set("h_payto", Amounts.stringify(params.account)); + } const resp = await this.fetch(url, { headers: { @@ -1198,7 +1205,10 @@ export class TalerExchangeHttpClient { */ async getTransfersDebit( auth: OfficerAccount, - params: PaginationParams & { threshold?: AmountJson } = {}, + params: PaginationParams & { + threshold?: AmountJson; + account?: PaytoHash; + } = {}, ): Promise< | OperationOk<ExchangeTransferList> | OperationFail< @@ -1214,6 +1224,60 @@ export class TalerExchangeHttpClient { if (params.threshold) { url.searchParams.set("threshold", Amounts.stringify(params.threshold)); } + if (params.account) { + url.searchParams.set("h_payto", Amounts.stringify(params.account)); + } + + const resp = await this.fetch(url, { + headers: { + "Taler-AML-Officer-Signature": encodeCrock( + signAmlQuery(auth.signingKey), + ), + }, + }); + + switch (resp.status) { + case HttpStatusCode.Ok: + return opSuccessFromHttp(resp, codecForExchangeTransferList()); + case HttpStatusCode.NoContent: + return opFixedSuccess({ transfers: [] }); + case HttpStatusCode.Forbidden: + case HttpStatusCode.NotFound: + case HttpStatusCode.Conflict: + return opKnownHttpFailure(resp.status, resp); + default: + return opUnknownHttpFailure(resp); + } + } + + /** + * https://docs.taler.net/core/api-exchange.html#get--aml-$OFFICER_PUB-transfers-kycauth + * + */ + async getTransfersKycAuth( + auth: OfficerAccount, + params: PaginationParams & { + threshold?: AmountJson; + account?: PaytoHash; + } = {}, + ): Promise< + | OperationOk<ExchangeTransferList> + | OperationFail< + | HttpStatusCode.Forbidden + | HttpStatusCode.NotFound + | HttpStatusCode.Conflict + > + > { + const url = new URL(`aml/${auth.id}/transfers-kycauth`, this.baseUrl); + + addPaginationParams(url, params); + + if (params.threshold) { + url.searchParams.set("threshold", Amounts.stringify(params.threshold)); + } + if (params.account) { + url.searchParams.set("h_payto", Amounts.stringify(params.account)); + } const resp = await this.fetch(url, { headers: {