taler-typescript-core

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

commit ca821acf48f8e08284be17e6e200fb53ccbd4323
parent 487357341ff4b4c6ba9587dcf40d766ef43c7766
Author: Florian Dold <florian@dold.me>
Date:   Thu,  9 Oct 2025 15:28:30 +0200

donau: make setDonau idempotent

Diffstat:
Mpackages/taler-wallet-core/src/donau.ts | 14+++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/packages/taler-wallet-core/src/donau.ts b/packages/taler-wallet-core/src/donau.ts @@ -165,12 +165,24 @@ export async function handleSetDonau( // FIXME: This should be idempotent, do not re-salt // for same taxpayer ID. const salt = getRandomBytes(32); - // FIXME: Where is the salted hashing for this specified? + // Hashing as defined in lsd0013. const idHasher = createHashContext(); idHasher.update(stringToBytes(req.taxPayerId + "\0")); idHasher.update(stringToBytes(encodeCrock(salt) + "\0")); const saltedId = idHasher.finish(); await wex.db.runAllStoresReadWriteTx({}, async (tx) => { + const oldRec = await WalletDbHelpers.getConfig( + tx, + ConfigRecordKey.DonauConfig, + ); + if ( + oldRec && + oldRec.value.donauBaseUrl === req.donauBaseUrl && + oldRec.value.donauTaxId === req.taxPayerId + ) { + // Be idempotent, re-use old salt. + return; + } await tx.config.put({ key: ConfigRecordKey.DonauConfig, value: {