summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-01-29 21:58:35 +0100
committerFlorian Dold <florian@dold.me>2024-01-29 21:58:39 +0100
commit2c9c3d4cdf3f59eabbb47327f78966b781d77256 (patch)
tree17d36c45e67bd12e0beaaf4d5524423419ac2836
parent7b83d8f8dd220e04a26b33b03afc5f989cc5d1fb (diff)
downloadwallet-core-2c9c3d4cdf3f59eabbb47327f78966b781d77256.tar.gz
wallet-core-2c9c3d4cdf3f59eabbb47327f78966b781d77256.tar.bz2
wallet-core-2c9c3d4cdf3f59eabbb47327f78966b781d77256.zip
remove deprecated http client lib methods
-rw-r--r--packages/taler-util/src/http-common.ts22
-rw-r--r--packages/taler-util/src/http-impl.missing.ts13
-rw-r--r--packages/taler-util/src/http-impl.node.ts19
-rw-r--r--packages/taler-util/src/http-impl.qtart.ts19
-rw-r--r--packages/taler-wallet-core/src/dbless.ts16
-rw-r--r--packages/taler-wallet-core/src/dev-experiments.ts17
-rw-r--r--packages/taler-wallet-core/src/operations/pay-merchant.ts9
-rw-r--r--packages/taler-wallet-core/src/operations/recoup.ts10
-rw-r--r--packages/taler-wallet-core/src/operations/refresh.ts8
-rw-r--r--packages/taler-wallet-core/src/operations/testing.ts6
10 files changed, 34 insertions, 105 deletions
diff --git a/packages/taler-util/src/http-common.ts b/packages/taler-util/src/http-common.ts
index 68e1d2816..705881801 100644
--- a/packages/taler-util/src/http-common.ts
+++ b/packages/taler-util/src/http-common.ts
@@ -106,28 +106,6 @@ export class Headers {
*/
export interface HttpRequestLibrary {
/**
- * Make an HTTP GET request.
- *
- * FIXME: Get rid of this, we want the API surface to be minimal.
- *
- * @deprecated use fetch instead
- */
- get(url: string, opt?: HttpRequestOptions): Promise<HttpResponse>;
-
- /**
- * Make an HTTP POST request with a JSON body.
- *
- * FIXME: Get rid of this, we want the API surface to be minimal.
- *
- * @deprecated use fetch instead
- */
- postJson(
- url: string,
- body: any,
- opt?: HttpRequestOptions,
- ): Promise<HttpResponse>;
-
- /**
* Make an HTTP POST request with a JSON body.
*/
fetch(url: string, opt?: HttpRequestOptions): Promise<HttpResponse>;
diff --git a/packages/taler-util/src/http-impl.missing.ts b/packages/taler-util/src/http-impl.missing.ts
index a8eb227b9..6ae6b93ec 100644
--- a/packages/taler-util/src/http-impl.missing.ts
+++ b/packages/taler-util/src/http-impl.missing.ts
@@ -29,19 +29,6 @@ import {
* Implementation of the HTTP request library interface for node.
*/
export class HttpLibImpl implements HttpRequestLibrary {
- get(
- url: string,
- opt?: HttpRequestOptions | undefined,
- ): Promise<HttpResponse> {
- throw new Error("Method not implemented.");
- }
- postJson(
- url: string,
- body: any,
- opt?: HttpRequestOptions | undefined,
- ): Promise<HttpResponse> {
- throw new Error("Method not implemented.");
- }
fetch(
url: string,
opt?: HttpRequestOptions | undefined,
diff --git a/packages/taler-util/src/http-impl.node.ts b/packages/taler-util/src/http-impl.node.ts
index 8ec823eca..4ca357b02 100644
--- a/packages/taler-util/src/http-impl.node.ts
+++ b/packages/taler-util/src/http-impl.node.ts
@@ -240,23 +240,4 @@ export class HttpLibImpl implements HttpRequestLibrary {
req.end();
});
}
-
- async get(url: string, opt?: HttpRequestOptions): Promise<HttpResponse> {
- return this.fetch(url, {
- method: "GET",
- ...opt,
- });
- }
-
- async postJson(
- url: string,
- body: any,
- opt?: HttpRequestOptions,
- ): Promise<HttpResponse> {
- return this.fetch(url, {
- method: "POST",
- body,
- ...opt,
- });
- }
}
diff --git a/packages/taler-util/src/http-impl.qtart.ts b/packages/taler-util/src/http-impl.qtart.ts
index 73ca417f7..a37029d6e 100644
--- a/packages/taler-util/src/http-impl.qtart.ts
+++ b/packages/taler-util/src/http-impl.qtart.ts
@@ -130,23 +130,4 @@ export class HttpLibImpl implements HttpRequestLibrary {
status: res.status,
};
}
-
- async get(url: string, opt?: HttpRequestOptions): Promise<HttpResponse> {
- return this.fetch(url, {
- method: "GET",
- ...opt,
- });
- }
-
- async postJson(
- url: string,
- body: any,
- opt?: HttpRequestOptions,
- ): Promise<HttpResponse> {
- return this.fetch(url, {
- method: "POST",
- body,
- ...opt,
- });
- }
}
diff --git a/packages/taler-wallet-core/src/dbless.ts b/packages/taler-wallet-core/src/dbless.ts
index e841d1d20..4a7767771 100644
--- a/packages/taler-wallet-core/src/dbless.ts
+++ b/packages/taler-wallet-core/src/dbless.ts
@@ -106,7 +106,7 @@ export async function checkReserve(
if (longpollTimeoutMs) {
reqUrl.searchParams.set("timeout_ms", `${longpollTimeoutMs}`);
}
- const resp = await http.get(reqUrl.href);
+ const resp = await http.fetch(reqUrl.href, { method: "GET" });
if (resp.status !== 200) {
throw new Error("reserve not okay");
}
@@ -140,9 +140,12 @@ export async function topupReserveWithDemobank(
if (plainPaytoUris.length <= 0) {
throw new Error();
}
- const httpResp = await http.postJson(bankStatusUrl, {
- reserve_pub: reservePub,
- selected_exchange: plainPaytoUris[0],
+ const httpResp = await http.fetch(bankStatusUrl, {
+ method: "POST",
+ body: {
+ reserve_pub: reservePub,
+ selected_exchange: plainPaytoUris[0],
+ },
});
await readSuccessResponseJsonOrThrow(
httpResp,
@@ -369,7 +372,10 @@ export async function refreshCoin(req: {
oldCoin.exchangeBaseUrl,
);
- const revealResp = await http.postJson(reqUrl.href, revealRequest);
+ const revealResp = await http.fetch(reqUrl.href, {
+ method: "POST",
+ body: revealRequest,
+ });
logger.info("requesting reveal done");
diff --git a/packages/taler-wallet-core/src/dev-experiments.ts b/packages/taler-wallet-core/src/dev-experiments.ts
index 176ed09d9..cb8f7aa19 100644
--- a/packages/taler-wallet-core/src/dev-experiments.ts
+++ b/packages/taler-wallet-core/src/dev-experiments.ts
@@ -65,23 +65,6 @@ export class DevExperimentHttpLib implements HttpRequestLibrary {
this.underlyingLib = lib;
}
- get(
- url: string,
- opt?: HttpRequestOptions | undefined,
- ): Promise<HttpResponse> {
- logger.trace(`devexperiment httplib ${url}`);
- return this.underlyingLib.fetch(url, opt);
- }
-
- postJson(
- url: string,
- body: any,
- opt?: HttpRequestOptions | undefined,
- ): Promise<HttpResponse> {
- logger.trace(`devexperiment httplib ${url}`);
- return this.underlyingLib.postJson(url, body, opt);
- }
-
fetch(
url: string,
opt?: HttpRequestOptions | undefined,
diff --git a/packages/taler-wallet-core/src/operations/pay-merchant.ts b/packages/taler-wallet-core/src/operations/pay-merchant.ts
index c71dd7d90..3acfbd457 100644
--- a/packages/taler-wallet-core/src/operations/pay-merchant.ts
+++ b/packages/taler-wallet-core/src/operations/pay-merchant.ts
@@ -2060,7 +2060,7 @@ async function processPurchasePay(
};
logger.trace(`/paid request body: ${j2s(reqBody)}`);
const resp = await ws.runSequentialized([EXCHANGE_COINS_LOCK], () =>
- ws.http.postJson(payAgainUrl, reqBody),
+ ws.http.fetch(payAgainUrl, { method: "POST", body: reqBody }),
);
logger.trace(`/paid response status: ${resp.status}`);
if (
@@ -2777,8 +2777,11 @@ async function processPurchaseAcceptRefund(
logger.trace(`making refund request to ${requestUrl.href}`);
- const request = await ws.http.postJson(requestUrl.href, {
- h_contract: download.contractData.contractTermsHash,
+ const request = await ws.http.fetch(requestUrl.href, {
+ method: "POST",
+ body: {
+ h_contract: download.contractData.contractTermsHash,
+ },
});
const refundResponse = await readSuccessResponseJsonOrThrow(
diff --git a/packages/taler-wallet-core/src/operations/recoup.ts b/packages/taler-wallet-core/src/operations/recoup.ts
index 0ae873125..a6270783e 100644
--- a/packages/taler-wallet-core/src/operations/recoup.ts
+++ b/packages/taler-wallet-core/src/operations/recoup.ts
@@ -152,7 +152,10 @@ async function recoupWithdrawCoin(
});
const reqUrl = new URL(`/coins/${coin.coinPub}/recoup`, coin.exchangeBaseUrl);
logger.trace(`requesting recoup via ${reqUrl.href}`);
- const resp = await ws.http.postJson(reqUrl.href, recoupRequest);
+ const resp = await ws.http.fetch(reqUrl.href, {
+ method: "POST",
+ body: recoupRequest,
+ });
const recoupConfirmation = await readSuccessResponseJsonOrThrow(
resp,
codecForRecoupConfirmation(),
@@ -226,7 +229,10 @@ async function recoupRefreshCoin(
);
logger.trace(`making recoup request for ${coin.coinPub}`);
- const resp = await ws.http.postJson(reqUrl.href, recoupRequest);
+ const resp = await ws.http.fetch(reqUrl.href, {
+ method: "POST",
+ body: recoupRequest,
+ });
const recoupConfirmation = await readSuccessResponseJsonOrThrow(
resp,
codecForRecoupConfirmation(),
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts
index 39c6ef906..dff6d3019 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -599,7 +599,9 @@ async function refreshMelt(
};
const resp = await ws.runSequentialized([EXCHANGE_COINS_LOCK], async () => {
- return await ws.http.postJson(reqUrl.href, meltReqBody, {
+ return await ws.http.fetch(reqUrl.href, {
+ method: "POST",
+ body: meltReqBody,
timeout: getRefreshRequestTimeout(refreshGroup),
});
});
@@ -906,7 +908,9 @@ async function refreshReveal(
});
const resp = await ws.runSequentialized([EXCHANGE_COINS_LOCK], async () => {
- return await ws.http.postJson(reqUrl.href, req, {
+ return await ws.http.fetch(reqUrl.href, {
+ body: req,
+ method: "POST",
timeout: getRefreshRequestTimeout(refreshGroup),
});
});
diff --git a/packages/taler-wallet-core/src/operations/testing.ts b/packages/taler-wallet-core/src/operations/testing.ts
index f2fb74bdb..92ce504fe 100644
--- a/packages/taler-wallet-core/src/operations/testing.ts
+++ b/packages/taler-wallet-core/src/operations/testing.ts
@@ -38,9 +38,7 @@ import {
Logger,
NotificationType,
PreparePayResultType,
- stringifyTalerUri,
TalerCorebankApiClient,
- TalerUriAction,
TestPayArgs,
TestPayResult,
TransactionMajorState,
@@ -200,7 +198,9 @@ async function createOrder(
wire_transfer_deadline: { t_s: t },
},
};
- const resp = await http.postJson(reqUrl, orderReq, {
+ const resp = await http.fetch(reqUrl, {
+ method: "POST",
+ body: orderReq,
headers: getMerchantAuthHeader(merchantBackend),
});
const r = await readSuccessResponseJsonOrThrow(resp, codecForAny());