diff --git a/packages/console/src/consts/env.ts b/packages/console/src/consts/env.ts index bdfe997af..7af761d2a 100644 --- a/packages/console/src/consts/env.ts +++ b/packages/console/src/consts/env.ts @@ -6,4 +6,4 @@ export const isCloud = yes(process.env.IS_CLOUD); export const adminEndpoint = process.env.ADMIN_ENDPOINT; // eslint-disable-next-line unicorn/prevent-abbreviations -- we love dev export const isDevFeaturesEnabled = - yes(process.env.DEV_FEATURES_ENABLED) || yes(process.env.INTEGRATION_TEST); + !isProduction || yes(process.env.DEV_FEATURES_ENABLED) || yes(process.env.INTEGRATION_TEST); diff --git a/packages/core/src/libraries/sign-in-experience/mfa.ts b/packages/core/src/libraries/sign-in-experience/mfa.ts index d704c6a43..fa4b59b50 100644 --- a/packages/core/src/libraries/sign-in-experience/mfa.ts +++ b/packages/core/src/libraries/sign-in-experience/mfa.ts @@ -5,7 +5,7 @@ import assertThat from '#src/utils/assert-that.js'; export const validateMfa = (mfa: Mfa) => { // TODO @sijie: remove this check when MFA is ready for production. - if (EnvSet.values.isProduction && !EnvSet.values.isIntegrationTest) { + if (!EnvSet.values.isDevFeaturesEnabled) { throw new Error('MFA is not ready for production yet.'); } diff --git a/packages/experience/src/App.tsx b/packages/experience/src/App.tsx index 1c6e39631..c31443236 100644 --- a/packages/experience/src/App.tsx +++ b/packages/experience/src/App.tsx @@ -7,7 +7,7 @@ import AppBoundary from './Providers/AppBoundary'; import LoadingLayerProvider from './Providers/LoadingLayerProvider'; import PageContextProvider from './Providers/PageContextProvider'; import SettingsProvider from './Providers/SettingsProvider'; -import { isDevelopmentFeaturesEnabled } from './constants/env'; +import { isDevFeaturesEnabled as isDevelopmentFeaturesEnabled } from './constants/env'; import Callback from './pages/Callback'; import Consent from './pages/Consent'; import Continue from './pages/Continue'; diff --git a/packages/experience/src/constants/env.ts b/packages/experience/src/constants/env.ts index d98764a31..a53651b16 100644 --- a/packages/experience/src/constants/env.ts +++ b/packages/experience/src/constants/env.ts @@ -1,4 +1,7 @@ import { yes } from '@silverhand/essentials'; -export const isDevelopmentFeaturesEnabled = - yes(process.env.DEV_FEATURES_ENABLED) || yes(process.env.INTEGRATION_TEST); +// eslint-disable-next-line unicorn/prevent-abbreviations -- keep the same as in other packages +export const isDevFeaturesEnabled = + process.env.NODE_ENV !== 'production' || + yes(process.env.DEV_FEATURES_ENABLED) || + yes(process.env.INTEGRATION_TEST); diff --git a/packages/experience/src/hooks/use-pre-sign-in-error-handler.ts b/packages/experience/src/hooks/use-pre-sign-in-error-handler.ts index 5f03eabb3..94193654e 100644 --- a/packages/experience/src/hooks/use-pre-sign-in-error-handler.ts +++ b/packages/experience/src/hooks/use-pre-sign-in-error-handler.ts @@ -1,7 +1,7 @@ import { conditional } from '@silverhand/essentials'; import { useMemo } from 'react'; -import { isDevelopmentFeaturesEnabled } from '@/constants/env'; +import { isDevFeaturesEnabled } from '@/constants/env'; import { type ErrorHandlers } from './use-error-handler'; import useMfaErrorHandler, { @@ -20,7 +20,7 @@ const usePreSignInErrorHandler = ({ replace, linkSocial }: Options = {}): ErrorH return useMemo( () => ({ ...requiredProfileErrorHandler, - ...conditional(isDevelopmentFeaturesEnabled && mfaErrorHandler), + ...conditional(isDevFeaturesEnabled && mfaErrorHandler), }), [mfaErrorHandler, requiredProfileErrorHandler] ); diff --git a/packages/shared/src/node/env/GlobalValues.ts b/packages/shared/src/node/env/GlobalValues.ts index d6dcab756..9e1f27bd6 100644 --- a/packages/shared/src/node/env/GlobalValues.ts +++ b/packages/shared/src/node/env/GlobalValues.ts @@ -7,6 +7,8 @@ export default class GlobalValues { public readonly isProduction = getEnv('NODE_ENV') === 'production'; public readonly isIntegrationTest = yes(getEnv('INTEGRATION_TEST')); public readonly isUnitTest = getEnv('NODE_ENV') === 'test'; + public readonly isDevFeaturesEnabled = + !this.isProduction || yes(getEnv('DEV_FEATURES_ENABLED')) || this.isIntegrationTest; public readonly httpsCert = process.env.HTTPS_CERT_PATH; public readonly httpsKey = process.env.HTTPS_KEY_PATH;