import { ChallengeFeedback, ChallengeFeedbackStatus } from "anastasis-core";
import { h, VNode } from "preact";
import { useAnastasisContext } from "../../context/anastasis";
import { AnastasisClientFrame } from "./index";
import { authMethods, KnownAuthMethods } from "./authMethod";
function OverviewFeedbackDisplay(props: { feedback?: ChallengeFeedback }) {
const { feedback } = props;
if (!feedback) {
return null;
}
switch (feedback.state) {
case ChallengeFeedbackStatus.Message:
return (
{feedback.message}
);
case ChallengeFeedbackStatus.Solved:
return
case ChallengeFeedbackStatus.Pending:
case ChallengeFeedbackStatus.Solved:
case ChallengeFeedbackStatus.AuthIban:
return null;
case ChallengeFeedbackStatus.ServerFailure:
return
Server error.
;
case ChallengeFeedbackStatus.RateLimitExceeded:
return
There were to many failed attempts.
;
case ChallengeFeedbackStatus.Unsupported:
return
This client doesn't support solving this type of challenge. Use another version or contact the provider.
;
case ChallengeFeedbackStatus.TruthUnknown:
return
Provider doesn't recognize the challenge of the policy. Contact the provider for further information.
;
case ChallengeFeedbackStatus.Redirect:
default:
return ;
}
}
export function ChallengeOverviewScreen(): VNode {
const reducer = useAnastasisContext();
if (!reducer) {
return
}
function ChallengeButton({ id, feedback }: { id: string; feedback?: ChallengeFeedback }): VNode {
function selectChallenge(): void {
if (reducer) reducer.transition("select_challenge", { uuid: id })
}
if (!feedback) {
return
}
switch (feedback.state) {
case ChallengeFeedbackStatus.ServerFailure:
case ChallengeFeedbackStatus.Unsupported:
case ChallengeFeedbackStatus.TruthUnknown:
case ChallengeFeedbackStatus.RateLimitExceeded: return
case ChallengeFeedbackStatus.AuthIban:
case ChallengeFeedbackStatus.Payment: return