Skip to content

Commit

Permalink
feat: enable security alerts api
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistevam committed Oct 14, 2024
1 parent 247686d commit cfbaf46
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .js.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions app/core/AppConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
Expand Down
3 changes: 2 additions & 1 deletion app/lib/ppom/security-alerts-api.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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');
Expand Down
3 changes: 3 additions & 0 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cfbaf46

Please sign in to comment.