[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: fix and test case for "insecu
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: fix and test case for "insecure" taler://refund URIs |
Date: |
Sat, 18 Jan 2020 23:32:21 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new af57a404 fix and test case for "insecure" taler://refund URIs
af57a404 is described below
commit af57a404d070500ce63ed9ed0dfce721e82e4801
Author: Florian Dold <address@hidden>
AuthorDate: Sat Jan 18 23:32:03 2020 +0100
fix and test case for "insecure" taler://refund URIs
---
src/headless/integrationtest.ts | 2 ++
src/operations/pay.ts | 1 +
src/operations/refund.ts | 4 ++--
src/util/taleruri-test.ts | 15 +++++++++++++--
src/util/taleruri.ts | 17 ++++++++++-------
src/wallet.ts | 25 +++++++++++++++++++++++++
6 files changed, 53 insertions(+), 11 deletions(-)
diff --git a/src/headless/integrationtest.ts b/src/headless/integrationtest.ts
index b00fa5cc..ee52c4c4 100644
--- a/src/headless/integrationtest.ts
+++ b/src/headless/integrationtest.ts
@@ -171,6 +171,8 @@ export async function runIntegrationTest(args:
IntegrationTestArgs) {
Amounts.toString(refundAmount),
);
+ console.log("refund URI", refundUri);
+
await myWallet.applyRefund(refundUri);
// Wait until the refund is done
diff --git a/src/operations/pay.ts b/src/operations/pay.ts
index 098e6e18..c5a34418 100644
--- a/src/operations/pay.ts
+++ b/src/operations/pay.ts
@@ -1093,6 +1093,7 @@ export async function confirmPay(
);
logger.trace("confirmPay: submitting payment after creating purchase
record");
+ logger.trace("purchaseRecord:", purchase);
return submitPay(ws, proposalId);
}
diff --git a/src/operations/refund.ts b/src/operations/refund.ts
index 6a96868a..27d83230 100644
--- a/src/operations/refund.ts
+++ b/src/operations/refund.ts
@@ -271,7 +271,7 @@ export async function applyRefund(
): Promise<string> {
const parseResult = parseRefundUri(talerRefundUri);
- console.log("applying refund");
+ console.log("applying refund", parseResult);
if (!parseResult) {
throw Error("invalid refund URI");
@@ -283,7 +283,7 @@ export async function applyRefund(
]);
if (!purchase) {
- throw Error("no purchase for the taler://refund/ URI was found");
+ throw Error(`no purchase for the taler://refund/ URI (${talerRefundUri})
was found`);
}
console.log("processing purchase for refund");
diff --git a/src/util/taleruri-test.ts b/src/util/taleruri-test.ts
index de4a9069..052581a9 100644
--- a/src/util/taleruri-test.ts
+++ b/src/util/taleruri-test.ts
@@ -96,7 +96,7 @@ test("taler pay url parsing: complex path prefix", t => {
t.is(r1.sessionId, undefined);
});
-test("taler pay url parsing: complex path prefix and instance", t => {
+test("taler pay uri parsing: complex path prefix and instance", t => {
const url1 = "taler://pay/example.com/mypfx%2Fpublic/foo/myorder";
const r1 = parsePayUri(url1);
if (!r1) {
@@ -107,7 +107,18 @@ test("taler pay url parsing: complex path prefix and
instance", t => {
t.is(r1.orderId, "myorder");
});
-test("taler pay url parsing: non-https #1", t => {
+test("taler refund uri parsing: non-https #1", t => {
+ const url1 = "taler://refund/example.com/-/-/myorder?insecure=1";
+ const r1 = parseRefundUri(url1);
+ if (!r1) {
+ t.fail();
+ return;
+ }
+ t.is(r1.merchantBaseUrl, "http://example.com/public/";);
+ t.is(r1.orderId, "myorder")
+});
+
+test("taler pay uri parsing: non-https #1", t => {
const url1 = "taler://pay/example.com/-/-/myorder?insecure=1";
const r1 = parsePayUri(url1);
if (!r1) {
diff --git a/src/util/taleruri.ts b/src/util/taleruri.ts
index 1b4e4352..8ad79669 100644
--- a/src/util/taleruri.ts
+++ b/src/util/taleruri.ts
@@ -95,13 +95,12 @@ export function classifyTalerUri(s: string): TalerUriType {
return TalerUriType.TalerNotifyReserve;
}
return TalerUriType.Unknown;
-
}
export function getOrderDownloadUrl(merchantBaseUrl: string, orderId: string) {
const u = new URL("proposal", merchantBaseUrl);
u.searchParams.set("order_id", orderId);
- return u.href
+ return u.href;
}
export function parsePayUri(s: string): PayUriResult | undefined {
@@ -208,7 +207,7 @@ export function parseRefundUri(s: string): RefundUriResult
| undefined {
return undefined;
}
- const path = s.slice(pfx.length);
+ const [path, search] = s.slice(pfx.length).split("?");
let [host, maybePath, maybeInstance, orderId] = path.split("/");
@@ -236,10 +235,14 @@ export function parseRefundUri(s: string):
RefundUriResult | undefined {
maybeInstancePath = `instances/${maybeInstance}/`;
}
- const merchantBaseUrl = "https://"; + host +
- "/" +
- maybePath +
- maybeInstancePath
+ let protocol = "https";
+ const searchParams = new URLSearchParams(search);
+ if (searchParams.get("insecure") === "1") {
+ protocol = "http";
+ }
+
+ const merchantBaseUrl =
+ `${protocol}://${host}/` + maybePath + maybeInstancePath;
return {
merchantBaseUrl,
diff --git a/src/wallet.ts b/src/wallet.ts
index a89d2d56..32a92cee 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -241,6 +241,31 @@ export class Wallet {
* returns without resolving to an exception.
*/
public async runUntilDone(): Promise<void> {
+ const p = new Promise((resolve, reject) => {
+ // Run this asynchronously
+ this.addNotificationListener(n => {
+ if (
+ n.type === NotificationType.WaitingForRetry &&
+ n.numGivingLiveness == 0
+ ) {
+ logger.trace("no liveness-giving operations left, returning");
+ resolve();
+ }
+ });
+ this.runRetryLoop().catch(e => {
+ console.log("exception in wallet retry loop");
+ reject(e);
+ });
+ });
+ await p;
+ }
+
+ /**
+ * Run the wallet until there are no more pending operations that give
+ * liveness left. The wallet will be in a stopped state when this function
+ * returns without resolving to an exception.
+ */
+ public async runUntilDoneAndStop(): Promise<void> {
const p = new Promise((resolve, reject) => {
// Run this asynchronously
this.addNotificationListener(n => {
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: fix and test case for "insecure" taler://refund URIs,
gnunet <=