aboutsummaryrefslogtreecommitdiff
path: root/packages/challenger-ui/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/challenger-ui/src')
-rw-r--r--packages/challenger-ui/src/Routing.tsx264
-rw-r--r--packages/challenger-ui/src/app.tsx14
-rw-r--r--packages/challenger-ui/src/attempts-exhausted.html88
-rw-r--r--packages/challenger-ui/src/components/CheckChallengeIsUpToDate.tsx52
-rw-r--r--packages/challenger-ui/src/context/preferences.ts87
-rw-r--r--packages/challenger-ui/src/declaration.d.ts35
-rw-r--r--packages/challenger-ui/src/enter-address-form.html133
-rw-r--r--packages/challenger-ui/src/enter-email-form.html127
-rw-r--r--packages/challenger-ui/src/enter-file-access-form.html102
-rw-r--r--packages/challenger-ui/src/enter-phone-form.html126
-rw-r--r--packages/challenger-ui/src/enter-tan-form.html117
-rw-r--r--packages/challenger-ui/src/hooks/challenge.ts23
-rw-r--r--packages/challenger-ui/src/hooks/session.ts113
-rw-r--r--packages/challenger-ui/src/i18n/challenger-ui.pot2
-rw-r--r--packages/challenger-ui/src/internal-error.html89
-rw-r--r--packages/challenger-ui/src/invalid-pin.html87
-rw-r--r--packages/challenger-ui/src/invalid-request.html88
-rw-r--r--packages/challenger-ui/src/pages/AnswerChallenge.tsx314
-rw-r--r--packages/challenger-ui/src/pages/AskChallenge.tsx463
-rw-r--r--packages/challenger-ui/src/pages/CallengeCompleted.tsx36
-rw-r--r--packages/challenger-ui/src/pages/Frame.tsx153
-rw-r--r--packages/challenger-ui/src/pages/Setup.tsx161
-rw-r--r--packages/challenger-ui/src/validation-unknown.html89
23 files changed, 1182 insertions, 1581 deletions
diff --git a/packages/challenger-ui/src/Routing.tsx b/packages/challenger-ui/src/Routing.tsx
index 6166f159a..e2a4bd067 100644
--- a/packages/challenger-ui/src/Routing.tsx
+++ b/packages/challenger-ui/src/Routing.tsx
@@ -15,22 +15,20 @@
*/
import {
- Loading,
urlPattern,
useCurrentLocation,
- useNavigationContext,
+ useNavigationContext
} from "@gnu-taler/web-util/browser";
import { Fragment, VNode, h } from "preact";
import { assertUnreachable } from "@gnu-taler/taler-util";
+import { useErrorBoundary } from "preact/hooks";
import { CheckChallengeIsUpToDate } from "./components/CheckChallengeIsUpToDate.js";
-import { SessionId, useSessionState } from "./hooks/session.js";
+import { SessionId } from "./hooks/session.js";
import { AnswerChallenge } from "./pages/AnswerChallenge.js";
import { AskChallenge } from "./pages/AskChallenge.js";
import { CallengeCompleted } from "./pages/CallengeCompleted.js";
import { Frame } from "./pages/Frame.js";
-import { MissingParams } from "./pages/MissingParams.js";
-import { NonceNotFound } from "./pages/NonceNotFound.js";
import { Setup } from "./pages/Setup.js";
export function Routing(): VNode {
@@ -44,26 +42,11 @@ export function Routing(): VNode {
}
const publicPages = {
- noinfo: urlPattern<{ nonce: string }>(
- /\/noinfo\/(?<nonce>[a-zA-Z0-9]+)/,
- ({ nonce }) => `#/noinfo/${nonce}`,
- ),
- authorize: urlPattern<{ nonce: string }>(
- /\/authorize\/(?<nonce>[a-zA-Z0-9]+)/,
- ({ nonce }) => `#/authorize/${nonce}`,
- ),
- ask: urlPattern<{ nonce: string }>(
- /\/ask\/(?<nonce>[a-zA-Z0-9]+)/,
- ({ nonce }) => `#/ask/${nonce}`,
- ),
- answer: urlPattern<{ nonce: string }>(
- /\/answer\/(?<nonce>[a-zA-Z0-9]+)/,
- ({ nonce }) => `#/answer/${nonce}`,
- ),
- completed: urlPattern<{ nonce: string }>(
- /\/completed\/(?<nonce>[a-zA-Z0-9]+)/,
- ({ nonce }) => `#/completed/${nonce}`,
- ),
+ noinfo: urlPattern(/\/noinfo/, () => `#/noinfo`),
+ authorize: urlPattern(/\/authorize/, () => `#/authorize`),
+ ask: urlPattern(/\/ask/, () => `#/ask`),
+ answer: urlPattern(/\/answer/, () => `#/answer`),
+ completed: urlPattern(/\/completed/, () => `#/completed`),
setup: urlPattern<{ client: string }>(
/\/setup\/(?<client>[0-9]+)/,
({ client }) => `#/setup/${client}`,
@@ -78,7 +61,7 @@ function safeGetParam(
return ps[n][0];
}
-function safeToURL(s: string | undefined): URL | undefined {
+export function safeToURL(s: string | undefined): URL | undefined {
if (s === undefined) return undefined;
try {
return new URL(s);
@@ -88,71 +71,75 @@ function safeToURL(s: string | undefined): URL | undefined {
}
function PublicRounting(): VNode {
- const location = useCurrentLocation(publicPages);
+ const loc = useCurrentLocation(publicPages);
const { navigateTo } = useNavigationContext();
- const { start } = useSessionState();
+ useErrorBoundary((e) => {
+ console.log("error", e);
+ });
- if (location === undefined) {
- return <NonceNotFound />;
- }
+ const location: typeof loc =
+ loc.name === undefined
+ ? {
+ ...loc,
+ name: "authorize",
+ }
+ : loc;
switch (location.name) {
case "noinfo": {
return <div>no info</div>;
}
case "setup": {
+ const secret = safeGetParam(location.params, "secret");
+ const redirectURL = safeToURL(
+ safeGetParam(location.params, "redirect_uri"),
+ );
+
return (
<Setup
clientId={location.values.client}
- onCreated={(nonce) => {
- navigateTo(publicPages.ask.url({ nonce }));
- //response_type=code
- //client_id=1
- //redirect_uri=http://exchange.taler.test:1180/kyc-proof/kyc-provider-wallet
- //state=123
+ secret={secret}
+ redirectURL={redirectURL}
+ onCreated={() => {
+ navigateTo(publicPages.ask.url({}));
}}
/>
);
}
case "authorize": {
- const responseType = safeGetParam(location.params, "response_type");
const clientId = safeGetParam(location.params, "client_id");
const redirectURL = safeToURL(
safeGetParam(location.params, "redirect_uri"),
);
const state = safeGetParam(location.params, "state");
- // http://localhost:8080/app/#/authorize/ASDASD123?response_type=code&client_id=1&redirect_uri=goog.ecom&state=123
- //
+ const nonce = safeGetParam(location.params, "nonce");
- // http://localhost:8080/app/?response_type=code&client_id=1&redirect_uri=http://exchange.taler.test:1180/kyc-proof/kyc-provider-wallet&state=123#/authorize/X9668AR2CFC26X55H0M87GJZXGM45VD4SZE05C5SNS5FADPWN220
+ const sessionId: SessionId | undefined =
+ !clientId || !redirectURL || !state || !nonce
+ ? undefined
+ : {
+ clientId,
+ nonce: nonce,
+ redirectURL: redirectURL.href,
+ state,
+ };
- if (
- !responseType ||
- !clientId ||
- !redirectURL ||
- !state ||
- responseType !== "code"
- ) {
- return <MissingParams />;
+ if (!sessionId) {
+ return (
+ <div>
+ one of the params is missing{" "}
+ {JSON.stringify(
+ { clientId, redirectURL, state, nonce },
+ undefined,
+ 2,
+ )}
+ </div>
+ );
}
- const sessionId: SessionId = {
- clientId,
- redirectURL: redirectURL.href,
- state,
- };
return (
<CheckChallengeIsUpToDate
- sessionId={sessionId}
- nonce={location.values.nonce}
- onNoInfo={() => {
- navigateTo(
- publicPages.noinfo.url({
- nonce: location.values.nonce,
- }),
- );
- }}
+ session={sessionId}
onCompleted={() => {
- start(sessionId);
navigateTo(
publicPages.completed.url({
nonce: location.values.nonce,
@@ -160,7 +147,6 @@ function PublicRounting(): VNode {
);
}}
onChangeLeft={() => {
- start(sessionId);
navigateTo(
publicPages.ask.url({
nonce: location.values.nonce,
@@ -168,7 +154,6 @@ function PublicRounting(): VNode {
);
}}
onNoMoreChanges={() => {
- start(sessionId);
navigateTo(
publicPages.ask.url({
nonce: location.values.nonce,
@@ -176,93 +161,112 @@ function PublicRounting(): VNode {
);
}}
>
- <Loading />
+ No nonce has been found
</CheckChallengeIsUpToDate>
);
}
case "ask": {
+ const clientId = safeGetParam(location.params, "client_id");
+ const redirectURL = safeToURL(
+ safeGetParam(location.params, "redirect_uri"),
+ );
+ const state = safeGetParam(location.params, "state");
+ const nonce = safeGetParam(location.params, "nonce");
+
+ const sessionId: SessionId | undefined =
+ !clientId || !redirectURL || !state || !nonce
+ ? undefined
+ : {
+ clientId,
+ nonce: nonce,
+ redirectURL: redirectURL.href,
+ state,
+ };
+
+ if (!sessionId) {
+ return (
+ <div>
+ one of the params is missing{" "}
+ {JSON.stringify(sessionId, undefined, 2)}
+ </div>
+ );
+ }
return (
- <CheckChallengeIsUpToDate
- nonce={location.values.nonce}
- onNoInfo={() => {
+ <AskChallenge
+ session={sessionId}
+ focus
+ routeSolveChallenge={publicPages.answer}
+ onSendSuccesful={() => {
navigateTo(
- publicPages.noinfo.url({
- nonce: location.values.nonce,
- }),
- );
- }}
- onCompleted={() => {
- navigateTo(
- publicPages.completed.url({
+ publicPages.answer.url({
nonce: location.values.nonce,
}),
);
}}
- >
- <AskChallenge
- focus
- nonce={location.values.nonce}
- routeSolveChallenge={publicPages.answer}
- onSendSuccesful={() => {
- navigateTo(
- publicPages.answer.url({
- nonce: location.values.nonce,
- }),
- );
- }}
- />
- </CheckChallengeIsUpToDate>
+ // onCompleted={() => {
+ // navigateTo(
+ // publicPages.completed.url({
+ // nonce: location.values.nonce,
+ // }),
+ // );
+ // }}
+ />
);
}
case "answer": {
+ const clientId = safeGetParam(location.params, "client_id");
+ const redirectURL = safeToURL(
+ safeGetParam(location.params, "redirect_uri"),
+ );
+ const state = safeGetParam(location.params, "state");
+ const nonce = safeGetParam(location.params, "nonce");
+
+ const sessionId: SessionId | undefined =
+ !clientId || !redirectURL || !state || !nonce
+ ? undefined
+ : {
+ clientId,
+ nonce: nonce,
+ redirectURL: redirectURL.href,
+ state,
+ };
+
+ if (!sessionId) {
+ return (
+ <div>
+ one of the params is missing{" "}
+ {JSON.stringify(
+ { clientId, redirectURL, state, nonce },
+ undefined,
+ 2,
+ )}
+ </div>
+ );
+ }
return (
- <CheckChallengeIsUpToDate
- nonce={location.values.nonce}
- onNoInfo={() => {
- navigateTo(
- publicPages.noinfo.url({
- nonce: location.values.nonce,
- }),
- );
- }}
- onCompleted={() => {
+ <AnswerChallenge
+ focus
+ session={sessionId}
+ routeAsk={publicPages.ask}
+ onComplete={() => {
navigateTo(
publicPages.completed.url({
nonce: location.values.nonce,
}),
);
}}
- >
- <AnswerChallenge
- focus
- nonce={location.values.nonce}
- routeAsk={publicPages.ask}
- onComplete={() => {
- navigateTo(
- publicPages.completed.url({
- nonce: location.values.nonce,
- }),
- );
- }}
- />
- </CheckChallengeIsUpToDate>
+ // onCompleted={() => {
+ // navigateTo(
+ // publicPages.completed.url({
+ // nonce: location.values.nonce,
+ // }),
+ // );
+ // }}
+ />
);
}
case "completed": {
- return (
- <CheckChallengeIsUpToDate
- nonce={location.values.nonce}
- onNoInfo={() => {
- navigateTo(
- publicPages.noinfo.url({
- nonce: location.values.nonce,
- }),
- );
- }}
- >
- <CallengeCompleted nonce={location.values.nonce} />
- </CheckChallengeIsUpToDate>
- );
+ return <CallengeCompleted />;
}
default:
assertUnreachable(location);
diff --git a/packages/challenger-ui/src/app.tsx b/packages/challenger-ui/src/app.tsx
index 2b5c5c815..655e46a5c 100644
--- a/packages/challenger-ui/src/app.tsx
+++ b/packages/challenger-ui/src/app.tsx
@@ -29,18 +29,16 @@ import {
TalerWalletIntegrationBrowserProvider,
TranslationProvider,
} from "@gnu-taler/web-util/browser";
+import { VNode, h } from "preact";
import { useEffect, useState } from "preact/hooks";
import { SWRConfig } from "swr";
import { Routing } from "./Routing.js";
-// import { BankCoreApiProvider } from "./context/config.js";
-// import { BrowserHashNavigationProvider } from "./context/navigation.js";
import { SettingsProvider } from "./context/settings.js";
-// import { TalerWalletIntegrationBrowserProvider } from "./context/wallet-integration.js";
-import { VNode, h } from "preact";
+import { revalidateChallengeSession } from "./hooks/challenge.js";
import { strings } from "./i18n/strings.js";
-import { ChallengerUiSettings, fetchSettings } from "./settings.js";
import { Frame } from "./pages/Frame.js";
-import { revalidateChallengeSession } from "./hooks/challenge.js";
+import { ChallengerUiSettings, fetchSettings } from "./settings.js";
+
const WITH_LOCAL_STORAGE_CACHE = false;
const evictBankSwrCache: CacheEvictor<ChallengerCacheEviction> = {
@@ -50,6 +48,10 @@ const evictBankSwrCache: CacheEvictor<ChallengerCacheEviction> = {
await Promise.all([revalidateChallengeSession()]);
return;
}
+ case ChallengerCacheEviction.SOLVE_CHALLENGE: {
+ await Promise.all([revalidateChallengeSession()]);
+ return;
+ }
default: {
assertUnreachable(op);
}
diff --git a/packages/challenger-ui/src/attempts-exhausted.html b/packages/challenger-ui/src/attempts-exhausted.html
deleted file mode 100644
index c2468b98b..000000000
--- a/packages/challenger-ui/src/attempts-exhausted.html
+++ /dev/null
@@ -1,88 +0,0 @@
-<!--
- This file is part of GNU Taler
- (C) 2021--2022 Taler Systems S.A.
-
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-
- @author Sebastian Javier Marchano
--->
-<!DOCTYPE html>
-<html lang="en" class="h-full">
-
-<head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <meta name="taler-support" content="uri">
- <meta name="mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <link rel="icon"
- href="data:;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////7//v38//78/P/+/fz//vz7///+/v/+/f3//vz7///+/v/+/fz//v38///////////////////////+/v3///7+/////////////////////////////////////////////////////////v3//v79///////+/v3///////r28v/ct5//06SG/9Gffv/Xqo7/7N/V/9e2nf/bsJb/6uDW/9Sskf/euKH/+/j2///////+/v3//////+3azv+/eE3/2rWd/9Kkhv/Vr5T/48i2/8J+VP/Qn3//3ryn/795Tf/WrpP/2LCW/8B6T//w4Nb///////Pn4P+/d0v/9u3n/+7d0v/EhV7//v///+HDr//fxLD/zph2/+TJt//8/Pv/woBX//Lm3f/y5dz/v3hN//bu6f/JjGn/4sW0///////Df1j/8OLZ//v6+P+/elH/+vj1//jy7f+/elL//////+zYzP/Eg13//////967p//MlHT/wn5X///////v4Nb/yY1s///////jw7H/06KG////////////z5t9/+fNvf//////x4pn//Pp4v/8+vn/w39X/8WEX///////5s/A/9CbfP//////27Oc/9y2n////////////9itlf/gu6f//////86Vdf/r2Mz//////8SCXP/Df1j//////+7d0v/KkG7//////+HBrf/VpYr////////////RnoH/5sq6///////Ii2n/8ubf//39/P/Cf1j/xohk/+bNvv//////wn5W//Tq4//58/D/wHxV//7+/f/59fH/v3xU//39/P/w4Nf/xIFb///////hw7H/yo9t/+/f1f/AeU3/+/n2/+nSxP/FhmD//////9qzm//Upon/4MSx/96+qf//////xINc/+3bz//48e3/v3hN//Pn3///////6M+//752S//gw6//06aK/8J+VP/kzLr/zZd1/8OCWv/q18r/17KZ/9Ooi//fv6r/v3dK/+vWyP///////v39///////27un/1aeK/9Opjv/m1cf/1KCC/9a0nP/n08T/0Jx8/82YdP/QnHz/16yR//jx7P///////v39///////+/f3///7+///////+//7//v7+///////+/v7//v/+/////////////////////////v7//v79///////////////////+/v/+/Pv//v39///+/v/+/Pv///7+//7+/f/+/Pv//v39//79/P/+/Pv///7+////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" />
- <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
- <link rel="stylesheet" href="main.css" />
- <script type="module" src="main.js"></script>
- <title>Attempts exhausted (#{{ec}})</title>
-</head>
-
-<body class="min-h-full flex flex-col">
- <header class="bg-indigo-600 w-full mx-auto px-2 border-b border-opacity-25 border-indigo-400">
- <div class="flex flex-row h-16 items-center ">
- <div class="flex px-2 justify-start">
- <div class="flex-shrink-0 bg-white rounded-lg"><a href="#"><img class="h-8 w-auto"
- src="data:image/svg+xml,<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?>%0A<svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 201 90&quot;>%0A <g fill=&quot;%230042b3&quot; fill-rule=&quot;evenodd&quot; stroke-width=&quot;.3&quot;>%0A <path d=&quot;M86.7 1.1c15.6 0 29 9.4 36 23.2h-5.9A35.1 35.1 0 0086.7 6.5C67 6.5 51 23.6 51 44.7c0 10.4 3.8 19.7 10 26.6a31.4 31.4 0 01-4.2 3A45.2 45.2 0 0146 44.7c0-24 18.2-43.6 40.7-43.6zm35.8 64.3a40.4 40.4 0 01-39 22.8c3-1.5 6-3.5 8.6-5.7a35.6 35.6 0 0024.6-17.1z&quot; />%0A <path d=&quot;M64.2 1.1l3.1.1c-3 1.6-5.9 3.5-8.5 5.8a37.5 37.5 0 00-30.2 37.7c0 14.3 7.3 26.7 18 33.3a29.6 29.6 0 01-8.5.2c-9-8-14.6-20-14.6-33.5 0-24 18.2-43.6 40.7-43.6zm5.4 81.4a35.6 35.6 0 0024.6-17.1h5.9a40.4 40.4 0 01-39 22.8c3-1.5 5.9-3.5 8.5-5.7zm24.8-58.2a37 37 0 00-12.6-12.8 29.6 29.6 0 018.5-.2c4 3.6 7.4 8 9.9 13z&quot; />%0A <path d=&quot;M41.8 1.1c1 0 2 0 3.1.2-3 1.5-5.9 3.4-8.5 5.6A37.5 37.5 0 006.1 44.7c0 21.1 16 38.3 35.7 38.3 12.6 0 23.6-7 30-17.6h5.8a40.4 40.4 0 01-35.8 23C19.3 88.4 1 68.8 1 44.7c0-24 18.2-43.6 40.7-43.6zm30.1 23.2a38.1 38.1 0 00-4.5-6.1c1.3-1.2 2.7-2.2 4.3-3 2.3 2.7 4.4 5.8 6 9.1z&quot; />%0A </g>%0A <path d=&quot;M76.1 34.4h9.2v-5H61.9v5H71v26h5.1zM92.6 52.9h13.7l3 7.4h5.3l-12.7-31.2h-4.7L84.5 60.3h5.2zm11.8-4.9h-9.9l5-12.4zM123.8 29.4h-4.6v31h20.6v-5h-16zM166.5 29.4H145v31h21.6v-5H150v-8.3h14.5v-4.9h-14.5v-8h16.4zM191.2 39.5c0 1.6-.5 2.8-1.6 3.8s-2.6 1.4-4.4 1.4h-7.4V34.3h7.4c1.9 0 3.4.4 4.4 1.3 1 .9 1.6 2.2 1.6 3.9zm6 20.8l-7.7-11.7c1-.3 1.9-.7 2.7-1.3a8.8 8.8 0 003.6-4.6c.4-1 .5-2.2.5-3.5 0-1.5-.2-2.9-.7-4.1a8.4 8.4 0 00-2.1-3.1c-1-.8-2-1.5-3.4-2-1.3-.4-2.8-.6-4.5-.6h-12.9v31h5V49.4h6.5l7 10.8z&quot; />%0A</svg>"
- alt="GNU Taler" style="height: 1.5rem; margin: 0.5rem;"></a></div><span
- class="flex items-center text-white text-lg font-bold ml-4">Challenger</span>
- </div>
- <div class="block flex-1 ml-6 "></div>
- <div class="flex justify-end">
- </div>
- </div>
- </header>
-
- <main class="flex-1">
- <div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 items-center mt-4">
- <div class="rounded-md bg-red-50 p-4 shadow-xl">
- <div class="flex">
- <div class="flex-shrink-0">
- <svg xmlns="http://www.w3.org/2000/svg" stroke="none" viewBox="0 0 24 24" fill="currentColor"
- class="w-8 h-8 text-red-400">
- <path fill-rule="evenodd"
- d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z" />
- </svg>
- </div>
- <div class="ml-3">
- <h3 class="text-sm font-medium text-red-800">
- You have tried too many times
- </h3>
- <div class="mt-2 text-sm text-red-700">
- <p>More attempts are not allowed</p>
- </div>
- </div>
- </div>
- </div>
- </div>
- </main>
-
- <footer class="bottom-4 mb-4">
- <div class="mt-8 mx-8 md:order-1 md:mt-0">
- <div>
- <p class="text-xs leading-5 text-gray-400">Learn more about <a target="_blank" rel="noreferrer noopener"
- class="font-semibold text-gray-500 hover:text-gray-400" href="https://taler.net">GNU Taler</a></p>
- </div>
- <div style="flex-grow: 1;"></div>
- <p class="text-xs leading-5 text-gray-400">Copyright © 2014—2023 Taler Systems SA. </p>
- </div>
- </footer>
-
-</body>
-
-</html> \ No newline at end of file
diff --git a/packages/challenger-ui/src/components/CheckChallengeIsUpToDate.tsx b/packages/challenger-ui/src/components/CheckChallengeIsUpToDate.tsx
index 70e41bf1e..fecb36cbb 100644
--- a/packages/challenger-ui/src/components/CheckChallengeIsUpToDate.tsx
+++ b/packages/challenger-ui/src/components/CheckChallengeIsUpToDate.tsx
@@ -28,42 +28,23 @@ import { useChallengeSession } from "../hooks/challenge.js";
import { SessionId, useSessionState } from "../hooks/session.js";
interface Props {
- nonce: string;
+ session: SessionId;
children: ComponentChildren;
- sessionId?: SessionId;
onCompleted?: () => void;
onChangeLeft?: () => void;
onNoMoreChanges?: () => void;
- onNoInfo: () => void;
}
export function CheckChallengeIsUpToDate({
- sessionId: sessionFromParam,
- nonce,
+ session,
children,
onCompleted,
onChangeLeft,
onNoMoreChanges,
- onNoInfo,
}: Props): VNode {
- const { state, updateStatus } = useSessionState();
+ const { state } = useSessionState();
const { i18n } = useTranslationContext();
- const sessionId = sessionFromParam
- ? sessionFromParam
- : !state
- ? undefined
- : {
- clientId: state.clientId,
- redirectURL: state.redirectURL,
- state: state.state,
- };
-
- const result = useChallengeSession(nonce, sessionId);
- console.log("asd");
- if (!sessionId) {
- onNoInfo();
- return <Loading />;
- }
+ const result = useChallengeSession(session);
if (!result) {
return <Loading />;
@@ -106,14 +87,31 @@ export function CheckChallengeIsUpToDate({
</Attention>
);
}
+ case HttpStatusCode.TooManyRequests: {
+ return (
+ <Fragment>
+ <Attention
+ type="danger"
+ title={i18n.str`Can't complete this challenge`}
+ >
+ <i18n.Translate>
+ There have been too many attempts to request challenge
+ transmissions and check the TAN code.
+ </i18n.Translate>
+ </Attention>
+
+ <div class="mt-2">
+ <a href={session.redirectURL ?? ""}>{session.redirectURL}</a>
+ </div>
+ </Fragment>
+ );
+ }
default:
assertUnreachable(result);
}
}
- updateStatus(result.body);
-
- if (onCompleted && "redirectURL" in result.body) {
+ if (onCompleted && result.body.solved) {
onCompleted();
return <Loading />;
}
@@ -123,7 +121,7 @@ export function CheckChallengeIsUpToDate({
return <Loading />;
}
- if (onChangeLeft && !result.body.changes_left) {
+ if (onChangeLeft && result.body.changes_left) {
onChangeLeft();
return <Loading />;
}
diff --git a/packages/challenger-ui/src/context/preferences.ts b/packages/challenger-ui/src/context/preferences.ts
new file mode 100644
index 000000000..3188bd71c
--- /dev/null
+++ b/packages/challenger-ui/src/context/preferences.ts
@@ -0,0 +1,87 @@
+/*
+ This file is part of GNU Taler
+ (C) 2022-2024 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+import {
+ Codec,
+ TranslatedString,
+ buildCodecForObject,
+ codecForBoolean,
+} from "@gnu-taler/taler-util";
+import {
+ buildStorageKey,
+ useLocalStorage,
+ useTranslationContext,
+} from "@gnu-taler/web-util/browser";
+
+interface Preferences {
+ showChallangeSetup: boolean;
+ showDebugInfo: boolean;
+}
+
+export const codecForPreferences = (): Codec<Preferences> =>
+ buildCodecForObject<Preferences>()
+ .property("showChallangeSetup", codecForBoolean())
+ .property("showDebugInfo", codecForBoolean())
+ .build("Preferences");
+
+const defaultPreferences: Preferences = {
+ showChallangeSetup: false,
+ showDebugInfo: false,
+};
+
+const PREFERENCES_KEY = buildStorageKey(
+ "challenger-preferences",
+ codecForPreferences(),
+);
+/**
+ * User preferences.
+ *
+ * @returns tuple of [state, update()]
+ */
+export function usePreferences(): [
+ Readonly<Preferences>,
+ <T extends keyof Preferences>(key: T, value: Preferences[T]) => void,
+] {
+ const { value, update } = useLocalStorage(
+ PREFERENCES_KEY,
+ defaultPreferences,
+ );
+
+ function updateField<T extends keyof Preferences>(k: T, v: Preferences[T]) {
+ const newValue = { ...value, [k]: v };
+ update(newValue);
+ }
+ return [value, updateField];
+}
+
+export function getAllBooleanPreferences(): Array<keyof Preferences> {
+ return [
+ "showChallangeSetup",
+ "showDebugInfo",
+ ];
+}
+
+export function getLabelForPreferences(
+ k: keyof Preferences,
+ i18n: ReturnType<typeof useTranslationContext>["i18n"],
+): TranslatedString {
+ switch (k) {
+ case "showChallangeSetup":
+ return i18n.str`Show challenger setup screen`;
+ case "showDebugInfo":
+ return i18n.str`Show debug info`;
+ }
+}
diff --git a/packages/challenger-ui/src/declaration.d.ts b/packages/challenger-ui/src/declaration.d.ts
new file mode 100644
index 000000000..581cbcd07
--- /dev/null
+++ b/packages/challenger-ui/src/declaration.d.ts
@@ -0,0 +1,35 @@
+/*
+ This file is part of GNU Taler
+ (C) 2022-2024 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+declare module "*.css" {
+ const mapping: Record<string, string>;
+ export default mapping;
+}
+declare module "*.svg" {
+ const content: string;
+ export default content;
+}
+declare module "*.jpeg" {
+ const content: string;
+ export default content;
+}
+declare module "*.png" {
+ const content: string;
+ export default content;
+}
+
+declare const __VERSION__: string;
+declare const __GIT_HASH__: string;
diff --git a/packages/challenger-ui/src/enter-address-form.html b/packages/challenger-ui/src/enter-address-form.html
deleted file mode 100644
index 76b4d2262..000000000
--- a/packages/challenger-ui/src/enter-address-form.html
+++ /dev/null
@@ -1,133 +0,0 @@
-<!--
- This file is part of GNU Taler
- (C) 2021--2023 Taler Systems S.A.
-
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-
- @author Sebastian Javier Marchano
--->
-<!DOCTYPE html>
-<html lang="en" class="h-full">
-
-<head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <meta name="taler-support" content="uri">
- <meta name="mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <link rel="icon"
- href="data:;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////7//v38//78/P/+/fz//vz7///+/v/+/f3//vz7///+/v/+/fz//v38///////////////////////+/v3///7+/////////////////////////////////////////////////////////v3//v79///////+/v3///////r28v/ct5//06SG/9Gffv/Xqo7/7N/V/9e2nf/bsJb/6uDW/9Sskf/euKH/+/j2///////+/v3//////+3azv+/eE3/2rWd/9Kkhv/Vr5T/48i2/8J+VP/Qn3//3ryn/795Tf/WrpP/2LCW/8B6T//w4Nb///////Pn4P+/d0v/9u3n/+7d0v/EhV7//v///+HDr//fxLD/zph2/+TJt//8/Pv/woBX//Lm3f/y5dz/v3hN//bu6f/JjGn/4sW0///////Df1j/8OLZ//v6+P+/elH/+vj1//jy7f+/elL//////+zYzP/Eg13//////967p//MlHT/wn5X///////v4Nb/yY1s///////jw7H/06KG////////////z5t9/+fNvf//////x4pn//Pp4v/8+vn/w39X/8WEX///////5s/A/9CbfP//////27Oc/9y2n////////////9itlf/gu6f//////86Vdf/r2Mz//////8SCXP/Df1j//////+7d0v/KkG7//////+HBrf/VpYr////////////RnoH/5sq6///////Ii2n/8ubf//39/P/Cf1j/xohk/+bNvv//////wn5W//Tq4//58/D/wHxV//7+/f/59fH/v3xU//39/P/w4Nf/xIFb///////hw7H/yo9t/+/f1f/AeU3/+/n2/+nSxP/FhmD//////9qzm//Upon/4MSx/96+qf//////xINc/+3bz//48e3/v3hN//Pn3///////6M+//752S//gw6//06aK/8J+VP/kzLr/zZd1/8OCWv/q18r/17KZ/9Ooi//fv6r/v3dK/+vWyP///////v39///////27un/1aeK/9Opjv/m1cf/1KCC/9a0nP/n08T/0Jx8/82YdP/QnHz/16yR//jx7P///////v39///////+/f3///7+///////+//7//v7+///////+/v7//v/+/////////////////////////v7//v79///////////////////+/v/+/Pv//v39///+/v/+/Pv///7+//7+/f/+/Pv//v39//79/P/+/Pv///7+////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" />
- <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
- <link rel="stylesheet" href="main.css" />
- <script type="module" src="main.js"></script>
- <title>Enter contact details</title>
-</head>
-
-<body class="min-h-full flex flex-col">
- <header class="bg-indigo-600 w-full mx-auto px-2 border-b border-opacity-25 border-indigo-400">
- <div class="flex flex-row h-16 items-center ">
- <div class="flex px-2 justify-start">
- <div class="flex-shrink-0 bg-white rounded-lg"><a href="#"><img class="h-8 w-auto"
- src="data:image/svg+xml,<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?>%0A<svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 201 90&quot;>%0A <g fill=&quot;%230042b3&quot; fill-rule=&quot;evenodd&quot; stroke-width=&quot;.3&quot;>%0A <path d=&quot;M86.7 1.1c15.6 0 29 9.4 36 23.2h-5.9A35.1 35.1 0 0086.7 6.5C67 6.5 51 23.6 51 44.7c0 10.4 3.8 19.7 10 26.6a31.4 31.4 0 01-4.2 3A45.2 45.2 0 0146 44.7c0-24 18.2-43.6 40.7-43.6zm35.8 64.3a40.4 40.4 0 01-39 22.8c3-1.5 6-3.5 8.6-5.7a35.6 35.6 0 0024.6-17.1z&quot; />%0A <path d=&quot;M64.2 1.1l3.1.1c-3 1.6-5.9 3.5-8.5 5.8a37.5 37.5 0 00-30.2 37.7c0 14.3 7.3 26.7 18 33.3a29.6 29.6 0 01-8.5.2c-9-8-14.6-20-14.6-33.5 0-24 18.2-43.6 40.7-43.6zm5.4 81.4a35.6 35.6 0 0024.6-17.1h5.9a40.4 40.4 0 01-39 22.8c3-1.5 5.9-3.5 8.5-5.7zm24.8-58.2a37 37 0 00-12.6-12.8 29.6 29.6 0 018.5-.2c4 3.6 7.4 8 9.9 13z&quot; />%0A <path d=&quot;M41.8 1.1c1 0 2 0 3.1.2-3 1.5-5.9 3.4-8.5 5.6A37.5 37.5 0 006.1 44.7c0 21.1 16 38.3 35.7 38.3 12.6 0 23.6-7 30-17.6h5.8a40.4 40.4 0 01-35.8 23C19.3 88.4 1 68.8 1 44.7c0-24 18.2-43.6 40.7-43.6zm30.1 23.2a38.1 38.1 0 00-4.5-6.1c1.3-1.2 2.7-2.2 4.3-3 2.3 2.7 4.4 5.8 6 9.1z&quot; />%0A </g>%0A <path d=&quot;M76.1 34.4h9.2v-5H61.9v5H71v26h5.1zM92.6 52.9h13.7l3 7.4h5.3l-12.7-31.2h-4.7L84.5 60.3h5.2zm11.8-4.9h-9.9l5-12.4zM123.8 29.4h-4.6v31h20.6v-5h-16zM166.5 29.4H145v31h21.6v-5H150v-8.3h14.5v-4.9h-14.5v-8h16.4zM191.2 39.5c0 1.6-.5 2.8-1.6 3.8s-2.6 1.4-4.4 1.4h-7.4V34.3h7.4c1.9 0 3.4.4 4.4 1.3 1 .9 1.6 2.2 1.6 3.9zm6 20.8l-7.7-11.7c1-.3 1.9-.7 2.7-1.3a8.8 8.8 0 003.6-4.6c.4-1 .5-2.2.5-3.5 0-1.5-.2-2.9-.7-4.1a8.4 8.4 0 00-2.1-3.1c-1-.8-2-1.5-3.4-2-1.3-.4-2.8-.6-4.5-.6h-12.9v31h5V49.4h6.5l7 10.8z&quot; />%0A</svg>"
- alt="GNU Taler" style="height: 1.5rem; margin: 0.5rem;"></a></div><span
- class="flex items-center text-white text-lg font-bold ml-4">Challenger</span>
- </div>
- <div class="block flex-1 ml-6 "></div>
- <div class="flex justify-end">
- </div>
- </div>
- </header>
-
- <main class="flex-1">
-
- <div class="isolate bg-white px-6 py-12">
- <div class="mx-auto max-w-2xl text-center">
- <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
- Enter contact details
- </h2>
- <p class="mt-2 text-lg leading-8 text-gray-600">
- You will receive a letter with a TAN code that must be provided on the next page.
- </p>
- </div>
- <form action="/challenge/{{nonce}}" method="POST" class="mx-auto mt-16 max-w-xl sm:mt-20">
- <div class="grid grid-cols-1 gap-x-8 gap-y-6">
- <div class="sm:col-span-2">
- <label for="address" class="block text-sm font-semibold leading-6 text-gray-900">
- Street address
- </label>
- <div class="mt-2.5">
- <textarea name="address" id="address" rows="3" autocomplete="shipping street-address"
- class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"></textarea>
-
- </div>
- </div>
-
- <div class="sm:col-span-2">
- <label for="city" class="block text-sm font-semibold leading-6 text-gray-900">
- City
- </label>
- <div class="mt-2.5">
- <input type="text" name="city" id="city" maxlength="512" autocomplete="address-level2"
- class="block w-full rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
- </div>
- </div>
-
- <div class="sm:col-span-2">
- <label for="postal-code" class="block text-sm font-semibold leading-6 text-gray-900">
- Postal code
- </label>
- <div class="mt-2.5">
- <input type="text" name="postal-code" id="postal-code" maxlength="512" autocomplete="postal-code"
- class="block w-full rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
- </div>
- </div>
-
- <div class="sm:col-span-2">
- <label for="country" class="block text-sm font-semibold leading-6 text-gray-900">
- Country
- </label>
- <div class="mt-2.5">
- <input type="text" name="country" id="country" maxlength="512" autocomplete="country"
- class="block w-full rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
- </div>
- </div>
-
- <p class="mt-3 text-sm leading-6 text-gray-400">
- You can change address another {{changes_left}} times.
- </p>
- </div>
-
- <div class="mt-10">
- <button type="submit"
- class="block w-full rounded-md bg-indigo-600 px-3.5 py-2.5 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
- Send mail
- </button>
- </div>
- </form>
- </div>
- </main>
-
-
- <footer class="bottom-4 mb-4">
- <div class="mt-8 mx-8 md:order-1 md:mt-0">
- <div>
- <p class="text-xs leading-5 text-gray-400">Learn more about <a target="_blank" rel="noreferrer noopener"
- class="font-semibold text-gray-500 hover:text-gray-400" href="https://taler.net">GNU Taler</a></p>
- </div>
- <div style="flex-grow: 1;"></div>
- <p class="text-xs leading-5 text-gray-400">Copyright © 2014—2023 Taler Systems SA. </p>
- </div>
- </footer>
-</body>
-
-</html>
diff --git a/packages/challenger-ui/src/enter-email-form.html b/packages/challenger-ui/src/enter-email-form.html
deleted file mode 100644
index 3b8720244..000000000
--- a/packages/challenger-ui/src/enter-email-form.html
+++ /dev/null
@@ -1,127 +0,0 @@
-<!--
- This file is part of GNU Taler
- (C) 2021--2022 Taler Systems S.A.
-
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-
- @author Sebastian Javier Marchano
--->
-<!DOCTYPE html>
-<html lang="en" class="h-full">
-
-<head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <meta name="taler-support" content="uri">
- <meta name="mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <link rel="icon"
- href="data:;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////7//v38//78/P/+/fz//vz7///+/v/+/f3//vz7///+/v/+/fz//v38///////////////////////+/v3///7+/////////////////////////////////////////////////////////v3//v79///////+/v3///////r28v/ct5//06SG/9Gffv/Xqo7/7N/V/9e2nf/bsJb/6uDW/9Sskf/euKH/+/j2///////+/v3//////+3azv+/eE3/2rWd/9Kkhv/Vr5T/48i2/8J+VP/Qn3//3ryn/795Tf/WrpP/2LCW/8B6T//w4Nb///////Pn4P+/d0v/9u3n/+7d0v/EhV7//v///+HDr//fxLD/zph2/+TJt//8/Pv/woBX//Lm3f/y5dz/v3hN//bu6f/JjGn/4sW0///////Df1j/8OLZ//v6+P+/elH/+vj1//jy7f+/elL//////+zYzP/Eg13//////967p//MlHT/wn5X///////v4Nb/yY1s///////jw7H/06KG////////////z5t9/+fNvf//////x4pn//Pp4v/8+vn/w39X/8WEX///////5s/A/9CbfP//////27Oc/9y2n////////////9itlf/gu6f//////86Vdf/r2Mz//////8SCXP/Df1j//////+7d0v/KkG7//////+HBrf/VpYr////////////RnoH/5sq6///////Ii2n/8ubf//39/P/Cf1j/xohk/+bNvv//////wn5W//Tq4//58/D/wHxV//7+/f/59fH/v3xU//39/P/w4Nf/xIFb///////hw7H/yo9t/+/f1f/AeU3/+/n2/+nSxP/FhmD//////9qzm//Upon/4MSx/96+qf//////xINc/+3bz//48e3/v3hN//Pn3///////6M+//752S//gw6//06aK/8J+VP/kzLr/zZd1/8OCWv/q18r/17KZ/9Ooi//fv6r/v3dK/+vWyP///////v39///////27un/1aeK/9Opjv/m1cf/1KCC/9a0nP/n08T/0Jx8/82YdP/QnHz/16yR//jx7P///////v39///////+/f3///7+///////+//7//v7+///////+/v7//v/+/////////////////////////v7//v79///////////////////+/v/+/Pv//v39///+/v/+/Pv///7+//7+/f/+/Pv//v39//79/P/+/Pv///7+////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" />
- <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
- <link rel="stylesheet" href="main.css" />
- <script type="module" src="main.js"></script>
- <title>Enter contact details</title>
-</head>
-
-<body class="min-h-full flex flex-col">
- <header class="bg-indigo-600 w-full mx-auto px-2 border-b border-opacity-25 border-indigo-400">
- <div class="flex flex-row h-16 items-center ">
- <div class="flex px-2 justify-start">
- <div class="flex-shrink-0 bg-white rounded-lg"><a href="#"><img class="h-8 w-auto"
- src="data:image/svg+xml,<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?>%0A<svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 201 90&quot;>%0A <g fill=&quot;%230042b3&quot; fill-rule=&quot;evenodd&quot; stroke-width=&quot;.3&quot;>%0A <path d=&quot;M86.7 1.1c15.6 0 29 9.4 36 23.2h-5.9A35.1 35.1 0 0086.7 6.5C67 6.5 51 23.6 51 44.7c0 10.4 3.8 19.7 10 26.6a31.4 31.4 0 01-4.2 3A45.2 45.2 0 0146 44.7c0-24 18.2-43.6 40.7-43.6zm35.8 64.3a40.4 40.4 0 01-39 22.8c3-1.5 6-3.5 8.6-5.7a35.6 35.6 0 0024.6-17.1z&quot; />%0A <path d=&quot;M64.2 1.1l3.1.1c-3 1.6-5.9 3.5-8.5 5.8a37.5 37.5 0 00-30.2 37.7c0 14.3 7.3 26.7 18 33.3a29.6 29.6 0 01-8.5.2c-9-8-14.6-20-14.6-33.5 0-24 18.2-43.6 40.7-43.6zm5.4 81.4a35.6 35.6 0 0024.6-17.1h5.9a40.4 40.4 0 01-39 22.8c3-1.5 5.9-3.5 8.5-5.7zm24.8-58.2a37 37 0 00-12.6-12.8 29.6 29.6 0 018.5-.2c4 3.6 7.4 8 9.9 13z&quot; />%0A <path d=&quot;M41.8 1.1c1 0 2 0 3.1.2-3 1.5-5.9 3.4-8.5 5.6A37.5 37.5 0 006.1 44.7c0 21.1 16 38.3 35.7 38.3 12.6 0 23.6-7 30-17.6h5.8a40.4 40.4 0 01-35.8 23C19.3 88.4 1 68.8 1 44.7c0-24 18.2-43.6 40.7-43.6zm30.1 23.2a38.1 38.1 0 00-4.5-6.1c1.3-1.2 2.7-2.2 4.3-3 2.3 2.7 4.4 5.8 6 9.1z&quot; />%0A </g>%0A <path d=&quot;M76.1 34.4h9.2v-5H61.9v5H71v26h5.1zM92.6 52.9h13.7l3 7.4h5.3l-12.7-31.2h-4.7L84.5 60.3h5.2zm11.8-4.9h-9.9l5-12.4zM123.8 29.4h-4.6v31h20.6v-5h-16zM166.5 29.4H145v31h21.6v-5H150v-8.3h14.5v-4.9h-14.5v-8h16.4zM191.2 39.5c0 1.6-.5 2.8-1.6 3.8s-2.6 1.4-4.4 1.4h-7.4V34.3h7.4c1.9 0 3.4.4 4.4 1.3 1 .9 1.6 2.2 1.6 3.9zm6 20.8l-7.7-11.7c1-.3 1.9-.7 2.7-1.3a8.8 8.8 0 003.6-4.6c.4-1 .5-2.2.5-3.5 0-1.5-.2-2.9-.7-4.1a8.4 8.4 0 00-2.1-3.1c-1-.8-2-1.5-3.4-2-1.3-.4-2.8-.6-4.5-.6h-12.9v31h5V49.4h6.5l7 10.8z&quot; />%0A</svg>"
- alt="GNU Taler" style="height: 1.5rem; margin: 0.5rem;"></a></div><span
- class="flex items-center text-white text-lg font-bold ml-4">Challenger</span>
- </div>
- <div class="block flex-1 ml-6 "></div>
- <div class="flex justify-end">
- </div>
- </div>
- </header>
-
- <main class="flex-1">
-
- <div class="isolate bg-white px-6 py-12">
- <div class="mx-auto max-w-2xl text-center">
- <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
- Enter contact details
- </h2>
- <p class="mt-2 text-lg leading-8 text-gray-600">
- You will receive an email with a TAN code that must be provided on the next page.
- </p>
- </div>
- <form action="/challenge/{{nonce}}" method="POST" class="mx-auto mt-16 max-w-xl sm:mt-20">
- <div class="grid grid-cols-1 gap-x-8 gap-y-6">
- <div class="sm:col-span-2">
- <label for="email" class="block text-sm font-semibold leading-6 text-gray-900">
- Email
- </label>
- <div class="mt-2.5">
- <input type="email" name="email" id="email" maxlength="512" autocomplete="email" value="{{last_address}}"
- {{#fixed_address}}readonly{{/fixed_address}}
- class="block w-full rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
- </div>
- </div>
-
- <script>
- function check() {
- var email = document.getElementById('email');
- var emailRepeat = document.getElementById('repeat-email');
-
- if (email.value != emailRepeat.value) {
- emailRepeat.setCustomValidity('The two email addresses must match.');
- } else {
- // input is valid -- reset the error message
- emailRepeat.setCustomValidity('');
- }
- }
- </script>
-
- <div class="sm:col-span-2">
- <label for="repeat-email" class="block text-sm font-semibold leading-6 text-gray-900">
- Repeat email
- </label>
- <div class="mt-2.5">
- <input oninput="check(this)" type="email" name="repeat-email" id="repeat-email" autocomplete="email"
- class="block w-full rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
- </div>
- </div>
-
- <p class="mt-3 text-sm leading-6 text-gray-400">
- You can change your email address another {{changes_left}} times.
- </p>
- </div>
-
- <div class="mt-10">
- <button type="submit"
- class="block w-full rounded-md bg-indigo-600 px-3.5 py-2.5 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
- Send email
- </button>
- </div>
- </form>
- </div>
- </main>
-
-
- <footer class="bottom-4 mb-4">
- <div class="mt-8 mx-8 md:order-1 md:mt-0">
- <div>
- <p class="text-xs leading-5 text-gray-400">Learn more about <a target="_blank" rel="noreferrer noopener"
- class="font-semibold text-gray-500 hover:text-gray-400" href="https://taler.net">GNU Taler</a></p>
- </div>
- <div style="flex-grow: 1;"></div>
- <p class="text-xs leading-5 text-gray-400">Copyright © 2014—2023 Taler Systems SA. </p>
- </div>
- </footer>
-</body>
-
-</html>
diff --git a/packages/challenger-ui/src/enter-file-access-form.html b/packages/challenger-ui/src/enter-file-access-form.html
deleted file mode 100644
index b79d1dada..000000000
--- a/packages/challenger-ui/src/enter-file-access-form.html
+++ /dev/null
@@ -1,102 +0,0 @@
-<!--
- This file is part of GNU Taler
- (C) 2021--2023 Taler Systems S.A.
-
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-
- @author Sebastian Javier Marchano
--->
-<!DOCTYPE html>
-<html lang="en" class="h-full">
-
-<head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <meta name="taler-support" content="uri">
- <meta name="mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <link rel="icon"
- href="data:;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////7//v38//78/P/+/fz//vz7///+/v/+/f3//vz7///+/v/+/fz//v38///////////////////////+/v3///7+/////////////////////////////////////////////////////////v3//v79///////+/v3///////r28v/ct5//06SG/9Gffv/Xqo7/7N/V/9e2nf/bsJb/6uDW/9Sskf/euKH/+/j2///////+/v3//////+3azv+/eE3/2rWd/9Kkhv/Vr5T/48i2/8J+VP/Qn3//3ryn/795Tf/WrpP/2LCW/8B6T//w4Nb///////Pn4P+/d0v/9u3n/+7d0v/EhV7//v///+HDr//fxLD/zph2/+TJt//8/Pv/woBX//Lm3f/y5dz/v3hN//bu6f/JjGn/4sW0///////Df1j/8OLZ//v6+P+/elH/+vj1//jy7f+/elL//////+zYzP/Eg13//////967p//MlHT/wn5X///////v4Nb/yY1s///////jw7H/06KG////////////z5t9/+fNvf//////x4pn//Pp4v/8+vn/w39X/8WEX///////5s/A/9CbfP//////27Oc/9y2n////////////9itlf/gu6f//////86Vdf/r2Mz//////8SCXP/Df1j//////+7d0v/KkG7//////+HBrf/VpYr////////////RnoH/5sq6///////Ii2n/8ubf//39/P/Cf1j/xohk/+bNvv//////wn5W//Tq4//58/D/wHxV//7+/f/59fH/v3xU//39/P/w4Nf/xIFb///////hw7H/yo9t/+/f1f/AeU3/+/n2/+nSxP/FhmD//////9qzm//Upon/4MSx/96+qf//////xINc/+3bz//48e3/v3hN//Pn3///////6M+//752S//gw6//06aK/8J+VP/kzLr/zZd1/8OCWv/q18r/17KZ/9Ooi//fv6r/v3dK/+vWyP///////v39///////27un/1aeK/9Opjv/m1cf/1KCC/9a0nP/n08T/0Jx8/82YdP/QnHz/16yR//jx7P///////v39///////+/f3///7+///////+//7//v7+///////+/v7//v/+/////////////////////////v7//v79///////////////////+/v/+/Pv//v39///+/v/+/Pv///7+//7+/f/+/Pv//v39//79/P/+/Pv///7+////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" />
- <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
- <link rel="stylesheet" href="main.css" />
- <script type="module" src="main.js"></script>
- <title>Enter local file name</title>
-</head>
-
-<body class="min-h-full flex flex-col">
- <header class="bg-indigo-600 w-full mx-auto px-2 border-b border-opacity-25 border-indigo-400">
- <div class="flex flex-row h-16 items-center ">
- <div class="flex px-2 justify-start">
- <div class="flex-shrink-0 bg-white rounded-lg"><a href="#"><img class="h-8 w-auto"
- src="data:image/svg+xml,<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?>%0A<svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 201 90&quot;>%0A <g fill=&quot;%230042b3&quot; fill-rule=&quot;evenodd&quot; stroke-width=&quot;.3&quot;>%0A <path d=&quot;M86.7 1.1c15.6 0 29 9.4 36 23.2h-5.9A35.1 35.1 0 0086.7 6.5C67 6.5 51 23.6 51 44.7c0 10.4 3.8 19.7 10 26.6a31.4 31.4 0 01-4.2 3A45.2 45.2 0 0146 44.7c0-24 18.2-43.6 40.7-43.6zm35.8 64.3a40.4 40.4 0 01-39 22.8c3-1.5 6-3.5 8.6-5.7a35.6 35.6 0 0024.6-17.1z&quot; />%0A <path d=&quot;M64.2 1.1l3.1.1c-3 1.6-5.9 3.5-8.5 5.8a37.5 37.5 0 00-30.2 37.7c0 14.3 7.3 26.7 18 33.3a29.6 29.6 0 01-8.5.2c-9-8-14.6-20-14.6-33.5 0-24 18.2-43.6 40.7-43.6zm5.4 81.4a35.6 35.6 0 0024.6-17.1h5.9a40.4 40.4 0 01-39 22.8c3-1.5 5.9-3.5 8.5-5.7zm24.8-58.2a37 37 0 00-12.6-12.8 29.6 29.6 0 018.5-.2c4 3.6 7.4 8 9.9 13z&quot; />%0A <path d=&quot;M41.8 1.1c1 0 2 0 3.1.2-3 1.5-5.9 3.4-8.5 5.6A37.5 37.5 0 006.1 44.7c0 21.1 16 38.3 35.7 38.3 12.6 0 23.6-7 30-17.6h5.8a40.4 40.4 0 01-35.8 23C19.3 88.4 1 68.8 1 44.7c0-24 18.2-43.6 40.7-43.6zm30.1 23.2a38.1 38.1 0 00-4.5-6.1c1.3-1.2 2.7-2.2 4.3-3 2.3 2.7 4.4 5.8 6 9.1z&quot; />%0A </g>%0A <path d=&quot;M76.1 34.4h9.2v-5H61.9v5H71v26h5.1zM92.6 52.9h13.7l3 7.4h5.3l-12.7-31.2h-4.7L84.5 60.3h5.2zm11.8-4.9h-9.9l5-12.4zM123.8 29.4h-4.6v31h20.6v-5h-16zM166.5 29.4H145v31h21.6v-5H150v-8.3h14.5v-4.9h-14.5v-8h16.4zM191.2 39.5c0 1.6-.5 2.8-1.6 3.8s-2.6 1.4-4.4 1.4h-7.4V34.3h7.4c1.9 0 3.4.4 4.4 1.3 1 .9 1.6 2.2 1.6 3.9zm6 20.8l-7.7-11.7c1-.3 1.9-.7 2.7-1.3a8.8 8.8 0 003.6-4.6c.4-1 .5-2.2.5-3.5 0-1.5-.2-2.9-.7-4.1a8.4 8.4 0 00-2.1-3.1c-1-.8-2-1.5-3.4-2-1.3-.4-2.8-.6-4.5-.6h-12.9v31h5V49.4h6.5l7 10.8z&quot; />%0A</svg>"
- alt="GNU Taler" style="height: 1.5rem; margin: 0.5rem;"></a></div><span
- class="flex items-center text-white text-lg font-bold ml-4">Challenger</span>
- </div>
- <div class="block flex-1 ml-6 "></div>
- <div class="flex justify-end">
- </div>
- </div>
- </header>
-
- <main class="flex-1">
-
- <div class="isolate bg-white px-6 py-12">
- <div class="mx-auto max-w-2xl text-center">
- <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
- Enter file name
- </h2>
- <p class="mt-2 text-lg leading-8 text-gray-600">
- The file will be overwritten with a code which need to be entered in the next page.
- </p>
- </div>
- <form action="/challenge/{{nonce}}" method="POST" class="mx-auto mt-16 max-w-xl sm:mt-20">
- <div class="grid grid-cols-1 gap-x-8 gap-y-6">
- <div class="sm:col-span-2">
- <label for="phone" class="block text-sm font-semibold leading-6 text-gray-900">
- Phone number
- </label>
- <div class="mt-2.5">
- <input type="filename" name="filename" id="filename" maxlength="200"
- class="block w-full rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
- </div>
- </div>
-
- <p class="mt-3 text-sm leading-6 text-gray-400">
- You can change the filename another {{changes_left}} times.
- </p>
- </div>
-
- <div class="mt-10">
- <button type="submit"
- class="block w-full rounded-md bg-indigo-600 px-3.5 py-2.5 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
- Write file
- </button>
- </div>
- </form>
- </div>
- </main>
-
-
- <footer class="bottom-4 mb-4">
- <div class="mt-8 mx-8 md:order-1 md:mt-0">
- <div>
- <p class="text-xs leading-5 text-gray-400">Learn more about <a target="_blank" rel="noreferrer noopener"
- class="font-semibold text-gray-500 hover:text-gray-400" href="https://taler.net">GNU Taler</a></p>
- </div>
- <div style="flex-grow: 1;"></div>
- <p class="text-xs leading-5 text-gray-400">Copyright © 2014—2023 Taler Systems SA. </p>
- </div>
- </footer>
-</body>
-
-</html>
diff --git a/packages/challenger-ui/src/enter-phone-form.html b/packages/challenger-ui/src/enter-phone-form.html
deleted file mode 100644
index ca06fb94e..000000000
--- a/packages/challenger-ui/src/enter-phone-form.html
+++ /dev/null
@@ -1,126 +0,0 @@
-<!--
- This file is part of GNU Taler
- (C) 2021--2023 Taler Systems S.A.
-
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-
- @author Sebastian Javier Marchano
--->
-<!DOCTYPE html>
-<html lang="en" class="h-full">
-
-<head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <meta name="taler-support" content="uri">
- <meta name="mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <link rel="icon"
- href="data:;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////7//v38//78/P/+/fz//vz7///+/v/+/f3//vz7///+/v/+/fz//v38///////////////////////+/v3///7+/////////////////////////////////////////////////////////v3//v79///////+/v3///////r28v/ct5//06SG/9Gffv/Xqo7/7N/V/9e2nf/bsJb/6uDW/9Sskf/euKH/+/j2///////+/v3//////+3azv+/eE3/2rWd/9Kkhv/Vr5T/48i2/8J+VP/Qn3//3ryn/795Tf/WrpP/2LCW/8B6T//w4Nb///////Pn4P+/d0v/9u3n/+7d0v/EhV7//v///+HDr//fxLD/zph2/+TJt//8/Pv/woBX//Lm3f/y5dz/v3hN//bu6f/JjGn/4sW0///////Df1j/8OLZ//v6+P+/elH/+vj1//jy7f+/elL//////+zYzP/Eg13//////967p//MlHT/wn5X///////v4Nb/yY1s///////jw7H/06KG////////////z5t9/+fNvf//////x4pn//Pp4v/8+vn/w39X/8WEX///////5s/A/9CbfP//////27Oc/9y2n////////////9itlf/gu6f//////86Vdf/r2Mz//////8SCXP/Df1j//////+7d0v/KkG7//////+HBrf/VpYr////////////RnoH/5sq6///////Ii2n/8ubf//39/P/Cf1j/xohk/+bNvv//////wn5W//Tq4//58/D/wHxV//7+/f/59fH/v3xU//39/P/w4Nf/xIFb///////hw7H/yo9t/+/f1f/AeU3/+/n2/+nSxP/FhmD//////9qzm//Upon/4MSx/96+qf//////xINc/+3bz//48e3/v3hN//Pn3///////6M+//752S//gw6//06aK/8J+VP/kzLr/zZd1/8OCWv/q18r/17KZ/9Ooi//fv6r/v3dK/+vWyP///////v39///////27un/1aeK/9Opjv/m1cf/1KCC/9a0nP/n08T/0Jx8/82YdP/QnHz/16yR//jx7P///////v39///////+/f3///7+///////+//7//v7+///////+/v7//v/+/////////////////////////v7//v79///////////////////+/v/+/Pv//v39///+/v/+/Pv///7+//7+/f/+/Pv//v39//79/P/+/Pv///7+////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" />
- <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
- <link rel="stylesheet" href="main.css" />
- <script type="module" src="main.js"></script>
- <title>Enter contact details</title>
-</head>
-
-<body class="min-h-full flex flex-col">
- <header class="bg-indigo-600 w-full mx-auto px-2 border-b border-opacity-25 border-indigo-400">
- <div class="flex flex-row h-16 items-center ">
- <div class="flex px-2 justify-start">
- <div class="flex-shrink-0 bg-white rounded-lg"><a href="#"><img class="h-8 w-auto"
- src="data:image/svg+xml,<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?>%0A<svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 201 90&quot;>%0A <g fill=&quot;%230042b3&quot; fill-rule=&quot;evenodd&quot; stroke-width=&quot;.3&quot;>%0A <path d=&quot;M86.7 1.1c15.6 0 29 9.4 36 23.2h-5.9A35.1 35.1 0 0086.7 6.5C67 6.5 51 23.6 51 44.7c0 10.4 3.8 19.7 10 26.6a31.4 31.4 0 01-4.2 3A45.2 45.2 0 0146 44.7c0-24 18.2-43.6 40.7-43.6zm35.8 64.3a40.4 40.4 0 01-39 22.8c3-1.5 6-3.5 8.6-5.7a35.6 35.6 0 0024.6-17.1z&quot; />%0A <path d=&quot;M64.2 1.1l3.1.1c-3 1.6-5.9 3.5-8.5 5.8a37.5 37.5 0 00-30.2 37.7c0 14.3 7.3 26.7 18 33.3a29.6 29.6 0 01-8.5.2c-9-8-14.6-20-14.6-33.5 0-24 18.2-43.6 40.7-43.6zm5.4 81.4a35.6 35.6 0 0024.6-17.1h5.9a40.4 40.4 0 01-39 22.8c3-1.5 5.9-3.5 8.5-5.7zm24.8-58.2a37 37 0 00-12.6-12.8 29.6 29.6 0 018.5-.2c4 3.6 7.4 8 9.9 13z&quot; />%0A <path d=&quot;M41.8 1.1c1 0 2 0 3.1.2-3 1.5-5.9 3.4-8.5 5.6A37.5 37.5 0 006.1 44.7c0 21.1 16 38.3 35.7 38.3 12.6 0 23.6-7 30-17.6h5.8a40.4 40.4 0 01-35.8 23C19.3 88.4 1 68.8 1 44.7c0-24 18.2-43.6 40.7-43.6zm30.1 23.2a38.1 38.1 0 00-4.5-6.1c1.3-1.2 2.7-2.2 4.3-3 2.3 2.7 4.4 5.8 6 9.1z&quot; />%0A </g>%0A <path d=&quot;M76.1 34.4h9.2v-5H61.9v5H71v26h5.1zM92.6 52.9h13.7l3 7.4h5.3l-12.7-31.2h-4.7L84.5 60.3h5.2zm11.8-4.9h-9.9l5-12.4zM123.8 29.4h-4.6v31h20.6v-5h-16zM166.5 29.4H145v31h21.6v-5H150v-8.3h14.5v-4.9h-14.5v-8h16.4zM191.2 39.5c0 1.6-.5 2.8-1.6 3.8s-2.6 1.4-4.4 1.4h-7.4V34.3h7.4c1.9 0 3.4.4 4.4 1.3 1 .9 1.6 2.2 1.6 3.9zm6 20.8l-7.7-11.7c1-.3 1.9-.7 2.7-1.3a8.8 8.8 0 003.6-4.6c.4-1 .5-2.2.5-3.5 0-1.5-.2-2.9-.7-4.1a8.4 8.4 0 00-2.1-3.1c-1-.8-2-1.5-3.4-2-1.3-.4-2.8-.6-4.5-.6h-12.9v31h5V49.4h6.5l7 10.8z&quot; />%0A</svg>"
- alt="GNU Taler" style="height: 1.5rem; margin: 0.5rem;"></a></div><span
- class="flex items-center text-white text-lg font-bold ml-4">Challenger</span>
- </div>
- <div class="block flex-1 ml-6 "></div>
- <div class="flex justify-end">
- </div>
- </div>
- </header>
-
- <main class="flex-1">
-
- <div class="isolate bg-white px-6 py-12">
- <div class="mx-auto max-w-2xl text-center">
- <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
- Enter contact details
- </h2>
- <p class="mt-2 text-lg leading-8 text-gray-600">
- You will receive an SMS with a TAN code that must be provided on the next page.
- </p>
- </div>
- <form action="/challenge/{{nonce}}" method="POST" class="mx-auto mt-16 max-w-xl sm:mt-20">
- <div class="grid grid-cols-1 gap-x-8 gap-y-6">
- <div class="sm:col-span-2">
- <label for="phone" class="block text-sm font-semibold leading-6 text-gray-900">
- Phone number
- </label>
- <div class="mt-2.5">
- <input type="phone" name="phone" id="phone" maxlength="20" autocomplete="tel"
- class="block w-full rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
- </div>
- </div>
-
- <script>
- function check() {
- var phone = document.getElementById('phone');
- var phoneRepeat = document.getElementById('repeat-phone');
-
- if (phone.value != phoneRepeat.value) {
- phoneRepeat.setCustomValidity('The two phone numbers must match.');
- } else {
- // input is valid -- reset the error message
- phoneRepeat.setCustomValidity('');
- }
- }
- </script>
-
- <div class="sm:col-span-2">
- <label for="repeat-phone" class="block text-sm font-semibold leading-6 text-gray-900">
- Repeat phone
- </label>
- <div class="mt-2.5">
- <input oninput="check(this)" type="number" name="repeat-phone" id="repeat-phone" autocomplete="tel"
- class="block w-full rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
- </div>
- </div>
-
- <p class="mt-3 text-sm leading-6 text-gray-400">
- You can change your phone number another {{changes_left}} times.
- </p>
- </div>
-
- <div class="mt-10">
- <button type="submit"
- class="block w-full rounded-md bg-indigo-600 px-3.5 py-2.5 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
- Send SMS
- </button>
- </div>
- </form>
- </div>
- </main>
-
-
- <footer class="bottom-4 mb-4">
- <div class="mt-8 mx-8 md:order-1 md:mt-0">
- <div>
- <p class="text-xs leading-5 text-gray-400">Learn more about <a target="_blank" rel="noreferrer noopener"
- class="font-semibold text-gray-500 hover:text-gray-400" href="https://taler.net">GNU Taler</a></p>
- </div>
- <div style="flex-grow: 1;"></div>
- <p class="text-xs leading-5 text-gray-400">Copyright © 2014—2023 Taler Systems SA. </p>
- </div>
- </footer>
-</body>
-
-</html>
diff --git a/packages/challenger-ui/src/enter-tan-form.html b/packages/challenger-ui/src/enter-tan-form.html
deleted file mode 100644
index 965f8e9d2..000000000
--- a/packages/challenger-ui/src/enter-tan-form.html
+++ /dev/null
@@ -1,117 +0,0 @@
-<!--
- This file is part of GNU Taler
- (C) 2021--2022 Taler Systems S.A.
-
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-
- @author Sebastian Javier Marchano
--->
-<!DOCTYPE html>
-<html lang="en" class="h-full">
-
-<head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <meta name="taler-support" content="uri">
- <meta name="mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <link rel="icon"
- href="data:;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////7//v38//78/P/+/fz//vz7///+/v/+/f3//vz7///+/v/+/fz//v38///////////////////////+/v3///7+/////////////////////////////////////////////////////////v3//v79///////+/v3///////r28v/ct5//06SG/9Gffv/Xqo7/7N/V/9e2nf/bsJb/6uDW/9Sskf/euKH/+/j2///////+/v3//////+3azv+/eE3/2rWd/9Kkhv/Vr5T/48i2/8J+VP/Qn3//3ryn/795Tf/WrpP/2LCW/8B6T//w4Nb///////Pn4P+/d0v/9u3n/+7d0v/EhV7//v///+HDr//fxLD/zph2/+TJt//8/Pv/woBX//Lm3f/y5dz/v3hN//bu6f/JjGn/4sW0///////Df1j/8OLZ//v6+P+/elH/+vj1//jy7f+/elL//////+zYzP/Eg13//////967p//MlHT/wn5X///////v4Nb/yY1s///////jw7H/06KG////////////z5t9/+fNvf//////x4pn//Pp4v/8+vn/w39X/8WEX///////5s/A/9CbfP//////27Oc/9y2n////////////9itlf/gu6f//////86Vdf/r2Mz//////8SCXP/Df1j//////+7d0v/KkG7//////+HBrf/VpYr////////////RnoH/5sq6///////Ii2n/8ubf//39/P/Cf1j/xohk/+bNvv//////wn5W//Tq4//58/D/wHxV//7+/f/59fH/v3xU//39/P/w4Nf/xIFb///////hw7H/yo9t/+/f1f/AeU3/+/n2/+nSxP/FhmD//////9qzm//Upon/4MSx/96+qf//////xINc/+3bz//48e3/v3hN//Pn3///////6M+//752S//gw6//06aK/8J+VP/kzLr/zZd1/8OCWv/q18r/17KZ/9Ooi//fv6r/v3dK/+vWyP///////v39///////27un/1aeK/9Opjv/m1cf/1KCC/9a0nP/n08T/0Jx8/82YdP/QnHz/16yR//jx7P///////v39///////+/f3///7+///////+//7//v7+///////+/v7//v/+/////////////////////////v7//v79///////////////////+/v/+/Pv//v39///+/v/+/Pv///7+//7+/f/+/Pv//v39//79/P/+/Pv///7+////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" />
- <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
- <link rel="stylesheet" href="main.css" />
- <script type="module" src="main.js"></script>
- <title>Enter your TAN</title>
-</head>
-
-<body class="min-h-full flex flex-col">
- <header class="bg-indigo-600 w-full mx-auto px-2 border-b border-opacity-25 border-indigo-400">
- <div class="flex flex-row h-16 items-center ">
- <div class="flex px-2 justify-start">
- <div class="flex-shrink-0 bg-white rounded-lg"><a href="#"><img class="h-8 w-auto"
- src="data:image/svg+xml,<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?>%0A<svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 201 90&quot;>%0A <g fill=&quot;%230042b3&quot; fill-rule=&quot;evenodd&quot; stroke-width=&quot;.3&quot;>%0A <path d=&quot;M86.7 1.1c15.6 0 29 9.4 36 23.2h-5.9A35.1 35.1 0 0086.7 6.5C67 6.5 51 23.6 51 44.7c0 10.4 3.8 19.7 10 26.6a31.4 31.4 0 01-4.2 3A45.2 45.2 0 0146 44.7c0-24 18.2-43.6 40.7-43.6zm35.8 64.3a40.4 40.4 0 01-39 22.8c3-1.5 6-3.5 8.6-5.7a35.6 35.6 0 0024.6-17.1z&quot; />%0A <path d=&quot;M64.2 1.1l3.1.1c-3 1.6-5.9 3.5-8.5 5.8a37.5 37.5 0 00-30.2 37.7c0 14.3 7.3 26.7 18 33.3a29.6 29.6 0 01-8.5.2c-9-8-14.6-20-14.6-33.5 0-24 18.2-43.6 40.7-43.6zm5.4 81.4a35.6 35.6 0 0024.6-17.1h5.9a40.4 40.4 0 01-39 22.8c3-1.5 5.9-3.5 8.5-5.7zm24.8-58.2a37 37 0 00-12.6-12.8 29.6 29.6 0 018.5-.2c4 3.6 7.4 8 9.9 13z&quot; />%0A <path d=&quot;M41.8 1.1c1 0 2 0 3.1.2-3 1.5-5.9 3.4-8.5 5.6A37.5 37.5 0 006.1 44.7c0 21.1 16 38.3 35.7 38.3 12.6 0 23.6-7 30-17.6h5.8a40.4 40.4 0 01-35.8 23C19.3 88.4 1 68.8 1 44.7c0-24 18.2-43.6 40.7-43.6zm30.1 23.2a38.1 38.1 0 00-4.5-6.1c1.3-1.2 2.7-2.2 4.3-3 2.3 2.7 4.4 5.8 6 9.1z&quot; />%0A </g>%0A <path d=&quot;M76.1 34.4h9.2v-5H61.9v5H71v26h5.1zM92.6 52.9h13.7l3 7.4h5.3l-12.7-31.2h-4.7L84.5 60.3h5.2zm11.8-4.9h-9.9l5-12.4zM123.8 29.4h-4.6v31h20.6v-5h-16zM166.5 29.4H145v31h21.6v-5H150v-8.3h14.5v-4.9h-14.5v-8h16.4zM191.2 39.5c0 1.6-.5 2.8-1.6 3.8s-2.6 1.4-4.4 1.4h-7.4V34.3h7.4c1.9 0 3.4.4 4.4 1.3 1 .9 1.6 2.2 1.6 3.9zm6 20.8l-7.7-11.7c1-.3 1.9-.7 2.7-1.3a8.8 8.8 0 003.6-4.6c.4-1 .5-2.2.5-3.5 0-1.5-.2-2.9-.7-4.1a8.4 8.4 0 00-2.1-3.1c-1-.8-2-1.5-3.4-2-1.3-.4-2.8-.6-4.5-.6h-12.9v31h5V49.4h6.5l7 10.8z&quot; />%0A</svg>"
- alt="GNU Taler" style="height: 1.5rem; margin: 0.5rem;"></a></div><span
- class="flex items-center text-white text-lg font-bold ml-4">Challenger</span>
- </div>
- <div class="block flex-1 ml-6 "></div>
- <div class="flex justify-end">
- </div>
- </div>
- </header>
-
- <main class="flex-1">
-
- <div class="isolate bg-white px-6 py-12">
- <div class="mx-auto max-w-2xl text-center">
- <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
- Please enter the TAN you received to authenticate.
- </h2>
- <p class="mt-2 text-lg leading-8 text-gray-600">
- <!-- {{#transmitted}}
- A TAN was sent to your address &quot;{{address}}&quot;.
- {{/transmitted}} -->
- <!-- {{^transmitted}} -->
- We recently already sent a TAN to your address &quot;{{address}}&quot;.
- A new TAN will not be transmitted again before {{next_tx_time}}.
- <!-- {{/transmitted}} -->
- </p>
- </div>
-
-
- <form action="/solve/{{nonce}}" method="POST" class="mx-auto mt-16 max-w-xl sm:mt-20">
- <div class="grid grid-cols-1 gap-x-8 gap-y-6">
- <div class="sm:col-span-2">
- <label for="pin" class="block text-sm font-semibold leading-6 text-gray-900">
- TAN code
- </label>
- <div class="mt-2.5">
- <div
- class="flex rounded-md shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-600">
- <span class="flex select-none items-center pl-3 text-gray-500 sm:text-sm">TAN:</span>
- <input type="number" name="pin" id="pin" maxlength="64"
- class="block flex-1 border-0 bg-transparent py-1.5 pl-1 text-gray-900 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6"
- placeholder="12345678">
- </div>
-
- </div>
- </div>
-
- <p class="mt-3 text-sm leading-6 text-gray-400">
- You have {{attempts_left}} attempts left.
- </p>
- </div>
-
- <div class="mt-10">
- <button type="submit"
- class="block w-full rounded-md bg-indigo-600 px-3.5 py-2.5 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
- Check
- </button>
- </div>
- </form>
-
- </div>
- </main>
-
- <footer class="bottom-4 mb-4">
- <div class="mt-8 mx-8 md:order-1 md:mt-0">
- <div>
- <p class="text-xs leading-5 text-gray-400">Learn more about <a target="_blank" rel="noreferrer noopener"
- class="font-semibold text-gray-500 hover:text-gray-400" href="https://taler.net">GNU Taler</a></p>
- </div>
- <div style="flex-grow: 1;"></div>
- <p class="text-xs leading-5 text-gray-400">Copyright © 2014—2023 Taler Systems SA. </p>
- </div>
- </footer>
-
-</body>
-
-</html>
diff --git a/packages/challenger-ui/src/hooks/challenge.ts b/packages/challenger-ui/src/hooks/challenge.ts
index 846242816..81cceec3f 100644
--- a/packages/challenger-ui/src/hooks/challenge.ts
+++ b/packages/challenger-ui/src/hooks/challenge.ts
@@ -30,27 +30,24 @@ export function revalidateChallengeSession() {
);
}
-export function useChallengeSession(
- nonce: string,
- session: SessionId | undefined,
-) {
+export function useChallengeSession(session: SessionId) {
const {
lib: { challenger: api },
} = useChallengerApiContext();
- async function fetcher([n, c, r, s]: [string, string, string, string]) {
- return await api.login(n, c, r, s);
+ async function fetcher([s]: [SessionId]) {
+ return await api.login(s.nonce, s.clientId, s.redirectURL, s.state);
}
const { data, error } = useSWR<
ChallengerResultByMethod<"login">,
TalerHttpError
- >(
- !session
- ? undefined
- : [nonce, session.clientId, session.redirectURL, session.state, "login"],
- fetcher,
- {},
- );
+ >(!session ? undefined : [session, "login"], fetcher, {
+ revalidateIfStale: false,
+ errorRetryCount: 0,
+ errorRetryInterval: 1,
+ shouldRetryOnError: false,
+ keepPreviousData: true,
+ });
if (data) return data;
if (error) return error;
diff --git a/packages/challenger-ui/src/hooks/session.ts b/packages/challenger-ui/src/hooks/session.ts
index ed7ea8986..86dfff94e 100644
--- a/packages/challenger-ui/src/hooks/session.ts
+++ b/packages/challenger-ui/src/hooks/session.ts
@@ -15,63 +15,69 @@
*/
import {
+ AbsoluteTime,
ChallengerApi,
Codec,
buildCodecForObject,
- codecForBoolean,
- codecForChallengeStatus,
- codecForNumber,
+ codecForAbsoluteTime,
+ codecForAny,
+ codecForList,
codecForString,
codecForStringURL,
codecOptional,
} from "@gnu-taler/taler-util";
import { buildStorageKey, useLocalStorage } from "@gnu-taler/web-util/browser";
-import { mutate } from "swr";
/**
* Has the information to reach and
* authenticate at the bank's backend.
*/
export type SessionId = {
+ nonce: string;
clientId: string;
redirectURL: string;
state: string;
};
export type LastChallengeResponse = {
- attemptsLeft: number;
- nextSend: string;
+ sendCodeLeft: number;
+ changeTargetLeft: number;
+ checkPinLeft: number;
+ nextSend: AbsoluteTime;
transmitted: boolean;
};
-export type SessionState = SessionId & {
- lastTry: LastChallengeResponse | undefined;
- lastStatus: ChallengerApi.ChallengeStatus | undefined;
+interface LastAddress {
+ address: Record<string, string>;
+ type: string;
+ savedAt: AbsoluteTime;
+}
+
+export type SessionState = {
completedURL: string | undefined;
+ lastAddress: Array<LastAddress> | undefined;
};
-export const codecForLastChallengeResponse = (): Codec<LastChallengeResponse> =>
- buildCodecForObject<LastChallengeResponse>()
- .property("attemptsLeft", codecForNumber())
- .property("nextSend", codecForString())
- .property("transmitted", codecForBoolean())
- .build("LastChallengeResponse");
+export const codecForLastAddress = (): Codec<LastAddress> =>
+ buildCodecForObject<LastAddress>()
+ .property("address", codecForAny())
+ .property("type", codecForString())
+ .property("savedAt", codecForAbsoluteTime)
+ .build("LastAddress");
export const codecForSessionState = (): Codec<SessionState> =>
buildCodecForObject<SessionState>()
- .property("clientId", codecForString())
- .property("redirectURL", codecForStringURL())
.property("completedURL", codecOptional(codecForStringURL()))
- .property("state", codecForString())
- .property("lastStatus", codecOptional(codecForChallengeStatus()))
- .property("lastTry", codecOptional(codecForLastChallengeResponse()))
+ .property("lastAddress", codecOptional(codecForList(codecForLastAddress())))
.build("SessionState");
export interface SessionStateHandler {
state: SessionState | undefined;
start(s: SessionId): void;
- accepted(l: LastChallengeResponse): void;
- completed(e: URL): void;
- updateStatus(s: ChallengerApi.ChallengeStatus): void;
+ saveAddress(type: string, address: Record<string, string>): void;
+ removeAddress(index: number): void;
+ sent(info: ChallengerApi.ChallengeCreateResponse): void;
+ failed(info: ChallengerApi.InvalidPinResponse): void;
+ completed(info: ChallengerApi.ChallengeRedirect): void;
}
const SESSION_STATE_KEY = buildStorageKey(
@@ -89,55 +95,48 @@ export function useSessionState(): SessionStateHandler {
return {
state,
- start(info) {
+ start() {
update({
- ...info,
- lastTry: undefined,
completedURL: undefined,
- lastStatus: undefined,
+ lastAddress: state?.lastAddress ?? [],
});
- cleanAllCache();
},
- accepted(lastTry) {
- if (!state) return;
+ removeAddress(index) {
+ const lastAddr = [...(state?.lastAddress ?? [])];
+ lastAddr.splice(index, 1);
update({
- ...state,
- lastTry,
+ completedURL: undefined,
+ lastAddress: lastAddr,
});
},
- completed(url) {
- if (!state) return;
+ saveAddress(type, address) {
+ const lastAddr = [...(state?.lastAddress ?? [])];
+ lastAddr.push({
+ type,
+ address: address ?? {},
+ savedAt: AbsoluteTime.now(),
+ });
update({
- ...state,
- completedURL: url.href,
+ completedURL: undefined,
+ lastAddress: lastAddr,
});
},
- updateStatus(st: ChallengerApi.ChallengeStatus) {
- if (!state) return;
- if (!state.lastStatus) {
+ sent(info) {
+ },
+ failed(info) {
+ },
+ completed(info) {
+ if (!state) {
update({
- ...state,
- lastStatus: st,
+ completedURL: info.redirect_url,
+ lastAddress: [],
});
- return;
- }
- // current status
- const ls = state.lastStatus;
- if (
- ls.changes_left !== st.changes_left ||
- ls.fix_address !== st.fix_address ||
- ls.last_address !== st.last_address
- ) {
+ } else {
update({
- ...state,
- lastStatus: st,
+ completedURL: info.redirect_url,
+ lastAddress: state.lastAddress,
});
- return;
}
},
};
}
-
-function cleanAllCache(): void {
- mutate(() => true, undefined, { revalidate: false });
-}
diff --git a/packages/challenger-ui/src/i18n/challenger-ui.pot b/packages/challenger-ui/src/i18n/challenger-ui.pot
index 5d2497acf..c1501192f 100644
--- a/packages/challenger-ui/src/i18n/challenger-ui.pot
+++ b/packages/challenger-ui/src/i18n/challenger-ui.pot
@@ -15,7 +15,7 @@
#, fuzzy
msgid ""
msgstr ""
-"Project-Id-Version: Taler Bank\n"
+"Project-Id-Version: Challenger\n"
"Report-Msgid-Bugs-To: taler@gnu.org\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
diff --git a/packages/challenger-ui/src/internal-error.html b/packages/challenger-ui/src/internal-error.html
deleted file mode 100644
index 521a2b69e..000000000
--- a/packages/challenger-ui/src/internal-error.html
+++ /dev/null
@@ -1,89 +0,0 @@
-<!--
- This file is part of GNU Taler
- (C) 2021--2022 Taler Systems S.A.
-
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-
- @author Sebastian Javier Marchano
--->
-<!DOCTYPE html>
-<html lang="en" class="h-full">
-
-<head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <meta name="taler-support" content="uri">
- <meta name="mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <link rel="icon"
- href="data:;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////7//v38//78/P/+/fz//vz7///+/v/+/f3//vz7///+/v/+/fz//v38///////////////////////+/v3///7+/////////////////////////////////////////////////////////v3//v79///////+/v3///////r28v/ct5//06SG/9Gffv/Xqo7/7N/V/9e2nf/bsJb/6uDW/9Sskf/euKH/+/j2///////+/v3//////+3azv+/eE3/2rWd/9Kkhv/Vr5T/48i2/8J+VP/Qn3//3ryn/795Tf/WrpP/2LCW/8B6T//w4Nb///////Pn4P+/d0v/9u3n/+7d0v/EhV7//v///+HDr//fxLD/zph2/+TJt//8/Pv/woBX//Lm3f/y5dz/v3hN//bu6f/JjGn/4sW0///////Df1j/8OLZ//v6+P+/elH/+vj1//jy7f+/elL//////+zYzP/Eg13//////967p//MlHT/wn5X///////v4Nb/yY1s///////jw7H/06KG////////////z5t9/+fNvf//////x4pn//Pp4v/8+vn/w39X/8WEX///////5s/A/9CbfP//////27Oc/9y2n////////////9itlf/gu6f//////86Vdf/r2Mz//////8SCXP/Df1j//////+7d0v/KkG7//////+HBrf/VpYr////////////RnoH/5sq6///////Ii2n/8ubf//39/P/Cf1j/xohk/+bNvv//////wn5W//Tq4//58/D/wHxV//7+/f/59fH/v3xU//39/P/w4Nf/xIFb///////hw7H/yo9t/+/f1f/AeU3/+/n2/+nSxP/FhmD//////9qzm//Upon/4MSx/96+qf//////xINc/+3bz//48e3/v3hN//Pn3///////6M+//752S//gw6//06aK/8J+VP/kzLr/zZd1/8OCWv/q18r/17KZ/9Ooi//fv6r/v3dK/+vWyP///////v39///////27un/1aeK/9Opjv/m1cf/1KCC/9a0nP/n08T/0Jx8/82YdP/QnHz/16yR//jx7P///////v39///////+/f3///7+///////+//7//v7+///////+/v7//v/+/////////////////////////v7//v79///////////////////+/v/+/Pv//v39///+/v/+/Pv///7+//7+/f/+/Pv//v39//79/P/+/Pv///7+////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" />
- <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
- <link rel="stylesheet" href="main.css" />
- <script type="module" src="main.js"></script>
- <title>Internal server error (#{{ec}})</title>
-</head>
-
-<body class="min-h-full flex flex-col">
- <header class="bg-indigo-600 w-full mx-auto px-2 border-b border-opacity-25 border-indigo-400">
- <div class="flex flex-row h-16 items-center ">
- <div class="flex px-2 justify-start">
- <div class="flex-shrink-0 bg-white rounded-lg"><a href="#"><img class="h-8 w-auto"
- src="data:image/svg+xml,<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?>%0A<svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 201 90&quot;>%0A <g fill=&quot;%230042b3&quot; fill-rule=&quot;evenodd&quot; stroke-width=&quot;.3&quot;>%0A <path d=&quot;M86.7 1.1c15.6 0 29 9.4 36 23.2h-5.9A35.1 35.1 0 0086.7 6.5C67 6.5 51 23.6 51 44.7c0 10.4 3.8 19.7 10 26.6a31.4 31.4 0 01-4.2 3A45.2 45.2 0 0146 44.7c0-24 18.2-43.6 40.7-43.6zm35.8 64.3a40.4 40.4 0 01-39 22.8c3-1.5 6-3.5 8.6-5.7a35.6 35.6 0 0024.6-17.1z&quot; />%0A <path d=&quot;M64.2 1.1l3.1.1c-3 1.6-5.9 3.5-8.5 5.8a37.5 37.5 0 00-30.2 37.7c0 14.3 7.3 26.7 18 33.3a29.6 29.6 0 01-8.5.2c-9-8-14.6-20-14.6-33.5 0-24 18.2-43.6 40.7-43.6zm5.4 81.4a35.6 35.6 0 0024.6-17.1h5.9a40.4 40.4 0 01-39 22.8c3-1.5 5.9-3.5 8.5-5.7zm24.8-58.2a37 37 0 00-12.6-12.8 29.6 29.6 0 018.5-.2c4 3.6 7.4 8 9.9 13z&quot; />%0A <path d=&quot;M41.8 1.1c1 0 2 0 3.1.2-3 1.5-5.9 3.4-8.5 5.6A37.5 37.5 0 006.1 44.7c0 21.1 16 38.3 35.7 38.3 12.6 0 23.6-7 30-17.6h5.8a40.4 40.4 0 01-35.8 23C19.3 88.4 1 68.8 1 44.7c0-24 18.2-43.6 40.7-43.6zm30.1 23.2a38.1 38.1 0 00-4.5-6.1c1.3-1.2 2.7-2.2 4.3-3 2.3 2.7 4.4 5.8 6 9.1z&quot; />%0A </g>%0A <path d=&quot;M76.1 34.4h9.2v-5H61.9v5H71v26h5.1zM92.6 52.9h13.7l3 7.4h5.3l-12.7-31.2h-4.7L84.5 60.3h5.2zm11.8-4.9h-9.9l5-12.4zM123.8 29.4h-4.6v31h20.6v-5h-16zM166.5 29.4H145v31h21.6v-5H150v-8.3h14.5v-4.9h-14.5v-8h16.4zM191.2 39.5c0 1.6-.5 2.8-1.6 3.8s-2.6 1.4-4.4 1.4h-7.4V34.3h7.4c1.9 0 3.4.4 4.4 1.3 1 .9 1.6 2.2 1.6 3.9zm6 20.8l-7.7-11.7c1-.3 1.9-.7 2.7-1.3a8.8 8.8 0 003.6-4.6c.4-1 .5-2.2.5-3.5 0-1.5-.2-2.9-.7-4.1a8.4 8.4 0 00-2.1-3.1c-1-.8-2-1.5-3.4-2-1.3-.4-2.8-.6-4.5-.6h-12.9v31h5V49.4h6.5l7 10.8z&quot; />%0A</svg>"
- alt="GNU Taler" style="height: 1.5rem; margin: 0.5rem;"></a></div><span
- class="flex items-center text-white text-lg font-bold ml-4">Challenger</span>
- </div>
- <div class="block flex-1 ml-6 "></div>
- <div class="flex justify-end">
- </div>
- </div>
- </header>
-
- <main class="flex-1">
- <div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 items-center mt-4">
- <div class="rounded-md bg-red-50 p-4 shadow-xl">
- <div class="flex">
- <div class="flex-shrink-0">
- <svg xmlns="http://www.w3.org/2000/svg" stroke="none" viewBox="0 0 24 24" fill="currentColor"
- class="w-8 h-8 text-red-400">
- <path fill-rule="evenodd"
- d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z" />
- </svg>
- </div>
- <div class="ml-3">
- <h3 class="text-sm font-medium text-red-800">
- Internal error
- </h3>
- <div class="mt-2 text-sm text-red-700">
- <p>{{hint}} ({{detail}})</p>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- </main>
-
- <footer class="bottom-4 mb-4">
- <div class="mt-8 mx-8 md:order-1 md:mt-0">
- <div>
- <p class="text-xs leading-5 text-gray-400">Learn more about <a target="_blank" rel="noreferrer noopener"
- class="font-semibold text-gray-500 hover:text-gray-400" href="https://taler.net">GNU Taler</a></p>
- </div>
- <div style="flex-grow: 1;"></div>
- <p class="text-xs leading-5 text-gray-400">Copyright © 2014—2023 Taler Systems SA. </p>
- </div>
- </footer>
-
-</body>
-
-</html> \ No newline at end of file
diff --git a/packages/challenger-ui/src/invalid-pin.html b/packages/challenger-ui/src/invalid-pin.html
deleted file mode 100644
index 1229b8095..000000000
--- a/packages/challenger-ui/src/invalid-pin.html
+++ /dev/null
@@ -1,87 +0,0 @@
-<!--
- This file is part of GNU Taler
- (C) 2021--2022 Taler Systems S.A.
-
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-
- @author Sebastian Javier Marchano
--->
-<!DOCTYPE html>
-<html lang="en" class="h-full">
-
-<head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <meta name="taler-support" content="uri">
- <meta name="mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <link rel="icon"
- href="data:;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////7//v38//78/P/+/fz//vz7///+/v/+/f3//vz7///+/v/+/fz//v38///////////////////////+/v3///7+/////////////////////////////////////////////////////////v3//v79///////+/v3///////r28v/ct5//06SG/9Gffv/Xqo7/7N/V/9e2nf/bsJb/6uDW/9Sskf/euKH/+/j2///////+/v3//////+3azv+/eE3/2rWd/9Kkhv/Vr5T/48i2/8J+VP/Qn3//3ryn/795Tf/WrpP/2LCW/8B6T//w4Nb///////Pn4P+/d0v/9u3n/+7d0v/EhV7//v///+HDr//fxLD/zph2/+TJt//8/Pv/woBX//Lm3f/y5dz/v3hN//bu6f/JjGn/4sW0///////Df1j/8OLZ//v6+P+/elH/+vj1//jy7f+/elL//////+zYzP/Eg13//////967p//MlHT/wn5X///////v4Nb/yY1s///////jw7H/06KG////////////z5t9/+fNvf//////x4pn//Pp4v/8+vn/w39X/8WEX///////5s/A/9CbfP//////27Oc/9y2n////////////9itlf/gu6f//////86Vdf/r2Mz//////8SCXP/Df1j//////+7d0v/KkG7//////+HBrf/VpYr////////////RnoH/5sq6///////Ii2n/8ubf//39/P/Cf1j/xohk/+bNvv//////wn5W//Tq4//58/D/wHxV//7+/f/59fH/v3xU//39/P/w4Nf/xIFb///////hw7H/yo9t/+/f1f/AeU3/+/n2/+nSxP/FhmD//////9qzm//Upon/4MSx/96+qf//////xINc/+3bz//48e3/v3hN//Pn3///////6M+//752S//gw6//06aK/8J+VP/kzLr/zZd1/8OCWv/q18r/17KZ/9Ooi//fv6r/v3dK/+vWyP///////v39///////27un/1aeK/9Opjv/m1cf/1KCC/9a0nP/n08T/0Jx8/82YdP/QnHz/16yR//jx7P///////v39///////+/f3///7+///////+//7//v7+///////+/v7//v/+/////////////////////////v7//v79///////////////////+/v/+/Pv//v39///+/v/+/Pv///7+//7+/f/+/Pv//v39//79/P/+/Pv///7+////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" />
- <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
- <link rel="stylesheet" href="main.css" />
- <script type="module" src="main.js"></script>
- <title>Invalid solution (#{{ec}})</title>
-</head>
-
-<body class="min-h-full flex flex-col">
- <header class="bg-indigo-600 w-full mx-auto px-2 border-b border-opacity-25 border-indigo-400">
- <div class="flex flex-row h-16 items-center ">
- <div class="flex px-2 justify-start">
- <div class="flex-shrink-0 bg-white rounded-lg"><a href="#"><img class="h-8 w-auto"
- src="data:image/svg+xml,<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?>%0A<svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 201 90&quot;>%0A <g fill=&quot;%230042b3&quot; fill-rule=&quot;evenodd&quot; stroke-width=&quot;.3&quot;>%0A <path d=&quot;M86.7 1.1c15.6 0 29 9.4 36 23.2h-5.9A35.1 35.1 0 0086.7 6.5C67 6.5 51 23.6 51 44.7c0 10.4 3.8 19.7 10 26.6a31.4 31.4 0 01-4.2 3A45.2 45.2 0 0146 44.7c0-24 18.2-43.6 40.7-43.6zm35.8 64.3a40.4 40.4 0 01-39 22.8c3-1.5 6-3.5 8.6-5.7a35.6 35.6 0 0024.6-17.1z&quot; />%0A <path d=&quot;M64.2 1.1l3.1.1c-3 1.6-5.9 3.5-8.5 5.8a37.5 37.5 0 00-30.2 37.7c0 14.3 7.3 26.7 18 33.3a29.6 29.6 0 01-8.5.2c-9-8-14.6-20-14.6-33.5 0-24 18.2-43.6 40.7-43.6zm5.4 81.4a35.6 35.6 0 0024.6-17.1h5.9a40.4 40.4 0 01-39 22.8c3-1.5 5.9-3.5 8.5-5.7zm24.8-58.2a37 37 0 00-12.6-12.8 29.6 29.6 0 018.5-.2c4 3.6 7.4 8 9.9 13z&quot; />%0A <path d=&quot;M41.8 1.1c1 0 2 0 3.1.2-3 1.5-5.9 3.4-8.5 5.6A37.5 37.5 0 006.1 44.7c0 21.1 16 38.3 35.7 38.3 12.6 0 23.6-7 30-17.6h5.8a40.4 40.4 0 01-35.8 23C19.3 88.4 1 68.8 1 44.7c0-24 18.2-43.6 40.7-43.6zm30.1 23.2a38.1 38.1 0 00-4.5-6.1c1.3-1.2 2.7-2.2 4.3-3 2.3 2.7 4.4 5.8 6 9.1z&quot; />%0A </g>%0A <path d=&quot;M76.1 34.4h9.2v-5H61.9v5H71v26h5.1zM92.6 52.9h13.7l3 7.4h5.3l-12.7-31.2h-4.7L84.5 60.3h5.2zm11.8-4.9h-9.9l5-12.4zM123.8 29.4h-4.6v31h20.6v-5h-16zM166.5 29.4H145v31h21.6v-5H150v-8.3h14.5v-4.9h-14.5v-8h16.4zM191.2 39.5c0 1.6-.5 2.8-1.6 3.8s-2.6 1.4-4.4 1.4h-7.4V34.3h7.4c1.9 0 3.4.4 4.4 1.3 1 .9 1.6 2.2 1.6 3.9zm6 20.8l-7.7-11.7c1-.3 1.9-.7 2.7-1.3a8.8 8.8 0 003.6-4.6c.4-1 .5-2.2.5-3.5 0-1.5-.2-2.9-.7-4.1a8.4 8.4 0 00-2.1-3.1c-1-.8-2-1.5-3.4-2-1.3-.4-2.8-.6-4.5-.6h-12.9v31h5V49.4h6.5l7 10.8z&quot; />%0A</svg>"
- alt="GNU Taler" style="height: 1.5rem; margin: 0.5rem;"></a></div><span
- class="flex items-center text-white text-lg font-bold ml-4">Challenger</span>
- </div>
- <div class="block flex-1 ml-6 "></div>
- <div class="flex justify-end">
- </div>
- </div>
- </header>
-
- <main class="flex-1">
- <div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 items-center mt-4">
- <div class="rounded-md bg-red-50 p-4 shadow-xl">
- <div class="flex">
- <div class="flex-shrink-0">
- <svg xmlns="http://www.w3.org/2000/svg" stroke="none" viewBox="0 0 24 24" fill="currentColor"
- class="w-8 h-8 text-red-400">
- <path fill-rule="evenodd"
- d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z" />
- </svg>
- </div>
- <div class="ml-3">
- <h3 class="text-sm font-medium text-red-800">
- Invalid PIN
- </h3>
- <div class="mt-2 text-sm text-red-700">
- <p>{{hint}}</p>
- </div>
- </div>
- </div>
- </div>
- </div>
- </main>
-
- <footer class="bottom-4 mb-4">
- <div class="mt-8 mx-8 md:order-1 md:mt-0">
- <div>
- <p class="text-xs leading-5 text-gray-400">Learn more about <a target="_blank" rel="noreferrer noopener"
- class="font-semibold text-gray-500 hover:text-gray-400" href="https://taler.net">GNU Taler</a></p>
- </div>
- <div style="flex-grow: 1;"></div>
- <p class="text-xs leading-5 text-gray-400">Copyright © 2014—2023 Taler Systems SA. </p>
- </div>
- </footer>
-</body>
-
-</html> \ No newline at end of file
diff --git a/packages/challenger-ui/src/invalid-request.html b/packages/challenger-ui/src/invalid-request.html
deleted file mode 100644
index 89e6b125c..000000000
--- a/packages/challenger-ui/src/invalid-request.html
+++ /dev/null
@@ -1,88 +0,0 @@
-<!--
- This file is part of GNU Taler
- (C) 2021--2022 Taler Systems S.A.
-
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-
- @author Sebastian Javier Marchano
--->
-<!DOCTYPE html>
-<html lang="en" class="h-full">
-
-<head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <meta name="taler-support" content="uri">
- <meta name="mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <link rel="icon"
- href="data:;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////7//v38//78/P/+/fz//vz7///+/v/+/f3//vz7///+/v/+/fz//v38///////////////////////+/v3///7+/////////////////////////////////////////////////////////v3//v79///////+/v3///////r28v/ct5//06SG/9Gffv/Xqo7/7N/V/9e2nf/bsJb/6uDW/9Sskf/euKH/+/j2///////+/v3//////+3azv+/eE3/2rWd/9Kkhv/Vr5T/48i2/8J+VP/Qn3//3ryn/795Tf/WrpP/2LCW/8B6T//w4Nb///////Pn4P+/d0v/9u3n/+7d0v/EhV7//v///+HDr//fxLD/zph2/+TJt//8/Pv/woBX//Lm3f/y5dz/v3hN//bu6f/JjGn/4sW0///////Df1j/8OLZ//v6+P+/elH/+vj1//jy7f+/elL//////+zYzP/Eg13//////967p//MlHT/wn5X///////v4Nb/yY1s///////jw7H/06KG////////////z5t9/+fNvf//////x4pn//Pp4v/8+vn/w39X/8WEX///////5s/A/9CbfP//////27Oc/9y2n////////////9itlf/gu6f//////86Vdf/r2Mz//////8SCXP/Df1j//////+7d0v/KkG7//////+HBrf/VpYr////////////RnoH/5sq6///////Ii2n/8ubf//39/P/Cf1j/xohk/+bNvv//////wn5W//Tq4//58/D/wHxV//7+/f/59fH/v3xU//39/P/w4Nf/xIFb///////hw7H/yo9t/+/f1f/AeU3/+/n2/+nSxP/FhmD//////9qzm//Upon/4MSx/96+qf//////xINc/+3bz//48e3/v3hN//Pn3///////6M+//752S//gw6//06aK/8J+VP/kzLr/zZd1/8OCWv/q18r/17KZ/9Ooi//fv6r/v3dK/+vWyP///////v39///////27un/1aeK/9Opjv/m1cf/1KCC/9a0nP/n08T/0Jx8/82YdP/QnHz/16yR//jx7P///////v39///////+/f3///7+///////+//7//v7+///////+/v7//v/+/////////////////////////v7//v79///////////////////+/v/+/Pv//v39///+/v/+/Pv///7+//7+/f/+/Pv//v39//79/P/+/Pv///7+////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" />
- <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
- <link rel="stylesheet" href="main.css" />
- <script type="module" src="main.js"></script>
- <title>Invalid request (#{{ec}})</title>
-</head>
-
-<body class="min-h-full flex flex-col">
- <header class="bg-indigo-600 w-full mx-auto px-2 border-b border-opacity-25 border-indigo-400">
- <div class="flex flex-row h-16 items-center ">
- <div class="flex px-2 justify-start">
- <div class="flex-shrink-0 bg-white rounded-lg"><a href="#"><img class="h-8 w-auto"
- src="data:image/svg+xml,<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?>%0A<svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 201 90&quot;>%0A <g fill=&quot;%230042b3&quot; fill-rule=&quot;evenodd&quot; stroke-width=&quot;.3&quot;>%0A <path d=&quot;M86.7 1.1c15.6 0 29 9.4 36 23.2h-5.9A35.1 35.1 0 0086.7 6.5C67 6.5 51 23.6 51 44.7c0 10.4 3.8 19.7 10 26.6a31.4 31.4 0 01-4.2 3A45.2 45.2 0 0146 44.7c0-24 18.2-43.6 40.7-43.6zm35.8 64.3a40.4 40.4 0 01-39 22.8c3-1.5 6-3.5 8.6-5.7a35.6 35.6 0 0024.6-17.1z&quot; />%0A <path d=&quot;M64.2 1.1l3.1.1c-3 1.6-5.9 3.5-8.5 5.8a37.5 37.5 0 00-30.2 37.7c0 14.3 7.3 26.7 18 33.3a29.6 29.6 0 01-8.5.2c-9-8-14.6-20-14.6-33.5 0-24 18.2-43.6 40.7-43.6zm5.4 81.4a35.6 35.6 0 0024.6-17.1h5.9a40.4 40.4 0 01-39 22.8c3-1.5 5.9-3.5 8.5-5.7zm24.8-58.2a37 37 0 00-12.6-12.8 29.6 29.6 0 018.5-.2c4 3.6 7.4 8 9.9 13z&quot; />%0A <path d=&quot;M41.8 1.1c1 0 2 0 3.1.2-3 1.5-5.9 3.4-8.5 5.6A37.5 37.5 0 006.1 44.7c0 21.1 16 38.3 35.7 38.3 12.6 0 23.6-7 30-17.6h5.8a40.4 40.4 0 01-35.8 23C19.3 88.4 1 68.8 1 44.7c0-24 18.2-43.6 40.7-43.6zm30.1 23.2a38.1 38.1 0 00-4.5-6.1c1.3-1.2 2.7-2.2 4.3-3 2.3 2.7 4.4 5.8 6 9.1z&quot; />%0A </g>%0A <path d=&quot;M76.1 34.4h9.2v-5H61.9v5H71v26h5.1zM92.6 52.9h13.7l3 7.4h5.3l-12.7-31.2h-4.7L84.5 60.3h5.2zm11.8-4.9h-9.9l5-12.4zM123.8 29.4h-4.6v31h20.6v-5h-16zM166.5 29.4H145v31h21.6v-5H150v-8.3h14.5v-4.9h-14.5v-8h16.4zM191.2 39.5c0 1.6-.5 2.8-1.6 3.8s-2.6 1.4-4.4 1.4h-7.4V34.3h7.4c1.9 0 3.4.4 4.4 1.3 1 .9 1.6 2.2 1.6 3.9zm6 20.8l-7.7-11.7c1-.3 1.9-.7 2.7-1.3a8.8 8.8 0 003.6-4.6c.4-1 .5-2.2.5-3.5 0-1.5-.2-2.9-.7-4.1a8.4 8.4 0 00-2.1-3.1c-1-.8-2-1.5-3.4-2-1.3-.4-2.8-.6-4.5-.6h-12.9v31h5V49.4h6.5l7 10.8z&quot; />%0A</svg>"
- alt="GNU Taler" style="height: 1.5rem; margin: 0.5rem;"></a></div><span
- class="flex items-center text-white text-lg font-bold ml-4">Challenger</span>
- </div>
- <div class="block flex-1 ml-6 "></div>
- <div class="flex justify-end">
- </div>
- </div>
- </header>
-
- <main class="flex-1">
-
- <div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 items-center mt-4">
- <div class="rounded-md bg-red-50 p-4 shadow-xl">
- <div class="flex">
- <div class="flex-shrink-0">
- <svg xmlns="http://www.w3.org/2000/svg" stroke="none" viewBox="0 0 24 24" fill="currentColor"
- class="w-8 h-8 text-red-400">
- <path fill-rule="evenodd"
- d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z" />
- </svg>
- </div>
- <div class="ml-3">
- <h3 class="text-sm font-medium text-red-800">
- Request error
- </h3>
- <div class="mt-2 text-sm text-red-700">
- <p>{{hint}}</p>
- </div>
- </div>
- </div>
- </div>
- </div>
- </main>
-
- <footer class="bottom-4 mb-4">
- <div class="mt-8 mx-8 md:order-1 md:mt-0">
- <div>
- <p class="text-xs leading-5 text-gray-400">Learn more about <a target="_blank" rel="noreferrer noopener"
- class="font-semibold text-gray-500 hover:text-gray-400" href="https://taler.net">GNU Taler</a></p>
- </div>
- <div style="flex-grow: 1;"></div>
- <p class="text-xs leading-5 text-gray-400">Copyright © 2014—2023 Taler Systems SA. </p>
- </div>
- </footer>
-</body>
-
-</html> \ No newline at end of file
diff --git a/packages/challenger-ui/src/pages/AnswerChallenge.tsx b/packages/challenger-ui/src/pages/AnswerChallenge.tsx
index 73a79c51f..48f4db477 100644
--- a/packages/challenger-ui/src/pages/AnswerChallenge.tsx
+++ b/packages/challenger-ui/src/pages/AnswerChallenge.tsx
@@ -14,8 +14,10 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
import {
- ChallengerApi,
+ AbsoluteTime,
+ EmptyObject,
HttpStatusCode,
+ TalerError,
assertUnreachable,
} from "@gnu-taler/taler-util";
import {
@@ -24,118 +26,268 @@ import {
LocalNotificationBanner,
RouteDefinition,
ShowInputErrorLabel,
+ Time,
useChallengerApiContext,
useLocalNotificationHandler,
useTranslationContext,
} from "@gnu-taler/web-util/browser";
import { Fragment, VNode, h } from "preact";
-import { useState } from "preact/hooks";
-import { useSessionState } from "../hooks/session.js";
-
-export const EMAIL_REGEX = /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/;
+import { useEffect, useState } from "preact/hooks";
+import {
+ revalidateChallengeSession,
+ useChallengeSession,
+} from "../hooks/challenge.js";
+import { SessionId, useSessionState } from "../hooks/session.js";
type Props = {
- nonce: string;
focus?: boolean;
+ session: SessionId,
onComplete: () => void;
- routeAsk: RouteDefinition<{ nonce: string }>;
+ routeAsk: RouteDefinition<EmptyObject>;
};
-export function AnswerChallenge({ focus, nonce, onComplete, routeAsk }: Props): VNode {
- const { lib } = useChallengerApiContext();
+function useReloadOnDeadline(deadline: AbsoluteTime): void {
+ const [, set] = useState(false);
+ function toggle(): void {
+ set((s) => !s);
+ }
+ useEffect(() => {
+ if (AbsoluteTime.isExpired(deadline)) {
+ return;
+ }
+ const diff = AbsoluteTime.difference(AbsoluteTime.now(), deadline);
+ if (diff.d_ms === "forever") return;
+ const timer = setTimeout(toggle, diff.d_ms);
+ return () => {
+ clearTimeout(timer);
+ };
+ }, [deadline]);
+}
+
+export function AnswerChallenge({ session, focus, onComplete, routeAsk }: Props): VNode {
+ const { config, lib } = useChallengerApiContext();
const { i18n } = useTranslationContext();
- const { state, accepted, completed } = useSessionState();
+ const { sent, failed, completed } = useSessionState();
const [notification, withErrorHandler] = useLocalNotificationHandler();
const [pin, setPin] = useState<string | undefined>();
- const [lastTryError, setLastTryError] =
- useState<ChallengerApi.InvalidPinResponse>();
const errors = undefinedIfEmpty({
pin: !pin ? i18n.str`Can't be empty` : undefined,
});
- const lastEmail = !state
+ const restrictionKeys = !config.restrictions
+ ? []
+ : Object.keys(config.restrictions);
+ const restrictionKey = !restrictionKeys.length
? undefined
- : !state.lastStatus
+ : restrictionKeys[0];
+
+ const result = useChallengeSession(session);
+
+ const lastStatus =
+ result && !(result instanceof TalerError) && result.type !== "fail"
+ ? result.body
+ : undefined;
+
+ const deadline =
+ lastStatus == undefined
? undefined
- : !state.lastStatus.last_address
- ? undefined
- : state.lastStatus.last_address["email"];
+ : AbsoluteTime.fromProtocolTimestamp(lastStatus.retransmission_time);
+
+ useReloadOnDeadline(deadline ?? AbsoluteTime.never());
+
+ if (!restrictionKey) {
+ return (
+ <div>
+ invalid server configuration, there is no restriction in /config
+ </div>
+ );
+ }
+
+ const lastAddr = !lastStatus?.last_address
+ ? undefined
+ : lastStatus.last_address[restrictionKey];
+
+ const unableToChangeAddr = !lastStatus || lastStatus.changes_left < 1;
+ const contact = lastAddr ? { [restrictionKey]: lastAddr } : undefined;
const onSendAgain =
- !state || lastEmail === undefined
+ contact === undefined ||
+ lastStatus == undefined ||
+ lastStatus.pin_transmissions_left === 0 ||
+ !deadline ||
+ !AbsoluteTime.isExpired(deadline)
? undefined
: withErrorHandler(
async () => {
- if (!lastEmail) return;
- return await lib.challenger.challenge(nonce, { email: lastEmail });
+ return await lib.challenger.challenge(session.nonce, contact);
},
(ok) => {
- if ("redirectURL" in ok.body) {
- completed(ok.body.redirectURL);
+ if (ok.body.type === "completed") {
+ completed(ok.body);
} else {
- accepted({
- attemptsLeft: ok.body.attempts_left,
- nextSend: ok.body.next_tx_time,
- transmitted: ok.body.transmitted,
- });
+ sent(ok.body);
}
- return undefined;
},
(fail) => {
switch (fail.case) {
case HttpStatusCode.BadRequest:
- return i18n.str``;
+ return i18n.str`The request was not accepted, try reloading the app.`;
case HttpStatusCode.NotFound:
- return i18n.str``;
+ return i18n.str`Challenge not found.`;
case HttpStatusCode.NotAcceptable:
- return i18n.str``;
+ return i18n.str`Server templates are missing due to misconfiguration.`;
case HttpStatusCode.TooManyRequests:
- return i18n.str``;
+ return i18n.str`There have been too many attempts to request challenge transmissions.`;
case HttpStatusCode.InternalServerError:
- return i18n.str``;
+ return i18n.str`Server is not able to respond due to internal problems.`;
}
},
);
const onCheck =
- errors !== undefined || (lastTryError && lastTryError.exhausted)
+ errors !== undefined ||
+ lastStatus == undefined ||
+ lastStatus.auth_attempts_left === 0
? undefined
: withErrorHandler(
async () => {
- return lib.challenger.solve(nonce, { pin: pin! });
+ return lib.challenger.solve(session.nonce, { pin: pin! });
},
(ok) => {
- completed(ok.body.redirectURL as URL);
+ if (ok.body.type === "completed") {
+ completed(ok.body);
+ } else {
+ failed(ok.body);
+ }
onComplete();
},
(fail) => {
switch (fail.case) {
case HttpStatusCode.BadRequest:
- return i18n.str`Invalid request`;
+ return i18n.str`The request was not accepted, try reloading the app.`;
case HttpStatusCode.Forbidden: {
- setLastTryError(fail.body);
- return i18n.str`Invalid pin`;
+ revalidateChallengeSession();
+ return i18n.str`Invalid pin.`;
}
case HttpStatusCode.NotFound:
- return i18n.str``;
+ return i18n.str`Challenge not found.`;
case HttpStatusCode.NotAcceptable:
- return i18n.str``;
- case HttpStatusCode.TooManyRequests:
- return i18n.str``;
+ return i18n.str`Server templates are missing due to misconfiguration.`;
+ case HttpStatusCode.TooManyRequests: {
+ revalidateChallengeSession();
+ return i18n.str`There have been too many attempts to request challenge transmissions.`;
+ }
case HttpStatusCode.InternalServerError:
- return i18n.str``;
+ return i18n.str`Server is not able to respond due to internal problems.`;
default:
assertUnreachable(fail);
}
},
);
+ const cantTryAnymore = lastStatus?.auth_attempts_left === 0;
+
+ function LastContactSent(): VNode {
+ return (
+ <p class="mt-2 text-lg leading-8 text-gray-600">
+ {!lastStatus || !deadline || AbsoluteTime.isExpired(deadline) ? (
+ <i18n.Translate>
+ Last TAN code was sent to your address &quot;{lastAddr}
+ &quot; is not valid anymore.
+ </i18n.Translate>
+ ) : (
+ <Attention
+ title={i18n.str`A TAN code was sent to your address "${lastAddr}"`}
+ >
+ <i18n.Translate>
+ You should wait until &quot;
+ <Time format="dd/MM/yyyy HH:mm:ss" timestamp={deadline} />
+ &quot; to send a new one.
+ </i18n.Translate>
+ </Attention>
+ )}
+ </p>
+ );
+ }
- if (!state) {
- return <div>no state</div>;
+ function TryAnotherCode(): VNode {
+ return (
+ <div class="mx-auto mt-4 max-w-xl flex justify-between">
+ <div>
+ <a
+ data-disabled={unableToChangeAddr}
+ href={unableToChangeAddr ? undefined : routeAsk.url({})}
+ class="relative data-[disabled=true]:bg-gray-300 data-[disabled=true]:text-white data-[disabled=true]:cursor-default inline-flex items-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus-visible:outline-offset-0"
+ >
+ <i18n.Translate>Try with another address</i18n.Translate>
+ </a>
+ {lastStatus === undefined ? undefined : (
+ <p class="mt-2 text-sm leading-6 text-gray-400">
+ {lastStatus.changes_left < 1 ? (
+ <i18n.Translate>
+ You can&#39;t change the contact address anymore.
+ </i18n.Translate>
+ ) : lastStatus.changes_left === 1 ? (
+ <i18n.Translate>
+ You can change the contact address one last time.
+ </i18n.Translate>
+ ) : (
+ <i18n.Translate>
+ You can change the contact address {lastStatus.changes_left}{" "}
+ more times.
+ </i18n.Translate>
+ )}
+ </p>
+ )}
+ </div>
+ <div>
+ <Button
+ type="submit"
+ disabled={!onSendAgain}
+ class="block w-full disabled:bg-gray-300 rounded-md bg-indigo-600 px-3.5 py-2.5 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
+ handler={onSendAgain}
+ >
+ <i18n.Translate>Send new code</i18n.Translate>
+ </Button>
+ {lastStatus === undefined ? undefined : (
+ <p class="mt-2 text-sm leading-6 text-gray-400">
+ {lastStatus.pin_transmissions_left < 1 ? (
+ <i18n.Translate>
+ We can&#39;t send you the code anymore.
+ </i18n.Translate>
+ ) : lastStatus.pin_transmissions_left === 1 ? (
+ <i18n.Translate>
+ We can send the code one last time.
+ </i18n.Translate>
+ ) : (
+ <i18n.Translate>
+ We can send the code {lastStatus.pin_transmissions_left} more
+ times.
+ </i18n.Translate>
+ )}
+ </p>
+ )}
+ </div>
+ </div>
+ );
}
- if (!state.lastTry) {
- return <div>you should do a challenge first</div>;
+ if (cantTryAnymore) {
+ return (
+ <Fragment>
+ <LocalNotificationBanner notification={notification} />
+ <div class="isolate bg-white px-6 py-12">
+ <div class="mx-auto max-w-2xl text-center">
+ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
+ <i18n.Translate>Last TAN code can not be used.</i18n.Translate>
+ </h2>
+
+ <LastContactSent />
+ </div>
+
+ <TryAnotherCode />
+ </div>
+ </Fragment>
+ );
}
return (
@@ -149,33 +301,31 @@ export function AnswerChallenge({ focus, nonce, onComplete, routeAsk }: Props):
Enter the TAN you received to authenticate.
</i18n.Translate>
</h2>
- <p class="mt-2 text-lg leading-8 text-gray-600">
- {state.lastTry.transmitted ? (
- <i18n.Translate>
- A TAN was sent to your address &quot;{lastEmail}&quot;.
- </i18n.Translate>
- ) : (
- <Attention title={i18n.str`Resend failed`} type="warning">
+ <LastContactSent />
+
+ {lastStatus === undefined ? undefined : (
+ <p class="mt-2 text-lg leading-8 text-gray-600">
+ {lastStatus.auth_attempts_left < 1 ? (
<i18n.Translate>
- We recently already sent a TAN to your address &quot;
- {lastEmail}&quot;. A new TAN will not be transmitted again
- before &quot;{state.lastTry.nextSend}&quot;.
+ You can&#39;t check the PIN anymore.
</i18n.Translate>
- </Attention>
- )}
- </p>
- {!lastTryError ? undefined : (
- <p class="mt-2 text-lg leading-8 text-gray-600">
- <i18n.Translate>
- You can try another PIN but just{" "}
- {lastTryError.auth_attempts_left} times more.
- </i18n.Translate>
+ ) : lastStatus.auth_attempts_left === 1 ? (
+ <i18n.Translate>
+ You can check the PIN one last time.
+ </i18n.Translate>
+ ) : (
+ <i18n.Translate>
+ You can check the PIN {lastStatus.auth_attempts_left} more
+ times.
+ </i18n.Translate>
+ )}
</p>
)}
</div>
+
<form
method="POST"
- class="mx-auto mt-16 max-w-xl sm:mt-20"
+ class="mx-auto mt-4 max-w-xl"
onSubmit={(e) => {
e.preventDefault();
}}
@@ -209,12 +359,6 @@ export function AnswerChallenge({ focus, nonce, onComplete, routeAsk }: Props):
/>
</div>
</div>
-
- <p class="mt-3 text-sm leading-6 text-gray-400">
- <i18n.Translate>
- You have {state.lastTry.attemptsLeft} attempts left.
- </i18n.Translate>
- </p>
</div>
<div class="mt-10">
@@ -227,27 +371,9 @@ export function AnswerChallenge({ focus, nonce, onComplete, routeAsk }: Props):
<i18n.Translate>Check</i18n.Translate>
</Button>
</div>
- <div class="mt-10 flex justify-between">
- <div>
- <a
- href={routeAsk.url({ nonce })}
- class="relative disabled:bg-gray-100 disabled:text-gray-500 inline-flex items-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus-visible:outline-offset-0"
- >
- <i18n.Translate>Change email</i18n.Translate>
- </a>
- </div>
- <div>
- <Button
- type="submit"
- disabled={!onSendAgain}
- class="block w-full disabled:bg-gray-300 rounded-md bg-indigo-600 px-3.5 py-2.5 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
- handler={onSendAgain}
- >
- <i18n.Translate>Send code again</i18n.Translate>
- </Button>
- </div>
- </div>
</form>
+
+ <TryAnotherCode />
</div>
</Fragment>
);
diff --git a/packages/challenger-ui/src/pages/AskChallenge.tsx b/packages/challenger-ui/src/pages/AskChallenge.tsx
index 30b50d707..f034a773b 100644
--- a/packages/challenger-ui/src/pages/AskChallenge.tsx
+++ b/packages/challenger-ui/src/pages/AskChallenge.tsx
@@ -13,219 +13,418 @@
You should have received a copy of the GNU General Public License along with
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { HttpStatusCode } from "@gnu-taler/taler-util";
+import {
+ EmptyObject,
+ HttpStatusCode,
+ TalerError,
+ TranslatedString
+} from "@gnu-taler/taler-util";
import {
Attention,
Button,
LocalNotificationBanner,
RouteDefinition,
ShowInputErrorLabel,
+ Time,
useChallengerApiContext,
useLocalNotificationHandler,
useTranslationContext,
} from "@gnu-taler/web-util/browser";
import { Fragment, VNode, h } from "preact";
import { useState } from "preact/hooks";
-import { useSessionState } from "../hooks/session.js";
+import { useChallengeSession } from "../hooks/challenge.js";
+import { SessionId, useSessionState } from "../hooks/session.js";
import { doAutoFocus } from "./AnswerChallenge.js";
-type Form = {
- email: string;
-};
export const EMAIL_REGEX = /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/;
type Props = {
- nonce: string;
onSendSuccesful: () => void;
- routeSolveChallenge: RouteDefinition<{ nonce: string }>;
+ session: SessionId;
+ routeSolveChallenge: RouteDefinition<EmptyObject>;
focus?: boolean;
};
export function AskChallenge({
- nonce,
onSendSuccesful,
routeSolveChallenge,
+ session,
focus,
}: Props): VNode {
- const { state, accepted, completed } = useSessionState();
- const status = state?.lastStatus;
- const prevEmail =
- !status || !status.last_address ? undefined : status.last_address["email"];
- const regexEmail =
- !status || !status.restrictions ? undefined : status.restrictions["email"];
+ const { state, sent, saveAddress, completed } = useSessionState();
+ const { lib, config } = useChallengerApiContext();
- const { lib } = useChallengerApiContext();
const { i18n } = useTranslationContext();
const [notification, withErrorHandler] = useLocalNotificationHandler();
- const [email, setEmail] = useState<string | undefined>();
+ const [address, setEmail] = useState<string | undefined>();
const [repeat, setRepeat] = useState<string | undefined>();
+ const [remember, setRemember] = useState<boolean>(false);
+ const [addrIndex, setAddrIndex] = useState<number | undefined>();
+
+ const restrictionKeys = !config.restrictions
+ ? []
+ : Object.keys(config.restrictions);
+ const restrictionKey = !restrictionKeys.length
+ ? undefined
+ : restrictionKeys[0];
+ const result = useChallengeSession(session);
+
+ if (!restrictionKey) {
+ return (
+ <div>
+ invalid server configuration, there is no restriction in /config
+ </div>
+ );
+ }
+
+ const regexEmail = !config.restrictions
+ ? undefined
+ : config.restrictions[restrictionKey];
const regexTest =
regexEmail && regexEmail.regex ? new RegExp(regexEmail.regex) : EMAIL_REGEX;
const regexHint =
regexEmail && regexEmail.hint ? regexEmail.hint : i18n.str`invalid email`;
+ const lastStatus =
+ result && !(result instanceof TalerError) && result.type !== "fail"
+ ? result.body
+ : undefined;
+
+ const prevAddr = !lastStatus?.last_address
+ ? undefined
+ : lastStatus.last_address[restrictionKey];
+
const errors = undefinedIfEmpty({
- email: !email
+ address: !address
? i18n.str`required`
- : !regexTest.test(email)
+ : !regexTest.test(address)
? regexHint
- : prevEmail !== undefined && email === prevEmail
- ? i18n.str`email should be different`
+ : prevAddr !== undefined && address === prevAddr
+ ? i18n.str`can't use the same address`
: undefined,
repeat: !repeat
? i18n.str`required`
- : email !== repeat
- ? i18n.str`emails doesn't match`
+ : address !== repeat
+ ? i18n.str`doesn't match`
: undefined,
});
- const onSend = errors
- ? undefined
- : withErrorHandler(
- async () => {
- return lib.challenger.challenge(nonce, { email: email! });
- },
- (ok) => {
- if ("redirectURL" in ok.body) {
- completed(ok.body.redirectURL);
- } else {
- accepted({
- attemptsLeft: ok.body.attempts_left,
- nextSend: ok.body.next_tx_time,
- transmitted: ok.body.transmitted,
- });
- }
- onSendSuccesful();
- },
- (fail) => {
- switch (fail.case) {
- case HttpStatusCode.BadRequest:
- return i18n.str``;
- case HttpStatusCode.NotFound:
- return i18n.str``;
- case HttpStatusCode.NotAcceptable:
- return i18n.str``;
- case HttpStatusCode.TooManyRequests:
- return i18n.str``;
- case HttpStatusCode.InternalServerError:
- return i18n.str``;
- }
- },
- );
+ const contact = address ? { [restrictionKey]: address } : undefined;
- if (!status) {
+ const usableAddrs =
+ !state?.lastAddress || !state.lastAddress.length
+ ? []
+ : state.lastAddress.filter((d) => !!d.address[restrictionKey]);
+
+ const onSend =
+ errors || !contact
+ ? undefined
+ : withErrorHandler(
+ async () => {
+ return lib.challenger.challenge(session.nonce, contact);
+ },
+ (ok) => {
+ if (ok.body.type === "completed") {
+ completed(ok.body);
+ } else {
+ if (remember) {
+ saveAddress(config.address_type, contact);
+ }
+ sent(ok.body);
+ }
+ onSendSuccesful();
+ },
+ (fail) => {
+ switch (fail.case) {
+ case HttpStatusCode.BadRequest:
+ return i18n.str`The request was not accepted, try reloading the app.`;
+ case HttpStatusCode.NotFound:
+ return i18n.str`Challenge not found.`;
+ case HttpStatusCode.NotAcceptable:
+ return i18n.str`Server templates are missing due to misconfiguration.`;
+ case HttpStatusCode.TooManyRequests:
+ return i18n.str`There have been too many attempts to request challenge transmissions.`;
+ case HttpStatusCode.InternalServerError:
+ return i18n.str`Server is not able to respond due to internal problems.`;
+ }
+ },
+ );
+
+ if (!lastStatus) {
return <div>no status loaded</div>;
}
return (
<Fragment>
- <LocalNotificationBanner notification={notification} />
+ <LocalNotificationBanner notification={notification} showDebug={true} />
<div class="isolate bg-white px-6 py-12">
<div class="mx-auto max-w-2xl text-center">
<h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
<i18n.Translate>Enter contact details</i18n.Translate>
</h2>
- <p class="mt-2 text-lg leading-8 text-gray-600">
- <i18n.Translate>
- You will receive an email with a TAN code that must be provided on
- the next page.
- </i18n.Translate>
- </p>
+ {config.address_type === "email" ? (
+ <p class="mt-2 text-lg leading-8 text-gray-600">
+ <i18n.Translate>
+ You will receive an email with a TAN code that must be provided
+ on the next page.
+ </i18n.Translate>
+ </p>
+ ) : config.address_type === "phone" ? (
+ <p class="mt-2 text-lg leading-8 text-gray-600">
+ <i18n.Translate>
+ You will receive an SMS with a TAN code that must be provided on
+ the next page.
+ </i18n.Translate>
+ </p>
+ ) : (
+ <p class="mt-2 text-lg leading-8 text-gray-600">
+ <i18n.Translate>
+ You will receive an message with a TAN code that must be
+ provided on the next page.
+ </i18n.Translate>
+ </p>
+ )}
</div>
- {state.lastTry && (
+
+ {lastStatus?.last_address && (
<Fragment>
- <Attention title={i18n.str`A code has been sent to ${prevEmail}`}>
+ <Attention title={i18n.str`A code has been sent to ${prevAddr}`}>
<i18n.Translate>
- <a href={routeSolveChallenge.url({ nonce })} class="underline">
+ <a href={routeSolveChallenge.url({})} class="underline">
<i18n.Translate>Complete the challenge here.</i18n.Translate>
</a>
</i18n.Translate>
</Attention>
</Fragment>
)}
+
+ {!usableAddrs.length ? undefined : (
+ <div class="mx-auto max-w-xl mt-4">
+ <h3>
+ <i18n.Translate>Previous address</i18n.Translate>
+ </h3>
+ <fieldset>
+ <div class="relative -space-y-px rounded-md bg-white">
+ {usableAddrs.map((addr, idx) => {
+ return (
+ <label
+ data-checked={addrIndex === idx}
+ key={idx}
+ class="relative flex border-gray-200 data-[checked=true]:z-10 data-[checked=true]:bg-indigo-50 cursor-pointer flex-col rounded-tl-md rounded-tr-md border p-4 focus:outline-none md:grid md:grid-cols-2 md:pl-4 md:pr-6"
+ >
+ <span class="flex items-center text-sm">
+ <input
+ type="radio"
+ name={`addr-${idx}`}
+ value={addr.address[restrictionKey]}
+ checked={addrIndex === idx}
+ onClick={() => {
+ setAddrIndex(idx);
+ setEmail(addr.address[restrictionKey]);
+ setRepeat(addr.address[restrictionKey]);
+ }}
+ class="h-4 w-4 border-gray-300 text-indigo-600 focus:ring-indigo-600 active:ring-2 active:ring-indigo-600 active:ring-offset-2"
+ />
+ <span
+ data-checked={addrIndex === idx}
+ class="ml-3 font-medium text-gray-900 data-[checked=true]:text-indigo-900 "
+ >
+ {addr.address[restrictionKey]}
+ </span>
+ </span>
+ <span
+ data-checked={addrIndex === idx}
+ class="ml-6 pl-1 text-sm md:ml-0 md:pl-0 md:text-right text-gray-500 data-[checked=true]:text-indigo-700"
+ >
+ <i18n.Translate>
+ Last used at{" "}
+ <Time
+ format="dd/MM/yyyy HH:mm:ss"
+ timestamp={addr.savedAt}
+ />
+ </i18n.Translate>
+ </span>
+ </label>
+ );
+ })}
+ <label
+ data-checked={addrIndex === undefined}
+ class="relative rounded-bl-md rounded-br-md flex border-gray-200 data-[checked=true]:z-10 data-[checked=true]:bg-indigo-50 cursor-pointer flex-col rounded-tl-md rounded-tr-md border p-4 focus:outline-none md:grid md:grid-cols-2 md:pl-4 md:pr-6"
+ >
+ <span class="flex items-center text-sm">
+ <input
+ type="radio"
+ name="new-addr"
+ value="new-addr"
+ checked={addrIndex === undefined}
+ onClick={() => {
+ setAddrIndex(undefined);
+ setEmail(undefined);
+ setRepeat(undefined);
+ }}
+ class="h-4 w-4 border-gray-300 text-indigo-600 focus:ring-indigo-600 active:ring-2 active:ring-indigo-600 active:ring-offset-2"
+ />
+ <span
+ data-checked={addrIndex === undefined}
+ class="ml-3 font-medium text-gray-900 data-[checked=true]:text-indigo-900 "
+ >
+ <i18n.Translate>Use new address</i18n.Translate>
+ </span>
+ </span>
+ </label>
+ </div>
+ </fieldset>
+ </div>
+ )}
+
<form
method="POST"
- class="mx-auto mt-16 max-w-xl sm:mt-20"
+ class="mx-auto mt-4 max-w-xl "
onSubmit={(e) => {
e.preventDefault();
}}
>
- <div class="grid grid-cols-1 gap-x-8 gap-y-6">
+ <div class="sm:col-span-2">
+ <label
+ for="address"
+ class="block text-sm font-semibold leading-6 text-gray-900"
+ >
+ {(function (): TranslatedString {
+ switch (config.address_type) {
+ case "email":
+ return i18n.str`Email`;
+ case "phone":
+ return i18n.str`Phone`;
+ }
+ })()}
+ </label>
+ <div class="mt-2.5">
+ <input
+ type="text"
+ name="address"
+ id="address"
+ ref={focus ? doAutoFocus : undefined}
+ maxLength={512}
+ autocomplete={(function (): string {
+ switch (config.address_type) {
+ case "email":
+ return "email";
+ case "phone":
+ return "phone";
+ }
+ })()}
+ value={address ?? ""}
+ onChange={(e) => {
+ setEmail(e.currentTarget.value);
+ }}
+ placeholder={prevAddr}
+ readOnly={lastStatus.fix_address || addrIndex !== undefined}
+ class="block w-full read-only:bg-slate-200 rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
+ />
+ <ShowInputErrorLabel
+ message={errors?.address}
+ isDirty={address !== undefined}
+ />
+ </div>
+ </div>
+
+ {lastStatus.fix_address || addrIndex !== undefined ? undefined : (
<div class="sm:col-span-2">
<label
- for="email"
+ for="repeat-address"
class="block text-sm font-semibold leading-6 text-gray-900"
>
- <i18n.Translate>Email</i18n.Translate>
+ {(function (): TranslatedString {
+ switch (config.address_type) {
+ case "email":
+ return i18n.str`Repeat email`;
+ case "phone":
+ return i18n.str`Repeat phone`;
+ }
+ })()}
</label>
<div class="mt-2.5">
<input
- type="email"
- name="email"
- id="email"
- ref={focus ? doAutoFocus : undefined}
- maxLength={512}
- autocomplete="email"
- value={email}
+ type="text"
+ name="repeat-address"
+ id="repeat-address"
+ value={repeat ?? ""}
onChange={(e) => {
- setEmail(e.currentTarget.value);
+ setRepeat(e.currentTarget.value);
}}
- placeholder={prevEmail}
- readOnly={status.fix_address}
- class="block w-full read-only:bg-slate-200 rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
+ autocomplete={(function (): string {
+ switch (config.address_type) {
+ case "email":
+ return "email";
+ case "phone":
+ return "phone";
+ }
+ })()}
+ class="block w-full rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
/>
<ShowInputErrorLabel
- message={errors?.email}
- isDirty={email !== undefined}
+ message={errors?.repeat}
+ isDirty={repeat !== undefined}
/>
</div>
</div>
+ )}
- {status.fix_address ? undefined : (
- <div class="sm:col-span-2">
- <label
- for="repeat-email"
- class="block text-sm font-semibold leading-6 text-gray-900"
- >
- <i18n.Translate>Repeat email</i18n.Translate>
- </label>
- <div class="mt-2.5">
- <input
- type="email"
- name="repeat-email"
- id="repeat-email"
- value={repeat}
- onChange={(e) => {
- setRepeat(e.currentTarget.value);
- }}
- autocomplete="email"
- class="block w-full rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
- />
- <ShowInputErrorLabel
- message={errors?.repeat}
- isDirty={repeat !== undefined}
- />
- </div>
- </div>
- )}
+ {lastStatus === undefined ? undefined : (
+ <p class="mt-2 text-sm leading-6 text-gray-400">
+ {lastStatus.changes_left < 1 ? (
+ <i18n.Translate>
+ You can&#39;t change the contact address anymore.
+ </i18n.Translate>
+ ) : lastStatus.changes_left === 1 ? (
+ <i18n.Translate>
+ You can change the contact address one last time.
+ </i18n.Translate>
+ ) : (
+ <i18n.Translate>
+ You can change the contact address {lastStatus.changes_left}{" "}
+ more times.
+ </i18n.Translate>
+ )}
+ </p>
+ )}
- {!status.changes_left ? (
- <p class="mt-3 text-sm leading-6 text-gray-400">
- <i18n.Translate>No more changes left</i18n.Translate>
- </p>
- ) : (
- <p class="mt-3 text-sm leading-6 text-gray-400">
+ <div class="flex items-center justify-between py-2">
+ <span class="flex flex-grow flex-col">
+ <span
+ class="text-sm text-black font-medium leading-6 "
+ id="availability-label"
+ >
<i18n.Translate>
- You can change your email address another{" "}
- {status.changes_left} times.
+ Remember this address for future challenges.
</i18n.Translate>
- </p>
- )}
+ </span>
+ </span>
+ <button
+ type="button"
+ name={`remember switch`}
+ data-enabled={remember}
+ class="bg-indigo-600 data-[enabled=false]:bg-gray-200 relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2"
+ role="switch"
+ aria-checked="false"
+ aria-labelledby="availability-label"
+ aria-describedby="availability-description"
+ onClick={() => {
+ setRemember(!remember);
+ }}
+ >
+ <span
+ aria-hidden="true"
+ data-enabled={remember}
+ class="translate-x-5 data-[enabled=false]:translate-x-0 pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out"
+ ></span>
+ </button>
</div>
-
- {!prevEmail ? (
+ </form>
+ <div class="mx-auto mt-4 max-w-xl ">
+ {!prevAddr ? (
<div class="mt-10">
<Button
type="submit"
@@ -233,7 +432,14 @@ export function AskChallenge({
class="block w-full disabled:bg-gray-300 rounded-md bg-indigo-600 px-3.5 py-2.5 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
handler={onSend}
>
- <i18n.Translate>Send email</i18n.Translate>
+ {(function (): TranslatedString {
+ switch (config.address_type) {
+ case "email":
+ return i18n.str`Send email`;
+ case "phone":
+ return i18n.str`Send SMS`;
+ }
+ })()}
</Button>
</div>
) : (
@@ -244,11 +450,18 @@ export function AskChallenge({
class="block w-full disabled:bg-gray-300 rounded-md bg-indigo-600 px-3.5 py-2.5 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
handler={onSend}
>
- <i18n.Translate>Change email</i18n.Translate>
+ {(function (): TranslatedString {
+ switch (config.address_type) {
+ case "email":
+ return i18n.str`Change email`;
+ case "phone":
+ return i18n.str`Change phone`;
+ }
+ })()}
</Button>
</div>
)}
- </form>
+ </div>
</div>
</Fragment>
);
diff --git a/packages/challenger-ui/src/pages/CallengeCompleted.tsx b/packages/challenger-ui/src/pages/CallengeCompleted.tsx
index f8cd7ce60..bff7b68f5 100644
--- a/packages/challenger-ui/src/pages/CallengeCompleted.tsx
+++ b/packages/challenger-ui/src/pages/CallengeCompleted.tsx
@@ -13,14 +13,32 @@
You should have received a copy of the GNU General Public License along with
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { VNode, h } from "preact";
+import { Attention, useTranslationContext } from "@gnu-taler/web-util/browser";
+import { Fragment, VNode, h } from "preact";
+import { useSessionState } from "../hooks/session.js";
+import { useEffect } from "preact/hooks";
-type Props = {
- nonce: string;
-}
-export function CallengeCompleted({nonce}:Props):VNode {
+export function CallengeCompleted(): VNode {
+ const { state } = useSessionState();
+
+ const { i18n } = useTranslationContext();
- return <div>
- completed {nonce}
- </div>
-} \ No newline at end of file
+ useEffect(() => {
+ window.location.href = state?.completedURL ?? "#"
+ },[])
+
+ return (
+ <div class="m-4">
+ <Attention
+ title={i18n.str`Challenge completed`}
+ type="success"
+ >
+ <i18n.Translate>
+ You will be redirected to <a href={state?.completedURL} class="break-all">&quot;
+ {state?.completedURL}
+ &quot;</a>
+ </i18n.Translate>
+ </Attention>
+ </div>
+ );
+}
diff --git a/packages/challenger-ui/src/pages/Frame.tsx b/packages/challenger-ui/src/pages/Frame.tsx
index 612eced0b..7f81b9d77 100644
--- a/packages/challenger-ui/src/pages/Frame.tsx
+++ b/packages/challenger-ui/src/pages/Frame.tsx
@@ -14,56 +14,121 @@
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { ComponentChildren, Fragment, h, VNode } from "preact";
+import { TranslatedString } from "@gnu-taler/taler-util";
+import {
+ Footer,
+ Header,
+ ToastBanner,
+ notifyError,
+ notifyException,
+ useTranslationContext,
+} from "@gnu-taler/web-util/browser";
+import { ComponentChildren, Fragment, VNode, h } from "preact";
+import { useEffect, useErrorBoundary } from "preact/hooks";
+import {
+ getAllBooleanPreferences,
+ getLabelForPreferences,
+ usePreferences,
+} from "../context/preferences.js";
+import { useSettingsContext } from "../context/settings.js";
+
+const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined;
+const VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : undefined;
export function Frame({ children }: { children: ComponentChildren }): VNode {
+ const settings = useSettingsContext();
+ const [preferences, updatePreferences] = usePreferences();
+
+ const [error, resetError] = useErrorBoundary();
+ const { i18n } = useTranslationContext();
+ useEffect(() => {
+ if (error) {
+ if (error instanceof Error) {
+ console.log("Internal error, please report", error);
+ notifyException(i18n.str`Internal error, please report.`, error);
+ } else {
+ console.log("Internal error, please report", error);
+ notifyError(
+ i18n.str`Internal error, please report.`,
+ String(error) as TranslatedString,
+ );
+ }
+ resetError();
+ }
+ }, [error]);
+
return (
- <Fragment>
- <header class="bg-indigo-600 w-full mx-auto px-2 border-b border-opacity-25 border-indigo-400">
- <div class="flex flex-row h-16 items-center ">
- <div class="flex px-2 justify-start">
- <div class="flex-shrink-0 bg-white rounded-lg">
- <a href="#">
- <img
- class="h-8 w-auto"
- src='data:image/svg+xml,<?xml version="1.0" encoding="UTF-8" standalone="no"?>%0A<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 201 90">%0A <g fill="%230042b3" fill-rule="evenodd" stroke-width=".3">%0A <path d="M86.7 1.1c15.6 0 29 9.4 36 23.2h-5.9A35.1 35.1 0 0086.7 6.5C67 6.5 51 23.6 51 44.7c0 10.4 3.8 19.7 10 26.6a31.4 31.4 0 01-4.2 3A45.2 45.2 0 0146 44.7c0-24 18.2-43.6 40.7-43.6zm35.8 64.3a40.4 40.4 0 01-39 22.8c3-1.5 6-3.5 8.6-5.7a35.6 35.6 0 0024.6-17.1z" />%0A <path d="M64.2 1.1l3.1.1c-3 1.6-5.9 3.5-8.5 5.8a37.5 37.5 0 00-30.2 37.7c0 14.3 7.3 26.7 18 33.3a29.6 29.6 0 01-8.5.2c-9-8-14.6-20-14.6-33.5 0-24 18.2-43.6 40.7-43.6zm5.4 81.4a35.6 35.6 0 0024.6-17.1h5.9a40.4 40.4 0 01-39 22.8c3-1.5 5.9-3.5 8.5-5.7zm24.8-58.2a37 37 0 00-12.6-12.8 29.6 29.6 0 018.5-.2c4 3.6 7.4 8 9.9 13z" />%0A <path d="M41.8 1.1c1 0 2 0 3.1.2-3 1.5-5.9 3.4-8.5 5.6A37.5 37.5 0 006.1 44.7c0 21.1 16 38.3 35.7 38.3 12.6 0 23.6-7 30-17.6h5.8a40.4 40.4 0 01-35.8 23C19.3 88.4 1 68.8 1 44.7c0-24 18.2-43.6 40.7-43.6zm30.1 23.2a38.1 38.1 0 00-4.5-6.1c1.3-1.2 2.7-2.2 4.3-3 2.3 2.7 4.4 5.8 6 9.1z" />%0A </g>%0A <path d="M76.1 34.4h9.2v-5H61.9v5H71v26h5.1zM92.6 52.9h13.7l3 7.4h5.3l-12.7-31.2h-4.7L84.5 60.3h5.2zm11.8-4.9h-9.9l5-12.4zM123.8 29.4h-4.6v31h20.6v-5h-16zM166.5 29.4H145v31h21.6v-5H150v-8.3h14.5v-4.9h-14.5v-8h16.4zM191.2 39.5c0 1.6-.5 2.8-1.6 3.8s-2.6 1.4-4.4 1.4h-7.4V34.3h7.4c1.9 0 3.4.4 4.4 1.3 1 .9 1.6 2.2 1.6 3.9zm6 20.8l-7.7-11.7c1-.3 1.9-.7 2.7-1.3a8.8 8.8 0 003.6-4.6c.4-1 .5-2.2.5-3.5 0-1.5-.2-2.9-.7-4.1a8.4 8.4 0 00-2.1-3.1c-1-.8-2-1.5-3.4-2-1.3-.4-2.8-.6-4.5-.6h-12.9v31h5V49.4h6.5l7 10.8z" />%0A</svg>'
- alt="GNU Taler"
- style="height: 1.5rem; margin: 0.5rem;"
- />
- </a>
- </div>
- <span class="flex items-center text-white text-lg font-bold ml-4">
- Challenger
- </span>
+ <div
+ class="min-h-full flex flex-col m-0 bg-slate-200"
+ style="min-height: 100vh;"
+ >
+ <Header
+ title="Challenger"
+ onLogout={undefined}
+ iconLinkURL="#"
+ sites={preferences.showChallangeSetup ? [
+ ["New challenge","#/setup/1"]
+ ] :[]}
+ supportedLangs={["en"]}
+ >
+ <li>
+ <div class="text-xs font-semibold leading-6 text-gray-400">
+ <i18n.Translate>Preferences</i18n.Translate>
</div>
- <div class="block flex-1 ml-6 "></div>
- <div class="flex justify-end"></div>
+ <ul role="list" class="space-y-4">
+ {getAllBooleanPreferences().map((set) => {
+ const isOn: boolean = !!preferences[set];
+ return (
+ <li key={set} class="pl-2">
+ <div class="flex items-center justify-between">
+ <span class="flex flex-grow flex-col">
+ <span
+ class="text-sm text-black font-medium leading-6 "
+ id="availability-label"
+ >
+ {getLabelForPreferences(set, i18n)}
+ </span>
+ </span>
+ <button
+ type="button"
+ name={`${set} switch`}
+ data-enabled={isOn}
+ class="bg-indigo-600 data-[enabled=false]:bg-gray-200 relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2"
+ role="switch"
+ aria-checked="false"
+ aria-labelledby="availability-label"
+ aria-describedby="availability-description"
+ onClick={() => {
+ updatePreferences(set, !isOn);
+ }}
+ >
+ <span
+ aria-hidden="true"
+ data-enabled={isOn}
+ class="translate-x-5 data-[enabled=false]:translate-x-0 pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out"
+ ></span>
+ </button>
+ </div>
+ </li>
+ );
+ })}
+ </ul>
+ </li>
+ </Header>
+
+ <div class="fixed z-20 top-14 w-full">
+ <div class="mx-auto w-4/5">
+ <ToastBanner />
</div>
- </header>
+ </div>
<main class="flex-1">{children}</main>
-
- <footer class="bottom-4 mb-4">
- <div class="mt-8 mx-8 md:order-1 md:mt-0">
- <div>
- <p class="text-xs leading-5 text-gray-400">
- Learn more about{" "}
- <a
- target="_blank"
- rel="noreferrer noopener"
- class="font-semibold text-gray-500 hover:text-gray-400"
- href="https://taler.net"
- >
- GNU Taler
- </a>
- </p>
- </div>
- <div style="flex-grow: 1;"></div>
- <p class="text-xs leading-5 text-gray-400">
- Copyright © 2014—2023 Taler Systems SA.{" "}
- </p>
- </div>
- </footer>
- </Fragment>
+
+ <Footer
+ testingUrlKey="challenger-base-url"
+ GIT_HASH={GIT_HASH}
+ VERSION={VERSION}
+ />
+ </div>
);
}
diff --git a/packages/challenger-ui/src/pages/Setup.tsx b/packages/challenger-ui/src/pages/Setup.tsx
index f431835aa..c7395f605 100644
--- a/packages/challenger-ui/src/pages/Setup.tsx
+++ b/packages/challenger-ui/src/pages/Setup.tsx
@@ -13,47 +13,84 @@
You should have received a copy of the GNU General Public License along with
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
-import { AccessToken, HttpStatusCode, encodeCrock, randomBytes } from "@gnu-taler/taler-util";
+import {
+ HttpStatusCode,
+ createClientSecretAccessToken,
+ createRFC8959AccessTokenEncoded,
+ encodeCrock,
+ randomBytes,
+} from "@gnu-taler/taler-util";
import {
Button,
LocalNotificationBanner,
+ ShowInputErrorLabel,
useChallengerApiContext,
useLocalNotificationHandler,
useTranslationContext,
} from "@gnu-taler/web-util/browser";
import { Fragment, VNode, h } from "preact";
+import { useState } from "preact/hooks";
+import { safeToURL } from "../Routing.js";
import { useSessionState } from "../hooks/session.js";
+import { doAutoFocus, undefinedIfEmpty } from "./AnswerChallenge.js";
type Props = {
clientId: string;
- onCreated: (nonce:string) => void;
+ secret: string | undefined;
+ redirectURL: URL | undefined;
+ onCreated: () => void;
+ focus?: boolean;
};
-export function Setup({ clientId, onCreated }: Props): VNode {
+export function Setup({
+ clientId,
+ secret,
+ redirectURL,
+ focus,
+ onCreated,
+}: Props): VNode {
const { i18n } = useTranslationContext();
const [notification, withErrorHandler] = useLocalNotificationHandler();
const { lib } = useChallengerApiContext();
const { start } = useSessionState();
+ const [password, setPassword] = useState<string | undefined>(secret);
+ const [url, setUrl] = useState<string | undefined>(redirectURL?.href);
- const onStart = withErrorHandler(
- async () => {
- return lib.challenger.setup(clientId, "secret-token:chal-secret" as AccessToken);
- },
- (ok) => {
- start({
- clientId,
- redirectURL: "http://exchange.taler.test:1180/kyc-proof/kyc-provider-wallet",
- state: encodeCrock(randomBytes(32)),
- });
+ const errors = undefinedIfEmpty({
+ password: !password ? i18n.str`required` : undefined,
+ url: !url
+ ? i18n.str`required`
+ : !safeToURL(url)
+ ? i18n.str`invalid format`
+ : undefined,
+ });
- onCreated(ok.body.nonce);
- },
- (fail) => {
- switch (fail.case) {
- case HttpStatusCode.NotFound:
- return i18n.str`Client doesn't exist.`;
- }
- },
- );
+ const onStart =
+ !!errors || password === undefined || url === undefined
+ ? undefined
+ : withErrorHandler(
+ async () => {
+ return lib.challenger.setup(
+ clientId,
+ createRFC8959AccessTokenEncoded(password),
+ );
+ },
+ (ok) => {
+ start({
+ nonce: ok.body.nonce,
+ clientId,
+ redirectURL: url,
+ state: encodeCrock(randomBytes(32)),
+ });
+
+ onCreated();
+ },
+ (fail) => {
+ switch (fail.case) {
+ case HttpStatusCode.NotFound:
+ return i18n.str`Client doesn't exist.`;
+ }
+ },
+ );
return (
<Fragment>
@@ -67,15 +104,81 @@ export function Setup({ clientId, onCreated }: Props): VNode {
</i18n.Translate>
</h2>
</div>
- <div class="mt-10">
- <Button
- type="submit"
- class="block w-full disabled:bg-gray-300 rounded-md bg-indigo-600 px-3.5 py-2.5 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
- handler={onStart}
+
+ <form
+ method="POST"
+ class="mx-auto mt-4 max-w-xl sm:mt-20"
+ onSubmit={(e) => {
+ e.preventDefault();
+ }}
+ >
+ <div class="sm:col-span-2">
+ <label
+ for="email"
+ class="block text-sm font-semibold leading-6 text-gray-900"
>
- <i18n.Translate>Start</i18n.Translate>
- </Button>
+ <i18n.Translate>Password</i18n.Translate>
+ </label>
+ <div class="mt-2.5">
+ <input
+ type="password"
+ name="password"
+ id="password"
+ ref={focus ? doAutoFocus : undefined}
+ maxLength={512}
+ autocomplete="password"
+ value={password}
+ onChange={(e) => {
+ setPassword(e.currentTarget.value);
+ }}
+ readOnly={secret !== undefined}
+ class="block w-full read-only:bg-slate-200 rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
+ />
+ <ShowInputErrorLabel
+ message={errors?.password}
+ isDirty={password !== undefined}
+ />
+ </div>
</div>
+
+ <div class="sm:col-span-2">
+ <label
+ for="email"
+ class="block text-sm font-semibold leading-6 text-gray-900"
+ >
+ <i18n.Translate>Redirect URL</i18n.Translate>
+ </label>
+ <div class="mt-2.5">
+ <input
+ type="text"
+ name="redirect_url"
+ id="redirect_url"
+ maxLength={512}
+ autocomplete="redirect_url"
+ value={url}
+ onChange={(e) => {
+ setUrl(e.currentTarget.value);
+ }}
+ readOnly={redirectURL !== undefined}
+ class="block w-full read-only:bg-slate-200 rounded-md border-0 px-3.5 py-2 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
+ />
+ <ShowInputErrorLabel
+ message={errors?.url}
+ isDirty={url !== undefined}
+ />
+ </div>
+ </div>
+ </form>
+ <div class="mt-10">
+ <Button
+ type="submit"
+ disabled={!onStart}
+ class="block w-full disabled:bg-gray-300 rounded-md bg-indigo-600 px-3.5 py-2.5 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
+ handler={onStart}
+ >
+ <i18n.Translate>Start</i18n.Translate>
+ </Button>
+ </div>
</div>
</Fragment>
);
diff --git a/packages/challenger-ui/src/validation-unknown.html b/packages/challenger-ui/src/validation-unknown.html
deleted file mode 100644
index 56c8d156c..000000000
--- a/packages/challenger-ui/src/validation-unknown.html
+++ /dev/null
@@ -1,89 +0,0 @@
-<!--
- This file is part of GNU Taler
- (C) 2021--2022 Taler Systems S.A.
-
- GNU Taler is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-
- @author Sebastian Javier Marchano
--->
-<!DOCTYPE html>
-<html lang="en" class="h-full">
-
-<head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <meta name="taler-support" content="uri">
- <meta name="mobile-web-app-capable" content="yes" />
- <meta name="apple-mobile-web-app-capable" content="yes" />
- <link rel="icon"
- href="data:;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAABILAAASCwAAAAAAAAAAAAD///////////////////////////////////////////////////////////////////////////////////////////////////7//v38//78/P/+/fz//vz7///+/v/+/f3//vz7///+/v/+/fz//v38///////////////////////+/v3///7+/////////////////////////////////////////////////////////v3//v79///////+/v3///////r28v/ct5//06SG/9Gffv/Xqo7/7N/V/9e2nf/bsJb/6uDW/9Sskf/euKH/+/j2///////+/v3//////+3azv+/eE3/2rWd/9Kkhv/Vr5T/48i2/8J+VP/Qn3//3ryn/795Tf/WrpP/2LCW/8B6T//w4Nb///////Pn4P+/d0v/9u3n/+7d0v/EhV7//v///+HDr//fxLD/zph2/+TJt//8/Pv/woBX//Lm3f/y5dz/v3hN//bu6f/JjGn/4sW0///////Df1j/8OLZ//v6+P+/elH/+vj1//jy7f+/elL//////+zYzP/Eg13//////967p//MlHT/wn5X///////v4Nb/yY1s///////jw7H/06KG////////////z5t9/+fNvf//////x4pn//Pp4v/8+vn/w39X/8WEX///////5s/A/9CbfP//////27Oc/9y2n////////////9itlf/gu6f//////86Vdf/r2Mz//////8SCXP/Df1j//////+7d0v/KkG7//////+HBrf/VpYr////////////RnoH/5sq6///////Ii2n/8ubf//39/P/Cf1j/xohk/+bNvv//////wn5W//Tq4//58/D/wHxV//7+/f/59fH/v3xU//39/P/w4Nf/xIFb///////hw7H/yo9t/+/f1f/AeU3/+/n2/+nSxP/FhmD//////9qzm//Upon/4MSx/96+qf//////xINc/+3bz//48e3/v3hN//Pn3///////6M+//752S//gw6//06aK/8J+VP/kzLr/zZd1/8OCWv/q18r/17KZ/9Ooi//fv6r/v3dK/+vWyP///////v39///////27un/1aeK/9Opjv/m1cf/1KCC/9a0nP/n08T/0Jx8/82YdP/QnHz/16yR//jx7P///////v39///////+/f3///7+///////+//7//v7+///////+/v7//v/+/////////////////////////v7//v79///////////////////+/v/+/Pv//v39///+/v/+/Pv///7+//7+/f/+/Pv//v39//79/P/+/Pv///7+////////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==" />
- <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon" />
- <link rel="stylesheet" href="main.css" />
- <script type="module" src="main.js"></script>
- <title>Validation process unknown (#{{ec}})</title>
-</head>
-
-<body class="min-h-full flex flex-col">
- <header class="bg-indigo-600 w-full mx-auto px-2 border-b border-opacity-25 border-indigo-400">
- <div class="flex flex-row h-16 items-center ">
- <div class="flex px-2 justify-start">
- <div class="flex-shrink-0 bg-white rounded-lg"><a href="#"><img class="h-8 w-auto"
- src="data:image/svg+xml,<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?>%0A<svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 201 90&quot;>%0A <g fill=&quot;%230042b3&quot; fill-rule=&quot;evenodd&quot; stroke-width=&quot;.3&quot;>%0A <path d=&quot;M86.7 1.1c15.6 0 29 9.4 36 23.2h-5.9A35.1 35.1 0 0086.7 6.5C67 6.5 51 23.6 51 44.7c0 10.4 3.8 19.7 10 26.6a31.4 31.4 0 01-4.2 3A45.2 45.2 0 0146 44.7c0-24 18.2-43.6 40.7-43.6zm35.8 64.3a40.4 40.4 0 01-39 22.8c3-1.5 6-3.5 8.6-5.7a35.6 35.6 0 0024.6-17.1z&quot; />%0A <path d=&quot;M64.2 1.1l3.1.1c-3 1.6-5.9 3.5-8.5 5.8a37.5 37.5 0 00-30.2 37.7c0 14.3 7.3 26.7 18 33.3a29.6 29.6 0 01-8.5.2c-9-8-14.6-20-14.6-33.5 0-24 18.2-43.6 40.7-43.6zm5.4 81.4a35.6 35.6 0 0024.6-17.1h5.9a40.4 40.4 0 01-39 22.8c3-1.5 5.9-3.5 8.5-5.7zm24.8-58.2a37 37 0 00-12.6-12.8 29.6 29.6 0 018.5-.2c4 3.6 7.4 8 9.9 13z&quot; />%0A <path d=&quot;M41.8 1.1c1 0 2 0 3.1.2-3 1.5-5.9 3.4-8.5 5.6A37.5 37.5 0 006.1 44.7c0 21.1 16 38.3 35.7 38.3 12.6 0 23.6-7 30-17.6h5.8a40.4 40.4 0 01-35.8 23C19.3 88.4 1 68.8 1 44.7c0-24 18.2-43.6 40.7-43.6zm30.1 23.2a38.1 38.1 0 00-4.5-6.1c1.3-1.2 2.7-2.2 4.3-3 2.3 2.7 4.4 5.8 6 9.1z&quot; />%0A </g>%0A <path d=&quot;M76.1 34.4h9.2v-5H61.9v5H71v26h5.1zM92.6 52.9h13.7l3 7.4h5.3l-12.7-31.2h-4.7L84.5 60.3h5.2zm11.8-4.9h-9.9l5-12.4zM123.8 29.4h-4.6v31h20.6v-5h-16zM166.5 29.4H145v31h21.6v-5H150v-8.3h14.5v-4.9h-14.5v-8h16.4zM191.2 39.5c0 1.6-.5 2.8-1.6 3.8s-2.6 1.4-4.4 1.4h-7.4V34.3h7.4c1.9 0 3.4.4 4.4 1.3 1 .9 1.6 2.2 1.6 3.9zm6 20.8l-7.7-11.7c1-.3 1.9-.7 2.7-1.3a8.8 8.8 0 003.6-4.6c.4-1 .5-2.2.5-3.5 0-1.5-.2-2.9-.7-4.1a8.4 8.4 0 00-2.1-3.1c-1-.8-2-1.5-3.4-2-1.3-.4-2.8-.6-4.5-.6h-12.9v31h5V49.4h6.5l7 10.8z&quot; />%0A</svg>"
- alt="GNU Taler" style="height: 1.5rem; margin: 0.5rem;"></a></div><span
- class="flex items-center text-white text-lg font-bold ml-4">Challenger</span>
- </div>
- <div class="block flex-1 ml-6 "></div>
- <div class="flex justify-end">
- </div>
- </div>
- </header>
-
- <main class="flex-1">
-
- <div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 items-center mt-4">
- <div class="rounded-md bg-red-50 p-4 shadow-xl">
- <div class="flex">
- <div class="flex-shrink-0">
- <svg xmlns="http://www.w3.org/2000/svg" stroke="none" viewBox="0 0 24 24" fill="currentColor"
- class="w-8 h-8 text-red-400">
- <path fill-rule="evenodd"
- d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z" />
- </svg>
- </div>
- <div class="ml-3">
- <h3 class="text-sm font-medium text-red-800">
- Validation error
- </h3>
- <div class="mt-2 text-sm text-red-700">
- <p>{{hint}}</p>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- </main>
-
- <footer class="bottom-4 mb-4">
- <div class="mt-8 mx-8 md:order-1 md:mt-0">
- <div>
- <p class="text-xs leading-5 text-gray-400">Learn more about <a target="_blank" rel="noreferrer noopener"
- class="font-semibold text-gray-500 hover:text-gray-400" href="https://taler.net">GNU Taler</a></p>
- </div>
- <div style="flex-grow: 1;"></div>
- <p class="text-xs leading-5 text-gray-400">Copyright © 2014—2023 Taler Systems SA. </p>
- </div>
- </footer>
-</body>
-
-</html> \ No newline at end of file