import { encodeCrock, stringToBytes } from "@gnu-taler/taler-util"; import { Fragment, h, VNode } from "preact"; import { useState } from "preact/hooks"; import { AuthMethodSetupProps } from "./index"; import { AnastasisClientFrame } from "../index"; import { TextInput } from "../../../components/fields/TextInput"; export function AuthMethodQuestionSetup({ cancel, addAuthMethod, configured, }: AuthMethodSetupProps): VNode { const [questionText, setQuestionText] = useState(""); const [answerText, setAnswerText] = useState(""); const addQuestionAuth = (): void => addAuthMethod({ authentication_method: { type: "question", instructions: questionText, challenge: encodeCrock(stringToBytes(answerText)), }, }); const errors = !questionText ? "Add your security question" : !answerText ? "Add the answer to your question" : undefined; return (

For2 security question authentication, you need to provide a question and its answer. When recovering your secret, you will be shown the question and you will need to type the answer exactly as you typed it here.

{configured.length > 0 && (
Your security questions:
{configured.map((c, i) => { return (

{c.instructions}

); })}
)}
); }