commit d4eb77afbfaebd12db1b83c45aaa1705e28eab27
parent 2536a6504a299d2310d894c9969b3f5d58299990
Author: Sebastian <sebasjm@taler-systems.com>
Date: Wed, 24 Jun 2026 16:12:36 -0300
fix #11550
Diffstat:
3 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/packages/taler-util/src/result.ts b/packages/taler-util/src/result.ts
@@ -45,7 +45,7 @@ export const Result = {
},
unpack<T, Err>(r: Result<T, Err>): T {
if (r.tag !== "ok") {
- throw Error("expected success result");
+ throw Error(`expected success, code: ${r.error} - ` + JSON.stringify(r.detail));
}
return r.value;
},
diff --git a/packages/taler-util/src/taleruri.ts b/packages/taler-util/src/taleruri.ts
@@ -577,6 +577,12 @@ function parsePayPush(
// get contract priv
const contractPriv = cs[cs.length - 1]; // FIXME: validate private key
+ if (!opts.ignoreComponentError && !contractPriv) {
+ return Result.errorWithDetail(TalerUriParseError.COMPONENTS_LENGTH, {
+ uriType,
+ });
+ }
+
return Result.of({
type: TalerUriAction.PayPush,
exchangeBaseUrl: exchange ?? (cs[0] as HostPortPath),
@@ -613,6 +619,11 @@ function parsePayPull(
}
// get contract priv
const contractPriv = cs[cs.length - 1]; // FIXME: validate private key
+ if (!opts.ignoreComponentError && !contractPriv) {
+ return Result.errorWithDetail(TalerUriParseError.COMPONENTS_LENGTH, {
+ uriType,
+ });
+ }
return Result.of({
type: TalerUriAction.PayPull,
diff --git a/packages/taler-util/src/taleruris.test.ts b/packages/taler-util/src/taleruris.test.ts
@@ -277,6 +277,16 @@ test("taler-new peer to peer push URI", (t) => {
assert.strictEqual(r1.contractPriv, "foo");
});
+test("taler-new peer to peer push URI, merge_priv is mandatory", (t) => {
+ const url1 = "taler://pay-push/exch.example.com/";
+ // const r1 = parsePayPushUri(url1);
+ assert.throws(() => {
+ Result.unpack(TalerUris.parse(url1))
+ });
+ return;
+ }
+);
+
test("taler-new peer to peer push URI (path)", (t) => {
const url1 = "taler://pay-push/exch.example.com:123/bla/foo";
const r1 = Result.unpack(TalerUris.parse(url1));
@@ -334,6 +344,16 @@ test("taler-new peer to peer pull URI", (t) => {
assert.strictEqual(r1.contractPriv, "foo");
});
+test("taler-new peer to peer pull URI, contract_priv is mandatory", (t) => {
+ const url1 = "taler://pay-pull/exch.example.com/";
+ // const r1 = parsePayPushUri(url1);
+ assert.throws(() => {
+ Result.unpack(TalerUris.parse(url1))
+ });
+ return;
+ }
+);
+
test("taler-new peer to peer pull URI (path)", (t) => {
const url1 = "taler://pay-pull/exch.example.com:123/bla/foo";
const r1 = Result.unpack(TalerUris.parse(url1));