aboutsummaryrefslogtreecommitdiff
path: root/src/headless
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-02 00:42:40 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-02 00:42:40 +0100
commite1369ff7e8fc02116b9c4261036f0e42e3423cf4 (patch)
treec621067ebda8977a888bfed34b7bbecf64b3b0f0 /src/headless
parentaaf7e1338d6cdb1b4e01ad318938b3eaea2f922b (diff)
downloadwallet-core-e1369ff7e8fc02116b9c4261036f0e42e3423cf4.tar.xz
the giant refactoring: split wallet into multiple parts
Diffstat (limited to 'src/headless')
-rw-r--r--src/headless/bank.ts11
-rw-r--r--src/headless/helpers.ts10
-rw-r--r--src/headless/merchant.ts13
-rw-r--r--src/headless/taler-wallet-cli.ts7
4 files changed, 16 insertions, 25 deletions
diff --git a/src/headless/bank.ts b/src/headless/bank.ts
index 36f61a71a..99d7e050b 100644
--- a/src/headless/bank.ts
+++ b/src/headless/bank.ts
@@ -25,7 +25,6 @@
*/
import Axios from "axios";
import querystring = require("querystring");
-import URI = require("urijs");
export interface BankUser {
username: string;
@@ -50,9 +49,7 @@ export class Bank {
amount,
};
- const reqUrl = new URI("api/withdraw-headless-uri")
- .absoluteTo(this.bankBaseUrl)
- .href();
+ const reqUrl = new URL("api/withdraw-headless-uri", this.bankBaseUrl).href;
const resp = await Axios({
method: "post",
@@ -82,9 +79,7 @@ export class Bank {
reservePub: string,
exchangePaytoUri: string,
) {
- const reqUrl = new URI("api/withdraw-headless")
- .absoluteTo(this.bankBaseUrl)
- .href();
+ const reqUrl = new URL("api/withdraw-headless", this.bankBaseUrl).href;
const body = {
auth: { type: "basic" },
@@ -111,7 +106,7 @@ export class Bank {
}
async registerRandomUser(): Promise<BankUser> {
- const reqUrl = new URI("api/register").absoluteTo(this.bankBaseUrl).href();
+ const reqUrl = new URL("api/register", this.bankBaseUrl).href;
const randId = makeId(8);
const bankUser: BankUser = {
username: `testuser-${randId}`,
diff --git a/src/headless/helpers.ts b/src/headless/helpers.ts
index 9faf24daf..e5338369e 100644
--- a/src/headless/helpers.ts
+++ b/src/headless/helpers.ts
@@ -28,13 +28,13 @@ import { SynchronousCryptoWorkerFactory } from "../crypto/synchronousWorker";
import { openTalerDb } from "../db";
import Axios from "axios";
import querystring = require("querystring");
-import { HttpRequestLibrary } from "../http";
-import * as amounts from "../amounts";
+import { HttpRequestLibrary } from "../util/http";
+import * as amounts from "../util/amounts";
import { Bank } from "./bank";
import fs = require("fs");
import { NodeCryptoWorkerFactory } from "../crypto/nodeProcessWorker";
-import { Logger } from "../logging";
+import { Logger } from "../util/logging";
const logger = new Logger("helpers.ts");
@@ -51,7 +51,7 @@ class ConsoleBadge implements Badge {
}
export class NodeHttpLib implements HttpRequestLibrary {
- async get(url: string): Promise<import("../http").HttpResponse> {
+ async get(url: string): Promise<import("../util/http").HttpResponse> {
try {
const resp = await Axios({
method: "get",
@@ -70,7 +70,7 @@ export class NodeHttpLib implements HttpRequestLibrary {
async postJson(
url: string,
body: any,
- ): Promise<import("../http").HttpResponse> {
+ ): Promise<import("../util/http").HttpResponse> {
try {
const resp = await Axios({
method: "post",
diff --git a/src/headless/merchant.ts b/src/headless/merchant.ts
index 423e3d09e..1b9630732 100644
--- a/src/headless/merchant.ts
+++ b/src/headless/merchant.ts
@@ -24,7 +24,6 @@
*/
import axios from "axios";
import { CheckPaymentResponse } from "../talerTypes";
-import URI = require("urijs");
/**
* Connection to the *internal* merchant backend.
@@ -35,7 +34,7 @@ export class MerchantBackendConnection {
reason: string,
refundAmount: string,
): Promise<void> {
- const reqUrl = new URI("refund").absoluteTo(this.merchantBaseUrl).href();
+ const reqUrl = new URL("refund", this.merchantBaseUrl);
const refundReq = {
order_id: orderId,
reason,
@@ -43,7 +42,7 @@ export class MerchantBackendConnection {
};
const resp = await axios({
method: "post",
- url: reqUrl,
+ url: reqUrl.href,
data: refundReq,
responseType: "json",
headers: {
@@ -64,7 +63,7 @@ export class MerchantBackendConnection {
constructor(public merchantBaseUrl: string, public apiKey: string) {}
async authorizeTip(amount: string, justification: string) {
- const reqUrl = new URI("tip-authorize").absoluteTo(this.merchantBaseUrl).href();
+ const reqUrl = new URL("tip-authorize", this.merchantBaseUrl).href;
const tipReq = {
amount,
justification,
@@ -90,7 +89,7 @@ export class MerchantBackendConnection {
summary: string,
fulfillmentUrl: string,
): Promise<{ orderId: string }> {
- const reqUrl = new URI("order").absoluteTo(this.merchantBaseUrl).href();
+ const reqUrl = new URL("order", this.merchantBaseUrl).href;
const orderReq = {
order: {
amount,
@@ -118,9 +117,7 @@ export class MerchantBackendConnection {
}
async checkPayment(orderId: string): Promise<CheckPaymentResponse> {
- const reqUrl = new URI("check-payment")
- .absoluteTo(this.merchantBaseUrl)
- .href();
+ const reqUrl = new URL("check-payment", this.merchantBaseUrl).href;
const resp = await axios({
method: "get",
url: reqUrl,
diff --git a/src/headless/taler-wallet-cli.ts b/src/headless/taler-wallet-cli.ts
index cb2ff055c..9598b9d98 100644
--- a/src/headless/taler-wallet-cli.ts
+++ b/src/headless/taler-wallet-cli.ts
@@ -23,8 +23,8 @@ import { Wallet, OperationFailedAndReportedError } from "../wallet";
import qrcodeGenerator = require("qrcode-generator");
import * as clk from "./clk";
import { BridgeIDBFactory, MemoryBackend } from "idb-bridge";
-import { Logger } from "../logging";
-import * as Amounts from "../amounts";
+import { Logger } from "../util/logging";
+import * as Amounts from "../util/amounts";
import { decodeCrock } from "../crypto/talerCrypto";
import { Bank } from "./bank";
@@ -93,7 +93,6 @@ async function doPay(
function applyVerbose(verbose: boolean) {
if (verbose) {
console.log("enabled verbose logging");
- Wallet.enableTracing = true;
BridgeIDBFactory.enableTracing = true;
}
}
@@ -217,7 +216,7 @@ walletCli
} else if (uri.startsWith("taler://tip/")) {
const res = await wallet.getTipStatus(uri);
console.log("tip status", res);
- await wallet.acceptTip(uri);
+ await wallet.acceptTip(res.tipId);
} else if (uri.startsWith("taler://refund/")) {
await wallet.applyRefund(uri);
} else if (uri.startsWith("taler://withdraw/")) {