diff --git a/examples/for-tests/src/App.js b/examples/for-tests/src/App.js index 782e4b000..966ecf2ef 100644 --- a/examples/for-tests/src/App.js +++ b/examples/for-tests/src/App.js @@ -368,9 +368,7 @@ window.resetTOTP = () => { tryCount = 0; }; let recipeList = [ - TOTP.init({ - override: {}, - }), + TOTP.init(), MultiFactorAuth.init({ firstFactors: testContext.firstFactors, }), diff --git a/lib/build/multifactorauth-shared.js b/lib/build/multifactorauth-shared.js index 8832912d9..eb4c9ac84 100644 --- a/lib/build/multifactorauth-shared.js +++ b/lib/build/multifactorauth-shared.js @@ -276,7 +276,7 @@ var MultiFactorAuth = /** @class */ (function (_super) { }; MultiFactorAuth.getInstanceOrThrow = function () { if (MultiFactorAuth.instance === undefined) { - var error = "No instance of EmailVerification found. Make sure to call the EmailVerification.init method."; + var error = "No instance of MultiFactorAuth found. Make sure to call the MultiFactorAuth.init method."; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { error = error + genericComponentOverrideContext.SSR_ERROR; diff --git a/lib/build/recipe/totp/components/themes/mfa/retryButton.d.ts b/lib/build/recipe/totp/components/themes/mfa/retryButton.d.ts index 1c4898840..0da6902e4 100644 --- a/lib/build/recipe/totp/components/themes/mfa/retryButton.d.ts +++ b/lib/build/recipe/totp/components/themes/mfa/retryButton.d.ts @@ -1,5 +1,5 @@ import React from "react"; -export declare const RetryButton: React.ComponentType<{ +export declare const RetryButton: React.FC<{ nextRetryAt: number; onClick: () => void; }>; diff --git a/lib/build/recipe/totp/components/themes/mfa/totpDeviceInfoSection.d.ts b/lib/build/recipe/totp/components/themes/mfa/totpDeviceInfoSection.d.ts index 797dd94e6..913a49ee7 100644 --- a/lib/build/recipe/totp/components/themes/mfa/totpDeviceInfoSection.d.ts +++ b/lib/build/recipe/totp/components/themes/mfa/totpDeviceInfoSection.d.ts @@ -5,6 +5,6 @@ export declare const DeviceInfoSection: import("react").ComponentType< TOTPMFACommonProps & { deviceInfo: DeviceInfo; showSecret: boolean; - onShowSecretClick: () => void; + onShowSecretClicked: () => void; } >; diff --git a/lib/build/recipe/totp/types.d.ts b/lib/build/recipe/totp/types.d.ts index a10f3d95e..5729be5cc 100644 --- a/lib/build/recipe/totp/types.d.ts +++ b/lib/build/recipe/totp/types.d.ts @@ -88,7 +88,7 @@ export declare type TOTPMFAProps = { recipeImplementation: RecipeInterface; config: NormalisedConfig; onSuccess: () => void; - onShowSecretClick: () => void; + onShowSecretClicked: () => void; onBackButtonClicked: () => void; onRetryClicked: () => void; onFactorChooserButtonClicked: () => void; diff --git a/lib/build/totp-shared.js b/lib/build/totp-shared.js index 4ce9b039e..59d371d01 100644 --- a/lib/build/totp-shared.js +++ b/lib/build/totp-shared.js @@ -238,7 +238,7 @@ var TOTP = /** @class */ (function (_super) { }; TOTP.getInstanceOrThrow = function () { if (TOTP.instance === undefined) { - var error = "No instance of EmailVerification found. Make sure to call the EmailVerification.init method."; + var error = "No instance of TOTP found. Make sure to call the TOTP.init method."; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { error = error + genericComponentOverrideContext.SSR_ERROR; diff --git a/lib/build/totpprebuiltui.js b/lib/build/totpprebuiltui.js index 2dcddd280..8ec5b5b02 100644 --- a/lib/build/totpprebuiltui.js +++ b/lib/build/totpprebuiltui.js @@ -115,7 +115,7 @@ var BlockedIcon = function () { ); }; -var RetryButton = uiEntry.withOverride("TOTPRetryButton", function TOTPRetryButton(_a) { +var RetryButton = function (_a) { var nextRetryAt = _a.nextRetryAt, onClick = _a.onClick; var t = translationContext.useTranslation(); @@ -177,7 +177,7 @@ var RetryButton = uiEntry.withOverride("TOTPRetryButton", function TOTPRetryButt } ) ); -}); +}; var TOTPBlockedScreen = function (props) { var t = translationContext.useTranslation(); @@ -3394,7 +3394,7 @@ var DeviceInfoSection = uiEntry.withOverride("TOTPDeviceInfoSection", function T genericComponentOverrideContext.__assign( { type: "button", - onClick: props.onShowSecretClick, + onClick: props.onShowSecretClicked, "data-supertokens": "link linkButton showTOTPSecretBtn", }, { children: t("TOTP_SHOW_SECRET_LINK") } @@ -3572,7 +3572,7 @@ var TOTPMFATheme = function (_a) { genericComponentOverrideContext.__assign({}, commonProps, { deviceInfo: featureState.deviceInfo, showSecret: featureState.showSecret, - onShowSecretClick: props.onShowSecretClick, + onShowSecretClicked: props.onShowSecretClicked, }) ), featureState.error !== undefined && @@ -3928,7 +3928,7 @@ function useChildProps(recipe$2, recipeImplementation, state, dispatch, userCont return React.useMemo( function () { return { - onShowSecretClick: function () { + onShowSecretClicked: function () { dispatch({ type: "showSecret" }); }, onBackButtonClicked: function () { diff --git a/lib/ts/recipe/multifactorauth/recipe.tsx b/lib/ts/recipe/multifactorauth/recipe.tsx index 58a80806c..a7bb5ceae 100644 --- a/lib/ts/recipe/multifactorauth/recipe.tsx +++ b/lib/ts/recipe/multifactorauth/recipe.tsx @@ -115,7 +115,7 @@ export default class MultiFactorAuth extends RecipeModule< static getInstanceOrThrow(): MultiFactorAuth { if (MultiFactorAuth.instance === undefined) { - let error = "No instance of EmailVerification found. Make sure to call the EmailVerification.init method."; + let error = "No instance of MultiFactorAuth found. Make sure to call the MultiFactorAuth.init method."; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { diff --git a/lib/ts/recipe/totp/components/features/mfa/index.tsx b/lib/ts/recipe/totp/components/features/mfa/index.tsx index 475bc2952..75dddc43c 100644 --- a/lib/ts/recipe/totp/components/features/mfa/index.tsx +++ b/lib/ts/recipe/totp/components/features/mfa/index.tsx @@ -220,7 +220,7 @@ export function useChildProps( return useMemo(() => { return { - onShowSecretClick: () => { + onShowSecretClicked: () => { dispatch({ type: "showSecret" }); }, onBackButtonClicked: async () => { diff --git a/lib/ts/recipe/totp/components/themes/mfa/index.tsx b/lib/ts/recipe/totp/components/themes/mfa/index.tsx index 54792b863..e36a1abdd 100644 --- a/lib/ts/recipe/totp/components/themes/mfa/index.tsx +++ b/lib/ts/recipe/totp/components/themes/mfa/index.tsx @@ -89,7 +89,7 @@ const TOTPMFATheme: React.FC = {...commonProps} deviceInfo={featureState.deviceInfo!} showSecret={featureState.showSecret} - onShowSecretClick={props.onShowSecretClick} + onShowSecretClicked={props.onShowSecretClicked} /> )} {featureState.error !== undefined && ( diff --git a/lib/ts/recipe/totp/components/themes/mfa/retryButton.tsx b/lib/ts/recipe/totp/components/themes/mfa/retryButton.tsx index 74286dccf..619964097 100644 --- a/lib/ts/recipe/totp/components/themes/mfa/retryButton.tsx +++ b/lib/ts/recipe/totp/components/themes/mfa/retryButton.tsx @@ -19,66 +19,59 @@ import React, { useCallback, useEffect, useState } from "react"; -import { withOverride } from "../../../../../components/componentOverride/withOverride"; import { useTranslation } from "../../../../../translation/translationContext"; -export const RetryButton = withOverride( - "TOTPRetryButton", - function TOTPRetryButton({ - nextRetryAt, - onClick, - }: { - nextRetryAt: number; - onClick: () => void; - }): JSX.Element | null { - const t = useTranslation(); +export const RetryButton: React.FC<{ + nextRetryAt: number; + onClick: () => void; +}> = ({ nextRetryAt, onClick }) => { + const t = useTranslation(); - const getTimeLeft = useCallback(() => { - const timeLeft = nextRetryAt - Date.now(); - return timeLeft < 0 ? undefined : Math.ceil(timeLeft / 1000); - }, [nextRetryAt]); + const getTimeLeft = useCallback(() => { + const timeLeft = nextRetryAt - Date.now(); + return timeLeft < 0 ? undefined : Math.ceil(timeLeft / 1000); + }, [nextRetryAt]); - const [secsUntilRetry, setSecsUntilRetry] = useState(getTimeLeft()); + const [secsUntilRetry, setSecsUntilRetry] = useState(getTimeLeft()); - useEffect(() => { - // This runs every time the loginAttemptInfo updates, so after every resend - const interval = setInterval(() => { - const timeLeft = getTimeLeft(); + useEffect(() => { + // This runs every time the loginAttemptInfo updates, so after every resend + const interval = setInterval(() => { + const timeLeft = getTimeLeft(); - if (timeLeft === undefined) { - clearInterval(interval); - } + if (timeLeft === undefined) { + clearInterval(interval); + } - setSecsUntilRetry(timeLeft); - }, 500); + setSecsUntilRetry(timeLeft); + }, 500); - return () => { - // This can safely run twice - clearInterval(interval); - }; - }, [getTimeLeft, setSecsUntilRetry]); + return () => { + // This can safely run twice + clearInterval(interval); + }; + }, [getTimeLeft, setSecsUntilRetry]); - return ( - - ); - } -); + return ( + + ); +}; diff --git a/lib/ts/recipe/totp/components/themes/mfa/totpDeviceInfoSection.tsx b/lib/ts/recipe/totp/components/themes/mfa/totpDeviceInfoSection.tsx index 324968533..23d208ae3 100644 --- a/lib/ts/recipe/totp/components/themes/mfa/totpDeviceInfoSection.tsx +++ b/lib/ts/recipe/totp/components/themes/mfa/totpDeviceInfoSection.tsx @@ -27,7 +27,7 @@ export const DeviceInfoSection = withOverride( props: TOTPMFACommonProps & { deviceInfo: DeviceInfo; showSecret: boolean; - onShowSecretClick: () => void; + onShowSecretClicked: () => void; } ): JSX.Element { const t = useTranslation(); @@ -40,7 +40,7 @@ export const DeviceInfoSection = withOverride( {t("TOTP_SHOW_SECRET_START")} diff --git a/lib/ts/recipe/totp/recipe.tsx b/lib/ts/recipe/totp/recipe.tsx index 0973c70cb..da3dd1aa0 100644 --- a/lib/ts/recipe/totp/recipe.tsx +++ b/lib/ts/recipe/totp/recipe.tsx @@ -120,7 +120,7 @@ export default class TOTP extends RecipeModule< static getInstanceOrThrow(): TOTP { if (TOTP.instance === undefined) { - let error = "No instance of EmailVerification found. Make sure to call the EmailVerification.init method."; + let error = "No instance of TOTP found. Make sure to call the TOTP.init method."; // eslint-disable-next-line supertokens-auth-react/no-direct-window-object if (typeof window === "undefined") { diff --git a/lib/ts/recipe/totp/types.ts b/lib/ts/recipe/totp/types.ts index 3a8b9ad4e..ce0c20579 100644 --- a/lib/ts/recipe/totp/types.ts +++ b/lib/ts/recipe/totp/types.ts @@ -109,7 +109,7 @@ export type TOTPMFAProps = { recipeImplementation: RecipeInterface; config: NormalisedConfig; onSuccess: () => void; - onShowSecretClick: () => void; + onShowSecretClicked: () => void; onBackButtonClicked: () => void; onRetryClicked: () => void; onFactorChooserButtonClicked: () => void;