File tree Expand file tree Collapse file tree
packages/clerk-js/src/ui/components/UserVerification Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @clerk/clerk-js ' : patch
3+ ---
4+
5+ Filters out non supported strategies for reverification
Original file line number Diff line number Diff line change 1- import type { SignInFactor } from '@clerk/types' ;
1+ import type { SessionVerificationFirstFactor , SignInFactor } from '@clerk/types' ;
22import React , { useEffect , useMemo } from 'react' ;
33
44import { useEnvironment } from '../../contexts' ;
@@ -29,6 +29,13 @@ const factorKey = (factor: SignInFactor | null | undefined) => {
2929 return key ;
3030} ;
3131
32+ const SUPPORTED_STRATEGIES : SessionVerificationFirstFactor [ 'strategy' ] [ ] = [
33+ 'password' ,
34+ 'email_code' ,
35+ 'phone_code' ,
36+ 'passkey' ,
37+ ] as const ;
38+
3239export function UserVerificationFactorOneInternal ( ) : JSX . Element | null {
3340 const { data } = useUserVerificationSession ( ) ;
3441 const card = useCardState ( ) ;
@@ -39,7 +46,11 @@ export function UserVerificationFactorOneInternal(): JSX.Element | null {
3946 const sessionVerification = data ! ;
4047
4148 const availableFactors = useMemo ( ( ) => {
42- return sessionVerification . supportedFirstFactors ?. sort ( sortByPrimaryFactor ) || null ;
49+ return (
50+ sessionVerification . supportedFirstFactors
51+ ?. filter ( factor => SUPPORTED_STRATEGIES . includes ( factor . strategy ) )
52+ ?. sort ( sortByPrimaryFactor ) || null
53+ ) ;
4354 } , [ sessionVerification . supportedFirstFactors ] ) ;
4455 const { preferredSignInStrategy } = useEnvironment ( ) . displayConfig ;
4556
Original file line number Diff line number Diff line change @@ -23,13 +23,23 @@ const factorKey = (factor: SignInFactor | null | undefined) => {
2323 return key ;
2424} ;
2525
26+ const SUPPORTED_STRATEGIES : SessionVerificationSecondFactor [ 'strategy' ] [ ] = [
27+ 'phone_code' ,
28+ 'totp' ,
29+ 'backup_code' ,
30+ ] as const ;
31+
2632export function UserVerificationFactorTwoComponent ( ) : JSX . Element {
2733 const { navigate } = useRouter ( ) ;
2834 const { data } = useUserVerificationSession ( ) ;
2935 const sessionVerification = data as SessionVerificationResource ;
3036
3137 const availableFactors = useMemo ( ( ) => {
32- return sessionVerification . supportedSecondFactors ?. sort ( sortByPrimaryFactor ) || null ;
38+ return (
39+ sessionVerification . supportedSecondFactors
40+ ?. filter ( factor => SUPPORTED_STRATEGIES . includes ( factor . strategy ) )
41+ ?. sort ( sortByPrimaryFactor ) || null
42+ ) ;
3343 } , [ sessionVerification . supportedSecondFactors ] ) ;
3444
3545 const lastPreparedFactorKeyRef = React . useRef ( '' ) ;
You can’t perform that action at this time.
0 commit comments