taler-typescript-core

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

commit 250206d6e9d57eb576091aed86ac051c16053329
parent b2ae1bbf6af45dead5beda488c473bd0dc71059a
Author: Florian Dold <florian@dold.me>
Date:   Mon, 23 Sep 2024 18:53:29 +0200

wallet-core: report full kyc auth payto

Diffstat:
Mpackages/taler-harness/src/integrationtests/test-kyc-deposit-deposit-kyctransfer.ts | 10++++++++++
Mpackages/taler-wallet-core/src/deposits.ts | 17+++++++++++++----
Mpackages/taler-wallet-core/src/withdraw.ts | 13+++++++++++++
3 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/test-kyc-deposit-deposit-kyctransfer.ts b/packages/taler-harness/src/integrationtests/test-kyc-deposit-deposit-kyctransfer.ts @@ -19,6 +19,7 @@ */ import { Logger, + parsePaytoUri, TalerCorebankApiClient, TransactionMajorState, TransactionMinorState, @@ -312,6 +313,15 @@ export async function runKycDepositDepositKyctransferTest(t: GlobalTestState) { }, ); + { + const kycAuthCreditPayto = + txDetails.kycAuthTransferInfo?.creditPaytoUris[0]; + t.assertTrue(!!kycAuthCreditPayto); + const p = parsePaytoUri(kycAuthCreditPayto); + t.assertTrue(!!p); + t.assertAmountEquals(p.params["amount"], "TESTKUDOS:0.01"); + } + const kycPaytoHash = txDetails.kycPaytoHash; t.assertTrue(!!kycPaytoHash); diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts @@ -130,6 +130,7 @@ import { parseTransactionIdentifier, } from "./transactions.js"; import { WalletExecutionContext, getDenomInfo } from "./wallet.js"; +import { augmentPaytoUrisForKycTransfer } from "./withdraw.js"; /** * Logger. @@ -210,21 +211,29 @@ export class DepositTransactionContext implements TransactionContext { if (!dg.kycInfo) { break; } - const creditPaytoUris: string[] = []; + const plainCreditPaytoUris: string[] = []; const exchangeWire = await getExchangeWireDetailsInTx( tx, dg.kycInfo.exchangeBaseUrl, ); if (exchangeWire) { - // FIXME: Add subject, amount for (const acc of exchangeWire.wireInfo.accounts) { - creditPaytoUris.push(acc.payto_uri); + if (acc.conversion_url) { + // Conversion accounts do not work for KYC auth! + continue; + } + plainCreditPaytoUris.push(acc.payto_uri); } } kycAuthTransferInfo = { debitPaytoUri: dg.wire.payto_uri, accountPub: dg.merchantPub, - creditPaytoUris, + creditPaytoUris: augmentPaytoUrisForKycTransfer( + plainCreditPaytoUris, + dg.kycInfo?.paytoHash, + // FIXME: Query tiny amount from exchange. + `${dg.currency}:0.01`, + ), }; break; } diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts @@ -2672,6 +2672,19 @@ export function augmentPaytoUrisForWithdrawal( ); } +export function augmentPaytoUrisForKycTransfer( + plainPaytoUris: string[], + reservePub: string, + tinyAmount: AmountLike, +): string[] { + return plainPaytoUris.map((x) => + addPaytoQueryParams(x, { + amount: Amounts.stringify(tinyAmount), + message: `Taler KYC ${reservePub}`, + }), + ); +} + /** * Get payto URIs that can be used to fund a withdrawal operation. */