File tree 3 files changed +29
-3
lines changed
packages/clerk-js/src/ui/components/UserVerification
3 files changed +29
-3
lines changed 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' ;
2
2
import React , { useEffect , useMemo } from 'react' ;
3
3
4
4
import { useEnvironment } from '../../contexts' ;
@@ -29,6 +29,13 @@ const factorKey = (factor: SignInFactor | null | undefined) => {
29
29
return key ;
30
30
} ;
31
31
32
+ const SUPPORTED_STRATEGIES : SessionVerificationFirstFactor [ 'strategy' ] [ ] = [
33
+ 'password' ,
34
+ 'email_code' ,
35
+ 'phone_code' ,
36
+ 'passkey' ,
37
+ ] as const ;
38
+
32
39
export function UserVerificationFactorOneInternal ( ) : JSX . Element | null {
33
40
const { data } = useUserVerificationSession ( ) ;
34
41
const card = useCardState ( ) ;
@@ -39,7 +46,11 @@ export function UserVerificationFactorOneInternal(): JSX.Element | null {
39
46
const sessionVerification = data ! ;
40
47
41
48
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
+ ) ;
43
54
} , [ sessionVerification . supportedFirstFactors ] ) ;
44
55
const { preferredSignInStrategy } = useEnvironment ( ) . displayConfig ;
45
56
Original file line number Diff line number Diff line change @@ -23,13 +23,23 @@ const factorKey = (factor: SignInFactor | null | undefined) => {
23
23
return key ;
24
24
} ;
25
25
26
+ const SUPPORTED_STRATEGIES : SessionVerificationSecondFactor [ 'strategy' ] [ ] = [
27
+ 'phone_code' ,
28
+ 'totp' ,
29
+ 'backup_code' ,
30
+ ] as const ;
31
+
26
32
export function UserVerificationFactorTwoComponent ( ) : JSX . Element {
27
33
const { navigate } = useRouter ( ) ;
28
34
const { data } = useUserVerificationSession ( ) ;
29
35
const sessionVerification = data as SessionVerificationResource ;
30
36
31
37
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
+ ) ;
33
43
} , [ sessionVerification . supportedSecondFactors ] ) ;
34
44
35
45
const lastPreparedFactorKeyRef = React . useRef ( '' ) ;
You can’t perform that action at this time.
0 commit comments