/* eslint-disable @typescript-eslint/camelcase */ import { encodeCrock, stringToBytes } from "@gnu-taler/taler-util"; import { Fragment, h, VNode } from "preact"; import { useLayoutEffect, useRef, useState } from "preact/hooks"; import { NumberInput } from "../../../components/fields/NumberInput"; import { AuthMethodSetupProps } from "../AuthenticationEditorScreen"; import { AnastasisClientFrame } from "../index"; export function AuthMethodSmsSetup({ addAuthMethod, cancel, configured }: AuthMethodSetupProps): VNode { const [mobileNumber, setMobileNumber] = useState(""); const addSmsAuth = (): void => { addAuthMethod({ authentication_method: { type: "sms", instructions: `SMS to ${mobileNumber}`, challenge: encodeCrock(stringToBytes(mobileNumber)), }, }); }; const inputRef = useRef(null); useLayoutEffect(() => { inputRef.current?.focus(); }, []); const errors = !mobileNumber ? 'Add a mobile number' : undefined return (

For SMS authentication, you need to provide a mobile number. When recovering your secret, you will be asked to enter the code you receive via SMS.

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

{c.instructions}

})}
}
); }