From 2c9c3d4cdf3f59eabbb47327f78966b781d77256 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 29 Jan 2024 21:58:35 +0100 Subject: remove deprecated http client lib methods --- packages/taler-util/src/http-common.ts | 22 ---------------------- packages/taler-util/src/http-impl.missing.ts | 13 ------------- packages/taler-util/src/http-impl.node.ts | 19 ------------------- packages/taler-util/src/http-impl.qtart.ts | 19 ------------------- packages/taler-wallet-core/src/dbless.ts | 16 +++++++++++----- packages/taler-wallet-core/src/dev-experiments.ts | 17 ----------------- .../src/operations/pay-merchant.ts | 9 ++++++--- .../taler-wallet-core/src/operations/recoup.ts | 10 ++++++++-- .../taler-wallet-core/src/operations/refresh.ts | 8 ++++++-- .../taler-wallet-core/src/operations/testing.ts | 6 +++--- 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 @@ -105,28 +105,6 @@ export class Headers { * request tunneling easy. */ 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; - - /** - * 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; - /** * Make an HTTP POST request with a JSON body. */ 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 { - throw new Error("Method not implemented."); - } - postJson( - url: string, - body: any, - opt?: HttpRequestOptions | undefined, - ): Promise { - 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 { - return this.fetch(url, { - method: "GET", - ...opt, - }); - } - - async postJson( - url: string, - body: any, - opt?: HttpRequestOptions, - ): Promise { - 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 { - return this.fetch(url, { - method: "GET", - ...opt, - }); - } - - async postJson( - url: string, - body: any, - opt?: HttpRequestOptions, - ): Promise { - 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 { - logger.trace(`devexperiment httplib ${url}`); - return this.underlyingLib.fetch(url, opt); - } - - postJson( - url: string, - body: any, - opt?: HttpRequestOptions | undefined, - ): Promise { - 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()); -- cgit v1.2.3