MCPcopy Index your code
hub / github.com/codeaashu/claude-code / checkSecurityRestrictionGate

Function checkSecurityRestrictionGate

src/services/analytics/growthbook.ts:851–889  ·  view source on GitHub ↗
(
  gate: string,
)

Source from the content-addressed store, hash-verified

849 * if the Statsig cache indicates the gate is enabled, we honor it.
850 */
851export async function checkSecurityRestrictionGate(
852 gate: string,
853): Promise<boolean> {
854 // Check env var overrides first (for eval harnesses)
855 const overrides = getEnvOverrides()
856 if (overrides && gate in overrides) {
857 return Boolean(overrides[gate])
858 }
859 const configOverrides = getConfigOverrides()
860 if (configOverrides && gate in configOverrides) {
861 return Boolean(configOverrides[gate])
862 }
863
864 if (!isGrowthBookEnabled()) {
865 return false
866 }
867
868 // If re-initialization is in progress, wait for it to complete
869 // This ensures we get fresh values after auth changes
870 if (reinitializingPromise) {
871 await reinitializingPromise
872 }
873
874 // Check Statsig cache first - it may have correct value from previous logged-in session
875 const config = getGlobalConfig()
876 const statsigCached = config.cachedStatsigGates?.[gate]
877 if (statsigCached !== undefined) {
878 return Boolean(statsigCached)
879 }
880
881 // Then check GrowthBook cache
882 const gbCached = config.cachedGrowthBookFeatures?.[gate]
883 if (gbCached !== undefined) {
884 return Boolean(gbCached)
885 }
886
887 // No cache - return false (don't block on init for uncached gates)
888 return false
889}
890
891/**
892 * Check a boolean entitlement gate with fallback-to-blocking semantics.

Callers 1

Calls 4

getEnvOverridesFunction · 0.85
getConfigOverridesFunction · 0.85
isGrowthBookEnabledFunction · 0.85
getGlobalConfigFunction · 0.85

Tested by

no test coverage detected