Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mfa)!: add mfa and totp recipes #780

Merged
merged 164 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 129 commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
26d1e48
chore: update to mfa branch of web-js
porcellus Oct 12, 2023
db3be18
feat: mfa recipe setup
porcellus Oct 13, 2023
8b339a4
feat: add support for firstFactor
porcellus Oct 13, 2023
02429f8
fix: fix chooseComponentBasedOnFirstFactors to properly get the max c…
porcellus Oct 15, 2023
f3c955e
feat: navigation based on claim validation failures
porcellus Oct 16, 2023
8932a0e
feat: implement factor chooser screen
porcellus Oct 16, 2023
ad99b5f
feat: factor chooser fixes and updates
porcellus Oct 19, 2023
083e908
feat: update pwless to support otp based mfa
porcellus Oct 19, 2023
f7c710b
feat: initial impl of totp mfa
porcellus Oct 22, 2023
9174480
feat: export totp bundle
porcellus Oct 25, 2023
f9b13c3
feat: finish TOTP + test setup WIP
porcellus Oct 26, 2023
9b8e063
feat: finish TOTP + test setup WIP
porcellus Oct 26, 2023
e61dd45
feat: add back button to factor chooser and filter the options
porcellus Oct 30, 2023
1114c60
Merge remote-tracking branch 'origin/feat/mfa/recipe-setup' into feat…
porcellus Oct 30, 2023
b589515
feat: update how back buttons are styled
porcellus Oct 30, 2023
85b1c4d
test: update how back button is selected in tests
porcellus Oct 30, 2023
4b1bd32
Merge remote-tracking branch 'origin/feat/mfa/recipe-setup' into feat…
porcellus Oct 30, 2023
3dd7c52
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Oct 30, 2023
f17de3a
feat: finishing totp initial impl
porcellus Oct 30, 2023
b8b3e3c
test: initial test for MFA
porcellus Oct 30, 2023
a9ce3b5
feat: self-review fixes & updates
porcellus Oct 31, 2023
c62fd92
Merge branch 'feat/mfa/recipe-setup' into feat/mfa/otp
porcellus Oct 31, 2023
fa3d6d5
feat: self-review fixes&cleanup
porcellus Oct 31, 2023
068d687
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Oct 31, 2023
ca49aee
feat: self-review fixes&cleanup
porcellus Oct 31, 2023
ce5e615
Merge branch 'feat/mfa/totp' into feat/mfa/tests
porcellus Oct 31, 2023
c11f185
test: add firstFactors tests
porcellus Oct 31, 2023
acfecc8
tests: complete initial test-set of MFA
porcellus Nov 6, 2023
3deb3cd
fix: firstFactors + test helpers
porcellus Nov 6, 2023
9653c1b
Merge branch 'feat/mfa/recipe-setup' into feat/mfa/otp
porcellus Nov 6, 2023
8e231ae
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Nov 6, 2023
6b84340
fix: small test based fixes
porcellus Nov 6, 2023
8129ef0
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Nov 6, 2023
1ec993a
feat: finishing touches
porcellus Nov 6, 2023
3f48569
Merge branch 'feat/mfa/totp' into feat/mfa/tests
porcellus Nov 6, 2023
7ead9c6
test: update first factor tests to match new behaviour w/ extra checks
porcellus Nov 7, 2023
7355f50
feat: clean up first factor handling
porcellus Nov 7, 2023
e66c584
Merge branch 'feat/mfa/recipe-setup' into feat/mfa/otp
porcellus Nov 7, 2023
61da851
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Nov 7, 2023
0b2b35e
Merge branch 'feat/mfa/totp' into feat/mfa/tests
porcellus Nov 7, 2023
1da8517
feat: add retry info to verifyCode/Device
porcellus Nov 9, 2023
fb89c18
refactor: rename passwordlessFirstFactors since it's not only first f…
porcellus Nov 9, 2023
23e6a46
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Nov 9, 2023
f159c84
Merge branch 'feat/mfa/totp' into feat/mfa/tests
porcellus Nov 9, 2023
792316b
feat: self-review fixes
porcellus Nov 9, 2023
f45271c
chore: add mfa ui to size limits
porcellus Nov 9, 2023
1990358
refactor: remove updates that will be added in other PRs + simplifica…
porcellus Nov 9, 2023
666d3fb
Merge branch 'feat/mfa/recipe-setup' into feat/mfa/otp
porcellus Nov 9, 2023
5ad586e
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Nov 9, 2023
8b44d6b
Merge branch 'feat/mfa/totp' into feat/mfa/tests
porcellus Nov 9, 2023
60e0cbb
test: clean up
porcellus Nov 9, 2023
46ae327
chore: increase size limits
porcellus Nov 9, 2023
150c9ad
test: add reset method to mfa recipe
porcellus Nov 9, 2023
b1203cf
Merge branch 'feat/mfa/recipe-setup' into feat/mfa/otp
porcellus Nov 9, 2023
897f900
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Nov 9, 2023
ba6621e
Merge branch 'feat/mfa/totp' into feat/mfa/tests
porcellus Nov 9, 2023
907930e
feat: make sure firstFactor conflicts hit user error boundaries
porcellus Nov 13, 2023
fbd63e4
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Nov 13, 2023
ae7ee82
Merge branch 'feat/mfa/totp' into feat/mfa/tests
porcellus Nov 13, 2023
f84d9b8
feat: update design and fix font-weight issues
porcellus Nov 15, 2023
ea768d1
chore: update web-js dep
porcellus Nov 15, 2023
a9b010f
Merge branch 'feat/mfa/recipe-setup' into feat/mfa/otp
porcellus Nov 15, 2023
598be73
feat: update design
porcellus Nov 15, 2023
a774c13
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Nov 15, 2023
be04faa
feat: update design
porcellus Nov 15, 2023
d1f615f
Merge branch 'feat/mfa/totp' into feat/mfa/tests
porcellus Nov 15, 2023
a4c0095
refactor: self-review fixes
porcellus Nov 16, 2023
b397c67
refactor: self-review fixes
porcellus Nov 16, 2023
69a2110
chore: update changelog
porcellus Nov 16, 2023
4ecfc27
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Nov 16, 2023
0d9ea8e
fix: revert unnecessary changes
porcellus Nov 16, 2023
abce472
feat: use redirect info if available on mfa success
porcellus Nov 16, 2023
00ee185
refactor: use redirectToFactor instead of re-implementing
porcellus Nov 16, 2023
7d8f419
Merge branch 'feat/mfa/recipe-setup' into feat/mfa/otp
porcellus Nov 16, 2023
95bd42f
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Nov 16, 2023
21dee6b
fix: add missing param into redirectToFactorChooser call
porcellus Nov 16, 2023
b520384
feat: self-review fixes
porcellus Nov 17, 2023
b483c83
chore: update changelog
porcellus Nov 17, 2023
51c7c4d
Merge branch 'feat/mfa/totp' into feat/mfa/tests
porcellus Nov 17, 2023
78c2a96
test: update tests for MFA
porcellus Nov 21, 2023
3082073
test: skip mock mfa tests until removal
porcellus Nov 21, 2023
7891b73
fix: override and routing fixes
porcellus Nov 21, 2023
da4ac03
Merge branch 'feat/mfa/recipe-setup' into feat/mfa/otp
porcellus Nov 21, 2023
8f35657
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Nov 21, 2023
405c419
Merge branch 'feat/mfa/tests' into feat/mfa/totp
porcellus Nov 21, 2023
9040500
test: update e2e test to work with an actual BE
porcellus Nov 27, 2023
ddc73be
fix: making sure async errors hit error boundaries + smaller test fixes
porcellus Dec 4, 2023
9d8fae1
feat: allow showing matching sub-recipe components if not on websiteb…
porcellus Dec 6, 2023
c0d686f
Merge branch 'feat/mfa/recipe-setup' into feat/mfa/otp
porcellus Dec 6, 2023
82aaef8
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Dec 6, 2023
758cca1
Merge branch 'feat/mfa/totp' into feat/mfa/tests
porcellus Dec 6, 2023
acf8ab8
fix: auth server test
sattvikc Dec 7, 2023
c42c397
feat: add the mfa recipe and basic support (#758)
porcellus Dec 10, 2023
2710ea5
test: ensure tests pass on older versions
porcellus Dec 10, 2023
07eb081
test: add missing case
porcellus Dec 10, 2023
fb74a61
Merge remote-tracking branch 'origin/feat/mfa/base' into feat/mfa/otp
porcellus Dec 10, 2023
ec913fb
fix: exposing mfa in tppwless + cleanup/refactor
porcellus Dec 10, 2023
4ce1591
Merge branch 'feat/mfa/otp' into feat/mfa/totp
porcellus Dec 10, 2023
0182e4b
Merge branch 'feat/mfa/totp' into feat/mfa/tests
porcellus Dec 10, 2023
4dcddb3
test: split up mfa tests into multiple files
porcellus Dec 10, 2023
153da40
feat: update passwordless to support OTP based MFA (#759)
porcellus Dec 10, 2023
2e81323
feat: totp recipe for MFA (#763)
porcellus Dec 11, 2023
457bfe4
Merge remote-tracking branch 'origin/feat/mfa/base' into feat/mfa/tests
porcellus Dec 11, 2023
bcba405
refactor: consistency fixes
porcellus Dec 11, 2023
1eb1505
docs: add storybook (#774)
porcellus Dec 11, 2023
c1f3a48
test: update tests to work w/ new BE behaviour
porcellus Dec 11, 2023
e865afc
fix: small self-review fixes
porcellus Dec 11, 2023
9a7a04e
fix: self-review fixes
porcellus Dec 11, 2023
e39c5ba
fix: add missing type to prebuiltuis
porcellus Dec 12, 2023
381124c
fix: fix console errors
porcellus Dec 12, 2023
ae18961
fix: small design and usability upgrades
porcellus Dec 14, 2023
322d83d
docs: update with-phone-password to use MFA
porcellus Dec 14, 2023
851b9b4
docs: remove 2fa examples and update the README to point to new mfa e…
porcellus Dec 14, 2023
a870d47
fix: add missing arg to redirectToFactorChooser
porcellus Dec 14, 2023
d9f812a
fix: add missing param
porcellus Dec 14, 2023
f75c9b3
fix: add missing param
porcellus Dec 14, 2023
fe49eb2
docs: add mfa example with recovery codes
porcellus Dec 15, 2023
5fe17b3
docs: save netlify-cli version in netlify example
porcellus Dec 15, 2023
677cdac
fix: mfa otp loading screen override
porcellus Dec 15, 2023
53ffd90
docs: add mfa-with-phone-chooser example
porcellus Dec 16, 2023
686e029
fix: remove duplicate type + rebuild
porcellus Dec 21, 2023
a40af42
Merge remote-tracking branch 'origin/0.36' into feat/mfa/tests
porcellus Dec 21, 2023
ce37fa0
refactor: removed unused state and related action/types
porcellus Dec 21, 2023
3892c1b
refactor: simplify impl
porcellus Dec 21, 2023
5b22bdd
refactor: make usage of FeatureBaseProps consistent
porcellus Dec 21, 2023
6e3b936
refactor: consistency updates
porcellus Dec 21, 2023
7a0810c
chore: remove unused test code
porcellus Dec 21, 2023
aaae5c3
feat(mfa): finish todo list (#782)
porcellus Dec 24, 2023
68d68c4
feat(mfa!): w1 discussions (#787)
porcellus Jan 16, 2024
5a4cbf1
feat(mfa): implement w2 discussion (#788)
porcellus Jan 19, 2024
bc63c93
chore: add storybook to npmignore
porcellus Jan 19, 2024
cac7f34
feat: implementing review comments
porcellus Jan 19, 2024
c8f8a28
fix: update how we decide when to show the back button
porcellus Jan 19, 2024
2c7fdd9
fix: remove !important from css styles (#791)
anku255 Jan 31, 2024
786ad44
feat: fix types and add newSessionCreated to redirect context
porcellus Feb 20, 2024
564d49f
feat: implementing review feedback + discussion
porcellus Feb 23, 2024
0a69e7e
feat: update getLoginMethod types and related logic
porcellus Feb 25, 2024
d0d807e
fix: test fixes
porcellus Feb 28, 2024
3642981
feat: expose FactorIds through the mfa recipe
porcellus Feb 28, 2024
5b7cd66
feat: add rid to success events
porcellus Feb 29, 2024
fd266e9
docs: update examples to newest API
porcellus Feb 29, 2024
5e87bad
Merge remote-tracking branch 'origin/0.37' into feat/mfa/base
porcellus Feb 29, 2024
8c41066
feat: redirect to the email verification page in case MFA requires it
porcellus Mar 3, 2024
4bc9f39
docs: update account-linking example
porcellus Mar 3, 2024
4eab9f5
docs: update recovery code example to separate the create recovery co…
porcellus Mar 3, 2024
c297519
docs: update example readmes and minor cleanup
porcellus Mar 3, 2024
71663e3
feat\!: rename isNewPrimaryUser to createdNewUser
porcellus Mar 4, 2024
83fcd62
Merge remote-tracking branch 'origin/0.38' into feat/mfa/base
porcellus Mar 6, 2024
3cedfbb
chore: update changelog and PR template checklist with review comments
porcellus Mar 6, 2024
00011ff
docs: add error codes to translation files
porcellus Mar 6, 2024
236c708
chore: move and update version requirements in changelog
porcellus Mar 6, 2024
1331987
chore: add factor id list update to pr checklist
porcellus Mar 7, 2024
f6812ab
docs: complete error code list in translation files
porcellus Mar 7, 2024
d217866
feat: add consistent fallbacks to every onFetchError
porcellus Mar 7, 2024
2eaaa1c
docs: removed example we will be splitting up
porcellus Mar 7, 2024
a4d7586
docs: implement review comments in examples and extend the changelog
porcellus Mar 7, 2024
b1bc1b9
docs: replace custom API with session based linking
porcellus Mar 8, 2024
8c787e4
docs: update examples to new interface
porcellus Mar 8, 2024
2d3410d
feat: update totp logo
porcellus Mar 11, 2024
25707c1
feat: update after web-js types changed
porcellus Mar 11, 2024
719bee9
fix: minor test fixes and updates
porcellus Mar 11, 2024
9d7ae89
chore: update size limits
porcellus Mar 11, 2024
b894004
docs: update examples
porcellus Mar 11, 2024
1b4e666
docs: rename updated phone-pw example to phone-pw-mfa and reset the p…
porcellus Mar 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 7 additions & 5 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"presets": [["@babel/preset-env", {}, "@babel/preset-react"]],
"plugins": [
"presets": [
"@babel/preset-env",
[
"@babel/plugin-transform-react-jsx",
"@babel/preset-typescript",
{
"pragmaFrag": "React.Fragment"
"allExtensions": true,
"isTSX": true
}
]
],
["@babel/preset-react", { "runtime": "automatic" }]
]
}
26 changes: 26 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { StorybookConfig } from "@storybook/react-webpack5";
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved
// import '@storybook/addon-console';

const config: StorybookConfig = {
stories: ["../stories/**/*.mdx", "../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
"@storybook/addon-essentials",
"@storybook/addon-actions",
"@storybook/addon-links",
"@storybook/addon-interactions",
"@storybook/addon-designs",
// "@storybook/addon-actions/register",
],
framework: {
name: "@storybook/react-webpack5",
options: {},
},
docs: {
autodocs: false,
},
env: {
REACT_APP_TEST_MODE: "testing",
TEST_MODE: "testing",
},
};
export default config;
16 changes: 16 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Preview } from "@storybook/react";

const preview: Preview = {
parameters: {
actions: { argTypesRegex: "^(w+.)*on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
boolean: /(is|show|loaded)/i,
},
},
},
};

export default preview;
54 changes: 54 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,60 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)

## [0.37.0] - 2023-12-XX

### Overview

#### Introducing MFA

With this release, we are introducing MultiFactorAuth and TOTP, this will let you:

- require (2FA or MFA) during sign in
- make use of our TOTP
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved

Check our [guide](https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/multi-factor-auth/overview) for more information.
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved

To use this you'll need compatible versions:

- Core>=8.0.0
- supertokens-node>=17.0.0 (support is pending in other backend SDKs)
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved
- supertokens-website>=17.0.3
- supertokens-web-js>=0.9.0
- supertokens-auth-react>=0.36.0

### Changes
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved

- Added support for FDI 1.19 (Node SDK>= 17.0.0), but keeping support FDI version 1.17 and 1.18 (node >= 15.0.0, golang>=0.13, python>=0.15.0)
- Added `firstFactors` into the return type of `getLoginMethods`
- Added the `MultiFactorAuth` recipe
- Updated how we select which login UI to show to take the `firstFactors` config value into account (defined in the `MultiFactorAuth` recipe or in the tenant information)
- Refactored/renamed some styling options (`resetPasswordHeaderTitle` -> `headerTitle withBackButton`)
- Added a `useShadowDom` prop to the `AccessDeniedScreen`
- Added an `error` prop to the `AccessDeniedScreen` that can be used to describe the reason access is denied.
- Added new MFA related components to Passwordless
- Added new prop `mfaFeature` to recipe config
- `disableDefaultUI`: can be used to disable paths: `${websiteBasePath}/mfa/otp-phone`, `${websiteBasePath}/mfa/otp-email`
- `style`: is applied on top of normal sign in/up styles on the MFA paths
- New embeddable components:
- `MfaOtpPhone` (by default handling path `${websiteBasePath}/mfa/otp-phone`)
- `MfaOtpEmail` (by default handling path `${websiteBasePath}/mfa/otp-email`)
- New overrideable components:
- `PasswordlessMFAHeader_Override`
- `PasswordlessMFAFooter_Override`
- `PasswordlessMFAOTPHeader_Override`
- `PasswordlessMFAOTPFooter_Override`
- Please note, that during MFA we re-use the existing overrideable comps for the form section:
- `PasswordlessEmailForm_Override`
- `PasswordlessPhoneForm_Override`
- `PasswordlessEmailOrPhoneForm_Override`
- Removed an `ErrorBoundary` wrapping all our feature components to make sure all errors are properly catchable by the app
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved
- Added a `footer` prop to `EmailOrPhoneForm`, `EmailForm` and `PhoneForm` which is used to override the default sign in/up footers in case the component is for MFA
- The passwordless and thirdpartypasswordless sign in/up screens now respect the first configuration (defined in the `MultiFactorAuth` recipe or in the tenant information) when selecting the available contact methods.
- Added TOTP recipe. For more details please check our guide [here](TODO)
- Fixed a font loading issue, that caused apps using the default (Rubik) font to appear with the incorrect font weights
- Some default styling has changed related to how fonts/font-weights are applied
- Changed how `headerSubtitle` is styled in components: `EmailPasswordResetPasswordEmail`, `EmailPasswordSubmitNewPassword`, `EmailPasswordSignInHeader`, `EmailPasswordSignUpHeader`

## [0.36.1] - 2023-12-20

### Fixes
Expand Down
30 changes: 29 additions & 1 deletion examples/for-tests-react-16/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import ThirdPartyEmailPassword from "supertokens-auth-react/recipe/thirdpartyema
import ThirdPartyPasswordless from "supertokens-auth-react/recipe/thirdpartypasswordless";
import UserRoles from "supertokens-auth-react/recipe/userroles";
import Multitenancy from "supertokens-auth-react/recipe/multitenancy";
import MultiFactorAuth from "supertokens-auth-react/recipe/multifactorauth";
import TOTP from "supertokens-auth-react/recipe/totp";

import axios from "axios";
import { useSessionContext } from "supertokens-auth-react/recipe/session";
Expand Down Expand Up @@ -178,6 +180,7 @@ const formFields = [
const testContext = getTestContext();

let recipeList = [
TOTP.init(),
Multitenancy.init({
override: {
functions: (oI) => ({
Expand Down Expand Up @@ -221,7 +224,7 @@ let recipeList = [
return implementation.doesSessionExist(...args);
},
getAccessTokenPayloadSecurely(...args) {
log(`GET_JWT_PAYLOAD_SECURELY`);
// log(`GET_JWT_PAYLOAD_SECURELY`);
return implementation.getAccessTokenPayloadSecurely(...args);
},
getUserId(...args) {
Expand Down Expand Up @@ -270,6 +273,15 @@ if (enabledRecipes.includes("thirdpartypasswordless")) {
if (emailVerificationMode !== "OFF") {
recipeList.push(getEmailVerificationConfigs(testContext));
}

if (testContext.enableMFA) {
recipeList.push(
MultiFactorAuth.init({
firstFactors: testContext.firstFactors,
})
);
}

SuperTokens.init({
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
clientType: testContext.clientType,
Expand Down Expand Up @@ -491,6 +503,13 @@ export function DashboardHelper({ redirectOnLogout, ...props } = {}) {
</div>
<div className="session-context-userId">session context userID: {sessionContext.userId}</div>
<pre className="invalidClaims">{JSON.stringify(sessionContext.invalidClaims, undefined, 2)}</pre>
<a
className="goToFactorChooser"
onClick={() => {
return MultiFactorAuth.redirectToFactorChooser(true, undefined, props.history);
}}>
MFA chooser
</a>
</div>
);
}
Expand All @@ -509,6 +528,7 @@ function SessionInfoTable({ sessionInfo }) {

function getEmailVerificationConfigs({ disableDefaultUI }) {
return EmailVerification.init({
useShadowDom,
disableDefaultUI,
sendVerifyEmailScreen: {
style: theme,
Expand Down Expand Up @@ -769,6 +789,10 @@ function getThirdPartyPasswordlessConfigs({ staticProviderList, disableDefaultUI
disableDefaultUI,
style: theme.style,
},
mfaFeature: {
disableDefaultUI,
style: theme,
},
});
}

Expand Down Expand Up @@ -850,6 +874,10 @@ function getPasswordlessConfigs({ disableDefaultUI }) {
disableDefaultUI,
style: theme.style,
},
mfaFeature: {
disableDefaultUI,
style: theme,
},
});
}

Expand Down
12 changes: 10 additions & 2 deletions examples/for-tests-react-16/src/AppWithReactDomRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ import { EmailVerificationPreBuiltUI } from "supertokens-auth-react/recipe/email
import { EmailPasswordPreBuiltUI } from "supertokens-auth-react/recipe/emailpassword/prebuiltui";
import { PasswordlessPreBuiltUI } from "supertokens-auth-react/recipe/passwordless/prebuiltui";
import { ThirdPartyPreBuiltUI } from "supertokens-auth-react/recipe/thirdparty/prebuiltui";
import { MultiFactorAuthPreBuiltUI } from "supertokens-auth-react/recipe/multifactorauth/prebuiltui";
import { TOTPPreBuiltUI } from "supertokens-auth-react/recipe/totp/prebuiltui";
import { AccessDeniedScreen } from "supertokens-auth-react/recipe/session/prebuiltui";
import { getEnabledRecipes } from "./testContext";
import { getEnabledRecipes, getTestContext } from "./testContext";

function AppWithReactDomRouter(props) {
const context = getTestContext();
const enabledRecipes = getEnabledRecipes();
const emailVerificationMode = window.localStorage.getItem("mode") || "OFF";

let recipePreBuiltUIList = [];
let recipePreBuiltUIList = [TOTPPreBuiltUI];
if (enabledRecipes.includes("emailpassword")) {
recipePreBuiltUIList.push(EmailPasswordPreBuiltUI);
}
Expand All @@ -42,6 +45,11 @@ function AppWithReactDomRouter(props) {
if (emailVerificationMode !== "OFF") {
recipePreBuiltUIList.push(EmailVerificationPreBuiltUI);
}

if (context.enableMFA) {
recipePreBuiltUIList.push(MultiFactorAuthPreBuiltUI);
}

/**
* For user context tests we add this query param so the additional routes
* dont interfere with other tests
Expand Down
11 changes: 9 additions & 2 deletions examples/for-tests-react-16/src/AppWithReactDomRouterV5.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ import { EmailPasswordPreBuiltUI } from "supertokens-auth-react/recipe/emailpass
import { PasswordlessPreBuiltUI } from "supertokens-auth-react/recipe/passwordless/prebuiltui";
import { ThirdPartyPreBuiltUI } from "supertokens-auth-react/recipe/thirdparty/prebuiltui";
import { AccessDeniedScreen } from "supertokens-auth-react/recipe/session/prebuiltui";
import { getEnabledRecipes } from "./testContext";
import { MultiFactorAuthPreBuiltUI } from "supertokens-auth-react/recipe/multifactorauth/prebuiltui";
import { TOTPPreBuiltUI } from "supertokens-auth-react/recipe/totp/prebuiltui";
import { getEnabledRecipes, getTestContext } from "./testContext";

function AppWithReactDomRouter(props) {
const context = getTestContext();
const enabledRecipes = getEnabledRecipes();
const emailVerificationMode = window.localStorage.getItem("mode") || "OFF";

let recipePreBuiltUIList = [];
let recipePreBuiltUIList = [TOTPPreBuiltUI];
if (enabledRecipes.includes("emailpassword")) {
recipePreBuiltUIList.push(EmailPasswordPreBuiltUI);
}
Expand All @@ -38,6 +41,10 @@ function AppWithReactDomRouter(props) {
recipePreBuiltUIList.push(EmailVerificationPreBuiltUI);
}

if (context.enableMFA) {
recipePreBuiltUIList.push(MultiFactorAuthPreBuiltUI);
}

const websiteBasePath = window.localStorage.getItem("websiteBasePath") || undefined;

const [claimValidators, setClaimValidators] = useState(undefined);
Expand Down
36 changes: 24 additions & 12 deletions examples/for-tests-react-16/src/testContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ export function getTestContext() {
thirdPartyRedirectURL: localStorage.getItem("thirdPartyRedirectURL"),
authRecipe: window.localStorage.getItem("authRecipe") || "emailpassword",
usesDynamicLoginMethods: localStorage.getItem("usesDynamicLoginMethods") === "true",
enableAllRecipes: localStorage.getItem("enableAllRecipes") === "true",
clientRecipeListForDynamicLogin: localStorage.getItem("clientRecipeListForDynamicLogin"),
mockLoginMethodsForDynamicLogin: localStorage.getItem("mockLoginMethodsForDynamicLogin"),
staticProviderList: localStorage.getItem("staticProviderList"),
mockTenantId: localStorage.getItem("mockTenantId"),
clientType: localStorage.getItem("clientType") || undefined,
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved
firstFactors:
localStorage.getItem("firstFactors") !== null
? localStorage.getItem("firstFactors").split(", ")
: undefined,
enableMFA: localStorage.getItem("enableMFA") === "true",
disableRedirectionAfterSuccessfulSignInUp:
localStorage.getItem("disableRedirectionAfterSuccessfulSignInUp") === "true",
};
Expand All @@ -25,18 +31,24 @@ export function getEnabledRecipes() {

let enabledRecipes = [];

if (testContext.usesDynamicLoginMethods) {
if (testContext.clientRecipeListForDynamicLogin) {
enabledRecipes = JSON.parse(testContext.clientRecipeListForDynamicLogin);
} else {
enabledRecipes = [
"emailpassword",
"thirdparty",
"thirdpartyemailpassword",
"passwordless",
"thirdpartypasswordless",
];
}
if (testContext.enableAllRecipes) {
enabledRecipes = [
"emailpassword",
"thirdparty",
"thirdpartyemailpassword",
"passwordless",
"thirdpartypasswordless",
];
} else if (testContext.clientRecipeListForDynamicLogin) {
enabledRecipes = JSON.parse(testContext.clientRecipeListForDynamicLogin);
} else if (testContext.usesDynamicLoginMethods) {
enabledRecipes = [
"emailpassword",
"thirdparty",
"thirdpartyemailpassword",
"passwordless",
"thirdpartypasswordless",
];
} else {
if (testContext.authRecipe === "both") {
enabledRecipes.push("emailpassword", "thirdparty");
Expand Down
Loading
Loading