Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable Security Alerts API #11770

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .js.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ 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"
export MM_SECURITY_ALERTS_API_ENABLED="true"
# Firebase
export FCM_CONFIG_API_KEY=""
export FCM_CONFIG_AUTH_DOMAIN=""
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
5 changes: 3 additions & 2 deletions 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 All @@ -10,7 +11,7 @@ export interface SecurityAlertsAPIRequest {
}

export function isSecurityAlertsAPIEnabled() {
return process.env.SECURITY_ALERTS_API_ENABLED === 'true';
return process.env.MM_SECURITY_ALERTS_API_ENABLED === 'true';
}

export async function validateWithSecurityAlertsAPI(
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 @@ -1504,6 +1504,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
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ process.env.SEGMENT_REGULATIONS_ENDPOINT = 'TestRegulationsEndpoint';

process.env.MM_FOX_CODE = 'EXAMPLE_FOX_CODE';

process.env.SECURITY_ALERTS_API_ENABLED = 'true';
process.env.MM_SECURITY_ALERTS_API_ENABLED = 'true';
process.env.SECURITY_ALERTS_API_URL = 'https://example.com';

process.env.REDESIGNED_SIGNATURE_REQUEST = 'true';
Expand Down
Loading