From cfbaf46d991e5802648e6f2e7e624fe93eed99c1 Mon Sep 17 00:00:00 2001 From: Vinicius Stevam Date: Mon, 14 Oct 2024 10:19:08 +0100 Subject: [PATCH] feat: enable security alerts api --- .js.env.example | 2 +- app/core/AppConstants.ts | 4 ++++ app/lib/ppom/security-alerts-api.ts | 3 ++- bitrise.yml | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.js.env.example b/.js.env.example index 68e8316f034..1199f33bf2c 100644 --- a/.js.env.example +++ b/.js.env.example @@ -68,7 +68,7 @@ export SEGMENT_FLUSH_INTERVAL="1" export SEGMENT_FLUSH_EVENT_LIMIT="1" # URL of security alerts API used to validate dApp requests. -export SECURITY_ALERTS_API_URL="http://localhost:3000" +export SECURITY_ALERTS_API_URL="https://security-alerts.api.cx.metamask.io" # Temporary mechanism to enable security alerts API prior to release. export SECURITY_ALERTS_API_ENABLED="true" diff --git a/app/core/AppConstants.ts b/app/core/AppConstants.ts index 4999b670957..465bc585646 100644 --- a/app/core/AppConstants.ts +++ b/app/core/AppConstants.ts @@ -5,6 +5,7 @@ import { DEFAULT_SERVER_URL } from '@metamask/sdk-communication-layer'; const DEVELOPMENT = 'development'; const PORTFOLIO_URL = process.env.MM_PORTFOLIO_URL || 'https://portfolio.metamask.io'; +const SECURITY_ALERTS_API_URL = process.env.SECURITY_ALERTS_API_URL ?? 'https://security-alerts.api.cx.metamask.io'; export default { IS_DEV: process.env?.NODE_ENV === DEVELOPMENT, @@ -17,6 +18,9 @@ export default { SWARM_DEFAULT_GATEWAY_URL: 'https://swarm-gateways.net/bzz:/', supportedTLDs: ['eth', 'xyz', 'test'], MAX_PUSH_NOTIFICATION_PROMPT_TIMES: 2, + SECURITY_ALERTS_API: { + URL: SECURITY_ALERTS_API_URL, + }, PORTFOLIO: { URL: PORTFOLIO_URL, }, diff --git a/app/lib/ppom/security-alerts-api.ts b/app/lib/ppom/security-alerts-api.ts index 94737e28b8d..6d42f241944 100644 --- a/app/lib/ppom/security-alerts-api.ts +++ b/app/lib/ppom/security-alerts-api.ts @@ -1,5 +1,6 @@ import { Hex } from '@metamask/utils'; import { SecurityAlertResponse } from '../../components/Views/confirmations/components/BlockaidBanner/BlockaidBanner.types'; +import AppConstants from '../../core/AppConstants'; const ENDPOINT_VALIDATE = 'validate'; const ENDPOINT_SUPPORTED_CHAINS = 'supportedChains'; @@ -46,7 +47,7 @@ async function request(endpoint: string, options?: RequestInit) { } function getUrl(endpoint: string) { - const host = process.env.SECURITY_ALERTS_API_URL; + const host = AppConstants.SECURITY_ALERTS_API.URL; if (!host) { throw new Error('Security alerts API URL is not set'); diff --git a/bitrise.yml b/bitrise.yml index 4df0c76e2c4..6c8fdd0deb2 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -1465,6 +1465,9 @@ app: - opts: is_expand: false MM_POOLED_STAKING_UI_ENABLED: false + - opts: + is_expand: false + MM_SECURITY_ALERTS_API_ENABLED: true - opts: is_expand: false PROJECT_LOCATION: android