1+ import NormalisedURLPath from "supertokens-web-js/lib/build/normalisedURLPath" ;
2+
13import UserContextWrapper from "../../usercontext/userContextWrapper" ;
2- import { isTest } from "../../utils" ;
4+ import { isTest , matchRecipeIdUsingQueryParams } from "../../utils" ;
35import { FactorIds } from "../multifactorauth" ;
46import { RecipeRouter } from "../recipeRouter" ;
57import SessionAuth from "../session/sessionAuth" ;
68
79import { useRecipeComponentOverrideContext } from "./componentOverrideContext" ;
10+ import { RecoverAccountUsingToken } from "./components/features/recoverAccountWithToken" ;
811import SignInWithPasskeyFeature from "./components/features/signIn" ;
912import SignUpFeature , { SignUpWithPasskeyFeature } from "./components/features/signUp" ;
1013import { defaultTranslationsWebauthn } from "./components/themes/translations" ;
14+ import { DEFAULT_WEBAUTHN_RECOVERY_PATH } from "./constants" ;
1115import WebauthnRecipe from "./recipe" ;
1216
1317import type { GenericComponentOverrideMap } from "../../components/componentOverride/componentOverrideContext" ;
@@ -42,7 +46,7 @@ export class WebauthnPreBuiltUI extends RecipeRouter {
4246 return WebauthnPreBuiltUI . getInstanceOrInitAndGetInstance ( ) . getFeatures ( useComponentOverrides ) ;
4347 }
4448 static getFeatureComponent (
45- componentName : "webauthn-sign-up " ,
49+ componentName : "webauthn-recover-account " ,
4650 props : FeatureBaseProps < { userContext ?: UserContext } > ,
4751 useComponentOverrides : ( ) => GenericComponentOverrideMap < any > = useRecipeComponentOverrideContext
4852 ) : JSX . Element {
@@ -55,23 +59,33 @@ export class WebauthnPreBuiltUI extends RecipeRouter {
5559
5660 // Instance methods
5761 getFeatures = (
58- _ : ( ) => GenericComponentOverrideMap < any > = useRecipeComponentOverrideContext
62+ useComponentOverrides : ( ) => GenericComponentOverrideMap < any > = useRecipeComponentOverrideContext
5963 ) : RecipeFeatureComponentMap => {
6064 const features : RecipeFeatureComponentMap = { } ;
61- // TODO: Define after components are defined
65+ if ( this . recipeInstance . config . disableDefaultUI !== true ) {
66+ const normalisedFullPath = this . recipeInstance . config . appInfo . websiteBasePath . appendPath (
67+ new NormalisedURLPath ( DEFAULT_WEBAUTHN_RECOVERY_PATH )
68+ ) ;
69+ features [ normalisedFullPath . getAsStringDangerous ( ) ] = {
70+ matches : matchRecipeIdUsingQueryParams ( this . recipeInstance . config . recipeId ) ,
71+ component : ( props : any ) =>
72+ this . getFeatureComponent ( "webauthn-recover-account" , props , useComponentOverrides ) ,
73+ recipeID : WebauthnRecipe . RECIPE_ID ,
74+ } ;
75+ }
6276 return features ;
6377 } ;
6478
6579 getFeatureComponent = (
66- componentName : "webauthn-sign-up " ,
80+ componentName : "webauthn-recover-account " ,
6781 props : FeatureBaseProps < { userContext ?: UserContext } > ,
6882 _ : ( ) => GenericComponentOverrideMap < any > = useRecipeComponentOverrideContext
6983 ) : JSX . Element => {
70- if ( componentName === "webauthn-sign-up " ) {
84+ if ( componentName === "webauthn-recover-account " ) {
7185 return (
7286 < UserContextWrapper userContext = { props . userContext } >
7387 < SessionAuth requireAuth = { false } doRedirection = { false } >
74- < div > </ div >
88+ < RecoverAccountUsingToken / >
7589 </ SessionAuth >
7690 </ UserContextWrapper >
7791 ) ;
0 commit comments