@@ -3,30 +3,15 @@ import type { Attribute } from '@clerk/shared/types';
33import { useEnvironment } from '../contexts/EnvironmentContext' ;
44import { useEnabledThirdPartyProviders } from './useEnabledThirdPartyProviders' ;
55
6- /**
7- * Calculates the total count of all enabled authentication methods.
8- * This includes:
9- * - First factor identifiers (email_address, username, phone_number)
10- * - OAuth strategies
11- * - Web3 strategies
12- * - Alternative phone code channels
13- *
14- * Note: When both email and username are enabled, they count as 2 separate methods
15- * even though the UI may show them as one combined field.
16- */
176export const useTotalEnabledAuthMethods = ( ) : { totalCount : number } => {
187 const { userSettings } = useEnvironment ( ) ;
198 const { authenticatableOauthStrategies, web3Strategies, alternativePhoneCodeChannels } =
209 useEnabledThirdPartyProviders ( ) ;
2110
22- // Count enabled first factor identifiers
23- // Use the raw array (not grouped) to get accurate counts
24- // Filter out 'passkey' as it's not counted as a separate method in the UI
2511 const firstFactorCount = userSettings . enabledFirstFactorIdentifiers . filter (
2612 ( attr : Attribute ) => attr !== 'passkey' ,
2713 ) . length ;
2814
29- // Count third-party authentication methods
3015 const oauthCount = authenticatableOauthStrategies . length ;
3116 const web3Count = web3Strategies . length ;
3217 const alternativePhoneCodeCount = alternativePhoneCodeChannels . length ;
0 commit comments