diff --git a/packages/connectors/connector-logto-email/src/constant.ts b/packages/connectors/connector-logto-email/src/constant.ts index bd47c8eed..78a79d657 100644 --- a/packages/connectors/connector-logto-email/src/constant.ts +++ b/packages/connectors/connector-logto-email/src/constant.ts @@ -1,3 +1,5 @@ +import { getEnv } from '@silverhand/essentials'; + import type { ConnectorMetadata } from '@logto/connector-kit'; import { ConnectorConfigFormItemType } from '@logto/connector-kit'; @@ -102,6 +104,9 @@ export const scope = ['send:email']; export const defaultTimeout = 5000; -export const emailEndpoint = '/services/mails'; +/** @deprecated Will be replaced by `/services/mails` soon. */ +export const demoEmailEndpoint = '/services/send-email'; +export const emailEndpoint = + getEnv('NODE_ENV') === 'production' ? demoEmailEndpoint : '/services/mails'; export const usageEndpoint = '/services/mails/usage'; diff --git a/packages/core/src/utils/connectors/index.ts b/packages/core/src/utils/connectors/index.ts index bf678d70a..19428e78b 100644 --- a/packages/core/src/utils/connectors/index.ts +++ b/packages/core/src/utils/connectors/index.ts @@ -8,6 +8,7 @@ import { connectorDirectory } from '@logto/cli/lib/constants.js'; import { getConnectorPackagesFromDirectory } from '@logto/cli/lib/utils.js'; import { demoConnectorIds, + serviceConnectorIds, ConnectorType, type EmailConnector, type SmsConnector, @@ -27,6 +28,14 @@ export const isPasswordlessLogtoConnector = ( ): connector is LogtoConnector => connector.type !== ConnectorType.Social; +/** + * Treat Logto service connectors as demo connectors in production since they are not available + * for public use yet. + */ +const isDemoConnector = (connectorId: string) => + demoConnectorIds.includes(connectorId) || + (EnvSet.values.isProduction && serviceConnectorIds.includes(connectorId)); + export const transpileLogtoConnector = async ( connector: LogtoConnector, extraInfo?: ConnectorResponse['extraInfo'] @@ -40,7 +49,8 @@ export const transpileLogtoConnector = async ( ); const { dbEntry, metadata, type } = connector; const { config, connectorId: id } = dbEntry; - const isDemo = demoConnectorIds.includes(id); + + const isDemo = isDemoConnector(id); return { type, @@ -61,7 +71,8 @@ export const transpileConnectorFactory = ({ return { type, ...metadata, - isDemo: demoConnectorIds.includes(metadata.id), + /** Temporarily block entering Logto email connector as well until this feature is ready for prod. */ + isDemo: isDemoConnector(metadata.id), }; };