@@ -8,10 +8,11 @@ import SessionAuth from "../session/sessionAuth";
88
99import { useRecipeComponentOverrideContext } from "./componentOverrideContext" ;
1010import { RecoverAccountUsingToken } from "./components/features/recoverAccountWithToken" ;
11+ import { SendRecoveryEmailForm } from "./components/features/sendRecoveryEmail" ;
1112import SignInWithPasskeyFeature from "./components/features/signIn" ;
1213import SignUpFeature , { SignUpWithPasskeyFeature } from "./components/features/signUp" ;
1314import { defaultTranslationsWebauthn } from "./components/themes/translations" ;
14- import { DEFAULT_WEBAUTHN_RECOVERY_PATH } from "./constants" ;
15+ import { DEFAULT_WEBAUTHN_RECOVERY_PATH , DEFAULT_WEBAUTHN_SEND_RECOVERY_EMAIL_PATH } from "./constants" ;
1516import WebauthnRecipe from "./recipe" ;
1617
1718import type { GenericComponentOverrideMap } from "../../components/componentOverride/componentOverrideContext" ;
@@ -46,7 +47,7 @@ export class WebauthnPreBuiltUI extends RecipeRouter {
4647 return WebauthnPreBuiltUI . getInstanceOrInitAndGetInstance ( ) . getFeatures ( useComponentOverrides ) ;
4748 }
4849 static getFeatureComponent (
49- componentName : "webauthn-recover-account" ,
50+ componentName : "webauthn-recover-account" | "webauthn-send-recovery-email" ,
5051 props : FeatureBaseProps < { userContext ?: UserContext } > ,
5152 useComponentOverrides : ( ) => GenericComponentOverrideMap < any > = useRecipeComponentOverrideContext
5253 ) : JSX . Element {
@@ -72,12 +73,23 @@ export class WebauthnPreBuiltUI extends RecipeRouter {
7273 this . getFeatureComponent ( "webauthn-recover-account" , props , useComponentOverrides ) ,
7374 recipeID : WebauthnRecipe . RECIPE_ID ,
7475 } ;
76+
77+ const normalisedFullPathForRecoveryThroughEmail =
78+ this . recipeInstance . config . appInfo . websiteBasePath . appendPath (
79+ new NormalisedURLPath ( DEFAULT_WEBAUTHN_SEND_RECOVERY_EMAIL_PATH )
80+ ) ;
81+ features [ normalisedFullPathForRecoveryThroughEmail . getAsStringDangerous ( ) ] = {
82+ matches : matchRecipeIdUsingQueryParams ( this . recipeInstance . config . recipeId ) ,
83+ component : ( props : any ) =>
84+ this . getFeatureComponent ( "webauthn-send-recovery-email" , props , useComponentOverrides ) ,
85+ recipeID : WebauthnRecipe . RECIPE_ID ,
86+ } ;
7587 }
7688 return features ;
7789 } ;
7890
7991 getFeatureComponent = (
80- componentName : "webauthn-recover-account" ,
92+ componentName : "webauthn-recover-account" | "webauthn-send-recovery-email" ,
8193 props : FeatureBaseProps < { userContext ?: UserContext } > ,
8294 useComponentOverrides : ( ) => GenericComponentOverrideMap < any > = useRecipeComponentOverrideContext
8395 ) : JSX . Element => {
@@ -93,6 +105,18 @@ export class WebauthnPreBuiltUI extends RecipeRouter {
93105 </ SessionAuth >
94106 </ UserContextWrapper >
95107 ) ;
108+ } else if ( componentName === "webauthn-send-recovery-email" ) {
109+ return (
110+ < UserContextWrapper userContext = { props . userContext } >
111+ < SessionAuth requireAuth = { false } doRedirection = { false } >
112+ < SendRecoveryEmailForm
113+ recipe = { this . recipeInstance }
114+ { ...props }
115+ useComponentOverrides = { useComponentOverrides }
116+ />
117+ </ SessionAuth >
118+ </ UserContextWrapper >
119+ ) ;
96120 }
97121 throw new Error ( "Should never come here." ) ;
98122 } ;
0 commit comments