1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-22 17:33:23 +01:00
metamask-extension/shared/modules/security-provider.utils.ts
Ariella Vu 34375a57e5
Security Provider cleanup (#19694)
* security-prov: isFlaggedSecurityProviderResponse

* security-prov: create shared/modules/util

* security prov: rn isFlagged -> isSuspcious
- util fn returns true if response is not verified and flagged

* security prov: add util test
and support undefined param

* security prov: reorg util fn
- no logic changes
2023-06-23 20:08:22 +02:00

20 lines
601 B
TypeScript

import { Json } from '@metamask/utils';
import { SECURITY_PROVIDER_MESSAGE_SEVERITY } from '../constants/security-provider';
export function isSuspiciousResponse(
securityProviderResponse: Record<string, Json> | undefined,
): boolean {
if (!securityProviderResponse) {
return false;
}
const isFlagged =
securityProviderResponse.flagAsDangerous !== undefined &&
securityProviderResponse.flagAsDangerous !==
SECURITY_PROVIDER_MESSAGE_SEVERITY.NOT_MALICIOUS;
const isNotVerified = Object.keys(securityProviderResponse).length === 0;
return isFlagged || isNotVerified;
}