From 237c4e8adae997e84f5fb7a8fe5c03b1148e99dc Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 27 Mar 2024 01:05:10 -0300 Subject: wip #8655 --- packages/web-util/src/context/merchant-api.ts | 25 ++++++------------------- packages/web-util/src/utils/request.ts | 2 +- 2 files changed, 7 insertions(+), 20 deletions(-) (limited to 'packages/web-util/src') diff --git a/packages/web-util/src/context/merchant-api.ts b/packages/web-util/src/context/merchant-api.ts index a531a5958..23ea05cd2 100644 --- a/packages/web-util/src/context/merchant-api.ts +++ b/packages/web-util/src/context/merchant-api.ts @@ -79,6 +79,9 @@ type Evictors = { type ConfigResult = | undefined | { type: "ok"; config: T; hints: VersionHint[] } + | ConfigResultFail; + +export type ConfigResultFail = | { type: "incompatible"; result: T; supported: string } | { type: "error"; error: TalerError }; @@ -91,7 +94,7 @@ export const MerchantApiProvider = ({ baseUrl: URL; evictors?: Evictors; children: ComponentChildren; - frameOnError: FunctionComponent<{ children: ComponentChildren }>; + frameOnError: FunctionComponent<{ state: ConfigResultFail | undefined }>; }): VNode => { const [checked, setChecked] = useState>(); @@ -120,24 +123,8 @@ export const MerchantApiProvider = ({ }); }, []); - if (checked === undefined) { - return h(frameOnError, { - children: h("div", {}, "checking compatibility with server..."), - }); - } - if (checked.type === "error") { - return h(frameOnError, { - children: h(ErrorLoading, { error: checked.error, showDetail: true }), - }); - } - if (checked.type === "incompatible") { - return h(frameOnError, { - children: h( - "div", - {}, - i18n.str`The server version is not supported. Supported version "${checked.supported}", server version "${checked.result.version}"`, - ), - }); + if (!checked || checked.type !== "ok") { + return h(frameOnError, { state: checked }, []); } const value: MerchantContextType = { diff --git a/packages/web-util/src/utils/request.ts b/packages/web-util/src/utils/request.ts index f8a892d99..70f943540 100644 --- a/packages/web-util/src/utils/request.ts +++ b/packages/web-util/src/utils/request.ts @@ -41,7 +41,7 @@ export async function defaultRequestHandler( ): Promise> { const requestHeaders: Record = {}; if (options.token) { - requestHeaders.Authorization = `Bearer ${options.token}`; + requestHeaders.Authorization = `Bearer secret-token:${options.token}`; } else if (options.basicAuth) { requestHeaders.Authorization = `Basic ${base64encode( `${options.basicAuth.username}:${options.basicAuth.password}`, -- cgit v1.2.3