taler-typescript-core

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

commit c92834dd171ff89e8fc95de462fe3a12d9bfddc6
parent 70340843124f74f05eb5e76573dca7ff9300d75a
Author: Florian Dold <dold@taler.net>
Date:   Tue, 10 Nov 2026 16:21:32 +0100

wallet-core: preserve AML changes from KYC responses

Diffstat:
Mpackages/taler-wallet-core/src/exchanges.ts | 14+++++++++++++-
Mpackages/taler-wallet-core/src/kyc.test.ts | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpackages/taler-wallet-core/src/kyc.ts | 3++-
3 files changed, 90 insertions(+), 2 deletions(-)

diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts @@ -5441,7 +5441,19 @@ async function handleExchangeKycPendingLegitimization( return handleExchangeKycSuccess(wex, exchange.baseUrl, nextLimit); } case HttpStatusCode.Accepted: - // FIXME: Do we ever need to update the access token? + await wex.runWalletDbTx(async (tx) => { + const current = await tx.getReserve(reserve.rowId!); + if (!current || current.status !== ReserveRecordStatus.PendingLegi) + return; + if ( + current.amlReview === resp.body.aml_review && + current.kycAccessToken === resp.body.access_token + ) + return; + current.amlReview = resp.body.aml_review; + current.kycAccessToken = resp.body.access_token; + await tx.upsertReserve(current); + }); return TaskRunResult.longpollReturnedPending(); case HttpStatusCode.NoContent: // KYC not configured, so already satisfied diff --git a/packages/taler-wallet-core/src/kyc.test.ts b/packages/taler-wallet-core/src/kyc.test.ts @@ -317,3 +317,78 @@ test("deposit hard limits apply to each exchange contribution", () => { amount: "KUDOS:3", }); }); + +test("an AML-only response change reaches the owning transaction", async () => { + const body = { + aml_review: true, + rule_gen: 7, + access_token: "access-token", + limits: [limit("KUDOS:5" as AmountString, true)], + }; + let waiting = false; + let waitPhases = 0; + const http: HttpRequestLibrary = { + async fetch(url, opt) { + assert.equal(waiting, true); + return { + requestMethod: opt?.method ?? "GET", + requestUrl: url, + status: HttpStatusCode.Accepted, + headers: new HeadersImpl(), + async bytes() { + return new TextEncoder().encode(JSON.stringify(body)); + }, + async json() { + return body; + }, + async text() { + return JSON.stringify(body); + }, + }; + }, + }; + const wex = { + http, + taskExecution: { + async suspend<T>(wait: () => Promise<T>): Promise<T> { + waiting = true; + waitPhases++; + try { + return await wait(); + } finally { + waiting = false; + } + }, + }, + ws: { longpollQueue: new LongpollQueue() }, + cryptoApi: { + async signWalletKycAuth() { + return { sig: "account-signature" }; + }, + }, + } as unknown as WalletExecutionContext; + const state: GenericKycStatusReq = { + accountPriv: "account-private-key", + accountPub: "account-public-key", + amount: "KUDOS:10", + exchangeBaseUrl: "https://exchange.example/", + operation: LimitOperationType.withdraw, + paytoHash: "payto-hash", + lastCheckStatus: HttpStatusCode.Accepted, + lastRuleGen: 7, + lastAmlReview: false, + haveAccessToken: true, + }; + + const result = await runKycCheckAlgo(wex, state); + + assert.equal(waiting, false); + assert.equal(waitPhases, 1); + assert.strictEqual(result.hardLimitExceeded, undefined); + assert.strictEqual(result.updatedStatus?.lastAmlReview, true); + assert.ok(result.updatedStatus); + assert.strictEqual( + result.updatedStatus.lastCheckStatus, + HttpStatusCode.Accepted, + ); +}); diff --git a/packages/taler-wallet-core/src/kyc.ts b/packages/taler-wallet-core/src/kyc.ts @@ -629,7 +629,8 @@ export async function runKycCheckAlgo( const sameResp = status === st.lastCheckStatus && code === st.lastCheckCode && - ruleGen === st.lastRuleGen; + ruleGen === st.lastRuleGen && + amlReview === st.lastAmlReview; const updatedStatus: GenericKycStatusResp["updatedStatus"] = { lastAmlReview: amlReview,