gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-wallet-webex] branch master updated: fix handling of


From: gnunet
Subject: [GNUnet-SVN] [taler-wallet-webex] branch master updated: fix handling of resource_url
Date: Thu, 18 Jan 2018 02:50:29 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-webex.

The following commit(s) were added to refs/heads/master by this push:
     new 2f68e9e5 fix handling of resource_url
2f68e9e5 is described below

commit 2f68e9e50e83c55ca46e9d4d72956d6525d0fa8c
Author: Florian Dold <address@hidden>
AuthorDate: Thu Jan 18 02:50:18 2018 +0100

    fix handling of resource_url
---
 src/dbTypes.ts                       |  1 +
 src/i18n/de.po                       |  4 ++--
 src/i18n/en-US.po                    |  4 ++--
 src/i18n/fr.po                       |  4 ++--
 src/i18n/it.po                       |  4 ++--
 src/i18n/taler-wallet-webex.pot      |  4 ++--
 src/query.ts                         |  1 -
 src/wallet.ts                        | 14 +++++++++-----
 src/walletTypes.ts                   | 10 ++++++++++
 src/webex/pages/confirm-contract.tsx |  4 +++-
 src/webex/wxBackend.ts               |  8 ++++----
 11 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/src/dbTypes.ts b/src/dbTypes.ts
index 9e966321..609c8526 100644
--- a/src/dbTypes.ts
+++ b/src/dbTypes.ts
@@ -784,6 +784,7 @@ export interface PurchaseRecord {
   timestamp_refund: number;
 
   lastSessionSig: string | undefined;
+  lastSessionId: string | undefined;
 }
 
 
diff --git a/src/i18n/de.po b/src/i18n/de.po
index 1f6e9896..39f1f56e 100644
--- a/src/i18n/de.po
+++ b/src/i18n/de.po
@@ -56,12 +56,12 @@ msgid ""
 "wallet."
 msgstr ""
 
-#: src/webex/pages/confirm-contract.tsx:249
+#: src/webex/pages/confirm-contract.tsx:251
 #, c-format
 msgid "The merchant%1$s offers you to purchase:\n"
 msgstr ""
 
-#: src/webex/pages/confirm-contract.tsx:270
+#: src/webex/pages/confirm-contract.tsx:272
 #, fuzzy, c-format
 msgid "Confirm payment"
 msgstr "Bezahlung bestätigen"
diff --git a/src/i18n/en-US.po b/src/i18n/en-US.po
index 3e47e952..2fdb451d 100644
--- a/src/i18n/en-US.po
+++ b/src/i18n/en-US.po
@@ -56,12 +56,12 @@ msgid ""
 "wallet."
 msgstr ""
 
-#: src/webex/pages/confirm-contract.tsx:249
+#: src/webex/pages/confirm-contract.tsx:251
 #, c-format
 msgid "The merchant%1$s offers you to purchase:\n"
 msgstr ""
 
-#: src/webex/pages/confirm-contract.tsx:270
+#: src/webex/pages/confirm-contract.tsx:272
 #, c-format
 msgid "Confirm payment"
 msgstr ""
diff --git a/src/i18n/fr.po b/src/i18n/fr.po
index 97ff4706..5d47a1f7 100644
--- a/src/i18n/fr.po
+++ b/src/i18n/fr.po
@@ -56,12 +56,12 @@ msgid ""
 "wallet."
 msgstr ""
 
-#: src/webex/pages/confirm-contract.tsx:249
+#: src/webex/pages/confirm-contract.tsx:251
 #, c-format
 msgid "The merchant%1$s offers you to purchase:\n"
 msgstr ""
 
-#: src/webex/pages/confirm-contract.tsx:270
+#: src/webex/pages/confirm-contract.tsx:272
 #, c-format
 msgid "Confirm payment"
 msgstr ""
diff --git a/src/i18n/it.po b/src/i18n/it.po
index 97ff4706..5d47a1f7 100644
--- a/src/i18n/it.po
+++ b/src/i18n/it.po
@@ -56,12 +56,12 @@ msgid ""
 "wallet."
 msgstr ""
 
