-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
04a6d99
commit b7baba2
Showing
3 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { isTest } from "../../utils"; | ||
import { RecipeRouter } from "../recipeRouter"; | ||
|
||
import { useRecipeComponentOverrideContext } from "./componentOverrideContext"; | ||
import WebauthnRecipe from "./recipe"; | ||
|
||
import type { GenericComponentOverrideMap } from "../../components/componentOverride/componentOverrideContext"; | ||
import type { AuthComponent, RecipeFeatureComponentMap } from "../../types"; | ||
|
||
export class WebauthnPreBuiltUI extends RecipeRouter { | ||
static instance?: WebauthnPreBuiltUI; | ||
languageTranslations = { | ||
en: {}, | ||
}; | ||
|
||
constructor(public readonly recipeInstance: WebauthnRecipe) { | ||
super(); | ||
} | ||
|
||
// Static methods | ||
static getInstanceOrInitAndGetInstance(): WebauthnPreBuiltUI { | ||
if (WebauthnPreBuiltUI.instance === undefined) { | ||
const recipeInstance = WebauthnRecipe.getInstanceOrThrow(); | ||
WebauthnPreBuiltUI.instance = new WebauthnPreBuiltUI(recipeInstance); | ||
} | ||
|
||
return WebauthnPreBuiltUI.instance; | ||
} | ||
static getFeatures( | ||
useComponentOverrides: () => GenericComponentOverrideMap<any> = useRecipeComponentOverrideContext | ||
): RecipeFeatureComponentMap { | ||
return WebauthnPreBuiltUI.getInstanceOrInitAndGetInstance().getFeatures(useComponentOverrides); | ||
} | ||
static getFeatureComponent( | ||
componentName: "mfaWebauthn", | ||
props: any, | ||
useComponentOverrides: () => GenericComponentOverrideMap<any> = useRecipeComponentOverrideContext | ||
): JSX.Element { | ||
return WebauthnPreBuiltUI.getInstanceOrInitAndGetInstance().getFeatureComponent( | ||
componentName, | ||
props, | ||
useComponentOverrides | ||
); | ||
} | ||
|
||
// Instance methods | ||
getFeatures = ( | ||
useComponentOverrides: () => GenericComponentOverrideMap<any> = useRecipeComponentOverrideContext | ||
): RecipeFeatureComponentMap => { | ||
const features: RecipeFeatureComponentMap = {}; | ||
// TODO: Define after components are defined | ||
return features; | ||
}; | ||
|
||
getFeatureComponent = ( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
_: "mfaWebauthn", | ||
props: any, | ||
useComponentOverrides: () => GenericComponentOverrideMap<any> = useRecipeComponentOverrideContext | ||
): JSX.Element => { | ||
return <div></div>; | ||
}; | ||
|
||
getAuthComponents(): AuthComponent[] { | ||
return []; | ||
} | ||
|
||
// For tests | ||
static reset(): void { | ||
if (!isTest()) { | ||
return; | ||
} | ||
|
||
WebauthnPreBuiltUI.instance = undefined; | ||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters