taler-typescript-core

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

commit 2b91170b3480fe230055d0766ff888612d5b3bc5
parent bec18897cc7344c077be019b84d560d8716c4deb
Author: Sebastian <sebasjm@taler-systems.com>
Date:   Mon, 27 Apr 2026 11:02:31 -0300

test with nodejs crypto

Diffstat:
Mpackages/taler-harness/src/integrationtests/test-paivana.ts | 23+++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/packages/taler-harness/src/integrationtests/test-paivana.ts b/packages/taler-harness/src/integrationtests/test-paivana.ts @@ -36,6 +36,7 @@ import { withdrawViaBankV3 } from "../harness/environments.js"; import { GlobalTestState } from "../harness/harness.js"; +import { createHash } from "node:crypto"; const harnessHttpLib = createPlatformHttpLib({ enableThrottling: false, @@ -78,14 +79,24 @@ export async function runPaivanaTest(t: GlobalTestState) { const uri = Result.unpack(TalerUris.fromString(templateURI)) t.assertTrue(uri.type === TalerUriAction.PayTemplate) - const cur_time = Math.floor(Date.now() / 1000);// + 60*60*24; - const nonce = Array.from(new Uint8Array(32)) - .map(b => b.toString(16).padStart(2, '0')).join(''); + const cur_time = Math.floor(Date.now() / 1000);// + 60*60*24; - const sha = bytesToString(sha256(stringToBytes(nonce + website + cur_time))) - const hash = base64Url(sha) - const paivanaId = (`${cur_time}-${hash}`) + // not so random + const nonce = Array.from(new Uint8Array(32)) + .map(b => b.toString(16).padStart(2, '0')).join(''); + + // const sha = bytesToString(sha256(stringToBytes(nonce + website + cur_time))) + // const hash = base64Url(sha) + + // using nodejs crypto lib + const hash = createHash('sha256') + .update(nonce + website + cur_time) + .digest("base64") + .replace(/\+/g, '-') + .replace(/\//g, '_') + .replace(/=+$/, ''); + const paivanaId = `${cur_time}-${hash}` logger.info("PAIVANA TEMPLATE ID::", paivanaId); const PAIVANA_POLL_BASE = `${website}/.well-known/paivana/sessions/${encodeURIComponent(paivanaId)}`;