taler-typescript-core

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

commit 52abcdb8ac02a1921a5beb5c306189123ed63643
parent 7d8d550a9d6679eb10a4d09de83664fb701a04bf
Author: Florian Dold <dold@taler.net>
Date:   Tue, 21 Jul 2026 10:50:43 +0200

util: test that account restrictions match the normalized payto

The regex applies to the normalized URI, so a receiver-name parameter, a
lower-case IBAN with separators and an upper-case target type must not
change the verdict.

Diffstat:
Mpackages/taler-util/src/account-restrictions.test.ts | 30++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+), 0 deletions(-)

diff --git a/packages/taler-util/src/account-restrictions.test.ts b/packages/taler-util/src/account-restrictions.test.ts @@ -50,6 +50,36 @@ test("account restriction: unknown type fails closed", (t) => { assert.strictEqual(checkAccountRestriction(payto, [unknown]).ok, false); }); +test("account restriction: regex is matched against the normalized payto", (t) => { + // Banks routinely hand out payto URIs carrying a receiver-name parameter, + // and IBANs written in lower case or with separators. The regex applies + // to the normalized URI, so none of that may change the verdict. + const restrictions: AccountRestriction[] = [ + { + type: "regex", + payto_regex: "^payto://iban/CH[0-9A-Z]+$", + human_hint: "CH only", + }, + ]; + for (const variant of [ + "payto://iban/CH9300762011623852957", + "payto://iban/CH9300762011623852957?receiver-name=Alice", + "payto://iban/ch93-0076-2011-6238-5295-7", + "payto://IBAN/CH9300762011623852957", + ]) { + assert.strictEqual( + checkAccountRestriction(variant, restrictions).ok, + true, + variant, + ); + } + assert.strictEqual( + checkAccountRestriction("payto://iban/DE75512108001245126199", restrictions) + .ok, + false, + ); +}); + test("account restriction: malformed regex fails closed, does not throw", (t) => { const bad: AccountRestriction = { type: "regex",