aboutsummaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/context/config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/demobank-ui/src/context/config.ts')
-rw-r--r--packages/demobank-ui/src/context/config.ts21
1 files changed, 17 insertions, 4 deletions
diff --git a/packages/demobank-ui/src/context/config.ts b/packages/demobank-ui/src/context/config.ts
index 9908c73a2..2d70cf932 100644
--- a/packages/demobank-ui/src/context/config.ts
+++ b/packages/demobank-ui/src/context/config.ts
@@ -14,7 +14,7 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { TalerCorebankApi, TalerCoreBankHttpClient, TalerError } from "@gnu-taler/taler-util";
+import { LibtoolVersion, TalerCorebankApi, TalerCoreBankHttpClient, TalerError } from "@gnu-taler/taler-util";
import { BrowserHttpLib, ErrorLoading, useTranslationContext } from "@gnu-taler/web-util/browser";
import { ComponentChildren, createContext, FunctionComponent, h, VNode } from "preact";
import { useContext, useEffect, useState } from "preact/hooks";
@@ -34,8 +34,15 @@ const Context = createContext<Type>(undefined as any);
export const useBankCoreApiContext = (): Type => useContext(Context);
+enum VersionHint {
+ /**
+ * when this flag is on, server is running an old version with cashout before implementing 2fa API
+ */
+ CASHOUT_BEFORE_2FA,
+}
+
export type ConfigResult = undefined
- | { type: "ok", config: TalerCorebankApi.Config }
+ | { type: "ok", config: TalerCorebankApi.Config, hint: VersionHint[] }
| { type: "incompatible", result: TalerCorebankApi.Config, supported: string }
| { type: "error", error: TalerError }
@@ -56,9 +63,15 @@ export const BankCoreApiProvider = ({
api.getConfig()
.then((resp) => {
if (api.isCompatible(resp.body.version)) {
- setChecked({ type: "ok", config: resp.body });
+ setChecked({ type: "ok", config: resp.body, hint: [] });
} else {
- setChecked({ type: "incompatible", result: resp.body, supported: api.PROTOCOL_VERSION })
+ //this API supports version 3.0.3
+ const compare = LibtoolVersion.compare("3:0:3", resp.body.version)
+ if (compare?.compatible ?? false) {
+ setChecked({ type: "ok", config: resp.body, hint: [VersionHint.CASHOUT_BEFORE_2FA] });
+ } else {
+ setChecked({ type: "incompatible", result: resp.body, supported: api.PROTOCOL_VERSION })
+ }
}
})
.catch((error: unknown) => {