-#: src/webex/pages/confirm-contract.tsx:249
+#: src/webex/pages/confirm-contract.tsx:251
 #, c-format
 msgid "The merchant%1$s offers you to purchase:\n"
 msgstr ""
 
-#: src/webex/pages/confirm-contract.tsx:270
+#: src/webex/pages/confirm-contract.tsx:272
 #, c-format
 msgid "Confirm payment"
 msgstr ""
diff --git a/src/i18n/taler-wallet-webex.pot b/src/i18n/taler-wallet-webex.pot
index 97ff4706..5d47a1f7 100644
--- a/src/i18n/taler-wallet-webex.pot
+++ b/src/i18n/taler-wallet-webex.pot
@@ -56,12 +56,12 @@ msgid ""
 "wallet."
 msgstr ""
 
-#: src/webex/pages/confirm-contract.tsx:249
+#: src/webex/pages/confirm-contract.tsx:251
 #, c-format
 msgid "The merchant%1$s offers you to purchase:\n"
 msgstr ""
 
-#: src/webex/pages/confirm-contract.tsx:270
+#: src/webex/pages/confirm-contract.tsx:272
 #, c-format
 msgid "Confirm payment"
 msgstr ""
diff --git a/src/query.ts b/src/query.ts
index 290d02a2..e45596c6 100644
--- a/src/query.ts
+++ b/src/query.ts
@@ -685,7 +685,6 @@ export class QueryRoot {
   put<T>(store: Store<T>, val: T, keyName?: string): QueryRoot {
     this.checkFinished();
     const doPut = (tx: IDBTransaction) => {
-      console.log("put into", store.name, "value", val);
       const req = tx.objectStore(store.name).put(val);
       if (keyName) {
         req.onsuccess = () => {
diff --git a/src/wallet.ts b/src/wallet.ts
index aa974369..7c291492 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -96,6 +96,7 @@ import {
   CreateReserveRequest,
   CreateReserveResponse,
   HistoryRecord,
+  NextUrlResult,
   Notifier,
   PayCoinInfo,
   QueryPaymentResult,
@@ -312,7 +313,7 @@ export class Wallet {
   private processPreCoinThrottle: {[url: string]: number} = {};
   private timerGroup: TimerGroup;
   private speculativePayData: SpeculativePayData | undefined;
-  private cachedNextUrl: { [fulfillmentUrl: string]: string } = {};
+  private cachedNextUrl: { [fulfillmentUrl: string]: NextUrlResult } = {};
 
   /**
    * Set of identifiers for running operations.
@@ -652,6 +653,7 @@ export class Wallet {
       contractTermsHash: proposal.contractTermsHash,
       finished: false,
       lastSessionSig: undefined,
+      lastSessionId: undefined,
       merchantSig: proposal.merchantSig,
       payReq,
       refundsDone: {},
@@ -735,14 +737,14 @@ export class Wallet {
     const fu = new URI(purchase.contractTerms.fulfillment_url);
     fu.addSearch("order_id", purchase.contractTerms.order_id);
     if (merchantResp.session_sig) {
-      fu.addSearch("session_sig", merchantResp.session_sig);
       purchase.lastSessionSig = merchantResp.session_sig;
-      console.log("updating session sig", purchase);
+      purchase.lastSessionId = sessionId;
+      fu.addSearch("session_sig", merchantResp.session_sig);
       await this.q().put(Stores.purchases, purchase).finish();
     }
     await this.paymentSucceeded(purchase.contractTermsHash, merchantResp.sig);
     const nextUrl = fu.href();
-    this.cachedNextUrl[purchase.contractTerms.fulfillment_url] = nextUrl;
+    this.cachedNextUrl[purchase.contractTerms.fulfillment_url] = { nextUrl, 
lastSessionId: sessionId };
     return { nextUrl };
   }
 
@@ -899,6 +901,7 @@ export class Wallet {
       contractTerms: t.contractTerms,
       contractTermsHash: t.contractTermsHash,
       found: true,
+      lastSessionId: t.lastSessionId,
       lastSessionSig: t.lastSessionSig,
       payReq: t.payReq,
     };
@@ -925,6 +928,7 @@ export class Wallet {
       contractTermsHash: t.contractTermsHash,
       found: true,
       lastSessionSig: t.lastSessionSig,
+      lastSessionId: t.lastSessionId,
       payReq: t.payReq,
     };
   }
@@ -2891,7 +2895,7 @@ export class Wallet {
    * payed for, or if it is not cached anymore.  Use the asynchronous
    * queryPaymentByFulfillmentUrl to avoid false negatives.
    */
-  getNextUrlFromResourceUrl(resourceUrl: string): string | undefined {
+  getNextUrlFromResourceUrl(resourceUrl: string): NextUrlResult | undefined {
     return this.cachedNextUrl[resourceUrl];
   }
 
diff --git a/src/walletTypes.ts b/src/walletTypes.ts
index 45a79587..c98717ac 100644
--- a/src/walletTypes.ts
+++ b/src/walletTypes.ts
@@ -302,6 +302,7 @@ export interface QueryPaymentFound {
   contractTermsHash: string;
   contractTerms: ContractTerms;
   lastSessionSig?: string;
+  lastSessionId?: string;
   payReq: PayReq;
 }
 
@@ -603,3 +604,12 @@ export interface Badge {
    */
   clearNotification(): void;
 }
+
+
+/**
+ * Cached next URL for a particular session id.
+ */
+export interface NextUrlResult {
+  nextUrl: string;
+  lastSessionId: string | undefined;
+}
diff --git a/src/webex/pages/confirm-contract.tsx 
b/src/webex/pages/confirm-contract.tsx
index c302239c..cd58d712 100644
--- a/src/webex/pages/confirm-contract.tsx
+++ b/src/webex/pages/confirm-contract.tsx
@@ -150,7 +150,7 @@ class ContractPrompt extends 
React.Component<ContractPromptProps, ContractPrompt
     if (this.props.resourceUrl) {
       const p = await 
wxApi.queryPaymentByFulfillmentUrl(this.props.resourceUrl);
       console.log("query for resource url", this.props.resourceUrl, "result", 
p);
-      if (p.found) {
+      if (p.found && (p.lastSessionSig === undefined || p.lastSessionSig === 
this.props.sessionId)) {
         const nextUrl = new URI(p.contractTerms.fulfillment_url);
         nextUrl.addSearch("order_id", p.contractTerms.order_id);
         if (p.lastSessionSig) {
@@ -218,7 +218,9 @@ class ContractPrompt extends 
React.Component<ContractPromptProps, ContractPrompt
       console.error("proposal has no id");
       return;
     }
+    console.log("confirmPay with", proposalId, "and", this.props.sessionId);
     const payResult = await wxApi.confirmPay(proposalId, this.props.sessionId);
+    console.log("payResult", payResult);
     document.location.href = payResult.nextUrl;
     this.setState({ holdCheck: true });
   }
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index 7bbba175..a4f534af 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -422,7 +422,7 @@ async function talerPay(fields: any, url: string, tabId: 
number): Promise<string
   if (fields.resource_url) {
     const p = await w.queryPaymentByFulfillmentUrl(fields.resource_url);
     console.log("query for resource url", fields.resource_url, "result", p);
-    if (p.found) {
+    if (p.found && (fields.session_id === undefined || fields.session_id === 
p.lastSessionId)) {
       return goToPayment(p);
     }
   }
@@ -508,9 +508,9 @@ function handleHttpPayment(headerList: 
chrome.webRequest.HttpHeader[], url: stri
 
   // Fast path for existing payment
   if (fields.resource_url) {
-    const nextUrl = 
currentWallet.getNextUrlFromResourceUrl(fields.resource_url);
-    if (nextUrl) {
-      return { redirectUrl: nextUrl };
+    const result = 
currentWallet.getNextUrlFromResourceUrl(fields.resource_url);
+    if (result && (fields.session_id === undefined || fields.session_id === 
result.lastSessionId)) {
+      return { redirectUrl: result.nextUrl };
     }
   }
   // Fast path for new contract

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]