aboutsummaryrefslogtreecommitdiff
path: root/packages/web-util/src
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-07-15 17:32:26 +0200
committerFlorian Dold <florian@dold.me>2024-07-15 17:32:32 +0200
commit87066659bf4c62a06bfcca2fbd6c3a81ed4fef40 (patch)
tree5300143eebd707d1f881e6c12df7a6c2922357da /packages/web-util/src
parentbe412f419efd37dd558753a5f79a687b4672d90f (diff)
harness,util,others: check version in /config responses
Diffstat (limited to 'packages/web-util/src')
-rw-r--r--packages/web-util/src/context/bank-api.ts12
-rw-r--r--packages/web-util/src/context/merchant-api.ts12
2 files changed, 13 insertions, 11 deletions
diff --git a/packages/web-util/src/context/bank-api.ts b/packages/web-util/src/context/bank-api.ts
index 3f6a32f4b..978eba171 100644
--- a/packages/web-util/src/context/bank-api.ts
+++ b/packages/web-util/src/context/bank-api.ts
@@ -16,6 +16,7 @@
import {
CacheEvictor,
+ TalerCorebankConfigResponse,
LibtoolVersion,
ObservabilityEvent,
ObservableHttpClientLibrary,
@@ -24,7 +25,6 @@ import {
TalerBankConversionHttpClient,
TalerCoreBankCacheEviction,
TalerCoreBankHttpClient,
- TalerCorebankApi,
TalerError,
} from "@gnu-taler/taler-util";
import {
@@ -35,9 +35,9 @@ import {
h,
} from "preact";
import { useContext, useEffect, useState } from "preact/hooks";
+import { BrowserFetchHttpLib, ErrorLoading } from "../index.browser.js";
import { APIClient, ActiviyTracker, BankLib, Subscriber } from "./activity.js";
import { useTranslationContext } from "./translation.js";
-import { BrowserFetchHttpLib, ErrorLoading } from "../index.browser.js";
/**
*
@@ -46,7 +46,7 @@ import { BrowserFetchHttpLib, ErrorLoading } from "../index.browser.js";
export type BankContextType = {
url: URL;
- config: TalerCorebankApi.Config;
+ config: TalerCorebankConfigResponse;
lib: BankLib;
hints: VersionHint[];
onActivity: Subscriber<ObservabilityEvent>;
@@ -88,7 +88,7 @@ export const BankApiProvider = ({
frameOnError: FunctionComponent<{ children: ComponentChildren }>;
}): VNode => {
const [checked, setChecked] =
- useState<ConfigResult<TalerCorebankApi.Config>>();
+ useState<ConfigResult<TalerCorebankConfigResponse>>();
const { i18n } = useTranslationContext();
const { getRemoteConfig, VERSION, lib, cancelRequest, onActivity } =
@@ -165,7 +165,7 @@ export const BankApiProvider = ({
function buildBankApiClient(
url: URL,
evictors: Evictors,
-): APIClient<BankLib, TalerCorebankApi.Config> {
+): APIClient<BankLib, TalerCorebankConfigResponse> {
const httpFetch = new BrowserFetchHttpLib({
enableThrottling: true,
requireTls: false,
@@ -189,7 +189,7 @@ function buildBankApiClient(
httpLib,
);
- async function getRemoteConfig(): Promise<TalerCorebankApi.Config> {
+ async function getRemoteConfig(): Promise<TalerCorebankConfigResponse> {
const resp = await bank.getConfig();
if (resp.type === "fail") {
throw TalerError.fromUncheckedDetail(resp.detail);
diff --git a/packages/web-util/src/context/merchant-api.ts b/packages/web-util/src/context/merchant-api.ts
index 03c95d48e..09d1d6adc 100644
--- a/packages/web-util/src/context/merchant-api.ts
+++ b/packages/web-util/src/context/merchant-api.ts
@@ -49,7 +49,7 @@ import {
export type MerchantContextType = {
url: URL;
- config: TalerMerchantApi.VersionResponse;
+ config: TalerMerchantApi.TalerMerchantConfigResponse;
lib: MerchantLib;
hints: VersionHint[];
onActivity: Subscriber<ObservabilityEvent>;
@@ -95,11 +95,13 @@ export const MerchantApiProvider = ({
evictors?: Evictors;
children: ComponentChildren;
frameOnError: FunctionComponent<{
- state: ConfigResultFail<TalerMerchantApi.VersionResponse> | undefined;
+ state:
+ | ConfigResultFail<TalerMerchantApi.TalerMerchantConfigResponse>
+ | undefined;
}>;
}): VNode => {
const [checked, setChecked] =
- useState<ConfigResult<TalerMerchantApi.VersionResponse>>();
+ useState<ConfigResult<TalerMerchantApi.TalerMerchantConfigResponse>>();
const [merchantEndpoint, changeMerchantEndpoint] = useState(baseUrl);
@@ -162,7 +164,7 @@ export const MerchantApiProvider = ({
function buildMerchantApiClient(
url: URL,
evictors: Evictors,
-): APIClient<MerchantLib, TalerMerchantApi.VersionResponse> {
+): APIClient<MerchantLib, TalerMerchantApi.TalerMerchantConfigResponse> {
const httpFetch = new BrowserFetchHttpLib({
enableThrottling: true,
requireTls: false,
@@ -193,7 +195,7 @@ function buildMerchantApiClient(
return api.lib;
}
- async function getRemoteConfig(): Promise<TalerMerchantApi.VersionResponse> {
+ async function getRemoteConfig(): Promise<TalerMerchantApi.TalerMerchantConfigResponse> {
const resp = await instance.getConfig();
if (resp.type === "fail") {
throw TalerError.fromUncheckedDetail(resp.detail);