LCOV - code coverage report
Current view: top level - src/composables/auth - useTurnstile.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 6 6
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { computed } from 'vue'
       2              : 
       3              : import {
       4              :   isTurnstileEnabled,
       5              :   normalizeTurnstileMode
       6              : } from '@comfyorg/account-core/turnstile'
       7              : 
       8              : import { getTurnstileSiteKey } from '@/config/turnstile'
       9              : import { useFeatureFlags } from '@/composables/useFeatureFlags'
      10              : import type { TurnstileMode } from '@/platform/remoteConfig/types'
      11              : 
      12              : export { useTurnstileGate } from '@comfyorg/account-ui/auth/turnstileGate'
      13              : 
      14              : /**
      15              :  * Reactive Turnstile state for the signup form.
      16              :  * - `enabled`: render the widget
      17              :  * - `enforced`: block submit until the challenge is solved
      18              :  *
      19              :  * Binds the shared resolution rules to this app's config sources: the
      20              :  * signupTurnstileMode feature flag and the per-env sitekey. OSS / local
      21              :  * builds resolve no sitekey — the real per-env keys are tree-shaken out via
      22              :  * the __DISTRIBUTION__ build define (see config/turnstile.ts) — so the widget
      23              :  * never renders there.
      24              :  */
      25            2 : export function useTurnstile() {
      26            2 :   const { flags } = useFeatureFlags()
      27            2 :   const mode = computed<TurnstileMode>(() =>
      28              :     normalizeTurnstileMode(flags.signupTurnstileMode)
      29              :   )
      30            2 :   const siteKey = computed(getTurnstileSiteKey)
      31            2 :   const enabled = computed(() => isTurnstileEnabled(mode.value, siteKey.value))
      32              :   const enforced = computed(() => enabled.value && mode.value === 'enforce')
      33              : 
      34            2 :   return { mode, siteKey, enabled, enforced }
      35              : }
        

Generated by: LCOV version 2.0-1