diff --git a/lib/build/emailpassword-shared4.js b/lib/build/emailpassword-shared4.js index e3070936a..86c050580 100644 --- a/lib/build/emailpassword-shared4.js +++ b/lib/build/emailpassword-shared4.js @@ -3,7 +3,9 @@ var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var EmailPasswordWebJS = require("supertokens-web-js/recipe/emailpassword"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); +var postSuperTokensInitCallbacks = require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); var utils = require("./authRecipe-shared.js"); +var recipe = require("./multifactorauth-shared.js"); var validators = require("./emailpassword-shared5.js"); function _interopDefault(e) { @@ -446,6 +448,12 @@ var EmailPassword = /** @class */ (function (_super) { }); }); }; + postSuperTokensInitCallbacks.PostSuperTokensInitCallbacks.addPostInitCallback(function () { + var mfa = recipe.MultiFactorAuth.getInstance(); + if (mfa !== undefined) { + mfa.addMFAFactors(["emailpassword"], []); + } + }); return _this; } EmailPassword.init = function (config) { diff --git a/lib/build/emailpassword.js b/lib/build/emailpassword.js index 54ade2cbb..efd4da4be 100644 --- a/lib/build/emailpassword.js +++ b/lib/build/emailpassword.js @@ -20,6 +20,9 @@ require("./authRecipe-shared.js"); require("./recipeModule-shared.js"); require("./session-shared2.js"); require("supertokens-web-js/recipe/session"); +require("./multifactorauth-shared.js"); +require("supertokens-web-js/recipe/multifactorauth"); +require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./emailpassword-shared5.js"); /* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. diff --git a/lib/build/index2.js b/lib/build/index2.js index 0bcc45e78..0f4076127 100644 --- a/lib/build/index2.js +++ b/lib/build/index2.js @@ -535,7 +535,8 @@ var RecipeRouter = /** @class */ (function () { if (componentMatchingRid) { return componentMatchingRid; } - if (mfaRecipe) { + // TODO: check if we need this whole defaultFirstFactors thing. + if (mfaRecipe && mfaRecipe.config.firstFactors !== undefined) { return chooseComponentBasedOnFirstFactors(mfaRecipe.getFirstFactors(), routeComponents); } else { return defaultComp; diff --git a/lib/build/multifactorauthprebuiltui.js b/lib/build/multifactorauthprebuiltui.js index 753794946..2cb2a2c3c 100644 --- a/lib/build/multifactorauthprebuiltui.js +++ b/lib/build/multifactorauthprebuiltui.js @@ -150,6 +150,7 @@ var FactorChooserHeader = uiEntry.withOverride( var FactorOption = uiEntry.withOverride("MultiFactorAuthFactorOption", function MultiFactorAuthFactorOption(_a) { var onClick = _a.onClick, + id = _a.id, name = _a.name, description = _a.description, logo = _a.logo; @@ -157,7 +158,7 @@ var FactorOption = uiEntry.withOverride("MultiFactorAuthFactorOption", function return jsxRuntime.jsxs( "a", genericComponentOverrideContext.__assign( - { "data-supertokens": "factorChooserOption", onClick: onClick }, + { "data-supertokens": "factorChooserOption ".concat(id), onClick: onClick }, { children: [ jsxRuntime.jsxs( @@ -209,6 +210,7 @@ var FactorList = uiEntry.withOverride("MultiFactorAuthFactorList", function Mult return jsxRuntime.jsx( FactorOption, { + id: factor.id, name: factor.name, description: factor.description, logo: factor.logo, @@ -228,7 +230,7 @@ function FactorChooserTheme(props) { var t = translationContext.useTranslation(); if (props.availableFactors.length === 0) { return jsxRuntime.jsx(sessionprebuiltui.AccessDeniedScreen, { - useShadowDom: props.config.useShadowDom, + useShadowDom: false, error: props.showBackButton ? t("MFA_NO_AVAILABLE_OPTIONS") : t("MFA_NO_AVAILABLE_OPTIONS_LOGIN"), }); } diff --git a/lib/build/recipe/multifactorauth/components/themes/factorChooser/factorOption.d.ts b/lib/build/recipe/multifactorauth/components/themes/factorChooser/factorOption.d.ts index 1802621c5..a22f99c92 100644 --- a/lib/build/recipe/multifactorauth/components/themes/factorChooser/factorOption.d.ts +++ b/lib/build/recipe/multifactorauth/components/themes/factorChooser/factorOption.d.ts @@ -1,6 +1,7 @@ import type { FC } from "react"; export declare const FactorOption: import("react").ComponentType<{ onClick: (() => void) | undefined; + id: string; name: string; description: string; logo: FC; diff --git a/lib/build/thirdparty-shared.js b/lib/build/thirdparty-shared.js index d88cf5dee..702b79231 100644 --- a/lib/build/thirdparty-shared.js +++ b/lib/build/thirdparty-shared.js @@ -2,7 +2,9 @@ var genericComponentOverrideContext = require("./genericComponentOverrideContext.js"); var ThirdpartyWebJS = require("supertokens-web-js/recipe/thirdparty"); +var postSuperTokensInitCallbacks = require("supertokens-web-js/utils/postSuperTokensInitCallbacks"); var utils = require("./authRecipe-shared.js"); +var recipe = require("./multifactorauth-shared.js"); var jsxRuntime = require("react/jsx-runtime"); var NormalisedURLPath = require("supertokens-web-js/utils/normalisedURLPath"); var translationContext = require("./translationContext.js"); @@ -1407,6 +1409,12 @@ var ThirdParty = /** @class */ (function (_super) { ) { throw new Error("ThirdParty signInAndUpFeature providers array cannot be empty."); } + postSuperTokensInitCallbacks.PostSuperTokensInitCallbacks.addPostInitCallback(function () { + var mfa = recipe.MultiFactorAuth.getInstance(); + if (mfa !== undefined) { + mfa.addMFAFactors(["thirdparty"], []); + } + }); _this = _super.call(this, config) || this; _this.webJSRecipe = webJSRecipe; _this.recipeID = ThirdParty.RECIPE_ID; diff --git a/lib/build/thirdparty.js b/lib/build/thirdparty.js index 39d78aa94..ab560710f 100644 --- a/lib/build/thirdparty.js +++ b/lib/build/thirdparty.js @@ -19,6 +19,9 @@ require("./authRecipe-shared.js"); require("./recipeModule-shared.js"); require("./session-shared2.js"); require("supertokens-web-js/recipe/session"); +require("./multifactorauth-shared.js"); +require("supertokens-web-js/recipe/multifactorauth"); +require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./translationContext.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); diff --git a/lib/build/thirdpartyemailpassword.js b/lib/build/thirdpartyemailpassword.js index def27b758..b1816806f 100644 --- a/lib/build/thirdpartyemailpassword.js +++ b/lib/build/thirdpartyemailpassword.js @@ -21,6 +21,9 @@ require("./authRecipe-shared.js"); require("./recipeModule-shared.js"); require("./session-shared2.js"); require("supertokens-web-js/recipe/session"); +require("./multifactorauth-shared.js"); +require("supertokens-web-js/recipe/multifactorauth"); +require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./translationContext.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); require("supertokens-web-js/recipe/thirdpartyemailpassword"); diff --git a/lib/build/thirdpartypasswordless.js b/lib/build/thirdpartypasswordless.js index 796cbe40c..db87e7729 100644 --- a/lib/build/thirdpartypasswordless.js +++ b/lib/build/thirdpartypasswordless.js @@ -21,14 +21,14 @@ require("./authRecipe-shared.js"); require("./recipeModule-shared.js"); require("./session-shared2.js"); require("supertokens-web-js/recipe/session"); +require("./multifactorauth-shared.js"); +require("supertokens-web-js/recipe/multifactorauth"); +require("supertokens-web-js/utils/sessionClaimValidatorStore"); require("./translationContext.js"); require("supertokens-web-js/lib/build/normalisedURLPath"); require("supertokens-web-js/recipe/thirdpartypasswordless"); require("./passwordless-shared2.js"); require("supertokens-web-js/recipe/passwordless"); -require("./multifactorauth-shared.js"); -require("supertokens-web-js/recipe/multifactorauth"); -require("supertokens-web-js/utils/sessionClaimValidatorStore"); var Wrapper = /** @class */ (function () { function Wrapper() {} diff --git a/lib/ts/recipe/emailpassword/recipe.tsx b/lib/ts/recipe/emailpassword/recipe.tsx index e48caf6d1..267ad67f3 100644 --- a/lib/ts/recipe/emailpassword/recipe.tsx +++ b/lib/ts/recipe/emailpassword/recipe.tsx @@ -19,10 +19,12 @@ import EmailPasswordWebJS from "supertokens-web-js/recipe/emailpassword"; import NormalisedURLPath from "supertokens-web-js/utils/normalisedURLPath"; +import { PostSuperTokensInitCallbacks } from "supertokens-web-js/utils/postSuperTokensInitCallbacks"; import { SSR_ERROR } from "../../constants"; import { isTest } from "../../utils"; import AuthRecipe from "../authRecipe"; +import MultiFactorAuth from "../multifactorauth/recipe"; import { DEFAULT_RESET_PASSWORD_PATH } from "./constants"; import { getFunctionOverrides } from "./functionOverrides"; @@ -58,6 +60,13 @@ export default class EmailPassword extends AuthRecipe< public readonly webJSRecipe: WebJSRecipeInterface = EmailPasswordWebJS ) { super(config); + + PostSuperTokensInitCallbacks.addPostInitCallback(() => { + const mfa = MultiFactorAuth.getInstance(); + if (mfa !== undefined) { + mfa.addMFAFactors(["emailpassword"], []); + } + }); } getDefaultRedirectionURL = async (context: GetRedirectionURLContext): Promise => { diff --git a/lib/ts/recipe/multifactorauth/components/themes/factorChooser/factorList.tsx b/lib/ts/recipe/multifactorauth/components/themes/factorChooser/factorList.tsx index 0a06de9f1..cbce96903 100644 --- a/lib/ts/recipe/multifactorauth/components/themes/factorChooser/factorList.tsx +++ b/lib/ts/recipe/multifactorauth/components/themes/factorChooser/factorList.tsx @@ -35,6 +35,7 @@ export const FactorList = withOverride( {availableFactors.map((factor) => ( void) | undefined; + id: string; name: string; description: string; logo: FC; }): JSX.Element { const t = useTranslation(); return ( - +
{logo({})}
{t(name)}
diff --git a/lib/ts/recipe/multifactorauth/components/themes/factorChooser/index.tsx b/lib/ts/recipe/multifactorauth/components/themes/factorChooser/index.tsx index 5e8483b52..8c1e7174e 100644 --- a/lib/ts/recipe/multifactorauth/components/themes/factorChooser/index.tsx +++ b/lib/ts/recipe/multifactorauth/components/themes/factorChooser/index.tsx @@ -31,7 +31,7 @@ export function FactorChooserTheme(props: FactorChooserThemeProps): JSX.Element if (props.availableFactors.length === 0) { return ( ); diff --git a/lib/ts/recipe/recipeRouter/index.tsx b/lib/ts/recipe/recipeRouter/index.tsx index 9ece4880b..b9065329b 100644 --- a/lib/ts/recipe/recipeRouter/index.tsx +++ b/lib/ts/recipe/recipeRouter/index.tsx @@ -124,7 +124,8 @@ export abstract class RecipeRouter { return componentMatchingRid; } - if (mfaRecipe) { + // TODO: check if we need this whole defaultFirstFactors thing. + if (mfaRecipe && mfaRecipe.config.firstFactors !== undefined) { return chooseComponentBasedOnFirstFactors(mfaRecipe.getFirstFactors(), routeComponents); } else { return defaultComp; diff --git a/lib/ts/recipe/thirdparty/recipe.tsx b/lib/ts/recipe/thirdparty/recipe.tsx index 556700003..bc31e6114 100644 --- a/lib/ts/recipe/thirdparty/recipe.tsx +++ b/lib/ts/recipe/thirdparty/recipe.tsx @@ -18,11 +18,13 @@ */ import ThirdpartyWebJS from "supertokens-web-js/recipe/thirdparty"; +import { PostSuperTokensInitCallbacks } from "supertokens-web-js/utils/postSuperTokensInitCallbacks"; import { SSR_ERROR } from "../../constants"; import SuperTokens from "../../superTokens"; import { isTest } from "../../utils"; import AuthRecipe from "../authRecipe"; +import MultiFactorAuth from "../multifactorauth/recipe"; import { getFunctionOverrides } from "./functionOverrides"; import { normaliseThirdPartyConfig } from "./utils"; @@ -58,6 +60,14 @@ export default class ThirdParty extends AuthRecipe< if (SuperTokens.usesDynamicLoginMethods === false && config.signInAndUpFeature.providers.length === 0) { throw new Error("ThirdParty signInAndUpFeature providers array cannot be empty."); } + + PostSuperTokensInitCallbacks.addPostInitCallback(() => { + const mfa = MultiFactorAuth.getInstance(); + if (mfa !== undefined) { + mfa.addMFAFactors(["thirdparty"], []); + } + }); + super(config); }