commit 051704d0d9b3a7e921c91a559e65c79a31f3fdc5
parent 814fa3f7f315b33c278100f2493506aad9a87dc8
Author: Florian Dold <florian@dold.me>
Date: Sun, 23 Aug 2026 10:43:17 +0200
eliminate dead code
Diffstat:
2 files changed, 0 insertions(+), 122 deletions(-)
diff --git a/packages/web-util/src/hooks/index.ts b/packages/web-util/src/hooks/index.ts
@@ -18,7 +18,6 @@ export {
} from "./useForm.js";
export { useRenderErrorReport } from "./errors.js";
export { useLang } from "./useLang.js";
-export { useChallengeHandler, MfaHandler, MfaState } from "./useChallenge.js";
export {
buildStorageKey,
StorageKey,
diff --git a/packages/web-util/src/hooks/useChallenge.ts b/packages/web-util/src/hooks/useChallenge.ts
@@ -1,121 +0,0 @@
-/*
- This file is part of GNU Taler
- (C) 2021-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/>
- */
-/**
- *
- * @author Sebastian Javier Marchano (sebasjm)
- */
-
-import {
- Challenge,
- ChallengeRequestResponse,
- ChallengeResponse,
-} from "@gnu-taler/taler-util";
-import { useState } from "preact/hooks";
-import { SafeHandler } from "./useNotifications.js";
-
-/**
- * State of the current MFA operation and handler to manage
- * the state and retry.
- *
- */
-export interface MfaState {
- onChallengeRequired: (
- c: ChallengeResponse,
- repeat: SafeHandler<[ids: string[]], unknown>,
- ) => void;
-
- onChallengeRequiredWithInitial: (
- c: ChallengeResponse,
- initial: { request: Challenge; response: ChallengeRequestResponse },
- repeat: SafeHandler<[ids: string[]], unknown>,
- ) => void;
-
- /**
- * Cancel the current pending challenge.
- *
- * @returns
- */
- doCancelChallenge: () => void;
-
- /**
- * If a mfa has been started this will contain
- * the challenge response.
- */
- pendingChallenge:
- | undefined
- | {
- response: ChallengeResponse;
- repeatCall: SafeHandler<[string[]], unknown>;
- initial?: { request: Challenge; response: ChallengeRequestResponse };
- };
-}
-
-/**
- * Handler to be used by the function performing the MFA
- * guarded operation
- */
-export interface MfaHandler {
- /**
- * Callback handler to use when the operation fails with MFA required
- * @param challenge
- * @param params
- * @returns
- */
- onChallengeRequired: (challenge: ChallengeResponse, ...params: any[]) => void;
- /**
- * Challenges that are already solved and can be used for the operation.
- * If this is undefined it may mean that it is the first call.
- */
- ids: string[] | undefined;
-}
-
-/**
- *
- * @returns
- */
-export function useChallengeHandler(): MfaState {
- const [state, setState] = useState<{
- response: ChallengeResponse;
- repeatCall: SafeHandler<[string[]], unknown>;
- initial?: { request: Challenge; response: ChallengeRequestResponse };
- }>();
-
- function reset() {
- setState(undefined);
- }
-
- function onChallengeRequired(
- response: ChallengeResponse,
- repeatCall: SafeHandler<[string[]], any>,
- ) {
- setState({ response, initial: undefined, repeatCall });
- }
- function onChallengeRequiredWithInitial(
- response: ChallengeResponse,
- initial: { request: Challenge; response: ChallengeRequestResponse },
- repeatCall: SafeHandler<[string[]], any>,
- ) {
- setState({ response, initial, repeatCall });
- }
-
- return {
- doCancelChallenge: reset,
- onChallengeRequired,
- onChallengeRequiredWithInitial,
-
- pendingChallenge: state,
- };
-}