Merge branch 'master' of git.taler.net:wallet-core
This commit is contained in:
commit
5e05c22c57
5
.gitignore
vendored
5
.gitignore
vendored
@ -12,10 +12,13 @@ yarn-error.log
|
||||
|
||||
npm-packages-offline-cache/
|
||||
|
||||
config.mk
|
||||
/configure
|
||||
/config.mk
|
||||
|
||||
|
||||
\#*\#
|
||||
*~
|
||||
|
||||
# old folder
|
||||
build-scripts/
|
||||
|
||||
|
19
.npmignore
19
.npmignore
@ -1,19 +0,0 @@
|
||||
/articles
|
||||
/packages
|
||||
/npm-packages-offline-cache
|
||||
/.vscode
|
||||
/*.log
|
||||
/contrib
|
||||
/.*
|
||||
/configure
|
||||
/selenium
|
||||
/*.json
|
||||
*.tsbuildinfo
|
||||
|
||||
/Makefile
|
||||
/*.js
|
||||
|
||||
/dist/*
|
||||
!/dist/node
|
||||
|
||||
config.mk
|
11
Makefile
11
Makefile
@ -93,3 +93,14 @@ endif
|
||||
.PHONY: watch
|
||||
watch: tsconfig.json
|
||||
./node_modules/.bin/webpack --watch
|
||||
|
||||
|
||||
# Create the node_modules directory for the android wallet
|
||||
package-android:
|
||||
rm -rf dist/android
|
||||
mkdir -p dist/android
|
||||
yarn pack --filename dist/android/taler-wallet.tar.gz
|
||||
cp contrib/package-android.json dist/android/package.json
|
||||
cd dist/android && yarn install
|
||||
#cd dist/android && npm install --global --prefix $(CURDIR)/dist/android $(CURDIR)
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit b2c9672f2e493db810865b7de1e568a466b59360
|
||||
Subproject commit 2536801927781ea38fefc3de924934e1c6a74d88
|
87
configure
vendored
87
configure
vendored
@ -1,87 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This file is part of TALER
|
||||
# (C) 2019 GNUnet e.V.
|
||||
#
|
||||
# This is very simple POSIX sh script which
|
||||
# identifies the first matching
|
||||
# python3 identifier in $PATH and produces
|
||||
# configure.py from configure.py.in, and then
|
||||
# calls the new executable configure.py.
|
||||
#
|
||||
# It should be portable on Unices. Report bugs on
|
||||
# the bugtracker if you discover that it isn't
|
||||
# working as intended.
|
||||
#
|
||||
# Authors:
|
||||
# Author: ng0 <ng0@taler.net>
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
|
||||
# LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
||||
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
# THIS SOFTWARE.
|
||||
#
|
||||
# SPDX-License-Identifier: 0BSD
|
||||
|
||||
# there is a function used in curl to replicate which(1), but
|
||||
# it uses too many other tools. this one uses command and in
|
||||
# gnunet so far has no reports about failures.
|
||||
existence()
|
||||
{
|
||||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# We have to check every possible variant of the
|
||||
# executable name because there is a PEP which
|
||||
# defines the executable to be like this.
|
||||
if existence python3; then
|
||||
if test ! -z "`python3 --version | awk '$2 ~ /3.7/ { print }'`"; then
|
||||
python="python3"
|
||||
else
|
||||
echo "*** At least python 3.7 is required for the buildsystem"
|
||||
exit 1
|
||||
fi
|
||||
# elif existence python3.1; then
|
||||
# python="python3.1"
|
||||
# elif existence python3.2; then
|
||||
# python="python3.2"
|
||||
# elif existence python3.3; then
|
||||
# python="python3.3"
|
||||
# elif existence python3.4; then
|
||||
# python="python3.4"
|
||||
# elif existence python3.5; then
|
||||
# python="python3.5"
|
||||
# elif existence python3.6; then
|
||||
# python="python3.6"
|
||||
elif existence python3.7; then
|
||||
python="python3.7"
|
||||
elif existence python3.8; then
|
||||
python="python3.8"
|
||||
else
|
||||
echo "*** No known python3 executable found in path ***"
|
||||
echo "*** falling back to env(1) python ***"
|
||||
# Unreliable, but if env finds no python, we still can
|
||||
# not assume python in a fixed location.
|
||||
# TODO: Check this in a clean chroot!
|
||||
python="env python"
|
||||
fi
|
||||
|
||||
# we could check the return value here via || echo "blafoo"
|
||||
# or fail anyway once configure.py is invoked because we
|
||||
# don't have python if we reach the point to fail.
|
||||
PYTHON=$($python -c 'import sys; print(sys.executable)')
|
||||
|
||||
|
||||
# Call configure.py, assuming all went well.
|
||||
# $1 is read by configure.py as the prefix.
|
||||
# If $1 is empty, the python script checks the
|
||||
# environment for PREFIX. We might need more
|
||||
# variables and switches, such as DESTDIR.
|
||||
exec "$PYTHON" ./configure.py $@
|
15
configure.py
15
configure.py
@ -1,15 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
# This configure.py file is places in the public domain.
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
base_dir = Path(__file__, "../build-system/taler-build-scripts").resolve()
|
||||
if not base_dir.exists():
|
||||
print(
|
||||
f"build system directory ({base_dir}) missing", file=sys.stderr
|
||||
)
|
||||
sys.exit(1)
|
||||
sys.path.insert(0, str(base_dir))
|
||||
# Configure the build directory.
|
||||
# This file is invoked by './configure' and should usually not be invoked
|
||||
# manually.
|
||||
|
||||
from talerbuildconfig import *
|
||||
|
||||
|
8
contrib/package-android.json
Normal file
8
contrib/package-android.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "android-taler-wallet",
|
||||
"version": "0.6.0",
|
||||
"license": "AGPL3+",
|
||||
"dependencies": {
|
||||
"taler-wallet": "./taler-wallet.tar.gz"
|
||||
}
|
||||
}
|
@ -4,8 +4,8 @@
|
||||
"name": "GNU Taler Wallet (git)",
|
||||
"description": "Privacy preserving and transparent payments",
|
||||
"author": "GNU Taler Developers",
|
||||
"version": "0.6.68",
|
||||
"version_name": "0.6.0pre1",
|
||||
"version": "0.6.70",
|
||||
"version_name": "0.6.0pre3",
|
||||
|
||||
"minimum_chrome_version": "51",
|
||||
"minimum_opera_version": "36",
|
||||
|
@ -15,6 +15,15 @@
|
||||
"scripts": {
|
||||
"build": "make tsc"
|
||||
},
|
||||
"files": [
|
||||
"AUTHORS",
|
||||
"README",
|
||||
"COPYING",
|
||||
"bin/",
|
||||
"dist/node",
|
||||
"src/",
|
||||
"emscripten/"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/react": "^16.4.0",
|
||||
"@types/react-dom": "^16.0.0",
|
||||
|
@ -37,27 +37,27 @@ msgstr ""
|
||||
msgid "time (ms/op)"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:113
|
||||
#: src/webex/pages/pay.tsx:118
|
||||
#, fuzzy, c-format
|
||||
msgid "The merchant %1$s offers you to purchase:"
|
||||
msgstr "Der Händler %1$s möchte einen Vertrag über %2$s mit Ihnen abschließen."
|
||||
|
||||
#: src/webex/pages/pay.tsx:119
|
||||
#: src/webex/pages/pay.tsx:124
|
||||
#, c-format
|
||||
msgid "The total price is %1$s (plus %2$s fees)."
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:124
|
||||
#: src/webex/pages/pay.tsx:129
|
||||
#, c-format
|
||||
msgid "The total price is %1$s."
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:138
|
||||
#: src/webex/pages/pay.tsx:149
|
||||
#, c-format
|
||||
msgid "Retry"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:146
|
||||
#: src/webex/pages/pay.tsx:158
|
||||
#, fuzzy, c-format
|
||||
msgid "Confirm payment"
|
||||
msgstr "Bezahlung bestätigen"
|
||||
|
@ -37,27 +37,27 @@ msgstr ""
|
||||
msgid "time (ms/op)"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:113
|
||||
#: src/webex/pages/pay.tsx:118
|
||||
#, c-format
|
||||
msgid "The merchant %1$s offers you to purchase:"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:119
|
||||
#: src/webex/pages/pay.tsx:124
|
||||
#, c-format
|
||||
msgid "The total price is %1$s (plus %2$s fees)."
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:124
|
||||
#: src/webex/pages/pay.tsx:129
|
||||
#, c-format
|
||||
msgid "The total price is %1$s."
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:138
|
||||
#: src/webex/pages/pay.tsx:149
|
||||
#, c-format
|
||||
msgid "Retry"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:146
|
||||
#: src/webex/pages/pay.tsx:158
|
||||
#, c-format
|
||||
msgid "Confirm payment"
|
||||
msgstr ""
|
||||
|
@ -37,27 +37,27 @@ msgstr ""
|
||||
msgid "time (ms/op)"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:113
|
||||
#: src/webex/pages/pay.tsx:118
|
||||
#, c-format
|
||||
msgid "The merchant %1$s offers you to purchase:"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:119
|
||||
#: src/webex/pages/pay.tsx:124
|
||||
#, c-format
|
||||
msgid "The total price is %1$s (plus %2$s fees)."
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:124
|
||||
#: src/webex/pages/pay.tsx:129
|
||||
#, c-format
|
||||
msgid "The total price is %1$s."
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:138
|
||||
#: src/webex/pages/pay.tsx:149
|
||||
#, c-format
|
||||
msgid "Retry"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:146
|
||||
#: src/webex/pages/pay.tsx:158
|
||||
#, c-format
|
||||
msgid "Confirm payment"
|
||||
msgstr ""
|
||||
|
@ -37,27 +37,27 @@ msgstr ""
|
||||
msgid "time (ms/op)"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:113
|
||||
#: src/webex/pages/pay.tsx:118
|
||||
#, c-format
|
||||
msgid "The merchant %1$s offers you to purchase:"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:119
|
||||
#: src/webex/pages/pay.tsx:124
|
||||
#, c-format
|
||||
msgid "The total price is %1$s (plus %2$s fees)."
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:124
|
||||
#: src/webex/pages/pay.tsx:129
|
||||
#, c-format
|
||||
msgid "The total price is %1$s."
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:138
|
||||
#: src/webex/pages/pay.tsx:149
|
||||
#, c-format
|
||||
msgid "Retry"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:146
|
||||
#: src/webex/pages/pay.tsx:158
|
||||
#, c-format
|
||||
msgid "Confirm payment"
|
||||
msgstr ""
|
||||
|
@ -37,27 +37,27 @@ msgstr ""
|
||||
msgid "time (ms/op)"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:113
|
||||
#: src/webex/pages/pay.tsx:118
|
||||
#, fuzzy, c-format
|
||||
msgid "The merchant %1$s offers you to purchase:"
|
||||
msgstr "Säljaren %1$s erbjuder följande:"
|
||||
|
||||
#: src/webex/pages/pay.tsx:119
|
||||
#: src/webex/pages/pay.tsx:124
|
||||
#, fuzzy, c-format
|
||||
msgid "The total price is %1$s (plus %2$s fees)."
|
||||
msgstr "Det totala priset är %1$s (plus %2$s avgifter).\n"
|
||||
|
||||
#: src/webex/pages/pay.tsx:124
|
||||
#: src/webex/pages/pay.tsx:129
|
||||
#, fuzzy, c-format
|
||||
msgid "The total price is %1$s."
|
||||
msgstr "Det totala priset är %1$s."
|
||||
|
||||
#: src/webex/pages/pay.tsx:138
|
||||
#: src/webex/pages/pay.tsx:149
|
||||
#, c-format
|
||||
msgid "Retry"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:146
|
||||
#: src/webex/pages/pay.tsx:158
|
||||
#, c-format
|
||||
msgid "Confirm payment"
|
||||
msgstr "Godkän betalning"
|
||||
|
@ -37,27 +37,27 @@ msgstr ""
|
||||
msgid "time (ms/op)"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:113
|
||||
#: src/webex/pages/pay.tsx:118
|
||||
#, c-format
|
||||
msgid "The merchant %1$s offers you to purchase:"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:119
|
||||
#: src/webex/pages/pay.tsx:124
|
||||
#, c-format
|
||||
msgid "The total price is %1$s (plus %2$s fees)."
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:124
|
||||
#: src/webex/pages/pay.tsx:129
|
||||
#, c-format
|
||||
msgid "The total price is %1$s."
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:138
|
||||
#: src/webex/pages/pay.tsx:149
|
||||
#, c-format
|
||||
msgid "Retry"
|
||||
msgstr ""
|
||||
|
||||
#: src/webex/pages/pay.tsx:146
|
||||
#: src/webex/pages/pay.tsx:158
|
||||
#, c-format
|
||||
msgid "Confirm payment"
|
||||
msgstr ""
|
||||
|
@ -388,6 +388,12 @@ export class ContractTerms {
|
||||
@Checkable.String(timestampCheck)
|
||||
refund_deadline: string;
|
||||
|
||||
/**
|
||||
* Deadline for the wire transfer.
|
||||
*/
|
||||
@Checkable.String(timestampCheck)
|
||||
wire_transfer_deadline: string;
|
||||
|
||||
/**
|
||||
* Time when the contract was generated by the merchant.
|
||||
*/
|
||||
@ -402,10 +408,10 @@ export class ContractTerms {
|
||||
order_id: string;
|
||||
|
||||
/**
|
||||
* URL to post the payment to.
|
||||
* Base URL of the merchant's backend.
|
||||
*/
|
||||
@Checkable.String()
|
||||
pay_url: string;
|
||||
merchant_base_url: string;
|
||||
|
||||
/**
|
||||
* Fulfillment URL to view the product or
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import test from "ava";
|
||||
import { parsePayUri, parseWithdrawUri } from "./taleruri";
|
||||
import { parsePayUri, parseWithdrawUri, parseRefundUri, parseTipUri } from "./taleruri";
|
||||
|
||||
test("taler pay url parsing: http(s)", (t) => {
|
||||
const url1 = "https://example.com/bar?spam=eggs";
|
||||
@ -150,3 +150,57 @@ test("taler withdraw uri parsing", (t) => {
|
||||
}
|
||||
t.is(r1.statusUrl, "https://bank.example.com/api/withdraw-operation/12345");
|
||||
});
|
||||
|
||||
|
||||
test("taler refund uri parsing", (t) => {
|
||||
const url1 = "taler://refund/merchant.example.com/-/-/1234";
|
||||
const r1 = parseRefundUri(url1);
|
||||
if (!r1) {
|
||||
t.fail();
|
||||
return;
|
||||
}
|
||||
t.is(r1.refundUrl, "https://merchant.example.com/public/refund?order_id=1234");
|
||||
});
|
||||
|
||||
|
||||
test("taler refund uri parsing with instance", (t) => {
|
||||
const url1 = "taler://refund/merchant.example.com/-/myinst/1234";
|
||||
const r1 = parseRefundUri(url1);
|
||||
if (!r1) {
|
||||
t.fail();
|
||||
return;
|
||||
}
|
||||
t.is(r1.refundUrl, "https://merchant.example.com/public/instances/myinst/refund?order_id=1234");
|
||||
});
|
||||
|
||||
test("taler tip pickup uri", (t) => {
|
||||
const url1 = "taler://tip/merchant.example.com/-/-/tipid";
|
||||
const r1 = parseTipUri(url1);
|
||||
if (!r1) {
|
||||
t.fail();
|
||||
return;
|
||||
}
|
||||
t.is(r1.tipPickupUrl, "https://merchant.example.com/public/tip-pickup?tip_id=tipid");
|
||||
});
|
||||
|
||||
|
||||
test("taler tip pickup uri with instance", (t) => {
|
||||
const url1 = "taler://tip/merchant.example.com/-/tipm/tipid";
|
||||
const r1 = parseTipUri(url1);
|
||||
if (!r1) {
|
||||
t.fail();
|
||||
return;
|
||||
}
|
||||
t.is(r1.tipPickupUrl, "https://merchant.example.com/public/instances/tipm/tip-pickup?tip_id=tipid");
|
||||
});
|
||||
|
||||
|
||||
test("taler tip pickup uri with instance and prefix", (t) => {
|
||||
const url1 = "taler://tip/merchant.example.com/my%2fpfx/tipm/tipid";
|
||||
const r1 = parseTipUri(url1);
|
||||
if (!r1) {
|
||||
t.fail();
|
||||
return;
|
||||
}
|
||||
t.is(r1.tipPickupUrl, "https://merchant.example.com/my/pfx/instances/tipm/tip-pickup?tip_id=tipid");
|
||||
});
|
||||
|
@ -147,17 +147,18 @@ export function parseTipUri(s: string): TipUriResult | undefined {
|
||||
}
|
||||
|
||||
if (maybePath === "-") {
|
||||
maybePath = "public/tip-pickup";
|
||||
maybePath = "public/";
|
||||
} else {
|
||||
maybePath = decodeURIComponent(maybePath);
|
||||
maybePath = decodeURIComponent(maybePath) + "/";
|
||||
}
|
||||
if (maybeInstance === "-") {
|
||||
maybeInstance = "default";
|
||||
let maybeInstancePath = "";
|
||||
if (maybeInstance !== "-") {
|
||||
maybeInstancePath = `instances/${maybeInstance}/`;
|
||||
}
|
||||
|
||||
const tipPickupUrl = new URI(
|
||||
"https://" + host + "/" + decodeURIComponent(maybePath),
|
||||
).href();
|
||||
"https://" + host + "/" + maybePath + maybeInstancePath + "tip-pickup",
|
||||
).addQuery({ tip_id: tipId }).href();
|
||||
|
||||
return {
|
||||
tipPickupUrl,
|
||||
@ -197,20 +198,20 @@ export function parseRefundUri(s: string): RefundUriResult | undefined {
|
||||
}
|
||||
|
||||
if (maybePath === "-") {
|
||||
maybePath = "public/refund";
|
||||
maybePath = "public/";
|
||||
} else {
|
||||
maybePath = decodeURIComponent(maybePath);
|
||||
maybePath = decodeURIComponent(maybePath) + "/";
|
||||
}
|
||||
if (maybeInstance === "-") {
|
||||
maybeInstance = "default";
|
||||
let maybeInstancePath = "";
|
||||
if (maybeInstance !== "-") {
|
||||
maybeInstancePath = `instances/${maybeInstance}/`;
|
||||
}
|
||||
|
||||
const refundUrl = new URI(
|
||||
"https://" + host + "/" + decodeURIComponent(maybePath),
|
||||
"https://" + host + "/" + maybePath + maybeInstancePath + "refund",
|
||||
)
|
||||
.addQuery({ instance: maybeInstance, order_id: orderId })
|
||||
.addQuery({ order_id: orderId })
|
||||
.href();
|
||||
|
||||
return {
|
||||
refundUrl,
|
||||
};
|
||||
|
@ -115,7 +115,8 @@ test("contract terms validation", (t) => {
|
||||
merchant_pub: "12345",
|
||||
order_id: "test_order",
|
||||
pay_deadline: "Date(12346)",
|
||||
pay_url: "https://example.com/pay",
|
||||
wire_transfer_deadline: "Date(12346)",
|
||||
merchant_base_url: "https://example.com/pay",
|
||||
products: [],
|
||||
refund_deadline: "Date(12345)",
|
||||
summary: "hello",
|
||||
|
@ -114,6 +114,7 @@ import {
|
||||
parseTipUri,
|
||||
parseRefundUri,
|
||||
} from "./taleruri";
|
||||
import { isFirefox } from "./webex/compat";
|
||||
|
||||
interface SpeculativePayData {
|
||||
payCoinInfo: PayCoinInfo;
|
||||
@ -965,15 +966,19 @@ export class Wallet {
|
||||
let resp;
|
||||
const payReq = { ...purchase.payReq, session_id: sessionId };
|
||||
|
||||
const payUrl = new URI("pay")
|
||||
.absoluteTo(purchase.contractTerms.merchant_base_url)
|
||||
.href();
|
||||
|
||||
try {
|
||||
resp = await this.http.postJson(purchase.contractTerms.pay_url, payReq);
|
||||
resp = await this.http.postJson(payUrl, payReq);
|
||||
} catch (e) {
|
||||
// Gives the user the option to retry / abort and refresh
|
||||
console.log("payment failed", e);
|
||||
throw e;
|
||||
}
|
||||
const merchantResp = resp.responseJson;
|
||||
console.log("got success from pay_url");
|
||||
console.log("got success from pay URL");
|
||||
|
||||
const merchantPub = purchase.contractTerms.merchant_pub;
|
||||
const valid: boolean = await this.cryptoApi.isValidPaymentSignature(
|
||||
@ -1923,10 +1928,16 @@ export class Wallet {
|
||||
!versionMatch.compatible &&
|
||||
versionMatch.currentCmp === -1
|
||||
) {
|
||||
console.log("wallet version might be outdated, checking for updates");
|
||||
chrome.runtime.requestUpdateCheck((status, details) => {
|
||||
console.log("update check status:", status);
|
||||
});
|
||||
console.warn(
|
||||
`wallet version ${WALLET_PROTOCOL_VERSION} might be outdated (exchange has ${exchangeInfo.protocolVersion}), checking for updates`,
|
||||
);
|
||||
if (isFirefox()) {
|
||||
console.log("skipping update check on Firefox")
|
||||
} else {
|
||||
chrome.runtime.requestUpdateCheck((status, details) => {
|
||||
console.log("update check status:", status);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2213,6 +2224,9 @@ export class Wallet {
|
||||
paybackAmount: z,
|
||||
pendingIncoming: z,
|
||||
pendingPayment: z,
|
||||
pendingIncomingDirty: z,
|
||||
pendingIncomingRefresh: z,
|
||||
pendingIncomingWithdraw: z,
|
||||
};
|
||||
let entryCurr = balance.byCurrency[amount.currency];
|
||||
if (!entryCurr) {
|
||||
@ -2238,6 +2252,7 @@ export class Wallet {
|
||||
}
|
||||
if (c.status === CoinStatus.Dirty) {
|
||||
addTo(balance, "pendingIncoming", c.currentAmount, c.exchangeBaseUrl);
|
||||
addTo(balance, "pendingIncomingDirty", c.currentAmount, c.exchangeBaseUrl);
|
||||
return balance;
|
||||
}
|
||||
return balance;
|
||||
@ -2257,6 +2272,7 @@ export class Wallet {
|
||||
amount = Amounts.add(amount, r.precoin_amount).amount;
|
||||
if (Amounts.cmp(smallestWithdraw[r.exchange_base_url], amount) < 0) {
|
||||
addTo(balance, "pendingIncoming", amount, r.exchange_base_url);
|
||||
addTo(balance, "pendingIncomingWithdraw", amount, r.exchange_base_url);
|
||||
}
|
||||
return balance;
|
||||
}
|
||||
@ -2284,6 +2300,7 @@ export class Wallet {
|
||||
return balance;
|
||||
}
|
||||
addTo(balance, "pendingIncoming", r.valueOutput, r.exchangeBaseUrl);
|
||||
addTo(balance, "pendingIncomingRefresh", r.valueOutput, r.exchangeBaseUrl);
|
||||
|
||||
return balance;
|
||||
}
|
||||
@ -2338,6 +2355,7 @@ export class Wallet {
|
||||
tx.iter(Stores.reserves).fold(collectPaybacks, balanceStore);
|
||||
tx.iter(Stores.purchases).fold(collectPayments, balanceStore);
|
||||
await tx.finish();
|
||||
console.log("computed balances:", balanceStore)
|
||||
return balanceStore;
|
||||
}
|
||||
|
||||
@ -2441,9 +2459,12 @@ export class Wallet {
|
||||
.iter(Stores.refresh)
|
||||
.toArray();
|
||||
for (const session of oldRefreshSessions) {
|
||||
if (session.finished) {
|
||||
continue;
|
||||
}
|
||||
Wallet.enableTracing &&
|
||||
console.log("got old refresh session for", oldCoinPub, session);
|
||||
return this.continueRefreshSession(session);
|
||||
console.log("waiting for unfinished old refresh session for", oldCoinPub, session);
|
||||
await this.continueRefreshSession(session);
|
||||
}
|
||||
const coin = await this.q().get(Stores.coins, oldCoinPub);
|
||||
if (!coin) {
|
||||
@ -2454,6 +2475,7 @@ export class Wallet {
|
||||
coin.status === CoinStatus.Useless ||
|
||||
coin.status === CoinStatus.Fresh
|
||||
) {
|
||||
Wallet.enableTracing && console.log("not refreshing due to coin status", CoinStatus[coin.status])
|
||||
return;
|
||||
}
|
||||
const refreshSession = await this.createRefreshSession(oldCoinPub);
|
||||
@ -3032,8 +3054,9 @@ export class Wallet {
|
||||
merchant: {},
|
||||
merchant_pub: pub,
|
||||
order_id: "none",
|
||||
pay_deadline: `/Date(${stampSecNow + 60 * 5})/`,
|
||||
pay_url: "",
|
||||
pay_deadline: `/Date(${stampSecNow + 30 * 5})/`,
|
||||
wire_transfer_deadline: `/Date(${stampSecNow + 60 * 5})/`,
|
||||
merchant_base_url: "taler://return-to-account",
|
||||
products: [],
|
||||
refund_deadline: `/Date(${stampSecNow + 60 * 5})/`,
|
||||
timestamp: `/Date(${stampSecNow})/`,
|
||||
@ -3466,9 +3489,7 @@ export class Wallet {
|
||||
throw Error("invalid taler://tip URI");
|
||||
}
|
||||
|
||||
const tipStatusUrl = new URI(res.tipPickupUrl)
|
||||
.addQuery({ tip_id: res.tipId })
|
||||
.href();
|
||||
const tipStatusUrl = new URI(res.tipPickupUrl).href();
|
||||
console.log("checking tip status from", tipStatusUrl);
|
||||
const merchantResp = await this.http.get(tipStatusUrl);
|
||||
console.log("resp:", merchantResp.responseJson);
|
||||
@ -3552,8 +3573,12 @@ export class Wallet {
|
||||
|
||||
const abortReq = { ...purchase.payReq, mode: "abort-refund" };
|
||||
|
||||
const payUrl = new URI("pay")
|
||||
.absoluteTo(purchase.contractTerms.merchant_base_url)
|
||||
.href();
|
||||
|
||||
try {
|
||||
resp = await this.http.postJson(purchase.contractTerms.pay_url, abortReq);
|
||||
resp = await this.http.postJson(payUrl, abortReq);
|
||||
} catch (e) {
|
||||
// Gives the user the option to retry / abort and refresh
|
||||
console.log("aborting payment failed", e);
|
||||
|
@ -187,6 +187,10 @@ export interface WalletBalanceEntry {
|
||||
* Amount that was paid back and we could withdraw again.
|
||||
*/
|
||||
paybackAmount: AmountJson;
|
||||
|
||||
pendingIncomingWithdraw: AmountJson;
|
||||
pendingIncomingRefresh: AmountJson;
|
||||
pendingIncomingDirty: AmountJson;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import {wxMain} from "./wxBackend";
|
||||
import { wxMain } from "./wxBackend";
|
||||
|
||||
window.addEventListener("load", () => {
|
||||
wxMain();
|
||||
|
@ -53,6 +53,11 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) {
|
||||
return <span>Loading payment information ...</span>;
|
||||
}
|
||||
|
||||
let insufficientBalance = false;
|
||||
if (payStatus.status == "insufficient-balance") {
|
||||
insufficientBalance = true;
|
||||
}
|
||||
|
||||
if (payStatus.status === "error") {
|
||||
return <span>Error: {payStatus.error}</span>;
|
||||
}
|
||||
@ -93,7 +98,7 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) {
|
||||
|
||||
const doPayment = async () => {
|
||||
if (payStatus.status !== "payment-possible") {
|
||||
throw Error("invalid state");
|
||||
throw Error(`invalid state: ${payStatus.status}`);
|
||||
}
|
||||
const proposalId = payStatus.proposalId;
|
||||
setNumTries(numTries + 1);
|
||||
@ -128,6 +133,12 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) {
|
||||
)}
|
||||
</p>
|
||||
|
||||
{insufficientBalance ? (
|
||||
<div>
|
||||
<p style={{color: "red", fontWeight: "bold"}}>Unable to pay: Your balance is insufficient.</p>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{payErrMsg ? (
|
||||
<div>
|
||||
<p>Payment failed: {payErrMsg}</p>
|
||||
@ -142,6 +153,7 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) {
|
||||
<div>
|
||||
<ProgressButton
|
||||
loading={loading}
|
||||
disabled={insufficientBalance}
|
||||
onClick={() => doPayment()}>
|
||||
{i18n.str`Confirm payment`}
|
||||
</ProgressButton>
|
||||
|
@ -88,7 +88,7 @@ function TipDisplay(props: { talerTipUri: string }) {
|
||||
</p>
|
||||
<form className="pure-form">
|
||||
<ProgressButton loading={loading} onClick={() => accept()}>
|
||||
AcceptTip
|
||||
Accept Tip
|
||||
</ProgressButton>
|
||||
{" "}
|
||||
<button className="pure-button" type="button" onClick={() => discard()}>
|
||||
|
@ -86,6 +86,7 @@ async function callBackend<T extends MessageType>(
|
||||
return new Promise<MessageMap[T]["response"]>((resolve, reject) => {
|
||||
chrome.runtime.sendMessage({ type, detail }, (resp) => {
|
||||
if (typeof resp === "object" && resp && resp.error) {
|
||||
console.warn("response error:", resp)
|
||||
const e = new WalletApiError(resp.error.message, resp.error);
|
||||
reject(e);
|
||||
} else {
|
||||
|
@ -547,19 +547,26 @@ function injectScript(
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
// This needs to be outside of main, as Firefox won't fire the event if
|
||||
// the listener isn't created synchronously on loading the backend.
|
||||
chrome.runtime.onInstalled.addListener(details => {
|
||||
console.log("onInstalled with reason", details.reason);
|
||||
if (details.reason === "install") {
|
||||
const url = chrome.extension.getURL("/src/webex/pages/welcome.html");
|
||||
chrome.tabs.create({ active: true, url: url });
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main function to run for the WebExtension backend.
|
||||
*
|
||||
* Sets up all event handlers and other machinery.
|
||||
*/
|
||||
export async function wxMain() {
|
||||
chrome.runtime.onInstalled.addListener(details => {
|
||||
if (details.reason === "install") {
|
||||
const url = chrome.extension.getURL("/src/webex/pages/welcome.html");
|
||||
chrome.tabs.create({ active: true, url: url });
|
||||
}
|
||||
});
|
||||
|
||||
// Explicitly unload the extension page as soon as an update is available,
|
||||
// so the update gets installed as soon as possible.
|
||||
chrome.runtime.onUpdateAvailable.addListener(details => {
|
||||
|
Loading…
Reference in New Issue
Block a user